@pencil-agent/nano-pencil 1.4.0 → 1.4.2
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/dist/cli/args.d.ts +48 -0
- package/{cli/args.ts → dist/cli/args.js} +165 -182
- package/dist/cli/config-selector.d.ts +14 -0
- package/dist/cli/config-selector.js +31 -0
- package/dist/cli/file-processor.d.ts +15 -0
- package/dist/cli/file-processor.js +79 -0
- package/dist/cli/list-models.d.ts +9 -0
- package/dist/cli/list-models.js +92 -0
- package/dist/cli/session-picker.d.ts +9 -0
- package/dist/cli/session-picker.js +34 -0
- package/dist/cli.d.ts +3 -0
- package/{cli.ts → dist/cli.js} +1 -2
- package/dist/config.d.ts +73 -0
- package/dist/config.js +216 -0
- package/dist/core/agent-session.d.ts +606 -0
- package/dist/core/agent-session.js +2493 -0
- package/dist/core/auth-storage.d.ts +133 -0
- package/dist/core/auth-storage.js +394 -0
- package/dist/core/bash-executor.d.ts +47 -0
- package/dist/core/bash-executor.js +212 -0
- package/dist/core/compaction/branch-summarization.d.ts +86 -0
- package/dist/core/compaction/branch-summarization.js +242 -0
- package/dist/core/compaction/compaction.d.ts +121 -0
- package/dist/core/compaction/compaction.js +607 -0
- package/dist/core/compaction/index.d.ts +7 -0
- package/{core/compaction/index.ts → dist/core/compaction/index.js} +7 -7
- package/dist/core/compaction/utils.d.ts +35 -0
- package/dist/core/compaction/utils.js +138 -0
- package/dist/core/defaults.d.ts +3 -0
- package/dist/core/defaults.js +2 -0
- package/dist/core/diagnostics.d.ts +15 -0
- package/dist/core/diagnostics.js +2 -0
- package/dist/core/event-bus.d.ts +9 -0
- package/dist/core/event-bus.js +25 -0
- package/dist/core/exec.d.ts +29 -0
- package/dist/core/exec.js +71 -0
- package/dist/core/export-html/ansi-to-html.d.ts +22 -0
- package/dist/core/export-html/ansi-to-html.js +249 -0
- package/dist/core/export-html/index.d.ts +34 -0
- package/dist/core/export-html/index.js +222 -0
- package/dist/core/export-html/tool-renderer.d.ts +35 -0
- package/dist/core/export-html/tool-renderer.js +57 -0
- package/dist/core/extensions/index.d.ts +11 -0
- package/dist/core/extensions/index.js +9 -0
- package/dist/core/extensions/loader.d.ts +25 -0
- package/dist/core/extensions/loader.js +402 -0
- package/dist/core/extensions/runner.d.ts +147 -0
- package/dist/core/extensions/runner.js +645 -0
- package/dist/core/extensions/types.d.ts +988 -0
- package/dist/core/extensions/types.js +35 -0
- package/dist/core/extensions/wrapper.d.ts +27 -0
- package/dist/core/extensions/wrapper.js +102 -0
- package/dist/core/footer-data-provider.d.ts +32 -0
- package/dist/core/footer-data-provider.js +134 -0
- package/dist/core/index.d.ts +12 -0
- package/dist/core/index.js +12 -0
- package/dist/core/keybindings.d.ts +55 -0
- package/dist/core/keybindings.js +157 -0
- package/dist/core/mcp/index.d.ts +11 -0
- package/dist/core/mcp/index.js +9 -0
- package/dist/core/mcp/mcp-adapter.d.ts +20 -0
- package/dist/core/mcp/mcp-adapter.js +111 -0
- package/dist/core/mcp/mcp-client.d.ts +109 -0
- package/dist/core/mcp/mcp-client.js +215 -0
- package/dist/core/mcp/mcp-config.d.ts +50 -0
- package/dist/core/mcp/mcp-config.js +187 -0
- package/dist/core/mcp/mcp-guidance.d.ts +52 -0
- package/dist/core/mcp/mcp-guidance.js +154 -0
- package/dist/core/mcp-manager.d.ts +29 -0
- package/dist/core/mcp-manager.js +50 -0
- package/dist/core/messages.d.ts +77 -0
- package/dist/core/messages.js +123 -0
- package/dist/core/model-registry.d.ts +110 -0
- package/dist/core/model-registry.js +520 -0
- package/dist/core/model-resolver.d.ts +104 -0
- package/dist/core/model-resolver.js +432 -0
- package/dist/core/package-manager.d.ts +156 -0
- package/dist/core/package-manager.js +1447 -0
- package/dist/core/prompt-templates.d.ts +50 -0
- package/dist/core/prompt-templates.js +251 -0
- package/dist/core/resolve-config-value.d.ts +17 -0
- package/dist/core/resolve-config-value.js +59 -0
- package/dist/core/resource-loader.d.ts +184 -0
- package/dist/core/resource-loader.js +694 -0
- package/dist/core/sdk.d.ts +96 -0
- package/dist/core/sdk.js +284 -0
- package/dist/core/session-manager.d.ts +323 -0
- package/dist/core/session-manager.js +1091 -0
- package/dist/core/settings-manager.d.ts +225 -0
- package/dist/core/settings-manager.js +656 -0
- package/dist/core/skills.d.ts +58 -0
- package/dist/core/skills.js +364 -0
- package/dist/core/slash-commands.d.ts +15 -0
- package/dist/core/slash-commands.js +36 -0
- package/dist/core/soul-integration.d.ts +52 -0
- package/dist/core/soul-integration.js +71 -0
- package/dist/core/system-prompt.d.ts +26 -0
- package/dist/core/system-prompt.js +144 -0
- package/dist/core/timings.d.ts +7 -0
- package/dist/core/timings.js +25 -0
- package/dist/core/tools/bash.d.ts +55 -0
- package/dist/core/tools/bash.js +242 -0
- package/dist/core/tools/edit-diff.d.ts +63 -0
- package/dist/core/tools/edit-diff.js +243 -0
- package/dist/core/tools/edit.d.ts +39 -0
- package/dist/core/tools/edit.js +146 -0
- package/dist/core/tools/find.d.ts +39 -0
- package/dist/core/tools/find.js +206 -0
- package/dist/core/tools/grep.d.ts +45 -0
- package/dist/core/tools/grep.js +239 -0
- package/dist/core/tools/index.d.ts +73 -0
- package/dist/core/tools/index.js +61 -0
- package/dist/core/tools/ls.d.ts +40 -0
- package/dist/core/tools/ls.js +118 -0
- package/dist/core/tools/path-utils.d.ts +8 -0
- package/dist/core/tools/path-utils.js +81 -0
- package/dist/core/tools/read.d.ts +39 -0
- package/dist/core/tools/read.js +166 -0
- package/dist/core/tools/truncate.d.ts +70 -0
- package/dist/core/tools/truncate.js +205 -0
- package/dist/core/tools/write.d.ts +29 -0
- package/dist/core/tools/write.js +78 -0
- package/dist/extensions/simplify/index.d.ts +14 -0
- package/dist/extensions/simplify/index.js +437 -0
- package/dist/index.d.ts +27 -0
- package/dist/index.js +42 -0
- package/dist/main.d.ts +8 -0
- package/dist/main.js +692 -0
- package/dist/migrations.d.ts +33 -0
- package/dist/migrations.js +261 -0
- package/{modes/index.ts → dist/modes/index.d.ts} +9 -9
- package/dist/modes/index.js +8 -0
- package/dist/modes/interactive/components/apikey-input.d.ts +13 -0
- package/dist/modes/interactive/components/apikey-input.js +33 -0
- package/dist/modes/interactive/components/armin.d.ts +34 -0
- package/dist/modes/interactive/components/armin.js +333 -0
- package/dist/modes/interactive/components/assistant-message.d.ts +16 -0
- package/dist/modes/interactive/components/assistant-message.js +96 -0
- package/dist/modes/interactive/components/bash-execution.d.ts +35 -0
- package/dist/modes/interactive/components/bash-execution.js +162 -0
- package/dist/modes/interactive/components/bordered-loader.d.ts +16 -0
- package/dist/modes/interactive/components/bordered-loader.js +51 -0
- package/dist/modes/interactive/components/branch-summary-message.d.ts +16 -0
- package/dist/modes/interactive/components/branch-summary-message.js +44 -0
- package/dist/modes/interactive/components/compaction-summary-message.d.ts +16 -0
- package/dist/modes/interactive/components/compaction-summary-message.js +45 -0
- package/dist/modes/interactive/components/config-selector.d.ts +71 -0
- package/dist/modes/interactive/components/config-selector.js +479 -0
- package/dist/modes/interactive/components/countdown-timer.d.ts +14 -0
- package/dist/modes/interactive/components/countdown-timer.js +33 -0
- package/dist/modes/interactive/components/custom-editor.d.ts +21 -0
- package/dist/modes/interactive/components/custom-editor.js +70 -0
- package/dist/modes/interactive/components/custom-message.d.ts +20 -0
- package/dist/modes/interactive/components/custom-message.js +79 -0
- package/dist/modes/interactive/components/daxnuts.d.ts +23 -0
- package/dist/modes/interactive/components/daxnuts.js +140 -0
- package/dist/modes/interactive/components/diff.d.ts +12 -0
- package/dist/modes/interactive/components/diff.js +133 -0
- package/dist/modes/interactive/components/dynamic-border.d.ts +15 -0
- package/dist/modes/interactive/components/dynamic-border.js +21 -0
- package/dist/modes/interactive/components/extension-editor.d.ts +17 -0
- package/dist/modes/interactive/components/extension-editor.js +102 -0
- package/dist/modes/interactive/components/extension-input.d.ts +23 -0
- package/dist/modes/interactive/components/extension-input.js +61 -0
- package/dist/modes/interactive/components/extension-selector.d.ts +24 -0
- package/dist/modes/interactive/components/extension-selector.js +78 -0
- package/dist/modes/interactive/components/footer.d.ts +26 -0
- package/dist/modes/interactive/components/footer.js +213 -0
- package/{modes/interactive/components/index.ts → dist/modes/interactive/components/index.d.ts} +6 -26
- package/dist/modes/interactive/components/index.js +36 -0
- package/dist/modes/interactive/components/keybinding-hints.d.ts +41 -0
- package/{modes/interactive/components/keybinding-hints.ts → dist/modes/interactive/components/keybinding-hints.js} +61 -66
- package/dist/modes/interactive/components/login-dialog.d.ts +42 -0
- package/dist/modes/interactive/components/login-dialog.js +145 -0
- package/dist/modes/interactive/components/memory-stats.d.ts +14 -0
- package/dist/modes/interactive/components/memory-stats.js +96 -0
- package/dist/modes/interactive/components/model-selector.d.ts +49 -0
- package/dist/modes/interactive/components/model-selector.js +284 -0
- package/dist/modes/interactive/components/oauth-selector.d.ts +19 -0
- package/dist/modes/interactive/components/oauth-selector.js +97 -0
- package/dist/modes/interactive/components/pencil-loader.d.ts +23 -0
- package/dist/modes/interactive/components/pencil-loader.js +70 -0
- package/dist/modes/interactive/components/provider-selector.d.ts +10 -0
- package/dist/modes/interactive/components/provider-selector.js +31 -0
- package/dist/modes/interactive/components/scoped-models-selector.d.ts +49 -0
- package/dist/modes/interactive/components/scoped-models-selector.js +275 -0
- package/dist/modes/interactive/components/session-selector-search.d.ts +23 -0
- package/dist/modes/interactive/components/session-selector-search.js +155 -0
- package/dist/modes/interactive/components/session-selector.d.ts +95 -0
- package/dist/modes/interactive/components/session-selector.js +851 -0
- package/dist/modes/interactive/components/settings-selector.d.ts +56 -0
- package/dist/modes/interactive/components/settings-selector.js +287 -0
- package/dist/modes/interactive/components/show-images-selector.d.ts +10 -0
- package/dist/modes/interactive/components/show-images-selector.js +35 -0
- package/dist/modes/interactive/components/skill-invocation-message.d.ts +17 -0
- package/dist/modes/interactive/components/skill-invocation-message.js +47 -0
- package/dist/modes/interactive/components/soul-stats.d.ts +15 -0
- package/dist/modes/interactive/components/soul-stats.js +156 -0
- package/dist/modes/interactive/components/theme-selector.d.ts +11 -0
- package/dist/modes/interactive/components/theme-selector.js +46 -0
- package/dist/modes/interactive/components/thinking-selector.d.ts +11 -0
- package/dist/modes/interactive/components/thinking-selector.js +47 -0
- package/dist/modes/interactive/components/tool-execution.d.ts +75 -0
- package/dist/modes/interactive/components/tool-execution.js +752 -0
- package/dist/modes/interactive/components/tree-selector.d.ts +68 -0
- package/dist/modes/interactive/components/tree-selector.js +934 -0
- package/dist/modes/interactive/components/user-message-selector.d.ts +30 -0
- package/dist/modes/interactive/components/user-message-selector.js +113 -0
- package/dist/modes/interactive/components/user-message.d.ts +8 -0
- package/dist/modes/interactive/components/user-message.js +16 -0
- package/dist/modes/interactive/components/visual-truncate.d.ts +24 -0
- package/dist/modes/interactive/components/visual-truncate.js +33 -0
- package/dist/modes/interactive/interactive-mode.d.ts +332 -0
- package/dist/modes/interactive/interactive-mode.js +4019 -0
- package/dist/modes/interactive/theme/theme.d.ts +78 -0
- package/dist/modes/interactive/theme/theme.js +951 -0
- package/dist/modes/print-mode.d.ts +28 -0
- package/dist/modes/print-mode.js +101 -0
- package/dist/modes/rpc/rpc-client.d.ts +217 -0
- package/dist/modes/rpc/rpc-client.js +405 -0
- package/dist/modes/rpc/rpc-mode.d.ts +20 -0
- package/dist/modes/rpc/rpc-mode.js +511 -0
- package/dist/modes/rpc/rpc-types.d.ts +409 -0
- package/dist/modes/rpc/rpc-types.js +8 -0
- package/dist/nanopencil-defaults.d.ts +105 -0
- package/dist/nanopencil-defaults.js +297 -0
- package/dist/pencil-mem-integration.d.ts +9 -0
- package/dist/pencil-mem-integration.js +70 -0
- package/dist/utils/changelog.d.ts +21 -0
- package/dist/utils/changelog.js +87 -0
- package/dist/utils/clipboard-image.d.ts +11 -0
- package/dist/utils/clipboard-image.js +162 -0
- package/dist/utils/clipboard-native.d.ts +7 -0
- package/dist/utils/clipboard-native.js +14 -0
- package/dist/utils/clipboard.d.ts +2 -0
- package/dist/utils/clipboard.js +67 -0
- package/dist/utils/frontmatter.d.ts +8 -0
- package/dist/utils/frontmatter.js +26 -0
- package/dist/utils/git.d.ts +26 -0
- package/dist/utils/git.js +163 -0
- package/dist/utils/image-convert.d.ts +9 -0
- package/dist/utils/image-convert.js +35 -0
- package/dist/utils/image-resize.d.ts +36 -0
- package/dist/utils/image-resize.js +181 -0
- package/dist/utils/mime.d.ts +2 -0
- package/dist/utils/mime.js +26 -0
- package/dist/utils/photon.d.ts +21 -0
- package/dist/utils/photon.js +121 -0
- package/dist/utils/shell.d.ts +26 -0
- package/dist/utils/shell.js +186 -0
- package/dist/utils/sleep.d.ts +5 -0
- package/dist/utils/sleep.js +17 -0
- package/dist/utils/tools-manager.d.ts +17 -0
- package/dist/utils/tools-manager.js +299 -0
- package/docs/APIKEY_COMMAND.md +64 -0
- package/docs/APIKEY_FIX_SUMMARY.md +147 -0
- package/docs/API_KEY_GUIDANCE.md +292 -0
- package/docs/BUILTIN_MCP_TOOLS.md +326 -0
- package/docs/CHANGELOG.md +41 -0
- package/docs/CHANGES_SUMMARY.md +138 -0
- package/docs/MCP_GUIDE.md +255 -0
- package/docs/MCP_QUICK_REFERENCE.md +113 -0
- package/docs/MEMORY_SYSTEM.md +236 -0
- package/docs/MIGRATION_SUMMARY.md +204 -0
- package/docs/MONOREPO_MIGRATION.md +232 -0
- package/docs/README.md +130 -0
- package/docs/README.monorepo.md +189 -0
- package/docs/RELEASE_GUIDE.md +129 -0
- package/docs/STRUCTURE.md +339 -0
- package/docs/TOOLS_MANAGER_OPTIMIZATION.md +208 -0
- package/package.json +9 -11
- package/cli/config-selector.ts +0 -52
- package/cli/file-processor.ts +0 -96
- package/cli/list-models.ts +0 -104
- package/cli/session-picker.ts +0 -51
- package/config.ts +0 -255
- package/core/agent-session.ts +0 -3238
- package/core/auth-storage.ts +0 -464
- package/core/bash-executor.ts +0 -278
- package/core/compaction/branch-summarization.ts +0 -352
- package/core/compaction/compaction.ts +0 -809
- package/core/compaction/utils.ts +0 -154
- package/core/defaults.ts +0 -3
- package/core/diagnostics.ts +0 -15
- package/core/event-bus.ts +0 -33
- package/core/exec.ts +0 -104
- package/core/export-html/ansi-to-html.ts +0 -258
- package/core/export-html/index.ts +0 -304
- package/core/export-html/template.css +0 -971
- package/core/export-html/template.html +0 -54
- package/core/export-html/template.js +0 -1586
- package/core/export-html/tool-renderer.ts +0 -90
- package/core/export-html/vendor/highlight.min.js +0 -1213
- package/core/export-html/vendor/marked.min.js +0 -6
- package/core/extensions/index.ts +0 -166
- package/core/extensions/loader.ts +0 -518
- package/core/extensions/runner.ts +0 -848
- package/core/extensions/types.ts +0 -1345
- package/core/extensions/wrapper.ts +0 -118
- package/core/footer-data-provider.ts +0 -144
- package/core/index.ts +0 -87
- package/core/keybindings.ts +0 -217
- package/core/mcp/index.ts +0 -23
- package/core/mcp/mcp-adapter.ts +0 -134
- package/core/mcp/mcp-client.ts +0 -296
- package/core/mcp/mcp-config.ts +0 -217
- package/core/mcp/mcp-guidance.ts +0 -188
- package/core/mcp-manager.ts +0 -61
- package/core/messages.ts +0 -195
- package/core/model-registry.ts +0 -681
- package/core/model-resolver.ts +0 -561
- package/core/package-manager.ts +0 -1792
- package/core/prompt-templates.ts +0 -299
- package/core/resolve-config-value.ts +0 -64
- package/core/resource-loader.ts +0 -891
- package/core/sdk.ts +0 -442
- package/core/session-manager.ts +0 -1401
- package/core/settings-manager.ts +0 -898
- package/core/skills.ts +0 -459
- package/core/slash-commands.ts +0 -51
- package/core/soul-integration.ts +0 -83
- package/core/system-prompt.ts +0 -209
- package/core/timings.ts +0 -25
- package/core/tools/bash.ts +0 -321
- package/core/tools/edit-diff.ts +0 -308
- package/core/tools/edit.ts +0 -227
- package/core/tools/find.ts +0 -273
- package/core/tools/grep.ts +0 -346
- package/core/tools/index.ts +0 -139
- package/core/tools/ls.ts +0 -170
- package/core/tools/path-utils.ts +0 -94
- package/core/tools/read.ts +0 -222
- package/core/tools/truncate.ts +0 -265
- package/core/tools/write.ts +0 -118
- package/extensions/simplify/index.ts +0 -535
- package/index.ts +0 -331
- package/main.ts +0 -822
- package/migrations.ts +0 -295
- package/modes/interactive/components/apikey-input.ts +0 -43
- package/modes/interactive/components/armin.ts +0 -382
- package/modes/interactive/components/assistant-message.ts +0 -115
- package/modes/interactive/components/bash-execution.ts +0 -210
- package/modes/interactive/components/bordered-loader.ts +0 -66
- package/modes/interactive/components/branch-summary-message.ts +0 -58
- package/modes/interactive/components/compaction-summary-message.ts +0 -59
- package/modes/interactive/components/config-selector.ts +0 -592
- package/modes/interactive/components/countdown-timer.ts +0 -38
- package/modes/interactive/components/custom-editor.ts +0 -80
- package/modes/interactive/components/custom-message.ts +0 -99
- package/modes/interactive/components/daxnuts.ts +0 -164
- package/modes/interactive/components/diff.ts +0 -147
- package/modes/interactive/components/dynamic-border.ts +0 -25
- package/modes/interactive/components/extension-editor.ts +0 -136
- package/modes/interactive/components/extension-input.ts +0 -85
- package/modes/interactive/components/extension-selector.ts +0 -107
- package/modes/interactive/components/footer.ts +0 -231
- package/modes/interactive/components/login-dialog.ts +0 -174
- package/modes/interactive/components/memory-stats.ts +0 -139
- package/modes/interactive/components/model-selector.ts +0 -342
- package/modes/interactive/components/oauth-selector.ts +0 -120
- package/modes/interactive/components/pencil-loader.ts +0 -85
- package/modes/interactive/components/provider-selector.ts +0 -42
- package/modes/interactive/components/scoped-models-selector.ts +0 -346
- package/modes/interactive/components/session-selector-search.ts +0 -194
- package/modes/interactive/components/session-selector.ts +0 -1019
- package/modes/interactive/components/settings-selector.ts +0 -407
- package/modes/interactive/components/show-images-selector.ts +0 -45
- package/modes/interactive/components/skill-invocation-message.ts +0 -55
- package/modes/interactive/components/soul-stats.ts +0 -193
- package/modes/interactive/components/theme-selector.ts +0 -62
- package/modes/interactive/components/thinking-selector.ts +0 -64
- package/modes/interactive/components/tool-execution.ts +0 -878
- package/modes/interactive/components/tree-selector.ts +0 -1079
- package/modes/interactive/components/user-message-selector.ts +0 -143
- package/modes/interactive/components/user-message.ts +0 -18
- package/modes/interactive/components/visual-truncate.ts +0 -50
- package/modes/interactive/interactive-mode.ts +0 -5149
- package/modes/interactive/theme/dark.json +0 -85
- package/modes/interactive/theme/light.json +0 -84
- package/modes/interactive/theme/theme-schema.json +0 -335
- package/modes/interactive/theme/theme.ts +0 -1109
- package/modes/interactive/theme/warm.json +0 -81
- package/modes/print-mode.ts +0 -124
- package/modes/rpc/rpc-client.ts +0 -510
- package/modes/rpc/rpc-mode.ts +0 -639
- package/modes/rpc/rpc-types.ts +0 -263
- package/nanopencil-defaults.ts +0 -319
- package/pencil-mem-integration.ts +0 -70
- package/utils/changelog.ts +0 -99
- package/utils/clipboard-image.ts +0 -207
- package/utils/clipboard-native.ts +0 -21
- package/utils/clipboard.ts +0 -62
- package/utils/frontmatter.ts +0 -39
- package/utils/git.ts +0 -192
- package/utils/image-convert.ts +0 -38
- package/utils/image-resize.ts +0 -231
- package/utils/mime.ts +0 -30
- package/utils/photon.ts +0 -139
- package/utils/shell.ts +0 -202
- package/utils/sleep.ts +0 -18
- package/utils/tools-manager.ts +0 -394
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* CLI argument parsing and help display
|
|
3
|
+
*/
|
|
4
|
+
import type { ThinkingLevel } from "@mariozechner/pi-agent-core";
|
|
5
|
+
import { type ToolName } from "../core/tools/index.js";
|
|
6
|
+
export type Mode = "text" | "json" | "rpc";
|
|
7
|
+
export interface Args {
|
|
8
|
+
provider?: string;
|
|
9
|
+
model?: string;
|
|
10
|
+
apiKey?: string;
|
|
11
|
+
systemPrompt?: string;
|
|
12
|
+
appendSystemPrompt?: string;
|
|
13
|
+
thinking?: ThinkingLevel;
|
|
14
|
+
continue?: boolean;
|
|
15
|
+
resume?: boolean;
|
|
16
|
+
help?: boolean;
|
|
17
|
+
version?: boolean;
|
|
18
|
+
mode?: Mode;
|
|
19
|
+
noSession?: boolean;
|
|
20
|
+
session?: string;
|
|
21
|
+
sessionDir?: string;
|
|
22
|
+
models?: string[];
|
|
23
|
+
tools?: ToolName[];
|
|
24
|
+
noTools?: boolean;
|
|
25
|
+
extensions?: string[];
|
|
26
|
+
noExtensions?: boolean;
|
|
27
|
+
print?: boolean;
|
|
28
|
+
export?: string;
|
|
29
|
+
noSkills?: boolean;
|
|
30
|
+
skills?: string[];
|
|
31
|
+
promptTemplates?: string[];
|
|
32
|
+
noPromptTemplates?: boolean;
|
|
33
|
+
themes?: string[];
|
|
34
|
+
noThemes?: boolean;
|
|
35
|
+
listModels?: string | true;
|
|
36
|
+
offline?: boolean;
|
|
37
|
+
verbose?: boolean;
|
|
38
|
+
messages: string[];
|
|
39
|
+
fileArgs: string[];
|
|
40
|
+
/** Unknown flags (potentially extension flags) - map of flag name to value */
|
|
41
|
+
unknownFlags: Map<string, boolean | string>;
|
|
42
|
+
}
|
|
43
|
+
export declare function isValidThinkingLevel(level: string): level is ThinkingLevel;
|
|
44
|
+
export declare function parseArgs(args: string[], extensionFlags?: Map<string, {
|
|
45
|
+
type: "boolean" | "string";
|
|
46
|
+
}>): Args;
|
|
47
|
+
export declare function printHelp(): void;
|
|
48
|
+
//# sourceMappingURL=args.d.ts.map
|
|
@@ -1,183 +1,165 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* CLI argument parsing and help display
|
|
3
|
-
*/
|
|
4
|
-
|
|
5
|
-
import
|
|
6
|
-
import
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
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
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
if (extFlag) {
|
|
164
|
-
if (extFlag.type === "boolean") {
|
|
165
|
-
result.unknownFlags.set(flagName, true);
|
|
166
|
-
} else if (extFlag.type === "string" && i + 1 < args.length) {
|
|
167
|
-
result.unknownFlags.set(flagName, args[++i]);
|
|
168
|
-
}
|
|
169
|
-
}
|
|
170
|
-
// Unknown flags without extensionFlags are silently ignored (first pass)
|
|
171
|
-
} else if (!arg.startsWith("-")) {
|
|
172
|
-
result.messages.push(arg);
|
|
173
|
-
}
|
|
174
|
-
}
|
|
175
|
-
|
|
176
|
-
return result;
|
|
177
|
-
}
|
|
178
|
-
|
|
179
|
-
export function printHelp(): void {
|
|
180
|
-
console.log(`${chalk.bold(APP_NAME)} - AI coding assistant with read, bash, edit, write tools
|
|
1
|
+
/**
|
|
2
|
+
* CLI argument parsing and help display
|
|
3
|
+
*/
|
|
4
|
+
import chalk from "chalk";
|
|
5
|
+
import { APP_NAME, CONFIG_DIR_NAME, ENV_AGENT_DIR } from "../config.js";
|
|
6
|
+
import { allTools } from "../core/tools/index.js";
|
|
7
|
+
const VALID_THINKING_LEVELS = ["off", "minimal", "low", "medium", "high", "xhigh"];
|
|
8
|
+
export function isValidThinkingLevel(level) {
|
|
9
|
+
return VALID_THINKING_LEVELS.includes(level);
|
|
10
|
+
}
|
|
11
|
+
export function parseArgs(args, extensionFlags) {
|
|
12
|
+
const result = {
|
|
13
|
+
messages: [],
|
|
14
|
+
fileArgs: [],
|
|
15
|
+
unknownFlags: new Map(),
|
|
16
|
+
};
|
|
17
|
+
for (let i = 0; i < args.length; i++) {
|
|
18
|
+
const arg = args[i];
|
|
19
|
+
if (arg === "--help" || arg === "-h") {
|
|
20
|
+
result.help = true;
|
|
21
|
+
}
|
|
22
|
+
else if (arg === "--version" || arg === "-v") {
|
|
23
|
+
result.version = true;
|
|
24
|
+
}
|
|
25
|
+
else if (arg === "--mode" && i + 1 < args.length) {
|
|
26
|
+
const mode = args[++i];
|
|
27
|
+
if (mode === "text" || mode === "json" || mode === "rpc") {
|
|
28
|
+
result.mode = mode;
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
else if (arg === "--continue" || arg === "-c") {
|
|
32
|
+
result.continue = true;
|
|
33
|
+
}
|
|
34
|
+
else if (arg === "--resume" || arg === "-r") {
|
|
35
|
+
result.resume = true;
|
|
36
|
+
}
|
|
37
|
+
else if (arg === "--provider" && i + 1 < args.length) {
|
|
38
|
+
result.provider = args[++i];
|
|
39
|
+
}
|
|
40
|
+
else if (arg === "--model" && i + 1 < args.length) {
|
|
41
|
+
result.model = args[++i];
|
|
42
|
+
}
|
|
43
|
+
else if (arg === "--api-key" && i + 1 < args.length) {
|
|
44
|
+
result.apiKey = args[++i];
|
|
45
|
+
}
|
|
46
|
+
else if (arg === "--system-prompt" && i + 1 < args.length) {
|
|
47
|
+
result.systemPrompt = args[++i];
|
|
48
|
+
}
|
|
49
|
+
else if (arg === "--append-system-prompt" && i + 1 < args.length) {
|
|
50
|
+
result.appendSystemPrompt = args[++i];
|
|
51
|
+
}
|
|
52
|
+
else if (arg === "--no-session") {
|
|
53
|
+
result.noSession = true;
|
|
54
|
+
}
|
|
55
|
+
else if (arg === "--session" && i + 1 < args.length) {
|
|
56
|
+
result.session = args[++i];
|
|
57
|
+
}
|
|
58
|
+
else if (arg === "--session-dir" && i + 1 < args.length) {
|
|
59
|
+
result.sessionDir = args[++i];
|
|
60
|
+
}
|
|
61
|
+
else if (arg === "--models" && i + 1 < args.length) {
|
|
62
|
+
result.models = args[++i].split(",").map((s) => s.trim());
|
|
63
|
+
}
|
|
64
|
+
else if (arg === "--no-tools") {
|
|
65
|
+
result.noTools = true;
|
|
66
|
+
}
|
|
67
|
+
else if (arg === "--tools" && i + 1 < args.length) {
|
|
68
|
+
const toolNames = args[++i].split(",").map((s) => s.trim());
|
|
69
|
+
const validTools = [];
|
|
70
|
+
for (const name of toolNames) {
|
|
71
|
+
if (name in allTools) {
|
|
72
|
+
validTools.push(name);
|
|
73
|
+
}
|
|
74
|
+
else {
|
|
75
|
+
console.error(chalk.yellow(`Warning: Unknown tool "${name}". Valid tools: ${Object.keys(allTools).join(", ")}`));
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
result.tools = validTools;
|
|
79
|
+
}
|
|
80
|
+
else if (arg === "--thinking" && i + 1 < args.length) {
|
|
81
|
+
const level = args[++i];
|
|
82
|
+
if (isValidThinkingLevel(level)) {
|
|
83
|
+
result.thinking = level;
|
|
84
|
+
}
|
|
85
|
+
else {
|
|
86
|
+
console.error(chalk.yellow(`Warning: Invalid thinking level "${level}". Valid values: ${VALID_THINKING_LEVELS.join(", ")}`));
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
else if (arg === "--print" || arg === "-p") {
|
|
90
|
+
result.print = true;
|
|
91
|
+
}
|
|
92
|
+
else if (arg === "--export" && i + 1 < args.length) {
|
|
93
|
+
result.export = args[++i];
|
|
94
|
+
}
|
|
95
|
+
else if ((arg === "--extension" || arg === "-e") && i + 1 < args.length) {
|
|
96
|
+
result.extensions = result.extensions ?? [];
|
|
97
|
+
result.extensions.push(args[++i]);
|
|
98
|
+
}
|
|
99
|
+
else if (arg === "--no-extensions" || arg === "-ne") {
|
|
100
|
+
result.noExtensions = true;
|
|
101
|
+
}
|
|
102
|
+
else if (arg === "--skill" && i + 1 < args.length) {
|
|
103
|
+
result.skills = result.skills ?? [];
|
|
104
|
+
result.skills.push(args[++i]);
|
|
105
|
+
}
|
|
106
|
+
else if (arg === "--prompt-template" && i + 1 < args.length) {
|
|
107
|
+
result.promptTemplates = result.promptTemplates ?? [];
|
|
108
|
+
result.promptTemplates.push(args[++i]);
|
|
109
|
+
}
|
|
110
|
+
else if (arg === "--theme" && i + 1 < args.length) {
|
|
111
|
+
result.themes = result.themes ?? [];
|
|
112
|
+
result.themes.push(args[++i]);
|
|
113
|
+
}
|
|
114
|
+
else if (arg === "--no-skills" || arg === "-ns") {
|
|
115
|
+
result.noSkills = true;
|
|
116
|
+
}
|
|
117
|
+
else if (arg === "--no-prompt-templates" || arg === "-np") {
|
|
118
|
+
result.noPromptTemplates = true;
|
|
119
|
+
}
|
|
120
|
+
else if (arg === "--no-themes") {
|
|
121
|
+
result.noThemes = true;
|
|
122
|
+
}
|
|
123
|
+
else if (arg === "--list-models") {
|
|
124
|
+
// Check if next arg is a search pattern (not a flag or file arg)
|
|
125
|
+
if (i + 1 < args.length && !args[i + 1].startsWith("-") && !args[i + 1].startsWith("@")) {
|
|
126
|
+
result.listModels = args[++i];
|
|
127
|
+
}
|
|
128
|
+
else {
|
|
129
|
+
result.listModels = true;
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
else if (arg === "--verbose") {
|
|
133
|
+
result.verbose = true;
|
|
134
|
+
}
|
|
135
|
+
else if (arg === "--offline") {
|
|
136
|
+
result.offline = true;
|
|
137
|
+
}
|
|
138
|
+
else if (arg.startsWith("@")) {
|
|
139
|
+
result.fileArgs.push(arg.slice(1)); // Remove @ prefix
|
|
140
|
+
}
|
|
141
|
+
else if (arg.startsWith("--") && extensionFlags) {
|
|
142
|
+
// Check if it's an extension-registered flag
|
|
143
|
+
const flagName = arg.slice(2);
|
|
144
|
+
const extFlag = extensionFlags.get(flagName);
|
|
145
|
+
if (extFlag) {
|
|
146
|
+
if (extFlag.type === "boolean") {
|
|
147
|
+
result.unknownFlags.set(flagName, true);
|
|
148
|
+
}
|
|
149
|
+
else if (extFlag.type === "string" && i + 1 < args.length) {
|
|
150
|
+
result.unknownFlags.set(flagName, args[++i]);
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
// Unknown flags without extensionFlags are silently ignored (first pass)
|
|
154
|
+
}
|
|
155
|
+
else if (!arg.startsWith("-")) {
|
|
156
|
+
result.messages.push(arg);
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
return result;
|
|
160
|
+
}
|
|
161
|
+
export function printHelp() {
|
|
162
|
+
console.log(`${chalk.bold(APP_NAME)} - AI coding assistant with read, bash, edit, write tools
|
|
181
163
|
|
|
182
164
|
${chalk.bold("Usage:")}
|
|
183
165
|
${APP_NAME} [options] [@files...] [messages...]
|
|
@@ -312,5 +294,6 @@ ${chalk.bold("Available Tools (default: read, bash, edit, write):")}
|
|
|
312
294
|
grep - Search file contents (read-only, off by default)
|
|
313
295
|
find - Find files by glob pattern (read-only, off by default)
|
|
314
296
|
ls - List directory contents (read-only, off by default)
|
|
315
|
-
`);
|
|
316
|
-
}
|
|
297
|
+
`);
|
|
298
|
+
}
|
|
299
|
+
//# sourceMappingURL=args.js.map
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* TUI config selector for `pi config` command
|
|
3
|
+
*/
|
|
4
|
+
import type { ResolvedPaths } from "../core/package-manager.js";
|
|
5
|
+
import type { SettingsManager } from "../core/settings-manager.js";
|
|
6
|
+
export interface ConfigSelectorOptions {
|
|
7
|
+
resolvedPaths: ResolvedPaths;
|
|
8
|
+
settingsManager: SettingsManager;
|
|
9
|
+
cwd: string;
|
|
10
|
+
agentDir: string;
|
|
11
|
+
}
|
|
12
|
+
/** Show TUI config selector and return when closed */
|
|
13
|
+
export declare function selectConfig(options: ConfigSelectorOptions): Promise<void>;
|
|
14
|
+
//# sourceMappingURL=config-selector.d.ts.map
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* TUI config selector for `pi config` command
|
|
3
|
+
*/
|
|
4
|
+
import { ProcessTerminal, TUI } from "@mariozechner/pi-tui";
|
|
5
|
+
import { ConfigSelectorComponent } from "../modes/interactive/components/config-selector.js";
|
|
6
|
+
import { initTheme, stopThemeWatcher } from "../modes/interactive/theme/theme.js";
|
|
7
|
+
/** Show TUI config selector and return when closed */
|
|
8
|
+
export async function selectConfig(options) {
|
|
9
|
+
// Initialize theme before showing TUI
|
|
10
|
+
initTheme(options.settingsManager.getTheme(), true);
|
|
11
|
+
return new Promise((resolve) => {
|
|
12
|
+
const ui = new TUI(new ProcessTerminal());
|
|
13
|
+
let resolved = false;
|
|
14
|
+
const selector = new ConfigSelectorComponent(options.resolvedPaths, options.settingsManager, options.cwd, options.agentDir, () => {
|
|
15
|
+
if (!resolved) {
|
|
16
|
+
resolved = true;
|
|
17
|
+
ui.stop();
|
|
18
|
+
stopThemeWatcher();
|
|
19
|
+
resolve();
|
|
20
|
+
}
|
|
21
|
+
}, () => {
|
|
22
|
+
ui.stop();
|
|
23
|
+
stopThemeWatcher();
|
|
24
|
+
process.exit(0);
|
|
25
|
+
}, () => ui.requestRender());
|
|
26
|
+
ui.addChild(selector);
|
|
27
|
+
ui.setFocus(selector.getResourceList());
|
|
28
|
+
ui.start();
|
|
29
|
+
});
|
|
30
|
+
}
|
|
31
|
+
//# sourceMappingURL=config-selector.js.map
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Process @file CLI arguments into text content and image attachments
|
|
3
|
+
*/
|
|
4
|
+
import type { ImageContent } from "@mariozechner/pi-ai";
|
|
5
|
+
export interface ProcessedFiles {
|
|
6
|
+
text: string;
|
|
7
|
+
images: ImageContent[];
|
|
8
|
+
}
|
|
9
|
+
export interface ProcessFileOptions {
|
|
10
|
+
/** Whether to auto-resize images to 2000x2000 max. Default: true */
|
|
11
|
+
autoResizeImages?: boolean;
|
|
12
|
+
}
|
|
13
|
+
/** Process @file arguments into text content and image attachments */
|
|
14
|
+
export declare function processFileArguments(fileArgs: string[], options?: ProcessFileOptions): Promise<ProcessedFiles>;
|
|
15
|
+
//# sourceMappingURL=file-processor.d.ts.map
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Process @file CLI arguments into text content and image attachments
|
|
3
|
+
*/
|
|
4
|
+
import { access, readFile, stat } from "node:fs/promises";
|
|
5
|
+
import chalk from "chalk";
|
|
6
|
+
import { resolve } from "path";
|
|
7
|
+
import { resolveReadPath } from "../core/tools/path-utils.js";
|
|
8
|
+
import { formatDimensionNote, resizeImage } from "../utils/image-resize.js";
|
|
9
|
+
import { detectSupportedImageMimeTypeFromFile } from "../utils/mime.js";
|
|
10
|
+
/** Process @file arguments into text content and image attachments */
|
|
11
|
+
export async function processFileArguments(fileArgs, options) {
|
|
12
|
+
const autoResizeImages = options?.autoResizeImages ?? true;
|
|
13
|
+
let text = "";
|
|
14
|
+
const images = [];
|
|
15
|
+
for (const fileArg of fileArgs) {
|
|
16
|
+
// Expand and resolve path (handles ~ expansion and macOS screenshot Unicode spaces)
|
|
17
|
+
const absolutePath = resolve(resolveReadPath(fileArg, process.cwd()));
|
|
18
|
+
// Check if file exists
|
|
19
|
+
try {
|
|
20
|
+
await access(absolutePath);
|
|
21
|
+
}
|
|
22
|
+
catch {
|
|
23
|
+
console.error(chalk.red(`Error: File not found: ${absolutePath}`));
|
|
24
|
+
process.exit(1);
|
|
25
|
+
}
|
|
26
|
+
// Check if file is empty
|
|
27
|
+
const stats = await stat(absolutePath);
|
|
28
|
+
if (stats.size === 0) {
|
|
29
|
+
// Skip empty files
|
|
30
|
+
continue;
|
|
31
|
+
}
|
|
32
|
+
const mimeType = await detectSupportedImageMimeTypeFromFile(absolutePath);
|
|
33
|
+
if (mimeType) {
|
|
34
|
+
// Handle image file
|
|
35
|
+
const content = await readFile(absolutePath);
|
|
36
|
+
const base64Content = content.toString("base64");
|
|
37
|
+
let attachment;
|
|
38
|
+
let dimensionNote;
|
|
39
|
+
if (autoResizeImages) {
|
|
40
|
+
const resized = await resizeImage({ type: "image", data: base64Content, mimeType });
|
|
41
|
+
dimensionNote = formatDimensionNote(resized);
|
|
42
|
+
attachment = {
|
|
43
|
+
type: "image",
|
|
44
|
+
mimeType: resized.mimeType,
|
|
45
|
+
data: resized.data,
|
|
46
|
+
};
|
|
47
|
+
}
|
|
48
|
+
else {
|
|
49
|
+
attachment = {
|
|
50
|
+
type: "image",
|
|
51
|
+
mimeType,
|
|
52
|
+
data: base64Content,
|
|
53
|
+
};
|
|
54
|
+
}
|
|
55
|
+
images.push(attachment);
|
|
56
|
+
// Add text reference to image with optional dimension note
|
|
57
|
+
if (dimensionNote) {
|
|
58
|
+
text += `<file name="${absolutePath}">${dimensionNote}</file>\n`;
|
|
59
|
+
}
|
|
60
|
+
else {
|
|
61
|
+
text += `<file name="${absolutePath}"></file>\n`;
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
else {
|
|
65
|
+
// Handle text file
|
|
66
|
+
try {
|
|
67
|
+
const content = await readFile(absolutePath, "utf-8");
|
|
68
|
+
text += `<file name="${absolutePath}">\n${content}\n</file>\n`;
|
|
69
|
+
}
|
|
70
|
+
catch (error) {
|
|
71
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
72
|
+
console.error(chalk.red(`Error: Could not read file ${absolutePath}: ${message}`));
|
|
73
|
+
process.exit(1);
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
return { text, images };
|
|
78
|
+
}
|
|
79
|
+
//# sourceMappingURL=file-processor.js.map
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* List available models with optional fuzzy search
|
|
3
|
+
*/
|
|
4
|
+
import type { ModelRegistry } from "../core/model-registry.js";
|
|
5
|
+
/**
|
|
6
|
+
* List available models, optionally filtered by search pattern
|
|
7
|
+
*/
|
|
8
|
+
export declare function listModels(modelRegistry: ModelRegistry, searchPattern?: string): Promise<void>;
|
|
9
|
+
//# sourceMappingURL=list-models.d.ts.map
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* List available models with optional fuzzy search
|
|
3
|
+
*/
|
|
4
|
+
import { fuzzyFilter } from "@mariozechner/pi-tui";
|
|
5
|
+
/**
|
|
6
|
+
* Format a number as human-readable (e.g., 200000 -> "200K", 1000000 -> "1M")
|
|
7
|
+
*/
|
|
8
|
+
function formatTokenCount(count) {
|
|
9
|
+
if (count >= 1_000_000) {
|
|
10
|
+
const millions = count / 1_000_000;
|
|
11
|
+
return millions % 1 === 0 ? `${millions}M` : `${millions.toFixed(1)}M`;
|
|
12
|
+
}
|
|
13
|
+
if (count >= 1_000) {
|
|
14
|
+
const thousands = count / 1_000;
|
|
15
|
+
return thousands % 1 === 0 ? `${thousands}K` : `${thousands.toFixed(1)}K`;
|
|
16
|
+
}
|
|
17
|
+
return count.toString();
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* List available models, optionally filtered by search pattern
|
|
21
|
+
*/
|
|
22
|
+
export async function listModels(modelRegistry, searchPattern) {
|
|
23
|
+
const models = modelRegistry.getAvailable();
|
|
24
|
+
if (models.length === 0) {
|
|
25
|
+
console.log("No models available. Set API keys in environment variables.");
|
|
26
|
+
return;
|
|
27
|
+
}
|
|
28
|
+
// Apply fuzzy filter if search pattern provided
|
|
29
|
+
let filteredModels = models;
|
|
30
|
+
if (searchPattern) {
|
|
31
|
+
filteredModels = fuzzyFilter(models, searchPattern, (m) => `${m.provider} ${m.id}`);
|
|
32
|
+
}
|
|
33
|
+
if (filteredModels.length === 0) {
|
|
34
|
+
console.log(`No models matching "${searchPattern}"`);
|
|
35
|
+
return;
|
|
36
|
+
}
|
|
37
|
+
// Sort by provider, then by model id
|
|
38
|
+
filteredModels.sort((a, b) => {
|
|
39
|
+
const providerCmp = a.provider.localeCompare(b.provider);
|
|
40
|
+
if (providerCmp !== 0)
|
|
41
|
+
return providerCmp;
|
|
42
|
+
return a.id.localeCompare(b.id);
|
|
43
|
+
});
|
|
44
|
+
// Calculate column widths
|
|
45
|
+
const rows = filteredModels.map((m) => ({
|
|
46
|
+
provider: m.provider,
|
|
47
|
+
model: m.id,
|
|
48
|
+
context: formatTokenCount(m.contextWindow),
|
|
49
|
+
maxOut: formatTokenCount(m.maxTokens),
|
|
50
|
+
thinking: m.reasoning ? "yes" : "no",
|
|
51
|
+
images: m.input.includes("image") ? "yes" : "no",
|
|
52
|
+
}));
|
|
53
|
+
const headers = {
|
|
54
|
+
provider: "provider",
|
|
55
|
+
model: "model",
|
|
56
|
+
context: "context",
|
|
57
|
+
maxOut: "max-out",
|
|
58
|
+
thinking: "thinking",
|
|
59
|
+
images: "images",
|
|
60
|
+
};
|
|
61
|
+
const widths = {
|
|
62
|
+
provider: Math.max(headers.provider.length, ...rows.map((r) => r.provider.length)),
|
|
63
|
+
model: Math.max(headers.model.length, ...rows.map((r) => r.model.length)),
|
|
64
|
+
context: Math.max(headers.context.length, ...rows.map((r) => r.context.length)),
|
|
65
|
+
maxOut: Math.max(headers.maxOut.length, ...rows.map((r) => r.maxOut.length)),
|
|
66
|
+
thinking: Math.max(headers.thinking.length, ...rows.map((r) => r.thinking.length)),
|
|
67
|
+
images: Math.max(headers.images.length, ...rows.map((r) => r.images.length)),
|
|
68
|
+
};
|
|
69
|
+
// Print header
|
|
70
|
+
const headerLine = [
|
|
71
|
+
headers.provider.padEnd(widths.provider),
|
|
72
|
+
headers.model.padEnd(widths.model),
|
|
73
|
+
headers.context.padEnd(widths.context),
|
|
74
|
+
headers.maxOut.padEnd(widths.maxOut),
|
|
75
|
+
headers.thinking.padEnd(widths.thinking),
|
|
76
|
+
headers.images.padEnd(widths.images),
|
|
77
|
+
].join(" ");
|
|
78
|
+
console.log(headerLine);
|
|
79
|
+
// Print rows
|
|
80
|
+
for (const row of rows) {
|
|
81
|
+
const line = [
|
|
82
|
+
row.provider.padEnd(widths.provider),
|
|
83
|
+
row.model.padEnd(widths.model),
|
|
84
|
+
row.context.padEnd(widths.context),
|
|
85
|
+
row.maxOut.padEnd(widths.maxOut),
|
|
86
|
+
row.thinking.padEnd(widths.thinking),
|
|
87
|
+
row.images.padEnd(widths.images),
|
|
88
|
+
].join(" ");
|
|
89
|
+
console.log(line);
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
//# sourceMappingURL=list-models.js.map
|