@travisennis/acai 0.0.7 → 0.0.9
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 +76 -27
- package/dist/agent/index.d.ts +21 -25
- package/dist/agent/index.d.ts.map +1 -1
- package/dist/agent/index.js +145 -103
- package/dist/cli.d.ts +2 -2
- package/dist/cli.d.ts.map +1 -1
- package/dist/cli.js +23 -17
- package/dist/commands/add-directory/index.d.ts +3 -0
- package/dist/commands/add-directory/index.d.ts.map +1 -0
- package/dist/commands/{add-directory-command.js → add-directory/index.js} +6 -10
- package/dist/commands/add-directory/types.d.ts +6 -0
- package/dist/commands/add-directory/types.d.ts.map +1 -0
- package/dist/commands/add-directory/types.js +1 -0
- package/dist/commands/add-directory/utils.d.ts +3 -0
- package/dist/commands/add-directory/utils.d.ts.map +1 -0
- package/dist/commands/add-directory/utils.js +15 -0
- package/dist/commands/clear/index.d.ts +3 -0
- package/dist/commands/clear/index.d.ts.map +1 -0
- package/dist/commands/{clear-command.js → clear/index.js} +0 -2
- package/dist/commands/copy/index.d.ts +3 -0
- package/dist/commands/copy/index.d.ts.map +1 -0
- package/dist/commands/{copy-command.js → copy/index.js} +4 -26
- package/dist/commands/copy/types.d.ts +3 -0
- package/dist/commands/copy/types.d.ts.map +1 -0
- package/dist/commands/copy/types.js +1 -0
- package/dist/commands/copy/utils.d.ts +3 -0
- package/dist/commands/copy/utils.d.ts.map +1 -0
- package/dist/commands/copy/utils.js +22 -0
- package/dist/commands/{exit-command.d.ts → exit/index.d.ts} +4 -4
- package/dist/commands/exit/index.d.ts.map +1 -0
- package/dist/commands/exit/index.js +21 -0
- package/dist/commands/exit/types.d.ts +8 -0
- package/dist/commands/exit/types.d.ts.map +1 -0
- package/dist/commands/exit/types.js +1 -0
- package/dist/commands/exit/utils.d.ts +2 -0
- package/dist/commands/exit/utils.d.ts.map +1 -0
- package/dist/commands/exit/utils.js +13 -0
- package/dist/commands/generate-rules/index.d.ts +3 -0
- package/dist/commands/generate-rules/index.d.ts.map +1 -0
- package/dist/commands/{generate-rules-command.js → generate-rules/index.js} +57 -96
- package/dist/commands/generate-rules/utils.d.ts +5 -0
- package/dist/commands/generate-rules/utils.d.ts.map +1 -0
- package/dist/commands/generate-rules/utils.js +25 -0
- package/dist/commands/handoff/index.d.ts +3 -0
- package/dist/commands/handoff/index.d.ts.map +1 -0
- package/dist/commands/handoff/index.js +97 -0
- package/dist/commands/handoff/utils.d.ts +4 -0
- package/dist/commands/handoff/utils.d.ts.map +1 -0
- package/dist/commands/{handoff-command.js → handoff/utils.js} +24 -92
- package/dist/commands/health/index.d.ts +3 -0
- package/dist/commands/health/index.d.ts.map +1 -0
- package/dist/commands/health/index.js +56 -0
- package/dist/commands/health/utils.d.ts +15 -0
- package/dist/commands/health/utils.d.ts.map +1 -0
- package/dist/commands/health/utils.js +52 -0
- package/dist/commands/{help-command.d.ts → help/index.d.ts} +2 -2
- package/dist/commands/help/index.d.ts.map +1 -0
- package/dist/commands/{help-command.js → help/index.js} +1 -1
- package/dist/commands/history/index.d.ts +3 -0
- package/dist/commands/history/index.d.ts.map +1 -0
- package/dist/commands/{history-command.js → history/index.js} +16 -100
- package/dist/commands/history/types.d.ts +11 -0
- package/dist/commands/history/types.d.ts.map +1 -0
- package/dist/commands/history/types.js +1 -0
- package/dist/commands/history/utils.d.ts +4 -0
- package/dist/commands/history/utils.d.ts.map +1 -0
- package/dist/commands/history/utils.js +86 -0
- package/dist/commands/init/index.d.ts +3 -0
- package/dist/commands/init/index.d.ts.map +1 -0
- package/dist/commands/{init-command.js → init/index.js} +16 -7
- package/dist/commands/init-project/index.d.ts +3 -0
- package/dist/commands/init-project/index.d.ts.map +1 -0
- package/dist/commands/init-project/index.js +51 -0
- package/dist/commands/init-project/utils.d.ts +9 -0
- package/dist/commands/init-project/utils.d.ts.map +1 -0
- package/dist/commands/init-project/utils.js +43 -0
- package/dist/commands/list-directories/index.d.ts +3 -0
- package/dist/commands/list-directories/index.d.ts.map +1 -0
- package/dist/commands/{list-directories-command.js → list-directories/index.js} +1 -1
- package/dist/commands/list-tools/index.d.ts +3 -0
- package/dist/commands/list-tools/index.d.ts.map +1 -0
- package/dist/commands/{list-tools-command.js → list-tools/index.js} +4 -16
- package/dist/commands/manager.d.ts +2 -2
- package/dist/commands/manager.d.ts.map +1 -1
- package/dist/commands/manager.js +35 -43
- package/dist/commands/model/index.d.ts +3 -0
- package/dist/commands/model/index.d.ts.map +1 -0
- package/dist/commands/{model-command.js → model/index.js} +15 -52
- package/dist/commands/model/utils.d.ts +3 -0
- package/dist/commands/model/utils.d.ts.map +1 -0
- package/dist/commands/model/utils.js +5 -0
- package/dist/commands/{paste-command.d.ts → paste/index.d.ts} +2 -2
- package/dist/commands/paste/index.d.ts.map +1 -0
- package/dist/commands/{paste-command.js → paste/index.js} +6 -111
- package/dist/commands/paste/utils.d.ts +5 -0
- package/dist/commands/paste/utils.d.ts.map +1 -0
- package/dist/commands/paste/utils.js +86 -0
- package/dist/commands/pickup/index.d.ts +3 -0
- package/dist/commands/pickup/index.d.ts.map +1 -0
- package/dist/commands/pickup/index.js +138 -0
- package/dist/commands/pickup/types.d.ts +6 -0
- package/dist/commands/pickup/types.d.ts.map +1 -0
- package/dist/commands/pickup/types.js +1 -0
- package/dist/commands/pickup/utils.d.ts +7 -0
- package/dist/commands/pickup/utils.d.ts.map +1 -0
- package/dist/commands/pickup/utils.js +56 -0
- package/dist/commands/prompt/index.d.ts +5 -0
- package/dist/commands/prompt/index.d.ts.map +1 -0
- package/dist/commands/prompt/index.js +122 -0
- package/dist/commands/prompt/types.d.ts +15 -0
- package/dist/commands/prompt/types.d.ts.map +1 -0
- package/dist/commands/prompt/types.js +1 -0
- package/dist/commands/prompt/utils.d.ts +12 -0
- package/dist/commands/prompt/utils.d.ts.map +1 -0
- package/dist/commands/prompt/utils.js +107 -0
- package/dist/commands/remove-directory/index.d.ts +3 -0
- package/dist/commands/remove-directory/index.d.ts.map +1 -0
- package/dist/commands/{remove-directory-command.js → remove-directory/index.js} +2 -2
- package/dist/commands/reset/index.d.ts +3 -0
- package/dist/commands/reset/index.d.ts.map +1 -0
- package/dist/commands/{reset-command.js → reset/index.js} +7 -2
- package/dist/commands/reset/types.d.ts +1 -0
- package/dist/commands/reset/types.d.ts.map +1 -0
- package/dist/commands/reset/types.js +3 -0
- package/dist/commands/resources/index.d.ts +3 -0
- package/dist/commands/resources/index.d.ts.map +1 -0
- package/dist/commands/resources/index.js +84 -0
- package/dist/commands/review/index.d.ts +3 -0
- package/dist/commands/review/index.d.ts.map +1 -0
- package/dist/commands/review/index.js +126 -0
- package/dist/commands/review/types.d.ts +12 -0
- package/dist/commands/review/types.d.ts.map +1 -0
- package/dist/commands/review/types.js +1 -0
- package/dist/commands/review/utils.d.ts +4 -0
- package/dist/commands/review/utils.d.ts.map +1 -0
- package/dist/commands/review/utils.js +87 -0
- package/dist/commands/save/index.d.ts +3 -0
- package/dist/commands/save/index.d.ts.map +1 -0
- package/dist/commands/{save-command.js → save/index.js} +3 -3
- package/dist/commands/session/index.d.ts +3 -0
- package/dist/commands/session/index.d.ts.map +1 -0
- package/dist/commands/session/index.js +230 -0
- package/dist/commands/session/types.d.ts +20 -0
- package/dist/commands/session/types.d.ts.map +1 -0
- package/dist/commands/session/types.js +7 -0
- package/dist/commands/share/html-renderer.d.ts +25 -0
- package/dist/commands/share/html-renderer.d.ts.map +1 -0
- package/dist/commands/share/html-renderer.js +384 -0
- package/dist/commands/share/index.d.ts +3 -0
- package/dist/commands/share/index.d.ts.map +1 -0
- package/dist/commands/share/index.js +122 -0
- package/dist/commands/shell/index.d.ts +3 -0
- package/dist/commands/shell/index.d.ts.map +1 -0
- package/dist/commands/{shell-command.js → shell/index.js} +3 -3
- package/dist/commands/types.d.ts +2 -2
- package/dist/commands/types.d.ts.map +1 -1
- package/dist/config.d.ts +25 -7
- package/dist/config.d.ts.map +1 -1
- package/dist/config.js +45 -20
- package/dist/dedent.d.ts.map +1 -1
- package/dist/dedent.js +7 -7
- package/dist/execution/index.d.ts +1 -0
- package/dist/execution/index.d.ts.map +1 -1
- package/dist/execution/index.js +60 -64
- package/dist/formatting.d.ts +27 -0
- package/dist/formatting.d.ts.map +1 -1
- package/dist/formatting.js +40 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +194 -95
- package/dist/logger.d.ts.map +1 -1
- package/dist/logger.js +4 -11
- package/dist/mentions.d.ts.map +1 -1
- package/dist/mentions.js +3 -53
- package/dist/middleware/audit-message.d.ts +2 -2
- package/dist/middleware/audit-message.d.ts.map +1 -1
- package/dist/middleware/audit-message.js +40 -2
- package/dist/middleware/cache.d.ts +2 -2
- package/dist/middleware/cache.d.ts.map +1 -1
- package/dist/middleware/cache.js +111 -27
- package/dist/middleware/rate-limit.d.ts +2 -2
- package/dist/middleware/rate-limit.d.ts.map +1 -1
- package/dist/middleware/rate-limit.js +1 -0
- package/dist/models/ai-config.d.ts.map +1 -1
- package/dist/models/ai-config.js +46 -29
- package/dist/models/anthropic-provider.d.ts +14 -13
- package/dist/models/anthropic-provider.d.ts.map +1 -1
- package/dist/models/deepseek-provider.d.ts +9 -8
- package/dist/models/deepseek-provider.d.ts.map +1 -1
- package/dist/models/google-provider.d.ts +10 -9
- package/dist/models/google-provider.d.ts.map +1 -1
- package/dist/models/groq-provider.d.ts +8 -7
- package/dist/models/groq-provider.d.ts.map +1 -1
- package/dist/models/manager.d.ts +7 -4
- package/dist/models/manager.d.ts.map +1 -1
- package/dist/models/manager.js +5 -25
- package/dist/models/openai-provider.d.ts +14 -10
- package/dist/models/openai-provider.d.ts.map +1 -1
- package/dist/models/openai-provider.js +39 -0
- package/dist/models/opencode-zen-provider.d.ts +24 -0
- package/dist/models/opencode-zen-provider.d.ts.map +1 -0
- package/dist/models/opencode-zen-provider.js +94 -0
- package/dist/models/openrouter-provider.d.ts +35 -29
- package/dist/models/openrouter-provider.d.ts.map +1 -1
- package/dist/models/openrouter-provider.js +108 -80
- package/dist/models/providers.d.ts +4 -4
- package/dist/models/providers.d.ts.map +1 -1
- package/dist/models/providers.js +7 -1
- package/dist/models/xai-provider.d.ts +9 -8
- package/dist/models/xai-provider.d.ts.map +1 -1
- package/dist/prompts/manager.d.ts +1 -1
- package/dist/prompts/manager.d.ts.map +1 -1
- package/dist/prompts/manager.js +1 -1
- package/dist/prompts.d.ts +12 -2
- package/dist/prompts.d.ts.map +1 -1
- package/dist/prompts.js +74 -411
- package/dist/repl/project-status.d.ts +19 -0
- package/dist/repl/project-status.d.ts.map +1 -0
- package/dist/repl/project-status.js +78 -0
- package/dist/repl-new.d.ts +18 -4
- package/dist/repl-new.d.ts.map +1 -1
- package/dist/repl-new.js +256 -43
- package/dist/{messages.d.ts → sessions/manager.d.ts} +10 -4
- package/dist/sessions/manager.d.ts.map +1 -0
- package/dist/{messages.js → sessions/manager.js} +62 -14
- package/dist/skills.d.ts +0 -4
- package/dist/skills.d.ts.map +1 -1
- package/dist/skills.js +100 -59
- package/dist/stdin.d.ts +9 -0
- package/dist/stdin.d.ts.map +1 -0
- package/dist/stdin.js +26 -0
- package/dist/terminal/control.d.ts +1 -0
- package/dist/terminal/control.d.ts.map +1 -1
- package/dist/terminal/control.js +29 -6
- package/dist/terminal/formatting.d.ts +1 -2
- package/dist/terminal/formatting.d.ts.map +1 -1
- package/dist/terminal/formatting.js +1 -2
- package/dist/terminal/keys.d.ts +211 -0
- package/dist/terminal/keys.d.ts.map +1 -0
- package/dist/terminal/keys.js +546 -0
- package/dist/terminal/segmenter.d.ts +6 -0
- package/dist/terminal/segmenter.d.ts.map +1 -0
- package/dist/terminal/segmenter.js +11 -0
- package/dist/terminal/select-prompt.d.ts.map +1 -1
- package/dist/terminal/select-prompt.js +9 -21
- package/dist/terminal/string-width.d.ts.map +1 -1
- package/dist/terminal/string-width.js +40 -21
- package/dist/terminal/strip-ansi.d.ts.map +1 -1
- package/dist/terminal/strip-ansi.js +9 -15
- package/dist/tokens/tracker.d.ts.map +1 -1
- package/dist/tokens/tracker.js +58 -16
- package/dist/tools/bash.d.ts +9 -11
- package/dist/tools/bash.d.ts.map +1 -1
- package/dist/tools/bash.js +104 -123
- package/dist/tools/directory-tree.d.ts +9 -7
- package/dist/tools/directory-tree.d.ts.map +1 -1
- package/dist/tools/directory-tree.js +89 -70
- package/dist/tools/dynamic-tool-loader.d.ts +22 -4
- package/dist/tools/dynamic-tool-loader.d.ts.map +1 -1
- package/dist/tools/dynamic-tool-loader.js +39 -44
- package/dist/tools/edit-file.d.ts +6 -16
- package/dist/tools/edit-file.d.ts.map +1 -1
- package/dist/tools/edit-file.js +19 -76
- package/dist/tools/glob.d.ts +15 -16
- package/dist/tools/glob.d.ts.map +1 -1
- package/dist/tools/glob.js +77 -119
- package/dist/tools/grep.d.ts +19 -22
- package/dist/tools/grep.d.ts.map +1 -1
- package/dist/tools/grep.js +61 -108
- package/dist/tools/index.d.ts +200 -179
- package/dist/tools/index.d.ts.map +1 -1
- package/dist/tools/index.js +17 -315
- package/dist/tools/ls.d.ts +26 -0
- package/dist/tools/ls.d.ts.map +1 -0
- package/dist/tools/ls.js +80 -0
- package/dist/tools/read-file.d.ts +15 -15
- package/dist/tools/read-file.d.ts.map +1 -1
- package/dist/tools/read-file.js +49 -82
- package/dist/tools/save-file.d.ts +4 -4
- package/dist/tools/save-file.d.ts.map +1 -1
- package/dist/tools/save-file.js +37 -66
- package/dist/tools/think.d.ts +4 -4
- package/dist/tools/think.d.ts.map +1 -1
- package/dist/tools/think.js +9 -38
- package/dist/tools/types.d.ts +5 -25
- package/dist/tools/types.d.ts.map +1 -1
- package/dist/tools/types.js +0 -9
- package/dist/tui/autocomplete/attachment-provider.d.ts +18 -0
- package/dist/tui/autocomplete/attachment-provider.d.ts.map +1 -0
- package/dist/tui/autocomplete/attachment-provider.js +159 -0
- package/dist/tui/autocomplete/base-provider.d.ts +17 -0
- package/dist/tui/autocomplete/base-provider.d.ts.map +1 -0
- package/dist/tui/autocomplete/base-provider.js +1 -0
- package/dist/tui/autocomplete/combined-provider.d.ts +20 -0
- package/dist/tui/autocomplete/combined-provider.d.ts.map +1 -0
- package/dist/tui/autocomplete/combined-provider.js +61 -0
- package/dist/tui/autocomplete/command-provider.d.ts +20 -0
- package/dist/tui/autocomplete/command-provider.d.ts.map +1 -0
- package/dist/tui/autocomplete/command-provider.js +90 -0
- package/dist/tui/autocomplete/file-search-provider.d.ts +16 -0
- package/dist/tui/autocomplete/file-search-provider.d.ts.map +1 -0
- package/dist/tui/autocomplete/file-search-provider.js +123 -0
- package/dist/tui/autocomplete/path-provider.d.ts +21 -0
- package/dist/tui/autocomplete/path-provider.d.ts.map +1 -0
- package/dist/tui/autocomplete/path-provider.js +164 -0
- package/dist/tui/autocomplete/utils.d.ts +16 -0
- package/dist/tui/autocomplete/utils.d.ts.map +1 -0
- package/dist/tui/autocomplete/utils.js +137 -0
- package/dist/tui/autocomplete.d.ts +12 -43
- package/dist/tui/autocomplete.d.ts.map +1 -1
- package/dist/tui/autocomplete.js +20 -465
- package/dist/tui/components/box.d.ts.map +1 -1
- package/dist/tui/components/box.js +16 -10
- package/dist/tui/components/editor.d.ts +6 -2
- package/dist/tui/components/editor.d.ts.map +1 -1
- package/dist/tui/components/editor.js +166 -107
- package/dist/tui/components/footer.d.ts +20 -7
- package/dist/tui/components/footer.d.ts.map +1 -1
- package/dist/tui/components/footer.js +89 -196
- package/dist/tui/components/input.d.ts.map +1 -1
- package/dist/tui/components/input.js +8 -7
- package/dist/tui/components/loader.d.ts +2 -1
- package/dist/tui/components/loader.d.ts.map +1 -1
- package/dist/tui/components/loader.js +7 -2
- package/dist/tui/components/markdown.d.ts +5 -4
- package/dist/tui/components/markdown.d.ts.map +1 -1
- package/dist/tui/components/markdown.js +51 -40
- package/dist/tui/components/modal.d.ts.map +1 -1
- package/dist/tui/components/modal.js +9 -8
- package/dist/tui/components/notification.d.ts +28 -0
- package/dist/tui/components/notification.d.ts.map +1 -0
- package/dist/tui/components/notification.js +64 -0
- package/dist/tui/components/progress-bar.d.ts.map +1 -1
- package/dist/tui/components/progress-bar.js +3 -15
- package/dist/tui/components/select-list.d.ts +0 -15
- package/dist/tui/components/select-list.d.ts.map +1 -1
- package/dist/tui/components/select-list.js +5 -28
- package/dist/tui/components/tool-execution.d.ts +3 -6
- package/dist/tui/components/tool-execution.d.ts.map +1 -1
- package/dist/tui/components/tool-execution.js +26 -38
- package/dist/tui/components/welcome.d.ts +8 -1
- package/dist/tui/components/welcome.d.ts.map +1 -1
- package/dist/tui/components/welcome.js +45 -6
- package/dist/tui/editor-launcher.d.ts +13 -0
- package/dist/tui/editor-launcher.d.ts.map +1 -0
- package/dist/tui/editor-launcher.js +39 -0
- package/dist/tui/index.d.ts +7 -3
- package/dist/tui/index.d.ts.map +1 -1
- package/dist/tui/index.js +3 -2
- package/dist/tui/terminal.d.ts +29 -2
- package/dist/tui/terminal.d.ts.map +1 -1
- package/dist/tui/terminal.js +153 -28
- package/dist/tui/tui.d.ts +2 -0
- package/dist/tui/tui.d.ts.map +1 -1
- package/dist/tui/tui.js +39 -29
- package/dist/tui/utils.d.ts.map +1 -1
- package/dist/tui/utils.js +2 -3
- package/dist/utils/filesystem/security.d.ts.map +1 -1
- package/dist/utils/filesystem/security.js +4 -1
- package/dist/utils/yaml.d.ts +11 -0
- package/dist/utils/yaml.d.ts.map +1 -0
- package/dist/utils/yaml.js +207 -0
- package/dist/utils/zod.d.ts +1 -0
- package/dist/utils/zod.d.ts.map +1 -1
- package/dist/utils/zod.js +17 -0
- package/package.json +31 -29
- package/bin/acai-wrapper.js +0 -26
- package/dist/api/exa/index.d.ts +0 -177
- package/dist/api/exa/index.d.ts.map +0 -1
- package/dist/api/exa/index.js +0 -439
- package/dist/commands/add-directory-command.d.ts +0 -3
- package/dist/commands/add-directory-command.d.ts.map +0 -1
- package/dist/commands/application-log-command.d.ts +0 -3
- package/dist/commands/application-log-command.d.ts.map +0 -1
- package/dist/commands/application-log-command.js +0 -43
- package/dist/commands/clear-command.d.ts +0 -3
- package/dist/commands/clear-command.d.ts.map +0 -1
- package/dist/commands/compact-command.d.ts +0 -3
- package/dist/commands/compact-command.d.ts.map +0 -1
- package/dist/commands/compact-command.js +0 -55
- package/dist/commands/context-command.d.ts +0 -3
- package/dist/commands/context-command.d.ts.map +0 -1
- package/dist/commands/context-command.js +0 -124
- package/dist/commands/copy-command.d.ts +0 -3
- package/dist/commands/copy-command.d.ts.map +0 -1
- package/dist/commands/edit-command.d.ts +0 -3
- package/dist/commands/edit-command.d.ts.map +0 -1
- package/dist/commands/edit-command.js +0 -42
- package/dist/commands/edit-prompt-command.d.ts +0 -3
- package/dist/commands/edit-prompt-command.d.ts.map +0 -1
- package/dist/commands/edit-prompt-command.js +0 -36
- package/dist/commands/exit-command.d.ts.map +0 -1
- package/dist/commands/exit-command.js +0 -30
- package/dist/commands/files-command.d.ts +0 -3
- package/dist/commands/files-command.d.ts.map +0 -1
- package/dist/commands/files-command.js +0 -68
- package/dist/commands/generate-rules-command.d.ts +0 -3
- package/dist/commands/generate-rules-command.d.ts.map +0 -1
- package/dist/commands/handoff-command.d.ts +0 -3
- package/dist/commands/handoff-command.d.ts.map +0 -1
- package/dist/commands/health-command.d.ts +0 -4
- package/dist/commands/health-command.d.ts.map +0 -1
- package/dist/commands/health-command.js +0 -118
- package/dist/commands/help-command.d.ts.map +0 -1
- package/dist/commands/history-command.d.ts +0 -3
- package/dist/commands/history-command.d.ts.map +0 -1
- package/dist/commands/init-command.d.ts +0 -3
- package/dist/commands/init-command.d.ts.map +0 -1
- package/dist/commands/last-log-command.d.ts +0 -3
- package/dist/commands/last-log-command.d.ts.map +0 -1
- package/dist/commands/last-log-command.js +0 -71
- package/dist/commands/list-directories-command.d.ts +0 -3
- package/dist/commands/list-directories-command.d.ts.map +0 -1
- package/dist/commands/list-tools-command.d.ts +0 -3
- package/dist/commands/list-tools-command.d.ts.map +0 -1
- package/dist/commands/model-command.d.ts +0 -3
- package/dist/commands/model-command.d.ts.map +0 -1
- package/dist/commands/paste-command.d.ts.map +0 -1
- package/dist/commands/pickup-command.d.ts +0 -3
- package/dist/commands/pickup-command.d.ts.map +0 -1
- package/dist/commands/pickup-command.js +0 -109
- package/dist/commands/prompt-command.d.ts +0 -21
- package/dist/commands/prompt-command.d.ts.map +0 -1
- package/dist/commands/prompt-command.js +0 -258
- package/dist/commands/remove-directory-command.d.ts +0 -3
- package/dist/commands/remove-directory-command.d.ts.map +0 -1
- package/dist/commands/reset-command.d.ts +0 -3
- package/dist/commands/reset-command.d.ts.map +0 -1
- package/dist/commands/rules-command.d.ts +0 -3
- package/dist/commands/rules-command.d.ts.map +0 -1
- package/dist/commands/rules-command.js +0 -73
- package/dist/commands/save-command.d.ts +0 -3
- package/dist/commands/save-command.d.ts.map +0 -1
- package/dist/commands/shell-command.d.ts +0 -3
- package/dist/commands/shell-command.d.ts.map +0 -1
- package/dist/commands/usage-command.d.ts +0 -3
- package/dist/commands/usage-command.d.ts.map +0 -1
- package/dist/commands/usage-command.js +0 -31
- package/dist/messages.d.ts.map +0 -1
- package/dist/repl/project-status-line.d.ts +0 -3
- package/dist/repl/project-status-line.d.ts.map +0 -1
- package/dist/repl/project-status-line.js +0 -61
- package/dist/repl/tool-call-repair.d.ts +0 -4
- package/dist/repl/tool-call-repair.d.ts.map +0 -1
- package/dist/repl/tool-call-repair.js +0 -54
- package/dist/terminal/markdown.d.ts +0 -2
- package/dist/terminal/markdown.d.ts.map +0 -1
- package/dist/terminal/markdown.js +0 -120
- package/dist/tokens/threshold.d.ts +0 -20
- package/dist/tokens/threshold.d.ts.map +0 -1
- package/dist/tokens/threshold.js +0 -67
- package/dist/tools/advanced-edit-file.d.ts +0 -69
- package/dist/tools/advanced-edit-file.d.ts.map +0 -1
- package/dist/tools/advanced-edit-file.js +0 -285
- package/dist/tools/agent.d.ts +0 -29
- package/dist/tools/agent.d.ts.map +0 -1
- package/dist/tools/agent.js +0 -117
- package/dist/tools/batch.d.ts +0 -34
- package/dist/tools/batch.d.ts.map +0 -1
- package/dist/tools/batch.js +0 -174
- package/dist/tools/code-interpreter.d.ts +0 -25
- package/dist/tools/code-interpreter.d.ts.map +0 -1
- package/dist/tools/code-interpreter.js +0 -183
- package/dist/tools/delete-file.d.ts +0 -24
- package/dist/tools/delete-file.d.ts.map +0 -1
- package/dist/tools/delete-file.js +0 -77
- package/dist/tools/dynamic-tool-parser.d.ts +0 -21
- package/dist/tools/dynamic-tool-parser.d.ts.map +0 -1
- package/dist/tools/dynamic-tool-parser.js +0 -22
- package/dist/tools/llm-edit-fixer.d.ts +0 -24
- package/dist/tools/llm-edit-fixer.d.ts.map +0 -1
- package/dist/tools/llm-edit-fixer.js +0 -136
- package/dist/tools/move-file.d.ts +0 -26
- package/dist/tools/move-file.d.ts.map +0 -1
- package/dist/tools/move-file.js +0 -65
- package/dist/tools/read-multiple-files.d.ts +0 -26
- package/dist/tools/read-multiple-files.d.ts.map +0 -1
- package/dist/tools/read-multiple-files.js +0 -196
- package/dist/tools/web-fetch.d.ts +0 -56
- package/dist/tools/web-fetch.d.ts.map +0 -1
- package/dist/tools/web-fetch.js +0 -247
- package/dist/tools/web-search.d.ts +0 -23
- package/dist/tools/web-search.d.ts.map +0 -1
- package/dist/tools/web-search.js +0 -148
- package/dist/tui/components/prompt-status.d.ts +0 -17
- package/dist/tui/components/prompt-status.d.ts.map +0 -1
- package/dist/tui/components/prompt-status.js +0 -26
|
@@ -0,0 +1,230 @@
|
|
|
1
|
+
import { tool } from "ai";
|
|
2
|
+
import { formatDate, formatDuration, formatNumber, formatPercentage, } from "../../formatting.js";
|
|
3
|
+
import { logger } from "../../logger.js";
|
|
4
|
+
import { systemPrompt } from "../../prompts.js";
|
|
5
|
+
import { getTerminalSize } from "../../terminal/control.js";
|
|
6
|
+
import { initTools, } from "../../tools/index.js";
|
|
7
|
+
import { prepareTools } from "../../tools/utils.js";
|
|
8
|
+
import { Container, Modal, ModalText, TableComponent, } from "../../tui/index.js";
|
|
9
|
+
import { countMessageTokens } from "./types.js";
|
|
10
|
+
export function sessionCommand({ config, tokenCounter, modelManager, sessionManager: messageHistory, workspace, tokenTracker, }) {
|
|
11
|
+
return {
|
|
12
|
+
command: "/session",
|
|
13
|
+
description: "Show comprehensive session information including usage, context, and costs",
|
|
14
|
+
getSubCommands: () => Promise.resolve([]),
|
|
15
|
+
async handle(_args, { tui, editor }) {
|
|
16
|
+
const meta = modelManager.getModelMetadata("repl");
|
|
17
|
+
const window = meta.contextWindow;
|
|
18
|
+
const projectConfig = await config.getConfig();
|
|
19
|
+
const sysResult = await systemPrompt({
|
|
20
|
+
activeTools: projectConfig.tools.activeTools,
|
|
21
|
+
allowedDirs: workspace.allowedDirs,
|
|
22
|
+
includeRules: true,
|
|
23
|
+
});
|
|
24
|
+
const systemPromptTokens = tokenCounter.count(sysResult.prompt);
|
|
25
|
+
const systemPromptBreakdown = {
|
|
26
|
+
core: tokenCounter.count(sysResult.components.core),
|
|
27
|
+
userAgentsMd: tokenCounter.count(sysResult.components.userAgentsMd),
|
|
28
|
+
cwdAgentsMd: tokenCounter.count(sysResult.components.cwdAgentsMd),
|
|
29
|
+
learnedRules: tokenCounter.count(sysResult.components.learnedRules),
|
|
30
|
+
skills: tokenCounter.count(sysResult.components.skills),
|
|
31
|
+
};
|
|
32
|
+
let toolsTokens = 0;
|
|
33
|
+
try {
|
|
34
|
+
const tools = await initTools({
|
|
35
|
+
workspace,
|
|
36
|
+
});
|
|
37
|
+
const toolDefs = Object.fromEntries(Object.entries(tools).map((t) => [
|
|
38
|
+
t[0],
|
|
39
|
+
// biome-ignore lint/suspicious/noExplicitAny: temporary
|
|
40
|
+
tool(t[1].toolDef),
|
|
41
|
+
]));
|
|
42
|
+
const toolNames = JSON.stringify(prepareTools(toolDefs));
|
|
43
|
+
toolsTokens = tokenCounter.count(toolNames);
|
|
44
|
+
}
|
|
45
|
+
catch (error) {
|
|
46
|
+
logger.info({ error: error instanceof Error ? error.message : String(error) }, "Failed to calculate tools tokens");
|
|
47
|
+
toolsTokens = 0;
|
|
48
|
+
}
|
|
49
|
+
const messages = messageHistory.get();
|
|
50
|
+
const messagesTokens = countMessageTokens(messages, tokenCounter);
|
|
51
|
+
const used = systemPromptTokens + toolsTokens + messagesTokens;
|
|
52
|
+
const free = Math.max(0, window - used);
|
|
53
|
+
const usedPercentage = window > 0 ? (used / window) * 100 : 0;
|
|
54
|
+
const breakdown = {
|
|
55
|
+
systemPrompt: systemPromptTokens,
|
|
56
|
+
systemPromptBreakdown,
|
|
57
|
+
tools: toolsTokens,
|
|
58
|
+
messages: messagesTokens,
|
|
59
|
+
totalUsed: used,
|
|
60
|
+
window,
|
|
61
|
+
free,
|
|
62
|
+
};
|
|
63
|
+
const sessionId = messageHistory.getSessionId();
|
|
64
|
+
const sessionFile = `message-history-${sessionId}.json`;
|
|
65
|
+
const modelId = messageHistory.getModelId() || "Not set";
|
|
66
|
+
const title = messageHistory.getTitle() || "No title";
|
|
67
|
+
const createdAt = messageHistory.getCreatedAt();
|
|
68
|
+
const updatedAt = messageHistory.getUpdatedAt();
|
|
69
|
+
const duration = formatDuration(updatedAt.getTime() - createdAt.getTime());
|
|
70
|
+
const messageCount = messages.length;
|
|
71
|
+
const userMessages = messages.filter((m) => m.role === "user").length;
|
|
72
|
+
const assistantMessages = messages.filter((m) => m.role === "assistant").length;
|
|
73
|
+
const toolMessages = messages.filter((m) => m.role === "tool").length;
|
|
74
|
+
const totalUsage = tokenTracker.getTotalUsage();
|
|
75
|
+
const inputTokens = totalUsage.inputTokens ?? 0;
|
|
76
|
+
const outputTokens = totalUsage.outputTokens ?? 0;
|
|
77
|
+
const totalTokens = inputTokens + outputTokens;
|
|
78
|
+
const inputCost = (meta.costPerInputToken ?? 0) * inputTokens;
|
|
79
|
+
const outputCost = (meta.costPerOutputToken ?? 0) * outputTokens;
|
|
80
|
+
const totalCost = inputCost + outputCost;
|
|
81
|
+
const usageBreakdown = tokenTracker.getUsageBreakdown();
|
|
82
|
+
const { columns } = getTerminalSize();
|
|
83
|
+
const modalContent = new Container();
|
|
84
|
+
modalContent.addChild(new ModalText("Session Overview", 0, 1));
|
|
85
|
+
modalContent.addChild(new ModalText("─".repeat(columns - 10), 0, 1));
|
|
86
|
+
const metadataTable = [
|
|
87
|
+
["Session ID", sessionId],
|
|
88
|
+
["Session File", sessionFile],
|
|
89
|
+
["Model", modelId],
|
|
90
|
+
["Title", title],
|
|
91
|
+
["Duration", duration],
|
|
92
|
+
["Started", formatDate(createdAt)],
|
|
93
|
+
["Last Updated", formatDate(updatedAt)],
|
|
94
|
+
];
|
|
95
|
+
modalContent.addChild(new TableComponent(metadataTable, {
|
|
96
|
+
headers: ["Property", "Value"],
|
|
97
|
+
colWidths: [25, 75],
|
|
98
|
+
}));
|
|
99
|
+
modalContent.addChild(new ModalText("", 0, 1));
|
|
100
|
+
modalContent.addChild(new ModalText("Message Statistics", 0, 1));
|
|
101
|
+
const messageStatsTable = [
|
|
102
|
+
["Total Messages", String(messageCount)],
|
|
103
|
+
["User Messages", String(userMessages)],
|
|
104
|
+
["Assistant Messages", String(assistantMessages)],
|
|
105
|
+
["Tool Messages", String(toolMessages)],
|
|
106
|
+
];
|
|
107
|
+
modalContent.addChild(new TableComponent(messageStatsTable, {
|
|
108
|
+
headers: ["Type", "Count"],
|
|
109
|
+
}));
|
|
110
|
+
modalContent.addChild(new ModalText("", 0, 1));
|
|
111
|
+
modalContent.addChild(new ModalText("Context Usage", 0, 1));
|
|
112
|
+
const contextTable = [
|
|
113
|
+
[
|
|
114
|
+
"System Prompt",
|
|
115
|
+
formatNumber(breakdown.systemPrompt),
|
|
116
|
+
formatPercentage(breakdown.systemPrompt, window),
|
|
117
|
+
],
|
|
118
|
+
[
|
|
119
|
+
" Core Instructions",
|
|
120
|
+
formatNumber(breakdown.systemPromptBreakdown.core),
|
|
121
|
+
formatPercentage(breakdown.systemPromptBreakdown.core, window),
|
|
122
|
+
],
|
|
123
|
+
[
|
|
124
|
+
" ~/.acai/AGENTS.md",
|
|
125
|
+
formatNumber(breakdown.systemPromptBreakdown.userAgentsMd),
|
|
126
|
+
formatPercentage(breakdown.systemPromptBreakdown.userAgentsMd, window),
|
|
127
|
+
],
|
|
128
|
+
[
|
|
129
|
+
" ./AGENTS.md",
|
|
130
|
+
formatNumber(breakdown.systemPromptBreakdown.cwdAgentsMd),
|
|
131
|
+
formatPercentage(breakdown.systemPromptBreakdown.cwdAgentsMd, window),
|
|
132
|
+
],
|
|
133
|
+
[
|
|
134
|
+
" Learned Rules",
|
|
135
|
+
formatNumber(breakdown.systemPromptBreakdown.learnedRules),
|
|
136
|
+
formatPercentage(breakdown.systemPromptBreakdown.learnedRules, window),
|
|
137
|
+
],
|
|
138
|
+
[
|
|
139
|
+
" Skills",
|
|
140
|
+
formatNumber(breakdown.systemPromptBreakdown.skills),
|
|
141
|
+
formatPercentage(breakdown.systemPromptBreakdown.skills, window),
|
|
142
|
+
],
|
|
143
|
+
[
|
|
144
|
+
"System Tools",
|
|
145
|
+
formatNumber(breakdown.tools),
|
|
146
|
+
formatPercentage(breakdown.tools, window),
|
|
147
|
+
],
|
|
148
|
+
[
|
|
149
|
+
"Messages",
|
|
150
|
+
formatNumber(breakdown.messages),
|
|
151
|
+
formatPercentage(breakdown.messages, window),
|
|
152
|
+
],
|
|
153
|
+
[
|
|
154
|
+
"Free Space",
|
|
155
|
+
formatNumber(breakdown.free),
|
|
156
|
+
formatPercentage(breakdown.free, window),
|
|
157
|
+
],
|
|
158
|
+
[
|
|
159
|
+
"Total Used",
|
|
160
|
+
formatNumber(breakdown.totalUsed),
|
|
161
|
+
formatPercentage(breakdown.totalUsed, window),
|
|
162
|
+
],
|
|
163
|
+
["Context Window", formatNumber(window), "100%"],
|
|
164
|
+
];
|
|
165
|
+
modalContent.addChild(new TableComponent(contextTable, {
|
|
166
|
+
headers: ["Section", "Tokens", "Percent"],
|
|
167
|
+
}));
|
|
168
|
+
const barWidth = Math.max(20, Math.min(50, columns - 40));
|
|
169
|
+
const filled = Math.floor((usedPercentage / 100) * barWidth);
|
|
170
|
+
const empty = barWidth - filled;
|
|
171
|
+
const progressBar = `[${"█".repeat(filled)}${"░".repeat(empty)}] ${usedPercentage.toFixed(1)}%`;
|
|
172
|
+
modalContent.addChild(new ModalText("", 0, 1));
|
|
173
|
+
modalContent.addChild(new ModalText(progressBar, 0, 1));
|
|
174
|
+
modalContent.addChild(new ModalText("", 0, 1));
|
|
175
|
+
modalContent.addChild(new ModalText("Token Usage & Costs", 0, 1));
|
|
176
|
+
const formatCost = (cost) => {
|
|
177
|
+
if (cost === 0)
|
|
178
|
+
return "$0.00";
|
|
179
|
+
if (cost < 0.01)
|
|
180
|
+
return `$${cost.toFixed(6)}`;
|
|
181
|
+
if (cost < 1)
|
|
182
|
+
return `$${cost.toFixed(4)}`;
|
|
183
|
+
return `$${cost.toFixed(2)}`;
|
|
184
|
+
};
|
|
185
|
+
const tokenTable = [
|
|
186
|
+
[
|
|
187
|
+
"Input Tokens",
|
|
188
|
+
formatNumber(inputTokens),
|
|
189
|
+
formatCost(inputCost),
|
|
190
|
+
meta.costPerInputToken
|
|
191
|
+
? `$${meta.costPerInputToken.toFixed(6)}/token`
|
|
192
|
+
: "N/A",
|
|
193
|
+
],
|
|
194
|
+
[
|
|
195
|
+
"Output Tokens",
|
|
196
|
+
formatNumber(outputTokens),
|
|
197
|
+
formatCost(outputCost),
|
|
198
|
+
meta.costPerOutputToken
|
|
199
|
+
? `$${meta.costPerOutputToken.toFixed(6)}/token`
|
|
200
|
+
: "N/A",
|
|
201
|
+
],
|
|
202
|
+
["Total Tokens", formatNumber(totalTokens), formatCost(totalCost), ""],
|
|
203
|
+
];
|
|
204
|
+
modalContent.addChild(new TableComponent(tokenTable, {
|
|
205
|
+
headers: ["Type", "Tokens", "Cost", "Rate"],
|
|
206
|
+
}));
|
|
207
|
+
modalContent.addChild(new ModalText("", 0, 1));
|
|
208
|
+
if (Object.keys(usageBreakdown).length > 0) {
|
|
209
|
+
modalContent.addChild(new ModalText("Usage by Application", 0, 1));
|
|
210
|
+
const usageEntries = Object.entries(usageBreakdown);
|
|
211
|
+
const usageTable = usageEntries.map(([app, tokens]) => [
|
|
212
|
+
app,
|
|
213
|
+
formatNumber(tokens),
|
|
214
|
+
]);
|
|
215
|
+
modalContent.addChild(new TableComponent(usageTable, {
|
|
216
|
+
headers: ["Application", "Tokens"],
|
|
217
|
+
}));
|
|
218
|
+
}
|
|
219
|
+
else {
|
|
220
|
+
modalContent.addChild(new ModalText("No usage data available", 0, 1));
|
|
221
|
+
}
|
|
222
|
+
const modal = new Modal("Session Information", modalContent, true, () => {
|
|
223
|
+
editor.setText("");
|
|
224
|
+
tui.requestRender();
|
|
225
|
+
});
|
|
226
|
+
tui.showModal(modal);
|
|
227
|
+
return "continue";
|
|
228
|
+
},
|
|
229
|
+
};
|
|
230
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import type { ModelMessage } from "ai";
|
|
2
|
+
export type Breakdown = {
|
|
3
|
+
systemPrompt: number;
|
|
4
|
+
systemPromptBreakdown: {
|
|
5
|
+
core: number;
|
|
6
|
+
userAgentsMd: number;
|
|
7
|
+
cwdAgentsMd: number;
|
|
8
|
+
learnedRules: number;
|
|
9
|
+
skills: number;
|
|
10
|
+
};
|
|
11
|
+
tools: number;
|
|
12
|
+
messages: number;
|
|
13
|
+
totalUsed: number;
|
|
14
|
+
window: number;
|
|
15
|
+
free: number;
|
|
16
|
+
};
|
|
17
|
+
export declare function countMessageTokens(messages: ModelMessage[], counter: {
|
|
18
|
+
count: (s: string) => number;
|
|
19
|
+
}): number;
|
|
20
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../source/commands/session/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,IAAI,CAAC;AAEvC,MAAM,MAAM,SAAS,GAAG;IACtB,YAAY,EAAE,MAAM,CAAC;IACrB,qBAAqB,EAAE;QACrB,IAAI,EAAE,MAAM,CAAC;QACb,YAAY,EAAE,MAAM,CAAC;QACrB,WAAW,EAAE,MAAM,CAAC;QACpB,YAAY,EAAE,MAAM,CAAC;QACrB,MAAM,EAAE,MAAM,CAAC;KAChB,CAAC;IACF,KAAK,EAAE,MAAM,CAAC;IACd,QAAQ,EAAE,MAAM,CAAC;IACjB,SAAS,EAAE,MAAM,CAAC;IAClB,MAAM,EAAE,MAAM,CAAC;IACf,IAAI,EAAE,MAAM,CAAC;CACd,CAAC;AAEF,wBAAgB,kBAAkB,CAChC,QAAQ,EAAE,YAAY,EAAE,EACxB,OAAO,EAAE;IAAE,KAAK,EAAE,CAAC,CAAC,EAAE,MAAM,KAAK,MAAM,CAAA;CAAE,GACxC,MAAM,CAOR"}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import type { ModelMessage } from "ai";
|
|
2
|
+
export interface SessionData {
|
|
3
|
+
sessionId: string;
|
|
4
|
+
title: string;
|
|
5
|
+
modelId: string;
|
|
6
|
+
project: string;
|
|
7
|
+
createdAt: Date;
|
|
8
|
+
updatedAt: Date;
|
|
9
|
+
messages: ModelMessage[];
|
|
10
|
+
}
|
|
11
|
+
export declare function escapeHtml(text: string): string;
|
|
12
|
+
export declare function renderSessionHtml(session: SessionData): string;
|
|
13
|
+
export declare function getSessionData(sessionManager: {
|
|
14
|
+
get: () => ModelMessage[];
|
|
15
|
+
getSessionId: () => string;
|
|
16
|
+
getTitle: () => string;
|
|
17
|
+
getModelId: () => string;
|
|
18
|
+
getCreatedAt: () => Date;
|
|
19
|
+
getUpdatedAt: () => Date;
|
|
20
|
+
}, project?: string): SessionData;
|
|
21
|
+
export declare function estimateSessionSize(session: SessionData): {
|
|
22
|
+
messageCount: number;
|
|
23
|
+
contentSizeBytes: number;
|
|
24
|
+
};
|
|
25
|
+
//# sourceMappingURL=html-renderer.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"html-renderer.d.ts","sourceRoot":"","sources":["../../../source/commands/share/html-renderer.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,YAAY,EAA0C,MAAM,IAAI,CAAC;AAE/E,MAAM,WAAW,WAAW;IAC1B,SAAS,EAAE,MAAM,CAAC;IAClB,KAAK,EAAE,MAAM,CAAC;IACd,OAAO,EAAE,MAAM,CAAC;IAChB,OAAO,EAAE,MAAM,CAAC;IAChB,SAAS,EAAE,IAAI,CAAC;IAChB,SAAS,EAAE,IAAI,CAAC;IAChB,QAAQ,EAAE,YAAY,EAAE,CAAC;CAC1B;AAED,wBAAgB,UAAU,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAO/C;AAiJD,wBAAgB,iBAAiB,CAAC,OAAO,EAAE,WAAW,GAAG,MAAM,CAwO9D;AAED,wBAAgB,cAAc,CAC5B,cAAc,EAAE;IACd,GAAG,EAAE,MAAM,YAAY,EAAE,CAAC;IAC1B,YAAY,EAAE,MAAM,MAAM,CAAC;IAC3B,QAAQ,EAAE,MAAM,MAAM,CAAC;IACvB,UAAU,EAAE,MAAM,MAAM,CAAC;IACzB,YAAY,EAAE,MAAM,IAAI,CAAC;IACzB,YAAY,EAAE,MAAM,IAAI,CAAC;CAC1B,EACD,OAAO,CAAC,EAAE,MAAM,GACf,WAAW,CAUb;AAED,wBAAgB,mBAAmB,CAAC,OAAO,EAAE,WAAW,GAAG;IACzD,YAAY,EAAE,MAAM,CAAC;IACrB,gBAAgB,EAAE,MAAM,CAAC;CAC1B,CAMA"}
|
|
@@ -0,0 +1,384 @@
|
|
|
1
|
+
import { basename } from "node:path";
|
|
2
|
+
export function escapeHtml(text) {
|
|
3
|
+
return text
|
|
4
|
+
.replace(/&/g, "&")
|
|
5
|
+
.replace(/</g, "<")
|
|
6
|
+
.replace(/>/g, ">")
|
|
7
|
+
.replace(/"/g, """)
|
|
8
|
+
.replace(/'/g, "'");
|
|
9
|
+
}
|
|
10
|
+
function formatDate(date) {
|
|
11
|
+
return date.toLocaleString("en-US", {
|
|
12
|
+
year: "numeric",
|
|
13
|
+
month: "short",
|
|
14
|
+
day: "numeric",
|
|
15
|
+
hour: "2-digit",
|
|
16
|
+
minute: "2-digit",
|
|
17
|
+
});
|
|
18
|
+
}
|
|
19
|
+
function renderToolCall(toolCall) {
|
|
20
|
+
const toolName = escapeHtml(toolCall.toolName);
|
|
21
|
+
const input = escapeHtml(JSON.stringify(toolCall.input, null, 2));
|
|
22
|
+
return `
|
|
23
|
+
<div class="tool-call">
|
|
24
|
+
<div class="tool-header">
|
|
25
|
+
<span class="tool-icon">→</span>
|
|
26
|
+
<span class="tool-name">${toolName}</span>
|
|
27
|
+
</div>
|
|
28
|
+
<div class="tool-body">
|
|
29
|
+
<pre class="tool-args">${input}</pre>
|
|
30
|
+
</div>
|
|
31
|
+
</div>`;
|
|
32
|
+
}
|
|
33
|
+
function renderToolResult(toolResult) {
|
|
34
|
+
const toolName = escapeHtml(toolResult.toolName);
|
|
35
|
+
let resultContent = "";
|
|
36
|
+
const output = toolResult.output;
|
|
37
|
+
if (output.type === "text") {
|
|
38
|
+
resultContent = escapeHtml(output.value);
|
|
39
|
+
}
|
|
40
|
+
else if (output.type === "json") {
|
|
41
|
+
resultContent = escapeHtml(JSON.stringify(output.value, null, 2));
|
|
42
|
+
}
|
|
43
|
+
else if (output.type === "execution-denied") {
|
|
44
|
+
resultContent = output.reason
|
|
45
|
+
? `[Tool execution denied: ${escapeHtml(output.reason)}]`
|
|
46
|
+
: "[Tool execution denied]";
|
|
47
|
+
}
|
|
48
|
+
else if (output.type === "error-text") {
|
|
49
|
+
resultContent = `[Error: ${escapeHtml(output.value)}]`;
|
|
50
|
+
}
|
|
51
|
+
else if (output.type === "error-json") {
|
|
52
|
+
resultContent = `[Error: ${escapeHtml(JSON.stringify(output.value, null, 2))}]`;
|
|
53
|
+
}
|
|
54
|
+
else if (output.type === "content") {
|
|
55
|
+
const textParts = output.value.filter((part) => part.type === "text");
|
|
56
|
+
resultContent = textParts.map((part) => escapeHtml(part.text)).join("\n");
|
|
57
|
+
}
|
|
58
|
+
const truncated = resultContent.length > 5000
|
|
59
|
+
? `${resultContent.slice(0, 5000)}...\n[truncated]`
|
|
60
|
+
: resultContent;
|
|
61
|
+
return `
|
|
62
|
+
<div class="tool-result">
|
|
63
|
+
<div class="tool-header">
|
|
64
|
+
<span class="tool-icon">←</span>
|
|
65
|
+
<span class="tool-name">${toolName}</span>
|
|
66
|
+
</div>
|
|
67
|
+
<div class="tool-body">
|
|
68
|
+
<pre class="tool-output">${truncated}</pre>
|
|
69
|
+
</div>
|
|
70
|
+
</div>`;
|
|
71
|
+
}
|
|
72
|
+
function renderMessage(message) {
|
|
73
|
+
const role = message.role;
|
|
74
|
+
if (role === "system") {
|
|
75
|
+
const content = Array.isArray(message.content)
|
|
76
|
+
? message.content
|
|
77
|
+
.filter((p) => p.type === "text")
|
|
78
|
+
.map((p) => escapeHtml(p.text))
|
|
79
|
+
.join("\n")
|
|
80
|
+
: escapeHtml(String(message.content));
|
|
81
|
+
return `
|
|
82
|
+
<div class="message system">
|
|
83
|
+
<div class="role">system</div>
|
|
84
|
+
<div class="content">${content}</div>
|
|
85
|
+
</div>`;
|
|
86
|
+
}
|
|
87
|
+
if (role === "user") {
|
|
88
|
+
const content = message.content;
|
|
89
|
+
let textContent = "";
|
|
90
|
+
if (typeof content === "string") {
|
|
91
|
+
textContent = escapeHtml(content);
|
|
92
|
+
}
|
|
93
|
+
else if (Array.isArray(content)) {
|
|
94
|
+
textContent = content
|
|
95
|
+
.filter((p) => typeof p !== "string" && p.type === "text")
|
|
96
|
+
.map((p) => escapeHtml(p.text))
|
|
97
|
+
.join("\n");
|
|
98
|
+
}
|
|
99
|
+
return `
|
|
100
|
+
<div class="message user">
|
|
101
|
+
<div class="role">user</div>
|
|
102
|
+
<div class="content">${textContent}</div>
|
|
103
|
+
</div>`;
|
|
104
|
+
}
|
|
105
|
+
if (role === "assistant") {
|
|
106
|
+
const content = message.content;
|
|
107
|
+
let html = `<div class="message assistant"><div class="role">assistant</div>`;
|
|
108
|
+
if (typeof content === "string") {
|
|
109
|
+
html += `<div class="content">${escapeHtml(content)}</div>`;
|
|
110
|
+
}
|
|
111
|
+
else if (Array.isArray(content)) {
|
|
112
|
+
for (const part of content) {
|
|
113
|
+
if (part.type === "text" && part.text.trim()) {
|
|
114
|
+
html += `<div class="content">${escapeHtml(part.text)}</div>`;
|
|
115
|
+
}
|
|
116
|
+
else if (part.type === "tool-call") {
|
|
117
|
+
html += renderToolCall(part);
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
html += "</div>";
|
|
122
|
+
return html;
|
|
123
|
+
}
|
|
124
|
+
if (role === "tool") {
|
|
125
|
+
const parts = message.content;
|
|
126
|
+
let html = "";
|
|
127
|
+
for (const part of parts) {
|
|
128
|
+
if (part.type === "tool-result") {
|
|
129
|
+
html += renderToolResult(part);
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
return html;
|
|
133
|
+
}
|
|
134
|
+
return "";
|
|
135
|
+
}
|
|
136
|
+
export function renderSessionHtml(session) {
|
|
137
|
+
const title = escapeHtml(session.title || "Untitled Session");
|
|
138
|
+
const project = escapeHtml(session.project);
|
|
139
|
+
const modelId = escapeHtml(session.modelId);
|
|
140
|
+
const createdAt = formatDate(session.createdAt);
|
|
141
|
+
const updatedAt = formatDate(session.updatedAt);
|
|
142
|
+
const messagesHtml = session.messages.map(renderMessage).join("\n");
|
|
143
|
+
return `<!DOCTYPE html>
|
|
144
|
+
<html lang="en">
|
|
145
|
+
<head>
|
|
146
|
+
<meta charset="utf-8">
|
|
147
|
+
<meta name="viewport" content="width=device-width, initial-scale=1">
|
|
148
|
+
<title>Session: ${title}</title>
|
|
149
|
+
<style>
|
|
150
|
+
:root {
|
|
151
|
+
--bg: #0d1117;
|
|
152
|
+
--bg-secondary: #161b22;
|
|
153
|
+
--bg-tertiary: #21262d;
|
|
154
|
+
--text: #e6edf3;
|
|
155
|
+
--text-muted: #8b949e;
|
|
156
|
+
--border: #30363d;
|
|
157
|
+
--user-bg: #1f2937;
|
|
158
|
+
--user-accent: #58a6ff;
|
|
159
|
+
--assistant-bg: #161b22;
|
|
160
|
+
--assistant-accent: #e6edf3;
|
|
161
|
+
--system-bg: transparent;
|
|
162
|
+
--system-accent: #8b949e;
|
|
163
|
+
--tool-bg: #21262d;
|
|
164
|
+
--tool-accent: #8b949e;
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
* {
|
|
168
|
+
box-sizing: border-box;
|
|
169
|
+
margin: 0;
|
|
170
|
+
padding: 0;
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
body {
|
|
174
|
+
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Noto Sans', Helvetica, Arial, sans-serif;
|
|
175
|
+
background: var(--bg);
|
|
176
|
+
color: var(--text);
|
|
177
|
+
line-height: 1.6;
|
|
178
|
+
font-size: 14px;
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
.container {
|
|
182
|
+
max-width: 800px;
|
|
183
|
+
margin: 0 auto;
|
|
184
|
+
padding: 24px;
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
header {
|
|
188
|
+
margin-bottom: 32px;
|
|
189
|
+
padding-bottom: 16px;
|
|
190
|
+
border-bottom: 1px solid var(--border);
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
h1 {
|
|
194
|
+
font-size: 20px;
|
|
195
|
+
font-weight: 600;
|
|
196
|
+
color: var(--text);
|
|
197
|
+
margin-bottom: 12px;
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
.metadata {
|
|
201
|
+
display: flex;
|
|
202
|
+
flex-wrap: wrap;
|
|
203
|
+
gap: 16px;
|
|
204
|
+
font-size: 12px;
|
|
205
|
+
color: var(--text-muted);
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
.metadata-item {
|
|
209
|
+
display: flex;
|
|
210
|
+
gap: 6px;
|
|
211
|
+
}
|
|
212
|
+
|
|
213
|
+
.metadata-label {
|
|
214
|
+
color: var(--text-muted);
|
|
215
|
+
}
|
|
216
|
+
|
|
217
|
+
.metadata-value {
|
|
218
|
+
color: var(--text);
|
|
219
|
+
}
|
|
220
|
+
|
|
221
|
+
.message {
|
|
222
|
+
margin: 16px 0;
|
|
223
|
+
padding: 16px;
|
|
224
|
+
border-radius: 8px;
|
|
225
|
+
border: 1px solid var(--border);
|
|
226
|
+
}
|
|
227
|
+
|
|
228
|
+
.role {
|
|
229
|
+
font-size: 11px;
|
|
230
|
+
font-weight: 600;
|
|
231
|
+
text-transform: uppercase;
|
|
232
|
+
letter-spacing: 0.5px;
|
|
233
|
+
margin-bottom: 8px;
|
|
234
|
+
}
|
|
235
|
+
|
|
236
|
+
.user {
|
|
237
|
+
background: var(--user-bg);
|
|
238
|
+
}
|
|
239
|
+
|
|
240
|
+
.user .role {
|
|
241
|
+
color: var(--user-accent);
|
|
242
|
+
}
|
|
243
|
+
|
|
244
|
+
.user .content {
|
|
245
|
+
color: var(--text);
|
|
246
|
+
}
|
|
247
|
+
|
|
248
|
+
.assistant {
|
|
249
|
+
background: var(--assistant-bg);
|
|
250
|
+
}
|
|
251
|
+
|
|
252
|
+
.assistant .role {
|
|
253
|
+
color: var(--text-muted);
|
|
254
|
+
}
|
|
255
|
+
|
|
256
|
+
.assistant .content {
|
|
257
|
+
color: var(--text);
|
|
258
|
+
}
|
|
259
|
+
|
|
260
|
+
.system {
|
|
261
|
+
background: var(--system-bg);
|
|
262
|
+
border-style: dashed;
|
|
263
|
+
}
|
|
264
|
+
|
|
265
|
+
.system .role {
|
|
266
|
+
color: var(--system-accent);
|
|
267
|
+
}
|
|
268
|
+
|
|
269
|
+
.system .content {
|
|
270
|
+
color: var(--text-muted);
|
|
271
|
+
font-size: 13px;
|
|
272
|
+
}
|
|
273
|
+
|
|
274
|
+
.content {
|
|
275
|
+
white-space: pre-wrap;
|
|
276
|
+
word-break: break-word;
|
|
277
|
+
}
|
|
278
|
+
|
|
279
|
+
.tool-call, .tool-result {
|
|
280
|
+
margin: 12px 0;
|
|
281
|
+
border-radius: 6px;
|
|
282
|
+
border: 1px solid var(--border);
|
|
283
|
+
overflow: hidden;
|
|
284
|
+
}
|
|
285
|
+
|
|
286
|
+
.tool-header {
|
|
287
|
+
display: flex;
|
|
288
|
+
align-items: center;
|
|
289
|
+
gap: 8px;
|
|
290
|
+
padding: 8px 12px;
|
|
291
|
+
background: var(--bg-tertiary);
|
|
292
|
+
font-size: 12px;
|
|
293
|
+
font-weight: 500;
|
|
294
|
+
color: var(--text-muted);
|
|
295
|
+
}
|
|
296
|
+
|
|
297
|
+
.tool-icon {
|
|
298
|
+
font-size: 14px;
|
|
299
|
+
}
|
|
300
|
+
|
|
301
|
+
.tool-name {
|
|
302
|
+
font-family: 'SF Mono', 'Fira Code', 'Consolas', monospace;
|
|
303
|
+
color: var(--text);
|
|
304
|
+
}
|
|
305
|
+
|
|
306
|
+
.tool-body {
|
|
307
|
+
padding: 12px;
|
|
308
|
+
background: var(--tool-bg);
|
|
309
|
+
}
|
|
310
|
+
|
|
311
|
+
.tool-args, .tool-output {
|
|
312
|
+
font-family: 'SF Mono', 'Fira Code', 'Consolas', monospace;
|
|
313
|
+
font-size: 12px;
|
|
314
|
+
color: var(--text-muted);
|
|
315
|
+
overflow-x: auto;
|
|
316
|
+
margin: 0;
|
|
317
|
+
white-space: pre-wrap;
|
|
318
|
+
word-break: break-word;
|
|
319
|
+
}
|
|
320
|
+
|
|
321
|
+
@media (max-width: 600px) {
|
|
322
|
+
.container {
|
|
323
|
+
padding: 16px;
|
|
324
|
+
}
|
|
325
|
+
|
|
326
|
+
h1 {
|
|
327
|
+
font-size: 18px;
|
|
328
|
+
}
|
|
329
|
+
|
|
330
|
+
.metadata {
|
|
331
|
+
flex-direction: column;
|
|
332
|
+
gap: 8px;
|
|
333
|
+
}
|
|
334
|
+
}
|
|
335
|
+
</style>
|
|
336
|
+
</head>
|
|
337
|
+
<body>
|
|
338
|
+
<div class="container">
|
|
339
|
+
<header>
|
|
340
|
+
<h1>${title}</h1>
|
|
341
|
+
<div class="metadata">
|
|
342
|
+
<div class="metadata-item">
|
|
343
|
+
<span class="metadata-label">Project:</span>
|
|
344
|
+
<span class="metadata-value">${project}</span>
|
|
345
|
+
</div>
|
|
346
|
+
<div class="metadata-item">
|
|
347
|
+
<span class="metadata-label">Model:</span>
|
|
348
|
+
<span class="metadata-value">${modelId}</span>
|
|
349
|
+
</div>
|
|
350
|
+
<div class="metadata-item">
|
|
351
|
+
<span class="metadata-label">Created:</span>
|
|
352
|
+
<span class="metadata-value">${createdAt}</span>
|
|
353
|
+
</div>
|
|
354
|
+
<div class="metadata-item">
|
|
355
|
+
<span class="metadata-label">Updated:</span>
|
|
356
|
+
<span class="metadata-value">${updatedAt}</span>
|
|
357
|
+
</div>
|
|
358
|
+
</div>
|
|
359
|
+
</header>
|
|
360
|
+
<main>
|
|
361
|
+
${messagesHtml}
|
|
362
|
+
</main>
|
|
363
|
+
</div>
|
|
364
|
+
</body>
|
|
365
|
+
</html>`;
|
|
366
|
+
}
|
|
367
|
+
export function getSessionData(sessionManager, project) {
|
|
368
|
+
return {
|
|
369
|
+
sessionId: sessionManager.getSessionId(),
|
|
370
|
+
title: sessionManager.getTitle(),
|
|
371
|
+
modelId: sessionManager.getModelId(),
|
|
372
|
+
project: project ?? basename(process.cwd()),
|
|
373
|
+
createdAt: sessionManager.getCreatedAt(),
|
|
374
|
+
updatedAt: sessionManager.getUpdatedAt(),
|
|
375
|
+
messages: sessionManager.get(),
|
|
376
|
+
};
|
|
377
|
+
}
|
|
378
|
+
export function estimateSessionSize(session) {
|
|
379
|
+
const html = renderSessionHtml(session);
|
|
380
|
+
return {
|
|
381
|
+
messageCount: session.messages.length,
|
|
382
|
+
contentSizeBytes: Buffer.byteLength(html, "utf-8"),
|
|
383
|
+
};
|
|
384
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../source/commands/share/index.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,cAAc,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AA0D/D,eAAO,MAAM,YAAY,GAAI,SAAS,cAAc,KAAG,WA6JtD,CAAC"}
|