@f5xc-salesdemos/xcsh 2.2.0 → 14.0.2
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/CHANGELOG.md +6854 -24
- package/README.md +11 -610
- package/examples/README.md +8 -15
- package/examples/custom-tools/README.md +109 -0
- package/examples/custom-tools/hello/index.ts +20 -0
- package/examples/custom-tools/todo/index.ts +206 -0
- package/examples/extensions/README.md +78 -143
- package/examples/extensions/api-demo.ts +89 -0
- package/examples/extensions/chalk-logger.ts +25 -0
- package/examples/extensions/hello.ts +24 -18
- package/examples/extensions/pirate.ts +5 -9
- package/examples/extensions/plan-mode.ts +551 -0
- package/examples/extensions/reload-runtime.ts +1 -1
- package/examples/extensions/todo.ts +18 -19
- package/examples/extensions/tools.ts +23 -19
- package/examples/extensions/with-deps/index.ts +5 -1
- package/examples/extensions/with-deps/package-lock.json +2 -2
- package/examples/extensions/with-deps/package.json +2 -8
- package/examples/hooks/README.md +56 -0
- package/examples/hooks/auto-commit-on-exit.ts +48 -0
- package/examples/hooks/confirm-destructive.ts +58 -0
- package/examples/hooks/custom-compaction.ts +115 -0
- package/examples/hooks/dirty-repo-guard.ts +51 -0
- package/examples/hooks/file-trigger.ts +40 -0
- package/examples/hooks/git-checkpoint.ts +52 -0
- package/examples/hooks/handoff.ts +149 -0
- package/examples/hooks/permission-gate.ts +33 -0
- package/examples/hooks/protected-paths.ts +29 -0
- package/examples/hooks/qna.ts +118 -0
- package/examples/hooks/status-line.ts +39 -0
- package/examples/sdk/01-minimal.ts +3 -4
- package/examples/sdk/02-custom-model.ts +9 -9
- package/examples/sdk/03-custom-prompt.ts +11 -23
- package/examples/sdk/04-skills.ts +23 -32
- package/examples/sdk/06-extensions.ts +14 -22
- package/examples/sdk/06-hooks.ts +61 -0
- package/examples/sdk/07-context-files.ts +18 -23
- package/examples/sdk/08-prompt-templates.ts +14 -21
- package/examples/sdk/08-slash-commands.ts +46 -0
- package/examples/sdk/09-api-keys-and-oauth.ts +15 -9
- package/examples/sdk/11-sessions.ts +3 -4
- package/examples/sdk/README.md +117 -92
- package/package.json +507 -82
- package/scripts/format-prompts.ts +68 -0
- package/scripts/generate-docs-index.ts +40 -0
- package/scripts/generate-template.ts +32 -0
- package/src/async/index.ts +1 -0
- package/src/async/job-manager.ts +383 -0
- package/src/autoresearch/apply-contract-to-state.ts +24 -0
- package/src/autoresearch/command-resume.md +17 -0
- package/src/autoresearch/contract.ts +288 -0
- package/src/autoresearch/dashboard.ts +446 -0
- package/src/autoresearch/git.ts +329 -0
- package/src/autoresearch/helpers.ts +507 -0
- package/src/autoresearch/index.ts +534 -0
- package/src/autoresearch/prompt.md +244 -0
- package/src/autoresearch/resume-message.md +16 -0
- package/src/autoresearch/state.ts +380 -0
- package/src/autoresearch/tools/init-experiment.ts +395 -0
- package/src/autoresearch/tools/log-experiment.ts +778 -0
- package/src/autoresearch/tools/run-experiment.ts +678 -0
- package/src/autoresearch/types.ts +218 -0
- package/src/bun-imports.d.ts +22 -0
- package/src/capability/context-file.ts +44 -0
- package/src/capability/extension-module.ts +34 -0
- package/src/capability/extension.ts +47 -0
- package/src/capability/fs.ts +107 -0
- package/src/capability/hook.ts +40 -0
- package/src/capability/index.ts +436 -0
- package/src/capability/instruction.ts +37 -0
- package/src/capability/mcp.ts +74 -0
- package/src/capability/prompt.ts +35 -0
- package/src/capability/rule.ts +224 -0
- package/src/capability/settings.ts +34 -0
- package/src/capability/skill.ts +49 -0
- package/src/capability/slash-command.ts +40 -0
- package/src/capability/ssh.ts +41 -0
- package/src/capability/system-prompt.ts +34 -0
- package/src/capability/tool.ts +38 -0
- package/src/capability/types.ts +168 -0
- package/src/cli/agents-cli.ts +138 -0
- package/src/cli/args.ts +283 -0
- package/src/cli/classify-install-target.ts +50 -0
- package/src/cli/commands/init-xdg.ts +27 -0
- package/src/cli/config-cli.ts +418 -0
- package/src/cli/file-processor.ts +123 -0
- package/src/cli/grep-cli.ts +160 -0
- package/src/cli/grievances-cli.ts +78 -0
- package/src/cli/initial-message.ts +58 -0
- package/src/cli/jupyter-cli.ts +106 -0
- package/src/cli/list-models.ts +89 -0
- package/src/cli/plugin-cli.ts +964 -0
- package/src/cli/read-cli.ts +67 -0
- package/src/cli/session-picker.ts +52 -0
- package/src/cli/setup-cli.ts +376 -0
- package/src/cli/shell-cli.ts +174 -0
- package/src/cli/ssh-cli.ts +179 -0
- package/src/cli/stats-cli.ts +182 -0
- package/src/cli/update-cli.ts +342 -0
- package/src/cli/web-search-cli.ts +133 -0
- package/src/cli.ts +96 -0
- package/src/commands/agents.ts +57 -0
- package/src/commands/commit.ts +36 -0
- package/src/commands/config.ts +51 -0
- package/src/commands/grep.ts +48 -0
- package/src/commands/grievances.ts +20 -0
- package/src/commands/jupyter.ts +32 -0
- package/src/commands/launch.ts +141 -0
- package/src/commands/plugin.ts +78 -0
- package/src/commands/read.ts +33 -0
- package/src/commands/setup.ts +42 -0
- package/src/commands/shell.ts +29 -0
- package/src/commands/ssh.ts +60 -0
- package/src/commands/stats.ts +29 -0
- package/src/commands/update.ts +21 -0
- package/src/commands/web-search.ts +42 -0
- package/src/commit/agentic/agent.ts +314 -0
- package/src/commit/agentic/fallback.ts +96 -0
- package/src/commit/agentic/index.ts +354 -0
- package/src/commit/agentic/prompts/analyze-file.md +22 -0
- package/src/commit/agentic/prompts/session-user.md +25 -0
- package/src/commit/agentic/prompts/split-confirm.md +1 -0
- package/src/commit/agentic/prompts/system.md +38 -0
- package/src/commit/agentic/state.ts +60 -0
- package/src/commit/agentic/tools/analyze-file.ts +128 -0
- package/src/commit/agentic/tools/git-file-diff.ts +191 -0
- package/src/commit/agentic/tools/git-hunk.ts +50 -0
- package/src/commit/agentic/tools/git-overview.ts +81 -0
- package/src/commit/agentic/tools/index.ts +54 -0
- package/src/commit/agentic/tools/propose-changelog.ts +139 -0
- package/src/commit/agentic/tools/propose-commit.ts +122 -0
- package/src/commit/agentic/tools/recent-commits.ts +81 -0
- package/src/commit/agentic/tools/schemas.ts +31 -0
- package/src/commit/agentic/tools/split-commit.ts +251 -0
- package/src/commit/agentic/topo-sort.ts +44 -0
- package/src/commit/agentic/trivial.ts +51 -0
- package/src/commit/agentic/validation.ts +183 -0
- package/src/commit/analysis/conventional.ts +122 -0
- package/src/commit/analysis/index.ts +4 -0
- package/src/commit/analysis/scope.ts +242 -0
- package/src/commit/analysis/summary.ts +105 -0
- package/src/commit/analysis/validation.ts +66 -0
- package/src/commit/changelog/detect.ts +40 -0
- package/src/commit/changelog/generate.ts +101 -0
- package/src/commit/changelog/index.ts +234 -0
- package/src/commit/changelog/parse.ts +44 -0
- package/src/commit/cli.ts +85 -0
- package/src/commit/git/diff.ts +148 -0
- package/src/commit/index.ts +5 -0
- package/src/commit/map-reduce/index.ts +69 -0
- package/src/commit/map-reduce/map-phase.ts +193 -0
- package/src/commit/map-reduce/reduce-phase.ts +108 -0
- package/src/commit/map-reduce/utils.ts +9 -0
- package/src/commit/message.ts +11 -0
- package/src/commit/model-selection.ts +63 -0
- package/src/commit/pipeline.ts +242 -0
- package/src/commit/prompts/analysis-system.md +148 -0
- package/src/commit/prompts/analysis-user.md +38 -0
- package/src/commit/prompts/changelog-system.md +50 -0
- package/src/commit/prompts/changelog-user.md +18 -0
- package/src/commit/prompts/file-observer-system.md +24 -0
- package/src/commit/prompts/file-observer-user.md +8 -0
- package/src/commit/prompts/reduce-system.md +50 -0
- package/src/commit/prompts/reduce-user.md +17 -0
- package/src/commit/prompts/summary-retry.md +3 -0
- package/src/commit/prompts/summary-system.md +38 -0
- package/src/commit/prompts/summary-user.md +13 -0
- package/src/commit/prompts/types-description.md +2 -0
- package/src/commit/types.ts +118 -0
- package/src/commit/utils/exclusions.ts +42 -0
- package/src/commit/utils.ts +44 -0
- package/src/config/file-lock.ts +121 -0
- package/src/config/keybindings.ts +493 -0
- package/src/config/mcp-schema.json +230 -0
- package/src/config/model-registry.ts +1917 -0
- package/src/config/model-resolver.ts +1064 -0
- package/src/config/prompt-templates.ts +255 -0
- package/src/config/resolve-config-value.ts +94 -0
- package/src/config/settings-schema.ts +1929 -0
- package/src/config/settings.ts +701 -0
- package/src/config.ts +419 -0
- package/src/cursor.ts +304 -0
- package/src/dap/client.ts +674 -0
- package/src/dap/config.ts +150 -0
- package/src/dap/defaults.json +211 -0
- package/src/dap/index.ts +4 -0
- package/src/dap/session.ts +1255 -0
- package/src/dap/types.ts +600 -0
- package/src/debug/index.ts +438 -0
- package/src/debug/log-formatting.ts +58 -0
- package/src/debug/log-viewer.ts +908 -0
- package/src/debug/profiler.ts +158 -0
- package/src/debug/report-bundle.ts +365 -0
- package/src/debug/system-info.ts +107 -0
- package/src/discovery/agents-md.ts +67 -0
- package/src/discovery/agents.ts +219 -0
- package/src/discovery/builtin.ts +851 -0
- package/src/discovery/claude-plugins.ts +296 -0
- package/src/discovery/claude.ts +543 -0
- package/src/discovery/cline.ts +83 -0
- package/src/discovery/codex.ts +535 -0
- package/src/discovery/cursor.ts +220 -0
- package/src/discovery/gemini.ts +396 -0
- package/src/discovery/github.ts +118 -0
- package/src/discovery/helpers.ts +968 -0
- package/src/discovery/index.ts +79 -0
- package/src/discovery/mcp-json.ts +171 -0
- package/src/discovery/opencode.ts +393 -0
- package/src/discovery/plugin-dir-roots.ts +28 -0
- package/src/discovery/ssh.ts +153 -0
- package/src/discovery/substitute-plugin-root.ts +29 -0
- package/src/discovery/vscode.ts +105 -0
- package/src/discovery/windsurf.ts +147 -0
- package/src/edit/diff.ts +818 -0
- package/src/edit/index.ts +314 -0
- package/src/edit/line-hash.ts +67 -0
- package/src/edit/modes/chunk.ts +454 -0
- package/src/edit/modes/hashline.ts +1341 -0
- package/src/edit/modes/patch.ts +1785 -0
- package/src/edit/modes/replace.ts +1107 -0
- package/src/edit/normalize.ts +375 -0
- package/src/edit/renderer.ts +467 -0
- package/src/exa/factory.ts +59 -0
- package/src/exa/index.ts +27 -0
- package/src/exa/mcp-client.ts +291 -0
- package/src/exa/render.ts +244 -0
- package/src/exa/researcher.ts +47 -0
- package/src/exa/search.ts +86 -0
- package/src/exa/types.ts +166 -0
- package/src/exa/websets.ts +247 -0
- package/src/exec/bash-executor.ts +240 -0
- package/src/exec/exec.ts +53 -0
- package/src/exec/idle-timeout-watchdog.ts +126 -0
- package/src/exec/non-interactive-env.ts +48 -0
- package/src/export/custom-share.ts +65 -0
- package/src/export/html/index.ts +161 -0
- package/src/export/html/template.css +919 -0
- package/src/export/html/template.generated.ts +2 -0
- package/src/export/html/template.html +46 -0
- package/src/export/html/template.js +1458 -0
- package/src/export/html/template.macro.ts +24 -0
- package/src/export/ttsr.ts +434 -0
- package/src/extensibility/custom-commands/bundled/ci-green/index.ts +25 -0
- package/src/extensibility/custom-commands/bundled/review/index.ts +435 -0
- package/src/extensibility/custom-commands/index.ts +2 -0
- package/src/extensibility/custom-commands/loader.ts +236 -0
- package/src/extensibility/custom-commands/types.ts +111 -0
- package/src/extensibility/custom-tools/index.ts +7 -0
- package/src/extensibility/custom-tools/loader.ts +238 -0
- package/src/extensibility/custom-tools/types.ts +255 -0
- package/src/extensibility/custom-tools/wrapper.ts +47 -0
- package/src/extensibility/extensions/index.ts +15 -0
- package/src/extensibility/extensions/loader.ts +516 -0
- package/src/extensibility/extensions/runner.ts +841 -0
- package/src/extensibility/extensions/types.ts +1366 -0
- package/src/extensibility/extensions/wrapper.ts +191 -0
- package/src/extensibility/hooks/index.ts +5 -0
- package/src/extensibility/hooks/loader.ts +255 -0
- package/src/extensibility/hooks/runner.ts +425 -0
- package/src/extensibility/hooks/tool-wrapper.ts +108 -0
- package/src/extensibility/hooks/types.ts +822 -0
- package/src/extensibility/plugins/doctor.ts +66 -0
- package/src/extensibility/plugins/git-url.ts +281 -0
- package/src/extensibility/plugins/index.ts +9 -0
- package/src/extensibility/plugins/installer.ts +192 -0
- package/src/extensibility/plugins/loader.ts +267 -0
- package/src/extensibility/plugins/manager.ts +731 -0
- package/src/extensibility/plugins/marketplace/cache.ts +136 -0
- package/src/extensibility/plugins/marketplace/fetcher.ts +317 -0
- package/src/extensibility/plugins/marketplace/index.ts +6 -0
- package/src/extensibility/plugins/marketplace/manager.ts +751 -0
- package/src/extensibility/plugins/marketplace/registry.ts +196 -0
- package/src/extensibility/plugins/marketplace/source-resolver.ts +147 -0
- package/src/extensibility/plugins/marketplace/types.ts +191 -0
- package/src/extensibility/plugins/parser.ts +105 -0
- package/src/extensibility/plugins/types.ts +194 -0
- package/src/extensibility/skills.ts +252 -0
- package/src/extensibility/slash-commands.ts +227 -0
- package/src/extensibility/tool-proxy.ts +25 -0
- package/src/extensibility/utils.ts +38 -0
- package/src/index.ts +61 -0
- package/src/internal-urls/agent-protocol.ts +136 -0
- package/src/internal-urls/artifact-protocol.ts +97 -0
- package/src/internal-urls/docs-index.generated.ts +57 -0
- package/src/internal-urls/index.ts +35 -0
- package/src/internal-urls/jobs-protocol.ts +118 -0
- package/src/internal-urls/json-query.ts +126 -0
- package/src/internal-urls/local-protocol.ts +206 -0
- package/src/internal-urls/mcp-protocol.ts +156 -0
- package/src/internal-urls/memory-protocol.ts +133 -0
- package/src/internal-urls/parse.ts +72 -0
- package/src/internal-urls/pi-protocol.ts +84 -0
- package/src/internal-urls/router.ts +54 -0
- package/src/internal-urls/rule-protocol.ts +55 -0
- package/src/internal-urls/skill-protocol.ts +111 -0
- package/src/internal-urls/types.ts +52 -0
- package/src/ipy/cancellation.ts +28 -0
- package/src/ipy/executor.ts +762 -0
- package/src/ipy/gateway-coordinator.ts +424 -0
- package/src/ipy/kernel.ts +1065 -0
- package/src/ipy/modules.ts +144 -0
- package/src/ipy/prelude.py +849 -0
- package/src/ipy/prelude.ts +3 -0
- package/src/ipy/runtime.ts +221 -0
- package/src/lsp/client.ts +878 -0
- package/src/lsp/clients/biome-client.ts +202 -0
- package/src/lsp/clients/index.ts +50 -0
- package/src/lsp/clients/lsp-linter-client.ts +93 -0
- package/src/lsp/clients/swiftlint-client.ts +120 -0
- package/src/lsp/config.ts +402 -0
- package/src/lsp/defaults.json +998 -0
- package/src/lsp/edits.ts +109 -0
- package/src/lsp/index.ts +1743 -0
- package/src/lsp/lspmux.ts +233 -0
- package/src/lsp/render.ts +683 -0
- package/src/lsp/startup-events.ts +13 -0
- package/src/lsp/types.ts +438 -0
- package/src/lsp/utils.ts +807 -0
- package/src/main.ts +914 -0
- package/src/mcp/client.ts +482 -0
- package/src/mcp/config-writer.ts +225 -0
- package/src/mcp/config.ts +365 -0
- package/src/mcp/discoverable-tool-metadata.ts +202 -0
- package/src/mcp/index.ts +29 -0
- package/src/mcp/json-rpc.ts +84 -0
- package/src/mcp/loader.ts +124 -0
- package/src/mcp/manager.ts +1152 -0
- package/src/mcp/oauth-discovery.ts +349 -0
- package/src/mcp/oauth-flow.ts +387 -0
- package/src/mcp/render.ts +130 -0
- package/src/mcp/smithery-auth.ts +104 -0
- package/src/mcp/smithery-connect.ts +145 -0
- package/src/mcp/smithery-registry.ts +477 -0
- package/src/mcp/tool-bridge.ts +417 -0
- package/src/mcp/tool-cache.ts +117 -0
- package/src/mcp/transports/http.ts +475 -0
- package/src/mcp/transports/index.ts +6 -0
- package/src/mcp/transports/stdio.ts +325 -0
- package/src/mcp/types.ts +423 -0
- package/src/memories/index.ts +1114 -0
- package/src/memories/storage.ts +577 -0
- package/src/modes/acp/acp-agent.ts +1358 -0
- package/src/modes/acp/acp-event-mapper.ts +538 -0
- package/src/modes/acp/acp-mode.ts +15 -0
- package/src/modes/acp/index.ts +2 -0
- package/src/modes/components/agent-dashboard.ts +1120 -0
- package/src/modes/components/assistant-message.ts +206 -0
- package/src/modes/components/bash-execution.ts +247 -0
- package/src/modes/components/bordered-loader.ts +41 -0
- package/src/modes/components/branch-summary-message.ts +45 -0
- package/src/modes/components/btw-panel.ts +104 -0
- package/src/modes/components/compaction-summary-message.ts +51 -0
- package/src/modes/components/countdown-timer.ts +75 -0
- package/src/modes/components/custom-editor.ts +238 -0
- package/src/modes/components/custom-message.ts +91 -0
- package/src/modes/components/diff.ts +210 -0
- package/src/modes/components/dynamic-border.ts +25 -0
- package/src/modes/components/extensions/extension-dashboard.ts +326 -0
- package/src/modes/components/extensions/extension-list.ts +492 -0
- package/src/modes/components/extensions/index.ts +9 -0
- package/src/modes/components/extensions/inspector-panel.ts +317 -0
- package/src/modes/components/extensions/state-manager.ts +587 -0
- package/src/modes/components/extensions/types.ts +191 -0
- package/src/modes/components/footer.ts +262 -0
- package/src/modes/components/history-search.ts +158 -0
- package/src/modes/components/hook-editor.ts +151 -0
- package/src/modes/components/hook-input.ts +79 -0
- package/src/modes/components/hook-message.ts +100 -0
- package/src/modes/components/hook-selector.ts +190 -0
- package/src/modes/components/index.ts +36 -0
- package/src/modes/components/keybinding-hints.ts +65 -0
- package/src/modes/components/login-dialog.ts +164 -0
- package/src/modes/components/mcp-add-wizard.ts +1314 -0
- package/src/modes/components/model-selector.ts +789 -0
- package/src/modes/components/oauth-selector.ts +211 -0
- package/src/modes/components/plugin-selector.ts +95 -0
- package/src/modes/components/plugin-settings.ts +477 -0
- package/src/modes/components/python-execution.ts +181 -0
- package/src/modes/components/queue-mode-selector.ts +56 -0
- package/src/modes/components/read-tool-group.ts +152 -0
- package/src/modes/components/session-observer-overlay.ts +472 -0
- package/src/modes/components/session-selector.ts +343 -0
- package/src/modes/components/settings-defs.ts +547 -0
- package/src/modes/components/settings-selector.ts +624 -0
- package/src/modes/components/show-images-selector.ts +45 -0
- package/src/modes/components/skill-message.ts +90 -0
- package/src/modes/components/status-line/context-thresholds.ts +68 -0
- package/src/modes/components/status-line/git-utils.ts +42 -0
- package/src/modes/components/status-line/index.ts +4 -0
- package/src/modes/components/status-line/presets.ts +94 -0
- package/src/modes/components/status-line/segments.ts +392 -0
- package/src/modes/components/status-line/separators.ts +55 -0
- package/src/modes/components/status-line/token-rate.ts +66 -0
- package/src/modes/components/status-line/types.ts +82 -0
- package/src/modes/components/status-line-segment-editor.ts +358 -0
- package/src/modes/components/status-line.ts +499 -0
- package/src/modes/components/theme-selector.ts +63 -0
- package/src/modes/components/thinking-selector.ts +52 -0
- package/src/modes/components/todo-reminder.ts +47 -0
- package/src/modes/components/tool-execution.ts +697 -0
- package/src/modes/components/tree-selector.ts +908 -0
- package/src/modes/components/ttsr-notification.ts +80 -0
- package/src/modes/components/user-message-selector.ts +141 -0
- package/src/modes/components/user-message.ts +38 -0
- package/src/modes/components/visual-truncate.ts +63 -0
- package/src/modes/components/welcome.ts +248 -0
- package/src/modes/controllers/btw-controller.ts +193 -0
- package/src/modes/controllers/command-controller.ts +1195 -0
- package/src/modes/controllers/event-controller.ts +644 -0
- package/src/modes/controllers/extension-ui-controller.ts +960 -0
- package/src/modes/controllers/input-controller.ts +762 -0
- package/src/modes/controllers/mcp-command-controller.ts +1926 -0
- package/src/modes/controllers/selector-controller.ts +991 -0
- package/src/modes/controllers/ssh-command-controller.ts +421 -0
- package/src/modes/index.ts +34 -0
- package/src/modes/interactive-mode.ts +1664 -0
- package/src/modes/oauth-manual-input.ts +42 -0
- package/src/modes/print-mode.ts +192 -0
- package/src/modes/prompt-action-autocomplete.ts +233 -0
- package/src/modes/rpc/host-tools.ts +186 -0
- package/src/modes/rpc/rpc-client.ts +750 -0
- package/src/modes/rpc/rpc-mode.ts +825 -0
- package/src/modes/rpc/rpc-types.ts +297 -0
- package/src/modes/session-observer-registry.ts +146 -0
- package/src/modes/shared.ts +30 -0
- package/src/modes/theme/dark.json +95 -0
- package/src/modes/theme/defaults/alabaster.json +93 -0
- package/src/modes/theme/defaults/amethyst.json +96 -0
- package/src/modes/theme/defaults/anthracite.json +93 -0
- package/src/modes/theme/defaults/basalt.json +91 -0
- package/src/modes/theme/defaults/birch.json +95 -0
- package/src/modes/theme/defaults/dark-abyss.json +91 -0
- package/src/modes/theme/defaults/dark-arctic.json +104 -0
- package/src/modes/theme/defaults/dark-aurora.json +95 -0
- package/src/modes/theme/defaults/dark-catppuccin.json +107 -0
- package/src/modes/theme/defaults/dark-cavern.json +91 -0
- package/src/modes/theme/defaults/dark-copper.json +95 -0
- package/src/modes/theme/defaults/dark-cosmos.json +90 -0
- package/src/modes/theme/defaults/dark-cyberpunk.json +102 -0
- package/src/modes/theme/defaults/dark-dracula.json +98 -0
- package/src/modes/theme/defaults/dark-eclipse.json +91 -0
- package/src/modes/theme/defaults/dark-ember.json +95 -0
- package/src/modes/theme/defaults/dark-equinox.json +90 -0
- package/src/modes/theme/defaults/dark-forest.json +96 -0
- package/src/modes/theme/defaults/dark-github.json +105 -0
- package/src/modes/theme/defaults/dark-gruvbox.json +112 -0
- package/src/modes/theme/defaults/dark-lavender.json +95 -0
- package/src/modes/theme/defaults/dark-lunar.json +89 -0
- package/src/modes/theme/defaults/dark-midnight.json +95 -0
- package/src/modes/theme/defaults/dark-monochrome.json +94 -0
- package/src/modes/theme/defaults/dark-monokai.json +98 -0
- package/src/modes/theme/defaults/dark-nebula.json +90 -0
- package/src/modes/theme/defaults/dark-nord.json +97 -0
- package/src/modes/theme/defaults/dark-ocean.json +101 -0
- package/src/modes/theme/defaults/dark-one.json +100 -0
- package/src/modes/theme/defaults/dark-poimandres.json +138 -0
- package/src/modes/theme/defaults/dark-rainforest.json +91 -0
- package/src/modes/theme/defaults/dark-reef.json +91 -0
- package/src/modes/theme/defaults/dark-retro.json +92 -0
- package/src/modes/theme/defaults/dark-rose-pine.json +96 -0
- package/src/modes/theme/defaults/dark-sakura.json +95 -0
- package/src/modes/theme/defaults/dark-slate.json +95 -0
- package/src/modes/theme/defaults/dark-solarized.json +97 -0
- package/src/modes/theme/defaults/dark-solstice.json +90 -0
- package/src/modes/theme/defaults/dark-starfall.json +91 -0
- package/src/modes/theme/defaults/dark-sunset.json +99 -0
- package/src/modes/theme/defaults/dark-swamp.json +90 -0
- package/src/modes/theme/defaults/dark-synthwave.json +103 -0
- package/src/modes/theme/defaults/dark-taiga.json +91 -0
- package/src/modes/theme/defaults/dark-terminal.json +95 -0
- package/src/modes/theme/defaults/dark-tokyo-night.json +101 -0
- package/src/modes/theme/defaults/dark-tundra.json +91 -0
- package/src/modes/theme/defaults/dark-twilight.json +91 -0
- package/src/modes/theme/defaults/dark-volcanic.json +91 -0
- package/src/modes/theme/defaults/graphite.json +92 -0
- package/src/modes/theme/defaults/index.ts +203 -0
- package/src/modes/theme/defaults/light-arctic.json +107 -0
- package/src/modes/theme/defaults/light-aurora-day.json +91 -0
- package/src/modes/theme/defaults/light-canyon.json +91 -0
- package/src/modes/theme/defaults/light-catppuccin.json +106 -0
- package/src/modes/theme/defaults/light-cirrus.json +90 -0
- package/src/modes/theme/defaults/light-coral.json +95 -0
- package/src/modes/theme/defaults/light-cyberpunk.json +96 -0
- package/src/modes/theme/defaults/light-dawn.json +90 -0
- package/src/modes/theme/defaults/light-dunes.json +91 -0
- package/src/modes/theme/defaults/light-eucalyptus.json +95 -0
- package/src/modes/theme/defaults/light-forest.json +100 -0
- package/src/modes/theme/defaults/light-frost.json +95 -0
- package/src/modes/theme/defaults/light-github.json +115 -0
- package/src/modes/theme/defaults/light-glacier.json +91 -0
- package/src/modes/theme/defaults/light-gruvbox.json +108 -0
- package/src/modes/theme/defaults/light-haze.json +90 -0
- package/src/modes/theme/defaults/light-honeycomb.json +95 -0
- package/src/modes/theme/defaults/light-lagoon.json +91 -0
- package/src/modes/theme/defaults/light-lavender.json +95 -0
- package/src/modes/theme/defaults/light-meadow.json +91 -0
- package/src/modes/theme/defaults/light-mint.json +95 -0
- package/src/modes/theme/defaults/light-monochrome.json +101 -0
- package/src/modes/theme/defaults/light-ocean.json +99 -0
- package/src/modes/theme/defaults/light-one.json +99 -0
- package/src/modes/theme/defaults/light-opal.json +91 -0
- package/src/modes/theme/defaults/light-orchard.json +91 -0
- package/src/modes/theme/defaults/light-paper.json +95 -0
- package/src/modes/theme/defaults/light-poimandres.json +138 -0
- package/src/modes/theme/defaults/light-prism.json +90 -0
- package/src/modes/theme/defaults/light-retro.json +98 -0
- package/src/modes/theme/defaults/light-sand.json +95 -0
- package/src/modes/theme/defaults/light-savanna.json +91 -0
- package/src/modes/theme/defaults/light-solarized.json +102 -0
- package/src/modes/theme/defaults/light-soleil.json +90 -0
- package/src/modes/theme/defaults/light-sunset.json +99 -0
- package/src/modes/theme/defaults/light-synthwave.json +98 -0
- package/src/modes/theme/defaults/light-tokyo-night.json +111 -0
- package/src/modes/theme/defaults/light-wetland.json +91 -0
- package/src/modes/theme/defaults/light-zenith.json +89 -0
- package/src/modes/theme/defaults/limestone.json +94 -0
- package/src/modes/theme/defaults/mahogany.json +97 -0
- package/src/modes/theme/defaults/marble.json +93 -0
- package/src/modes/theme/defaults/obsidian.json +91 -0
- package/src/modes/theme/defaults/onyx.json +91 -0
- package/src/modes/theme/defaults/pearl.json +93 -0
- package/src/modes/theme/defaults/porcelain.json +91 -0
- package/src/modes/theme/defaults/quartz.json +96 -0
- package/src/modes/theme/defaults/sandstone.json +95 -0
- package/src/modes/theme/defaults/titanium.json +90 -0
- package/src/modes/theme/defaults/xcsh-dark.json +89 -0
- package/src/modes/theme/defaults/xcsh-light.json +91 -0
- package/src/modes/theme/light.json +93 -0
- package/src/modes/theme/mermaid-cache.ts +70 -0
- package/src/modes/theme/theme-schema.json +429 -0
- package/src/modes/theme/theme.ts +2541 -0
- package/src/modes/types.ts +269 -0
- package/src/modes/utils/hotkeys-markdown.ts +59 -0
- package/src/modes/utils/keybinding-matchers.ts +30 -0
- package/src/modes/utils/tools-markdown.ts +27 -0
- package/src/modes/utils/ui-helpers.ts +620 -0
- package/src/plan-mode/approved-plan.ts +55 -0
- package/src/plan-mode/state.ts +6 -0
- package/src/priority.json +29 -0
- package/src/prompts/agents/designer.md +68 -0
- package/src/prompts/agents/explore.md +60 -0
- package/src/prompts/agents/frontmatter.md +10 -0
- package/src/prompts/agents/init.md +36 -0
- package/src/prompts/agents/librarian.md +121 -0
- package/src/prompts/agents/plan.md +49 -0
- package/src/prompts/agents/reviewer.md +127 -0
- package/src/prompts/agents/task.md +16 -0
- package/src/prompts/ci-green-request.md +36 -0
- package/src/prompts/compaction/branch-summary-context.md +5 -0
- package/src/prompts/compaction/branch-summary-preamble.md +2 -0
- package/src/prompts/compaction/branch-summary.md +30 -0
- package/src/prompts/compaction/compaction-short-summary.md +9 -0
- package/src/prompts/compaction/compaction-summary-context.md +5 -0
- package/src/prompts/compaction/compaction-summary.md +38 -0
- package/src/prompts/compaction/compaction-turn-prefix.md +17 -0
- package/src/prompts/compaction/compaction-update-summary.md +45 -0
- package/src/prompts/memories/consolidation.md +30 -0
- package/src/prompts/memories/read-path.md +11 -0
- package/src/prompts/memories/stage_one_input.md +6 -0
- package/src/prompts/memories/stage_one_system.md +21 -0
- package/src/prompts/review-request.md +64 -0
- package/src/prompts/system/agent-creation-architect.md +65 -0
- package/src/prompts/system/agent-creation-user.md +6 -0
- package/src/prompts/system/auto-handoff-threshold-focus.md +1 -0
- package/src/prompts/system/btw-user.md +8 -0
- package/src/prompts/system/commit-message-system.md +2 -0
- package/src/prompts/system/custom-system-prompt.md +68 -0
- package/src/prompts/system/eager-todo.md +13 -0
- package/src/prompts/system/file-operations.md +10 -0
- package/src/prompts/system/handoff-document.md +46 -0
- package/src/prompts/system/plan-mode-active.md +107 -0
- package/src/prompts/system/plan-mode-approved.md +23 -0
- package/src/prompts/system/plan-mode-reference.md +14 -0
- package/src/prompts/system/plan-mode-subagent.md +34 -0
- package/src/prompts/system/plan-mode-tool-decision-reminder.md +9 -0
- package/src/prompts/system/subagent-submit-reminder.md +11 -0
- package/src/prompts/system/subagent-system-prompt.md +35 -0
- package/src/prompts/system/subagent-user-prompt.md +12 -0
- package/src/prompts/system/summarization-system.md +3 -0
- package/src/prompts/system/system-prompt.md +333 -0
- package/src/prompts/system/title-system.md +2 -0
- package/src/prompts/system/ttsr-interrupt.md +7 -0
- package/src/prompts/system/web-search.md +28 -0
- package/src/prompts/tools/ask.md +28 -0
- package/src/prompts/tools/ast-edit.md +48 -0
- package/src/prompts/tools/ast-grep.md +54 -0
- package/src/prompts/tools/async-result.md +5 -0
- package/src/prompts/tools/await.md +5 -0
- package/src/prompts/tools/bash.md +47 -0
- package/src/prompts/tools/browser.md +24 -0
- package/src/prompts/tools/calculator.md +10 -0
- package/src/prompts/tools/cancel-job.md +5 -0
- package/src/prompts/tools/checkpoint.md +16 -0
- package/src/prompts/tools/chunk-edit.md +219 -0
- package/src/prompts/tools/debug.md +43 -0
- package/src/prompts/tools/exit-plan-mode.md +41 -0
- package/src/prompts/tools/find.md +26 -0
- package/src/prompts/tools/gemini-image.md +7 -0
- package/src/prompts/tools/gh-issue-view.md +11 -0
- package/src/prompts/tools/gh-pr-checkout.md +12 -0
- package/src/prompts/tools/gh-pr-diff.md +12 -0
- package/src/prompts/tools/gh-pr-push.md +11 -0
- package/src/prompts/tools/gh-pr-view.md +11 -0
- package/src/prompts/tools/gh-repo-view.md +11 -0
- package/src/prompts/tools/gh-run-watch.md +12 -0
- package/src/prompts/tools/gh-search-issues.md +11 -0
- package/src/prompts/tools/gh-search-prs.md +11 -0
- package/src/prompts/tools/grep.md +29 -0
- package/src/prompts/tools/hashline.md +131 -0
- package/src/prompts/tools/inspect-image-system.md +20 -0
- package/src/prompts/tools/inspect-image.md +32 -0
- package/src/prompts/tools/lsp.md +33 -0
- package/src/prompts/tools/patch.md +72 -0
- package/src/prompts/tools/python.md +60 -0
- package/src/prompts/tools/read-chunk.md +17 -0
- package/src/prompts/tools/read.md +54 -0
- package/src/prompts/tools/render-mermaid.md +9 -0
- package/src/prompts/tools/replace.md +36 -0
- package/src/prompts/tools/resolve.md +8 -0
- package/src/prompts/tools/rewind.md +13 -0
- package/src/prompts/tools/search-tool-bm25.md +34 -0
- package/src/prompts/tools/ssh.md +44 -0
- package/src/prompts/tools/task-summary.md +28 -0
- package/src/prompts/tools/task.md +131 -0
- package/src/prompts/tools/todo-write.md +89 -0
- package/src/prompts/tools/web-search.md +10 -0
- package/src/prompts/tools/write.md +13 -0
- package/src/sdk.ts +1694 -0
- package/src/secrets/index.ts +116 -0
- package/src/secrets/obfuscator.ts +277 -0
- package/src/secrets/regex.ts +21 -0
- package/src/session/agent-session.ts +6506 -0
- package/src/session/agent-storage.ts +451 -0
- package/src/session/artifacts.ts +132 -0
- package/src/session/auth-storage.ts +17 -0
- package/src/session/blob-store.ts +135 -0
- package/src/session/compaction/branch-summarization.ts +322 -0
- package/src/session/compaction/compaction.ts +1388 -0
- package/src/session/compaction/index.ts +7 -0
- package/src/session/compaction/pruning.ts +91 -0
- package/src/session/compaction/utils.ts +184 -0
- package/src/session/history-storage.ts +253 -0
- package/src/session/messages.ts +373 -0
- package/src/session/session-dump-format.ts +203 -0
- package/src/session/session-manager.ts +2728 -0
- package/src/session/session-storage.ts +367 -0
- package/src/session/streaming-output.ts +752 -0
- package/src/session/tool-choice-queue.ts +213 -0
- package/src/slash-commands/builtin-registry.ts +981 -0
- package/src/slash-commands/marketplace-install-parser.ts +99 -0
- package/src/ssh/config-writer.ts +183 -0
- package/src/ssh/connection-manager.ts +445 -0
- package/src/ssh/ssh-executor.ts +128 -0
- package/src/ssh/sshfs-mount.ts +137 -0
- package/src/ssh/utils.ts +8 -0
- package/src/stt/downloader.ts +71 -0
- package/src/stt/index.ts +3 -0
- package/src/stt/recorder.ts +351 -0
- package/src/stt/setup.ts +52 -0
- package/src/stt/stt-controller.ts +160 -0
- package/src/stt/transcribe.py +70 -0
- package/src/stt/transcriber.ts +91 -0
- package/src/system-prompt.ts +620 -0
- package/src/task/agents.ts +166 -0
- package/src/task/commands.ts +131 -0
- package/src/task/discovery.ts +126 -0
- package/src/task/executor.ts +1293 -0
- package/src/task/index.ts +1199 -0
- package/src/task/isolation-backend.ts +72 -0
- package/src/task/name-generator.ts +1577 -0
- package/src/task/output-manager.ts +107 -0
- package/src/task/parallel.ts +116 -0
- package/src/task/render.ts +1021 -0
- package/src/task/subprocess-tool-registry.ts +88 -0
- package/src/task/template.ts +33 -0
- package/src/task/types.ts +230 -0
- package/src/task/worktree.ts +580 -0
- package/src/task/xcsh-command.ts +26 -0
- package/src/thinking.ts +87 -0
- package/src/tools/archive-reader.ts +315 -0
- package/src/tools/ask.ts +795 -0
- package/src/tools/ast-edit.ts +495 -0
- package/src/tools/ast-grep.ts +456 -0
- package/src/tools/auto-generated-guard.ts +305 -0
- package/src/tools/await-tool.ts +170 -0
- package/src/tools/bash-interactive.ts +377 -0
- package/src/tools/bash-interceptor.ts +67 -0
- package/src/tools/bash-normalize.ts +107 -0
- package/src/tools/bash-skill-urls.ts +246 -0
- package/src/tools/bash.ts +600 -0
- package/src/tools/browser.ts +1473 -0
- package/src/tools/calculator.ts +537 -0
- package/src/tools/cancel-job.ts +99 -0
- package/src/tools/checkpoint.ts +133 -0
- package/src/tools/context.ts +39 -0
- package/src/tools/debug.ts +1007 -0
- package/src/tools/exit-plan-mode.ts +101 -0
- package/src/tools/fetch.ts +1463 -0
- package/src/tools/find.ts +495 -0
- package/src/tools/fs-cache-invalidation.ts +33 -0
- package/src/tools/gemini-image.ts +896 -0
- package/src/tools/gh-renderer.ts +305 -0
- package/src/tools/gh.ts +2546 -0
- package/src/tools/grep.ts +625 -0
- package/src/tools/index.ts +426 -0
- package/src/tools/inspect-image-renderer.ts +103 -0
- package/src/tools/inspect-image.ts +173 -0
- package/src/tools/json-tree.ts +243 -0
- package/src/tools/jtd-to-json-schema.ts +199 -0
- package/src/tools/jtd-to-typescript.ts +136 -0
- package/src/tools/jtd-utils.ts +102 -0
- package/src/tools/list-limit.ts +40 -0
- package/src/tools/notebook.ts +288 -0
- package/src/tools/output-meta.ts +588 -0
- package/src/tools/path-utils.ts +560 -0
- package/src/tools/plan-mode-guard.ts +41 -0
- package/src/tools/puppeteer/00_stealth_tampering.txt +63 -0
- package/src/tools/puppeteer/01_stealth_activity.txt +20 -0
- package/src/tools/puppeteer/02_stealth_hairline.txt +11 -0
- package/src/tools/puppeteer/03_stealth_botd.txt +384 -0
- package/src/tools/puppeteer/04_stealth_iframe.txt +81 -0
- package/src/tools/puppeteer/05_stealth_webgl.txt +75 -0
- package/src/tools/puppeteer/06_stealth_screen.txt +72 -0
- package/src/tools/puppeteer/07_stealth_fonts.txt +97 -0
- package/src/tools/puppeteer/08_stealth_audio.txt +51 -0
- package/src/tools/puppeteer/09_stealth_locale.txt +46 -0
- package/src/tools/puppeteer/10_stealth_plugins.txt +206 -0
- package/src/tools/puppeteer/11_stealth_hardware.txt +8 -0
- package/src/tools/puppeteer/12_stealth_codecs.txt +40 -0
- package/src/tools/puppeteer/13_stealth_worker.txt +74 -0
- package/src/tools/python.ts +1135 -0
- package/src/tools/read.ts +1375 -0
- package/src/tools/render-mermaid.ts +71 -0
- package/src/tools/render-utils.ts +618 -0
- package/src/tools/renderers.ts +68 -0
- package/src/tools/report-tool-issue.ts +80 -0
- package/src/tools/resolve.ts +192 -0
- package/src/tools/review.ts +238 -0
- package/src/tools/search-tool-bm25.ts +283 -0
- package/src/tools/ssh.ts +320 -0
- package/src/tools/submit-result.ts +226 -0
- package/src/tools/todo-write.ts +450 -0
- package/src/tools/tool-errors.ts +62 -0
- package/src/tools/tool-result.ts +86 -0
- package/src/tools/tool-timeouts.ts +30 -0
- package/src/tools/write.ts +479 -0
- package/src/tui/code-cell.ts +113 -0
- package/src/tui/file-list.ts +47 -0
- package/src/tui/index.ts +11 -0
- package/src/tui/output-block.ts +150 -0
- package/src/tui/status-line.ts +39 -0
- package/src/tui/tree-list.ts +84 -0
- package/src/tui/types.ts +15 -0
- package/src/tui/utils.ts +103 -0
- package/src/utils/changelog.ts +98 -0
- package/src/utils/clipboard.ts +80 -0
- package/src/utils/command-args.ts +76 -0
- package/src/utils/commit-message-generator.ts +136 -0
- package/src/utils/edit-mode.ts +49 -0
- package/src/utils/event-bus.ts +33 -0
- package/src/utils/external-editor.ts +65 -0
- package/src/utils/file-display-mode.ts +37 -0
- package/src/utils/file-mentions.ts +376 -0
- package/src/utils/fuzzy.ts +108 -0
- package/src/utils/git.ts +1400 -0
- package/src/utils/image-convert.ts +27 -0
- package/src/utils/image-loading.ts +98 -0
- package/src/utils/image-resize.ts +236 -0
- package/src/utils/markit.ts +81 -0
- package/src/utils/open.ts +20 -0
- package/src/utils/shell-snapshot.ts +188 -0
- package/src/utils/sixel.ts +69 -0
- package/src/utils/title-generator.ts +184 -0
- package/src/utils/tool-choice.ts +28 -0
- package/src/utils/tools-manager.ts +356 -0
- package/src/web/kagi.ts +174 -0
- package/src/web/parallel.ts +346 -0
- package/src/web/scrapers/artifacthub.ts +207 -0
- package/src/web/scrapers/arxiv.ts +83 -0
- package/src/web/scrapers/aur.ts +162 -0
- package/src/web/scrapers/biorxiv.ts +133 -0
- package/src/web/scrapers/bluesky.ts +262 -0
- package/src/web/scrapers/brew.ts +172 -0
- package/src/web/scrapers/cheatsh.ts +68 -0
- package/src/web/scrapers/chocolatey.ts +196 -0
- package/src/web/scrapers/choosealicense.ts +95 -0
- package/src/web/scrapers/cisa-kev.ts +87 -0
- package/src/web/scrapers/clojars.ts +154 -0
- package/src/web/scrapers/coingecko.ts +177 -0
- package/src/web/scrapers/crates-io.ts +110 -0
- package/src/web/scrapers/crossref.ts +136 -0
- package/src/web/scrapers/devto.ts +147 -0
- package/src/web/scrapers/discogs.ts +306 -0
- package/src/web/scrapers/discourse.ts +197 -0
- package/src/web/scrapers/dockerhub.ts +138 -0
- package/src/web/scrapers/docs-rs.ts +653 -0
- package/src/web/scrapers/fdroid.ts +134 -0
- package/src/web/scrapers/firefox-addons.ts +191 -0
- package/src/web/scrapers/flathub.ts +223 -0
- package/src/web/scrapers/github-gist.ts +58 -0
- package/src/web/scrapers/github.ts +452 -0
- package/src/web/scrapers/gitlab.ts +401 -0
- package/src/web/scrapers/go-pkg.ts +266 -0
- package/src/web/scrapers/hackage.ts +140 -0
- package/src/web/scrapers/hackernews.ts +189 -0
- package/src/web/scrapers/hex.ts +105 -0
- package/src/web/scrapers/huggingface.ts +321 -0
- package/src/web/scrapers/iacr.ts +89 -0
- package/src/web/scrapers/index.ts +252 -0
- package/src/web/scrapers/jetbrains-marketplace.ts +159 -0
- package/src/web/scrapers/lemmy.ts +203 -0
- package/src/web/scrapers/lobsters.ts +175 -0
- package/src/web/scrapers/mastodon.ts +292 -0
- package/src/web/scrapers/maven.ts +138 -0
- package/src/web/scrapers/mdn.ts +169 -0
- package/src/web/scrapers/metacpan.ts +222 -0
- package/src/web/scrapers/musicbrainz.ts +250 -0
- package/src/web/scrapers/npm.ts +98 -0
- package/src/web/scrapers/nuget.ts +183 -0
- package/src/web/scrapers/nvd.ts +222 -0
- package/src/web/scrapers/ollama.ts +239 -0
- package/src/web/scrapers/open-vsx.ts +106 -0
- package/src/web/scrapers/opencorporates.ts +292 -0
- package/src/web/scrapers/openlibrary.ts +336 -0
- package/src/web/scrapers/orcid.ts +286 -0
- package/src/web/scrapers/osv.ts +176 -0
- package/src/web/scrapers/packagist.ts +160 -0
- package/src/web/scrapers/pub-dev.ts +143 -0
- package/src/web/scrapers/pubmed.ts +211 -0
- package/src/web/scrapers/pypi.ts +112 -0
- package/src/web/scrapers/rawg.ts +110 -0
- package/src/web/scrapers/readthedocs.ts +120 -0
- package/src/web/scrapers/reddit.ts +95 -0
- package/src/web/scrapers/repology.ts +251 -0
- package/src/web/scrapers/rfc.ts +201 -0
- package/src/web/scrapers/rubygems.ts +103 -0
- package/src/web/scrapers/searchcode.ts +190 -0
- package/src/web/scrapers/sec-edgar.ts +261 -0
- package/src/web/scrapers/semantic-scholar.ts +171 -0
- package/src/web/scrapers/snapcraft.ts +187 -0
- package/src/web/scrapers/sourcegraph.ts +336 -0
- package/src/web/scrapers/spdx.ts +108 -0
- package/src/web/scrapers/spotify.ts +198 -0
- package/src/web/scrapers/stackoverflow.ts +120 -0
- package/src/web/scrapers/terraform.ts +277 -0
- package/src/web/scrapers/tldr.ts +47 -0
- package/src/web/scrapers/twitter.ts +93 -0
- package/src/web/scrapers/types.ts +267 -0
- package/src/web/scrapers/utils.ts +109 -0
- package/src/web/scrapers/vimeo.ts +133 -0
- package/src/web/scrapers/vscode-marketplace.ts +187 -0
- package/src/web/scrapers/w3c.ts +156 -0
- package/src/web/scrapers/wikidata.ts +344 -0
- package/src/web/scrapers/wikipedia.ts +84 -0
- package/src/web/scrapers/youtube.ts +313 -0
- package/src/web/search/index.ts +268 -0
- package/src/web/search/provider.ts +86 -0
- package/src/web/search/providers/anthropic.ts +286 -0
- package/src/web/search/providers/base.ts +25 -0
- package/src/web/search/providers/brave.ts +150 -0
- package/src/web/search/providers/codex.ts +383 -0
- package/src/web/search/providers/exa.ts +264 -0
- package/src/web/search/providers/gemini.ts +566 -0
- package/src/web/search/providers/jina.ts +99 -0
- package/src/web/search/providers/kagi.ts +70 -0
- package/src/web/search/providers/kimi.ts +157 -0
- package/src/web/search/providers/parallel.ts +63 -0
- package/src/web/search/providers/perplexity.ts +546 -0
- package/src/web/search/providers/synthetic.ts +113 -0
- package/src/web/search/providers/tavily.ts +162 -0
- package/src/web/search/providers/utils.ts +36 -0
- package/src/web/search/providers/zai.ts +311 -0
- package/src/web/search/render.ts +299 -0
- package/src/web/search/types.ts +434 -0
- package/src/web/search/utils.ts +17 -0
- package/dist/bun/cli.d.ts +0 -3
- package/dist/bun/cli.d.ts.map +0 -1
- package/dist/bun/cli.js +0 -7
- package/dist/bun/cli.js.map +0 -1
- package/dist/bun/register-bedrock.d.ts +0 -2
- package/dist/bun/register-bedrock.d.ts.map +0 -1
- package/dist/bun/register-bedrock.js +0 -4
- package/dist/bun/register-bedrock.js.map +0 -1
- package/dist/cli/args.d.ts +0 -52
- package/dist/cli/args.d.ts.map +0 -1
- package/dist/cli/args.js +0 -326
- package/dist/cli/args.js.map +0 -1
- package/dist/cli/config-selector.d.ts +0 -14
- package/dist/cli/config-selector.d.ts.map +0 -1
- package/dist/cli/config-selector.js +0 -31
- package/dist/cli/config-selector.js.map +0 -1
- package/dist/cli/file-processor.d.ts +0 -15
- package/dist/cli/file-processor.d.ts.map +0 -1
- package/dist/cli/file-processor.js +0 -83
- package/dist/cli/file-processor.js.map +0 -1
- package/dist/cli/initial-message.d.ts +0 -18
- package/dist/cli/initial-message.d.ts.map +0 -1
- package/dist/cli/initial-message.js +0 -22
- package/dist/cli/initial-message.js.map +0 -1
- package/dist/cli/list-models.d.ts +0 -9
- package/dist/cli/list-models.d.ts.map +0 -1
- package/dist/cli/list-models.js +0 -92
- package/dist/cli/list-models.js.map +0 -1
- package/dist/cli/session-picker.d.ts +0 -9
- package/dist/cli/session-picker.d.ts.map +0 -1
- package/dist/cli/session-picker.js +0 -35
- package/dist/cli/session-picker.js.map +0 -1
- package/dist/cli.d.ts +0 -3
- package/dist/cli.d.ts.map +0 -1
- package/dist/cli.js +0 -14
- package/dist/cli.js.map +0 -1
- package/dist/config.d.ts +0 -68
- package/dist/config.d.ts.map +0 -1
- package/dist/config.js +0 -203
- package/dist/config.js.map +0 -1
- package/dist/core/agent-session-runtime.d.ts +0 -83
- package/dist/core/agent-session-runtime.d.ts.map +0 -1
- package/dist/core/agent-session-runtime.js +0 -236
- package/dist/core/agent-session-runtime.js.map +0 -1
- package/dist/core/agent-session-services.d.ts +0 -86
- package/dist/core/agent-session-services.d.ts.map +0 -1
- package/dist/core/agent-session-services.js +0 -116
- package/dist/core/agent-session-services.js.map +0 -1
- package/dist/core/agent-session.d.ts +0 -585
- package/dist/core/agent-session.d.ts.map +0 -1
- package/dist/core/agent-session.js +0 -2497
- package/dist/core/agent-session.js.map +0 -1
- package/dist/core/auth-storage.d.ts +0 -132
- package/dist/core/auth-storage.d.ts.map +0 -1
- package/dist/core/auth-storage.js +0 -422
- package/dist/core/auth-storage.js.map +0 -1
- package/dist/core/bash-executor.d.ts +0 -46
- package/dist/core/bash-executor.d.ts.map +0 -1
- package/dist/core/bash-executor.js +0 -125
- package/dist/core/bash-executor.js.map +0 -1
- package/dist/core/compaction/branch-summarization.d.ts +0 -88
- package/dist/core/compaction/branch-summarization.d.ts.map +0 -1
- package/dist/core/compaction/branch-summarization.js +0 -243
- package/dist/core/compaction/branch-summarization.js.map +0 -1
- package/dist/core/compaction/compaction.d.ts +0 -121
- package/dist/core/compaction/compaction.d.ts.map +0 -1
- package/dist/core/compaction/compaction.js +0 -613
- package/dist/core/compaction/compaction.js.map +0 -1
- package/dist/core/compaction/index.d.ts +0 -7
- package/dist/core/compaction/index.d.ts.map +0 -1
- package/dist/core/compaction/index.js +0 -7
- package/dist/core/compaction/index.js.map +0 -1
- package/dist/core/compaction/utils.d.ts +0 -38
- package/dist/core/compaction/utils.d.ts.map +0 -1
- package/dist/core/compaction/utils.js +0 -153
- package/dist/core/compaction/utils.js.map +0 -1
- package/dist/core/defaults.d.ts +0 -3
- package/dist/core/defaults.d.ts.map +0 -1
- package/dist/core/defaults.js +0 -2
- package/dist/core/defaults.js.map +0 -1
- package/dist/core/diagnostics.d.ts +0 -15
- package/dist/core/diagnostics.d.ts.map +0 -1
- package/dist/core/diagnostics.js +0 -2
- package/dist/core/diagnostics.js.map +0 -1
- package/dist/core/event-bus.d.ts +0 -9
- package/dist/core/event-bus.d.ts.map +0 -1
- package/dist/core/event-bus.js +0 -25
- package/dist/core/event-bus.js.map +0 -1
- package/dist/core/exec.d.ts +0 -29
- package/dist/core/exec.d.ts.map +0 -1
- package/dist/core/exec.js +0 -75
- package/dist/core/exec.js.map +0 -1
- package/dist/core/export-html/ansi-to-html.d.ts +0 -22
- package/dist/core/export-html/ansi-to-html.d.ts.map +0 -1
- package/dist/core/export-html/ansi-to-html.js +0 -249
- package/dist/core/export-html/ansi-to-html.js.map +0 -1
- package/dist/core/export-html/index.d.ts +0 -37
- package/dist/core/export-html/index.d.ts.map +0 -1
- package/dist/core/export-html/index.js +0 -224
- package/dist/core/export-html/index.js.map +0 -1
- package/dist/core/export-html/template.css +0 -1001
- package/dist/core/export-html/template.html +0 -55
- package/dist/core/export-html/template.js +0 -1690
- package/dist/core/export-html/tool-renderer.d.ts +0 -40
- package/dist/core/export-html/tool-renderer.d.ts.map +0 -1
- package/dist/core/export-html/tool-renderer.js +0 -95
- package/dist/core/export-html/tool-renderer.js.map +0 -1
- package/dist/core/extensions/index.d.ts +0 -12
- package/dist/core/extensions/index.d.ts.map +0 -1
- package/dist/core/extensions/index.js +0 -9
- package/dist/core/extensions/index.js.map +0 -1
- package/dist/core/extensions/loader.d.ts +0 -25
- package/dist/core/extensions/loader.d.ts.map +0 -1
- package/dist/core/extensions/loader.js +0 -436
- package/dist/core/extensions/loader.js.map +0 -1
- package/dist/core/extensions/runner.d.ts +0 -148
- package/dist/core/extensions/runner.d.ts.map +0 -1
- package/dist/core/extensions/runner.js +0 -700
- package/dist/core/extensions/runner.js.map +0 -1
- package/dist/core/extensions/types.d.ts +0 -1073
- package/dist/core/extensions/types.d.ts.map +0 -1
- package/dist/core/extensions/types.js +0 -45
- package/dist/core/extensions/types.js.map +0 -1
- package/dist/core/extensions/wrapper.d.ts +0 -20
- package/dist/core/extensions/wrapper.d.ts.map +0 -1
- package/dist/core/extensions/wrapper.js +0 -22
- package/dist/core/extensions/wrapper.js.map +0 -1
- package/dist/core/footer-data-provider.d.ts +0 -48
- package/dist/core/footer-data-provider.d.ts.map +0 -1
- package/dist/core/footer-data-provider.js +0 -314
- package/dist/core/footer-data-provider.js.map +0 -1
- package/dist/core/index.d.ts +0 -12
- package/dist/core/index.d.ts.map +0 -1
- package/dist/core/index.js +0 -12
- package/dist/core/index.js.map +0 -1
- package/dist/core/keybindings.d.ts +0 -288
- package/dist/core/keybindings.d.ts.map +0 -1
- package/dist/core/keybindings.js +0 -240
- package/dist/core/keybindings.js.map +0 -1
- package/dist/core/messages.d.ts +0 -77
- package/dist/core/messages.d.ts.map +0 -1
- package/dist/core/messages.js +0 -123
- package/dist/core/messages.js.map +0 -1
- package/dist/core/model-registry.d.ts +0 -132
- package/dist/core/model-registry.d.ts.map +0 -1
- package/dist/core/model-registry.js +0 -583
- package/dist/core/model-registry.js.map +0 -1
- package/dist/core/model-resolver.d.ts +0 -110
- package/dist/core/model-resolver.d.ts.map +0 -1
- package/dist/core/model-resolver.js +0 -486
- package/dist/core/model-resolver.js.map +0 -1
- package/dist/core/output-guard.d.ts +0 -6
- package/dist/core/output-guard.d.ts.map +0 -1
- package/dist/core/output-guard.js +0 -59
- package/dist/core/output-guard.js.map +0 -1
- package/dist/core/package-manager.d.ts +0 -192
- package/dist/core/package-manager.d.ts.map +0 -1
- package/dist/core/package-manager.js +0 -1832
- package/dist/core/package-manager.js.map +0 -1
- package/dist/core/prompt-templates.d.ts +0 -51
- package/dist/core/prompt-templates.d.ts.map +0 -1
- package/dist/core/prompt-templates.js +0 -249
- package/dist/core/prompt-templates.js.map +0 -1
- package/dist/core/resolve-config-value.d.ts +0 -23
- package/dist/core/resolve-config-value.d.ts.map +0 -1
- package/dist/core/resolve-config-value.js +0 -126
- package/dist/core/resolve-config-value.js.map +0 -1
- package/dist/core/resource-loader.d.ts +0 -185
- package/dist/core/resource-loader.d.ts.map +0 -1
- package/dist/core/resource-loader.js +0 -720
- package/dist/core/resource-loader.js.map +0 -1
- package/dist/core/sdk.d.ts +0 -93
- package/dist/core/sdk.d.ts.map +0 -1
- package/dist/core/sdk.js +0 -236
- package/dist/core/sdk.js.map +0 -1
- package/dist/core/session-cwd.d.ts +0 -19
- package/dist/core/session-cwd.d.ts.map +0 -1
- package/dist/core/session-cwd.js +0 -38
- package/dist/core/session-cwd.js.map +0 -1
- package/dist/core/session-manager.d.ts +0 -333
- package/dist/core/session-manager.d.ts.map +0 -1
- package/dist/core/session-manager.js +0 -1105
- package/dist/core/session-manager.js.map +0 -1
- package/dist/core/settings-manager.d.ts +0 -237
- package/dist/core/settings-manager.d.ts.map +0 -1
- package/dist/core/settings-manager.js +0 -703
- package/dist/core/settings-manager.js.map +0 -1
- package/dist/core/skills.d.ts +0 -60
- package/dist/core/skills.d.ts.map +0 -1
- package/dist/core/skills.js +0 -409
- package/dist/core/skills.js.map +0 -1
- package/dist/core/slash-commands.d.ts +0 -14
- package/dist/core/slash-commands.d.ts.map +0 -1
- package/dist/core/slash-commands.js +0 -23
- package/dist/core/slash-commands.js.map +0 -1
- package/dist/core/source-info.d.ts +0 -18
- package/dist/core/source-info.d.ts.map +0 -1
- package/dist/core/source-info.js +0 -19
- package/dist/core/source-info.js.map +0 -1
- package/dist/core/system-prompt.d.ts +0 -28
- package/dist/core/system-prompt.d.ts.map +0 -1
- package/dist/core/system-prompt.js +0 -116
- package/dist/core/system-prompt.js.map +0 -1
- package/dist/core/timings.d.ts +0 -8
- package/dist/core/timings.d.ts.map +0 -1
- package/dist/core/timings.js +0 -31
- package/dist/core/timings.js.map +0 -1
- package/dist/core/tools/bash.d.ts +0 -73
- package/dist/core/tools/bash.d.ts.map +0 -1
- package/dist/core/tools/bash.js +0 -352
- package/dist/core/tools/bash.js.map +0 -1
- package/dist/core/tools/edit-diff.d.ts +0 -85
- package/dist/core/tools/edit-diff.d.ts.map +0 -1
- package/dist/core/tools/edit-diff.js +0 -337
- package/dist/core/tools/edit-diff.js.map +0 -1
- package/dist/core/tools/edit.d.ts +0 -53
- package/dist/core/tools/edit.d.ts.map +0 -1
- package/dist/core/tools/edit.js +0 -196
- package/dist/core/tools/edit.js.map +0 -1
- package/dist/core/tools/file-mutation-queue.d.ts +0 -6
- package/dist/core/tools/file-mutation-queue.d.ts.map +0 -1
- package/dist/core/tools/file-mutation-queue.js +0 -37
- package/dist/core/tools/file-mutation-queue.js.map +0 -1
- package/dist/core/tools/find.d.ts +0 -46
- package/dist/core/tools/find.d.ts.map +0 -1
- package/dist/core/tools/find.js +0 -258
- package/dist/core/tools/find.js.map +0 -1
- package/dist/core/tools/grep.d.ts +0 -56
- package/dist/core/tools/grep.d.ts.map +0 -1
- package/dist/core/tools/grep.js +0 -293
- package/dist/core/tools/grep.js.map +0 -1
- package/dist/core/tools/index.d.ts +0 -115
- package/dist/core/tools/index.d.ts.map +0 -1
- package/dist/core/tools/index.js +0 -86
- package/dist/core/tools/index.js.map +0 -1
- package/dist/core/tools/ls.d.ts +0 -46
- package/dist/core/tools/ls.d.ts.map +0 -1
- package/dist/core/tools/ls.js +0 -172
- package/dist/core/tools/ls.js.map +0 -1
- package/dist/core/tools/path-utils.d.ts +0 -8
- package/dist/core/tools/path-utils.d.ts.map +0 -1
- package/dist/core/tools/path-utils.js +0 -81
- package/dist/core/tools/path-utils.js.map +0 -1
- package/dist/core/tools/read.d.ts +0 -46
- package/dist/core/tools/read.d.ts.map +0 -1
- package/dist/core/tools/read.js +0 -225
- package/dist/core/tools/read.js.map +0 -1
- package/dist/core/tools/render-utils.d.ts +0 -21
- package/dist/core/tools/render-utils.d.ts.map +0 -1
- package/dist/core/tools/render-utils.js +0 -49
- package/dist/core/tools/render-utils.js.map +0 -1
- package/dist/core/tools/tool-definition-wrapper.d.ts +0 -14
- package/dist/core/tools/tool-definition-wrapper.d.ts.map +0 -1
- package/dist/core/tools/tool-definition-wrapper.js +0 -32
- package/dist/core/tools/tool-definition-wrapper.js.map +0 -1
- package/dist/core/tools/truncate.d.ts +0 -70
- package/dist/core/tools/truncate.d.ts.map +0 -1
- package/dist/core/tools/truncate.js +0 -205
- package/dist/core/tools/truncate.js.map +0 -1
- package/dist/core/tools/write.d.ts +0 -35
- package/dist/core/tools/write.d.ts.map +0 -1
- package/dist/core/tools/write.js +0 -216
- package/dist/core/tools/write.js.map +0 -1
- package/dist/index.d.ts +0 -28
- package/dist/index.d.ts.map +0 -1
- package/dist/index.js +0 -43
- package/dist/index.js.map +0 -1
- package/dist/main.d.ts +0 -8
- package/dist/main.d.ts.map +0 -1
- package/dist/main.js +0 -593
- package/dist/main.js.map +0 -1
- package/dist/migrations.d.ts +0 -33
- package/dist/migrations.d.ts.map +0 -1
- package/dist/migrations.js +0 -281
- package/dist/migrations.js.map +0 -1
- package/dist/modes/index.d.ts +0 -9
- package/dist/modes/index.d.ts.map +0 -1
- package/dist/modes/index.js +0 -8
- package/dist/modes/index.js.map +0 -1
- package/dist/modes/interactive/components/armin.d.ts +0 -34
- package/dist/modes/interactive/components/armin.d.ts.map +0 -1
- package/dist/modes/interactive/components/armin.js +0 -333
- package/dist/modes/interactive/components/armin.js.map +0 -1
- package/dist/modes/interactive/components/assistant-message.d.ts +0 -18
- package/dist/modes/interactive/components/assistant-message.d.ts.map +0 -1
- package/dist/modes/interactive/components/assistant-message.js +0 -107
- package/dist/modes/interactive/components/assistant-message.js.map +0 -1
- package/dist/modes/interactive/components/bash-execution.d.ts +0 -34
- package/dist/modes/interactive/components/bash-execution.d.ts.map +0 -1
- package/dist/modes/interactive/components/bash-execution.js +0 -175
- package/dist/modes/interactive/components/bash-execution.js.map +0 -1
- package/dist/modes/interactive/components/bordered-loader.d.ts +0 -16
- package/dist/modes/interactive/components/bordered-loader.d.ts.map +0 -1
- package/dist/modes/interactive/components/bordered-loader.js +0 -51
- package/dist/modes/interactive/components/bordered-loader.js.map +0 -1
- package/dist/modes/interactive/components/branch-summary-message.d.ts +0 -16
- package/dist/modes/interactive/components/branch-summary-message.d.ts.map +0 -1
- package/dist/modes/interactive/components/branch-summary-message.js +0 -44
- package/dist/modes/interactive/components/branch-summary-message.js.map +0 -1
- package/dist/modes/interactive/components/compaction-summary-message.d.ts +0 -16
- package/dist/modes/interactive/components/compaction-summary-message.d.ts.map +0 -1
- package/dist/modes/interactive/components/compaction-summary-message.js +0 -45
- package/dist/modes/interactive/components/compaction-summary-message.js.map +0 -1
- package/dist/modes/interactive/components/config-selector.d.ts +0 -71
- package/dist/modes/interactive/components/config-selector.d.ts.map +0 -1
- package/dist/modes/interactive/components/config-selector.js +0 -479
- package/dist/modes/interactive/components/config-selector.js.map +0 -1
- package/dist/modes/interactive/components/countdown-timer.d.ts +0 -14
- package/dist/modes/interactive/components/countdown-timer.d.ts.map +0 -1
- package/dist/modes/interactive/components/countdown-timer.js +0 -33
- package/dist/modes/interactive/components/countdown-timer.js.map +0 -1
- package/dist/modes/interactive/components/custom-editor.d.ts +0 -21
- package/dist/modes/interactive/components/custom-editor.d.ts.map +0 -1
- package/dist/modes/interactive/components/custom-editor.js +0 -70
- package/dist/modes/interactive/components/custom-editor.js.map +0 -1
- package/dist/modes/interactive/components/custom-message.d.ts +0 -20
- package/dist/modes/interactive/components/custom-message.d.ts.map +0 -1
- package/dist/modes/interactive/components/custom-message.js +0 -79
- package/dist/modes/interactive/components/custom-message.js.map +0 -1
- package/dist/modes/interactive/components/daxnuts.d.ts +0 -23
- package/dist/modes/interactive/components/daxnuts.d.ts.map +0 -1
- package/dist/modes/interactive/components/daxnuts.js +0 -140
- package/dist/modes/interactive/components/daxnuts.js.map +0 -1
- package/dist/modes/interactive/components/diff.d.ts +0 -12
- package/dist/modes/interactive/components/diff.d.ts.map +0 -1
- package/dist/modes/interactive/components/diff.js +0 -133
- package/dist/modes/interactive/components/diff.js.map +0 -1
- package/dist/modes/interactive/components/dynamic-border.d.ts +0 -15
- package/dist/modes/interactive/components/dynamic-border.d.ts.map +0 -1
- package/dist/modes/interactive/components/dynamic-border.js +0 -21
- package/dist/modes/interactive/components/dynamic-border.js.map +0 -1
- package/dist/modes/interactive/components/extension-editor.d.ts +0 -20
- package/dist/modes/interactive/components/extension-editor.d.ts.map +0 -1
- package/dist/modes/interactive/components/extension-editor.js +0 -111
- package/dist/modes/interactive/components/extension-editor.js.map +0 -1
- package/dist/modes/interactive/components/extension-input.d.ts +0 -23
- package/dist/modes/interactive/components/extension-input.d.ts.map +0 -1
- package/dist/modes/interactive/components/extension-input.js +0 -61
- package/dist/modes/interactive/components/extension-input.js.map +0 -1
- package/dist/modes/interactive/components/extension-selector.d.ts +0 -24
- package/dist/modes/interactive/components/extension-selector.d.ts.map +0 -1
- package/dist/modes/interactive/components/extension-selector.js +0 -78
- package/dist/modes/interactive/components/extension-selector.js.map +0 -1
- package/dist/modes/interactive/components/footer.d.ts +0 -27
- package/dist/modes/interactive/components/footer.d.ts.map +0 -1
- package/dist/modes/interactive/components/footer.js +0 -201
- package/dist/modes/interactive/components/footer.js.map +0 -1
- package/dist/modes/interactive/components/index.d.ts +0 -32
- package/dist/modes/interactive/components/index.d.ts.map +0 -1
- package/dist/modes/interactive/components/index.js +0 -33
- package/dist/modes/interactive/components/index.js.map +0 -1
- package/dist/modes/interactive/components/keybinding-hints.d.ts +0 -8
- package/dist/modes/interactive/components/keybinding-hints.d.ts.map +0 -1
- package/dist/modes/interactive/components/keybinding-hints.js +0 -22
- package/dist/modes/interactive/components/keybinding-hints.js.map +0 -1
- package/dist/modes/interactive/components/login-dialog.d.ts +0 -42
- package/dist/modes/interactive/components/login-dialog.d.ts.map +0 -1
- package/dist/modes/interactive/components/login-dialog.js +0 -145
- package/dist/modes/interactive/components/login-dialog.js.map +0 -1
- package/dist/modes/interactive/components/model-selector.d.ts +0 -47
- package/dist/modes/interactive/components/model-selector.d.ts.map +0 -1
- package/dist/modes/interactive/components/model-selector.js +0 -275
- package/dist/modes/interactive/components/model-selector.js.map +0 -1
- package/dist/modes/interactive/components/oauth-selector.d.ts +0 -19
- package/dist/modes/interactive/components/oauth-selector.d.ts.map +0 -1
- package/dist/modes/interactive/components/oauth-selector.js +0 -97
- package/dist/modes/interactive/components/oauth-selector.js.map +0 -1
- package/dist/modes/interactive/components/scoped-models-selector.d.ts +0 -49
- package/dist/modes/interactive/components/scoped-models-selector.d.ts.map +0 -1
- package/dist/modes/interactive/components/scoped-models-selector.js +0 -275
- package/dist/modes/interactive/components/scoped-models-selector.js.map +0 -1
- package/dist/modes/interactive/components/session-selector-search.d.ts +0 -23
- package/dist/modes/interactive/components/session-selector-search.d.ts.map +0 -1
- package/dist/modes/interactive/components/session-selector-search.js +0 -155
- package/dist/modes/interactive/components/session-selector-search.js.map +0 -1
- package/dist/modes/interactive/components/session-selector.d.ts +0 -95
- package/dist/modes/interactive/components/session-selector.d.ts.map +0 -1
- package/dist/modes/interactive/components/session-selector.js +0 -848
- package/dist/modes/interactive/components/session-selector.js.map +0 -1
- package/dist/modes/interactive/components/settings-selector.d.ts +0 -58
- package/dist/modes/interactive/components/settings-selector.d.ts.map +0 -1
- package/dist/modes/interactive/components/settings-selector.js +0 -301
- package/dist/modes/interactive/components/settings-selector.js.map +0 -1
- package/dist/modes/interactive/components/show-images-selector.d.ts +0 -10
- package/dist/modes/interactive/components/show-images-selector.d.ts.map +0 -1
- package/dist/modes/interactive/components/show-images-selector.js +0 -39
- package/dist/modes/interactive/components/show-images-selector.js.map +0 -1
- package/dist/modes/interactive/components/skill-invocation-message.d.ts +0 -17
- package/dist/modes/interactive/components/skill-invocation-message.d.ts.map +0 -1
- package/dist/modes/interactive/components/skill-invocation-message.js +0 -47
- package/dist/modes/interactive/components/skill-invocation-message.js.map +0 -1
- package/dist/modes/interactive/components/theme-selector.d.ts +0 -11
- package/dist/modes/interactive/components/theme-selector.d.ts.map +0 -1
- package/dist/modes/interactive/components/theme-selector.js +0 -50
- package/dist/modes/interactive/components/theme-selector.js.map +0 -1
- package/dist/modes/interactive/components/thinking-selector.d.ts +0 -11
- package/dist/modes/interactive/components/thinking-selector.d.ts.map +0 -1
- package/dist/modes/interactive/components/thinking-selector.js +0 -51
- package/dist/modes/interactive/components/thinking-selector.js.map +0 -1
- package/dist/modes/interactive/components/tool-execution.d.ts +0 -58
- package/dist/modes/interactive/components/tool-execution.d.ts.map +0 -1
- package/dist/modes/interactive/components/tool-execution.js +0 -274
- package/dist/modes/interactive/components/tool-execution.js.map +0 -1
- package/dist/modes/interactive/components/tree-selector.d.ts +0 -89
- package/dist/modes/interactive/components/tree-selector.d.ts.map +0 -1
- package/dist/modes/interactive/components/tree-selector.js +0 -1084
- package/dist/modes/interactive/components/tree-selector.js.map +0 -1
- package/dist/modes/interactive/components/user-message-selector.d.ts +0 -30
- package/dist/modes/interactive/components/user-message-selector.d.ts.map +0 -1
- package/dist/modes/interactive/components/user-message-selector.js +0 -113
- package/dist/modes/interactive/components/user-message-selector.js.map +0 -1
- package/dist/modes/interactive/components/user-message.d.ts +0 -9
- package/dist/modes/interactive/components/user-message.d.ts.map +0 -1
- package/dist/modes/interactive/components/user-message.js +0 -28
- package/dist/modes/interactive/components/user-message.js.map +0 -1
- package/dist/modes/interactive/components/visual-truncate.d.ts +0 -24
- package/dist/modes/interactive/components/visual-truncate.d.ts.map +0 -1
- package/dist/modes/interactive/components/visual-truncate.js +0 -33
- package/dist/modes/interactive/components/visual-truncate.js.map +0 -1
- package/dist/modes/interactive/interactive-mode.d.ts +0 -320
- package/dist/modes/interactive/interactive-mode.d.ts.map +0 -1
- package/dist/modes/interactive/interactive-mode.js +0 -3970
- package/dist/modes/interactive/interactive-mode.js.map +0 -1
- package/dist/modes/interactive/theme/dark.json +0 -85
- package/dist/modes/interactive/theme/light.json +0 -84
- package/dist/modes/interactive/theme/theme-schema.json +0 -335
- package/dist/modes/interactive/theme/theme.d.ts +0 -81
- package/dist/modes/interactive/theme/theme.d.ts.map +0 -1
- package/dist/modes/interactive/theme/theme.js +0 -979
- package/dist/modes/interactive/theme/theme.js.map +0 -1
- package/dist/modes/print-mode.d.ts +0 -28
- package/dist/modes/print-mode.d.ts.map +0 -1
- package/dist/modes/print-mode.js +0 -112
- package/dist/modes/print-mode.js.map +0 -1
- package/dist/modes/rpc/jsonl.d.ts +0 -17
- package/dist/modes/rpc/jsonl.d.ts.map +0 -1
- package/dist/modes/rpc/jsonl.js +0 -49
- package/dist/modes/rpc/jsonl.js.map +0 -1
- package/dist/modes/rpc/rpc-client.d.ts +0 -217
- package/dist/modes/rpc/rpc-client.d.ts.map +0 -1
- package/dist/modes/rpc/rpc-client.js +0 -402
- package/dist/modes/rpc/rpc-client.js.map +0 -1
- package/dist/modes/rpc/rpc-mode.d.ts +0 -20
- package/dist/modes/rpc/rpc-mode.d.ts.map +0 -1
- package/dist/modes/rpc/rpc-mode.js +0 -550
- package/dist/modes/rpc/rpc-mode.js.map +0 -1
- package/dist/modes/rpc/rpc-types.d.ts +0 -408
- package/dist/modes/rpc/rpc-types.d.ts.map +0 -1
- package/dist/modes/rpc/rpc-types.js +0 -8
- package/dist/modes/rpc/rpc-types.js.map +0 -1
- package/dist/package-manager-cli.d.ts +0 -4
- package/dist/package-manager-cli.d.ts.map +0 -1
- package/dist/package-manager-cli.js +0 -234
- package/dist/package-manager-cli.js.map +0 -1
- package/dist/utils/changelog.d.ts +0 -21
- package/dist/utils/changelog.d.ts.map +0 -1
- package/dist/utils/changelog.js +0 -87
- package/dist/utils/changelog.js.map +0 -1
- package/dist/utils/child-process.d.ts +0 -11
- package/dist/utils/child-process.d.ts.map +0 -1
- package/dist/utils/child-process.js +0 -78
- package/dist/utils/child-process.js.map +0 -1
- package/dist/utils/clipboard-image.d.ts +0 -11
- package/dist/utils/clipboard-image.d.ts.map +0 -1
- package/dist/utils/clipboard-image.js +0 -245
- package/dist/utils/clipboard-image.js.map +0 -1
- package/dist/utils/clipboard-native.d.ts +0 -8
- package/dist/utils/clipboard-native.d.ts.map +0 -1
- package/dist/utils/clipboard-native.js +0 -14
- package/dist/utils/clipboard-native.js.map +0 -1
- package/dist/utils/clipboard.d.ts +0 -2
- package/dist/utils/clipboard.d.ts.map +0 -1
- package/dist/utils/clipboard.js +0 -78
- package/dist/utils/clipboard.js.map +0 -1
- package/dist/utils/exif-orientation.d.ts +0 -5
- package/dist/utils/exif-orientation.d.ts.map +0 -1
- package/dist/utils/exif-orientation.js +0 -158
- package/dist/utils/exif-orientation.js.map +0 -1
- package/dist/utils/frontmatter.d.ts +0 -8
- package/dist/utils/frontmatter.d.ts.map +0 -1
- package/dist/utils/frontmatter.js +0 -26
- package/dist/utils/frontmatter.js.map +0 -1
- package/dist/utils/git.d.ts +0 -26
- package/dist/utils/git.d.ts.map +0 -1
- package/dist/utils/git.js +0 -163
- package/dist/utils/git.js.map +0 -1
- package/dist/utils/image-convert.d.ts +0 -9
- package/dist/utils/image-convert.d.ts.map +0 -1
- package/dist/utils/image-convert.js +0 -39
- package/dist/utils/image-convert.js.map +0 -1
- package/dist/utils/image-resize.d.ts +0 -36
- package/dist/utils/image-resize.d.ts.map +0 -1
- package/dist/utils/image-resize.js +0 -137
- package/dist/utils/image-resize.js.map +0 -1
- package/dist/utils/mime.d.ts +0 -2
- package/dist/utils/mime.d.ts.map +0 -1
- package/dist/utils/mime.js +0 -26
- package/dist/utils/mime.js.map +0 -1
- package/dist/utils/paths.d.ts +0 -7
- package/dist/utils/paths.d.ts.map +0 -1
- package/dist/utils/paths.js +0 -19
- package/dist/utils/paths.js.map +0 -1
- package/dist/utils/photon.d.ts +0 -21
- package/dist/utils/photon.d.ts.map +0 -1
- package/dist/utils/photon.js +0 -121
- package/dist/utils/photon.js.map +0 -1
- package/dist/utils/shell.d.ts +0 -26
- package/dist/utils/shell.d.ts.map +0 -1
- package/dist/utils/shell.js +0 -186
- package/dist/utils/shell.js.map +0 -1
- package/dist/utils/sleep.d.ts +0 -5
- package/dist/utils/sleep.d.ts.map +0 -1
- package/dist/utils/sleep.js +0 -17
- package/dist/utils/sleep.js.map +0 -1
- package/dist/utils/tools-manager.d.ts +0 -3
- package/dist/utils/tools-manager.d.ts.map +0 -1
- package/dist/utils/tools-manager.js +0 -252
- package/dist/utils/tools-manager.js.map +0 -1
- package/docs/compaction.md +0 -398
- package/docs/custom-provider.md +0 -597
- package/docs/development.md +0 -72
- package/docs/extensions.md +0 -2288
- package/docs/images/doom-extension.png +0 -0
- package/docs/images/exy.png +0 -0
- package/docs/images/interactive-mode.png +0 -0
- package/docs/images/tree-view.png +0 -0
- package/docs/json.md +0 -84
- package/docs/keybindings.md +0 -175
- package/docs/models.md +0 -349
- package/docs/packages.md +0 -219
- package/docs/prompt-templates.md +0 -67
- package/docs/providers.md +0 -200
- package/docs/rpc.md +0 -1425
- package/docs/sdk.md +0 -1136
- package/docs/session.md +0 -423
- package/docs/settings.md +0 -246
- package/docs/shell-aliases.md +0 -13
- package/docs/skills.md +0 -236
- package/docs/terminal-setup.md +0 -108
- package/docs/termux.md +0 -137
- package/docs/themes.md +0 -296
- package/docs/tmux.md +0 -61
- package/docs/tree.md +0 -239
- package/docs/tui.md +0 -890
- package/docs/windows.md +0 -17
- package/examples/extensions/antigravity-image-gen.ts +0 -418
- package/examples/extensions/auto-commit-on-exit.ts +0 -49
- package/examples/extensions/bash-spawn-hook.ts +0 -30
- package/examples/extensions/bookmark.ts +0 -50
- package/examples/extensions/built-in-tool-renderer.ts +0 -246
- package/examples/extensions/claude-rules.ts +0 -86
- package/examples/extensions/commands.ts +0 -72
- package/examples/extensions/confirm-destructive.ts +0 -59
- package/examples/extensions/custom-compaction.ts +0 -127
- package/examples/extensions/custom-footer.ts +0 -64
- package/examples/extensions/custom-header.ts +0 -73
- package/examples/extensions/custom-provider-anthropic/index.ts +0 -604
- package/examples/extensions/custom-provider-anthropic/package-lock.json +0 -24
- package/examples/extensions/custom-provider-anthropic/package.json +0 -19
- package/examples/extensions/custom-provider-gitlab-duo/index.ts +0 -349
- package/examples/extensions/custom-provider-gitlab-duo/package.json +0 -16
- package/examples/extensions/custom-provider-gitlab-duo/test.ts +0 -82
- package/examples/extensions/custom-provider-qwen-cli/index.ts +0 -345
- package/examples/extensions/custom-provider-qwen-cli/package.json +0 -16
- package/examples/extensions/dirty-repo-guard.ts +0 -56
- package/examples/extensions/doom-overlay/README.md +0 -48
- package/examples/extensions/doom-overlay/doom/build/doom.js +0 -21
- package/examples/extensions/doom-overlay/doom/build/doom.wasm +0 -0
- package/examples/extensions/doom-overlay/doom/build.sh +0 -152
- package/examples/extensions/doom-overlay/doom/doomgeneric_pi.c +0 -72
- package/examples/extensions/doom-overlay/doom-component.ts +0 -132
- package/examples/extensions/doom-overlay/doom-engine.ts +0 -173
- package/examples/extensions/doom-overlay/doom-keys.ts +0 -104
- package/examples/extensions/doom-overlay/index.ts +0 -74
- package/examples/extensions/doom-overlay/wad-finder.ts +0 -51
- package/examples/extensions/dynamic-resources/SKILL.md +0 -8
- package/examples/extensions/dynamic-resources/dynamic.json +0 -79
- package/examples/extensions/dynamic-resources/dynamic.md +0 -5
- package/examples/extensions/dynamic-resources/index.ts +0 -15
- package/examples/extensions/dynamic-tools.ts +0 -74
- package/examples/extensions/event-bus.ts +0 -43
- package/examples/extensions/file-trigger.ts +0 -41
- package/examples/extensions/git-checkpoint.ts +0 -53
- package/examples/extensions/handoff.ts +0 -153
- package/examples/extensions/hidden-thinking-label.ts +0 -53
- package/examples/extensions/inline-bash.ts +0 -94
- package/examples/extensions/input-transform.ts +0 -43
- package/examples/extensions/interactive-shell.ts +0 -196
- package/examples/extensions/mac-system-theme.ts +0 -47
- package/examples/extensions/message-renderer.ts +0 -59
- package/examples/extensions/minimal-mode.ts +0 -426
- package/examples/extensions/modal-editor.ts +0 -85
- package/examples/extensions/model-status.ts +0 -31
- package/examples/extensions/notify.ts +0 -55
- package/examples/extensions/overlay-qa-tests.ts +0 -1348
- package/examples/extensions/overlay-test.ts +0 -150
- package/examples/extensions/permission-gate.ts +0 -34
- package/examples/extensions/plan-mode/README.md +0 -69
- package/examples/extensions/plan-mode/index.ts +0 -340
- package/examples/extensions/plan-mode/utils.ts +0 -168
- package/examples/extensions/preset.ts +0 -403
- package/examples/extensions/protected-paths.ts +0 -30
- package/examples/extensions/provider-payload.ts +0 -14
- package/examples/extensions/qna.ts +0 -122
- package/examples/extensions/question.ts +0 -264
- package/examples/extensions/questionnaire.ts +0 -427
- package/examples/extensions/rainbow-editor.ts +0 -88
- package/examples/extensions/rpc-demo.ts +0 -118
- package/examples/extensions/sandbox/index.ts +0 -321
- package/examples/extensions/sandbox/package-lock.json +0 -92
- package/examples/extensions/sandbox/package.json +0 -19
- package/examples/extensions/send-user-message.ts +0 -97
- package/examples/extensions/session-name.ts +0 -27
- package/examples/extensions/shutdown-command.ts +0 -63
- package/examples/extensions/snake.ts +0 -343
- package/examples/extensions/space-invaders.ts +0 -560
- package/examples/extensions/ssh.ts +0 -220
- package/examples/extensions/status-line.ts +0 -32
- package/examples/extensions/subagent/README.md +0 -181
- package/examples/extensions/subagent/agents/planner.md +0 -37
- package/examples/extensions/subagent/agents/reviewer.md +0 -35
- package/examples/extensions/subagent/agents/scout.md +0 -50
- package/examples/extensions/subagent/agents/worker.md +0 -24
- package/examples/extensions/subagent/agents.ts +0 -126
- package/examples/extensions/subagent/index.ts +0 -986
- package/examples/extensions/subagent/prompts/implement-and-review.md +0 -10
- package/examples/extensions/subagent/prompts/implement.md +0 -10
- package/examples/extensions/subagent/prompts/scout-and-plan.md +0 -9
- package/examples/extensions/summarize.ts +0 -206
- package/examples/extensions/system-prompt-header.ts +0 -17
- package/examples/extensions/timed-confirm.ts +0 -70
- package/examples/extensions/titlebar-spinner.ts +0 -58
- package/examples/extensions/tool-override.ts +0 -144
- package/examples/extensions/trigger-compact.ts +0 -50
- package/examples/extensions/truncated-tool.ts +0 -195
- package/examples/extensions/widget-placement.ts +0 -9
- package/examples/rpc-extension-ui.ts +0 -640
- package/examples/sdk/05-tools.ts +0 -56
- package/examples/sdk/10-settings.ts +0 -51
- package/examples/sdk/12-full-control.ts +0 -81
- package/examples/sdk/13-session-runtime.ts +0 -67
- /package/{dist/core/export-html → src/export/html}/vendor/highlight.min.js +0 -0
- /package/{dist/core/export-html → src/export/html}/vendor/marked.min.js +0 -0
|
@@ -1,1690 +0,0 @@
|
|
|
1
|
-
(function() {
|
|
2
|
-
'use strict';
|
|
3
|
-
|
|
4
|
-
// ============================================================
|
|
5
|
-
// DATA LOADING
|
|
6
|
-
// ============================================================
|
|
7
|
-
|
|
8
|
-
const base64 = document.getElementById('session-data').textContent;
|
|
9
|
-
const binary = atob(base64);
|
|
10
|
-
const bytes = new Uint8Array(binary.length);
|
|
11
|
-
for (let i = 0; i < binary.length; i++) {
|
|
12
|
-
bytes[i] = binary.charCodeAt(i);
|
|
13
|
-
}
|
|
14
|
-
const data = JSON.parse(new TextDecoder('utf-8').decode(bytes));
|
|
15
|
-
const { header, entries, leafId: defaultLeafId, systemPrompt, tools, renderedTools } = data;
|
|
16
|
-
|
|
17
|
-
// ============================================================
|
|
18
|
-
// URL PARAMETER HANDLING
|
|
19
|
-
// ============================================================
|
|
20
|
-
|
|
21
|
-
// Parse URL parameters for deep linking: leafId and targetId
|
|
22
|
-
// Check for injected params (when loaded in iframe via srcdoc) or use window.location
|
|
23
|
-
const injectedParams = document.querySelector('meta[name="pi-url-params"]');
|
|
24
|
-
const searchString = injectedParams ? injectedParams.content : window.location.search.substring(1);
|
|
25
|
-
const urlParams = new URLSearchParams(searchString);
|
|
26
|
-
const urlLeafId = urlParams.get('leafId');
|
|
27
|
-
const urlTargetId = urlParams.get('targetId');
|
|
28
|
-
// Use URL leafId if provided, otherwise fall back to session default
|
|
29
|
-
const leafId = urlLeafId || defaultLeafId;
|
|
30
|
-
|
|
31
|
-
// ============================================================
|
|
32
|
-
// DATA STRUCTURES
|
|
33
|
-
// ============================================================
|
|
34
|
-
|
|
35
|
-
// Entry lookup by ID
|
|
36
|
-
const byId = new Map();
|
|
37
|
-
for (const entry of entries) {
|
|
38
|
-
byId.set(entry.id, entry);
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
// Tool call lookup (toolCallId -> {name, arguments})
|
|
42
|
-
const toolCallMap = new Map();
|
|
43
|
-
for (const entry of entries) {
|
|
44
|
-
if (entry.type === 'message' && entry.message.role === 'assistant') {
|
|
45
|
-
const content = entry.message.content;
|
|
46
|
-
if (Array.isArray(content)) {
|
|
47
|
-
for (const block of content) {
|
|
48
|
-
if (block.type === 'toolCall') {
|
|
49
|
-
toolCallMap.set(block.id, { name: block.name, arguments: block.arguments });
|
|
50
|
-
}
|
|
51
|
-
}
|
|
52
|
-
}
|
|
53
|
-
}
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
// Label lookup (entryId -> label string)
|
|
57
|
-
// Labels are stored in 'label' entries that reference their target via targetId
|
|
58
|
-
const labelMap = new Map();
|
|
59
|
-
for (const entry of entries) {
|
|
60
|
-
if (entry.type === 'label' && entry.targetId && entry.label) {
|
|
61
|
-
labelMap.set(entry.targetId, entry.label);
|
|
62
|
-
}
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
// ============================================================
|
|
66
|
-
// TREE DATA PREPARATION (no DOM, pure data)
|
|
67
|
-
// ============================================================
|
|
68
|
-
|
|
69
|
-
/**
|
|
70
|
-
* Build tree structure from flat entries.
|
|
71
|
-
* Returns array of root nodes, each with { entry, children, label }.
|
|
72
|
-
*/
|
|
73
|
-
function buildTree() {
|
|
74
|
-
const nodeMap = new Map();
|
|
75
|
-
const roots = [];
|
|
76
|
-
|
|
77
|
-
// Create nodes
|
|
78
|
-
for (const entry of entries) {
|
|
79
|
-
nodeMap.set(entry.id, {
|
|
80
|
-
entry,
|
|
81
|
-
children: [],
|
|
82
|
-
label: labelMap.get(entry.id)
|
|
83
|
-
});
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
// Build parent-child relationships
|
|
87
|
-
for (const entry of entries) {
|
|
88
|
-
const node = nodeMap.get(entry.id);
|
|
89
|
-
if (entry.parentId === null || entry.parentId === undefined || entry.parentId === entry.id) {
|
|
90
|
-
roots.push(node);
|
|
91
|
-
} else {
|
|
92
|
-
const parent = nodeMap.get(entry.parentId);
|
|
93
|
-
if (parent) {
|
|
94
|
-
parent.children.push(node);
|
|
95
|
-
} else {
|
|
96
|
-
roots.push(node);
|
|
97
|
-
}
|
|
98
|
-
}
|
|
99
|
-
}
|
|
100
|
-
|
|
101
|
-
// Sort children by timestamp
|
|
102
|
-
function sortChildren(node) {
|
|
103
|
-
node.children.sort((a, b) =>
|
|
104
|
-
new Date(a.entry.timestamp).getTime() - new Date(b.entry.timestamp).getTime()
|
|
105
|
-
);
|
|
106
|
-
node.children.forEach(sortChildren);
|
|
107
|
-
}
|
|
108
|
-
roots.forEach(sortChildren);
|
|
109
|
-
|
|
110
|
-
return roots;
|
|
111
|
-
}
|
|
112
|
-
|
|
113
|
-
/**
|
|
114
|
-
* Build set of entry IDs on path from root to target.
|
|
115
|
-
*/
|
|
116
|
-
function buildActivePathIds(targetId) {
|
|
117
|
-
const ids = new Set();
|
|
118
|
-
let current = byId.get(targetId);
|
|
119
|
-
while (current) {
|
|
120
|
-
ids.add(current.id);
|
|
121
|
-
// Stop if no parent or self-referencing (root)
|
|
122
|
-
if (!current.parentId || current.parentId === current.id) {
|
|
123
|
-
break;
|
|
124
|
-
}
|
|
125
|
-
current = byId.get(current.parentId);
|
|
126
|
-
}
|
|
127
|
-
return ids;
|
|
128
|
-
}
|
|
129
|
-
|
|
130
|
-
/**
|
|
131
|
-
* Get array of entries from root to target (the conversation path).
|
|
132
|
-
*/
|
|
133
|
-
function getPath(targetId) {
|
|
134
|
-
const path = [];
|
|
135
|
-
let current = byId.get(targetId);
|
|
136
|
-
while (current) {
|
|
137
|
-
path.unshift(current);
|
|
138
|
-
// Stop if no parent or self-referencing (root)
|
|
139
|
-
if (!current.parentId || current.parentId === current.id) {
|
|
140
|
-
break;
|
|
141
|
-
}
|
|
142
|
-
current = byId.get(current.parentId);
|
|
143
|
-
}
|
|
144
|
-
return path;
|
|
145
|
-
}
|
|
146
|
-
|
|
147
|
-
// Tree node lookup for finding leaves
|
|
148
|
-
let treeNodeMap = null;
|
|
149
|
-
|
|
150
|
-
/**
|
|
151
|
-
* Find the newest leaf node reachable from a given node.
|
|
152
|
-
* This allows clicking any node in a branch to show the full branch.
|
|
153
|
-
* Children are sorted by timestamp, so the newest is always last.
|
|
154
|
-
*/
|
|
155
|
-
function findNewestLeaf(nodeId) {
|
|
156
|
-
// Build tree node map lazily
|
|
157
|
-
if (!treeNodeMap) {
|
|
158
|
-
treeNodeMap = new Map();
|
|
159
|
-
const tree = buildTree();
|
|
160
|
-
function mapNodes(node) {
|
|
161
|
-
treeNodeMap.set(node.entry.id, node);
|
|
162
|
-
node.children.forEach(mapNodes);
|
|
163
|
-
}
|
|
164
|
-
tree.forEach(mapNodes);
|
|
165
|
-
}
|
|
166
|
-
|
|
167
|
-
const node = treeNodeMap.get(nodeId);
|
|
168
|
-
if (!node) return nodeId;
|
|
169
|
-
|
|
170
|
-
// Follow the newest (last) child at each level
|
|
171
|
-
let current = node;
|
|
172
|
-
while (current.children.length > 0) {
|
|
173
|
-
current = current.children[current.children.length - 1];
|
|
174
|
-
}
|
|
175
|
-
return current.entry.id;
|
|
176
|
-
}
|
|
177
|
-
|
|
178
|
-
/**
|
|
179
|
-
* Flatten tree into list with indentation and connector info.
|
|
180
|
-
* Returns array of { node, indent, showConnector, isLast, gutters, isVirtualRootChild, multipleRoots }.
|
|
181
|
-
* Matches tree-selector.ts logic exactly.
|
|
182
|
-
*/
|
|
183
|
-
function flattenTree(roots, activePathIds) {
|
|
184
|
-
const result = [];
|
|
185
|
-
const multipleRoots = roots.length > 1;
|
|
186
|
-
|
|
187
|
-
// Mark which subtrees contain the active leaf
|
|
188
|
-
const containsActive = new Map();
|
|
189
|
-
function markActive(node) {
|
|
190
|
-
let has = activePathIds.has(node.entry.id);
|
|
191
|
-
for (const child of node.children) {
|
|
192
|
-
if (markActive(child)) has = true;
|
|
193
|
-
}
|
|
194
|
-
containsActive.set(node, has);
|
|
195
|
-
return has;
|
|
196
|
-
}
|
|
197
|
-
roots.forEach(markActive);
|
|
198
|
-
|
|
199
|
-
// Stack: [node, indent, justBranched, showConnector, isLast, gutters, isVirtualRootChild]
|
|
200
|
-
const stack = [];
|
|
201
|
-
|
|
202
|
-
// Add roots (prioritize branch containing active leaf)
|
|
203
|
-
const orderedRoots = [...roots].sort((a, b) =>
|
|
204
|
-
Number(containsActive.get(b)) - Number(containsActive.get(a))
|
|
205
|
-
);
|
|
206
|
-
for (let i = orderedRoots.length - 1; i >= 0; i--) {
|
|
207
|
-
const isLast = i === orderedRoots.length - 1;
|
|
208
|
-
stack.push([orderedRoots[i], multipleRoots ? 1 : 0, multipleRoots, multipleRoots, isLast, [], multipleRoots]);
|
|
209
|
-
}
|
|
210
|
-
|
|
211
|
-
while (stack.length > 0) {
|
|
212
|
-
const [node, indent, justBranched, showConnector, isLast, gutters, isVirtualRootChild] = stack.pop();
|
|
213
|
-
|
|
214
|
-
result.push({ node, indent, showConnector, isLast, gutters, isVirtualRootChild, multipleRoots });
|
|
215
|
-
|
|
216
|
-
const children = node.children;
|
|
217
|
-
const multipleChildren = children.length > 1;
|
|
218
|
-
|
|
219
|
-
// Order children (active branch first)
|
|
220
|
-
const orderedChildren = [...children].sort((a, b) =>
|
|
221
|
-
Number(containsActive.get(b)) - Number(containsActive.get(a))
|
|
222
|
-
);
|
|
223
|
-
|
|
224
|
-
// Calculate child indent (matches tree-selector.ts)
|
|
225
|
-
let childIndent;
|
|
226
|
-
if (multipleChildren) {
|
|
227
|
-
// Parent branches: children get +1
|
|
228
|
-
childIndent = indent + 1;
|
|
229
|
-
} else if (justBranched && indent > 0) {
|
|
230
|
-
// First generation after a branch: +1 for visual grouping
|
|
231
|
-
childIndent = indent + 1;
|
|
232
|
-
} else {
|
|
233
|
-
// Single-child chain: stay flat
|
|
234
|
-
childIndent = indent;
|
|
235
|
-
}
|
|
236
|
-
|
|
237
|
-
// Build gutters for children
|
|
238
|
-
const connectorDisplayed = showConnector && !isVirtualRootChild;
|
|
239
|
-
const currentDisplayIndent = multipleRoots ? Math.max(0, indent - 1) : indent;
|
|
240
|
-
const connectorPosition = Math.max(0, currentDisplayIndent - 1);
|
|
241
|
-
const childGutters = connectorDisplayed
|
|
242
|
-
? [...gutters, { position: connectorPosition, show: !isLast }]
|
|
243
|
-
: gutters;
|
|
244
|
-
|
|
245
|
-
// Add children in reverse order for stack
|
|
246
|
-
for (let i = orderedChildren.length - 1; i >= 0; i--) {
|
|
247
|
-
const childIsLast = i === orderedChildren.length - 1;
|
|
248
|
-
stack.push([orderedChildren[i], childIndent, multipleChildren, multipleChildren, childIsLast, childGutters, false]);
|
|
249
|
-
}
|
|
250
|
-
}
|
|
251
|
-
|
|
252
|
-
return result;
|
|
253
|
-
}
|
|
254
|
-
|
|
255
|
-
/**
|
|
256
|
-
* Build ASCII prefix string for tree node.
|
|
257
|
-
*/
|
|
258
|
-
function buildTreePrefix(flatNode) {
|
|
259
|
-
const { indent, showConnector, isLast, gutters, isVirtualRootChild, multipleRoots } = flatNode;
|
|
260
|
-
const displayIndent = multipleRoots ? Math.max(0, indent - 1) : indent;
|
|
261
|
-
const connector = showConnector && !isVirtualRootChild ? (isLast ? '└─ ' : '├─ ') : '';
|
|
262
|
-
const connectorPosition = connector ? displayIndent - 1 : -1;
|
|
263
|
-
|
|
264
|
-
const totalChars = displayIndent * 3;
|
|
265
|
-
const prefixChars = [];
|
|
266
|
-
for (let i = 0; i < totalChars; i++) {
|
|
267
|
-
const level = Math.floor(i / 3);
|
|
268
|
-
const posInLevel = i % 3;
|
|
269
|
-
|
|
270
|
-
const gutter = gutters.find(g => g.position === level);
|
|
271
|
-
if (gutter) {
|
|
272
|
-
prefixChars.push(posInLevel === 0 ? (gutter.show ? '│' : ' ') : ' ');
|
|
273
|
-
} else if (connector && level === connectorPosition) {
|
|
274
|
-
if (posInLevel === 0) {
|
|
275
|
-
prefixChars.push(isLast ? '└' : '├');
|
|
276
|
-
} else if (posInLevel === 1) {
|
|
277
|
-
prefixChars.push('─');
|
|
278
|
-
} else {
|
|
279
|
-
prefixChars.push(' ');
|
|
280
|
-
}
|
|
281
|
-
} else {
|
|
282
|
-
prefixChars.push(' ');
|
|
283
|
-
}
|
|
284
|
-
}
|
|
285
|
-
return prefixChars.join('');
|
|
286
|
-
}
|
|
287
|
-
|
|
288
|
-
// ============================================================
|
|
289
|
-
// FILTERING (pure data)
|
|
290
|
-
// ============================================================
|
|
291
|
-
|
|
292
|
-
let filterMode = 'default';
|
|
293
|
-
let searchQuery = '';
|
|
294
|
-
|
|
295
|
-
function hasTextContent(content) {
|
|
296
|
-
if (typeof content === 'string') return content.trim().length > 0;
|
|
297
|
-
if (Array.isArray(content)) {
|
|
298
|
-
for (const c of content) {
|
|
299
|
-
if (c.type === 'text' && c.text && c.text.trim().length > 0) return true;
|
|
300
|
-
}
|
|
301
|
-
}
|
|
302
|
-
return false;
|
|
303
|
-
}
|
|
304
|
-
|
|
305
|
-
function extractContent(content) {
|
|
306
|
-
if (typeof content === 'string') return content;
|
|
307
|
-
if (Array.isArray(content)) {
|
|
308
|
-
return content
|
|
309
|
-
.filter(c => c.type === 'text' && c.text)
|
|
310
|
-
.map(c => c.text)
|
|
311
|
-
.join('');
|
|
312
|
-
}
|
|
313
|
-
return '';
|
|
314
|
-
}
|
|
315
|
-
|
|
316
|
-
function getSearchableText(entry, label) {
|
|
317
|
-
const parts = [];
|
|
318
|
-
if (label) parts.push(label);
|
|
319
|
-
|
|
320
|
-
switch (entry.type) {
|
|
321
|
-
case 'message': {
|
|
322
|
-
const msg = entry.message;
|
|
323
|
-
parts.push(msg.role);
|
|
324
|
-
if (msg.content) parts.push(extractContent(msg.content));
|
|
325
|
-
if (msg.role === 'bashExecution' && msg.command) parts.push(msg.command);
|
|
326
|
-
break;
|
|
327
|
-
}
|
|
328
|
-
case 'custom_message':
|
|
329
|
-
parts.push(entry.customType);
|
|
330
|
-
parts.push(typeof entry.content === 'string' ? entry.content : extractContent(entry.content));
|
|
331
|
-
break;
|
|
332
|
-
case 'compaction':
|
|
333
|
-
parts.push('compaction');
|
|
334
|
-
break;
|
|
335
|
-
case 'branch_summary':
|
|
336
|
-
parts.push('branch summary', entry.summary);
|
|
337
|
-
break;
|
|
338
|
-
case 'model_change':
|
|
339
|
-
parts.push('model', entry.modelId);
|
|
340
|
-
break;
|
|
341
|
-
case 'thinking_level_change':
|
|
342
|
-
parts.push('thinking', entry.thinkingLevel);
|
|
343
|
-
break;
|
|
344
|
-
}
|
|
345
|
-
|
|
346
|
-
return parts.join(' ').toLowerCase();
|
|
347
|
-
}
|
|
348
|
-
|
|
349
|
-
/**
|
|
350
|
-
* Filter flat nodes based on current filterMode and searchQuery.
|
|
351
|
-
*/
|
|
352
|
-
function filterNodes(flatNodes, currentLeafId) {
|
|
353
|
-
const searchTokens = searchQuery.toLowerCase().split(/\s+/).filter(Boolean);
|
|
354
|
-
|
|
355
|
-
const filtered = flatNodes.filter(flatNode => {
|
|
356
|
-
const entry = flatNode.node.entry;
|
|
357
|
-
const label = flatNode.node.label;
|
|
358
|
-
const isCurrentLeaf = entry.id === currentLeafId;
|
|
359
|
-
|
|
360
|
-
// Always show current leaf
|
|
361
|
-
if (isCurrentLeaf) return true;
|
|
362
|
-
|
|
363
|
-
// Hide assistant messages with only tool calls (no text) unless error/aborted
|
|
364
|
-
if (entry.type === 'message' && entry.message.role === 'assistant') {
|
|
365
|
-
const msg = entry.message;
|
|
366
|
-
const hasText = hasTextContent(msg.content);
|
|
367
|
-
const isErrorOrAborted = msg.stopReason && msg.stopReason !== 'stop' && msg.stopReason !== 'toolUse';
|
|
368
|
-
if (!hasText && !isErrorOrAborted) return false;
|
|
369
|
-
}
|
|
370
|
-
|
|
371
|
-
// Apply filter mode
|
|
372
|
-
const isSettingsEntry = ['label', 'custom', 'model_change', 'thinking_level_change'].includes(entry.type);
|
|
373
|
-
let passesFilter = true;
|
|
374
|
-
|
|
375
|
-
switch (filterMode) {
|
|
376
|
-
case 'user-only':
|
|
377
|
-
passesFilter = entry.type === 'message' && entry.message.role === 'user';
|
|
378
|
-
break;
|
|
379
|
-
case 'no-tools':
|
|
380
|
-
passesFilter = !isSettingsEntry && !(entry.type === 'message' && entry.message.role === 'toolResult');
|
|
381
|
-
break;
|
|
382
|
-
case 'labeled-only':
|
|
383
|
-
passesFilter = label !== undefined;
|
|
384
|
-
break;
|
|
385
|
-
case 'all':
|
|
386
|
-
passesFilter = true;
|
|
387
|
-
break;
|
|
388
|
-
default: // 'default'
|
|
389
|
-
passesFilter = !isSettingsEntry;
|
|
390
|
-
break;
|
|
391
|
-
}
|
|
392
|
-
|
|
393
|
-
if (!passesFilter) return false;
|
|
394
|
-
|
|
395
|
-
// Apply search filter
|
|
396
|
-
if (searchTokens.length > 0) {
|
|
397
|
-
const nodeText = getSearchableText(entry, label);
|
|
398
|
-
if (!searchTokens.every(t => nodeText.includes(t))) return false;
|
|
399
|
-
}
|
|
400
|
-
|
|
401
|
-
return true;
|
|
402
|
-
});
|
|
403
|
-
|
|
404
|
-
// Recalculate visual structure based on visible tree
|
|
405
|
-
recalculateVisualStructure(filtered, flatNodes);
|
|
406
|
-
|
|
407
|
-
return filtered;
|
|
408
|
-
}
|
|
409
|
-
|
|
410
|
-
/**
|
|
411
|
-
* Recompute indentation/connectors for the filtered view
|
|
412
|
-
*
|
|
413
|
-
* Filtering can hide intermediate entries; descendants attach to the nearest visible ancestor.
|
|
414
|
-
* Keep indentation semantics aligned with flattenTree() so single-child chains don't drift right.
|
|
415
|
-
*/
|
|
416
|
-
function recalculateVisualStructure(filteredNodes, allFlatNodes) {
|
|
417
|
-
if (filteredNodes.length === 0) return;
|
|
418
|
-
|
|
419
|
-
const visibleIds = new Set(filteredNodes.map(n => n.node.entry.id));
|
|
420
|
-
|
|
421
|
-
// Build entry map for parent lookup (using full tree)
|
|
422
|
-
const entryMap = new Map();
|
|
423
|
-
for (const flatNode of allFlatNodes) {
|
|
424
|
-
entryMap.set(flatNode.node.entry.id, flatNode);
|
|
425
|
-
}
|
|
426
|
-
|
|
427
|
-
// Find nearest visible ancestor for a node
|
|
428
|
-
function findVisibleAncestor(nodeId) {
|
|
429
|
-
let currentId = entryMap.get(nodeId)?.node.entry.parentId;
|
|
430
|
-
while (currentId != null) {
|
|
431
|
-
if (visibleIds.has(currentId)) {
|
|
432
|
-
return currentId;
|
|
433
|
-
}
|
|
434
|
-
currentId = entryMap.get(currentId)?.node.entry.parentId;
|
|
435
|
-
}
|
|
436
|
-
return null;
|
|
437
|
-
}
|
|
438
|
-
|
|
439
|
-
// Build visible tree structure
|
|
440
|
-
const visibleParent = new Map();
|
|
441
|
-
const visibleChildren = new Map();
|
|
442
|
-
visibleChildren.set(null, []); // root-level nodes
|
|
443
|
-
|
|
444
|
-
for (const flatNode of filteredNodes) {
|
|
445
|
-
const nodeId = flatNode.node.entry.id;
|
|
446
|
-
const ancestorId = findVisibleAncestor(nodeId);
|
|
447
|
-
visibleParent.set(nodeId, ancestorId);
|
|
448
|
-
|
|
449
|
-
if (!visibleChildren.has(ancestorId)) {
|
|
450
|
-
visibleChildren.set(ancestorId, []);
|
|
451
|
-
}
|
|
452
|
-
visibleChildren.get(ancestorId).push(nodeId);
|
|
453
|
-
}
|
|
454
|
-
|
|
455
|
-
// Update multipleRoots based on visible roots
|
|
456
|
-
const visibleRootIds = visibleChildren.get(null);
|
|
457
|
-
const multipleRoots = visibleRootIds.length > 1;
|
|
458
|
-
|
|
459
|
-
// Build a map for quick lookup: nodeId → FlatNode
|
|
460
|
-
const filteredNodeMap = new Map();
|
|
461
|
-
for (const flatNode of filteredNodes) {
|
|
462
|
-
filteredNodeMap.set(flatNode.node.entry.id, flatNode);
|
|
463
|
-
}
|
|
464
|
-
|
|
465
|
-
// DFS traversal of visible tree, applying same indentation rules as flattenTree()
|
|
466
|
-
// Stack items: [nodeId, indent, justBranched, showConnector, isLast, gutters, isVirtualRootChild]
|
|
467
|
-
const stack = [];
|
|
468
|
-
|
|
469
|
-
// Add visible roots in reverse order (to process in forward order via stack)
|
|
470
|
-
for (let i = visibleRootIds.length - 1; i >= 0; i--) {
|
|
471
|
-
const isLast = i === visibleRootIds.length - 1;
|
|
472
|
-
stack.push([
|
|
473
|
-
visibleRootIds[i],
|
|
474
|
-
multipleRoots ? 1 : 0,
|
|
475
|
-
multipleRoots,
|
|
476
|
-
multipleRoots,
|
|
477
|
-
isLast,
|
|
478
|
-
[],
|
|
479
|
-
multipleRoots
|
|
480
|
-
]);
|
|
481
|
-
}
|
|
482
|
-
|
|
483
|
-
while (stack.length > 0) {
|
|
484
|
-
const [nodeId, indent, justBranched, showConnector, isLast, gutters, isVirtualRootChild] = stack.pop();
|
|
485
|
-
|
|
486
|
-
const flatNode = filteredNodeMap.get(nodeId);
|
|
487
|
-
if (!flatNode) continue;
|
|
488
|
-
|
|
489
|
-
// Update this node's visual properties
|
|
490
|
-
flatNode.indent = indent;
|
|
491
|
-
flatNode.showConnector = showConnector;
|
|
492
|
-
flatNode.isLast = isLast;
|
|
493
|
-
flatNode.gutters = gutters;
|
|
494
|
-
flatNode.isVirtualRootChild = isVirtualRootChild;
|
|
495
|
-
flatNode.multipleRoots = multipleRoots;
|
|
496
|
-
|
|
497
|
-
// Get visible children of this node
|
|
498
|
-
const children = visibleChildren.get(nodeId) || [];
|
|
499
|
-
const multipleChildren = children.length > 1;
|
|
500
|
-
|
|
501
|
-
// Calculate child indent using same rules as flattenTree():
|
|
502
|
-
// - Parent branches (multiple children): children get +1
|
|
503
|
-
// - Just branched and indent > 0: children get +1 for visual grouping
|
|
504
|
-
// - Single-child chain: stay flat
|
|
505
|
-
let childIndent;
|
|
506
|
-
if (multipleChildren) {
|
|
507
|
-
childIndent = indent + 1;
|
|
508
|
-
} else if (justBranched && indent > 0) {
|
|
509
|
-
childIndent = indent + 1;
|
|
510
|
-
} else {
|
|
511
|
-
childIndent = indent;
|
|
512
|
-
}
|
|
513
|
-
|
|
514
|
-
// Build gutters for children (same logic as flattenTree)
|
|
515
|
-
const connectorDisplayed = showConnector && !isVirtualRootChild;
|
|
516
|
-
const currentDisplayIndent = multipleRoots ? Math.max(0, indent - 1) : indent;
|
|
517
|
-
const connectorPosition = Math.max(0, currentDisplayIndent - 1);
|
|
518
|
-
const childGutters = connectorDisplayed
|
|
519
|
-
? [...gutters, { position: connectorPosition, show: !isLast }]
|
|
520
|
-
: gutters;
|
|
521
|
-
|
|
522
|
-
// Add children in reverse order (to process in forward order via stack)
|
|
523
|
-
for (let i = children.length - 1; i >= 0; i--) {
|
|
524
|
-
const childIsLast = i === children.length - 1;
|
|
525
|
-
stack.push([
|
|
526
|
-
children[i],
|
|
527
|
-
childIndent,
|
|
528
|
-
multipleChildren,
|
|
529
|
-
multipleChildren,
|
|
530
|
-
childIsLast,
|
|
531
|
-
childGutters,
|
|
532
|
-
false
|
|
533
|
-
]);
|
|
534
|
-
}
|
|
535
|
-
}
|
|
536
|
-
}
|
|
537
|
-
|
|
538
|
-
// ============================================================
|
|
539
|
-
// TREE DISPLAY TEXT (pure data -> string)
|
|
540
|
-
// ============================================================
|
|
541
|
-
|
|
542
|
-
function shortenPath(p) {
|
|
543
|
-
if (typeof p !== 'string') return '';
|
|
544
|
-
if (p.startsWith('/Users/')) {
|
|
545
|
-
const parts = p.split('/');
|
|
546
|
-
if (parts.length > 2) return '~' + p.slice(('/Users/' + parts[2]).length);
|
|
547
|
-
}
|
|
548
|
-
if (p.startsWith('/home/')) {
|
|
549
|
-
const parts = p.split('/');
|
|
550
|
-
if (parts.length > 2) return '~' + p.slice(('/home/' + parts[2]).length);
|
|
551
|
-
}
|
|
552
|
-
return p;
|
|
553
|
-
}
|
|
554
|
-
|
|
555
|
-
function formatToolCall(name, args) {
|
|
556
|
-
switch (name) {
|
|
557
|
-
case 'read': {
|
|
558
|
-
const path = shortenPath(String(args.path || args.file_path || ''));
|
|
559
|
-
const offset = args.offset;
|
|
560
|
-
const limit = args.limit;
|
|
561
|
-
let display = path;
|
|
562
|
-
if (offset !== undefined || limit !== undefined) {
|
|
563
|
-
const start = offset ?? 1;
|
|
564
|
-
const end = limit !== undefined ? start + limit - 1 : '';
|
|
565
|
-
display += `:${start}${end ? `-${end}` : ''}`;
|
|
566
|
-
}
|
|
567
|
-
return `[read: ${display}]`;
|
|
568
|
-
}
|
|
569
|
-
case 'write':
|
|
570
|
-
return `[write: ${shortenPath(String(args.path || args.file_path || ''))}]`;
|
|
571
|
-
case 'edit':
|
|
572
|
-
return `[edit: ${shortenPath(String(args.path || args.file_path || ''))}]`;
|
|
573
|
-
case 'bash': {
|
|
574
|
-
const rawCmd = String(args.command || '');
|
|
575
|
-
const cmd = rawCmd.replace(/[\n\t]/g, ' ').trim().slice(0, 50);
|
|
576
|
-
return `[bash: ${cmd}${rawCmd.length > 50 ? '...' : ''}]`;
|
|
577
|
-
}
|
|
578
|
-
case 'grep':
|
|
579
|
-
return `[grep: /${args.pattern || ''}/ in ${shortenPath(String(args.path || '.'))}]`;
|
|
580
|
-
case 'find':
|
|
581
|
-
return `[find: ${args.pattern || ''} in ${shortenPath(String(args.path || '.'))}]`;
|
|
582
|
-
case 'ls':
|
|
583
|
-
return `[ls: ${shortenPath(String(args.path || '.'))}]`;
|
|
584
|
-
default: {
|
|
585
|
-
const argsStr = JSON.stringify(args).slice(0, 40);
|
|
586
|
-
return `[${name}: ${argsStr}${JSON.stringify(args).length > 40 ? '...' : ''}]`;
|
|
587
|
-
}
|
|
588
|
-
}
|
|
589
|
-
}
|
|
590
|
-
|
|
591
|
-
function escapeHtml(text) {
|
|
592
|
-
const div = document.createElement('div');
|
|
593
|
-
div.textContent = text;
|
|
594
|
-
return div.innerHTML;
|
|
595
|
-
}
|
|
596
|
-
|
|
597
|
-
/**
|
|
598
|
-
* Truncate string to maxLen chars, append "..." if truncated.
|
|
599
|
-
*/
|
|
600
|
-
function truncate(s, maxLen = 100) {
|
|
601
|
-
if (s.length <= maxLen) return s;
|
|
602
|
-
return s.slice(0, maxLen) + '...';
|
|
603
|
-
}
|
|
604
|
-
|
|
605
|
-
/**
|
|
606
|
-
* Get display text for tree node (returns HTML string).
|
|
607
|
-
*/
|
|
608
|
-
function getTreeNodeDisplayHtml(entry, label) {
|
|
609
|
-
const normalize = s => s.replace(/[\n\t]/g, ' ').trim();
|
|
610
|
-
const labelHtml = label ? `<span class="tree-label">[${escapeHtml(label)}]</span> ` : '';
|
|
611
|
-
|
|
612
|
-
switch (entry.type) {
|
|
613
|
-
case 'message': {
|
|
614
|
-
const msg = entry.message;
|
|
615
|
-
if (msg.role === 'user') {
|
|
616
|
-
const content = truncate(normalize(extractContent(msg.content)));
|
|
617
|
-
return labelHtml + `<span class="tree-role-user">user:</span> ${escapeHtml(content)}`;
|
|
618
|
-
}
|
|
619
|
-
if (msg.role === 'assistant') {
|
|
620
|
-
const textContent = truncate(normalize(extractContent(msg.content)));
|
|
621
|
-
if (textContent) {
|
|
622
|
-
return labelHtml + `<span class="tree-role-assistant">assistant:</span> ${escapeHtml(textContent)}`;
|
|
623
|
-
}
|
|
624
|
-
if (msg.stopReason === 'aborted') {
|
|
625
|
-
return labelHtml + `<span class="tree-role-assistant">assistant:</span> <span class="tree-muted">(aborted)</span>`;
|
|
626
|
-
}
|
|
627
|
-
if (msg.errorMessage) {
|
|
628
|
-
return labelHtml + `<span class="tree-role-assistant">assistant:</span> <span class="tree-error">${escapeHtml(truncate(msg.errorMessage))}</span>`;
|
|
629
|
-
}
|
|
630
|
-
return labelHtml + `<span class="tree-role-assistant">assistant:</span> <span class="tree-muted">(no text)</span>`;
|
|
631
|
-
}
|
|
632
|
-
if (msg.role === 'toolResult') {
|
|
633
|
-
const toolCall = msg.toolCallId ? toolCallMap.get(msg.toolCallId) : null;
|
|
634
|
-
if (toolCall) {
|
|
635
|
-
return labelHtml + `<span class="tree-role-tool">${escapeHtml(formatToolCall(toolCall.name, toolCall.arguments))}</span>`;
|
|
636
|
-
}
|
|
637
|
-
return labelHtml + `<span class="tree-role-tool">[${msg.toolName || 'tool'}]</span>`;
|
|
638
|
-
}
|
|
639
|
-
if (msg.role === 'bashExecution') {
|
|
640
|
-
const cmd = truncate(normalize(msg.command || ''));
|
|
641
|
-
return labelHtml + `<span class="tree-role-tool">[bash]:</span> ${escapeHtml(cmd)}`;
|
|
642
|
-
}
|
|
643
|
-
return labelHtml + `<span class="tree-muted">[${msg.role}]</span>`;
|
|
644
|
-
}
|
|
645
|
-
case 'compaction':
|
|
646
|
-
return labelHtml + `<span class="tree-compaction">[compaction: ${Math.round(entry.tokensBefore/1000)}k tokens]</span>`;
|
|
647
|
-
case 'branch_summary': {
|
|
648
|
-
const summary = truncate(normalize(entry.summary || ''));
|
|
649
|
-
return labelHtml + `<span class="tree-branch-summary">[branch summary]:</span> ${escapeHtml(summary)}`;
|
|
650
|
-
}
|
|
651
|
-
case 'custom_message': {
|
|
652
|
-
const content = typeof entry.content === 'string' ? entry.content : extractContent(entry.content);
|
|
653
|
-
return labelHtml + `<span class="tree-custom">[${escapeHtml(entry.customType)}]:</span> ${escapeHtml(truncate(normalize(content)))}`;
|
|
654
|
-
}
|
|
655
|
-
case 'model_change':
|
|
656
|
-
return labelHtml + `<span class="tree-muted">[model: ${entry.modelId}]</span>`;
|
|
657
|
-
case 'thinking_level_change':
|
|
658
|
-
return labelHtml + `<span class="tree-muted">[thinking: ${entry.thinkingLevel}]</span>`;
|
|
659
|
-
default:
|
|
660
|
-
return labelHtml + `<span class="tree-muted">[${entry.type}]</span>`;
|
|
661
|
-
}
|
|
662
|
-
}
|
|
663
|
-
|
|
664
|
-
// ============================================================
|
|
665
|
-
// TREE RENDERING (DOM manipulation)
|
|
666
|
-
// ============================================================
|
|
667
|
-
|
|
668
|
-
let currentLeafId = leafId;
|
|
669
|
-
let currentTargetId = urlTargetId || leafId;
|
|
670
|
-
let treeRendered = false;
|
|
671
|
-
|
|
672
|
-
function renderTree() {
|
|
673
|
-
const tree = buildTree();
|
|
674
|
-
const activePathIds = buildActivePathIds(currentLeafId);
|
|
675
|
-
const flatNodes = flattenTree(tree, activePathIds);
|
|
676
|
-
const filtered = filterNodes(flatNodes, currentLeafId);
|
|
677
|
-
const container = document.getElementById('tree-container');
|
|
678
|
-
|
|
679
|
-
// Full render only on first call or when filter/search changes
|
|
680
|
-
if (!treeRendered) {
|
|
681
|
-
container.innerHTML = '';
|
|
682
|
-
|
|
683
|
-
for (const flatNode of filtered) {
|
|
684
|
-
const entry = flatNode.node.entry;
|
|
685
|
-
const isOnPath = activePathIds.has(entry.id);
|
|
686
|
-
const isTarget = entry.id === currentTargetId;
|
|
687
|
-
|
|
688
|
-
const div = document.createElement('div');
|
|
689
|
-
div.className = 'tree-node';
|
|
690
|
-
if (isOnPath) div.classList.add('in-path');
|
|
691
|
-
if (isTarget) div.classList.add('active');
|
|
692
|
-
div.dataset.id = entry.id;
|
|
693
|
-
|
|
694
|
-
const prefix = buildTreePrefix(flatNode);
|
|
695
|
-
const prefixSpan = document.createElement('span');
|
|
696
|
-
prefixSpan.className = 'tree-prefix';
|
|
697
|
-
prefixSpan.textContent = prefix;
|
|
698
|
-
|
|
699
|
-
const marker = document.createElement('span');
|
|
700
|
-
marker.className = 'tree-marker';
|
|
701
|
-
marker.textContent = isOnPath ? '•' : ' ';
|
|
702
|
-
|
|
703
|
-
const content = document.createElement('span');
|
|
704
|
-
content.className = 'tree-content';
|
|
705
|
-
content.innerHTML = getTreeNodeDisplayHtml(entry, flatNode.node.label);
|
|
706
|
-
|
|
707
|
-
div.appendChild(prefixSpan);
|
|
708
|
-
div.appendChild(marker);
|
|
709
|
-
div.appendChild(content);
|
|
710
|
-
// Navigate to the newest leaf through this node, but scroll to the clicked node
|
|
711
|
-
div.addEventListener('click', () => {
|
|
712
|
-
const leafId = findNewestLeaf(entry.id);
|
|
713
|
-
navigateTo(leafId, 'target', entry.id);
|
|
714
|
-
});
|
|
715
|
-
|
|
716
|
-
container.appendChild(div);
|
|
717
|
-
}
|
|
718
|
-
|
|
719
|
-
treeRendered = true;
|
|
720
|
-
} else {
|
|
721
|
-
// Just update markers and classes
|
|
722
|
-
const nodes = container.querySelectorAll('.tree-node');
|
|
723
|
-
for (const node of nodes) {
|
|
724
|
-
const id = node.dataset.id;
|
|
725
|
-
const isOnPath = activePathIds.has(id);
|
|
726
|
-
const isTarget = id === currentTargetId;
|
|
727
|
-
|
|
728
|
-
node.classList.toggle('in-path', isOnPath);
|
|
729
|
-
node.classList.toggle('active', isTarget);
|
|
730
|
-
|
|
731
|
-
const marker = node.querySelector('.tree-marker');
|
|
732
|
-
if (marker) {
|
|
733
|
-
marker.textContent = isOnPath ? '•' : ' ';
|
|
734
|
-
}
|
|
735
|
-
}
|
|
736
|
-
}
|
|
737
|
-
|
|
738
|
-
document.getElementById('tree-status').textContent = `${filtered.length} / ${flatNodes.length} entries`;
|
|
739
|
-
|
|
740
|
-
// Scroll active node into view after layout
|
|
741
|
-
setTimeout(() => {
|
|
742
|
-
const activeNode = container.querySelector('.tree-node.active');
|
|
743
|
-
if (activeNode) {
|
|
744
|
-
activeNode.scrollIntoView({ block: 'nearest' });
|
|
745
|
-
}
|
|
746
|
-
}, 0);
|
|
747
|
-
}
|
|
748
|
-
|
|
749
|
-
function forceTreeRerender() {
|
|
750
|
-
treeRendered = false;
|
|
751
|
-
renderTree();
|
|
752
|
-
}
|
|
753
|
-
|
|
754
|
-
// ============================================================
|
|
755
|
-
// MESSAGE RENDERING
|
|
756
|
-
// ============================================================
|
|
757
|
-
|
|
758
|
-
function formatTokens(count) {
|
|
759
|
-
if (count < 1000) return count.toString();
|
|
760
|
-
if (count < 10000) return (count / 1000).toFixed(1) + 'k';
|
|
761
|
-
if (count < 1000000) return Math.round(count / 1000) + 'k';
|
|
762
|
-
return (count / 1000000).toFixed(1) + 'M';
|
|
763
|
-
}
|
|
764
|
-
|
|
765
|
-
function formatTimestamp(ts) {
|
|
766
|
-
if (!ts) return '';
|
|
767
|
-
const date = new Date(ts);
|
|
768
|
-
return date.toLocaleTimeString(undefined, { hour: '2-digit', minute: '2-digit', second: '2-digit' });
|
|
769
|
-
}
|
|
770
|
-
|
|
771
|
-
function replaceTabs(text) {
|
|
772
|
-
return text.replace(/\t/g, ' ');
|
|
773
|
-
}
|
|
774
|
-
|
|
775
|
-
/** Safely coerce value to string for display. Returns null if invalid type. */
|
|
776
|
-
function str(value) {
|
|
777
|
-
if (typeof value === 'string') return value;
|
|
778
|
-
if (value == null) return '';
|
|
779
|
-
return null;
|
|
780
|
-
}
|
|
781
|
-
|
|
782
|
-
function getLanguageFromPath(filePath) {
|
|
783
|
-
const ext = filePath.split('.').pop()?.toLowerCase();
|
|
784
|
-
const extToLang = {
|
|
785
|
-
ts: 'typescript', tsx: 'typescript', js: 'javascript', jsx: 'javascript',
|
|
786
|
-
py: 'python', rb: 'ruby', rs: 'rust', go: 'go', java: 'java',
|
|
787
|
-
c: 'c', cpp: 'cpp', h: 'c', hpp: 'cpp', cs: 'csharp',
|
|
788
|
-
php: 'php', sh: 'bash', bash: 'bash', zsh: 'bash',
|
|
789
|
-
sql: 'sql', html: 'html', css: 'css', scss: 'scss',
|
|
790
|
-
json: 'json', yaml: 'yaml', yml: 'yaml', xml: 'xml',
|
|
791
|
-
md: 'markdown', dockerfile: 'dockerfile'
|
|
792
|
-
};
|
|
793
|
-
return extToLang[ext];
|
|
794
|
-
}
|
|
795
|
-
|
|
796
|
-
function findToolResult(toolCallId) {
|
|
797
|
-
for (const entry of entries) {
|
|
798
|
-
if (entry.type === 'message' && entry.message.role === 'toolResult') {
|
|
799
|
-
if (entry.message.toolCallId === toolCallId) {
|
|
800
|
-
return entry.message;
|
|
801
|
-
}
|
|
802
|
-
}
|
|
803
|
-
}
|
|
804
|
-
return null;
|
|
805
|
-
}
|
|
806
|
-
|
|
807
|
-
function formatExpandableOutput(text, maxLines, lang) {
|
|
808
|
-
text = replaceTabs(text);
|
|
809
|
-
const lines = text.split('\n');
|
|
810
|
-
const displayLines = lines.slice(0, maxLines);
|
|
811
|
-
const remaining = lines.length - maxLines;
|
|
812
|
-
|
|
813
|
-
if (lang) {
|
|
814
|
-
let highlighted;
|
|
815
|
-
try {
|
|
816
|
-
highlighted = hljs.highlight(text, { language: lang }).value;
|
|
817
|
-
} catch {
|
|
818
|
-
highlighted = escapeHtml(text);
|
|
819
|
-
}
|
|
820
|
-
|
|
821
|
-
if (remaining > 0) {
|
|
822
|
-
const previewCode = displayLines.join('\n');
|
|
823
|
-
let previewHighlighted;
|
|
824
|
-
try {
|
|
825
|
-
previewHighlighted = hljs.highlight(previewCode, { language: lang }).value;
|
|
826
|
-
} catch {
|
|
827
|
-
previewHighlighted = escapeHtml(previewCode);
|
|
828
|
-
}
|
|
829
|
-
|
|
830
|
-
return `<div class="tool-output expandable" onclick="this.classList.toggle('expanded')">
|
|
831
|
-
<div class="output-preview"><pre><code class="hljs">${previewHighlighted}</code></pre>
|
|
832
|
-
<div class="expand-hint">... (${remaining} more lines)</div></div>
|
|
833
|
-
<div class="output-full"><pre><code class="hljs">${highlighted}</code></pre></div></div>`;
|
|
834
|
-
}
|
|
835
|
-
|
|
836
|
-
return `<div class="tool-output"><pre><code class="hljs">${highlighted}</code></pre></div>`;
|
|
837
|
-
}
|
|
838
|
-
|
|
839
|
-
// Plain text output
|
|
840
|
-
if (remaining > 0) {
|
|
841
|
-
let out = '<div class="tool-output expandable" onclick="this.classList.toggle(\'expanded\')">';
|
|
842
|
-
out += '<div class="output-preview">';
|
|
843
|
-
for (const line of displayLines) {
|
|
844
|
-
out += `<div>${escapeHtml(replaceTabs(line))}</div>`;
|
|
845
|
-
}
|
|
846
|
-
out += `<div class="expand-hint">... (${remaining} more lines)</div></div>`;
|
|
847
|
-
out += '<div class="output-full">';
|
|
848
|
-
for (const line of lines) {
|
|
849
|
-
out += `<div>${escapeHtml(replaceTabs(line))}</div>`;
|
|
850
|
-
}
|
|
851
|
-
out += '</div></div>';
|
|
852
|
-
return out;
|
|
853
|
-
}
|
|
854
|
-
|
|
855
|
-
let out = '<div class="tool-output">';
|
|
856
|
-
for (const line of displayLines) {
|
|
857
|
-
out += `<div>${escapeHtml(replaceTabs(line))}</div>`;
|
|
858
|
-
}
|
|
859
|
-
out += '</div>';
|
|
860
|
-
return out;
|
|
861
|
-
}
|
|
862
|
-
|
|
863
|
-
function renderToolCall(call) {
|
|
864
|
-
const result = findToolResult(call.id);
|
|
865
|
-
const isError = result?.isError || false;
|
|
866
|
-
const statusClass = result ? (isError ? 'error' : 'success') : 'pending';
|
|
867
|
-
|
|
868
|
-
const getResultText = () => {
|
|
869
|
-
if (!result) return '';
|
|
870
|
-
const textBlocks = result.content.filter(c => c.type === 'text');
|
|
871
|
-
return textBlocks.map(c => c.text).join('\n');
|
|
872
|
-
};
|
|
873
|
-
|
|
874
|
-
const getResultImages = () => {
|
|
875
|
-
if (!result) return [];
|
|
876
|
-
return result.content.filter(c => c.type === 'image');
|
|
877
|
-
};
|
|
878
|
-
|
|
879
|
-
const renderResultImages = () => {
|
|
880
|
-
const images = getResultImages();
|
|
881
|
-
if (images.length === 0) return '';
|
|
882
|
-
return '<div class="tool-images">' +
|
|
883
|
-
images.map(img => `<img src="data:${img.mimeType};base64,${img.data}" class="tool-image" />`).join('') +
|
|
884
|
-
'</div>';
|
|
885
|
-
};
|
|
886
|
-
|
|
887
|
-
let html = `<div class="tool-execution ${statusClass}">`;
|
|
888
|
-
const args = call.arguments || {};
|
|
889
|
-
const name = call.name;
|
|
890
|
-
|
|
891
|
-
const invalidArg = '<span class="tool-error">[invalid arg]</span>';
|
|
892
|
-
|
|
893
|
-
switch (name) {
|
|
894
|
-
case 'bash': {
|
|
895
|
-
const command = str(args.command);
|
|
896
|
-
const cmdDisplay = command === null ? invalidArg : escapeHtml(command || '...');
|
|
897
|
-
html += `<div class="tool-command">$ ${cmdDisplay}</div>`;
|
|
898
|
-
if (result) {
|
|
899
|
-
const output = getResultText().trim();
|
|
900
|
-
if (output) html += formatExpandableOutput(output, 5);
|
|
901
|
-
}
|
|
902
|
-
break;
|
|
903
|
-
}
|
|
904
|
-
case 'read': {
|
|
905
|
-
const filePath = str(args.file_path ?? args.path);
|
|
906
|
-
const offset = args.offset;
|
|
907
|
-
const limit = args.limit;
|
|
908
|
-
|
|
909
|
-
let pathHtml = filePath === null ? invalidArg : escapeHtml(shortenPath(filePath || ''));
|
|
910
|
-
if (filePath !== null && (offset !== undefined || limit !== undefined)) {
|
|
911
|
-
const startLine = offset ?? 1;
|
|
912
|
-
const endLine = limit !== undefined ? startLine + limit - 1 : '';
|
|
913
|
-
pathHtml += `<span class="line-numbers">:${startLine}${endLine ? '-' + endLine : ''}</span>`;
|
|
914
|
-
}
|
|
915
|
-
|
|
916
|
-
html += `<div class="tool-header"><span class="tool-name">read</span> <span class="tool-path">${pathHtml}</span></div>`;
|
|
917
|
-
if (result) {
|
|
918
|
-
html += renderResultImages();
|
|
919
|
-
const output = getResultText();
|
|
920
|
-
const lang = filePath ? getLanguageFromPath(filePath) : null;
|
|
921
|
-
if (output) html += formatExpandableOutput(output, 10, lang);
|
|
922
|
-
}
|
|
923
|
-
break;
|
|
924
|
-
}
|
|
925
|
-
case 'write': {
|
|
926
|
-
const filePath = str(args.file_path ?? args.path);
|
|
927
|
-
const content = str(args.content);
|
|
928
|
-
|
|
929
|
-
html += `<div class="tool-header"><span class="tool-name">write</span> <span class="tool-path">${filePath === null ? invalidArg : escapeHtml(shortenPath(filePath || ''))}</span>`;
|
|
930
|
-
if (content !== null && content) {
|
|
931
|
-
const lines = content.split('\n');
|
|
932
|
-
if (lines.length > 10) html += ` <span class="line-count">(${lines.length} lines)</span>`;
|
|
933
|
-
}
|
|
934
|
-
html += '</div>';
|
|
935
|
-
|
|
936
|
-
if (content === null) {
|
|
937
|
-
html += `<div class="tool-error">[invalid content arg - expected string]</div>`;
|
|
938
|
-
} else if (content) {
|
|
939
|
-
const lang = filePath ? getLanguageFromPath(filePath) : null;
|
|
940
|
-
html += formatExpandableOutput(content, 10, lang);
|
|
941
|
-
}
|
|
942
|
-
if (result) {
|
|
943
|
-
const output = getResultText().trim();
|
|
944
|
-
if (output) html += `<div class="tool-output"><div>${escapeHtml(output)}</div></div>`;
|
|
945
|
-
}
|
|
946
|
-
break;
|
|
947
|
-
}
|
|
948
|
-
case 'edit': {
|
|
949
|
-
const filePath = str(args.file_path ?? args.path);
|
|
950
|
-
html += `<div class="tool-header"><span class="tool-name">edit</span> <span class="tool-path">${filePath === null ? invalidArg : escapeHtml(shortenPath(filePath || ''))}</span></div>`;
|
|
951
|
-
|
|
952
|
-
if (result?.details?.diff) {
|
|
953
|
-
const diffLines = result.details.diff.split('\n');
|
|
954
|
-
html += '<div class="tool-diff">';
|
|
955
|
-
for (const line of diffLines) {
|
|
956
|
-
const cls = line.match(/^\+/) ? 'diff-added' : line.match(/^-/) ? 'diff-removed' : 'diff-context';
|
|
957
|
-
html += `<div class="${cls}">${escapeHtml(replaceTabs(line))}</div>`;
|
|
958
|
-
}
|
|
959
|
-
html += '</div>';
|
|
960
|
-
} else if (result) {
|
|
961
|
-
const output = getResultText().trim();
|
|
962
|
-
if (output) html += `<div class="tool-output"><pre>${escapeHtml(output)}</pre></div>`;
|
|
963
|
-
}
|
|
964
|
-
break;
|
|
965
|
-
}
|
|
966
|
-
default: {
|
|
967
|
-
// Check for pre-rendered custom tool HTML
|
|
968
|
-
const rendered = renderedTools?.[call.id];
|
|
969
|
-
if (rendered?.callHtml || rendered?.resultHtmlCollapsed || rendered?.resultHtmlExpanded) {
|
|
970
|
-
// Custom tool with pre-rendered HTML from TUI renderer
|
|
971
|
-
if (rendered.callHtml) {
|
|
972
|
-
html += `<div class="tool-header ansi-rendered">${rendered.callHtml}</div>`;
|
|
973
|
-
} else {
|
|
974
|
-
html += `<div class="tool-header"><span class="tool-name">${escapeHtml(name)}</span></div>`;
|
|
975
|
-
}
|
|
976
|
-
|
|
977
|
-
if (rendered.resultHtmlCollapsed && rendered.resultHtmlExpanded && rendered.resultHtmlCollapsed !== rendered.resultHtmlExpanded) {
|
|
978
|
-
// Both collapsed and expanded differ - render expandable section
|
|
979
|
-
html += `<div class="tool-output expandable ansi-rendered" onclick="this.classList.toggle('expanded')">
|
|
980
|
-
<div class="output-preview">${rendered.resultHtmlCollapsed}</div>
|
|
981
|
-
<div class="output-full">${rendered.resultHtmlExpanded}</div>
|
|
982
|
-
</div>`;
|
|
983
|
-
} else if (rendered.resultHtmlExpanded) {
|
|
984
|
-
// Only expanded exists (or collapsed is identical) - show directly
|
|
985
|
-
html += `<div class="tool-output ansi-rendered">${rendered.resultHtmlExpanded}</div>`;
|
|
986
|
-
} else if (result) {
|
|
987
|
-
// No pre-rendered result HTML - fallback to JSON
|
|
988
|
-
const output = getResultText();
|
|
989
|
-
if (output) html += formatExpandableOutput(output, 10);
|
|
990
|
-
}
|
|
991
|
-
} else {
|
|
992
|
-
// Fallback to JSON display (existing behavior)
|
|
993
|
-
html += `<div class="tool-header"><span class="tool-name">${escapeHtml(name)}</span></div>`;
|
|
994
|
-
html += `<div class="tool-output"><pre>${escapeHtml(JSON.stringify(args, null, 2))}</pre></div>`;
|
|
995
|
-
if (result) {
|
|
996
|
-
const output = getResultText();
|
|
997
|
-
if (output) html += formatExpandableOutput(output, 10);
|
|
998
|
-
}
|
|
999
|
-
}
|
|
1000
|
-
}
|
|
1001
|
-
}
|
|
1002
|
-
|
|
1003
|
-
html += '</div>';
|
|
1004
|
-
return html;
|
|
1005
|
-
}
|
|
1006
|
-
|
|
1007
|
-
/**
|
|
1008
|
-
* Download the session data as a JSONL file.
|
|
1009
|
-
* Reconstructs the original format: header line + entry lines.
|
|
1010
|
-
*/
|
|
1011
|
-
window.downloadSessionJson = function() {
|
|
1012
|
-
// Build JSONL content: header first, then all entries
|
|
1013
|
-
const lines = [];
|
|
1014
|
-
if (header) {
|
|
1015
|
-
lines.push(JSON.stringify({ type: 'header', ...header }));
|
|
1016
|
-
}
|
|
1017
|
-
for (const entry of entries) {
|
|
1018
|
-
lines.push(JSON.stringify(entry));
|
|
1019
|
-
}
|
|
1020
|
-
const jsonlContent = lines.join('\n');
|
|
1021
|
-
|
|
1022
|
-
// Create download
|
|
1023
|
-
const blob = new Blob([jsonlContent], { type: 'application/x-ndjson' });
|
|
1024
|
-
const url = URL.createObjectURL(blob);
|
|
1025
|
-
const a = document.createElement('a');
|
|
1026
|
-
a.href = url;
|
|
1027
|
-
a.download = `${header?.id || 'session'}.jsonl`;
|
|
1028
|
-
document.body.appendChild(a);
|
|
1029
|
-
a.click();
|
|
1030
|
-
document.body.removeChild(a);
|
|
1031
|
-
URL.revokeObjectURL(url);
|
|
1032
|
-
}
|
|
1033
|
-
|
|
1034
|
-
/**
|
|
1035
|
-
* Build a shareable URL for a specific message.
|
|
1036
|
-
* URL format: base?gistId&leafId=<leafId>&targetId=<entryId>
|
|
1037
|
-
*/
|
|
1038
|
-
function buildShareUrl(entryId) {
|
|
1039
|
-
// Check for injected base URL (used when loaded in iframe via srcdoc)
|
|
1040
|
-
const baseUrlMeta = document.querySelector('meta[name="pi-share-base-url"]');
|
|
1041
|
-
const baseUrl = baseUrlMeta ? baseUrlMeta.content : window.location.href.split('?')[0];
|
|
1042
|
-
|
|
1043
|
-
const url = new URL(window.location.href);
|
|
1044
|
-
// Find the gist ID (first query param without value, e.g., ?abc123)
|
|
1045
|
-
const gistId = Array.from(url.searchParams.keys()).find(k => !url.searchParams.get(k));
|
|
1046
|
-
|
|
1047
|
-
// Build the share URL
|
|
1048
|
-
const params = new URLSearchParams();
|
|
1049
|
-
params.set('leafId', currentLeafId);
|
|
1050
|
-
params.set('targetId', entryId);
|
|
1051
|
-
|
|
1052
|
-
// If we have an injected base URL (iframe context), use it directly
|
|
1053
|
-
if (baseUrlMeta) {
|
|
1054
|
-
return `${baseUrl}&${params.toString()}`;
|
|
1055
|
-
}
|
|
1056
|
-
|
|
1057
|
-
// Otherwise build from current location (direct file access)
|
|
1058
|
-
url.search = gistId ? `?${gistId}&${params.toString()}` : `?${params.toString()}`;
|
|
1059
|
-
return url.toString();
|
|
1060
|
-
}
|
|
1061
|
-
|
|
1062
|
-
/**
|
|
1063
|
-
* Copy text to clipboard with visual feedback.
|
|
1064
|
-
* Uses navigator.clipboard with fallback to execCommand for HTTP contexts.
|
|
1065
|
-
*/
|
|
1066
|
-
async function copyToClipboard(text, button) {
|
|
1067
|
-
let success = false;
|
|
1068
|
-
try {
|
|
1069
|
-
if (navigator.clipboard && navigator.clipboard.writeText) {
|
|
1070
|
-
await navigator.clipboard.writeText(text);
|
|
1071
|
-
success = true;
|
|
1072
|
-
}
|
|
1073
|
-
} catch (err) {
|
|
1074
|
-
// Clipboard API failed, try fallback
|
|
1075
|
-
}
|
|
1076
|
-
|
|
1077
|
-
// Fallback for HTTP or when Clipboard API is unavailable
|
|
1078
|
-
if (!success) {
|
|
1079
|
-
try {
|
|
1080
|
-
const textarea = document.createElement('textarea');
|
|
1081
|
-
textarea.value = text;
|
|
1082
|
-
textarea.style.position = 'fixed';
|
|
1083
|
-
textarea.style.opacity = '0';
|
|
1084
|
-
document.body.appendChild(textarea);
|
|
1085
|
-
textarea.select();
|
|
1086
|
-
success = document.execCommand('copy');
|
|
1087
|
-
document.body.removeChild(textarea);
|
|
1088
|
-
} catch (err) {
|
|
1089
|
-
console.error('Failed to copy:', err);
|
|
1090
|
-
}
|
|
1091
|
-
}
|
|
1092
|
-
|
|
1093
|
-
if (success && button) {
|
|
1094
|
-
const originalHtml = button.innerHTML;
|
|
1095
|
-
button.innerHTML = '✓';
|
|
1096
|
-
button.classList.add('copied');
|
|
1097
|
-
setTimeout(() => {
|
|
1098
|
-
button.innerHTML = originalHtml;
|
|
1099
|
-
button.classList.remove('copied');
|
|
1100
|
-
}, 1500);
|
|
1101
|
-
}
|
|
1102
|
-
}
|
|
1103
|
-
|
|
1104
|
-
/**
|
|
1105
|
-
* Render the copy-link button HTML for a message.
|
|
1106
|
-
*/
|
|
1107
|
-
function renderCopyLinkButton(entryId) {
|
|
1108
|
-
return `<button class="copy-link-btn" data-entry-id="${entryId}" title="Copy link to this message">
|
|
1109
|
-
<svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
|
|
1110
|
-
<path d="M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71"/>
|
|
1111
|
-
<path d="M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71"/>
|
|
1112
|
-
</svg>
|
|
1113
|
-
</button>`;
|
|
1114
|
-
}
|
|
1115
|
-
|
|
1116
|
-
function renderEntry(entry) {
|
|
1117
|
-
const ts = formatTimestamp(entry.timestamp);
|
|
1118
|
-
const tsHtml = ts ? `<div class="message-timestamp">${ts}</div>` : '';
|
|
1119
|
-
const entryId = `entry-${entry.id}`;
|
|
1120
|
-
const copyBtnHtml = renderCopyLinkButton(entry.id);
|
|
1121
|
-
|
|
1122
|
-
if (entry.type === 'message') {
|
|
1123
|
-
const msg = entry.message;
|
|
1124
|
-
|
|
1125
|
-
if (msg.role === 'user') {
|
|
1126
|
-
let html = `<div class="user-message" id="${entryId}">${copyBtnHtml}${tsHtml}`;
|
|
1127
|
-
const content = msg.content;
|
|
1128
|
-
|
|
1129
|
-
if (Array.isArray(content)) {
|
|
1130
|
-
const images = content.filter(c => c.type === 'image');
|
|
1131
|
-
if (images.length > 0) {
|
|
1132
|
-
html += '<div class="message-images">';
|
|
1133
|
-
for (const img of images) {
|
|
1134
|
-
html += `<img src="data:${img.mimeType};base64,${img.data}" class="message-image" />`;
|
|
1135
|
-
}
|
|
1136
|
-
html += '</div>';
|
|
1137
|
-
}
|
|
1138
|
-
}
|
|
1139
|
-
|
|
1140
|
-
const text = typeof content === 'string' ? content :
|
|
1141
|
-
content.filter(c => c.type === 'text').map(c => c.text).join('\n');
|
|
1142
|
-
if (text.trim()) {
|
|
1143
|
-
html += `<div class="markdown-content">${safeMarkedParse(text)}</div>`;
|
|
1144
|
-
}
|
|
1145
|
-
html += '</div>';
|
|
1146
|
-
return html;
|
|
1147
|
-
}
|
|
1148
|
-
|
|
1149
|
-
if (msg.role === 'assistant') {
|
|
1150
|
-
let html = `<div class="assistant-message" id="${entryId}">${copyBtnHtml}${tsHtml}`;
|
|
1151
|
-
|
|
1152
|
-
for (const block of msg.content) {
|
|
1153
|
-
if (block.type === 'text' && block.text.trim()) {
|
|
1154
|
-
html += `<div class="assistant-text markdown-content">${safeMarkedParse(block.text)}</div>`;
|
|
1155
|
-
} else if (block.type === 'thinking' && block.thinking.trim()) {
|
|
1156
|
-
html += `<div class="thinking-block">
|
|
1157
|
-
<div class="thinking-text">${escapeHtml(block.thinking)}</div>
|
|
1158
|
-
<div class="thinking-collapsed">Thinking ...</div>
|
|
1159
|
-
</div>`;
|
|
1160
|
-
}
|
|
1161
|
-
}
|
|
1162
|
-
|
|
1163
|
-
for (const block of msg.content) {
|
|
1164
|
-
if (block.type === 'toolCall') {
|
|
1165
|
-
html += renderToolCall(block);
|
|
1166
|
-
}
|
|
1167
|
-
}
|
|
1168
|
-
|
|
1169
|
-
if (msg.stopReason === 'aborted') {
|
|
1170
|
-
html += '<div class="error-text">Aborted</div>';
|
|
1171
|
-
} else if (msg.stopReason === 'error') {
|
|
1172
|
-
html += `<div class="error-text">Error: ${escapeHtml(msg.errorMessage || 'Unknown error')}</div>`;
|
|
1173
|
-
}
|
|
1174
|
-
|
|
1175
|
-
html += '</div>';
|
|
1176
|
-
return html;
|
|
1177
|
-
}
|
|
1178
|
-
|
|
1179
|
-
if (msg.role === 'bashExecution') {
|
|
1180
|
-
const isError = msg.cancelled || (msg.exitCode !== 0 && msg.exitCode !== null);
|
|
1181
|
-
let html = `<div class="tool-execution ${isError ? 'error' : 'success'}" id="${entryId}">${tsHtml}`;
|
|
1182
|
-
html += `<div class="tool-command">$ ${escapeHtml(msg.command)}</div>`;
|
|
1183
|
-
if (msg.output) html += formatExpandableOutput(msg.output, 10);
|
|
1184
|
-
if (msg.cancelled) {
|
|
1185
|
-
html += '<div style="color: var(--warning)">(cancelled)</div>';
|
|
1186
|
-
} else if (msg.exitCode !== 0 && msg.exitCode !== null) {
|
|
1187
|
-
html += `<div style="color: var(--error)">(exit ${msg.exitCode})</div>`;
|
|
1188
|
-
}
|
|
1189
|
-
html += '</div>';
|
|
1190
|
-
return html;
|
|
1191
|
-
}
|
|
1192
|
-
|
|
1193
|
-
if (msg.role === 'toolResult') return '';
|
|
1194
|
-
}
|
|
1195
|
-
|
|
1196
|
-
if (entry.type === 'model_change') {
|
|
1197
|
-
return `<div class="model-change" id="${entryId}">${tsHtml}Switched to model: <span class="model-name">${escapeHtml(entry.provider)}/${escapeHtml(entry.modelId)}</span></div>`;
|
|
1198
|
-
}
|
|
1199
|
-
|
|
1200
|
-
if (entry.type === 'compaction') {
|
|
1201
|
-
return `<div class="compaction" id="${entryId}" onclick="this.classList.toggle('expanded')">
|
|
1202
|
-
<div class="compaction-label">[compaction]</div>
|
|
1203
|
-
<div class="compaction-collapsed">Compacted from ${entry.tokensBefore.toLocaleString()} tokens</div>
|
|
1204
|
-
<div class="compaction-content"><strong>Compacted from ${entry.tokensBefore.toLocaleString()} tokens</strong>\n\n${escapeHtml(entry.summary)}</div>
|
|
1205
|
-
</div>`;
|
|
1206
|
-
}
|
|
1207
|
-
|
|
1208
|
-
if (entry.type === 'branch_summary') {
|
|
1209
|
-
return `<div class="branch-summary" id="${entryId}">${tsHtml}
|
|
1210
|
-
<div class="branch-summary-header">Branch Summary</div>
|
|
1211
|
-
<div class="markdown-content">${safeMarkedParse(entry.summary)}</div>
|
|
1212
|
-
</div>`;
|
|
1213
|
-
}
|
|
1214
|
-
|
|
1215
|
-
if (entry.type === 'custom_message' && entry.display) {
|
|
1216
|
-
return `<div class="hook-message" id="${entryId}">${tsHtml}
|
|
1217
|
-
<div class="hook-type">[${escapeHtml(entry.customType)}]</div>
|
|
1218
|
-
<div class="markdown-content">${safeMarkedParse(typeof entry.content === 'string' ? entry.content : JSON.stringify(entry.content))}</div>
|
|
1219
|
-
</div>`;
|
|
1220
|
-
}
|
|
1221
|
-
|
|
1222
|
-
return '';
|
|
1223
|
-
}
|
|
1224
|
-
|
|
1225
|
-
// ============================================================
|
|
1226
|
-
// HEADER / STATS
|
|
1227
|
-
// ============================================================
|
|
1228
|
-
|
|
1229
|
-
function computeStats(entryList) {
|
|
1230
|
-
let userMessages = 0, assistantMessages = 0, toolResults = 0;
|
|
1231
|
-
let customMessages = 0, compactions = 0, branchSummaries = 0, toolCalls = 0;
|
|
1232
|
-
const tokens = { input: 0, output: 0, cacheRead: 0, cacheWrite: 0 };
|
|
1233
|
-
const cost = { input: 0, output: 0, cacheRead: 0, cacheWrite: 0 };
|
|
1234
|
-
const models = new Set();
|
|
1235
|
-
|
|
1236
|
-
for (const entry of entryList) {
|
|
1237
|
-
if (entry.type === 'message') {
|
|
1238
|
-
const msg = entry.message;
|
|
1239
|
-
if (msg.role === 'user') userMessages++;
|
|
1240
|
-
if (msg.role === 'assistant') {
|
|
1241
|
-
assistantMessages++;
|
|
1242
|
-
if (msg.model) models.add(msg.provider ? `${msg.provider}/${msg.model}` : msg.model);
|
|
1243
|
-
if (msg.usage) {
|
|
1244
|
-
tokens.input += msg.usage.input || 0;
|
|
1245
|
-
tokens.output += msg.usage.output || 0;
|
|
1246
|
-
tokens.cacheRead += msg.usage.cacheRead || 0;
|
|
1247
|
-
tokens.cacheWrite += msg.usage.cacheWrite || 0;
|
|
1248
|
-
if (msg.usage.cost) {
|
|
1249
|
-
cost.input += msg.usage.cost.input || 0;
|
|
1250
|
-
cost.output += msg.usage.cost.output || 0;
|
|
1251
|
-
cost.cacheRead += msg.usage.cost.cacheRead || 0;
|
|
1252
|
-
cost.cacheWrite += msg.usage.cost.cacheWrite || 0;
|
|
1253
|
-
}
|
|
1254
|
-
}
|
|
1255
|
-
toolCalls += msg.content.filter(c => c.type === 'toolCall').length;
|
|
1256
|
-
}
|
|
1257
|
-
if (msg.role === 'toolResult') toolResults++;
|
|
1258
|
-
} else if (entry.type === 'compaction') {
|
|
1259
|
-
compactions++;
|
|
1260
|
-
} else if (entry.type === 'branch_summary') {
|
|
1261
|
-
branchSummaries++;
|
|
1262
|
-
} else if (entry.type === 'custom_message') {
|
|
1263
|
-
customMessages++;
|
|
1264
|
-
}
|
|
1265
|
-
}
|
|
1266
|
-
|
|
1267
|
-
return { userMessages, assistantMessages, toolResults, customMessages, compactions, branchSummaries, toolCalls, tokens, cost, models: Array.from(models) };
|
|
1268
|
-
}
|
|
1269
|
-
|
|
1270
|
-
const globalStats = computeStats(entries);
|
|
1271
|
-
|
|
1272
|
-
function renderHeader() {
|
|
1273
|
-
const totalCost = globalStats.cost.input + globalStats.cost.output + globalStats.cost.cacheRead + globalStats.cost.cacheWrite;
|
|
1274
|
-
|
|
1275
|
-
const tokenParts = [];
|
|
1276
|
-
if (globalStats.tokens.input) tokenParts.push(`↑${formatTokens(globalStats.tokens.input)}`);
|
|
1277
|
-
if (globalStats.tokens.output) tokenParts.push(`↓${formatTokens(globalStats.tokens.output)}`);
|
|
1278
|
-
if (globalStats.tokens.cacheRead) tokenParts.push(`R${formatTokens(globalStats.tokens.cacheRead)}`);
|
|
1279
|
-
if (globalStats.tokens.cacheWrite) tokenParts.push(`W${formatTokens(globalStats.tokens.cacheWrite)}`);
|
|
1280
|
-
|
|
1281
|
-
const msgParts = [];
|
|
1282
|
-
if (globalStats.userMessages) msgParts.push(`${globalStats.userMessages} user`);
|
|
1283
|
-
if (globalStats.assistantMessages) msgParts.push(`${globalStats.assistantMessages} assistant`);
|
|
1284
|
-
if (globalStats.toolResults) msgParts.push(`${globalStats.toolResults} tool results`);
|
|
1285
|
-
if (globalStats.customMessages) msgParts.push(`${globalStats.customMessages} custom`);
|
|
1286
|
-
if (globalStats.compactions) msgParts.push(`${globalStats.compactions} compactions`);
|
|
1287
|
-
if (globalStats.branchSummaries) msgParts.push(`${globalStats.branchSummaries} branch summaries`);
|
|
1288
|
-
|
|
1289
|
-
let html = `
|
|
1290
|
-
<div class="header">
|
|
1291
|
-
<h1>Session: ${escapeHtml(header?.id || 'unknown')}</h1>
|
|
1292
|
-
<div class="help-bar">
|
|
1293
|
-
<span>Ctrl+T toggle thinking · Ctrl+O toggle tools</span>
|
|
1294
|
-
<button class="download-json-btn" onclick="downloadSessionJson()" title="Download session as JSONL">↓ JSONL</button>
|
|
1295
|
-
</div>
|
|
1296
|
-
<div class="header-info">
|
|
1297
|
-
<div class="info-item"><span class="info-label">Date:</span><span class="info-value">${header?.timestamp ? new Date(header.timestamp).toLocaleString() : 'unknown'}</span></div>
|
|
1298
|
-
<div class="info-item"><span class="info-label">Models:</span><span class="info-value">${globalStats.models.join(', ') || 'unknown'}</span></div>
|
|
1299
|
-
<div class="info-item"><span class="info-label">Messages:</span><span class="info-value">${msgParts.join(', ') || '0'}</span></div>
|
|
1300
|
-
<div class="info-item"><span class="info-label">Tool Calls:</span><span class="info-value">${globalStats.toolCalls}</span></div>
|
|
1301
|
-
<div class="info-item"><span class="info-label">Tokens:</span><span class="info-value">${tokenParts.join(' ') || '0'}</span></div>
|
|
1302
|
-
<div class="info-item"><span class="info-label">Cost:</span><span class="info-value">$${totalCost.toFixed(3)}</span></div>
|
|
1303
|
-
</div>
|
|
1304
|
-
</div>`;
|
|
1305
|
-
|
|
1306
|
-
// Render system prompt (user's base prompt, applies to all providers)
|
|
1307
|
-
if (systemPrompt) {
|
|
1308
|
-
const lines = systemPrompt.split('\n');
|
|
1309
|
-
const previewLines = 10;
|
|
1310
|
-
if (lines.length > previewLines) {
|
|
1311
|
-
const preview = lines.slice(0, previewLines).join('\n');
|
|
1312
|
-
const remaining = lines.length - previewLines;
|
|
1313
|
-
html += `<div class="system-prompt expandable" onclick="this.classList.toggle('expanded')">
|
|
1314
|
-
<div class="system-prompt-header">System Prompt</div>
|
|
1315
|
-
<div class="system-prompt-preview">${escapeHtml(preview)}</div>
|
|
1316
|
-
<div class="system-prompt-expand-hint">... (${remaining} more lines, click to expand)</div>
|
|
1317
|
-
<div class="system-prompt-full">${escapeHtml(systemPrompt)}</div>
|
|
1318
|
-
</div>`;
|
|
1319
|
-
} else {
|
|
1320
|
-
html += `<div class="system-prompt">
|
|
1321
|
-
<div class="system-prompt-header">System Prompt</div>
|
|
1322
|
-
<div class="system-prompt-full" style="display: block">${escapeHtml(systemPrompt)}</div>
|
|
1323
|
-
</div>`;
|
|
1324
|
-
}
|
|
1325
|
-
}
|
|
1326
|
-
|
|
1327
|
-
if (tools && tools.length > 0) {
|
|
1328
|
-
html += `<div class="tools-list">
|
|
1329
|
-
<div class="tools-header">Available Tools</div>
|
|
1330
|
-
<div class="tools-content">
|
|
1331
|
-
${tools.map(t => {
|
|
1332
|
-
const hasParams = t.parameters && typeof t.parameters === 'object' && t.parameters.properties && Object.keys(t.parameters.properties).length > 0;
|
|
1333
|
-
if (!hasParams) {
|
|
1334
|
-
return `<div class="tool-item"><span class="tool-item-name">${escapeHtml(t.name)}</span> - <span class="tool-item-desc">${escapeHtml(t.description)}</span></div>`;
|
|
1335
|
-
}
|
|
1336
|
-
const params = t.parameters;
|
|
1337
|
-
const properties = params.properties;
|
|
1338
|
-
const required = params.required || [];
|
|
1339
|
-
let paramsHtml = '';
|
|
1340
|
-
for (const [name, prop] of Object.entries(properties)) {
|
|
1341
|
-
const isRequired = required.includes(name);
|
|
1342
|
-
const typeStr = prop.type || 'any';
|
|
1343
|
-
const reqLabel = isRequired ? '<span class="tool-param-required">required</span>' : '<span class="tool-param-optional">optional</span>';
|
|
1344
|
-
paramsHtml += `<div class="tool-param"><span class="tool-param-name">${escapeHtml(name)}</span> <span class="tool-param-type">${escapeHtml(typeStr)}</span> ${reqLabel}`;
|
|
1345
|
-
if (prop.description) {
|
|
1346
|
-
paramsHtml += `<div class="tool-param-desc">${escapeHtml(prop.description)}</div>`;
|
|
1347
|
-
}
|
|
1348
|
-
paramsHtml += `</div>`;
|
|
1349
|
-
}
|
|
1350
|
-
return `<div class="tool-item" onclick="this.classList.toggle('params-expanded')"><span class="tool-item-name">${escapeHtml(t.name)}</span> - <span class="tool-item-desc">${escapeHtml(t.description)}</span> <span class="tool-params-hint"></span><div class="tool-params-content">${paramsHtml}</div></div>`;
|
|
1351
|
-
}).join('')}
|
|
1352
|
-
</div>
|
|
1353
|
-
</div>`;
|
|
1354
|
-
}
|
|
1355
|
-
|
|
1356
|
-
return html;
|
|
1357
|
-
}
|
|
1358
|
-
|
|
1359
|
-
// ============================================================
|
|
1360
|
-
// NAVIGATION
|
|
1361
|
-
// ============================================================
|
|
1362
|
-
|
|
1363
|
-
// Cache for rendered entry DOM nodes
|
|
1364
|
-
const entryCache = new Map();
|
|
1365
|
-
|
|
1366
|
-
function renderEntryToNode(entry) {
|
|
1367
|
-
// Check cache first
|
|
1368
|
-
if (entryCache.has(entry.id)) {
|
|
1369
|
-
return entryCache.get(entry.id).cloneNode(true);
|
|
1370
|
-
}
|
|
1371
|
-
|
|
1372
|
-
// Render to HTML string, then parse to node
|
|
1373
|
-
const html = renderEntry(entry);
|
|
1374
|
-
if (!html) return null;
|
|
1375
|
-
|
|
1376
|
-
const template = document.createElement('template');
|
|
1377
|
-
template.innerHTML = html;
|
|
1378
|
-
const node = template.content.firstElementChild;
|
|
1379
|
-
|
|
1380
|
-
// Cache the node
|
|
1381
|
-
if (node) {
|
|
1382
|
-
entryCache.set(entry.id, node.cloneNode(true));
|
|
1383
|
-
}
|
|
1384
|
-
return node;
|
|
1385
|
-
}
|
|
1386
|
-
|
|
1387
|
-
function navigateTo(targetId, scrollMode = 'target', scrollToEntryId = null) {
|
|
1388
|
-
currentLeafId = targetId;
|
|
1389
|
-
currentTargetId = scrollToEntryId || targetId;
|
|
1390
|
-
const path = getPath(targetId);
|
|
1391
|
-
|
|
1392
|
-
renderTree();
|
|
1393
|
-
|
|
1394
|
-
document.getElementById('header-container').innerHTML = renderHeader();
|
|
1395
|
-
|
|
1396
|
-
// Build messages using cached DOM nodes
|
|
1397
|
-
const messagesEl = document.getElementById('messages');
|
|
1398
|
-
const fragment = document.createDocumentFragment();
|
|
1399
|
-
|
|
1400
|
-
for (const entry of path) {
|
|
1401
|
-
const node = renderEntryToNode(entry);
|
|
1402
|
-
if (node) {
|
|
1403
|
-
fragment.appendChild(node);
|
|
1404
|
-
}
|
|
1405
|
-
}
|
|
1406
|
-
|
|
1407
|
-
messagesEl.innerHTML = '';
|
|
1408
|
-
messagesEl.appendChild(fragment);
|
|
1409
|
-
|
|
1410
|
-
// Attach click handlers for copy-link buttons
|
|
1411
|
-
messagesEl.querySelectorAll('.copy-link-btn').forEach(btn => {
|
|
1412
|
-
btn.addEventListener('click', (e) => {
|
|
1413
|
-
e.stopPropagation();
|
|
1414
|
-
const entryId = btn.dataset.entryId;
|
|
1415
|
-
const shareUrl = buildShareUrl(entryId);
|
|
1416
|
-
copyToClipboard(shareUrl, btn);
|
|
1417
|
-
});
|
|
1418
|
-
});
|
|
1419
|
-
|
|
1420
|
-
// Use setTimeout(0) to ensure DOM is fully laid out before scrolling
|
|
1421
|
-
setTimeout(() => {
|
|
1422
|
-
const content = document.getElementById('content');
|
|
1423
|
-
if (scrollMode === 'bottom') {
|
|
1424
|
-
content.scrollTop = content.scrollHeight;
|
|
1425
|
-
} else if (scrollMode === 'target') {
|
|
1426
|
-
// If scrollToEntryId is provided, scroll to that specific entry
|
|
1427
|
-
const scrollTargetId = scrollToEntryId || targetId;
|
|
1428
|
-
const targetEl = document.getElementById(`entry-${scrollTargetId}`);
|
|
1429
|
-
if (targetEl) {
|
|
1430
|
-
targetEl.scrollIntoView({ block: 'center' });
|
|
1431
|
-
// Briefly highlight the target message
|
|
1432
|
-
if (scrollToEntryId) {
|
|
1433
|
-
targetEl.classList.add('highlight');
|
|
1434
|
-
setTimeout(() => targetEl.classList.remove('highlight'), 2000);
|
|
1435
|
-
}
|
|
1436
|
-
}
|
|
1437
|
-
}
|
|
1438
|
-
}, 0);
|
|
1439
|
-
}
|
|
1440
|
-
|
|
1441
|
-
// ============================================================
|
|
1442
|
-
// INITIALIZATION
|
|
1443
|
-
// ============================================================
|
|
1444
|
-
|
|
1445
|
-
// Escape HTML tags in text (but not code blocks)
|
|
1446
|
-
function escapeHtmlTags(text) {
|
|
1447
|
-
return text.replace(/<(?=[a-zA-Z\/])/g, '<');
|
|
1448
|
-
}
|
|
1449
|
-
|
|
1450
|
-
// Configure marked with syntax highlighting and HTML escaping for text
|
|
1451
|
-
marked.use({
|
|
1452
|
-
breaks: true,
|
|
1453
|
-
gfm: true,
|
|
1454
|
-
renderer: {
|
|
1455
|
-
// Code blocks: syntax highlight, no HTML escaping
|
|
1456
|
-
code(token) {
|
|
1457
|
-
const code = token.text;
|
|
1458
|
-
const lang = token.lang;
|
|
1459
|
-
let highlighted;
|
|
1460
|
-
if (lang && hljs.getLanguage(lang)) {
|
|
1461
|
-
try {
|
|
1462
|
-
highlighted = hljs.highlight(code, { language: lang }).value;
|
|
1463
|
-
} catch {
|
|
1464
|
-
highlighted = escapeHtml(code);
|
|
1465
|
-
}
|
|
1466
|
-
} else {
|
|
1467
|
-
// Auto-detect language if not specified
|
|
1468
|
-
try {
|
|
1469
|
-
highlighted = hljs.highlightAuto(code).value;
|
|
1470
|
-
} catch {
|
|
1471
|
-
highlighted = escapeHtml(code);
|
|
1472
|
-
}
|
|
1473
|
-
}
|
|
1474
|
-
return `<pre><code class="hljs">${highlighted}</code></pre>`;
|
|
1475
|
-
},
|
|
1476
|
-
// Text content: escape HTML tags
|
|
1477
|
-
text(token) {
|
|
1478
|
-
return escapeHtmlTags(escapeHtml(token.text));
|
|
1479
|
-
},
|
|
1480
|
-
// Inline code: escape HTML
|
|
1481
|
-
codespan(token) {
|
|
1482
|
-
return `<code>${escapeHtml(token.text)}</code>`;
|
|
1483
|
-
}
|
|
1484
|
-
}
|
|
1485
|
-
});
|
|
1486
|
-
|
|
1487
|
-
// Simple marked parse (escaping handled in renderers)
|
|
1488
|
-
function safeMarkedParse(text) {
|
|
1489
|
-
return marked.parse(text);
|
|
1490
|
-
}
|
|
1491
|
-
|
|
1492
|
-
// Search input
|
|
1493
|
-
const searchInput = document.getElementById('tree-search');
|
|
1494
|
-
searchInput.addEventListener('input', (e) => {
|
|
1495
|
-
searchQuery = e.target.value;
|
|
1496
|
-
forceTreeRerender();
|
|
1497
|
-
});
|
|
1498
|
-
|
|
1499
|
-
// Filter buttons
|
|
1500
|
-
document.querySelectorAll('.filter-btn').forEach(btn => {
|
|
1501
|
-
btn.addEventListener('click', () => {
|
|
1502
|
-
document.querySelectorAll('.filter-btn').forEach(b => b.classList.remove('active'));
|
|
1503
|
-
btn.classList.add('active');
|
|
1504
|
-
filterMode = btn.dataset.filter;
|
|
1505
|
-
forceTreeRerender();
|
|
1506
|
-
});
|
|
1507
|
-
});
|
|
1508
|
-
|
|
1509
|
-
// Sidebar toggle
|
|
1510
|
-
const sidebar = document.getElementById('sidebar');
|
|
1511
|
-
const overlay = document.getElementById('sidebar-overlay');
|
|
1512
|
-
const hamburger = document.getElementById('hamburger');
|
|
1513
|
-
const sidebarResizer = document.getElementById('sidebar-resizer');
|
|
1514
|
-
const SIDEBAR_WIDTH_STORAGE_KEY = 'pi-share:v1:sidebar-width';
|
|
1515
|
-
const MIN_CONTENT_WIDTH = 320;
|
|
1516
|
-
|
|
1517
|
-
function isMobileLayout() {
|
|
1518
|
-
return window.matchMedia('(max-width: 900px)').matches;
|
|
1519
|
-
}
|
|
1520
|
-
|
|
1521
|
-
function getSidebarBounds() {
|
|
1522
|
-
const rootStyles = getComputedStyle(document.documentElement);
|
|
1523
|
-
const minWidth = parseFloat(rootStyles.getPropertyValue('--sidebar-min-width')) || 240;
|
|
1524
|
-
const maxWidth = parseFloat(rootStyles.getPropertyValue('--sidebar-max-width')) || 720;
|
|
1525
|
-
const viewportMaxWidth = window.innerWidth - MIN_CONTENT_WIDTH;
|
|
1526
|
-
return {
|
|
1527
|
-
minWidth,
|
|
1528
|
-
maxWidth: Math.max(minWidth, Math.min(maxWidth, viewportMaxWidth))
|
|
1529
|
-
};
|
|
1530
|
-
}
|
|
1531
|
-
|
|
1532
|
-
function clampSidebarWidth(width) {
|
|
1533
|
-
const { minWidth, maxWidth } = getSidebarBounds();
|
|
1534
|
-
return Math.max(minWidth, Math.min(maxWidth, width));
|
|
1535
|
-
}
|
|
1536
|
-
|
|
1537
|
-
function applySidebarWidth(width) {
|
|
1538
|
-
document.documentElement.style.setProperty('--sidebar-width', `${Math.round(clampSidebarWidth(width))}px`);
|
|
1539
|
-
}
|
|
1540
|
-
|
|
1541
|
-
function loadSidebarWidth() {
|
|
1542
|
-
try {
|
|
1543
|
-
const raw = localStorage.getItem(SIDEBAR_WIDTH_STORAGE_KEY);
|
|
1544
|
-
if (raw === null) return null;
|
|
1545
|
-
const width = Number(raw);
|
|
1546
|
-
return Number.isFinite(width) ? width : null;
|
|
1547
|
-
} catch {
|
|
1548
|
-
return null;
|
|
1549
|
-
}
|
|
1550
|
-
}
|
|
1551
|
-
|
|
1552
|
-
function saveSidebarWidth(width) {
|
|
1553
|
-
try {
|
|
1554
|
-
localStorage.setItem(SIDEBAR_WIDTH_STORAGE_KEY, String(Math.round(clampSidebarWidth(width))));
|
|
1555
|
-
} catch {
|
|
1556
|
-
// Ignore storage failures (e.g. private browsing restrictions)
|
|
1557
|
-
}
|
|
1558
|
-
}
|
|
1559
|
-
|
|
1560
|
-
function setupSidebarResize() {
|
|
1561
|
-
const savedWidth = loadSidebarWidth();
|
|
1562
|
-
if (savedWidth !== null) {
|
|
1563
|
-
applySidebarWidth(savedWidth);
|
|
1564
|
-
}
|
|
1565
|
-
|
|
1566
|
-
if (!sidebarResizer) return;
|
|
1567
|
-
|
|
1568
|
-
let cleanupDrag = null;
|
|
1569
|
-
|
|
1570
|
-
const stopDrag = (pointerId) => {
|
|
1571
|
-
if (cleanupDrag) {
|
|
1572
|
-
cleanupDrag(pointerId);
|
|
1573
|
-
cleanupDrag = null;
|
|
1574
|
-
}
|
|
1575
|
-
};
|
|
1576
|
-
|
|
1577
|
-
sidebarResizer.addEventListener('pointerdown', (e) => {
|
|
1578
|
-
if (isMobileLayout()) return;
|
|
1579
|
-
|
|
1580
|
-
e.preventDefault();
|
|
1581
|
-
const startX = e.clientX;
|
|
1582
|
-
const startWidth = sidebar.getBoundingClientRect().width;
|
|
1583
|
-
document.body.classList.add('sidebar-resizing');
|
|
1584
|
-
sidebarResizer.setPointerCapture?.(e.pointerId);
|
|
1585
|
-
|
|
1586
|
-
const onPointerMove = (event) => {
|
|
1587
|
-
applySidebarWidth(startWidth + (event.clientX - startX));
|
|
1588
|
-
};
|
|
1589
|
-
|
|
1590
|
-
cleanupDrag = (pointerIdToRelease) => {
|
|
1591
|
-
document.body.classList.remove('sidebar-resizing');
|
|
1592
|
-
sidebarResizer.releasePointerCapture?.(pointerIdToRelease);
|
|
1593
|
-
window.removeEventListener('pointermove', onPointerMove);
|
|
1594
|
-
window.removeEventListener('pointerup', onPointerUp);
|
|
1595
|
-
window.removeEventListener('pointercancel', onPointerCancel);
|
|
1596
|
-
saveSidebarWidth(sidebar.getBoundingClientRect().width);
|
|
1597
|
-
};
|
|
1598
|
-
|
|
1599
|
-
const onPointerUp = (event) => stopDrag(event.pointerId);
|
|
1600
|
-
const onPointerCancel = (event) => stopDrag(event.pointerId);
|
|
1601
|
-
|
|
1602
|
-
window.addEventListener('pointermove', onPointerMove);
|
|
1603
|
-
window.addEventListener('pointerup', onPointerUp);
|
|
1604
|
-
window.addEventListener('pointercancel', onPointerCancel);
|
|
1605
|
-
});
|
|
1606
|
-
|
|
1607
|
-
sidebarResizer.addEventListener('dblclick', () => {
|
|
1608
|
-
if (isMobileLayout()) return;
|
|
1609
|
-
applySidebarWidth(400);
|
|
1610
|
-
saveSidebarWidth(400);
|
|
1611
|
-
});
|
|
1612
|
-
|
|
1613
|
-
window.addEventListener('resize', () => {
|
|
1614
|
-
if (isMobileLayout()) return;
|
|
1615
|
-
applySidebarWidth(sidebar.getBoundingClientRect().width);
|
|
1616
|
-
});
|
|
1617
|
-
}
|
|
1618
|
-
|
|
1619
|
-
setupSidebarResize();
|
|
1620
|
-
|
|
1621
|
-
hamburger.addEventListener('click', () => {
|
|
1622
|
-
sidebar.classList.add('open');
|
|
1623
|
-
overlay.classList.add('open');
|
|
1624
|
-
hamburger.style.display = 'none';
|
|
1625
|
-
});
|
|
1626
|
-
|
|
1627
|
-
const closeSidebar = () => {
|
|
1628
|
-
sidebar.classList.remove('open');
|
|
1629
|
-
overlay.classList.remove('open');
|
|
1630
|
-
hamburger.style.display = '';
|
|
1631
|
-
};
|
|
1632
|
-
|
|
1633
|
-
overlay.addEventListener('click', closeSidebar);
|
|
1634
|
-
document.getElementById('sidebar-close').addEventListener('click', closeSidebar);
|
|
1635
|
-
|
|
1636
|
-
// Toggle states
|
|
1637
|
-
let thinkingExpanded = true;
|
|
1638
|
-
let toolOutputsExpanded = false;
|
|
1639
|
-
|
|
1640
|
-
const toggleThinking = () => {
|
|
1641
|
-
thinkingExpanded = !thinkingExpanded;
|
|
1642
|
-
document.querySelectorAll('.thinking-text').forEach(el => {
|
|
1643
|
-
el.style.display = thinkingExpanded ? '' : 'none';
|
|
1644
|
-
});
|
|
1645
|
-
document.querySelectorAll('.thinking-collapsed').forEach(el => {
|
|
1646
|
-
el.style.display = thinkingExpanded ? 'none' : 'block';
|
|
1647
|
-
});
|
|
1648
|
-
};
|
|
1649
|
-
|
|
1650
|
-
const toggleToolOutputs = () => {
|
|
1651
|
-
toolOutputsExpanded = !toolOutputsExpanded;
|
|
1652
|
-
document.querySelectorAll('.tool-output.expandable').forEach(el => {
|
|
1653
|
-
el.classList.toggle('expanded', toolOutputsExpanded);
|
|
1654
|
-
});
|
|
1655
|
-
document.querySelectorAll('.compaction').forEach(el => {
|
|
1656
|
-
el.classList.toggle('expanded', toolOutputsExpanded);
|
|
1657
|
-
});
|
|
1658
|
-
};
|
|
1659
|
-
|
|
1660
|
-
// Keyboard shortcuts
|
|
1661
|
-
document.addEventListener('keydown', (e) => {
|
|
1662
|
-
if (e.key === 'Escape') {
|
|
1663
|
-
searchInput.value = '';
|
|
1664
|
-
searchQuery = '';
|
|
1665
|
-
navigateTo(leafId, 'bottom');
|
|
1666
|
-
}
|
|
1667
|
-
if (e.ctrlKey && e.key === 't') {
|
|
1668
|
-
e.preventDefault();
|
|
1669
|
-
toggleThinking();
|
|
1670
|
-
}
|
|
1671
|
-
if (e.ctrlKey && e.key === 'o') {
|
|
1672
|
-
e.preventDefault();
|
|
1673
|
-
toggleToolOutputs();
|
|
1674
|
-
}
|
|
1675
|
-
});
|
|
1676
|
-
|
|
1677
|
-
// Initial render
|
|
1678
|
-
// If URL has targetId, scroll to that specific message; otherwise stay at top
|
|
1679
|
-
if (leafId) {
|
|
1680
|
-
if (urlTargetId && byId.has(urlTargetId)) {
|
|
1681
|
-
// Deep link: navigate to leaf and scroll to target message
|
|
1682
|
-
navigateTo(leafId, 'target', urlTargetId);
|
|
1683
|
-
} else {
|
|
1684
|
-
navigateTo(leafId, 'none');
|
|
1685
|
-
}
|
|
1686
|
-
} else if (entries.length > 0) {
|
|
1687
|
-
// Fallback: use last entry if no leafId
|
|
1688
|
-
navigateTo(entries[entries.length - 1].id, 'none');
|
|
1689
|
-
}
|
|
1690
|
-
})();
|