@selesai/code 0.9.11 → 0.9.13
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 +17 -0
- package/dist/config.d.ts +4 -6
- package/dist/config.js +10 -14
- package/dist/core/agent-session.d.ts +0 -1
- package/dist/core/agent-session.js +3 -49
- package/dist/core/extensions/types.d.ts +0 -2
- package/dist/core/settings-manager.d.ts +0 -2
- package/dist/core/settings-manager.js +0 -3
- package/dist/core/tools/index.d.ts +0 -1
- package/dist/core/tools/index.js +0 -1
- package/dist/defaults/settings.json +2 -3
- package/dist/extensions/model-prompt-injector/index.test.ts +0 -10
- package/dist/extensions/model-prompt-injector/index.ts +0 -3
- package/dist/extensions/pi-intercom/CHANGELOG.md +53 -16
- package/dist/extensions/pi-intercom/README.md +41 -8
- package/dist/extensions/pi-intercom/banner.png +0 -0
- package/dist/extensions/pi-intercom/broker/broker.ts +498 -215
- package/dist/extensions/pi-intercom/broker/client.ts +39 -12
- package/dist/extensions/pi-intercom/broker/extension.test.ts +102 -3
- package/dist/extensions/pi-intercom/broker/paths.test.ts +2 -2
- package/dist/extensions/pi-intercom/broker/protocol.ts +26 -0
- package/dist/extensions/pi-intercom/broker/spawn.test.ts +5 -20
- package/dist/extensions/pi-intercom/config.test.ts +41 -0
- package/dist/extensions/pi-intercom/config.ts +21 -0
- package/dist/extensions/pi-intercom/extension-api.ts +40 -0
- package/dist/extensions/pi-intercom/index.ts +362 -26
- package/dist/extensions/pi-intercom/intercom.integration.test.ts +819 -13
- package/dist/extensions/pi-intercom/package.json +1 -1
- package/dist/extensions/pi-intercom/project-agent.ts +2 -2
- package/dist/extensions/pi-intercom/skills/pi-intercom/SKILL.md +8 -110
- package/dist/extensions/pi-intercom/types.ts +32 -5
- package/dist/extensions/pi-intercom/ui/inline-message.ts +6 -0
- package/dist/extensions/pi-subagents/.github/assets/subagent-fleet-inspector.png +0 -0
- package/dist/extensions/pi-subagents/.github/workflows/release.yml +28 -0
- package/dist/extensions/pi-subagents/.github/workflows/test.yml +51 -0
- package/dist/extensions/pi-subagents/.greptile/config.json +33 -0
- package/dist/extensions/pi-subagents/.greptile/files.json +8 -0
- package/dist/extensions/pi-subagents/.greptile/rules.md +16 -0
- package/dist/extensions/pi-subagents/CHANGELOG.md +309 -87
- package/dist/extensions/pi-subagents/README.md +15 -17
- package/dist/extensions/pi-subagents/agents/oracle.md +3 -1
- package/dist/extensions/pi-subagents/agents/researcher.md +32 -13
- package/dist/extensions/pi-subagents/agents/reviewer.md +13 -2
- package/dist/extensions/pi-subagents/agents/scout.md +2 -2
- package/dist/extensions/pi-subagents/agents/worker.md +2 -1
- package/dist/extensions/pi-subagents/async-retention-discovery-worker.mjs +180 -0
- package/dist/extensions/pi-subagents/docs/configuration.md +106 -27
- package/dist/extensions/pi-subagents/docs/extension-api.md +85 -21
- package/dist/extensions/pi-subagents/docs/missions.md +41 -4
- package/dist/extensions/pi-subagents/docs/models.md +52 -9
- package/dist/extensions/pi-subagents/docs/observability.md +103 -16
- package/dist/extensions/pi-subagents/docs/tool-reference.md +60 -45
- package/dist/extensions/pi-subagents/docs/watchdog.md +60 -3
- package/dist/extensions/pi-subagents/docs/workflows.md +181 -7
- package/dist/extensions/pi-subagents/index.ts +10 -1
- package/dist/extensions/pi-subagents/install.mjs +4 -4
- package/dist/extensions/pi-subagents/package-lock.json +1483 -1470
- package/dist/extensions/pi-subagents/package.json +6 -3
- package/dist/extensions/pi-subagents/prompts/council.md +60 -0
- package/dist/extensions/pi-subagents/prompts/parallel-review.md +5 -1
- package/dist/extensions/pi-subagents/prompts/review-loop.md +9 -5
- package/dist/extensions/pi-subagents/skills/council-mode/SKILL.md +254 -0
- package/dist/extensions/pi-subagents/skills/pi-subagents/SKILL.md +18 -17
- package/dist/extensions/pi-subagents/skills/pi-subagents/references/constraints-and-recipes.md +31 -9
- package/dist/extensions/pi-subagents/skills/pi-subagents/references/execution-controls.md +107 -140
- package/dist/extensions/pi-subagents/skills/pi-subagents/references/management-authoring-rpc.md +9 -12
- package/dist/extensions/pi-subagents/skills/pi-subagents/references/multi-lane-orchestration.md +39 -0
- package/dist/extensions/pi-subagents/skills/pi-subagents/references/prompting-and-roles.md +44 -92
- package/dist/extensions/pi-subagents/src/agents/agent-management.ts +261 -368
- package/dist/extensions/pi-subagents/src/agents/agent-serializer.ts +6 -2
- package/dist/extensions/pi-subagents/src/agents/agents.ts +388 -85
- package/dist/extensions/pi-subagents/src/agents/builtin-names.ts +14 -0
- package/dist/extensions/pi-subagents/src/agents/runtime-agent-registry.ts +418 -0
- package/dist/extensions/pi-subagents/src/agents/skills.ts +1 -1
- package/dist/extensions/pi-subagents/src/api/agents.ts +7 -0
- package/dist/extensions/pi-subagents/src/api/external-job-provider.ts +195 -0
- package/dist/extensions/pi-subagents/src/api/preflight.ts +88 -27
- package/dist/extensions/pi-subagents/src/api/project-panes.ts +2 -0
- package/dist/extensions/pi-subagents/src/api/shared-types.ts +2 -0
- package/dist/extensions/pi-subagents/src/extension/config.ts +20 -11
- package/dist/extensions/pi-subagents/src/extension/doctor.ts +14 -6
- package/dist/extensions/pi-subagents/src/extension/fanout-child.ts +5 -4
- package/dist/extensions/pi-subagents/src/extension/index.ts +270 -187
- package/dist/extensions/pi-subagents/src/extension/public-execution.ts +65 -28
- package/dist/extensions/pi-subagents/src/extension/rpc.ts +120 -11
- package/dist/extensions/pi-subagents/src/extension/schemas.ts +46 -64
- package/dist/extensions/pi-subagents/src/extension/tool-description.ts +51 -37
- package/dist/extensions/pi-subagents/src/extension/tool-result.ts +19 -0
- package/dist/extensions/pi-subagents/src/inspectors/herdr/actions.ts +2 -2
- package/dist/extensions/pi-subagents/src/inspectors/herdr/client.ts +3 -3
- package/dist/extensions/pi-subagents/src/inspectors/herdr/focus.ts +55 -0
- package/dist/extensions/pi-subagents/src/inspectors/herdr/inspector-runner.ts +2 -1
- package/dist/extensions/pi-subagents/src/inspectors/herdr/project-panes.ts +230 -46
- package/dist/extensions/pi-subagents/src/integrations/herdr-status.ts +26 -4
- package/dist/extensions/pi-subagents/src/intercom/native-supervisor-channel.ts +32 -10
- package/dist/extensions/pi-subagents/src/missions/lifecycle.ts +6 -1
- package/dist/extensions/pi-subagents/src/missions/store.ts +4 -9
- package/dist/extensions/pi-subagents/src/missions/workflow-state.ts +2 -2
- package/dist/extensions/pi-subagents/src/policy/authority.ts +2 -0
- package/dist/extensions/pi-subagents/src/profiles/profiles.ts +3 -1
- package/dist/extensions/pi-subagents/src/runs/background/active-run-index.ts +31 -8
- package/dist/extensions/pi-subagents/src/runs/background/async-execution.ts +210 -52
- package/dist/extensions/pi-subagents/src/runs/background/async-job-tracker.ts +63 -33
- package/dist/extensions/pi-subagents/src/runs/background/async-resume.ts +71 -17
- package/dist/extensions/pi-subagents/src/runs/background/async-retention.ts +886 -0
- package/dist/extensions/pi-subagents/src/runs/background/async-status-snapshot.ts +14 -5
- package/dist/extensions/pi-subagents/src/runs/background/async-status.ts +49 -56
- package/dist/extensions/pi-subagents/src/runs/background/auto-drain.ts +1 -0
- package/dist/extensions/pi-subagents/src/runs/background/chain-append.ts +3 -33
- package/dist/extensions/pi-subagents/src/runs/background/chain-root-attachment.ts +5 -0
- package/dist/extensions/pi-subagents/src/runs/background/completion-dedupe.ts +5 -1
- package/dist/extensions/pi-subagents/src/runs/background/completion-replay.ts +22 -12
- package/dist/extensions/pi-subagents/src/runs/background/control-channel.ts +105 -71
- package/dist/extensions/pi-subagents/src/runs/background/fleet-view.ts +68 -19
- package/dist/extensions/pi-subagents/src/runs/background/index-segment.ts +59 -0
- package/dist/extensions/pi-subagents/src/runs/background/inspect-rpc.ts +443 -0
- package/dist/extensions/pi-subagents/src/runs/background/notify.ts +94 -10
- package/dist/extensions/pi-subagents/src/runs/background/result-files.ts +158 -90
- package/dist/extensions/pi-subagents/src/runs/background/result-watcher.ts +141 -53
- package/dist/extensions/pi-subagents/src/runs/background/resume-guidance.ts +8 -5
- package/dist/extensions/pi-subagents/src/runs/background/retained-children.ts +14 -4
- package/dist/extensions/pi-subagents/src/runs/background/run-id-query.ts +7 -0
- package/dist/extensions/pi-subagents/src/runs/background/run-id-resolver.ts +13 -14
- package/dist/extensions/pi-subagents/src/runs/background/run-status.ts +46 -25
- package/dist/extensions/pi-subagents/src/runs/background/scheduled-runs.ts +823 -0
- package/dist/extensions/pi-subagents/src/runs/background/stale-run-reconciler.ts +9 -3
- package/dist/extensions/pi-subagents/src/runs/background/steering.ts +11 -1
- package/dist/extensions/pi-subagents/src/runs/background/subagent-runner.ts +594 -216
- package/dist/extensions/pi-subagents/src/runs/background/subagent-wait.ts +17 -13
- package/dist/extensions/pi-subagents/src/runs/background/terminal-run-index.ts +138 -0
- package/dist/extensions/pi-subagents/src/runs/background/wait-completions.ts +23 -4
- package/dist/extensions/pi-subagents/src/runs/background/wait-subscriptions.ts +82 -4
- package/dist/extensions/pi-subagents/src/runs/background/wait-tool.ts +5 -3
- package/dist/extensions/pi-subagents/src/runs/foreground/async-steering-action.ts +21 -14
- package/dist/extensions/pi-subagents/src/runs/foreground/async-stop-action.ts +23 -2
- package/dist/extensions/pi-subagents/src/runs/foreground/execution.ts +153 -58
- package/dist/extensions/pi-subagents/src/runs/foreground/foreground-history.ts +7 -9
- package/dist/extensions/pi-subagents/src/runs/foreground/subagent-executor.ts +1283 -1657
- package/dist/extensions/pi-subagents/src/runs/foreground/workflow-detach-reconcile.ts +274 -0
- package/dist/extensions/pi-subagents/src/runs/foreground/workflow-foreground-steering.ts +6 -5
- package/dist/extensions/pi-subagents/src/runs/shared/acceptance.ts +59 -10
- package/dist/extensions/pi-subagents/src/runs/shared/agent-contract.ts +1 -1
- package/dist/extensions/pi-subagents/src/runs/shared/chain-outputs.ts +1 -3
- package/dist/extensions/pi-subagents/src/runs/shared/child-identity.ts +36 -0
- package/dist/extensions/pi-subagents/src/runs/shared/completion-guard.ts +52 -2
- package/dist/extensions/pi-subagents/src/runs/shared/dynamic-fanout.ts +1 -1
- package/dist/extensions/pi-subagents/src/runs/shared/extension-bindings.ts +78 -0
- package/dist/extensions/pi-subagents/src/runs/shared/external-cli-runner.ts +2 -0
- package/dist/extensions/pi-subagents/src/runs/shared/external-job-bridge.ts +460 -0
- package/dist/extensions/pi-subagents/src/runs/shared/external-job-runner.ts +389 -0
- package/dist/extensions/pi-subagents/src/runs/shared/fast-mode-extension.ts +10 -0
- package/dist/extensions/pi-subagents/src/runs/shared/mcp-direct-tool-allowlist.ts +14 -0
- package/dist/extensions/pi-subagents/src/runs/shared/model-exclusions.ts +243 -0
- package/dist/extensions/pi-subagents/src/runs/shared/model-fallback.ts +201 -85
- package/dist/extensions/pi-subagents/src/runs/shared/model-scope.ts +106 -39
- package/dist/extensions/pi-subagents/src/runs/shared/mutation-evidence.ts +145 -0
- package/dist/extensions/pi-subagents/src/runs/shared/orca-progress-tabs.ts +150 -27
- package/dist/extensions/pi-subagents/src/runs/shared/parallel-handoff.ts +46 -4
- package/dist/extensions/pi-subagents/src/runs/shared/parallel-utils.ts +19 -15
- package/dist/extensions/pi-subagents/src/runs/shared/permissions.ts +5 -1
- package/dist/extensions/pi-subagents/src/runs/shared/pi-args.ts +86 -2
- package/dist/extensions/pi-subagents/src/runs/shared/pi-spawn.ts +9 -9
- package/dist/extensions/pi-subagents/src/runs/shared/session-lease.ts +0 -6
- package/dist/extensions/pi-subagents/src/runs/shared/structured-output.ts +18 -4
- package/dist/extensions/pi-subagents/src/runs/shared/subagent-control.ts +51 -7
- package/dist/extensions/pi-subagents/src/runs/shared/subagent-prompt-runtime.ts +62 -21
- package/dist/extensions/pi-subagents/src/runs/shared/tool-availability.ts +1 -3
- package/dist/extensions/pi-subagents/src/runs/shared/tool-timeout.ts +1 -3
- package/dist/extensions/pi-subagents/src/runs/shared/workflow-graph.ts +1 -23
- package/dist/extensions/pi-subagents/src/runs/shared/worktree.ts +14 -2
- package/dist/extensions/pi-subagents/src/shared/artifacts.ts +2 -2
- package/dist/extensions/pi-subagents/src/shared/atomic-json.ts +22 -2
- package/dist/extensions/pi-subagents/src/shared/capacity-resilient-json.ts +102 -0
- package/dist/extensions/pi-subagents/src/shared/completion-owner.ts +14 -0
- package/dist/extensions/pi-subagents/src/shared/file-system-retry.ts +49 -1
- package/dist/extensions/pi-subagents/src/shared/fork-context.ts +59 -1
- package/dist/extensions/pi-subagents/src/shared/launch-contract.ts +12 -5
- package/dist/extensions/pi-subagents/src/shared/model-info.ts +20 -0
- package/dist/extensions/pi-subagents/src/shared/prompt-resources.ts +0 -40
- package/dist/extensions/pi-subagents/src/shared/settings.ts +11 -30
- package/dist/extensions/pi-subagents/src/shared/thinking-ceiling.ts +52 -0
- package/dist/extensions/pi-subagents/src/shared/types.ts +228 -49
- package/dist/extensions/pi-subagents/src/shared/utils.ts +11 -3
- package/dist/extensions/pi-subagents/src/shared/watch-strategy.ts +10 -0
- package/dist/extensions/pi-subagents/src/slash/prompt-workflows.ts +0 -162
- package/dist/extensions/pi-subagents/src/slash/slash-bridge.ts +2 -5
- package/dist/extensions/pi-subagents/src/slash/slash-commands.ts +105 -13
- package/dist/extensions/pi-subagents/src/slash/slash-live-state.ts +6 -36
- package/dist/extensions/pi-subagents/src/tui/fleet-status.ts +829 -0
- package/dist/extensions/pi-subagents/src/tui/fleet.ts +1415 -0
- package/dist/extensions/pi-subagents/src/tui/render.ts +78 -7
- package/dist/extensions/pi-subagents/src/watchdog/change-signature.ts +1 -1
- package/dist/extensions/pi-subagents/src/watchdog/lsp-diagnostics.ts +1 -0
- package/dist/extensions/pi-subagents/src/watchdog/permission-arbiter.ts +59 -51
- package/dist/extensions/pi-subagents/src/watchdog/register-main.ts +8 -2
- package/dist/extensions/pi-subagents/src/watchdog/tool-actions.ts +2 -1
- package/dist/extensions/pi-subagents/src/workflows/chat-progress.ts +4 -4
- package/dist/extensions/pi-subagents/src/workflows/scripted-workflow.ts +471 -86
- package/dist/extensions/pi-subagents/src/workflows/workflow-receipt.ts +140 -0
- package/dist/extensions/pi-subagents/test/e2e/real-session-subagent.test.ts +2 -2
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/bun/cli.d.ts +3 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/bun/register-bedrock.d.ts +2 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/bun/restore-sandbox-env.d.ts +17 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/cli/args.d.ts +57 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/cli/config-selector.d.ts +16 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/cli/file-processor.d.ts +15 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/cli/initial-message.d.ts +18 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/cli/list-models.d.ts +9 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/cli/project-trust.d.ts +10 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/cli/session-picker.d.ts +10 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/cli/startup-ui.d.ts +20 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/cli.d.ts +3 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/config.d.ts +96 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/core/agent-session-runtime.d.ts +119 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/core/agent-session-services.d.ts +85 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/core/agent-session.d.ts +620 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/core/auth-guidance.d.ts +5 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/core/auth-storage.d.ts +56 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/core/bash-executor.d.ts +32 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/core/cache-stats.d.ts +49 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/core/compaction/branch-summarization.d.ts +93 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/core/compaction/compaction.d.ts +128 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/core/compaction/index.d.ts +7 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/core/compaction/utils.d.ts +38 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/core/defaults.d.ts +3 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/core/diagnostics.d.ts +15 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/core/event-bus.d.ts +9 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/core/exec.d.ts +29 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/core/experimental.d.ts +2 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/core/export-html/ansi-to-html.d.ts +22 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/core/export-html/index.d.ts +37 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/core/export-html/tool-renderer.d.ts +34 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/core/extensions/index.d.ts +12 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/core/extensions/loader.d.ts +23 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/core/extensions/runner.d.ts +171 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/core/extensions/types.d.ts +1261 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/core/extensions/wrapper.d.ts +20 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/core/footer-data-provider.d.ts +54 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/core/http-dispatcher.d.ts +22 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/core/index.d.ts +13 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/core/keybindings.d.ts +358 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/core/messages.d.ts +77 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/core/model-config.d.ts +512 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/core/model-registry.d.ts +43 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/core/model-resolver.d.ts +121 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/core/model-runtime.d.ts +82 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/core/models-store.d.ts +17 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/core/output-guard.d.ts +7 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/core/package-manager.d.ts +210 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/core/project-trust.d.ts +15 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/core/prompt-templates.d.ts +54 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/core/provider-attribution.d.ts +4 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/core/provider-composer.d.ts +55 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/core/radius.d.ts +2 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/core/remote-catalog-provider.d.ts +5 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/core/resolve-config-value.d.ts +30 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/core/resource-loader.d.ts +206 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/core/runtime-credentials.d.ts +15 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/core/sdk.d.ts +106 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/core/session-cwd.d.ts +19 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/core/session-manager.d.ts +356 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/core/settings-manager.d.ts +297 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/core/skills.d.ts +60 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/core/slash-commands.d.ts +15 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/core/source-info.d.ts +18 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/core/system-prompt.d.ts +28 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/core/telemetry.d.ts +3 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/core/timings.d.ts +10 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/core/tools/bash.d.ts +68 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/core/tools/edit-diff.d.ts +106 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/core/tools/edit.d.ts +51 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/core/tools/file-mutation-queue.d.ts +6 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/core/tools/find.d.ts +35 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/core/tools/grep.d.ts +37 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/core/tools/index.d.ts +40 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/core/tools/ls.d.ts +37 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/core/tools/output-accumulator.d.ts +52 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/core/tools/path-utils.d.ts +10 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/core/tools/read.d.ts +35 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/core/tools/render-utils.d.ts +24 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/core/tools/tool-definition-wrapper.d.ts +14 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/core/tools/truncate.d.ts +70 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/core/tools/write.d.ts +26 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/core/trust-manager.d.ts +36 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/core/usage-totals.d.ts +19 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/extensions/index.d.ts +3 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/extensions/llama/client.d.ts +61 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/extensions/llama/huggingface.d.ts +23 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/extensions/llama/index.d.ts +3 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/extensions/llama/provider.d.ts +10 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/extensions/llama/ui.d.ts +42 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/index.d.ts +35 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/main.d.ts +12 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/migrations.d.ts +33 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/modes/index.d.ts +9 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/modes/interactive/components/armin.d.ts +34 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/modes/interactive/components/assistant-message.d.ts +22 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/modes/interactive/components/bash-execution.d.ts +34 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/modes/interactive/components/bordered-loader.d.ts +16 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/modes/interactive/components/branch-summary-message.d.ts +16 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/modes/interactive/components/compaction-summary-message.d.ts +16 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/modes/interactive/components/config-selector.d.ts +102 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/modes/interactive/components/countdown-timer.d.ts +14 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/modes/interactive/components/custom-editor.d.ts +21 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/modes/interactive/components/custom-entry.d.ts +19 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/modes/interactive/components/custom-message.d.ts +20 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/modes/interactive/components/daxnuts.d.ts +23 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/modes/interactive/components/diff.d.ts +12 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/modes/interactive/components/dynamic-border.d.ts +15 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/modes/interactive/components/earendil-announcement.d.ts +5 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/modes/interactive/components/extension-editor.d.ts +22 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/modes/interactive/components/extension-input.d.ts +23 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/modes/interactive/components/extension-selector.d.ts +26 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/modes/interactive/components/first-time-setup.d.ts +25 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/modes/interactive/components/footer.d.ts +32 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/modes/interactive/components/index.d.ts +34 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/modes/interactive/components/keybinding-hints.d.ts +13 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/modes/interactive/components/login-dialog.d.ts +52 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/modes/interactive/components/model-selector.d.ts +54 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/modes/interactive/components/oauth-selector.d.ts +33 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/modes/interactive/components/scoped-models-selector.d.ts +42 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/modes/interactive/components/session-selector-search.d.ts +23 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/modes/interactive/components/session-selector.d.ts +95 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/modes/interactive/components/settings-selector.d.ts +77 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/modes/interactive/components/show-images-selector.d.ts +10 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/modes/interactive/components/skill-invocation-message.d.ts +17 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/modes/interactive/components/status-indicator.d.ts +28 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/modes/interactive/components/theme-selector.d.ts +11 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/modes/interactive/components/thinking-selector.d.ts +11 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/modes/interactive/components/tool-execution.d.ts +63 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/modes/interactive/components/tree-selector.d.ts +94 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/modes/interactive/components/trust-selector.d.ts +23 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/modes/interactive/components/user-message-selector.d.ts +30 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/modes/interactive/components/user-message.d.ts +14 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/modes/interactive/components/visual-truncate.d.ts +24 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/modes/interactive/interactive-mode.d.ts +394 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/modes/interactive/model-search.d.ts +12 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/modes/interactive/theme/theme-controller.d.ts +29 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/modes/interactive/theme/theme.d.ts +120 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/modes/print-mode.d.ts +28 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/modes/rpc/jsonl.d.ts +17 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/modes/rpc/rpc-client.d.ts +246 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/modes/rpc/rpc-mode.d.ts +20 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/modes/rpc/rpc-types.d.ts +457 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/package-manager-cli.d.ts +8 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/rpc-entry.d.ts +3 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/utils/ansi.d.ts +2 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/utils/changelog.d.ts +22 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/utils/child-process.d.ts +18 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/utils/clipboard-image.d.ts +11 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/utils/clipboard-native.d.ts +11 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/utils/clipboard.d.ts +4 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/utils/deprecation.d.ts +4 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/utils/exif-orientation.d.ts +5 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/utils/frontmatter.d.ts +8 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/utils/fs-watch.d.ts +5 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/utils/git.d.ts +26 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/utils/html.d.ts +7 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/utils/image-convert.d.ts +10 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/utils/image-process.d.ts +18 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/utils/image-resize-core.d.ts +30 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/utils/image-resize-worker.d.ts +2 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/utils/image-resize.d.ts +16 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/utils/json.d.ts +3 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/utils/mime.d.ts +3 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/utils/open-browser.d.ts +9 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/utils/paths.d.ts +31 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/utils/photon.d.ts +21 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/utils/pi-user-agent.d.ts +2 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/utils/shell.d.ts +31 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/utils/sleep.d.ts +5 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/utils/syntax-highlight.d.ts +12 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/utils/tools-manager.d.ts +3 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/utils/version-check.d.ts +15 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/utils/windows-self-update.d.ts +3 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/index.mjs +1 -1
- package/dist/extensions/pi-subagents/test/integration/acceptance-file-report.test.ts +0 -54
- package/dist/extensions/pi-subagents/test/integration/async-execution.test.ts +1053 -414
- package/dist/extensions/pi-subagents/test/integration/async-job-tracker.test.ts +194 -4
- package/dist/extensions/pi-subagents/test/integration/async-status.test.ts +59 -4
- package/dist/extensions/pi-subagents/test/integration/error-handling.test.ts +0 -77
- package/dist/extensions/pi-subagents/test/integration/external-cli-runner.test.ts +107 -6
- package/dist/extensions/pi-subagents/test/integration/fork-context-execution.test.ts +211 -897
- package/dist/extensions/pi-subagents/test/integration/intercom-result-delivery.test.ts +265 -375
- package/dist/extensions/pi-subagents/test/integration/orca-progress-tabs.test.ts +77 -7
- package/dist/extensions/pi-subagents/test/integration/render-fork-badge.test.ts +1 -1
- package/dist/extensions/pi-subagents/test/integration/render-widget.test.ts +10 -10
- package/dist/extensions/pi-subagents/test/integration/result-watcher.test.ts +547 -30
- package/dist/extensions/pi-subagents/test/integration/single-execution.test.ts +2112 -310
- package/dist/extensions/pi-subagents/test/integration/slash-commands.test.ts +274 -34
- package/dist/extensions/pi-subagents/test/integration/slash-live-state.test.ts +1 -1
- package/dist/extensions/pi-subagents/test/integration/template-resolution.test.ts +20 -3
- package/dist/extensions/pi-subagents/test/support/isolated-temp-root.mjs +9 -0
- package/dist/extensions/pi-subagents/test/support/mock-pi-script.mjs +30 -5
- package/dist/extensions/pi-subagents/test/support/mock-pi.ts +2 -0
- package/dist/extensions/pi-subagents/test/support/real-session-runner.ts +4 -2
- package/dist/extensions/pi-subagents/test/support/register-loader.mjs +1 -0
- package/dist/extensions/pi-subagents/test/unit/acceptance.test.ts +197 -0
- package/dist/extensions/pi-subagents/test/unit/agent-contract.test.ts +14 -0
- package/dist/extensions/pi-subagents/test/unit/agent-disabled.test.ts +1 -1
- package/dist/extensions/pi-subagents/test/unit/agent-frontmatter.test.ts +204 -27
- package/dist/extensions/pi-subagents/test/unit/agent-management.test.ts +444 -145
- package/dist/extensions/pi-subagents/test/unit/agent-overrides.test.ts +256 -4
- package/dist/extensions/pi-subagents/test/unit/artifacts.test.ts +9 -7
- package/dist/extensions/pi-subagents/test/unit/async-interrupt-action.test.ts +152 -22
- package/dist/extensions/pi-subagents/test/unit/async-recovery-descriptor.test.ts +29 -0
- package/dist/extensions/pi-subagents/test/unit/async-resume.test.ts +205 -23
- package/dist/extensions/pi-subagents/test/unit/async-retention.test.ts +579 -0
- package/dist/extensions/pi-subagents/test/unit/atomic-json.test.ts +24 -0
- package/dist/extensions/pi-subagents/test/unit/authority-policy.test.ts +1 -0
- package/dist/extensions/pi-subagents/test/unit/auto-drain.test.ts +3 -3
- package/dist/extensions/pi-subagents/test/unit/capacity-resilient-json.test.ts +155 -0
- package/dist/extensions/pi-subagents/test/unit/compaction-resume.test.ts +2 -2
- package/dist/extensions/pi-subagents/test/unit/completion-dedupe.test.ts +7 -0
- package/dist/extensions/pi-subagents/test/unit/completion-guard.test.ts +123 -0
- package/dist/extensions/pi-subagents/test/unit/completion-replay.test.ts +81 -3
- package/dist/extensions/pi-subagents/test/unit/control-channel.test.ts +109 -7
- package/dist/extensions/pi-subagents/test/unit/default-extensions.test.ts +2 -2
- package/dist/extensions/pi-subagents/test/unit/doctor.test.ts +5 -2
- package/dist/extensions/pi-subagents/test/unit/dynamic-fanout.test.ts +3 -2
- package/dist/extensions/pi-subagents/test/unit/extension-bindings.test.ts +79 -0
- package/dist/extensions/pi-subagents/test/unit/external-cli-runner.test.ts +22 -0
- package/dist/extensions/pi-subagents/test/unit/external-job-runner.test.ts +961 -0
- package/dist/extensions/pi-subagents/test/unit/file-system-retry.test.ts +64 -0
- package/dist/extensions/pi-subagents/test/unit/fleet-status.test.ts +1110 -0
- package/dist/extensions/pi-subagents/test/unit/fleet.test.ts +1664 -0
- package/dist/extensions/pi-subagents/test/unit/fork-context.test.ts +81 -1
- package/dist/extensions/pi-subagents/test/unit/herdr-inspector.test.ts +138 -11
- package/dist/extensions/pi-subagents/test/unit/herdr-status-bridge.test.ts +41 -2
- package/dist/extensions/pi-subagents/test/unit/index-child-registration.test.ts +210 -79
- package/dist/extensions/pi-subagents/test/unit/index-segment.test.ts +95 -0
- package/dist/extensions/pi-subagents/test/unit/inspect-rpc.test.ts +596 -0
- package/dist/extensions/pi-subagents/test/unit/mission-lifecycle.test.ts +10 -1
- package/dist/extensions/pi-subagents/test/unit/mission-store.test.ts +3 -5
- package/dist/extensions/pi-subagents/test/unit/model-exclusions.test.ts +167 -0
- package/dist/extensions/pi-subagents/test/unit/model-fallback.test.ts +319 -18
- package/dist/extensions/pi-subagents/test/unit/model-info.test.ts +78 -0
- package/dist/extensions/pi-subagents/test/unit/model-scope-settings.test.ts +19 -5
- package/dist/extensions/pi-subagents/test/unit/model-scope.test.ts +44 -0
- package/dist/extensions/pi-subagents/test/unit/mutation-evidence.test.ts +129 -0
- package/dist/extensions/pi-subagents/test/unit/native-supervisor-channel.test.ts +231 -2
- package/dist/extensions/pi-subagents/test/unit/nested-control.test.ts +28 -1
- package/dist/extensions/pi-subagents/test/unit/notify.test.ts +106 -2
- package/dist/extensions/pi-subagents/test/unit/orca-progress-tabs.test.ts +204 -7
- package/dist/extensions/pi-subagents/test/unit/package-manifest.test.ts +59 -4
- package/dist/extensions/pi-subagents/test/unit/path-handling.test.ts +2 -6
- package/dist/extensions/pi-subagents/test/unit/pi-args-permission-system.test.ts +34 -2
- package/dist/extensions/pi-subagents/test/unit/pi-args.test.ts +116 -6
- package/dist/extensions/pi-subagents/test/unit/pi-coding-agent-dir.test.ts +12 -3
- package/dist/extensions/pi-subagents/test/unit/pi-spawn.test.ts +56 -61
- package/dist/extensions/pi-subagents/test/unit/preflight.test.ts +416 -1
- package/dist/extensions/pi-subagents/test/unit/profiles.test.ts +9 -2
- package/dist/extensions/pi-subagents/test/unit/project-panes-public-api.test.ts +42 -0
- package/dist/extensions/pi-subagents/test/unit/prompt-workflows.test.ts +21 -30
- package/dist/extensions/pi-subagents/test/unit/public-execution.test.ts +86 -11
- package/dist/extensions/pi-subagents/test/unit/render-helpers.test.ts +49 -1
- package/dist/extensions/pi-subagents/test/unit/result-files.test.ts +233 -5
- package/dist/extensions/pi-subagents/test/unit/retained-children.test.ts +28 -5
- package/dist/extensions/pi-subagents/test/unit/rpc.test.ts +323 -20
- package/dist/extensions/pi-subagents/test/unit/run-id-resolver.test.ts +66 -10
- package/dist/extensions/pi-subagents/test/unit/run-status.test.ts +68 -5
- package/dist/extensions/pi-subagents/test/unit/runtime-agent-registration.test.ts +174 -0
- package/dist/extensions/pi-subagents/test/unit/scheduled-runs.test.ts +679 -0
- package/dist/extensions/pi-subagents/test/unit/scheduled-store-root.test.ts +67 -0
- package/dist/extensions/pi-subagents/test/unit/schemas.test.ts +55 -44
- package/dist/extensions/pi-subagents/test/unit/scripted-workflow.test.ts +399 -84
- package/dist/extensions/pi-subagents/test/unit/session-lease.test.ts +13 -0
- package/dist/extensions/pi-subagents/test/unit/skills-fallback.test.ts +1 -1
- package/dist/extensions/pi-subagents/test/unit/slash-bridge.test.ts +15 -10
- package/dist/extensions/pi-subagents/test/unit/stale-run-reconciler.test.ts +11 -7
- package/dist/extensions/pi-subagents/test/unit/steering-action.test.ts +2 -0
- package/dist/extensions/pi-subagents/test/unit/steering.test.ts +40 -1
- package/dist/extensions/pi-subagents/test/unit/subagent-action-recovery.test.ts +10 -2
- package/dist/extensions/pi-subagents/test/unit/subagent-control.test.ts +38 -3
- package/dist/extensions/pi-subagents/test/unit/subagent-prompt-runtime.test.ts +110 -12
- package/dist/extensions/pi-subagents/test/unit/subagent-wait.test.ts +204 -19
- package/dist/extensions/pi-subagents/test/unit/temp-paths.test.ts +25 -0
- package/dist/extensions/pi-subagents/test/unit/thinking-ceiling.test.ts +73 -0
- package/dist/extensions/pi-subagents/test/unit/tool-description.test.ts +90 -50
- package/dist/extensions/pi-subagents/test/unit/tool-timeout.test.ts +1 -2
- package/dist/extensions/pi-subagents/test/unit/wait-subscriptions.test.ts +234 -7
- package/dist/extensions/pi-subagents/test/unit/watch-strategy.test.ts +24 -0
- package/dist/extensions/pi-subagents/test/unit/watchdog-permission-arbiter.test.ts +36 -0
- package/dist/extensions/pi-subagents/test/unit/workflow-chat-progress.test.ts +37 -9
- package/dist/extensions/pi-subagents/test/unit/workflow-detach-reconcile.test.ts +302 -0
- package/dist/extensions/pi-subagents/test/unit/workflow-launch-params.test.ts +167 -7
- package/dist/extensions/pi-subagents/test/unit/workflow-receipt.test.ts +113 -0
- package/dist/extensions/pi-subagents/test/unit/worktree.test.ts +6 -6
- package/dist/extensions/ponytail/index.js +31 -25
- package/dist/extensions/ponytail/ponytail-config.cjs +34 -7
- package/dist/extensions/ponytail/ponytail-instructions.cjs +7 -9
- package/dist/extensions/ponytail/test/extension.test.js +7 -8
- package/dist/extensions/ponytail/test/helpers.test.js +1 -1
- package/dist/skills/brandkit/SKILL.md +799 -0
- package/dist/skills/design-taste-frontend/SKILL.md +1207 -0
- package/dist/skills/design-taste-frontend-v1/SKILL.md +227 -0
- package/dist/skills/full-output-enforcement/SKILL.md +50 -0
- package/dist/skills/gpt-taste/SKILL.md +75 -0
- package/dist/skills/high-end-visual-design/SKILL.md +99 -0
- package/dist/skills/image-to-code/SKILL.md +1229 -0
- package/dist/skills/imagegen-frontend-mobile/SKILL.md +1466 -0
- package/dist/skills/imagegen-frontend-web/SKILL.md +988 -0
- package/dist/skills/industrial-brutalist-ui/SKILL.md +93 -0
- package/dist/skills/minimalist-ui/SKILL.md +86 -0
- package/dist/skills/pi-subagents/SKILL.md +18 -17
- package/dist/skills/pi-subagents/references/constraints-and-recipes.md +31 -9
- package/dist/skills/pi-subagents/references/execution-controls.md +95 -143
- package/dist/skills/pi-subagents/references/management-authoring-rpc.md +9 -12
- package/dist/skills/pi-subagents/references/multi-lane-orchestration.md +39 -0
- package/dist/skills/pi-subagents/references/prompting-and-roles.md +45 -94
- package/dist/skills/ponytail/SKILL.md +12 -8
- package/dist/skills/ponytail-audit/SKILL.md +0 -1
- package/dist/skills/ponytail-debt/SKILL.md +0 -1
- package/dist/skills/ponytail-gain/SKILL.md +0 -1
- package/dist/skills/ponytail-help/SKILL.md +4 -3
- package/dist/skills/ponytail-review/SKILL.md +0 -1
- package/dist/skills/redesign-existing-projects/SKILL.md +179 -0
- package/dist/skills/stitch-design-taste/SKILL.md +185 -0
- package/dist/skills/unlazy/CHANGELOG.md +100 -0
- package/dist/skills/unlazy/CONTRIBUTING.md +66 -0
- package/dist/skills/unlazy/LICENSE +21 -0
- package/dist/skills/unlazy/README.md +242 -0
- package/dist/skills/unlazy/SECURITY.md +70 -0
- package/dist/skills/unlazy/SKILL.md +100 -0
- package/dist/skills/unlazy/package.json +13 -0
- package/dist/skills/unlazy/references/dispatch.md +82 -0
- package/dist/skills/unlazy/references/gates.md +132 -0
- package/dist/skills/unlazy/references/method.md +49 -0
- package/dist/skills/unlazy/references/orchestration.md +99 -0
- package/dist/skills/unlazy/references/parallel.md +123 -0
- package/dist/skills/unlazy/references/token-economy.md +39 -0
- package/dist/skills/unlazy/research/validation-protocol.md +81 -0
- package/dist/skills/unlazy/scripts/dispatch-check.mjs +108 -0
- package/dist/skills/unlazy/scripts/gate-check.mjs +894 -0
- package/dist/skills/unlazy/scripts/gate-lint.mjs +178 -0
- package/dist/skills/unlazy/scripts/install-hooks.mjs +206 -0
- package/dist/skills/unlazy/scripts/lib/check-supervisor.mjs +46 -0
- package/dist/skills/unlazy/scripts/lib/dispatch.mjs +283 -0
- package/dist/skills/unlazy/scripts/lib/gates.mjs +629 -0
- package/dist/skills/unlazy/scripts/lib/process-tree.mjs +161 -0
- package/dist/skills/unlazy/scripts/lib/regex-worker.mjs +9 -0
- package/dist/skills/unlazy/scripts/stop-hook.mjs +174 -0
- package/dist/skills/unlazy/templates/PLAN.md +65 -0
- package/dist/skills/unlazy/templates/gates-leaf.md +51 -0
- package/dist/skills/unlazy/templates/gates-node.md +50 -0
- package/dist/skills/unlazy/tests/contract-tests.mjs +127 -0
- package/dist/skills/unlazy/tests/dispatch-tests.mjs +481 -0
- package/dist/skills/unlazy/tests/hardening-tests.mjs +903 -0
- package/dist/skills/unlazy/tests/lint-tests.mjs +242 -0
- package/dist/skills/unlazy/tests/run-tests.mjs +554 -0
- package/dist/skills/unlazy/tests/self-check.mjs +165 -0
- package/dist/skills/unlazy/tests/stress-tests.mjs +356 -0
- package/dist/skills/web-design-guidelines/SKILL.md +40 -0
- package/docs/settings.md +0 -5
- package/package.json +1 -1
- package/dist/core/tools/schema-prune.d.ts +0 -16
- package/dist/core/tools/schema-prune.js +0 -39
- package/dist/core/tools/schema-prune.test.d.ts +0 -1
- package/dist/core/tools/schema-prune.test.js +0 -111
- package/dist/extensions/pi-subagents/UPSTREAM-V0.50-MAPPING.md +0 -172
- package/dist/extensions/pi-subagents/prompts/parallel-context-build.md +0 -55
- package/dist/extensions/pi-subagents/prompts/parallel-handoff-plan.md +0 -61
- package/dist/extensions/pi-subagents/src/agents/task-aware-routing.ts +0 -132
- package/dist/extensions/pi-subagents/src/extension/chain-validation.ts +0 -181
- package/dist/extensions/pi-subagents/src/runs/foreground/chain-clarify.ts +0 -1354
- package/dist/extensions/pi-subagents/src/runs/foreground/chain-execution.ts +0 -1581
- package/dist/extensions/pi-subagents/src/shared/env.ts +0 -16
- package/dist/extensions/pi-subagents/src/shared/session-lineage.ts +0 -71
- package/dist/extensions/pi-subagents/src/slash/inline-subagents.ts +0 -136
- package/dist/extensions/pi-subagents/src/workflows/workflow-auto-relaunch.ts +0 -41
- package/dist/extensions/pi-subagents/test/integration/chain-clarify.test.ts +0 -466
- package/dist/extensions/pi-subagents/test/integration/chain-execution.test.ts +0 -1859
- package/dist/extensions/pi-subagents/test/integration/parallel-execution.test.ts +0 -733
- package/dist/extensions/pi-subagents/test/unit/builtin-agent-documentation.test.ts +0 -63
- package/dist/extensions/pi-subagents/test/unit/chain-validation.test.ts +0 -326
- package/dist/extensions/pi-subagents/test/unit/handoff-adoption.test.ts +0 -103
- package/dist/extensions/pi-subagents/test/unit/inline-subagents.test.ts +0 -127
- package/dist/extensions/pi-subagents/test/unit/session-lineage.test.ts +0 -73
- package/dist/extensions/pi-subagents/test/unit/task-aware-routing.test.ts +0 -213
- package/dist/extensions/pi-subagents/test/unit/workflow-auto-relaunch.test.ts +0 -65
|
@@ -1,1354 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Chain Clarification TUI Component
|
|
3
|
-
*
|
|
4
|
-
* Shows templates and resolved behaviors for each step in a chain.
|
|
5
|
-
* Supports runtime editing of templates, output paths, reads lists, and progress toggle.
|
|
6
|
-
*/
|
|
7
|
-
|
|
8
|
-
import type { Theme } from "@selesai/code";
|
|
9
|
-
import type { Component, TUI } from "@earendil-works/pi-tui";
|
|
10
|
-
import { matchesKey, visibleWidth, truncateToWidth } from "@earendil-works/pi-tui";
|
|
11
|
-
import type { AgentConfig } from "../../agents/agents.ts";
|
|
12
|
-
import type { ResolvedStepBehavior } from "../../shared/settings.ts";
|
|
13
|
-
import { resolveModelCandidate, splitThinkingSuffix } from "../shared/model-fallback.ts";
|
|
14
|
-
import { findModelInfo, getSupportedThinkingLevels, type ModelInfo, type ThinkingLevel } from "../../shared/model-info.ts";
|
|
15
|
-
|
|
16
|
-
type ClarifyMode = 'single' | 'parallel' | 'chain';
|
|
17
|
-
|
|
18
|
-
export interface BehaviorOverride {
|
|
19
|
-
output?: string | false;
|
|
20
|
-
reads?: string[] | false;
|
|
21
|
-
progress?: boolean;
|
|
22
|
-
model?: string;
|
|
23
|
-
skills?: string[] | false;
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
export interface ChainClarifyResult {
|
|
27
|
-
confirmed: boolean;
|
|
28
|
-
templates: string[];
|
|
29
|
-
behaviorOverrides: (BehaviorOverride | undefined)[];
|
|
30
|
-
runInBackground?: boolean;
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
type EditMode = "template" | "output" | "reads" | "model" | "thinking" | "skills";
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
interface TextEditorState {
|
|
37
|
-
buffer: string;
|
|
38
|
-
cursor: number;
|
|
39
|
-
viewportOffset: number;
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
function createEditorState(initial = ""): TextEditorState {
|
|
43
|
-
return { buffer: initial, cursor: 0, viewportOffset: 0 };
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
function wrapText(text: string, width: number): { lines: string[]; starts: number[] } {
|
|
47
|
-
if (width <= 0) return { lines: [text], starts: [0] };
|
|
48
|
-
if (text.length === 0) return { lines: [""], starts: [0] };
|
|
49
|
-
|
|
50
|
-
const lines: string[] = [];
|
|
51
|
-
const starts: number[] = [];
|
|
52
|
-
let offset = 0;
|
|
53
|
-
const segments = text.split("\n");
|
|
54
|
-
for (const [index, segment] of segments.entries()) {
|
|
55
|
-
if (segment.length === 0) {
|
|
56
|
-
starts.push(offset);
|
|
57
|
-
lines.push("");
|
|
58
|
-
} else {
|
|
59
|
-
let lineStart = 0;
|
|
60
|
-
let pos = 0;
|
|
61
|
-
let lineWidth = 0;
|
|
62
|
-
while (pos < segment.length) {
|
|
63
|
-
const char = String.fromCodePoint(segment.codePointAt(pos)!);
|
|
64
|
-
const charWidth = visibleWidth(char);
|
|
65
|
-
if (lineWidth > 0 && lineWidth + charWidth > width) {
|
|
66
|
-
starts.push(offset + lineStart);
|
|
67
|
-
lines.push(segment.slice(lineStart, pos));
|
|
68
|
-
lineStart = pos;
|
|
69
|
-
lineWidth = 0;
|
|
70
|
-
continue;
|
|
71
|
-
}
|
|
72
|
-
pos += char.length;
|
|
73
|
-
lineWidth += charWidth;
|
|
74
|
-
}
|
|
75
|
-
starts.push(offset + lineStart);
|
|
76
|
-
lines.push(segment.slice(lineStart));
|
|
77
|
-
}
|
|
78
|
-
offset += segment.length + (index < segments.length - 1 ? 1 : 0);
|
|
79
|
-
}
|
|
80
|
-
if (!text.endsWith("\n") && text.length > 0 && visibleWidth(lines[lines.length - 1] ?? "") === width) {
|
|
81
|
-
starts.push(text.length);
|
|
82
|
-
lines.push("");
|
|
83
|
-
}
|
|
84
|
-
return { lines, starts };
|
|
85
|
-
}
|
|
86
|
-
|
|
87
|
-
function getCursorDisplayPos(cursor: number, starts: number[]): { line: number; col: number } {
|
|
88
|
-
for (let i = starts.length - 1; i >= 0; i--) {
|
|
89
|
-
if (cursor >= starts[i]!) return { line: i, col: cursor - starts[i]! };
|
|
90
|
-
}
|
|
91
|
-
return { line: 0, col: 0 };
|
|
92
|
-
}
|
|
93
|
-
|
|
94
|
-
function ensureCursorVisible(cursorLine: number, viewportHeight: number, currentOffset: number): number {
|
|
95
|
-
if (cursorLine < currentOffset) return Math.max(0, cursorLine);
|
|
96
|
-
if (cursorLine >= currentOffset + viewportHeight) return Math.max(0, cursorLine - viewportHeight + 1);
|
|
97
|
-
return Math.max(0, currentOffset);
|
|
98
|
-
}
|
|
99
|
-
|
|
100
|
-
function isWordChar(ch: string): boolean {
|
|
101
|
-
const code = ch.charCodeAt(0);
|
|
102
|
-
return (code >= 48 && code <= 57) || (code >= 65 && code <= 90) || (code >= 97 && code <= 122) || code === 95;
|
|
103
|
-
}
|
|
104
|
-
|
|
105
|
-
function wordBackward(buffer: string, cursor: number): number {
|
|
106
|
-
let pos = cursor;
|
|
107
|
-
while (pos > 0 && !isWordChar(buffer[pos - 1]!)) pos--;
|
|
108
|
-
while (pos > 0 && isWordChar(buffer[pos - 1]!)) pos--;
|
|
109
|
-
return pos;
|
|
110
|
-
}
|
|
111
|
-
|
|
112
|
-
function wordForward(buffer: string, cursor: number): number {
|
|
113
|
-
let pos = cursor;
|
|
114
|
-
while (pos < buffer.length && isWordChar(buffer[pos]!)) pos++;
|
|
115
|
-
while (pos < buffer.length && !isWordChar(buffer[pos]!)) pos++;
|
|
116
|
-
return pos;
|
|
117
|
-
}
|
|
118
|
-
|
|
119
|
-
function normalizeInsertText(data: string): string | null {
|
|
120
|
-
let text = data.split("\x1b[200~").join("").split("\x1b[201~").join("");
|
|
121
|
-
text = text.replace(/\r\n/g, "\n").replace(/\r/g, "\n");
|
|
122
|
-
const newline = text.indexOf("\n");
|
|
123
|
-
if (newline !== -1) text = text.slice(0, newline);
|
|
124
|
-
text = text.replace(/\t/g, " ");
|
|
125
|
-
if (text.length === 0) return null;
|
|
126
|
-
for (let i = 0; i < text.length; i++) {
|
|
127
|
-
if (text.charCodeAt(i) < 32) return null;
|
|
128
|
-
}
|
|
129
|
-
return text;
|
|
130
|
-
}
|
|
131
|
-
|
|
132
|
-
function handleEditorInput(state: TextEditorState, data: string, textWidth: number): TextEditorState | null {
|
|
133
|
-
if (matchesKey(data, "escape") || matchesKey(data, "ctrl+c") || matchesKey(data, "return")) return null;
|
|
134
|
-
|
|
135
|
-
const { lines: wrapped, starts } = wrapText(state.buffer, textWidth);
|
|
136
|
-
const cursorPos = getCursorDisplayPos(state.cursor, starts);
|
|
137
|
-
|
|
138
|
-
if (matchesKey(data, "alt+left") || matchesKey(data, "ctrl+left")) return { ...state, cursor: wordBackward(state.buffer, state.cursor) };
|
|
139
|
-
if (matchesKey(data, "alt+right") || matchesKey(data, "ctrl+right")) return { ...state, cursor: wordForward(state.buffer, state.cursor) };
|
|
140
|
-
if (matchesKey(data, "left")) return state.cursor > 0 ? { ...state, cursor: state.cursor - 1 } : state;
|
|
141
|
-
if (matchesKey(data, "right")) return state.cursor < state.buffer.length ? { ...state, cursor: state.cursor + 1 } : state;
|
|
142
|
-
if (matchesKey(data, "up") && cursorPos.line > 0) {
|
|
143
|
-
const targetLine = cursorPos.line - 1;
|
|
144
|
-
return { ...state, cursor: starts[targetLine]! + Math.min(cursorPos.col, wrapped[targetLine]?.length ?? 0) };
|
|
145
|
-
}
|
|
146
|
-
if (matchesKey(data, "down") && cursorPos.line < wrapped.length - 1) {
|
|
147
|
-
const targetLine = cursorPos.line + 1;
|
|
148
|
-
return { ...state, cursor: starts[targetLine]! + Math.min(cursorPos.col, wrapped[targetLine]?.length ?? 0) };
|
|
149
|
-
}
|
|
150
|
-
if (matchesKey(data, "home")) return { ...state, cursor: starts[cursorPos.line]! };
|
|
151
|
-
if (matchesKey(data, "end")) return { ...state, cursor: starts[cursorPos.line]! + (wrapped[cursorPos.line]?.length ?? 0) };
|
|
152
|
-
if (matchesKey(data, "ctrl+home")) return { ...state, cursor: 0 };
|
|
153
|
-
if (matchesKey(data, "ctrl+end")) return { ...state, cursor: state.buffer.length };
|
|
154
|
-
if (matchesKey(data, "alt+backspace")) {
|
|
155
|
-
const target = wordBackward(state.buffer, state.cursor);
|
|
156
|
-
return target === state.cursor ? state : { ...state, buffer: state.buffer.slice(0, target) + state.buffer.slice(state.cursor), cursor: target };
|
|
157
|
-
}
|
|
158
|
-
if (matchesKey(data, "backspace")) {
|
|
159
|
-
return state.cursor > 0
|
|
160
|
-
? { ...state, buffer: state.buffer.slice(0, state.cursor - 1) + state.buffer.slice(state.cursor), cursor: state.cursor - 1 }
|
|
161
|
-
: state;
|
|
162
|
-
}
|
|
163
|
-
if (matchesKey(data, "delete")) {
|
|
164
|
-
return state.cursor < state.buffer.length
|
|
165
|
-
? { ...state, buffer: state.buffer.slice(0, state.cursor) + state.buffer.slice(state.cursor + 1) }
|
|
166
|
-
: state;
|
|
167
|
-
}
|
|
168
|
-
|
|
169
|
-
const insert = normalizeInsertText(data);
|
|
170
|
-
return insert
|
|
171
|
-
? { ...state, buffer: state.buffer.slice(0, state.cursor) + insert + state.buffer.slice(state.cursor), cursor: state.cursor + insert.length }
|
|
172
|
-
: null;
|
|
173
|
-
}
|
|
174
|
-
|
|
175
|
-
function renderWithCursor(text: string, cursorPos: number): string {
|
|
176
|
-
const before = text.slice(0, cursorPos);
|
|
177
|
-
const cursorChar = text[cursorPos] ?? " ";
|
|
178
|
-
const after = text.slice(cursorPos + 1);
|
|
179
|
-
return `${before}\x1b[7m${cursorChar}\x1b[27m${after}`;
|
|
180
|
-
}
|
|
181
|
-
|
|
182
|
-
function renderEditor(state: TextEditorState, width: number, viewportHeight: number): string[] {
|
|
183
|
-
const { lines: wrapped, starts } = wrapText(state.buffer, width);
|
|
184
|
-
const cursorPos = getCursorDisplayPos(state.cursor, starts);
|
|
185
|
-
const lines: string[] = [];
|
|
186
|
-
for (let i = 0; i < viewportHeight; i++) {
|
|
187
|
-
const lineIdx = state.viewportOffset + i;
|
|
188
|
-
let content = lineIdx < wrapped.length ? wrapped[lineIdx] ?? "" : "";
|
|
189
|
-
if (lineIdx === cursorPos.line) content = renderWithCursor(content, cursorPos.col);
|
|
190
|
-
lines.push(content);
|
|
191
|
-
}
|
|
192
|
-
return lines;
|
|
193
|
-
}
|
|
194
|
-
|
|
195
|
-
/**
|
|
196
|
-
* TUI component for chain clarification.
|
|
197
|
-
* Factory signature matches ctx.ui.custom: (tui, theme, kb, done) => Component
|
|
198
|
-
*/
|
|
199
|
-
export class ChainClarifyComponent implements Component {
|
|
200
|
-
readonly width = 84;
|
|
201
|
-
|
|
202
|
-
private selectedStep = 0;
|
|
203
|
-
private editingStep: number | null = null;
|
|
204
|
-
private editMode: EditMode = "template";
|
|
205
|
-
private editState: TextEditorState = createEditorState();
|
|
206
|
-
|
|
207
|
-
private readonly EDIT_VIEWPORT_HEIGHT = 12;
|
|
208
|
-
private behaviorOverrides: Map<number, BehaviorOverride> = new Map();
|
|
209
|
-
private modelSearchQuery: string = "";
|
|
210
|
-
private modelSelectedIndex: number = 0;
|
|
211
|
-
private filteredModels: ModelInfo[] = [];
|
|
212
|
-
private readonly MODEL_SELECTOR_HEIGHT = 10;
|
|
213
|
-
private thinkingSelectedIndex: number = 0;
|
|
214
|
-
private skillSearchQuery: string = "";
|
|
215
|
-
private skillSelectedNames: Set<string> = new Set();
|
|
216
|
-
private skillCursorIndex: number = 0;
|
|
217
|
-
private filteredSkills: Array<{ name: string; source: string; description?: string }> = [];
|
|
218
|
-
private noticeMessage: { text: string; type: "info" | "error" } | null = null;
|
|
219
|
-
private noticeMessageTimer: ReturnType<typeof setTimeout> | null = null;
|
|
220
|
-
/** Run in background (async) mode */
|
|
221
|
-
private runInBackground = false;
|
|
222
|
-
private tui: TUI;
|
|
223
|
-
private theme: Theme;
|
|
224
|
-
private agentConfigs: AgentConfig[];
|
|
225
|
-
private templates: string[];
|
|
226
|
-
private originalTask: string;
|
|
227
|
-
private chainDir: string | undefined;
|
|
228
|
-
private resolvedBehaviors: ResolvedStepBehavior[];
|
|
229
|
-
private availableModels: ModelInfo[];
|
|
230
|
-
private preferredProvider: string | undefined;
|
|
231
|
-
private availableSkills: Array<{ name: string; source: string; description?: string }>;
|
|
232
|
-
private done: (result: ChainClarifyResult) => void;
|
|
233
|
-
private mode: ClarifyMode;
|
|
234
|
-
|
|
235
|
-
constructor(
|
|
236
|
-
tui: TUI,
|
|
237
|
-
theme: Theme,
|
|
238
|
-
agentConfigs: AgentConfig[],
|
|
239
|
-
templates: string[],
|
|
240
|
-
originalTask: string,
|
|
241
|
-
chainDir: string | undefined,
|
|
242
|
-
resolvedBehaviors: ResolvedStepBehavior[],
|
|
243
|
-
availableModels: ModelInfo[],
|
|
244
|
-
preferredProvider: string | undefined,
|
|
245
|
-
availableSkills: Array<{ name: string; source: string; description?: string }>,
|
|
246
|
-
done: (result: ChainClarifyResult) => void,
|
|
247
|
-
mode: ClarifyMode = 'chain',
|
|
248
|
-
) {
|
|
249
|
-
this.tui = tui;
|
|
250
|
-
this.theme = theme;
|
|
251
|
-
this.agentConfigs = agentConfigs;
|
|
252
|
-
this.templates = templates;
|
|
253
|
-
this.originalTask = originalTask;
|
|
254
|
-
this.chainDir = chainDir;
|
|
255
|
-
this.resolvedBehaviors = resolvedBehaviors;
|
|
256
|
-
this.availableModels = availableModels;
|
|
257
|
-
this.preferredProvider = preferredProvider;
|
|
258
|
-
this.availableSkills = availableSkills;
|
|
259
|
-
this.done = done;
|
|
260
|
-
this.mode = mode;
|
|
261
|
-
this.filteredModels = [...availableModels];
|
|
262
|
-
this.filteredSkills = [...availableSkills];
|
|
263
|
-
}
|
|
264
|
-
|
|
265
|
-
// ─────────────────────────────────────────────────────────────────────────────
|
|
266
|
-
// Helper methods for rendering
|
|
267
|
-
// ─────────────────────────────────────────────────────────────────────────────
|
|
268
|
-
|
|
269
|
-
/** Pad string to specified visible width */
|
|
270
|
-
private pad(s: string, len: number): string {
|
|
271
|
-
const vis = visibleWidth(s);
|
|
272
|
-
return s + " ".repeat(Math.max(0, len - vis));
|
|
273
|
-
}
|
|
274
|
-
|
|
275
|
-
/** Create a row with border characters */
|
|
276
|
-
private row(content: string): string {
|
|
277
|
-
const innerW = this.width - 2;
|
|
278
|
-
return this.theme.fg("border", "│") + this.pad(content, innerW) + this.theme.fg("border", "│");
|
|
279
|
-
}
|
|
280
|
-
|
|
281
|
-
/** Render centered header line with border */
|
|
282
|
-
private renderHeader(text: string): string {
|
|
283
|
-
const innerW = this.width - 2;
|
|
284
|
-
const padLen = Math.max(0, innerW - visibleWidth(text));
|
|
285
|
-
const padLeft = Math.floor(padLen / 2);
|
|
286
|
-
const padRight = padLen - padLeft;
|
|
287
|
-
return (
|
|
288
|
-
this.theme.fg("border", "╭" + "─".repeat(padLeft)) +
|
|
289
|
-
this.theme.fg("accent", text) +
|
|
290
|
-
this.theme.fg("border", "─".repeat(padRight) + "╮")
|
|
291
|
-
);
|
|
292
|
-
}
|
|
293
|
-
|
|
294
|
-
/** Render centered footer line with border */
|
|
295
|
-
private renderFooter(text: string): string {
|
|
296
|
-
const innerW = this.width - 2;
|
|
297
|
-
const padLen = Math.max(0, innerW - visibleWidth(text));
|
|
298
|
-
const padLeft = Math.floor(padLen / 2);
|
|
299
|
-
const padRight = padLen - padLeft;
|
|
300
|
-
return (
|
|
301
|
-
this.theme.fg("border", "╰" + "─".repeat(padLeft)) +
|
|
302
|
-
this.theme.fg("dim", text) +
|
|
303
|
-
this.theme.fg("border", "─".repeat(padRight) + "╯")
|
|
304
|
-
);
|
|
305
|
-
}
|
|
306
|
-
|
|
307
|
-
/** Exit edit mode and reset state */
|
|
308
|
-
private exitEditMode(): void {
|
|
309
|
-
this.editingStep = null;
|
|
310
|
-
this.editState = createEditorState();
|
|
311
|
-
this.tui.requestRender();
|
|
312
|
-
}
|
|
313
|
-
|
|
314
|
-
// ─────────────────────────────────────────────────────────────────────────────
|
|
315
|
-
// Full edit mode methods
|
|
316
|
-
// ─────────────────────────────────────────────────────────────────────────────
|
|
317
|
-
|
|
318
|
-
/** Render the full-edit takeover view */
|
|
319
|
-
private renderFullEditMode(): string[] {
|
|
320
|
-
const innerW = this.width - 2;
|
|
321
|
-
const textWidth = innerW - 2; // 1 char padding on each side
|
|
322
|
-
const lines: string[] = [];
|
|
323
|
-
|
|
324
|
-
const { lines: wrapped, starts } = wrapText(this.editState.buffer, textWidth);
|
|
325
|
-
const cursorPos = getCursorDisplayPos(this.editState.cursor, starts);
|
|
326
|
-
this.editState = {
|
|
327
|
-
...this.editState,
|
|
328
|
-
viewportOffset: ensureCursorVisible(
|
|
329
|
-
cursorPos.line,
|
|
330
|
-
this.EDIT_VIEWPORT_HEIGHT,
|
|
331
|
-
this.editState.viewportOffset,
|
|
332
|
-
),
|
|
333
|
-
};
|
|
334
|
-
|
|
335
|
-
// Header (truncate agent name to prevent overflow)
|
|
336
|
-
const fieldName = this.editMode === "template" ? "task" : this.editMode;
|
|
337
|
-
const rawAgentName = this.agentConfigs[this.editingStep!]?.name ?? "unknown";
|
|
338
|
-
const maxAgentLen = innerW - 30; // Reserve space for " Editing X (Step/Task N: ) "
|
|
339
|
-
const agentName = rawAgentName.length > maxAgentLen
|
|
340
|
-
? rawAgentName.slice(0, maxAgentLen - 1) + "…"
|
|
341
|
-
: rawAgentName;
|
|
342
|
-
// Use mode-appropriate terminology
|
|
343
|
-
const stepLabel = this.mode === 'single'
|
|
344
|
-
? agentName
|
|
345
|
-
: this.mode === 'parallel'
|
|
346
|
-
? `Task ${this.editingStep! + 1}: ${agentName}`
|
|
347
|
-
: `Step ${this.editingStep! + 1}: ${agentName}`;
|
|
348
|
-
const headerText = ` Editing ${fieldName} (${stepLabel}) `;
|
|
349
|
-
lines.push(this.renderHeader(headerText));
|
|
350
|
-
lines.push(this.row(""));
|
|
351
|
-
|
|
352
|
-
const editorLines = renderEditor(this.editState, textWidth, this.EDIT_VIEWPORT_HEIGHT);
|
|
353
|
-
for (const line of editorLines) {
|
|
354
|
-
lines.push(this.row(` ${line}`));
|
|
355
|
-
}
|
|
356
|
-
|
|
357
|
-
const linesBelow = wrapped.length - this.editState.viewportOffset - this.EDIT_VIEWPORT_HEIGHT;
|
|
358
|
-
const hasMore = linesBelow > 0;
|
|
359
|
-
const hasLess = this.editState.viewportOffset > 0;
|
|
360
|
-
let scrollInfo = "";
|
|
361
|
-
if (hasLess) scrollInfo += "↑";
|
|
362
|
-
if (hasMore) scrollInfo += `↓ ${linesBelow}+`;
|
|
363
|
-
|
|
364
|
-
lines.push(this.row(""));
|
|
365
|
-
|
|
366
|
-
const footerText = scrollInfo
|
|
367
|
-
? ` [Esc] Done • [Ctrl+C] Discard • ${scrollInfo} `
|
|
368
|
-
: " [Esc] Done • [Ctrl+C] Discard ";
|
|
369
|
-
lines.push(this.renderFooter(footerText));
|
|
370
|
-
|
|
371
|
-
return lines;
|
|
372
|
-
}
|
|
373
|
-
|
|
374
|
-
// ─────────────────────────────────────────────────────────────────────────────
|
|
375
|
-
// Behavior helpers
|
|
376
|
-
// ─────────────────────────────────────────────────────────────────────────────
|
|
377
|
-
|
|
378
|
-
/** Get effective behavior for a step (with user overrides applied) */
|
|
379
|
-
private getEffectiveBehavior(stepIndex: number): ResolvedStepBehavior {
|
|
380
|
-
const base = this.resolvedBehaviors[stepIndex]!;
|
|
381
|
-
const override = this.behaviorOverrides.get(stepIndex);
|
|
382
|
-
if (!override) return base;
|
|
383
|
-
|
|
384
|
-
return {
|
|
385
|
-
output: override.output !== undefined ? override.output : base.output,
|
|
386
|
-
outputMode: base.outputMode,
|
|
387
|
-
reads: override.reads !== undefined ? override.reads : base.reads,
|
|
388
|
-
progress: override.progress !== undefined ? override.progress : base.progress,
|
|
389
|
-
skills: override.skills !== undefined ? override.skills : base.skills,
|
|
390
|
-
model: override.model !== undefined ? override.model : base.model,
|
|
391
|
-
};
|
|
392
|
-
}
|
|
393
|
-
|
|
394
|
-
/** Get the effective model for a step (override or agent default) */
|
|
395
|
-
private getEffectiveModel(stepIndex: number): string {
|
|
396
|
-
const override = this.behaviorOverrides.get(stepIndex);
|
|
397
|
-
if (override?.model) return this.resolveModelFullId(override.model);
|
|
398
|
-
|
|
399
|
-
const baseModel = this.resolvedBehaviors[stepIndex]?.model;
|
|
400
|
-
if (baseModel) return this.resolveModelFullId(baseModel);
|
|
401
|
-
return "default";
|
|
402
|
-
}
|
|
403
|
-
|
|
404
|
-
/** Resolve a model name to its full provider/model format */
|
|
405
|
-
private resolveModelFullId(modelName: string): string {
|
|
406
|
-
return resolveModelCandidate(modelName, this.availableModels, this.preferredProvider) ?? modelName;
|
|
407
|
-
}
|
|
408
|
-
|
|
409
|
-
/** Update a behavior override for a step */
|
|
410
|
-
private updateBehavior(stepIndex: number, field: keyof BehaviorOverride, value: string | boolean | string[] | false): void {
|
|
411
|
-
const existing = this.behaviorOverrides.get(stepIndex) ?? {};
|
|
412
|
-
this.behaviorOverrides.set(stepIndex, { ...existing, [field]: value });
|
|
413
|
-
}
|
|
414
|
-
|
|
415
|
-
private showNotice(text: string, type: "info" | "error"): void {
|
|
416
|
-
this.noticeMessage = { text, type };
|
|
417
|
-
if (this.noticeMessageTimer) clearTimeout(this.noticeMessageTimer);
|
|
418
|
-
this.noticeMessageTimer = setTimeout(() => {
|
|
419
|
-
this.noticeMessage = null;
|
|
420
|
-
this.noticeMessageTimer = null;
|
|
421
|
-
this.tui.requestRender();
|
|
422
|
-
}, 2000);
|
|
423
|
-
this.tui.requestRender();
|
|
424
|
-
}
|
|
425
|
-
|
|
426
|
-
handleInput(data: string): void {
|
|
427
|
-
if (this.editingStep !== null) {
|
|
428
|
-
if (this.editMode === "model") {
|
|
429
|
-
this.handleModelSelectorInput(data);
|
|
430
|
-
} else if (this.editMode === "thinking") {
|
|
431
|
-
this.handleThinkingSelectorInput(data);
|
|
432
|
-
} else if (this.editMode === "skills") {
|
|
433
|
-
this.handleSkillSelectorInput(data);
|
|
434
|
-
} else {
|
|
435
|
-
this.handleEditInput(data);
|
|
436
|
-
}
|
|
437
|
-
return;
|
|
438
|
-
}
|
|
439
|
-
|
|
440
|
-
if (matchesKey(data, "escape") || matchesKey(data, "ctrl+c")) {
|
|
441
|
-
this.done({ confirmed: false, templates: [], behaviorOverrides: [] });
|
|
442
|
-
return;
|
|
443
|
-
}
|
|
444
|
-
|
|
445
|
-
if (matchesKey(data, "return")) {
|
|
446
|
-
const overrides: (BehaviorOverride | undefined)[] = [];
|
|
447
|
-
for (let i = 0; i < this.agentConfigs.length; i++) {
|
|
448
|
-
overrides.push(this.behaviorOverrides.get(i));
|
|
449
|
-
}
|
|
450
|
-
this.done({ confirmed: true, templates: this.templates, behaviorOverrides: overrides, runInBackground: this.runInBackground });
|
|
451
|
-
return;
|
|
452
|
-
}
|
|
453
|
-
|
|
454
|
-
if (matchesKey(data, "up") || matchesKey(data, "k")) {
|
|
455
|
-
this.selectedStep = Math.max(0, this.selectedStep - 1);
|
|
456
|
-
this.tui.requestRender();
|
|
457
|
-
return;
|
|
458
|
-
}
|
|
459
|
-
|
|
460
|
-
if (matchesKey(data, "down") || matchesKey(data, "j")) {
|
|
461
|
-
const maxStep = Math.max(0, this.agentConfigs.length - 1);
|
|
462
|
-
this.selectedStep = Math.min(maxStep, this.selectedStep + 1);
|
|
463
|
-
this.tui.requestRender();
|
|
464
|
-
return;
|
|
465
|
-
}
|
|
466
|
-
|
|
467
|
-
if (data === "e") {
|
|
468
|
-
this.enterEditMode("template");
|
|
469
|
-
return;
|
|
470
|
-
}
|
|
471
|
-
|
|
472
|
-
if (data === "m") {
|
|
473
|
-
this.enterModelSelector();
|
|
474
|
-
return;
|
|
475
|
-
}
|
|
476
|
-
|
|
477
|
-
if (data === "t") {
|
|
478
|
-
this.enterThinkingSelector();
|
|
479
|
-
return;
|
|
480
|
-
}
|
|
481
|
-
|
|
482
|
-
if (data === "s") {
|
|
483
|
-
this.editingStep = this.selectedStep;
|
|
484
|
-
this.editMode = "skills";
|
|
485
|
-
this.skillSearchQuery = "";
|
|
486
|
-
this.skillCursorIndex = 0;
|
|
487
|
-
this.filteredSkills = [...this.availableSkills];
|
|
488
|
-
const current = this.getEffectiveBehavior(this.selectedStep).skills;
|
|
489
|
-
this.skillSelectedNames.clear();
|
|
490
|
-
if (current !== false && current.length > 0) {
|
|
491
|
-
current.forEach((skillName) => this.skillSelectedNames.add(skillName));
|
|
492
|
-
}
|
|
493
|
-
this.tui.requestRender();
|
|
494
|
-
return;
|
|
495
|
-
}
|
|
496
|
-
|
|
497
|
-
if (data === "w" && this.mode !== 'parallel') {
|
|
498
|
-
this.enterEditMode("output");
|
|
499
|
-
return;
|
|
500
|
-
}
|
|
501
|
-
|
|
502
|
-
if (data === "r" && this.mode === 'chain') {
|
|
503
|
-
this.enterEditMode("reads");
|
|
504
|
-
return;
|
|
505
|
-
}
|
|
506
|
-
|
|
507
|
-
if (data === "p" && this.mode === 'chain') {
|
|
508
|
-
const anyEnabled = this.agentConfigs.some((_, i) => this.getEffectiveBehavior(i).progress);
|
|
509
|
-
const newState = !anyEnabled;
|
|
510
|
-
for (let i = 0; i < this.agentConfigs.length; i++) {
|
|
511
|
-
this.updateBehavior(i, "progress", newState);
|
|
512
|
-
}
|
|
513
|
-
this.tui.requestRender();
|
|
514
|
-
return;
|
|
515
|
-
}
|
|
516
|
-
|
|
517
|
-
if (data === "b") {
|
|
518
|
-
this.runInBackground = !this.runInBackground;
|
|
519
|
-
this.tui.requestRender();
|
|
520
|
-
return;
|
|
521
|
-
}
|
|
522
|
-
|
|
523
|
-
}
|
|
524
|
-
|
|
525
|
-
private enterEditMode(mode: EditMode): void {
|
|
526
|
-
this.editingStep = this.selectedStep;
|
|
527
|
-
this.editMode = mode;
|
|
528
|
-
let buffer = "";
|
|
529
|
-
|
|
530
|
-
if (mode === "template") {
|
|
531
|
-
const template = this.templates[this.selectedStep] ?? "";
|
|
532
|
-
buffer = template.split("\n")[0] ?? "";
|
|
533
|
-
} else if (mode === "output") {
|
|
534
|
-
const behavior = this.getEffectiveBehavior(this.selectedStep);
|
|
535
|
-
buffer = typeof behavior.output === "string" ? behavior.output : "";
|
|
536
|
-
} else if (mode === "reads") {
|
|
537
|
-
const behavior = this.getEffectiveBehavior(this.selectedStep);
|
|
538
|
-
buffer = behavior.reads === false ? "" : (behavior.reads?.join(", ") || "");
|
|
539
|
-
}
|
|
540
|
-
|
|
541
|
-
this.editState = createEditorState(buffer);
|
|
542
|
-
this.tui.requestRender();
|
|
543
|
-
}
|
|
544
|
-
|
|
545
|
-
/** Enter model selector mode */
|
|
546
|
-
private enterModelSelector(): void {
|
|
547
|
-
this.editingStep = this.selectedStep;
|
|
548
|
-
this.editMode = "model";
|
|
549
|
-
this.modelSearchQuery = "";
|
|
550
|
-
this.modelSelectedIndex = 0;
|
|
551
|
-
this.filteredModels = [...this.availableModels];
|
|
552
|
-
const currentModel = splitThinkingSuffix(this.getEffectiveModel(this.selectedStep)).baseModel;
|
|
553
|
-
const currentIndex = this.filteredModels.findIndex((m) => m.fullId === currentModel || m.id === currentModel);
|
|
554
|
-
if (currentIndex >= 0) {
|
|
555
|
-
this.modelSelectedIndex = currentIndex;
|
|
556
|
-
}
|
|
557
|
-
|
|
558
|
-
this.tui.requestRender();
|
|
559
|
-
}
|
|
560
|
-
|
|
561
|
-
/** Filter models based on search query */
|
|
562
|
-
private filterModels(): void {
|
|
563
|
-
const query = this.modelSearchQuery.toLowerCase();
|
|
564
|
-
if (!query) {
|
|
565
|
-
this.filteredModels = [...this.availableModels];
|
|
566
|
-
} else {
|
|
567
|
-
this.filteredModels = this.availableModels.filter((m) =>
|
|
568
|
-
m.fullId.toLowerCase().includes(query) ||
|
|
569
|
-
m.id.toLowerCase().includes(query) ||
|
|
570
|
-
m.provider.toLowerCase().includes(query)
|
|
571
|
-
);
|
|
572
|
-
}
|
|
573
|
-
this.modelSelectedIndex = Math.min(this.modelSelectedIndex, Math.max(0, this.filteredModels.length - 1));
|
|
574
|
-
}
|
|
575
|
-
|
|
576
|
-
private handleModelSelectorInput(data: string): void {
|
|
577
|
-
if (matchesKey(data, "escape") || matchesKey(data, "ctrl+c")) {
|
|
578
|
-
this.exitEditMode();
|
|
579
|
-
return;
|
|
580
|
-
}
|
|
581
|
-
|
|
582
|
-
if (matchesKey(data, "return")) {
|
|
583
|
-
const selected = this.filteredModels[this.modelSelectedIndex];
|
|
584
|
-
if (selected) {
|
|
585
|
-
const { thinkingSuffix } = splitThinkingSuffix(this.getEffectiveModel(this.editingStep!));
|
|
586
|
-
const requestedLevel = thinkingSuffix.slice(1);
|
|
587
|
-
const selectedModel = findModelInfo(selected.fullId, this.availableModels, this.preferredProvider);
|
|
588
|
-
const suffix = getSupportedThinkingLevels(selectedModel).some((level) => level === requestedLevel) ? thinkingSuffix : "";
|
|
589
|
-
this.updateBehavior(this.editingStep!, "model", `${selected.fullId}${suffix}`);
|
|
590
|
-
}
|
|
591
|
-
this.exitEditMode();
|
|
592
|
-
return;
|
|
593
|
-
}
|
|
594
|
-
|
|
595
|
-
if (matchesKey(data, "up")) {
|
|
596
|
-
if (this.filteredModels.length > 0) {
|
|
597
|
-
this.modelSelectedIndex = this.modelSelectedIndex === 0
|
|
598
|
-
? this.filteredModels.length - 1
|
|
599
|
-
: this.modelSelectedIndex - 1;
|
|
600
|
-
}
|
|
601
|
-
this.tui.requestRender();
|
|
602
|
-
return;
|
|
603
|
-
}
|
|
604
|
-
|
|
605
|
-
if (matchesKey(data, "down")) {
|
|
606
|
-
if (this.filteredModels.length > 0) {
|
|
607
|
-
this.modelSelectedIndex = this.modelSelectedIndex === this.filteredModels.length - 1
|
|
608
|
-
? 0
|
|
609
|
-
: this.modelSelectedIndex + 1;
|
|
610
|
-
}
|
|
611
|
-
this.tui.requestRender();
|
|
612
|
-
return;
|
|
613
|
-
}
|
|
614
|
-
|
|
615
|
-
if (matchesKey(data, "backspace")) {
|
|
616
|
-
if (this.modelSearchQuery.length > 0) {
|
|
617
|
-
this.modelSearchQuery = this.modelSearchQuery.slice(0, -1);
|
|
618
|
-
this.filterModels();
|
|
619
|
-
}
|
|
620
|
-
this.tui.requestRender();
|
|
621
|
-
return;
|
|
622
|
-
}
|
|
623
|
-
|
|
624
|
-
if (data.length === 1 && data.charCodeAt(0) >= 32) {
|
|
625
|
-
this.modelSearchQuery += data;
|
|
626
|
-
this.filterModels();
|
|
627
|
-
this.tui.requestRender();
|
|
628
|
-
return;
|
|
629
|
-
}
|
|
630
|
-
}
|
|
631
|
-
|
|
632
|
-
private getAvailableThinkingLevels(stepIndex: number): ThinkingLevel[] {
|
|
633
|
-
return getSupportedThinkingLevels(findModelInfo(this.getEffectiveModel(stepIndex), this.availableModels, this.preferredProvider));
|
|
634
|
-
}
|
|
635
|
-
|
|
636
|
-
/** Enter thinking level selector mode */
|
|
637
|
-
private enterThinkingSelector(): void {
|
|
638
|
-
if (!this.getEffectiveBehavior(this.selectedStep).model) {
|
|
639
|
-
this.showNotice("Select a model first", "error");
|
|
640
|
-
return;
|
|
641
|
-
}
|
|
642
|
-
this.editingStep = this.selectedStep;
|
|
643
|
-
this.editMode = "thinking";
|
|
644
|
-
|
|
645
|
-
const levels = this.getAvailableThinkingLevels(this.selectedStep);
|
|
646
|
-
const { thinkingSuffix } = splitThinkingSuffix(this.getEffectiveModel(this.selectedStep));
|
|
647
|
-
const suffix = thinkingSuffix.slice(1);
|
|
648
|
-
const levelIdx = levels.findIndex((level) => level === suffix);
|
|
649
|
-
this.thinkingSelectedIndex = levelIdx >= 0 ? levelIdx : Math.max(0, levels.indexOf("off"));
|
|
650
|
-
|
|
651
|
-
this.tui.requestRender();
|
|
652
|
-
}
|
|
653
|
-
|
|
654
|
-
private handleThinkingSelectorInput(data: string): void {
|
|
655
|
-
if (matchesKey(data, "escape") || matchesKey(data, "ctrl+c")) {
|
|
656
|
-
this.exitEditMode();
|
|
657
|
-
return;
|
|
658
|
-
}
|
|
659
|
-
|
|
660
|
-
const levels = this.getAvailableThinkingLevels(this.editingStep!);
|
|
661
|
-
if (levels.length === 0) return;
|
|
662
|
-
|
|
663
|
-
if (matchesKey(data, "return")) {
|
|
664
|
-
const selectedLevel = levels[this.thinkingSelectedIndex] ?? "off";
|
|
665
|
-
this.applyThinkingLevel(selectedLevel);
|
|
666
|
-
this.exitEditMode();
|
|
667
|
-
return;
|
|
668
|
-
}
|
|
669
|
-
|
|
670
|
-
if (matchesKey(data, "up")) {
|
|
671
|
-
this.thinkingSelectedIndex = this.thinkingSelectedIndex === 0
|
|
672
|
-
? levels.length - 1
|
|
673
|
-
: this.thinkingSelectedIndex - 1;
|
|
674
|
-
this.tui.requestRender();
|
|
675
|
-
return;
|
|
676
|
-
}
|
|
677
|
-
|
|
678
|
-
if (matchesKey(data, "down")) {
|
|
679
|
-
this.thinkingSelectedIndex = this.thinkingSelectedIndex === levels.length - 1
|
|
680
|
-
? 0
|
|
681
|
-
: this.thinkingSelectedIndex + 1;
|
|
682
|
-
this.tui.requestRender();
|
|
683
|
-
return;
|
|
684
|
-
}
|
|
685
|
-
}
|
|
686
|
-
|
|
687
|
-
/** Apply thinking level to the current step's model */
|
|
688
|
-
private applyThinkingLevel(level: ThinkingLevel): void {
|
|
689
|
-
const stepIndex = this.editingStep!;
|
|
690
|
-
const currentModel = this.getEffectiveBehavior(stepIndex).model;
|
|
691
|
-
if (!currentModel) return;
|
|
692
|
-
|
|
693
|
-
const { baseModel } = splitThinkingSuffix(currentModel);
|
|
694
|
-
const newModel = level === "off" ? baseModel : `${baseModel}:${level}`;
|
|
695
|
-
this.updateBehavior(stepIndex, "model", newModel);
|
|
696
|
-
}
|
|
697
|
-
|
|
698
|
-
private filterSkills(): void {
|
|
699
|
-
const query = this.skillSearchQuery.toLowerCase();
|
|
700
|
-
if (!query) {
|
|
701
|
-
this.filteredSkills = [...this.availableSkills];
|
|
702
|
-
} else {
|
|
703
|
-
this.filteredSkills = this.availableSkills.filter((s) =>
|
|
704
|
-
s.name.toLowerCase().includes(query) ||
|
|
705
|
-
(s.description?.toLowerCase().includes(query) ?? false),
|
|
706
|
-
);
|
|
707
|
-
}
|
|
708
|
-
this.skillCursorIndex = Math.min(this.skillCursorIndex, Math.max(0, this.filteredSkills.length - 1));
|
|
709
|
-
}
|
|
710
|
-
|
|
711
|
-
private handleSkillSelectorInput(data: string): void {
|
|
712
|
-
if (matchesKey(data, "escape") || matchesKey(data, "ctrl+c")) {
|
|
713
|
-
this.exitEditMode();
|
|
714
|
-
return;
|
|
715
|
-
}
|
|
716
|
-
|
|
717
|
-
if (matchesKey(data, "return")) {
|
|
718
|
-
const selected = [...this.skillSelectedNames];
|
|
719
|
-
this.updateBehavior(this.editingStep!, "skills", selected);
|
|
720
|
-
this.exitEditMode();
|
|
721
|
-
return;
|
|
722
|
-
}
|
|
723
|
-
|
|
724
|
-
if (data === " ") {
|
|
725
|
-
if (this.filteredSkills.length > 0) {
|
|
726
|
-
const skill = this.filteredSkills[this.skillCursorIndex];
|
|
727
|
-
if (skill) {
|
|
728
|
-
if (this.skillSelectedNames.has(skill.name)) {
|
|
729
|
-
this.skillSelectedNames.delete(skill.name);
|
|
730
|
-
} else {
|
|
731
|
-
this.skillSelectedNames.add(skill.name);
|
|
732
|
-
}
|
|
733
|
-
}
|
|
734
|
-
}
|
|
735
|
-
this.tui.requestRender();
|
|
736
|
-
return;
|
|
737
|
-
}
|
|
738
|
-
|
|
739
|
-
if (matchesKey(data, "up")) {
|
|
740
|
-
if (this.filteredSkills.length > 0) {
|
|
741
|
-
this.skillCursorIndex = this.skillCursorIndex === 0
|
|
742
|
-
? this.filteredSkills.length - 1
|
|
743
|
-
: this.skillCursorIndex - 1;
|
|
744
|
-
}
|
|
745
|
-
this.tui.requestRender();
|
|
746
|
-
return;
|
|
747
|
-
}
|
|
748
|
-
|
|
749
|
-
if (matchesKey(data, "down")) {
|
|
750
|
-
if (this.filteredSkills.length > 0) {
|
|
751
|
-
this.skillCursorIndex = this.skillCursorIndex === this.filteredSkills.length - 1
|
|
752
|
-
? 0
|
|
753
|
-
: this.skillCursorIndex + 1;
|
|
754
|
-
}
|
|
755
|
-
this.tui.requestRender();
|
|
756
|
-
return;
|
|
757
|
-
}
|
|
758
|
-
|
|
759
|
-
if (matchesKey(data, "backspace")) {
|
|
760
|
-
if (this.skillSearchQuery.length > 0) {
|
|
761
|
-
this.skillSearchQuery = this.skillSearchQuery.slice(0, -1);
|
|
762
|
-
this.filterSkills();
|
|
763
|
-
}
|
|
764
|
-
this.tui.requestRender();
|
|
765
|
-
return;
|
|
766
|
-
}
|
|
767
|
-
|
|
768
|
-
if (data.length === 1 && data.charCodeAt(0) >= 32) {
|
|
769
|
-
this.skillSearchQuery += data;
|
|
770
|
-
this.filterSkills();
|
|
771
|
-
this.tui.requestRender();
|
|
772
|
-
return;
|
|
773
|
-
}
|
|
774
|
-
}
|
|
775
|
-
|
|
776
|
-
private handleEditInput(data: string): void {
|
|
777
|
-
const textWidth = this.width - 4; // Must match render: innerW - 2 = (width - 2) - 2
|
|
778
|
-
if (matchesKey(data, "shift+up") || matchesKey(data, "pageUp")) {
|
|
779
|
-
const { lines: wrapped, starts } = wrapText(this.editState.buffer, textWidth);
|
|
780
|
-
const cursorPos = getCursorDisplayPos(this.editState.cursor, starts);
|
|
781
|
-
const targetLine = Math.max(0, cursorPos.line - this.EDIT_VIEWPORT_HEIGHT);
|
|
782
|
-
const targetStart = starts[targetLine];
|
|
783
|
-
if (targetStart === undefined) return;
|
|
784
|
-
const targetCol = Math.min(cursorPos.col, wrapped[targetLine]?.length ?? 0);
|
|
785
|
-
this.editState = { ...this.editState, cursor: targetStart + targetCol };
|
|
786
|
-
this.tui.requestRender();
|
|
787
|
-
return;
|
|
788
|
-
}
|
|
789
|
-
|
|
790
|
-
if (matchesKey(data, "shift+down") || matchesKey(data, "pageDown")) {
|
|
791
|
-
const { lines: wrapped, starts } = wrapText(this.editState.buffer, textWidth);
|
|
792
|
-
const cursorPos = getCursorDisplayPos(this.editState.cursor, starts);
|
|
793
|
-
const targetLine = Math.min(wrapped.length - 1, cursorPos.line + this.EDIT_VIEWPORT_HEIGHT);
|
|
794
|
-
const targetStart = starts[targetLine];
|
|
795
|
-
if (targetStart === undefined) return;
|
|
796
|
-
const targetCol = Math.min(cursorPos.col, wrapped[targetLine]?.length ?? 0);
|
|
797
|
-
this.editState = { ...this.editState, cursor: targetStart + targetCol };
|
|
798
|
-
this.tui.requestRender();
|
|
799
|
-
return;
|
|
800
|
-
}
|
|
801
|
-
|
|
802
|
-
if (matchesKey(data, "tab")) return;
|
|
803
|
-
|
|
804
|
-
const nextState = handleEditorInput(this.editState, data, textWidth);
|
|
805
|
-
if (nextState) {
|
|
806
|
-
this.editState = nextState;
|
|
807
|
-
this.tui.requestRender();
|
|
808
|
-
return;
|
|
809
|
-
}
|
|
810
|
-
|
|
811
|
-
if (matchesKey(data, "escape")) {
|
|
812
|
-
this.saveEdit();
|
|
813
|
-
this.exitEditMode();
|
|
814
|
-
return;
|
|
815
|
-
}
|
|
816
|
-
|
|
817
|
-
if (matchesKey(data, "ctrl+c")) {
|
|
818
|
-
this.exitEditMode();
|
|
819
|
-
return;
|
|
820
|
-
}
|
|
821
|
-
}
|
|
822
|
-
|
|
823
|
-
private saveEdit(): void {
|
|
824
|
-
const stepIndex = this.editingStep!;
|
|
825
|
-
|
|
826
|
-
if (this.editMode === "template") {
|
|
827
|
-
// For template, preserve other lines if they existed
|
|
828
|
-
const original = this.templates[stepIndex] ?? "";
|
|
829
|
-
const originalLines = original.split("\n");
|
|
830
|
-
originalLines[0] = this.editState.buffer;
|
|
831
|
-
this.templates[stepIndex] = originalLines.join("\n");
|
|
832
|
-
} else if (this.editMode === "output") {
|
|
833
|
-
// Capture OLD output before updating (for downstream propagation)
|
|
834
|
-
const oldBehavior = this.getEffectiveBehavior(stepIndex);
|
|
835
|
-
const oldOutput = typeof oldBehavior.output === "string" ? oldBehavior.output : null;
|
|
836
|
-
|
|
837
|
-
// Empty string or whitespace means disable output
|
|
838
|
-
const trimmed = this.editState.buffer.trim();
|
|
839
|
-
const newOutput = trimmed === "" ? false : trimmed;
|
|
840
|
-
this.updateBehavior(stepIndex, "output", newOutput);
|
|
841
|
-
|
|
842
|
-
// Propagate output filename change to downstream steps' reads
|
|
843
|
-
if (oldOutput && typeof newOutput === "string" && oldOutput !== newOutput) {
|
|
844
|
-
this.propagateOutputChange(stepIndex, oldOutput, newOutput);
|
|
845
|
-
}
|
|
846
|
-
} else if (this.editMode === "reads") {
|
|
847
|
-
// Parse comma-separated list, empty means disable reads
|
|
848
|
-
const trimmed = this.editState.buffer.trim();
|
|
849
|
-
if (trimmed === "") {
|
|
850
|
-
this.updateBehavior(stepIndex, "reads", false);
|
|
851
|
-
} else {
|
|
852
|
-
const files = trimmed.split(",").map(f => f.trim()).filter(f => f !== "");
|
|
853
|
-
this.updateBehavior(stepIndex, "reads", files.length > 0 ? files : false);
|
|
854
|
-
}
|
|
855
|
-
}
|
|
856
|
-
}
|
|
857
|
-
|
|
858
|
-
/**
|
|
859
|
-
* When a step's output filename changes, update downstream steps that read from it.
|
|
860
|
-
* This maintains the chain dependency automatically.
|
|
861
|
-
*/
|
|
862
|
-
private propagateOutputChange(changedStepIndex: number, oldOutput: string, newOutput: string): void {
|
|
863
|
-
// Check all downstream steps (steps that come after the changed step)
|
|
864
|
-
for (let i = changedStepIndex + 1; i < this.agentConfigs.length; i++) {
|
|
865
|
-
const behavior = this.getEffectiveBehavior(i);
|
|
866
|
-
|
|
867
|
-
// Skip if reads is disabled or empty
|
|
868
|
-
if (behavior.reads === false || !behavior.reads || behavior.reads.length === 0) {
|
|
869
|
-
continue;
|
|
870
|
-
}
|
|
871
|
-
|
|
872
|
-
// Check if this step reads the old output file
|
|
873
|
-
const readsArray = behavior.reads;
|
|
874
|
-
const oldIndex = readsArray.indexOf(oldOutput);
|
|
875
|
-
|
|
876
|
-
if (oldIndex !== -1) {
|
|
877
|
-
// Replace old filename with new filename in reads
|
|
878
|
-
const newReads = [...readsArray];
|
|
879
|
-
newReads[oldIndex] = newOutput;
|
|
880
|
-
this.updateBehavior(i, "reads", newReads);
|
|
881
|
-
}
|
|
882
|
-
}
|
|
883
|
-
}
|
|
884
|
-
|
|
885
|
-
render(width: number): string[] {
|
|
886
|
-
let lines: string[] = [];
|
|
887
|
-
if (this.editingStep !== null) {
|
|
888
|
-
if (this.editMode === "model") lines = this.renderModelSelector();
|
|
889
|
-
else if (this.editMode === "thinking") lines = this.renderThinkingSelector();
|
|
890
|
-
else if (this.editMode === "skills") lines = this.renderSkillSelector();
|
|
891
|
-
else lines = this.renderFullEditMode();
|
|
892
|
-
} else {
|
|
893
|
-
switch (this.mode) {
|
|
894
|
-
case 'single': lines = this.renderSingleMode(); break;
|
|
895
|
-
case 'parallel': lines = this.renderParallelMode(); break;
|
|
896
|
-
case 'chain': lines = this.renderChainMode(); break;
|
|
897
|
-
}
|
|
898
|
-
}
|
|
899
|
-
const renderWidth = Math.max(0, Math.min(this.width, Math.floor(width)));
|
|
900
|
-
return lines.map((line) => truncateToWidth(line, renderWidth));
|
|
901
|
-
}
|
|
902
|
-
|
|
903
|
-
/** Render the model selector view */
|
|
904
|
-
private renderModelSelector(): string[] {
|
|
905
|
-
const th = this.theme;
|
|
906
|
-
const lines: string[] = [];
|
|
907
|
-
|
|
908
|
-
// Header (mode-aware terminology)
|
|
909
|
-
const agentName = this.agentConfigs[this.editingStep!]?.name ?? "unknown";
|
|
910
|
-
const stepLabel = this.mode === 'single'
|
|
911
|
-
? agentName
|
|
912
|
-
: this.mode === 'parallel'
|
|
913
|
-
? `Task ${this.editingStep! + 1}: ${agentName}`
|
|
914
|
-
: `Step ${this.editingStep! + 1}: ${agentName}`;
|
|
915
|
-
const headerText = ` Select Model (${stepLabel}) `;
|
|
916
|
-
lines.push(this.renderHeader(headerText));
|
|
917
|
-
lines.push(this.row(""));
|
|
918
|
-
|
|
919
|
-
const searchPrefix = th.fg("dim", "Search: ");
|
|
920
|
-
const cursor = "\x1b[7m \x1b[27m"; // Reverse video space for cursor
|
|
921
|
-
const searchDisplay = this.modelSearchQuery + cursor;
|
|
922
|
-
lines.push(this.row(` ${searchPrefix}${searchDisplay}`));
|
|
923
|
-
lines.push(this.row(""));
|
|
924
|
-
|
|
925
|
-
const currentModel = this.getEffectiveModel(this.editingStep!);
|
|
926
|
-
const currentModelBase = splitThinkingSuffix(currentModel).baseModel;
|
|
927
|
-
const currentLabel = th.fg("dim", "Current: ");
|
|
928
|
-
lines.push(this.row(` ${currentLabel}${th.fg("warning", currentModel)}`));
|
|
929
|
-
lines.push(this.row(""));
|
|
930
|
-
|
|
931
|
-
if (this.filteredModels.length === 0) {
|
|
932
|
-
lines.push(this.row(` ${th.fg("dim", "No matching models")}`));
|
|
933
|
-
} else {
|
|
934
|
-
const maxVisible = this.MODEL_SELECTOR_HEIGHT;
|
|
935
|
-
let startIdx = 0;
|
|
936
|
-
|
|
937
|
-
if (this.filteredModels.length > maxVisible) {
|
|
938
|
-
startIdx = Math.max(0, this.modelSelectedIndex - Math.floor(maxVisible / 2));
|
|
939
|
-
startIdx = Math.min(startIdx, this.filteredModels.length - maxVisible);
|
|
940
|
-
}
|
|
941
|
-
|
|
942
|
-
const endIdx = Math.min(startIdx + maxVisible, this.filteredModels.length);
|
|
943
|
-
|
|
944
|
-
if (startIdx > 0) {
|
|
945
|
-
lines.push(this.row(` ${th.fg("dim", ` ↑ ${startIdx} more`)}`));
|
|
946
|
-
}
|
|
947
|
-
|
|
948
|
-
for (let i = startIdx; i < endIdx; i++) {
|
|
949
|
-
const model = this.filteredModels[i]!;
|
|
950
|
-
const isSelected = i === this.modelSelectedIndex;
|
|
951
|
-
const isCurrent = model.fullId === currentModelBase || model.id === currentModelBase;
|
|
952
|
-
const prefix = isSelected ? th.fg("accent", "→ ") : " ";
|
|
953
|
-
const modelText = isSelected ? th.fg("accent", model.id) : model.id;
|
|
954
|
-
const providerBadge = th.fg("dim", ` [${model.provider}]`);
|
|
955
|
-
const currentBadge = isCurrent ? th.fg("success", " current") : "";
|
|
956
|
-
|
|
957
|
-
lines.push(this.row(` ${prefix}${modelText}${providerBadge}${currentBadge}`));
|
|
958
|
-
}
|
|
959
|
-
|
|
960
|
-
const remaining = this.filteredModels.length - endIdx;
|
|
961
|
-
if (remaining > 0) {
|
|
962
|
-
lines.push(this.row(` ${th.fg("dim", ` ↓ ${remaining} more`)}`));
|
|
963
|
-
}
|
|
964
|
-
}
|
|
965
|
-
|
|
966
|
-
const contentLines = lines.length;
|
|
967
|
-
const targetHeight = 18;
|
|
968
|
-
for (let i = contentLines; i < targetHeight; i++) {
|
|
969
|
-
lines.push(this.row(""));
|
|
970
|
-
}
|
|
971
|
-
|
|
972
|
-
const footerText = " [Enter] Select • [Esc] Cancel • Type to search ";
|
|
973
|
-
lines.push(this.renderFooter(footerText));
|
|
974
|
-
|
|
975
|
-
return lines;
|
|
976
|
-
}
|
|
977
|
-
|
|
978
|
-
/** Render the thinking level selector view */
|
|
979
|
-
private renderThinkingSelector(): string[] {
|
|
980
|
-
const th = this.theme;
|
|
981
|
-
const lines: string[] = [];
|
|
982
|
-
|
|
983
|
-
const agentName = this.agentConfigs[this.editingStep!]?.name ?? "unknown";
|
|
984
|
-
const stepLabel = this.mode === 'single'
|
|
985
|
-
? agentName
|
|
986
|
-
: this.mode === 'parallel'
|
|
987
|
-
? `Task ${this.editingStep! + 1}: ${agentName}`
|
|
988
|
-
: `Step ${this.editingStep! + 1}: ${agentName}`;
|
|
989
|
-
const headerText = ` Thinking Level (${stepLabel}) `;
|
|
990
|
-
lines.push(this.renderHeader(headerText));
|
|
991
|
-
lines.push(this.row(""));
|
|
992
|
-
|
|
993
|
-
const currentModel = this.getEffectiveModel(this.editingStep!);
|
|
994
|
-
const currentLabel = th.fg("dim", "Model: ");
|
|
995
|
-
lines.push(this.row(` ${currentLabel}${th.fg("accent", currentModel)}`));
|
|
996
|
-
lines.push(this.row(""));
|
|
997
|
-
|
|
998
|
-
lines.push(this.row(` ${th.fg("dim", "Select thinking level (extended thinking budget):")}`));
|
|
999
|
-
lines.push(this.row(""));
|
|
1000
|
-
|
|
1001
|
-
const levelDescriptions: Record<ThinkingLevel, string> = {
|
|
1002
|
-
"off": "No extended thinking",
|
|
1003
|
-
"minimal": "Brief reasoning",
|
|
1004
|
-
"low": "Light reasoning",
|
|
1005
|
-
"medium": "Moderate reasoning",
|
|
1006
|
-
"high": "Deep reasoning",
|
|
1007
|
-
"xhigh": "Maximum reasoning (ultrathink)",
|
|
1008
|
-
"max": "Maximum available reasoning",
|
|
1009
|
-
};
|
|
1010
|
-
|
|
1011
|
-
const levels = this.getAvailableThinkingLevels(this.editingStep!);
|
|
1012
|
-
if (levels.length === 0) {
|
|
1013
|
-
lines.push(this.row(` ${th.fg("dim", "No supported thinking levels")}`));
|
|
1014
|
-
} else {
|
|
1015
|
-
for (let i = 0; i < levels.length; i++) {
|
|
1016
|
-
const level = levels[i]!;
|
|
1017
|
-
const isSelected = i === this.thinkingSelectedIndex;
|
|
1018
|
-
const prefix = isSelected ? th.fg("accent", "→ ") : " ";
|
|
1019
|
-
const levelText = isSelected ? th.fg("accent", level) : level;
|
|
1020
|
-
const desc = th.fg("dim", ` - ${levelDescriptions[level]}`);
|
|
1021
|
-
lines.push(this.row(` ${prefix}${levelText}${desc}`));
|
|
1022
|
-
}
|
|
1023
|
-
}
|
|
1024
|
-
|
|
1025
|
-
const contentLines = lines.length;
|
|
1026
|
-
const targetHeight = 16;
|
|
1027
|
-
for (let i = contentLines; i < targetHeight; i++) {
|
|
1028
|
-
lines.push(this.row(""));
|
|
1029
|
-
}
|
|
1030
|
-
|
|
1031
|
-
const footerText = levels.length === 0
|
|
1032
|
-
? " [Esc] Cancel "
|
|
1033
|
-
: " [Enter] Select • [Esc] Cancel • ↑↓ Navigate ";
|
|
1034
|
-
lines.push(this.renderFooter(footerText));
|
|
1035
|
-
|
|
1036
|
-
return lines;
|
|
1037
|
-
}
|
|
1038
|
-
|
|
1039
|
-
private renderSkillSelector(): string[] {
|
|
1040
|
-
const innerW = this.width - 2;
|
|
1041
|
-
const th = this.theme;
|
|
1042
|
-
const lines: string[] = [];
|
|
1043
|
-
|
|
1044
|
-
const agentName = this.agentConfigs[this.editingStep!]?.name ?? "unknown";
|
|
1045
|
-
const stepLabel = this.mode === 'single'
|
|
1046
|
-
? agentName
|
|
1047
|
-
: this.mode === 'parallel'
|
|
1048
|
-
? `Task ${this.editingStep! + 1}: ${agentName}`
|
|
1049
|
-
: `Step ${this.editingStep! + 1}: ${agentName}`;
|
|
1050
|
-
lines.push(this.renderHeader(` Select Skills (${stepLabel}) `));
|
|
1051
|
-
lines.push(this.row(""));
|
|
1052
|
-
|
|
1053
|
-
const cursor = "\x1b[7m \x1b[27m";
|
|
1054
|
-
lines.push(this.row(` ${th.fg("dim", "Search: ")}${this.skillSearchQuery}${cursor}`));
|
|
1055
|
-
lines.push(this.row(""));
|
|
1056
|
-
|
|
1057
|
-
const selected = [...this.skillSelectedNames].join(", ") || th.fg("dim", "(none)");
|
|
1058
|
-
lines.push(this.row(` ${th.fg("dim", "Selected: ")}${truncateToWidth(selected, innerW - 12)}`));
|
|
1059
|
-
lines.push(this.row(""));
|
|
1060
|
-
|
|
1061
|
-
const selectorHeight = 10;
|
|
1062
|
-
if (this.filteredSkills.length === 0) {
|
|
1063
|
-
lines.push(this.row(` ${th.fg("dim", "No matching skills")}`));
|
|
1064
|
-
} else {
|
|
1065
|
-
let startIdx = 0;
|
|
1066
|
-
if (this.filteredSkills.length > selectorHeight) {
|
|
1067
|
-
startIdx = Math.max(0, this.skillCursorIndex - Math.floor(selectorHeight / 2));
|
|
1068
|
-
startIdx = Math.min(startIdx, this.filteredSkills.length - selectorHeight);
|
|
1069
|
-
}
|
|
1070
|
-
const endIdx = Math.min(startIdx + selectorHeight, this.filteredSkills.length);
|
|
1071
|
-
|
|
1072
|
-
if (startIdx > 0) {
|
|
1073
|
-
lines.push(this.row(` ${th.fg("dim", ` ↑ ${startIdx} more`)}`));
|
|
1074
|
-
}
|
|
1075
|
-
|
|
1076
|
-
for (let i = startIdx; i < endIdx; i++) {
|
|
1077
|
-
const skill = this.filteredSkills[i]!;
|
|
1078
|
-
const isCursor = i === this.skillCursorIndex;
|
|
1079
|
-
const isSelected = this.skillSelectedNames.has(skill.name);
|
|
1080
|
-
|
|
1081
|
-
const prefix = isCursor ? th.fg("accent", "→ ") : " ";
|
|
1082
|
-
const checkbox = isSelected ? th.fg("success", "[x]") : "[ ]";
|
|
1083
|
-
const nameText = isCursor ? th.fg("accent", skill.name) : skill.name;
|
|
1084
|
-
const sourceBadge = th.fg("dim", ` [${skill.source}]`);
|
|
1085
|
-
const desc = skill.description
|
|
1086
|
-
? th.fg("dim", ` - ${truncateToWidth(skill.description, 25)}`)
|
|
1087
|
-
: "";
|
|
1088
|
-
|
|
1089
|
-
lines.push(this.row(` ${prefix}${checkbox} ${nameText}${sourceBadge}${desc}`));
|
|
1090
|
-
}
|
|
1091
|
-
|
|
1092
|
-
const remaining = this.filteredSkills.length - endIdx;
|
|
1093
|
-
if (remaining > 0) {
|
|
1094
|
-
lines.push(this.row(` ${th.fg("dim", ` ↓ ${remaining} more`)}`));
|
|
1095
|
-
}
|
|
1096
|
-
}
|
|
1097
|
-
|
|
1098
|
-
const targetHeight = 18;
|
|
1099
|
-
for (let i = lines.length; i < targetHeight; i++) {
|
|
1100
|
-
lines.push(this.row(""));
|
|
1101
|
-
}
|
|
1102
|
-
|
|
1103
|
-
lines.push(this.renderFooter(" [Enter] Confirm • [Space] Toggle • [Esc] Cancel "));
|
|
1104
|
-
return lines;
|
|
1105
|
-
}
|
|
1106
|
-
|
|
1107
|
-
private getShortcutHelpText(): string {
|
|
1108
|
-
const th = this.theme;
|
|
1109
|
-
const shortcut = (key: string, label: string) =>
|
|
1110
|
-
th.fg("accent", `[${key}]`) + th.fg("dim", label);
|
|
1111
|
-
const backgroundState = this.runInBackground ? "ON" : "OFF";
|
|
1112
|
-
const background = shortcut("b", `Background:${backgroundState}`);
|
|
1113
|
-
|
|
1114
|
-
switch (this.mode) {
|
|
1115
|
-
case 'single':
|
|
1116
|
-
return ` ${shortcut("e", "Task")} ${shortcut("m", "Model")} ${shortcut("t", "Think")} ${shortcut("w", "Output")} ${shortcut("s", "Skills")} ${background}`;
|
|
1117
|
-
case 'parallel':
|
|
1118
|
-
return ` ${shortcut("e", "Task")} ${shortcut("m", "Model")} ${shortcut("t", "Think")} ${shortcut("s", "Skills")} ${background}`;
|
|
1119
|
-
case 'chain':
|
|
1120
|
-
return ` ${shortcut("e", "Task")} ${shortcut("m", "Model")} ${shortcut("t", "Think")} ${shortcut("w", "Output")} ${shortcut("r", "Reads")} ${shortcut("p", "Prog")} ${shortcut("s", "Skills")} ${background}`;
|
|
1121
|
-
}
|
|
1122
|
-
}
|
|
1123
|
-
|
|
1124
|
-
private getFooterText(): string {
|
|
1125
|
-
return this.mode === 'single'
|
|
1126
|
-
? " [Enter] Run • [Esc] Cancel "
|
|
1127
|
-
: " [Enter] Run • [Esc] Cancel • [↑↓/jk] Navigate ";
|
|
1128
|
-
}
|
|
1129
|
-
|
|
1130
|
-
private appendNotice(lines: string[]): void {
|
|
1131
|
-
if (!this.noticeMessage) return;
|
|
1132
|
-
const color = this.noticeMessage.type === "error" ? "error" : "success";
|
|
1133
|
-
lines.push(this.row(` ${this.theme.fg(color, this.noticeMessage.text)}`));
|
|
1134
|
-
}
|
|
1135
|
-
|
|
1136
|
-
private renderSingleMode(): string[] {
|
|
1137
|
-
const innerW = this.width - 2;
|
|
1138
|
-
const th = this.theme;
|
|
1139
|
-
const lines: string[] = [];
|
|
1140
|
-
|
|
1141
|
-
const agentName = this.agentConfigs[0]?.name ?? "unknown";
|
|
1142
|
-
const maxHeaderLen = innerW - 4;
|
|
1143
|
-
const headerText = ` Agent: ${truncateToWidth(agentName, maxHeaderLen - 9)} `;
|
|
1144
|
-
lines.push(this.renderHeader(headerText));
|
|
1145
|
-
lines.push(this.row(""));
|
|
1146
|
-
|
|
1147
|
-
const config = this.agentConfigs[0]!;
|
|
1148
|
-
const behavior = this.getEffectiveBehavior(0);
|
|
1149
|
-
|
|
1150
|
-
const stepLabel = config.name;
|
|
1151
|
-
lines.push(this.row(` ${th.fg("accent", "▶ " + stepLabel)}`));
|
|
1152
|
-
|
|
1153
|
-
const template = (this.templates[0] ?? "").split("\n")[0] ?? "";
|
|
1154
|
-
const taskLabel = th.fg("dim", "task: ");
|
|
1155
|
-
lines.push(this.row(` ${taskLabel}${truncateToWidth(template, innerW - 12)}`));
|
|
1156
|
-
|
|
1157
|
-
const effectiveModel = this.getEffectiveModel(0);
|
|
1158
|
-
const override = this.behaviorOverrides.get(0);
|
|
1159
|
-
const isOverridden = override?.model !== undefined;
|
|
1160
|
-
const modelValue = isOverridden
|
|
1161
|
-
? th.fg("warning", effectiveModel) + th.fg("dim", " ✎")
|
|
1162
|
-
: effectiveModel;
|
|
1163
|
-
const modelLabel = th.fg("dim", "model: ");
|
|
1164
|
-
lines.push(this.row(` ${modelLabel}${truncateToWidth(modelValue, innerW - 13)}`));
|
|
1165
|
-
|
|
1166
|
-
const writesValue = behavior.output === false
|
|
1167
|
-
? th.fg("dim", "(disabled)")
|
|
1168
|
-
: (typeof behavior.output === "string" && behavior.output
|
|
1169
|
-
? behavior.output
|
|
1170
|
-
: th.fg("dim", "(none)"));
|
|
1171
|
-
const writesLabel = th.fg("dim", "writes: ");
|
|
1172
|
-
lines.push(this.row(` ${writesLabel}${truncateToWidth(writesValue, innerW - 14)}`));
|
|
1173
|
-
|
|
1174
|
-
const skillsValue = behavior.skills === false
|
|
1175
|
-
? th.fg("dim", "(disabled)")
|
|
1176
|
-
: (behavior.skills?.length ? behavior.skills.join(", ") : th.fg("dim", "(none)"));
|
|
1177
|
-
const skillsLabel = th.fg("dim", "skills: ");
|
|
1178
|
-
lines.push(this.row(` ${skillsLabel}${truncateToWidth(skillsValue, innerW - 14)}`));
|
|
1179
|
-
|
|
1180
|
-
lines.push(this.row(this.getShortcutHelpText()));
|
|
1181
|
-
|
|
1182
|
-
this.appendNotice(lines);
|
|
1183
|
-
lines.push(this.renderFooter(this.getFooterText()));
|
|
1184
|
-
|
|
1185
|
-
return lines;
|
|
1186
|
-
}
|
|
1187
|
-
|
|
1188
|
-
private renderParallelMode(): string[] {
|
|
1189
|
-
const innerW = this.width - 2;
|
|
1190
|
-
const th = this.theme;
|
|
1191
|
-
const lines: string[] = [];
|
|
1192
|
-
|
|
1193
|
-
const headerText = ` Parallel Tasks (${this.agentConfigs.length}) `;
|
|
1194
|
-
lines.push(this.renderHeader(headerText));
|
|
1195
|
-
lines.push(this.row(""));
|
|
1196
|
-
|
|
1197
|
-
for (let i = 0; i < this.agentConfigs.length; i++) {
|
|
1198
|
-
const config = this.agentConfigs[i]!;
|
|
1199
|
-
const isSelected = i === this.selectedStep;
|
|
1200
|
-
|
|
1201
|
-
const color = isSelected ? "accent" : "dim";
|
|
1202
|
-
const prefix = isSelected ? "▶ " : " ";
|
|
1203
|
-
const taskPrefix = `Task ${i + 1}: `;
|
|
1204
|
-
const maxNameLen = innerW - 4 - prefix.length - taskPrefix.length;
|
|
1205
|
-
const agentName = config.name.length > maxNameLen
|
|
1206
|
-
? config.name.slice(0, maxNameLen - 1) + "…"
|
|
1207
|
-
: config.name;
|
|
1208
|
-
const taskLabel = `${taskPrefix}${agentName}`;
|
|
1209
|
-
lines.push(this.row(` ${th.fg(color, prefix + taskLabel)}`));
|
|
1210
|
-
|
|
1211
|
-
const template = (this.templates[i] ?? "").split("\n")[0] ?? "";
|
|
1212
|
-
const taskTextLabel = th.fg("dim", "task: ");
|
|
1213
|
-
lines.push(this.row(` ${taskTextLabel}${truncateToWidth(template, innerW - 12)}`));
|
|
1214
|
-
|
|
1215
|
-
const effectiveModel = this.getEffectiveModel(i);
|
|
1216
|
-
const override = this.behaviorOverrides.get(i);
|
|
1217
|
-
const isOverridden = override?.model !== undefined;
|
|
1218
|
-
const modelValue = isOverridden
|
|
1219
|
-
? th.fg("warning", effectiveModel) + th.fg("dim", " ✎")
|
|
1220
|
-
: effectiveModel;
|
|
1221
|
-
const modelLabel = th.fg("dim", "model: ");
|
|
1222
|
-
lines.push(this.row(` ${modelLabel}${truncateToWidth(modelValue, innerW - 13)}`));
|
|
1223
|
-
|
|
1224
|
-
const behavior = this.getEffectiveBehavior(i);
|
|
1225
|
-
const skillsValue = behavior.skills === false
|
|
1226
|
-
? th.fg("dim", "(disabled)")
|
|
1227
|
-
: (behavior.skills?.length ? behavior.skills.join(", ") : th.fg("dim", "(none)"));
|
|
1228
|
-
const skillsLabel = th.fg("dim", "skills: ");
|
|
1229
|
-
lines.push(this.row(` ${skillsLabel}${truncateToWidth(skillsValue, innerW - 14)}`));
|
|
1230
|
-
|
|
1231
|
-
lines.push(this.row(""));
|
|
1232
|
-
}
|
|
1233
|
-
|
|
1234
|
-
if (this.agentConfigs.length > 0) lines.pop();
|
|
1235
|
-
lines.push(this.row(this.getShortcutHelpText()));
|
|
1236
|
-
this.appendNotice(lines);
|
|
1237
|
-
lines.push(this.renderFooter(this.getFooterText()));
|
|
1238
|
-
|
|
1239
|
-
return lines;
|
|
1240
|
-
}
|
|
1241
|
-
|
|
1242
|
-
private renderChainMode(): string[] {
|
|
1243
|
-
const innerW = this.width - 2;
|
|
1244
|
-
const th = this.theme;
|
|
1245
|
-
const lines: string[] = [];
|
|
1246
|
-
|
|
1247
|
-
const chainLabel = this.agentConfigs.map((c) => c.name).join(" → ");
|
|
1248
|
-
const maxHeaderLen = innerW - 4;
|
|
1249
|
-
const headerText = ` Chain: ${truncateToWidth(chainLabel, maxHeaderLen - 9)} `;
|
|
1250
|
-
lines.push(this.renderHeader(headerText));
|
|
1251
|
-
|
|
1252
|
-
lines.push(this.row(""));
|
|
1253
|
-
|
|
1254
|
-
const taskPreview = truncateToWidth(this.originalTask, innerW - 16);
|
|
1255
|
-
lines.push(this.row(` Original Task: ${taskPreview}`));
|
|
1256
|
-
const chainDirPreview = truncateToWidth(this.chainDir ?? "", innerW - 12);
|
|
1257
|
-
lines.push(this.row(` Chain Dir: ${th.fg("dim", chainDirPreview)}`));
|
|
1258
|
-
|
|
1259
|
-
const progressEnabled = this.agentConfigs.some((_, i) => this.getEffectiveBehavior(i).progress);
|
|
1260
|
-
const progressValue = progressEnabled ? th.fg("success", "enabled") : th.fg("dim", "disabled");
|
|
1261
|
-
lines.push(this.row(` Progress: ${progressValue} ${th.fg("dim", "(press [p] to toggle)")}`));
|
|
1262
|
-
lines.push(this.row(""));
|
|
1263
|
-
|
|
1264
|
-
for (let i = 0; i < this.agentConfigs.length; i++) {
|
|
1265
|
-
const config = this.agentConfigs[i]!;
|
|
1266
|
-
const isSelected = i === this.selectedStep;
|
|
1267
|
-
const behavior = this.getEffectiveBehavior(i);
|
|
1268
|
-
|
|
1269
|
-
const color = isSelected ? "accent" : "dim";
|
|
1270
|
-
const prefix = isSelected ? "▶ " : " ";
|
|
1271
|
-
const stepPrefix = `Step ${i + 1}: `;
|
|
1272
|
-
const maxNameLen = innerW - 4 - prefix.length - stepPrefix.length;
|
|
1273
|
-
const agentName = config.name.length > maxNameLen
|
|
1274
|
-
? config.name.slice(0, maxNameLen - 1) + "…"
|
|
1275
|
-
: config.name;
|
|
1276
|
-
const stepLabel = `${stepPrefix}${agentName}`;
|
|
1277
|
-
lines.push(
|
|
1278
|
-
this.row(` ${th.fg(color, prefix + stepLabel)}`),
|
|
1279
|
-
);
|
|
1280
|
-
|
|
1281
|
-
const template = (this.templates[i] ?? "").split("\n")[0] ?? "";
|
|
1282
|
-
const highlighted = template
|
|
1283
|
-
.replace(/\{task\}/g, th.fg("success", "{task}"))
|
|
1284
|
-
.replace(/\{previous\}/g, th.fg("warning", "{previous}"))
|
|
1285
|
-
.replace(/\{chain_dir\}/g, th.fg("accent", "{chain_dir}"));
|
|
1286
|
-
|
|
1287
|
-
const templateLabel = th.fg("dim", "task: ");
|
|
1288
|
-
lines.push(this.row(` ${templateLabel}${truncateToWidth(highlighted, innerW - 12)}`));
|
|
1289
|
-
|
|
1290
|
-
const effectiveModel = this.getEffectiveModel(i);
|
|
1291
|
-
const override = this.behaviorOverrides.get(i);
|
|
1292
|
-
const isOverridden = override?.model !== undefined;
|
|
1293
|
-
const modelValue = isOverridden
|
|
1294
|
-
? th.fg("warning", effectiveModel) + th.fg("dim", " ✎")
|
|
1295
|
-
: effectiveModel;
|
|
1296
|
-
const modelLabel = th.fg("dim", "model: ");
|
|
1297
|
-
lines.push(this.row(` ${modelLabel}${truncateToWidth(modelValue, innerW - 13)}`));
|
|
1298
|
-
|
|
1299
|
-
const writesValue = behavior.output === false
|
|
1300
|
-
? th.fg("dim", "(disabled)")
|
|
1301
|
-
: (typeof behavior.output === "string" && behavior.output
|
|
1302
|
-
? behavior.output
|
|
1303
|
-
: th.fg("dim", "(none)"));
|
|
1304
|
-
const writesLabel = th.fg("dim", "writes: ");
|
|
1305
|
-
lines.push(this.row(` ${writesLabel}${truncateToWidth(writesValue, innerW - 14)}`));
|
|
1306
|
-
|
|
1307
|
-
const readsValue = behavior.reads === false
|
|
1308
|
-
? th.fg("dim", "(disabled)")
|
|
1309
|
-
: (behavior.reads && behavior.reads.length > 0
|
|
1310
|
-
? behavior.reads.join(", ")
|
|
1311
|
-
: th.fg("dim", "(none)"));
|
|
1312
|
-
const readsLabel = th.fg("dim", "reads: ");
|
|
1313
|
-
lines.push(this.row(` ${readsLabel}${truncateToWidth(readsValue, innerW - 13)}`));
|
|
1314
|
-
|
|
1315
|
-
const skillsValue = behavior.skills === false
|
|
1316
|
-
? th.fg("dim", "(disabled)")
|
|
1317
|
-
: (behavior.skills?.length ? behavior.skills.join(", ") : th.fg("dim", "(none)"));
|
|
1318
|
-
const skillsLabel = th.fg("dim", "skills: ");
|
|
1319
|
-
lines.push(this.row(` ${skillsLabel}${truncateToWidth(skillsValue, innerW - 14)}`));
|
|
1320
|
-
|
|
1321
|
-
if (progressEnabled) {
|
|
1322
|
-
const isFirstStep = i === 0;
|
|
1323
|
-
const progressAction = isFirstStep
|
|
1324
|
-
? th.fg("success", "writes progress.md")
|
|
1325
|
-
: th.fg("accent", "reads progress.md");
|
|
1326
|
-
const progressLabel = th.fg("dim", "progress: ");
|
|
1327
|
-
lines.push(this.row(` ${progressLabel}${progressAction}`));
|
|
1328
|
-
}
|
|
1329
|
-
|
|
1330
|
-
if (i < this.agentConfigs.length - 1) {
|
|
1331
|
-
const nextStepUsePrevious = (this.templates[i + 1] ?? "").includes("{previous}");
|
|
1332
|
-
if (nextStepUsePrevious) {
|
|
1333
|
-
const indicator = th.fg("dim", " ↳ response → ") + th.fg("warning", "{previous}");
|
|
1334
|
-
lines.push(this.row(indicator));
|
|
1335
|
-
}
|
|
1336
|
-
}
|
|
1337
|
-
|
|
1338
|
-
lines.push(this.row(""));
|
|
1339
|
-
}
|
|
1340
|
-
|
|
1341
|
-
if (this.agentConfigs.length > 0) lines.pop();
|
|
1342
|
-
lines.push(this.row(this.getShortcutHelpText()));
|
|
1343
|
-
this.appendNotice(lines);
|
|
1344
|
-
lines.push(this.renderFooter(this.getFooterText()));
|
|
1345
|
-
|
|
1346
|
-
return lines;
|
|
1347
|
-
}
|
|
1348
|
-
|
|
1349
|
-
invalidate(): void {}
|
|
1350
|
-
dispose(): void {
|
|
1351
|
-
if (this.noticeMessageTimer) clearTimeout(this.noticeMessageTimer);
|
|
1352
|
-
this.noticeMessageTimer = null;
|
|
1353
|
-
}
|
|
1354
|
-
}
|