@travisennis/acai 0.0.8 → 0.0.10
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 +48 -729
- package/bin/acai +52 -0
- package/dist/agent/index.d.ts +12 -2
- package/dist/agent/index.d.ts.map +1 -1
- package/dist/agent/index.js +378 -168
- package/dist/agent/sub-agent.d.ts +23 -0
- package/dist/agent/sub-agent.d.ts.map +1 -0
- package/dist/agent/sub-agent.js +109 -0
- package/dist/cli/index.d.ts +26 -0
- package/dist/cli/index.d.ts.map +1 -0
- package/dist/{cli.js → cli/index.js} +84 -76
- package/dist/cli/stdin.d.ts +9 -0
- package/dist/cli/stdin.d.ts.map +1 -0
- package/dist/cli/stdin.js +37 -0
- package/dist/commands/copy/index.js +2 -2
- package/dist/commands/copy/utils.d.ts.map +1 -1
- package/dist/commands/copy/utils.js +15 -13
- package/dist/commands/generate-rules/index.d.ts +1 -1
- package/dist/commands/generate-rules/index.d.ts.map +1 -1
- package/dist/commands/generate-rules/index.js +16 -100
- package/dist/commands/generate-rules/service.d.ts +21 -0
- package/dist/commands/generate-rules/service.d.ts.map +1 -0
- package/dist/commands/generate-rules/service.js +103 -0
- package/dist/commands/handoff/index.js +2 -2
- package/dist/commands/health/index.js +1 -1
- package/dist/commands/health/utils.d.ts.map +1 -1
- package/dist/commands/health/utils.js +6 -0
- package/dist/commands/history/index.d.ts +1 -1
- package/dist/commands/history/index.d.ts.map +1 -1
- package/dist/commands/history/index.js +17 -18
- package/dist/commands/history/types.d.ts +38 -0
- package/dist/commands/history/types.d.ts.map +1 -1
- package/dist/commands/history/utils.d.ts.map +1 -1
- package/dist/commands/history/utils.js +63 -58
- package/dist/commands/init/index.d.ts.map +1 -1
- package/dist/commands/init/index.js +3 -8
- package/dist/commands/init-project/index.d.ts.map +1 -1
- package/dist/commands/init-project/index.js +3 -3
- package/dist/commands/init-project/utils.d.ts.map +1 -1
- package/dist/commands/init-project/utils.js +10 -2
- package/dist/commands/list-tools/index.d.ts.map +1 -1
- package/dist/commands/list-tools/index.js +7 -31
- package/dist/commands/manager.d.ts +2 -2
- package/dist/commands/manager.d.ts.map +1 -1
- package/dist/commands/manager.js +57 -33
- package/dist/commands/model/index.d.ts.map +1 -1
- package/dist/commands/model/index.js +20 -151
- package/dist/commands/model/model-panel.d.ts +4 -0
- package/dist/commands/model/model-panel.d.ts.map +1 -0
- package/dist/commands/model/model-panel.js +144 -0
- package/dist/commands/paste/index.d.ts.map +1 -1
- package/dist/commands/paste/index.js +59 -62
- package/dist/commands/paste/utils.d.ts.map +1 -1
- package/dist/commands/paste/utils.js +88 -58
- package/dist/commands/pickup/index.d.ts.map +1 -1
- package/dist/commands/pickup/index.js +6 -3
- package/dist/commands/pickup/utils.js +3 -3
- package/dist/commands/resources/index.d.ts.map +1 -1
- package/dist/commands/resources/index.js +33 -50
- package/dist/commands/review/index.d.ts.map +1 -1
- package/dist/commands/review/index.js +3 -117
- package/dist/commands/review/review-panel.d.ts +3 -0
- package/dist/commands/review/review-panel.d.ts.map +1 -0
- package/dist/commands/review/review-panel.js +186 -0
- package/dist/commands/review/utils.d.ts +9 -0
- package/dist/commands/review/utils.d.ts.map +1 -1
- package/dist/commands/review/utils.js +127 -68
- package/dist/commands/session/index.d.ts +1 -1
- package/dist/commands/session/index.d.ts.map +1 -1
- package/dist/commands/session/index.js +134 -112
- package/dist/commands/session/types.d.ts +7 -0
- package/dist/commands/session/types.d.ts.map +1 -1
- 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.map +1 -1
- package/dist/commands/shell/index.js +16 -1
- package/dist/commands/types.d.ts +2 -2
- package/dist/commands/types.d.ts.map +1 -1
- package/dist/{config.d.ts → config/index.d.ts} +20 -9
- package/dist/config/index.d.ts.map +1 -0
- package/dist/{config.js → config/index.js} +43 -42
- package/dist/execution/index.d.ts.map +1 -1
- package/dist/execution/index.js +75 -55
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +170 -127
- package/dist/middleware/cache.d.ts.map +1 -1
- package/dist/middleware/cache.js +18 -36
- package/dist/models/ai-config.d.ts +1 -0
- package/dist/models/ai-config.d.ts.map +1 -1
- package/dist/models/ai-config.js +4 -3
- package/dist/models/anthropic-provider.d.ts +2 -5
- package/dist/models/anthropic-provider.d.ts.map +1 -1
- package/dist/models/anthropic-provider.js +3 -70
- package/dist/models/deepseek-provider.d.ts +1 -0
- package/dist/models/deepseek-provider.d.ts.map +1 -1
- package/dist/models/google-provider.d.ts +2 -3
- package/dist/models/google-provider.d.ts.map +1 -1
- package/dist/models/google-provider.js +0 -26
- package/dist/models/groq-provider.d.ts +1 -0
- package/dist/models/groq-provider.d.ts.map +1 -1
- package/dist/models/manager.d.ts +13 -2
- package/dist/models/manager.d.ts.map +1 -1
- package/dist/models/manager.js +20 -8
- package/dist/models/openai-provider.d.ts +5 -5
- package/dist/models/openai-provider.d.ts.map +1 -1
- package/dist/models/openai-provider.js +27 -40
- package/dist/models/opencode-zen-provider.d.ts +8 -3
- package/dist/models/opencode-zen-provider.d.ts.map +1 -1
- package/dist/models/opencode-zen-provider.js +68 -11
- package/dist/models/openrouter-provider.d.ts +24 -30
- package/dist/models/openrouter-provider.d.ts.map +1 -1
- package/dist/models/openrouter-provider.js +92 -177
- package/dist/models/providers.d.ts +1 -1
- package/dist/models/providers.d.ts.map +1 -1
- package/dist/models/xai-provider.d.ts +4 -3
- package/dist/models/xai-provider.d.ts.map +1 -1
- package/dist/models/xai-provider.js +18 -18
- package/dist/modes/manager.d.ts +23 -0
- package/dist/modes/manager.d.ts.map +1 -0
- package/dist/modes/manager.js +77 -0
- package/dist/modes/prompts.d.ts +2 -0
- package/dist/modes/prompts.d.ts.map +1 -0
- package/dist/modes/prompts.js +143 -0
- package/dist/prompts/mentions.d.ts +11 -0
- package/dist/prompts/mentions.d.ts.map +1 -0
- package/dist/{mentions.js → prompts/mentions.js} +21 -80
- package/dist/prompts/system-prompt.d.ts +26 -0
- package/dist/prompts/system-prompt.d.ts.map +1 -0
- package/dist/{prompts.js → prompts/system-prompt.js} +50 -22
- package/dist/repl/index.d.ts +174 -0
- package/dist/repl/index.d.ts.map +1 -0
- package/dist/{repl-new.js → repl/index.js} +399 -76
- package/dist/repl/project-status.d.ts +1 -0
- package/dist/repl/project-status.d.ts.map +1 -1
- package/dist/repl/project-status.js +4 -1
- package/dist/sessions/manager.d.ts +93 -1
- package/dist/sessions/manager.d.ts.map +1 -1
- package/dist/sessions/manager.js +264 -9
- package/dist/sessions/summary.d.ts +4 -0
- package/dist/sessions/summary.d.ts.map +1 -0
- package/dist/sessions/summary.js +30 -0
- package/dist/{skills.d.ts → skills/index.d.ts} +14 -2
- package/dist/skills/index.d.ts.map +1 -0
- package/dist/skills/index.js +294 -0
- package/dist/subagents/index.d.ts +15 -0
- package/dist/subagents/index.d.ts.map +1 -0
- package/dist/subagents/index.js +231 -0
- package/dist/terminal/control.d.ts +1 -1
- package/dist/terminal/control.d.ts.map +1 -1
- package/dist/terminal/control.js +30 -9
- package/dist/terminal/east-asian-width.d.ts.map +1 -1
- package/dist/terminal/east-asian-width.js +404 -351
- package/dist/terminal/keys.d.ts +17 -0
- package/dist/terminal/keys.d.ts.map +1 -1
- package/dist/terminal/keys.js +37 -0
- package/dist/terminal/select-prompt.d.ts.map +1 -1
- package/dist/terminal/select-prompt.js +24 -12
- package/dist/terminal/string-width.d.ts.map +1 -1
- package/dist/terminal/string-width.js +25 -27
- package/dist/terminal/style.d.ts.map +1 -1
- package/dist/terminal/style.js +4 -7
- package/dist/terminal/supports-color.d.ts.map +1 -1
- package/dist/terminal/supports-color.js +41 -27
- package/dist/terminal/table/cell.d.ts +12 -0
- package/dist/terminal/table/cell.d.ts.map +1 -1
- package/dist/terminal/table/cell.js +40 -25
- package/dist/terminal/table/layout-manager.d.ts.map +1 -1
- package/dist/terminal/table/layout-manager.js +100 -68
- package/dist/terminal/table/utils.d.ts.map +1 -1
- package/dist/terminal/table/utils.js +17 -10
- package/dist/terminal/wrap-ansi.d.ts.map +1 -1
- package/dist/terminal/wrap-ansi.js +172 -103
- package/dist/tokens/tracker.d.ts +1 -0
- package/dist/tokens/tracker.d.ts.map +1 -1
- package/dist/tokens/tracker.js +3 -0
- package/dist/tools/agent.d.ts +27 -0
- package/dist/tools/agent.d.ts.map +1 -0
- package/dist/tools/agent.js +81 -0
- package/dist/tools/bash.d.ts +4 -3
- package/dist/tools/bash.d.ts.map +1 -1
- package/dist/tools/bash.js +343 -121
- package/dist/tools/code-search.d.ts +41 -0
- package/dist/tools/code-search.d.ts.map +1 -0
- package/dist/tools/code-search.js +195 -0
- package/dist/tools/directory-tree.d.ts +3 -3
- package/dist/tools/directory-tree.d.ts.map +1 -1
- package/dist/tools/directory-tree.js +8 -5
- package/dist/tools/dynamic-tool-loader.d.ts +2 -5
- package/dist/tools/dynamic-tool-loader.d.ts.map +1 -1
- package/dist/tools/dynamic-tool-loader.js +20 -4
- package/dist/tools/edit-file.d.ts +7 -7
- package/dist/tools/edit-file.d.ts.map +1 -1
- package/dist/tools/edit-file.js +164 -66
- package/dist/tools/glob.d.ts +6 -6
- package/dist/tools/glob.d.ts.map +1 -1
- package/dist/tools/glob.js +95 -55
- package/dist/tools/grep.d.ts +15 -12
- package/dist/tools/grep.d.ts.map +1 -1
- package/dist/tools/grep.js +300 -192
- package/dist/tools/index.d.ts +143 -5
- package/dist/tools/index.d.ts.map +1 -1
- package/dist/tools/index.js +39 -24
- package/dist/tools/ls.d.ts +2 -2
- package/dist/tools/ls.d.ts.map +1 -1
- package/dist/tools/ls.js +7 -5
- package/dist/tools/read-file.d.ts +3 -3
- package/dist/tools/read-file.d.ts.map +1 -1
- package/dist/tools/read-file.js +74 -34
- package/dist/tools/save-file.d.ts +3 -3
- package/dist/tools/save-file.d.ts.map +1 -1
- package/dist/tools/save-file.js +11 -11
- package/dist/tools/skill.d.ts +23 -0
- package/dist/tools/skill.d.ts.map +1 -0
- package/dist/tools/skill.js +65 -0
- package/dist/tools/think.d.ts.map +1 -1
- package/dist/tools/think.js +2 -9
- package/dist/tools/utils.d.ts +2 -0
- package/dist/tools/utils.d.ts.map +1 -1
- package/dist/tools/utils.js +12 -0
- package/dist/tools/web-fetch.d.ts +62 -0
- package/dist/tools/web-fetch.d.ts.map +1 -0
- package/dist/tools/web-fetch.js +429 -0
- package/dist/tools/web-search.d.ts +62 -0
- package/dist/tools/web-search.d.ts.map +1 -0
- package/dist/tools/web-search.js +226 -0
- package/dist/tui/autocomplete/attachment-provider.d.ts +3 -6
- package/dist/tui/autocomplete/attachment-provider.d.ts.map +1 -1
- package/dist/tui/autocomplete/attachment-provider.js +25 -78
- package/dist/tui/autocomplete/base-provider.d.ts +1 -0
- package/dist/tui/autocomplete/base-provider.d.ts.map +1 -1
- package/dist/tui/autocomplete/combined-provider.d.ts +1 -4
- package/dist/tui/autocomplete/combined-provider.d.ts.map +1 -1
- package/dist/tui/autocomplete/combined-provider.js +3 -17
- package/dist/tui/autocomplete/command-provider.d.ts +1 -0
- package/dist/tui/autocomplete/command-provider.d.ts.map +1 -1
- package/dist/tui/autocomplete/command-provider.js +3 -0
- package/dist/tui/autocomplete/file-search-provider.d.ts +2 -1
- package/dist/tui/autocomplete/file-search-provider.d.ts.map +1 -1
- package/dist/tui/autocomplete/file-search-provider.js +36 -16
- package/dist/tui/autocomplete/skill-provider.d.ts +17 -0
- package/dist/tui/autocomplete/skill-provider.d.ts.map +1 -0
- package/dist/tui/autocomplete/skill-provider.js +49 -0
- package/dist/tui/autocomplete.d.ts +2 -2
- package/dist/tui/autocomplete.d.ts.map +1 -1
- package/dist/tui/autocomplete.js +3 -5
- package/dist/tui/components/assistant-message.d.ts.map +1 -1
- package/dist/tui/components/assistant-message.js +0 -4
- package/dist/tui/components/editor.d.ts +21 -2
- package/dist/tui/components/editor.d.ts.map +1 -1
- package/dist/tui/components/editor.js +228 -236
- package/dist/tui/components/footer.d.ts +6 -4
- package/dist/tui/components/footer.d.ts.map +1 -1
- package/dist/tui/components/footer.js +49 -25
- package/dist/tui/components/markdown.d.ts +8 -5
- package/dist/tui/components/markdown.d.ts.map +1 -1
- package/dist/tui/components/markdown.js +57 -39
- package/dist/tui/components/modal.d.ts.map +1 -1
- package/dist/tui/components/modal.js +35 -33
- package/dist/tui/components/notification.d.ts +13 -2
- package/dist/tui/components/notification.d.ts.map +1 -1
- package/dist/tui/components/notification.js +37 -2
- package/dist/tui/components/progress-bar.js +1 -1
- package/dist/tui/components/select-list.d.ts +1 -0
- package/dist/tui/components/select-list.d.ts.map +1 -1
- package/dist/tui/components/select-list.js +14 -11
- package/dist/tui/components/text.d.ts +16 -0
- package/dist/tui/components/text.d.ts.map +1 -1
- package/dist/tui/components/text.js +72 -57
- package/dist/tui/components/thinking-block.d.ts +9 -0
- package/dist/tui/components/thinking-block.d.ts.map +1 -1
- package/dist/tui/components/thinking-block.js +43 -11
- package/dist/tui/components/tool-execution.d.ts +5 -1
- package/dist/tui/components/tool-execution.d.ts.map +1 -1
- package/dist/tui/components/tool-execution.js +19 -10
- package/dist/tui/components/user-message.d.ts.map +1 -1
- package/dist/tui/components/user-message.js +0 -3
- package/dist/tui/components/welcome.js +2 -2
- 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 +3 -1
- package/dist/tui/index.d.ts.map +1 -1
- package/dist/tui/index.js +1 -0
- package/dist/tui/terminal.d.ts +27 -0
- package/dist/tui/terminal.d.ts.map +1 -1
- package/dist/tui/terminal.js +144 -15
- package/dist/tui/tui.d.ts +43 -0
- package/dist/tui/tui.d.ts.map +1 -1
- package/dist/tui/tui.js +172 -41
- package/dist/utils/bash/parse.d.ts +19 -0
- package/dist/utils/bash/parse.d.ts.map +1 -0
- package/dist/utils/bash/parse.js +223 -0
- package/dist/utils/bash/quote.d.ts +6 -0
- package/dist/utils/bash/quote.d.ts.map +1 -0
- package/dist/utils/bash/quote.js +23 -0
- package/dist/utils/bash.d.ts.map +1 -1
- package/dist/utils/bash.js +211 -126
- package/dist/utils/command-protection.d.ts +28 -0
- package/dist/utils/command-protection.d.ts.map +1 -0
- package/dist/utils/command-protection.js +324 -0
- package/dist/utils/dedent.d.ts.map +1 -0
- package/dist/utils/env-expand.d.ts +2 -0
- package/dist/utils/env-expand.d.ts.map +1 -0
- package/dist/utils/env-expand.js +8 -0
- package/dist/utils/filesystem/path-display.d.ts +11 -0
- package/dist/utils/filesystem/path-display.d.ts.map +1 -0
- package/dist/utils/filesystem/path-display.js +32 -0
- package/dist/utils/filesystem/security.d.ts +2 -2
- package/dist/utils/filesystem/security.d.ts.map +1 -1
- package/dist/utils/filesystem/security.js +32 -31
- package/dist/utils/formatting.d.ts.map +1 -0
- package/dist/{formatting.js → utils/formatting.js} +1 -1
- package/dist/utils/git.d.ts +4 -0
- package/dist/utils/git.d.ts.map +1 -1
- package/dist/utils/git.js +30 -0
- package/dist/utils/glob.d.ts +1 -1
- package/dist/utils/glob.d.ts.map +1 -1
- package/dist/utils/logger.d.ts.map +1 -0
- package/dist/{logger.js → utils/logger.js} +1 -1
- package/dist/utils/parsing.d.ts.map +1 -0
- package/dist/utils/process.d.ts.map +1 -1
- package/dist/utils/process.js +90 -37
- package/dist/utils/templates.d.ts +2 -0
- package/dist/utils/templates.d.ts.map +1 -0
- package/dist/utils/templates.js +24 -0
- package/dist/utils/version.d.ts.map +1 -0
- package/dist/{version.js → utils/version.js} +1 -1
- package/package.json +34 -25
- package/dist/cli.d.ts +0 -23
- package/dist/cli.d.ts.map +0 -1
- package/dist/commands/exit/index.d.ts +0 -10
- package/dist/commands/exit/index.d.ts.map +0 -1
- package/dist/commands/exit/index.js +0 -21
- package/dist/commands/exit/types.d.ts +0 -8
- package/dist/commands/exit/types.d.ts.map +0 -1
- package/dist/commands/exit/types.js +0 -1
- package/dist/commands/exit/utils.d.ts +0 -2
- package/dist/commands/exit/utils.d.ts.map +0 -1
- package/dist/commands/exit/utils.js +0 -13
- package/dist/commands/prompt/index.d.ts +0 -5
- package/dist/commands/prompt/index.d.ts.map +0 -1
- package/dist/commands/prompt/index.js +0 -126
- package/dist/commands/prompt/types.d.ts +0 -15
- package/dist/commands/prompt/types.d.ts.map +0 -1
- package/dist/commands/prompt/types.js +0 -1
- package/dist/commands/prompt/utils.d.ts +0 -12
- package/dist/commands/prompt/utils.d.ts.map +0 -1
- package/dist/commands/prompt/utils.js +0 -107
- package/dist/commands/reset/index.d.ts +0 -3
- package/dist/commands/reset/index.d.ts.map +0 -1
- package/dist/commands/reset/index.js +0 -25
- package/dist/commands/reset/types.d.ts +0 -1
- package/dist/commands/reset/types.d.ts.map +0 -1
- package/dist/commands/reset/types.js +0 -3
- package/dist/commands/save/index.d.ts +0 -3
- package/dist/commands/save/index.d.ts.map +0 -1
- package/dist/commands/save/index.js +0 -19
- package/dist/config.d.ts.map +0 -1
- package/dist/dedent.d.ts.map +0 -1
- package/dist/formatting.d.ts.map +0 -1
- package/dist/logger.d.ts.map +0 -1
- package/dist/mentions.d.ts +0 -14
- package/dist/mentions.d.ts.map +0 -1
- package/dist/parsing.d.ts.map +0 -1
- package/dist/prompts.d.ts +0 -10
- package/dist/prompts.d.ts.map +0 -1
- package/dist/repl-new.d.ts +0 -62
- package/dist/repl-new.d.ts.map +0 -1
- package/dist/skills.d.ts.map +0 -1
- package/dist/skills.js +0 -233
- package/dist/tui/autocomplete/path-provider.d.ts +0 -21
- package/dist/tui/autocomplete/path-provider.d.ts.map +0 -1
- package/dist/tui/autocomplete/path-provider.js +0 -164
- package/dist/version.d.ts.map +0 -1
- /package/dist/{dedent.d.ts → utils/dedent.d.ts} +0 -0
- /package/dist/{dedent.js → utils/dedent.js} +0 -0
- /package/dist/{formatting.d.ts → utils/formatting.d.ts} +0 -0
- /package/dist/{logger.d.ts → utils/logger.d.ts} +0 -0
- /package/dist/{parsing.d.ts → utils/parsing.d.ts} +0 -0
- /package/dist/{parsing.js → utils/parsing.js} +0 -0
- /package/dist/{version.d.ts → utils/version.d.ts} +0 -0
|
@@ -129,6 +129,33 @@ export function insertCell(cell, row) {
|
|
|
129
129
|
}
|
|
130
130
|
row.splice(x, 0, cell);
|
|
131
131
|
}
|
|
132
|
+
function findColSpan(table, startX, y, wMax) {
|
|
133
|
+
let colSpan = 1;
|
|
134
|
+
let x = startX;
|
|
135
|
+
// Increment x first, then check while loop (matches original logic)
|
|
136
|
+
x++;
|
|
137
|
+
while (x < wMax && !conflictExists(table, x, y)) {
|
|
138
|
+
colSpan++;
|
|
139
|
+
x++;
|
|
140
|
+
}
|
|
141
|
+
return colSpan;
|
|
142
|
+
}
|
|
143
|
+
function findRowSpan(table, x, y, colSpan, hMax) {
|
|
144
|
+
let rowSpan = 1;
|
|
145
|
+
let y2 = y + 1;
|
|
146
|
+
while (y2 < hMax && allBlank(table, y2, x, x + colSpan)) {
|
|
147
|
+
rowSpan++;
|
|
148
|
+
y2++;
|
|
149
|
+
}
|
|
150
|
+
return rowSpan;
|
|
151
|
+
}
|
|
152
|
+
function createAndInsertMissingCell(table, x, y, colSpan, rowSpan) {
|
|
153
|
+
const cell = new Cell({ content: "", colSpan, rowSpan });
|
|
154
|
+
cell.x = x;
|
|
155
|
+
cell.y = y;
|
|
156
|
+
debug.warn(`Missing cell at ${y}-${x}.`);
|
|
157
|
+
insertCell(cell, table[y]);
|
|
158
|
+
}
|
|
132
159
|
export function fillInTable(table) {
|
|
133
160
|
const hMax = maxHeight(table);
|
|
134
161
|
const wMax = maxWidth(table);
|
|
@@ -136,23 +163,10 @@ export function fillInTable(table) {
|
|
|
136
163
|
for (let y = 0; y < hMax; y++) {
|
|
137
164
|
for (let x = 0; x < wMax; x++) {
|
|
138
165
|
if (!conflictExists(table, x, y)) {
|
|
139
|
-
const
|
|
140
|
-
x
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
x++;
|
|
144
|
-
}
|
|
145
|
-
let y2 = y + 1;
|
|
146
|
-
while (y2 < hMax &&
|
|
147
|
-
allBlank(table, y2, opts.x, opts.x + opts.colSpan)) {
|
|
148
|
-
opts.rowSpan++;
|
|
149
|
-
y2++;
|
|
150
|
-
}
|
|
151
|
-
const cell = new Cell({ ...opts, content: "" });
|
|
152
|
-
cell.x = opts.x;
|
|
153
|
-
cell.y = opts.y;
|
|
154
|
-
debug.warn(`Missing cell at ${cell.y}-${cell.x}.`);
|
|
155
|
-
insertCell(cell, table[y]);
|
|
166
|
+
const colSpan = findColSpan(table, x, y, wMax);
|
|
167
|
+
const rowSpan = findRowSpan(table, x, y, colSpan, hMax);
|
|
168
|
+
createAndInsertMissingCell(table, x, y, colSpan, rowSpan);
|
|
169
|
+
x += colSpan - 1;
|
|
156
170
|
}
|
|
157
171
|
}
|
|
158
172
|
}
|
|
@@ -187,66 +201,84 @@ export function makeTableLayout(rows) {
|
|
|
187
201
|
addColSpanCells(cellRows);
|
|
188
202
|
return cellRows;
|
|
189
203
|
}
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
204
|
+
/**
|
|
205
|
+
* Scans table rows and populates result array with cell widths and collects spanning cells.
|
|
206
|
+
*/
|
|
207
|
+
function scanTableForWidths(colSpan, desiredWidth, x, forcedMin, table) {
|
|
208
|
+
const result = [];
|
|
209
|
+
const spanners = [];
|
|
210
|
+
const auto = {};
|
|
211
|
+
table.forEach((row) => {
|
|
212
|
+
row.forEach((cell) => {
|
|
213
|
+
if ((cell[colSpan] || 1) > 1) {
|
|
214
|
+
spanners.push(cell);
|
|
215
|
+
}
|
|
216
|
+
else {
|
|
217
|
+
const key = cell[x];
|
|
218
|
+
if (key !== null) {
|
|
219
|
+
result[key] = Math.max(result[key] || 0, cell[desiredWidth] || 0, forcedMin);
|
|
205
220
|
}
|
|
206
|
-
});
|
|
207
|
-
});
|
|
208
|
-
vals.forEach((val, index) => {
|
|
209
|
-
if (typeof val === "number") {
|
|
210
|
-
result[index] = val;
|
|
211
221
|
}
|
|
212
222
|
});
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
223
|
+
});
|
|
224
|
+
return { result, spanners, auto };
|
|
225
|
+
}
|
|
226
|
+
/**
|
|
227
|
+
* Applies forced values from vals array to result.
|
|
228
|
+
*/
|
|
229
|
+
function applyForcedValues(vals, result) {
|
|
230
|
+
vals.forEach((val, index) => {
|
|
231
|
+
if (typeof val === "number") {
|
|
232
|
+
result[index] = val;
|
|
233
|
+
}
|
|
234
|
+
});
|
|
235
|
+
}
|
|
236
|
+
/**
|
|
237
|
+
* Processes spanning cells and distributes their widths across columns.
|
|
238
|
+
*/
|
|
239
|
+
function processSpanners(colSpan, desiredWidth, x, spanners, result, auto, vals) {
|
|
240
|
+
for (let k = spanners.length - 1; k >= 0; k--) {
|
|
241
|
+
const cell = spanners[k];
|
|
242
|
+
const span = cell[colSpan];
|
|
243
|
+
const col = cell[x];
|
|
244
|
+
if (col === null)
|
|
245
|
+
continue;
|
|
246
|
+
let existingWidth = result[col];
|
|
247
|
+
let editableCols = typeof vals[col] === "number" ? 0 : 1;
|
|
248
|
+
if (typeof existingWidth === "number") {
|
|
249
|
+
for (let i = 1; i < span; i++) {
|
|
250
|
+
existingWidth += 1 + result[col + i];
|
|
251
|
+
if (typeof vals[col + i] !== "number") {
|
|
252
|
+
editableCols++;
|
|
228
253
|
}
|
|
229
254
|
}
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
255
|
+
}
|
|
256
|
+
else {
|
|
257
|
+
existingWidth =
|
|
258
|
+
desiredWidth === "desiredWidth" ? cell.desiredWidth - 1 : 1;
|
|
259
|
+
if (!auto[col] || auto[col] < existingWidth) {
|
|
260
|
+
auto[col] = existingWidth;
|
|
236
261
|
}
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
i++;
|
|
262
|
+
}
|
|
263
|
+
if (cell[desiredWidth] > existingWidth) {
|
|
264
|
+
let i = 0;
|
|
265
|
+
while (editableCols > 0 && cell[desiredWidth] > existingWidth) {
|
|
266
|
+
if (typeof vals[col + i] !== "number") {
|
|
267
|
+
const dif = Math.round((cell[desiredWidth] - existingWidth) / editableCols);
|
|
268
|
+
existingWidth += dif;
|
|
269
|
+
result[col + i] += dif;
|
|
270
|
+
editableCols--;
|
|
247
271
|
}
|
|
272
|
+
i++;
|
|
248
273
|
}
|
|
249
274
|
}
|
|
275
|
+
}
|
|
276
|
+
}
|
|
277
|
+
export function makeComputeWidths(colSpan, desiredWidth, x, forcedMin) {
|
|
278
|
+
return (vals, table) => {
|
|
279
|
+
const { result, spanners, auto } = scanTableForWidths(colSpan, desiredWidth, x, forcedMin, table);
|
|
280
|
+
applyForcedValues(vals, result);
|
|
281
|
+
processSpanners(colSpan, desiredWidth, x, spanners, result, auto, vals);
|
|
250
282
|
Object.assign(vals, result, auto);
|
|
251
283
|
for (let j = 0; j < vals.length; j++) {
|
|
252
284
|
vals[j] = Math.max(forcedMin, vals[j] || 0);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../../source/terminal/table/utils.ts"],"names":[],"mappings":"AAEA,KAAK,QAAQ,GACT,KAAK,GACL,QAAQ,GACR,SAAS,GACT,U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,uBAAuB,CAAC,EAC1C,QAAQ,CAAC,EAAE,oBAAoB,GAC9B,oBAAoB,CAOtB;AAsDD,wBAAgB,iBAAiB,CAC/B,SAAS,EAAE,MAAM,EACjB,KAAK,EAAE,MAAM,EACb,kBAAkB,UAAO,GACxB,MAAM,EAAE,CAQV;AAED,wBAAgB,aAAa,CAAC,KAAK,EAAE,MAAM,EAAE,GAAG,MAAM,EAAE,CAUvD;AAED;;GAEG;AACH,wBAAgB,SAAS,CAAC,GAAG,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,MAAM,CAmB3D;AAED,YAAY,EACV,QAAQ,EACR,mBAAmB,EACnB,iBAAiB,EACjB,oBAAoB,EACpB,uBAAuB,EACvB,WAAW,EACX,IAAI,GACL,CAAC"}
|
|
@@ -55,27 +55,34 @@ addToCodeCache("italics", "3", "23");
|
|
|
55
55
|
addToCodeCache("underline", "4", "24");
|
|
56
56
|
addToCodeCache("inverse", "7", "27");
|
|
57
57
|
addToCodeCache("strikethrough", "9", "29");
|
|
58
|
+
function isForegroundColor(code) {
|
|
59
|
+
return (code >= 30 && code <= 39) || (code >= 90 && code <= 97);
|
|
60
|
+
}
|
|
61
|
+
function isBackgroundColor(code) {
|
|
62
|
+
return (code >= 40 && code <= 49) || (code >= 100 && code <= 107);
|
|
63
|
+
}
|
|
64
|
+
function clearState(state) {
|
|
65
|
+
for (const i in state) {
|
|
66
|
+
/* istanbul ignore else */
|
|
67
|
+
if (Object.hasOwn(state, i)) {
|
|
68
|
+
delete state[i];
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
}
|
|
58
72
|
function updateState(state, controlChars) {
|
|
59
73
|
const controlCode = controlChars[1]
|
|
60
74
|
? Number.parseInt(controlChars[1].split(";")[0], 10)
|
|
61
75
|
: 0;
|
|
62
|
-
if ((controlCode
|
|
63
|
-
(controlCode >= 90 && controlCode <= 97)) {
|
|
76
|
+
if (isForegroundColor(controlCode)) {
|
|
64
77
|
state.lastForegroundAdded = controlChars[0];
|
|
65
78
|
return;
|
|
66
79
|
}
|
|
67
|
-
if ((controlCode
|
|
68
|
-
(controlCode >= 100 && controlCode <= 107)) {
|
|
80
|
+
if (isBackgroundColor(controlCode)) {
|
|
69
81
|
state.lastBackgroundAdded = controlChars[0];
|
|
70
82
|
return;
|
|
71
83
|
}
|
|
72
84
|
if (controlCode === 0) {
|
|
73
|
-
|
|
74
|
-
/* istanbul ignore else */
|
|
75
|
-
if (Object.hasOwn(state, i)) {
|
|
76
|
-
delete state[i];
|
|
77
|
-
}
|
|
78
|
-
}
|
|
85
|
+
clearState(state);
|
|
79
86
|
return;
|
|
80
87
|
}
|
|
81
88
|
const info = codeCache[controlChars[0]];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"wrap-ansi.d.ts","sourceRoot":"","sources":["../../source/terminal/wrap-ansi.ts"],"names":[],"mappings":"AAIA,UAAU,eAAe;IACvB,IAAI,CAAC,EAAE,OAAO,CAAC;IACf,IAAI,CAAC,EAAE,OAAO,CAAC;IACf,QAAQ,CAAC,EAAE,OAAO,CAAC;CACpB;
|
|
1
|
+
{"version":3,"file":"wrap-ansi.d.ts","sourceRoot":"","sources":["../../source/terminal/wrap-ansi.ts"],"names":[],"mappings":"AAIA,UAAU,eAAe;IACvB,IAAI,CAAC,EAAE,OAAO,CAAC;IACf,IAAI,CAAC,EAAE,OAAO,CAAC;IACf,QAAQ,CAAC,EAAE,OAAO,CAAC;CACpB;AA0XD,MAAM,CAAC,OAAO,UAAU,QAAQ,CAC9B,MAAM,EAAE,MAAM,EACd,OAAO,EAAE,MAAM,EACf,OAAO,CAAC,EAAE,eAAe,GACxB,MAAM,CAOR"}
|
|
@@ -13,6 +13,32 @@ const wrapAnsiHyperlink = (url) => `${ESCAPES.values().next().value}${ANSI_ESCAP
|
|
|
13
13
|
// Calculate the length of words split on ' ', ignoring
|
|
14
14
|
// the extra characters added by ansi escape codes
|
|
15
15
|
const wordLengths = (string) => string.split(" ").map((character) => stringWidth(character));
|
|
16
|
+
// Check if character starts an ANSI escape sequence
|
|
17
|
+
const isEscapeStart = (character) => ESCAPES.has(character);
|
|
18
|
+
// Check if this is the start of a hyperlink escape sequence
|
|
19
|
+
const isLinkEscapeStart = (characters, index) => {
|
|
20
|
+
const candidate = characters
|
|
21
|
+
.slice(index + 1, index + 1 + ANSI_ESCAPE_LINK.length)
|
|
22
|
+
.join("");
|
|
23
|
+
return candidate === ANSI_ESCAPE_LINK;
|
|
24
|
+
};
|
|
25
|
+
// Check if character ends an escape sequence
|
|
26
|
+
const isEscapeEnd = (character, isInsideLinkEscape) => {
|
|
27
|
+
if (isInsideLinkEscape) {
|
|
28
|
+
return character === ANSI_ESCAPE_BELL;
|
|
29
|
+
}
|
|
30
|
+
return character === ANSI_SGR_TERMINATOR;
|
|
31
|
+
};
|
|
32
|
+
// Handle final row edge case (ANSI-only rows)
|
|
33
|
+
const handleFinalRowEdgeCase = (rows, visible) => {
|
|
34
|
+
const lastRow = rows.at(-1);
|
|
35
|
+
if (!visible && lastRow && lastRow.length > 0 && rows.length > 1) {
|
|
36
|
+
const poppedRow = rows.pop();
|
|
37
|
+
if (poppedRow) {
|
|
38
|
+
rows[rows.length - 1] += poppedRow;
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
};
|
|
16
42
|
// Wrap a long word across multiple rows
|
|
17
43
|
// Ansi escape codes do not count towards length
|
|
18
44
|
const wrapWord = (rows, word, columns) => {
|
|
@@ -29,22 +55,16 @@ const wrapWord = (rows, word, columns) => {
|
|
|
29
55
|
rows.push(character);
|
|
30
56
|
visible = 0;
|
|
31
57
|
}
|
|
32
|
-
|
|
58
|
+
// Handle escape sequence detection
|
|
59
|
+
if (isEscapeStart(character)) {
|
|
33
60
|
isInsideEscape = true;
|
|
34
|
-
|
|
35
|
-
.slice(index + 1, index + 1 + ANSI_ESCAPE_LINK.length)
|
|
36
|
-
.join("");
|
|
37
|
-
isInsideLinkEscape = ansiEscapeLinkCandidate === ANSI_ESCAPE_LINK;
|
|
61
|
+
isInsideLinkEscape = isLinkEscapeStart(characters, index);
|
|
38
62
|
}
|
|
63
|
+
// Process escape sequence
|
|
39
64
|
if (isInsideEscape) {
|
|
40
|
-
if (isInsideLinkEscape) {
|
|
41
|
-
if (character === ANSI_ESCAPE_BELL) {
|
|
42
|
-
isInsideEscape = false;
|
|
43
|
-
isInsideLinkEscape = false;
|
|
44
|
-
}
|
|
45
|
-
}
|
|
46
|
-
else if (character === ANSI_SGR_TERMINATOR) {
|
|
65
|
+
if (isEscapeEnd(character, isInsideLinkEscape)) {
|
|
47
66
|
isInsideEscape = false;
|
|
67
|
+
isInsideLinkEscape = false;
|
|
48
68
|
}
|
|
49
69
|
continue;
|
|
50
70
|
}
|
|
@@ -54,15 +74,7 @@ const wrapWord = (rows, word, columns) => {
|
|
|
54
74
|
visible = 0;
|
|
55
75
|
}
|
|
56
76
|
}
|
|
57
|
-
|
|
58
|
-
// ansi escape characters, handle this edge-case
|
|
59
|
-
const lastRow = rows.at(-1);
|
|
60
|
-
if (!visible && lastRow && lastRow.length > 0 && rows.length > 1) {
|
|
61
|
-
const poppedRow = rows.pop();
|
|
62
|
-
if (poppedRow) {
|
|
63
|
-
rows[rows.length - 1] += poppedRow;
|
|
64
|
-
}
|
|
65
|
-
}
|
|
77
|
+
handleFinalRowEdgeCase(rows, visible);
|
|
66
78
|
};
|
|
67
79
|
// Trims spaces from a string ignoring invisible sequences
|
|
68
80
|
const stringVisibleTrimSpacesRight = (string) => {
|
|
@@ -79,105 +91,162 @@ const stringVisibleTrimSpacesRight = (string) => {
|
|
|
79
91
|
}
|
|
80
92
|
return words.slice(0, last).join(" ") + words.slice(last).join("");
|
|
81
93
|
};
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
const
|
|
88
|
-
|
|
89
|
-
|
|
94
|
+
/**
|
|
95
|
+
* Parses an ANSI escape sequence from preString starting at the given index.
|
|
96
|
+
* Returns the updated escapeCode and escapeUrl.
|
|
97
|
+
*/
|
|
98
|
+
function parseEscapeSequence(preString, preStringIndex, currentEscapeCode, currentEscapeUrl) {
|
|
99
|
+
const match = new RegExp(`(?:\\\\${ANSI_CSI}(?<code>\\d+)m|\\\\${ANSI_ESCAPE_LINK}(?<uri>.*)${ANSI_ESCAPE_BELL})`).exec(preString.slice(preStringIndex));
|
|
100
|
+
let newEscapeCode = currentEscapeCode;
|
|
101
|
+
let newEscapeUrl = currentEscapeUrl;
|
|
102
|
+
if (match?.groups) {
|
|
103
|
+
const { groups } = match;
|
|
104
|
+
if (groups["code"] !== undefined) {
|
|
105
|
+
const code = Number.parseFloat(groups["code"]);
|
|
106
|
+
newEscapeCode = code === END_CODE ? undefined : code;
|
|
107
|
+
}
|
|
108
|
+
else if (groups["uri"] !== undefined) {
|
|
109
|
+
newEscapeUrl = groups["uri"].length === 0 ? undefined : groups["uri"];
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
return { escapeCode: newEscapeCode, escapeUrl: newEscapeUrl };
|
|
113
|
+
}
|
|
114
|
+
/**
|
|
115
|
+
* Handles escape output when the next character is a newline.
|
|
116
|
+
*/
|
|
117
|
+
function handleEscapeOnNextNewline(currentReturnValue, escapeCode, escapeUrl) {
|
|
118
|
+
const code = ansiStyles["codes"].get(Number(escapeCode));
|
|
119
|
+
let newReturnValue = currentReturnValue;
|
|
120
|
+
if (escapeUrl) {
|
|
121
|
+
newReturnValue += wrapAnsiHyperlink("");
|
|
90
122
|
}
|
|
123
|
+
if (escapeCode && code) {
|
|
124
|
+
newReturnValue += wrapAnsiCode(code);
|
|
125
|
+
}
|
|
126
|
+
return newReturnValue;
|
|
127
|
+
}
|
|
128
|
+
/**
|
|
129
|
+
* Handles escape output when the current character is a newline.
|
|
130
|
+
*/
|
|
131
|
+
function handleEscapeOnCurrentNewline(currentReturnValue, escapeCode, escapeUrl) {
|
|
132
|
+
const code = ansiStyles["codes"].get(Number(escapeCode));
|
|
133
|
+
let newReturnValue = currentReturnValue;
|
|
134
|
+
if (escapeCode && code) {
|
|
135
|
+
newReturnValue += wrapAnsiCode(escapeCode);
|
|
136
|
+
}
|
|
137
|
+
if (escapeUrl) {
|
|
138
|
+
newReturnValue += wrapAnsiHyperlink(escapeUrl);
|
|
139
|
+
}
|
|
140
|
+
return newReturnValue;
|
|
141
|
+
}
|
|
142
|
+
const processAnsiEscapes = (pre, preString) => {
|
|
91
143
|
let returnValue = "";
|
|
92
144
|
let escapeCode;
|
|
93
145
|
let escapeUrl;
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
if (
|
|
98
|
-
|
|
146
|
+
let preStringIndex = 0;
|
|
147
|
+
for (const [index, character] of pre.entries()) {
|
|
148
|
+
returnValue += character;
|
|
149
|
+
if (ESCAPES.has(character)) {
|
|
150
|
+
const parsed = parseEscapeSequence(preString, preStringIndex, escapeCode, escapeUrl);
|
|
151
|
+
escapeCode = parsed.escapeCode;
|
|
152
|
+
escapeUrl = parsed.escapeUrl;
|
|
99
153
|
}
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
if (rowLength >= columns &&
|
|
103
|
-
(options.wordWrap === false || options.trim === false)) {
|
|
104
|
-
// If we start with a new word but the current row length equals the length of the columns, add a new row
|
|
105
|
-
rows.push("");
|
|
106
|
-
rowLength = 0;
|
|
107
|
-
}
|
|
108
|
-
if (rowLength > 0 || options.trim === false) {
|
|
109
|
-
rows[rows.length - 1] += " ";
|
|
110
|
-
rowLength++;
|
|
111
|
-
}
|
|
154
|
+
if (pre[index + 1] === "\n") {
|
|
155
|
+
returnValue = handleEscapeOnNextNewline(returnValue, escapeCode, escapeUrl);
|
|
112
156
|
}
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
157
|
+
else if (character === "\n") {
|
|
158
|
+
returnValue = handleEscapeOnCurrentNewline(returnValue, escapeCode, escapeUrl);
|
|
159
|
+
}
|
|
160
|
+
preStringIndex += character.length;
|
|
161
|
+
}
|
|
162
|
+
return returnValue;
|
|
163
|
+
};
|
|
164
|
+
// Determines if a new row should be started based on current row state
|
|
165
|
+
const shouldStartNewRow = (rowLength, columns, options) => rowLength >= columns &&
|
|
166
|
+
(options.wordWrap === false || options.trim === false);
|
|
167
|
+
// Adds a space between words if needed
|
|
168
|
+
const addWordSpacing = (rows, rowLength, options) => {
|
|
169
|
+
if (rowLength > 0 || options.trim === false) {
|
|
170
|
+
rows[rows.length - 1] += " ";
|
|
171
|
+
return rowLength + 1;
|
|
172
|
+
}
|
|
173
|
+
return rowLength;
|
|
174
|
+
};
|
|
175
|
+
// Handles hard wrap mode where words cannot exceed column width
|
|
176
|
+
const handleHardWrap = (rows, word, wordLength, rowLength, columns) => {
|
|
177
|
+
if (wordLength <= columns) {
|
|
178
|
+
return false;
|
|
179
|
+
}
|
|
180
|
+
const remainingColumns = columns - rowLength;
|
|
181
|
+
const breaksStartingThisLine = 1 + Math.floor((wordLength - remainingColumns - 1) / columns);
|
|
182
|
+
const breaksStartingNextLine = Math.floor((wordLength - 1) / columns);
|
|
183
|
+
if (breaksStartingNextLine < breaksStartingThisLine) {
|
|
184
|
+
rows.push("");
|
|
185
|
+
}
|
|
186
|
+
wrapWord(rows, word, columns);
|
|
187
|
+
return true;
|
|
188
|
+
};
|
|
189
|
+
// Handles soft wrap mode for normal word wrapping
|
|
190
|
+
const handleSoftWrap = (rows, word, wordLength, rowLength, columns, options) => {
|
|
191
|
+
const totalLength = rowLength + wordLength;
|
|
192
|
+
if (totalLength > columns && rowLength > 0 && wordLength > 0) {
|
|
193
|
+
if (options.wordWrap === false && rowLength < columns) {
|
|
121
194
|
wrapWord(rows, word, columns);
|
|
122
|
-
|
|
195
|
+
return true;
|
|
123
196
|
}
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
197
|
+
rows.push("");
|
|
198
|
+
}
|
|
199
|
+
if (totalLength > columns && options.wordWrap === false) {
|
|
200
|
+
wrapWord(rows, word, columns);
|
|
201
|
+
return true;
|
|
202
|
+
}
|
|
203
|
+
return false;
|
|
204
|
+
};
|
|
205
|
+
// Process a single word and update rows accordingly
|
|
206
|
+
const processWord = (rows, word, wordLength, index, columns, options) => {
|
|
207
|
+
if (options.trim !== false) {
|
|
208
|
+
rows[rows.length - 1] = rows.at(-1)?.trimStart() ?? "";
|
|
209
|
+
}
|
|
210
|
+
let rowLength = stringWidth(rows.at(-1) ?? "");
|
|
211
|
+
if (index !== 0) {
|
|
212
|
+
if (shouldStartNewRow(rowLength, columns, options)) {
|
|
131
213
|
rows.push("");
|
|
214
|
+
rowLength = 0;
|
|
132
215
|
}
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
216
|
+
rowLength = addWordSpacing(rows, rowLength, options);
|
|
217
|
+
}
|
|
218
|
+
if (options.hard) {
|
|
219
|
+
if (handleHardWrap(rows, word, wordLength, rowLength, columns)) {
|
|
220
|
+
return -1;
|
|
136
221
|
}
|
|
137
|
-
|
|
222
|
+
}
|
|
223
|
+
if (handleSoftWrap(rows, word, wordLength, rowLength, columns, options)) {
|
|
224
|
+
return -1;
|
|
225
|
+
}
|
|
226
|
+
rows[rows.length - 1] += word;
|
|
227
|
+
return stringWidth(rows.at(-1) ?? "");
|
|
228
|
+
};
|
|
229
|
+
// The wrap-ansi module can be invoked in either 'hard' or 'soft' wrap mode.
|
|
230
|
+
//
|
|
231
|
+
// 'hard' will never allow a string to take up more than columns characters.
|
|
232
|
+
//
|
|
233
|
+
// 'soft' allows long words to expand past the column length.
|
|
234
|
+
const exec = (string, columns, options = {}) => {
|
|
235
|
+
if (options.trim !== false && string.trim() === "") {
|
|
236
|
+
return "";
|
|
237
|
+
}
|
|
238
|
+
const lengths = wordLengths(string);
|
|
239
|
+
const words = string.split(" ");
|
|
240
|
+
let rows = [""];
|
|
241
|
+
for (const [index, word] of words.entries()) {
|
|
242
|
+
processWord(rows, word, lengths[index], index, columns, options);
|
|
138
243
|
}
|
|
139
244
|
if (options.trim !== false) {
|
|
140
245
|
rows = rows.map((row) => stringVisibleTrimSpacesRight(row));
|
|
141
246
|
}
|
|
142
247
|
const preString = rows.join("\n");
|
|
143
248
|
const pre = [...preString];
|
|
144
|
-
|
|
145
|
-
let preStringIndex = 0;
|
|
146
|
-
for (const [index, character] of pre.entries()) {
|
|
147
|
-
returnValue += character;
|
|
148
|
-
if (ESCAPES.has(character)) {
|
|
149
|
-
const match = new RegExp(`(?:\\\\${ANSI_CSI}(?<code>\\d+)m|\\\\${ANSI_ESCAPE_LINK}(?<uri>.*)${ANSI_ESCAPE_BELL})`).exec(preString.slice(preStringIndex));
|
|
150
|
-
if (match?.groups) {
|
|
151
|
-
const { groups } = match;
|
|
152
|
-
if (groups["code"] !== undefined) {
|
|
153
|
-
const code = Number.parseFloat(groups["code"]);
|
|
154
|
-
escapeCode = code === END_CODE ? undefined : code;
|
|
155
|
-
}
|
|
156
|
-
else if (groups["uri"] !== undefined) {
|
|
157
|
-
escapeUrl = groups["uri"].length === 0 ? undefined : groups["uri"];
|
|
158
|
-
}
|
|
159
|
-
}
|
|
160
|
-
}
|
|
161
|
-
const code = ansiStyles["codes"].get(Number(escapeCode));
|
|
162
|
-
if (pre[index + 1] === "\n") {
|
|
163
|
-
if (escapeUrl) {
|
|
164
|
-
returnValue += wrapAnsiHyperlink("");
|
|
165
|
-
}
|
|
166
|
-
if (escapeCode && code) {
|
|
167
|
-
returnValue += wrapAnsiCode(code);
|
|
168
|
-
}
|
|
169
|
-
}
|
|
170
|
-
else if (character === "\n") {
|
|
171
|
-
if (escapeCode && code) {
|
|
172
|
-
returnValue += wrapAnsiCode(escapeCode);
|
|
173
|
-
}
|
|
174
|
-
if (escapeUrl) {
|
|
175
|
-
returnValue += wrapAnsiHyperlink(escapeUrl);
|
|
176
|
-
}
|
|
177
|
-
}
|
|
178
|
-
preStringIndex += character.length;
|
|
179
|
-
}
|
|
180
|
-
return returnValue;
|
|
249
|
+
return processAnsiEscapes(pre, preString);
|
|
181
250
|
};
|
|
182
251
|
// For each newline, invoke the method separately
|
|
183
252
|
export default function wrapAnsi(string, columns, options) {
|
package/dist/tokens/tracker.d.ts
CHANGED
|
@@ -9,6 +9,7 @@ export declare class TokenTracker extends EventEmitter<TokenTrackerEvents> {
|
|
|
9
9
|
getTotalUsage(): LanguageModelUsage;
|
|
10
10
|
getUsageByApp(app: string): LanguageModelUsage;
|
|
11
11
|
getUsageBreakdown(): Record<string, number>;
|
|
12
|
+
reset(): void;
|
|
12
13
|
printSummary(): void;
|
|
13
14
|
}
|
|
14
15
|
export {};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tracker.d.ts","sourceRoot":"","sources":["../../source/tokens/tracker.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAE3C,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,IAAI,CAAC;AAO7C,UAAU,kBAAkB;IAC1B,KAAK,EAAE,CAAC,kBAAkB,CAAC,CAAC;CAC7B;AAED,qBAAa,YAAa,SAAQ,YAAY,CAAC,kBAAkB,CAAC;IAChE,OAAO,CAAC,MAAM,CAAoB;IAElC,UAAU,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,kBAAkB,GAAG,SAAS;IAQ9D,aAAa,IAAI,kBAAkB;IA0CnC,aAAa,CAAC,GAAG,EAAE,MAAM,GAAG,kBAAkB;IA0C9C,iBAAiB,IAAI,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC;IAY3C,YAAY;CAOb"}
|
|
1
|
+
{"version":3,"file":"tracker.d.ts","sourceRoot":"","sources":["../../source/tokens/tracker.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAE3C,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,IAAI,CAAC;AAO7C,UAAU,kBAAkB;IAC1B,KAAK,EAAE,CAAC,kBAAkB,CAAC,CAAC;CAC7B;AAED,qBAAa,YAAa,SAAQ,YAAY,CAAC,kBAAkB,CAAC;IAChE,OAAO,CAAC,MAAM,CAAoB;IAElC,UAAU,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,kBAAkB,GAAG,SAAS;IAQ9D,aAAa,IAAI,kBAAkB;IA0CnC,aAAa,CAAC,GAAG,EAAE,MAAM,GAAG,kBAAkB;IA0C9C,iBAAiB,IAAI,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC;IAY3C,KAAK;IAIL,YAAY;CAOb"}
|
package/dist/tokens/tracker.js
CHANGED
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
import type { WorkspaceContext } from "../index.ts";
|
|
3
|
+
import type { ToolExecutionOptions } from "./types.ts";
|
|
4
|
+
export declare const AgentTool: {
|
|
5
|
+
name: "Agent";
|
|
6
|
+
};
|
|
7
|
+
declare const inputSchema: z.ZodObject<{
|
|
8
|
+
prompt: z.ZodString;
|
|
9
|
+
type: z.ZodString;
|
|
10
|
+
timeout: z.ZodOptional<z.ZodNumber>;
|
|
11
|
+
}, z.core.$strip>;
|
|
12
|
+
export declare const createAgentTools: (options: {
|
|
13
|
+
workspace: WorkspaceContext;
|
|
14
|
+
}) => Promise<{
|
|
15
|
+
toolDef: {
|
|
16
|
+
description: string;
|
|
17
|
+
inputSchema: z.ZodObject<{
|
|
18
|
+
prompt: z.ZodString;
|
|
19
|
+
type: z.ZodString;
|
|
20
|
+
timeout: z.ZodOptional<z.ZodNumber>;
|
|
21
|
+
}, z.core.$strip>;
|
|
22
|
+
};
|
|
23
|
+
display: ({ prompt, type }: z.infer<typeof inputSchema>) => string;
|
|
24
|
+
execute: ({ prompt, type, timeout }: z.infer<typeof inputSchema>, { abortSignal }: ToolExecutionOptions) => Promise<string>;
|
|
25
|
+
}>;
|
|
26
|
+
export {};
|
|
27
|
+
//# sourceMappingURL=agent.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"agent.d.ts","sourceRoot":"","sources":["../../source/tools/agent.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAKpD,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,YAAY,CAAC;AAEvD,eAAO,MAAM,SAAS;;CAErB,CAAC;AAMF,QAAA,MAAM,WAAW;;;;iBAOf,CAAC;AAsBH,eAAO,MAAM,gBAAgB,GAAU,SAAS;IAC9C,SAAS,EAAE,gBAAgB,CAAC;CAC7B;;;;;;;;;gCAQoC,CAAC,CAAC,KAAK,CAAC,OAAO,WAAW,CAAC;yCAIjC,CAAC,CAAC,KAAK,CAAC,OAAO,WAAW,CAAC,mBACrC,oBAAoB,KACpC,OAAO,CAAC,MAAM,CAAC;EAkDnB,CAAC"}
|