feat: add fork assistant message to new session
Add fork button on assistant messages to start new execution session Include synthetic meta-instruction when forking to explain context
This commit is contained in:
@@ -0,0 +1,8 @@
|
||||
export const EXECUTION_FORK_META_TEXT =
|
||||
"This message comes from an AI assistant in another session. The user wants you to respond according to its content: " +
|
||||
"if it is an implementation plan, your task is to implement that plan; " +
|
||||
"if it is a conclusion or summary, your task is to verify it, explain whether you agree or disagree, and correct it if needed. " +
|
||||
"Always clearly state what you understand your task to be, and wait for the user's approval of your conclusions before taking any further actions.";
|
||||
|
||||
export const isExecutionForkMetaText = (text: string | null | undefined): boolean =>
|
||||
typeof text === 'string' && text.trim() === EXECUTION_FORK_META_TEXT.trim();
|
||||
@@ -0,0 +1,13 @@
|
||||
import type { Part } from '@opencode-ai/sdk';
|
||||
|
||||
type TextLikePart = Part & { text?: string; content?: string };
|
||||
|
||||
export const flattenAssistantTextParts = (parts: Part[]): string => {
|
||||
const textParts = parts
|
||||
.filter((part): part is TextLikePart => part?.type === 'text')
|
||||
.map((part) => (part.text || part.content || '').trim())
|
||||
.filter((text) => text.length > 0);
|
||||
|
||||
const combined = textParts.join('\n');
|
||||
return combined.replace(/\n\s*\n+/g, '\n');
|
||||
};
|
||||
Reference in New Issue
Block a user