@tomsun28/pizza 0.0.9 → 0.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +20 -143
- package/README.zh-CN.md +36 -0
- package/dist/bun/cli.d.ts +2 -0
- package/dist/bun/cli.js +6 -0
- package/dist/bun/register-bedrock.d.ts +1 -0
- package/dist/bun/register-bedrock.js +3 -0
- package/dist/cli/args.d.ts +48 -0
- package/dist/cli/args.js +330 -0
- package/dist/cli/config-selector.d.ts +13 -0
- package/dist/cli/config-selector.js +30 -0
- package/dist/cli/file-processor.d.ts +14 -0
- package/dist/cli/file-processor.js +82 -0
- package/dist/cli/initial-message.d.ts +17 -0
- package/dist/cli/initial-message.js +21 -0
- package/dist/cli/list-models.d.ts +8 -0
- package/dist/cli/list-models.js +96 -0
- package/dist/cli.d.ts +2 -0
- package/dist/cli.js +68 -0
- package/dist/config.d.ts +79 -0
- package/dist/config.js +223 -0
- package/dist/core/agent/index.d.ts +6 -0
- package/dist/core/agent/index.js +6 -0
- package/dist/core/agent/types.d.ts +202 -0
- package/dist/core/agent/types.js +51 -0
- package/dist/core/auth-storage.d.ts +135 -0
- package/dist/core/auth-storage.js +417 -0
- package/dist/core/bash-executor.d.ts +31 -0
- package/dist/core/bash-executor.js +107 -0
- package/dist/core/compaction/branch-summarization.d.ts +87 -0
- package/dist/core/compaction/branch-summarization.js +242 -0
- package/dist/core/compaction/compaction-engine.d.ts +40 -0
- package/dist/core/compaction/compaction-engine.js +292 -0
- package/dist/core/compaction/compaction.d.ts +106 -0
- package/dist/core/compaction/compaction.js +295 -0
- package/dist/core/compaction/index.d.ts +7 -0
- package/dist/core/compaction/index.js +7 -0
- package/dist/core/compaction/utils.d.ts +37 -0
- package/dist/core/compaction/utils.js +152 -0
- package/dist/core/defaults.d.ts +2 -0
- package/dist/core/defaults.js +1 -0
- package/dist/core/diagnostics.d.ts +14 -0
- package/dist/core/diagnostics.js +1 -0
- package/dist/core/event-bus.d.ts +8 -0
- package/dist/core/event-bus.js +24 -0
- package/dist/core/event-store/events.d.ts +465 -0
- package/dist/core/event-store/events.js +6 -0
- package/dist/core/event-store/index.d.ts +10 -0
- package/dist/core/event-store/index.js +10 -0
- package/dist/core/event-store/sqlite-store.d.ts +27 -0
- package/dist/core/event-store/sqlite-store.js +275 -0
- package/dist/core/event-store/store.d.ts +91 -0
- package/dist/core/event-store/store.js +7 -0
- package/dist/core/event-store/thread-scoped-store.d.ts +29 -0
- package/dist/core/event-store/thread-scoped-store.js +50 -0
- package/dist/core/event-store/types.d.ts +70 -0
- package/dist/core/event-store/types.js +7 -0
- package/dist/core/event-store/workspace.d.ts +37 -0
- package/dist/core/event-store/workspace.js +71 -0
- package/dist/core/exec.d.ts +28 -0
- package/dist/core/exec.js +74 -0
- package/dist/core/export-html/ansi-to-html.d.ts +21 -0
- package/dist/core/export-html/ansi-to-html.js +248 -0
- package/dist/core/export-html/index.d.ts +29 -0
- package/dist/core/export-html/index.js +186 -0
- package/dist/core/export-html/template.css +1017 -0
- package/dist/core/export-html/template.html +55 -0
- package/dist/core/export-html/template.js +1742 -0
- package/dist/core/export-html/tool-renderer.d.ts +39 -0
- package/dist/core/export-html/tool-renderer.js +94 -0
- package/dist/core/export-html/vendor/highlight.min.js +1213 -0
- package/dist/core/export-html/vendor/marked.min.js +6 -0
- package/dist/core/extensions/index.d.ts +12 -0
- package/dist/core/extensions/index.js +9 -0
- package/dist/core/extensions/loader.d.ts +24 -0
- package/dist/core/extensions/loader.js +492 -0
- package/dist/core/extensions/runner.d.ts +167 -0
- package/dist/core/extensions/runner.js +898 -0
- package/dist/core/extensions/session-context.d.ts +67 -0
- package/dist/core/extensions/session-context.js +272 -0
- package/dist/core/extensions/types.d.ts +1147 -0
- package/dist/core/extensions/types.js +44 -0
- package/dist/core/extensions/wrapper.d.ts +19 -0
- package/dist/core/extensions/wrapper.js +21 -0
- package/dist/core/footer-data-provider.d.ts +47 -0
- package/dist/core/footer-data-provider.js +321 -0
- package/dist/core/goal/index.d.ts +3 -0
- package/dist/core/goal/index.js +1 -0
- package/dist/core/goal/scheduler.d.ts +83 -0
- package/dist/core/goal/scheduler.js +154 -0
- package/dist/core/goal/types.d.ts +182 -0
- package/dist/core/goal/types.js +11 -0
- package/dist/core/index.d.ts +8 -0
- package/dist/core/index.js +8 -0
- package/dist/core/intent/classifier.d.ts +53 -0
- package/dist/core/intent/classifier.js +353 -0
- package/dist/core/intent/index.d.ts +8 -0
- package/dist/core/intent/index.js +8 -0
- package/dist/core/intent/tool-adapter.d.ts +31 -0
- package/dist/core/intent/tool-adapter.js +168 -0
- package/dist/core/intent/types.d.ts +71 -0
- package/dist/core/intent/types.js +6 -0
- package/dist/core/keybindings.d.ts +297 -0
- package/dist/core/keybindings.js +250 -0
- package/dist/core/messages.d.ts +30 -0
- package/dist/core/messages.js +134 -0
- package/dist/core/model-registry.d.ts +131 -0
- package/dist/core/model-registry.js +634 -0
- package/dist/core/model-resolver.d.ts +109 -0
- package/dist/core/model-resolver.js +486 -0
- package/dist/core/output-guard.d.ts +5 -0
- package/dist/core/output-guard.js +58 -0
- package/dist/core/package-manager.d.ts +196 -0
- package/dist/core/package-manager.js +1873 -0
- package/dist/core/projection/boundary-inferrer.d.ts +58 -0
- package/dist/core/projection/boundary-inferrer.js +122 -0
- package/dist/core/projection/event-to-message.d.ts +35 -0
- package/dist/core/projection/event-to-message.js +253 -0
- package/dist/core/projection/goal-projection.d.ts +67 -0
- package/dist/core/projection/goal-projection.js +339 -0
- package/dist/core/projection/index.d.ts +13 -0
- package/dist/core/projection/index.js +13 -0
- package/dist/core/projection/session-manager.d.ts +100 -0
- package/dist/core/projection/session-manager.js +331 -0
- package/dist/core/projection/session-projection.d.ts +58 -0
- package/dist/core/projection/session-projection.js +257 -0
- package/dist/core/projection/task-history.d.ts +13 -0
- package/dist/core/projection/task-history.js +61 -0
- package/dist/core/projection/timeline-projection.d.ts +82 -0
- package/dist/core/projection/timeline-projection.js +276 -0
- package/dist/core/projection/types.d.ts +69 -0
- package/dist/core/projection/types.js +6 -0
- package/dist/core/prompt-templates.d.ts +51 -0
- package/dist/core/prompt-templates.js +249 -0
- package/dist/core/resolve-config-value.d.ts +22 -0
- package/dist/core/resolve-config-value.js +125 -0
- package/dist/core/resource-loader.d.ts +193 -0
- package/dist/core/resource-loader.js +685 -0
- package/dist/core/runtime/ai-client.d.ts +12 -0
- package/dist/core/runtime/ai-client.js +153 -0
- package/dist/core/runtime/checkpoint.d.ts +12 -0
- package/dist/core/runtime/checkpoint.js +78 -0
- package/dist/core/runtime/index.d.ts +12 -0
- package/dist/core/runtime/index.js +12 -0
- package/dist/core/runtime/llm-types.d.ts +99 -0
- package/dist/core/runtime/llm-types.js +6 -0
- package/dist/core/runtime/local-runtime.d.ts +23 -0
- package/dist/core/runtime/local-runtime.js +59 -0
- package/dist/core/runtime/policies.d.ts +72 -0
- package/dist/core/runtime/policies.js +37 -0
- package/dist/core/runtime/reactor.d.ts +213 -0
- package/dist/core/runtime/reactor.js +992 -0
- package/dist/core/runtime/runtime.d.ts +191 -0
- package/dist/core/runtime/runtime.js +449 -0
- package/dist/core/runtime/types.d.ts +42 -0
- package/dist/core/runtime/types.js +1 -0
- package/dist/core/sdk.d.ts +12 -0
- package/dist/core/sdk.js +10 -0
- package/dist/core/session-context-builder.d.ts +9 -0
- package/dist/core/session-context-builder.js +87 -0
- package/dist/core/session-cwd.d.ts +18 -0
- package/dist/core/session-cwd.js +36 -0
- package/dist/core/session-facade-factory.d.ts +79 -0
- package/dist/core/session-facade-factory.js +460 -0
- package/dist/core/session-facade.d.ts +57 -0
- package/dist/core/session-facade.js +91 -0
- package/dist/core/session-listing.d.ts +30 -0
- package/dist/core/session-listing.js +168 -0
- package/dist/core/session-reader.d.ts +19 -0
- package/dist/core/session-reader.js +101 -0
- package/dist/core/session-ref.d.ts +7 -0
- package/dist/core/session-ref.js +25 -0
- package/dist/core/session-services.d.ts +51 -0
- package/dist/core/session-services.js +90 -0
- package/dist/core/session-stats.d.ts +43 -0
- package/dist/core/session-stats.js +41 -0
- package/dist/core/settings-manager.d.ts +236 -0
- package/dist/core/settings-manager.js +706 -0
- package/dist/core/skill-block-parser.d.ts +12 -0
- package/dist/core/skill-block-parser.js +15 -0
- package/dist/core/skills.d.ts +59 -0
- package/dist/core/skills.js +408 -0
- package/dist/core/slash-commands.d.ts +13 -0
- package/dist/core/slash-commands.js +17 -0
- package/dist/core/source-info.d.ts +17 -0
- package/dist/core/source-info.js +18 -0
- package/dist/core/system-prompt.d.ts +27 -0
- package/dist/core/system-prompt.js +179 -0
- package/dist/core/timings.d.ts +7 -0
- package/dist/core/timings.js +30 -0
- package/dist/core/tools/bash.d.ts +95 -0
- package/dist/core/tools/bash.js +513 -0
- package/dist/core/tools/builtin-commands.d.ts +75 -0
- package/dist/core/tools/builtin-commands.js +503 -0
- package/dist/core/tools/compat-commands.d.ts +12 -0
- package/dist/core/tools/compat-commands.js +1280 -0
- package/dist/core/tools/edit-diff.d.ts +59 -0
- package/dist/core/tools/edit-diff.js +263 -0
- package/dist/core/tools/edit.d.ts +49 -0
- package/dist/core/tools/edit.js +340 -0
- package/dist/core/tools/file-mutation-queue.d.ts +5 -0
- package/dist/core/tools/file-mutation-queue.js +36 -0
- package/dist/core/tools/find.d.ts +34 -0
- package/dist/core/tools/find.js +459 -0
- package/dist/core/tools/grep.d.ts +36 -0
- package/dist/core/tools/grep.js +422 -0
- package/dist/core/tools/index.d.ts +70 -0
- package/dist/core/tools/index.js +129 -0
- package/dist/core/tools/line-anchors.d.ts +33 -0
- package/dist/core/tools/line-anchors.js +151 -0
- package/dist/core/tools/ls.d.ts +36 -0
- package/dist/core/tools/ls.js +268 -0
- package/dist/core/tools/path-utils.d.ts +7 -0
- package/dist/core/tools/path-utils.js +80 -0
- package/dist/core/tools/read.d.ts +35 -0
- package/dist/core/tools/read.js +244 -0
- package/dist/core/tools/render-utils.d.ts +20 -0
- package/dist/core/tools/render-utils.js +48 -0
- package/dist/core/tools/session-split.d.ts +9 -0
- package/dist/core/tools/session-split.js +77 -0
- package/dist/core/tools/tool-definition-wrapper.d.ts +13 -0
- package/dist/core/tools/tool-definition-wrapper.js +32 -0
- package/dist/core/tools/truncate.d.ts +69 -0
- package/dist/core/tools/truncate.js +204 -0
- package/dist/core/tools/write.d.ts +25 -0
- package/dist/core/tools/write.js +211 -0
- package/dist/core/types/session-types.d.ts +123 -0
- package/dist/core/types/session-types.js +8 -0
- package/dist/index.d.ts +27 -0
- package/dist/index.js +38 -0
- package/dist/main.d.ts +11 -2
- package/dist/main.js +577 -149
- package/dist/modes/event-mapper.d.ts +115 -0
- package/dist/modes/event-mapper.js +200 -0
- package/dist/modes/gui/server.d.ts +14 -0
- package/dist/modes/gui/server.js +1032 -0
- package/dist/modes/index.d.ts +10 -0
- package/dist/modes/index.js +9 -0
- package/dist/modes/interactive/assets/clankolas.png +0 -0
- package/dist/modes/interactive/components/armin.d.ts +33 -0
- package/dist/modes/interactive/components/armin.js +328 -0
- package/dist/modes/interactive/components/assistant-message.d.ts +19 -0
- package/dist/modes/interactive/components/assistant-message.js +115 -0
- package/dist/modes/interactive/components/bash-execution.d.ts +33 -0
- package/dist/modes/interactive/components/bash-execution.js +169 -0
- package/dist/modes/interactive/components/bordered-loader.d.ts +15 -0
- package/dist/modes/interactive/components/bordered-loader.js +50 -0
- package/dist/modes/interactive/components/branch-summary-message.d.ts +15 -0
- package/dist/modes/interactive/components/branch-summary-message.js +41 -0
- package/dist/modes/interactive/components/brand-header.d.ts +33 -0
- package/dist/modes/interactive/components/brand-header.js +235 -0
- package/dist/modes/interactive/components/compaction-summary-message.d.ts +15 -0
- package/dist/modes/interactive/components/compaction-summary-message.js +42 -0
- package/dist/modes/interactive/components/config-selector.d.ts +70 -0
- package/dist/modes/interactive/components/config-selector.js +469 -0
- package/dist/modes/interactive/components/countdown-timer.d.ts +13 -0
- package/dist/modes/interactive/components/countdown-timer.js +27 -0
- package/dist/modes/interactive/components/custom-editor.d.ts +27 -0
- package/dist/modes/interactive/components/custom-editor.js +94 -0
- package/dist/modes/interactive/components/custom-message.d.ts +19 -0
- package/dist/modes/interactive/components/custom-message.js +73 -0
- package/dist/modes/interactive/components/daxnuts.d.ts +22 -0
- package/dist/modes/interactive/components/daxnuts.js +137 -0
- package/dist/modes/interactive/components/diff.d.ts +11 -0
- package/dist/modes/interactive/components/diff.js +132 -0
- package/dist/modes/interactive/components/dynamic-border.d.ts +14 -0
- package/dist/modes/interactive/components/dynamic-border.js +19 -0
- package/dist/modes/interactive/components/earendil-announcement.d.ts +4 -0
- package/dist/modes/interactive/components/earendil-announcement.js +39 -0
- package/dist/modes/interactive/components/extension-editor.d.ts +19 -0
- package/dist/modes/interactive/components/extension-editor.js +105 -0
- package/dist/modes/interactive/components/extension-input.d.ts +22 -0
- package/dist/modes/interactive/components/extension-input.js +54 -0
- package/dist/modes/interactive/components/extension-selector.d.ts +23 -0
- package/dist/modes/interactive/components/extension-selector.js +70 -0
- package/dist/modes/interactive/components/footer.d.ts +55 -0
- package/dist/modes/interactive/components/footer.js +207 -0
- package/dist/modes/interactive/components/index.d.ts +31 -0
- package/dist/modes/interactive/components/index.js +32 -0
- package/dist/modes/interactive/components/keybinding-hints.d.ts +7 -0
- package/dist/modes/interactive/components/keybinding-hints.js +21 -0
- package/dist/modes/interactive/components/login-dialog.d.ts +41 -0
- package/dist/modes/interactive/components/login-dialog.js +138 -0
- package/dist/modes/interactive/components/model-selector.d.ts +32 -0
- package/dist/modes/interactive/components/model-selector.js +209 -0
- package/dist/modes/interactive/components/oauth-selector.d.ts +18 -0
- package/dist/modes/interactive/components/oauth-selector.js +91 -0
- package/dist/modes/interactive/components/settings-selector.d.ts +57 -0
- package/dist/modes/interactive/components/settings-selector.js +299 -0
- package/dist/modes/interactive/components/show-images-selector.d.ts +9 -0
- package/dist/modes/interactive/components/show-images-selector.js +37 -0
- package/dist/modes/interactive/components/skill-invocation-message.d.ts +16 -0
- package/dist/modes/interactive/components/skill-invocation-message.js +44 -0
- package/dist/modes/interactive/components/theme-selector.d.ts +10 -0
- package/dist/modes/interactive/components/theme-selector.js +47 -0
- package/dist/modes/interactive/components/thinking-selector.d.ts +10 -0
- package/dist/modes/interactive/components/thinking-selector.js +50 -0
- package/dist/modes/interactive/components/timeline-view.d.ts +31 -0
- package/dist/modes/interactive/components/timeline-view.js +81 -0
- package/dist/modes/interactive/components/tool-execution.d.ts +64 -0
- package/dist/modes/interactive/components/tool-execution.js +305 -0
- package/dist/modes/interactive/components/tree-selector.d.ts +88 -0
- package/dist/modes/interactive/components/tree-selector.js +1072 -0
- package/dist/modes/interactive/components/user-message-selector.d.ts +29 -0
- package/dist/modes/interactive/components/user-message-selector.js +110 -0
- package/dist/modes/interactive/components/user-message.d.ts +9 -0
- package/dist/modes/interactive/components/user-message.js +27 -0
- package/dist/modes/interactive/components/visual-truncate.d.ts +23 -0
- package/dist/modes/interactive/components/visual-truncate.js +32 -0
- package/dist/modes/interactive/interactive-mode.d.ts +394 -0
- package/dist/modes/interactive/interactive-mode.js +4116 -0
- package/dist/modes/interactive/theme/dark.json +85 -0
- package/dist/modes/interactive/theme/light.json +84 -0
- package/dist/modes/interactive/theme/theme-schema.json +335 -0
- package/dist/modes/interactive/theme/theme.d.ts +80 -0
- package/dist/modes/interactive/theme/theme.js +973 -0
- package/dist/modes/print-mode.d.ts +27 -0
- package/dist/modes/print-mode.js +102 -0
- package/dist/modes/rpc/jsonl.d.ts +16 -0
- package/dist/modes/rpc/jsonl.js +48 -0
- package/dist/modes/rpc/rpc-client.d.ts +219 -0
- package/dist/modes/rpc/rpc-client.js +405 -0
- package/dist/modes/rpc/rpc-mode.d.ts +19 -0
- package/dist/modes/rpc/rpc-mode.js +381 -0
- package/dist/modes/rpc/rpc-types.d.ts +406 -0
- package/dist/modes/rpc/rpc-types.js +7 -0
- package/dist/package-manager-cli.d.ts +3 -0
- package/dist/package-manager-cli.js +233 -0
- package/dist/utils/changelog.d.ts +20 -0
- package/dist/utils/changelog.js +86 -0
- package/dist/utils/child-process.d.ts +10 -0
- package/dist/utils/child-process.js +77 -0
- package/dist/utils/clipboard-image.d.ts +10 -0
- package/dist/utils/clipboard-image.js +244 -0
- package/dist/utils/clipboard-native.d.ts +7 -0
- package/dist/utils/clipboard-native.js +13 -0
- package/dist/utils/clipboard.d.ts +1 -0
- package/dist/utils/clipboard.js +77 -0
- package/dist/utils/exif-orientation.d.ts +4 -0
- package/dist/utils/exif-orientation.js +157 -0
- package/dist/utils/frontmatter.d.ts +7 -0
- package/dist/utils/frontmatter.js +25 -0
- package/dist/utils/git.d.ts +25 -0
- package/dist/utils/git.js +162 -0
- package/dist/utils/image-convert.d.ts +8 -0
- package/dist/utils/image-convert.js +38 -0
- package/dist/utils/image-resize.d.ts +35 -0
- package/dist/utils/image-resize.js +136 -0
- package/dist/utils/mime.d.ts +1 -0
- package/dist/utils/mime.js +25 -0
- package/dist/utils/path-shims.d.ts +1 -0
- package/dist/utils/path-shims.js +90 -0
- package/dist/utils/paths.d.ts +6 -0
- package/dist/utils/paths.js +18 -0
- package/dist/utils/photon.d.ts +20 -0
- package/dist/utils/photon.js +120 -0
- package/dist/utils/shell.d.ts +29 -0
- package/dist/utils/shell.js +189 -0
- package/dist/utils/sleep.d.ts +4 -0
- package/dist/utils/sleep.js +16 -0
- package/dist/utils/tools-manager.d.ts +3 -0
- package/dist/utils/tools-manager.js +101 -0
- package/dist/vendor/bin/darwin-arm64/fd +0 -0
- package/dist/vendor/bin/darwin-arm64/rg +0 -0
- package/dist/vendor/bin/darwin-x64/fd +0 -0
- package/dist/vendor/bin/darwin-x64/rg +0 -0
- package/dist/vendor/bin/linux-arm64/fd +0 -0
- package/dist/vendor/bin/linux-arm64/rg +0 -0
- package/dist/vendor/bin/linux-x64/fd +0 -0
- package/dist/vendor/bin/linux-x64/rg +0 -0
- package/dist/vendor/bin/win32-arm64/fd.exe +0 -0
- package/dist/vendor/bin/win32-arm64/rg.exe +0 -0
- package/dist/vendor/bin/win32-x64/fd.exe +0 -0
- package/dist/vendor/bin/win32-x64/rg.exe +0 -0
- package/package.json +90 -26
- package/dist/extension/core.d.ts +0 -69
- package/dist/extension/core.js +0 -270
- package/dist/extension/core.js.map +0 -1
- package/dist/extension/index.d.ts +0 -25
- package/dist/extension/index.js +0 -303
- package/dist/extension/index.js.map +0 -1
- package/dist/main.js.map +0 -1
- package/themes/pizza.json +0 -87
package/dist/main.js
CHANGED
|
@@ -1,168 +1,596 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
function
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
}
|
|
38
|
-
else if (args[i] === "--mode" && args[i + 1]) {
|
|
39
|
-
const m = args[++i];
|
|
40
|
-
if (m === "json" || m === "text")
|
|
41
|
-
result.mode = m;
|
|
42
|
-
}
|
|
43
|
-
else if (args[i] === "-p" || args[i] === "--print") {
|
|
44
|
-
result.print = true;
|
|
45
|
-
}
|
|
46
|
-
else if (args[i] === "--no-session") {
|
|
47
|
-
result.noSession = true;
|
|
48
|
-
}
|
|
49
|
-
else if (args[i] === "--no-skills") {
|
|
50
|
-
result.noSkills = true;
|
|
51
|
-
}
|
|
52
|
-
else if (args[i] === "--no-extensions") {
|
|
53
|
-
result.noExtensions = true;
|
|
54
|
-
}
|
|
55
|
-
else if (args[i] === "--no-prompt-templates") {
|
|
56
|
-
result.noPromptTemplates = true;
|
|
57
|
-
}
|
|
58
|
-
else if (args[i] === "--help" || args[i] === "-h") {
|
|
59
|
-
printHelp();
|
|
60
|
-
process.exit(0);
|
|
61
|
-
}
|
|
62
|
-
else if (!args[i].startsWith("-")) {
|
|
63
|
-
result.message = args[i];
|
|
64
|
-
}
|
|
65
|
-
}
|
|
66
|
-
return result;
|
|
67
|
-
}
|
|
68
|
-
function printHelp() {
|
|
69
|
-
console.log(`
|
|
70
|
-
🍕 pizza — CLI is all you need
|
|
71
|
-
|
|
72
|
-
USAGE
|
|
73
|
-
pizza [options] [message]
|
|
74
|
-
|
|
75
|
-
OPTIONS
|
|
76
|
-
--provider <name> LLM provider (default: from pizza settings)
|
|
77
|
-
-m, --model <id> Model ID (default: from pizza settings)
|
|
78
|
-
--mode <text|json> Output mode: text or JSON event stream
|
|
79
|
-
-p, --print Print mode (non-interactive, single-shot)
|
|
80
|
-
--no-session Disable session persistence
|
|
81
|
-
--no-skills Disable skills
|
|
82
|
-
--no-extensions Disable extensions
|
|
83
|
-
--no-prompt-templates Disable prompt templates
|
|
84
|
-
-h, --help Show this help
|
|
85
|
-
|
|
86
|
-
Powered by pi coding agent. Uses pi's TUI, session management, and extension system.
|
|
87
|
-
[CLI] tag mode is active by default. Use /cli-mode inside the session to toggle it.
|
|
88
|
-
`);
|
|
89
|
-
}
|
|
90
|
-
// ─── Main ─────────────────────────────────────────────────────────────────────
|
|
1
|
+
/**
|
|
2
|
+
* Main entry point for the coding agent CLI.
|
|
3
|
+
*
|
|
4
|
+
* This file handles CLI argument parsing and translates them into
|
|
5
|
+
* createSessionFacade() options. The SDK does the heavy lifting.
|
|
6
|
+
*/
|
|
7
|
+
import { join, resolve } from "node:path";
|
|
8
|
+
import { createInterface } from "node:readline";
|
|
9
|
+
import { getSupportedThinkingLevels } from "@earendil-works/pi-ai/compat";
|
|
10
|
+
function supportsXhigh(model) {
|
|
11
|
+
return getSupportedThinkingLevels(model).includes("xhigh");
|
|
12
|
+
}
|
|
13
|
+
import chalk from "chalk";
|
|
14
|
+
import { parseArgs, printHelp } from "./cli/args.js";
|
|
15
|
+
import { processFileArguments } from "./cli/file-processor.js";
|
|
16
|
+
import { buildInitialMessage } from "./cli/initial-message.js";
|
|
17
|
+
import { listModels } from "./cli/list-models.js";
|
|
18
|
+
import { getAgentDir, getModelsPath, VERSION } from "./config.js";
|
|
19
|
+
import { createSessionServices, } from "./core/session-services.js";
|
|
20
|
+
import { AuthStorage } from "./core/auth-storage.js";
|
|
21
|
+
import { exportFromFile } from "./core/export-html/index.js";
|
|
22
|
+
import { resolveCliModel } from "./core/model-resolver.js";
|
|
23
|
+
import { restoreStdout, takeOverStdout } from "./core/output-guard.js";
|
|
24
|
+
import { createSessionFacade } from "./core/session-facade-factory.js";
|
|
25
|
+
import { getAgentDirFromSessionDir, parseSessionRef } from "./core/session-ref.js";
|
|
26
|
+
import { listWorkspaceSessions, listAllSessions } from "./core/session-listing.js";
|
|
27
|
+
import { SettingsManager } from "./core/settings-manager.js";
|
|
28
|
+
import { printTimings, resetTimings, time } from "./core/timings.js";
|
|
29
|
+
import { InteractiveMode, runGuiModeWithFacade, runPrintModeWithFacade, runRpcModeWithFacade } from "./modes/index.js";
|
|
30
|
+
import { initTheme, stopThemeWatcher } from "./modes/interactive/theme/theme.js";
|
|
31
|
+
import { handleConfigCommand, handlePackageCommand } from "./package-manager-cli.js";
|
|
32
|
+
import { isLocalPath } from "./utils/paths.js";
|
|
33
|
+
/**
|
|
34
|
+
* Read all content from piped stdin.
|
|
35
|
+
* Returns undefined if stdin is a TTY (interactive terminal).
|
|
36
|
+
*/
|
|
91
37
|
async function readPipedStdin() {
|
|
92
|
-
|
|
38
|
+
// If stdin is a TTY, we're running interactively - don't read stdin
|
|
39
|
+
if (process.stdin.isTTY) {
|
|
93
40
|
return undefined;
|
|
41
|
+
}
|
|
94
42
|
return new Promise((resolve) => {
|
|
95
43
|
let data = "";
|
|
96
44
|
process.stdin.setEncoding("utf8");
|
|
97
|
-
process.stdin.on("data", (chunk) => {
|
|
98
|
-
|
|
45
|
+
process.stdin.on("data", (chunk) => {
|
|
46
|
+
data += chunk;
|
|
47
|
+
});
|
|
48
|
+
process.stdin.on("end", () => {
|
|
49
|
+
resolve(data.trim() || undefined);
|
|
50
|
+
});
|
|
99
51
|
process.stdin.resume();
|
|
100
52
|
});
|
|
101
53
|
}
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
const
|
|
110
|
-
|
|
111
|
-
const
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
54
|
+
function collectSettingsDiagnostics(settingsManager, context) {
|
|
55
|
+
return settingsManager.drainErrors().map(({ scope, error }) => ({
|
|
56
|
+
type: "warning",
|
|
57
|
+
message: `(${context}, ${scope} settings) ${error.message}`,
|
|
58
|
+
}));
|
|
59
|
+
}
|
|
60
|
+
function reportDiagnostics(diagnostics) {
|
|
61
|
+
for (const diagnostic of diagnostics) {
|
|
62
|
+
const color = diagnostic.type === "error" ? chalk.red : diagnostic.type === "warning" ? chalk.yellow : chalk.dim;
|
|
63
|
+
const prefix = diagnostic.type === "error" ? "Error: " : diagnostic.type === "warning" ? "Warning: " : "";
|
|
64
|
+
console.error(color(`${prefix}${diagnostic.message}`));
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
function isTruthyEnvFlag(value) {
|
|
68
|
+
if (!value)
|
|
69
|
+
return false;
|
|
70
|
+
return value === "1" || value.toLowerCase() === "true" || value.toLowerCase() === "yes";
|
|
71
|
+
}
|
|
72
|
+
function resolveAppMode(parsed, stdinIsTTY) {
|
|
73
|
+
if (parsed.mode === "gui") {
|
|
74
|
+
return "gui";
|
|
75
|
+
}
|
|
76
|
+
if (parsed.mode === "rpc") {
|
|
77
|
+
return "rpc";
|
|
78
|
+
}
|
|
79
|
+
if (parsed.mode === "json") {
|
|
80
|
+
return "json";
|
|
81
|
+
}
|
|
82
|
+
if (parsed.print || !stdinIsTTY) {
|
|
83
|
+
return "print";
|
|
84
|
+
}
|
|
85
|
+
return "interactive";
|
|
86
|
+
}
|
|
87
|
+
function toPrintOutputMode(appMode) {
|
|
88
|
+
return appMode === "json" ? "json" : "text";
|
|
89
|
+
}
|
|
90
|
+
async function prepareInitialMessage(parsed, autoResizeImages, stdinContent) {
|
|
91
|
+
if (parsed.fileArgs.length === 0) {
|
|
92
|
+
return buildInitialMessage({ parsed, stdinContent });
|
|
93
|
+
}
|
|
94
|
+
const { text, images } = await processFileArguments(parsed.fileArgs, { autoResizeImages });
|
|
95
|
+
return buildInitialMessage({
|
|
96
|
+
parsed,
|
|
97
|
+
fileText: text,
|
|
98
|
+
fileImages: images,
|
|
99
|
+
stdinContent,
|
|
100
|
+
});
|
|
101
|
+
}
|
|
102
|
+
/**
|
|
103
|
+
* Resolve a session argument to an event-session reference.
|
|
104
|
+
* Accepts a full event-session ref or a session ID prefix.
|
|
105
|
+
*/
|
|
106
|
+
async function resolveSessionPath(sessionArg, cwd, agentDir) {
|
|
107
|
+
if (sessionArg.includes("/") || sessionArg.includes("\\") || sessionArg.endsWith(".jsonl")) {
|
|
108
|
+
return { type: "not_found", arg: `${sessionArg} (legacy JSONL paths are no longer supported)` };
|
|
109
|
+
}
|
|
110
|
+
// Try to match as session ID in current project first
|
|
111
|
+
const localSessions = await listWorkspaceSessions(cwd, agentDir);
|
|
112
|
+
const localMatches = localSessions.filter((s) => s.id.startsWith(sessionArg) || s.path === sessionArg);
|
|
113
|
+
if (localMatches.length >= 1) {
|
|
114
|
+
return { type: "local", path: localMatches[0].path };
|
|
115
|
+
}
|
|
116
|
+
// Try global search across all projects
|
|
117
|
+
const allSessions = await listAllSessions(agentDir);
|
|
118
|
+
const globalMatches = allSessions.filter((s) => s.id.startsWith(sessionArg) || s.path === sessionArg);
|
|
119
|
+
if (globalMatches.length >= 1) {
|
|
120
|
+
const match = globalMatches[0];
|
|
121
|
+
return { type: "global", path: match.path, cwd: match.cwd };
|
|
122
|
+
}
|
|
123
|
+
// Not found anywhere
|
|
124
|
+
return { type: "not_found", arg: sessionArg };
|
|
125
|
+
}
|
|
126
|
+
/** Prompt user for yes/no confirmation */
|
|
127
|
+
async function promptConfirm(message) {
|
|
128
|
+
return new Promise((resolve) => {
|
|
129
|
+
const rl = createInterface({
|
|
130
|
+
input: process.stdin,
|
|
131
|
+
output: process.stdout,
|
|
121
132
|
});
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
if (args.provider && args.model) {
|
|
126
|
-
model = getModel(args.provider, args.model);
|
|
127
|
-
}
|
|
128
|
-
else if (args.model) {
|
|
129
|
-
model = getModel("openai", args.model);
|
|
130
|
-
}
|
|
131
|
-
const created = await createAgentSessionFromServices({
|
|
132
|
-
services,
|
|
133
|
-
sessionManager,
|
|
134
|
-
sessionStartEvent,
|
|
135
|
-
model,
|
|
133
|
+
rl.question(`${message} [y/N] `, (answer) => {
|
|
134
|
+
rl.close();
|
|
135
|
+
resolve(answer.toLowerCase() === "y" || answer.toLowerCase() === "yes");
|
|
136
136
|
});
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
const
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
137
|
+
});
|
|
138
|
+
}
|
|
139
|
+
function buildSessionOptions(parsed, hasExistingSession, modelRegistry, settingsManager) {
|
|
140
|
+
const options = {};
|
|
141
|
+
const diagnostics = [];
|
|
142
|
+
let cliThinkingFromModel = false;
|
|
143
|
+
// Model from CLI
|
|
144
|
+
// - supports --provider <name> --model <pattern>
|
|
145
|
+
// - supports --model <provider>/<pattern>
|
|
146
|
+
if (parsed.model) {
|
|
147
|
+
const resolved = resolveCliModel({
|
|
148
|
+
cliProvider: parsed.provider,
|
|
149
|
+
cliModel: parsed.model,
|
|
150
|
+
modelRegistry,
|
|
151
|
+
});
|
|
152
|
+
if (resolved.warning) {
|
|
153
|
+
diagnostics.push({ type: "warning", message: resolved.warning });
|
|
154
|
+
}
|
|
155
|
+
if (resolved.error) {
|
|
156
|
+
diagnostics.push({ type: "error", message: resolved.error });
|
|
157
|
+
}
|
|
158
|
+
if (resolved.model) {
|
|
159
|
+
options.model = resolved.model;
|
|
160
|
+
// Allow "--model <pattern>:<thinking>" as a shorthand.
|
|
161
|
+
// Explicit --thinking still takes precedence (applied later).
|
|
162
|
+
if (!parsed.thinking && resolved.thinkingLevel) {
|
|
163
|
+
options.thinkingLevel = resolved.thinkingLevel;
|
|
164
|
+
cliThinkingFromModel = true;
|
|
165
|
+
}
|
|
166
|
+
}
|
|
167
|
+
}
|
|
168
|
+
// Thinking level from CLI (takes precedence over any model-level thinking)
|
|
169
|
+
if (parsed.thinking) {
|
|
170
|
+
options.thinkingLevel = parsed.thinking;
|
|
171
|
+
}
|
|
172
|
+
// API key from CLI - set in authStorage
|
|
173
|
+
// Tools
|
|
174
|
+
if (parsed.noTools) {
|
|
175
|
+
// --no-tools: start with no built-in tools
|
|
176
|
+
// --tools can still add specific ones back, including extension tools.
|
|
177
|
+
options.tools = parsed.tools && parsed.tools.length > 0 ? [...parsed.tools] : [];
|
|
178
|
+
}
|
|
179
|
+
else if (parsed.tools) {
|
|
180
|
+
options.tools = [...parsed.tools];
|
|
181
|
+
}
|
|
182
|
+
return { options, cliThinkingFromModel, diagnostics };
|
|
183
|
+
}
|
|
184
|
+
function resolveCliPaths(cwd, paths) {
|
|
185
|
+
return paths?.map((value) => (isLocalPath(value) ? resolve(cwd, value) : value));
|
|
186
|
+
}
|
|
187
|
+
async function createCliSessionSetup(options) {
|
|
188
|
+
const { cwd, agentDir, authStorage, parsed, resolvedPaths, extensionFactories, hasExistingSession } = options;
|
|
189
|
+
const services = await createSessionServices({
|
|
144
190
|
cwd,
|
|
145
191
|
agentDir,
|
|
146
|
-
|
|
192
|
+
authStorage,
|
|
193
|
+
extensionFlagValues: parsed.unknownFlags,
|
|
194
|
+
resourceLoaderOptions: {
|
|
195
|
+
additionalExtensionPaths: resolvedPaths.extensions,
|
|
196
|
+
additionalSkillPaths: resolvedPaths.skills,
|
|
197
|
+
additionalPromptTemplatePaths: resolvedPaths.promptTemplates,
|
|
198
|
+
additionalThemePaths: resolvedPaths.themes,
|
|
199
|
+
noExtensions: parsed.noExtensions,
|
|
200
|
+
noSkills: parsed.noSkills,
|
|
201
|
+
noPromptTemplates: parsed.noPromptTemplates,
|
|
202
|
+
noThemes: parsed.noThemes,
|
|
203
|
+
noContextFiles: parsed.noContextFiles,
|
|
204
|
+
systemPrompt: parsed.systemPrompt,
|
|
205
|
+
appendSystemPrompt: parsed.appendSystemPrompt,
|
|
206
|
+
extensionFactories,
|
|
207
|
+
},
|
|
147
208
|
});
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
209
|
+
const { settingsManager, modelRegistry, resourceLoader } = services;
|
|
210
|
+
const diagnostics = [
|
|
211
|
+
...services.diagnostics,
|
|
212
|
+
...collectSettingsDiagnostics(settingsManager, "runtime creation"),
|
|
213
|
+
...resourceLoader.getExtensions().errors.map(({ path, error }) => ({
|
|
214
|
+
type: "error",
|
|
215
|
+
message: `Failed to load extension "${path}": ${error}`,
|
|
216
|
+
})),
|
|
217
|
+
];
|
|
218
|
+
const { options: sessionOptions, cliThinkingFromModel, diagnostics: sessionOptionDiagnostics, } = buildSessionOptions(parsed, hasExistingSession, modelRegistry, settingsManager);
|
|
219
|
+
diagnostics.push(...sessionOptionDiagnostics);
|
|
220
|
+
if (parsed.apiKey) {
|
|
221
|
+
if (!sessionOptions.model) {
|
|
222
|
+
diagnostics.push({
|
|
223
|
+
type: "error",
|
|
224
|
+
message: "--api-key requires a model to be specified via --model, --provider/--model, or --models",
|
|
225
|
+
});
|
|
226
|
+
}
|
|
227
|
+
else {
|
|
228
|
+
authStorage.setRuntimeApiKey(sessionOptions.model.provider, parsed.apiKey);
|
|
229
|
+
}
|
|
230
|
+
}
|
|
231
|
+
return { services, diagnostics, sessionOptions, cliThinkingFromModel };
|
|
232
|
+
}
|
|
233
|
+
function applyCliThinkingClampToFacade(created, cliThinkingOverride) {
|
|
234
|
+
if (!created.model || !cliThinkingOverride)
|
|
235
|
+
return;
|
|
236
|
+
let effectiveThinking = created.thinkingLevel;
|
|
237
|
+
if (!created.model.reasoning) {
|
|
238
|
+
effectiveThinking = "off";
|
|
239
|
+
}
|
|
240
|
+
else if (effectiveThinking === "xhigh" && !supportsXhigh(created.model)) {
|
|
241
|
+
effectiveThinking = "high";
|
|
242
|
+
}
|
|
243
|
+
if (effectiveThinking !== created.thinkingLevel) {
|
|
244
|
+
created.facade.thinkingLevel = effectiveThinking;
|
|
245
|
+
}
|
|
246
|
+
}
|
|
247
|
+
async function resolveFacadePrintSessionTarget(parsed, cwd, agentDir) {
|
|
248
|
+
// --no-session: ephemeral in-memory mode
|
|
249
|
+
if (parsed.noSession) {
|
|
250
|
+
return { cwd, hasExistingSession: false };
|
|
251
|
+
}
|
|
252
|
+
// --rewind <id>: jump to a specific branch point
|
|
253
|
+
if (typeof parsed.rewind === "string") {
|
|
254
|
+
const resolved = await resolveSessionPath(parsed.rewind, cwd, agentDir);
|
|
255
|
+
switch (resolved.type) {
|
|
256
|
+
case "local":
|
|
257
|
+
case "global": {
|
|
258
|
+
const parsedRef = parseSessionRef(resolved.path);
|
|
259
|
+
if (!parsedRef.workspaceId) {
|
|
260
|
+
throw new Error(`Invalid session reference: ${resolved.path}`);
|
|
261
|
+
}
|
|
262
|
+
return {
|
|
263
|
+
cwd,
|
|
264
|
+
forkFrom: {
|
|
265
|
+
workspaceId: parsedRef.workspaceId,
|
|
266
|
+
sessionId: parsedRef.sessionId,
|
|
267
|
+
},
|
|
268
|
+
hasExistingSession: true,
|
|
269
|
+
};
|
|
270
|
+
}
|
|
271
|
+
case "not_found":
|
|
272
|
+
console.error(chalk.red(`No session found matching '${resolved.arg}'`));
|
|
273
|
+
process.exit(1);
|
|
274
|
+
}
|
|
275
|
+
}
|
|
276
|
+
// Default: auto-resume the eternal conversation
|
|
277
|
+
return { cwd, hasExistingSession: true };
|
|
278
|
+
}
|
|
279
|
+
export async function main(args, options) {
|
|
280
|
+
resetTimings();
|
|
281
|
+
const offlineMode = args.includes("--offline") || isTruthyEnvFlag(process.env.PIZZA_OFFLINE);
|
|
282
|
+
if (offlineMode) {
|
|
283
|
+
process.env.PIZZA_OFFLINE = "1";
|
|
284
|
+
process.env.PIZZA_SKIP_VERSION_CHECK = "1";
|
|
285
|
+
}
|
|
286
|
+
if (await handlePackageCommand(args)) {
|
|
287
|
+
return;
|
|
288
|
+
}
|
|
289
|
+
if (await handleConfigCommand(args)) {
|
|
290
|
+
return;
|
|
291
|
+
}
|
|
292
|
+
const parsed = parseArgs(args);
|
|
293
|
+
if (parsed.diagnostics.length > 0) {
|
|
294
|
+
for (const d of parsed.diagnostics) {
|
|
295
|
+
const color = d.type === "error" ? chalk.red : chalk.yellow;
|
|
296
|
+
console.error(color(`${d.type === "error" ? "Error" : "Warning"}: ${d.message}`));
|
|
297
|
+
}
|
|
298
|
+
if (parsed.diagnostics.some((d) => d.type === "error")) {
|
|
299
|
+
process.exit(1);
|
|
300
|
+
}
|
|
301
|
+
}
|
|
302
|
+
time("parseArgs");
|
|
303
|
+
let appMode = resolveAppMode(parsed, process.stdin.isTTY);
|
|
304
|
+
const shouldTakeOverStdout = appMode !== "interactive" && appMode !== "gui";
|
|
305
|
+
if (shouldTakeOverStdout) {
|
|
306
|
+
takeOverStdout();
|
|
307
|
+
}
|
|
308
|
+
if (parsed.version) {
|
|
309
|
+
console.log(VERSION);
|
|
310
|
+
process.exit(0);
|
|
311
|
+
}
|
|
312
|
+
if (parsed.export) {
|
|
313
|
+
let result;
|
|
314
|
+
try {
|
|
315
|
+
const outputPath = parsed.messages.length > 0 ? parsed.messages[0] : undefined;
|
|
316
|
+
result = await exportFromFile(parsed.export, outputPath);
|
|
317
|
+
}
|
|
318
|
+
catch (error) {
|
|
319
|
+
const message = error instanceof Error ? error.message : "Failed to export session";
|
|
320
|
+
console.error(chalk.red(`Error: ${message}`));
|
|
321
|
+
process.exit(1);
|
|
322
|
+
}
|
|
323
|
+
console.log(`Exported to: ${result}`);
|
|
324
|
+
process.exit(0);
|
|
325
|
+
}
|
|
326
|
+
if (parsed.mode === "rpc" && parsed.fileArgs.length > 0) {
|
|
327
|
+
console.error(chalk.red("Error: @file arguments are not supported in RPC mode"));
|
|
328
|
+
process.exit(1);
|
|
329
|
+
}
|
|
330
|
+
const cwd = process.cwd();
|
|
331
|
+
const agentDir = getAgentDir();
|
|
332
|
+
const startupSettingsManager = SettingsManager.create(cwd, agentDir);
|
|
333
|
+
reportDiagnostics(collectSettingsDiagnostics(startupSettingsManager, "startup session lookup"));
|
|
334
|
+
const sessionDir = parsed.sessionDir ?? startupSettingsManager.getSessionDir();
|
|
335
|
+
const sessionStorageAgentDir = getAgentDirFromSessionDir(sessionDir);
|
|
336
|
+
const resolvedPaths = {
|
|
337
|
+
extensions: resolveCliPaths(cwd, parsed.extensions),
|
|
338
|
+
skills: resolveCliPaths(cwd, parsed.skills),
|
|
339
|
+
promptTemplates: resolveCliPaths(cwd, parsed.promptTemplates),
|
|
340
|
+
themes: resolveCliPaths(cwd, parsed.themes),
|
|
341
|
+
};
|
|
342
|
+
const authStorage = AuthStorage.create(join(agentDir, "auth.json"));
|
|
343
|
+
const target = await resolveFacadePrintSessionTarget(parsed, cwd, agentDir);
|
|
344
|
+
const setup = await createCliSessionSetup({
|
|
345
|
+
cwd: target.cwd,
|
|
346
|
+
agentDir,
|
|
347
|
+
authStorage,
|
|
348
|
+
parsed,
|
|
349
|
+
resolvedPaths,
|
|
350
|
+
extensionFactories: options?.extensionFactories,
|
|
351
|
+
hasExistingSession: target.hasExistingSession,
|
|
352
|
+
});
|
|
353
|
+
const { services, sessionOptions, cliThinkingFromModel } = setup;
|
|
354
|
+
const { settingsManager, modelRegistry, resourceLoader } = services;
|
|
355
|
+
if (parsed.help) {
|
|
356
|
+
const extensionFlags = resourceLoader
|
|
357
|
+
.getExtensions()
|
|
358
|
+
.extensions.flatMap((extension) => Array.from(extension.flags.values()));
|
|
359
|
+
printHelp(extensionFlags);
|
|
360
|
+
process.exit(0);
|
|
361
|
+
}
|
|
362
|
+
if (parsed.listModels !== undefined) {
|
|
363
|
+
const searchPattern = typeof parsed.listModels === "string" ? parsed.listModels : undefined;
|
|
364
|
+
await listModels(modelRegistry, searchPattern);
|
|
365
|
+
process.exit(0);
|
|
366
|
+
}
|
|
367
|
+
if (appMode === "rpc") {
|
|
368
|
+
initTheme(settingsManager.getTheme(), false);
|
|
369
|
+
time("initTheme");
|
|
370
|
+
reportDiagnostics(setup.diagnostics);
|
|
371
|
+
if (setup.diagnostics.some((diagnostic) => diagnostic.type === "error")) {
|
|
372
|
+
process.exit(1);
|
|
373
|
+
}
|
|
374
|
+
time("createSessionFacade.setup");
|
|
375
|
+
const created = await createSessionFacade({
|
|
376
|
+
cwd: target.cwd,
|
|
377
|
+
agentDir: sessionStorageAgentDir,
|
|
378
|
+
authStorage,
|
|
379
|
+
settingsManager,
|
|
380
|
+
modelRegistry,
|
|
381
|
+
resourceLoader,
|
|
382
|
+
model: sessionOptions.model,
|
|
383
|
+
thinkingLevel: sessionOptions.thinkingLevel,
|
|
384
|
+
tools: sessionOptions.tools,
|
|
385
|
+
customTools: sessionOptions.customTools,
|
|
386
|
+
storagePath: parsed.noSession ? ":memory:" : undefined,
|
|
387
|
+
sessionIndexPath: parsed.noSession ? ":memory:" : undefined,
|
|
388
|
+
workspaceId: target.workspaceId,
|
|
389
|
+
sessionId: target.sessionId,
|
|
390
|
+
forkFrom: target.forkFrom
|
|
391
|
+
? {
|
|
392
|
+
...target.forkFrom,
|
|
393
|
+
agentDir: sessionStorageAgentDir,
|
|
394
|
+
}
|
|
395
|
+
: undefined,
|
|
396
|
+
});
|
|
397
|
+
applyCliThinkingClampToFacade(created, parsed.thinking !== undefined || cliThinkingFromModel);
|
|
398
|
+
time("createSessionFacade");
|
|
399
|
+
if (!created.model) {
|
|
400
|
+
console.error(chalk.red("No models available."));
|
|
401
|
+
console.error(chalk.yellow("\nSet an API key environment variable:"));
|
|
402
|
+
console.error(" ANTHROPIC_API_KEY, OPENAI_API_KEY, GEMINI_API_KEY, etc.");
|
|
403
|
+
console.error(chalk.yellow(`\nOr create ${getModelsPath()}`));
|
|
404
|
+
process.exit(1);
|
|
405
|
+
}
|
|
406
|
+
const startupBenchmark = isTruthyEnvFlag(process.env.PIZZA_STARTUP_BENCHMARK);
|
|
407
|
+
if (startupBenchmark) {
|
|
408
|
+
console.error(chalk.red("Error: PIZZA_STARTUP_BENCHMARK only supports interactive mode"));
|
|
409
|
+
process.exit(1);
|
|
410
|
+
}
|
|
411
|
+
printTimings();
|
|
412
|
+
await runRpcModeWithFacade(created.facade);
|
|
413
|
+
return;
|
|
414
|
+
}
|
|
415
|
+
if (appMode === "interactive") {
|
|
416
|
+
// Interactive mode via SessionFacade
|
|
417
|
+
initTheme(settingsManager.getTheme(), true);
|
|
418
|
+
time("initTheme");
|
|
419
|
+
reportDiagnostics(setup.diagnostics);
|
|
420
|
+
if (setup.diagnostics.some((diagnostic) => diagnostic.type === "error")) {
|
|
421
|
+
process.exit(1);
|
|
422
|
+
}
|
|
423
|
+
time("createSessionFacade.setup");
|
|
424
|
+
const created = await createSessionFacade({
|
|
425
|
+
cwd: target.cwd,
|
|
426
|
+
agentDir: sessionStorageAgentDir,
|
|
427
|
+
authStorage,
|
|
428
|
+
settingsManager,
|
|
429
|
+
modelRegistry,
|
|
430
|
+
resourceLoader,
|
|
431
|
+
model: sessionOptions.model,
|
|
432
|
+
thinkingLevel: sessionOptions.thinkingLevel,
|
|
433
|
+
tools: sessionOptions.tools,
|
|
434
|
+
customTools: sessionOptions.customTools,
|
|
435
|
+
storagePath: parsed.noSession ? ":memory:" : undefined,
|
|
436
|
+
sessionIndexPath: parsed.noSession ? ":memory:" : undefined,
|
|
437
|
+
workspaceId: target.workspaceId,
|
|
438
|
+
sessionId: target.sessionId,
|
|
439
|
+
forkFrom: target.forkFrom
|
|
440
|
+
? {
|
|
441
|
+
...target.forkFrom,
|
|
442
|
+
agentDir: sessionStorageAgentDir,
|
|
443
|
+
}
|
|
444
|
+
: undefined,
|
|
445
|
+
});
|
|
446
|
+
applyCliThinkingClampToFacade(created, parsed.thinking !== undefined || cliThinkingFromModel);
|
|
447
|
+
time("createSessionFacade");
|
|
448
|
+
if (!created.model) {
|
|
449
|
+
console.error(chalk.red("No models available."));
|
|
450
|
+
console.error(chalk.yellow("\nSet an API key environment variable:"));
|
|
451
|
+
console.error(" ANTHROPIC_API_KEY, OPENAI_API_KEY, GEMINI_API_KEY, etc.");
|
|
452
|
+
console.error(chalk.yellow(`\nOr create ${getModelsPath()}`));
|
|
453
|
+
process.exit(1);
|
|
454
|
+
}
|
|
455
|
+
// Read piped stdin for initial message
|
|
456
|
+
const stdinContent = await readPipedStdin();
|
|
457
|
+
time("readPipedStdin");
|
|
458
|
+
const { initialMessage, initialImages } = await prepareInitialMessage(parsed, settingsManager.getImageAutoResize(), stdinContent);
|
|
459
|
+
time("prepareInitialMessage");
|
|
460
|
+
const startupBenchmark = isTruthyEnvFlag(process.env.PIZZA_STARTUP_BENCHMARK);
|
|
461
|
+
const interactiveMode = InteractiveMode.fromFacade(created, {
|
|
462
|
+
modelFallbackMessage: created.modelFallbackMessage,
|
|
463
|
+
initialMessage,
|
|
464
|
+
initialImages,
|
|
465
|
+
initialMessages: parsed.messages,
|
|
466
|
+
verbose: parsed.verbose,
|
|
467
|
+
});
|
|
468
|
+
if (startupBenchmark) {
|
|
469
|
+
await interactiveMode.init();
|
|
470
|
+
time("interactiveMode.init");
|
|
471
|
+
printTimings();
|
|
472
|
+
interactiveMode.stop();
|
|
473
|
+
stopThemeWatcher();
|
|
474
|
+
if (process.stdout.writableLength > 0) {
|
|
475
|
+
await new Promise((resolve) => process.stdout.once("drain", resolve));
|
|
476
|
+
}
|
|
477
|
+
if (process.stderr.writableLength > 0) {
|
|
478
|
+
await new Promise((resolve) => process.stderr.once("drain", resolve));
|
|
479
|
+
}
|
|
480
|
+
return;
|
|
481
|
+
}
|
|
482
|
+
printTimings();
|
|
483
|
+
await interactiveMode.run();
|
|
484
|
+
return;
|
|
485
|
+
}
|
|
486
|
+
if (appMode === "gui") {
|
|
487
|
+
initTheme(settingsManager.getTheme(), false);
|
|
488
|
+
time("initTheme");
|
|
489
|
+
reportDiagnostics(setup.diagnostics);
|
|
490
|
+
if (setup.diagnostics.some((diagnostic) => diagnostic.type === "error")) {
|
|
491
|
+
process.exit(1);
|
|
492
|
+
}
|
|
493
|
+
time("createSessionFacade.setup");
|
|
494
|
+
const created = await createSessionFacade({
|
|
495
|
+
cwd: target.cwd,
|
|
496
|
+
agentDir: sessionStorageAgentDir,
|
|
497
|
+
authStorage,
|
|
498
|
+
settingsManager,
|
|
499
|
+
modelRegistry,
|
|
500
|
+
resourceLoader,
|
|
501
|
+
model: sessionOptions.model,
|
|
502
|
+
thinkingLevel: sessionOptions.thinkingLevel,
|
|
503
|
+
tools: sessionOptions.tools,
|
|
504
|
+
customTools: sessionOptions.customTools,
|
|
505
|
+
storagePath: parsed.noSession ? ":memory:" : undefined,
|
|
506
|
+
sessionIndexPath: parsed.noSession ? ":memory:" : undefined,
|
|
507
|
+
workspaceId: target.workspaceId,
|
|
508
|
+
sessionId: target.sessionId,
|
|
509
|
+
forkFrom: target.forkFrom
|
|
510
|
+
? {
|
|
511
|
+
...target.forkFrom,
|
|
512
|
+
agentDir: sessionStorageAgentDir,
|
|
513
|
+
}
|
|
514
|
+
: undefined,
|
|
515
|
+
});
|
|
516
|
+
applyCliThinkingClampToFacade(created, parsed.thinking !== undefined || cliThinkingFromModel);
|
|
517
|
+
time("createSessionFacade");
|
|
518
|
+
if (!created.model) {
|
|
519
|
+
console.error(chalk.red("No models available."));
|
|
520
|
+
console.error(chalk.yellow("\nSet an API key environment variable:"));
|
|
521
|
+
console.error(" ANTHROPIC_API_KEY, OPENAI_API_KEY, GEMINI_API_KEY, etc.");
|
|
522
|
+
console.error(chalk.yellow(`\nOr create ${getModelsPath()}`));
|
|
523
|
+
process.exit(1);
|
|
524
|
+
}
|
|
525
|
+
const stdinContent = await readPipedStdin();
|
|
526
|
+
time("readPipedStdin");
|
|
527
|
+
const { initialMessage, initialImages } = await prepareInitialMessage(parsed, settingsManager.getImageAutoResize(), stdinContent);
|
|
528
|
+
time("prepareInitialMessage");
|
|
529
|
+
printTimings();
|
|
530
|
+
await runGuiModeWithFacade(created.facade, {
|
|
531
|
+
cwd: target.cwd,
|
|
151
532
|
initialMessage,
|
|
533
|
+
initialImages,
|
|
152
534
|
});
|
|
153
|
-
|
|
535
|
+
return;
|
|
536
|
+
}
|
|
537
|
+
const stdinContent = await readPipedStdin();
|
|
538
|
+
time("readPipedStdin");
|
|
539
|
+
const { initialMessage, initialImages } = await prepareInitialMessage(parsed, settingsManager.getImageAutoResize(), stdinContent);
|
|
540
|
+
time("prepareInitialMessage");
|
|
541
|
+
initTheme(settingsManager.getTheme(), false);
|
|
542
|
+
time("initTheme");
|
|
543
|
+
reportDiagnostics(setup.diagnostics);
|
|
544
|
+
if (setup.diagnostics.some((diagnostic) => diagnostic.type === "error")) {
|
|
545
|
+
process.exit(1);
|
|
546
|
+
}
|
|
547
|
+
time("createSessionFacade.setup");
|
|
548
|
+
const created = await createSessionFacade({
|
|
549
|
+
cwd: target.cwd,
|
|
550
|
+
agentDir: sessionStorageAgentDir,
|
|
551
|
+
authStorage,
|
|
552
|
+
settingsManager,
|
|
553
|
+
modelRegistry,
|
|
554
|
+
resourceLoader,
|
|
555
|
+
model: sessionOptions.model,
|
|
556
|
+
thinkingLevel: sessionOptions.thinkingLevel,
|
|
557
|
+
tools: sessionOptions.tools,
|
|
558
|
+
customTools: sessionOptions.customTools,
|
|
559
|
+
storagePath: parsed.noSession ? ":memory:" : undefined,
|
|
560
|
+
sessionIndexPath: parsed.noSession ? ":memory:" : undefined,
|
|
561
|
+
workspaceId: target.workspaceId,
|
|
562
|
+
sessionId: target.sessionId,
|
|
563
|
+
forkFrom: target.forkFrom
|
|
564
|
+
? {
|
|
565
|
+
...target.forkFrom,
|
|
566
|
+
agentDir: sessionStorageAgentDir,
|
|
567
|
+
}
|
|
568
|
+
: undefined,
|
|
569
|
+
});
|
|
570
|
+
applyCliThinkingClampToFacade(created, parsed.thinking !== undefined || cliThinkingFromModel);
|
|
571
|
+
time("createSessionFacade");
|
|
572
|
+
if (!created.model) {
|
|
573
|
+
console.error(chalk.red("No models available."));
|
|
574
|
+
console.error(chalk.yellow("\nSet an API key environment variable:"));
|
|
575
|
+
console.error(" ANTHROPIC_API_KEY, OPENAI_API_KEY, GEMINI_API_KEY, etc.");
|
|
576
|
+
console.error(chalk.yellow(`\nOr create ${getModelsPath()}`));
|
|
577
|
+
process.exit(1);
|
|
578
|
+
}
|
|
579
|
+
const startupBenchmark = isTruthyEnvFlag(process.env.PIZZA_STARTUP_BENCHMARK);
|
|
580
|
+
if (startupBenchmark) {
|
|
581
|
+
console.error(chalk.red("Error: PIZZA_STARTUP_BENCHMARK only supports interactive mode"));
|
|
582
|
+
process.exit(1);
|
|
154
583
|
}
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
584
|
+
printTimings();
|
|
585
|
+
const exitCode = await runPrintModeWithFacade(created.facade, {
|
|
586
|
+
mode: toPrintOutputMode(appMode),
|
|
587
|
+
messages: parsed.messages,
|
|
588
|
+
initialMessage,
|
|
589
|
+
initialImages,
|
|
158
590
|
});
|
|
159
|
-
|
|
160
|
-
|
|
591
|
+
stopThemeWatcher();
|
|
592
|
+
restoreStdout();
|
|
593
|
+
if (exitCode !== 0) {
|
|
594
|
+
process.exitCode = exitCode;
|
|
161
595
|
}
|
|
162
|
-
await interactive.run();
|
|
163
596
|
}
|
|
164
|
-
main().catch((err) => {
|
|
165
|
-
console.error("Fatal:", err);
|
|
166
|
-
process.exit(1);
|
|
167
|
-
});
|
|
168
|
-
//# sourceMappingURL=main.js.map
|