@uniqbit/mate-core 1.0.0-canary.0 → 1.0.0-canary.2

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 (325) hide show
  1. package/claude-capability-plugins/companion-mentions/.claude-plugin/marketplace.json +14 -0
  2. package/claude-capability-plugins/companion-mentions/.claude-plugin/plugin.json +8 -0
  3. package/claude-capability-plugins/companion-mentions/hooks/companion.ts +457 -0
  4. package/claude-capability-plugins/companion-mentions/hooks/hooks.json +1 -0
  5. package/claude-capability-plugins/companion-mentions/hooks/register.ts +403 -0
  6. package/claude-plugin/hooks/hooks.json +10 -1
  7. package/claude-plugin/hooks/tokensave-route.mjs +52 -0
  8. package/opencode-plugin/src/server.ts +4 -0
  9. package/opencode-plugin/src/tui.tsx +2 -0
  10. package/opencode-plugin/tui.tsx +2 -0
  11. package/package.json +45 -16
  12. package/src/brand/terminal.ts +5 -0
  13. package/src/cli/commands/artifact/apply-context.ts +275 -0
  14. package/src/cli/commands/artifact/artifact.ts +4 -0
  15. package/src/cli/commands/artifact/delivery/archive.ts +13 -5
  16. package/src/cli/commands/artifact/delivery/environment.ts +36 -13
  17. package/src/cli/commands/artifact/delivery/link.ts +35 -15
  18. package/src/cli/commands/artifact/delivery/output.ts +31 -0
  19. package/src/cli/commands/artifact/finish/command.ts +50 -5
  20. package/src/cli/commands/artifact/finish/engine.ts +44 -11
  21. package/src/cli/commands/artifact/finish/git.ts +132 -19
  22. package/src/cli/commands/artifact/finish/openspec.ts +6 -1
  23. package/src/cli/commands/artifact/finish/worktree-cleanup.ts +92 -0
  24. package/src/cli/commands/cap/index-cmd.ts +64 -15
  25. package/src/cli/commands/cap/tokensave.ts +7 -5
  26. package/src/cli/commands/companion/link.ts +14 -1
  27. package/src/cli/commands/companion/open.ts +16 -11
  28. package/src/cli/commands/companion/sync.ts +10 -0
  29. package/src/cli/commands/companion/tui.ts +17 -7
  30. package/src/cli/commands/companion/update.ts +74 -12
  31. package/src/cli/commands/doctor.ts +20 -5
  32. package/src/cli/commands/factory/factory.ts +301 -0
  33. package/src/cli/commands/install.ts +133 -9
  34. package/src/cli/commands/launch/shared.ts +16 -11
  35. package/src/cli/commands/report/index.ts +20 -1
  36. package/src/cli/commands/session/context.ts +102 -0
  37. package/src/cli/commands/setup.ts +44 -10
  38. package/src/cli/commands/studio/factory-credential.ts +49 -0
  39. package/src/cli/commands/studio/index.ts +29 -2
  40. package/src/cli/commands/studio/payload.ts +249 -15
  41. package/src/cli/commands/studio/routes.ts +41 -8
  42. package/src/cli/commands/studio/selection.ts +142 -16
  43. package/src/cli/commands/studio/server.ts +403 -364
  44. package/src/cli/commands/studio/services.ts +60 -0
  45. package/src/cli/commands/studio/studio-app.ts +67 -0
  46. package/src/cli/commands/studio/terminal-assets.ts +21 -33
  47. package/src/cli/commands/studio/terminal.ts +85 -15
  48. package/src/cli/commands/studio/views/model.ts +18 -0
  49. package/src/cli/commands/studio/views/vault/markdown-tree.ts +267 -0
  50. package/src/cli/commands/studio/views/vault/view.ts +185 -0
  51. package/src/cli/commands/studio/workset-session.ts +131 -0
  52. package/src/cli/commands/unwrap.ts +8 -0
  53. package/src/cli/commands/update.ts +27 -1
  54. package/src/cli/commands/working/cleanup.ts +10 -1
  55. package/src/cli/commands/working/link.ts +76 -0
  56. package/src/cli/commands/working/working.ts +10 -0
  57. package/src/cli/commands/working/worktree.ts +356 -0
  58. package/src/cli/companion-link-wizard.tsx +2 -0
  59. package/src/cli/companion-selector.tsx +2 -0
  60. package/src/cli/confirm.ts +2 -0
  61. package/src/cli/install-plan.tsx +127 -160
  62. package/src/cli/launch-selector.tsx +2 -0
  63. package/src/cli/main.ts +18 -0
  64. package/src/cli/parse-flags.ts +9 -1
  65. package/src/cli/repo-list-table.tsx +2 -0
  66. package/src/cli/setup-selector.tsx +79 -20
  67. package/src/cli/usage.ts +11 -1
  68. package/src/create-mate.ts +5 -4
  69. package/src/hooks/tokensave-route.ts +26 -0
  70. package/src/lib/apply-context/fingerprint.ts +174 -0
  71. package/src/lib/apply-context/protocol.ts +193 -0
  72. package/src/lib/components/confirm-prompt.tsx +21 -9
  73. package/src/lib/components/select-menu.tsx +10 -3
  74. package/src/lib/components/spinner.tsx +4 -2
  75. package/src/lib/components/startup-progress.tsx +227 -41
  76. package/src/lib/components/text-input-display.tsx +2 -0
  77. package/src/lib/components/wizard-footer.tsx +2 -0
  78. package/src/lib/components/wizard-header.tsx +13 -11
  79. package/src/lib/delivery/archive-change.ts +14 -2
  80. package/src/lib/delivery/branches.ts +29 -5
  81. package/src/lib/delivery/environment.ts +7 -1
  82. package/src/lib/delivery/forge.ts +2 -2
  83. package/src/lib/delivery/merge-git.ts +261 -0
  84. package/src/lib/delivery/overlap.ts +11 -4
  85. package/src/lib/delivery/record-delivery.ts +97 -10
  86. package/src/lib/delivery/record.ts +67 -7
  87. package/src/lib/delivery/refresh.ts +104 -10
  88. package/src/lib/delivery/repository-access.ts +46 -2
  89. package/src/lib/delivery/resolve-branch.ts +162 -0
  90. package/src/lib/delivery/token.ts +7 -41
  91. package/src/lib/factory/attach-client.ts +113 -0
  92. package/src/lib/factory/attach.ts +178 -0
  93. package/src/lib/factory/broker.ts +190 -0
  94. package/src/lib/factory/bun-commands.ts +39 -0
  95. package/src/lib/factory/client.ts +92 -0
  96. package/src/lib/factory/command.ts +61 -0
  97. package/src/lib/factory/credential-store.ts +153 -0
  98. package/src/lib/factory/frames.ts +77 -0
  99. package/src/lib/factory/ids.ts +58 -0
  100. package/src/lib/factory/keyed-serial.ts +27 -0
  101. package/src/lib/factory/outcomes/actions.ts +114 -0
  102. package/src/lib/factory/outcomes/index.ts +381 -0
  103. package/src/lib/factory/outcomes/lifecycle.ts +205 -0
  104. package/src/lib/factory/outcomes/runs.ts +81 -0
  105. package/src/lib/factory/outcomes/sessions.ts +38 -0
  106. package/src/lib/factory/prepare.ts +49 -0
  107. package/src/lib/factory/pty.ts +103 -0
  108. package/src/lib/factory/runner/companion-context.ts +178 -0
  109. package/src/lib/factory/runner/control.ts +92 -0
  110. package/src/lib/factory/runner/harness-agent.ts +250 -0
  111. package/src/lib/factory/runner/live.ts +159 -0
  112. package/src/lib/factory/runner/questions.ts +22 -0
  113. package/src/lib/factory/runner/rank.ts +26 -0
  114. package/src/lib/factory/runner/run-policy.ts +12 -0
  115. package/src/lib/factory/runner/run.ts +199 -0
  116. package/src/lib/factory/runner/scheduler.ts +416 -0
  117. package/src/lib/factory/runner/state.ts +233 -0
  118. package/src/lib/factory/runner/workflow.ts +542 -0
  119. package/src/lib/factory/runtime.ts +972 -0
  120. package/src/lib/factory/sandbox.ts +292 -0
  121. package/src/lib/factory/worktree-branch.ts +17 -0
  122. package/src/lib/install.ts +66 -14
  123. package/src/lib/live-progress.ts +36 -0
  124. package/src/lib/member-choices.ts +67 -0
  125. package/src/lib/orchestrator/adapters/base.ts +55 -22
  126. package/src/lib/orchestrator/adapters/claude.ts +6 -1
  127. package/src/lib/orchestrator/config-store.ts +3 -2
  128. package/src/lib/orchestrator/editor.ts +29 -23
  129. package/src/lib/orchestrator/projection-entries.ts +56 -21
  130. package/src/lib/orchestrator/projection-opencode-copies.ts +32 -15
  131. package/src/lib/orchestrator/projection-openspec-store.ts +54 -9
  132. package/src/lib/orchestrator/projection-types.ts +33 -1
  133. package/src/lib/orchestrator/session-context-link.ts +67 -0
  134. package/src/lib/orchestrator/setup-compatibilities.ts +55 -12
  135. package/src/lib/orchestrator/types.ts +5 -0
  136. package/src/lib/orchestrator/working-repo-projection.ts +50 -7
  137. package/src/lib/orchestrator/workspace-document.ts +105 -0
  138. package/src/lib/package-paths.ts +29 -0
  139. package/src/lib/runtime-directory-refresh.ts +17 -1
  140. package/src/lib/workset/record.ts +513 -0
  141. package/src/lib/workset/repositories.ts +55 -0
  142. package/src/lib/workset/stage.ts +148 -0
  143. package/src/lib/workset/stages.ts +113 -0
  144. package/src/lib/workset/worktree-index.ts +116 -0
  145. package/src/lib/workset/worktree.ts +830 -0
  146. package/src/opencode/companion-hooks.ts +45 -2
  147. package/src/opencode/enter-worktree.ts +72 -0
  148. package/src/opencode/tui.tsx +9 -4
  149. package/src/plugins.ts +1 -0
  150. package/src/runtime/claude-delivery-plan.ts +22 -5
  151. package/src/runtime/companion-git.ts +52 -10
  152. package/src/runtime/companion-guidance.ts +7 -7
  153. package/src/runtime/companion-lock.ts +30 -7
  154. package/src/runtime/env.ts +48 -3
  155. package/src/runtime/git-layout.ts +219 -0
  156. package/src/runtime/index.ts +24 -0
  157. package/src/runtime/physical-path.ts +111 -0
  158. package/src/runtime/policy.ts +36 -2
  159. package/src/runtime/runtime-directory.ts +5 -0
  160. package/src/runtime/secret-guard.ts +19 -5
  161. package/src/runtime/secret-patterns.ts +267 -34
  162. package/src/runtime/session-context.ts +98 -0
  163. package/src/runtime/tokensave-route.ts +152 -0
  164. package/src/runtime/wrap-state.ts +24 -16
  165. package/src/studio.ts +124 -0
  166. package/src/templates/capabilities/openspec-cap/mate-minimal/schema.yaml +10 -8
  167. package/src/templates/capabilities/openspec-cap/mate-v1/schema.yaml +16 -98
  168. package/src/templates/capabilities/openspec-cap/openspec-conventions.yaml +10 -2
  169. package/src/templates/mate-skills/agents/mate-apply-change/SKILL.md +76 -18
  170. package/src/templates/mate-skills/agents/mate-apply-change/references/mate-compact-apply.md +47 -0
  171. package/src/templates/mate-skills/agents/mate-apply-change/references/openspec-apply-change.md +2 -0
  172. package/src/templates/mate-skills/agents/mate-archive-change/SKILL.md +32 -5
  173. package/src/templates/mate-skills/agents/mate-backfill-spec/SKILL.md +8 -1
  174. package/src/templates/mate-skills/agents/mate-clarify-intent/SKILL.md +16 -1
  175. package/src/templates/mate-skills/agents/mate-explore-change/SKILL.md +22 -6
  176. package/src/templates/mate-skills/agents/mate-explore-change/references/openspec-explore.md +2 -0
  177. package/src/templates/mate-skills/agents/mate-grill-me/SKILL.md +8 -1
  178. package/src/templates/mate-skills/agents/mate-grill-with-docs/SKILL.md +2 -2
  179. package/src/templates/mate-skills/agents/mate-interview-me/SKILL.md +7 -0
  180. package/src/templates/mate-skills/agents/mate-propose-change/SKILL.md +55 -50
  181. package/src/templates/mate-skills/agents/mate-propose-change/references/mate-revise.md +47 -0
  182. package/src/templates/mate-skills/agents/mate-propose-change/references/openspec-propose.md +2 -0
  183. package/src/templates/mate-skills/agents/mate-propose-change/references/openspec-update-change.md +2 -0
  184. package/src/templates/mate-skills/agents/mate-publish-artifact/SKILL.md +29 -10
  185. package/src/templates/mate-skills/agents/mate-publish-artifact/references/openspec.md +4 -2
  186. package/src/templates/mate-skills/agents/mate-show-me/SKILL.md +21 -0
  187. package/src/templates/mate-skills/agents/mate-simplify-code/SKILL.md +13 -0
  188. package/src/templates/mate-skills/claude/mate-apply-change/SKILL.md +76 -18
  189. package/src/templates/mate-skills/claude/mate-apply-change/references/mate-compact-apply.md +47 -0
  190. package/src/templates/mate-skills/claude/mate-apply-change/references/openspec-apply-change.md +2 -0
  191. package/src/templates/mate-skills/claude/mate-archive-change/SKILL.md +32 -5
  192. package/src/templates/mate-skills/claude/mate-backfill-spec/SKILL.md +8 -1
  193. package/src/templates/mate-skills/claude/mate-clarify-intent/SKILL.md +16 -1
  194. package/src/templates/mate-skills/claude/mate-explore-change/SKILL.md +22 -6
  195. package/src/templates/mate-skills/claude/mate-explore-change/references/openspec-explore.md +2 -0
  196. package/src/templates/mate-skills/claude/mate-grill-me/SKILL.md +8 -1
  197. package/src/templates/mate-skills/claude/mate-grill-with-docs/SKILL.md +2 -2
  198. package/src/templates/mate-skills/claude/mate-interview-me/SKILL.md +7 -0
  199. package/src/templates/mate-skills/claude/mate-propose-change/SKILL.md +55 -50
  200. package/src/templates/mate-skills/claude/mate-propose-change/references/mate-revise.md +47 -0
  201. package/src/templates/mate-skills/claude/mate-propose-change/references/openspec-propose.md +2 -0
  202. package/src/templates/mate-skills/claude/mate-propose-change/references/openspec-update-change.md +2 -0
  203. package/src/templates/mate-skills/claude/mate-publish-artifact/SKILL.md +29 -10
  204. package/src/templates/mate-skills/claude/mate-publish-artifact/references/openspec.md +4 -2
  205. package/src/templates/mate-skills/claude/mate-show-me/SKILL.md +21 -0
  206. package/src/templates/mate-skills/claude/mate-simplify-code/SKILL.md +13 -0
  207. package/src/templates/mate-skills/openspec-references.ts +2 -0
  208. package/src/tools/setup/__snapshots__/runtime-surface-golden.test.ts.snap +364 -224
  209. package/src/tools/setup/capabilities/companion-mentions.ts +27 -0
  210. package/src/tools/setup/capabilities/context-mode.ts +34 -5
  211. package/src/tools/setup/capabilities/graphify-secrets.ts +2 -14
  212. package/src/tools/setup/capabilities/graphify.ts +34 -7
  213. package/src/tools/setup/capabilities/openspec.ts +12 -2
  214. package/src/tools/setup/capabilities/react-doctor.ts +8 -1
  215. package/src/tools/setup/capabilities/rtk.ts +4 -0
  216. package/src/tools/setup/capabilities/tokensave.ts +77 -68
  217. package/src/tools/setup/engine.ts +3 -2
  218. package/src/tools/setup/install-contract.ts +8 -0
  219. package/src/tools/setup/mate-skill-copies.ts +51 -0
  220. package/src/tools/setup/package-managers/uv.ts +73 -11
  221. package/src/tools/setup/plugin.ts +5 -0
  222. package/src/tools/setup/providers/claude-plugin-hooks.ts +12 -0
  223. package/src/tools/setup/providers/claude-worktree-plugins.ts +122 -0
  224. package/src/tools/setup/providers/claude.ts +11 -5
  225. package/src/tools/setup/utils.ts +4 -0
  226. package/src/tools/setup/working-repo-cleanup.ts +29 -1
  227. package/src/tools/setup/working-repo-local-state.ts +252 -75
  228. package/src/tools/setup.ts +57 -16
  229. package/studio-dist/client/assets/companion-view-Csva26Ir.js +1 -0
  230. package/studio-dist/client/assets/delivery-path-DJMpRmiY.js +1 -0
  231. package/studio-dist/client/assets/dist-Dm7MtyHc.js +5 -0
  232. package/studio-dist/client/assets/factory-B7l9ZQyx.js +4 -0
  233. package/studio-dist/client/assets/index-n6uo_92S.js +40 -0
  234. package/studio-dist/client/assets/preload-helper-BLdHbfdN.js +1 -0
  235. package/studio-dist/client/assets/prepaint-CD5OpmTM.js +24 -0
  236. package/studio-dist/client/assets/queries-CN3JwMBX.js +1 -0
  237. package/studio-dist/client/assets/react-CabXf2Ds.js +1 -0
  238. package/studio-dist/client/assets/report-time-Dc-KOqQu.js +1 -0
  239. package/studio-dist/client/assets/reports-C01RsnMA.js +1 -0
  240. package/studio-dist/client/assets/rolldown-runtime-WkwZ5CU-.js +1 -0
  241. package/studio-dist/client/assets/routes-4pbC-2Hj.js +1 -0
  242. package/studio-dist/client/assets/skills-CihQganl.js +1 -0
  243. package/studio-dist/client/assets/spec-areas-C2L48N4C.js +1 -0
  244. package/studio-dist/client/assets/specs-D24_35_K.js +1 -0
  245. package/studio-dist/client/assets/studio-DKxfi691.css +1 -0
  246. package/studio-dist/client/assets/studio-queries-rvbJupCy.js +3 -0
  247. package/studio-dist/client/assets/terminal-eU5fzQzv.css +1 -0
  248. package/studio-dist/client/assets/vault-Bd4CQiTK.js +1 -0
  249. package/studio-dist/client/assets/warnings-V_Ys51wJ.js +1 -0
  250. package/studio-dist/client/assets/wasm-inline-C2en61B5.js +1 -0
  251. package/studio-dist/client/assets/workflow-BJejeVwQ.js +1 -0
  252. package/studio-dist/server/assets/__23tanstack-start-server-fn-resolver-BQKuMdJW.js +3881 -0
  253. package/studio-dist/server/assets/_tanstack-start-manifest_v.js +85 -0
  254. package/studio-dist/server/assets/actions-Bvgj9eb8.js +54 -0
  255. package/studio-dist/server/assets/actions-D8erOphH.js +44 -0
  256. package/studio-dist/server/assets/companion-view-aBady57v.js +33 -0
  257. package/studio-dist/server/assets/createServerFn-F5sAOF8V.js +459 -0
  258. package/studio-dist/server/assets/createServerRpc-tK2lE9R2.js +11 -0
  259. package/studio-dist/server/assets/delivery-path-BkKNjgkf.js +778 -0
  260. package/studio-dist/server/assets/dist-DpJWKyCm.js +5582 -0
  261. package/studio-dist/server/assets/empty-plugin-adapters-Cipd4ZH4.js +4 -0
  262. package/studio-dist/server/assets/factory-D6xnjedJ.js +2385 -0
  263. package/studio-dist/server/assets/factory-DT3UzHlh.js +68 -0
  264. package/studio-dist/server/assets/model-PyPALjii.js +18 -0
  265. package/studio-dist/server/assets/prepaint-BMke0fo1.js +41 -0
  266. package/studio-dist/server/assets/queries-Ag2iL8q2.js +107 -0
  267. package/studio-dist/server/assets/react-COs0LHn-.js +51 -0
  268. package/studio-dist/server/assets/report-time-DAfzln-N.js +8 -0
  269. package/studio-dist/server/assets/reports-BnUNJVtx.js +126 -0
  270. package/studio-dist/server/assets/rolldown-runtime-DYf_mQCB.js +34 -0
  271. package/studio-dist/server/assets/router-BH--drIx.js +4298 -0
  272. package/studio-dist/server/assets/routes-khSDK1bV.js +361 -0
  273. package/studio-dist/server/assets/search-JAKurDNh.js +36 -0
  274. package/studio-dist/server/assets/shell-CboT2f66.js +51 -0
  275. package/studio-dist/server/assets/skills-MWYnWoKs.js +106 -0
  276. package/studio-dist/server/assets/spec-areas-DcnO6vW-.js +16 -0
  277. package/studio-dist/server/assets/specs-DE3w8hZP.js +155 -0
  278. package/studio-dist/server/assets/start-BW5ovN0k.js +33 -0
  279. package/studio-dist/server/assets/studio-BeltxxKt.js +216 -0
  280. package/studio-dist/server/assets/studio-queries-CLnP9kGu.js +3365 -0
  281. package/studio-dist/server/assets/utils-C9CX1kcy.js +221 -0
  282. package/studio-dist/server/assets/vault-BGulVoNh.js +70 -0
  283. package/studio-dist/server/assets/vault-CuyyhLyB.js +832 -0
  284. package/studio-dist/server/assets/views-Bd7cRr27.js +82 -0
  285. package/studio-dist/server/assets/warnings-BH05rOuG.js +15 -0
  286. package/studio-dist/server/assets/wasm-inline-CNeBKGwC.js +3 -0
  287. package/studio-dist/server/assets/workflow-BSuIKWqH.js +42 -0
  288. package/studio-dist/server/server.js +16220 -0
  289. package/src/cli/commands/studio/client-asset.ts +0 -16
  290. package/src/cli/commands/studio/views/client.ts +0 -44
  291. package/src/cli/commands/studio/views/companion-picker.tsx +0 -95
  292. package/src/cli/commands/studio/views/companion-selector.tsx +0 -94
  293. package/src/cli/commands/studio/views/dashboard/changes.tsx +0 -102
  294. package/src/cli/commands/studio/views/dashboard/index.tsx +0 -19
  295. package/src/cli/commands/studio/views/document.tsx +0 -910
  296. package/src/cli/commands/studio/views/error.tsx +0 -20
  297. package/src/cli/commands/studio/views/markdown.tsx +0 -250
  298. package/src/cli/commands/studio/views/palette.ts +0 -134
  299. package/src/cli/commands/studio/views/reports/index.tsx +0 -44
  300. package/src/cli/commands/studio/views/selection-fields.tsx +0 -14
  301. package/src/cli/commands/studio/views/skills/index.tsx +0 -68
  302. package/src/cli/commands/studio/views/specs/index.tsx +0 -149
  303. package/src/cli/commands/studio/views/studio-client/actions.ts +0 -51
  304. package/src/cli/commands/studio/views/studio-client/companion.ts +0 -13
  305. package/src/cli/commands/studio/views/studio-client/index.ts +0 -32
  306. package/src/cli/commands/studio/views/studio-client/keys.ts +0 -3
  307. package/src/cli/commands/studio/views/studio-client/main.ts +0 -3
  308. package/src/cli/commands/studio/views/studio-client/page.ts +0 -146
  309. package/src/cli/commands/studio/views/studio-client/panels.ts +0 -57
  310. package/src/cli/commands/studio/views/studio-client/reports.ts +0 -122
  311. package/src/cli/commands/studio/views/studio-client/theme.ts +0 -63
  312. package/src/cli/commands/studio/views/studio-client/vault-editor.ts +0 -166
  313. package/src/cli/commands/studio/views/studio-client/vault-pane.ts +0 -202
  314. package/src/cli/commands/studio/views/studio-client/vault-tree.ts +0 -258
  315. package/src/cli/commands/studio/views/studio-client.generated.ts +0 -2
  316. package/src/cli/commands/studio/views/styles.ts +0 -530
  317. package/src/cli/commands/studio/views/terminal.tsx +0 -484
  318. package/src/cli/commands/studio/views/vault/state.ts +0 -41
  319. package/src/cli/commands/studio/views/warnings.tsx +0 -21
  320. package/src/cli/commands/studio/views/workflow/delivery-path.tsx +0 -370
  321. package/src/cli/commands/studio/views/workflow/graph.ts +0 -220
  322. package/src/cli/commands/studio/views/workflow/index.tsx +0 -20
  323. package/src/cli/commands/studio/views/workflow/steps.ts +0 -278
  324. package/src/lib/components/theme.ts +0 -2
  325. package/src/tools/setup/git-utils.ts +0 -30
