@travisennis/acai 0.0.5 → 0.0.7
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 +190 -19
- package/bin/acai-wrapper.js +26 -0
- package/dist/agent/index.d.ts +132 -0
- package/dist/agent/index.d.ts.map +1 -0
- package/dist/agent/index.js +434 -0
- package/dist/api/exa/index.js +1 -1
- package/dist/cli.d.ts +4 -1
- package/dist/cli.d.ts.map +1 -1
- package/dist/cli.js +67 -40
- package/dist/commands/add-directory-command.d.ts +3 -0
- package/dist/commands/add-directory-command.d.ts.map +1 -0
- package/dist/commands/add-directory-command.js +54 -0
- package/dist/commands/application-log-command.d.ts +1 -1
- package/dist/commands/application-log-command.d.ts.map +1 -1
- package/dist/commands/application-log-command.js +18 -20
- package/dist/commands/clear-command.d.ts +1 -1
- package/dist/commands/clear-command.d.ts.map +1 -1
- package/dist/commands/clear-command.js +7 -3
- package/dist/commands/compact-command.d.ts.map +1 -1
- package/dist/commands/compact-command.js +9 -5
- package/dist/commands/context-command.d.ts +3 -0
- package/dist/commands/context-command.d.ts.map +1 -0
- package/dist/commands/context-command.js +124 -0
- package/dist/commands/copy-command.d.ts.map +1 -1
- package/dist/commands/copy-command.js +14 -5
- package/dist/commands/edit-command.d.ts +1 -1
- package/dist/commands/edit-command.d.ts.map +1 -1
- package/dist/commands/edit-command.js +21 -34
- package/dist/commands/edit-prompt-command.d.ts +1 -1
- package/dist/commands/edit-prompt-command.d.ts.map +1 -1
- package/dist/commands/edit-prompt-command.js +18 -15
- package/dist/commands/exit-command.d.ts +1 -4
- package/dist/commands/exit-command.d.ts.map +1 -1
- package/dist/commands/exit-command.js +9 -5
- package/dist/commands/files-command.d.ts +1 -1
- package/dist/commands/files-command.d.ts.map +1 -1
- package/dist/commands/files-command.js +20 -16
- package/dist/commands/generate-rules-command.d.ts +1 -1
- package/dist/commands/generate-rules-command.d.ts.map +1 -1
- package/dist/commands/generate-rules-command.js +307 -39
- package/dist/commands/handoff-command.d.ts +3 -0
- package/dist/commands/handoff-command.d.ts.map +1 -0
- package/dist/commands/handoff-command.js +191 -0
- package/dist/commands/health-command.d.ts +1 -1
- package/dist/commands/health-command.d.ts.map +1 -1
- package/dist/commands/health-command.js +49 -27
- package/dist/commands/help-command.d.ts +1 -1
- package/dist/commands/help-command.d.ts.map +1 -1
- package/dist/commands/help-command.js +25 -5
- package/dist/commands/history-command.d.ts +3 -0
- package/dist/commands/history-command.d.ts.map +1 -0
- package/dist/commands/history-command.js +458 -0
- package/dist/commands/init-command.d.ts +1 -1
- package/dist/commands/init-command.d.ts.map +1 -1
- package/dist/commands/init-command.js +40 -22
- package/dist/commands/last-log-command.d.ts +1 -1
- package/dist/commands/last-log-command.d.ts.map +1 -1
- package/dist/commands/last-log-command.js +15 -15
- package/dist/commands/list-directories-command.d.ts +3 -0
- package/dist/commands/list-directories-command.d.ts.map +1 -0
- package/dist/commands/list-directories-command.js +35 -0
- package/dist/commands/list-tools-command.d.ts.map +1 -1
- package/dist/commands/list-tools-command.js +61 -21
- package/dist/commands/manager.d.ts +9 -4
- package/dist/commands/manager.d.ts.map +1 -1
- package/dist/commands/manager.js +64 -39
- package/dist/commands/model-command.d.ts.map +1 -1
- package/dist/commands/model-command.js +201 -66
- package/dist/commands/paste-command.d.ts +1 -1
- package/dist/commands/paste-command.d.ts.map +1 -1
- package/dist/commands/paste-command.js +23 -9
- package/dist/commands/pickup-command.d.ts +3 -0
- package/dist/commands/pickup-command.d.ts.map +1 -0
- package/dist/commands/pickup-command.js +109 -0
- package/dist/commands/prompt-command.d.ts +19 -1
- package/dist/commands/prompt-command.d.ts.map +1 -1
- package/dist/commands/prompt-command.js +191 -98
- package/dist/commands/remove-directory-command.d.ts +3 -0
- package/dist/commands/remove-directory-command.d.ts.map +1 -0
- package/dist/commands/remove-directory-command.js +55 -0
- package/dist/commands/reset-command.d.ts +1 -1
- package/dist/commands/reset-command.d.ts.map +1 -1
- package/dist/commands/reset-command.js +8 -5
- package/dist/commands/rules-command.d.ts +1 -1
- package/dist/commands/rules-command.d.ts.map +1 -1
- package/dist/commands/rules-command.js +25 -22
- package/dist/commands/save-command.d.ts +1 -1
- package/dist/commands/save-command.d.ts.map +1 -1
- package/dist/commands/save-command.js +8 -3
- package/dist/commands/shell-command.d.ts.map +1 -1
- package/dist/commands/shell-command.js +45 -24
- package/dist/commands/types.d.ts +9 -7
- package/dist/commands/types.d.ts.map +1 -1
- package/dist/commands/usage-command.d.ts +1 -1
- package/dist/commands/usage-command.d.ts.map +1 -1
- package/dist/commands/usage-command.js +18 -7
- package/dist/config.d.ts +21 -11
- package/dist/config.d.ts.map +1 -1
- package/dist/config.js +90 -63
- package/dist/execution/index.d.ts +17 -2
- package/dist/execution/index.d.ts.map +1 -1
- package/dist/execution/index.js +62 -20
- package/dist/formatting.d.ts +127 -0
- package/dist/formatting.d.ts.map +1 -1
- package/dist/formatting.js +201 -0
- package/dist/index.d.ts +7 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +263 -102
- package/dist/logger.d.ts.map +1 -1
- package/dist/logger.js +47 -18
- package/dist/mentions.d.ts +2 -1
- package/dist/mentions.d.ts.map +1 -1
- package/dist/mentions.js +16 -1
- package/dist/messages.d.ts +11 -0
- package/dist/messages.d.ts.map +1 -1
- package/dist/messages.js +122 -21
- package/dist/middleware/cache.d.ts +3 -0
- package/dist/middleware/cache.d.ts.map +1 -0
- package/dist/middleware/cache.js +53 -0
- package/dist/middleware/index.d.ts +1 -0
- package/dist/middleware/index.d.ts.map +1 -1
- package/dist/middleware/index.js +1 -0
- package/dist/models/ai-config.d.ts +4 -2
- package/dist/models/ai-config.d.ts.map +1 -1
- package/dist/models/ai-config.js +12 -2
- package/dist/models/anthropic-provider.d.ts.map +1 -1
- package/dist/models/anthropic-provider.js +3 -67
- 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.map +1 -1
- package/dist/models/google-provider.js +0 -3
- package/dist/models/groq-provider.d.ts.map +1 -1
- package/dist/models/groq-provider.js +0 -1
- package/dist/models/manager.d.ts +2 -1
- package/dist/models/manager.d.ts.map +1 -1
- package/dist/models/manager.js +26 -2
- package/dist/models/openai-provider.d.ts.map +1 -1
- package/dist/models/openai-provider.js +0 -4
- package/dist/models/openrouter-provider.d.ts +16 -22
- package/dist/models/openrouter-provider.d.ts.map +1 -1
- package/dist/models/openrouter-provider.js +175 -236
- package/dist/models/providers.d.ts +4 -14
- package/dist/models/providers.d.ts.map +1 -1
- package/dist/models/providers.js +1 -57
- package/dist/models/xai-provider.d.ts.map +1 -1
- package/dist/models/xai-provider.js +0 -2
- package/dist/prompts.d.ts +10 -4
- package/dist/prompts.d.ts.map +1 -1
- package/dist/prompts.js +447 -70
- package/dist/repl/project-status-line.d.ts +3 -0
- package/dist/repl/project-status-line.d.ts.map +1 -0
- package/dist/repl/project-status-line.js +61 -0
- package/dist/repl/tool-call-repair.d.ts.map +1 -1
- package/dist/repl/tool-call-repair.js +8 -4
- package/dist/repl-new.d.ts +51 -0
- package/dist/repl-new.d.ts.map +1 -0
- package/dist/repl-new.js +354 -0
- package/dist/skills.d.ts +20 -0
- package/dist/skills.d.ts.map +1 -0
- package/dist/skills.js +192 -0
- package/dist/terminal/control.d.ts +55 -0
- package/dist/terminal/control.d.ts.map +1 -0
- package/dist/terminal/control.js +109 -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 -25
- package/dist/terminal/formatting.d.ts.map +1 -1
- package/dist/terminal/formatting.js +35 -52
- 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 -94
- package/dist/terminal/index.d.ts.map +1 -1
- package/dist/terminal/index.js +2 -370
- package/dist/terminal/markdown.js +10 -5
- package/dist/terminal/select-prompt.d.ts +2 -2
- package/dist/terminal/select-prompt.d.ts.map +1 -1
- package/dist/terminal/select-prompt.js +47 -39
- package/dist/terminal/strip-ansi.js +4 -4
- 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/threshold.d.ts +20 -0
- package/dist/tokens/threshold.d.ts.map +1 -0
- package/dist/tokens/threshold.js +67 -0
- package/dist/tools/advanced-edit-file.d.ts +69 -0
- package/dist/tools/advanced-edit-file.d.ts.map +1 -0
- package/dist/tools/advanced-edit-file.js +285 -0
- package/dist/tools/agent.d.ts +16 -5
- package/dist/tools/agent.d.ts.map +1 -1
- package/dist/tools/agent.js +86 -59
- package/dist/tools/bash.d.ts +23 -12
- package/dist/tools/bash.d.ts.map +1 -1
- package/dist/tools/bash.js +243 -128
- package/dist/tools/batch.d.ts +34 -0
- package/dist/tools/batch.d.ts.map +1 -0
- package/dist/tools/batch.js +174 -0
- package/dist/tools/code-interpreter.d.ts +21 -9
- package/dist/tools/code-interpreter.d.ts.map +1 -1
- package/dist/tools/code-interpreter.js +151 -134
- package/dist/tools/delete-file.d.ts +17 -10
- package/dist/tools/delete-file.d.ts.map +1 -1
- package/dist/tools/delete-file.js +60 -97
- package/dist/tools/directory-tree.d.ts +17 -12
- package/dist/tools/directory-tree.d.ts.map +1 -1
- package/dist/tools/directory-tree.js +57 -48
- package/dist/tools/dynamic-tool-loader.d.ts +16 -10
- package/dist/tools/dynamic-tool-loader.d.ts.map +1 -1
- package/dist/tools/dynamic-tool-loader.js +122 -130
- package/dist/tools/dynamic-tool-parser.d.ts +1 -0
- package/dist/tools/dynamic-tool-parser.d.ts.map +1 -1
- package/dist/tools/dynamic-tool-parser.js +1 -0
- package/dist/tools/edit-file.d.ts +35 -15
- package/dist/tools/edit-file.d.ts.map +1 -1
- package/dist/tools/edit-file.js +127 -114
- package/dist/tools/glob.d.ts +36 -0
- package/dist/tools/glob.d.ts.map +1 -0
- package/dist/tools/glob.js +154 -0
- package/dist/tools/grep.d.ts +73 -12
- package/dist/tools/grep.d.ts.map +1 -1
- package/dist/tools/grep.js +425 -165
- package/dist/tools/index.d.ts +220 -126
- package/dist/tools/index.d.ts.map +1 -1
- package/dist/tools/index.js +284 -135
- package/dist/tools/llm-edit-fixer.d.ts +24 -0
- package/dist/tools/llm-edit-fixer.d.ts.map +1 -0
- package/dist/tools/llm-edit-fixer.js +136 -0
- package/dist/tools/move-file.d.ts +19 -7
- package/dist/tools/move-file.d.ts.map +1 -1
- package/dist/tools/move-file.js +48 -34
- package/dist/tools/read-file.d.ts +47 -9
- package/dist/tools/read-file.d.ts.map +1 -1
- package/dist/tools/read-file.js +84 -70
- package/dist/tools/read-multiple-files.d.ts +17 -6
- package/dist/tools/read-multiple-files.d.ts.map +1 -1
- package/dist/tools/read-multiple-files.js +132 -72
- package/dist/tools/save-file.d.ts +45 -12
- package/dist/tools/save-file.d.ts.map +1 -1
- package/dist/tools/save-file.js +76 -101
- package/dist/tools/think.d.ts +15 -7
- package/dist/tools/think.d.ts.map +1 -1
- package/dist/tools/think.js +34 -20
- package/dist/tools/types.d.ts +8 -10
- package/dist/tools/types.d.ts.map +1 -1
- package/dist/tools/types.js +9 -0
- package/dist/tools/utils.d.ts +14 -0
- package/dist/tools/utils.d.ts.map +1 -0
- package/dist/tools/utils.js +16 -0
- package/dist/tools/web-fetch.d.ts +11 -4
- package/dist/tools/web-fetch.d.ts.map +1 -1
- package/dist/tools/web-fetch.js +39 -38
- package/dist/tools/web-search.d.ts +15 -6
- package/dist/tools/web-search.d.ts.map +1 -1
- package/dist/tools/web-search.js +64 -31
- package/dist/tui/autocomplete.d.ts +44 -0
- package/dist/tui/autocomplete.d.ts.map +1 -0
- package/dist/tui/autocomplete.js +466 -0
- package/dist/tui/components/assistant-message.d.ts +18 -0
- package/dist/tui/components/assistant-message.d.ts.map +1 -0
- package/dist/tui/components/assistant-message.js +29 -0
- 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 +81 -0
- package/dist/tui/components/editor.d.ts +106 -0
- package/dist/tui/components/editor.d.ts.map +1 -0
- package/dist/tui/components/editor.js +1220 -0
- package/dist/tui/components/footer.d.ts +12 -0
- package/dist/tui/components/footer.d.ts.map +1 -0
- package/dist/tui/components/footer.js +209 -0
- 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 +14 -0
- package/dist/tui/components/input.d.ts.map +1 -0
- package/dist/tui/components/input.js +122 -0
- package/dist/tui/components/loader.d.ts +23 -0
- package/dist/tui/components/loader.d.ts.map +1 -0
- package/dist/tui/components/loader.js +45 -0
- package/dist/tui/components/markdown.d.ts +106 -0
- package/dist/tui/components/markdown.d.ts.map +1 -0
- package/dist/tui/components/markdown.js +586 -0
- package/dist/tui/components/modal.d.ts +29 -0
- package/dist/tui/components/modal.d.ts.map +1 -0
- package/dist/tui/components/modal.js +263 -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 +78 -0
- package/dist/tui/components/prompt-status.d.ts +17 -0
- package/dist/tui/components/prompt-status.d.ts.map +1 -0
- package/dist/tui/components/prompt-status.js +26 -0
- package/dist/tui/components/select-list.d.ts +48 -0
- package/dist/tui/components/select-list.d.ts.map +1 -0
- package/dist/tui/components/select-list.js +207 -0
- package/dist/tui/components/spacer.d.ts +16 -0
- package/dist/tui/components/spacer.d.ts.map +1 -0
- package/dist/tui/components/spacer.js +27 -0
- 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/text.d.ts +26 -0
- package/dist/tui/components/text.d.ts.map +1 -0
- package/dist/tui/components/text.js +143 -0
- package/dist/tui/components/thinking-block.d.ts +14 -0
- package/dist/tui/components/thinking-block.d.ts.map +1 -0
- package/dist/tui/components/thinking-block.js +33 -0
- package/dist/tui/components/tool-execution.d.ts +21 -0
- package/dist/tui/components/tool-execution.d.ts.map +1 -0
- package/dist/tui/components/tool-execution.js +161 -0
- package/dist/tui/components/user-message.d.ts +9 -0
- package/dist/tui/components/user-message.d.ts.map +1 -0
- package/dist/tui/components/user-message.js +23 -0
- package/dist/tui/components/welcome.d.ts +6 -0
- package/dist/tui/components/welcome.d.ts.map +1 -0
- package/dist/tui/components/welcome.js +30 -0
- package/dist/tui/index.d.ts +18 -0
- package/dist/tui/index.d.ts.map +1 -0
- package/dist/tui/index.js +22 -0
- package/dist/tui/terminal.d.ts +38 -0
- package/dist/tui/terminal.d.ts.map +1 -0
- package/dist/tui/terminal.js +94 -0
- package/dist/tui/tui.d.ts +69 -0
- package/dist/tui/tui.d.ts.map +1 -0
- package/dist/tui/tui.js +204 -0
- package/dist/tui/utils.d.ts +24 -0
- package/dist/tui/utils.d.ts.map +1 -0
- package/dist/tui/utils.js +111 -0
- package/dist/utils/bash.d.ts +7 -0
- package/dist/utils/bash.d.ts.map +1 -0
- package/dist/{tools/bash-utils.js → utils/bash.js} +31 -12
- package/dist/utils/{filesystem.d.ts → filesystem/operations.d.ts} +1 -1
- package/dist/utils/filesystem/operations.d.ts.map +1 -0
- package/dist/utils/filesystem/security.d.ts +9 -0
- package/dist/utils/filesystem/security.d.ts.map +1 -0
- package/dist/{tools/filesystem-utils.js → utils/filesystem/security.js} +93 -21
- 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/utils/generators.d.ts +3 -0
- package/dist/utils/generators.d.ts.map +1 -0
- package/dist/utils/generators.js +25 -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/iterables.d.ts +2 -0
- package/dist/utils/iterables.d.ts.map +1 -0
- package/dist/utils/iterables.js +6 -0
- package/dist/utils/{zod-utils.d.ts → zod.d.ts} +1 -1
- package/dist/utils/zod.d.ts.map +1 -0
- package/package.json +21 -21
- package/dist/conversation-analyzer.d.ts +0 -11
- package/dist/conversation-analyzer.d.ts.map +0 -1
- package/dist/conversation-analyzer.js +0 -88
- 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 -55
- 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 -38
- package/dist/repl-prompt.d.ts +0 -15
- package/dist/repl-prompt.d.ts.map +0 -1
- package/dist/repl-prompt.js +0 -147
- package/dist/repl.d.ts +0 -31
- package/dist/repl.d.ts.map +0 -1
- package/dist/repl.js +0 -310
- 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 -362
- 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 -16
- package/dist/terminal/input-prompt.d.ts.map +0 -1
- package/dist/terminal/input-prompt.js +0 -181
- 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 -279
- package/dist/terminal/types.d.ts +0 -35
- package/dist/terminal/types.d.ts.map +0 -1
- package/dist/terminal/types.js +0 -1
- package/dist/tokens/manage-output.d.ts +0 -34
- package/dist/tokens/manage-output.d.ts.map +0 -1
- package/dist/tokens/manage-output.js +0 -44
- package/dist/tool-executor.d.ts +0 -28
- package/dist/tool-executor.d.ts.map +0 -1
- package/dist/tool-executor.js +0 -74
- package/dist/tools/bash-utils.d.ts +0 -7
- package/dist/tools/bash-utils.d.ts.map +0 -1
- package/dist/tools/file-editing-utils.d.ts +0 -2
- package/dist/tools/file-editing-utils.d.ts.map +0 -1
- package/dist/tools/file-editing-utils.js +0 -135
- package/dist/tools/filesystem-utils.d.ts +0 -7
- package/dist/tools/filesystem-utils.d.ts.map +0 -1
- package/dist/tools/git-utils.d.ts.map +0 -1
- package/dist/utils/filesystem.d.ts.map +0 -1
- package/dist/utils/zod-utils.d.ts.map +0 -1
- /package/dist/utils/{filesystem.js → filesystem/operations.js} +0 -0
- /package/dist/utils/{zod-utils.js → zod.js} +0 -0
|
@@ -1,82 +1,195 @@
|
|
|
1
1
|
import { readdir, readFile } from "node:fs/promises";
|
|
2
2
|
import path, { basename } from "node:path";
|
|
3
|
+
import { logger } from "../logger.js";
|
|
3
4
|
import { processPrompt } from "../mentions.js";
|
|
4
|
-
|
|
5
|
+
import style from "../terminal/style.js";
|
|
6
|
+
import { Spacer, Text } from "../tui/index.js";
|
|
7
|
+
/**
|
|
8
|
+
* Replaces argument placeholders in prompt content.
|
|
9
|
+
* Supports:
|
|
10
|
+
* - $ARGUMENTS: All arguments joined by space
|
|
11
|
+
* - $1, $2, $3, etc.: Individual positional arguments
|
|
12
|
+
* - {{INPUT}}: Backward compatibility with existing syntax
|
|
13
|
+
* If no placeholders are found, appends arguments at the end.
|
|
14
|
+
*/
|
|
15
|
+
function replaceArgumentPlaceholders(content, args) {
|
|
16
|
+
const allArguments = args.join(" ");
|
|
17
|
+
// Track if any replacements were made
|
|
18
|
+
let replacementsMade = false;
|
|
19
|
+
let result = content;
|
|
20
|
+
// Replace positional arguments ($1, $2, $3, etc.)
|
|
21
|
+
// Use string replacement since $ has special meaning in regex
|
|
22
|
+
for (let i = 0; i < args.length; i++) {
|
|
23
|
+
const placeholder = `$${i + 1}`;
|
|
24
|
+
if (result.includes(placeholder)) {
|
|
25
|
+
result = result.replaceAll(placeholder, args[i]);
|
|
26
|
+
replacementsMade = true;
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
// Replace $ARGUMENTS placeholder
|
|
30
|
+
if (result.includes("$ARGUMENTS")) {
|
|
31
|
+
result = result.replaceAll("$ARGUMENTS", allArguments);
|
|
32
|
+
replacementsMade = true;
|
|
33
|
+
}
|
|
34
|
+
// Replace {{INPUT}} placeholder (backward compatibility)
|
|
35
|
+
if (result.includes("{{INPUT}}")) {
|
|
36
|
+
result = result.replaceAll("{{INPUT}}", allArguments);
|
|
37
|
+
replacementsMade = true;
|
|
38
|
+
}
|
|
39
|
+
// If no replacements were made and we have arguments, append them
|
|
40
|
+
if (!replacementsMade && allArguments.trim().length > 0) {
|
|
41
|
+
result += `\n\n${allArguments}`;
|
|
42
|
+
}
|
|
43
|
+
return result;
|
|
44
|
+
}
|
|
45
|
+
export function parsePromptFile(content) {
|
|
46
|
+
// Check for YAML front matter
|
|
47
|
+
const frontMatterMatch = content.match(/^---\s*\n([\s\S]*?)\n---\s*(?:\n([\s\S]*))?$/);
|
|
48
|
+
if (!frontMatterMatch) {
|
|
49
|
+
// No YAML front matter - use first 50 chars of entire content as description
|
|
50
|
+
return {
|
|
51
|
+
content,
|
|
52
|
+
metadata: {
|
|
53
|
+
description:
|
|
54
|
+
// Get first line, then first 50 characters of that line
|
|
55
|
+
content.split("\n")[0].trim().slice(0, 50) +
|
|
56
|
+
(content.split("\n")[0].trim().length > 50 ? "..." : ""),
|
|
57
|
+
enabled: true,
|
|
58
|
+
},
|
|
59
|
+
};
|
|
60
|
+
}
|
|
61
|
+
const yamlContent = frontMatterMatch[1];
|
|
62
|
+
const promptContent = frontMatterMatch[2] || "";
|
|
63
|
+
// Default metadata for YAML front matter case
|
|
64
|
+
const defaultDescription = promptContent.split("\n")[0].trim().slice(0, 50) +
|
|
65
|
+
(promptContent.split("\n")[0].trim().length > 50 ? "..." : "");
|
|
66
|
+
// Parse simple YAML fields
|
|
67
|
+
let description = defaultDescription;
|
|
68
|
+
let enabled = true;
|
|
69
|
+
// Extract description field
|
|
70
|
+
const descriptionMatch = yamlContent.match(/^description:\s*(.+)$/m);
|
|
71
|
+
if (descriptionMatch) {
|
|
72
|
+
description = descriptionMatch[1].trim();
|
|
73
|
+
}
|
|
74
|
+
// Extract enabled field
|
|
75
|
+
const enabledMatch = yamlContent.match(/^enabled:\s*(true|false)$/im);
|
|
76
|
+
if (enabledMatch) {
|
|
77
|
+
enabled = enabledMatch[1].toLowerCase() === "true";
|
|
78
|
+
}
|
|
5
79
|
return {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
80
|
+
content: promptContent,
|
|
81
|
+
metadata: {
|
|
82
|
+
description,
|
|
83
|
+
enabled,
|
|
84
|
+
},
|
|
85
|
+
};
|
|
86
|
+
}
|
|
87
|
+
export async function loadPrompts(config) {
|
|
88
|
+
const getPromptsFromDir = async (dirPath, type) => {
|
|
89
|
+
try {
|
|
90
|
+
const dirents = await readdir(dirPath, { withFileTypes: true });
|
|
91
|
+
const mdFiles = dirents.filter((dirent) => dirent.isFile() && dirent.name.endsWith(".md"));
|
|
92
|
+
const prompts = [];
|
|
93
|
+
for (const dirent of mdFiles) {
|
|
94
|
+
const filePath = path.join(dirPath, dirent.name);
|
|
10
95
|
try {
|
|
11
|
-
const
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
.
|
|
96
|
+
const content = await readFile(filePath, "utf8");
|
|
97
|
+
const parsed = parsePromptFile(content);
|
|
98
|
+
if (parsed.metadata.enabled) {
|
|
99
|
+
prompts.push({
|
|
100
|
+
name: basename(dirent.name, ".md"),
|
|
101
|
+
description: parsed.metadata.description,
|
|
102
|
+
enabled: parsed.metadata.enabled,
|
|
103
|
+
path: filePath,
|
|
104
|
+
type,
|
|
105
|
+
});
|
|
106
|
+
}
|
|
15
107
|
}
|
|
16
108
|
catch (error) {
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
}
|
|
20
|
-
terminal.error(`Error reading prompts from ${dirPath}: ${error}`);
|
|
21
|
-
return []; // Return empty on other errors too, but log them
|
|
109
|
+
logger.error(`Error reading prompt file ${filePath}: ${error}`);
|
|
110
|
+
// Skip this file but continue with others
|
|
22
111
|
}
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
//
|
|
32
|
-
|
|
112
|
+
}
|
|
113
|
+
return prompts;
|
|
114
|
+
}
|
|
115
|
+
catch (error) {
|
|
116
|
+
if (error.code === "ENOENT") {
|
|
117
|
+
return []; // Directory doesn't exist, return empty array
|
|
118
|
+
}
|
|
119
|
+
logger.error(`Error reading prompts from ${dirPath}: ${error}`);
|
|
120
|
+
return []; // Return empty on other errors too, but log them
|
|
121
|
+
}
|
|
122
|
+
};
|
|
123
|
+
const userPromptDir = config.app.ensurePathSync("prompts"); // User prompts are global (~/.acai/prompts)
|
|
124
|
+
const projectPromptDir = config.project.ensurePathSync("prompts"); // Project prompts are local (./.acai/prompts)
|
|
125
|
+
const userPrompts = await getPromptsFromDir(userPromptDir, "user");
|
|
126
|
+
const projectPrompts = await getPromptsFromDir(projectPromptDir, "project");
|
|
127
|
+
// Combine and deduplicate, with project prompts taking precedence
|
|
128
|
+
const promptMap = new Map();
|
|
129
|
+
// Add user prompts first
|
|
130
|
+
for (const prompt of userPrompts) {
|
|
131
|
+
promptMap.set(prompt.name, prompt);
|
|
132
|
+
}
|
|
133
|
+
// Override with project prompts (project prompts take precedence)
|
|
134
|
+
for (const prompt of projectPrompts) {
|
|
135
|
+
promptMap.set(prompt.name, prompt);
|
|
136
|
+
}
|
|
137
|
+
return promptMap;
|
|
138
|
+
}
|
|
139
|
+
export const promptCommand = ({ modelManager, promptManager, config, promptHistory, workspace, }) => {
|
|
140
|
+
return {
|
|
141
|
+
command: "/prompt",
|
|
142
|
+
description: "Loads and executes prompts. Project prompts override user prompts with the same name.",
|
|
143
|
+
getSubCommands: async () => {
|
|
144
|
+
const promptMap = await loadPrompts(config);
|
|
145
|
+
const promptList = Array.from(promptMap.values())
|
|
146
|
+
.map((p) => p.name)
|
|
147
|
+
.sort();
|
|
148
|
+
return promptList;
|
|
33
149
|
},
|
|
34
|
-
|
|
150
|
+
async handle(args, { tui, container, editor, }) {
|
|
35
151
|
const promptName = args?.[0];
|
|
152
|
+
// Handle no subcommand
|
|
36
153
|
if (!promptName) {
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
// Handle 'list' subcommand
|
|
41
|
-
if (promptName === "list") {
|
|
42
|
-
await listAllPrompts(terminal, config);
|
|
43
|
-
return "continue";
|
|
44
|
-
}
|
|
45
|
-
// Check for old format and provide helpful error
|
|
46
|
-
if (promptName.includes(":")) {
|
|
47
|
-
terminal.warn("The old format (user:name or project:name) is no longer supported. Use: /prompt <prompt-name> [input...]");
|
|
154
|
+
container.addChild(new Text(style.red("No prompt given."), 1, 0));
|
|
155
|
+
tui.requestRender();
|
|
156
|
+
editor.setText("");
|
|
48
157
|
return "continue";
|
|
49
158
|
}
|
|
50
159
|
try {
|
|
51
160
|
const promptResult = await findPrompt(promptName, config);
|
|
52
161
|
if (!promptResult) {
|
|
53
|
-
|
|
162
|
+
container.addChild(new Text(style.red(`Prompt not found: ${promptName}. Available prompts can be seen with tab completion.`), 1, 0));
|
|
163
|
+
tui.requestRender();
|
|
164
|
+
editor.setText("");
|
|
54
165
|
return "continue";
|
|
55
166
|
}
|
|
56
167
|
let promptContent;
|
|
57
168
|
try {
|
|
58
|
-
|
|
169
|
+
const fileContent = await readFile(promptResult.path, "utf8");
|
|
170
|
+
const parsed = parsePromptFile(fileContent);
|
|
171
|
+
promptContent = parsed.content;
|
|
59
172
|
}
|
|
60
173
|
catch (error) {
|
|
61
174
|
if (error.code === "ENOENT") {
|
|
62
|
-
|
|
175
|
+
container.addChild(new Text(style.red(`Prompt file not found: ${promptName} at ${promptResult.path}`), 1, 0));
|
|
176
|
+
tui.requestRender();
|
|
177
|
+
editor.setText("");
|
|
63
178
|
return "continue";
|
|
64
179
|
}
|
|
65
180
|
throw error;
|
|
66
181
|
}
|
|
67
|
-
//
|
|
182
|
+
// Get arguments for the prompt (everything after the prompt name)
|
|
68
183
|
const inputArgs = args.slice(1);
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
}
|
|
74
|
-
terminal.info(`Loaded ${promptResult.type} prompt: ${promptName}`);
|
|
184
|
+
// Replace argument placeholders
|
|
185
|
+
promptContent = replaceArgumentPlaceholders(promptContent, inputArgs);
|
|
186
|
+
container.addChild(new Spacer(1));
|
|
187
|
+
container.addChild(new Text(`Loaded ${promptResult.type} prompt: ${style.blue(promptName)}`, 1, 0));
|
|
75
188
|
if (inputArgs.length > 0) {
|
|
76
|
-
|
|
189
|
+
container.addChild(new Text(`Input: "${inputArgs.join(" ")}"`, 2, 0));
|
|
77
190
|
}
|
|
78
|
-
const processedPrompt = await processPrompt(promptContent, {
|
|
79
|
-
baseDir:
|
|
191
|
+
const processedPrompt = await processPrompt(promptContent.trim(), {
|
|
192
|
+
baseDir: workspace.primaryDir,
|
|
80
193
|
model: modelManager.getModelMetadata("repl"),
|
|
81
194
|
});
|
|
82
195
|
for (const context of processedPrompt.context) {
|
|
@@ -85,14 +198,14 @@ export const promptCommand = ({ terminal, modelManager, promptManager, config, p
|
|
|
85
198
|
promptManager.set(processedPrompt.message);
|
|
86
199
|
// Add the loaded prompt to history
|
|
87
200
|
promptHistory.push(processedPrompt.message);
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
terminal.lineBreak();
|
|
91
|
-
terminal.hr();
|
|
201
|
+
tui.requestRender();
|
|
202
|
+
editor.setText("");
|
|
92
203
|
return "use";
|
|
93
204
|
}
|
|
94
205
|
catch (error) {
|
|
95
|
-
|
|
206
|
+
container.addChild(new Text(style.red(`Error loading prompt: ${error.message}`), 1, 0));
|
|
207
|
+
tui.requestRender();
|
|
208
|
+
editor.setText("");
|
|
96
209
|
return "continue";
|
|
97
210
|
}
|
|
98
211
|
},
|
|
@@ -102,8 +215,18 @@ async function findPrompt(promptName, config) {
|
|
|
102
215
|
// Check project prompts first (they take precedence)
|
|
103
216
|
const projectPath = path.join(config.project.ensurePathSync("prompts"), `${promptName}.md`);
|
|
104
217
|
try {
|
|
105
|
-
await readFile(projectPath, "utf8");
|
|
106
|
-
|
|
218
|
+
const content = await readFile(projectPath, "utf8");
|
|
219
|
+
const parsed = parsePromptFile(content);
|
|
220
|
+
if (!parsed.metadata.enabled) {
|
|
221
|
+
return null; // Prompt is disabled
|
|
222
|
+
}
|
|
223
|
+
return {
|
|
224
|
+
name: promptName,
|
|
225
|
+
description: parsed.metadata.description,
|
|
226
|
+
enabled: parsed.metadata.enabled,
|
|
227
|
+
path: projectPath,
|
|
228
|
+
type: "project",
|
|
229
|
+
};
|
|
107
230
|
}
|
|
108
231
|
catch (error) {
|
|
109
232
|
if (error.code !== "ENOENT") {
|
|
@@ -113,8 +236,18 @@ async function findPrompt(promptName, config) {
|
|
|
113
236
|
// Check user prompts if not found in project
|
|
114
237
|
const userPath = path.join(config.app.ensurePathSync("prompts"), `${promptName}.md`);
|
|
115
238
|
try {
|
|
116
|
-
await readFile(userPath, "utf8");
|
|
117
|
-
|
|
239
|
+
const content = await readFile(userPath, "utf8");
|
|
240
|
+
const parsed = parsePromptFile(content);
|
|
241
|
+
if (!parsed.metadata.enabled) {
|
|
242
|
+
return null; // Prompt is disabled
|
|
243
|
+
}
|
|
244
|
+
return {
|
|
245
|
+
name: promptName,
|
|
246
|
+
description: parsed.metadata.description,
|
|
247
|
+
enabled: parsed.metadata.enabled,
|
|
248
|
+
path: userPath,
|
|
249
|
+
type: "user",
|
|
250
|
+
};
|
|
118
251
|
}
|
|
119
252
|
catch (error) {
|
|
120
253
|
if (error.code !== "ENOENT") {
|
|
@@ -123,43 +256,3 @@ async function findPrompt(promptName, config) {
|
|
|
123
256
|
}
|
|
124
257
|
return null; // Prompt not found in either location
|
|
125
258
|
}
|
|
126
|
-
async function listAllPrompts(terminal, config) {
|
|
127
|
-
const getPromptNamesFromDir = async (dirPath) => {
|
|
128
|
-
try {
|
|
129
|
-
const dirents = await readdir(dirPath, { withFileTypes: true });
|
|
130
|
-
return dirents
|
|
131
|
-
.filter((dirent) => dirent.isFile() && dirent.name.endsWith(".md"))
|
|
132
|
-
.map((dirent) => basename(dirent.name, ".md"));
|
|
133
|
-
}
|
|
134
|
-
catch (error) {
|
|
135
|
-
if (error.code === "ENOENT") {
|
|
136
|
-
return []; // Directory doesn't exist, return empty array
|
|
137
|
-
}
|
|
138
|
-
terminal.error(`Error reading prompts from ${dirPath}: ${error}`);
|
|
139
|
-
return []; // Return empty on other errors too, but log them
|
|
140
|
-
}
|
|
141
|
-
};
|
|
142
|
-
const userPromptDir = config.app.ensurePathSync("prompts");
|
|
143
|
-
const projectPromptDir = config.project.ensurePathSync("prompts");
|
|
144
|
-
const userPrompts = await getPromptNamesFromDir(userPromptDir);
|
|
145
|
-
const projectPrompts = await getPromptNamesFromDir(projectPromptDir);
|
|
146
|
-
if (userPrompts.length === 0 && projectPrompts.length === 0) {
|
|
147
|
-
terminal.warn("No prompts found. Create prompts in ~/.acai/prompts/ or ./.acai/prompts/");
|
|
148
|
-
return;
|
|
149
|
-
}
|
|
150
|
-
terminal.info("Available prompts:");
|
|
151
|
-
if (projectPrompts.length > 0) {
|
|
152
|
-
terminal.info(" Project prompts (./.acai/prompts/):");
|
|
153
|
-
projectPrompts.sort().forEach((prompt) => {
|
|
154
|
-
terminal.info(` • ${prompt}`);
|
|
155
|
-
});
|
|
156
|
-
}
|
|
157
|
-
if (userPrompts.length > 0) {
|
|
158
|
-
terminal.info(" User prompts (~/.acai/prompts/):");
|
|
159
|
-
userPrompts.sort().forEach((prompt) => {
|
|
160
|
-
terminal.info(` • ${prompt}`);
|
|
161
|
-
});
|
|
162
|
-
}
|
|
163
|
-
terminal.info("\nUsage: /prompt <prompt-name> [input...]");
|
|
164
|
-
terminal.info("Example: /prompt project-status");
|
|
165
|
-
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"remove-directory-command.d.ts","sourceRoot":"","sources":["../../source/commands/remove-directory-command.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,cAAc,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AAE9D,eAAO,MAAM,sBAAsB,GAAI,gBAEpC,cAAc,KAAG,WAkGnB,CAAC"}
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import path from "node:path";
|
|
2
|
+
import style from "../terminal/style.js";
|
|
3
|
+
import { Text } from "../tui/index.js";
|
|
4
|
+
export const removeDirectoryCommand = ({ workspace, }) => {
|
|
5
|
+
return {
|
|
6
|
+
command: "/remove-directory",
|
|
7
|
+
description: "Remove a directory from the list of allowed working directories",
|
|
8
|
+
getSubCommands: async () => {
|
|
9
|
+
// Return only non-primary directories for tab completion
|
|
10
|
+
return workspace.allowedDirs.filter((dir) => dir !== workspace.primaryDir);
|
|
11
|
+
},
|
|
12
|
+
async handle(args, { tui, container, editor, }) {
|
|
13
|
+
const directoryPath = args?.[0];
|
|
14
|
+
if (!directoryPath) {
|
|
15
|
+
container.addChild(new Text(style.red("Usage: /remove-directory <path>"), 0, 1));
|
|
16
|
+
tui.requestRender();
|
|
17
|
+
editor.setText("");
|
|
18
|
+
return "continue";
|
|
19
|
+
}
|
|
20
|
+
try {
|
|
21
|
+
// Resolve the directory path
|
|
22
|
+
const resolvedPath = path.resolve(directoryPath);
|
|
23
|
+
// Check if it's the primary directory
|
|
24
|
+
if (resolvedPath === workspace.primaryDir) {
|
|
25
|
+
container.addChild(new Text(style.red("Cannot remove the primary working directory"), 1, 0));
|
|
26
|
+
tui.requestRender();
|
|
27
|
+
editor.setText("");
|
|
28
|
+
return "continue";
|
|
29
|
+
}
|
|
30
|
+
// Find the directory in the list
|
|
31
|
+
const index = workspace.allowedDirs.indexOf(resolvedPath);
|
|
32
|
+
if (index === -1) {
|
|
33
|
+
container.addChild(new Text(style.red(`Directory not found in allowed list: ${resolvedPath}`), 1, 0));
|
|
34
|
+
tui.requestRender();
|
|
35
|
+
editor.setText("");
|
|
36
|
+
return "continue";
|
|
37
|
+
}
|
|
38
|
+
// Remove the directory
|
|
39
|
+
workspace.allowedDirs.splice(index, 1);
|
|
40
|
+
container.addChild(new Text(`Removed directory from allowed list: ${style.blue(resolvedPath)}`, 1, 0));
|
|
41
|
+
container.addChild(new Text(`Current allowed directories: ${style.blue(workspace.allowedDirs.join(", "))}`, 2, 0));
|
|
42
|
+
tui.requestRender();
|
|
43
|
+
editor.setText("");
|
|
44
|
+
return "continue";
|
|
45
|
+
}
|
|
46
|
+
catch (error) {
|
|
47
|
+
const errorMessage = error instanceof Error ? error.message : String(error);
|
|
48
|
+
container.addChild(new Text(style.red(`Failed to remove directory: ${errorMessage}`), 1, 0));
|
|
49
|
+
tui.requestRender();
|
|
50
|
+
editor.setText("");
|
|
51
|
+
return "continue";
|
|
52
|
+
}
|
|
53
|
+
},
|
|
54
|
+
};
|
|
55
|
+
};
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import type { CommandOptions, ReplCommand } from "./types.ts";
|
|
2
|
-
export declare const resetCommand: ({
|
|
2
|
+
export declare const resetCommand: ({ modelManager, messageHistory, }: CommandOptions) => ReplCommand;
|
|
3
3
|
//# sourceMappingURL=reset-command.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"reset-command.d.ts","sourceRoot":"","sources":["../../source/commands/reset-command.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"reset-command.d.ts","sourceRoot":"","sources":["../../source/commands/reset-command.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,cAAc,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AAE9D,eAAO,MAAM,YAAY,GAAI,mCAG1B,cAAc,KAAG,WA4BnB,CAAC"}
|
|
@@ -1,16 +1,19 @@
|
|
|
1
|
-
|
|
1
|
+
import { setTerminalTitle } from "../terminal/formatting.js";
|
|
2
|
+
export const resetCommand = ({ modelManager, messageHistory, }) => {
|
|
2
3
|
return {
|
|
3
4
|
command: "/reset",
|
|
4
5
|
aliases: ["/new"],
|
|
5
6
|
description: "Saves the chat history and then resets it.",
|
|
6
7
|
getSubCommands: () => Promise.resolve([]),
|
|
7
|
-
|
|
8
|
+
async handle(_args, { tui, container, editor, }) {
|
|
8
9
|
if (!messageHistory.isEmpty()) {
|
|
9
10
|
await messageHistory.save();
|
|
10
|
-
messageHistory.
|
|
11
|
+
messageHistory.create(modelManager.getModel("repl").modelId);
|
|
11
12
|
}
|
|
12
|
-
|
|
13
|
-
|
|
13
|
+
setTerminalTitle(`acai: ${process.cwd()}`);
|
|
14
|
+
container.clear();
|
|
15
|
+
editor.setText("");
|
|
16
|
+
tui.requestRender();
|
|
14
17
|
return "continue";
|
|
15
18
|
},
|
|
16
19
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"rules-command.d.ts","sourceRoot":"","sources":["../../source/commands/rules-command.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"rules-command.d.ts","sourceRoot":"","sources":["../../source/commands/rules-command.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,cAAc,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AAE9D,eAAO,MAAM,YAAY,GAAI,UAAU,cAAc,KAAG,WA2HvD,CAAC"}
|
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
import { config } from "../config.js";
|
|
2
|
-
import
|
|
3
|
-
|
|
2
|
+
import style from "../terminal/style.js";
|
|
3
|
+
import { Text } from "../tui/index.js";
|
|
4
|
+
export const rulesCommand = (_options) => {
|
|
4
5
|
return {
|
|
5
6
|
command: "/rules",
|
|
6
7
|
description: "View, add, or edit rules. Usage: /rules [view|add <text>|edit]",
|
|
7
8
|
getSubCommands: () => Promise.resolve(["view", "add", "edit"]),
|
|
8
|
-
|
|
9
|
+
async handle(args, { tui, container, editor, }) {
|
|
9
10
|
const subCommand = args[0] ?? "view"; // Default to 'view'
|
|
10
11
|
const commandArgs = args.slice(1).join(" ");
|
|
11
12
|
try {
|
|
@@ -13,20 +14,22 @@ export const rulesCommand = ({ terminal }) => {
|
|
|
13
14
|
case "view": {
|
|
14
15
|
const currentContent = await config.readAgentsFile();
|
|
15
16
|
if (currentContent) {
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
17
|
+
container.addChild(new Text("--- Current Rules ---", 0, 1));
|
|
18
|
+
container.addChild(new Text(currentContent, 2, 0));
|
|
19
|
+
container.addChild(new Text("---------------------", 3, 0));
|
|
19
20
|
}
|
|
20
21
|
else {
|
|
21
|
-
|
|
22
|
+
container.addChild(new Text(style.yellow("No rules defined yet. Use '/rules add' or '/rules edit'."), 1, 0));
|
|
22
23
|
}
|
|
23
24
|
break;
|
|
24
25
|
}
|
|
25
26
|
case "add": {
|
|
26
27
|
const newMemory = commandArgs.trim();
|
|
27
28
|
if (!newMemory) {
|
|
28
|
-
|
|
29
|
-
|
|
29
|
+
container.addChild(new Text(style.red("Error: Memory text cannot be empty for 'add'."), 1, 0));
|
|
30
|
+
container.addChild(new Text("Usage: /memory add <new memory text>", 2, 0));
|
|
31
|
+
tui.requestRender();
|
|
32
|
+
editor.setText("");
|
|
30
33
|
return "continue";
|
|
31
34
|
}
|
|
32
35
|
const currentContent = await config.readAgentsFile();
|
|
@@ -34,35 +37,35 @@ export const rulesCommand = ({ terminal }) => {
|
|
|
34
37
|
? `${currentContent.trim()}\n- ${newMemory}` // Ensure space after dash
|
|
35
38
|
: `- ${newMemory}`; // Start with dash if new file
|
|
36
39
|
await config.writeAgentsFile(updatedContent);
|
|
40
|
+
container.addChild(new Text(style.green("Rule added successfully"), 0, 1));
|
|
37
41
|
break;
|
|
38
42
|
}
|
|
39
43
|
case "edit": {
|
|
40
44
|
const currentContent = await config.readAgentsFile();
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
});
|
|
47
|
-
// Check if the user cancelled the edit (editor returns the original content)
|
|
48
|
-
// Or if the content is actually different
|
|
49
|
-
if (updatedContent !== currentContent) {
|
|
50
|
-
await config.writeAgentsFile(updatedContent);
|
|
45
|
+
// For TUI mode, we can't use the editor prompt, so we'll just show current content
|
|
46
|
+
if (currentContent) {
|
|
47
|
+
container.addChild(new Text("Current rules:", 0, 1));
|
|
48
|
+
container.addChild(new Text(currentContent, 2, 0));
|
|
49
|
+
container.addChild(new Text(style.dim("Note: Rule editing not available in TUI mode"), 3, 0));
|
|
51
50
|
}
|
|
52
51
|
else {
|
|
53
|
-
|
|
52
|
+
container.addChild(new Text(style.yellow("No rules defined yet. Use '/rules add' or '/rules edit'."), 1, 0));
|
|
54
53
|
}
|
|
55
54
|
break;
|
|
56
55
|
}
|
|
57
56
|
default:
|
|
58
|
-
|
|
57
|
+
container.addChild(new Text(style.red("Invalid subcommand. Usage: /rules [view|add <text>|edit]"), 1, 0));
|
|
59
58
|
break;
|
|
60
59
|
}
|
|
60
|
+
tui.requestRender();
|
|
61
|
+
editor.setText("");
|
|
61
62
|
return "continue";
|
|
62
63
|
}
|
|
63
64
|
catch (_error) {
|
|
64
65
|
// Errors from read/write helpers are already logged
|
|
65
|
-
|
|
66
|
+
container.addChild(new Text(style.red("Failed to execute memory command."), 0, 1));
|
|
67
|
+
tui.requestRender();
|
|
68
|
+
editor.setText("");
|
|
66
69
|
return "continue";
|
|
67
70
|
}
|
|
68
71
|
},
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import type { CommandOptions, ReplCommand } from "./types.ts";
|
|
2
|
-
export declare const saveCommand: ({ messageHistory,
|
|
2
|
+
export declare const saveCommand: ({ messageHistory, }: CommandOptions) => ReplCommand;
|
|
3
3
|
//# sourceMappingURL=save-command.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"save-command.d.ts","sourceRoot":"","sources":["../../source/commands/save-command.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"save-command.d.ts","sourceRoot":"","sources":["../../source/commands/save-command.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,cAAc,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AAE9D,eAAO,MAAM,WAAW,GAAI,qBAEzB,cAAc,KAAG,WAyBnB,CAAC"}
|
|
@@ -1,13 +1,18 @@
|
|
|
1
|
-
|
|
1
|
+
import style from "../terminal/style.js";
|
|
2
|
+
import { Spacer, Text } from "../tui/index.js";
|
|
3
|
+
export const saveCommand = ({ messageHistory, }) => {
|
|
2
4
|
return {
|
|
3
5
|
command: "/save",
|
|
4
6
|
description: "Saves the chat history.",
|
|
5
7
|
getSubCommands: () => Promise.resolve([]),
|
|
6
|
-
|
|
8
|
+
async handle(_args, { tui, container, editor, }) {
|
|
7
9
|
if (!messageHistory.isEmpty()) {
|
|
8
10
|
await messageHistory.save();
|
|
9
11
|
}
|
|
10
|
-
|
|
12
|
+
container.addChild(new Spacer(1));
|
|
13
|
+
container.addChild(new Text(style.green("Message history saved."), 0, 1));
|
|
14
|
+
tui.requestRender();
|
|
15
|
+
editor.setText("");
|
|
11
16
|
return "continue";
|
|
12
17
|
},
|
|
13
18
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"shell-command.d.ts","sourceRoot":"","sources":["../../source/commands/shell-command.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"shell-command.d.ts","sourceRoot":"","sources":["../../source/commands/shell-command.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,cAAc,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AAK9D,eAAO,MAAM,YAAY,GAAI,SAAS,cAAc,KAAG,WAqHtD,CAAC"}
|