mirror of
https://github.com/ruvnet/ruflo.git
synced 2026-11-24 06:06:02 +09:00
🔖 Checkpoint: Edit /workspaces/claude-code-flow/src/cli/simple-commands/stream-chain.js
This commit is contained in:
1 parent
928bd34ec1
commit
4e6edc4efb
3 files changed
+37
-11
No files matched your search
@@ -0,0 +1 @@
|
||||
{"branch": "checkpoint/pre-edit-20250812-191256", "file": "/workspaces/claude-code-flow/src/cli/simple-commands/stream-chain.js", "timestamp": "2025-08-12T19:12:56Z", "type": "pre-edit", "original_branch": "alpha-89"}
|
||||
@@ -0,0 +1 @@
|
||||
{"tag": "checkpoint-20250812-191257", "file": "/workspaces/claude-code-flow/src/cli/simple-commands/stream-chain.js", "timestamp": "2025-08-12T19:12:58Z", "type": "post-edit", "branch": "alpha-89", "diff_summary": " .claude-flow/metrics/performance.json | 2 +- .claude-flow/metrics/system-metrics.json | 7274 ++---------------------------- .claude-flow/metrics/task-metrics.json | 6 +- .claude/checkpoints/task-1755025932.json | 1 + claude-flow-wiki | 0 src/cli/simple-commands/stream-chain.js | 37 +- 6 files changed, 442 insertions(+), 6878 deletions(-) "}
|
||||
@@ -68,22 +68,24 @@ async function executeRealChain(prompts, flags = {}) {
|
||||
}
|
||||
|
||||
/**
|
||||
* Filter stream-json to remove system messages and keep only user/assistant/result
|
||||
* Transform stream-json output to create proper input for next step
|
||||
* This converts the previous assistant's output into a user message for chaining
|
||||
*/
|
||||
function filterStreamJson(rawOutput) {
|
||||
function transformStreamForChaining(rawOutput, nextPrompt) {
|
||||
const lines = rawOutput.split('\n').filter(line => line.trim());
|
||||
const filtered = [];
|
||||
const messages = [];
|
||||
let assistantContent = '';
|
||||
|
||||
// Extract the assistant's response from the stream
|
||||
for (const line of lines) {
|
||||
try {
|
||||
const json = JSON.parse(line);
|
||||
// Keep only message types that --input-format accepts
|
||||
if (json.type === 'message' || json.type === 'tool_use' || json.type === 'tool_result' || json.type === 'result') {
|
||||
// For messages, ensure they have user or assistant role
|
||||
if (json.type === 'message' && json.role !== 'system') {
|
||||
filtered.push(line);
|
||||
} else if (json.type !== 'message') {
|
||||
filtered.push(line);
|
||||
if (json.type === 'message' && json.role === 'assistant' && json.content) {
|
||||
// Extract text content from assistant messages
|
||||
for (const content of json.content) {
|
||||
if (content.type === 'text' && content.text) {
|
||||
assistantContent += content.text + '\n';
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (e) {
|
||||
@@ -91,7 +93,29 @@ function filterStreamJson(rawOutput) {
|
||||
}
|
||||
}
|
||||
|
||||
return filtered.join('\n');
|
||||
// Create a user message with the previous output and new prompt
|
||||
if (assistantContent) {
|
||||
const userMessage = {
|
||||
type: 'message',
|
||||
role: 'user',
|
||||
content: [{
|
||||
type: 'text',
|
||||
text: `Previous step output:\n${assistantContent.trim()}\n\nNext step: ${nextPrompt}`
|
||||
}]
|
||||
};
|
||||
return JSON.stringify(userMessage);
|
||||
}
|
||||
|
||||
// Fallback: just create a user message with the prompt
|
||||
const fallbackMessage = {
|
||||
type: 'message',
|
||||
role: 'user',
|
||||
content: [{
|
||||
type: 'text',
|
||||
text: nextPrompt
|
||||
}]
|
||||
};
|
||||
return JSON.stringify(fallbackMessage);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in new issue
Block a user