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,164 @@
|
|
|
1
|
+
import { isRecord } from "./guards.js";
|
|
2
|
+
import { createId } from "./id.js";
|
|
3
|
+
import { extractImageContents, renderContent, renderUserMessageContent, stringifyUnknown } from "./message-content.js";
|
|
4
|
+
const SYSTEM_CUSTOM_MESSAGE_TYPE = "pix-system";
|
|
5
|
+
const HISTORICAL_SUBAGENTS_OBSERVATION = { showSnapshot: false };
|
|
6
|
+
const DEFAULT_HISTORY_CHUNK_SIZE = 50;
|
|
7
|
+
const DEFAULT_HISTORY_TAIL_MESSAGE_COUNT = 80;
|
|
8
|
+
export function loadSessionHistoryEntries(options) {
|
|
9
|
+
const { messages } = options;
|
|
10
|
+
if (!messages || messages.length === 0)
|
|
11
|
+
return;
|
|
12
|
+
const toolResults = buildToolResults(messages, options, 0, messages.length);
|
|
13
|
+
addSessionHistoryRangeEntries(messages, 0, messages.length, toolResults, options.addEntry, options);
|
|
14
|
+
}
|
|
15
|
+
export async function loadSessionHistoryEntriesAsync(options) {
|
|
16
|
+
const { messages } = options;
|
|
17
|
+
if (!messages || messages.length === 0)
|
|
18
|
+
return !options.isCancelled();
|
|
19
|
+
const chunkSize = Math.max(1, options.chunkSize ?? DEFAULT_HISTORY_CHUNK_SIZE);
|
|
20
|
+
const tailMessageCount = Math.max(1, options.tailMessageCount ?? DEFAULT_HISTORY_TAIL_MESSAGE_COUNT);
|
|
21
|
+
const toolResults = new Map();
|
|
22
|
+
if (options.isCancelled())
|
|
23
|
+
return false;
|
|
24
|
+
const tailStart = expandedTailStart(messages, Math.max(0, messages.length - tailMessageCount));
|
|
25
|
+
buildToolResults(messages, options, tailStart, messages.length, toolResults);
|
|
26
|
+
addSessionHistoryRangeEntries(messages, tailStart, messages.length, toolResults, options.addEntry, options);
|
|
27
|
+
options.render();
|
|
28
|
+
await yieldToEventLoop();
|
|
29
|
+
for (let end = tailStart; end > 0; end -= chunkSize) {
|
|
30
|
+
if (options.isCancelled())
|
|
31
|
+
return false;
|
|
32
|
+
const start = Math.max(0, end - chunkSize);
|
|
33
|
+
buildToolResults(messages, options, start, end, toolResults);
|
|
34
|
+
const entries = [];
|
|
35
|
+
addSessionHistoryRangeEntries(messages, start, end, toolResults, (entry) => entries.push(entry), options);
|
|
36
|
+
if (entries.length > 0)
|
|
37
|
+
options.prependEntries(entries);
|
|
38
|
+
options.render();
|
|
39
|
+
await yieldToEventLoop();
|
|
40
|
+
}
|
|
41
|
+
return !options.isCancelled();
|
|
42
|
+
}
|
|
43
|
+
function expandedTailStart(messages, initialStart) {
|
|
44
|
+
let start = initialStart;
|
|
45
|
+
while (start > 0) {
|
|
46
|
+
const message = messages[start];
|
|
47
|
+
if (!isRecord(message) || message.role !== "toolResult")
|
|
48
|
+
break;
|
|
49
|
+
start -= 1;
|
|
50
|
+
}
|
|
51
|
+
return start;
|
|
52
|
+
}
|
|
53
|
+
function buildToolResults(messages, observers, start, end, toolResults = new Map()) {
|
|
54
|
+
// Build a map from toolCallId -> tool result content for pairing.
|
|
55
|
+
for (let index = start; index < end; index += 1) {
|
|
56
|
+
const message = messages[index];
|
|
57
|
+
if (isRecord(message) && message.role === "toolResult") {
|
|
58
|
+
if (typeof message.toolName === "string")
|
|
59
|
+
observers.observeSubagentsToolResult(message.toolName, message.details, HISTORICAL_SUBAGENTS_OBSERVATION);
|
|
60
|
+
toolResults.set(String(message.toolCallId), {
|
|
61
|
+
content: Array.isArray(message.content) ? message.content : [],
|
|
62
|
+
...(message.details === undefined ? {} : { details: message.details }),
|
|
63
|
+
isError: Boolean(message.isError),
|
|
64
|
+
...(typeof message.toolName === "string" ? { toolName: message.toolName } : {}),
|
|
65
|
+
});
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
return toolResults;
|
|
69
|
+
}
|
|
70
|
+
function addSessionHistoryRangeEntries(messages, start, end, toolResults, addEntry, options) {
|
|
71
|
+
for (let index = start; index < end; index += 1) {
|
|
72
|
+
const message = messages[index];
|
|
73
|
+
if (!isRecord(message))
|
|
74
|
+
continue;
|
|
75
|
+
if (message.role === "custom") {
|
|
76
|
+
const entry = customMessageEntry(message);
|
|
77
|
+
if (entry)
|
|
78
|
+
addEntry(entry);
|
|
79
|
+
}
|
|
80
|
+
else if (message.role === "user") {
|
|
81
|
+
const text = renderUserMessageContent(message.content);
|
|
82
|
+
if (text) {
|
|
83
|
+
const images = extractImageContents(message.content);
|
|
84
|
+
addEntry({ id: createId("user"), kind: "user", text, ...(images.length === 0 ? {} : { images }) });
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
else if (message.role === "assistant") {
|
|
88
|
+
renderAssistantHistoryMessage(message, toolResults, { ...options, addEntry });
|
|
89
|
+
}
|
|
90
|
+
// toolResult messages are rendered inline with their tool entries, skip.
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
async function yieldToEventLoop() {
|
|
94
|
+
await new Promise((resolve) => { setTimeout(resolve, 0); });
|
|
95
|
+
}
|
|
96
|
+
export function customMessageEntry(message) {
|
|
97
|
+
if (message.display !== true)
|
|
98
|
+
return undefined;
|
|
99
|
+
const customType = typeof message.customType === "string" ? message.customType : "custom";
|
|
100
|
+
const text = renderUserMessageContent(message.content);
|
|
101
|
+
if (!text)
|
|
102
|
+
return undefined;
|
|
103
|
+
if (customType === SYSTEM_CUSTOM_MESSAGE_TYPE)
|
|
104
|
+
return { id: createId("system"), kind: "system", text };
|
|
105
|
+
return { id: createId("custom"), kind: "custom", customType, text };
|
|
106
|
+
}
|
|
107
|
+
function renderAssistantHistoryMessage(message, toolResults, options) {
|
|
108
|
+
const content = message.content;
|
|
109
|
+
if (!Array.isArray(content))
|
|
110
|
+
return;
|
|
111
|
+
let assistantText = "";
|
|
112
|
+
let thinkingText = "";
|
|
113
|
+
for (const block of content) {
|
|
114
|
+
if (!isRecord(block))
|
|
115
|
+
continue;
|
|
116
|
+
if (block.type === "toolCall") {
|
|
117
|
+
// Flush accumulated text/thinking before tool call.
|
|
118
|
+
if (thinkingText) {
|
|
119
|
+
options.addEntry({ id: createId("thinking"), kind: "thinking", text: thinkingText, expanded: false, status: "done" });
|
|
120
|
+
thinkingText = "";
|
|
121
|
+
}
|
|
122
|
+
if (assistantText) {
|
|
123
|
+
options.addEntry({ id: createId("assistant"), kind: "assistant", text: assistantText });
|
|
124
|
+
assistantText = "";
|
|
125
|
+
}
|
|
126
|
+
const toolCallId = String(block.id ?? createId("tool"));
|
|
127
|
+
const result = toolResults.get(toolCallId);
|
|
128
|
+
const toolName = result?.toolName ?? String(block.name ?? "unknown");
|
|
129
|
+
const argsText = stringifyUnknown(block.arguments);
|
|
130
|
+
const output = result ? renderContent(result.content) : "";
|
|
131
|
+
const images = result ? extractImageContents(result.content) : [];
|
|
132
|
+
if (result?.details !== undefined)
|
|
133
|
+
options.observeSubagentsToolResult(toolName, result.details, HISTORICAL_SUBAGENTS_OBSERVATION);
|
|
134
|
+
const entryId = createId("tool");
|
|
135
|
+
options.addEntry({
|
|
136
|
+
id: entryId,
|
|
137
|
+
kind: "tool",
|
|
138
|
+
toolCallId,
|
|
139
|
+
toolName,
|
|
140
|
+
argsText,
|
|
141
|
+
output,
|
|
142
|
+
...(images.length === 0 ? {} : { images }),
|
|
143
|
+
...(result?.details === undefined ? {} : { details: result.details }),
|
|
144
|
+
expanded: options.toolDefaultExpanded(toolName),
|
|
145
|
+
isError: result?.isError ?? false,
|
|
146
|
+
status: "done",
|
|
147
|
+
});
|
|
148
|
+
options.setToolEntryId(toolCallId, entryId);
|
|
149
|
+
}
|
|
150
|
+
else if (block.type === "thinking") {
|
|
151
|
+
thinkingText += typeof block.thinking === "string" ? block.thinking : "";
|
|
152
|
+
}
|
|
153
|
+
else if (typeof block.text === "string") {
|
|
154
|
+
assistantText += block.text;
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
// Flush remaining text.
|
|
158
|
+
if (thinkingText) {
|
|
159
|
+
options.addEntry({ id: createId("thinking"), kind: "thinking", text: thinkingText, expanded: false, status: "done" });
|
|
160
|
+
}
|
|
161
|
+
if (assistantText) {
|
|
162
|
+
options.addEntry({ id: createId("assistant"), kind: "assistant", text: assistantText });
|
|
163
|
+
}
|
|
164
|
+
}
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import type { AgentSession, AgentSessionEvent, AgentSessionRuntime, ExtensionCommandContextActions, ExtensionError } from "@earendil-works/pi-coding-agent";
|
|
2
|
+
import type { InputEditor } from "../input-editor.js";
|
|
3
|
+
import type { AppOptions, Entry, PixExtensionUIContext, SessionActivity } from "./types.js";
|
|
4
|
+
export type AppSessionLifecycleHost = {
|
|
5
|
+
options: AppOptions;
|
|
6
|
+
createRuntime(): Promise<AgentSessionRuntime>;
|
|
7
|
+
entries: Entry[];
|
|
8
|
+
runtime(): AgentSessionRuntime | undefined;
|
|
9
|
+
setRuntime(runtime: AgentSessionRuntime | undefined): void;
|
|
10
|
+
isRunning(): boolean;
|
|
11
|
+
setRunning(running: boolean): void;
|
|
12
|
+
inputText(): string;
|
|
13
|
+
setInput(value: string): void;
|
|
14
|
+
inputEditor(): InputEditor;
|
|
15
|
+
enableTerminal(): void;
|
|
16
|
+
disposeRuntimeForQuit(runtime: AgentSessionRuntime): Promise<void>;
|
|
17
|
+
loadRequestHistory(): Promise<void>;
|
|
18
|
+
startSubagentsPolling(): void;
|
|
19
|
+
closeSdkMenuForBind(): void;
|
|
20
|
+
clearExtensionWidgets(): void;
|
|
21
|
+
createExtensionUIContext(): PixExtensionUIContext;
|
|
22
|
+
extensionShutdownHandler(): () => void;
|
|
23
|
+
createExtensionCommandContextActions(runtime: AgentSessionRuntime): ExtensionCommandContextActions;
|
|
24
|
+
handleExtensionError(error: ExtensionError): void;
|
|
25
|
+
handleSessionEvent(event: AgentSessionEvent): void;
|
|
26
|
+
addEntry(entry: Entry): void;
|
|
27
|
+
setStatus(status: string): void;
|
|
28
|
+
showToast(message: string, kind: "success" | "error" | "warning" | "info"): void;
|
|
29
|
+
setSessionStatus(session: AgentSession | undefined): void;
|
|
30
|
+
setSessionActivity(activity: SessionActivity): void;
|
|
31
|
+
sessionEventsReset(): void;
|
|
32
|
+
resetSubagentsWidget(): void;
|
|
33
|
+
resetTodoWidget(): void;
|
|
34
|
+
conversationViewportClear(): void;
|
|
35
|
+
queuedMessagesReset(): void;
|
|
36
|
+
resetConversationMenuState(): void;
|
|
37
|
+
clearMouseRenderState(): void;
|
|
38
|
+
scrollReset(): void;
|
|
39
|
+
loadSessionHistoryEntries(): void;
|
|
40
|
+
syncUserSessionEntryMetadata(): void;
|
|
41
|
+
restoreTabsAfterStartup(): Promise<void>;
|
|
42
|
+
render(): void;
|
|
43
|
+
};
|
|
44
|
+
export declare class AppSessionLifecycleController {
|
|
45
|
+
private readonly host;
|
|
46
|
+
private unsubscribe;
|
|
47
|
+
constructor(host: AppSessionLifecycleHost);
|
|
48
|
+
start(): Promise<void>;
|
|
49
|
+
bindCurrentSession(): Promise<void>;
|
|
50
|
+
unsubscribeSession(): void;
|
|
51
|
+
afterSessionReplacement(message?: string): void;
|
|
52
|
+
resetSessionView(): void;
|
|
53
|
+
loadSessionHistory(): void;
|
|
54
|
+
requireRuntime(): AgentSessionRuntime;
|
|
55
|
+
}
|
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
import { createId } from "./id.js";
|
|
2
|
+
import { stringifyUnknown } from "./message-content.js";
|
|
3
|
+
import { collectStartupAvailabilityIssues } from "./startup-checks.js";
|
|
4
|
+
import { createStartupInfoMessage, isEmptyStartupSession } from "./startup-info.js";
|
|
5
|
+
export class AppSessionLifecycleController {
|
|
6
|
+
host;
|
|
7
|
+
unsubscribe;
|
|
8
|
+
constructor(host) {
|
|
9
|
+
this.host = host;
|
|
10
|
+
}
|
|
11
|
+
async start() {
|
|
12
|
+
if (!process.stdin.isTTY || !process.stdout.isTTY) {
|
|
13
|
+
throw new Error("pi-ui-extend needs an interactive TTY");
|
|
14
|
+
}
|
|
15
|
+
this.host.enableTerminal();
|
|
16
|
+
await this.host.loadRequestHistory();
|
|
17
|
+
this.host.setRunning(true);
|
|
18
|
+
this.host.startSubagentsPolling();
|
|
19
|
+
this.host.render();
|
|
20
|
+
try {
|
|
21
|
+
const runtime = await this.host.createRuntime();
|
|
22
|
+
if (!this.host.isRunning()) {
|
|
23
|
+
await this.host.disposeRuntimeForQuit(runtime);
|
|
24
|
+
return;
|
|
25
|
+
}
|
|
26
|
+
this.host.setRuntime(runtime);
|
|
27
|
+
runtime.setRebindSession(async () => {
|
|
28
|
+
await this.bindCurrentSession();
|
|
29
|
+
});
|
|
30
|
+
await this.bindCurrentSession();
|
|
31
|
+
if (isEmptyStartupSession(runtime)) {
|
|
32
|
+
this.host.addEntry({ id: createId("system"), kind: "system", text: createStartupInfoMessage(runtime) });
|
|
33
|
+
}
|
|
34
|
+
await this.host.restoreTabsAfterStartup();
|
|
35
|
+
const availabilityIssues = await collectStartupAvailabilityIssues(runtime);
|
|
36
|
+
for (const issue of availabilityIssues) {
|
|
37
|
+
this.host.addEntry({
|
|
38
|
+
id: createId(issue.kind),
|
|
39
|
+
kind: issue.kind === "error" ? "error" : "system",
|
|
40
|
+
text: issue.message,
|
|
41
|
+
});
|
|
42
|
+
}
|
|
43
|
+
if (availabilityIssues.some((issue) => issue.kind === "error")) {
|
|
44
|
+
this.host.showToast("Startup dependency unavailable", "error");
|
|
45
|
+
}
|
|
46
|
+
else if (availabilityIssues.length > 0) {
|
|
47
|
+
this.host.showToast("Startup dependency warning", "warning");
|
|
48
|
+
}
|
|
49
|
+
if (runtime.modelFallbackMessage) {
|
|
50
|
+
this.host.addEntry({ id: createId("system"), kind: "system", text: runtime.modelFallbackMessage });
|
|
51
|
+
}
|
|
52
|
+
for (const diag of runtime.diagnostics ?? []) {
|
|
53
|
+
const kind = diag.type === "error" ? "error" : "system";
|
|
54
|
+
this.host.addEntry({ id: createId("system"), kind, text: `[${diag.type}] ${diag.message}` });
|
|
55
|
+
}
|
|
56
|
+
this.host.setSessionStatus(runtime.session);
|
|
57
|
+
this.host.setSessionActivity(runtime.session.isStreaming ? "running" : "idle");
|
|
58
|
+
this.host.render();
|
|
59
|
+
}
|
|
60
|
+
catch (error) {
|
|
61
|
+
this.host.addEntry({ id: createId("error"), kind: "error", text: stringifyUnknown(error) });
|
|
62
|
+
this.host.showToast("Session startup failed", "error");
|
|
63
|
+
this.host.setSessionStatus(undefined);
|
|
64
|
+
this.host.render();
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
async bindCurrentSession() {
|
|
68
|
+
const runtime = this.requireRuntime();
|
|
69
|
+
this.unsubscribe?.();
|
|
70
|
+
this.host.closeSdkMenuForBind();
|
|
71
|
+
this.host.clearExtensionWidgets();
|
|
72
|
+
await runtime.session.bindExtensions({
|
|
73
|
+
uiContext: this.host.createExtensionUIContext(),
|
|
74
|
+
commandContextActions: this.host.createExtensionCommandContextActions(runtime),
|
|
75
|
+
shutdownHandler: this.host.extensionShutdownHandler(),
|
|
76
|
+
onError: (error) => this.host.handleExtensionError(error),
|
|
77
|
+
});
|
|
78
|
+
this.unsubscribe = runtime.session.subscribe((event) => {
|
|
79
|
+
this.host.handleSessionEvent(event);
|
|
80
|
+
});
|
|
81
|
+
}
|
|
82
|
+
unsubscribeSession() {
|
|
83
|
+
this.unsubscribe?.();
|
|
84
|
+
}
|
|
85
|
+
afterSessionReplacement(message) {
|
|
86
|
+
this.resetSessionView();
|
|
87
|
+
this.loadSessionHistory();
|
|
88
|
+
if (message)
|
|
89
|
+
this.host.addEntry({ id: createId("system"), kind: "system", text: message });
|
|
90
|
+
const session = this.host.runtime()?.session;
|
|
91
|
+
this.host.setSessionStatus(session);
|
|
92
|
+
this.host.setSessionActivity(session?.isStreaming ? "running" : "idle");
|
|
93
|
+
this.host.render();
|
|
94
|
+
}
|
|
95
|
+
resetSessionView() {
|
|
96
|
+
this.host.entries.length = 0;
|
|
97
|
+
this.host.sessionEventsReset();
|
|
98
|
+
this.host.resetSubagentsWidget();
|
|
99
|
+
this.host.resetTodoWidget();
|
|
100
|
+
this.host.conversationViewportClear();
|
|
101
|
+
this.host.queuedMessagesReset();
|
|
102
|
+
this.host.resetConversationMenuState();
|
|
103
|
+
this.host.clearMouseRenderState();
|
|
104
|
+
this.host.scrollReset();
|
|
105
|
+
}
|
|
106
|
+
loadSessionHistory() {
|
|
107
|
+
this.host.loadSessionHistoryEntries();
|
|
108
|
+
this.host.syncUserSessionEntryMetadata();
|
|
109
|
+
}
|
|
110
|
+
requireRuntime() {
|
|
111
|
+
const runtime = this.host.runtime();
|
|
112
|
+
if (!runtime)
|
|
113
|
+
throw new Error("Runtime is not initialized");
|
|
114
|
+
return runtime;
|
|
115
|
+
}
|
|
116
|
+
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { type SessionInfo } from "@earendil-works/pi-coding-agent";
|
|
2
|
+
import type { Entry, PixMenuItem } from "./types.js";
|
|
3
|
+
export type SessionSearchMatch = {
|
|
4
|
+
sessionEntryId?: string;
|
|
5
|
+
role?: string;
|
|
6
|
+
text: string;
|
|
7
|
+
matchIndex: number;
|
|
8
|
+
};
|
|
9
|
+
export type SessionSearchResult = {
|
|
10
|
+
session: SessionInfo;
|
|
11
|
+
query: string;
|
|
12
|
+
snippet: string;
|
|
13
|
+
match: SessionSearchMatch;
|
|
14
|
+
};
|
|
15
|
+
export type SessionSearchOptions = {
|
|
16
|
+
cwd: string;
|
|
17
|
+
maxResults?: number;
|
|
18
|
+
snippetLength?: number;
|
|
19
|
+
onProgress?: (loaded: number, total: number) => void;
|
|
20
|
+
};
|
|
21
|
+
export declare function searchSessions(query: string, options: SessionSearchOptions): Promise<SessionSearchResult[]>;
|
|
22
|
+
export declare function createSessionSearchMenuItems(results: readonly SessionSearchResult[]): PixMenuItem<SessionSearchResult>[];
|
|
23
|
+
export declare function searchResultTargetEntry(entries: readonly Entry[], result: SessionSearchResult): Entry | undefined;
|
|
24
|
+
export declare function searchResultScrollNeedles(result: SessionSearchResult): string[];
|
|
@@ -0,0 +1,215 @@
|
|
|
1
|
+
import { SessionManager } from "@earendil-works/pi-coding-agent";
|
|
2
|
+
import { isRecord } from "./guards.js";
|
|
3
|
+
import { renderContent, renderUserMessageContent } from "./message-content.js";
|
|
4
|
+
import { sanitizeText } from "./render-text.js";
|
|
5
|
+
const DEFAULT_MAX_SEARCH_RESULTS = 50;
|
|
6
|
+
const DEFAULT_SNIPPET_LENGTH = 160;
|
|
7
|
+
const DEFAULT_SCROLL_SAMPLE_LENGTH = 80;
|
|
8
|
+
export async function searchSessions(query, options) {
|
|
9
|
+
const needle = normalizeSearchText(query);
|
|
10
|
+
if (!needle)
|
|
11
|
+
return [];
|
|
12
|
+
const maxResults = Math.max(1, options.maxResults ?? DEFAULT_MAX_SEARCH_RESULTS);
|
|
13
|
+
const sessions = await SessionManager.list(options.cwd, undefined, options.onProgress);
|
|
14
|
+
const results = [];
|
|
15
|
+
for (const session of sessions) {
|
|
16
|
+
if (results.length >= maxResults)
|
|
17
|
+
break;
|
|
18
|
+
if (!normalizeSearchText(session.allMessagesText).includes(needle))
|
|
19
|
+
continue;
|
|
20
|
+
const match = findSessionMatch(session, needle);
|
|
21
|
+
if (!match)
|
|
22
|
+
continue;
|
|
23
|
+
results.push({
|
|
24
|
+
session,
|
|
25
|
+
query,
|
|
26
|
+
snippet: createSearchSnippet(match.text, needle, options.snippetLength ?? DEFAULT_SNIPPET_LENGTH),
|
|
27
|
+
match,
|
|
28
|
+
});
|
|
29
|
+
}
|
|
30
|
+
return results;
|
|
31
|
+
}
|
|
32
|
+
export function createSessionSearchMenuItems(results) {
|
|
33
|
+
return results.map((result) => {
|
|
34
|
+
const title = sessionSearchResultTitle(result.session);
|
|
35
|
+
const { date, time } = formatSessionSearchDateTime(result.session.modified);
|
|
36
|
+
const messages = `${result.session.messageCount} msg${result.session.messageCount !== 1 ? "s" : ""}`;
|
|
37
|
+
return {
|
|
38
|
+
value: result,
|
|
39
|
+
label: title,
|
|
40
|
+
description: `${result.snippet} · ${date} ${time} · ${messages} · ${result.session.id.slice(0, 8)}`,
|
|
41
|
+
keywords: [
|
|
42
|
+
result.session.id,
|
|
43
|
+
result.session.name ?? "",
|
|
44
|
+
result.session.firstMessage,
|
|
45
|
+
result.snippet,
|
|
46
|
+
result.match.role ?? "",
|
|
47
|
+
].filter(Boolean),
|
|
48
|
+
};
|
|
49
|
+
});
|
|
50
|
+
}
|
|
51
|
+
export function searchResultTargetEntry(entries, result) {
|
|
52
|
+
const targetSessionEntryId = result.match.sessionEntryId;
|
|
53
|
+
if (targetSessionEntryId) {
|
|
54
|
+
const userEntry = entries.find((entry) => (entry.kind === "user" && entry.sessionEntryId === targetSessionEntryId));
|
|
55
|
+
if (userEntry)
|
|
56
|
+
return userEntry;
|
|
57
|
+
}
|
|
58
|
+
const queryNeedle = normalizeSearchText(result.query);
|
|
59
|
+
if (queryNeedle) {
|
|
60
|
+
const queryMatch = entries.find((entry) => normalizeSearchText(entrySearchText(entry)).includes(queryNeedle));
|
|
61
|
+
if (queryMatch)
|
|
62
|
+
return queryMatch;
|
|
63
|
+
}
|
|
64
|
+
const matchNeedle = normalizeSearchText(result.match.text);
|
|
65
|
+
if (!matchNeedle)
|
|
66
|
+
return undefined;
|
|
67
|
+
return entries.find((entry) => {
|
|
68
|
+
const text = normalizeSearchText(entrySearchText(entry));
|
|
69
|
+
return text.includes(matchNeedle) || matchNeedle.includes(text);
|
|
70
|
+
});
|
|
71
|
+
}
|
|
72
|
+
export function searchResultScrollNeedles(result) {
|
|
73
|
+
const needle = normalizeSearchText(result.query);
|
|
74
|
+
return uniqueNonEmptyStrings([
|
|
75
|
+
createSearchSample(result.match.text, needle, DEFAULT_SCROLL_SAMPLE_LENGTH),
|
|
76
|
+
stripSnippetEllipses(result.snippet),
|
|
77
|
+
result.query,
|
|
78
|
+
]);
|
|
79
|
+
}
|
|
80
|
+
function findSessionMatch(session, needle) {
|
|
81
|
+
try {
|
|
82
|
+
const manager = SessionManager.open(session.path);
|
|
83
|
+
for (const entry of manager.getBranch()) {
|
|
84
|
+
const text = sessionEntrySearchText(entry);
|
|
85
|
+
if (!text)
|
|
86
|
+
continue;
|
|
87
|
+
const matchIndex = normalizeSearchText(text).indexOf(needle);
|
|
88
|
+
if (matchIndex < 0)
|
|
89
|
+
continue;
|
|
90
|
+
const role = sessionEntryRole(entry);
|
|
91
|
+
return {
|
|
92
|
+
sessionEntryId: entry.id,
|
|
93
|
+
...(role === undefined ? {} : { role }),
|
|
94
|
+
text,
|
|
95
|
+
matchIndex,
|
|
96
|
+
};
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
catch {
|
|
100
|
+
return undefined;
|
|
101
|
+
}
|
|
102
|
+
return undefined;
|
|
103
|
+
}
|
|
104
|
+
function sessionEntrySearchText(entry) {
|
|
105
|
+
if (entry.type === "message")
|
|
106
|
+
return messageSearchText(entry.message);
|
|
107
|
+
if (entry.type === "custom_message")
|
|
108
|
+
return renderUserMessageContent(entry.content);
|
|
109
|
+
if (entry.type === "compaction")
|
|
110
|
+
return entry.summary;
|
|
111
|
+
if (entry.type === "branch_summary")
|
|
112
|
+
return entry.summary;
|
|
113
|
+
return "";
|
|
114
|
+
}
|
|
115
|
+
function sessionEntryRole(entry) {
|
|
116
|
+
if (entry.type === "custom_message")
|
|
117
|
+
return entry.customType;
|
|
118
|
+
if (entry.type !== "message" || !isRecord(entry.message))
|
|
119
|
+
return entry.type;
|
|
120
|
+
return typeof entry.message.role === "string" ? entry.message.role : entry.type;
|
|
121
|
+
}
|
|
122
|
+
function messageSearchText(message) {
|
|
123
|
+
if (!isRecord(message))
|
|
124
|
+
return "";
|
|
125
|
+
const content = message.content;
|
|
126
|
+
if (typeof content === "string")
|
|
127
|
+
return content;
|
|
128
|
+
if (!Array.isArray(content))
|
|
129
|
+
return "";
|
|
130
|
+
return message.role === "user" ? renderUserMessageContent(content) : renderContent(content);
|
|
131
|
+
}
|
|
132
|
+
function entrySearchText(entry) {
|
|
133
|
+
switch (entry.kind) {
|
|
134
|
+
case "tool":
|
|
135
|
+
return `${entry.toolName}\n${entry.argsText}\n${entry.output}`;
|
|
136
|
+
case "shell":
|
|
137
|
+
return `${entry.command}\n${entry.output}`;
|
|
138
|
+
case "user":
|
|
139
|
+
case "assistant":
|
|
140
|
+
case "custom":
|
|
141
|
+
case "system":
|
|
142
|
+
case "session-aborted":
|
|
143
|
+
case "thinking":
|
|
144
|
+
case "error":
|
|
145
|
+
case "queued":
|
|
146
|
+
return entry.text;
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
function createSearchSnippet(text, needle, maxLength) {
|
|
150
|
+
const compact = compactDisplayText(text);
|
|
151
|
+
const normalized = normalizeSearchText(compact);
|
|
152
|
+
const matchIndex = normalized.indexOf(needle);
|
|
153
|
+
if (matchIndex < 0)
|
|
154
|
+
return compact.slice(0, maxLength);
|
|
155
|
+
const safeMaxLength = Math.max(20, maxLength);
|
|
156
|
+
const context = Math.max(10, Math.floor((safeMaxLength - needle.length) / 2));
|
|
157
|
+
const start = Math.max(0, matchIndex - context);
|
|
158
|
+
const end = Math.min(compact.length, matchIndex + needle.length + context);
|
|
159
|
+
const prefix = start > 0 ? "…" : "";
|
|
160
|
+
const suffix = end < compact.length ? "…" : "";
|
|
161
|
+
return `${prefix}${compact.slice(start, end)}${suffix}`;
|
|
162
|
+
}
|
|
163
|
+
function createSearchSample(text, needle, maxLength) {
|
|
164
|
+
const compact = compactDisplayText(text);
|
|
165
|
+
if (!compact)
|
|
166
|
+
return "";
|
|
167
|
+
const normalized = normalizeSearchText(compact);
|
|
168
|
+
const matchIndex = needle ? normalized.indexOf(needle) : -1;
|
|
169
|
+
if (matchIndex < 0)
|
|
170
|
+
return compact.slice(0, Math.max(20, maxLength));
|
|
171
|
+
const safeMaxLength = Math.max(20, maxLength, needle.length);
|
|
172
|
+
const context = Math.max(0, Math.floor((safeMaxLength - needle.length) / 2));
|
|
173
|
+
const start = Math.max(0, matchIndex - context);
|
|
174
|
+
const end = Math.min(compact.length, matchIndex + needle.length + context);
|
|
175
|
+
return compact.slice(start, end);
|
|
176
|
+
}
|
|
177
|
+
function stripSnippetEllipses(snippet) {
|
|
178
|
+
return compactDisplayText(snippet.replace(/^…/u, "").replace(/…$/u, ""));
|
|
179
|
+
}
|
|
180
|
+
function uniqueNonEmptyStrings(values) {
|
|
181
|
+
const seen = new Set();
|
|
182
|
+
const result = [];
|
|
183
|
+
for (const value of values) {
|
|
184
|
+
const trimmed = value.trim();
|
|
185
|
+
if (!trimmed)
|
|
186
|
+
continue;
|
|
187
|
+
const key = normalizeSearchText(trimmed);
|
|
188
|
+
if (!key || seen.has(key))
|
|
189
|
+
continue;
|
|
190
|
+
seen.add(key);
|
|
191
|
+
result.push(trimmed);
|
|
192
|
+
}
|
|
193
|
+
return result;
|
|
194
|
+
}
|
|
195
|
+
function compactDisplayText(text) {
|
|
196
|
+
return sanitizeText(text).replace(/\s+/gu, " ").trim();
|
|
197
|
+
}
|
|
198
|
+
function normalizeSearchText(text) {
|
|
199
|
+
return compactDisplayText(text).toLocaleLowerCase();
|
|
200
|
+
}
|
|
201
|
+
function sessionSearchResultTitle(session) {
|
|
202
|
+
const name = session.name?.trim();
|
|
203
|
+
if (name)
|
|
204
|
+
return name;
|
|
205
|
+
const firstMessage = compactDisplayText(session.firstMessage);
|
|
206
|
+
if (firstMessage)
|
|
207
|
+
return firstMessage.slice(0, 60);
|
|
208
|
+
return `session ${session.id.slice(0, 8)}`;
|
|
209
|
+
}
|
|
210
|
+
function formatSessionSearchDateTime(dateTime) {
|
|
211
|
+
return {
|
|
212
|
+
date: dateTime.toLocaleDateString("ru-RU", { day: "2-digit", month: "2-digit", year: "numeric" }),
|
|
213
|
+
time: dateTime.toLocaleTimeString("ru-RU", { hour: "2-digit", minute: "2-digit", hourCycle: "h23" }),
|
|
214
|
+
};
|
|
215
|
+
}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
export type InteractiveShellCommandResult = {
|
|
2
|
+
exitCode: number | null;
|
|
3
|
+
signal: NodeJS.Signals | null;
|
|
4
|
+
error?: string;
|
|
5
|
+
};
|
|
6
|
+
export type BangShellCommand = {
|
|
7
|
+
command: string;
|
|
8
|
+
interactive: boolean;
|
|
9
|
+
};
|
|
10
|
+
export type ChatShellCommandStream = "stdout" | "stderr";
|
|
11
|
+
export type ChatShellCommandHandlers = {
|
|
12
|
+
onOutput?: (chunk: string, stream: ChatShellCommandStream) => void;
|
|
13
|
+
onSettled?: (result: InteractiveShellCommandResult) => void;
|
|
14
|
+
};
|
|
15
|
+
export type RunningChatShellCommand = {
|
|
16
|
+
pid?: number;
|
|
17
|
+
done: Promise<InteractiveShellCommandResult>;
|
|
18
|
+
writeInput(input: string): boolean;
|
|
19
|
+
interrupt(): boolean;
|
|
20
|
+
kill(signal?: NodeJS.Signals): boolean;
|
|
21
|
+
endInput(): void;
|
|
22
|
+
};
|
|
23
|
+
export declare function bangShellCommandFromInput(text: string): BangShellCommand | undefined;
|
|
24
|
+
export declare function shellCommandFromBangInput(text: string): string | undefined;
|
|
25
|
+
export declare function runChatShellCommand(command: string, cwd: string, handlers?: ChatShellCommandHandlers): RunningChatShellCommand;
|
|
26
|
+
export declare function runInteractiveShellCommand(command: string, cwd: string): Promise<InteractiveShellCommandResult>;
|
|
27
|
+
export declare function formatShellCommandEntry(command: string, result: InteractiveShellCommandResult, prefix?: string): string;
|