@selesai/code 0.10.2 → 0.12.0
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 +34 -0
- package/dist/cli/credential-print.js +4 -4
- package/dist/cli/startup-ui.js +2 -1
- package/dist/cli.js +0 -0
- package/dist/core/agent-session.d.ts +12 -1
- package/dist/core/agent-session.js +77 -9
- package/dist/core/compaction/branch-summarization.js +34 -33
- package/dist/core/compaction/compaction.d.ts +5 -0
- package/dist/core/compaction/compaction.js +100 -85
- package/dist/core/compaction/utils.js +2 -2
- package/dist/core/export-html/template.css +1066 -1066
- package/dist/core/export-html/template.html +55 -55
- package/dist/core/export-html/template.js +1864 -1864
- package/dist/core/export-html/vendor/highlight.min.js +1212 -1212
- package/dist/core/export-html/vendor/marked.min.js +78 -78
- package/dist/core/extensions/index.d.ts +1 -1
- package/dist/core/extensions/runner.d.ts +5 -0
- package/dist/core/extensions/runner.js +48 -1
- package/dist/core/extensions/types.d.ts +18 -1
- package/dist/core/llama/client.d.ts +6 -0
- package/dist/core/llama/client.js +7 -0
- package/dist/core/llama/provider.d.ts +3 -1
- package/dist/core/llama/provider.js +28 -6
- package/dist/core/messages.js +7 -7
- package/dist/core/session-manager.js +4 -2
- package/dist/core/settings-manager.d.ts +8 -1
- package/dist/core/settings-manager.js +17 -0
- package/dist/defaults/models.json +32 -9
- package/dist/defaults/settings.json +0 -3
- package/dist/extensions/auto-session-name.test.ts +157 -0
- package/dist/extensions/auto-session-name.ts +96 -0
- package/dist/extensions/context-compaction-reminder.test.ts +82 -82
- package/dist/extensions/context-compaction-reminder.ts +28 -28
- package/dist/extensions/cost-reconcile.test.ts +76 -0
- package/dist/extensions/cost-reconcile.ts +278 -0
- package/dist/extensions/enable-readonly-tools.test.ts +11 -0
- package/dist/extensions/enable-readonly-tools.ts +7 -3
- package/dist/extensions/package.json +3 -0
- package/dist/extensions/pi-intercom/LICENSE +21 -21
- package/dist/extensions/pi-intercom/broker/client.test.ts +83 -83
- package/dist/extensions/pi-intercom/broker/framing.test.ts +114 -114
- package/dist/extensions/pi-intercom/broker/paths.ts +134 -134
- package/dist/extensions/pi-intercom/broker/runtime-claim.test.ts +34 -34
- package/dist/extensions/pi-intercom/broker/runtime-claim.ts +21 -21
- package/dist/extensions/pi-intercom/cwd.test.ts +40 -40
- package/dist/extensions/pi-intercom/cwd.ts +31 -31
- package/dist/extensions/pi-intercom/format-context.test.ts +31 -31
- package/dist/extensions/pi-intercom/format-context.ts +32 -32
- package/dist/extensions/pi-intercom/test/overlay-width.test.ts +66 -66
- package/dist/extensions/pi-intercom/ui/compose.ts +143 -143
- package/dist/extensions/pi-intercom/ui/session-list.ts +166 -166
- package/dist/extensions/pi-rewind-hook/README.md +245 -245
- package/dist/extensions/pi-rewind-hook/index.ts +1445 -1445
- package/dist/extensions/pi-rewind-hook/package.json +29 -29
- package/dist/extensions/pi-subagents/install.mjs +0 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/bun/cli.d.ts +3 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/bun/register-bedrock.d.ts +2 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/bun/restore-sandbox-env.d.ts +17 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/cli/args.d.ts +57 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/cli/config-selector.d.ts +16 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/cli/file-processor.d.ts +15 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/cli/initial-message.d.ts +18 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/cli/list-models.d.ts +9 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/cli/project-trust.d.ts +10 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/cli/session-picker.d.ts +10 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/cli/startup-ui.d.ts +20 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/cli.d.ts +3 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/config.d.ts +96 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/core/agent-session-runtime.d.ts +119 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/core/agent-session-services.d.ts +85 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/core/agent-session.d.ts +620 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/core/auth-guidance.d.ts +5 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/core/auth-storage.d.ts +56 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/core/bash-executor.d.ts +32 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/core/cache-stats.d.ts +49 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/core/compaction/branch-summarization.d.ts +93 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/core/compaction/compaction.d.ts +128 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/core/compaction/index.d.ts +7 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/core/compaction/utils.d.ts +38 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/core/defaults.d.ts +3 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/core/diagnostics.d.ts +15 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/core/event-bus.d.ts +9 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/core/exec.d.ts +29 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/core/experimental.d.ts +2 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/core/export-html/ansi-to-html.d.ts +22 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/core/export-html/index.d.ts +37 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/core/export-html/tool-renderer.d.ts +34 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/core/extensions/index.d.ts +12 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/core/extensions/loader.d.ts +23 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/core/extensions/runner.d.ts +171 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/core/extensions/types.d.ts +1261 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/core/extensions/wrapper.d.ts +20 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/core/footer-data-provider.d.ts +54 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/core/http-dispatcher.d.ts +22 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/core/index.d.ts +13 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/core/keybindings.d.ts +358 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/core/messages.d.ts +77 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/core/model-config.d.ts +512 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/core/model-registry.d.ts +43 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/core/model-resolver.d.ts +121 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/core/model-runtime.d.ts +82 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/core/models-store.d.ts +17 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/core/output-guard.d.ts +7 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/core/package-manager.d.ts +210 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/core/project-trust.d.ts +15 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/core/prompt-templates.d.ts +54 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/core/provider-attribution.d.ts +4 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/core/provider-composer.d.ts +55 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/core/radius.d.ts +2 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/core/remote-catalog-provider.d.ts +5 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/core/resolve-config-value.d.ts +30 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/core/resource-loader.d.ts +206 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/core/runtime-credentials.d.ts +15 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/core/sdk.d.ts +106 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/core/session-cwd.d.ts +19 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/core/session-manager.d.ts +356 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/core/settings-manager.d.ts +297 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/core/skills.d.ts +60 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/core/slash-commands.d.ts +15 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/core/source-info.d.ts +18 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/core/system-prompt.d.ts +28 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/core/telemetry.d.ts +3 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/core/timings.d.ts +10 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/core/tools/bash.d.ts +68 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/core/tools/edit-diff.d.ts +106 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/core/tools/edit.d.ts +51 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/core/tools/file-mutation-queue.d.ts +6 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/core/tools/find.d.ts +35 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/core/tools/grep.d.ts +37 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/core/tools/index.d.ts +40 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/core/tools/ls.d.ts +37 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/core/tools/output-accumulator.d.ts +52 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/core/tools/path-utils.d.ts +10 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/core/tools/read.d.ts +35 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/core/tools/render-utils.d.ts +24 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/core/tools/tool-definition-wrapper.d.ts +14 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/core/tools/truncate.d.ts +70 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/core/tools/write.d.ts +26 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/core/trust-manager.d.ts +36 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/core/usage-totals.d.ts +19 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/extensions/index.d.ts +3 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/extensions/llama/client.d.ts +61 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/extensions/llama/huggingface.d.ts +23 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/extensions/llama/index.d.ts +3 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/extensions/llama/provider.d.ts +10 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/extensions/llama/ui.d.ts +42 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/index.d.ts +35 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/main.d.ts +12 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/migrations.d.ts +33 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/modes/index.d.ts +9 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/modes/interactive/components/armin.d.ts +34 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/modes/interactive/components/assistant-message.d.ts +22 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/modes/interactive/components/bash-execution.d.ts +34 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/modes/interactive/components/bordered-loader.d.ts +16 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/modes/interactive/components/branch-summary-message.d.ts +16 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/modes/interactive/components/compaction-summary-message.d.ts +16 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/modes/interactive/components/config-selector.d.ts +102 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/modes/interactive/components/countdown-timer.d.ts +14 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/modes/interactive/components/custom-editor.d.ts +21 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/modes/interactive/components/custom-entry.d.ts +19 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/modes/interactive/components/custom-message.d.ts +20 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/modes/interactive/components/daxnuts.d.ts +23 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/modes/interactive/components/diff.d.ts +12 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/modes/interactive/components/dynamic-border.d.ts +15 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/modes/interactive/components/earendil-announcement.d.ts +5 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/modes/interactive/components/extension-editor.d.ts +22 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/modes/interactive/components/extension-input.d.ts +23 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/modes/interactive/components/extension-selector.d.ts +26 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/modes/interactive/components/first-time-setup.d.ts +25 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/modes/interactive/components/footer.d.ts +32 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/modes/interactive/components/index.d.ts +34 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/modes/interactive/components/keybinding-hints.d.ts +13 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/modes/interactive/components/login-dialog.d.ts +52 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/modes/interactive/components/model-selector.d.ts +54 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/modes/interactive/components/oauth-selector.d.ts +33 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/modes/interactive/components/scoped-models-selector.d.ts +42 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/modes/interactive/components/session-selector-search.d.ts +23 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/modes/interactive/components/session-selector.d.ts +95 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/modes/interactive/components/settings-selector.d.ts +77 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/modes/interactive/components/show-images-selector.d.ts +10 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/modes/interactive/components/skill-invocation-message.d.ts +17 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/modes/interactive/components/status-indicator.d.ts +28 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/modes/interactive/components/theme-selector.d.ts +11 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/modes/interactive/components/thinking-selector.d.ts +11 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/modes/interactive/components/tool-execution.d.ts +63 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/modes/interactive/components/tree-selector.d.ts +94 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/modes/interactive/components/trust-selector.d.ts +23 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/modes/interactive/components/user-message-selector.d.ts +30 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/modes/interactive/components/user-message.d.ts +14 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/modes/interactive/components/visual-truncate.d.ts +24 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/modes/interactive/interactive-mode.d.ts +394 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/modes/interactive/model-search.d.ts +12 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/modes/interactive/theme/theme-controller.d.ts +29 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/modes/interactive/theme/theme.d.ts +120 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/modes/print-mode.d.ts +28 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/modes/rpc/jsonl.d.ts +17 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/modes/rpc/rpc-client.d.ts +246 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/modes/rpc/rpc-mode.d.ts +20 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/modes/rpc/rpc-types.d.ts +457 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/package-manager-cli.d.ts +8 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/rpc-entry.d.ts +3 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/utils/ansi.d.ts +2 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/utils/changelog.d.ts +22 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/utils/child-process.d.ts +18 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/utils/clipboard-image.d.ts +11 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/utils/clipboard-native.d.ts +11 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/utils/clipboard.d.ts +4 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/utils/deprecation.d.ts +4 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/utils/exif-orientation.d.ts +5 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/utils/frontmatter.d.ts +8 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/utils/fs-watch.d.ts +5 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/utils/git.d.ts +26 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/utils/html.d.ts +7 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/utils/image-convert.d.ts +10 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/utils/image-process.d.ts +18 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/utils/image-resize-core.d.ts +30 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/utils/image-resize-worker.d.ts +2 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/utils/image-resize.d.ts +16 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/utils/json.d.ts +3 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/utils/mime.d.ts +3 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/utils/open-browser.d.ts +9 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/utils/paths.d.ts +31 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/utils/photon.d.ts +21 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/utils/pi-user-agent.d.ts +2 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/utils/shell.d.ts +31 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/utils/sleep.d.ts +5 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/utils/syntax-highlight.d.ts +12 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/utils/tools-manager.d.ts +3 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/utils/version-check.d.ts +15 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/utils/windows-self-update.d.ts +3 -0
- package/dist/extensions/pi-tool-display/CHANGELOG.md +329 -0
- package/dist/extensions/pi-tool-display/LICENSE +21 -0
- package/dist/extensions/pi-tool-display/README.md +417 -0
- package/dist/extensions/pi-tool-display/config/config.example.json +40 -0
- package/dist/extensions/pi-tool-display/index.ts +3 -0
- package/dist/extensions/pi-tool-display/package-lock.json +2555 -0
- package/dist/extensions/pi-tool-display/package.json +86 -0
- package/dist/extensions/pi-tool-display/src/agent-dir.ts +35 -0
- package/dist/extensions/pi-tool-display/src/ansi-utils.ts +116 -0
- package/dist/extensions/pi-tool-display/src/bash-display.ts +213 -0
- package/dist/extensions/pi-tool-display/src/capabilities.ts +88 -0
- package/dist/extensions/pi-tool-display/src/config-modal.ts +541 -0
- package/dist/extensions/pi-tool-display/src/config-store.ts +304 -0
- package/dist/extensions/pi-tool-display/src/debug-logger.ts +150 -0
- package/dist/extensions/pi-tool-display/src/diff-presentation.ts +72 -0
- package/dist/extensions/pi-tool-display/src/diff-renderer.ts +2517 -0
- package/dist/extensions/pi-tool-display/src/disposable.ts +34 -0
- package/dist/extensions/pi-tool-display/src/extension-lifecycle.ts +14 -0
- package/dist/extensions/pi-tool-display/src/index.ts +109 -0
- package/dist/extensions/pi-tool-display/src/line-width-safety.ts +93 -0
- package/dist/extensions/pi-tool-display/src/modal-icons.ts +57 -0
- package/dist/extensions/pi-tool-display/src/pending-diff-preview.ts +370 -0
- package/dist/extensions/pi-tool-display/src/presets.ts +117 -0
- package/dist/extensions/pi-tool-display/src/render-utils.ts +186 -0
- package/dist/extensions/pi-tool-display/src/settings-inspector-modal.ts +475 -0
- package/dist/extensions/pi-tool-display/src/thinking-label.ts +343 -0
- package/dist/extensions/pi-tool-display/src/tool-call-box.ts +181 -0
- package/dist/extensions/pi-tool-display/src/tool-metadata.ts +139 -0
- package/dist/extensions/pi-tool-display/src/tool-overrides.ts +2168 -0
- package/dist/extensions/pi-tool-display/src/types.ts +109 -0
- package/dist/extensions/pi-tool-display/src/user-message-box-markdown.ts +64 -0
- package/dist/extensions/pi-tool-display/src/user-message-box-native.ts +66 -0
- package/dist/extensions/pi-tool-display/src/user-message-box-patch.ts +72 -0
- package/dist/extensions/pi-tool-display/src/user-message-box-renderer.ts +419 -0
- package/dist/extensions/pi-tool-display/src/user-message-box-utils.ts +106 -0
- package/dist/extensions/pi-tool-display/src/write-display-utils.ts +31 -0
- package/dist/extensions/pi-tool-display/src/zellij-modal.ts +1027 -0
- package/dist/extensions/pi-tool-display/tests/active-backlog-red.test.ts +65 -0
- package/dist/extensions/pi-tool-display/tests/ansi-utils.test.ts +345 -0
- package/dist/extensions/pi-tool-display/tests/bash-display.test.ts +442 -0
- package/dist/extensions/pi-tool-display/tests/capabilities-edge.test.ts +360 -0
- package/dist/extensions/pi-tool-display/tests/capabilities.test.ts +54 -0
- package/dist/extensions/pi-tool-display/tests/config-modal.test.ts +360 -0
- package/dist/extensions/pi-tool-display/tests/config-store.test.ts +87 -0
- package/dist/extensions/pi-tool-display/tests/custom-tool-overrides.test.ts +415 -0
- package/dist/extensions/pi-tool-display/tests/debug-logger-edge.test.ts +630 -0
- package/dist/extensions/pi-tool-display/tests/debug-logger.test.ts +62 -0
- package/dist/extensions/pi-tool-display/tests/diff-renderer-ansi.test.ts +55 -0
- package/dist/extensions/pi-tool-display/tests/diff-renderer-edge.test.ts +886 -0
- package/dist/extensions/pi-tool-display/tests/diff-renderer-numbering.test.ts +135 -0
- package/dist/extensions/pi-tool-display/tests/diff-renderer-width.test.ts +454 -0
- package/dist/extensions/pi-tool-display/tests/diff-renderer-wrap.test.ts +169 -0
- package/dist/extensions/pi-tool-display/tests/index-integration.test.ts +354 -0
- package/dist/extensions/pi-tool-display/tests/pending-diff-preview.test.ts +79 -0
- package/dist/extensions/pi-tool-display/tests/presets-edge.test.ts +229 -0
- package/dist/extensions/pi-tool-display/tests/presets.test.ts +26 -0
- package/dist/extensions/pi-tool-display/tests/reload-behavior.test.ts +1241 -0
- package/dist/extensions/pi-tool-display/tests/render-utils.test.ts +710 -0
- package/dist/extensions/pi-tool-display/tests/settings-inspector.test.ts +450 -0
- package/dist/extensions/pi-tool-display/tests/thinking-label-edge.test.ts +904 -0
- package/dist/extensions/pi-tool-display/tests/thinking-label.test.ts +72 -0
- package/dist/extensions/pi-tool-display/tests/tool-call-box.test.ts +105 -0
- package/dist/extensions/pi-tool-display/tests/tool-overrides-config.test.ts +613 -0
- package/dist/extensions/pi-tool-display/tests/tool-overrides-mcp.test.ts +499 -0
- package/dist/extensions/pi-tool-display/tests/tool-overrides-registration.test.ts +315 -0
- package/dist/extensions/pi-tool-display/tests/tool-overrides-write-meta.test.ts +68 -0
- package/dist/extensions/pi-tool-display/tests/tool-ui-utils.test.ts +413 -0
- package/dist/extensions/pi-tool-display/tests/user-message-box-performance-red.test.ts +176 -0
- package/dist/extensions/pi-tool-display/tests/user-message-box.test.ts +908 -0
- package/dist/extensions/pi-tool-display/tests/zellij-modal.test.ts +848 -0
- package/dist/extensions/pi-tool-display/tool-display-api-consumer.d.ts +30 -0
- package/dist/extensions/pi-tool-display/tool-display-api-consumer.js +40 -0
- package/dist/extensions/pi-web-agent/package.json +31 -31
- package/dist/extensions/pi-web-agent/src/backends/config.ts +205 -205
- package/dist/extensions/pi-web-agent/src/backends/doctor.ts +136 -136
- package/dist/extensions/pi-web-agent/src/backends/factory.ts +152 -152
- package/dist/extensions/pi-web-agent/src/backends/settings-reader.ts +25 -25
- package/dist/extensions/pi-web-agent/src/cache/ttl-cache.ts +28 -28
- package/dist/extensions/pi-web-agent/src/changelog-notice.ts +136 -136
- package/dist/extensions/pi-web-agent/src/commands/web-agent-config.ts +946 -946
- package/dist/extensions/pi-web-agent/src/extension.ts +126 -126
- package/dist/extensions/pi-web-agent/src/extract/readability.ts +118 -118
- package/dist/extensions/pi-web-agent/src/fetch/browser-resolution.ts +199 -199
- package/dist/extensions/pi-web-agent/src/fetch/firecrawl-fetch.ts +100 -100
- package/dist/extensions/pi-web-agent/src/fetch/headless-fetch.ts +117 -117
- package/dist/extensions/pi-web-agent/src/fetch/http-fetch.ts +67 -67
- package/dist/extensions/pi-web-agent/src/orchestration/answer-synthesizer.ts +60 -60
- package/dist/extensions/pi-web-agent/src/orchestration/candidate-selector.ts +50 -50
- package/dist/extensions/pi-web-agent/src/orchestration/direct-url.ts +52 -52
- package/dist/extensions/pi-web-agent/src/orchestration/evidence-quality.ts +105 -105
- package/dist/extensions/pi-web-agent/src/orchestration/evidence-ranker.ts +45 -45
- package/dist/extensions/pi-web-agent/src/orchestration/index.ts +28 -28
- package/dist/extensions/pi-web-agent/src/orchestration/query-planner.ts +47 -47
- package/dist/extensions/pi-web-agent/src/orchestration/research-orchestrator.ts +376 -376
- package/dist/extensions/pi-web-agent/src/orchestration/research-types.ts +64 -64
- package/dist/extensions/pi-web-agent/src/orchestration/research-worker.ts +181 -181
- package/dist/extensions/pi-web-agent/src/orchestration/source-profile.ts +101 -101
- package/dist/extensions/pi-web-agent/src/orchestration/stop-decider.ts +81 -81
- package/dist/extensions/pi-web-agent/src/presentation/config-store.ts +210 -210
- package/dist/extensions/pi-web-agent/src/presentation/config.ts +75 -75
- package/dist/extensions/pi-web-agent/src/presentation/explore-presentation.ts +61 -61
- package/dist/extensions/pi-web-agent/src/presentation/fetch-presentation.ts +54 -54
- package/dist/extensions/pi-web-agent/src/presentation/search-presentation.ts +41 -41
- package/dist/extensions/pi-web-agent/src/presentation/select-view.ts +20 -20
- package/dist/extensions/pi-web-agent/src/presentation/types.ts +63 -63
- package/dist/extensions/pi-web-agent/src/search/brave.ts +114 -114
- package/dist/extensions/pi-web-agent/src/search/duckduckgo.ts +72 -72
- package/dist/extensions/pi-web-agent/src/search/searxng.ts +96 -96
- package/dist/extensions/pi-web-agent/src/tools/web-explore.ts +71 -71
- package/dist/extensions/pi-web-agent/src/tools/web-fetch-headless.ts +31 -31
- package/dist/extensions/pi-web-agent/src/tools/web-fetch.ts +31 -31
- package/dist/extensions/pi-web-agent/src/tools/web-search.ts +157 -157
- package/dist/extensions/pi-web-agent/src/types.ts +88 -88
- package/dist/extensions/pi-zentui/extensions/zentui/format.ts +46 -1
- package/dist/extensions/pi-zentui/extensions/zentui/index.ts +10 -0
- package/dist/extensions/pi-zentui/extensions/zentui/user-message-styles.ts +1 -1
- package/dist/extensions/pi-zentui/test/extension-compliance.test.ts +3 -3
- package/dist/extensions/pi-zentui/test/format.test.ts +50 -2
- package/dist/extensions/ponytail/package.json +8 -8
- package/dist/extensions/question/constants.ts +30 -30
- package/dist/extensions/question/helpers.ts +58 -58
- package/dist/extensions/question/navigation.ts +14 -14
- package/dist/extensions/question/package.json +19 -19
- package/dist/extensions/question/selection-mode.ts +46 -46
- package/dist/extensions/question/shortcuts.ts +44 -44
- package/dist/extensions/question/types.ts +132 -132
- package/dist/extensions/test-resolve-hook-impl.mjs +6 -6
- package/dist/extensions/test-resolve-hook.mjs +6 -6
- package/dist/extensions/tokenin-onboarding.ts +112 -2
- package/dist/extensions/web-agent-onboarding.ts +222 -222
- package/dist/index.d.ts +2 -1
- package/dist/index.js +1 -0
- package/dist/main.js +2 -0
- package/dist/modes/interactive/components/settings-selector.d.ts +2 -0
- package/dist/modes/interactive/components/settings-selector.js +10 -0
- package/dist/modes/interactive/interactive-mode.d.ts +4 -0
- package/dist/modes/interactive/interactive-mode.js +72 -42
- package/dist/modes/rpc/rpc-client.d.ts +7 -0
- package/dist/modes/rpc/rpc-client.js +7 -0
- package/dist/modes/rpc/rpc-mode.js +3 -0
- package/dist/modes/rpc/rpc-types.d.ts +12 -0
- package/dist/package-manager-cli.js +71 -71
- package/dist/rpc-entry.js +0 -0
- package/dist/skills/improve-codebase/REFERENCE.md +78 -78
- package/dist/utils/shell.js +6 -4
- package/docs/compaction.md +396 -396
- package/docs/containerization.md +111 -111
- package/docs/development.md +71 -71
- package/docs/docs.json +164 -164
- package/docs/environment-variables.md +86 -86
- package/docs/index.md +83 -83
- package/docs/json.md +82 -82
- package/docs/models.md +502 -502
- package/docs/packages.md +227 -227
- package/docs/plans/subagent-delegation/phase-0-correctness.md +264 -264
- package/docs/plans/subagent-delegation/phase-1-behavioral-contract.md +485 -485
- package/docs/plans/subagent-delegation/phase-2-context-controls.md +281 -281
- package/docs/plans/subagent-delegation/phase-3-advisory-routing.md +361 -361
- package/docs/plans/subagent-delegation/phase-4-optional-enforcement.md +380 -380
- package/docs/prompt-templates.md +95 -95
- package/docs/providers.md +293 -293
- package/docs/security.md +59 -59
- package/docs/session-format.md +414 -414
- package/docs/sessions.md +145 -145
- package/docs/settings.md +4 -0
- package/docs/shared-host-extensions.md +109 -109
- package/docs/shell-aliases.md +13 -13
- package/docs/skills.md +231 -231
- package/docs/terminal-setup.md +142 -142
- package/docs/termux.md +127 -127
- package/docs/themes.md +295 -295
- package/docs/tmux.md +63 -63
- package/docs/tui.md +927 -927
- package/docs/windows.md +17 -17
- package/examples/README.md +25 -25
- package/examples/extensions/README.md +211 -211
- package/examples/extensions/auto-commit-on-exit.ts +49 -49
- package/examples/extensions/bash-spawn-hook.ts +30 -30
- package/examples/extensions/bookmark.ts +50 -50
- package/examples/extensions/border-status-editor.ts +150 -150
- package/examples/extensions/built-in-tool-renderer.ts +249 -249
- package/examples/extensions/claude-rules.ts +86 -86
- package/examples/extensions/commands.ts +72 -72
- package/examples/extensions/confirm-destructive.ts +59 -59
- package/examples/extensions/custom-compaction.ts +130 -130
- package/examples/extensions/custom-footer.ts +64 -64
- package/examples/extensions/custom-header.ts +73 -73
- package/examples/extensions/custom-provider-anthropic/index.ts +610 -610
- package/examples/extensions/custom-provider-anthropic/package-lock.json +24 -24
- package/examples/extensions/custom-provider-anthropic/package.json +19 -19
- package/examples/extensions/custom-provider-gitlab-duo/index.ts +404 -404
- package/examples/extensions/custom-provider-gitlab-duo/package.json +16 -16
- package/examples/extensions/custom-provider-gitlab-duo/test.ts +82 -82
- package/examples/extensions/dirty-repo-guard.ts +56 -56
- package/examples/extensions/doom-overlay/README.md +46 -46
- package/examples/extensions/doom-overlay/doom/build/doom.js +21 -21
- package/examples/extensions/doom-overlay/doom/build/doom.wasm +0 -0
- package/examples/extensions/doom-overlay/doom/build.sh +152 -152
- package/examples/extensions/doom-overlay/doom/doomgeneric_pi.c +72 -72
- package/examples/extensions/doom-overlay/doom-component.ts +132 -132
- package/examples/extensions/doom-overlay/doom-engine.ts +173 -173
- package/examples/extensions/doom-overlay/doom-keys.ts +104 -104
- package/examples/extensions/doom-overlay/index.ts +74 -74
- package/examples/extensions/doom-overlay/wad-finder.ts +51 -51
- package/examples/extensions/dynamic-resources/SKILL.md +8 -8
- package/examples/extensions/dynamic-resources/dynamic.json +79 -79
- package/examples/extensions/dynamic-resources/dynamic.md +5 -5
- package/examples/extensions/dynamic-resources/index.ts +15 -15
- package/examples/extensions/dynamic-tools.ts +74 -74
- package/examples/extensions/event-bus.ts +43 -43
- package/examples/extensions/file-trigger.ts +41 -41
- package/examples/extensions/git-checkpoint.ts +53 -53
- package/examples/extensions/git-merge-and-resolve.ts +115 -115
- package/examples/extensions/github-issue-autocomplete.ts +185 -185
- package/examples/extensions/gondolin/index.ts +531 -531
- package/examples/extensions/gondolin/package-lock.json +185 -185
- package/examples/extensions/gondolin/package.json +19 -19
- package/examples/extensions/handoff.ts +199 -199
- package/examples/extensions/hello.ts +26 -26
- package/examples/extensions/hidden-thinking-label.ts +53 -53
- package/examples/extensions/inline-bash.ts +94 -94
- package/examples/extensions/input-transform-streaming.ts +39 -39
- package/examples/extensions/input-transform.ts +43 -43
- package/examples/extensions/interactive-shell.ts +196 -196
- package/examples/extensions/mac-system-theme.ts +47 -47
- package/examples/extensions/message-renderer.ts +59 -59
- package/examples/extensions/minimal-mode.ts +426 -426
- package/examples/extensions/modal-editor.ts +85 -85
- package/examples/extensions/model-status.ts +31 -31
- package/examples/extensions/notify.ts +55 -55
- package/examples/extensions/overlay-qa-tests.ts +1450 -1450
- package/examples/extensions/overlay-test.ts +153 -153
- package/examples/extensions/permission-gate.ts +34 -34
- package/examples/extensions/pirate.ts +47 -47
- package/examples/extensions/plan-mode/README.md +66 -66
- package/examples/extensions/plan-mode/index.ts +390 -390
- package/examples/extensions/plan-mode/utils.ts +168 -168
- package/examples/extensions/preset.ts +436 -436
- package/examples/extensions/project-trust.ts +64 -64
- package/examples/extensions/prompt-customizer.ts +97 -97
- package/examples/extensions/protected-paths.ts +30 -30
- package/examples/extensions/provider-payload.ts +18 -18
- package/examples/extensions/qna.ts +122 -122
- package/examples/extensions/question.ts +285 -285
- package/examples/extensions/questionnaire.ts +448 -448
- package/examples/extensions/rainbow-editor.ts +88 -88
- package/examples/extensions/reload-runtime.ts +37 -37
- package/examples/extensions/rpc-demo.ts +118 -118
- package/examples/extensions/sandbox/index.ts +321 -321
- package/examples/extensions/sandbox/package-lock.json +92 -92
- package/examples/extensions/sandbox/package.json +19 -19
- package/examples/extensions/send-user-message.ts +97 -97
- package/examples/extensions/session-name.ts +27 -27
- package/examples/extensions/shutdown-command.ts +63 -63
- package/examples/extensions/snake.ts +343 -343
- package/examples/extensions/space-invaders.ts +560 -560
- package/examples/extensions/ssh.ts +220 -220
- package/examples/extensions/status-line.ts +32 -32
- package/examples/extensions/structured-output.ts +65 -65
- package/examples/extensions/subagent/README.md +175 -175
- package/examples/extensions/subagent/agents/planner.md +37 -37
- package/examples/extensions/subagent/agents/reviewer.md +35 -35
- package/examples/extensions/subagent/agents/scout.md +50 -50
- package/examples/extensions/subagent/agents/worker.md +24 -24
- package/examples/extensions/subagent/agents.ts +126 -126
- package/examples/extensions/subagent/index.ts +1015 -1015
- package/examples/extensions/subagent/prompts/implement-and-review.md +10 -10
- package/examples/extensions/subagent/prompts/implement.md +10 -10
- package/examples/extensions/subagent/prompts/scout-and-plan.md +9 -9
- package/examples/extensions/summarize.ts +209 -209
- package/examples/extensions/system-prompt-header.ts +17 -17
- package/examples/extensions/tic-tac-toe.ts +1008 -1008
- package/examples/extensions/timed-confirm.ts +70 -70
- package/examples/extensions/titlebar-spinner.ts +58 -58
- package/examples/extensions/todo.ts +297 -297
- package/examples/extensions/tool-override.ts +144 -144
- package/examples/extensions/tools.ts +146 -146
- package/examples/extensions/trigger-compact.ts +50 -50
- package/examples/extensions/truncated-tool.ts +195 -195
- package/examples/extensions/widget-placement.ts +9 -9
- package/examples/extensions/with-deps/index.ts +32 -32
- package/examples/extensions/with-deps/package-lock.json +31 -31
- package/examples/extensions/with-deps/package.json +22 -22
- package/examples/extensions/working-indicator.ts +123 -123
- package/examples/extensions/working-message-test.ts +25 -25
- package/examples/rpc-extension-ui.ts +632 -632
- package/examples/sdk/01-minimal.ts +26 -26
- package/examples/sdk/02-custom-model.ts +53 -53
- package/examples/sdk/03-custom-prompt.ts +75 -75
- package/examples/sdk/04-skills.ts +55 -55
- package/examples/sdk/05-tools.ts +48 -48
- package/examples/sdk/06-extensions.ts +99 -99
- package/examples/sdk/07-context-files.ts +47 -47
- package/examples/sdk/08-prompt-templates.ts +51 -51
- package/examples/sdk/09-api-keys-and-oauth.ts +52 -52
- package/examples/sdk/10-settings.ts +53 -53
- package/examples/sdk/11-sessions.ts +52 -52
- package/examples/sdk/12-full-control.ts +79 -79
- package/examples/sdk/13-session-runtime.ts +67 -67
- package/examples/sdk/README.md +144 -144
- package/package.json +6 -6
package/dist/core/messages.js
CHANGED
|
@@ -4,15 +4,15 @@
|
|
|
4
4
|
* Extends the base AgentMessage type with coding-agent specific message types,
|
|
5
5
|
* and provides a transformer to convert them to LLM-compatible messages.
|
|
6
6
|
*/
|
|
7
|
-
export const COMPACTION_SUMMARY_PREFIX = `The conversation history before this point was compacted into the following summary:
|
|
8
|
-
|
|
9
|
-
<summary>
|
|
7
|
+
export const COMPACTION_SUMMARY_PREFIX = `The conversation history before this point was compacted into the following summary:
|
|
8
|
+
|
|
9
|
+
<summary>
|
|
10
10
|
`;
|
|
11
|
-
export const COMPACTION_SUMMARY_SUFFIX = `
|
|
11
|
+
export const COMPACTION_SUMMARY_SUFFIX = `
|
|
12
12
|
</summary>`;
|
|
13
|
-
export const BRANCH_SUMMARY_PREFIX = `The following is a summary of a branch that this conversation came back from:
|
|
14
|
-
|
|
15
|
-
<summary>
|
|
13
|
+
export const BRANCH_SUMMARY_PREFIX = `The following is a summary of a branch that this conversation came back from:
|
|
14
|
+
|
|
15
|
+
<summary>
|
|
16
16
|
`;
|
|
17
17
|
export const BRANCH_SUMMARY_SUFFIX = `</summary>`;
|
|
18
18
|
/**
|
|
@@ -279,11 +279,11 @@ export function loadEntriesFromFile(filePath) {
|
|
|
279
279
|
if (!existsSync(resolvedFilePath))
|
|
280
280
|
return [];
|
|
281
281
|
const entries = [];
|
|
282
|
+
let pending = "";
|
|
282
283
|
const fd = openSync(resolvedFilePath, "r");
|
|
283
284
|
try {
|
|
284
285
|
const decoder = new StringDecoder("utf8");
|
|
285
286
|
const buffer = Buffer.allocUnsafe(SESSION_READ_BUFFER_SIZE);
|
|
286
|
-
let pending = "";
|
|
287
287
|
while (true) {
|
|
288
288
|
const bytesRead = readSync(fd, buffer, 0, buffer.length, null);
|
|
289
289
|
if (bytesRead === 0)
|
|
@@ -308,13 +308,15 @@ export function loadEntriesFromFile(filePath) {
|
|
|
308
308
|
finally {
|
|
309
309
|
closeSync(fd);
|
|
310
310
|
}
|
|
311
|
-
// Validate session header
|
|
311
|
+
// Validate session header before repairing the file.
|
|
312
312
|
if (entries.length === 0)
|
|
313
313
|
return entries;
|
|
314
314
|
const header = entries[0];
|
|
315
315
|
if (header.type !== "session" || typeof header.id !== "string") {
|
|
316
316
|
return [];
|
|
317
317
|
}
|
|
318
|
+
if (pending)
|
|
319
|
+
appendFileSync(resolvedFilePath, "\n");
|
|
318
320
|
return entries;
|
|
319
321
|
}
|
|
320
322
|
/**
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { ThinkingLevel } from "@earendil-works/pi-agent-core";
|
|
2
2
|
import type { Transport } from "@earendil-works/pi-ai";
|
|
3
|
-
import type { ScrollViewScrollbar, TuiMode as RendererTuiMode } from "@earendil-works/pi-tui";
|
|
3
|
+
import type { ScrollViewScrollbar, TerminalCapabilities, TuiMode as RendererTuiMode } from "@earendil-works/pi-tui";
|
|
4
4
|
export interface CompactionSettings {
|
|
5
5
|
enabled?: boolean;
|
|
6
6
|
reserveTokens?: number;
|
|
@@ -28,6 +28,9 @@ export interface TerminalSettings {
|
|
|
28
28
|
imageWidthCells?: number;
|
|
29
29
|
clearOnShrink?: boolean;
|
|
30
30
|
showTerminalProgress?: boolean;
|
|
31
|
+
hyperlinks?: boolean | "auto";
|
|
32
|
+
images?: "kitty" | "iterm2" | "auto" | false;
|
|
33
|
+
trueColor?: boolean | "auto";
|
|
31
34
|
}
|
|
32
35
|
export interface ImageSettings {
|
|
33
36
|
autoResize?: boolean;
|
|
@@ -104,6 +107,7 @@ export interface Settings {
|
|
|
104
107
|
defaultTools?: string[];
|
|
105
108
|
fullscreenExitOutput?: FullscreenExitOutput;
|
|
106
109
|
fullscreenScrollbar?: ScrollViewScrollbar;
|
|
110
|
+
fullscreenCopyOnSelect?: boolean;
|
|
107
111
|
images?: ImageSettings;
|
|
108
112
|
enabledModels?: string[];
|
|
109
113
|
doubleEscapeAction?: "fork" | "tree" | "none";
|
|
@@ -285,6 +289,7 @@ export declare class SettingsManager {
|
|
|
285
289
|
setThemePaths(paths: string[]): void;
|
|
286
290
|
setProjectThemePaths(paths: string[]): void;
|
|
287
291
|
getThinkingBudgets(): ThinkingBudgetsSettings | undefined;
|
|
292
|
+
getTerminalCapabilityOverrides(): Partial<TerminalCapabilities>;
|
|
288
293
|
getShowImages(): boolean;
|
|
289
294
|
setShowImages(show: boolean): void;
|
|
290
295
|
getImageWidthCells(): number;
|
|
@@ -299,6 +304,8 @@ export declare class SettingsManager {
|
|
|
299
304
|
setFullscreenScrollbar(mode: ScrollViewScrollbar): void;
|
|
300
305
|
getFullscreenExitOutput(): FullscreenExitOutput;
|
|
301
306
|
setFullscreenExitOutput(output: FullscreenExitOutput): void;
|
|
307
|
+
getFullscreenCopyOnSelect(): boolean;
|
|
308
|
+
setFullscreenCopyOnSelect(enabled: boolean): void;
|
|
302
309
|
getImageAutoResize(): boolean;
|
|
303
310
|
setImageAutoResize(enabled: boolean): void;
|
|
304
311
|
getBlockImages(): boolean;
|
|
@@ -786,6 +786,15 @@ export class SettingsManager {
|
|
|
786
786
|
getThinkingBudgets() {
|
|
787
787
|
return this.settings.thinkingBudgets;
|
|
788
788
|
}
|
|
789
|
+
getTerminalCapabilityOverrides() {
|
|
790
|
+
const terminal = this.settings.terminal;
|
|
791
|
+
const images = terminal?.images;
|
|
792
|
+
return {
|
|
793
|
+
...(images === "kitty" || images === "iterm2" ? { images } : images === false ? { images: null } : {}),
|
|
794
|
+
...(typeof terminal?.trueColor === "boolean" ? { trueColor: terminal.trueColor } : {}),
|
|
795
|
+
...(typeof terminal?.hyperlinks === "boolean" ? { hyperlinks: terminal.hyperlinks } : {}),
|
|
796
|
+
};
|
|
797
|
+
}
|
|
789
798
|
getShowImages() {
|
|
790
799
|
return this.settings.terminal?.showImages ?? true;
|
|
791
800
|
}
|
|
@@ -864,6 +873,14 @@ export class SettingsManager {
|
|
|
864
873
|
this.markModified("fullscreenExitOutput");
|
|
865
874
|
this.save();
|
|
866
875
|
}
|
|
876
|
+
getFullscreenCopyOnSelect() {
|
|
877
|
+
return this.settings.fullscreenCopyOnSelect ?? true;
|
|
878
|
+
}
|
|
879
|
+
setFullscreenCopyOnSelect(enabled) {
|
|
880
|
+
this.globalSettings.fullscreenCopyOnSelect = enabled;
|
|
881
|
+
this.markModified("fullscreenCopyOnSelect");
|
|
882
|
+
this.save();
|
|
883
|
+
}
|
|
867
884
|
getImageAutoResize() {
|
|
868
885
|
return this.settings.images?.autoResize ?? true;
|
|
869
886
|
}
|
|
@@ -24,7 +24,10 @@
|
|
|
24
24
|
"high": "high",
|
|
25
25
|
"xhigh": null,
|
|
26
26
|
"max": "max"
|
|
27
|
-
}
|
|
27
|
+
},
|
|
28
|
+
"compat": {
|
|
29
|
+
"requiresReasoningContentOnAssistantMessages": true
|
|
30
|
+
}
|
|
28
31
|
},
|
|
29
32
|
{
|
|
30
33
|
"id": "celestial-max",
|
|
@@ -40,7 +43,10 @@
|
|
|
40
43
|
"high": "high",
|
|
41
44
|
"xhigh": null,
|
|
42
45
|
"max": "max"
|
|
43
|
-
}
|
|
46
|
+
},
|
|
47
|
+
"compat": {
|
|
48
|
+
"requiresReasoningContentOnAssistantMessages": true
|
|
49
|
+
}
|
|
44
50
|
},
|
|
45
51
|
{
|
|
46
52
|
"id": "celestial-ultra",
|
|
@@ -56,7 +62,10 @@
|
|
|
56
62
|
"high": "high",
|
|
57
63
|
"xhigh": null,
|
|
58
64
|
"max": "max"
|
|
59
|
-
}
|
|
65
|
+
},
|
|
66
|
+
"compat": {
|
|
67
|
+
"requiresReasoningContentOnAssistantMessages": true
|
|
68
|
+
}
|
|
60
69
|
},
|
|
61
70
|
{
|
|
62
71
|
"id": "deepseek-v4-flash",
|
|
@@ -72,7 +81,10 @@
|
|
|
72
81
|
"high": "high",
|
|
73
82
|
"xhigh": null,
|
|
74
83
|
"max": "max"
|
|
75
|
-
}
|
|
84
|
+
},
|
|
85
|
+
"compat": {
|
|
86
|
+
"requiresReasoningContentOnAssistantMessages": true
|
|
87
|
+
}
|
|
76
88
|
},
|
|
77
89
|
{
|
|
78
90
|
"id": "deepseek-v4-flash-vision-exp",
|
|
@@ -88,7 +100,10 @@
|
|
|
88
100
|
"high": "high",
|
|
89
101
|
"xhigh": null,
|
|
90
102
|
"max": "max"
|
|
91
|
-
}
|
|
103
|
+
},
|
|
104
|
+
"compat": {
|
|
105
|
+
"requiresReasoningContentOnAssistantMessages": true
|
|
106
|
+
}
|
|
92
107
|
},
|
|
93
108
|
{
|
|
94
109
|
"id": "deepseek-v4-pro",
|
|
@@ -104,7 +119,10 @@
|
|
|
104
119
|
"high": "high",
|
|
105
120
|
"xhigh": null,
|
|
106
121
|
"max": "max"
|
|
107
|
-
}
|
|
122
|
+
},
|
|
123
|
+
"compat": {
|
|
124
|
+
"requiresReasoningContentOnAssistantMessages": true
|
|
125
|
+
}
|
|
108
126
|
},
|
|
109
127
|
{
|
|
110
128
|
"id": "gpt-5.6-luna",
|
|
@@ -200,7 +218,10 @@
|
|
|
200
218
|
"reasoning": false,
|
|
201
219
|
"input": ["text", "image"],
|
|
202
220
|
"contextWindow": 256000,
|
|
203
|
-
"maxTokens": 64000
|
|
221
|
+
"maxTokens": 64000,
|
|
222
|
+
"compat": {
|
|
223
|
+
"thinkingFormat": "qwen"
|
|
224
|
+
}
|
|
204
225
|
},
|
|
205
226
|
{
|
|
206
227
|
"id": "gemini-3.7-flash",
|
|
@@ -219,7 +240,8 @@
|
|
|
219
240
|
"maxTokens": 8192,
|
|
220
241
|
"compat": {
|
|
221
242
|
"supportsDeveloperRole": false,
|
|
222
|
-
"supportsReasoningEffort": false
|
|
243
|
+
"supportsReasoningEffort": false,
|
|
244
|
+
"thinkingFormat": "qwen"
|
|
223
245
|
}
|
|
224
246
|
},
|
|
225
247
|
{
|
|
@@ -231,7 +253,8 @@
|
|
|
231
253
|
"maxTokens": 8192,
|
|
232
254
|
"compat": {
|
|
233
255
|
"supportsDeveloperRole": false,
|
|
234
|
-
"supportsReasoningEffort": false
|
|
256
|
+
"supportsReasoningEffort": false,
|
|
257
|
+
"thinkingFormat": "qwen"
|
|
235
258
|
}
|
|
236
259
|
}
|
|
237
260
|
]
|
|
@@ -0,0 +1,157 @@
|
|
|
1
|
+
import { describe, expect, it, vi } from "vitest";
|
|
2
|
+
import type { ExtensionAPI, ExtensionContext, SessionEntry } from "@selesai/code";
|
|
3
|
+
import autoSessionNameExtension, {
|
|
4
|
+
MAX_MESSAGE_CHARS,
|
|
5
|
+
MAX_NAME_WORDS,
|
|
6
|
+
MAX_PREVIOUS_MESSAGES,
|
|
7
|
+
NAMING_MAX_TOKENS,
|
|
8
|
+
NAMING_SYSTEM_PROMPT,
|
|
9
|
+
previousUserMessages,
|
|
10
|
+
} from "./auto-session-name.ts";
|
|
11
|
+
|
|
12
|
+
vi.mock("@earendil-works/pi-ai/compat", async (importOriginal) => {
|
|
13
|
+
const actual = await importOriginal<typeof import("@earendil-works/pi-ai/compat")>();
|
|
14
|
+
return {
|
|
15
|
+
...actual,
|
|
16
|
+
complete: vi.fn(),
|
|
17
|
+
};
|
|
18
|
+
});
|
|
19
|
+
|
|
20
|
+
import { complete } from "@earendil-works/pi-ai/compat";
|
|
21
|
+
const completeMock = vi.mocked(complete);
|
|
22
|
+
|
|
23
|
+
type Handler = (event: unknown, ctx: ExtensionContext) => void | Promise<void>;
|
|
24
|
+
|
|
25
|
+
function userEntry(text: string, id: string): SessionEntry {
|
|
26
|
+
return {
|
|
27
|
+
id,
|
|
28
|
+
type: "message",
|
|
29
|
+
message: { role: "user", content: [{ type: "text", text }], timestamp: 100 },
|
|
30
|
+
parentId: "root",
|
|
31
|
+
timestamp: "2025-01-01T00:00:00.000Z",
|
|
32
|
+
} as unknown as SessionEntry;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
function createHarness(branch: SessionEntry[] = []) {
|
|
36
|
+
const handlers = new Map<string, Handler>();
|
|
37
|
+
const setSessionName = vi.fn();
|
|
38
|
+
const pi = {
|
|
39
|
+
on: vi.fn((event: string, handler: Handler) => handlers.set(event, handler)),
|
|
40
|
+
setSessionName,
|
|
41
|
+
} as unknown as ExtensionAPI;
|
|
42
|
+
const model = { provider: "openai", id: "gpt-5", name: "GPT-5" };
|
|
43
|
+
const ctx = {
|
|
44
|
+
model,
|
|
45
|
+
modelRegistry: {
|
|
46
|
+
getApiKeyAndHeaders: vi.fn().mockResolvedValue({ ok: true, apiKey: "key", headers: {} }),
|
|
47
|
+
},
|
|
48
|
+
sessionManager: { getBranch: () => branch },
|
|
49
|
+
} as unknown as ExtensionContext;
|
|
50
|
+
|
|
51
|
+
autoSessionNameExtension(pi);
|
|
52
|
+
return { handlers, setSessionName, ctx };
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
function textResponse(text: string) {
|
|
56
|
+
return {
|
|
57
|
+
content: [{ type: "text", text }],
|
|
58
|
+
stopReason: "stop",
|
|
59
|
+
usage: { input: 0, output: 0 },
|
|
60
|
+
} as never;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
describe("auto-session-name", () => {
|
|
64
|
+
beforeEach(() => {
|
|
65
|
+
vi.clearAllMocks();
|
|
66
|
+
});
|
|
67
|
+
|
|
68
|
+
it("registers an input handler", () => {
|
|
69
|
+
const { handlers } = createHarness();
|
|
70
|
+
expect(handlers.has("input")).toBe(true);
|
|
71
|
+
});
|
|
72
|
+
|
|
73
|
+
it("names the session from the user prompt with a small system prompt and 10-token cap", async () => {
|
|
74
|
+
const { handlers, setSessionName, ctx } = createHarness();
|
|
75
|
+
completeMock.mockResolvedValue(textResponse("Refactor auth"));
|
|
76
|
+
|
|
77
|
+
await handlers.get("input")!({ type: "input", text: "refactor the auth module", source: "interactive" }, ctx);
|
|
78
|
+
await vi.waitFor(() => expect(setSessionName).toHaveBeenCalledWith("Refactor auth"));
|
|
79
|
+
|
|
80
|
+
expect(completeMock).toHaveBeenCalledTimes(1);
|
|
81
|
+
const [model, context, options] = completeMock.mock.calls[0];
|
|
82
|
+
expect(model).toBe(ctx.model);
|
|
83
|
+
expect(context.systemPrompt).toBe(NAMING_SYSTEM_PROMPT);
|
|
84
|
+
expect(context.messages).toHaveLength(1);
|
|
85
|
+
expect(context.messages[0].role).toBe("user");
|
|
86
|
+
expect(context.messages[0].content).toBe("refactor the auth module");
|
|
87
|
+
expect(options?.maxTokens).toBe(NAMING_MAX_TOKENS);
|
|
88
|
+
expect(options?.samplingParams).toEqual({ reasoning_effort: "none" });
|
|
89
|
+
expect(setSessionName).toHaveBeenCalledWith("Refactor auth");
|
|
90
|
+
});
|
|
91
|
+
|
|
92
|
+
it("caps the name at 5 words even if the model returns more", async () => {
|
|
93
|
+
const { handlers, setSessionName, ctx } = createHarness();
|
|
94
|
+
completeMock.mockResolvedValue(textResponse("one two three four five six seven"));
|
|
95
|
+
|
|
96
|
+
await handlers.get("input")!({ type: "input", text: "hello", source: "interactive" }, ctx);
|
|
97
|
+
await vi.waitFor(() => expect(setSessionName).toHaveBeenCalledWith("one two three four five"));
|
|
98
|
+
|
|
99
|
+
expect(setSessionName.mock.calls[0][0].split(/\s+/)).toHaveLength(MAX_NAME_WORDS);
|
|
100
|
+
});
|
|
101
|
+
|
|
102
|
+
it("includes previous user messages (newest first) for context", async () => {
|
|
103
|
+
const branch = [userEntry("first message", "u1"), userEntry("second message", "u2")];
|
|
104
|
+
const { handlers, ctx } = createHarness(branch);
|
|
105
|
+
completeMock.mockResolvedValue(textResponse("Auth refactor"));
|
|
106
|
+
|
|
107
|
+
await handlers.get("input")!({ type: "input", text: "now fix the tests", source: "interactive" }, ctx);
|
|
108
|
+
|
|
109
|
+
const [, context] = completeMock.mock.calls[0];
|
|
110
|
+
expect(context.messages[0].content).toBe("second message\nfirst message\nnow fix the tests");
|
|
111
|
+
});
|
|
112
|
+
|
|
113
|
+
it("truncates long previous messages and caps the count", () => {
|
|
114
|
+
const long = "x".repeat(MAX_MESSAGE_CHARS + 50);
|
|
115
|
+
const branch = Array.from({ length: MAX_PREVIOUS_MESSAGES + 5 }, (_, i) =>
|
|
116
|
+
userEntry(i === MAX_PREVIOUS_MESSAGES + 4 ? long : `msg ${i}`, `u${i}`),
|
|
117
|
+
);
|
|
118
|
+
const texts = previousUserMessages({ getBranch: () => branch });
|
|
119
|
+
|
|
120
|
+
expect(texts).toHaveLength(MAX_PREVIOUS_MESSAGES);
|
|
121
|
+
expect(texts[0]).toBe(`${"x".repeat(MAX_MESSAGE_CHARS)}…`);
|
|
122
|
+
expect(texts[1]).toBe("msg 23");
|
|
123
|
+
});
|
|
124
|
+
|
|
125
|
+
it("skips extension-sourced input, commands, and empty text", async () => {
|
|
126
|
+
const { handlers, setSessionName, ctx } = createHarness();
|
|
127
|
+
|
|
128
|
+
await handlers.get("input")!({ type: "input", text: "hi", source: "extension" }, ctx);
|
|
129
|
+
await handlers.get("input")!({ type: "input", text: "/name foo", source: "interactive" }, ctx);
|
|
130
|
+
await handlers.get("input")!({ type: "input", text: " ", source: "interactive" }, ctx);
|
|
131
|
+
|
|
132
|
+
expect(completeMock).not.toHaveBeenCalled();
|
|
133
|
+
expect(setSessionName).not.toHaveBeenCalled();
|
|
134
|
+
});
|
|
135
|
+
|
|
136
|
+
it("does not set a name when the model returns no text", async () => {
|
|
137
|
+
const { handlers, setSessionName, ctx } = createHarness();
|
|
138
|
+
completeMock.mockResolvedValue({ content: [], stopReason: "stop" } as never);
|
|
139
|
+
|
|
140
|
+
await handlers.get("input")!({ type: "input", text: "hello", source: "interactive" }, ctx);
|
|
141
|
+
|
|
142
|
+
expect(setSessionName).not.toHaveBeenCalled();
|
|
143
|
+
});
|
|
144
|
+
|
|
145
|
+
it("swallows auth and completion errors without breaking the message flow", async () => {
|
|
146
|
+
const { handlers, setSessionName, ctx } = createHarness();
|
|
147
|
+
ctx.modelRegistry.getApiKeyAndHeaders = vi.fn().mockResolvedValue({ ok: false, error: "no key" });
|
|
148
|
+
await handlers.get("input")!({ type: "input", text: "hello", source: "interactive" }, ctx);
|
|
149
|
+
expect(setSessionName).not.toHaveBeenCalled();
|
|
150
|
+
|
|
151
|
+
ctx.modelRegistry.getApiKeyAndHeaders = vi.fn().mockResolvedValue({ ok: true, apiKey: "key" });
|
|
152
|
+
completeMock.mockRejectedValue(new Error("boom"));
|
|
153
|
+
await handlers.get("input")!({ type: "input", text: "hello", source: "interactive" }, ctx);
|
|
154
|
+
await vi.waitFor(() => expect(completeMock).toHaveBeenCalled());
|
|
155
|
+
expect(setSessionName).not.toHaveBeenCalled();
|
|
156
|
+
});
|
|
157
|
+
});
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* auto-session-name
|
|
3
|
+
*
|
|
4
|
+
* Names the session on every user message using the currently selected model.
|
|
5
|
+
* Sends only user messages (current prompt plus previous user messages,
|
|
6
|
+
* truncated) for context, capped at 10 output tokens (1-5 word name).
|
|
7
|
+
* Thinking is never enabled. Equivalent to running /name automatically.
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
import { complete } from "@earendil-works/pi-ai/compat";
|
|
11
|
+
import type { ExtensionAPI, SessionEntry } from "@selesai/code";
|
|
12
|
+
|
|
13
|
+
export const NAMING_SYSTEM_PROMPT =
|
|
14
|
+
"Reply with only a short session name (1-5 words) for this conversation based on the user's messages. No punctuation, no quotes, no explanation.";
|
|
15
|
+
|
|
16
|
+
export const NAMING_MAX_TOKENS = 10;
|
|
17
|
+
/** Hard cap on the name itself: at most 5 words (≈5 tokens). */
|
|
18
|
+
export const MAX_NAME_WORDS = 5;
|
|
19
|
+
/** How many previous user messages to include, newest first. */
|
|
20
|
+
export const MAX_PREVIOUS_MESSAGES = 20;
|
|
21
|
+
/** Per-message character cap when truncating. */
|
|
22
|
+
export const MAX_MESSAGE_CHARS = 200;
|
|
23
|
+
|
|
24
|
+
function truncate(text: string): string {
|
|
25
|
+
return text.length > MAX_MESSAGE_CHARS ? `${text.slice(0, MAX_MESSAGE_CHARS)}…` : text;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
/** Collect previous user message texts from the session branch, newest first, truncated. */
|
|
29
|
+
export function previousUserMessages(sessionManager: { getBranch(): SessionEntry[] }): string[] {
|
|
30
|
+
const branch = sessionManager.getBranch();
|
|
31
|
+
const texts: string[] = [];
|
|
32
|
+
for (let i = branch.length - 1; i >= 0 && texts.length < MAX_PREVIOUS_MESSAGES; i--) {
|
|
33
|
+
const entry = branch[i];
|
|
34
|
+
if (entry.type !== "message" || entry.message.role !== "user") continue;
|
|
35
|
+
const content = entry.message.content;
|
|
36
|
+
const text = typeof content === "string" ? content : content
|
|
37
|
+
.filter((c): c is { type: "text"; text: string } => c.type === "text")
|
|
38
|
+
.map((c) => c.text)
|
|
39
|
+
.join("\n");
|
|
40
|
+
if (text.trim()) texts.push(truncate(text.trim()));
|
|
41
|
+
}
|
|
42
|
+
return texts;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
export default function autoSessionNameExtension(pi: ExtensionAPI): void {
|
|
46
|
+
// Guards run synchronously; the naming call itself is fire-and-forget so it
|
|
47
|
+
// never blocks the user's message from being sent.
|
|
48
|
+
let namingSeq = 0;
|
|
49
|
+
pi.on("input", (event, ctx) => {
|
|
50
|
+
// Only real user messages; skip extension-sourced messages and commands.
|
|
51
|
+
if (event.source === "extension") return;
|
|
52
|
+
const text = event.text.trim();
|
|
53
|
+
if (!text || text.startsWith("/")) return;
|
|
54
|
+
if (!ctx.model) return;
|
|
55
|
+
|
|
56
|
+
const seq = ++namingSeq;
|
|
57
|
+
void (async () => {
|
|
58
|
+
try {
|
|
59
|
+
const auth = await ctx.modelRegistry.getApiKeyAndHeaders(ctx.model);
|
|
60
|
+
if (!auth.ok || !auth.apiKey) return;
|
|
61
|
+
|
|
62
|
+
const previous = previousUserMessages(ctx.sessionManager);
|
|
63
|
+
const conversation = [...previous, text].join("\n");
|
|
64
|
+
|
|
65
|
+
const response = await complete(
|
|
66
|
+
ctx.model,
|
|
67
|
+
{
|
|
68
|
+
systemPrompt: NAMING_SYSTEM_PROMPT,
|
|
69
|
+
messages: [{ role: "user", content: conversation, timestamp: Date.now() }],
|
|
70
|
+
},
|
|
71
|
+
{
|
|
72
|
+
apiKey: auth.apiKey,
|
|
73
|
+
headers: auth.headers,
|
|
74
|
+
maxTokens: NAMING_MAX_TOKENS,
|
|
75
|
+
cacheRetention: "none",
|
|
76
|
+
// The tokenin gateway ignores `thinking: {type:"disabled"}` and burns the
|
|
77
|
+
// whole budget on reasoning; `reasoning_effort: "none"` is what disables it.
|
|
78
|
+
samplingParams: { reasoning_effort: "none" },
|
|
79
|
+
},
|
|
80
|
+
);
|
|
81
|
+
const name = response.content
|
|
82
|
+
.filter((c): c is { type: "text"; text: string } => c.type === "text")
|
|
83
|
+
.map((c) => c.text)
|
|
84
|
+
.join("")
|
|
85
|
+
.trim()
|
|
86
|
+
.split(/\s+/)
|
|
87
|
+
.slice(0, MAX_NAME_WORDS)
|
|
88
|
+
.join(" ");
|
|
89
|
+
// Only the latest request may set the name; slower older responses lose.
|
|
90
|
+
if (name && seq === namingSeq) pi.setSessionName(name);
|
|
91
|
+
} catch {
|
|
92
|
+
// Best-effort naming; never break the user's message flow.
|
|
93
|
+
}
|
|
94
|
+
})();
|
|
95
|
+
});
|
|
96
|
+
}
|
|
@@ -1,82 +1,82 @@
|
|
|
1
|
-
import { describe, expect, it, vi } from "vitest";
|
|
2
|
-
import type { ExtensionAPI, ExtensionContext } from "@selesai/code";
|
|
3
|
-
import contextCompactionReminderExtension, {
|
|
4
|
-
CONTEXT_COMPACTION_REMINDER_MESSAGE,
|
|
5
|
-
} from "./context-compaction-reminder.ts";
|
|
6
|
-
|
|
7
|
-
type Handler = (event: unknown, ctx: ExtensionContext) => void | Promise<void>;
|
|
8
|
-
|
|
9
|
-
function createHarness(tokens: number | null | undefined = undefined) {
|
|
10
|
-
const handlers = new Map<string, Handler>();
|
|
11
|
-
const notify = vi.fn();
|
|
12
|
-
const pi = {
|
|
13
|
-
on: vi.fn((event: string, handler: Handler) => handlers.set(event, handler)),
|
|
14
|
-
} as unknown as ExtensionAPI;
|
|
15
|
-
const ctx = {
|
|
16
|
-
getContextUsage: () =>
|
|
17
|
-
tokens === undefined ? undefined : { tokens, contextWindow: 200_000, percent: tokens === null ? null : tokens / 2_000 },
|
|
18
|
-
ui: { notify },
|
|
19
|
-
} as unknown as ExtensionContext;
|
|
20
|
-
|
|
21
|
-
contextCompactionReminderExtension(pi);
|
|
22
|
-
|
|
23
|
-
return {
|
|
24
|
-
notify,
|
|
25
|
-
setTokens: (value: number | null | undefined) => {
|
|
26
|
-
tokens = value;
|
|
27
|
-
},
|
|
28
|
-
settle: () => handlers.get("agent_settled")!({ type: "agent_settled" }, ctx),
|
|
29
|
-
compact: () => handlers.get("session_compact")!({ type: "session_compact" }, ctx),
|
|
30
|
-
};
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
describe("context-compaction-reminder", () => {
|
|
34
|
-
it("warns once when known context reaches 128k", async () => {
|
|
35
|
-
const { notify, setTokens, settle } = createHarness(127_999);
|
|
36
|
-
|
|
37
|
-
await settle();
|
|
38
|
-
setTokens(128_000);
|
|
39
|
-
await settle();
|
|
40
|
-
setTokens(130_000);
|
|
41
|
-
await settle();
|
|
42
|
-
|
|
43
|
-
expect(notify).toHaveBeenCalledTimes(1);
|
|
44
|
-
expect(notify).toHaveBeenCalledWith(CONTEXT_COMPACTION_REMINDER_MESSAGE, "warning");
|
|
45
|
-
});
|
|
46
|
-
|
|
47
|
-
it("does not reset the reminder for unavailable or post-compaction usage", async () => {
|
|
48
|
-
const { notify, setTokens, settle } = createHarness(128_000);
|
|
49
|
-
|
|
50
|
-
await settle();
|
|
51
|
-
setTokens(undefined);
|
|
52
|
-
await settle();
|
|
53
|
-
setTokens(null);
|
|
54
|
-
await settle();
|
|
55
|
-
setTokens(130_000);
|
|
56
|
-
await settle();
|
|
57
|
-
|
|
58
|
-
expect(notify).toHaveBeenCalledTimes(1);
|
|
59
|
-
});
|
|
60
|
-
|
|
61
|
-
it("allows another warning after successful compaction", async () => {
|
|
62
|
-
const { notify, settle, compact } = createHarness(128_000);
|
|
63
|
-
|
|
64
|
-
await settle();
|
|
65
|
-
await compact();
|
|
66
|
-
await settle();
|
|
67
|
-
|
|
68
|
-
expect(notify).toHaveBeenCalledTimes(2);
|
|
69
|
-
});
|
|
70
|
-
|
|
71
|
-
it("allows another warning after known usage drops below 128k", async () => {
|
|
72
|
-
const { notify, setTokens, settle } = createHarness(128_000);
|
|
73
|
-
|
|
74
|
-
await settle();
|
|
75
|
-
setTokens(127_999);
|
|
76
|
-
await settle();
|
|
77
|
-
setTokens(128_000);
|
|
78
|
-
await settle();
|
|
79
|
-
|
|
80
|
-
expect(notify).toHaveBeenCalledTimes(2);
|
|
81
|
-
});
|
|
82
|
-
});
|
|
1
|
+
import { describe, expect, it, vi } from "vitest";
|
|
2
|
+
import type { ExtensionAPI, ExtensionContext } from "@selesai/code";
|
|
3
|
+
import contextCompactionReminderExtension, {
|
|
4
|
+
CONTEXT_COMPACTION_REMINDER_MESSAGE,
|
|
5
|
+
} from "./context-compaction-reminder.ts";
|
|
6
|
+
|
|
7
|
+
type Handler = (event: unknown, ctx: ExtensionContext) => void | Promise<void>;
|
|
8
|
+
|
|
9
|
+
function createHarness(tokens: number | null | undefined = undefined) {
|
|
10
|
+
const handlers = new Map<string, Handler>();
|
|
11
|
+
const notify = vi.fn();
|
|
12
|
+
const pi = {
|
|
13
|
+
on: vi.fn((event: string, handler: Handler) => handlers.set(event, handler)),
|
|
14
|
+
} as unknown as ExtensionAPI;
|
|
15
|
+
const ctx = {
|
|
16
|
+
getContextUsage: () =>
|
|
17
|
+
tokens === undefined ? undefined : { tokens, contextWindow: 200_000, percent: tokens === null ? null : tokens / 2_000 },
|
|
18
|
+
ui: { notify },
|
|
19
|
+
} as unknown as ExtensionContext;
|
|
20
|
+
|
|
21
|
+
contextCompactionReminderExtension(pi);
|
|
22
|
+
|
|
23
|
+
return {
|
|
24
|
+
notify,
|
|
25
|
+
setTokens: (value: number | null | undefined) => {
|
|
26
|
+
tokens = value;
|
|
27
|
+
},
|
|
28
|
+
settle: () => handlers.get("agent_settled")!({ type: "agent_settled" }, ctx),
|
|
29
|
+
compact: () => handlers.get("session_compact")!({ type: "session_compact" }, ctx),
|
|
30
|
+
};
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
describe("context-compaction-reminder", () => {
|
|
34
|
+
it("warns once when known context reaches 128k", async () => {
|
|
35
|
+
const { notify, setTokens, settle } = createHarness(127_999);
|
|
36
|
+
|
|
37
|
+
await settle();
|
|
38
|
+
setTokens(128_000);
|
|
39
|
+
await settle();
|
|
40
|
+
setTokens(130_000);
|
|
41
|
+
await settle();
|
|
42
|
+
|
|
43
|
+
expect(notify).toHaveBeenCalledTimes(1);
|
|
44
|
+
expect(notify).toHaveBeenCalledWith(CONTEXT_COMPACTION_REMINDER_MESSAGE, "warning");
|
|
45
|
+
});
|
|
46
|
+
|
|
47
|
+
it("does not reset the reminder for unavailable or post-compaction usage", async () => {
|
|
48
|
+
const { notify, setTokens, settle } = createHarness(128_000);
|
|
49
|
+
|
|
50
|
+
await settle();
|
|
51
|
+
setTokens(undefined);
|
|
52
|
+
await settle();
|
|
53
|
+
setTokens(null);
|
|
54
|
+
await settle();
|
|
55
|
+
setTokens(130_000);
|
|
56
|
+
await settle();
|
|
57
|
+
|
|
58
|
+
expect(notify).toHaveBeenCalledTimes(1);
|
|
59
|
+
});
|
|
60
|
+
|
|
61
|
+
it("allows another warning after successful compaction", async () => {
|
|
62
|
+
const { notify, settle, compact } = createHarness(128_000);
|
|
63
|
+
|
|
64
|
+
await settle();
|
|
65
|
+
await compact();
|
|
66
|
+
await settle();
|
|
67
|
+
|
|
68
|
+
expect(notify).toHaveBeenCalledTimes(2);
|
|
69
|
+
});
|
|
70
|
+
|
|
71
|
+
it("allows another warning after known usage drops below 128k", async () => {
|
|
72
|
+
const { notify, setTokens, settle } = createHarness(128_000);
|
|
73
|
+
|
|
74
|
+
await settle();
|
|
75
|
+
setTokens(127_999);
|
|
76
|
+
await settle();
|
|
77
|
+
setTokens(128_000);
|
|
78
|
+
await settle();
|
|
79
|
+
|
|
80
|
+
expect(notify).toHaveBeenCalledTimes(2);
|
|
81
|
+
});
|
|
82
|
+
});
|