@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/skills.js
ADDED
|
@@ -0,0 +1,192 @@
|
|
|
1
|
+
import { readdir, readFile, stat } from "node:fs/promises";
|
|
2
|
+
import { homedir } from "node:os";
|
|
3
|
+
import { join, resolve, sep } from "node:path";
|
|
4
|
+
import { logger } from "./logger.js";
|
|
5
|
+
const CONFIG_DIR_NAME = ".acai";
|
|
6
|
+
function stripQuotes(str) {
|
|
7
|
+
if ((str.startsWith('"') && str.endsWith('"')) ||
|
|
8
|
+
(str.startsWith("'") && str.endsWith("'"))) {
|
|
9
|
+
return str.slice(1, -1);
|
|
10
|
+
}
|
|
11
|
+
return str;
|
|
12
|
+
}
|
|
13
|
+
function parseFrontmatter(content) {
|
|
14
|
+
const frontmatter = { description: "" };
|
|
15
|
+
const normalizedContent = content.replace(/\r\n/g, "\n").replace(/\r/g, "\n");
|
|
16
|
+
if (!normalizedContent.startsWith("---")) {
|
|
17
|
+
return { frontmatter, body: normalizedContent };
|
|
18
|
+
}
|
|
19
|
+
const endIndex = normalizedContent.indexOf("\n---", 3);
|
|
20
|
+
if (endIndex === -1) {
|
|
21
|
+
return { frontmatter, body: normalizedContent };
|
|
22
|
+
}
|
|
23
|
+
const frontmatterBlock = normalizedContent.slice(4, endIndex);
|
|
24
|
+
const body = normalizedContent.slice(endIndex + 4).trim();
|
|
25
|
+
for (const line of frontmatterBlock.split("\n")) {
|
|
26
|
+
const match = line.match(/^(\w+):\s*(.*)$/);
|
|
27
|
+
if (match) {
|
|
28
|
+
const key = match[1];
|
|
29
|
+
const value = stripQuotes(match[2].trim());
|
|
30
|
+
if (key === "name") {
|
|
31
|
+
frontmatter.name = value;
|
|
32
|
+
}
|
|
33
|
+
else if (key === "description") {
|
|
34
|
+
frontmatter.description = value;
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
return { frontmatter, body };
|
|
39
|
+
}
|
|
40
|
+
async function loadSkillsFromDirInternal(dir, source, mode, useColonPath, subdir = "") {
|
|
41
|
+
const skills = [];
|
|
42
|
+
const fullDir = join(dir, subdir);
|
|
43
|
+
try {
|
|
44
|
+
const entries = await readdir(fullDir, { withFileTypes: true });
|
|
45
|
+
for (const entry of entries) {
|
|
46
|
+
// Skip hidden files and directories
|
|
47
|
+
if (entry.name.startsWith(".")) {
|
|
48
|
+
continue;
|
|
49
|
+
}
|
|
50
|
+
const entryPath = join(fullDir, entry.name);
|
|
51
|
+
// Skip symbolic links to avoid infinite recursion
|
|
52
|
+
try {
|
|
53
|
+
const stats = await stat(entryPath);
|
|
54
|
+
if (stats.isSymbolicLink()) {
|
|
55
|
+
continue;
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
catch {
|
|
59
|
+
// If we can't stat, skip it
|
|
60
|
+
continue;
|
|
61
|
+
}
|
|
62
|
+
if (entry.isDirectory()) {
|
|
63
|
+
if (mode === "recursive") {
|
|
64
|
+
// Recursively scan subdirectories
|
|
65
|
+
const newSubdir = subdir ? join(subdir, entry.name) : entry.name;
|
|
66
|
+
const subSkills = await loadSkillsFromDirInternal(dir, source, mode, useColonPath, newSubdir);
|
|
67
|
+
skills.push(...subSkills);
|
|
68
|
+
}
|
|
69
|
+
else if (mode === "claude") {
|
|
70
|
+
// Claude mode: only check immediate subdirectories for SKILL.md
|
|
71
|
+
const skillPath = join(entryPath, "SKILL.md");
|
|
72
|
+
try {
|
|
73
|
+
const content = await readFile(skillPath, "utf8");
|
|
74
|
+
const { frontmatter } = parseFrontmatter(content);
|
|
75
|
+
if (!frontmatter.description) {
|
|
76
|
+
continue;
|
|
77
|
+
}
|
|
78
|
+
const skillName = frontmatter.name || entry.name;
|
|
79
|
+
skills.push({
|
|
80
|
+
name: skillName,
|
|
81
|
+
description: frontmatter.description,
|
|
82
|
+
filePath: skillPath,
|
|
83
|
+
baseDir: entryPath,
|
|
84
|
+
source,
|
|
85
|
+
});
|
|
86
|
+
}
|
|
87
|
+
catch (error) {
|
|
88
|
+
logger.warn(error, `Failed to load skill from ${skillPath}:`);
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
else if (entry.isFile() &&
|
|
93
|
+
entry.name === "SKILL.md" &&
|
|
94
|
+
mode === "recursive") {
|
|
95
|
+
// Found a SKILL.md file in recursive mode
|
|
96
|
+
try {
|
|
97
|
+
const content = await readFile(entryPath, "utf8");
|
|
98
|
+
const { frontmatter } = parseFrontmatter(content);
|
|
99
|
+
if (!frontmatter.description) {
|
|
100
|
+
continue;
|
|
101
|
+
}
|
|
102
|
+
// Determine skill name
|
|
103
|
+
let skillName;
|
|
104
|
+
if (frontmatter.name) {
|
|
105
|
+
skillName = frontmatter.name;
|
|
106
|
+
}
|
|
107
|
+
else if (useColonPath && subdir) {
|
|
108
|
+
// Use colon-separated path for subdirectories
|
|
109
|
+
skillName = subdir.split(sep).join(":");
|
|
110
|
+
}
|
|
111
|
+
else if (subdir) {
|
|
112
|
+
// Use the directory name
|
|
113
|
+
const dirParts = subdir.split(sep);
|
|
114
|
+
skillName = dirParts[dirParts.length - 1];
|
|
115
|
+
}
|
|
116
|
+
else {
|
|
117
|
+
// Shouldn't happen in practice, but fallback
|
|
118
|
+
skillName = "unnamed";
|
|
119
|
+
}
|
|
120
|
+
// Base directory is the directory containing the SKILL.md file
|
|
121
|
+
const baseDir = subdir ? join(dir, subdir) : dir;
|
|
122
|
+
skills.push({
|
|
123
|
+
name: skillName,
|
|
124
|
+
description: frontmatter.description,
|
|
125
|
+
filePath: entryPath,
|
|
126
|
+
baseDir,
|
|
127
|
+
source,
|
|
128
|
+
});
|
|
129
|
+
}
|
|
130
|
+
catch (error) {
|
|
131
|
+
logger.warn(error, `Failed to load skill from ${entryPath}:`);
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
catch (error) {
|
|
137
|
+
// Directory doesn't exist or can't be read
|
|
138
|
+
if (error.code !== "ENOENT") {
|
|
139
|
+
logger.error(error, `Error reading skills directory ${fullDir}:`);
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
return skills;
|
|
143
|
+
}
|
|
144
|
+
export async function loadSkillsFromDir(options, subdir = "") {
|
|
145
|
+
const { dir, source, useColonPath = false } = options;
|
|
146
|
+
return await loadSkillsFromDirInternal(dir, source, "recursive", useColonPath, subdir);
|
|
147
|
+
}
|
|
148
|
+
export async function loadSkills() {
|
|
149
|
+
const skillMap = new Map();
|
|
150
|
+
// Codex: recursive, simple directory name
|
|
151
|
+
const codexUserDir = join(homedir(), ".codex", "skills");
|
|
152
|
+
for (const skill of await loadSkillsFromDirInternal(codexUserDir, "codex-user", "recursive", false)) {
|
|
153
|
+
skillMap.set(skill.name, skill);
|
|
154
|
+
}
|
|
155
|
+
// Claude: single level only
|
|
156
|
+
const claudeUserDir = join(homedir(), ".claude", "skills");
|
|
157
|
+
for (const skill of await loadSkillsFromDirInternal(claudeUserDir, "claude-user", "claude", false)) {
|
|
158
|
+
skillMap.set(skill.name, skill);
|
|
159
|
+
}
|
|
160
|
+
const claudeProjectDir = resolve(process.cwd(), ".claude", "skills");
|
|
161
|
+
for (const skill of await loadSkillsFromDirInternal(claudeProjectDir, "claude-project", "claude", false)) {
|
|
162
|
+
skillMap.set(skill.name, skill);
|
|
163
|
+
}
|
|
164
|
+
// Pi: recursive, colon-separated path names
|
|
165
|
+
const globalSkillsDir = join(homedir(), CONFIG_DIR_NAME, "skills");
|
|
166
|
+
for (const skill of await loadSkillsFromDirInternal(globalSkillsDir, "user", "recursive", true)) {
|
|
167
|
+
skillMap.set(skill.name, skill);
|
|
168
|
+
}
|
|
169
|
+
const projectSkillsDir = resolve(process.cwd(), CONFIG_DIR_NAME, "skills");
|
|
170
|
+
for (const skill of await loadSkillsFromDirInternal(projectSkillsDir, "project", "recursive", true)) {
|
|
171
|
+
skillMap.set(skill.name, skill);
|
|
172
|
+
}
|
|
173
|
+
return Array.from(skillMap.values());
|
|
174
|
+
}
|
|
175
|
+
export function formatSkillsForPrompt(skills) {
|
|
176
|
+
if (skills.length === 0) {
|
|
177
|
+
return "";
|
|
178
|
+
}
|
|
179
|
+
const lines = [
|
|
180
|
+
"\n\n<available_skills>",
|
|
181
|
+
"The following skills provide specialized instructions for specific tasks.",
|
|
182
|
+
"Use the readFile tool to load a skill's file when the task matches its description.",
|
|
183
|
+
"Skills may contain {baseDir} placeholders - replace them with the skill's base directory path.\n",
|
|
184
|
+
];
|
|
185
|
+
for (const skill of skills) {
|
|
186
|
+
lines.push(`- ${skill.name}: ${skill.description}`);
|
|
187
|
+
lines.push(` File: ${skill.filePath}`);
|
|
188
|
+
lines.push(` Base directory: ${skill.baseDir}`);
|
|
189
|
+
}
|
|
190
|
+
lines.push("</available_skills>");
|
|
191
|
+
return lines.join("\n");
|
|
192
|
+
}
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Terminal Control Module
|
|
3
|
+
*
|
|
4
|
+
* Provides functions for controlling terminal behavior and state.
|
|
5
|
+
*/
|
|
6
|
+
/**
|
|
7
|
+
* Get the current shell
|
|
8
|
+
*/
|
|
9
|
+
export declare function getShell(): string;
|
|
10
|
+
/**
|
|
11
|
+
* Check if terminal is interactive
|
|
12
|
+
*/
|
|
13
|
+
export declare function isInteractive(): boolean;
|
|
14
|
+
/**
|
|
15
|
+
* Send terminal alert/notification
|
|
16
|
+
*/
|
|
17
|
+
export declare function alert(): Promise<void>;
|
|
18
|
+
/**
|
|
19
|
+
* Clear the terminal screen
|
|
20
|
+
*/
|
|
21
|
+
export declare function clearScreen(): void;
|
|
22
|
+
/**
|
|
23
|
+
* Clear the terminal screen including scrollback buffer
|
|
24
|
+
*
|
|
25
|
+
* Unlike clearScreen, this function:
|
|
26
|
+
* 1. Clears the entire screen (\x1b[2J)
|
|
27
|
+
* 2. Clears the scrollback buffer (\x1b[3J)
|
|
28
|
+
* 3. Moves cursor to home position (\x1b[H)
|
|
29
|
+
* 4. Returns a Promise that resolves when the write operation completes
|
|
30
|
+
*
|
|
31
|
+
* @returns Promise that resolves when the terminal has been cleared
|
|
32
|
+
*/
|
|
33
|
+
export declare function clearTerminal(): Promise<void>;
|
|
34
|
+
/**
|
|
35
|
+
* Sets the terminal title
|
|
36
|
+
*/
|
|
37
|
+
export declare function setTerminalTitle(title: string): void;
|
|
38
|
+
/**
|
|
39
|
+
* Get the terminal size (rows and columns)
|
|
40
|
+
*/
|
|
41
|
+
export declare function getTerminalSize(): {
|
|
42
|
+
rows: number;
|
|
43
|
+
columns: number;
|
|
44
|
+
};
|
|
45
|
+
/**
|
|
46
|
+
* Start progress indicator in terminal
|
|
47
|
+
* Sends terminal escape sequence to show progress animation
|
|
48
|
+
*/
|
|
49
|
+
export declare function startProgress(): void;
|
|
50
|
+
/**
|
|
51
|
+
* Stop progress indicator in terminal
|
|
52
|
+
* Sends terminal escape sequence to hide progress animation
|
|
53
|
+
*/
|
|
54
|
+
export declare function stopProgress(): void;
|
|
55
|
+
//# sourceMappingURL=control.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"control.d.ts","sourceRoot":"","sources":["../../source/terminal/control.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAKH;;GAEG;AACH,wBAAgB,QAAQ,WAEvB;AAED;;GAEG;AACH,wBAAgB,aAAa,YAE5B;AAED;;GAEG;AACH,wBAAsB,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC,CAkB3C;AAED;;GAEG;AACH,wBAAgB,WAAW,IAAI,IAAI,CAGlC;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,aAAa,IAAI,OAAO,CAAC,IAAI,CAAC,CAM7C;AAED;;GAEG;AACH,wBAAgB,gBAAgB,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI,CAMpD;AAED;;GAEG;AACH,wBAAgB,eAAe,IAAI;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,OAAO,EAAE,MAAM,CAAA;CAAE,CAgBnE;AAED;;;GAGG;AACH,wBAAgB,aAAa,IAAI,IAAI,CAEpC;AAED;;;GAGG;AACH,wBAAgB,YAAY,IAAI,IAAI,CAEnC"}
|
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Terminal Control Module
|
|
3
|
+
*
|
|
4
|
+
* Provides functions for controlling terminal behavior and state.
|
|
5
|
+
*/
|
|
6
|
+
import { config } from "../config.js";
|
|
7
|
+
import { logger } from "../logger.js";
|
|
8
|
+
/**
|
|
9
|
+
* Get the current shell
|
|
10
|
+
*/
|
|
11
|
+
export function getShell() {
|
|
12
|
+
return process.env["ZSH_VERSION"] ? "zsh" : process.env["SHELL"] || "bash";
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* Check if terminal is interactive
|
|
16
|
+
*/
|
|
17
|
+
export function isInteractive() {
|
|
18
|
+
return Boolean(process.stdout.isTTY && process.stdin.isTTY);
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* Send terminal alert/notification
|
|
22
|
+
*/
|
|
23
|
+
export async function alert() {
|
|
24
|
+
if (!(await config.getConfig()).notify) {
|
|
25
|
+
return;
|
|
26
|
+
}
|
|
27
|
+
const t = "acai";
|
|
28
|
+
const b = "";
|
|
29
|
+
try {
|
|
30
|
+
process.stdout.write("\x07");
|
|
31
|
+
const esc = "\u001b";
|
|
32
|
+
const bel = "\u0007";
|
|
33
|
+
const safe = (s) => s.replaceAll("\u0007", "").replaceAll("\u001b", "");
|
|
34
|
+
const payload = `${esc}]777;notify;${safe(t)};${safe(b)}${bel}`;
|
|
35
|
+
process.stdout.write(payload);
|
|
36
|
+
}
|
|
37
|
+
catch (err) {
|
|
38
|
+
logger.warn({ err }, "Failed to emit alert");
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* Clear the terminal screen
|
|
43
|
+
*/
|
|
44
|
+
export function clearScreen() {
|
|
45
|
+
// Clear screen and move cursor to top-left
|
|
46
|
+
process.stdout.write("\x1b[2J\x1b[0f");
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* Clear the terminal screen including scrollback buffer
|
|
50
|
+
*
|
|
51
|
+
* Unlike clearScreen, this function:
|
|
52
|
+
* 1. Clears the entire screen (\x1b[2J)
|
|
53
|
+
* 2. Clears the scrollback buffer (\x1b[3J)
|
|
54
|
+
* 3. Moves cursor to home position (\x1b[H)
|
|
55
|
+
* 4. Returns a Promise that resolves when the write operation completes
|
|
56
|
+
*
|
|
57
|
+
* @returns Promise that resolves when the terminal has been cleared
|
|
58
|
+
*/
|
|
59
|
+
export function clearTerminal() {
|
|
60
|
+
return new Promise((resolve) => {
|
|
61
|
+
process.stdout.write("\x1b[2J\x1b[3J\x1b[H", () => {
|
|
62
|
+
resolve();
|
|
63
|
+
});
|
|
64
|
+
});
|
|
65
|
+
}
|
|
66
|
+
/**
|
|
67
|
+
* Sets the terminal title
|
|
68
|
+
*/
|
|
69
|
+
export function setTerminalTitle(title) {
|
|
70
|
+
if (process.platform === "win32") {
|
|
71
|
+
process.title = title ? `✳✳ ${title}` : title;
|
|
72
|
+
}
|
|
73
|
+
else {
|
|
74
|
+
process.stdout.write(`\x1b]0;${title ? `✳✳ ${title}` : ""}\x07`);
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
/**
|
|
78
|
+
* Get the terminal size (rows and columns)
|
|
79
|
+
*/
|
|
80
|
+
export function getTerminalSize() {
|
|
81
|
+
// Default to a reasonable size if we can't determine the actual size
|
|
82
|
+
const defaultSize = { rows: 24, columns: 80 };
|
|
83
|
+
try {
|
|
84
|
+
if (process.stdout.isTTY) {
|
|
85
|
+
return {
|
|
86
|
+
rows: process.stdout.rows || defaultSize.rows,
|
|
87
|
+
columns: process.stdout.columns || defaultSize.columns,
|
|
88
|
+
};
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
catch (_error) {
|
|
92
|
+
// Ignore errors
|
|
93
|
+
}
|
|
94
|
+
return defaultSize;
|
|
95
|
+
}
|
|
96
|
+
/**
|
|
97
|
+
* Start progress indicator in terminal
|
|
98
|
+
* Sends terminal escape sequence to show progress animation
|
|
99
|
+
*/
|
|
100
|
+
export function startProgress() {
|
|
101
|
+
process.stdout.write("\u001b]9;4;3;0\u0007");
|
|
102
|
+
}
|
|
103
|
+
/**
|
|
104
|
+
* Stop progress indicator in terminal
|
|
105
|
+
* Sends terminal escape sequence to hide progress animation
|
|
106
|
+
*/
|
|
107
|
+
export function stopProgress() {
|
|
108
|
+
process.stdout.write("\u001b]9;4;0;0\u0007");
|
|
109
|
+
}
|
|
@@ -2,5 +2,5 @@ import type { Theme } from "./highlight/theme.ts";
|
|
|
2
2
|
/**
|
|
3
3
|
* The default theme. It is possible to override just individual keys.
|
|
4
4
|
*/
|
|
5
|
-
export declare const
|
|
5
|
+
export declare const DEFAULT_HIGHLIGHT_THEME: Theme;
|
|
6
6
|
//# sourceMappingURL=default-theme.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"default-theme.d.ts","sourceRoot":"","sources":["../../source/terminal/default-theme.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"default-theme.d.ts","sourceRoot":"","sources":["../../source/terminal/default-theme.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,sBAAsB,CAAC;AAGlD;;GAEG;AACH,eAAO,MAAM,uBAAuB,EAAE,KAqNrC,CAAC"}
|
|
@@ -1,13 +1,9 @@
|
|
|
1
|
+
import { id } from "../utils/funcs.js";
|
|
1
2
|
import style from "./style.js";
|
|
2
|
-
/**
|
|
3
|
-
* Identity function for tokens that should not be styled (returns the input string as-is).
|
|
4
|
-
* See [[Theme]] for an example.
|
|
5
|
-
*/
|
|
6
|
-
const plain = (codePart) => codePart;
|
|
7
3
|
/**
|
|
8
4
|
* The default theme. It is possible to override just individual keys.
|
|
9
5
|
*/
|
|
10
|
-
export const
|
|
6
|
+
export const DEFAULT_HIGHLIGHT_THEME = {
|
|
11
7
|
/**
|
|
12
8
|
* keyword in a regular Algol-style language
|
|
13
9
|
*/
|
|
@@ -41,11 +37,11 @@ export const DEFAULT_THEME = {
|
|
|
41
37
|
/**
|
|
42
38
|
* parsed section inside a literal string
|
|
43
39
|
*/
|
|
44
|
-
subst:
|
|
40
|
+
subst: id,
|
|
45
41
|
/**
|
|
46
42
|
* symbolic constant, interned string, goto label
|
|
47
43
|
*/
|
|
48
|
-
symbol:
|
|
44
|
+
symbol: id,
|
|
49
45
|
/**
|
|
50
46
|
* class or class-level declaration (interfaces, traits, modules, etc)
|
|
51
47
|
*/
|
|
@@ -57,11 +53,11 @@ export const DEFAULT_THEME = {
|
|
|
57
53
|
/**
|
|
58
54
|
* name of a class or a function at the place of declaration
|
|
59
55
|
*/
|
|
60
|
-
title:
|
|
56
|
+
title: id,
|
|
61
57
|
/**
|
|
62
58
|
* block of function arguments (parameters) at the place of declaration
|
|
63
59
|
*/
|
|
64
|
-
params:
|
|
60
|
+
params: id,
|
|
65
61
|
/**
|
|
66
62
|
* comment
|
|
67
63
|
*/
|
|
@@ -77,15 +73,15 @@ export const DEFAULT_THEME = {
|
|
|
77
73
|
/**
|
|
78
74
|
* keyword or built-in within meta construct
|
|
79
75
|
*/
|
|
80
|
-
"meta-keyword":
|
|
76
|
+
"meta-keyword": id,
|
|
81
77
|
/**
|
|
82
78
|
* string within meta construct
|
|
83
79
|
*/
|
|
84
|
-
"meta-string":
|
|
80
|
+
"meta-string": id,
|
|
85
81
|
/**
|
|
86
82
|
* heading of a section in a config file, heading in text markup
|
|
87
83
|
*/
|
|
88
|
-
section:
|
|
84
|
+
section: id,
|
|
89
85
|
/**
|
|
90
86
|
* XML/HTML tag
|
|
91
87
|
*/
|
|
@@ -97,7 +93,7 @@ export const DEFAULT_THEME = {
|
|
|
97
93
|
/**
|
|
98
94
|
* s-expression name from the language standard library
|
|
99
95
|
*/
|
|
100
|
-
"builtin-name":
|
|
96
|
+
"builtin-name": id,
|
|
101
97
|
/**
|
|
102
98
|
* name of an attribute with no language defined semantics (keys in JSON, setting names in
|
|
103
99
|
* .ini), also sub-attribute within another highlighted object, like XML tag
|
|
@@ -106,19 +102,19 @@ export const DEFAULT_THEME = {
|
|
|
106
102
|
/**
|
|
107
103
|
* name of an attribute followed by a structured value part, like CSS properties
|
|
108
104
|
*/
|
|
109
|
-
attribute:
|
|
105
|
+
attribute: id,
|
|
110
106
|
/**
|
|
111
107
|
* variable in a config or a template file, environment var expansion in a script
|
|
112
108
|
*/
|
|
113
|
-
variable:
|
|
109
|
+
variable: id,
|
|
114
110
|
/**
|
|
115
111
|
* list item bullet in text markup
|
|
116
112
|
*/
|
|
117
|
-
bullet:
|
|
113
|
+
bullet: id,
|
|
118
114
|
/**
|
|
119
115
|
* code block in text markup
|
|
120
116
|
*/
|
|
121
|
-
code:
|
|
117
|
+
code: id,
|
|
122
118
|
/**
|
|
123
119
|
* emphasis in text markup
|
|
124
120
|
*/
|
|
@@ -130,7 +126,7 @@ export const DEFAULT_THEME = {
|
|
|
130
126
|
/**
|
|
131
127
|
* mathematical formula in text markup
|
|
132
128
|
*/
|
|
133
|
-
formula:
|
|
129
|
+
formula: id,
|
|
134
130
|
/**
|
|
135
131
|
* hyperlink in text markup
|
|
136
132
|
*/
|
|
@@ -138,35 +134,35 @@ export const DEFAULT_THEME = {
|
|
|
138
134
|
/**
|
|
139
135
|
* quotation in text markup
|
|
140
136
|
*/
|
|
141
|
-
quote:
|
|
137
|
+
quote: id,
|
|
142
138
|
/**
|
|
143
139
|
* tag selector in CSS
|
|
144
140
|
*/
|
|
145
|
-
"selector-tag":
|
|
141
|
+
"selector-tag": id,
|
|
146
142
|
/**
|
|
147
143
|
* #id selector in CSS
|
|
148
144
|
*/
|
|
149
|
-
"selector-id":
|
|
145
|
+
"selector-id": id,
|
|
150
146
|
/**
|
|
151
147
|
* .class selector in CSS
|
|
152
148
|
*/
|
|
153
|
-
"selector-class":
|
|
149
|
+
"selector-class": id,
|
|
154
150
|
/**
|
|
155
151
|
* [attr] selector in CSS
|
|
156
152
|
*/
|
|
157
|
-
"selector-attr":
|
|
153
|
+
"selector-attr": id,
|
|
158
154
|
/**
|
|
159
155
|
* :pseudo selector in CSS
|
|
160
156
|
*/
|
|
161
|
-
"selector-pseudo":
|
|
157
|
+
"selector-pseudo": id,
|
|
162
158
|
/**
|
|
163
159
|
* tag of a template language
|
|
164
160
|
*/
|
|
165
|
-
"template-tag":
|
|
161
|
+
"template-tag": id,
|
|
166
162
|
/**
|
|
167
163
|
* variable in a template language
|
|
168
164
|
*/
|
|
169
|
-
"template-variable":
|
|
165
|
+
"template-variable": id,
|
|
170
166
|
/**
|
|
171
167
|
* added or changed line in a diff
|
|
172
168
|
*/
|
|
@@ -178,5 +174,5 @@ export const DEFAULT_THEME = {
|
|
|
178
174
|
/**
|
|
179
175
|
* things not matched by any token
|
|
180
176
|
*/
|
|
181
|
-
default:
|
|
177
|
+
default: id,
|
|
182
178
|
};
|
|
@@ -1,30 +1,8 @@
|
|
|
1
|
+
export { clearScreen, clearTerminal, getTerminalSize, setTerminalTitle, startProgress, stopProgress, } from "./control.ts";
|
|
1
2
|
/**
|
|
2
|
-
*
|
|
3
|
+
* Create a horizontal rule
|
|
3
4
|
*/
|
|
4
|
-
export declare function
|
|
5
|
-
/**
|
|
6
|
-
* Clear the terminal screen including scrollback buffer
|
|
7
|
-
*
|
|
8
|
-
* Unlike clearScreen, this function:
|
|
9
|
-
* 1. Clears the entire screen (\x1b[2J)
|
|
10
|
-
* 2. Clears the scrollback buffer (\x1b[3J)
|
|
11
|
-
* 3. Moves cursor to home position (\x1b[H)
|
|
12
|
-
* 4. Returns a Promise that resolves when the write operation completes
|
|
13
|
-
*
|
|
14
|
-
* @returns Promise that resolves when the terminal has been cleared
|
|
15
|
-
*/
|
|
16
|
-
export declare function clearTerminal(): Promise<void>;
|
|
17
|
-
/**
|
|
18
|
-
* Sets the terminal title
|
|
19
|
-
*/
|
|
20
|
-
export declare function setTerminalTitle(title: string): void;
|
|
21
|
-
/**
|
|
22
|
-
* Get the terminal size (rows and columns)
|
|
23
|
-
*/
|
|
24
|
-
export declare function getTerminalSize(): {
|
|
25
|
-
rows: number;
|
|
26
|
-
columns: number;
|
|
27
|
-
};
|
|
5
|
+
export declare function hr(width: number): string;
|
|
28
6
|
/**
|
|
29
7
|
* Word wrap text to the specified width
|
|
30
8
|
*/
|
|
@@ -35,4 +13,24 @@ export declare const image: (data: string | Buffer, options?: {
|
|
|
35
13
|
height?: number | string;
|
|
36
14
|
preserveAspectRatio?: boolean;
|
|
37
15
|
}) => string;
|
|
16
|
+
/**
|
|
17
|
+
* Display a message with emphasis
|
|
18
|
+
*/
|
|
19
|
+
export declare function emphasize(message: string): string;
|
|
20
|
+
/**
|
|
21
|
+
* Display an informational message
|
|
22
|
+
*/
|
|
23
|
+
export declare function info(message: string): string;
|
|
24
|
+
/**
|
|
25
|
+
* Display a success message
|
|
26
|
+
*/
|
|
27
|
+
export declare function success(message: string): string;
|
|
28
|
+
/**
|
|
29
|
+
* Display a warning message
|
|
30
|
+
*/
|
|
31
|
+
export declare function warn(message: string): string;
|
|
32
|
+
/**
|
|
33
|
+
* Display an error message
|
|
34
|
+
*/
|
|
35
|
+
export declare function error(message: string): string;
|
|
38
36
|
//# sourceMappingURL=formatting.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"formatting.d.ts","sourceRoot":"","sources":["../../source/terminal/formatting.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"formatting.d.ts","sourceRoot":"","sources":["../../source/terminal/formatting.ts"],"names":[],"mappings":"AAQA,OAAO,EACL,WAAW,EACX,aAAa,EACb,eAAe,EACf,gBAAgB,EAChB,aAAa,EACb,YAAY,GACb,MAAM,cAAc,CAAC;AAEtB;;GAEG;AACH,wBAAgB,EAAE,CAAC,KAAK,EAAE,MAAM,UAE/B;AAED;;GAEG;AACH,wBAAgB,QAAQ,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,MAAM,CAI5D;AA2CD,eAAO,MAAM,IAAI,GAAI,MAAM,MAAM,EAAE,KAAK,MAAM,WAO7C,CAAC;AAEF,eAAO,MAAM,KAAK,GAChB,MAAM,MAAM,GAAG,MAAM,EACrB,UAAS;IACP,KAAK,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC;IACxB,MAAM,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC;IACzB,mBAAmB,CAAC,EAAE,OAAO,CAAC;CAC1B,WAiBP,CAAC;AAEF;;GAEG;AACH,wBAAgB,SAAS,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM,CAEjD;AAED;;GAEG;AACH,wBAAgB,IAAI,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM,CAE5C;AAED;;GAEG;AACH,wBAAgB,OAAO,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM,CAE/C;AAED;;GAEG;AACH,wBAAgB,IAAI,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM,CAE5C;AAED;;GAEG;AACH,wBAAgB,KAAK,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM,CAE7C"}
|
|
@@ -3,61 +3,14 @@
|
|
|
3
3
|
*
|
|
4
4
|
* Provides functions for formatting and displaying text in the terminal.
|
|
5
5
|
*/
|
|
6
|
+
import style from "./style.js";
|
|
6
7
|
import { supportsHyperlinks } from "./supports-hyperlinks.js";
|
|
8
|
+
export { clearScreen, clearTerminal, getTerminalSize, setTerminalTitle, startProgress, stopProgress, } from "./control.js";
|
|
7
9
|
/**
|
|
8
|
-
*
|
|
10
|
+
* Create a horizontal rule
|
|
9
11
|
*/
|
|
10
|
-
export function
|
|
11
|
-
|
|
12
|
-
process.stdout.write("\x1b[2J\x1b[0f");
|
|
13
|
-
}
|
|
14
|
-
/**
|
|
15
|
-
* Clear the terminal screen including scrollback buffer
|
|
16
|
-
*
|
|
17
|
-
* Unlike clearScreen, this function:
|
|
18
|
-
* 1. Clears the entire screen (\x1b[2J)
|
|
19
|
-
* 2. Clears the scrollback buffer (\x1b[3J)
|
|
20
|
-
* 3. Moves cursor to home position (\x1b[H)
|
|
21
|
-
* 4. Returns a Promise that resolves when the write operation completes
|
|
22
|
-
*
|
|
23
|
-
* @returns Promise that resolves when the terminal has been cleared
|
|
24
|
-
*/
|
|
25
|
-
export function clearTerminal() {
|
|
26
|
-
return new Promise((resolve) => {
|
|
27
|
-
process.stdout.write("\x1b[2J\x1b[3J\x1b[H", () => {
|
|
28
|
-
resolve();
|
|
29
|
-
});
|
|
30
|
-
});
|
|
31
|
-
}
|
|
32
|
-
/**
|
|
33
|
-
* Sets the terminal title
|
|
34
|
-
*/
|
|
35
|
-
export function setTerminalTitle(title) {
|
|
36
|
-
if (process.platform === "win32") {
|
|
37
|
-
process.title = title ? `✳✳ ${title}` : title;
|
|
38
|
-
}
|
|
39
|
-
else {
|
|
40
|
-
process.stdout.write(`\x1b]0;${title ? `✳✳ ${title}` : ""}\x07`);
|
|
41
|
-
}
|
|
42
|
-
}
|
|
43
|
-
/**
|
|
44
|
-
* Get the terminal size (rows and columns)
|
|
45
|
-
*/
|
|
46
|
-
export function getTerminalSize() {
|
|
47
|
-
// Default to a reasonable size if we can't determine the actual size
|
|
48
|
-
const defaultSize = { rows: 24, columns: 80 };
|
|
49
|
-
try {
|
|
50
|
-
if (process.stdout.isTTY) {
|
|
51
|
-
return {
|
|
52
|
-
rows: process.stdout.rows || defaultSize.rows,
|
|
53
|
-
columns: process.stdout.columns || defaultSize.columns,
|
|
54
|
-
};
|
|
55
|
-
}
|
|
56
|
-
}
|
|
57
|
-
catch (_error) {
|
|
58
|
-
// Ignore errors
|
|
59
|
-
}
|
|
60
|
-
return defaultSize;
|
|
12
|
+
export function hr(width) {
|
|
13
|
+
return `${style.gray("─").repeat(width)}`;
|
|
61
14
|
}
|
|
62
15
|
/**
|
|
63
16
|
* Word wrap text to the specified width
|
|
@@ -122,3 +75,33 @@ export const image = (data, options = {}) => {
|
|
|
122
75
|
}
|
|
123
76
|
return `${returnValue}:${Buffer.from(data).toString("base64")}${BEL}`;
|
|
124
77
|
};
|
|
78
|
+
/**
|
|
79
|
+
* Display a message with emphasis
|
|
80
|
+
*/
|
|
81
|
+
export function emphasize(message) {
|
|
82
|
+
return style.cyan.bold(message);
|
|
83
|
+
}
|
|
84
|
+
/**
|
|
85
|
+
* Display an informational message
|
|
86
|
+
*/
|
|
87
|
+
export function info(message) {
|
|
88
|
+
return style.blue(`ℹ ${message}`);
|
|
89
|
+
}
|
|
90
|
+
/**
|
|
91
|
+
* Display a success message
|
|
92
|
+
*/
|
|
93
|
+
export function success(message) {
|
|
94
|
+
return style.green(`✓ ${message}`);
|
|
95
|
+
}
|
|
96
|
+
/**
|
|
97
|
+
* Display a warning message
|
|
98
|
+
*/
|
|
99
|
+
export function warn(message) {
|
|
100
|
+
return style.yellow(`⚠ ${message}`);
|
|
101
|
+
}
|
|
102
|
+
/**
|
|
103
|
+
* Display an error message
|
|
104
|
+
*/
|
|
105
|
+
export function error(message) {
|
|
106
|
+
return style.red(`✗ ${message}`);
|
|
107
|
+
}
|