@travisennis/acai 0.0.6 → 0.0.8
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 +225 -39
- package/dist/agent/index.d.ts +30 -21
- package/dist/agent/index.d.ts.map +1 -1
- package/dist/agent/index.js +237 -198
- package/dist/cli.d.ts +4 -3
- package/dist/cli.d.ts.map +1 -1
- package/dist/cli.js +56 -18
- 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/index.js +50 -0
- 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/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} +1 -7
- package/dist/commands/copy/index.d.ts +3 -0
- package/dist/commands/copy/index.d.ts.map +1 -0
- package/dist/commands/copy/index.js +39 -0
- 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/index.d.ts +10 -0
- 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} +65 -147
- 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/utils.js +123 -0
- 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/index.d.ts +3 -0
- package/dist/commands/help/index.d.ts.map +1 -0
- package/dist/commands/{help-command.js → help/index.js} +6 -14
- 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} +40 -200
- 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} +17 -27
- 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} +2 -15
- 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/index.js +89 -0
- package/dist/commands/manager.d.ts +2 -9
- package/dist/commands/manager.d.ts.map +1 -1
- package/dist/commands/manager.js +38 -83
- package/dist/commands/model/index.d.ts +3 -0
- package/dist/commands/model/index.d.ts.map +1 -0
- package/dist/commands/model/index.js +182 -0
- 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/index.d.ts +3 -0
- package/dist/commands/paste/index.d.ts.map +1 -0
- package/dist/commands/paste/index.js +94 -0
- 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 +126 -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} +3 -35
- 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} +8 -11
- 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 -10
- 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 +197 -0
- package/dist/commands/session/types.d.ts +13 -0
- package/dist/commands/session/types.d.ts.map +1 -0
- package/dist/commands/session/types.js +7 -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} +4 -51
- package/dist/commands/types.d.ts +2 -5
- package/dist/commands/types.d.ts.map +1 -1
- package/dist/config.d.ts +36 -7
- package/dist/config.d.ts.map +1 -1
- package/dist/config.js +118 -60
- package/dist/dedent.d.ts.map +1 -1
- package/dist/dedent.js +7 -7
- package/dist/execution/index.d.ts +18 -2
- package/dist/execution/index.d.ts.map +1 -1
- package/dist/execution/index.js +119 -81
- package/dist/formatting.d.ts +46 -0
- package/dist/formatting.d.ts.map +1 -1
- package/dist/formatting.js +94 -0
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +299 -177
- 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/anthropic-provider.js +0 -7
- package/dist/models/deepseek-provider.d.ts +9 -8
- package/dist/models/deepseek-provider.d.ts.map +1 -1
- package/dist/models/deepseek-provider.js +0 -2
- package/dist/models/google-provider.d.ts +10 -9
- package/dist/models/google-provider.d.ts.map +1 -1
- package/dist/models/google-provider.js +0 -3
- package/dist/models/groq-provider.d.ts +8 -7
- package/dist/models/groq-provider.d.ts.map +1 -1
- package/dist/models/groq-provider.js +0 -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 +11 -10
- package/dist/models/openai-provider.d.ts.map +1 -1
- package/dist/models/openai-provider.js +0 -4
- package/dist/models/opencode-zen-provider.d.ts +23 -0
- package/dist/models/opencode-zen-provider.d.ts.map +1 -0
- package/dist/models/opencode-zen-provider.js +76 -0
- package/dist/models/openrouter-provider.d.ts +34 -28
- package/dist/models/openrouter-provider.d.ts.map +1 -1
- package/dist/models/openrouter-provider.js +148 -139
- package/dist/models/providers.d.ts +6 -16
- package/dist/models/providers.d.ts.map +1 -1
- package/dist/models/providers.js +8 -58
- package/dist/models/xai-provider.d.ts +9 -8
- package/dist/models/xai-provider.d.ts.map +1 -1
- package/dist/models/xai-provider.js +0 -2
- 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 +8 -4
- package/dist/prompts.d.ts.map +1 -1
- package/dist/prompts.js +155 -177
- 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 +15 -6
- package/dist/repl-new.d.ts.map +1 -1
- package/dist/repl-new.js +266 -83
- package/dist/{messages.d.ts → sessions/manager.d.ts} +13 -4
- package/dist/sessions/manager.d.ts.map +1 -0
- package/dist/{messages.js → sessions/manager.js} +126 -16
- package/dist/skills.d.ts +16 -0
- package/dist/skills.d.ts.map +1 -0
- package/dist/skills.js +233 -0
- package/dist/terminal/control.d.ts +56 -0
- package/dist/terminal/control.d.ts.map +1 -0
- package/dist/terminal/control.js +111 -0
- package/dist/terminal/default-theme.d.ts +1 -1
- package/dist/terminal/default-theme.d.ts.map +1 -1
- package/dist/terminal/default-theme.js +24 -28
- package/dist/terminal/formatting.d.ts +23 -26
- package/dist/terminal/formatting.d.ts.map +1 -1
- package/dist/terminal/formatting.js +35 -53
- package/dist/terminal/highlight/index.d.ts.map +1 -1
- package/dist/terminal/highlight/index.js +3 -6
- package/dist/terminal/highlight/theme.d.ts.map +1 -1
- package/dist/terminal/highlight/theme.js +2 -6
- package/dist/terminal/index.d.ts +2 -101
- package/dist/terminal/index.d.ts.map +1 -1
- package/dist/terminal/index.js +2 -464
- 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/terminal/table/cell.d.ts +114 -0
- package/dist/terminal/table/cell.d.ts.map +1 -0
- package/dist/terminal/table/cell.js +407 -0
- package/dist/terminal/table/debug.d.ts +15 -0
- package/dist/terminal/table/debug.d.ts.map +1 -0
- package/dist/terminal/table/debug.js +32 -0
- package/dist/terminal/table/index.d.ts +3 -0
- package/dist/terminal/table/index.d.ts.map +1 -0
- package/dist/terminal/table/index.js +2 -0
- package/dist/terminal/table/layout-manager.d.ts +27 -0
- package/dist/terminal/table/layout-manager.d.ts.map +1 -0
- package/dist/terminal/table/layout-manager.js +257 -0
- package/dist/terminal/table/table.d.ts +9 -0
- package/dist/terminal/table/table.d.ts.map +1 -0
- package/dist/terminal/table/table.js +97 -0
- package/dist/terminal/table/utils.d.ts +63 -0
- package/dist/terminal/table/utils.d.ts.map +1 -0
- package/dist/terminal/table/utils.js +326 -0
- package/dist/tokens/tracker.d.ts.map +1 -1
- package/dist/tokens/tracker.js +58 -16
- package/dist/tools/bash.d.ts +11 -11
- package/dist/tools/bash.d.ts.map +1 -1
- package/dist/tools/bash.js +189 -81
- package/dist/tools/directory-tree.d.ts +9 -13
- package/dist/tools/directory-tree.d.ts.map +1 -1
- package/dist/tools/directory-tree.js +90 -60
- package/dist/tools/dynamic-tool-loader.d.ts +22 -8
- package/dist/tools/dynamic-tool-loader.d.ts.map +1 -1
- package/dist/tools/dynamic-tool-loader.js +41 -46
- 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 +22 -66
- package/dist/tools/glob.d.ts +15 -16
- package/dist/tools/glob.d.ts.map +1 -1
- package/dist/tools/glob.js +78 -109
- package/dist/tools/grep.d.ts +19 -22
- package/dist/tools/grep.d.ts.map +1 -1
- package/dist/tools/grep.js +61 -93
- package/dist/tools/index.d.ts +202 -167
- package/dist/tools/index.d.ts.map +1 -1
- package/dist/tools/index.js +17 -273
- 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 +52 -76
- package/dist/tools/save-file.d.ts +8 -8
- package/dist/tools/save-file.d.ts.map +1 -1
- package/dist/tools/save-file.js +42 -53
- package/dist/tools/think.d.ts +4 -4
- package/dist/tools/think.d.ts.map +1 -1
- package/dist/tools/think.js +9 -32
- package/dist/tools/types.d.ts +5 -21
- 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/assistant-message.js +1 -1
- package/dist/tui/components/box.d.ts +20 -0
- package/dist/tui/components/box.d.ts.map +1 -0
- package/dist/tui/components/box.js +87 -0
- package/dist/tui/components/editor.d.ts +61 -7
- package/dist/tui/components/editor.d.ts.map +1 -1
- package/dist/tui/components/editor.js +630 -127
- package/dist/tui/components/footer.d.ts +19 -18
- package/dist/tui/components/footer.d.ts.map +1 -1
- package/dist/tui/components/footer.js +90 -185
- package/dist/tui/components/header.d.ts +21 -0
- package/dist/tui/components/header.d.ts.map +1 -0
- package/dist/tui/components/header.js +63 -0
- 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 +6 -1
- package/dist/tui/components/loader.d.ts.map +1 -1
- package/dist/tui/components/loader.js +8 -3
- package/dist/tui/components/markdown.d.ts +31 -27
- package/dist/tui/components/markdown.d.ts.map +1 -1
- package/dist/tui/components/markdown.js +131 -67
- package/dist/tui/components/modal.d.ts +0 -11
- package/dist/tui/components/modal.d.ts.map +1 -1
- package/dist/tui/components/modal.js +9 -37
- 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 +63 -0
- package/dist/tui/components/progress-bar.d.ts +19 -0
- package/dist/tui/components/progress-bar.d.ts.map +1 -0
- package/dist/tui/components/progress-bar.js +66 -0
- package/dist/tui/components/select-list.d.ts +12 -1
- package/dist/tui/components/select-list.d.ts.map +1 -1
- package/dist/tui/components/select-list.js +73 -32
- package/dist/tui/components/spacer.d.ts +1 -1
- package/dist/tui/components/spacer.d.ts.map +1 -1
- package/dist/tui/components/spacer.js +2 -2
- package/dist/tui/components/table.d.ts +27 -0
- package/dist/tui/components/table.d.ts.map +1 -0
- package/dist/tui/components/table.js +125 -0
- package/dist/tui/components/thinking-block.d.ts.map +1 -1
- package/dist/tui/components/thinking-block.js +4 -1
- package/dist/tui/components/tool-execution.d.ts +7 -6
- package/dist/tui/components/tool-execution.d.ts.map +1 -1
- package/dist/tui/components/tool-execution.js +81 -85
- package/dist/tui/components/user-message.d.ts.map +1 -1
- package/dist/tui/components/user-message.js +6 -4
- 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/index.d.ts +12 -6
- package/dist/tui/index.d.ts.map +1 -1
- package/dist/tui/index.js +7 -3
- package/dist/tui/terminal.d.ts +4 -3
- package/dist/tui/terminal.d.ts.map +1 -1
- package/dist/tui/terminal.js +43 -49
- package/dist/tui/tui.d.ts +3 -0
- package/dist/tui/tui.d.ts.map +1 -1
- package/dist/tui/tui.js +58 -43
- package/dist/tui/utils.d.ts +5 -0
- package/dist/tui/utils.d.ts.map +1 -1
- package/dist/tui/utils.js +80 -1
- package/dist/{tools/bash-utils.d.ts → utils/bash.d.ts} +3 -3
- package/dist/utils/bash.d.ts.map +1 -0
- package/dist/{tools/bash-utils.js → utils/bash.js} +22 -11
- package/dist/utils/{filesystem.d.ts → filesystem/operations.d.ts} +1 -1
- package/dist/utils/filesystem/operations.d.ts.map +1 -0
- package/dist/{tools/filesystem-utils.d.ts → utils/filesystem/security.d.ts} +3 -2
- package/dist/utils/filesystem/security.d.ts.map +1 -0
- package/dist/{tools/filesystem-utils.js → utils/filesystem/security.js} +62 -4
- package/dist/utils/funcs.d.ts +6 -0
- package/dist/utils/funcs.d.ts.map +1 -0
- package/dist/utils/funcs.js +6 -0
- package/dist/{tools/git-utils.d.ts → utils/git.d.ts} +1 -1
- package/dist/utils/git.d.ts.map +1 -0
- package/dist/{tools/git-utils.js → utils/git.js} +0 -6
- package/dist/utils/glob.js +1 -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-utils.d.ts → zod.d.ts} +2 -1
- package/dist/utils/zod.d.ts.map +1 -0
- package/dist/utils/zod.js +24 -0
- package/package.json +31 -29
- package/dist/agent/manual-loop.d.ts +0 -41
- package/dist/agent/manual-loop.d.ts.map +0 -1
- package/dist/agent/manual-loop.js +0 -278
- 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/add-directory-command.js +0 -85
- 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 -79
- 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 -64
- 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 -183
- package/dist/commands/copy-command.d.ts +0 -3
- package/dist/commands/copy-command.d.ts.map +0 -1
- package/dist/commands/copy-command.js +0 -80
- 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 -88
- 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 -61
- package/dist/commands/exit-command.d.ts +0 -13
- package/dist/commands/exit-command.d.ts.map +0 -1
- package/dist/commands/exit-command.js +0 -46
- 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 -121
- 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/handoff-command.js +0 -202
- 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 -213
- package/dist/commands/help-command.d.ts +0 -3
- 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 -98
- 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/list-tools-command.js +0 -124
- package/dist/commands/model-command.d.ts +0 -25
- package/dist/commands/model-command.d.ts.map +0 -1
- package/dist/commands/model-command.js +0 -340
- package/dist/commands/paste-command.d.ts +0 -3
- package/dist/commands/paste-command.d.ts.map +0 -1
- package/dist/commands/paste-command.js +0 -277
- 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 -161
- package/dist/commands/prompt-command.d.ts +0 -3
- package/dist/commands/prompt-command.d.ts.map +0 -1
- package/dist/commands/prompt-command.js +0 -280
- 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 -135
- 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 -42
- package/dist/messages.d.ts.map +0 -1
- package/dist/repl/display-tool-messages.d.ts +0 -4
- package/dist/repl/display-tool-messages.d.ts.map +0 -1
- package/dist/repl/display-tool-messages.js +0 -58
- package/dist/repl/display-tool-use.d.ts +0 -14
- package/dist/repl/display-tool-use.d.ts.map +0 -1
- package/dist/repl/display-tool-use.js +0 -63
- package/dist/repl/get-prompt-header.d.ts +0 -8
- package/dist/repl/get-prompt-header.d.ts.map +0 -1
- package/dist/repl/get-prompt-header.js +0 -9
- package/dist/repl/project-status-line.d.ts +0 -2
- package/dist/repl/project-status-line.d.ts.map +0 -1
- package/dist/repl/project-status-line.js +0 -31
- package/dist/repl/prompt.d.ts +0 -21
- package/dist/repl/prompt.d.ts.map +0 -1
- package/dist/repl/prompt.js +0 -244
- 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/repl.d.ts +0 -29
- package/dist/repl.d.ts.map +0 -1
- package/dist/repl.js +0 -218
- package/dist/terminal/checkbox-prompt.d.ts +0 -36
- package/dist/terminal/checkbox-prompt.d.ts.map +0 -1
- package/dist/terminal/checkbox-prompt.js +0 -368
- package/dist/terminal/editor-prompt.d.ts +0 -10
- package/dist/terminal/editor-prompt.d.ts.map +0 -1
- package/dist/terminal/editor-prompt.js +0 -61
- package/dist/terminal/errors.d.ts +0 -19
- package/dist/terminal/errors.d.ts.map +0 -1
- package/dist/terminal/errors.js +0 -37
- package/dist/terminal/input-prompt.d.ts +0 -17
- package/dist/terminal/input-prompt.d.ts.map +0 -1
- package/dist/terminal/input-prompt.js +0 -181
- package/dist/terminal/markdown.d.ts +0 -2
- package/dist/terminal/markdown.d.ts.map +0 -1
- package/dist/terminal/markdown.js +0 -118
- package/dist/terminal/search-prompt.d.ts +0 -20
- package/dist/terminal/search-prompt.d.ts.map +0 -1
- package/dist/terminal/search-prompt.js +0 -280
- package/dist/terminal/types.d.ts +0 -35
- package/dist/terminal/types.d.ts.map +0 -1
- package/dist/tokens/threshold.d.ts +0 -35
- package/dist/tokens/threshold.d.ts.map +0 -1
- package/dist/tokens/threshold.js +0 -85
- 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 -281
- package/dist/tools/agent.d.ts +0 -29
- package/dist/tools/agent.d.ts.map +0 -1
- package/dist/tools/agent.js +0 -103
- package/dist/tools/bash-utils.d.ts.map +0 -1
- 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 -167
- 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 -70
- 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/filesystem-utils.d.ts.map +0 -1
- package/dist/tools/git-utils.d.ts.map +0 -1
- package/dist/tools/llm-edit-fixer.d.ts +0 -25
- package/dist/tools/llm-edit-fixer.d.ts.map +0 -1
- package/dist/tools/llm-edit-fixer.js +0 -150
- 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 -58
- 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 -139
- 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 -133
- package/dist/tui/components/prompt-status.d.ts +0 -16
- package/dist/tui/components/prompt-status.d.ts.map +0 -1
- package/dist/tui/components/prompt-status.js +0 -21
- package/dist/utils/filesystem.d.ts.map +0 -1
- package/dist/utils/zod-utils.d.ts.map +0 -1
- package/dist/utils/zod-utils.js +0 -7
- /package/dist/{terminal → commands/add-directory}/types.js +0 -0
- /package/dist/utils/{filesystem.js → filesystem/operations.js} +0 -0
package/dist/tui/tui.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Minimal TUI implementation with differential rendering
|
|
3
3
|
*/
|
|
4
|
-
import { getTerminalSize } from "../terminal/
|
|
4
|
+
import { getTerminalSize, isCtrlC, isEscape } from "../terminal/control.js";
|
|
5
5
|
import style from "../terminal/style.js";
|
|
6
6
|
import { visibleWidth } from "./utils.js";
|
|
7
7
|
export { visibleWidth };
|
|
@@ -23,11 +23,7 @@ export class Container {
|
|
|
23
23
|
this.children = [];
|
|
24
24
|
}
|
|
25
25
|
render(width) {
|
|
26
|
-
|
|
27
|
-
for (const child of this.children) {
|
|
28
|
-
lines.push(...child.render(width));
|
|
29
|
-
}
|
|
30
|
-
return lines;
|
|
26
|
+
return this.children.flatMap((child) => child.render(width));
|
|
31
27
|
}
|
|
32
28
|
}
|
|
33
29
|
/**
|
|
@@ -38,7 +34,10 @@ export class TUI extends Container {
|
|
|
38
34
|
terminal;
|
|
39
35
|
focusedComponent = null;
|
|
40
36
|
renderRequested = false;
|
|
37
|
+
isRendering = false;
|
|
38
|
+
renderAgain = false;
|
|
41
39
|
activeModal = null;
|
|
40
|
+
onCtrlC;
|
|
42
41
|
constructor(terminal) {
|
|
43
42
|
super();
|
|
44
43
|
this.terminal = terminal;
|
|
@@ -56,23 +55,32 @@ export class TUI extends Container {
|
|
|
56
55
|
this.terminal.stop();
|
|
57
56
|
}
|
|
58
57
|
requestRender() {
|
|
58
|
+
if (this.isRendering) {
|
|
59
|
+
this.renderAgain = true;
|
|
60
|
+
return;
|
|
61
|
+
}
|
|
59
62
|
if (this.renderRequested)
|
|
60
63
|
return;
|
|
61
64
|
this.renderRequested = true;
|
|
62
|
-
|
|
65
|
+
setImmediate(() => {
|
|
63
66
|
this.renderRequested = false;
|
|
64
67
|
this.doRender();
|
|
65
68
|
});
|
|
66
69
|
}
|
|
67
70
|
handleInput(data) {
|
|
68
71
|
// Handle Ctrl+C globally - exit the application
|
|
69
|
-
if (data
|
|
70
|
-
console.
|
|
71
|
-
this.
|
|
72
|
-
|
|
72
|
+
if (isCtrlC(data)) {
|
|
73
|
+
console.info("\nCtrl+C pressed - exiting...");
|
|
74
|
+
if (this.onCtrlC) {
|
|
75
|
+
this.onCtrlC();
|
|
76
|
+
}
|
|
77
|
+
else {
|
|
78
|
+
this.stop();
|
|
79
|
+
process.exit(0);
|
|
80
|
+
}
|
|
73
81
|
}
|
|
74
82
|
// Handle Escape key to close modal if one is active
|
|
75
|
-
if (data
|
|
83
|
+
if (isEscape(data) && this.activeModal) {
|
|
76
84
|
this.hideModal();
|
|
77
85
|
return;
|
|
78
86
|
}
|
|
@@ -87,42 +95,49 @@ export class TUI extends Container {
|
|
|
87
95
|
}
|
|
88
96
|
}
|
|
89
97
|
doRender() {
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
// Always do full re-render for simplicity and reliability
|
|
94
|
-
// This ensures that previous content is properly cleared
|
|
95
|
-
let buffer = "\x1b[?2026h"; // Begin synchronized output
|
|
96
|
-
buffer += "\x1b[3J\x1b[2J\x1b[H"; // Clear scrollback, screen, and home
|
|
97
|
-
for (let i = 0; i < newLines.length; i++) {
|
|
98
|
-
if (i > 0)
|
|
99
|
-
buffer += "\r\n";
|
|
100
|
-
buffer += newLines[i];
|
|
98
|
+
if (this.isRendering) {
|
|
99
|
+
this.renderAgain = true;
|
|
100
|
+
return;
|
|
101
101
|
}
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
const
|
|
105
|
-
// Render
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
102
|
+
this.isRendering = true;
|
|
103
|
+
try {
|
|
104
|
+
const width = this.terminal.columns;
|
|
105
|
+
// Render all components to get new lines
|
|
106
|
+
const newLines = this.render(width);
|
|
107
|
+
// Build output buffer using array join (more efficient than string concat)
|
|
108
|
+
const bufferParts = [
|
|
109
|
+
"\x1b[?2026h", // Begin synchronized output
|
|
110
|
+
"\x1b[3J\x1b[2J\x1b[H", // Clear scrollback, screen, and home
|
|
111
|
+
newLines.join("\r\n"),
|
|
112
|
+
];
|
|
113
|
+
// Render modal on top if active
|
|
114
|
+
if (this.activeModal) {
|
|
115
|
+
const modalLines = this.activeModal.render(width);
|
|
116
|
+
// Render backdrop first if modal has backdrop
|
|
117
|
+
if (this.activeModal.backdrop) {
|
|
118
|
+
const backdropLine = style.bgRgb(0, 0, 0)(" ".repeat(width));
|
|
119
|
+
const { rows } = getTerminalSize();
|
|
120
|
+
for (let i = 0; i < rows; i++) {
|
|
121
|
+
bufferParts.push(`\x1b[${i + 1};1H`, backdropLine);
|
|
122
|
+
}
|
|
113
123
|
}
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
buffer += `\x1b[${i + 1};1H`;
|
|
120
|
-
buffer += modalLines[i];
|
|
124
|
+
// Render modal content
|
|
125
|
+
for (let i = 0; i < modalLines.length; i++) {
|
|
126
|
+
if (modalLines[i]) {
|
|
127
|
+
bufferParts.push(`\x1b[${i + 1};1H`, modalLines[i]);
|
|
128
|
+
}
|
|
121
129
|
}
|
|
122
130
|
}
|
|
131
|
+
bufferParts.push("\x1b[?2026l"); // End synchronized output
|
|
132
|
+
this.terminal.write(bufferParts.join(""));
|
|
133
|
+
}
|
|
134
|
+
finally {
|
|
135
|
+
this.isRendering = false;
|
|
136
|
+
if (this.renderAgain) {
|
|
137
|
+
this.renderAgain = false;
|
|
138
|
+
this.requestRender();
|
|
139
|
+
}
|
|
123
140
|
}
|
|
124
|
-
buffer += "\x1b[?2026l"; // End synchronized output
|
|
125
|
-
this.terminal.write(buffer);
|
|
126
141
|
}
|
|
127
142
|
// private positionCursor(
|
|
128
143
|
// componentCursorPos: [number, number] | null,
|
package/dist/tui/utils.d.ts
CHANGED
|
@@ -7,6 +7,11 @@
|
|
|
7
7
|
* - Tabs (replaced with 3 spaces for consistent width)
|
|
8
8
|
*/
|
|
9
9
|
export declare function visibleWidth(str: string): number;
|
|
10
|
+
/**
|
|
11
|
+
* Truncate text to fit within a maximum visible width, preserving ANSI codes.
|
|
12
|
+
* Adds ellipsis if truncation occurs.
|
|
13
|
+
*/
|
|
14
|
+
export declare function truncateToWidth(text: string, maxWidth: number, ellipsis?: string): string;
|
|
10
15
|
/**
|
|
11
16
|
* Apply background color to a line, padding to full width.
|
|
12
17
|
*
|
package/dist/tui/utils.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../source/tui/utils.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../source/tui/utils.ts"],"names":[],"mappings":"AAGA;;;;;;;GAOG;AACH,wBAAgB,YAAY,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAIhD;AA4BD;;;GAGG;AACH,wBAAgB,eAAe,CAC7B,IAAI,EAAE,MAAM,EACZ,QAAQ,EAAE,MAAM,EAChB,QAAQ,SAAQ,GACf,MAAM,CA+DR;AAED;;;;;;;GAOG;AACH,wBAAgB,qBAAqB,CACnC,IAAI,EAAE,MAAM,EACZ,KAAK,EAAE,MAAM,EACb,IAAI,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,MAAM,GAC7B,MAAM,CASR"}
|
package/dist/tui/utils.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { getSegmenter } from "../terminal/segmenter.js";
|
|
2
|
+
import stringWidth from "../terminal/string-width.js";
|
|
2
3
|
/**
|
|
3
4
|
* Calculate the visible width of a string in terminal columns.
|
|
4
5
|
* This correctly handles:
|
|
@@ -12,6 +13,84 @@ export function visibleWidth(str) {
|
|
|
12
13
|
const normalized = str.replace(/\t/g, " ");
|
|
13
14
|
return stringWidth(normalized);
|
|
14
15
|
}
|
|
16
|
+
/**
|
|
17
|
+
* Extract ANSI escape sequences from a string at the given position.
|
|
18
|
+
*/
|
|
19
|
+
function extractAnsiCode(str, pos) {
|
|
20
|
+
if (pos >= str.length || str[pos] !== "\x1b" || str[pos + 1] !== "[") {
|
|
21
|
+
return null;
|
|
22
|
+
}
|
|
23
|
+
let j = pos + 2;
|
|
24
|
+
while (j < str.length && str[j] && !/[mGKHJ]/.test(str[j])) {
|
|
25
|
+
j++;
|
|
26
|
+
}
|
|
27
|
+
if (j < str.length) {
|
|
28
|
+
return {
|
|
29
|
+
code: str.substring(pos, j + 1),
|
|
30
|
+
length: j + 1 - pos,
|
|
31
|
+
};
|
|
32
|
+
}
|
|
33
|
+
return null;
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* Truncate text to fit within a maximum visible width, preserving ANSI codes.
|
|
37
|
+
* Adds ellipsis if truncation occurs.
|
|
38
|
+
*/
|
|
39
|
+
export function truncateToWidth(text, maxWidth, ellipsis = "...") {
|
|
40
|
+
const textVisibleWidth = visibleWidth(text);
|
|
41
|
+
if (textVisibleWidth <= maxWidth) {
|
|
42
|
+
return text;
|
|
43
|
+
}
|
|
44
|
+
const ellipsisWidth = visibleWidth(ellipsis);
|
|
45
|
+
const targetWidth = maxWidth - ellipsisWidth;
|
|
46
|
+
if (targetWidth <= 0) {
|
|
47
|
+
return ellipsis.substring(0, maxWidth);
|
|
48
|
+
}
|
|
49
|
+
// Separate ANSI codes from visible content using grapheme segmentation
|
|
50
|
+
let i = 0;
|
|
51
|
+
const segments = [];
|
|
52
|
+
while (i < text.length) {
|
|
53
|
+
const ansiResult = extractAnsiCode(text, i);
|
|
54
|
+
if (ansiResult) {
|
|
55
|
+
segments.push({ type: "ansi", value: ansiResult.code });
|
|
56
|
+
i += ansiResult.length;
|
|
57
|
+
}
|
|
58
|
+
else {
|
|
59
|
+
// Find the next ANSI code or end of string
|
|
60
|
+
let end = i;
|
|
61
|
+
while (end < text.length) {
|
|
62
|
+
const nextAnsi = extractAnsiCode(text, end);
|
|
63
|
+
if (nextAnsi)
|
|
64
|
+
break;
|
|
65
|
+
end++;
|
|
66
|
+
}
|
|
67
|
+
// Segment this non-ANSI portion into graphemes
|
|
68
|
+
const textPortion = text.slice(i, end);
|
|
69
|
+
for (const seg of getSegmenter().segment(textPortion)) {
|
|
70
|
+
segments.push({ type: "grapheme", value: seg.segment });
|
|
71
|
+
}
|
|
72
|
+
i = end;
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
// Build truncated string from segments
|
|
76
|
+
let result = "";
|
|
77
|
+
let currentWidth = 0;
|
|
78
|
+
for (const seg of segments) {
|
|
79
|
+
if (seg.type === "ansi") {
|
|
80
|
+
result += seg.value;
|
|
81
|
+
continue;
|
|
82
|
+
}
|
|
83
|
+
const grapheme = seg.value;
|
|
84
|
+
const graphemeWidth = visibleWidth(grapheme);
|
|
85
|
+
if (currentWidth + graphemeWidth > targetWidth) {
|
|
86
|
+
break;
|
|
87
|
+
}
|
|
88
|
+
result += grapheme;
|
|
89
|
+
currentWidth += graphemeWidth;
|
|
90
|
+
}
|
|
91
|
+
// Add reset code before ellipsis to prevent styling leaking into it
|
|
92
|
+
return `${result}\x1b[0m${ellipsis}`;
|
|
93
|
+
}
|
|
15
94
|
/**
|
|
16
95
|
* Apply background color to a line, padding to full width.
|
|
17
96
|
*
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
export declare function validatePaths(command: string, allowedDirs: string[], cwd: string
|
|
1
|
+
export declare function validatePaths(command: string, allowedDirs: string[], cwd: string): {
|
|
2
2
|
isValid: boolean;
|
|
3
3
|
error?: string;
|
|
4
4
|
};
|
|
5
|
-
export declare const resolveCwd: (cwdInput: string | null | undefined, workingDir: string) => string;
|
|
5
|
+
export declare const resolveCwd: (cwdInput: string | null | undefined, workingDir: string, allowedDirs?: string[]) => string;
|
|
6
6
|
export declare const isMutatingCommand: (rawCommand: string) => boolean;
|
|
7
|
-
//# sourceMappingURL=bash
|
|
7
|
+
//# sourceMappingURL=bash.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"bash.d.ts","sourceRoot":"","sources":["../../source/utils/bash.ts"],"names":[],"mappings":"AAMA,wBAAgB,aAAa,CAC3B,OAAO,EAAE,MAAM,EACf,WAAW,EAAE,MAAM,EAAE,EACrB,GAAG,EAAE,MAAM,GACV;IAAE,OAAO,EAAE,OAAO,CAAC;IAAC,KAAK,CAAC,EAAE,MAAM,CAAA;CAAE,CA0EtC;AAED,eAAO,MAAM,UAAU,GACrB,UAAU,MAAM,GAAG,IAAI,GAAG,SAAS,EACnC,YAAY,MAAM,EAClB,cAAc,MAAM,EAAE,KACrB,MAkEF,CAAC;AAEF,eAAO,MAAM,iBAAiB,GAAI,YAAY,MAAM,KAAG,OAmHtD,CAAC"}
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import fs from "node:fs";
|
|
2
2
|
import os from "node:os";
|
|
3
3
|
import path from "node:path";
|
|
4
|
-
import { isPathWithinAllowedDirs } from "./filesystem
|
|
4
|
+
import { isPathWithinAllowedDirs } from "./filesystem/security.js";
|
|
5
5
|
// Validate path arguments to ensure they're within the project
|
|
6
|
-
export function validatePaths(command, allowedDirs, cwd
|
|
6
|
+
export function validatePaths(command, allowedDirs, cwd) {
|
|
7
7
|
// Simple tokenization - split on spaces but respect quotes
|
|
8
8
|
const tokens = [];
|
|
9
9
|
let current = "";
|
|
@@ -59,9 +59,7 @@ export function validatePaths(command, allowedDirs, cwd, allowedPaths) {
|
|
|
59
59
|
: cleanToken;
|
|
60
60
|
const resolvedPath = path.resolve(cwd, expandedToken);
|
|
61
61
|
// Allow access to explicitly allowed paths
|
|
62
|
-
|
|
63
|
-
if (!isAllowedPath &&
|
|
64
|
-
!isPathWithinAllowedDirs(resolvedPath, allowedDirs)) {
|
|
62
|
+
if (!isPathWithinAllowedDirs(resolvedPath, allowedDirs)) {
|
|
65
63
|
return {
|
|
66
64
|
isValid: false,
|
|
67
65
|
error: `Path '${cleanToken}' resolves outside the allowed directories (${resolvedPath}). All paths must be within ${allowedDirs.join(", ")}`,
|
|
@@ -72,8 +70,12 @@ export function validatePaths(command, allowedDirs, cwd, allowedPaths) {
|
|
|
72
70
|
}
|
|
73
71
|
return { isValid: true };
|
|
74
72
|
}
|
|
75
|
-
export const resolveCwd = (cwdInput, workingDir) => {
|
|
76
|
-
|
|
73
|
+
export const resolveCwd = (cwdInput, workingDir, allowedDirs) => {
|
|
74
|
+
// Determine which directory to use as the base for resolving relative paths
|
|
75
|
+
// If allowedDirs is provided and non-empty, use the first allowed directory
|
|
76
|
+
// Otherwise use the workingDir parameter (backward compatibility)
|
|
77
|
+
const baseDirForResolution = allowedDirs && allowedDirs.length > 0 ? allowedDirs[0] : workingDir;
|
|
78
|
+
const projectRootAbs = path.resolve(baseDirForResolution);
|
|
77
79
|
let projectRoot = projectRootAbs;
|
|
78
80
|
try {
|
|
79
81
|
projectRoot = fs.realpathSync(projectRootAbs);
|
|
@@ -92,10 +94,19 @@ export const resolveCwd = (cwdInput, workingDir) => {
|
|
|
92
94
|
catch {
|
|
93
95
|
// If the path doesn't exist entirely, validate intended path
|
|
94
96
|
}
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
97
|
+
// Check if within allowed directories if provided, otherwise check project root
|
|
98
|
+
if (allowedDirs && allowedDirs.length > 0) {
|
|
99
|
+
if (!isPathWithinAllowedDirs(target, allowedDirs)) {
|
|
100
|
+
throw new Error(`Working directory must be within the allowed directories: ${allowedDirs.join(", ")}. Received: ${cwdInput ?? "<default>"} -> ${target}`);
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
else {
|
|
104
|
+
// Fallback to original behavior: check within project root
|
|
105
|
+
const rel = path.relative(projectRoot, target);
|
|
106
|
+
const inside = rel === "" || (!rel.startsWith("..") && !path.isAbsolute(rel));
|
|
107
|
+
if (!inside) {
|
|
108
|
+
throw new Error(`Working directory must be within the project directory: ${projectRoot}. Received: ${cwdInput ?? "<default>"} -> ${target}`);
|
|
109
|
+
}
|
|
99
110
|
}
|
|
100
111
|
// Check existence and that it's a directory
|
|
101
112
|
let stats;
|
|
@@ -20,4 +20,4 @@ export declare function isDirectory(filePath: URL | string): Promise<boolean>;
|
|
|
20
20
|
* @throws Error if directory cannot be cleared or if path is invalid/unsafe
|
|
21
21
|
*/
|
|
22
22
|
export declare function clearDirectory(directoryPath: URL | string): Promise<void>;
|
|
23
|
-
//# sourceMappingURL=
|
|
23
|
+
//# sourceMappingURL=operations.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"operations.d.ts","sourceRoot":"","sources":["../../../source/utils/filesystem/operations.ts"],"names":[],"mappings":"AAIA,wBAAgB,MAAM,CAAC,SAAS,EAAE,GAAG,GAAG,MAAM,GAAG,MAAM,CAEtD;AAED;;;;;GAKG;AACH,wBAAgB,KAAK,CAAC,SAAS,EAAE,MAAM,GAAG,MAAM,CAS/C;AAED;;;;;GAKG;AACH,wBAAsB,WAAW,CAAC,QAAQ,EAAE,GAAG,GAAG,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC,CAmB1E;AAED;;;;;GAKG;AACH,wBAAsB,cAAc,CAClC,aAAa,EAAE,GAAG,GAAG,MAAM,GAC1B,OAAO,CAAC,IAAI,CAAC,CAuGf"}
|
|
@@ -1,8 +1,9 @@
|
|
|
1
|
+
import type { ProjectConfig } from "../../config.ts";
|
|
1
2
|
export declare function joinWorkingDir(userPath: string, workingDir: string): string;
|
|
2
|
-
export declare function isPathWithinBaseDir(requestedPath: string, baseDir: string): boolean;
|
|
3
3
|
export declare function isPathWithinAllowedDirs(requestedPath: string, allowedDirs: string[]): boolean;
|
|
4
4
|
export declare function validatePath(requestedPath: string, allowedDirectory: string | string[], options?: {
|
|
5
5
|
requireExistence?: boolean;
|
|
6
6
|
abortSignal?: AbortSignal;
|
|
7
7
|
}): Promise<string>;
|
|
8
|
-
|
|
8
|
+
export declare function validateFileNotReadOnly(filePath: string, config: ProjectConfig, workingDir: string): void;
|
|
9
|
+
//# sourceMappingURL=security.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"security.d.ts","sourceRoot":"","sources":["../../../source/utils/filesystem/security.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAsCrD,wBAAgB,cAAc,CAAC,QAAQ,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,GAAG,MAAM,CAK3E;AAoCD,wBAAgB,uBAAuB,CACrC,aAAa,EAAE,MAAM,EACrB,WAAW,EAAE,MAAM,EAAE,GACpB,OAAO,CAIT;AAGD,wBAAsB,YAAY,CAChC,aAAa,EAAE,MAAM,EACrB,gBAAgB,EAAE,MAAM,GAAG,MAAM,EAAE,EACnC,OAAO,GAAE;IAAE,gBAAgB,CAAC,EAAE,OAAO,CAAC;IAAC,WAAW,CAAC,EAAE,WAAW,CAAA;CAAO,GACtE,OAAO,CAAC,MAAM,CAAC,CA6HjB;AA8BD,wBAAgB,uBAAuB,CACrC,QAAQ,EAAE,MAAM,EAChB,MAAM,EAAE,aAAa,EACrB,UAAU,EAAE,MAAM,GACjB,IAAI,CAIN"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { realpathSync } from "node:fs";
|
|
1
|
+
import { realpathSync, statSync } from "node:fs";
|
|
2
2
|
import fs from "node:fs/promises";
|
|
3
3
|
import os from "node:os";
|
|
4
4
|
import path from "node:path";
|
|
@@ -6,6 +6,36 @@ import path from "node:path";
|
|
|
6
6
|
function normalizePath(p) {
|
|
7
7
|
return path.normalize(p);
|
|
8
8
|
}
|
|
9
|
+
// Resolve symlinks for existing ancestors of a path.
|
|
10
|
+
// Walks up the directory tree until an existing directory is found, resolves its real path,
|
|
11
|
+
// and appends the remaining relative path. Permission errors are treated as non-existence.
|
|
12
|
+
function resolveExistingAncestorSync(filePath) {
|
|
13
|
+
let current = filePath;
|
|
14
|
+
while (true) {
|
|
15
|
+
try {
|
|
16
|
+
const stats = statSync(current);
|
|
17
|
+
if (stats.isDirectory()) {
|
|
18
|
+
const realCurrent = realpathSync(current);
|
|
19
|
+
const remaining = path.relative(current, filePath);
|
|
20
|
+
return remaining === ""
|
|
21
|
+
? realCurrent
|
|
22
|
+
: path.join(realCurrent, remaining);
|
|
23
|
+
}
|
|
24
|
+
// If current exists but is not a directory, move up
|
|
25
|
+
}
|
|
26
|
+
catch {
|
|
27
|
+
// current doesn't exist or we lack permission to stat it
|
|
28
|
+
}
|
|
29
|
+
const parent = path.dirname(current);
|
|
30
|
+
if (parent === current) {
|
|
31
|
+
// Reached root, cannot resolve further
|
|
32
|
+
break;
|
|
33
|
+
}
|
|
34
|
+
current = parent;
|
|
35
|
+
}
|
|
36
|
+
// No existing ancestor found, return original path
|
|
37
|
+
return filePath;
|
|
38
|
+
}
|
|
9
39
|
// Handle path joining with working directory
|
|
10
40
|
export function joinWorkingDir(userPath, workingDir) {
|
|
11
41
|
if (path.isAbsolute(userPath)) {
|
|
@@ -20,7 +50,7 @@ function expandHome(filepath) {
|
|
|
20
50
|
return filepath;
|
|
21
51
|
}
|
|
22
52
|
// Ensure path is within base directory (handles '.', relative paths, and symlinks)
|
|
23
|
-
|
|
53
|
+
function isPathWithinBaseDir(requestedPath, baseDir) {
|
|
24
54
|
const baseAbs = path.resolve(baseDir);
|
|
25
55
|
let baseReal = baseAbs;
|
|
26
56
|
try {
|
|
@@ -37,7 +67,8 @@ export function isPathWithinBaseDir(requestedPath, baseDir) {
|
|
|
37
67
|
target = realpathSync(abs);
|
|
38
68
|
}
|
|
39
69
|
catch {
|
|
40
|
-
// If target doesn't fully exist,
|
|
70
|
+
// If target doesn't fully exist, resolve existing ancestors
|
|
71
|
+
target = resolveExistingAncestorSync(abs);
|
|
41
72
|
}
|
|
42
73
|
const rel = path.relative(baseReal, target);
|
|
43
74
|
return rel === "" || (!rel.startsWith("..") && !path.isAbsolute(rel));
|
|
@@ -119,7 +150,11 @@ export async function validatePath(requestedPath, allowedDirectory, options = {}
|
|
|
119
150
|
foundValidAncestor = true;
|
|
120
151
|
break;
|
|
121
152
|
}
|
|
122
|
-
catch (
|
|
153
|
+
catch (err) {
|
|
154
|
+
// If it's a security denial, rethrow
|
|
155
|
+
if (err instanceof Error && err.message.startsWith("Access denied")) {
|
|
156
|
+
throw err;
|
|
157
|
+
}
|
|
123
158
|
// If we reached the filesystem root, break to fallback check
|
|
124
159
|
const parent = path.dirname(current);
|
|
125
160
|
if (parent === current) {
|
|
@@ -151,3 +186,26 @@ export async function validatePath(requestedPath, allowedDirectory, options = {}
|
|
|
151
186
|
}
|
|
152
187
|
return validatedPath;
|
|
153
188
|
}
|
|
189
|
+
// Check if a file is read-only based on config
|
|
190
|
+
function isFileReadOnly(filePath, readOnlyFiles, workingDir) {
|
|
191
|
+
if (readOnlyFiles.length === 0) {
|
|
192
|
+
return false;
|
|
193
|
+
}
|
|
194
|
+
const normalizedFilePath = normalizePath(path.resolve(workingDir, filePath));
|
|
195
|
+
return readOnlyFiles.some((readOnlyPattern) => {
|
|
196
|
+
// Handle absolute paths
|
|
197
|
+
if (path.isAbsolute(readOnlyPattern)) {
|
|
198
|
+
const normalizedPattern = normalizePath(path.resolve(readOnlyPattern));
|
|
199
|
+
return normalizedFilePath === normalizedPattern;
|
|
200
|
+
}
|
|
201
|
+
// Handle relative paths (relative to working directory)
|
|
202
|
+
const normalizedRelativePattern = normalizePath(path.resolve(workingDir, readOnlyPattern));
|
|
203
|
+
return normalizedFilePath === normalizedRelativePattern;
|
|
204
|
+
});
|
|
205
|
+
}
|
|
206
|
+
// Validate that a file is not read-only before modification
|
|
207
|
+
export function validateFileNotReadOnly(filePath, config, workingDir) {
|
|
208
|
+
if (isFileReadOnly(filePath, config.readOnlyFiles, workingDir)) {
|
|
209
|
+
throw new Error(`File is read-only and cannot be modified: ${filePath}`);
|
|
210
|
+
}
|
|
211
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"funcs.d.ts","sourceRoot":"","sources":["../../source/utils/funcs.ts"],"names":[],"mappings":"AACA;;;GAGG;AACH,eAAO,MAAM,EAAE,GAAI,CAAC,EAAE,OAAO,CAAC,KAAG,CAAU,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"git.d.ts","sourceRoot":"","sources":["../../source/utils/git.ts"],"names":[],"mappings":"AAIA,wBAAsB,WAAW;;;;GAyDhC;AAED,wBAAsB,YAAY;;;;;GAmCjC;AAED,eAAO,MAAM,cAAc,QAAqB,OAAO,CAAC,OAAO,CAS7D,CAAC;AAEH;;GAEG;AACH,wBAAsB,qBAAqB,IAAI,OAAO,CAAC,OAAO,CAAC,CAY9D;AAED;;GAEG;AACH,wBAAsB,gBAAgB,IAAI,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC,CAkB/D"}
|
|
@@ -103,9 +103,6 @@ export const inGitDirectory = memoize(async () => {
|
|
|
103
103
|
* Check if there are uncommitted changes
|
|
104
104
|
*/
|
|
105
105
|
export async function hasUncommittedChanges() {
|
|
106
|
-
if (!(await inGitDirectory())) {
|
|
107
|
-
return false;
|
|
108
|
-
}
|
|
109
106
|
try {
|
|
110
107
|
const result = await executeCommand(["git", "status", "--porcelain"], {
|
|
111
108
|
cwd: process.cwd(),
|
|
@@ -122,9 +119,6 @@ export async function hasUncommittedChanges() {
|
|
|
122
119
|
* Get the current git branch name
|
|
123
120
|
*/
|
|
124
121
|
export async function getCurrentBranch() {
|
|
125
|
-
if (!(await inGitDirectory())) {
|
|
126
|
-
return null;
|
|
127
|
-
}
|
|
128
122
|
try {
|
|
129
123
|
const result = await executeCommand(["git", "rev-parse", "--abbrev-ref", "HEAD"], {
|
|
130
124
|
cwd: process.cwd(),
|
package/dist/utils/glob.js
CHANGED
|
@@ -3,7 +3,7 @@ import { readFile } from "node:fs/promises";
|
|
|
3
3
|
import path, * as nodePath from "node:path";
|
|
4
4
|
import * as process from "node:process";
|
|
5
5
|
import fg from "fast-glob";
|
|
6
|
-
import { isDirectory, slash, toPath } from "./filesystem.js";
|
|
6
|
+
import { isDirectory, slash, toPath } from "./filesystem/operations.js";
|
|
7
7
|
import { Ignore } from "./ignore.js";
|
|
8
8
|
// Cache for ignore patterns to avoid repeated IO
|
|
9
9
|
const ignoreCache = new Map();
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
type YamlValue = string | number | boolean | null | YamlObject | YamlValue[];
|
|
2
|
+
type YamlObject = {
|
|
3
|
+
[key: string]: YamlValue;
|
|
4
|
+
};
|
|
5
|
+
export declare function parseYaml(input: string): YamlObject;
|
|
6
|
+
export declare function parseFrontMatter(markdown: string): {
|
|
7
|
+
data: YamlObject;
|
|
8
|
+
content: string;
|
|
9
|
+
};
|
|
10
|
+
export {};
|
|
11
|
+
//# sourceMappingURL=yaml.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"yaml.d.ts","sourceRoot":"","sources":["../../source/utils/yaml.ts"],"names":[],"mappings":"AAAA,KAAK,SAAS,GAAG,MAAM,GAAG,MAAM,GAAG,OAAO,GAAG,IAAI,GAAG,UAAU,GAAG,SAAS,EAAE,CAAC;AAC7E,KAAK,UAAU,GAAG;IAAE,CAAC,GAAG,EAAE,MAAM,GAAG,SAAS,CAAA;CAAE,CAAC;AAE/C,wBAAgB,SAAS,CAAC,KAAK,EAAE,MAAM,GAAG,UAAU,CA0DnD;AA2JD,wBAAgB,gBAAgB,CAAC,QAAQ,EAAE,MAAM,GAAG;IAClD,IAAI,EAAE,UAAU,CAAC;IACjB,OAAO,EAAE,MAAM,CAAC;CACjB,CAwBA"}
|