@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,513 @@
|
|
|
1
|
+
// Scoped checks for the ordinary archive primitive, not mutation custody.
|
|
2
|
+
// Nonparticipating editors are not excluded; late failures retain actual state.
|
|
3
|
+
import { promises as fs } from "node:fs"
|
|
4
|
+
import path from "node:path"
|
|
5
|
+
import { createHash } from "node:crypto"
|
|
6
|
+
import { isPathContained } from "../util/paths.js"
|
|
7
|
+
import { indexEntries, stagePaths, commitIndexPaths } from "../util/git-stage.js"
|
|
8
|
+
import { commitFailure, commitRoute } from "../util/route-around.js"
|
|
9
|
+
import { setTaskArchiveLinks } from "./track-row.js"
|
|
10
|
+
|
|
11
|
+
const hash = (bytes) => createHash("sha256").update(bytes).digest("hex")
|
|
12
|
+
const identity = (stat) => `${stat.dev}:${stat.ino}:${stat.mode & 0o170000n}`
|
|
13
|
+
const relative = (root, file) => path.relative(root, file).split(path.sep).join("/")
|
|
14
|
+
function gitPath(git, file) {
|
|
15
|
+
if (isPathContained(git.physicalRoot, file)) return relative(git.root, file)
|
|
16
|
+
const suffix = path.relative(git.logicalRoot, file)
|
|
17
|
+
if (suffix === ".." || suffix.startsWith(`..${path.sep}`) || path.isAbsolute(suffix))
|
|
18
|
+
throw Object.assign(new Error("task_archive: Keep the path inside the desk: a Git path leaves the effective desk"), { code: "task_archive_a_git_path_leaves_the" })
|
|
19
|
+
return relative(git.root, path.resolve(git.physicalRoot, suffix))
|
|
20
|
+
}
|
|
21
|
+
async function present(file) {
|
|
22
|
+
try { return await fs.lstat(file, { bigint: true }) } catch (error) {
|
|
23
|
+
if (error.code === "ENOENT") return null
|
|
24
|
+
throw error
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
function readGit(root, args, spawnGit, input) {
|
|
28
|
+
const answer = spawnGit("git", ["-C", root, ...args], { windowsHide: true, encoding: "utf8", timeout: 10000, ...(input === undefined ? {} : { input }) })
|
|
29
|
+
if (answer.status !== 0) throw Object.assign(new Error(`task_archive: Check that Git works in this desk, then run it again: Git precondition unavailable (${args[0]}): ${answer.stderr || answer.error?.code || answer.status}`), { code: "task_archive_git_precondition_unavailable" })
|
|
30
|
+
return answer.stdout
|
|
31
|
+
}
|
|
32
|
+
function gitBoolean(root, name, spawnGit) {
|
|
33
|
+
const answer = spawnGit("git", ["-C", root, "config", "--bool", "--get", name], { windowsHide: true, encoding: "utf8", timeout: 10000 })
|
|
34
|
+
if (answer.status === 1) return true
|
|
35
|
+
if (answer.status !== 0 || !["true", "false"].includes(answer.stdout.trim()))
|
|
36
|
+
throw Object.assign(new Error(`task_archive: Check that Git works in this desk, then run it again: Git ${name} could not be qualified`), { code: "task_archive_git_could_not_be_qualified" })
|
|
37
|
+
return answer.stdout.trim() === "true"
|
|
38
|
+
}
|
|
39
|
+
// `deskRoot` is the root a successful archive schedules its push for; every route publishes exactly it (R6).
|
|
40
|
+
async function gitContext(root, spawnGit, deskRoot = root) {
|
|
41
|
+
const physicalRoot = await fs.realpath(root)
|
|
42
|
+
let marker = false
|
|
43
|
+
for (let dir = physicalRoot; ; dir = path.dirname(dir)) {
|
|
44
|
+
if (await present(path.join(dir, ".git"))) { marker = true; break }
|
|
45
|
+
if (dir === path.dirname(dir)) break
|
|
46
|
+
}
|
|
47
|
+
if (!marker) return null
|
|
48
|
+
const top = readGit(root, ["rev-parse", "--show-toplevel"], spawnGit).trim()
|
|
49
|
+
const head = spawnGit("git", ["-C", top, "rev-parse", "--verify", "-q", "HEAD"], { windowsHide: true, encoding: "utf8", timeout: 10000 })
|
|
50
|
+
if (head.status !== 0 && head.status !== 1) throw Object.assign(new Error("task_archive: Check that Git works in this desk, then run it again: HEAD could not be qualified; nothing was moved"), { code: "task_archive_head_could_not_be_qualified" })
|
|
51
|
+
return { root: top, deskRoot, logicalRoot: path.resolve(root), physicalRoot, head: head.status === 0 ? head.stdout.trim() : null,
|
|
52
|
+
fileMode: gitBoolean(top, "core.filemode", spawnGit), symlinks: gitBoolean(top, "core.symlinks", spawnGit), spawnGit }
|
|
53
|
+
}
|
|
54
|
+
function headEntries(git, folder) {
|
|
55
|
+
if (!git.head) return []
|
|
56
|
+
return readGit(git.root, ["ls-tree", "-r", "-z", git.head, "--", gitPath(git, folder)], git.spawnGit)
|
|
57
|
+
.split("\0").filter(Boolean).map((line) => {
|
|
58
|
+
const tab = line.indexOf("\t")
|
|
59
|
+
const [mode, , sha] = line.slice(0, tab).split(" ")
|
|
60
|
+
return { mode, sha, path: line.slice(tab + 1), stage: "0" }
|
|
61
|
+
})
|
|
62
|
+
}
|
|
63
|
+
function destinationVacant(git, archiveDir) {
|
|
64
|
+
const entries = indexEntries(git.root, [gitPath(git, archiveDir)], git.spawnGit)
|
|
65
|
+
if (entries === null) throw Object.assign(new Error("task_archive: Check that Git works in this desk, then run it again: archive destination index state is unavailable; nothing was moved"), { code: "task_archive_archive_destination_index_state_is" })
|
|
66
|
+
if (entries.length || headEntries(git, archiveDir).length)
|
|
67
|
+
throw Object.assign(new Error("task_archive: Remove or rename what occupies the archive destination, then run it again: archive destination is occupied in HEAD or the index (including a staged deletion); nothing was moved"), { code: "task_archive_archive_destination_is_occupied_in" })
|
|
68
|
+
}
|
|
69
|
+
async function tree(directory) {
|
|
70
|
+
const result = new Map()
|
|
71
|
+
async function visit(file, key) {
|
|
72
|
+
const before = await fs.lstat(file, { bigint: true })
|
|
73
|
+
const entry = { identity: identity(before), mode: Number(before.mode & 0o777n) }
|
|
74
|
+
if (before.isDirectory()) {
|
|
75
|
+
entry.kind = "directory"
|
|
76
|
+
result.set(key, entry)
|
|
77
|
+
for (const name of (await fs.readdir(file)).sort()) await visit(path.join(file, name), key ? `${key}/${name}` : name)
|
|
78
|
+
return
|
|
79
|
+
}
|
|
80
|
+
if (!before.isFile() && !before.isSymbolicLink()) throw Object.assign(new Error("task_archive: Remove the unsupported entry from the task folder, then run it again: an unsupported companion type cannot be admitted"), { code: "task_archive_an_unsupported_companion_type_cannot" })
|
|
81
|
+
entry.kind = before.isSymbolicLink() ? "link" : "file"
|
|
82
|
+
entry.bytes = before.isSymbolicLink() ? Buffer.from(await fs.readlink(file)) : await fs.readFile(file)
|
|
83
|
+
entry.hash = hash(entry.bytes)
|
|
84
|
+
const after = await fs.lstat(file, { bigint: true })
|
|
85
|
+
if (identity(after) !== entry.identity || before.size !== after.size ||
|
|
86
|
+
before.mtimeNs !== after.mtimeNs || before.ctimeNs !== after.ctimeNs)
|
|
87
|
+
throw Object.assign(new Error("task_archive: Run it again: source changed while its bytes were being admitted"), { code: "task_archive_source_changed_while_its_bytes" })
|
|
88
|
+
result.set(key, entry)
|
|
89
|
+
}
|
|
90
|
+
await visit(directory, "")
|
|
91
|
+
return result
|
|
92
|
+
}
|
|
93
|
+
function sameTree(actual, expected) {
|
|
94
|
+
return actual.size === expected.size && [...expected].every(([key, entry]) => {
|
|
95
|
+
const found = actual.get(key)
|
|
96
|
+
return found && found.identity === entry.identity &&
|
|
97
|
+
found.mode === entry.mode && found.hash === entry.hash
|
|
98
|
+
})
|
|
99
|
+
}
|
|
100
|
+
function cleanHash(git, file, bytes) {
|
|
101
|
+
const oid = readGit(git.root, ["hash-object", "--path", gitPath(git, file), "--stdin"], git.spawnGit, bytes).trim()
|
|
102
|
+
if (!/^(?:[a-f0-9]{40}|[a-f0-9]{64})$/u.test(oid)) throw Object.assign(new Error("task_archive: Check that Git works in this desk, then run it again: Git did not return a qualified clean blob"), { code: "task_archive_git_did_not_return_a" })
|
|
103
|
+
return oid
|
|
104
|
+
}
|
|
105
|
+
function gitMode(entry, previous, git) {
|
|
106
|
+
if (entry.kind === "link" || (previous?.mode === "120000" && !git.symlinks)) return "120000"
|
|
107
|
+
if (!git.fileMode) return previous?.mode === "100755" ? "100755" : "100644"
|
|
108
|
+
return entry.mode & 0o100 ? "100755" : "100644"
|
|
109
|
+
}
|
|
110
|
+
function blobHash(git, file, bytes, mode) {
|
|
111
|
+
return mode === "120000"
|
|
112
|
+
? readGit(git.root, ["hash-object", "--stdin"], git.spawnGit, bytes).trim()
|
|
113
|
+
: cleanHash(git, file, bytes)
|
|
114
|
+
}
|
|
115
|
+
function assertGitState(git) {
|
|
116
|
+
if (headSha(git) !== git.head) throw Object.assign(new Error("task_archive: Run it again: HEAD changed after preflight"), { code: "task_archive_head_changed_after_preflight" })
|
|
117
|
+
if (gitBoolean(git.root, "core.filemode", git.spawnGit) !== git.fileMode ||
|
|
118
|
+
gitBoolean(git.root, "core.symlinks", git.spawnGit) !== git.symlinks)
|
|
119
|
+
throw Object.assign(new Error("task_archive: Run it again: Git mode/type policy changed after preflight"), { code: "task_archive_git_mode_type_policy_changed" })
|
|
120
|
+
}
|
|
121
|
+
function indexMatches(entries, expected) {
|
|
122
|
+
return entries !== null && entries.length === expected.size && entries.every((entry) =>
|
|
123
|
+
entry.stage === "0" && expected.get(entry.path)?.sha === entry.sha && expected.get(entry.path)?.mode === entry.mode)
|
|
124
|
+
}
|
|
125
|
+
// Every failure here carries `route_around` (#561, #623). A failure that found bytes Desk did not admit gets reads only: the
|
|
126
|
+
// archive's admitted entries are not what the paths hold, so nothing can tell this archive's change from another session's
|
|
127
|
+
// edit, and no step commits either (R3).
|
|
128
|
+
function differsRoute(git, paths, message) {
|
|
129
|
+
const route = commitRoute({ root: git.root, paths, message, readback: "unknown", deskRoot: git.deskRoot })
|
|
130
|
+
route.summary = "These paths changed after Desk admitted them, so Desk did not commit, and no step here commits: read the differences, change nothing, and report them."
|
|
131
|
+
return route
|
|
132
|
+
}
|
|
133
|
+
// A failure before the commit dispatch carries the admitted entries themselves (R3): their modes and blobs, on the HEAD
|
|
134
|
+
// preflight read and the branch it is on. The route's finish-commit check requalifies them, and commits exactly them only when
|
|
135
|
+
// the shared index already holds exactly them; it never commits what disk holds, so a link kept as a placeholder stays a link.
|
|
136
|
+
function admittedRoute(git, paths, expected, message) {
|
|
137
|
+
const branch = git.spawnGit("git", ["-C", git.root, "symbolic-ref", "--short", "-q", "HEAD"], { windowsHide: true, encoding: "utf8", timeout: 10000 })
|
|
138
|
+
const name = branch.status === 0 ? String(branch.stdout).trim() : ""
|
|
139
|
+
const capture = name && git.head ? { before: git.head, branch: name, expected: [...expected].map(([file, entry]) => `${entry.mode} ${entry.sha}\t${file}`).sort() } : null
|
|
140
|
+
return commitRoute({ root: git.root, paths, message, readback: "absent", deskRoot: git.deskRoot, capture })
|
|
141
|
+
}
|
|
142
|
+
function publishExpected(git, paths, expected, message, stagingPaths = paths) {
|
|
143
|
+
assertGitState(git)
|
|
144
|
+
const staged = stagePaths(git.root, stagingPaths, git.spawnGit)
|
|
145
|
+
if (!staged.ok) return { status: "failed", reason: staged.stderr, route_around: admittedRoute(git, paths, expected, message) }
|
|
146
|
+
let entries = indexEntries(git.root, paths, git.spawnGit)
|
|
147
|
+
const normalStage = new Map([...expected].map(([file, entry]) => [file, { sha: entry.stageSha, mode: entry.stageMode }]))
|
|
148
|
+
if (!indexMatches(entries, normalStage))
|
|
149
|
+
return { status: "failed", reason: "staged archive differs from the admitted bytes; no commit was attempted", route_around: differsRoute(git, paths, message) }
|
|
150
|
+
const metadata = [...expected].filter(([, entry]) => entry.mode !== entry.stageMode || entry.sha !== entry.stageSha)
|
|
151
|
+
if (metadata.length) {
|
|
152
|
+
const input = metadata.map(([file, entry]) => `${entry.mode} ${entry.sha}\t${file}\0`).join("")
|
|
153
|
+
const updated = git.spawnGit("git", ["-C", git.root, "update-index", "-z", "--index-info"],
|
|
154
|
+
{ windowsHide: true, encoding: "utf8", timeout: 10000, input })
|
|
155
|
+
if (updated.status !== 0) return { status: "failed", reason: updated.stderr || updated.error?.code || "Git metadata staging failed", route_around: admittedRoute(git, paths, expected, message) }
|
|
156
|
+
entries = indexEntries(git.root, paths, git.spawnGit)
|
|
157
|
+
}
|
|
158
|
+
if (!indexMatches(entries, expected))
|
|
159
|
+
return { status: "failed", reason: "the admitted Git mode/type metadata could not be staged", route_around: differsRoute(git, paths, message) }
|
|
160
|
+
assertGitState(git)
|
|
161
|
+
const committed = commitIndexPaths(git.root, paths, entries, message, git.spawnGit)
|
|
162
|
+
return committed.ok ? undefined : commitFailure({ root: git.root, paths, message, committed, deskRoot: git.deskRoot })
|
|
163
|
+
}
|
|
164
|
+
async function ancestry(boundary, destination) {
|
|
165
|
+
const physical = await fs.realpath(boundary)
|
|
166
|
+
const segments = path.relative(boundary, path.dirname(destination)).split(path.sep).filter(Boolean)
|
|
167
|
+
const nodes = new Map()
|
|
168
|
+
let cursor = boundary
|
|
169
|
+
for (const segment of ["", ...segments]) {
|
|
170
|
+
cursor = segment ? path.join(cursor, segment) : cursor
|
|
171
|
+
const info = await present(cursor)
|
|
172
|
+
if (!info) continue
|
|
173
|
+
const real = await fs.realpath(cursor)
|
|
174
|
+
if (!isPathContained(physical, real)) throw Object.assign(new Error("task_archive: Keep the path inside the desk: destination ancestry is outside the effective desk"), { code: "task_archive_destination_ancestry_is_outside_the_2" })
|
|
175
|
+
nodes.set(cursor, { identity: identity(info), real, target: identity(await fs.stat(cursor, { bigint: true })) })
|
|
176
|
+
}
|
|
177
|
+
return { physical, async assert() {
|
|
178
|
+
for (const [file, expected] of nodes) {
|
|
179
|
+
const info = await present(file)
|
|
180
|
+
if (!info || identity(info) !== expected.identity || await fs.realpath(file) !== expected.real ||
|
|
181
|
+
identity(await fs.stat(file, { bigint: true })) !== expected.target)
|
|
182
|
+
throw Object.assign(new Error("task_archive: Run it again: destination ancestor identity changed"), { code: "task_archive_destination_ancestor_identity_changed" })
|
|
183
|
+
}
|
|
184
|
+
const parent = await fs.realpath(path.dirname(destination))
|
|
185
|
+
if (!isPathContained(physical, parent)) throw Object.assign(new Error("task_archive: Keep the path inside the desk: destination ancestry is outside the effective desk"), { code: "task_archive_destination_ancestry_is_outside_the" })
|
|
186
|
+
} }
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
export async function prepareArchiveState({ effectiveRoot, deskRoot = effectiveRoot, srcDir, archiveDir, srcFile, trackPlan, trackFile, slug, spawnGit, relocated = false }) {
|
|
190
|
+
const snapshot = await tree(relocated ? archiveDir : srcDir)
|
|
191
|
+
const fence = await ancestry(effectiveRoot, archiveDir)
|
|
192
|
+
const git = await gitContext(effectiveRoot, spawnGit, deskRoot)
|
|
193
|
+
let track = null
|
|
194
|
+
let tracked = []
|
|
195
|
+
let originals = new Map()
|
|
196
|
+
let sourceIndex = new Map()
|
|
197
|
+
let destinationIndex = new Map()
|
|
198
|
+
let stagedRelocation = false
|
|
199
|
+
let recoveredTrack = false
|
|
200
|
+
let trackEntry = null
|
|
201
|
+
// Files outside the moved folder that the archive rewrote, keyed by Git path; they join the archive commit.
|
|
202
|
+
const inbound = new Map()
|
|
203
|
+
if (git) {
|
|
204
|
+
const source = gitPath(git, srcDir)
|
|
205
|
+
const destination = gitPath(git, archiveDir)
|
|
206
|
+
const card = gitPath(git, srcFile)
|
|
207
|
+
const entries = indexEntries(git.root, [source], spawnGit)
|
|
208
|
+
if (entries === null || entries.some((entry) => entry.stage !== "0" || entry.mode === "160000"))
|
|
209
|
+
throw Object.assign(new Error("task_archive: Remove the unsupported entry from the task folder, then run it again: source index conflicts/submodules cannot be admitted; nothing was moved"), { code: "task_archive_source_index_conflicts_submodules_cannot" })
|
|
210
|
+
const baseline = new Map(headEntries(git, srcDir).map((entry) => [entry.path, entry]))
|
|
211
|
+
sourceIndex = new Map(entries.map((entry) => [entry.path, entry]))
|
|
212
|
+
if (relocated && entries.length === 0 && baseline.size > 0) {
|
|
213
|
+
destinationIndex = new Map([...baseline].map(([file, entry]) =>
|
|
214
|
+
[`${destination}${file.slice(source.length)}`, entry]))
|
|
215
|
+
if (headEntries(git, archiveDir).length ||
|
|
216
|
+
!indexMatches(indexEntries(git.root, [destination], spawnGit), destinationIndex))
|
|
217
|
+
throw Object.assign(new Error("task_archive: Keep the index and the archive, resolve the difference, then run it again: the interrupted staged move does not exactly match the source HEAD; preserve the index and archive before retrying"), { code: "task_archive_the_interrupted_staged_move_does" })
|
|
218
|
+
stagedRelocation = true
|
|
219
|
+
} else destinationVacant(git, archiveDir)
|
|
220
|
+
originals = stagedRelocation ? baseline : sourceIndex
|
|
221
|
+
tracked = [...originals.keys()]
|
|
222
|
+
for (const [name, entry] of snapshot) {
|
|
223
|
+
if (entry.kind !== "directory" && name !== "task.md" && !originals.has(`${source}/${name}`))
|
|
224
|
+
throw Object.assign(new Error("task_archive: Commit or move the extra changes out of the task folder, then run it again: an untracked companion is not implicitly owned; nothing was moved"), { code: "task_archive_an_untracked_companion_is_not" })
|
|
225
|
+
}
|
|
226
|
+
if (relocated) {
|
|
227
|
+
if (!stagedRelocation && (entries.length === 0 || entries.length !== baseline.size ||
|
|
228
|
+
entries.some((entry) => baseline.get(entry.path)?.sha !== entry.sha || baseline.get(entry.path)?.mode !== entry.mode)))
|
|
229
|
+
throw Object.assign(new Error("task_archive: Keep the index and the archive, resolve the difference, then run it again: the interrupted move has no unchanged source HEAD/index to reconcile"), { code: "task_archive_the_interrupted_move_has_no" })
|
|
230
|
+
for (const [key, entry] of snapshot) {
|
|
231
|
+
if (entry.kind === "directory") continue
|
|
232
|
+
const held = baseline.get(`${source}/${key}`)
|
|
233
|
+
const mode = gitMode(entry, held, git)
|
|
234
|
+
const sha = blobHash(git, path.join(srcDir, key), entry.bytes, mode)
|
|
235
|
+
if (!held || held.sha !== sha || held.mode !== mode)
|
|
236
|
+
throw Object.assign(new Error("task_archive: Keep the archive and resolve the discrepancy, then run it again: relocated bytes differ from the source HEAD/index; preserve the archive and resolve the discrepancy before retrying"), { code: "task_archive_relocated_bytes_differ_from_the" })
|
|
237
|
+
}
|
|
238
|
+
if ([...baseline.keys()].some((file) => !snapshot.has(file.slice(source.length + 1))))
|
|
239
|
+
throw Object.assign(new Error("task_archive: Keep the index and the archive, resolve the difference, then run it again: the interrupted move is missing a tracked source file"), { code: "task_archive_the_interrupted_move_is_missing" })
|
|
240
|
+
}
|
|
241
|
+
for (const entry of originals.values()) {
|
|
242
|
+
if (entry.path === card) continue
|
|
243
|
+
const previous = baseline.get(entry.path)
|
|
244
|
+
const key = entry.path.slice(source.length + 1)
|
|
245
|
+
const current = snapshot.get(key), bytes = current?.bytes
|
|
246
|
+
if (!previous || previous.sha !== entry.sha || previous.mode !== entry.mode || !bytes ||
|
|
247
|
+
gitMode(current, entry, git) !== entry.mode ||
|
|
248
|
+
blobHash(git, path.join(srcDir, key), bytes, entry.mode) !== entry.sha)
|
|
249
|
+
throw Object.assign(new Error("task_archive: Commit or move the extra changes out of the task folder, then run it again: a staged or dirty companion is not implicitly owned; nothing was moved"), { code: "task_archive_a_staged_or_dirty_companion" })
|
|
250
|
+
}
|
|
251
|
+
for (const args of relocated ? [] : [
|
|
252
|
+
["diff", "--name-only", "-z", "--", source],
|
|
253
|
+
["diff", "--cached", "--name-only", "-z", "--", source],
|
|
254
|
+
["ls-files", "--others", "-z", "--", source],
|
|
255
|
+
]) {
|
|
256
|
+
const changes = readGit(git.root, args, spawnGit).split("\0").filter(Boolean)
|
|
257
|
+
if (changes.some((file) => file !== card))
|
|
258
|
+
throw Object.assign(new Error("task_archive: Commit or move the extra changes out of the task folder, then run it again: dirty, staged, or untracked companion bytes cannot be adopted; nothing was moved"), { code: "task_archive_dirty_staged_or_untracked_companion" })
|
|
259
|
+
}
|
|
260
|
+
if (stagedRelocation && trackFile) {
|
|
261
|
+
const key = gitPath(git, trackFile)
|
|
262
|
+
const held = headEntries(git, trackFile)
|
|
263
|
+
if (held.length === 1 && ["100644", "100755"].includes(held[0].mode)) {
|
|
264
|
+
const before = readGit(git.root, ["show", `${git.head}:${key}`], spawnGit)
|
|
265
|
+
const after = setTaskArchiveLinks(before, slug)
|
|
266
|
+
if (after !== null) {
|
|
267
|
+
const stat = await fs.lstat(trackFile)
|
|
268
|
+
const expected = { mode: held[0].mode, sha: cleanHash(git, trackFile, Buffer.from(after)), path: key, stage: "0" }
|
|
269
|
+
if (!stat.isFile() || gitMode({ kind: "file", mode: stat.mode & 0o777 }, held[0], git) !== held[0].mode ||
|
|
270
|
+
await fs.readFile(trackFile, "utf8") !== after ||
|
|
271
|
+
!indexMatches(indexEntries(git.root, [key], spawnGit), new Map([[key, expected]])))
|
|
272
|
+
throw Object.assign(new Error("task_archive: Keep the index and the archive, resolve the difference, then run it again: the interrupted track link update differs from its source HEAD; outside edits were retained"), { code: "task_archive_the_interrupted_track_link_update" })
|
|
273
|
+
trackPlan = { file: trackFile, before: after, after }
|
|
274
|
+
trackEntry = expected
|
|
275
|
+
recoveredTrack = true
|
|
276
|
+
}
|
|
277
|
+
}
|
|
278
|
+
}
|
|
279
|
+
}
|
|
280
|
+
if (trackPlan) {
|
|
281
|
+
const stat = await fs.lstat(trackPlan.file, { bigint: true })
|
|
282
|
+
if (!stat.isFile()) throw Object.assign(new Error("task_archive: Use a regular file, then run it again: a track link update requires a regular track card"), { code: "task_archive_a_track_link_update_requires" })
|
|
283
|
+
track = { ...trackPlan, identity: identity(stat), mode: Number(stat.mode & 0o777n) }
|
|
284
|
+
}
|
|
285
|
+
if (git) {
|
|
286
|
+
if (track && !recoveredTrack && [
|
|
287
|
+
["diff", "--name-only", "--", gitPath(git, track.file)],
|
|
288
|
+
["diff", "--cached", "--name-only", "--", gitPath(git, track.file)],
|
|
289
|
+
["ls-files", "--others", "--", gitPath(git, track.file)],
|
|
290
|
+
].some((args) => readGit(git.root, args, spawnGit).trim()))
|
|
291
|
+
throw Object.assign(new Error("task_archive: Commit or move the extra changes out of the task folder, then run it again: the track row/link has outside edits; nothing was moved"), { code: "task_archive_the_track_row_link_has" })
|
|
292
|
+
if (track) {
|
|
293
|
+
const held = indexEntries(git.root, [gitPath(git, track.file)], spawnGit)
|
|
294
|
+
if (held === null || held.length !== 1 || held[0].stage !== "0" || !["100644", "100755"].includes(held[0].mode))
|
|
295
|
+
throw Object.assign(new Error("task_archive: Check that Git works in this desk, then run it again: the track's regular Git file state could not be qualified"), { code: "task_archive_the_track_s_regular_git" })
|
|
296
|
+
if (recoveredTrack && !indexMatches(held, new Map([[trackEntry.path, trackEntry]])))
|
|
297
|
+
throw Object.assign(new Error("task_archive: Run it again: interrupted track index changed during preflight; outside staged bytes were retained"), { code: "task_archive_interrupted_track_index_changed_during" })
|
|
298
|
+
trackEntry = held[0]
|
|
299
|
+
}
|
|
300
|
+
}
|
|
301
|
+
async function assertTrack() {
|
|
302
|
+
if (!track) return
|
|
303
|
+
const stat = await fs.lstat(track.file, { bigint: true })
|
|
304
|
+
if (identity(stat) !== track.identity || !Buffer.from(await fs.readFile(track.file)).equals(Buffer.from(track.before)))
|
|
305
|
+
throw Object.assign(new Error("task_archive: Run it again: the track changed after preflight; outside edits were retained"), { code: "task_archive_the_track_changed_after_preflight" })
|
|
306
|
+
}
|
|
307
|
+
function assertSourceIndex() {
|
|
308
|
+
if (!indexMatches(indexEntries(git.root, [gitPath(git, srcDir)], spawnGit), sourceIndex))
|
|
309
|
+
throw Object.assign(new Error("task_archive: Run it again: source index changed after preflight; outside staged bytes were retained"), { code: "task_archive_source_index_changed_after_preflight" })
|
|
310
|
+
}
|
|
311
|
+
function assertDestinationIndex() {
|
|
312
|
+
if (!stagedRelocation) return destinationVacant(git, archiveDir)
|
|
313
|
+
if (headEntries(git, archiveDir).length ||
|
|
314
|
+
!indexMatches(indexEntries(git.root, [gitPath(git, archiveDir)], spawnGit), destinationIndex))
|
|
315
|
+
throw Object.assign(new Error("task_archive: Run it again: interrupted destination index changed after preflight; outside staged bytes were retained"), { code: "task_archive_interrupted_destination_index_changed_after" })
|
|
316
|
+
if (track && !indexMatches(indexEntries(git.root, [gitPath(git, track.file)], spawnGit),
|
|
317
|
+
new Map([[trackEntry.path, trackEntry]])))
|
|
318
|
+
throw Object.assign(new Error("task_archive: Run it again: interrupted track index changed after preflight; outside staged bytes were retained"), { code: "task_archive_interrupted_track_index_changed_after" })
|
|
319
|
+
}
|
|
320
|
+
return {
|
|
321
|
+
git, snapshot, fence, trackPlan,
|
|
322
|
+
async atUse() {
|
|
323
|
+
await fence.assert()
|
|
324
|
+
await assertTrack()
|
|
325
|
+
if (!sameTree(await tree(relocated ? archiveDir : srcDir), snapshot))
|
|
326
|
+
throw Object.assign(new Error("task_archive: Run it again: source changed after preflight"), { code: "task_archive_source_changed_after_preflight" })
|
|
327
|
+
if (await present(relocated ? srcDir : archiveDir))
|
|
328
|
+
throw Object.assign(new Error("task_archive: Run it again: the other archive path appeared before publication"), { code: "task_archive_the_other_archive_path_appeared" })
|
|
329
|
+
if (git) {
|
|
330
|
+
assertDestinationIndex()
|
|
331
|
+
assertSourceIndex()
|
|
332
|
+
assertGitState(git)
|
|
333
|
+
}
|
|
334
|
+
},
|
|
335
|
+
async afterMove() {
|
|
336
|
+
await fence.assert()
|
|
337
|
+
if (!sameTree(await tree(archiveDir), snapshot)) throw Object.assign(new Error("task_archive: Run it again: relocated payload changed; outside bytes retained"), { code: "task_archive_relocated_payload_changed_outside_bytes" })
|
|
338
|
+
},
|
|
339
|
+
assertTrack,
|
|
340
|
+
async cardWritten(expectedBytes, name = "task.md") {
|
|
341
|
+
const real = await fs.realpath(path.join(archiveDir, name))
|
|
342
|
+
if (!(await fs.readFile(real)).equals(Buffer.from(expectedBytes))) throw Object.assign(new Error("task_archive: Run it again: card bytes changed during its patch; no publication was admitted"), { code: "task_archive_card_bytes_changed_during_its" })
|
|
343
|
+
if (isPathContained(await fs.realpath(archiveDir), real)) {
|
|
344
|
+
const key = relative(await fs.realpath(archiveDir), real)
|
|
345
|
+
const stat = await fs.lstat(real, { bigint: true })
|
|
346
|
+
snapshot.set(key, { ...snapshot.get(key), identity: identity(stat), bytes: Buffer.from(expectedBytes), hash: hash(expectedBytes) })
|
|
347
|
+
}
|
|
348
|
+
},
|
|
349
|
+
// Rewrites one file outside the moved folder, but only when it still holds the bytes the plan read and, in a Git desk, has no
|
|
350
|
+
// unstaged, staged or untracked work. Returns null once written, else the reason it was left alone.
|
|
351
|
+
async relinkInbound(file, before, after) {
|
|
352
|
+
let key = null, mode = null
|
|
353
|
+
if (git) {
|
|
354
|
+
key = gitPath(git, file)
|
|
355
|
+
const held = indexEntries(git.root, [key], spawnGit)
|
|
356
|
+
if (held === null || held.length !== 1 || held[0].stage !== "0" || !["100644", "100755"].includes(held[0].mode))
|
|
357
|
+
return "it is not a tracked regular file in Git"
|
|
358
|
+
if ([["diff", "--name-only", "--", key], ["diff", "--cached", "--name-only", "--", key], ["ls-files", "--others", "--exclude-standard", "--", key]]
|
|
359
|
+
.some((args) => readGit(git.root, args, spawnGit).trim()))
|
|
360
|
+
return "it has unstaged, staged or untracked changes, so another session may be editing it"
|
|
361
|
+
mode = gitMode({ kind: "file", mode: Number((await fs.lstat(file, { bigint: true })).mode & 0o777n) }, held[0], git)
|
|
362
|
+
}
|
|
363
|
+
/* istanbul ignore next -- the file changed between the plan's read and this write; a test cannot time that gap, and the reason is reported. */
|
|
364
|
+
if (!(await fs.readFile(file)).equals(Buffer.from(before))) return "it changed after the archive read it"
|
|
365
|
+
await fs.writeFile(file, after)
|
|
366
|
+
if (git) inbound.set(key, { file, after, mode })
|
|
367
|
+
return null
|
|
368
|
+
},
|
|
369
|
+
async publish(message) {
|
|
370
|
+
await fence.assert()
|
|
371
|
+
if (!sameTree(await tree(archiveDir), snapshot)) throw Object.assign(new Error("task_archive: Run it again: relocated bytes changed before staging; outside edits retained"), { code: "task_archive_relocated_bytes_changed_before_staging" })
|
|
372
|
+
if (track && (!(await fs.lstat(track.file)).isFile() ||
|
|
373
|
+
!isPathContained(fence.physical, await fs.realpath(track.file)) ||
|
|
374
|
+
!(await fs.readFile(track.file)).equals(Buffer.from(track.after))))
|
|
375
|
+
throw Object.assign(new Error("task_archive: Run it again: track changed before publication"), { code: "task_archive_track_changed_before_publication" })
|
|
376
|
+
if (!git) return undefined
|
|
377
|
+
assertDestinationIndex()
|
|
378
|
+
assertSourceIndex()
|
|
379
|
+
if (headSha(git) !== git.head) throw Object.assign(new Error("task_archive: Run it again: HEAD changed before publication"), { code: "task_archive_head_changed_before_publication" })
|
|
380
|
+
const expected = new Map()
|
|
381
|
+
const source = gitPath(git, srcDir)
|
|
382
|
+
const destination = gitPath(git, archiveDir)
|
|
383
|
+
for (const [name, entry] of snapshot) {
|
|
384
|
+
if (entry.kind === "directory") continue
|
|
385
|
+
const mode = gitMode(entry, originals.get(`${source}/${name}`), git)
|
|
386
|
+
const sha = blobHash(git, path.join(archiveDir, name), entry.bytes, mode)
|
|
387
|
+
const key = `${destination}/${name}`
|
|
388
|
+
const stageMode = gitMode(entry, destinationIndex.get(key), git)
|
|
389
|
+
expected.set(key, { sha, mode, stageMode,
|
|
390
|
+
stageSha: stageMode === mode ? sha : blobHash(git, path.join(archiveDir, name), entry.bytes, stageMode) })
|
|
391
|
+
}
|
|
392
|
+
for (const [key, entry] of inbound) {
|
|
393
|
+
const sha = cleanHash(git, entry.file, Buffer.from(entry.after))
|
|
394
|
+
expected.set(key, { sha, mode: entry.mode, stageSha: sha, stageMode: entry.mode })
|
|
395
|
+
}
|
|
396
|
+
if (track) {
|
|
397
|
+
const bytes = Buffer.from(track.after)
|
|
398
|
+
const sha = cleanHash(git, track.file, bytes), mode = gitMode({ kind: "file", mode: track.mode }, trackEntry, git)
|
|
399
|
+
expected.set(gitPath(git, track.file), { sha, mode, stageSha: sha, stageMode: mode })
|
|
400
|
+
}
|
|
401
|
+
const paths = [...new Set([...tracked, ...expected.keys()])]
|
|
402
|
+
return publishExpected(git, paths, expected, message, stagedRelocation ? [...expected.keys()] : paths)
|
|
403
|
+
},
|
|
404
|
+
}
|
|
405
|
+
}
|
|
406
|
+
|
|
407
|
+
export async function prepareArchivedCardPublication({ effectiveRoot, deskRoot = effectiveRoot, file, before, spawnGit }) {
|
|
408
|
+
const physical = await fs.realpath(file), boundary = await fs.realpath(effectiveRoot)
|
|
409
|
+
if (!isPathContained(boundary, physical)) throw Object.assign(new Error("task_archive: Keep the archived card inside the desk, then run it again: archived card target is outside the effective desk"), { code: "task_archive_archived_card_target_is_outside" })
|
|
410
|
+
const stat = await fs.lstat(physical, { bigint: true })
|
|
411
|
+
if (!stat.isFile()) throw Object.assign(new Error("task_archive: Use a regular file for the archived card, then run it again: archived card target is not a regular file"), { code: "task_archive_archived_card_target_is_not" })
|
|
412
|
+
const git = await gitContext(effectiveRoot, spawnGit, deskRoot)
|
|
413
|
+
let previous = null
|
|
414
|
+
let key
|
|
415
|
+
if (git) {
|
|
416
|
+
key = gitPath(git, physical)
|
|
417
|
+
const held = indexEntries(git.root, [key], spawnGit)
|
|
418
|
+
if (held === null || held.length !== 1 || held[0].stage !== "0" || !["100644", "100755"].includes(held[0].mode))
|
|
419
|
+
throw Object.assign(new Error("task_archive: Check that Git works in this desk, then run it again: archived card Git state could not be qualified"), { code: "task_archive_archived_card_git_state_could" })
|
|
420
|
+
previous = held[0]
|
|
421
|
+
for (const args of [
|
|
422
|
+
["diff", "--name-only", "--", key], ["diff", "--cached", "--name-only", "--", key],
|
|
423
|
+
["ls-files", "--others", "--", key],
|
|
424
|
+
]) if (readGit(git.root, args, spawnGit).trim())
|
|
425
|
+
throw Object.assign(new Error("task_archive: Commit or move the outside edits on the archived card, then run it again: archived card has outside edits; no report fields were changed"), { code: "task_archive_archived_card_has_outside_edits" })
|
|
426
|
+
}
|
|
427
|
+
async function sameTarget(expected) {
|
|
428
|
+
return await fs.realpath(file) === physical &&
|
|
429
|
+
identity(await fs.lstat(physical, { bigint: true })) === identity(stat) &&
|
|
430
|
+
(await fs.readFile(physical)).equals(Buffer.from(expected))
|
|
431
|
+
}
|
|
432
|
+
return {
|
|
433
|
+
file: physical, git,
|
|
434
|
+
async retainedTarget() {
|
|
435
|
+
try {
|
|
436
|
+
const actual = await fs.realpath(physical)
|
|
437
|
+
if (!isPathContained(boundary, actual)) return null
|
|
438
|
+
const current = await fs.lstat(actual, { bigint: true })
|
|
439
|
+
return current.isFile() && identity(current) === identity(stat) ? actual : null
|
|
440
|
+
} catch { return null }
|
|
441
|
+
},
|
|
442
|
+
async assertBefore() {
|
|
443
|
+
if (!(await sameTarget(before))) throw Object.assign(new Error("task_archive: Run it again: archived card changed before its report patch"), { code: "task_archive_archived_card_changed_before_its" })
|
|
444
|
+
if (git) assertGitState(git)
|
|
445
|
+
},
|
|
446
|
+
async publish(expected, message) {
|
|
447
|
+
if (!(await sameTarget(expected))) return { status: "failed", reason: "archived card changed during its report patch; no commit was attempted", route_around: git ? differsRoute(git, [key], message) : undefined }
|
|
448
|
+
if (!git) return undefined
|
|
449
|
+
const mode = gitMode({ kind: "file", mode: Number(stat.mode & 0o777n) }, previous, git)
|
|
450
|
+
const sha = cleanHash(git, physical, Buffer.from(expected))
|
|
451
|
+
return publishExpected(git, [key], new Map([[key, { sha, mode, stageSha: sha, stageMode: mode }]]), message)
|
|
452
|
+
},
|
|
453
|
+
}
|
|
454
|
+
}
|
|
455
|
+
|
|
456
|
+
function headSha(git) {
|
|
457
|
+
const answer = git.spawnGit("git", ["-C", git.root, "rev-parse", "--verify", "-q", "HEAD"], { windowsHide: true, encoding: "utf8", timeout: 10000 })
|
|
458
|
+
if (answer.status === 1) return null
|
|
459
|
+
if (answer.status !== 0) throw Object.assign(new Error("task_archive: Check that Git works in this desk, then run it again: current HEAD could not be qualified"), { code: "task_archive_current_head_could_not_be" })
|
|
460
|
+
return answer.stdout.trim()
|
|
461
|
+
}
|
|
462
|
+
|
|
463
|
+
export async function archivePublicationState({ effectiveRoot, srcDir, archiveDir, spawnGit }) {
|
|
464
|
+
try {
|
|
465
|
+
const git = await gitContext(effectiveRoot, spawnGit)
|
|
466
|
+
if (!git) return { status: "not_git" }
|
|
467
|
+
const oldPath = gitPath(git, srcDir)
|
|
468
|
+
const newPath = gitPath(git, archiveDir)
|
|
469
|
+
const entries = indexEntries(git.root, [oldPath, newPath], spawnGit)
|
|
470
|
+
if (entries === null) return { status: "unknown", reason: "archive index could not be read" }
|
|
471
|
+
const before = headEntries(git, srcDir)
|
|
472
|
+
const published = headEntries(git, archiveDir)
|
|
473
|
+
const actual = new Map(entries.map((entry) => [entry.path, entry]))
|
|
474
|
+
const clean = !readGit(git.root, ["diff", "--name-only", "--", newPath], spawnGit).trim() &&
|
|
475
|
+
!readGit(git.root, ["ls-files", "--others", "--exclude-standard", "--", newPath], spawnGit).trim()
|
|
476
|
+
if (!before.length && published.length && entries.length === published.length && clean &&
|
|
477
|
+
published.every((entry) => actual.get(entry.path)?.sha === entry.sha && actual.get(entry.path)?.mode === entry.mode))
|
|
478
|
+
return { status: "published" }
|
|
479
|
+
return { status: "pending", reason: "the directory exists, but the exact archive move is not cleanly published in HEAD/index" }
|
|
480
|
+
} catch {
|
|
481
|
+
return { status: "unknown", reason: "the existing archive's Git publication could not be qualified" }
|
|
482
|
+
}
|
|
483
|
+
}
|
|
484
|
+
|
|
485
|
+
export async function qualifyArchiveFailure(error, { effectiveRoot, srcDir, archiveDir, sourceIdentity, moved, published }) {
|
|
486
|
+
let actual = null
|
|
487
|
+
for (const candidate of [archiveDir, srcDir]) {
|
|
488
|
+
try {
|
|
489
|
+
if (identity(await fs.lstat(candidate, { bigint: true })) === sourceIdentity) {
|
|
490
|
+
actual = await fs.realpath(candidate)
|
|
491
|
+
break
|
|
492
|
+
}
|
|
493
|
+
} catch { /* A missing/unreadable candidate is unknown, not an actual path. */ }
|
|
494
|
+
}
|
|
495
|
+
const physical = await fs.realpath(effectiveRoot).catch(() => null)
|
|
496
|
+
const outside = actual !== null && physical !== null && !isPathContained(physical, actual)
|
|
497
|
+
const uncertain = error.archiveMove?.released && error.archiveMove.movement === "unconfirmed"
|
|
498
|
+
error.archive_phase = outside ? "relocated_outside_boundary" : published ? "archived_publication_complete" :
|
|
499
|
+
uncertain ? "relocation_outcome_uncertain" : moved ? "relocated_publication_unconfirmed" : actual === null ? "relocation_outcome_uncertain" : "not_moved"
|
|
500
|
+
if (uncertain) {
|
|
501
|
+
error.possible_late_effect = error.archiveMove.retirement !== "confirmed"
|
|
502
|
+
error.observed_placement = actual
|
|
503
|
+
error.message += `; possible_late_effect=${error.possible_late_effect}; reconcile observed placement before any retry`
|
|
504
|
+
}
|
|
505
|
+
if (error.created_parents === "retained_until_native_retirement_resolved")
|
|
506
|
+
error.message += "; created_parents=retained_until_native_retirement_resolved; do not retry or reuse parents until native retirement is resolved"
|
|
507
|
+
if (error.native_close_failure) error.message += `; ${error.native_close_failure}`
|
|
508
|
+
error.actual_path = actual === null ? null : path.join(actual, "task.md")
|
|
509
|
+
error.path = error.actual_path
|
|
510
|
+
if (actual === null) error.last_known_path = path.join(archiveDir, "task.md")
|
|
511
|
+
error.message += `; archive_phase=${error.archive_phase}; actual_path=${error.actual_path ?? "unknown"}; no rollback or unknown publication was attempted`
|
|
512
|
+
return error
|
|
513
|
+
}
|