@travisennis/acai 0.0.5 → 0.0.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +190 -19
- package/bin/acai-wrapper.js +26 -0
- package/dist/agent/index.d.ts +132 -0
- package/dist/agent/index.d.ts.map +1 -0
- package/dist/agent/index.js +434 -0
- package/dist/api/exa/index.js +1 -1
- package/dist/cli.d.ts +4 -1
- package/dist/cli.d.ts.map +1 -1
- package/dist/cli.js +67 -40
- package/dist/commands/add-directory-command.d.ts +3 -0
- package/dist/commands/add-directory-command.d.ts.map +1 -0
- package/dist/commands/add-directory-command.js +54 -0
- package/dist/commands/application-log-command.d.ts +1 -1
- package/dist/commands/application-log-command.d.ts.map +1 -1
- package/dist/commands/application-log-command.js +18 -20
- package/dist/commands/clear-command.d.ts +1 -1
- package/dist/commands/clear-command.d.ts.map +1 -1
- package/dist/commands/clear-command.js +7 -3
- package/dist/commands/compact-command.d.ts.map +1 -1
- package/dist/commands/compact-command.js +9 -5
- package/dist/commands/context-command.d.ts +3 -0
- package/dist/commands/context-command.d.ts.map +1 -0
- package/dist/commands/context-command.js +124 -0
- package/dist/commands/copy-command.d.ts.map +1 -1
- package/dist/commands/copy-command.js +14 -5
- package/dist/commands/edit-command.d.ts +1 -1
- package/dist/commands/edit-command.d.ts.map +1 -1
- package/dist/commands/edit-command.js +21 -34
- package/dist/commands/edit-prompt-command.d.ts +1 -1
- package/dist/commands/edit-prompt-command.d.ts.map +1 -1
- package/dist/commands/edit-prompt-command.js +18 -15
- package/dist/commands/exit-command.d.ts +1 -4
- package/dist/commands/exit-command.d.ts.map +1 -1
- package/dist/commands/exit-command.js +9 -5
- package/dist/commands/files-command.d.ts +1 -1
- package/dist/commands/files-command.d.ts.map +1 -1
- package/dist/commands/files-command.js +20 -16
- package/dist/commands/generate-rules-command.d.ts +1 -1
- package/dist/commands/generate-rules-command.d.ts.map +1 -1
- package/dist/commands/generate-rules-command.js +307 -39
- package/dist/commands/handoff-command.d.ts +3 -0
- package/dist/commands/handoff-command.d.ts.map +1 -0
- package/dist/commands/handoff-command.js +191 -0
- package/dist/commands/health-command.d.ts +1 -1
- package/dist/commands/health-command.d.ts.map +1 -1
- package/dist/commands/health-command.js +49 -27
- package/dist/commands/help-command.d.ts +1 -1
- package/dist/commands/help-command.d.ts.map +1 -1
- package/dist/commands/help-command.js +25 -5
- package/dist/commands/history-command.d.ts +3 -0
- package/dist/commands/history-command.d.ts.map +1 -0
- package/dist/commands/history-command.js +458 -0
- package/dist/commands/init-command.d.ts +1 -1
- package/dist/commands/init-command.d.ts.map +1 -1
- package/dist/commands/init-command.js +40 -22
- package/dist/commands/last-log-command.d.ts +1 -1
- package/dist/commands/last-log-command.d.ts.map +1 -1
- package/dist/commands/last-log-command.js +15 -15
- package/dist/commands/list-directories-command.d.ts +3 -0
- package/dist/commands/list-directories-command.d.ts.map +1 -0
- package/dist/commands/list-directories-command.js +35 -0
- package/dist/commands/list-tools-command.d.ts.map +1 -1
- package/dist/commands/list-tools-command.js +61 -21
- package/dist/commands/manager.d.ts +9 -4
- package/dist/commands/manager.d.ts.map +1 -1
- package/dist/commands/manager.js +64 -39
- package/dist/commands/model-command.d.ts.map +1 -1
- package/dist/commands/model-command.js +201 -66
- package/dist/commands/paste-command.d.ts +1 -1
- package/dist/commands/paste-command.d.ts.map +1 -1
- package/dist/commands/paste-command.js +23 -9
- package/dist/commands/pickup-command.d.ts +3 -0
- package/dist/commands/pickup-command.d.ts.map +1 -0
- package/dist/commands/pickup-command.js +109 -0
- package/dist/commands/prompt-command.d.ts +19 -1
- package/dist/commands/prompt-command.d.ts.map +1 -1
- package/dist/commands/prompt-command.js +191 -98
- package/dist/commands/remove-directory-command.d.ts +3 -0
- package/dist/commands/remove-directory-command.d.ts.map +1 -0
- package/dist/commands/remove-directory-command.js +55 -0
- package/dist/commands/reset-command.d.ts +1 -1
- package/dist/commands/reset-command.d.ts.map +1 -1
- package/dist/commands/reset-command.js +8 -5
- package/dist/commands/rules-command.d.ts +1 -1
- package/dist/commands/rules-command.d.ts.map +1 -1
- package/dist/commands/rules-command.js +25 -22
- package/dist/commands/save-command.d.ts +1 -1
- package/dist/commands/save-command.d.ts.map +1 -1
- package/dist/commands/save-command.js +8 -3
- package/dist/commands/shell-command.d.ts.map +1 -1
- package/dist/commands/shell-command.js +45 -24
- package/dist/commands/types.d.ts +9 -7
- package/dist/commands/types.d.ts.map +1 -1
- package/dist/commands/usage-command.d.ts +1 -1
- package/dist/commands/usage-command.d.ts.map +1 -1
- package/dist/commands/usage-command.js +18 -7
- package/dist/config.d.ts +21 -11
- package/dist/config.d.ts.map +1 -1
- package/dist/config.js +90 -63
- package/dist/execution/index.d.ts +17 -2
- package/dist/execution/index.d.ts.map +1 -1
- package/dist/execution/index.js +62 -20
- package/dist/formatting.d.ts +127 -0
- package/dist/formatting.d.ts.map +1 -1
- package/dist/formatting.js +201 -0
- package/dist/index.d.ts +7 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +263 -102
- package/dist/logger.d.ts.map +1 -1
- package/dist/logger.js +47 -18
- package/dist/mentions.d.ts +2 -1
- package/dist/mentions.d.ts.map +1 -1
- package/dist/mentions.js +16 -1
- package/dist/messages.d.ts +11 -0
- package/dist/messages.d.ts.map +1 -1
- package/dist/messages.js +122 -21
- package/dist/middleware/cache.d.ts +3 -0
- package/dist/middleware/cache.d.ts.map +1 -0
- package/dist/middleware/cache.js +53 -0
- package/dist/middleware/index.d.ts +1 -0
- package/dist/middleware/index.d.ts.map +1 -1
- package/dist/middleware/index.js +1 -0
- package/dist/models/ai-config.d.ts +4 -2
- package/dist/models/ai-config.d.ts.map +1 -1
- package/dist/models/ai-config.js +12 -2
- package/dist/models/anthropic-provider.d.ts.map +1 -1
- package/dist/models/anthropic-provider.js +3 -67
- package/dist/models/deepseek-provider.d.ts.map +1 -1
- package/dist/models/deepseek-provider.js +0 -2
- package/dist/models/google-provider.d.ts.map +1 -1
- package/dist/models/google-provider.js +0 -3
- package/dist/models/groq-provider.d.ts.map +1 -1
- package/dist/models/groq-provider.js +0 -1
- package/dist/models/manager.d.ts +2 -1
- package/dist/models/manager.d.ts.map +1 -1
- package/dist/models/manager.js +26 -2
- package/dist/models/openai-provider.d.ts.map +1 -1
- package/dist/models/openai-provider.js +0 -4
- package/dist/models/openrouter-provider.d.ts +16 -22
- package/dist/models/openrouter-provider.d.ts.map +1 -1
- package/dist/models/openrouter-provider.js +175 -236
- package/dist/models/providers.d.ts +4 -14
- package/dist/models/providers.d.ts.map +1 -1
- package/dist/models/providers.js +1 -57
- package/dist/models/xai-provider.d.ts.map +1 -1
- package/dist/models/xai-provider.js +0 -2
- package/dist/prompts.d.ts +10 -4
- package/dist/prompts.d.ts.map +1 -1
- package/dist/prompts.js +447 -70
- package/dist/repl/project-status-line.d.ts +3 -0
- package/dist/repl/project-status-line.d.ts.map +1 -0
- package/dist/repl/project-status-line.js +61 -0
- package/dist/repl/tool-call-repair.d.ts.map +1 -1
- package/dist/repl/tool-call-repair.js +8 -4
- package/dist/repl-new.d.ts +51 -0
- package/dist/repl-new.d.ts.map +1 -0
- package/dist/repl-new.js +354 -0
- package/dist/skills.d.ts +20 -0
- package/dist/skills.d.ts.map +1 -0
- package/dist/skills.js +192 -0
- package/dist/terminal/control.d.ts +55 -0
- package/dist/terminal/control.d.ts.map +1 -0
- package/dist/terminal/control.js +109 -0
- package/dist/terminal/default-theme.d.ts +1 -1
- package/dist/terminal/default-theme.d.ts.map +1 -1
- package/dist/terminal/default-theme.js +24 -28
- package/dist/terminal/formatting.d.ts +23 -25
- package/dist/terminal/formatting.d.ts.map +1 -1
- package/dist/terminal/formatting.js +35 -52
- package/dist/terminal/highlight/index.d.ts.map +1 -1
- package/dist/terminal/highlight/index.js +3 -6
- package/dist/terminal/highlight/theme.d.ts.map +1 -1
- package/dist/terminal/highlight/theme.js +2 -6
- package/dist/terminal/index.d.ts +2 -94
- package/dist/terminal/index.d.ts.map +1 -1
- package/dist/terminal/index.js +2 -370
- package/dist/terminal/markdown.js +10 -5
- package/dist/terminal/select-prompt.d.ts +2 -2
- package/dist/terminal/select-prompt.d.ts.map +1 -1
- package/dist/terminal/select-prompt.js +47 -39
- package/dist/terminal/strip-ansi.js +4 -4
- package/dist/terminal/table/cell.d.ts +114 -0
- package/dist/terminal/table/cell.d.ts.map +1 -0
- package/dist/terminal/table/cell.js +407 -0
- package/dist/terminal/table/debug.d.ts +15 -0
- package/dist/terminal/table/debug.d.ts.map +1 -0
- package/dist/terminal/table/debug.js +32 -0
- package/dist/terminal/table/index.d.ts +3 -0
- package/dist/terminal/table/index.d.ts.map +1 -0
- package/dist/terminal/table/index.js +2 -0
- package/dist/terminal/table/layout-manager.d.ts +27 -0
- package/dist/terminal/table/layout-manager.d.ts.map +1 -0
- package/dist/terminal/table/layout-manager.js +257 -0
- package/dist/terminal/table/table.d.ts +9 -0
- package/dist/terminal/table/table.d.ts.map +1 -0
- package/dist/terminal/table/table.js +97 -0
- package/dist/terminal/table/utils.d.ts +63 -0
- package/dist/terminal/table/utils.d.ts.map +1 -0
- package/dist/terminal/table/utils.js +326 -0
- package/dist/tokens/threshold.d.ts +20 -0
- package/dist/tokens/threshold.d.ts.map +1 -0
- package/dist/tokens/threshold.js +67 -0
- package/dist/tools/advanced-edit-file.d.ts +69 -0
- package/dist/tools/advanced-edit-file.d.ts.map +1 -0
- package/dist/tools/advanced-edit-file.js +285 -0
- package/dist/tools/agent.d.ts +16 -5
- package/dist/tools/agent.d.ts.map +1 -1
- package/dist/tools/agent.js +86 -59
- package/dist/tools/bash.d.ts +23 -12
- package/dist/tools/bash.d.ts.map +1 -1
- package/dist/tools/bash.js +243 -128
- package/dist/tools/batch.d.ts +34 -0
- package/dist/tools/batch.d.ts.map +1 -0
- package/dist/tools/batch.js +174 -0
- package/dist/tools/code-interpreter.d.ts +21 -9
- package/dist/tools/code-interpreter.d.ts.map +1 -1
- package/dist/tools/code-interpreter.js +151 -134
- package/dist/tools/delete-file.d.ts +17 -10
- package/dist/tools/delete-file.d.ts.map +1 -1
- package/dist/tools/delete-file.js +60 -97
- package/dist/tools/directory-tree.d.ts +17 -12
- package/dist/tools/directory-tree.d.ts.map +1 -1
- package/dist/tools/directory-tree.js +57 -48
- package/dist/tools/dynamic-tool-loader.d.ts +16 -10
- package/dist/tools/dynamic-tool-loader.d.ts.map +1 -1
- package/dist/tools/dynamic-tool-loader.js +122 -130
- package/dist/tools/dynamic-tool-parser.d.ts +1 -0
- package/dist/tools/dynamic-tool-parser.d.ts.map +1 -1
- package/dist/tools/dynamic-tool-parser.js +1 -0
- package/dist/tools/edit-file.d.ts +35 -15
- package/dist/tools/edit-file.d.ts.map +1 -1
- package/dist/tools/edit-file.js +127 -114
- package/dist/tools/glob.d.ts +36 -0
- package/dist/tools/glob.d.ts.map +1 -0
- package/dist/tools/glob.js +154 -0
- package/dist/tools/grep.d.ts +73 -12
- package/dist/tools/grep.d.ts.map +1 -1
- package/dist/tools/grep.js +425 -165
- package/dist/tools/index.d.ts +220 -126
- package/dist/tools/index.d.ts.map +1 -1
- package/dist/tools/index.js +284 -135
- package/dist/tools/llm-edit-fixer.d.ts +24 -0
- package/dist/tools/llm-edit-fixer.d.ts.map +1 -0
- package/dist/tools/llm-edit-fixer.js +136 -0
- package/dist/tools/move-file.d.ts +19 -7
- package/dist/tools/move-file.d.ts.map +1 -1
- package/dist/tools/move-file.js +48 -34
- package/dist/tools/read-file.d.ts +47 -9
- package/dist/tools/read-file.d.ts.map +1 -1
- package/dist/tools/read-file.js +84 -70
- package/dist/tools/read-multiple-files.d.ts +17 -6
- package/dist/tools/read-multiple-files.d.ts.map +1 -1
- package/dist/tools/read-multiple-files.js +132 -72
- package/dist/tools/save-file.d.ts +45 -12
- package/dist/tools/save-file.d.ts.map +1 -1
- package/dist/tools/save-file.js +76 -101
- package/dist/tools/think.d.ts +15 -7
- package/dist/tools/think.d.ts.map +1 -1
- package/dist/tools/think.js +34 -20
- package/dist/tools/types.d.ts +8 -10
- package/dist/tools/types.d.ts.map +1 -1
- package/dist/tools/types.js +9 -0
- package/dist/tools/utils.d.ts +14 -0
- package/dist/tools/utils.d.ts.map +1 -0
- package/dist/tools/utils.js +16 -0
- package/dist/tools/web-fetch.d.ts +11 -4
- package/dist/tools/web-fetch.d.ts.map +1 -1
- package/dist/tools/web-fetch.js +39 -38
- package/dist/tools/web-search.d.ts +15 -6
- package/dist/tools/web-search.d.ts.map +1 -1
- package/dist/tools/web-search.js +64 -31
- package/dist/tui/autocomplete.d.ts +44 -0
- package/dist/tui/autocomplete.d.ts.map +1 -0
- package/dist/tui/autocomplete.js +466 -0
- package/dist/tui/components/assistant-message.d.ts +18 -0
- package/dist/tui/components/assistant-message.d.ts.map +1 -0
- package/dist/tui/components/assistant-message.js +29 -0
- package/dist/tui/components/box.d.ts +20 -0
- package/dist/tui/components/box.d.ts.map +1 -0
- package/dist/tui/components/box.js +81 -0
- package/dist/tui/components/editor.d.ts +106 -0
- package/dist/tui/components/editor.d.ts.map +1 -0
- package/dist/tui/components/editor.js +1220 -0
- package/dist/tui/components/footer.d.ts +12 -0
- package/dist/tui/components/footer.d.ts.map +1 -0
- package/dist/tui/components/footer.js +209 -0
- package/dist/tui/components/header.d.ts +21 -0
- package/dist/tui/components/header.d.ts.map +1 -0
- package/dist/tui/components/header.js +63 -0
- package/dist/tui/components/input.d.ts +14 -0
- package/dist/tui/components/input.d.ts.map +1 -0
- package/dist/tui/components/input.js +122 -0
- package/dist/tui/components/loader.d.ts +23 -0
- package/dist/tui/components/loader.d.ts.map +1 -0
- package/dist/tui/components/loader.js +45 -0
- package/dist/tui/components/markdown.d.ts +106 -0
- package/dist/tui/components/markdown.d.ts.map +1 -0
- package/dist/tui/components/markdown.js +586 -0
- package/dist/tui/components/modal.d.ts +29 -0
- package/dist/tui/components/modal.d.ts.map +1 -0
- package/dist/tui/components/modal.js +263 -0
- package/dist/tui/components/progress-bar.d.ts +19 -0
- package/dist/tui/components/progress-bar.d.ts.map +1 -0
- package/dist/tui/components/progress-bar.js +78 -0
- package/dist/tui/components/prompt-status.d.ts +17 -0
- package/dist/tui/components/prompt-status.d.ts.map +1 -0
- package/dist/tui/components/prompt-status.js +26 -0
- package/dist/tui/components/select-list.d.ts +48 -0
- package/dist/tui/components/select-list.d.ts.map +1 -0
- package/dist/tui/components/select-list.js +207 -0
- package/dist/tui/components/spacer.d.ts +16 -0
- package/dist/tui/components/spacer.d.ts.map +1 -0
- package/dist/tui/components/spacer.js +27 -0
- package/dist/tui/components/table.d.ts +27 -0
- package/dist/tui/components/table.d.ts.map +1 -0
- package/dist/tui/components/table.js +125 -0
- package/dist/tui/components/text.d.ts +26 -0
- package/dist/tui/components/text.d.ts.map +1 -0
- package/dist/tui/components/text.js +143 -0
- package/dist/tui/components/thinking-block.d.ts +14 -0
- package/dist/tui/components/thinking-block.d.ts.map +1 -0
- package/dist/tui/components/thinking-block.js +33 -0
- package/dist/tui/components/tool-execution.d.ts +21 -0
- package/dist/tui/components/tool-execution.d.ts.map +1 -0
- package/dist/tui/components/tool-execution.js +161 -0
- package/dist/tui/components/user-message.d.ts +9 -0
- package/dist/tui/components/user-message.d.ts.map +1 -0
- package/dist/tui/components/user-message.js +23 -0
- package/dist/tui/components/welcome.d.ts +6 -0
- package/dist/tui/components/welcome.d.ts.map +1 -0
- package/dist/tui/components/welcome.js +30 -0
- package/dist/tui/index.d.ts +18 -0
- package/dist/tui/index.d.ts.map +1 -0
- package/dist/tui/index.js +22 -0
- package/dist/tui/terminal.d.ts +38 -0
- package/dist/tui/terminal.d.ts.map +1 -0
- package/dist/tui/terminal.js +94 -0
- package/dist/tui/tui.d.ts +69 -0
- package/dist/tui/tui.d.ts.map +1 -0
- package/dist/tui/tui.js +204 -0
- package/dist/tui/utils.d.ts +24 -0
- package/dist/tui/utils.d.ts.map +1 -0
- package/dist/tui/utils.js +111 -0
- package/dist/utils/bash.d.ts +7 -0
- package/dist/utils/bash.d.ts.map +1 -0
- package/dist/{tools/bash-utils.js → utils/bash.js} +31 -12
- package/dist/utils/{filesystem.d.ts → filesystem/operations.d.ts} +1 -1
- package/dist/utils/filesystem/operations.d.ts.map +1 -0
- package/dist/utils/filesystem/security.d.ts +9 -0
- package/dist/utils/filesystem/security.d.ts.map +1 -0
- package/dist/{tools/filesystem-utils.js → utils/filesystem/security.js} +93 -21
- package/dist/utils/funcs.d.ts +6 -0
- package/dist/utils/funcs.d.ts.map +1 -0
- package/dist/utils/funcs.js +6 -0
- package/dist/utils/generators.d.ts +3 -0
- package/dist/utils/generators.d.ts.map +1 -0
- package/dist/utils/generators.js +25 -0
- package/dist/{tools/git-utils.d.ts → utils/git.d.ts} +1 -1
- package/dist/utils/git.d.ts.map +1 -0
- package/dist/{tools/git-utils.js → utils/git.js} +0 -6
- package/dist/utils/glob.js +1 -1
- package/dist/utils/iterables.d.ts +2 -0
- package/dist/utils/iterables.d.ts.map +1 -0
- package/dist/utils/iterables.js +6 -0
- package/dist/utils/{zod-utils.d.ts → zod.d.ts} +1 -1
- package/dist/utils/zod.d.ts.map +1 -0
- package/package.json +21 -21
- package/dist/conversation-analyzer.d.ts +0 -11
- package/dist/conversation-analyzer.d.ts.map +0 -1
- package/dist/conversation-analyzer.js +0 -88
- package/dist/repl/display-tool-messages.d.ts +0 -4
- package/dist/repl/display-tool-messages.d.ts.map +0 -1
- package/dist/repl/display-tool-messages.js +0 -55
- package/dist/repl/display-tool-use.d.ts +0 -14
- package/dist/repl/display-tool-use.d.ts.map +0 -1
- package/dist/repl/display-tool-use.js +0 -63
- package/dist/repl/get-prompt-header.d.ts +0 -8
- package/dist/repl/get-prompt-header.d.ts.map +0 -1
- package/dist/repl/get-prompt-header.js +0 -38
- package/dist/repl-prompt.d.ts +0 -15
- package/dist/repl-prompt.d.ts.map +0 -1
- package/dist/repl-prompt.js +0 -147
- package/dist/repl.d.ts +0 -31
- package/dist/repl.d.ts.map +0 -1
- package/dist/repl.js +0 -310
- package/dist/terminal/checkbox-prompt.d.ts +0 -36
- package/dist/terminal/checkbox-prompt.d.ts.map +0 -1
- package/dist/terminal/checkbox-prompt.js +0 -362
- package/dist/terminal/editor-prompt.d.ts +0 -10
- package/dist/terminal/editor-prompt.d.ts.map +0 -1
- package/dist/terminal/editor-prompt.js +0 -61
- package/dist/terminal/errors.d.ts +0 -19
- package/dist/terminal/errors.d.ts.map +0 -1
- package/dist/terminal/errors.js +0 -37
- package/dist/terminal/input-prompt.d.ts +0 -16
- package/dist/terminal/input-prompt.d.ts.map +0 -1
- package/dist/terminal/input-prompt.js +0 -181
- package/dist/terminal/search-prompt.d.ts +0 -20
- package/dist/terminal/search-prompt.d.ts.map +0 -1
- package/dist/terminal/search-prompt.js +0 -279
- package/dist/terminal/types.d.ts +0 -35
- package/dist/terminal/types.d.ts.map +0 -1
- package/dist/terminal/types.js +0 -1
- package/dist/tokens/manage-output.d.ts +0 -34
- package/dist/tokens/manage-output.d.ts.map +0 -1
- package/dist/tokens/manage-output.js +0 -44
- package/dist/tool-executor.d.ts +0 -28
- package/dist/tool-executor.d.ts.map +0 -1
- package/dist/tool-executor.js +0 -74
- package/dist/tools/bash-utils.d.ts +0 -7
- package/dist/tools/bash-utils.d.ts.map +0 -1
- package/dist/tools/file-editing-utils.d.ts +0 -2
- package/dist/tools/file-editing-utils.d.ts.map +0 -1
- package/dist/tools/file-editing-utils.js +0 -135
- package/dist/tools/filesystem-utils.d.ts +0 -7
- package/dist/tools/filesystem-utils.d.ts.map +0 -1
- package/dist/tools/git-utils.d.ts.map +0 -1
- package/dist/utils/filesystem.d.ts.map +0 -1
- package/dist/utils/zod-utils.d.ts.map +0 -1
- /package/dist/utils/{filesystem.js → filesystem/operations.js} +0 -0
- /package/dist/utils/{zod-utils.js → zod.js} +0 -0
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import style from "../terminal/style.js";
|
|
2
|
+
import { getCurrentBranch, getDiffStat, getGitStatus, inGitDirectory, } from "../utils/git.js";
|
|
3
|
+
// Cache for project status to prevent excessive Git operations
|
|
4
|
+
class ProjectStatusCache {
|
|
5
|
+
cachedStatus = null;
|
|
6
|
+
cacheTime = 0;
|
|
7
|
+
cacheTtl = 2000; // 2 seconds
|
|
8
|
+
async getStatus() {
|
|
9
|
+
const now = Date.now();
|
|
10
|
+
// Return cached status if it's still valid
|
|
11
|
+
if (this.cachedStatus && now - this.cacheTime < this.cacheTtl) {
|
|
12
|
+
return this.cachedStatus;
|
|
13
|
+
}
|
|
14
|
+
const currentDir = process.cwd().split("/").pop() || process.cwd();
|
|
15
|
+
let gitStatus = "";
|
|
16
|
+
if (await inGitDirectory()) {
|
|
17
|
+
// Generate fresh status
|
|
18
|
+
const branch = await getCurrentBranch();
|
|
19
|
+
const fileChanges = await getGitStatus();
|
|
20
|
+
if (branch) {
|
|
21
|
+
const hasChanges = fileChanges.added > 0 ||
|
|
22
|
+
fileChanges.deleted > 0 ||
|
|
23
|
+
fileChanges.modified > 0;
|
|
24
|
+
const asterisk = hasChanges ? "*" : "";
|
|
25
|
+
gitStatus = ` ${style.gray(branch + asterisk)}`;
|
|
26
|
+
}
|
|
27
|
+
const stats = await getDiffStat();
|
|
28
|
+
let fileStatus = "";
|
|
29
|
+
if (fileChanges.added)
|
|
30
|
+
fileStatus += ` +${fileChanges.added}`;
|
|
31
|
+
if (fileChanges.modified)
|
|
32
|
+
fileStatus += ` ~${fileChanges.modified}`;
|
|
33
|
+
if (fileChanges.deleted)
|
|
34
|
+
fileStatus += ` -${fileChanges.deleted}`;
|
|
35
|
+
if (fileChanges.untracked)
|
|
36
|
+
fileStatus += ` ?${fileChanges.untracked}`;
|
|
37
|
+
gitStatus +=
|
|
38
|
+
" " +
|
|
39
|
+
`${style.dim("[")}${style.yellow(fileStatus.trim())} ` +
|
|
40
|
+
`${style.green(`+${stats.insertions}`)} ` +
|
|
41
|
+
`${style.red(`-${stats.deletions}`)}${style.dim("]")}`;
|
|
42
|
+
}
|
|
43
|
+
this.cachedStatus = `${style.blue(currentDir)}${gitStatus}`;
|
|
44
|
+
this.cacheTime = now;
|
|
45
|
+
return this.cachedStatus;
|
|
46
|
+
}
|
|
47
|
+
// Clear cache (call this when you know the status has changed)
|
|
48
|
+
clear() {
|
|
49
|
+
this.cachedStatus = null;
|
|
50
|
+
this.cacheTime = 0;
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
const statusCache = new ProjectStatusCache();
|
|
54
|
+
export async function getProjectStatusLine() {
|
|
55
|
+
return await statusCache.getStatus();
|
|
56
|
+
}
|
|
57
|
+
// Export clear function for cases where we know the status changed
|
|
58
|
+
// (e.g., after file operations, git operations)
|
|
59
|
+
export function clearProjectStatusCache() {
|
|
60
|
+
statusCache.clear();
|
|
61
|
+
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tool-call-repair.d.ts","sourceRoot":"","sources":["../../source/repl/tool-call-repair.ts"],"names":[],"mappings":"AACA,OAAO,EAIL,KAAK,sBAAsB,EAC3B,KAAK,OAAO,EACb,MAAM,IAAI,CAAC;AAIZ,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAC;AAoCzD,eAAO,MAAM,cAAc,GAAI,cAAc,YAAY,
|
|
1
|
+
{"version":3,"file":"tool-call-repair.d.ts","sourceRoot":"","sources":["../../source/repl/tool-call-repair.ts"],"names":[],"mappings":"AACA,OAAO,EAIL,KAAK,sBAAsB,EAC3B,KAAK,OAAO,EACb,MAAM,IAAI,CAAC;AAIZ,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAC;AAoCzD,eAAO,MAAM,cAAc,GAAI,cAAc,YAAY,oCAmDxD,CAAC"}
|
|
@@ -18,8 +18,8 @@ async function remoteToolCallRepair(modelManager, toolCall, tool, inputSchema) {
|
|
|
18
18
|
const localToolCallRepair = async (toolCall, tool) => {
|
|
19
19
|
const schema = tool.inputSchema;
|
|
20
20
|
const repairedArgs = jsonrepair(toolCall.input);
|
|
21
|
-
schema.parse(repairedArgs);
|
|
22
|
-
return { ...toolCall, input: JSON.stringify(
|
|
21
|
+
const validatedArgs = schema.parse(JSON.parse(repairedArgs));
|
|
22
|
+
return { ...toolCall, input: JSON.stringify(validatedArgs) };
|
|
23
23
|
};
|
|
24
24
|
export const toolCallRepair = (modelManager) => {
|
|
25
25
|
const fn = async ({ toolCall, tools, inputSchema, error, }) => {
|
|
@@ -33,12 +33,16 @@ export const toolCallRepair = (modelManager) => {
|
|
|
33
33
|
return null;
|
|
34
34
|
}
|
|
35
35
|
try {
|
|
36
|
-
|
|
36
|
+
const repaired = await localToolCallRepair(toolCall, tool);
|
|
37
|
+
logger.debug(`Tool call repaired with jsonrepair ${repaired.input}`);
|
|
38
|
+
return repaired;
|
|
37
39
|
}
|
|
38
40
|
catch (err) {
|
|
39
41
|
logger.error(err, `Failed to repair tool call locally: ${toolCall.toolName}.`);
|
|
40
42
|
try {
|
|
41
|
-
|
|
43
|
+
const repaired = await remoteToolCallRepair(modelManager, toolCall, tool, inputSchema);
|
|
44
|
+
logger.debug(`Tool call repaired with remote repair ${repaired.input}`);
|
|
45
|
+
return repaired;
|
|
42
46
|
}
|
|
43
47
|
catch (err2) {
|
|
44
48
|
logger.error(err2, `Failed to repair tool call remotely: ${toolCall.toolName}.`);
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import type { Agent, AgentEvent, AgentState } from "./agent/index.ts";
|
|
2
|
+
import type { CommandManager } from "./commands/manager.ts";
|
|
3
|
+
import type { WorkspaceContext } from "./index.ts";
|
|
4
|
+
import type { MessageHistory } from "./messages.ts";
|
|
5
|
+
import type { ModelManager } from "./models/manager.ts";
|
|
6
|
+
import type { PromptManager } from "./prompts/manager.ts";
|
|
7
|
+
import type { TokenCounter } from "./tokens/counter.ts";
|
|
8
|
+
import type { TokenTracker } from "./tokens/tracker.ts";
|
|
9
|
+
interface ReplOptions {
|
|
10
|
+
agent: Agent;
|
|
11
|
+
messageHistory: MessageHistory;
|
|
12
|
+
promptManager: PromptManager;
|
|
13
|
+
modelManager: ModelManager;
|
|
14
|
+
tokenTracker: TokenTracker;
|
|
15
|
+
commands: CommandManager;
|
|
16
|
+
config: Record<PropertyKey, unknown>;
|
|
17
|
+
tokenCounter: TokenCounter;
|
|
18
|
+
promptHistory: string[];
|
|
19
|
+
workspace: WorkspaceContext;
|
|
20
|
+
}
|
|
21
|
+
export declare class NewRepl {
|
|
22
|
+
private options;
|
|
23
|
+
private tui;
|
|
24
|
+
private welcome;
|
|
25
|
+
private editor;
|
|
26
|
+
private chatContainer;
|
|
27
|
+
private statusContainer;
|
|
28
|
+
private promptStatus;
|
|
29
|
+
private footer;
|
|
30
|
+
private editorContainer;
|
|
31
|
+
private isInitialized;
|
|
32
|
+
private onInputCallback?;
|
|
33
|
+
private loadingAnimation;
|
|
34
|
+
private onInterruptCallback?;
|
|
35
|
+
private lastSigintTime;
|
|
36
|
+
private pendingTools;
|
|
37
|
+
private streamingComponent;
|
|
38
|
+
private thinkingBlockComponent;
|
|
39
|
+
constructor(options: ReplOptions);
|
|
40
|
+
init(): Promise<void>;
|
|
41
|
+
handle(event: AgentEvent, state: AgentState): Promise<void>;
|
|
42
|
+
private addMessageToChat;
|
|
43
|
+
getUserInput(): Promise<string>;
|
|
44
|
+
clearEditor(): void;
|
|
45
|
+
setInterruptCallback(callback: () => void): void;
|
|
46
|
+
rerender(): Promise<void>;
|
|
47
|
+
private handleCtrlC;
|
|
48
|
+
stop(): void;
|
|
49
|
+
}
|
|
50
|
+
export {};
|
|
51
|
+
//# sourceMappingURL=repl-new.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"repl-new.d.ts","sourceRoot":"","sources":["../source/repl-new.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,UAAU,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AACtE,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;AAC5D,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAC;AAGnD,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC;AACpD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AACxD,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AAI1D,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AACxD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AAmBxD,UAAU,WAAW;IACnB,KAAK,EAAE,KAAK,CAAC;IACb,cAAc,EAAE,cAAc,CAAC;IAC/B,aAAa,EAAE,aAAa,CAAC;IAC7B,YAAY,EAAE,YAAY,CAAC;IAC3B,YAAY,EAAE,YAAY,CAAC;IAC3B,QAAQ,EAAE,cAAc,CAAC;IACzB,MAAM,EAAE,MAAM,CAAC,WAAW,EAAE,OAAO,CAAC,CAAC;IACrC,YAAY,EAAE,YAAY,CAAC;IAC3B,aAAa,EAAE,MAAM,EAAE,CAAC;IACxB,SAAS,EAAE,gBAAgB,CAAC;CAC7B;AAED,qBAAa,OAAO;IAClB,OAAO,CAAC,OAAO,CAAc;IAC7B,OAAO,CAAC,GAAG,CAAM;IACjB,OAAO,CAAC,OAAO,CAAU;IACzB,OAAO,CAAC,MAAM,CAAS;IACvB,OAAO,CAAC,aAAa,CAAY;IACjC,OAAO,CAAC,eAAe,CAAY;IACnC,OAAO,CAAC,YAAY,CAAwB;IAC5C,OAAO,CAAC,MAAM,CAAkB;IAChC,OAAO,CAAC,eAAe,CAAY;IACnC,OAAO,CAAC,aAAa,CAAU;IAC/B,OAAO,CAAC,eAAe,CAAC,CAAyB;IACjD,OAAO,CAAC,gBAAgB,CAAuB;IAC/C,OAAO,CAAC,mBAAmB,CAAC,CAAa;IACzC,OAAO,CAAC,cAAc,CAAK;IAC3B,OAAO,CAAC,YAAY,CAAsC;IAG1D,OAAO,CAAC,kBAAkB,CAA0C;IAGpE,OAAO,CAAC,sBAAsB,CAAuC;gBAEzD,OAAO,EAAE,WAAW;IAuB1B,IAAI;IAuJJ,MAAM,CAAC,KAAK,EAAE,UAAU,EAAE,KAAK,EAAE,UAAU;IA+JjD,OAAO,CAAC,gBAAgB;IAWlB,YAAY,IAAI,OAAO,CAAC,MAAM,CAAC;IASrC,WAAW,IAAI,IAAI;IAKnB,oBAAoB,CAAC,QAAQ,EAAE,MAAM,IAAI,GAAG,IAAI;IAI1C,QAAQ;IAYd,OAAO,CAAC,WAAW;IAiBnB,IAAI,IAAI,IAAI;CAUb"}
|
package/dist/repl-new.js
ADDED
|
@@ -0,0 +1,354 @@
|
|
|
1
|
+
import { logger } from "./logger.js";
|
|
2
|
+
import { PromptError, processPrompt } from "./mentions.js";
|
|
3
|
+
import { getProjectStatusLine } from "./repl/project-status-line.js";
|
|
4
|
+
import { loadSkills } from "./skills.js";
|
|
5
|
+
import style from "./terminal/style.js";
|
|
6
|
+
import { AssistantMessageComponent } from "./tui/components/assistant-message.js";
|
|
7
|
+
import { FooterComponent } from "./tui/components/footer.js";
|
|
8
|
+
import { PromptStatusComponent } from "./tui/components/prompt-status.js";
|
|
9
|
+
import { ThinkingBlockComponent } from "./tui/components/thinking-block.js";
|
|
10
|
+
import { ToolExecutionComponent } from "./tui/components/tool-execution.js";
|
|
11
|
+
import { Welcome } from "./tui/components/welcome.js";
|
|
12
|
+
import { CombinedAutocompleteProvider, Container, Editor, Loader, ProcessTerminal, Spacer, Text, TUI, UserMessageComponent, } from "./tui/index.js";
|
|
13
|
+
export class NewRepl {
|
|
14
|
+
options;
|
|
15
|
+
tui;
|
|
16
|
+
welcome;
|
|
17
|
+
editor;
|
|
18
|
+
chatContainer;
|
|
19
|
+
statusContainer;
|
|
20
|
+
promptStatus;
|
|
21
|
+
footer;
|
|
22
|
+
editorContainer; // Container to swap between editor and selector
|
|
23
|
+
isInitialized;
|
|
24
|
+
onInputCallback;
|
|
25
|
+
loadingAnimation = null;
|
|
26
|
+
onInterruptCallback;
|
|
27
|
+
lastSigintTime = 0;
|
|
28
|
+
pendingTools;
|
|
29
|
+
// Streaming message tracking
|
|
30
|
+
streamingComponent = null;
|
|
31
|
+
// thinking block tracking
|
|
32
|
+
thinkingBlockComponent = null;
|
|
33
|
+
constructor(options) {
|
|
34
|
+
this.options = options;
|
|
35
|
+
this.tui = new TUI(new ProcessTerminal());
|
|
36
|
+
this.welcome = new Welcome();
|
|
37
|
+
this.editor = new Editor({
|
|
38
|
+
borderColor: style.gray,
|
|
39
|
+
});
|
|
40
|
+
this.chatContainer = new Container();
|
|
41
|
+
this.statusContainer = new Container();
|
|
42
|
+
this.editorContainer = new Container(); // Container to hold editor or selector
|
|
43
|
+
this.footer = new FooterComponent(options.agent.state);
|
|
44
|
+
this.promptStatus = new PromptStatusComponent(options.modelManager, {
|
|
45
|
+
projectStatus: "",
|
|
46
|
+
currentContextWindow: 0,
|
|
47
|
+
contextWindow: options.modelManager.getModelMetadata("repl").contextWindow,
|
|
48
|
+
});
|
|
49
|
+
this.editorContainer.addChild(this.editor); // Start with editor
|
|
50
|
+
this.editor.onRenderRequested = () => this.tui.requestRender();
|
|
51
|
+
this.isInitialized = false;
|
|
52
|
+
this.pendingTools = new Map();
|
|
53
|
+
}
|
|
54
|
+
async init() {
|
|
55
|
+
if (this.isInitialized) {
|
|
56
|
+
return;
|
|
57
|
+
}
|
|
58
|
+
// Setup autocomplete for file paths and slash commands
|
|
59
|
+
const autocompleteProvider = new CombinedAutocompleteProvider([...(await this.options.commands.getCompletions())], this.options.workspace.allowedDirs);
|
|
60
|
+
this.editor.setAutocompleteProvider(autocompleteProvider);
|
|
61
|
+
const { promptManager, modelManager, messageHistory, commands, promptHistory, } = this.options;
|
|
62
|
+
const modelConfig = modelManager.getModelMetadata("repl");
|
|
63
|
+
this.promptStatus.setState({
|
|
64
|
+
projectStatus: await getProjectStatusLine(),
|
|
65
|
+
currentContextWindow: 0,
|
|
66
|
+
contextWindow: modelConfig.contextWindow,
|
|
67
|
+
});
|
|
68
|
+
this.tui.addChild(this.welcome);
|
|
69
|
+
// Show loaded skills
|
|
70
|
+
const skills = await loadSkills();
|
|
71
|
+
if (skills.length > 0) {
|
|
72
|
+
const skillList = skills
|
|
73
|
+
.map((s) => style.dim(` ${s.filePath}`))
|
|
74
|
+
.join("\n");
|
|
75
|
+
this.tui.addChild(new Text(style.gray("Loaded skills:\n") + skillList, 0, 0));
|
|
76
|
+
this.tui.addChild(new Spacer(1));
|
|
77
|
+
}
|
|
78
|
+
this.tui.addChild(this.chatContainer);
|
|
79
|
+
this.tui.addChild(this.statusContainer);
|
|
80
|
+
this.tui.addChild(new Spacer(1));
|
|
81
|
+
this.tui.addChild(this.footer);
|
|
82
|
+
this.tui.addChild(this.editorContainer); // Use container that can hold editor or selector
|
|
83
|
+
this.tui.addChild(this.promptStatus);
|
|
84
|
+
this.tui.setFocus(this.editor);
|
|
85
|
+
// Set up custom key handlers on the editor
|
|
86
|
+
this.editor.onEscape = () => {
|
|
87
|
+
// Intercept Escape key when processing
|
|
88
|
+
if (this.loadingAnimation && this.onInterruptCallback) {
|
|
89
|
+
this.onInterruptCallback();
|
|
90
|
+
}
|
|
91
|
+
};
|
|
92
|
+
this.editor.onCtrlC = () => {
|
|
93
|
+
this.handleCtrlC();
|
|
94
|
+
};
|
|
95
|
+
// Create editor for input
|
|
96
|
+
this.editor.onSubmit = async (text) => {
|
|
97
|
+
if (text.trim()) {
|
|
98
|
+
// see if the text contains a command
|
|
99
|
+
const commandResult = await commands.handle({ userInput: text }, {
|
|
100
|
+
tui: this.tui,
|
|
101
|
+
container: this.chatContainer,
|
|
102
|
+
inputContainer: this.editorContainer,
|
|
103
|
+
editor: this.editor,
|
|
104
|
+
});
|
|
105
|
+
if (commandResult.break) {
|
|
106
|
+
this.stop();
|
|
107
|
+
process.exit(0);
|
|
108
|
+
}
|
|
109
|
+
if (commandResult.continue) {
|
|
110
|
+
this.editor.setText("");
|
|
111
|
+
this.tui.requestRender();
|
|
112
|
+
return;
|
|
113
|
+
}
|
|
114
|
+
if (!promptManager.isPending()) {
|
|
115
|
+
try {
|
|
116
|
+
const processedPrompt = await processPrompt(text, {
|
|
117
|
+
baseDir: process.cwd(),
|
|
118
|
+
model: modelConfig,
|
|
119
|
+
});
|
|
120
|
+
for (const context of processedPrompt.context) {
|
|
121
|
+
promptManager.addContext(context);
|
|
122
|
+
}
|
|
123
|
+
promptManager.set(processedPrompt.message);
|
|
124
|
+
}
|
|
125
|
+
catch (error) {
|
|
126
|
+
if (error instanceof PromptError) {
|
|
127
|
+
this.chatContainer.addChild(new Text(style.red(`Prompt processing failed: ${error.message}`), 1, 1));
|
|
128
|
+
if (error.cause &&
|
|
129
|
+
typeof error.cause === "object" &&
|
|
130
|
+
"command" in error.cause &&
|
|
131
|
+
typeof error.cause.command === "string") {
|
|
132
|
+
this.chatContainer.addChild(new Text(style.red(`Command: ${error.cause.command}`, 1, 1)));
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
throw error; // Re-throw other errors
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
else {
|
|
139
|
+
promptHistory.push(promptManager.get());
|
|
140
|
+
this.editor.addToHistory(promptManager.get());
|
|
141
|
+
}
|
|
142
|
+
// flag to see if the user prompt has added context
|
|
143
|
+
const hasAddedContext = promptManager.hasContext();
|
|
144
|
+
if (hasAddedContext) {
|
|
145
|
+
const contextTokenCount = promptManager.getContextTokenCount();
|
|
146
|
+
this.chatContainer.addChild(new Text(style.green(`Context will be added to prompt. (${contextTokenCount} tokens)`, 1, 1)));
|
|
147
|
+
}
|
|
148
|
+
const userPrompt = promptManager.get();
|
|
149
|
+
const userMsg = promptManager.getUserMessage();
|
|
150
|
+
messageHistory.appendUserMessage(userMsg);
|
|
151
|
+
if (this.onInputCallback) {
|
|
152
|
+
this.onInputCallback(userPrompt);
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
};
|
|
156
|
+
// Start
|
|
157
|
+
this.tui.start();
|
|
158
|
+
this.isInitialized = true;
|
|
159
|
+
}
|
|
160
|
+
async handle(event, state) {
|
|
161
|
+
if (!this.isInitialized) {
|
|
162
|
+
await this.init();
|
|
163
|
+
}
|
|
164
|
+
// Update footer with current stats
|
|
165
|
+
this.footer.updateState(state);
|
|
166
|
+
this.promptStatus.setState({
|
|
167
|
+
projectStatus: await getProjectStatusLine(),
|
|
168
|
+
currentContextWindow: this.options.messageHistory.getContextWindow(),
|
|
169
|
+
contextWindow: this.options.modelManager.getModelMetadata("repl").contextWindow,
|
|
170
|
+
});
|
|
171
|
+
const eventType = event.type;
|
|
172
|
+
switch (eventType) {
|
|
173
|
+
case "agent-start":
|
|
174
|
+
// Show loading animation
|
|
175
|
+
this.editor.disableSubmit = true;
|
|
176
|
+
// Stop old loader before clearing
|
|
177
|
+
if (this.loadingAnimation) {
|
|
178
|
+
this.loadingAnimation.stop();
|
|
179
|
+
}
|
|
180
|
+
this.statusContainer.clear();
|
|
181
|
+
this.loadingAnimation = new Loader(this.tui, "Working... (esc to interrupt)");
|
|
182
|
+
this.statusContainer.addChild(this.loadingAnimation);
|
|
183
|
+
this.tui.requestRender();
|
|
184
|
+
break;
|
|
185
|
+
case "step-start":
|
|
186
|
+
// this.tui.requestRender();
|
|
187
|
+
break;
|
|
188
|
+
case "step-stop":
|
|
189
|
+
// this.pendingTools.clear();
|
|
190
|
+
// this.tui.requestRender();
|
|
191
|
+
break;
|
|
192
|
+
case "message-start":
|
|
193
|
+
if (event.role === "assistant") {
|
|
194
|
+
// Create assistant component for streaming
|
|
195
|
+
const assistantMessageComponent = new AssistantMessageComponent();
|
|
196
|
+
this.streamingComponent = assistantMessageComponent;
|
|
197
|
+
this.chatContainer.addChild(assistantMessageComponent);
|
|
198
|
+
this.streamingComponent.updateContent(event);
|
|
199
|
+
this.tui.requestRender();
|
|
200
|
+
}
|
|
201
|
+
break;
|
|
202
|
+
case "message":
|
|
203
|
+
if (event.role === "user") {
|
|
204
|
+
// Show user message immediately and clear editor
|
|
205
|
+
this.addMessageToChat(event);
|
|
206
|
+
this.editor.setText("");
|
|
207
|
+
this.tui.requestRender();
|
|
208
|
+
}
|
|
209
|
+
else if (event.role === "assistant") {
|
|
210
|
+
// Update streaming component
|
|
211
|
+
if (this.streamingComponent && event.role === "assistant") {
|
|
212
|
+
this.streamingComponent.updateContent(event);
|
|
213
|
+
this.tui.requestRender();
|
|
214
|
+
}
|
|
215
|
+
}
|
|
216
|
+
break;
|
|
217
|
+
case "message-end":
|
|
218
|
+
if (this.streamingComponent && event.role === "assistant") {
|
|
219
|
+
this.streamingComponent.updateContent(event);
|
|
220
|
+
this.streamingComponent = null;
|
|
221
|
+
this.tui.requestRender();
|
|
222
|
+
}
|
|
223
|
+
break;
|
|
224
|
+
case "tool-call-lifecycle": {
|
|
225
|
+
const component = this.pendingTools.get(event.toolCallId);
|
|
226
|
+
if (component) {
|
|
227
|
+
component.update(event.events);
|
|
228
|
+
}
|
|
229
|
+
else {
|
|
230
|
+
// Create tool component for new tool call
|
|
231
|
+
const newComponent = new ToolExecutionComponent(this.tui, event.events);
|
|
232
|
+
this.pendingTools.set(event.toolCallId, newComponent);
|
|
233
|
+
this.chatContainer.addChild(newComponent);
|
|
234
|
+
}
|
|
235
|
+
this.tui.requestRender();
|
|
236
|
+
break;
|
|
237
|
+
}
|
|
238
|
+
case "agent-stop":
|
|
239
|
+
// Stop loading animation
|
|
240
|
+
if (this.loadingAnimation) {
|
|
241
|
+
this.loadingAnimation.stop();
|
|
242
|
+
this.loadingAnimation = null;
|
|
243
|
+
this.statusContainer.clear();
|
|
244
|
+
}
|
|
245
|
+
// Clear streaming component reference
|
|
246
|
+
if (this.streamingComponent) {
|
|
247
|
+
this.streamingComponent = null;
|
|
248
|
+
}
|
|
249
|
+
this.pendingTools.clear();
|
|
250
|
+
this.editor.disableSubmit = false;
|
|
251
|
+
this.tui.requestRender();
|
|
252
|
+
break;
|
|
253
|
+
case "agent-error":
|
|
254
|
+
logger.error(event, "agent-error");
|
|
255
|
+
// Stop loading animation
|
|
256
|
+
if (this.loadingAnimation) {
|
|
257
|
+
this.loadingAnimation.stop();
|
|
258
|
+
this.loadingAnimation = null;
|
|
259
|
+
this.statusContainer.clear();
|
|
260
|
+
}
|
|
261
|
+
// Clear streaming component reference
|
|
262
|
+
if (this.streamingComponent) {
|
|
263
|
+
this.streamingComponent = null;
|
|
264
|
+
}
|
|
265
|
+
this.pendingTools.clear();
|
|
266
|
+
this.editor.disableSubmit = false;
|
|
267
|
+
this.tui.requestRender();
|
|
268
|
+
break;
|
|
269
|
+
case "thinking-start": {
|
|
270
|
+
const component = new ThinkingBlockComponent();
|
|
271
|
+
this.thinkingBlockComponent = component;
|
|
272
|
+
this.chatContainer.addChild(component);
|
|
273
|
+
this.thinkingBlockComponent.updateContent(event);
|
|
274
|
+
this.tui.requestRender();
|
|
275
|
+
break;
|
|
276
|
+
}
|
|
277
|
+
case "thinking":
|
|
278
|
+
if (this.thinkingBlockComponent) {
|
|
279
|
+
this.thinkingBlockComponent.updateContent(event);
|
|
280
|
+
this.tui.requestRender();
|
|
281
|
+
}
|
|
282
|
+
break;
|
|
283
|
+
case "thinking-end":
|
|
284
|
+
if (this.thinkingBlockComponent) {
|
|
285
|
+
this.thinkingBlockComponent.updateContent(event);
|
|
286
|
+
this.thinkingBlockComponent = null;
|
|
287
|
+
this.tui.requestRender();
|
|
288
|
+
}
|
|
289
|
+
break;
|
|
290
|
+
default:
|
|
291
|
+
eventType;
|
|
292
|
+
}
|
|
293
|
+
}
|
|
294
|
+
addMessageToChat(message) {
|
|
295
|
+
if (message.role === "user") {
|
|
296
|
+
// Extract text content from content blocks
|
|
297
|
+
const textContent = message.content;
|
|
298
|
+
if (textContent) {
|
|
299
|
+
const userComponent = new UserMessageComponent(textContent);
|
|
300
|
+
this.chatContainer.addChild(userComponent);
|
|
301
|
+
}
|
|
302
|
+
}
|
|
303
|
+
}
|
|
304
|
+
async getUserInput() {
|
|
305
|
+
return new Promise((resolve) => {
|
|
306
|
+
this.onInputCallback = (text) => {
|
|
307
|
+
this.onInputCallback = undefined;
|
|
308
|
+
resolve(text);
|
|
309
|
+
};
|
|
310
|
+
});
|
|
311
|
+
}
|
|
312
|
+
clearEditor() {
|
|
313
|
+
this.editor.setText("");
|
|
314
|
+
this.tui.requestRender();
|
|
315
|
+
}
|
|
316
|
+
setInterruptCallback(callback) {
|
|
317
|
+
this.onInterruptCallback = callback;
|
|
318
|
+
}
|
|
319
|
+
async rerender() {
|
|
320
|
+
this.footer.updateState(this.options.agent.state);
|
|
321
|
+
this.promptStatus.setState({
|
|
322
|
+
projectStatus: await getProjectStatusLine(),
|
|
323
|
+
currentContextWindow: this.options.messageHistory.getContextWindow(),
|
|
324
|
+
contextWindow: this.options.modelManager.getModelMetadata("repl").contextWindow,
|
|
325
|
+
});
|
|
326
|
+
this.tui.requestRender();
|
|
327
|
+
}
|
|
328
|
+
handleCtrlC() {
|
|
329
|
+
// Handle Ctrl+C double-press logic
|
|
330
|
+
const now = Date.now();
|
|
331
|
+
const timeSinceLastCtrlC = now - this.lastSigintTime;
|
|
332
|
+
if (timeSinceLastCtrlC < 500) {
|
|
333
|
+
// Second Ctrl+C within 500ms - exit
|
|
334
|
+
this.options.messageHistory.save();
|
|
335
|
+
this.stop();
|
|
336
|
+
process.exit(0);
|
|
337
|
+
}
|
|
338
|
+
else {
|
|
339
|
+
// First Ctrl+C - clear the editor
|
|
340
|
+
this.clearEditor();
|
|
341
|
+
this.lastSigintTime = now;
|
|
342
|
+
}
|
|
343
|
+
}
|
|
344
|
+
stop() {
|
|
345
|
+
if (this.loadingAnimation) {
|
|
346
|
+
this.loadingAnimation.stop();
|
|
347
|
+
this.loadingAnimation = null;
|
|
348
|
+
}
|
|
349
|
+
if (this.isInitialized) {
|
|
350
|
+
this.tui.stop();
|
|
351
|
+
this.isInitialized = false;
|
|
352
|
+
}
|
|
353
|
+
}
|
|
354
|
+
}
|
package/dist/skills.d.ts
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
export interface SkillFrontmatter {
|
|
2
|
+
name?: string;
|
|
3
|
+
description: string;
|
|
4
|
+
}
|
|
5
|
+
export interface Skill {
|
|
6
|
+
name: string;
|
|
7
|
+
description: string;
|
|
8
|
+
filePath: string;
|
|
9
|
+
baseDir: string;
|
|
10
|
+
source: string;
|
|
11
|
+
}
|
|
12
|
+
export interface LoadSkillsFromDirOptions {
|
|
13
|
+
dir: string;
|
|
14
|
+
source: string;
|
|
15
|
+
useColonPath?: boolean;
|
|
16
|
+
}
|
|
17
|
+
export declare function loadSkillsFromDir(options: LoadSkillsFromDirOptions, subdir?: string): Promise<Skill[]>;
|
|
18
|
+
export declare function loadSkills(): Promise<Skill[]>;
|
|
19
|
+
export declare function formatSkillsForPrompt(skills: Skill[]): string;
|
|
20
|
+
//# sourceMappingURL=skills.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"skills.d.ts","sourceRoot":"","sources":["../source/skills.ts"],"names":[],"mappings":"AAMA,MAAM,WAAW,gBAAgB;IAC/B,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,WAAW,EAAE,MAAM,CAAC;CACrB;AAED,MAAM,WAAW,KAAK;IACpB,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,EAAE,MAAM,CAAC;IACpB,QAAQ,EAAE,MAAM,CAAC;IACjB,OAAO,EAAE,MAAM,CAAC;IAChB,MAAM,EAAE,MAAM,CAAC;CAChB;AAED,MAAM,WAAW,wBAAwB;IACvC,GAAG,EAAE,MAAM,CAAC;IACZ,MAAM,EAAE,MAAM,CAAC;IACf,YAAY,CAAC,EAAE,OAAO,CAAC;CACxB;AA4KD,wBAAsB,iBAAiB,CACrC,OAAO,EAAE,wBAAwB,EACjC,MAAM,SAAK,GACV,OAAO,CAAC,KAAK,EAAE,CAAC,CASlB;AAED,wBAAsB,UAAU,IAAI,OAAO,CAAC,KAAK,EAAE,CAAC,CAyDnD;AAED,wBAAgB,qBAAqB,CAAC,MAAM,EAAE,KAAK,EAAE,GAAG,MAAM,CAqB7D"}
|