@selesai/code 0.9.10 → 0.9.12
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 +271 -255
- package/dist/cli/args.js +13 -2
- package/dist/cli/args.test.js +8 -0
- package/dist/cli/credential-print.js +4 -4
- package/dist/cli.js +0 -0
- package/dist/config.d.ts +4 -6
- package/dist/config.js +10 -14
- package/dist/core/agent-session-auto-handoff.test.js +24 -1
- package/dist/core/agent-session.d.ts +10 -4
- package/dist/core/agent-session.js +61 -46
- package/dist/core/compaction/branch-summarization.js +30 -30
- package/dist/core/compaction/compaction.js +81 -81
- package/dist/core/compaction/utils.js +2 -2
- package/dist/core/defaults.d.ts +1 -0
- package/dist/core/defaults.js +9 -0
- package/dist/core/export-html/template.css +1066 -1066
- package/dist/core/export-html/template.html +55 -55
- package/dist/core/export-html/template.js +1864 -1864
- package/dist/core/export-html/vendor/highlight.min.js +1212 -1212
- package/dist/core/export-html/vendor/marked.min.js +78 -78
- package/dist/core/extensions/loader.js +108 -35
- package/dist/core/extensions/loader.test.js +21 -0
- package/dist/core/extensions/types.d.ts +12 -4
- package/dist/core/keybindings.d.ts +2 -2
- package/dist/core/messages.js +7 -7
- package/dist/core/model-resolver.d.ts +1 -0
- package/dist/core/model-resolver.js +10 -4
- package/dist/core/package-manager.js +4 -4
- package/dist/core/sdk.d.ts +5 -5
- package/dist/core/sdk.js +16 -4
- package/dist/core/settings-manager.d.ts +6 -2
- package/dist/core/settings-manager.js +22 -3
- package/dist/core/tools/bash.d.ts +18 -1
- package/dist/core/tools/bash.js +41 -23
- package/dist/core/tools/index.d.ts +4 -2
- package/dist/core/tools/index.js +9 -2
- package/dist/core/tools/powershell.d.ts +15 -0
- package/dist/core/tools/powershell.js +38 -0
- package/dist/core/tools/powershell.test.d.ts +1 -0
- package/dist/core/tools/powershell.test.js +20 -0
- package/dist/defaults/settings.json +0 -1
- package/dist/extensions/context-compaction-reminder.test.ts +82 -82
- package/dist/extensions/context-compaction-reminder.ts +28 -28
- 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/LICENSE +21 -21
- 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.test.ts +83 -83
- package/dist/extensions/pi-intercom/broker/client.ts +39 -12
- package/dist/extensions/pi-intercom/broker/extension.test.ts +486 -387
- package/dist/extensions/pi-intercom/broker/framing.test.ts +114 -114
- package/dist/extensions/pi-intercom/broker/paths.test.ts +153 -153
- package/dist/extensions/pi-intercom/broker/paths.ts +134 -134
- package/dist/extensions/pi-intercom/broker/protocol.ts +26 -0
- package/dist/extensions/pi-intercom/broker/runtime-claim.test.ts +34 -34
- package/dist/extensions/pi-intercom/broker/runtime-claim.ts +21 -21
- 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/cwd.test.ts +40 -40
- package/dist/extensions/pi-intercom/cwd.ts +31 -31
- package/dist/extensions/pi-intercom/extension-api.ts +84 -44
- package/dist/extensions/pi-intercom/format-context.test.ts +31 -31
- package/dist/extensions/pi-intercom/format-context.ts +32 -32
- 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/test/overlay-width.test.ts +66 -66
- package/dist/extensions/pi-intercom/types.ts +32 -5
- package/dist/extensions/pi-intercom/ui/compose.ts +143 -143
- package/dist/extensions/pi-intercom/ui/inline-message.ts +6 -0
- package/dist/extensions/pi-intercom/ui/session-list.ts +166 -166
- package/dist/extensions/pi-powerline-footer/bash-mode/shell-session.ts +286 -286
- package/dist/extensions/pi-powerline-footer/bash-mode/transcript.ts +108 -108
- package/dist/extensions/pi-powerline-footer/separators.ts +57 -57
- package/dist/extensions/pi-powerline-footer/tests/session-usage.test.ts +47 -47
- package/dist/extensions/pi-powerline-footer/tests/tps.test.ts +39 -39
- package/dist/extensions/pi-powerline-footer/theme.example.json +24 -24
- package/dist/extensions/pi-powerline-footer/theme.json +12 -12
- package/dist/extensions/pi-powerline-footer/tps.ts +345 -345
- package/dist/extensions/pi-rewind-hook/README.md +245 -245
- package/dist/extensions/pi-rewind-hook/index.ts +1445 -1445
- package/dist/extensions/pi-rewind-hook/package.json +29 -29
- 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/pi-web-agent/package.json +31 -31
- package/dist/extensions/pi-web-agent/src/backends/config.ts +205 -205
- package/dist/extensions/pi-web-agent/src/backends/doctor.ts +136 -136
- package/dist/extensions/pi-web-agent/src/backends/factory.ts +152 -152
- package/dist/extensions/pi-web-agent/src/backends/settings-reader.ts +25 -25
- package/dist/extensions/pi-web-agent/src/cache/ttl-cache.ts +28 -28
- package/dist/extensions/pi-web-agent/src/changelog-notice.ts +136 -136
- package/dist/extensions/pi-web-agent/src/commands/web-agent-config.ts +946 -946
- package/dist/extensions/pi-web-agent/src/extension.ts +126 -126
- package/dist/extensions/pi-web-agent/src/extract/readability.ts +118 -118
- package/dist/extensions/pi-web-agent/src/fetch/browser-resolution.ts +199 -199
- package/dist/extensions/pi-web-agent/src/fetch/firecrawl-fetch.ts +100 -100
- package/dist/extensions/pi-web-agent/src/fetch/headless-fetch.ts +117 -117
- package/dist/extensions/pi-web-agent/src/fetch/http-fetch.ts +67 -67
- package/dist/extensions/pi-web-agent/src/orchestration/answer-synthesizer.ts +60 -60
- package/dist/extensions/pi-web-agent/src/orchestration/candidate-selector.ts +50 -50
- package/dist/extensions/pi-web-agent/src/orchestration/direct-url.ts +52 -52
- package/dist/extensions/pi-web-agent/src/orchestration/evidence-quality.ts +105 -105
- package/dist/extensions/pi-web-agent/src/orchestration/evidence-ranker.ts +45 -45
- package/dist/extensions/pi-web-agent/src/orchestration/index.ts +28 -28
- package/dist/extensions/pi-web-agent/src/orchestration/query-planner.ts +47 -47
- package/dist/extensions/pi-web-agent/src/orchestration/research-orchestrator.ts +376 -376
- package/dist/extensions/pi-web-agent/src/orchestration/research-types.ts +64 -64
- package/dist/extensions/pi-web-agent/src/orchestration/research-worker.ts +181 -181
- package/dist/extensions/pi-web-agent/src/orchestration/source-profile.ts +101 -101
- package/dist/extensions/pi-web-agent/src/orchestration/stop-decider.ts +81 -81
- package/dist/extensions/pi-web-agent/src/presentation/config-store.ts +210 -210
- package/dist/extensions/pi-web-agent/src/presentation/config.ts +75 -75
- package/dist/extensions/pi-web-agent/src/presentation/explore-presentation.ts +61 -61
- package/dist/extensions/pi-web-agent/src/presentation/fetch-presentation.ts +54 -54
- package/dist/extensions/pi-web-agent/src/presentation/search-presentation.ts +41 -41
- package/dist/extensions/pi-web-agent/src/presentation/select-view.ts +20 -20
- package/dist/extensions/pi-web-agent/src/presentation/types.ts +63 -63
- package/dist/extensions/pi-web-agent/src/search/brave.ts +114 -114
- package/dist/extensions/pi-web-agent/src/search/duckduckgo.ts +72 -72
- package/dist/extensions/pi-web-agent/src/search/searxng.ts +96 -96
- package/dist/extensions/pi-web-agent/src/tools/web-explore.ts +71 -71
- package/dist/extensions/pi-web-agent/src/tools/web-fetch-headless.ts +31 -31
- package/dist/extensions/pi-web-agent/src/tools/web-fetch.ts +31 -31
- package/dist/extensions/pi-web-agent/src/tools/web-search.ts +157 -157
- package/dist/extensions/pi-web-agent/src/types.ts +88 -88
- package/dist/extensions/ponytail/index.js +31 -25
- package/dist/extensions/ponytail/package.json +8 -8
- 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/extensions/question/batch.ts +103 -103
- package/dist/extensions/question/constants.ts +30 -30
- package/dist/extensions/question/helpers.ts +58 -58
- package/dist/extensions/question/navigation.ts +14 -14
- package/dist/extensions/question/package.json +19 -19
- package/dist/extensions/question/schemas.ts +43 -43
- package/dist/extensions/question/selection-mode.ts +46 -46
- package/dist/extensions/question/shortcuts.ts +44 -44
- package/dist/extensions/question/types.ts +132 -132
- package/dist/extensions/test-resolve-hook-impl.mjs +6 -6
- package/dist/extensions/test-resolve-hook.mjs +6 -6
- package/dist/extensions/web-agent-onboarding.ts +222 -222
- package/dist/extensions/workflow/package.json +17 -17
- package/dist/package-manager-cli.js +71 -71
- package/dist/rpc-entry.js +0 -0
- package/dist/skills/agent-browser/SKILL.md +52 -52
- package/dist/skills/batch-grill-me/SKILL.md +19 -19
- 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/grill-me/SKILL.md +10 -10
- package/dist/skills/handoff/SKILL.md +16 -16
- package/dist/skills/handoff-text/SKILL.md +14 -14
- 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/implanger/SKILL.md +69 -69
- package/dist/skills/improve-codebase/REFERENCE.md +78 -78
- package/dist/skills/improve-codebase/SKILL.md +178 -178
- 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/planger/SKILL.md +166 -166
- package/dist/skills/ponytail/SKILL.md +120 -116
- package/dist/skills/ponytail-audit/SKILL.md +41 -42
- package/dist/skills/ponytail-debt/SKILL.md +44 -45
- package/dist/skills/ponytail-gain/SKILL.md +50 -51
- package/dist/skills/ponytail-help/SKILL.md +71 -70
- package/dist/skills/ponytail-review/SKILL.md +57 -58
- package/dist/skills/redesign-existing-projects/SKILL.md +179 -0
- package/dist/skills/selesai-handoff/SKILL.md +20 -20
- 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/dist/skills/workflow-creation/SKILL.md +73 -73
- package/dist/themes/powerline-footer/theme.json +33 -33
- package/dist/utils/shell.d.ts +3 -0
- package/dist/utils/shell.js +17 -5
- package/docs/compaction.md +396 -396
- package/docs/containerization.md +111 -111
- package/docs/development.md +71 -71
- package/docs/docs.json +164 -164
- package/docs/environment-variables.md +86 -86
- package/docs/index.md +83 -83
- package/docs/json.md +82 -82
- package/docs/models.md +502 -502
- package/docs/packages.md +227 -227
- package/docs/plans/subagent-delegation/phase-0-correctness.md +264 -264
- package/docs/plans/subagent-delegation/phase-1-behavioral-contract.md +485 -485
- package/docs/plans/subagent-delegation/phase-2-context-controls.md +281 -281
- package/docs/plans/subagent-delegation/phase-3-advisory-routing.md +361 -361
- package/docs/plans/subagent-delegation/phase-4-optional-enforcement.md +380 -380
- package/docs/prompt-templates.md +95 -95
- package/docs/providers.md +293 -293
- package/docs/sdk.md +1144 -1143
- package/docs/security.md +59 -59
- package/docs/session-format.md +414 -414
- package/docs/sessions.md +145 -145
- package/docs/settings.md +0 -5
- package/docs/shared-host-extensions.md +109 -109
- package/docs/shell-aliases.md +13 -13
- package/docs/skills.md +231 -231
- package/docs/terminal-setup.md +142 -142
- package/docs/termux.md +127 -127
- package/docs/themes.md +295 -295
- package/docs/tmux.md +63 -63
- package/docs/tui.md +927 -927
- package/docs/windows.md +17 -17
- package/examples/README.md +25 -25
- package/examples/extensions/README.md +211 -211
- package/examples/extensions/auto-commit-on-exit.ts +49 -49
- package/examples/extensions/bash-spawn-hook.ts +30 -30
- package/examples/extensions/bookmark.ts +50 -50
- package/examples/extensions/border-status-editor.ts +150 -150
- package/examples/extensions/built-in-tool-renderer.ts +249 -249
- package/examples/extensions/claude-rules.ts +86 -86
- package/examples/extensions/commands.ts +72 -72
- package/examples/extensions/confirm-destructive.ts +59 -59
- package/examples/extensions/custom-compaction.ts +130 -130
- package/examples/extensions/custom-footer.ts +64 -64
- package/examples/extensions/custom-header.ts +73 -73
- package/examples/extensions/custom-provider-anthropic/index.ts +610 -610
- package/examples/extensions/custom-provider-anthropic/package-lock.json +24 -24
- package/examples/extensions/custom-provider-anthropic/package.json +19 -19
- package/examples/extensions/custom-provider-gitlab-duo/index.ts +404 -404
- package/examples/extensions/custom-provider-gitlab-duo/package.json +16 -16
- package/examples/extensions/custom-provider-gitlab-duo/test.ts +82 -82
- package/examples/extensions/dirty-repo-guard.ts +56 -56
- package/examples/extensions/doom-overlay/README.md +46 -46
- package/examples/extensions/doom-overlay/doom/build/doom.js +21 -21
- package/examples/extensions/doom-overlay/doom/build/doom.wasm +0 -0
- package/examples/extensions/doom-overlay/doom/build.sh +152 -152
- package/examples/extensions/doom-overlay/doom/doomgeneric_pi.c +72 -72
- package/examples/extensions/doom-overlay/doom-component.ts +132 -132
- package/examples/extensions/doom-overlay/doom-engine.ts +173 -173
- package/examples/extensions/doom-overlay/doom-keys.ts +104 -104
- package/examples/extensions/doom-overlay/index.ts +74 -74
- package/examples/extensions/doom-overlay/wad-finder.ts +51 -51
- package/examples/extensions/dynamic-resources/SKILL.md +8 -8
- package/examples/extensions/dynamic-resources/dynamic.json +79 -79
- package/examples/extensions/dynamic-resources/dynamic.md +5 -5
- package/examples/extensions/dynamic-resources/index.ts +15 -15
- package/examples/extensions/dynamic-tools.ts +74 -74
- package/examples/extensions/event-bus.ts +43 -43
- package/examples/extensions/file-trigger.ts +41 -41
- package/examples/extensions/git-checkpoint.ts +53 -53
- package/examples/extensions/git-merge-and-resolve.ts +115 -115
- package/examples/extensions/github-issue-autocomplete.ts +185 -185
- package/examples/extensions/gondolin/index.ts +531 -531
- package/examples/extensions/gondolin/package-lock.json +185 -185
- package/examples/extensions/gondolin/package.json +19 -19
- package/examples/extensions/handoff.ts +199 -199
- package/examples/extensions/hello.ts +26 -26
- package/examples/extensions/hidden-thinking-label.ts +53 -53
- package/examples/extensions/inline-bash.ts +94 -94
- package/examples/extensions/input-transform-streaming.ts +39 -39
- package/examples/extensions/input-transform.ts +43 -43
- package/examples/extensions/interactive-shell.ts +196 -196
- package/examples/extensions/mac-system-theme.ts +47 -47
- package/examples/extensions/message-renderer.ts +59 -59
- package/examples/extensions/minimal-mode.ts +426 -426
- package/examples/extensions/modal-editor.ts +85 -85
- package/examples/extensions/model-status.ts +31 -31
- package/examples/extensions/notify.ts +55 -55
- package/examples/extensions/overlay-qa-tests.ts +1450 -1450
- package/examples/extensions/overlay-test.ts +153 -153
- package/examples/extensions/permission-gate.ts +34 -34
- package/examples/extensions/pirate.ts +47 -47
- package/examples/extensions/plan-mode/README.md +66 -66
- package/examples/extensions/plan-mode/index.ts +390 -390
- package/examples/extensions/plan-mode/utils.ts +168 -168
- package/examples/extensions/preset.ts +436 -436
- package/examples/extensions/project-trust.ts +64 -64
- package/examples/extensions/prompt-customizer.ts +97 -97
- package/examples/extensions/protected-paths.ts +30 -30
- package/examples/extensions/provider-payload.ts +18 -18
- package/examples/extensions/qna.ts +122 -122
- package/examples/extensions/question.ts +285 -285
- package/examples/extensions/questionnaire.ts +448 -448
- package/examples/extensions/rainbow-editor.ts +88 -88
- package/examples/extensions/reload-runtime.ts +37 -37
- package/examples/extensions/rpc-demo.ts +118 -118
- package/examples/extensions/sandbox/index.ts +321 -321
- package/examples/extensions/sandbox/package-lock.json +92 -92
- package/examples/extensions/sandbox/package.json +19 -19
- package/examples/extensions/send-user-message.ts +97 -97
- package/examples/extensions/session-name.ts +27 -27
- package/examples/extensions/shutdown-command.ts +63 -63
- package/examples/extensions/snake.ts +343 -343
- package/examples/extensions/space-invaders.ts +560 -560
- package/examples/extensions/ssh.ts +220 -220
- package/examples/extensions/status-line.ts +32 -32
- package/examples/extensions/structured-output.ts +65 -65
- package/examples/extensions/subagent/README.md +175 -175
- package/examples/extensions/subagent/agents/planner.md +37 -37
- package/examples/extensions/subagent/agents/reviewer.md +35 -35
- package/examples/extensions/subagent/agents/scout.md +50 -50
- package/examples/extensions/subagent/agents/worker.md +24 -24
- package/examples/extensions/subagent/agents.ts +126 -126
- package/examples/extensions/subagent/index.ts +1015 -1015
- package/examples/extensions/subagent/prompts/implement-and-review.md +10 -10
- package/examples/extensions/subagent/prompts/implement.md +10 -10
- package/examples/extensions/subagent/prompts/scout-and-plan.md +9 -9
- package/examples/extensions/summarize.ts +209 -209
- package/examples/extensions/system-prompt-header.ts +17 -17
- package/examples/extensions/tic-tac-toe.ts +1008 -1008
- package/examples/extensions/timed-confirm.ts +70 -70
- package/examples/extensions/titlebar-spinner.ts +58 -58
- package/examples/extensions/todo.ts +297 -297
- package/examples/extensions/tool-override.ts +144 -144
- package/examples/extensions/tools.ts +146 -146
- package/examples/extensions/trigger-compact.ts +50 -50
- package/examples/extensions/truncated-tool.ts +195 -195
- package/examples/extensions/widget-placement.ts +9 -9
- package/examples/extensions/with-deps/index.ts +32 -32
- package/examples/extensions/with-deps/package-lock.json +31 -31
- package/examples/extensions/with-deps/package.json +22 -22
- package/examples/extensions/working-indicator.ts +123 -123
- package/examples/extensions/working-message-test.ts +25 -25
- package/examples/rpc-extension-ui.ts +632 -632
- package/examples/sdk/01-minimal.ts +26 -26
- package/examples/sdk/02-custom-model.ts +53 -53
- package/examples/sdk/03-custom-prompt.ts +75 -75
- package/examples/sdk/04-skills.ts +55 -55
- package/examples/sdk/05-tools.ts +48 -48
- package/examples/sdk/06-extensions.ts +99 -99
- package/examples/sdk/07-context-files.ts +47 -47
- package/examples/sdk/08-prompt-templates.ts +51 -51
- package/examples/sdk/09-api-keys-and-oauth.ts +52 -52
- package/examples/sdk/10-settings.ts +53 -53
- package/examples/sdk/11-sessions.ts +52 -52
- package/examples/sdk/12-full-control.ts +79 -79
- package/examples/sdk/13-session-runtime.ts +67 -67
- package/examples/sdk/README.md +144 -144
- package/package.json +4 -4
- 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.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
- /package/dist/core/{tools/schema-prune.test.d.ts → extensions/loader.test.d.ts} +0 -0
|
@@ -0,0 +1,894 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
// Execute gate oracles, update evidence, coordinate scopes, and manage leases.
|
|
3
|
+
// Zero dependencies. Node 16+.
|
|
4
|
+
|
|
5
|
+
import {
|
|
6
|
+
closeSync, constants as fsConstants, existsSync, fstatSync, lstatSync,
|
|
7
|
+
mkdirSync, openSync, readFileSync, realpathSync, statSync, unlinkSync,
|
|
8
|
+
writeFileSync,
|
|
9
|
+
} from "node:fs";
|
|
10
|
+
import { spawn } from "node:child_process";
|
|
11
|
+
import { Worker } from "node:worker_threads";
|
|
12
|
+
import { randomBytes } from "node:crypto";
|
|
13
|
+
import { delimiter, dirname, basename, isAbsolute, join, relative, resolve, sep } from "node:path";
|
|
14
|
+
import { homedir } from "node:os";
|
|
15
|
+
import { fileURLToPath } from "node:url";
|
|
16
|
+
import {
|
|
17
|
+
UNLAZY_DIR, appendStatus, claimLeases, formatDocument, gateState,
|
|
18
|
+
hookStatePath, listScopes, parseGates, qualify, releaseLeases, resolveTarget,
|
|
19
|
+
scopeRoot, sha256, sleep, validateScopeId, withFileLock, writeAtomic,
|
|
20
|
+
} from "./lib/gates.mjs";
|
|
21
|
+
import { terminateProcessTree } from "./lib/process-tree.mjs";
|
|
22
|
+
import { dispatchStatus } from "./lib/dispatch.mjs";
|
|
23
|
+
|
|
24
|
+
const HELP = `usage: gate-check.mjs [options] [file ...]
|
|
25
|
+
|
|
26
|
+
run modes:
|
|
27
|
+
(default) run unmet runnable gates and update their ledgers
|
|
28
|
+
--status report only; never execute, approve, or write
|
|
29
|
+
--reverify re-run every runnable gate and demote stale failures
|
|
30
|
+
--approve approve each exact pending oracle, then run it
|
|
31
|
+
--jobs N rolling concurrency, integer 1..64 (default 1)
|
|
32
|
+
--timeout S per-check timeout, integer seconds 1..86400 (default 120)
|
|
33
|
+
--shell PATH command shell (UNLAZY_SHELL, then platform default)
|
|
34
|
+
--cwd DIR default CHECK directory (explicit: file dir; discovered: --root)
|
|
35
|
+
|
|
36
|
+
pipeline actions:
|
|
37
|
+
--claim --scope ID [--leaf NAME] atomically claim the leaf's OWNS paths
|
|
38
|
+
--release --scope ID [--leaf NAME] release serialized ownership leases
|
|
39
|
+
--log TEXT --scope ID append one status line
|
|
40
|
+
--bind SESSION --scope ID bind a session to one pipeline
|
|
41
|
+
--list-scopes list .unlazy pipelines
|
|
42
|
+
|
|
43
|
+
targeting:
|
|
44
|
+
--scope ID use .unlazy/ID (or UNLAZY_SCOPE)
|
|
45
|
+
--root DIR repository/pipeline root (default current directory)
|
|
46
|
+
file ... explicit regular ledger files; all are honored
|
|
47
|
+
|
|
48
|
+
CHECK execution requires prior approval keyed to the exact CHECK, EXPECT,
|
|
49
|
+
resolved CWD, resolved shell, timeout, output/regex limits, platform, and PATH.
|
|
50
|
+
Approvals live outside the repository under ~/.unlazy/approved by default.
|
|
51
|
+
|
|
52
|
+
exit codes: 0 all met/action succeeded; 1 unmet; 2 usage/parse/infrastructure;
|
|
53
|
+
3 lease conflict.`;
|
|
54
|
+
|
|
55
|
+
const FLAG_OPTIONS = new Set([
|
|
56
|
+
"--status", "--reverify", "--approve", "--claim", "--release",
|
|
57
|
+
"--list-scopes", "--help", "-h",
|
|
58
|
+
]);
|
|
59
|
+
const VALUE_OPTIONS = new Set([
|
|
60
|
+
"--scope", "--leaf", "--timeout", "--jobs", "--cwd", "--root",
|
|
61
|
+
"--log", "--bind", "--shell",
|
|
62
|
+
]);
|
|
63
|
+
const MAX_OUTPUT_BYTES = 1024 * 1024;
|
|
64
|
+
const MAX_APPROVAL_BYTES = 256 * 1024;
|
|
65
|
+
const REGEX_TIMEOUT_MS = 250;
|
|
66
|
+
const REGEX_STARTUP_TIMEOUT_MS = 5000;
|
|
67
|
+
const MAX_REGEX_WORKERS = 4;
|
|
68
|
+
const DEFAULT_TIMEOUT_SECONDS = 120;
|
|
69
|
+
const CHECK_SUPERVISOR = fileURLToPath(new URL("./lib/check-supervisor.mjs", import.meta.url));
|
|
70
|
+
|
|
71
|
+
// Repository-controlled titles, paths, commands, and output must not be able
|
|
72
|
+
// to rewrite terminal history, set a window title, or visually reorder text.
|
|
73
|
+
// Strip every C0/C1 control plus Unicode bidi formatting markers at the final
|
|
74
|
+
// sink. Each console call still receives its own trailing newline.
|
|
75
|
+
const UNSAFE_TERMINAL_RE = /[\u0000-\u001f\u007f-\u009f\u061c\u200e\u200f\u202a-\u202e\u2066-\u2069]/g;
|
|
76
|
+
const terminalSafe = (value) => String(value).replace(UNSAFE_TERMINAL_RE, " ");
|
|
77
|
+
for (const method of ["log", "error"]) {
|
|
78
|
+
const write = console[method].bind(console);
|
|
79
|
+
console[method] = (...values) => write(...values.map(terminalSafe));
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
function parseArgs(argv) {
|
|
83
|
+
const options = {};
|
|
84
|
+
const files = [];
|
|
85
|
+
let positional = false;
|
|
86
|
+
for (let index = 0; index < argv.length; index++) {
|
|
87
|
+
const arg = argv[index];
|
|
88
|
+
if (arg === "--") { positional = true; continue; }
|
|
89
|
+
if (!positional && FLAG_OPTIONS.has(arg)) {
|
|
90
|
+
const key = arg.replace(/^-+/, "");
|
|
91
|
+
if (options[key] !== undefined) return { error: "duplicate option " + arg };
|
|
92
|
+
options[key] = true;
|
|
93
|
+
continue;
|
|
94
|
+
}
|
|
95
|
+
if (!positional && arg.startsWith("--")) {
|
|
96
|
+
const equals = arg.indexOf("=");
|
|
97
|
+
const name = equals === -1 ? arg : arg.slice(0, equals);
|
|
98
|
+
if (!VALUE_OPTIONS.has(name)) return { error: "unknown option " + name };
|
|
99
|
+
const key = name.slice(2);
|
|
100
|
+
if (options[key] !== undefined) return { error: "duplicate option " + name };
|
|
101
|
+
const value = equals === -1 ? argv[++index] : arg.slice(equals + 1);
|
|
102
|
+
if (value === undefined || value === "") return { error: name + " needs a value" };
|
|
103
|
+
options[key] = value;
|
|
104
|
+
continue;
|
|
105
|
+
}
|
|
106
|
+
if (!positional && arg.startsWith("-")) return { error: "unknown option " + arg };
|
|
107
|
+
files.push(arg);
|
|
108
|
+
}
|
|
109
|
+
return { options, files };
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
function failUsage(message) {
|
|
113
|
+
console.error("gate-check: " + message);
|
|
114
|
+
console.error("run gate-check.mjs --help for usage");
|
|
115
|
+
process.exit(2);
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
function asDirectory(path, label) {
|
|
119
|
+
try {
|
|
120
|
+
if (!statSync(path).isDirectory()) failUsage(label + " is not a directory: " + path);
|
|
121
|
+
} catch (error) {
|
|
122
|
+
if (error.code === "ENOENT") failUsage(label + " does not exist: " + path);
|
|
123
|
+
failUsage("cannot inspect " + label + " " + path + ": " + error.message);
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
function timeoutValue(value) {
|
|
128
|
+
if (value === undefined) return DEFAULT_TIMEOUT_SECONDS;
|
|
129
|
+
const number = Number(value);
|
|
130
|
+
if (!Number.isFinite(number) || !Number.isInteger(number) || number < 1 || number > 86400) {
|
|
131
|
+
failUsage("--timeout needs an integer from 1 through 86400, got " + JSON.stringify(value));
|
|
132
|
+
}
|
|
133
|
+
return number;
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
function jobCount(value) {
|
|
137
|
+
if (value === undefined) return 1;
|
|
138
|
+
const number = Number(value);
|
|
139
|
+
if (!Number.isFinite(number) || !Number.isInteger(number) || number < 1 || number > 64) {
|
|
140
|
+
failUsage("--jobs needs an integer from 1 through 64, got " + JSON.stringify(value));
|
|
141
|
+
}
|
|
142
|
+
return number;
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
const parsedArgs = parseArgs(process.argv.slice(2));
|
|
146
|
+
if (parsedArgs.error) failUsage(parsedArgs.error);
|
|
147
|
+
const { options: opt, files: fileArgs } = parsedArgs;
|
|
148
|
+
if (opt.help || opt.h) {
|
|
149
|
+
// HELP is a fixed local constant, so preserve its intentional layout instead
|
|
150
|
+
// of routing it through the untrusted-value terminal sanitizer.
|
|
151
|
+
process.stdout.write(HELP + "\n");
|
|
152
|
+
process.exit(0);
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
const actionNames = [];
|
|
156
|
+
for (const key of ["claim", "release", "list-scopes"]) if (opt[key]) actionNames.push("--" + key);
|
|
157
|
+
for (const key of ["log", "bind"]) if (opt[key] !== undefined) actionNames.push("--" + key);
|
|
158
|
+
if (actionNames.length > 1) failUsage("pipeline actions are mutually exclusive: " + actionNames.join(", "));
|
|
159
|
+
const action = actionNames[0] || null;
|
|
160
|
+
|
|
161
|
+
if (opt.status && opt.reverify) failUsage("--status and --reverify are mutually exclusive");
|
|
162
|
+
if (opt.status && opt.approve) failUsage("--status never approves commands; remove --approve");
|
|
163
|
+
if (action && (opt.status || opt.reverify || opt.approve)) failUsage(action + " cannot be combined with a run mode");
|
|
164
|
+
if (action && fileArgs.length) failUsage(action + " cannot be combined with explicit files");
|
|
165
|
+
if (fileArgs.length && opt.scope) failUsage("explicit files and --scope are mutually exclusive");
|
|
166
|
+
if (opt.leaf && !opt.claim && !opt.release) failUsage("--leaf is only valid with --claim or --release");
|
|
167
|
+
if ((opt.timeout || opt.jobs || opt.shell || opt.cwd) && (action || opt.status)) {
|
|
168
|
+
failUsage("--timeout, --jobs, --shell, and --cwd are execution options only");
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
const root = resolve(opt.root || process.cwd());
|
|
172
|
+
asDirectory(root, "--root");
|
|
173
|
+
const timeoutSeconds = timeoutValue(opt.timeout);
|
|
174
|
+
const jobs = jobCount(opt.jobs);
|
|
175
|
+
const defaultCwd = resolve(root, opt.cwd || ".");
|
|
176
|
+
if (!action && !opt.status) asDirectory(defaultCwd, "--cwd");
|
|
177
|
+
|
|
178
|
+
if (action === "--list-scopes") {
|
|
179
|
+
const scopes = listScopes(root);
|
|
180
|
+
if (scopes.length) {
|
|
181
|
+
for (const scope of scopes) console.log(scope);
|
|
182
|
+
} else console.log("(no pipelines under " + UNLAZY_DIR + "/)");
|
|
183
|
+
process.exit(0);
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
if (opt.scope) {
|
|
187
|
+
const error = validateScopeId(opt.scope);
|
|
188
|
+
if (error) failUsage(error);
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
let target = resolveTarget({ root, scope: opt.scope, files: fileArgs });
|
|
192
|
+
// A deleted/crashed pipeline can leave coordination leases behind after its
|
|
193
|
+
// ledger directory is gone. An explicit, validated release target must remain
|
|
194
|
+
// usable for that recovery path; claims still require a live exact ledger.
|
|
195
|
+
if (target.error && action === "--release" && opt.scope) {
|
|
196
|
+
target = { mode: "scope", scope: opt.scope, files: [] };
|
|
197
|
+
} else if (target.error) failUsage(target.error);
|
|
198
|
+
const scope = target.scope;
|
|
199
|
+
|
|
200
|
+
if (action === "--log") {
|
|
201
|
+
if (!scope) failUsage("--log needs --scope ID or exactly one discoverable pipeline");
|
|
202
|
+
if (!String(opt.log).trim()) failUsage("--log needs non-blank text");
|
|
203
|
+
try {
|
|
204
|
+
const path = await appendStatus(root, scope, opt.log);
|
|
205
|
+
console.log("appended to " + path);
|
|
206
|
+
process.exit(0);
|
|
207
|
+
} catch (error) {
|
|
208
|
+
console.error("gate-check: cannot append status: " + error.message);
|
|
209
|
+
process.exit(2);
|
|
210
|
+
}
|
|
211
|
+
}
|
|
212
|
+
|
|
213
|
+
if (action === "--bind") {
|
|
214
|
+
if (!scope) failUsage("--bind needs --scope ID or exactly one discoverable pipeline");
|
|
215
|
+
if (!String(opt.bind).trim()) failUsage("--bind needs a non-blank session id");
|
|
216
|
+
const path = join(scopeRoot(root, scope), "session");
|
|
217
|
+
try {
|
|
218
|
+
writeAtomic(path, String(opt.bind).trim() + "\n", { root });
|
|
219
|
+
console.log("bound session " + opt.bind + " to scope " + scope);
|
|
220
|
+
process.exit(0);
|
|
221
|
+
} catch (error) {
|
|
222
|
+
console.error("gate-check: cannot bind session: " + error.message);
|
|
223
|
+
process.exit(2);
|
|
224
|
+
}
|
|
225
|
+
}
|
|
226
|
+
|
|
227
|
+
if (!target.files.length && action !== "--release") {
|
|
228
|
+
failUsage("no gate files found (looked for " + UNLAZY_DIR + "/<scope>/, then GATES.md and gates/*.md under " + root + ")");
|
|
229
|
+
}
|
|
230
|
+
|
|
231
|
+
for (const file of target.files) {
|
|
232
|
+
try {
|
|
233
|
+
if (!statSync(file).isFile()) failUsage("gate target is not a regular file: " + file);
|
|
234
|
+
} catch (error) {
|
|
235
|
+
if (error.code === "ENOENT") failUsage("no such gate file: " + file);
|
|
236
|
+
failUsage("cannot inspect gate file " + file + ": " + error.message);
|
|
237
|
+
}
|
|
238
|
+
}
|
|
239
|
+
|
|
240
|
+
function loadLedger(file) {
|
|
241
|
+
let text;
|
|
242
|
+
try { text = readFileSync(file, "utf8"); }
|
|
243
|
+
catch (error) { failUsage("cannot read " + file + ": " + error.message); }
|
|
244
|
+
const doc = parseGates(text);
|
|
245
|
+
for (const warning of doc.warnings) console.error("gate-check: " + file + ": warning: " + warning);
|
|
246
|
+
if (doc.errors.length) {
|
|
247
|
+
for (const error of doc.errors) console.error("gate-check: " + file + ": " + error);
|
|
248
|
+
process.exit(2);
|
|
249
|
+
}
|
|
250
|
+
return { file, doc };
|
|
251
|
+
}
|
|
252
|
+
|
|
253
|
+
if (action === "--claim" || action === "--release") {
|
|
254
|
+
if (!scope) failUsage(action + " needs --scope ID or exactly one discoverable pipeline");
|
|
255
|
+
const stems = target.files.map((file) => basename(file).replace(/\.md$/i, ""));
|
|
256
|
+
if (opt.leaf) {
|
|
257
|
+
const error = validateScopeId(opt.leaf, "leaf");
|
|
258
|
+
if (error) failUsage(error);
|
|
259
|
+
if (stems.length && !stems.includes(opt.leaf)) failUsage("unknown --leaf " + opt.leaf + " (have: " + stems.join(", ") + ")");
|
|
260
|
+
}
|
|
261
|
+
if (action === "--release") {
|
|
262
|
+
try {
|
|
263
|
+
const count = await releaseLeases(root, { scope, leaf: opt.leaf || null });
|
|
264
|
+
console.log("released " + count + " lease(s) for " + scope + (opt.leaf ? "/" + opt.leaf : ""));
|
|
265
|
+
process.exit(0);
|
|
266
|
+
} catch (error) {
|
|
267
|
+
console.error("gate-check: cannot release leases: " + error.message);
|
|
268
|
+
process.exit(2);
|
|
269
|
+
}
|
|
270
|
+
}
|
|
271
|
+
|
|
272
|
+
const leaf = opt.leaf || (stems.length === 1 ? stems[0] : null);
|
|
273
|
+
if (!leaf) failUsage("--claim needs --leaf NAME when a scope has several gate files");
|
|
274
|
+
const selectedFile = target.files.find((file) => basename(file).replace(/\.md$/i, "") === leaf);
|
|
275
|
+
const selected = loadLedger(selectedFile);
|
|
276
|
+
if (!selected.doc.owns.length) failUsage(basename(selected.file) + " declares no OWNS paths");
|
|
277
|
+
let result;
|
|
278
|
+
try { result = await claimLeases(root, { scope, leaf, globs: selected.doc.owns }); }
|
|
279
|
+
catch (error) {
|
|
280
|
+
console.error("gate-check: cannot claim leases: " + error.message);
|
|
281
|
+
process.exit(2);
|
|
282
|
+
}
|
|
283
|
+
if (!result.ok) {
|
|
284
|
+
if (result.error) failUsage(result.error);
|
|
285
|
+
for (const conflict of result.conflicts) {
|
|
286
|
+
console.log("CONFLICT " + conflict.glob + " overlaps " + conflict.theirGlob + " held by " + conflict.with);
|
|
287
|
+
}
|
|
288
|
+
console.log("CLAIM REFUSED (" + result.conflicts.length + " conflict(s))");
|
|
289
|
+
process.exit(3);
|
|
290
|
+
}
|
|
291
|
+
console.log("CLAIMED " + result.globs.length + " path(s) for " + scope + "/" + leaf + ": " + result.globs.join(", "));
|
|
292
|
+
process.exit(0);
|
|
293
|
+
}
|
|
294
|
+
|
|
295
|
+
let ledgers = target.files.map(loadLedger);
|
|
296
|
+
|
|
297
|
+
function executableCandidates(name) {
|
|
298
|
+
if (process.platform !== "win32") return [name];
|
|
299
|
+
if (/\.[A-Za-z0-9]+$/.test(name)) return [name];
|
|
300
|
+
const extensions = (process.env.PATHEXT || ".COM;.EXE;.BAT;.CMD").split(";").filter(Boolean);
|
|
301
|
+
return [name, ...extensions.map((extension) => name + extension.toLowerCase()), ...extensions.map((extension) => name + extension.toUpperCase())];
|
|
302
|
+
}
|
|
303
|
+
|
|
304
|
+
function resolveShell(raw) {
|
|
305
|
+
const requested = raw || process.env.UNLAZY_SHELL || (process.platform === "win32" ? (process.env.ComSpec || "cmd.exe") : "/bin/sh");
|
|
306
|
+
const containsSeparator = requested.includes("/") || requested.includes("\\") || isAbsolute(requested);
|
|
307
|
+
const candidates = [];
|
|
308
|
+
if (containsSeparator) candidates.push(resolve(process.cwd(), requested));
|
|
309
|
+
else {
|
|
310
|
+
for (const directory of String(process.env.PATH || "").split(delimiter).filter(Boolean)) {
|
|
311
|
+
for (const name of executableCandidates(requested)) candidates.push(join(directory, name));
|
|
312
|
+
}
|
|
313
|
+
}
|
|
314
|
+
for (const candidate of candidates) {
|
|
315
|
+
try { if (statSync(candidate).isFile()) return candidate; } catch { /* keep looking */ }
|
|
316
|
+
}
|
|
317
|
+
failUsage("cannot resolve command shell " + JSON.stringify(requested) + " from PATH");
|
|
318
|
+
}
|
|
319
|
+
|
|
320
|
+
const shell = opt.status ? "(not used: status mode)" : resolveShell(opt.shell);
|
|
321
|
+
const pathValue = String(process.env.PATH || "");
|
|
322
|
+
const pathHash = sha256(pathValue).slice(0, 12);
|
|
323
|
+
const pathCount = pathValue ? pathValue.split(delimiter).length : 0;
|
|
324
|
+
const pathEvidence = pathHash + "/" + pathCount + " entries";
|
|
325
|
+
const pathTranscript = pathValue.replace(/[\r\n]/g, " ").slice(0, 800) + (pathValue.length > 800 ? "..." : "");
|
|
326
|
+
|
|
327
|
+
function resolvedGateCwd(gate, file) {
|
|
328
|
+
// Explicit ledgers are self-contained: absent --cwd, relative commands and
|
|
329
|
+
// CWD attributes anchor beside that ledger instead of wherever the caller
|
|
330
|
+
// happened to launch the checker. Scoped and legacy discovery anchor at root.
|
|
331
|
+
const base = opt.cwd ? defaultCwd : (target.mode === "explicit" ? dirname(resolve(file)) : root);
|
|
332
|
+
return gate.cwd ? resolve(base, gate.cwd) : base;
|
|
333
|
+
}
|
|
334
|
+
|
|
335
|
+
function oracle(file, gate) {
|
|
336
|
+
const cwd = resolvedGateCwd(gate, file);
|
|
337
|
+
return {
|
|
338
|
+
schema: 1,
|
|
339
|
+
check: gate.check,
|
|
340
|
+
expect: gate.expect,
|
|
341
|
+
cwd,
|
|
342
|
+
shell,
|
|
343
|
+
timeoutMs: timeoutSeconds * 1000,
|
|
344
|
+
maxOutputBytes: MAX_OUTPUT_BYTES,
|
|
345
|
+
regexTimeoutMs: REGEX_TIMEOUT_MS,
|
|
346
|
+
regexStartupTimeoutMs: REGEX_STARTUP_TIMEOUT_MS,
|
|
347
|
+
maxRegexWorkers: MAX_REGEX_WORKERS,
|
|
348
|
+
platform: process.platform,
|
|
349
|
+
path: pathValue,
|
|
350
|
+
};
|
|
351
|
+
}
|
|
352
|
+
|
|
353
|
+
function signature(file, gate) {
|
|
354
|
+
return sha256(JSON.stringify(oracle(file, gate)));
|
|
355
|
+
}
|
|
356
|
+
|
|
357
|
+
function pathIsInside(parent, child) {
|
|
358
|
+
const rel = relative(resolve(parent), resolve(child));
|
|
359
|
+
return rel === "" || (!rel.startsWith(".." + sep) && rel !== ".." && !isAbsolute(rel));
|
|
360
|
+
}
|
|
361
|
+
|
|
362
|
+
const approvalDir = resolve(process.env.UNLAZY_APPROVAL_DIR || join(homedir(), ".unlazy", "approved"));
|
|
363
|
+
const canonicalRoot = realpathSync(root);
|
|
364
|
+
if (!opt.status && pathIsInside(root, approvalDir)) failUsage("UNLAZY_APPROVAL_DIR must be outside the repository root");
|
|
365
|
+
|
|
366
|
+
function approvalPath(file, gate, directory = approvalDir) {
|
|
367
|
+
const identity = resolve(file) + "\0" + gate.id + "\0" + signature(file, gate);
|
|
368
|
+
return join(directory, sha256(identity) + ".json");
|
|
369
|
+
}
|
|
370
|
+
|
|
371
|
+
function assertPrivateApprovalEntry(path, info, kind) {
|
|
372
|
+
if (info.isSymbolicLink() || (kind === "directory" ? !info.isDirectory() : !info.isFile())) {
|
|
373
|
+
throw new Error(path + " must be a real " + kind);
|
|
374
|
+
}
|
|
375
|
+
const uid = typeof process.geteuid === "function" ? process.geteuid()
|
|
376
|
+
: typeof process.getuid === "function" ? process.getuid() : null;
|
|
377
|
+
if (uid !== null && info.uid !== uid) {
|
|
378
|
+
throw new Error(path + " must be owned by the current user");
|
|
379
|
+
}
|
|
380
|
+
if (process.platform !== "win32" && (info.mode & 0o077) !== 0) {
|
|
381
|
+
throw new Error(path + " must not grant group or other permissions");
|
|
382
|
+
}
|
|
383
|
+
}
|
|
384
|
+
|
|
385
|
+
function validatedApprovalDir({ create = false } = {}) {
|
|
386
|
+
if (create) mkdirSync(approvalDir, { recursive: true, mode: 0o700 });
|
|
387
|
+
else if (!existsSync(approvalDir)) return null;
|
|
388
|
+
const info = lstatSync(approvalDir);
|
|
389
|
+
assertPrivateApprovalEntry(approvalDir, info, "directory");
|
|
390
|
+
const canonical = realpathSync(approvalDir);
|
|
391
|
+
if (pathIsInside(canonicalRoot, canonical)) {
|
|
392
|
+
throw new Error("approval directory resolves inside the repository root: " + canonical);
|
|
393
|
+
}
|
|
394
|
+
const canonicalInfo = lstatSync(canonical);
|
|
395
|
+
assertPrivateApprovalEntry(canonical, canonicalInfo, "directory");
|
|
396
|
+
return { path: canonical, dev: canonicalInfo.dev, ino: canonicalInfo.ino };
|
|
397
|
+
}
|
|
398
|
+
|
|
399
|
+
function assertApprovalDirUnchanged(store) {
|
|
400
|
+
const current = lstatSync(store.path);
|
|
401
|
+
assertPrivateApprovalEntry(store.path, current, "directory");
|
|
402
|
+
if (current.dev !== store.dev || current.ino !== store.ino) {
|
|
403
|
+
throw new Error("approval directory changed during use: " + store.path);
|
|
404
|
+
}
|
|
405
|
+
}
|
|
406
|
+
|
|
407
|
+
function readApprovalFile(path) {
|
|
408
|
+
let fd = null;
|
|
409
|
+
try {
|
|
410
|
+
const noFollow = process.platform === "win32" ? 0 : (fsConstants.O_NOFOLLOW || 0);
|
|
411
|
+
fd = openSync(path, fsConstants.O_RDONLY | (fsConstants.O_NONBLOCK || 0) | noFollow);
|
|
412
|
+
const opened = fstatSync(fd);
|
|
413
|
+
const named = lstatSync(path);
|
|
414
|
+
assertPrivateApprovalEntry(path, opened, "file");
|
|
415
|
+
if (opened.size > MAX_APPROVAL_BYTES) {
|
|
416
|
+
throw new Error("approval record exceeds " + MAX_APPROVAL_BYTES + " bytes: " + path);
|
|
417
|
+
}
|
|
418
|
+
if (named.isSymbolicLink() || !named.isFile() || named.nlink !== 1 || opened.nlink !== 1 ||
|
|
419
|
+
named.dev !== opened.dev || named.ino !== opened.ino) {
|
|
420
|
+
throw new Error("refusing linked or replaced approval record " + path);
|
|
421
|
+
}
|
|
422
|
+
const text = readFileSync(fd, "utf8");
|
|
423
|
+
const after = lstatSync(path);
|
|
424
|
+
if (after.isSymbolicLink() || !after.isFile() || after.nlink !== 1 ||
|
|
425
|
+
after.dev !== opened.dev || after.ino !== opened.ino) {
|
|
426
|
+
throw new Error("approval record changed while it was read: " + path);
|
|
427
|
+
}
|
|
428
|
+
return text;
|
|
429
|
+
} finally {
|
|
430
|
+
if (fd !== null) try { closeSync(fd); } catch { /* ignore */ }
|
|
431
|
+
}
|
|
432
|
+
}
|
|
433
|
+
|
|
434
|
+
function approvalExists(file, gate) {
|
|
435
|
+
const store = validatedApprovalDir();
|
|
436
|
+
if (!store) return false;
|
|
437
|
+
const path = approvalPath(file, gate, store.path);
|
|
438
|
+
let text;
|
|
439
|
+
try { text = readApprovalFile(path); }
|
|
440
|
+
catch (error) {
|
|
441
|
+
if (error.code === "ENOENT") return false;
|
|
442
|
+
throw error;
|
|
443
|
+
}
|
|
444
|
+
let value;
|
|
445
|
+
try { value = JSON.parse(text); }
|
|
446
|
+
catch { return false; }
|
|
447
|
+
assertApprovalDirUnchanged(store);
|
|
448
|
+
return value && value.file === resolve(file) && value.gate === gate.id && value.signature === signature(file, gate);
|
|
449
|
+
}
|
|
450
|
+
|
|
451
|
+
async function recordApproval(file, gate) {
|
|
452
|
+
const store = validatedApprovalDir({ create: true });
|
|
453
|
+
const token = approvalPath(file, gate, store.path);
|
|
454
|
+
const lock = token + ".lock";
|
|
455
|
+
const deadline = Date.now() + 10000;
|
|
456
|
+
const owner = randomBytes(16).toString("hex");
|
|
457
|
+
let fd = null;
|
|
458
|
+
for (;;) {
|
|
459
|
+
try { fd = openSync(lock, "wx", 0o600); break; }
|
|
460
|
+
catch (error) {
|
|
461
|
+
if (error.code !== "EEXIST") throw error;
|
|
462
|
+
// Fail closed instead of trying to steal by path: an owner can release
|
|
463
|
+
// and a successor can acquire between stat and unlink.
|
|
464
|
+
try { statSync(lock); } catch (statError) {
|
|
465
|
+
if (statError.code === "ENOENT") continue;
|
|
466
|
+
throw statError;
|
|
467
|
+
}
|
|
468
|
+
if (Date.now() >= deadline) throw new Error("timed out waiting for approval lock");
|
|
469
|
+
await sleep(20);
|
|
470
|
+
}
|
|
471
|
+
}
|
|
472
|
+
try {
|
|
473
|
+
writeFileSync(fd, JSON.stringify({ owner, pid: process.pid, at: Date.now() }));
|
|
474
|
+
const value = {
|
|
475
|
+
schema: 1, file: resolve(file), gate: gate.id, signature: signature(file, gate),
|
|
476
|
+
oracle: oracle(file, gate), approvedAt: new Date().toISOString(),
|
|
477
|
+
};
|
|
478
|
+
writeAtomic(token, JSON.stringify(value, null, 2) + "\n");
|
|
479
|
+
assertApprovalDirUnchanged(store);
|
|
480
|
+
} finally {
|
|
481
|
+
try { closeSync(fd); } catch { /* ignore */ }
|
|
482
|
+
try {
|
|
483
|
+
const current = JSON.parse(readFileSync(lock, "utf8"));
|
|
484
|
+
if (current.owner === owner) unlinkSync(lock);
|
|
485
|
+
} catch { /* manual cleanup or a successor owns the lock */ }
|
|
486
|
+
}
|
|
487
|
+
}
|
|
488
|
+
|
|
489
|
+
function printOracle(file, gate, prefix) {
|
|
490
|
+
const value = oracle(file, gate);
|
|
491
|
+
console.log(prefix + " " + qualify(file, gate.id));
|
|
492
|
+
console.log(" CHECK: " + value.check);
|
|
493
|
+
console.log(" EXPECT: " + value.expect);
|
|
494
|
+
console.log(" CWD: " + value.cwd);
|
|
495
|
+
console.log(" SHELL: " + value.shell);
|
|
496
|
+
console.log(" PATH: " + pathTranscript);
|
|
497
|
+
}
|
|
498
|
+
|
|
499
|
+
let activeRegexWorkers = 0;
|
|
500
|
+
const regexWaiters = [];
|
|
501
|
+
|
|
502
|
+
function acquireRegexWorker() {
|
|
503
|
+
if (activeRegexWorkers < MAX_REGEX_WORKERS) {
|
|
504
|
+
activeRegexWorkers++;
|
|
505
|
+
return Promise.resolve();
|
|
506
|
+
}
|
|
507
|
+
return new Promise((done) => regexWaiters.push(done));
|
|
508
|
+
}
|
|
509
|
+
|
|
510
|
+
function releaseRegexWorker() {
|
|
511
|
+
const next = regexWaiters.shift();
|
|
512
|
+
if (next) next();
|
|
513
|
+
else activeRegexWorkers--;
|
|
514
|
+
}
|
|
515
|
+
|
|
516
|
+
async function safeRegexMatch(expectation, output) {
|
|
517
|
+
if (expectation.kind === "text") return { matched: output.includes(expectation.value) };
|
|
518
|
+
await acquireRegexWorker();
|
|
519
|
+
try {
|
|
520
|
+
return await new Promise((done) => {
|
|
521
|
+
let worker;
|
|
522
|
+
let settled = false;
|
|
523
|
+
let startupTimer = null;
|
|
524
|
+
let matchTimer = null;
|
|
525
|
+
const finish = (value) => {
|
|
526
|
+
if (settled) return;
|
|
527
|
+
settled = true;
|
|
528
|
+
if (startupTimer) clearTimeout(startupTimer);
|
|
529
|
+
if (matchTimer) clearTimeout(matchTimer);
|
|
530
|
+
if (worker) worker.terminate().catch(() => {});
|
|
531
|
+
done(value);
|
|
532
|
+
};
|
|
533
|
+
try { worker = new Worker(new URL("./lib/regex-worker.mjs", import.meta.url)); }
|
|
534
|
+
catch (error) {
|
|
535
|
+
finish({ matched: false, error: "EXPECT worker could not start: " + error.message });
|
|
536
|
+
return;
|
|
537
|
+
}
|
|
538
|
+
startupTimer = setTimeout(() => finish({
|
|
539
|
+
matched: false,
|
|
540
|
+
error: "EXPECT worker startup exceeded " + REGEX_STARTUP_TIMEOUT_MS + "ms",
|
|
541
|
+
}), REGEX_STARTUP_TIMEOUT_MS);
|
|
542
|
+
worker.once("online", () => {
|
|
543
|
+
if (settled) return;
|
|
544
|
+
clearTimeout(startupTimer);
|
|
545
|
+
startupTimer = null;
|
|
546
|
+
// The catastrophic-backtracking budget starts only after the worker is
|
|
547
|
+
// online; process startup and a busy --jobs queue are not regex time.
|
|
548
|
+
matchTimer = setTimeout(() => finish({
|
|
549
|
+
matched: false,
|
|
550
|
+
error: "EXPECT regex exceeded " + REGEX_TIMEOUT_MS + "ms",
|
|
551
|
+
}), REGEX_TIMEOUT_MS);
|
|
552
|
+
try { worker.postMessage({ source: expectation.source, flags: expectation.flags, output }); }
|
|
553
|
+
catch (error) { finish({ matched: false, error: error.message }); }
|
|
554
|
+
});
|
|
555
|
+
worker.once("message", (message) => finish(message));
|
|
556
|
+
worker.once("error", (error) => finish({ matched: false, error: error.message }));
|
|
557
|
+
worker.once("exit", (code) => {
|
|
558
|
+
finish({ matched: false, error: "EXPECT worker exited " + code + " without a result" });
|
|
559
|
+
});
|
|
560
|
+
});
|
|
561
|
+
} finally {
|
|
562
|
+
releaseRegexWorker();
|
|
563
|
+
}
|
|
564
|
+
}
|
|
565
|
+
|
|
566
|
+
function runCheck(task) {
|
|
567
|
+
return new Promise((done) => {
|
|
568
|
+
const chunks = { stdout: [], stderr: [] };
|
|
569
|
+
let bytes = 0;
|
|
570
|
+
let overflow = false;
|
|
571
|
+
let timedOut = false;
|
|
572
|
+
let spawnError = null;
|
|
573
|
+
let closed = false;
|
|
574
|
+
let closeStreamsTimer = null;
|
|
575
|
+
let forceSettleTimer = null;
|
|
576
|
+
let timeoutTimer = null;
|
|
577
|
+
let cleanupDiagnostic = null;
|
|
578
|
+
let child;
|
|
579
|
+
|
|
580
|
+
const settle = async (exitCode, signal) => {
|
|
581
|
+
if (closed) return;
|
|
582
|
+
closed = true;
|
|
583
|
+
if (timeoutTimer) clearTimeout(timeoutTimer);
|
|
584
|
+
if (closeStreamsTimer) clearTimeout(closeStreamsTimer);
|
|
585
|
+
if (forceSettleTimer) clearTimeout(forceSettleTimer);
|
|
586
|
+
const stdout = Buffer.concat(chunks.stdout).toString("utf8");
|
|
587
|
+
const stderr = Buffer.concat(chunks.stderr).toString("utf8");
|
|
588
|
+
const output = stdout + (stdout && stderr ? "\n" : "") + stderr;
|
|
589
|
+
const match = timedOut || overflow || spawnError
|
|
590
|
+
? { matched: false }
|
|
591
|
+
: await safeRegexMatch(task.gate.expectation, output);
|
|
592
|
+
const cleanupSuffix = cleanupDiagnostic ? "; cleanup: " + cleanupDiagnostic : "";
|
|
593
|
+
const error = timedOut ? "timed out after " + timeoutSeconds + "s" + cleanupSuffix
|
|
594
|
+
: overflow ? "output exceeded " + MAX_OUTPUT_BYTES + " bytes" + cleanupSuffix
|
|
595
|
+
: spawnError ? spawnError.message
|
|
596
|
+
: match.error || null;
|
|
597
|
+
done({
|
|
598
|
+
...task, output, exitCode, signal, matched: Boolean(match.matched), error,
|
|
599
|
+
ok: !error && exitCode === 0 && Boolean(match.matched),
|
|
600
|
+
});
|
|
601
|
+
};
|
|
602
|
+
|
|
603
|
+
const stopChild = () => {
|
|
604
|
+
if (closeStreamsTimer) return;
|
|
605
|
+
const cleanup = terminateProcessTree(child);
|
|
606
|
+
cleanupDiagnostic = cleanup.diagnostic;
|
|
607
|
+
// A descendant that escaped the shell can otherwise keep inherited pipes
|
|
608
|
+
// open forever. We still settle through the child's close event, after
|
|
609
|
+
// giving stdio a short grace period to drain.
|
|
610
|
+
closeStreamsTimer = setTimeout(() => {
|
|
611
|
+
try { child.stdout.destroy(); } catch { /* closed */ }
|
|
612
|
+
try { child.stderr.destroy(); } catch { /* closed */ }
|
|
613
|
+
}, 1000);
|
|
614
|
+
// A successful signal request is not proof that a child closed or that
|
|
615
|
+
// every pipe-holding descendant exited. Settle independently after the
|
|
616
|
+
// bounded helper attempt for every cleanup outcome, while retaining any
|
|
617
|
+
// explicit cleanup failure in the result.
|
|
618
|
+
forceSettleTimer = setTimeout(() => {
|
|
619
|
+
try { child.stdout.destroy(); } catch { /* closed */ }
|
|
620
|
+
try { child.stderr.destroy(); } catch { /* closed */ }
|
|
621
|
+
try { child.unref(); } catch { /* unavailable */ }
|
|
622
|
+
settle(null, null);
|
|
623
|
+
}, 1500);
|
|
624
|
+
};
|
|
625
|
+
|
|
626
|
+
const capture = (stream, chunk) => {
|
|
627
|
+
const buffer = Buffer.isBuffer(chunk) ? chunk : Buffer.from(chunk);
|
|
628
|
+
const remaining = MAX_OUTPUT_BYTES - bytes;
|
|
629
|
+
if (remaining > 0) chunks[stream].push(buffer.subarray(0, remaining));
|
|
630
|
+
bytes += buffer.length;
|
|
631
|
+
if (bytes > MAX_OUTPUT_BYTES && !overflow) {
|
|
632
|
+
overflow = true;
|
|
633
|
+
stopChild();
|
|
634
|
+
}
|
|
635
|
+
};
|
|
636
|
+
|
|
637
|
+
try {
|
|
638
|
+
child = spawn(process.execPath, [CHECK_SUPERVISOR, shell, task.gate.check], {
|
|
639
|
+
cwd: task.cwd,
|
|
640
|
+
shell: false,
|
|
641
|
+
windowsHide: true,
|
|
642
|
+
detached: process.platform !== "win32",
|
|
643
|
+
env: process.env,
|
|
644
|
+
stdio: ["ignore", "pipe", "pipe"],
|
|
645
|
+
});
|
|
646
|
+
} catch (error) {
|
|
647
|
+
done({ ...task, ok: false, output: "", exitCode: null, signal: null, matched: false, error: error.message });
|
|
648
|
+
return;
|
|
649
|
+
}
|
|
650
|
+
child.stdout.on("data", (chunk) => capture("stdout", chunk));
|
|
651
|
+
child.stderr.on("data", (chunk) => capture("stderr", chunk));
|
|
652
|
+
child.once("error", (error) => { spawnError = error; });
|
|
653
|
+
timeoutTimer = setTimeout(() => {
|
|
654
|
+
timedOut = true;
|
|
655
|
+
stopChild();
|
|
656
|
+
}, timeoutSeconds * 1000);
|
|
657
|
+
child.once("close", settle);
|
|
658
|
+
});
|
|
659
|
+
}
|
|
660
|
+
|
|
661
|
+
async function runRolling(tasks, limit) {
|
|
662
|
+
const results = new Array(tasks.length);
|
|
663
|
+
let next = 0;
|
|
664
|
+
async function worker() {
|
|
665
|
+
for (;;) {
|
|
666
|
+
const index = next++;
|
|
667
|
+
if (index >= tasks.length) return;
|
|
668
|
+
results[index] = await runCheck(tasks[index]);
|
|
669
|
+
}
|
|
670
|
+
}
|
|
671
|
+
const workers = [];
|
|
672
|
+
for (let index = 0; index < Math.min(limit, tasks.length); index++) workers.push(worker());
|
|
673
|
+
await Promise.all(workers);
|
|
674
|
+
return results;
|
|
675
|
+
}
|
|
676
|
+
|
|
677
|
+
const pending = [];
|
|
678
|
+
for (const ledger of ledgers) {
|
|
679
|
+
for (const gate of ledger.doc.gates) {
|
|
680
|
+
if (ledger.doc.abandoned.has(gate.id) || !gate.check) continue;
|
|
681
|
+
const state = gateState(gate, ledger.doc.abandoned);
|
|
682
|
+
if (opt.status || (!opt.reverify && state === "met")) continue;
|
|
683
|
+
const cwd = resolvedGateCwd(gate, ledger.file);
|
|
684
|
+
try {
|
|
685
|
+
if (!statSync(cwd).isDirectory()) failUsage("gate " + qualify(ledger.file, gate.id) + " CWD is not a directory: " + cwd);
|
|
686
|
+
} catch (error) {
|
|
687
|
+
if (error.code === "ENOENT") failUsage("gate " + qualify(ledger.file, gate.id) + " CWD does not exist: " + cwd);
|
|
688
|
+
failUsage("cannot inspect gate CWD " + cwd + ": " + error.message);
|
|
689
|
+
}
|
|
690
|
+
pending.push({ file: ledger.file, gate, cwd, wasMet: state === "met", signature: signature(ledger.file, gate) });
|
|
691
|
+
}
|
|
692
|
+
}
|
|
693
|
+
|
|
694
|
+
const runnable = [];
|
|
695
|
+
const notRun = [];
|
|
696
|
+
let approvalInfrastructureFailures = 0;
|
|
697
|
+
for (const task of pending) {
|
|
698
|
+
let approved = false;
|
|
699
|
+
try { approved = approvalExists(task.file, task.gate); }
|
|
700
|
+
catch (error) {
|
|
701
|
+
console.error("gate-check: could not validate approval for " + qualify(task.file, task.gate.id) + ": " + error.message);
|
|
702
|
+
approvalInfrastructureFailures++;
|
|
703
|
+
notRun.push(task);
|
|
704
|
+
continue;
|
|
705
|
+
}
|
|
706
|
+
if (!approved) {
|
|
707
|
+
printOracle(task.file, task.gate, "APPROVAL REQUIRED");
|
|
708
|
+
if (!opt.approve) {
|
|
709
|
+
console.log(" NOT RUN: inspect this oracle, then re-run with --approve");
|
|
710
|
+
notRun.push(task);
|
|
711
|
+
continue;
|
|
712
|
+
}
|
|
713
|
+
try {
|
|
714
|
+
await recordApproval(task.file, task.gate);
|
|
715
|
+
console.log(" APPROVED: " + approvalPath(task.file, task.gate, validatedApprovalDir().path));
|
|
716
|
+
} catch (error) {
|
|
717
|
+
console.error("gate-check: could not record approval for " + qualify(task.file, task.gate.id) + ": " + error.message);
|
|
718
|
+
approvalInfrastructureFailures++;
|
|
719
|
+
notRun.push(task);
|
|
720
|
+
continue;
|
|
721
|
+
}
|
|
722
|
+
}
|
|
723
|
+
runnable.push(task);
|
|
724
|
+
}
|
|
725
|
+
|
|
726
|
+
for (const task of runnable) {
|
|
727
|
+
console.log(" RUN " + qualify(task.file, task.gate.id) + " shell=" + shell + " cwd=" + task.cwd + " PATH=" + pathTranscript);
|
|
728
|
+
}
|
|
729
|
+
const results = opt.status ? [] : await runRolling(runnable, jobs);
|
|
730
|
+
const outputFingerprint = (output) => ({
|
|
731
|
+
sha256: sha256(String(output)),
|
|
732
|
+
bytes: Buffer.byteLength(String(output), "utf8"),
|
|
733
|
+
});
|
|
734
|
+
for (const result of results) {
|
|
735
|
+
const fingerprint = outputFingerprint(result.output);
|
|
736
|
+
const outputSummary = result.ok
|
|
737
|
+
? "sha256=" + fingerprint.sha256 + "; bytes=" + fingerprint.bytes
|
|
738
|
+
: failureOutput(result.output);
|
|
739
|
+
const outcome = "exit=" + (result.exitCode === null ? "none" : result.exitCode) +
|
|
740
|
+
(result.signal ? " signal=" + result.signal : "") +
|
|
741
|
+
"; EXPECT=" + (result.matched ? "matched" : "not matched") +
|
|
742
|
+
"; output=" + outputSummary;
|
|
743
|
+
if (result.ok) {
|
|
744
|
+
console.log(" PASS " + qualify(result.file, result.gate.id) + ": " + result.gate.title);
|
|
745
|
+
console.log(" " + outcome);
|
|
746
|
+
} else {
|
|
747
|
+
console.log(" FAIL " + qualify(result.file, result.gate.id) + ": " + result.gate.title);
|
|
748
|
+
console.log(" " + (result.error ? result.error + "; " : "") + outcome);
|
|
749
|
+
}
|
|
750
|
+
}
|
|
751
|
+
|
|
752
|
+
function failureOutput(output, max = 480) {
|
|
753
|
+
const lines = String(output).split(/\r?\n/).map((line) => line.trim()).filter(Boolean);
|
|
754
|
+
if (lines.length <= 8) return (lines.join(" | ") || "(no output)").slice(0, max);
|
|
755
|
+
const summary = [...lines.slice(0, 6), "...", ...lines.slice(-2)].join(" | ");
|
|
756
|
+
return summary.slice(0, max);
|
|
757
|
+
}
|
|
758
|
+
|
|
759
|
+
function evidenceFor(result) {
|
|
760
|
+
const clean = (value) => terminalSafe(value).replace(/[\r\n\t]+/g, " ");
|
|
761
|
+
const fingerprint = outputFingerprint(result.output);
|
|
762
|
+
return ("exit=0; shell=" + clean(shell) + "; cwd=" + clean(result.cwd) +
|
|
763
|
+
"; path=" + pathEvidence + "; EXPECT=matched; output-sha256=" + fingerprint.sha256 +
|
|
764
|
+
"; output-bytes=" + fingerprint.bytes).slice(0, 900);
|
|
765
|
+
}
|
|
766
|
+
|
|
767
|
+
function insertOrUpdateEvidence(doc, gate, value) {
|
|
768
|
+
if (gate.evidenceLine !== -1) {
|
|
769
|
+
const indent = (doc.lines[gate.evidenceLine].match(/^\s*/) || [" "])[0];
|
|
770
|
+
doc.lines[gate.evidenceLine] = indent + "EVIDENCE: " + value;
|
|
771
|
+
return;
|
|
772
|
+
}
|
|
773
|
+
let line = gate.line + 1;
|
|
774
|
+
while (line < doc.lines.length && /^\s+(CHECK|EXPECT|EVIDENCE|CWD):/.test(doc.lines[line])) line++;
|
|
775
|
+
doc.lines.splice(line, 0, " EVIDENCE: " + value);
|
|
776
|
+
}
|
|
777
|
+
|
|
778
|
+
const resultKey = (file, id) => resolve(file) + "\0" + id;
|
|
779
|
+
const staleResults = new Map();
|
|
780
|
+
for (const result of results) {
|
|
781
|
+
if (!result.ok && !(opt.reverify && result.wasMet)) continue;
|
|
782
|
+
try {
|
|
783
|
+
await withFileLock(root, result.file, () => {
|
|
784
|
+
let doc = parseGates(readFileSync(result.file, "utf8"));
|
|
785
|
+
if (doc.errors.length) throw new Error("fresh ledger became invalid: " + doc.errors.join("; "));
|
|
786
|
+
const fresh = doc.gates.find((gate) => gate.id === result.gate.id);
|
|
787
|
+
if (!fresh || signature(result.file, fresh) !== result.signature) {
|
|
788
|
+
staleResults.set(resultKey(result.file, result.gate.id), qualify(result.file, result.gate.id));
|
|
789
|
+
console.log(" STALE " + qualify(result.file, result.gate.id) + ": CHECK/EXPECT/CWD/shell signature changed; result not written");
|
|
790
|
+
return;
|
|
791
|
+
}
|
|
792
|
+
if (result.ok) {
|
|
793
|
+
doc.lines[fresh.line] = doc.lines[fresh.line].replace(/^- \[( |x|X)\]/, "- [x]");
|
|
794
|
+
insertOrUpdateEvidence(doc, fresh, evidenceFor(result));
|
|
795
|
+
} else {
|
|
796
|
+
doc.lines[fresh.line] = doc.lines[fresh.line].replace(/^- \[(x|X)\]/, "- [ ]");
|
|
797
|
+
insertOrUpdateEvidence(doc, fresh, "pending");
|
|
798
|
+
}
|
|
799
|
+
writeAtomic(result.file, formatDocument(doc));
|
|
800
|
+
});
|
|
801
|
+
} catch (error) {
|
|
802
|
+
console.error("gate-check: cannot update " + result.file + ": " + error.message);
|
|
803
|
+
process.exitCode = 2;
|
|
804
|
+
}
|
|
805
|
+
}
|
|
806
|
+
if (process.exitCode === 2) process.exit(2);
|
|
807
|
+
|
|
808
|
+
ledgers = target.files.map(loadLedger);
|
|
809
|
+
let totalMet = 0;
|
|
810
|
+
let totalUnmet = 0;
|
|
811
|
+
let totalAbandoned = 0;
|
|
812
|
+
let reverified = 0;
|
|
813
|
+
const unmetIds = [];
|
|
814
|
+
const abandonedIds = [];
|
|
815
|
+
const finalStates = new Map();
|
|
816
|
+
for (const result of results) {
|
|
817
|
+
if (opt.reverify && result.wasMet && !staleResults.has(resultKey(result.file, result.gate.id))) reverified++;
|
|
818
|
+
}
|
|
819
|
+
|
|
820
|
+
for (const ledger of ledgers) {
|
|
821
|
+
for (const gate of ledger.doc.gates) {
|
|
822
|
+
const state = gateState(gate, ledger.doc.abandoned);
|
|
823
|
+
finalStates.set(resultKey(ledger.file, gate.id), state);
|
|
824
|
+
if (state === "abandoned") {
|
|
825
|
+
totalAbandoned++;
|
|
826
|
+
abandonedIds.push(qualify(ledger.file, gate.id));
|
|
827
|
+
}
|
|
828
|
+
else if (state === "met") totalMet++;
|
|
829
|
+
else {
|
|
830
|
+
totalUnmet++;
|
|
831
|
+
unmetIds.push(qualify(ledger.file, gate.id));
|
|
832
|
+
if (opt.status) {
|
|
833
|
+
console.log(" UNMET " + qualify(ledger.file, gate.id) + " (" +
|
|
834
|
+
(state === "unmet" ? "unchecked" : "checked but EVIDENCE pending") + "): " + gate.title);
|
|
835
|
+
}
|
|
836
|
+
}
|
|
837
|
+
}
|
|
838
|
+
console.log(basename(ledger.file) + ": " + ledger.doc.gates.length + " gates");
|
|
839
|
+
}
|
|
840
|
+
|
|
841
|
+
// A scoped pipeline is complete only when both its ledgers and its native
|
|
842
|
+
// dispatch waves are resolved. Per-wave `dispatch-check status` is useful for
|
|
843
|
+
// inspection, but completion cannot depend on callers remembering a second
|
|
844
|
+
// command (or on the optional Stop hook being installed).
|
|
845
|
+
const aggregateDispatch = dispatchStatus(root, scope);
|
|
846
|
+
if (aggregateDispatch.errors.length) {
|
|
847
|
+
for (const error of aggregateDispatch.errors) console.error("gate-check: " + error);
|
|
848
|
+
process.exit(2);
|
|
849
|
+
}
|
|
850
|
+
totalAbandoned += aggregateDispatch.abandoned.length;
|
|
851
|
+
abandonedIds.push(...aggregateDispatch.abandoned);
|
|
852
|
+
if (opt.status) {
|
|
853
|
+
for (const blocker of aggregateDispatch.blocking) console.log(" UNMET " + blocker);
|
|
854
|
+
}
|
|
855
|
+
|
|
856
|
+
const where = scope ? " [scope " + scope + "]" : "";
|
|
857
|
+
const verifyNote = opt.reverify
|
|
858
|
+
? ", reran: " + results.length + ", previously met reverified: " + reverified
|
|
859
|
+
: "";
|
|
860
|
+
const unverifiedMet = opt.reverify ? notRun.filter((task) => task.wasMet) : [];
|
|
861
|
+
const extraUnmet = new Map();
|
|
862
|
+
for (const task of unverifiedMet) {
|
|
863
|
+
const key = resultKey(task.file, task.gate.id);
|
|
864
|
+
const state = finalStates.get(key);
|
|
865
|
+
if (state === "met" || state === undefined) extraUnmet.set(key, qualify(task.file, task.gate.id) + " (reverify not run)");
|
|
866
|
+
}
|
|
867
|
+
for (const [key, label] of staleResults) {
|
|
868
|
+
const state = finalStates.get(key);
|
|
869
|
+
if (state === "met" || state === undefined) extraUnmet.set(key, label + " (stale result discarded)");
|
|
870
|
+
}
|
|
871
|
+
const effectiveUnmet = totalUnmet + extraUnmet.size + aggregateDispatch.blocking.length;
|
|
872
|
+
unmetIds.push(...extraUnmet.values());
|
|
873
|
+
unmetIds.push(...aggregateDispatch.blocking);
|
|
874
|
+
if (approvalInfrastructureFailures) {
|
|
875
|
+
console.error("gate-check: infrastructure failure prevented " + approvalInfrastructureFailures + " approval(s)");
|
|
876
|
+
process.exit(2);
|
|
877
|
+
}
|
|
878
|
+
if (effectiveUnmet === 0 && totalAbandoned === 0) {
|
|
879
|
+
console.log("ALL MET (" + totalMet + " met" + verifyNote + ")" + where);
|
|
880
|
+
process.exit(0);
|
|
881
|
+
}
|
|
882
|
+
if (totalAbandoned) {
|
|
883
|
+
console.log("HANDOFF REQUIRED: " + totalAbandoned + " abandoned (met: " +
|
|
884
|
+
Math.max(0, totalMet - extraUnmet.size) + (effectiveUnmet ? ", unmet: " + effectiveUnmet : "") +
|
|
885
|
+
verifyNote + ")" + where);
|
|
886
|
+
console.log(" " + abandonedIds.slice(0, 12).join(", ") +
|
|
887
|
+
(abandonedIds.length > 12 ? ", +" + (abandonedIds.length - 12) + " more" : ""));
|
|
888
|
+
}
|
|
889
|
+
if (effectiveUnmet) {
|
|
890
|
+
console.log("UNMET: " + effectiveUnmet + " (met: " + Math.max(0, totalMet - extraUnmet.size) +
|
|
891
|
+
(totalAbandoned ? ", abandoned: " + totalAbandoned : "") + verifyNote + ")" + where);
|
|
892
|
+
console.log(" " + unmetIds.slice(0, 12).join(", ") + (unmetIds.length > 12 ? ", +" + (unmetIds.length - 12) + " more" : ""));
|
|
893
|
+
}
|
|
894
|
+
process.exit(1);
|