@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,3 +1,5 @@
1
+ /** @jsxRuntime automatic */
2
+ /** @jsxImportSource react */
1
3
  import { Box, Text, render as inkRender } from "ink";
2
4
  import { useEffect } from "react";
3
5
 
@@ -15,7 +17,9 @@ import {
15
17
  listSetupGitModeCompatibilities,
16
18
  listSetupPackageManagerCompatibilities,
17
19
  listSetupProviderCompatibilities,
20
+ listSetupTicketCompatibilities,
18
21
  } from "../lib/orchestrator/setup-compatibilities";
22
+ import type { TicketFormat } from "../lib/orchestrator/types";
19
23
 
20
24
  interface SetupSelectorOptions {
21
25
  initialSelections: SetupSelections;
@@ -24,7 +28,7 @@ interface SetupSelectorOptions {
24
28
  stderr?: NodeJS.WriteStream;
25
29
  }
26
30
 
27
- export type WizardStep = "providers" | "capabilities" | "gitMode";
31
+ export type WizardStep = "providers" | "capabilities" | "gitMode" | "tickets";
28
32
 
29
33
  interface SetupSelectorProps {
30
34
  activeIndex: number;
@@ -33,6 +37,7 @@ interface SetupSelectorProps {
33
37
  selectedPackageManagers: Set<string>;
34
38
  selectedCapabilities: Set<string>;
35
39
  selectedGitMode: GitModeSelection;
40
+ selectedTicket: TicketFormat;
36
41
  onMounted?: () => void;
37
42
  }
38
43
 
@@ -41,7 +46,7 @@ export const setupSelectorDeps = {
41
46
  };
42
47
 
43
48
  export interface SetupSelectorItem {
44
- kind: "provider" | "packageManager" | "capability" | "gitMode";
49
+ kind: "provider" | "packageManager" | "capability" | "gitMode" | "ticket";
45
50
  id: string;
46
51
  label: string;
47
52
  description: string;
@@ -57,16 +62,30 @@ export interface SetupSelectorState {
57
62
  selectedPackageManagers: Set<string>;
58
63
  selectedCapabilities: Set<string>;
59
64
  selectedGitMode: GitModeSelection;
65
+ selectedTicket?: TicketFormat;
60
66
  }
61
67
 
62
- export const WIZARD_STEPS: readonly WizardStep[] = ["providers", "capabilities", "gitMode"];
68
+ export const WIZARD_STEPS: readonly WizardStep[] = [
69
+ "providers",
70
+ "capabilities",
71
+ "gitMode",
72
+ "tickets",
73
+ ];
74
+
75
+ /** The Tickets step configures openspec, so it is shown only while openspec is selected. */
76
+ export function wizardStepsFor(selectedCapabilities: ReadonlySet<string>): WizardStep[] {
77
+ return WIZARD_STEPS.filter((step) => step !== "tickets" || selectedCapabilities.has("openspec"));
78
+ }
63
79
 
64
80
  const STEP_DISPLAY_NAMES: Record<WizardStep, string> = {
65
81
  providers: "Agents",
66
82
  capabilities: "Capabilities",
67
83
  gitMode: "Git Auto Mode",
84
+ tickets: "Tickets",
68
85
  };
69
86
 
87
+ const RADIO_STEPS: ReadonlySet<WizardStep> = new Set(["gitMode", "tickets"]);
88
+
70
89
  export function parseSelectorInput(
71
90
  input: string,
72
91
  ): "up" | "down" | "toggle" | "submit" | "cancel" | "back" | null {
@@ -87,7 +106,10 @@ function getDistributionSelectorItems(knownIds: Set<string>): SetupSelectorItem[
87
106
  return getActiveDistribution()
88
107
  .registry.getEntries()
89
108
  .filter(
90
- (entry) => SELECTABLE_PLUGIN_KINDS.has(entry.plugin.kind) && !knownIds.has(entry.plugin.id),
109
+ (entry) =>
110
+ SELECTABLE_PLUGIN_KINDS.has(entry.plugin.kind) &&
111
+ entry.plugin.selectable !== false &&
112
+ !knownIds.has(entry.plugin.id),
91
113
  )
92
114
  .map((entry) => ({
93
115
  kind: entry.plugin.kind as "provider" | "packageManager" | "capability",
@@ -144,6 +166,12 @@ export function getSelectableItems(): SetupSelectorItem[] {
144
166
  label: entry.label,
145
167
  description: entry.description,
146
168
  })),
169
+ ...listSetupTicketCompatibilities().map((entry) => ({
170
+ kind: "ticket" as const,
171
+ id: entry.id,
172
+ label: entry.label,
173
+ description: entry.description,
174
+ })),
147
175
  ]);
148
176
  }
149
177
 
@@ -152,6 +180,7 @@ export function getItemsForStep(step: WizardStep): SetupSelectorItem[] {
152
180
  providers: "provider",
153
181
  capabilities: "capability",
154
182
  gitMode: "gitMode",
183
+ tickets: "ticket",
155
184
  };
156
185
  return getSelectableItems().filter((item) => item.kind === kindMap[step]);
157
186
  }
@@ -212,6 +241,7 @@ export function toggleSelectableItem(
212
241
  selectedPackageManagers,
213
242
  selectedCapabilities,
214
243
  selectedGitMode: state.selectedGitMode,
244
+ ...(state.selectedTicket ? { selectedTicket: state.selectedTicket } : {}),
215
245
  };
216
246
  }
217
247
 
@@ -219,21 +249,29 @@ export function selectRadioItem(
219
249
  state: SetupSelectorState,
220
250
  current: SetupSelectorItem,
221
251
  ): SetupSelectorState {
222
- if (current.kind !== "gitMode") return state;
223
- return {
252
+ if (current.kind !== "gitMode" && current.kind !== "ticket") return state;
253
+ const next: SetupSelectorState = {
224
254
  selectedProviders: new Set(state.selectedProviders),
225
255
  selectedPackageManagers: new Set(state.selectedPackageManagers),
226
256
  selectedCapabilities: new Set(state.selectedCapabilities),
227
- selectedGitMode: current.id as GitModeSelection,
257
+ selectedGitMode: state.selectedGitMode,
258
+ ...(state.selectedTicket ? { selectedTicket: state.selectedTicket } : {}),
228
259
  };
260
+ if (current.kind === "gitMode") next.selectedGitMode = current.id as GitModeSelection;
261
+ else next.selectedTicket = current.id as TicketFormat;
262
+ return next;
229
263
  }
230
264
 
231
265
  function getInitialActiveIndexForStep(
232
266
  step: WizardStep,
233
267
  selectedGitMode: GitModeSelection = DEFAULT_GIT_MODE_SELECTION,
268
+ selectedTicket: TicketFormat = "none",
234
269
  ): number {
235
- if (step !== "gitMode") return 0;
236
- const index = getItemsForStep(step).findIndex((item) => item.id === selectedGitMode);
270
+ let selected: string;
271
+ if (step === "gitMode") selected = selectedGitMode;
272
+ else if (step === "tickets") selected = selectedTicket;
273
+ else return 0;
274
+ const index = getItemsForStep(step).findIndex((item) => item.id === selected);
237
275
  return index >= 0 ? index : 0;
238
276
  }
239
277
 
@@ -244,18 +282,20 @@ function SetupSelectorApp({
244
282
  selectedPackageManagers,
245
283
  selectedCapabilities,
246
284
  selectedGitMode,
285
+ selectedTicket,
247
286
  onMounted,
248
287
  }: SetupSelectorProps) {
249
288
  useEffect(() => {
250
289
  onMounted?.();
251
290
  }, [onMounted]);
252
291
 
253
- const totalSteps = WIZARD_STEPS.length;
254
- const stepKey = WIZARD_STEPS[currentStep];
292
+ const steps = wizardStepsFor(selectedCapabilities);
293
+ const totalSteps = steps.length;
294
+ const stepKey = steps[currentStep];
255
295
  const stepName = STEP_DISPLAY_NAMES[stepKey];
256
296
  const disabledCapabilityIds = getDisabledCapabilityIds(selectedPackageManagers);
257
297
  const navigableItems = getItemsForStep(stepKey);
258
- const isRadioStep = stepKey === "gitMode";
298
+ const isRadioStep = RADIO_STEPS.has(stepKey);
259
299
  const isLastStep = currentStep === totalSteps - 1;
260
300
  const enterHint = isLastStep ? "enter confirm" : "enter next";
261
301
  const backHint = currentStep > 0 ? " · ← back" : "";
@@ -298,6 +338,16 @@ function SetupSelectorApp({
298
338
  },
299
339
  ];
300
340
  }
341
+ if (item.kind === "ticket") {
342
+ return [
343
+ {
344
+ key: `ticket:${item.id}`,
345
+ label: item.label,
346
+ description: item.description,
347
+ indicator: renderIndicator(selectedTicket === item.id, { mode: "radio" }),
348
+ },
349
+ ];
350
+ }
301
351
  return [];
302
352
  });
