mirror of
https://github.com/catlog22/Claude-Code-Workflow.git
synced 2026-02-10 02:24:35 +08:00
Refactor CLI command usage from ccw cli exec to ccw cli -p for improved prompt handling
- Updated command patterns across documentation and templates to reflect the new CLI syntax. - Enhanced CLI tool implementation to support reading prompts from files and multi-line inputs. - Modified core components and views to ensure compatibility with the new command structure. - Adjusted help messages and internationalization strings to align with the updated command format. - Improved error handling and user notifications in the CLI execution flow.
This commit is contained in:
@@ -153,6 +153,8 @@ export function run(argv: string[]): void {
|
||||
program
|
||||
.command('cli [subcommand] [args...]')
|
||||
.description('Unified CLI tool executor (gemini/qwen/codex/claude)')
|
||||
.option('-p, --prompt <prompt>', 'Prompt text (alternative to positional argument)')
|
||||
.option('-f, --file <file>', 'Read prompt from file (best for multi-line prompts)')
|
||||
.option('--tool <tool>', 'CLI tool to use', 'gemini')
|
||||
.option('--mode <mode>', 'Execution mode: analysis, write, auto', 'analysis')
|
||||
.option('--model <model>', 'Model override')
|
||||
|
||||
@@ -58,6 +58,8 @@ function notifyDashboard(data: Record<string, unknown>): void {
|
||||
}
|
||||
|
||||
interface CliExecOptions {
|
||||
prompt?: string; // Prompt via --prompt/-p option (preferred for multi-line)
|
||||
file?: string; // Read prompt from file
|
||||
tool?: string;
|
||||
mode?: string;
|
||||
model?: string;
|
||||
@@ -269,6 +271,83 @@ function showStorageHelp(): void {
|
||||
console.log();
|
||||
}
|
||||
|
||||
/**
|
||||
* Test endpoint for debugging multi-line prompt parsing
|
||||
* Shows exactly how Commander.js parsed the arguments
|
||||
*/
|
||||
function testParseAction(args: string[], options: CliExecOptions): void {
|
||||
console.log(chalk.bold.cyan('\n ═══════════════════════════════════════════════'));
|
||||
console.log(chalk.bold.cyan(' │ CLI PARSE TEST ENDPOINT │'));
|
||||
console.log(chalk.bold.cyan(' ═══════════════════════════════════════════════\n'));
|
||||
|
||||
// Show args array parsing
|
||||
console.log(chalk.bold.yellow('📦 Positional Arguments (args[]):'));
|
||||
console.log(chalk.gray(' Length: ') + chalk.white(args.length));
|
||||
if (args.length === 0) {
|
||||
console.log(chalk.gray(' (empty)'));
|
||||
} else {
|
||||
args.forEach((arg, i) => {
|
||||
console.log(chalk.gray(` [${i}]: `) + chalk.green(`"${arg}"`));
|
||||
// Show if multiline
|
||||
if (arg.includes('\n')) {
|
||||
console.log(chalk.yellow(` ↳ Contains ${arg.split('\n').length} lines`));
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
console.log();
|
||||
|
||||
// Show options parsing
|
||||
console.log(chalk.bold.yellow('⚙️ Options:'));
|
||||
const optionEntries = Object.entries(options).filter(([_, v]) => v !== undefined);
|
||||
if (optionEntries.length === 0) {
|
||||
console.log(chalk.gray(' (none)'));
|
||||
} else {
|
||||
optionEntries.forEach(([key, value]) => {
|
||||
const displayValue = typeof value === 'string' && value.includes('\n')
|
||||
? `"${value.substring(0, 50)}..." (${value.split('\n').length} lines)`
|
||||
: JSON.stringify(value);
|
||||
console.log(chalk.gray(` --${key}: `) + chalk.cyan(displayValue));
|
||||
});
|
||||
}
|
||||
|
||||
console.log();
|
||||
|
||||
// Show what would be used as prompt
|
||||
console.log(chalk.bold.yellow('🎯 Final Prompt Resolution:'));
|
||||
const { prompt: optionPrompt, file } = options;
|
||||
|
||||
if (file) {
|
||||
console.log(chalk.gray(' Source: ') + chalk.magenta('--file/-f option'));
|
||||
console.log(chalk.gray(' File: ') + chalk.cyan(file));
|
||||
} else if (optionPrompt) {
|
||||
console.log(chalk.gray(' Source: ') + chalk.magenta('--prompt/-p option'));
|
||||
console.log(chalk.gray(' Value: ') + chalk.green(`"${optionPrompt.substring(0, 100)}${optionPrompt.length > 100 ? '...' : ''}"`));
|
||||
if (optionPrompt.includes('\n')) {
|
||||
console.log(chalk.yellow(` ↳ Multiline: ${optionPrompt.split('\n').length} lines`));
|
||||
}
|
||||
} else if (args[0]) {
|
||||
console.log(chalk.gray(' Source: ') + chalk.magenta('positional argument (args[0])'));
|
||||
console.log(chalk.gray(' Value: ') + chalk.green(`"${args[0].substring(0, 100)}${args[0].length > 100 ? '...' : ''}"`));
|
||||
if (args[0].includes('\n')) {
|
||||
console.log(chalk.yellow(` ↳ Multiline: ${args[0].split('\n').length} lines`));
|
||||
}
|
||||
} else {
|
||||
console.log(chalk.red(' No prompt found!'));
|
||||
}
|
||||
|
||||
console.log();
|
||||
|
||||
// Show raw debug info
|
||||
console.log(chalk.bold.yellow('🔍 Raw Debug Info:'));
|
||||
console.log(chalk.gray(' process.argv:'));
|
||||
process.argv.forEach((arg, i) => {
|
||||
console.log(chalk.gray(` [${i}]: `) + chalk.dim(arg.length > 60 ? arg.substring(0, 60) + '...' : arg));
|
||||
});
|
||||
|
||||
console.log(chalk.bold.cyan('\n ═══════════════════════════════════════════════\n'));
|
||||
}
|
||||
|
||||
/**
|
||||
* Show CLI tool status
|
||||
*/
|
||||
@@ -295,14 +374,42 @@ async function statusAction(): Promise<void> {
|
||||
* @param {string} prompt - Prompt to execute
|
||||
* @param {Object} options - CLI options
|
||||
*/
|
||||
async function execAction(prompt: string | undefined, options: CliExecOptions): Promise<void> {
|
||||
if (!prompt) {
|
||||
async function execAction(positionalPrompt: string | undefined, options: CliExecOptions): Promise<void> {
|
||||
const { prompt: optionPrompt, file, tool = 'gemini', mode = 'analysis', model, cd, includeDirs, timeout, noStream, resume, id, noNative } = options;
|
||||
|
||||
// Priority: 1. --file, 2. --prompt/-p option, 3. positional argument
|
||||
let finalPrompt: string | undefined;
|
||||
|
||||
if (file) {
|
||||
// Read from file
|
||||
const { readFileSync, existsSync } = await import('fs');
|
||||
const { resolve } = await import('path');
|
||||
const filePath = resolve(file);
|
||||
if (!existsSync(filePath)) {
|
||||
console.error(chalk.red(`Error: File not found: ${filePath}`));
|
||||
process.exit(1);
|
||||
}
|
||||
finalPrompt = readFileSync(filePath, 'utf8').trim();
|
||||
if (!finalPrompt) {
|
||||
console.error(chalk.red('Error: File is empty'));
|
||||
process.exit(1);
|
||||
}
|
||||
} else if (optionPrompt) {
|
||||
// Use --prompt/-p option (preferred for multi-line)
|
||||
finalPrompt = optionPrompt;
|
||||
} else {
|
||||
// Fall back to positional argument
|
||||
finalPrompt = positionalPrompt;
|
||||
}
|
||||
|
||||
if (!finalPrompt) {
|
||||
console.error(chalk.red('Error: Prompt is required'));
|
||||
console.error(chalk.gray('Usage: ccw cli exec "<prompt>" --tool gemini'));
|
||||
console.error(chalk.gray('Usage: ccw cli -p "<prompt>" --tool gemini'));
|
||||
console.error(chalk.gray(' or: ccw cli -f prompt.txt --tool codex'));
|
||||
process.exit(1);
|
||||
}
|
||||
|
||||
const { tool = 'gemini', mode = 'analysis', model, cd, includeDirs, timeout, noStream, resume, id, noNative } = options;
|
||||
const prompt_to_use = finalPrompt;
|
||||
|
||||
// Parse resume IDs for merge scenario
|
||||
const resumeIds = resume && typeof resume === 'string' ? resume.split(',').map(s => s.trim()).filter(Boolean) : [];
|
||||
@@ -333,7 +440,7 @@ async function execAction(prompt: string | undefined, options: CliExecOptions):
|
||||
event: 'started',
|
||||
tool,
|
||||
mode,
|
||||
prompt_preview: prompt.substring(0, 100) + (prompt.length > 100 ? '...' : ''),
|
||||
prompt_preview: prompt_to_use.substring(0, 100) + (prompt_to_use.length > 100 ? '...' : ''),
|
||||
custom_id: id || null
|
||||
});
|
||||
|
||||
@@ -345,7 +452,7 @@ async function execAction(prompt: string | undefined, options: CliExecOptions):
|
||||
try {
|
||||
const result = await cliExecutorTool.execute({
|
||||
tool,
|
||||
prompt,
|
||||
prompt: prompt_to_use,
|
||||
mode,
|
||||
model,
|
||||
cd,
|
||||
@@ -398,7 +505,7 @@ async function execAction(prompt: string | undefined, options: CliExecOptions):
|
||||
console.error(chalk.red(result.stderr));
|
||||
}
|
||||
|
||||
// Notify dashboard: execution failed
|
||||
// Notify dashboard: execution failccw cli -p
|
||||
notifyDashboard({
|
||||
event: 'completed',
|
||||
tool,
|
||||
@@ -535,7 +642,7 @@ function getTimeAgo(date: Date): string {
|
||||
return date.toLocaleDateString();
|
||||
}
|
||||
|
||||
/**
|
||||
/**ccw cli -p
|
||||
* CLI command entry point
|
||||
* @param {string} subcommand - Subcommand (status, exec, history, detail)
|
||||
* @param {string[]} args - Arguments array
|
||||
@@ -553,10 +660,6 @@ export async function cliCommand(
|
||||
await statusAction();
|
||||
break;
|
||||
|
||||
case 'exec':
|
||||
await execAction(argsArray[0], options as CliExecOptions);
|
||||
break;
|
||||
|
||||
case 'history':
|
||||
await historyAction(options as HistoryOptions);
|
||||
break;
|
||||
@@ -569,42 +672,62 @@ export async function cliCommand(
|
||||
await storageAction(argsArray[0], options as unknown as StorageOptions);
|
||||
break;
|
||||
|
||||
default:
|
||||
console.log(chalk.bold.cyan('\n CCW CLI Tool Executor\n'));
|
||||
console.log(' Unified interface for Gemini, Qwen, and Codex CLI tools.\n');
|
||||
console.log(' Subcommands:');
|
||||
console.log(chalk.gray(' status Check CLI tools availability'));
|
||||
console.log(chalk.gray(' storage [cmd] Manage CCW storage (info/clean/config)'));
|
||||
console.log(chalk.gray(' exec <prompt> Execute a CLI tool'));
|
||||
console.log(chalk.gray(' history Show execution history'));
|
||||
console.log(chalk.gray(' detail <id> Show execution detail'));
|
||||
console.log();
|
||||
console.log(' Exec Options:');
|
||||
console.log(chalk.gray(' --tool <tool> Tool to use: gemini, qwen, codex (default: gemini)'));
|
||||
console.log(chalk.gray(' --mode <mode> Mode: analysis, write, auto (default: analysis)'));
|
||||
console.log(chalk.gray(' --model <model> Model override'));
|
||||
console.log(chalk.gray(' --cd <path> Working directory'));
|
||||
console.log(chalk.gray(' --includeDirs <dirs> Additional directories (comma-separated)'));
|
||||
console.log(chalk.gray(' → gemini/qwen: --include-directories'));
|
||||
console.log(chalk.gray(' → codex: --add-dir'));
|
||||
console.log(chalk.gray(' --timeout <ms> Timeout in milliseconds (default: 300000)'));
|
||||
console.log(chalk.gray(' --no-stream Disable streaming output'));
|
||||
console.log(chalk.gray(' --resume [id] Resume previous session (empty=last, or execution ID)'));
|
||||
console.log(chalk.gray(' --id <id> Custom execution ID (e.g., IMPL-001-step1)'));
|
||||
console.log();
|
||||
console.log(' History Options:');
|
||||
console.log(chalk.gray(' --limit <n> Number of results (default: 20)'));
|
||||
console.log(chalk.gray(' --tool <tool> Filter by tool'));
|
||||
console.log(chalk.gray(' --status <status> Filter by status'));
|
||||
console.log();
|
||||
console.log(' Examples:');
|
||||
console.log(chalk.gray(' ccw cli status'));
|
||||
console.log(chalk.gray(' ccw cli exec "Analyze the auth module" --tool gemini'));
|
||||
console.log(chalk.gray(' ccw cli exec "Analyze with context" --tool gemini --includeDirs ../shared,../types'));
|
||||
console.log(chalk.gray(' ccw cli exec "Implement feature" --tool codex --mode auto --includeDirs ./lib'));
|
||||
console.log(chalk.gray(' ccw cli exec "Continue analysis" --resume # Resume last session'));
|
||||
console.log(chalk.gray(' ccw cli exec "Continue..." --resume <id> --tool gemini # Resume specific session'));
|
||||
console.log(chalk.gray(' ccw cli history --tool gemini --limit 10'));
|
||||
console.log();
|
||||
case 'test-parse':
|
||||
// Test endpoint to debug multi-line prompt parsing
|
||||
testParseAction(argsArray, options as CliExecOptions);
|
||||
break;
|
||||
|
||||
default: {
|
||||
const execOptions = options as CliExecOptions;
|
||||
// Auto-exec if: has -p/--prompt, has --stdin, has --resume, or subcommand looks like a prompt
|
||||
const hasPromptOption = !!execOptions.prompt;
|
||||
const hasStdin = !!execOptions.stdin;
|
||||
const hasResume = execOptions.resume !== undefined;
|
||||
const subcommandIsPrompt = subcommand && !subcommand.startsWith('-');
|
||||
|
||||
if (hasPromptOption || hasStdin || hasResume || subcommandIsPrompt) {
|
||||
// Treat as exec: use subcommand as positional prompt if no -p option
|
||||
const positionalPrompt = subcommandIsPrompt ? subcommand : undefined;
|
||||
await execAction(positionalPrompt, execOptions);
|
||||
} else {
|
||||
// Show help
|
||||
console.log(chalk.bold.cyan('\n CCW CLI Tool Executor\n'));
|
||||
console.log(' Unified interface for Gemini, Qwen, and Codex CLI tools.\n');
|
||||
console.log(' Usage:');
|
||||
console.log(chalk.gray(' ccw cli -p "<prompt>" --tool <tool> Direct execution (recommended)'));
|
||||
console.log(chalk.gray(' ccw cli "<prompt>" --tool <tool> Shorthand'));
|
||||
console.log(chalk.gray(' ccw cli exec "<prompt>" --tool <tool> Explicit exec'));
|
||||
console.log();
|
||||
console.log(' Subcommands:');
|
||||
console.log(chalk.gray(' status Check CLI tools availability'));
|
||||
console.log(chalk.gray(' storage [cmd] Manage CCW storage (info/clean/config)'));
|
||||
console.log(chalk.gray(' exec <prompt> Execute a CLI tool (optional, default behavior)'));
|
||||
console.log(chalk.gray(' history Show execution history'));
|
||||
console.log(chalk.gray(' detail <id> Show execution detail'));
|
||||
console.log(chalk.gray(' test-parse [args] Debug CLI argument parsing'));
|
||||
console.log();
|
||||
console.log(' Exec Options:');
|
||||
console.log(chalk.gray(' -p, --prompt <text> Prompt text (preferred for multi-line)'));
|
||||
console.log(chalk.gray(' -f, --file <file> Read prompt from file'));
|
||||
console.log(chalk.gray(' --stdin Read prompt from stdin'));
|
||||
console.log(chalk.gray(' --tool <tool> Tool to use: gemini, qwen, codex (default: gemini)'));
|
||||
console.log(chalk.gray(' --mode <mode> Mode: analysis, write, auto (default: analysis)'));
|
||||
console.log(chalk.gray(' --model <model> Model override'));
|
||||
console.log(chalk.gray(' --cd <path> Working directory'));
|
||||
console.log(chalk.gray(' --includeDirs <dirs> Additional directories (comma-separated)'));
|
||||
console.log(chalk.gray(' ccw cli -ps> Timeout in milliseconds (default: 300000)'));
|
||||
console.log(chalk.gray(' --no-stream Disable streaming output'));
|
||||
console.log(chalk.gray(' --resume [id] Resume previous session'));
|
||||
console.log(chalk.gray(' --id <id> Custom execution ID'));
|
||||
console.log();
|
||||
console.log(' Examples:');
|
||||
console.log(chalk.gray(' ccw cli -p "Analyze auth module" --tool gemini'));
|
||||
console.log(chalk.gray(' ccw cli "Simple prompt" --tool codex --mode write'));
|
||||
console.log(chalk.gray(' ccw cli -p "$(cat prompt.txt)" --tool gemini'));
|
||||
console.log(chalk.gray(' ccw cli --resume --tool gemini'));
|
||||
console.log(chalk.gray(' ccw cli history --tool gemini --limit 10'));
|
||||
console.log();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -68,7 +68,8 @@ const MODULE_CSS_FILES = [
|
||||
'13-claude-manager.css',
|
||||
'14-graph-explorer.css',
|
||||
'15-mcp-manager.css',
|
||||
'16-help.css'
|
||||
'16-help.css',
|
||||
'17-core-memory.css'
|
||||
];
|
||||
|
||||
// Modular JS files in dependency order
|
||||
@@ -82,41 +83,45 @@ const MODULE_FILES = [
|
||||
'components/modals.js',
|
||||
'components/navigation.js',
|
||||
'components/sidebar.js',
|
||||
'components/tabs-context.js',
|
||||
'components/tabs-other.js',
|
||||
'components/task-drawer-core.js',
|
||||
'components/task-drawer-renderers.js',
|
||||
'components/flowchart.js',
|
||||
'components/carousel.js',
|
||||
'components/notifications.js',
|
||||
'components/global-notifications.js',
|
||||
'components/version-check.js',
|
||||
'components/mcp-manager.js',
|
||||
'components/hook-manager.js',
|
||||
'components/task-queue-sidebar.js',
|
||||
'components/cli-status.js',
|
||||
'components/cli-history.js',
|
||||
'components/mcp-manager.js',
|
||||
'components/hook-manager.js',
|
||||
'components/version-check.js',
|
||||
'components/storage-manager.js',
|
||||
'components/index-manager.js',
|
||||
'components/_exp_helpers.js',
|
||||
'components/tabs-other.js',
|
||||
'components/tabs-context.js',
|
||||
'components/_conflict_tab.js',
|
||||
'components/_review_tab.js',
|
||||
'components/task-drawer-core.js',
|
||||
'components/task-drawer-renderers.js',
|
||||
'components/task-queue-sidebar.js',
|
||||
'components/flowchart.js',
|
||||
'views/home.js',
|
||||
'views/project-overview.js',
|
||||
'views/session-detail.js',
|
||||
'views/review-session.js',
|
||||
'views/lite-tasks.js',
|
||||
'views/fix-session.js',
|
||||
'views/cli-manager.js',
|
||||
'views/codexlens-manager.js',
|
||||
'views/explorer.js',
|
||||
'views/mcp-manager.js',
|
||||
'views/hook-manager.js',
|
||||
'views/cli-manager.js',
|
||||
'views/history.js',
|
||||
'views/explorer.js',
|
||||
'views/graph-explorer.js',
|
||||
'views/memory.js',
|
||||
'views/core-memory.js',
|
||||
'views/core-memory-graph.js',
|
||||
'views/prompt-history.js',
|
||||
'views/skills-manager.js',
|
||||
'views/rules-manager.js',
|
||||
'views/claude-manager.js',
|
||||
'views/graph-explorer.js',
|
||||
'views/help.js',
|
||||
'main.js'
|
||||
];
|
||||
|
||||
@@ -138,7 +138,11 @@ function initNavigation() {
|
||||
} else if (currentView === 'help') {
|
||||
renderHelpView();
|
||||
} else if (currentView === 'core-memory') {
|
||||
renderCoreMemoryView();
|
||||
if (typeof renderCoreMemoryView === 'function') {
|
||||
renderCoreMemoryView();
|
||||
} else {
|
||||
console.error('renderCoreMemoryView not defined - please refresh the page');
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
@@ -208,7 +208,7 @@ function handleNotification(data) {
|
||||
break;
|
||||
|
||||
case 'cli_execution':
|
||||
// Handle CLI command notifications (ccw cli exec)
|
||||
// Handle CLI command notifications (ccw cli -p)
|
||||
handleCliCommandNotification(payload);
|
||||
break;
|
||||
|
||||
@@ -500,7 +500,7 @@ function handleToolExecutionNotification(payload) {
|
||||
}
|
||||
|
||||
/**
|
||||
* Handle CLI command notifications (ccw cli exec)
|
||||
* Handle CLI command notifications (ccw cli -p)
|
||||
* @param {Object} payload - CLI execution payload
|
||||
*/
|
||||
function handleCliCommandNotification(payload) {
|
||||
|
||||
@@ -67,9 +67,9 @@ var helpI18n = {
|
||||
'help.workflows.brainstorm.next': '进入规划阶段',
|
||||
|
||||
// Workflow Steps - CLI Resume
|
||||
'help.workflows.cliResume.firstExec': 'ccw cli exec "分析..."',
|
||||
'help.workflows.cliResume.firstExec': 'ccw cli -p "分析..."',
|
||||
'help.workflows.cliResume.saveContext': '保存会话上下文',
|
||||
'help.workflows.cliResume.resumeCmd': 'ccw cli exec --resume',
|
||||
'help.workflows.cliResume.resumeCmd': 'ccw cli -p --resume',
|
||||
'help.workflows.cliResume.merge': '合并历史对话',
|
||||
'help.workflows.cliResume.continue': '继续执行任务',
|
||||
'help.workflows.cliResume.splitOutput': '拆分结果存储',
|
||||
@@ -188,9 +188,9 @@ var helpI18n = {
|
||||
'help.workflows.brainstorm.next': 'Enter Planning Phase',
|
||||
|
||||
// Workflow Steps - CLI Resume
|
||||
'help.workflows.cliResume.firstExec': 'ccw cli exec "analyze..."',
|
||||
'help.workflows.cliResume.firstExec': 'ccw cli -p "analyze..."',
|
||||
'help.workflows.cliResume.saveContext': 'Save Session Context',
|
||||
'help.workflows.cliResume.resumeCmd': 'ccw cli exec --resume',
|
||||
'help.workflows.cliResume.resumeCmd': 'ccw cli -p --resume',
|
||||
'help.workflows.cliResume.merge': 'Merge Conversation History',
|
||||
'help.workflows.cliResume.continue': 'Continue Execution',
|
||||
'help.workflows.cliResume.splitOutput': 'Split & Store Results',
|
||||
|
||||
@@ -87,7 +87,7 @@ function renderKnowledgeGraphD3(graph) {
|
||||
}));
|
||||
|
||||
// Create SVG with zoom support
|
||||
graphSvg = d3.select('#knowledgeGraphContainer')
|
||||
coreMemGraphSvg = d3.select('#knowledgeGraphContainer')
|
||||
.append('svg')
|
||||
.attr('width', width)
|
||||
.attr('height', height)
|
||||
@@ -95,19 +95,19 @@ function renderKnowledgeGraphD3(graph) {
|
||||
.attr('viewBox', [0, 0, width, height]);
|
||||
|
||||
// Create a group for zoom/pan transformations
|
||||
graphGroup = graphSvg.append('g').attr('class', 'graph-content');
|
||||
coreMemGraphGroup = coreMemGraphSvg.append('g').attr('class', 'graph-content');
|
||||
|
||||
// Setup zoom behavior
|
||||
graphZoom = d3.zoom()
|
||||
coreMemGraphZoom = d3.zoom()
|
||||
.scaleExtent([0.1, 4])
|
||||
.on('zoom', (event) => {
|
||||
graphGroup.attr('transform', event.transform);
|
||||
coreMemGraphGroup.attr('transform', event.transform);
|
||||
});
|
||||
|
||||
graphSvg.call(graphZoom);
|
||||
coreMemGraphSvg.call(coreMemGraphZoom);
|
||||
|
||||
// Add arrowhead marker
|
||||
graphSvg.append('defs').append('marker')
|
||||
coreMemGraphSvg.append('defs').append('marker')
|
||||
.attr('id', 'arrowhead-core')
|
||||
.attr('viewBox', '-0 -5 10 10')
|
||||
.attr('refX', 20)
|
||||
@@ -122,7 +122,7 @@ function renderKnowledgeGraphD3(graph) {
|
||||
.style('stroke', 'none');
|
||||
|
||||
// Create force simulation
|
||||
graphSimulation = d3.forceSimulation(nodes)
|
||||
coreMemGraphSimulation = d3.forceSimulation(nodes)
|
||||
.force('link', d3.forceLink(edges).id(d => d.id).distance(100))
|
||||
.force('charge', d3.forceManyBody().strength(-300))
|
||||
.force('center', d3.forceCenter(width / 2, height / 2))
|
||||
@@ -131,7 +131,7 @@ function renderKnowledgeGraphD3(graph) {
|
||||
.force('y', d3.forceY(height / 2).strength(0.05));
|
||||
|
||||
// Draw edges
|
||||
const link = graphGroup.append('g')
|
||||
const link = coreMemGraphGroup.append('g')
|
||||
.attr('class', 'graph-links')
|
||||
.selectAll('line')
|
||||
.data(edges)
|
||||
@@ -143,7 +143,7 @@ function renderKnowledgeGraphD3(graph) {
|
||||
.attr('marker-end', 'url(#arrowhead-core)');
|
||||
|
||||
// Draw nodes
|
||||
const node = graphGroup.append('g')
|
||||
const node = coreMemGraphGroup.append('g')
|
||||
.attr('class', 'graph-nodes')
|
||||
.selectAll('g')
|
||||
.data(nodes)
|
||||
@@ -183,7 +183,7 @@ function renderKnowledgeGraphD3(graph) {
|
||||
.attr('fill', '#333');
|
||||
|
||||
// Update positions on simulation tick
|
||||
graphSimulation.on('tick', () => {
|
||||
coreMemGraphSimulation.on('tick', () => {
|
||||
link
|
||||
.attr('x1', d => d.source.x)
|
||||
.attr('y1', d => d.source.y)
|
||||
@@ -195,7 +195,7 @@ function renderKnowledgeGraphD3(graph) {
|
||||
|
||||
// Drag functions
|
||||
function dragstarted(event, d) {
|
||||
if (!event.active) graphSimulation.alphaTarget(0.3).restart();
|
||||
if (!event.active) coreMemGraphSimulation.alphaTarget(0.3).restart();
|
||||
d.fx = d.x;
|
||||
d.fy = d.y;
|
||||
}
|
||||
@@ -206,7 +206,7 @@ function renderKnowledgeGraphD3(graph) {
|
||||
}
|
||||
|
||||
function dragended(event, d) {
|
||||
if (!event.active) graphSimulation.alphaTarget(0);
|
||||
if (!event.active) coreMemGraphSimulation.alphaTarget(0);
|
||||
d.fx = null;
|
||||
d.fy = null;
|
||||
}
|
||||
|
||||
@@ -1,15 +1,15 @@
|
||||
// Core Memory View
|
||||
// Manages strategic context entries with knowledge graph and evolution tracking
|
||||
|
||||
// State for visualization
|
||||
let graphSvg = null;
|
||||
let graphGroup = null;
|
||||
let graphZoom = null;
|
||||
let graphSimulation = null;
|
||||
// State for visualization (prefixed to avoid collision with memory.js)
|
||||
var coreMemGraphSvg = null;
|
||||
var coreMemGraphGroup = null;
|
||||
var coreMemGraphZoom = null;
|
||||
var coreMemGraphSimulation = null;
|
||||
|
||||
async function renderCoreMemoryView() {
|
||||
const content = document.getElementById('content');
|
||||
hideStatsAndSearch();
|
||||
hideStatsAndCarousel();
|
||||
|
||||
// Fetch core memories
|
||||
const archived = false;
|
||||
@@ -214,7 +214,8 @@ async function fetchCoreMemories(archived = false) {
|
||||
try {
|
||||
const response = await fetch(`/api/core-memory/memories?path=${encodeURIComponent(projectPath)}&archived=${archived}`);
|
||||
if (!response.ok) throw new Error(`HTTP ${response.status}`);
|
||||
return await response.json();
|
||||
const data = await response.json();
|
||||
return data.memories || [];
|
||||
} catch (error) {
|
||||
console.error('Failed to fetch core memories:', error);
|
||||
showNotification(t('coreMemory.fetchError'), 'error');
|
||||
@@ -226,7 +227,8 @@ async function fetchMemoryById(memoryId) {
|
||||
try {
|
||||
const response = await fetch(`/api/core-memory/memories/${memoryId}?path=${encodeURIComponent(projectPath)}`);
|
||||
if (!response.ok) throw new Error(`HTTP ${response.status}`);
|
||||
return await response.json();
|
||||
const data = await response.json();
|
||||
return data.memory || null;
|
||||
} catch (error) {
|
||||
console.error('Failed to fetch memory:', error);
|
||||
showNotification(t('coreMemory.fetchError'), 'error');
|
||||
|
||||
@@ -7,6 +7,7 @@ const CCW_MCP_TOOLS = [
|
||||
{ name: 'write_file', desc: 'Write/create files', core: true },
|
||||
{ name: 'edit_file', desc: 'Edit/replace content', core: true },
|
||||
{ name: 'smart_search', desc: 'Hybrid search (regex + semantic)', core: true },
|
||||
{ name: 'core_memory', desc: 'Core memory management', core: true },
|
||||
// Optional tools
|
||||
{ name: 'session_manager', desc: 'Workflow sessions', core: false },
|
||||
{ name: 'generate_module_docs', desc: 'Generate docs', core: false },
|
||||
|
||||
@@ -11,7 +11,7 @@ import { StoragePaths, ensureStorageDir } from '../config/storage-paths.js';
|
||||
|
||||
export interface CliToolConfig {
|
||||
enabled: boolean;
|
||||
primaryModel: string; // For CLI endpoint calls (ccw cli exec)
|
||||
primaryModel: string; // For CLI endpoint calls (ccw cli -p)
|
||||
secondaryModel: string; // For internal calls (llm_enhancer, generate_module_docs)
|
||||
}
|
||||
|
||||
|
||||
@@ -319,8 +319,9 @@ function buildCommand(params: {
|
||||
break;
|
||||
|
||||
case 'codex':
|
||||
// Codex does NOT support stdin - prompt must be passed as command line argument
|
||||
useStdin = false;
|
||||
// Codex supports stdin when using `-` as prompt argument
|
||||
// Using stdin avoids Windows command line escaping issues with multi-line/special char prompts
|
||||
useStdin = true;
|
||||
// Native resume: codex resume <uuid> [prompt] or --last
|
||||
if (nativeResume?.enabled) {
|
||||
args.push('resume');
|
||||
@@ -333,8 +334,13 @@ function buildCommand(params: {
|
||||
if (dir) {
|
||||
args.push('-C', dir);
|
||||
}
|
||||
// Permission configuration based on mode:
|
||||
// - analysis: --full-auto (read-only sandbox, no prompts) - safer for read operations
|
||||
// - write/auto: --dangerously-bypass-approvals-and-sandbox (full access for modifications)
|
||||
if (mode === 'write' || mode === 'auto') {
|
||||
args.push('--skip-git-repo-check', '-s', 'danger-full-access');
|
||||
args.push('--dangerously-bypass-approvals-and-sandbox');
|
||||
} else {
|
||||
args.push('--full-auto');
|
||||
}
|
||||
if (model) {
|
||||
args.push('-m', model);
|
||||
@@ -345,19 +351,21 @@ function buildCommand(params: {
|
||||
args.push('--add-dir', addDir);
|
||||
}
|
||||
}
|
||||
// Add prompt as positional argument for resume
|
||||
if (prompt) {
|
||||
args.push(prompt);
|
||||
}
|
||||
// Use `-` to indicate reading prompt from stdin
|
||||
args.push('-');
|
||||
} else {
|
||||
// Standard exec mode
|
||||
args.push('exec');
|
||||
if (dir) {
|
||||
args.push('-C', dir);
|
||||
}
|
||||
args.push('--full-auto');
|
||||
// Permission configuration based on mode:
|
||||
// - analysis: --full-auto (read-only sandbox, no prompts) - safer for read operations
|
||||
// - write/auto: --dangerously-bypass-approvals-and-sandbox (full access for modifications)
|
||||
if (mode === 'write' || mode === 'auto') {
|
||||
args.push('--skip-git-repo-check', '-s', 'danger-full-access');
|
||||
args.push('--dangerously-bypass-approvals-and-sandbox');
|
||||
} else {
|
||||
args.push('--full-auto');
|
||||
}
|
||||
if (model) {
|
||||
args.push('-m', model);
|
||||
@@ -368,10 +376,8 @@ function buildCommand(params: {
|
||||
args.push('--add-dir', addDir);
|
||||
}
|
||||
}
|
||||
// Add prompt as positional argument (codex exec "prompt")
|
||||
if (prompt) {
|
||||
args.push(prompt);
|
||||
}
|
||||
// Use `-` to indicate reading prompt from stdin (avoids Windows escaping issues)
|
||||
args.push('-');
|
||||
}
|
||||
break;
|
||||
|
||||
@@ -734,8 +740,8 @@ async function executeCliTool(
|
||||
}
|
||||
}
|
||||
|
||||
// Only pass model if explicitly provided - let CLI tools use their own defaults
|
||||
const effectiveModel = model;
|
||||
// Use configured primary model if no explicit model provided
|
||||
const effectiveModel = model || getPrimaryModel(workingDir, tool);
|
||||
|
||||
// Build command
|
||||
const { command, args, useStdin } = buildCommand({
|
||||
|
||||
Reference in New Issue
Block a user