@travisennis/acai 0.0.5 → 0.0.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +190 -19
- package/bin/acai-wrapper.js +26 -0
- package/dist/agent/index.d.ts +132 -0
- package/dist/agent/index.d.ts.map +1 -0
- package/dist/agent/index.js +434 -0
- package/dist/api/exa/index.js +1 -1
- package/dist/cli.d.ts +4 -1
- package/dist/cli.d.ts.map +1 -1
- package/dist/cli.js +67 -40
- package/dist/commands/add-directory-command.d.ts +3 -0
- package/dist/commands/add-directory-command.d.ts.map +1 -0
- package/dist/commands/add-directory-command.js +54 -0
- package/dist/commands/application-log-command.d.ts +1 -1
- package/dist/commands/application-log-command.d.ts.map +1 -1
- package/dist/commands/application-log-command.js +18 -20
- package/dist/commands/clear-command.d.ts +1 -1
- package/dist/commands/clear-command.d.ts.map +1 -1
- package/dist/commands/clear-command.js +7 -3
- package/dist/commands/compact-command.d.ts.map +1 -1
- package/dist/commands/compact-command.js +9 -5
- package/dist/commands/context-command.d.ts +3 -0
- package/dist/commands/context-command.d.ts.map +1 -0
- package/dist/commands/context-command.js +124 -0
- package/dist/commands/copy-command.d.ts.map +1 -1
- package/dist/commands/copy-command.js +14 -5
- package/dist/commands/edit-command.d.ts +1 -1
- package/dist/commands/edit-command.d.ts.map +1 -1
- package/dist/commands/edit-command.js +21 -34
- package/dist/commands/edit-prompt-command.d.ts +1 -1
- package/dist/commands/edit-prompt-command.d.ts.map +1 -1
- package/dist/commands/edit-prompt-command.js +18 -15
- package/dist/commands/exit-command.d.ts +1 -4
- package/dist/commands/exit-command.d.ts.map +1 -1
- package/dist/commands/exit-command.js +9 -5
- package/dist/commands/files-command.d.ts +1 -1
- package/dist/commands/files-command.d.ts.map +1 -1
- package/dist/commands/files-command.js +20 -16
- package/dist/commands/generate-rules-command.d.ts +1 -1
- package/dist/commands/generate-rules-command.d.ts.map +1 -1
- package/dist/commands/generate-rules-command.js +307 -39
- package/dist/commands/handoff-command.d.ts +3 -0
- package/dist/commands/handoff-command.d.ts.map +1 -0
- package/dist/commands/handoff-command.js +191 -0
- package/dist/commands/health-command.d.ts +1 -1
- package/dist/commands/health-command.d.ts.map +1 -1
- package/dist/commands/health-command.js +49 -27
- package/dist/commands/help-command.d.ts +1 -1
- package/dist/commands/help-command.d.ts.map +1 -1
- package/dist/commands/help-command.js +25 -5
- package/dist/commands/history-command.d.ts +3 -0
- package/dist/commands/history-command.d.ts.map +1 -0
- package/dist/commands/history-command.js +458 -0
- package/dist/commands/init-command.d.ts +1 -1
- package/dist/commands/init-command.d.ts.map +1 -1
- package/dist/commands/init-command.js +40 -22
- package/dist/commands/last-log-command.d.ts +1 -1
- package/dist/commands/last-log-command.d.ts.map +1 -1
- package/dist/commands/last-log-command.js +15 -15
- package/dist/commands/list-directories-command.d.ts +3 -0
- package/dist/commands/list-directories-command.d.ts.map +1 -0
- package/dist/commands/list-directories-command.js +35 -0
- package/dist/commands/list-tools-command.d.ts.map +1 -1
- package/dist/commands/list-tools-command.js +61 -21
- package/dist/commands/manager.d.ts +9 -4
- package/dist/commands/manager.d.ts.map +1 -1
- package/dist/commands/manager.js +64 -39
- package/dist/commands/model-command.d.ts.map +1 -1
- package/dist/commands/model-command.js +201 -66
- package/dist/commands/paste-command.d.ts +1 -1
- package/dist/commands/paste-command.d.ts.map +1 -1
- package/dist/commands/paste-command.js +23 -9
- package/dist/commands/pickup-command.d.ts +3 -0
- package/dist/commands/pickup-command.d.ts.map +1 -0
- package/dist/commands/pickup-command.js +109 -0
- package/dist/commands/prompt-command.d.ts +19 -1
- package/dist/commands/prompt-command.d.ts.map +1 -1
- package/dist/commands/prompt-command.js +191 -98
- package/dist/commands/remove-directory-command.d.ts +3 -0
- package/dist/commands/remove-directory-command.d.ts.map +1 -0
- package/dist/commands/remove-directory-command.js +55 -0
- package/dist/commands/reset-command.d.ts +1 -1
- package/dist/commands/reset-command.d.ts.map +1 -1
- package/dist/commands/reset-command.js +8 -5
- package/dist/commands/rules-command.d.ts +1 -1
- package/dist/commands/rules-command.d.ts.map +1 -1
- package/dist/commands/rules-command.js +25 -22
- package/dist/commands/save-command.d.ts +1 -1
- package/dist/commands/save-command.d.ts.map +1 -1
- package/dist/commands/save-command.js +8 -3
- package/dist/commands/shell-command.d.ts.map +1 -1
- package/dist/commands/shell-command.js +45 -24
- package/dist/commands/types.d.ts +9 -7
- package/dist/commands/types.d.ts.map +1 -1
- package/dist/commands/usage-command.d.ts +1 -1
- package/dist/commands/usage-command.d.ts.map +1 -1
- package/dist/commands/usage-command.js +18 -7
- package/dist/config.d.ts +21 -11
- package/dist/config.d.ts.map +1 -1
- package/dist/config.js +90 -63
- package/dist/execution/index.d.ts +17 -2
- package/dist/execution/index.d.ts.map +1 -1
- package/dist/execution/index.js +62 -20
- package/dist/formatting.d.ts +127 -0
- package/dist/formatting.d.ts.map +1 -1
- package/dist/formatting.js +201 -0
- package/dist/index.d.ts +7 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +263 -102
- package/dist/logger.d.ts.map +1 -1
- package/dist/logger.js +47 -18
- package/dist/mentions.d.ts +2 -1
- package/dist/mentions.d.ts.map +1 -1
- package/dist/mentions.js +16 -1
- package/dist/messages.d.ts +11 -0
- package/dist/messages.d.ts.map +1 -1
- package/dist/messages.js +122 -21
- package/dist/middleware/cache.d.ts +3 -0
- package/dist/middleware/cache.d.ts.map +1 -0
- package/dist/middleware/cache.js +53 -0
- package/dist/middleware/index.d.ts +1 -0
- package/dist/middleware/index.d.ts.map +1 -1
- package/dist/middleware/index.js +1 -0
- package/dist/models/ai-config.d.ts +4 -2
- package/dist/models/ai-config.d.ts.map +1 -1
- package/dist/models/ai-config.js +12 -2
- package/dist/models/anthropic-provider.d.ts.map +1 -1
- package/dist/models/anthropic-provider.js +3 -67
- package/dist/models/deepseek-provider.d.ts.map +1 -1
- package/dist/models/deepseek-provider.js +0 -2
- package/dist/models/google-provider.d.ts.map +1 -1
- package/dist/models/google-provider.js +0 -3
- package/dist/models/groq-provider.d.ts.map +1 -1
- package/dist/models/groq-provider.js +0 -1
- package/dist/models/manager.d.ts +2 -1
- package/dist/models/manager.d.ts.map +1 -1
- package/dist/models/manager.js +26 -2
- package/dist/models/openai-provider.d.ts.map +1 -1
- package/dist/models/openai-provider.js +0 -4
- package/dist/models/openrouter-provider.d.ts +16 -22
- package/dist/models/openrouter-provider.d.ts.map +1 -1
- package/dist/models/openrouter-provider.js +175 -236
- package/dist/models/providers.d.ts +4 -14
- package/dist/models/providers.d.ts.map +1 -1
- package/dist/models/providers.js +1 -57
- package/dist/models/xai-provider.d.ts.map +1 -1
- package/dist/models/xai-provider.js +0 -2
- package/dist/prompts.d.ts +10 -4
- package/dist/prompts.d.ts.map +1 -1
- package/dist/prompts.js +447 -70
- package/dist/repl/project-status-line.d.ts +3 -0
- package/dist/repl/project-status-line.d.ts.map +1 -0
- package/dist/repl/project-status-line.js +61 -0
- package/dist/repl/tool-call-repair.d.ts.map +1 -1
- package/dist/repl/tool-call-repair.js +8 -4
- package/dist/repl-new.d.ts +51 -0
- package/dist/repl-new.d.ts.map +1 -0
- package/dist/repl-new.js +354 -0
- package/dist/skills.d.ts +20 -0
- package/dist/skills.d.ts.map +1 -0
- package/dist/skills.js +192 -0
- package/dist/terminal/control.d.ts +55 -0
- package/dist/terminal/control.d.ts.map +1 -0
- package/dist/terminal/control.js +109 -0
- package/dist/terminal/default-theme.d.ts +1 -1
- package/dist/terminal/default-theme.d.ts.map +1 -1
- package/dist/terminal/default-theme.js +24 -28
- package/dist/terminal/formatting.d.ts +23 -25
- package/dist/terminal/formatting.d.ts.map +1 -1
- package/dist/terminal/formatting.js +35 -52
- package/dist/terminal/highlight/index.d.ts.map +1 -1
- package/dist/terminal/highlight/index.js +3 -6
- package/dist/terminal/highlight/theme.d.ts.map +1 -1
- package/dist/terminal/highlight/theme.js +2 -6
- package/dist/terminal/index.d.ts +2 -94
- package/dist/terminal/index.d.ts.map +1 -1
- package/dist/terminal/index.js +2 -370
- package/dist/terminal/markdown.js +10 -5
- package/dist/terminal/select-prompt.d.ts +2 -2
- package/dist/terminal/select-prompt.d.ts.map +1 -1
- package/dist/terminal/select-prompt.js +47 -39
- package/dist/terminal/strip-ansi.js +4 -4
- package/dist/terminal/table/cell.d.ts +114 -0
- package/dist/terminal/table/cell.d.ts.map +1 -0
- package/dist/terminal/table/cell.js +407 -0
- package/dist/terminal/table/debug.d.ts +15 -0
- package/dist/terminal/table/debug.d.ts.map +1 -0
- package/dist/terminal/table/debug.js +32 -0
- package/dist/terminal/table/index.d.ts +3 -0
- package/dist/terminal/table/index.d.ts.map +1 -0
- package/dist/terminal/table/index.js +2 -0
- package/dist/terminal/table/layout-manager.d.ts +27 -0
- package/dist/terminal/table/layout-manager.d.ts.map +1 -0
- package/dist/terminal/table/layout-manager.js +257 -0
- package/dist/terminal/table/table.d.ts +9 -0
- package/dist/terminal/table/table.d.ts.map +1 -0
- package/dist/terminal/table/table.js +97 -0
- package/dist/terminal/table/utils.d.ts +63 -0
- package/dist/terminal/table/utils.d.ts.map +1 -0
- package/dist/terminal/table/utils.js +326 -0
- package/dist/tokens/threshold.d.ts +20 -0
- package/dist/tokens/threshold.d.ts.map +1 -0
- package/dist/tokens/threshold.js +67 -0
- package/dist/tools/advanced-edit-file.d.ts +69 -0
- package/dist/tools/advanced-edit-file.d.ts.map +1 -0
- package/dist/tools/advanced-edit-file.js +285 -0
- package/dist/tools/agent.d.ts +16 -5
- package/dist/tools/agent.d.ts.map +1 -1
- package/dist/tools/agent.js +86 -59
- package/dist/tools/bash.d.ts +23 -12
- package/dist/tools/bash.d.ts.map +1 -1
- package/dist/tools/bash.js +243 -128
- package/dist/tools/batch.d.ts +34 -0
- package/dist/tools/batch.d.ts.map +1 -0
- package/dist/tools/batch.js +174 -0
- package/dist/tools/code-interpreter.d.ts +21 -9
- package/dist/tools/code-interpreter.d.ts.map +1 -1
- package/dist/tools/code-interpreter.js +151 -134
- package/dist/tools/delete-file.d.ts +17 -10
- package/dist/tools/delete-file.d.ts.map +1 -1
- package/dist/tools/delete-file.js +60 -97
- package/dist/tools/directory-tree.d.ts +17 -12
- package/dist/tools/directory-tree.d.ts.map +1 -1
- package/dist/tools/directory-tree.js +57 -48
- package/dist/tools/dynamic-tool-loader.d.ts +16 -10
- package/dist/tools/dynamic-tool-loader.d.ts.map +1 -1
- package/dist/tools/dynamic-tool-loader.js +122 -130
- package/dist/tools/dynamic-tool-parser.d.ts +1 -0
- package/dist/tools/dynamic-tool-parser.d.ts.map +1 -1
- package/dist/tools/dynamic-tool-parser.js +1 -0
- package/dist/tools/edit-file.d.ts +35 -15
- package/dist/tools/edit-file.d.ts.map +1 -1
- package/dist/tools/edit-file.js +127 -114
- package/dist/tools/glob.d.ts +36 -0
- package/dist/tools/glob.d.ts.map +1 -0
- package/dist/tools/glob.js +154 -0
- package/dist/tools/grep.d.ts +73 -12
- package/dist/tools/grep.d.ts.map +1 -1
- package/dist/tools/grep.js +425 -165
- package/dist/tools/index.d.ts +220 -126
- package/dist/tools/index.d.ts.map +1 -1
- package/dist/tools/index.js +284 -135
- package/dist/tools/llm-edit-fixer.d.ts +24 -0
- package/dist/tools/llm-edit-fixer.d.ts.map +1 -0
- package/dist/tools/llm-edit-fixer.js +136 -0
- package/dist/tools/move-file.d.ts +19 -7
- package/dist/tools/move-file.d.ts.map +1 -1
- package/dist/tools/move-file.js +48 -34
- package/dist/tools/read-file.d.ts +47 -9
- package/dist/tools/read-file.d.ts.map +1 -1
- package/dist/tools/read-file.js +84 -70
- package/dist/tools/read-multiple-files.d.ts +17 -6
- package/dist/tools/read-multiple-files.d.ts.map +1 -1
- package/dist/tools/read-multiple-files.js +132 -72
- package/dist/tools/save-file.d.ts +45 -12
- package/dist/tools/save-file.d.ts.map +1 -1
- package/dist/tools/save-file.js +76 -101
- package/dist/tools/think.d.ts +15 -7
- package/dist/tools/think.d.ts.map +1 -1
- package/dist/tools/think.js +34 -20
- package/dist/tools/types.d.ts +8 -10
- package/dist/tools/types.d.ts.map +1 -1
- package/dist/tools/types.js +9 -0
- package/dist/tools/utils.d.ts +14 -0
- package/dist/tools/utils.d.ts.map +1 -0
- package/dist/tools/utils.js +16 -0
- package/dist/tools/web-fetch.d.ts +11 -4
- package/dist/tools/web-fetch.d.ts.map +1 -1
- package/dist/tools/web-fetch.js +39 -38
- package/dist/tools/web-search.d.ts +15 -6
- package/dist/tools/web-search.d.ts.map +1 -1
- package/dist/tools/web-search.js +64 -31
- package/dist/tui/autocomplete.d.ts +44 -0
- package/dist/tui/autocomplete.d.ts.map +1 -0
- package/dist/tui/autocomplete.js +466 -0
- package/dist/tui/components/assistant-message.d.ts +18 -0
- package/dist/tui/components/assistant-message.d.ts.map +1 -0
- package/dist/tui/components/assistant-message.js +29 -0
- package/dist/tui/components/box.d.ts +20 -0
- package/dist/tui/components/box.d.ts.map +1 -0
- package/dist/tui/components/box.js +81 -0
- package/dist/tui/components/editor.d.ts +106 -0
- package/dist/tui/components/editor.d.ts.map +1 -0
- package/dist/tui/components/editor.js +1220 -0
- package/dist/tui/components/footer.d.ts +12 -0
- package/dist/tui/components/footer.d.ts.map +1 -0
- package/dist/tui/components/footer.js +209 -0
- package/dist/tui/components/header.d.ts +21 -0
- package/dist/tui/components/header.d.ts.map +1 -0
- package/dist/tui/components/header.js +63 -0
- package/dist/tui/components/input.d.ts +14 -0
- package/dist/tui/components/input.d.ts.map +1 -0
- package/dist/tui/components/input.js +122 -0
- package/dist/tui/components/loader.d.ts +23 -0
- package/dist/tui/components/loader.d.ts.map +1 -0
- package/dist/tui/components/loader.js +45 -0
- package/dist/tui/components/markdown.d.ts +106 -0
- package/dist/tui/components/markdown.d.ts.map +1 -0
- package/dist/tui/components/markdown.js +586 -0
- package/dist/tui/components/modal.d.ts +29 -0
- package/dist/tui/components/modal.d.ts.map +1 -0
- package/dist/tui/components/modal.js +263 -0
- package/dist/tui/components/progress-bar.d.ts +19 -0
- package/dist/tui/components/progress-bar.d.ts.map +1 -0
- package/dist/tui/components/progress-bar.js +78 -0
- package/dist/tui/components/prompt-status.d.ts +17 -0
- package/dist/tui/components/prompt-status.d.ts.map +1 -0
- package/dist/tui/components/prompt-status.js +26 -0
- package/dist/tui/components/select-list.d.ts +48 -0
- package/dist/tui/components/select-list.d.ts.map +1 -0
- package/dist/tui/components/select-list.js +207 -0
- package/dist/tui/components/spacer.d.ts +16 -0
- package/dist/tui/components/spacer.d.ts.map +1 -0
- package/dist/tui/components/spacer.js +27 -0
- package/dist/tui/components/table.d.ts +27 -0
- package/dist/tui/components/table.d.ts.map +1 -0
- package/dist/tui/components/table.js +125 -0
- package/dist/tui/components/text.d.ts +26 -0
- package/dist/tui/components/text.d.ts.map +1 -0
- package/dist/tui/components/text.js +143 -0
- package/dist/tui/components/thinking-block.d.ts +14 -0
- package/dist/tui/components/thinking-block.d.ts.map +1 -0
- package/dist/tui/components/thinking-block.js +33 -0
- package/dist/tui/components/tool-execution.d.ts +21 -0
- package/dist/tui/components/tool-execution.d.ts.map +1 -0
- package/dist/tui/components/tool-execution.js +161 -0
- package/dist/tui/components/user-message.d.ts +9 -0
- package/dist/tui/components/user-message.d.ts.map +1 -0
- package/dist/tui/components/user-message.js +23 -0
- package/dist/tui/components/welcome.d.ts +6 -0
- package/dist/tui/components/welcome.d.ts.map +1 -0
- package/dist/tui/components/welcome.js +30 -0
- package/dist/tui/index.d.ts +18 -0
- package/dist/tui/index.d.ts.map +1 -0
- package/dist/tui/index.js +22 -0
- package/dist/tui/terminal.d.ts +38 -0
- package/dist/tui/terminal.d.ts.map +1 -0
- package/dist/tui/terminal.js +94 -0
- package/dist/tui/tui.d.ts +69 -0
- package/dist/tui/tui.d.ts.map +1 -0
- package/dist/tui/tui.js +204 -0
- package/dist/tui/utils.d.ts +24 -0
- package/dist/tui/utils.d.ts.map +1 -0
- package/dist/tui/utils.js +111 -0
- package/dist/utils/bash.d.ts +7 -0
- package/dist/utils/bash.d.ts.map +1 -0
- package/dist/{tools/bash-utils.js → utils/bash.js} +31 -12
- package/dist/utils/{filesystem.d.ts → filesystem/operations.d.ts} +1 -1
- package/dist/utils/filesystem/operations.d.ts.map +1 -0
- package/dist/utils/filesystem/security.d.ts +9 -0
- package/dist/utils/filesystem/security.d.ts.map +1 -0
- package/dist/{tools/filesystem-utils.js → utils/filesystem/security.js} +93 -21
- package/dist/utils/funcs.d.ts +6 -0
- package/dist/utils/funcs.d.ts.map +1 -0
- package/dist/utils/funcs.js +6 -0
- package/dist/utils/generators.d.ts +3 -0
- package/dist/utils/generators.d.ts.map +1 -0
- package/dist/utils/generators.js +25 -0
- package/dist/{tools/git-utils.d.ts → utils/git.d.ts} +1 -1
- package/dist/utils/git.d.ts.map +1 -0
- package/dist/{tools/git-utils.js → utils/git.js} +0 -6
- package/dist/utils/glob.js +1 -1
- package/dist/utils/iterables.d.ts +2 -0
- package/dist/utils/iterables.d.ts.map +1 -0
- package/dist/utils/iterables.js +6 -0
- package/dist/utils/{zod-utils.d.ts → zod.d.ts} +1 -1
- package/dist/utils/zod.d.ts.map +1 -0
- package/package.json +21 -21
- package/dist/conversation-analyzer.d.ts +0 -11
- package/dist/conversation-analyzer.d.ts.map +0 -1
- package/dist/conversation-analyzer.js +0 -88
- package/dist/repl/display-tool-messages.d.ts +0 -4
- package/dist/repl/display-tool-messages.d.ts.map +0 -1
- package/dist/repl/display-tool-messages.js +0 -55
- package/dist/repl/display-tool-use.d.ts +0 -14
- package/dist/repl/display-tool-use.d.ts.map +0 -1
- package/dist/repl/display-tool-use.js +0 -63
- package/dist/repl/get-prompt-header.d.ts +0 -8
- package/dist/repl/get-prompt-header.d.ts.map +0 -1
- package/dist/repl/get-prompt-header.js +0 -38
- package/dist/repl-prompt.d.ts +0 -15
- package/dist/repl-prompt.d.ts.map +0 -1
- package/dist/repl-prompt.js +0 -147
- package/dist/repl.d.ts +0 -31
- package/dist/repl.d.ts.map +0 -1
- package/dist/repl.js +0 -310
- package/dist/terminal/checkbox-prompt.d.ts +0 -36
- package/dist/terminal/checkbox-prompt.d.ts.map +0 -1
- package/dist/terminal/checkbox-prompt.js +0 -362
- package/dist/terminal/editor-prompt.d.ts +0 -10
- package/dist/terminal/editor-prompt.d.ts.map +0 -1
- package/dist/terminal/editor-prompt.js +0 -61
- package/dist/terminal/errors.d.ts +0 -19
- package/dist/terminal/errors.d.ts.map +0 -1
- package/dist/terminal/errors.js +0 -37
- package/dist/terminal/input-prompt.d.ts +0 -16
- package/dist/terminal/input-prompt.d.ts.map +0 -1
- package/dist/terminal/input-prompt.js +0 -181
- package/dist/terminal/search-prompt.d.ts +0 -20
- package/dist/terminal/search-prompt.d.ts.map +0 -1
- package/dist/terminal/search-prompt.js +0 -279
- package/dist/terminal/types.d.ts +0 -35
- package/dist/terminal/types.d.ts.map +0 -1
- package/dist/terminal/types.js +0 -1
- package/dist/tokens/manage-output.d.ts +0 -34
- package/dist/tokens/manage-output.d.ts.map +0 -1
- package/dist/tokens/manage-output.js +0 -44
- package/dist/tool-executor.d.ts +0 -28
- package/dist/tool-executor.d.ts.map +0 -1
- package/dist/tool-executor.js +0 -74
- package/dist/tools/bash-utils.d.ts +0 -7
- package/dist/tools/bash-utils.d.ts.map +0 -1
- package/dist/tools/file-editing-utils.d.ts +0 -2
- package/dist/tools/file-editing-utils.d.ts.map +0 -1
- package/dist/tools/file-editing-utils.js +0 -135
- package/dist/tools/filesystem-utils.d.ts +0 -7
- package/dist/tools/filesystem-utils.d.ts.map +0 -1
- package/dist/tools/git-utils.d.ts.map +0 -1
- package/dist/utils/filesystem.d.ts.map +0 -1
- package/dist/utils/zod-utils.d.ts.map +0 -1
- /package/dist/utils/{filesystem.js → filesystem/operations.js} +0 -0
- /package/dist/utils/{zod-utils.js → zod.js} +0 -0
package/dist/execution/index.js
CHANGED
|
@@ -211,9 +211,18 @@ export class ExecutionEnvironment {
|
|
|
211
211
|
* Execute a command in the background
|
|
212
212
|
*/
|
|
213
213
|
executeCommandInBackground(command, options = {}) {
|
|
214
|
+
const cwd = options.cwd || this.workingDirectory;
|
|
215
|
+
// Create the tracked process first
|
|
216
|
+
const trackedProcess = {
|
|
217
|
+
pid: -1, // Will be set after spawn
|
|
218
|
+
kill: () => false, // Will be set after spawn
|
|
219
|
+
isRunning: true,
|
|
220
|
+
originalCwd: cwd,
|
|
221
|
+
startTime: new Date(),
|
|
222
|
+
command,
|
|
223
|
+
};
|
|
214
224
|
// Validate command for safety
|
|
215
225
|
this.validateCommand(command);
|
|
216
|
-
const cwd = options.cwd || this.workingDirectory;
|
|
217
226
|
const env = {
|
|
218
227
|
...this.environmentVariables,
|
|
219
228
|
...ttySizeEnv(),
|
|
@@ -244,6 +253,21 @@ export class ExecutionEnvironment {
|
|
|
244
253
|
});
|
|
245
254
|
const pid = childProcess.pid ?? -1;
|
|
246
255
|
let isRunning = true;
|
|
256
|
+
// Update tracked process with actual PID and kill function
|
|
257
|
+
trackedProcess.pid = pid;
|
|
258
|
+
trackedProcess.kill = () => {
|
|
259
|
+
if (isRunning) {
|
|
260
|
+
childProcess.kill();
|
|
261
|
+
isRunning = false;
|
|
262
|
+
this.backgroundProcesses.delete(pid);
|
|
263
|
+
// Clean up abort listener
|
|
264
|
+
if (abortHandler) {
|
|
265
|
+
options.abortSignal?.removeEventListener("abort", abortHandler);
|
|
266
|
+
}
|
|
267
|
+
return true;
|
|
268
|
+
}
|
|
269
|
+
return false;
|
|
270
|
+
};
|
|
247
271
|
// Set up output handlers
|
|
248
272
|
if (childProcess.stdout) {
|
|
249
273
|
childProcess.stdout.on("data", (data) => {
|
|
@@ -292,28 +316,44 @@ export class ExecutionEnvironment {
|
|
|
292
316
|
once: true,
|
|
293
317
|
});
|
|
294
318
|
}
|
|
295
|
-
// Create the process handle
|
|
319
|
+
// Create the public process handle
|
|
296
320
|
const backgroundProcess = {
|
|
297
321
|
pid,
|
|
298
|
-
kill:
|
|
299
|
-
if (isRunning) {
|
|
300
|
-
childProcess.kill();
|
|
301
|
-
isRunning = false;
|
|
302
|
-
this.backgroundProcesses.delete(pid);
|
|
303
|
-
// Clean up abort listener
|
|
304
|
-
if (abortHandler) {
|
|
305
|
-
options.abortSignal?.removeEventListener("abort", abortHandler);
|
|
306
|
-
}
|
|
307
|
-
return true;
|
|
308
|
-
}
|
|
309
|
-
return false;
|
|
310
|
-
},
|
|
322
|
+
kill: trackedProcess.kill,
|
|
311
323
|
isRunning: true,
|
|
312
324
|
};
|
|
313
325
|
// Track the process
|
|
314
|
-
this.backgroundProcesses.set(pid,
|
|
326
|
+
this.backgroundProcesses.set(pid, trackedProcess);
|
|
315
327
|
return backgroundProcess;
|
|
316
328
|
}
|
|
329
|
+
/**
|
|
330
|
+
* Get background processes for a specific project directory
|
|
331
|
+
*/
|
|
332
|
+
getBackgroundProcessesForProject(projectRoot) {
|
|
333
|
+
const processes = [];
|
|
334
|
+
for (const process of this.backgroundProcesses.values()) {
|
|
335
|
+
// Check if process was started in or under the project root
|
|
336
|
+
if (process.originalCwd.startsWith(projectRoot)) {
|
|
337
|
+
processes.push(process);
|
|
338
|
+
}
|
|
339
|
+
}
|
|
340
|
+
return processes;
|
|
341
|
+
}
|
|
342
|
+
/**
|
|
343
|
+
* Kill all background processes for a specific project directory
|
|
344
|
+
*/
|
|
345
|
+
killBackgroundProcessesForProject(projectRoot) {
|
|
346
|
+
const processes = this.getBackgroundProcessesForProject(projectRoot);
|
|
347
|
+
logger.info(`Killing ${processes.length} background processes for project: ${projectRoot}`);
|
|
348
|
+
for (const process of processes) {
|
|
349
|
+
try {
|
|
350
|
+
process.kill();
|
|
351
|
+
}
|
|
352
|
+
catch (error) {
|
|
353
|
+
logger.warn(error, `Failed to kill process ${process.pid}`);
|
|
354
|
+
}
|
|
355
|
+
}
|
|
356
|
+
}
|
|
317
357
|
/**
|
|
318
358
|
* Kill all running background processes
|
|
319
359
|
*/
|
|
@@ -388,13 +428,17 @@ export async function initExecutionEnvironment(config = {}) {
|
|
|
388
428
|
try {
|
|
389
429
|
const executionEnv = new ExecutionEnvironment(config);
|
|
390
430
|
await executionEnv.initialize();
|
|
431
|
+
// Set up cleanup for background processes
|
|
432
|
+
setupProcessCleanup(executionEnv);
|
|
391
433
|
logger.info("Execution environment initialized successfully");
|
|
392
434
|
return executionEnv;
|
|
393
435
|
}
|
|
394
436
|
catch (error) {
|
|
395
437
|
logger.error(error, "Failed to initialize execution environment");
|
|
396
438
|
// Return a minimal execution environment even if initialization failed
|
|
397
|
-
|
|
439
|
+
const executionEnv = new ExecutionEnvironment(config);
|
|
440
|
+
setupProcessCleanup(executionEnv);
|
|
441
|
+
return executionEnv;
|
|
398
442
|
}
|
|
399
443
|
}
|
|
400
444
|
// const platformName = process.platform;
|
|
@@ -417,16 +461,14 @@ export async function initExecutionEnvironment(config = {}) {
|
|
|
417
461
|
// args = ["-c", command];
|
|
418
462
|
// }
|
|
419
463
|
// Set up cleanup on process exit
|
|
420
|
-
|
|
464
|
+
function setupProcessCleanup(executionEnv) {
|
|
421
465
|
process.on("exit", () => {
|
|
422
466
|
executionEnv.killAllBackgroundProcesses();
|
|
423
467
|
});
|
|
424
468
|
process.on("SIGINT", () => {
|
|
425
469
|
executionEnv.killAllBackgroundProcesses();
|
|
426
|
-
process.exit(0);
|
|
427
470
|
});
|
|
428
471
|
process.on("SIGTERM", () => {
|
|
429
472
|
executionEnv.killAllBackgroundProcesses();
|
|
430
|
-
process.exit(0);
|
|
431
473
|
});
|
|
432
474
|
}
|
package/dist/formatting.d.ts
CHANGED
|
@@ -1,6 +1,133 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Formatting utilities for various content types including files, URLs, code blocks, and memory usage.
|
|
3
|
+
* Provides consistent formatting across different output formats (XML, Markdown, Bracket).
|
|
4
|
+
*
|
|
5
|
+
* @module formatting
|
|
6
|
+
*/
|
|
7
|
+
/**
|
|
8
|
+
* Supported formatting types for content output.
|
|
9
|
+
*/
|
|
1
10
|
export type FormatType = "xml" | "markdown" | "bracket";
|
|
11
|
+
/**
|
|
12
|
+
* Formats file content with metadata in the specified format.
|
|
13
|
+
*
|
|
14
|
+
* @param file - The file path or name
|
|
15
|
+
* @param content - The file content to format
|
|
16
|
+
* @param format - The output format type
|
|
17
|
+
* @returns Formatted file content with metadata
|
|
18
|
+
* @throws {Error} When an unsupported format is provided
|
|
19
|
+
*
|
|
20
|
+
* @example
|
|
21
|
+
* ```typescript
|
|
22
|
+
* formatFile("example.ts", "const x = 1;", "markdown")
|
|
23
|
+
* // Returns: "## File: example.ts\n``` typescript\nconst x = 1;\n```"
|
|
24
|
+
* ```
|
|
25
|
+
*/
|
|
2
26
|
export declare function formatFile(file: string, content: string, format: FormatType): string;
|
|
27
|
+
/**
|
|
28
|
+
* Formats URL content with metadata in the specified format.
|
|
29
|
+
*
|
|
30
|
+
* @param siteUrl - The URL to format
|
|
31
|
+
* @param content - The URL content to format
|
|
32
|
+
* @param format - The output format type
|
|
33
|
+
* @returns Formatted URL content with metadata
|
|
34
|
+
* @throws {Error} When an unsupported format is provided
|
|
35
|
+
*
|
|
36
|
+
* @example
|
|
37
|
+
* ```typescript
|
|
38
|
+
* formatUrl("https://example.com", "<html>...</html>", "xml")
|
|
39
|
+
* // Returns: "<webpage>\n<url>https://example.com</url>\n<content>\n<html>...</html>\n</content>\n</webpage>"
|
|
40
|
+
* ```
|
|
41
|
+
*/
|
|
3
42
|
export declare function formatUrl(siteUrl: string, content: string, format: FormatType): string;
|
|
43
|
+
/**
|
|
44
|
+
* Formats content as a code block with appropriate language identifier.
|
|
45
|
+
*
|
|
46
|
+
* @param file - The file path used to determine the code block language
|
|
47
|
+
* @param content - The code content to format
|
|
48
|
+
* @returns Formatted code block with language identifier
|
|
49
|
+
*
|
|
50
|
+
* @example
|
|
51
|
+
* ```typescript
|
|
52
|
+
* formatCodeBlock("example.js", "console.log('hello');")
|
|
53
|
+
* // Returns: "``` javascript\nconsole.log('hello');\n```"
|
|
54
|
+
* ```
|
|
55
|
+
*/
|
|
4
56
|
export declare function formatCodeBlock(file: string, content: string): string;
|
|
57
|
+
/**
|
|
58
|
+
* Formats generic content blocks with a name in the specified format.
|
|
59
|
+
*
|
|
60
|
+
* @param content - The block content to format
|
|
61
|
+
* @param blockName - The name/title of the block
|
|
62
|
+
* @param format - The output format type
|
|
63
|
+
* @returns Formatted block content with name
|
|
64
|
+
* @throws {Error} When an unsupported format is provided
|
|
65
|
+
*
|
|
66
|
+
* @example
|
|
67
|
+
* ```typescript
|
|
68
|
+
* formatBlock("Some content", "Custom Block", "markdown")
|
|
69
|
+
* // Returns: "## Custom Block\n```\nSome content\n```"
|
|
70
|
+
* ```
|
|
71
|
+
*/
|
|
5
72
|
export declare function formatBlock(content: string, blockName: string, format: FormatType): string;
|
|
73
|
+
/**
|
|
74
|
+
* Capitalizes the first character of a string.
|
|
75
|
+
*
|
|
76
|
+
* @param str - The string to capitalize
|
|
77
|
+
* @returns The string with first character capitalized
|
|
78
|
+
*
|
|
79
|
+
* @example
|
|
80
|
+
* ```typescript
|
|
81
|
+
* capitalize("hello") // Returns: "Hello"
|
|
82
|
+
* ```
|
|
83
|
+
*/
|
|
84
|
+
export declare const capitalize: (str: string) => string;
|
|
85
|
+
/**
|
|
86
|
+
* Formats memory usage in bytes into human-readable units (KB, MB, GB).
|
|
87
|
+
*
|
|
88
|
+
* @param bytes - Memory usage in bytes
|
|
89
|
+
* @returns Formatted memory usage string
|
|
90
|
+
*
|
|
91
|
+
* @example
|
|
92
|
+
* ```typescript
|
|
93
|
+
* formatMemoryUsage(1024) // Returns: "1.0 KB"
|
|
94
|
+
* formatMemoryUsage(1048576) // Returns: "1.0 MB"
|
|
95
|
+
* formatMemoryUsage(1073741824) // Returns: "1.00 GB"
|
|
96
|
+
* ```
|
|
97
|
+
*/
|
|
98
|
+
export declare const formatMemoryUsage: (bytes: number) => string;
|
|
99
|
+
/**
|
|
100
|
+
* Formats a duration in milliseconds into a concise, human-readable string.
|
|
101
|
+
* Omits any time units that are zero.
|
|
102
|
+
*
|
|
103
|
+
* @param milliseconds - The duration in milliseconds
|
|
104
|
+
* @returns A formatted string representing the duration
|
|
105
|
+
*
|
|
106
|
+
* @example
|
|
107
|
+
* ```typescript
|
|
108
|
+
* formatDuration(3661000) // Returns: "1h 1m 1s"
|
|
109
|
+
* formatDuration(500) // Returns: "500ms"
|
|
110
|
+
* formatDuration(1500) // Returns: "1.5s"
|
|
111
|
+
* ```
|
|
112
|
+
*/
|
|
113
|
+
export declare const formatDuration: (milliseconds: number) => string;
|
|
114
|
+
/**
|
|
115
|
+
* Formats a number into a compact, human-readable string.
|
|
116
|
+
* Uses K, M, B, T notation for large numbers while maintaining readability.
|
|
117
|
+
*
|
|
118
|
+
* @param num - The number to format
|
|
119
|
+
* @returns A formatted string representing the number
|
|
120
|
+
*
|
|
121
|
+
* @example
|
|
122
|
+
* ```typescript
|
|
123
|
+
* formatNumber(1) // Returns: "1"
|
|
124
|
+
* formatNumber(100) // Returns: "100"
|
|
125
|
+
* formatNumber(1000) // Returns: "1K"
|
|
126
|
+
* formatNumber(1100) // Returns: "1.1K"
|
|
127
|
+
* formatNumber(1234567) // Returns: "1.2M"
|
|
128
|
+
* formatNumber(1234567890) // Returns: "1.2B"
|
|
129
|
+
* formatNumber(1234567890123) // Returns: "1.2T"
|
|
130
|
+
* ```
|
|
131
|
+
*/
|
|
132
|
+
export declare const formatNumber: (num: number) => string;
|
|
6
133
|
//# sourceMappingURL=formatting.d.ts.map
|
package/dist/formatting.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"formatting.d.ts","sourceRoot":"","sources":["../source/formatting.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"formatting.d.ts","sourceRoot":"","sources":["../source/formatting.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAOH;;GAEG;AACH,MAAM,MAAM,UAAU,GAAG,KAAK,GAAG,UAAU,GAAG,SAAS,CAAC;AAExD;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,UAAU,CACxB,IAAI,EAAE,MAAM,EACZ,OAAO,EAAE,MAAM,EACf,MAAM,EAAE,UAAU,GACjB,MAAM,CAaR;AAED;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,SAAS,CACvB,OAAO,EAAE,MAAM,EACf,OAAO,EAAE,MAAM,EACf,MAAM,EAAE,UAAU,GACjB,MAAM,CAWR;AAED;;;;;;;;;;;;GAYG;AACH,wBAAgB,eAAe,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,GAAG,MAAM,CAIrE;AAED;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,WAAW,CACzB,OAAO,EAAE,MAAM,EACf,SAAS,EAAE,MAAM,EACjB,MAAM,EAAE,UAAU,GACjB,MAAM,CAWR;AAED;;;;;;;;;;GAUG;AACH,eAAO,MAAM,UAAU,GAAI,KAAK,MAAM,KAAG,MACG,CAAC;AAE7C;;;;;;;;;;;;GAYG;AACH,eAAO,MAAM,iBAAiB,GAAI,OAAO,MAAM,KAAG,MASjD,CAAC;AAEF;;;;;;;;;;;;;GAaG;AACH,eAAO,MAAM,cAAc,GAAI,cAAc,MAAM,KAAG,MAuCrD,CAAC;AAEF;;;;;;;;;;;;;;;;;GAiBG;AACH,eAAO,MAAM,YAAY,GAAI,KAAK,MAAM,KAAG,MAwC1C,CAAC"}
|
package/dist/formatting.js
CHANGED
|
@@ -1,6 +1,27 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Formatting utilities for various content types including files, URLs, code blocks, and memory usage.
|
|
3
|
+
* Provides consistent formatting across different output formats (XML, Markdown, Bracket).
|
|
4
|
+
*
|
|
5
|
+
* @module formatting
|
|
6
|
+
*/
|
|
1
7
|
import path from "node:path";
|
|
2
8
|
import { getCodeblockFromFilePath } from "./utils/filetype-detection.js";
|
|
3
9
|
const MD_TRIPLE_QUOTE = "```";
|
|
10
|
+
/**
|
|
11
|
+
* Formats file content with metadata in the specified format.
|
|
12
|
+
*
|
|
13
|
+
* @param file - The file path or name
|
|
14
|
+
* @param content - The file content to format
|
|
15
|
+
* @param format - The output format type
|
|
16
|
+
* @returns Formatted file content with metadata
|
|
17
|
+
* @throws {Error} When an unsupported format is provided
|
|
18
|
+
*
|
|
19
|
+
* @example
|
|
20
|
+
* ```typescript
|
|
21
|
+
* formatFile("example.ts", "const x = 1;", "markdown")
|
|
22
|
+
* // Returns: "## File: example.ts\n``` typescript\nconst x = 1;\n```"
|
|
23
|
+
* ```
|
|
24
|
+
*/
|
|
4
25
|
export function formatFile(file, content, format) {
|
|
5
26
|
const codeBlockName = getCodeblockFromFilePath(file) || path.extname(file).slice(1);
|
|
6
27
|
switch (format) {
|
|
@@ -14,6 +35,21 @@ export function formatFile(file, content, format) {
|
|
|
14
35
|
throw new Error(`Unsupported format: ${format}`);
|
|
15
36
|
}
|
|
16
37
|
}
|
|
38
|
+
/**
|
|
39
|
+
* Formats URL content with metadata in the specified format.
|
|
40
|
+
*
|
|
41
|
+
* @param siteUrl - The URL to format
|
|
42
|
+
* @param content - The URL content to format
|
|
43
|
+
* @param format - The output format type
|
|
44
|
+
* @returns Formatted URL content with metadata
|
|
45
|
+
* @throws {Error} When an unsupported format is provided
|
|
46
|
+
*
|
|
47
|
+
* @example
|
|
48
|
+
* ```typescript
|
|
49
|
+
* formatUrl("https://example.com", "<html>...</html>", "xml")
|
|
50
|
+
* // Returns: "<webpage>\n<url>https://example.com</url>\n<content>\n<html>...</html>\n</content>\n</webpage>"
|
|
51
|
+
* ```
|
|
52
|
+
*/
|
|
17
53
|
export function formatUrl(siteUrl, content, format) {
|
|
18
54
|
switch (format) {
|
|
19
55
|
case "xml":
|
|
@@ -26,10 +62,38 @@ export function formatUrl(siteUrl, content, format) {
|
|
|
26
62
|
throw new Error(`Unsupported format: ${format}`);
|
|
27
63
|
}
|
|
28
64
|
}
|
|
65
|
+
/**
|
|
66
|
+
* Formats content as a code block with appropriate language identifier.
|
|
67
|
+
*
|
|
68
|
+
* @param file - The file path used to determine the code block language
|
|
69
|
+
* @param content - The code content to format
|
|
70
|
+
* @returns Formatted code block with language identifier
|
|
71
|
+
*
|
|
72
|
+
* @example
|
|
73
|
+
* ```typescript
|
|
74
|
+
* formatCodeBlock("example.js", "console.log('hello');")
|
|
75
|
+
* // Returns: "``` javascript\nconsole.log('hello');\n```"
|
|
76
|
+
* ```
|
|
77
|
+
*/
|
|
29
78
|
export function formatCodeBlock(file, content) {
|
|
30
79
|
const codeBlockName = getCodeblockFromFilePath(file) || path.extname(file).slice(1);
|
|
31
80
|
return `${MD_TRIPLE_QUOTE} ${codeBlockName}\n${content}\n${MD_TRIPLE_QUOTE}`;
|
|
32
81
|
}
|
|
82
|
+
/**
|
|
83
|
+
* Formats generic content blocks with a name in the specified format.
|
|
84
|
+
*
|
|
85
|
+
* @param content - The block content to format
|
|
86
|
+
* @param blockName - The name/title of the block
|
|
87
|
+
* @param format - The output format type
|
|
88
|
+
* @returns Formatted block content with name
|
|
89
|
+
* @throws {Error} When an unsupported format is provided
|
|
90
|
+
*
|
|
91
|
+
* @example
|
|
92
|
+
* ```typescript
|
|
93
|
+
* formatBlock("Some content", "Custom Block", "markdown")
|
|
94
|
+
* // Returns: "## Custom Block\n```\nSome content\n```"
|
|
95
|
+
* ```
|
|
96
|
+
*/
|
|
33
97
|
export function formatBlock(content, blockName, format) {
|
|
34
98
|
switch (format) {
|
|
35
99
|
case "xml":
|
|
@@ -42,3 +106,140 @@ export function formatBlock(content, blockName, format) {
|
|
|
42
106
|
throw new Error(`Unsupported format: ${format}`);
|
|
43
107
|
}
|
|
44
108
|
}
|
|
109
|
+
/**
|
|
110
|
+
* Capitalizes the first character of a string.
|
|
111
|
+
*
|
|
112
|
+
* @param str - The string to capitalize
|
|
113
|
+
* @returns The string with first character capitalized
|
|
114
|
+
*
|
|
115
|
+
* @example
|
|
116
|
+
* ```typescript
|
|
117
|
+
* capitalize("hello") // Returns: "Hello"
|
|
118
|
+
* ```
|
|
119
|
+
*/
|
|
120
|
+
export const capitalize = (str) => str.charAt(0).toUpperCase() + str.slice(1);
|
|
121
|
+
/**
|
|
122
|
+
* Formats memory usage in bytes into human-readable units (KB, MB, GB).
|
|
123
|
+
*
|
|
124
|
+
* @param bytes - Memory usage in bytes
|
|
125
|
+
* @returns Formatted memory usage string
|
|
126
|
+
*
|
|
127
|
+
* @example
|
|
128
|
+
* ```typescript
|
|
129
|
+
* formatMemoryUsage(1024) // Returns: "1.0 KB"
|
|
130
|
+
* formatMemoryUsage(1048576) // Returns: "1.0 MB"
|
|
131
|
+
* formatMemoryUsage(1073741824) // Returns: "1.00 GB"
|
|
132
|
+
* ```
|
|
133
|
+
*/
|
|
134
|
+
export const formatMemoryUsage = (bytes) => {
|
|
135
|
+
const gb = bytes / (1024 * 1024 * 1024);
|
|
136
|
+
if (bytes < 1024 * 1024) {
|
|
137
|
+
return `${(bytes / 1024).toFixed(1)} KB`;
|
|
138
|
+
}
|
|
139
|
+
if (bytes < 1024 * 1024 * 1024) {
|
|
140
|
+
return `${(bytes / (1024 * 1024)).toFixed(1)} MB`;
|
|
141
|
+
}
|
|
142
|
+
return `${gb.toFixed(2)} GB`;
|
|
143
|
+
};
|
|
144
|
+
/**
|
|
145
|
+
* Formats a duration in milliseconds into a concise, human-readable string.
|
|
146
|
+
* Omits any time units that are zero.
|
|
147
|
+
*
|
|
148
|
+
* @param milliseconds - The duration in milliseconds
|
|
149
|
+
* @returns A formatted string representing the duration
|
|
150
|
+
*
|
|
151
|
+
* @example
|
|
152
|
+
* ```typescript
|
|
153
|
+
* formatDuration(3661000) // Returns: "1h 1m 1s"
|
|
154
|
+
* formatDuration(500) // Returns: "500ms"
|
|
155
|
+
* formatDuration(1500) // Returns: "1.5s"
|
|
156
|
+
* ```
|
|
157
|
+
*/
|
|
158
|
+
export const formatDuration = (milliseconds) => {
|
|
159
|
+
if (milliseconds <= 0) {
|
|
160
|
+
return "0s";
|
|
161
|
+
}
|
|
162
|
+
if (milliseconds < 1000) {
|
|
163
|
+
return `${Math.round(milliseconds)}ms`;
|
|
164
|
+
}
|
|
165
|
+
const totalSeconds = milliseconds / 1000;
|
|
166
|
+
if (totalSeconds < 60) {
|
|
167
|
+
return `${totalSeconds.toFixed(1)}s`;
|
|
168
|
+
}
|
|
169
|
+
const hours = Math.floor(totalSeconds / 3600);
|
|
170
|
+
const minutes = Math.floor((totalSeconds % 3600) / 60);
|
|
171
|
+
const seconds = Math.floor(totalSeconds % 60);
|
|
172
|
+
const parts = [];
|
|
173
|
+
if (hours > 0) {
|
|
174
|
+
parts.push(`${hours}h`);
|
|
175
|
+
}
|
|
176
|
+
if (minutes > 0) {
|
|
177
|
+
parts.push(`${minutes}m`);
|
|
178
|
+
}
|
|
179
|
+
if (seconds > 0) {
|
|
180
|
+
parts.push(`${seconds}s`);
|
|
181
|
+
}
|
|
182
|
+
// If all parts are zero (e.g., exactly 1 hour), return the largest unit.
|
|
183
|
+
if (parts.length === 0) {
|
|
184
|
+
if (hours > 0)
|
|
185
|
+
return `${hours}h`;
|
|
186
|
+
if (minutes > 0)
|
|
187
|
+
return `${minutes}m`;
|
|
188
|
+
return `${seconds}s`;
|
|
189
|
+
}
|
|
190
|
+
return parts.join(" ");
|
|
191
|
+
};
|
|
192
|
+
/**
|
|
193
|
+
* Formats a number into a compact, human-readable string.
|
|
194
|
+
* Uses K, M, B, T notation for large numbers while maintaining readability.
|
|
195
|
+
*
|
|
196
|
+
* @param num - The number to format
|
|
197
|
+
* @returns A formatted string representing the number
|
|
198
|
+
*
|
|
199
|
+
* @example
|
|
200
|
+
* ```typescript
|
|
201
|
+
* formatNumber(1) // Returns: "1"
|
|
202
|
+
* formatNumber(100) // Returns: "100"
|
|
203
|
+
* formatNumber(1000) // Returns: "1K"
|
|
204
|
+
* formatNumber(1100) // Returns: "1.1K"
|
|
205
|
+
* formatNumber(1234567) // Returns: "1.2M"
|
|
206
|
+
* formatNumber(1234567890) // Returns: "1.2B"
|
|
207
|
+
* formatNumber(1234567890123) // Returns: "1.2T"
|
|
208
|
+
* ```
|
|
209
|
+
*/
|
|
210
|
+
export const formatNumber = (num) => {
|
|
211
|
+
if (num < 1000) {
|
|
212
|
+
return num.toString();
|
|
213
|
+
}
|
|
214
|
+
const units = ["", "K", "M", "B", "T"];
|
|
215
|
+
// Calculate unit index based on number of digits
|
|
216
|
+
const numDigits = Math.floor(Math.log10(num)) + 1;
|
|
217
|
+
let unitIndex = Math.min(Math.floor((numDigits - 1) / 3), units.length - 1);
|
|
218
|
+
let unit = units[unitIndex] || "";
|
|
219
|
+
// Calculate scaled value
|
|
220
|
+
let scaled = num / 1000 ** unitIndex;
|
|
221
|
+
// Check if we need to move to the next unit (e.g., 999.999K -> 1M)
|
|
222
|
+
if (Math.round(scaled) >= 1000 && unitIndex < units.length - 1) {
|
|
223
|
+
unitIndex++;
|
|
224
|
+
unit = units[unitIndex] || "";
|
|
225
|
+
scaled = num / 1000 ** unitIndex;
|
|
226
|
+
}
|
|
227
|
+
// Determine decimal places based on the value
|
|
228
|
+
if (scaled < 10) {
|
|
229
|
+
// For values under 10, show one decimal place unless it's a whole number
|
|
230
|
+
// Also handle the case where rounding would give a whole number
|
|
231
|
+
const rounded = Math.round(scaled * 10) / 10;
|
|
232
|
+
return rounded % 1 === 0
|
|
233
|
+
? `${Math.round(rounded)}${unit}`
|
|
234
|
+
: `${rounded.toFixed(1)}${unit}`;
|
|
235
|
+
}
|
|
236
|
+
if (scaled < 100) {
|
|
237
|
+
// For values between 10-100, show one decimal place unless it's a whole number
|
|
238
|
+
const rounded = Math.round(scaled * 10) / 10;
|
|
239
|
+
return rounded % 1 === 0
|
|
240
|
+
? `${Math.round(rounded)}${unit}`
|
|
241
|
+
: `${rounded.toFixed(1)}${unit}`;
|
|
242
|
+
}
|
|
243
|
+
// For values 100+, round to nearest whole number
|
|
244
|
+
return `${Math.round(scaled)}${unit}`;
|
|
245
|
+
};
|
package/dist/index.d.ts
CHANGED
|
@@ -1,11 +1,16 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
+
export interface WorkspaceContext {
|
|
3
|
+
primaryDir: string;
|
|
4
|
+
allowedDirs: string[];
|
|
5
|
+
}
|
|
6
|
+
export declare function createWorkspaceContext(addDirArgs?: string[]): WorkspaceContext;
|
|
2
7
|
declare const flags: {
|
|
3
8
|
model?: string | undefined;
|
|
4
9
|
prompt?: string | undefined;
|
|
5
|
-
oneshot: boolean;
|
|
6
10
|
continue: boolean;
|
|
7
11
|
resume: boolean;
|
|
8
|
-
|
|
12
|
+
"add-dir"?: string[] | undefined;
|
|
13
|
+
"no-skills": boolean;
|
|
9
14
|
help?: boolean | undefined;
|
|
10
15
|
version?: boolean | undefined;
|
|
11
16
|
};
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../source/index.ts"],"names":[],"mappings":";
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../source/index.ts"],"names":[],"mappings":";AAkCA,MAAM,WAAW,gBAAgB;IAC/B,UAAU,EAAE,MAAM,CAAC;IACnB,WAAW,EAAE,MAAM,EAAE,CAAC;CACvB;AAGD,wBAAgB,sBAAsB,CACpC,UAAU,GAAE,MAAM,EAAO,GACxB,gBAAgB,CAmBlB;AAuCD,QAAA,MAAM,KAAK;;;;;;;;;CAAgB,CAAC;AAM5B;;;;GAIG;AACH,wBAAgB,WAAW,CAAC,KAAK,EAAE,KAAK,GAAG,IAAI,CAE9C;AAED,MAAM,MAAM,KAAK,GAAG,OAAO,KAAK,CAAC"}
|