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:
catlog22
2025-12-18 14:12:45 +08:00
parent e096fc98e2
commit 8dd4a513c8
52 changed files with 386 additions and 243 deletions

View File

@@ -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');
}
}
});
});

View File

@@ -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) {

View File

@@ -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',

View File

@@ -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;
}

View File

@@ -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');

View File

@@ -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 },