303
353
 
@@ -345,6 +395,7 @@ export async function selectSetupCompatibilities(
345
395
  let selectedPackageManagers = new Set(initialSelections.packageManagers);
346
396
  let selectedCapabilities = new Set(initialSelections.capabilities.map((entry) => entry.name));
347
397
  let selectedGitMode = initialSelections.selectedGitMode;
398
+ let selectedTicket: TicketFormat = initialSelections.selectedTicket ?? "none";
348
399
  let rendered: ReturnType<typeof inkRender> | undefined;
349
400
 
350
401
  const cleanup = () => {
@@ -363,7 +414,8 @@ export async function selectSetupCompatibilities(
363
414
  resolve(value);
364
415
  };
365
416
 
366
- const getCurrentStep = () => WIZARD_STEPS[currentStep];
417
+ const steps = () => wizardStepsFor(selectedCapabilities);
418
+ const getCurrentStep = () => steps()[currentStep];
367
419
  const getCurrentItems = () => getItemsForStep(getCurrentStep());
368
420
 
369
421
  const rerender = () => {
@@ -375,6 +427,7 @@ export async function selectSetupCompatibilities(
375
427
  selectedPackageManagers={selectedPackageManagers}
376
428
  selectedCapabilities={selectedCapabilities}
377
429
  selectedGitMode={selectedGitMode}
430
+ selectedTicket={selectedTicket}
378
431
  />,
379
432
  );
380
433
  };
@@ -432,30 +485,34 @@ export async function selectSetupCompatibilities(
432
485
 
433
486
  if (action === "submit") {
434
487
  const stepKey = getCurrentStep();
435
- if (stepKey === "gitMode") {
488
+ if (RADIO_STEPS.has(stepKey)) {
436
489
  const current = getCurrentItems()[activeIndex];
437
- if (current && current.id !== selectedGitMode) {
490
+ const selected = stepKey === "gitMode" ? selectedGitMode : selectedTicket;
491
+ if (current && current.id !== selected) {
438
492
  const next = selectRadioItem(
439
493
  {
440
494
  selectedProviders,
441
495
  selectedPackageManagers,
442
496
  selectedCapabilities,
443
497
  selectedGitMode,
498
+ selectedTicket,
444
499
  },
445
500
  current,
446
501
  );
447
- selectedProviders = next.selectedProviders;
448
- selectedPackageManagers = next.selectedPackageManagers;
449
- selectedCapabilities = next.selectedCapabilities;
450
502
  selectedGitMode = next.selectedGitMode;
503
+ selectedTicket = next.selectedTicket ?? selectedTicket;
451
504
  rerender();
452
505
  return;
453
506
  }
454
507
  }
455
508
 
456
- if (currentStep < WIZARD_STEPS.length - 1) {
509
+ if (currentStep < steps().length - 1) {
457
510
  currentStep++;
458
- activeIndex = getInitialActiveIndexForStep(WIZARD_STEPS[currentStep], selectedGitMode);
511
+ activeIndex = getInitialActiveIndexForStep(
512
+ steps()[currentStep],
513
+ selectedGitMode,
514
+ selectedTicket,
515
+ );
459
516
  rerender();
460
517
  return;
461
518
  }
@@ -475,6 +532,7 @@ export async function selectSetupCompatibilities(
475
532
  .map((id) => ({ name: id })),
476
533
  ],
477
534
  selectedGitMode,
535
+ selectedTicket,
478
536
  });
479
537
  rendered?.unmount();
480
538
  return;
@@ -506,6 +564,7 @@ export async function selectSetupCompatibilities(
506
564
  selectedPackageManagers={selectedPackageManagers}
507
565
  selectedCapabilities={selectedCapabilities}
508
566
  selectedGitMode={selectedGitMode}
567
+ selectedTicket={selectedTicket}
509
568
  onMounted={onMounted}
510
569
  />,
511
570
  { stdin, stdout, stderr, exitOnCtrlC: true, interactive: true },
package/src/cli/usage.ts CHANGED
@@ -21,9 +21,14 @@ export function usage(): string {
21
21
  ` ${n} companion open`,
22
22
  ` ${n} companion tui`,
23
23
  ` ${n} working cleanup`,
24
+ ` ${n} working link --companion <path> --yes`,
25
+ ` ${n} working worktree <workset-id> [--companion <path>] [--no-install] [--json]`,
26
+ ` ${n} working worktree --change <change> [--enter] [--companion <path>] [--no-install] [--json]`,
27
+ ` ${n} working worktree prune [--companion <path>] [--json]`,
24
28
  ` ${n} wrap [--companion PATH]`,
25
29
  ` ${n} unwrap`,
26
30
  ` ${n} session prepare --repo <dir> [--json] [--sync]`,
31
+ ` ${n} session context --repo <dir> [--json]`,
27
32
  ` ${n} hub init [folder]`,
28
33
  ` ${n} hub add [source] [--id ID] [--path PATH]`,
29
34
  ` ${n} hub sync [--json] (companions + hub plugins)`,
@@ -31,15 +36,20 @@ export function usage(): string {
31
36
  " target: a dated archive anchor, or a change name matching exactly one archive",
32
37
  ` ${n} artifact pending [--json]`,
33
38
  ` ${n} artifact link <change>... [--repository <org/repo>] [--branch <b> [--direct]]`,
34
- " [--not-applicable <reason>] [--pr <url>] [--refresh]",
39
+ " [--not-applicable <reason>] [--pr <url>] [--ticket <KEY>] [--refresh]",
35
40
  " [--confirm-merged|--confirm-open|--confirm-dropped] [--json]",
36
41
  ` ${n} artifact archive <change> [--repository <org/repo>] [--branch <b> [--direct]|--not-applicable <reason>|--skip-branch] [--json]`,
42
+ ` ${n} artifact apply-context <change> --json [--since <digest>]`,
37
43
  ` ${n} doctor`,
38
44
  ` ${n} report [--days N] [--input FILE|-] [--json]`,
39
45
  ` ${n} studio [--writable] [--terminal] [--detach-timeout <minutes>]`,
40
46
  ` ${n} studio serve --port <port> [--host <host>] [--writable] [--terminal]`,
41
47
  " [--detach-timeout <minutes>] [--token <value>] [--allowed-host <host>]",
42
48
  " [--public-origin <origin>] [--companion <path>] [--no-git]",
49
+ " [--profile standard|appliance]",
50
+ ` ${n} factory serve --socket <path> --docker-host <url> --state-dir <dir> --image <image>`,
51
+ " --user <name> --companions-dir <dir> (the appliance's factory broker, run as root)",
52
+ ` ${n} factory attach <workset> --session <id> --companion <path> [--start clarify|explore|continue]`,
43
53
  ` ${n} config`,
44
54
  ` ${n} claude [args...] (after --: --no-git, --companion, --yes no-op)`,
45
55
  ` ${n} opencode [args...] (after --: --no-git, --companion, --yes no-op)`,
@@ -23,15 +23,16 @@ export interface MateCli {
23
23
  /**
24
24
  * Assemble a distribution from an identity config and plugin registration
25
25
  * entries. Distributions choose their plugin set; the framework always adds
26
- * bun and uv as required runtime substrate, plus gitignore management named
27
- * after the framework identity (built last since it reads the full plugin
28
- * set). Returns the runnable CLI.
26
+ * bun as the required runtime substrate, uv for the capabilities that install
27
+ * through it (enabled only by them, e.g. Graphify), plus gitignore management
28
+ * named after the framework identity (built last since it reads the full
29
+ * plugin set). Returns the runnable CLI.
29
30
  */
30
31
  export function createMate({ config, plugins, main: runMain = main }: CreateMateOptions): MateCli {
31
32
  const registry = new PluginRegistry([
32
33
  ...plugins,
33
34
  { plugin: createBunPlugin(), policy: "required" },
34
- { plugin: createUvPlugin(), policy: "required" },
35
+ { plugin: createUvPlugin(), policy: "optional" },
35
36
  createGitignorePlugin(FRAMEWORK_NAME),
36
37
  ]);
37
38
  setActiveDistribution({ config, registry });
@@ -0,0 +1,26 @@
1
+ // Route a Claude session's tokensave calls to the linked worktree it works in.
2
+ import { routeTokensaveInput, type RouteDeps } from "../runtime/tokensave-route";
3
+ import { hookOutcome, type HookOutcome } from "./hook-io";
4
+
5
+ interface TokensaveHookInput {
6
+ cwd?: unknown;
7
+ tool_name?: unknown;
8
+ tool_input?: unknown;
9
+ }
10
+
11
+ /**
12
+ * `updatedInput` when the call should run against the session directory's
13
+ * worktree, else no output. Never a permission decision: the call keeps its
14
+ * own permission flow. Input-pure, so the plugin copy and a carried copy
15
+ * emit the same rewrite and the call is routed once either way.
16
+ */
17
+ export function buildTokensaveRoute(input: unknown, deps?: RouteDeps): HookOutcome {
18
+ const { cwd, tool_name: tool, tool_input: toolInput } = (input ?? {}) as TokensaveHookInput;
19
+ const updatedInput =
20
+ typeof cwd === "string" && typeof tool === "string"
21
+ ? routeTokensaveInput(tool, cwd, toolInput, deps)
22
+ : undefined;
23
+ return hookOutcome(
24
+ updatedInput ? { hookSpecificOutput: { hookEventName: "PreToolUse", updatedInput } } : null,
25
+ );
26
+ }
@@ -0,0 +1,174 @@
1
+ import { createHash } from "node:crypto";
2
+ import fs from "node:fs/promises";
3
+ import path from "node:path";
4
+
5
+ import { isSecretFile, type SecretPolicy } from "../../runtime/secret-patterns";
6
+ import type { ApplyPayload, ArtifactFingerprint } from "./protocol";
7
+
8
+ export interface FingerprintOptions {
9
+ /** Directories a referenced file must resolve into; nothing outside them is read. */
10
+ allowedRoots: string[];
11
+ secretPolicy: SecretPolicy;
12
+ readFile?: (filePath: string) => Promise<string>;
13
+ realpath?: (filePath: string) => Promise<string>;
14
+ }
15
+
16
+ export type FingerprintResult =
17
+ | {
18
+ ok: true;
19
+ /** Hashes with validated tracked checkbox states normalized; feeds the digest. */
20
+ fingerprints: ArtifactFingerprint[];
21
+ /** Hashes of the bytes as read; detects a file changing during collection. */
22
+ raw: ArtifactFingerprint[];
23
+ }
24
+ | { ok: false; reason: string };
25
+
26
+ /** A task checkbox line: indent, list marker, the state character, then the task text. */
27
+ const CHECKBOX = /^(\s*[-*+]\s+\[)([ xX])(\]\s+)(.*?)\s*$/;
28
+
29
+ interface TrackedTask {
30
+ id: string;
31
+ description: string;
32
+ done: boolean;
33
+ line: number;
34
+ }
35
+
36
+ function sha256(text: string): string {
37
+ return createHash("sha256").update(text).digest("hex");
38
+ }
39
+
40
+ function isUnder(child: string, root: string): boolean {
41
+ const relative = path.relative(root, child);
42
+ return relative === "" || (!relative.startsWith("..") && !path.isAbsolute(relative));
43
+ }
44
+
45
+ /** Every file path the payload references: `contextFiles` values and task source paths. */
46
+ function referencedPaths(payload: ApplyPayload): string[] | string {
47
+ const paths = new Set<string>();
48
+ const contextFiles = payload.contextFiles;
49
+ if (contextFiles !== undefined) {
50
+ if (contextFiles === null || typeof contextFiles !== "object" || Array.isArray(contextFiles)) {
51
+ return "contextFiles has an unsupported shape";
52
+ }
53
+ for (const value of Object.values(contextFiles)) {
54
+ const list = Array.isArray(value) ? value : [value];
55
+ for (const entry of list) {
56
+ if (typeof entry !== "string") return "contextFiles has an unsupported shape";
57
+ paths.add(entry);
58
+ }
59
+ }
60
+ }
61
+ if (Array.isArray(payload.tasks)) {
62
+ for (const task of payload.tasks as Record<string, unknown>[]) {
63
+ if (task && typeof task.sourcePath === "string") paths.add(task.sourcePath);
64
+ }
65
+ }
66
+ return [...paths].sort();
67
+ }
68
+
69
+ /** Tasks per source file; a string names the ambiguity that disables compaction. */
70
+ function trackedTasks(payload: ApplyPayload): Map<string, TrackedTask[]> | string {
71
+ const byFile = new Map<string, TrackedTask[]>();
72
+ if (!Array.isArray(payload.tasks)) return byFile;
73
+ const locations = new Set<string>();
74
+ for (const task of payload.tasks as Record<string, unknown>[]) {
75
+ if (!task || task.sourcePath === undefined) continue;
76
+ const { id, description, done, sourcePath, line } = task;
77
+ if (
78
+ typeof sourcePath !== "string" ||
79
+ typeof id !== "string" ||
80
+ typeof description !== "string" ||
81
+ typeof done !== "boolean" ||
82
+ typeof line !== "number" ||
83
+ !Number.isInteger(line) ||
84
+ line < 1
85
+ ) {
86
+ return `task ${String(id)} has an unsupported source location`;
87
+ }
88
+ const location = `${sourcePath}:${line}`;
89
+ if (locations.has(location)) return `two tasks share the source location ${location}`;
90
+ locations.add(location);
91
+ const list = byFile.get(sourcePath) ?? [];
92
+ list.push({ id, description, done, line });
93
+ byFile.set(sourcePath, list);
94
+ }
95
+ return byFile;
96
+ }
97
+
98
+ /**
99
+ * Normalizes the checkbox state character of each task line that freshly parsed
100
+ * upstream tasks vouch for. Any line that does not match its task, by text or by
101
+ * state, makes the file ambiguous: every other byte stays significant.
102
+ */
103
+ function normalizeTracked(content: string, tasks: TrackedTask[]): string | { reason: string } {
104
+ const lines = content.split("\n");
105
+ for (const task of tasks) {
106
+ const match = CHECKBOX.exec(lines[task.line - 1] ?? "");
107
+ if (!match || match[4] !== task.description.trim()) {
108
+ return { reason: `task ${task.id} does not match its source line ${task.line}` };
109
+ }
110
+ if ((match[2] !== " ") !== task.done) {
111
+ return { reason: `task ${task.id} state differs from its source line ${task.line}` };
112
+ }
113
+ lines[task.line - 1] = lines[task.line - 1].replace(
114
+ CHECKBOX,
115
+ (_all, open, _state, close, text) => `${open} ${close}${text}`,
116
+ );
117
+ }
118
+ return lines.join("\n");
119
+ }
120
+
121
+ /**
122
+ * Read-only fingerprints of every referenced artifact. Files outside the allowed
123
+ * roots, secret files, unreadable files, and ambiguous task locations are never
124
+ * guessed around: they disable compaction with a reason.
125
+ */
126
+ export async function fingerprintArtifacts(
127
+ payload: ApplyPayload,
128
+ options: FingerprintOptions,
129
+ ): Promise<FingerprintResult> {
130
+ const readFile = options.readFile ?? ((filePath: string) => fs.readFile(filePath, "utf8"));
131
+ const realpath = options.realpath ?? fs.realpath;
132
+ const paths = referencedPaths(payload);
133
+ if (typeof paths === "string") return { ok: false, reason: paths };
134
+ const tracked = trackedTasks(payload);
135
+ if (typeof tracked === "string") return { ok: false, reason: tracked };
136
+
137
+ const roots: string[] = [];
138
+ for (const root of options.allowedRoots) {
139
+ roots.push(await realpath(root).catch(() => path.resolve(root)));
140
+ }
141
+
142
+ const fingerprints: ArtifactFingerprint[] = [];
143
+ const raw: ArtifactFingerprint[] = [];
144
+ for (const filePath of paths) {
145
+ if (!path.isAbsolute(filePath)) return { ok: false, reason: `${filePath} is not absolute` };
146
+ if (isSecretFile(filePath, options.secretPolicy)) {
147
+ return { ok: false, reason: `${path.basename(filePath)} is a secret file and is not read` };
148
+ }
149
+ let resolved: string;
150
+ try {
151
+ resolved = await realpath(filePath);
152
+ } catch {
153
+ return { ok: false, reason: `${filePath} is unreadable` };
154
+ }
155
+ if (!roots.some((root) => isUnder(resolved, root))) {
156
+ return { ok: false, reason: `${filePath} is outside the companion and Working Repository` };
157
+ }
158
+ if (isSecretFile(resolved, options.secretPolicy)) {
159
+ return { ok: false, reason: `${path.basename(resolved)} is a secret file and is not read` };
160
+ }
161
+ let content: string;
162
+ try {
163
+ content = await readFile(resolved);
164
+ } catch {
165
+ return { ok: false, reason: `${filePath} is unreadable` };
166
+ }
167
+ const tasks = tracked.get(filePath);
168
+ const normalized = tasks ? normalizeTracked(content, tasks) : content;
169
+ if (typeof normalized !== "string") return { ok: false, reason: normalized.reason };
170
+ fingerprints.push({ path: filePath, sha256: sha256(normalized) });
171
+ raw.push({ path: filePath, sha256: sha256(content) });
172
+ }
173
+ return { ok: true, fingerprints, raw };
174
+ }