pi-ui-extend 0.1.1
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 +307 -0
- package/bin/pix.mjs +219 -0
- package/dist/app/app.d.ts +96 -0
- package/dist/app/app.js +871 -0
- package/dist/app/blink-controller.d.ts +23 -0
- package/dist/app/blink-controller.js +82 -0
- package/dist/app/cli.d.ts +8 -0
- package/dist/app/cli.js +83 -0
- package/dist/app/clipboard.d.ts +1 -0
- package/dist/app/clipboard.js +24 -0
- package/dist/app/command-controller.d.ts +18 -0
- package/dist/app/command-controller.js +58 -0
- package/dist/app/command-host.d.ts +44 -0
- package/dist/app/command-host.js +1 -0
- package/dist/app/command-model-actions.d.ts +12 -0
- package/dist/app/command-model-actions.js +176 -0
- package/dist/app/command-navigation-actions.d.ts +19 -0
- package/dist/app/command-navigation-actions.js +267 -0
- package/dist/app/command-registry.d.ts +32 -0
- package/dist/app/command-registry.js +225 -0
- package/dist/app/command-runtime.d.ts +5 -0
- package/dist/app/command-runtime.js +32 -0
- package/dist/app/command-session-actions.d.ts +20 -0
- package/dist/app/command-session-actions.js +295 -0
- package/dist/app/constants.d.ts +52 -0
- package/dist/app/constants.js +103 -0
- package/dist/app/conversation-entry-renderer.d.ts +21 -0
- package/dist/app/conversation-entry-renderer.js +81 -0
- package/dist/app/conversation-shell-renderer.d.ts +5 -0
- package/dist/app/conversation-shell-renderer.js +43 -0
- package/dist/app/conversation-tool-renderer.d.ts +16 -0
- package/dist/app/conversation-tool-renderer.js +216 -0
- package/dist/app/conversation-viewport.d.ts +55 -0
- package/dist/app/conversation-viewport.js +252 -0
- package/dist/app/dcp-stats.d.ts +2 -0
- package/dist/app/dcp-stats.js +116 -0
- package/dist/app/editor-layout-renderer.d.ts +31 -0
- package/dist/app/editor-layout-renderer.js +211 -0
- package/dist/app/editor-panels.d.ts +4 -0
- package/dist/app/editor-panels.js +130 -0
- package/dist/app/extension-actions-controller.d.ts +22 -0
- package/dist/app/extension-actions-controller.js +60 -0
- package/dist/app/extension-event-bus.d.ts +3 -0
- package/dist/app/extension-event-bus.js +23 -0
- package/dist/app/extension-ui-controller.d.ts +57 -0
- package/dist/app/extension-ui-controller.js +532 -0
- package/dist/app/file-link-opener.d.ts +2 -0
- package/dist/app/file-link-opener.js +66 -0
- package/dist/app/file-links.d.ts +10 -0
- package/dist/app/file-links.js +117 -0
- package/dist/app/guards.d.ts +3 -0
- package/dist/app/guards.js +9 -0
- package/dist/app/icons.d.ts +37 -0
- package/dist/app/icons.js +97 -0
- package/dist/app/id.d.ts +1 -0
- package/dist/app/id.js +4 -0
- package/dist/app/image-click-targets.d.ts +5 -0
- package/dist/app/image-click-targets.js +32 -0
- package/dist/app/image-opener.d.ts +2 -0
- package/dist/app/image-opener.js +64 -0
- package/dist/app/input-action-controller.d.ts +47 -0
- package/dist/app/input-action-controller.js +209 -0
- package/dist/app/input-controller.d.ts +60 -0
- package/dist/app/input-controller.js +425 -0
- package/dist/app/input-paste-handler.d.ts +27 -0
- package/dist/app/input-paste-handler.js +146 -0
- package/dist/app/menu-items-controller.d.ts +32 -0
- package/dist/app/menu-items-controller.js +182 -0
- package/dist/app/message-content.d.ts +8 -0
- package/dist/app/message-content.js +115 -0
- package/dist/app/model-ref.d.ts +13 -0
- package/dist/app/model-ref.js +50 -0
- package/dist/app/model-usage-controller.d.ts +35 -0
- package/dist/app/model-usage-controller.js +99 -0
- package/dist/app/model-usage-status.d.ts +125 -0
- package/dist/app/model-usage-status.js +749 -0
- package/dist/app/mouse-controller.d.ts +182 -0
- package/dist/app/mouse-controller.js +968 -0
- package/dist/app/native-modifiers.d.ts +3 -0
- package/dist/app/native-modifiers.js +60 -0
- package/dist/app/nerd-font-controller.d.ts +11 -0
- package/dist/app/nerd-font-controller.js +90 -0
- package/dist/app/popup-action-controller.d.ts +44 -0
- package/dist/app/popup-action-controller.js +278 -0
- package/dist/app/popup-menu-controller.d.ts +183 -0
- package/dist/app/popup-menu-controller.js +1070 -0
- package/dist/app/prompt-enhancer-controller.d.ts +40 -0
- package/dist/app/prompt-enhancer-controller.js +215 -0
- package/dist/app/queued-message-controller.d.ts +62 -0
- package/dist/app/queued-message-controller.js +377 -0
- package/dist/app/render-controller.d.ts +41 -0
- package/dist/app/render-controller.js +378 -0
- package/dist/app/render-text.d.ts +19 -0
- package/dist/app/render-text.js +67 -0
- package/dist/app/request-history.d.ts +23 -0
- package/dist/app/request-history.js +131 -0
- package/dist/app/runtime.d.ts +39 -0
- package/dist/app/runtime.js +195 -0
- package/dist/app/screen-selection.d.ts +6 -0
- package/dist/app/screen-selection.js +9 -0
- package/dist/app/screen-styler.d.ts +34 -0
- package/dist/app/screen-styler.js +168 -0
- package/dist/app/scroll-controller.d.ts +51 -0
- package/dist/app/scroll-controller.js +207 -0
- package/dist/app/session-event-controller.d.ts +69 -0
- package/dist/app/session-event-controller.js +338 -0
- package/dist/app/session-history.d.ts +23 -0
- package/dist/app/session-history.js +164 -0
- package/dist/app/session-lifecycle-controller.d.ts +55 -0
- package/dist/app/session-lifecycle-controller.js +116 -0
- package/dist/app/session-search.d.ts +24 -0
- package/dist/app/session-search.js +215 -0
- package/dist/app/shell-command.d.ts +27 -0
- package/dist/app/shell-command.js +176 -0
- package/dist/app/shell-controller.d.ts +28 -0
- package/dist/app/shell-controller.js +124 -0
- package/dist/app/slash-commands.d.ts +6 -0
- package/dist/app/slash-commands.js +75 -0
- package/dist/app/startup-checks.d.ts +8 -0
- package/dist/app/startup-checks.js +59 -0
- package/dist/app/startup-info.d.ts +3 -0
- package/dist/app/startup-info.js +176 -0
- package/dist/app/status-controller.d.ts +35 -0
- package/dist/app/status-controller.js +105 -0
- package/dist/app/status-line-renderer.d.ts +68 -0
- package/dist/app/status-line-renderer.js +453 -0
- package/dist/app/subagents-files.d.ts +10 -0
- package/dist/app/subagents-files.js +193 -0
- package/dist/app/subagents-model.d.ts +23 -0
- package/dist/app/subagents-model.js +224 -0
- package/dist/app/subagents-widget-controller.d.ts +43 -0
- package/dist/app/subagents-widget-controller.js +311 -0
- package/dist/app/tab-line-renderer.d.ts +26 -0
- package/dist/app/tab-line-renderer.js +222 -0
- package/dist/app/tabs-controller.d.ts +100 -0
- package/dist/app/tabs-controller.js +885 -0
- package/dist/app/terminal-controller.d.ts +40 -0
- package/dist/app/terminal-controller.js +135 -0
- package/dist/app/terminal-edit-shortcuts.d.ts +23 -0
- package/dist/app/terminal-edit-shortcuts.js +138 -0
- package/dist/app/terminal-output-buffer.d.ts +20 -0
- package/dist/app/terminal-output-buffer.js +52 -0
- package/dist/app/toast-controller.d.ts +13 -0
- package/dist/app/toast-controller.js +40 -0
- package/dist/app/toast-renderer.d.ts +9 -0
- package/dist/app/toast-renderer.js +79 -0
- package/dist/app/todo-model.d.ts +22 -0
- package/dist/app/todo-model.js +179 -0
- package/dist/app/todo-widget-controller.d.ts +21 -0
- package/dist/app/todo-widget-controller.js +59 -0
- package/dist/app/tool-block-renderer.d.ts +26 -0
- package/dist/app/tool-block-renderer.js +439 -0
- package/dist/app/types.d.ts +550 -0
- package/dist/app/types.js +1 -0
- package/dist/app/update.d.ts +36 -0
- package/dist/app/update.js +315 -0
- package/dist/app/voice-controller.d.ts +52 -0
- package/dist/app/voice-controller.js +600 -0
- package/dist/app/workspace-actions-controller.d.ts +40 -0
- package/dist/app/workspace-actions-controller.js +215 -0
- package/dist/app/workspace-undo.d.ts +44 -0
- package/dist/app/workspace-undo.js +215 -0
- package/dist/config.d.ts +62 -0
- package/dist/config.js +527 -0
- package/dist/context-progress-bar.d.ts +17 -0
- package/dist/context-progress-bar.js +48 -0
- package/dist/default-pix-config.d.ts +1 -0
- package/dist/default-pix-config.js +375 -0
- package/dist/fuzzy.d.ts +23 -0
- package/dist/fuzzy.js +165 -0
- package/dist/input-editor-files.d.ts +15 -0
- package/dist/input-editor-files.js +62 -0
- package/dist/input-editor.d.ts +186 -0
- package/dist/input-editor.js +835 -0
- package/dist/main.d.ts +1 -0
- package/dist/main.js +12 -0
- package/dist/markdown-format.d.ts +22 -0
- package/dist/markdown-format.js +542 -0
- package/dist/sdk.d.ts +3 -0
- package/dist/sdk.js +1 -0
- package/dist/syntax-highlight.d.ts +22 -0
- package/dist/syntax-highlight.js +528 -0
- package/dist/terminal-width.d.ts +6 -0
- package/dist/terminal-width.js +245 -0
- package/dist/theme.d.ts +56 -0
- package/dist/theme.js +118 -0
- package/dist/tool-renderers/apply-patch.d.ts +2 -0
- package/dist/tool-renderers/apply-patch.js +36 -0
- package/dist/tool-renderers/ast.d.ts +2 -0
- package/dist/tool-renderers/ast.js +5 -0
- package/dist/tool-renderers/compress.d.ts +2 -0
- package/dist/tool-renderers/compress.js +126 -0
- package/dist/tool-renderers/index.d.ts +3 -0
- package/dist/tool-renderers/index.js +44 -0
- package/dist/tool-renderers/question.d.ts +2 -0
- package/dist/tool-renderers/question.js +88 -0
- package/dist/tool-renderers/read.d.ts +2 -0
- package/dist/tool-renderers/read.js +36 -0
- package/dist/tool-renderers/repo.d.ts +2 -0
- package/dist/tool-renderers/repo.js +13 -0
- package/dist/tool-renderers/shell.d.ts +3 -0
- package/dist/tool-renderers/shell.js +27 -0
- package/dist/tool-renderers/skill.d.ts +2 -0
- package/dist/tool-renderers/skill.js +132 -0
- package/dist/tool-renderers/subagents.d.ts +2 -0
- package/dist/tool-renderers/subagents.js +51 -0
- package/dist/tool-renderers/todo.d.ts +2 -0
- package/dist/tool-renderers/todo.js +9 -0
- package/dist/tool-renderers/types.d.ts +42 -0
- package/dist/tool-renderers/types.js +1 -0
- package/dist/tool-renderers/utils.d.ts +31 -0
- package/dist/tool-renderers/utils.js +230 -0
- package/dist/tool-renderers/web.d.ts +3 -0
- package/dist/tool-renderers/web.js +9 -0
- package/dist/tool-renderers/write.d.ts +2 -0
- package/dist/tool-renderers/write.js +42 -0
- package/dist/ui.d.ts +56 -0
- package/dist/ui.js +94 -0
- package/docs/release.md +81 -0
- package/extensions/question/contract.ts +100 -0
- package/extensions/question/index.ts +34 -0
- package/extensions/question/render.ts +28 -0
- package/extensions/question/result.ts +86 -0
- package/extensions/question/tool-description.ts +11 -0
- package/extensions/question/tui.ts +629 -0
- package/extensions/question/types.ts +123 -0
- package/extensions/session-title/config.ts +169 -0
- package/extensions/session-title/index.ts +459 -0
- package/extensions/terminal-bell/index.ts +315 -0
- package/external/pi-tools-suite/README.md +242 -0
- package/external/pi-tools-suite/index.ts +1 -0
- package/external/pi-tools-suite/licenses/ollama-pi-web-search.MIT +21 -0
- package/external/pi-tools-suite/licenses/opencode-mystatus-MIT.txt +21 -0
- package/external/pi-tools-suite/package.json +53 -0
- package/external/pi-tools-suite/src/antigravity-auth/auth-store.ts +194 -0
- package/external/pi-tools-suite/src/antigravity-auth/commands.ts +80 -0
- package/external/pi-tools-suite/src/antigravity-auth/constants.ts +26 -0
- package/external/pi-tools-suite/src/antigravity-auth/headers.ts +20 -0
- package/external/pi-tools-suite/src/antigravity-auth/index.ts +104 -0
- package/external/pi-tools-suite/src/antigravity-auth/models.ts +86 -0
- package/external/pi-tools-suite/src/antigravity-auth/oauth.ts +305 -0
- package/external/pi-tools-suite/src/antigravity-auth/payload.ts +423 -0
- package/external/pi-tools-suite/src/antigravity-auth/status.ts +78 -0
- package/external/pi-tools-suite/src/antigravity-auth/stream.ts +302 -0
- package/external/pi-tools-suite/src/antigravity-auth/types.ts +113 -0
- package/external/pi-tools-suite/src/ast-grep/index.ts +6 -0
- package/external/pi-tools-suite/src/ast-grep/render.ts +70 -0
- package/external/pi-tools-suite/src/ast-grep/schema.ts +109 -0
- package/external/pi-tools-suite/src/ast-grep/tool.ts +345 -0
- package/external/pi-tools-suite/src/ast-grep/types.ts +55 -0
- package/external/pi-tools-suite/src/ast-grep/utils.ts +65 -0
- package/external/pi-tools-suite/src/async-subagents/async-subagents.sample.jsonc +222 -0
- package/external/pi-tools-suite/src/async-subagents/commands.ts +518 -0
- package/external/pi-tools-suite/src/async-subagents/constants.ts +11 -0
- package/external/pi-tools-suite/src/async-subagents/core/agent-strategy.ts +74 -0
- package/external/pi-tools-suite/src/async-subagents/core/attachment-bridge.ts +133 -0
- package/external/pi-tools-suite/src/async-subagents/core/cleanup.ts +66 -0
- package/external/pi-tools-suite/src/async-subagents/core/concurrency.ts +90 -0
- package/external/pi-tools-suite/src/async-subagents/core/config.ts +819 -0
- package/external/pi-tools-suite/src/async-subagents/core/log-limits.ts +166 -0
- package/external/pi-tools-suite/src/async-subagents/core/model-fallback.ts +133 -0
- package/external/pi-tools-suite/src/async-subagents/core/paths.ts +47 -0
- package/external/pi-tools-suite/src/async-subagents/core/pi-invocation.ts +35 -0
- package/external/pi-tools-suite/src/async-subagents/core/presets.ts +67 -0
- package/external/pi-tools-suite/src/async-subagents/core/process.ts +15 -0
- package/external/pi-tools-suite/src/async-subagents/core/prompt.ts +66 -0
- package/external/pi-tools-suite/src/async-subagents/core/registry.ts +224 -0
- package/external/pi-tools-suite/src/async-subagents/core/retry.ts +191 -0
- package/external/pi-tools-suite/src/async-subagents/core/routing.ts +259 -0
- package/external/pi-tools-suite/src/async-subagents/core/sessions.ts +138 -0
- package/external/pi-tools-suite/src/async-subagents/core/spawn.ts +688 -0
- package/external/pi-tools-suite/src/async-subagents/core/state.ts +281 -0
- package/external/pi-tools-suite/src/async-subagents/core/stop.ts +131 -0
- package/external/pi-tools-suite/src/async-subagents/core/structured-result.ts +237 -0
- package/external/pi-tools-suite/src/async-subagents/core/tool-guard.ts +34 -0
- package/external/pi-tools-suite/src/async-subagents/core/types.ts +150 -0
- package/external/pi-tools-suite/src/async-subagents/core/ultrawork-auto.ts +184 -0
- package/external/pi-tools-suite/src/async-subagents/core/utils.ts +11 -0
- package/external/pi-tools-suite/src/async-subagents/format.ts +41 -0
- package/external/pi-tools-suite/src/async-subagents/index.ts +422 -0
- package/external/pi-tools-suite/src/async-subagents/lib.ts +88 -0
- package/external/pi-tools-suite/src/async-subagents/live.ts +10 -0
- package/external/pi-tools-suite/src/async-subagents/polling.ts +83 -0
- package/external/pi-tools-suite/src/async-subagents/render.ts +230 -0
- package/external/pi-tools-suite/src/async-subagents/subagent-overlay.ts +77 -0
- package/external/pi-tools-suite/src/async-subagents/tasks.ts +120 -0
- package/external/pi-tools-suite/src/async-subagents/tools/cleanup.ts +99 -0
- package/external/pi-tools-suite/src/async-subagents/tools/result.ts +179 -0
- package/external/pi-tools-suite/src/async-subagents/tools/spawn.ts +372 -0
- package/external/pi-tools-suite/src/async-subagents/tools/status.ts +60 -0
- package/external/pi-tools-suite/src/async-subagents/tools/stop.ts +79 -0
- package/external/pi-tools-suite/src/async-subagents/tools/subagents.ts +152 -0
- package/external/pi-tools-suite/src/async-subagents/tools/wait.ts +67 -0
- package/external/pi-tools-suite/src/async-subagents/types.ts +45 -0
- package/external/pi-tools-suite/src/async-subagents/ui.ts +5 -0
- package/external/pi-tools-suite/src/compress/commands.ts +440 -0
- package/external/pi-tools-suite/src/compress/compress-tool.ts +368 -0
- package/external/pi-tools-suite/src/compress/compression-blocks.ts +524 -0
- package/external/pi-tools-suite/src/compress/config.ts +310 -0
- package/external/pi-tools-suite/src/compress/dcp-tui-filter.ts +498 -0
- package/external/pi-tools-suite/src/compress/index.ts +397 -0
- package/external/pi-tools-suite/src/compress/prompts.ts +269 -0
- package/external/pi-tools-suite/src/compress/pruner-candidates.ts +176 -0
- package/external/pi-tools-suite/src/compress/pruner-compression-blocks.ts +260 -0
- package/external/pi-tools-suite/src/compress/pruner-message-ids.ts +147 -0
- package/external/pi-tools-suite/src/compress/pruner-metadata.ts +268 -0
- package/external/pi-tools-suite/src/compress/pruner-nudge.ts +315 -0
- package/external/pi-tools-suite/src/compress/pruner-tools.ts +263 -0
- package/external/pi-tools-suite/src/compress/pruner-types.ts +25 -0
- package/external/pi-tools-suite/src/compress/pruner.ts +92 -0
- package/external/pi-tools-suite/src/compress/state.ts +486 -0
- package/external/pi-tools-suite/src/compress/ui.ts +308 -0
- package/external/pi-tools-suite/src/config.ts +176 -0
- package/external/pi-tools-suite/src/context-usage.ts +31 -0
- package/external/pi-tools-suite/src/default-pi-tools-suite-config.ts +355 -0
- package/external/pi-tools-suite/src/index.ts +46 -0
- package/external/pi-tools-suite/src/lib/lsp.ts +62 -0
- package/external/pi-tools-suite/src/lib/project.ts +42 -0
- package/external/pi-tools-suite/src/lib/tool-args.ts +137 -0
- package/external/pi-tools-suite/src/lsp/_shared/config.ts +156 -0
- package/external/pi-tools-suite/src/lsp/_shared/glob.ts +60 -0
- package/external/pi-tools-suite/src/lsp/_shared/output.ts +102 -0
- package/external/pi-tools-suite/src/lsp/_shared/paths.ts +138 -0
- package/external/pi-tools-suite/src/lsp/_shared/runner.ts +64 -0
- package/external/pi-tools-suite/src/lsp/_shared/template.ts +23 -0
- package/external/pi-tools-suite/src/lsp/_shared/trust.ts +116 -0
- package/external/pi-tools-suite/src/lsp/_shared/types.ts +98 -0
- package/external/pi-tools-suite/src/lsp/async.ts +29 -0
- package/external/pi-tools-suite/src/lsp/child-process.ts +81 -0
- package/external/pi-tools-suite/src/lsp/client.ts +340 -0
- package/external/pi-tools-suite/src/lsp/constants.ts +9 -0
- package/external/pi-tools-suite/src/lsp/diagnostics-store.ts +64 -0
- package/external/pi-tools-suite/src/lsp/documents.ts +24 -0
- package/external/pi-tools-suite/src/lsp/index.ts +31 -0
- package/external/pi-tools-suite/src/lsp/lsp-utils.ts +37 -0
- package/external/pi-tools-suite/src/lsp/manager.ts +190 -0
- package/external/pi-tools-suite/src/lsp/mutation-events.ts +78 -0
- package/external/pi-tools-suite/src/lsp/renderer.ts +1 -0
- package/external/pi-tools-suite/src/lsp/tool-result.ts +6 -0
- package/external/pi-tools-suite/src/lsp/tsserver.ts +107 -0
- package/external/pi-tools-suite/src/lsp/types.ts +15 -0
- package/external/pi-tools-suite/src/model-tools/apply-patch.ts +590 -0
- package/external/pi-tools-suite/src/model-tools/index.ts +430 -0
- package/external/pi-tools-suite/src/model-tools/path-utils.ts +6 -0
- package/external/pi-tools-suite/src/model-tools/tool-args.ts +11 -0
- package/external/pi-tools-suite/src/prompt-commands/index.ts +349 -0
- package/external/pi-tools-suite/src/repo-discovery/index.ts +384 -0
- package/external/pi-tools-suite/src/repo-discovery/project.ts +7 -0
- package/external/pi-tools-suite/src/startup-section.ts +13 -0
- package/external/pi-tools-suite/src/terminal-bell/index.ts +309 -0
- package/external/pi-tools-suite/src/todo/index.ts +201 -0
- package/external/pi-tools-suite/src/todo/state/auto-clear.ts +13 -0
- package/external/pi-tools-suite/src/todo/state/invariants.ts +21 -0
- package/external/pi-tools-suite/src/todo/state/persistence.ts +94 -0
- package/external/pi-tools-suite/src/todo/state/replay.ts +38 -0
- package/external/pi-tools-suite/src/todo/state/selectors.ts +49 -0
- package/external/pi-tools-suite/src/todo/state/state-reducer.ts +362 -0
- package/external/pi-tools-suite/src/todo/state/state.ts +18 -0
- package/external/pi-tools-suite/src/todo/state/store.ts +52 -0
- package/external/pi-tools-suite/src/todo/state/task-graph.ts +57 -0
- package/external/pi-tools-suite/src/todo/todo.ts +487 -0
- package/external/pi-tools-suite/src/todo/tool/response-envelope.ts +143 -0
- package/external/pi-tools-suite/src/todo/tool/types.ts +188 -0
- package/external/pi-tools-suite/src/todo/view/format.ts +18 -0
- package/external/pi-tools-suite/src/todo/view/labels.ts +13 -0
- package/external/pi-tools-suite/src/tool-descriptions.ts +369 -0
- package/external/pi-tools-suite/src/usage/index.ts +152 -0
- package/external/pi-tools-suite/src/usage/lib/copilot.ts +535 -0
- package/external/pi-tools-suite/src/usage/lib/google.ts +478 -0
- package/external/pi-tools-suite/src/usage/lib/openai.ts +268 -0
- package/external/pi-tools-suite/src/usage/lib/types.ts +114 -0
- package/external/pi-tools-suite/src/usage/lib/utils.ts +134 -0
- package/external/pi-tools-suite/src/usage/lib/zhipu.ts +228 -0
- package/external/pi-tools-suite/src/web-search/index.ts +397 -0
- package/package.json +89 -0
- package/skills/context7/SKILL.md +69 -0
- package/skills/context7/scripts/context7.sh +73 -0
- package/skills/handoff/SKILL.md +15 -0
- package/skills/pdf/LICENSE.txt +30 -0
- package/skills/pdf/SKILL.md +314 -0
- package/skills/pdf/forms.md +294 -0
- package/skills/pdf/reference.md +612 -0
- package/skills/pdf/scripts/check_bounding_boxes.py +65 -0
- package/skills/pdf/scripts/check_fillable_fields.py +11 -0
- package/skills/pdf/scripts/convert_pdf_to_images.py +33 -0
- package/skills/pdf/scripts/create_validation_image.py +37 -0
- package/skills/pdf/scripts/extract_form_field_info.py +122 -0
- package/skills/pdf/scripts/extract_form_structure.py +115 -0
- package/skills/pdf/scripts/fill_fillable_fields.py +98 -0
- package/skills/pdf/scripts/fill_pdf_form_with_annotations.py +107 -0
- package/skills/playwright-cli/SKILL.md +388 -0
- package/skills/playwright-cli/references/element-attributes.md +23 -0
- package/skills/playwright-cli/references/playwright-tests.md +39 -0
- package/skills/playwright-cli/references/request-mocking.md +87 -0
- package/skills/playwright-cli/references/running-code.md +241 -0
- package/skills/playwright-cli/references/session-management.md +225 -0
- package/skills/playwright-cli/references/spec-driven-testing.md +305 -0
- package/skills/playwright-cli/references/storage-state.md +275 -0
- package/skills/playwright-cli/references/test-generation.md +134 -0
- package/skills/playwright-cli/references/tracing.md +139 -0
- package/skills/playwright-cli/references/video-recording.md +143 -0
- package/skills/simplify/SKILL.md +51 -0
- package/skills/skill-creator/LICENSE.txt +202 -0
- package/skills/skill-creator/SKILL.md +485 -0
- package/skills/skill-creator/agents/analyzer.md +274 -0
- package/skills/skill-creator/agents/comparator.md +202 -0
- package/skills/skill-creator/agents/grader.md +223 -0
- package/skills/skill-creator/assets/eval_review.html +146 -0
- package/skills/skill-creator/eval-viewer/generate_review.py +471 -0
- package/skills/skill-creator/eval-viewer/viewer.html +1325 -0
- package/skills/skill-creator/references/schemas.md +430 -0
- package/skills/skill-creator/scripts/__init__.py +0 -0
- package/skills/skill-creator/scripts/aggregate_benchmark.py +401 -0
- package/skills/skill-creator/scripts/generate_report.py +326 -0
- package/skills/skill-creator/scripts/improve_description.py +247 -0
- package/skills/skill-creator/scripts/package_skill.py +136 -0
- package/skills/skill-creator/scripts/quick_validate.py +103 -0
- package/skills/skill-creator/scripts/run_eval.py +310 -0
- package/skills/skill-creator/scripts/run_loop.py +328 -0
- package/skills/skill-creator/scripts/utils.py +47 -0
|
@@ -0,0 +1,629 @@
|
|
|
1
|
+
import * as PiTui from "@earendil-works/pi-tui";
|
|
2
|
+
|
|
3
|
+
import { CUSTOM_ANSWER_LABEL } from "./contract";
|
|
4
|
+
import type {
|
|
5
|
+
NormalizedQuestion,
|
|
6
|
+
QuestionInputHandlingResult,
|
|
7
|
+
QuestionMouseEvent,
|
|
8
|
+
QuestionSelection,
|
|
9
|
+
QuestionUiContext,
|
|
10
|
+
} from "./types";
|
|
11
|
+
|
|
12
|
+
type QuestionMode = "choices" | "custom" | "review";
|
|
13
|
+
type AddLine = (text: string) => number;
|
|
14
|
+
type AddWrappedLine = (text: string) => number;
|
|
15
|
+
type TabTarget = number | "review";
|
|
16
|
+
|
|
17
|
+
type ClickZone =
|
|
18
|
+
| { kind: "tab"; target: TabTarget; row: number; startColumn: number; endColumn: number }
|
|
19
|
+
| { kind: "choice"; index: number; row: number; startColumn: number; endColumn: number }
|
|
20
|
+
| { kind: "custom"; row: number; startColumn: number; endColumn: number }
|
|
21
|
+
| { kind: "review"; index: number; row: number; startColumn: number; endColumn: number }
|
|
22
|
+
| { kind: "submit"; row: number; startColumn: number; endColumn: number };
|
|
23
|
+
|
|
24
|
+
function isKey(data: string, key: string): boolean {
|
|
25
|
+
const tui = PiTui as unknown as { Key?: Record<string, string | ((value: string) => string)>; matchesKey?: (data: string, key: string) => boolean };
|
|
26
|
+
const keyValue = key === "shift+enter" && typeof tui.Key?.shift === "function" ? tui.Key.shift("enter") : tui.Key?.[key];
|
|
27
|
+
if (typeof keyValue === "string" && tui.matchesKey?.(data, keyValue)) return true;
|
|
28
|
+
if (data === key) return true;
|
|
29
|
+
const aliases: Record<string, string[]> = {
|
|
30
|
+
up: ["\u001b[A"],
|
|
31
|
+
down: ["\u001b[B"],
|
|
32
|
+
right: ["\u001b[C"],
|
|
33
|
+
left: ["\u001b[D"],
|
|
34
|
+
enter: ["\r", "\n"],
|
|
35
|
+
escape: ["\u001b"],
|
|
36
|
+
backspace: ["\u007f", "\b"],
|
|
37
|
+
tab: ["\t"],
|
|
38
|
+
"shift+tab": ["\u001b[Z"],
|
|
39
|
+
"shift+enter": ["\u001b[13;2u", "\u001b[13;2~", "\u001b[27;2;13~", "\u001b\r", "\u001b\n"],
|
|
40
|
+
};
|
|
41
|
+
return aliases[key]?.includes(data) ?? false;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
function truncateLine(line: string, width: number, suffix = "…"): string {
|
|
45
|
+
const truncateToWidth = (PiTui as unknown as { truncateToWidth?: (line: string, width: number, suffix?: string) => string }).truncateToWidth;
|
|
46
|
+
if (truncateToWidth) return truncateToWidth(line, width, suffix);
|
|
47
|
+
if (line.length <= width) return line;
|
|
48
|
+
return `${line.slice(0, Math.max(0, width - suffix.length))}${suffix}`;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
function wrapLine(line: string, width: number): string[] {
|
|
52
|
+
const wrapTextWithAnsi = (PiTui as unknown as { wrapTextWithAnsi?: (line: string, width: number) => string[] }).wrapTextWithAnsi;
|
|
53
|
+
if (wrapTextWithAnsi) return wrapTextWithAnsi(line, width);
|
|
54
|
+
if (width <= 0) return [""];
|
|
55
|
+
if (line.length <= width) return [line];
|
|
56
|
+
const words = line.split(/(\s+)/);
|
|
57
|
+
const lines: string[] = [];
|
|
58
|
+
let current = "";
|
|
59
|
+
for (const word of words) {
|
|
60
|
+
if (current.length + word.length <= width) {
|
|
61
|
+
current += word;
|
|
62
|
+
continue;
|
|
63
|
+
}
|
|
64
|
+
if (current.trimEnd()) lines.push(current.trimEnd());
|
|
65
|
+
if (word.length > width) {
|
|
66
|
+
for (let index = 0; index < word.length; index += width) lines.push(word.slice(index, index + width));
|
|
67
|
+
current = "";
|
|
68
|
+
} else {
|
|
69
|
+
current = word.trimStart();
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
if (current.trimEnd()) lines.push(current.trimEnd());
|
|
73
|
+
return lines.length > 0 ? lines : [""];
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
function stripAnsi(text: string): string {
|
|
77
|
+
return text.replace(/\u001b\[[0-9;]*m/g, "");
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
function visibleLength(text: string): number {
|
|
81
|
+
return stripAnsi(text).length;
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
type QuestionStyleOptions = {
|
|
85
|
+
foreground?: string;
|
|
86
|
+
background?: string;
|
|
87
|
+
bold?: boolean;
|
|
88
|
+
};
|
|
89
|
+
|
|
90
|
+
type QuestionThemeLike = {
|
|
91
|
+
fg(color: string, text: string): string;
|
|
92
|
+
bg?: (color: string, text: string) => string;
|
|
93
|
+
bold?: (text: string) => string;
|
|
94
|
+
style?: (text: string, options: QuestionStyleOptions) => string;
|
|
95
|
+
};
|
|
96
|
+
|
|
97
|
+
function styleText(theme: QuestionThemeLike, text: string, options: QuestionStyleOptions): string {
|
|
98
|
+
if (theme.style) return theme.style(text, options);
|
|
99
|
+
let styled = text;
|
|
100
|
+
if (options.foreground) styled = theme.fg(options.foreground, styled);
|
|
101
|
+
if (options.background && theme.bg) styled = theme.bg(options.background, styled);
|
|
102
|
+
if (options.bold && theme.bold) styled = theme.bold(styled);
|
|
103
|
+
return styled;
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
function padVisible(text: string, width: number): string {
|
|
107
|
+
return `${text}${" ".repeat(Math.max(0, width - visibleLength(text)))}`;
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
function paintLine(theme: QuestionThemeLike, text: string, width: number, options: QuestionStyleOptions = {}): string {
|
|
111
|
+
return styleText(theme, padVisible(truncateLine(text, width), width), options);
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
function formatHeader(title: string, width: number): string {
|
|
115
|
+
const titleText = title.replace(/\s+/g, " ").trim() || "Question";
|
|
116
|
+
return truncateLine(titleText, width);
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
function clampIndex(index: number, length: number): number {
|
|
120
|
+
return Math.max(0, Math.min(Math.max(0, length - 1), index));
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
export async function runQuestionnaire(questions: NormalizedQuestion[], ctx: QuestionUiContext): Promise<QuestionSelection[] | null> {
|
|
124
|
+
return ctx.ui.custom<QuestionSelection[] | null>((tui, theme, _keybindings, done) => {
|
|
125
|
+
const selections = new Map<string, QuestionSelection>();
|
|
126
|
+
const customDrafts = new Map<string, string>();
|
|
127
|
+
const reviewSubmitIndex = questions.length;
|
|
128
|
+
const pixCapabilities = (tui as unknown as { pix?: { delegatedEditorInput?: boolean; inputMouse?: boolean } }).pix;
|
|
129
|
+
const usesSharedEditor = Boolean(pixCapabilities?.delegatedEditorInput && ctx.ui.setEditorText && ctx.ui.getEditorText);
|
|
130
|
+
let questionIndex = 0;
|
|
131
|
+
let selectedChoiceIndex = 0;
|
|
132
|
+
let selectedReviewIndex = reviewSubmitIndex;
|
|
133
|
+
let mode: QuestionMode = "choices";
|
|
134
|
+
let customError: string | undefined;
|
|
135
|
+
let cachedWidth: number | undefined;
|
|
136
|
+
let cachedLines: string[] | undefined;
|
|
137
|
+
let clickZones: ClickZone[] = [];
|
|
138
|
+
|
|
139
|
+
function currentQuestion(): NormalizedQuestion {
|
|
140
|
+
return questions[questionIndex]!;
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
function invalidateCache(): void {
|
|
144
|
+
cachedWidth = undefined;
|
|
145
|
+
cachedLines = undefined;
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
function refresh(): void {
|
|
149
|
+
invalidateCache();
|
|
150
|
+
tui.requestRender();
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
function customAnswerIndex(question = currentQuestion()): number {
|
|
154
|
+
return question.choices.length;
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
function sharedEditorText(): string {
|
|
158
|
+
if (usesSharedEditor) return ctx.ui.getEditorText?.() ?? "";
|
|
159
|
+
return customDrafts.get(currentQuestion().id) ?? "";
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
function setSharedEditorText(text: string): void {
|
|
163
|
+
customDrafts.set(currentQuestion().id, text);
|
|
164
|
+
if (usesSharedEditor) ctx.ui.setEditorText?.(text);
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
function clearSharedEditorText(): void {
|
|
168
|
+
if (usesSharedEditor) ctx.ui.setEditorText?.("");
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
function captureCustomDraft(): void {
|
|
172
|
+
if (mode !== "custom") return;
|
|
173
|
+
customDrafts.set(currentQuestion().id, sharedEditorText());
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
function getCompleteSelections(): QuestionSelection[] | undefined {
|
|
177
|
+
const orderedSelections: QuestionSelection[] = [];
|
|
178
|
+
for (const question of questions) {
|
|
179
|
+
const selection = selections.get(question.id);
|
|
180
|
+
if (!selection) return undefined;
|
|
181
|
+
orderedSelections.push(selection);
|
|
182
|
+
}
|
|
183
|
+
return orderedSelections;
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
function firstUnansweredIndex(): number {
|
|
187
|
+
return questions.findIndex((question) => !selections.has(question.id));
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
function submitCompleteSelections(): void {
|
|
191
|
+
const completeSelections = getCompleteSelections();
|
|
192
|
+
if (completeSelections) done(completeSelections);
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
function submitOrAnswerRemaining(): void {
|
|
196
|
+
const firstUnanswered = firstUnansweredIndex();
|
|
197
|
+
if (firstUnanswered !== -1) {
|
|
198
|
+
moveToQuestion(firstUnanswered);
|
|
199
|
+
return;
|
|
200
|
+
}
|
|
201
|
+
submitCompleteSelections();
|
|
202
|
+
}
|
|
203
|
+
|
|
204
|
+
function formatReviewAnswerLabel(question: NormalizedQuestion, selection: QuestionSelection): string {
|
|
205
|
+
if ("customText" in selection) return `${CUSTOM_ANSWER_LABEL}: ${selection.customText}`;
|
|
206
|
+
return question.choices.find((choice) => choice.value === selection.choiceValue)?.label ?? "Unknown";
|
|
207
|
+
}
|
|
208
|
+
|
|
209
|
+
function selectionIndexForQuestion(question: NormalizedQuestion): number {
|
|
210
|
+
const selection = selections.get(question.id);
|
|
211
|
+
if (!selection) return 0;
|
|
212
|
+
if ("customText" in selection) return customAnswerIndex(question);
|
|
213
|
+
const choiceIndex = question.choices.findIndex((choice) => choice.value === selection.choiceValue);
|
|
214
|
+
return choiceIndex === -1 ? 0 : choiceIndex;
|
|
215
|
+
}
|
|
216
|
+
|
|
217
|
+
function syncChoiceSelection(): void {
|
|
218
|
+
selectedChoiceIndex = selectionIndexForQuestion(currentQuestion());
|
|
219
|
+
}
|
|
220
|
+
|
|
221
|
+
function renderSelectableLine(add: AddLine, selected: boolean, text: string, zone: Omit<ClickZone, "row" | "startColumn" | "endColumn">, width: number, foreground = "text"): void {
|
|
222
|
+
const marker = selected ? "›" : " ";
|
|
223
|
+
const line = ` ${marker} ${text}`;
|
|
224
|
+
const row = add(selected
|
|
225
|
+
? paintLine(theme, line, width, { foreground: "selectedText", background: "selectedBg", bold: true })
|
|
226
|
+
: paintLine(theme, line, width, { foreground }));
|
|
227
|
+
clickZones.push({ ...zone, row, startColumn: 1, endColumn: width + 1 } as ClickZone);
|
|
228
|
+
}
|
|
229
|
+
|
|
230
|
+
function renderMutedLine(add: AddLine, text: string, width: number): void {
|
|
231
|
+
add(paintLine(theme, text, width, { foreground: "muted" }));
|
|
232
|
+
}
|
|
233
|
+
|
|
234
|
+
function moveToQuestion(index: number): void {
|
|
235
|
+
captureCustomDraft();
|
|
236
|
+
clearSharedEditorText();
|
|
237
|
+
questionIndex = clampIndex(index, questions.length);
|
|
238
|
+
mode = "choices";
|
|
239
|
+
customError = undefined;
|
|
240
|
+
syncChoiceSelection();
|
|
241
|
+
refresh();
|
|
242
|
+
}
|
|
243
|
+
|
|
244
|
+
function goBack(): void {
|
|
245
|
+
if (mode === "custom") {
|
|
246
|
+
captureCustomDraft();
|
|
247
|
+
clearSharedEditorText();
|
|
248
|
+
mode = "choices";
|
|
249
|
+
customError = undefined;
|
|
250
|
+
syncChoiceSelection();
|
|
251
|
+
refresh();
|
|
252
|
+
return;
|
|
253
|
+
}
|
|
254
|
+
if (mode === "review") {
|
|
255
|
+
moveToQuestion(questions.length - 1);
|
|
256
|
+
return;
|
|
257
|
+
}
|
|
258
|
+
if (questionIndex > 0) moveToQuestion(questionIndex - 1);
|
|
259
|
+
else done(null);
|
|
260
|
+
}
|
|
261
|
+
|
|
262
|
+
function showReview(): void {
|
|
263
|
+
captureCustomDraft();
|
|
264
|
+
clearSharedEditorText();
|
|
265
|
+
mode = "review";
|
|
266
|
+
const firstUnanswered = firstUnansweredIndex();
|
|
267
|
+
selectedReviewIndex = firstUnanswered === -1 ? reviewSubmitIndex : firstUnanswered;
|
|
268
|
+
refresh();
|
|
269
|
+
}
|
|
270
|
+
|
|
271
|
+
function advanceAfterAnswer(): void {
|
|
272
|
+
if (!pixCapabilities?.delegatedEditorInput && questions.length === 1) {
|
|
273
|
+
submitCompleteSelections();
|
|
274
|
+
return;
|
|
275
|
+
}
|
|
276
|
+
if (questionIndex < questions.length - 1) {
|
|
277
|
+
moveToQuestion(questionIndex + 1);
|
|
278
|
+
return;
|
|
279
|
+
}
|
|
280
|
+
showReview();
|
|
281
|
+
}
|
|
282
|
+
|
|
283
|
+
function enterCustomMode(): void {
|
|
284
|
+
const question = currentQuestion();
|
|
285
|
+
const existing = selections.get(question.id);
|
|
286
|
+
const prefill = existing && "customText" in existing ? existing.customText : customDrafts.get(question.id) ?? "";
|
|
287
|
+
mode = "custom";
|
|
288
|
+
selectedChoiceIndex = customAnswerIndex(question);
|
|
289
|
+
customError = undefined;
|
|
290
|
+
setSharedEditorText(prefill);
|
|
291
|
+
refresh();
|
|
292
|
+
}
|
|
293
|
+
|
|
294
|
+
function selectChoice(index: number): void {
|
|
295
|
+
const question = currentQuestion();
|
|
296
|
+
const choice = question.choices[index];
|
|
297
|
+
if (choice) {
|
|
298
|
+
selections.set(question.id, { id: question.id, choiceValue: choice.value });
|
|
299
|
+
customDrafts.delete(question.id);
|
|
300
|
+
clearSharedEditorText();
|
|
301
|
+
advanceAfterAnswer();
|
|
302
|
+
return;
|
|
303
|
+
}
|
|
304
|
+
if (index === question.choices.length) enterCustomMode();
|
|
305
|
+
}
|
|
306
|
+
|
|
307
|
+
function submitCustomAnswer(): void {
|
|
308
|
+
const text = sharedEditorText();
|
|
309
|
+
const trimmed = text.trim();
|
|
310
|
+
if (!trimmed) {
|
|
311
|
+
customError = "Custom Answer cannot be empty.";
|
|
312
|
+
refresh();
|
|
313
|
+
return;
|
|
314
|
+
}
|
|
315
|
+
const question = currentQuestion();
|
|
316
|
+
selections.set(question.id, { id: question.id, customText: trimmed });
|
|
317
|
+
customDrafts.delete(question.id);
|
|
318
|
+
clearSharedEditorText();
|
|
319
|
+
advanceAfterAnswer();
|
|
320
|
+
}
|
|
321
|
+
|
|
322
|
+
function updateChoiceSelection(index: number): void {
|
|
323
|
+
const maxIndex = customAnswerIndex();
|
|
324
|
+
const nextIndex = Math.max(0, Math.min(maxIndex, index));
|
|
325
|
+
if (nextIndex === selectedChoiceIndex) return;
|
|
326
|
+
selectedChoiceIndex = nextIndex;
|
|
327
|
+
refresh();
|
|
328
|
+
}
|
|
329
|
+
|
|
330
|
+
function updateReviewSelection(index: number): void {
|
|
331
|
+
const nextIndex = Math.max(0, Math.min(reviewSubmitIndex, index));
|
|
332
|
+
if (nextIndex === selectedReviewIndex) return;
|
|
333
|
+
selectedReviewIndex = nextIndex;
|
|
334
|
+
refresh();
|
|
335
|
+
}
|
|
336
|
+
|
|
337
|
+
function activeTab(): TabTarget {
|
|
338
|
+
return mode === "review" ? "review" : questionIndex;
|
|
339
|
+
}
|
|
340
|
+
|
|
341
|
+
function activateTab(target: TabTarget): void {
|
|
342
|
+
if (target === "review") showReview();
|
|
343
|
+
else moveToQuestion(target);
|
|
344
|
+
}
|
|
345
|
+
|
|
346
|
+
function moveTab(delta: number): void {
|
|
347
|
+
const targets: TabTarget[] = [...questions.map((_, index) => index), "review"];
|
|
348
|
+
const current = activeTab();
|
|
349
|
+
const currentIndex = Math.max(0, targets.findIndex((target) => target === current));
|
|
350
|
+
const nextIndex = (currentIndex + delta + targets.length) % targets.length;
|
|
351
|
+
activateTab(targets[nextIndex]!);
|
|
352
|
+
}
|
|
353
|
+
|
|
354
|
+
function handleTabNavigation(data: string): boolean {
|
|
355
|
+
if (isKey(data, "tab")) {
|
|
356
|
+
moveTab(1);
|
|
357
|
+
return true;
|
|
358
|
+
}
|
|
359
|
+
if (isKey(data, "shift+tab")) {
|
|
360
|
+
moveTab(-1);
|
|
361
|
+
return true;
|
|
362
|
+
}
|
|
363
|
+
return false;
|
|
364
|
+
}
|
|
365
|
+
|
|
366
|
+
function handleCustomInput(data: string): QuestionInputHandlingResult | void {
|
|
367
|
+
if (handleTabNavigation(data)) return;
|
|
368
|
+
if (isKey(data, "escape")) {
|
|
369
|
+
goBack();
|
|
370
|
+
return;
|
|
371
|
+
}
|
|
372
|
+
if (isKey(data, "shift+enter")) {
|
|
373
|
+
if (usesSharedEditor) return { consume: false };
|
|
374
|
+
setSharedEditorText(`${sharedEditorText()}\n`);
|
|
375
|
+
customError = undefined;
|
|
376
|
+
refresh();
|
|
377
|
+
return;
|
|
378
|
+
}
|
|
379
|
+
if (isKey(data, "enter")) {
|
|
380
|
+
submitCustomAnswer();
|
|
381
|
+
return;
|
|
382
|
+
}
|
|
383
|
+
|
|
384
|
+
if (usesSharedEditor) return { consume: false };
|
|
385
|
+
if (isKey(data, "backspace")) {
|
|
386
|
+
setSharedEditorText(sharedEditorText().slice(0, -1));
|
|
387
|
+
customError = undefined;
|
|
388
|
+
refresh();
|
|
389
|
+
return;
|
|
390
|
+
}
|
|
391
|
+
if (data >= " ") {
|
|
392
|
+
setSharedEditorText(sharedEditorText() + data);
|
|
393
|
+
customError = undefined;
|
|
394
|
+
refresh();
|
|
395
|
+
}
|
|
396
|
+
}
|
|
397
|
+
|
|
398
|
+
function handleReviewInput(data: string): void {
|
|
399
|
+
if (handleTabNavigation(data)) return;
|
|
400
|
+
if (isKey(data, "left")) {
|
|
401
|
+
moveTab(-1);
|
|
402
|
+
return;
|
|
403
|
+
}
|
|
404
|
+
if (isKey(data, "right")) {
|
|
405
|
+
moveTab(1);
|
|
406
|
+
return;
|
|
407
|
+
}
|
|
408
|
+
if (isKey(data, "up")) {
|
|
409
|
+
updateReviewSelection(selectedReviewIndex - 1);
|
|
410
|
+
return;
|
|
411
|
+
}
|
|
412
|
+
if (isKey(data, "down")) {
|
|
413
|
+
updateReviewSelection(selectedReviewIndex + 1);
|
|
414
|
+
return;
|
|
415
|
+
}
|
|
416
|
+
if (data === "s") {
|
|
417
|
+
submitOrAnswerRemaining();
|
|
418
|
+
return;
|
|
419
|
+
}
|
|
420
|
+
if (data === "b" || isKey(data, "backspace")) {
|
|
421
|
+
goBack();
|
|
422
|
+
return;
|
|
423
|
+
}
|
|
424
|
+
if (isKey(data, "enter")) {
|
|
425
|
+
if (selectedReviewIndex === reviewSubmitIndex) {
|
|
426
|
+
submitOrAnswerRemaining();
|
|
427
|
+
return;
|
|
428
|
+
}
|
|
429
|
+
moveToQuestion(selectedReviewIndex);
|
|
430
|
+
return;
|
|
431
|
+
}
|
|
432
|
+
if (isKey(data, "escape")) done(null);
|
|
433
|
+
}
|
|
434
|
+
|
|
435
|
+
function handleChoiceInput(data: string): void {
|
|
436
|
+
if (handleTabNavigation(data)) return;
|
|
437
|
+
if (isKey(data, "left")) {
|
|
438
|
+
moveTab(-1);
|
|
439
|
+
return;
|
|
440
|
+
}
|
|
441
|
+
if (isKey(data, "right")) {
|
|
442
|
+
moveTab(1);
|
|
443
|
+
return;
|
|
444
|
+
}
|
|
445
|
+
if (isKey(data, "up")) {
|
|
446
|
+
updateChoiceSelection(selectedChoiceIndex - 1);
|
|
447
|
+
return;
|
|
448
|
+
}
|
|
449
|
+
if (isKey(data, "down")) {
|
|
450
|
+
updateChoiceSelection(selectedChoiceIndex + 1);
|
|
451
|
+
return;
|
|
452
|
+
}
|
|
453
|
+
if (data === "b" || isKey(data, "backspace")) {
|
|
454
|
+
goBack();
|
|
455
|
+
return;
|
|
456
|
+
}
|
|
457
|
+
if (isKey(data, "enter")) {
|
|
458
|
+
selectChoice(selectedChoiceIndex);
|
|
459
|
+
return;
|
|
460
|
+
}
|
|
461
|
+
if (isKey(data, "escape")) {
|
|
462
|
+
done(null);
|
|
463
|
+
return;
|
|
464
|
+
}
|
|
465
|
+
if (/^[1-9]$/.test(data)) {
|
|
466
|
+
const index = Number(data) - 1;
|
|
467
|
+
if (index <= customAnswerIndex()) selectChoice(index);
|
|
468
|
+
}
|
|
469
|
+
}
|
|
470
|
+
|
|
471
|
+
function renderHeader(add: AddLine, title: string, width: number): void {
|
|
472
|
+
add(paintLine(theme, formatHeader(title, width), width, { foreground: "accent", background: "headerBg", bold: true }));
|
|
473
|
+
}
|
|
474
|
+
|
|
475
|
+
function renderTabs(add: AddLine, width: number): void {
|
|
476
|
+
let plain = " ";
|
|
477
|
+
const styledParts: string[] = [" "];
|
|
478
|
+
const zones: Array<Omit<Extract<ClickZone, { kind: "tab" }>, "row">> = [];
|
|
479
|
+
const active = activeTab();
|
|
480
|
+
|
|
481
|
+
for (let index = 0; index < questions.length; index += 1) {
|
|
482
|
+
const answered = selections.has(questions[index]!.id);
|
|
483
|
+
const label = ` ${index + 1}${answered ? "✓" : "·"} `;
|
|
484
|
+
const startColumn = visibleLength(plain) + 1;
|
|
485
|
+
plain += label;
|
|
486
|
+
const endColumn = visibleLength(plain) + 1;
|
|
487
|
+
styledParts.push(active === index
|
|
488
|
+
? styleText(theme, label, { foreground: "selectedText", background: "selectedBg", bold: true })
|
|
489
|
+
: theme.fg(answered ? "success" : "muted", label));
|
|
490
|
+
zones.push({ kind: "tab", target: index, startColumn, endColumn });
|
|
491
|
+
plain += " ";
|
|
492
|
+
styledParts.push(" ");
|
|
493
|
+
}
|
|
494
|
+
|
|
495
|
+
const reviewComplete = Boolean(getCompleteSelections());
|
|
496
|
+
const reviewLabel = " Review ";
|
|
497
|
+
const reviewStart = visibleLength(plain) + 1;
|
|
498
|
+
plain += reviewLabel;
|
|
499
|
+
const reviewEnd = visibleLength(plain) + 1;
|
|
500
|
+
styledParts.push(active === "review"
|
|
501
|
+
? styleText(theme, reviewLabel, { foreground: "selectedText", background: "selectedBg", bold: true })
|
|
502
|
+
: theme.fg(reviewComplete ? "success" : "muted", reviewLabel));
|
|
503
|
+
zones.push({ kind: "tab", target: "review", startColumn: reviewStart, endColumn: reviewEnd });
|
|
504
|
+
|
|
505
|
+
const renderedRow = add(padVisible(styledParts.join(""), width));
|
|
506
|
+
for (const zone of zones) {
|
|
507
|
+
if (zone.startColumn <= width) clickZones.push({ ...zone, row: renderedRow, endColumn: Math.min(zone.endColumn, width + 1) });
|
|
508
|
+
}
|
|
509
|
+
}
|
|
510
|
+
|
|
511
|
+
function renderSeparator(add: AddLine, width: number): void {
|
|
512
|
+
add(paintLine(theme, "─".repeat(width), width, { foreground: "muted" }));
|
|
513
|
+
}
|
|
514
|
+
|
|
515
|
+
function renderReview(add: AddLine, addWrapped: AddWrappedLine, width: number): void {
|
|
516
|
+
renderHeader(add, "Review answers", width);
|
|
517
|
+
renderTabs(add, width);
|
|
518
|
+
renderSeparator(add, width);
|
|
519
|
+
questions.forEach((question, index) => {
|
|
520
|
+
const answer = selections.get(question.id);
|
|
521
|
+
const label = answer ? formatReviewAnswerLabel(question, answer) : "Unanswered";
|
|
522
|
+
const status = answer ? "✓" : "·";
|
|
523
|
+
renderSelectableLine(
|
|
524
|
+
add,
|
|
525
|
+
index === selectedReviewIndex,
|
|
526
|
+
`${status} ${index + 1}. ${question.label}: ${label}`,
|
|
527
|
+
{ kind: "review", index },
|
|
528
|
+
width,
|
|
529
|
+
answer ? "success" : "warning",
|
|
530
|
+
);
|
|
531
|
+
});
|
|
532
|
+
|
|
533
|
+
const isComplete = Boolean(getCompleteSelections());
|
|
534
|
+
renderSeparator(add, width);
|
|
535
|
+
renderSelectableLine(add, selectedReviewIndex === reviewSubmitIndex, isComplete ? "Submit answers" : "Answer remaining questions", { kind: "submit" }, width, isComplete ? "success" : "warning");
|
|
536
|
+
}
|
|
537
|
+
|
|
538
|
+
function renderQuestion(add: AddLine, addWrapped: AddWrappedLine, width: number): void {
|
|
539
|
+
const question = currentQuestion();
|
|
540
|
+
renderHeader(add, `${questionIndex + 1}/${questions.length} ${question.label}`, width);
|
|
541
|
+
renderTabs(add, width);
|
|
542
|
+
renderSeparator(add, width);
|
|
543
|
+
addWrapped(theme.fg("info", ` ${question.prompt}`));
|
|
544
|
+
question.choices.forEach((choice, index) => {
|
|
545
|
+
renderSelectableLine(add, mode === "choices" && index === selectedChoiceIndex, `${index + 1}. ${choice.label}`, { kind: "choice", index }, width, "warning");
|
|
546
|
+
if (choice.description) renderMutedLine(add, ` ${choice.description}`, width);
|
|
547
|
+
});
|
|
548
|
+
renderSelectableLine(add, mode === "choices" && selectedChoiceIndex === customAnswerIndex(), `${question.choices.length + 1}. ${CUSTOM_ANSWER_LABEL}`, { kind: "custom" }, width, "warning");
|
|
549
|
+
if (mode === "custom") {
|
|
550
|
+
if (!usesSharedEditor) {
|
|
551
|
+
(sharedEditorText() || " ").split("\n").forEach((line) => addWrapped(theme.fg("text", ` ${line}`)));
|
|
552
|
+
}
|
|
553
|
+
if (customError && !sharedEditorText().trim()) addWrapped(theme.fg("warning", ` ${customError}`));
|
|
554
|
+
}
|
|
555
|
+
}
|
|
556
|
+
|
|
557
|
+
function handleMouse(event: QuestionMouseEvent): boolean {
|
|
558
|
+
if (!event.released) return false;
|
|
559
|
+
const zone = clickZones.find((candidate) => (
|
|
560
|
+
candidate.row === event.localRow
|
|
561
|
+
&& event.localColumn >= candidate.startColumn
|
|
562
|
+
&& event.localColumn < candidate.endColumn
|
|
563
|
+
));
|
|
564
|
+
if (!zone) return false;
|
|
565
|
+
|
|
566
|
+
switch (zone.kind) {
|
|
567
|
+
case "tab":
|
|
568
|
+
activateTab(zone.target);
|
|
569
|
+
return true;
|
|
570
|
+
case "choice":
|
|
571
|
+
selectedChoiceIndex = zone.index;
|
|
572
|
+
selectChoice(zone.index);
|
|
573
|
+
return true;
|
|
574
|
+
case "custom":
|
|
575
|
+
enterCustomMode();
|
|
576
|
+
return true;
|
|
577
|
+
case "review":
|
|
578
|
+
moveToQuestion(zone.index);
|
|
579
|
+
return true;
|
|
580
|
+
case "submit":
|
|
581
|
+
submitOrAnswerRemaining();
|
|
582
|
+
return true;
|
|
583
|
+
}
|
|
584
|
+
}
|
|
585
|
+
|
|
586
|
+
return {
|
|
587
|
+
handleInput(data: string): void | QuestionInputHandlingResult {
|
|
588
|
+
switch (mode) {
|
|
589
|
+
case "custom":
|
|
590
|
+
return handleCustomInput(data);
|
|
591
|
+
case "review":
|
|
592
|
+
handleReviewInput(data);
|
|
593
|
+
return;
|
|
594
|
+
case "choices":
|
|
595
|
+
handleChoiceInput(data);
|
|
596
|
+
}
|
|
597
|
+
},
|
|
598
|
+
handleMouse,
|
|
599
|
+
usesEditor() {
|
|
600
|
+
return mode === "custom" && usesSharedEditor;
|
|
601
|
+
},
|
|
602
|
+
invalidate() {
|
|
603
|
+
invalidateCache();
|
|
604
|
+
},
|
|
605
|
+
render(width: number) {
|
|
606
|
+
if (cachedLines && cachedWidth === width) return cachedLines;
|
|
607
|
+
const safeWidth = Math.max(1, width);
|
|
608
|
+
const lines: string[] = [];
|
|
609
|
+
clickZones = [];
|
|
610
|
+
const add = (text: string) => {
|
|
611
|
+
const row = lines.length;
|
|
612
|
+
lines.push(text);
|
|
613
|
+
return row;
|
|
614
|
+
};
|
|
615
|
+
const addWrapped = (text: string) => {
|
|
616
|
+
const row = lines.length;
|
|
617
|
+
const wrapped = wrapLine(text, safeWidth);
|
|
618
|
+
for (const line of wrapped.length > 0 ? wrapped : [""]) lines.push(truncateLine(line, safeWidth));
|
|
619
|
+
return row;
|
|
620
|
+
};
|
|
621
|
+
if (mode === "review") renderReview(add, addWrapped, safeWidth);
|
|
622
|
+
else renderQuestion(add, addWrapped, safeWidth);
|
|
623
|
+
cachedWidth = width;
|
|
624
|
+
cachedLines = lines;
|
|
625
|
+
return lines;
|
|
626
|
+
},
|
|
627
|
+
};
|
|
628
|
+
});
|
|
629
|
+
}
|