@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.
Files changed (567) hide show
  1. package/README.md +1 -1
  2. package/changelog.json +6 -2
  3. package/deploy/unraid/sanctuary.ouro/bundle-meta.json +1 -1
  4. package/deploy/unraid/sanctuary.xml +1 -1
  5. package/desk.lock.json +8 -0
  6. package/dist/heart/identity.js +27 -1
  7. package/dist/mind/desk-section.js +33 -43
  8. package/dist/repertoire/desk-mcp.js +140 -0
  9. package/dist/repertoire/mcp-manager.js +22 -0
  10. package/dist/repertoire/mcp-tools.js +11 -7
  11. package/npm-shrinkwrap.json +2 -2
  12. package/package.json +4 -1
  13. package/vendor/desk/.claude-plugin/plugin.json +35 -0
  14. package/vendor/desk/.mcp.claude-codex.json +28 -0
  15. package/vendor/desk/.mcp.copilot.json +16 -0
  16. package/vendor/desk/.ouro-desk.json +6 -0
  17. package/vendor/desk/CHANGELOG.md +7004 -0
  18. package/vendor/desk/README.md +195 -0
  19. package/vendor/desk/activation/README.md +98 -0
  20. package/vendor/desk/activation/copilot-root.flattened-bundle.json +38 -0
  21. package/vendor/desk/activation/desk.activation.json +251 -0
  22. package/vendor/desk/activation/host-capability-evidence.md +46 -0
  23. package/vendor/desk/activation/support-matrix.json +84 -0
  24. package/vendor/desk/agency.json +20 -0
  25. package/vendor/desk/agents/observer.agent.md +26 -0
  26. package/vendor/desk/agents/observer.md +29 -0
  27. package/vendor/desk/agents/worker.agent.md +32 -0
  28. package/vendor/desk/agents/worker.md +40 -0
  29. package/vendor/desk/artifacts/tombstones/tombstone.schema.json +53 -0
  30. package/vendor/desk/artifacts/tombstones/tombstones.jsonl +1 -0
  31. package/vendor/desk/changelog.d/README.md +12 -0
  32. package/vendor/desk/docs/agent-files.md +104 -0
  33. package/vendor/desk/docs/agentic-engineering-v2-rfc.md +206 -0
  34. package/vendor/desk/docs/agentic-engineering-v3-rfc.md +109 -0
  35. package/vendor/desk/docs/browser-remote-desktops.md +69 -0
  36. package/vendor/desk/docs/dependency-activation-stories-and-criteria.md +500 -0
  37. package/vendor/desk/docs/evaluation-packet.md +363 -0
  38. package/vendor/desk/docs/factory-local-capture.md +651 -0
  39. package/vendor/desk/docs/factory-store-playbook.md +927 -0
  40. package/vendor/desk/docs/images/factory-site.png +0 -0
  41. package/vendor/desk/docs/issue-drains.md +79 -0
  42. package/vendor/desk/docs/lfs-inspection.md +55 -0
  43. package/vendor/desk/docs/preview-diagnostics.md +11 -0
  44. package/vendor/desk/docs/relays.md +88 -0
  45. package/vendor/desk/docs/schedules.md +69 -0
  46. package/vendor/desk/docs/search-recovery.md +22 -0
  47. package/vendor/desk/docs/session-labels.md +157 -0
  48. package/vendor/desk/docs/session-retention.md +125 -0
  49. package/vendor/desk/docs/sessions.md +17 -0
  50. package/vendor/desk/docs/stalled-nudges.md +54 -0
  51. package/vendor/desk/docs/webhooks.md +80 -0
  52. package/vendor/desk/docs/workspace-tidy.md +74 -0
  53. package/vendor/desk/hooks/boot-checks.cjs +7 -0
  54. package/vendor/desk/hooks/claude-session-start.cjs +123 -0
  55. package/vendor/desk/hooks/compatible-node.cjs +97 -0
  56. package/vendor/desk/hooks/copilot-boot-prompt.cjs +69 -0
  57. package/vendor/desk/hooks/copilot-durable-files.cjs +8 -0
  58. package/vendor/desk/hooks/copilot-hooks.json +61 -0
  59. package/vendor/desk/hooks/copilot-intake-context.cjs +5 -0
  60. package/vendor/desk/hooks/copilot-lane-model.cjs +8 -0
  61. package/vendor/desk/hooks/copilot-session-start.cjs +264 -0
  62. package/vendor/desk/hooks/copilot-skill-current.cjs +28 -0
  63. package/vendor/desk/hooks/factory-end.cjs +5 -0
  64. package/vendor/desk/hooks/factory-start.cjs +27 -0
  65. package/vendor/desk/hooks/hooks.json +40 -0
  66. package/vendor/desk/hooks/lib/boot-checks.cjs +643 -0
  67. package/vendor/desk/hooks/lib/child-agent.cjs +14 -0
  68. package/vendor/desk/hooks/lib/copilot-intake-context.cjs +73 -0
  69. package/vendor/desk/hooks/lib/current-release.cjs +162 -0
  70. package/vendor/desk/hooks/lib/delivery-stop.cjs +326 -0
  71. package/vendor/desk/hooks/lib/detach-worker.cjs +43 -0
  72. package/vendor/desk/hooks/lib/durable-files.cjs +102 -0
  73. package/vendor/desk/hooks/lib/factory-end.cjs +327 -0
  74. package/vendor/desk/hooks/lib/lane-model.cjs +82 -0
  75. package/vendor/desk/hooks/lib/node-required.cjs +56 -0
  76. package/vendor/desk/hooks/lib/orca-session-title.cjs +60 -0
  77. package/vendor/desk/hooks/lib/session-end.cjs +30 -0
  78. package/vendor/desk/hooks/lib/sync-end.cjs +89 -0
  79. package/vendor/desk/hooks/loop-start.cjs +105 -0
  80. package/vendor/desk/hooks/node-missing.sh +78 -0
  81. package/vendor/desk/hooks/orca-session-title.cjs +8 -0
  82. package/vendor/desk/hooks/session-end.cjs +8 -0
  83. package/vendor/desk/mcp/README.md +269 -0
  84. package/vendor/desk/mcp/artifacts/runtime-deps/1.4.0-alpha.6/darwin-arm64-node-127/3b0cb8b1e7dd77a982b38375fe88a5278bd77974213e18be025d7dc8deea800f/runtime-deps.manifest.json +881 -0
  85. package/vendor/desk/mcp/artifacts/runtime-deps/1.4.0-alpha.6/darwin-arm64-node-127/3b0cb8b1e7dd77a982b38375fe88a5278bd77974213e18be025d7dc8deea800f/runtime-deps.sha256 +1 -0
  86. package/vendor/desk/mcp/artifacts/runtime-deps/1.4.0-alpha.6/darwin-arm64-node-127/3b0cb8b1e7dd77a982b38375fe88a5278bd77974213e18be025d7dc8deea800f/runtime-deps.tgz +0 -0
  87. package/vendor/desk/mcp/artifacts/runtime-deps/1.4.0-alpha.6/darwin-arm64-node-137/3b0cb8b1e7dd77a982b38375fe88a5278bd77974213e18be025d7dc8deea800f/runtime-deps.manifest.json +881 -0
  88. package/vendor/desk/mcp/artifacts/runtime-deps/1.4.0-alpha.6/darwin-arm64-node-137/3b0cb8b1e7dd77a982b38375fe88a5278bd77974213e18be025d7dc8deea800f/runtime-deps.sha256 +1 -0
  89. package/vendor/desk/mcp/artifacts/runtime-deps/1.4.0-alpha.6/darwin-arm64-node-137/3b0cb8b1e7dd77a982b38375fe88a5278bd77974213e18be025d7dc8deea800f/runtime-deps.tgz +0 -0
  90. package/vendor/desk/mcp/artifacts/runtime-deps/1.4.0-alpha.6/linux-x64-node-127/3b0cb8b1e7dd77a982b38375fe88a5278bd77974213e18be025d7dc8deea800f/runtime-deps.manifest.json +881 -0
  91. package/vendor/desk/mcp/artifacts/runtime-deps/1.4.0-alpha.6/linux-x64-node-127/3b0cb8b1e7dd77a982b38375fe88a5278bd77974213e18be025d7dc8deea800f/runtime-deps.sha256 +1 -0
  92. package/vendor/desk/mcp/artifacts/runtime-deps/1.4.0-alpha.6/linux-x64-node-127/3b0cb8b1e7dd77a982b38375fe88a5278bd77974213e18be025d7dc8deea800f/runtime-deps.tgz +0 -0
  93. package/vendor/desk/mcp/artifacts/runtime-deps/1.4.0-alpha.6/linux-x64-node-137/3b0cb8b1e7dd77a982b38375fe88a5278bd77974213e18be025d7dc8deea800f/runtime-deps.manifest.json +881 -0
  94. package/vendor/desk/mcp/artifacts/runtime-deps/1.4.0-alpha.6/linux-x64-node-137/3b0cb8b1e7dd77a982b38375fe88a5278bd77974213e18be025d7dc8deea800f/runtime-deps.sha256 +1 -0
  95. package/vendor/desk/mcp/artifacts/runtime-deps/1.4.0-alpha.6/linux-x64-node-137/3b0cb8b1e7dd77a982b38375fe88a5278bd77974213e18be025d7dc8deea800f/runtime-deps.tgz +0 -0
  96. package/vendor/desk/mcp/artifacts/runtime-deps/1.4.0-alpha.6/linux-x64-node-147/3b0cb8b1e7dd77a982b38375fe88a5278bd77974213e18be025d7dc8deea800f/runtime-deps.manifest.json +881 -0
  97. package/vendor/desk/mcp/artifacts/runtime-deps/1.4.0-alpha.6/linux-x64-node-147/3b0cb8b1e7dd77a982b38375fe88a5278bd77974213e18be025d7dc8deea800f/runtime-deps.sha256 +1 -0
  98. package/vendor/desk/mcp/artifacts/runtime-deps/1.4.0-alpha.6/linux-x64-node-147/3b0cb8b1e7dd77a982b38375fe88a5278bd77974213e18be025d7dc8deea800f/runtime-deps.tgz +0 -0
  99. package/vendor/desk/mcp/artifacts/runtime-deps/1.4.0-alpha.6/support-matrix.json +72 -0
  100. package/vendor/desk/mcp/artifacts/runtime-deps/1.4.0-alpha.6/win32-x64-node-137/3b0cb8b1e7dd77a982b38375fe88a5278bd77974213e18be025d7dc8deea800f/runtime-deps.manifest.json +881 -0
  101. package/vendor/desk/mcp/artifacts/runtime-deps/1.4.0-alpha.6/win32-x64-node-137/3b0cb8b1e7dd77a982b38375fe88a5278bd77974213e18be025d7dc8deea800f/runtime-deps.sha256 +1 -0
  102. package/vendor/desk/mcp/artifacts/runtime-deps/1.4.0-alpha.6/win32-x64-node-137/3b0cb8b1e7dd77a982b38375fe88a5278bd77974213e18be025d7dc8deea800f/runtime-deps.tgz +0 -0
  103. package/vendor/desk/mcp/artifacts/runtime-deps/1.4.0-alpha.6/win32-x64-node-147/3b0cb8b1e7dd77a982b38375fe88a5278bd77974213e18be025d7dc8deea800f/runtime-deps.manifest.json +881 -0
  104. package/vendor/desk/mcp/artifacts/runtime-deps/1.4.0-alpha.6/win32-x64-node-147/3b0cb8b1e7dd77a982b38375fe88a5278bd77974213e18be025d7dc8deea800f/runtime-deps.sha256 +1 -0
  105. package/vendor/desk/mcp/artifacts/runtime-deps/1.4.0-alpha.6/win32-x64-node-147/3b0cb8b1e7dd77a982b38375fe88a5278bd77974213e18be025d7dc8deea800f/runtime-deps.tgz +0 -0
  106. package/vendor/desk/mcp/artifacts/runtime-deps/README.md +25 -0
  107. package/vendor/desk/mcp/bootstrap.cjs +761 -0
  108. package/vendor/desk/mcp/docs/private-feedback.md +13 -0
  109. package/vendor/desk/mcp/idle-proxy.cjs +423 -0
  110. package/vendor/desk/mcp/index.js +813 -0
  111. package/vendor/desk/mcp/package-lock.json +3717 -0
  112. package/vendor/desk/mcp/package.json +44 -0
  113. package/vendor/desk/mcp/scripts/agency-desk-channel.js +7 -0
  114. package/vendor/desk/mcp/scripts/build-runtime-deps-pack.js +5 -0
  115. package/vendor/desk/mcp/scripts/crew.js +89 -0
  116. package/vendor/desk/mcp/scripts/drains-launcher.mjs +329 -0
  117. package/vendor/desk/mcp/scripts/drains.js +5 -0
  118. package/vendor/desk/mcp/scripts/factory.js +657 -0
  119. package/vendor/desk/mcp/scripts/file-desk-problem.js +9 -0
  120. package/vendor/desk/mcp/scripts/finish-commit.js +7 -0
  121. package/vendor/desk/mcp/scripts/lfs.js +37 -0
  122. package/vendor/desk/mcp/scripts/local-recovery.js +363 -0
  123. package/vendor/desk/mcp/scripts/migrations.js +11 -0
  124. package/vendor/desk/mcp/scripts/private-view.js +177 -0
  125. package/vendor/desk/mcp/scripts/resolve-desk-root.js +106 -0
  126. package/vendor/desk/mcp/scripts/session-boot.js +22 -0
  127. package/vendor/desk/mcp/scripts/session-retention.js +5 -0
  128. package/vendor/desk/mcp/scripts/session-sync.js +10 -0
  129. package/vendor/desk/mcp/scripts/sessions.js +5 -0
  130. package/vendor/desk/mcp/scripts/sync-push.js +13 -0
  131. package/vendor/desk/mcp/scripts/tidy-status.js +8 -0
  132. package/vendor/desk/mcp/scripts/verify-runtime-deps-pack.js +5 -0
  133. package/vendor/desk/mcp/src/actions/desk-read.actions.mts +73 -0
  134. package/vendor/desk/mcp/src/actions/desk-session.actions.mts +42 -0
  135. package/vendor/desk/mcp/src/actions/desk-web.actions.mts +52 -0
  136. package/vendor/desk/mcp/src/actions/desk.actions.mts +5 -0
  137. package/vendor/desk/mcp/src/actions/generated/desk/OuroActions.swift +649 -0
  138. package/vendor/desk/mcp/src/actions/generated/desk/OuroActionsReins.swift +61 -0
  139. package/vendor/desk/mcp/src/actions/generated/desk/actions.json +280 -0
  140. package/vendor/desk/mcp/src/actions/generated/desk/commands.json +145 -0
  141. package/vendor/desk/mcp/src/actions/generated/desk/mcp.json +256 -0
  142. package/vendor/desk/mcp/src/actions/generated/desk/web.ts +59 -0
  143. package/vendor/desk/mcp/src/actions/generated/desk/webmcp.json +250 -0
  144. package/vendor/desk/mcp/src/actions/generated/desk-web/OuroActions.swift +241 -0
  145. package/vendor/desk/mcp/src/actions/generated/desk-web/OuroActionsReins.swift +25 -0
  146. package/vendor/desk/mcp/src/actions/generated/desk-web/actions.json +73 -0
  147. package/vendor/desk/mcp/src/actions/generated/desk-web/commands.json +53 -0
  148. package/vendor/desk/mcp/src/actions/generated/desk-web/mcp.json +83 -0
  149. package/vendor/desk/mcp/src/actions/generated/desk-web/web.ts +47 -0
  150. package/vendor/desk/mcp/src/actions/generated/desk-web/webmcp.json +81 -0
  151. package/vendor/desk/mcp/src/actions/served.js +5 -0
  152. package/vendor/desk/mcp/src/activation/admit.js +77 -0
  153. package/vendor/desk/mcp/src/activation/failures.js +65 -0
  154. package/vendor/desk/mcp/src/activation/readiness-policy.js +102 -0
  155. package/vendor/desk/mcp/src/activation/schema.js +17 -0
  156. package/vendor/desk/mcp/src/activation/superpowers-context.js +265 -0
  157. package/vendor/desk/mcp/src/activation/validate.js +540 -0
  158. package/vendor/desk/mcp/src/artifacts/tombstones.js +61 -0
  159. package/vendor/desk/mcp/src/crew/initiative.js +287 -0
  160. package/vendor/desk/mcp/src/crew/workspace.js +1259 -0
  161. package/vendor/desk/mcp/src/db/init.js +75 -0
  162. package/vendor/desk/mcp/src/db/schema.sql +83 -0
  163. package/vendor/desk/mcp/src/desk/active-tasks.js +408 -0
  164. package/vendor/desk/mcp/src/desk/card-commit-guard.js +281 -0
  165. package/vendor/desk/mcp/src/desk/cleanup-index.js +53 -0
  166. package/vendor/desk/mcp/src/desk/content-home.js +246 -0
  167. package/vendor/desk/mcp/src/desk/crew-config.js +102 -0
  168. package/vendor/desk/mcp/src/desk/crew-member.js +196 -0
  169. package/vendor/desk/mcp/src/desk/crew-roster.js +151 -0
  170. package/vendor/desk/mcp/src/desk/frontmatter-lite.js +228 -0
  171. package/vendor/desk/mcp/src/desk/gh-logins.js +109 -0
  172. package/vendor/desk/mcp/src/desk/handles.js +123 -0
  173. package/vendor/desk/mcp/src/desk/handoff-reference.js +35 -0
  174. package/vendor/desk/mcp/src/desk/improvement-authority.js +3 -0
  175. package/vendor/desk/mcp/src/desk/improvement-cards.js +704 -0
  176. package/vendor/desk/mcp/src/desk/improvement-person.js +51 -0
  177. package/vendor/desk/mcp/src/desk/lifecycle.js +16 -0
  178. package/vendor/desk/mcp/src/desk/machine-desks.js +119 -0
  179. package/vendor/desk/mcp/src/desk/naming.js +333 -0
  180. package/vendor/desk/mcp/src/desk/organization.js +592 -0
  181. package/vendor/desk/mcp/src/desk/resources.js +274 -0
  182. package/vendor/desk/mcp/src/desk/runtime-resolver.js +30 -0
  183. package/vendor/desk/mcp/src/desk/scratch-paths.js +44 -0
  184. package/vendor/desk/mcp/src/desk/step-delivery.js +140 -0
  185. package/vendor/desk/mcp/src/desk/steps.js +263 -0
  186. package/vendor/desk/mcp/src/desk/tidy.js +930 -0
  187. package/vendor/desk/mcp/src/desk/unsigned-deliveries.js +359 -0
  188. package/vendor/desk/mcp/src/factory/agent-types.js +45 -0
  189. package/vendor/desk/mcp/src/factory/andon-watch.js +109 -0
  190. package/vendor/desk/mcp/src/factory/binding.js +612 -0
  191. package/vendor/desk/mcp/src/factory/boot-check.js +645 -0
  192. package/vendor/desk/mcp/src/factory/capture-classify.js +158 -0
  193. package/vendor/desk/mcp/src/factory/capture-count.js +183 -0
  194. package/vendor/desk/mcp/src/factory/capture-flush.js +268 -0
  195. package/vendor/desk/mcp/src/factory/capture-publish.js +141 -0
  196. package/vendor/desk/mcp/src/factory/capture-schema.js +193 -0
  197. package/vendor/desk/mcp/src/factory/capture-sweep.js +239 -0
  198. package/vendor/desk/mcp/src/factory/catch-point.js +60 -0
  199. package/vendor/desk/mcp/src/factory/commit-resolve.js +94 -0
  200. package/vendor/desk/mcp/src/factory/consent-answer.js +37 -0
  201. package/vendor/desk/mcp/src/factory/context-capability.js +15 -0
  202. package/vendor/desk/mcp/src/factory/context-outbox.js +885 -0
  203. package/vendor/desk/mcp/src/factory/context-run.js +386 -0
  204. package/vendor/desk/mcp/src/factory/context-schema.js +249 -0
  205. package/vendor/desk/mcp/src/factory/copilot-turn-index.js +93 -0
  206. package/vendor/desk/mcp/src/factory/copilot-usage.js +148 -0
  207. package/vendor/desk/mcp/src/factory/credential.js +45 -0
  208. package/vendor/desk/mcp/src/factory/derive-claude.js +960 -0
  209. package/vendor/desk/mcp/src/factory/derive-codex.js +734 -0
  210. package/vendor/desk/mcp/src/factory/derive-common.js +279 -0
  211. package/vendor/desk/mcp/src/factory/derive-copilot.js +1057 -0
  212. package/vendor/desk/mcp/src/factory/derive-run.js +807 -0
  213. package/vendor/desk/mcp/src/factory/desk-problem-file.js +310 -0
  214. package/vendor/desk/mcp/src/factory/desk-problem-fingerprint.js +70 -0
  215. package/vendor/desk/mcp/src/factory/desk-problem-known.js +246 -0
  216. package/vendor/desk/mcp/src/factory/desk-problem-template.js +107 -0
  217. package/vendor/desk/mcp/src/factory/desk-repo.js +1223 -0
  218. package/vendor/desk/mcp/src/factory/desk-task-line.js +28 -0
  219. package/vendor/desk/mcp/src/factory/desk-visibility.js +48 -0
  220. package/vendor/desk/mcp/src/factory/end-hook.js +14 -0
  221. package/vendor/desk/mcp/src/factory/evaluate-kick.js +164 -0
  222. package/vendor/desk/mcp/src/factory/evaluate-run.js +678 -0
  223. package/vendor/desk/mcp/src/factory/evaluator-step.js +484 -0
  224. package/vendor/desk/mcp/src/factory/filer-launch.js +79 -0
  225. package/vendor/desk/mcp/src/factory/flush-health.js +26 -0
  226. package/vendor/desk/mcp/src/factory/flush.js +1758 -0
  227. package/vendor/desk/mcp/src/factory/focus.js +326 -0
  228. package/vendor/desk/mcp/src/factory/headless-flag.cjs +32 -0
  229. package/vendor/desk/mcp/src/factory/headless-flag.js +25 -0
  230. package/vendor/desk/mcp/src/factory/headless-ledger.js +743 -0
  231. package/vendor/desk/mcp/src/factory/headless.js +567 -0
  232. package/vendor/desk/mcp/src/factory/held-route.js +93 -0
  233. package/vendor/desk/mcp/src/factory/host-flags.js +36 -0
  234. package/vendor/desk/mcp/src/factory/improvement-verify.js +429 -0
  235. package/vendor/desk/mcp/src/factory/kaizen-file.js +231 -0
  236. package/vendor/desk/mcp/src/factory/label-binding.js +90 -0
  237. package/vendor/desk/mcp/src/factory/label-schema.js +426 -0
  238. package/vendor/desk/mcp/src/factory/local-status.js +368 -0
  239. package/vendor/desk/mcp/src/factory/loop-conditions.js +121 -0
  240. package/vendor/desk/mcp/src/factory/loop-health.js +500 -0
  241. package/vendor/desk/mcp/src/factory/loop-slot.js +90 -0
  242. package/vendor/desk/mcp/src/factory/loop-status.js +100 -0
  243. package/vendor/desk/mcp/src/factory/loop-switch.cjs +14 -0
  244. package/vendor/desk/mcp/src/factory/loop-worker-state.js +96 -0
  245. package/vendor/desk/mcp/src/factory/loop-worker.js +290 -0
  246. package/vendor/desk/mcp/src/factory/marker.js +61 -0
  247. package/vendor/desk/mcp/src/factory/mirror-step.js +145 -0
  248. package/vendor/desk/mcp/src/factory/os-protect.js +243 -0
  249. package/vendor/desk/mcp/src/factory/outbox.js +2231 -0
  250. package/vendor/desk/mcp/src/factory/outcome.js +431 -0
  251. package/vendor/desk/mcp/src/factory/pipeline/andon.js +319 -0
  252. package/vendor/desk/mcp/src/factory/pipeline/attention-rollup.js +158 -0
  253. package/vendor/desk/mcp/src/factory/pipeline/attention.js +146 -0
  254. package/vendor/desk/mcp/src/factory/pipeline/build.js +299 -0
  255. package/vendor/desk/mcp/src/factory/pipeline/compare.js +148 -0
  256. package/vendor/desk/mcp/src/factory/pipeline/formulas.js +652 -0
  257. package/vendor/desk/mcp/src/factory/pipeline/kaizen.js +387 -0
  258. package/vendor/desk/mcp/src/factory/pipeline/lifecycle-clocks.js +345 -0
  259. package/vendor/desk/mcp/src/factory/pipeline/normalize.js +73 -0
  260. package/vendor/desk/mcp/src/factory/pipeline/number-states.js +154 -0
  261. package/vendor/desk/mcp/src/factory/pipeline/outcomes.js +268 -0
  262. package/vendor/desk/mcp/src/factory/pipeline/report.js +737 -0
  263. package/vendor/desk/mcp/src/factory/pipeline/rollups.js +883 -0
  264. package/vendor/desk/mcp/src/factory/pipeline/stretches.js +523 -0
  265. package/vendor/desk/mcp/src/factory/pipeline/timeline.js +199 -0
  266. package/vendor/desk/mcp/src/factory/pipeline/validate-pr.js +238 -0
  267. package/vendor/desk/mcp/src/factory/pipeline/versions.js +42 -0
  268. package/vendor/desk/mcp/src/factory/pipeline/walk.js +1177 -0
  269. package/vendor/desk/mcp/src/factory/plugin-registry.js +72 -0
  270. package/vendor/desk/mcp/src/factory/plugin-sources.cjs +249 -0
  271. package/vendor/desk/mcp/src/factory/pr-green.js +77 -0
  272. package/vendor/desk/mcp/src/factory/process-lock.js +142 -0
  273. package/vendor/desk/mcp/src/factory/proof-session.js +75 -0
  274. package/vendor/desk/mcp/src/factory/publish.js +637 -0
  275. package/vendor/desk/mcp/src/factory/published-schema.js +648 -0
  276. package/vendor/desk/mcp/src/factory/reconcile-reasons.js +22 -0
  277. package/vendor/desk/mcp/src/factory/reconcile-step.js +251 -0
  278. package/vendor/desk/mcp/src/factory/reconcile.js +808 -0
  279. package/vendor/desk/mcp/src/factory/release-version.js +134 -0
  280. package/vendor/desk/mcp/src/factory/repo-name.js +13 -0
  281. package/vendor/desk/mcp/src/factory/retention.js +60 -0
  282. package/vendor/desk/mcp/src/factory/route-desk.js +40 -0
  283. package/vendor/desk/mcp/src/factory/route-issues.js +251 -0
  284. package/vendor/desk/mcp/src/factory/route-local.js +264 -0
  285. package/vendor/desk/mcp/src/factory/schema.js +957 -0
  286. package/vendor/desk/mcp/src/factory/session-kind.js +16 -0
  287. package/vendor/desk/mcp/src/factory/session-lifetime.js +56 -0
  288. package/vendor/desk/mcp/src/factory/session-route.js +183 -0
  289. package/vendor/desk/mcp/src/factory/shell-git.js +500 -0
  290. package/vendor/desk/mcp/src/factory/store-issues.js +143 -0
  291. package/vendor/desk/mcp/src/factory/store-route.js +208 -0
  292. package/vendor/desk/mcp/src/factory/test-state-guard.js +103 -0
  293. package/vendor/desk/mcp/src/factory/time.js +36 -0
  294. package/vendor/desk/mcp/src/factory/tool-issue-file.js +84 -0
  295. package/vendor/desk/mcp/src/factory/tool-kinds.js +87 -0
  296. package/vendor/desk/mcp/src/factory/triage-schema.js +233 -0
  297. package/vendor/desk/mcp/src/factory/windows-acl.js +679 -0
  298. package/vendor/desk/mcp/src/indexer/chunk.js +232 -0
  299. package/vendor/desk/mcp/src/indexer/discover.js +434 -0
  300. package/vendor/desk/mcp/src/indexer/exclusions.js +247 -0
  301. package/vendor/desk/mcp/src/indexer/index.js +167 -0
  302. package/vendor/desk/mcp/src/indexer/refs.js +0 -0
  303. package/vendor/desk/mcp/src/indexer/text-hash.js +18 -0
  304. package/vendor/desk/mcp/src/lib/ouro-actions/actions.claims.json +75 -0
  305. package/vendor/desk/mcp/src/lib/ouro-actions/dist-manifest.json +70 -0
  306. package/vendor/desk/mcp/src/lib/ouro-actions/ouro-actions.mts +1416 -0
  307. package/vendor/desk/mcp/src/lib/ouro-ui/LICENSE +21 -0
  308. package/vendor/desk/mcp/src/lib/ouro-ui/registry/ouro/ax/ax-claims.ts +190 -0
  309. package/vendor/desk/mcp/src/lib/ouro-ui/registry/ouro/ax/ax-command.ts +1020 -0
  310. package/vendor/desk/mcp/src/lib/ouro-ui/registry/ouro/ax/checks.ts +343 -0
  311. package/vendor/desk/mcp/src/lib/ouro-ui/registry/ouro/ax/cli.ts +240 -0
  312. package/vendor/desk/mcp/src/lib/ouro-ui/registry/ouro/ax/component.ts +430 -0
  313. package/vendor/desk/mcp/src/lib/ouro-ui/registry/ouro/ax/dev-commands.ts +204 -0
  314. package/vendor/desk/mcp/src/lib/ouro-ui/registry/ouro/ax/doctor.ts +126 -0
  315. package/vendor/desk/mcp/src/lib/ouro-ui/registry/ouro/ax/effects.ts +68 -0
  316. package/vendor/desk/mcp/src/lib/ouro-ui/registry/ouro/ax/exit-codes.ts +75 -0
  317. package/vendor/desk/mcp/src/lib/ouro-ui/registry/ouro/ax/help.ts +220 -0
  318. package/vendor/desk/mcp/src/lib/ouro-ui/registry/ouro/ax/mcp.ts +268 -0
  319. package/vendor/desk/mcp/src/lib/ouro-ui/registry/ouro/ax/outcome.ts +265 -0
  320. package/vendor/desk/mcp/src/lib/ouro-ui/registry/ouro/ax/output.ts +67 -0
  321. package/vendor/desk/mcp/src/lib/ouro-ui/registry/ouro/ax/precise-copy.ts +235 -0
  322. package/vendor/desk/mcp/src/lib/ouro-ui/registry/ouro/ax/problem.ts +124 -0
  323. package/vendor/desk/mcp/src/lib/ouro-ui/registry/ouro/ax/surfaces.kit.mts +8 -0
  324. package/vendor/desk/mcp/src/lib/ouro-ui/registry/ouro/ax/surfaces.ts +568 -0
  325. package/vendor/desk/mcp/src/lib/ouro-ui/registry/ouro/ax/terminal.ts +245 -0
  326. package/vendor/desk/mcp/src/lib/ouro-ui/registry/ouro/ax/voice.ts +136 -0
  327. package/vendor/desk/mcp/src/lib/ouro-ui/registry/ouro/ax/wait.ts +226 -0
  328. package/vendor/desk/mcp/src/lib/ouro-ui/registry/ouro/ax/work-event.ts +181 -0
  329. package/vendor/desk/mcp/src/lib/ouro-ui/registry/ouro/ax/xray.kit.mts +18 -0
  330. package/vendor/desk/mcp/src/lib/ouro-ui/registry/ouro/ax/xray.ts +2072 -0
  331. package/vendor/desk/mcp/src/package-metadata.js +20 -0
  332. package/vendor/desk/mcp/src/protected/legacy-ledger.js +55 -0
  333. package/vendor/desk/mcp/src/readiness/leftovers.js +75 -0
  334. package/vendor/desk/mcp/src/readiness/process-start.js +149 -0
  335. package/vendor/desk/mcp/src/runtime/admission-worker.js +194 -0
  336. package/vendor/desk/mcp/src/runtime/admission.js +177 -0
  337. package/vendor/desk/mcp/src/runtime/agency-desk-channel.js +342 -0
  338. package/vendor/desk/mcp/src/runtime/agents-md.js +62 -0
  339. package/vendor/desk/mcp/src/runtime/append-lane.js +68 -0
  340. package/vendor/desk/mcp/src/runtime/argv-safe-reason.js +55 -0
  341. package/vendor/desk/mcp/src/runtime/boot-dependencies.js +75 -0
  342. package/vendor/desk/mcp/src/runtime/boot-text.js +504 -0
  343. package/vendor/desk/mcp/src/runtime/boot.js +1677 -0
  344. package/vendor/desk/mcp/src/runtime/bootstrap.js +1455 -0
  345. package/vendor/desk/mcp/src/runtime/chunked-import.js +102 -0
  346. package/vendor/desk/mcp/src/runtime/copilot-commit-trailer.js +133 -0
  347. package/vendor/desk/mcp/src/runtime/copilot-session.js +155 -0
  348. package/vendor/desk/mcp/src/runtime/deliver.js +469 -0
  349. package/vendor/desk/mcp/src/runtime/desk-channel.js +86 -0
  350. package/vendor/desk/mcp/src/runtime/desk-failure.js +26 -0
  351. package/vendor/desk/mcp/src/runtime/desk-health.js +168 -0
  352. package/vendor/desk/mcp/src/runtime/desk-session.js +1451 -0
  353. package/vendor/desk/mcp/src/runtime/diagnostic-server.js +72 -0
  354. package/vendor/desk/mcp/src/runtime/diagnostics.js +241 -0
  355. package/vendor/desk/mcp/src/runtime/drains-cli.js +187 -0
  356. package/vendor/desk/mcp/src/runtime/drains.js +781 -0
  357. package/vendor/desk/mcp/src/runtime/elsewhere-note.js +9 -0
  358. package/vendor/desk/mcp/src/runtime/failure-evidence.js +21 -0
  359. package/vendor/desk/mcp/src/runtime/fast-refs.js +209 -0
  360. package/vendor/desk/mcp/src/runtime/filer-throttle.js +66 -0
  361. package/vendor/desk/mcp/src/runtime/focused-card.js +147 -0
  362. package/vendor/desk/mcp/src/runtime/front-door.js +204 -0
  363. package/vendor/desk/mcp/src/runtime/gate-wait.js +2 -0
  364. package/vendor/desk/mcp/src/runtime/git-inspection.js +201 -0
  365. package/vendor/desk/mcp/src/runtime/git-read-worker.js +157 -0
  366. package/vendor/desk/mcp/src/runtime/health.js +50 -0
  367. package/vendor/desk/mcp/src/runtime/hooks.js +353 -0
  368. package/vendor/desk/mcp/src/runtime/hosted.js +163 -0
  369. package/vendor/desk/mcp/src/runtime/inbox.js +102 -0
  370. package/vendor/desk/mcp/src/runtime/index-drift.js +118 -0
  371. package/vendor/desk/mcp/src/runtime/last-start.js +133 -0
  372. package/vendor/desk/mcp/src/runtime/lesson-section.js +92 -0
  373. package/vendor/desk/mcp/src/runtime/lessons-shelf.js +100 -0
  374. package/vendor/desk/mcp/src/runtime/lfs.js +319 -0
  375. package/vendor/desk/mcp/src/runtime/native-path.js +12 -0
  376. package/vendor/desk/mcp/src/runtime/newest-release.js +197 -0
  377. package/vendor/desk/mcp/src/runtime/node-selection.js +233 -0
  378. package/vendor/desk/mcp/src/runtime/orca-session-title.js +225 -0
  379. package/vendor/desk/mcp/src/runtime/other-sessions.js +183 -0
  380. package/vendor/desk/mcp/src/runtime/pending-migrations.js +653 -0
  381. package/vendor/desk/mcp/src/runtime/plugin-update.js +215 -0
  382. package/vendor/desk/mcp/src/runtime/pluginless-runtimes.js +34 -0
  383. package/vendor/desk/mcp/src/runtime/pr-publication.js +226 -0
  384. package/vendor/desk/mcp/src/runtime/preview-snapshot.js +23 -0
  385. package/vendor/desk/mcp/src/runtime/publication-mode.js +19 -0
  386. package/vendor/desk/mcp/src/runtime/relays.js +974 -0
  387. package/vendor/desk/mcp/src/runtime/release-alert.js +148 -0
  388. package/vendor/desk/mcp/src/runtime/remote-identity.js +140 -0
  389. package/vendor/desk/mcp/src/runtime/resolve-here.js +4 -0
  390. package/vendor/desk/mcp/src/runtime/runtime-deps-cli.js +65 -0
  391. package/vendor/desk/mcp/src/runtime/runtime-deps.js +1109 -0
  392. package/vendor/desk/mcp/src/runtime/runtime-identity.js +22 -0
  393. package/vendor/desk/mcp/src/runtime/runtime-swap.js +101 -0
  394. package/vendor/desk/mcp/src/runtime/schedules.js +235 -0
  395. package/vendor/desk/mcp/src/runtime/session-activity.js +190 -0
  396. package/vendor/desk/mcp/src/runtime/session-label.js +30 -0
  397. package/vendor/desk/mcp/src/runtime/session-retention.js +662 -0
  398. package/vendor/desk/mcp/src/runtime/session-sync.js +333 -0
  399. package/vendor/desk/mcp/src/runtime/session-trailer.js +126 -0
  400. package/vendor/desk/mcp/src/runtime/sessions-cli.js +301 -0
  401. package/vendor/desk/mcp/src/runtime/signoff-listed.js +81 -0
  402. package/vendor/desk/mcp/src/runtime/skills.js +76 -0
  403. package/vendor/desk/mcp/src/runtime/stale-card-lead.js +52 -0
  404. package/vendor/desk/mcp/src/runtime/stale-desk-refresh.js +198 -0
  405. package/vendor/desk/mcp/src/runtime/stale-desk.js +219 -0
  406. package/vendor/desk/mcp/src/runtime/stalled.js +255 -0
  407. package/vendor/desk/mcp/src/runtime/standing-authority.js +79 -0
  408. package/vendor/desk/mcp/src/runtime/startup-boot.js +341 -0
  409. package/vendor/desk/mcp/src/runtime/startup-resolve.js +140 -0
  410. package/vendor/desk/mcp/src/runtime/state-branch.js +203 -0
  411. package/vendor/desk/mcp/src/runtime/status-compact.js +165 -0
  412. package/vendor/desk/mcp/src/runtime/status-inspection-child.js +26 -0
  413. package/vendor/desk/mcp/src/runtime/status-inspection.js +147 -0
  414. package/vendor/desk/mcp/src/runtime/status-root.js +39 -0
  415. package/vendor/desk/mcp/src/runtime/sync-worker.js +911 -0
  416. package/vendor/desk/mcp/src/runtime/test-state-guard.js +107 -0
  417. package/vendor/desk/mcp/src/runtime/unmerged-saves.js +247 -0
  418. package/vendor/desk/mcp/src/runtime/workspace-claim.js +53 -0
  419. package/vendor/desk/mcp/src/runtime/workspace-evidence.js +96 -0
  420. package/vendor/desk/mcp/src/runtime/workspace-tidy.js +509 -0
  421. package/vendor/desk/mcp/src/search/direct-lexical.js +54 -0
  422. package/vendor/desk/mcp/src/search/embedder.js +108 -0
  423. package/vendor/desk/mcp/src/search/engine.js +406 -0
  424. package/vendor/desk/mcp/src/search/files-router.js +22 -0
  425. package/vendor/desk/mcp/src/search/old-index.js +46 -0
  426. package/vendor/desk/mcp/src/search/vectors.js +60 -0
  427. package/vendor/desk/mcp/src/server.js +389 -0
  428. package/vendor/desk/mcp/src/tool-names.js +73 -0
  429. package/vendor/desk/mcp/src/tool-refusal.cjs +35 -0
  430. package/vendor/desk/mcp/src/tool-schema-parts.js +12 -0
  431. package/vendor/desk/mcp/src/tool-schemas.js +325 -0
  432. package/vendor/desk/mcp/src/tools/_card-commit.js +148 -0
  433. package/vendor/desk/mcp/src/tools/archive-links.js +185 -0
  434. package/vendor/desk/mcp/src/tools/archive-move.js +18 -0
  435. package/vendor/desk/mcp/src/tools/archive-native-session.js +728 -0
  436. package/vendor/desk/mcp/src/tools/archive-state.js +513 -0
  437. package/vendor/desk/mcp/src/tools/delivery-gate.js +251 -0
  438. package/vendor/desk/mcp/src/tools/desk-save.js +444 -0
  439. package/vendor/desk/mcp/src/tools/doctor.js +122 -0
  440. package/vendor/desk/mcp/src/tools/done-evidence.js +260 -0
  441. package/vendor/desk/mcp/src/tools/factory-context.js +204 -0
  442. package/vendor/desk/mcp/src/tools/friction.js +332 -0
  443. package/vendor/desk/mcp/src/tools/improvement.js +156 -0
  444. package/vendor/desk/mcp/src/tools/lesson-lines.js +22 -0
  445. package/vendor/desk/mcp/src/tools/lesson-owners.js +137 -0
  446. package/vendor/desk/mcp/src/tools/lesson-team.js +169 -0
  447. package/vendor/desk/mcp/src/tools/lesson.js +254 -0
  448. package/vendor/desk/mcp/src/tools/local-only.js +151 -0
  449. package/vendor/desk/mcp/src/tools/move.js +794 -0
  450. package/vendor/desk/mcp/src/tools/native-stage-context.js +32 -0
  451. package/vendor/desk/mcp/src/tools/note.js +267 -0
  452. package/vendor/desk/mcp/src/tools/search.js +634 -0
  453. package/vendor/desk/mcp/src/tools/shared-write.js +196 -0
  454. package/vendor/desk/mcp/src/tools/sibling-desk.js +37 -0
  455. package/vendor/desk/mcp/src/tools/status.js +233 -0
  456. package/vendor/desk/mcp/src/tools/task-archive-due.js +9 -0
  457. package/vendor/desk/mcp/src/tools/task-archived-resource.js +53 -0
  458. package/vendor/desk/mcp/src/tools/task-body.js +141 -0
  459. package/vendor/desk/mcp/src/tools/task-focus.js +164 -0
  460. package/vendor/desk/mcp/src/tools/task-log.js +76 -0
  461. package/vendor/desk/mcp/src/tools/task-signoff.js +155 -0
  462. package/vendor/desk/mcp/src/tools/task.js +1768 -0
  463. package/vendor/desk/mcp/src/tools/track-row.js +89 -0
  464. package/vendor/desk/mcp/src/tools/track.js +240 -0
  465. package/vendor/desk/mcp/src/util/agency-session.cjs +29 -0
  466. package/vendor/desk/mcp/src/util/archive-links.js +105 -0
  467. package/vendor/desk/mcp/src/util/bash.js +36 -0
  468. package/vendor/desk/mcp/src/util/capture-record.js +73 -0
  469. package/vendor/desk/mcp/src/util/cas-commit.js +252 -0
  470. package/vendor/desk/mcp/src/util/created-dirs.js +71 -0
  471. package/vendor/desk/mcp/src/util/deferred-tools.js +51 -0
  472. package/vendor/desk/mcp/src/util/desk-owner.js +99 -0
  473. package/vendor/desk/mcp/src/util/env-value.js +13 -0
  474. package/vendor/desk/mcp/src/util/file-identity.js +40 -0
  475. package/vendor/desk/mcp/src/util/finish-commit.js +145 -0
  476. package/vendor/desk/mcp/src/util/fm.js +410 -0
  477. package/vendor/desk/mcp/src/util/git-config-file.js +85 -0
  478. package/vendor/desk/mcp/src/util/git-stage.js +440 -0
  479. package/vendor/desk/mcp/src/util/main-publish.js +240 -0
  480. package/vendor/desk/mcp/src/util/markdown-links.cjs +555 -0
  481. package/vendor/desk/mcp/src/util/object-input.js +59 -0
  482. package/vendor/desk/mcp/src/util/paths.js +647 -0
  483. package/vendor/desk/mcp/src/util/rank.js +189 -0
  484. package/vendor/desk/mcp/src/util/redact.js +92 -0
  485. package/vendor/desk/mcp/src/util/remove-retry.js +35 -0
  486. package/vendor/desk/mcp/src/util/rename-retry.js +73 -0
  487. package/vendor/desk/mcp/src/util/route-around.js +265 -0
  488. package/vendor/desk/mcp/src/util/shell-quote.js +18 -0
  489. package/vendor/desk/mcp/src/util/startup-direction.js +124 -0
  490. package/vendor/desk/mcp/src/util/state-ignore.js +33 -0
  491. package/vendor/desk/mcp/src/util/tool-commits.js +64 -0
  492. package/vendor/desk/mcp/src/util/unicode-16/LICENSE-MIT.txt +7 -0
  493. package/vendor/desk/mcp/src/util/unicode-16/README.md +9 -0
  494. package/vendor/desk/mcp/src/util/unicode-16/letter.cjs +1 -0
  495. package/vendor/desk/mcp/src/util/unicode-16/mark.cjs +1 -0
  496. package/vendor/desk/mcp/src/util/unicode-16/number.cjs +1 -0
  497. package/vendor/desk/mcp/web-auth.cjs +1897 -0
  498. package/vendor/desk/mcp/web-browser-discovery.cjs +53 -0
  499. package/vendor/desk/mcp/web-catalog.json +34 -0
  500. package/vendor/desk/mcp/web-launch.cjs +101 -0
  501. package/vendor/desk/mcp/web.cjs +1239 -0
  502. package/vendor/desk/migrations/01-move-to-ourostack-desk.md +188 -0
  503. package/vendor/desk/migrations/02-tidy-desk.md +87 -0
  504. package/vendor/desk/migrations/03-desk-release-channel.md +38 -0
  505. package/vendor/desk/optional/session-label/consumer.mjs +237 -0
  506. package/vendor/desk/optional/session-label/extension.mjs +32 -0
  507. package/vendor/desk/plugin.json +54 -0
  508. package/vendor/desk/settings.json +3 -0
  509. package/vendor/desk/skills/add-workspace-mcp/SKILL.md +180 -0
  510. package/vendor/desk/skills/adopt-inflight-work/SKILL.md +212 -0
  511. package/vendor/desk/skills/archive-workflow/SKILL.md +132 -0
  512. package/vendor/desk/skills/content-routing/SKILL.md +95 -0
  513. package/vendor/desk/skills/core-meeting-capture/SKILL.md +47 -0
  514. package/vendor/desk/skills/core-meeting-capture/references/capture-contract.md +175 -0
  515. package/vendor/desk/skills/curator/SKILL.md +103 -0
  516. package/vendor/desk/skills/delightful-decks/SKILL.md +67 -0
  517. package/vendor/desk/skills/desk-problem/SKILL.md +87 -0
  518. package/vendor/desk/skills/directory-structure/SKILL.md +169 -0
  519. package/vendor/desk/skills/doc-review-rigor/SKILL.md +63 -0
  520. package/vendor/desk/skills/draining-issues/SKILL.md +62 -0
  521. package/vendor/desk/skills/evaluate-release/SKILL.md +96 -0
  522. package/vendor/desk/skills/evidence-discipline/SKILL.md +150 -0
  523. package/vendor/desk/skills/factory-evaluator/SKILL.md +122 -0
  524. package/vendor/desk/skills/factory-task-context/SKILL.md +116 -0
  525. package/vendor/desk/skills/factory-work/SKILL.md +16 -0
  526. package/vendor/desk/skills/fast-honest-ci/SKILL.md +70 -0
  527. package/vendor/desk/skills/fast-honest-ci/examples.md +49 -0
  528. package/vendor/desk/skills/first-run-bootstrap/SKILL.md +95 -0
  529. package/vendor/desk/skills/friction-management/SKILL.md +98 -0
  530. package/vendor/desk/skills/git-hygiene/SKILL.md +253 -0
  531. package/vendor/desk/skills/independent-review/SKILL.md +34 -0
  532. package/vendor/desk/skills/interaction-style/SKILL.md +239 -0
  533. package/vendor/desk/skills/lesson-capture/SKILL.md +85 -0
  534. package/vendor/desk/skills/lesson-capture/agents-md-budget.mjs +61 -0
  535. package/vendor/desk/skills/online-evaluation/SKILL.md +81 -0
  536. package/vendor/desk/skills/operator-voice-comments/LICENSE-humanize +21 -0
  537. package/vendor/desk/skills/operator-voice-comments/SKILL.md +90 -0
  538. package/vendor/desk/skills/operator-voice-comments/human-voice.md +43 -0
  539. package/vendor/desk/skills/peer-pr-review/SKILL.md +104 -0
  540. package/vendor/desk/skills/pr-feedback-on-own-pr/SKILL.md +145 -0
  541. package/vendor/desk/skills/pr-review-interrogation/SKILL.md +121 -0
  542. package/vendor/desk/skills/pr-reviewer-audit/SKILL.md +68 -0
  543. package/vendor/desk/skills/pr-reviewer-audit/helpers/audit.py +335 -0
  544. package/vendor/desk/skills/pr-reviewer-audit/helpers/test_audit.py +486 -0
  545. package/vendor/desk/skills/pr-self-review/SKILL.md +86 -0
  546. package/vendor/desk/skills/pr-surface-hygiene/SKILL.md +105 -0
  547. package/vendor/desk/skills/pr-surface-hygiene/check-visual-proof.cjs +99 -0
  548. package/vendor/desk/skills/pr-surface-hygiene/repository-setup.md +19 -0
  549. package/vendor/desk/skills/pr-surface-hygiene/resources/pr-visual-proof.yml +29 -0
  550. package/vendor/desk/skills/pr-surface-hygiene/resources/pull-request-template.md +5 -0
  551. package/vendor/desk/skills/preflight-actions/SKILL.md +60 -0
  552. package/vendor/desk/skills/preview-feedback/SKILL.md +70 -0
  553. package/vendor/desk/skills/repo-handling/SKILL.md +67 -0
  554. package/vendor/desk/skills/rnd-lab/SKILL.md +52 -0
  555. package/vendor/desk/skills/runtime-symptom-investigation/SKILL.md +106 -0
  556. package/vendor/desk/skills/session-resumption/SKILL.md +126 -0
  557. package/vendor/desk/skills/session-start/SKILL.md +54 -0
  558. package/vendor/desk/skills/session-start/details.md +150 -0
  559. package/vendor/desk/skills/session-start-migrations/README.md +71 -0
  560. package/vendor/desk/skills/session-start-migrations/SKILL.md +108 -0
  561. package/vendor/desk/skills/start-task/SKILL.md +88 -0
  562. package/vendor/desk/skills/task-card-format/SKILL.md +198 -0
  563. package/vendor/desk/skills/task-lifecycle/SKILL.md +217 -0
  564. package/vendor/desk/skills/track-card-format/SKILL.md +90 -0
  565. package/vendor/desk/skills/using-desk/SKILL.md +58 -0
  566. package/vendor/desk/skills/using-superpowers-with-desk/SKILL.md +156 -0
  567. package/vendor/desk/skills/work-orchestration/SKILL.md +162 -0
