@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,201 @@
|
|
|
1
|
+
import { spawn } from "node:child_process"
|
|
2
|
+
import { accessSync, constants } from "node:fs"
|
|
3
|
+
import * as path from "node:path"
|
|
4
|
+
|
|
5
|
+
// Capture the host environment once. In particular PATH, executable search paths and loader variables are not input.
|
|
6
|
+
const HOST_ENV = { ...process.env }
|
|
7
|
+
let trustedGit
|
|
8
|
+
|
|
9
|
+
// Windows environment names are case-insensitive, but HOST_ENV is a plain copy, so its lookups are not. Claude Code runs hooks through Git Bash, which passes PROGRAMFILES in capitals.
|
|
10
|
+
function windowsEnvValue(env, name) {
|
|
11
|
+
if (typeof env[name] === "string") return env[name]
|
|
12
|
+
const lower = name.toLowerCase()
|
|
13
|
+
const key = Object.keys(env).find((candidate) => candidate.toLowerCase() === lower)
|
|
14
|
+
return key === undefined ? undefined : env[key]
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
export function resolveInspectionGit({ platform = process.platform, env = HOST_ENV, accessible = (file) => {
|
|
18
|
+
try { accessSync(file, constants.X_OK); return true } catch { return false }
|
|
19
|
+
} } = {}) {
|
|
20
|
+
const candidates = platform === "win32"
|
|
21
|
+
? [...new Set(["ProgramFiles", "ProgramW6432", "ProgramFiles(x86)"].map((name) => windowsEnvValue(env, name)).filter(Boolean))].map((root) => path.win32.join(root, "Git", "cmd", "git.exe"))
|
|
22
|
+
: ["/usr/bin/git", "/usr/local/bin/git", "/opt/homebrew/bin/git"]
|
|
23
|
+
const executable = candidates.find(accessible)
|
|
24
|
+
if (!executable) throw Object.assign(new Error("Install Git in a standard system location: trusted Git is unavailable; install Git in a standard system location"), { code: "git_inspection_install_git_in_a_standard" })
|
|
25
|
+
return executable
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
function inspectionEnvironment() {
|
|
29
|
+
const env = { ...HOST_ENV }
|
|
30
|
+
for (const key of Object.keys(env)) {
|
|
31
|
+
if (/^(?:GIT_|LD_|DYLD_)/u.test(key)) delete env[key]
|
|
32
|
+
}
|
|
33
|
+
return { ...env, GIT_TERMINAL_PROMPT: "0", GIT_OPTIONAL_LOCKS: "0", GIT_NO_LAZY_FETCH: "1", LC_ALL: "C" }
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
// A hook answers its host within seconds, so by default each inspection call gets 2 s. Callers off the hook path, such as the detached workspace repair, pass a longer limit.
|
|
37
|
+
export const INSPECTION_TIMEOUT_MS = 2000
|
|
38
|
+
|
|
39
|
+
// No inspection Git may outlive the process that started it. Three layers, each covering what the one before cannot:
|
|
40
|
+
// 1. The timeout above kills the child, but only while this process is alive.
|
|
41
|
+
// 2. Each child leads its own process group, and `reapLive` kills every live group when this process exits or receives SIGTERM, SIGINT or SIGHUP. Detaching means a Ctrl-C aimed at the host's group no longer reaches Git on its own; the handler covers that.
|
|
42
|
+
// 3. A kernel alarm armed inside the child itself. `perl -e 'alarm ...; exec git ...'` replaces itself with Git, and a pending alarm survives exec, so the kernel delivers SIGALRM to Git at the deadline whether or not any parent is alive. This is the only layer that covers a SIGKILLed parent or a host that kills just the hook PID: a Git blocked in open() on a FIFO, a stalled network filesystem or a locked include would otherwise stay blocked forever.
|
|
43
|
+
// The alarm adds no process (perl becomes Git) and runs one second after the parent's own timeout so it never races it. Windows has neither process groups nor perl, so there the first two layers are reduced to killing the child itself.
|
|
44
|
+
const MAX_OUTPUT = 1024 * 1024
|
|
45
|
+
const WATCHDOG_SCRIPT = 'alarm shift @ARGV; exec { $ARGV[0] } @ARGV or do { print STDERR "exec failed: $!\n"; exit 127 }'
|
|
46
|
+
const WATCHDOG_CANDIDATES = ["/usr/bin/perl", "/usr/local/bin/perl", "/opt/homebrew/bin/perl"]
|
|
47
|
+
const SIGNALS = ["SIGTERM", "SIGINT", "SIGHUP"]
|
|
48
|
+
|
|
49
|
+
export function isExecutable(file) {
|
|
50
|
+
try { accessSync(file, constants.X_OK); return true } catch { return false }
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
export function resolveWatchdog({ platform = process.platform, accessible = isExecutable } = {}) {
|
|
54
|
+
return platform === "win32" ? undefined : WATCHDOG_CANDIDATES.find(accessible)
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
export function watchdogSeconds(timeoutMs) {
|
|
58
|
+
return Math.ceil(timeoutMs / 1000) + 1
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
const liveChildren = new Set()
|
|
62
|
+
const signalHandlers = new Map()
|
|
63
|
+
|
|
64
|
+
/** Where the child runs: its own process group everywhere but Windows, which has none. */
|
|
65
|
+
export function inspectionSpawnOptions(platform = process.platform) {
|
|
66
|
+
return { detached: platform !== "win32" }
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
/** The command line for one inspection read: Git behind the alarm wrapper when there is one, else Git itself. The wrapper is perl, which reads PERL* variables as code and library paths, so they are not input either; the caller's environment is copied, never changed. Git's progress meter uses setitimer(ITIMER_REAL), which would replace the alarm, but the guard's read-only commands never show progress. */
|
|
70
|
+
export function inspectionCommand({ watchdog, git, args, timeoutMs, env }) {
|
|
71
|
+
if (!watchdog) return { file: git, argv: args, env }
|
|
72
|
+
const clean = Object.fromEntries(Object.entries(env).filter(([key]) => !/^PERL/u.test(key)))
|
|
73
|
+
return { file: watchdog, argv: ["-e", WATCHDOG_SCRIPT, String(watchdogSeconds(timeoutMs)), git, ...args], env: clean }
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
export function killProcessGroup(child, { kill = process.kill, platform = process.platform } = {}) {
|
|
77
|
+
if (child.exitCode !== null || child.signalCode !== null) return
|
|
78
|
+
try {
|
|
79
|
+
if (platform === "win32") child.kill("SIGKILL")
|
|
80
|
+
else kill(-child.pid, "SIGKILL")
|
|
81
|
+
} catch {
|
|
82
|
+
try { child.kill("SIGKILL") } catch { /* already gone */ }
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
export function liveInspectionChildren() {
|
|
87
|
+
return liveChildren.size
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
function reapLive() {
|
|
91
|
+
for (const child of liveChildren) killProcessGroup(child)
|
|
92
|
+
liveChildren.clear()
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
/** Kill every live inspection Git, then let the signal take its normal course. Our listener only cleans up: when no other listener handles the signal, deliver it again so the default action still ends the process. */
|
|
96
|
+
export function reapOnSignal(sig, { listenerCount = (name) => process.listenerCount(name), kill = process.kill } = {}) {
|
|
97
|
+
reapLive()
|
|
98
|
+
removeReaper()
|
|
99
|
+
if (listenerCount(sig) === 0) kill(process.pid, sig)
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
function installReaper() {
|
|
103
|
+
if (signalHandlers.size > 0) return
|
|
104
|
+
process.on("exit", reapLive)
|
|
105
|
+
for (const sig of SIGNALS) {
|
|
106
|
+
const handler = () => reapOnSignal(sig)
|
|
107
|
+
signalHandlers.set(sig, handler)
|
|
108
|
+
process.on(sig, handler)
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
function removeReaper() {
|
|
113
|
+
process.removeListener("exit", reapLive)
|
|
114
|
+
for (const [sig, handler] of signalHandlers) process.removeListener(sig, handler)
|
|
115
|
+
signalHandlers.clear()
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
function track(child) {
|
|
119
|
+
liveChildren.add(child)
|
|
120
|
+
installReaper()
|
|
121
|
+
child.once("close", () => {
|
|
122
|
+
liveChildren.delete(child)
|
|
123
|
+
if (liveChildren.size === 0) removeReaper()
|
|
124
|
+
})
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
// Set once the wrapper itself fails to run (perl missing at its path, not executable, or exec failed before Git started). From then on every read in this process runs bare Git, so a broken perl never looks like a Git failure.
|
|
128
|
+
let watchdogBroken = false
|
|
129
|
+
|
|
130
|
+
export function watchdogIsBroken() {
|
|
131
|
+
return watchdogBroken
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
export function resetWatchdogForTests() {
|
|
135
|
+
watchdogBroken = false
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
// perl prints "exec failed" and exits 127 when it cannot exec Git; a spawn error (ENOENT, EACCES) means perl itself would not start. Neither says anything about the repository.
|
|
139
|
+
function wrapperFailed({ error, stderr, timedOut, aborted }) {
|
|
140
|
+
if (!error || timedOut || aborted) return false
|
|
141
|
+
if (error.code === 127) return stderr.startsWith("exec failed:")
|
|
142
|
+
return failedToSpawn(error)
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
function failedToSpawn(error) {
|
|
146
|
+
return typeof error.code === "string" && error.syscall !== undefined
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
// Spawned directly because execFile drops the `detached` option, so its child would share the host's process group and the group kills below would reach nothing.
|
|
150
|
+
function runInspection({ file, argv, env, cwd, signal, timeoutMs }) {
|
|
151
|
+
return new Promise((resolve) => {
|
|
152
|
+
let timedOut = false
|
|
153
|
+
let aborted = false
|
|
154
|
+
let error
|
|
155
|
+
let stdout = ""
|
|
156
|
+
let stderr = ""
|
|
157
|
+
const child = spawn(file, argv, { cwd, env, windowsHide: true, stdio: ["pipe", "pipe", "pipe"], ...inspectionSpawnOptions() })
|
|
158
|
+
track(child)
|
|
159
|
+
// Timeout and abort kill the whole group, as the exit and signal paths do, so a Git helper such as fsmonitor cannot outlive them.
|
|
160
|
+
const timer = setTimeout(() => { timedOut = true; killProcessGroup(child) }, Math.max(1, Math.ceil(timeoutMs)))
|
|
161
|
+
const onAbort = () => { aborted = true; killProcessGroup(child) }
|
|
162
|
+
signal?.addEventListener("abort", onAbort, { once: true })
|
|
163
|
+
const collect = (chunk, which) => {
|
|
164
|
+
if (which === "out") stdout += chunk; else stderr += chunk
|
|
165
|
+
if (stdout.length + stderr.length > MAX_OUTPUT) {
|
|
166
|
+
error ??= Object.assign(Object.assign(new Error("Inspect a smaller scope: Git inspection output exceeded its limit"), { code: "git_inspection_inspect_a_smaller_scope_git" }), { code: "ERR_CHILD_PROCESS_STDIO_MAXBUFFER" })
|
|
167
|
+
killProcessGroup(child)
|
|
168
|
+
}
|
|
169
|
+
}
|
|
170
|
+
child.stdout.setEncoding("utf8").on("data", (chunk) => collect(chunk, "out"))
|
|
171
|
+
child.stderr.setEncoding("utf8").on("data", (chunk) => collect(chunk, "err"))
|
|
172
|
+
// A failed spawn (ENOENT, EACCES) emits "error" and then "close".
|
|
173
|
+
child.once("error", (spawnError) => { error ??= spawnError })
|
|
174
|
+
child.once("close", (code, killedBy) => {
|
|
175
|
+
clearTimeout(timer)
|
|
176
|
+
signal?.removeEventListener("abort", onAbort)
|
|
177
|
+
if (!error && killedBy) error = Object.assign(new Error(`Command failed: killed by ${killedBy}`), { code: null, killed: true, signal: killedBy })
|
|
178
|
+
else if (!error && code !== 0) error = Object.assign(new Error(`Command failed with exit code ${code}`), { code })
|
|
179
|
+
resolve({ error, stdout, stderr, timedOut, aborted })
|
|
180
|
+
})
|
|
181
|
+
})
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
export async function readInspectionGit(cwd, args, { signal, timeoutMs = INSPECTION_TIMEOUT_MS, watchdog = watchdogBroken ? undefined : resolveWatchdog() } = {}) {
|
|
185
|
+
trustedGit ??= resolveInspectionGit()
|
|
186
|
+
const env = inspectionEnvironment()
|
|
187
|
+
if (signal?.aborted) throw Object.assign(new Error("The operation was aborted"), { name: "AbortError", code: "ABORT_ERR" })
|
|
188
|
+
const command = inspectionCommand({ watchdog, git: trustedGit, args, timeoutMs, env })
|
|
189
|
+
let result = await runInspection({ ...command, cwd, signal, timeoutMs })
|
|
190
|
+
if (command.file !== trustedGit && wrapperFailed(result)) {
|
|
191
|
+
result = await runInspection({ file: trustedGit, argv: args, env, cwd, signal, timeoutMs })
|
|
192
|
+
// A spawn that fails for bare Git too (a missing cwd, say) says nothing about perl.
|
|
193
|
+
watchdogBroken = !(result.error && failedToSpawn(result.error))
|
|
194
|
+
}
|
|
195
|
+
const { error, stdout, stderr, timedOut, aborted } = result
|
|
196
|
+
// A killed child is reported only as a SIGKILLed "Command failed"; name the cause so a retained resource explains itself.
|
|
197
|
+
if (timedOut && error) throw Object.assign(Object.assign(new Error(`Run it again, or inspect a smaller scope: Git inspection timed out after ${timeoutMs} ms: git ${args.join(" ")}`), { code: "git_inspection_run_it_again_or_inspect" }), { code: "ETIMEDOUT", cause: error })
|
|
198
|
+
if (aborted && error) throw Object.assign(new Error("The operation was aborted"), { name: "AbortError", code: "ABORT_ERR", cause: error })
|
|
199
|
+
if (error && (error.killed || typeof error.code !== "number")) throw error
|
|
200
|
+
return { ok: !error, stdout: stdout.includes("\0") ? stdout : stdout.trim(), stderr: stderr.trim(), code: error?.code }
|
|
201
|
+
}
|
|
@@ -0,0 +1,157 @@
|
|
|
1
|
+
// Local Git reads for desk_status, run on a worker thread.
|
|
2
|
+
//
|
|
3
|
+
// Starting a process is synchronous in Node, even through the asynchronous child_process calls: the thread that asks waits until the operating system has created the process. On Windows that wait is usually a few milliseconds, but it took about 600 ms once on a CI runner, and desk_status asked from the thread that answers the host, so the call took 619 ms. Here the thread that asks is a worker, so the host's thread only posts a message.
|
|
4
|
+
//
|
|
5
|
+
// One worker serves every read of the process. It starts each Git process itself and waits for it asynchronously, so reads overlap as they did on the host's thread, and the process can still exit while a read is running. It keeps the process alive only while a read is waiting for its answer. It imports nothing but Node's own modules; it never imports index.js, which would start Desk inside the worker.
|
|
6
|
+
|
|
7
|
+
import { execFile } from "node:child_process"
|
|
8
|
+
import { parentPort, Worker, workerData } from "node:worker_threads"
|
|
9
|
+
|
|
10
|
+
const FAILED = { status: 1, stdout: "" }
|
|
11
|
+
|
|
12
|
+
/** Run one read from this thread: resolves with `{ status, stdout }`, where `status` is 0 only when Git ran and exited 0. Never rejects. Aborting `signal` kills the Git process, and the read then resolves as failed once that process has exited and its output has closed; a read asked with a signal that has already aborted starts no process. */
|
|
13
|
+
export function runGitRead({ root, args, env, timeoutMs }, { execGit = execFile, signal } = {}) {
|
|
14
|
+
return new Promise((resolve) => {
|
|
15
|
+
if (signal?.aborted) return resolve(FAILED)
|
|
16
|
+
try {
|
|
17
|
+
// Not execFile's own `signal` option: with it Node calls back as soon as it has sent the kill, while the process may still be working in the folder. A killed child calls back when it has closed.
|
|
18
|
+
const kill = () => child?.kill()
|
|
19
|
+
const child = execGit("git", ["-C", root, ...args], { encoding: "utf8", timeout: timeoutMs, env, windowsHide: true }, (error, stdout) => {
|
|
20
|
+
signal?.removeEventListener("abort", kill)
|
|
21
|
+
resolve(error || typeof stdout !== "string" ? FAILED : { status: 0, stdout })
|
|
22
|
+
})
|
|
23
|
+
signal?.addEventListener("abort", kill, { once: true })
|
|
24
|
+
} catch {
|
|
25
|
+
resolve(FAILED)
|
|
26
|
+
}
|
|
27
|
+
})
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
/** The worker side: answer each read on `port`. Does nothing outside a Desk Git read worker, so importing this module elsewhere is harmless. */
|
|
31
|
+
export function attachGitReadWorker(port, data, { execGit } = {}) {
|
|
32
|
+
if (!port || data?.deskGitReadWorker !== true) return false
|
|
33
|
+
const running = new Map()
|
|
34
|
+
port.on("message", async ({ id, read, cancel }) => {
|
|
35
|
+
if (cancel !== undefined) return running.get(cancel)?.abort()
|
|
36
|
+
const controller = new AbortController()
|
|
37
|
+
running.set(id, controller)
|
|
38
|
+
const answer = await runGitRead(read, { execGit, signal: controller.signal })
|
|
39
|
+
running.delete(id)
|
|
40
|
+
port.postMessage({ id, ...answer })
|
|
41
|
+
})
|
|
42
|
+
return true
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
attachGitReadWorker(parentPort, workerData)
|
|
46
|
+
|
|
47
|
+
/**
|
|
48
|
+
* `{ read, warm, settled, close }`. `read({ root, args, env, timeoutMs }, { signal })` resolves with `{ status, stdout }` and never rejects.
|
|
49
|
+
* `signal` names the read's owner. A read asked after `signal` aborted starts no process and resolves as failed. Aborting `signal` during a read kills its Git process, and the read resolves as failed once that process has closed.
|
|
50
|
+
* `settled(signal)` resolves when every read asked with `signal` has resolved, so an owner that aborts and then awaits it knows none of its Git processes is still running, for example inside a folder it is about to remove.
|
|
51
|
+
* The worker starts at the first read. If it fails or exits, every read it had not answered resolves as failed, and the next read starts a new worker.
|
|
52
|
+
* `onError(reason)` hears the first such failure only: a failed read answers the same as a repository with no remote, so a worker that cannot run must be said once.
|
|
53
|
+
* `warm()` starts the worker ahead of the first read, without holding the process open, so that read does not also wait for a thread to start.
|
|
54
|
+
* `close()` stops the worker; a later read starts another.
|
|
55
|
+
* A read that fails because its worker was lost or closed resolves at once, without waiting for a Git process that worker had started; that process ends by itself or at its timeout.
|
|
56
|
+
*/
|
|
57
|
+
export function createGitReader({ createWorker = (url, options) => new Worker(url, options), onError = () => {} } = {}) {
|
|
58
|
+
let worker = null
|
|
59
|
+
let nextId = 0
|
|
60
|
+
let reported = false
|
|
61
|
+
const waiting = new Map()
|
|
62
|
+
const owned = new WeakMap()
|
|
63
|
+
|
|
64
|
+
const report = (reason) => {
|
|
65
|
+
if (reported) return
|
|
66
|
+
reported = true
|
|
67
|
+
try {
|
|
68
|
+
onError(reason)
|
|
69
|
+
} catch {
|
|
70
|
+
// A logger that fails must not fail the read.
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
const drop = (failed) => {
|
|
75
|
+
if (worker !== failed) return
|
|
76
|
+
worker = null
|
|
77
|
+
for (const resolve of waiting.values()) resolve(FAILED)
|
|
78
|
+
waiting.clear()
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
const start = () => {
|
|
82
|
+
const started = createWorker(new URL(import.meta.url), { workerData: { deskGitReadWorker: true } })
|
|
83
|
+
started.on("message", ({ id, status, stdout }) => {
|
|
84
|
+
const resolve = waiting.get(id)
|
|
85
|
+
waiting.delete(id)
|
|
86
|
+
if (waiting.size === 0) started.unref()
|
|
87
|
+
resolve?.({ status, stdout })
|
|
88
|
+
})
|
|
89
|
+
started.once("error", (error) => {
|
|
90
|
+
if (worker === started) report(`the Git read worker failed: ${error?.message ?? error}`)
|
|
91
|
+
drop(started)
|
|
92
|
+
})
|
|
93
|
+
started.once("exit", (code) => {
|
|
94
|
+
if (worker === started) report(`the Git read worker exited (code ${code})`)
|
|
95
|
+
drop(started)
|
|
96
|
+
})
|
|
97
|
+
return started
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
const ask = (read, signal) => new Promise((resolve) => {
|
|
101
|
+
const id = nextId += 1
|
|
102
|
+
try {
|
|
103
|
+
worker ??= start()
|
|
104
|
+
const asked = worker
|
|
105
|
+
// Runs only while the read waits: its answer, or the loss of its worker, removes this listener.
|
|
106
|
+
const cancel = () => {
|
|
107
|
+
try {
|
|
108
|
+
asked.postMessage({ cancel: id })
|
|
109
|
+
} catch {
|
|
110
|
+
// A worker that cannot hear the cancel is ending, which resolves the read.
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
waiting.set(id, (answer) => {
|
|
114
|
+
signal?.removeEventListener("abort", cancel)
|
|
115
|
+
resolve(answer)
|
|
116
|
+
})
|
|
117
|
+
worker.ref()
|
|
118
|
+
worker.postMessage({ id, read })
|
|
119
|
+
signal?.addEventListener("abort", cancel, { once: true })
|
|
120
|
+
} catch (error) {
|
|
121
|
+
waiting.delete(id)
|
|
122
|
+
if (waiting.size === 0) worker?.unref()
|
|
123
|
+
report(`the Git read worker could not take a read: ${error?.message ?? error}`)
|
|
124
|
+
resolve(FAILED)
|
|
125
|
+
}
|
|
126
|
+
})
|
|
127
|
+
|
|
128
|
+
return {
|
|
129
|
+
read(read, { signal } = {}) {
|
|
130
|
+
if (signal?.aborted) return Promise.resolve(FAILED)
|
|
131
|
+
const asked = ask(read, signal)
|
|
132
|
+
if (signal) {
|
|
133
|
+
const reads = owned.get(signal) ?? new Set()
|
|
134
|
+
owned.set(signal, reads)
|
|
135
|
+
reads.add(asked)
|
|
136
|
+
asked.then(() => reads.delete(asked))
|
|
137
|
+
}
|
|
138
|
+
return asked
|
|
139
|
+
},
|
|
140
|
+
warm() {
|
|
141
|
+
try {
|
|
142
|
+
worker ??= start()
|
|
143
|
+
if (waiting.size === 0) worker.unref()
|
|
144
|
+
} catch (error) {
|
|
145
|
+
report(`the Git read worker could not start: ${error?.message ?? error}`)
|
|
146
|
+
}
|
|
147
|
+
},
|
|
148
|
+
async settled(signal) {
|
|
149
|
+
await Promise.all(owned.get(signal) ?? [])
|
|
150
|
+
},
|
|
151
|
+
async close() {
|
|
152
|
+
const closing = worker
|
|
153
|
+
drop(closing)
|
|
154
|
+
await closing?.terminate()
|
|
155
|
+
},
|
|
156
|
+
}
|
|
157
|
+
}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
// The sync word both the session-start boot script and the compact `desk_status` report, so the two cannot
|
|
2
|
+
// disagree about a failed sync (boot acceptance round A: boot said `degraded` for a failed sync while `desk_status`
|
|
3
|
+
// said `ready` and "in sync", because it only read local ahead/behind counts that a failed pull never changes).
|
|
4
|
+
// This module shares only that word and the `ready`/`degraded` join; everything else in either answer (prerequisites,
|
|
5
|
+
// task cards, push accounts, the search index) stays with its own caller. `setup_required` and `admitting` are also
|
|
6
|
+
// decided by their callers.
|
|
7
|
+
//
|
|
8
|
+
// `degraded` lines are plain sentences, one per problem. The word is `degraded` when any line exists and `ready`
|
|
9
|
+
// when none does.
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* The degraded line for the outcome of a desk sync (`{ state, reason, cause }` as `syncWorkspace` returns it, or
|
|
13
|
+
* the `last_pull` record `desk_status` reads back), or null when the sync did not fail.
|
|
14
|
+
*/
|
|
15
|
+
export function syncDegradation(sync) {
|
|
16
|
+
// Local commits a push could not deliver are degraded even when the pull worked: work the operator thinks is shared is not.
|
|
17
|
+
const stuck = sync?.unpushed?.count > 0 && (typeof sync.unpushed.reason === "string" || sync.unpushed.delivering === false)
|
|
18
|
+
const push = stuck ? `push: ${sync.unpushed.count} local commit(s) not on the remote (${sync.unpushed.reason ?? "not delivered"})` : null
|
|
19
|
+
if (sync?.state !== "unresolved") return push
|
|
20
|
+
const detail = [sync.reason, sync.cause].filter((value) => typeof value === "string" && value !== "")
|
|
21
|
+
return `sync: unresolved${detail.length > 0 ? ` (${detail.join(", ")})` : ""}${push === null ? "" : `; ${push}`}`
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
/** `degraded` when any line says so, otherwise `ready`. */
|
|
25
|
+
export function healthWord(degraded) {
|
|
26
|
+
return degraded.length > 0 ? "degraded" : "ready"
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
const REACHABILITY_CAUSES = new Set(["unreachable", "auth_failed", "deadline"])
|
|
30
|
+
const LAST_PULL_TTL_MS = 24 * 60 * 60 * 1000
|
|
31
|
+
|
|
32
|
+
/**
|
|
33
|
+
* Whether a recorded failed pull still counts. It stops counting once something proves the remote reachable again
|
|
34
|
+
* (a push, or Desk's own fetch, that finished after the failure; both are recorded by Desk, never read from Git's `FETCH_HEAD`, which a failed fetch rewrites too) and in any case after 24 hours, because `desk_status` does not
|
|
35
|
+
* re-run the pull: the record is a note from the last boot, not a live probe. `lastPull.at` is when it failed;
|
|
36
|
+
* `lastPushAt` and `fetchedAt` are ISO text or epoch milliseconds, either may be null.
|
|
37
|
+
*/
|
|
38
|
+
export function pullStillFailing({ lastPull, lastPushAt = null, fetchedAt = null, now = Date.now() }) {
|
|
39
|
+
if (lastPull?.state !== "unresolved") return false
|
|
40
|
+
const failedAt = Date.parse(lastPull.at)
|
|
41
|
+
if (Number.isNaN(failedAt) || now - failedAt > LAST_PULL_TTL_MS) return false
|
|
42
|
+
// A fetch proves reachability only, so it clears only a failure caused by reachability; a conflict, a divergence or an
|
|
43
|
+
// unknown failure stays until a pull succeeds (or a push, or 24 hours).
|
|
44
|
+
const fetchCounts = REACHABILITY_CAUSES.has(lastPull.cause)
|
|
45
|
+
const after = (when) => {
|
|
46
|
+
const at = typeof when === "number" ? when : Date.parse(when)
|
|
47
|
+
return !Number.isNaN(at) && at >= failedAt
|
|
48
|
+
}
|
|
49
|
+
return !(after(lastPushAt) || (fetchCounts && after(fetchedAt)))
|
|
50
|
+
}
|