@ouro.bot/cli 0.1.0-alpha.1469 → 0.1.0-alpha.1470
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/README.md +1 -1
- package/changelog.json +6 -2
- package/deploy/unraid/sanctuary.ouro/bundle-meta.json +1 -1
- package/deploy/unraid/sanctuary.xml +1 -1
- package/desk.lock.json +8 -0
- package/dist/heart/identity.js +27 -1
- package/dist/mind/desk-section.js +33 -43
- package/dist/repertoire/desk-mcp.js +140 -0
- package/dist/repertoire/mcp-manager.js +22 -0
- package/dist/repertoire/mcp-tools.js +11 -7
- package/npm-shrinkwrap.json +2 -2
- package/package.json +4 -1
- package/vendor/desk/.claude-plugin/plugin.json +35 -0
- package/vendor/desk/.mcp.claude-codex.json +28 -0
- package/vendor/desk/.mcp.copilot.json +16 -0
- package/vendor/desk/.ouro-desk.json +6 -0
- package/vendor/desk/CHANGELOG.md +7004 -0
- package/vendor/desk/README.md +195 -0
- package/vendor/desk/activation/README.md +98 -0
- package/vendor/desk/activation/copilot-root.flattened-bundle.json +38 -0
- package/vendor/desk/activation/desk.activation.json +251 -0
- package/vendor/desk/activation/host-capability-evidence.md +46 -0
- package/vendor/desk/activation/support-matrix.json +84 -0
- package/vendor/desk/agency.json +20 -0
- package/vendor/desk/agents/observer.agent.md +26 -0
- package/vendor/desk/agents/observer.md +29 -0
- package/vendor/desk/agents/worker.agent.md +32 -0
- package/vendor/desk/agents/worker.md +40 -0
- package/vendor/desk/artifacts/tombstones/tombstone.schema.json +53 -0
- package/vendor/desk/artifacts/tombstones/tombstones.jsonl +1 -0
- package/vendor/desk/changelog.d/README.md +12 -0
- package/vendor/desk/docs/agent-files.md +104 -0
- package/vendor/desk/docs/agentic-engineering-v2-rfc.md +206 -0
- package/vendor/desk/docs/agentic-engineering-v3-rfc.md +109 -0
- package/vendor/desk/docs/browser-remote-desktops.md +69 -0
- package/vendor/desk/docs/dependency-activation-stories-and-criteria.md +500 -0
- package/vendor/desk/docs/evaluation-packet.md +363 -0
- package/vendor/desk/docs/factory-local-capture.md +651 -0
- package/vendor/desk/docs/factory-store-playbook.md +927 -0
- package/vendor/desk/docs/images/factory-site.png +0 -0
- package/vendor/desk/docs/issue-drains.md +79 -0
- package/vendor/desk/docs/lfs-inspection.md +55 -0
- package/vendor/desk/docs/preview-diagnostics.md +11 -0
- package/vendor/desk/docs/relays.md +88 -0
- package/vendor/desk/docs/schedules.md +69 -0
- package/vendor/desk/docs/search-recovery.md +22 -0
- package/vendor/desk/docs/session-labels.md +157 -0
- package/vendor/desk/docs/session-retention.md +125 -0
- package/vendor/desk/docs/sessions.md +17 -0
- package/vendor/desk/docs/stalled-nudges.md +54 -0
- package/vendor/desk/docs/webhooks.md +80 -0
- package/vendor/desk/docs/workspace-tidy.md +74 -0
- package/vendor/desk/hooks/boot-checks.cjs +7 -0
- package/vendor/desk/hooks/claude-session-start.cjs +123 -0
- package/vendor/desk/hooks/compatible-node.cjs +97 -0
- package/vendor/desk/hooks/copilot-boot-prompt.cjs +69 -0
- package/vendor/desk/hooks/copilot-durable-files.cjs +8 -0
- package/vendor/desk/hooks/copilot-hooks.json +61 -0
- package/vendor/desk/hooks/copilot-intake-context.cjs +5 -0
- package/vendor/desk/hooks/copilot-lane-model.cjs +8 -0
- package/vendor/desk/hooks/copilot-session-start.cjs +264 -0
- package/vendor/desk/hooks/copilot-skill-current.cjs +28 -0
- package/vendor/desk/hooks/factory-end.cjs +5 -0
- package/vendor/desk/hooks/factory-start.cjs +27 -0
- package/vendor/desk/hooks/hooks.json +40 -0
- package/vendor/desk/hooks/lib/boot-checks.cjs +643 -0
- package/vendor/desk/hooks/lib/child-agent.cjs +14 -0
- package/vendor/desk/hooks/lib/copilot-intake-context.cjs +73 -0
- package/vendor/desk/hooks/lib/current-release.cjs +162 -0
- package/vendor/desk/hooks/lib/delivery-stop.cjs +326 -0
- package/vendor/desk/hooks/lib/detach-worker.cjs +43 -0
- package/vendor/desk/hooks/lib/durable-files.cjs +102 -0
- package/vendor/desk/hooks/lib/factory-end.cjs +327 -0
- package/vendor/desk/hooks/lib/lane-model.cjs +82 -0
- package/vendor/desk/hooks/lib/node-required.cjs +56 -0
- package/vendor/desk/hooks/lib/orca-session-title.cjs +60 -0
- package/vendor/desk/hooks/lib/session-end.cjs +30 -0
- package/vendor/desk/hooks/lib/sync-end.cjs +89 -0
- package/vendor/desk/hooks/loop-start.cjs +105 -0
- package/vendor/desk/hooks/node-missing.sh +78 -0
- package/vendor/desk/hooks/orca-session-title.cjs +8 -0
- package/vendor/desk/hooks/session-end.cjs +8 -0
- package/vendor/desk/mcp/README.md +269 -0
- package/vendor/desk/mcp/artifacts/runtime-deps/1.4.0-alpha.6/darwin-arm64-node-127/3b0cb8b1e7dd77a982b38375fe88a5278bd77974213e18be025d7dc8deea800f/runtime-deps.manifest.json +881 -0
- package/vendor/desk/mcp/artifacts/runtime-deps/1.4.0-alpha.6/darwin-arm64-node-127/3b0cb8b1e7dd77a982b38375fe88a5278bd77974213e18be025d7dc8deea800f/runtime-deps.sha256 +1 -0
- package/vendor/desk/mcp/artifacts/runtime-deps/1.4.0-alpha.6/darwin-arm64-node-127/3b0cb8b1e7dd77a982b38375fe88a5278bd77974213e18be025d7dc8deea800f/runtime-deps.tgz +0 -0
- package/vendor/desk/mcp/artifacts/runtime-deps/1.4.0-alpha.6/darwin-arm64-node-137/3b0cb8b1e7dd77a982b38375fe88a5278bd77974213e18be025d7dc8deea800f/runtime-deps.manifest.json +881 -0
- package/vendor/desk/mcp/artifacts/runtime-deps/1.4.0-alpha.6/darwin-arm64-node-137/3b0cb8b1e7dd77a982b38375fe88a5278bd77974213e18be025d7dc8deea800f/runtime-deps.sha256 +1 -0
- package/vendor/desk/mcp/artifacts/runtime-deps/1.4.0-alpha.6/darwin-arm64-node-137/3b0cb8b1e7dd77a982b38375fe88a5278bd77974213e18be025d7dc8deea800f/runtime-deps.tgz +0 -0
- package/vendor/desk/mcp/artifacts/runtime-deps/1.4.0-alpha.6/linux-x64-node-127/3b0cb8b1e7dd77a982b38375fe88a5278bd77974213e18be025d7dc8deea800f/runtime-deps.manifest.json +881 -0
- package/vendor/desk/mcp/artifacts/runtime-deps/1.4.0-alpha.6/linux-x64-node-127/3b0cb8b1e7dd77a982b38375fe88a5278bd77974213e18be025d7dc8deea800f/runtime-deps.sha256 +1 -0
- package/vendor/desk/mcp/artifacts/runtime-deps/1.4.0-alpha.6/linux-x64-node-127/3b0cb8b1e7dd77a982b38375fe88a5278bd77974213e18be025d7dc8deea800f/runtime-deps.tgz +0 -0
- package/vendor/desk/mcp/artifacts/runtime-deps/1.4.0-alpha.6/linux-x64-node-137/3b0cb8b1e7dd77a982b38375fe88a5278bd77974213e18be025d7dc8deea800f/runtime-deps.manifest.json +881 -0
- package/vendor/desk/mcp/artifacts/runtime-deps/1.4.0-alpha.6/linux-x64-node-137/3b0cb8b1e7dd77a982b38375fe88a5278bd77974213e18be025d7dc8deea800f/runtime-deps.sha256 +1 -0
- package/vendor/desk/mcp/artifacts/runtime-deps/1.4.0-alpha.6/linux-x64-node-137/3b0cb8b1e7dd77a982b38375fe88a5278bd77974213e18be025d7dc8deea800f/runtime-deps.tgz +0 -0
- package/vendor/desk/mcp/artifacts/runtime-deps/1.4.0-alpha.6/linux-x64-node-147/3b0cb8b1e7dd77a982b38375fe88a5278bd77974213e18be025d7dc8deea800f/runtime-deps.manifest.json +881 -0
- package/vendor/desk/mcp/artifacts/runtime-deps/1.4.0-alpha.6/linux-x64-node-147/3b0cb8b1e7dd77a982b38375fe88a5278bd77974213e18be025d7dc8deea800f/runtime-deps.sha256 +1 -0
- package/vendor/desk/mcp/artifacts/runtime-deps/1.4.0-alpha.6/linux-x64-node-147/3b0cb8b1e7dd77a982b38375fe88a5278bd77974213e18be025d7dc8deea800f/runtime-deps.tgz +0 -0
- package/vendor/desk/mcp/artifacts/runtime-deps/1.4.0-alpha.6/support-matrix.json +72 -0
- package/vendor/desk/mcp/artifacts/runtime-deps/1.4.0-alpha.6/win32-x64-node-137/3b0cb8b1e7dd77a982b38375fe88a5278bd77974213e18be025d7dc8deea800f/runtime-deps.manifest.json +881 -0
- package/vendor/desk/mcp/artifacts/runtime-deps/1.4.0-alpha.6/win32-x64-node-137/3b0cb8b1e7dd77a982b38375fe88a5278bd77974213e18be025d7dc8deea800f/runtime-deps.sha256 +1 -0
- package/vendor/desk/mcp/artifacts/runtime-deps/1.4.0-alpha.6/win32-x64-node-137/3b0cb8b1e7dd77a982b38375fe88a5278bd77974213e18be025d7dc8deea800f/runtime-deps.tgz +0 -0
- package/vendor/desk/mcp/artifacts/runtime-deps/1.4.0-alpha.6/win32-x64-node-147/3b0cb8b1e7dd77a982b38375fe88a5278bd77974213e18be025d7dc8deea800f/runtime-deps.manifest.json +881 -0
- package/vendor/desk/mcp/artifacts/runtime-deps/1.4.0-alpha.6/win32-x64-node-147/3b0cb8b1e7dd77a982b38375fe88a5278bd77974213e18be025d7dc8deea800f/runtime-deps.sha256 +1 -0
- package/vendor/desk/mcp/artifacts/runtime-deps/1.4.0-alpha.6/win32-x64-node-147/3b0cb8b1e7dd77a982b38375fe88a5278bd77974213e18be025d7dc8deea800f/runtime-deps.tgz +0 -0
- package/vendor/desk/mcp/artifacts/runtime-deps/README.md +25 -0
- package/vendor/desk/mcp/bootstrap.cjs +761 -0
- package/vendor/desk/mcp/docs/private-feedback.md +13 -0
- package/vendor/desk/mcp/idle-proxy.cjs +423 -0
- package/vendor/desk/mcp/index.js +813 -0
- package/vendor/desk/mcp/package-lock.json +3717 -0
- package/vendor/desk/mcp/package.json +44 -0
- package/vendor/desk/mcp/scripts/agency-desk-channel.js +7 -0
- package/vendor/desk/mcp/scripts/build-runtime-deps-pack.js +5 -0
- package/vendor/desk/mcp/scripts/crew.js +89 -0
- package/vendor/desk/mcp/scripts/drains-launcher.mjs +329 -0
- package/vendor/desk/mcp/scripts/drains.js +5 -0
- package/vendor/desk/mcp/scripts/factory.js +657 -0
- package/vendor/desk/mcp/scripts/file-desk-problem.js +9 -0
- package/vendor/desk/mcp/scripts/finish-commit.js +7 -0
- package/vendor/desk/mcp/scripts/lfs.js +37 -0
- package/vendor/desk/mcp/scripts/local-recovery.js +363 -0
- package/vendor/desk/mcp/scripts/migrations.js +11 -0
- package/vendor/desk/mcp/scripts/private-view.js +177 -0
- package/vendor/desk/mcp/scripts/resolve-desk-root.js +106 -0
- package/vendor/desk/mcp/scripts/session-boot.js +22 -0
- package/vendor/desk/mcp/scripts/session-retention.js +5 -0
- package/vendor/desk/mcp/scripts/session-sync.js +10 -0
- package/vendor/desk/mcp/scripts/sessions.js +5 -0
- package/vendor/desk/mcp/scripts/sync-push.js +13 -0
- package/vendor/desk/mcp/scripts/tidy-status.js +8 -0
- package/vendor/desk/mcp/scripts/verify-runtime-deps-pack.js +5 -0
- package/vendor/desk/mcp/src/actions/desk-read.actions.mts +73 -0
- package/vendor/desk/mcp/src/actions/desk-session.actions.mts +42 -0
- package/vendor/desk/mcp/src/actions/desk-web.actions.mts +52 -0
- package/vendor/desk/mcp/src/actions/desk.actions.mts +5 -0
- package/vendor/desk/mcp/src/actions/generated/desk/OuroActions.swift +649 -0
- package/vendor/desk/mcp/src/actions/generated/desk/OuroActionsReins.swift +61 -0
- package/vendor/desk/mcp/src/actions/generated/desk/actions.json +280 -0
- package/vendor/desk/mcp/src/actions/generated/desk/commands.json +145 -0
- package/vendor/desk/mcp/src/actions/generated/desk/mcp.json +256 -0
- package/vendor/desk/mcp/src/actions/generated/desk/web.ts +59 -0
- package/vendor/desk/mcp/src/actions/generated/desk/webmcp.json +250 -0
- package/vendor/desk/mcp/src/actions/generated/desk-web/OuroActions.swift +241 -0
- package/vendor/desk/mcp/src/actions/generated/desk-web/OuroActionsReins.swift +25 -0
- package/vendor/desk/mcp/src/actions/generated/desk-web/actions.json +73 -0
- package/vendor/desk/mcp/src/actions/generated/desk-web/commands.json +53 -0
- package/vendor/desk/mcp/src/actions/generated/desk-web/mcp.json +83 -0
- package/vendor/desk/mcp/src/actions/generated/desk-web/web.ts +47 -0
- package/vendor/desk/mcp/src/actions/generated/desk-web/webmcp.json +81 -0
- package/vendor/desk/mcp/src/actions/served.js +5 -0
- package/vendor/desk/mcp/src/activation/admit.js +77 -0
- package/vendor/desk/mcp/src/activation/failures.js +65 -0
- package/vendor/desk/mcp/src/activation/readiness-policy.js +102 -0
- package/vendor/desk/mcp/src/activation/schema.js +17 -0
- package/vendor/desk/mcp/src/activation/superpowers-context.js +265 -0
- package/vendor/desk/mcp/src/activation/validate.js +540 -0
- package/vendor/desk/mcp/src/artifacts/tombstones.js +61 -0
- package/vendor/desk/mcp/src/crew/initiative.js +287 -0
- package/vendor/desk/mcp/src/crew/workspace.js +1259 -0
- package/vendor/desk/mcp/src/db/init.js +75 -0
- package/vendor/desk/mcp/src/db/schema.sql +83 -0
- package/vendor/desk/mcp/src/desk/active-tasks.js +408 -0
- package/vendor/desk/mcp/src/desk/card-commit-guard.js +281 -0
- package/vendor/desk/mcp/src/desk/cleanup-index.js +53 -0
- package/vendor/desk/mcp/src/desk/content-home.js +246 -0
- package/vendor/desk/mcp/src/desk/crew-config.js +102 -0
- package/vendor/desk/mcp/src/desk/crew-member.js +196 -0
- package/vendor/desk/mcp/src/desk/crew-roster.js +151 -0
- package/vendor/desk/mcp/src/desk/frontmatter-lite.js +228 -0
- package/vendor/desk/mcp/src/desk/gh-logins.js +109 -0
- package/vendor/desk/mcp/src/desk/handles.js +123 -0
- package/vendor/desk/mcp/src/desk/handoff-reference.js +35 -0
- package/vendor/desk/mcp/src/desk/improvement-authority.js +3 -0
- package/vendor/desk/mcp/src/desk/improvement-cards.js +704 -0
- package/vendor/desk/mcp/src/desk/improvement-person.js +51 -0
- package/vendor/desk/mcp/src/desk/lifecycle.js +16 -0
- package/vendor/desk/mcp/src/desk/machine-desks.js +119 -0
- package/vendor/desk/mcp/src/desk/naming.js +333 -0
- package/vendor/desk/mcp/src/desk/organization.js +592 -0
- package/vendor/desk/mcp/src/desk/resources.js +274 -0
- package/vendor/desk/mcp/src/desk/runtime-resolver.js +30 -0
- package/vendor/desk/mcp/src/desk/scratch-paths.js +44 -0
- package/vendor/desk/mcp/src/desk/step-delivery.js +140 -0
- package/vendor/desk/mcp/src/desk/steps.js +263 -0
- package/vendor/desk/mcp/src/desk/tidy.js +930 -0
- package/vendor/desk/mcp/src/desk/unsigned-deliveries.js +359 -0
- package/vendor/desk/mcp/src/factory/agent-types.js +45 -0
- package/vendor/desk/mcp/src/factory/andon-watch.js +109 -0
- package/vendor/desk/mcp/src/factory/binding.js +612 -0
- package/vendor/desk/mcp/src/factory/boot-check.js +645 -0
- package/vendor/desk/mcp/src/factory/capture-classify.js +158 -0
- package/vendor/desk/mcp/src/factory/capture-count.js +183 -0
- package/vendor/desk/mcp/src/factory/capture-flush.js +268 -0
- package/vendor/desk/mcp/src/factory/capture-publish.js +141 -0
- package/vendor/desk/mcp/src/factory/capture-schema.js +193 -0
- package/vendor/desk/mcp/src/factory/capture-sweep.js +239 -0
- package/vendor/desk/mcp/src/factory/catch-point.js +60 -0
- package/vendor/desk/mcp/src/factory/commit-resolve.js +94 -0
- package/vendor/desk/mcp/src/factory/consent-answer.js +37 -0
- package/vendor/desk/mcp/src/factory/context-capability.js +15 -0
- package/vendor/desk/mcp/src/factory/context-outbox.js +885 -0
- package/vendor/desk/mcp/src/factory/context-run.js +386 -0
- package/vendor/desk/mcp/src/factory/context-schema.js +249 -0
- package/vendor/desk/mcp/src/factory/copilot-turn-index.js +93 -0
- package/vendor/desk/mcp/src/factory/copilot-usage.js +148 -0
- package/vendor/desk/mcp/src/factory/credential.js +45 -0
- package/vendor/desk/mcp/src/factory/derive-claude.js +960 -0
- package/vendor/desk/mcp/src/factory/derive-codex.js +734 -0
- package/vendor/desk/mcp/src/factory/derive-common.js +279 -0
- package/vendor/desk/mcp/src/factory/derive-copilot.js +1057 -0
- package/vendor/desk/mcp/src/factory/derive-run.js +807 -0
- package/vendor/desk/mcp/src/factory/desk-problem-file.js +310 -0
- package/vendor/desk/mcp/src/factory/desk-problem-fingerprint.js +70 -0
- package/vendor/desk/mcp/src/factory/desk-problem-known.js +246 -0
- package/vendor/desk/mcp/src/factory/desk-problem-template.js +107 -0
- package/vendor/desk/mcp/src/factory/desk-repo.js +1223 -0
- package/vendor/desk/mcp/src/factory/desk-task-line.js +28 -0
- package/vendor/desk/mcp/src/factory/desk-visibility.js +48 -0
- package/vendor/desk/mcp/src/factory/end-hook.js +14 -0
- package/vendor/desk/mcp/src/factory/evaluate-kick.js +164 -0
- package/vendor/desk/mcp/src/factory/evaluate-run.js +678 -0
- package/vendor/desk/mcp/src/factory/evaluator-step.js +484 -0
- package/vendor/desk/mcp/src/factory/filer-launch.js +79 -0
- package/vendor/desk/mcp/src/factory/flush-health.js +26 -0
- package/vendor/desk/mcp/src/factory/flush.js +1758 -0
- package/vendor/desk/mcp/src/factory/focus.js +326 -0
- package/vendor/desk/mcp/src/factory/headless-flag.cjs +32 -0
- package/vendor/desk/mcp/src/factory/headless-flag.js +25 -0
- package/vendor/desk/mcp/src/factory/headless-ledger.js +743 -0
- package/vendor/desk/mcp/src/factory/headless.js +567 -0
- package/vendor/desk/mcp/src/factory/held-route.js +93 -0
- package/vendor/desk/mcp/src/factory/host-flags.js +36 -0
- package/vendor/desk/mcp/src/factory/improvement-verify.js +429 -0
- package/vendor/desk/mcp/src/factory/kaizen-file.js +231 -0
- package/vendor/desk/mcp/src/factory/label-binding.js +90 -0
- package/vendor/desk/mcp/src/factory/label-schema.js +426 -0
- package/vendor/desk/mcp/src/factory/local-status.js +368 -0
- package/vendor/desk/mcp/src/factory/loop-conditions.js +121 -0
- package/vendor/desk/mcp/src/factory/loop-health.js +500 -0
- package/vendor/desk/mcp/src/factory/loop-slot.js +90 -0
- package/vendor/desk/mcp/src/factory/loop-status.js +100 -0
- package/vendor/desk/mcp/src/factory/loop-switch.cjs +14 -0
- package/vendor/desk/mcp/src/factory/loop-worker-state.js +96 -0
- package/vendor/desk/mcp/src/factory/loop-worker.js +290 -0
- package/vendor/desk/mcp/src/factory/marker.js +61 -0
- package/vendor/desk/mcp/src/factory/mirror-step.js +145 -0
- package/vendor/desk/mcp/src/factory/os-protect.js +243 -0
- package/vendor/desk/mcp/src/factory/outbox.js +2231 -0
- package/vendor/desk/mcp/src/factory/outcome.js +431 -0
- package/vendor/desk/mcp/src/factory/pipeline/andon.js +319 -0
- package/vendor/desk/mcp/src/factory/pipeline/attention-rollup.js +158 -0
- package/vendor/desk/mcp/src/factory/pipeline/attention.js +146 -0
- package/vendor/desk/mcp/src/factory/pipeline/build.js +299 -0
- package/vendor/desk/mcp/src/factory/pipeline/compare.js +148 -0
- package/vendor/desk/mcp/src/factory/pipeline/formulas.js +652 -0
- package/vendor/desk/mcp/src/factory/pipeline/kaizen.js +387 -0
- package/vendor/desk/mcp/src/factory/pipeline/lifecycle-clocks.js +345 -0
- package/vendor/desk/mcp/src/factory/pipeline/normalize.js +73 -0
- package/vendor/desk/mcp/src/factory/pipeline/number-states.js +154 -0
- package/vendor/desk/mcp/src/factory/pipeline/outcomes.js +268 -0
- package/vendor/desk/mcp/src/factory/pipeline/report.js +737 -0
- package/vendor/desk/mcp/src/factory/pipeline/rollups.js +883 -0
- package/vendor/desk/mcp/src/factory/pipeline/stretches.js +523 -0
- package/vendor/desk/mcp/src/factory/pipeline/timeline.js +199 -0
- package/vendor/desk/mcp/src/factory/pipeline/validate-pr.js +238 -0
- package/vendor/desk/mcp/src/factory/pipeline/versions.js +42 -0
- package/vendor/desk/mcp/src/factory/pipeline/walk.js +1177 -0
- package/vendor/desk/mcp/src/factory/plugin-registry.js +72 -0
- package/vendor/desk/mcp/src/factory/plugin-sources.cjs +249 -0
- package/vendor/desk/mcp/src/factory/pr-green.js +77 -0
- package/vendor/desk/mcp/src/factory/process-lock.js +142 -0
- package/vendor/desk/mcp/src/factory/proof-session.js +75 -0
- package/vendor/desk/mcp/src/factory/publish.js +637 -0
- package/vendor/desk/mcp/src/factory/published-schema.js +648 -0
- package/vendor/desk/mcp/src/factory/reconcile-reasons.js +22 -0
- package/vendor/desk/mcp/src/factory/reconcile-step.js +251 -0
- package/vendor/desk/mcp/src/factory/reconcile.js +808 -0
- package/vendor/desk/mcp/src/factory/release-version.js +134 -0
- package/vendor/desk/mcp/src/factory/repo-name.js +13 -0
- package/vendor/desk/mcp/src/factory/retention.js +60 -0
- package/vendor/desk/mcp/src/factory/route-desk.js +40 -0
- package/vendor/desk/mcp/src/factory/route-issues.js +251 -0
- package/vendor/desk/mcp/src/factory/route-local.js +264 -0
- package/vendor/desk/mcp/src/factory/schema.js +957 -0
- package/vendor/desk/mcp/src/factory/session-kind.js +16 -0
- package/vendor/desk/mcp/src/factory/session-lifetime.js +56 -0
- package/vendor/desk/mcp/src/factory/session-route.js +183 -0
- package/vendor/desk/mcp/src/factory/shell-git.js +500 -0
- package/vendor/desk/mcp/src/factory/store-issues.js +143 -0
- package/vendor/desk/mcp/src/factory/store-route.js +208 -0
- package/vendor/desk/mcp/src/factory/test-state-guard.js +103 -0
- package/vendor/desk/mcp/src/factory/time.js +36 -0
- package/vendor/desk/mcp/src/factory/tool-issue-file.js +84 -0
- package/vendor/desk/mcp/src/factory/tool-kinds.js +87 -0
- package/vendor/desk/mcp/src/factory/triage-schema.js +233 -0
- package/vendor/desk/mcp/src/factory/windows-acl.js +679 -0
- package/vendor/desk/mcp/src/indexer/chunk.js +232 -0
- package/vendor/desk/mcp/src/indexer/discover.js +434 -0
- package/vendor/desk/mcp/src/indexer/exclusions.js +247 -0
- package/vendor/desk/mcp/src/indexer/index.js +167 -0
- package/vendor/desk/mcp/src/indexer/refs.js +0 -0
- package/vendor/desk/mcp/src/indexer/text-hash.js +18 -0
- package/vendor/desk/mcp/src/lib/ouro-actions/actions.claims.json +75 -0
- package/vendor/desk/mcp/src/lib/ouro-actions/dist-manifest.json +70 -0
- package/vendor/desk/mcp/src/lib/ouro-actions/ouro-actions.mts +1416 -0
- package/vendor/desk/mcp/src/lib/ouro-ui/LICENSE +21 -0
- package/vendor/desk/mcp/src/lib/ouro-ui/registry/ouro/ax/ax-claims.ts +190 -0
- package/vendor/desk/mcp/src/lib/ouro-ui/registry/ouro/ax/ax-command.ts +1020 -0
- package/vendor/desk/mcp/src/lib/ouro-ui/registry/ouro/ax/checks.ts +343 -0
- package/vendor/desk/mcp/src/lib/ouro-ui/registry/ouro/ax/cli.ts +240 -0
- package/vendor/desk/mcp/src/lib/ouro-ui/registry/ouro/ax/component.ts +430 -0
- package/vendor/desk/mcp/src/lib/ouro-ui/registry/ouro/ax/dev-commands.ts +204 -0
- package/vendor/desk/mcp/src/lib/ouro-ui/registry/ouro/ax/doctor.ts +126 -0
- package/vendor/desk/mcp/src/lib/ouro-ui/registry/ouro/ax/effects.ts +68 -0
- package/vendor/desk/mcp/src/lib/ouro-ui/registry/ouro/ax/exit-codes.ts +75 -0
- package/vendor/desk/mcp/src/lib/ouro-ui/registry/ouro/ax/help.ts +220 -0
- package/vendor/desk/mcp/src/lib/ouro-ui/registry/ouro/ax/mcp.ts +268 -0
- package/vendor/desk/mcp/src/lib/ouro-ui/registry/ouro/ax/outcome.ts +265 -0
- package/vendor/desk/mcp/src/lib/ouro-ui/registry/ouro/ax/output.ts +67 -0
- package/vendor/desk/mcp/src/lib/ouro-ui/registry/ouro/ax/precise-copy.ts +235 -0
- package/vendor/desk/mcp/src/lib/ouro-ui/registry/ouro/ax/problem.ts +124 -0
- package/vendor/desk/mcp/src/lib/ouro-ui/registry/ouro/ax/surfaces.kit.mts +8 -0
- package/vendor/desk/mcp/src/lib/ouro-ui/registry/ouro/ax/surfaces.ts +568 -0
- package/vendor/desk/mcp/src/lib/ouro-ui/registry/ouro/ax/terminal.ts +245 -0
- package/vendor/desk/mcp/src/lib/ouro-ui/registry/ouro/ax/voice.ts +136 -0
- package/vendor/desk/mcp/src/lib/ouro-ui/registry/ouro/ax/wait.ts +226 -0
- package/vendor/desk/mcp/src/lib/ouro-ui/registry/ouro/ax/work-event.ts +181 -0
- package/vendor/desk/mcp/src/lib/ouro-ui/registry/ouro/ax/xray.kit.mts +18 -0
- package/vendor/desk/mcp/src/lib/ouro-ui/registry/ouro/ax/xray.ts +2072 -0
- package/vendor/desk/mcp/src/package-metadata.js +20 -0
- package/vendor/desk/mcp/src/protected/legacy-ledger.js +55 -0
- package/vendor/desk/mcp/src/readiness/leftovers.js +75 -0
- package/vendor/desk/mcp/src/readiness/process-start.js +149 -0
- package/vendor/desk/mcp/src/runtime/admission-worker.js +194 -0
- package/vendor/desk/mcp/src/runtime/admission.js +177 -0
- package/vendor/desk/mcp/src/runtime/agency-desk-channel.js +342 -0
- package/vendor/desk/mcp/src/runtime/agents-md.js +62 -0
- package/vendor/desk/mcp/src/runtime/append-lane.js +68 -0
- package/vendor/desk/mcp/src/runtime/argv-safe-reason.js +55 -0
- package/vendor/desk/mcp/src/runtime/boot-dependencies.js +75 -0
- package/vendor/desk/mcp/src/runtime/boot-text.js +504 -0
- package/vendor/desk/mcp/src/runtime/boot.js +1677 -0
- package/vendor/desk/mcp/src/runtime/bootstrap.js +1455 -0
- package/vendor/desk/mcp/src/runtime/chunked-import.js +102 -0
- package/vendor/desk/mcp/src/runtime/copilot-commit-trailer.js +133 -0
- package/vendor/desk/mcp/src/runtime/copilot-session.js +155 -0
- package/vendor/desk/mcp/src/runtime/deliver.js +469 -0
- package/vendor/desk/mcp/src/runtime/desk-channel.js +86 -0
- package/vendor/desk/mcp/src/runtime/desk-failure.js +26 -0
- package/vendor/desk/mcp/src/runtime/desk-health.js +168 -0
- package/vendor/desk/mcp/src/runtime/desk-session.js +1451 -0
- package/vendor/desk/mcp/src/runtime/diagnostic-server.js +72 -0
- package/vendor/desk/mcp/src/runtime/diagnostics.js +241 -0
- package/vendor/desk/mcp/src/runtime/drains-cli.js +187 -0
- package/vendor/desk/mcp/src/runtime/drains.js +781 -0
- package/vendor/desk/mcp/src/runtime/elsewhere-note.js +9 -0
- package/vendor/desk/mcp/src/runtime/failure-evidence.js +21 -0
- package/vendor/desk/mcp/src/runtime/fast-refs.js +209 -0
- package/vendor/desk/mcp/src/runtime/filer-throttle.js +66 -0
- package/vendor/desk/mcp/src/runtime/focused-card.js +147 -0
- package/vendor/desk/mcp/src/runtime/front-door.js +204 -0
- package/vendor/desk/mcp/src/runtime/gate-wait.js +2 -0
- package/vendor/desk/mcp/src/runtime/git-inspection.js +201 -0
- package/vendor/desk/mcp/src/runtime/git-read-worker.js +157 -0
- package/vendor/desk/mcp/src/runtime/health.js +50 -0
- package/vendor/desk/mcp/src/runtime/hooks.js +353 -0
- package/vendor/desk/mcp/src/runtime/hosted.js +163 -0
- package/vendor/desk/mcp/src/runtime/inbox.js +102 -0
- package/vendor/desk/mcp/src/runtime/index-drift.js +118 -0
- package/vendor/desk/mcp/src/runtime/last-start.js +133 -0
- package/vendor/desk/mcp/src/runtime/lesson-section.js +92 -0
- package/vendor/desk/mcp/src/runtime/lessons-shelf.js +100 -0
- package/vendor/desk/mcp/src/runtime/lfs.js +319 -0
- package/vendor/desk/mcp/src/runtime/native-path.js +12 -0
- package/vendor/desk/mcp/src/runtime/newest-release.js +197 -0
- package/vendor/desk/mcp/src/runtime/node-selection.js +233 -0
- package/vendor/desk/mcp/src/runtime/orca-session-title.js +225 -0
- package/vendor/desk/mcp/src/runtime/other-sessions.js +183 -0
- package/vendor/desk/mcp/src/runtime/pending-migrations.js +653 -0
- package/vendor/desk/mcp/src/runtime/plugin-update.js +215 -0
- package/vendor/desk/mcp/src/runtime/pluginless-runtimes.js +34 -0
- package/vendor/desk/mcp/src/runtime/pr-publication.js +226 -0
- package/vendor/desk/mcp/src/runtime/preview-snapshot.js +23 -0
- package/vendor/desk/mcp/src/runtime/publication-mode.js +19 -0
- package/vendor/desk/mcp/src/runtime/relays.js +974 -0
- package/vendor/desk/mcp/src/runtime/release-alert.js +148 -0
- package/vendor/desk/mcp/src/runtime/remote-identity.js +140 -0
- package/vendor/desk/mcp/src/runtime/resolve-here.js +4 -0
- package/vendor/desk/mcp/src/runtime/runtime-deps-cli.js +65 -0
- package/vendor/desk/mcp/src/runtime/runtime-deps.js +1109 -0
- package/vendor/desk/mcp/src/runtime/runtime-identity.js +22 -0
- package/vendor/desk/mcp/src/runtime/runtime-swap.js +101 -0
- package/vendor/desk/mcp/src/runtime/schedules.js +235 -0
- package/vendor/desk/mcp/src/runtime/session-activity.js +190 -0
- package/vendor/desk/mcp/src/runtime/session-label.js +30 -0
- package/vendor/desk/mcp/src/runtime/session-retention.js +662 -0
- package/vendor/desk/mcp/src/runtime/session-sync.js +333 -0
- package/vendor/desk/mcp/src/runtime/session-trailer.js +126 -0
- package/vendor/desk/mcp/src/runtime/sessions-cli.js +301 -0
- package/vendor/desk/mcp/src/runtime/signoff-listed.js +81 -0
- package/vendor/desk/mcp/src/runtime/skills.js +76 -0
- package/vendor/desk/mcp/src/runtime/stale-card-lead.js +52 -0
- package/vendor/desk/mcp/src/runtime/stale-desk-refresh.js +198 -0
- package/vendor/desk/mcp/src/runtime/stale-desk.js +219 -0
- package/vendor/desk/mcp/src/runtime/stalled.js +255 -0
- package/vendor/desk/mcp/src/runtime/standing-authority.js +79 -0
- package/vendor/desk/mcp/src/runtime/startup-boot.js +341 -0
- package/vendor/desk/mcp/src/runtime/startup-resolve.js +140 -0
- package/vendor/desk/mcp/src/runtime/state-branch.js +203 -0
- package/vendor/desk/mcp/src/runtime/status-compact.js +165 -0
- package/vendor/desk/mcp/src/runtime/status-inspection-child.js +26 -0
- package/vendor/desk/mcp/src/runtime/status-inspection.js +147 -0
- package/vendor/desk/mcp/src/runtime/status-root.js +39 -0
- package/vendor/desk/mcp/src/runtime/sync-worker.js +911 -0
- package/vendor/desk/mcp/src/runtime/test-state-guard.js +107 -0
- package/vendor/desk/mcp/src/runtime/unmerged-saves.js +247 -0
- package/vendor/desk/mcp/src/runtime/workspace-claim.js +53 -0
- package/vendor/desk/mcp/src/runtime/workspace-evidence.js +96 -0
- package/vendor/desk/mcp/src/runtime/workspace-tidy.js +509 -0
- package/vendor/desk/mcp/src/search/direct-lexical.js +54 -0
- package/vendor/desk/mcp/src/search/embedder.js +108 -0
- package/vendor/desk/mcp/src/search/engine.js +406 -0
- package/vendor/desk/mcp/src/search/files-router.js +22 -0
- package/vendor/desk/mcp/src/search/old-index.js +46 -0
- package/vendor/desk/mcp/src/search/vectors.js +60 -0
- package/vendor/desk/mcp/src/server.js +389 -0
- package/vendor/desk/mcp/src/tool-names.js +73 -0
- package/vendor/desk/mcp/src/tool-refusal.cjs +35 -0
- package/vendor/desk/mcp/src/tool-schema-parts.js +12 -0
- package/vendor/desk/mcp/src/tool-schemas.js +325 -0
- package/vendor/desk/mcp/src/tools/_card-commit.js +148 -0
- package/vendor/desk/mcp/src/tools/archive-links.js +185 -0
- package/vendor/desk/mcp/src/tools/archive-move.js +18 -0
- package/vendor/desk/mcp/src/tools/archive-native-session.js +728 -0
- package/vendor/desk/mcp/src/tools/archive-state.js +513 -0
- package/vendor/desk/mcp/src/tools/delivery-gate.js +251 -0
- package/vendor/desk/mcp/src/tools/desk-save.js +444 -0
- package/vendor/desk/mcp/src/tools/doctor.js +122 -0
- package/vendor/desk/mcp/src/tools/done-evidence.js +260 -0
- package/vendor/desk/mcp/src/tools/factory-context.js +204 -0
- package/vendor/desk/mcp/src/tools/friction.js +332 -0
- package/vendor/desk/mcp/src/tools/improvement.js +156 -0
- package/vendor/desk/mcp/src/tools/lesson-lines.js +22 -0
- package/vendor/desk/mcp/src/tools/lesson-owners.js +137 -0
- package/vendor/desk/mcp/src/tools/lesson-team.js +169 -0
- package/vendor/desk/mcp/src/tools/lesson.js +254 -0
- package/vendor/desk/mcp/src/tools/local-only.js +151 -0
- package/vendor/desk/mcp/src/tools/move.js +794 -0
- package/vendor/desk/mcp/src/tools/native-stage-context.js +32 -0
- package/vendor/desk/mcp/src/tools/note.js +267 -0
- package/vendor/desk/mcp/src/tools/search.js +634 -0
- package/vendor/desk/mcp/src/tools/shared-write.js +196 -0
- package/vendor/desk/mcp/src/tools/sibling-desk.js +37 -0
- package/vendor/desk/mcp/src/tools/status.js +233 -0
- package/vendor/desk/mcp/src/tools/task-archive-due.js +9 -0
- package/vendor/desk/mcp/src/tools/task-archived-resource.js +53 -0
- package/vendor/desk/mcp/src/tools/task-body.js +141 -0
- package/vendor/desk/mcp/src/tools/task-focus.js +164 -0
- package/vendor/desk/mcp/src/tools/task-log.js +76 -0
- package/vendor/desk/mcp/src/tools/task-signoff.js +155 -0
- package/vendor/desk/mcp/src/tools/task.js +1768 -0
- package/vendor/desk/mcp/src/tools/track-row.js +89 -0
- package/vendor/desk/mcp/src/tools/track.js +240 -0
- package/vendor/desk/mcp/src/util/agency-session.cjs +29 -0
- package/vendor/desk/mcp/src/util/archive-links.js +105 -0
- package/vendor/desk/mcp/src/util/bash.js +36 -0
- package/vendor/desk/mcp/src/util/capture-record.js +73 -0
- package/vendor/desk/mcp/src/util/cas-commit.js +252 -0
- package/vendor/desk/mcp/src/util/created-dirs.js +71 -0
- package/vendor/desk/mcp/src/util/deferred-tools.js +51 -0
- package/vendor/desk/mcp/src/util/desk-owner.js +99 -0
- package/vendor/desk/mcp/src/util/env-value.js +13 -0
- package/vendor/desk/mcp/src/util/file-identity.js +40 -0
- package/vendor/desk/mcp/src/util/finish-commit.js +145 -0
- package/vendor/desk/mcp/src/util/fm.js +410 -0
- package/vendor/desk/mcp/src/util/git-config-file.js +85 -0
- package/vendor/desk/mcp/src/util/git-stage.js +440 -0
- package/vendor/desk/mcp/src/util/main-publish.js +240 -0
- package/vendor/desk/mcp/src/util/markdown-links.cjs +555 -0
- package/vendor/desk/mcp/src/util/object-input.js +59 -0
- package/vendor/desk/mcp/src/util/paths.js +647 -0
- package/vendor/desk/mcp/src/util/rank.js +189 -0
- package/vendor/desk/mcp/src/util/redact.js +92 -0
- package/vendor/desk/mcp/src/util/remove-retry.js +35 -0
- package/vendor/desk/mcp/src/util/rename-retry.js +73 -0
- package/vendor/desk/mcp/src/util/route-around.js +265 -0
- package/vendor/desk/mcp/src/util/shell-quote.js +18 -0
- package/vendor/desk/mcp/src/util/startup-direction.js +124 -0
- package/vendor/desk/mcp/src/util/state-ignore.js +33 -0
- package/vendor/desk/mcp/src/util/tool-commits.js +64 -0
- package/vendor/desk/mcp/src/util/unicode-16/LICENSE-MIT.txt +7 -0
- package/vendor/desk/mcp/src/util/unicode-16/README.md +9 -0
- package/vendor/desk/mcp/src/util/unicode-16/letter.cjs +1 -0
- package/vendor/desk/mcp/src/util/unicode-16/mark.cjs +1 -0
- package/vendor/desk/mcp/src/util/unicode-16/number.cjs +1 -0
- package/vendor/desk/mcp/web-auth.cjs +1897 -0
- package/vendor/desk/mcp/web-browser-discovery.cjs +53 -0
- package/vendor/desk/mcp/web-catalog.json +34 -0
- package/vendor/desk/mcp/web-launch.cjs +101 -0
- package/vendor/desk/mcp/web.cjs +1239 -0
- package/vendor/desk/migrations/01-move-to-ourostack-desk.md +188 -0
- package/vendor/desk/migrations/02-tidy-desk.md +87 -0
- package/vendor/desk/migrations/03-desk-release-channel.md +38 -0
- package/vendor/desk/optional/session-label/consumer.mjs +237 -0
- package/vendor/desk/optional/session-label/extension.mjs +32 -0
- package/vendor/desk/plugin.json +54 -0
- package/vendor/desk/settings.json +3 -0
- package/vendor/desk/skills/add-workspace-mcp/SKILL.md +180 -0
- package/vendor/desk/skills/adopt-inflight-work/SKILL.md +212 -0
- package/vendor/desk/skills/archive-workflow/SKILL.md +132 -0
- package/vendor/desk/skills/content-routing/SKILL.md +95 -0
- package/vendor/desk/skills/core-meeting-capture/SKILL.md +47 -0
- package/vendor/desk/skills/core-meeting-capture/references/capture-contract.md +175 -0
- package/vendor/desk/skills/curator/SKILL.md +103 -0
- package/vendor/desk/skills/delightful-decks/SKILL.md +67 -0
- package/vendor/desk/skills/desk-problem/SKILL.md +87 -0
- package/vendor/desk/skills/directory-structure/SKILL.md +169 -0
- package/vendor/desk/skills/doc-review-rigor/SKILL.md +63 -0
- package/vendor/desk/skills/draining-issues/SKILL.md +62 -0
- package/vendor/desk/skills/evaluate-release/SKILL.md +96 -0
- package/vendor/desk/skills/evidence-discipline/SKILL.md +150 -0
- package/vendor/desk/skills/factory-evaluator/SKILL.md +122 -0
- package/vendor/desk/skills/factory-task-context/SKILL.md +116 -0
- package/vendor/desk/skills/factory-work/SKILL.md +16 -0
- package/vendor/desk/skills/fast-honest-ci/SKILL.md +70 -0
- package/vendor/desk/skills/fast-honest-ci/examples.md +49 -0
- package/vendor/desk/skills/first-run-bootstrap/SKILL.md +95 -0
- package/vendor/desk/skills/friction-management/SKILL.md +98 -0
- package/vendor/desk/skills/git-hygiene/SKILL.md +253 -0
- package/vendor/desk/skills/independent-review/SKILL.md +34 -0
- package/vendor/desk/skills/interaction-style/SKILL.md +239 -0
- package/vendor/desk/skills/lesson-capture/SKILL.md +85 -0
- package/vendor/desk/skills/lesson-capture/agents-md-budget.mjs +61 -0
- package/vendor/desk/skills/online-evaluation/SKILL.md +81 -0
- package/vendor/desk/skills/operator-voice-comments/LICENSE-humanize +21 -0
- package/vendor/desk/skills/operator-voice-comments/SKILL.md +90 -0
- package/vendor/desk/skills/operator-voice-comments/human-voice.md +43 -0
- package/vendor/desk/skills/peer-pr-review/SKILL.md +104 -0
- package/vendor/desk/skills/pr-feedback-on-own-pr/SKILL.md +145 -0
- package/vendor/desk/skills/pr-review-interrogation/SKILL.md +121 -0
- package/vendor/desk/skills/pr-reviewer-audit/SKILL.md +68 -0
- package/vendor/desk/skills/pr-reviewer-audit/helpers/audit.py +335 -0
- package/vendor/desk/skills/pr-reviewer-audit/helpers/test_audit.py +486 -0
- package/vendor/desk/skills/pr-self-review/SKILL.md +86 -0
- package/vendor/desk/skills/pr-surface-hygiene/SKILL.md +105 -0
- package/vendor/desk/skills/pr-surface-hygiene/check-visual-proof.cjs +99 -0
- package/vendor/desk/skills/pr-surface-hygiene/repository-setup.md +19 -0
- package/vendor/desk/skills/pr-surface-hygiene/resources/pr-visual-proof.yml +29 -0
- package/vendor/desk/skills/pr-surface-hygiene/resources/pull-request-template.md +5 -0
- package/vendor/desk/skills/preflight-actions/SKILL.md +60 -0
- package/vendor/desk/skills/preview-feedback/SKILL.md +70 -0
- package/vendor/desk/skills/repo-handling/SKILL.md +67 -0
- package/vendor/desk/skills/rnd-lab/SKILL.md +52 -0
- package/vendor/desk/skills/runtime-symptom-investigation/SKILL.md +106 -0
- package/vendor/desk/skills/session-resumption/SKILL.md +126 -0
- package/vendor/desk/skills/session-start/SKILL.md +54 -0
- package/vendor/desk/skills/session-start/details.md +150 -0
- package/vendor/desk/skills/session-start-migrations/README.md +71 -0
- package/vendor/desk/skills/session-start-migrations/SKILL.md +108 -0
- package/vendor/desk/skills/start-task/SKILL.md +88 -0
- package/vendor/desk/skills/task-card-format/SKILL.md +198 -0
- package/vendor/desk/skills/task-lifecycle/SKILL.md +217 -0
- package/vendor/desk/skills/track-card-format/SKILL.md +90 -0
- package/vendor/desk/skills/using-desk/SKILL.md +58 -0
- package/vendor/desk/skills/using-superpowers-with-desk/SKILL.md +156 -0
- package/vendor/desk/skills/work-orchestration/SKILL.md +162 -0
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
// Refuses the real Desk state folder from a node:test run, independent of whether that run happened to load the test
|
|
2
|
+
// suite's own isolation harness (`_isolated_env.mjs`) — a defense against exactly the shape of an incident this guards
|
|
3
|
+
// against (ourostack/desk, 2026-09-29): 34 evaluate-requests files recorded under a developer's real
|
|
4
|
+
// ~/.local/state/ouroboros-skills/desk/factory/, from an agent running `node --test <file>` bare, without the
|
|
5
|
+
// `--import` that preloads isolation. `last-start.js`'s `writeLastStart` and `appendRepairLog` — the two places that
|
|
6
|
+
// module actually writes — call this right before creating anything.
|
|
7
|
+
//
|
|
8
|
+
// Duplicated from `../factory/test-state-guard.js` rather than shared: `src/factory/**` may only import `node:`
|
|
9
|
+
// built-ins and other `src/factory/**` files (see `../factory/outbox.js`'s header), so the two trees each keep their
|
|
10
|
+
// own copy of this small guard, the same way they already each keep their own copy of state-home resolution.
|
|
11
|
+
//
|
|
12
|
+
// Detection is two independent signals, either one enough:
|
|
13
|
+
//
|
|
14
|
+
// - `NODE_TEST_CONTEXT` — set by Node itself on every child test-file process under the default (per-file) isolation
|
|
15
|
+
// mode. Verified empirically on Node v22.23.3: present for a single file, multiple files and directory-discovery
|
|
16
|
+
// invocations of `node --test`. It is NOT set under `node --test --experimental-test-isolation=none` (also verified
|
|
17
|
+
// empirically), so it alone is not reliable enough to be the only signal.
|
|
18
|
+
// - The entry script's own name — `process.argv[1]` ends in `.test.js`, `.test.cjs` or `.test.mjs`. Verified present
|
|
19
|
+
// in every invocation shape above, including `--experimental-test-isolation=none`, and even a bare `node
|
|
20
|
+
// some.test.js` with no `--test` flag at all (node:test's `test()` still runs immediately). This is the signal that
|
|
21
|
+
// closes the `--experimental-test-isolation=none` gap; a controller ruling's suggested alternative — checking
|
|
22
|
+
// `--test` in `process.argv`/`process.execArgv` — was tried first and never appears in either array in any invocation
|
|
23
|
+
// shape tested, so it was dropped in favor of this one.
|
|
24
|
+
//
|
|
25
|
+
// A resolved state directory that is itself under the OS temp directory is always allowed (this is exactly where the
|
|
26
|
+
// isolation harness points HOME/XDG_STATE_HOME), and so is a caller that explicitly opts in.
|
|
27
|
+
|
|
28
|
+
import { realpathSync } from "node:fs"
|
|
29
|
+
import * as os from "node:os"
|
|
30
|
+
import * as path from "node:path"
|
|
31
|
+
|
|
32
|
+
export const DESK_TEST_REAL_STATE = "DESK_TEST_REAL_STATE"
|
|
33
|
+
export const DESK_ALLOW_REAL_STATE_IN_TEST = "DESK_ALLOW_REAL_STATE_IN_TEST"
|
|
34
|
+
|
|
35
|
+
const TEST_ENTRY_FILE = /\.test\.(?:js|cjs|mjs)$/u
|
|
36
|
+
|
|
37
|
+
// `platform` is injectable (defaults to `process.platform`, the same shape `../factory/outbox.js`'s own
|
|
38
|
+
// `factoryStateRoot` already uses for its Windows-only branches) so a test can exercise the win32 case-folding on any
|
|
39
|
+
// OS — the coverage gate's own run never is Windows.
|
|
40
|
+
function fold(value, platform) {
|
|
41
|
+
return platform === "win32" ? value.toLowerCase() : value
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
function hasText(value) {
|
|
45
|
+
return typeof value === "string" && value.trim() !== ""
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
function inside(child, parent, platform) {
|
|
49
|
+
const relative = path.relative(fold(parent, platform), fold(child, platform))
|
|
50
|
+
return relative === "" || (!relative.startsWith("..") && !path.isAbsolute(relative))
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
// `realpathSync.native` asks the operating system, so on Windows it expands an 8.3 short name such as C:\\Users\\RUNNER~1
|
|
54
|
+
// to the long spelling a test's own `fs.promises.realpath` returns. The JavaScript `realpathSync` leaves the short name alone.
|
|
55
|
+
export function tmpdirSpellingsOf(target, { realpath = realpathSync, native = realpathSync.native } = {}) {
|
|
56
|
+
const out = new Set([target])
|
|
57
|
+
for (const resolve of [realpath, native]) {
|
|
58
|
+
try {
|
|
59
|
+
out.add(resolve(target))
|
|
60
|
+
} catch {
|
|
61
|
+
// A temp directory that cannot be resolved adds no further spelling.
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
return out
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
// os.tmpdir() does not change for the life of a process (Node reads it fresh from the environment on every call, but
|
|
68
|
+
// nothing in this codebase mutates TMPDIR/TEMP/TMP after start), so its realpath spellings are computed once, lazily,
|
|
69
|
+
// rather than on every isUnderOsTmpdir call. This guard sits on `last-start.js`'s two write points and runs on every
|
|
70
|
+
// call once a node:test run is detected (see looksLikeNodeTestRunner below); a repeated realpathSync syscall there
|
|
71
|
+
// was measurable on a loaded CI runner (ourostack/desk PR #101, 2026-09-29).
|
|
72
|
+
let cachedTmpdirSpellings
|
|
73
|
+
function tmpdirSpellings() {
|
|
74
|
+
if (!cachedTmpdirSpellings) cachedTmpdirSpellings = tmpdirSpellingsOf(os.tmpdir())
|
|
75
|
+
return cachedTmpdirSpellings
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
/** True when this process looks like a node:test test-file run, by either signal above. */
|
|
79
|
+
export function looksLikeNodeTestRunner(env = process.env) {
|
|
80
|
+
if (hasText(env.NODE_TEST_CONTEXT)) return true
|
|
81
|
+
const entry = process.argv[1]
|
|
82
|
+
return typeof entry === "string" && TEST_ENTRY_FILE.test(entry)
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
/** True when `dir` (an already-resolved absolute path) sits under the OS temp directory, in either spelling. */
|
|
86
|
+
export function isUnderOsTmpdir(dir, { platform = process.platform } = {}) {
|
|
87
|
+
for (const root of tmpdirSpellings()) {
|
|
88
|
+
if (inside(dir, root, platform)) return true
|
|
89
|
+
}
|
|
90
|
+
return false
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
/**
|
|
94
|
+
* Refuses `dir` as the state directory when this process looks like a node:test run and `dir` is not under the OS
|
|
95
|
+
* temp directory — unless the caller set `DESK_ALLOW_REAL_STATE_IN_TEST`. Throws an `Error` with `.code =
|
|
96
|
+
* DESK_TEST_REAL_STATE`; never throws otherwise.
|
|
97
|
+
*/
|
|
98
|
+
export function assertNotRealStateUnderTest(dir, { env = process.env, platform = process.platform } = {}) {
|
|
99
|
+
if (!looksLikeNodeTestRunner(env)) return
|
|
100
|
+
if (hasText(env[DESK_ALLOW_REAL_STATE_IN_TEST])) return
|
|
101
|
+
if (isUnderOsTmpdir(path.resolve(dir), { platform })) return
|
|
102
|
+
const error = Object.assign(new Error(
|
|
103
|
+
`Resolve state under the OS temp directory in tests, or set ${DESK_ALLOW_REAL_STATE_IN_TEST}=1 to override. ` +
|
|
104
|
+
`Test isolation refused the real Desk state folder (${dir}) from what looks like a node:test run.`), { code: "test_state_guard_resolve_state_under_the_os" })
|
|
105
|
+
error.code = DESK_TEST_REAL_STATE
|
|
106
|
+
throw error
|
|
107
|
+
}
|
|
@@ -0,0 +1,247 @@
|
|
|
1
|
+
// A save that went out as a publication pull request is not on the desk's main until that PR merges. This module keeps the
|
|
2
|
+
// record of those PRs (in the desk's sync status, so every session on the desk and `drains status` read the same one), says
|
|
3
|
+
// loudly which of them has been waiting past ten minutes, and settles them: a PR whose changes are already on main is closed
|
|
4
|
+
// as superseded with the evidence, a PR that conflicts with main is rebuilt on the newest main and published again (append-only
|
|
5
|
+
// logs and cards merge), a conflict in the content itself stays open and is named with its files, and every open desk/publish/*
|
|
6
|
+
// PR of the repository that conflicts is found and settled even when this machine never recorded it.
|
|
7
|
+
|
|
8
|
+
import { readdirSync, readFileSync } from "node:fs"
|
|
9
|
+
import * as path from "node:path"
|
|
10
|
+
|
|
11
|
+
import { deliveryPaths, removeWorktree, replay, runner, upstreamOf } from "./deliver.js"
|
|
12
|
+
import { resolveDeskStateDir } from "./last-start.js"
|
|
13
|
+
import { publicationPolicy, publishPullRequest, repository } from "./pr-publication.js"
|
|
14
|
+
import { readSyncStatus, updateSyncStatus } from "./sync-worker.js"
|
|
15
|
+
|
|
16
|
+
const STUCK_AFTER_MS = 10 * 60 * 1000
|
|
17
|
+
const OBJECT_ID = /^[0-9a-f]{40}(?:[0-9a-f]{24})?$/u
|
|
18
|
+
const KEY = "unmerged_saves"
|
|
19
|
+
const NETWORK_TIMEOUT_MS = 60_000
|
|
20
|
+
|
|
21
|
+
const entries = (record) => (Array.isArray(record?.[KEY]) ? record[KEY].filter((save) => typeof save?.url === "string" && typeof save.since === "string") : [])
|
|
22
|
+
|
|
23
|
+
/** The registry callers hand to `publishPullRequest` for the desk at `root`. */
|
|
24
|
+
export function savesFor({ root, env, now }) {
|
|
25
|
+
return { record: (receipt) => recordUnmerged({ root, env, receipt, at: now() }), clear: (receipt) => clearUnmerged({ root, env, url: receipt.url }) }
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
/** Notes a publication PR as waiting to merge; the first time it was noted stays its start. Never throws. */
|
|
29
|
+
function recordUnmerged({ root, env, receipt, at }) {
|
|
30
|
+
try {
|
|
31
|
+
updateSyncStatus(root, env, (current) => {
|
|
32
|
+
const list = entries(current)
|
|
33
|
+
if (list.some((save) => save.url === receipt.url)) return {}
|
|
34
|
+
return { [KEY]: [...list, { url: receipt.url, head: receipt.head, branch: receipt.branch, base: receipt.base, since: new Date(at).toISOString() }] }
|
|
35
|
+
})
|
|
36
|
+
} catch {
|
|
37
|
+
// The record only makes a waiting save louder; losing it never fails the save.
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
/** Forgets a PR that merged or was closed. Never throws. */
|
|
42
|
+
function clearUnmerged({ root, env, url }) {
|
|
43
|
+
try {
|
|
44
|
+
updateSyncStatus(root, env, (current) => ({ [KEY]: entries(current).filter((save) => save.url !== url) }))
|
|
45
|
+
} catch {
|
|
46
|
+
// See recordUnmerged.
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
const stuckOf = (list, at) => list.map((save) => ({ ...save, minutes: Math.floor((at - Date.parse(save.since)) / 60_000) })).filter((save) => save.minutes * 60_000 >= STUCK_AFTER_MS)
|
|
51
|
+
|
|
52
|
+
/** The desk's saves still unmerged after ten minutes, oldest first, each `{ url, head, branch, base, since, minutes }`. Local read. */
|
|
53
|
+
export function stuckSaves({ root, env, now }) {
|
|
54
|
+
return stuckOf(entries(readSyncStatus({ root, env })), now()).sort((a, b) => Date.parse(a.since) - Date.parse(b.since))
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
/** The stuck saves of every desk on this machine, for `drains status`. Never throws. */
|
|
58
|
+
export function allStuckSaves({ env, now }) {
|
|
59
|
+
try {
|
|
60
|
+
const dir = path.join(resolveDeskStateDir({ env }), "sync")
|
|
61
|
+
const found = []
|
|
62
|
+
for (const name of readdirSync(dir).filter((file) => file.endsWith(".status.json"))) {
|
|
63
|
+
let record = null
|
|
64
|
+
try { record = JSON.parse(readFileSync(path.join(dir, name), "utf8")) } catch { continue }
|
|
65
|
+
found.push(...stuckOf(entries(record), now()))
|
|
66
|
+
}
|
|
67
|
+
return found.sort((a, b) => Date.parse(a.since) - Date.parse(b.since))
|
|
68
|
+
} catch {
|
|
69
|
+
return []
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
/** Notes the files a save's pull request conflicts on with main, which Desk could not merge by itself. */
|
|
74
|
+
function markConflict({ root, env, url, files }) {
|
|
75
|
+
updateSyncStatus(root, env, (current) => {
|
|
76
|
+
const list = entries(current)
|
|
77
|
+
return { [KEY]: [...list.filter((save) => save.url !== url), { ...list.find((save) => save.url === url), conflict: { files } }] }
|
|
78
|
+
})
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
const conflictFiles = (save) => save.conflict?.files ?? []
|
|
82
|
+
|
|
83
|
+
/** One plain sentence per stuck save, naming its PR link, and the files that conflict when Desk could not merge them. */
|
|
84
|
+
export const stuckLine = (save) => conflictFiles(save).length > 0
|
|
85
|
+
? `Desk save not on main after ${save.minutes} min: ${save.url} conflicts with main in ${conflictFiles(save).join(", ")}, which Desk cannot merge by itself; open the pull request, resolve the conflict and merge it`
|
|
86
|
+
: `Desk save not on main after ${save.minutes} min: ${save.url} (the pull request is still open; Desk rebases it and the merge-when-green relay merges it once its checks are green)`
|
|
87
|
+
|
|
88
|
+
/** `reply` with the stuck saves named, when there are any. A reply that is not an object, or a call with no desk, is returned as it is. */
|
|
89
|
+
export function withStuckSaves(reply, { root, env, now }) {
|
|
90
|
+
if (typeof root !== "string" || reply === null || typeof reply !== "object" || Array.isArray(reply)) return reply
|
|
91
|
+
const stuck = stuckSaves({ root, env, now })
|
|
92
|
+
if (stuck.length === 0) return reply
|
|
93
|
+
return {
|
|
94
|
+
...reply,
|
|
95
|
+
desk_unmerged_saves: stuck.map((save) => ({ pr: save.url, minutes: save.minutes, ...(conflictFiles(save).length > 0 ? { conflicts: conflictFiles(save) } : {}) })),
|
|
96
|
+
desk_unmerged_note: `${stuck.map(stuckLine).join("; ")}. Tell the operator this save is not merged yet; do not report it as merged.`,
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
// The lines a save's pull request adds, and the file's text on `commit`, for the supersession check.
|
|
101
|
+
const FRONTMATTER_KEY = /^([A-Za-z][\w-]*):(?:\s|$)/u
|
|
102
|
+
|
|
103
|
+
/**
|
|
104
|
+
* Evidence that everything a pull request commit changes is already on `main`, or null. A file counts when it is the same on
|
|
105
|
+
* main, when every line the commit adds is on main, or when the commit only sets frontmatter fields that a newer commit on
|
|
106
|
+
* main has since set differently.
|
|
107
|
+
*/
|
|
108
|
+
function supersession(git, head, main, link) {
|
|
109
|
+
const parent = `${head}^`
|
|
110
|
+
const files = git(["diff-tree", "--root", "-r", "--name-only", "--no-renames", "--no-commit-id", "-z", head]).stdout.split("\0").filter(Boolean)
|
|
111
|
+
const headTime = Number(git(["log", "-1", "--format=%ct", head]).stdout.trim())
|
|
112
|
+
const evidence = []
|
|
113
|
+
for (const file of files) {
|
|
114
|
+
const onMain = git(["cat-file", "blob", `${main}:${file}`])
|
|
115
|
+
const onHead = git(["cat-file", "blob", `${head}:${file}`])
|
|
116
|
+
if (onMain.status !== 0 || onHead.status !== 0) {
|
|
117
|
+
// Deleted by the save: superseded only when main has it gone too.
|
|
118
|
+
if (onMain.status !== 0 && onHead.status !== 0) { evidence.push(`${file} is absent on main, as the save left it`); continue }
|
|
119
|
+
return null
|
|
120
|
+
}
|
|
121
|
+
if (onMain.stdout === onHead.stdout) { evidence.push(`${file} is identical on main (${link(file)})`); continue }
|
|
122
|
+
const had = new Set(git(["cat-file", "blob", `${parent}:${file}`]).stdout.split("\n"))
|
|
123
|
+
const added = onHead.stdout.split("\n").filter((line) => line.trim() !== "" && !had.has(line))
|
|
124
|
+
const mainLines = onMain.stdout.split("\n")
|
|
125
|
+
const missing = added.filter((line) => !mainLines.includes(line))
|
|
126
|
+
if (missing.length === 0) { evidence.push(`every line the save adds to ${file} is already on main (${link(file)})`); continue }
|
|
127
|
+
const newer = Number(git(["log", "-1", "--format=%ct", main, "--", file]).stdout.trim()) > headTime
|
|
128
|
+
const replaced = missing.every((line) => {
|
|
129
|
+
const key = FRONTMATTER_KEY.exec(line)?.[1]
|
|
130
|
+
return key !== undefined && mainLines.some((other) => FRONTMATTER_KEY.exec(other)?.[1] === key)
|
|
131
|
+
})
|
|
132
|
+
if (newer && replaced) { evidence.push(`${file}: the fields the save sets were set again by newer commits on main (${link(file)})`); continue }
|
|
133
|
+
return null
|
|
134
|
+
}
|
|
135
|
+
return evidence
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
const short = (sha) => sha.slice(0, 12)
|
|
139
|
+
|
|
140
|
+
function ghRun(spawnGit, root, args) {
|
|
141
|
+
const result = spawnGit("gh", args, { cwd: root, encoding: "utf8", windowsHide: true, timeout: NETWORK_TIMEOUT_MS, env: process.env })
|
|
142
|
+
return { status: result.status, stdout: typeof result.stdout === "string" ? result.stdout : "" }
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
/** Closes a publication PR with the comment saying why, drops its branch and forgets it. Returns whether GitHub closed it. */
|
|
146
|
+
export function closeSaved({ spawnGit, root, env, url, comment }) {
|
|
147
|
+
const closed = ghRun(spawnGit, root, ["pr", "close", url, "--delete-branch", "--comment", comment]).status === 0
|
|
148
|
+
if (closed) clearUnmerged({ root, env, url })
|
|
149
|
+
return closed
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
const supersededComment = (main, evidence) => `Superseded: this save is already on main (${short(main)}), so this pull request is closed without merging. Evidence: ${evidence.join("; ")}.`
|
|
153
|
+
|
|
154
|
+
/** Why a publication PR that a rebuild replaced is closed: superseded when its content is on main without it, else rebuilt as `publication`. */
|
|
155
|
+
export const abandonedComment = ({ target, branch, publication }) => publication === undefined
|
|
156
|
+
? supersededComment(target, [`rebuilding the save on the newest ${branch} landed it directly or left nothing to add`])
|
|
157
|
+
: `Rebuilt on the newest ${branch} as ${publication.url} because ${branch} moved or this pull request conflicted; this pull request is closed in its favour.`
|
|
158
|
+
|
|
159
|
+
/**
|
|
160
|
+
* Settles every recorded save of the desk at `root` against the newest main (a network step; call it where a fetch is
|
|
161
|
+
* expected). Returns `{ closed, rebased, waiting }` (PR urls); never throws.
|
|
162
|
+
*/
|
|
163
|
+
export function settleSaves(options) {
|
|
164
|
+
try {
|
|
165
|
+
return settle(options)
|
|
166
|
+
} catch {
|
|
167
|
+
// A settle that fails leaves the saves recorded, and named.
|
|
168
|
+
return { closed: [], rebased: [], waiting: [] }
|
|
169
|
+
}
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
// Open desk/publish/* pull requests against `base` that GitHub reports as conflicting and this desk never recorded (another
|
|
173
|
+
// machine's save, or a record lost): recorded from the time they were opened, so they are as loud as any other waiting save.
|
|
174
|
+
function adoptConflicting({ spawnGit, root, env, repo, base, known }) {
|
|
175
|
+
const listed = ghRun(spawnGit, root, ["pr", "list", "--repo", repo.full, "--state", "open", "--base", base, "--limit", "200", "--json", "url,headRefName,headRefOid,baseRefName,mergeable,createdAt"])
|
|
176
|
+
for (const pr of JSON.parse(listed.stdout)) {
|
|
177
|
+
if (!pr.headRefName.startsWith("desk/publish/") || pr.mergeable !== "CONFLICTING" || known.has(pr.url)) continue
|
|
178
|
+
updateSyncStatus(root, env, (current) => ({ [KEY]: [...entries(current), { url: pr.url, head: pr.headRefOid, branch: pr.headRefName, base, since: pr.createdAt }] }))
|
|
179
|
+
}
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
function settle({ root, env, spawnGit, clock }) {
|
|
183
|
+
const outcome = { closed: [], rebased: [], waiting: [] }
|
|
184
|
+
const git = runner(spawnGit, root)
|
|
185
|
+
const upstream = upstreamOf(git)
|
|
186
|
+
let list = entries(readSyncStatus({ root, env }))
|
|
187
|
+
let repo = null
|
|
188
|
+
if (upstream !== null) {
|
|
189
|
+
try { repo = repository(git(["remote", "get-url", upstream.remote]).stdout.trim()) } catch { repo = null }
|
|
190
|
+
}
|
|
191
|
+
if (repo !== null) {
|
|
192
|
+
try {
|
|
193
|
+
adoptConflicting({ spawnGit, root, env, repo, base: upstream.merge.replace(/^refs\/heads\//u, ""), known: new Set(list.map((save) => save.url)) })
|
|
194
|
+
list = entries(readSyncStatus({ root, env }))
|
|
195
|
+
} catch {
|
|
196
|
+
// Finding strays is best effort; the recorded saves are still settled.
|
|
197
|
+
}
|
|
198
|
+
}
|
|
199
|
+
if (list.length === 0) return outcome
|
|
200
|
+
if (upstream === null || git(["fetch", "--quiet", "--no-tags", upstream.remote, `+${upstream.merge}:${upstream.tracking}`], NETWORK_TIMEOUT_MS).status !== 0) {
|
|
201
|
+
outcome.waiting.push(...list.map((save) => save.url))
|
|
202
|
+
return outcome
|
|
203
|
+
}
|
|
204
|
+
const main = git(["rev-parse", upstream.tracking]).stdout.trim()
|
|
205
|
+
for (const save of list) {
|
|
206
|
+
const viewed = ghRun(spawnGit, root, ["pr", "view", save.url, "--json", "state,mergeable"])
|
|
207
|
+
let view
|
|
208
|
+
try { view = JSON.parse(viewed.stdout) } catch { view = null }
|
|
209
|
+
if (viewed.status !== 0 || view === null) { outcome.waiting.push(save.url); continue }
|
|
210
|
+
if (view.state !== "OPEN") { clearUnmerged({ root, env, url: save.url }); continue }
|
|
211
|
+
if (git(["cat-file", "-e", `${save.head}^{commit}`]).status !== 0) git(["fetch", "--quiet", "--no-tags", upstream.remote, `refs/heads/${save.branch}`], NETWORK_TIMEOUT_MS)
|
|
212
|
+
if (git(["merge-base", "--is-ancestor", save.head, main]).status === 0) { clearUnmerged({ root, env, url: save.url }); continue }
|
|
213
|
+
const evidence = supersession(git, save.head, main, (file) => `https://${repo?.full ?? ""}/blob/${main}/${file.split("/").map(encodeURIComponent).join("/")}`)
|
|
214
|
+
if (evidence !== null) {
|
|
215
|
+
if (closeSaved({ spawnGit, root, env, url: save.url, comment: supersededComment(main, evidence) })) outcome.closed.push(save.url)
|
|
216
|
+
else outcome.waiting.push(save.url)
|
|
217
|
+
continue
|
|
218
|
+
}
|
|
219
|
+
if (view.mergeable !== "CONFLICTING") { outcome.waiting.push(save.url); continue }
|
|
220
|
+
const rebased = rebaseSave({ git, spawnGit, root, env, upstream, save, main, clock })
|
|
221
|
+
if (rebased === "rebased") outcome.rebased.push(save.url)
|
|
222
|
+
else outcome.waiting.push(save.url)
|
|
223
|
+
}
|
|
224
|
+
return outcome
|
|
225
|
+
}
|
|
226
|
+
|
|
227
|
+
// Builds the save on the newest main (Desk's card and log conflict rules apply) and publishes it again; the old PR is closed
|
|
228
|
+
// once the new one exists.
|
|
229
|
+
function rebaseSave({ git, spawnGit, root, env, upstream, save, main, clock }) {
|
|
230
|
+
let policy
|
|
231
|
+
try { policy = publicationPolicy(git, main) } catch { return "waiting" }
|
|
232
|
+
if (policy === null) return "waiting"
|
|
233
|
+
const paths = deliveryPaths({ root, env })
|
|
234
|
+
const prefix = git(["rev-parse", "--show-prefix"]).stdout.trim()
|
|
235
|
+
const built = replay({ git, spawnGit, paths, onto: main, commits: [save.head], prefix })
|
|
236
|
+
removeWorktree(git, paths)
|
|
237
|
+
if (built.skipped.length > 0) markConflict({ root, env, url: save.url, files: [...new Set(built.skipped.flatMap((skip) => skip.paths))] })
|
|
238
|
+
if (built.error !== undefined || built.skipped.length > 0 || !OBJECT_ID.test(built.head) || built.head === main) return "waiting"
|
|
239
|
+
let receipt
|
|
240
|
+
try {
|
|
241
|
+
receipt = publishPullRequest({ git, spawnGit, root, upstream, head: built.head, onto: main, policy, clock, track: savesFor({ root, env, now: Date.now }) }).receipt
|
|
242
|
+
} catch (error) {
|
|
243
|
+
receipt = error.publication
|
|
244
|
+
}
|
|
245
|
+
if (receipt === undefined) return "waiting"
|
|
246
|
+
return closeSaved({ spawnGit, root, env, url: save.url, comment: `Rebased onto ${short(main)} as ${receipt.url} because it conflicted with main; this pull request is closed in its favour.` }) ? "rebased" : "waiting"
|
|
247
|
+
}
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import { promises as fs } from "node:fs"
|
|
2
|
+
import path from "node:path"
|
|
3
|
+
import { createHash, randomUUID } from "node:crypto"
|
|
4
|
+
import { foldPath, nativeGitPath, samePath } from "./native-path.js"
|
|
5
|
+
import { readProcessStart } from "../readiness/process-start.js"
|
|
6
|
+
import { EXACT, sameFile } from "../util/file-identity.js"
|
|
7
|
+
|
|
8
|
+
// Both names are locked: a branch can be reacquired at a different path, and a
|
|
9
|
+
// worktree path can be reused with another branch. Locks outlive worktree admin.
|
|
10
|
+
// Paths from Git arrive with forward slashes on Windows; the claim works in the platform's own spelling, and two spellings of one folder (case, short name) take the same locks.
|
|
11
|
+
export async function withWorkspaceClaim({ repository: givenRepository, worktree: givenWorktree, branch, owner }, action) {
|
|
12
|
+
const repository = nativeGitPath(givenRepository)
|
|
13
|
+
const worktree = nativeGitPath(givenWorktree)
|
|
14
|
+
if (!path.isAbsolute(repository) || !path.isAbsolute(worktree) || !/^refs\/heads\/.+/u.test(branch) || typeof owner !== "string" || !owner) {
|
|
15
|
+
throw Object.assign(new Error("Pass repository, worktree, branch and owner: exact resource claim requires repository, worktree, branch and owner"), { code: "workspace_claim_pass_repository_worktree_branch_and" })
|
|
16
|
+
}
|
|
17
|
+
if (!samePath(await fs.realpath(repository), repository)) throw Object.assign(new Error("Pass the canonical repository identity: claim repository identity is not canonical"), { code: "workspace_claim_pass_the_canonical_repository_identity" })
|
|
18
|
+
const directory = path.join(repository, "desk-resource-claims")
|
|
19
|
+
await fs.mkdir(directory, { recursive: true, mode: 0o700 })
|
|
20
|
+
if (!(await fs.lstat(directory)).isDirectory()) throw Object.assign(new Error("Use a real directory for the claim: unsafe resource claim directory"), { code: "workspace_claim_use_a_real_directory_for" })
|
|
21
|
+
const token = randomUUID()
|
|
22
|
+
const record = JSON.stringify({ token, owner, repository, worktree, branch, pid: process.pid, start: await readProcessStart(process.pid) })
|
|
23
|
+
const claims = []
|
|
24
|
+
const assertHeld = async () => {
|
|
25
|
+
for (const claim of claims) {
|
|
26
|
+
const info = await fs.lstat(claim.file, EXACT)
|
|
27
|
+
if (!info.isFile() || info.nlink !== 1n || !sameFile(info, claim) ||
|
|
28
|
+
await fs.readFile(claim.file, "utf8") !== record) throw Object.assign(new Error("Run it again: exact resource claim changed; cleanup refused"), { code: "workspace_claim_run_it_again_exact_resource" })
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
try {
|
|
32
|
+
for (const identity of [`branch:${branch}`, `worktree:${foldPath(worktree)}`].sort()) {
|
|
33
|
+
const file = path.join(directory, `${createHash("sha256").update(identity).digest("hex")}.lock`)
|
|
34
|
+
let handle
|
|
35
|
+
try { handle = await fs.open(file, "wx", 0o600) } catch (error) {
|
|
36
|
+
if (error.code === "EEXIST") throw Object.assign(new Error(`Release the claim or choose another resource: resource already claimed: ${identity}`), { code: "workspace_claim_release_the_claim_or_choose" })
|
|
37
|
+
throw error
|
|
38
|
+
}
|
|
39
|
+
try {
|
|
40
|
+
await handle.writeFile(record)
|
|
41
|
+
const { dev, ino } = await handle.stat(EXACT)
|
|
42
|
+
claims.push({ file, dev, ino })
|
|
43
|
+
} finally { await handle.close() }
|
|
44
|
+
}
|
|
45
|
+
await assertHeld()
|
|
46
|
+
return await action(assertHeld)
|
|
47
|
+
} finally {
|
|
48
|
+
// A replaced/unreadable claim is not ours to remove. Preserve it for exact
|
|
49
|
+
// owner reconciliation, and never treat age or a reused PID as authority.
|
|
50
|
+
await assertHeld()
|
|
51
|
+
for (const claim of claims.reverse()) await fs.unlink(claim.file)
|
|
52
|
+
}
|
|
53
|
+
}
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
import { createHash } from "node:crypto"
|
|
2
|
+
|
|
3
|
+
const hash = (value) => createHash("sha256").update(JSON.stringify(value)).digest("hex")
|
|
4
|
+
const signed = (value) => ({ ...value, digest: hash(value) })
|
|
5
|
+
export const TIDY_REPORT_MAX_BYTES = 1_048_576
|
|
6
|
+
const REPORT_FORMAT = "workspace-tidy-compact-v1"
|
|
7
|
+
|
|
8
|
+
function requireReportCapacity(bytes) {
|
|
9
|
+
if (Buffer.byteLength(bytes) > TIDY_REPORT_MAX_BYTES) {
|
|
10
|
+
throw Object.assign(new Error("Check the retained resources and acknowledge them before cleanup: workspace-tidy evidence capacity exhausted; acknowledge retained resources before cleanup"), { code: "workspace_evidence_check_the_retained_resources_and" })
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
function requireReportShape(report) {
|
|
15
|
+
if (!Array.isArray(report.resources) || !Array.isArray(report.issues)) throw Object.assign(new Error("Run the tidy again to rebuild the compact report: invalid compact workspace-tidy report"), { code: "workspace_evidence_run_the_tidy_again_to" })
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
export function encodeTidyReport(report) {
|
|
19
|
+
requireReportShape(report)
|
|
20
|
+
const bytes = `${JSON.stringify({
|
|
21
|
+
format: REPORT_FORMAT,
|
|
22
|
+
resources: report.resources,
|
|
23
|
+
issues: report.issues,
|
|
24
|
+
root: report.root,
|
|
25
|
+
updated: report.updated,
|
|
26
|
+
line: report.line,
|
|
27
|
+
})}\n`
|
|
28
|
+
requireReportCapacity(bytes)
|
|
29
|
+
return bytes
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
export function decodeTidyReport(bytes) {
|
|
33
|
+
requireReportCapacity(bytes)
|
|
34
|
+
const report = JSON.parse(bytes)
|
|
35
|
+
if (report?.format !== REPORT_FORMAT) return report
|
|
36
|
+
requireReportShape(report)
|
|
37
|
+
return { ...report, ...mergeTidyEvidence(report, { issues: report.issues }) }
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
export function dispositionRecord(receipt, state, branchRemoved = false) {
|
|
41
|
+
const value = {
|
|
42
|
+
id: hash([receipt.repository, receipt.worktree, receipt.branch, receipt.head, receipt.owner]),
|
|
43
|
+
path: receipt.worktree, branch: receipt.branch, owner: receipt.owner, receipt, state, branchRemoved,
|
|
44
|
+
}
|
|
45
|
+
return signed(value)
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
// Resources are an outbox for canonical accounting, not a last-run cache.
|
|
49
|
+
// Even an interrupted removal keeps its write-ahead receipt until acknowledged.
|
|
50
|
+
export function mergeTidyEvidence(previous = {}, current = {}, update = null) {
|
|
51
|
+
const resources = new Map((previous.resources ?? []).map((entry) => [entry.id, entry]))
|
|
52
|
+
const observe = (observation, state) => {
|
|
53
|
+
const entry = signed({ id: hash(["observation", observation.path]), path: observation.path, state, observation })
|
|
54
|
+
resources.set(entry.id, entry)
|
|
55
|
+
}
|
|
56
|
+
if (!previous.resources) {
|
|
57
|
+
for (const entry of previous.removed ?? []) observe(entry, "legacy_removed")
|
|
58
|
+
for (const entry of previous.left ?? []) observe(entry, "reported")
|
|
59
|
+
}
|
|
60
|
+
if (update) {
|
|
61
|
+
resources.delete(hash(["observation", update.path]))
|
|
62
|
+
resources.set(update.id, update)
|
|
63
|
+
}
|
|
64
|
+
for (const entry of current.left ?? []) {
|
|
65
|
+
const owned = [...resources.values()].find((item) => item.receipt &&
|
|
66
|
+
(item.path === entry.path || `${item.receipt.repository}:${item.branch}` === entry.path))
|
|
67
|
+
if (!owned) observe(entry, "reported")
|
|
68
|
+
}
|
|
69
|
+
const entries = [...resources.values()]
|
|
70
|
+
const left = []
|
|
71
|
+
const removed = []
|
|
72
|
+
for (const entry of entries) {
|
|
73
|
+
if (entry.state === "reported") left.push(entry.observation)
|
|
74
|
+
else if (entry.state === "legacy_removed") removed.push(entry.observation)
|
|
75
|
+
else if (entry.state === "cleanup_pending") left.push({ path: entry.path, reason: "cleanup pending; reconcile persisted resource evidence" })
|
|
76
|
+
else {
|
|
77
|
+
removed.push(entry)
|
|
78
|
+
if (!entry.branchRemoved) left.push({ path: `${entry.receipt.repository}:${entry.branch}`, reason: "branch retained; owner must reconcile" })
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
return {
|
|
82
|
+
resources: entries,
|
|
83
|
+
acknowledgements: previous.acknowledgements ?? [],
|
|
84
|
+
removed,
|
|
85
|
+
left: [...new Map(left.map((entry) => [entry.path, entry])).values()],
|
|
86
|
+
issues: current.issues ?? [],
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
export function acknowledgeTidyEvidence(previous, { id, digest, canonicalEvidence }) {
|
|
91
|
+
if (typeof canonicalEvidence !== "string" || !canonicalEvidence.trim()) throw Object.assign(new Error("Pass the canonical accounting evidence: canonical accounting evidence is required"), { code: "workspace_evidence_pass_the_canonical_accounting_evidence" })
|
|
92
|
+
const resource = previous.resources?.find((entry) => entry.id === id)
|
|
93
|
+
if (!resource || resource.digest !== digest) throw Object.assign(new Error("Run it again: resource evidence changed or is missing; acknowledgement refused"), { code: "workspace_evidence_run_it_again_resource_evidence" })
|
|
94
|
+
const acknowledgements = [...(previous.acknowledgements ?? []), { id, digest, canonicalEvidence }]
|
|
95
|
+
return mergeTidyEvidence({ ...previous, resources: previous.resources.filter((entry) => entry.id !== id), acknowledgements })
|
|
96
|
+
}
|