@uniqbit/mate-core 0.18.5 → 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 (390) 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/companion-instructions.mjs +9 -0
  7. package/claude-plugin/hooks/hooks.json +21 -2
  8. package/claude-plugin/hooks/tokensave-route.mjs +52 -0
  9. package/opencode-plugin/src/server.ts +4 -0
  10. package/opencode-plugin/src/tui.tsx +2 -0
  11. package/opencode-plugin/tui.tsx +2 -0
  12. package/package.json +52 -15
  13. package/src/brand/art.generated.ts +69 -0
  14. package/src/brand/index.ts +12 -0
  15. package/src/brand/palette.ts +19 -0
  16. package/src/brand/svg.generated.ts +8 -0
  17. package/src/brand/terminal.ts +88 -0
  18. package/src/brand/types.ts +33 -0
  19. package/src/cli/commands/artifact/apply-context.ts +275 -0
  20. package/src/cli/commands/artifact/artifact.ts +12 -0
  21. package/src/cli/commands/artifact/delivery/archive.ts +125 -0
  22. package/src/cli/commands/artifact/delivery/branch-flags.ts +55 -0
  23. package/src/cli/commands/artifact/delivery/environment.ts +127 -0
  24. package/src/cli/commands/artifact/delivery/link.ts +174 -0
  25. package/src/cli/commands/artifact/delivery/output.ts +89 -0
  26. package/src/cli/commands/artifact/finish/command.ts +83 -8
  27. package/src/cli/commands/artifact/finish/engine.ts +91 -14
  28. package/src/cli/commands/artifact/finish/finisher.ts +10 -0
  29. package/src/cli/commands/artifact/finish/git.ts +132 -19
  30. package/src/cli/commands/artifact/finish/openspec.ts +182 -138
  31. package/src/cli/commands/artifact/finish/secret-scan.ts +43 -0
  32. package/src/cli/commands/artifact/finish/worktree-cleanup.ts +92 -0
  33. package/src/cli/commands/artifact/pending/command.ts +31 -3
  34. package/src/cli/commands/artifact/pending/discovery.ts +21 -57
  35. package/src/cli/commands/cap/graphify.ts +52 -3
  36. package/src/cli/commands/cap/index-cmd.ts +71 -15
  37. package/src/cli/commands/cap/openspec.ts +13 -25
  38. package/src/cli/commands/cap/tokensave.ts +7 -5
  39. package/src/cli/commands/companion/link.ts +14 -1
  40. package/src/cli/commands/companion/open.ts +68 -46
  41. package/src/cli/commands/companion/sync.ts +10 -0
  42. package/src/cli/commands/companion/tui.ts +17 -7
  43. package/src/cli/commands/companion/update.ts +143 -48
  44. package/src/cli/commands/doctor.ts +195 -7
  45. package/src/cli/commands/factory/factory.ts +301 -0
  46. package/src/cli/commands/install.ts +133 -9
  47. package/src/cli/commands/launch/shared.ts +16 -11
  48. package/src/cli/commands/plugin/install.ts +9 -4
  49. package/src/cli/commands/plugin/plugin.ts +3 -2
  50. package/src/cli/commands/report/adapter.ts +11 -2
  51. package/src/cli/commands/report/contract.ts +21 -0
  52. package/src/cli/commands/report/highlight.ts +34 -4
  53. package/src/cli/commands/report/index.ts +20 -1
  54. package/src/cli/commands/report/markdown.ts +110 -0
  55. package/src/cli/commands/report/palette.ts +118 -0
  56. package/src/cli/commands/report/renderer.ts +456 -153
  57. package/src/cli/commands/report/types.ts +16 -0
  58. package/src/cli/commands/session/context.ts +102 -0
  59. package/src/cli/commands/setup.ts +50 -24
  60. package/src/cli/commands/studio/factory-credential.ts +49 -0
  61. package/src/cli/commands/studio/index.ts +29 -2
  62. package/src/cli/commands/studio/openspec-cli.ts +10 -58
  63. package/src/cli/commands/studio/payload.ts +249 -15
  64. package/src/cli/commands/studio/routes.ts +41 -6
  65. package/src/cli/commands/studio/selection.ts +161 -17
  66. package/src/cli/commands/studio/server.ts +404 -324
  67. package/src/cli/commands/studio/services.ts +60 -0
  68. package/src/cli/commands/studio/studio-app.ts +67 -0
  69. package/src/cli/commands/studio/terminal-assets.ts +21 -33
  70. package/src/cli/commands/studio/terminal.ts +85 -15
  71. package/src/cli/commands/studio/views/model.ts +18 -0
  72. package/src/cli/commands/studio/views/vault/markdown-tree.ts +267 -0
  73. package/src/cli/commands/studio/views/vault/view.ts +185 -0
  74. package/src/cli/commands/studio/workset-session.ts +131 -0
  75. package/src/cli/commands/unwrap.ts +8 -0
  76. package/src/cli/commands/update.ts +27 -1
  77. package/src/cli/commands/working/cleanup.ts +10 -1
  78. package/src/cli/commands/working/link.ts +76 -0
  79. package/src/cli/commands/working/working.ts +10 -0
  80. package/src/cli/commands/working/worktree.ts +356 -0
  81. package/src/cli/commands/wrap.ts +5 -13
  82. package/src/cli/companion-link-wizard.tsx +2 -0
  83. package/src/cli/companion-selector.tsx +2 -0
  84. package/src/cli/confirm.ts +2 -0
  85. package/src/cli/install-plan.tsx +127 -160
  86. package/src/cli/launch-selector.tsx +2 -0
  87. package/src/cli/main.ts +22 -1
  88. package/src/cli/parse-flags.ts +32 -6
  89. package/src/cli/repo-list-table.tsx +2 -0
  90. package/src/cli/setup-selector.tsx +86 -151
  91. package/src/cli/usage.ts +14 -0
  92. package/src/create-mate.ts +5 -4
  93. package/src/hooks/companion-instructions.ts +190 -0
  94. package/src/hooks/hook-io.ts +63 -0
  95. package/src/hooks/session-banner.ts +21 -29
  96. package/src/hooks/session-guidance.ts +9 -17
  97. package/src/hooks/session-prepare.ts +115 -28
  98. package/src/hooks/tokensave-route.ts +26 -0
  99. package/src/hooks/validate-artifact-path.ts +82 -24
  100. package/src/index.ts +4 -0
  101. package/src/lib/apply-context/fingerprint.ts +174 -0
  102. package/src/lib/apply-context/protocol.ts +193 -0
  103. package/src/lib/change-layout.ts +154 -0
  104. package/src/lib/components/confirm-prompt.tsx +21 -9
  105. package/src/lib/components/select-menu.tsx +10 -3
  106. package/src/lib/components/spinner.tsx +4 -2
  107. package/src/lib/components/startup-progress.tsx +227 -41
  108. package/src/lib/components/text-input-display.tsx +2 -0
  109. package/src/lib/components/wizard-footer.tsx +2 -0
  110. package/src/lib/components/wizard-header.tsx +16 -12
  111. package/src/lib/context-mode-package.ts +24 -11
  112. package/src/lib/delivery/archive-change.ts +166 -0
  113. package/src/lib/delivery/branches.ts +132 -0
  114. package/src/lib/delivery/environment.ts +35 -0
  115. package/src/lib/delivery/forge.ts +279 -0
  116. package/src/lib/delivery/merge-git.ts +261 -0
  117. package/src/lib/delivery/overlap.ts +209 -0
  118. package/src/lib/delivery/record-delivery.ts +283 -0
  119. package/src/lib/delivery/record.ts +403 -0
  120. package/src/lib/delivery/refresh.ts +268 -0
  121. package/src/lib/delivery/repository-access.ts +141 -0
  122. package/src/lib/delivery/resolve-branch.ts +162 -0
  123. package/src/lib/delivery/stages.ts +111 -0
  124. package/src/lib/delivery/token.ts +24 -0
  125. package/src/lib/factory/attach-client.ts +113 -0
  126. package/src/lib/factory/attach.ts +178 -0
  127. package/src/lib/factory/broker.ts +190 -0
  128. package/src/lib/factory/bun-commands.ts +39 -0
  129. package/src/lib/factory/client.ts +92 -0
  130. package/src/lib/factory/command.ts +61 -0
  131. package/src/lib/factory/credential-store.ts +153 -0
  132. package/src/lib/factory/frames.ts +77 -0
  133. package/src/lib/factory/ids.ts +58 -0
  134. package/src/lib/factory/keyed-serial.ts +27 -0
  135. package/src/lib/factory/outcomes/actions.ts +114 -0
  136. package/src/lib/factory/outcomes/index.ts +381 -0
  137. package/src/lib/factory/outcomes/lifecycle.ts +205 -0
  138. package/src/lib/factory/outcomes/runs.ts +81 -0
  139. package/src/lib/factory/outcomes/sessions.ts +38 -0
  140. package/src/lib/factory/prepare.ts +49 -0
  141. package/src/lib/factory/pty.ts +103 -0
  142. package/src/lib/factory/runner/companion-context.ts +178 -0
  143. package/src/lib/factory/runner/control.ts +92 -0
  144. package/src/lib/factory/runner/harness-agent.ts +250 -0
  145. package/src/lib/factory/runner/live.ts +159 -0
  146. package/src/lib/factory/runner/questions.ts +22 -0
  147. package/src/lib/factory/runner/rank.ts +26 -0
  148. package/src/lib/factory/runner/run-policy.ts +12 -0
  149. package/src/lib/factory/runner/run.ts +199 -0
  150. package/src/lib/factory/runner/scheduler.ts +416 -0
  151. package/src/lib/factory/runner/state.ts +233 -0
  152. package/src/lib/factory/runner/workflow.ts +542 -0
  153. package/src/lib/factory/runtime.ts +972 -0
  154. package/src/lib/factory/sandbox.ts +292 -0
  155. package/src/lib/factory/worktree-branch.ts +17 -0
  156. package/src/lib/frontmatter.ts +18 -0
  157. package/src/lib/install.ts +66 -14
  158. package/src/lib/live-progress.ts +36 -0
  159. package/src/lib/member-choices.ts +67 -0
  160. package/src/lib/opencode-plugin-package.ts +5 -5
  161. package/src/lib/openspec-cli.ts +116 -0
  162. package/src/lib/openspec-scopes.ts +86 -0
  163. package/src/lib/orchestrator/adapters/base.ts +55 -22
  164. package/src/lib/orchestrator/adapters/claude-args.ts +50 -0
  165. package/src/lib/orchestrator/adapters/claude.ts +54 -41
  166. package/src/lib/orchestrator/adapters/opencode.ts +2 -0
  167. package/src/lib/orchestrator/config-store.ts +3 -2
  168. package/src/lib/orchestrator/editor.ts +31 -25
  169. package/src/lib/orchestrator/openspec-store.ts +14 -54
  170. package/src/lib/orchestrator/projection-claude-commands.ts +36 -0
  171. package/src/lib/orchestrator/projection-claude-links.ts +159 -0
  172. package/src/lib/orchestrator/projection-claude-skills.ts +19 -137
  173. package/src/lib/orchestrator/projection-entries.ts +100 -34
  174. package/src/lib/orchestrator/projection-opencode-copies.ts +32 -15
  175. package/src/lib/orchestrator/projection-openspec-store.ts +54 -9
  176. package/src/lib/orchestrator/projection-runtime-documents.ts +15 -6
  177. package/src/lib/orchestrator/projection-types.ts +36 -1
  178. package/src/lib/orchestrator/refresh-working-claude-links.ts +87 -0
  179. package/src/lib/orchestrator/session-context-link.ts +67 -0
  180. package/src/lib/orchestrator/session-prepare.ts +45 -5
  181. package/src/lib/orchestrator/setup-compatibilities.ts +56 -70
  182. package/src/lib/orchestrator/types.ts +7 -2
  183. package/src/lib/orchestrator/working-repo-projection.ts +50 -7
  184. package/src/lib/orchestrator/workspace-document.ts +105 -0
  185. package/src/lib/orchestrator/wrap-pass.ts +22 -1
  186. package/src/lib/package-paths.ts +37 -0
  187. package/src/lib/runtime-directory-refresh.ts +17 -1
  188. package/src/lib/workset/record.ts +513 -0
  189. package/src/lib/workset/repositories.ts +55 -0
  190. package/src/lib/workset/stage.ts +148 -0
  191. package/src/lib/workset/stages.ts +113 -0
  192. package/src/lib/workset/worktree-index.ts +116 -0
  193. package/src/lib/workset/worktree.ts +830 -0
  194. package/src/opencode/companion-hooks.ts +109 -7
  195. package/src/opencode/companion-policy.ts +37 -18
  196. package/src/opencode/enter-worktree.ts +72 -0
  197. package/src/opencode/projected-guidance.ts +4 -1
  198. package/src/opencode/session-prepare.ts +2 -1
  199. package/src/opencode/tui.tsx +13 -6
  200. package/src/plugins.ts +1 -0
  201. package/src/runtime/artifact-refusal.ts +63 -0
  202. package/src/runtime/claude-delivery-plan.ts +107 -8
  203. package/src/runtime/commit-attribution-guard.ts +181 -0
  204. package/src/runtime/companion-git.ts +52 -10
  205. package/src/runtime/companion-guidance.ts +20 -8
  206. package/src/runtime/companion-instructions.ts +340 -0
  207. package/src/runtime/companion-lock.ts +30 -7
  208. package/src/runtime/env.ts +48 -3
  209. package/src/runtime/error-message.ts +4 -0
  210. package/src/runtime/git-layout.ts +219 -0
  211. package/src/runtime/index.ts +29 -0
  212. package/src/runtime/managed-block.ts +117 -0
  213. package/src/runtime/markdown-scan.ts +266 -0
  214. package/src/runtime/physical-path.ts +111 -0
  215. package/src/runtime/policy.ts +50 -2
  216. package/src/runtime/projected-flag.ts +7 -0
  217. package/src/runtime/projected-guidance.ts +1 -0
  218. package/src/runtime/runtime-directory.ts +5 -0
  219. package/src/runtime/runtime-document-manifest.ts +62 -11
  220. package/src/runtime/secret-guard.ts +162 -0
  221. package/src/runtime/secret-patterns.ts +397 -0
  222. package/src/runtime/secret-scan.ts +90 -0
  223. package/src/runtime/session-context.ts +98 -0
  224. package/src/runtime/session-kind.ts +13 -0
  225. package/src/runtime/shell-heredoc.ts +81 -0
  226. package/src/runtime/tokensave-route.ts +152 -0
  227. package/src/runtime/wrap-state.ts +44 -2
  228. package/src/runtime/write-atomic.ts +64 -0
  229. package/src/studio.ts +124 -0
  230. package/src/templates/capabilities/openspec-cap/mate-minimal/schema.yaml +14 -10
  231. package/src/templates/capabilities/openspec-cap/mate-minimal/templates/spec.md +3 -5
  232. package/src/templates/capabilities/openspec-cap/mate-v1/schema.yaml +18 -102
  233. package/src/templates/capabilities/openspec-cap/mate-v1/templates/spec.md +3 -5
  234. package/src/templates/capabilities/openspec-cap/openspec-conventions.yaml +20 -14
  235. package/src/templates/mate-skills/THIRD-PARTY-NOTICES.md +40 -0
  236. package/src/templates/mate-skills/agents/mate-apply-change/SKILL.md +134 -0
  237. package/src/templates/mate-skills/agents/mate-apply-change/references/mate-compact-apply.md +47 -0
  238. package/src/templates/mate-skills/agents/mate-apply-change/references/openspec-apply-change.md +200 -0
  239. package/src/templates/mate-skills/agents/mate-archive-change/SKILL.md +86 -0
  240. package/src/templates/mate-skills/{claude/mate-openspec-backfill → agents/mate-backfill-spec}/SKILL.md +11 -4
  241. package/src/templates/mate-skills/agents/mate-clarify-intent/SKILL.md +110 -0
  242. package/src/templates/mate-skills/agents/mate-explore-change/SKILL.md +66 -0
  243. package/src/templates/mate-skills/agents/mate-explore-change/references/openspec-explore.md +350 -0
  244. package/src/templates/mate-skills/agents/mate-grill-me/SKILL.md +11 -4
  245. package/src/templates/mate-skills/agents/mate-grill-with-docs/SKILL.md +2 -2
  246. package/src/templates/mate-skills/agents/mate-interview-me/SKILL.md +12 -5
  247. package/src/templates/mate-skills/agents/mate-propose-change/SKILL.md +108 -0
  248. package/src/templates/mate-skills/agents/mate-propose-change/references/mate-revise.md +47 -0
  249. package/src/templates/mate-skills/agents/mate-propose-change/references/openspec-propose.md +169 -0
  250. package/src/templates/mate-skills/agents/mate-propose-change/references/openspec-update-change.md +103 -0
  251. package/src/templates/mate-skills/agents/{mate-artifact-publish → mate-publish-artifact}/SKILL.md +111 -24
  252. package/src/templates/mate-skills/{claude/mate-artifact-publish → agents/mate-publish-artifact}/references/openspec.md +8 -5
  253. package/src/templates/mate-skills/agents/mate-show-me/SKILL.md +95 -16
  254. package/src/templates/mate-skills/agents/mate-simplify-code/SKILL.md +87 -68
  255. package/src/templates/mate-skills/claude/mate-apply-change/SKILL.md +134 -0
  256. package/src/templates/mate-skills/claude/mate-apply-change/references/mate-compact-apply.md +47 -0
  257. package/src/templates/mate-skills/claude/mate-apply-change/references/openspec-apply-change.md +200 -0
  258. package/src/templates/mate-skills/claude/mate-archive-change/SKILL.md +86 -0
  259. package/src/templates/mate-skills/{agents/mate-openspec-backfill → claude/mate-backfill-spec}/SKILL.md +11 -4
  260. package/src/templates/mate-skills/claude/mate-clarify-intent/SKILL.md +110 -0
  261. package/src/templates/mate-skills/claude/mate-explore-change/SKILL.md +66 -0
  262. package/src/templates/mate-skills/claude/mate-explore-change/references/openspec-explore.md +350 -0
  263. package/src/templates/mate-skills/claude/mate-grill-me/SKILL.md +11 -4
  264. package/src/templates/mate-skills/claude/mate-grill-with-docs/SKILL.md +2 -2
  265. package/src/templates/mate-skills/claude/mate-interview-me/SKILL.md +12 -5
  266. package/src/templates/mate-skills/claude/mate-propose-change/SKILL.md +108 -0
  267. package/src/templates/mate-skills/claude/mate-propose-change/references/mate-revise.md +47 -0
  268. package/src/templates/mate-skills/claude/mate-propose-change/references/openspec-propose.md +169 -0
  269. package/src/templates/mate-skills/claude/mate-propose-change/references/openspec-update-change.md +103 -0
  270. package/src/templates/mate-skills/claude/{mate-artifact-publish → mate-publish-artifact}/SKILL.md +111 -24
  271. package/src/templates/mate-skills/{agents/mate-artifact-publish → claude/mate-publish-artifact}/references/openspec.md +8 -5
  272. package/src/templates/mate-skills/claude/mate-show-me/SKILL.md +95 -16
  273. package/src/templates/mate-skills/claude/mate-simplify-code/SKILL.md +87 -68
  274. package/src/templates/mate-skills/openspec-references.ts +142 -0
  275. package/src/templates/root/TEMPLATE_AGENTS.md +2 -2
  276. package/src/tools/setup/__snapshots__/runtime-surface-golden.test.ts.snap +3938 -391
  277. package/src/tools/setup/capabilities/companion-mentions.ts +27 -0
  278. package/src/tools/setup/capabilities/context-mode.ts +56 -7
  279. package/src/tools/setup/capabilities/graphify-gate.ts +31 -0
  280. package/src/tools/setup/capabilities/graphify-secrets.ts +243 -0
  281. package/src/tools/setup/capabilities/graphify.ts +46 -7
  282. package/src/tools/setup/capabilities/openspec.ts +163 -272
  283. package/src/tools/setup/capabilities/react-doctor.ts +8 -1
  284. package/src/tools/setup/capabilities/rtk.ts +4 -0
  285. package/src/tools/setup/capabilities/tokensave.ts +113 -71
  286. package/src/tools/setup/context-services.ts +9 -17
  287. package/src/tools/setup/dynamic-plugins/install.ts +24 -28
  288. package/src/tools/setup/engine.ts +100 -23
  289. package/src/tools/setup/install-contract.ts +8 -0
  290. package/src/tools/setup/managed-output.ts +51 -0
  291. package/src/tools/setup/mate-skill-copies.ts +51 -0
  292. package/src/tools/setup/mate.ts +86 -11
  293. package/src/tools/setup/package-managers/uv.ts +73 -11
  294. package/src/tools/setup/plugin.ts +40 -0
  295. package/src/tools/setup/plugins/guidance.ts +7 -4
  296. package/src/tools/setup/providers/agent-file-sections.ts +4 -2
  297. package/src/tools/setup/providers/claude-attribution.ts +65 -0
  298. package/src/tools/setup/providers/claude-plugin-folders.ts +625 -0
  299. package/src/tools/setup/providers/claude-plugin-hooks.ts +51 -19
  300. package/src/tools/setup/providers/claude-worktree-plugins.ts +122 -0
  301. package/src/tools/setup/providers/claude.ts +290 -8
  302. package/src/tools/setup/providers/opencode.ts +180 -1
  303. package/src/tools/setup/utils.ts +18 -4
  304. package/src/tools/setup/working-repo-cleanup.ts +29 -1
  305. package/src/tools/setup/working-repo-local-state.ts +252 -75
  306. package/src/tools/setup.ts +183 -26
  307. package/studio-dist/client/assets/companion-view-Csva26Ir.js +1 -0
  308. package/studio-dist/client/assets/delivery-path-DJMpRmiY.js +1 -0
  309. package/studio-dist/client/assets/dist-Dm7MtyHc.js +5 -0
  310. package/studio-dist/client/assets/factory-B7l9ZQyx.js +4 -0
  311. package/studio-dist/client/assets/index-n6uo_92S.js +40 -0
  312. package/studio-dist/client/assets/preload-helper-BLdHbfdN.js +1 -0
  313. package/studio-dist/client/assets/prepaint-CD5OpmTM.js +24 -0
  314. package/studio-dist/client/assets/queries-CN3JwMBX.js +1 -0
  315. package/studio-dist/client/assets/react-CabXf2Ds.js +1 -0
  316. package/studio-dist/client/assets/report-time-Dc-KOqQu.js +1 -0
  317. package/studio-dist/client/assets/reports-C01RsnMA.js +1 -0
  318. package/studio-dist/client/assets/rolldown-runtime-WkwZ5CU-.js +1 -0
  319. package/studio-dist/client/assets/routes-4pbC-2Hj.js +1 -0
  320. package/studio-dist/client/assets/skills-CihQganl.js +1 -0
  321. package/studio-dist/client/assets/spec-areas-C2L48N4C.js +1 -0
  322. package/studio-dist/client/assets/specs-D24_35_K.js +1 -0
  323. package/studio-dist/client/assets/studio-DKxfi691.css +1 -0
  324. package/studio-dist/client/assets/studio-queries-rvbJupCy.js +3 -0
  325. package/studio-dist/client/assets/terminal-eU5fzQzv.css +1 -0
  326. package/studio-dist/client/assets/vault-Bd4CQiTK.js +1 -0
  327. package/studio-dist/client/assets/warnings-V_Ys51wJ.js +1 -0
  328. package/studio-dist/client/assets/wasm-inline-C2en61B5.js +1 -0
  329. package/studio-dist/client/assets/workflow-BJejeVwQ.js +1 -0
  330. package/studio-dist/server/assets/__23tanstack-start-server-fn-resolver-BQKuMdJW.js +3881 -0
  331. package/studio-dist/server/assets/_tanstack-start-manifest_v.js +85 -0
  332. package/studio-dist/server/assets/actions-Bvgj9eb8.js +54 -0
  333. package/studio-dist/server/assets/actions-D8erOphH.js +44 -0
  334. package/studio-dist/server/assets/companion-view-aBady57v.js +33 -0
  335. package/studio-dist/server/assets/createServerFn-F5sAOF8V.js +459 -0
  336. package/studio-dist/server/assets/createServerRpc-tK2lE9R2.js +11 -0
  337. package/studio-dist/server/assets/delivery-path-BkKNjgkf.js +778 -0
  338. package/studio-dist/server/assets/dist-DpJWKyCm.js +5582 -0
  339. package/studio-dist/server/assets/empty-plugin-adapters-Cipd4ZH4.js +4 -0
  340. package/studio-dist/server/assets/factory-D6xnjedJ.js +2385 -0
  341. package/studio-dist/server/assets/factory-DT3UzHlh.js +68 -0
  342. package/studio-dist/server/assets/model-PyPALjii.js +18 -0
  343. package/studio-dist/server/assets/prepaint-BMke0fo1.js +41 -0
  344. package/studio-dist/server/assets/queries-Ag2iL8q2.js +107 -0
  345. package/studio-dist/server/assets/react-COs0LHn-.js +51 -0
  346. package/studio-dist/server/assets/report-time-DAfzln-N.js +8 -0
  347. package/studio-dist/server/assets/reports-BnUNJVtx.js +126 -0
  348. package/studio-dist/server/assets/rolldown-runtime-DYf_mQCB.js +34 -0
  349. package/studio-dist/server/assets/router-BH--drIx.js +4298 -0
  350. package/studio-dist/server/assets/routes-khSDK1bV.js +361 -0
  351. package/studio-dist/server/assets/search-JAKurDNh.js +36 -0
  352. package/studio-dist/server/assets/shell-CboT2f66.js +51 -0
  353. package/studio-dist/server/assets/skills-MWYnWoKs.js +106 -0
  354. package/studio-dist/server/assets/spec-areas-DcnO6vW-.js +16 -0
  355. package/studio-dist/server/assets/specs-DE3w8hZP.js +155 -0
  356. package/studio-dist/server/assets/start-BW5ovN0k.js +33 -0
  357. package/studio-dist/server/assets/studio-BeltxxKt.js +216 -0
  358. package/studio-dist/server/assets/studio-queries-CLnP9kGu.js +3365 -0
  359. package/studio-dist/server/assets/utils-C9CX1kcy.js +221 -0
  360. package/studio-dist/server/assets/vault-BGulVoNh.js +70 -0
  361. package/studio-dist/server/assets/vault-CuyyhLyB.js +832 -0
  362. package/studio-dist/server/assets/views-Bd7cRr27.js +82 -0
  363. package/studio-dist/server/assets/warnings-BH05rOuG.js +15 -0
  364. package/studio-dist/server/assets/wasm-inline-CNeBKGwC.js +3 -0
  365. package/studio-dist/server/assets/workflow-BSuIKWqH.js +42 -0
  366. package/studio-dist/server/server.js +16220 -0
  367. package/wrappers/bin/graphify +52 -4
  368. package/wrappers/bin/openspec +33 -9
  369. package/wrappers/lib/graphify-gate.mjs +8 -0
  370. package/src/cli/commands/studio/views/client.ts +0 -654
  371. package/src/cli/commands/studio/views/companion-picker.tsx +0 -95
  372. package/src/cli/commands/studio/views/companion-selector.tsx +0 -94
  373. package/src/cli/commands/studio/views/dashboard/changes.tsx +0 -107
  374. package/src/cli/commands/studio/views/dashboard/index.tsx +0 -19
  375. package/src/cli/commands/studio/views/document.tsx +0 -842
  376. package/src/cli/commands/studio/views/error.tsx +0 -20
  377. package/src/cli/commands/studio/views/reports/index.tsx +0 -49
  378. package/src/cli/commands/studio/views/selection-fields.tsx +0 -14
  379. package/src/cli/commands/studio/views/skills/index.tsx +0 -87
  380. package/src/cli/commands/studio/views/specs/index.tsx +0 -157
  381. package/src/cli/commands/studio/views/styles.ts +0 -519
  382. package/src/cli/commands/studio/views/terminal.tsx +0 -484
  383. package/src/cli/commands/studio/views/vault/state.ts +0 -43
  384. package/src/cli/commands/studio/views/warnings.tsx +0 -21
  385. package/src/cli/commands/studio/views/workflow/index.tsx +0 -21
  386. package/src/cli/commands/studio/views/workflow/steps.ts +0 -337
  387. package/src/cli/commands/studio/views/workflow/transcript.tsx +0 -190
  388. package/src/lib/components/theme.ts +0 -2
  389. package/src/tools/setup/git-utils.ts +0 -30
  390. package/src/tools/setup/runtime-documents.ts +0 -291
