@vandeepunk/pi-coding-agent 0.0.6 → 1.0.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 +814 -16
- package/README.md +66 -27
- package/dist/bun/cli.d.ts +3 -0
- package/dist/bun/cli.d.ts.map +1 -0
- package/dist/bun/cli.js +7 -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/cli/args.d.ts +9 -4
- package/dist/cli/args.d.ts.map +1 -1
- package/dist/cli/args.js +61 -22
- package/dist/cli/args.js.map +1 -1
- package/dist/cli/file-processor.d.ts.map +1 -1
- package/dist/cli/file-processor.js +4 -0
- package/dist/cli/file-processor.js.map +1 -1
- 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/session-picker.d.ts.map +1 -1
- package/dist/cli/session-picker.js +2 -1
- package/dist/cli/session-picker.js.map +1 -1
- package/dist/cli.d.ts.map +1 -1
- package/dist/cli.js +3 -0
- package/dist/cli.js.map +1 -1
- package/dist/config.d.ts +1 -1
- package/dist/config.d.ts.map +1 -1
- package/dist/config.js +2 -2
- package/dist/config.js.map +1 -1
- package/dist/core/agent-session-runtime.d.ts +83 -0
- package/dist/core/agent-session-runtime.d.ts.map +1 -0
- package/dist/core/agent-session-runtime.js +236 -0
- package/dist/core/agent-session-runtime.js.map +1 -0
- package/dist/core/agent-session-services.d.ts +86 -0
- package/dist/core/agent-session-services.d.ts.map +1 -0
- package/dist/core/agent-session-services.js +116 -0
- package/dist/core/agent-session-services.js.map +1 -0
- package/dist/core/agent-session.d.ts +63 -49
- package/dist/core/agent-session.d.ts.map +1 -1
- package/dist/core/agent-session.js +599 -370
- package/dist/core/agent-session.js.map +1 -1
- package/dist/core/auth-storage.d.ts +38 -8
- package/dist/core/auth-storage.d.ts.map +1 -1
- package/dist/core/auth-storage.js +220 -96
- package/dist/core/auth-storage.js.map +1 -1
- package/dist/core/bash-executor.d.ts +6 -7
- package/dist/core/bash-executor.d.ts.map +1 -1
- package/dist/core/bash-executor.js +27 -114
- package/dist/core/bash-executor.js.map +1 -1
- package/dist/core/compaction/branch-summarization.d.ts +2 -0
- package/dist/core/compaction/branch-summarization.d.ts.map +1 -1
- package/dist/core/compaction/branch-summarization.js +3 -2
- package/dist/core/compaction/branch-summarization.js.map +1 -1
- package/dist/core/compaction/compaction.d.ts +3 -3
- package/dist/core/compaction/compaction.d.ts.map +1 -1
- package/dist/core/compaction/compaction.js +31 -25
- package/dist/core/compaction/compaction.js.map +1 -1
- package/dist/core/compaction/utils.d.ts +3 -0
- package/dist/core/compaction/utils.d.ts.map +1 -1
- package/dist/core/compaction/utils.js +16 -1
- package/dist/core/compaction/utils.js.map +1 -1
- package/dist/core/exec.d.ts.map +1 -1
- package/dist/core/exec.js +7 -3
- package/dist/core/exec.js.map +1 -1
- package/dist/core/export-html/index.d.ts +7 -4
- package/dist/core/export-html/index.d.ts.map +1 -1
- package/dist/core/export-html/index.js +10 -8
- package/dist/core/export-html/index.js.map +1 -1
- package/dist/core/export-html/template.css +43 -13
- package/dist/core/export-html/template.html +1 -0
- package/dist/core/export-html/template.js +118 -14
- package/dist/core/export-html/tool-renderer.d.ts +9 -4
- package/dist/core/export-html/tool-renderer.d.ts.map +1 -1
- package/dist/core/export-html/tool-renderer.js +48 -10
- package/dist/core/export-html/tool-renderer.js.map +1 -1
- package/dist/core/extensions/index.d.ts +5 -4
- package/dist/core/extensions/index.d.ts.map +1 -1
- package/dist/core/extensions/index.js +2 -2
- package/dist/core/extensions/index.js.map +1 -1
- package/dist/core/extensions/loader.d.ts.map +1 -1
- package/dist/core/extensions/loader.js +49 -13
- package/dist/core/extensions/loader.js.map +1 -1
- package/dist/core/extensions/runner.d.ts +13 -11
- package/dist/core/extensions/runner.d.ts.map +1 -1
- package/dist/core/extensions/runner.js +139 -64
- package/dist/core/extensions/runner.js.map +1 -1
- package/dist/core/extensions/types.d.ts +174 -34
- package/dist/core/extensions/types.d.ts.map +1 -1
- package/dist/core/extensions/types.js +10 -0
- package/dist/core/extensions/types.js.map +1 -1
- package/dist/core/extensions/wrapper.d.ts +4 -11
- package/dist/core/extensions/wrapper.d.ts.map +1 -1
- package/dist/core/extensions/wrapper.js +6 -86
- package/dist/core/extensions/wrapper.js.map +1 -1
- package/dist/core/footer-data-provider.d.ts +18 -2
- package/dist/core/footer-data-provider.d.ts.map +1 -1
- package/dist/core/footer-data-provider.js +220 -40
- package/dist/core/footer-data-provider.js.map +1 -1
- package/dist/core/index.d.ts +4 -1
- package/dist/core/index.d.ts.map +1 -1
- package/dist/core/index.js +4 -1
- package/dist/core/index.js.map +1 -1
- package/dist/core/keybindings.d.ts +283 -50
- package/dist/core/keybindings.d.ts.map +1 -1
- package/dist/core/keybindings.js +221 -134
- package/dist/core/keybindings.js.map +1 -1
- package/dist/core/model-registry.d.ts +33 -3
- package/dist/core/model-registry.d.ts.map +1 -1
- package/dist/core/model-registry.js +165 -97
- package/dist/core/model-registry.js.map +1 -1
- package/dist/core/model-resolver.d.ts +35 -1
- package/dist/core/model-resolver.d.ts.map +1 -1
- package/dist/core/model-resolver.js +205 -32
- package/dist/core/model-resolver.js.map +1 -1
- package/dist/core/output-guard.d.ts +6 -0
- package/dist/core/output-guard.d.ts.map +1 -0
- package/dist/core/output-guard.js +59 -0
- package/dist/core/output-guard.js.map +1 -0
- package/dist/core/package-manager.d.ts +43 -2
- package/dist/core/package-manager.d.ts.map +1 -1
- package/dist/core/package-manager.js +541 -102
- package/dist/core/package-manager.js.map +1 -1
- package/dist/core/prompt-templates.d.ts +5 -4
- package/dist/core/prompt-templates.d.ts.map +1 -1
- package/dist/core/prompt-templates.js +35 -37
- package/dist/core/prompt-templates.js.map +1 -1
- package/dist/core/resolve-config-value.d.ts +6 -0
- package/dist/core/resolve-config-value.d.ts.map +1 -1
- package/dist/core/resolve-config-value.js +75 -8
- package/dist/core/resolve-config-value.js.map +1 -1
- package/dist/core/resource-loader.d.ts +6 -5
- package/dist/core/resource-loader.d.ts.map +1 -1
- package/dist/core/resource-loader.js +166 -119
- package/dist/core/resource-loader.js.map +1 -1
- package/dist/core/sdk.d.ts +11 -8
- package/dist/core/sdk.d.ts.map +1 -1
- package/dist/core/sdk.js +31 -29
- package/dist/core/sdk.js.map +1 -1
- 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 +11 -1
- package/dist/core/session-manager.d.ts.map +1 -1
- package/dist/core/session-manager.js +39 -25
- package/dist/core/session-manager.js.map +1 -1
- package/dist/core/settings-manager.d.ts +60 -10
- package/dist/core/settings-manager.d.ts.map +1 -1
- package/dist/core/settings-manager.js +291 -140
- package/dist/core/settings-manager.js.map +1 -1
- package/dist/core/skills.d.ts +5 -3
- package/dist/core/skills.d.ts.map +1 -1
- package/dist/core/skills.js +54 -9
- package/dist/core/skills.js.map +1 -1
- package/dist/core/slash-commands.d.ts +2 -3
- package/dist/core/slash-commands.d.ts.map +1 -1
- package/dist/core/slash-commands.js +3 -2
- package/dist/core/slash-commands.js.map +1 -1
- 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 +4 -0
- package/dist/core/system-prompt.d.ts.map +1 -1
- package/dist/core/system-prompt.js +31 -52
- package/dist/core/system-prompt.js.map +1 -1
- package/dist/core/timings.d.ts +1 -0
- package/dist/core/timings.d.ts.map +1 -1
- package/dist/core/timings.js +6 -0
- package/dist/core/timings.js.map +1 -1
- package/dist/core/tools/bash.d.ts +24 -6
- package/dist/core/tools/bash.d.ts.map +1 -1
- package/dist/core/tools/bash.js +225 -115
- package/dist/core/tools/bash.js.map +1 -1
- package/dist/core/tools/edit-diff.d.ts +23 -1
- package/dist/core/tools/edit-diff.d.ts.map +1 -1
- package/dist/core/tools/edit-diff.js +151 -57
- package/dist/core/tools/edit-diff.js.map +1 -1
- package/dist/core/tools/edit.d.ts +20 -6
- package/dist/core/tools/edit.d.ts.map +1 -1
- package/dist/core/tools/edit.js +111 -61
- package/dist/core/tools/edit.js.map +1 -1
- 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 +37 -0
- package/dist/core/tools/file-mutation-queue.js.map +1 -0
- package/dist/core/tools/find.d.ts +11 -4
- package/dist/core/tools/find.d.ts.map +1 -1
- package/dist/core/tools/find.js +82 -30
- package/dist/core/tools/find.js.map +1 -1
- package/dist/core/tools/grep.d.ts +15 -4
- package/dist/core/tools/grep.d.ts.map +1 -1
- package/dist/core/tools/grep.js +83 -29
- package/dist/core/tools/grep.js.map +1 -1
- package/dist/core/tools/index.d.ts +63 -21
- package/dist/core/tools/index.d.ts.map +1 -1
- package/dist/core/tools/index.js +51 -26
- package/dist/core/tools/index.js.map +1 -1
- package/dist/core/tools/ls.d.ts +9 -3
- package/dist/core/tools/ls.d.ts.map +1 -1
- package/dist/core/tools/ls.js +67 -13
- package/dist/core/tools/ls.js.map +1 -1
- package/dist/core/tools/read.d.ts +10 -3
- package/dist/core/tools/read.d.ts.map +1 -1
- package/dist/core/tools/read.js +110 -51
- package/dist/core/tools/read.js.map +1 -1
- package/dist/core/tools/render-utils.d.ts +21 -0
- package/dist/core/tools/render-utils.d.ts.map +1 -0
- package/dist/core/tools/render-utils.js +49 -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 +32 -0
- package/dist/core/tools/tool-definition-wrapper.js.map +1 -0
- package/dist/core/tools/write.d.ts +9 -3
- package/dist/core/tools/write.d.ts.map +1 -1
- package/dist/core/tools/write.js +168 -30
- package/dist/core/tools/write.js.map +1 -1
- package/dist/index.d.ts +7 -6
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +7 -6
- package/dist/index.js.map +1 -1
- package/dist/main.d.ts.map +1 -1
- package/dist/main.js +354 -379
- package/dist/main.js.map +1 -1
- package/dist/migrations.d.ts.map +1 -1
- package/dist/migrations.js +31 -11
- package/dist/migrations.js.map +1 -1
- package/dist/modes/interactive/components/assistant-message.d.ts +3 -1
- package/dist/modes/interactive/components/assistant-message.d.ts.map +1 -1
- package/dist/modes/interactive/components/assistant-message.js +14 -3
- package/dist/modes/interactive/components/assistant-message.js.map +1 -1
- package/dist/modes/interactive/components/bash-execution.d.ts +0 -1
- package/dist/modes/interactive/components/bash-execution.d.ts.map +1 -1
- package/dist/modes/interactive/components/bash-execution.js +22 -9
- package/dist/modes/interactive/components/bash-execution.js.map +1 -1
- package/dist/modes/interactive/components/bordered-loader.d.ts.map +1 -1
- package/dist/modes/interactive/components/bordered-loader.js +1 -1
- package/dist/modes/interactive/components/bordered-loader.js.map +1 -1
- package/dist/modes/interactive/components/branch-summary-message.d.ts.map +1 -1
- package/dist/modes/interactive/components/branch-summary-message.js +2 -2
- package/dist/modes/interactive/components/branch-summary-message.js.map +1 -1
- package/dist/modes/interactive/components/compaction-summary-message.d.ts.map +1 -1
- package/dist/modes/interactive/components/compaction-summary-message.js +2 -2
- package/dist/modes/interactive/components/compaction-summary-message.js.map +1 -1
- package/dist/modes/interactive/components/config-selector.d.ts +1 -1
- package/dist/modes/interactive/components/config-selector.d.ts.map +1 -1
- package/dist/modes/interactive/components/config-selector.js +14 -14
- package/dist/modes/interactive/components/config-selector.js.map +1 -1
- package/dist/modes/interactive/components/custom-editor.d.ts +3 -3
- package/dist/modes/interactive/components/custom-editor.d.ts.map +1 -1
- package/dist/modes/interactive/components/custom-editor.js +6 -6
- package/dist/modes/interactive/components/custom-editor.js.map +1 -1
- package/dist/modes/interactive/components/extension-editor.d.ts +5 -2
- package/dist/modes/interactive/components/extension-editor.d.ts.map +1 -1
- package/dist/modes/interactive/components/extension-editor.js +18 -9
- package/dist/modes/interactive/components/extension-editor.js.map +1 -1
- package/dist/modes/interactive/components/extension-input.d.ts.map +1 -1
- package/dist/modes/interactive/components/extension-input.js +5 -5
- package/dist/modes/interactive/components/extension-input.js.map +1 -1
- package/dist/modes/interactive/components/extension-selector.d.ts.map +1 -1
- package/dist/modes/interactive/components/extension-selector.js +8 -8
- package/dist/modes/interactive/components/extension-selector.js.map +1 -1
- package/dist/modes/interactive/components/footer.d.ts +1 -0
- package/dist/modes/interactive/components/footer.d.ts.map +1 -1
- package/dist/modes/interactive/components/footer.js +21 -40
- package/dist/modes/interactive/components/footer.js.map +1 -1
- package/dist/modes/interactive/components/index.d.ts +1 -1
- package/dist/modes/interactive/components/index.d.ts.map +1 -1
- package/dist/modes/interactive/components/index.js +1 -1
- package/dist/modes/interactive/components/index.js.map +1 -1
- package/dist/modes/interactive/components/keybinding-hints.d.ts +3 -36
- package/dist/modes/interactive/components/keybinding-hints.d.ts.map +1 -1
- package/dist/modes/interactive/components/keybinding-hints.js +5 -44
- package/dist/modes/interactive/components/keybinding-hints.js.map +1 -1
- package/dist/modes/interactive/components/login-dialog.d.ts.map +1 -1
- package/dist/modes/interactive/components/login-dialog.js +7 -7
- package/dist/modes/interactive/components/login-dialog.js.map +1 -1
- package/dist/modes/interactive/components/model-selector.d.ts +1 -1
- package/dist/modes/interactive/components/model-selector.d.ts.map +1 -1
- package/dist/modes/interactive/components/model-selector.js +13 -9
- package/dist/modes/interactive/components/model-selector.js.map +1 -1
- package/dist/modes/interactive/components/oauth-selector.d.ts.map +1 -1
- package/dist/modes/interactive/components/oauth-selector.js +7 -7
- package/dist/modes/interactive/components/oauth-selector.js.map +1 -1
- package/dist/modes/interactive/components/scoped-models-selector.d.ts.map +1 -1
- package/dist/modes/interactive/components/scoped-models-selector.js +4 -4
- package/dist/modes/interactive/components/scoped-models-selector.js.map +1 -1
- package/dist/modes/interactive/components/session-selector.d.ts.map +1 -1
- package/dist/modes/interactive/components/session-selector.js +33 -36
- package/dist/modes/interactive/components/session-selector.js.map +1 -1
- package/dist/modes/interactive/components/settings-selector.d.ts +5 -0
- package/dist/modes/interactive/components/settings-selector.d.ts.map +1 -1
- package/dist/modes/interactive/components/settings-selector.js +25 -1
- package/dist/modes/interactive/components/settings-selector.js.map +1 -1
- package/dist/modes/interactive/components/show-images-selector.d.ts.map +1 -1
- package/dist/modes/interactive/components/show-images-selector.js +5 -1
- package/dist/modes/interactive/components/show-images-selector.js.map +1 -1
- package/dist/modes/interactive/components/skill-invocation-message.d.ts.map +1 -1
- package/dist/modes/interactive/components/skill-invocation-message.js +2 -2
- package/dist/modes/interactive/components/skill-invocation-message.js.map +1 -1
- package/dist/modes/interactive/components/theme-selector.d.ts.map +1 -1
- package/dist/modes/interactive/components/theme-selector.js +5 -1
- package/dist/modes/interactive/components/theme-selector.js.map +1 -1
- package/dist/modes/interactive/components/thinking-selector.d.ts.map +1 -1
- package/dist/modes/interactive/components/thinking-selector.js +5 -1
- package/dist/modes/interactive/components/thinking-selector.js.map +1 -1
- package/dist/modes/interactive/components/tool-execution.d.ts +17 -29
- package/dist/modes/interactive/components/tool-execution.d.ts.map +1 -1
- package/dist/modes/interactive/components/tool-execution.js +139 -501
- package/dist/modes/interactive/components/tool-execution.js.map +1 -1
- package/dist/modes/interactive/components/tree-selector.d.ts +25 -4
- package/dist/modes/interactive/components/tree-selector.d.ts.map +1 -1
- package/dist/modes/interactive/components/tree-selector.js +184 -34
- package/dist/modes/interactive/components/tree-selector.js.map +1 -1
- package/dist/modes/interactive/components/user-message-selector.d.ts.map +1 -1
- package/dist/modes/interactive/components/user-message-selector.js +6 -6
- package/dist/modes/interactive/components/user-message-selector.js.map +1 -1
- package/dist/modes/interactive/components/user-message.d.ts +1 -0
- package/dist/modes/interactive/components/user-message.d.ts.map +1 -1
- package/dist/modes/interactive/components/user-message.js +12 -0
- package/dist/modes/interactive/components/user-message.js.map +1 -1
- package/dist/modes/interactive/interactive-mode.d.ts +25 -17
- package/dist/modes/interactive/interactive-mode.d.ts.map +1 -1
- package/dist/modes/interactive/interactive-mode.js +669 -385
- package/dist/modes/interactive/interactive-mode.js.map +1 -1
- package/dist/modes/interactive/theme/theme.d.ts +3 -0
- package/dist/modes/interactive/theme/theme.d.ts.map +1 -1
- package/dist/modes/interactive/theme/theme.js +83 -48
- package/dist/modes/interactive/theme/theme.js.map +1 -1
- package/dist/modes/print-mode.d.ts +2 -2
- package/dist/modes/print-mode.d.ts.map +1 -1
- package/dist/modes/print-mode.js +90 -79
- package/dist/modes/print-mode.js.map +1 -1
- 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 +1 -1
- package/dist/modes/rpc/rpc-client.d.ts.map +1 -1
- package/dist/modes/rpc/rpc-client.js +8 -11
- package/dist/modes/rpc/rpc-client.js.map +1 -1
- package/dist/modes/rpc/rpc-mode.d.ts +2 -2
- package/dist/modes/rpc/rpc-mode.d.ts.map +1 -1
- package/dist/modes/rpc/rpc-mode.js +130 -87
- package/dist/modes/rpc/rpc-mode.js.map +1 -1
- package/dist/modes/rpc/rpc-types.d.ts +3 -4
- package/dist/modes/rpc/rpc-types.d.ts.map +1 -1
- package/dist/modes/rpc/rpc-types.js.map +1 -1
- package/dist/package-manager-cli.d.ts +4 -0
- package/dist/package-manager-cli.d.ts.map +1 -0
- package/dist/package-manager-cli.js +234 -0
- package/dist/package-manager-cli.js.map +1 -0
- package/dist/utils/child-process.d.ts +11 -0
- package/dist/utils/child-process.d.ts.map +1 -0
- package/dist/utils/child-process.js +78 -0
- package/dist/utils/child-process.js.map +1 -0
- package/dist/utils/clipboard-image.d.ts.map +1 -1
- package/dist/utils/clipboard-image.js +94 -11
- package/dist/utils/clipboard-image.js.map +1 -1
- package/dist/utils/clipboard-native.d.ts +1 -0
- package/dist/utils/clipboard-native.d.ts.map +1 -1
- package/dist/utils/clipboard-native.js.map +1 -1
- package/dist/utils/clipboard.d.ts +1 -1
- package/dist/utils/clipboard.d.ts.map +1 -1
- package/dist/utils/clipboard.js +27 -16
- package/dist/utils/clipboard.js.map +1 -1
- 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/git.d.ts +5 -1
- package/dist/utils/git.d.ts.map +1 -1
- package/dist/utils/git.js +14 -3
- package/dist/utils/git.js.map +1 -1
- package/dist/utils/image-convert.d.ts.map +1 -1
- package/dist/utils/image-convert.js +5 -1
- package/dist/utils/image-convert.js.map +1 -1
- package/dist/utils/image-resize.d.ts +5 -5
- package/dist/utils/image-resize.d.ts.map +1 -1
- package/dist/utils/image-resize.js +51 -95
- package/dist/utils/image-resize.js.map +1 -1
- package/dist/utils/paths.d.ts +7 -0
- package/dist/utils/paths.d.ts.map +1 -0
- package/dist/utils/paths.js +19 -0
- package/dist/utils/paths.js.map +1 -0
- package/dist/utils/tools-manager.d.ts.map +1 -1
- package/dist/utils/tools-manager.js +67 -22
- package/dist/utils/tools-manager.js.map +1 -1
- package/docs/compaction.md +6 -2
- package/docs/custom-provider.md +57 -9
- package/docs/development.md +3 -1
- package/docs/extensions.md +437 -67
- package/docs/json.md +5 -2
- package/docs/keybindings.md +108 -107
- package/docs/models.md +50 -2
- package/docs/packages.md +17 -10
- package/docs/prompt-templates.md +6 -6
- package/docs/providers.md +10 -1
- package/docs/rpc.md +78 -18
- package/docs/sdk.md +261 -96
- package/docs/settings.md +28 -3
- package/docs/skills.md +9 -4
- package/docs/terminal-setup.md +39 -3
- package/docs/tmux.md +61 -0
- package/docs/tree.md +15 -3
- package/docs/tui.md +2 -2
- package/examples/extensions/README.md +3 -0
- package/examples/extensions/antigravity-image-gen.ts +12 -7
- package/examples/extensions/built-in-tool-renderer.ts +246 -0
- package/examples/extensions/commands.ts +3 -3
- package/examples/extensions/custom-compaction.ts +17 -4
- package/examples/extensions/custom-provider-anthropic/package-lock.json +2 -2
- package/examples/extensions/custom-provider-anthropic/package.json +1 -1
- package/examples/extensions/custom-provider-gitlab-duo/package.json +1 -1
- package/examples/extensions/custom-provider-gitlab-duo/test.ts +2 -2
- package/examples/extensions/custom-provider-qwen-cli/package.json +1 -1
- package/examples/extensions/doom-overlay/doom/build.sh +2 -2
- package/examples/extensions/dynamic-tools.ts +74 -0
- package/examples/extensions/handoff.ts +5 -2
- package/examples/extensions/hello.ts +18 -17
- package/examples/extensions/hidden-thinking-label.ts +53 -0
- package/examples/extensions/minimal-mode.ts +14 -14
- package/examples/extensions/overlay-qa-tests.ts +468 -1
- package/examples/extensions/preset.ts +2 -3
- package/examples/extensions/provider-payload.ts +14 -0
- package/examples/extensions/qna.ts +5 -2
- package/examples/extensions/question.ts +2 -2
- package/examples/extensions/questionnaire.ts +2 -2
- package/examples/extensions/rpc-demo.ts +3 -9
- package/examples/extensions/sandbox/index.ts +6 -3
- package/examples/extensions/status-line.ts +0 -8
- package/examples/extensions/subagent/README.md +4 -4
- package/examples/extensions/subagent/agents.ts +2 -3
- package/examples/extensions/subagent/index.ts +30 -8
- package/examples/extensions/summarize.ts +15 -4
- package/examples/extensions/todo.ts +2 -4
- package/examples/extensions/tool-override.ts +10 -9
- package/examples/extensions/tools.ts +0 -5
- package/examples/extensions/trigger-compact.ts +11 -1
- package/examples/extensions/truncated-tool.ts +8 -5
- package/examples/extensions/widget-placement.ts +4 -12
- package/examples/extensions/with-deps/index.ts +1 -5
- package/examples/extensions/with-deps/package-lock.json +2 -2
- package/examples/extensions/with-deps/package.json +1 -1
- package/examples/sdk/02-custom-model.ts +2 -2
- package/examples/sdk/04-skills.ts +8 -2
- package/examples/sdk/08-prompt-templates.ts +4 -3
- package/examples/sdk/09-api-keys-and-oauth.ts +5 -5
- package/examples/sdk/10-settings.ts +13 -0
- package/examples/sdk/12-full-control.ts +2 -3
- package/examples/sdk/13-session-runtime.ts +67 -0
- package/examples/sdk/README.md +10 -7
- package/package.json +98 -94
- /package/examples/extensions/subagent/{commands → prompts}/implement-and-review.md +0 -0
- /package/examples/extensions/subagent/{commands → prompts}/implement.md +0 -0
- /package/examples/extensions/subagent/{commands → prompts}/scout-and-plan.md +0 -0
package/dist/main.js
CHANGED
|
@@ -4,31 +4,35 @@
|
|
|
4
4
|
* This file handles CLI argument parsing and translates them into
|
|
5
5
|
* createAgentSession() options. The SDK does the heavy lifting.
|
|
6
6
|
*/
|
|
7
|
+
import { resolve } from "node:path";
|
|
7
8
|
import { modelsAreEqual, supportsXhigh } from "@mariozechner/pi-ai";
|
|
9
|
+
import { ProcessTerminal, setKeybindings, TUI } from "@mariozechner/pi-tui";
|
|
8
10
|
import chalk from "chalk";
|
|
9
11
|
import { createInterface } from "readline";
|
|
10
12
|
import { parseArgs, printHelp } from "./cli/args.js";
|
|
11
|
-
import { selectConfig } from "./cli/config-selector.js";
|
|
12
13
|
import { processFileArguments } from "./cli/file-processor.js";
|
|
14
|
+
import { buildInitialMessage } from "./cli/initial-message.js";
|
|
13
15
|
import { listModels } from "./cli/list-models.js";
|
|
14
16
|
import { selectSession } from "./cli/session-picker.js";
|
|
15
|
-
import {
|
|
17
|
+
import { getAgentDir, getModelsPath, VERSION } from "./config.js";
|
|
18
|
+
import { createAgentSessionRuntime } from "./core/agent-session-runtime.js";
|
|
19
|
+
import { createAgentSessionFromServices, createAgentSessionServices, } from "./core/agent-session-services.js";
|
|
16
20
|
import { AuthStorage } from "./core/auth-storage.js";
|
|
17
|
-
import { DEFAULT_THINKING_LEVEL } from "./core/defaults.js";
|
|
18
21
|
import { exportFromFile } from "./core/export-html/index.js";
|
|
19
22
|
import { KeybindingsManager } from "./core/keybindings.js";
|
|
20
|
-
import {
|
|
21
|
-
import {
|
|
22
|
-
import {
|
|
23
|
-
import { DefaultResourceLoader } from "./core/resource-loader.js";
|
|
24
|
-
import { createAgentSession } from "./core/sdk.js";
|
|
23
|
+
import { resolveCliModel, resolveModelScope } from "./core/model-resolver.js";
|
|
24
|
+
import { restoreStdout, takeOverStdout } from "./core/output-guard.js";
|
|
25
|
+
import { formatMissingSessionCwdPrompt, getMissingSessionCwdIssue, MissingSessionCwdError, } from "./core/session-cwd.js";
|
|
25
26
|
import { SessionManager } from "./core/session-manager.js";
|
|
26
27
|
import { SettingsManager } from "./core/settings-manager.js";
|
|
27
|
-
import { printTimings, time } from "./core/timings.js";
|
|
28
|
+
import { printTimings, resetTimings, time } from "./core/timings.js";
|
|
28
29
|
import { allTools } from "./core/tools/index.js";
|
|
29
30
|
import { runMigrations, showDeprecationWarnings } from "./migrations.js";
|
|
30
31
|
import { InteractiveMode, runPrintMode, runRpcMode } from "./modes/index.js";
|
|
32
|
+
import { ExtensionSelectorComponent } from "./modes/interactive/components/extension-selector.js";
|
|
31
33
|
import { initTheme, stopThemeWatcher } from "./modes/interactive/theme/theme.js";
|
|
34
|
+
import { handleConfigCommand, handlePackageCommand } from "./package-manager-cli.js";
|
|
35
|
+
import { isLocalPath } from "./utils/paths.js";
|
|
32
36
|
/**
|
|
33
37
|
* Read all content from piped stdin.
|
|
34
38
|
* Returns undefined if stdin is a TTY (interactive terminal).
|
|
@@ -50,219 +54,50 @@ async function readPipedStdin() {
|
|
|
50
54
|
process.stdin.resume();
|
|
51
55
|
});
|
|
52
56
|
}
|
|
53
|
-
function
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
return `${APP_NAME} remove <source> [-l]`;
|
|
59
|
-
case "update":
|
|
60
|
-
return `${APP_NAME} update [source]`;
|
|
61
|
-
case "list":
|
|
62
|
-
return `${APP_NAME} list`;
|
|
63
|
-
}
|
|
64
|
-
}
|
|
65
|
-
function printPackageCommandHelp(command) {
|
|
66
|
-
switch (command) {
|
|
67
|
-
case "install":
|
|
68
|
-
console.log(`${chalk.bold("Usage:")}
|
|
69
|
-
${getPackageCommandUsage("install")}
|
|
70
|
-
|
|
71
|
-
Install a package and add it to settings.
|
|
72
|
-
|
|
73
|
-
Options:
|
|
74
|
-
-l, --local Install project-locally (.pi/settings.json)
|
|
75
|
-
|
|
76
|
-
Examples:
|
|
77
|
-
${APP_NAME} install npm:@foo/bar
|
|
78
|
-
${APP_NAME} install git:github.com/user/repo
|
|
79
|
-
${APP_NAME} install https://github.com/user/repo
|
|
80
|
-
${APP_NAME} install git@github.com:user/repo
|
|
81
|
-
${APP_NAME} install ./local/path
|
|
82
|
-
`);
|
|
83
|
-
return;
|
|
84
|
-
case "remove":
|
|
85
|
-
console.log(`${chalk.bold("Usage:")}
|
|
86
|
-
${getPackageCommandUsage("remove")}
|
|
87
|
-
|
|
88
|
-
Remove a package and its source from settings.
|
|
89
|
-
|
|
90
|
-
Options:
|
|
91
|
-
-l, --local Remove from project settings (.pi/settings.json)
|
|
92
|
-
|
|
93
|
-
Example:
|
|
94
|
-
${APP_NAME} remove npm:@foo/bar
|
|
95
|
-
`);
|
|
96
|
-
return;
|
|
97
|
-
case "update":
|
|
98
|
-
console.log(`${chalk.bold("Usage:")}
|
|
99
|
-
${getPackageCommandUsage("update")}
|
|
100
|
-
|
|
101
|
-
Update installed packages.
|
|
102
|
-
If <source> is provided, only that package is updated.
|
|
103
|
-
`);
|
|
104
|
-
return;
|
|
105
|
-
case "list":
|
|
106
|
-
console.log(`${chalk.bold("Usage:")}
|
|
107
|
-
${getPackageCommandUsage("list")}
|
|
108
|
-
|
|
109
|
-
List installed packages from user and project settings.
|
|
110
|
-
`);
|
|
111
|
-
return;
|
|
112
|
-
}
|
|
57
|
+
function collectSettingsDiagnostics(settingsManager, context) {
|
|
58
|
+
return settingsManager.drainErrors().map(({ scope, error }) => ({
|
|
59
|
+
type: "warning",
|
|
60
|
+
message: `(${context}, ${scope} settings) ${error.message}`,
|
|
61
|
+
}));
|
|
113
62
|
}
|
|
114
|
-
function
|
|
115
|
-
const
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
let local = false;
|
|
120
|
-
let help = false;
|
|
121
|
-
let invalidOption;
|
|
122
|
-
let source;
|
|
123
|
-
for (const arg of rest) {
|
|
124
|
-
if (arg === "-h" || arg === "--help") {
|
|
125
|
-
help = true;
|
|
126
|
-
continue;
|
|
127
|
-
}
|
|
128
|
-
if (arg === "-l" || arg === "--local") {
|
|
129
|
-
if (command === "install" || command === "remove") {
|
|
130
|
-
local = true;
|
|
131
|
-
}
|
|
132
|
-
else {
|
|
133
|
-
invalidOption = invalidOption ?? arg;
|
|
134
|
-
}
|
|
135
|
-
continue;
|
|
136
|
-
}
|
|
137
|
-
if (arg.startsWith("-")) {
|
|
138
|
-
invalidOption = invalidOption ?? arg;
|
|
139
|
-
continue;
|
|
140
|
-
}
|
|
141
|
-
if (!source) {
|
|
142
|
-
source = arg;
|
|
143
|
-
}
|
|
63
|
+
function reportDiagnostics(diagnostics) {
|
|
64
|
+
for (const diagnostic of diagnostics) {
|
|
65
|
+
const color = diagnostic.type === "error" ? chalk.red : diagnostic.type === "warning" ? chalk.yellow : chalk.dim;
|
|
66
|
+
const prefix = diagnostic.type === "error" ? "Error: " : diagnostic.type === "warning" ? "Warning: " : "";
|
|
67
|
+
console.error(color(`${prefix}${diagnostic.message}`));
|
|
144
68
|
}
|
|
145
|
-
return { command, source, local, help, invalidOption };
|
|
146
69
|
}
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
if (!options) {
|
|
70
|
+
function isTruthyEnvFlag(value) {
|
|
71
|
+
if (!value)
|
|
150
72
|
return false;
|
|
73
|
+
return value === "1" || value.toLowerCase() === "true" || value.toLowerCase() === "yes";
|
|
74
|
+
}
|
|
75
|
+
function resolveAppMode(parsed, stdinIsTTY) {
|
|
76
|
+
if (parsed.mode === "rpc") {
|
|
77
|
+
return "rpc";
|
|
151
78
|
}
|
|
152
|
-
if (
|
|
153
|
-
|
|
154
|
-
return true;
|
|
155
|
-
}
|
|
156
|
-
if (options.invalidOption) {
|
|
157
|
-
console.error(chalk.red(`Unknown option ${options.invalidOption} for "${options.command}".`));
|
|
158
|
-
console.error(chalk.dim(`Use "${APP_NAME} --help" or "${getPackageCommandUsage(options.command)}".`));
|
|
159
|
-
process.exitCode = 1;
|
|
160
|
-
return true;
|
|
161
|
-
}
|
|
162
|
-
const source = options.source;
|
|
163
|
-
if ((options.command === "install" || options.command === "remove") && !source) {
|
|
164
|
-
console.error(chalk.red(`Missing ${options.command} source.`));
|
|
165
|
-
console.error(chalk.dim(`Usage: ${getPackageCommandUsage(options.command)}`));
|
|
166
|
-
process.exitCode = 1;
|
|
167
|
-
return true;
|
|
168
|
-
}
|
|
169
|
-
const cwd = process.cwd();
|
|
170
|
-
const agentDir = getAgentDir();
|
|
171
|
-
const settingsManager = SettingsManager.create(cwd, agentDir);
|
|
172
|
-
const packageManager = new DefaultPackageManager({ cwd, agentDir, settingsManager });
|
|
173
|
-
packageManager.setProgressCallback((event) => {
|
|
174
|
-
if (event.type === "start") {
|
|
175
|
-
process.stdout.write(chalk.dim(`${event.message}\n`));
|
|
176
|
-
}
|
|
177
|
-
});
|
|
178
|
-
try {
|
|
179
|
-
switch (options.command) {
|
|
180
|
-
case "install":
|
|
181
|
-
await packageManager.install(source, { local: options.local });
|
|
182
|
-
packageManager.addSourceToSettings(source, { local: options.local });
|
|
183
|
-
console.log(chalk.green(`Installed ${source}`));
|
|
184
|
-
return true;
|
|
185
|
-
case "remove": {
|
|
186
|
-
await packageManager.remove(source, { local: options.local });
|
|
187
|
-
const removed = packageManager.removeSourceFromSettings(source, { local: options.local });
|
|
188
|
-
if (!removed) {
|
|
189
|
-
console.error(chalk.red(`No matching package found for ${source}`));
|
|
190
|
-
process.exitCode = 1;
|
|
191
|
-
return true;
|
|
192
|
-
}
|
|
193
|
-
console.log(chalk.green(`Removed ${source}`));
|
|
194
|
-
return true;
|
|
195
|
-
}
|
|
196
|
-
case "list": {
|
|
197
|
-
const globalSettings = settingsManager.getGlobalSettings();
|
|
198
|
-
const projectSettings = settingsManager.getProjectSettings();
|
|
199
|
-
const globalPackages = globalSettings.packages ?? [];
|
|
200
|
-
const projectPackages = projectSettings.packages ?? [];
|
|
201
|
-
if (globalPackages.length === 0 && projectPackages.length === 0) {
|
|
202
|
-
console.log(chalk.dim("No packages installed."));
|
|
203
|
-
return true;
|
|
204
|
-
}
|
|
205
|
-
const formatPackage = (pkg, scope) => {
|
|
206
|
-
const source = typeof pkg === "string" ? pkg : pkg.source;
|
|
207
|
-
const filtered = typeof pkg === "object";
|
|
208
|
-
const display = filtered ? `${source} (filtered)` : source;
|
|
209
|
-
console.log(` ${display}`);
|
|
210
|
-
const path = packageManager.getInstalledPath(source, scope);
|
|
211
|
-
if (path) {
|
|
212
|
-
console.log(chalk.dim(` ${path}`));
|
|
213
|
-
}
|
|
214
|
-
};
|
|
215
|
-
if (globalPackages.length > 0) {
|
|
216
|
-
console.log(chalk.bold("User packages:"));
|
|
217
|
-
for (const pkg of globalPackages) {
|
|
218
|
-
formatPackage(pkg, "user");
|
|
219
|
-
}
|
|
220
|
-
}
|
|
221
|
-
if (projectPackages.length > 0) {
|
|
222
|
-
if (globalPackages.length > 0)
|
|
223
|
-
console.log();
|
|
224
|
-
console.log(chalk.bold("Project packages:"));
|
|
225
|
-
for (const pkg of projectPackages) {
|
|
226
|
-
formatPackage(pkg, "project");
|
|
227
|
-
}
|
|
228
|
-
}
|
|
229
|
-
return true;
|
|
230
|
-
}
|
|
231
|
-
case "update":
|
|
232
|
-
await packageManager.update(source);
|
|
233
|
-
if (source) {
|
|
234
|
-
console.log(chalk.green(`Updated ${source}`));
|
|
235
|
-
}
|
|
236
|
-
else {
|
|
237
|
-
console.log(chalk.green("Updated packages"));
|
|
238
|
-
}
|
|
239
|
-
return true;
|
|
240
|
-
}
|
|
79
|
+
if (parsed.mode === "json") {
|
|
80
|
+
return "json";
|
|
241
81
|
}
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
console.error(chalk.red(`Error: ${message}`));
|
|
245
|
-
process.exitCode = 1;
|
|
246
|
-
return true;
|
|
82
|
+
if (parsed.print || !stdinIsTTY) {
|
|
83
|
+
return "print";
|
|
247
84
|
}
|
|
85
|
+
return "interactive";
|
|
86
|
+
}
|
|
87
|
+
function toPrintOutputMode(appMode) {
|
|
88
|
+
return appMode === "json" ? "json" : "text";
|
|
248
89
|
}
|
|
249
|
-
async function prepareInitialMessage(parsed, autoResizeImages) {
|
|
90
|
+
async function prepareInitialMessage(parsed, autoResizeImages, stdinContent) {
|
|
250
91
|
if (parsed.fileArgs.length === 0) {
|
|
251
|
-
return {};
|
|
92
|
+
return buildInitialMessage({ parsed, stdinContent });
|
|
252
93
|
}
|
|
253
94
|
const { text, images } = await processFileArguments(parsed.fileArgs, { autoResizeImages });
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
initialMessage = text;
|
|
261
|
-
}
|
|
262
|
-
return {
|
|
263
|
-
initialMessage,
|
|
264
|
-
initialImages: images.length > 0 ? images : undefined,
|
|
265
|
-
};
|
|
95
|
+
return buildInitialMessage({
|
|
96
|
+
parsed,
|
|
97
|
+
fileText: text,
|
|
98
|
+
fileImages: images,
|
|
99
|
+
stdinContent,
|
|
100
|
+
});
|
|
266
101
|
}
|
|
267
102
|
/**
|
|
268
103
|
* Resolve a session argument to a file path.
|
|
@@ -302,57 +137,115 @@ async function promptConfirm(message) {
|
|
|
302
137
|
});
|
|
303
138
|
});
|
|
304
139
|
}
|
|
305
|
-
|
|
140
|
+
function validateForkFlags(parsed) {
|
|
141
|
+
if (!parsed.fork)
|
|
142
|
+
return;
|
|
143
|
+
const conflictingFlags = [
|
|
144
|
+
parsed.session ? "--session" : undefined,
|
|
145
|
+
parsed.continue ? "--continue" : undefined,
|
|
146
|
+
parsed.resume ? "--resume" : undefined,
|
|
147
|
+
parsed.noSession ? "--no-session" : undefined,
|
|
148
|
+
].filter((flag) => flag !== undefined);
|
|
149
|
+
if (conflictingFlags.length > 0) {
|
|
150
|
+
console.error(chalk.red(`Error: --fork cannot be combined with ${conflictingFlags.join(", ")}`));
|
|
151
|
+
process.exit(1);
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
function forkSessionOrExit(sourcePath, cwd, sessionDir) {
|
|
155
|
+
try {
|
|
156
|
+
return SessionManager.forkFrom(sourcePath, cwd, sessionDir);
|
|
157
|
+
}
|
|
158
|
+
catch (error) {
|
|
159
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
160
|
+
console.error(chalk.red(`Error: ${message}`));
|
|
161
|
+
process.exit(1);
|
|
162
|
+
}
|
|
163
|
+
}
|
|
164
|
+
async function createSessionManager(parsed, cwd, sessionDir, settingsManager) {
|
|
306
165
|
if (parsed.noSession) {
|
|
307
166
|
return SessionManager.inMemory();
|
|
308
167
|
}
|
|
168
|
+
if (parsed.fork) {
|
|
169
|
+
const resolved = await resolveSessionPath(parsed.fork, cwd, sessionDir);
|
|
170
|
+
switch (resolved.type) {
|
|
171
|
+
case "path":
|
|
172
|
+
case "local":
|
|
173
|
+
case "global":
|
|
174
|
+
return forkSessionOrExit(resolved.path, cwd, sessionDir);
|
|
175
|
+
case "not_found":
|
|
176
|
+
console.error(chalk.red(`No session found matching '${resolved.arg}'`));
|
|
177
|
+
process.exit(1);
|
|
178
|
+
}
|
|
179
|
+
}
|
|
309
180
|
if (parsed.session) {
|
|
310
|
-
const resolved = await resolveSessionPath(parsed.session, cwd,
|
|
181
|
+
const resolved = await resolveSessionPath(parsed.session, cwd, sessionDir);
|
|
311
182
|
switch (resolved.type) {
|
|
312
183
|
case "path":
|
|
313
184
|
case "local":
|
|
314
|
-
return SessionManager.open(resolved.path,
|
|
185
|
+
return SessionManager.open(resolved.path, sessionDir);
|
|
315
186
|
case "global": {
|
|
316
|
-
// Session found in different project - ask user if they want to fork
|
|
317
187
|
console.log(chalk.yellow(`Session found in different project: ${resolved.cwd}`));
|
|
318
188
|
const shouldFork = await promptConfirm("Fork this session into current directory?");
|
|
319
189
|
if (!shouldFork) {
|
|
320
190
|
console.log(chalk.dim("Aborted."));
|
|
321
191
|
process.exit(0);
|
|
322
192
|
}
|
|
323
|
-
return
|
|
193
|
+
return forkSessionOrExit(resolved.path, cwd, sessionDir);
|
|
324
194
|
}
|
|
325
195
|
case "not_found":
|
|
326
196
|
console.error(chalk.red(`No session found matching '${resolved.arg}'`));
|
|
327
197
|
process.exit(1);
|
|
328
198
|
}
|
|
329
199
|
}
|
|
330
|
-
if (parsed.
|
|
331
|
-
|
|
200
|
+
if (parsed.resume) {
|
|
201
|
+
initTheme(settingsManager.getTheme(), true);
|
|
202
|
+
try {
|
|
203
|
+
const selectedPath = await selectSession((onProgress) => SessionManager.list(cwd, sessionDir, onProgress), SessionManager.listAll);
|
|
204
|
+
if (!selectedPath) {
|
|
205
|
+
console.log(chalk.dim("No session selected"));
|
|
206
|
+
process.exit(0);
|
|
207
|
+
}
|
|
208
|
+
return SessionManager.open(selectedPath, sessionDir);
|
|
209
|
+
}
|
|
210
|
+
finally {
|
|
211
|
+
stopThemeWatcher();
|
|
212
|
+
}
|
|
332
213
|
}
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
if (parsed.sessionDir) {
|
|
336
|
-
return SessionManager.create(cwd, parsed.sessionDir);
|
|
214
|
+
if (parsed.continue) {
|
|
215
|
+
return SessionManager.continueRecent(cwd, sessionDir);
|
|
337
216
|
}
|
|
338
|
-
|
|
339
|
-
return undefined;
|
|
217
|
+
return SessionManager.create(cwd, sessionDir);
|
|
340
218
|
}
|
|
341
|
-
function buildSessionOptions(parsed, scopedModels,
|
|
219
|
+
function buildSessionOptions(parsed, scopedModels, hasExistingSession, modelRegistry, settingsManager) {
|
|
342
220
|
const options = {};
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
}
|
|
221
|
+
const diagnostics = [];
|
|
222
|
+
let cliThinkingFromModel = false;
|
|
346
223
|
// Model from CLI
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
224
|
+
// - supports --provider <name> --model <pattern>
|
|
225
|
+
// - supports --model <provider>/<pattern>
|
|
226
|
+
if (parsed.model) {
|
|
227
|
+
const resolved = resolveCliModel({
|
|
228
|
+
cliProvider: parsed.provider,
|
|
229
|
+
cliModel: parsed.model,
|
|
230
|
+
modelRegistry,
|
|
231
|
+
});
|
|
232
|
+
if (resolved.warning) {
|
|
233
|
+
diagnostics.push({ type: "warning", message: resolved.warning });
|
|
234
|
+
}
|
|
235
|
+
if (resolved.error) {
|
|
236
|
+
diagnostics.push({ type: "error", message: resolved.error });
|
|
237
|
+
}
|
|
238
|
+
if (resolved.model) {
|
|
239
|
+
options.model = resolved.model;
|
|
240
|
+
// Allow "--model <pattern>:<thinking>" as a shorthand.
|
|
241
|
+
// Explicit --thinking still takes precedence (applied later).
|
|
242
|
+
if (!parsed.thinking && resolved.thinkingLevel) {
|
|
243
|
+
options.thinkingLevel = resolved.thinkingLevel;
|
|
244
|
+
cliThinkingFromModel = true;
|
|
245
|
+
}
|
|
352
246
|
}
|
|
353
|
-
options.model = model;
|
|
354
247
|
}
|
|
355
|
-
|
|
248
|
+
if (!options.model && scopedModels.length > 0 && !hasExistingSession) {
|
|
356
249
|
// Check if saved default is in scoped models - use it if so, otherwise first scoped model
|
|
357
250
|
const savedProvider = settingsManager.getDefaultProvider();
|
|
358
251
|
const savedModelId = settingsManager.getDefaultModel();
|
|
@@ -377,12 +270,13 @@ function buildSessionOptions(parsed, scopedModels, sessionManager, modelRegistry
|
|
|
377
270
|
if (parsed.thinking) {
|
|
378
271
|
options.thinkingLevel = parsed.thinking;
|
|
379
272
|
}
|
|
380
|
-
// Scoped models for Ctrl+P cycling
|
|
273
|
+
// Scoped models for Ctrl+P cycling
|
|
274
|
+
// Keep thinking level undefined when not explicitly set in the model pattern.
|
|
275
|
+
// Undefined means "inherit current session thinking level" during cycling.
|
|
381
276
|
if (scopedModels.length > 0) {
|
|
382
|
-
const defaultThinkingLevel = settingsManager.getDefaultThinkingLevel() ?? DEFAULT_THINKING_LEVEL;
|
|
383
277
|
options.scopedModels = scopedModels.map((sm) => ({
|
|
384
278
|
model: sm.model,
|
|
385
|
-
thinkingLevel: sm.thinkingLevel
|
|
279
|
+
thinkingLevel: sm.thinkingLevel,
|
|
386
280
|
}));
|
|
387
281
|
}
|
|
388
282
|
// API key from CLI - set in authStorage
|
|
@@ -401,104 +295,65 @@ function buildSessionOptions(parsed, scopedModels, sessionManager, modelRegistry
|
|
|
401
295
|
else if (parsed.tools) {
|
|
402
296
|
options.tools = parsed.tools.map((name) => allTools[name]);
|
|
403
297
|
}
|
|
404
|
-
return options;
|
|
298
|
+
return { options, cliThinkingFromModel, diagnostics };
|
|
405
299
|
}
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
300
|
+
function resolveCliPaths(cwd, paths) {
|
|
301
|
+
return paths?.map((value) => (isLocalPath(value) ? resolve(cwd, value) : value));
|
|
302
|
+
}
|
|
303
|
+
async function promptForMissingSessionCwd(issue, settingsManager) {
|
|
304
|
+
initTheme(settingsManager.getTheme());
|
|
305
|
+
setKeybindings(KeybindingsManager.create());
|
|
306
|
+
return new Promise((resolve) => {
|
|
307
|
+
const ui = new TUI(new ProcessTerminal(), settingsManager.getShowHardwareCursor());
|
|
308
|
+
ui.setClearOnShrink(settingsManager.getClearOnShrink());
|
|
309
|
+
let settled = false;
|
|
310
|
+
const finish = (result) => {
|
|
311
|
+
if (settled) {
|
|
312
|
+
return;
|
|
313
|
+
}
|
|
314
|
+
settled = true;
|
|
315
|
+
ui.stop();
|
|
316
|
+
resolve(result);
|
|
317
|
+
};
|
|
318
|
+
const selector = new ExtensionSelectorComponent(formatMissingSessionCwdPrompt(issue), ["Continue", "Cancel"], (option) => finish(option === "Continue" ? issue.fallbackCwd : undefined), () => finish(undefined), { tui: ui });
|
|
319
|
+
ui.addChild(selector);
|
|
320
|
+
ui.setFocus(selector);
|
|
321
|
+
ui.start();
|
|
420
322
|
});
|
|
421
|
-
process.exit(0);
|
|
422
323
|
}
|
|
423
324
|
export async function main(args) {
|
|
325
|
+
resetTimings();
|
|
326
|
+
const offlineMode = args.includes("--offline") || isTruthyEnvFlag(process.env.PI_OFFLINE);
|
|
327
|
+
if (offlineMode) {
|
|
328
|
+
process.env.PI_OFFLINE = "1";
|
|
329
|
+
process.env.PI_SKIP_VERSION_CHECK = "1";
|
|
330
|
+
}
|
|
424
331
|
if (await handlePackageCommand(args)) {
|
|
425
332
|
return;
|
|
426
333
|
}
|
|
427
334
|
if (await handleConfigCommand(args)) {
|
|
428
335
|
return;
|
|
429
336
|
}
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
const authStorage = new AuthStorage();
|
|
439
|
-
const modelRegistry = new ModelRegistry(authStorage, getModelsPath());
|
|
440
|
-
const resourceLoader = new DefaultResourceLoader({
|
|
441
|
-
cwd,
|
|
442
|
-
agentDir,
|
|
443
|
-
settingsManager,
|
|
444
|
-
additionalExtensionPaths: firstPass.extensions,
|
|
445
|
-
additionalSkillPaths: firstPass.skills,
|
|
446
|
-
additionalPromptTemplatePaths: firstPass.promptTemplates,
|
|
447
|
-
additionalThemePaths: firstPass.themes,
|
|
448
|
-
noExtensions: firstPass.noExtensions,
|
|
449
|
-
noSkills: firstPass.noSkills,
|
|
450
|
-
noPromptTemplates: firstPass.noPromptTemplates,
|
|
451
|
-
noThemes: firstPass.noThemes,
|
|
452
|
-
systemPrompt: firstPass.systemPrompt,
|
|
453
|
-
appendSystemPrompt: firstPass.appendSystemPrompt,
|
|
454
|
-
});
|
|
455
|
-
await resourceLoader.reload();
|
|
456
|
-
time("resourceLoader.reload");
|
|
457
|
-
const extensionsResult = resourceLoader.getExtensions();
|
|
458
|
-
for (const { path, error } of extensionsResult.errors) {
|
|
459
|
-
console.error(chalk.red(`Failed to load extension "${path}": ${error}`));
|
|
460
|
-
}
|
|
461
|
-
// Apply pending provider registrations from extensions immediately
|
|
462
|
-
// so they're available for model resolution before AgentSession is created
|
|
463
|
-
for (const { name, config } of extensionsResult.runtime.pendingProviderRegistrations) {
|
|
464
|
-
modelRegistry.registerProvider(name, config);
|
|
465
|
-
}
|
|
466
|
-
extensionsResult.runtime.pendingProviderRegistrations = [];
|
|
467
|
-
const extensionFlags = new Map();
|
|
468
|
-
for (const ext of extensionsResult.extensions) {
|
|
469
|
-
for (const [name, flag] of ext.flags) {
|
|
470
|
-
extensionFlags.set(name, { type: flag.type });
|
|
337
|
+
const parsed = parseArgs(args);
|
|
338
|
+
if (parsed.diagnostics.length > 0) {
|
|
339
|
+
for (const d of parsed.diagnostics) {
|
|
340
|
+
const color = d.type === "error" ? chalk.red : chalk.yellow;
|
|
341
|
+
console.error(color(`${d.type === "error" ? "Error" : "Warning"}: ${d.message}`));
|
|
342
|
+
}
|
|
343
|
+
if (parsed.diagnostics.some((d) => d.type === "error")) {
|
|
344
|
+
process.exit(1);
|
|
471
345
|
}
|
|
472
346
|
}
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
347
|
+
time("parseArgs");
|
|
348
|
+
let appMode = resolveAppMode(parsed, process.stdin.isTTY);
|
|
349
|
+
const shouldTakeOverStdout = appMode !== "interactive";
|
|
350
|
+
if (shouldTakeOverStdout) {
|
|
351
|
+
takeOverStdout();
|
|
478
352
|
}
|
|
479
353
|
if (parsed.version) {
|
|
480
354
|
console.log(VERSION);
|
|
481
355
|
process.exit(0);
|
|
482
356
|
}
|
|
483
|
-
if (parsed.help) {
|
|
484
|
-
printHelp();
|
|
485
|
-
process.exit(0);
|
|
486
|
-
}
|
|
487
|
-
if (parsed.listModels !== undefined) {
|
|
488
|
-
const searchPattern = typeof parsed.listModels === "string" ? parsed.listModels : undefined;
|
|
489
|
-
await listModels(modelRegistry, searchPattern);
|
|
490
|
-
process.exit(0);
|
|
491
|
-
}
|
|
492
|
-
// Read piped stdin content (if any) - skip for RPC mode which uses stdin for JSON-RPC
|
|
493
|
-
if (parsed.mode !== "rpc") {
|
|
494
|
-
const stdinContent = await readPipedStdin();
|
|
495
|
-
if (stdinContent !== undefined) {
|
|
496
|
-
// Force print mode since interactive mode requires a TTY for keyboard input
|
|
497
|
-
parsed.print = true;
|
|
498
|
-
// Prepend stdin content to messages
|
|
499
|
-
parsed.messages.unshift(stdinContent);
|
|
500
|
-
}
|
|
501
|
-
}
|
|
502
357
|
if (parsed.export) {
|
|
503
358
|
let result;
|
|
504
359
|
try {
|
|
@@ -517,70 +372,174 @@ export async function main(args) {
|
|
|
517
372
|
console.error(chalk.red("Error: @file arguments are not supported in RPC mode"));
|
|
518
373
|
process.exit(1);
|
|
519
374
|
}
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
const
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
let sessionManager = await createSessionManager(parsed, cwd);
|
|
535
|
-
|
|
536
|
-
if (
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
process.exit(0);
|
|
375
|
+
validateForkFlags(parsed);
|
|
376
|
+
// Run migrations (pass cwd for project-local migrations)
|
|
377
|
+
const { migratedAuthProviders: migratedProviders, deprecationWarnings } = runMigrations(process.cwd());
|
|
378
|
+
time("runMigrations");
|
|
379
|
+
const cwd = process.cwd();
|
|
380
|
+
const agentDir = getAgentDir();
|
|
381
|
+
const startupSettingsManager = SettingsManager.create(cwd, agentDir);
|
|
382
|
+
reportDiagnostics(collectSettingsDiagnostics(startupSettingsManager, "startup session lookup"));
|
|
383
|
+
// Decide the final runtime cwd before creating cwd-bound runtime services.
|
|
384
|
+
// --session and --resume may select a session from another project, so project-local
|
|
385
|
+
// settings, resources, provider registrations, and models must be resolved only after
|
|
386
|
+
// the target session cwd is known. The startup-cwd settings manager is used only for
|
|
387
|
+
// sessionDir lookup during session selection.
|
|
388
|
+
const sessionDir = parsed.sessionDir ?? startupSettingsManager.getSessionDir();
|
|
389
|
+
let sessionManager = await createSessionManager(parsed, cwd, sessionDir, startupSettingsManager);
|
|
390
|
+
const missingSessionCwdIssue = getMissingSessionCwdIssue(sessionManager, cwd);
|
|
391
|
+
if (missingSessionCwdIssue) {
|
|
392
|
+
if (appMode === "interactive") {
|
|
393
|
+
const selectedCwd = await promptForMissingSessionCwd(missingSessionCwdIssue, startupSettingsManager);
|
|
394
|
+
if (!selectedCwd) {
|
|
395
|
+
process.exit(0);
|
|
396
|
+
}
|
|
397
|
+
sessionManager = SessionManager.open(missingSessionCwdIssue.sessionFile, sessionDir, selectedCwd);
|
|
544
398
|
}
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
const sessionOptions = buildSessionOptions(parsed, scopedModels, sessionManager, modelRegistry, settingsManager);
|
|
548
|
-
sessionOptions.authStorage = authStorage;
|
|
549
|
-
sessionOptions.modelRegistry = modelRegistry;
|
|
550
|
-
sessionOptions.resourceLoader = resourceLoader;
|
|
551
|
-
// Handle CLI --api-key as runtime override (not persisted)
|
|
552
|
-
if (parsed.apiKey) {
|
|
553
|
-
if (!sessionOptions.model) {
|
|
554
|
-
console.error(chalk.red("--api-key requires a model to be specified via --provider/--model or -m/--models"));
|
|
399
|
+
else {
|
|
400
|
+
console.error(chalk.red(new MissingSessionCwdError(missingSessionCwdIssue).message));
|
|
555
401
|
process.exit(1);
|
|
556
402
|
}
|
|
557
|
-
authStorage.setRuntimeApiKey(sessionOptions.model.provider, parsed.apiKey);
|
|
558
403
|
}
|
|
559
|
-
|
|
560
|
-
|
|
404
|
+
time("createSessionManager");
|
|
405
|
+
const resolvedExtensionPaths = resolveCliPaths(cwd, parsed.extensions);
|
|
406
|
+
const resolvedSkillPaths = resolveCliPaths(cwd, parsed.skills);
|
|
407
|
+
const resolvedPromptTemplatePaths = resolveCliPaths(cwd, parsed.promptTemplates);
|
|
408
|
+
const resolvedThemePaths = resolveCliPaths(cwd, parsed.themes);
|
|
409
|
+
const authStorage = AuthStorage.create();
|
|
410
|
+
const createRuntime = async ({ cwd, agentDir, sessionManager, sessionStartEvent, }) => {
|
|
411
|
+
const services = await createAgentSessionServices({
|
|
412
|
+
cwd,
|
|
413
|
+
agentDir,
|
|
414
|
+
authStorage,
|
|
415
|
+
extensionFlagValues: parsed.unknownFlags,
|
|
416
|
+
resourceLoaderOptions: {
|
|
417
|
+
additionalExtensionPaths: resolvedExtensionPaths,
|
|
418
|
+
additionalSkillPaths: resolvedSkillPaths,
|
|
419
|
+
additionalPromptTemplatePaths: resolvedPromptTemplatePaths,
|
|
420
|
+
additionalThemePaths: resolvedThemePaths,
|
|
421
|
+
noExtensions: parsed.noExtensions,
|
|
422
|
+
noSkills: parsed.noSkills,
|
|
423
|
+
noPromptTemplates: parsed.noPromptTemplates,
|
|
424
|
+
noThemes: parsed.noThemes,
|
|
425
|
+
systemPrompt: parsed.systemPrompt,
|
|
426
|
+
appendSystemPrompt: parsed.appendSystemPrompt,
|
|
427
|
+
},
|
|
428
|
+
});
|
|
429
|
+
const { settingsManager, modelRegistry, resourceLoader } = services;
|
|
430
|
+
const diagnostics = [
|
|
431
|
+
...services.diagnostics,
|
|
432
|
+
...collectSettingsDiagnostics(settingsManager, "runtime creation"),
|
|
433
|
+
...resourceLoader.getExtensions().errors.map(({ path, error }) => ({
|
|
434
|
+
type: "error",
|
|
435
|
+
message: `Failed to load extension "${path}": ${error}`,
|
|
436
|
+
})),
|
|
437
|
+
];
|
|
438
|
+
const modelPatterns = parsed.models ?? settingsManager.getEnabledModels();
|
|
439
|
+
const scopedModels = modelPatterns && modelPatterns.length > 0 ? await resolveModelScope(modelPatterns, modelRegistry) : [];
|
|
440
|
+
const { options: sessionOptions, cliThinkingFromModel, diagnostics: sessionOptionDiagnostics, } = buildSessionOptions(parsed, scopedModels, sessionManager.buildSessionContext().messages.length > 0, modelRegistry, settingsManager);
|
|
441
|
+
diagnostics.push(...sessionOptionDiagnostics);
|
|
442
|
+
if (parsed.apiKey) {
|
|
443
|
+
if (!sessionOptions.model) {
|
|
444
|
+
diagnostics.push({
|
|
445
|
+
type: "error",
|
|
446
|
+
message: "--api-key requires a model to be specified via --model, --provider/--model, or --models",
|
|
447
|
+
});
|
|
448
|
+
}
|
|
449
|
+
else {
|
|
450
|
+
authStorage.setRuntimeApiKey(sessionOptions.model.provider, parsed.apiKey);
|
|
451
|
+
}
|
|
452
|
+
}
|
|
453
|
+
const created = await createAgentSessionFromServices({
|
|
454
|
+
services,
|
|
455
|
+
sessionManager,
|
|
456
|
+
sessionStartEvent,
|
|
457
|
+
model: sessionOptions.model,
|
|
458
|
+
thinkingLevel: sessionOptions.thinkingLevel,
|
|
459
|
+
scopedModels: sessionOptions.scopedModels,
|
|
460
|
+
tools: sessionOptions.tools,
|
|
461
|
+
customTools: sessionOptions.customTools,
|
|
462
|
+
});
|
|
463
|
+
const cliThinkingOverride = parsed.thinking !== undefined || cliThinkingFromModel;
|
|
464
|
+
if (created.session.model && cliThinkingOverride) {
|
|
465
|
+
let effectiveThinking = created.session.thinkingLevel;
|
|
466
|
+
if (!created.session.model.reasoning) {
|
|
467
|
+
effectiveThinking = "off";
|
|
468
|
+
}
|
|
469
|
+
else if (effectiveThinking === "xhigh" && !supportsXhigh(created.session.model)) {
|
|
470
|
+
effectiveThinking = "high";
|
|
471
|
+
}
|
|
472
|
+
if (effectiveThinking !== created.session.thinkingLevel) {
|
|
473
|
+
created.session.setThinkingLevel(effectiveThinking);
|
|
474
|
+
}
|
|
475
|
+
}
|
|
476
|
+
return {
|
|
477
|
+
...created,
|
|
478
|
+
services,
|
|
479
|
+
diagnostics,
|
|
480
|
+
};
|
|
481
|
+
};
|
|
482
|
+
time("createRuntime");
|
|
483
|
+
const runtime = await createAgentSessionRuntime(createRuntime, {
|
|
484
|
+
cwd: sessionManager.getCwd(),
|
|
485
|
+
agentDir,
|
|
486
|
+
sessionManager,
|
|
487
|
+
});
|
|
488
|
+
const { services, session, modelFallbackMessage } = runtime;
|
|
489
|
+
const { settingsManager, modelRegistry, resourceLoader } = services;
|
|
490
|
+
if (parsed.help) {
|
|
491
|
+
const extensionFlags = resourceLoader
|
|
492
|
+
.getExtensions()
|
|
493
|
+
.extensions.flatMap((extension) => Array.from(extension.flags.values()));
|
|
494
|
+
printHelp(extensionFlags);
|
|
495
|
+
process.exit(0);
|
|
496
|
+
}
|
|
497
|
+
if (parsed.listModels !== undefined) {
|
|
498
|
+
const searchPattern = typeof parsed.listModels === "string" ? parsed.listModels : undefined;
|
|
499
|
+
await listModels(modelRegistry, searchPattern);
|
|
500
|
+
process.exit(0);
|
|
501
|
+
}
|
|
502
|
+
// Read piped stdin content (if any) - skip for RPC mode which uses stdin for JSON-RPC
|
|
503
|
+
let stdinContent;
|
|
504
|
+
if (appMode !== "rpc") {
|
|
505
|
+
stdinContent = await readPipedStdin();
|
|
506
|
+
if (stdinContent !== undefined && appMode === "interactive") {
|
|
507
|
+
appMode = "print";
|
|
508
|
+
}
|
|
509
|
+
}
|
|
510
|
+
time("readPipedStdin");
|
|
511
|
+
const { initialMessage, initialImages } = await prepareInitialMessage(parsed, settingsManager.getImageAutoResize(), stdinContent);
|
|
512
|
+
time("prepareInitialMessage");
|
|
513
|
+
initTheme(settingsManager.getTheme(), appMode === "interactive");
|
|
514
|
+
time("initTheme");
|
|
515
|
+
// Show deprecation warnings in interactive mode
|
|
516
|
+
if (appMode === "interactive" && deprecationWarnings.length > 0) {
|
|
517
|
+
await showDeprecationWarnings(deprecationWarnings);
|
|
518
|
+
}
|
|
519
|
+
const scopedModels = [...session.scopedModels];
|
|
520
|
+
time("resolveModelScope");
|
|
521
|
+
reportDiagnostics(runtime.diagnostics);
|
|
522
|
+
if (runtime.diagnostics.some((diagnostic) => diagnostic.type === "error")) {
|
|
523
|
+
process.exit(1);
|
|
524
|
+
}
|
|
525
|
+
time("createAgentSession");
|
|
526
|
+
if (appMode !== "interactive" && !session.model) {
|
|
561
527
|
console.error(chalk.red("No models available."));
|
|
562
528
|
console.error(chalk.yellow("\nSet an API key environment variable:"));
|
|
563
529
|
console.error(" ANTHROPIC_API_KEY, OPENAI_API_KEY, GEMINI_API_KEY, etc.");
|
|
564
530
|
console.error(chalk.yellow(`\nOr create ${getModelsPath()}`));
|
|
565
531
|
process.exit(1);
|
|
566
532
|
}
|
|
567
|
-
|
|
568
|
-
if (
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
effectiveThinking = "off";
|
|
572
|
-
}
|
|
573
|
-
else if (effectiveThinking === "xhigh" && !supportsXhigh(session.model)) {
|
|
574
|
-
effectiveThinking = "high";
|
|
575
|
-
}
|
|
576
|
-
if (effectiveThinking !== session.thinkingLevel) {
|
|
577
|
-
session.setThinkingLevel(effectiveThinking);
|
|
578
|
-
}
|
|
533
|
+
const startupBenchmark = isTruthyEnvFlag(process.env.PI_STARTUP_BENCHMARK);
|
|
534
|
+
if (startupBenchmark && appMode !== "interactive") {
|
|
535
|
+
console.error(chalk.red("Error: PI_STARTUP_BENCHMARK only supports interactive mode"));
|
|
536
|
+
process.exit(1);
|
|
579
537
|
}
|
|
580
|
-
if (
|
|
581
|
-
|
|
538
|
+
if (appMode === "rpc") {
|
|
539
|
+
printTimings();
|
|
540
|
+
await runRpcMode(runtime);
|
|
582
541
|
}
|
|
583
|
-
else if (
|
|
542
|
+
else if (appMode === "interactive") {
|
|
584
543
|
if (scopedModels.length > 0 && (parsed.verbose || !settingsManager.getQuietStartup())) {
|
|
585
544
|
const modelList = scopedModels
|
|
586
545
|
.map((sm) => {
|
|
@@ -590,8 +549,7 @@ export async function main(args) {
|
|
|
590
549
|
.join(", ");
|
|
591
550
|
console.log(chalk.dim(`Model scope: ${modelList} ${chalk.gray("(Ctrl+P to cycle)")}`));
|
|
592
551
|
}
|
|
593
|
-
|
|
594
|
-
const mode = new InteractiveMode(session, {
|
|
552
|
+
const interactiveMode = new InteractiveMode(runtime, {
|
|
595
553
|
migratedProviders,
|
|
596
554
|
modelFallbackMessage,
|
|
597
555
|
initialMessage,
|
|
@@ -599,20 +557,37 @@ export async function main(args) {
|
|
|
599
557
|
initialMessages: parsed.messages,
|
|
600
558
|
verbose: parsed.verbose,
|
|
601
559
|
});
|
|
602
|
-
|
|
560
|
+
if (startupBenchmark) {
|
|
561
|
+
await interactiveMode.init();
|
|
562
|
+
time("interactiveMode.init");
|
|
563
|
+
printTimings();
|
|
564
|
+
interactiveMode.stop();
|
|
565
|
+
stopThemeWatcher();
|
|
566
|
+
if (process.stdout.writableLength > 0) {
|
|
567
|
+
await new Promise((resolve) => process.stdout.once("drain", resolve));
|
|
568
|
+
}
|
|
569
|
+
if (process.stderr.writableLength > 0) {
|
|
570
|
+
await new Promise((resolve) => process.stderr.once("drain", resolve));
|
|
571
|
+
}
|
|
572
|
+
return;
|
|
573
|
+
}
|
|
574
|
+
printTimings();
|
|
575
|
+
await interactiveMode.run();
|
|
603
576
|
}
|
|
604
577
|
else {
|
|
605
|
-
|
|
606
|
-
|
|
578
|
+
printTimings();
|
|
579
|
+
const exitCode = await runPrintMode(runtime, {
|
|
580
|
+
mode: toPrintOutputMode(appMode),
|
|
607
581
|
messages: parsed.messages,
|
|
608
582
|
initialMessage,
|
|
609
583
|
initialImages,
|
|
610
584
|
});
|
|
611
585
|
stopThemeWatcher();
|
|
612
|
-
|
|
613
|
-
|
|
586
|
+
restoreStdout();
|
|
587
|
+
if (exitCode !== 0) {
|
|
588
|
+
process.exitCode = exitCode;
|
|
614
589
|
}
|
|
615
|
-
|
|
590
|
+
return;
|
|
616
591
|
}
|
|
617
592
|
}
|
|
618
593
|
//# sourceMappingURL=main.js.map
|