@@ -0,0 +1,368 @@
1
+ // The factory's local status: what desk_status, desk_doctor and the task
2
+ // tools need to know about the bound desk's store, read synchronously from
3
+ // bounded local state and never written.
4
+ //
5
+ // `factoryLocalStatus({ env, deskRoot, pluginDirs, pluginScanIncomplete })`
6
+ // resolves the desk's store exactly as the end hook and the boot check do
7
+ // (`resolveStore`; an incomplete plugin scan holds routing unless the desk
8
+ // declares its own store) and returns:
9
+ //
10
+ // {
11
+ // store: "<owner/repo>" | null,
12
+ // source: "desk" | "overlay" | "default" | "invalid_declaration" | "plugin_scan_incomplete" | "no_desk",
13
+ // consent: "yes" | "no" | "undecided" | "unreadable" | "held",
14
+ // stores: [{ store, consent, pending, route_changed, quarantined, last_flush }],
15
+ // warnings: ["manifest_unreadable" | "manifest_unparseable", ...],
16
+ // }
17
+ //
18
+ // `consent` is the resolved store's decision; `held` means no store is
19
+ // resolved, so nothing is asked and nothing is sent. `stores` lists the
20
+ // resolved store first, then every other store with a recorded decision,
21
+ // sorted. `pending` counts the store's outbox files never delivered and not
22
+ // quarantined whose session the flush would publish there (`here`, or
23
+ // `unknown`, waiting for its route); `route_changed` counts its outbox files
24
+ // and kept copies (`retracted-copies/`), not quarantined, whose session routes
25
+ // elsewhere as the flush reads it (`session-route.js`: `away`, including a
26
+ // finished retraction's tombstone, `stale` or `stalled`; a copy without a
27
+ // positive route here and no checked route here is `stale`): the flush never publishes them there; `quarantined`
28
+ // counts its quarantined files; `last_flush` is the last flush's result
29
+ // code, or `null`.
30
+ //
31
+ // `visibility_unasked` is present only when a store's flushes have held sessions back, unable to ask their desk's visibility, for over 7 days:
32
+ // `[{ store, sessions }]` (the last flush records `visibility_unasked` and `visibility_unasked_since`).
33
+ // `orphans` is present only when the orphan pass (`derive-run.js` `rebuildOrphans`) needs attention: `"pass_failed"` (the last pass threw),
34
+ // `"pass_interrupted"` (a record with a start older than `ORPHAN_INTERRUPTED_MS`, or with a start that does not parse, and no result),
35
+ // `"orphans_hung"` (an orphan was interrupted twice and is frozen; `orphans_hung` then counts them), `"pass_stale"` (the last pass ran more than
36
+ // `ORPHAN_STALE_MS` ago) or `"walk_not_advancing"` (`sweeps_in_walk` is past `ceil((worked + unexamined) / max(1, worked))`, `worked` counting only
37
+ // the orphans that took a transcript slot, so the walk should have wrapped). `orphanPassLine(record, now)` is the one-line
38
+ // reading `factory.js status` prints; both read counts, times and fixed codes only.
39
+ // `retention` is present only when a pruning part stopped (`retention.js` `retentionFinding`): `"prune_failed"` (the last sweep's tombstone
40
+ // pruning failed) or `"copies_prune_failed"` (the last orphan pass counted a delivered-copy prune that threw). `capture_check_unavailable` is
41
+ // present only when a store's own capture check could not read the record `CHECK_UNAVAILABLE_ALARM` (3) or more times in a row:
42
+ // `[{ store, times }]`. `capture_dropped` is present when a record dropped from a rebuilt intake branch was still not sent six hours later: `[{ store, since }]`. `coverage_kept` is present when the coverage pass was kept back for a quarantine that did not settle within an hour and was recorded anyway: `{ since }`. Like `orphans`, all are pushed to the doctor and the boot status, not only shown by `factory.js status`.
43
+ //
44
+ // The result carries store names, codes and counts only: never the machine
45
+ // secret, an account, an intake ID, a token or any content, and no local
46
+ // path or time except where a held route needs one to be fixed. Manifest
47
+ // warnings keep their codes and drop their paths. `held_by` (this desk's
48
+ // route is held now), `route_holds` (`{ count, reasons }`: the sessions the
49
+ // last sweep counted as held, `held-route.js` `routeHolds`) and
50
+ // `held_pruned` (`{ count, last_at }`: held sessions pruned uncaptured after
51
+ // 90 days) name each hold's reason, the manifest or plugin folder to fix
52
+ // (`path`, or `null` when the hook named none) and its remedy, so a hold is
53
+ // never silent; the doctor and the boot print them.
54
+ //
55
+ // `factoryReportLink({ env, deskRoot, deskRemote, personPrefix, track, slug,
56
+ // pluginDirs, pluginScanIncomplete })` is the task card's `factory_report`
57
+ // link, `{ link }`, when the resolved store has consent `contribute: true`
58
+ // and the desk is known to be private: its cached visibility is `private` or
59
+ // `internal`, so the store publishes the plain job ID the link names. Any
60
+ // other contributing desk gets `{ link: null, reason }`: `desk_not_private`
61
+ // (a public or unknown desk, or one with no GitHub remote: its store job is
62
+ // keyed so that nobody can tie the desk's public cards to it, and a link
63
+ // would make that tie) or `visibility_not_known` (a GitHub desk whose cached
64
+ // answer is expired, absent or unreadable). Without consent it is
65
+ // `{ link: null }` with no reason: the factory is not in use for this desk.
66
+ // A link names the job's report path; the report exists only once the store
67
+ // has merged facts for the job and rebuilt its reports, so a job never
68
+ // credited with a session has none.
69
+ //
70
+ // `src/factory/**` imports only `node:` built-ins and other `src/factory/`
71
+ // files.
72
+
73
+ import { readdirSync, statSync } from "node:fs"
74
+ import * as path from "node:path"
75
+ import { deskVersion } from "../package-metadata.js"
76
+
77
+ import { consentDecision, consentRecords as readConsentRecords, factoryStateDir } from "./boot-check.js"
78
+ import { jobId } from "./binding.js"
79
+ import { deskTimingKept, deskVisibilityOf, freshVisibility, githubRepoOfRemote, visibilityMap } from "./desk-visibility.js"
80
+ import { readSmallText, validMarker } from "./marker.js"
81
+ import { jobReportUrl } from "./pipeline/build.js"
82
+ import { ENUMS, PATTERNS, isPlainObject } from "./schema.js"
83
+ import { captureCheckFindings, captureDroppedFindings, coverageKeptFinding, retentionFinding } from "./retention.js"
84
+ import { HOLD_REMEDIES, holdReason } from "./held-route.js"
85
+ import { RETRACTED_COPIES, derivedStoreOf, deskRootOf, isFolder, sessionPlace, sessionRoute } from "./session-route.js"
86
+ import { resolveStore } from "./store-route.js"
87
+
88
+ const STATE_BYTES = 8 * 1024 * 1024
89
+ const MAX_ENTRIES = 4096
90
+ const OUTBOX_NAME = new RegExp(`^(?:${ENUMS.host.join("|")})-[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}\\.json$`, "u")
91
+ const RESULT_CODE = /^[a-z][a-z0-9_]{0,63}$/u
92
+ const UNREADABLE = Symbol("unreadable")
93
+ // The places whose files the flush never publishes to the store they sit in (`session-route.js`).
94
+ const ELSEWHERE = new Set(["away", "stale", "stalled"])
95
+
96
+ /** A JSON object state file: `fallback` when absent, `UNREADABLE` when unsafe, unreadable or not an object (as the boot check reads it). */
97
+ function readState(file, fallback) {
98
+ let text
99
+ try {
100
+ text = readSmallText(file, STATE_BYTES)
101
+ } catch (error) {
102
+ return error.code === "ENOENT" ? fallback : UNREADABLE
103
+ }
104
+ try {
105
+ const value = JSON.parse(text)
106
+ return isPlainObject(value) ? value : UNREADABLE
107
+ } catch {
108
+ return UNREADABLE
109
+ }
110
+ }
111
+
112
+ /** How long a pass may run before a record with a start and no result reads as interrupted: past the 150 s the start hook allows. */
113
+ export const ORPHAN_INTERRUPTED_MS = 5 * 60 * 1000
114
+ /** How long since the last pass ran before the doctor reports it: the pass runs at every session start. */
115
+ export const ORPHAN_STALE_MS = 2 * 24 * 60 * 60 * 1000
116
+ /** Interrupted passes that freeze an orphan (`derive-run.js` `ORPHAN_HUNG_STRIKES`; the status code stays in `src/factory/`). */
117
+ const HUNG_STRIKES = 2
118
+
119
+ const finiteCount = (value) => (Number.isSafeInteger(value) && value >= 0 ? value : null)
120
+
121
+ /** The version of Desk running this code, or `null` (`package-metadata.js`'s one resolver). */
122
+ export const ownVersion = () => deskVersion()
123
+
124
+ /** How many orphans the record holds frozen by repeated interruptions (two strikes) under Desk `version` (a newer Desk starts the count again), or 0. */
125
+ export function orphansHung(record, version) {
126
+ if (!isPlainObject(record) || !isPlainObject(record.hung) || typeof version !== "string") return 0
127
+ return Object.values(record.hung).filter((entry) => isPlainObject(entry) && entry.version === version && Number.isSafeInteger(entry.strikes) && entry.strikes >= HUNG_STRIKES).length
128
+ }
129
+
130
+ /**
131
+ * What is wrong with the orphan pass's record, or `null`: see the header. `now` is milliseconds; `version` is the running Desk's (hung strikes of
132
+ * another version do not count); `active` is whether this machine ended a session in the last `ORPHAN_STALE_MS` (a machine that stopped
133
+ * contributing is not alarmed that the pass has not run).
134
+ */
135
+ export function orphanPassFinding(record, now = Date.now(), { version = null, active = false } = {}) {
136
+ if (!isPlainObject(record)) return null
137
+ if (record.failed !== undefined) return "pass_failed"
138
+ // A start time that does not parse is never "running".
139
+ if (record.ran_at === undefined) return now - Date.parse(record.started_at) <= ORPHAN_INTERRUPTED_MS ? null : "pass_interrupted"
140
+ if (orphansHung(record, version) > 0) return "orphans_hung"
141
+ if (active && now - Date.parse(record.ran_at) > ORPHAN_STALE_MS) return "pass_stale"
142
+ // `worked` is the orphans that took a transcript slot (a record from before it counted `examined`, which includes cheaply frozen ones).
143
+ const worked = finiteCount(record.worked) ?? finiteCount(record.examined)
144
+ const unexamined = finiteCount(record.unexamined)
145
+ const sweeps = finiteCount(record.sweeps_in_walk)
146
+ if (worked === null || unexamined === null || sweeps === null) return null
147
+ return sweeps > Math.ceil((worked + unexamined) / Math.max(1, worked)) ? "walk_not_advancing" : null
148
+ }
149
+
150
+ /** Whether any marker on this machine records a session that ended within `ORPHAN_STALE_MS`. */
151
+ function endedSessionRecently(dir, now = Date.now()) {
152
+ return outboxNames(path.join(dir, "markers")).some((name) => {
153
+ const marker = readState(path.join(dir, "markers", name), null)
154
+ return validMarker(marker) && typeof marker.ended_at === "string" && now - Date.parse(marker.ended_at) <= ORPHAN_STALE_MS
155
+ })
156
+ }
157
+
158
+ /** How long a desk's visibility may go unasked (every flush deferring its sessions) before the doctor reports it. */
159
+ export const UNASKED_REPORT_MS = 7 * 24 * 60 * 60 * 1000
160
+
161
+ /** `[{ store, sessions, age? }]` (`age: "unknown"` when the start time does not parse) for each store whose last flush has held sessions back for want of a visibility answer for longer than `UNASKED_REPORT_MS`. */
162
+ export function visibilityUnasked(lastFlush, stores, now = Date.now()) {
163
+ if (!isPlainObject(lastFlush)) return []
164
+ return stores.flatMap((store) => {
165
+ const entry = lastFlush[store]
166
+ if (!isPlainObject(entry) || !Number.isSafeInteger(entry.visibility_unasked) || entry.visibility_unasked <= 0) return []
167
+ const age = now - Date.parse(entry.visibility_unasked_since)
168
+ // A start time that does not parse is a deferral of unknown age, reported, never ignored.
169
+ if (Number.isNaN(age)) return [{ store, sessions: entry.visibility_unasked, age: "unknown" }]
170
+ return age > UNASKED_REPORT_MS ? [{ store, sessions: entry.visibility_unasked }] : []
171
+ })
172
+ }
173
+
174
+ /** One sentence saying what to do about sessions held back for want of a visibility answer. */
175
+ export const UNASKED_ADVICE = (store) => `Run \`node mcp/scripts/factory.js flush --store ${store}\` from the Desk plugin folder and read its result; if it keeps failing, file a Desk problem.`
176
+
177
+ /** One sentence saying what to do about a finding. */
178
+ export const ORPHAN_FINDING_ADVICE = "Run `node mcp/scripts/factory.js status` from the Desk plugin folder and read its orphan_pass line; if the pass keeps failing or stalling, file a Desk problem."
179
+
180
+ /** One sentence saying what to do about a retention finding. */
181
+ export const RETENTION_FINDING_ADVICE = "Run `node mcp/scripts/factory.js status` from the Desk plugin folder and read its retention line; if pruning keeps failing, file a Desk problem."
182
+
183
+ /** One sentence saying what to do about a store whose own capture check keeps failing. */
184
+ export const CAPTURE_CHECK_ADVICE = (store) => `The store's own check, not this machine, is failing: file a problem against ${store}'s capture check, and run \`node mcp/scripts/factory.js status\` from the Desk plugin folder to see its capture line.`
185
+
186
+ /** One line for the orphan pass's record: counts, times and fixed codes only (a failure is its class, never a message). */
187
+ export function orphanPassLine(record, now = Date.now(), { version = null } = {}) {
188
+ if (!isPlainObject(record)) return "orphan pass: no record yet"
189
+ const wrap = typeof record.last_wrap_at === "string" ? record.last_wrap_at : "never"
190
+ if (record.failed !== undefined) return `orphan pass: failed (${typeof record.failed === "string" && RESULT_CODE.test(record.failed) ? record.failed : "unknown"}), last full walk ${wrap}`
191
+ if (record.ran_at === undefined) return `orphan pass: ${orphanPassFinding(record, now, { version }) === null ? "running" : "interrupted"}, started ${typeof record.started_at === "string" ? record.started_at : "unknown"}, last full walk ${wrap}`
192
+ const frozen = isPlainObject(record.frozen) ? Object.values(record.frozen).reduce((sum, count) => sum + (finiteCount(count) ?? 0), 0) : 0
193
+ const count = (value) => finiteCount(value) ?? "unknown"
194
+ const hung = orphansHung(record, version)
195
+ return `orphan pass: ran ${record.ran_at}, examined ${count(record.examined)}, unexamined ${count(record.unexamined)}, pending ${count(record.pending)}, frozen ${frozen}${hung > 0 ? ` (${hung} hung)` : ""}, last full walk ${wrap}, ${count(record.sweeps_in_walk)} sweeps into the walk`
196
+ }
197
+
198
+ function outboxNames(dir) {
199
+ try {
200
+ return readdirSync(dir, { withFileTypes: true }).slice(0, MAX_ENTRIES).filter((entry) => entry.isFile() && OUTBOX_NAME.test(entry.name)).map((entry) => entry.name)
201
+ } catch {
202
+ return []
203
+ }
204
+ }
205
+
206
+ /** The recorded consent map, `{}` when nothing is decided, or `UNREADABLE`; read exactly as the boot check reads it. */
207
+ function consentRecords(dir) {
208
+ return readConsentRecords(dir) ?? UNREADABLE
209
+ }
210
+
211
+ function decision(records, store) {
212
+ return consentDecision(records === UNREADABLE ? null : records, store)
213
+ }
214
+
215
+ function route({ deskRoot, pluginDirs, pluginScanIncomplete }) {
216
+ if (typeof deskRoot !== "string" || !path.isAbsolute(deskRoot)) return { store: null, source: "no_desk", warnings: [] }
217
+ const resolved = resolveStore({ deskRoot, pluginDirs, read: (file) => readSmallText(file) })
218
+ // As in the end hook and the boot check: an incomplete scan may have missed an overlay's declaration.
219
+ if (resolved.store !== null && pluginScanIncomplete && resolved.source !== "desk") return { store: null, source: "plugin_scan_incomplete", warnings: resolved.warnings }
220
+ return resolved
221
+ }
222
+
223
+ // Where an outbox file's session routes now, for `store`, read from the markers and receipts the flush reads (`session-route.js`).
224
+ // A marker that is missing, unreadable or malformed says nothing new, as `listMarkers` drops it for the flush.
225
+ function placer(dir, receipts) {
226
+ const markerOf = (name) => {
227
+ const marker = readState(path.join(dir, "markers", name), null)
228
+ return validMarker(marker) && `${marker.host}-${marker.session_id}.json` === name ? marker : null
229
+ }
230
+ let siblings = null
231
+ const listSiblings = () => (siblings ??= outboxNames(path.join(dir, "markers")).map(markerOf).filter((marker) => marker !== null))
232
+ // `retracting` is the store's retracting records and tombstones, by name. A session whose recorded desk folder no longer resolves is here
233
+ // only on a positive route, as the flush reads it. Returns `{ place, positive }`.
234
+ return (store, name, retracting) => {
235
+ // An outbox name, like a labels key, ends in the 36-character session id and `.json`.
236
+ const session = name.slice(-41, -5)
237
+ const names = ENUMS.host.map((host) => `${host}-${session}.json`)
238
+ const marker = names.map(markerOf).find((found) => found !== null) ?? null
239
+ const records = Object.entries(retracting).filter(([key, record]) => key.slice(-41, -5) === session && isPlainObject(record)).map(([, record]) => record)
240
+ const deskRoot = deskRootOf(receipts, names)
241
+ const route = sessionRoute(marker, { siblings: listSiblings, deskRoot })
242
+ const place = sessionPlace(store, route, derivedStoreOf(receipts, names), records)
243
+ const recorded = [marker?.desk_root, deskRoot].filter((root) => typeof root === "string")
244
+ const gone = recorded.length > 0 && !recorded.some(isFolder)
245
+ return { place: place === "here" && route.kind !== "store" && gone ? "stale" : place, positive: route.kind === "store" }
246
+ }
247
+ }
248
+
249
+ function storeEntry(dir, consents, store, lastFlush, place, now) {
250
+ const slug = store.replace("/", "__")
251
+ const delivered = readState(path.join(dir, "delivered", `${slug}.json`), {})
252
+ const quarantined = new Set(outboxNames(path.join(dir, "quarantine", slug)))
253
+ const retracting = readState(path.join(dir, "retracting", `${slug}.json`), {})
254
+ // The kept copies of sessions that left the store (`session-route.js`) count with the outbox files: they are what `route_changed` reports.
255
+ const records = retracting === UNREADABLE ? {} : retracting
256
+ const live = new Set(outboxNames(path.join(dir, "outbox", slug)))
257
+ const keptDir = path.join(dir, RETRACTED_COPIES, slug)
258
+ const kept = outboxNames(keptDir).filter((name) => !live.has(name))
259
+ const listed = [...new Set([...live, ...kept])].filter((name) => !quarantined.has(name))
260
+ const away = new Set(listed.filter((name) => ELSEWHERE.has(place(store, name, records).place)))
261
+ // Kept copies with no positive route anywhere that are not here on a checked route are frozen (never published, never deleted): counted, with
262
+ // the oldest one's age.
263
+ const frozen = kept.filter((name) => { const { place: where, positive } = place(store, name, records); return !positive && where !== "here" })
264
+ const ages = frozen.map((name) => keptAgeDays(path.join(keptDir, name), now)).filter((days) => days !== null)
265
+ const pending = listed.filter((name) => !away.has(name) && (delivered === UNREADABLE || !Object.hasOwn(delivered, name))).length
266
+ const flush = isPlainObject(lastFlush) && isPlainObject(lastFlush[store]) ? lastFlush[store].result : null
267
+ const waiting = isPlainObject(lastFlush) && isPlainObject(lastFlush[store]) && Number.isSafeInteger(lastFlush[store].visibility_unasked) ? lastFlush[store].visibility_unasked : 0
268
+ const frozenFields = frozen.length > 0 ? { kept_frozen: frozen.length, kept_frozen_oldest_days: ages.length > 0 ? Math.max(...ages) : null } : {}
269
+ return { store, consent: decision(consents, store), pending, ...(waiting > 0 ? { waiting_for_visibility: waiting } : {}), route_changed: away.size, quarantined: quarantined.size, ...frozenFields, last_flush: typeof flush === "string" && RESULT_CODE.test(flush) ? flush : null }
270
+ }
271
+
272
+ // A kept copy's age in whole days from its file's time, or null when it cannot be read.
273
+ function keptAgeDays(file, now) {
274
+ try {
275
+ return Math.max(0, Math.floor((now - statSync(file).mtimeMs) / (24 * 60 * 60 * 1000)))
276
+ } catch {
277
+ return null
278
+ }
279
+ }
280
+
281
+ /** See the header. Never writes and never throws for missing or unreadable state. */
282
+ export function factoryLocalStatus({ env, deskRoot, pluginDirs = [], pluginScanIncomplete = false, pluginScanReason = null }) {
283
+ const routing = route({ deskRoot, pluginDirs, pluginScanIncomplete })
284
+ const dir = factoryStateDir(env)
285
+ const records = consentRecords(dir)
286
+ const status = readState(path.join(dir, "status.json"), {})
287
+ const lastFlush = status === UNREADABLE ? null : status.last_flush
288
+ const place = placer(dir, status === UNREADABLE ? {} : status.derivations)
289
+ const decided = records === UNREADABLE ? [] : Object.keys(records).filter((store) => PATTERNS.prRepo.test(store)).sort()
290
+ const stores = [...new Set([...(routing.store === null ? [] : [routing.store]), ...decided])]
291
+ const version = ownVersion()
292
+ // Contribution must be switched on for a stale pass to mean anything: a machine that wrote markers but never opted in has no pass to run.
293
+ const contributing = stores.some((store) => decision(records, store) === "yes")
294
+ const orphans = status === UNREADABLE ? null : orphanPassFinding(status.orphans, Date.now(), { version, active: contributing && endedSessionRecently(dir) })
295
+ const unasked = visibilityUnasked(lastFlush, stores)
296
+ const hung = status === UNREADABLE ? 0 : orphansHung(status.orphans, version)
297
+ const retention = status === UNREADABLE ? null : retentionFinding(status)
298
+ // Only a store this machine still contributes to: a count left from before consent was withdrawn never settles, so it is no finding.
299
+ const captureCheck = status === UNREADABLE ? [] : captureCheckFindings(status).filter(({ store }) => PATTERNS.prRepo.test(store) && decision(records, store) === "yes")
300
+ const captureDropped = status === UNREADABLE ? [] : captureDroppedFindings(status, Date.now()).filter(({ store }) => PATTERNS.prRepo.test(store) && decision(records, store) === "yes")
301
+ const coverageKept = status === UNREADABLE ? null : coverageKeptFinding(status)
302
+ return {
303
+ store: routing.store,
304
+ source: routing.source,
305
+ consent: routing.store === null ? "held" : decision(records, routing.store),
306
+ stores: stores.map((store) => storeEntry(dir, records, store, lastFlush, place, Date.now())),
307
+ warnings: [...new Set(routing.warnings.map((warning) => warning.code))].sort(),
308
+ ...(orphans === null ? {} : { orphans }),
309
+ ...(unasked.length > 0 ? { visibility_unasked: unasked } : {}),
310
+ ...(hung > 0 ? { orphans_hung: hung } : {}),
311
+ ...(retention === null ? {} : { retention }),
312
+ ...(captureCheck.length > 0 ? { capture_check_unavailable: captureCheck } : {}),
313
+ ...(captureDropped.length > 0 ? { capture_dropped: captureDropped } : {}),
314
+ ...(coverageKept === null ? {} : { coverage_kept: coverageKept }),
315
+ ...heldFields(routing, pluginScanReason, status === UNREADABLE ? {} : status),
316
+ }
317
+ }
318
+
319
+ const HELD_PRUNED_SHOWN_MS = 30 * 24 * 60 * 60 * 1000
320
+ const described = (reason, file) => ({ reason, path: file, remedy: HOLD_REMEDIES[reason] })
321
+
322
+ // What holds routes, with the paths to fix and the remedy (`held-route.js`): this desk's own route now (`held_by`), the sessions the last sweep
323
+ // counted as held (`route_holds`), and the held sessions pruned uncaptured (`held_pruned`). Present only when there is something to say.
324
+ function heldFields(routing, scanReason, status) {
325
+ const fields = {}
326
+ if (routing.store === null && routing.warnings.length > 0) fields.held_by = routing.warnings.map(({ code, manifest }) => described(holdReason(manifest, { code }), manifest))
327
+ else if (routing.source === "plugin_scan_incomplete") fields.held_by = [described(Object.hasOwn(HOLD_REMEDIES, scanReason ?? "") ? scanReason : "plugin_scan_incomplete", null)]
328
+ const holds = status.route_holds
329
+ if (isPlainObject(holds) && Number.isSafeInteger(holds.count) && holds.count > 0 && Array.isArray(holds.reasons)) {
330
+ const reasons = holds.reasons.filter((entry) => isPlainObject(entry) && (entry.path === null || typeof entry.path === "string") && Number.isSafeInteger(entry.sessions))
331
+ fields.route_holds = { count: holds.count, reasons: reasons.map((entry) => ({ ...described(holdReason(entry.path, { code: entry.code }), entry.path), sessions: entry.sessions })) }
332
+ }
333
+ const sessions = status.held_sessions
334
+ if (isPlainObject(sessions) && Array.isArray(sessions.groups)) {
335
+ const groups = sessions.groups.filter((group) => isPlainObject(group) && typeof group.route === "string" && typeof group.reason === "string" && Number.isSafeInteger(group.sessions) && group.sessions > 0 && typeof group.oldest_at === "string")
336
+ if (groups.length > 0) fields.held_groups = groups.map(({ route, reason, sessions: count, oldest_at: oldest }) => ({ route, reason, sessions: count, oldest_at: oldest }))
337
+ }
338
+ const pruned = status.held_pruned
339
+ // Said for 30 days after the last such prune: long enough to be read, never a standing line.
340
+ const recent = isPlainObject(pruned) && Date.now() - Date.parse(pruned.last_at) <= HELD_PRUNED_SHOWN_MS
341
+ if (recent && Number.isSafeInteger(pruned.count) && pruned.count > 0) fields.held_pruned = { count: pruned.count, last_at: pruned.last_at }
342
+ return fields
343
+ }
344
+
345
+ /**
346
+ * The job ID a task card may link for plain job ID `job` of the desk at `deskRemote`, read from this machine's factory state without creating
347
+ * anything: `{ job }` for a desk whose cached visibility is `private` or `internal`, else `{ job: null, reason }` with `visibility_not_known`
348
+ * (a GitHub desk whose cached answer is expired, absent or unreadable) or `desk_not_private` (any other desk). See the header.
349
+ */
350
+ export function publishedJobId({ env, deskRemote, job, now = Date.now() }) {
351
+ const repo = githubRepoOfRemote(deskRemote)
352
+ if (repo === null) return { job: null, reason: "desk_not_private" }
353
+ const cached = readState(path.join(factoryStateDir(env), "visibility.json"), {})
354
+ const known = cached === UNREADABLE ? new Map() : visibilityMap(freshVisibility(cached, now))
355
+ if (!known.has(repo.toLowerCase())) return { job: null, reason: "visibility_not_known" }
356
+ return deskTimingKept(deskVisibilityOf(repo, known)) ? { job } : { job: null, reason: "desk_not_private" }
357
+ }
358
+
359
+ /**
360
+ * See the header: `{ link }`, the task card's `factory_report` link; `{ link: null, reason }` when the desk contributes but no link can be
361
+ * named; `{ link: null }` when the resolved store has no consent `contribute: true`, so the factory is not in use for this desk.
362
+ */
363
+ export function factoryReportLink({ env, deskRoot, deskRemote, personPrefix, track, slug, pluginDirs = [], pluginScanIncomplete = false }) {
364
+ const routing = route({ deskRoot, pluginDirs, pluginScanIncomplete })
365
+ if (routing.store === null || decision(consentRecords(factoryStateDir(env)), routing.store) !== "yes") return { link: null }
366
+ const { job, reason } = publishedJobId({ env, deskRemote, job: jobId({ deskRemote, personPrefix, track, slug }) })
367
+ return job === null ? { link: null, reason } : { link: jobReportUrl({ store: routing.store, job }) }
368
+ }
@@ -0,0 +1,121 @@
1
+ // The loop's conditions record. For each improvement-card key `<source>:<id>` it keeps, in `status.json` under
2
+ // `loop.conditions`, whether the condition held at the last successful observation and how many counted
3
+ // observations in a row found it clear. The route collectors write it; the measure and verify steps read it,
4
+ // so "the condition was false at 2 consecutive measures" is stated once. A missing or damaged entry reads as
5
+ // unavailable, never as clear, and an observation that could not be made is never recorded. Keys are the card
6
+ // library's own, so nothing but a well-formed key enters, and no free text is stored.
7
+
8
+ import { SOURCES, cardKey } from "../desk/improvement-cards.js"
9
+ import { PATTERNS } from "./schema.js"
10
+ import { isHeadlessFactorySession } from "./headless-flag.js"
11
+ import { updateStatus } from "./outbox.js"
12
+
13
+ /** The shortest time between two observations of a source that both count as a clear run, in hours. Two looks closer together are one look. */
14
+ export const MIN_OBSERVATION_GAP_HOURS = 6
15
+
16
+ /** The most keys kept. Over it, keys that are not present go first (damaged, then the longest since observed, then the fewest clear runs); a present key is never dropped. */
17
+ export const MAX_CONDITIONS = 500
18
+
19
+ const HOUR_MS = 3600 * 1000
20
+
21
+ const isObject = (value) => typeof value === "object" && value !== null && !Array.isArray(value)
22
+ const timeOf = (value) => (typeof value === "string" && PATTERNS.timestamp.test(value) ? Date.parse(value) : Number.NaN)
23
+
24
+ const isValidEntry = (entry) =>
25
+ isObject(entry) &&
26
+ typeof entry.present === "boolean" &&
27
+ Number.isSafeInteger(entry.clear_runs) && entry.clear_runs >= 0 &&
28
+ !(entry.present && entry.clear_runs !== 0) &&
29
+ !Number.isNaN(timeOf(entry.observed_at))
30
+
31
+ /** `conditionOf(status, key) -> { state: "measured", present, clear_runs, observed_at } | { state: "unavailable", reason: "not_observed" | "damaged" }`. */
32
+ export function conditionOf(status, key) {
33
+ const conditions = isObject(status?.loop) ? status.loop.conditions : undefined
34
+ if (conditions === undefined) return { state: "unavailable", reason: "not_observed" }
35
+ if (!isObject(conditions)) return { state: "unavailable", reason: "damaged" }
36
+ if (!Object.hasOwn(conditions, key)) return { state: "unavailable", reason: "not_observed" }
37
+ const entry = conditions[key]
38
+ if (!isValidEntry(entry)) return { state: "unavailable", reason: "damaged" }
39
+ return { state: "measured", present: entry.present, clear_runs: entry.clear_runs, observed_at: entry.observed_at }
40
+ }
41
+
42
+ function wellFormedKeys(source, present) {
43
+ const keys = new Set()
44
+ for (const id of present) {
45
+ try {
46
+ if (typeof id !== "string") return null
47
+ keys.add(cardKey(source, id))
48
+ } catch {
49
+ return null
50
+ }
51
+ }
52
+ return keys
53
+ }
54
+
55
+ /** Drops keys over the bound, worst first; present keys are kept even when they alone exceed it. */
56
+ function bounded(conditions) {
57
+ const keys = Object.keys(conditions)
58
+ let over = keys.length - MAX_CONDITIONS
59
+ if (over <= 0) return conditions
60
+ const rank = (key) => {
61
+ const entry = conditions[key]
62
+ if (!isValidEntry(entry)) return [0, 0, 0]
63
+ return entry.present ? null : [1, timeOf(entry.observed_at), entry.clear_runs]
64
+ }
65
+ const droppable = keys.map((key) => ({ key, rank: rank(key) })).filter((item) => item.rank !== null)
66
+ droppable.sort((a, b) => a.rank[0] - b.rank[0] || a.rank[1] - b.rank[1] || a.rank[2] - b.rank[2])
67
+ const kept = { ...conditions }
68
+ for (const { key } of droppable) {
69
+ if (over-- <= 0) break
70
+ delete kept[key]
71
+ }
72
+ return kept
73
+ }
74
+
75
+ /**
76
+ * `observeConditions(env, { source, present, now, updateStatusImpl }) -> { ok, result }`: records one successful observation of `source`.
77
+ * `present` is every id of that source whose condition holds right now. A key in `present` is recorded as present with 0 clear runs; every other
78
+ * key of the source already recorded is recorded as not present with one more clear run, unless the last counted look at it was less than
79
+ * `MIN_OBSERVATION_GAP_HOURS` ago (then it is not counted again). A damaged entry of an absent key is left as it is, so it never reads as clear.
80
+ * A collector that could not look must not call this. Results: `observed`, `observed_within_gap` (ok); `headless_session`, `invalid_source`,
81
+ * `invalid_present`, `invalid_key`, `invalid_time`, `status_unwritable` (not ok, nothing written).
82
+ */
83
+ export async function observeConditions(env, { source, present, now = new Date(), updateStatusImpl = updateStatus }) {
84
+ if (isHeadlessFactorySession(env)) return { ok: false, result: "headless_session" }
85
+ if (!SOURCES.includes(source)) return { ok: false, result: "invalid_source" }
86
+ if (!Array.isArray(present)) return { ok: false, result: "invalid_present" }
87
+ const keys = wellFormedKeys(source, present)
88
+ if (keys === null) return { ok: false, result: "invalid_key" }
89
+ const nowMs = now === null ? Number.NaN : new Date(now).getTime()
90
+ if (Number.isNaN(nowMs)) return { ok: false, result: "invalid_time" }
91
+ const stamp = new Date(nowMs).toISOString()
92
+ let counted = false
93
+ let skipped = false
94
+ try {
95
+ await updateStatusImpl(env, (current) => {
96
+ const loop = isObject(current.loop) ? current.loop : {}
97
+ const before = isObject(loop.conditions) ? loop.conditions : {}
98
+ const next = { ...before }
99
+ counted = false
100
+ skipped = false
101
+ for (const key of keys) next[key] = { present: true, clear_runs: 0, observed_at: stamp, counted_at: stamp }
102
+ for (const [key, entry] of Object.entries(before)) {
103
+ if (keys.has(key) || !key.startsWith(`${source}:`) || !isValidEntry(entry)) continue
104
+ const lastCounted = Number.isNaN(timeOf(entry.counted_at)) ? timeOf(entry.observed_at) : timeOf(entry.counted_at)
105
+ const elapsed = nowMs - lastCounted
106
+ const countsNow = elapsed >= MIN_OBSERVATION_GAP_HOURS * HOUR_MS
107
+ if (countsNow) counted = true
108
+ else skipped = true
109
+ // A clock that moved back, or an entry dated ahead, never counts; the stamp is pulled back to now so it blocks for at most one gap.
110
+ const stampKept = new Date(Math.min(lastCounted, nowMs)).toISOString()
111
+ next[key] = countsNow
112
+ ? { present: false, clear_runs: entry.clear_runs + 1, observed_at: stamp, counted_at: stamp }
113
+ : { present: false, clear_runs: entry.clear_runs, observed_at: stamp, counted_at: stampKept }
114
+ }
115
+ return { ...current, loop: { ...loop, conditions: bounded(next) } }
116
+ })
117
+ } catch {
118
+ return { ok: false, result: "status_unwritable" }
119
+ }
120
+ return { ok: true, result: skipped && !counted ? "observed_within_gap" : "observed" }
121
+ }