@@ -0,0 +1,832 @@
1
+ import { i as __toESM } from "./rolldown-runtime-DYf_mQCB.js";
2
+ import { i as useSuspenseQuery } from "./queries-Ag2iL8q2.js";
3
+ import { Z as useQueryClient, a as afterVaultRefresh, d as vaultMatchesQuery, f as vaultQuery, i as afterVaultFileChange, l as shellQuery, m as saveVaultFile, nt as useNavigate, p as getVault, tt as Link, u as vaultChildrenQuery } from "./studio-queries-CLnP9kGu.js";
4
+ import { _ as useMutation, h as useVaultUi, m as ViewPlaceholder, r as Route } from "./router-BH--drIx.js";
5
+ import { n as useQuery } from "./react-COs0LHn-.js";
6
+ import { A as require_react, l as require_jsx_runtime, s as useRouter } from "./__23tanstack-start-server-fn-resolver-BQKuMdJW.js";
7
+ // ../../node_modules/.bun/@tanstack+react-router@1.170.46+7492c01c6988791b/node_modules/@tanstack/react-router/dist/esm/useBlocker.js
8
+ var import_react = /* @__PURE__ */ __toESM(require_react(), 1);
9
+ function _resolveBlockerOpts(opts, condition) {
10
+ if (opts === void 0) return {
11
+ shouldBlockFn: () => true,
12
+ withResolver: false
13
+ };
14
+ if ("shouldBlockFn" in opts) return opts;
15
+ if (typeof opts === "function") {
16
+ const shouldBlock = Boolean(condition ?? true);
17
+ const _customBlockerFn = async () => {
18
+ if (shouldBlock) return await opts();
19
+ return false;
20
+ };
21
+ return {
22
+ shouldBlockFn: _customBlockerFn,
23
+ enableBeforeUnload: shouldBlock,
24
+ withResolver: false
25
+ };
26
+ }
27
+ const shouldBlock = Boolean(opts.condition ?? true);
28
+ const fn = opts.blockerFn;
29
+ const _customBlockerFn = async () => {
30
+ if (shouldBlock && fn !== void 0) return await fn();
31
+ return shouldBlock;
32
+ };
33
+ return {
34
+ shouldBlockFn: _customBlockerFn,
35
+ enableBeforeUnload: shouldBlock,
36
+ withResolver: fn === void 0
37
+ };
38
+ }
39
+ function useBlocker(opts, condition) {
40
+ const { shouldBlockFn, enableBeforeUnload = true, disabled = false, withResolver = false } = _resolveBlockerOpts(opts, condition);
41
+ const router = useRouter();
42
+ const { history } = router;
43
+ const [resolver, setResolver] = import_react.useState({
44
+ status: "idle",
45
+ current: void 0,
46
+ next: void 0,
47
+ action: void 0,
48
+ proceed: void 0,
49
+ reset: void 0
50
+ });
51
+ import_react.useEffect(() => {
52
+ const blockerFnComposed = async (blockerFnArgs) => {
53
+ function getLocation(location) {
54
+ const parsedLocation = router.parseLocation(location);
55
+ const [, rawParams, foundRoute] = router.getMatchedRoutes(parsedLocation.pathname);
56
+ if (foundRoute === void 0) return {
57
+ routeId: "__notFound__",
58
+ fullPath: parsedLocation.pathname,
59
+ pathname: parsedLocation.pathname,
60
+ params: rawParams,
61
+ search: router.options.parseSearch(location.search)
62
+ };
63
+ return {
64
+ routeId: foundRoute.id,
65
+ fullPath: foundRoute.fullPath,
66
+ pathname: parsedLocation.pathname,
67
+ params: rawParams,
68
+ search: router.options.parseSearch(location.search)
69
+ };
70
+ }
71
+ const current = getLocation(blockerFnArgs.currentLocation);
72
+ const next = getLocation(blockerFnArgs.nextLocation);
73
+ if (current.routeId === "__notFound__" && next.routeId !== "__notFound__") return false;
74
+ const shouldBlock = await shouldBlockFn({
75
+ action: blockerFnArgs.action,
76
+ current,
77
+ next
78
+ });
79
+ if (!withResolver) return shouldBlock;
80
+ if (!shouldBlock) return false;
81
+ const canNavigateAsync = await new Promise((resolve) => {
82
+ setResolver({
83
+ status: "blocked",
84
+ current,
85
+ next,
86
+ action: blockerFnArgs.action,
87
+ proceed: () => resolve(false),
88
+ reset: () => resolve(true)
89
+ });
90
+ });
91
+ setResolver({
92
+ status: "idle",
93
+ current: void 0,
94
+ next: void 0,
95
+ action: void 0,
96
+ proceed: void 0,
97
+ reset: void 0
98
+ });
99
+ return canNavigateAsync;
100
+ };
101
+ return disabled ? void 0 : history.block({
102
+ blockerFn: blockerFnComposed,
103
+ enableBeforeUnload
104
+ });
105
+ }, [
106
+ shouldBlockFn,
107
+ enableBeforeUnload,
108
+ disabled,
109
+ withResolver,
110
+ history,
111
+ router
112
+ ]);
113
+ return resolver;
114
+ }
115
+ // src/views/vault/markdown-view.tsx
116
+ var import_jsx_runtime = require_jsx_runtime();
117
+ var TAGS = /* @__PURE__ */ new Set([
118
+ "h1",
119
+ "h2",
120
+ "h3",
121
+ "h4",
122
+ "h5",
123
+ "h6",
124
+ "p",
125
+ "pre",
126
+ "code",
127
+ "span",
128
+ "blockquote",
129
+ "hr",
130
+ "ol",
131
+ "ul",
132
+ "li",
133
+ "div",
134
+ "table",
135
+ "thead",
136
+ "tbody",
137
+ "tr",
138
+ "th",
139
+ "td",
140
+ "strong",
141
+ "em",
142
+ "del",
143
+ "br"
144
+ ]);
145
+ function element(node, key) {
146
+ const children = node.c?.map(render);
147
+ const { a } = node;
148
+ if (node.t === "a") {
149
+ if (a?.note) return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Link, {
150
+ to: "/vault",
151
+ search: (previous) => ({
152
+ ...previous,
153
+ path: a.note,
154
+ dir: void 0,
155
+ mode: void 0
156
+ }),
157
+ "data-vault-entry": a.note,
158
+ children
159
+ }, key);
160
+ if (a?.href && /^https?:\/\//i.test(a.href)) return /* @__PURE__ */ (0, import_jsx_runtime.jsx)("a", {
161
+ href: a.href,
162
+ target: "_blank",
163
+ rel: "noopener noreferrer",
164
+ children
165
+ }, key);
166
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { children }, key);
167
+ }
168
+ if (node.t === "input") return /* @__PURE__ */ (0, import_jsx_runtime.jsx)("input", {
169
+ type: "checkbox",
170
+ checked: !!a?.checked,
171
+ disabled: true,
172
+ readOnly: true,
173
+ "aria-label": "Task"
174
+ }, key);
175
+ if (!TAGS.has(node.t)) return /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { children }, key);
176
+ return (0, import_react.createElement)(node.t, {
177
+ key,
178
+ className: a?.className,
179
+ start: a?.start,
180
+ style: a?.align ? { textAlign: a.align } : void 0
181
+ }, children && children.length > 0 ? children : void 0);
182
+ }
183
+ function render(node, key) {
184
+ return typeof node === "string" ? node : element(node, key);
185
+ }
186
+ /** A file the server rendered to data; React escapes every value it shows. */
187
+ function MarkdownView({ nodes }) {
188
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", {
189
+ className: "markdown-body",
190
+ children: nodes.map(render)
191
+ });
192
+ }
193
+ // src/views/vault/vault-file.tsx
194
+ var eventsUrl = (companion, path) => `/api/vault/events?${new URLSearchParams({
195
+ companion,
196
+ path
197
+ })}`;
198
+ /** Follows the open file on disk for as long as it is shown. */
199
+ function useFileEvents(companion, path, onEvent) {
200
+ const handler = (0, import_react.useRef)(onEvent);
201
+ (0, import_react.useEffect)(() => {
202
+ handler.current = onEvent;
203
+ });
204
+ (0, import_react.useEffect)(() => {
205
+ if (typeof EventSource === "undefined") return;
206
+ const source = new EventSource(eventsUrl(companion, path));
207
+ source.onmessage = (message) => {
208
+ try {
209
+ handler.current(JSON.parse(message.data));
210
+ } catch {}
211
+ };
212
+ return () => source.close();
213
+ }, [companion, path]);
214
+ }
215
+ /**
216
+ * An open file, read rendered or edited raw. Without the write path a file is only ever read,
217
+ * whatever the address names. Saving returns to read; leaving edit with unsaved text asks.
218
+ */
219
+ function VaultFile({ companion, data, writable, search }) {
220
+ const open = data.open;
221
+ if (!open) return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", {
222
+ className: "panel vault-editor-panel",
223
+ children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)("h3", { children: data.refusal ? "File refused" : "Open a markdown file" }), /* @__PURE__ */ (0, import_jsx_runtime.jsx)("p", {
224
+ className: data.refusal ? "note vault-warning" : "empty",
225
+ children: data.refusal ?? "Choose a file from the tree to begin."
226
+ })]
227
+ });
228
+ return writable && search.mode === "edit" ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Editor, {
229
+ companion,
230
+ data
231
+ }, `${open.path}:edit`) : /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Reader, {
232
+ companion,
233
+ data,
234
+ writable
235
+ }, `${open.path}:read`);
236
+ }
237
+ function Header({ name, note, children }) {
238
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", {
239
+ className: "section-header",
240
+ children: [/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)("h3", { children: name }), /* @__PURE__ */ (0, import_jsx_runtime.jsx)("p", {
241
+ className: "section-note",
242
+ children: note
243
+ })] }), /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", {
244
+ className: "vault-actions",
245
+ children
246
+ })]
247
+ });
248
+ }
249
+ var fileName = (path) => path.split("/").at(-1) ?? path;
250
+ /** Rendered; a change on disk shows at once, a removal is stated. */
251
+ function Reader({ companion, data, writable }) {
252
+ const open = data.open;
253
+ const queryClient = useQueryClient();
254
+ const [status, setStatus] = (0, import_react.useState)("");
255
+ useFileEvents(companion, open.path, (event) => {
256
+ if (event.kind === "removed") setStatus("this file no longer exists on disk");
257
+ else afterVaultFileChange(queryClient, companion);
258
+ });
259
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", {
260
+ className: "panel vault-editor-panel",
261
+ "data-vault-root": true,
262
+ "data-vault-mode": "read",
263
+ "data-vault-path": open.path,
264
+ children: [
265
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Header, {
266
+ name: fileName(open.path),
267
+ note: writable ? "Rendered view." : "Read-only mode. Start Studio with --writable to edit.",
268
+ children: writable ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Link, {
269
+ className: "vault-mode-link",
270
+ id: "vault-mode-edit",
271
+ to: "/vault",
272
+ search: (previous) => ({
273
+ ...previous,
274
+ mode: "edit"
275
+ }),
276
+ "data-vault-mode-link": true,
277
+ children: "Edit"
278
+ }) : null
279
+ }),
280
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(MarkdownView, { nodes: open.markdown }),
281
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("p", {
282
+ id: "vault-status",
283
+ className: "note",
284
+ "aria-live": "polite",
285
+ children: status
286
+ })
287
+ ]
288
+ });
289
+ }
290
+ /** The raw editor with an explicit save; unsaved text is never replaced by a version from disk. */
291
+ function Editor({ companion, data }) {
292
+ const open = data.open;
293
+ const queryClient = useQueryClient();
294
+ const navigate = useNavigate();
295
+ const [text, setText] = (0, import_react.useState)(open.content);
296
+ const [original, setOriginal] = (0, import_react.useState)(open.content);
297
+ const [token, setToken] = (0, import_react.useState)(open.token);
298
+ const [status, setStatus] = (0, import_react.useState)("");
299
+ const [incoming, setIncoming] = (0, import_react.useState)(null);
300
+ const dirty = text !== original;
301
+ const unsaved = (0, import_react.useRef)(dirty);
302
+ (0, import_react.useEffect)(() => {
303
+ unsaved.current = dirty;
304
+ }, [dirty]);
305
+ const setDirty = useVaultUi((state) => state.setDirty);
306
+ (0, import_react.useEffect)(() => setDirty(dirty), [dirty, setDirty]);
307
+ (0, import_react.useEffect)(() => () => setDirty(false), [setDirty]);
308
+ useBlocker({
309
+ shouldBlockFn: () => unsaved.current && !window.confirm("Discard unsaved changes?"),
310
+ enableBeforeUnload: () => unsaved.current
311
+ });
312
+ useFileEvents(companion, open.path, (event) => {
313
+ if (event.kind === "removed") {
314
+ setStatus("this file no longer exists on disk");
315
+ return;
316
+ }
317
+ const version = {
318
+ content: event.content ?? "",
319
+ token: event.token ?? ""
320
+ };
321
+ if (event.kind === "overwritten") {
322
+ setIncoming(version);
323
+ setStatus("a version was overwritten; its content is available below");
324
+ } else if (dirty) {
325
+ setIncoming(version);
326
+ setStatus("the file changed on disk; unsaved content is still in the editor");
327
+ } else {
328
+ setText(version.content);
329
+ setOriginal(version.content);
330
+ setToken(version.token);
331
+ setStatus("updated from disk");
332
+ }
333
+ });
334
+ const save = useMutation({
335
+ mutationFn: () => saveVaultFile({ data: {
336
+ companion,
337
+ path: open.path,
338
+ content: text,
339
+ token
340
+ } }),
341
+ onSuccess: (result) => {
342
+ if (result.kind === "conflict") {
343
+ setIncoming({
344
+ content: result.content,
345
+ token: result.token
346
+ });
347
+ setStatus(result.reason || "save refused");
348
+ return;
349
+ }
350
+ setToken(result.token);
351
+ setOriginal(text);
352
+ unsaved.current = false;
353
+ setDirty(false);
354
+ setStatus("saved");
355
+ afterVaultFileChange(queryClient, companion);
356
+ navigate({
357
+ to: "/vault",
358
+ search: (previous) => ({
359
+ ...previous,
360
+ mode: void 0
361
+ }),
362
+ resetScroll: false
363
+ });
364
+ },
365
+ onError: (error) => setStatus(error.message || "save failed")
366
+ });
367
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", {
368
+ className: "panel vault-editor-panel",
369
+ "data-vault-root": true,
370
+ "data-vault-mode": "edit",
371
+ "data-vault-path": open.path,
372
+ children: [
373
+ /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(Header, {
374
+ name: fileName(open.path),
375
+ note: "Changes stay in the editor until you save.",
376
+ children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)("button", {
377
+ type: "button",
378
+ id: "vault-save",
379
+ onClick: () => save.mutate(),
380
+ disabled: save.isPending,
381
+ children: "Save"
382
+ }), /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Link, {
383
+ className: "vault-mode-link",
384
+ id: "vault-mode-read",
385
+ to: "/vault",
386
+ search: (previous) => ({
387
+ ...previous,
388
+ mode: void 0
389
+ }),
390
+ "data-vault-mode-link": true,
391
+ children: "Read"
392
+ })]
393
+ }),
394
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("textarea", {
395
+ id: "vault-editor",
396
+ "data-vault-editor": true,
397
+ "data-vault-path": open.path,
398
+ "aria-label": `Markdown source of ${fileName(open.path)}`,
399
+ spellCheck: false,
400
+ value: text,
401
+ onChange: (event) => setText(event.target.value)
402
+ }),
403
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("p", {
404
+ id: "vault-status",
405
+ className: "note",
406
+ "aria-live": "polite",
407
+ children: status
408
+ }),
409
+ incoming ? /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", {
410
+ id: "vault-incoming",
411
+ className: "vault-incoming",
412
+ children: [
413
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("strong", {
414
+ id: "vault-incoming-title",
415
+ children: "Incoming version"
416
+ }),
417
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("pre", {
418
+ id: "vault-incoming-content",
419
+ children: incoming.content
420
+ }),
421
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("button", {
422
+ type: "button",
423
+ id: "vault-recover",
424
+ onClick: () => {
425
+ setText(incoming.content);
426
+ setOriginal(incoming.content);
427
+ if (incoming.token) setToken(incoming.token);
428
+ setIncoming(null);
429
+ setStatus("incoming version loaded into the editor");
430
+ },
431
+ children: "Put incoming content back"
432
+ })
433
+ ]
434
+ }) : null
435
+ ]
436
+ });
437
+ }
438
+ // src/views/vault/vault-view.tsx
439
+ var segments = (relative) => relative.split("/").filter(Boolean);
440
+ function FolderIcon() {
441
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", {
442
+ className: "vault-icon vault-icon-folder",
443
+ "aria-hidden": "true"
444
+ });
445
+ }
446
+ function FileIcon() {
447
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", {
448
+ className: "vault-icon vault-icon-file",
449
+ "aria-hidden": "true"
450
+ });
451
+ }
452
+ /** A file entry is a link to the file's address; it opens in read. */
453
+ function FileLink({ entry, current, label }) {
454
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(Link, {
455
+ to: "/vault",
456
+ search: (previous) => ({
457
+ ...previous,
458
+ path: entry.path,
459
+ dir: void 0,
460
+ mode: void 0
461
+ }),
462
+ className: "vault-file",
463
+ "data-vault-entry": entry.path,
464
+ "aria-current": current ? "page" : void 0,
465
+ children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)(FileIcon, {}), /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { children: label ?? entry.name })]
466
+ });
467
+ }
468
+ /** Opens a folder's listing; a breadcrumb step or a listing row. */
469
+ function FolderLink({ dir, className, children }) {
470
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Link, {
471
+ to: "/vault",
472
+ search: (previous) => ({
473
+ ...previous,
474
+ path: void 0,
475
+ dir: dir ?? void 0,
476
+ mode: void 0
477
+ }),
478
+ className,
479
+ children
480
+ });
481
+ }
482
+ function TreeEntry({ entry, companion, search }) {
483
+ if (entry.kind === "file") return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(FileLink, {
484
+ entry,
485
+ current: search.path === entry.path
486
+ });
487
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(TreeFolder, {
488
+ entry,
489
+ companion,
490
+ search
491
+ });
492
+ }
493
+ /** Collapsed unless on the open path; a collapsed folder asks for its entries when first opened. */
494
+ function TreeFolder({ entry, companion, search }) {
495
+ const [open, setOpen] = (0, import_react.useState)(entry.children !== void 0);
496
+ const children = useQuery({
497
+ ...vaultChildrenQuery(companion, entry.path),
498
+ enabled: open && entry.children === void 0
499
+ });
500
+ const entries = entry.children ?? children.data?.entries;
501
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("details", {
502
+ className: "vault-directory",
503
+ open,
504
+ "data-vault-dir": entry.path,
505
+ onToggle: (event) => setOpen(event.currentTarget.open),
506
+ children: [/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("summary", {
507
+ "aria-current": search.dir === entry.path ? "page" : void 0,
508
+ children: [
509
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", {
510
+ className: "vault-chevron",
511
+ "aria-hidden": "true"
512
+ }),
513
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(FolderIcon, {}),
514
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { children: entry.name })
515
+ ]
516
+ }), /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", {
517
+ className: "vault-children",
518
+ children: [open && entries ? entries.map((child) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)(TreeEntry, {
519
+ entry: child,
520
+ companion,
521
+ search
522
+ }, child.path)) : null, children.error ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)("p", {
523
+ className: "note vault-warning",
524
+ children: children.error.message
525
+ }) : null]
526
+ })]
527
+ });
528
+ }
529
+ function TreeSlot({ data, companion, search }) {
530
+ if (data.failure) return /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", {
531
+ "data-vault-slot": "tree",
532
+ children: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("p", {
533
+ className: "note vault-warning",
534
+ children: ["The files could not be listed: ", data.failure]
535
+ })
536
+ });
537
+ if (data.tree === null) return /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", {
538
+ "data-vault-slot": "tree",
539
+ "aria-busy": "true",
540
+ children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)("p", {
541
+ className: "empty",
542
+ children: "Listing files…"
543
+ })
544
+ });
545
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", {
546
+ "data-vault-slot": "tree",
547
+ "data-vault-generation": data.generation ?? void 0,
548
+ children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)(TreeStaleNote, { data }), data.tree.length === 0 ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)("p", {
549
+ className: "empty",
550
+ children: "This companion has no markdown files."
551
+ }) : /* @__PURE__ */ (0, import_jsx_runtime.jsx)("nav", {
552
+ className: "vault-tree",
553
+ "aria-label": "Markdown files",
554
+ children: data.tree.map((entry) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)(TreeEntry, {
555
+ entry,
556
+ companion,
557
+ search
558
+ }, entry.path))
559
+ })]
560
+ });
561
+ }
562
+ function TreeStaleNote({ data }) {
563
+ if (data.warning) return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("p", {
564
+ className: "note vault-warning",
565
+ children: [data.warning, ". The tree may be out of date."]
566
+ });
567
+ if (data.watching) return null;
568
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)("p", {
569
+ className: "note vault-warning",
570
+ children: "The tree may be out of date."
571
+ });
572
+ }
573
+ /** Name matches over the whole listed tree, bounded by the server. */
574
+ function FilterResults({ companion, query, search }) {
575
+ const [settled, setSettled] = (0, import_react.useState)(query);
576
+ (0, import_react.useEffect)(() => {
577
+ const timer = setTimeout(() => setSettled(query), 150);
578
+ return () => clearTimeout(timer);
579
+ }, [query]);
580
+ const matches = useQuery({
581
+ ...vaultMatchesQuery(companion, settled),
582
+ enabled: settled.trim().length > 0
583
+ });
584
+ if (!matches.data) return null;
585
+ const { shown, total } = matches.data;
586
+ const more = total - shown.length;
587
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", {
588
+ "data-vault-filter-results": true,
589
+ children: [shown.length === 0 ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)("p", {
590
+ className: "empty",
591
+ children: "No files match."
592
+ }) : /* @__PURE__ */ (0, import_jsx_runtime.jsx)("nav", {
593
+ className: "vault-tree vault-results",
594
+ "aria-label": "Matching files",
595
+ children: shown.map((entry) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)(FileLink, {
596
+ entry,
597
+ current: search.path === entry.path,
598
+ label: entry.path
599
+ }, entry.path))
600
+ }), more > 0 ? /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("p", {
601
+ className: "note",
602
+ "data-vault-more": true,
603
+ children: [
604
+ more,
605
+ " more match",
606
+ more === 1 ? "" : "es",
607
+ "; refine the filter."
608
+ ]
609
+ }) : null]
610
+ });
611
+ }
612
+ /** Built from the address alone, so it shows before the tree is listed. */
613
+ function Breadcrumb({ rootName, search }) {
614
+ const parts = segments(search.path ?? search.dir ?? "");
615
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)("nav", {
616
+ className: "vault-breadcrumb",
617
+ "aria-label": "Breadcrumb",
618
+ "data-vault-crumb": true,
619
+ children: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("ol", { children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)("li", { children: parts.length === 0 ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", {
620
+ "aria-current": "page",
621
+ children: rootName
622
+ }) : /* @__PURE__ */ (0, import_jsx_runtime.jsx)(FolderLink, {
623
+ dir: null,
624
+ className: "vault-crumb",
625
+ children: rootName
626
+ }) }), parts.map((name, index) => {
627
+ const dir = parts.slice(0, index + 1).join("/");
628
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)("li", { children: index === parts.length - 1 ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", {
629
+ "aria-current": "page",
630
+ children: name
631
+ }) : /* @__PURE__ */ (0, import_jsx_runtime.jsx)(FolderLink, {
632
+ dir,
633
+ className: "vault-crumb",
634
+ children: name
635
+ }) }, dir);
636
+ })] })
637
+ });
638
+ }
639
+ function findEntries(tree, dir) {
640
+ let level = tree;
641
+ for (const name of segments(dir)) {
642
+ const folder = level?.find((entry) => entry.kind === "directory" && entry.name === name);
643
+ if (!folder) return null;
644
+ level = folder.children;
645
+ }
646
+ return level ?? null;
647
+ }
648
+ /** With no file open: the open folder's entries, folders first, and the way to its parent. */
649
+ function Listing({ data }) {
650
+ if (data.failure) return /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", {
651
+ "data-vault-slot": "listing",
652
+ className: "panel vault-listing",
653
+ children: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("p", {
654
+ className: "note vault-warning",
655
+ children: ["The files could not be listed: ", data.failure]
656
+ })
657
+ });
658
+ if (data.tree === null) return /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", {
659
+ "data-vault-slot": "listing",
660
+ className: "panel vault-listing",
661
+ "aria-busy": "true",
662
+ children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)("p", {
663
+ className: "empty",
664
+ children: "Listing files…"
665
+ })
666
+ });
667
+ const entries = (data.dir ? findEntries(data.tree, data.dir) : null) ?? data.tree;
668
+ const parts = data.dir ? segments(data.dir) : [];
669
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", {
670
+ "data-vault-slot": "listing",
671
+ className: "panel vault-listing",
672
+ children: [data.dirMissing ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)("p", {
673
+ className: "note vault-warning",
674
+ children: "That folder is not in the tree; showing the root."
675
+ }) : null, entries.length === 0 && parts.length === 0 ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)("p", {
676
+ className: "empty",
677
+ children: "This companion has no markdown files."
678
+ }) : /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("ul", {
679
+ className: "vault-rows",
680
+ "aria-label": "Folder contents",
681
+ children: [parts.length > 0 ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)("li", { children: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(FolderLink, {
682
+ dir: parts.length > 1 ? parts.slice(0, -1).join("/") : null,
683
+ className: "vault-row",
684
+ children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)(FolderIcon, {}), /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { children: ".." })]
685
+ }) }) : null, entries.map((entry) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)("li", { children: entry.kind === "directory" ? /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(FolderLink, {
686
+ dir: entry.path,
687
+ className: "vault-row",
688
+ children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)(FolderIcon, {}), /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { children: entry.name })]
689
+ }) : /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(Link, {
690
+ to: "/vault",
691
+ search: (previous) => ({
692
+ ...previous,
693
+ path: entry.path,
694
+ dir: void 0,
695
+ mode: void 0
696
+ }),
697
+ className: "vault-row",
698
+ children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)(FileIcon, {}), /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { children: entry.name })]
699
+ }) }, entry.path))]
700
+ })]
701
+ });
702
+ }
703
+ /**
704
+ * The vault: the companion as folders beside the content. The tree holds only the top level
705
+ * and the open path; it fills in without the viewer acting when it was not listed yet.
706
+ */
707
+ function VaultLayout({ companion, rootName, writable, search }) {
708
+ const queryClient = useQueryClient();
709
+ const view = useQuery(vaultQuery(companion, search));
710
+ const data = useQuery({
711
+ ...vaultQuery(companion, search, true),
712
+ enabled: Boolean(view.data && view.data.tree === null && !view.data.failure)
713
+ }).data ?? view.data;
714
+ const [filter, setFilter] = (0, import_react.useState)("");
715
+ const latest = useVaultUi((state) => state.latestGeneration);
716
+ const treeHidden = useVaultUi((state) => state.treeHidden);
717
+ const toggleTree = useVaultUi((state) => state.toggleTree);
718
+ const hydrate = useVaultUi((state) => state.hydrate);
719
+ (0, import_react.useEffect)(hydrate, [hydrate]);
720
+ const refresh = useMutation({
721
+ mutationFn: () => getVault({ data: {
722
+ companion,
723
+ path: search.path,
724
+ dir: search.dir,
725
+ refresh: true,
726
+ wait: true
727
+ } }),
728
+ onSuccess: (fresh) => void afterVaultRefresh(queryClient, companion, search, fresh)
729
+ });
730
+ if (!data) return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(ViewPlaceholder, {});
731
+ const stale = latest !== null && data.generation !== null && latest > data.generation;
732
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("section", {
733
+ className: "vault-layout",
734
+ "data-vault-layout": true,
735
+ children: [/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("aside", {
736
+ className: "panel vault-tree-panel",
737
+ id: "vault-tree-panel",
738
+ "aria-label": "Files",
739
+ children: [
740
+ /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", {
741
+ className: "vault-tree-head",
742
+ children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)("strong", { children: "Files" }), /* @__PURE__ */ (0, import_jsx_runtime.jsx)("button", {
743
+ type: "button",
744
+ onClick: () => refresh.mutate(),
745
+ disabled: refresh.isPending,
746
+ children: refresh.isPending ? "Refreshing…" : "Refresh tree"
747
+ })]
748
+ }),
749
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("p", {
750
+ id: "vault-stale",
751
+ className: "note vault-warning",
752
+ role: "status",
753
+ hidden: !stale,
754
+ children: "Files changed — refresh tree."
755
+ }),
756
+ refresh.error ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)("p", {
757
+ className: "note vault-warning",
758
+ role: "status",
759
+ children: refresh.error.message
760
+ }) : null,
761
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("input", {
762
+ type: "search",
763
+ id: "vault-filter",
764
+ className: "vault-filter",
765
+ placeholder: "Go to file",
766
+ "aria-label": "Go to file",
767
+ value: filter,
768
+ onChange: (event) => setFilter(event.target.value),
769
+ onKeyDown: (event) => {
770
+ if (event.key === "Escape") setFilter("");
771
+ }
772
+ }),
773
+ filter.trim() ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(FilterResults, {
774
+ companion,
775
+ query: filter,
776
+ search
777
+ }) : /* @__PURE__ */ (0, import_jsx_runtime.jsx)(TreeSlot, {
778
+ data,
779
+ companion,
780
+ search
781
+ })
782
+ ]
783
+ }), /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", {
784
+ className: "vault-main",
785
+ "data-vault-main": true,
786
+ children: [/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", {
787
+ className: "vault-bar",
788
+ children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)("button", {
789
+ type: "button",
790
+ id: "vault-tree-toggle",
791
+ className: "vault-tree-toggle",
792
+ "aria-controls": "vault-tree-panel",
793
+ "aria-expanded": !treeHidden,
794
+ onClick: toggleTree,
795
+ children: treeHidden ? "Show files" : "Hide files"
796
+ }), /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Breadcrumb, {
797
+ rootName,
798
+ search
799
+ })]
800
+ }), /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", {
801
+ "data-vault-pane": true,
802
+ children: search.path || data.open || data.refusal ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(VaultFile, {
803
+ companion,
804
+ data,
805
+ writable,
806
+ search
807
+ }) : /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Listing, { data })
808
+ })]
809
+ })]
810
+ });
811
+ }
812
+ // src/routes/vault.tsx?tsr-split=component
813
+ function VaultRoute() {
814
+ const search = Route.useSearch();
815
+ const { data: shell } = useSuspenseQuery(shellQuery({
816
+ companion: search.companion,
817
+ studioMode: search.studioMode
818
+ }));
819
+ if (!search.companion || !shell.selected) return null;
820
+ const rootName = shell.selected.path.split(/[\\/]/).findLast(Boolean) ?? "companion";
821
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(VaultLayout, {
822
+ companion: search.companion,
823
+ rootName,
824
+ writable: shell.writable,
825
+ search: {
826
+ path: search.path,
827
+ dir: search.dir,
828
+ mode: search.mode
829
+ }
830
+ });
831
+ }
832
+ export { VaultRoute as component };