@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,118 @@
|
|
|
1
|
+
// Index tracing: a shared diagnostic primitive that snapshots the Git staging
|
|
2
|
+
// area immediately before and immediately after Desk's own bash blocks run
|
|
3
|
+
// (boot checks, migration blocks), so a staged path that appears mid-run is
|
|
4
|
+
// caught the moment it happens instead of surfacing later as an opaque pull
|
|
5
|
+
// failure. See spec.md §3 "Index tracing" — this is the diagnostic primitive
|
|
6
|
+
// every later part of the design reuses; it depends on nothing else in that
|
|
7
|
+
// design (no `kaizen-file.js`, no failure-contract filer).
|
|
8
|
+
//
|
|
9
|
+
// `spawnGit` is an injectable seam over `node:child_process`'s `spawnSync`,
|
|
10
|
+
// for tests only; real callers never pass it — mirrors `util/git-stage.js`'s
|
|
11
|
+
// own `run()` helper, hardened the way `runtime/git-inspection.js` hardens
|
|
12
|
+
// its own Git calls (`core.fsmonitor=false`, `core.hooksPath=/dev/null`,
|
|
13
|
+
// `GIT_OPTIONAL_LOCKS=0`), plus a short timeout of its own: a snapshot call
|
|
14
|
+
// sits on a budgeted hot path (a boot check's own budget, as little as 20 ms;
|
|
15
|
+
// a migration block's, up to 2 s), so an unbounded `git` can never hang it.
|
|
16
|
+
|
|
17
|
+
const INDEX_TRACE_TIMEOUT_MS = 1000
|
|
18
|
+
|
|
19
|
+
function run(spawnGit, root, args, timeoutMs) {
|
|
20
|
+
return spawnGit("git", ["-C", root, "-c", "core.fsmonitor=false", "-c", "core.hooksPath=/dev/null", ...args], { windowsHide: true,
|
|
21
|
+
encoding: "utf8",
|
|
22
|
+
timeout: Math.max(1, Math.floor(Math.min(INDEX_TRACE_TIMEOUT_MS, timeoutMs))),
|
|
23
|
+
killSignal: "SIGKILL",
|
|
24
|
+
env: { ...process.env, GIT_OPTIONAL_LOCKS: "0", GIT_NO_LAZY_FETCH: "1" },
|
|
25
|
+
})
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* The paths currently staged (the index) under `root`, or `null` when the
|
|
30
|
+
* read failed or timed out — never thrown. `null` is deliberately not `[]`:
|
|
31
|
+
* they mean different things. A caller that snapshots `null` before a block
|
|
32
|
+
* runs must skip the after-snapshot and the diff entirely, not treat the
|
|
33
|
+
* unknown "before" as empty — that would turn a merely-failed read into a
|
|
34
|
+
* false positive naming every already-staged path as new.
|
|
35
|
+
*/
|
|
36
|
+
export function snapshotStagedPaths({ root, spawnGit, timeoutMs = INDEX_TRACE_TIMEOUT_MS }) {
|
|
37
|
+
if (timeoutMs < 1) return null
|
|
38
|
+
let result
|
|
39
|
+
try {
|
|
40
|
+
result = run(spawnGit, root, ["diff", "--cached", "--name-only", "--no-ext-diff", "--no-textconv", "--ignore-submodules=all"], timeoutMs)
|
|
41
|
+
} catch {
|
|
42
|
+
return null
|
|
43
|
+
}
|
|
44
|
+
if (result.error || result.status !== 0 || typeof result.stdout !== "string") return null
|
|
45
|
+
return result.stdout
|
|
46
|
+
.split("\n")
|
|
47
|
+
.map((line) => line.trim())
|
|
48
|
+
.filter((line) => line !== "")
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
/** The paths present in `after` but not in `before` — what newly became staged between two snapshots. */
|
|
52
|
+
export function diffStagedPaths(before, after) {
|
|
53
|
+
const seen = new Set(before)
|
|
54
|
+
return after.filter((entry) => !seen.has(entry))
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
/**
|
|
58
|
+
* The `Desk problem:` block every mechanism emits (spec.md, "The block
|
|
59
|
+
* format"): a `Desk problem: <mechanism> — <symptom>` header line, then
|
|
60
|
+
* `broke`/`means`/`fix`/`file`/`tell`, each on its own two-space-indented
|
|
61
|
+
* line, in that order. `symptom` is a short, identity-bearing phrase for the
|
|
62
|
+
* header alone (for example `unexpected file staged during probe`); `broke`
|
|
63
|
+
* carries the full detail (exact paths and all) for the body.
|
|
64
|
+
*/
|
|
65
|
+
export function formatDeskProblem({ mechanism, symptom, broke, means, fix, file, tell }) {
|
|
66
|
+
return [
|
|
67
|
+
`Desk problem: ${mechanism} — ${symptom}`,
|
|
68
|
+
` broke: ${broke}`,
|
|
69
|
+
` means: ${means}`,
|
|
70
|
+
` fix: ${fix}`,
|
|
71
|
+
` file: ${file}`,
|
|
72
|
+
` tell: ${tell}`,
|
|
73
|
+
].join("\n")
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
/** The honest, no-op filing step: never called with `env` missing -- see the header above `formatIndexDriftProblem`. */
|
|
77
|
+
async function noFiler() {
|
|
78
|
+
return { file: "not filed: filer_unavailable" }
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
/**
|
|
82
|
+
* The complete index-drift `Desk problem:` block for `drift` (one or more
|
|
83
|
+
* newly staged paths) found while `label` ran — a boot check's own id, or a
|
|
84
|
+
* migration's `<id>:detect`/`<id>:safety-check`/`<id>:migrate` tag. `kind`
|
|
85
|
+
* names what kind of thing `label` is, for the prose ("boot check" or
|
|
86
|
+
* "migration block"). Shared by every index-tracing call site so the wording
|
|
87
|
+
* never drifts between them.
|
|
88
|
+
*
|
|
89
|
+
* `means` and `tell` deliberately stop short of naming `label` as the staging
|
|
90
|
+
* agent: the same-process check and a different session's own work landing
|
|
91
|
+
* at that exact moment look identical from here, so both are named as
|
|
92
|
+
* possibilities rather than one being asserted as fact.
|
|
93
|
+
*
|
|
94
|
+
* Migrated onto the failure contract (spec.md §1, Part 5): filing is never
|
|
95
|
+
* done here, and never awaited by this function's own callers past this
|
|
96
|
+
* call -- `fileProblem` is an injectable hook. With no default filing
|
|
97
|
+
* step (real callers on a hot, tightly budgeted path could not afford an
|
|
98
|
+
* account lookup and `gh` calls inline), the block renders honestly with
|
|
99
|
+
* `file: not filed: filer_unavailable`; each real call site (boot-
|
|
100
|
+
* checks.cjs's registry loop, pending-migrations.js's `pendingMigrations`
|
|
101
|
+
* and `runMigrationCli`) supplies its own closure that queues the same
|
|
102
|
+
* detached `file-desk-problem.js` run every other migrated mechanism uses
|
|
103
|
+
* and reports `file: filing in background`.
|
|
104
|
+
*/
|
|
105
|
+
export async function formatIndexDriftProblem({ kind, label, drift, env, host, fileProblem = noFiler }) {
|
|
106
|
+
const plural = drift.length !== 1
|
|
107
|
+
const paths = drift.join(", ")
|
|
108
|
+
const { file } = await fileProblem({ env, host, reason: `${label}: unexpected staged path(s) appeared during this ${kind}: ${paths}` })
|
|
109
|
+
return formatDeskProblem({
|
|
110
|
+
mechanism: "index-drift",
|
|
111
|
+
symptom: `unexpected ${plural ? "files" : "file"} staged during ${label}`,
|
|
112
|
+
broke: `${label}: unexpected staged path(s) appeared during this ${kind}: ${paths}`,
|
|
113
|
+
means: `${paths} appeared in the index while ${kind} "${label}" ran — it may have staged ${plural ? "them" : "it"}, or another session may have staged ${plural ? "them" : "it"} at the same time`,
|
|
114
|
+
fix: "not undone — staged paths left as-is for inspection",
|
|
115
|
+
file,
|
|
116
|
+
tell: `${plural ? "Files" : "A file"} appeared in the index while "${label}" ran (${paths}); it may have staged ${plural ? "them" : "it"}, or another session may have staged ${plural ? "them" : "it"} at the same time. Left as-is so you can inspect it.`,
|
|
117
|
+
})
|
|
118
|
+
}
|
|
@@ -0,0 +1,133 @@
|
|
|
1
|
+
// Desk's small local record of how its latest start went, for boot checks and agents that did not see the session's tool calls.
|
|
2
|
+
//
|
|
3
|
+
// `last-start.json` in Desk's state directory holds the latest admission state of any session, its code and the latest repair; `last-start/<root key>.json` holds the same for each desk root, so a boot check reads the record of its own root. Both are rewritten on every state change, starting with `admitting`: the root's own record gets that first `admitting` state as soon as the session resolves the root. `repairs.log` gets one line per repair Desk makes on its own.
|
|
4
|
+
//
|
|
5
|
+
// `writeLastStart` and `appendRepairLog` are the two places this module actually writes; each calls `assertNotRealStateUnderTest` (`./test-state-guard.js`) first, refusing a non-temp state directory from what looks like a node:test run. `resolveDeskStateDir` itself stays a plain, side-effect-free function — many tests call it only to compute an expected path — so the guard sits at the write points, not there.
|
|
6
|
+
|
|
7
|
+
import { createHash, randomBytes } from "node:crypto"
|
|
8
|
+
import { appendFileSync, mkdirSync } from "node:fs"
|
|
9
|
+
import { mkdir, rm, writeFile } from "node:fs/promises"
|
|
10
|
+
import * as os from "node:os"
|
|
11
|
+
import * as path from "node:path"
|
|
12
|
+
import { renameWithRetryAsync } from "../util/rename-retry.js"
|
|
13
|
+
import { assertNotRealStateUnderTest } from "./test-state-guard.js"
|
|
14
|
+
|
|
15
|
+
export const LAST_START_FILE = "last-start.json"
|
|
16
|
+
export const REPAIR_LOG_FILE = "repairs.log"
|
|
17
|
+
export const LAST_START_ROOTS_DIR = "last-start"
|
|
18
|
+
|
|
19
|
+
/** The per-root record's file name: a short digest of the root path. */
|
|
20
|
+
export function lastStartRootKey(root) {
|
|
21
|
+
return createHash("sha256").update(root).digest("hex").slice(0, 16)
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
/** Desk's state directory: `$XDG_STATE_HOME/ouroboros-skills/desk`, else `~/.local/state/ouroboros-skills/desk`. */
|
|
25
|
+
export function resolveDeskStateDir({ env = process.env, homeDir } = {}) {
|
|
26
|
+
const home = homeDir ?? (hasText(env.HOME) ? env.HOME : os.homedir())
|
|
27
|
+
const stateHome = hasText(env.XDG_STATE_HOME) ? env.XDG_STATE_HOME : path.join(home, ".local", "state")
|
|
28
|
+
return path.join(stateHome, "ouroboros-skills", "desk")
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
/** Where older Desk versions' readiness controllers kept their folders, which each session now removes (src/readiness/leftovers.js), unless a caller passes its own. */
|
|
32
|
+
export function resolveReadinessStateHome({ env = process.env, homeDir } = {}) {
|
|
33
|
+
const home = homeDir ?? (hasText(env.HOME) ? env.HOME : os.homedir())
|
|
34
|
+
return path.join(home, ".cache", "ouroboros-skills", "desk", "readiness")
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
/** The record a reader should use: the root's own record once the root is known, else the shared last-start.json. */
|
|
38
|
+
export function lastStartPath({ stateDir, root = null }) {
|
|
39
|
+
return root === null ? path.join(stateDir, LAST_START_FILE) : path.join(stateDir, LAST_START_ROOTS_DIR, `${lastStartRootKey(root)}.json`)
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
/**
|
|
43
|
+
* Replace last-start.json, and the root's own record when the root is known, atomically. Resolves to the path of last-start.json.
|
|
44
|
+
* The I/O is asynchronous: on Windows, creating a file can wait on an antivirus scan for over 100 ms, and a Desk session must not stall its event loop (and every tool call it is answering) for that.
|
|
45
|
+
*/
|
|
46
|
+
export async function writeLastStart({ stateDir, snapshot, root = null, pid = process.pid, now = () => new Date() }) {
|
|
47
|
+
assertNotRealStateUnderTest(stateDir)
|
|
48
|
+
await mkdir(stateDir, { recursive: true, mode: 0o700 })
|
|
49
|
+
const file = path.join(stateDir, LAST_START_FILE)
|
|
50
|
+
const record = {
|
|
51
|
+
schema_version: 1,
|
|
52
|
+
state: snapshot.state,
|
|
53
|
+
code: snapshot.code,
|
|
54
|
+
repair: snapshot.repair,
|
|
55
|
+
fix: snapshot.fix,
|
|
56
|
+
root,
|
|
57
|
+
pid,
|
|
58
|
+
updated_at: now().toISOString(),
|
|
59
|
+
}
|
|
60
|
+
await replaceFile(file, record, pid)
|
|
61
|
+
if (root !== null) {
|
|
62
|
+
const rootsDir = path.join(stateDir, LAST_START_ROOTS_DIR)
|
|
63
|
+
await mkdir(rootsDir, { recursive: true, mode: 0o700 })
|
|
64
|
+
await replaceFile(lastStartPath({ stateDir, root }), record, pid)
|
|
65
|
+
}
|
|
66
|
+
return file
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
/**
|
|
70
|
+
* A session's writer of its start records: `record` returns at once, the writes run one at a time in the order recorded, and `written()` resolves once every record so far is on disk.
|
|
71
|
+
* Records waiting behind a running write are coalesced to the latest one per root: each file holds only the latest state, so a skipped intermediate record loses nothing, and closing a session waits for at most one record per root.
|
|
72
|
+
* A failed write goes to `onError` and does not stop later ones. `updated_at` is when `record` was called, not when the write ran.
|
|
73
|
+
*/
|
|
74
|
+
export function createLastStartWriter({ onError, write = writeLastStart }) {
|
|
75
|
+
// Keyed by root and re-inserted on every record, so iteration order is recency order and the newest record is written last, leaving it in the shared last-start.json.
|
|
76
|
+
const pending = new Map()
|
|
77
|
+
let tail = Promise.resolve()
|
|
78
|
+
const report = (error) => {
|
|
79
|
+
try {
|
|
80
|
+
onError(error)
|
|
81
|
+
} catch {
|
|
82
|
+
// A failing error report must not stop the records after it.
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
const drain = async () => {
|
|
86
|
+
for (const [root, args] of pending) {
|
|
87
|
+
pending.delete(root)
|
|
88
|
+
try {
|
|
89
|
+
await write(args)
|
|
90
|
+
} catch (error) {
|
|
91
|
+
report(error)
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
return {
|
|
96
|
+
record(args) {
|
|
97
|
+
const at = new Date()
|
|
98
|
+
const root = args.root ?? null
|
|
99
|
+
const queued = pending.size > 0
|
|
100
|
+
pending.delete(root)
|
|
101
|
+
pending.set(root, { ...args, now: () => at })
|
|
102
|
+
// A drain already queued picks this record up; otherwise start one after the running write.
|
|
103
|
+
if (!queued) tail = tail.then(drain)
|
|
104
|
+
},
|
|
105
|
+
written: () => tail,
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
async function replaceFile(file, record, pid) {
|
|
110
|
+
// Unique per write: two sessions in one process may write the same record at once.
|
|
111
|
+
const temporary = `${file}.${pid}.${randomBytes(4).toString("hex")}.tmp`
|
|
112
|
+
try {
|
|
113
|
+
await writeFile(temporary, `${JSON.stringify(record, null, 2)}\n`, { mode: 0o600 })
|
|
114
|
+
await renameWithRetryAsync(temporary, file)
|
|
115
|
+
} catch (error) {
|
|
116
|
+
// A unique name is never reused, so a failed write removes its own; a failed removal never hides the error.
|
|
117
|
+
await Promise.allSettled([rm(temporary, { force: true })])
|
|
118
|
+
throw error
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
/** Append one repair line: `<time> <root> <line>`. */
|
|
123
|
+
export function appendRepairLog({ stateDir, line, root, now = () => new Date() }) {
|
|
124
|
+
assertNotRealStateUnderTest(stateDir)
|
|
125
|
+
mkdirSync(stateDir, { recursive: true, mode: 0o700 })
|
|
126
|
+
const file = path.join(stateDir, REPAIR_LOG_FILE)
|
|
127
|
+
appendFileSync(file, `${now().toISOString()} ${root} ${line}\n`, { mode: 0o600 })
|
|
128
|
+
return file
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
function hasText(value) {
|
|
132
|
+
return typeof value === "string" && value.trim().length > 0
|
|
133
|
+
}
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
// The `## Lessons` section of an AGENTS.md or a lessons shelf: find, add, replace and remove one-line lessons. Plain
|
|
2
|
+
// string work with no imports, so session start can use it before the runtime dependencies are restored.
|
|
3
|
+
|
|
4
|
+
export const SECTION = "## Lessons"
|
|
5
|
+
|
|
6
|
+
export const lead = (topic) => `- **${topic}.**`
|
|
7
|
+
|
|
8
|
+
/** The line in `text` that holds the lesson for `topic`, or undefined. */
|
|
9
|
+
export function lessonLine(text, topic) {
|
|
10
|
+
return text.split(/\r?\n/u).find((entry) => entry.startsWith(`${lead(topic)} `))
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* `withLesson(text, line, topic) -> { text, replaced }`: the AGENTS.md text with `line` in its `## Lessons` section. A
|
|
15
|
+
* line for the same topic is replaced in place; otherwise the line goes after the section's last line, before the next
|
|
16
|
+
* heading of the same or a higher level, and a file with no section gets one at the end. The file keeps its own line
|
|
17
|
+
* ending: a file checked out on Windows with CRLF stays CRLF, and its section is still found. With `append: true` no line
|
|
18
|
+
* is replaced: `line` goes at the end unless the section already holds that exact line.
|
|
19
|
+
*/
|
|
20
|
+
export function withLesson(text, line, topic, { append = false } = {}) {
|
|
21
|
+
const eol = /\r\n/u.test(text) ? "\r\n" : "\n"
|
|
22
|
+
const lines = text === "" ? [] : text.replace(/(?:\r?\n)+$/u, "").split(/\r?\n/u)
|
|
23
|
+
const join = (list) => `${list.join(eol)}${eol}`
|
|
24
|
+
const section = sectionOf(lines)
|
|
25
|
+
if (section === null) {
|
|
26
|
+
const head = lines.length === 0 ? [] : [...lines, ""]
|
|
27
|
+
return { text: join([...head, SECTION, "", line]), replaced: false }
|
|
28
|
+
}
|
|
29
|
+
const { start, end } = section
|
|
30
|
+
const prefix = `${lead(topic)} `
|
|
31
|
+
const same = lines.findIndex((entry, index) => index > start && index < end && (append ? entry === line : entry.startsWith(prefix)))
|
|
32
|
+
if (same !== -1) {
|
|
33
|
+
lines[same] = line
|
|
34
|
+
return { text: join(lines), replaced: true }
|
|
35
|
+
}
|
|
36
|
+
let last = end - 1
|
|
37
|
+
while (last > start && lines[last].trim() === "") last -= 1
|
|
38
|
+
const insert = last === start ? [lines.slice(0, start + 1), [""], [line]] : [lines.slice(0, last + 1), [line]]
|
|
39
|
+
const rest = lines.slice(last + 1)
|
|
40
|
+
const after = rest.length > 0 && rest[0].trim() !== "" ? ["", ...rest] : rest
|
|
41
|
+
return { text: join([...insert.flat(), ...after]), replaced: false }
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
// The `## Lessons` section's bounds in `lines`: { start, end } with `end` the next heading of the same or a higher level, or null.
|
|
45
|
+
function sectionOf(lines) {
|
|
46
|
+
const start = lines.findIndex((entry) => entry.trimEnd() === SECTION)
|
|
47
|
+
if (start === -1) return null
|
|
48
|
+
let end = lines.length
|
|
49
|
+
for (let index = start + 1; index < lines.length; index += 1) {
|
|
50
|
+
if (/^#{1,2} /u.test(lines[index])) {
|
|
51
|
+
end = index
|
|
52
|
+
break
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
return { start, end }
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
const LEAD = /^- \*\*(.+?)\.\*\*(?: |$)/u
|
|
59
|
+
const DATE = /(\d{4}-\d{2}-\d{2})(?!.*\d{4}-\d{2}-\d{2})/u
|
|
60
|
+
|
|
61
|
+
/**
|
|
62
|
+
* The lesson lines of `text`'s `## Lessons` section, in file order, as `{ line, topic, date, order }`: a lesson line starts
|
|
63
|
+
* with the bold lead `lesson_add` writes, `date` is the last YYYY-MM-DD on it (or "" when it has none) and `order` is its
|
|
64
|
+
* place in the section.
|
|
65
|
+
*/
|
|
66
|
+
export function lessonEntries(text) {
|
|
67
|
+
const lines = text.split(/\r?\n/u)
|
|
68
|
+
const section = sectionOf(lines)
|
|
69
|
+
if (section === null) return []
|
|
70
|
+
const found = []
|
|
71
|
+
for (let index = section.start + 1; index < section.end; index += 1) {
|
|
72
|
+
const lead = LEAD.exec(lines[index])
|
|
73
|
+
if (lead) found.push({ line: lines[index], topic: lead[1], date: DATE.exec(lines[index])?.[1] ?? "", order: found.length })
|
|
74
|
+
}
|
|
75
|
+
return found
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
/**
|
|
79
|
+
* `withoutLesson(text, line) -> text`: `text` with the exact `line` taken out of its `## Lessons` section, or `text` itself
|
|
80
|
+
* when the section does not hold it. A blank line left doubled by the removal is folded, and the file keeps its line ending.
|
|
81
|
+
*/
|
|
82
|
+
export function withoutLesson(text, line) {
|
|
83
|
+
const eol = /\r\n/u.test(text) ? "\r\n" : "\n"
|
|
84
|
+
const lines = text.replace(/(?:\r?\n)+$/u, "").split(/\r?\n/u)
|
|
85
|
+
const section = sectionOf(lines)
|
|
86
|
+
if (section === null) return text
|
|
87
|
+
const index = lines.findIndex((entry, at) => at > section.start && at < section.end && entry === line)
|
|
88
|
+
if (index === -1) return text
|
|
89
|
+
lines.splice(index, 1)
|
|
90
|
+
if (index > 0 && index < lines.length && lines[index - 1].trim() === "" && lines[index].trim() === "") lines.splice(index, 1)
|
|
91
|
+
return `${lines.join(eol)}${eol}`
|
|
92
|
+
}
|
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
// The lessons shelf: LESSONS.md beside a person's AGENTS.md (the desk root's on a solo desk), for the lessons that no
|
|
2
|
+
// longer fit in what session start prints.
|
|
3
|
+
//
|
|
4
|
+
// AGENTS.md is always on: every session prints it, up to a byte budget, so a desk that keeps learning outgrows it.
|
|
5
|
+
// lesson_add therefore writes every lesson to the shelf and never appends to AGENTS.md. Every shelved lesson loads: session start lists each shelved topic, task_focus (and
|
|
6
|
+
// task_create with focus) returns the shelved lessons that fit, those that share the most words with the task first, and
|
|
7
|
+
// desk_search finds them. A lesson recorded again under a topic replaces the earlier one.
|
|
8
|
+
|
|
9
|
+
import { readFileSync } from "node:fs"
|
|
10
|
+
import * as path from "node:path"
|
|
11
|
+
import { lessonEntries, withLesson, withoutLesson } from "./lesson-section.js"
|
|
12
|
+
|
|
13
|
+
export const SHELF_FILE = "LESSONS.md"
|
|
14
|
+
/** How many bytes of shelved lessons a focus answer carries. */
|
|
15
|
+
const SHELF_FOCUS_BYTES = 8 * 1024
|
|
16
|
+
/** How many characters of shelved topics session start lists before it says how many more there are. */
|
|
17
|
+
const SHELF_INDEX_CHARS = 1500
|
|
18
|
+
// A shelf is one line per lesson; a file past this is read only this far.
|
|
19
|
+
const SHELF_READ_BYTES = 1024 * 1024
|
|
20
|
+
|
|
21
|
+
export const SHELF_HEADER = [
|
|
22
|
+
"# Shelved lessons",
|
|
23
|
+
"",
|
|
24
|
+
"Lessons that `lesson_add` records, kept out of AGENTS.md so that file stays small. Nothing here is dropped: session start lists every topic, and `task_focus` returns the lessons that fit for the task you focus (those closest to it first). Recording a lesson again under its topic replaces it.",
|
|
25
|
+
"",
|
|
26
|
+
].join("\n")
|
|
27
|
+
|
|
28
|
+
const oldestFirst = (a, b) => a.date.localeCompare(b.date) || a.order - b.order
|
|
29
|
+
|
|
30
|
+
/**
|
|
31
|
+
* `shelve({ agents, shelf, line, topic }) -> { agents, shelf, replaced }`: AGENTS.md and LESSONS.md texts with the lesson
|
|
32
|
+
* `line` for `topic` recorded on the shelf. A lesson never goes into AGENTS.md, which every session prints in full and
|
|
33
|
+
* which a write from a stale copy could regrow. A line already under `topic` in AGENTS.md (an older Desk wrote there)
|
|
34
|
+
* leaves it, so the newest word on the topic is the only one loaded.
|
|
35
|
+
*/
|
|
36
|
+
export function shelve({ agents, shelf, line, topic }) {
|
|
37
|
+
const old = lessonEntries(agents).find((entry) => entry.topic === topic)
|
|
38
|
+
const base = shelf.trim() === "" ? SHELF_HEADER : shelf
|
|
39
|
+
const recorded = withLesson(base, line, topic)
|
|
40
|
+
return { agents: old === undefined ? agents : withoutLesson(agents, old.line), shelf: recorded.text, replaced: recorded.replaced || old !== undefined }
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
/** The shelf in `dir` as `{ path, entries }` (entries as `lessonEntries` gives them), or null when it holds no lesson. */
|
|
44
|
+
export function readShelf(dir) {
|
|
45
|
+
const file = path.join(dir, SHELF_FILE)
|
|
46
|
+
let text
|
|
47
|
+
try {
|
|
48
|
+
text = readFileSync(file).subarray(0, SHELF_READ_BYTES).toString("utf8")
|
|
49
|
+
} catch {
|
|
50
|
+
return null
|
|
51
|
+
}
|
|
52
|
+
const entries = lessonEntries(text)
|
|
53
|
+
return entries.length === 0 ? null : { path: file, entries }
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
/** What session start prints for a shelf: `{ path, count, topics }`, or null when there is none. */
|
|
57
|
+
export function shelfIndex(dir) {
|
|
58
|
+
const shelf = readShelf(dir)
|
|
59
|
+
return shelf === null ? null : { path: shelf.path, count: shelf.entries.length, topics: shelf.entries.map((entry) => entry.topic) }
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
/** The topics as one line within `max` characters, naming how many more there are when they do not all fit. */
|
|
63
|
+
export function topicList(topics, max = SHELF_INDEX_CHARS) {
|
|
64
|
+
const shown = []
|
|
65
|
+
let used = 0
|
|
66
|
+
for (const topic of topics) {
|
|
67
|
+
if (used + topic.length + 2 > max) break
|
|
68
|
+
shown.push(topic)
|
|
69
|
+
used += topic.length + 2
|
|
70
|
+
}
|
|
71
|
+
const more = topics.length - shown.length
|
|
72
|
+
return `${shown.join("; ")}${more > 0 ? `${shown.length > 0 ? "; " : ""}and ${more} more` : ""}`
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
const STOP = new Set(["about", "after", "agent", "before", "desk", "every", "from", "have", "into", "lesson", "lessons", "never", "only", "that", "their", "them", "then", "they", "this", "what", "when", "where", "which", "with", "work", "your"])
|
|
76
|
+
const words = (text) => new Set((String(text).toLowerCase().match(/[\p{L}\p{N}]{4,}/gu) ?? []).filter((word) => !STOP.has(word)))
|
|
77
|
+
|
|
78
|
+
/**
|
|
79
|
+
* `shelfForTask(entries, task, cap) -> { shown, not_shown }`: the shelved lesson lines to hand a session focusing `task`
|
|
80
|
+
* (any text about it: track, slug, title, next step), within `cap` bytes. Lessons sharing more words with the task come
|
|
81
|
+
* first, then the newest; a lesson that does not fit is skipped for a shorter one, and `not_shown` counts the rest.
|
|
82
|
+
*/
|
|
83
|
+
export function shelfForTask(entries, task, cap = SHELF_FOCUS_BYTES) {
|
|
84
|
+
const wanted = words(task)
|
|
85
|
+
const score = (entry) => {
|
|
86
|
+
let shared = 0
|
|
87
|
+
for (const word of words(entry.line)) if (wanted.has(word)) shared += 1
|
|
88
|
+
return shared
|
|
89
|
+
}
|
|
90
|
+
const ranked = entries.map((entry) => ({ entry, score: score(entry) })).sort((a, b) => b.score - a.score || oldestFirst(b.entry, a.entry))
|
|
91
|
+
const shown = []
|
|
92
|
+
let used = 0
|
|
93
|
+
for (const { entry } of ranked) {
|
|
94
|
+
const size = Buffer.byteLength(entry.line, "utf8") + 1
|
|
95
|
+
if (used + size > cap) continue
|
|
96
|
+
shown.push(entry.line)
|
|
97
|
+
used += size
|
|
98
|
+
}
|
|
99
|
+
return { shown, not_shown: entries.length - shown.length }
|
|
100
|
+
}
|