iosm-cli 0.1.0
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 +55 -0
- package/LICENSE +21 -0
- package/README.md +650 -0
- package/dist/cli/args.d.ts +54 -0
- package/dist/cli/args.d.ts.map +1 -0
- package/dist/cli/args.js +331 -0
- package/dist/cli/args.js.map +1 -0
- package/dist/cli/config-selector.d.ts +14 -0
- package/dist/cli/config-selector.d.ts.map +1 -0
- package/dist/cli/config-selector.js +31 -0
- package/dist/cli/config-selector.js.map +1 -0
- package/dist/cli/file-processor.d.ts +15 -0
- package/dist/cli/file-processor.d.ts.map +1 -0
- package/dist/cli/file-processor.js +79 -0
- package/dist/cli/file-processor.js.map +1 -0
- package/dist/cli/list-models.d.ts +9 -0
- package/dist/cli/list-models.d.ts.map +1 -0
- package/dist/cli/list-models.js +92 -0
- package/dist/cli/list-models.js.map +1 -0
- package/dist/cli/session-picker.d.ts +9 -0
- package/dist/cli/session-picker.d.ts.map +1 -0
- package/dist/cli/session-picker.js +34 -0
- package/dist/cli/session-picker.js.map +1 -0
- package/dist/cli.d.ts +3 -0
- package/dist/cli.d.ts.map +1 -0
- package/dist/cli.js +15 -0
- package/dist/cli.js.map +1 -0
- package/dist/config.d.ts +88 -0
- package/dist/config.d.ts.map +1 -0
- package/dist/config.js +262 -0
- package/dist/config.js.map +1 -0
- package/dist/core/agent-profiles.d.ts +29 -0
- package/dist/core/agent-profiles.d.ts.map +1 -0
- package/dist/core/agent-profiles.js +86 -0
- package/dist/core/agent-profiles.js.map +1 -0
- package/dist/core/agent-session.d.ts +688 -0
- package/dist/core/agent-session.d.ts.map +1 -0
- package/dist/core/agent-session.js +3112 -0
- package/dist/core/agent-session.js.map +1 -0
- package/dist/core/agent-teams.d.ts +41 -0
- package/dist/core/agent-teams.d.ts.map +1 -0
- package/dist/core/agent-teams.js +90 -0
- package/dist/core/agent-teams.js.map +1 -0
- package/dist/core/ask-user-tool.d.ts +22 -0
- package/dist/core/ask-user-tool.d.ts.map +1 -0
- package/dist/core/ask-user-tool.js +115 -0
- package/dist/core/ask-user-tool.js.map +1 -0
- package/dist/core/auth-storage.d.ts +133 -0
- package/dist/core/auth-storage.d.ts.map +1 -0
- package/dist/core/auth-storage.js +391 -0
- package/dist/core/auth-storage.js.map +1 -0
- package/dist/core/bash-executor.d.ts +49 -0
- package/dist/core/bash-executor.d.ts.map +1 -0
- package/dist/core/bash-executor.js +213 -0
- package/dist/core/bash-executor.js.map +1 -0
- package/dist/core/compaction/branch-summarization.d.ts +86 -0
- package/dist/core/compaction/branch-summarization.d.ts.map +1 -0
- package/dist/core/compaction/branch-summarization.js +242 -0
- package/dist/core/compaction/branch-summarization.js.map +1 -0
- package/dist/core/compaction/compaction.d.ts +121 -0
- package/dist/core/compaction/compaction.d.ts.map +1 -0
- package/dist/core/compaction/compaction.js +610 -0
- package/dist/core/compaction/compaction.js.map +1 -0
- package/dist/core/compaction/index.d.ts +7 -0
- package/dist/core/compaction/index.d.ts.map +1 -0
- package/dist/core/compaction/index.js +7 -0
- package/dist/core/compaction/index.js.map +1 -0
- package/dist/core/compaction/utils.d.ts +35 -0
- package/dist/core/compaction/utils.d.ts.map +1 -0
- package/dist/core/compaction/utils.js +138 -0
- package/dist/core/compaction/utils.js.map +1 -0
- package/dist/core/defaults.d.ts +3 -0
- package/dist/core/defaults.d.ts.map +1 -0
- package/dist/core/defaults.js +2 -0
- package/dist/core/defaults.js.map +1 -0
- package/dist/core/diagnostics.d.ts +15 -0
- package/dist/core/diagnostics.d.ts.map +1 -0
- package/dist/core/diagnostics.js +2 -0
- package/dist/core/diagnostics.js.map +1 -0
- package/dist/core/event-bus.d.ts +9 -0
- package/dist/core/event-bus.d.ts.map +1 -0
- package/dist/core/event-bus.js +25 -0
- package/dist/core/event-bus.js.map +1 -0
- package/dist/core/exec.d.ts +29 -0
- package/dist/core/exec.d.ts.map +1 -0
- package/dist/core/exec.js +71 -0
- package/dist/core/exec.js.map +1 -0
- package/dist/core/export-html/ansi-to-html.d.ts +22 -0
- package/dist/core/export-html/ansi-to-html.d.ts.map +1 -0
- package/dist/core/export-html/ansi-to-html.js +249 -0
- package/dist/core/export-html/ansi-to-html.js.map +1 -0
- package/dist/core/export-html/index.d.ts +34 -0
- package/dist/core/export-html/index.d.ts.map +1 -0
- package/dist/core/export-html/index.js +222 -0
- package/dist/core/export-html/index.js.map +1 -0
- package/dist/core/export-html/template.css +971 -0
- package/dist/core/export-html/template.html +54 -0
- package/dist/core/export-html/template.js +1590 -0
- package/dist/core/export-html/tool-renderer.d.ts +35 -0
- package/dist/core/export-html/tool-renderer.d.ts.map +1 -0
- package/dist/core/export-html/tool-renderer.js +63 -0
- package/dist/core/export-html/tool-renderer.js.map +1 -0
- package/dist/core/export-html/vendor/highlight.min.js +1213 -0
- package/dist/core/export-html/vendor/marked.min.js +6 -0
- package/dist/core/extensions/index.d.ts +11 -0
- package/dist/core/extensions/index.d.ts.map +1 -0
- package/dist/core/extensions/index.js +9 -0
- package/dist/core/extensions/index.js.map +1 -0
- package/dist/core/extensions/loader.d.ts +25 -0
- package/dist/core/extensions/loader.d.ts.map +1 -0
- package/dist/core/extensions/loader.js +447 -0
- package/dist/core/extensions/loader.js.map +1 -0
- package/dist/core/extensions/runner.d.ts +146 -0
- package/dist/core/extensions/runner.d.ts.map +1 -0
- package/dist/core/extensions/runner.js +652 -0
- package/dist/core/extensions/runner.js.map +1 -0
- package/dist/core/extensions/types.d.ts +1074 -0
- package/dist/core/extensions/types.d.ts.map +1 -0
- package/dist/core/extensions/types.js +35 -0
- package/dist/core/extensions/types.js.map +1 -0
- package/dist/core/extensions/wrapper.d.ts +27 -0
- package/dist/core/extensions/wrapper.d.ts.map +1 -0
- package/dist/core/extensions/wrapper.js +102 -0
- package/dist/core/extensions/wrapper.js.map +1 -0
- package/dist/core/footer-data-provider.d.ts +32 -0
- package/dist/core/footer-data-provider.d.ts.map +1 -0
- package/dist/core/footer-data-provider.js +134 -0
- package/dist/core/footer-data-provider.js.map +1 -0
- package/dist/core/hooks.d.ts +53 -0
- package/dist/core/hooks.d.ts.map +1 -0
- package/dist/core/hooks.js +332 -0
- package/dist/core/hooks.js.map +1 -0
- package/dist/core/index.d.ts +9 -0
- package/dist/core/index.d.ts.map +1 -0
- package/dist/core/index.js +9 -0
- package/dist/core/index.js.map +1 -0
- package/dist/core/keybindings.d.ts +55 -0
- package/dist/core/keybindings.d.ts.map +1 -0
- package/dist/core/keybindings.js +157 -0
- package/dist/core/keybindings.js.map +1 -0
- package/dist/core/mcp/cli.d.ts +27 -0
- package/dist/core/mcp/cli.d.ts.map +1 -0
- package/dist/core/mcp/cli.js +275 -0
- package/dist/core/mcp/cli.js.map +1 -0
- package/dist/core/mcp/config.d.ts +11 -0
- package/dist/core/mcp/config.d.ts.map +1 -0
- package/dist/core/mcp/config.js +310 -0
- package/dist/core/mcp/config.js.map +1 -0
- package/dist/core/mcp/index.d.ts +5 -0
- package/dist/core/mcp/index.d.ts.map +1 -0
- package/dist/core/mcp/index.js +4 -0
- package/dist/core/mcp/index.js.map +1 -0
- package/dist/core/mcp/runtime.d.ts +42 -0
- package/dist/core/mcp/runtime.d.ts.map +1 -0
- package/dist/core/mcp/runtime.js +387 -0
- package/dist/core/mcp/runtime.js.map +1 -0
- package/dist/core/mcp/types.d.ts +76 -0
- package/dist/core/mcp/types.d.ts.map +1 -0
- package/dist/core/mcp/types.js +2 -0
- package/dist/core/mcp/types.js.map +1 -0
- package/dist/core/memory.d.ts +27 -0
- package/dist/core/memory.d.ts.map +1 -0
- package/dist/core/memory.js +203 -0
- package/dist/core/memory.js.map +1 -0
- package/dist/core/messages.d.ts +84 -0
- package/dist/core/messages.d.ts.map +1 -0
- package/dist/core/messages.js +141 -0
- package/dist/core/messages.js.map +1 -0
- package/dist/core/model-registry.d.ts +115 -0
- package/dist/core/model-registry.d.ts.map +1 -0
- package/dist/core/model-registry.js +549 -0
- package/dist/core/model-registry.js.map +1 -0
- package/dist/core/model-resolver.d.ts +104 -0
- package/dist/core/model-resolver.d.ts.map +1 -0
- package/dist/core/model-resolver.js +448 -0
- package/dist/core/model-resolver.js.map +1 -0
- package/dist/core/package-manager.d.ts +156 -0
- package/dist/core/package-manager.d.ts.map +1 -0
- package/dist/core/package-manager.js +1465 -0
- package/dist/core/package-manager.js.map +1 -0
- package/dist/core/parallel-task-agent.d.ts +19 -0
- package/dist/core/parallel-task-agent.d.ts.map +1 -0
- package/dist/core/parallel-task-agent.js +482 -0
- package/dist/core/parallel-task-agent.js.map +1 -0
- package/dist/core/prompt-templates.d.ts +50 -0
- package/dist/core/prompt-templates.d.ts.map +1 -0
- package/dist/core/prompt-templates.js +251 -0
- package/dist/core/prompt-templates.js.map +1 -0
- package/dist/core/qwen-cli-provider.d.ts +10 -0
- package/dist/core/qwen-cli-provider.d.ts.map +1 -0
- package/dist/core/qwen-cli-provider.js +271 -0
- package/dist/core/qwen-cli-provider.js.map +1 -0
- package/dist/core/resolve-config-value.d.ts +17 -0
- package/dist/core/resolve-config-value.d.ts.map +1 -0
- package/dist/core/resolve-config-value.js +60 -0
- package/dist/core/resolve-config-value.js.map +1 -0
- package/dist/core/resource-loader.d.ts +195 -0
- package/dist/core/resource-loader.d.ts.map +1 -0
- package/dist/core/resource-loader.js +820 -0
- package/dist/core/resource-loader.js.map +1 -0
- package/dist/core/sdk.d.ts +106 -0
- package/dist/core/sdk.d.ts.map +1 -0
- package/dist/core/sdk.js +460 -0
- package/dist/core/sdk.js.map +1 -0
- package/dist/core/session-manager.d.ts +323 -0
- package/dist/core/session-manager.d.ts.map +1 -0
- package/dist/core/session-manager.js +1094 -0
- package/dist/core/session-manager.js.map +1 -0
- package/dist/core/settings-manager.d.ts +243 -0
- package/dist/core/settings-manager.d.ts.map +1 -0
- package/dist/core/settings-manager.js +691 -0
- package/dist/core/settings-manager.js.map +1 -0
- package/dist/core/skills.d.ts +58 -0
- package/dist/core/skills.d.ts.map +1 -0
- package/dist/core/skills.js +364 -0
- package/dist/core/skills.js.map +1 -0
- package/dist/core/slash-commands.d.ts +15 -0
- package/dist/core/slash-commands.d.ts.map +1 -0
- package/dist/core/slash-commands.js +64 -0
- package/dist/core/slash-commands.js.map +1 -0
- package/dist/core/subagent-runs.d.ts +16 -0
- package/dist/core/subagent-runs.d.ts.map +1 -0
- package/dist/core/subagent-runs.js +70 -0
- package/dist/core/subagent-runs.js.map +1 -0
- package/dist/core/subagents.d.ts +45 -0
- package/dist/core/subagents.d.ts.map +1 -0
- package/dist/core/subagents.js +467 -0
- package/dist/core/subagents.js.map +1 -0
- package/dist/core/system-prompt.d.ts +28 -0
- package/dist/core/system-prompt.d.ts.map +1 -0
- package/dist/core/system-prompt.js +196 -0
- package/dist/core/system-prompt.js.map +1 -0
- package/dist/core/task-plan.d.ts +32 -0
- package/dist/core/task-plan.d.ts.map +1 -0
- package/dist/core/task-plan.js +155 -0
- package/dist/core/task-plan.js.map +1 -0
- package/dist/core/timings.d.ts +7 -0
- package/dist/core/timings.d.ts.map +1 -0
- package/dist/core/timings.js +26 -0
- package/dist/core/timings.js.map +1 -0
- package/dist/core/tools/bash.d.ts +58 -0
- package/dist/core/tools/bash.d.ts.map +1 -0
- package/dist/core/tools/bash.js +275 -0
- package/dist/core/tools/bash.js.map +1 -0
- package/dist/core/tools/edit-diff.d.ts +63 -0
- package/dist/core/tools/edit-diff.d.ts.map +1 -0
- package/dist/core/tools/edit-diff.js +243 -0
- package/dist/core/tools/edit-diff.js.map +1 -0
- package/dist/core/tools/edit.d.ts +42 -0
- package/dist/core/tools/edit.d.ts.map +1 -0
- package/dist/core/tools/edit.js +158 -0
- package/dist/core/tools/edit.js.map +1 -0
- package/dist/core/tools/find.d.ts +39 -0
- package/dist/core/tools/find.d.ts.map +1 -0
- package/dist/core/tools/find.js +219 -0
- package/dist/core/tools/find.js.map +1 -0
- package/dist/core/tools/grep.d.ts +45 -0
- package/dist/core/tools/grep.d.ts.map +1 -0
- package/dist/core/tools/grep.js +254 -0
- package/dist/core/tools/grep.js.map +1 -0
- package/dist/core/tools/ignore-filter.d.ts +5 -0
- package/dist/core/tools/ignore-filter.d.ts.map +1 -0
- package/dist/core/tools/ignore-filter.js +97 -0
- package/dist/core/tools/ignore-filter.js.map +1 -0
- package/dist/core/tools/index.d.ts +97 -0
- package/dist/core/tools/index.d.ts.map +1 -0
- package/dist/core/tools/index.js +78 -0
- package/dist/core/tools/index.js.map +1 -0
- package/dist/core/tools/ls.d.ts +46 -0
- package/dist/core/tools/ls.d.ts.map +1 -0
- package/dist/core/tools/ls.js +136 -0
- package/dist/core/tools/ls.js.map +1 -0
- package/dist/core/tools/path-utils.d.ts +8 -0
- package/dist/core/tools/path-utils.d.ts.map +1 -0
- package/dist/core/tools/path-utils.js +81 -0
- package/dist/core/tools/path-utils.js.map +1 -0
- package/dist/core/tools/permissions.d.ts +8 -0
- package/dist/core/tools/permissions.d.ts.map +1 -0
- package/dist/core/tools/permissions.js +2 -0
- package/dist/core/tools/permissions.js.map +1 -0
- package/dist/core/tools/read.d.ts +39 -0
- package/dist/core/tools/read.d.ts.map +1 -0
- package/dist/core/tools/read.js +166 -0
- package/dist/core/tools/read.js.map +1 -0
- package/dist/core/tools/task.d.ts +109 -0
- package/dist/core/tools/task.d.ts.map +1 -0
- package/dist/core/tools/task.js +1065 -0
- package/dist/core/tools/task.js.map +1 -0
- package/dist/core/tools/todo.d.ts +42 -0
- package/dist/core/tools/todo.d.ts.map +1 -0
- package/dist/core/tools/todo.js +159 -0
- package/dist/core/tools/todo.js.map +1 -0
- package/dist/core/tools/truncate.d.ts +70 -0
- package/dist/core/tools/truncate.d.ts.map +1 -0
- package/dist/core/tools/truncate.js +205 -0
- package/dist/core/tools/truncate.js.map +1 -0
- package/dist/core/tools/write.d.ts +32 -0
- package/dist/core/tools/write.d.ts.map +1 -0
- package/dist/core/tools/write.js +90 -0
- package/dist/core/tools/write.js.map +1 -0
- package/dist/index.d.ts +30 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +45 -0
- package/dist/index.js.map +1 -0
- package/dist/iosm/agent-verification.d.ts +16 -0
- package/dist/iosm/agent-verification.d.ts.map +1 -0
- package/dist/iosm/agent-verification.js +138 -0
- package/dist/iosm/agent-verification.js.map +1 -0
- package/dist/iosm/automation.d.ts +40 -0
- package/dist/iosm/automation.d.ts.map +1 -0
- package/dist/iosm/automation.js +76 -0
- package/dist/iosm/automation.js.map +1 -0
- package/dist/iosm/config.d.ts +151 -0
- package/dist/iosm/config.d.ts.map +1 -0
- package/dist/iosm/config.js +323 -0
- package/dist/iosm/config.js.map +1 -0
- package/dist/iosm/context-loader.d.ts +12 -0
- package/dist/iosm/context-loader.d.ts.map +1 -0
- package/dist/iosm/context-loader.js +50 -0
- package/dist/iosm/context-loader.js.map +1 -0
- package/dist/iosm/cycle.d.ts +51 -0
- package/dist/iosm/cycle.d.ts.map +1 -0
- package/dist/iosm/cycle.js +861 -0
- package/dist/iosm/cycle.js.map +1 -0
- package/dist/iosm/guide.d.ts +31 -0
- package/dist/iosm/guide.d.ts.map +1 -0
- package/dist/iosm/guide.js +101 -0
- package/dist/iosm/guide.js.map +1 -0
- package/dist/iosm/index.d.ts +12 -0
- package/dist/iosm/index.d.ts.map +1 -0
- package/dist/iosm/index.js +11 -0
- package/dist/iosm/index.js.map +1 -0
- package/dist/iosm/init.d.ts +58 -0
- package/dist/iosm/init.d.ts.map +1 -0
- package/dist/iosm/init.js +1221 -0
- package/dist/iosm/init.js.map +1 -0
- package/dist/iosm/metrics.d.ts +23 -0
- package/dist/iosm/metrics.d.ts.map +1 -0
- package/dist/iosm/metrics.js +336 -0
- package/dist/iosm/metrics.js.map +1 -0
- package/dist/iosm/paths.d.ts +24 -0
- package/dist/iosm/paths.d.ts.map +1 -0
- package/dist/iosm/paths.js +77 -0
- package/dist/iosm/paths.js.map +1 -0
- package/dist/iosm/runtime-context.d.ts +20 -0
- package/dist/iosm/runtime-context.d.ts.map +1 -0
- package/dist/iosm/runtime-context.js +170 -0
- package/dist/iosm/runtime-context.js.map +1 -0
- package/dist/iosm/types.d.ts +151 -0
- package/dist/iosm/types.d.ts.map +1 -0
- package/dist/iosm/types.js +3 -0
- package/dist/iosm/types.js.map +1 -0
- package/dist/main.d.ts +8 -0
- package/dist/main.d.ts.map +1 -0
- package/dist/main.js +1478 -0
- package/dist/main.js.map +1 -0
- package/dist/migrations.d.ts +33 -0
- package/dist/migrations.d.ts.map +1 -0
- package/dist/migrations.js +261 -0
- package/dist/migrations.js.map +1 -0
- package/dist/modes/index.d.ts +9 -0
- package/dist/modes/index.d.ts.map +1 -0
- package/dist/modes/index.js +8 -0
- package/dist/modes/index.js.map +1 -0
- package/dist/modes/interactive/components/armin.d.ts +34 -0
- package/dist/modes/interactive/components/armin.d.ts.map +1 -0
- package/dist/modes/interactive/components/armin.js +329 -0
- package/dist/modes/interactive/components/armin.js.map +1 -0
- package/dist/modes/interactive/components/ascii-logo.d.ts +11 -0
- package/dist/modes/interactive/components/ascii-logo.d.ts.map +1 -0
- package/dist/modes/interactive/components/ascii-logo.js +25 -0
- package/dist/modes/interactive/components/ascii-logo.js.map +1 -0
- package/dist/modes/interactive/components/assistant-message.d.ts +16 -0
- package/dist/modes/interactive/components/assistant-message.d.ts.map +1 -0
- package/dist/modes/interactive/components/assistant-message.js +92 -0
- package/dist/modes/interactive/components/assistant-message.js.map +1 -0
- package/dist/modes/interactive/components/bash-execution.d.ts +36 -0
- package/dist/modes/interactive/components/bash-execution.d.ts.map +1 -0
- package/dist/modes/interactive/components/bash-execution.js +170 -0
- package/dist/modes/interactive/components/bash-execution.js.map +1 -0
- package/dist/modes/interactive/components/bordered-loader.d.ts +16 -0
- package/dist/modes/interactive/components/bordered-loader.d.ts.map +1 -0
- package/dist/modes/interactive/components/bordered-loader.js +48 -0
- package/dist/modes/interactive/components/bordered-loader.js.map +1 -0
- package/dist/modes/interactive/components/branch-summary-message.d.ts +16 -0
- package/dist/modes/interactive/components/branch-summary-message.d.ts.map +1 -0
- package/dist/modes/interactive/components/branch-summary-message.js +42 -0
- package/dist/modes/interactive/components/branch-summary-message.js.map +1 -0
- package/dist/modes/interactive/components/compaction-summary-message.d.ts +16 -0
- package/dist/modes/interactive/components/compaction-summary-message.d.ts.map +1 -0
- package/dist/modes/interactive/components/compaction-summary-message.js +43 -0
- package/dist/modes/interactive/components/compaction-summary-message.js.map +1 -0
- package/dist/modes/interactive/components/config-selector.d.ts +71 -0
- package/dist/modes/interactive/components/config-selector.d.ts.map +1 -0
- package/dist/modes/interactive/components/config-selector.js +470 -0
- package/dist/modes/interactive/components/config-selector.js.map +1 -0
- package/dist/modes/interactive/components/countdown-timer.d.ts +14 -0
- package/dist/modes/interactive/components/countdown-timer.d.ts.map +1 -0
- package/dist/modes/interactive/components/countdown-timer.js +28 -0
- package/dist/modes/interactive/components/countdown-timer.js.map +1 -0
- package/dist/modes/interactive/components/custom-editor.d.ts +21 -0
- package/dist/modes/interactive/components/custom-editor.d.ts.map +1 -0
- package/dist/modes/interactive/components/custom-editor.js +63 -0
- package/dist/modes/interactive/components/custom-editor.js.map +1 -0
- package/dist/modes/interactive/components/custom-message.d.ts +20 -0
- package/dist/modes/interactive/components/custom-message.d.ts.map +1 -0
- package/dist/modes/interactive/components/custom-message.js +74 -0
- package/dist/modes/interactive/components/custom-message.js.map +1 -0
- package/dist/modes/interactive/components/daxnuts.d.ts +23 -0
- package/dist/modes/interactive/components/daxnuts.d.ts.map +1 -0
- package/dist/modes/interactive/components/daxnuts.js +138 -0
- package/dist/modes/interactive/components/daxnuts.js.map +1 -0
- package/dist/modes/interactive/components/decrypt-loader.d.ts +25 -0
- package/dist/modes/interactive/components/decrypt-loader.d.ts.map +1 -0
- package/dist/modes/interactive/components/decrypt-loader.js +102 -0
- package/dist/modes/interactive/components/decrypt-loader.js.map +1 -0
- package/dist/modes/interactive/components/diff.d.ts +12 -0
- package/dist/modes/interactive/components/diff.d.ts.map +1 -0
- package/dist/modes/interactive/components/diff.js +133 -0
- package/dist/modes/interactive/components/diff.js.map +1 -0
- package/dist/modes/interactive/components/dynamic-border.d.ts +15 -0
- package/dist/modes/interactive/components/dynamic-border.d.ts.map +1 -0
- package/dist/modes/interactive/components/dynamic-border.js +20 -0
- package/dist/modes/interactive/components/dynamic-border.js.map +1 -0
- package/dist/modes/interactive/components/extension-editor.d.ts +20 -0
- package/dist/modes/interactive/components/extension-editor.d.ts.map +1 -0
- package/dist/modes/interactive/components/extension-editor.js +105 -0
- package/dist/modes/interactive/components/extension-editor.js.map +1 -0
- package/dist/modes/interactive/components/extension-input.d.ts +23 -0
- package/dist/modes/interactive/components/extension-input.d.ts.map +1 -0
- package/dist/modes/interactive/components/extension-input.js +55 -0
- package/dist/modes/interactive/components/extension-input.js.map +1 -0
- package/dist/modes/interactive/components/extension-selector.d.ts +24 -0
- package/dist/modes/interactive/components/extension-selector.d.ts.map +1 -0
- package/dist/modes/interactive/components/extension-selector.js +71 -0
- package/dist/modes/interactive/components/extension-selector.js.map +1 -0
- package/dist/modes/interactive/components/footer.d.ts +39 -0
- package/dist/modes/interactive/components/footer.d.ts.map +1 -0
- package/dist/modes/interactive/components/footer.js +285 -0
- package/dist/modes/interactive/components/footer.js.map +1 -0
- package/dist/modes/interactive/components/index.d.ts +33 -0
- package/dist/modes/interactive/components/index.d.ts.map +1 -0
- package/dist/modes/interactive/components/index.js +34 -0
- package/dist/modes/interactive/components/index.js.map +1 -0
- package/dist/modes/interactive/components/keybinding-hints.d.ts +50 -0
- package/dist/modes/interactive/components/keybinding-hints.d.ts.map +1 -0
- package/dist/modes/interactive/components/keybinding-hints.js +85 -0
- package/dist/modes/interactive/components/keybinding-hints.js.map +1 -0
- package/dist/modes/interactive/components/login-dialog.d.ts +42 -0
- package/dist/modes/interactive/components/login-dialog.d.ts.map +1 -0
- package/dist/modes/interactive/components/login-dialog.js +139 -0
- package/dist/modes/interactive/components/login-dialog.js.map +1 -0
- package/dist/modes/interactive/components/mcp-selector.d.ts +31 -0
- package/dist/modes/interactive/components/mcp-selector.d.ts.map +1 -0
- package/dist/modes/interactive/components/mcp-selector.js +171 -0
- package/dist/modes/interactive/components/mcp-selector.js.map +1 -0
- package/dist/modes/interactive/components/model-selector.d.ts +51 -0
- package/dist/modes/interactive/components/model-selector.d.ts.map +1 -0
- package/dist/modes/interactive/components/model-selector.js +292 -0
- package/dist/modes/interactive/components/model-selector.js.map +1 -0
- package/dist/modes/interactive/components/oauth-selector.d.ts +19 -0
- package/dist/modes/interactive/components/oauth-selector.d.ts.map +1 -0
- package/dist/modes/interactive/components/oauth-selector.js +134 -0
- package/dist/modes/interactive/components/oauth-selector.js.map +1 -0
- package/dist/modes/interactive/components/scoped-models-selector.d.ts +49 -0
- package/dist/modes/interactive/components/scoped-models-selector.d.ts.map +1 -0
- package/dist/modes/interactive/components/scoped-models-selector.js +271 -0
- package/dist/modes/interactive/components/scoped-models-selector.js.map +1 -0
- package/dist/modes/interactive/components/session-selector-search.d.ts +23 -0
- package/dist/modes/interactive/components/session-selector-search.d.ts.map +1 -0
- package/dist/modes/interactive/components/session-selector-search.js +155 -0
- package/dist/modes/interactive/components/session-selector-search.js.map +1 -0
- package/dist/modes/interactive/components/session-selector.d.ts +95 -0
- package/dist/modes/interactive/components/session-selector.d.ts.map +1 -0
- package/dist/modes/interactive/components/session-selector.js +839 -0
- package/dist/modes/interactive/components/session-selector.js.map +1 -0
- package/dist/modes/interactive/components/settings-selector.d.ts +60 -0
- package/dist/modes/interactive/components/settings-selector.d.ts.map +1 -0
- package/dist/modes/interactive/components/settings-selector.js +311 -0
- package/dist/modes/interactive/components/settings-selector.js.map +1 -0
- package/dist/modes/interactive/components/show-images-selector.d.ts +10 -0
- package/dist/modes/interactive/components/show-images-selector.d.ts.map +1 -0
- package/dist/modes/interactive/components/show-images-selector.js +34 -0
- package/dist/modes/interactive/components/show-images-selector.js.map +1 -0
- package/dist/modes/interactive/components/skill-invocation-message.d.ts +17 -0
- package/dist/modes/interactive/components/skill-invocation-message.d.ts.map +1 -0
- package/dist/modes/interactive/components/skill-invocation-message.js +45 -0
- package/dist/modes/interactive/components/skill-invocation-message.js.map +1 -0
- package/dist/modes/interactive/components/subagent-message.d.ts +91 -0
- package/dist/modes/interactive/components/subagent-message.d.ts.map +1 -0
- package/dist/modes/interactive/components/subagent-message.js +306 -0
- package/dist/modes/interactive/components/subagent-message.js.map +1 -0
- package/dist/modes/interactive/components/task-plan-message.d.ts +12 -0
- package/dist/modes/interactive/components/task-plan-message.d.ts.map +1 -0
- package/dist/modes/interactive/components/task-plan-message.js +61 -0
- package/dist/modes/interactive/components/task-plan-message.js.map +1 -0
- package/dist/modes/interactive/components/theme-selector.d.ts +11 -0
- package/dist/modes/interactive/components/theme-selector.d.ts.map +1 -0
- package/dist/modes/interactive/components/theme-selector.js +44 -0
- package/dist/modes/interactive/components/theme-selector.js.map +1 -0
- package/dist/modes/interactive/components/thinking-selector.d.ts +11 -0
- package/dist/modes/interactive/components/thinking-selector.d.ts.map +1 -0
- package/dist/modes/interactive/components/thinking-selector.js +46 -0
- package/dist/modes/interactive/components/thinking-selector.js.map +1 -0
- package/dist/modes/interactive/components/tool-execution.d.ts +78 -0
- package/dist/modes/interactive/components/tool-execution.d.ts.map +1 -0
- package/dist/modes/interactive/components/tool-execution.js +880 -0
- package/dist/modes/interactive/components/tool-execution.js.map +1 -0
- package/dist/modes/interactive/components/tree-selector.d.ts +70 -0
- package/dist/modes/interactive/components/tree-selector.d.ts.map +1 -0
- package/dist/modes/interactive/components/tree-selector.js +921 -0
- package/dist/modes/interactive/components/tree-selector.js.map +1 -0
- package/dist/modes/interactive/components/user-message-selector.d.ts +30 -0
- package/dist/modes/interactive/components/user-message-selector.d.ts.map +1 -0
- package/dist/modes/interactive/components/user-message-selector.js +110 -0
- package/dist/modes/interactive/components/user-message-selector.js.map +1 -0
- package/dist/modes/interactive/components/user-message.d.ts +9 -0
- package/dist/modes/interactive/components/user-message.d.ts.map +1 -0
- package/dist/modes/interactive/components/user-message.js +27 -0
- package/dist/modes/interactive/components/user-message.js.map +1 -0
- package/dist/modes/interactive/components/visual-truncate.d.ts +24 -0
- package/dist/modes/interactive/components/visual-truncate.d.ts.map +1 -0
- package/dist/modes/interactive/components/visual-truncate.js +33 -0
- package/dist/modes/interactive/components/visual-truncate.js.map +1 -0
- package/dist/modes/interactive/interactive-mode.d.ts +453 -0
- package/dist/modes/interactive/interactive-mode.d.ts.map +1 -0
- package/dist/modes/interactive/interactive-mode.js +8669 -0
- package/dist/modes/interactive/interactive-mode.js.map +1 -0
- package/dist/modes/interactive/theme/dark.json +85 -0
- package/dist/modes/interactive/theme/light.json +84 -0
- package/dist/modes/interactive/theme/theme-schema.json +335 -0
- package/dist/modes/interactive/theme/theme.d.ts +78 -0
- package/dist/modes/interactive/theme/theme.d.ts.map +1 -0
- package/dist/modes/interactive/theme/theme.js +944 -0
- package/dist/modes/interactive/theme/theme.js.map +1 -0
- package/dist/modes/print-mode.d.ts +28 -0
- package/dist/modes/print-mode.d.ts.map +1 -0
- package/dist/modes/print-mode.js +101 -0
- package/dist/modes/print-mode.js.map +1 -0
- package/dist/modes/rpc/rpc-client.d.ts +217 -0
- package/dist/modes/rpc/rpc-client.d.ts.map +1 -0
- package/dist/modes/rpc/rpc-client.js +404 -0
- package/dist/modes/rpc/rpc-client.js.map +1 -0
- package/dist/modes/rpc/rpc-mode.d.ts +20 -0
- package/dist/modes/rpc/rpc-mode.d.ts.map +1 -0
- package/dist/modes/rpc/rpc-mode.js +580 -0
- package/dist/modes/rpc/rpc-mode.js.map +1 -0
- package/dist/modes/rpc/rpc-types.d.ts +409 -0
- package/dist/modes/rpc/rpc-types.d.ts.map +1 -0
- package/dist/modes/rpc/rpc-types.js +8 -0
- package/dist/modes/rpc/rpc-types.js.map +1 -0
- package/dist/utils/changelog.d.ts +21 -0
- package/dist/utils/changelog.d.ts.map +1 -0
- package/dist/utils/changelog.js +87 -0
- package/dist/utils/changelog.js.map +1 -0
- package/dist/utils/clipboard-image.d.ts +11 -0
- package/dist/utils/clipboard-image.d.ts.map +1 -0
- package/dist/utils/clipboard-image.js +162 -0
- package/dist/utils/clipboard-image.js.map +1 -0
- package/dist/utils/clipboard-native.d.ts +7 -0
- package/dist/utils/clipboard-native.d.ts.map +1 -0
- package/dist/utils/clipboard-native.js +14 -0
- package/dist/utils/clipboard-native.js.map +1 -0
- package/dist/utils/clipboard.d.ts +2 -0
- package/dist/utils/clipboard.d.ts.map +1 -0
- package/dist/utils/clipboard.js +67 -0
- package/dist/utils/clipboard.js.map +1 -0
- package/dist/utils/frontmatter.d.ts +8 -0
- package/dist/utils/frontmatter.d.ts.map +1 -0
- package/dist/utils/frontmatter.js +26 -0
- package/dist/utils/frontmatter.js.map +1 -0
- package/dist/utils/git.d.ts +26 -0
- package/dist/utils/git.d.ts.map +1 -0
- package/dist/utils/git.js +163 -0
- package/dist/utils/git.js.map +1 -0
- package/dist/utils/image-convert.d.ts +9 -0
- package/dist/utils/image-convert.d.ts.map +1 -0
- package/dist/utils/image-convert.js +35 -0
- package/dist/utils/image-convert.js.map +1 -0
- package/dist/utils/image-resize.d.ts +36 -0
- package/dist/utils/image-resize.d.ts.map +1 -0
- package/dist/utils/image-resize.js +181 -0
- package/dist/utils/image-resize.js.map +1 -0
- package/dist/utils/mime.d.ts +2 -0
- package/dist/utils/mime.d.ts.map +1 -0
- package/dist/utils/mime.js +26 -0
- package/dist/utils/mime.js.map +1 -0
- package/dist/utils/photon.d.ts +21 -0
- package/dist/utils/photon.d.ts.map +1 -0
- package/dist/utils/photon.js +121 -0
- package/dist/utils/photon.js.map +1 -0
- package/dist/utils/shell.d.ts +26 -0
- package/dist/utils/shell.d.ts.map +1 -0
- package/dist/utils/shell.js +186 -0
- package/dist/utils/shell.js.map +1 -0
- package/dist/utils/sleep.d.ts +5 -0
- package/dist/utils/sleep.d.ts.map +1 -0
- package/dist/utils/sleep.js +17 -0
- package/dist/utils/sleep.js.map +1 -0
- package/dist/utils/tools-manager.d.ts +3 -0
- package/dist/utils/tools-manager.d.ts.map +1 -0
- package/dist/utils/tools-manager.js +251 -0
- package/dist/utils/tools-manager.js.map +1 -0
- package/docs/README.md +32 -0
- package/docs/cli-reference.md +342 -0
- package/docs/configuration.md +301 -0
- package/docs/development-and-testing.md +295 -0
- package/docs/extensions-packages-themes.md +415 -0
- package/docs/getting-started.md +246 -0
- package/docs/interactive-mode.md +272 -0
- package/docs/iosm-init-and-cycles.md +355 -0
- package/docs/orchestration-and-subagents.md +273 -0
- package/docs/rpc-json-sdk.md +353 -0
- package/docs/sessions-traces-export.md +260 -0
- package/examples/README.md +120 -0
- package/examples/extensions/README.md +306 -0
- package/examples/extensions/antigravity-image-gen.ts +415 -0
- package/examples/extensions/auto-commit-on-exit.ts +49 -0
- package/examples/extensions/bash-spawn-hook.ts +30 -0
- package/examples/extensions/bookmark.ts +50 -0
- package/examples/extensions/built-in-tool-renderer.ts +246 -0
- package/examples/extensions/claude-rules.ts +86 -0
- package/examples/extensions/commands.ts +72 -0
- package/examples/extensions/confirm-destructive.ts +59 -0
- package/examples/extensions/custom-compaction.ts +114 -0
- package/examples/extensions/custom-footer.ts +64 -0
- package/examples/extensions/custom-header.ts +73 -0
- package/examples/extensions/custom-provider-anthropic/index.ts +604 -0
- package/examples/extensions/custom-provider-anthropic/package-lock.json +24 -0
- package/examples/extensions/custom-provider-anthropic/package.json +19 -0
- package/examples/extensions/custom-provider-gitlab-duo/index.ts +349 -0
- package/examples/extensions/custom-provider-gitlab-duo/package.json +16 -0
- package/examples/extensions/custom-provider-gitlab-duo/test.ts +82 -0
- package/examples/extensions/custom-provider-qwen-cli/index.ts +345 -0
- package/examples/extensions/custom-provider-qwen-cli/package.json +16 -0
- package/examples/extensions/dirty-repo-guard.ts +56 -0
- package/examples/extensions/doom-overlay/README.md +46 -0
- package/examples/extensions/doom-overlay/doom/build/doom.js +21 -0
- package/examples/extensions/doom-overlay/doom/build/doom.wasm +0 -0
- package/examples/extensions/doom-overlay/doom/build.sh +152 -0
- package/examples/extensions/doom-overlay/doom/doomgeneric_pi.c +72 -0
- package/examples/extensions/doom-overlay/doom-component.ts +132 -0
- package/examples/extensions/doom-overlay/doom-engine.ts +173 -0
- package/examples/extensions/doom-overlay/doom-keys.ts +104 -0
- package/examples/extensions/doom-overlay/index.ts +74 -0
- package/examples/extensions/doom-overlay/wad-finder.ts +51 -0
- package/examples/extensions/dynamic-resources/SKILL.md +8 -0
- package/examples/extensions/dynamic-resources/dynamic.json +79 -0
- package/examples/extensions/dynamic-resources/dynamic.md +5 -0
- package/examples/extensions/dynamic-resources/index.ts +15 -0
- package/examples/extensions/dynamic-tools.ts +74 -0
- package/examples/extensions/event-bus.ts +43 -0
- package/examples/extensions/file-trigger.ts +41 -0
- package/examples/extensions/git-checkpoint.ts +53 -0
- package/examples/extensions/handoff.ts +150 -0
- package/examples/extensions/hello.ts +25 -0
- package/examples/extensions/inline-bash.ts +94 -0
- package/examples/extensions/input-transform.ts +43 -0
- package/examples/extensions/interactive-shell.ts +196 -0
- package/examples/extensions/mac-system-theme.ts +47 -0
- package/examples/extensions/message-renderer.ts +59 -0
- package/examples/extensions/minimal-mode.ts +426 -0
- package/examples/extensions/modal-editor.ts +85 -0
- package/examples/extensions/model-status.ts +31 -0
- package/examples/extensions/notify.ts +55 -0
- package/examples/extensions/overlay-qa-tests.ts +881 -0
- package/examples/extensions/overlay-test.ts +150 -0
- package/examples/extensions/permission-gate.ts +34 -0
- package/examples/extensions/pirate.ts +47 -0
- package/examples/extensions/plan-mode/README.md +65 -0
- package/examples/extensions/plan-mode/index.ts +340 -0
- package/examples/extensions/plan-mode/utils.ts +168 -0
- package/examples/extensions/preset.ts +398 -0
- package/examples/extensions/protected-paths.ts +30 -0
- package/examples/extensions/qna.ts +119 -0
- package/examples/extensions/question.ts +264 -0
- package/examples/extensions/questionnaire.ts +427 -0
- package/examples/extensions/rainbow-editor.ts +88 -0
- package/examples/extensions/reload-runtime.ts +37 -0
- package/examples/extensions/rpc-demo.ts +124 -0
- package/examples/extensions/sandbox/index.ts +318 -0
- package/examples/extensions/sandbox/package-lock.json +92 -0
- package/examples/extensions/sandbox/package.json +19 -0
- package/examples/extensions/send-user-message.ts +97 -0
- package/examples/extensions/session-name.ts +27 -0
- package/examples/extensions/shutdown-command.ts +63 -0
- package/examples/extensions/snake.ts +343 -0
- package/examples/extensions/space-invaders.ts +560 -0
- package/examples/extensions/ssh.ts +220 -0
- package/examples/extensions/status-line.ts +40 -0
- package/examples/extensions/subagent/README.md +172 -0
- package/examples/extensions/subagent/agents/planner.md +37 -0
- package/examples/extensions/subagent/agents/reviewer.md +35 -0
- package/examples/extensions/subagent/agents/scout.md +50 -0
- package/examples/extensions/subagent/agents/worker.md +24 -0
- package/examples/extensions/subagent/agents.ts +126 -0
- package/examples/extensions/subagent/index.ts +964 -0
- package/examples/extensions/subagent/prompts/implement-and-review.md +10 -0
- package/examples/extensions/subagent/prompts/implement.md +10 -0
- package/examples/extensions/subagent/prompts/scout-and-plan.md +9 -0
- package/examples/extensions/summarize.ts +195 -0
- package/examples/extensions/system-prompt-header.ts +17 -0
- package/examples/extensions/timed-confirm.ts +70 -0
- package/examples/extensions/titlebar-spinner.ts +58 -0
- package/examples/extensions/todo.ts +299 -0
- package/examples/extensions/tool-override.ts +143 -0
- package/examples/extensions/tools.ts +146 -0
- package/examples/extensions/trigger-compact.ts +40 -0
- package/examples/extensions/truncated-tool.ts +192 -0
- package/examples/extensions/widget-placement.ts +17 -0
- package/examples/extensions/with-deps/index.ts +36 -0
- package/examples/extensions/with-deps/package-lock.json +31 -0
- package/examples/extensions/with-deps/package.json +22 -0
- package/examples/rpc-extension-ui.ts +632 -0
- package/examples/sdk/01-minimal.ts +22 -0
- package/examples/sdk/02-custom-model.ts +49 -0
- package/examples/sdk/03-custom-prompt.ts +55 -0
- package/examples/sdk/04-skills.ts +46 -0
- package/examples/sdk/05-tools.ts +56 -0
- package/examples/sdk/06-extensions.ts +88 -0
- package/examples/sdk/07-context-files.ts +40 -0
- package/examples/sdk/08-prompt-templates.ts +47 -0
- package/examples/sdk/09-api-keys-and-oauth.ts +48 -0
- package/examples/sdk/10-settings.ts +51 -0
- package/examples/sdk/11-sessions.ts +48 -0
- package/examples/sdk/12-full-control.ts +82 -0
- package/examples/sdk/README.md +337 -0
- package/examples/tsconfig.json +3 -0
- package/package.json +107 -0
|
@@ -0,0 +1,921 @@
|
|
|
1
|
+
import { Container, getEditorKeybindings, Input, matchesKey, Spacer, Text, TruncatedText, truncateToWidth, } from "@mariozechner/pi-tui";
|
|
2
|
+
import { theme } from "../theme/theme.js";
|
|
3
|
+
import { DynamicBorder } from "./dynamic-border.js";
|
|
4
|
+
import { keyHint } from "./keybinding-hints.js";
|
|
5
|
+
class TreeList {
|
|
6
|
+
constructor(tree, currentLeafId, maxVisibleLines, initialSelectedId, initialFilterMode) {
|
|
7
|
+
this.flatNodes = [];
|
|
8
|
+
this.filteredNodes = [];
|
|
9
|
+
this.selectedIndex = 0;
|
|
10
|
+
this.filterMode = "default";
|
|
11
|
+
this.searchQuery = "";
|
|
12
|
+
this.toolCallMap = new Map();
|
|
13
|
+
this.multipleRoots = false;
|
|
14
|
+
this.activePathIds = new Set();
|
|
15
|
+
this.lastSelectedId = null;
|
|
16
|
+
this.currentLeafId = currentLeafId;
|
|
17
|
+
this.maxVisibleLines = maxVisibleLines;
|
|
18
|
+
this.filterMode = initialFilterMode ?? "default";
|
|
19
|
+
this.multipleRoots = tree.length > 1;
|
|
20
|
+
this.flatNodes = this.flattenTree(tree);
|
|
21
|
+
this.buildActivePath();
|
|
22
|
+
this.applyFilter();
|
|
23
|
+
// Start with initialSelectedId if provided, otherwise current leaf
|
|
24
|
+
const targetId = initialSelectedId ?? currentLeafId;
|
|
25
|
+
this.selectedIndex = this.findNearestVisibleIndex(targetId);
|
|
26
|
+
this.lastSelectedId = this.filteredNodes[this.selectedIndex]?.node.entry.id ?? null;
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* Find the index of the nearest visible entry, walking up the parent chain if needed.
|
|
30
|
+
* Returns the index in filteredNodes, or the last index as fallback.
|
|
31
|
+
*/
|
|
32
|
+
findNearestVisibleIndex(entryId) {
|
|
33
|
+
if (this.filteredNodes.length === 0)
|
|
34
|
+
return 0;
|
|
35
|
+
// Build a map for parent lookup
|
|
36
|
+
const entryMap = new Map();
|
|
37
|
+
for (const flatNode of this.flatNodes) {
|
|
38
|
+
entryMap.set(flatNode.node.entry.id, flatNode);
|
|
39
|
+
}
|
|
40
|
+
// Build a map of visible entry IDs to their indices in filteredNodes
|
|
41
|
+
const visibleIdToIndex = new Map(this.filteredNodes.map((node, i) => [node.node.entry.id, i]));
|
|
42
|
+
// Walk from entryId up to root, looking for a visible entry
|
|
43
|
+
let currentId = entryId;
|
|
44
|
+
while (currentId !== null) {
|
|
45
|
+
const index = visibleIdToIndex.get(currentId);
|
|
46
|
+
if (index !== undefined)
|
|
47
|
+
return index;
|
|
48
|
+
const node = entryMap.get(currentId);
|
|
49
|
+
if (!node)
|
|
50
|
+
break;
|
|
51
|
+
currentId = node.node.entry.parentId ?? null;
|
|
52
|
+
}
|
|
53
|
+
// Fallback: last visible entry
|
|
54
|
+
return this.filteredNodes.length - 1;
|
|
55
|
+
}
|
|
56
|
+
/** Build the set of entry IDs on the path from root to current leaf */
|
|
57
|
+
buildActivePath() {
|
|
58
|
+
this.activePathIds.clear();
|
|
59
|
+
if (!this.currentLeafId)
|
|
60
|
+
return;
|
|
61
|
+
// Build a map of id -> entry for parent lookup
|
|
62
|
+
const entryMap = new Map();
|
|
63
|
+
for (const flatNode of this.flatNodes) {
|
|
64
|
+
entryMap.set(flatNode.node.entry.id, flatNode);
|
|
65
|
+
}
|
|
66
|
+
// Walk from leaf to root
|
|
67
|
+
let currentId = this.currentLeafId;
|
|
68
|
+
while (currentId) {
|
|
69
|
+
this.activePathIds.add(currentId);
|
|
70
|
+
const node = entryMap.get(currentId);
|
|
71
|
+
if (!node)
|
|
72
|
+
break;
|
|
73
|
+
currentId = node.node.entry.parentId ?? null;
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
flattenTree(roots) {
|
|
77
|
+
const result = [];
|
|
78
|
+
this.toolCallMap.clear();
|
|
79
|
+
const stack = [];
|
|
80
|
+
// Determine which subtrees contain the active leaf (to sort current branch first)
|
|
81
|
+
// Use iterative post-order traversal to avoid stack overflow
|
|
82
|
+
const containsActive = new Map();
|
|
83
|
+
const leafId = this.currentLeafId;
|
|
84
|
+
{
|
|
85
|
+
// Build list in pre-order, then process in reverse for post-order effect
|
|
86
|
+
const allNodes = [];
|
|
87
|
+
const preOrderStack = [...roots];
|
|
88
|
+
while (preOrderStack.length > 0) {
|
|
89
|
+
const node = preOrderStack.pop();
|
|
90
|
+
allNodes.push(node);
|
|
91
|
+
// Push children in reverse so they're processed left-to-right
|
|
92
|
+
for (let i = node.children.length - 1; i >= 0; i--) {
|
|
93
|
+
preOrderStack.push(node.children[i]);
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
// Process in reverse (post-order): children before parents
|
|
97
|
+
for (let i = allNodes.length - 1; i >= 0; i--) {
|
|
98
|
+
const node = allNodes[i];
|
|
99
|
+
let has = leafId !== null && node.entry.id === leafId;
|
|
100
|
+
for (const child of node.children) {
|
|
101
|
+
if (containsActive.get(child)) {
|
|
102
|
+
has = true;
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
containsActive.set(node, has);
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
// Add roots in reverse order, prioritizing the one containing the active leaf
|
|
109
|
+
// If multiple roots, treat them as children of a virtual root that branches
|
|
110
|
+
const multipleRoots = roots.length > 1;
|
|
111
|
+
const orderedRoots = [...roots].sort((a, b) => Number(containsActive.get(b)) - Number(containsActive.get(a)));
|
|
112
|
+
for (let i = orderedRoots.length - 1; i >= 0; i--) {
|
|
113
|
+
const isLast = i === orderedRoots.length - 1;
|
|
114
|
+
stack.push([orderedRoots[i], multipleRoots ? 1 : 0, multipleRoots, multipleRoots, isLast, [], multipleRoots]);
|
|
115
|
+
}
|
|
116
|
+
while (stack.length > 0) {
|
|
117
|
+
const [node, indent, justBranched, showConnector, isLast, gutters, isVirtualRootChild] = stack.pop();
|
|
118
|
+
// Extract tool calls from assistant messages for later lookup
|
|
119
|
+
const entry = node.entry;
|
|
120
|
+
if (entry.type === "message" && entry.message.role === "assistant") {
|
|
121
|
+
const content = entry.message.content;
|
|
122
|
+
if (Array.isArray(content)) {
|
|
123
|
+
for (const block of content) {
|
|
124
|
+
if (typeof block === "object" && block !== null && "type" in block && block.type === "toolCall") {
|
|
125
|
+
const tc = block;
|
|
126
|
+
this.toolCallMap.set(tc.id, { name: tc.name, arguments: tc.arguments });
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
result.push({ node, indent, showConnector, isLast, gutters, isVirtualRootChild });
|
|
132
|
+
const children = node.children;
|
|
133
|
+
const multipleChildren = children.length > 1;
|
|
134
|
+
// Order children so the branch containing the active leaf comes first
|
|
135
|
+
const orderedChildren = (() => {
|
|
136
|
+
const prioritized = [];
|
|
137
|
+
const rest = [];
|
|
138
|
+
for (const child of children) {
|
|
139
|
+
if (containsActive.get(child)) {
|
|
140
|
+
prioritized.push(child);
|
|
141
|
+
}
|
|
142
|
+
else {
|
|
143
|
+
rest.push(child);
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
return [...prioritized, ...rest];
|
|
147
|
+
})();
|
|
148
|
+
// Calculate child indent
|
|
149
|
+
let childIndent;
|
|
150
|
+
if (multipleChildren) {
|
|
151
|
+
// Parent branches: children get +1
|
|
152
|
+
childIndent = indent + 1;
|
|
153
|
+
}
|
|
154
|
+
else if (justBranched && indent > 0) {
|
|
155
|
+
// First generation after a branch: +1 for visual grouping
|
|
156
|
+
childIndent = indent + 1;
|
|
157
|
+
}
|
|
158
|
+
else {
|
|
159
|
+
// Single-child chain: stay flat
|
|
160
|
+
childIndent = indent;
|
|
161
|
+
}
|
|
162
|
+
// Build gutters for children
|
|
163
|
+
// If this node showed a connector, add a gutter entry for descendants
|
|
164
|
+
// Only add gutter if connector is actually displayed (not suppressed for virtual root children)
|
|
165
|
+
const connectorDisplayed = showConnector && !isVirtualRootChild;
|
|
166
|
+
// When connector is displayed, add a gutter entry at the connector's position
|
|
167
|
+
// Connector is at position (displayIndent - 1), so gutter should be there too
|
|
168
|
+
const currentDisplayIndent = this.multipleRoots ? Math.max(0, indent - 1) : indent;
|
|
169
|
+
const connectorPosition = Math.max(0, currentDisplayIndent - 1);
|
|
170
|
+
const childGutters = connectorDisplayed
|
|
171
|
+
? [...gutters, { position: connectorPosition, show: !isLast }]
|
|
172
|
+
: gutters;
|
|
173
|
+
// Add children in reverse order
|
|
174
|
+
for (let i = orderedChildren.length - 1; i >= 0; i--) {
|
|
175
|
+
const childIsLast = i === orderedChildren.length - 1;
|
|
176
|
+
stack.push([
|
|
177
|
+
orderedChildren[i],
|
|
178
|
+
childIndent,
|
|
179
|
+
multipleChildren,
|
|
180
|
+
multipleChildren,
|
|
181
|
+
childIsLast,
|
|
182
|
+
childGutters,
|
|
183
|
+
false,
|
|
184
|
+
]);
|
|
185
|
+
}
|
|
186
|
+
}
|
|
187
|
+
return result;
|
|
188
|
+
}
|
|
189
|
+
applyFilter() {
|
|
190
|
+
// Update lastSelectedId only when we have a valid selection (non-empty list)
|
|
191
|
+
// This preserves the selection when switching through empty filter results
|
|
192
|
+
if (this.filteredNodes.length > 0) {
|
|
193
|
+
this.lastSelectedId = this.filteredNodes[this.selectedIndex]?.node.entry.id ?? this.lastSelectedId;
|
|
194
|
+
}
|
|
195
|
+
const searchTokens = this.searchQuery.toLowerCase().split(/\s+/).filter(Boolean);
|
|
196
|
+
this.filteredNodes = this.flatNodes.filter((flatNode) => {
|
|
197
|
+
const entry = flatNode.node.entry;
|
|
198
|
+
const isCurrentLeaf = entry.id === this.currentLeafId;
|
|
199
|
+
// Skip assistant messages with only tool calls (no text) unless error/aborted
|
|
200
|
+
// Always show current leaf so active position is visible
|
|
201
|
+
if (entry.type === "message" && entry.message.role === "assistant" && !isCurrentLeaf) {
|
|
202
|
+
const msg = entry.message;
|
|
203
|
+
const hasText = this.hasTextContent(msg.content);
|
|
204
|
+
const isErrorOrAborted = msg.stopReason && msg.stopReason !== "stop" && msg.stopReason !== "toolUse";
|
|
205
|
+
// Only hide if no text AND not an error/aborted message
|
|
206
|
+
if (!hasText && !isErrorOrAborted) {
|
|
207
|
+
return false;
|
|
208
|
+
}
|
|
209
|
+
}
|
|
210
|
+
// Apply filter mode
|
|
211
|
+
let passesFilter = true;
|
|
212
|
+
// Entry types hidden in default view (settings/bookkeeping)
|
|
213
|
+
const isSettingsEntry = entry.type === "label" ||
|
|
214
|
+
entry.type === "custom" ||
|
|
215
|
+
entry.type === "model_change" ||
|
|
216
|
+
entry.type === "thinking_level_change";
|
|
217
|
+
switch (this.filterMode) {
|
|
218
|
+
case "user-only":
|
|
219
|
+
// Just user messages
|
|
220
|
+
passesFilter = entry.type === "message" && entry.message.role === "user";
|
|
221
|
+
break;
|
|
222
|
+
case "no-tools":
|
|
223
|
+
// Default minus tool results
|
|
224
|
+
passesFilter = !isSettingsEntry && !(entry.type === "message" && entry.message.role === "toolResult");
|
|
225
|
+
break;
|
|
226
|
+
case "labeled-only":
|
|
227
|
+
// Just labeled entries
|
|
228
|
+
passesFilter = flatNode.node.label !== undefined;
|
|
229
|
+
break;
|
|
230
|
+
case "all":
|
|
231
|
+
// Show everything
|
|
232
|
+
passesFilter = true;
|
|
233
|
+
break;
|
|
234
|
+
default:
|
|
235
|
+
// Default mode: hide settings/bookkeeping entries
|
|
236
|
+
passesFilter = !isSettingsEntry;
|
|
237
|
+
break;
|
|
238
|
+
}
|
|
239
|
+
if (!passesFilter)
|
|
240
|
+
return false;
|
|
241
|
+
// Apply search filter
|
|
242
|
+
if (searchTokens.length > 0) {
|
|
243
|
+
const nodeText = this.getSearchableText(flatNode.node).toLowerCase();
|
|
244
|
+
return searchTokens.every((token) => nodeText.includes(token));
|
|
245
|
+
}
|
|
246
|
+
return true;
|
|
247
|
+
});
|
|
248
|
+
// Recalculate visual structure (indent, connectors, gutters) based on visible tree
|
|
249
|
+
this.recalculateVisualStructure();
|
|
250
|
+
// Try to preserve cursor on the same node, or find nearest visible ancestor
|
|
251
|
+
if (this.lastSelectedId) {
|
|
252
|
+
this.selectedIndex = this.findNearestVisibleIndex(this.lastSelectedId);
|
|
253
|
+
}
|
|
254
|
+
else if (this.selectedIndex >= this.filteredNodes.length) {
|
|
255
|
+
// Clamp index if out of bounds
|
|
256
|
+
this.selectedIndex = Math.max(0, this.filteredNodes.length - 1);
|
|
257
|
+
}
|
|
258
|
+
// Update lastSelectedId to the actual selection (may have changed due to parent walk)
|
|
259
|
+
if (this.filteredNodes.length > 0) {
|
|
260
|
+
this.lastSelectedId = this.filteredNodes[this.selectedIndex]?.node.entry.id ?? this.lastSelectedId;
|
|
261
|
+
}
|
|
262
|
+
}
|
|
263
|
+
/**
|
|
264
|
+
* Recompute indentation/connectors for the filtered view
|
|
265
|
+
*
|
|
266
|
+
* Filtering can hide intermediate entries; descendants attach to the nearest visible ancestor.
|
|
267
|
+
* Keep indentation semantics aligned with flattenTree() so single-child chains don't drift right.
|
|
268
|
+
*/
|
|
269
|
+
recalculateVisualStructure() {
|
|
270
|
+
if (this.filteredNodes.length === 0)
|
|
271
|
+
return;
|
|
272
|
+
const visibleIds = new Set(this.filteredNodes.map((n) => n.node.entry.id));
|
|
273
|
+
// Build entry map for efficient parent lookup (using full tree)
|
|
274
|
+
const entryMap = new Map();
|
|
275
|
+
for (const flatNode of this.flatNodes) {
|
|
276
|
+
entryMap.set(flatNode.node.entry.id, flatNode);
|
|
277
|
+
}
|
|
278
|
+
// Find nearest visible ancestor for a node
|
|
279
|
+
const findVisibleAncestor = (nodeId) => {
|
|
280
|
+
let currentId = entryMap.get(nodeId)?.node.entry.parentId ?? null;
|
|
281
|
+
while (currentId !== null) {
|
|
282
|
+
if (visibleIds.has(currentId)) {
|
|
283
|
+
return currentId;
|
|
284
|
+
}
|
|
285
|
+
currentId = entryMap.get(currentId)?.node.entry.parentId ?? null;
|
|
286
|
+
}
|
|
287
|
+
return null;
|
|
288
|
+
};
|
|
289
|
+
// Build visible tree structure:
|
|
290
|
+
// - visibleParent: nodeId → nearest visible ancestor (or null for roots)
|
|
291
|
+
// - visibleChildren: parentId → list of visible children (in filteredNodes order)
|
|
292
|
+
const visibleParent = new Map();
|
|
293
|
+
const visibleChildren = new Map();
|
|
294
|
+
visibleChildren.set(null, []); // root-level nodes
|
|
295
|
+
for (const flatNode of this.filteredNodes) {
|
|
296
|
+
const nodeId = flatNode.node.entry.id;
|
|
297
|
+
const ancestorId = findVisibleAncestor(nodeId);
|
|
298
|
+
visibleParent.set(nodeId, ancestorId);
|
|
299
|
+
if (!visibleChildren.has(ancestorId)) {
|
|
300
|
+
visibleChildren.set(ancestorId, []);
|
|
301
|
+
}
|
|
302
|
+
visibleChildren.get(ancestorId).push(nodeId);
|
|
303
|
+
}
|
|
304
|
+
// Update multipleRoots based on visible roots
|
|
305
|
+
const visibleRootIds = visibleChildren.get(null);
|
|
306
|
+
this.multipleRoots = visibleRootIds.length > 1;
|
|
307
|
+
// Build a map for quick lookup: nodeId → FlatNode
|
|
308
|
+
const filteredNodeMap = new Map();
|
|
309
|
+
for (const flatNode of this.filteredNodes) {
|
|
310
|
+
filteredNodeMap.set(flatNode.node.entry.id, flatNode);
|
|
311
|
+
}
|
|
312
|
+
const stack = [];
|
|
313
|
+
// Add visible roots in reverse order (to process in forward order via stack)
|
|
314
|
+
for (let i = visibleRootIds.length - 1; i >= 0; i--) {
|
|
315
|
+
const isLast = i === visibleRootIds.length - 1;
|
|
316
|
+
stack.push([
|
|
317
|
+
visibleRootIds[i],
|
|
318
|
+
this.multipleRoots ? 1 : 0,
|
|
319
|
+
this.multipleRoots,
|
|
320
|
+
this.multipleRoots,
|
|
321
|
+
isLast,
|
|
322
|
+
[],
|
|
323
|
+
this.multipleRoots,
|
|
324
|
+
]);
|
|
325
|
+
}
|
|
326
|
+
while (stack.length > 0) {
|
|
327
|
+
const [nodeId, indent, justBranched, showConnector, isLast, gutters, isVirtualRootChild] = stack.pop();
|
|
328
|
+
const flatNode = filteredNodeMap.get(nodeId);
|
|
329
|
+
if (!flatNode)
|
|
330
|
+
continue;
|
|
331
|
+
// Update this node's visual properties
|
|
332
|
+
flatNode.indent = indent;
|
|
333
|
+
flatNode.showConnector = showConnector;
|
|
334
|
+
flatNode.isLast = isLast;
|
|
335
|
+
flatNode.gutters = gutters;
|
|
336
|
+
flatNode.isVirtualRootChild = isVirtualRootChild;
|
|
337
|
+
// Get visible children of this node
|
|
338
|
+
const children = visibleChildren.get(nodeId) || [];
|
|
339
|
+
const multipleChildren = children.length > 1;
|
|
340
|
+
// Child indent follows flattenTree(): branch points (and first generation after a branch) shift +1
|
|
341
|
+
let childIndent;
|
|
342
|
+
if (multipleChildren) {
|
|
343
|
+
childIndent = indent + 1;
|
|
344
|
+
}
|
|
345
|
+
else if (justBranched && indent > 0) {
|
|
346
|
+
childIndent = indent + 1;
|
|
347
|
+
}
|
|
348
|
+
else {
|
|
349
|
+
childIndent = indent;
|
|
350
|
+
}
|
|
351
|
+
// Child gutters follow flattenTree() connector/gutter rules
|
|
352
|
+
const connectorDisplayed = showConnector && !isVirtualRootChild;
|
|
353
|
+
const currentDisplayIndent = this.multipleRoots ? Math.max(0, indent - 1) : indent;
|
|
354
|
+
const connectorPosition = Math.max(0, currentDisplayIndent - 1);
|
|
355
|
+
const childGutters = connectorDisplayed
|
|
356
|
+
? [...gutters, { position: connectorPosition, show: !isLast }]
|
|
357
|
+
: gutters;
|
|
358
|
+
// Add children in reverse order (to process in forward order via stack)
|
|
359
|
+
for (let i = children.length - 1; i >= 0; i--) {
|
|
360
|
+
const childIsLast = i === children.length - 1;
|
|
361
|
+
stack.push([
|
|
362
|
+
children[i],
|
|
363
|
+
childIndent,
|
|
364
|
+
multipleChildren,
|
|
365
|
+
multipleChildren,
|
|
366
|
+
childIsLast,
|
|
367
|
+
childGutters,
|
|
368
|
+
false,
|
|
369
|
+
]);
|
|
370
|
+
}
|
|
371
|
+
}
|
|
372
|
+
}
|
|
373
|
+
/** Get searchable text content from a node */
|
|
374
|
+
getSearchableText(node) {
|
|
375
|
+
const entry = node.entry;
|
|
376
|
+
const parts = [];
|
|
377
|
+
if (node.label) {
|
|
378
|
+
parts.push(node.label);
|
|
379
|
+
}
|
|
380
|
+
switch (entry.type) {
|
|
381
|
+
case "message": {
|
|
382
|
+
const msg = entry.message;
|
|
383
|
+
parts.push(msg.role);
|
|
384
|
+
if ("content" in msg && msg.content) {
|
|
385
|
+
parts.push(this.extractContent(msg.content));
|
|
386
|
+
}
|
|
387
|
+
if (msg.role === "bashExecution") {
|
|
388
|
+
const bashMsg = msg;
|
|
389
|
+
if (bashMsg.command)
|
|
390
|
+
parts.push(bashMsg.command);
|
|
391
|
+
}
|
|
392
|
+
break;
|
|
393
|
+
}
|
|
394
|
+
case "custom_message": {
|
|
395
|
+
parts.push(entry.customType);
|
|
396
|
+
if (typeof entry.content === "string") {
|
|
397
|
+
parts.push(entry.content);
|
|
398
|
+
}
|
|
399
|
+
else {
|
|
400
|
+
parts.push(this.extractContent(entry.content));
|
|
401
|
+
}
|
|
402
|
+
break;
|
|
403
|
+
}
|
|
404
|
+
case "compaction":
|
|
405
|
+
parts.push("compaction");
|
|
406
|
+
break;
|
|
407
|
+
case "branch_summary":
|
|
408
|
+
parts.push("branch summary", entry.summary);
|
|
409
|
+
break;
|
|
410
|
+
case "model_change":
|
|
411
|
+
parts.push("model", entry.modelId);
|
|
412
|
+
break;
|
|
413
|
+
case "thinking_level_change":
|
|
414
|
+
parts.push("thinking", entry.thinkingLevel);
|
|
415
|
+
break;
|
|
416
|
+
case "custom":
|
|
417
|
+
parts.push("custom", entry.customType);
|
|
418
|
+
break;
|
|
419
|
+
case "label":
|
|
420
|
+
parts.push("label", entry.label ?? "");
|
|
421
|
+
break;
|
|
422
|
+
}
|
|
423
|
+
return parts.join(" ");
|
|
424
|
+
}
|
|
425
|
+
invalidate() { }
|
|
426
|
+
getSearchQuery() {
|
|
427
|
+
return this.searchQuery;
|
|
428
|
+
}
|
|
429
|
+
getSelectedNode() {
|
|
430
|
+
return this.filteredNodes[this.selectedIndex]?.node;
|
|
431
|
+
}
|
|
432
|
+
updateNodeLabel(entryId, label) {
|
|
433
|
+
for (const flatNode of this.flatNodes) {
|
|
434
|
+
if (flatNode.node.entry.id === entryId) {
|
|
435
|
+
flatNode.node.label = label;
|
|
436
|
+
break;
|
|
437
|
+
}
|
|
438
|
+
}
|
|
439
|
+
}
|
|
440
|
+
getFilterLabel() {
|
|
441
|
+
switch (this.filterMode) {
|
|
442
|
+
case "no-tools":
|
|
443
|
+
return " [no-tools]";
|
|
444
|
+
case "user-only":
|
|
445
|
+
return " [user]";
|
|
446
|
+
case "labeled-only":
|
|
447
|
+
return " [labeled]";
|
|
448
|
+
case "all":
|
|
449
|
+
return " [all]";
|
|
450
|
+
default:
|
|
451
|
+
return "";
|
|
452
|
+
}
|
|
453
|
+
}
|
|
454
|
+
render(width) {
|
|
455
|
+
const lines = [];
|
|
456
|
+
if (this.filteredNodes.length === 0) {
|
|
457
|
+
lines.push(truncateToWidth(theme.fg("muted", " No entries found"), width));
|
|
458
|
+
lines.push(truncateToWidth(theme.fg("muted", ` (0/0)${this.getFilterLabel()}`), width));
|
|
459
|
+
return lines;
|
|
460
|
+
}
|
|
461
|
+
const startIndex = Math.max(0, Math.min(this.selectedIndex - Math.floor(this.maxVisibleLines / 2), this.filteredNodes.length - this.maxVisibleLines));
|
|
462
|
+
const endIndex = Math.min(startIndex + this.maxVisibleLines, this.filteredNodes.length);
|
|
463
|
+
for (let i = startIndex; i < endIndex; i++) {
|
|
464
|
+
const flatNode = this.filteredNodes[i];
|
|
465
|
+
const entry = flatNode.node.entry;
|
|
466
|
+
const isSelected = i === this.selectedIndex;
|
|
467
|
+
// Build line: cursor + prefix + path marker + label + content
|
|
468
|
+
const cursor = isSelected ? theme.fg("accent", "› ") : " ";
|
|
469
|
+
// If multiple roots, shift display (roots at 0, not 1)
|
|
470
|
+
const displayIndent = this.multipleRoots ? Math.max(0, flatNode.indent - 1) : flatNode.indent;
|
|
471
|
+
// Build prefix with gutters at their correct positions
|
|
472
|
+
// Each gutter has a position (displayIndent where its connector was shown)
|
|
473
|
+
const connector = flatNode.showConnector && !flatNode.isVirtualRootChild ? (flatNode.isLast ? "└─ " : "├─ ") : "";
|
|
474
|
+
const connectorPosition = connector ? displayIndent - 1 : -1;
|
|
475
|
+
// Build prefix char by char, placing gutters and connector at their positions
|
|
476
|
+
const totalChars = displayIndent * 3;
|
|
477
|
+
const prefixChars = [];
|
|
478
|
+
for (let i = 0; i < totalChars; i++) {
|
|
479
|
+
const level = Math.floor(i / 3);
|
|
480
|
+
const posInLevel = i % 3;
|
|
481
|
+
// Check if there's a gutter at this level
|
|
482
|
+
const gutter = flatNode.gutters.find((g) => g.position === level);
|
|
483
|
+
if (gutter) {
|
|
484
|
+
if (posInLevel === 0) {
|
|
485
|
+
prefixChars.push(gutter.show ? "│" : " ");
|
|
486
|
+
}
|
|
487
|
+
else {
|
|
488
|
+
prefixChars.push(" ");
|
|
489
|
+
}
|
|
490
|
+
}
|
|
491
|
+
else if (connector && level === connectorPosition) {
|
|
492
|
+
// Connector at this level
|
|
493
|
+
if (posInLevel === 0) {
|
|
494
|
+
prefixChars.push(flatNode.isLast ? "└" : "├");
|
|
495
|
+
}
|
|
496
|
+
else if (posInLevel === 1) {
|
|
497
|
+
prefixChars.push("─");
|
|
498
|
+
}
|
|
499
|
+
else {
|
|
500
|
+
prefixChars.push(" ");
|
|
501
|
+
}
|
|
502
|
+
}
|
|
503
|
+
else {
|
|
504
|
+
prefixChars.push(" ");
|
|
505
|
+
}
|
|
506
|
+
}
|
|
507
|
+
const prefix = prefixChars.join("");
|
|
508
|
+
// Active path marker - shown right before the entry text
|
|
509
|
+
const isOnActivePath = this.activePathIds.has(entry.id);
|
|
510
|
+
const pathMarker = isOnActivePath ? theme.fg("accent", "• ") : "";
|
|
511
|
+
const label = flatNode.node.label ? theme.fg("warning", `[${flatNode.node.label}] `) : "";
|
|
512
|
+
const content = this.getEntryDisplayText(flatNode.node, isSelected);
|
|
513
|
+
let line = cursor + theme.fg("dim", prefix) + pathMarker + label + content;
|
|
514
|
+
if (isSelected) {
|
|
515
|
+
line = theme.bg("selectedBg", line);
|
|
516
|
+
}
|
|
517
|
+
lines.push(truncateToWidth(line, width));
|
|
518
|
+
}
|
|
519
|
+
lines.push(truncateToWidth(theme.fg("muted", ` (${this.selectedIndex + 1}/${this.filteredNodes.length})${this.getFilterLabel()}`), width));
|
|
520
|
+
return lines;
|
|
521
|
+
}
|
|
522
|
+
getEntryDisplayText(node, isSelected) {
|
|
523
|
+
const entry = node.entry;
|
|
524
|
+
let result;
|
|
525
|
+
const normalize = (s) => s.replace(/[\n\t]/g, " ").trim();
|
|
526
|
+
switch (entry.type) {
|
|
527
|
+
case "message": {
|
|
528
|
+
const msg = entry.message;
|
|
529
|
+
const role = msg.role;
|
|
530
|
+
if (role === "user") {
|
|
531
|
+
const msgWithContent = msg;
|
|
532
|
+
const content = normalize(this.extractContent(msgWithContent.content));
|
|
533
|
+
result = theme.fg("accent", "user: ") + content;
|
|
534
|
+
}
|
|
535
|
+
else if (role === "assistant") {
|
|
536
|
+
const msgWithContent = msg;
|
|
537
|
+
const textContent = normalize(this.extractContent(msgWithContent.content));
|
|
538
|
+
if (textContent) {
|
|
539
|
+
result = theme.fg("success", "assistant: ") + textContent;
|
|
540
|
+
}
|
|
541
|
+
else if (msgWithContent.stopReason === "aborted") {
|
|
542
|
+
result = theme.fg("success", "assistant: ") + theme.fg("muted", "(aborted)");
|
|
543
|
+
}
|
|
544
|
+
else if (msgWithContent.errorMessage) {
|
|
545
|
+
const errMsg = normalize(msgWithContent.errorMessage).slice(0, 80);
|
|
546
|
+
result = theme.fg("success", "assistant: ") + theme.fg("error", errMsg);
|
|
547
|
+
}
|
|
548
|
+
else {
|
|
549
|
+
result = theme.fg("success", "assistant: ") + theme.fg("muted", "(no content)");
|
|
550
|
+
}
|
|
551
|
+
}
|
|
552
|
+
else if (role === "toolResult") {
|
|
553
|
+
const toolMsg = msg;
|
|
554
|
+
const toolCall = toolMsg.toolCallId ? this.toolCallMap.get(toolMsg.toolCallId) : undefined;
|
|
555
|
+
if (toolCall) {
|
|
556
|
+
result = theme.fg("muted", this.formatToolCall(toolCall.name, toolCall.arguments));
|
|
557
|
+
}
|
|
558
|
+
else {
|
|
559
|
+
result = theme.fg("muted", `[${toolMsg.toolName ?? "tool"}]`);
|
|
560
|
+
}
|
|
561
|
+
}
|
|
562
|
+
else if (role === "bashExecution") {
|
|
563
|
+
const bashMsg = msg;
|
|
564
|
+
result = theme.fg("dim", `[bash]: ${normalize(bashMsg.command ?? "")}`);
|
|
565
|
+
}
|
|
566
|
+
else {
|
|
567
|
+
result = theme.fg("dim", `[${role}]`);
|
|
568
|
+
}
|
|
569
|
+
break;
|
|
570
|
+
}
|
|
571
|
+
case "custom_message": {
|
|
572
|
+
const content = typeof entry.content === "string"
|
|
573
|
+
? entry.content
|
|
574
|
+
: entry.content
|
|
575
|
+
.filter((c) => c.type === "text")
|
|
576
|
+
.map((c) => c.text)
|
|
577
|
+
.join("");
|
|
578
|
+
result = theme.fg("customMessageLabel", `[${entry.customType}]: `) + normalize(content);
|
|
579
|
+
break;
|
|
580
|
+
}
|
|
581
|
+
case "compaction": {
|
|
582
|
+
const tokens = Math.round(entry.tokensBefore / 1000);
|
|
583
|
+
result = theme.fg("borderAccent", `[compaction: ${tokens}k tokens]`);
|
|
584
|
+
break;
|
|
585
|
+
}
|
|
586
|
+
case "branch_summary":
|
|
587
|
+
result = theme.fg("warning", `[branch summary]: `) + normalize(entry.summary);
|
|
588
|
+
break;
|
|
589
|
+
case "model_change":
|
|
590
|
+
result = theme.fg("dim", `[model: ${entry.modelId}]`);
|
|
591
|
+
break;
|
|
592
|
+
case "thinking_level_change":
|
|
593
|
+
result = theme.fg("dim", `[thinking: ${entry.thinkingLevel}]`);
|
|
594
|
+
break;
|
|
595
|
+
case "custom":
|
|
596
|
+
result = theme.fg("dim", `[custom: ${entry.customType}]`);
|
|
597
|
+
break;
|
|
598
|
+
case "label":
|
|
599
|
+
result = theme.fg("dim", `[label: ${entry.label ?? "(cleared)"}]`);
|
|
600
|
+
break;
|
|
601
|
+
default:
|
|
602
|
+
result = "";
|
|
603
|
+
}
|
|
604
|
+
return isSelected ? theme.bold(result) : result;
|
|
605
|
+
}
|
|
606
|
+
extractContent(content) {
|
|
607
|
+
const maxLen = 200;
|
|
608
|
+
if (typeof content === "string")
|
|
609
|
+
return content.slice(0, maxLen);
|
|
610
|
+
if (Array.isArray(content)) {
|
|
611
|
+
let result = "";
|
|
612
|
+
for (const c of content) {
|
|
613
|
+
if (typeof c === "object" && c !== null && "type" in c && c.type === "text") {
|
|
614
|
+
result += c.text;
|
|
615
|
+
if (result.length >= maxLen)
|
|
616
|
+
return result.slice(0, maxLen);
|
|
617
|
+
}
|
|
618
|
+
}
|
|
619
|
+
return result;
|
|
620
|
+
}
|
|
621
|
+
return "";
|
|
622
|
+
}
|
|
623
|
+
hasTextContent(content) {
|
|
624
|
+
if (typeof content === "string")
|
|
625
|
+
return content.trim().length > 0;
|
|
626
|
+
if (Array.isArray(content)) {
|
|
627
|
+
for (const c of content) {
|
|
628
|
+
if (typeof c === "object" && c !== null && "type" in c && c.type === "text") {
|
|
629
|
+
const text = c.text;
|
|
630
|
+
if (text && text.trim().length > 0)
|
|
631
|
+
return true;
|
|
632
|
+
}
|
|
633
|
+
}
|
|
634
|
+
}
|
|
635
|
+
return false;
|
|
636
|
+
}
|
|
637
|
+
formatToolCall(name, args) {
|
|
638
|
+
const shortenPath = (p) => {
|
|
639
|
+
const home = process.env.HOME || process.env.USERPROFILE || "";
|
|
640
|
+
if (home && p.startsWith(home))
|
|
641
|
+
return `~${p.slice(home.length)}`;
|
|
642
|
+
return p;
|
|
643
|
+
};
|
|
644
|
+
switch (name) {
|
|
645
|
+
case "read": {
|
|
646
|
+
const path = shortenPath(String(args.path || args.file_path || ""));
|
|
647
|
+
const offset = args.offset;
|
|
648
|
+
const limit = args.limit;
|
|
649
|
+
let display = path;
|
|
650
|
+
if (offset !== undefined || limit !== undefined) {
|
|
651
|
+
const start = offset ?? 1;
|
|
652
|
+
const end = limit !== undefined ? start + limit - 1 : "";
|
|
653
|
+
display += `:${start}${end ? `-${end}` : ""}`;
|
|
654
|
+
}
|
|
655
|
+
return `[read: ${display}]`;
|
|
656
|
+
}
|
|
657
|
+
case "write": {
|
|
658
|
+
const path = shortenPath(String(args.path || args.file_path || ""));
|
|
659
|
+
return `[write: ${path}]`;
|
|
660
|
+
}
|
|
661
|
+
case "edit": {
|
|
662
|
+
const path = shortenPath(String(args.path || args.file_path || ""));
|
|
663
|
+
return `[edit: ${path}]`;
|
|
664
|
+
}
|
|
665
|
+
case "bash": {
|
|
666
|
+
const rawCmd = String(args.command || "");
|
|
667
|
+
const cmd = rawCmd
|
|
668
|
+
.replace(/[\n\t]/g, " ")
|
|
669
|
+
.trim()
|
|
670
|
+
.slice(0, 50);
|
|
671
|
+
return `[bash: ${cmd}${rawCmd.length > 50 ? "..." : ""}]`;
|
|
672
|
+
}
|
|
673
|
+
case "grep": {
|
|
674
|
+
const pattern = String(args.pattern || "");
|
|
675
|
+
const path = shortenPath(String(args.path || "."));
|
|
676
|
+
return `[grep: /${pattern}/ in ${path}]`;
|
|
677
|
+
}
|
|
678
|
+
case "find": {
|
|
679
|
+
const pattern = String(args.pattern || "");
|
|
680
|
+
const path = shortenPath(String(args.path || "."));
|
|
681
|
+
return `[find: ${pattern} in ${path}]`;
|
|
682
|
+
}
|
|
683
|
+
case "ls": {
|
|
684
|
+
const path = shortenPath(String(args.path || "."));
|
|
685
|
+
return `[ls: ${path}]`;
|
|
686
|
+
}
|
|
687
|
+
default: {
|
|
688
|
+
// Custom tool - show name and truncated JSON args
|
|
689
|
+
const argsStr = JSON.stringify(args).slice(0, 40);
|
|
690
|
+
return `[${name}: ${argsStr}${JSON.stringify(args).length > 40 ? "..." : ""}]`;
|
|
691
|
+
}
|
|
692
|
+
}
|
|
693
|
+
}
|
|
694
|
+
handleInput(keyData) {
|
|
695
|
+
const kb = getEditorKeybindings();
|
|
696
|
+
if (kb.matches(keyData, "selectUp")) {
|
|
697
|
+
this.selectedIndex = this.selectedIndex === 0 ? this.filteredNodes.length - 1 : this.selectedIndex - 1;
|
|
698
|
+
}
|
|
699
|
+
else if (kb.matches(keyData, "selectDown")) {
|
|
700
|
+
this.selectedIndex = this.selectedIndex === this.filteredNodes.length - 1 ? 0 : this.selectedIndex + 1;
|
|
701
|
+
}
|
|
702
|
+
else if (kb.matches(keyData, "cursorLeft")) {
|
|
703
|
+
// Page up
|
|
704
|
+
this.selectedIndex = Math.max(0, this.selectedIndex - this.maxVisibleLines);
|
|
705
|
+
}
|
|
706
|
+
else if (kb.matches(keyData, "cursorRight")) {
|
|
707
|
+
// Page down
|
|
708
|
+
this.selectedIndex = Math.min(this.filteredNodes.length - 1, this.selectedIndex + this.maxVisibleLines);
|
|
709
|
+
}
|
|
710
|
+
else if (kb.matches(keyData, "selectConfirm")) {
|
|
711
|
+
const selected = this.filteredNodes[this.selectedIndex];
|
|
712
|
+
if (selected && this.onSelect) {
|
|
713
|
+
this.onSelect(selected.node.entry.id);
|
|
714
|
+
}
|
|
715
|
+
}
|
|
716
|
+
else if (kb.matches(keyData, "selectCancel")) {
|
|
717
|
+
if (this.searchQuery) {
|
|
718
|
+
this.searchQuery = "";
|
|
719
|
+
this.applyFilter();
|
|
720
|
+
}
|
|
721
|
+
else {
|
|
722
|
+
this.onCancel?.();
|
|
723
|
+
}
|
|
724
|
+
}
|
|
725
|
+
else if (matchesKey(keyData, "ctrl+d")) {
|
|
726
|
+
// Direct filter: default
|
|
727
|
+
this.filterMode = "default";
|
|
728
|
+
this.applyFilter();
|
|
729
|
+
}
|
|
730
|
+
else if (matchesKey(keyData, "ctrl+t")) {
|
|
731
|
+
// Toggle filter: no-tools ↔ default
|
|
732
|
+
this.filterMode = this.filterMode === "no-tools" ? "default" : "no-tools";
|
|
733
|
+
this.applyFilter();
|
|
734
|
+
}
|
|
735
|
+
else if (matchesKey(keyData, "ctrl+u")) {
|
|
736
|
+
// Toggle filter: user-only ↔ default
|
|
737
|
+
this.filterMode = this.filterMode === "user-only" ? "default" : "user-only";
|
|
738
|
+
this.applyFilter();
|
|
739
|
+
}
|
|
740
|
+
else if (matchesKey(keyData, "ctrl+l")) {
|
|
741
|
+
// Toggle filter: labeled-only ↔ default
|
|
742
|
+
this.filterMode = this.filterMode === "labeled-only" ? "default" : "labeled-only";
|
|
743
|
+
this.applyFilter();
|
|
744
|
+
}
|
|
745
|
+
else if (matchesKey(keyData, "ctrl+a")) {
|
|
746
|
+
// Toggle filter: all ↔ default
|
|
747
|
+
this.filterMode = this.filterMode === "all" ? "default" : "all";
|
|
748
|
+
this.applyFilter();
|
|
749
|
+
}
|
|
750
|
+
else if (matchesKey(keyData, "shift+ctrl+o")) {
|
|
751
|
+
// Cycle filter backwards
|
|
752
|
+
const modes = ["default", "no-tools", "user-only", "labeled-only", "all"];
|
|
753
|
+
const currentIndex = modes.indexOf(this.filterMode);
|
|
754
|
+
this.filterMode = modes[(currentIndex - 1 + modes.length) % modes.length];
|
|
755
|
+
this.applyFilter();
|
|
756
|
+
}
|
|
757
|
+
else if (matchesKey(keyData, "ctrl+o")) {
|
|
758
|
+
// Cycle filter forwards: default → no-tools → user-only → labeled-only → all → default
|
|
759
|
+
const modes = ["default", "no-tools", "user-only", "labeled-only", "all"];
|
|
760
|
+
const currentIndex = modes.indexOf(this.filterMode);
|
|
761
|
+
this.filterMode = modes[(currentIndex + 1) % modes.length];
|
|
762
|
+
this.applyFilter();
|
|
763
|
+
}
|
|
764
|
+
else if (kb.matches(keyData, "deleteCharBackward")) {
|
|
765
|
+
if (this.searchQuery.length > 0) {
|
|
766
|
+
this.searchQuery = this.searchQuery.slice(0, -1);
|
|
767
|
+
this.applyFilter();
|
|
768
|
+
}
|
|
769
|
+
}
|
|
770
|
+
else if (matchesKey(keyData, "shift+l")) {
|
|
771
|
+
const selected = this.filteredNodes[this.selectedIndex];
|
|
772
|
+
if (selected && this.onLabelEdit) {
|
|
773
|
+
this.onLabelEdit(selected.node.entry.id, selected.node.label);
|
|
774
|
+
}
|
|
775
|
+
}
|
|
776
|
+
else {
|
|
777
|
+
const hasControlChars = [...keyData].some((ch) => {
|
|
778
|
+
const code = ch.charCodeAt(0);
|
|
779
|
+
return code < 32 || code === 0x7f || (code >= 0x80 && code <= 0x9f);
|
|
780
|
+
});
|
|
781
|
+
if (!hasControlChars && keyData.length > 0) {
|
|
782
|
+
this.searchQuery += keyData;
|
|
783
|
+
this.applyFilter();
|
|
784
|
+
}
|
|
785
|
+
}
|
|
786
|
+
}
|
|
787
|
+
}
|
|
788
|
+
/** Component that displays the current search query */
|
|
789
|
+
class SearchLine {
|
|
790
|
+
constructor(treeList) {
|
|
791
|
+
this.treeList = treeList;
|
|
792
|
+
}
|
|
793
|
+
invalidate() { }
|
|
794
|
+
render(width) {
|
|
795
|
+
const query = this.treeList.getSearchQuery();
|
|
796
|
+
if (query) {
|
|
797
|
+
return [truncateToWidth(` ${theme.fg("muted", "Type to search:")} ${theme.fg("accent", query)}`, width)];
|
|
798
|
+
}
|
|
799
|
+
return [truncateToWidth(` ${theme.fg("muted", "Type to search:")}`, width)];
|
|
800
|
+
}
|
|
801
|
+
handleInput(_keyData) { }
|
|
802
|
+
}
|
|
803
|
+
/** Label input component shown when editing a label */
|
|
804
|
+
class LabelInput {
|
|
805
|
+
get focused() {
|
|
806
|
+
return this._focused;
|
|
807
|
+
}
|
|
808
|
+
set focused(value) {
|
|
809
|
+
this._focused = value;
|
|
810
|
+
this.input.focused = value;
|
|
811
|
+
}
|
|
812
|
+
constructor(entryId, currentLabel) {
|
|
813
|
+
// Focusable implementation - propagate to input for IME cursor positioning
|
|
814
|
+
this._focused = false;
|
|
815
|
+
this.entryId = entryId;
|
|
816
|
+
this.input = new Input();
|
|
817
|
+
if (currentLabel) {
|
|
818
|
+
this.input.setValue(currentLabel);
|
|
819
|
+
}
|
|
820
|
+
}
|
|
821
|
+
invalidate() { }
|
|
822
|
+
render(width) {
|
|
823
|
+
const lines = [];
|
|
824
|
+
const indent = " ";
|
|
825
|
+
const availableWidth = width - indent.length;
|
|
826
|
+
lines.push(truncateToWidth(`${indent}${theme.fg("muted", "Label (empty to remove):")}`, width));
|
|
827
|
+
lines.push(...this.input.render(availableWidth).map((line) => truncateToWidth(`${indent}${line}`, width)));
|
|
828
|
+
lines.push(truncateToWidth(`${indent}${keyHint("selectConfirm", "save")} ${keyHint("selectCancel", "cancel")}`, width));
|
|
829
|
+
return lines;
|
|
830
|
+
}
|
|
831
|
+
handleInput(keyData) {
|
|
832
|
+
const kb = getEditorKeybindings();
|
|
833
|
+
if (kb.matches(keyData, "selectConfirm")) {
|
|
834
|
+
const value = this.input.getValue().trim();
|
|
835
|
+
this.onSubmit?.(this.entryId, value || undefined);
|
|
836
|
+
}
|
|
837
|
+
else if (kb.matches(keyData, "selectCancel")) {
|
|
838
|
+
this.onCancel?.();
|
|
839
|
+
}
|
|
840
|
+
else {
|
|
841
|
+
this.input.handleInput(keyData);
|
|
842
|
+
}
|
|
843
|
+
}
|
|
844
|
+
}
|
|
845
|
+
/**
|
|
846
|
+
* Component that renders a session tree selector for navigation
|
|
847
|
+
*/
|
|
848
|
+
export class TreeSelectorComponent extends Container {
|
|
849
|
+
get focused() {
|
|
850
|
+
return this._focused;
|
|
851
|
+
}
|
|
852
|
+
set focused(value) {
|
|
853
|
+
this._focused = value;
|
|
854
|
+
// Propagate to labelInput when it's active
|
|
855
|
+
if (this.labelInput) {
|
|
856
|
+
this.labelInput.focused = value;
|
|
857
|
+
}
|
|
858
|
+
}
|
|
859
|
+
constructor(tree, currentLeafId, terminalHeight, onSelect, onCancel, onLabelChange, initialSelectedId, initialFilterMode) {
|
|
860
|
+
super();
|
|
861
|
+
this.labelInput = null;
|
|
862
|
+
// Focusable implementation - propagate to labelInput when active for IME cursor positioning
|
|
863
|
+
this._focused = false;
|
|
864
|
+
this.onLabelChangeCallback = onLabelChange;
|
|
865
|
+
const maxVisibleLines = Math.max(5, Math.floor(terminalHeight / 2));
|
|
866
|
+
this.treeList = new TreeList(tree, currentLeafId, maxVisibleLines, initialSelectedId, initialFilterMode);
|
|
867
|
+
this.treeList.onSelect = onSelect;
|
|
868
|
+
this.treeList.onCancel = onCancel;
|
|
869
|
+
this.treeList.onLabelEdit = (entryId, currentLabel) => this.showLabelInput(entryId, currentLabel);
|
|
870
|
+
this.treeContainer = new Container();
|
|
871
|
+
this.treeContainer.addChild(this.treeList);
|
|
872
|
+
this.labelInputContainer = new Container();
|
|
873
|
+
this.addChild(new Spacer(1));
|
|
874
|
+
this.addChild(new DynamicBorder());
|
|
875
|
+
this.addChild(new Text(theme.bold(" Session Tree"), 1, 0));
|
|
876
|
+
this.addChild(new TruncatedText(theme.fg("muted", " ↑/↓: move. ←/→: page. Shift+L: label. ") +
|
|
877
|
+
theme.fg("muted", "^D/^T/^U/^L/^A: filters (^O/⇧^O cycle)"), 0, 0));
|
|
878
|
+
this.addChild(new SearchLine(this.treeList));
|
|
879
|
+
this.addChild(new DynamicBorder());
|
|
880
|
+
this.addChild(new Spacer(1));
|
|
881
|
+
this.addChild(this.treeContainer);
|
|
882
|
+
this.addChild(this.labelInputContainer);
|
|
883
|
+
this.addChild(new Spacer(1));
|
|
884
|
+
this.addChild(new DynamicBorder());
|
|
885
|
+
if (tree.length === 0) {
|
|
886
|
+
setTimeout(() => onCancel(), 100);
|
|
887
|
+
}
|
|
888
|
+
}
|
|
889
|
+
showLabelInput(entryId, currentLabel) {
|
|
890
|
+
this.labelInput = new LabelInput(entryId, currentLabel);
|
|
891
|
+
this.labelInput.onSubmit = (id, label) => {
|
|
892
|
+
this.treeList.updateNodeLabel(id, label);
|
|
893
|
+
this.onLabelChangeCallback?.(id, label);
|
|
894
|
+
this.hideLabelInput();
|
|
895
|
+
};
|
|
896
|
+
this.labelInput.onCancel = () => this.hideLabelInput();
|
|
897
|
+
// Propagate current focused state to the new labelInput
|
|
898
|
+
this.labelInput.focused = this._focused;
|
|
899
|
+
this.treeContainer.clear();
|
|
900
|
+
this.labelInputContainer.clear();
|
|
901
|
+
this.labelInputContainer.addChild(this.labelInput);
|
|
902
|
+
}
|
|
903
|
+
hideLabelInput() {
|
|
904
|
+
this.labelInput = null;
|
|
905
|
+
this.labelInputContainer.clear();
|
|
906
|
+
this.treeContainer.clear();
|
|
907
|
+
this.treeContainer.addChild(this.treeList);
|
|
908
|
+
}
|
|
909
|
+
handleInput(keyData) {
|
|
910
|
+
if (this.labelInput) {
|
|
911
|
+
this.labelInput.handleInput(keyData);
|
|
912
|
+
}
|
|
913
|
+
else {
|
|
914
|
+
this.treeList.handleInput(keyData);
|
|
915
|
+
}
|
|
916
|
+
}
|
|
917
|
+
getTreeList() {
|
|
918
|
+
return this.treeList;
|
|
919
|
+
}
|
|
920
|
+
}
|
|
921
|
+
//# sourceMappingURL=tree-selector.js.map
|