@travisennis/acai 0.0.9 → 0.0.11
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 +51 -760
- package/bin/acai +52 -0
- package/dist/agent/index.d.ts +12 -2
- package/dist/agent/index.d.ts.map +1 -1
- package/dist/agent/index.js +380 -199
- package/dist/agent/sub-agent.d.ts +23 -0
- package/dist/agent/sub-agent.d.ts.map +1 -0
- package/dist/agent/sub-agent.js +109 -0
- package/dist/cli/index.d.ts +26 -0
- package/dist/cli/index.d.ts.map +1 -0
- package/dist/{cli.js → cli/index.js} +84 -77
- package/dist/{stdin.d.ts → cli/stdin.d.ts} +2 -1
- package/dist/cli/stdin.d.ts.map +1 -0
- package/dist/{stdin.js → cli/stdin.js} +11 -0
- package/dist/commands/copy/index.js +2 -2
- package/dist/commands/copy/utils.d.ts.map +1 -1
- package/dist/commands/copy/utils.js +15 -13
- package/dist/commands/generate-rules/index.d.ts +1 -1
- package/dist/commands/generate-rules/index.d.ts.map +1 -1
- package/dist/commands/generate-rules/index.js +16 -101
- package/dist/commands/generate-rules/service.d.ts +22 -0
- package/dist/commands/generate-rules/service.d.ts.map +1 -0
- package/dist/commands/generate-rules/service.js +103 -0
- package/dist/commands/handoff/index.js +2 -2
- package/dist/commands/health/index.js +1 -1
- package/dist/commands/health/utils.d.ts +3 -2
- package/dist/commands/health/utils.d.ts.map +1 -1
- package/dist/commands/health/utils.js +6 -0
- package/dist/commands/history/index.d.ts +1 -1
- package/dist/commands/history/index.d.ts.map +1 -1
- package/dist/commands/history/index.js +17 -18
- package/dist/commands/history/types.d.ts +38 -0
- package/dist/commands/history/types.d.ts.map +1 -1
- package/dist/commands/history/utils.d.ts.map +1 -1
- package/dist/commands/history/utils.js +63 -58
- package/dist/commands/init/index.d.ts.map +1 -1
- package/dist/commands/init/index.js +3 -8
- package/dist/commands/init-project/index.d.ts.map +1 -1
- package/dist/commands/init-project/index.js +3 -3
- package/dist/commands/init-project/utils.d.ts +2 -1
- package/dist/commands/init-project/utils.d.ts.map +1 -1
- package/dist/commands/init-project/utils.js +10 -2
- package/dist/commands/list-tools/index.d.ts.map +1 -1
- package/dist/commands/list-tools/index.js +7 -31
- package/dist/commands/manager.d.ts +2 -2
- package/dist/commands/manager.d.ts.map +1 -1
- package/dist/commands/manager.js +55 -33
- package/dist/commands/model/index.d.ts.map +1 -1
- package/dist/commands/model/index.js +20 -151
- package/dist/commands/model/model-panel.d.ts +4 -0
- package/dist/commands/model/model-panel.d.ts.map +1 -0
- package/dist/commands/model/model-panel.js +144 -0
- package/dist/commands/paste/index.d.ts.map +1 -1
- package/dist/commands/paste/index.js +59 -62
- package/dist/commands/paste/utils.d.ts.map +1 -1
- package/dist/commands/paste/utils.js +88 -58
- package/dist/commands/pickup/index.d.ts.map +1 -1
- package/dist/commands/pickup/index.js +6 -3
- package/dist/commands/pickup/utils.js +3 -3
- package/dist/commands/resources/index.d.ts.map +1 -1
- package/dist/commands/resources/index.js +33 -50
- package/dist/commands/review/index.d.ts.map +1 -1
- package/dist/commands/review/index.js +3 -117
- package/dist/commands/review/review-panel.d.ts +3 -0
- package/dist/commands/review/review-panel.d.ts.map +1 -0
- package/dist/commands/review/review-panel.js +186 -0
- package/dist/commands/review/utils.d.ts +15 -1
- package/dist/commands/review/utils.d.ts.map +1 -1
- package/dist/commands/review/utils.js +127 -68
- package/dist/commands/session/index.d.ts +1 -1
- package/dist/commands/session/index.d.ts.map +1 -1
- package/dist/commands/session/index.js +124 -135
- package/dist/commands/shell/index.d.ts.map +1 -1
- package/dist/commands/shell/index.js +16 -1
- package/dist/commands/types.d.ts +2 -2
- package/dist/commands/types.d.ts.map +1 -1
- package/dist/{config.d.ts → config/index.d.ts} +20 -9
- package/dist/config/index.d.ts.map +1 -0
- package/dist/{config.js → config/index.js} +43 -42
- package/dist/execution/index.d.ts.map +1 -1
- package/dist/execution/index.js +75 -55
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +148 -141
- package/dist/middleware/cache.d.ts.map +1 -1
- package/dist/middleware/cache.js +18 -36
- package/dist/models/ai-config.d.ts +1 -0
- package/dist/models/ai-config.d.ts.map +1 -1
- package/dist/models/ai-config.js +4 -3
- package/dist/models/anthropic-provider.d.ts +2 -5
- package/dist/models/anthropic-provider.d.ts.map +1 -1
- package/dist/models/anthropic-provider.js +3 -70
- package/dist/models/deepseek-provider.d.ts +1 -0
- package/dist/models/deepseek-provider.d.ts.map +1 -1
- package/dist/models/google-provider.d.ts +2 -3
- package/dist/models/google-provider.d.ts.map +1 -1
- package/dist/models/google-provider.js +0 -26
- package/dist/models/groq-provider.d.ts +1 -0
- package/dist/models/groq-provider.d.ts.map +1 -1
- package/dist/models/manager.d.ts +13 -2
- package/dist/models/manager.d.ts.map +1 -1
- package/dist/models/manager.js +20 -8
- package/dist/models/openai-provider.d.ts +2 -5
- package/dist/models/openai-provider.d.ts.map +1 -1
- package/dist/models/openai-provider.js +0 -52
- package/dist/models/opencode-go-provider.d.ts +25 -0
- package/dist/models/opencode-go-provider.d.ts.map +1 -0
- package/dist/models/opencode-go-provider.js +78 -0
- package/dist/models/opencode-zen-provider.d.ts +7 -3
- package/dist/models/opencode-zen-provider.d.ts.map +1 -1
- package/dist/models/opencode-zen-provider.js +49 -10
- package/dist/models/openrouter-provider.d.ts +27 -31
- package/dist/models/openrouter-provider.d.ts.map +1 -1
- package/dist/models/openrouter-provider.js +121 -180
- package/dist/models/providers.d.ts +3 -3
- package/dist/models/providers.d.ts.map +1 -1
- package/dist/models/providers.js +6 -0
- package/dist/models/xai-provider.d.ts +4 -3
- package/dist/models/xai-provider.d.ts.map +1 -1
- package/dist/models/xai-provider.js +18 -18
- package/dist/modes/manager.d.ts +24 -0
- package/dist/modes/manager.d.ts.map +1 -0
- package/dist/modes/manager.js +77 -0
- package/dist/modes/prompts.d.ts +2 -0
- package/dist/modes/prompts.d.ts.map +1 -0
- package/dist/modes/prompts.js +142 -0
- package/dist/prompts/mentions.d.ts +11 -0
- package/dist/prompts/mentions.d.ts.map +1 -0
- package/dist/{mentions.js → prompts/mentions.js} +55 -85
- package/dist/{prompts.d.ts → prompts/system-prompt.d.ts} +7 -2
- package/dist/prompts/system-prompt.d.ts.map +1 -0
- package/dist/{prompts.js → prompts/system-prompt.js} +31 -16
- package/dist/repl/index.d.ts +174 -0
- package/dist/repl/index.d.ts.map +1 -0
- package/dist/{repl-new.js → repl/index.js} +397 -76
- package/dist/repl/project-status.d.ts +1 -0
- package/dist/repl/project-status.d.ts.map +1 -1
- package/dist/repl/project-status.js +4 -1
- package/dist/sessions/manager.d.ts +92 -0
- package/dist/sessions/manager.d.ts.map +1 -1
- package/dist/sessions/manager.js +262 -9
- package/dist/sessions/summary.d.ts +4 -0
- package/dist/sessions/summary.d.ts.map +1 -0
- package/dist/sessions/summary.js +30 -0
- package/dist/skills/index.d.ts +29 -0
- package/dist/skills/index.d.ts.map +1 -0
- package/dist/skills/index.js +294 -0
- package/dist/subagents/index.d.ts +16 -0
- package/dist/subagents/index.d.ts.map +1 -0
- package/dist/subagents/index.js +231 -0
- package/dist/terminal/control.d.ts +1 -1
- package/dist/terminal/control.d.ts.map +1 -1
- package/dist/terminal/control.js +3 -3
- package/dist/terminal/east-asian-width.d.ts.map +1 -1
- package/dist/terminal/east-asian-width.js +404 -351
- package/dist/terminal/keys.d.ts +17 -0
- package/dist/terminal/keys.d.ts.map +1 -1
- package/dist/terminal/keys.js +37 -0
- package/dist/terminal/select-prompt.d.ts.map +1 -1
- package/dist/terminal/select-prompt.js +24 -12
- package/dist/terminal/string-width.d.ts.map +1 -1
- package/dist/terminal/string-width.js +25 -27
- package/dist/terminal/style.d.ts.map +1 -1
- package/dist/terminal/style.js +4 -7
- package/dist/terminal/supports-color.d.ts.map +1 -1
- package/dist/terminal/supports-color.js +41 -27
- package/dist/terminal/table/cell.d.ts +12 -0
- package/dist/terminal/table/cell.d.ts.map +1 -1
- package/dist/terminal/table/cell.js +40 -25
- package/dist/terminal/table/layout-manager.d.ts.map +1 -1
- package/dist/terminal/table/layout-manager.js +100 -68
- package/dist/terminal/table/utils.d.ts +1 -1
- package/dist/terminal/table/utils.d.ts.map +1 -1
- package/dist/terminal/table/utils.js +17 -10
- package/dist/terminal/wrap-ansi.d.ts.map +1 -1
- package/dist/terminal/wrap-ansi.js +174 -105
- package/dist/tokens/tracker.d.ts +1 -0
- package/dist/tokens/tracker.d.ts.map +1 -1
- package/dist/tokens/tracker.js +3 -0
- package/dist/tools/agent.d.ts +27 -0
- package/dist/tools/agent.d.ts.map +1 -0
- package/dist/tools/agent.js +81 -0
- package/dist/tools/apply-patch.d.ts +62 -0
- package/dist/tools/apply-patch.d.ts.map +1 -0
- package/dist/tools/apply-patch.js +377 -0
- package/dist/tools/bash.d.ts +4 -3
- package/dist/tools/bash.d.ts.map +1 -1
- package/dist/tools/bash.js +349 -141
- package/dist/tools/directory-tree.d.ts +3 -3
- package/dist/tools/directory-tree.d.ts.map +1 -1
- package/dist/tools/directory-tree.js +8 -5
- package/dist/tools/dynamic-tool-loader.d.ts +3 -6
- package/dist/tools/dynamic-tool-loader.d.ts.map +1 -1
- package/dist/tools/dynamic-tool-loader.js +20 -4
- package/dist/tools/edit-file.d.ts +7 -7
- package/dist/tools/edit-file.d.ts.map +1 -1
- package/dist/tools/edit-file.js +292 -85
- package/dist/tools/glob.d.ts +6 -6
- package/dist/tools/glob.d.ts.map +1 -1
- package/dist/tools/glob.js +110 -63
- package/dist/tools/grep.d.ts +15 -12
- package/dist/tools/grep.d.ts.map +1 -1
- package/dist/tools/grep.js +315 -193
- package/dist/tools/index.d.ts +114 -9
- package/dist/tools/index.d.ts.map +1 -1
- package/dist/tools/index.js +39 -24
- package/dist/tools/ls.d.ts +2 -2
- package/dist/tools/ls.d.ts.map +1 -1
- package/dist/tools/ls.js +7 -5
- package/dist/tools/read-file.d.ts +4 -6
- package/dist/tools/read-file.d.ts.map +1 -1
- package/dist/tools/read-file.js +84 -39
- package/dist/tools/save-file.d.ts +3 -3
- package/dist/tools/save-file.d.ts.map +1 -1
- package/dist/tools/save-file.js +36 -31
- package/dist/tools/skill.d.ts +23 -0
- package/dist/tools/skill.d.ts.map +1 -0
- package/dist/tools/skill.js +65 -0
- package/dist/tools/think.d.ts.map +1 -1
- package/dist/tools/think.js +2 -9
- package/dist/tools/utils.d.ts +2 -0
- package/dist/tools/utils.d.ts.map +1 -1
- package/dist/tools/utils.js +12 -0
- package/dist/tools/web-fetch.d.ts +50 -0
- package/dist/tools/web-fetch.d.ts.map +1 -0
- package/dist/tools/web-fetch.js +446 -0
- package/dist/tools/web-search.d.ts +44 -0
- package/dist/tools/web-search.d.ts.map +1 -0
- package/dist/tools/web-search.js +226 -0
- package/dist/tui/autocomplete/attachment-provider.d.ts +3 -6
- package/dist/tui/autocomplete/attachment-provider.d.ts.map +1 -1
- package/dist/tui/autocomplete/attachment-provider.js +25 -78
- package/dist/tui/autocomplete/base-provider.d.ts +1 -0
- package/dist/tui/autocomplete/base-provider.d.ts.map +1 -1
- package/dist/tui/autocomplete/combined-provider.d.ts +1 -4
- package/dist/tui/autocomplete/combined-provider.d.ts.map +1 -1
- package/dist/tui/autocomplete/combined-provider.js +3 -17
- package/dist/tui/autocomplete/command-provider.d.ts +1 -0
- package/dist/tui/autocomplete/command-provider.d.ts.map +1 -1
- package/dist/tui/autocomplete/command-provider.js +3 -0
- package/dist/tui/autocomplete/file-search-provider.d.ts +2 -1
- package/dist/tui/autocomplete/file-search-provider.d.ts.map +1 -1
- package/dist/tui/autocomplete/file-search-provider.js +37 -17
- package/dist/tui/autocomplete/skill-provider.d.ts +17 -0
- package/dist/tui/autocomplete/skill-provider.d.ts.map +1 -0
- package/dist/tui/autocomplete/skill-provider.js +49 -0
- package/dist/tui/autocomplete/utils.d.ts +2 -1
- package/dist/tui/autocomplete/utils.d.ts.map +1 -1
- package/dist/tui/autocomplete/utils.js +25 -23
- package/dist/tui/autocomplete.d.ts +2 -2
- package/dist/tui/autocomplete.d.ts.map +1 -1
- package/dist/tui/autocomplete.js +3 -5
- package/dist/tui/components/assistant-message.d.ts.map +1 -1
- package/dist/tui/components/assistant-message.js +0 -4
- package/dist/tui/components/editor.d.ts +18 -3
- package/dist/tui/components/editor.d.ts.map +1 -1
- package/dist/tui/components/editor.js +211 -237
- package/dist/tui/components/footer.d.ts +6 -4
- package/dist/tui/components/footer.d.ts.map +1 -1
- package/dist/tui/components/footer.js +49 -25
- package/dist/tui/components/markdown.d.ts +10 -7
- package/dist/tui/components/markdown.d.ts.map +1 -1
- package/dist/tui/components/markdown.js +57 -39
- package/dist/tui/components/modal.d.ts.map +1 -1
- package/dist/tui/components/modal.js +35 -33
- package/dist/tui/components/notification.d.ts +13 -2
- package/dist/tui/components/notification.d.ts.map +1 -1
- package/dist/tui/components/notification.js +36 -2
- package/dist/tui/components/progress-bar.js +1 -1
- package/dist/tui/components/select-list.d.ts +1 -0
- package/dist/tui/components/select-list.d.ts.map +1 -1
- package/dist/tui/components/select-list.js +14 -11
- package/dist/tui/components/text.d.ts +16 -0
- package/dist/tui/components/text.d.ts.map +1 -1
- package/dist/tui/components/text.js +72 -57
- package/dist/tui/components/thinking-block.d.ts +9 -0
- package/dist/tui/components/thinking-block.d.ts.map +1 -1
- package/dist/tui/components/thinking-block.js +43 -11
- package/dist/tui/components/tool-execution.d.ts +5 -1
- package/dist/tui/components/tool-execution.d.ts.map +1 -1
- package/dist/tui/components/tool-execution.js +19 -10
- package/dist/tui/components/user-message.d.ts.map +1 -1
- package/dist/tui/components/user-message.js +0 -3
- package/dist/tui/components/welcome.d.ts +2 -1
- package/dist/tui/components/welcome.d.ts.map +1 -1
- package/dist/tui/components/welcome.js +2 -2
- package/dist/tui/editor-launcher.d.ts +3 -2
- package/dist/tui/editor-launcher.d.ts.map +1 -1
- package/dist/tui/index.d.ts +0 -1
- package/dist/tui/index.d.ts.map +1 -1
- package/dist/tui/terminal.d.ts.map +1 -1
- package/dist/tui/terminal.js +10 -2
- package/dist/tui/tui.d.ts +43 -0
- package/dist/tui/tui.d.ts.map +1 -1
- package/dist/tui/tui.js +166 -41
- package/dist/tui/utils.d.ts +1 -5
- package/dist/tui/utils.d.ts.map +1 -1
- package/dist/tui/utils.js +271 -44
- package/dist/utils/bash/parse.d.ts +19 -0
- package/dist/utils/bash/parse.d.ts.map +1 -0
- package/dist/utils/bash/parse.js +223 -0
- package/dist/utils/bash/quote.d.ts +6 -0
- package/dist/utils/bash/quote.d.ts.map +1 -0
- package/dist/utils/bash/quote.js +23 -0
- package/dist/utils/bash.d.ts.map +1 -1
- package/dist/utils/bash.js +211 -126
- package/dist/utils/command-protection.d.ts +28 -0
- package/dist/utils/command-protection.d.ts.map +1 -0
- package/dist/utils/command-protection.js +324 -0
- package/dist/utils/dedent.d.ts.map +1 -0
- package/dist/utils/env-expand.d.ts +2 -0
- package/dist/utils/env-expand.d.ts.map +1 -0
- package/dist/utils/env-expand.js +8 -0
- package/dist/utils/filesystem/path-display.d.ts +11 -0
- package/dist/utils/filesystem/path-display.d.ts.map +1 -0
- package/dist/utils/filesystem/path-display.js +32 -0
- package/dist/utils/filesystem/security.d.ts +2 -2
- package/dist/utils/filesystem/security.d.ts.map +1 -1
- package/dist/utils/filesystem/security.js +28 -30
- package/dist/utils/formatting.d.ts.map +1 -0
- package/dist/{formatting.js → utils/formatting.js} +1 -1
- package/dist/utils/git.d.ts +4 -0
- package/dist/utils/git.d.ts.map +1 -1
- package/dist/utils/git.js +30 -0
- package/dist/utils/glob.d.ts +1 -1
- package/dist/utils/glob.d.ts.map +1 -1
- package/dist/utils/logger.d.ts.map +1 -0
- package/dist/{logger.js → utils/logger.js} +1 -1
- package/dist/utils/parsing.d.ts.map +1 -0
- package/dist/utils/process.d.ts.map +1 -1
- package/dist/utils/process.js +90 -37
- package/dist/utils/templates.d.ts +2 -0
- package/dist/utils/templates.d.ts.map +1 -0
- package/dist/utils/templates.js +24 -0
- package/dist/utils/version.d.ts.map +1 -0
- package/dist/{version.js → utils/version.js} +1 -1
- package/package.json +35 -26
- package/dist/cli.d.ts +0 -23
- package/dist/cli.d.ts.map +0 -1
- package/dist/commands/add-directory/types.d.ts +0 -6
- package/dist/commands/add-directory/types.d.ts.map +0 -1
- package/dist/commands/add-directory/types.js +0 -1
- package/dist/commands/copy/types.d.ts +0 -3
- package/dist/commands/copy/types.d.ts.map +0 -1
- package/dist/commands/copy/types.js +0 -1
- package/dist/commands/exit/index.d.ts +0 -10
- package/dist/commands/exit/index.d.ts.map +0 -1
- package/dist/commands/exit/index.js +0 -21
- package/dist/commands/exit/types.d.ts +0 -8
- package/dist/commands/exit/types.d.ts.map +0 -1
- package/dist/commands/exit/types.js +0 -1
- package/dist/commands/exit/utils.d.ts +0 -2
- package/dist/commands/exit/utils.d.ts.map +0 -1
- package/dist/commands/exit/utils.js +0 -13
- package/dist/commands/prompt/index.d.ts +0 -5
- package/dist/commands/prompt/index.d.ts.map +0 -1
- package/dist/commands/prompt/index.js +0 -122
- package/dist/commands/prompt/types.d.ts +0 -15
- package/dist/commands/prompt/types.d.ts.map +0 -1
- package/dist/commands/prompt/types.js +0 -1
- package/dist/commands/prompt/utils.d.ts +0 -12
- package/dist/commands/prompt/utils.d.ts.map +0 -1
- package/dist/commands/prompt/utils.js +0 -107
- package/dist/commands/reset/index.d.ts +0 -3
- package/dist/commands/reset/index.d.ts.map +0 -1
- package/dist/commands/reset/index.js +0 -25
- package/dist/commands/reset/types.d.ts +0 -1
- package/dist/commands/reset/types.d.ts.map +0 -1
- package/dist/commands/reset/types.js +0 -3
- package/dist/commands/review/types.d.ts +0 -12
- package/dist/commands/review/types.d.ts.map +0 -1
- package/dist/commands/review/types.js +0 -1
- package/dist/commands/save/index.d.ts +0 -3
- package/dist/commands/save/index.d.ts.map +0 -1
- package/dist/commands/save/index.js +0 -19
- package/dist/config.d.ts.map +0 -1
- package/dist/dedent.d.ts.map +0 -1
- package/dist/formatting.d.ts.map +0 -1
- package/dist/logger.d.ts.map +0 -1
- package/dist/mentions.d.ts +0 -14
- package/dist/mentions.d.ts.map +0 -1
- package/dist/parsing.d.ts.map +0 -1
- package/dist/prompts.d.ts.map +0 -1
- package/dist/repl-new.d.ts +0 -65
- package/dist/repl-new.d.ts.map +0 -1
- package/dist/skills.d.ts +0 -16
- package/dist/skills.d.ts.map +0 -1
- package/dist/skills.js +0 -233
- package/dist/stdin.d.ts.map +0 -1
- package/dist/tui/autocomplete/path-provider.d.ts +0 -21
- package/dist/tui/autocomplete/path-provider.d.ts.map +0 -1
- package/dist/tui/autocomplete/path-provider.js +0 -164
- package/dist/utils/iterables.d.ts +0 -2
- package/dist/utils/iterables.d.ts.map +0 -1
- package/dist/utils/iterables.js +0 -6
- package/dist/version.d.ts.map +0 -1
- /package/dist/{dedent.d.ts → utils/dedent.d.ts} +0 -0
- /package/dist/{dedent.js → utils/dedent.js} +0 -0
- /package/dist/{formatting.d.ts → utils/formatting.d.ts} +0 -0
- /package/dist/{logger.d.ts → utils/logger.d.ts} +0 -0
- /package/dist/{parsing.d.ts → utils/parsing.d.ts} +0 -0
- /package/dist/{parsing.js → utils/parsing.js} +0 -0
- /package/dist/{version.d.ts → utils/version.d.ts} +0 -0
|
@@ -1,70 +1,71 @@
|
|
|
1
1
|
import Clipboard from "@crosscopy/clipboard";
|
|
2
|
-
import { formatBlock } from "../../formatting.js";
|
|
3
|
-
import { logger } from "../../logger.js";
|
|
4
2
|
import style from "../../terminal/style.js";
|
|
5
3
|
import { Text } from "../../tui/index.js";
|
|
6
|
-
import {
|
|
4
|
+
import { formatBlock } from "../../utils/formatting.js";
|
|
5
|
+
import { logger } from "../../utils/logger.js";
|
|
6
|
+
import { detectImageFormatFromBase64, extractBase64Content, extractMimeTypeFromDataUrl, isValidBase64, } from "./utils.js";
|
|
7
|
+
function resolveMimeType(base64DataUrl) {
|
|
8
|
+
try {
|
|
9
|
+
const dataUrlMimeType = extractMimeTypeFromDataUrl(base64DataUrl);
|
|
10
|
+
const base64Content = extractBase64Content(base64DataUrl);
|
|
11
|
+
const detectedFormat = detectImageFormatFromBase64(base64Content);
|
|
12
|
+
if (detectedFormat === "unknown") {
|
|
13
|
+
logger.warn(`Could not detect image format, using data URL MIME type: ${dataUrlMimeType}`);
|
|
14
|
+
return dataUrlMimeType;
|
|
15
|
+
}
|
|
16
|
+
if (dataUrlMimeType !== detectedFormat) {
|
|
17
|
+
logger.warn(`Clipboard library reported ${dataUrlMimeType} but actual image format is ${detectedFormat}. Using detected format.`);
|
|
18
|
+
}
|
|
19
|
+
return detectedFormat;
|
|
20
|
+
}
|
|
21
|
+
catch (error) {
|
|
22
|
+
logger.warn(`Failed to extract MIME type from clipboard image: ${error}`);
|
|
23
|
+
return "image/png";
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
function buildImageDataUrl(base64DataUrl, mimeType) {
|
|
27
|
+
if (base64DataUrl.startsWith(`data:${mimeType};base64,`)) {
|
|
28
|
+
return { dataUrl: base64DataUrl, valid: true };
|
|
29
|
+
}
|
|
30
|
+
const base64Content = extractBase64Content(base64DataUrl);
|
|
31
|
+
const correctedDataUrl = `data:${mimeType};base64,${base64Content}`;
|
|
32
|
+
return { dataUrl: correctedDataUrl, valid: isValidBase64(correctedDataUrl) };
|
|
33
|
+
}
|
|
34
|
+
function showMessage(ctx, message) {
|
|
35
|
+
ctx.container.addChild(new Text(message, 1, 0));
|
|
36
|
+
ctx.tui.requestRender();
|
|
37
|
+
ctx.editor.setText("");
|
|
38
|
+
}
|
|
39
|
+
async function handleImagePaste(ctx, promptManager) {
|
|
40
|
+
const base64DataUrl = await Clipboard.getImageBase64();
|
|
41
|
+
if (!isValidBase64(base64DataUrl)) {
|
|
42
|
+
showMessage(ctx, style.red("Invalid base64 data in clipboard. The image data may be corrupted."));
|
|
43
|
+
return "continue";
|
|
44
|
+
}
|
|
45
|
+
const mimeType = resolveMimeType(base64DataUrl);
|
|
46
|
+
const { dataUrl, valid } = buildImageDataUrl(base64DataUrl, mimeType);
|
|
47
|
+
if (!valid) {
|
|
48
|
+
showMessage(ctx, style.red("Failed to correct base64 data format. The image data may be corrupted."));
|
|
49
|
+
return "continue";
|
|
50
|
+
}
|
|
51
|
+
promptManager.addContext({
|
|
52
|
+
type: "image",
|
|
53
|
+
image: dataUrl,
|
|
54
|
+
mediaType: mimeType,
|
|
55
|
+
});
|
|
56
|
+
showMessage(ctx, style.green("Image from clipboard will be added to your next prompt."));
|
|
57
|
+
return "continue";
|
|
58
|
+
}
|
|
7
59
|
export const pasteCommand = ({ modelManager, promptManager, tokenCounter, }) => {
|
|
8
60
|
return {
|
|
9
61
|
command: "/paste",
|
|
10
62
|
description: "Pastes image or text content from the clipboard into the next prompt.",
|
|
11
63
|
getSubCommands: () => Promise.resolve([]),
|
|
12
64
|
async handle(_args, { tui, container, editor, }) {
|
|
65
|
+
const ctx = { tui, container, editor };
|
|
13
66
|
try {
|
|
14
67
|
if (Clipboard.hasImage()) {
|
|
15
|
-
|
|
16
|
-
if (!isValidBase64(base64DataUrl)) {
|
|
17
|
-
container.addChild(new Text(style.red("Invalid base64 data in clipboard. The image data may be corrupted."), 1, 0));
|
|
18
|
-
tui.requestRender();
|
|
19
|
-
editor.setText("");
|
|
20
|
-
return "continue";
|
|
21
|
-
}
|
|
22
|
-
let mimeType;
|
|
23
|
-
try {
|
|
24
|
-
const dataUrlMimeType = extractMimeTypeFromDataUrl(base64DataUrl);
|
|
25
|
-
const base64Content = base64DataUrl.replace(/^data:.*?;base64,/, "");
|
|
26
|
-
const detectedFormat = detectImageFormatFromBase64(base64Content);
|
|
27
|
-
if (detectedFormat !== "unknown") {
|
|
28
|
-
mimeType = detectedFormat;
|
|
29
|
-
if (dataUrlMimeType !== detectedFormat) {
|
|
30
|
-
logger.warn(`Clipboard library reported ${dataUrlMimeType} but actual image format is ${detectedFormat}. Using detected format.`);
|
|
31
|
-
}
|
|
32
|
-
}
|
|
33
|
-
else {
|
|
34
|
-
mimeType = dataUrlMimeType;
|
|
35
|
-
logger.warn(`Could not detect image format, using data URL MIME type: ${mimeType}`);
|
|
36
|
-
}
|
|
37
|
-
}
|
|
38
|
-
catch (error) {
|
|
39
|
-
logger.warn(`Failed to extract MIME type from clipboard image: ${error}`);
|
|
40
|
-
mimeType = "image/png";
|
|
41
|
-
}
|
|
42
|
-
if (!base64DataUrl.startsWith(`data:${mimeType};base64,`)) {
|
|
43
|
-
const base64Content = base64DataUrl.replace(/^data:.*?;base64,/, "");
|
|
44
|
-
const correctedDataUrl = `data:${mimeType};base64,${base64Content}`;
|
|
45
|
-
if (!isValidBase64(correctedDataUrl)) {
|
|
46
|
-
container.addChild(new Text(style.red("Failed to correct base64 data format. The image data may be corrupted."), 1, 0));
|
|
47
|
-
tui.requestRender();
|
|
48
|
-
editor.setText("");
|
|
49
|
-
return "continue";
|
|
50
|
-
}
|
|
51
|
-
promptManager.addContext({
|
|
52
|
-
type: "image",
|
|
53
|
-
image: correctedDataUrl,
|
|
54
|
-
mediaType: mimeType,
|
|
55
|
-
});
|
|
56
|
-
}
|
|
57
|
-
else {
|
|
58
|
-
promptManager.addContext({
|
|
59
|
-
type: "image",
|
|
60
|
-
image: base64DataUrl,
|
|
61
|
-
mediaType: mimeType,
|
|
62
|
-
});
|
|
63
|
-
}
|
|
64
|
-
container.addChild(new Text(style.green("Image from clipboard will be added to your next prompt."), 1, 0));
|
|
65
|
-
tui.requestRender();
|
|
66
|
-
editor.setText("");
|
|
67
|
-
return "continue";
|
|
68
|
+
return await handleImagePaste(ctx, promptManager);
|
|
68
69
|
}
|
|
69
70
|
const clipboardContent = await Clipboard.getText();
|
|
70
71
|
if (!clipboardContent || clipboardContent.trim() === "") {
|
|
@@ -76,17 +77,13 @@ export const pasteCommand = ({ modelManager, promptManager, tokenCounter, }) =>
|
|
|
76
77
|
const content = formatBlock(clipboardContent, "clipboard", modelManager.getModelMetadata("repl").promptFormat);
|
|
77
78
|
promptManager.addContext(content);
|
|
78
79
|
const tokenCount = tokenCounter.count(content);
|
|
79
|
-
|
|
80
|
-
tui.requestRender();
|
|
81
|
-
editor.setText("");
|
|
80
|
+
showMessage(ctx, style.green(`Clipboard content will be added to your next prompt. (${tokenCount} tokens)`));
|
|
82
81
|
return "continue";
|
|
83
82
|
}
|
|
84
83
|
catch (error) {
|
|
85
84
|
const message = error instanceof Error ? error.message : String(error);
|
|
86
|
-
|
|
85
|
+
showMessage(ctx, style.red(`Error processing clipboard content: ${message}`));
|
|
87
86
|
logger.error(error, "Paste command error:");
|
|
88
|
-
tui.requestRender();
|
|
89
|
-
editor.setText("");
|
|
90
87
|
return "continue";
|
|
91
88
|
}
|
|
92
89
|
},
|
|
@@ -1 +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;
|
|
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;AAiGD,wBAAgB,2BAA2B,CAAC,aAAa,EAAE,MAAM,GAAG,MAAM,CAQzE;AAED,wBAAgB,0BAA0B,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM,CAGlE"}
|
|
@@ -14,67 +14,97 @@ export function isValidBase64(str) {
|
|
|
14
14
|
return false;
|
|
15
15
|
}
|
|
16
16
|
}
|
|
17
|
+
const IMAGE_SIGNATURES = [
|
|
18
|
+
{
|
|
19
|
+
bytes: [
|
|
20
|
+
[0, 0xff],
|
|
21
|
+
[1, 0xd8],
|
|
22
|
+
[2, 0xff],
|
|
23
|
+
],
|
|
24
|
+
mimeType: "image/jpeg",
|
|
25
|
+
},
|
|
26
|
+
{
|
|
27
|
+
bytes: [
|
|
28
|
+
[0, 0x89],
|
|
29
|
+
[1, 0x50],
|
|
30
|
+
[2, 0x4e],
|
|
31
|
+
[3, 0x47],
|
|
32
|
+
[4, 0x0d],
|
|
33
|
+
[5, 0x0a],
|
|
34
|
+
[6, 0x1a],
|
|
35
|
+
[7, 0x0a],
|
|
36
|
+
],
|
|
37
|
+
mimeType: "image/png",
|
|
38
|
+
},
|
|
39
|
+
{
|
|
40
|
+
bytes: [
|
|
41
|
+
[0, 0x47],
|
|
42
|
+
[1, 0x49],
|
|
43
|
+
[2, 0x46],
|
|
44
|
+
[3, 0x38],
|
|
45
|
+
[4, 0x37],
|
|
46
|
+
[5, 0x61],
|
|
47
|
+
],
|
|
48
|
+
mimeType: "image/gif",
|
|
49
|
+
},
|
|
50
|
+
{
|
|
51
|
+
bytes: [
|
|
52
|
+
[0, 0x47],
|
|
53
|
+
[1, 0x49],
|
|
54
|
+
[2, 0x46],
|
|
55
|
+
[3, 0x38],
|
|
56
|
+
[4, 0x39],
|
|
57
|
+
[5, 0x61],
|
|
58
|
+
],
|
|
59
|
+
mimeType: "image/gif",
|
|
60
|
+
},
|
|
61
|
+
{
|
|
62
|
+
bytes: [
|
|
63
|
+
[0, 0x52],
|
|
64
|
+
[1, 0x49],
|
|
65
|
+
[2, 0x46],
|
|
66
|
+
[3, 0x46],
|
|
67
|
+
[8, 0x57],
|
|
68
|
+
[9, 0x45],
|
|
69
|
+
[10, 0x42],
|
|
70
|
+
[11, 0x50],
|
|
71
|
+
],
|
|
72
|
+
mimeType: "image/webp",
|
|
73
|
+
},
|
|
74
|
+
{
|
|
75
|
+
bytes: [
|
|
76
|
+
[0, 0x42],
|
|
77
|
+
[1, 0x4d],
|
|
78
|
+
],
|
|
79
|
+
mimeType: "image/bmp",
|
|
80
|
+
},
|
|
81
|
+
{
|
|
82
|
+
bytes: [
|
|
83
|
+
[0, 0x49],
|
|
84
|
+
[1, 0x49],
|
|
85
|
+
[2, 0x2a],
|
|
86
|
+
[3, 0x00],
|
|
87
|
+
],
|
|
88
|
+
mimeType: "image/tiff",
|
|
89
|
+
},
|
|
90
|
+
{
|
|
91
|
+
bytes: [
|
|
92
|
+
[0, 0x4d],
|
|
93
|
+
[1, 0x4d],
|
|
94
|
+
[2, 0x00],
|
|
95
|
+
[3, 0x2a],
|
|
96
|
+
],
|
|
97
|
+
mimeType: "image/tiff",
|
|
98
|
+
},
|
|
99
|
+
];
|
|
100
|
+
function matchesSignature(buffer, signature) {
|
|
101
|
+
return signature.bytes.every(([offset, value]) => offset < buffer.length && buffer[offset] === value);
|
|
102
|
+
}
|
|
17
103
|
export function detectImageFormatFromBase64(base64Content) {
|
|
18
104
|
try {
|
|
19
105
|
const buffer = Buffer.from(base64Content, "base64");
|
|
20
|
-
|
|
21
|
-
|
|
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";
|
|
106
|
+
const match = IMAGE_SIGNATURES.find((sig) => matchesSignature(buffer, sig));
|
|
107
|
+
return match?.mimeType ?? "unknown";
|
|
78
108
|
}
|
|
79
109
|
catch {
|
|
80
110
|
return "unknown";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../source/commands/pickup/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../source/commands/pickup/index.ts"],"names":[],"mappings":"AAiBA,OAAO,KAAK,EAAE,cAAc,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAQ/D,eAAO,MAAM,aAAa,GAAI,SAAS,cAAc,KAAG,WA0DvD,CAAC"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { getTerminalSize, isArrowDown, isArrowUp, isEnter, isEscape, } from "../../terminal/control.js";
|
|
1
|
+
import { getTerminalSize, isArrowDown, isArrowUp, isEnter, isEscape, isShiftTab, isTab, } from "../../terminal/control.js";
|
|
2
2
|
import style from "../../terminal/style.js";
|
|
3
3
|
import { Input, Spacer, Text, Container as TuiContainer, } from "../../tui/index.js";
|
|
4
4
|
import { getAvailableHandoffFiles, hidePickupSelector, loadHandoff, } from "./utils.js";
|
|
@@ -109,12 +109,15 @@ class HandoffSelectorComponent extends TuiContainer {
|
|
|
109
109
|
this.listContainer.addChild(new Text(style.gray(" No matching handoffs"), 0, 0));
|
|
110
110
|
}
|
|
111
111
|
}
|
|
112
|
+
wantsNavigationKeys() {
|
|
113
|
+
return true;
|
|
114
|
+
}
|
|
112
115
|
handleInput(keyData) {
|
|
113
|
-
if (isArrowUp(keyData)) {
|
|
116
|
+
if (isArrowUp(keyData) || isShiftTab(keyData)) {
|
|
114
117
|
this.selectedIndex = Math.max(0, this.selectedIndex - 1);
|
|
115
118
|
this.updateList();
|
|
116
119
|
}
|
|
117
|
-
else if (isArrowDown(keyData)) {
|
|
120
|
+
else if (isArrowDown(keyData) || isTab(keyData)) {
|
|
118
121
|
this.selectedIndex = Math.min(this.filteredHandoffs.length - 1, this.selectedIndex + 1);
|
|
119
122
|
this.updateList();
|
|
120
123
|
}
|
|
@@ -36,13 +36,13 @@ export async function getAvailableHandoffFiles() {
|
|
|
36
36
|
}
|
|
37
37
|
}
|
|
38
38
|
export async function loadHandoff(handoff, options, container, tui, editor) {
|
|
39
|
-
const { sessionManager
|
|
39
|
+
const { sessionManager, modelManager } = options;
|
|
40
40
|
const filepath = `.acai/handoffs/${handoff.filename}`;
|
|
41
41
|
try {
|
|
42
42
|
const handoffContent = await readFile(filepath, "utf8");
|
|
43
43
|
container.addChild(new (await import("../../tui/index.js")).Text(`Loading handoff: ${(await import("../../terminal/style.js")).default.blue(handoff.name)}`, 0, 1));
|
|
44
|
-
|
|
45
|
-
|
|
44
|
+
sessionManager.create(modelManager.getModel("repl").modelId);
|
|
45
|
+
sessionManager.appendUserMessage(createUserMessage([], handoffContent));
|
|
46
46
|
container.addChild(new (await import("../../tui/index.js")).Text("Handoff loaded successfully.", 1, 0));
|
|
47
47
|
container.addChild(new (await import("../../tui/index.js")).Text("You can now continue with your previous work.", 2, 0));
|
|
48
48
|
tui.requestRender();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../source/commands/resources/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../source/commands/resources/index.ts"],"names":[],"mappings":"AASA,OAAO,KAAK,EAAE,cAAc,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAkC/D,wBAAgB,gBAAgB,CAAC,OAAO,EAAE,cAAc,GAAG,WAAW,CAmErE"}
|
|
@@ -1,6 +1,27 @@
|
|
|
1
|
-
import { loadSkills } from "../../skills.js";
|
|
1
|
+
import { loadSkills } from "../../skills/index.js";
|
|
2
2
|
import style from "../../terminal/style.js";
|
|
3
3
|
import { Modal, Container as ModalContainer, ModalText, } from "../../tui/index.js";
|
|
4
|
+
function formatSkillSection(label, skills, showSource = false) {
|
|
5
|
+
if (skills.length === 0)
|
|
6
|
+
return [];
|
|
7
|
+
const lines = [style.gray(`${label} (${skills.length}):`)];
|
|
8
|
+
for (const skill of skills) {
|
|
9
|
+
const pathSuffix = showSource ? ` ${style.dim(`[${skill.source}]`)}` : "";
|
|
10
|
+
lines.push(`${style.yellow.bold(skill.name)}\n${skill.description}\n${style.dim(skill.filePath)}${pathSuffix}\n`);
|
|
11
|
+
}
|
|
12
|
+
lines.push("");
|
|
13
|
+
return lines;
|
|
14
|
+
}
|
|
15
|
+
function formatAgentsFiles(agentsFiles) {
|
|
16
|
+
const lines = [style.gray("AGENTS.md:")];
|
|
17
|
+
for (const agentsFile of agentsFiles) {
|
|
18
|
+
const status = agentsFile.content.length > 0
|
|
19
|
+
? style.green("(Exists)")
|
|
20
|
+
: style.dim("(Not found)");
|
|
21
|
+
lines.push(` • ${agentsFile.path} ${status}`);
|
|
22
|
+
}
|
|
23
|
+
return lines;
|
|
24
|
+
}
|
|
4
25
|
export function resourcesCommand(options) {
|
|
5
26
|
return {
|
|
6
27
|
command: "/resources",
|
|
@@ -10,58 +31,20 @@ export function resourcesCommand(options) {
|
|
|
10
31
|
async handle(_args, { tui, editor }) {
|
|
11
32
|
try {
|
|
12
33
|
const skills = await loadSkills();
|
|
34
|
+
const allSkills = skills.getAll();
|
|
13
35
|
const agentsFiles = await options.config.readAgentsFiles();
|
|
14
|
-
const projectSkills =
|
|
15
|
-
const userSkills =
|
|
16
|
-
const otherSkills =
|
|
17
|
-
const lines = [
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
${style.dim(skill.filePath)}
|
|
24
|
-
`);
|
|
25
|
-
}
|
|
26
|
-
lines.push("");
|
|
27
|
-
}
|
|
28
|
-
if (userSkills.length > 0) {
|
|
29
|
-
lines.push(style.gray(`User Skills (${userSkills.length}):`));
|
|
30
|
-
for (const skill of userSkills) {
|
|
31
|
-
lines.push(`${style.yellow.bold(skill.name)}
|
|
32
|
-
${skill.description}
|
|
33
|
-
${style.dim(skill.filePath)}
|
|
34
|
-
`);
|
|
35
|
-
}
|
|
36
|
-
lines.push("");
|
|
37
|
-
}
|
|
38
|
-
if (otherSkills.length > 0) {
|
|
39
|
-
lines.push(style.gray(`Other Skills (${otherSkills.length}):`));
|
|
40
|
-
for (const skill of otherSkills) {
|
|
41
|
-
lines.push(`${style.yellow.bold(skill.name)}
|
|
42
|
-
${skill.description}
|
|
43
|
-
${style.dim(skill.filePath)} ${style.dim(`[${skill.source}]`)}
|
|
44
|
-
`);
|
|
45
|
-
}
|
|
46
|
-
lines.push("");
|
|
47
|
-
}
|
|
48
|
-
lines.push(style.gray("AGENTS.md:"));
|
|
49
|
-
for (const agentsFile of agentsFiles) {
|
|
50
|
-
if (agentsFile.content.length > 0) {
|
|
51
|
-
lines.push(` • ${agentsFile.path} ${style.green("(Exists)")}`);
|
|
52
|
-
}
|
|
53
|
-
else {
|
|
54
|
-
lines.push(` • ${agentsFile.path} ${style.dim("(Not found)")}`);
|
|
55
|
-
}
|
|
56
|
-
}
|
|
36
|
+
const projectSkills = allSkills.filter((s) => s.source === "project");
|
|
37
|
+
const userSkills = allSkills.filter((s) => s.source === "user");
|
|
38
|
+
const otherSkills = allSkills.filter((s) => s.source !== "project" && s.source !== "user");
|
|
39
|
+
const lines = [
|
|
40
|
+
...formatSkillSection("Project Skills", projectSkills),
|
|
41
|
+
...formatSkillSection("User Skills", userSkills),
|
|
42
|
+
...formatSkillSection("Other Skills", otherSkills, true),
|
|
43
|
+
...formatAgentsFiles(agentsFiles),
|
|
44
|
+
];
|
|
57
45
|
const modalContent = new ModalContainer();
|
|
58
46
|
const formattedText = lines.join("\n");
|
|
59
|
-
|
|
60
|
-
modalContent.addChild(new ModalText(formattedText, 0, 1));
|
|
61
|
-
}
|
|
62
|
-
else {
|
|
63
|
-
modalContent.addChild(new ModalText("No resources found.", 0, 1));
|
|
64
|
-
}
|
|
47
|
+
modalContent.addChild(new ModalText(formattedText.trim() ? formattedText : "No resources found.", 0, 1));
|
|
65
48
|
const modal = new Modal("Active Resources", modalContent, true, () => {
|
|
66
49
|
editor.setText("");
|
|
67
50
|
tui.requestRender();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../source/commands/review/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../source/commands/review/index.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,cAAc,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAG/D,eAAO,MAAM,aAAa,GAAI,UAAU,cAAc,KAAG,WAuBxD,CAAC"}
|
|
@@ -1,126 +1,12 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { getTerminalSize } from "../../terminal/control.js";
|
|
3
|
-
import style from "../../terminal/style.js";
|
|
4
|
-
import { Markdown } from "../../tui/components/markdown.js";
|
|
5
|
-
import { Spacer } from "../../tui/components/spacer.js";
|
|
6
|
-
import { Container, SelectList, Text, } from "../../tui/index.js";
|
|
7
|
-
import { formatFileDiffForDisplay, parseGitDiffFiles } from "./utils.js";
|
|
1
|
+
import { showReviewPanel } from "./review-panel.js";
|
|
8
2
|
export const reviewCommand = (_options) => {
|
|
9
3
|
return {
|
|
10
4
|
command: "/review",
|
|
11
5
|
description: "Shows a diff of all changes in the current directory.",
|
|
12
6
|
getSubCommands: () => Promise.resolve([]),
|
|
13
7
|
async handle(_args, { tui, container, editor, inputContainer, }) {
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
const stagedResult = await execEnv.executeCommand("git diff --cached", {
|
|
17
|
-
cwd: process.cwd(),
|
|
18
|
-
timeout: 5000,
|
|
19
|
-
preserveOutputOnError: true,
|
|
20
|
-
captureStderr: true,
|
|
21
|
-
throwOnError: false,
|
|
22
|
-
});
|
|
23
|
-
const unstagedResult = await execEnv.executeCommand("git diff", {
|
|
24
|
-
cwd: process.cwd(),
|
|
25
|
-
timeout: 5000,
|
|
26
|
-
preserveOutputOnError: true,
|
|
27
|
-
captureStderr: true,
|
|
28
|
-
throwOnError: false,
|
|
29
|
-
});
|
|
30
|
-
const stagedOutput = stagedResult.exitCode === 0 ? stagedResult.output : "";
|
|
31
|
-
const unstagedOutput = unstagedResult.exitCode === 0 ? unstagedResult.output : "";
|
|
32
|
-
const combinedOutput = stagedOutput +
|
|
33
|
-
(stagedOutput && unstagedOutput ? "\n" : "") +
|
|
34
|
-
unstagedOutput;
|
|
35
|
-
if (!combinedOutput.trim()) {
|
|
36
|
-
container.addChild(new Spacer(1));
|
|
37
|
-
container.addChild(new Markdown("No changes detected in the current directory.", {
|
|
38
|
-
customBgRgb: {
|
|
39
|
-
r: 52,
|
|
40
|
-
g: 53,
|
|
41
|
-
b: 65,
|
|
42
|
-
},
|
|
43
|
-
paddingX: 1,
|
|
44
|
-
paddingY: 1,
|
|
45
|
-
}));
|
|
46
|
-
tui.requestRender();
|
|
47
|
-
return "continue";
|
|
48
|
-
}
|
|
49
|
-
const fileChanges = parseGitDiffFiles(combinedOutput);
|
|
50
|
-
if (fileChanges.length === 0) {
|
|
51
|
-
container.addChild(new Spacer(1));
|
|
52
|
-
container.addChild(new Markdown("No file changes could be parsed.", {
|
|
53
|
-
customBgRgb: {
|
|
54
|
-
r: 52,
|
|
55
|
-
g: 53,
|
|
56
|
-
b: 65,
|
|
57
|
-
},
|
|
58
|
-
paddingX: 1,
|
|
59
|
-
paddingY: 1,
|
|
60
|
-
}));
|
|
61
|
-
tui.requestRender();
|
|
62
|
-
return "continue";
|
|
63
|
-
}
|
|
64
|
-
const selectItems = fileChanges.map((file) => ({
|
|
65
|
-
value: file.fileName,
|
|
66
|
-
label: file.fileName,
|
|
67
|
-
description: file.stats,
|
|
68
|
-
}));
|
|
69
|
-
const selectList = new SelectList(selectItems, 10);
|
|
70
|
-
const selectContainer = new Container();
|
|
71
|
-
const { columns } = getTerminalSize();
|
|
72
|
-
selectContainer.addChild(new Text(style.blue("─".repeat(columns)), 0, 0));
|
|
73
|
-
selectContainer.addChild(new Spacer(1));
|
|
74
|
-
selectContainer.addChild(selectList);
|
|
75
|
-
selectContainer.addChild(new Spacer(1));
|
|
76
|
-
selectContainer.addChild(new Text(style.blue("─".repeat(columns)), 0, 0));
|
|
77
|
-
const originalEditor = editor;
|
|
78
|
-
inputContainer.clear();
|
|
79
|
-
inputContainer.addChild(selectContainer);
|
|
80
|
-
tui.setFocus(selectList);
|
|
81
|
-
selectList.onSelect = (selectedItem) => {
|
|
82
|
-
const selectedFile = fileChanges.find((file) => file.fileName === selectedItem.value);
|
|
83
|
-
if (selectedFile) {
|
|
84
|
-
container.addChild(new Spacer(1));
|
|
85
|
-
container.addChild(new Markdown(formatFileDiffForDisplay(selectedFile.fileName, selectedFile.diff), {
|
|
86
|
-
customBgRgb: {
|
|
87
|
-
r: 52,
|
|
88
|
-
g: 53,
|
|
89
|
-
b: 65,
|
|
90
|
-
},
|
|
91
|
-
paddingX: 1,
|
|
92
|
-
paddingY: 1,
|
|
93
|
-
}));
|
|
94
|
-
inputContainer.clear();
|
|
95
|
-
inputContainer.addChild(originalEditor);
|
|
96
|
-
tui.setFocus(originalEditor);
|
|
97
|
-
tui.requestRender();
|
|
98
|
-
}
|
|
99
|
-
};
|
|
100
|
-
selectList.onCancel = () => {
|
|
101
|
-
inputContainer.clear();
|
|
102
|
-
inputContainer.addChild(originalEditor);
|
|
103
|
-
tui.setFocus(originalEditor);
|
|
104
|
-
tui.requestRender();
|
|
105
|
-
};
|
|
106
|
-
tui.requestRender();
|
|
107
|
-
return "continue";
|
|
108
|
-
}
|
|
109
|
-
catch (error) {
|
|
110
|
-
console.error("Error executing git diff:", error);
|
|
111
|
-
container.addChild(new Spacer(1));
|
|
112
|
-
container.addChild(new Markdown("Failed to retrieve git changes. Ensure git is installed and initialized.", {
|
|
113
|
-
customBgRgb: {
|
|
114
|
-
r: 52,
|
|
115
|
-
g: 53,
|
|
116
|
-
b: 65,
|
|
117
|
-
},
|
|
118
|
-
paddingX: 1,
|
|
119
|
-
paddingY: 1,
|
|
120
|
-
}));
|
|
121
|
-
tui.requestRender();
|
|
122
|
-
return "continue";
|
|
123
|
-
}
|
|
8
|
+
await showReviewPanel(tui, container, inputContainer, editor);
|
|
9
|
+
return "continue";
|
|
124
10
|
},
|
|
125
11
|
};
|
|
126
12
|
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"review-panel.d.ts","sourceRoot":"","sources":["../../../source/commands/review/review-panel.ts"],"names":[],"mappings":"AAOA,OAAO,EACL,SAAS,EACT,KAAK,MAAM,EAGX,KAAK,GAAG,EACT,MAAM,oBAAoB,CAAC;AAQ5B,wBAAsB,eAAe,CACnC,GAAG,EAAE,GAAG,EACR,SAAS,EAAE,SAAS,EACpB,cAAc,EAAE,SAAS,EACzB,MAAM,EAAE,MAAM,GACb,OAAO,CAAC,IAAI,CAAC,CA8Of"}
|