@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,22 @@
1
+ import * as path from "node:path"
2
+ import { deskPluginRoot, deskVersion } from "../package-metadata.js"
3
+
4
+ /**
5
+ * Who is serving this call, read from the serving process alone: no search, index, git or network read, so desk_status can
6
+ * attach it to every answer even when the slow runtime status misses its budget. `plugin_root` is the plugin folder the tools
7
+ * load from (the newest release's copy when Desk runs that), and `loaded` is false until the runtime's source mirror is.
8
+ */
9
+ export function runtimeIdentity({ env, runtime }) {
10
+ const loadedRoot = typeof runtime?.plugin_root === "string" && runtime.plugin_root !== "" ? runtime.plugin_root : null
11
+ const pluginRoot = loadedRoot ?? deskPluginRoot(env)
12
+ const mirror = runtime?.source_mirror_path ?? runtime?.sourceMirrorPath ?? null
13
+ const mirrorPath = typeof mirror === "string" && mirror !== "" ? mirror : null
14
+ return {
15
+ plugin: { name: "desk", version: deskVersion({ DESK_PLUGIN_ROOT: pluginRoot }) },
16
+ plugin_root: pluginRoot,
17
+ source_mirror_path: mirrorPath,
18
+ source_mirror_hash: mirrorPath === null ? null : path.basename(mirrorPath),
19
+ loaded: mirrorPath !== null,
20
+ ...(runtime?.newest_release === undefined ? {} : { newest_release: runtime.newest_release }),
21
+ }
22
+ }
@@ -0,0 +1,101 @@
1
+ // Keeps a long-running Desk server current. A host keeps one MCP server per project folder for days and routes every new chat to
2
+ // it, so the release the server loaded when it started (src/runtime/newest-release.js) goes stale. This watcher checks the
3
+ // `release` channel on a call, in the background, prepares the newer runtime beside the serving one, and hands it to the caller,
4
+ // which swaps it in between calls. A call already running finishes on the code it started with.
5
+ //
6
+ // Nothing here blocks a call or throws: a check or load that fails leaves the serving runtime in place and records why, so
7
+ // `desk_status` and the browser's replies can say so (`runtime.refresh`).
8
+
9
+ /** At most one check this often, however many calls arrive. */
10
+ export const REFRESH_INTERVAL_MS = 10 * 60 * 1000
11
+ /** `desk_status` is how an agent asks "is Desk current?", so it may check this often. */
12
+ const STATUS_REFRESH_INTERVAL_MS = 30 * 1000
13
+
14
+ const SWITCH = "DESK_RUNTIME_REFRESH"
15
+
16
+ const short = (error) => String(error?.message ?? error).split("\n")[0].slice(0, 120)
17
+
18
+ /** Why refreshing is off, or null. `DESK_RUNTIME_REFRESH=0` turns it off; `DESK_RUNTIME_REFRESH_MINUTES` sets the interval. */
19
+ function refreshSwitch(env) {
20
+ return String(env[SWITCH] ?? "").trim() === "0" ? `${SWITCH}=0` : null
21
+ }
22
+
23
+ export function refreshIntervalMs(env) {
24
+ const minutes = Number(env.DESK_RUNTIME_REFRESH_MINUTES)
25
+ return Number.isFinite(minutes) && minutes > 0 ? Math.round(minutes * 60 * 1000) : REFRESH_INTERVAL_MS
26
+ }
27
+
28
+ /**
29
+ * `prepare({ running })` finds out whether a newer release exists and, if so, has it loaded: it resolves to one of
30
+ * - `{ state: "not_applicable", reason }`: this install does not follow the release channel
31
+ * - `{ state: "current", latest }`
32
+ * - `{ state: "failed", latest, reason }`: a fetch or load that did not finish; the serving runtime stays
33
+ * - `{ state: "ready", latest, loaded }`: `loaded` is what the caller swaps in (`{ runtimeServer, runtimeStatus }`)
34
+ */
35
+ export function createRuntimeRefresher({ prepare, env = process.env, now = Date.now, intervalMs = refreshIntervalMs(env), log = () => {} }) {
36
+ const disabled = refreshSwitch(env)
37
+ let checking = null
38
+ let checkedAt = null
39
+ let startedAt = null
40
+ let pending = null
41
+ let outcome = disabled === null ? { state: "idle" } : { state: "not_applicable", reason: disabled }
42
+ let swap = null
43
+
44
+ const iso = () => new Date(now()).toISOString()
45
+
46
+ async function check(running) {
47
+ try {
48
+ const result = await prepare({ running })
49
+ checkedAt = iso()
50
+ if (result.state === "ready") {
51
+ pending = { loaded: result.loaded, latest: result.latest }
52
+ outcome = { state: "ready_to_swap", latest: result.latest }
53
+ } else {
54
+ outcome = { state: result.state, latest: result.latest, reason: result.reason }
55
+ }
56
+ } catch (error) {
57
+ checkedAt = iso()
58
+ outcome = { state: "failed", reason: `the check threw (${short(error)})` }
59
+ }
60
+ if (outcome.state === "failed") log(`runtime refresh failed: ${outcome.reason}; the serving runtime stays`)
61
+ }
62
+
63
+ return {
64
+ /** Starts a background check when none is running and the last one is older than the interval (`soon`: the shorter one for a caller asking whether Desk is current). Returns whether one started. */
65
+ poke({ running, soon = false } = {}) {
66
+ if (disabled !== null || checking !== null || pending !== null) return false
67
+ if (startedAt !== null && now() - startedAt < (soon ? Math.min(intervalMs, STATUS_REFRESH_INTERVAL_MS) : intervalMs)) return false
68
+ startedAt = now()
69
+ outcome = { state: "checking" }
70
+ checking = check(running).finally(() => { checking = null })
71
+ return true
72
+ },
73
+ /** The prepared runtime, once; the caller swaps it in and then calls `swapped`. */
74
+ take() {
75
+ const taken = pending
76
+ pending = null
77
+ return taken
78
+ },
79
+ /** A prepared runtime that could not be swapped in (the caller refused or failed): the serving one stays, and the next check retries. */
80
+ abandoned(reason, latest) {
81
+ outcome = { state: "failed", latest, reason }
82
+ startedAt = null
83
+ log(`runtime refresh failed: ${reason}; the serving runtime stays`)
84
+ },
85
+ swapped({ from, to }) {
86
+ swap = { swapped_at: iso(), from }
87
+ outcome = { state: "swapped", latest: to }
88
+ },
89
+ /** True while a prepared runtime waits for the next call to swap it in. */
90
+ get ready() { return pending !== null },
91
+ /** Resolves when the running check, if any, is done. */
92
+ idle() { return checking ?? Promise.resolve() },
93
+ /** What `runtime` reports about refreshing: the last check, and the last swap (`swapped_at`, `from`). */
94
+ describe() {
95
+ return {
96
+ refresh: { ...outcome, ...(checkedAt === null ? {} : { checked_at: checkedAt }) },
97
+ ...(swap === null ? {} : { swapped_at: swap.swapped_at, from: swap.from }),
98
+ }
99
+ },
100
+ }
101
+ }
@@ -0,0 +1,235 @@
1
+ // Schedules: a prompt a session wants every N minutes, owned by the always-on runtime instead of the app's session automations.
2
+ // The app queues every run it misses while a session is busy and replays them back to back; a schedule here never does. It is
3
+ // the same contract as `drains.js poll`: no model turn, the wakes are printed and the runner delivers them and reports back
4
+ // with `ack`. A schedule is due once however many intervals went by, and its next run is counted from the delivery that
5
+ // landed, so missed runs fold into one. A schedule may carry a `when` gate, an argv the poll runs when the schedule is due so
6
+ // that an unchanged world costs no model turn. See docs/schedules.md.
7
+ import { spawn } from "node:child_process"
8
+ import { createHash } from "node:crypto"
9
+ import { readFileSync, mkdirSync, renameSync, writeFileSync } from "node:fs"
10
+ import * as path from "node:path"
11
+ import { deskFailure } from "./desk-failure.js"
12
+ import { drainsHome } from "./drains.js"
13
+ import { assertNotRealStateUnderTest } from "./test-state-guard.js"
14
+
15
+ const MINUTE_MS = 60_000
16
+ const GATE_OUTPUT_CAP = 2048
17
+ const GATE_STDERR_CAP = 200
18
+ const GATE_DEFAULT_TIMEOUT_S = 30
19
+ const GATE_SKIPPED = "skipped (when: nothing to do)"
20
+
21
+ export function schedulePaths(options) {
22
+ const home = drainsHome(options)
23
+ return { config: path.join(home, "schedules.json"), state: path.join(home, "schedules-state.json"), lock: path.join(home, "schedule.lock") }
24
+ }
25
+
26
+ function problem(code, thing, probably, look, fix) {
27
+ return new Error(deskFailure({ code, thing, probably, look, keepWorking: "no schedule moved and nothing was sent", fix }))
28
+ }
29
+
30
+ const isText = (value) => typeof value === "string" && value.trim() !== ""
31
+
32
+ /** The schedules in a config file's text, validated. A bad entry is an error, never a silent drop: a dropped schedule would stop a watchdog. */
33
+ export function parseScheduleConfig(raw, file) {
34
+ const bad = (what) => problem("desk_schedules_config_invalid", "schedules config", `${file} ${what}, probably a hand edit`, "open the file and compare it with docs/schedules.md", "correct the entry and run the command again")
35
+ let parsed
36
+ try {
37
+ parsed = JSON.parse(raw)
38
+ } catch {
39
+ throw bad("is not valid JSON")
40
+ }
41
+ const list = parsed?.schedules
42
+ if (!Array.isArray(list)) throw bad('has no "schedules" array')
43
+ const names = new Set()
44
+ return list.map((entry, index) => {
45
+ if (entry === null || typeof entry !== "object" || Array.isArray(entry)) throw bad(`schedules[${index}] is not an object`)
46
+ const { session, prompt, everyMinutes, name } = entry
47
+ if (!isText(session)) throw bad(`schedules[${index}].session is not a session id`)
48
+ if (!isText(prompt)) throw bad(`schedules[${index}].prompt is not the text to send`)
49
+ if (!Number.isInteger(everyMinutes) || everyMinutes < 1) throw bad(`schedules[${index}].everyMinutes is not a whole number of minutes, 1 or more`)
50
+ if (name !== undefined && !isText(name)) throw bad(`schedules[${index}].name is not a name`)
51
+ const { when, whenEveryMinutes, whenTimeoutSeconds } = entry
52
+ if (when === undefined && (whenEveryMinutes !== undefined || whenTimeoutSeconds !== undefined)) throw bad(`schedules[${index}] sets whenEveryMinutes or whenTimeoutSeconds without a "when" command`)
53
+ if (when !== undefined && (!Array.isArray(when) || !when.every((part) => typeof part === "string") || !isText(when[0]))) throw bad(`schedules[${index}].when is not an argv array of strings starting with the program to run (never a shell string)`)
54
+ for (const [field, value] of [["whenEveryMinutes", whenEveryMinutes], ["whenTimeoutSeconds", whenTimeoutSeconds]]) {
55
+ if (value !== undefined && (!Number.isInteger(value) || value < 1)) throw bad(`schedules[${index}].${field} is not a whole number, 1 or more`)
56
+ }
57
+ const key = (name ?? session).trim()
58
+ if (names.has(key)) throw bad(`schedules[${index}] reuses the name ${key}; give each schedule on one session its own "name"`)
59
+ names.add(key)
60
+ return { name: key, session: session.trim(), prompt, everyMinutes, ...(when === undefined ? {} : { when: [...when], ...(whenEveryMinutes === undefined ? {} : { whenEveryMinutes }), ...(whenTimeoutSeconds === undefined ? {} : { whenTimeoutSeconds }) }) }
61
+ })
62
+ }
63
+
64
+ export function readScheduleConfig(file) {
65
+ let raw
66
+ try {
67
+ raw = readFileSync(file, "utf8")
68
+ } catch (error) {
69
+ if (error.code !== "ENOENT") throw problem("desk_schedules_config_unreadable", "schedules config", `${file} cannot be read (${error.code}), probably because its owner or permissions changed`, "check the file's permissions", "fix them and run the command again")
70
+ return []
71
+ }
72
+ return parseScheduleConfig(raw, file)
73
+ }
74
+
75
+ export function readScheduleStates(file) {
76
+ try {
77
+ const parsed = JSON.parse(readFileSync(file, "utf8"))
78
+ return parsed !== null && typeof parsed === "object" && !Array.isArray(parsed) ? parsed : {}
79
+ } catch {
80
+ return {}
81
+ }
82
+ }
83
+
84
+ function writeScheduleStates(file, states) {
85
+ assertNotRealStateUnderTest(path.dirname(file))
86
+ mkdirSync(path.dirname(file), { recursive: true })
87
+ const temporary = `${file}.${process.pid}.tmp`
88
+ writeFileSync(temporary, `${JSON.stringify(states, null, 2)}\n`)
89
+ renameSync(temporary, file)
90
+ }
91
+
92
+ const clip = (text, cap) => {
93
+ const trimmed = String(text).trim()
94
+ return trimmed.length > cap ? `${trimmed.slice(0, cap).trimEnd()} … (cut at ${cap} characters)` : trimmed
95
+ }
96
+
97
+ /** Runs a schedule's `when` argv with no shell. Resolves `{ exit, stdout, stderr, timedOut, startError, signal }` and never rejects. */
98
+ function runWhenGate(argv, timeoutSeconds) {
99
+ return new Promise((resolve) => {
100
+ let stdout = ""
101
+ let stderr = ""
102
+ let finished = false
103
+ const finish = (result) => {
104
+ if (finished) return
105
+ finished = true
106
+ clearTimeout(timer)
107
+ resolve({ stdout, stderr, ...result })
108
+ }
109
+ let child
110
+ try {
111
+ child = spawn(argv[0], argv.slice(1), { shell: false, stdio: ["ignore", "pipe", "pipe"], windowsHide: true })
112
+ } catch (error) {
113
+ resolve({ stdout, stderr, startError: error.code })
114
+ return
115
+ }
116
+ const keep = (current, chunk) => (current + chunk).slice(0, GATE_OUTPUT_CAP * 2)
117
+ child.stdout.setEncoding("utf8").on("data", (chunk) => { stdout = keep(stdout, chunk) })
118
+ child.stderr.setEncoding("utf8").on("data", (chunk) => { stderr = keep(stderr, chunk) })
119
+ const timer = setTimeout(() => {
120
+ child.kill("SIGKILL")
121
+ finish({ timedOut: timeoutSeconds })
122
+ }, timeoutSeconds * 1000)
123
+ child.on("error", (error) => finish({ startError: error.code }))
124
+ child.on("close", (exit, signal) => finish({ exit, signal }))
125
+ })
126
+ }
127
+
128
+ /** What a gate run means: whether to send, the text added to the prompt and the record kept for status. */
129
+ function judgeGate(run, now) {
130
+ const at = new Date(now).toISOString()
131
+ if (run.exit === 0) {
132
+ const why = clip(run.stdout, GATE_OUTPUT_CAP)
133
+ return { send: true, addition: why ? `Why now: ${why}` : "", record: { at, result: "delivered (when: exit 0)", ...(why ? { why: clip(why.split("\n")[0], GATE_STDERR_CAP) } : {}) } }
134
+ }
135
+ if (run.exit === 1) return { send: false, record: { at, result: GATE_SKIPPED } }
136
+ const how = run.timedOut ? `timed out after ${run.timedOut}s` : run.startError ? `could not start (${run.startError})` : run.signal ? `ended by signal ${run.signal}` : `exited ${run.exit}`
137
+ const detail = clip(run.stderr.trim().split("\n")[0], GATE_STDERR_CAP)
138
+ const reason = `${how}${detail ? `: ${detail}` : ""}`
139
+ return { send: true, addition: `Note: this schedule's \`when\` gate failed (${reason}), so the prompt is delivered anyway.`, record: { at, result: `gate failed (${reason}), prompt delivered anyway` } }
140
+ }
141
+
142
+ const scheduleWakeId = (schedule, nextAt) => createHash("sha1").update(JSON.stringify([schedule.name, schedule.session, schedule.prompt, nextAt])).digest("hex").slice(0, 16)
143
+
144
+ function span(ms) {
145
+ const minutes = Math.max(0, Math.round(ms / MINUTE_MS))
146
+ return minutes < 1 ? "under 1m" : minutes < 90 ? `${minutes}m` : `${Math.round(minutes / 60)}h`
147
+ }
148
+
149
+ /** One line per schedule: its cadence, when it last landed and when it runs next. */
150
+ export function scheduleStatusLines(schedules, states, now) {
151
+ return schedules.map((schedule) => {
152
+ const state = states[schedule.name]
153
+ const gated = schedule.when ? `, gated by when${schedule.whenEveryMinutes ? ` (checked every ${schedule.whenEveryMinutes}m)` : ""}` : ""
154
+ const head = `schedule ${schedule.name} -> ${schedule.session.slice(0, 8)}: every ${schedule.everyMinutes}m${gated}`
155
+ if (!state?.nextAt) return `${head}, not polled yet`
156
+ const sent = state.lastSentAt ? `last sent ${span(now - Date.parse(state.lastSentAt))} ago` : "never sent"
157
+ const due = Math.max(Date.parse(state.nextAt), state.notBefore ? Date.parse(state.notBefore) : 0)
158
+ const wait = due - now
159
+ const next = wait <= 0 ? "due now" : `next run in ${span(wait)} (${new Date(due).toISOString()})`
160
+ const gate = state.lastGate ? `, last gate: ${state.lastGate.result}${state.lastGate.why ? ` (${state.lastGate.why})` : ""} ${span(now - Date.parse(state.lastGate.at))} ago` : ""
161
+ return `${head}, ${sent}, ${next}${gate}${state.lastError ? `, last error: ${state.lastError}` : ""}`
162
+ })
163
+ }
164
+
165
+ /**
166
+ * Print the schedules that are due. A new schedule is first due one interval after it is first seen. A due schedule is offered
167
+ * once per poll with the same id until a delivery lands, so a runner that holds it (the session still has the last prompt
168
+ * queued) leaves exactly one prompt waiting, never a pile. Each wake names its own text as `replaces`, so a runner takes an
169
+ * older copy still queued in the session back before it sends the new one.
170
+ */
171
+ export async function pollSchedules({ paths, now, ackCommand, ackFlags = [], gate = runWhenGate }) {
172
+ const schedules = readScheduleConfig(paths.config)
173
+ const stored = readScheduleStates(paths.state)
174
+ const states = {}
175
+ for (const schedule of schedules) {
176
+ const previous = stored[schedule.name]
177
+ const reseed = !previous?.nextAt || previous.everyMinutes !== schedule.everyMinutes || previous.whenEveryMinutes !== schedule.whenEveryMinutes
178
+ const { lastSentAt, lastGate } = previous ?? {}
179
+ states[schedule.name] = reseed
180
+ ? { lastSentAt, lastGate, everyMinutes: schedule.everyMinutes, whenEveryMinutes: schedule.whenEveryMinutes, nextAt: new Date(now + (schedule.whenEveryMinutes ?? schedule.everyMinutes) * MINUTE_MS).toISOString() }
181
+ : { ...previous }
182
+ if (!schedule.when) {
183
+ delete states[schedule.name].lastGate
184
+ delete states[schedule.name].notBefore
185
+ }
186
+ }
187
+ const wakes = []
188
+ for (const schedule of schedules) {
189
+ const state = states[schedule.name]
190
+ if (Math.max(Date.parse(state.nextAt), state.notBefore ? Date.parse(state.notBefore) : 0) > now) continue
191
+ const id = scheduleWakeId(schedule, state.nextAt)
192
+ let message = schedule.prompt
193
+ if (schedule.when && state.offered === id && typeof state.offeredMessage === "string") {
194
+ message = state.offeredMessage
195
+ } else if (schedule.when) {
196
+ const judged = judgeGate(await gate(schedule.when, schedule.whenTimeoutSeconds ?? GATE_DEFAULT_TIMEOUT_S), now)
197
+ state.lastGate = judged.record
198
+ if (!judged.send) {
199
+ delete state.offered
200
+ delete state.offeredMessage
201
+ state.nextAt = new Date(now + (schedule.whenEveryMinutes ?? schedule.everyMinutes) * MINUTE_MS).toISOString()
202
+ continue
203
+ }
204
+ if (judged.addition) message = `${schedule.prompt}\n\n${judged.addition}`
205
+ state.offeredMessage = message
206
+ }
207
+ state.offered = id
208
+ wakes.push({ id, name: schedule.name, session: schedule.session, message, replaces: schedule.prompt, done: [...ackCommand, "schedule", "ack", "--name", schedule.name, "--wake", id, ...ackFlags] })
209
+ }
210
+ writeScheduleStates(paths.state, states)
211
+ const errors = schedules.filter((schedule) => states[schedule.name].lastError).map((schedule) => ({ name: schedule.name, error: states[schedule.name].lastError }))
212
+ return { at: new Date(now).toISOString(), wakes, errors, status: scheduleStatusLines(schedules, states, now) }
213
+ }
214
+
215
+ /** Record how a wake went. A delivery that landed moves the next run one interval on from now; a failed one keeps the schedule due. A wake that is not the one offered last is left alone. */
216
+ export function ackSchedule({ paths, name, wake, error, now }) {
217
+ const states = readScheduleStates(paths.state)
218
+ const state = states[name]
219
+ if (!state || state.offered !== wake) return { ok: true, changed: false, reason: "this wake is not the one waiting, so the next poll offers the current one" }
220
+ if (error) {
221
+ state.lastError = `the prompt was not delivered: ${error}`
222
+ } else {
223
+ delete state.lastError
224
+ delete state.offered
225
+ delete state.offeredMessage
226
+ states[name] = {
227
+ ...state,
228
+ lastSentAt: new Date(now).toISOString(),
229
+ nextAt: new Date(now + (state.whenEveryMinutes ?? state.everyMinutes) * MINUTE_MS).toISOString(),
230
+ ...(state.whenEveryMinutes ? { notBefore: new Date(now + state.everyMinutes * MINUTE_MS).toISOString() } : {}),
231
+ }
232
+ }
233
+ writeScheduleStates(paths.state, states)
234
+ return { ok: true, changed: true, reason: error ? "recorded the failed delivery; the schedule stays due" : "recorded the delivery and moved the next run one interval on" }
235
+ }
@@ -0,0 +1,190 @@
1
+ // What one Copilot session's own history (`<session-state>/<id>/events.jsonl`) says about it: whether its last turn ended, what
2
+ // still runs after it, and which Desk task it declared with `task_focus`. Histories reach hundreds of MB, so every read runs
3
+ // backwards in bounded chunks and parses only the few lines that matter. Nothing here writes.
4
+ import { readFileSync } from "node:fs"
5
+ import { open } from "node:fs/promises"
6
+ import * as os from "node:os"
7
+ import * as path from "node:path"
8
+ import { declaredFocus } from "../factory/derive-common.js"
9
+
10
+ const CHUNK_BYTES = 1024 * 1024
11
+ /** How far back the open-work scan reads before it gives up and reports what it saw. */
12
+ const OPEN_WORK_SCAN_BYTES = 48 * 1024 * 1024
13
+ /** How far back a focus search reads, in total across polls (a cached answer stops it at the bytes already read). */
14
+ const FOCUS_SCAN_BYTES = 1024 * 1024 * 1024
15
+
16
+ const TYPE = /^\{"type":"([^"]+)"/u
17
+ const TIMESTAMP = /"timestamp":"([^"]+)"/u
18
+ const OWNER_AGENT = /"agentId":"([^"]*)","id":"[^"]*","timestamp"/u
19
+ const TOOL_CALL = /"toolCallId":"([^"]+)"/u
20
+ const SHELL_STARTED = /shellId: (\d+)(?:>| is still running)/u
21
+ const FOCUS_START = /"toolName":"(?:[^"]*[-_.])?(task_focus|task_create)"/u
22
+ const BLOCKING_TOOL = /"toolName":"(?:[^"]*[-_.])?(ask_user|exit_plan_mode)"/u
23
+ const STOPPED_SHELL = /"shellId":"?(\d+)"?/u
24
+
25
+ // The events that show what the main agent is doing. Hooks, usage records and model snapshots are not.
26
+ const MEANINGFUL = new Set([
27
+ "user.message", "assistant.turn_start", "assistant.turn_end", "assistant.message", "abort", "tool.execution_start", "tool.execution_complete",
28
+ "permission.requested", "permission.completed", "system.notification", "subagent.started", "subagent.completed", "subagent.failed",
29
+ "external_tool.requested", "external_tool.completed", "session.task_complete", "session.start", "session.resume", "session.shutdown",
30
+ ])
31
+ const BOUNDARY = new Set(["session.start", "session.resume", "session.shutdown"])
32
+ // A turn that ended cleanly: the agent stopped on its own.
33
+ const ENDED = new Set(["assistant.turn_end", "session.task_complete"])
34
+
35
+ /** The Copilot app's data folder: `COPILOT_HOME`, else `~/.copilot`. */
36
+ export function copilotHome(env) {
37
+ return env.COPILOT_HOME || path.join(os.homedir(), ".copilot")
38
+ }
39
+
40
+ export const sessionStateDir = (env) => path.join(copilotHome(env), "session-state")
41
+
42
+ /** The lines of a file from the last to the first, as strings, reading `CHUNK_BYTES` at a time without holding the event loop. `stopAt` is a byte offset at a line start; reading ends there or after `maxBytes`. */
43
+ async function* reverseLines(file, { stopAt, maxBytes }) {
44
+ const handle = await open(file, "r")
45
+ try {
46
+ let position = (await handle.stat()).size
47
+ let carry = Buffer.alloc(0)
48
+ let consumed = 0
49
+ while (position > stopAt && consumed < maxBytes) {
50
+ const length = Math.min(CHUNK_BYTES, position - stopAt)
51
+ position -= length
52
+ const chunk = Buffer.allocUnsafe(length)
53
+ await handle.read(chunk, 0, length, position)
54
+ consumed += length
55
+ const data = Buffer.concat([chunk, carry])
56
+ let end = data.length
57
+ while (end > 0) {
58
+ const newline = data.lastIndexOf(10, end - 1)
59
+ if (newline === -1) break
60
+ if (end - newline > 1) yield data.toString("utf8", newline + 1, end)
61
+ end = newline
62
+ }
63
+ carry = Buffer.from(data.subarray(0, end))
64
+ }
65
+ // The oldest fragment: the first line when the read reached it, else a partial line no reader parses.
66
+ yield carry.toString("utf8")
67
+ } finally {
68
+ await handle.close()
69
+ }
70
+ }
71
+
72
+ const isSubagentOwned = (line) => OWNER_AGENT.test(line.slice(-400))
73
+
74
+ /** The main agent's last meaningful event, as `{ type, at, ms, ended, stoppedByPerson, closed }`, or null for a history with none. A subagent's own events are skipped. */
75
+ export async function lastActivity(file) {
76
+ for await (const line of reverseLines(file, { stopAt: 0, maxBytes: 8 * 1024 * 1024 })) {
77
+ const type = TYPE.exec(line)?.[1]
78
+ if (!MEANINGFUL.has(type) || (!type.startsWith("subagent.") && isSubagentOwned(line))) continue
79
+ const at = TIMESTAMP.exec(line.slice(-400))?.[1]
80
+ // A last line still being written has no timestamp yet.
81
+ if (at === undefined) continue
82
+ return { type, at, ms: Date.parse(at), ended: ENDED.has(type), stoppedByPerson: type === "abort" && line.includes('"reason":"user_initiated"'), closed: type === "session.shutdown" }
83
+ }
84
+ return null
85
+ }
86
+
87
+ /** Whether the main agent's last message with text is a final report (Asked / Delivered / Accept or send back?), which is how a session that is truly done ends. */
88
+ export async function endsWithFinalReport(file) {
89
+ for await (const line of reverseLines(file, { stopAt: 0, maxBytes: 8 * 1024 * 1024 })) {
90
+ if (TYPE.exec(line)?.[1] !== "assistant.message" || isSubagentOwned(line)) continue
91
+ let text
92
+ try {
93
+ text = String(JSON.parse(line).data.content ?? "")
94
+ } catch {
95
+ continue
96
+ }
97
+ if (text.trim() !== "") return /^\W*Asked\b.*:/mu.test(text) && /^\W*Delivered\b.*:/mu.test(text)
98
+ }
99
+ return false
100
+ }
101
+
102
+ /**
103
+ * What still runs after the main agent's last turn: subagents that started and never finished, background shells that never
104
+ * reported completion, and a question or plan waiting on a person. The scan stops at the last session start, resume or shutdown,
105
+ * because nothing survives one, or at `maxBytes` back.
106
+ */
107
+ export async function openWork(file) {
108
+ const finishedSubagents = new Set()
109
+ const cancelledAgents = new Set()
110
+ const finishedShells = new Set()
111
+ const finishedTools = new Set()
112
+ const subagents = []
113
+ const shells = new Set()
114
+ const waiting = []
115
+ for await (const line of reverseLines(file, { stopAt: 0, maxBytes: OPEN_WORK_SCAN_BYTES })) {
116
+ const type = TYPE.exec(line)?.[1]
117
+ if (BOUNDARY.has(type)) break
118
+ const id = TOOL_CALL.exec(line)?.[1]
119
+ const owner = OWNER_AGENT.exec(line.slice(-400))?.[1]
120
+ if (type === "subagent.completed" || type === "subagent.failed") finishedSubagents.add(id)
121
+ else if (type === "abort" && line.includes('"subagent_cancelled"')) cancelledAgents.add(owner)
122
+ else if (type === "subagent.started" && !finishedSubagents.has(id) && !cancelledAgents.has(owner)) subagents.push(id)
123
+ else if (type === "system.notification" && line.includes('"shell_completed"')) finishedShells.add(STOPPED_SHELL.exec(line)?.[1])
124
+ else if (type === "permission.completed") finishedTools.add(id)
125
+ else if (type === "permission.requested" && !finishedTools.has(id)) waiting.push("a permission prompt")
126
+ else if (type === "tool.execution_complete") {
127
+ finishedTools.add(id)
128
+ const shell = owner === undefined ? SHELL_STARTED.exec(line)?.[1] : undefined
129
+ if (shell !== undefined && !finishedShells.has(shell)) shells.add(shell)
130
+ } else if (type === "tool.execution_start" && owner === undefined) {
131
+ if (line.includes('"toolName":"stop_bash"')) finishedShells.add(STOPPED_SHELL.exec(line.slice(line.indexOf('"arguments"')))?.[1])
132
+ const blocking = BLOCKING_TOOL.exec(line)?.[1]
133
+ if (blocking !== undefined && !finishedTools.has(id)) waiting.push(blocking === "ask_user" ? "a question for a person" : "a plan waiting for approval")
134
+ }
135
+ }
136
+ return { subagents: subagents.length, shells: shells.size, waiting }
137
+ }
138
+
139
+ /**
140
+ * The task the main agent last declared: `{ focus: { track, slug } | null, size, fresh }`. `focus` is null when the last declaration cleared it
141
+ * or none was found; `fresh` says a declaration was read now. A `cached` answer (`{ size, focus }` from an earlier read) makes the scan stop
142
+ * at the bytes it already covered, so only new history is read.
143
+ */
144
+ export async function findFocus(file, { cached = null } = {}) {
145
+ const size = await fileSize(file)
146
+ if (cached !== null && cached.size === size) return { focus: cached.focus, size, fresh: false }
147
+ const failed = new Set()
148
+ for await (const line of reverseLines(file, { stopAt: cached === null ? 0 : cached.size, maxBytes: FOCUS_SCAN_BYTES })) {
149
+ const type = TYPE.exec(line)?.[1]
150
+ if (type === "tool.execution_complete") {
151
+ if (line.includes('"success":false')) failed.add(TOOL_CALL.exec(line)?.[1])
152
+ continue
153
+ }
154
+ const verb = type === "tool.execution_start" ? FOCUS_START.exec(line.slice(0, 600))?.[1] : undefined
155
+ if (verb === undefined || isSubagentOwned(line)) continue
156
+ let event
157
+ try {
158
+ event = JSON.parse(line)
159
+ } catch {
160
+ // A last line still being written.
161
+ continue
162
+ }
163
+ if (failed.has(event.data.toolCallId)) continue
164
+ const declared = declaredFocus(verb, event.data.arguments)
165
+ if (declared === null) continue
166
+ return { focus: declared.clear === true ? null : { track: declared.track, slug: declared.slug }, size, fresh: true }
167
+ }
168
+ return { focus: cached === null ? null : cached.focus, size, fresh: false }
169
+ }
170
+
171
+ async function fileSize(file) {
172
+ const handle = await open(file, "r")
173
+ try {
174
+ return (await handle.stat()).size
175
+ } finally {
176
+ await handle.close()
177
+ }
178
+ }
179
+
180
+ /** `{ cwd, gitRoot, name }` from a session's `workspace.yaml`, each null when missing (a name written as a block or a quoted scalar counts as missing). */
181
+ export function readWorkspaceFile(file) {
182
+ let raw = ""
183
+ try {
184
+ raw = readFileSync(file, "utf8")
185
+ } catch {
186
+ // No file reads as no fields.
187
+ }
188
+ const field = (key, first = ".") => new RegExp(`^${key}: (${first}.*)$`, "mu").exec(raw)?.[1].trim() ?? null
189
+ return { cwd: field("cwd"), gitRoot: field("git_root"), name: field("name", "[^|>'\"]") }
190
+ }
@@ -0,0 +1,30 @@
1
+ import { isCredentialLike } from "../factory/credential.js"
2
+
3
+ const unavailable = (code) => ({ state: "unavailable", code })
4
+ const UNSAFE_TEXT = /[\p{Cc}\p{Cf}\p{Cs}\\/@]|\b(?:https?|file|data|mailto):|\bwww\.|(?:^|\s)~|^[a-z]:/iu
5
+ const CREDENTIAL_VALUE = /\b(?:password|api[_-]?key|access[_-]?token|secret)\s*[:=]\s*\S+|\bbearer\s+\S+/iu
6
+ const isTaskSegment = (value) => typeof value === "string" && value.trim() !== "" &&
7
+ value !== "." && value !== ".." && !/[/\\\p{Cc}]/u.test(value)
8
+
9
+ // A task observation proposes display text only. Native identity, freshness,
10
+ // activity and manual-name ownership must be established by its consumer.
11
+ export function makeSessionLabelProposal({ task, displayLabel, focused = true }) {
12
+ if (focused !== true) return unavailable("awaiting_focus")
13
+ if (!isTaskSegment(task?.track) || !isTaskSegment(task?.slug)) return unavailable("owner_unknown")
14
+ if (displayLabel === undefined) return unavailable("missing_safe_label")
15
+ if (typeof displayLabel !== "string") return unavailable("unsafe_label")
16
+ const text = displayLabel.trim()
17
+ if (text === "" || [...text].length > 72 || UNSAFE_TEXT.test(displayLabel) ||
18
+ CREDENTIAL_VALUE.test(text) || isCredentialLike(text) ||
19
+ [...text.matchAll(/(?:^|[^\p{L}\p{N}])/gu)]
20
+ .some((match) => isCredentialLike(text.slice(match.index + match[0].length)))) return unavailable("unsafe_label")
21
+ return {
22
+ proposal: {
23
+ version: 1,
24
+ task: { track: task.track, slug: task.slug },
25
+ text,
26
+ phase: "unknown",
27
+ origin: "automatic",
28
+ },
29
+ }
30
+ }