@selesai/code 0.9.11 → 0.9.13
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +17 -0
- package/dist/config.d.ts +4 -6
- package/dist/config.js +10 -14
- package/dist/core/agent-session.d.ts +0 -1
- package/dist/core/agent-session.js +3 -49
- package/dist/core/extensions/types.d.ts +0 -2
- package/dist/core/settings-manager.d.ts +0 -2
- package/dist/core/settings-manager.js +0 -3
- package/dist/core/tools/index.d.ts +0 -1
- package/dist/core/tools/index.js +0 -1
- package/dist/defaults/settings.json +2 -3
- package/dist/extensions/model-prompt-injector/index.test.ts +0 -10
- package/dist/extensions/model-prompt-injector/index.ts +0 -3
- package/dist/extensions/pi-intercom/CHANGELOG.md +53 -16
- package/dist/extensions/pi-intercom/README.md +41 -8
- package/dist/extensions/pi-intercom/banner.png +0 -0
- package/dist/extensions/pi-intercom/broker/broker.ts +498 -215
- package/dist/extensions/pi-intercom/broker/client.ts +39 -12
- package/dist/extensions/pi-intercom/broker/extension.test.ts +102 -3
- package/dist/extensions/pi-intercom/broker/paths.test.ts +2 -2
- package/dist/extensions/pi-intercom/broker/protocol.ts +26 -0
- package/dist/extensions/pi-intercom/broker/spawn.test.ts +5 -20
- package/dist/extensions/pi-intercom/config.test.ts +41 -0
- package/dist/extensions/pi-intercom/config.ts +21 -0
- package/dist/extensions/pi-intercom/extension-api.ts +40 -0
- package/dist/extensions/pi-intercom/index.ts +362 -26
- package/dist/extensions/pi-intercom/intercom.integration.test.ts +819 -13
- package/dist/extensions/pi-intercom/package.json +1 -1
- package/dist/extensions/pi-intercom/project-agent.ts +2 -2
- package/dist/extensions/pi-intercom/skills/pi-intercom/SKILL.md +8 -110
- package/dist/extensions/pi-intercom/types.ts +32 -5
- package/dist/extensions/pi-intercom/ui/inline-message.ts +6 -0
- package/dist/extensions/pi-subagents/.github/assets/subagent-fleet-inspector.png +0 -0
- package/dist/extensions/pi-subagents/.github/workflows/release.yml +28 -0
- package/dist/extensions/pi-subagents/.github/workflows/test.yml +51 -0
- package/dist/extensions/pi-subagents/.greptile/config.json +33 -0
- package/dist/extensions/pi-subagents/.greptile/files.json +8 -0
- package/dist/extensions/pi-subagents/.greptile/rules.md +16 -0
- package/dist/extensions/pi-subagents/CHANGELOG.md +309 -87
- package/dist/extensions/pi-subagents/README.md +15 -17
- package/dist/extensions/pi-subagents/agents/oracle.md +3 -1
- package/dist/extensions/pi-subagents/agents/researcher.md +32 -13
- package/dist/extensions/pi-subagents/agents/reviewer.md +13 -2
- package/dist/extensions/pi-subagents/agents/scout.md +2 -2
- package/dist/extensions/pi-subagents/agents/worker.md +2 -1
- package/dist/extensions/pi-subagents/async-retention-discovery-worker.mjs +180 -0
- package/dist/extensions/pi-subagents/docs/configuration.md +106 -27
- package/dist/extensions/pi-subagents/docs/extension-api.md +85 -21
- package/dist/extensions/pi-subagents/docs/missions.md +41 -4
- package/dist/extensions/pi-subagents/docs/models.md +52 -9
- package/dist/extensions/pi-subagents/docs/observability.md +103 -16
- package/dist/extensions/pi-subagents/docs/tool-reference.md +60 -45
- package/dist/extensions/pi-subagents/docs/watchdog.md +60 -3
- package/dist/extensions/pi-subagents/docs/workflows.md +181 -7
- package/dist/extensions/pi-subagents/index.ts +10 -1
- package/dist/extensions/pi-subagents/install.mjs +4 -4
- package/dist/extensions/pi-subagents/package-lock.json +1483 -1470
- package/dist/extensions/pi-subagents/package.json +6 -3
- package/dist/extensions/pi-subagents/prompts/council.md +60 -0
- package/dist/extensions/pi-subagents/prompts/parallel-review.md +5 -1
- package/dist/extensions/pi-subagents/prompts/review-loop.md +9 -5
- package/dist/extensions/pi-subagents/skills/council-mode/SKILL.md +254 -0
- package/dist/extensions/pi-subagents/skills/pi-subagents/SKILL.md +18 -17
- package/dist/extensions/pi-subagents/skills/pi-subagents/references/constraints-and-recipes.md +31 -9
- package/dist/extensions/pi-subagents/skills/pi-subagents/references/execution-controls.md +107 -140
- package/dist/extensions/pi-subagents/skills/pi-subagents/references/management-authoring-rpc.md +9 -12
- package/dist/extensions/pi-subagents/skills/pi-subagents/references/multi-lane-orchestration.md +39 -0
- package/dist/extensions/pi-subagents/skills/pi-subagents/references/prompting-and-roles.md +44 -92
- package/dist/extensions/pi-subagents/src/agents/agent-management.ts +261 -368
- package/dist/extensions/pi-subagents/src/agents/agent-serializer.ts +6 -2
- package/dist/extensions/pi-subagents/src/agents/agents.ts +388 -85
- package/dist/extensions/pi-subagents/src/agents/builtin-names.ts +14 -0
- package/dist/extensions/pi-subagents/src/agents/runtime-agent-registry.ts +418 -0
- package/dist/extensions/pi-subagents/src/agents/skills.ts +1 -1
- package/dist/extensions/pi-subagents/src/api/agents.ts +7 -0
- package/dist/extensions/pi-subagents/src/api/external-job-provider.ts +195 -0
- package/dist/extensions/pi-subagents/src/api/preflight.ts +88 -27
- package/dist/extensions/pi-subagents/src/api/project-panes.ts +2 -0
- package/dist/extensions/pi-subagents/src/api/shared-types.ts +2 -0
- package/dist/extensions/pi-subagents/src/extension/config.ts +20 -11
- package/dist/extensions/pi-subagents/src/extension/doctor.ts +14 -6
- package/dist/extensions/pi-subagents/src/extension/fanout-child.ts +5 -4
- package/dist/extensions/pi-subagents/src/extension/index.ts +270 -187
- package/dist/extensions/pi-subagents/src/extension/public-execution.ts +65 -28
- package/dist/extensions/pi-subagents/src/extension/rpc.ts +120 -11
- package/dist/extensions/pi-subagents/src/extension/schemas.ts +46 -64
- package/dist/extensions/pi-subagents/src/extension/tool-description.ts +51 -37
- package/dist/extensions/pi-subagents/src/extension/tool-result.ts +19 -0
- package/dist/extensions/pi-subagents/src/inspectors/herdr/actions.ts +2 -2
- package/dist/extensions/pi-subagents/src/inspectors/herdr/client.ts +3 -3
- package/dist/extensions/pi-subagents/src/inspectors/herdr/focus.ts +55 -0
- package/dist/extensions/pi-subagents/src/inspectors/herdr/inspector-runner.ts +2 -1
- package/dist/extensions/pi-subagents/src/inspectors/herdr/project-panes.ts +230 -46
- package/dist/extensions/pi-subagents/src/integrations/herdr-status.ts +26 -4
- package/dist/extensions/pi-subagents/src/intercom/native-supervisor-channel.ts +32 -10
- package/dist/extensions/pi-subagents/src/missions/lifecycle.ts +6 -1
- package/dist/extensions/pi-subagents/src/missions/store.ts +4 -9
- package/dist/extensions/pi-subagents/src/missions/workflow-state.ts +2 -2
- package/dist/extensions/pi-subagents/src/policy/authority.ts +2 -0
- package/dist/extensions/pi-subagents/src/profiles/profiles.ts +3 -1
- package/dist/extensions/pi-subagents/src/runs/background/active-run-index.ts +31 -8
- package/dist/extensions/pi-subagents/src/runs/background/async-execution.ts +210 -52
- package/dist/extensions/pi-subagents/src/runs/background/async-job-tracker.ts +63 -33
- package/dist/extensions/pi-subagents/src/runs/background/async-resume.ts +71 -17
- package/dist/extensions/pi-subagents/src/runs/background/async-retention.ts +886 -0
- package/dist/extensions/pi-subagents/src/runs/background/async-status-snapshot.ts +14 -5
- package/dist/extensions/pi-subagents/src/runs/background/async-status.ts +49 -56
- package/dist/extensions/pi-subagents/src/runs/background/auto-drain.ts +1 -0
- package/dist/extensions/pi-subagents/src/runs/background/chain-append.ts +3 -33
- package/dist/extensions/pi-subagents/src/runs/background/chain-root-attachment.ts +5 -0
- package/dist/extensions/pi-subagents/src/runs/background/completion-dedupe.ts +5 -1
- package/dist/extensions/pi-subagents/src/runs/background/completion-replay.ts +22 -12
- package/dist/extensions/pi-subagents/src/runs/background/control-channel.ts +105 -71
- package/dist/extensions/pi-subagents/src/runs/background/fleet-view.ts +68 -19
- package/dist/extensions/pi-subagents/src/runs/background/index-segment.ts +59 -0
- package/dist/extensions/pi-subagents/src/runs/background/inspect-rpc.ts +443 -0
- package/dist/extensions/pi-subagents/src/runs/background/notify.ts +94 -10
- package/dist/extensions/pi-subagents/src/runs/background/result-files.ts +158 -90
- package/dist/extensions/pi-subagents/src/runs/background/result-watcher.ts +141 -53
- package/dist/extensions/pi-subagents/src/runs/background/resume-guidance.ts +8 -5
- package/dist/extensions/pi-subagents/src/runs/background/retained-children.ts +14 -4
- package/dist/extensions/pi-subagents/src/runs/background/run-id-query.ts +7 -0
- package/dist/extensions/pi-subagents/src/runs/background/run-id-resolver.ts +13 -14
- package/dist/extensions/pi-subagents/src/runs/background/run-status.ts +46 -25
- package/dist/extensions/pi-subagents/src/runs/background/scheduled-runs.ts +823 -0
- package/dist/extensions/pi-subagents/src/runs/background/stale-run-reconciler.ts +9 -3
- package/dist/extensions/pi-subagents/src/runs/background/steering.ts +11 -1
- package/dist/extensions/pi-subagents/src/runs/background/subagent-runner.ts +594 -216
- package/dist/extensions/pi-subagents/src/runs/background/subagent-wait.ts +17 -13
- package/dist/extensions/pi-subagents/src/runs/background/terminal-run-index.ts +138 -0
- package/dist/extensions/pi-subagents/src/runs/background/wait-completions.ts +23 -4
- package/dist/extensions/pi-subagents/src/runs/background/wait-subscriptions.ts +82 -4
- package/dist/extensions/pi-subagents/src/runs/background/wait-tool.ts +5 -3
- package/dist/extensions/pi-subagents/src/runs/foreground/async-steering-action.ts +21 -14
- package/dist/extensions/pi-subagents/src/runs/foreground/async-stop-action.ts +23 -2
- package/dist/extensions/pi-subagents/src/runs/foreground/execution.ts +153 -58
- package/dist/extensions/pi-subagents/src/runs/foreground/foreground-history.ts +7 -9
- package/dist/extensions/pi-subagents/src/runs/foreground/subagent-executor.ts +1283 -1657
- package/dist/extensions/pi-subagents/src/runs/foreground/workflow-detach-reconcile.ts +274 -0
- package/dist/extensions/pi-subagents/src/runs/foreground/workflow-foreground-steering.ts +6 -5
- package/dist/extensions/pi-subagents/src/runs/shared/acceptance.ts +59 -10
- package/dist/extensions/pi-subagents/src/runs/shared/agent-contract.ts +1 -1
- package/dist/extensions/pi-subagents/src/runs/shared/chain-outputs.ts +1 -3
- package/dist/extensions/pi-subagents/src/runs/shared/child-identity.ts +36 -0
- package/dist/extensions/pi-subagents/src/runs/shared/completion-guard.ts +52 -2
- package/dist/extensions/pi-subagents/src/runs/shared/dynamic-fanout.ts +1 -1
- package/dist/extensions/pi-subagents/src/runs/shared/extension-bindings.ts +78 -0
- package/dist/extensions/pi-subagents/src/runs/shared/external-cli-runner.ts +2 -0
- package/dist/extensions/pi-subagents/src/runs/shared/external-job-bridge.ts +460 -0
- package/dist/extensions/pi-subagents/src/runs/shared/external-job-runner.ts +389 -0
- package/dist/extensions/pi-subagents/src/runs/shared/fast-mode-extension.ts +10 -0
- package/dist/extensions/pi-subagents/src/runs/shared/mcp-direct-tool-allowlist.ts +14 -0
- package/dist/extensions/pi-subagents/src/runs/shared/model-exclusions.ts +243 -0
- package/dist/extensions/pi-subagents/src/runs/shared/model-fallback.ts +201 -85
- package/dist/extensions/pi-subagents/src/runs/shared/model-scope.ts +106 -39
- package/dist/extensions/pi-subagents/src/runs/shared/mutation-evidence.ts +145 -0
- package/dist/extensions/pi-subagents/src/runs/shared/orca-progress-tabs.ts +150 -27
- package/dist/extensions/pi-subagents/src/runs/shared/parallel-handoff.ts +46 -4
- package/dist/extensions/pi-subagents/src/runs/shared/parallel-utils.ts +19 -15
- package/dist/extensions/pi-subagents/src/runs/shared/permissions.ts +5 -1
- package/dist/extensions/pi-subagents/src/runs/shared/pi-args.ts +86 -2
- package/dist/extensions/pi-subagents/src/runs/shared/pi-spawn.ts +9 -9
- package/dist/extensions/pi-subagents/src/runs/shared/session-lease.ts +0 -6
- package/dist/extensions/pi-subagents/src/runs/shared/structured-output.ts +18 -4
- package/dist/extensions/pi-subagents/src/runs/shared/subagent-control.ts +51 -7
- package/dist/extensions/pi-subagents/src/runs/shared/subagent-prompt-runtime.ts +62 -21
- package/dist/extensions/pi-subagents/src/runs/shared/tool-availability.ts +1 -3
- package/dist/extensions/pi-subagents/src/runs/shared/tool-timeout.ts +1 -3
- package/dist/extensions/pi-subagents/src/runs/shared/workflow-graph.ts +1 -23
- package/dist/extensions/pi-subagents/src/runs/shared/worktree.ts +14 -2
- package/dist/extensions/pi-subagents/src/shared/artifacts.ts +2 -2
- package/dist/extensions/pi-subagents/src/shared/atomic-json.ts +22 -2
- package/dist/extensions/pi-subagents/src/shared/capacity-resilient-json.ts +102 -0
- package/dist/extensions/pi-subagents/src/shared/completion-owner.ts +14 -0
- package/dist/extensions/pi-subagents/src/shared/file-system-retry.ts +49 -1
- package/dist/extensions/pi-subagents/src/shared/fork-context.ts +59 -1
- package/dist/extensions/pi-subagents/src/shared/launch-contract.ts +12 -5
- package/dist/extensions/pi-subagents/src/shared/model-info.ts +20 -0
- package/dist/extensions/pi-subagents/src/shared/prompt-resources.ts +0 -40
- package/dist/extensions/pi-subagents/src/shared/settings.ts +11 -30
- package/dist/extensions/pi-subagents/src/shared/thinking-ceiling.ts +52 -0
- package/dist/extensions/pi-subagents/src/shared/types.ts +228 -49
- package/dist/extensions/pi-subagents/src/shared/utils.ts +11 -3
- package/dist/extensions/pi-subagents/src/shared/watch-strategy.ts +10 -0
- package/dist/extensions/pi-subagents/src/slash/prompt-workflows.ts +0 -162
- package/dist/extensions/pi-subagents/src/slash/slash-bridge.ts +2 -5
- package/dist/extensions/pi-subagents/src/slash/slash-commands.ts +105 -13
- package/dist/extensions/pi-subagents/src/slash/slash-live-state.ts +6 -36
- package/dist/extensions/pi-subagents/src/tui/fleet-status.ts +829 -0
- package/dist/extensions/pi-subagents/src/tui/fleet.ts +1415 -0
- package/dist/extensions/pi-subagents/src/tui/render.ts +78 -7
- package/dist/extensions/pi-subagents/src/watchdog/change-signature.ts +1 -1
- package/dist/extensions/pi-subagents/src/watchdog/lsp-diagnostics.ts +1 -0
- package/dist/extensions/pi-subagents/src/watchdog/permission-arbiter.ts +59 -51
- package/dist/extensions/pi-subagents/src/watchdog/register-main.ts +8 -2
- package/dist/extensions/pi-subagents/src/watchdog/tool-actions.ts +2 -1
- package/dist/extensions/pi-subagents/src/workflows/chat-progress.ts +4 -4
- package/dist/extensions/pi-subagents/src/workflows/scripted-workflow.ts +471 -86
- package/dist/extensions/pi-subagents/src/workflows/workflow-receipt.ts +140 -0
- package/dist/extensions/pi-subagents/test/e2e/real-session-subagent.test.ts +2 -2
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/bun/cli.d.ts +3 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/bun/register-bedrock.d.ts +2 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/bun/restore-sandbox-env.d.ts +17 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/cli/args.d.ts +57 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/cli/config-selector.d.ts +16 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/cli/file-processor.d.ts +15 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/cli/initial-message.d.ts +18 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/cli/list-models.d.ts +9 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/cli/project-trust.d.ts +10 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/cli/session-picker.d.ts +10 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/cli/startup-ui.d.ts +20 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/cli.d.ts +3 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/config.d.ts +96 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/core/agent-session-runtime.d.ts +119 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/core/agent-session-services.d.ts +85 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/core/agent-session.d.ts +620 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/core/auth-guidance.d.ts +5 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/core/auth-storage.d.ts +56 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/core/bash-executor.d.ts +32 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/core/cache-stats.d.ts +49 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/core/compaction/branch-summarization.d.ts +93 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/core/compaction/compaction.d.ts +128 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/core/compaction/index.d.ts +7 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/core/compaction/utils.d.ts +38 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/core/defaults.d.ts +3 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/core/diagnostics.d.ts +15 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/core/event-bus.d.ts +9 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/core/exec.d.ts +29 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/core/experimental.d.ts +2 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/core/export-html/ansi-to-html.d.ts +22 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/core/export-html/index.d.ts +37 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/core/export-html/tool-renderer.d.ts +34 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/core/extensions/index.d.ts +12 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/core/extensions/loader.d.ts +23 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/core/extensions/runner.d.ts +171 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/core/extensions/types.d.ts +1261 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/core/extensions/wrapper.d.ts +20 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/core/footer-data-provider.d.ts +54 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/core/http-dispatcher.d.ts +22 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/core/index.d.ts +13 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/core/keybindings.d.ts +358 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/core/messages.d.ts +77 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/core/model-config.d.ts +512 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/core/model-registry.d.ts +43 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/core/model-resolver.d.ts +121 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/core/model-runtime.d.ts +82 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/core/models-store.d.ts +17 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/core/output-guard.d.ts +7 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/core/package-manager.d.ts +210 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/core/project-trust.d.ts +15 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/core/prompt-templates.d.ts +54 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/core/provider-attribution.d.ts +4 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/core/provider-composer.d.ts +55 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/core/radius.d.ts +2 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/core/remote-catalog-provider.d.ts +5 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/core/resolve-config-value.d.ts +30 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/core/resource-loader.d.ts +206 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/core/runtime-credentials.d.ts +15 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/core/sdk.d.ts +106 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/core/session-cwd.d.ts +19 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/core/session-manager.d.ts +356 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/core/settings-manager.d.ts +297 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/core/skills.d.ts +60 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/core/slash-commands.d.ts +15 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/core/source-info.d.ts +18 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/core/system-prompt.d.ts +28 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/core/telemetry.d.ts +3 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/core/timings.d.ts +10 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/core/tools/bash.d.ts +68 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/core/tools/edit-diff.d.ts +106 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/core/tools/edit.d.ts +51 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/core/tools/file-mutation-queue.d.ts +6 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/core/tools/find.d.ts +35 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/core/tools/grep.d.ts +37 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/core/tools/index.d.ts +40 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/core/tools/ls.d.ts +37 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/core/tools/output-accumulator.d.ts +52 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/core/tools/path-utils.d.ts +10 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/core/tools/read.d.ts +35 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/core/tools/render-utils.d.ts +24 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/core/tools/tool-definition-wrapper.d.ts +14 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/core/tools/truncate.d.ts +70 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/core/tools/write.d.ts +26 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/core/trust-manager.d.ts +36 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/core/usage-totals.d.ts +19 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/extensions/index.d.ts +3 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/extensions/llama/client.d.ts +61 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/extensions/llama/huggingface.d.ts +23 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/extensions/llama/index.d.ts +3 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/extensions/llama/provider.d.ts +10 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/extensions/llama/ui.d.ts +42 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/index.d.ts +35 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/main.d.ts +12 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/migrations.d.ts +33 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/modes/index.d.ts +9 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/modes/interactive/components/armin.d.ts +34 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/modes/interactive/components/assistant-message.d.ts +22 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/modes/interactive/components/bash-execution.d.ts +34 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/modes/interactive/components/bordered-loader.d.ts +16 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/modes/interactive/components/branch-summary-message.d.ts +16 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/modes/interactive/components/compaction-summary-message.d.ts +16 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/modes/interactive/components/config-selector.d.ts +102 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/modes/interactive/components/countdown-timer.d.ts +14 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/modes/interactive/components/custom-editor.d.ts +21 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/modes/interactive/components/custom-entry.d.ts +19 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/modes/interactive/components/custom-message.d.ts +20 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/modes/interactive/components/daxnuts.d.ts +23 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/modes/interactive/components/diff.d.ts +12 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/modes/interactive/components/dynamic-border.d.ts +15 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/modes/interactive/components/earendil-announcement.d.ts +5 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/modes/interactive/components/extension-editor.d.ts +22 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/modes/interactive/components/extension-input.d.ts +23 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/modes/interactive/components/extension-selector.d.ts +26 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/modes/interactive/components/first-time-setup.d.ts +25 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/modes/interactive/components/footer.d.ts +32 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/modes/interactive/components/index.d.ts +34 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/modes/interactive/components/keybinding-hints.d.ts +13 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/modes/interactive/components/login-dialog.d.ts +52 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/modes/interactive/components/model-selector.d.ts +54 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/modes/interactive/components/oauth-selector.d.ts +33 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/modes/interactive/components/scoped-models-selector.d.ts +42 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/modes/interactive/components/session-selector-search.d.ts +23 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/modes/interactive/components/session-selector.d.ts +95 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/modes/interactive/components/settings-selector.d.ts +77 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/modes/interactive/components/show-images-selector.d.ts +10 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/modes/interactive/components/skill-invocation-message.d.ts +17 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/modes/interactive/components/status-indicator.d.ts +28 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/modes/interactive/components/theme-selector.d.ts +11 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/modes/interactive/components/thinking-selector.d.ts +11 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/modes/interactive/components/tool-execution.d.ts +63 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/modes/interactive/components/tree-selector.d.ts +94 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/modes/interactive/components/trust-selector.d.ts +23 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/modes/interactive/components/user-message-selector.d.ts +30 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/modes/interactive/components/user-message.d.ts +14 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/modes/interactive/components/visual-truncate.d.ts +24 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/modes/interactive/interactive-mode.d.ts +394 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/modes/interactive/model-search.d.ts +12 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/modes/interactive/theme/theme-controller.d.ts +29 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/modes/interactive/theme/theme.d.ts +120 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/modes/print-mode.d.ts +28 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/modes/rpc/jsonl.d.ts +17 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/modes/rpc/rpc-client.d.ts +246 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/modes/rpc/rpc-mode.d.ts +20 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/modes/rpc/rpc-types.d.ts +457 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/package-manager-cli.d.ts +8 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/rpc-entry.d.ts +3 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/utils/ansi.d.ts +2 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/utils/changelog.d.ts +22 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/utils/child-process.d.ts +18 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/utils/clipboard-image.d.ts +11 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/utils/clipboard-native.d.ts +11 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/utils/clipboard.d.ts +4 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/utils/deprecation.d.ts +4 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/utils/exif-orientation.d.ts +5 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/utils/frontmatter.d.ts +8 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/utils/fs-watch.d.ts +5 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/utils/git.d.ts +26 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/utils/html.d.ts +7 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/utils/image-convert.d.ts +10 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/utils/image-process.d.ts +18 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/utils/image-resize-core.d.ts +30 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/utils/image-resize-worker.d.ts +2 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/utils/image-resize.d.ts +16 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/utils/json.d.ts +3 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/utils/mime.d.ts +3 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/utils/open-browser.d.ts +9 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/utils/paths.d.ts +31 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/utils/photon.d.ts +21 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/utils/pi-user-agent.d.ts +2 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/utils/shell.d.ts +31 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/utils/sleep.d.ts +5 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/utils/syntax-highlight.d.ts +12 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/utils/tools-manager.d.ts +3 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/utils/version-check.d.ts +15 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/utils/windows-self-update.d.ts +3 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/index.mjs +1 -1
- package/dist/extensions/pi-subagents/test/integration/acceptance-file-report.test.ts +0 -54
- package/dist/extensions/pi-subagents/test/integration/async-execution.test.ts +1053 -414
- package/dist/extensions/pi-subagents/test/integration/async-job-tracker.test.ts +194 -4
- package/dist/extensions/pi-subagents/test/integration/async-status.test.ts +59 -4
- package/dist/extensions/pi-subagents/test/integration/error-handling.test.ts +0 -77
- package/dist/extensions/pi-subagents/test/integration/external-cli-runner.test.ts +107 -6
- package/dist/extensions/pi-subagents/test/integration/fork-context-execution.test.ts +211 -897
- package/dist/extensions/pi-subagents/test/integration/intercom-result-delivery.test.ts +265 -375
- package/dist/extensions/pi-subagents/test/integration/orca-progress-tabs.test.ts +77 -7
- package/dist/extensions/pi-subagents/test/integration/render-fork-badge.test.ts +1 -1
- package/dist/extensions/pi-subagents/test/integration/render-widget.test.ts +10 -10
- package/dist/extensions/pi-subagents/test/integration/result-watcher.test.ts +547 -30
- package/dist/extensions/pi-subagents/test/integration/single-execution.test.ts +2112 -310
- package/dist/extensions/pi-subagents/test/integration/slash-commands.test.ts +274 -34
- package/dist/extensions/pi-subagents/test/integration/slash-live-state.test.ts +1 -1
- package/dist/extensions/pi-subagents/test/integration/template-resolution.test.ts +20 -3
- package/dist/extensions/pi-subagents/test/support/isolated-temp-root.mjs +9 -0
- package/dist/extensions/pi-subagents/test/support/mock-pi-script.mjs +30 -5
- package/dist/extensions/pi-subagents/test/support/mock-pi.ts +2 -0
- package/dist/extensions/pi-subagents/test/support/real-session-runner.ts +4 -2
- package/dist/extensions/pi-subagents/test/support/register-loader.mjs +1 -0
- package/dist/extensions/pi-subagents/test/unit/acceptance.test.ts +197 -0
- package/dist/extensions/pi-subagents/test/unit/agent-contract.test.ts +14 -0
- package/dist/extensions/pi-subagents/test/unit/agent-disabled.test.ts +1 -1
- package/dist/extensions/pi-subagents/test/unit/agent-frontmatter.test.ts +204 -27
- package/dist/extensions/pi-subagents/test/unit/agent-management.test.ts +444 -145
- package/dist/extensions/pi-subagents/test/unit/agent-overrides.test.ts +256 -4
- package/dist/extensions/pi-subagents/test/unit/artifacts.test.ts +9 -7
- package/dist/extensions/pi-subagents/test/unit/async-interrupt-action.test.ts +152 -22
- package/dist/extensions/pi-subagents/test/unit/async-recovery-descriptor.test.ts +29 -0
- package/dist/extensions/pi-subagents/test/unit/async-resume.test.ts +205 -23
- package/dist/extensions/pi-subagents/test/unit/async-retention.test.ts +579 -0
- package/dist/extensions/pi-subagents/test/unit/atomic-json.test.ts +24 -0
- package/dist/extensions/pi-subagents/test/unit/authority-policy.test.ts +1 -0
- package/dist/extensions/pi-subagents/test/unit/auto-drain.test.ts +3 -3
- package/dist/extensions/pi-subagents/test/unit/capacity-resilient-json.test.ts +155 -0
- package/dist/extensions/pi-subagents/test/unit/compaction-resume.test.ts +2 -2
- package/dist/extensions/pi-subagents/test/unit/completion-dedupe.test.ts +7 -0
- package/dist/extensions/pi-subagents/test/unit/completion-guard.test.ts +123 -0
- package/dist/extensions/pi-subagents/test/unit/completion-replay.test.ts +81 -3
- package/dist/extensions/pi-subagents/test/unit/control-channel.test.ts +109 -7
- package/dist/extensions/pi-subagents/test/unit/default-extensions.test.ts +2 -2
- package/dist/extensions/pi-subagents/test/unit/doctor.test.ts +5 -2
- package/dist/extensions/pi-subagents/test/unit/dynamic-fanout.test.ts +3 -2
- package/dist/extensions/pi-subagents/test/unit/extension-bindings.test.ts +79 -0
- package/dist/extensions/pi-subagents/test/unit/external-cli-runner.test.ts +22 -0
- package/dist/extensions/pi-subagents/test/unit/external-job-runner.test.ts +961 -0
- package/dist/extensions/pi-subagents/test/unit/file-system-retry.test.ts +64 -0
- package/dist/extensions/pi-subagents/test/unit/fleet-status.test.ts +1110 -0
- package/dist/extensions/pi-subagents/test/unit/fleet.test.ts +1664 -0
- package/dist/extensions/pi-subagents/test/unit/fork-context.test.ts +81 -1
- package/dist/extensions/pi-subagents/test/unit/herdr-inspector.test.ts +138 -11
- package/dist/extensions/pi-subagents/test/unit/herdr-status-bridge.test.ts +41 -2
- package/dist/extensions/pi-subagents/test/unit/index-child-registration.test.ts +210 -79
- package/dist/extensions/pi-subagents/test/unit/index-segment.test.ts +95 -0
- package/dist/extensions/pi-subagents/test/unit/inspect-rpc.test.ts +596 -0
- package/dist/extensions/pi-subagents/test/unit/mission-lifecycle.test.ts +10 -1
- package/dist/extensions/pi-subagents/test/unit/mission-store.test.ts +3 -5
- package/dist/extensions/pi-subagents/test/unit/model-exclusions.test.ts +167 -0
- package/dist/extensions/pi-subagents/test/unit/model-fallback.test.ts +319 -18
- package/dist/extensions/pi-subagents/test/unit/model-info.test.ts +78 -0
- package/dist/extensions/pi-subagents/test/unit/model-scope-settings.test.ts +19 -5
- package/dist/extensions/pi-subagents/test/unit/model-scope.test.ts +44 -0
- package/dist/extensions/pi-subagents/test/unit/mutation-evidence.test.ts +129 -0
- package/dist/extensions/pi-subagents/test/unit/native-supervisor-channel.test.ts +231 -2
- package/dist/extensions/pi-subagents/test/unit/nested-control.test.ts +28 -1
- package/dist/extensions/pi-subagents/test/unit/notify.test.ts +106 -2
- package/dist/extensions/pi-subagents/test/unit/orca-progress-tabs.test.ts +204 -7
- package/dist/extensions/pi-subagents/test/unit/package-manifest.test.ts +59 -4
- package/dist/extensions/pi-subagents/test/unit/path-handling.test.ts +2 -6
- package/dist/extensions/pi-subagents/test/unit/pi-args-permission-system.test.ts +34 -2
- package/dist/extensions/pi-subagents/test/unit/pi-args.test.ts +116 -6
- package/dist/extensions/pi-subagents/test/unit/pi-coding-agent-dir.test.ts +12 -3
- package/dist/extensions/pi-subagents/test/unit/pi-spawn.test.ts +56 -61
- package/dist/extensions/pi-subagents/test/unit/preflight.test.ts +416 -1
- package/dist/extensions/pi-subagents/test/unit/profiles.test.ts +9 -2
- package/dist/extensions/pi-subagents/test/unit/project-panes-public-api.test.ts +42 -0
- package/dist/extensions/pi-subagents/test/unit/prompt-workflows.test.ts +21 -30
- package/dist/extensions/pi-subagents/test/unit/public-execution.test.ts +86 -11
- package/dist/extensions/pi-subagents/test/unit/render-helpers.test.ts +49 -1
- package/dist/extensions/pi-subagents/test/unit/result-files.test.ts +233 -5
- package/dist/extensions/pi-subagents/test/unit/retained-children.test.ts +28 -5
- package/dist/extensions/pi-subagents/test/unit/rpc.test.ts +323 -20
- package/dist/extensions/pi-subagents/test/unit/run-id-resolver.test.ts +66 -10
- package/dist/extensions/pi-subagents/test/unit/run-status.test.ts +68 -5
- package/dist/extensions/pi-subagents/test/unit/runtime-agent-registration.test.ts +174 -0
- package/dist/extensions/pi-subagents/test/unit/scheduled-runs.test.ts +679 -0
- package/dist/extensions/pi-subagents/test/unit/scheduled-store-root.test.ts +67 -0
- package/dist/extensions/pi-subagents/test/unit/schemas.test.ts +55 -44
- package/dist/extensions/pi-subagents/test/unit/scripted-workflow.test.ts +399 -84
- package/dist/extensions/pi-subagents/test/unit/session-lease.test.ts +13 -0
- package/dist/extensions/pi-subagents/test/unit/skills-fallback.test.ts +1 -1
- package/dist/extensions/pi-subagents/test/unit/slash-bridge.test.ts +15 -10
- package/dist/extensions/pi-subagents/test/unit/stale-run-reconciler.test.ts +11 -7
- package/dist/extensions/pi-subagents/test/unit/steering-action.test.ts +2 -0
- package/dist/extensions/pi-subagents/test/unit/steering.test.ts +40 -1
- package/dist/extensions/pi-subagents/test/unit/subagent-action-recovery.test.ts +10 -2
- package/dist/extensions/pi-subagents/test/unit/subagent-control.test.ts +38 -3
- package/dist/extensions/pi-subagents/test/unit/subagent-prompt-runtime.test.ts +110 -12
- package/dist/extensions/pi-subagents/test/unit/subagent-wait.test.ts +204 -19
- package/dist/extensions/pi-subagents/test/unit/temp-paths.test.ts +25 -0
- package/dist/extensions/pi-subagents/test/unit/thinking-ceiling.test.ts +73 -0
- package/dist/extensions/pi-subagents/test/unit/tool-description.test.ts +90 -50
- package/dist/extensions/pi-subagents/test/unit/tool-timeout.test.ts +1 -2
- package/dist/extensions/pi-subagents/test/unit/wait-subscriptions.test.ts +234 -7
- package/dist/extensions/pi-subagents/test/unit/watch-strategy.test.ts +24 -0
- package/dist/extensions/pi-subagents/test/unit/watchdog-permission-arbiter.test.ts +36 -0
- package/dist/extensions/pi-subagents/test/unit/workflow-chat-progress.test.ts +37 -9
- package/dist/extensions/pi-subagents/test/unit/workflow-detach-reconcile.test.ts +302 -0
- package/dist/extensions/pi-subagents/test/unit/workflow-launch-params.test.ts +167 -7
- package/dist/extensions/pi-subagents/test/unit/workflow-receipt.test.ts +113 -0
- package/dist/extensions/pi-subagents/test/unit/worktree.test.ts +6 -6
- package/dist/extensions/ponytail/index.js +31 -25
- package/dist/extensions/ponytail/ponytail-config.cjs +34 -7
- package/dist/extensions/ponytail/ponytail-instructions.cjs +7 -9
- package/dist/extensions/ponytail/test/extension.test.js +7 -8
- package/dist/extensions/ponytail/test/helpers.test.js +1 -1
- package/dist/skills/brandkit/SKILL.md +799 -0
- package/dist/skills/design-taste-frontend/SKILL.md +1207 -0
- package/dist/skills/design-taste-frontend-v1/SKILL.md +227 -0
- package/dist/skills/full-output-enforcement/SKILL.md +50 -0
- package/dist/skills/gpt-taste/SKILL.md +75 -0
- package/dist/skills/high-end-visual-design/SKILL.md +99 -0
- package/dist/skills/image-to-code/SKILL.md +1229 -0
- package/dist/skills/imagegen-frontend-mobile/SKILL.md +1466 -0
- package/dist/skills/imagegen-frontend-web/SKILL.md +988 -0
- package/dist/skills/industrial-brutalist-ui/SKILL.md +93 -0
- package/dist/skills/minimalist-ui/SKILL.md +86 -0
- package/dist/skills/pi-subagents/SKILL.md +18 -17
- package/dist/skills/pi-subagents/references/constraints-and-recipes.md +31 -9
- package/dist/skills/pi-subagents/references/execution-controls.md +95 -143
- package/dist/skills/pi-subagents/references/management-authoring-rpc.md +9 -12
- package/dist/skills/pi-subagents/references/multi-lane-orchestration.md +39 -0
- package/dist/skills/pi-subagents/references/prompting-and-roles.md +45 -94
- package/dist/skills/ponytail/SKILL.md +12 -8
- package/dist/skills/ponytail-audit/SKILL.md +0 -1
- package/dist/skills/ponytail-debt/SKILL.md +0 -1
- package/dist/skills/ponytail-gain/SKILL.md +0 -1
- package/dist/skills/ponytail-help/SKILL.md +4 -3
- package/dist/skills/ponytail-review/SKILL.md +0 -1
- package/dist/skills/redesign-existing-projects/SKILL.md +179 -0
- package/dist/skills/stitch-design-taste/SKILL.md +185 -0
- package/dist/skills/unlazy/CHANGELOG.md +100 -0
- package/dist/skills/unlazy/CONTRIBUTING.md +66 -0
- package/dist/skills/unlazy/LICENSE +21 -0
- package/dist/skills/unlazy/README.md +242 -0
- package/dist/skills/unlazy/SECURITY.md +70 -0
- package/dist/skills/unlazy/SKILL.md +100 -0
- package/dist/skills/unlazy/package.json +13 -0
- package/dist/skills/unlazy/references/dispatch.md +82 -0
- package/dist/skills/unlazy/references/gates.md +132 -0
- package/dist/skills/unlazy/references/method.md +49 -0
- package/dist/skills/unlazy/references/orchestration.md +99 -0
- package/dist/skills/unlazy/references/parallel.md +123 -0
- package/dist/skills/unlazy/references/token-economy.md +39 -0
- package/dist/skills/unlazy/research/validation-protocol.md +81 -0
- package/dist/skills/unlazy/scripts/dispatch-check.mjs +108 -0
- package/dist/skills/unlazy/scripts/gate-check.mjs +894 -0
- package/dist/skills/unlazy/scripts/gate-lint.mjs +178 -0
- package/dist/skills/unlazy/scripts/install-hooks.mjs +206 -0
- package/dist/skills/unlazy/scripts/lib/check-supervisor.mjs +46 -0
- package/dist/skills/unlazy/scripts/lib/dispatch.mjs +283 -0
- package/dist/skills/unlazy/scripts/lib/gates.mjs +629 -0
- package/dist/skills/unlazy/scripts/lib/process-tree.mjs +161 -0
- package/dist/skills/unlazy/scripts/lib/regex-worker.mjs +9 -0
- package/dist/skills/unlazy/scripts/stop-hook.mjs +174 -0
- package/dist/skills/unlazy/templates/PLAN.md +65 -0
- package/dist/skills/unlazy/templates/gates-leaf.md +51 -0
- package/dist/skills/unlazy/templates/gates-node.md +50 -0
- package/dist/skills/unlazy/tests/contract-tests.mjs +127 -0
- package/dist/skills/unlazy/tests/dispatch-tests.mjs +481 -0
- package/dist/skills/unlazy/tests/hardening-tests.mjs +903 -0
- package/dist/skills/unlazy/tests/lint-tests.mjs +242 -0
- package/dist/skills/unlazy/tests/run-tests.mjs +554 -0
- package/dist/skills/unlazy/tests/self-check.mjs +165 -0
- package/dist/skills/unlazy/tests/stress-tests.mjs +356 -0
- package/dist/skills/web-design-guidelines/SKILL.md +40 -0
- package/docs/settings.md +0 -5
- package/package.json +1 -1
- package/dist/core/tools/schema-prune.d.ts +0 -16
- package/dist/core/tools/schema-prune.js +0 -39
- package/dist/core/tools/schema-prune.test.d.ts +0 -1
- package/dist/core/tools/schema-prune.test.js +0 -111
- package/dist/extensions/pi-subagents/UPSTREAM-V0.50-MAPPING.md +0 -172
- package/dist/extensions/pi-subagents/prompts/parallel-context-build.md +0 -55
- package/dist/extensions/pi-subagents/prompts/parallel-handoff-plan.md +0 -61
- package/dist/extensions/pi-subagents/src/agents/task-aware-routing.ts +0 -132
- package/dist/extensions/pi-subagents/src/extension/chain-validation.ts +0 -181
- package/dist/extensions/pi-subagents/src/runs/foreground/chain-clarify.ts +0 -1354
- package/dist/extensions/pi-subagents/src/runs/foreground/chain-execution.ts +0 -1581
- package/dist/extensions/pi-subagents/src/shared/env.ts +0 -16
- package/dist/extensions/pi-subagents/src/shared/session-lineage.ts +0 -71
- package/dist/extensions/pi-subagents/src/slash/inline-subagents.ts +0 -136
- package/dist/extensions/pi-subagents/src/workflows/workflow-auto-relaunch.ts +0 -41
- package/dist/extensions/pi-subagents/test/integration/chain-clarify.test.ts +0 -466
- package/dist/extensions/pi-subagents/test/integration/chain-execution.test.ts +0 -1859
- package/dist/extensions/pi-subagents/test/integration/parallel-execution.test.ts +0 -733
- package/dist/extensions/pi-subagents/test/unit/builtin-agent-documentation.test.ts +0 -63
- package/dist/extensions/pi-subagents/test/unit/chain-validation.test.ts +0 -326
- package/dist/extensions/pi-subagents/test/unit/handoff-adoption.test.ts +0 -103
- package/dist/extensions/pi-subagents/test/unit/inline-subagents.test.ts +0 -127
- package/dist/extensions/pi-subagents/test/unit/session-lineage.test.ts +0 -73
- package/dist/extensions/pi-subagents/test/unit/task-aware-routing.test.ts +0 -213
- package/dist/extensions/pi-subagents/test/unit/workflow-auto-relaunch.test.ts +0 -65
|
@@ -0,0 +1,629 @@
|
|
|
1
|
+
// Shared gate parsing, scope resolution, durable writes, locks, and leases.
|
|
2
|
+
// Zero dependencies. Node 16+.
|
|
3
|
+
|
|
4
|
+
import {
|
|
5
|
+
closeSync, constants as fsConstants, existsSync, fstatSync, fsyncSync, lstatSync, mkdirSync,
|
|
6
|
+
openSync, readFileSync, readdirSync, renameSync, statSync, unlinkSync,
|
|
7
|
+
writeFileSync,
|
|
8
|
+
} from "node:fs";
|
|
9
|
+
import { createHash, randomBytes } from "node:crypto";
|
|
10
|
+
import { basename, dirname, isAbsolute, join, resolve } from "node:path";
|
|
11
|
+
|
|
12
|
+
export const UNLAZY_DIR = ".unlazy";
|
|
13
|
+
export const LOCK_DIR = join(UNLAZY_DIR, "locks");
|
|
14
|
+
|
|
15
|
+
export const sleep = (ms) => new Promise((done) => setTimeout(done, ms));
|
|
16
|
+
export const sha256 = (value) => createHash("sha256").update(String(value)).digest("hex");
|
|
17
|
+
|
|
18
|
+
const WINDOWS_TRANSIENT_FS_ERRORS = new Set(["EACCES", "EBUSY", "EPERM"]);
|
|
19
|
+
const SYNC_SLEEP_CELL = new Int32Array(new SharedArrayBuffer(4));
|
|
20
|
+
|
|
21
|
+
function isTransientWindowsFsError(error) {
|
|
22
|
+
return process.platform === "win32" && WINDOWS_TRANSIENT_FS_ERRORS.has(error && error.code);
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
// Windows scanners and indexers can briefly retain a handle to a file after it
|
|
26
|
+
// closes. Keep the same private temp file and retry replacement while the caller
|
|
27
|
+
// still holds its lock; never unlink the destination or fall back to an in-place
|
|
28
|
+
// write, either of which would sacrifice atomicity.
|
|
29
|
+
function replaceAtomic(temp, target) {
|
|
30
|
+
const deadline = Date.now() + 2000;
|
|
31
|
+
let delay = 5;
|
|
32
|
+
for (;;) {
|
|
33
|
+
try {
|
|
34
|
+
renameSync(temp, target);
|
|
35
|
+
return;
|
|
36
|
+
} catch (error) {
|
|
37
|
+
const remaining = deadline - Date.now();
|
|
38
|
+
if (!isTransientWindowsFsError(error) || remaining <= 0) throw error;
|
|
39
|
+
Atomics.wait(SYNC_SLEEP_CELL, 0, 0, Math.min(delay, remaining));
|
|
40
|
+
delay = Math.min(delay * 2, 100);
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
const GATE_RE = /^- \[( |x|X)\] (.*)$/;
|
|
46
|
+
const ATTR_RE = /^(\s+)(CHECK|EXPECT|EVIDENCE|CWD):\s?(.*)$/;
|
|
47
|
+
const UNINDENTED_ATTR_RE = /^(CHECK|EXPECT|EVIDENCE|CWD):\s?(.*)$/;
|
|
48
|
+
const ABANDON_RE = /^ABANDON:\s*(\S*)\s*(.*)$/;
|
|
49
|
+
const INDENTED_ABANDON_RE = /^\s+ABANDON:/;
|
|
50
|
+
const OWNS_RE = /^OWNS:\s*(.*)$/;
|
|
51
|
+
const FENCE_OPEN_RE = /^( {0,3})(`{3,}|~{3,})(.*)$/;
|
|
52
|
+
const REGEX_RE = /^\/([\s\S]*)\/([a-z]*)$/;
|
|
53
|
+
// A pattern author escapes an inner slash or has none. A literal path always
|
|
54
|
+
// carries one, so an unescaped inner slash marks the ambiguous reading.
|
|
55
|
+
const UNESCAPED_SLASH_RE = /(^|[^\\])\//;
|
|
56
|
+
const SCOPE_RE = /^[A-Za-z0-9][A-Za-z0-9._-]{0,63}$/;
|
|
57
|
+
|
|
58
|
+
function parseRegex(expect) {
|
|
59
|
+
const match = String(expect).match(REGEX_RE);
|
|
60
|
+
if (!match) return { kind: "text", value: String(expect) };
|
|
61
|
+
if (match[1].length > 1000) return { error: "EXPECT regex is longer than 1000 characters" };
|
|
62
|
+
try {
|
|
63
|
+
// Matching happens in a disposable worker so catastrophic backtracking
|
|
64
|
+
// cannot hang the checker.
|
|
65
|
+
new RegExp(match[1], match[2]);
|
|
66
|
+
} catch (error) {
|
|
67
|
+
return { error: "invalid EXPECT regex: " + error.message };
|
|
68
|
+
}
|
|
69
|
+
return {
|
|
70
|
+
kind: "regex",
|
|
71
|
+
source: match[1],
|
|
72
|
+
flags: match[2],
|
|
73
|
+
pathLike: UNESCAPED_SLASH_RE.test(match[1]),
|
|
74
|
+
};
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
// The checker and Stop hook both consume this exact result. Diagnostics are
|
|
78
|
+
// returned together so callers can report all malformed input in one pass.
|
|
79
|
+
export function parseGates(text, options = {}) {
|
|
80
|
+
const source = String(text);
|
|
81
|
+
const eol = source.includes("\r\n") ? "\r\n" : "\n";
|
|
82
|
+
const finalNewline = source.endsWith("\n");
|
|
83
|
+
const lines = source.split(/\r?\n/);
|
|
84
|
+
const gates = [];
|
|
85
|
+
const abandoned = new Map();
|
|
86
|
+
const owns = [];
|
|
87
|
+
const errors = [];
|
|
88
|
+
const warnings = [];
|
|
89
|
+
const ids = new Map();
|
|
90
|
+
const attrs = new Map();
|
|
91
|
+
let current = null;
|
|
92
|
+
let seenGate = false;
|
|
93
|
+
let fence = null;
|
|
94
|
+
|
|
95
|
+
for (let index = 0; index < lines.length; index++) {
|
|
96
|
+
const line = lines[index];
|
|
97
|
+
if (fence) {
|
|
98
|
+
const close = line.match(/^( {0,3})(`+|~+)[ \t]*$/);
|
|
99
|
+
if (close && close[2][0] === fence.character && close[2].length >= fence.length) fence = null;
|
|
100
|
+
continue;
|
|
101
|
+
}
|
|
102
|
+
const fenceMatch = line.match(FENCE_OPEN_RE);
|
|
103
|
+
if (fenceMatch && !(fenceMatch[2][0] === "`" && fenceMatch[3].includes("`"))) {
|
|
104
|
+
fence = { character: fenceMatch[2][0], length: fenceMatch[2].length };
|
|
105
|
+
continue;
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
const gateMatch = line.match(GATE_RE);
|
|
109
|
+
if (gateMatch) {
|
|
110
|
+
seenGate = true;
|
|
111
|
+
const rawTitle = gateMatch[2].trim();
|
|
112
|
+
const idMatch = rawTitle.match(/^(\S+?):(?:\s+|$)/);
|
|
113
|
+
const id = idMatch ? idMatch[1] : "L" + (index + 1);
|
|
114
|
+
const title = idMatch ? rawTitle.slice(idMatch[0].length).trim() : rawTitle;
|
|
115
|
+
current = {
|
|
116
|
+
line: index,
|
|
117
|
+
checked: gateMatch[1].toLowerCase() === "x",
|
|
118
|
+
id,
|
|
119
|
+
title,
|
|
120
|
+
check: null,
|
|
121
|
+
expect: null,
|
|
122
|
+
evidence: null,
|
|
123
|
+
evidenceLine: -1,
|
|
124
|
+
cwd: null,
|
|
125
|
+
};
|
|
126
|
+
gates.push(current);
|
|
127
|
+
attrs.set(current, new Set());
|
|
128
|
+
if (!idMatch) errors.push("line " + (index + 1) + ": gate needs an explicit ID followed by a colon");
|
|
129
|
+
else if (!/^[A-Za-z0-9][A-Za-z0-9._-]*$/.test(id)) {
|
|
130
|
+
errors.push("line " + (index + 1) + ": invalid gate id " + id);
|
|
131
|
+
}
|
|
132
|
+
if (!title) errors.push("line " + (index + 1) + ": gate outcome is blank");
|
|
133
|
+
if (ids.has(id)) {
|
|
134
|
+
errors.push("line " + (index + 1) + ": duplicate gate id " + id +
|
|
135
|
+
" (first declared on line " + ids.get(id) + ")");
|
|
136
|
+
} else ids.set(id, index + 1);
|
|
137
|
+
continue;
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
// Attributes must be indented and ABANDON must not be, so the two rules
|
|
141
|
+
// point opposite ways. Diagnose the indented abandonment rather than
|
|
142
|
+
// ignoring it, or the author's honest exit fails with no explanation.
|
|
143
|
+
if (INDENTED_ABANDON_RE.test(line)) {
|
|
144
|
+
errors.push("line " + (index + 1) +
|
|
145
|
+
": indented ABANDON is not applied; start ABANDON at column 1");
|
|
146
|
+
current = null;
|
|
147
|
+
continue;
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
const unindented = line.match(UNINDENTED_ATTR_RE);
|
|
151
|
+
if (unindented) {
|
|
152
|
+
errors.push("line " + (index + 1) + ": unindented " + unindented[1] +
|
|
153
|
+
" is not attached to a gate; indent attribute lines with spaces");
|
|
154
|
+
current = null;
|
|
155
|
+
continue;
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
const anyAttr = line.match(ATTR_RE);
|
|
159
|
+
if (anyAttr && !current) {
|
|
160
|
+
errors.push("line " + (index + 1) + ": orphan " + anyAttr[2] + " is not attached to a gate");
|
|
161
|
+
continue;
|
|
162
|
+
}
|
|
163
|
+
const attrMatch = current && anyAttr;
|
|
164
|
+
if (attrMatch) {
|
|
165
|
+
const key = attrMatch[2].toLowerCase();
|
|
166
|
+
const value = attrMatch[3].trim();
|
|
167
|
+
if (attrs.get(current).has(key)) {
|
|
168
|
+
errors.push("line " + (index + 1) + ": duplicate " + attrMatch[2] +
|
|
169
|
+
" for gate " + current.id);
|
|
170
|
+
}
|
|
171
|
+
attrs.get(current).add(key);
|
|
172
|
+
if (key === "evidence") {
|
|
173
|
+
current.evidence = value;
|
|
174
|
+
current.evidenceLine = index;
|
|
175
|
+
} else current[key] = value;
|
|
176
|
+
continue;
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
const abandonMatch = line.match(ABANDON_RE);
|
|
180
|
+
if (abandonMatch) {
|
|
181
|
+
const id = abandonMatch[1].replace(/:$/, "");
|
|
182
|
+
const reason = abandonMatch[2].trim();
|
|
183
|
+
if (!id) errors.push("line " + (index + 1) + ": ABANDON needs a gate id and reason");
|
|
184
|
+
else if (!reason) errors.push("line " + (index + 1) + ": ABANDON " + id + " needs a non-blank reason");
|
|
185
|
+
else if (abandoned.has(id)) errors.push("line " + (index + 1) + ": duplicate ABANDON for " + id);
|
|
186
|
+
else abandoned.set(id, reason);
|
|
187
|
+
current = null;
|
|
188
|
+
continue;
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
const ownsMatch = line.match(OWNS_RE);
|
|
192
|
+
if (ownsMatch) {
|
|
193
|
+
if (seenGate) {
|
|
194
|
+
errors.push("line " + (index + 1) + ": OWNS must appear before the first gate");
|
|
195
|
+
current = null;
|
|
196
|
+
continue;
|
|
197
|
+
}
|
|
198
|
+
const declared = ownsMatch[1].split(",").map((item) => item.trim()).filter(Boolean);
|
|
199
|
+
if (!declared.length) errors.push("line " + (index + 1) + ": OWNS declares no paths");
|
|
200
|
+
for (const item of declared) {
|
|
201
|
+
const normalized = normalizeOwnsGlob(item);
|
|
202
|
+
if (normalized.error) errors.push("line " + (index + 1) + ": " + normalized.error);
|
|
203
|
+
else owns.push(normalized.value);
|
|
204
|
+
}
|
|
205
|
+
continue;
|
|
206
|
+
}
|
|
207
|
+
if (/^#|^- /.test(line)) current = null;
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
if (fence) errors.push("unclosed fenced block");
|
|
211
|
+
|
|
212
|
+
for (const gate of gates) {
|
|
213
|
+
const hasCheck = gate.check !== null && gate.check !== "";
|
|
214
|
+
const hasExpect = gate.expect !== null && gate.expect !== "";
|
|
215
|
+
if (hasCheck !== hasExpect) {
|
|
216
|
+
errors.push("gate " + gate.id + ": runnable gates require both non-blank CHECK and EXPECT");
|
|
217
|
+
}
|
|
218
|
+
if (gate.check === "" || gate.expect === "") {
|
|
219
|
+
errors.push("gate " + gate.id + ": CHECK and EXPECT cannot be blank");
|
|
220
|
+
}
|
|
221
|
+
if (hasExpect) {
|
|
222
|
+
const parsed = parseRegex(gate.expect);
|
|
223
|
+
if (parsed.error) errors.push("gate " + gate.id + ": " + parsed.error);
|
|
224
|
+
else if (parsed.pathLike) {
|
|
225
|
+
// Warn rather than reject: the pattern reading may be intended, and a
|
|
226
|
+
// literal path cannot be expressed once the wrapping slashes sniff.
|
|
227
|
+
warnings.push("gate " + gate.id + ": EXPECT " + JSON.stringify(gate.expect) +
|
|
228
|
+
" is read as a regular expression, so its dots and other metacharacters" +
|
|
229
|
+
" are wildcards. Escape the inner slashes to keep the pattern, or drop" +
|
|
230
|
+
" the wrapping slashes to match a literal substring.");
|
|
231
|
+
}
|
|
232
|
+
gate.expectation = parsed;
|
|
233
|
+
} else gate.expectation = null;
|
|
234
|
+
}
|
|
235
|
+
|
|
236
|
+
for (const id of abandoned.keys()) {
|
|
237
|
+
if (!ids.has(id)) errors.push("ABANDON references unknown gate " + id);
|
|
238
|
+
}
|
|
239
|
+
if (options.requireGates !== false && gates.length === 0) errors.push("ledger contains zero live gates");
|
|
240
|
+
|
|
241
|
+
return { lines, eol, finalNewline, gates, abandoned, owns, errors, warnings };
|
|
242
|
+
}
|
|
243
|
+
|
|
244
|
+
export function formatDocument(doc) {
|
|
245
|
+
let output = doc.lines.join(doc.eol);
|
|
246
|
+
if (doc.finalNewline && !output.endsWith(doc.eol)) output += doc.eol;
|
|
247
|
+
return output;
|
|
248
|
+
}
|
|
249
|
+
|
|
250
|
+
export function qualify(fileOrLabel, id) {
|
|
251
|
+
return basename(String(fileOrLabel)).replace(/\.md$/i, "") + ":" + id;
|
|
252
|
+
}
|
|
253
|
+
|
|
254
|
+
export function gateState(gate, abandoned) {
|
|
255
|
+
if (abandoned.has(gate.id)) return "abandoned";
|
|
256
|
+
const pending = gate.evidence === null || gate.evidence === "" || /^pending$/i.test(gate.evidence);
|
|
257
|
+
if (!gate.checked) return "unmet";
|
|
258
|
+
if (pending) return "unmet-no-evidence";
|
|
259
|
+
return "met";
|
|
260
|
+
}
|
|
261
|
+
|
|
262
|
+
export function tail(output, max = 240) {
|
|
263
|
+
const lines = String(output).split(/\r?\n/).map((line) => line.trim()).filter(Boolean);
|
|
264
|
+
return (lines.slice(-2).join(" | ") || "(no output)").slice(0, max);
|
|
265
|
+
}
|
|
266
|
+
|
|
267
|
+
export function validateScopeId(value, label = "scope") {
|
|
268
|
+
const id = String(value || "");
|
|
269
|
+
if (!SCOPE_RE.test(id) || id === "." || id === "..") {
|
|
270
|
+
return label + " must match " + SCOPE_RE + " and cannot be . or ..";
|
|
271
|
+
}
|
|
272
|
+
return null;
|
|
273
|
+
}
|
|
274
|
+
|
|
275
|
+
export function normalizeOwnsGlob(value) {
|
|
276
|
+
const raw = String(value || "").trim().replace(/\\/g, "/").replace(/^\.\//, "");
|
|
277
|
+
if (!raw) return { error: "OWNS path is blank" };
|
|
278
|
+
if (isAbsolute(raw) || /^[A-Za-z]:\//.test(raw) || raw.startsWith("//")) {
|
|
279
|
+
return { error: "OWNS path must be relative: " + value };
|
|
280
|
+
}
|
|
281
|
+
const parts = raw.split("/");
|
|
282
|
+
if (raw.includes("\0") || parts.some((part) => part === "..")) {
|
|
283
|
+
return { error: "OWNS path cannot contain traversal: " + value };
|
|
284
|
+
}
|
|
285
|
+
const normalized = parts.filter((part) => part !== "" && part !== ".").join("/");
|
|
286
|
+
if (!normalized || normalized === ".") return { error: "OWNS path cannot claim an implicit root" };
|
|
287
|
+
return { value: normalized };
|
|
288
|
+
}
|
|
289
|
+
|
|
290
|
+
export function literalPrefix(glob) {
|
|
291
|
+
const normalized = normalizeOwnsGlob(glob);
|
|
292
|
+
if (normalized.error) return "";
|
|
293
|
+
const literal = [];
|
|
294
|
+
for (const part of normalized.value.split("/")) {
|
|
295
|
+
if (/[*?[{]/.test(part)) break;
|
|
296
|
+
literal.push(part);
|
|
297
|
+
}
|
|
298
|
+
return literal.join("/");
|
|
299
|
+
}
|
|
300
|
+
|
|
301
|
+
// Prove disjointness only when literal path segments disagree. Everything else
|
|
302
|
+
// conflicts, including mid-segment pairs such as a* and ab*.
|
|
303
|
+
export function globsOverlap(left, right) {
|
|
304
|
+
const a = normalizeOwnsGlob(left);
|
|
305
|
+
const b = normalizeOwnsGlob(right);
|
|
306
|
+
if (a.error || b.error) return true;
|
|
307
|
+
const as = a.value.split("/");
|
|
308
|
+
const bs = b.value.split("/");
|
|
309
|
+
const count = Math.min(as.length, bs.length);
|
|
310
|
+
for (let index = 0; index < count; index++) {
|
|
311
|
+
const av = as[index], bv = bs[index];
|
|
312
|
+
if (/[*?[{]/.test(av) || /[*?[{]/.test(bv)) return true;
|
|
313
|
+
if (av !== bv) return false;
|
|
314
|
+
}
|
|
315
|
+
// An exact prefix may denote a directory ownership claim, so it can overlap
|
|
316
|
+
// every descendant. Treat common-prefix length differences as conflicts.
|
|
317
|
+
if (as.length !== bs.length) return true;
|
|
318
|
+
return true;
|
|
319
|
+
}
|
|
320
|
+
|
|
321
|
+
export function scopeRoot(root, scope) {
|
|
322
|
+
return join(root, UNLAZY_DIR, scope);
|
|
323
|
+
}
|
|
324
|
+
|
|
325
|
+
export function listScopes(root) {
|
|
326
|
+
const directory = join(root, UNLAZY_DIR);
|
|
327
|
+
if (!existsSync(directory)) return [];
|
|
328
|
+
try {
|
|
329
|
+
return readdirSync(directory, { withFileTypes: true })
|
|
330
|
+
.filter((entry) => entry.isDirectory() && !entry.isSymbolicLink() && entry.name !== "locks" && !validateScopeId(entry.name))
|
|
331
|
+
.map((entry) => entry.name)
|
|
332
|
+
.sort();
|
|
333
|
+
} catch {
|
|
334
|
+
return [];
|
|
335
|
+
}
|
|
336
|
+
}
|
|
337
|
+
|
|
338
|
+
function markdownFiles(directory) {
|
|
339
|
+
if (!existsSync(directory)) return [];
|
|
340
|
+
try {
|
|
341
|
+
if (!statSync(directory).isDirectory()) return [];
|
|
342
|
+
return readdirSync(directory, { withFileTypes: true })
|
|
343
|
+
.filter((entry) => entry.isFile() && entry.name.endsWith(".md"))
|
|
344
|
+
.map((entry) => join(directory, entry.name))
|
|
345
|
+
.sort();
|
|
346
|
+
} catch {
|
|
347
|
+
return [];
|
|
348
|
+
}
|
|
349
|
+
}
|
|
350
|
+
|
|
351
|
+
export function scopeFiles(root, scope) {
|
|
352
|
+
const base = scopeRoot(root, scope);
|
|
353
|
+
const files = [];
|
|
354
|
+
const top = join(base, "GATES.md");
|
|
355
|
+
try { if (statSync(top).isFile()) files.push(top); } catch { /* absent */ }
|
|
356
|
+
files.push(...markdownFiles(join(base, "gates")));
|
|
357
|
+
return files;
|
|
358
|
+
}
|
|
359
|
+
|
|
360
|
+
export function legacyFiles(root) {
|
|
361
|
+
const files = [];
|
|
362
|
+
const top = join(root, "GATES.md");
|
|
363
|
+
try { if (statSync(top).isFile()) files.push(top); } catch { /* absent */ }
|
|
364
|
+
files.push(...markdownFiles(join(root, "gates")));
|
|
365
|
+
return files;
|
|
366
|
+
}
|
|
367
|
+
|
|
368
|
+
export function resolveTarget(options = {}) {
|
|
369
|
+
const root = resolve(options.root || process.cwd());
|
|
370
|
+
const files = options.files || [];
|
|
371
|
+
const sessionId = options.sessionId || null;
|
|
372
|
+
if (files.length) return { mode: "explicit", scope: null, files: files.map((file) => resolve(root, file)) };
|
|
373
|
+
|
|
374
|
+
const scopes = listScopes(root);
|
|
375
|
+
const wanted = options.scope || process.env.UNLAZY_SCOPE || null;
|
|
376
|
+
if (wanted) {
|
|
377
|
+
const invalid = validateScopeId(wanted);
|
|
378
|
+
if (invalid) return { mode: "none", scope: wanted, files: [], error: invalid };
|
|
379
|
+
if (!scopes.includes(wanted)) {
|
|
380
|
+
return {
|
|
381
|
+
mode: "none", scope: wanted, files: [],
|
|
382
|
+
error: "no such scope \"" + wanted + "\" under " + UNLAZY_DIR + "/ (have: " +
|
|
383
|
+
(scopes.join(", ") || "none") + ")",
|
|
384
|
+
};
|
|
385
|
+
}
|
|
386
|
+
return { mode: "scope", scope: wanted, files: scopeFiles(root, wanted) };
|
|
387
|
+
}
|
|
388
|
+
|
|
389
|
+
if (scopes.length === 1) return { mode: "scope", scope: scopes[0], files: scopeFiles(root, scopes[0]) };
|
|
390
|
+
if (scopes.length > 1) {
|
|
391
|
+
if (sessionId) {
|
|
392
|
+
const owned = scopes.filter((scope) => {
|
|
393
|
+
try {
|
|
394
|
+
return readFileSync(join(scopeRoot(root, scope), "session"), "utf8").trim() === String(sessionId).trim();
|
|
395
|
+
} catch { return false; }
|
|
396
|
+
});
|
|
397
|
+
if (owned.length === 1) return { mode: "scope", scope: owned[0], files: scopeFiles(root, owned[0]) };
|
|
398
|
+
}
|
|
399
|
+
return {
|
|
400
|
+
mode: "none", scope: null, files: [], ambiguous: scopes,
|
|
401
|
+
error: scopes.length + " pipelines present (" + scopes.join(", ") +
|
|
402
|
+
"); pass --scope <id> or set UNLAZY_SCOPE. Refusing to guess.",
|
|
403
|
+
};
|
|
404
|
+
}
|
|
405
|
+
|
|
406
|
+
const legacy = legacyFiles(root);
|
|
407
|
+
if (legacy.length) return { mode: "legacy", scope: null, files: legacy };
|
|
408
|
+
return { mode: "none", scope: null, files: [] };
|
|
409
|
+
}
|
|
410
|
+
|
|
411
|
+
export function statusLogPath(root, scope) {
|
|
412
|
+
return scope ? join(scopeRoot(root, scope), "status.log") : join(root, "unlazy-status.log");
|
|
413
|
+
}
|
|
414
|
+
|
|
415
|
+
export function hookStatePath(root, scope) {
|
|
416
|
+
return scope ? join(scopeRoot(root, scope), "hook-state.json") : join(root, ".unlazy-hook-state.json");
|
|
417
|
+
}
|
|
418
|
+
|
|
419
|
+
function assertSafeStatePath(root, target) {
|
|
420
|
+
const stateRoot = join(resolve(root), UNLAZY_DIR);
|
|
421
|
+
if (existsSync(stateRoot)) {
|
|
422
|
+
const info = lstatSync(stateRoot);
|
|
423
|
+
if (info.isSymbolicLink() || !info.isDirectory()) throw new Error(stateRoot + " must be a real directory, not a link or file");
|
|
424
|
+
}
|
|
425
|
+
const parent = dirname(target);
|
|
426
|
+
mkdirSync(parent, { recursive: true, mode: 0o700 });
|
|
427
|
+
const info = lstatSync(parent);
|
|
428
|
+
if (info.isSymbolicLink() || !info.isDirectory()) throw new Error(parent + " must be a real directory");
|
|
429
|
+
}
|
|
430
|
+
|
|
431
|
+
export function writeAtomic(file, text, options = {}) {
|
|
432
|
+
const target = resolve(file);
|
|
433
|
+
if (options.root) assertSafeStatePath(options.root, target);
|
|
434
|
+
else {
|
|
435
|
+
const parent = dirname(target);
|
|
436
|
+
mkdirSync(parent, { recursive: true });
|
|
437
|
+
const info = lstatSync(parent);
|
|
438
|
+
if (info.isSymbolicLink() || !info.isDirectory()) throw new Error(parent + " must be a real directory");
|
|
439
|
+
}
|
|
440
|
+
try {
|
|
441
|
+
const existing = lstatSync(target);
|
|
442
|
+
if (existing.isSymbolicLink()) throw new Error("refusing to replace symlink " + target);
|
|
443
|
+
} catch (error) {
|
|
444
|
+
if (error.code !== "ENOENT") throw error;
|
|
445
|
+
}
|
|
446
|
+
let temp = "";
|
|
447
|
+
let fd = null;
|
|
448
|
+
for (let attempt = 0; attempt < 8; attempt++) {
|
|
449
|
+
temp = target + "." + process.pid + "." + randomBytes(8).toString("hex") + ".tmp";
|
|
450
|
+
try { fd = openSync(temp, "wx", 0o600); break; }
|
|
451
|
+
catch (error) { if (error.code !== "EEXIST") throw error; }
|
|
452
|
+
}
|
|
453
|
+
if (fd === null) throw new Error("could not create a unique temporary file for " + target);
|
|
454
|
+
try {
|
|
455
|
+
writeFileSync(fd, String(text), "utf8");
|
|
456
|
+
fsyncSync(fd);
|
|
457
|
+
closeSync(fd);
|
|
458
|
+
fd = null;
|
|
459
|
+
replaceAtomic(temp, target);
|
|
460
|
+
} finally {
|
|
461
|
+
if (fd !== null) try { closeSync(fd); } catch { /* ignore */ }
|
|
462
|
+
if (temp) try { unlinkSync(temp); } catch { /* renamed or absent */ }
|
|
463
|
+
}
|
|
464
|
+
}
|
|
465
|
+
|
|
466
|
+
function lockDirectory(root) {
|
|
467
|
+
const directory = join(resolve(root), LOCK_DIR);
|
|
468
|
+
assertSafeStatePath(root, directory);
|
|
469
|
+
mkdirSync(directory, { recursive: true, mode: 0o700 });
|
|
470
|
+
const info = lstatSync(directory);
|
|
471
|
+
if (info.isSymbolicLink() || !info.isDirectory()) throw new Error(directory + " must be a real directory");
|
|
472
|
+
return directory;
|
|
473
|
+
}
|
|
474
|
+
|
|
475
|
+
export async function withFileLock(root, target, fn, options = {}) {
|
|
476
|
+
const timeoutMs = options.timeoutMs === undefined ? 30000 : options.timeoutMs;
|
|
477
|
+
const lock = join(lockDirectory(root), sha256(resolve(target)).slice(0, 24) + ".filelock");
|
|
478
|
+
const deadline = Date.now() + timeoutMs;
|
|
479
|
+
const token = randomBytes(16).toString("hex");
|
|
480
|
+
let fd = null;
|
|
481
|
+
for (;;) {
|
|
482
|
+
try { fd = openSync(lock, "wx", 0o600); break; }
|
|
483
|
+
catch (error) {
|
|
484
|
+
// On Windows, opening or inspecting an existing file held by another
|
|
485
|
+
// process can surface as EPERM/EACCES/EBUSY rather than EEXIST. Treat
|
|
486
|
+
// only those platform-specific sharing errors as lock contention.
|
|
487
|
+
if (error.code !== "EEXIST" && !isTransientWindowsFsError(error)) throw error;
|
|
488
|
+
// Never unlink a lock observed by path: between stat and unlink its
|
|
489
|
+
// prior owner can release and a successor can acquire the same name
|
|
490
|
+
// (the classic ABA race). Missing-after-EEXIST simply means retry. A
|
|
491
|
+
// crashed owner's lock fails closed at timeout and can be removed by a
|
|
492
|
+
// human after inspecting its JSON metadata.
|
|
493
|
+
let missing = false;
|
|
494
|
+
try { statSync(lock); } catch (statError) {
|
|
495
|
+
if (statError.code === "ENOENT") missing = true;
|
|
496
|
+
else if (!isTransientWindowsFsError(statError)) throw statError;
|
|
497
|
+
}
|
|
498
|
+
if (Date.now() >= deadline) {
|
|
499
|
+
throw new Error("timed out waiting for lock on " + target + " (last filesystem error: " + error.code + ")");
|
|
500
|
+
}
|
|
501
|
+
if (missing && error.code === "EEXIST") continue;
|
|
502
|
+
await sleep(15 + Math.floor(Math.random() * 25));
|
|
503
|
+
}
|
|
504
|
+
}
|
|
505
|
+
let identified = false;
|
|
506
|
+
try {
|
|
507
|
+
writeFileSync(fd, JSON.stringify({ token, pid: process.pid, target: resolve(target), at: Date.now() }));
|
|
508
|
+
identified = true;
|
|
509
|
+
} catch { /* leave for manual cleanup rather than risk deleting a successor */ }
|
|
510
|
+
try { return await fn(); }
|
|
511
|
+
finally {
|
|
512
|
+
try { closeSync(fd); } catch { /* ignore */ }
|
|
513
|
+
if (identified) {
|
|
514
|
+
const deadline = Date.now() + 2000;
|
|
515
|
+
let delay = 5;
|
|
516
|
+
for (;;) {
|
|
517
|
+
try {
|
|
518
|
+
const current = JSON.parse(readFileSync(lock, "utf8"));
|
|
519
|
+
if (current.token === token) unlinkSync(lock);
|
|
520
|
+
break;
|
|
521
|
+
} catch (error) {
|
|
522
|
+
if (error && error.code === "ENOENT") break;
|
|
523
|
+
const remaining = deadline - Date.now();
|
|
524
|
+
if (!isTransientWindowsFsError(error) || remaining <= 0) break;
|
|
525
|
+
await sleep(Math.min(delay, remaining));
|
|
526
|
+
delay = Math.min(delay * 2, 100);
|
|
527
|
+
}
|
|
528
|
+
}
|
|
529
|
+
}
|
|
530
|
+
}
|
|
531
|
+
}
|
|
532
|
+
|
|
533
|
+
export function appendStatus(root, scope, line) {
|
|
534
|
+
const path = statusLogPath(root, scope);
|
|
535
|
+
assertSafeStatePath(root, path);
|
|
536
|
+
let fd = null;
|
|
537
|
+
try {
|
|
538
|
+
try {
|
|
539
|
+
const before = lstatSync(path);
|
|
540
|
+
if (!before.isFile() || before.isSymbolicLink() || before.nlink !== 1) {
|
|
541
|
+
throw new Error("refusing non-file or linked status log " + path);
|
|
542
|
+
}
|
|
543
|
+
} catch (error) {
|
|
544
|
+
if (error.code !== "ENOENT") throw error;
|
|
545
|
+
}
|
|
546
|
+
// Open first but write only after proving that the named entry is the same
|
|
547
|
+
// regular file as the descriptor. A symlink swap can therefore never turn
|
|
548
|
+
// the append into a write through an outside-root target.
|
|
549
|
+
const noFollow = process.platform === "win32" ? 0 : (fsConstants.O_NOFOLLOW || 0);
|
|
550
|
+
fd = openSync(path, fsConstants.O_WRONLY | fsConstants.O_APPEND | fsConstants.O_CREAT |
|
|
551
|
+
(fsConstants.O_NONBLOCK || 0) | noFollow, 0o600);
|
|
552
|
+
const opened = fstatSync(fd);
|
|
553
|
+
const named = lstatSync(path);
|
|
554
|
+
if (!opened.isFile() || !named.isFile() || named.isSymbolicLink() ||
|
|
555
|
+
opened.nlink !== 1 || named.nlink !== 1 ||
|
|
556
|
+
opened.dev !== named.dev || opened.ino !== named.ino) {
|
|
557
|
+
throw new Error("refusing non-file or replaced status log " + path);
|
|
558
|
+
}
|
|
559
|
+
writeFileSync(fd, String(line).replace(/[\r\n]+/g, " ") + "\n", "utf8");
|
|
560
|
+
fsyncSync(fd);
|
|
561
|
+
return path;
|
|
562
|
+
} finally {
|
|
563
|
+
if (fd !== null) try { closeSync(fd); } catch { /* ignore */ }
|
|
564
|
+
}
|
|
565
|
+
}
|
|
566
|
+
|
|
567
|
+
function readLeasesUnlocked(root) {
|
|
568
|
+
const directory = join(resolve(root), LOCK_DIR);
|
|
569
|
+
if (!existsSync(directory)) return [];
|
|
570
|
+
const leases = [];
|
|
571
|
+
for (const name of readdirSync(directory).sort()) {
|
|
572
|
+
if (!name.endsWith(".lease")) continue;
|
|
573
|
+
const file = join(directory, name);
|
|
574
|
+
try {
|
|
575
|
+
const value = JSON.parse(readFileSync(file, "utf8"));
|
|
576
|
+
if (value && typeof value.scope === "string" && typeof value.leaf === "string" && Array.isArray(value.globs)) {
|
|
577
|
+
leases.push({ ...value, file });
|
|
578
|
+
}
|
|
579
|
+
} catch {
|
|
580
|
+
leases.push({ scope: "(invalid)", leaf: name, globs: ["**"], file, invalid: true });
|
|
581
|
+
}
|
|
582
|
+
}
|
|
583
|
+
return leases;
|
|
584
|
+
}
|
|
585
|
+
|
|
586
|
+
export function readLeases(root) {
|
|
587
|
+
return readLeasesUnlocked(root);
|
|
588
|
+
}
|
|
589
|
+
|
|
590
|
+
const leaseRegistry = (root) => join(resolve(root), LOCK_DIR, "lease-registry");
|
|
591
|
+
|
|
592
|
+
export async function claimLeases(root, spec) {
|
|
593
|
+
return withFileLock(root, leaseRegistry(root), () => {
|
|
594
|
+
const scopeError = validateScopeId(spec.scope);
|
|
595
|
+
const leafError = validateScopeId(spec.leaf, "leaf");
|
|
596
|
+
if (scopeError || leafError) return { ok: false, conflicts: [], error: scopeError || leafError };
|
|
597
|
+
const normalized = [];
|
|
598
|
+
for (const glob of spec.globs || []) {
|
|
599
|
+
const result = normalizeOwnsGlob(glob);
|
|
600
|
+
if (result.error) return { ok: false, conflicts: [], error: result.error };
|
|
601
|
+
normalized.push(result.value);
|
|
602
|
+
}
|
|
603
|
+
if (!normalized.length) return { ok: false, conflicts: [], error: "no OWNS paths to claim" };
|
|
604
|
+
|
|
605
|
+
const conflicts = [];
|
|
606
|
+
for (const glob of normalized) {
|
|
607
|
+
for (const held of readLeasesUnlocked(root)) {
|
|
608
|
+
const theirGlob = held.globs.find((other) => globsOverlap(glob, other));
|
|
609
|
+
if (theirGlob) conflicts.push({ glob, with: held.scope + "/" + held.leaf, theirGlob });
|
|
610
|
+
}
|
|
611
|
+
}
|
|
612
|
+
if (conflicts.length) return { ok: false, conflicts };
|
|
613
|
+
const file = join(lockDirectory(root), sha256(spec.scope + "::" + spec.leaf).slice(0, 24) + ".lease");
|
|
614
|
+
writeAtomic(file, JSON.stringify({ scope: spec.scope, leaf: spec.leaf, globs: normalized, pid: process.pid }, null, 2) + "\n", { root });
|
|
615
|
+
return { ok: true, file, conflicts: [], globs: normalized };
|
|
616
|
+
});
|
|
617
|
+
}
|
|
618
|
+
|
|
619
|
+
export async function releaseLeases(root, spec) {
|
|
620
|
+
return withFileLock(root, leaseRegistry(root), () => {
|
|
621
|
+
let count = 0;
|
|
622
|
+
for (const lease of readLeasesUnlocked(root)) {
|
|
623
|
+
if (lease.scope !== spec.scope) continue;
|
|
624
|
+
if (spec.leaf && lease.leaf !== spec.leaf) continue;
|
|
625
|
+
try { unlinkSync(lease.file); count++; } catch { /* raced or absent */ }
|
|
626
|
+
}
|
|
627
|
+
return count;
|
|
628
|
+
});
|
|
629
|
+
}
|