@travisennis/acai 0.0.7 → 0.0.9
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 +76 -27
- package/dist/agent/index.d.ts +21 -25
- package/dist/agent/index.d.ts.map +1 -1
- package/dist/agent/index.js +145 -103
- package/dist/cli.d.ts +2 -2
- package/dist/cli.d.ts.map +1 -1
- package/dist/cli.js +23 -17
- package/dist/commands/add-directory/index.d.ts +3 -0
- package/dist/commands/add-directory/index.d.ts.map +1 -0
- package/dist/commands/{add-directory-command.js → add-directory/index.js} +6 -10
- package/dist/commands/add-directory/types.d.ts +6 -0
- package/dist/commands/add-directory/types.d.ts.map +1 -0
- package/dist/commands/add-directory/types.js +1 -0
- package/dist/commands/add-directory/utils.d.ts +3 -0
- package/dist/commands/add-directory/utils.d.ts.map +1 -0
- package/dist/commands/add-directory/utils.js +15 -0
- package/dist/commands/clear/index.d.ts +3 -0
- package/dist/commands/clear/index.d.ts.map +1 -0
- package/dist/commands/{clear-command.js → clear/index.js} +0 -2
- package/dist/commands/copy/index.d.ts +3 -0
- package/dist/commands/copy/index.d.ts.map +1 -0
- package/dist/commands/{copy-command.js → copy/index.js} +4 -26
- package/dist/commands/copy/types.d.ts +3 -0
- package/dist/commands/copy/types.d.ts.map +1 -0
- package/dist/commands/copy/types.js +1 -0
- package/dist/commands/copy/utils.d.ts +3 -0
- package/dist/commands/copy/utils.d.ts.map +1 -0
- package/dist/commands/copy/utils.js +22 -0
- package/dist/commands/{exit-command.d.ts → exit/index.d.ts} +4 -4
- package/dist/commands/exit/index.d.ts.map +1 -0
- package/dist/commands/exit/index.js +21 -0
- package/dist/commands/exit/types.d.ts +8 -0
- package/dist/commands/exit/types.d.ts.map +1 -0
- package/dist/commands/exit/types.js +1 -0
- package/dist/commands/exit/utils.d.ts +2 -0
- package/dist/commands/exit/utils.d.ts.map +1 -0
- package/dist/commands/exit/utils.js +13 -0
- package/dist/commands/generate-rules/index.d.ts +3 -0
- package/dist/commands/generate-rules/index.d.ts.map +1 -0
- package/dist/commands/{generate-rules-command.js → generate-rules/index.js} +57 -96
- package/dist/commands/generate-rules/utils.d.ts +5 -0
- package/dist/commands/generate-rules/utils.d.ts.map +1 -0
- package/dist/commands/generate-rules/utils.js +25 -0
- package/dist/commands/handoff/index.d.ts +3 -0
- package/dist/commands/handoff/index.d.ts.map +1 -0
- package/dist/commands/handoff/index.js +97 -0
- package/dist/commands/handoff/utils.d.ts +4 -0
- package/dist/commands/handoff/utils.d.ts.map +1 -0
- package/dist/commands/{handoff-command.js → handoff/utils.js} +24 -92
- package/dist/commands/health/index.d.ts +3 -0
- package/dist/commands/health/index.d.ts.map +1 -0
- package/dist/commands/health/index.js +56 -0
- package/dist/commands/health/utils.d.ts +15 -0
- package/dist/commands/health/utils.d.ts.map +1 -0
- package/dist/commands/health/utils.js +52 -0
- package/dist/commands/{help-command.d.ts → help/index.d.ts} +2 -2
- package/dist/commands/help/index.d.ts.map +1 -0
- package/dist/commands/{help-command.js → help/index.js} +1 -1
- package/dist/commands/history/index.d.ts +3 -0
- package/dist/commands/history/index.d.ts.map +1 -0
- package/dist/commands/{history-command.js → history/index.js} +16 -100
- package/dist/commands/history/types.d.ts +11 -0
- package/dist/commands/history/types.d.ts.map +1 -0
- package/dist/commands/history/types.js +1 -0
- package/dist/commands/history/utils.d.ts +4 -0
- package/dist/commands/history/utils.d.ts.map +1 -0
- package/dist/commands/history/utils.js +86 -0
- package/dist/commands/init/index.d.ts +3 -0
- package/dist/commands/init/index.d.ts.map +1 -0
- package/dist/commands/{init-command.js → init/index.js} +16 -7
- package/dist/commands/init-project/index.d.ts +3 -0
- package/dist/commands/init-project/index.d.ts.map +1 -0
- package/dist/commands/init-project/index.js +51 -0
- package/dist/commands/init-project/utils.d.ts +9 -0
- package/dist/commands/init-project/utils.d.ts.map +1 -0
- package/dist/commands/init-project/utils.js +43 -0
- package/dist/commands/list-directories/index.d.ts +3 -0
- package/dist/commands/list-directories/index.d.ts.map +1 -0
- package/dist/commands/{list-directories-command.js → list-directories/index.js} +1 -1
- package/dist/commands/list-tools/index.d.ts +3 -0
- package/dist/commands/list-tools/index.d.ts.map +1 -0
- package/dist/commands/{list-tools-command.js → list-tools/index.js} +4 -16
- package/dist/commands/manager.d.ts +2 -2
- package/dist/commands/manager.d.ts.map +1 -1
- package/dist/commands/manager.js +35 -43
- package/dist/commands/model/index.d.ts +3 -0
- package/dist/commands/model/index.d.ts.map +1 -0
- package/dist/commands/{model-command.js → model/index.js} +15 -52
- package/dist/commands/model/utils.d.ts +3 -0
- package/dist/commands/model/utils.d.ts.map +1 -0
- package/dist/commands/model/utils.js +5 -0
- package/dist/commands/{paste-command.d.ts → paste/index.d.ts} +2 -2
- package/dist/commands/paste/index.d.ts.map +1 -0
- package/dist/commands/{paste-command.js → paste/index.js} +6 -111
- package/dist/commands/paste/utils.d.ts +5 -0
- package/dist/commands/paste/utils.d.ts.map +1 -0
- package/dist/commands/paste/utils.js +86 -0
- package/dist/commands/pickup/index.d.ts +3 -0
- package/dist/commands/pickup/index.d.ts.map +1 -0
- package/dist/commands/pickup/index.js +138 -0
- package/dist/commands/pickup/types.d.ts +6 -0
- package/dist/commands/pickup/types.d.ts.map +1 -0
- package/dist/commands/pickup/types.js +1 -0
- package/dist/commands/pickup/utils.d.ts +7 -0
- package/dist/commands/pickup/utils.d.ts.map +1 -0
- package/dist/commands/pickup/utils.js +56 -0
- package/dist/commands/prompt/index.d.ts +5 -0
- package/dist/commands/prompt/index.d.ts.map +1 -0
- package/dist/commands/prompt/index.js +122 -0
- package/dist/commands/prompt/types.d.ts +15 -0
- package/dist/commands/prompt/types.d.ts.map +1 -0
- package/dist/commands/prompt/types.js +1 -0
- package/dist/commands/prompt/utils.d.ts +12 -0
- package/dist/commands/prompt/utils.d.ts.map +1 -0
- package/dist/commands/prompt/utils.js +107 -0
- package/dist/commands/remove-directory/index.d.ts +3 -0
- package/dist/commands/remove-directory/index.d.ts.map +1 -0
- package/dist/commands/{remove-directory-command.js → remove-directory/index.js} +2 -2
- package/dist/commands/reset/index.d.ts +3 -0
- package/dist/commands/reset/index.d.ts.map +1 -0
- package/dist/commands/{reset-command.js → reset/index.js} +7 -2
- package/dist/commands/reset/types.d.ts +1 -0
- package/dist/commands/reset/types.d.ts.map +1 -0
- package/dist/commands/reset/types.js +3 -0
- package/dist/commands/resources/index.d.ts +3 -0
- package/dist/commands/resources/index.d.ts.map +1 -0
- package/dist/commands/resources/index.js +84 -0
- package/dist/commands/review/index.d.ts +3 -0
- package/dist/commands/review/index.d.ts.map +1 -0
- package/dist/commands/review/index.js +126 -0
- package/dist/commands/review/types.d.ts +12 -0
- package/dist/commands/review/types.d.ts.map +1 -0
- package/dist/commands/review/types.js +1 -0
- package/dist/commands/review/utils.d.ts +4 -0
- package/dist/commands/review/utils.d.ts.map +1 -0
- package/dist/commands/review/utils.js +87 -0
- package/dist/commands/save/index.d.ts +3 -0
- package/dist/commands/save/index.d.ts.map +1 -0
- package/dist/commands/{save-command.js → save/index.js} +3 -3
- package/dist/commands/session/index.d.ts +3 -0
- package/dist/commands/session/index.d.ts.map +1 -0
- package/dist/commands/session/index.js +230 -0
- package/dist/commands/session/types.d.ts +20 -0
- package/dist/commands/session/types.d.ts.map +1 -0
- package/dist/commands/session/types.js +7 -0
- package/dist/commands/share/html-renderer.d.ts +25 -0
- package/dist/commands/share/html-renderer.d.ts.map +1 -0
- package/dist/commands/share/html-renderer.js +384 -0
- package/dist/commands/share/index.d.ts +3 -0
- package/dist/commands/share/index.d.ts.map +1 -0
- package/dist/commands/share/index.js +122 -0
- package/dist/commands/shell/index.d.ts +3 -0
- package/dist/commands/shell/index.d.ts.map +1 -0
- package/dist/commands/{shell-command.js → shell/index.js} +3 -3
- package/dist/commands/types.d.ts +2 -2
- package/dist/commands/types.d.ts.map +1 -1
- package/dist/config.d.ts +25 -7
- package/dist/config.d.ts.map +1 -1
- package/dist/config.js +45 -20
- package/dist/dedent.d.ts.map +1 -1
- package/dist/dedent.js +7 -7
- package/dist/execution/index.d.ts +1 -0
- package/dist/execution/index.d.ts.map +1 -1
- package/dist/execution/index.js +60 -64
- package/dist/formatting.d.ts +27 -0
- package/dist/formatting.d.ts.map +1 -1
- package/dist/formatting.js +40 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +194 -95
- package/dist/logger.d.ts.map +1 -1
- package/dist/logger.js +4 -11
- package/dist/mentions.d.ts.map +1 -1
- package/dist/mentions.js +3 -53
- package/dist/middleware/audit-message.d.ts +2 -2
- package/dist/middleware/audit-message.d.ts.map +1 -1
- package/dist/middleware/audit-message.js +40 -2
- package/dist/middleware/cache.d.ts +2 -2
- package/dist/middleware/cache.d.ts.map +1 -1
- package/dist/middleware/cache.js +111 -27
- package/dist/middleware/rate-limit.d.ts +2 -2
- package/dist/middleware/rate-limit.d.ts.map +1 -1
- package/dist/middleware/rate-limit.js +1 -0
- package/dist/models/ai-config.d.ts.map +1 -1
- package/dist/models/ai-config.js +46 -29
- package/dist/models/anthropic-provider.d.ts +14 -13
- package/dist/models/anthropic-provider.d.ts.map +1 -1
- package/dist/models/deepseek-provider.d.ts +9 -8
- package/dist/models/deepseek-provider.d.ts.map +1 -1
- package/dist/models/google-provider.d.ts +10 -9
- package/dist/models/google-provider.d.ts.map +1 -1
- package/dist/models/groq-provider.d.ts +8 -7
- package/dist/models/groq-provider.d.ts.map +1 -1
- package/dist/models/manager.d.ts +7 -4
- package/dist/models/manager.d.ts.map +1 -1
- package/dist/models/manager.js +5 -25
- package/dist/models/openai-provider.d.ts +14 -10
- package/dist/models/openai-provider.d.ts.map +1 -1
- package/dist/models/openai-provider.js +39 -0
- package/dist/models/opencode-zen-provider.d.ts +24 -0
- package/dist/models/opencode-zen-provider.d.ts.map +1 -0
- package/dist/models/opencode-zen-provider.js +94 -0
- package/dist/models/openrouter-provider.d.ts +35 -29
- package/dist/models/openrouter-provider.d.ts.map +1 -1
- package/dist/models/openrouter-provider.js +108 -80
- package/dist/models/providers.d.ts +4 -4
- package/dist/models/providers.d.ts.map +1 -1
- package/dist/models/providers.js +7 -1
- package/dist/models/xai-provider.d.ts +9 -8
- package/dist/models/xai-provider.d.ts.map +1 -1
- package/dist/prompts/manager.d.ts +1 -1
- package/dist/prompts/manager.d.ts.map +1 -1
- package/dist/prompts/manager.js +1 -1
- package/dist/prompts.d.ts +12 -2
- package/dist/prompts.d.ts.map +1 -1
- package/dist/prompts.js +74 -411
- package/dist/repl/project-status.d.ts +19 -0
- package/dist/repl/project-status.d.ts.map +1 -0
- package/dist/repl/project-status.js +78 -0
- package/dist/repl-new.d.ts +18 -4
- package/dist/repl-new.d.ts.map +1 -1
- package/dist/repl-new.js +256 -43
- package/dist/{messages.d.ts → sessions/manager.d.ts} +10 -4
- package/dist/sessions/manager.d.ts.map +1 -0
- package/dist/{messages.js → sessions/manager.js} +62 -14
- package/dist/skills.d.ts +0 -4
- package/dist/skills.d.ts.map +1 -1
- package/dist/skills.js +100 -59
- package/dist/stdin.d.ts +9 -0
- package/dist/stdin.d.ts.map +1 -0
- package/dist/stdin.js +26 -0
- package/dist/terminal/control.d.ts +1 -0
- package/dist/terminal/control.d.ts.map +1 -1
- package/dist/terminal/control.js +29 -6
- package/dist/terminal/formatting.d.ts +1 -2
- package/dist/terminal/formatting.d.ts.map +1 -1
- package/dist/terminal/formatting.js +1 -2
- package/dist/terminal/keys.d.ts +211 -0
- package/dist/terminal/keys.d.ts.map +1 -0
- package/dist/terminal/keys.js +546 -0
- package/dist/terminal/segmenter.d.ts +6 -0
- package/dist/terminal/segmenter.d.ts.map +1 -0
- package/dist/terminal/segmenter.js +11 -0
- package/dist/terminal/select-prompt.d.ts.map +1 -1
- package/dist/terminal/select-prompt.js +9 -21
- package/dist/terminal/string-width.d.ts.map +1 -1
- package/dist/terminal/string-width.js +40 -21
- package/dist/terminal/strip-ansi.d.ts.map +1 -1
- package/dist/terminal/strip-ansi.js +9 -15
- package/dist/tokens/tracker.d.ts.map +1 -1
- package/dist/tokens/tracker.js +58 -16
- package/dist/tools/bash.d.ts +9 -11
- package/dist/tools/bash.d.ts.map +1 -1
- package/dist/tools/bash.js +104 -123
- package/dist/tools/directory-tree.d.ts +9 -7
- package/dist/tools/directory-tree.d.ts.map +1 -1
- package/dist/tools/directory-tree.js +89 -70
- package/dist/tools/dynamic-tool-loader.d.ts +22 -4
- package/dist/tools/dynamic-tool-loader.d.ts.map +1 -1
- package/dist/tools/dynamic-tool-loader.js +39 -44
- package/dist/tools/edit-file.d.ts +6 -16
- package/dist/tools/edit-file.d.ts.map +1 -1
- package/dist/tools/edit-file.js +19 -76
- package/dist/tools/glob.d.ts +15 -16
- package/dist/tools/glob.d.ts.map +1 -1
- package/dist/tools/glob.js +77 -119
- package/dist/tools/grep.d.ts +19 -22
- package/dist/tools/grep.d.ts.map +1 -1
- package/dist/tools/grep.js +61 -108
- package/dist/tools/index.d.ts +200 -179
- package/dist/tools/index.d.ts.map +1 -1
- package/dist/tools/index.js +17 -315
- package/dist/tools/ls.d.ts +26 -0
- package/dist/tools/ls.d.ts.map +1 -0
- package/dist/tools/ls.js +80 -0
- package/dist/tools/read-file.d.ts +15 -15
- package/dist/tools/read-file.d.ts.map +1 -1
- package/dist/tools/read-file.js +49 -82
- package/dist/tools/save-file.d.ts +4 -4
- package/dist/tools/save-file.d.ts.map +1 -1
- package/dist/tools/save-file.js +37 -66
- package/dist/tools/think.d.ts +4 -4
- package/dist/tools/think.d.ts.map +1 -1
- package/dist/tools/think.js +9 -38
- package/dist/tools/types.d.ts +5 -25
- package/dist/tools/types.d.ts.map +1 -1
- package/dist/tools/types.js +0 -9
- package/dist/tui/autocomplete/attachment-provider.d.ts +18 -0
- package/dist/tui/autocomplete/attachment-provider.d.ts.map +1 -0
- package/dist/tui/autocomplete/attachment-provider.js +159 -0
- package/dist/tui/autocomplete/base-provider.d.ts +17 -0
- package/dist/tui/autocomplete/base-provider.d.ts.map +1 -0
- package/dist/tui/autocomplete/base-provider.js +1 -0
- package/dist/tui/autocomplete/combined-provider.d.ts +20 -0
- package/dist/tui/autocomplete/combined-provider.d.ts.map +1 -0
- package/dist/tui/autocomplete/combined-provider.js +61 -0
- package/dist/tui/autocomplete/command-provider.d.ts +20 -0
- package/dist/tui/autocomplete/command-provider.d.ts.map +1 -0
- package/dist/tui/autocomplete/command-provider.js +90 -0
- package/dist/tui/autocomplete/file-search-provider.d.ts +16 -0
- package/dist/tui/autocomplete/file-search-provider.d.ts.map +1 -0
- package/dist/tui/autocomplete/file-search-provider.js +123 -0
- package/dist/tui/autocomplete/path-provider.d.ts +21 -0
- package/dist/tui/autocomplete/path-provider.d.ts.map +1 -0
- package/dist/tui/autocomplete/path-provider.js +164 -0
- package/dist/tui/autocomplete/utils.d.ts +16 -0
- package/dist/tui/autocomplete/utils.d.ts.map +1 -0
- package/dist/tui/autocomplete/utils.js +137 -0
- package/dist/tui/autocomplete.d.ts +12 -43
- package/dist/tui/autocomplete.d.ts.map +1 -1
- package/dist/tui/autocomplete.js +20 -465
- package/dist/tui/components/box.d.ts.map +1 -1
- package/dist/tui/components/box.js +16 -10
- package/dist/tui/components/editor.d.ts +6 -2
- package/dist/tui/components/editor.d.ts.map +1 -1
- package/dist/tui/components/editor.js +166 -107
- package/dist/tui/components/footer.d.ts +20 -7
- package/dist/tui/components/footer.d.ts.map +1 -1
- package/dist/tui/components/footer.js +89 -196
- package/dist/tui/components/input.d.ts.map +1 -1
- package/dist/tui/components/input.js +8 -7
- package/dist/tui/components/loader.d.ts +2 -1
- package/dist/tui/components/loader.d.ts.map +1 -1
- package/dist/tui/components/loader.js +7 -2
- package/dist/tui/components/markdown.d.ts +5 -4
- package/dist/tui/components/markdown.d.ts.map +1 -1
- package/dist/tui/components/markdown.js +51 -40
- package/dist/tui/components/modal.d.ts.map +1 -1
- package/dist/tui/components/modal.js +9 -8
- package/dist/tui/components/notification.d.ts +28 -0
- package/dist/tui/components/notification.d.ts.map +1 -0
- package/dist/tui/components/notification.js +64 -0
- package/dist/tui/components/progress-bar.d.ts.map +1 -1
- package/dist/tui/components/progress-bar.js +3 -15
- package/dist/tui/components/select-list.d.ts +0 -15
- package/dist/tui/components/select-list.d.ts.map +1 -1
- package/dist/tui/components/select-list.js +5 -28
- package/dist/tui/components/tool-execution.d.ts +3 -6
- package/dist/tui/components/tool-execution.d.ts.map +1 -1
- package/dist/tui/components/tool-execution.js +26 -38
- package/dist/tui/components/welcome.d.ts +8 -1
- package/dist/tui/components/welcome.d.ts.map +1 -1
- package/dist/tui/components/welcome.js +45 -6
- package/dist/tui/editor-launcher.d.ts +13 -0
- package/dist/tui/editor-launcher.d.ts.map +1 -0
- package/dist/tui/editor-launcher.js +39 -0
- package/dist/tui/index.d.ts +7 -3
- package/dist/tui/index.d.ts.map +1 -1
- package/dist/tui/index.js +3 -2
- package/dist/tui/terminal.d.ts +29 -2
- package/dist/tui/terminal.d.ts.map +1 -1
- package/dist/tui/terminal.js +153 -28
- package/dist/tui/tui.d.ts +2 -0
- package/dist/tui/tui.d.ts.map +1 -1
- package/dist/tui/tui.js +39 -29
- package/dist/tui/utils.d.ts.map +1 -1
- package/dist/tui/utils.js +2 -3
- package/dist/utils/filesystem/security.d.ts.map +1 -1
- package/dist/utils/filesystem/security.js +4 -1
- package/dist/utils/yaml.d.ts +11 -0
- package/dist/utils/yaml.d.ts.map +1 -0
- package/dist/utils/yaml.js +207 -0
- package/dist/utils/zod.d.ts +1 -0
- package/dist/utils/zod.d.ts.map +1 -1
- package/dist/utils/zod.js +17 -0
- package/package.json +31 -29
- package/bin/acai-wrapper.js +0 -26
- package/dist/api/exa/index.d.ts +0 -177
- package/dist/api/exa/index.d.ts.map +0 -1
- package/dist/api/exa/index.js +0 -439
- package/dist/commands/add-directory-command.d.ts +0 -3
- package/dist/commands/add-directory-command.d.ts.map +0 -1
- package/dist/commands/application-log-command.d.ts +0 -3
- package/dist/commands/application-log-command.d.ts.map +0 -1
- package/dist/commands/application-log-command.js +0 -43
- package/dist/commands/clear-command.d.ts +0 -3
- package/dist/commands/clear-command.d.ts.map +0 -1
- package/dist/commands/compact-command.d.ts +0 -3
- package/dist/commands/compact-command.d.ts.map +0 -1
- package/dist/commands/compact-command.js +0 -55
- package/dist/commands/context-command.d.ts +0 -3
- package/dist/commands/context-command.d.ts.map +0 -1
- package/dist/commands/context-command.js +0 -124
- package/dist/commands/copy-command.d.ts +0 -3
- package/dist/commands/copy-command.d.ts.map +0 -1
- package/dist/commands/edit-command.d.ts +0 -3
- package/dist/commands/edit-command.d.ts.map +0 -1
- package/dist/commands/edit-command.js +0 -42
- package/dist/commands/edit-prompt-command.d.ts +0 -3
- package/dist/commands/edit-prompt-command.d.ts.map +0 -1
- package/dist/commands/edit-prompt-command.js +0 -36
- package/dist/commands/exit-command.d.ts.map +0 -1
- package/dist/commands/exit-command.js +0 -30
- package/dist/commands/files-command.d.ts +0 -3
- package/dist/commands/files-command.d.ts.map +0 -1
- package/dist/commands/files-command.js +0 -68
- package/dist/commands/generate-rules-command.d.ts +0 -3
- package/dist/commands/generate-rules-command.d.ts.map +0 -1
- package/dist/commands/handoff-command.d.ts +0 -3
- package/dist/commands/handoff-command.d.ts.map +0 -1
- package/dist/commands/health-command.d.ts +0 -4
- package/dist/commands/health-command.d.ts.map +0 -1
- package/dist/commands/health-command.js +0 -118
- package/dist/commands/help-command.d.ts.map +0 -1
- package/dist/commands/history-command.d.ts +0 -3
- package/dist/commands/history-command.d.ts.map +0 -1
- package/dist/commands/init-command.d.ts +0 -3
- package/dist/commands/init-command.d.ts.map +0 -1
- package/dist/commands/last-log-command.d.ts +0 -3
- package/dist/commands/last-log-command.d.ts.map +0 -1
- package/dist/commands/last-log-command.js +0 -71
- package/dist/commands/list-directories-command.d.ts +0 -3
- package/dist/commands/list-directories-command.d.ts.map +0 -1
- package/dist/commands/list-tools-command.d.ts +0 -3
- package/dist/commands/list-tools-command.d.ts.map +0 -1
- package/dist/commands/model-command.d.ts +0 -3
- package/dist/commands/model-command.d.ts.map +0 -1
- package/dist/commands/paste-command.d.ts.map +0 -1
- package/dist/commands/pickup-command.d.ts +0 -3
- package/dist/commands/pickup-command.d.ts.map +0 -1
- package/dist/commands/pickup-command.js +0 -109
- package/dist/commands/prompt-command.d.ts +0 -21
- package/dist/commands/prompt-command.d.ts.map +0 -1
- package/dist/commands/prompt-command.js +0 -258
- package/dist/commands/remove-directory-command.d.ts +0 -3
- package/dist/commands/remove-directory-command.d.ts.map +0 -1
- package/dist/commands/reset-command.d.ts +0 -3
- package/dist/commands/reset-command.d.ts.map +0 -1
- package/dist/commands/rules-command.d.ts +0 -3
- package/dist/commands/rules-command.d.ts.map +0 -1
- package/dist/commands/rules-command.js +0 -73
- package/dist/commands/save-command.d.ts +0 -3
- package/dist/commands/save-command.d.ts.map +0 -1
- package/dist/commands/shell-command.d.ts +0 -3
- package/dist/commands/shell-command.d.ts.map +0 -1
- package/dist/commands/usage-command.d.ts +0 -3
- package/dist/commands/usage-command.d.ts.map +0 -1
- package/dist/commands/usage-command.js +0 -31
- package/dist/messages.d.ts.map +0 -1
- package/dist/repl/project-status-line.d.ts +0 -3
- package/dist/repl/project-status-line.d.ts.map +0 -1
- package/dist/repl/project-status-line.js +0 -61
- package/dist/repl/tool-call-repair.d.ts +0 -4
- package/dist/repl/tool-call-repair.d.ts.map +0 -1
- package/dist/repl/tool-call-repair.js +0 -54
- package/dist/terminal/markdown.d.ts +0 -2
- package/dist/terminal/markdown.d.ts.map +0 -1
- package/dist/terminal/markdown.js +0 -120
- package/dist/tokens/threshold.d.ts +0 -20
- package/dist/tokens/threshold.d.ts.map +0 -1
- package/dist/tokens/threshold.js +0 -67
- package/dist/tools/advanced-edit-file.d.ts +0 -69
- package/dist/tools/advanced-edit-file.d.ts.map +0 -1
- package/dist/tools/advanced-edit-file.js +0 -285
- package/dist/tools/agent.d.ts +0 -29
- package/dist/tools/agent.d.ts.map +0 -1
- package/dist/tools/agent.js +0 -117
- package/dist/tools/batch.d.ts +0 -34
- package/dist/tools/batch.d.ts.map +0 -1
- package/dist/tools/batch.js +0 -174
- package/dist/tools/code-interpreter.d.ts +0 -25
- package/dist/tools/code-interpreter.d.ts.map +0 -1
- package/dist/tools/code-interpreter.js +0 -183
- package/dist/tools/delete-file.d.ts +0 -24
- package/dist/tools/delete-file.d.ts.map +0 -1
- package/dist/tools/delete-file.js +0 -77
- package/dist/tools/dynamic-tool-parser.d.ts +0 -21
- package/dist/tools/dynamic-tool-parser.d.ts.map +0 -1
- package/dist/tools/dynamic-tool-parser.js +0 -22
- package/dist/tools/llm-edit-fixer.d.ts +0 -24
- package/dist/tools/llm-edit-fixer.d.ts.map +0 -1
- package/dist/tools/llm-edit-fixer.js +0 -136
- package/dist/tools/move-file.d.ts +0 -26
- package/dist/tools/move-file.d.ts.map +0 -1
- package/dist/tools/move-file.js +0 -65
- package/dist/tools/read-multiple-files.d.ts +0 -26
- package/dist/tools/read-multiple-files.d.ts.map +0 -1
- package/dist/tools/read-multiple-files.js +0 -196
- package/dist/tools/web-fetch.d.ts +0 -56
- package/dist/tools/web-fetch.d.ts.map +0 -1
- package/dist/tools/web-fetch.js +0 -247
- package/dist/tools/web-search.d.ts +0 -23
- package/dist/tools/web-search.d.ts.map +0 -1
- package/dist/tools/web-search.js +0 -148
- package/dist/tui/components/prompt-status.d.ts +0 -17
- package/dist/tui/components/prompt-status.d.ts.map +0 -1
- package/dist/tui/components/prompt-status.js +0 -26
|
@@ -1,105 +1,9 @@
|
|
|
1
1
|
import Clipboard from "@crosscopy/clipboard";
|
|
2
|
-
import { formatBlock } from "
|
|
3
|
-
import { logger } from "
|
|
4
|
-
import style from "
|
|
5
|
-
import { Text } from "
|
|
6
|
-
|
|
7
|
-
return dataUrl.replace(/^data:.*?;base64,/, "");
|
|
8
|
-
}
|
|
9
|
-
function isValidBase64(str) {
|
|
10
|
-
try {
|
|
11
|
-
// Remove data URL prefix if present
|
|
12
|
-
const base64Content = extractBase64Content(str);
|
|
13
|
-
// Try to decode the base64 string
|
|
14
|
-
const decoded = Buffer.from(base64Content, "base64");
|
|
15
|
-
// Re-encode to verify it's valid base64
|
|
16
|
-
const reEncoded = decoded.toString("base64");
|
|
17
|
-
// Remove padding for comparison
|
|
18
|
-
const normalizedOriginal = base64Content.replace(/=/g, "");
|
|
19
|
-
const normalizedReEncoded = reEncoded.replace(/=/g, "");
|
|
20
|
-
return normalizedOriginal === normalizedReEncoded;
|
|
21
|
-
}
|
|
22
|
-
catch {
|
|
23
|
-
return false;
|
|
24
|
-
}
|
|
25
|
-
}
|
|
26
|
-
function detectImageFormatFromBase64(base64Content) {
|
|
27
|
-
try {
|
|
28
|
-
const buffer = Buffer.from(base64Content, "base64");
|
|
29
|
-
// Check for JPEG signature (FF D8 FF)
|
|
30
|
-
if (buffer.length >= 3 &&
|
|
31
|
-
buffer[0] === 0xff &&
|
|
32
|
-
buffer[1] === 0xd8 &&
|
|
33
|
-
buffer[2] === 0xff) {
|
|
34
|
-
return "image/jpeg";
|
|
35
|
-
}
|
|
36
|
-
// Check for PNG signature (89 50 4E 47 0D 0A 1A 0A)
|
|
37
|
-
if (buffer.length >= 8 &&
|
|
38
|
-
buffer[0] === 0x89 &&
|
|
39
|
-
buffer[1] === 0x50 &&
|
|
40
|
-
buffer[2] === 0x4e &&
|
|
41
|
-
buffer[3] === 0x47 &&
|
|
42
|
-
buffer[4] === 0x0d &&
|
|
43
|
-
buffer[5] === 0x0a &&
|
|
44
|
-
buffer[6] === 0x1a &&
|
|
45
|
-
buffer[7] === 0x0a) {
|
|
46
|
-
return "image/png";
|
|
47
|
-
}
|
|
48
|
-
// Check for GIF signature (GIF87a or GIF89a)
|
|
49
|
-
if (buffer.length >= 6 &&
|
|
50
|
-
((buffer[0] === 0x47 &&
|
|
51
|
-
buffer[1] === 0x49 &&
|
|
52
|
-
buffer[2] === 0x46 &&
|
|
53
|
-
buffer[3] === 0x38 &&
|
|
54
|
-
buffer[4] === 0x37 &&
|
|
55
|
-
buffer[5] === 0x61) ||
|
|
56
|
-
(buffer[0] === 0x47 &&
|
|
57
|
-
buffer[1] === 0x49 &&
|
|
58
|
-
buffer[2] === 0x46 &&
|
|
59
|
-
buffer[3] === 0x38 &&
|
|
60
|
-
buffer[4] === 0x39 &&
|
|
61
|
-
buffer[5] === 0x61))) {
|
|
62
|
-
return "image/gif";
|
|
63
|
-
}
|
|
64
|
-
// Check for WebP signature (RIFF .... WEBP)
|
|
65
|
-
if (buffer.length >= 12 &&
|
|
66
|
-
buffer[0] === 0x52 &&
|
|
67
|
-
buffer[1] === 0x49 &&
|
|
68
|
-
buffer[2] === 0x46 &&
|
|
69
|
-
buffer[3] === 0x46 &&
|
|
70
|
-
buffer[8] === 0x57 &&
|
|
71
|
-
buffer[9] === 0x45 &&
|
|
72
|
-
buffer[10] === 0x42 &&
|
|
73
|
-
buffer[11] === 0x50) {
|
|
74
|
-
return "image/webp";
|
|
75
|
-
}
|
|
76
|
-
// Check for BMP signature (BM)
|
|
77
|
-
if (buffer.length >= 2 && buffer[0] === 0x42 && buffer[1] === 0x4d) {
|
|
78
|
-
return "image/bmp";
|
|
79
|
-
}
|
|
80
|
-
// Check for TIFF signatures (II* or MM*)
|
|
81
|
-
if (buffer.length >= 4 &&
|
|
82
|
-
((buffer[0] === 0x49 &&
|
|
83
|
-
buffer[1] === 0x49 &&
|
|
84
|
-
buffer[2] === 0x2a &&
|
|
85
|
-
buffer[3] === 0x00) ||
|
|
86
|
-
(buffer[0] === 0x4d &&
|
|
87
|
-
buffer[1] === 0x4d &&
|
|
88
|
-
buffer[2] === 0x00 &&
|
|
89
|
-
buffer[3] === 0x2a))) {
|
|
90
|
-
return "image/tiff";
|
|
91
|
-
}
|
|
92
|
-
// If no known signature found, fall back to the data URL MIME type
|
|
93
|
-
return "unknown";
|
|
94
|
-
}
|
|
95
|
-
catch {
|
|
96
|
-
return "unknown";
|
|
97
|
-
}
|
|
98
|
-
}
|
|
99
|
-
function extractMimeTypeFromDataUrl(dataUrl) {
|
|
100
|
-
const match = dataUrl.match(/^data:([^;]+);base64,/);
|
|
101
|
-
return match?.[1] ? match[1] : "image/png";
|
|
102
|
-
}
|
|
2
|
+
import { formatBlock } from "../../formatting.js";
|
|
3
|
+
import { logger } from "../../logger.js";
|
|
4
|
+
import style from "../../terminal/style.js";
|
|
5
|
+
import { Text } from "../../tui/index.js";
|
|
6
|
+
import { detectImageFormatFromBase64, extractMimeTypeFromDataUrl, isValidBase64, } from "./utils.js";
|
|
103
7
|
export const pasteCommand = ({ modelManager, promptManager, tokenCounter, }) => {
|
|
104
8
|
return {
|
|
105
9
|
command: "/paste",
|
|
@@ -109,25 +13,19 @@ export const pasteCommand = ({ modelManager, promptManager, tokenCounter, }) =>
|
|
|
109
13
|
try {
|
|
110
14
|
if (Clipboard.hasImage()) {
|
|
111
15
|
const base64DataUrl = await Clipboard.getImageBase64();
|
|
112
|
-
// Validate the base64 data
|
|
113
16
|
if (!isValidBase64(base64DataUrl)) {
|
|
114
17
|
container.addChild(new Text(style.red("Invalid base64 data in clipboard. The image data may be corrupted."), 1, 0));
|
|
115
18
|
tui.requestRender();
|
|
116
19
|
editor.setText("");
|
|
117
20
|
return "continue";
|
|
118
21
|
}
|
|
119
|
-
// Extract MIME type with better error handling and actual image format detection
|
|
120
22
|
let mimeType;
|
|
121
23
|
try {
|
|
122
|
-
// First, try to get MIME type from data URL
|
|
123
24
|
const dataUrlMimeType = extractMimeTypeFromDataUrl(base64DataUrl);
|
|
124
|
-
|
|
125
|
-
const base64Content = extractBase64Content(base64DataUrl);
|
|
25
|
+
const base64Content = base64DataUrl.replace(/^data:.*?;base64,/, "");
|
|
126
26
|
const detectedFormat = detectImageFormatFromBase64(base64Content);
|
|
127
|
-
// Use detected format if available, otherwise fall back to data URL MIME type
|
|
128
27
|
if (detectedFormat !== "unknown") {
|
|
129
28
|
mimeType = detectedFormat;
|
|
130
|
-
// Log if there's a mismatch between data URL and actual format
|
|
131
29
|
if (dataUrlMimeType !== detectedFormat) {
|
|
132
30
|
logger.warn(`Clipboard library reported ${dataUrlMimeType} but actual image format is ${detectedFormat}. Using detected format.`);
|
|
133
31
|
}
|
|
@@ -141,12 +39,9 @@ export const pasteCommand = ({ modelManager, promptManager, tokenCounter, }) =>
|
|
|
141
39
|
logger.warn(`Failed to extract MIME type from clipboard image: ${error}`);
|
|
142
40
|
mimeType = "image/png";
|
|
143
41
|
}
|
|
144
|
-
// Ensure the data URL format is correct
|
|
145
42
|
if (!base64DataUrl.startsWith(`data:${mimeType};base64,`)) {
|
|
146
|
-
// Fix malformed data URLs
|
|
147
43
|
const base64Content = base64DataUrl.replace(/^data:.*?;base64,/, "");
|
|
148
44
|
const correctedDataUrl = `data:${mimeType};base64,${base64Content}`;
|
|
149
|
-
// Final validation
|
|
150
45
|
if (!isValidBase64(correctedDataUrl)) {
|
|
151
46
|
container.addChild(new Text(style.red("Failed to correct base64 data format. The image data may be corrupted."), 1, 0));
|
|
152
47
|
tui.requestRender();
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
export declare function extractBase64Content(dataUrl: string): string;
|
|
2
|
+
export declare function isValidBase64(str: string): boolean;
|
|
3
|
+
export declare function detectImageFormatFromBase64(base64Content: string): string;
|
|
4
|
+
export declare function extractMimeTypeFromDataUrl(dataUrl: string): string;
|
|
5
|
+
//# sourceMappingURL=utils.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../../source/commands/paste/utils.ts"],"names":[],"mappings":"AAAA,wBAAgB,oBAAoB,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM,CAE5D;AAED,wBAAgB,aAAa,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAWlD;AAED,wBAAgB,2BAA2B,CAAC,aAAa,EAAE,MAAM,GAAG,MAAM,CAiFzE;AAED,wBAAgB,0BAA0B,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM,CAGlE"}
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
export function extractBase64Content(dataUrl) {
|
|
2
|
+
return dataUrl.replace(/^data:.*?;base64,/, "");
|
|
3
|
+
}
|
|
4
|
+
export function isValidBase64(str) {
|
|
5
|
+
try {
|
|
6
|
+
const base64Content = extractBase64Content(str);
|
|
7
|
+
const decoded = Buffer.from(base64Content, "base64");
|
|
8
|
+
const reEncoded = decoded.toString("base64");
|
|
9
|
+
const normalizedOriginal = base64Content.replace(/=/g, "");
|
|
10
|
+
const normalizedReEncoded = reEncoded.replace(/=/g, "");
|
|
11
|
+
return normalizedOriginal === normalizedReEncoded;
|
|
12
|
+
}
|
|
13
|
+
catch {
|
|
14
|
+
return false;
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
export function detectImageFormatFromBase64(base64Content) {
|
|
18
|
+
try {
|
|
19
|
+
const buffer = Buffer.from(base64Content, "base64");
|
|
20
|
+
if (buffer.length >= 3 &&
|
|
21
|
+
buffer[0] === 0xff &&
|
|
22
|
+
buffer[1] === 0xd8 &&
|
|
23
|
+
buffer[2] === 0xff) {
|
|
24
|
+
return "image/jpeg";
|
|
25
|
+
}
|
|
26
|
+
if (buffer.length >= 8 &&
|
|
27
|
+
buffer[0] === 0x89 &&
|
|
28
|
+
buffer[1] === 0x50 &&
|
|
29
|
+
buffer[2] === 0x4e &&
|
|
30
|
+
buffer[3] === 0x47 &&
|
|
31
|
+
buffer[4] === 0x0d &&
|
|
32
|
+
buffer[5] === 0x0a &&
|
|
33
|
+
buffer[6] === 0x1a &&
|
|
34
|
+
buffer[7] === 0x0a) {
|
|
35
|
+
return "image/png";
|
|
36
|
+
}
|
|
37
|
+
if (buffer.length >= 6 &&
|
|
38
|
+
((buffer[0] === 0x47 &&
|
|
39
|
+
buffer[1] === 0x49 &&
|
|
40
|
+
buffer[2] === 0x46 &&
|
|
41
|
+
buffer[3] === 0x38 &&
|
|
42
|
+
buffer[4] === 0x37 &&
|
|
43
|
+
buffer[5] === 0x61) ||
|
|
44
|
+
(buffer[0] === 0x47 &&
|
|
45
|
+
buffer[1] === 0x49 &&
|
|
46
|
+
buffer[2] === 0x46 &&
|
|
47
|
+
buffer[3] === 0x38 &&
|
|
48
|
+
buffer[4] === 0x39 &&
|
|
49
|
+
buffer[5] === 0x61))) {
|
|
50
|
+
return "image/gif";
|
|
51
|
+
}
|
|
52
|
+
if (buffer.length >= 12 &&
|
|
53
|
+
buffer[0] === 0x52 &&
|
|
54
|
+
buffer[1] === 0x49 &&
|
|
55
|
+
buffer[2] === 0x46 &&
|
|
56
|
+
buffer[3] === 0x46 &&
|
|
57
|
+
buffer[8] === 0x57 &&
|
|
58
|
+
buffer[9] === 0x45 &&
|
|
59
|
+
buffer[10] === 0x42 &&
|
|
60
|
+
buffer[11] === 0x50) {
|
|
61
|
+
return "image/webp";
|
|
62
|
+
}
|
|
63
|
+
if (buffer.length >= 2 && buffer[0] === 0x42 && buffer[1] === 0x4d) {
|
|
64
|
+
return "image/bmp";
|
|
65
|
+
}
|
|
66
|
+
if (buffer.length >= 4 &&
|
|
67
|
+
((buffer[0] === 0x49 &&
|
|
68
|
+
buffer[1] === 0x49 &&
|
|
69
|
+
buffer[2] === 0x2a &&
|
|
70
|
+
buffer[3] === 0x00) ||
|
|
71
|
+
(buffer[0] === 0x4d &&
|
|
72
|
+
buffer[1] === 0x4d &&
|
|
73
|
+
buffer[2] === 0x00 &&
|
|
74
|
+
buffer[3] === 0x2a))) {
|
|
75
|
+
return "image/tiff";
|
|
76
|
+
}
|
|
77
|
+
return "unknown";
|
|
78
|
+
}
|
|
79
|
+
catch {
|
|
80
|
+
return "unknown";
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
export function extractMimeTypeFromDataUrl(dataUrl) {
|
|
84
|
+
const match = dataUrl.match(/^data:([^;]+);base64,/);
|
|
85
|
+
return match?.[1] ?? "image/png";
|
|
86
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../source/commands/pickup/index.ts"],"names":[],"mappings":"AAeA,OAAO,KAAK,EAAE,cAAc,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAQ/D,eAAO,MAAM,aAAa,GAAI,SAAS,cAAc,KAAG,WA0DvD,CAAC"}
|
|
@@ -0,0 +1,138 @@
|
|
|
1
|
+
import { getTerminalSize, isArrowDown, isArrowUp, isEnter, isEscape, } from "../../terminal/control.js";
|
|
2
|
+
import style from "../../terminal/style.js";
|
|
3
|
+
import { Input, Spacer, Text, Container as TuiContainer, } from "../../tui/index.js";
|
|
4
|
+
import { getAvailableHandoffFiles, hidePickupSelector, loadHandoff, } from "./utils.js";
|
|
5
|
+
export const pickupCommand = (options) => {
|
|
6
|
+
return {
|
|
7
|
+
command: "/pickup",
|
|
8
|
+
description: "Loads a handoff file into a new session to continue previous work. Usage: /pickup",
|
|
9
|
+
getSubCommands: () => Promise.resolve([]),
|
|
10
|
+
async handle(_args, { tui, container, inputContainer, editor, }) {
|
|
11
|
+
const handoffs = await getAvailableHandoffFiles();
|
|
12
|
+
if (handoffs.length === 0) {
|
|
13
|
+
container.addChild(new Text(style.yellow("No handoff files found."), 0, 1));
|
|
14
|
+
container.addChild(new Text("Create a handoff file first using /handoff <purpose>", 1, 0));
|
|
15
|
+
tui.requestRender();
|
|
16
|
+
editor.setText("");
|
|
17
|
+
return "continue";
|
|
18
|
+
}
|
|
19
|
+
const handoffSelector = new HandoffSelectorComponent(handoffs, async (handoff) => {
|
|
20
|
+
await loadHandoff(handoff, options, container, tui, editor);
|
|
21
|
+
hidePickupSelector(inputContainer, editor, tui);
|
|
22
|
+
}, () => {
|
|
23
|
+
hidePickupSelector(inputContainer, editor, tui);
|
|
24
|
+
});
|
|
25
|
+
inputContainer.clear();
|
|
26
|
+
inputContainer.addChild(handoffSelector);
|
|
27
|
+
tui.setFocus(handoffSelector);
|
|
28
|
+
tui.requestRender();
|
|
29
|
+
return "continue";
|
|
30
|
+
},
|
|
31
|
+
};
|
|
32
|
+
};
|
|
33
|
+
class HandoffSelectorComponent extends TuiContainer {
|
|
34
|
+
searchInput;
|
|
35
|
+
listContainer;
|
|
36
|
+
allHandoffs = [];
|
|
37
|
+
filteredHandoffs = [];
|
|
38
|
+
selectedIndex = 0;
|
|
39
|
+
onSelectCallback;
|
|
40
|
+
onCancelCallback;
|
|
41
|
+
constructor(handoffs, onSelect, onCancel) {
|
|
42
|
+
super();
|
|
43
|
+
this.onSelectCallback = onSelect;
|
|
44
|
+
this.onCancelCallback = onCancel;
|
|
45
|
+
this.allHandoffs = handoffs;
|
|
46
|
+
this.filteredHandoffs = handoffs;
|
|
47
|
+
const { columns } = getTerminalSize();
|
|
48
|
+
this.addChild(new Text(style.blue("─".repeat(columns)), 0, 0));
|
|
49
|
+
this.addChild(new Spacer(1));
|
|
50
|
+
this.searchInput = new Input();
|
|
51
|
+
this.searchInput.onSubmit = () => {
|
|
52
|
+
const handoff = this.filteredHandoffs[this.selectedIndex];
|
|
53
|
+
if (handoff !== undefined) {
|
|
54
|
+
this.handleSelect(handoff);
|
|
55
|
+
}
|
|
56
|
+
};
|
|
57
|
+
this.addChild(this.searchInput);
|
|
58
|
+
this.addChild(new Spacer(1));
|
|
59
|
+
this.listContainer = new TuiContainer();
|
|
60
|
+
this.addChild(this.listContainer);
|
|
61
|
+
this.addChild(new Spacer(1));
|
|
62
|
+
this.addChild(new Text(style.blue("─".repeat(columns)), 0, 0));
|
|
63
|
+
this.updateList();
|
|
64
|
+
}
|
|
65
|
+
filterHandoffs(query) {
|
|
66
|
+
if (!query.trim()) {
|
|
67
|
+
this.filteredHandoffs = this.allHandoffs;
|
|
68
|
+
}
|
|
69
|
+
else {
|
|
70
|
+
const searchTokens = query
|
|
71
|
+
.toLowerCase()
|
|
72
|
+
.split(/\s+/)
|
|
73
|
+
.filter((t) => t);
|
|
74
|
+
this.filteredHandoffs = this.allHandoffs.filter((handoff) => {
|
|
75
|
+
const searchText = handoff.name.toLowerCase();
|
|
76
|
+
return searchTokens.every((token) => searchText.includes(token));
|
|
77
|
+
});
|
|
78
|
+
}
|
|
79
|
+
this.selectedIndex = Math.min(this.selectedIndex, Math.max(0, this.filteredHandoffs.length - 1));
|
|
80
|
+
this.updateList();
|
|
81
|
+
}
|
|
82
|
+
updateList() {
|
|
83
|
+
this.listContainer.clear();
|
|
84
|
+
const maxVisible = 10;
|
|
85
|
+
const startIndex = Math.max(0, Math.min(this.selectedIndex - Math.floor(maxVisible / 2), this.filteredHandoffs.length - maxVisible));
|
|
86
|
+
const endIndex = Math.min(startIndex + maxVisible, this.filteredHandoffs.length);
|
|
87
|
+
for (let i = startIndex; i < endIndex; i++) {
|
|
88
|
+
const handoff = this.filteredHandoffs[i];
|
|
89
|
+
if (handoff === undefined)
|
|
90
|
+
continue;
|
|
91
|
+
const isSelected = i === this.selectedIndex;
|
|
92
|
+
let line = "";
|
|
93
|
+
if (isSelected) {
|
|
94
|
+
const prefix = style.blue("→ ");
|
|
95
|
+
const date = handoff.createdAt.toLocaleString();
|
|
96
|
+
line = `${prefix + style.blue(handoff.name)} ${style.gray(`(${date})`)}`;
|
|
97
|
+
}
|
|
98
|
+
else {
|
|
99
|
+
const date = handoff.createdAt.toLocaleString();
|
|
100
|
+
line = ` ${handoff.name} ${style.gray(`(${date})`)}`;
|
|
101
|
+
}
|
|
102
|
+
this.listContainer.addChild(new Text(line, 0, 0));
|
|
103
|
+
}
|
|
104
|
+
if (startIndex > 0 || endIndex < this.filteredHandoffs.length) {
|
|
105
|
+
const scrollInfo = style.gray(` (${this.selectedIndex + 1}/${this.filteredHandoffs.length})`);
|
|
106
|
+
this.listContainer.addChild(new Text(scrollInfo, 0, 0));
|
|
107
|
+
}
|
|
108
|
+
if (this.filteredHandoffs.length === 0) {
|
|
109
|
+
this.listContainer.addChild(new Text(style.gray(" No matching handoffs"), 0, 0));
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
handleInput(keyData) {
|
|
113
|
+
if (isArrowUp(keyData)) {
|
|
114
|
+
this.selectedIndex = Math.max(0, this.selectedIndex - 1);
|
|
115
|
+
this.updateList();
|
|
116
|
+
}
|
|
117
|
+
else if (isArrowDown(keyData)) {
|
|
118
|
+
this.selectedIndex = Math.min(this.filteredHandoffs.length - 1, this.selectedIndex + 1);
|
|
119
|
+
this.updateList();
|
|
120
|
+
}
|
|
121
|
+
else if (isEnter(keyData)) {
|
|
122
|
+
const selectedHandoff = this.filteredHandoffs[this.selectedIndex];
|
|
123
|
+
if (selectedHandoff !== undefined) {
|
|
124
|
+
this.handleSelect(selectedHandoff);
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
else if (isEscape(keyData)) {
|
|
128
|
+
this.onCancelCallback();
|
|
129
|
+
}
|
|
130
|
+
else {
|
|
131
|
+
this.searchInput.handleInput(keyData);
|
|
132
|
+
this.filterHandoffs(this.searchInput.getValue());
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
handleSelect(handoff) {
|
|
136
|
+
this.onSelectCallback(handoff);
|
|
137
|
+
}
|
|
138
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../source/commands/pickup/types.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,WAAW;IAC1B,IAAI,EAAE,MAAM,CAAC;IACb,QAAQ,EAAE,MAAM,CAAC;IACjB,SAAS,EAAE,IAAI,CAAC;CACjB"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { Container, Editor, TUI } from "../../tui/index.ts";
|
|
2
|
+
import type { CommandOptions } from "../types.ts";
|
|
3
|
+
import type { HandoffFile } from "./types.ts";
|
|
4
|
+
export declare function hidePickupSelector(editorContainer: Container, editor: Editor, tui: TUI): void;
|
|
5
|
+
export declare function getAvailableHandoffFiles(): Promise<HandoffFile[]>;
|
|
6
|
+
export declare function loadHandoff(handoff: HandoffFile, options: CommandOptions, container: Container, tui: TUI, editor: Editor): Promise<void>;
|
|
7
|
+
//# sourceMappingURL=utils.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../../source/commands/pickup/utils.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,oBAAoB,CAAC;AACjE,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAClD,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AAE9C,wBAAgB,kBAAkB,CAChC,eAAe,EAAE,SAAS,EAC1B,MAAM,EAAE,MAAM,EACd,GAAG,EAAE,GAAG,GACP,IAAI,CAIN;AAED,wBAAsB,wBAAwB,IAAI,OAAO,CAAC,WAAW,EAAE,CAAC,CA4BvE;AAED,wBAAsB,WAAW,CAC/B,OAAO,EAAE,WAAW,EACpB,OAAO,EAAE,cAAc,EACvB,SAAS,EAAE,SAAS,EACpB,GAAG,EAAE,GAAG,EACR,MAAM,EAAE,MAAM,GACb,OAAO,CAAC,IAAI,CAAC,CA8Cf"}
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import { readFile } from "node:fs/promises";
|
|
2
|
+
import { basename } from "node:path";
|
|
3
|
+
import { createUserMessage } from "../../sessions/manager.js";
|
|
4
|
+
export function hidePickupSelector(editorContainer, editor, tui) {
|
|
5
|
+
editorContainer.clear();
|
|
6
|
+
editorContainer.addChild(editor);
|
|
7
|
+
tui.setFocus(editor);
|
|
8
|
+
}
|
|
9
|
+
export async function getAvailableHandoffFiles() {
|
|
10
|
+
const handoffsDir = ".acai/handoffs";
|
|
11
|
+
try {
|
|
12
|
+
const { readdir, stat } = await import("node:fs/promises");
|
|
13
|
+
const dirents = await readdir(handoffsDir, {
|
|
14
|
+
withFileTypes: true,
|
|
15
|
+
});
|
|
16
|
+
const files = [];
|
|
17
|
+
for (const dirent of dirents) {
|
|
18
|
+
if (dirent.isFile() && dirent.name.match(/^handoff-.*\.md$/)) {
|
|
19
|
+
const filepath = `${handoffsDir}/${dirent.name}`;
|
|
20
|
+
const stats = await stat(filepath);
|
|
21
|
+
files.push({
|
|
22
|
+
name: basename(dirent.name, ".md"),
|
|
23
|
+
filename: dirent.name,
|
|
24
|
+
createdAt: stats.mtime,
|
|
25
|
+
});
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
files.sort((a, b) => b.createdAt.getTime() - a.createdAt.getTime());
|
|
29
|
+
return files;
|
|
30
|
+
}
|
|
31
|
+
catch (error) {
|
|
32
|
+
if (error.code === "ENOENT") {
|
|
33
|
+
return [];
|
|
34
|
+
}
|
|
35
|
+
return [];
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
export async function loadHandoff(handoff, options, container, tui, editor) {
|
|
39
|
+
const { sessionManager: messageHistory, modelManager } = options;
|
|
40
|
+
const filepath = `.acai/handoffs/${handoff.filename}`;
|
|
41
|
+
try {
|
|
42
|
+
const handoffContent = await readFile(filepath, "utf8");
|
|
43
|
+
container.addChild(new (await import("../../tui/index.js")).Text(`Loading handoff: ${(await import("../../terminal/style.js")).default.blue(handoff.name)}`, 0, 1));
|
|
44
|
+
messageHistory.create(modelManager.getModel("repl").modelId);
|
|
45
|
+
messageHistory.appendUserMessage(createUserMessage([], handoffContent));
|
|
46
|
+
container.addChild(new (await import("../../tui/index.js")).Text("Handoff loaded successfully.", 1, 0));
|
|
47
|
+
container.addChild(new (await import("../../tui/index.js")).Text("You can now continue with your previous work.", 2, 0));
|
|
48
|
+
tui.requestRender();
|
|
49
|
+
editor.setText("");
|
|
50
|
+
}
|
|
51
|
+
catch (error) {
|
|
52
|
+
container.addChild(new (await import("../../tui/index.js")).Text(`Error loading handoff: ${error}`, 0, 1));
|
|
53
|
+
tui.requestRender();
|
|
54
|
+
editor.setText("");
|
|
55
|
+
}
|
|
56
|
+
}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import type { CommandOptions, ReplCommand } from "../types.ts";
|
|
2
|
+
import type { PromptMetadata } from "./types.ts";
|
|
3
|
+
export declare function loadPrompts(config: CommandOptions["config"]): Promise<Map<string, PromptMetadata>>;
|
|
4
|
+
export declare const promptCommand: ({ modelManager, promptManager, config, promptHistory, workspace, }: CommandOptions) => ReplCommand;
|
|
5
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../source/commands/prompt/index.ts"],"names":[],"mappings":"AAOA,OAAO,KAAK,EAAE,cAAc,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAC/D,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AAOjD,wBAAsB,WAAW,CAAC,MAAM,EAAE,cAAc,CAAC,QAAQ,CAAC,wCA0DjE;AAED,eAAO,MAAM,aAAa,GAAI,oEAM3B,cAAc,KAAG,WA4GnB,CAAC"}
|
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
import { readdir, readFile } from "node:fs/promises";
|
|
2
|
+
import path, { basename } from "node:path";
|
|
3
|
+
import { logger } from "../../logger.js";
|
|
4
|
+
import { processPrompt } from "../../mentions.js";
|
|
5
|
+
import style from "../../terminal/style.js";
|
|
6
|
+
import { Spacer, Text } from "../../tui/index.js";
|
|
7
|
+
import { findPrompt, parsePromptFile, replaceArgumentPlaceholders, } from "./utils.js";
|
|
8
|
+
export async function loadPrompts(config) {
|
|
9
|
+
const getPromptsFromDir = async (dirPath, type) => {
|
|
10
|
+
try {
|
|
11
|
+
const dirents = await readdir(dirPath, { withFileTypes: true });
|
|
12
|
+
const mdFiles = dirents.filter((dirent) => dirent.isFile() && dirent.name.endsWith(".md"));
|
|
13
|
+
const prompts = [];
|
|
14
|
+
for (const dirent of mdFiles) {
|
|
15
|
+
const filePath = path.join(dirPath, dirent.name);
|
|
16
|
+
try {
|
|
17
|
+
const content = await readFile(filePath, "utf8");
|
|
18
|
+
const parsed = parsePromptFile(content);
|
|
19
|
+
if (parsed.metadata.enabled) {
|
|
20
|
+
prompts.push({
|
|
21
|
+
name: basename(dirent.name, ".md"),
|
|
22
|
+
description: parsed.metadata.description,
|
|
23
|
+
enabled: parsed.metadata.enabled,
|
|
24
|
+
path: filePath,
|
|
25
|
+
type,
|
|
26
|
+
});
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
catch (error) {
|
|
30
|
+
logger.error(`Error reading prompt file ${filePath}: ${error}`);
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
return prompts;
|
|
34
|
+
}
|
|
35
|
+
catch (error) {
|
|
36
|
+
if (error.code === "ENOENT") {
|
|
37
|
+
return [];
|
|
38
|
+
}
|
|
39
|
+
logger.error(`Error reading prompts from ${dirPath}: ${error}`);
|
|
40
|
+
return [];
|
|
41
|
+
}
|
|
42
|
+
};
|
|
43
|
+
const userPromptDir = config.app.getPath("prompts");
|
|
44
|
+
const projectPromptDir = config.project.getPath("prompts");
|
|
45
|
+
const userPrompts = await getPromptsFromDir(userPromptDir, "user");
|
|
46
|
+
const projectPrompts = await getPromptsFromDir(projectPromptDir, "project");
|
|
47
|
+
const promptMap = new Map();
|
|
48
|
+
for (const prompt of userPrompts) {
|
|
49
|
+
promptMap.set(prompt.name, prompt);
|
|
50
|
+
}
|
|
51
|
+
for (const prompt of projectPrompts) {
|
|
52
|
+
promptMap.set(prompt.name, prompt);
|
|
53
|
+
}
|
|
54
|
+
return promptMap;
|
|
55
|
+
}
|
|
56
|
+
export const promptCommand = ({ modelManager, promptManager, config, promptHistory, workspace, }) => {
|
|
57
|
+
return {
|
|
58
|
+
command: "/prompt",
|
|
59
|
+
description: "Loads and executes prompts. Project prompts override user prompts with the same name.",
|
|
60
|
+
getSubCommands: async () => {
|
|
61
|
+
const promptMap = await loadPrompts(config);
|
|
62
|
+
const promptList = Array.from(promptMap.values())
|
|
63
|
+
.map((p) => p.name)
|
|
64
|
+
.sort();
|
|
65
|
+
return promptList;
|
|
66
|
+
},
|
|
67
|
+
async handle(args, { tui, container, editor, }) {
|
|
68
|
+
const promptName = args?.[0];
|
|
69
|
+
if (!promptName) {
|
|
70
|
+
container.addChild(new Text(style.red("No prompt given."), 1, 0));
|
|
71
|
+
tui.requestRender();
|
|
72
|
+
editor.setText("");
|
|
73
|
+
return "continue";
|
|
74
|
+
}
|
|
75
|
+
try {
|
|
76
|
+
const promptResult = await findPrompt(promptName, config);
|
|
77
|
+
if (!promptResult) {
|
|
78
|
+
container.addChild(new Text(style.red(`Prompt not found: ${promptName}. Available prompts can be seen with tab completion.`), 1, 0));
|
|
79
|
+
tui.requestRender();
|
|
80
|
+
editor.setText("");
|
|
81
|
+
return "continue";
|
|
82
|
+
}
|
|
83
|
+
let promptContent;
|
|
84
|
+
try {
|
|
85
|
+
const fileContent = await readFile(promptResult.path, "utf8");
|
|
86
|
+
const parsed = parsePromptFile(fileContent);
|
|
87
|
+
promptContent = parsed.content;
|
|
88
|
+
}
|
|
89
|
+
catch (error) {
|
|
90
|
+
if (error.code === "ENOENT") {
|
|
91
|
+
container.addChild(new Text(style.red(`Prompt file not found: ${promptName} at ${promptResult.path}`), 1, 0));
|
|
92
|
+
tui.requestRender();
|
|
93
|
+
editor.setText("");
|
|
94
|
+
return "continue";
|
|
95
|
+
}
|
|
96
|
+
throw error;
|
|
97
|
+
}
|
|
98
|
+
const inputArgs = args.slice(1);
|
|
99
|
+
promptContent = replaceArgumentPlaceholders(promptContent, inputArgs);
|
|
100
|
+
container.addChild(new Spacer(1));
|
|
101
|
+
const processedPrompt = await processPrompt(promptContent.trim(), {
|
|
102
|
+
baseDir: workspace.primaryDir,
|
|
103
|
+
model: modelManager.getModelMetadata("repl"),
|
|
104
|
+
});
|
|
105
|
+
for (const context of processedPrompt.context) {
|
|
106
|
+
promptManager.addContext(context);
|
|
107
|
+
}
|
|
108
|
+
promptManager.set(processedPrompt.message);
|
|
109
|
+
promptHistory.push(processedPrompt.message);
|
|
110
|
+
tui.requestRender();
|
|
111
|
+
editor.setText("");
|
|
112
|
+
return "use";
|
|
113
|
+
}
|
|
114
|
+
catch (error) {
|
|
115
|
+
container.addChild(new Text(style.red(`Error loading prompt: ${error.message}`), 1, 0));
|
|
116
|
+
tui.requestRender();
|
|
117
|
+
editor.setText("");
|
|
118
|
+
return "continue";
|
|
119
|
+
}
|
|
120
|
+
},
|
|
121
|
+
};
|
|
122
|
+
};
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
export interface PromptMetadata {
|
|
2
|
+
name: string;
|
|
3
|
+
description: string;
|
|
4
|
+
enabled: boolean;
|
|
5
|
+
path: string;
|
|
6
|
+
type: "project" | "user";
|
|
7
|
+
}
|
|
8
|
+
export interface ParsedPrompt {
|
|
9
|
+
content: string;
|
|
10
|
+
metadata: {
|
|
11
|
+
description: string;
|
|
12
|
+
enabled: boolean;
|
|
13
|
+
};
|
|
14
|
+
}
|
|
15
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../source/commands/prompt/types.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,cAAc;IAC7B,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,EAAE,MAAM,CAAC;IACpB,OAAO,EAAE,OAAO,CAAC;IACjB,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,SAAS,GAAG,MAAM,CAAC;CAC1B;AAED,MAAM,WAAW,YAAY;IAC3B,OAAO,EAAE,MAAM,CAAC;IAChB,QAAQ,EAAE;QACR,WAAW,EAAE,MAAM,CAAC;QACpB,OAAO,EAAE,OAAO,CAAC;KAClB,CAAC;CACH"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { ConfigManager } from "../../config.ts";
|
|
2
|
+
import type { PromptMetadata } from "./types.ts";
|
|
3
|
+
export declare function replaceArgumentPlaceholders(content: string, args: string[]): string;
|
|
4
|
+
export declare function parsePromptFile(content: string): {
|
|
5
|
+
content: string;
|
|
6
|
+
metadata: {
|
|
7
|
+
description: string;
|
|
8
|
+
enabled: boolean;
|
|
9
|
+
};
|
|
10
|
+
};
|
|
11
|
+
export declare function findPrompt(promptName: string, config: ConfigManager): Promise<PromptMetadata | null>;
|
|
12
|
+
//# sourceMappingURL=utils.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../../source/commands/prompt/utils.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AACrD,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AAEjD,wBAAgB,2BAA2B,CACzC,OAAO,EAAE,MAAM,EACf,IAAI,EAAE,MAAM,EAAE,GACb,MAAM,CA6BR;AAED,wBAAgB,eAAe,CAAC,OAAO,EAAE,MAAM,GAAG;IAChD,OAAO,EAAE,MAAM,CAAC;IAChB,QAAQ,EAAE;QACR,WAAW,EAAE,MAAM,CAAC;QACpB,OAAO,EAAE,OAAO,CAAC;KAClB,CAAC;CACH,CA4CA;AAED,wBAAsB,UAAU,CAC9B,UAAU,EAAE,MAAM,EAClB,MAAM,EAAE,aAAa,GACpB,OAAO,CAAC,cAAc,GAAG,IAAI,CAAC,CAoDhC"}
|