@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
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2024 Travis Ennis
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,392 @@
|
|
|
1
|
+
# Acai: AI-Powered Software Development Assistant
|
|
2
|
+
|
|
3
|
+

|
|
4
|
+

|
|
5
|
+
<!-- Add more badges as appropriate, e.g., build status, version, etc. -->
|
|
6
|
+
|
|
7
|
+
## 🚀 Overview
|
|
8
|
+
|
|
9
|
+
Acai is a powerful **AI-driven command-line interface (CLI) tool** designed to assist software developers in their daily tasks. It acts as an intelligent assistant, capable of understanding natural language prompts, interacting with your codebase, and automating various development workflows.
|
|
10
|
+
|
|
11
|
+
### Core Functionality:
|
|
12
|
+
|
|
13
|
+
* **Interactive AI Assistant:** Engage in a conversational REPL (Read-Eval-Print Loop) to get assistance with coding, debugging, refactoring, and more.
|
|
14
|
+
* **Codebase Interaction:** Read, edit, and navigate files; search code; and understand project structure.
|
|
15
|
+
* **Git Integration:** Generate conventional commits, review pull requests, and manage local changes.
|
|
16
|
+
* **Extensible Tooling:** Utilizes a suite of internal tools (e.g., `bash`, `codeInterpreter`, `webSearch`) to perform actions.
|
|
17
|
+
* **Multi-Model Support:** Seamlessly switch between various AI providers (e.g., OpenAI, Google, Anthropic, DeepSeek, OpenRouter).
|
|
18
|
+
* **Context Management:** Automatically incorporates relevant file content, clipboard data, and conversation history into AI prompts.
|
|
19
|
+
* **Configurable & Learnable:** Customize behavior through project-specific rules and learn from user corrections.
|
|
20
|
+
|
|
21
|
+
## ✨ Features
|
|
22
|
+
|
|
23
|
+
* **Conversational REPL:** Intuitive command-line interface for interacting with the AI.
|
|
24
|
+
* **File System Operations:** Read, write, edit, move, and delete files.
|
|
25
|
+
* **File & Directory Mentions:** Include file contents and entire directories in prompts using `@filename` and `@dirname` syntax.
|
|
26
|
+
* **Code Navigation & Analysis:** Leverage Tree-sitter for intelligent code understanding.
|
|
27
|
+
* **Git Workflow Automation:** Streamline commit messages and code reviews.
|
|
28
|
+
* **Web Integration:** Perform web searches and fetch content from URLs.
|
|
29
|
+
* **Extensible Commands:** A rich set of built-in commands (`/files`, `/edit`, `/commit`, `/model`, `/help`, etc.).
|
|
30
|
+
* **Token Usage Tracking:** Monitor AI token consumption.
|
|
31
|
+
* **Configurable AI Models:** Easily switch between different LLM providers and models.
|
|
32
|
+
* **Shell Integration:** Execute shell commands inline using `!`command`` syntax.
|
|
33
|
+
|
|
34
|
+
## 🛠️ Technologies Used
|
|
35
|
+
|
|
36
|
+
Acai is built primarily with **TypeScript** and runs on **Node.js**. Key technologies and dependencies include:
|
|
37
|
+
|
|
38
|
+
* **TypeScript:** For type-safe and scalable code.
|
|
39
|
+
* **Node.js:** The JavaScript runtime environment.
|
|
40
|
+
* **AI SDK (`@ai-sdk/*`):** For integrating with various Large Language Models (LLMs) like OpenAI, Google Gemini, Anthropic, DeepSeek, and OpenRouter.
|
|
41
|
+
* **Tree-sitter:** For robust and efficient code parsing and syntax analysis across multiple programming languages (TypeScript, JavaScript, Java, Python).
|
|
42
|
+
* **`chalk`, `ora`, `log-update`:** For rich and interactive terminal output.
|
|
43
|
+
* **`@inquirer/prompts`:** For interactive prompts; CLI args parsed with Node's `util.parseArgs`.
|
|
44
|
+
* **`simple-git`:** For Git operations.
|
|
45
|
+
* **`ripgrep` (via `grep.ts` tool):** For fast file content searching.
|
|
46
|
+
* **`marked`:** For rendering Markdown in the terminal.
|
|
47
|
+
* **`pino`:** For structured logging.
|
|
48
|
+
* **`zod`:** For schema validation.
|
|
49
|
+
* **`biomejs/biome`:** For code formatting and linting.
|
|
50
|
+
|
|
51
|
+
## 🚀 Getting Started
|
|
52
|
+
|
|
53
|
+
### Prerequisites
|
|
54
|
+
|
|
55
|
+
**Required:**
|
|
56
|
+
* Node.js 18.20.0 or higher
|
|
57
|
+
* Git
|
|
58
|
+
* [Ripgrep](https://github.com/BurntSushi/ripgrep) (`rg` command) - Fast file content searching
|
|
59
|
+
* [GitHub CLI](https://cli.github.com/) (`gh` command) - Git operations and repository management
|
|
60
|
+
|
|
61
|
+
**Installation of system dependencies:**
|
|
62
|
+
|
|
63
|
+
```bash
|
|
64
|
+
# macOS (using Homebrew)
|
|
65
|
+
brew install ripgrep gh
|
|
66
|
+
|
|
67
|
+
# Ubuntu/Debian
|
|
68
|
+
sudo apt install ripgrep gh
|
|
69
|
+
|
|
70
|
+
# Windows (using Chocolatey)
|
|
71
|
+
choco install ripgrep gh
|
|
72
|
+
|
|
73
|
+
# Or using winget
|
|
74
|
+
winget install BurntSushi.ripgrep GitHub.cli
|
|
75
|
+
```
|
|
76
|
+
|
|
77
|
+
**Optional but recommended:**
|
|
78
|
+
* API keys for AI providers (see Environment Variables section below)
|
|
79
|
+
|
|
80
|
+
### Installation for Users
|
|
81
|
+
|
|
82
|
+
```bash
|
|
83
|
+
npm install -g @travisennis/acai
|
|
84
|
+
```
|
|
85
|
+
|
|
86
|
+
### Installation for Developers
|
|
87
|
+
|
|
88
|
+
```bash
|
|
89
|
+
# Clone the repository
|
|
90
|
+
git clone https://github.com/travisennis/acai-ts.git # Assuming this is the repo URL
|
|
91
|
+
cd acai-ts
|
|
92
|
+
|
|
93
|
+
# Install dependencies
|
|
94
|
+
npm install
|
|
95
|
+
|
|
96
|
+
# Set up environment variables (see Environment Variables section)
|
|
97
|
+
cp .env.example .env # If .env.example exists, or create .env manually
|
|
98
|
+
# Edit .env file with your API keys
|
|
99
|
+
|
|
100
|
+
# Build the project
|
|
101
|
+
npm run build
|
|
102
|
+
|
|
103
|
+
# Link the CLI tool globally (optional, for easy access)
|
|
104
|
+
npm link
|
|
105
|
+
```
|
|
106
|
+
|
|
107
|
+
## Environment Variables
|
|
108
|
+
|
|
109
|
+
Acai supports various AI providers and web services through environment variables. Create a `.env` file in your project root or set these variables in your shell environment.
|
|
110
|
+
|
|
111
|
+
### AI Provider API Keys
|
|
112
|
+
|
|
113
|
+
```bash
|
|
114
|
+
# OpenAI (GPT models)
|
|
115
|
+
OPENAI_API_KEY=your_openai_api_key_here
|
|
116
|
+
|
|
117
|
+
# Anthropic (Claude models)
|
|
118
|
+
ANTHROPIC_API_KEY=your_anthropic_api_key_here
|
|
119
|
+
|
|
120
|
+
# Google (Gemini models)
|
|
121
|
+
GOOGLE_API_KEY=your_google_api_key_here
|
|
122
|
+
|
|
123
|
+
# DeepSeek
|
|
124
|
+
DEEPSEEK_API_KEY=your_deepseek_api_key_here
|
|
125
|
+
|
|
126
|
+
# X.AI (Grok models)
|
|
127
|
+
X_AI_API_KEY=your_xai_api_key_here
|
|
128
|
+
# Alternative name also supported:
|
|
129
|
+
# XAI_API_KEY=your_xai_api_key_here
|
|
130
|
+
|
|
131
|
+
# OpenRouter (Access to multiple models)
|
|
132
|
+
OPENROUTER_API_KEY=your_openrouter_api_key_here
|
|
133
|
+
```
|
|
134
|
+
|
|
135
|
+
### Web Service API Keys (Optional)
|
|
136
|
+
|
|
137
|
+
```bash
|
|
138
|
+
# Exa (for enhanced web search functionality)
|
|
139
|
+
# Optional: Falls back to DuckDuckGo search if not provided
|
|
140
|
+
EXA_API_KEY=your_exa_api_key_here
|
|
141
|
+
|
|
142
|
+
# Jina Reader (for enhanced web content extraction)
|
|
143
|
+
JINA_READER_API_KEY=your_jina_api_key_here
|
|
144
|
+
```
|
|
145
|
+
|
|
146
|
+
### Application Configuration
|
|
147
|
+
|
|
148
|
+
```bash
|
|
149
|
+
# Logging level (optional, defaults to "debug")
|
|
150
|
+
# Options: trace, debug, info, warn, error, fatal
|
|
151
|
+
LOG_LEVEL=info
|
|
152
|
+
```
|
|
153
|
+
|
|
154
|
+
### Example .env File
|
|
155
|
+
|
|
156
|
+
```bash
|
|
157
|
+
# Core AI providers (at least one recommended)
|
|
158
|
+
OPENAI_API_KEY=sk-...
|
|
159
|
+
ANTHROPIC_API_KEY=sk-ant-...
|
|
160
|
+
|
|
161
|
+
# Optional: Additional providers
|
|
162
|
+
GOOGLE_API_KEY=...
|
|
163
|
+
OPENROUTER_API_KEY=sk-or-...
|
|
164
|
+
|
|
165
|
+
# Optional: Web services (fallbacks available if not provided)
|
|
166
|
+
EXA_API_KEY=... # Falls back to DuckDuckGo search
|
|
167
|
+
|
|
168
|
+
# Optional: Application settings
|
|
169
|
+
LOG_LEVEL=info
|
|
170
|
+
```
|
|
171
|
+
|
|
172
|
+
**Note:** You need at least one AI provider API key to use Acai. The tool will work with any combination of the supported providers.
|
|
173
|
+
|
|
174
|
+
**Web Search:** The web search functionality works without any API keys by using DuckDuckGo as a fallback. Providing an EXA_API_KEY enables enhanced search capabilities with more detailed content extraction.
|
|
175
|
+
|
|
176
|
+
### Usage
|
|
177
|
+
|
|
178
|
+
```bash
|
|
179
|
+
# Start interactive mode with default model
|
|
180
|
+
acai
|
|
181
|
+
|
|
182
|
+
# Specify a model
|
|
183
|
+
acai --model anthropic:sonnet
|
|
184
|
+
|
|
185
|
+
# One-shot mode
|
|
186
|
+
acai -p "What files contain the term 'toolCallRepair'?" -o
|
|
187
|
+
|
|
188
|
+
# Pipe input
|
|
189
|
+
echo "How many TypeScript files are in this project?" | acai
|
|
190
|
+
```
|
|
191
|
+
|
|
192
|
+
Once in the REPL, you can type your prompts or use commands:
|
|
193
|
+
|
|
194
|
+
```
|
|
195
|
+
> How do I read a file in Node.js?
|
|
196
|
+
> /files add source/index.ts
|
|
197
|
+
> /edit source/cli.ts "Change this function name"
|
|
198
|
+
> /help
|
|
199
|
+
```
|
|
200
|
+
|
|
201
|
+
### Prompt Mentions & Special Syntax
|
|
202
|
+
|
|
203
|
+
You can reference files and directories directly in your prompts:
|
|
204
|
+
|
|
205
|
+
```
|
|
206
|
+
> Explain the purpose of @source/index.ts
|
|
207
|
+
> What patterns do you see in @source/tools/ directory
|
|
208
|
+
> Find security issues in @config/ directory
|
|
209
|
+
> Check if `!ls -la` shows any suspicious files
|
|
210
|
+
> Analyze @README.md for typos
|
|
211
|
+
```
|
|
212
|
+
|
|
213
|
+
**Supported syntax:**
|
|
214
|
+
- `@filename` - Include contents of a specific file
|
|
215
|
+
- `@dirname` - Recursively include all files in a directory
|
|
216
|
+
- `@http://example.com` - Fetch and include web content
|
|
217
|
+
- ``!`command` `` - Execute shell command and include output
|
|
218
|
+
|
|
219
|
+
For a list of available commands, type `/help` within the REPL.
|
|
220
|
+
|
|
221
|
+
## Interactive CLI Commands
|
|
222
|
+
|
|
223
|
+
- `/help` - Shows usage information
|
|
224
|
+
- `/reset` - Saves chat history and resets the conversation
|
|
225
|
+
- `/save` - Saves chat history
|
|
226
|
+
- `/compact` - Saves, summarizes and resets the chat history
|
|
227
|
+
- `/exit` or `/bye` - Exits and saves chat history
|
|
228
|
+
- `/files [pattern]` - Select files interactively or by pattern, adding content to prompt
|
|
229
|
+
- `/init` - Generate or improve `AGENTS.md`
|
|
230
|
+
- `/editPrompt` - Edit the current prompt
|
|
231
|
+
- `/paste` - Add clipboard contents to the next prompt
|
|
232
|
+
- `/prompt <name>` - Load saved prompts. Project prompts override user prompts.
|
|
233
|
+
- `/rules [view|add <text>|edit]` - View or edit persistent project rules/memories (formerly /memory)
|
|
234
|
+
- `/model [provider:model|category|provider]` - List or switch models
|
|
235
|
+
- `/usage` - Show token usage breakdown
|
|
236
|
+
- `/clear` - Clears the terminal screen for the current session
|
|
237
|
+
- `/lastLog` - Show the last application log entries
|
|
238
|
+
- `/appLog` - Show or follow the application log
|
|
239
|
+
- `/generateRules` - Analyze the current conversation and suggest project rules
|
|
240
|
+
- `/edit <path> "<change description>"` - Edit a file with AI assistance
|
|
241
|
+
- `/copy` - Copy the last assistant response to the system clipboard
|
|
242
|
+
|
|
243
|
+
Clipboard notes:
|
|
244
|
+
- macOS: uses `pbcopy`
|
|
245
|
+
- Windows: uses `clip`
|
|
246
|
+
- Linux: tries `xclip`, falls back to `xsel`
|
|
247
|
+
|
|
248
|
+
## Configuration
|
|
249
|
+
|
|
250
|
+
### Project Configuration
|
|
251
|
+
|
|
252
|
+
Acai supports project-specific configuration through a `.acai/acai.json` file in your project directory:
|
|
253
|
+
|
|
254
|
+
```json
|
|
255
|
+
{
|
|
256
|
+
"logs": {
|
|
257
|
+
"path": "~/.acai/logs/acai.log" // Optional: Custom log file location
|
|
258
|
+
},
|
|
259
|
+
"notify": true, // Optional: Enable system notifications (default: false)
|
|
260
|
+
"tools": {
|
|
261
|
+
"maxTokens": 30000 // Optional: Global max token limit for tools
|
|
262
|
+
}
|
|
263
|
+
}
|
|
264
|
+
```
|
|
265
|
+
|
|
266
|
+
### Project-Specific Customization
|
|
267
|
+
|
|
268
|
+
- **Rules/Guidelines**: Add project-specific AI behavior rules in `AGENTS.md`
|
|
269
|
+
- **Custom Prompts**: Store reusable prompts in `.acai/prompts/`
|
|
270
|
+
- **Context Selections**: Save file/directory selections in `.acai/context/`
|
|
271
|
+
- **Memory/Rules**: Persistent project rules stored in `.acai/rules/`
|
|
272
|
+
|
|
273
|
+
### Global Configuration
|
|
274
|
+
|
|
275
|
+
Global application settings are stored in:
|
|
276
|
+
- **Configuration**: `~/.acai/`
|
|
277
|
+
- **Logs**: `~/.acai/logs/acai.log`
|
|
278
|
+
- **Message History**: `~/.acai/message-history/`
|
|
279
|
+
|
|
280
|
+
### Environment-Specific Setup
|
|
281
|
+
|
|
282
|
+
For development, you can use different configurations:
|
|
283
|
+
|
|
284
|
+
```bash
|
|
285
|
+
# Development with .env file
|
|
286
|
+
npm run dev
|
|
287
|
+
|
|
288
|
+
# Production
|
|
289
|
+
acai
|
|
290
|
+
|
|
291
|
+
# Custom log level
|
|
292
|
+
LOG_LEVEL=warn acai
|
|
293
|
+
```
|
|
294
|
+
|
|
295
|
+
## ⚙️ Development
|
|
296
|
+
|
|
297
|
+
### Development Environment Setup
|
|
298
|
+
|
|
299
|
+
1. **Clone and install dependencies:**
|
|
300
|
+
```bash
|
|
301
|
+
git clone https://github.com/travisennis/acai-ts.git
|
|
302
|
+
cd acai-ts
|
|
303
|
+
npm install
|
|
304
|
+
```
|
|
305
|
+
|
|
306
|
+
2. **Set up environment variables:**
|
|
307
|
+
```bash
|
|
308
|
+
# Create .env file with your API keys
|
|
309
|
+
touch .env
|
|
310
|
+
# Add your API keys (see Environment Variables section above)
|
|
311
|
+
```
|
|
312
|
+
|
|
313
|
+
3. **Development workflow:**
|
|
314
|
+
```bash
|
|
315
|
+
# Run in development mode (uses .env file)
|
|
316
|
+
npm run dev
|
|
317
|
+
|
|
318
|
+
# Build and test
|
|
319
|
+
npm run build
|
|
320
|
+
npm test
|
|
321
|
+
|
|
322
|
+
# Code quality
|
|
323
|
+
npm run lint
|
|
324
|
+
npm run format
|
|
325
|
+
```
|
|
326
|
+
|
|
327
|
+
### Available NPM Scripts
|
|
328
|
+
|
|
329
|
+
Here's a list of useful `npm` scripts for development:
|
|
330
|
+
|
|
331
|
+
| Script | Description |
|
|
332
|
+
| :------------ | :----------------------------------------------------------------------- |
|
|
333
|
+
| `npm run build` | Compiles the TypeScript source code to JavaScript. |
|
|
334
|
+
| `npm run clean` | Removes the `dist/` directory. |
|
|
335
|
+
| `npm run compile` | Compiles TypeScript files (`tsc --pretty`). |
|
|
336
|
+
| `npm run lint` | Runs Biome linter to check for code style and quality issues. |
|
|
337
|
+
| `npm run lint:fix` | Automatically fixes linting issues using Biome. |
|
|
338
|
+
| `npm run test` | Runs unit tests with code coverage using `c8`. |
|
|
339
|
+
| `npm run format` | Formats the codebase using Biome. |
|
|
340
|
+
| `npm run dev` | Starts the application in development mode (loads .env file automatically). |
|
|
341
|
+
| `npm run oxlint` | Runs Oxlint for additional code quality checks. |
|
|
342
|
+
| `npm run knip` | Detects unused files, dependencies, and exports. |
|
|
343
|
+
| `npm run check` | Interactively checks for and updates outdated npm packages. |
|
|
344
|
+
| `npm run cpd` | Checks for copy-pasted code using `jscpd`. |
|
|
345
|
+
|
|
346
|
+
### Code Structure
|
|
347
|
+
|
|
348
|
+
The project is organized as follows:
|
|
349
|
+
|
|
350
|
+
```
|
|
351
|
+
.
|
|
352
|
+
├── .acai/ # Internal configuration, context, and temporary files
|
|
353
|
+
├── source/ # Main application source code
|
|
354
|
+
│ ├── cli.ts # CLI entry point
|
|
355
|
+
│ ├── code-utils/ # Code parsing and navigation utilities (Tree-sitter)
|
|
356
|
+
│ ├── commands/ # Implementations of REPL commands (e.g., /edit, /commit)
|
|
357
|
+
│ ├── middleware/ # AI request/response middleware (logging, rate limiting)
|
|
358
|
+
│ ├── models/ # AI model providers and management
|
|
359
|
+
│ ├── prompts/ # Prompt generation and management
|
|
360
|
+
│ ├── terminal/ # Terminal output formatting and rendering
|
|
361
|
+
│ ├── tools/ # AI-callable tools (filesystem, git, web, bash, etc.)
|
|
362
|
+
│ └── ... # Other core modules (config, logger, repl, token tracking)
|
|
363
|
+
├── test/ # Unit tests
|
|
364
|
+
├── ARCHITECTURE.md # Detailed architectural overview and flow diagrams
|
|
365
|
+
├── AGENTS.md # Project-specific AI rules and guidelines
|
|
366
|
+
├── TODO.md # Project roadmap and planned features
|
|
367
|
+
├── package.json # Project metadata, dependencies, and scripts
|
|
368
|
+
└── README.md # This file
|
|
369
|
+
```
|
|
370
|
+
|
|
371
|
+
For a more in-depth understanding of the project's architecture and internal flows, please refer to the [ARCHITECTURE.md](ARCHITECTURE.md) document.
|
|
372
|
+
|
|
373
|
+
## 📚 Documentation & Examples
|
|
374
|
+
|
|
375
|
+
* **[ARCHITECTURE.md](ARCHITECTURE.md):** Provides a comprehensive overview of the project's architecture, including file descriptions and Mermaid flow diagrams.
|
|
376
|
+
* **[AGENTS.md](AGENTS.md):** Contains specific rules and guidelines for the AI agent's behavior within this project.
|
|
377
|
+
* **In-app `/help` command:** Use `/help` within the Acai REPL for a list of available commands and their usage.
|
|
378
|
+
* **`source/commands/` directory:** Review the TypeScript files in this directory to understand how each REPL command is implemented.
|
|
379
|
+
* **`source/tools/` directory:** Explore the available tools that the AI can leverage.
|
|
380
|
+
|
|
381
|
+
## 🤝 Contributing
|
|
382
|
+
|
|
383
|
+
We welcome contributions! Please see our [CONTRIBUTING.md](CONTRIBUTING.md) (if it exists, otherwise remove this line) for guidelines on how to contribute.
|
|
384
|
+
|
|
385
|
+
## 📄 License
|
|
386
|
+
|
|
387
|
+
This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.
|
|
388
|
+
|
|
389
|
+
## 📞 Contact
|
|
390
|
+
|
|
391
|
+
For questions or feedback, please open an issue on the GitHub repository.
|
|
392
|
+
```
|
package/TODO.md
ADDED
package/biome.json
ADDED
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "https://biomejs.dev/schemas/2.1.4/schema.json",
|
|
3
|
+
"files": {
|
|
4
|
+
"includes": ["source/**/*.*", "test/**/*.*"],
|
|
5
|
+
"maxSize": 1048576
|
|
6
|
+
},
|
|
7
|
+
"assist": { "actions": { "source": { "organizeImports": "on" } } },
|
|
8
|
+
"linter": {
|
|
9
|
+
"enabled": true,
|
|
10
|
+
"rules": {
|
|
11
|
+
"complexity": { "useLiteralKeys": "off" },
|
|
12
|
+
"correctness": { "noNodejsModules": "off" },
|
|
13
|
+
"performance": {},
|
|
14
|
+
"security": {},
|
|
15
|
+
"suspicious": { "noConsole": "off" },
|
|
16
|
+
"style": {
|
|
17
|
+
"noParameterAssign": "error",
|
|
18
|
+
"useAsConstAssertion": "error",
|
|
19
|
+
"useDefaultParameterLast": "error",
|
|
20
|
+
"useEnumInitializers": "error",
|
|
21
|
+
"useSelfClosingElements": "error",
|
|
22
|
+
"useSingleVarDeclarator": "error",
|
|
23
|
+
"noUnusedTemplateLiteral": "error",
|
|
24
|
+
"useNumberNamespace": "error",
|
|
25
|
+
"noInferrableTypes": "error",
|
|
26
|
+
"noUselessElse": "error",
|
|
27
|
+
"useNamingConvention": "error"
|
|
28
|
+
},
|
|
29
|
+
"nursery": { "recommended": true }
|
|
30
|
+
}
|
|
31
|
+
},
|
|
32
|
+
"formatter": {
|
|
33
|
+
"enabled": true,
|
|
34
|
+
"formatWithErrors": false,
|
|
35
|
+
"indentStyle": "space",
|
|
36
|
+
"indentWidth": 2,
|
|
37
|
+
"lineEnding": "lf",
|
|
38
|
+
"lineWidth": 80,
|
|
39
|
+
"attributePosition": "auto"
|
|
40
|
+
},
|
|
41
|
+
"javascript": {
|
|
42
|
+
"formatter": {
|
|
43
|
+
"jsxQuoteStyle": "double",
|
|
44
|
+
"quoteProperties": "asNeeded",
|
|
45
|
+
"trailingCommas": "all",
|
|
46
|
+
"arrowParentheses": "always",
|
|
47
|
+
"bracketSpacing": true,
|
|
48
|
+
"bracketSameLine": false,
|
|
49
|
+
"quoteStyle": "double",
|
|
50
|
+
"attributePosition": "auto"
|
|
51
|
+
},
|
|
52
|
+
"parser": {
|
|
53
|
+
"unsafeParameterDecoratorsEnabled": true
|
|
54
|
+
}
|
|
55
|
+
},
|
|
56
|
+
"html": {
|
|
57
|
+
"formatter": {
|
|
58
|
+
"enabled": true
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
}
|
package/dist/cli.d.ts
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import type { MessageHistory } from "./messages.ts";
|
|
2
|
+
import type { ModelManager } from "./models/manager.js";
|
|
3
|
+
import type { PromptManager } from "./prompts/manager.ts";
|
|
4
|
+
import type { TokenTracker } from "./token-tracker.ts";
|
|
5
|
+
import type { TokenCounter } from "./token-utils.ts";
|
|
6
|
+
interface CliOptions {
|
|
7
|
+
messageHistory: MessageHistory;
|
|
8
|
+
promptManager: PromptManager;
|
|
9
|
+
modelManager: ModelManager;
|
|
10
|
+
tokenTracker: TokenTracker;
|
|
11
|
+
config: Record<PropertyKey, unknown>;
|
|
12
|
+
tokenCounter: TokenCounter;
|
|
13
|
+
}
|
|
14
|
+
export declare class Cli {
|
|
15
|
+
private options;
|
|
16
|
+
constructor(options: CliOptions);
|
|
17
|
+
run(): Promise<void>;
|
|
18
|
+
}
|
|
19
|
+
export {};
|
package/dist/cli.js
ADDED
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
import { generateObject, generateText, NoSuchToolError, stepCountIs, } from "ai";
|
|
2
|
+
import { logger } from "./logger.js";
|
|
3
|
+
import { AiConfig } from "./models/ai-config.js";
|
|
4
|
+
import { minSystemPrompt } from "./prompts.js";
|
|
5
|
+
import { DeleteFileTool } from "./tools/delete-file.js";
|
|
6
|
+
import { EditFileTool } from "./tools/edit-file.js";
|
|
7
|
+
import { initCliTools } from "./tools/index.js";
|
|
8
|
+
import { MoveFileTool } from "./tools/move-file.js";
|
|
9
|
+
import { SaveFileTool } from "./tools/save-file.js";
|
|
10
|
+
import { ThinkTool } from "./tools/think.js";
|
|
11
|
+
export class Cli {
|
|
12
|
+
options;
|
|
13
|
+
constructor(options) {
|
|
14
|
+
this.options = options;
|
|
15
|
+
}
|
|
16
|
+
async run() {
|
|
17
|
+
const { config, promptManager, modelManager, tokenTracker, messageHistory, tokenCounter, } = this.options;
|
|
18
|
+
logger.info(config, "Config:");
|
|
19
|
+
const abortController = new AbortController();
|
|
20
|
+
const { signal } = abortController;
|
|
21
|
+
const cb = () => {
|
|
22
|
+
abortController.abort();
|
|
23
|
+
};
|
|
24
|
+
// Handle Ctrl+C (SIGINT)
|
|
25
|
+
process.on("SIGINT", cb);
|
|
26
|
+
const langModel = modelManager.getModel("cli");
|
|
27
|
+
const modelConfig = modelManager.getModelMetadata("cli");
|
|
28
|
+
const userPrompt = promptManager.get();
|
|
29
|
+
const userMsg = promptManager.getUserMessage();
|
|
30
|
+
messageHistory.appendUserMessage(userMsg);
|
|
31
|
+
const finalSystemPrompt = await minSystemPrompt();
|
|
32
|
+
const aiConfig = new AiConfig({
|
|
33
|
+
modelMetadata: modelConfig,
|
|
34
|
+
prompt: userPrompt,
|
|
35
|
+
});
|
|
36
|
+
const maxTokens = aiConfig.getMaxTokens();
|
|
37
|
+
const tools = modelConfig.supportsToolCalling
|
|
38
|
+
? await initCliTools({ tokenCounter })
|
|
39
|
+
: undefined;
|
|
40
|
+
try {
|
|
41
|
+
const result = await generateText({
|
|
42
|
+
model: langModel,
|
|
43
|
+
maxOutputTokens: maxTokens,
|
|
44
|
+
messages: [
|
|
45
|
+
{
|
|
46
|
+
role: "system",
|
|
47
|
+
content: finalSystemPrompt,
|
|
48
|
+
providerOptions: {
|
|
49
|
+
anthropic: { cacheControl: { type: "ephemeral" } },
|
|
50
|
+
},
|
|
51
|
+
},
|
|
52
|
+
...messageHistory.get(),
|
|
53
|
+
],
|
|
54
|
+
temperature: modelConfig.defaultTemperature,
|
|
55
|
+
stopWhen: stepCountIs(60),
|
|
56
|
+
maxRetries: 2,
|
|
57
|
+
providerOptions: aiConfig.getProviderOptions(),
|
|
58
|
+
tools,
|
|
59
|
+
// biome-ignore lint/style/useNamingConvention: third-party controlled
|
|
60
|
+
experimental_activeTools: [
|
|
61
|
+
EditFileTool.name,
|
|
62
|
+
SaveFileTool.name,
|
|
63
|
+
MoveFileTool.name,
|
|
64
|
+
DeleteFileTool.name,
|
|
65
|
+
ThinkTool.name,
|
|
66
|
+
],
|
|
67
|
+
// biome-ignore lint/style/useNamingConvention: third-party controlled
|
|
68
|
+
experimental_repairToolCall: modelConfig.supportsToolCalling
|
|
69
|
+
? toolCallRepair(modelManager)
|
|
70
|
+
: undefined,
|
|
71
|
+
abortSignal: signal,
|
|
72
|
+
});
|
|
73
|
+
if (result.response.messages.length > 0) {
|
|
74
|
+
messageHistory.appendResponseMessages(result.response.messages);
|
|
75
|
+
}
|
|
76
|
+
// this tracks the usage of every step in the call to streamText. it's a cumulative usage.
|
|
77
|
+
tokenTracker.trackUsage("cli", result.usage);
|
|
78
|
+
process.stdout.end(result.text.endsWith("\n") ? result.text : `${result.text}\n`);
|
|
79
|
+
}
|
|
80
|
+
catch (e) {
|
|
81
|
+
if (e instanceof Error) {
|
|
82
|
+
logger.error(e);
|
|
83
|
+
}
|
|
84
|
+
else {
|
|
85
|
+
logger.error(JSON.stringify(e, null, 2));
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
const toolCallRepair = (modelManager) => {
|
|
91
|
+
const fn = async ({ toolCall, tools, inputSchema, error, }) => {
|
|
92
|
+
if (NoSuchToolError.isInstance(error)) {
|
|
93
|
+
return null; // do not attempt to fix invalid tool names
|
|
94
|
+
}
|
|
95
|
+
const tool = tools[toolCall.toolName];
|
|
96
|
+
try {
|
|
97
|
+
const { object: repairedArgs } = await generateObject({
|
|
98
|
+
model: modelManager.getModel("tool-repair"),
|
|
99
|
+
schema: tool.inputSchema,
|
|
100
|
+
prompt: [
|
|
101
|
+
`The model tried to call the tool "${toolCall.toolName}" with the following arguments:`,
|
|
102
|
+
JSON.stringify(toolCall.input),
|
|
103
|
+
"The tool accepts the following schema:",
|
|
104
|
+
JSON.stringify(inputSchema(toolCall)),
|
|
105
|
+
"Please fix the arguments.",
|
|
106
|
+
].join("\n"),
|
|
107
|
+
});
|
|
108
|
+
return { ...toolCall, args: JSON.stringify(repairedArgs) };
|
|
109
|
+
}
|
|
110
|
+
catch (err) {
|
|
111
|
+
logger.error(err, `Failed to repair tool call: ${toolCall.toolName}.`);
|
|
112
|
+
return null;
|
|
113
|
+
}
|
|
114
|
+
};
|
|
115
|
+
return fn;
|
|
116
|
+
};
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { readFile } from "node:fs/promises";
|
|
2
|
+
import { editor } from "@inquirer/prompts";
|
|
3
|
+
import { config } from "../config.js";
|
|
4
|
+
export const applicationLogCommand = ({ terminal, }) => {
|
|
5
|
+
return {
|
|
6
|
+
command: "/application-logs",
|
|
7
|
+
description: "Opens the application log file defined in acai.json in the editor.",
|
|
8
|
+
result: "continue",
|
|
9
|
+
getSubCommands: () => Promise.resolve([]),
|
|
10
|
+
execute: async () => {
|
|
11
|
+
let logFilePath;
|
|
12
|
+
try {
|
|
13
|
+
const projectConfig = await config.readProjectConfig();
|
|
14
|
+
logFilePath = projectConfig.logs?.path;
|
|
15
|
+
if (!logFilePath) {
|
|
16
|
+
terminal.error("Application log path is not defined in .acai/acai.json under the 'logs.path' key.");
|
|
17
|
+
return;
|
|
18
|
+
}
|
|
19
|
+
const content = await readFile(logFilePath, { encoding: "utf8" });
|
|
20
|
+
// Use the editor prompt to display the content (read-only)
|
|
21
|
+
await editor({
|
|
22
|
+
message: `Viewing ${logFilePath}`,
|
|
23
|
+
// Attempt to infer postfix from file extension, default otherwise
|
|
24
|
+
postfix: logFilePath.includes(".")
|
|
25
|
+
? `.${logFilePath.split(".").pop()}`
|
|
26
|
+
: ".log",
|
|
27
|
+
default: content,
|
|
28
|
+
// By not providing an onSubmit or similar handler to write the file,
|
|
29
|
+
// and not calling writeFileSync after, this effectively becomes read-only.
|
|
30
|
+
});
|
|
31
|
+
terminal.info(`Closed log view for: ${logFilePath}`);
|
|
32
|
+
}
|
|
33
|
+
catch (error) {
|
|
34
|
+
if (logFilePath && error.code === "ENOENT") {
|
|
35
|
+
terminal.error(`Application log file not found at: ${logFilePath}`);
|
|
36
|
+
}
|
|
37
|
+
else {
|
|
38
|
+
terminal.error(`Error reading or displaying log file ${logFilePath ?? "specified in config"}: ${error}`);
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
},
|
|
42
|
+
};
|
|
43
|
+
};
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
export const clearCommand = ({ terminal }) => {
|
|
2
|
+
return {
|
|
3
|
+
command: "/clear",
|
|
4
|
+
description: "Clears the terminal screen.",
|
|
5
|
+
result: "continue", // Keep the REPL running
|
|
6
|
+
getSubCommands: () => Promise.resolve([]),
|
|
7
|
+
execute: () => {
|
|
8
|
+
terminal.clear();
|
|
9
|
+
return Promise.resolve();
|
|
10
|
+
},
|
|
11
|
+
};
|
|
12
|
+
};
|