@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/.acai/acai.json
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
Your task it to add a new model to the ./source/model/openrouter-provider.ts.
|
|
2
|
+
|
|
3
|
+
I want you to accomplish this by writing a javascript script and executing it with the code-interpreter tool.
|
|
4
|
+
|
|
5
|
+
This script should do the following:
|
|
6
|
+
1. fetch `openrouter.ai/api/v1/models` using https
|
|
7
|
+
2. parse the json response. the shape should be `{"data":[]}`
|
|
8
|
+
3. filter the `data` array to find the object whose `id` is `{{INPUT}}`
|
|
9
|
+
4. log the model information found in the object
|
|
10
|
+
|
|
11
|
+
Take that model information and use it to add a new model to openrouter-provider.ts. Follow the pattern that exists to add a new model. If any information is missing ask the user to provide guidance.
|
|
12
|
+
|
|
13
|
+
Create a new git branch before making any edits.
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
Manage the ./ARCHITECTURE.md document for this project. If file doesn't exist create it. If it does exist make sure it is up-to-date and reflects the current state of the project.
|
|
2
|
+
|
|
3
|
+
The main header of the document should be Acai Architecture.
|
|
4
|
+
|
|
5
|
+
Include a Project Structure that is the current directory tree for the entire project.
|
|
6
|
+
|
|
7
|
+
Next, there should be section called File Descriptions that should include a list of every file in the project and a brief description of what each is and does.
|
|
8
|
+
|
|
9
|
+
Finally, a section called Flow Diagram should document with mermaid diagrams the primary flows in the application, starting with the entry points defined in the package.json.
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
- Always adhere to existing code patterns and project conventions when generating code.
|
|
2
|
+
- Always explicitly ask for user confirmation before committing changes.
|
|
3
|
+
- Always replace usages console.log with usages of console.info.
|
|
4
|
+
- Always run a build after making code changes to verify correctness.
|
|
5
|
+
- Always use the most efficient workflow to complete tasks.
|
|
6
|
+
- Always stage changes before attempting to commit them.
|
|
7
|
+
- Never amend git commits without approval from the user.
|
|
8
|
+
- Never use `git add -A` when preparing for multiple, distinct commits; instead, selectively add files or hunks relevant to each commit.
|
|
9
|
+
- Always use `git checkout -b <branch-name>` with a branch name that accurately reflects the *type* of changes being made.
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
# Cognitive Complexity Refactoring Task
|
|
2
|
+
|
|
3
|
+
**Goal**: Reduce cognitive complexity for functions slightly over the 15-point limit.
|
|
4
|
+
|
|
5
|
+
This file tracks the progress of refactoring functions that were identified by `npm run lint` as having a cognitive complexity score between 16 and 18 (inclusive).
|
|
6
|
+
|
|
7
|
+
## Identified Functions & Status:
|
|
8
|
+
|
|
9
|
+
1. **File**: `/Users/travisennis/Github/acai-ts/source/commands/prompt-command.ts:47:37`
|
|
10
|
+
* **Function**: `execute`
|
|
11
|
+
* **Initial Complexity**: 16
|
|
12
|
+
* **Status**: DONE
|
|
13
|
+
* **Commit**: `60f5bcb`
|
|
14
|
+
|
|
15
|
+
2. **File**: `/Users/travisennis/Github/acai-ts/source/prompts/manager.ts:29:3`
|
|
16
|
+
* **Function**: `getUserMessage`
|
|
17
|
+
* **Initial Complexity**: 16
|
|
18
|
+
* **Status**: DONE
|
|
19
|
+
* **Commit**: `ff0e76d`
|
|
20
|
+
|
|
21
|
+
3. **File**: `/Users/travisennis/Github/acai-ts/source/terminal/marked-renderer.ts:607:12`
|
|
22
|
+
* **Function**: `link`
|
|
23
|
+
* **Initial Complexity**: 16
|
|
24
|
+
* **Status**: DONE
|
|
25
|
+
* **Commit**: `a88600c`
|
|
26
|
+
|
|
27
|
+
4. **File**: `/Users/travisennis/Github/acai-ts/source/code-utils/code-navigator.ts:804:11`
|
|
28
|
+
* **Function**: `findNodeAtPosition`
|
|
29
|
+
* **Initial Complexity**: 17
|
|
30
|
+
* **Status**: DONE
|
|
31
|
+
* **Commit**: `da3d449`
|
|
32
|
+
|
|
33
|
+
5. **File**: `/Users/travisennis/Github/acai-ts/source/repl.ts:421:10`
|
|
34
|
+
* **Function**: `displayToolMessages`
|
|
35
|
+
* **Initial Complexity**: 17
|
|
36
|
+
* **Status**: DONE
|
|
37
|
+
* **Commit**: `ab8ad6a`
|
|
38
|
+
|
|
39
|
+
6. **File**: `/Users/travisennis/Github/acai-ts/source/commands/generate-rules-command.ts:18:23`
|
|
40
|
+
* **Function**: `execute`
|
|
41
|
+
* **Initial Complexity**: 18
|
|
42
|
+
* **Status**: DONE
|
|
43
|
+
* **Commit**: `ff19776`
|
|
44
|
+
|
|
45
|
+
7. **File**: `/Users/travisennis/Github/acai-ts/source/commands/selections-command.ts:19:37`
|
|
46
|
+
* **Function**: `execute`
|
|
47
|
+
* **Initial Complexity**: 18
|
|
48
|
+
* **Status**: DONE
|
|
49
|
+
* **Commit**: `5c35563`
|
|
50
|
+
|
|
51
|
+
8. **File**: `/Users/travisennis/Github/acai-ts/source/terminal/formatting.ts:113:17`
|
|
52
|
+
* **Function**: (anonymous map callback)
|
|
53
|
+
* **Initial Complexity**: 18
|
|
54
|
+
* **Status**: DONE
|
|
55
|
+
* **Commit**: `6bf0d91`
|
|
56
|
+
|
|
57
|
+
9. **File**: `/Users/travisennis/Github/acai-ts/source/tools/filesystem.ts:404:38`
|
|
58
|
+
* **Function**: (anonymous map callback)
|
|
59
|
+
* **Initial Complexity**: 16
|
|
60
|
+
* **Status**: DONE
|
|
61
|
+
* **Commit**: `0881b9d`
|
|
62
|
+
|
|
63
|
+
---
|
|
64
|
+
|
|
65
|
+
**Next Up**: All functions with cognitive complexity between 16 and 18 have been refactored.
|
|
@@ -0,0 +1,168 @@
|
|
|
1
|
+
|
|
2
|
+
# Deleted Tools in Commit 88ced9ef7224f73f2f49bdb4679e21f56f5374d3
|
|
3
|
+
|
|
4
|
+
This document lists the tools that were removed or commented out in commit `88ced9ef7224f73f2f49bdb4679e21f56f5374d3`.
|
|
5
|
+
|
|
6
|
+
## 1. `launchAgent`
|
|
7
|
+
|
|
8
|
+
* **Description:** Launch a new agent that has access to the following tools: grepFiles, basheTool, readFile, directoryTree. When you are searching for a keyword or file and are not confident that you will find the right match on the first try, use the Agent tool to perform the search for you. For example:
|
|
9
|
+
* If you are searching for a keyword like "config" or "logger", the Agent tool is appropriate
|
|
10
|
+
* If you want to read a specific file path, use the readFile or searchFiles tool instead of the Agent tool, to find the match more quickly
|
|
11
|
+
* If you are searching for a specific class definition like "class Foo", use the grepFiles tool instead, to find the match more quickly
|
|
12
|
+
Usage notes:
|
|
13
|
+
1. Launch multiple agents concurrently whenever possible, to maximize performance; to do that, use a single message with multiple tool uses
|
|
14
|
+
2. When the agent is done, it will return a single message back to you. The result returned by the agent is not visible to the user. To show the user the result, you should send a text message back to the user with a concise summary of the result.
|
|
15
|
+
3. Each agent invocation is stateless. You will not be able to send additional messages to the agent, nor will the agent be able to communicate with you outside of its final report. Therefore, your prompt should contain a highly detailed task description for the agent to perform autonomously and you should specify exactly what information the agent should return back to you in its final and only message to you.
|
|
16
|
+
4. The agent's outputs should generally be trusted.
|
|
17
|
+
* **Parameters:**
|
|
18
|
+
* `prompt`: (string) The task for the agent to perform.
|
|
19
|
+
|
|
20
|
+
## 2. `architect`
|
|
21
|
+
|
|
22
|
+
* **Description:** Your go-to tool for any technical or coding task. Analyzes requirements and breaks them down into clear, actionable implementation steps. Use this whenever you need help planning how to implement a feature, solve a technical problem, or structure your code.
|
|
23
|
+
* **Parameters:**
|
|
24
|
+
* `prompt`: (string) The technical request or coding task to analyze. Be detailed and include any files that have been referenced in the request.
|
|
25
|
+
* `context`: (string | null) Optional context from previous conversation or system state.
|
|
26
|
+
|
|
27
|
+
## 3. `codeEditor`
|
|
28
|
+
|
|
29
|
+
* **Description:** Your go-to tool for code editing tasks. This tool is especially good for when you have lots of small, simple edits that need to be made in a file.
|
|
30
|
+
* **Parameters:**
|
|
31
|
+
* `path`: (string) The path of the file to edit.
|
|
32
|
+
* `edits`: (array of objects)
|
|
33
|
+
* `oldText`: (string) Text to search for - must match exactly and enough context must be provided to uniquely match the target text.
|
|
34
|
+
* `newText`: (string) Text to replace with.
|
|
35
|
+
|
|
36
|
+
## 4. `installDependencies`
|
|
37
|
+
|
|
38
|
+
* **Description:** Installs dependencies in the project. Accepts an array of package names (e.g., ['lodash', '@types/node']) with optional version specifiers (e.g., 'lodash@4.17.21', 'react@latest'). Defaults to 'npm install' but can be configured via project config. Use the dev parameter to install as development dependencies.
|
|
39
|
+
* **Parameters:**
|
|
40
|
+
* `dependencies`: (array of strings) Array of package names to install (e.g., ['express', 'lodash@4.17.21']).
|
|
41
|
+
* `dev`: (boolean, optional) Whether to install as dev dependencies (--save-dev).
|
|
42
|
+
|
|
43
|
+
## 5. `buildCode`
|
|
44
|
+
|
|
45
|
+
* **Description:** Executes the build command for the current code base and returns the output.
|
|
46
|
+
* **Parameters:** {} (None)
|
|
47
|
+
|
|
48
|
+
## 6. `lintCode`
|
|
49
|
+
|
|
50
|
+
* **Description:** Lints the current code base and returns the results. This tool helps identify and report potential issues, style violations, or errors in the code, improving code quality and consistency. If a path is provided it will lint the file at that path.
|
|
51
|
+
* **Parameters:**
|
|
52
|
+
* `path`: (string, optional) The path of the file to lint.
|
|
53
|
+
|
|
54
|
+
## 7. `formatCode`
|
|
55
|
+
|
|
56
|
+
* **Description:** Executes the 'format' command on the current code base and returns the results. This reports style and formatting issues with the code base.
|
|
57
|
+
* **Parameters:** {} (None)
|
|
58
|
+
|
|
59
|
+
## 8. `testCode`
|
|
60
|
+
|
|
61
|
+
* **Description:** Executes the 'test' command on the current code base to run unit tests and return the results.
|
|
62
|
+
* **Parameters:** {} (None)
|
|
63
|
+
|
|
64
|
+
## 9. `currentDirectory`
|
|
65
|
+
|
|
66
|
+
* **Description:** Get the current working directory. Use this to understand which directory is available before trying to access files.
|
|
67
|
+
* **Parameters:** {} (None)
|
|
68
|
+
|
|
69
|
+
## 10. `createDirectory`
|
|
70
|
+
|
|
71
|
+
* **Description:** Create a new directory or ensure a directory exists. Can create multiple nested directories in one operation. If the directory already exists, this operation will succeed silently. Perfect for setting up directory structures for projects or ensuring required paths exist. Only works within allowed directories.
|
|
72
|
+
* **Parameters:**
|
|
73
|
+
* `path`: (string) Absolute path to directory to create.
|
|
74
|
+
|
|
75
|
+
## 11. `searchFiles`
|
|
76
|
+
|
|
77
|
+
* **Description:** Recursively search for files and directories matching a pattern. Searches through all subdirectories from the starting path. The search is case-insensitive and matches partial names. Returns full paths to all matching items. Great for finding files when you don't know their exact location. Only searches within allowed directories. Use this tool when you need to find files by name patterns.
|
|
78
|
+
* **Parameters:**
|
|
79
|
+
* `path`: (string) The base path to search in.
|
|
80
|
+
* `pattern`: (string) Supports glob patterns like "**/*.js" or "src/**/*.ts".
|
|
81
|
+
* `excludePatterns`: (array of strings, optional, default: []) Patterns to exclude from the search.
|
|
82
|
+
|
|
83
|
+
## 12. `getFileInfo`
|
|
84
|
+
|
|
85
|
+
* **Description:** Retrieve detailed metadata about a file or directory. Returns comprehensive information including size, creation time, last modified time, permissions, and type. This tool is perfect for understanding file characteristics without reading the actual content. Only works within allowed directories.
|
|
86
|
+
* **Parameters:**
|
|
87
|
+
* `path`: (string) The path to the file or directory.
|
|
88
|
+
|
|
89
|
+
## 13. `listDirectory`
|
|
90
|
+
|
|
91
|
+
* **Description:** Get a detailed listing of all files and directories in a specified path. Results clearly distinguish between files and directories with [FILE] and [DIR] prefixes. This tool is essential for understanding directory structure and finding specific files within a directory. Only works within allowed directories. Use this tool when you need to see the contents of a directory.
|
|
92
|
+
* **Parameters:**
|
|
93
|
+
* `path`: (string) The path.
|
|
94
|
+
|
|
95
|
+
## 14. `gitNewBranch`
|
|
96
|
+
|
|
97
|
+
* **Description:** A tool to create a new git branch and switch to it. (Git command: `git checkout -b`)
|
|
98
|
+
* **Parameters:**
|
|
99
|
+
* `path`: (string) The absolute path to the git repo.
|
|
100
|
+
* `name`: (string) The name of the git branch.
|
|
101
|
+
|
|
102
|
+
## 15. `gitStatus`
|
|
103
|
+
|
|
104
|
+
* **Description:** Get the status of the git repo at the given path. (Git command: `git status`)
|
|
105
|
+
* **Parameters:**
|
|
106
|
+
* `path`: (string) The absolute path to the git repo.
|
|
107
|
+
|
|
108
|
+
## 16. `gitLog`
|
|
109
|
+
|
|
110
|
+
* **Description:** Gets the log of the git repo at the given path. Unless told otherwise, will return the 3 most recent commits. (Git command: `git log --max-count=n`)
|
|
111
|
+
* **Parameters:**
|
|
112
|
+
* `path`: (string) The absolute path to the git repo.
|
|
113
|
+
* `n`: (number | null) The number of commits to return in the log. This value is passed --max-count. Passing null will use the default value of 3.
|
|
114
|
+
|
|
115
|
+
## 17. `gitShow`
|
|
116
|
+
|
|
117
|
+
* **Description:** Shows the contents of a commit. (Git command: `git show`)
|
|
118
|
+
* **Parameters:**
|
|
119
|
+
* `path`: (string) The absolute path to the git repo.
|
|
120
|
+
* `revision`: (string) The commit hash or reference to show.
|
|
121
|
+
|
|
122
|
+
## 18. `gitDiff`
|
|
123
|
+
|
|
124
|
+
* **Description:** Shows differences between branches or commits. (Git command: `git diff`)
|
|
125
|
+
* **Parameters:**
|
|
126
|
+
* `path`: (string) The absolute path to the git repo.
|
|
127
|
+
* `target`: (string) The branch or commit to diff against.
|
|
128
|
+
|
|
129
|
+
## 19. `gitDiffUnstaged`
|
|
130
|
+
|
|
131
|
+
* **Description:** Shows changes in the working directory that are not yet staged. (Git command: `git diff`)
|
|
132
|
+
* **Parameters:**
|
|
133
|
+
* `path`: (string) The absolute path to the git repo.
|
|
134
|
+
|
|
135
|
+
## 20. `gitDiffStaged`
|
|
136
|
+
|
|
137
|
+
* **Description:** Shows changes that are staged for commit. (Git command: `git diff --cached`)
|
|
138
|
+
* **Parameters:**
|
|
139
|
+
* `path`: (string) The absolute path to the git repo.
|
|
140
|
+
|
|
141
|
+
## 21. `searchLogs`
|
|
142
|
+
|
|
143
|
+
* **Description:** Search the application log file for patterns. Prioritizes recent entries.
|
|
144
|
+
* **Parameters:**
|
|
145
|
+
* `pattern`: (string) The regex pattern to search for.
|
|
146
|
+
* `maxResults`: (number | null) Maximum number of matching lines to return (from the end of the file). Pass null to use the default (100).
|
|
147
|
+
* `ignoreCase`: (boolean | null) Whether to ignore case. Pass null to use the default (false).
|
|
148
|
+
* `contextLines`: (number | null) Number of lines of context to show around each match. Pass null for no context.
|
|
149
|
+
|
|
150
|
+
## 22. `getSignature`
|
|
151
|
+
|
|
152
|
+
* **Description:** Use the LSP to find the definition of a symbol in a file. Useful when you are unsure about the implementation of a class, method, or function but need the information to make progress.
|
|
153
|
+
* **Parameters:**
|
|
154
|
+
* `path`: (string) The absolute file path.
|
|
155
|
+
* `line`: (number) The line number that the symbol occurs on.
|
|
156
|
+
* `symbol`: (string) The name of the symbol to search for. This is usually a method, class, variable, or attribute.
|
|
157
|
+
|
|
158
|
+
## 23. `str_replace_editor` (Anthropic specific tool)
|
|
159
|
+
|
|
160
|
+
* **Description:** (Implicitly, a tool for text editing operations like view, create, replace, insert, undo)
|
|
161
|
+
* **Parameters:**
|
|
162
|
+
* `command`: (string) The operation to perform ("view", "create", "str_replace", "insert", "undo_edit").
|
|
163
|
+
* `path`: (string) The path to the file.
|
|
164
|
+
* `file_text`: (string, optional) Content for the 'create' command.
|
|
165
|
+
* `insert_line`: (number, optional) Line number for the 'insert' command (0 for beginning).
|
|
166
|
+
* `new_str`: (string, optional) Text for 'str_replace' or 'insert'.
|
|
167
|
+
* `old_str`: (string, optional) Text for 'str_replace'.
|
|
168
|
+
* `view_range`: (array of numbers, optional) Start and end line (1-indexed, -1 for end) for 'view'.
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
# Deleted Tools in Commit 88ced9ef7224f73f2f49bdb4679e21f56f5374d3
|
|
2
|
+
|
|
3
|
+
Here is a list of tools that were deleted or commented out in commit `88ced9ef7224f73f2f49bdb4679e21f56f5374d3`.
|
|
4
|
+
|
|
5
|
+
## 1. `launchAgent`
|
|
6
|
+
|
|
7
|
+
* **Description:** Launch a new agent that has access to the following tools: `grepFiles`, `bashTool`, `readFile`, `readMultipleFiles`, `directoryTree`. When you are searching for a keyword or file and are not confident that you will find the right match on the first try, use the Agent tool to perform the search for you. For example:
|
|
8
|
+
* If you are searching for a keyword like "config" or "logger", the Agent tool is appropriate
|
|
9
|
+
* If you want to read a specific file path, use the `readFile` or `searchFiles` tool instead of the Agent tool, to find the match more quickly
|
|
10
|
+
* If you are searching for a specific class definition like "class Foo", use the `grepFiles` tool instead, to find the match more quickly
|
|
11
|
+
Usage notes:
|
|
12
|
+
1. Launch multiple agents concurrently whenever possible, to maximize performance; to do that, use a single message with multiple tool uses
|
|
13
|
+
2. When the agent is done, it will return a single message back to you. The result returned by the agent is not visible to the user. To show the user the result, you should send a text message back to the user with a concise summary of the result.
|
|
14
|
+
3. Each agent invocation is stateless. You will not be able to send additional messages to the agent, nor will the agent be able to communicate with you outside of its final report. Therefore, your prompt should contain a highly detailed task description for the agent to perform autonomously and you should specify exactly what information the agent should return back to you in its final and only message to you.
|
|
15
|
+
4. The agent's outputs should generally be trusted.
|
|
16
|
+
* **Parameters:**
|
|
17
|
+
* `prompt`: (string) The task for the agent to perform
|
|
18
|
+
|
|
19
|
+
## 2. `architect`
|
|
20
|
+
|
|
21
|
+
* **Description:** Your go-to tool for any technical or coding task. Analyzes requirements and breaks them down into clear, actionable implementation steps. Use this whenever you need help planning how to implement a feature, solve a technical problem, or structure your code.
|
|
22
|
+
* **Parameters:**
|
|
23
|
+
* `prompt`: (string) The technical request or coding task to analyze. Be detailed and include any files that have been referenced in the request.
|
|
24
|
+
* `context`: (string | null) Optional context from previous conversation or system state.
|
|
25
|
+
|
|
26
|
+
## 3. `codeEditor`
|
|
27
|
+
|
|
28
|
+
* **Description:** Your go-to tool for code editing tasks. This tool is especially good for when you have lots of small, simple edits that need to be made in a file.
|
|
29
|
+
* **Parameters:**
|
|
30
|
+
* `path`: (string) The path of the file to edit.
|
|
31
|
+
* `edits`: (array of objects)
|
|
32
|
+
* `oldText`: (string) Text to search for - must match exactly and enough context must be provided to uniquely match the target text
|
|
33
|
+
* `newText`: (string) Text to replace with
|
|
34
|
+
|
|
35
|
+
## 4. `searchLogs`
|
|
36
|
+
|
|
37
|
+
* **Description:** Search the application log file for patterns. Prioritizes recent entries.
|
|
38
|
+
* **Parameters:**
|
|
39
|
+
* `pattern`: (string) The regex pattern to search for
|
|
40
|
+
* `maxResults`: (number | null) Maximum number of matching lines to return (from the end of the file). Pass null to use the default (100).
|
|
41
|
+
* `ignoreCase`: (boolean | null) Whether to ignore case. Pass null to use the default (false).
|
|
42
|
+
* `contextLines`: (number | null) Number of lines of context to show around each match. Pass null for no context.
|
|
43
|
+
|
|
44
|
+
## 5. `str_replace_editor` (Anthropic Text Editor Tool)
|
|
45
|
+
|
|
46
|
+
*Versions: `20250124`, `20241022`*
|
|
47
|
+
|
|
48
|
+
* **Description:** An Anthropic-provided tool for performing text editing operations on files, including viewing content, creating files, replacing strings, inserting text, and undoing the last edit. It operates based on commands.
|
|
49
|
+
* **Parameters:**
|
|
50
|
+
* `command`: (string) The operation to perform. Can be "view", "create", "str_replace", "insert", or "undo_edit".
|
|
51
|
+
* `path`: (string) The path to the file to operate on.
|
|
52
|
+
* `file_text`: (string | null) The content to write when using the "create" command.
|
|
53
|
+
* `insert_line`: (number | null) The line number after which to insert text when using the "insert" command (0 for the beginning).
|
|
54
|
+
* `new_str`: (string | null) The new text to insert (for "insert") or replace with (for "str_replace").
|
|
55
|
+
* `old_str`: (string | null) The exact text to replace when using the "str_replace" command.
|
|
56
|
+
* `view_range`: (array of numbers | null) A [start, end] array specifying the 1-indexed line range to view (for "view" command). -1 for end means read to the end.
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
Create an /image command at source/commands/image-command.ts. It should be somewhat similar to source/commands/paste-command.ts except it handles images.
|
|
2
|
+
|
|
3
|
+
You will need to update source/prompts/manager.ts to handle image data.
|
|
4
|
+
|
|
5
|
+
The function `createUserMessage` in source/messages.ts will need to be extended to handle image data.
|
|
6
|
+
|
|
7
|
+
for the image command use this code as guidance
|
|
8
|
+
|
|
9
|
+
``` javascript
|
|
10
|
+
// Requires installation of @napi-rs/clipboard and @napi-rs/image
|
|
11
|
+
import { Clipboard } from '@napi-rs/clipboard';
|
|
12
|
+
import { Transformer } from '@napi-rs/image';
|
|
13
|
+
import { writeFileSync } from 'fs';
|
|
14
|
+
import { join } from 'path';
|
|
15
|
+
|
|
16
|
+
async function handlePastedImage() {
|
|
17
|
+
const clipboard = new Clipboard();
|
|
18
|
+
// Get image data from clipboard
|
|
19
|
+
const image = await clipboard.getImage();
|
|
20
|
+
|
|
21
|
+
if (image) {
|
|
22
|
+
const { width, height, rawPixels } = image;
|
|
23
|
+
const transformer = new Transformer(rawPixels);
|
|
24
|
+
const pngBuffer = await transformer.png();
|
|
25
|
+
const filename = `pasted-image-${Date.now()}.png`;
|
|
26
|
+
writeFileSync(join(process.cwd(), filename), pngBuffer);
|
|
27
|
+
console.log(`Image saved to ${filename}`);
|
|
28
|
+
} else {
|
|
29
|
+
console.log('No image found in clipboard.');
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
for the update to `createUserMessage` keep this code in mind
|
|
35
|
+
|
|
36
|
+
``` javascript
|
|
37
|
+
{
|
|
38
|
+
role: 'user',
|
|
39
|
+
content: [
|
|
40
|
+
{
|
|
41
|
+
type: 'image',
|
|
42
|
+
image: 'data:image/png;base64,...',
|
|
43
|
+
},
|
|
44
|
+
]
|
|
45
|
+
}
|
|
46
|
+
```
|
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
Code (suggested new method to add to ConfigManager — async, non-blocking bootstrap that creates dirs/files safely):
|
|
2
|
+
|
|
3
|
+
async initialize(): Promise<void> {
|
|
4
|
+
// ensure base dirs
|
|
5
|
+
await fs.mkdir(this.app.getPath(), { recursive: true });
|
|
6
|
+
await fs.mkdir(this.project.getPath(), { recursive: true });
|
|
7
|
+
|
|
8
|
+
// ensure common subdirs
|
|
9
|
+
await fs.mkdir(path.join(this.app.getPath(), "rules"), { recursive: true });
|
|
10
|
+
await fs.mkdir(path.join(this.project.getPath(), "rules"), { recursive: true });
|
|
11
|
+
await fs.mkdir(path.join(this.app.getPath(), "logs"), { recursive: true });
|
|
12
|
+
|
|
13
|
+
// ensure default app config (acai.json) exists (use safe write)
|
|
14
|
+
const appConfigName = "acai";
|
|
15
|
+
const appConfigPath = path.join(this.app.getPath(), `${appConfigName}.json`);
|
|
16
|
+
try {
|
|
17
|
+
await fs.access(appConfigPath);
|
|
18
|
+
} catch {
|
|
19
|
+
const defaultAppConfig = {
|
|
20
|
+
logs: { path: path.join(this.app.getPath(), "logs", "current.log") },
|
|
21
|
+
tools: { maxTokens: 30000 },
|
|
22
|
+
notify: true,
|
|
23
|
+
};
|
|
24
|
+
await fs.writeFile(appConfigPath, JSON.stringify(defaultAppConfig, null, 2), { mode: 0o600, flag: "wx" });
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
// ensure project acai.json exists (in .acai)
|
|
28
|
+
const projectConfigPath = path.join(this.project.getPath(), "acai.json");
|
|
29
|
+
try {
|
|
30
|
+
await fs.access(projectConfigPath);
|
|
31
|
+
} catch {
|
|
32
|
+
const defaultProjectConfig = ProjectConfigSchema.parse({});
|
|
33
|
+
await fs.writeFile(projectConfigPath, JSON.stringify(defaultProjectConfig, null, 2), { mode: 0o600, flag: "wx" });
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
// AGENTS.md in repo root
|
|
37
|
+
const agentsPath = path.join(process.cwd(), "AGENTS.md");
|
|
38
|
+
try {
|
|
39
|
+
await fs.access(agentsPath);
|
|
40
|
+
} catch {
|
|
41
|
+
await fs.writeFile(agentsPath, "# Agents\n\n", { flag: "wx" });
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
// learned-rules files
|
|
45
|
+
const appLearned = path.join(this.app.getPath(), "rules", "learned-rules.md");
|
|
46
|
+
const projectLearned = path.join(this.project.getPath(), "rules", "learned-rules.md");
|
|
47
|
+
for (const p of [appLearned, projectLearned]) {
|
|
48
|
+
try {
|
|
49
|
+
await fs.access(p);
|
|
50
|
+
} catch {
|
|
51
|
+
await fs.writeFile(p, "", { flag: "wx", mode: 0o600 });
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
Short analysis of current source/config.ts (what it does today)
|
|
57
|
+
- Sets two DirectoryProvider instances:
|
|
58
|
+
- project -> ./ .acai (process.cwd())
|
|
59
|
+
- app -> ~/.acai (homedir)
|
|
60
|
+
- DirectoryProvider.getPath and ensurePath(sync) exist; ensurePath uses mkdirSync(..., { recursive: true }).
|
|
61
|
+
- Methods that write files often call ensurePath (project rules, cached rules, writeAppConfig). ensureAppConfig will create ~/.acai and write a default acai.json if missing.
|
|
62
|
+
- Many read methods gracefully return empty {} or "" on ENOENT (missing files) so the app won't crash on fresh install.
|
|
63
|
+
- However, most reads do NOT proactively create directories/files. Directories are only created when code path writes something or ensureAppConfig is called.
|
|
64
|
+
|
|
65
|
+
What this means for a fresh machine / fresh checkout
|
|
66
|
+
- App will not fully "self-bootstrap" just by importing config.ts. Only certain code paths will create directories:
|
|
67
|
+
- Calling ensureAppConfig will create ~/.acai and write the default acai.json.
|
|
68
|
+
- Writing rules/logs via write* methods will create required dirs because those methods call ensurePath.
|
|
69
|
+
- If the app expects defaults to exist up-front (logs dir, AGENTS.md, .acai/acai.json in project), those will be missing until specific operations run.
|
|
70
|
+
- readProjectConfig and readAppConfig will return defaults or empty values but do not create files, so user/config won't see actual files created on disk automatically.
|
|
71
|
+
|
|
72
|
+
Failure modes and issues to address
|
|
73
|
+
- Blocking mkdirSync in DirectoryProvider.ensurePath: works but blocks the event loop; consider async fs.mkdir for non-blocking startup.
|
|
74
|
+
- Parsing: _readConfig uses jsonParser(...).parse(data) — this will throw on invalid JSON/schema and bubble up. readAppConfig uses JSON.parse directly (no schema validation).
|
|
75
|
+
- Consider using z.safeParse or provide clearer error handling for corrupted config files.
|
|
76
|
+
- ensureAppConfig writes config but does not ensure the logs subdirectory exists. Default logs path points into ~/.acai/logs/current.log but logs/ may not exist until created.
|
|
77
|
+
- writeAgentsFile has a catch that returns silently on ENOENT — but writeFile normally creates files; that catch path seems unnecessary and hides errors.
|
|
78
|
+
- No atomic writes: writeFile is used directly; using atomic write (temp + rename) reduces risk of partial/corrupted config if interrupted.
|
|
79
|
+
- Permissions: no explicit file/directory permissions set. Sensitive data should be restricted (e.g., 0o700 for .acai, 0o600 for files).
|
|
80
|
+
- Race conditions: multiple concurrent initializers could race to create files. mkdir recursive is ok, but writes with flag "wx" and atomic write would be safer where appropriate.
|
|
81
|
+
- No explicit initialization step or CLI command to "acai init" — users rely on implicit writes.
|
|
82
|
+
|
|
83
|
+
Recommended improvements (priority)
|
|
84
|
+
1. Add an async initialize() method (see code above) that:
|
|
85
|
+
- Creates ~/.acai and ./.acai and their rules/logs subdirs.
|
|
86
|
+
- Ensures default app acai.json and project acai.json exist.
|
|
87
|
+
- Creates AGENTS.md and learned-rules.md files if missing.
|
|
88
|
+
- Sets conservative file/directory permissions (0o700 for dirs, 0o600 for files).
|
|
89
|
+
- Uses fs.mkdir + fs.access + write with flags to avoid clobbering existing files (or use atomic writes).
|
|
90
|
+
2. Replace DirectoryProvider.ensurePath to async version using fs.mkdir (or add ensurePathAsync) to avoid blocking the event loop.
|
|
91
|
+
3. Use schema safe parsing for config reads:
|
|
92
|
+
- Use ProjectConfigSchema.safeParse on parsed JSON and return helpful errors or repair strategies (backups / move to corrupted file) instead of throwing raw Zod errors.
|
|
93
|
+
- Use jsonParser for readAppConfig or wrap JSON.parse with try/catch and return {} or surface a clear error.
|
|
94
|
+
4. Ensure logs/ directory is created whenever default log path configured, and ensure writeAppConfig preserves existence of referenced subdirs.
|
|
95
|
+
5. Add atomic write helper (write to tmp then fs.rename) or use a small dependency if acceptable — but per policy don't add dependencies without approval.
|
|
96
|
+
6. Add tests:
|
|
97
|
+
- unit test initialize() creates the expected directories/files with correct permissions.
|
|
98
|
+
- tests for reading malformed config files and recovery behavior.
|
|
99
|
+
7. Add a CLI "init" command or run config.initialize() once on first run and surface a single-line informational message (respecting no console.log rule; use proper logger). Ask user before printing anything to stdout by default.
|
|
100
|
+
|
|
101
|
+
Security / hardening suggestions
|
|
102
|
+
- Default .acai directory should be mode 0o700.
|
|
103
|
+
- Config files containing secrets (if any later) should be 0o600.
|
|
104
|
+
- Avoid parsing arbitrary JSON strings without schema validation; provide clear error messages if config corrupted.
|
|
105
|
+
- When writing default files use "wx" flag to avoid overwriting existing files accidentally.
|
|
106
|
+
|
|
107
|
+
Concrete next steps I can take (need your approval)
|
|
108
|
+
- Implement initialize() + an async ensurePath and update code paths to use it (non-breaking).
|
|
109
|
+
- Add safeParse behavior in _readConfig and readAppConfig.
|
|
110
|
+
- Add unit tests in test/ to verify initialization.
|
|
111
|
+
- Run npm run build, npm run lint, npm test locally and provide the diff for review. (I will ask before committing or creating branch.)
|
|
112
|
+
|
|
113
|
+
Do you want me to implement the initialize() method + accompanying changes and tests now? If so, confirm and I will:
|
|
114
|
+
- create a branch (git checkout -b feat/init-config),
|
|
115
|
+
- implement changes,
|
|
116
|
+
- run build/lint/tests,
|
|
117
|
+
- show a git diff and test results for your approval before any commit.
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
## Implementation Plan for Issue #4: Support Asynchronous Creation of Subcommands
|
|
2
|
+
|
|
3
|
+
**Goal:** Modify the command system to allow `getSubCommands` to be an asynchronous operation, enabling scenarios where subcommand lists are generated dynamically (e.g., based on filesystem reads, API calls, etc.).
|
|
4
|
+
|
|
5
|
+
**Plan:**
|
|
6
|
+
|
|
7
|
+
1. **Update `ReplCommand` Interface (`source/commands/types.ts`):**
|
|
8
|
+
* Modify the `getSubCommands` property signature from `() => string[]` to `() => Promise<string[]>`.
|
|
9
|
+
|
|
10
|
+
2. **Update `CommandManager` (`source/commands/manager.ts`):**
|
|
11
|
+
* Change the `getSubCommands` method signature to `async getSubCommands(command: string): Promise<string[]>`.
|
|
12
|
+
* Modify the implementation to `await` the result of the individual command's `getSubCommands()` method.
|
|
13
|
+
* Include basic error handling for the awaited promise (e.g., log an error and return an empty array if the promise rejects).
|
|
14
|
+
|
|
15
|
+
3. **Adapt Existing Command Implementations (`source/commands/*.ts`):**
|
|
16
|
+
* Iterate through each command definition file (e.g., `help-command.ts`, `edit-command.ts`, etc.).
|
|
17
|
+
* Locate the `getSubCommands` function within each command's definition.
|
|
18
|
+
* Modify each synchronous `getSubCommands` function to return a resolved promise.
|
|
19
|
+
* Example: Change `getSubCommands: () => ['list', 'add']` to `getSubCommands: () => Promise.resolve(['list', 'add'])`.
|
|
20
|
+
* Example: Change `getSubCommands: () => []` to `getSubCommands: () => Promise.resolve([])` or `async () => []`.
|
|
21
|
+
* This ensures all existing commands conform to the new asynchronous interface without changing their current behavior.
|
|
22
|
+
|
|
23
|
+
4. **Identify and Update Callers of `getSubCommands`:**
|
|
24
|
+
* Search the codebase (using `grepFiles`) for any instances where `getSubCommands()` is called (both on `CommandManager` instances and `ReplCommand` instances).
|
|
25
|
+
* Likely candidates include help generation logic (potentially within `help-command.ts`) or any potential future tab-completion features.
|
|
26
|
+
* Modify these call sites to use `await` to handle the returned `Promise<string[]>`. Add appropriate error handling (try/catch) around the `await` calls.
|
|
27
|
+
|
|
28
|
+
5. **Testing:**
|
|
29
|
+
* **Unit Tests:**
|
|
30
|
+
* Update existing unit tests for `CommandManager.getSubCommands` to reflect the asynchronous nature.
|
|
31
|
+
* Ensure tests for individual commands correctly mock or test the promise-based `getSubCommands`.
|
|
32
|
+
* Add a test case for a command where `getSubCommands` simulates an asynchronous operation (e.g., using `new Promise(resolve => setTimeout(() => resolve(['sub1']), 10))`).
|
|
33
|
+
* Add test cases for error handling when a command's `getSubCommands` promise rejects.
|
|
34
|
+
* **Manual Tests:**
|
|
35
|
+
* Run the application and test commands that have subcommands (e.g., potentially the `help` command if it lists subcommands). Verify they still work as expected.
|
|
36
|
+
|
|
37
|
+
6. **Code Quality Checks:**
|
|
38
|
+
* Run `npm run lint:fix` to ensure code style consistency.
|
|
39
|
+
* Run `npm run build` to check for TypeScript errors.
|
|
40
|
+
* Run `npm test` to execute the test suite.
|
|
41
|
+
|
|
42
|
+
**Implementation Steps:**
|
|
43
|
+
|
|
44
|
+
Proceed with these steps sequentially, starting with modifying the interface and the manager. Propose code changes for approval before applying them.
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
A renderer that renders markdown for display in the terminal is found in ./source/terminal/marked-renderer.ts. It currently has some issues that need to be fixed.
|
|
2
|
+
|
|
3
|
+
In order to see the issues I have developed a script that reads the markdown stored in ./acai/docs/system_prompt.txt and outputs to console.
|
|
4
|
+
|
|
5
|
+
To run this script issue the following command:
|
|
6
|
+
```bash
|
|
7
|
+
node --no-warnings ./source/terminal/script.ts
|
|
8
|
+
```
|
|
9
|
+
Hopefully by using this script you can see the issues and make the appropriate fixes to make this api work as expected.
|
|
10
|
+
|
|
11
|
+
Here is a list of known issues:
|
|
12
|
+
* In the header `Use the think tool` there are no spaces around `think`
|
|
13
|
+
* The `User:` and `acai:` usages in the `Examples of Good Responses` section do not have any spaces after them
|
|
14
|
+
|
|
15
|
+
Fix any other issues you notice, but identify them to me first before doing so.
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
# Refactoring Plan: source/terminal/marked-renderer.ts
|
|
2
|
+
|
|
3
|
+
**Goal:** Refactor the legacy prototype-based `marked-terminal` renderer (`source/terminal/marked-renderer.ts`) into a modern, well-typed TypeScript class (`TerminalRenderer`) using ES Modules, adhering to the project's coding standards (strict TypeScript, ES Modules, Biome linting/formatting, Conventional Commits).
|
|
4
|
+
|
|
5
|
+
**Current Status:**
|
|
6
|
+
- The code has been partially refactored from its original state into a `TerminalRenderer` class structure.
|
|
7
|
+
- Helper functions have been extracted for complex methods like `listitem` and `link` to improve readability and structure.
|
|
8
|
+
- Many `any` types have been replaced with `unknown` or a placeholder `Token = Record<string, unknown>` type.
|
|
9
|
+
- Safe accessor methods (`_safeParse`, `_safeParseInline`, `_getParserContext`) were introduced to handle interactions with the `marked` parser instance (`this.parser`), whose type is currently `unknown`.
|
|
10
|
+
- The `markedTerminal` extension function has been updated to dynamically wrap methods from the `TerminalRenderer` instance.
|
|
11
|
+
- **Build Errors Persist:** The last build attempt (`npm run build`) failed with several TypeScript errors (see details below).
|
|
12
|
+
- **Lint Warnings Persist:** The last lint run (`npm run lint -- source/terminal/marked-renderer.ts`) showed cognitive complexity warnings for `listitem` and `link`, and potentially remaining `noExplicitAny` issues.
|
|
13
|
+
|
|
14
|
+
**Remaining Tasks:**
|
|
15
|
+
|
|
16
|
+
1. **Resolve Build Errors:** Address the errors reported by `tsc` during `npm run build`.
|
|
17
|
+
* **Error:** `TS2532`, `TS2684`, `TS2683` - `this` context issues in the `compose` helper function.
|
|
18
|
+
* **Location:** Around line 40 in the original `compose` function implementation (check current file).
|
|
19
|
+
* **Cause:** The `compose` helper uses `funcs[i].apply(this, result)`, which attempts to forward a `this` context. However, the context within `compose` itself is likely not the intended one for the composed functions (`undoColon`, `unescapeEntities`, `insertEmojis`).
|
|
20
|
+
* **Suggestion:** Analyze if `undoColon`, `unescapeEntities`, `insertEmojis` actually *require* a specific `this` context. If not, modify `compose` to call them directly (e.g., `result = [funcs[i](...result)]` if `result` is always an array, or adjust based on expected arguments). If they *do* need `this` (unlikely for these utilities), ensure `compose` is called with the correct context bound, or refactor the utilities.
|
|
21
|
+
* **Error:** `TS2323`, `TS2484` - Redeclared exported variable `markedTerminal`.
|
|
22
|
+
* **Location:** Build output indicated potential duplicates. The last file read seemed to have fixed this, but verification is needed.
|
|
23
|
+
* **Suggestion:** Ensure there is only *one* `export function markedTerminal(...)` statement and *one* `export { TerminalRenderer };` statement in the final file structure. Remove any duplicates.
|
|
24
|
+
* **Error:** `TS2322`, `TS7053`, `TS2339` - Indexing/Typing errors within the `markedTerminal` wrapper function.
|
|
25
|
+
* **Location:** Inside the loop assigning methods to `extension.renderer` (approx lines 880-895 in last file read).
|
|
26
|
+
* **Cause:**
|
|
27
|
+
* TypeScript cannot guarantee that `funcName` (a `keyof TerminalRenderer`) is a valid index for `extension.renderer` when it's initially typed as `{}` or even `Record<string, ...>`.
|
|
28
|
+
* The type of `this` inside the dynamically created wrapper functions (`function (this: MarkedContext, ...args: unknown[])`) is not correctly resolving `this.options` and `this.parser`.
|
|
29
|
+
* **Suggestion:**
|
|
30
|
+
* Explicitly type `extension.renderer`: `const extension = { renderer: {} as Record<string, (...args: unknown[]) => string> };`.
|
|
31
|
+
* Define a placeholder type for the `marked` context: `type MarkedContext = { options: unknown; parser: unknown; };`.
|
|
32
|
+
* Ensure `this` is typed correctly in the wrapper: `extension.renderer[funcName] = function (this: MarkedContext, ...args: unknown[]) { ... };`.
|
|
33
|
+
* When accessing `this.options` and `this.parser`, cast `this` if necessary or ensure `MarkedContext` accurately reflects their presence.
|
|
34
|
+
* Consider casting `funcName` to `string` when indexing `extension.renderer` if TypeScript complains about the `keyof` type: `extension.renderer[funcName as string] = ...`.
|
|
35
|
+
|
|
36
|
+
2. **Address Lint Warnings:** Resolve warnings reported by `npm run lint -- source/terminal/marked-renderer.ts`.
|
|
37
|
+
* **Warning:** `lint/complexity/noExcessiveCognitiveComplexity` for `listitem` and `link`.
|
|
38
|
+
* **Location:** Definitions of `listitem` and `link` methods.
|
|
39
|
+
* **Cause:** The methods (including helpers) still contain enough branching/nesting logic to exceed Biome's threshold (15).
|
|
40
|
+
* **Suggestion:** Further review `listitem`, `link`, and their private helpers (`_parseListitemInput`, `_getListitemPrefix`, `_formatListitemText`, `_parseLinkInput`, `_cleanLinkComponents`, `_formatLinkOutput`) for simplification. If the complexity is deemed necessary and the code readable, add a `biome-ignore lint/complexity/noExcessiveCognitiveComplexity: <Reason: Refactored complex logic from Marked spec.>` comment above each method definition.
|
|
41
|
+
* **Warning:** `lint/suspicious/noExplicitAny` (Verify if any remain).
|
|
42
|
+
* **Location:** Check the latest lint report.
|
|
43
|
+
* **Suggestion:** Replace any remaining `any` types with `unknown`, specific types (if determinable), or the placeholder `Token`. Focus on function arguments and potentially types within `TerminalRendererOptions` or `HighlightOptions`.
|
|
44
|
+
|
|
45
|
+
3. **Improve Type Definitions (Blocked Task):**
|
|
46
|
+
* **Issue:** The core types for `marked` (Tokens, Parser context, Options) are currently represented by `unknown` or basic placeholders (`Token = Record<string, unknown>`) because external type definitions (`@types/marked`) could not be fetched or inspected.
|
|
47
|
+
* **Impact:** This necessitates type guards, safe accessors, and potentially unsafe casts (`as any`, though minimized).
|
|
48
|
+
* **Suggestion:** Once access to `@types/marked` is possible:
|
|
49
|
+
* Import relevant types (e.g., `Token`, `TokensList`, `RendererThis`, `MarkedOptions`).
|
|
50
|
+
* Replace the placeholder `Token` type.
|
|
51
|
+
* Replace `parser: unknown` and `options: unknown` with the correct imported types.
|
|
52
|
+
* Replace the placeholder `MarkedContext` with the imported `RendererThis` (or equivalent).
|
|
53
|
+
* Remove casts like `(this.parser as any)` and use type-safe property access.
|
|
54
|
+
* Update method signatures (e.g., `blockquote(quote: Tokens.Blockquote)`) to use specific token types instead of `string | { tokens: Token[] }`.
|
|
55
|
+
|
|
56
|
+
4. **Final Verification Steps:**
|
|
57
|
+
* Run `npm run format` to ensure code formatting is correct.
|
|
58
|
+
* Run `npm run lint -- source/terminal/marked-renderer.ts` until no errors or unexpected warnings remain.
|
|
59
|
+
* Run `npm run build` until it completes successfully.
|
|
60
|
+
* Consider running `npm test` if tests covering this renderer exist or can be added.
|
|
61
|
+
* Commit changes using Conventional Commit standards (e.g., `refactor(terminal): modernize marked-renderer class`).
|
|
62
|
+
|
|
63
|
+
**File Path:** `source/terminal/marked-renderer.ts`
|
|
64
|
+
**Project Root:** `/Users/travisennis/Github/acai-ts`
|