feat: Enhance JSON streaming parsing and UI updates

- Added a function to parse JSON streaming content in core-memory.js, extracting readable text from messages.
- Updated memory detail view to utilize the new parsing function for content and summary.
- Introduced an enableReview option in rules-manager.js, allowing users to toggle review functionality in rule creation.
- Simplified skill creation modal in skills-manager.js by removing generation type selection UI.
- Improved CLI executor to handle tool calls for file writing, ensuring proper output parsing.
- Adjusted CLI command tests to set timeout to 0 for immediate execution.
- Updated file watcher to implement a true debounce mechanism and added a pending queue status for UI updates.
- Enhanced watcher manager to handle queue changes and provide JSON output for better integration with TypeScript backend.
- Established TypeScript naming conventions documentation to standardize code style across the project.
This commit is contained in:
catlog22
2026-01-07 21:51:26 +08:00
parent e9fb7be85f
commit 05514631f2
19 changed files with 1346 additions and 173 deletions

View File

@@ -205,6 +205,18 @@ class UnifiedStreamParser {
this.extractedText += item.text;
output += `[响应] ${item.text}\n`; // Add newline for proper line separation
}
// Extract content from write_file tool calls (for rules generation)
// Use type assertion to access tool_use properties
const anyItem = item as { type: string; name?: string; input?: { content?: string } };
if (anyItem.type === 'tool_use' && anyItem.input?.content && typeof anyItem.input.content === 'string') {
const toolName = anyItem.name || '';
// Check if this is a file write operation
if (toolName.includes('write_file') || toolName.includes('Write')) {
// Use the file content as extracted text (overwrite previous text response)
this.extractedText = anyItem.input.content;
output += `[工具] ${toolName}: 写入文件内容 (${anyItem.input.content.length} 字符)\n`;
}
}
}
}
@@ -1286,9 +1298,10 @@ async function executeCliTool(
stdout += text;
// Parse stream-json for all supported tools
if (streamParser && onOutput) {
// Always process chunks to populate extractedText, even without onOutput callback
if (streamParser) {
const parsedText = streamParser.processChunk(text);
if (parsedText) {
if (parsedText && onOutput) {
onOutput({ type: 'stdout', data: parsedText });
}
} else if (onOutput) {
@@ -1311,9 +1324,10 @@ async function executeCliTool(
currentChildProcess = null;
// Flush unified parser buffer if present
if (streamParser && onOutput) {
// Always flush to capture remaining content, even without onOutput callback
if (streamParser) {
const remaining = streamParser.flush();
if (remaining) {
if (remaining && onOutput) {
onOutput({ type: 'stdout', data: remaining });
}