@travisennis/acai 0.0.1
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/.acai/acai.json +9 -0
- package/.acai/prompts/add-openrouter-model.md +13 -0
- package/.acai/prompts/project-status.md +4 -0
- package/.acai/prompts/update-architecture-document.md +9 -0
- package/.acai/rules/learned-rules.md +9 -0
- package/.ai/docs/available-tools.txt +3 -0
- package/.ai/docs/cognitive_complexity_refactoring_progress.md +65 -0
- package/.ai/docs/deleted_tools.md +168 -0
- package/.ai/docs/deleted_tools_88ced9ef.md +56 -0
- package/.ai/docs/image-pasting.md +46 -0
- package/.ai/docs/initialize-app.md +117 -0
- package/.ai/docs/issue-4-plan.md +44 -0
- package/.ai/docs/marked-renderer-debug.md +15 -0
- package/.ai/docs/marked-renderer-refactor-plan.md +64 -0
- package/.ai/docs/memory-use-cases.md +55 -0
- package/.ai/docs/prompt-consistency.md +31 -0
- package/.ai/docs/refactoring-tools.md +98 -0
- package/.ai/docs/system-prompt-update.md +174 -0
- package/.ai/docs/system_prompt.txt +210 -0
- package/.ai/docs/tasks.md +49 -0
- package/.ai/plan.md +131 -0
- package/.ai/prompt.md +1 -0
- package/.ai/scripts/fetch_models.js +27 -0
- package/.ai/scripts/generateSystemPrompt.ts +15 -0
- package/.ai/scripts/list-tools.mjs +4 -0
- package/.ai/scripts/p5_geometric_shapes.js +149 -0
- package/.husky/commit-msg +1 -0
- package/.husky/pre-commit +3 -0
- package/.husky/pre-push +1 -0
- package/.ignore +4 -0
- package/AGENTS.md +25 -0
- package/ARCHITECTURE.md +304 -0
- package/LICENSE +21 -0
- package/README.md +392 -0
- package/TODO.md +2 -0
- package/biome.json +61 -0
- package/commitlint.config.js +3 -0
- package/dist/cli.d.ts +19 -0
- package/dist/cli.js +116 -0
- package/dist/commands/application-log-command.d.ts +2 -0
- package/dist/commands/application-log-command.js +43 -0
- package/dist/commands/clear-command.d.ts +2 -0
- package/dist/commands/clear-command.js +12 -0
- package/dist/commands/compact-command.d.ts +2 -0
- package/dist/commands/compact-command.js +51 -0
- package/dist/commands/copy-command.d.ts +2 -0
- package/dist/commands/copy-command.js +51 -0
- package/dist/commands/edit-command.d.ts +2 -0
- package/dist/commands/edit-command.js +53 -0
- package/dist/commands/edit-prompt-command.d.ts +2 -0
- package/dist/commands/edit-prompt-command.js +25 -0
- package/dist/commands/exit-command.d.ts +2 -0
- package/dist/commands/exit-command.js +14 -0
- package/dist/commands/files-command.d.ts +2 -0
- package/dist/commands/files-command.js +63 -0
- package/dist/commands/generate-rules-command.d.ts +2 -0
- package/dist/commands/generate-rules-command.js +61 -0
- package/dist/commands/help-command.d.ts +2 -0
- package/dist/commands/help-command.js +19 -0
- package/dist/commands/init-command.d.ts +2 -0
- package/dist/commands/init-command.js +40 -0
- package/dist/commands/last-log-command.d.ts +2 -0
- package/dist/commands/last-log-command.js +76 -0
- package/dist/commands/manager.d.ts +22 -0
- package/dist/commands/manager.js +123 -0
- package/dist/commands/model-command.d.ts +2 -0
- package/dist/commands/model-command.js +84 -0
- package/dist/commands/paste-command.d.ts +2 -0
- package/dist/commands/paste-command.js +40 -0
- package/dist/commands/prompt-command.d.ts +2 -0
- package/dist/commands/prompt-command.js +111 -0
- package/dist/commands/reset-command.d.ts +2 -0
- package/dist/commands/reset-command.js +16 -0
- package/dist/commands/rules-command.d.ts +2 -0
- package/dist/commands/rules-command.js +68 -0
- package/dist/commands/save-command.d.ts +2 -0
- package/dist/commands/save-command.js +14 -0
- package/dist/commands/types.d.ts +26 -0
- package/dist/commands/types.js +1 -0
- package/dist/commands/usage-command.d.ts +2 -0
- package/dist/commands/usage-command.js +21 -0
- package/dist/config.d.ts +60 -0
- package/dist/config.js +193 -0
- package/dist/conversation-analyzer.d.ts +10 -0
- package/dist/conversation-analyzer.js +88 -0
- package/dist/dedent.d.ts +3 -0
- package/dist/dedent.js +38 -0
- package/dist/formatting.d.ts +17 -0
- package/dist/formatting.js +103 -0
- package/dist/index.d.ts +18 -0
- package/dist/index.js +213 -0
- package/dist/logger.d.ts +2 -0
- package/dist/logger.js +24 -0
- package/dist/mentions.d.ts +9 -0
- package/dist/mentions.js +182 -0
- package/dist/messages.d.ts +69 -0
- package/dist/messages.js +261 -0
- package/dist/middleware/audit-message.d.ts +5 -0
- package/dist/middleware/audit-message.js +95 -0
- package/dist/middleware/index.d.ts +2 -0
- package/dist/middleware/index.js +2 -0
- package/dist/middleware/rate-limit.d.ts +4 -0
- package/dist/middleware/rate-limit.js +17 -0
- package/dist/models/ai-config.d.ts +12 -0
- package/dist/models/ai-config.js +87 -0
- package/dist/models/anthropic-provider.d.ts +25 -0
- package/dist/models/anthropic-provider.js +184 -0
- package/dist/models/deepseek-provider.d.ts +20 -0
- package/dist/models/deepseek-provider.js +42 -0
- package/dist/models/google-provider.d.ts +19 -0
- package/dist/models/google-provider.js +56 -0
- package/dist/models/manager.d.ts +15 -0
- package/dist/models/manager.js +48 -0
- package/dist/models/openai-provider.d.ts +22 -0
- package/dist/models/openai-provider.js +70 -0
- package/dist/models/openrouter-provider.d.ts +36 -0
- package/dist/models/openrouter-provider.js +276 -0
- package/dist/models/providers.d.ts +33 -0
- package/dist/models/providers.js +116 -0
- package/dist/models/xai-provider.d.ts +20 -0
- package/dist/models/xai-provider.js +47 -0
- package/dist/parsing.d.ts +2 -0
- package/dist/parsing.js +18 -0
- package/dist/prompts/manager.d.ts +19 -0
- package/dist/prompts/manager.js +71 -0
- package/dist/prompts.d.ts +4 -0
- package/dist/prompts.js +158 -0
- package/dist/repl-prompt.d.ts +14 -0
- package/dist/repl-prompt.js +147 -0
- package/dist/repl.d.ts +27 -0
- package/dist/repl.js +431 -0
- package/dist/source/cli.d.ts +19 -0
- package/dist/source/cli.js +116 -0
- package/dist/source/commands/application-log-command.d.ts +2 -0
- package/dist/source/commands/application-log-command.js +43 -0
- package/dist/source/commands/clear-command.d.ts +2 -0
- package/dist/source/commands/clear-command.js +12 -0
- package/dist/source/commands/compact-command.d.ts +2 -0
- package/dist/source/commands/compact-command.js +51 -0
- package/dist/source/commands/copy-command.d.ts +2 -0
- package/dist/source/commands/copy-command.js +51 -0
- package/dist/source/commands/edit-command.d.ts +2 -0
- package/dist/source/commands/edit-command.js +53 -0
- package/dist/source/commands/edit-prompt-command.d.ts +2 -0
- package/dist/source/commands/edit-prompt-command.js +25 -0
- package/dist/source/commands/exit-command.d.ts +2 -0
- package/dist/source/commands/exit-command.js +14 -0
- package/dist/source/commands/files-command.d.ts +2 -0
- package/dist/source/commands/files-command.js +63 -0
- package/dist/source/commands/generate-rules-command.d.ts +2 -0
- package/dist/source/commands/generate-rules-command.js +61 -0
- package/dist/source/commands/help-command.d.ts +2 -0
- package/dist/source/commands/help-command.js +19 -0
- package/dist/source/commands/init-command.d.ts +2 -0
- package/dist/source/commands/init-command.js +40 -0
- package/dist/source/commands/last-log-command.d.ts +2 -0
- package/dist/source/commands/last-log-command.js +76 -0
- package/dist/source/commands/manager.d.ts +22 -0
- package/dist/source/commands/manager.js +123 -0
- package/dist/source/commands/model-command.d.ts +2 -0
- package/dist/source/commands/model-command.js +84 -0
- package/dist/source/commands/paste-command.d.ts +2 -0
- package/dist/source/commands/paste-command.js +40 -0
- package/dist/source/commands/prompt-command.d.ts +2 -0
- package/dist/source/commands/prompt-command.js +111 -0
- package/dist/source/commands/reset-command.d.ts +2 -0
- package/dist/source/commands/reset-command.js +16 -0
- package/dist/source/commands/rules-command.d.ts +2 -0
- package/dist/source/commands/rules-command.js +68 -0
- package/dist/source/commands/save-command.d.ts +2 -0
- package/dist/source/commands/save-command.js +14 -0
- package/dist/source/commands/types.d.ts +26 -0
- package/dist/source/commands/types.js +1 -0
- package/dist/source/commands/usage-command.d.ts +2 -0
- package/dist/source/commands/usage-command.js +21 -0
- package/dist/source/config.d.ts +60 -0
- package/dist/source/config.js +193 -0
- package/dist/source/conversation-analyzer.d.ts +10 -0
- package/dist/source/conversation-analyzer.js +88 -0
- package/dist/source/dedent.d.ts +3 -0
- package/dist/source/dedent.js +38 -0
- package/dist/source/formatting.d.ts +17 -0
- package/dist/source/formatting.js +103 -0
- package/dist/source/index.d.ts +18 -0
- package/dist/source/index.js +213 -0
- package/dist/source/logger.d.ts +2 -0
- package/dist/source/logger.js +24 -0
- package/dist/source/mentions.d.ts +9 -0
- package/dist/source/mentions.js +182 -0
- package/dist/source/messages.d.ts +69 -0
- package/dist/source/messages.js +261 -0
- package/dist/source/middleware/audit-message.d.ts +5 -0
- package/dist/source/middleware/audit-message.js +95 -0
- package/dist/source/middleware/index.d.ts +2 -0
- package/dist/source/middleware/index.js +2 -0
- package/dist/source/middleware/rate-limit.d.ts +4 -0
- package/dist/source/middleware/rate-limit.js +17 -0
- package/dist/source/models/ai-config.d.ts +12 -0
- package/dist/source/models/ai-config.js +87 -0
- package/dist/source/models/anthropic-provider.d.ts +25 -0
- package/dist/source/models/anthropic-provider.js +184 -0
- package/dist/source/models/deepseek-provider.d.ts +20 -0
- package/dist/source/models/deepseek-provider.js +42 -0
- package/dist/source/models/google-provider.d.ts +19 -0
- package/dist/source/models/google-provider.js +56 -0
- package/dist/source/models/manager.d.ts +15 -0
- package/dist/source/models/manager.js +48 -0
- package/dist/source/models/openai-provider.d.ts +22 -0
- package/dist/source/models/openai-provider.js +70 -0
- package/dist/source/models/openrouter-provider.d.ts +36 -0
- package/dist/source/models/openrouter-provider.js +276 -0
- package/dist/source/models/providers.d.ts +33 -0
- package/dist/source/models/providers.js +116 -0
- package/dist/source/models/xai-provider.d.ts +20 -0
- package/dist/source/models/xai-provider.js +47 -0
- package/dist/source/parsing.d.ts +2 -0
- package/dist/source/parsing.js +18 -0
- package/dist/source/prompts/manager.d.ts +19 -0
- package/dist/source/prompts/manager.js +71 -0
- package/dist/source/prompts.d.ts +4 -0
- package/dist/source/prompts.js +158 -0
- package/dist/source/repl-prompt.d.ts +14 -0
- package/dist/source/repl-prompt.js +147 -0
- package/dist/source/repl.d.ts +27 -0
- package/dist/source/repl.js +431 -0
- package/dist/source/terminal/formatting.d.ts +37 -0
- package/dist/source/terminal/formatting.js +106 -0
- package/dist/source/terminal/index.d.ts +94 -0
- package/dist/source/terminal/index.js +420 -0
- package/dist/source/terminal/markdown-utils.d.ts +2 -0
- package/dist/source/terminal/markdown-utils.js +81 -0
- package/dist/source/terminal/markdown.d.ts +1 -0
- package/dist/source/terminal/markdown.js +111 -0
- package/dist/source/terminal/types.d.ts +71 -0
- package/dist/source/terminal/types.js +1 -0
- package/dist/source/terminal-output.d.ts +8 -0
- package/dist/source/terminal-output.js +213 -0
- package/dist/source/terminal-output.test.d.ts +8 -0
- package/dist/source/terminal-output.test.js +213 -0
- package/dist/source/token-tracker.d.ts +14 -0
- package/dist/source/token-tracker.js +53 -0
- package/dist/source/token-utils.d.ts +7 -0
- package/dist/source/token-utils.js +13 -0
- package/dist/source/tools/agent.d.ts +17 -0
- package/dist/source/tools/agent.js +87 -0
- package/dist/source/tools/bash.d.ts +19 -0
- package/dist/source/tools/bash.js +294 -0
- package/dist/source/tools/code-interpreter.d.ts +12 -0
- package/dist/source/tools/code-interpreter.js +131 -0
- package/dist/source/tools/command-validation.d.ts +8 -0
- package/dist/source/tools/command-validation.js +69 -0
- package/dist/source/tools/delete-file.d.ts +12 -0
- package/dist/source/tools/delete-file.js +56 -0
- package/dist/source/tools/directory-tree.d.ts +12 -0
- package/dist/source/tools/directory-tree.js +38 -0
- package/dist/source/tools/edit-file.d.ts +19 -0
- package/dist/source/tools/edit-file.js +107 -0
- package/dist/source/tools/filesystem-utils.d.ts +22 -0
- package/dist/source/tools/filesystem-utils.js +191 -0
- package/dist/source/tools/git-utils.d.ts +14 -0
- package/dist/source/tools/git-utils.js +64 -0
- package/dist/source/tools/grep.d.ts +17 -0
- package/dist/source/tools/grep.js +138 -0
- package/dist/source/tools/index.d.ts +161 -0
- package/dist/source/tools/index.js +209 -0
- package/dist/source/tools/memory-read.d.ts +13 -0
- package/dist/source/tools/memory-read.js +135 -0
- package/dist/source/tools/memory-write.d.ts +12 -0
- package/dist/source/tools/memory-write.js +83 -0
- package/dist/source/tools/move-file.d.ts +13 -0
- package/dist/source/tools/move-file.js +44 -0
- package/dist/source/tools/read-file.d.ts +17 -0
- package/dist/source/tools/read-file.js +86 -0
- package/dist/source/tools/read-multiple-files.d.ts +14 -0
- package/dist/source/tools/read-multiple-files.js +55 -0
- package/dist/source/tools/save-file.d.ts +17 -0
- package/dist/source/tools/save-file.js +98 -0
- package/dist/source/tools/think.d.ts +11 -0
- package/dist/source/tools/think.js +45 -0
- package/dist/source/tools/types.d.ts +29 -0
- package/dist/source/tools/types.js +14 -0
- package/dist/source/tools/web-fetch.d.ts +47 -0
- package/dist/source/tools/web-fetch.js +246 -0
- package/dist/source/tools/web-search.d.ts +13 -0
- package/dist/source/tools/web-search.js +80 -0
- package/dist/source/utils/process.d.ts +36 -0
- package/dist/source/utils/process.js +75 -0
- package/dist/source/version.d.ts +1 -0
- package/dist/source/version.js +21 -0
- package/dist/terminal/formatting.d.ts +37 -0
- package/dist/terminal/formatting.js +106 -0
- package/dist/terminal/index.d.ts +94 -0
- package/dist/terminal/index.js +420 -0
- package/dist/terminal/markdown-utils.d.ts +2 -0
- package/dist/terminal/markdown-utils.js +81 -0
- package/dist/terminal/markdown.d.ts +1 -0
- package/dist/terminal/markdown.js +111 -0
- package/dist/terminal/types.d.ts +71 -0
- package/dist/terminal/types.js +1 -0
- package/dist/terminal-output.d.ts +8 -0
- package/dist/terminal-output.js +213 -0
- package/dist/token-tracker.d.ts +14 -0
- package/dist/token-tracker.js +53 -0
- package/dist/token-utils.d.ts +7 -0
- package/dist/token-utils.js +13 -0
- package/dist/tools/agent.d.ts +17 -0
- package/dist/tools/agent.js +87 -0
- package/dist/tools/bash.d.ts +19 -0
- package/dist/tools/bash.js +294 -0
- package/dist/tools/code-interpreter.d.ts +12 -0
- package/dist/tools/code-interpreter.js +131 -0
- package/dist/tools/command-validation.d.ts +8 -0
- package/dist/tools/command-validation.js +69 -0
- package/dist/tools/delete-file.d.ts +12 -0
- package/dist/tools/delete-file.js +56 -0
- package/dist/tools/directory-tree.d.ts +12 -0
- package/dist/tools/directory-tree.js +38 -0
- package/dist/tools/edit-file.d.ts +19 -0
- package/dist/tools/edit-file.js +107 -0
- package/dist/tools/filesystem-utils.d.ts +22 -0
- package/dist/tools/filesystem-utils.js +191 -0
- package/dist/tools/git-utils.d.ts +14 -0
- package/dist/tools/git-utils.js +64 -0
- package/dist/tools/grep.d.ts +17 -0
- package/dist/tools/grep.js +138 -0
- package/dist/tools/index.d.ts +161 -0
- package/dist/tools/index.js +209 -0
- package/dist/tools/memory-read.d.ts +13 -0
- package/dist/tools/memory-read.js +135 -0
- package/dist/tools/memory-write.d.ts +12 -0
- package/dist/tools/memory-write.js +83 -0
- package/dist/tools/move-file.d.ts +13 -0
- package/dist/tools/move-file.js +44 -0
- package/dist/tools/read-file.d.ts +17 -0
- package/dist/tools/read-file.js +86 -0
- package/dist/tools/read-multiple-files.d.ts +14 -0
- package/dist/tools/read-multiple-files.js +55 -0
- package/dist/tools/save-file.d.ts +17 -0
- package/dist/tools/save-file.js +98 -0
- package/dist/tools/think.d.ts +11 -0
- package/dist/tools/think.js +45 -0
- package/dist/tools/types.d.ts +29 -0
- package/dist/tools/types.js +14 -0
- package/dist/tools/web-fetch.d.ts +47 -0
- package/dist/tools/web-fetch.js +246 -0
- package/dist/tools/web-search.d.ts +13 -0
- package/dist/tools/web-search.js +80 -0
- package/dist/utils/process.d.ts +36 -0
- package/dist/utils/process.js +75 -0
- package/dist/version.d.ts +1 -0
- package/dist/version.js +21 -0
- package/knip.json +5 -0
- package/package.json +83 -0
- package/source/cli.ts +172 -0
- package/source/commands/application-log-command.ts +53 -0
- package/source/commands/clear-command.ts +14 -0
- package/source/commands/compact-command.ts +64 -0
- package/source/commands/copy-command.ts +55 -0
- package/source/commands/edit-command.ts +63 -0
- package/source/commands/edit-prompt-command.ts +31 -0
- package/source/commands/exit-command.ts +18 -0
- package/source/commands/files-command.ts +85 -0
- package/source/commands/generate-rules-command.ts +82 -0
- package/source/commands/help-command.ts +27 -0
- package/source/commands/init-command.ts +48 -0
- package/source/commands/last-log-command.ts +88 -0
- package/source/commands/manager.ts +151 -0
- package/source/commands/model-command.ts +123 -0
- package/source/commands/paste-command.ts +62 -0
- package/source/commands/prompt-command.ts +150 -0
- package/source/commands/reset-command.ts +22 -0
- package/source/commands/rules-command.ts +76 -0
- package/source/commands/save-command.ts +20 -0
- package/source/commands/types.ts +28 -0
- package/source/commands/usage-command.ts +26 -0
- package/source/config.ts +223 -0
- package/source/conversation-analyzer.ts +115 -0
- package/source/dedent.ts +53 -0
- package/source/formatting.ts +132 -0
- package/source/index.ts +240 -0
- package/source/logger.ts +29 -0
- package/source/mentions.ts +227 -0
- package/source/messages.ts +360 -0
- package/source/middleware/audit-message.ts +133 -0
- package/source/middleware/index.ts +2 -0
- package/source/middleware/rate-limit.ts +24 -0
- package/source/models/ai-config.ts +109 -0
- package/source/models/anthropic-provider.ts +199 -0
- package/source/models/deepseek-provider.ts +53 -0
- package/source/models/google-provider.ts +68 -0
- package/source/models/manager.ts +84 -0
- package/source/models/openai-provider.ts +81 -0
- package/source/models/openrouter-provider.ts +288 -0
- package/source/models/providers.ts +197 -0
- package/source/models/xai-provider.ts +59 -0
- package/source/parsing.ts +20 -0
- package/source/prompts/manager.ts +90 -0
- package/source/prompts.ts +172 -0
- package/source/repl-prompt.ts +196 -0
- package/source/repl.ts +572 -0
- package/source/terminal/formatting.ts +121 -0
- package/source/terminal/index.ts +518 -0
- package/source/terminal/markdown-utils.ts +89 -0
- package/source/terminal/markdown.ts +155 -0
- package/source/terminal/types.ts +84 -0
- package/source/terminal-output.test.ts +266 -0
- package/source/token-tracker.ts +78 -0
- package/source/token-utils.ts +17 -0
- package/source/tools/agent.ts +107 -0
- package/source/tools/bash.ts +367 -0
- package/source/tools/code-interpreter.ts +172 -0
- package/source/tools/command-validation.ts +81 -0
- package/source/tools/delete-file.ts +71 -0
- package/source/tools/directory-tree.ts +54 -0
- package/source/tools/edit-file.ts +155 -0
- package/source/tools/filesystem-utils.ts +265 -0
- package/source/tools/git-utils.ts +70 -0
- package/source/tools/grep.ts +184 -0
- package/source/tools/index.ts +278 -0
- package/source/tools/memory-read.ts +174 -0
- package/source/tools/memory-write.ts +105 -0
- package/source/tools/move-file.ts +59 -0
- package/source/tools/read-file.ts +129 -0
- package/source/tools/read-multiple-files.ts +80 -0
- package/source/tools/save-file.ts +147 -0
- package/source/tools/think.ts +51 -0
- package/source/tools/types.ts +58 -0
- package/source/tools/web-fetch.ts +327 -0
- package/source/tools/web-search.ts +101 -0
- package/source/utils/process.ts +121 -0
- package/source/version.ts +21 -0
- package/test/commands/copy-command.test.ts +69 -0
- package/test/config.test.ts +200 -0
- package/test/terminal/markdown-utils.test.ts +124 -0
- package/test/tools/bash-tool.test.ts +58 -0
- package/test/tools/code-interpreter.test.ts +91 -0
- package/test/tools/command-validation.test.ts +48 -0
- package/tsconfig.build.json +9 -0
- package/tsconfig.json +30 -0
|
@@ -0,0 +1,172 @@
|
|
|
1
|
+
import { readFile } from "node:fs/promises";
|
|
2
|
+
import { platform } from "node:os";
|
|
3
|
+
import path from "node:path";
|
|
4
|
+
import { config } from "./config.ts";
|
|
5
|
+
import { dedent } from "./dedent.ts";
|
|
6
|
+
import { AgentTool } from "./tools/agent.ts";
|
|
7
|
+
import { BashTool } from "./tools/bash.ts";
|
|
8
|
+
import { CodeInterpreterTool } from "./tools/code-interpreter.ts";
|
|
9
|
+
import { DirectoryTreeTool } from "./tools/directory-tree.ts";
|
|
10
|
+
import { EditFileTool } from "./tools/edit-file.ts";
|
|
11
|
+
import { getCurrentBranch, inGitDirectory } from "./tools/git-utils.ts";
|
|
12
|
+
import { GrepTool } from "./tools/grep.ts";
|
|
13
|
+
import { ReadFileTool } from "./tools/read-file.ts";
|
|
14
|
+
import { SaveFileTool } from "./tools/save-file.ts";
|
|
15
|
+
import { ThinkTool } from "./tools/think.ts";
|
|
16
|
+
import { WebFetchTool } from "./tools/web-fetch.ts";
|
|
17
|
+
import { WebSearchTool } from "./tools/web-search.ts";
|
|
18
|
+
|
|
19
|
+
function intro() {
|
|
20
|
+
return "You are acai, an AI-powered CLI assistant that accelerates software engineering workflows through intelligent command-line assistance.";
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
async function instructions() {
|
|
24
|
+
const systemMdPath = path.join(config.project.getPath(), "system.md");
|
|
25
|
+
try {
|
|
26
|
+
const content = await readFile(systemMdPath, "utf8");
|
|
27
|
+
if (content.trim()) {
|
|
28
|
+
return content;
|
|
29
|
+
}
|
|
30
|
+
} catch {
|
|
31
|
+
// system.md doesn't exist or is empty, use default instructions
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
return `## Core Principles
|
|
35
|
+
|
|
36
|
+
- **CLI-Optimized**: Be concise and direct - responses appear in a terminal.
|
|
37
|
+
- **Progressive Problem Solving**: Work through problems methodically until resolution.
|
|
38
|
+
- **User Authority**: NEVER commit changes or add dependencies without explicit user approval.
|
|
39
|
+
- **Security-First**: Prioritize secure coding practices in all suggestions.
|
|
40
|
+
- **Completion Focus**: Continue working until the user's query is completely resolved.
|
|
41
|
+
- **Expert Level**: Assume the user is an experienced software engineer.
|
|
42
|
+
|
|
43
|
+
## Response Format
|
|
44
|
+
|
|
45
|
+
- **Direct Answers**: One-word or concise answers when possible.
|
|
46
|
+
- **Code First**: Lead with code snippets for code-related queries.
|
|
47
|
+
- **No Fluff**: Avoid preambles or phrases like "Here is the content..."
|
|
48
|
+
- **Error Reporting**: Specify error, location, and fix (e.g., \`Error: TypeError at auth.ts:42. Fix: Add null check.\`).
|
|
49
|
+
|
|
50
|
+
## Work Standards
|
|
51
|
+
|
|
52
|
+
### Code Quality
|
|
53
|
+
- Match existing code conventions and patterns
|
|
54
|
+
- Use libraries/utilities already in the project
|
|
55
|
+
- Prioritize maintainable, readable code over clever solutions
|
|
56
|
+
|
|
57
|
+
### Security & Error Handling
|
|
58
|
+
- Validate/sanitize all inputs and outputs
|
|
59
|
+
- Use parameterized queries for databases
|
|
60
|
+
- Never hardcode secrets; prevent injection attacks, XSS, unauthorized access
|
|
61
|
+
- Apply principle of least privilege in API integrations
|
|
62
|
+
- If a tool fails, ask the user how to proceed
|
|
63
|
+
- Report errors with specific locations and suggested fixes`;
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
function toolUsage() {
|
|
67
|
+
return `## Tool Usage Guidelines
|
|
68
|
+
|
|
69
|
+
### Information Gathering
|
|
70
|
+
- Use \`${DirectoryTreeTool.name}\` for project structure
|
|
71
|
+
- Use \`${ReadFileTool.name}\` for file contents if filenames are provided in the prompt
|
|
72
|
+
- Use \`${GrepTool.name}\` for code pattern searches
|
|
73
|
+
- Use \`${WebFetchTool.name}\` for text-based URLs provided in the prompt
|
|
74
|
+
- Use \`${WebSearchTool.name}\` for external research (e.g., libraries, errors)
|
|
75
|
+
- Use \`${AgentTool.name}\` for iterative keyword/file searches
|
|
76
|
+
- If file contents or URLs are provided in the prompt, use them directly without re-fetching
|
|
77
|
+
- Always verify file contents before suggesting changes unless provided in the prompt
|
|
78
|
+
|
|
79
|
+
### Code Modification
|
|
80
|
+
- Use \`${EditFileTool.name}\` for existing file edits (requires user approval)
|
|
81
|
+
- Use \`${SaveFileTool.name}\` for new files only
|
|
82
|
+
|
|
83
|
+
### Planning & Complex Tasks
|
|
84
|
+
- Use \`${ThinkTool.name}\` for structured reasoning on complex problems
|
|
85
|
+
- Outline multi-step tasks before execution
|
|
86
|
+
|
|
87
|
+
### Bash Commands (\`${BashTool.name}\`)
|
|
88
|
+
- Execute bash commands within project directory only
|
|
89
|
+
- Always specify absolute paths to avoid errors
|
|
90
|
+
- You have access to the Github CLI
|
|
91
|
+
- **Background Processes:** Use background processes (via \`&\`) for commands that are unlikely to stop on their own, e.g. \`node server.js &\`. If unsure, ask the user.
|
|
92
|
+
- **Interactive Commands:** Try to avoid shell commands that are likely to require user interaction (e.g. \`git rebase -i\`). Use non-interactive versions of commands (e.g. \`npm init -y\` instead of \`npm init\`) when available, and otherwise remind the user that interactive shell commands are not supported and may cause hangs until canceled by the user.
|
|
93
|
+
|
|
94
|
+
### Code Interpreter (\`${CodeInterpreterTool.name}\`)
|
|
95
|
+
- Executes JavaScript code in a separate Node.js process using Node's Permission Model
|
|
96
|
+
- By default, the child process has no permissions except read/write within the current working directory
|
|
97
|
+
- Returns stdout, stderr, and exitCode
|
|
98
|
+
- Use console.log/console.error to produce outpu`;
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
function escalationProcedures() {
|
|
102
|
+
return `## Escalation
|
|
103
|
+
|
|
104
|
+
- If stuck, state the limitation, suggest alternatives, and ask the user for guidance`;
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
async function getRules() {
|
|
108
|
+
const rules = (await config.readAgentsFile()).trim();
|
|
109
|
+
const learnedRules = (await config.readProjectLearnedRulesFile()).trim();
|
|
110
|
+
let result = "";
|
|
111
|
+
if (rules) {
|
|
112
|
+
result += `## Project Rules:\n\n${rules}\n`;
|
|
113
|
+
}
|
|
114
|
+
if (learnedRules) {
|
|
115
|
+
if (!rules) {
|
|
116
|
+
result += "## Project Rules:\n\n";
|
|
117
|
+
}
|
|
118
|
+
result += `### Important rules to follow\n\n${learnedRules}`;
|
|
119
|
+
}
|
|
120
|
+
return result.trim();
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
async function environmentInfo() {
|
|
124
|
+
const gitDirectory = await inGitDirectory();
|
|
125
|
+
let gitSection = `- **Is directory a git repo**: ${gitDirectory ? "Yes" : "No"}`;
|
|
126
|
+
if (gitDirectory) {
|
|
127
|
+
gitSection += `\n- ** Current git branch**: ${await getCurrentBranch()}`;
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
return `## Environment
|
|
131
|
+
|
|
132
|
+
- **Current working directory**: ${process.cwd()}. [Use this value directly instead of calling the \`${BashTool.name}(pwd)\` tool unless you have a specific reason to verify it].
|
|
133
|
+
${gitSection}
|
|
134
|
+
- **Platform**: ${platform()}
|
|
135
|
+
- **Today's date**: ${(new Date()).toISOString()}`;
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
export async function systemPrompt(options?: {
|
|
139
|
+
supportsToolCalling?: boolean;
|
|
140
|
+
}) {
|
|
141
|
+
const { supportsToolCalling = true } = options ?? {};
|
|
142
|
+
|
|
143
|
+
const prompt = dedent`
|
|
144
|
+
${intro()}
|
|
145
|
+
|
|
146
|
+
${await instructions()}
|
|
147
|
+
|
|
148
|
+
${supportsToolCalling ? toolUsage() : ""}
|
|
149
|
+
|
|
150
|
+
${escalationProcedures()}
|
|
151
|
+
|
|
152
|
+
${await getRules()}
|
|
153
|
+
|
|
154
|
+
${await environmentInfo()}
|
|
155
|
+
`;
|
|
156
|
+
|
|
157
|
+
return prompt;
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
export async function minSystemPrompt() {
|
|
161
|
+
const prompt = dedent`
|
|
162
|
+
${intro()}
|
|
163
|
+
|
|
164
|
+
${await instructions()}
|
|
165
|
+
|
|
166
|
+
${await getRules()}
|
|
167
|
+
|
|
168
|
+
${await environmentInfo()}
|
|
169
|
+
`;
|
|
170
|
+
|
|
171
|
+
return prompt;
|
|
172
|
+
}
|
|
@@ -0,0 +1,196 @@
|
|
|
1
|
+
import { readdir } from "node:fs/promises";
|
|
2
|
+
import { parse, sep } from "node:path";
|
|
3
|
+
import { createInterface, type Interface } from "node:readline/promises";
|
|
4
|
+
import Clipboard from "@crosscopy/clipboard";
|
|
5
|
+
import { asyncTry } from "@travisennis/stdlib/try";
|
|
6
|
+
import type { CommandManager } from "./commands/manager.ts";
|
|
7
|
+
import { logger } from "./logger.ts";
|
|
8
|
+
|
|
9
|
+
const whitespaceRegex = /\s+/;
|
|
10
|
+
|
|
11
|
+
async function fileSystemCompleter(line: string): Promise<[string[], string]> {
|
|
12
|
+
try {
|
|
13
|
+
const words = line.split(" ");
|
|
14
|
+
let last = words.at(-1);
|
|
15
|
+
if (!last) {
|
|
16
|
+
return [[], line];
|
|
17
|
+
}
|
|
18
|
+
const isAt = last.startsWith("@");
|
|
19
|
+
if (isAt) {
|
|
20
|
+
last = last.slice(1);
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
let { dir, base } = parse(last);
|
|
24
|
+
|
|
25
|
+
// If dir is empty, use current directory
|
|
26
|
+
if (!dir) {
|
|
27
|
+
dir = ".";
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
let tryAttempt = await asyncTry(readdir(dir, { withFileTypes: true }));
|
|
31
|
+
if (tryAttempt.isFailure) {
|
|
32
|
+
tryAttempt = await asyncTry(readdir(".", { withFileTypes: true }));
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
let dirEntries = tryAttempt.unwrap();
|
|
36
|
+
|
|
37
|
+
// for an exact match that is a directory, read the contents of the directory
|
|
38
|
+
if (
|
|
39
|
+
dirEntries.find((entry) => entry.name === base && entry.isDirectory())
|
|
40
|
+
) {
|
|
41
|
+
dir = dir === "/" || dir === sep ? `${dir}${base}` : `${dir}/${base}`;
|
|
42
|
+
dirEntries = await readdir(dir, { withFileTypes: true });
|
|
43
|
+
base = "";
|
|
44
|
+
} else {
|
|
45
|
+
dirEntries = dirEntries.filter((entry) => entry.name.startsWith(base));
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
const hits = dirEntries
|
|
49
|
+
.filter((entry) => entry.isFile() || entry.isDirectory())
|
|
50
|
+
.map((entry) => {
|
|
51
|
+
const prefix =
|
|
52
|
+
dir === "." ? "" : dir === sep || dir === "/" ? "" : `${dir}/`;
|
|
53
|
+
return `${isAt ? "@" : ""}${prefix}${entry.name}${entry.isDirectory() && !entry.name.endsWith("/") ? "/" : ""}`;
|
|
54
|
+
});
|
|
55
|
+
|
|
56
|
+
return [hits, `${isAt ? "@" : ""}${last}`];
|
|
57
|
+
} catch (_error) {
|
|
58
|
+
logger.error(_error);
|
|
59
|
+
return [[], line];
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
export class ReplPrompt {
|
|
64
|
+
// biome-ignore lint/suspicious/noExplicitAny: Keypress listener signature
|
|
65
|
+
private keypressListener?: (str: string, key: any) => void;
|
|
66
|
+
private rl: Interface;
|
|
67
|
+
private history: string[];
|
|
68
|
+
private maxHistory = 25;
|
|
69
|
+
|
|
70
|
+
constructor({
|
|
71
|
+
commands,
|
|
72
|
+
history,
|
|
73
|
+
}: { commands: CommandManager; history: string[] }) {
|
|
74
|
+
this.history = history;
|
|
75
|
+
|
|
76
|
+
this.rl = createInterface({
|
|
77
|
+
input: process.stdin,
|
|
78
|
+
output: process.stdout,
|
|
79
|
+
history: this.history,
|
|
80
|
+
historySize: this.maxHistory,
|
|
81
|
+
completer: async (line): Promise<[string[], string]> => {
|
|
82
|
+
const completions = commands.getCommands();
|
|
83
|
+
const words = line.trim().split(whitespaceRegex);
|
|
84
|
+
const firstWord = words[0] ?? "";
|
|
85
|
+
const rest: string = words.slice(1).join(" ") ?? "";
|
|
86
|
+
|
|
87
|
+
const matchingCommands = completions.filter((c) =>
|
|
88
|
+
c.startsWith(firstWord),
|
|
89
|
+
);
|
|
90
|
+
|
|
91
|
+
if (matchingCommands.length === 1 && rest !== "") {
|
|
92
|
+
// Single command matched, try to get subcommands
|
|
93
|
+
const subCompletions = await commands.getSubCommands(
|
|
94
|
+
matchingCommands[0] ?? "",
|
|
95
|
+
);
|
|
96
|
+
const hits = subCompletions.filter(
|
|
97
|
+
(sc) => sc.startsWith(rest) || rest === "*",
|
|
98
|
+
);
|
|
99
|
+
if (hits.length > 0) {
|
|
100
|
+
return [hits.map((h) => `${firstWord} ${h}`), line];
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
if (
|
|
105
|
+
matchingCommands.length > 0 &&
|
|
106
|
+
(words.length === 1 || line.endsWith(" "))
|
|
107
|
+
) {
|
|
108
|
+
return [matchingCommands, line];
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
return fileSystemCompleter(line); // [completions, line];
|
|
112
|
+
},
|
|
113
|
+
});
|
|
114
|
+
|
|
115
|
+
if (process.stdin.isTTY) {
|
|
116
|
+
this.keypressListener = async (
|
|
117
|
+
_str: string,
|
|
118
|
+
key: {
|
|
119
|
+
name: string;
|
|
120
|
+
ctrl: boolean;
|
|
121
|
+
meta: boolean;
|
|
122
|
+
shift: boolean;
|
|
123
|
+
sequence: string;
|
|
124
|
+
},
|
|
125
|
+
) => {
|
|
126
|
+
// if (this.rl.closed) {
|
|
127
|
+
// if (this.keypressListener) {
|
|
128
|
+
// process.stdin.off("keypress", this.keypressListener);
|
|
129
|
+
// this.keypressListener = undefined;
|
|
130
|
+
// }
|
|
131
|
+
// return;
|
|
132
|
+
// }
|
|
133
|
+
|
|
134
|
+
if (key?.ctrl && key.name === "v" && !key.meta && !key.shift) {
|
|
135
|
+
try {
|
|
136
|
+
const clipboardText = await Clipboard.getText();
|
|
137
|
+
if (clipboardText) {
|
|
138
|
+
const currentLine = this.rl.line;
|
|
139
|
+
const cursorPos = this.rl.cursor;
|
|
140
|
+
|
|
141
|
+
const beforeCursor = currentLine.substring(0, cursorPos);
|
|
142
|
+
const afterCursor = currentLine.substring(cursorPos);
|
|
143
|
+
|
|
144
|
+
const newLine = beforeCursor + clipboardText + afterCursor;
|
|
145
|
+
|
|
146
|
+
// biome-ignore lint/suspicious/noExplicitAny: Accessing internal readline method
|
|
147
|
+
(this.rl as any).line = newLine;
|
|
148
|
+
// biome-ignore lint/suspicious/noExplicitAny: Accessing internal readline method
|
|
149
|
+
(this.rl as any).cursor = cursorPos + clipboardText.length;
|
|
150
|
+
|
|
151
|
+
// biome-ignore lint/suspicious/noExplicitAny: Accessing internal readline method
|
|
152
|
+
(this.rl as any)._refreshLine();
|
|
153
|
+
}
|
|
154
|
+
} catch (error) {
|
|
155
|
+
logger.error(
|
|
156
|
+
`Failed to paste from clipboard: ${(error as Error).message}`,
|
|
157
|
+
);
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
};
|
|
161
|
+
process.stdin.on("keypress", this.keypressListener);
|
|
162
|
+
}
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
async input() {
|
|
166
|
+
const input = await this.rl.question("> ");
|
|
167
|
+
|
|
168
|
+
// The readline interface automatically adds the input to the history.
|
|
169
|
+
// We need to handle two things:
|
|
170
|
+
// 1. Don't save empty lines.
|
|
171
|
+
// 2. Enforce max history size.
|
|
172
|
+
if (!input.trim()) {
|
|
173
|
+
// Last entry was this empty input, so remove it.
|
|
174
|
+
this.history.pop();
|
|
175
|
+
} else {
|
|
176
|
+
// A valid command was added. Trim history if needed.
|
|
177
|
+
while (this.history.length > this.maxHistory) {
|
|
178
|
+
this.history.shift();
|
|
179
|
+
}
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
return input;
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
close() {
|
|
186
|
+
if (this.keypressListener) {
|
|
187
|
+
process.stdin.off("keypress", this.keypressListener);
|
|
188
|
+
this.keypressListener = undefined;
|
|
189
|
+
}
|
|
190
|
+
this.rl.close();
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
[Symbol.dispose]() {
|
|
194
|
+
this.close();
|
|
195
|
+
}
|
|
196
|
+
}
|