@@ -1,7 +1,11 @@
1
1
  import fs from "node:fs/promises";
2
2
  import path from "node:path";
3
3
 
4
- import { resolveGitInfoExcludePath } from "./git-utils";
4
+ import { pathIsDirectory } from "../../lib/fs-utils";
5
+ import { withPathLock } from "../../runtime/companion-lock";
6
+ import { gitExcludePath, otherCheckouts } from "../../runtime/git-layout";
7
+ import { repoLocalDirPath } from "../../runtime/repo-local";
8
+ import { writeAtomicThroughLink } from "../../runtime/write-atomic";
5
9
 
6
10
  const MANAGED_BLOCK_START = "# mate managed: start";
7
11
  const MANAGED_BLOCK_END = "# mate managed: end";
@@ -18,16 +22,31 @@ const CORE_EXCLUDE_ENTRIES = [
18
22
  ];
19
23
  const LEGACY_CORE_EXCLUDE_ENTRIES = new Set([".mate/", ".claude/settings.local.json"]);
20
24
 
21
- async function readExclude(excludePath: string): Promise<string> {
25
+ /**
26
+ * For an edit: only a missing file is empty. Any other read error fails the
27
+ * edit, since writing back what it could not read would drop the user's lines.
28
+ */
29
+ async function readExcludeForEdit(excludePath: string): Promise<string> {
22
30
  try {
23
31
  return await fs.readFile(excludePath, "utf8");
24
- } catch {
25
- return "";
32
+ } catch (error) {
33
+ if ((error as NodeJS.ErrnoException).code === "ENOENT") return "";
34
+ throw error;
26
35
  }
27
36
  }
28
37
 
38
+ /** For a presence check: a file it cannot read holds nothing it could find. */
39
+ function readExclude(excludePath: string): Promise<string> {
40
+ return readExcludeForEdit(excludePath).catch(() => "");
41
+ }
42
+
43
+ function fileContent(lines: readonly string[]): string {
44
+ return lines.length > 0 ? `${lines.join("\n")}\n` : "";
45
+ }
46
+
47
+ /** Split on `\n` alone, so a line keeps its `\r` and an untouched line its bytes. */
29
48
  function contentLines(content: string): string[] {
30
- const lines = content.split(/\r?\n/);
49
+ const lines = content.split("\n");
31
50
  if (lines.at(-1) === "") lines.pop();
32
51
  return lines;
33
52
  }
@@ -57,16 +76,136 @@ function trimTrailingEmptyLines(lines: string[]): string[] {
57
76
  return next;
58
77
  }
59
78
 
60
- async function writeExclude(
61
- excludePath: string,
62
- existing: string,
63
- lines: string[],
64
- ): Promise<boolean> {
65
- const nextContent = lines.length > 0 ? `${lines.join("\n")}\n` : "";
66
- if (nextContent === existing) return false;
79
+ /** Held for one read-edit-write; a pass that cannot get it fails that entry. */
80
+ const EXCLUDE_LOCK_TIMEOUT_MS = 5_000;
81
+
82
+ /**
83
+ * Rewrites the file's lines. `keep` holds entries another Checkout still needs;
84
+ * the edit must leave them in place, wherever its rule would remove them.
85
+ */
86
+ export type ExcludeEdit = (lines: string[], keep: ReadonlySet<string>) => string[];
87
+
88
+ /** The entries a Checkout of the same clone still needs in the shared file. */
89
+ export type ExcludeNeeds = (checkoutPath: string) => Promise<readonly string[]>;
90
+
91
+ export interface ExcludeEditResult {
92
+ changed: boolean;
93
+ /** Entries the edit would have removed but another Checkout still needs. */
94
+ kept: string[];
95
+ /** The Checkouts that need them. */
96
+ keptFor: string[];
97
+ }
98
+
99
+ const UNCHANGED: ExcludeEditResult = { changed: false, kept: [], keptFor: [] };
100
+
101
+ function entries(lines: readonly string[]): Set<string> {
102
+ return new Set(lines.map((line) => line.trim()).filter(Boolean));
103
+ }
104
+
105
+ /**
106
+ * A Checkout Mate cannot reach, as a locked worktree whose drive is away, or
107
+ * whose state it cannot read, keeps every entry: what it needs is unknown.
108
+ */
109
+ async function checkoutNeeds(
110
+ checkout: string,
111
+ removed: ReadonlySet<string>,
112
+ needs: ExcludeNeeds,
113
+ ): Promise<readonly string[]> {
114
+ if (!(await pathIsDirectory(checkout))) return [...removed];
115
+ try {
116
+ return await needs(checkout);
117
+ } catch {
118
+ return [...removed];
119
+ }
120
+ }
121
+
122
+ /** Other Checkouts are read only here, once the edit would remove an entry. */
123
+ async function neededEntries(
124
+ repoPath: string,
125
+ removed: ReadonlySet<string>,
126
+ needs: ExcludeNeeds,
127
+ ): Promise<{ keep: Set<string>; keptFor: string[] }> {
128
+ const checkouts = otherCheckouts(repoPath);
129
+ const needed = await Promise.all(
130
+ checkouts.map((checkout) => checkoutNeeds(checkout, removed, needs)),
131
+ );
132
+ const keep = new Set<string>();
133
+ const keptFor: string[] = [];
134
+ checkouts.forEach((checkout, index) => {
135
+ const wanted = needed[index].filter((entry) => removed.has(entry));
136
+ if (wanted.length === 0) return;
137
+ keptFor.push(checkout);
138
+ for (const entry of wanted) keep.add(entry);
139
+ });
140
+ return { keep, keptFor };
141
+ }
142
+
143
+ /** Runs `edit`, then again keeping what other Checkouts need once it would remove an entry. */
144
+ async function applyEdit(
145
+ repoPath: string,
146
+ current: string[],
147
+ edit: ExcludeEdit,
148
+ needs: ExcludeNeeds | undefined,
149
+ ): Promise<{ lines: string[]; kept: string[]; keptFor: string[] }> {
150
+ const lines = edit(current, new Set());
151
+ const after = entries(lines);
152
+ const removed = new Set([...entries(current)].filter((entry) => !after.has(entry)));
153
+ if (!needs || removed.size === 0) return { lines, kept: [], keptFor: [] };
154
+ const { keep, keptFor } = await neededEntries(repoPath, removed, needs);
155
+ if (keep.size === 0) return { lines, kept: [], keptFor: [] };
156
+ const keptLines = edit(current, keep);
157
+ const stayed = entries(keptLines);
158
+ return { lines: keptLines, kept: [...keep].filter((entry) => stayed.has(entry)), keptFor };
159
+ }
160
+
161
+ /**
162
+ * The one writer for the exclude file Git reads for `repoPath`. Every Checkout
163
+ * of a clone shares that file, so the read, the edit and the atomic replace
164
+ * happen under one lock keyed by the file. With `needs`, an entry the edit
165
+ * would remove stays while another Checkout of the clone needs it.
166
+ *
167
+ * Most passes change nothing. Those are settled by one read without the lock,
168
+ * so sessions starting in several Checkouts at once do not queue on it.
169
+ */
170
+ export async function editExcludeFile(
171
+ repoPath: string,
172
+ edit: ExcludeEdit,
173
+ needs?: ExcludeNeeds,
174
+ ): Promise<ExcludeEditResult> {
175
+ const excludePath = gitExcludePath(repoPath);
176
+ if (!excludePath) return UNCHANGED;
177
+ const unlocked = await readExcludeForEdit(excludePath);
178
+ if (fileContent(edit(contentLines(unlocked), new Set())) === unlocked) return UNCHANGED;
67
179
  await fs.mkdir(path.dirname(excludePath), { recursive: true });
68
- await fs.writeFile(excludePath, nextContent, "utf8");
69
- return true;
180
+ const locked = await withPathLock(
181
+ "git-exclude",
182
+ excludePath,
183
+ { timeoutMs: EXCLUDE_LOCK_TIMEOUT_MS, pollMs: 20 },
184
+ async () => {
185
+ const existing = await readExcludeForEdit(excludePath);
186
+ const { lines, kept, keptFor } = await applyEdit(
187
+ repoPath,
188
+ contentLines(existing),
189
+ edit,
190
+ needs,
191
+ );
192
+ const next = fileContent(lines);
193
+ const changed = next !== existing;
194
+ /** Through a symlink to its target, keeping the file's mode; a read-only file is refused. */
195
+ if (changed) await writeAtomicThroughLink(excludePath, next);
196
+ return { changed, kept, keptFor };
197
+ },
198
+ );
199
+ if (!locked.acquired) throw new Error(`${excludePath} is locked by another Mate process`);
200
+ return locked.value;
201
+ }
202
+
203
+ /** Appends `entry` unless a line already holds it; every other line stays as it is. */
204
+ export async function addExcludeLine(repoPath: string, entry: string): Promise<boolean> {
205
+ const result = await editExcludeFile(repoPath, (lines) =>
206
+ lines.some((line) => line.trim() === entry) ? lines : [...lines, entry],
207
+ );
208
+ return result.changed;
70
209
  }
71
210
 
72
211
  /** The first `startMarker`…`endMarker` pair, inclusive; `null` when either is missing. */
@@ -88,56 +227,58 @@ function withoutLegacy(lines: string[]): string[] {
88
227
  }
89
228
 
90
229
  export async function ensureWorkingRepoLocalExcludes(repoPath: string): Promise<boolean> {
91
- const excludePath = await resolveGitInfoExcludePath(repoPath);
92
- if (!excludePath) return false;
93
- const existing = await readExclude(excludePath);
94
- const current = contentLines(existing);
95
230
  const block = [MANAGED_BLOCK_START, ...CORE_EXCLUDE_ENTRIES, MANAGED_BLOCK_END];
96
- /**
97
- * Rewritten where it stands, not moved to the end: a block that follows it,
98
- * like the companion copies', would otherwise trade places with it on every
99
- * pass and turn an unchanged wrap into a write.
100
- */
101
- const managed = findBlock(current, MANAGED_BLOCK_START, MANAGED_BLOCK_END);
102
- const lines = managed
103
- ? trimTrailingEmptyLines([
104
- ...withoutLegacy(current.slice(0, managed.start)),
105
- ...block,
106
- ...withoutLegacy(current.slice(managed.end + 1)),
107
- ])
108
- : [...trimTrailingEmptyLines(withoutLegacy(current)), ...block];
109
- return writeExclude(excludePath, existing, lines);
110
- }
111
-
112
- export async function reconcileWorkingRepoCapabilityExcludes(
231
+ const result = await editExcludeFile(repoPath, (current) => {
232
+ /**
233
+ * Rewritten where it stands, not moved to the end: a block that follows it,
234
+ * like the companion copies', would otherwise trade places with it on every
235
+ * pass and turn an unchanged wrap into a write.
236
+ */
237
+ const managed = findBlock(current, MANAGED_BLOCK_START, MANAGED_BLOCK_END);
238
+ return managed
239
+ ? trimTrailingEmptyLines([
240
+ ...withoutLegacy(current.slice(0, managed.start)),
241
+ ...block,
242
+ ...withoutLegacy(current.slice(managed.end + 1)),
243
+ ])
244
+ : [...trimTrailingEmptyLines(withoutLegacy(current)), ...block];
245
+ });
246
+ return result.changed;
247
+ }
248
+
249
+ export function reconcileWorkingRepoCapabilityExcludes(
113
250
  repoPath: string,
114
251
  desiredEntries: string[],
115
252
  managedEntries: string[],
116
- ): Promise<boolean> {
117
- const excludePath = await resolveGitInfoExcludePath(repoPath);
118
- if (!excludePath) return false;
119
- const existing = await readExclude(excludePath);
253
+ needs: ExcludeNeeds,
254
+ ): Promise<ExcludeEditResult> {
120
255
  const managed = new Set(managedEntries);
121
256
  const desired = new Set(desiredEntries);
122
- /**
123
- * A desired line stays where it stands: re-appending it would trade places
124
- * with a block written after it, like the companion copies', on every pass.
125
- */
126
- const lines = trimTrailingEmptyLines(
127
- contentLines(existing).filter((line) => {
128
- const entry = line.trim();
129
- return desired.has(entry) || !managed.has(entry);
130
- }),
257
+ return editExcludeFile(
258
+ repoPath,
259
+ (current, keep) => {
260
+ /**
261
+ * A desired line stays where it stands: re-appending it would trade places
262
+ * with a block written after it, like the companion copies', on every pass.
263
+ */
264
+ const lines = trimTrailingEmptyLines(
265
+ current.filter((line) => {
266
+ const entry = line.trim();
267
+ return desired.has(entry) || keep.has(entry) || !managed.has(entry);
268
+ }),
269
+ );
270
+ for (const entry of desiredEntries) {
271
+ if (!lines.some((line) => line.trim() === entry)) lines.push(entry);
272
+ }
273
+ return lines;
274
+ },
275
+ needs,
131
276
  );
132
- for (const entry of desiredEntries) {
133
- if (!lines.some((line) => line.trim() === entry)) lines.push(entry);
134
- }
135
- return writeExclude(excludePath, existing, lines);
136
277
  }
137
278
 
138
279
  /** Whether the managed block is on disk; the block, not the exclude file. */
139
280
  export async function managedWorkingRepoExcludesPresent(repoPath: string): Promise<boolean> {
140
- const excludePath = await resolveGitInfoExcludePath(repoPath);
281
+ const excludePath = gitExcludePath(repoPath);
141
282
  if (!excludePath) return false;
142
283
  const lines = contentLines(await readExclude(excludePath));
143
284
  return lines.some((line) => line.trim() === MANAGED_BLOCK_START);
@@ -148,18 +289,52 @@ export async function workingRepoCapabilityExcludesPresent(
148
289
  repoPath: string,
149
290
  candidateEntries: string[],
150
291
  ): Promise<boolean> {
151
- const excludePath = await resolveGitInfoExcludePath(repoPath);
292
+ const excludePath = gitExcludePath(repoPath);
152
293
  if (!excludePath) return false;
153
294
  const lines = withoutManagedBlocks(contentLines(await readExclude(excludePath)));
154
295
  return candidateEntries.some((entry) => lines.some((line) => line.trim() === entry));
155
296
  }
156
297
 
157
- export async function removeWorkingRepoLocalExcludes(repoPath: string): Promise<boolean> {
158
- const excludePath = await resolveGitInfoExcludePath(repoPath);
159
- if (!excludePath) return false;
160
- const existing = await readExclude(excludePath);
161
- const lines = trimTrailingEmptyLines(withoutLegacy(contentLines(existing)));
162
- return writeExclude(excludePath, existing, lines);
298
+ /**
299
+ * A Checkout needs the whole managed block while it holds a Projection Root,
300
+ * and the legacy lines too: an older wrap may have left only those.
301
+ */
302
+ async function managedBlockNeeds(checkout: string): Promise<readonly string[]> {
303
+ return (await pathIsDirectory(repoLocalDirPath(checkout)))
304
+ ? [...CORE_EXCLUDE_ENTRIES, ...LEGACY_CORE_EXCLUDE_ENTRIES]
305
+ : [];
306
+ }
307
+
308
+ /** The `.tokensave/`-style entries whose folder exists in the Checkout. */
309
+ export function localDataNeeds(candidateEntries: readonly string[]): ExcludeNeeds {
310
+ return async (checkout) => {
311
+ const present = await Promise.all(
312
+ candidateEntries.map((entry) => pathIsDirectory(path.join(checkout, entry))),
313
+ );
314
+ return candidateEntries.filter((_, index) => present[index]);
315
+ };
316
+ }
317
+
318
+ /**
319
+ * The block goes as a whole or stays as a whole. A legacy line outside it
320
+ * stays only while another Checkout needs the block's lines and the block is
321
+ * gone, so the legacy line is all that hides that Checkout's files.
322
+ */
323
+ export function removeWorkingRepoLocalExcludes(repoPath: string): Promise<ExcludeEditResult> {
324
+ return editExcludeFile(
325
+ repoPath,
326
+ (current, keep) => {
327
+ if (keep.size === 0) return trimTrailingEmptyLines(withoutLegacy(current));
328
+ const hasBlock = findBlock(current, MANAGED_BLOCK_START, MANAGED_BLOCK_END) !== null;
329
+ return trimTrailingEmptyLines(
330
+ current.filter((line) => {
331
+ const entry = line.trim();
332
+ return !LEGACY_CORE_EXCLUDE_ENTRIES.has(entry) || (!hasBlock && keep.has(entry));
333
+ }),
334
+ );
335
+ },
336
+ managedBlockNeeds,
337
+ );
163
338
  }
164
339
 
165
340
  const COPIES_BLOCK_START = "# mate managed copies: start";
@@ -179,22 +354,24 @@ function withoutCopiesBlock(lines: string[]): string[] {
179
354
  /**
180
355
  * One exclude line per owned companion copy, in a block of its own so the core
181
356
  * block's rewrite leaves it alone. Per file rather than `/.opencode/`, so a file
182
- * the repository adds there itself stays visible to Git.
357
+ * the repository adds there itself stays visible to Git. The block is shared
358
+ * by the clone's Checkouts: `copiesOf` names the copies another one records,
359
+ * whose lines stay.
183
360
  */
184
- export async function reconcileWorkingRepoCopyExcludes(
361
+ export function reconcileWorkingRepoCopyExcludes(
185
362
  repoPath: string,
186
363
  relativePaths: readonly string[],
187
- ): Promise<boolean> {
188
- const excludePath = await resolveGitInfoExcludePath(repoPath);
189
- if (!excludePath) return false;
190
- const existing = await readExclude(excludePath);
191
- const lines = trimTrailingEmptyLines(withoutCopiesBlock(contentLines(existing)));
192
- if (relativePaths.length > 0) {
193
- lines.push(
194
- COPIES_BLOCK_START,
195
- ...relativePaths.toSorted().map(literalExcludeEntry),
196
- COPIES_BLOCK_END,
197
- );
198
- }
199
- return writeExclude(excludePath, existing, lines);
364
+ copiesOf: ExcludeNeeds,
365
+ ): Promise<ExcludeEditResult> {
366
+ const own = relativePaths.map(literalExcludeEntry);
367
+ return editExcludeFile(
368
+ repoPath,
369
+ (current, keep) => {
370
+ const lines = trimTrailingEmptyLines(withoutCopiesBlock(current));
371
+ const block = [...new Set([...own, ...keep])].toSorted();
372
+ if (block.length > 0) lines.push(COPIES_BLOCK_START, ...block, COPIES_BLOCK_END);
373
+ return lines;
374
+ },
375
+ async (checkout) => (await copiesOf(checkout)).map(literalExcludeEntry),
376
+ );
200
377
  }
@@ -24,6 +24,7 @@ import {
24
24
  collectManagedGitignoreEntries,
25
25
  writeManagedGitignoreBlock,
26
26
  } from "./setup/plugins/gitignore";
27
+ import { untrackSkillCopies } from "./setup/mate-skill-copies";
27
28
  import { createManagedOutputCollector } from "./setup/managed-output";
28
29
  import type {
29
30
  ManagedOutputReport,
@@ -42,6 +43,8 @@ import { createUvPlugin } from "./setup/package-managers/uv";
42
43
  import type { PackageManagerSetupDeps } from "./setup/package-managers/uv";
43
44
  import { applyRequiredSelectionsToConfig } from "./setup/policy";
44
45
  import { invalidateInstallState } from "../lib/install";
46
+ import type { StartupProgressController } from "../lib/components/startup-progress";
47
+ import { emitWarning } from "../lib/live-progress";
45
48
  import {
46
49
  describeUnknownAudience,
47
50
  installPluginDeclarations,
@@ -67,10 +70,20 @@ export interface SetupInput {
67
70
  git?: "auto" | "default";
68
71
  }
69
72
 
73
+ /** Reports setup's phases; `mate companion setup` passes its progress screen. */
74
+ export type SetupProgress = Pick<StartupProgressController, "step">;
75
+
76
+ const silentProgress: SetupProgress = {
77
+ async step(_id, _label, fn) {
78
+ return fn();
79
+ },
80
+ };
81
+
70
82
  export interface SetupDependencies {
71
83
  cwd?: string;
72
84
  configStore?: ConfigStore;
73
85
  globalConfigStore?: GlobalConfigStore;
86
+ progress?: SetupProgress;
74
87
  }
75
88
 
76
89
  export interface CompanionSyncOptions {
@@ -199,16 +212,31 @@ export async function inspectClaudePluginDirectories(
199
212
  };
200
213
  }
201
214
 
215
+ function managedGitignoreEntries(companionPath: string, config: FrameworkConfig): string[] {
216
+ const ctx: SetupContext = { companionPath, config, mode: "sync", activeProviders: [] };
217
+ return collectManagedGitignoreEntries(ctx, getActiveDistribution().registry.getAll());
218
+ }
219
+
202
220
  export async function updateProjectGitignore(
203
221
  companionPath: string,
204
222
  config: FrameworkConfig,
205
223
  ): Promise<void> {
206
- const ctx: SetupContext = { companionPath, config, mode: "sync", activeProviders: [] };
207
- const plugins = getActiveDistribution().registry.getAll();
208
- const entries = collectManagedGitignoreEntries(ctx, plugins);
224
+ const entries = managedGitignoreEntries(companionPath, config);
209
225
  await writeManagedGitignoreBlock(path.join(companionPath, ".gitignore"), FRAMEWORK_NAME, entries);
210
226
  }
211
227
 
228
+ /**
229
+ * Stops tracking the Mate skill copies the managed `.gitignore` block lists; the
230
+ * files stay on disk. Only setup and `mate companion update` call it, never a
231
+ * launch or prepare. Returns the paths removed from the index.
232
+ */
233
+ export async function untrackManagedSkillCopies(
234
+ companionPath: string,
235
+ config: FrameworkConfig,
236
+ ): Promise<string[]> {
237
+ return untrackSkillCopies(companionPath, managedGitignoreEntries(companionPath, config));
238
+ }
239
+
212
240
  export interface CompanionSyncResult {
213
241
  /** For a launch to pass and report; every other caller ignores them. */
214
242
  claudePluginFolders: ClaudePluginFolders;
@@ -283,27 +311,40 @@ export async function executeSetup(
283
311
  await configStore.save(config);
284
312
 
285
313
  const companionPath = path.resolve(cwd);
314
+ const progress = deps.progress ?? silentProgress;
286
315
  // Declared plugin packages install and hydrate before the setup plan runs,
287
316
  // so a fresh clone reaches a fully applied state from one setup run
288
317
  // (install → load → plan).
289
318
  const declarations = installPluginDeclarations(config);
290
319
  if (declarations.length) {
291
- for (const result of await installDeclaredPlugins(companionPath, declarations)) {
292
- if (result.status === "failed") {
293
- process.stderr.write(
294
- `${FRAMEWORK_NAME}: plugin "${result.package}" failed to install: ${result.error ?? "unknown error"}\n`,
295
- );
320
+ await progress.step("plugins", "Installing plugins", async () => {
321
+ for (const result of await installDeclaredPlugins(companionPath, declarations)) {
322
+ if (result.status === "failed") {
323
+ emitWarning(
324
+ `${FRAMEWORK_NAME}: plugin "${result.package}" failed to install: ${result.error ?? "unknown error"}`,
325
+ );
326
+ }
296
327
  }
297
- }
298
- await hydrateDynamicPlugins({ companionPath });
328
+ await hydrateDynamicPlugins({ companionPath });
329
+ });
299
330
  }
300
- await applySetupCompatibilities(companionPath, config, "setup");
301
- await invalidateInstallState({
302
- kind: config.type === "hub" ? "hub" : "companion",
303
- companionPath,
304
- });
331
+ await progress.step("capabilities", "Applying capabilities", () =>
332
+ applySetupCompatibilities(companionPath, config, "setup"),
333
+ );
334
+ await progress.step("register", "Registering companion", async () => {
335
+ const untracked = await untrackManagedSkillCopies(companionPath, config);
336
+ if (untracked.length > 0) {
337
+ emitWarning(
338
+ `${FRAMEWORK_NAME}: ${untracked.length} Mate skill copies are staged as deletions; the files stay on disk. Commit them with .gitignore.`,
339
+ );
340
+ }
341
+ await invalidateInstallState({
342
+ kind: config.type === "hub" ? "hub" : "companion",
343
+ companionPath,
344
+ });
305
345
 
306
- await globalConfigStore.register(companionPath);
346
+ await globalConfigStore.register(companionPath);
347
+ });
307
348
 
308
349
  // Setup no longer fans out to linked repos: capabilities that touch a working repo
309
350
  // (companion files on launch, the tokensave/graphify graph via `mate cap index`)
@@ -0,0 +1 @@
1
+ import{i as e}from"./queries-CN3JwMBX.js";import{Et as t,o as n}from"./studio-queries-rvbJupCy.js";var r=t();function i({companionPath:e,reason:t}){return(0,r.jsxs)(`section`,{className:`panel error`,children:[(0,r.jsx)(`h3`,{children:`Could not read this companion`}),(0,r.jsx)(`p`,{className:`mono`,children:e}),(0,r.jsx)(`p`,{children:t})]})}function a({view:t,search:a,children:o}){let{data:s}=e(n(t,a));return s.error?(0,r.jsx)(i,{companionPath:s.error.companionPath,reason:s.error.reason}):(0,r.jsx)(r.Fragment,{children:o(s)})}export{a as t};
@@ -0,0 +1 @@
1
+ import{n as e}from"./rolldown-runtime-WkwZ5CU-.js";import{D as t,E as n,Et as r,I as i,T as a,qt as o,z as s}from"./studio-queries-rvbJupCy.js";var c=[`mate-clarify-intent`,`mate-interview-me`,`mate-grill-me`],l={"mate-clarify-intent":`Default. Reads what the request already states and routes to an interview, grilling, or skip, then runs that one mode.`,"mate-interview-me":`Explicit mode: guided, one-question-at-a-time clarification when intent, constraints, or scope still need confirmation.`,"mate-grill-me":`Explicit mode: round-based stress test of a mostly known direction to surface hidden assumptions and risks.`},u={"clarify-intent":{what:`Settles who the change is for, why it is needed, how success is measured, and what binds it, before any artifact exists.`,why:`Intent gaps are cheapest to close before exploration turns them into documents.`},explore:{what:`Resolves repository evidence, unknowns, and options, with scope taken from the companion context map, and suggests slicing a large feature.`,why:`It separates uncertainty from the proposal's committed scope.`},propose:{what:`Chooses the schema from the minimal eligibility test, checks slicing when explore agreed none, and writes the change's planning artifacts in one prompt.`,why:`One prompt writes every artifact; each one is then reviewed on its own.`},apply:{what:`Records the delivery branch, avoiding protected branches, then implements the reviewed tasks.`,why:`The recorded branch is what archive and publication later wait on.`},"inspect-outcome":{what:`Shows what the applied change did as a rendered diagram and diff in a Mate report.`,why:`Seeing the result tells the reviewer whether cleanup is warranted.`},"refine-code":{what:`Looks for smaller, clearer code once tests pass, preserving behavior.`,why:`Cleanup lands before archive, so shipped code and recorded specs agree.`},archive:{what:`Applies the delta specs to the local canonical specs and records the delivery; allowed before the branch merges.`,why:`A feature's later changes build on canonical specs that already include this one.`},publish:{what:`Commits, tags, and pushes archived changes whose delivery branches are merged, chosen by the developer.`,why:`Published canonical specs then describe the default branch; unmerged archives wait.`}};function d(e,t,n){return{what:(t?.schemaName===n?t.artifacts.find(t=>t.id===e)?.description:void 0)??`A person reviews the ${e} artifact.`,why:`Reviews stay with people: Mate never marks them approved.`}}function f(e,t){if(e.kind===`human`)return null;if(e.id===`clarify-intent`)return`/${e.skill} about ${s}`;let n=e.id===`propose`&&t!==`mate-v1`?` (use schema: ${t})`:``;return`/${e.skill}${n} for ${i}`}function p(e){return e&&e.replace(` ${i}`,``).replace(` ${s}`,``)}function m(e){return c.filter(e).map(e=>({name:e,description:l[e],prompt:`/${e} about ${s}`,copyPrompt:`/${e} about`}))}var h=new Set([`explore`,`propose`,`apply`,`archive`]);function g(e){if(e.kind===`human`)return[`human-review`];let t=e.optional?[`optional`,`skill`]:[`skill`];return h.has(e.id)&&t.push(`openspec`),t}var _={"mate-v1":{tagline:`full planning`,description:`Full planning path: proposal, specs, design, and tasks.`},"mate-minimal":{tagline:`minimal planning`,description:`Short path: specs and tasks only, for one-Area, low-risk changes with clear intent.`}};function v(e){return t(e)?_[e]:{tagline:`custom schema`,description:`Planning path of the ${e} schema.`}}var y={plan:`Plan`,review:`Review`,build:`Build`,ship:`Ship`};function b(e,t){return e.kind===`human`?`review`:e.id===`apply`||t===`build`&&e.optional?`build`:t===void 0||t===`plan`?`plan`:`ship`}function x(e){return e.kind===`human`?`human`:e.optional?`optional`:null}function S(e){let t=[];for(let n of e){let e=x(n),r=t.at(-1);e&&r?.group===e?r.steps.push(n):t.push({group:e,steps:[n]})}return t.map(e=>e.group===`human`||e.group===`optional`&&e.steps.length>1?{kind:`group`,group:e.group,steps:e.steps}:{kind:`stage`,step:e.steps[0]})}function C(e,t,r){let i=r.skills?new Set(r.skills):null,a=e=>!i||i.has(e),o=n(t),s=[];for(let t of o.stages){let n=t.kind===`human`?d(t.artifact,r.topology,e):u[t.id],i=f(t,e),o=s.at(-1),c={...t,what:n.what,why:n.why,badges:g(t),prompt:i,copyPrompt:p(i),phase:b(t,o?.phase)};t.id===`clarify-intent`&&(c.alternatives=m(a)),t.kind===`skill`&&!a(t.skill)&&(c.missingSkill=t.skill),t.id===`apply`&&(c.sessionBreakBefore=!0),s.push(c)}return{schema:e,label:e,...v(e),steps:s,map:S(s),reviewsKnown:o.reviewsKnown}}function w(e,n){return n?.schemaName===e?n.artifacts.map(e=>e.id):t(e)?a[e]:void 0}function T(e={}){let n=e.topology?.schemaName;return{paths:(n&&!t(n)?[n]:Object.keys(a)).map(t=>C(t,w(t,e.topology),e))}}var E=e=>({id:e.id,kind:`stage`,step:e});function ee(e){let t=e.map.map(e=>e.kind===`stage`?{nodes:[E(e.step)],optional:e.step.optional,phase:e.step.phase}:e.group===`human`?{nodes:[{id:`reviews`,kind:`review-group`,steps:e.steps}],optional:!1,phase:e.steps[0].phase}:{nodes:e.steps.map(E),optional:!0,phase:e.steps[0].phase});return t.unshift({nodes:[{id:`start`,kind:`start`}],optional:!1,phase:t[0]?.phase??`plan`}),t}function te(e){return e.kind===`stage`?!!e.step.sessionBreakBefore:e.kind===`review-group`&&!!e.steps[0].sessionBreakBefore}function D(e){let t=[],n=(e,n,r)=>{for(let i of e)for(let e of n)t.push({from:i.id,to:e.id,kind:r,newSession:te(e)})};return e.forEach((t,r)=>{let i=e[r+1];i&&n(t.nodes,i.nodes,`flow`);let a=e[r-1];t.optional&&a&&i&&n(a.nodes,i.nodes,`bypass`)}),t}function O(e){let t=[];return e.forEach((e,n)=>{let r=t.at(-1);r?.phase===e.phase?r.to=n+1:t.push({phase:e.phase,label:y[e.phase],from:n,to:n+1})}),t}function k(e){let t=e.findIndex(e=>e.nodes.some(e=>e.id===`archive`));return t===-1?null:{from:0,to:t+1}}function A(e){let t=ee(e),n=Math.max(1,...t.map(e=>e.nodes.length)),r=t.flatMap((e,t)=>e.nodes.map((r,i)=>e.nodes.length===1?{...r,column:t,row:0,rowSpan:n}:{...r,column:t,row:i,rowSpan:1}));return{columns:t.length,rows:n,nodes:r,edges:D(t),bands:O(t),cycle:k(t)}}var j=e=>e.rows*2+1;function M(e){return{along:e.column+.5,across:e.row*2+e.rowSpan}}var N=e=>Math.round(e*1e4)/1e4,P=(e,t)=>`${N(e/t*100)}%`,F=({along:e,across:t})=>`${N(t)} ${N(e)}`;function I(e,t){let n=t=>{let n=e.nodes.find(e=>e.id===t);if(!n)throw Error(`Unknown graph node: ${t}`);return M(n)};return[n(t.from),n(t.to)]}function L(e,t){let[n,r]=I(e,t);if(t.kind===`bypass`){let t=j(e);return`M ${F(n)} C ${F({along:n.along,across:t})}, ${F({along:r.along,across:t})}, ${F(r)}`}let i=(n.along+r.along)/2;return`M ${F(n)} C ${F({along:i,across:n.across})}, ${F({along:i,across:r.across})}, ${F(r)}`}function R(e,t){let[n,r]=I(e,t),i=(n.along+r.along)/2;return t.kind===`bypass`?{along:i,across:(n.across+r.across)/8+j(e)*3/4}:{along:i,across:(n.across+r.across)/2}}function z(e,t){return{x:P(t.across,j(e)),y:P(t.along,e.columns)}}function B(e,t){return{top:P(t.from,e.columns),height:P(t.to-t.from,e.columns)}}var V=e(o(),1),H=r();function ne({payload:e}){let t=T({skills:e.skills&&e.skills.length>0?e.skills:void 0,topology:e.topology}),[n,r]=(0,V.useState)(t.paths[0]?.schema);return(0,H.jsx)(`section`,{className:`workflow-delivery-path`,"aria-label":`Delivery Path`,children:t.paths.length>1?(0,H.jsxs)(`div`,{className:`workflow-schema`,"data-workflow-schema-root":!0,children:[(0,H.jsxs)(`label`,{className:`view-choice`,children:[(0,H.jsx)(`span`,{children:`OpenSpec schema`}),(0,H.jsx)(`select`,{"data-workflow-schema-select":!0,value:n,onChange:e=>r(e.target.value),children:t.paths.map(e=>(0,H.jsxs)(`option`,{value:e.schema,children:[e.label,` – `,e.tagline]},e.schema))})]}),(0,H.jsx)(`div`,{className:`workflow-schema-panels`,children:t.paths.map(e=>(0,H.jsx)(`section`,{"data-workflow-schema-panel":e.schema,"data-active":e.schema===n?`true`:`false`,children:(0,H.jsx)(U,{path:e})},e.schema))})]}):(0,H.jsxs)(`div`,{className:`workflow-schema`,children:[(0,H.jsxs)(`p`,{className:`view-choice`,children:[(0,H.jsx)(`span`,{children:`OpenSpec schema`}),(0,H.jsxs)(`code`,{children:[t.paths[0].label,` – `,t.paths[0].tagline]})]}),(0,H.jsx)(U,{path:t.paths[0]})]})})}function U({path:e}){return(0,H.jsxs)(`div`,{className:`workflow-path`,children:[(0,H.jsxs)(`div`,{className:`workflow-path-graph`,children:[(0,H.jsx)(J,{path:e}),(0,H.jsx)(Y,{})]}),(0,H.jsxs)(`aside`,{className:`workflow-detail`,"aria-label":`${e.label} stage details`,children:[(0,H.jsxs)(`div`,{className:`workflow-detail-overview`,id:G(e),children:[(0,H.jsx)(`p`,{className:`workflow-description`,children:e.description}),e.reviewsKnown?null:(0,H.jsx)(`p`,{className:`workflow-description`,children:`The schema's artifacts could not be read, so its review stages are unknown.`}),(0,H.jsx)(`p`,{className:`workflow-description`,children:`A workset is one or more changes published together: after Archive change, start again at the top for the next change, and publish once they are archived.`}),(0,H.jsx)(`p`,{className:`workflow-detail-hint`,children:`Select a node in the graph to see what that stage does and the prompt that runs it.`})]}),e.steps.map(t=>(0,H.jsx)(re,{path:e,step:t},t.id))]})]})}var W=(e,t)=>`workflow-${e.schema}-${t.id}`,G=e=>`workflow-${e.schema}-overview`;function K(e,t){if(!t)return()=>void 0;let n=q(e,t.current);return e=>e.column<n?`done`:e.id===t.current?`current`:`next`}function q(e,t){let n=e.nodes.find(e=>e.id===t);return n?n.column:t===`complete`?e.columns:-1}function J({path:e,progress:t,label:n=`Delivery Path map`}){let r=A(e),i=K(r,t);return(0,H.jsxs)(`nav`,{className:`workflow-graph`,"aria-label":n,"data-progress-activity":t?.activity,style:{"--graph-columns":String(r.columns),"--graph-rows":String(r.rows)},children:[(0,H.jsxs)(`div`,{className:`workflow-graph-bands`,"aria-hidden":`true`,children:[r.bands.map(e=>(0,H.jsx)(`div`,{className:`workflow-graph-band`,"data-band":e.phase,style:B(r,e),children:e.label},e.phase)),r.cycle?(0,H.jsx)(`div`,{className:`workflow-graph-cycle`,style:B(r,r.cycle),children:(0,H.jsx)(`span`,{children:`repeats for each change`})}):null,(0,H.jsx)(`div`,{className:`workflow-graph-workset`,children:(0,H.jsx)(`span`,{children:`workset`})})]}),(0,H.jsx)(Z,{graph:r,stateOf:i}),(0,H.jsx)(`ol`,{className:`workflow-graph-nodes`,children:r.nodes.map(n=>n.kind===`start`?null:(0,H.jsx)(`li`,{className:`workflow-graph-node`,"data-node-kind":n.kind,"data-progress":i(n),"aria-current":i(n)===`current`?`step`:void 0,style:{"--graph-row":String(n.column+1),"--graph-lane":String(n.row+1),"--graph-span":String(n.rowSpan)},children:n.kind===`stage`?(0,H.jsx)(Q,{path:e,step:n.step,box:!0,plain:!!t,children:(0,H.jsx)(X,{progress:t,state:i(n)})}):(0,H.jsxs)(`div`,{className:`workflow-graph-box workflow-graph-group`,"data-map-group":`human`,children:[(0,H.jsx)(`span`,{className:`workflow-graph-group-label`,children:`Human review`}),(0,H.jsx)(`ol`,{children:n.steps.map(n=>(0,H.jsx)(`li`,{children:(0,H.jsx)(Q,{path:e,step:n,plain:!!t})},n.id))}),(0,H.jsx)(X,{progress:t,state:i(n)})]})},n.id))})]})}function Y(){return(0,H.jsxs)(`ul`,{className:`workflow-graph-legend`,"aria-hidden":`true`,children:[(0,H.jsxs)(`li`,{children:[(0,H.jsx)(`i`,{className:`workflow-legend-optional`}),`optional`]}),(0,H.jsxs)(`li`,{children:[(0,H.jsx)(`i`,{className:`workflow-graph-openspec`}),`OpenSpec`]}),(0,H.jsxs)(`li`,{children:[(0,H.jsx)(`i`,{className:`workflow-legend-session`}),`new session`]}),(0,H.jsxs)(`li`,{children:[(0,H.jsx)(`i`,{className:`workflow-legend-skip`}),`can be skipped`]})]})}function X({progress:e,state:t}){return t===`done`?(0,H.jsx)(`span`,{className:`visually-hidden`,children:`, done`}):t!==`current`||!e?.note?null:(0,H.jsx)(`span`,{className:`workflow-graph-note`,children:e.note})}function Z({graph:e,stateOf:t}){let n=n=>{let r=e.nodes.find(e=>e.id===n.to),i=r?t(r):void 0;return n.kind===`flow`&&(i===`done`||i===`current`)};return(0,H.jsxs)(`svg`,{className:`workflow-graph-layer`,"aria-hidden":`true`,focusable:`false`,children:[(0,H.jsx)(`svg`,{viewBox:`0 0 ${j(e)} ${e.columns}`,preserveAspectRatio:`none`,overflow:`visible`,children:e.edges.map(t=>(0,H.jsx)(`path`,{className:`workflow-graph-edge`,d:L(e,t),"data-edge-kind":t.kind,"data-edge-from":t.from,"data-edge-to":t.to,"data-new-session":t.newSession?`true`:void 0,"data-travelled":n(t)?`true`:void 0},`${t.kind}-${t.from}-${t.to}`))}),e.nodes.map(t=>{if(t.kind!==`start`)return null;let{x:n,y:r}=z(e,M(t));return(0,H.jsx)(`circle`,{className:`workflow-graph-start`,cx:n,cy:r,r:`3.5`},t.id)}),e.edges.map(t=>{if(!t.newSession)return null;let{x:n,y:r}=z(e,R(e,t));return(0,H.jsx)(`circle`,{className:`workflow-graph-session`,"data-session-mark":t.to,cx:n,cy:r,r:`3.5`},`${t.from}-${t.to}`)})]})}function Q({path:e,step:t,box:n,plain:r,children:i}){return(0,H.jsxs)(r?`span`:`a`,{className:n?`workflow-graph-link workflow-graph-box`:`workflow-graph-link`,href:r?void 0:`#${W(e,t)}`,"data-map-stage":t.id,"data-stage-kind":t.kind,"data-optional":t.optional?`true`:void 0,"aria-label":t.kind===`human`?t.label:void 0,children:[t.badges.includes(`openspec`)?(0,H.jsx)(`span`,{className:`workflow-graph-openspec`,"aria-hidden":`true`}):null,t.kind===`human`?t.artifact:t.label,i]})}function re({path:e,step:t}){return(0,H.jsxs)(`article`,{className:`workflow-card`,id:W(e,t),"data-stage":t.id,"data-stage-kind":t.kind,"data-optional":t.optional?`true`:void 0,children:[(0,H.jsxs)(`header`,{className:`workflow-card-header`,children:[(0,H.jsxs)(`div`,{className:`workflow-card-heading`,children:[(0,H.jsx)(`h3`,{children:t.label}),(0,H.jsx)(se,{badges:oe(t)})]}),(0,H.jsxs)(`p`,{className:`workflow-card-meta`,children:[(0,H.jsx)(`span`,{children:y[t.phase]}),t.skill?(0,H.jsx)(`code`,{children:t.skill}):null,t.sessionBreakBefore?(0,H.jsx)(`span`,{className:`workflow-card-session`,children:`New session / clean chat`}):null]})]}),(0,H.jsx)(ie,{step:t}),t.missingSkill?(0,H.jsxs)(`p`,{className:`workflow-missing-skill`,role:`note`,children:[`Skill not reported for this companion: `,(0,H.jsx)(`code`,{children:t.missingSkill}),`. Run`,` `,(0,H.jsx)(`code`,{children:`mate companion update`}),`; this stage is not complete.`]}):null,(0,H.jsxs)(`dl`,{className:`workflow-card-explanation`,children:[(0,H.jsxs)(`div`,{children:[(0,H.jsx)(`dt`,{children:`What`}),(0,H.jsx)(`dd`,{children:t.what})]}),(0,H.jsxs)(`div`,{children:[(0,H.jsx)(`dt`,{children:`Why`}),(0,H.jsx)(`dd`,{children:t.why})]})]}),(0,H.jsx)(`footer`,{className:`workflow-card-footer`,children:(0,H.jsx)(`a`,{href:`#${G(e)}`,children:`Path overview`})})]})}function ie({step:e}){return e.kind===`human`?(0,H.jsxs)(`p`,{className:`workflow-card-human`,children:[`Review `,e.artifact,` yourself — no skill, no prompt`]}):e.alternatives?.length?(0,H.jsx)(ae,{step:e}):e.prompt?(0,H.jsxs)(`div`,{className:`workflow-command`,children:[(0,H.jsx)(`span`,{className:`workflow-command-label`,children:`Run`}),(0,H.jsx)(`code`,{children:e.prompt}),(0,H.jsx)($,{text:e.copyPrompt??e.prompt,label:`${e.label} prompt`})]}):null}function ae({step:e}){return e.alternatives?.length?(0,H.jsx)(`div`,{className:`workflow-option-list`,children:e.alternatives.map(e=>(0,H.jsxs)(`div`,{className:`workflow-option`,children:[(0,H.jsxs)(`div`,{className:`workflow-command`,children:[(0,H.jsx)(`span`,{className:`workflow-command-label`,children:`Option`}),(0,H.jsx)(`code`,{children:e.prompt}),(0,H.jsx)($,{text:e.copyPrompt,label:`${e.name} prompt`})]}),(0,H.jsx)(`small`,{children:e.description})]},e.name))}):null}function $({text:e,label:t}){return(0,H.jsx)(`button`,{type:`button`,className:`runway-step-copy`,"data-copy":e,"data-copy-label":t,children:`Copy`})}var oe=e=>e.badges.filter(e=>e!==`skill`);function se({badges:e}){return(0,H.jsx)(`span`,{className:`workflow-badges`,children:e.map(e=>(0,H.jsx)(`em`,{className:`runway-step-badge runway-step-badge-${e}`,children:e===`human-review`?`Human review`:e},e))})}export{J as n,T as r,ne as t};