terminal-pilot 0.0.30 → 0.0.32
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/dist/cli.js +1599 -497
- package/dist/cli.js.map +4 -4
- package/dist/commands/close-session.js +489 -6
- package/dist/commands/close-session.js.map +4 -4
- package/dist/commands/create-session.js +489 -6
- package/dist/commands/create-session.js.map +4 -4
- package/dist/commands/fill.js +489 -6
- package/dist/commands/fill.js.map +4 -4
- package/dist/commands/get-session.js +489 -6
- package/dist/commands/get-session.js.map +4 -4
- package/dist/commands/index.js +630 -44
- package/dist/commands/index.js.map +4 -4
- package/dist/commands/install.js +626 -40
- package/dist/commands/install.js.map +4 -4
- package/dist/commands/installer.js +68 -17
- package/dist/commands/installer.js.map +4 -4
- package/dist/commands/list-sessions.js +489 -6
- package/dist/commands/list-sessions.js.map +4 -4
- package/dist/commands/press-key.js +489 -6
- package/dist/commands/press-key.js.map +4 -4
- package/dist/commands/read-history.js +489 -6
- package/dist/commands/read-history.js.map +4 -4
- package/dist/commands/read-screen.js +489 -6
- package/dist/commands/read-screen.js.map +4 -4
- package/dist/commands/resize.js +489 -6
- package/dist/commands/resize.js.map +4 -4
- package/dist/commands/runtime.js.map +1 -1
- package/dist/commands/screenshot.js +489 -6
- package/dist/commands/screenshot.js.map +4 -4
- package/dist/commands/send-signal.js +489 -6
- package/dist/commands/send-signal.js.map +4 -4
- package/dist/commands/type.js +489 -6
- package/dist/commands/type.js.map +4 -4
- package/dist/commands/uninstall.js +554 -20
- package/dist/commands/uninstall.js.map +4 -4
- package/dist/commands/wait-for-exit.js +489 -6
- package/dist/commands/wait-for-exit.js.map +4 -4
- package/dist/commands/wait-for.js +489 -6
- package/dist/commands/wait-for.js.map +4 -4
- package/dist/testing/cli-repl.js +1599 -497
- package/dist/testing/cli-repl.js.map +4 -4
- package/dist/testing/qa-cli.js +1609 -507
- package/dist/testing/qa-cli.js.map +4 -4
- package/node_modules/@poe-code/agent-defs/README.md +35 -0
- package/node_modules/@poe-code/agent-defs/dist/agents/claude-code.d.ts +2 -0
- package/node_modules/@poe-code/agent-defs/dist/agents/claude-code.js +21 -0
- package/node_modules/@poe-code/agent-defs/dist/agents/claude-desktop.d.ts +2 -0
- package/node_modules/@poe-code/agent-defs/dist/agents/claude-desktop.js +18 -0
- package/node_modules/@poe-code/agent-defs/dist/agents/codex.d.ts +2 -0
- package/node_modules/@poe-code/agent-defs/dist/agents/codex.js +25 -0
- package/node_modules/@poe-code/agent-defs/dist/agents/cursor.d.ts +2 -0
- package/node_modules/@poe-code/agent-defs/dist/agents/cursor.js +15 -0
- package/node_modules/@poe-code/agent-defs/dist/agents/gemini-cli.d.ts +2 -0
- package/node_modules/@poe-code/agent-defs/dist/agents/gemini-cli.js +16 -0
- package/node_modules/@poe-code/agent-defs/dist/agents/goose.d.ts +2 -0
- package/node_modules/@poe-code/agent-defs/dist/agents/goose.js +16 -0
- package/node_modules/@poe-code/agent-defs/dist/agents/index.d.ts +9 -0
- package/node_modules/@poe-code/agent-defs/dist/agents/index.js +9 -0
- package/node_modules/@poe-code/agent-defs/dist/agents/kimi.d.ts +2 -0
- package/node_modules/@poe-code/agent-defs/dist/agents/kimi.js +16 -0
- package/node_modules/@poe-code/agent-defs/dist/agents/opencode.d.ts +2 -0
- package/node_modules/@poe-code/agent-defs/dist/agents/opencode.js +20 -0
- package/node_modules/@poe-code/agent-defs/dist/agents/poe-agent.d.ts +2 -0
- package/node_modules/@poe-code/agent-defs/dist/agents/poe-agent.js +14 -0
- package/node_modules/@poe-code/agent-defs/dist/index.d.ts +5 -0
- package/node_modules/@poe-code/agent-defs/dist/index.js +3 -0
- package/node_modules/@poe-code/agent-defs/dist/registry.d.ts +3 -0
- package/node_modules/@poe-code/agent-defs/dist/registry.js +45 -0
- package/node_modules/@poe-code/agent-defs/dist/specifier.d.ts +7 -0
- package/node_modules/@poe-code/agent-defs/dist/specifier.js +40 -0
- package/node_modules/@poe-code/agent-defs/dist/types.d.ts +28 -0
- package/node_modules/@poe-code/agent-defs/dist/types.js +1 -0
- package/node_modules/@poe-code/agent-defs/package.json +20 -0
- package/node_modules/@poe-code/agent-skill-config/dist/apply.js +2 -1
- package/node_modules/@poe-code/agent-skill-config/dist/bridge-active-skills.d.ts +1 -0
- package/node_modules/@poe-code/agent-skill-config/dist/bridge-active-skills.js +37 -18
- package/node_modules/@poe-code/agent-skill-config/dist/resolve-skill-reference.js +8 -4
- package/node_modules/@poe-code/agent-skill-config/package.json +1 -5
- package/node_modules/@poe-code/config-mutations/README.md +55 -0
- package/node_modules/@poe-code/config-mutations/dist/error-codes.d.ts +1 -0
- package/node_modules/@poe-code/config-mutations/dist/error-codes.js +6 -0
- package/node_modules/@poe-code/config-mutations/dist/execution/apply-mutation.d.ts +6 -0
- package/node_modules/@poe-code/config-mutations/dist/execution/apply-mutation.js +829 -0
- package/node_modules/@poe-code/config-mutations/dist/execution/path-utils.d.ts +17 -0
- package/node_modules/@poe-code/config-mutations/dist/execution/path-utils.js +64 -0
- package/node_modules/@poe-code/config-mutations/dist/execution/run-mutations.d.ts +7 -0
- package/node_modules/@poe-code/config-mutations/dist/execution/run-mutations.js +39 -0
- package/node_modules/@poe-code/config-mutations/dist/formats/index.d.ts +13 -0
- package/node_modules/@poe-code/config-mutations/dist/formats/index.js +49 -0
- package/node_modules/@poe-code/config-mutations/dist/formats/json.d.ts +32 -0
- package/node_modules/@poe-code/config-mutations/dist/formats/json.js +171 -0
- package/node_modules/@poe-code/config-mutations/dist/formats/object.d.ts +4 -0
- package/node_modules/@poe-code/config-mutations/dist/formats/object.js +27 -0
- package/node_modules/@poe-code/config-mutations/dist/formats/toml.d.ts +2 -0
- package/node_modules/@poe-code/config-mutations/dist/formats/toml.js +75 -0
- package/node_modules/@poe-code/config-mutations/dist/formats/yaml.d.ts +2 -0
- package/node_modules/@poe-code/config-mutations/dist/formats/yaml.js +76 -0
- package/node_modules/@poe-code/config-mutations/dist/fs-utils.d.ts +18 -0
- package/node_modules/@poe-code/config-mutations/dist/fs-utils.js +43 -0
- package/node_modules/@poe-code/config-mutations/dist/index.d.ts +8 -0
- package/node_modules/@poe-code/config-mutations/dist/index.js +8 -0
- package/node_modules/@poe-code/config-mutations/dist/mutations/config-mutation.d.ts +47 -0
- package/node_modules/@poe-code/config-mutations/dist/mutations/config-mutation.js +34 -0
- package/node_modules/@poe-code/config-mutations/dist/mutations/file-mutation.d.ts +62 -0
- package/node_modules/@poe-code/config-mutations/dist/mutations/file-mutation.js +55 -0
- package/node_modules/@poe-code/config-mutations/dist/mutations/template-mutation.d.ts +40 -0
- package/node_modules/@poe-code/config-mutations/dist/mutations/template-mutation.js +32 -0
- package/node_modules/@poe-code/config-mutations/dist/template/render.d.ts +6 -0
- package/node_modules/@poe-code/config-mutations/dist/template/render.js +8 -0
- package/node_modules/@poe-code/config-mutations/dist/testing/format-utils.d.ts +7 -0
- package/node_modules/@poe-code/config-mutations/dist/testing/format-utils.js +21 -0
- package/node_modules/@poe-code/config-mutations/dist/testing/index.d.ts +3 -0
- package/node_modules/@poe-code/config-mutations/dist/testing/index.js +2 -0
- package/node_modules/@poe-code/config-mutations/dist/testing/mock-fs.d.ts +25 -0
- package/node_modules/@poe-code/config-mutations/dist/testing/mock-fs.js +194 -0
- package/node_modules/@poe-code/config-mutations/dist/types.d.ts +168 -0
- package/node_modules/@poe-code/config-mutations/dist/types.js +6 -0
- package/node_modules/@poe-code/config-mutations/package.json +29 -0
- package/node_modules/@poe-code/frontmatter/README.md +35 -0
- package/node_modules/@poe-code/frontmatter/dist/fences.d.ts +25 -0
- package/node_modules/@poe-code/frontmatter/dist/fences.js +100 -0
- package/node_modules/@poe-code/frontmatter/dist/index.d.ts +3 -0
- package/node_modules/@poe-code/frontmatter/dist/index.js +3 -0
- package/node_modules/@poe-code/frontmatter/dist/parse.d.ts +20 -0
- package/node_modules/@poe-code/frontmatter/dist/parse.js +209 -0
- package/node_modules/@poe-code/frontmatter/dist/stringify.d.ts +1 -0
- package/node_modules/@poe-code/frontmatter/dist/stringify.js +48 -0
- package/node_modules/@poe-code/frontmatter/package.json +25 -0
- package/node_modules/toolcraft-design/README.md +160 -0
- package/node_modules/toolcraft-design/dist/acp/components.d.ts +12 -0
- package/node_modules/toolcraft-design/dist/acp/components.js +137 -0
- package/node_modules/toolcraft-design/dist/acp/index.d.ts +3 -0
- package/node_modules/toolcraft-design/dist/acp/index.js +2 -0
- package/node_modules/toolcraft-design/dist/acp/writer.d.ts +13 -0
- package/node_modules/toolcraft-design/dist/acp/writer.js +21 -0
- package/node_modules/toolcraft-design/dist/components/browser.d.ts +15 -0
- package/node_modules/toolcraft-design/dist/components/browser.js +31 -0
- package/node_modules/toolcraft-design/dist/components/catalog.d.ts +26 -0
- package/node_modules/toolcraft-design/dist/components/catalog.js +95 -0
- package/node_modules/toolcraft-design/dist/components/color.d.ts +31 -0
- package/node_modules/toolcraft-design/dist/components/color.js +102 -0
- package/node_modules/toolcraft-design/dist/components/command-errors.d.ts +16 -0
- package/node_modules/toolcraft-design/dist/components/command-errors.js +23 -0
- package/node_modules/toolcraft-design/dist/components/detail-card.d.ts +22 -0
- package/node_modules/toolcraft-design/dist/components/detail-card.js +45 -0
- package/node_modules/toolcraft-design/dist/components/help-formatter-plain.d.ts +5 -0
- package/node_modules/toolcraft-design/dist/components/help-formatter-plain.js +132 -0
- package/node_modules/toolcraft-design/dist/components/help-formatter.d.ts +33 -0
- package/node_modules/toolcraft-design/dist/components/help-formatter.js +213 -0
- package/node_modules/toolcraft-design/dist/components/index.d.ts +16 -0
- package/node_modules/toolcraft-design/dist/components/index.js +10 -0
- package/node_modules/toolcraft-design/dist/components/logger.d.ts +11 -0
- package/node_modules/toolcraft-design/dist/components/logger.js +60 -0
- package/node_modules/toolcraft-design/dist/components/symbols.d.ts +12 -0
- package/node_modules/toolcraft-design/dist/components/symbols.js +71 -0
- package/node_modules/toolcraft-design/dist/components/table.d.ts +15 -0
- package/node_modules/toolcraft-design/dist/components/table.js +302 -0
- package/node_modules/toolcraft-design/dist/components/template.d.ts +10 -0
- package/node_modules/toolcraft-design/dist/components/template.js +437 -0
- package/node_modules/toolcraft-design/dist/components/text.d.ts +16 -0
- package/node_modules/toolcraft-design/dist/components/text.js +145 -0
- package/node_modules/toolcraft-design/dist/dashboard/ansi.d.ts +18 -0
- package/node_modules/toolcraft-design/dist/dashboard/ansi.js +343 -0
- package/node_modules/toolcraft-design/dist/dashboard/buffer.d.ts +25 -0
- package/node_modules/toolcraft-design/dist/dashboard/buffer.js +219 -0
- package/node_modules/toolcraft-design/dist/dashboard/components/border.d.ts +9 -0
- package/node_modules/toolcraft-design/dist/dashboard/components/border.js +123 -0
- package/node_modules/toolcraft-design/dist/dashboard/components/footer.d.ts +8 -0
- package/node_modules/toolcraft-design/dist/dashboard/components/footer.js +56 -0
- package/node_modules/toolcraft-design/dist/dashboard/components/output-pane.d.ts +12 -0
- package/node_modules/toolcraft-design/dist/dashboard/components/output-pane.js +268 -0
- package/node_modules/toolcraft-design/dist/dashboard/components/stats-pane.d.ts +7 -0
- package/node_modules/toolcraft-design/dist/dashboard/components/stats-pane.js +107 -0
- package/node_modules/toolcraft-design/dist/dashboard/dashboard.d.ts +20 -0
- package/node_modules/toolcraft-design/dist/dashboard/dashboard.js +167 -0
- package/node_modules/toolcraft-design/dist/dashboard/demo.d.ts +13 -0
- package/node_modules/toolcraft-design/dist/dashboard/demo.js +145 -0
- package/node_modules/toolcraft-design/dist/dashboard/index.d.ts +8 -0
- package/node_modules/toolcraft-design/dist/dashboard/index.js +4 -0
- package/node_modules/toolcraft-design/dist/dashboard/keymap.d.ts +8 -0
- package/node_modules/toolcraft-design/dist/dashboard/keymap.js +233 -0
- package/node_modules/toolcraft-design/dist/dashboard/layout.d.ts +25 -0
- package/node_modules/toolcraft-design/dist/dashboard/layout.js +79 -0
- package/node_modules/toolcraft-design/dist/dashboard/should-use-dashboard.d.ts +10 -0
- package/node_modules/toolcraft-design/dist/dashboard/should-use-dashboard.js +7 -0
- package/node_modules/toolcraft-design/dist/dashboard/snapshot.d.ts +10 -0
- package/node_modules/toolcraft-design/dist/dashboard/snapshot.js +68 -0
- package/node_modules/toolcraft-design/dist/dashboard/store.d.ts +8 -0
- package/node_modules/toolcraft-design/dist/dashboard/store.js +51 -0
- package/node_modules/toolcraft-design/dist/dashboard/terminal-width.d.ts +4 -0
- package/node_modules/toolcraft-design/dist/dashboard/terminal-width.js +71 -0
- package/node_modules/toolcraft-design/dist/dashboard/terminal.d.ts +37 -0
- package/node_modules/toolcraft-design/dist/dashboard/terminal.js +264 -0
- package/node_modules/toolcraft-design/dist/dashboard/types.d.ts +38 -0
- package/node_modules/toolcraft-design/dist/dashboard/types.js +1 -0
- package/node_modules/toolcraft-design/dist/explorer/actions.d.ts +16 -0
- package/node_modules/toolcraft-design/dist/explorer/actions.js +39 -0
- package/node_modules/toolcraft-design/dist/explorer/demo.d.ts +13 -0
- package/node_modules/toolcraft-design/dist/explorer/demo.js +297 -0
- package/node_modules/toolcraft-design/dist/explorer/events.d.ts +67 -0
- package/node_modules/toolcraft-design/dist/explorer/events.js +1 -0
- package/node_modules/toolcraft-design/dist/explorer/filter.d.ts +10 -0
- package/node_modules/toolcraft-design/dist/explorer/filter.js +95 -0
- package/node_modules/toolcraft-design/dist/explorer/index.d.ts +8 -0
- package/node_modules/toolcraft-design/dist/explorer/index.js +8 -0
- package/node_modules/toolcraft-design/dist/explorer/jobs.d.ts +7 -0
- package/node_modules/toolcraft-design/dist/explorer/jobs.js +59 -0
- package/node_modules/toolcraft-design/dist/explorer/keymap.d.ts +21 -0
- package/node_modules/toolcraft-design/dist/explorer/keymap.js +376 -0
- package/node_modules/toolcraft-design/dist/explorer/layout.d.ts +20 -0
- package/node_modules/toolcraft-design/dist/explorer/layout.js +73 -0
- package/node_modules/toolcraft-design/dist/explorer/reducer.d.ts +9 -0
- package/node_modules/toolcraft-design/dist/explorer/reducer.js +782 -0
- package/node_modules/toolcraft-design/dist/explorer/render/detail.d.ts +4 -0
- package/node_modules/toolcraft-design/dist/explorer/render/detail.js +97 -0
- package/node_modules/toolcraft-design/dist/explorer/render/footer.d.ts +4 -0
- package/node_modules/toolcraft-design/dist/explorer/render/footer.js +73 -0
- package/node_modules/toolcraft-design/dist/explorer/render/header.d.ts +4 -0
- package/node_modules/toolcraft-design/dist/explorer/render/header.js +49 -0
- package/node_modules/toolcraft-design/dist/explorer/render/index.d.ts +8 -0
- package/node_modules/toolcraft-design/dist/explorer/render/index.js +53 -0
- package/node_modules/toolcraft-design/dist/explorer/render/list.d.ts +4 -0
- package/node_modules/toolcraft-design/dist/explorer/render/list.js +116 -0
- package/node_modules/toolcraft-design/dist/explorer/render/modal.d.ts +3 -0
- package/node_modules/toolcraft-design/dist/explorer/render/modal.js +87 -0
- package/node_modules/toolcraft-design/dist/explorer/render/test-fixtures.d.ts +8 -0
- package/node_modules/toolcraft-design/dist/explorer/render/test-fixtures.js +156 -0
- package/node_modules/toolcraft-design/dist/explorer/render/text.d.ts +12 -0
- package/node_modules/toolcraft-design/dist/explorer/render/text.js +81 -0
- package/node_modules/toolcraft-design/dist/explorer/runtime.d.ts +2 -0
- package/node_modules/toolcraft-design/dist/explorer/runtime.js +340 -0
- package/node_modules/toolcraft-design/dist/explorer/runtime.test-helpers.d.ts +50 -0
- package/node_modules/toolcraft-design/dist/explorer/runtime.test-helpers.js +101 -0
- package/node_modules/toolcraft-design/dist/explorer/state.d.ts +137 -0
- package/node_modules/toolcraft-design/dist/explorer/state.js +86 -0
- package/node_modules/toolcraft-design/dist/explorer/theme.d.ts +27 -0
- package/node_modules/toolcraft-design/dist/explorer/theme.js +29 -0
- package/node_modules/toolcraft-design/dist/index.d.ts +50 -0
- package/node_modules/toolcraft-design/dist/index.js +43 -0
- package/node_modules/toolcraft-design/dist/internal/color-support.d.ts +9 -0
- package/node_modules/toolcraft-design/dist/internal/color-support.js +12 -0
- package/node_modules/toolcraft-design/dist/internal/output-format.d.ts +6 -0
- package/node_modules/toolcraft-design/dist/internal/output-format.js +22 -0
- package/node_modules/toolcraft-design/dist/internal/strip-ansi.d.ts +1 -0
- package/node_modules/toolcraft-design/dist/internal/strip-ansi.js +50 -0
- package/node_modules/toolcraft-design/dist/internal/theme-detect.d.ts +12 -0
- package/node_modules/toolcraft-design/dist/internal/theme-detect.js +71 -0
- package/node_modules/toolcraft-design/dist/internal/theme-state.d.ts +12 -0
- package/node_modules/toolcraft-design/dist/internal/theme-state.js +35 -0
- package/node_modules/toolcraft-design/dist/prompts/index.d.ts +91 -0
- package/node_modules/toolcraft-design/dist/prompts/index.js +137 -0
- package/node_modules/toolcraft-design/dist/prompts/interactive/cancel-symbol.d.ts +2 -0
- package/node_modules/toolcraft-design/dist/prompts/interactive/cancel-symbol.js +4 -0
- package/node_modules/toolcraft-design/dist/prompts/interactive/confirm.d.ts +9 -0
- package/node_modules/toolcraft-design/dist/prompts/interactive/confirm.js +47 -0
- package/node_modules/toolcraft-design/dist/prompts/interactive/core.d.ts +55 -0
- package/node_modules/toolcraft-design/dist/prompts/interactive/core.js +274 -0
- package/node_modules/toolcraft-design/dist/prompts/interactive/glyphs.d.ts +20 -0
- package/node_modules/toolcraft-design/dist/prompts/interactive/glyphs.js +53 -0
- package/node_modules/toolcraft-design/dist/prompts/interactive/index.d.ts +6 -0
- package/node_modules/toolcraft-design/dist/prompts/interactive/index.js +6 -0
- package/node_modules/toolcraft-design/dist/prompts/interactive/keys.d.ts +2 -0
- package/node_modules/toolcraft-design/dist/prompts/interactive/keys.js +28 -0
- package/node_modules/toolcraft-design/dist/prompts/interactive/multiselect.d.ts +13 -0
- package/node_modules/toolcraft-design/dist/prompts/interactive/multiselect.js +131 -0
- package/node_modules/toolcraft-design/dist/prompts/interactive/pagination.d.ts +10 -0
- package/node_modules/toolcraft-design/dist/prompts/interactive/pagination.js +52 -0
- package/node_modules/toolcraft-design/dist/prompts/interactive/password.d.ts +10 -0
- package/node_modules/toolcraft-design/dist/prompts/interactive/password.js +55 -0
- package/node_modules/toolcraft-design/dist/prompts/interactive/select.d.ts +18 -0
- package/node_modules/toolcraft-design/dist/prompts/interactive/select.js +89 -0
- package/node_modules/toolcraft-design/dist/prompts/interactive/test-helpers.d.ts +21 -0
- package/node_modules/toolcraft-design/dist/prompts/interactive/test-helpers.js +32 -0
- package/node_modules/toolcraft-design/dist/prompts/interactive/text.d.ts +12 -0
- package/node_modules/toolcraft-design/dist/prompts/interactive/text.js +60 -0
- package/node_modules/toolcraft-design/dist/prompts/interactive/wrap.d.ts +4 -0
- package/node_modules/toolcraft-design/dist/prompts/interactive/wrap.js +18 -0
- package/node_modules/toolcraft-design/dist/prompts/primitives/cancel.d.ts +2 -0
- package/node_modules/toolcraft-design/dist/prompts/primitives/cancel.js +9 -0
- package/node_modules/toolcraft-design/dist/prompts/primitives/intro.d.ts +1 -0
- package/node_modules/toolcraft-design/dist/prompts/primitives/intro.js +16 -0
- package/node_modules/toolcraft-design/dist/prompts/primitives/log.d.ts +18 -0
- package/node_modules/toolcraft-design/dist/prompts/primitives/log.js +104 -0
- package/node_modules/toolcraft-design/dist/prompts/primitives/note.d.ts +1 -0
- package/node_modules/toolcraft-design/dist/prompts/primitives/note.js +39 -0
- package/node_modules/toolcraft-design/dist/prompts/primitives/outro.d.ts +1 -0
- package/node_modules/toolcraft-design/dist/prompts/primitives/outro.js +16 -0
- package/node_modules/toolcraft-design/dist/prompts/primitives/spinner.d.ts +6 -0
- package/node_modules/toolcraft-design/dist/prompts/primitives/spinner.js +74 -0
- package/node_modules/toolcraft-design/dist/prompts/theme.d.ts +11 -0
- package/node_modules/toolcraft-design/dist/prompts/theme.js +15 -0
- package/node_modules/toolcraft-design/dist/static/index.d.ts +4 -0
- package/node_modules/toolcraft-design/dist/static/index.js +2 -0
- package/node_modules/toolcraft-design/dist/static/menu.d.ts +11 -0
- package/node_modules/toolcraft-design/dist/static/menu.js +42 -0
- package/node_modules/toolcraft-design/dist/static/spinner.d.ts +14 -0
- package/node_modules/toolcraft-design/dist/static/spinner.js +52 -0
- package/node_modules/toolcraft-design/dist/terminal-markdown/ast.d.ts +92 -0
- package/node_modules/toolcraft-design/dist/terminal-markdown/ast.js +1 -0
- package/node_modules/toolcraft-design/dist/terminal-markdown/demo-content.d.ts +2 -0
- package/node_modules/toolcraft-design/dist/terminal-markdown/demo-content.js +139 -0
- package/node_modules/toolcraft-design/dist/terminal-markdown/index.d.ts +6 -0
- package/node_modules/toolcraft-design/dist/terminal-markdown/index.js +8 -0
- package/node_modules/toolcraft-design/dist/terminal-markdown/parser/block.d.ts +7 -0
- package/node_modules/toolcraft-design/dist/terminal-markdown/parser/block.js +1495 -0
- package/node_modules/toolcraft-design/dist/terminal-markdown/parser/frontmatter.d.ts +8 -0
- package/node_modules/toolcraft-design/dist/terminal-markdown/parser/frontmatter.js +36 -0
- package/node_modules/toolcraft-design/dist/terminal-markdown/parser/inline.d.ts +10 -0
- package/node_modules/toolcraft-design/dist/terminal-markdown/parser/inline.js +1190 -0
- package/node_modules/toolcraft-design/dist/terminal-markdown/parser.d.ts +5 -0
- package/node_modules/toolcraft-design/dist/terminal-markdown/parser.js +42 -0
- package/node_modules/toolcraft-design/dist/terminal-markdown/renderer.d.ts +6 -0
- package/node_modules/toolcraft-design/dist/terminal-markdown/renderer.js +615 -0
- package/node_modules/toolcraft-design/dist/terminal-markdown/testing/theme-render-fixture.d.ts +1 -0
- package/node_modules/toolcraft-design/dist/terminal-markdown/testing/theme-render-fixture.js +27 -0
- package/node_modules/toolcraft-design/dist/tokens/brand.d.ts +5 -0
- package/node_modules/toolcraft-design/dist/tokens/brand.js +5 -0
- package/node_modules/toolcraft-design/dist/tokens/colors.d.ts +37 -0
- package/node_modules/toolcraft-design/dist/tokens/colors.js +85 -0
- package/node_modules/toolcraft-design/dist/tokens/index.d.ts +6 -0
- package/node_modules/toolcraft-design/dist/tokens/index.js +5 -0
- package/node_modules/toolcraft-design/dist/tokens/spacing.d.ts +6 -0
- package/node_modules/toolcraft-design/dist/tokens/spacing.js +6 -0
- package/node_modules/toolcraft-design/dist/tokens/typography.d.ts +7 -0
- package/node_modules/toolcraft-design/dist/tokens/typography.js +8 -0
- package/node_modules/toolcraft-design/dist/tokens/widths.d.ts +5 -0
- package/node_modules/toolcraft-design/dist/tokens/widths.js +5 -0
- package/node_modules/toolcraft-design/package.json +44 -0
- package/package.json +15 -5
|
@@ -0,0 +1,123 @@
|
|
|
1
|
+
export function renderBorder(buffer, layout, opts) {
|
|
2
|
+
const outer = layout.outerBorder;
|
|
3
|
+
if (outer.width <= 0 || outer.height <= 0) {
|
|
4
|
+
return;
|
|
5
|
+
}
|
|
6
|
+
const left = outer.x;
|
|
7
|
+
const top = outer.y;
|
|
8
|
+
const right = outer.x + outer.width - 1;
|
|
9
|
+
const bottom = outer.y + outer.height - 1;
|
|
10
|
+
renderTopBorder(buffer, left, top, right, layout, opts);
|
|
11
|
+
renderSideBorders(buffer, left, right, top, bottom, opts.style);
|
|
12
|
+
renderBottomBorder(buffer, left, top, right, bottom, layout, opts.style);
|
|
13
|
+
renderVerticalDivider(buffer, layout, opts.style);
|
|
14
|
+
renderFooterDivider(buffer, left, right, bottom, layout, opts.style);
|
|
15
|
+
}
|
|
16
|
+
function renderTopBorder(buffer, left, top, right, layout, opts) {
|
|
17
|
+
if (left === right) {
|
|
18
|
+
buffer.put(left, top, "┌", opts.style);
|
|
19
|
+
return;
|
|
20
|
+
}
|
|
21
|
+
const hasTopJunction = hasInteriorRows(top, layout.outerBorder.y + layout.outerBorder.height - 1)
|
|
22
|
+
&& hasPaneDivider(layout, left, right)
|
|
23
|
+
&& layout.divider.top <= top + 1
|
|
24
|
+
&& layout.divider.bottom >= top + 1;
|
|
25
|
+
if (!hasTopJunction) {
|
|
26
|
+
buffer.put(left, top, `┌${renderTopSegment(right - left - 1, opts.leftTitle)}┐`, opts.style);
|
|
27
|
+
return;
|
|
28
|
+
}
|
|
29
|
+
const leftWidth = layout.divider.x - left - 1;
|
|
30
|
+
const rightWidth = right - layout.divider.x - 1;
|
|
31
|
+
const row = [
|
|
32
|
+
"┌",
|
|
33
|
+
renderTopSegment(leftWidth, opts.leftTitle),
|
|
34
|
+
"┬",
|
|
35
|
+
renderTopSegment(rightWidth, opts.rightTitle),
|
|
36
|
+
"┐"
|
|
37
|
+
].join("");
|
|
38
|
+
buffer.put(left, top, row, opts.style);
|
|
39
|
+
}
|
|
40
|
+
function renderSideBorders(buffer, left, right, top, bottom, style) {
|
|
41
|
+
for (let y = top + 1; y < bottom; y += 1) {
|
|
42
|
+
buffer.put(left, y, "│", style);
|
|
43
|
+
buffer.put(right, y, "│", style);
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
function renderBottomBorder(buffer, left, top, right, bottom, layout, style) {
|
|
47
|
+
if (bottom <= top) {
|
|
48
|
+
return;
|
|
49
|
+
}
|
|
50
|
+
if (left === right) {
|
|
51
|
+
buffer.put(left, bottom, "└", style);
|
|
52
|
+
return;
|
|
53
|
+
}
|
|
54
|
+
buffer.put(left, bottom, "└", style);
|
|
55
|
+
buffer.put(left + 1, bottom, "─".repeat(Math.max(0, right - left - 1)), style);
|
|
56
|
+
buffer.put(right, bottom, "┘", style);
|
|
57
|
+
if (hasInteriorRows(top, bottom)
|
|
58
|
+
&& hasPaneDivider(layout, left, right)
|
|
59
|
+
&& layout.divider.top <= bottom - 1
|
|
60
|
+
&& layout.divider.bottom >= bottom - 1) {
|
|
61
|
+
buffer.put(layout.divider.x, bottom, "┴", style);
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
function renderVerticalDivider(buffer, layout, style) {
|
|
65
|
+
const left = layout.outerBorder.x;
|
|
66
|
+
const right = layout.outerBorder.x + layout.outerBorder.width - 1;
|
|
67
|
+
if (!hasPaneDivider(layout, left, right)) {
|
|
68
|
+
return;
|
|
69
|
+
}
|
|
70
|
+
const startY = Math.max(layout.divider.top, layout.outerBorder.y + 1);
|
|
71
|
+
const endY = Math.min(layout.divider.bottom, layout.outerBorder.y + layout.outerBorder.height - 2);
|
|
72
|
+
for (let y = startY; y <= endY; y += 1) {
|
|
73
|
+
buffer.put(layout.divider.x, y, "│", style);
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
function renderFooterDivider(buffer, left, right, bottom, layout, style) {
|
|
77
|
+
const y = layout.footerDivider.y;
|
|
78
|
+
if (y <= layout.outerBorder.y || y >= bottom) {
|
|
79
|
+
return;
|
|
80
|
+
}
|
|
81
|
+
const width = layout.footerDivider.right - layout.footerDivider.left + 1;
|
|
82
|
+
if (width > 0) {
|
|
83
|
+
buffer.put(layout.footerDivider.left, y, "─".repeat(width), style);
|
|
84
|
+
}
|
|
85
|
+
buffer.put(left, y, "├", style);
|
|
86
|
+
buffer.put(right, y, "┤", style);
|
|
87
|
+
if (!hasPaneDivider(layout, left, right)
|
|
88
|
+
|| layout.divider.x < layout.footerDivider.left
|
|
89
|
+
|| layout.divider.x > layout.footerDivider.right) {
|
|
90
|
+
return;
|
|
91
|
+
}
|
|
92
|
+
const connectsAbove = layout.divider.bottom >= y - 1 && layout.divider.top <= y;
|
|
93
|
+
const connectsBelow = layout.divider.bottom > y;
|
|
94
|
+
if (connectsAbove && connectsBelow) {
|
|
95
|
+
buffer.put(layout.divider.x, y, "┼", style);
|
|
96
|
+
return;
|
|
97
|
+
}
|
|
98
|
+
if (connectsAbove) {
|
|
99
|
+
buffer.put(layout.divider.x, y, "┴", style);
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
function renderTopSegment(width, title) {
|
|
103
|
+
if (width <= 0) {
|
|
104
|
+
return "";
|
|
105
|
+
}
|
|
106
|
+
if (!title) {
|
|
107
|
+
return "─".repeat(width);
|
|
108
|
+
}
|
|
109
|
+
const content = `─ ${title} `;
|
|
110
|
+
if (content.length >= width) {
|
|
111
|
+
return content.slice(0, width);
|
|
112
|
+
}
|
|
113
|
+
return `${content}${"─".repeat(width - content.length)}`;
|
|
114
|
+
}
|
|
115
|
+
function hasInteriorRows(top, bottom) {
|
|
116
|
+
return (bottom - top) > 1;
|
|
117
|
+
}
|
|
118
|
+
function hasPaneDivider(layout, left, right) {
|
|
119
|
+
return layout.leftPane.width > 0
|
|
120
|
+
&& layout.rightPane.width > 0
|
|
121
|
+
&& layout.divider.x > left
|
|
122
|
+
&& layout.divider.x < right;
|
|
123
|
+
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { ScreenBuffer } from "../buffer.js";
|
|
2
|
+
import type { Rect } from "../types.js";
|
|
3
|
+
export type FooterHint = {
|
|
4
|
+
key: string;
|
|
5
|
+
label: string;
|
|
6
|
+
};
|
|
7
|
+
export declare function renderFooter(buffer: ScreenBuffer, rect: Rect, hints: FooterHint[]): void;
|
|
8
|
+
export declare function defaultHints(): FooterHint[];
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import { getTheme } from "../../internal/theme-detect.js";
|
|
2
|
+
export function renderFooter(buffer, rect, hints) {
|
|
3
|
+
buffer.clearRect(rect);
|
|
4
|
+
if (rect.width <= 0 || rect.height <= 0 || hints.length === 0) {
|
|
5
|
+
return;
|
|
6
|
+
}
|
|
7
|
+
const cells = truncateCells(hintsToCells(hints), rect.width);
|
|
8
|
+
const startX = rect.x + Math.floor((rect.width - cells.length) / 2);
|
|
9
|
+
const y = rect.y + Math.floor(rect.height / 2);
|
|
10
|
+
cells.forEach((cell, index) => {
|
|
11
|
+
buffer.put(startX + index, y, cell.ch, cell.style);
|
|
12
|
+
});
|
|
13
|
+
}
|
|
14
|
+
export function defaultHints() {
|
|
15
|
+
return [
|
|
16
|
+
{ key: "q", label: "Quit" },
|
|
17
|
+
{ key: "e", label: "Edit" },
|
|
18
|
+
{ key: "l", label: "Log" },
|
|
19
|
+
{ key: "p", label: "Pause" },
|
|
20
|
+
{ key: "r", label: "Retry" }
|
|
21
|
+
];
|
|
22
|
+
}
|
|
23
|
+
function hintsToCells(hints) {
|
|
24
|
+
const accentStyle = getAccentStyle();
|
|
25
|
+
const cells = [];
|
|
26
|
+
hints.forEach((hint, hintIndex) => {
|
|
27
|
+
if (hintIndex > 0) {
|
|
28
|
+
cells.push({ ch: " ", style: {} }, { ch: " ", style: {} });
|
|
29
|
+
}
|
|
30
|
+
for (const ch of hint.key) {
|
|
31
|
+
cells.push({ ch, style: accentStyle });
|
|
32
|
+
}
|
|
33
|
+
cells.push({ ch: " ", style: {} });
|
|
34
|
+
for (const ch of hint.label) {
|
|
35
|
+
cells.push({ ch, style: {} });
|
|
36
|
+
}
|
|
37
|
+
});
|
|
38
|
+
return cells;
|
|
39
|
+
}
|
|
40
|
+
function truncateCells(cells, width) {
|
|
41
|
+
if (cells.length <= width) {
|
|
42
|
+
return cells;
|
|
43
|
+
}
|
|
44
|
+
if (width <= 3) {
|
|
45
|
+
return Array.from({ length: Math.max(0, width) }, () => ({ ch: ".", style: {} }));
|
|
46
|
+
}
|
|
47
|
+
return [
|
|
48
|
+
...cells.slice(0, width - 3),
|
|
49
|
+
{ ch: ".", style: {} },
|
|
50
|
+
{ ch: ".", style: {} },
|
|
51
|
+
{ ch: ".", style: {} }
|
|
52
|
+
];
|
|
53
|
+
}
|
|
54
|
+
function getAccentStyle() {
|
|
55
|
+
return getTheme().styles.accent;
|
|
56
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { type StyledSegment } from "../ansi.js";
|
|
2
|
+
import { ScreenBuffer } from "../buffer.js";
|
|
3
|
+
import type { CellStyle, OutputItem, Rect } from "../types.js";
|
|
4
|
+
export type VisualLine = {
|
|
5
|
+
text: string;
|
|
6
|
+
style: CellStyle;
|
|
7
|
+
prefix: string;
|
|
8
|
+
prefixStyle: CellStyle;
|
|
9
|
+
segments?: StyledSegment[];
|
|
10
|
+
};
|
|
11
|
+
export declare function renderOutputPane(buffer: ScreenBuffer, rect: Rect, items: OutputItem[]): void;
|
|
12
|
+
export declare function computeVisualLines(items: OutputItem[], width: number): VisualLine[];
|
|
@@ -0,0 +1,268 @@
|
|
|
1
|
+
import { getTheme } from "../../internal/theme-detect.js";
|
|
2
|
+
import { hasAnsi, parseAnsi } from "../ansi.js";
|
|
3
|
+
import { displayWidth, expandTabs, graphemes, graphemeWidth } from "../terminal-width.js";
|
|
4
|
+
const TEXT_OFFSET = 3;
|
|
5
|
+
const CONTINUATION_PREFIX = "│";
|
|
6
|
+
export function renderOutputPane(buffer, rect, items) {
|
|
7
|
+
buffer.clearRect(rect);
|
|
8
|
+
if (rect.width <= 0 || rect.height <= 0) {
|
|
9
|
+
return;
|
|
10
|
+
}
|
|
11
|
+
const visualLines = computeVisualLines(items, rect.width);
|
|
12
|
+
const startLine = Math.max(visualLines.length - rect.height, 0);
|
|
13
|
+
const textRect = {
|
|
14
|
+
x: rect.x + TEXT_OFFSET,
|
|
15
|
+
y: rect.y,
|
|
16
|
+
width: rect.width - TEXT_OFFSET,
|
|
17
|
+
height: rect.height
|
|
18
|
+
};
|
|
19
|
+
for (let row = 0; row < rect.height; row += 1) {
|
|
20
|
+
const line = visualLines[startLine + row];
|
|
21
|
+
if (line === undefined) {
|
|
22
|
+
continue;
|
|
23
|
+
}
|
|
24
|
+
buffer.putInRect(rect, row, line.prefix, line.prefixStyle);
|
|
25
|
+
if (line.segments && line.segments.length > 0) {
|
|
26
|
+
let offsetX = 0;
|
|
27
|
+
for (const segment of line.segments) {
|
|
28
|
+
if (segment.text.length === 0) {
|
|
29
|
+
continue;
|
|
30
|
+
}
|
|
31
|
+
const remaining = textRect.width - offsetX;
|
|
32
|
+
if (remaining <= 0) {
|
|
33
|
+
break;
|
|
34
|
+
}
|
|
35
|
+
buffer.putInRect({
|
|
36
|
+
x: textRect.x + offsetX,
|
|
37
|
+
y: textRect.y,
|
|
38
|
+
width: remaining,
|
|
39
|
+
height: textRect.height
|
|
40
|
+
}, row, segment.text, segment.style);
|
|
41
|
+
offsetX += displayWidth(segment.text, offsetX);
|
|
42
|
+
}
|
|
43
|
+
continue;
|
|
44
|
+
}
|
|
45
|
+
buffer.putInRect(textRect, row, line.text, line.style);
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
export function computeVisualLines(items, width) {
|
|
49
|
+
if (width <= 0) {
|
|
50
|
+
return [];
|
|
51
|
+
}
|
|
52
|
+
const mutedStyle = getTheme().styles.muted;
|
|
53
|
+
const textWidth = Math.max(width - TEXT_OFFSET, 0);
|
|
54
|
+
const visualLines = [];
|
|
55
|
+
for (const item of items) {
|
|
56
|
+
const itemStyle = getItemStyle(item.kind);
|
|
57
|
+
if (hasAnsi(item.text) || hasCursorControls(item.text)) {
|
|
58
|
+
const styledLines = parseAnsi(item.text, hasAnsi(item.text) ? {} : itemStyle);
|
|
59
|
+
let firstRow = true;
|
|
60
|
+
for (const styledLine of styledLines) {
|
|
61
|
+
const rows = hardWrapSegments(styledLine.segments, textWidth);
|
|
62
|
+
for (const rowSegments of rows) {
|
|
63
|
+
visualLines.push({
|
|
64
|
+
prefix: firstRow ? getPrefix(item.kind) : CONTINUATION_PREFIX,
|
|
65
|
+
prefixStyle: firstRow ? itemStyle : mutedStyle,
|
|
66
|
+
style: itemStyle,
|
|
67
|
+
text: rowSegments.map((segment) => segment.text).join(""),
|
|
68
|
+
segments: rowSegments
|
|
69
|
+
});
|
|
70
|
+
firstRow = false;
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
continue;
|
|
74
|
+
}
|
|
75
|
+
const wrappedLines = wrapText(item.text, textWidth);
|
|
76
|
+
for (let index = 0; index < wrappedLines.length; index += 1) {
|
|
77
|
+
visualLines.push({
|
|
78
|
+
prefix: index === 0 ? getPrefix(item.kind) : CONTINUATION_PREFIX,
|
|
79
|
+
prefixStyle: index === 0 ? itemStyle : mutedStyle,
|
|
80
|
+
style: itemStyle,
|
|
81
|
+
text: wrappedLines[index] ?? ""
|
|
82
|
+
});
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
return visualLines;
|
|
86
|
+
}
|
|
87
|
+
function hasCursorControls(text) {
|
|
88
|
+
return text.includes("\r") || text.includes("\b");
|
|
89
|
+
}
|
|
90
|
+
function hardWrapSegments(segments, width) {
|
|
91
|
+
if (width <= 0) {
|
|
92
|
+
return [[]];
|
|
93
|
+
}
|
|
94
|
+
const rows = [[]];
|
|
95
|
+
let rowWidth = 0;
|
|
96
|
+
for (const segment of segments) {
|
|
97
|
+
for (const grapheme of graphemes(expandTabs(segment.text, rowWidth))) {
|
|
98
|
+
const graphemeCells = graphemeWidth(grapheme);
|
|
99
|
+
if (rowWidth > 0 && rowWidth + graphemeCells > width) {
|
|
100
|
+
rows.push([]);
|
|
101
|
+
rowWidth = 0;
|
|
102
|
+
}
|
|
103
|
+
appendSegment(rows[rows.length - 1], grapheme, segment.style);
|
|
104
|
+
rowWidth += graphemeCells;
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
return rows;
|
|
108
|
+
}
|
|
109
|
+
function appendSegment(segments, text, style) {
|
|
110
|
+
const last = segments[segments.length - 1];
|
|
111
|
+
if (last && stylesEqual(last.style, style)) {
|
|
112
|
+
last.text += text;
|
|
113
|
+
}
|
|
114
|
+
else {
|
|
115
|
+
segments.push({ text, style: { ...style } });
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
function stylesEqual(left, right) {
|
|
119
|
+
return (left.fg === right.fg &&
|
|
120
|
+
left.bg === right.bg &&
|
|
121
|
+
left.bold === right.bold &&
|
|
122
|
+
left.dim === right.dim &&
|
|
123
|
+
left.inverse === right.inverse &&
|
|
124
|
+
left.underline === right.underline);
|
|
125
|
+
}
|
|
126
|
+
function getPrefix(kind) {
|
|
127
|
+
if (kind === "success") {
|
|
128
|
+
return "◆";
|
|
129
|
+
}
|
|
130
|
+
if (kind === "error") {
|
|
131
|
+
return "■";
|
|
132
|
+
}
|
|
133
|
+
if (kind === "tool") {
|
|
134
|
+
return CONTINUATION_PREFIX;
|
|
135
|
+
}
|
|
136
|
+
if (kind === "status") {
|
|
137
|
+
return "●";
|
|
138
|
+
}
|
|
139
|
+
return "◇";
|
|
140
|
+
}
|
|
141
|
+
function getItemStyle(kind) {
|
|
142
|
+
const styles = getTheme().styles;
|
|
143
|
+
if (kind === "success") {
|
|
144
|
+
return styles.success;
|
|
145
|
+
}
|
|
146
|
+
if (kind === "error") {
|
|
147
|
+
return styles.error;
|
|
148
|
+
}
|
|
149
|
+
if (kind === "tool") {
|
|
150
|
+
return styles.muted;
|
|
151
|
+
}
|
|
152
|
+
if (kind === "status") {
|
|
153
|
+
return styles.info;
|
|
154
|
+
}
|
|
155
|
+
return styles.info;
|
|
156
|
+
}
|
|
157
|
+
function wrapText(value, width) {
|
|
158
|
+
const logicalLines = splitLogicalLines(value);
|
|
159
|
+
if (logicalLines.length === 0) {
|
|
160
|
+
return [""];
|
|
161
|
+
}
|
|
162
|
+
if (width <= 0) {
|
|
163
|
+
return logicalLines.map(() => "");
|
|
164
|
+
}
|
|
165
|
+
return logicalLines.flatMap((line) => wrapParagraph(expandTabs(line), width));
|
|
166
|
+
}
|
|
167
|
+
function wrapParagraph(value, width) {
|
|
168
|
+
if (value.length === 0) {
|
|
169
|
+
return [""];
|
|
170
|
+
}
|
|
171
|
+
const tokens = tokenize(value);
|
|
172
|
+
const lines = [];
|
|
173
|
+
let currentLine = "";
|
|
174
|
+
let pendingSpace = "";
|
|
175
|
+
const flushLine = () => {
|
|
176
|
+
lines.push(currentLine);
|
|
177
|
+
currentLine = "";
|
|
178
|
+
pendingSpace = "";
|
|
179
|
+
};
|
|
180
|
+
for (const token of tokens) {
|
|
181
|
+
if (token.kind === "space") {
|
|
182
|
+
if (currentLine.length > 0) {
|
|
183
|
+
pendingSpace += token.value;
|
|
184
|
+
}
|
|
185
|
+
continue;
|
|
186
|
+
}
|
|
187
|
+
const chunks = splitWord(token.value, width);
|
|
188
|
+
for (let index = 0; index < chunks.length; index += 1) {
|
|
189
|
+
const chunk = chunks[index] ?? "";
|
|
190
|
+
const gap = index === 0 ? pendingSpace : "";
|
|
191
|
+
if (currentLine.length > 0 && displayWidth(`${currentLine}${gap}${chunk}`) > width) {
|
|
192
|
+
flushLine();
|
|
193
|
+
}
|
|
194
|
+
if (currentLine.length > 0 && gap.length > 0) {
|
|
195
|
+
currentLine += gap;
|
|
196
|
+
}
|
|
197
|
+
currentLine += chunk;
|
|
198
|
+
pendingSpace = "";
|
|
199
|
+
if (index < chunks.length - 1) {
|
|
200
|
+
flushLine();
|
|
201
|
+
}
|
|
202
|
+
}
|
|
203
|
+
}
|
|
204
|
+
if (currentLine.length > 0 || lines.length === 0) {
|
|
205
|
+
lines.push(currentLine);
|
|
206
|
+
}
|
|
207
|
+
return lines;
|
|
208
|
+
}
|
|
209
|
+
function splitWord(value, width) {
|
|
210
|
+
if (displayWidth(value) <= width) {
|
|
211
|
+
return [value];
|
|
212
|
+
}
|
|
213
|
+
const chunks = [];
|
|
214
|
+
let chunk = "";
|
|
215
|
+
let chunkWidth = 0;
|
|
216
|
+
for (const grapheme of graphemes(value)) {
|
|
217
|
+
const graphemeCells = graphemeWidth(grapheme);
|
|
218
|
+
if (chunk.length > 0 && chunkWidth + graphemeCells > width) {
|
|
219
|
+
chunks.push(chunk);
|
|
220
|
+
chunk = "";
|
|
221
|
+
chunkWidth = 0;
|
|
222
|
+
}
|
|
223
|
+
chunk += grapheme;
|
|
224
|
+
chunkWidth += graphemeCells;
|
|
225
|
+
}
|
|
226
|
+
if (chunk.length > 0) {
|
|
227
|
+
chunks.push(chunk);
|
|
228
|
+
}
|
|
229
|
+
return chunks;
|
|
230
|
+
}
|
|
231
|
+
function tokenize(value) {
|
|
232
|
+
const tokens = [];
|
|
233
|
+
let current = "";
|
|
234
|
+
let currentKind;
|
|
235
|
+
for (const ch of value) {
|
|
236
|
+
const nextKind = isWrappingSpace(ch) ? "space" : "word";
|
|
237
|
+
if (currentKind !== undefined && currentKind !== nextKind) {
|
|
238
|
+
tokens.push({ kind: currentKind, value: current });
|
|
239
|
+
current = "";
|
|
240
|
+
}
|
|
241
|
+
currentKind = nextKind;
|
|
242
|
+
current += ch;
|
|
243
|
+
}
|
|
244
|
+
if (currentKind !== undefined) {
|
|
245
|
+
tokens.push({ kind: currentKind, value: current });
|
|
246
|
+
}
|
|
247
|
+
return tokens;
|
|
248
|
+
}
|
|
249
|
+
function splitLogicalLines(value) {
|
|
250
|
+
const lines = [];
|
|
251
|
+
let currentLine = "";
|
|
252
|
+
for (const ch of value) {
|
|
253
|
+
if (ch === "\r") {
|
|
254
|
+
continue;
|
|
255
|
+
}
|
|
256
|
+
if (ch === "\n") {
|
|
257
|
+
lines.push(currentLine);
|
|
258
|
+
currentLine = "";
|
|
259
|
+
continue;
|
|
260
|
+
}
|
|
261
|
+
currentLine += ch;
|
|
262
|
+
}
|
|
263
|
+
lines.push(currentLine);
|
|
264
|
+
return lines;
|
|
265
|
+
}
|
|
266
|
+
function isWrappingSpace(ch) {
|
|
267
|
+
return ch === " " || ch === "\t";
|
|
268
|
+
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { ScreenBuffer } from "../buffer.js";
|
|
2
|
+
import type { DashboardStats, Rect } from "../types.js";
|
|
3
|
+
import type { VisualLine } from "./output-pane.js";
|
|
4
|
+
export declare function renderStatsPane(buffer: ScreenBuffer, rect: Rect, stats: DashboardStats): void;
|
|
5
|
+
export declare function formatElapsed(ms: number): string;
|
|
6
|
+
export declare function formatNumber(n: number): string;
|
|
7
|
+
export declare function statsToLines(stats: DashboardStats, width: number): VisualLine[];
|
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
import { getTheme } from "../../internal/theme-detect.js";
|
|
2
|
+
export function renderStatsPane(buffer, rect, stats) {
|
|
3
|
+
buffer.clearRect(rect);
|
|
4
|
+
if (rect.width <= 0 || rect.height <= 0) {
|
|
5
|
+
return;
|
|
6
|
+
}
|
|
7
|
+
const lines = statsToLines(stats, rect.width);
|
|
8
|
+
for (let row = 0; row < rect.height; row += 1) {
|
|
9
|
+
const line = lines[row];
|
|
10
|
+
if (line === undefined) {
|
|
11
|
+
continue;
|
|
12
|
+
}
|
|
13
|
+
if (line.prefix.length > 0) {
|
|
14
|
+
buffer.putInRect(rect, row, line.prefix, line.prefixStyle);
|
|
15
|
+
}
|
|
16
|
+
if (line.text.length === 0) {
|
|
17
|
+
continue;
|
|
18
|
+
}
|
|
19
|
+
const textStart = Math.min(line.prefix.length, rect.width);
|
|
20
|
+
buffer.putInRect({ x: rect.x + textStart, y: rect.y + row, width: rect.width - textStart, height: 1 }, 0, line.text, line.style);
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
export function formatElapsed(ms) {
|
|
24
|
+
const safeMs = Number.isFinite(ms) ? ms : 0;
|
|
25
|
+
const totalSeconds = Math.max(0, Math.floor(safeMs / 1_000));
|
|
26
|
+
const hours = Math.floor(totalSeconds / 3_600);
|
|
27
|
+
const minutes = Math.floor((totalSeconds % 3_600) / 60);
|
|
28
|
+
const seconds = totalSeconds % 60;
|
|
29
|
+
return [hours, minutes, seconds].map((value) => value.toString().padStart(2, "0")).join(":");
|
|
30
|
+
}
|
|
31
|
+
export function formatNumber(n) {
|
|
32
|
+
return new Intl.NumberFormat("en-US").format(n);
|
|
33
|
+
}
|
|
34
|
+
export function statsToLines(stats, width) {
|
|
35
|
+
if (width <= 0) {
|
|
36
|
+
return [];
|
|
37
|
+
}
|
|
38
|
+
const mutedStyle = getToneStyle("muted");
|
|
39
|
+
const totalTokens = stats.tokensIn + stats.tokensOut;
|
|
40
|
+
const iterationsLabel = stats.iterationsLabel ?? "Iteration";
|
|
41
|
+
const lines = [
|
|
42
|
+
createKeyValueLine("Status", formatStatus(stats.status), width, getStatusStyle(stats.status)),
|
|
43
|
+
createKeyValueLine(iterationsLabel, formatNumber(stats.iterations), width),
|
|
44
|
+
createKeyValueLine("Elapsed", formatElapsed(stats.elapsedMs), width),
|
|
45
|
+
createBlankLine(),
|
|
46
|
+
createKeyValueLine("Tokens In", formatNumber(stats.tokensIn), width),
|
|
47
|
+
createKeyValueLine("Tokens Out", formatNumber(stats.tokensOut), width),
|
|
48
|
+
createKeyValueLine("Total", formatNumber(totalTokens), width)
|
|
49
|
+
];
|
|
50
|
+
if (stats.currentAction !== undefined) {
|
|
51
|
+
lines.push(createBlankLine(), {
|
|
52
|
+
prefix: clipText("Current:", width),
|
|
53
|
+
prefixStyle: {},
|
|
54
|
+
style: {},
|
|
55
|
+
text: ""
|
|
56
|
+
}, {
|
|
57
|
+
prefix: width > 0 ? clipText(" ", width) : "",
|
|
58
|
+
prefixStyle: mutedStyle,
|
|
59
|
+
style: mutedStyle,
|
|
60
|
+
text: clipText(stats.currentAction, Math.max(width - 2, 0))
|
|
61
|
+
});
|
|
62
|
+
}
|
|
63
|
+
return lines;
|
|
64
|
+
}
|
|
65
|
+
function createBlankLine() {
|
|
66
|
+
return {
|
|
67
|
+
prefix: "",
|
|
68
|
+
prefixStyle: {},
|
|
69
|
+
style: {},
|
|
70
|
+
text: ""
|
|
71
|
+
};
|
|
72
|
+
}
|
|
73
|
+
function createKeyValueLine(label, value, width, valueStyle = {}) {
|
|
74
|
+
const clippedValue = clipText(value, width);
|
|
75
|
+
const availableBeforeValue = Math.max(width - clippedValue.length, 0);
|
|
76
|
+
const clippedLabel = clipText(label, Math.max(availableBeforeValue - 1, 0));
|
|
77
|
+
return {
|
|
78
|
+
prefix: clippedLabel + " ".repeat(Math.max(availableBeforeValue - clippedLabel.length, 0)),
|
|
79
|
+
prefixStyle: {},
|
|
80
|
+
style: valueStyle,
|
|
81
|
+
text: clippedValue
|
|
82
|
+
};
|
|
83
|
+
}
|
|
84
|
+
function clipText(value, width) {
|
|
85
|
+
return width <= 0 ? "" : value.slice(0, width);
|
|
86
|
+
}
|
|
87
|
+
function formatStatus(status) {
|
|
88
|
+
return `${status.slice(0, 1).toUpperCase()}${status.slice(1)}`;
|
|
89
|
+
}
|
|
90
|
+
function getStatusStyle(status) {
|
|
91
|
+
if (status === "running") {
|
|
92
|
+
return getToneStyle("info");
|
|
93
|
+
}
|
|
94
|
+
if (status === "paused") {
|
|
95
|
+
return getToneStyle("warning");
|
|
96
|
+
}
|
|
97
|
+
if (status === "error") {
|
|
98
|
+
return getToneStyle("error");
|
|
99
|
+
}
|
|
100
|
+
if (status === "done") {
|
|
101
|
+
return getToneStyle("success");
|
|
102
|
+
}
|
|
103
|
+
return getToneStyle("muted");
|
|
104
|
+
}
|
|
105
|
+
function getToneStyle(tone) {
|
|
106
|
+
return getTheme().styles[tone];
|
|
107
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import type { FooterHint } from "./components/footer.js";
|
|
2
|
+
import type { Command, DashboardStats, OutputItem } from "./types.js";
|
|
3
|
+
export type DashboardOptions = {
|
|
4
|
+
title?: string;
|
|
5
|
+
statsTitle?: string;
|
|
6
|
+
keymap?: Partial<Record<Command, string[]>>;
|
|
7
|
+
rightPaneWidth?: number;
|
|
8
|
+
hints?: FooterHint[];
|
|
9
|
+
stdin?: NodeJS.ReadStream;
|
|
10
|
+
stdout?: NodeJS.WriteStream;
|
|
11
|
+
};
|
|
12
|
+
export type Dashboard = {
|
|
13
|
+
start(): void;
|
|
14
|
+
stop(): void;
|
|
15
|
+
appendOutput(item: OutputItem): void;
|
|
16
|
+
updateStats(stats: Partial<DashboardStats>): void;
|
|
17
|
+
onCommand(handler: (cmd: Command) => void): void;
|
|
18
|
+
destroy(): void;
|
|
19
|
+
};
|
|
20
|
+
export declare function createDashboard(opts?: DashboardOptions): Dashboard;
|