@travisennis/acai 0.0.9 → 0.0.11
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +51 -760
- package/bin/acai +52 -0
- package/dist/agent/index.d.ts +12 -2
- package/dist/agent/index.d.ts.map +1 -1
- package/dist/agent/index.js +380 -199
- package/dist/agent/sub-agent.d.ts +23 -0
- package/dist/agent/sub-agent.d.ts.map +1 -0
- package/dist/agent/sub-agent.js +109 -0
- package/dist/cli/index.d.ts +26 -0
- package/dist/cli/index.d.ts.map +1 -0
- package/dist/{cli.js → cli/index.js} +84 -77
- package/dist/{stdin.d.ts → cli/stdin.d.ts} +2 -1
- package/dist/cli/stdin.d.ts.map +1 -0
- package/dist/{stdin.js → cli/stdin.js} +11 -0
- package/dist/commands/copy/index.js +2 -2
- package/dist/commands/copy/utils.d.ts.map +1 -1
- package/dist/commands/copy/utils.js +15 -13
- package/dist/commands/generate-rules/index.d.ts +1 -1
- package/dist/commands/generate-rules/index.d.ts.map +1 -1
- package/dist/commands/generate-rules/index.js +16 -101
- package/dist/commands/generate-rules/service.d.ts +22 -0
- package/dist/commands/generate-rules/service.d.ts.map +1 -0
- package/dist/commands/generate-rules/service.js +103 -0
- package/dist/commands/handoff/index.js +2 -2
- package/dist/commands/health/index.js +1 -1
- package/dist/commands/health/utils.d.ts +3 -2
- package/dist/commands/health/utils.d.ts.map +1 -1
- package/dist/commands/health/utils.js +6 -0
- package/dist/commands/history/index.d.ts +1 -1
- package/dist/commands/history/index.d.ts.map +1 -1
- package/dist/commands/history/index.js +17 -18
- package/dist/commands/history/types.d.ts +38 -0
- package/dist/commands/history/types.d.ts.map +1 -1
- package/dist/commands/history/utils.d.ts.map +1 -1
- package/dist/commands/history/utils.js +63 -58
- package/dist/commands/init/index.d.ts.map +1 -1
- package/dist/commands/init/index.js +3 -8
- package/dist/commands/init-project/index.d.ts.map +1 -1
- package/dist/commands/init-project/index.js +3 -3
- package/dist/commands/init-project/utils.d.ts +2 -1
- package/dist/commands/init-project/utils.d.ts.map +1 -1
- package/dist/commands/init-project/utils.js +10 -2
- package/dist/commands/list-tools/index.d.ts.map +1 -1
- package/dist/commands/list-tools/index.js +7 -31
- package/dist/commands/manager.d.ts +2 -2
- package/dist/commands/manager.d.ts.map +1 -1
- package/dist/commands/manager.js +55 -33
- package/dist/commands/model/index.d.ts.map +1 -1
- package/dist/commands/model/index.js +20 -151
- package/dist/commands/model/model-panel.d.ts +4 -0
- package/dist/commands/model/model-panel.d.ts.map +1 -0
- package/dist/commands/model/model-panel.js +144 -0
- package/dist/commands/paste/index.d.ts.map +1 -1
- package/dist/commands/paste/index.js +59 -62
- package/dist/commands/paste/utils.d.ts.map +1 -1
- package/dist/commands/paste/utils.js +88 -58
- package/dist/commands/pickup/index.d.ts.map +1 -1
- package/dist/commands/pickup/index.js +6 -3
- package/dist/commands/pickup/utils.js +3 -3
- package/dist/commands/resources/index.d.ts.map +1 -1
- package/dist/commands/resources/index.js +33 -50
- package/dist/commands/review/index.d.ts.map +1 -1
- package/dist/commands/review/index.js +3 -117
- package/dist/commands/review/review-panel.d.ts +3 -0
- package/dist/commands/review/review-panel.d.ts.map +1 -0
- package/dist/commands/review/review-panel.js +186 -0
- package/dist/commands/review/utils.d.ts +15 -1
- package/dist/commands/review/utils.d.ts.map +1 -1
- package/dist/commands/review/utils.js +127 -68
- package/dist/commands/session/index.d.ts +1 -1
- package/dist/commands/session/index.d.ts.map +1 -1
- package/dist/commands/session/index.js +124 -135
- package/dist/commands/shell/index.d.ts.map +1 -1
- package/dist/commands/shell/index.js +16 -1
- package/dist/commands/types.d.ts +2 -2
- package/dist/commands/types.d.ts.map +1 -1
- package/dist/{config.d.ts → config/index.d.ts} +20 -9
- package/dist/config/index.d.ts.map +1 -0
- package/dist/{config.js → config/index.js} +43 -42
- package/dist/execution/index.d.ts.map +1 -1
- package/dist/execution/index.js +75 -55
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +148 -141
- package/dist/middleware/cache.d.ts.map +1 -1
- package/dist/middleware/cache.js +18 -36
- package/dist/models/ai-config.d.ts +1 -0
- package/dist/models/ai-config.d.ts.map +1 -1
- package/dist/models/ai-config.js +4 -3
- package/dist/models/anthropic-provider.d.ts +2 -5
- package/dist/models/anthropic-provider.d.ts.map +1 -1
- package/dist/models/anthropic-provider.js +3 -70
- package/dist/models/deepseek-provider.d.ts +1 -0
- package/dist/models/deepseek-provider.d.ts.map +1 -1
- package/dist/models/google-provider.d.ts +2 -3
- package/dist/models/google-provider.d.ts.map +1 -1
- package/dist/models/google-provider.js +0 -26
- package/dist/models/groq-provider.d.ts +1 -0
- package/dist/models/groq-provider.d.ts.map +1 -1
- package/dist/models/manager.d.ts +13 -2
- package/dist/models/manager.d.ts.map +1 -1
- package/dist/models/manager.js +20 -8
- package/dist/models/openai-provider.d.ts +2 -5
- package/dist/models/openai-provider.d.ts.map +1 -1
- package/dist/models/openai-provider.js +0 -52
- package/dist/models/opencode-go-provider.d.ts +25 -0
- package/dist/models/opencode-go-provider.d.ts.map +1 -0
- package/dist/models/opencode-go-provider.js +78 -0
- package/dist/models/opencode-zen-provider.d.ts +7 -3
- package/dist/models/opencode-zen-provider.d.ts.map +1 -1
- package/dist/models/opencode-zen-provider.js +49 -10
- package/dist/models/openrouter-provider.d.ts +27 -31
- package/dist/models/openrouter-provider.d.ts.map +1 -1
- package/dist/models/openrouter-provider.js +121 -180
- package/dist/models/providers.d.ts +3 -3
- package/dist/models/providers.d.ts.map +1 -1
- package/dist/models/providers.js +6 -0
- package/dist/models/xai-provider.d.ts +4 -3
- package/dist/models/xai-provider.d.ts.map +1 -1
- package/dist/models/xai-provider.js +18 -18
- package/dist/modes/manager.d.ts +24 -0
- package/dist/modes/manager.d.ts.map +1 -0
- package/dist/modes/manager.js +77 -0
- package/dist/modes/prompts.d.ts +2 -0
- package/dist/modes/prompts.d.ts.map +1 -0
- package/dist/modes/prompts.js +142 -0
- package/dist/prompts/mentions.d.ts +11 -0
- package/dist/prompts/mentions.d.ts.map +1 -0
- package/dist/{mentions.js → prompts/mentions.js} +55 -85
- package/dist/{prompts.d.ts → prompts/system-prompt.d.ts} +7 -2
- package/dist/prompts/system-prompt.d.ts.map +1 -0
- package/dist/{prompts.js → prompts/system-prompt.js} +31 -16
- package/dist/repl/index.d.ts +174 -0
- package/dist/repl/index.d.ts.map +1 -0
- package/dist/{repl-new.js → repl/index.js} +397 -76
- package/dist/repl/project-status.d.ts +1 -0
- package/dist/repl/project-status.d.ts.map +1 -1
- package/dist/repl/project-status.js +4 -1
- package/dist/sessions/manager.d.ts +92 -0
- package/dist/sessions/manager.d.ts.map +1 -1
- package/dist/sessions/manager.js +262 -9
- package/dist/sessions/summary.d.ts +4 -0
- package/dist/sessions/summary.d.ts.map +1 -0
- package/dist/sessions/summary.js +30 -0
- package/dist/skills/index.d.ts +29 -0
- package/dist/skills/index.d.ts.map +1 -0
- package/dist/skills/index.js +294 -0
- package/dist/subagents/index.d.ts +16 -0
- package/dist/subagents/index.d.ts.map +1 -0
- package/dist/subagents/index.js +231 -0
- package/dist/terminal/control.d.ts +1 -1
- package/dist/terminal/control.d.ts.map +1 -1
- package/dist/terminal/control.js +3 -3
- package/dist/terminal/east-asian-width.d.ts.map +1 -1
- package/dist/terminal/east-asian-width.js +404 -351
- package/dist/terminal/keys.d.ts +17 -0
- package/dist/terminal/keys.d.ts.map +1 -1
- package/dist/terminal/keys.js +37 -0
- package/dist/terminal/select-prompt.d.ts.map +1 -1
- package/dist/terminal/select-prompt.js +24 -12
- package/dist/terminal/string-width.d.ts.map +1 -1
- package/dist/terminal/string-width.js +25 -27
- package/dist/terminal/style.d.ts.map +1 -1
- package/dist/terminal/style.js +4 -7
- package/dist/terminal/supports-color.d.ts.map +1 -1
- package/dist/terminal/supports-color.js +41 -27
- package/dist/terminal/table/cell.d.ts +12 -0
- package/dist/terminal/table/cell.d.ts.map +1 -1
- package/dist/terminal/table/cell.js +40 -25
- package/dist/terminal/table/layout-manager.d.ts.map +1 -1
- package/dist/terminal/table/layout-manager.js +100 -68
- package/dist/terminal/table/utils.d.ts +1 -1
- package/dist/terminal/table/utils.d.ts.map +1 -1
- package/dist/terminal/table/utils.js +17 -10
- package/dist/terminal/wrap-ansi.d.ts.map +1 -1
- package/dist/terminal/wrap-ansi.js +174 -105
- package/dist/tokens/tracker.d.ts +1 -0
- package/dist/tokens/tracker.d.ts.map +1 -1
- package/dist/tokens/tracker.js +3 -0
- package/dist/tools/agent.d.ts +27 -0
- package/dist/tools/agent.d.ts.map +1 -0
- package/dist/tools/agent.js +81 -0
- package/dist/tools/apply-patch.d.ts +62 -0
- package/dist/tools/apply-patch.d.ts.map +1 -0
- package/dist/tools/apply-patch.js +377 -0
- package/dist/tools/bash.d.ts +4 -3
- package/dist/tools/bash.d.ts.map +1 -1
- package/dist/tools/bash.js +349 -141
- package/dist/tools/directory-tree.d.ts +3 -3
- package/dist/tools/directory-tree.d.ts.map +1 -1
- package/dist/tools/directory-tree.js +8 -5
- package/dist/tools/dynamic-tool-loader.d.ts +3 -6
- package/dist/tools/dynamic-tool-loader.d.ts.map +1 -1
- package/dist/tools/dynamic-tool-loader.js +20 -4
- package/dist/tools/edit-file.d.ts +7 -7
- package/dist/tools/edit-file.d.ts.map +1 -1
- package/dist/tools/edit-file.js +292 -85
- package/dist/tools/glob.d.ts +6 -6
- package/dist/tools/glob.d.ts.map +1 -1
- package/dist/tools/glob.js +110 -63
- package/dist/tools/grep.d.ts +15 -12
- package/dist/tools/grep.d.ts.map +1 -1
- package/dist/tools/grep.js +315 -193
- package/dist/tools/index.d.ts +114 -9
- package/dist/tools/index.d.ts.map +1 -1
- package/dist/tools/index.js +39 -24
- package/dist/tools/ls.d.ts +2 -2
- package/dist/tools/ls.d.ts.map +1 -1
- package/dist/tools/ls.js +7 -5
- package/dist/tools/read-file.d.ts +4 -6
- package/dist/tools/read-file.d.ts.map +1 -1
- package/dist/tools/read-file.js +84 -39
- package/dist/tools/save-file.d.ts +3 -3
- package/dist/tools/save-file.d.ts.map +1 -1
- package/dist/tools/save-file.js +36 -31
- package/dist/tools/skill.d.ts +23 -0
- package/dist/tools/skill.d.ts.map +1 -0
- package/dist/tools/skill.js +65 -0
- package/dist/tools/think.d.ts.map +1 -1
- package/dist/tools/think.js +2 -9
- package/dist/tools/utils.d.ts +2 -0
- package/dist/tools/utils.d.ts.map +1 -1
- package/dist/tools/utils.js +12 -0
- package/dist/tools/web-fetch.d.ts +50 -0
- package/dist/tools/web-fetch.d.ts.map +1 -0
- package/dist/tools/web-fetch.js +446 -0
- package/dist/tools/web-search.d.ts +44 -0
- package/dist/tools/web-search.d.ts.map +1 -0
- package/dist/tools/web-search.js +226 -0
- package/dist/tui/autocomplete/attachment-provider.d.ts +3 -6
- package/dist/tui/autocomplete/attachment-provider.d.ts.map +1 -1
- package/dist/tui/autocomplete/attachment-provider.js +25 -78
- package/dist/tui/autocomplete/base-provider.d.ts +1 -0
- package/dist/tui/autocomplete/base-provider.d.ts.map +1 -1
- package/dist/tui/autocomplete/combined-provider.d.ts +1 -4
- package/dist/tui/autocomplete/combined-provider.d.ts.map +1 -1
- package/dist/tui/autocomplete/combined-provider.js +3 -17
- package/dist/tui/autocomplete/command-provider.d.ts +1 -0
- package/dist/tui/autocomplete/command-provider.d.ts.map +1 -1
- package/dist/tui/autocomplete/command-provider.js +3 -0
- package/dist/tui/autocomplete/file-search-provider.d.ts +2 -1
- package/dist/tui/autocomplete/file-search-provider.d.ts.map +1 -1
- package/dist/tui/autocomplete/file-search-provider.js +37 -17
- package/dist/tui/autocomplete/skill-provider.d.ts +17 -0
- package/dist/tui/autocomplete/skill-provider.d.ts.map +1 -0
- package/dist/tui/autocomplete/skill-provider.js +49 -0
- package/dist/tui/autocomplete/utils.d.ts +2 -1
- package/dist/tui/autocomplete/utils.d.ts.map +1 -1
- package/dist/tui/autocomplete/utils.js +25 -23
- package/dist/tui/autocomplete.d.ts +2 -2
- package/dist/tui/autocomplete.d.ts.map +1 -1
- package/dist/tui/autocomplete.js +3 -5
- package/dist/tui/components/assistant-message.d.ts.map +1 -1
- package/dist/tui/components/assistant-message.js +0 -4
- package/dist/tui/components/editor.d.ts +18 -3
- package/dist/tui/components/editor.d.ts.map +1 -1
- package/dist/tui/components/editor.js +211 -237
- package/dist/tui/components/footer.d.ts +6 -4
- package/dist/tui/components/footer.d.ts.map +1 -1
- package/dist/tui/components/footer.js +49 -25
- package/dist/tui/components/markdown.d.ts +10 -7
- package/dist/tui/components/markdown.d.ts.map +1 -1
- package/dist/tui/components/markdown.js +57 -39
- package/dist/tui/components/modal.d.ts.map +1 -1
- package/dist/tui/components/modal.js +35 -33
- package/dist/tui/components/notification.d.ts +13 -2
- package/dist/tui/components/notification.d.ts.map +1 -1
- package/dist/tui/components/notification.js +36 -2
- package/dist/tui/components/progress-bar.js +1 -1
- package/dist/tui/components/select-list.d.ts +1 -0
- package/dist/tui/components/select-list.d.ts.map +1 -1
- package/dist/tui/components/select-list.js +14 -11
- package/dist/tui/components/text.d.ts +16 -0
- package/dist/tui/components/text.d.ts.map +1 -1
- package/dist/tui/components/text.js +72 -57
- package/dist/tui/components/thinking-block.d.ts +9 -0
- package/dist/tui/components/thinking-block.d.ts.map +1 -1
- package/dist/tui/components/thinking-block.js +43 -11
- package/dist/tui/components/tool-execution.d.ts +5 -1
- package/dist/tui/components/tool-execution.d.ts.map +1 -1
- package/dist/tui/components/tool-execution.js +19 -10
- package/dist/tui/components/user-message.d.ts.map +1 -1
- package/dist/tui/components/user-message.js +0 -3
- package/dist/tui/components/welcome.d.ts +2 -1
- package/dist/tui/components/welcome.d.ts.map +1 -1
- package/dist/tui/components/welcome.js +2 -2
- package/dist/tui/editor-launcher.d.ts +3 -2
- package/dist/tui/editor-launcher.d.ts.map +1 -1
- package/dist/tui/index.d.ts +0 -1
- package/dist/tui/index.d.ts.map +1 -1
- package/dist/tui/terminal.d.ts.map +1 -1
- package/dist/tui/terminal.js +10 -2
- package/dist/tui/tui.d.ts +43 -0
- package/dist/tui/tui.d.ts.map +1 -1
- package/dist/tui/tui.js +166 -41
- package/dist/tui/utils.d.ts +1 -5
- package/dist/tui/utils.d.ts.map +1 -1
- package/dist/tui/utils.js +271 -44
- package/dist/utils/bash/parse.d.ts +19 -0
- package/dist/utils/bash/parse.d.ts.map +1 -0
- package/dist/utils/bash/parse.js +223 -0
- package/dist/utils/bash/quote.d.ts +6 -0
- package/dist/utils/bash/quote.d.ts.map +1 -0
- package/dist/utils/bash/quote.js +23 -0
- package/dist/utils/bash.d.ts.map +1 -1
- package/dist/utils/bash.js +211 -126
- package/dist/utils/command-protection.d.ts +28 -0
- package/dist/utils/command-protection.d.ts.map +1 -0
- package/dist/utils/command-protection.js +324 -0
- package/dist/utils/dedent.d.ts.map +1 -0
- package/dist/utils/env-expand.d.ts +2 -0
- package/dist/utils/env-expand.d.ts.map +1 -0
- package/dist/utils/env-expand.js +8 -0
- package/dist/utils/filesystem/path-display.d.ts +11 -0
- package/dist/utils/filesystem/path-display.d.ts.map +1 -0
- package/dist/utils/filesystem/path-display.js +32 -0
- package/dist/utils/filesystem/security.d.ts +2 -2
- package/dist/utils/filesystem/security.d.ts.map +1 -1
- package/dist/utils/filesystem/security.js +28 -30
- package/dist/utils/formatting.d.ts.map +1 -0
- package/dist/{formatting.js → utils/formatting.js} +1 -1
- package/dist/utils/git.d.ts +4 -0
- package/dist/utils/git.d.ts.map +1 -1
- package/dist/utils/git.js +30 -0
- package/dist/utils/glob.d.ts +1 -1
- package/dist/utils/glob.d.ts.map +1 -1
- package/dist/utils/logger.d.ts.map +1 -0
- package/dist/{logger.js → utils/logger.js} +1 -1
- package/dist/utils/parsing.d.ts.map +1 -0
- package/dist/utils/process.d.ts.map +1 -1
- package/dist/utils/process.js +90 -37
- package/dist/utils/templates.d.ts +2 -0
- package/dist/utils/templates.d.ts.map +1 -0
- package/dist/utils/templates.js +24 -0
- package/dist/utils/version.d.ts.map +1 -0
- package/dist/{version.js → utils/version.js} +1 -1
- package/package.json +35 -26
- package/dist/cli.d.ts +0 -23
- package/dist/cli.d.ts.map +0 -1
- package/dist/commands/add-directory/types.d.ts +0 -6
- package/dist/commands/add-directory/types.d.ts.map +0 -1
- package/dist/commands/add-directory/types.js +0 -1
- package/dist/commands/copy/types.d.ts +0 -3
- package/dist/commands/copy/types.d.ts.map +0 -1
- package/dist/commands/copy/types.js +0 -1
- package/dist/commands/exit/index.d.ts +0 -10
- package/dist/commands/exit/index.d.ts.map +0 -1
- package/dist/commands/exit/index.js +0 -21
- package/dist/commands/exit/types.d.ts +0 -8
- package/dist/commands/exit/types.d.ts.map +0 -1
- package/dist/commands/exit/types.js +0 -1
- package/dist/commands/exit/utils.d.ts +0 -2
- package/dist/commands/exit/utils.d.ts.map +0 -1
- package/dist/commands/exit/utils.js +0 -13
- package/dist/commands/prompt/index.d.ts +0 -5
- package/dist/commands/prompt/index.d.ts.map +0 -1
- package/dist/commands/prompt/index.js +0 -122
- package/dist/commands/prompt/types.d.ts +0 -15
- package/dist/commands/prompt/types.d.ts.map +0 -1
- package/dist/commands/prompt/types.js +0 -1
- package/dist/commands/prompt/utils.d.ts +0 -12
- package/dist/commands/prompt/utils.d.ts.map +0 -1
- package/dist/commands/prompt/utils.js +0 -107
- package/dist/commands/reset/index.d.ts +0 -3
- package/dist/commands/reset/index.d.ts.map +0 -1
- package/dist/commands/reset/index.js +0 -25
- package/dist/commands/reset/types.d.ts +0 -1
- package/dist/commands/reset/types.d.ts.map +0 -1
- package/dist/commands/reset/types.js +0 -3
- package/dist/commands/review/types.d.ts +0 -12
- package/dist/commands/review/types.d.ts.map +0 -1
- package/dist/commands/review/types.js +0 -1
- package/dist/commands/save/index.d.ts +0 -3
- package/dist/commands/save/index.d.ts.map +0 -1
- package/dist/commands/save/index.js +0 -19
- package/dist/config.d.ts.map +0 -1
- package/dist/dedent.d.ts.map +0 -1
- package/dist/formatting.d.ts.map +0 -1
- package/dist/logger.d.ts.map +0 -1
- package/dist/mentions.d.ts +0 -14
- package/dist/mentions.d.ts.map +0 -1
- package/dist/parsing.d.ts.map +0 -1
- package/dist/prompts.d.ts.map +0 -1
- package/dist/repl-new.d.ts +0 -65
- package/dist/repl-new.d.ts.map +0 -1
- package/dist/skills.d.ts +0 -16
- package/dist/skills.d.ts.map +0 -1
- package/dist/skills.js +0 -233
- package/dist/stdin.d.ts.map +0 -1
- package/dist/tui/autocomplete/path-provider.d.ts +0 -21
- package/dist/tui/autocomplete/path-provider.d.ts.map +0 -1
- package/dist/tui/autocomplete/path-provider.js +0 -164
- package/dist/utils/iterables.d.ts +0 -2
- package/dist/utils/iterables.d.ts.map +0 -1
- package/dist/utils/iterables.js +0 -6
- package/dist/version.d.ts.map +0 -1
- /package/dist/{dedent.d.ts → utils/dedent.d.ts} +0 -0
- /package/dist/{dedent.js → utils/dedent.js} +0 -0
- /package/dist/{formatting.d.ts → utils/formatting.d.ts} +0 -0
- /package/dist/{logger.d.ts → utils/logger.d.ts} +0 -0
- /package/dist/{parsing.d.ts → utils/parsing.d.ts} +0 -0
- /package/dist/{parsing.js → utils/parsing.js} +0 -0
- /package/dist/{version.d.ts → utils/version.d.ts} +0 -0
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
import { createUserMessage } from "../sessions/manager.js";
|
|
2
|
+
import { planningPrompt } from "./prompts.js";
|
|
3
|
+
const MODE_DEFINITIONS = {
|
|
4
|
+
normal: {
|
|
5
|
+
name: "normal",
|
|
6
|
+
displayName: "Normal",
|
|
7
|
+
initialPrompt: "",
|
|
8
|
+
reminderPrompt: "",
|
|
9
|
+
},
|
|
10
|
+
planning: {
|
|
11
|
+
name: "planning",
|
|
12
|
+
displayName: "Plan",
|
|
13
|
+
initialPrompt: planningPrompt,
|
|
14
|
+
reminderPrompt: "Remember: You are still in Plan Mode. Continue focusing on architectural design, systematic planning, and high-level considerations.",
|
|
15
|
+
},
|
|
16
|
+
research: {
|
|
17
|
+
name: "research",
|
|
18
|
+
displayName: "Research",
|
|
19
|
+
initialPrompt: "You are in RESEARCH MODE. Your goal is to thoroughly investigate:\n\n1. Current state and context\n2. Existing solutions\n3. Best practices\n4. Trade-offs\n5. Potential pitfalls",
|
|
20
|
+
reminderPrompt: "Remember: You are still in RESEARCH MODE. Continue investigating thoroughly. Synthesize findings.",
|
|
21
|
+
},
|
|
22
|
+
};
|
|
23
|
+
const ALL_MODES = ["normal", "planning", "research"];
|
|
24
|
+
export class ModeManager {
|
|
25
|
+
currentMode = "normal";
|
|
26
|
+
firstMessageInMode = true;
|
|
27
|
+
getCurrentMode() {
|
|
28
|
+
return this.currentMode;
|
|
29
|
+
}
|
|
30
|
+
getDisplayName() {
|
|
31
|
+
return MODE_DEFINITIONS[this.currentMode].displayName;
|
|
32
|
+
}
|
|
33
|
+
cycleMode() {
|
|
34
|
+
const currentIndex = ALL_MODES.indexOf(this.currentMode);
|
|
35
|
+
const nextIndex = (currentIndex + 1) % ALL_MODES.length;
|
|
36
|
+
this.currentMode = ALL_MODES[nextIndex];
|
|
37
|
+
this.firstMessageInMode = true;
|
|
38
|
+
}
|
|
39
|
+
getInitialPrompt() {
|
|
40
|
+
return MODE_DEFINITIONS[this.currentMode].initialPrompt;
|
|
41
|
+
}
|
|
42
|
+
getReminderPrompt() {
|
|
43
|
+
return MODE_DEFINITIONS[this.currentMode].reminderPrompt;
|
|
44
|
+
}
|
|
45
|
+
isNormal() {
|
|
46
|
+
return this.currentMode === "normal";
|
|
47
|
+
}
|
|
48
|
+
isFirstMessage() {
|
|
49
|
+
return this.firstMessageInMode;
|
|
50
|
+
}
|
|
51
|
+
markFirstMessageSent() {
|
|
52
|
+
this.firstMessageInMode = false;
|
|
53
|
+
}
|
|
54
|
+
getReminderMessage() {
|
|
55
|
+
if (this.isNormal() || this.firstMessageInMode) {
|
|
56
|
+
return undefined;
|
|
57
|
+
}
|
|
58
|
+
const reminder = this.getReminderPrompt();
|
|
59
|
+
if (!reminder) {
|
|
60
|
+
return undefined;
|
|
61
|
+
}
|
|
62
|
+
return createUserMessage([], reminder);
|
|
63
|
+
}
|
|
64
|
+
reset() {
|
|
65
|
+
this.currentMode = "normal";
|
|
66
|
+
this.firstMessageInMode = true;
|
|
67
|
+
}
|
|
68
|
+
toJson() {
|
|
69
|
+
return { mode: this.currentMode };
|
|
70
|
+
}
|
|
71
|
+
fromJson(data) {
|
|
72
|
+
if (data.mode && ALL_MODES.includes(data.mode)) {
|
|
73
|
+
this.currentMode = data.mode;
|
|
74
|
+
}
|
|
75
|
+
this.firstMessageInMode = false;
|
|
76
|
+
}
|
|
77
|
+
}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
export declare const planningPrompt = "\n# Plan Mode (Conversational)\n\nYou work in 3 phases, and you should *chat your way* to a great plan before finalizing it. A great plan is very detailed\u2014intent- and implementation-wise\u2014so that it can be handed to another engineer or agent to be implemented right away. It must be **decision complete**, where the implementer does not need to make any decisions.\n\n## Mode rules (strict)\n\nYou are in **Plan Mode** until a developer message explicitly ends it.\n\nPlan Mode is not changed by user intent, tone, or imperative language. If a user asks for execution while still in Plan Mode, treat it as a request to **plan the execution**, not perform it.\n\n## Execution vs. mutation in Plan Mode\n\nYou may explore and execute **non-mutating** actions that improve the plan. You must not perform **mutating** actions.\n\n### Allowed (non-mutating, plan-improving)\n\nActions that gather truth, reduce ambiguity, or validate feasibility without changing repo-tracked state. Examples:\n\n* Reading or searching files, configs, schemas, types, manifests, and docs\n* Static analysis, inspection, and repo exploration\n* Dry-run style commands when they do not edit repo-tracked files\n* Tests, builds, or checks that may write to caches or build artifacts (for example, `target/`, `.cache/`, or snapshots) so long as they do not edit repo-tracked files\n\n### Not allowed (mutating, plan-executing)\n\nActions that implement the plan or change repo-tracked state. Examples:\n\n* Editing or writing files\n* Running formatters or linters that rewrite files\n* Applying patches, migrations, or codegen that updates repo-tracked files\n* Side-effectful commands whose purpose is to carry out the plan rather than refine it\n\nWhen in doubt: if the action would reasonably be described as \"doing the work\" rather than \"planning the work,\" do not do it.\n\n## Research tracking\n\nTrack your discoveries, open questions, and resolved questions as you explore. Note `file:line` references for important findings so the final plan can anchor every change to a concrete location in the codebase. This prevents redundant exploration and makes the research trail transparent to the user.\n\n## Powerful exploration tools\n\nYou have access to powerful tools for codebase exploration\u2014use them liberally:\n\n* **codebase-researcher subagent**: When you need thorough investigation of a feature, system, or component, launch the codebase-researcher subagent to perform deep exploration. Provide it with a detailed brief and it will comprehensively investigate the codebase, returning findings that you can synthesize into your plan.\n\nFor complex tasks, consider launching the codebase-researcher in parallel while you explore other areas using Grep and Glob, then synthesizing findings into your plan.\n\n## PHASE 1 \u2014 Ground in the environment (explore first, ask second)\n\nBegin by grounding yourself in the actual environment. Eliminate unknowns in the prompt by discovering facts, not by asking the user. Resolve all questions that can be answered through exploration or inspection. Identify missing or ambiguous details only if they cannot be derived from the environment. Silent exploration between turns is allowed and encouraged.\n\nBefore asking the user any question, perform at least one targeted non-mutating exploration pass (for example: search relevant files, inspect likely entrypoints/configs, confirm current implementation shape), unless no local environment/repo is available.\n\nException: you may ask clarifying questions about the user's prompt before exploring, ONLY if there are obvious ambiguities or contradictions in the prompt itself. However, if ambiguity might be resolved by exploring, always prefer exploring first.\n\nDo not ask questions that can be answered from the repo or system (for example, \"where is this struct?\" or \"which UI component should we use?\" when exploration can make it clear). Only ask once you have exhausted reasonable non-mutating exploration.\n\n## PHASE 2 \u2014 Intent chat (what they actually want)\n\n* Keep asking until you can clearly state: goal + success criteria, audience, in/out of scope, constraints, current state, and the key preferences/tradeoffs.\n* Require an explicit **\"Out of Scope\"** statement \u2014 what we are NOT doing. This prevents scope creep and sets clear expectations.\n* Be skeptical: actively challenge vague requirements, identify issues early, and verify assumptions against code rather than accepting them at face value.\n* Bias toward questions over guessing: if any high-impact ambiguity remains, do NOT plan yet\u2014ask.\n\n## PHASE 3 \u2014 Implementation chat (what/how we\u2019ll build)\n\n* Once intent is stable, keep asking until the spec is decision complete: approach, interfaces (APIs/schemas/I/O), data flow, edge cases/failure modes, testing + acceptance criteria, rollout/monitoring, and any migrations/compat constraints.\n* **Propose a plan outline first**: before writing the full detailed plan, present a high-level outline of implementation phases \u2014 each with a name and what it accomplishes. Get user feedback on structure before filling in details.\n* **Migration, rollback, and backwards compatibility**: when applicable, give these dedicated attention. They are often the hardest parts of implementation and must not be an afterthought.\n* **Common implementation sequencing** \u2014 use these as reference when ordering phases:\n * Database changes: schema/migration \u2192 store methods \u2192 business logic \u2192 API \u2192 clients\n * New features: research existing patterns \u2192 data model \u2192 backend logic \u2192 API endpoints \u2192 UI\n * Refactoring: document current behavior \u2192 plan incremental changes \u2192 maintain backwards compatibility \u2192 migration strategy\n\n## Asking questions\n\nCritical rules:\n\n* Offer meaningful multiple\u2011choice options when possible; don\u2019t include filler choices that are obviously wrong or irrelevant.\n\nYou SHOULD ask many questions, but each question must:\n\n* materially change the spec/plan, OR\n* confirm/lock an assumption, OR\n* choose between meaningful tradeoffs.\n* not be answerable by non-mutating commands.\n\n## Two kinds of unknowns (treat differently)\n\n1. **Discoverable facts** (repo/system truth): explore first.\n\n * Before asking, run targeted searches and check likely sources of truth (configs/manifests/entrypoints/schemas/types/constants).\n * Ask only if: multiple plausible candidates; nothing found but you need a missing identifier/context; or ambiguity is actually product intent.\n * If asking, present concrete candidates (paths/service names) + recommend one.\n * Never ask questions you can answer from your environment (e.g., \u201Cwhere is this struct\u201D).\n\n2. **Preferences/tradeoffs** (not discoverable): ask early.\n\n * These are intent or implementation preferences that cannot be derived from exploration.\n * Provide 2\u20134 mutually exclusive options + a recommended default.\n * If unanswered, proceed with the recommended option and record it as an assumption in the final plan.\n\n## Finalization rule\n\nOnly output the final plan when it is decision complete and leaves no decisions to the implementer.\n\nWhen you present the official plan, wrap it in a `<proposed_plan>` block so the client can render it specially:\n\n1) The opening tag must be on its own line.\n2) Start the plan content on the next line (no text on the same line as the tag).\n3) The closing tag must be on its own line.\n4) Use Markdown inside the block.\n5) Keep the tags exactly as `<proposed_plan>` and `</proposed_plan>` (do not translate or rename them), even if the plan content is in another language.\n\nExample:\n\n<proposed_plan>\nplan content\n</proposed_plan>\n\nplan content should be human and agent digestible. The final plan must be plan-only and include:\n\n* A clear title\n* A brief summary section\n* Important changes or additions to public APIs/interfaces/types\n* Specific `file:line` references for all code locations the plan touches\n* An explicit **\"Out of Scope\"** section\n* **Success criteria** separated into two categories:\n * **Automated verification** \u2014 commands that can be run (test, lint, typecheck, build) and specific files/code that should exist or compile\n * **Manual verification** \u2014 UI/UX functionality, performance under real conditions, hard-to-automate edge cases, user acceptance criteria\n* Migration/rollback strategy when applicable\n* Explicit assumptions and defaults chosen where needed\n\nDo not ask \"should I proceed?\" in the final output. The user can easily switch out of Plan mode and request implementation if you have included a `<proposed_plan>` block in your response. Alternatively, they can decide to stay in Plan mode and continue refining the plan.\n\nOnly produce at most one `<proposed_plan>` block per turn, and only when you are presenting a complete spec.\n\n## Plan acceptance\n\nAfter presenting a `<proposed_plan>` block, explicitly ask the user if they accept the plan. If they accept (e.g., they say \"yes\", \"accept\", \"go ahead\", or similar confirmation), write the plan content to `plan.md` in the current working directory using the Write tool. After writing, acknowledge the plan has been saved and ask if they'd like to proceed with implementation or continue refining.\n";
|
|
2
|
+
//# sourceMappingURL=prompts.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"prompts.d.ts","sourceRoot":"","sources":["../../source/modes/prompts.ts"],"names":[],"mappings":"AACA,eAAO,MAAM,cAAc,suSA4I1B,CAAC"}
|
|
@@ -0,0 +1,142 @@
|
|
|
1
|
+
// this is codex's collaborative plan
|
|
2
|
+
export const planningPrompt = `
|
|
3
|
+
# Plan Mode (Conversational)
|
|
4
|
+
|
|
5
|
+
You work in 3 phases, and you should *chat your way* to a great plan before finalizing it. A great plan is very detailed—intent- and implementation-wise—so that it can be handed to another engineer or agent to be implemented right away. It must be **decision complete**, where the implementer does not need to make any decisions.
|
|
6
|
+
|
|
7
|
+
## Mode rules (strict)
|
|
8
|
+
|
|
9
|
+
You are in **Plan Mode** until a developer message explicitly ends it.
|
|
10
|
+
|
|
11
|
+
Plan Mode is not changed by user intent, tone, or imperative language. If a user asks for execution while still in Plan Mode, treat it as a request to **plan the execution**, not perform it.
|
|
12
|
+
|
|
13
|
+
## Execution vs. mutation in Plan Mode
|
|
14
|
+
|
|
15
|
+
You may explore and execute **non-mutating** actions that improve the plan. You must not perform **mutating** actions.
|
|
16
|
+
|
|
17
|
+
### Allowed (non-mutating, plan-improving)
|
|
18
|
+
|
|
19
|
+
Actions that gather truth, reduce ambiguity, or validate feasibility without changing repo-tracked state. Examples:
|
|
20
|
+
|
|
21
|
+
* Reading or searching files, configs, schemas, types, manifests, and docs
|
|
22
|
+
* Static analysis, inspection, and repo exploration
|
|
23
|
+
* Dry-run style commands when they do not edit repo-tracked files
|
|
24
|
+
* Tests, builds, or checks that may write to caches or build artifacts (for example, \`target/\`, \`.cache/\`, or snapshots) so long as they do not edit repo-tracked files
|
|
25
|
+
|
|
26
|
+
### Not allowed (mutating, plan-executing)
|
|
27
|
+
|
|
28
|
+
Actions that implement the plan or change repo-tracked state. Examples:
|
|
29
|
+
|
|
30
|
+
* Editing or writing files
|
|
31
|
+
* Running formatters or linters that rewrite files
|
|
32
|
+
* Applying patches, migrations, or codegen that updates repo-tracked files
|
|
33
|
+
* Side-effectful commands whose purpose is to carry out the plan rather than refine it
|
|
34
|
+
|
|
35
|
+
When in doubt: if the action would reasonably be described as "doing the work" rather than "planning the work," do not do it.
|
|
36
|
+
|
|
37
|
+
## Research tracking
|
|
38
|
+
|
|
39
|
+
Track your discoveries, open questions, and resolved questions as you explore. Note \`file:line\` references for important findings so the final plan can anchor every change to a concrete location in the codebase. This prevents redundant exploration and makes the research trail transparent to the user.
|
|
40
|
+
|
|
41
|
+
## Powerful exploration tools
|
|
42
|
+
|
|
43
|
+
You have access to powerful tools for codebase exploration—use them liberally:
|
|
44
|
+
|
|
45
|
+
* **codebase-researcher subagent**: When you need thorough investigation of a feature, system, or component, launch the codebase-researcher subagent to perform deep exploration. Provide it with a detailed brief and it will comprehensively investigate the codebase, returning findings that you can synthesize into your plan.
|
|
46
|
+
|
|
47
|
+
For complex tasks, consider launching the codebase-researcher in parallel while you explore other areas using Grep and Glob, then synthesizing findings into your plan.
|
|
48
|
+
|
|
49
|
+
## PHASE 1 — Ground in the environment (explore first, ask second)
|
|
50
|
+
|
|
51
|
+
Begin by grounding yourself in the actual environment. Eliminate unknowns in the prompt by discovering facts, not by asking the user. Resolve all questions that can be answered through exploration or inspection. Identify missing or ambiguous details only if they cannot be derived from the environment. Silent exploration between turns is allowed and encouraged.
|
|
52
|
+
|
|
53
|
+
Before asking the user any question, perform at least one targeted non-mutating exploration pass (for example: search relevant files, inspect likely entrypoints/configs, confirm current implementation shape), unless no local environment/repo is available.
|
|
54
|
+
|
|
55
|
+
Exception: you may ask clarifying questions about the user's prompt before exploring, ONLY if there are obvious ambiguities or contradictions in the prompt itself. However, if ambiguity might be resolved by exploring, always prefer exploring first.
|
|
56
|
+
|
|
57
|
+
Do not ask questions that can be answered from the repo or system (for example, "where is this struct?" or "which UI component should we use?" when exploration can make it clear). Only ask once you have exhausted reasonable non-mutating exploration.
|
|
58
|
+
|
|
59
|
+
## PHASE 2 — Intent chat (what they actually want)
|
|
60
|
+
|
|
61
|
+
* Keep asking until you can clearly state: goal + success criteria, audience, in/out of scope, constraints, current state, and the key preferences/tradeoffs.
|
|
62
|
+
* Require an explicit **"Out of Scope"** statement — what we are NOT doing. This prevents scope creep and sets clear expectations.
|
|
63
|
+
* Be skeptical: actively challenge vague requirements, identify issues early, and verify assumptions against code rather than accepting them at face value.
|
|
64
|
+
* Bias toward questions over guessing: if any high-impact ambiguity remains, do NOT plan yet—ask.
|
|
65
|
+
|
|
66
|
+
## PHASE 3 — Implementation chat (what/how we’ll build)
|
|
67
|
+
|
|
68
|
+
* Once intent is stable, keep asking until the spec is decision complete: approach, interfaces (APIs/schemas/I/O), data flow, edge cases/failure modes, testing + acceptance criteria, rollout/monitoring, and any migrations/compat constraints.
|
|
69
|
+
* **Propose a plan outline first**: before writing the full detailed plan, present a high-level outline of implementation phases — each with a name and what it accomplishes. Get user feedback on structure before filling in details.
|
|
70
|
+
* **Migration, rollback, and backwards compatibility**: when applicable, give these dedicated attention. They are often the hardest parts of implementation and must not be an afterthought.
|
|
71
|
+
* **Common implementation sequencing** — use these as reference when ordering phases:
|
|
72
|
+
* Database changes: schema/migration → store methods → business logic → API → clients
|
|
73
|
+
* New features: research existing patterns → data model → backend logic → API endpoints → UI
|
|
74
|
+
* Refactoring: document current behavior → plan incremental changes → maintain backwards compatibility → migration strategy
|
|
75
|
+
|
|
76
|
+
## Asking questions
|
|
77
|
+
|
|
78
|
+
Critical rules:
|
|
79
|
+
|
|
80
|
+
* Offer meaningful multiple‑choice options when possible; don’t include filler choices that are obviously wrong or irrelevant.
|
|
81
|
+
|
|
82
|
+
You SHOULD ask many questions, but each question must:
|
|
83
|
+
|
|
84
|
+
* materially change the spec/plan, OR
|
|
85
|
+
* confirm/lock an assumption, OR
|
|
86
|
+
* choose between meaningful tradeoffs.
|
|
87
|
+
* not be answerable by non-mutating commands.
|
|
88
|
+
|
|
89
|
+
## Two kinds of unknowns (treat differently)
|
|
90
|
+
|
|
91
|
+
1. **Discoverable facts** (repo/system truth): explore first.
|
|
92
|
+
|
|
93
|
+
* Before asking, run targeted searches and check likely sources of truth (configs/manifests/entrypoints/schemas/types/constants).
|
|
94
|
+
* Ask only if: multiple plausible candidates; nothing found but you need a missing identifier/context; or ambiguity is actually product intent.
|
|
95
|
+
* If asking, present concrete candidates (paths/service names) + recommend one.
|
|
96
|
+
* Never ask questions you can answer from your environment (e.g., “where is this struct”).
|
|
97
|
+
|
|
98
|
+
2. **Preferences/tradeoffs** (not discoverable): ask early.
|
|
99
|
+
|
|
100
|
+
* These are intent or implementation preferences that cannot be derived from exploration.
|
|
101
|
+
* Provide 2–4 mutually exclusive options + a recommended default.
|
|
102
|
+
* If unanswered, proceed with the recommended option and record it as an assumption in the final plan.
|
|
103
|
+
|
|
104
|
+
## Finalization rule
|
|
105
|
+
|
|
106
|
+
Only output the final plan when it is decision complete and leaves no decisions to the implementer.
|
|
107
|
+
|
|
108
|
+
When you present the official plan, wrap it in a \`<proposed_plan>\` block so the client can render it specially:
|
|
109
|
+
|
|
110
|
+
1) The opening tag must be on its own line.
|
|
111
|
+
2) Start the plan content on the next line (no text on the same line as the tag).
|
|
112
|
+
3) The closing tag must be on its own line.
|
|
113
|
+
4) Use Markdown inside the block.
|
|
114
|
+
5) Keep the tags exactly as \`<proposed_plan>\` and \`</proposed_plan>\` (do not translate or rename them), even if the plan content is in another language.
|
|
115
|
+
|
|
116
|
+
Example:
|
|
117
|
+
|
|
118
|
+
<proposed_plan>
|
|
119
|
+
plan content
|
|
120
|
+
</proposed_plan>
|
|
121
|
+
|
|
122
|
+
plan content should be human and agent digestible. The final plan must be plan-only and include:
|
|
123
|
+
|
|
124
|
+
* A clear title
|
|
125
|
+
* A brief summary section
|
|
126
|
+
* Important changes or additions to public APIs/interfaces/types
|
|
127
|
+
* Specific \`file:line\` references for all code locations the plan touches
|
|
128
|
+
* An explicit **"Out of Scope"** section
|
|
129
|
+
* **Success criteria** separated into two categories:
|
|
130
|
+
* **Automated verification** — commands that can be run (test, lint, typecheck, build) and specific files/code that should exist or compile
|
|
131
|
+
* **Manual verification** — UI/UX functionality, performance under real conditions, hard-to-automate edge cases, user acceptance criteria
|
|
132
|
+
* Migration/rollback strategy when applicable
|
|
133
|
+
* Explicit assumptions and defaults chosen where needed
|
|
134
|
+
|
|
135
|
+
Do not ask "should I proceed?" in the final output. The user can easily switch out of Plan mode and request implementation if you have included a \`<proposed_plan>\` block in your response. Alternatively, they can decide to stay in Plan mode and continue refining the plan.
|
|
136
|
+
|
|
137
|
+
Only produce at most one \`<proposed_plan>\` block per turn, and only when you are presenting a complete spec.
|
|
138
|
+
|
|
139
|
+
## Plan acceptance
|
|
140
|
+
|
|
141
|
+
After presenting a \`<proposed_plan>\` block, explicitly ask the user if they accept the plan. If they accept (e.g., they say "yes", "accept", "go ahead", or similar confirmation), write the plan content to \`plan.md\` in the current working directory using the Write tool. After writing, acknowledge the plan has been saved and ask if they'd like to proceed with implementation or continue refining.
|
|
142
|
+
`;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { ModelMetadata } from "../models/providers.ts";
|
|
2
|
+
import type { ContextItem } from "./manager.ts";
|
|
3
|
+
export declare function processPrompt(message: string, { baseDir, model, pasteStore, }: {
|
|
4
|
+
baseDir: string;
|
|
5
|
+
model: ModelMetadata;
|
|
6
|
+
pasteStore?: Map<number, string>;
|
|
7
|
+
}): Promise<{
|
|
8
|
+
message: string;
|
|
9
|
+
context: ContextItem[];
|
|
10
|
+
}>;
|
|
11
|
+
//# sourceMappingURL=mentions.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mentions.d.ts","sourceRoot":"","sources":["../../source/prompts/mentions.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,wBAAwB,CAAC;AAG5D,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAwGhD,wBAAsB,aAAa,CACjC,OAAO,EAAE,MAAM,EACf,EACE,OAAO,EACP,KAAK,EACL,UAAU,GACX,EAAE;IACD,OAAO,EAAE,MAAM,CAAC;IAChB,KAAK,EAAE,aAAa,CAAC;IACrB,UAAU,CAAC,EAAE,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;CAClC,GACA,OAAO,CAAC;IAAE,OAAO,EAAE,MAAM,CAAC;IAAC,OAAO,EAAE,WAAW,EAAE,CAAA;CAAE,CAAC,CAwFtD"}
|
|
@@ -1,48 +1,31 @@
|
|
|
1
1
|
import fs from "node:fs/promises";
|
|
2
2
|
import path from "node:path";
|
|
3
|
-
import {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
this.name = "ShellCommandError";
|
|
12
|
-
this.command = command;
|
|
13
|
-
this.exitCode = exitCode;
|
|
14
|
-
this.output = output;
|
|
3
|
+
import { formatFile } from "../utils/formatting.js";
|
|
4
|
+
async function readFileEntry(fullPath, relativeFilePath, format) {
|
|
5
|
+
try {
|
|
6
|
+
const fileContents = await fs.readFile(fullPath, "utf8");
|
|
7
|
+
return formatFile(relativeFilePath, fileContents, format);
|
|
8
|
+
}
|
|
9
|
+
catch (error) {
|
|
10
|
+
return `Error reading file ${relativeFilePath}: ${error instanceof Error ? error.message : "Unknown error"}`;
|
|
15
11
|
}
|
|
16
12
|
}
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
13
|
+
async function collectFiles(currentPath, format, allContents, relativePath = "") {
|
|
14
|
+
const entries = await fs.readdir(currentPath, { withFileTypes: true });
|
|
15
|
+
for (const entry of entries) {
|
|
16
|
+
const fullPath = path.join(currentPath, entry.name);
|
|
17
|
+
const relativeFilePath = path.join(relativePath, entry.name);
|
|
18
|
+
if (entry.isDirectory()) {
|
|
19
|
+
await collectFiles(fullPath, format, allContents, relativeFilePath);
|
|
20
|
+
}
|
|
21
|
+
else if (entry.isFile()) {
|
|
22
|
+
allContents.push(await readFileEntry(fullPath, relativeFilePath, format));
|
|
23
|
+
}
|
|
21
24
|
}
|
|
22
25
|
}
|
|
23
|
-
// Helper function to recursively read all files in a directory
|
|
24
26
|
async function readDirectoryRecursive(dirPath, format) {
|
|
25
27
|
const allContents = [];
|
|
26
|
-
|
|
27
|
-
const entries = await fs.readdir(currentPath, { withFileTypes: true });
|
|
28
|
-
for (const entry of entries) {
|
|
29
|
-
const fullPath = path.join(currentPath, entry.name);
|
|
30
|
-
const relativeFilePath = path.join(relativePath, entry.name);
|
|
31
|
-
if (entry.isDirectory()) {
|
|
32
|
-
await readDir(fullPath, relativeFilePath);
|
|
33
|
-
}
|
|
34
|
-
else if (entry.isFile()) {
|
|
35
|
-
try {
|
|
36
|
-
const fileContents = await fs.readFile(fullPath, "utf8");
|
|
37
|
-
allContents.push(formatFile(relativeFilePath, fileContents, format));
|
|
38
|
-
}
|
|
39
|
-
catch (error) {
|
|
40
|
-
allContents.push(`Error reading file ${relativeFilePath}: ${error instanceof Error ? error.message : "Unknown error"}`);
|
|
41
|
-
}
|
|
42
|
-
}
|
|
43
|
-
}
|
|
44
|
-
}
|
|
45
|
-
await readDir(dirPath);
|
|
28
|
+
await collectFiles(dirPath, format, allContents);
|
|
46
29
|
if (allContents.length === 0) {
|
|
47
30
|
return `Directory ${path.basename(dirPath)} is empty or contains no readable files.`;
|
|
48
31
|
}
|
|
@@ -91,45 +74,32 @@ async function processFileCommand(context) {
|
|
|
91
74
|
return `Error accessing ${filePath}: An unknown error occurred.`;
|
|
92
75
|
}
|
|
93
76
|
}
|
|
94
|
-
async function processShellCommand(command) {
|
|
95
|
-
try {
|
|
96
|
-
const execEnv = await initExecutionEnvironment();
|
|
97
|
-
const { output, exitCode } = await execEnv.executeCommand(command, {
|
|
98
|
-
throwOnError: true,
|
|
99
|
-
});
|
|
100
|
-
if (exitCode === 0) {
|
|
101
|
-
return output;
|
|
102
|
-
}
|
|
103
|
-
throw new ShellCommandError(`Command failed with exit code ${exitCode}`, command, exitCode, output);
|
|
104
|
-
}
|
|
105
|
-
catch (error) {
|
|
106
|
-
if (error instanceof ShellCommandError) {
|
|
107
|
-
throw error;
|
|
108
|
-
}
|
|
109
|
-
if (error instanceof Error) {
|
|
110
|
-
throw new ShellCommandError(`Command execution failed: ${error.message}`, command, undefined, undefined);
|
|
111
|
-
}
|
|
112
|
-
throw new ShellCommandError("Command execution failed with unknown error", command, undefined, undefined);
|
|
113
|
-
}
|
|
114
|
-
}
|
|
115
|
-
// Returns the formatted string or an error message string
|
|
116
77
|
export async function processPrompt(message, { baseDir, model, pasteStore, }) {
|
|
117
|
-
|
|
118
|
-
|
|
78
|
+
// Regex matches # followed by a file path:
|
|
79
|
+
// - Can start with . (relative paths like ./file or .hidden)
|
|
80
|
+
// - Can start with / (absolute paths)
|
|
81
|
+
// - Can start with ~ (home directory)
|
|
82
|
+
// - Can start with alphanumeric/underscore (simple filenames)
|
|
83
|
+
// - Path continues with non-whitespace, non-# characters
|
|
84
|
+
// - Does NOT match # followed by just digits (paste placeholder format like [Paste #1])
|
|
85
|
+
// - Does NOT match # followed by digits and dots (version numbers like #1.2.3)
|
|
86
|
+
// - Does NOT match issue references like #123
|
|
87
|
+
const fileRegex = /(?<![a-zA-Z0-9_-])#(?![\d.]+(?:[\s,\]]|$))([./~]?[a-zA-Z0-9_][a-zA-Z0-9_./~-]*|[./~][a-zA-Z0-9_./~-]+)/g;
|
|
119
88
|
// Collect all matches for files
|
|
120
89
|
const fileMatches = Array.from(message.matchAll(fileRegex));
|
|
121
|
-
const shellMatches = Array.from(message.matchAll(shellRegex));
|
|
122
90
|
const mentionProcessingPromises = [];
|
|
91
|
+
const matchStrings = [];
|
|
123
92
|
// Process file references - collect promises
|
|
124
93
|
for (const match of fileMatches) {
|
|
125
|
-
const
|
|
126
|
-
if (
|
|
94
|
+
const filePath = match[1];
|
|
95
|
+
if (filePath) {
|
|
127
96
|
const context = {
|
|
128
97
|
model,
|
|
129
98
|
baseDir,
|
|
130
|
-
match:
|
|
99
|
+
match: filePath,
|
|
131
100
|
};
|
|
132
101
|
mentionProcessingPromises.push(processFileCommand(context));
|
|
102
|
+
matchStrings.push(match[0]); // Store the full match including #
|
|
133
103
|
}
|
|
134
104
|
}
|
|
135
105
|
let processedMessage = message;
|
|
@@ -148,30 +118,30 @@ export async function processPrompt(message, { baseDir, model, pasteStore, }) {
|
|
|
148
118
|
match = pasteRegex.exec(processedMessage);
|
|
149
119
|
}
|
|
150
120
|
}
|
|
151
|
-
// Process shell commands
|
|
152
|
-
for (const match of shellMatches) {
|
|
153
|
-
const command = match[1];
|
|
154
|
-
if (command) {
|
|
155
|
-
try {
|
|
156
|
-
const output = await processShellCommand(command);
|
|
157
|
-
processedMessage = processedMessage.replace(match[0], output);
|
|
158
|
-
}
|
|
159
|
-
catch (error) {
|
|
160
|
-
if (error instanceof ShellCommandError) {
|
|
161
|
-
// Wrap shell command errors in PromptError
|
|
162
|
-
throw new PromptError(`Shell command failed: ${error.message}`, error);
|
|
163
|
-
}
|
|
164
|
-
// For other errors, wrap them in PromptError
|
|
165
|
-
throw new PromptError(`Unexpected error executing command: ${error instanceof Error ? error.message : "Unknown error"}`, error instanceof Error ? error : undefined);
|
|
166
|
-
}
|
|
167
|
-
}
|
|
168
|
-
}
|
|
169
121
|
// Wait for all mentions to be processed
|
|
170
122
|
const mentionResults = await Promise.all(mentionProcessingPromises);
|
|
171
123
|
const context = [];
|
|
172
|
-
|
|
173
|
-
|
|
124
|
+
// Remove file references from message and add contents to context
|
|
125
|
+
for (let i = 0; i < mentionResults.length; i++) {
|
|
126
|
+
const fileContent = mentionResults[i];
|
|
127
|
+
const matchString = matchStrings[i];
|
|
128
|
+
// Add file content to context
|
|
129
|
+
context.push(fileContent);
|
|
130
|
+
// Remove the #filepath reference from the message
|
|
131
|
+
processedMessage = processedMessage.replace(matchString, "");
|
|
174
132
|
}
|
|
133
|
+
// Clean up multiple spaces left by removals, but preserve newlines
|
|
134
|
+
// First, normalize line endings to \n
|
|
135
|
+
processedMessage = processedMessage
|
|
136
|
+
.replace(/\r\n/g, "\n")
|
|
137
|
+
.replace(/\r/g, "\n");
|
|
138
|
+
// Replace multiple spaces with a single space (but not newlines)
|
|
139
|
+
processedMessage = processedMessage.replace(/[ \t]+/g, " ");
|
|
140
|
+
// Trim whitespace from each line while preserving empty lines
|
|
141
|
+
processedMessage = processedMessage
|
|
142
|
+
.split("\n")
|
|
143
|
+
.map((line) => line.trim())
|
|
144
|
+
.join("\n");
|
|
175
145
|
return {
|
|
176
146
|
message: processedMessage,
|
|
177
147
|
context,
|
|
@@ -1,16 +1,21 @@
|
|
|
1
|
-
import type { CompleteToolNames } from "
|
|
1
|
+
import type { CompleteToolNames } from "../tools/index.ts";
|
|
2
2
|
type SystemPromptComponents = {
|
|
3
3
|
core: string;
|
|
4
4
|
userAgentsMd: string;
|
|
5
5
|
cwdAgentsMd: string;
|
|
6
6
|
learnedRules: string;
|
|
7
7
|
skills: string;
|
|
8
|
+
subagents: string;
|
|
8
9
|
};
|
|
10
|
+
export declare function environmentInfo(currentWorkingDir: string, allowedDirs: string[], logsPath?: string): Promise<string>;
|
|
9
11
|
type SystemPromptOptions = {
|
|
12
|
+
currentWorkingDir?: string;
|
|
10
13
|
allowedDirs?: string[];
|
|
14
|
+
logsPath?: string;
|
|
11
15
|
activeTools?: CompleteToolNames[];
|
|
12
16
|
includeRules?: boolean;
|
|
13
17
|
skillsEnabled?: boolean;
|
|
18
|
+
minimalPrompt?: boolean;
|
|
14
19
|
};
|
|
15
20
|
type SystemPromptResult = {
|
|
16
21
|
prompt: string;
|
|
@@ -18,4 +23,4 @@ type SystemPromptResult = {
|
|
|
18
23
|
};
|
|
19
24
|
export declare function systemPrompt(options?: SystemPromptOptions): Promise<SystemPromptResult>;
|
|
20
25
|
export {};
|
|
21
|
-
//# sourceMappingURL=
|
|
26
|
+
//# sourceMappingURL=system-prompt.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"system-prompt.d.ts","sourceRoot":"","sources":["../../source/prompts/system-prompt.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,mBAAmB,CAAC;AAI3D,KAAK,sBAAsB,GAAG;IAC5B,IAAI,EAAE,MAAM,CAAC;IACb,YAAY,EAAE,MAAM,CAAC;IACrB,WAAW,EAAE,MAAM,CAAC;IACpB,YAAY,EAAE,MAAM,CAAC;IACrB,MAAM,EAAE,MAAM,CAAC;IACf,SAAS,EAAE,MAAM,CAAC;CACnB,CAAC;AAsCF,wBAAsB,eAAe,CACnC,iBAAiB,EAAE,MAAM,EACzB,WAAW,EAAE,MAAM,EAAE,EACrB,QAAQ,CAAC,EAAE,MAAM,mBA+BlB;AAED,KAAK,mBAAmB,GAAG;IACzB,iBAAiB,CAAC,EAAE,MAAM,CAAC;IAC3B,WAAW,CAAC,EAAE,MAAM,EAAE,CAAC;IACvB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,WAAW,CAAC,EAAE,iBAAiB,EAAE,CAAC;IAClC,YAAY,CAAC,EAAE,OAAO,CAAC;IACvB,aAAa,CAAC,EAAE,OAAO,CAAC;IACxB,aAAa,CAAC,EAAE,OAAO,CAAC;CACzB,CAAC;AAEF,KAAK,kBAAkB,GAAG;IACxB,MAAM,EAAE,MAAM,CAAC;IACf,UAAU,EAAE,sBAAsB,CAAC;CACpC,CAAC;AAKF,wBAAsB,YAAY,CAChC,OAAO,CAAC,EAAE,mBAAmB,GAC5B,OAAO,CAAC,kBAAkB,CAAC,CAyK7B"}
|
|
@@ -1,16 +1,17 @@
|
|
|
1
1
|
import { platform } from "node:os";
|
|
2
|
-
import { config } from "
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import { getShell } from "
|
|
6
|
-
import {
|
|
2
|
+
import { config } from "../config/index.js";
|
|
3
|
+
import { formatSkillsForPrompt, loadSkills } from "../skills/index.js";
|
|
4
|
+
import { formatSubagentsForPrompt, loadSubagents } from "../subagents/index.js";
|
|
5
|
+
import { getShell } from "../terminal/index.js";
|
|
6
|
+
import { dedent } from "../utils/dedent.js";
|
|
7
|
+
import { getCurrentBranch, inGitDirectory } from "../utils/git.js";
|
|
7
8
|
async function getProjectContext() {
|
|
8
9
|
const agentsFiles = await config.readAgentsFiles();
|
|
9
10
|
const userAgentsFile = agentsFiles.find((f) => f.path === "~/.acai/AGENTS.md");
|
|
10
11
|
const cwdAgentsFile = agentsFiles.find((f) => f.path === "./AGENTS.md");
|
|
11
12
|
const userRules = (userAgentsFile?.content ?? "").trim();
|
|
12
13
|
const cwdRules = (cwdAgentsFile?.content ?? "").trim();
|
|
13
|
-
const learnedRules = (await config.
|
|
14
|
+
const learnedRules = (await config.readLearnedRulesFile()).trim();
|
|
14
15
|
let result = "";
|
|
15
16
|
if (userRules || cwdRules) {
|
|
16
17
|
result += "## Project Context:\n\n";
|
|
@@ -34,17 +35,26 @@ async function getProjectContext() {
|
|
|
34
35
|
learnedRules: learnedRules,
|
|
35
36
|
};
|
|
36
37
|
}
|
|
37
|
-
async function environmentInfo(allowedDirs) {
|
|
38
|
+
export async function environmentInfo(currentWorkingDir, allowedDirs, logsPath) {
|
|
38
39
|
const gitDirectory = await inGitDirectory();
|
|
39
40
|
let gitSection = `- **Is directory a git repo**: ${gitDirectory ? "Yes" : "No"}`;
|
|
40
41
|
if (gitDirectory) {
|
|
41
42
|
gitSection += `\n- **Current git branch**: ${await getCurrentBranch()}`;
|
|
42
43
|
}
|
|
44
|
+
let logsSection = "";
|
|
45
|
+
if (logsPath) {
|
|
46
|
+
logsSection = `
|
|
47
|
+
### Project logs:
|
|
48
|
+
|
|
49
|
+
- ${logsPath}`;
|
|
50
|
+
}
|
|
43
51
|
return `## Environment
|
|
52
|
+
### Current working directory:
|
|
53
|
+
${currentWorkingDir}
|
|
44
54
|
|
|
45
55
|
### Allowed directories:
|
|
46
56
|
|
|
47
|
-
${allowedDirs.map((dir) => `- ${dir}`).join("\n")}
|
|
57
|
+
${allowedDirs.map((dir) => `- ${dir}`).join("\n")}${logsSection}
|
|
48
58
|
|
|
49
59
|
### Information:
|
|
50
60
|
|
|
@@ -52,23 +62,27 @@ ${gitSection}
|
|
|
52
62
|
- **Platform**: ${platform()}
|
|
53
63
|
- **Shell**: ${getShell()}
|
|
54
64
|
- **Today's date**: ${new Date().toISOString().split("T")[0]}
|
|
55
|
-
|
|
56
|
-
- Note: The .tmp directory in the current working directory is deleted each time the agent shuts down.`;
|
|
65
|
+
`;
|
|
57
66
|
}
|
|
58
|
-
const
|
|
67
|
+
const DEFAULT_WORKING_DIRS = process.cwd();
|
|
68
|
+
const DEFAULT_ALLOWED_DIR = [process.cwd()];
|
|
59
69
|
export async function systemPrompt(options) {
|
|
60
|
-
const { allowedDirs =
|
|
70
|
+
const { currentWorkingDir = DEFAULT_WORKING_DIRS, allowedDirs = DEFAULT_ALLOWED_DIR, logsPath, includeRules = true, skillsEnabled = true, minimalPrompt = true, } = options ?? {};
|
|
61
71
|
const projectContextResult = includeRules
|
|
62
72
|
? await getProjectContext()
|
|
63
73
|
: { text: "", userAgentsMd: "", cwdAgentsMd: "", learnedRules: "" };
|
|
64
74
|
const projectContextText = projectContextResult.text;
|
|
65
|
-
const environmentInfoText = await environmentInfo(allowedDirs);
|
|
75
|
+
const environmentInfoText = await environmentInfo(currentWorkingDir, allowedDirs, logsPath);
|
|
66
76
|
let skillsText = "";
|
|
67
77
|
if (skillsEnabled) {
|
|
68
78
|
const skills = await loadSkills();
|
|
69
|
-
skillsText = formatSkillsForPrompt(skills);
|
|
79
|
+
skillsText = formatSkillsForPrompt(skills.getModelInvocable());
|
|
70
80
|
}
|
|
71
|
-
const
|
|
81
|
+
const subagents = await loadSubagents();
|
|
82
|
+
const subagentsText = formatSubagentsForPrompt(subagents);
|
|
83
|
+
const corePrompt = minimalPrompt
|
|
84
|
+
? "You are acai. You are running as a coding agent in a CLI on the user's computer."
|
|
85
|
+
: dedent `
|
|
72
86
|
You are acai. You are running as a coding agent in a CLI on the user's computer.
|
|
73
87
|
|
|
74
88
|
## Core Principles
|
|
@@ -199,8 +213,9 @@ DEFAULT TO PARALLEL: Unless you have a specific reason why operations MUST be se
|
|
|
199
213
|
cwdAgentsMd: projectContextResult.cwdAgentsMd,
|
|
200
214
|
learnedRules: projectContextResult.learnedRules,
|
|
201
215
|
skills: skillsText,
|
|
216
|
+
subagents: subagentsText,
|
|
202
217
|
};
|
|
203
|
-
const assembledPrompt = `${corePrompt}\n${projectContextText}\n\n${environmentInfoText}${skillsText}`;
|
|
218
|
+
const assembledPrompt = `${corePrompt}\n${projectContextText}\n\n${environmentInfoText}${skillsText}\n\n${subagentsText}`;
|
|
204
219
|
const result = { prompt: assembledPrompt, components };
|
|
205
220
|
return result;
|
|
206
221
|
}
|