@handy_wote/pi-coding-agent 0.81.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +5107 -0
- package/README.md +694 -0
- package/dist/bun/cli.d.ts +3 -0
- package/dist/bun/cli.d.ts.map +1 -0
- package/dist/bun/cli.js +11 -0
- package/dist/bun/cli.js.map +1 -0
- package/dist/bun/register-bedrock.d.ts +2 -0
- package/dist/bun/register-bedrock.d.ts.map +1 -0
- package/dist/bun/register-bedrock.js +4 -0
- package/dist/bun/register-bedrock.js.map +1 -0
- package/dist/bun/restore-sandbox-env.d.ts +17 -0
- package/dist/bun/restore-sandbox-env.d.ts.map +1 -0
- package/dist/bun/restore-sandbox-env.js +36 -0
- package/dist/bun/restore-sandbox-env.js.map +1 -0
- package/dist/cli/args.d.ts +57 -0
- package/dist/cli/args.d.ts.map +1 -0
- package/dist/cli/args.js +381 -0
- package/dist/cli/args.js.map +1 -0
- package/dist/cli/config-selector.d.ts +16 -0
- package/dist/cli/config-selector.d.ts.map +1 -0
- package/dist/cli/config-selector.js +31 -0
- package/dist/cli/config-selector.js.map +1 -0
- package/dist/cli/file-processor.d.ts +15 -0
- package/dist/cli/file-processor.d.ts.map +1 -0
- package/dist/cli/file-processor.js +70 -0
- package/dist/cli/file-processor.js.map +1 -0
- package/dist/cli/initial-message.d.ts +18 -0
- package/dist/cli/initial-message.d.ts.map +1 -0
- package/dist/cli/initial-message.js +22 -0
- package/dist/cli/initial-message.js.map +1 -0
- package/dist/cli/list-models.d.ts +9 -0
- package/dist/cli/list-models.d.ts.map +1 -0
- package/dist/cli/list-models.js +95 -0
- package/dist/cli/list-models.js.map +1 -0
- package/dist/cli/project-trust.d.ts +10 -0
- package/dist/cli/project-trust.d.ts.map +1 -0
- package/dist/cli/project-trust.js +48 -0
- package/dist/cli/project-trust.js.map +1 -0
- package/dist/cli/session-picker.d.ts +10 -0
- package/dist/cli/session-picker.d.ts.map +1 -0
- package/dist/cli/session-picker.js +36 -0
- package/dist/cli/session-picker.js.map +1 -0
- package/dist/cli/startup-ui.d.ts +20 -0
- package/dist/cli/startup-ui.d.ts.map +1 -0
- package/dist/cli/startup-ui.js +184 -0
- package/dist/cli/startup-ui.js.map +1 -0
- package/dist/cli.d.ts +3 -0
- package/dist/cli.d.ts.map +1 -0
- package/dist/cli.js +18 -0
- package/dist/cli.js.map +1 -0
- package/dist/config.d.ts +98 -0
- package/dist/config.d.ts.map +1 -0
- package/dist/config.js +459 -0
- package/dist/config.js.map +1 -0
- package/dist/core/agent-session-runtime.d.ts +119 -0
- package/dist/core/agent-session-runtime.d.ts.map +1 -0
- package/dist/core/agent-session-runtime.js +306 -0
- package/dist/core/agent-session-runtime.js.map +1 -0
- package/dist/core/agent-session-services.d.ts +85 -0
- package/dist/core/agent-session-services.d.ts.map +1 -0
- package/dist/core/agent-session-services.js +133 -0
- package/dist/core/agent-session-services.js.map +1 -0
- package/dist/core/agent-session.d.ts +642 -0
- package/dist/core/agent-session.d.ts.map +1 -0
- package/dist/core/agent-session.js +2684 -0
- package/dist/core/agent-session.js.map +1 -0
- package/dist/core/auth-storage.d.ts +56 -0
- package/dist/core/auth-storage.d.ts.map +1 -0
- package/dist/core/auth-storage.js +232 -0
- package/dist/core/auth-storage.js.map +1 -0
- package/dist/core/bash-executor.d.ts +32 -0
- package/dist/core/bash-executor.d.ts.map +1 -0
- package/dist/core/bash-executor.js +111 -0
- package/dist/core/bash-executor.js.map +1 -0
- package/dist/core/cache-stats.d.ts +49 -0
- package/dist/core/cache-stats.d.ts.map +1 -0
- package/dist/core/cache-stats.js +101 -0
- package/dist/core/cache-stats.js.map +1 -0
- package/dist/core/compaction/branch-summarization.d.ts +98 -0
- package/dist/core/compaction/branch-summarization.d.ts.map +1 -0
- package/dist/core/compaction/branch-summarization.js +246 -0
- package/dist/core/compaction/branch-summarization.js.map +1 -0
- package/dist/core/compaction/compaction.d.ts +137 -0
- package/dist/core/compaction/compaction.d.ts.map +1 -0
- package/dist/core/compaction/compaction.js +637 -0
- package/dist/core/compaction/compaction.js.map +1 -0
- package/dist/core/compaction/index.d.ts +7 -0
- package/dist/core/compaction/index.d.ts.map +1 -0
- package/dist/core/compaction/index.js +7 -0
- package/dist/core/compaction/index.js.map +1 -0
- package/dist/core/compaction/utils.d.ts +38 -0
- package/dist/core/compaction/utils.d.ts.map +1 -0
- package/dist/core/compaction/utils.js +142 -0
- package/dist/core/compaction/utils.js.map +1 -0
- package/dist/core/defaults.d.ts +3 -0
- package/dist/core/defaults.d.ts.map +1 -0
- package/dist/core/defaults.js +2 -0
- package/dist/core/defaults.js.map +1 -0
- package/dist/core/diagnostics.d.ts +15 -0
- package/dist/core/diagnostics.d.ts.map +1 -0
- package/dist/core/diagnostics.js +2 -0
- package/dist/core/diagnostics.js.map +1 -0
- package/dist/core/event-bus.d.ts +9 -0
- package/dist/core/event-bus.d.ts.map +1 -0
- package/dist/core/event-bus.js +25 -0
- package/dist/core/event-bus.js.map +1 -0
- package/dist/core/exec.d.ts +29 -0
- package/dist/core/exec.d.ts.map +1 -0
- package/dist/core/exec.js +75 -0
- package/dist/core/exec.js.map +1 -0
- package/dist/core/experimental.d.ts +2 -0
- package/dist/core/experimental.d.ts.map +1 -0
- package/dist/core/experimental.js +4 -0
- package/dist/core/experimental.js.map +1 -0
- package/dist/core/export-html/ansi-to-html.d.ts +22 -0
- package/dist/core/export-html/ansi-to-html.d.ts.map +1 -0
- package/dist/core/export-html/ansi-to-html.js +249 -0
- package/dist/core/export-html/ansi-to-html.js.map +1 -0
- package/dist/core/export-html/index.d.ts +37 -0
- package/dist/core/export-html/index.d.ts.map +1 -0
- package/dist/core/export-html/index.js +226 -0
- package/dist/core/export-html/index.js.map +1 -0
- package/dist/core/export-html/template.css +1066 -0
- package/dist/core/export-html/template.html +55 -0
- package/dist/core/export-html/template.js +1864 -0
- package/dist/core/export-html/tool-renderer.d.ts +34 -0
- package/dist/core/export-html/tool-renderer.d.ts.map +1 -0
- package/dist/core/export-html/tool-renderer.js +108 -0
- package/dist/core/export-html/tool-renderer.js.map +1 -0
- package/dist/core/export-html/vendor/highlight.min.js +1213 -0
- package/dist/core/export-html/vendor/marked.min.js +78 -0
- package/dist/core/extensions/index.d.ts +12 -0
- package/dist/core/extensions/index.d.ts.map +1 -0
- package/dist/core/extensions/index.js +9 -0
- package/dist/core/extensions/index.js.map +1 -0
- package/dist/core/extensions/loader.d.ts +23 -0
- package/dist/core/extensions/loader.d.ts.map +1 -0
- package/dist/core/extensions/loader.js +586 -0
- package/dist/core/extensions/loader.js.map +1 -0
- package/dist/core/extensions/runner.d.ts +171 -0
- package/dist/core/extensions/runner.d.ts.map +1 -0
- package/dist/core/extensions/runner.js +953 -0
- package/dist/core/extensions/runner.js.map +1 -0
- package/dist/core/extensions/types.d.ts +1259 -0
- package/dist/core/extensions/types.d.ts.map +1 -0
- package/dist/core/extensions/types.js +45 -0
- package/dist/core/extensions/types.js.map +1 -0
- package/dist/core/extensions/wrapper.d.ts +20 -0
- package/dist/core/extensions/wrapper.d.ts.map +1 -0
- package/dist/core/extensions/wrapper.js +41 -0
- package/dist/core/extensions/wrapper.js.map +1 -0
- package/dist/core/footer-data-provider.d.ts +54 -0
- package/dist/core/footer-data-provider.d.ts.map +1 -0
- package/dist/core/footer-data-provider.js +338 -0
- package/dist/core/footer-data-provider.js.map +1 -0
- package/dist/core/http-dispatcher.d.ts +22 -0
- package/dist/core/http-dispatcher.d.ts.map +1 -0
- package/dist/core/http-dispatcher.js +91 -0
- package/dist/core/http-dispatcher.js.map +1 -0
- package/dist/core/index.d.ts +13 -0
- package/dist/core/index.d.ts.map +1 -0
- package/dist/core/index.js +13 -0
- package/dist/core/index.js.map +1 -0
- package/dist/core/keybindings.d.ts +390 -0
- package/dist/core/keybindings.d.ts.map +1 -0
- package/dist/core/keybindings.js +296 -0
- package/dist/core/keybindings.js.map +1 -0
- package/dist/core/messages.d.ts +77 -0
- package/dist/core/messages.d.ts.map +1 -0
- package/dist/core/messages.js +123 -0
- package/dist/core/messages.js.map +1 -0
- package/dist/core/model-metadata.d.ts +30 -0
- package/dist/core/model-metadata.d.ts.map +1 -0
- package/dist/core/model-metadata.js +139 -0
- package/dist/core/model-metadata.js.map +1 -0
- package/dist/core/model-registry.d.ts +48 -0
- package/dist/core/model-registry.d.ts.map +1 -0
- package/dist/core/model-registry.js +105 -0
- package/dist/core/model-registry.js.map +1 -0
- package/dist/core/model-resolver.d.ts +121 -0
- package/dist/core/model-resolver.d.ts.map +1 -0
- package/dist/core/model-resolver.js +534 -0
- package/dist/core/model-resolver.js.map +1 -0
- package/dist/core/model-runtime.d.ts +84 -0
- package/dist/core/model-runtime.d.ts.map +1 -0
- package/dist/core/model-runtime.js +453 -0
- package/dist/core/model-runtime.js.map +1 -0
- package/dist/core/models-store.d.ts +17 -0
- package/dist/core/models-store.d.ts.map +1 -0
- package/dist/core/models-store.js +45 -0
- package/dist/core/models-store.js.map +1 -0
- package/dist/core/output-guard.d.ts +7 -0
- package/dist/core/output-guard.d.ts.map +1 -0
- package/dist/core/output-guard.js +89 -0
- package/dist/core/output-guard.js.map +1 -0
- package/dist/core/package-manager.d.ts +210 -0
- package/dist/core/package-manager.d.ts.map +1 -0
- package/dist/core/package-manager.js +2135 -0
- package/dist/core/package-manager.js.map +1 -0
- package/dist/core/profile-runtime.d.ts +4 -0
- package/dist/core/profile-runtime.d.ts.map +1 -0
- package/dist/core/profile-runtime.js +57 -0
- package/dist/core/profile-runtime.js.map +1 -0
- package/dist/core/profiles-store.d.ts +17 -0
- package/dist/core/profiles-store.d.ts.map +1 -0
- package/dist/core/profiles-store.js +100 -0
- package/dist/core/profiles-store.js.map +1 -0
- package/dist/core/profiles-types.d.ts +31 -0
- package/dist/core/profiles-types.d.ts.map +1 -0
- package/dist/core/profiles-types.js +4 -0
- package/dist/core/profiles-types.js.map +1 -0
- package/dist/core/project-trust.d.ts +15 -0
- package/dist/core/project-trust.d.ts.map +1 -0
- package/dist/core/project-trust.js +59 -0
- package/dist/core/project-trust.js.map +1 -0
- package/dist/core/prompt-templates.d.ts +54 -0
- package/dist/core/prompt-templates.d.ts.map +1 -0
- package/dist/core/prompt-templates.js +236 -0
- package/dist/core/prompt-templates.js.map +1 -0
- package/dist/core/provider-attribution.d.ts +4 -0
- package/dist/core/provider-attribution.d.ts.map +1 -0
- package/dist/core/provider-attribution.js +72 -0
- package/dist/core/provider-attribution.js.map +1 -0
- package/dist/core/radius.d.ts +2 -0
- package/dist/core/radius.d.ts.map +1 -0
- package/dist/core/radius.js +2 -0
- package/dist/core/radius.js.map +1 -0
- package/dist/core/resource-loader.d.ts +206 -0
- package/dist/core/resource-loader.d.ts.map +1 -0
- package/dist/core/resource-loader.js +817 -0
- package/dist/core/resource-loader.js.map +1 -0
- package/dist/core/sdk.d.ts +106 -0
- package/dist/core/sdk.d.ts.map +1 -0
- package/dist/core/sdk.js +269 -0
- package/dist/core/sdk.js.map +1 -0
- package/dist/core/session-cwd.d.ts +19 -0
- package/dist/core/session-cwd.d.ts.map +1 -0
- package/dist/core/session-cwd.js +38 -0
- package/dist/core/session-cwd.js.map +1 -0
- package/dist/core/session-manager.d.ts +356 -0
- package/dist/core/session-manager.d.ts.map +1 -0
- package/dist/core/session-manager.js +1338 -0
- package/dist/core/session-manager.js.map +1 -0
- package/dist/core/settings-manager.d.ts +297 -0
- package/dist/core/settings-manager.d.ts.map +1 -0
- package/dist/core/settings-manager.js +902 -0
- package/dist/core/settings-manager.js.map +1 -0
- package/dist/core/skills.d.ts +60 -0
- package/dist/core/skills.d.ts.map +1 -0
- package/dist/core/skills.js +387 -0
- package/dist/core/skills.js.map +1 -0
- package/dist/core/slash-commands.d.ts +15 -0
- package/dist/core/slash-commands.d.ts.map +1 -0
- package/dist/core/slash-commands.js +25 -0
- package/dist/core/slash-commands.js.map +1 -0
- package/dist/core/source-info.d.ts +18 -0
- package/dist/core/source-info.d.ts.map +1 -0
- package/dist/core/source-info.js +19 -0
- package/dist/core/source-info.js.map +1 -0
- package/dist/core/system-prompt.d.ts +28 -0
- package/dist/core/system-prompt.d.ts.map +1 -0
- package/dist/core/system-prompt.js +110 -0
- package/dist/core/system-prompt.js.map +1 -0
- package/dist/core/telemetry.d.ts +3 -0
- package/dist/core/telemetry.d.ts.map +1 -0
- package/dist/core/telemetry.js +9 -0
- package/dist/core/telemetry.js.map +1 -0
- package/dist/core/timings.d.ts +10 -0
- package/dist/core/timings.d.ts.map +1 -0
- package/dist/core/timings.js +41 -0
- package/dist/core/timings.js.map +1 -0
- package/dist/core/tools/bash.d.ts +68 -0
- package/dist/core/tools/bash.d.ts.map +1 -0
- package/dist/core/tools/bash.js +361 -0
- package/dist/core/tools/bash.js.map +1 -0
- package/dist/core/tools/edit-diff.d.ts +106 -0
- package/dist/core/tools/edit-diff.d.ts.map +1 -0
- package/dist/core/tools/edit-diff.js +424 -0
- package/dist/core/tools/edit-diff.js.map +1 -0
- package/dist/core/tools/edit.d.ts +51 -0
- package/dist/core/tools/edit.d.ts.map +1 -0
- package/dist/core/tools/edit.js +284 -0
- package/dist/core/tools/edit.js.map +1 -0
- package/dist/core/tools/file-mutation-queue.d.ts +6 -0
- package/dist/core/tools/file-mutation-queue.d.ts.map +1 -0
- package/dist/core/tools/file-mutation-queue.js +52 -0
- package/dist/core/tools/file-mutation-queue.js.map +1 -0
- package/dist/core/tools/find.d.ts +35 -0
- package/dist/core/tools/find.d.ts.map +1 -0
- package/dist/core/tools/find.js +305 -0
- package/dist/core/tools/find.js.map +1 -0
- package/dist/core/tools/grep.d.ts +37 -0
- package/dist/core/tools/grep.d.ts.map +1 -0
- package/dist/core/tools/grep.js +304 -0
- package/dist/core/tools/grep.js.map +1 -0
- package/dist/core/tools/index.d.ts +40 -0
- package/dist/core/tools/index.d.ts.map +1 -0
- package/dist/core/tools/index.js +112 -0
- package/dist/core/tools/index.js.map +1 -0
- package/dist/core/tools/ls.d.ts +37 -0
- package/dist/core/tools/ls.d.ts.map +1 -0
- package/dist/core/tools/ls.js +167 -0
- package/dist/core/tools/ls.js.map +1 -0
- package/dist/core/tools/output-accumulator.d.ts +52 -0
- package/dist/core/tools/output-accumulator.d.ts.map +1 -0
- package/dist/core/tools/output-accumulator.js +184 -0
- package/dist/core/tools/output-accumulator.js.map +1 -0
- package/dist/core/tools/path-utils.d.ts +10 -0
- package/dist/core/tools/path-utils.d.ts.map +1 -0
- package/dist/core/tools/path-utils.js +99 -0
- package/dist/core/tools/path-utils.js.map +1 -0
- package/dist/core/tools/read.d.ts +35 -0
- package/dist/core/tools/read.d.ts.map +1 -0
- package/dist/core/tools/read.js +276 -0
- package/dist/core/tools/read.js.map +1 -0
- package/dist/core/tools/render-utils.d.ts +24 -0
- package/dist/core/tools/render-utils.d.ts.map +1 -0
- package/dist/core/tools/render-utils.js +65 -0
- package/dist/core/tools/render-utils.js.map +1 -0
- package/dist/core/tools/tool-definition-wrapper.d.ts +14 -0
- package/dist/core/tools/tool-definition-wrapper.d.ts.map +1 -0
- package/dist/core/tools/tool-definition-wrapper.js +34 -0
- package/dist/core/tools/tool-definition-wrapper.js.map +1 -0
- package/dist/core/tools/truncate.d.ts +70 -0
- package/dist/core/tools/truncate.d.ts.map +1 -0
- package/dist/core/tools/truncate.js +215 -0
- package/dist/core/tools/truncate.js.map +1 -0
- package/dist/core/tools/write.d.ts +26 -0
- package/dist/core/tools/write.d.ts.map +1 -0
- package/dist/core/tools/write.js +197 -0
- package/dist/core/tools/write.js.map +1 -0
- package/dist/core/trust-manager.d.ts +36 -0
- package/dist/core/trust-manager.d.ts.map +1 -0
- package/dist/core/trust-manager.js +202 -0
- package/dist/core/trust-manager.js.map +1 -0
- package/dist/core/usage-totals.d.ts +19 -0
- package/dist/core/usage-totals.d.ts.map +1 -0
- package/dist/core/usage-totals.js +52 -0
- package/dist/core/usage-totals.js.map +1 -0
- package/dist/extensions/index.d.ts +3 -0
- package/dist/extensions/index.d.ts.map +1 -0
- package/dist/extensions/index.js +3 -0
- package/dist/extensions/index.js.map +1 -0
- package/dist/extensions/llama/client.d.ts +61 -0
- package/dist/extensions/llama/client.d.ts.map +1 -0
- package/dist/extensions/llama/client.js +302 -0
- package/dist/extensions/llama/client.js.map +1 -0
- package/dist/extensions/llama/huggingface.d.ts +23 -0
- package/dist/extensions/llama/huggingface.d.ts.map +1 -0
- package/dist/extensions/llama/huggingface.js +141 -0
- package/dist/extensions/llama/huggingface.js.map +1 -0
- package/dist/extensions/llama/index.d.ts +3 -0
- package/dist/extensions/llama/index.d.ts.map +1 -0
- package/dist/extensions/llama/index.js +208 -0
- package/dist/extensions/llama/index.js.map +1 -0
- package/dist/extensions/llama/provider.d.ts +10 -0
- package/dist/extensions/llama/provider.d.ts.map +1 -0
- package/dist/extensions/llama/provider.js +102 -0
- package/dist/extensions/llama/provider.js.map +1 -0
- package/dist/extensions/llama/ui.d.ts +42 -0
- package/dist/extensions/llama/ui.d.ts.map +1 -0
- package/dist/extensions/llama/ui.js +416 -0
- package/dist/extensions/llama/ui.js.map +1 -0
- package/dist/index.d.ts +35 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +47 -0
- package/dist/index.js.map +1 -0
- package/dist/main.d.ts +12 -0
- package/dist/main.d.ts.map +1 -0
- package/dist/main.js +706 -0
- package/dist/main.js.map +1 -0
- package/dist/migrations.d.ts +33 -0
- package/dist/migrations.d.ts.map +1 -0
- package/dist/migrations.js +281 -0
- package/dist/migrations.js.map +1 -0
- package/dist/modes/index.d.ts +9 -0
- package/dist/modes/index.d.ts.map +1 -0
- package/dist/modes/index.js +8 -0
- package/dist/modes/index.js.map +1 -0
- package/dist/modes/interactive/assets/clankolas.png +0 -0
- package/dist/modes/interactive/components/armin.d.ts +34 -0
- package/dist/modes/interactive/components/armin.d.ts.map +1 -0
- package/dist/modes/interactive/components/armin.js +333 -0
- package/dist/modes/interactive/components/armin.js.map +1 -0
- package/dist/modes/interactive/components/assistant-message.d.ts +22 -0
- package/dist/modes/interactive/components/assistant-message.d.ts.map +1 -0
- package/dist/modes/interactive/components/assistant-message.js +141 -0
- package/dist/modes/interactive/components/assistant-message.js.map +1 -0
- package/dist/modes/interactive/components/bash-execution.d.ts +34 -0
- package/dist/modes/interactive/components/bash-execution.d.ts.map +1 -0
- package/dist/modes/interactive/components/bash-execution.js +175 -0
- package/dist/modes/interactive/components/bash-execution.js.map +1 -0
- package/dist/modes/interactive/components/bordered-loader.d.ts +16 -0
- package/dist/modes/interactive/components/bordered-loader.d.ts.map +1 -0
- package/dist/modes/interactive/components/bordered-loader.js +54 -0
- package/dist/modes/interactive/components/bordered-loader.js.map +1 -0
- package/dist/modes/interactive/components/branch-summary-message.d.ts +16 -0
- package/dist/modes/interactive/components/branch-summary-message.d.ts.map +1 -0
- package/dist/modes/interactive/components/branch-summary-message.js +44 -0
- package/dist/modes/interactive/components/branch-summary-message.js.map +1 -0
- package/dist/modes/interactive/components/compaction-summary-message.d.ts +16 -0
- package/dist/modes/interactive/components/compaction-summary-message.d.ts.map +1 -0
- package/dist/modes/interactive/components/compaction-summary-message.js +45 -0
- package/dist/modes/interactive/components/compaction-summary-message.js.map +1 -0
- package/dist/modes/interactive/components/config-selector.d.ts +102 -0
- package/dist/modes/interactive/components/config-selector.d.ts.map +1 -0
- package/dist/modes/interactive/components/config-selector.js +761 -0
- package/dist/modes/interactive/components/config-selector.js.map +1 -0
- package/dist/modes/interactive/components/countdown-timer.d.ts +14 -0
- package/dist/modes/interactive/components/countdown-timer.d.ts.map +1 -0
- package/dist/modes/interactive/components/countdown-timer.js +33 -0
- package/dist/modes/interactive/components/countdown-timer.js.map +1 -0
- package/dist/modes/interactive/components/custom-editor.d.ts +21 -0
- package/dist/modes/interactive/components/custom-editor.d.ts.map +1 -0
- package/dist/modes/interactive/components/custom-editor.js +70 -0
- package/dist/modes/interactive/components/custom-editor.js.map +1 -0
- package/dist/modes/interactive/components/custom-entry.d.ts +19 -0
- package/dist/modes/interactive/components/custom-entry.d.ts.map +1 -0
- package/dist/modes/interactive/components/custom-entry.js +52 -0
- package/dist/modes/interactive/components/custom-entry.js.map +1 -0
- package/dist/modes/interactive/components/custom-message.d.ts +20 -0
- package/dist/modes/interactive/components/custom-message.d.ts.map +1 -0
- package/dist/modes/interactive/components/custom-message.js +79 -0
- package/dist/modes/interactive/components/custom-message.js.map +1 -0
- package/dist/modes/interactive/components/daxnuts.d.ts +23 -0
- package/dist/modes/interactive/components/daxnuts.d.ts.map +1 -0
- package/dist/modes/interactive/components/daxnuts.js +140 -0
- package/dist/modes/interactive/components/daxnuts.js.map +1 -0
- package/dist/modes/interactive/components/diff.d.ts +12 -0
- package/dist/modes/interactive/components/diff.d.ts.map +1 -0
- package/dist/modes/interactive/components/diff.js +133 -0
- package/dist/modes/interactive/components/diff.js.map +1 -0
- package/dist/modes/interactive/components/dynamic-border.d.ts +15 -0
- package/dist/modes/interactive/components/dynamic-border.d.ts.map +1 -0
- package/dist/modes/interactive/components/dynamic-border.js +21 -0
- package/dist/modes/interactive/components/dynamic-border.js.map +1 -0
- package/dist/modes/interactive/components/earendil-announcement.d.ts +5 -0
- package/dist/modes/interactive/components/earendil-announcement.d.ts.map +1 -0
- package/dist/modes/interactive/components/earendil-announcement.js +40 -0
- package/dist/modes/interactive/components/earendil-announcement.js.map +1 -0
- package/dist/modes/interactive/components/entity-list-theme.d.ts +3 -0
- package/dist/modes/interactive/components/entity-list-theme.d.ts.map +1 -0
- package/dist/modes/interactive/components/entity-list-theme.js +17 -0
- package/dist/modes/interactive/components/entity-list-theme.js.map +1 -0
- package/dist/modes/interactive/components/extension-editor.d.ts +22 -0
- package/dist/modes/interactive/components/extension-editor.d.ts.map +1 -0
- package/dist/modes/interactive/components/extension-editor.js +128 -0
- package/dist/modes/interactive/components/extension-editor.js.map +1 -0
- package/dist/modes/interactive/components/extension-input.d.ts +23 -0
- package/dist/modes/interactive/components/extension-input.d.ts.map +1 -0
- package/dist/modes/interactive/components/extension-input.js +61 -0
- package/dist/modes/interactive/components/extension-input.js.map +1 -0
- package/dist/modes/interactive/components/extension-selector.d.ts +22 -0
- package/dist/modes/interactive/components/extension-selector.d.ts.map +1 -0
- package/dist/modes/interactive/components/extension-selector.js +61 -0
- package/dist/modes/interactive/components/extension-selector.js.map +1 -0
- package/dist/modes/interactive/components/first-time-setup.d.ts +24 -0
- package/dist/modes/interactive/components/first-time-setup.d.ts.map +1 -0
- package/dist/modes/interactive/components/first-time-setup.js +92 -0
- package/dist/modes/interactive/components/first-time-setup.js.map +1 -0
- package/dist/modes/interactive/components/footer.d.ts +32 -0
- package/dist/modes/interactive/components/footer.d.ts.map +1 -0
- package/dist/modes/interactive/components/footer.js +222 -0
- package/dist/modes/interactive/components/footer.js.map +1 -0
- package/dist/modes/interactive/components/index.d.ts +32 -0
- package/dist/modes/interactive/components/index.d.ts.map +1 -0
- package/dist/modes/interactive/components/index.js +33 -0
- package/dist/modes/interactive/components/index.js.map +1 -0
- package/dist/modes/interactive/components/keybinding-hints.d.ts +13 -0
- package/dist/modes/interactive/components/keybinding-hints.d.ts.map +1 -0
- package/dist/modes/interactive/components/keybinding-hints.js +36 -0
- package/dist/modes/interactive/components/keybinding-hints.js.map +1 -0
- package/dist/modes/interactive/components/model-selector.d.ts +50 -0
- package/dist/modes/interactive/components/model-selector.d.ts.map +1 -0
- package/dist/modes/interactive/components/model-selector.js +240 -0
- package/dist/modes/interactive/components/model-selector.js.map +1 -0
- package/dist/modes/interactive/components/scoped-models-selector.d.ts +36 -0
- package/dist/modes/interactive/components/scoped-models-selector.d.ts.map +1 -0
- package/dist/modes/interactive/components/scoped-models-selector.js +222 -0
- package/dist/modes/interactive/components/scoped-models-selector.js.map +1 -0
- package/dist/modes/interactive/components/session-selector-search.d.ts +23 -0
- package/dist/modes/interactive/components/session-selector-search.d.ts.map +1 -0
- package/dist/modes/interactive/components/session-selector-search.js +155 -0
- package/dist/modes/interactive/components/session-selector-search.js.map +1 -0
- package/dist/modes/interactive/components/session-selector.d.ts +95 -0
- package/dist/modes/interactive/components/session-selector.d.ts.map +1 -0
- package/dist/modes/interactive/components/session-selector.js +779 -0
- package/dist/modes/interactive/components/session-selector.js.map +1 -0
- package/dist/modes/interactive/components/settings-selector.d.ts +77 -0
- package/dist/modes/interactive/components/settings-selector.d.ts.map +1 -0
- package/dist/modes/interactive/components/settings-selector.js +593 -0
- package/dist/modes/interactive/components/settings-selector.js.map +1 -0
- package/dist/modes/interactive/components/show-images-selector.d.ts +10 -0
- package/dist/modes/interactive/components/show-images-selector.d.ts.map +1 -0
- package/dist/modes/interactive/components/show-images-selector.js +39 -0
- package/dist/modes/interactive/components/show-images-selector.js.map +1 -0
- package/dist/modes/interactive/components/skill-invocation-message.d.ts +17 -0
- package/dist/modes/interactive/components/skill-invocation-message.d.ts.map +1 -0
- package/dist/modes/interactive/components/skill-invocation-message.js +47 -0
- package/dist/modes/interactive/components/skill-invocation-message.js.map +1 -0
- package/dist/modes/interactive/components/status-indicator.d.ts +28 -0
- package/dist/modes/interactive/components/status-indicator.d.ts.map +1 -0
- package/dist/modes/interactive/components/status-indicator.js +60 -0
- package/dist/modes/interactive/components/status-indicator.js.map +1 -0
- package/dist/modes/interactive/components/theme-selector.d.ts +11 -0
- package/dist/modes/interactive/components/theme-selector.d.ts.map +1 -0
- package/dist/modes/interactive/components/theme-selector.js +46 -0
- package/dist/modes/interactive/components/theme-selector.js.map +1 -0
- package/dist/modes/interactive/components/thinking-selector.d.ts +11 -0
- package/dist/modes/interactive/components/thinking-selector.d.ts.map +1 -0
- package/dist/modes/interactive/components/thinking-selector.js +47 -0
- package/dist/modes/interactive/components/thinking-selector.js.map +1 -0
- package/dist/modes/interactive/components/tool-execution.d.ts +63 -0
- package/dist/modes/interactive/components/tool-execution.d.ts.map +1 -0
- package/dist/modes/interactive/components/tool-execution.js +317 -0
- package/dist/modes/interactive/components/tool-execution.js.map +1 -0
- package/dist/modes/interactive/components/tree-selector.d.ts +94 -0
- package/dist/modes/interactive/components/tree-selector.d.ts.map +1 -0
- package/dist/modes/interactive/components/tree-selector.js +1245 -0
- package/dist/modes/interactive/components/tree-selector.js.map +1 -0
- package/dist/modes/interactive/components/trust-selector.d.ts +21 -0
- package/dist/modes/interactive/components/trust-selector.d.ts.map +1 -0
- package/dist/modes/interactive/components/trust-selector.js +72 -0
- package/dist/modes/interactive/components/trust-selector.js.map +1 -0
- package/dist/modes/interactive/components/user-message-selector.d.ts +16 -0
- package/dist/modes/interactive/components/user-message-selector.d.ts.map +1 -0
- package/dist/modes/interactive/components/user-message-selector.js +53 -0
- package/dist/modes/interactive/components/user-message-selector.js.map +1 -0
- package/dist/modes/interactive/components/user-message.d.ts +14 -0
- package/dist/modes/interactive/components/user-message.d.ts.map +1 -0
- package/dist/modes/interactive/components/user-message.js +42 -0
- package/dist/modes/interactive/components/user-message.js.map +1 -0
- package/dist/modes/interactive/components/visual-truncate.d.ts +24 -0
- package/dist/modes/interactive/components/visual-truncate.d.ts.map +1 -0
- package/dist/modes/interactive/components/visual-truncate.js +33 -0
- package/dist/modes/interactive/components/visual-truncate.js.map +1 -0
- package/dist/modes/interactive/interactive-mode.d.ts +391 -0
- package/dist/modes/interactive/interactive-mode.d.ts.map +1 -0
- package/dist/modes/interactive/interactive-mode.js +4996 -0
- package/dist/modes/interactive/interactive-mode.js.map +1 -0
- package/dist/modes/interactive/model-search.d.ts +12 -0
- package/dist/modes/interactive/model-search.d.ts.map +1 -0
- package/dist/modes/interactive/model-search.js +15 -0
- package/dist/modes/interactive/model-search.js.map +1 -0
- package/dist/modes/interactive/theme/dark.json +87 -0
- package/dist/modes/interactive/theme/light.json +86 -0
- package/dist/modes/interactive/theme/theme-controller.d.ts +29 -0
- package/dist/modes/interactive/theme/theme-controller.d.ts.map +1 -0
- package/dist/modes/interactive/theme/theme-controller.js +102 -0
- package/dist/modes/interactive/theme/theme-controller.js.map +1 -0
- package/dist/modes/interactive/theme/theme-schema.json +340 -0
- package/dist/modes/interactive/theme/theme.d.ts +120 -0
- package/dist/modes/interactive/theme/theme.d.ts.map +1 -0
- package/dist/modes/interactive/theme/theme.js +1063 -0
- package/dist/modes/interactive/theme/theme.js.map +1 -0
- package/dist/modes/print-mode.d.ts +28 -0
- package/dist/modes/print-mode.d.ts.map +1 -0
- package/dist/modes/print-mode.js +132 -0
- package/dist/modes/print-mode.js.map +1 -0
- package/dist/modes/rpc/jsonl.d.ts +17 -0
- package/dist/modes/rpc/jsonl.d.ts.map +1 -0
- package/dist/modes/rpc/jsonl.js +49 -0
- package/dist/modes/rpc/jsonl.js.map +1 -0
- package/dist/modes/rpc/rpc-client.d.ts +246 -0
- package/dist/modes/rpc/rpc-client.d.ts.map +1 -0
- package/dist/modes/rpc/rpc-client.js +488 -0
- package/dist/modes/rpc/rpc-client.js.map +1 -0
- package/dist/modes/rpc/rpc-mode.d.ts +20 -0
- package/dist/modes/rpc/rpc-mode.d.ts.map +1 -0
- package/dist/modes/rpc/rpc-mode.js +639 -0
- package/dist/modes/rpc/rpc-mode.js.map +1 -0
- package/dist/modes/rpc/rpc-types.d.ts +457 -0
- package/dist/modes/rpc/rpc-types.d.ts.map +1 -0
- package/dist/modes/rpc/rpc-types.js +8 -0
- package/dist/modes/rpc/rpc-types.js.map +1 -0
- package/dist/package-manager-cli.d.ts +8 -0
- package/dist/package-manager-cli.d.ts.map +1 -0
- package/dist/package-manager-cli.js +775 -0
- package/dist/package-manager-cli.js.map +1 -0
- package/dist/rpc-entry.d.ts +3 -0
- package/dist/rpc-entry.d.ts.map +1 -0
- package/dist/rpc-entry.js +10 -0
- package/dist/rpc-entry.js.map +1 -0
- package/dist/utils/ansi.d.ts +2 -0
- package/dist/utils/ansi.d.ts.map +1 -0
- package/dist/utils/ansi.js +52 -0
- package/dist/utils/ansi.js.map +1 -0
- package/dist/utils/changelog.d.ts +22 -0
- package/dist/utils/changelog.d.ts.map +1 -0
- package/dist/utils/changelog.js +165 -0
- package/dist/utils/changelog.js.map +1 -0
- package/dist/utils/child-process.d.ts +18 -0
- package/dist/utils/child-process.d.ts.map +1 -0
- package/dist/utils/child-process.js +106 -0
- package/dist/utils/child-process.js.map +1 -0
- package/dist/utils/clipboard-image.d.ts +11 -0
- package/dist/utils/clipboard-image.d.ts.map +1 -0
- package/dist/utils/clipboard-image.js +245 -0
- package/dist/utils/clipboard-image.js.map +1 -0
- package/dist/utils/clipboard-native.d.ts +11 -0
- package/dist/utils/clipboard-native.d.ts.map +1 -0
- package/dist/utils/clipboard-native.js +20 -0
- package/dist/utils/clipboard-native.js.map +1 -0
- package/dist/utils/clipboard.d.ts +4 -0
- package/dist/utils/clipboard.d.ts.map +1 -0
- package/dist/utils/clipboard.js +130 -0
- package/dist/utils/clipboard.js.map +1 -0
- package/dist/utils/deprecation.d.ts +4 -0
- package/dist/utils/deprecation.d.ts.map +1 -0
- package/dist/utils/deprecation.js +13 -0
- package/dist/utils/deprecation.js.map +1 -0
- package/dist/utils/exif-orientation.d.ts +5 -0
- package/dist/utils/exif-orientation.d.ts.map +1 -0
- package/dist/utils/exif-orientation.js +158 -0
- package/dist/utils/exif-orientation.js.map +1 -0
- package/dist/utils/frontmatter.d.ts +8 -0
- package/dist/utils/frontmatter.d.ts.map +1 -0
- package/dist/utils/frontmatter.js +26 -0
- package/dist/utils/frontmatter.js.map +1 -0
- package/dist/utils/fs-watch.d.ts +5 -0
- package/dist/utils/fs-watch.d.ts.map +1 -0
- package/dist/utils/fs-watch.js +25 -0
- package/dist/utils/fs-watch.js.map +1 -0
- package/dist/utils/git.d.ts +26 -0
- package/dist/utils/git.d.ts.map +1 -0
- package/dist/utils/git.js +195 -0
- package/dist/utils/git.js.map +1 -0
- package/dist/utils/html.d.ts +7 -0
- package/dist/utils/html.d.ts.map +1 -0
- package/dist/utils/html.js +40 -0
- package/dist/utils/html.js.map +1 -0
- package/dist/utils/image-convert.d.ts +10 -0
- package/dist/utils/image-convert.d.ts.map +1 -0
- package/dist/utils/image-convert.js +45 -0
- package/dist/utils/image-convert.js.map +1 -0
- package/dist/utils/image-process.d.ts +18 -0
- package/dist/utils/image-process.d.ts.map +1 -0
- package/dist/utils/image-process.js +83 -0
- package/dist/utils/image-process.js.map +1 -0
- package/dist/utils/image-resize-core.d.ts +30 -0
- package/dist/utils/image-resize-core.d.ts.map +1 -0
- package/dist/utils/image-resize-core.js +124 -0
- package/dist/utils/image-resize-core.js.map +1 -0
- package/dist/utils/image-resize-worker.d.ts +2 -0
- package/dist/utils/image-resize-worker.d.ts.map +1 -0
- package/dist/utils/image-resize-worker.js +31 -0
- package/dist/utils/image-resize-worker.js.map +1 -0
- package/dist/utils/image-resize.d.ts +16 -0
- package/dist/utils/image-resize.d.ts.map +1 -0
- package/dist/utils/image-resize.js +97 -0
- package/dist/utils/image-resize.js.map +1 -0
- package/dist/utils/json.d.ts +3 -0
- package/dist/utils/json.d.ts.map +1 -0
- package/dist/utils/json.js +7 -0
- package/dist/utils/json.js.map +1 -0
- package/dist/utils/mime.d.ts +3 -0
- package/dist/utils/mime.d.ts.map +1 -0
- package/dist/utils/mime.js +110 -0
- package/dist/utils/mime.js.map +1 -0
- package/dist/utils/open-browser.d.ts +9 -0
- package/dist/utils/open-browser.d.ts.map +1 -0
- package/dist/utils/open-browser.js +22 -0
- package/dist/utils/open-browser.js.map +1 -0
- package/dist/utils/paths.d.ts +31 -0
- package/dist/utils/paths.d.ts.map +1 -0
- package/dist/utils/paths.js +92 -0
- package/dist/utils/paths.js.map +1 -0
- package/dist/utils/photon.d.ts +21 -0
- package/dist/utils/photon.d.ts.map +1 -0
- package/dist/utils/photon.js +121 -0
- package/dist/utils/photon.js.map +1 -0
- package/dist/utils/pi-user-agent.d.ts +2 -0
- package/dist/utils/pi-user-agent.d.ts.map +1 -0
- package/dist/utils/pi-user-agent.js +5 -0
- package/dist/utils/pi-user-agent.js.map +1 -0
- package/dist/utils/shell.d.ts +31 -0
- package/dist/utils/shell.d.ts.map +1 -0
- package/dist/utils/shell.js +202 -0
- package/dist/utils/shell.js.map +1 -0
- package/dist/utils/sleep.d.ts +5 -0
- package/dist/utils/sleep.d.ts.map +1 -0
- package/dist/utils/sleep.js +17 -0
- package/dist/utils/sleep.js.map +1 -0
- package/dist/utils/syntax-highlight.d.ts +12 -0
- package/dist/utils/syntax-highlight.d.ts.map +1 -0
- package/dist/utils/syntax-highlight.js +118 -0
- package/dist/utils/syntax-highlight.js.map +1 -0
- package/dist/utils/tools-manager.d.ts +3 -0
- package/dist/utils/tools-manager.d.ts.map +1 -0
- package/dist/utils/tools-manager.js +328 -0
- package/dist/utils/tools-manager.js.map +1 -0
- package/dist/utils/version-check.d.ts +15 -0
- package/dist/utils/version-check.d.ts.map +1 -0
- package/dist/utils/version-check.js +59 -0
- package/dist/utils/version-check.js.map +1 -0
- package/dist/utils/windows-self-update.d.ts +3 -0
- package/dist/utils/windows-self-update.d.ts.map +1 -0
- package/dist/utils/windows-self-update.js +77 -0
- package/dist/utils/windows-self-update.js.map +1 -0
- package/docs/compaction.md +401 -0
- package/docs/containerization.md +111 -0
- package/docs/custom-provider.md +763 -0
- package/docs/development.md +71 -0
- package/docs/docs.json +156 -0
- package/docs/extensions.md +2953 -0
- package/docs/images/doom-extension.png +0 -0
- package/docs/images/exy.png +0 -0
- package/docs/images/interactive-mode.png +0 -0
- package/docs/images/tree-view.png +0 -0
- package/docs/index.md +83 -0
- package/docs/json.md +86 -0
- package/docs/keybindings.md +198 -0
- package/docs/llama-cpp.md +99 -0
- package/docs/models.md +540 -0
- package/docs/packages.md +228 -0
- package/docs/prompt-templates.md +96 -0
- package/docs/providers.md +301 -0
- package/docs/quickstart.md +165 -0
- package/docs/rpc.md +1559 -0
- package/docs/sdk.md +1186 -0
- package/docs/security.md +59 -0
- package/docs/session-format.md +436 -0
- package/docs/sessions.md +145 -0
- package/docs/settings.md +319 -0
- package/docs/shell-aliases.md +13 -0
- package/docs/skills.md +231 -0
- package/docs/terminal-setup.md +142 -0
- package/docs/termux.md +127 -0
- package/docs/themes.md +297 -0
- package/docs/tmux.md +63 -0
- package/docs/tui.md +942 -0
- package/docs/usage.md +311 -0
- package/docs/windows.md +17 -0
- package/examples/README.md +25 -0
- package/examples/extensions/README.md +213 -0
- package/examples/extensions/auto-commit-on-exit.ts +49 -0
- package/examples/extensions/bash-spawn-hook.ts +30 -0
- package/examples/extensions/bookmark.ts +50 -0
- package/examples/extensions/border-status-editor.ts +150 -0
- package/examples/extensions/built-in-tool-renderer.ts +249 -0
- package/examples/extensions/claude-rules.ts +86 -0
- package/examples/extensions/commands.ts +72 -0
- package/examples/extensions/confirm-destructive.ts +59 -0
- package/examples/extensions/custom-compaction.ts +129 -0
- package/examples/extensions/custom-footer.ts +64 -0
- package/examples/extensions/custom-header.ts +73 -0
- package/examples/extensions/custom-provider-anthropic/index.ts +604 -0
- package/examples/extensions/custom-provider-anthropic/package-lock.json +24 -0
- package/examples/extensions/custom-provider-anthropic/package.json +19 -0
- package/examples/extensions/custom-provider-gitlab-duo/index.ts +404 -0
- package/examples/extensions/custom-provider-gitlab-duo/package.json +16 -0
- package/examples/extensions/custom-provider-gitlab-duo/test.ts +82 -0
- package/examples/extensions/dirty-repo-guard.ts +56 -0
- package/examples/extensions/doom-overlay/README.md +46 -0
- package/examples/extensions/doom-overlay/doom/build/doom.js +21 -0
- package/examples/extensions/doom-overlay/doom/build/doom.wasm +0 -0
- package/examples/extensions/doom-overlay/doom/build.sh +152 -0
- package/examples/extensions/doom-overlay/doom/doomgeneric_pi.c +72 -0
- package/examples/extensions/doom-overlay/doom-component.ts +132 -0
- package/examples/extensions/doom-overlay/doom-engine.ts +173 -0
- package/examples/extensions/doom-overlay/doom-keys.ts +104 -0
- package/examples/extensions/doom-overlay/index.ts +74 -0
- package/examples/extensions/doom-overlay/wad-finder.ts +51 -0
- package/examples/extensions/dynamic-resources/SKILL.md +8 -0
- package/examples/extensions/dynamic-resources/dynamic.json +79 -0
- package/examples/extensions/dynamic-resources/dynamic.md +5 -0
- package/examples/extensions/dynamic-resources/index.ts +15 -0
- package/examples/extensions/dynamic-tools.ts +74 -0
- package/examples/extensions/entry-renderer.ts +41 -0
- package/examples/extensions/event-bus.ts +43 -0
- package/examples/extensions/file-trigger.ts +41 -0
- package/examples/extensions/git-checkpoint.ts +53 -0
- package/examples/extensions/git-merge-and-resolve.ts +115 -0
- package/examples/extensions/github-issue-autocomplete.ts +185 -0
- package/examples/extensions/gondolin/index.ts +531 -0
- package/examples/extensions/gondolin/package-lock.json +185 -0
- package/examples/extensions/gondolin/package.json +19 -0
- package/examples/extensions/handoff.ts +191 -0
- package/examples/extensions/hello.ts +26 -0
- package/examples/extensions/hidden-thinking-label.ts +53 -0
- package/examples/extensions/inline-bash.ts +94 -0
- package/examples/extensions/input-transform-streaming.ts +39 -0
- package/examples/extensions/input-transform.ts +43 -0
- package/examples/extensions/interactive-shell.ts +196 -0
- package/examples/extensions/kimi-deferred-tools.ts +61 -0
- package/examples/extensions/mac-system-theme.ts +47 -0
- package/examples/extensions/message-renderer.ts +59 -0
- package/examples/extensions/minimal-mode.ts +426 -0
- package/examples/extensions/modal-editor.ts +85 -0
- package/examples/extensions/model-status.ts +31 -0
- package/examples/extensions/notify.ts +55 -0
- package/examples/extensions/overlay-qa-tests.ts +1450 -0
- package/examples/extensions/overlay-test.ts +153 -0
- package/examples/extensions/permission-gate.ts +34 -0
- package/examples/extensions/pirate.ts +47 -0
- package/examples/extensions/plan-mode/README.md +66 -0
- package/examples/extensions/plan-mode/index.ts +390 -0
- package/examples/extensions/plan-mode/utils.ts +168 -0
- package/examples/extensions/preset.ts +436 -0
- package/examples/extensions/project-trust.ts +64 -0
- package/examples/extensions/prompt-customizer.ts +97 -0
- package/examples/extensions/protected-paths.ts +30 -0
- package/examples/extensions/provider-payload.ts +18 -0
- package/examples/extensions/qna.ts +122 -0
- package/examples/extensions/question.ts +278 -0
- package/examples/extensions/questionnaire.ts +440 -0
- package/examples/extensions/rainbow-editor.ts +88 -0
- package/examples/extensions/reload-runtime.ts +37 -0
- package/examples/extensions/rpc-demo.ts +118 -0
- package/examples/extensions/sandbox/index.ts +321 -0
- package/examples/extensions/sandbox/package-lock.json +92 -0
- package/examples/extensions/sandbox/package.json +19 -0
- package/examples/extensions/send-user-message.ts +97 -0
- package/examples/extensions/session-name.ts +27 -0
- package/examples/extensions/shutdown-command.ts +63 -0
- package/examples/extensions/snake.ts +343 -0
- package/examples/extensions/space-invaders.ts +560 -0
- package/examples/extensions/ssh.ts +220 -0
- package/examples/extensions/status-line.ts +32 -0
- package/examples/extensions/structured-output.ts +65 -0
- package/examples/extensions/subagent/README.md +175 -0
- package/examples/extensions/subagent/agents/planner.md +37 -0
- package/examples/extensions/subagent/agents/reviewer.md +35 -0
- package/examples/extensions/subagent/agents/scout.md +50 -0
- package/examples/extensions/subagent/agents/worker.md +24 -0
- package/examples/extensions/subagent/agents.ts +126 -0
- package/examples/extensions/subagent/index.ts +1015 -0
- package/examples/extensions/subagent/prompts/implement-and-review.md +10 -0
- package/examples/extensions/subagent/prompts/implement.md +10 -0
- package/examples/extensions/subagent/prompts/scout-and-plan.md +9 -0
- package/examples/extensions/summarize.ts +207 -0
- package/examples/extensions/system-prompt-header.ts +17 -0
- package/examples/extensions/tic-tac-toe.ts +1008 -0
- package/examples/extensions/timed-confirm.ts +70 -0
- package/examples/extensions/titlebar-spinner.ts +58 -0
- package/examples/extensions/todo.ts +297 -0
- package/examples/extensions/tool-override.ts +144 -0
- package/examples/extensions/tools.ts +146 -0
- package/examples/extensions/trigger-compact.ts +50 -0
- package/examples/extensions/truncated-tool.ts +195 -0
- package/examples/extensions/widget-placement.ts +9 -0
- package/examples/extensions/with-deps/index.ts +32 -0
- package/examples/extensions/with-deps/package-lock.json +31 -0
- package/examples/extensions/with-deps/package.json +22 -0
- package/examples/extensions/working-indicator.ts +123 -0
- package/examples/extensions/working-message-test.ts +25 -0
- package/examples/rpc-extension-ui.ts +632 -0
- package/examples/sdk/01-minimal.ts +26 -0
- package/examples/sdk/02-custom-model.ts +50 -0
- package/examples/sdk/03-custom-prompt.ts +70 -0
- package/examples/sdk/04-skills.ts +55 -0
- package/examples/sdk/05-tools.ts +48 -0
- package/examples/sdk/06-extensions.ts +94 -0
- package/examples/sdk/07-context-files.ts +42 -0
- package/examples/sdk/08-prompt-templates.ts +51 -0
- package/examples/sdk/09-api-keys-and-oauth.ts +34 -0
- package/examples/sdk/10-settings.ts +53 -0
- package/examples/sdk/11-sessions.ts +52 -0
- package/examples/sdk/12-full-control.ts +72 -0
- package/examples/sdk/13-session-runtime.ts +67 -0
- package/examples/sdk/README.md +140 -0
- package/npm-shrinkwrap.json +1824 -0
- package/package.json +100 -0
|
@@ -0,0 +1,637 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Context compaction for long sessions.
|
|
3
|
+
*
|
|
4
|
+
* Pure functions for compaction logic. The session manager handles I/O,
|
|
5
|
+
* and after compaction the session is reloaded.
|
|
6
|
+
*/
|
|
7
|
+
import { contentText, retryAssistantCall } from "@handy_wote/pi-ai";
|
|
8
|
+
import { completeSimple } from "@handy_wote/pi-ai/compat";
|
|
9
|
+
import { convertToLlm } from "../messages.js";
|
|
10
|
+
import { buildSessionContext, sessionEntryToContextMessages, } from "../session-manager.js";
|
|
11
|
+
import { computeFileLists, createFileOps, extractFileOpsFromMessage, formatFileOperations, SUMMARIZATION_SYSTEM_PROMPT, serializeConversation, } from "./utils.js";
|
|
12
|
+
/**
|
|
13
|
+
* Extract file operations from messages and previous compaction entries.
|
|
14
|
+
*/
|
|
15
|
+
function extractFileOperations(messages, entries, prevCompactionIndex) {
|
|
16
|
+
const fileOps = createFileOps();
|
|
17
|
+
// Collect from previous compaction's details (if pi-generated)
|
|
18
|
+
if (prevCompactionIndex >= 0) {
|
|
19
|
+
const prevCompaction = entries[prevCompactionIndex];
|
|
20
|
+
if (!prevCompaction.fromHook && prevCompaction.details) {
|
|
21
|
+
// fromHook field kept for session file compatibility
|
|
22
|
+
const details = prevCompaction.details;
|
|
23
|
+
if (Array.isArray(details.readFiles)) {
|
|
24
|
+
for (const f of details.readFiles)
|
|
25
|
+
fileOps.read.add(f);
|
|
26
|
+
}
|
|
27
|
+
if (Array.isArray(details.modifiedFiles)) {
|
|
28
|
+
for (const f of details.modifiedFiles)
|
|
29
|
+
fileOps.edited.add(f);
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
// Extract from tool calls in messages
|
|
34
|
+
for (const msg of messages) {
|
|
35
|
+
extractFileOpsFromMessage(msg, fileOps);
|
|
36
|
+
}
|
|
37
|
+
return fileOps;
|
|
38
|
+
}
|
|
39
|
+
// ============================================================================
|
|
40
|
+
// Message Extraction
|
|
41
|
+
// ============================================================================
|
|
42
|
+
/**
|
|
43
|
+
* Extract AgentMessage from an entry if it produces one.
|
|
44
|
+
* Returns undefined for entries that don't contribute to LLM context.
|
|
45
|
+
*/
|
|
46
|
+
function getMessageFromEntryForCompaction(entry) {
|
|
47
|
+
if (entry.type === "compaction") {
|
|
48
|
+
return undefined;
|
|
49
|
+
}
|
|
50
|
+
return sessionEntryToContextMessages(entry)[0];
|
|
51
|
+
}
|
|
52
|
+
function combineUsage(first, second) {
|
|
53
|
+
return {
|
|
54
|
+
input: first.input + second.input,
|
|
55
|
+
output: first.output + second.output,
|
|
56
|
+
cacheRead: first.cacheRead + second.cacheRead,
|
|
57
|
+
cacheWrite: first.cacheWrite + second.cacheWrite,
|
|
58
|
+
...(first.cacheWrite1h !== undefined || second.cacheWrite1h !== undefined
|
|
59
|
+
? { cacheWrite1h: (first.cacheWrite1h ?? 0) + (second.cacheWrite1h ?? 0) }
|
|
60
|
+
: {}),
|
|
61
|
+
...(first.reasoning !== undefined || second.reasoning !== undefined
|
|
62
|
+
? { reasoning: (first.reasoning ?? 0) + (second.reasoning ?? 0) }
|
|
63
|
+
: {}),
|
|
64
|
+
totalTokens: first.totalTokens + second.totalTokens,
|
|
65
|
+
cost: {
|
|
66
|
+
input: first.cost.input + second.cost.input,
|
|
67
|
+
output: first.cost.output + second.cost.output,
|
|
68
|
+
cacheRead: first.cost.cacheRead + second.cost.cacheRead,
|
|
69
|
+
cacheWrite: first.cost.cacheWrite + second.cost.cacheWrite,
|
|
70
|
+
total: first.cost.total + second.cost.total,
|
|
71
|
+
},
|
|
72
|
+
};
|
|
73
|
+
}
|
|
74
|
+
export const DEFAULT_COMPACTION_SETTINGS = {
|
|
75
|
+
enabled: true,
|
|
76
|
+
reserveTokens: 16384,
|
|
77
|
+
keepRecentTokens: 20000,
|
|
78
|
+
};
|
|
79
|
+
// ============================================================================
|
|
80
|
+
// Token calculation
|
|
81
|
+
// ============================================================================
|
|
82
|
+
/**
|
|
83
|
+
* Calculate total context tokens from usage.
|
|
84
|
+
* Uses the native totalTokens field when available, falls back to computing from components.
|
|
85
|
+
*/
|
|
86
|
+
export function calculateContextTokens(usage) {
|
|
87
|
+
return usage.totalTokens || usage.input + usage.output + usage.cacheRead + usage.cacheWrite;
|
|
88
|
+
}
|
|
89
|
+
/**
|
|
90
|
+
* Get usage from an assistant message if available.
|
|
91
|
+
* Skips aborted, error, and all-zero usage messages as they don't have valid usage data.
|
|
92
|
+
*/
|
|
93
|
+
function getAssistantUsage(msg) {
|
|
94
|
+
if (msg.role === "assistant" && "usage" in msg) {
|
|
95
|
+
const assistantMsg = msg;
|
|
96
|
+
if (assistantMsg.stopReason !== "aborted" &&
|
|
97
|
+
assistantMsg.stopReason !== "error" &&
|
|
98
|
+
assistantMsg.usage &&
|
|
99
|
+
calculateContextTokens(assistantMsg.usage) > 0) {
|
|
100
|
+
return assistantMsg.usage;
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
return undefined;
|
|
104
|
+
}
|
|
105
|
+
/**
|
|
106
|
+
* Find the last valid assistant message usage from session entries.
|
|
107
|
+
*/
|
|
108
|
+
export function getLastAssistantUsage(entries) {
|
|
109
|
+
for (let i = entries.length - 1; i >= 0; i--) {
|
|
110
|
+
const entry = entries[i];
|
|
111
|
+
if (entry.type === "message") {
|
|
112
|
+
const usage = getAssistantUsage(entry.message);
|
|
113
|
+
if (usage)
|
|
114
|
+
return usage;
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
return undefined;
|
|
118
|
+
}
|
|
119
|
+
function getLastAssistantUsageInfo(messages) {
|
|
120
|
+
for (let i = messages.length - 1; i >= 0; i--) {
|
|
121
|
+
const usage = getAssistantUsage(messages[i]);
|
|
122
|
+
if (usage)
|
|
123
|
+
return { usage, index: i };
|
|
124
|
+
}
|
|
125
|
+
return undefined;
|
|
126
|
+
}
|
|
127
|
+
/**
|
|
128
|
+
* Estimate context tokens from messages, using the last assistant usage when available.
|
|
129
|
+
* If there are messages after the last usage, estimate their tokens with estimateTokens.
|
|
130
|
+
*/
|
|
131
|
+
export function estimateContextTokens(messages) {
|
|
132
|
+
const usageInfo = getLastAssistantUsageInfo(messages);
|
|
133
|
+
if (!usageInfo) {
|
|
134
|
+
let estimated = 0;
|
|
135
|
+
for (const message of messages) {
|
|
136
|
+
estimated += estimateTokens(message);
|
|
137
|
+
}
|
|
138
|
+
return {
|
|
139
|
+
tokens: estimated,
|
|
140
|
+
usageTokens: 0,
|
|
141
|
+
trailingTokens: estimated,
|
|
142
|
+
lastUsageIndex: null,
|
|
143
|
+
};
|
|
144
|
+
}
|
|
145
|
+
const usageTokens = calculateContextTokens(usageInfo.usage);
|
|
146
|
+
let trailingTokens = 0;
|
|
147
|
+
for (let i = usageInfo.index + 1; i < messages.length; i++) {
|
|
148
|
+
trailingTokens += estimateTokens(messages[i]);
|
|
149
|
+
}
|
|
150
|
+
return {
|
|
151
|
+
tokens: usageTokens + trailingTokens,
|
|
152
|
+
usageTokens,
|
|
153
|
+
trailingTokens,
|
|
154
|
+
lastUsageIndex: usageInfo.index,
|
|
155
|
+
};
|
|
156
|
+
}
|
|
157
|
+
/**
|
|
158
|
+
* Check if compaction should trigger based on context usage.
|
|
159
|
+
*/
|
|
160
|
+
export function shouldCompact(contextTokens, contextWindow, settings) {
|
|
161
|
+
if (!settings.enabled)
|
|
162
|
+
return false;
|
|
163
|
+
return contextTokens > contextWindow - settings.reserveTokens;
|
|
164
|
+
}
|
|
165
|
+
// ============================================================================
|
|
166
|
+
// Cut point detection
|
|
167
|
+
// ============================================================================
|
|
168
|
+
const ESTIMATED_IMAGE_CHARS = 4800;
|
|
169
|
+
function estimateTextAndImageContentChars(content) {
|
|
170
|
+
if (typeof content === "string") {
|
|
171
|
+
return content.length;
|
|
172
|
+
}
|
|
173
|
+
let chars = 0;
|
|
174
|
+
for (const block of content) {
|
|
175
|
+
if (block.type === "text" && block.text) {
|
|
176
|
+
chars += block.text.length;
|
|
177
|
+
}
|
|
178
|
+
else if (block.type === "image") {
|
|
179
|
+
chars += ESTIMATED_IMAGE_CHARS;
|
|
180
|
+
}
|
|
181
|
+
}
|
|
182
|
+
return chars;
|
|
183
|
+
}
|
|
184
|
+
/**
|
|
185
|
+
* Estimate token count for a message using chars/4 heuristic.
|
|
186
|
+
* This is conservative (overestimates tokens).
|
|
187
|
+
*/
|
|
188
|
+
export function estimateTokens(message) {
|
|
189
|
+
let chars = 0;
|
|
190
|
+
switch (message.role) {
|
|
191
|
+
case "user": {
|
|
192
|
+
chars = estimateTextAndImageContentChars(message.content);
|
|
193
|
+
return Math.ceil(chars / 4);
|
|
194
|
+
}
|
|
195
|
+
case "assistant": {
|
|
196
|
+
const assistant = message;
|
|
197
|
+
for (const block of assistant.content) {
|
|
198
|
+
if (block.type === "text") {
|
|
199
|
+
chars += block.text.length;
|
|
200
|
+
}
|
|
201
|
+
else if (block.type === "thinking") {
|
|
202
|
+
chars += block.thinking.length;
|
|
203
|
+
}
|
|
204
|
+
else if (block.type === "toolCall") {
|
|
205
|
+
chars += block.name.length + JSON.stringify(block.arguments).length;
|
|
206
|
+
}
|
|
207
|
+
}
|
|
208
|
+
return Math.ceil(chars / 4);
|
|
209
|
+
}
|
|
210
|
+
case "custom":
|
|
211
|
+
case "toolResult": {
|
|
212
|
+
chars = estimateTextAndImageContentChars(message.content);
|
|
213
|
+
return Math.ceil(chars / 4);
|
|
214
|
+
}
|
|
215
|
+
case "bashExecution": {
|
|
216
|
+
chars = message.command.length + message.output.length;
|
|
217
|
+
return Math.ceil(chars / 4);
|
|
218
|
+
}
|
|
219
|
+
case "branchSummary":
|
|
220
|
+
case "compactionSummary": {
|
|
221
|
+
chars = message.summary.length;
|
|
222
|
+
return Math.ceil(chars / 4);
|
|
223
|
+
}
|
|
224
|
+
}
|
|
225
|
+
return 0;
|
|
226
|
+
}
|
|
227
|
+
function isCutPointMessage(message) {
|
|
228
|
+
switch (message.role) {
|
|
229
|
+
case "user":
|
|
230
|
+
case "assistant":
|
|
231
|
+
case "bashExecution":
|
|
232
|
+
case "custom":
|
|
233
|
+
case "branchSummary":
|
|
234
|
+
case "compactionSummary":
|
|
235
|
+
return true;
|
|
236
|
+
case "toolResult":
|
|
237
|
+
return false;
|
|
238
|
+
}
|
|
239
|
+
return false;
|
|
240
|
+
}
|
|
241
|
+
function isTurnStartMessage(message) {
|
|
242
|
+
switch (message.role) {
|
|
243
|
+
case "user":
|
|
244
|
+
case "bashExecution":
|
|
245
|
+
case "custom":
|
|
246
|
+
case "branchSummary":
|
|
247
|
+
case "compactionSummary":
|
|
248
|
+
return true;
|
|
249
|
+
case "assistant":
|
|
250
|
+
case "toolResult":
|
|
251
|
+
return false;
|
|
252
|
+
}
|
|
253
|
+
return false;
|
|
254
|
+
}
|
|
255
|
+
function isTurnStartEntry(entry) {
|
|
256
|
+
if (entry.type === "compaction") {
|
|
257
|
+
return false;
|
|
258
|
+
}
|
|
259
|
+
return sessionEntryToContextMessages(entry).some(isTurnStartMessage);
|
|
260
|
+
}
|
|
261
|
+
/**
|
|
262
|
+
* Find valid cut points: indices of context-visible user-like or assistant messages.
|
|
263
|
+
* Never cut at tool results (they must follow their tool call).
|
|
264
|
+
* When we cut at an assistant message with tool calls, its tool results follow it
|
|
265
|
+
* and will be kept.
|
|
266
|
+
*/
|
|
267
|
+
function findValidCutPoints(entries, startIndex, endIndex) {
|
|
268
|
+
const cutPoints = [];
|
|
269
|
+
for (let i = startIndex; i < endIndex; i++) {
|
|
270
|
+
const entry = entries[i];
|
|
271
|
+
if (entry.type === "compaction") {
|
|
272
|
+
continue;
|
|
273
|
+
}
|
|
274
|
+
if (sessionEntryToContextMessages(entry).some(isCutPointMessage)) {
|
|
275
|
+
cutPoints.push(i);
|
|
276
|
+
}
|
|
277
|
+
}
|
|
278
|
+
return cutPoints;
|
|
279
|
+
}
|
|
280
|
+
/**
|
|
281
|
+
* Find the context-visible user-role message that starts the turn containing the given entry index.
|
|
282
|
+
* Returns -1 if no turn start found before the index.
|
|
283
|
+
*/
|
|
284
|
+
export function findTurnStartIndex(entries, entryIndex, startIndex) {
|
|
285
|
+
for (let i = entryIndex; i >= startIndex; i--) {
|
|
286
|
+
if (isTurnStartEntry(entries[i])) {
|
|
287
|
+
return i;
|
|
288
|
+
}
|
|
289
|
+
}
|
|
290
|
+
return -1;
|
|
291
|
+
}
|
|
292
|
+
/**
|
|
293
|
+
* Find the cut point in session entries that keeps approximately `keepRecentTokens`.
|
|
294
|
+
*
|
|
295
|
+
* Algorithm: Walk backwards from newest, accumulating estimated message sizes.
|
|
296
|
+
* Stop when we've accumulated >= keepRecentTokens. Cut at that point.
|
|
297
|
+
*
|
|
298
|
+
* Can cut at user OR assistant messages (never tool results). When cutting at an
|
|
299
|
+
* assistant message with tool calls, its tool results come after and will be kept.
|
|
300
|
+
*
|
|
301
|
+
* Returns CutPointResult with:
|
|
302
|
+
* - firstKeptEntryIndex: the entry index to start keeping from
|
|
303
|
+
* - turnStartIndex: if cutting mid-turn, the user message that started that turn
|
|
304
|
+
* - isSplitTurn: whether we're cutting in the middle of a turn
|
|
305
|
+
*
|
|
306
|
+
* Only considers entries between `startIndex` and `endIndex` (exclusive).
|
|
307
|
+
*/
|
|
308
|
+
export function findCutPoint(entries, startIndex, endIndex, keepRecentTokens) {
|
|
309
|
+
const cutPoints = findValidCutPoints(entries, startIndex, endIndex);
|
|
310
|
+
if (cutPoints.length === 0) {
|
|
311
|
+
return { firstKeptEntryIndex: startIndex, turnStartIndex: -1, isSplitTurn: false };
|
|
312
|
+
}
|
|
313
|
+
// Walk backwards from newest, accumulating estimated message sizes
|
|
314
|
+
let accumulatedTokens = 0;
|
|
315
|
+
let cutIndex = cutPoints[0]; // Default: keep from first message (not header)
|
|
316
|
+
for (let i = endIndex - 1; i >= startIndex; i--) {
|
|
317
|
+
const entry = entries[i];
|
|
318
|
+
const messageTokens = sessionEntryToContextMessages(entry).reduce((sum, message) => sum + estimateTokens(message), 0);
|
|
319
|
+
if (messageTokens === 0)
|
|
320
|
+
continue;
|
|
321
|
+
accumulatedTokens += messageTokens;
|
|
322
|
+
// Check if we've exceeded the budget
|
|
323
|
+
if (accumulatedTokens >= keepRecentTokens) {
|
|
324
|
+
// Find the closest valid cut point at or after this entry
|
|
325
|
+
for (let c = 0; c < cutPoints.length; c++) {
|
|
326
|
+
if (cutPoints[c] >= i) {
|
|
327
|
+
cutIndex = cutPoints[c];
|
|
328
|
+
break;
|
|
329
|
+
}
|
|
330
|
+
}
|
|
331
|
+
break;
|
|
332
|
+
}
|
|
333
|
+
}
|
|
334
|
+
// Scan backwards from cutIndex to include adjacent metadata entries that do not affect context.
|
|
335
|
+
while (cutIndex > startIndex) {
|
|
336
|
+
const prevEntry = entries[cutIndex - 1];
|
|
337
|
+
// Stop at compaction boundaries or context-visible entries.
|
|
338
|
+
if (prevEntry.type === "compaction" || sessionEntryToContextMessages(prevEntry).length > 0) {
|
|
339
|
+
break;
|
|
340
|
+
}
|
|
341
|
+
cutIndex--;
|
|
342
|
+
}
|
|
343
|
+
// Determine if this is a split turn
|
|
344
|
+
const cutEntry = entries[cutIndex];
|
|
345
|
+
const startsTurn = isTurnStartEntry(cutEntry);
|
|
346
|
+
const turnStartIndex = startsTurn ? -1 : findTurnStartIndex(entries, cutIndex, startIndex);
|
|
347
|
+
return {
|
|
348
|
+
firstKeptEntryIndex: cutIndex,
|
|
349
|
+
turnStartIndex,
|
|
350
|
+
isSplitTurn: !startsTurn && turnStartIndex !== -1,
|
|
351
|
+
};
|
|
352
|
+
}
|
|
353
|
+
// ============================================================================
|
|
354
|
+
// Summarization
|
|
355
|
+
// ============================================================================
|
|
356
|
+
const SUMMARIZATION_PROMPT = `The messages above are a conversation to summarize. Create a structured context checkpoint summary that another LLM will use to continue the work.
|
|
357
|
+
|
|
358
|
+
Use this EXACT format:
|
|
359
|
+
|
|
360
|
+
## Goal
|
|
361
|
+
[What is the user trying to accomplish? Can be multiple items if the session covers different tasks.]
|
|
362
|
+
|
|
363
|
+
## Constraints & Preferences
|
|
364
|
+
- [Any constraints, preferences, or requirements mentioned by user]
|
|
365
|
+
- [Or "(none)" if none were mentioned]
|
|
366
|
+
|
|
367
|
+
## Progress
|
|
368
|
+
### Done
|
|
369
|
+
- [x] [Completed tasks/changes]
|
|
370
|
+
|
|
371
|
+
### In Progress
|
|
372
|
+
- [ ] [Current work]
|
|
373
|
+
|
|
374
|
+
### Blocked
|
|
375
|
+
- [Issues preventing progress, if any]
|
|
376
|
+
|
|
377
|
+
## Key Decisions
|
|
378
|
+
- **[Decision]**: [Brief rationale]
|
|
379
|
+
|
|
380
|
+
## Next Steps
|
|
381
|
+
1. [Ordered list of what should happen next]
|
|
382
|
+
|
|
383
|
+
## Critical Context
|
|
384
|
+
- [Any data, examples, or references needed to continue]
|
|
385
|
+
- [Or "(none)" if not applicable]
|
|
386
|
+
|
|
387
|
+
Keep each section concise. Preserve exact file paths, function names, and error messages.`;
|
|
388
|
+
const UPDATE_SUMMARIZATION_PROMPT = `The messages above are NEW conversation messages to incorporate into the existing summary provided in <previous-summary> tags.
|
|
389
|
+
|
|
390
|
+
Update the existing structured summary with new information. RULES:
|
|
391
|
+
- PRESERVE all existing information from the previous summary
|
|
392
|
+
- ADD new progress, decisions, and context from the new messages
|
|
393
|
+
- UPDATE the Progress section: move items from "In Progress" to "Done" when completed
|
|
394
|
+
- UPDATE "Next Steps" based on what was accomplished
|
|
395
|
+
- PRESERVE exact file paths, function names, and error messages
|
|
396
|
+
- If something is no longer relevant, you may remove it
|
|
397
|
+
|
|
398
|
+
Use this EXACT format:
|
|
399
|
+
|
|
400
|
+
## Goal
|
|
401
|
+
[Preserve existing goals, add new ones if the task expanded]
|
|
402
|
+
|
|
403
|
+
## Constraints & Preferences
|
|
404
|
+
- [Preserve existing, add new ones discovered]
|
|
405
|
+
|
|
406
|
+
## Progress
|
|
407
|
+
### Done
|
|
408
|
+
- [x] [Include previously done items AND newly completed items]
|
|
409
|
+
|
|
410
|
+
### In Progress
|
|
411
|
+
- [ ] [Current work - update based on progress]
|
|
412
|
+
|
|
413
|
+
### Blocked
|
|
414
|
+
- [Current blockers - remove if resolved]
|
|
415
|
+
|
|
416
|
+
## Key Decisions
|
|
417
|
+
- **[Decision]**: [Brief rationale] (preserve all previous, add new)
|
|
418
|
+
|
|
419
|
+
## Next Steps
|
|
420
|
+
1. [Update based on current state]
|
|
421
|
+
|
|
422
|
+
## Critical Context
|
|
423
|
+
- [Preserve important context, add new if needed]
|
|
424
|
+
|
|
425
|
+
Keep each section concise. Preserve exact file paths, function names, and error messages.`;
|
|
426
|
+
function createSummarizationOptions(model, maxTokens, apiKey, headers, env, signal, thinkingLevel) {
|
|
427
|
+
const options = { maxTokens, signal, apiKey, headers, env };
|
|
428
|
+
if (model.reasoning && thinkingLevel && thinkingLevel !== "off") {
|
|
429
|
+
options.reasoning = thinkingLevel;
|
|
430
|
+
}
|
|
431
|
+
return options;
|
|
432
|
+
}
|
|
433
|
+
/**
|
|
434
|
+
* Shared choke point for every compaction/branch-summary summarization call. Wraps the
|
|
435
|
+
* single LLM call in {@link retryAssistantCall} so transient stream drops (e.g.
|
|
436
|
+
* `terminated`, socket close) honor the configured retry policy instead of failing
|
|
437
|
+
* the whole compaction on the first attempt. Deterministic errors and aborts return
|
|
438
|
+
* immediately (see {@link retryAssistantCall}).
|
|
439
|
+
*/
|
|
440
|
+
export async function completeSummarization(model, context, options, streamFn, retry, callbacks) {
|
|
441
|
+
const produce = async () => streamFn ? (await streamFn(model, context, options)).result() : completeSimple(model, context, options);
|
|
442
|
+
return retryAssistantCall(produce, retry, options.signal, callbacks);
|
|
443
|
+
}
|
|
444
|
+
/**
|
|
445
|
+
* Generate a summary of the conversation using the LLM.
|
|
446
|
+
* If previousSummary is provided, uses the update prompt to merge.
|
|
447
|
+
*/
|
|
448
|
+
export async function generateSummary(currentMessages, model, reserveTokens, apiKey, headers, signal, customInstructions, previousSummary, thinkingLevel, streamFn, env, retry, callbacks) {
|
|
449
|
+
return (await generateSummaryWithUsage(currentMessages, model, reserveTokens, apiKey, headers, signal, customInstructions, previousSummary, thinkingLevel, streamFn, env, retry, callbacks)).text;
|
|
450
|
+
}
|
|
451
|
+
/** Generate or update a conversation summary and return its provider usage. */
|
|
452
|
+
export async function generateSummaryWithUsage(currentMessages, model, reserveTokens, apiKey, headers, signal, customInstructions, previousSummary, thinkingLevel, streamFn, env, retry, callbacks) {
|
|
453
|
+
const maxTokens = Math.min(Math.floor(0.8 * reserveTokens), model.maxTokens > 0 ? model.maxTokens : Number.POSITIVE_INFINITY);
|
|
454
|
+
// Use update prompt if we have a previous summary, otherwise initial prompt
|
|
455
|
+
let basePrompt = previousSummary ? UPDATE_SUMMARIZATION_PROMPT : SUMMARIZATION_PROMPT;
|
|
456
|
+
if (customInstructions) {
|
|
457
|
+
basePrompt = `${basePrompt}\n\nAdditional focus: ${customInstructions}`;
|
|
458
|
+
}
|
|
459
|
+
// Serialize conversation to text so model doesn't try to continue it
|
|
460
|
+
// Convert to LLM messages first (handles custom types like bashExecution, custom, etc.)
|
|
461
|
+
const llmMessages = convertToLlm(currentMessages);
|
|
462
|
+
const conversationText = serializeConversation(llmMessages);
|
|
463
|
+
// Build the prompt with conversation wrapped in tags
|
|
464
|
+
let promptText = `<conversation>\n${conversationText}\n</conversation>\n\n`;
|
|
465
|
+
if (previousSummary) {
|
|
466
|
+
promptText += `<previous-summary>\n${previousSummary}\n</previous-summary>\n\n`;
|
|
467
|
+
}
|
|
468
|
+
promptText += basePrompt;
|
|
469
|
+
const summarizationMessages = [
|
|
470
|
+
{
|
|
471
|
+
role: "user",
|
|
472
|
+
content: [{ type: "text", text: promptText }],
|
|
473
|
+
timestamp: Date.now(),
|
|
474
|
+
},
|
|
475
|
+
];
|
|
476
|
+
const completionOptions = createSummarizationOptions(model, maxTokens, apiKey, headers, env, signal, thinkingLevel);
|
|
477
|
+
const response = await completeSummarization(model, { systemPrompt: SUMMARIZATION_SYSTEM_PROMPT, messages: summarizationMessages }, completionOptions, streamFn, retry, callbacks);
|
|
478
|
+
if (response.stopReason === "error") {
|
|
479
|
+
throw new Error(`Summarization failed: ${response.errorMessage || "Unknown error"}`);
|
|
480
|
+
}
|
|
481
|
+
const textContent = contentText(response.content);
|
|
482
|
+
return { text: textContent, usage: response.usage };
|
|
483
|
+
}
|
|
484
|
+
export function prepareCompaction(pathEntries, settings) {
|
|
485
|
+
if (pathEntries.length > 0 && pathEntries[pathEntries.length - 1].type === "compaction") {
|
|
486
|
+
return undefined;
|
|
487
|
+
}
|
|
488
|
+
let prevCompactionIndex = -1;
|
|
489
|
+
for (let i = pathEntries.length - 1; i >= 0; i--) {
|
|
490
|
+
if (pathEntries[i].type === "compaction") {
|
|
491
|
+
prevCompactionIndex = i;
|
|
492
|
+
break;
|
|
493
|
+
}
|
|
494
|
+
}
|
|
495
|
+
let previousSummary;
|
|
496
|
+
let boundaryStart = 0;
|
|
497
|
+
if (prevCompactionIndex >= 0) {
|
|
498
|
+
const prevCompaction = pathEntries[prevCompactionIndex];
|
|
499
|
+
previousSummary = prevCompaction.summary;
|
|
500
|
+
const firstKeptEntryIndex = pathEntries.findIndex((entry) => entry.id === prevCompaction.firstKeptEntryId);
|
|
501
|
+
boundaryStart = firstKeptEntryIndex >= 0 ? firstKeptEntryIndex : prevCompactionIndex + 1;
|
|
502
|
+
}
|
|
503
|
+
const boundaryEnd = pathEntries.length;
|
|
504
|
+
const tokensBefore = estimateContextTokens(buildSessionContext(pathEntries).messages).tokens;
|
|
505
|
+
const cutPoint = findCutPoint(pathEntries, boundaryStart, boundaryEnd, settings.keepRecentTokens);
|
|
506
|
+
// Get UUID of first kept entry
|
|
507
|
+
const firstKeptEntry = pathEntries[cutPoint.firstKeptEntryIndex];
|
|
508
|
+
if (!firstKeptEntry?.id) {
|
|
509
|
+
return undefined; // Session needs migration
|
|
510
|
+
}
|
|
511
|
+
const firstKeptEntryId = firstKeptEntry.id;
|
|
512
|
+
const historyEnd = cutPoint.isSplitTurn ? cutPoint.turnStartIndex : cutPoint.firstKeptEntryIndex;
|
|
513
|
+
// Messages to summarize (will be discarded after summary)
|
|
514
|
+
const messagesToSummarize = [];
|
|
515
|
+
for (let i = boundaryStart; i < historyEnd; i++) {
|
|
516
|
+
const msg = getMessageFromEntryForCompaction(pathEntries[i]);
|
|
517
|
+
if (msg)
|
|
518
|
+
messagesToSummarize.push(msg);
|
|
519
|
+
}
|
|
520
|
+
// Messages for turn prefix summary (if splitting a turn)
|
|
521
|
+
const turnPrefixMessages = [];
|
|
522
|
+
if (cutPoint.isSplitTurn) {
|
|
523
|
+
for (let i = cutPoint.turnStartIndex; i < cutPoint.firstKeptEntryIndex; i++) {
|
|
524
|
+
const msg = getMessageFromEntryForCompaction(pathEntries[i]);
|
|
525
|
+
if (msg)
|
|
526
|
+
turnPrefixMessages.push(msg);
|
|
527
|
+
}
|
|
528
|
+
}
|
|
529
|
+
if (messagesToSummarize.length === 0 && turnPrefixMessages.length === 0) {
|
|
530
|
+
return undefined;
|
|
531
|
+
}
|
|
532
|
+
// Extract file operations from messages and previous compaction
|
|
533
|
+
const fileOps = extractFileOperations(messagesToSummarize, pathEntries, prevCompactionIndex);
|
|
534
|
+
// Also extract file ops from turn prefix if splitting
|
|
535
|
+
if (cutPoint.isSplitTurn) {
|
|
536
|
+
for (const msg of turnPrefixMessages) {
|
|
537
|
+
extractFileOpsFromMessage(msg, fileOps);
|
|
538
|
+
}
|
|
539
|
+
}
|
|
540
|
+
return {
|
|
541
|
+
firstKeptEntryId,
|
|
542
|
+
messagesToSummarize,
|
|
543
|
+
turnPrefixMessages,
|
|
544
|
+
isSplitTurn: cutPoint.isSplitTurn,
|
|
545
|
+
tokensBefore,
|
|
546
|
+
previousSummary,
|
|
547
|
+
fileOps,
|
|
548
|
+
settings,
|
|
549
|
+
};
|
|
550
|
+
}
|
|
551
|
+
// ============================================================================
|
|
552
|
+
// Main compaction function
|
|
553
|
+
// ============================================================================
|
|
554
|
+
const TURN_PREFIX_SUMMARIZATION_PROMPT = `This is the PREFIX of a turn that was too large to keep. The SUFFIX (recent work) is retained.
|
|
555
|
+
|
|
556
|
+
Summarize the prefix to provide context for the retained suffix:
|
|
557
|
+
|
|
558
|
+
## Original Request
|
|
559
|
+
[What did the user ask for in this turn?]
|
|
560
|
+
|
|
561
|
+
## Early Progress
|
|
562
|
+
- [Key decisions and work done in the prefix]
|
|
563
|
+
|
|
564
|
+
## Context for Suffix
|
|
565
|
+
- [Information needed to understand the retained recent work]
|
|
566
|
+
|
|
567
|
+
Be concise. Focus on what's needed to understand the kept suffix.`;
|
|
568
|
+
/**
|
|
569
|
+
* Generate summaries for compaction using prepared data.
|
|
570
|
+
* Returns CompactionResult - SessionManager adds uuid/parentUuid when saving.
|
|
571
|
+
*
|
|
572
|
+
* @param preparation - Pre-calculated preparation from prepareCompaction()
|
|
573
|
+
* @param customInstructions - Optional custom focus for the summary
|
|
574
|
+
*/
|
|
575
|
+
export async function compact(preparation, model, apiKey, headers, customInstructions, signal, thinkingLevel, streamFn, env, retry, callbacks) {
|
|
576
|
+
const { firstKeptEntryId, messagesToSummarize, turnPrefixMessages, isSplitTurn, tokensBefore, previousSummary, fileOps, settings, } = preparation;
|
|
577
|
+
// Generate summaries and merge into one
|
|
578
|
+
let summary;
|
|
579
|
+
let summaryUsage;
|
|
580
|
+
if (isSplitTurn && turnPrefixMessages.length > 0) {
|
|
581
|
+
let historyText = "No prior history.";
|
|
582
|
+
let historyUsage;
|
|
583
|
+
if (messagesToSummarize.length > 0) {
|
|
584
|
+
const historyResult = await generateSummaryWithUsage(messagesToSummarize, model, settings.reserveTokens, apiKey, headers, signal, customInstructions, previousSummary, thinkingLevel, streamFn, env, retry, callbacks);
|
|
585
|
+
historyText = historyResult.text;
|
|
586
|
+
historyUsage = historyResult.usage;
|
|
587
|
+
}
|
|
588
|
+
const turnPrefixResult = await generateTurnPrefixSummary(turnPrefixMessages, model, settings.reserveTokens, apiKey, headers, env, signal, thinkingLevel, streamFn, retry, callbacks);
|
|
589
|
+
// Merge into single summary
|
|
590
|
+
summary = `${historyText}\n\n---\n\n**Turn Context (split turn):**\n\n${turnPrefixResult.text}`;
|
|
591
|
+
summaryUsage = historyUsage ? combineUsage(historyUsage, turnPrefixResult.usage) : turnPrefixResult.usage;
|
|
592
|
+
}
|
|
593
|
+
else {
|
|
594
|
+
// Just generate history summary
|
|
595
|
+
const result = await generateSummaryWithUsage(messagesToSummarize, model, settings.reserveTokens, apiKey, headers, signal, customInstructions, previousSummary, thinkingLevel, streamFn, env, retry, callbacks);
|
|
596
|
+
summary = result.text;
|
|
597
|
+
summaryUsage = result.usage;
|
|
598
|
+
}
|
|
599
|
+
// Compute file lists and append to summary
|
|
600
|
+
const { readFiles, modifiedFiles } = computeFileLists(fileOps);
|
|
601
|
+
summary += formatFileOperations(readFiles, modifiedFiles);
|
|
602
|
+
if (!firstKeptEntryId) {
|
|
603
|
+
throw new Error("First kept entry has no UUID - session may need migration");
|
|
604
|
+
}
|
|
605
|
+
return {
|
|
606
|
+
summary,
|
|
607
|
+
firstKeptEntryId,
|
|
608
|
+
tokensBefore,
|
|
609
|
+
usage: summaryUsage,
|
|
610
|
+
details: { readFiles, modifiedFiles },
|
|
611
|
+
};
|
|
612
|
+
}
|
|
613
|
+
/**
|
|
614
|
+
* Generate a summary for a turn prefix (when splitting a turn).
|
|
615
|
+
*/
|
|
616
|
+
async function generateTurnPrefixSummary(messages, model, reserveTokens, apiKey, headers, env, signal, thinkingLevel, streamFn, retry, callbacks) {
|
|
617
|
+
const maxTokens = Math.min(Math.floor(0.5 * reserveTokens), model.maxTokens > 0 ? model.maxTokens : Number.POSITIVE_INFINITY); // Smaller budget for turn prefix
|
|
618
|
+
const llmMessages = convertToLlm(messages);
|
|
619
|
+
const conversationText = serializeConversation(llmMessages);
|
|
620
|
+
const promptText = `<conversation>\n${conversationText}\n</conversation>\n\n${TURN_PREFIX_SUMMARIZATION_PROMPT}`;
|
|
621
|
+
const summarizationMessages = [
|
|
622
|
+
{
|
|
623
|
+
role: "user",
|
|
624
|
+
content: [{ type: "text", text: promptText }],
|
|
625
|
+
timestamp: Date.now(),
|
|
626
|
+
},
|
|
627
|
+
];
|
|
628
|
+
const response = await completeSummarization(model, { systemPrompt: SUMMARIZATION_SYSTEM_PROMPT, messages: summarizationMessages }, createSummarizationOptions(model, maxTokens, apiKey, headers, env, signal, thinkingLevel), streamFn, retry, callbacks);
|
|
629
|
+
if (response.stopReason === "error") {
|
|
630
|
+
throw new Error(`Turn prefix summarization failed: ${response.errorMessage || "Unknown error"}`);
|
|
631
|
+
}
|
|
632
|
+
return {
|
|
633
|
+
text: contentText(response.content),
|
|
634
|
+
usage: response.usage,
|
|
635
|
+
};
|
|
636
|
+
}
|
|
637
|
+
//# sourceMappingURL=compaction.js.map
|