feat: implement provider-side prompt caching and workflow scaffolding
ci / check (macos-latest) (push) Canceled after 0s
ci / check (ubuntu-latest) (push) Canceled after 0s
ci / check (windows-latest) (push) Canceled after 0s

- Added support for caching the stable prefix of the system prompt for Anthropic models.
- Introduced a new option `cacheSystemPrefix` in SessionOptions to enable caching.
- Implemented a nudge escalation system that reminds users to update the TODO.md file, capped at three nudges.
- Created a new `scaffoldWorkflowFiles` function to generate TODO.md, ROADMAP.md, and docs/ directory when they are missing.
- Updated the App component to scaffold workflow files during initialization.
- Added hooks functionality to allow external scripts to modify tool input and manage approvals.
- Implemented tests for the new hooks functionality, ensuring proper approval and execution flow.
This commit is contained in:
asepharyana committed 2026-09-09 20:11:23 +07:00
1 parent 4aeb0d2455
commit 7a1e415fea
12 files changed
+884 -32

No files matched your search

+6 -1
View File
@@ -91,6 +91,8 @@ export type AppHooks = {
};
/** Prompt to hand the model for /init. */
initPrompt: string;
/** Directly scaffold TODO.md / ROADMAP.md / docs/ when they are missing; returns what was written. */
scaffoldWorkflow: () => string[];
history: string[];
recordPrompt: (text: string) => void;
};
@@ -657,10 +659,13 @@ export function App({
setWorking(false);
return;
}
case 'init':
case 'init': {
push({ kind: 'user', text: chosen.trim() });
const written = hooks.scaffoldWorkflow();
if (written.length > 0) push({ kind: 'info', text: `scaffolded ${written.join(', ')}` });
await runTurn(hooks.initPrompt);
return;
}
case 'model':
push({ kind: 'user', text: chosen.trim() });
try {
+1 -1
View File
@@ -115,7 +115,7 @@ export function workflowPanel(session: Session): Panel {
['TODO.md', `${yes(w.hasTodo)}${w.hasTodo ? ` (${w.todoLines} lines)` : ''}`],
['ROADMAP.md', `${yes(w.hasRoadmap)}${w.hasRoadmap ? ` (${w.roadmapLines} lines)` : ''}`],
['docs dir', `${yes(w.hasDocs)}${w.hasDocs ? ` (${w.docsFiles} files)` : ''}`],
['reminders sent', w.nudged ? '1 (this session)' : 'none'],
['reminders sent', w.nudgeCount === 0 ? 'none' : `${w.nudgeCount}/3`],
];
const body = rows.map(([k, v]) => `${k}: ${v}`).join('\n');
return { title: 'workflow', body };