@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,233 @@
|
|
|
1
|
+
import { spawn as nodeSpawn, spawnSync as nodeSpawnSync } from "node:child_process"
|
|
2
|
+
import { readdirSync, statSync } from "node:fs"
|
|
3
|
+
import * as os from "node:os"
|
|
4
|
+
import * as path from "node:path"
|
|
5
|
+
|
|
6
|
+
export const REEXEC_ATTEMPT_ENV = "DESK_MCP_REEXEC_ATTEMPT"
|
|
7
|
+
|
|
8
|
+
const probeScript = [
|
|
9
|
+
"process.stdout.write(JSON.stringify({",
|
|
10
|
+
"platform: process.platform,",
|
|
11
|
+
"arch: process.arch,",
|
|
12
|
+
"node_abi: process.versions.modules,",
|
|
13
|
+
"node_version: process.version,",
|
|
14
|
+
"}))",
|
|
15
|
+
].join("")
|
|
16
|
+
|
|
17
|
+
export function discoverNodeCandidates({
|
|
18
|
+
currentExecutable = process.execPath,
|
|
19
|
+
env = process.env,
|
|
20
|
+
homeDir = env.HOME ?? os.homedir(),
|
|
21
|
+
platform = process.platform,
|
|
22
|
+
readDirectory = readdirSync,
|
|
23
|
+
} = {}) {
|
|
24
|
+
const executableName = platform === "win32" ? "node.exe" : "node"
|
|
25
|
+
const candidates = []
|
|
26
|
+
addExecutable(candidates, currentExecutable)
|
|
27
|
+
for (const directory of (env.PATH ?? "").split(path.delimiter).filter(Boolean)) {
|
|
28
|
+
addExecutable(candidates, path.join(directory, executableName))
|
|
29
|
+
}
|
|
30
|
+
const nvmVersionsRoot = path.join(homeDir, ".nvm", "versions", "node")
|
|
31
|
+
if (isDirectory(nvmVersionsRoot)) {
|
|
32
|
+
for (const version of readDirectorySafely(nvmVersionsRoot, readDirectory).sort()) {
|
|
33
|
+
addExecutable(candidates, path.join(nvmVersionsRoot, version, "bin", executableName))
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
for (const candidate of [
|
|
37
|
+
path.join(homeDir, ".volta", "bin", executableName),
|
|
38
|
+
path.join(homeDir, ".asdf", "shims", executableName),
|
|
39
|
+
path.join(homeDir, ".local", "share", "mise", "shims", executableName),
|
|
40
|
+
]) {
|
|
41
|
+
addExecutable(candidates, candidate)
|
|
42
|
+
}
|
|
43
|
+
return candidates
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
export function probeNodeRuntime({
|
|
47
|
+
executable,
|
|
48
|
+
env = process.env,
|
|
49
|
+
spawnSync = nodeSpawnSync,
|
|
50
|
+
} = {}) {
|
|
51
|
+
const result = spawnSync(executable, [
|
|
52
|
+
"--input-type=module",
|
|
53
|
+
"--eval",
|
|
54
|
+
probeScript,
|
|
55
|
+
], { windowsHide: true,
|
|
56
|
+
encoding: "utf8",
|
|
57
|
+
env,
|
|
58
|
+
shell: false,
|
|
59
|
+
timeout: 2000,
|
|
60
|
+
})
|
|
61
|
+
if (result.error !== undefined || result.status !== 0) {
|
|
62
|
+
return {
|
|
63
|
+
ok: false,
|
|
64
|
+
executable,
|
|
65
|
+
reason: result.error?.code ?? "probe_failed",
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
try {
|
|
69
|
+
const runtime = JSON.parse(result.stdout.trim())
|
|
70
|
+
if (
|
|
71
|
+
typeof runtime.platform !== "string" ||
|
|
72
|
+
typeof runtime.arch !== "string" ||
|
|
73
|
+
typeof runtime.node_abi !== "string"
|
|
74
|
+
) {
|
|
75
|
+
throw Object.assign(new Error("Use a Node that answers the version probe: invalid probe response"), { code: "node_selection_use_a_node_that_answers" })
|
|
76
|
+
}
|
|
77
|
+
return {
|
|
78
|
+
ok: true,
|
|
79
|
+
executable,
|
|
80
|
+
...runtime,
|
|
81
|
+
}
|
|
82
|
+
} catch {
|
|
83
|
+
return {
|
|
84
|
+
ok: false,
|
|
85
|
+
executable,
|
|
86
|
+
reason: "invalid_probe_response",
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
export function selectCompatibleNode({
|
|
92
|
+
candidates = [],
|
|
93
|
+
currentTarget,
|
|
94
|
+
env = process.env,
|
|
95
|
+
probe = (executable) => probeNodeRuntime({ executable, env }),
|
|
96
|
+
shippedTargets = [],
|
|
97
|
+
} = {}) {
|
|
98
|
+
if (hasText(env[REEXEC_ATTEMPT_ENV])) {
|
|
99
|
+
return {
|
|
100
|
+
mode: "diagnostic",
|
|
101
|
+
reason: "guarded_reexec_failure",
|
|
102
|
+
paths_checked: [],
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
const pathsChecked = []
|
|
106
|
+
for (const executable of candidates) {
|
|
107
|
+
pathsChecked.push(executable)
|
|
108
|
+
const runtime = probe(executable)
|
|
109
|
+
if (!runtime?.ok) {
|
|
110
|
+
continue
|
|
111
|
+
}
|
|
112
|
+
const target = shippedTargets.find((candidate) => (
|
|
113
|
+
candidate !== null &&
|
|
114
|
+
typeof candidate === "object" &&
|
|
115
|
+
candidate.platform === runtime.platform &&
|
|
116
|
+
candidate.arch === runtime.arch &&
|
|
117
|
+
String(candidate.node_abi) === String(runtime.node_abi)
|
|
118
|
+
))
|
|
119
|
+
if (target !== undefined && target.id !== currentTarget?.id) {
|
|
120
|
+
return {
|
|
121
|
+
mode: "reexec",
|
|
122
|
+
executable,
|
|
123
|
+
target,
|
|
124
|
+
paths_checked: pathsChecked,
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
return {
|
|
129
|
+
mode: "diagnostic",
|
|
130
|
+
reason: "no_compatible_node",
|
|
131
|
+
paths_checked: pathsChecked,
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
export function reexecWithCompatibleNode({
|
|
136
|
+
argv = process.argv.slice(2),
|
|
137
|
+
entrypointPath,
|
|
138
|
+
env = process.env,
|
|
139
|
+
executable,
|
|
140
|
+
parentProcess = process,
|
|
141
|
+
raiseSignal = (signal) => parentProcess.kill(parentProcess.pid, signal),
|
|
142
|
+
spawn = nodeSpawn,
|
|
143
|
+
} = {}) {
|
|
144
|
+
return new Promise((resolve, reject) => {
|
|
145
|
+
let childClosed = false
|
|
146
|
+
let forwardedSignal = null
|
|
147
|
+
const child = spawn(executable, [entrypointPath, ...argv], { windowsHide: true,
|
|
148
|
+
env: {
|
|
149
|
+
...env,
|
|
150
|
+
[REEXEC_ATTEMPT_ENV]: "1",
|
|
151
|
+
},
|
|
152
|
+
shell: false,
|
|
153
|
+
stdio: "inherit",
|
|
154
|
+
})
|
|
155
|
+
const forwardSignal = (signal) => {
|
|
156
|
+
if (childClosed || forwardedSignal !== null) {
|
|
157
|
+
return
|
|
158
|
+
}
|
|
159
|
+
forwardedSignal = signal
|
|
160
|
+
child.kill(signal)
|
|
161
|
+
}
|
|
162
|
+
// cleanup() removes this listener when the child closes, so it only ever runs while the child is alive.
|
|
163
|
+
const terminateChildOnParentExit = () => {
|
|
164
|
+
child.kill("SIGTERM")
|
|
165
|
+
}
|
|
166
|
+
const signalHandlers = new Map(
|
|
167
|
+
["SIGINT", "SIGTERM", "SIGHUP"].map((signal) => [
|
|
168
|
+
signal,
|
|
169
|
+
() => forwardSignal(signal),
|
|
170
|
+
]),
|
|
171
|
+
)
|
|
172
|
+
const cleanup = () => {
|
|
173
|
+
for (const [signal, handler] of signalHandlers) {
|
|
174
|
+
parentProcess.removeListener(signal, handler)
|
|
175
|
+
}
|
|
176
|
+
parentProcess.removeListener("exit", terminateChildOnParentExit)
|
|
177
|
+
}
|
|
178
|
+
for (const [signal, handler] of signalHandlers) {
|
|
179
|
+
parentProcess.on(signal, handler)
|
|
180
|
+
}
|
|
181
|
+
parentProcess.once("exit", terminateChildOnParentExit)
|
|
182
|
+
child.once("error", (error) => {
|
|
183
|
+
childClosed = true
|
|
184
|
+
cleanup()
|
|
185
|
+
reject(error)
|
|
186
|
+
})
|
|
187
|
+
child.once("close", (code, signal) => {
|
|
188
|
+
childClosed = true
|
|
189
|
+
cleanup()
|
|
190
|
+
resolve({ code, signal, forwardedSignal })
|
|
191
|
+
if (forwardedSignal !== null) {
|
|
192
|
+
queueMicrotask(() => raiseSignal(forwardedSignal))
|
|
193
|
+
}
|
|
194
|
+
})
|
|
195
|
+
})
|
|
196
|
+
}
|
|
197
|
+
|
|
198
|
+
function addExecutable(candidates, candidate) {
|
|
199
|
+
if (!hasText(candidate) || candidates.includes(candidate) || !isFile(candidate)) {
|
|
200
|
+
return
|
|
201
|
+
}
|
|
202
|
+
candidates.push(candidate)
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
// An unreadable path (for example one under a directory the user cannot search) is not a candidate.
|
|
206
|
+
function isFile(candidate) {
|
|
207
|
+
try {
|
|
208
|
+
return statSync(candidate, { throwIfNoEntry: false })?.isFile() === true
|
|
209
|
+
} catch {
|
|
210
|
+
return false
|
|
211
|
+
}
|
|
212
|
+
}
|
|
213
|
+
|
|
214
|
+
// An unreadable path (for example one under a directory the user cannot search) is not a candidate.
|
|
215
|
+
function isDirectory(candidate) {
|
|
216
|
+
try {
|
|
217
|
+
return statSync(candidate, { throwIfNoEntry: false })?.isDirectory() === true
|
|
218
|
+
} catch {
|
|
219
|
+
return false
|
|
220
|
+
}
|
|
221
|
+
}
|
|
222
|
+
|
|
223
|
+
function readDirectorySafely(candidate, readDirectory) {
|
|
224
|
+
try {
|
|
225
|
+
return readDirectory(candidate)
|
|
226
|
+
} catch {
|
|
227
|
+
return []
|
|
228
|
+
}
|
|
229
|
+
}
|
|
230
|
+
|
|
231
|
+
function hasText(value) {
|
|
232
|
+
return typeof value === "string" && value.trim().length > 0
|
|
233
|
+
}
|
|
@@ -0,0 +1,225 @@
|
|
|
1
|
+
// Names an Orca terminal after the task its main agent just focused (desk#1478), so the phone's session list says what
|
|
2
|
+
// each session is doing. Claude Code's PostToolUse hook (hooks/lib/orca-session-title.cjs) hands in the finished
|
|
3
|
+
// task_focus or focused task_create call.
|
|
4
|
+
//
|
|
5
|
+
// Whose title it is decides everything. Orca's CLI has one setter, `terminal rename`, and it writes the same custom
|
|
6
|
+
// title a person types, so Desk keeps its own record of the titles it set on each terminal. Desk renames only when the
|
|
7
|
+
// terminal still shows one of those or an Orca default (an agent or shell name, a working-folder title, Claude Code's
|
|
8
|
+
// own status title); any other title is a person's and stays. The caller's terminal is the one Orca names in
|
|
9
|
+
// ORCA_TERMINAL_HANDLE, never "the active terminal". A subagent (its hook input carries `agent_id`), a headless
|
|
10
|
+
// `claude -p` child (CLAUDE_CODE_ENTRYPOINT `sdk-*`) and Desk's own child processes never rename.
|
|
11
|
+
// Where the installed Orca supports `--if-manual-title`, the rename lands only if the tab's manual name is still the
|
|
12
|
+
// one Desk saw (none, or Desk's own), which closes the gap between reading and writing; otherwise that gap (a person
|
|
13
|
+
// renaming in the same instant) is the known limit, and the readback after the rename reports it.
|
|
14
|
+
//
|
|
15
|
+
// Every outcome is one line in Desk's state folder, `orca-session-titles.log`; nothing is shown to the agent and
|
|
16
|
+
// nothing here can fail the tool call.
|
|
17
|
+
|
|
18
|
+
import { execFile } from "node:child_process"
|
|
19
|
+
import { randomBytes } from "node:crypto"
|
|
20
|
+
import { appendFileSync, mkdirSync, readFileSync, readdirSync, renameSync, rmSync, statSync, writeFileSync } from "node:fs"
|
|
21
|
+
import * as path from "node:path"
|
|
22
|
+
import { startupChangesNothing } from "../factory/headless-flag.js"
|
|
23
|
+
import { isNoninteractive } from "../factory/session-kind.js"
|
|
24
|
+
import { makeSessionLabelProposal } from "./session-label.js"
|
|
25
|
+
import { resolveDeskStateDir } from "./last-start.js"
|
|
26
|
+
import { assertNotRealStateUnderTest } from "./test-state-guard.js"
|
|
27
|
+
|
|
28
|
+
/** The longest title Desk sets, in user-perceived characters: about what Orca's phone list shows before it cuts a name. */
|
|
29
|
+
export const ORCA_TITLE_MAX = 32
|
|
30
|
+
|
|
31
|
+
const STATE_DIR = "orca-session-titles"
|
|
32
|
+
const LOG_FILE = "orca-session-titles.log"
|
|
33
|
+
const LOG_MAX_BYTES = 256 * 1024
|
|
34
|
+
const KEEP_MS = 30 * 24 * 60 * 60 * 1000
|
|
35
|
+
const KEEP_TITLES = 3
|
|
36
|
+
const ORCA_TIMEOUT_MS = 2500
|
|
37
|
+
const HANDLE = /^term_[\w-]+$/u
|
|
38
|
+
// The session-label rules check text alone; the task they also ask for plays no part in the answer.
|
|
39
|
+
const SAFETY_TASK = { track: "orca", slug: "title" }
|
|
40
|
+
// What Orca shows before anyone names a tab: the agent or shell running in it, Orca's own "Terminal N", the shell's
|
|
41
|
+
// working-folder title, or the status title Claude Code writes (a braille spinner frame or ✳, then its summary).
|
|
42
|
+
const DEFAULT_TITLES = new Set(["", "terminal", "claude", "claude code", "codex", "copilot", "gemini", "opencode", "ouro", "zsh", "-zsh", "bash", "-bash", "fish", "sh", "desk:worker"])
|
|
43
|
+
const AGENT_STATUS_TITLE = /^[⠀-⣿✳]\s/u
|
|
44
|
+
const FOLDER_TITLE = /^(?:[^\s@]+@[^\s:]+:)?[~/]/u
|
|
45
|
+
|
|
46
|
+
/** True for a title Orca, the shell or the agent CLI made up, which Desk may replace. */
|
|
47
|
+
export function isOrcaDefaultTitle(title, agentIdentity) {
|
|
48
|
+
if (typeof title !== "string") return false
|
|
49
|
+
const trimmed = title.trim()
|
|
50
|
+
const text = trimmed.toLowerCase()
|
|
51
|
+
return DEFAULT_TITLES.has(text) || /^terminal \d+$/u.test(text) || AGENT_STATUS_TITLE.test(trimmed) || FOLDER_TITLE.test(trimmed) ||
|
|
52
|
+
(typeof agentIdentity === "string" && text === agentIdentity.trim().toLowerCase())
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
const graphemes = (text) => [...new Intl.Segmenter(undefined, { granularity: "grapheme" }).segment(text)].map((part) => part.segment)
|
|
56
|
+
|
|
57
|
+
/** `text` cut to ORCA_TITLE_MAX characters, at a word when one ends in the second half, ending in an ellipsis. */
|
|
58
|
+
export function shortTitle(text) {
|
|
59
|
+
const parts = graphemes(text)
|
|
60
|
+
if (parts.length <= ORCA_TITLE_MAX) return text
|
|
61
|
+
const kept = parts.slice(0, ORCA_TITLE_MAX - 1)
|
|
62
|
+
const space = kept.lastIndexOf(" ")
|
|
63
|
+
const cut = (space >= ORCA_TITLE_MAX / 2 ? kept.slice(0, space) : kept).join("")
|
|
64
|
+
return `${cut.replace(/[\s:;,.\-–—]+$/u, "")}…`
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
/**
|
|
68
|
+
* The title for a finished focusing call: the agent's own `display_label` (the result's session_label proposal) when
|
|
69
|
+
* it gave one, else the card's title. Either passes the session-label safety rules whole or not at all, so no path,
|
|
70
|
+
* URL, address or credential reaches a tab. Returns `{ title }` or `{ code }`.
|
|
71
|
+
*/
|
|
72
|
+
export function orcaTitleFor({ toolName, toolInput, result }) {
|
|
73
|
+
const authored = result?.session_label?.proposal?.text
|
|
74
|
+
const candidate = typeof authored === "string" ? authored : toolName.endsWith("__task_create") ? toolInput?.title : result?.title
|
|
75
|
+
if (typeof candidate !== "string" || candidate.trim() === "") return { code: "no_label" }
|
|
76
|
+
const checked = makeSessionLabelProposal({ task: SAFETY_TASK, displayLabel: candidate.trim().replace(/ {2,}/gu, " ") })
|
|
77
|
+
if (checked.proposal === undefined) return { code: "unsafe_label" }
|
|
78
|
+
return { title: shortTitle(checked.proposal.text) }
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
function parseToolResult(response) {
|
|
82
|
+
const content = Array.isArray(response) ? response : response?.content
|
|
83
|
+
const text = Array.isArray(content) ? content.find((block) => block?.type === "text")?.text : undefined
|
|
84
|
+
try {
|
|
85
|
+
const value = JSON.parse(text)
|
|
86
|
+
return value !== null && typeof value === "object" ? value : null
|
|
87
|
+
} catch {
|
|
88
|
+
return null
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
function focusedNow(toolName, toolInput, result) {
|
|
93
|
+
if (toolName.endsWith("__task_focus")) return result.status === "focused"
|
|
94
|
+
return toolInput?.focus === true && result.focused === true
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
const isChild = (hookInput, env) => (typeof hookInput.agent_id === "string" && hookInput.agent_id !== "") || startupChangesNothing(env) || isNoninteractive(env)
|
|
98
|
+
|
|
99
|
+
/** Runs the Orca CLI Orca itself names (ORCA_CLI_COMMAND), else `orca` on PATH; answers `{ status, stdout }`, never throws. */
|
|
100
|
+
export function defaultRunOrca(env) {
|
|
101
|
+
const command = env.ORCA_CLI_COMMAND || "orca"
|
|
102
|
+
return (args) => new Promise((resolve) => {
|
|
103
|
+
execFile(command, args, { timeout: ORCA_TIMEOUT_MS, windowsHide: true, encoding: "utf8" }, (error, stdout) => {
|
|
104
|
+
resolve({ status: error ? (typeof error.code === "number" ? error.code : 1) : 0, stdout })
|
|
105
|
+
})
|
|
106
|
+
})
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
async function readTerminal(runOrca, handle) {
|
|
110
|
+
try {
|
|
111
|
+
const { status, stdout } = await runOrca(["terminal", "show", "--terminal", handle, "--json"])
|
|
112
|
+
const terminal = status === 0 ? JSON.parse(stdout)?.result?.terminal : null
|
|
113
|
+
return typeof terminal?.title === "string" ? terminal : null
|
|
114
|
+
} catch {
|
|
115
|
+
return null
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
async function supportsConditionalRename(runOrca) {
|
|
120
|
+
try {
|
|
121
|
+
const { stdout } = await runOrca(["terminal", "rename", "--help"])
|
|
122
|
+
return stdout.includes("--if-manual-title")
|
|
123
|
+
} catch {
|
|
124
|
+
return false
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
// One small file per terminal, replaced whole, so sessions naming different terminals never write the same file.
|
|
129
|
+
const stateFile = (stateDir, handle) => path.join(stateDir, STATE_DIR, `${handle}.json`)
|
|
130
|
+
|
|
131
|
+
function readState(stateDir, handle) {
|
|
132
|
+
try {
|
|
133
|
+
const value = JSON.parse(readFileSync(stateFile(stateDir, handle), "utf8"))
|
|
134
|
+
return {
|
|
135
|
+
titles: Array.isArray(value?.titles) ? value.titles.filter((title) => typeof title === "string") : [],
|
|
136
|
+
requested: typeof value?.requested === "string" ? value.requested : null,
|
|
137
|
+
}
|
|
138
|
+
} catch {
|
|
139
|
+
return { titles: [], requested: null }
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
function writeState(stateDir, handle, state, at) {
|
|
144
|
+
try {
|
|
145
|
+
assertNotRealStateUnderTest(stateDir)
|
|
146
|
+
const dir = path.join(stateDir, STATE_DIR)
|
|
147
|
+
mkdirSync(dir, { recursive: true })
|
|
148
|
+
for (const name of readdirSync(dir)) {
|
|
149
|
+
const file = path.join(dir, name)
|
|
150
|
+
if (at - statSync(file).mtimeMs > KEEP_MS) rmSync(file, { force: true })
|
|
151
|
+
}
|
|
152
|
+
const target = stateFile(stateDir, handle)
|
|
153
|
+
const temporary = `${target}.${randomBytes(6).toString("hex")}.tmp`
|
|
154
|
+
writeFileSync(temporary, `${JSON.stringify({ ...state, at })}\n`)
|
|
155
|
+
renameSync(temporary, target)
|
|
156
|
+
return true
|
|
157
|
+
} catch {
|
|
158
|
+
return false
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
function logOutcome(stateDir, at, handle, code) {
|
|
163
|
+
try {
|
|
164
|
+
assertNotRealStateUnderTest(stateDir)
|
|
165
|
+
mkdirSync(stateDir, { recursive: true })
|
|
166
|
+
const file = path.join(stateDir, LOG_FILE)
|
|
167
|
+
try {
|
|
168
|
+
if (statSync(file).size > LOG_MAX_BYTES) renameSync(file, `${file}.old`)
|
|
169
|
+
} catch {}
|
|
170
|
+
appendFileSync(file, `${JSON.stringify({ at: new Date(at).toISOString(), terminal: handle ?? null, code })}\n`)
|
|
171
|
+
} catch {}
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
/**
|
|
175
|
+
* Names the caller's Orca terminal after the task a finished hook call focused. Returns `{ code, title? }`, where
|
|
176
|
+
* `code` is `applied`, `unchanged`, `manual_title_kept`, `superseded`, `conditional_rename_refused`,
|
|
177
|
+
* `readback_mismatch`, `rename_failed`, `orca_unavailable`, `not_in_orca`, `unsupported_platform`, `child_agent`,
|
|
178
|
+
* `not_naming_tool`, `not_focused`, `no_result`, `no_label` or `unsafe_label`. Never throws.
|
|
179
|
+
*/
|
|
180
|
+
export async function nameOrcaSession({ hookInput, env = process.env, runOrca = defaultRunOrca(env), stateDir = resolveDeskStateDir({ env }), now = Date.now, platform = process.platform }) {
|
|
181
|
+
const handle = typeof env.ORCA_TERMINAL_HANDLE === "string" && HANDLE.test(env.ORCA_TERMINAL_HANDLE) ? env.ORCA_TERMINAL_HANDLE : null
|
|
182
|
+
const finish = (outcome) => {
|
|
183
|
+
logOutcome(stateDir, now(), handle, outcome.code)
|
|
184
|
+
return outcome
|
|
185
|
+
}
|
|
186
|
+
const toolName = typeof hookInput?.tool_name === "string" ? hookInput.tool_name : ""
|
|
187
|
+
if (!/__task_(?:focus|create)$/u.test(toolName)) return finish({ code: "not_naming_tool" })
|
|
188
|
+
if (handle === null) return finish({ code: "not_in_orca" })
|
|
189
|
+
// Orca's Windows CLI is a .cmd shim, which execFile cannot start without a shell; quoting a label for cmd.exe is not worth the risk.
|
|
190
|
+
if (platform === "win32") return finish({ code: "unsupported_platform" })
|
|
191
|
+
if (isChild(hookInput, env)) return finish({ code: "child_agent" })
|
|
192
|
+
const result = parseToolResult(hookInput.tool_response)
|
|
193
|
+
if (result === null) return finish({ code: "no_result" })
|
|
194
|
+
if (!focusedNow(toolName, hookInput.tool_input, result)) return finish({ code: "not_focused" })
|
|
195
|
+
const label = orcaTitleFor({ toolName, toolInput: hookInput.tool_input, result })
|
|
196
|
+
if (label.title === undefined) return finish(label)
|
|
197
|
+
|
|
198
|
+
// Hooks run in the background and can overlap; the newest call claims the terminal, and an older one stands down.
|
|
199
|
+
// A state folder Desk cannot write holds no claim, so the call goes ahead on what it read.
|
|
200
|
+
const request = `${now()}-${randomBytes(6).toString("hex")}`
|
|
201
|
+
const claimed = writeState(stateDir, handle, { ...readState(stateDir, handle), requested: request }, now())
|
|
202
|
+
const [terminal, conditional] = await Promise.all([readTerminal(runOrca, handle), supportsConditionalRename(runOrca)])
|
|
203
|
+
if (terminal === null) return finish({ code: "orca_unavailable" })
|
|
204
|
+
if (terminal.title === label.title) return finish({ code: "unchanged" })
|
|
205
|
+
const state = readState(stateDir, handle)
|
|
206
|
+
const desks = state.titles.includes(terminal.title)
|
|
207
|
+
const isDefault = !desks && isOrcaDefaultTitle(terminal.title, terminal.agentIdentity)
|
|
208
|
+
if (!desks && !isDefault) return finish({ code: "manual_title_kept" })
|
|
209
|
+
if (claimed && state.requested !== request) return finish({ code: "superseded" })
|
|
210
|
+
|
|
211
|
+
// Recorded before the write, keeping the titles before it: a rename that times out or reads back late still leaves
|
|
212
|
+
// the tab's title recognisably Desk's, so naming carries on next time instead of mistaking it for a person's.
|
|
213
|
+
writeState(stateDir, handle, { titles: [label.title, ...state.titles.filter((title) => title !== label.title)].slice(0, KEEP_TITLES), requested: request }, now())
|
|
214
|
+
const args = ["terminal", "rename", "--terminal", handle, "--title", label.title, "--json", ...(conditional ? ["--if-manual-title", isDefault ? "" : terminal.title] : [])]
|
|
215
|
+
let renamed
|
|
216
|
+
try {
|
|
217
|
+
renamed = await runOrca(args)
|
|
218
|
+
} catch {
|
|
219
|
+
renamed = { status: 1, stdout: "" }
|
|
220
|
+
}
|
|
221
|
+
if (renamed.status !== 0) return finish({ code: String(renamed.stdout).includes("terminal_title_changed") ? "conditional_rename_refused" : "rename_failed" })
|
|
222
|
+
const after = await readTerminal(runOrca, handle)
|
|
223
|
+
if (after?.title !== label.title) return finish({ code: "readback_mismatch" })
|
|
224
|
+
return finish({ code: "applied", title: label.title })
|
|
225
|
+
}
|
|
@@ -0,0 +1,183 @@
|
|
|
1
|
+
// Which other sessions are working on this machine, in the repo this session starts in. Several Copilot app sessions often run at
|
|
2
|
+
// once, in sibling worktrees of one repo and sometimes in its shared main checkout, and an agent that does not know that stashes
|
|
3
|
+
// a neighbour's work, resets a checkout or removes a worktree that is not its own. Boot prints what it can see in a few lines, and
|
|
4
|
+
// the few rules that follow from it, only when there is someone else to be careful about.
|
|
5
|
+
//
|
|
6
|
+
// Everything comes from the machine: `git worktree list`, the time of each worktree's last git activity, and (where `ps` and `lsof`
|
|
7
|
+
// exist) the running `agency copilot` and `copilot` processes whose working directory is in the repo. A step that is missing or
|
|
8
|
+
// slow is skipped, so the lines say less and never fail or hold boot past `BUDGET_MS`.
|
|
9
|
+
|
|
10
|
+
import { execFile } from "node:child_process"
|
|
11
|
+
import { readFileSync, statSync } from "node:fs"
|
|
12
|
+
import * as path from "node:path"
|
|
13
|
+
import { promisify } from "node:util"
|
|
14
|
+
|
|
15
|
+
const run = promisify(execFile)
|
|
16
|
+
|
|
17
|
+
const BUDGET_MS = 2500
|
|
18
|
+
const SHOWN = 6
|
|
19
|
+
const QUIET_MS = 24 * 60 * 60 * 1000
|
|
20
|
+
const MAX_CANDIDATES = 40
|
|
21
|
+
// An `agency copilot ...` process is one session; a bare `copilot` or `copilot-runtime` is one too, unless it is a helper of one (an extension or a child of an `agency copilot`).
|
|
22
|
+
const SESSION_COMMAND = /(?:^|[\\/])(?:agency(?:\.exe)?\s+copilot|copilot(?:-runtime)?(?:\.exe)?)(?:\s|$)/u
|
|
23
|
+
|
|
24
|
+
const tilde = (dir, home) => (dir.startsWith(home + path.sep) ? `~${dir.slice(home.length)}` : dir)
|
|
25
|
+
|
|
26
|
+
/** The worktrees `git worktree list --porcelain` prints, main checkout first: `{ dir, branch, bare }`. */
|
|
27
|
+
export function parseWorktrees(porcelain) {
|
|
28
|
+
const trees = []
|
|
29
|
+
for (const block of String(porcelain).split(/\r?\n\r?\n/u)) {
|
|
30
|
+
const lines = block.split(/\r?\n/u)
|
|
31
|
+
const dir = lines.find((line) => line.startsWith("worktree "))?.slice("worktree ".length)
|
|
32
|
+
if (dir === undefined || dir === "") continue
|
|
33
|
+
if (lines.some((line) => line === "prunable" || line.startsWith("prunable "))) continue
|
|
34
|
+
const branch = lines.find((line) => line.startsWith("branch "))?.slice("branch ".length).replace(/^refs\/heads\//u, "")
|
|
35
|
+
trees.push({ dir: path.resolve(dir), branch: branch ?? (lines.includes("detached") ? "detached HEAD" : "no branch"), bare: lines.includes("bare") })
|
|
36
|
+
}
|
|
37
|
+
return trees
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
/** `ps -axo pid=,ppid=,etime=,command=` rows as `{ pid, ppid, up, command }`. */
|
|
41
|
+
export function parseProcesses(text) {
|
|
42
|
+
const rows = []
|
|
43
|
+
for (const line of String(text).split(/\r?\n/u)) {
|
|
44
|
+
const match = /^\s*(\d+)\s+(\d+)\s+(?:(\d+)-)?(?:(\d+):)?(\d+):(\d+)\s+(.*)$/u.exec(line)
|
|
45
|
+
if (match === null) continue
|
|
46
|
+
const [, pid, ppid, days = "0", hours = "0", minutes, seconds, command] = match
|
|
47
|
+
rows.push({ pid: Number(pid), ppid: Number(ppid), up: (((Number(days) * 24 + Number(hours)) * 60 + Number(minutes)) * 60 + Number(seconds)) * 1000, command })
|
|
48
|
+
}
|
|
49
|
+
return rows
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
/** The sessions among `rows`: one per `agency copilot` or `copilot` process that is not a helper of another, and none of the `hostPid`'s own ancestors (this session). */
|
|
53
|
+
export function sessionProcesses(rows, { hostPid = null } = {}) {
|
|
54
|
+
const byPid = new Map(rows.map((row) => [row.pid, row]))
|
|
55
|
+
const own = new Set()
|
|
56
|
+
for (let pid = hostPid; pid !== null && byPid.has(pid) && !own.has(pid); pid = byPid.get(pid).ppid) own.add(pid)
|
|
57
|
+
const sessions = rows.filter((row) => SESSION_COMMAND.test(row.command) && !/\bextension_bootstrap\b/u.test(row.command) && !own.has(row.pid))
|
|
58
|
+
const kept = new Set(sessions.map((row) => row.pid))
|
|
59
|
+
return sessions.filter((row) => !kept.has(row.ppid)).slice(0, MAX_CANDIDATES)
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
function gitDirOf(dir) {
|
|
63
|
+
try {
|
|
64
|
+
const dotGit = path.join(dir, ".git")
|
|
65
|
+
if (statSync(dotGit).isDirectory()) return dotGit
|
|
66
|
+
// A `.git` file that names no folder throws here, and reads as no git folder.
|
|
67
|
+
return path.resolve(dir, /^gitdir:\s*(.+)$/mu.exec(readFileSync(dotGit, "utf8"))[1].trim())
|
|
68
|
+
} catch {
|
|
69
|
+
return null
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
/** When something last happened in the worktree's git (a commit, checkout or staged change), in ms since the epoch, or null. */
|
|
74
|
+
function lastGitActivity(dir) {
|
|
75
|
+
const gitDir = gitDirOf(dir)
|
|
76
|
+
if (gitDir === null) return null
|
|
77
|
+
let latest = null
|
|
78
|
+
for (const name of ["index", "HEAD", path.join("logs", "HEAD")]) {
|
|
79
|
+
try {
|
|
80
|
+
const at = statSync(path.join(gitDir, name)).mtimeMs
|
|
81
|
+
if (latest === null || at > latest) latest = at
|
|
82
|
+
} catch {
|
|
83
|
+
// Not every file exists in every state.
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
return latest
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
// "5 min", "3 h" or "9 days".
|
|
90
|
+
function span(ms) {
|
|
91
|
+
const minutes = Math.max(1, Math.round(ms / 60000))
|
|
92
|
+
if (minutes < 90) return `${minutes} min`
|
|
93
|
+
const hours = Math.round(minutes / 60)
|
|
94
|
+
return hours < 48 ? `${hours} h` : `${Math.round(hours / 24)} days`
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
const plural = (count, word) => `${count} ${word}${count === 1 ? "" : "s"}`
|
|
98
|
+
|
|
99
|
+
/** The lines for the agent: what is where, then the rules. `trees` carry `dir`, `branch`, `activity` (ms or null) and `sessions` (how many other sessions run there). */
|
|
100
|
+
export function describe({ trees, current, home, now }) {
|
|
101
|
+
const rules = "Rules while others work here: in a shared checkout (the main one, or any folder another session uses) never stash, reset, clean, switch branches or delete files you did not create, even when asked to tidy it; never touch, move or remove another session's worktree. Do that work in your own worktree instead (`git worktree add <dir> -b <branch> origin/main`), and remove only what you created."
|
|
102
|
+
const line = (tree, index) => {
|
|
103
|
+
const mine = tree.dir === current
|
|
104
|
+
const where = `- ${tilde(tree.dir, home)} (${index === 0 ? "the shared main checkout, " : ""}${tree.branch})`
|
|
105
|
+
const facts = []
|
|
106
|
+
if (mine) facts.push("you are here")
|
|
107
|
+
if (tree.sessions > 0) facts.push(`${plural(tree.sessions, "session")} ${mine ? "besides yours" : `running (up ${span(tree.upMs)})`}`)
|
|
108
|
+
if (!mine && tree.activity !== null) facts.push(`last git activity ${span(now - tree.activity)} ago`)
|
|
109
|
+
// Only a worktree with something to say is listed (`lively`), so there is always a fact.
|
|
110
|
+
return `${where}: ${facts.join("; ")}`
|
|
111
|
+
}
|
|
112
|
+
const lively = (tree) => tree.dir === current || tree.sessions > 0 || (tree.activity !== null && now - tree.activity < QUIET_MS)
|
|
113
|
+
// This session's own worktree first, then the ones with a running session, then the most recently touched.
|
|
114
|
+
const rank = (tree) => (tree.dir === current ? 0 : tree.sessions > 0 ? 1 : 2)
|
|
115
|
+
const shownTrees = trees.filter(lively).sort((a, b) => rank(a) - rank(b) || (b.activity ?? 0) - (a.activity ?? 0))
|
|
116
|
+
const quiet = trees.length - shownTrees.length
|
|
117
|
+
const listed = shownTrees.slice(0, SHOWN)
|
|
118
|
+
const more = shownTrees.length - listed.length + quiet
|
|
119
|
+
const sessions = trees.reduce((total, tree) => total + tree.sessions, 0)
|
|
120
|
+
const head = `Other work on this machine in this repo: ${plural(trees.length, "worktree")}, ${plural(sessions, "other running session")}.`
|
|
121
|
+
return [head, ...listed.map((tree) => line(tree, trees.indexOf(tree))), ...(more > 0 ? [`- and ${plural(more, "more worktree")}, quiet for a day or more or past this list; \`git worktree list\` shows them`] : []), rules]
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
async function sessionsByWorktree({ trees, current, env, platform, inspect }) {
|
|
125
|
+
const counts = new Map(trees.map((tree) => [tree.dir, { sessions: 0, upMs: null }]))
|
|
126
|
+
if (platform === "win32") return counts
|
|
127
|
+
const listed = await inspect("ps", ["-axo", "pid=,ppid=,etime=,command="])
|
|
128
|
+
const hostPid = Number.parseInt(env.DESK_SESSION_HOST_PID ?? "", 10)
|
|
129
|
+
const ownKnown = Number.isInteger(hostPid)
|
|
130
|
+
const candidates = sessionProcesses(parseProcesses(listed), { hostPid: ownKnown ? hostPid : null })
|
|
131
|
+
if (candidates.length === 0) return counts
|
|
132
|
+
const cwds = await inspect("lsof", ["-a", "-p", candidates.map((row) => row.pid).join(","), "-d", "cwd", "-Fpn"])
|
|
133
|
+
const cwdOf = new Map()
|
|
134
|
+
let pid = null
|
|
135
|
+
for (const line of cwds.split(/\r?\n/u)) {
|
|
136
|
+
if (line.startsWith("p")) pid = Number(line.slice(1))
|
|
137
|
+
else if (line.startsWith("n") && pid !== null) cwdOf.set(pid, path.resolve(line.slice(1)))
|
|
138
|
+
}
|
|
139
|
+
// A nested worktree belongs to the deepest tree that holds the folder.
|
|
140
|
+
const byDepth = [...trees].sort((a, b) => b.dir.length - a.dir.length)
|
|
141
|
+
for (const row of candidates) {
|
|
142
|
+
const cwd = cwdOf.get(row.pid)
|
|
143
|
+
const tree = cwd === undefined ? undefined : byDepth.find((candidate) => cwd === candidate.dir || cwd.startsWith(candidate.dir + path.sep))
|
|
144
|
+
if (tree === undefined) continue
|
|
145
|
+
const entry = counts.get(tree.dir)
|
|
146
|
+
entry.sessions += 1
|
|
147
|
+
entry.upMs = entry.upMs === null ? row.up : Math.max(entry.upMs, row.up)
|
|
148
|
+
}
|
|
149
|
+
// Without the host's pid this session is one of the processes in its own folder; it is not "other".
|
|
150
|
+
const mine = counts.get(current)
|
|
151
|
+
if (!ownKnown && mine !== undefined && mine.sessions > 0) mine.sessions -= 1
|
|
152
|
+
return counts
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
/**
|
|
156
|
+
* `{ lines, worktrees, sessions }` for boot, or null when there is nobody else (one worktree and no other running session), no
|
|
157
|
+
* repo, or nothing could be read in `budgetMs`. Never rejects.
|
|
158
|
+
*/
|
|
159
|
+
export async function otherSessions({ cwd, env, now, platform, home, budgetMs = BUDGET_MS, inspect }) {
|
|
160
|
+
let timer
|
|
161
|
+
const hard = new Promise((resolve) => { timer = setTimeout(() => resolve(null), budgetMs) })
|
|
162
|
+
const work = (async () => {
|
|
163
|
+
const call = inspect ?? (async (file, args, options = {}) => (await run(file, args, { cwd, timeout: budgetMs, windowsHide: true, maxBuffer: 4 * 1024 * 1024, ...options })).stdout)
|
|
164
|
+
const trees = parseWorktrees(await call("git", ["worktree", "list", "--porcelain"])).filter((tree) => !tree.bare)
|
|
165
|
+
const top = path.resolve((await call("git", ["rev-parse", "--show-toplevel"])).trim())
|
|
166
|
+
let counts = new Map(trees.map((tree) => [tree.dir, { sessions: 0, upMs: null }]))
|
|
167
|
+
try {
|
|
168
|
+
counts = await sessionsByWorktree({ trees, current: top, env, platform, inspect: (file, args) => call(file, args) })
|
|
169
|
+
} catch {
|
|
170
|
+
// No ps or lsof here: worktrees alone still say who else may be about.
|
|
171
|
+
}
|
|
172
|
+
const full = trees.map((tree) => ({ ...tree, activity: lastGitActivity(tree.dir), ...counts.get(tree.dir) }))
|
|
173
|
+
const others = full.filter((tree) => tree.dir !== top).length
|
|
174
|
+
const sessions = full.reduce((total, tree) => total + tree.sessions, 0)
|
|
175
|
+
if (others === 0 && sessions === 0) return null
|
|
176
|
+
return { lines: describe({ trees: full, current: top, home, now: now() }), worktrees: full.length, sessions }
|
|
177
|
+
})().catch(() => null)
|
|
178
|
+
try {
|
|
179
|
+
return await Promise.race([work, hard])
|
|
180
|
+
} finally {
|
|
181
|
+
clearTimeout(timer)
|
|
182
|
+
}
|
|
183
|
+
}
|