@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,612 @@
|
|
|
1
|
+
// Binding: decides which Desk tasks (jobs) one session worked on, and which of
|
|
2
|
+
// its workers belong to each, from the in-memory events a deriver returns
|
|
3
|
+
// (`derive-claude.js`, `derive-codex.js`, `derive-copilot.js`).
|
|
4
|
+
//
|
|
5
|
+
// A job is one durable outcome, recorded as one task card. Everything a
|
|
6
|
+
// session tree does while working an outcome belongs to that outcome's job:
|
|
7
|
+
// the controller (worker 0), every subagent, and the time spent briefing,
|
|
8
|
+
// waiting on and reading back from them. Mentioning, filing, tidying or
|
|
9
|
+
// updating another card is not working on it, and binds nothing.
|
|
10
|
+
//
|
|
11
|
+
// The controller's timeline (`focus.js` has the rules). Worker 0's
|
|
12
|
+
// `task_focus` calls, and its `task_create` calls with `focus: true`
|
|
13
|
+
// (`events.focusCalls` holds both), cut the session into declared stretches. A stretch with no declaration is inferred from the session
|
|
14
|
+
// tree's evidence events:
|
|
15
|
+
// - `write`: a file write under a task's folder,
|
|
16
|
+
// `<deskRoot>/[<personPrefix>/]<track>/<task>/…` or
|
|
17
|
+
// `<track>/_archive/<task>/…` (`events.fileWrites`: file tools, shell
|
|
18
|
+
// redirects and `desk_save` paths; a relative path is a `desk_save` path
|
|
19
|
+
// and resolves against the desk root).
|
|
20
|
+
// - `tool`: a successful Desk task tool call naming the task
|
|
21
|
+
// (`events.deskToolCalls`), other than `task_create` and a status-only
|
|
22
|
+
// `task_update`. The person desk is the caller's `personPrefix`: Desk's
|
|
23
|
+
// task tools take it from the server's `--person` flag, never from the call.
|
|
24
|
+
// - `spawn`: a subagent's brief carrying a `Desk-Task:` line for the task
|
|
25
|
+
// (`events.spawns`), at the spawn's time, as its parent's event.
|
|
26
|
+
// - `commit`: one of the session's own `git … commit` shell calls whose
|
|
27
|
+
// `git add` or `git commit` names a path at or under the task's folder
|
|
28
|
+
// (`events.shellGitCommits[].paths`). A call naming no path (`git add -A`,
|
|
29
|
+
// `git add .`, `git commit -am`) counts for nothing, and so does one naming
|
|
30
|
+
// more than MASS_COMMIT_TASKS tasks, a sweep. Desk history is never read by
|
|
31
|
+
// time: another session's commit that lands while this one's `git commit`
|
|
32
|
+
// runs binds nothing. A commit from the session's native refs
|
|
33
|
+
// (`events.nativeCommitShas`, Copilot's `session_refs`) that exists in the
|
|
34
|
+
// desk is the session's own too, and counts for the tasks it changed
|
|
35
|
+
// (`taskCommitRule`). It has no time, so it counts toward candidacy only
|
|
36
|
+
// and never earns a task time over another.
|
|
37
|
+
// - `repo`: work in a code repository. A file write outside the desk, one of
|
|
38
|
+
// the session's `git … commit` calls that ran outside the desk or named a
|
|
39
|
+
// path there (one event for each repository the call touches, at its
|
|
40
|
+
// start), and a pull request the session created (`events.prRefs` with
|
|
41
|
+
// `created: true`). `repoLookup` names the repository a path is in; a path
|
|
42
|
+
// it cannot name is no evidence, never a guess, and its directory is
|
|
43
|
+
// counted in `repoUnresolved` only when the evidence was not available. A `repo` event counts only for the one card
|
|
44
|
+
// that lists the repository and has another event (`focus.js`).
|
|
45
|
+
// Events of a subagent bound by a `Desk-Task:` line, and of the subagents
|
|
46
|
+
// below it, are left out: that subtree has its own job. Reads never bind (no
|
|
47
|
+
// deriver emits them). Paths outside the desk, and paths under `_meta/`,
|
|
48
|
+
// `_friction/`, `_planning/`, the top-level `_archive/`, a dot folder, or
|
|
49
|
+
// directly in a track (such as `track.md`) name no task. A task whose card is
|
|
50
|
+
// found neither live nor archived is not a task: its events are dropped, a
|
|
51
|
+
// focus on it holds its stretch for no job, and a `Desk-Task:` line for it is
|
|
52
|
+
// ignored.
|
|
53
|
+
//
|
|
54
|
+
// Workers. Worker 0 is in every job that holds part of its timeline. Each
|
|
55
|
+
// subagent is in at most one job, chosen in this order: the task of its
|
|
56
|
+
// `Desk-Task:` line; else, for a nested subagent, its parent's job; else the
|
|
57
|
+
// job that held the controller's timeline when it was spawned
|
|
58
|
+
// (`events.spawns[].at`). A subagent with no spawn time, spawned while the
|
|
59
|
+
// controller had no job, or whose parent cannot be traced, is in no job. A
|
|
60
|
+
// subagent's own touches never create a job, and a subagent that keeps
|
|
61
|
+
// running, or is resumed, after the controller moves on keeps its job.
|
|
62
|
+
//
|
|
63
|
+
// Output. `{ jobs, boundBy, disagrees, ownActivity, repoUnresolved, segmentsCappedMs }`.
|
|
64
|
+
// - `jobs` is `LocalJob[]`, sorted by job ID: `{ job, basis, agents,
|
|
65
|
+
// task_created_at, transitions, observed, segments? }`, the hashed job ID
|
|
66
|
+
// only, never a track, slug, title or path. `agents` lists the job's
|
|
67
|
+
// workers. `segments` are the spans of the session, in milliseconds from
|
|
68
|
+
// its start, that worker 0's timeline gives the job. They are present
|
|
69
|
+
// exactly when `agents` lists worker 0, even for a session with one job, so
|
|
70
|
+
// a cleared or unbound stretch is never counted; no two jobs' segments
|
|
71
|
+
// overlap; and a job keeps at most `LIMITS.jobSegments` (`capSegments`).
|
|
72
|
+
// `basis` follows `ENUMS.jobBasis` order: `desk_tool` for a declared task
|
|
73
|
+
// or `tool` evidence, `file_write`, `desk_commit` and `spawn_brief` for the
|
|
74
|
+
// other evidence of a job worker 0 is in, `spawn_brief` for a subagent's
|
|
75
|
+
// own line and `inherited` for a subagent placed by its parent or its spawn
|
|
76
|
+
// time. `transitions` are the valid statuses of the session's successful
|
|
77
|
+
// task tool calls on that job, `at` being the call time, in time order; a
|
|
78
|
+
// status change on a card that is not one of the session's jobs is not
|
|
79
|
+
// recorded. `task_created_at` is the card's `created`, or `null` when
|
|
80
|
+
// unreadable. `observed` is the card's status now — `{ status, at }`, `at`
|
|
81
|
+
// being, for a terminal status (`done`, `cancelled`), the later of the
|
|
82
|
+
// session's last transition into that status and the card's `updated`
|
|
83
|
+
// from the same read, an `updated` not after the card's `created` never
|
|
84
|
+
// counting (`observedTime`), else `null`; and `null` for any other status
|
|
85
|
+
// — or `null` when the card has no valid status.
|
|
86
|
+
// Jobs and transitions are capped at the facts limits.
|
|
87
|
+
// - `boundBy` maps a job ID to `focus` or `inferred`, for the jobs worker 0
|
|
88
|
+
// is in. `disagrees` lists the declared jobs with a stretch that holds
|
|
89
|
+
// none of their own events and ten or more on another task.
|
|
90
|
+
// - `ownActivity` is up to 500 `[start_ms, end_ms]` spans, in milliseconds
|
|
91
|
+
// from the session's start (they may run before it or past its end): the
|
|
92
|
+
// session's `git commit` calls that ran in the desk and each successful
|
|
93
|
+
// task tool call widened by a minute each way, merged where they touch.
|
|
94
|
+
// `factory reconcile` matches desk commits to the session with it.
|
|
95
|
+
// - `repoUnresolved` is how many distinct directories outside the desk the
|
|
96
|
+
// session wrote or committed in whose repository evidence was not
|
|
97
|
+
// available: the directory is gone (ENOENT, ENOTDIR), any other stat
|
|
98
|
+
// error, or Git failed or timed out. A directory that exists and is in no
|
|
99
|
+
// repository, or in one with no origin, is a true none and is not
|
|
100
|
+
// counted. A number, never a path.
|
|
101
|
+
// - `segmentsCappedMs` is the time the segment cap took from the task that
|
|
102
|
+
// held it, dropped or given to another task (`capSegments` reports it):
|
|
103
|
+
// 0 only when the cap changed nothing.
|
|
104
|
+
// These five are local only (`derive-run.js` keeps them in the derivation
|
|
105
|
+
// receipt) and never reach facts.
|
|
106
|
+
//
|
|
107
|
+
// Without the session's `started_at` and `derived_through` there is no
|
|
108
|
+
// timeline, so worker 0 is in no job. Without `agents` the session is read as
|
|
109
|
+
// worker 0 alone, and every event as its own.
|
|
110
|
+
//
|
|
111
|
+
// A job's ID hashes its task's *birth* path, not the path a touch was
|
|
112
|
+
// matched against: once a task is found (`readTask` answers), its track and
|
|
113
|
+
// slug are handed to `resolveJobIdentity`, which is where the desk's Git
|
|
114
|
+
// decides whether the task has ever been renamed or moved (the controller
|
|
115
|
+
// ruling in ourostack/desk#76). Evidence is keyed by that birth path, so a
|
|
116
|
+
// task renamed in the middle of a session is still one task and one job.
|
|
117
|
+
//
|
|
118
|
+
// Dependencies are injected so tests can fake them (`desk-repo.js` has the
|
|
119
|
+
// real ones): `readTask(track, slug)`, `gitCommitTaskPaths(sha)`,
|
|
120
|
+
// `isCardHousekeeping(sha, path)`, `resolveJobIdentity(track, slug)` and
|
|
121
|
+
// `repoLookup(absolutePath)`, which answers `{ repo: "owner/name" }`,
|
|
122
|
+
// `{ none: true }` (a true none) or `{ unavailable: true }`, and the optional
|
|
123
|
+
// `mergedInto(track, slug)`, the `{ track, slug }` a task with no card of
|
|
124
|
+
// its own was merged into (`task_update into_task`), so a focus held on it
|
|
125
|
+
// follows into the task that keeps the job (null, or left out: no merge
|
|
126
|
+
// is followed). The desk root is passed in rather than resolved here: `src/util/paths.js` is
|
|
127
|
+
// outside `src/factory`, so the caller resolves it (with
|
|
128
|
+
// `resolveDeskRootWithSource`) and hands it over.
|
|
129
|
+
//
|
|
130
|
+
// `src/factory/**` imports only `node:` built-ins and other `src/factory/`
|
|
131
|
+
// files.
|
|
132
|
+
|
|
133
|
+
import { createHash } from "node:crypto"
|
|
134
|
+
import { realpathSync } from "node:fs"
|
|
135
|
+
import * as path from "node:path"
|
|
136
|
+
|
|
137
|
+
import { capSegments, controllerTimeline } from "./focus.js"
|
|
138
|
+
import { ENUMS, LIMITS, PATTERNS } from "./schema.js"
|
|
139
|
+
import { DESK_MARKER } from "./shell-git.js"
|
|
140
|
+
|
|
141
|
+
const TERMINAL = new Set(["done", "cancelled"])
|
|
142
|
+
const PERSON_PREFIX = /^(?:desks\/([^/\\]+))?$/u
|
|
143
|
+
const SCP_REMOTE = /^([^@/\s]+@)?([^:/\s]{2,}):\/?([^/].*)$/u
|
|
144
|
+
const WINDOWS_PATH = /^[A-Za-z]:[\\/]/u
|
|
145
|
+
const URL_REMOTE = /^([a-z][a-z0-9+.-]*):\/\/(?:[^@/]*@)?([^/:]+)(?::\d+)?(\/.*)?$/iu
|
|
146
|
+
const HTTPS_SCHEMES = new Set(["ssh", "git", "git+ssh", "ssh+git"])
|
|
147
|
+
|
|
148
|
+
// When a card read with a terminal `status` is known to have held it: the later of the session's own last transition into that status and the
|
|
149
|
+
// card's `updated` from the same read, or `null`. An `updated` that is not after the card's `created` was never restamped since the card was
|
|
150
|
+
// made (a card edited by hand), so it cannot date a status the card reached later, and pairing it with the status the read gave would date
|
|
151
|
+
// the finish before the work it ended; it counts only when the card has no readable `created` to compare with. Every transition counts, even
|
|
152
|
+
// one the facts' cap later cuts from the list.
|
|
153
|
+
function observedTime(card, status, transitions) {
|
|
154
|
+
const created = isTime(card.created_at) ? Date.parse(card.created_at) : null
|
|
155
|
+
const stamped = isTime(card.updated_at) && (created === null || Date.parse(card.updated_at) > created) ? card.updated_at : null
|
|
156
|
+
const moved = transitions.filter((transition) => transition.to === status).map((transition) => transition.at)
|
|
157
|
+
const candidates = [...moved, ...(stamped === null ? [] : [stamped])]
|
|
158
|
+
return candidates.length === 0 ? null : candidates.reduce((latest, at) => (Date.parse(at) > Date.parse(latest) ? at : latest))
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
// ---------------------------------------------------------------------------
|
|
162
|
+
// Job IDs.
|
|
163
|
+
// ---------------------------------------------------------------------------
|
|
164
|
+
|
|
165
|
+
function stripSuffixes(text) {
|
|
166
|
+
let result = text.replace(/[/\\]+$/u, "")
|
|
167
|
+
if (result.toLowerCase().endsWith(".git")) result = result.slice(0, -4)
|
|
168
|
+
return result.replace(/[/\\]+$/u, "")
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
/**
|
|
172
|
+
* Normalizes a desk remote so every spelling of one repository hashes the
|
|
173
|
+
* same: lowercases the host and owner/repo, strips credentials, a port, a
|
|
174
|
+
* `.git` suffix and trailing slashes, and maps `git@host:owner/repo` (also
|
|
175
|
+
* `git@host:/owner/repo`) and `ssh://`/`git://` URLs to
|
|
176
|
+
* `https://host/owner/repo`. `local:<root>` (a desk with no remote) is kept
|
|
177
|
+
* as is; any other string, a Windows path such as `C:\\repos\\desk` included,
|
|
178
|
+
* only loses its `.git` suffix and trailing slashes.
|
|
179
|
+
*/
|
|
180
|
+
export function normalizeRemote(remote) {
|
|
181
|
+
if (typeof remote !== "string" || remote.trim() === "") throw Object.assign(new TypeError("normalizeRemote: Pass remote as a non-empty string"), { code: "binding_normalizeremote_pass_remote_as_a" })
|
|
182
|
+
const text = remote.trim()
|
|
183
|
+
if (text.startsWith("local:")) return text
|
|
184
|
+
if (WINDOWS_PATH.test(text)) return stripSuffixes(text)
|
|
185
|
+
const url = URL_REMOTE.exec(text)
|
|
186
|
+
if (url) {
|
|
187
|
+
const scheme = url[1].toLowerCase()
|
|
188
|
+
const target = HTTPS_SCHEMES.has(scheme) ? "https" : scheme
|
|
189
|
+
return `${target}://${url[2].toLowerCase()}${stripSuffixes(url[3] ?? "").toLowerCase()}`
|
|
190
|
+
}
|
|
191
|
+
const scp = SCP_REMOTE.exec(text)
|
|
192
|
+
if (scp) return `https://${scp[2].toLowerCase()}/${stripSuffixes(scp[3]).toLowerCase()}`
|
|
193
|
+
return stripSuffixes(text)
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
/** A track or task folder name: one path segment, not hidden, not reserved (`_…`). */
|
|
197
|
+
export function isTaskSegment(value) {
|
|
198
|
+
return typeof value === "string" && value !== "" && !value.startsWith("_") && !value.startsWith(".") && !/[/\\]/u.test(value)
|
|
199
|
+
}
|
|
200
|
+
|
|
201
|
+
/** The alias in a `desks/<alias>` person prefix, `null` for `""`; anything else is a caller bug. */
|
|
202
|
+
export function checkPersonPrefix(personPrefix, caller) {
|
|
203
|
+
const match = typeof personPrefix === "string" ? PERSON_PREFIX.exec(personPrefix) : null
|
|
204
|
+
if (match === null || match[1] === "." || match[1] === "..") {
|
|
205
|
+
throw Object.assign(new TypeError(`${caller}: Pass personPrefix as "" or "desks/<alias>"`), { code: "binding_pass_personprefix_as_or_desks" })
|
|
206
|
+
}
|
|
207
|
+
return match[1] ?? null
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
/** `jobId({ deskRemote, personPrefix, track, slug })`: the first 32 hex of the job's SHA-256. */
|
|
211
|
+
export function jobId({ deskRemote, personPrefix, track, slug }) {
|
|
212
|
+
checkPersonPrefix(personPrefix, "jobId")
|
|
213
|
+
if (!isTaskSegment(track) || !isTaskSegment(slug)) throw Object.assign(new TypeError("jobId: Pass track and slug as task folder names"), { code: "binding_jobid_pass_track_and_slug" })
|
|
214
|
+
const input = `${normalizeRemote(deskRemote)}\n${personPrefix}\n${track}/${slug}`
|
|
215
|
+
return createHash("sha256").update(input).digest("hex").slice(0, 32)
|
|
216
|
+
}
|
|
217
|
+
|
|
218
|
+
// ---------------------------------------------------------------------------
|
|
219
|
+
// Paths to tasks.
|
|
220
|
+
// ---------------------------------------------------------------------------
|
|
221
|
+
|
|
222
|
+
const CARD_FILE = "task.md"
|
|
223
|
+
|
|
224
|
+
// A desk commit spanning more tasks than this is a sweep and binds none.
|
|
225
|
+
const MASS_COMMIT_TASKS = 3
|
|
226
|
+
|
|
227
|
+
const CREATE_CALL = /task_create$/u
|
|
228
|
+
// A sign-off is the human's answer to a delivery, given in a session that may have done no work on the task: it binds nothing.
|
|
229
|
+
const SIGNOFF_CALL = /task_signoff$/u
|
|
230
|
+
// A task tool call commits the card within moments; a minute each way covers Git's whole seconds and a slow push.
|
|
231
|
+
const TOOL_CALL_REACH_MS = 60000
|
|
232
|
+
// At most this many own-activity spans are kept; `reconcile.js` reads a full list as cut after its last span.
|
|
233
|
+
export const OWN_ACTIVITY_SPANS = 500
|
|
234
|
+
const KIND_BASIS = Object.freeze({ tool: "desk_tool", write: "file_write", commit: "desk_commit", spawn: "spawn_brief" })
|
|
235
|
+
|
|
236
|
+
/**
|
|
237
|
+
* `{ track, slug, bare }` for desk-relative path segments naming a path
|
|
238
|
+
* inside a task folder, or null. `bare` is true when the only segment past
|
|
239
|
+
* `<track>/<slug>` (or `<track>/_archive/<slug>`) is the card itself,
|
|
240
|
+
* `task.md`, matched case-insensitively so `Task.md` and `TASK.MD` are the
|
|
241
|
+
* same card; a nested `task.md` inside a subfolder is not bare. See the
|
|
242
|
+
* header for what a caller does with `bare`.
|
|
243
|
+
*/
|
|
244
|
+
export function taskOfSegments(segments, alias) {
|
|
245
|
+
let rest = segments
|
|
246
|
+
if (alias !== null) {
|
|
247
|
+
if (rest[0] !== "desks" || rest[1] !== alias) return null
|
|
248
|
+
rest = rest.slice(2)
|
|
249
|
+
} else if (rest[0] === "desks") {
|
|
250
|
+
return null
|
|
251
|
+
}
|
|
252
|
+
const [track, second, third] = rest
|
|
253
|
+
const archived = second === "_archive"
|
|
254
|
+
const slug = archived ? third : second
|
|
255
|
+
const inner = rest.slice(archived ? 3 : 2)
|
|
256
|
+
if (!isTaskSegment(track) || !isTaskSegment(slug) || inner.length < 1) return null
|
|
257
|
+
const bare = inner.length === 1 && inner[0].toLowerCase() === CARD_FILE
|
|
258
|
+
return { track, slug, bare }
|
|
259
|
+
}
|
|
260
|
+
|
|
261
|
+
export function relativeSegments(relative) {
|
|
262
|
+
return relative.split(/[/\\]/u).filter((segment) => segment !== "")
|
|
263
|
+
}
|
|
264
|
+
|
|
265
|
+
// The desk-relative segments of an absolute path inside one of `roots`, or null.
|
|
266
|
+
function segmentsInDesk(filePath, roots) {
|
|
267
|
+
if (typeof filePath !== "string" || !path.isAbsolute(filePath)) return null
|
|
268
|
+
for (const root of roots) {
|
|
269
|
+
const relative = path.relative(root, path.resolve(filePath))
|
|
270
|
+
if (!relative.startsWith("..") && !path.isAbsolute(relative)) return relativeSegments(relative)
|
|
271
|
+
}
|
|
272
|
+
return null
|
|
273
|
+
}
|
|
274
|
+
|
|
275
|
+
// The desk root's real path, or the root as given when it can't be resolved.
|
|
276
|
+
function realOrResolved(deskRoot) {
|
|
277
|
+
try {
|
|
278
|
+
return realpathSync(deskRoot)
|
|
279
|
+
} catch {
|
|
280
|
+
return path.resolve(deskRoot)
|
|
281
|
+
}
|
|
282
|
+
}
|
|
283
|
+
|
|
284
|
+
function deskRootsOf(deskRoot) {
|
|
285
|
+
return [...new Set([path.resolve(deskRoot), realOrResolved(deskRoot)])]
|
|
286
|
+
}
|
|
287
|
+
|
|
288
|
+
// A shell commit's directory with `$DESK` replaced by the desk root.
|
|
289
|
+
function expandDeskMarker(cwd, deskRoot) {
|
|
290
|
+
if (typeof cwd !== "string") return null
|
|
291
|
+
if (cwd === DESK_MARKER) return deskRoot
|
|
292
|
+
if (cwd.startsWith(`${DESK_MARKER}/`)) return path.join(deskRoot, cwd.slice(DESK_MARKER.length + 1))
|
|
293
|
+
return cwd
|
|
294
|
+
}
|
|
295
|
+
|
|
296
|
+
// ---------------------------------------------------------------------------
|
|
297
|
+
// Binding.
|
|
298
|
+
// ---------------------------------------------------------------------------
|
|
299
|
+
|
|
300
|
+
function isTime(value) {
|
|
301
|
+
return typeof value === "string" && PATTERNS.timestamp.test(value)
|
|
302
|
+
}
|
|
303
|
+
|
|
304
|
+
// Git keeps whole seconds, so a commit made during a call that started at
|
|
305
|
+
// 08:00:05.600 is stamped 08:00:05; the window opens at the start's second.
|
|
306
|
+
function floorToSecond(iso) {
|
|
307
|
+
return `${iso.slice(0, 19)}.000Z`
|
|
308
|
+
}
|
|
309
|
+
|
|
310
|
+
function asArray(value) {
|
|
311
|
+
return Array.isArray(value) ? value : []
|
|
312
|
+
}
|
|
313
|
+
|
|
314
|
+
// Epoch milliseconds of a facts timestamp, or `null`.
|
|
315
|
+
function msOf(value) {
|
|
316
|
+
return isTime(value) ? Date.parse(value) : null
|
|
317
|
+
}
|
|
318
|
+
|
|
319
|
+
/**
|
|
320
|
+
* `taskCommitRule({ alias, isCardHousekeeping })` -> `(sha, taskPaths) => { tasks, real, touched, mass }`:
|
|
321
|
+
* how one desk commit counts toward tasks, shared by the binder and `factory reconcile`.
|
|
322
|
+
* `touched` is every task a path names. `real` leaves out a bare card whose diff in that commit
|
|
323
|
+
* is identity or placement only (`isCardHousekeeping` is the judge). `mass` is true when `real`
|
|
324
|
+
* spans more than MASS_COMMIT_TASKS tasks, a housekeeping sweep rather than work on any one of
|
|
325
|
+
* them. `tasks` is what the commit binds: `real`, or nothing for a mass commit. Each task is
|
|
326
|
+
* `{ track, slug, bare }`.
|
|
327
|
+
*/
|
|
328
|
+
export function taskCommitRule({ alias, isCardHousekeeping }) {
|
|
329
|
+
return (sha, taskPaths) => {
|
|
330
|
+
const touched = new Map()
|
|
331
|
+
const real = new Map()
|
|
332
|
+
for (const taskPath of asArray(taskPaths)) {
|
|
333
|
+
if (typeof taskPath !== "string") continue
|
|
334
|
+
const task = taskOfSegments(relativeSegments(taskPath), alias)
|
|
335
|
+
if (task === null) continue
|
|
336
|
+
const key = `${task.track}/${task.slug}`
|
|
337
|
+
touched.set(key, task)
|
|
338
|
+
if (task.bare && isCardHousekeeping(sha, taskPath)) continue
|
|
339
|
+
real.set(key, task)
|
|
340
|
+
}
|
|
341
|
+
const mass = real.size > MASS_COMMIT_TASKS
|
|
342
|
+
return { tasks: mass ? [] : [...real.values()], real: [...real.values()], touched: [...touched.values()], mass }
|
|
343
|
+
}
|
|
344
|
+
}
|
|
345
|
+
|
|
346
|
+
function requireFunction(value, name) {
|
|
347
|
+
if (typeof value !== "function") throw Object.assign(new TypeError(`bindSession: Pass ${name} as a function`), { code: "binding_bindsession_pass_as_a_function" })
|
|
348
|
+
}
|
|
349
|
+
|
|
350
|
+
/**
|
|
351
|
+
* `bindSession({ events, agents, session, deskRoot, deskRemote, personPrefix,
|
|
352
|
+
* readTask, mergedInto, gitCommitTaskPaths, isCardHousekeeping, resolveJobIdentity,
|
|
353
|
+
* repoLookup }) -> { jobs, boundBy, disagrees, ownActivity, repoUnresolved, segmentsCappedMs }`; the
|
|
354
|
+
* header describes each. `agents` is the facts' `agents[]` (`{ n, parent }`),
|
|
355
|
+
* used for ancestry. `session` is the facts' `session` (`started_at` and
|
|
356
|
+
* `derived_through` are read). `deskRemote` is the desk's `origin` URL, or
|
|
357
|
+
* empty when it has none (the job IDs then use `local:` plus the desk root).
|
|
358
|
+
*/
|
|
359
|
+
export function bindSession({ events, agents, session, deskRoot, deskRemote, personPrefix, readTask, mergedInto = () => null, gitCommitTaskPaths, isCardHousekeeping, resolveJobIdentity, repoLookup }) {
|
|
360
|
+
if (typeof deskRoot !== "string" || !path.isAbsolute(deskRoot)) throw Object.assign(new TypeError("bindSession: Pass deskRoot as an absolute path"), { code: "binding_bindsession_pass_deskroot_as_an" })
|
|
361
|
+
const alias = checkPersonPrefix(personPrefix, "bindSession")
|
|
362
|
+
requireFunction(readTask, "readTask")
|
|
363
|
+
requireFunction(gitCommitTaskPaths, "gitCommitTaskPaths")
|
|
364
|
+
requireFunction(isCardHousekeeping, "isCardHousekeeping")
|
|
365
|
+
requireFunction(resolveJobIdentity, "resolveJobIdentity")
|
|
366
|
+
// One reader with three answers, so a caller cannot take evidence that is not available for a true none; a caller that omits it is an error.
|
|
367
|
+
requireFunction(repoLookup, "repoLookup")
|
|
368
|
+
if (deskRemote !== undefined && deskRemote !== null && typeof deskRemote !== "string") throw Object.assign(new TypeError("bindSession: Pass deskRemote as a string or empty"), { code: "binding_bindsession_pass_deskremote_as_a" })
|
|
369
|
+
// One unpublished desk reached through a symlink and through its real path is one desk.
|
|
370
|
+
const remote = typeof deskRemote === "string" && deskRemote.trim() !== "" ? deskRemote : `local:${realOrResolved(deskRoot)}`
|
|
371
|
+
const roots = deskRootsOf(deskRoot)
|
|
372
|
+
const source = events ?? {}
|
|
373
|
+
|
|
374
|
+
// Without `agents` the session is worker 0 alone, and every event is its own.
|
|
375
|
+
const hasAgents = Array.isArray(agents)
|
|
376
|
+
const workers = hasAgents ? agents : [{ n: 0, parent: null }]
|
|
377
|
+
const agentOf = (item) => (hasAgents && Number.isInteger(item?.agent) && item.agent >= 0 ? item.agent : 0)
|
|
378
|
+
// A worker `agents` does not list contributes nothing: the facts could not name it in a job's `agents`.
|
|
379
|
+
const listed = new Set(workers.map((worker) => worker?.n))
|
|
380
|
+
const parents = new Map()
|
|
381
|
+
for (const worker of workers) {
|
|
382
|
+
if (Number.isInteger(worker?.n) && Number.isInteger(worker.parent)) parents.set(worker.n, worker.parent)
|
|
383
|
+
}
|
|
384
|
+
const startedMs = msOf(session?.started_at)
|
|
385
|
+
const endMs = msOf(session?.derived_through)
|
|
386
|
+
|
|
387
|
+
// Tasks by birth key, `{ key, birth, card, transitions }`, each card read once per name it was touched under.
|
|
388
|
+
const tasks = new Map()
|
|
389
|
+
const named = new Map()
|
|
390
|
+
const taskOf = ({ track, slug }) => {
|
|
391
|
+
const name = `${track}/${slug}`
|
|
392
|
+
if (!named.has(name)) {
|
|
393
|
+
const card = readTask(track, slug)
|
|
394
|
+
let task = null
|
|
395
|
+
if (card !== null && card !== undefined) {
|
|
396
|
+
const birth = resolveJobIdentity(track, slug)
|
|
397
|
+
const key = `${birth.track}/${birth.slug}`
|
|
398
|
+
if (!tasks.has(key)) tasks.set(key, { key, birth, card, transitions: [] })
|
|
399
|
+
task = tasks.get(key)
|
|
400
|
+
}
|
|
401
|
+
named.set(name, task)
|
|
402
|
+
}
|
|
403
|
+
return named.get(name)
|
|
404
|
+
}
|
|
405
|
+
// Where a path an event names lies: `{ segments }`, its desk-relative segments, or `{ outside }`, its absolute path outside the
|
|
406
|
+
// desk; `null` for no path. A relative path is taken from the desk root.
|
|
407
|
+
const locate = (value) => {
|
|
408
|
+
if (typeof value !== "string" || value === "") return null
|
|
409
|
+
const absolute = path.resolve(roots[0], expandDeskMarker(value, roots[0]))
|
|
410
|
+
const segments = segmentsInDesk(absolute, roots)
|
|
411
|
+
return segments === null ? { outside: absolute } : { segments }
|
|
412
|
+
}
|
|
413
|
+
// The `{ track, slug }` desk segments name: a path inside a task folder, or (`folder`) the folder itself.
|
|
414
|
+
const nameOf = (segments, folder = false) => taskOfSegments(folder ? [...segments, CARD_FILE] : segments, alias)
|
|
415
|
+
// The repository holding an absolute path outside the desk, or `null`; `directory` is counted when it cannot be named.
|
|
416
|
+
const unresolved = new Set()
|
|
417
|
+
const repoAt = (lookup, directory = lookup, options = undefined) => {
|
|
418
|
+
const found = repoLookup(lookup, options)
|
|
419
|
+
if (typeof found?.repo === "string" && found.repo !== "") return found.repo
|
|
420
|
+
// A true none is nothing lost. Anything else, including an answer that is none of the three, is evidence that was not available.
|
|
421
|
+
if (found?.none !== true) unresolved.add(directory)
|
|
422
|
+
return null
|
|
423
|
+
}
|
|
424
|
+
|
|
425
|
+
// The session tree's evidence, `{ at, key, kind, agent }` (`at` in epoch ms, null when unknown), and its own activity spans in epoch ms.
|
|
426
|
+
const evidence = []
|
|
427
|
+
const spans = []
|
|
428
|
+
const note = (item, name, kind, at) => {
|
|
429
|
+
const agent = agentOf(item)
|
|
430
|
+
const task = name === null || !listed.has(agent) ? null : taskOf(name)
|
|
431
|
+
if (task !== null) evidence.push({ at, key: task.key, kind, agent })
|
|
432
|
+
}
|
|
433
|
+
|
|
434
|
+
for (const call of asArray(source.deskToolCalls)) {
|
|
435
|
+
if (call?.ok !== true) continue
|
|
436
|
+
const at = msOf(call.at)
|
|
437
|
+
if (at !== null) spans.push([at - TOOL_CALL_REACH_MS, at + TOOL_CALL_REACH_MS])
|
|
438
|
+
if (!isTaskSegment(call.track) || !isTaskSegment(call.slug) || !listed.has(agentOf(call))) continue
|
|
439
|
+
if (typeof call.name === "string" && SIGNOFF_CALL.test(call.name)) continue
|
|
440
|
+
const task = taskOf(call)
|
|
441
|
+
if (task === null) continue
|
|
442
|
+
if (ENUMS.jobStatus.includes(call.status) && at !== null) task.transitions.push({ to: call.status, at: call.at })
|
|
443
|
+
// Filing a card, or only moving its status, is not working on it.
|
|
444
|
+
const filing = typeof call.name === "string" && CREATE_CALL.test(call.name)
|
|
445
|
+
if (!filing && call.statusOnly !== true) evidence.push({ at, key: task.key, kind: "tool", agent: agentOf(call) })
|
|
446
|
+
}
|
|
447
|
+
|
|
448
|
+
for (const write of asArray(source.fileWrites)) {
|
|
449
|
+
const place = locate(write?.path)
|
|
450
|
+
if (place === null || !listed.has(agentOf(write))) continue
|
|
451
|
+
if (place.segments !== undefined) {
|
|
452
|
+
note(write, nameOf(place.segments), "write", msOf(write.at))
|
|
453
|
+
continue
|
|
454
|
+
}
|
|
455
|
+
const repo = repoAt(path.dirname(place.outside))
|
|
456
|
+
if (repo !== null) evidence.push({ at: msOf(write.at), repo, kind: "repo", agent: agentOf(write) })
|
|
457
|
+
}
|
|
458
|
+
|
|
459
|
+
// Each subagent's spawn time, and the task of its `Desk-Task:` line when that card exists.
|
|
460
|
+
const spawnedAt = new Map()
|
|
461
|
+
const briefed = new Map()
|
|
462
|
+
for (const spawn of asArray(source.spawns)) {
|
|
463
|
+
const child = spawn?.agent
|
|
464
|
+
if (!Number.isInteger(child) || child < 1 || !listed.has(child)) continue
|
|
465
|
+
const at = msOf(spawn.at)
|
|
466
|
+
if (at !== null) spawnedAt.set(child, at)
|
|
467
|
+
if (!isTaskSegment(spawn.task?.track) || !isTaskSegment(spawn.task.slug)) continue
|
|
468
|
+
const task = taskOf(spawn.task)
|
|
469
|
+
if (task === null) continue
|
|
470
|
+
briefed.set(child, task.key)
|
|
471
|
+
// The brief is its parent's event; with no parent on record it is nobody's.
|
|
472
|
+
evidence.push({ at, key: task.key, kind: "spawn", agent: parents.get(child) })
|
|
473
|
+
}
|
|
474
|
+
|
|
475
|
+
for (const call of asArray(source.shellGitCommits)) {
|
|
476
|
+
if (!isTime(call?.start) || !isTime(call.end) || call.end < call.start) continue
|
|
477
|
+
if (segmentsInDesk(expandDeskMarker(call.cwd, roots[0]), roots) !== null) spans.push([Date.parse(floorToSecond(call.start)), Date.parse(call.end)])
|
|
478
|
+
if (!listed.has(agentOf(call))) continue
|
|
479
|
+
const names = new Map()
|
|
480
|
+
const repos = new Set()
|
|
481
|
+
const cwd = locate(call.cwd)
|
|
482
|
+
// A directory that is not absolute says nothing about where the call ran.
|
|
483
|
+
if (cwd?.outside !== undefined && path.isAbsolute(call.cwd)) repos.add(repoAt(cwd.outside))
|
|
484
|
+
for (const entry of asArray(call.paths)) {
|
|
485
|
+
const place = locate(entry)
|
|
486
|
+
if (place === null) continue
|
|
487
|
+
if (place.segments === undefined) {
|
|
488
|
+
// The entry itself: a path that is a nested repository root names its own repository, a file is looked up by its folder.
|
|
489
|
+
repos.add(repoAt(place.outside, path.dirname(place.outside), { maybeFile: true }))
|
|
490
|
+
continue
|
|
491
|
+
}
|
|
492
|
+
const name = nameOf(place.segments, true)
|
|
493
|
+
if (name !== null) names.set(`${name.track}/${name.slug}`, name)
|
|
494
|
+
}
|
|
495
|
+
for (const repo of repos) if (repo !== null) evidence.push({ at: Date.parse(call.start), repo, kind: "repo", agent: agentOf(call) })
|
|
496
|
+
if (names.size > MASS_COMMIT_TASKS) continue
|
|
497
|
+
for (const name of names.values()) note(call, name, "commit", Date.parse(call.start))
|
|
498
|
+
}
|
|
499
|
+
|
|
500
|
+
// The tasks a native commit's paths count for (`taskCommitRule` judges).
|
|
501
|
+
const rule = taskCommitRule({ alias, isCardHousekeeping })
|
|
502
|
+
for (const entry of asArray(source.nativeCommitShas)) {
|
|
503
|
+
const sha = entry?.sha
|
|
504
|
+
if (typeof sha !== "string" || !PATTERNS.commitSha.test(sha)) continue
|
|
505
|
+
const found = gitCommitTaskPaths(sha)
|
|
506
|
+
if (found?.exists === true) for (const name of rule(sha, found.taskPaths).tasks) note(entry, name, "commit", null)
|
|
507
|
+
}
|
|
508
|
+
|
|
509
|
+
for (const ref of asArray(source.prRefs)) {
|
|
510
|
+
if (ref?.created === true && typeof ref.repo === "string") evidence.push({ at: msOf(ref.at), repo: ref.repo, kind: "repo", agent: agentOf(ref) })
|
|
511
|
+
}
|
|
512
|
+
|
|
513
|
+
// Where a subagent's job comes from: `{ line }`, the task of the nearest `Desk-Task:` line from itself upward,
|
|
514
|
+
// or `{ top }`, its ancestor that worker 0 spawned; neither when its ancestry cannot be traced.
|
|
515
|
+
const originOf = (agent) => {
|
|
516
|
+
const seen = new Set()
|
|
517
|
+
let current = agent
|
|
518
|
+
while (!seen.has(current)) {
|
|
519
|
+
if (briefed.has(current)) return { line: briefed.get(current) }
|
|
520
|
+
seen.add(current)
|
|
521
|
+
const parent = parents.get(current)
|
|
522
|
+
if (parent === 0) return { top: current }
|
|
523
|
+
current = parent
|
|
524
|
+
}
|
|
525
|
+
return {}
|
|
526
|
+
}
|
|
527
|
+
|
|
528
|
+
// Worker 0's timeline, `[{ key, start, end }]` in epoch ms.
|
|
529
|
+
let timeline = { segments: [], boundBy: new Map(), disagrees: new Set() }
|
|
530
|
+
// The time the segment cap dropped (`capSegments` reports it); 0 when nothing was dropped, which includes a session with no timeline.
|
|
531
|
+
let segmentsCappedMs = 0
|
|
532
|
+
let kept = []
|
|
533
|
+
if (startedMs !== null && endMs !== null && endMs >= startedMs && listed.has(0)) {
|
|
534
|
+
const focusCalls = []
|
|
535
|
+
for (const call of asArray(source.focusCalls)) {
|
|
536
|
+
if (agentOf(call) !== 0) continue
|
|
537
|
+
const at = msOf(call?.at)
|
|
538
|
+
if (call?.clear === true) focusCalls.push({ agent: 0, at, clear: true })
|
|
539
|
+
else if (isTaskSegment(call?.track) && isTaskSegment(call.slug)) {
|
|
540
|
+
// A focus on a task later merged into another (`task_update into_task`) follows it into the task that keeps the job, as the held focus
|
|
541
|
+
// did. A focus on a task whose card is otherwise gone still ends the stretch before it, and binds nothing.
|
|
542
|
+
const keeper = taskOf(call) === null ? mergedInto(call.track, call.slug) : null
|
|
543
|
+
const task = keeper === null ? taskOf(call) : taskOf(keeper)
|
|
544
|
+
focusCalls.push(task === null ? { agent: 0, at, clear: true } : { agent: 0, at, key: task.key })
|
|
545
|
+
}
|
|
546
|
+
}
|
|
547
|
+
kept = evidence.filter((event) => listed.has(event.agent) && originOf(event.agent).line === undefined)
|
|
548
|
+
const cards = new Map([...tasks].map(([key, task]) => [key, { repos: asArray(task.card.repos) }]))
|
|
549
|
+
timeline = controllerTimeline({ events: { focusCalls, evidence: kept }, startMs: startedMs, endMs, cards })
|
|
550
|
+
const capped = capSegments({ segments: timeline.segments, main: timeline.main, cap: LIMITS.jobSegments })
|
|
551
|
+
timeline.segments = capped.segments
|
|
552
|
+
segmentsCappedMs = capped.droppedMs
|
|
553
|
+
}
|
|
554
|
+
// The task holding worker 0's timeline at a time; the session's last instant belongs to its last segment.
|
|
555
|
+
const controllerAt = (at) => {
|
|
556
|
+
if (at === undefined) return undefined
|
|
557
|
+
const time = Math.min(endMs, Math.max(startedMs, at))
|
|
558
|
+
return timeline.segments.find((segment) => segment.start <= time && (time < segment.end || (time === endMs && segment.end === endMs)))?.key
|
|
559
|
+
}
|
|
560
|
+
|
|
561
|
+
// Task key -> Map(worker -> how it got there).
|
|
562
|
+
const members = new Map()
|
|
563
|
+
const join = (key, agent, basis) => {
|
|
564
|
+
if (!members.has(key)) members.set(key, new Map())
|
|
565
|
+
members.get(key).set(agent, basis)
|
|
566
|
+
}
|
|
567
|
+
for (const segment of timeline.segments) join(segment.key, 0, null)
|
|
568
|
+
for (const worker of workers) {
|
|
569
|
+
const n = worker?.n
|
|
570
|
+
if (!Number.isInteger(n) || n < 1) continue
|
|
571
|
+
const { line, top } = originOf(n)
|
|
572
|
+
if (line !== undefined) join(line, n, briefed.has(n) ? "spawn_brief" : "inherited")
|
|
573
|
+
else if (controllerAt(spawnedAt.get(top)) !== undefined) join(controllerAt(spawnedAt.get(top)), n, "inherited")
|
|
574
|
+
}
|
|
575
|
+
|
|
576
|
+
const jobs = []
|
|
577
|
+
const ids = new Map()
|
|
578
|
+
for (const [key, task] of tasks) {
|
|
579
|
+
const own = members.get(key)
|
|
580
|
+
if (own === undefined) continue
|
|
581
|
+
const basis = new Set([...own.values()])
|
|
582
|
+
if (timeline.boundBy.get(key) === "focus") basis.add("desk_tool")
|
|
583
|
+
// The evidence that placed worker 0 here; a job only subagents hold rests on their lines alone.
|
|
584
|
+
if (own.has(0)) for (const event of kept) if (event.key === key) basis.add(KIND_BASIS[event.kind])
|
|
585
|
+
const { card } = task
|
|
586
|
+
const status = ENUMS.jobStatus.includes(card.status) ? card.status : null
|
|
587
|
+
const observedAt = status !== null && TERMINAL.has(status) ? observedTime(card, status, task.transitions) : null
|
|
588
|
+
const segments = timeline.segments.filter((segment) => segment.key === key).map((segment) => ({ start_ms: segment.start - startedMs, end_ms: segment.end - startedMs }))
|
|
589
|
+
const id = jobId({ deskRemote: remote, personPrefix, track: task.birth.track, slug: task.birth.slug })
|
|
590
|
+
ids.set(key, id)
|
|
591
|
+
jobs.push({
|
|
592
|
+
job: id,
|
|
593
|
+
basis: ENUMS.jobBasis.filter((item) => basis.has(item)),
|
|
594
|
+
agents: [...own.keys()].sort((x, y) => x - y),
|
|
595
|
+
task_created_at: isTime(card.created_at) ? card.created_at : null,
|
|
596
|
+
transitions: task.transitions.sort((x, y) => (x.at < y.at ? -1 : x.at > y.at ? 1 : 0)).slice(0, LIMITS.jobTransitions),
|
|
597
|
+
observed: status === null ? null : { status, at: observedAt },
|
|
598
|
+
...(segments.length > 0 ? { segments } : {}),
|
|
599
|
+
})
|
|
600
|
+
}
|
|
601
|
+
jobs.sort((a, b) => (a.job < b.job ? -1 : 1))
|
|
602
|
+
|
|
603
|
+
const boundBy = Object.fromEntries([...timeline.boundBy].map(([key, how]) => [ids.get(key), how]).sort(([a], [b]) => (a < b ? -1 : 1)))
|
|
604
|
+
const disagrees = [...timeline.disagrees].map((key) => ids.get(key)).sort()
|
|
605
|
+
const ownActivity = []
|
|
606
|
+
for (const [start, end] of startedMs === null ? [] : spans.sort((a, b) => a[0] - b[0] || a[1] - b[1])) {
|
|
607
|
+
const last = ownActivity.at(-1)
|
|
608
|
+
if (last !== undefined && start - startedMs <= last[1]) last[1] = Math.max(last[1], end - startedMs)
|
|
609
|
+
else ownActivity.push([start - startedMs, end - startedMs])
|
|
610
|
+
}
|
|
611
|
+
return { jobs: jobs.slice(0, LIMITS.jobs), boundBy, disagrees, ownActivity: ownActivity.slice(0, OWN_ACTIVITY_SPANS), repoUnresolved: unresolved.size, segmentsCappedMs, tasks: [...ids].map(([key, id]) => ({ job: id, track: tasks.get(key).birth.track, slug: tasks.get(key).birth.slug })), remote }
|
|
612
|
+
}
|