@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,440 @@
|
|
|
1
|
+
// Git staging helpers shared by the tools that write track and task cards
|
|
2
|
+
// (M4-5 fix round 4).
|
|
3
|
+
//
|
|
4
|
+
// The one-time tidy makes many moves and edits and commits once, at the end.
|
|
5
|
+
// To tell the tidy's own earlier steps apart from another session's work,
|
|
6
|
+
// every Desk tool the tidy uses stages what it writes. So on a Git desk:
|
|
7
|
+
// - staged changes are this tidy's in-flight work, and never block a move;
|
|
8
|
+
// - unstaged changes to tracked files, and untracked files that are not
|
|
9
|
+
// ignored, belong to someone else, and do.
|
|
10
|
+
//
|
|
11
|
+
// `spawnGit` is an injectable seam over `node:child_process`'s `spawnSync`,
|
|
12
|
+
// for tests only; real callers never pass it.
|
|
13
|
+
|
|
14
|
+
import { spawnSync } from "node:child_process"
|
|
15
|
+
import { existsSync, readFileSync, realpathSync, writeFileSync } from "node:fs"
|
|
16
|
+
import * as path from "node:path"
|
|
17
|
+
|
|
18
|
+
import { fastGitAnswer } from "../runtime/fast-refs.js"
|
|
19
|
+
import { budgeted, commitCaptured, operationAnswer, treeLines } from "./cas-commit.js"
|
|
20
|
+
import { defaultBranchForPublication, publishCardCommit } from "./main-publish.js"
|
|
21
|
+
import { recordToolCommit } from "./tool-commits.js"
|
|
22
|
+
|
|
23
|
+
// Bounds every git call so a hung hook or a held lock can never block a tool
|
|
24
|
+
// call indefinitely. Git hooks stay enabled — disabling them is not this
|
|
25
|
+
// module's call to make; a hook that runs long simply times out like any
|
|
26
|
+
// other slow git command and is reported the same way a stage or commit
|
|
27
|
+
// failure is.
|
|
28
|
+
const GIT_TIMEOUT_MS = 10_000
|
|
29
|
+
// A commit gets one retry with this long after a first attempt the clock cut off; an index commit qualifies again at most this many times inside its one budget.
|
|
30
|
+
const COMMIT_RETRY_TIMEOUT_MS = 60_000
|
|
31
|
+
const QUALIFY_AGAIN = 3
|
|
32
|
+
const TOOL_COMMIT_ENV = "DESK_TOOL_COMMIT" // the same name `desk/card-commit-guard.js` exports; card_commit_guard.test.js checks they match
|
|
33
|
+
|
|
34
|
+
/**
|
|
35
|
+
* Why Desk must not stage or commit in `root` right now, or null when it may. A detached HEAD is always refused. Beyond that, `stateBranch` says what the caller knows:
|
|
36
|
+
* - a branch name: the checkout must be on it (the host configured a state branch);
|
|
37
|
+
* - `null` or `undefined`: no state branch is configured. A checkout on another branch publishes through `util/main-publish.js`, so only the detached-HEAD rule applies here.
|
|
38
|
+
* A Git read that cannot run (a status other than 0, or 1 for a detached HEAD) is not a refusal here: the stage or commit itself then fails and says why.
|
|
39
|
+
*/
|
|
40
|
+
export function commitBranchRefusal(root, spawnGit, stateBranch) {
|
|
41
|
+
const head = run(spawnGit, root, ["symbolic-ref", "--short", "-q", "HEAD"])
|
|
42
|
+
const status = head?.status
|
|
43
|
+
if (status !== 0 && status !== 1) return null
|
|
44
|
+
const found = status === 0 ? String(head.stdout ?? "").trim() : ""
|
|
45
|
+
if (found === "") return "Desk did not write: the desk checkout is on a detached HEAD. Switch it to a branch and try again."
|
|
46
|
+
// Without a configured state branch, a checkout on another branch publishes its commits to the remote's default branch (util/main-publish.js).
|
|
47
|
+
if (typeof stateBranch !== "string" || found === stateBranch) return null
|
|
48
|
+
return `Desk did not write: the desk checkout is on branch \`${found}\`, and Desk writes only on \`${stateBranch}\`. Switch the checkout to \`${stateBranch}\` and try again.`
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
// Another Git process (often Desk's own background loop committing an improvement card) can hold the desk's index or a ref lock
|
|
52
|
+
// for a moment. Staging waits for an observed index lock before dispatch; a failed mutation is never redispatched,
|
|
53
|
+
// because its hooks or filters may already have taken effect. Desk's background writers run with DESK_GIT_YIELD=1 and never wait.
|
|
54
|
+
const LOCK_WAIT_MS = 3000
|
|
55
|
+
const LOCK_RETRY_MS = 50
|
|
56
|
+
const LOCK_HELD = /Unable to create '[^']*\.lock'|\.lock': File exists|cannot lock ref/u
|
|
57
|
+
export const YIELD_ENV = "DESK_GIT_YIELD"
|
|
58
|
+
|
|
59
|
+
/** True when this process is one of Desk's background writers, which give way to a person's writes. */
|
|
60
|
+
export function yieldsGitLock() {
|
|
61
|
+
return process.env[YIELD_ENV] === "1"
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
function lockHeld(result) {
|
|
65
|
+
return result?.status !== 0 && LOCK_HELD.test(String(result?.stderr))
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
function sleepSync(ms) {
|
|
69
|
+
Atomics.wait(new Int32Array(new SharedArrayBuffer(4)), 0, 0, ms)
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
function run(spawnGit, root, args, extra = {}) {
|
|
73
|
+
const fast = spawnGit === spawnSync || spawnGit.real === spawnSync ? fastGitAnswer(root, args) : null
|
|
74
|
+
if (fast !== null) return fast
|
|
75
|
+
const once = () => spawnGit("git", ["-C", root, ...args], { windowsHide: true, encoding: "utf8", timeout: GIT_TIMEOUT_MS, ...extra })
|
|
76
|
+
let result = once()
|
|
77
|
+
if (!["symbolic-ref", "rev-parse", "diff", "ls-files"].includes(args[0]) || result?.error || yieldsGitLock()) return result
|
|
78
|
+
const deadline = Date.now() + LOCK_WAIT_MS
|
|
79
|
+
while (!result?.error && lockHeld(result) && Date.now() < deadline) {
|
|
80
|
+
sleepSync(LOCK_RETRY_MS)
|
|
81
|
+
result = once()
|
|
82
|
+
}
|
|
83
|
+
return result
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
/** True when another Git process holds `root`'s index lock right now. False when Git cannot say. */
|
|
87
|
+
export function indexLockHeld(root, spawnGit) {
|
|
88
|
+
const result = (spawnGit === spawnSync ? fastGitAnswer(root, ["rev-parse", "--git-path", "index.lock"]) : null) ?? spawnGit("git", ["-C", root, "rev-parse", "--git-path", "index.lock"], { windowsHide: true, encoding: "utf8", timeout: GIT_TIMEOUT_MS })
|
|
89
|
+
return result.status === 0 && existsSync(path.resolve(root, String(result.stdout).trim()))
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
/** True when `result` (a `spawnSync`-shaped return value) is `spawnGit` reporting its own timeout kill. */
|
|
93
|
+
function timedOut(result) {
|
|
94
|
+
return Boolean(result.error) && result.error.code === "ETIMEDOUT"
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
/** True when `root` is inside a Git work tree. A failing or missing `git` means no. */
|
|
98
|
+
export function isGitRepository(root, spawnGit) {
|
|
99
|
+
let result
|
|
100
|
+
try {
|
|
101
|
+
result = run(spawnGit, root, ["rev-parse", "--is-inside-work-tree"])
|
|
102
|
+
} catch {
|
|
103
|
+
return false
|
|
104
|
+
}
|
|
105
|
+
return result.status === 0 && result.stdout.trim() === "true"
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
/**
|
|
109
|
+
* True when any of `relPaths` (relative to `root`) holds unstaged changes to a
|
|
110
|
+
* tracked file (`git diff --name-only`) or an untracked, non-ignored file
|
|
111
|
+
* (`git ls-files --others --exclude-standard`). A failing Git command counts
|
|
112
|
+
* as unstaged work, so a caller refusing on it fails safe.
|
|
113
|
+
*/
|
|
114
|
+
export function hasUnstagedWork(root, relPaths, spawnGit) {
|
|
115
|
+
for (const args of [
|
|
116
|
+
["diff", "--name-only", "--", ...relPaths],
|
|
117
|
+
["ls-files", "--others", "--exclude-standard", "--", ...relPaths],
|
|
118
|
+
]) {
|
|
119
|
+
const result = run(spawnGit, root, args)
|
|
120
|
+
if (result.status !== 0 || result.stdout.trim() !== "") return true
|
|
121
|
+
}
|
|
122
|
+
return false
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
/**
|
|
126
|
+
* Whether Git holds any of `relPaths` as a conflict (unmerged index entries): staging such a path marks the conflict resolved with its
|
|
127
|
+
* markers still in the file. `false` when Git cannot say, so the caller's own stage or commit reports Git's failure.
|
|
128
|
+
*/
|
|
129
|
+
export function hasUnmergedPath(root, relPaths, spawnGit) {
|
|
130
|
+
const result = run(spawnGit, root, ["ls-files", "-u", "--", ...relPaths])
|
|
131
|
+
return result.status === 0 && result.stdout.trim() !== ""
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
/**
|
|
135
|
+
* What is staged at `relPaths`, with renames detected: `[{ status, paths }]`, where `status` is git's letter plus a rename's similarity (`R100`, `D`, `A`, `M`)
|
|
136
|
+
* and `paths` is the old and new path of a rename or the one path otherwise. Returns `null` when Git fails, so a caller refusing on it fails safe.
|
|
137
|
+
*/
|
|
138
|
+
export function stagedChanges(root, relPaths, spawnGit) {
|
|
139
|
+
const result = run(spawnGit, root, ["diff", "--cached", "-M", "--name-status", "-z", "--", ...relPaths])
|
|
140
|
+
if (result.status !== 0) return null
|
|
141
|
+
const fields = result.stdout.split("\0")
|
|
142
|
+
const changes = []
|
|
143
|
+
for (let i = 0; i < fields.length && fields[i] !== ""; ) {
|
|
144
|
+
const status = fields[i]
|
|
145
|
+
const count = status.startsWith("R") || status.startsWith("C") ? 2 : 1
|
|
146
|
+
changes.push({ status, paths: fields.slice(i + 1, i + 1 + count) })
|
|
147
|
+
i += 1 + count
|
|
148
|
+
}
|
|
149
|
+
return changes
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
/** The index entries at exactly `relPaths`: `[{ mode, sha, stage, path }]`, or `null` when Git fails. A path the index does not hold has no entry. */
|
|
153
|
+
export function indexEntries(root, relPaths, spawnGit) {
|
|
154
|
+
const result = run(spawnGit, root, ["ls-files", "-s", "-z", "--", ...relPaths])
|
|
155
|
+
if (result.status !== 0) return null
|
|
156
|
+
return result.stdout.split("\0").filter(Boolean).map((record) => {
|
|
157
|
+
const [meta, entryPath] = record.split("\t")
|
|
158
|
+
const [mode, sha, stage] = meta.split(" ")
|
|
159
|
+
return { mode, sha, stage, path: entryPath }
|
|
160
|
+
})
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
// #561: a commit Git was killed for (a post-commit hook such as Git LFS's outlasting GIT_TIMEOUT_MS) or reported as failed can
|
|
164
|
+
// still have landed. The failed dispatch is never repeated (a commit's hooks may already have run); HEAD is read back once instead.
|
|
165
|
+
const READBACK_LIMIT = 50
|
|
166
|
+
|
|
167
|
+
/** HEAD's full hash, `""` for an unborn branch, or null when Git cannot say. A read; only `run`'s read retry applies. */
|
|
168
|
+
function headOf(root, spawnGit) {
|
|
169
|
+
let result = run(spawnGit, root, ["rev-parse", "--verify", "-q", "HEAD"])
|
|
170
|
+
// Cut off by the clock, not answered: asked once more with three times the room.
|
|
171
|
+
if (result?.error) result = run(patiently(spawnGit), root, ["rev-parse", "--verify", "-q", "HEAD"])
|
|
172
|
+
if (result?.error) return null
|
|
173
|
+
if (result?.status === 0) return String(result.stdout).trim()
|
|
174
|
+
return result?.status === 1 && String(result?.stdout ?? "").trim() === "" ? "" : null
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
// Git's own message clean-up, near enough to compare: trailing spaces off each line, runs of blank lines folded, ends trimmed.
|
|
178
|
+
const cleanMessage = (text) => String(text).split("\n").map((line) => line.replace(/\s+$/u, "")).join("\n").replace(/\n{3,}/gu, "\n\n").trim()
|
|
179
|
+
|
|
180
|
+
function nulList(result) {
|
|
181
|
+
return String(result.stdout).split("\0").filter(Boolean)
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
/** The entries `commit`'s tree holds at `relPaths`, as sorted `mode sha\tpath` lines, or null when Git cannot say. */
|
|
185
|
+
function treeEntries(root, commit, relPaths, spawnGit) {
|
|
186
|
+
if (spawnGit === spawnSync) return treeLines(spawnGit, root, commit, relPaths)
|
|
187
|
+
const tree = run(spawnGit, root, ["ls-tree", "-r", "-z", commit, "--", ...relPaths])
|
|
188
|
+
if (tree?.status !== 0) return null
|
|
189
|
+
return nulList(tree).map((record) => {
|
|
190
|
+
const [meta, entryPath] = record.split("\t")
|
|
191
|
+
const [mode, , sha] = meta.split(" ")
|
|
192
|
+
return `${mode} ${sha}\t${entryPath}`
|
|
193
|
+
}).sort()
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
const entryLines = (entries) => entries.map((entry) => `${entry.mode} ${entry.sha}\t${entry.path}`).sort()
|
|
197
|
+
const sameEntries = (a, b) => JSON.stringify(a) === JSON.stringify(b)
|
|
198
|
+
|
|
199
|
+
/**
|
|
200
|
+
* Whether a commit of exactly `relPaths` with `message` landed after HEAD was `before` (`""` for unborn), and whether it is still in effect.
|
|
201
|
+
* `expected` is what this call meant to commit at `relPaths`, captured before it was dispatched (sorted `mode sha\tpath` lines; null when it
|
|
202
|
+
* could not be captured). Returns `{ readback, landed }`:
|
|
203
|
+
* - `committed`: a new commit on HEAD has that message, changes only those paths and holds `expected` there, and HEAD holds `expected` there now;
|
|
204
|
+
* - `absent`: HEAD has not moved, or no new commit touches those paths;
|
|
205
|
+
* - `unknown` otherwise, and whenever Git cannot answer. When our commit landed but HEAD no longer holds it, `landed` names both
|
|
206
|
+
* (`{ commit, head }`): it happened, but it is not in effect, so nothing claims completion and nothing replays it. Reads only.
|
|
207
|
+
*/
|
|
208
|
+
export function readBackCommit(root, relPaths, message, before, expected, spawnGit) {
|
|
209
|
+
const unknown = { readback: "unknown" }
|
|
210
|
+
if (before === null) return unknown
|
|
211
|
+
const after = headOf(root, spawnGit)
|
|
212
|
+
if (after === null) return unknown
|
|
213
|
+
if (after === before) return { readback: "absent" }
|
|
214
|
+
if (after === "") return unknown
|
|
215
|
+
const listed = run(spawnGit, root, ["rev-list", `--max-count=${READBACK_LIMIT + 1}`, before === "" ? after : `${before}..${after}`])
|
|
216
|
+
if (listed?.status !== 0) return unknown
|
|
217
|
+
const commits = String(listed.stdout).split("\n").map((line) => line.trim()).filter(Boolean)
|
|
218
|
+
if (commits.length > READBACK_LIMIT) return unknown
|
|
219
|
+
let touched = false
|
|
220
|
+
for (const commit of commits) {
|
|
221
|
+
const ours = run(spawnGit, root, ["diff-tree", "--root", "--no-commit-id", "-r", "--name-only", "-z", commit, "--", ...relPaths])
|
|
222
|
+
if (ours?.status !== 0) return unknown
|
|
223
|
+
const inside = nulList(ours).length
|
|
224
|
+
if (inside === 0) continue
|
|
225
|
+
touched = true
|
|
226
|
+
if (expected === null) return unknown
|
|
227
|
+
const all = run(spawnGit, root, ["diff-tree", "--root", "--no-commit-id", "-r", "--name-only", "-z", commit])
|
|
228
|
+
const body = run(spawnGit, root, ["log", "-1", "--format=%B", commit])
|
|
229
|
+
if (all?.status !== 0 || body?.status !== 0) return unknown
|
|
230
|
+
if (nulList(all).length !== inside || cleanMessage(body.stdout) !== cleanMessage(message)) continue
|
|
231
|
+
const held = treeEntries(root, commit, relPaths, spawnGit)
|
|
232
|
+
if (held === null) return unknown
|
|
233
|
+
if (!sameEntries(held, expected)) continue
|
|
234
|
+
const now = commit === after ? held : treeEntries(root, after, relPaths, spawnGit)
|
|
235
|
+
if (now === null) return unknown
|
|
236
|
+
return sameEntries(now, expected) ? { readback: "committed" } : { readback: "unknown", landed: { commit, head: after } }
|
|
237
|
+
}
|
|
238
|
+
return touched ? unknown : { readback: "absent" }
|
|
239
|
+
}
|
|
240
|
+
|
|
241
|
+
// A failed commit call's answer: `ok` when the read-back finds it landed and in effect (`readback: "committed"`), so every caller schedules its push; otherwise the failure with its read-back.
|
|
242
|
+
// A failure also carries what the call meant to commit (`capture`: the HEAD and branch it read before dispatch and the captured entries),
|
|
243
|
+
// so its route can finish exactly that change and never whatever the paths hold later (R2, R3). No capture means no route may commit.
|
|
244
|
+
// `made` is set when the call is known to have made a commit object whose effect is uncertain (a branch update cut off, or a
|
|
245
|
+
// post-commit hook that moved HEAD): a read-back that finds nothing then says `unknown`, never `absent`.
|
|
246
|
+
// A read-back that could not answer is asked once more with three times the room each read had: on a slow machine the commit often did land, and "unknown" is only for a Git that still cannot say.
|
|
247
|
+
const patiently = (spawnGit) => (command, args, options) => spawnGit(command, args, { windowsHide: true, ...options, timeout: options.timeout * 3 })
|
|
248
|
+
|
|
249
|
+
function afterFailedCommit(stderr, root, relPaths, message, before, expected, spawnGit, branch, made = false) {
|
|
250
|
+
let answer = readBackCommit(root, relPaths, message, before, expected, spawnGit)
|
|
251
|
+
if (answer.readback === "unknown" && answer.landed === undefined) answer = readBackCommit(root, relPaths, message, before, expected, patiently(spawnGit))
|
|
252
|
+
const { readback, landed } = answer
|
|
253
|
+
if (readback === "committed") {
|
|
254
|
+
recordToolCommit(root)
|
|
255
|
+
return { ok: true, stderr, readback }
|
|
256
|
+
}
|
|
257
|
+
const capture = before !== null && expected !== null && branch ? { before, branch, expected } : null
|
|
258
|
+
return { ok: false, stderr, readback: made && readback === "absent" ? "unknown" : readback, ...(landed ? { landed } : {}), ...(capture ? { capture } : {}) }
|
|
259
|
+
}
|
|
260
|
+
|
|
261
|
+
/** The branch HEAD is on, or null for a detached HEAD or when Git cannot say. A read. */
|
|
262
|
+
function branchOf(root, spawnGit) {
|
|
263
|
+
const head = run(spawnGit, root, ["symbolic-ref", "--short", "-q", "HEAD"])
|
|
264
|
+
const name = head?.status === 0 ? String(head.stdout ?? "").trim() : ""
|
|
265
|
+
return name === "" ? null : name
|
|
266
|
+
}
|
|
267
|
+
|
|
268
|
+
/**
|
|
269
|
+
* Commits exactly what the index holds at `relPaths` (`entries`, from `indexEntries` for the same paths), never what the working tree holds there, and only on
|
|
270
|
+
* the HEAD it read (#632). It builds a private index from that HEAD with the real index's entry for each path (and every leaf HEAD holds under a folder path
|
|
271
|
+
* that the index no longer does removed), runs the hooks git commit runs, makes the commit on that HEAD, and moves the branch by one compare-and-swap from it:
|
|
272
|
+
* another writer's commit landing at any point in between makes Git refuse, so it stands and nothing of this call's is committed over it. That is
|
|
273
|
+
* `cas-commit.js`'s `commitCaptured`, the core the hand finish uses, here with Desk's own commit marker and one total `GIT_TIMEOUT_MS` budget for the whole
|
|
274
|
+
* commit, every read before and after it and the read-back after a failure included: a Git call the budget leaves no room for is not run, and an answer it
|
|
275
|
+
* leaves unread is `unknown`. While a merge, cherry-pick, revert or rebase is in progress it commits nothing. A pre-commit hook that changes the tree Desk
|
|
276
|
+
* judged holds the commit (what the hook wrote stays written); one that writes only to the working tree does not. The real index is untouched, so other staged work stays staged,
|
|
277
|
+
* and a later edit to a file in the working tree can never ride along. Returns `{ ok, stderr }`, and on a failure the read-back and capture
|
|
278
|
+
* (`afterFailedCommit`); never throws on a Git failure.
|
|
279
|
+
*/
|
|
280
|
+
export function commitIndexPaths(root, relPaths, entries, message, spawnGit, stateBranch) {
|
|
281
|
+
const deadline = { at: Date.now() + GIT_TIMEOUT_MS }
|
|
282
|
+
const step = budgeted(spawnGit, deadline)
|
|
283
|
+
const refusal = commitBranchRefusal(root, step, stateBranch)
|
|
284
|
+
if (refusal !== null) return { ok: false, stderr: refusal, readback: "absent" }
|
|
285
|
+
let before = headOf(root, step)
|
|
286
|
+
const branch = branchOf(root, step)
|
|
287
|
+
if (before === null || branch === null) return { ok: false, stderr: "Git could not read the branch and HEAD to commit on, so nothing was committed", readback: "absent" }
|
|
288
|
+
// What this call means to commit is exactly `entries` at `relPaths`, and nothing at the paths the index does not hold.
|
|
289
|
+
const expected = entryLines(entries)
|
|
290
|
+
const failed = (reason, made) => {
|
|
291
|
+
const answer = afterFailedCommit(reason, root, relPaths, message, before, expected, step, branch, made)
|
|
292
|
+
return answer.readback === "unknown" && Date.now() >= deadline.at ? { ...answer, stderr: `${reason}; the commit's time budget ran out before the result could be read back, so its read-back is unknown: read back before anything else` } : answer
|
|
293
|
+
}
|
|
294
|
+
const operation = operationAnswer(step, root)
|
|
295
|
+
if (operation) return failed(operation.reason, false)
|
|
296
|
+
if (sameEntries(before === "" ? [] : treeEntries(root, before, relPaths, step), expected)) return failed("nothing to commit: HEAD already holds these paths as the index does", false)
|
|
297
|
+
let answer = commitCaptured({ root, paths: relPaths, wanted: expected, head: before, branch, message, spawnGit, env: { ...process.env, [TOOL_COMMIT_ENV]: "1" }, toolCommit: true, deadline, backgroundPostCommit: spawnGit === spawnSync })
|
|
298
|
+
// Another writer moved the branch while this commit was being qualified. Nothing was changed, so it is qualified again on the branch as it now is, here, within the same budget, rather than handed back.
|
|
299
|
+
for (let again = 0; answer.state === "held" && answer.moved === true && again < QUALIFY_AGAIN; again += 1) {
|
|
300
|
+
const now = headOf(root, step)
|
|
301
|
+
if (now === null || now === before) break
|
|
302
|
+
before = now
|
|
303
|
+
if (sameEntries(treeEntries(root, before, relPaths, step), expected)) return failed("nothing to commit: HEAD already holds these paths as the index does", false)
|
|
304
|
+
answer = commitCaptured({ root, paths: relPaths, wanted: expected, head: before, branch, message, spawnGit, env: { ...process.env, [TOOL_COMMIT_ENV]: "1" }, toolCommit: true, deadline, backgroundPostCommit: spawnGit === spawnSync })
|
|
305
|
+
}
|
|
306
|
+
if (answer.state === "finished") {
|
|
307
|
+
recordToolCommit(root)
|
|
308
|
+
return { ok: true, stderr: "" }
|
|
309
|
+
}
|
|
310
|
+
return failed(answer.reason, answer.commit !== undefined)
|
|
311
|
+
}
|
|
312
|
+
|
|
313
|
+
/**
|
|
314
|
+
* `git add` exactly `relPaths` (relative to `root`); `all: true` adds `-A`, so a deletion in the working tree is staged too,
|
|
315
|
+
* still only at those paths. Returns `{ ok, stderr }`; never throws on a Git failure. A call that runs past `GIT_TIMEOUT_MS` is
|
|
316
|
+
* killed and reported as `{ ok: false, stderr: "timeout" }`.
|
|
317
|
+
*/
|
|
318
|
+
export function stagePaths(root, relPaths, spawnGit, stateBranch, { all = false } = {}) {
|
|
319
|
+
const refusal = commitBranchRefusal(root, spawnGit, stateBranch)
|
|
320
|
+
if (refusal !== null) return { ok: false, stderr: refusal }
|
|
321
|
+
if (!yieldsGitLock()) {
|
|
322
|
+
const deadline = Date.now() + LOCK_WAIT_MS
|
|
323
|
+
while (indexLockHeld(root, spawnGit) && Date.now() < deadline) sleepSync(LOCK_RETRY_MS)
|
|
324
|
+
}
|
|
325
|
+
// `--sparse` stages a path a sparse checkout leaves out, such as a screenshot added in a hosted desk that excludes media; on a full checkout it
|
|
326
|
+
// changes nothing, and with `-A` it never stages a left-out file as deleted.
|
|
327
|
+
const result = run(spawnGit, root, ["add", "--sparse", ...(all ? ["-A"] : []), "--", ...relPaths])
|
|
328
|
+
if (timedOut(result)) return { ok: false, stderr: "timeout" }
|
|
329
|
+
return { ok: result.status === 0, stderr: result.stderr }
|
|
330
|
+
}
|
|
331
|
+
|
|
332
|
+
// A sparse-checkout pattern that matches every file under one folder, with Git's pattern characters escaped. `/dir/` alone would not: an exclusion
|
|
333
|
+
// such as `!*.png` matches the file itself, so it wins over a pattern that only matches its folder.
|
|
334
|
+
const folderPattern = (rel) => `/${rel.split(path.sep).join("/").replace(/[\\*?[\]!#]/gu, "\\$&").replace(/ $/u, "\\ ")}/**`
|
|
335
|
+
|
|
336
|
+
/**
|
|
337
|
+
* On a non-cone sparse checkout (a hosted desk leaves media out), brings `dirs` (absolute, under `root`) wholly into the checkout, left-out files
|
|
338
|
+
* included, until `releaseFromCheckout` takes them out again: a tool that hashes, moves and stages a whole folder then sees what Git holds there. Git
|
|
339
|
+
* fetches a partial clone's missing blobs as it writes them. Returns the patterns it added: none on a full or cone-mode checkout, or when Git or the
|
|
340
|
+
* pattern file cannot be read, and then the tool runs as before. Never throws. The pattern file is read and rewritten in one synchronous step, so
|
|
341
|
+
* writers in other processes can only lose an added line in that instant; the cost is disk (a folder stays on disk until the gateway's next
|
|
342
|
+
* start sets the patterns again), never a commit.
|
|
343
|
+
*/
|
|
344
|
+
export function includeInCheckout(root, dirs, spawnGit) {
|
|
345
|
+
try {
|
|
346
|
+
const file = sparsePatternFile(root, spawnGit)
|
|
347
|
+
const top = file === null ? null : run(spawnGit, root, ["rev-parse", "--show-toplevel"])
|
|
348
|
+
if (top === null || top.status !== 0) return []
|
|
349
|
+
const physical = realpathSync(root)
|
|
350
|
+
const added = dirs.map((dir) => folderPattern(path.relative(String(top.stdout).trim(), path.join(physical, path.relative(root, dir)))))
|
|
351
|
+
writeFileSync(file, `${readFileSync(file, "utf8").replace(/\n?$/u, "\n")}${added.join("\n")}\n`)
|
|
352
|
+
run(spawnGit, root, ["sparse-checkout", "reapply"])
|
|
353
|
+
return added
|
|
354
|
+
} catch {
|
|
355
|
+
return []
|
|
356
|
+
}
|
|
357
|
+
}
|
|
358
|
+
|
|
359
|
+
/** Takes the patterns `includeInCheckout` added back out, so the folders' left-out files leave the disk again. A no-op with none; never throws. */
|
|
360
|
+
export function releaseFromCheckout(root, added, spawnGit) {
|
|
361
|
+
try {
|
|
362
|
+
const file = added.length === 0 ? null : sparsePatternFile(root, spawnGit)
|
|
363
|
+
if (file === null) return
|
|
364
|
+
const lines = readFileSync(file, "utf8").split("\n")
|
|
365
|
+
for (const pattern of added) {
|
|
366
|
+
const at = lines.lastIndexOf(pattern)
|
|
367
|
+
if (at !== -1) lines.splice(at, 1)
|
|
368
|
+
}
|
|
369
|
+
writeFileSync(file, lines.join("\n"))
|
|
370
|
+
run(spawnGit, root, ["sparse-checkout", "reapply"])
|
|
371
|
+
} catch {
|
|
372
|
+
// The folders stay on disk until the patterns are next set; nothing else depends on this.
|
|
373
|
+
}
|
|
374
|
+
}
|
|
375
|
+
|
|
376
|
+
// The sparse-checkout pattern file of the checkout at `root` when non-cone sparse checkout is on, or null.
|
|
377
|
+
function sparsePatternFile(root, spawnGit) {
|
|
378
|
+
if (String(run(spawnGit, root, ["config", "--get", "core.sparseCheckout"]).stdout).trim() !== "true") return null
|
|
379
|
+
// A cone-mode checkout takes folder patterns only; this one's own `/dir/**` lines would turn cone matching off.
|
|
380
|
+
if (String(run(spawnGit, root, ["config", "--get", "core.sparseCheckoutCone"]).stdout).trim() !== "false") return null
|
|
381
|
+
const file = String(run(spawnGit, root, ["rev-parse", "--path-format=absolute", "--git-path", "info/sparse-checkout"]).stdout).trim()
|
|
382
|
+
return file !== "" && existsSync(file) ? file : null
|
|
383
|
+
}
|
|
384
|
+
|
|
385
|
+
/**
|
|
386
|
+
* What `git commit -- <relPaths>` is about to commit, captured before it is dispatched (R4, 0972 on #625): the index entries at those paths, as sorted
|
|
387
|
+
* `mode sha\tpath` lines, when the working tree there matches the index (the case for every Desk caller, which stages first). Null when it does not or
|
|
388
|
+
* Git cannot say: then the commit would take working-tree bytes this read did not hash, so a read-back can never call it committed. Reads only.
|
|
389
|
+
*/
|
|
390
|
+
function capturedPaths(root, relPaths, spawnGit, entries) {
|
|
391
|
+
if (entries === null || entries.some((entry) => entry.stage !== "0")) return null
|
|
392
|
+
const differs = run(spawnGit, root, ["diff", "--quiet", "--", ...relPaths])
|
|
393
|
+
return differs?.status === 0 ? entryLines(entries) : null
|
|
394
|
+
}
|
|
395
|
+
|
|
396
|
+
// A path written the way the index spells it (no `./`, no `..`, not absolute): the private-index commit matches paths by that spelling.
|
|
397
|
+
const plainRelative = (p) => !path.isAbsolute(p) && path.posix.normalize(p) === p && !p.startsWith("../") && p !== "." && !p.includes("\\")
|
|
398
|
+
|
|
399
|
+
/**
|
|
400
|
+
* `git commit` exactly `relPaths` (relative to `root`) with `message`, never
|
|
401
|
+
* `-a`/`-A` and never a pattern: the pathspec after `--` names precisely the
|
|
402
|
+
* paths this call commits, so a path another process staged in the same
|
|
403
|
+
* index in the meantime is left staged and untouched, not swept into this
|
|
404
|
+
* commit. Returns `{ ok, stderr }`; never throws on a Git failure. A call
|
|
405
|
+
* that runs past `GIT_TIMEOUT_MS` (a hung commit hook, most often) is killed
|
|
406
|
+
* and reported as `{ ok: false, stderr: "timeout" }`.
|
|
407
|
+
*/
|
|
408
|
+
export function commitPaths(root, relPaths, message, spawnGit, stateBranch, { keepLocal = false } = {}) {
|
|
409
|
+
// Index counts cannot distinguish deliberate deletions from damage. Publication builds from the target tree and
|
|
410
|
+
// checks every change against relPaths; local commits also start from HEAD, not from unrelated index entries.
|
|
411
|
+
// A checkout on another branch (a worktree) publishes the commit to the remote's default branch instead of committing on its own branch.
|
|
412
|
+
if (typeof stateBranch !== "string") {
|
|
413
|
+
const target = defaultBranchForPublication(root, spawnGit)
|
|
414
|
+
if (target !== null) return publishCardCommit({ root, relPaths, message, defaultBranch: target, spawnGit, keepLocal })
|
|
415
|
+
}
|
|
416
|
+
const refusal = commitBranchRefusal(root, spawnGit, stateBranch)
|
|
417
|
+
if (refusal !== null) return { ok: false, stderr: refusal, readback: "absent" }
|
|
418
|
+
const before = headOf(root, spawnGit)
|
|
419
|
+
const branch = branchOf(root, spawnGit)
|
|
420
|
+
const entries = indexEntries(root, relPaths, spawnGit)
|
|
421
|
+
const expected = capturedPaths(root, relPaths, spawnGit, entries)
|
|
422
|
+
// A real run whose paths are staged and clean commits on a private index with the post-commit hook (Git LFS's whole-tree walk) detached, so a save on a big repository returns at once.
|
|
423
|
+
if (spawnGit === spawnSync && expected !== null && relPaths.every(plainRelative)) {
|
|
424
|
+
// Only when every path is one file the index holds: a folder or a deletion keeps the commit it always had.
|
|
425
|
+
if (entries !== null && relPaths.every((p) => entries.some((entry) => entry.path === p))) return commitIndexPaths(root, relPaths, entries, message, spawnGit, stateBranch)
|
|
426
|
+
}
|
|
427
|
+
// The desk's own pre-commit hook (`desk/card-commit-guard.js`) refuses a commit that changes a task card unless Desk is the one committing:
|
|
428
|
+
// this is Desk's commit path, so it says so for the git call (and only for that call).
|
|
429
|
+
const env = { ...process.env, [TOOL_COMMIT_ENV]: "1" }
|
|
430
|
+
let result = run(spawnGit, root, ["commit", "-m", message, "--", ...relPaths], { env })
|
|
431
|
+
// A commit cut off by the clock on a slow machine is read back, and when it did not land it is run once more with room to finish, rather than handed back as a failure.
|
|
432
|
+
if (timedOut(result) && readBackCommit(root, relPaths, message, before, expected, spawnGit).readback === "absent" && !indexLockHeld(root, spawnGit)) {
|
|
433
|
+
result = run(spawnGit, root, ["commit", "-m", message, "--", ...relPaths], { env, timeout: COMMIT_RETRY_TIMEOUT_MS })
|
|
434
|
+
}
|
|
435
|
+
if (!timedOut(result) && result.status === 0) {
|
|
436
|
+
recordToolCommit(root)
|
|
437
|
+
return { ok: true, stderr: result.stderr }
|
|
438
|
+
}
|
|
439
|
+
return afterFailedCommit(timedOut(result) ? "timeout" : result.stderr, root, relPaths, message, before, expected, spawnGit, branch)
|
|
440
|
+
}
|