feat: Enhance CLI components with icons and improve file editing capabilities

- Added icons to the CLI History and CLI Tools headers for better UI representation.
- Updated CLI Status component to include tool-specific classes for styling.
- Refactored CCW Install Panel to improve layout and functionality, including upgrade and uninstall buttons.
- Enhanced the edit-file tool with new features:
  - Support for creating parent directories when writing files.
  - Added dryRun mode for previewing changes without modifying files.
  - Implemented a unified diff output for changes made.
  - Enabled multi-edit support in update mode.
- Introduced a new Smart Search Tool with multiple search modes (auto, exact, fuzzy, semantic, graph) and intent classification.
- Created a Write File Tool to handle file creation and overwriting with backup options.
This commit is contained in:
catlog22
2025-12-11 23:06:47 +08:00
parent 15c5cd5f6e
commit e8f1caa219
13 changed files with 1087 additions and 113 deletions

View File

@@ -459,6 +459,58 @@ export async function startServer(options = {}) {
return;
}
// API: CCW Upgrade
if (pathname === '/api/ccw/upgrade' && req.method === 'POST') {
handlePostRequest(req, res, async (body) => {
const { path: installPath } = body;
try {
const { spawn } = await import('child_process');
// Run ccw upgrade command
const args = installPath ? ['upgrade', '--all'] : ['upgrade', '--all'];
const upgradeProcess = spawn('ccw', args, {
shell: true,
stdio: ['ignore', 'pipe', 'pipe']
});
let stdout = '';
let stderr = '';
upgradeProcess.stdout.on('data', (data) => {
stdout += data.toString();
});
upgradeProcess.stderr.on('data', (data) => {
stderr += data.toString();
});
return new Promise((resolve) => {
upgradeProcess.on('close', (code) => {
if (code === 0) {
resolve({ success: true, message: 'Upgrade completed', output: stdout });
} else {
resolve({ success: false, error: stderr || 'Upgrade failed', output: stdout, status: 500 });
}
});
upgradeProcess.on('error', (err) => {
resolve({ success: false, error: err.message, status: 500 });
});
// Timeout after 2 minutes
setTimeout(() => {
upgradeProcess.kill();
resolve({ success: false, error: 'Upgrade timed out', status: 504 });
}, 120000);
});
} catch (err) {
return { success: false, error: err.message, status: 500 };
}
});
return;
}
// API: CLI Execution History
if (pathname === '/api/cli/history') {
const projectPath = url.searchParams.get('path') || initialPath;