@uniqbit/mate-core 0.21.1 → 1.0.0-canary.10

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 (467) hide show
  1. package/claude-capability-plugins/companion-mentions/.claude-plugin/plugin.json +1 -1
  2. package/claude-plugin/hooks/hooks.json +32 -1
  3. package/claude-plugin/hooks/workflow-turn.mjs +68 -0
  4. package/opencode-plugin/src/companion.ts +6 -0
  5. package/opencode-plugin/src/server.ts +24 -0
  6. package/package.json +9 -4
  7. package/src/cli/commands/artifact/apply-context.ts +1 -0
  8. package/src/cli/commands/artifact/artifact.ts +16 -0
  9. package/src/cli/commands/artifact/delivery/archive.ts +37 -112
  10. package/src/cli/commands/artifact/delivery/branch-flags.ts +19 -1
  11. package/src/cli/commands/artifact/delivery/environment.ts +30 -90
  12. package/src/cli/commands/artifact/delivery/link.ts +26 -26
  13. package/src/cli/commands/artifact/delivery/output.ts +27 -4
  14. package/src/cli/commands/artifact/delivery/resolve.ts +102 -0
  15. package/src/cli/commands/artifact/delivery/submit.ts +171 -0
  16. package/src/cli/commands/artifact/delivery/take.ts +46 -0
  17. package/src/cli/commands/artifact/extract-repo-name.ts +1 -1
  18. package/src/cli/commands/artifact/finish/command.ts +486 -55
  19. package/src/cli/commands/artifact/finish/engine.ts +87 -69
  20. package/src/cli/commands/artifact/finish/finisher.ts +5 -12
  21. package/src/cli/commands/artifact/finish/git.ts +9 -10
  22. package/src/cli/commands/artifact/finish/openspec.ts +21 -174
  23. package/src/cli/commands/artifact/finish/secret-scan.ts +5 -43
  24. package/src/cli/commands/artifact/finish/worktree-cleanup.ts +57 -7
  25. package/src/cli/commands/artifact/pending/command.ts +187 -10
  26. package/src/cli/commands/artifact/pending/discovery.ts +7 -11
  27. package/src/cli/commands/artifact/project/command.ts +59 -0
  28. package/src/cli/commands/cap/tokensave.ts +2 -2
  29. package/src/cli/commands/companion/hub.ts +11 -6
  30. package/src/cli/commands/companion/link.ts +173 -46
  31. package/src/cli/commands/companion/list.ts +70 -14
  32. package/src/cli/commands/companion/sync.ts +18 -0
  33. package/src/cli/commands/companion/update.ts +4 -3
  34. package/src/cli/commands/doctor.ts +84 -4
  35. package/src/cli/commands/friction.ts +558 -0
  36. package/src/cli/commands/install.ts +9 -4
  37. package/src/cli/commands/plugin/install.ts +82 -35
  38. package/src/cli/commands/studio/companion-add.ts +12 -27
  39. package/src/cli/commands/studio/connection.ts +53 -0
  40. package/src/{lib/factory/outcomes/sessions.ts → cli/commands/studio/live-sessions.ts} +7 -5
  41. package/src/cli/commands/studio/mcp-manager.ts +162 -0
  42. package/src/cli/commands/studio/payload.ts +172 -17
  43. package/src/cli/commands/studio/reports.ts +19 -18
  44. package/src/cli/commands/studio/routes.ts +8 -24
  45. package/src/cli/commands/studio/selection.ts +13 -4
  46. package/src/cli/commands/studio/server.ts +267 -243
  47. package/src/cli/commands/studio/service-host.ts +269 -0
  48. package/src/cli/commands/studio/services.ts +53 -34
  49. package/src/cli/commands/studio/studio-app.ts +1 -0
  50. package/src/cli/commands/studio/terminal.ts +1 -1
  51. package/src/cli/commands/studio/vault.ts +41 -40
  52. package/src/cli/commands/studio/views/model.ts +1 -9
  53. package/src/cli/commands/studio/views/vault/markdown-tree.ts +6 -5
  54. package/src/cli/commands/triage.ts +172 -0
  55. package/src/cli/commands/vscode/release-vsix.json +2 -2
  56. package/src/cli/commands/workflow/workflow.ts +516 -0
  57. package/src/cli/commands/working/cleanup.ts +1 -18
  58. package/src/cli/companion-link-wizard.tsx +158 -91
  59. package/src/cli/install-plan.tsx +3 -0
  60. package/src/cli/main.ts +106 -26
  61. package/src/cli/plugin-commands.ts +6 -1
  62. package/src/cli/repo-list-table.tsx +73 -37
  63. package/src/cli/usage.ts +30 -9
  64. package/src/create-mate.ts +15 -6
  65. package/src/distribution.ts +2 -0
  66. package/src/factory-host.ts +75 -0
  67. package/src/hooks/companion-instructions.ts +19 -8
  68. package/src/hooks/hook-io.ts +3 -1
  69. package/src/hooks/session-banner.ts +25 -0
  70. package/src/hooks/validate-artifact-path.ts +73 -22
  71. package/src/hooks/workflow-turn.ts +219 -0
  72. package/src/index.ts +1 -0
  73. package/src/lib/apply-context/fingerprint.ts +2 -1
  74. package/src/lib/apply-context/protocol.ts +2 -2
  75. package/src/lib/artifact-trailer.ts +27 -0
  76. package/src/lib/change-layout.ts +83 -38
  77. package/src/lib/delivery/branch-template.ts +4 -12
  78. package/src/lib/delivery/checkout.ts +3 -2
  79. package/src/lib/delivery/environment.ts +129 -7
  80. package/src/lib/delivery/merge-git.ts +312 -28
  81. package/src/lib/delivery/overlap.ts +81 -16
  82. package/src/lib/delivery/record-delivery.ts +102 -9
  83. package/src/lib/delivery/record.ts +186 -24
  84. package/src/lib/delivery/refresh.ts +241 -152
  85. package/src/lib/delivery/remote.ts +66 -0
  86. package/src/lib/delivery/repository-access.ts +30 -66
  87. package/src/lib/delivery/stages.ts +83 -50
  88. package/src/lib/delivery/staging/apply-chain.ts +182 -0
  89. package/src/lib/delivery/staging/artifact-type.ts +101 -0
  90. package/src/lib/delivery/staging/declared-type.ts +277 -0
  91. package/src/lib/delivery/staging/linked-merges.ts +175 -0
  92. package/src/lib/delivery/staging/naming.ts +67 -0
  93. package/src/lib/delivery/staging/openspec-type.ts +166 -0
  94. package/src/lib/delivery/staging/pending-edit.ts +291 -0
  95. package/src/lib/delivery/staging/pending.ts +922 -0
  96. package/src/lib/delivery/staging/preflight.ts +239 -0
  97. package/src/lib/delivery/staging/project.ts +512 -0
  98. package/src/lib/delivery/staging/publish.ts +1024 -0
  99. package/src/lib/delivery/staging/refs.ts +258 -0
  100. package/src/lib/delivery/staging/registry.ts +73 -0
  101. package/src/lib/delivery/staging/replay.ts +310 -0
  102. package/src/lib/delivery/staging/requirement-blocks.ts +10 -0
  103. package/src/lib/delivery/staging/resolve.ts +264 -0
  104. package/src/lib/delivery/staging/settle-linked.ts +176 -0
  105. package/src/lib/delivery/staging/submit.ts +1050 -0
  106. package/src/lib/delivery/staging/worktree.ts +130 -0
  107. package/src/lib/delivery/submit-change.ts +569 -0
  108. package/src/lib/friction/describe.ts +42 -0
  109. package/src/lib/friction/fields.ts +60 -0
  110. package/src/lib/friction/mark.ts +194 -0
  111. package/src/lib/friction/view/model.ts +67 -0
  112. package/src/lib/friction/view/read.ts +145 -0
  113. package/src/lib/friction/view/select.ts +54 -0
  114. package/src/lib/git-key.ts +15 -0
  115. package/src/lib/install.ts +2 -0
  116. package/src/lib/mcp-manager/resolve.ts +88 -0
  117. package/src/lib/mcp-manager/store.ts +133 -0
  118. package/src/lib/mcp-manager/types.ts +72 -0
  119. package/src/lib/mcp-manager/validate.ts +242 -0
  120. package/src/lib/openspec-canonical-frontmatter.ts +159 -0
  121. package/src/lib/openspec-cli.ts +10 -5
  122. package/src/lib/orchestrator/adapters/base.ts +31 -20
  123. package/src/lib/orchestrator/adapters/claude.ts +21 -7
  124. package/src/lib/orchestrator/adapters/opencode.ts +4 -0
  125. package/src/lib/orchestrator/companion-git-sync.ts +152 -16
  126. package/src/lib/orchestrator/config-store.ts +30 -7
  127. package/src/lib/orchestrator/engine-floor.ts +16 -4
  128. package/src/lib/orchestrator/engine-guard.ts +7 -1
  129. package/src/lib/orchestrator/framework-context.ts +15 -1
  130. package/src/lib/orchestrator/projection-claude-links.ts +1 -0
  131. package/src/lib/orchestrator/refresh-working-claude-links.ts +1 -0
  132. package/src/lib/orchestrator/repo-local-store.ts +14 -0
  133. package/src/lib/orchestrator/repository-link.ts +80 -52
  134. package/src/lib/orchestrator/root-context.ts +40 -7
  135. package/src/lib/orchestrator/session-prepare.ts +11 -1
  136. package/src/lib/orchestrator/types.ts +4 -0
  137. package/src/lib/orchestrator/umbrella-checkouts.ts +4 -4
  138. package/src/lib/package-paths.ts +23 -15
  139. package/src/lib/prebuilt-workspace-prepare.ts +2 -1
  140. package/src/lib/prebuilt-workspace.ts +1 -0
  141. package/src/lib/session-attribution.ts +3 -7
  142. package/src/lib/session-state.ts +3 -2
  143. package/src/lib/skills-cli.ts +38 -0
  144. package/src/lib/tool-manifest.ts +73 -0
  145. package/src/lib/triage/context.ts +312 -0
  146. package/src/lib/triage/launch.ts +52 -0
  147. package/src/lib/triage/prepare.ts +112 -0
  148. package/src/lib/triage/session.ts +126 -0
  149. package/src/lib/workflow/declaration.ts +6 -0
  150. package/src/lib/workflow/handoff.ts +90 -0
  151. package/src/lib/workflow/hook-trust.ts +108 -0
  152. package/src/lib/workflow/position.ts +524 -0
  153. package/src/lib/workflow/report.ts +79 -0
  154. package/src/lib/workflow/work.ts +106 -0
  155. package/src/lib/workset/factory-local.ts +2 -2
  156. package/src/lib/workset/repositories.ts +2 -2
  157. package/src/lib/workset/stage.ts +4 -2
  158. package/src/lib/workset/stages.ts +64 -4
  159. package/src/lib/workset/worktree.ts +32 -14
  160. package/src/opencode/companion-hooks.ts +63 -14
  161. package/src/opencode/projected-guidance.ts +7 -2
  162. package/src/opencode/turn-hook.ts +241 -0
  163. package/src/playbooks/companion-guidance.ts +7 -4
  164. package/src/plugin-api.ts +48 -0
  165. package/src/runtime/artifact-trailers.ts +63 -0
  166. package/src/runtime/claude-hook-group.ts +2 -0
  167. package/src/runtime/command-arg.ts +15 -0
  168. package/src/runtime/command-friction.ts +97 -0
  169. package/src/runtime/companion-git-state.ts +155 -10
  170. package/src/runtime/companion-git.ts +86 -11
  171. package/src/runtime/companion-guidance.ts +120 -17
  172. package/src/runtime/companion-instructions.ts +1 -1
  173. package/src/runtime/companion-sync.ts +109 -21
  174. package/src/runtime/env-names.ts +2 -2
  175. package/src/runtime/env.ts +7 -6
  176. package/src/runtime/forge-remote.ts +54 -0
  177. package/src/runtime/friction-fingerprint.ts +35 -0
  178. package/src/runtime/friction-log.ts +376 -0
  179. package/src/runtime/friction-recorder.ts +212 -0
  180. package/src/runtime/friction-retention.ts +1 -0
  181. package/src/runtime/friction-state.ts +110 -0
  182. package/src/runtime/friction-switch.ts +26 -0
  183. package/src/runtime/friction-vocabulary.ts +42 -0
  184. package/src/runtime/git-layout.ts +21 -7
  185. package/src/runtime/git-tracked.ts +13 -2
  186. package/src/runtime/json-fields.ts +8 -0
  187. package/src/runtime/pending-records.ts +533 -0
  188. package/src/runtime/projected-guidance.ts +8 -3
  189. package/src/runtime/publication-secret-scan.ts +45 -0
  190. package/src/runtime/secret-patterns.ts +7 -5
  191. package/src/runtime/secret-values.ts +16 -0
  192. package/src/runtime/session-id.ts +24 -0
  193. package/src/runtime/session-prepare-runner.ts +3 -0
  194. package/src/runtime/skill-prefix.ts +75 -0
  195. package/src/runtime/submitted-arrivals.ts +547 -0
  196. package/src/runtime/turn-state.d.mts +14 -0
  197. package/src/runtime/turn-state.mjs +93 -0
  198. package/src/runtime/umbrella-children.ts +52 -0
  199. package/src/runtime/umbrella-folder.ts +31 -3
  200. package/src/runtime/workflow/change-folders.ts +66 -0
  201. package/src/runtime/workflow/declaration.ts +720 -0
  202. package/src/runtime/workflow/globs.ts +85 -0
  203. package/src/runtime/workflow/next-handoff-process.ts +99 -0
  204. package/src/runtime/workflow/turn.ts +311 -0
  205. package/src/runtime/workflow/workflow.ts +262 -0
  206. package/src/studio.ts +113 -23
  207. package/src/templates/capabilities/openspec-cap/{mate-v1 → mate-full}/schema.yaml +3 -3
  208. package/src/templates/capabilities/openspec-cap/{mate-v1 → mate-full}/templates/design.md +1 -1
  209. package/src/templates/capabilities/openspec-cap/{mate-v1 → mate-full}/templates/proposal.md +1 -1
  210. package/src/templates/capabilities/openspec-cap/{mate-v1 → mate-full}/templates/tasks.md +1 -1
  211. package/src/templates/capabilities/openspec-cap/mate-minimal/schema.yaml +7 -3
  212. package/src/templates/capabilities/react-doctor/mate-react-doctor/SKILL.md +28 -0
  213. package/src/templates/mate-skills/agents/mate-apply-change/SKILL.md +84 -28
  214. package/src/templates/mate-skills/agents/mate-apply-change/references/openspec-apply-change.md +1 -1
  215. package/src/templates/mate-skills/agents/mate-archive-change/SKILL.md +30 -68
  216. package/src/templates/mate-skills/agents/mate-backfill-spec/SKILL.md +23 -1
  217. package/src/templates/mate-skills/agents/mate-clarify-intent/SKILL.md +39 -8
  218. package/src/templates/mate-skills/agents/mate-domain-modeling/SKILL.md +38 -0
  219. package/src/templates/mate-skills/agents/mate-explore-change/SKILL.md +65 -12
  220. package/src/templates/mate-skills/agents/mate-grill-me/SKILL.md +28 -0
  221. package/src/templates/mate-skills/agents/mate-grill-with-docs/SKILL.md +28 -0
  222. package/src/templates/mate-skills/agents/mate-grilling/SKILL.md +25 -0
  223. package/src/templates/mate-skills/agents/mate-interview-me/SKILL.md +28 -0
  224. package/src/templates/mate-skills/agents/mate-propose-change/SKILL.md +68 -28
  225. package/src/templates/mate-skills/agents/mate-propose-change/references/mate-revise.md +13 -7
  226. package/src/templates/mate-skills/agents/mate-propose-change/references/openspec-update-change.md +1 -1
  227. package/src/templates/mate-skills/agents/mate-publish-artifact/SKILL.md +136 -86
  228. package/src/templates/mate-skills/agents/mate-publish-artifact/references/openspec.md +111 -100
  229. package/src/templates/mate-skills/agents/mate-show-me/SKILL.md +28 -3
  230. package/src/templates/mate-skills/agents/mate-simplify-code/SKILL.md +39 -5
  231. package/src/templates/mate-skills/agents/mate-submit-change/SKILL.md +138 -0
  232. package/src/templates/mate-skills/claude/mate-apply-change/SKILL.md +84 -28
  233. package/src/templates/mate-skills/claude/mate-apply-change/references/openspec-apply-change.md +1 -1
  234. package/src/templates/mate-skills/claude/mate-archive-change/SKILL.md +30 -68
  235. package/src/templates/mate-skills/claude/mate-backfill-spec/SKILL.md +23 -1
  236. package/src/templates/mate-skills/claude/mate-clarify-intent/SKILL.md +39 -8
  237. package/src/templates/mate-skills/claude/mate-domain-modeling/SKILL.md +38 -0
  238. package/src/templates/mate-skills/claude/mate-explore-change/SKILL.md +65 -12
  239. package/src/templates/mate-skills/claude/mate-grill-me/SKILL.md +28 -0
  240. package/src/templates/mate-skills/claude/mate-grill-with-docs/SKILL.md +28 -0
  241. package/src/templates/mate-skills/claude/mate-grilling/SKILL.md +25 -0
  242. package/src/templates/mate-skills/claude/mate-interview-me/SKILL.md +28 -0
  243. package/src/templates/mate-skills/claude/mate-propose-change/SKILL.md +68 -28
  244. package/src/templates/mate-skills/claude/mate-propose-change/references/mate-revise.md +13 -7
  245. package/src/templates/mate-skills/claude/mate-propose-change/references/openspec-update-change.md +1 -1
  246. package/src/templates/mate-skills/claude/mate-publish-artifact/SKILL.md +136 -86
  247. package/src/templates/mate-skills/claude/mate-publish-artifact/references/openspec.md +111 -100
  248. package/src/templates/mate-skills/claude/mate-show-me/SKILL.md +28 -3
  249. package/src/templates/mate-skills/claude/mate-simplify-code/SKILL.md +39 -5
  250. package/src/templates/mate-skills/claude/mate-submit-change/SKILL.md +138 -0
  251. package/src/templates/mate-skills/openspec-references.ts +3 -2
  252. package/src/templates/triage/PLAYBOOK.md +120 -0
  253. package/src/tools/setup/__snapshots__/runtime-surface-golden.test.ts.snap +678 -170
  254. package/src/tools/setup/capabilities/graphify.ts +23 -1
  255. package/src/tools/setup/capabilities/mcp-manager.ts +73 -0
  256. package/src/tools/setup/capabilities/openspec.ts +54 -15
  257. package/src/tools/setup/capabilities/rtk.ts +47 -94
  258. package/src/tools/setup/capabilities/tokensave.ts +79 -56
  259. package/src/tools/setup/context-services.ts +35 -6
  260. package/src/tools/setup/dynamic-plugins/api.ts +38 -0
  261. package/src/tools/setup/dynamic-plugins/audiences.ts +31 -16
  262. package/src/tools/setup/dynamic-plugins/host.ts +2 -32
  263. package/src/tools/setup/dynamic-plugins/hydrate.ts +32 -14
  264. package/src/tools/setup/dynamic-plugins/install.ts +2 -0
  265. package/src/tools/setup/dynamic-plugins/installed.ts +73 -0
  266. package/src/tools/setup/dynamic-plugins/loader.ts +12 -10
  267. package/src/tools/setup/dynamic-plugins/local.ts +492 -0
  268. package/src/tools/setup/dynamic-plugins/paths.ts +34 -6
  269. package/src/tools/setup/dynamic-plugins/verify.ts +34 -14
  270. package/src/tools/setup/dynamic-plugins/workspaces.ts +21 -12
  271. package/src/tools/setup/engine.ts +75 -4
  272. package/src/tools/setup/mate.ts +28 -1
  273. package/src/tools/setup/package-managers/bun.ts +8 -8
  274. package/src/tools/setup/plugin.ts +28 -1
  275. package/src/tools/setup/plugins/gitignore.ts +45 -12
  276. package/src/tools/setup/plugins/guidance.ts +4 -2
  277. package/src/tools/setup/providers/claude-format.ts +39 -2
  278. package/src/tools/setup/providers/claude-plugin-hooks.ts +18 -0
  279. package/src/tools/setup/providers/claude.ts +56 -6
  280. package/src/tools/setup/providers/opencode-format.ts +13 -3
  281. package/src/tools/setup/providers/opencode.ts +7 -18
  282. package/src/tools/setup/providers/relative-path-warnings.ts +26 -0
  283. package/src/tools/setup/service-registry.ts +69 -0
  284. package/src/tools/setup/service.ts +245 -0
  285. package/src/tools/setup/utils.ts +34 -4
  286. package/src/tools/setup.ts +16 -2
  287. package/studio-dist/client/assets/DialogTitle-B_G47-lk.js +1 -0
  288. package/studio-dist/client/assets/app-0NoFqMou.css +2 -0
  289. package/studio-dist/client/assets/button-D_0295cs.js +1 -0
  290. package/studio-dist/client/assets/cn-Cx_D6I3u.js +1 -0
  291. package/studio-dist/client/assets/combobox-D0iPQP50.js +1 -0
  292. package/studio-dist/client/assets/{companion-view-CrabvxS8.js → companion-view-D3A76MLj.js} +1 -1
  293. package/studio-dist/client/assets/fields-Ctheim1h.js +1 -0
  294. package/studio-dist/client/assets/friction-Cn9n_zBA.js +1 -0
  295. package/studio-dist/client/assets/getting-started-DgoVWbWo.js +1 -0
  296. package/studio-dist/client/assets/{getting-started-D6kgWwWZ.js → getting-started-MmLqvy01.js} +1 -1
  297. package/studio-dist/client/assets/getting-started._topic-DBF0khhz.js +1 -0
  298. package/studio-dist/client/assets/getting-started.index-BRdAVqIh.js +1 -0
  299. package/studio-dist/client/assets/graph-BVRdq46V.js +2 -0
  300. package/studio-dist/client/assets/{graph-canvas-Ba37Y5AE.js → graph-canvas-BNzd-eVb.js} +1 -1
  301. package/studio-dist/client/assets/guides-DY1W9LRs.js +1 -0
  302. package/studio-dist/client/assets/index-CuTIc9yd.js +40 -0
  303. package/studio-dist/client/assets/{markdown-view-BOX6x0rL.js → markdown-view-BqZQkk_k.js} +1 -1
  304. package/studio-dist/client/assets/mcp-CIFxmDs0.js +4 -0
  305. package/studio-dist/client/assets/panel-DafanLQ4.js +1 -0
  306. package/studio-dist/client/assets/plugins._service._view-xSRLxHNM.js +1 -0
  307. package/studio-dist/client/assets/prepaint-C--F50QZ.js +27 -0
  308. package/studio-dist/client/assets/{queries-RvHeXY12.js → queries-ByCoiacy.js} +1 -1
  309. package/studio-dist/client/assets/react-BYUSgtBs.js +1 -0
  310. package/studio-dist/client/assets/reports-Diryyked.js +1 -0
  311. package/studio-dist/client/assets/routes-DbRwPd55.js +1 -0
  312. package/studio-dist/client/assets/search-BDKQRwa5.js +1 -0
  313. package/studio-dist/client/assets/select-_9JT3hpU.js +1 -0
  314. package/studio-dist/client/assets/skills-D5a6ybQM.js +1 -0
  315. package/studio-dist/client/assets/{specs-B0ldF_6J.js → specs-COAWUTog.js} +1 -1
  316. package/studio-dist/client/assets/specs-view-9eTn9TcN.js +1 -0
  317. package/studio-dist/client/assets/steps-BS588WAV.js +1 -0
  318. package/studio-dist/client/assets/store-3cffhIO6.js +1 -0
  319. package/studio-dist/client/assets/studio-CG9eioSx.js +100 -0
  320. package/studio-dist/client/assets/studio-queries-BS1yR7Wc.js +2 -0
  321. package/studio-dist/client/assets/{usage-C2QJ_0IZ.js → usage-Ccl4d7w0.js} +15 -15
  322. package/studio-dist/client/assets/useAnchoredPopupScrollLock-D_y83VP7.js +1 -0
  323. package/studio-dist/client/assets/useBlocker-BQOfcu_f.js +1 -0
  324. package/studio-dist/client/assets/useMutation-BDmS2V6y.js +1 -0
  325. package/studio-dist/client/assets/usePopupHandleStore-BcqpNR-F.js +1 -0
  326. package/studio-dist/client/assets/vault-C1tOhQMe.js +1 -0
  327. package/studio-dist/client/assets/warnings-BZ_X1nkO.js +1 -0
  328. package/studio-dist/client/assets/workflow-Cm2fsnly.js +1 -0
  329. package/studio-dist/server/assets/DialogTitle-KSVhF_7V.js +421 -0
  330. package/studio-dist/server/assets/{__23tanstack-start-server-fn-resolver-Bn896ZYj.js → __23tanstack-start-server-fn-resolver-QQnIXyKi.js} +40 -28
  331. package/studio-dist/server/assets/_tanstack-start-manifest_v.js +84 -74
  332. package/studio-dist/server/assets/{button-CgOIVdmD.js → button-C7EMLaX6.js} +229 -5527
  333. package/studio-dist/server/assets/cn-D7uJiH_O.js +5528 -0
  334. package/studio-dist/server/assets/{combobox-DV_s9W0s.js → combobox-Dc4_y20Y.js} +6 -5
  335. package/studio-dist/server/assets/{companion-view-BKVXD3TO.js → companion-view-CrSi37Mb.js} +2 -2
  336. package/studio-dist/server/assets/{companions-C7fctnU9.js → companions-CDSuLqA4.js} +1 -1
  337. package/studio-dist/server/assets/{fields-BbieQTD0.js → fields-BxBN6-Dz.js} +10 -2
  338. package/studio-dist/server/assets/friction-B1K8Kp8r.js +62 -0
  339. package/studio-dist/server/assets/friction-Vl3B6THL.js +943 -0
  340. package/studio-dist/server/assets/{getting-started-CRxMWorQ.js → getting-started-B3lu5W7M.js} +2 -2
  341. package/studio-dist/server/assets/{getting-started._topic-DJKQAzYl.js → getting-started._topic-EYtxZM-Y.js} +2 -2
  342. package/studio-dist/server/assets/{getting-started.index-D84gec1t.js → getting-started.index-CTaXYycH.js} +2 -2
  343. package/studio-dist/server/assets/{graph-DDZzXM1L.js → graph-Bhmk7H8V.js} +1 -1
  344. package/studio-dist/server/assets/{graph-CSje3029.js → graph-D3fXCaKt.js} +8 -8
  345. package/studio-dist/server/assets/{graph-canvas-22bWB5-2.js → graph-canvas-DIvTodML.js} +2 -2
  346. package/studio-dist/server/assets/{guides-IE-19POz.js → guides-BZWFpJl-.js} +1 -1
  347. package/studio-dist/server/assets/{guides-D9dk1Frq.js → guides-CHBkRO6R.js} +1 -1
  348. package/studio-dist/server/assets/{guides.server-vcYRY5wx.js → guides.server-DX9KRkcK.js} +1 -1
  349. package/studio-dist/server/assets/{markdown-view-BR8dJ7aR.js → markdown-view-qrCSkVta.js} +1 -1
  350. package/studio-dist/server/assets/mcp-Ljf4simO.js +1103 -0
  351. package/studio-dist/server/assets/mcp-manager-DohRwmJU.js +50 -0
  352. package/studio-dist/server/assets/{panel-BR_t9iMM.js → panel-CAwz4mKp.js} +6 -4
  353. package/studio-dist/server/assets/plugins._service._view-DUpAo5D_.js +97 -0
  354. package/studio-dist/server/assets/prepaint-BxZ-pU7t.js +45 -0
  355. package/studio-dist/server/assets/{queries-DWoTin-q.js → queries-W4LXzTnT.js} +1 -1
  356. package/studio-dist/server/assets/react-CiBZPDs8.js +45 -0
  357. package/studio-dist/server/assets/{reports-CQ9qQ1-n.js → reports-BVNSPHU3.js} +13 -7
  358. package/studio-dist/server/assets/{reports-dYDEoBeq.js → reports-CGG_wRN5.js} +1 -1
  359. package/studio-dist/server/assets/{router-DkRHNTpE.js → router-KH1x6ryF.js} +1039 -1096
  360. package/studio-dist/server/assets/{routes-B6GfOew4.js → routes-Bl90FC4R.js} +333 -38
  361. package/studio-dist/server/assets/search-BjG5f16n.js +110 -0
  362. package/studio-dist/server/assets/{select-Af7Wibii.js → select-B8q9tLbl.js} +5 -4
  363. package/studio-dist/server/assets/{shell-Hq-hXgnT.js → shell-C5emwofr.js} +12 -3
  364. package/studio-dist/server/assets/{skills-B7nEuVbx.js → skills-10l0eCfP.js} +8 -8
  365. package/studio-dist/server/assets/{skills-B_YYL7q8.js → skills-vG6TTvP1.js} +1 -1
  366. package/studio-dist/server/assets/{specs-BpLUFntA.js → specs-C1P2BEao.js} +4 -4
  367. package/studio-dist/server/assets/{specs-view-0peMVd22.js → specs-view-csUBtMWU.js} +10 -10
  368. package/studio-dist/server/assets/{steps-D56DApvK.js → steps-T4wXftgd.js} +88 -45
  369. package/studio-dist/server/assets/store-CWlRjv9s.js +93 -0
  370. package/studio-dist/server/assets/{studio-CAcKp3bM.js → studio-D-ZPWSMv.js} +1567 -59
  371. package/studio-dist/server/assets/{studio-queries-BtRGzDdh.js → studio-queries-DC273ifg.js} +66 -124
  372. package/studio-dist/server/assets/{usage-COdjd1gD.js → usage-CT3IWLJc.js} +13 -30
  373. package/studio-dist/server/assets/{usage-f6pqE1tm.js → usage-D4t_ibR8.js} +1 -1
  374. package/studio-dist/server/assets/{useAnchoredPopupScrollLock-DlBKHRw7.js → useAnchoredPopupScrollLock-BchJDJYg.js} +2 -2
  375. package/studio-dist/server/assets/useBlocker-CQtANHK8.js +111 -0
  376. package/studio-dist/server/assets/{useMutation-DzTZGenE.js → useMutation-0HbcKUsQ.js} +2 -2
  377. package/studio-dist/server/assets/usePopupHandleStore-B3SNGTic.js +26 -0
  378. package/studio-dist/server/assets/{vault-BDuIUq0F.js → vault-BIytrudF.js} +10 -117
  379. package/studio-dist/server/assets/{vault-BVLp6zu3.js → vault-MINXmyXA.js} +1 -1
  380. package/studio-dist/server/assets/{views-flRUr21z.js → views-DrmY_3J5.js} +7 -4
  381. package/studio-dist/server/assets/{warnings-CDy9pdgL.js → warnings-BVZCDbIz.js} +2 -2
  382. package/studio-dist/server/assets/{workflow-D9GKI2EV.js → workflow-DFdqnMtW.js} +57 -50
  383. package/studio-dist/server/server.js +2 -2
  384. package/tool-manifest.yaml +85 -0
  385. package/src/cli/commands/factory/factory.ts +0 -311
  386. package/src/cli/commands/studio/factory-credential.ts +0 -35
  387. package/src/cli/commands/studio/factory-git-tokens.ts +0 -40
  388. package/src/cli/commands/studio/factory-relay.ts +0 -18
  389. package/src/cli/commands/studio/repository-add.ts +0 -116
  390. package/src/cli/commands/studio/workset-session.ts +0 -164
  391. package/src/lib/delivery/archive-change.ts +0 -165
  392. package/src/lib/delivery/forge.ts +0 -279
  393. package/src/lib/delivery/token.ts +0 -24
  394. package/src/lib/factory/attach-client.ts +0 -123
  395. package/src/lib/factory/attach.ts +0 -178
  396. package/src/lib/factory/broker.ts +0 -187
  397. package/src/lib/factory/bun-commands.ts +0 -39
  398. package/src/lib/factory/client.ts +0 -113
  399. package/src/lib/factory/clone-url.ts +0 -39
  400. package/src/lib/factory/command.ts +0 -77
  401. package/src/lib/factory/credential-store.ts +0 -153
  402. package/src/lib/factory/frames.ts +0 -77
  403. package/src/lib/factory/git-auth.ts +0 -61
  404. package/src/lib/factory/git-credential-store.ts +0 -181
  405. package/src/lib/factory/ids.ts +0 -68
  406. package/src/lib/factory/outcomes/actions.ts +0 -130
  407. package/src/lib/factory/outcomes/index.ts +0 -457
  408. package/src/lib/factory/outcomes/lifecycle.ts +0 -212
  409. package/src/lib/factory/outcomes/runs.ts +0 -81
  410. package/src/lib/factory/prepare.ts +0 -55
  411. package/src/lib/factory/pty.ts +0 -103
  412. package/src/lib/factory/runner/companion-context.ts +0 -178
  413. package/src/lib/factory/runner/control.ts +0 -92
  414. package/src/lib/factory/runner/harness-agent.ts +0 -250
  415. package/src/lib/factory/runner/live.ts +0 -159
  416. package/src/lib/factory/runner/questions.ts +0 -22
  417. package/src/lib/factory/runner/rank.ts +0 -26
  418. package/src/lib/factory/runner/run-policy.ts +0 -12
  419. package/src/lib/factory/runner/run.ts +0 -199
  420. package/src/lib/factory/runner/scheduler.ts +0 -498
  421. package/src/lib/factory/runner/state.ts +0 -233
  422. package/src/lib/factory/runner/workflow.ts +0 -546
  423. package/src/lib/factory/runtime.ts +0 -1081
  424. package/src/lib/factory/sandbox.ts +0 -292
  425. package/src/lib/factory/worktree-branch.ts +0 -17
  426. package/src/templates/capabilities/openspec-cap/mate-v1/templates/explore-brief.md +0 -25
  427. package/studio-dist/client/assets/app-D9cw6szy.css +0 -2
  428. package/studio-dist/client/assets/artifacts-WD2ZXYrx.js +0 -1
  429. package/studio-dist/client/assets/button-Br0O1sXw.js +0 -1
  430. package/studio-dist/client/assets/combobox-DA7RAUUZ.js +0 -1
  431. package/studio-dist/client/assets/factory-DGS0E16C.js +0 -6
  432. package/studio-dist/client/assets/fields-6aXBpFhJ.js +0 -1
  433. package/studio-dist/client/assets/getting-started-Clde4w6P.js +0 -1
  434. package/studio-dist/client/assets/getting-started._topic-BiunccbT.js +0 -1
  435. package/studio-dist/client/assets/getting-started.index-DpiNoGw8.js +0 -1
  436. package/studio-dist/client/assets/graph-B_TCBVbu.js +0 -2
  437. package/studio-dist/client/assets/guides-Du_RtJxP.js +0 -1
  438. package/studio-dist/client/assets/index-Df8L1LQa.js +0 -40
  439. package/studio-dist/client/assets/panel-dbmCx7Mx.js +0 -1
  440. package/studio-dist/client/assets/react-3QStrcDO.js +0 -27
  441. package/studio-dist/client/assets/report-url-XRL0x1SY.js +0 -1
  442. package/studio-dist/client/assets/reports-r3IK7Doz.js +0 -1
  443. package/studio-dist/client/assets/routes-C0A5LTFc.js +0 -1
  444. package/studio-dist/client/assets/select-CnaMd617.js +0 -1
  445. package/studio-dist/client/assets/skills-CzjzHpBT.js +0 -1
  446. package/studio-dist/client/assets/specs-view-BnCLA0gW.js +0 -1
  447. package/studio-dist/client/assets/spinner-Dcm3fqK1.js +0 -1
  448. package/studio-dist/client/assets/steps-C0p2N1Pb.js +0 -1
  449. package/studio-dist/client/assets/store-Dw34catY.js +0 -1
  450. package/studio-dist/client/assets/studio-Cpz_HRHp.js +0 -100
  451. package/studio-dist/client/assets/studio-queries-ibmpFo6R.js +0 -2
  452. package/studio-dist/client/assets/useAnchoredPopupScrollLock-Bj-FWb8z.js +0 -1
  453. package/studio-dist/client/assets/useMutation-aAr2uiay.js +0 -1
  454. package/studio-dist/client/assets/vault-BGcxkSIY.js +0 -1
  455. package/studio-dist/client/assets/warnings-R1cE1rLf.js +0 -1
  456. package/studio-dist/client/assets/workflow-C2qTrMDH.js +0 -1
  457. package/studio-dist/server/assets/actions-DYSv-9VV.js +0 -60
  458. package/studio-dist/server/assets/artifacts-DnF9L3dZ.js +0 -216
  459. package/studio-dist/server/assets/factory-C7Ybg0xG.js +0 -3075
  460. package/studio-dist/server/assets/factory-Df5uAHjb.js +0 -116
  461. package/studio-dist/server/assets/react-CdqSUhaL.js +0 -89
  462. package/studio-dist/server/assets/report-url-BUXPcE_8.js +0 -9
  463. package/studio-dist/server/assets/search-BJnWLfkG.js +0 -55
  464. package/studio-dist/server/assets/spinner-CdwJW4VB.js +0 -20
  465. package/studio-dist/server/assets/store-Cs17okNG.js +0 -280
  466. /package/src/lib/{factory/keyed-serial.ts → keyed-serial.ts} +0 -0
  467. /package/src/templates/capabilities/openspec-cap/{mate-v1 → mate-full}/templates/spec.md +0 -0
@@ -0,0 +1,943 @@
1
+ import { C as useSetFrictionRecording, E as RecordingState, S as useMarkFriction, T as RecordingReach, b as useRetryFocus, g as Route, w as RecordingButton, x as frictionQuery, y as useBrowser } from "./router-KH1x6ryF.js";
2
+ import { B as keepPreviousData } from "./studio-queries-DC273ifg.js";
3
+ import { Lr as useQuery, et as CommandLine, it as PAGE_PAD, lt as StatusWord, nt as EmptyNote, ot as Pills, r as Icon, rt as ListCard, t as Button, tt as Count, ut as ViewLoading } from "./button-C7EMLaX6.js";
4
+ import { S as SUBJECT_TYPES, _ as selectFriction$1, b as REPORT_KINDS, v as FRICTION_STATES } from "./studio-D-ZPWSMv.js";
5
+ import { n as require_react, o as __toESM, t as require_jsx_runtime } from "./jsx-runtime-Bt0s0YKS.js";
6
+ import { a as Select, c as SelectTrigger, l as SelectValue, o as SelectContent, s as SelectItem } from "./select-B8q9tLbl.js";
7
+ import { t as cn } from "./cn-D7uJiH_O.js";
8
+ import { n as oneOf, s as FRICTION_VIEW_DAYS } from "./search-BjG5f16n.js";
9
+ import { t as Input } from "./fields-BxBN6-Dz.js";
10
+ // ../mate-core/src/runtime/framework.ts
11
+ /**
12
+ * Framework identity: names everything identity-shaped — state directories
13
+ * (`~/.mate`, `.mate/`), managed-block markers, `MATE_*` env values, usage
14
+ * output, command hints, error prefixes, agent guidance, and permission
15
+ * entries. The distribution is always invoked as `mate`.
16
+ *
17
+ * Lives under `runtime/` because the import-isolated runtime subpath derives
18
+ * repo-local `.mate/` paths from it; `../framework` re-exports it.
19
+ */
20
+ var FRAMEWORK_NAME = "mate";
21
+ // ../mate-core/src/runtime/command-arg.ts
22
+ /**
23
+ * Quotes one argument of a command a person pastes into a shell. Plain words stay bare and double
24
+ * quotes are used where cmd.exe, PowerShell and POSIX shells all keep the text unchanged; any
25
+ * other text falls back to POSIX single quotes.
26
+ */
27
+ function quoteCommandArg(value) {
28
+ if (/^[\w:./+=-]+$/.test(value)) return value;
29
+ if (!/["$`\\!%]/.test(value)) return `"${value}"`;
30
+ return `'${value.replaceAll("'", `'\\''`)}'`;
31
+ }
32
+ /** One command line from its words, each quoted with `quoteCommandArg`. */
33
+ function formatCommand(words) {
34
+ return words.map(quoteCommandArg).join(" ");
35
+ }
36
+ // src/views/friction/mark-actions.tsx
37
+ var import_react = /* @__PURE__ */ __toESM(require_react(), 1);
38
+ var import_jsx_runtime = require_jsx_runtime();
39
+ var STATE_WORDS = {
40
+ fixed: {
41
+ label: "Fixed",
42
+ marker: "done"
43
+ },
44
+ reported: {
45
+ label: "Reported",
46
+ marker: "review"
47
+ },
48
+ dismissed: {
49
+ label: "Dismissed",
50
+ marker: "idle"
51
+ }
52
+ };
53
+ var BY = {
54
+ person: "by a person",
55
+ triage: "by triage",
56
+ studio: "in Studio"
57
+ };
58
+ var plural = (count, noun) => `${count} ${noun}${count === 1 ? "" : "s"}`;
59
+ /** The item's Friction State as one word with its marker; nothing for an unmarked item. */
60
+ function StateWord({ state }) {
61
+ if (!state) return null;
62
+ const word = STATE_WORDS[state.state];
63
+ return state.reopened ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(StatusWord, {
64
+ marker: "warn",
65
+ children: "Reopened"
66
+ }) : /* @__PURE__ */ (0, import_jsx_runtime.jsx)(StatusWord, {
67
+ marker: word.marker,
68
+ children: word.label
69
+ });
70
+ }
71
+ function ItemState({ state, time }) {
72
+ const word = STATE_WORDS[state.state];
73
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("p", {
74
+ className: "m-0 flex flex-wrap items-baseline gap-x-3 gap-y-1 text-xs text-muted",
75
+ children: [
76
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(StateWord, { state }),
77
+ /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("span", { children: [
78
+ state.reopened ? "Fixed, then recorded again; marked " : `${word.label} `,
79
+ BY[state.by],
80
+ " ",
81
+ time
82
+ ] }),
83
+ state.state === "reported" && state.eventsSince !== void 0 ? /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("span", {
84
+ className: "tabular-nums",
85
+ children: [plural(state.eventsSince, "event"), " since reported"]
86
+ }) : null,
87
+ state.link ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)("a", {
88
+ href: state.link,
89
+ target: "_blank",
90
+ rel: "noreferrer",
91
+ className: "text-text underline",
92
+ children: state.link
93
+ }) : null,
94
+ state.note ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", {
95
+ className: "text-text",
96
+ children: state.note
97
+ }) : null
98
+ ]
99
+ });
100
+ }
101
+ var NOTE = {
102
+ label: "Note (optional)",
103
+ key: "note",
104
+ type: "text"
105
+ };
106
+ var MARKS = {
107
+ fixed: {
108
+ action: "Mark fixed",
109
+ field: NOTE
110
+ },
111
+ reported: {
112
+ action: "Mark reported",
113
+ field: {
114
+ label: "Issue link (optional)",
115
+ key: "link",
116
+ type: "url"
117
+ }
118
+ },
119
+ dismissed: {
120
+ action: "Dismiss",
121
+ field: NOTE
122
+ }
123
+ };
124
+ function MarkActions({ name, handled, onMark }) {
125
+ const [draft, setDraft] = (0, import_react.useState)(null);
126
+ const [text, setText] = (0, import_react.useState)("");
127
+ const [pending, setPending] = (0, import_react.useState)(false);
128
+ const [refusal, setRefusal] = (0, import_react.useState)(null);
129
+ const fieldId = (0, import_react.useId)();
130
+ const field = (0, import_react.useRef)(null);
131
+ const openers = (0, import_react.useRef)({});
132
+ const cancelled = (0, import_react.useRef)(null);
133
+ (0, import_react.useEffect)(() => {
134
+ if (draft) field.current?.focus();
135
+ else if (cancelled.current) openers.current[cancelled.current]?.focus();
136
+ cancelled.current = null;
137
+ }, [draft]);
138
+ const close = () => {
139
+ setDraft(null);
140
+ setText("");
141
+ setRefusal(null);
142
+ };
143
+ const cancel = () => {
144
+ if (pending) return;
145
+ cancelled.current = draft;
146
+ close();
147
+ };
148
+ async function submit(state, input = {}) {
149
+ setPending(true);
150
+ setRefusal(null);
151
+ const refused = await onMark(state, input);
152
+ setPending(false);
153
+ if (refused) setRefusal(refused);
154
+ else close();
155
+ }
156
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", {
157
+ className: "grid gap-1.5",
158
+ children: [draft ? /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("form", {
159
+ "aria-label": `${MARKS[draft].action}: ${name}`,
160
+ className: "flex flex-wrap items-end gap-2",
161
+ onSubmit: (event) => {
162
+ event.preventDefault();
163
+ submit(draft, { [MARKS[draft].field.key]: text });
164
+ },
165
+ onKeyDown: (event) => {
166
+ if (event.key === "Escape") cancel();
167
+ },
168
+ children: [
169
+ /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("label", {
170
+ htmlFor: fieldId,
171
+ className: "grid gap-1 text-xs text-muted",
172
+ children: [MARKS[draft].field.label, /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Input, {
173
+ id: fieldId,
174
+ ref: field,
175
+ type: MARKS[draft].field.type,
176
+ value: text,
177
+ onChange: (event) => setText(event.target.value),
178
+ className: "h-8 w-72 max-w-full"
179
+ })]
180
+ }),
181
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Button, {
182
+ size: "sm",
183
+ variant: "primary",
184
+ type: "submit",
185
+ disabled: pending,
186
+ children: MARKS[draft].action
187
+ }),
188
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Button, {
189
+ size: "sm",
190
+ onClick: cancel,
191
+ disabled: pending,
192
+ children: "Cancel"
193
+ })
194
+ ]
195
+ }) : /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", {
196
+ role: "group",
197
+ "aria-label": `Mark ${name}`,
198
+ className: "flex flex-wrap gap-2",
199
+ children: [FRICTION_STATES.map((state) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Button, {
200
+ ref: (button) => {
201
+ openers.current[state] = button;
202
+ },
203
+ size: "sm",
204
+ disabled: pending,
205
+ onClick: () => setDraft(state),
206
+ children: MARKS[state].action
207
+ }, state)), handled ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Button, {
208
+ size: "sm",
209
+ disabled: pending,
210
+ onClick: () => void submit("open"),
211
+ children: "Reopen"
212
+ }) : null]
213
+ }), refusal ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)("p", {
214
+ className: "m-0 max-w-[70ch] text-xs text-bad",
215
+ role: "alert",
216
+ children: refusal
217
+ }) : null]
218
+ });
219
+ }
220
+ // src/views/friction/select-friction.ts
221
+ var DEFAULT_FRICTION_FILTERS = {
222
+ state: "open",
223
+ sort: "repeats"
224
+ };
225
+ function filtersFromSearch(search) {
226
+ return {
227
+ state: search.frictionState ?? DEFAULT_FRICTION_FILTERS.state,
228
+ type: search.frictionType,
229
+ kind: search.frictionKind,
230
+ sort: search.frictionSort ?? DEFAULT_FRICTION_FILTERS.sort
231
+ };
232
+ }
233
+ /** Defaults leave the address, so it stays short. */
234
+ function searchFromFilters(filters) {
235
+ return {
236
+ frictionState: filters.state === DEFAULT_FRICTION_FILTERS.state ? void 0 : filters.state,
237
+ frictionType: filters.type,
238
+ frictionKind: filters.kind,
239
+ frictionSort: filters.sort === DEFAULT_FRICTION_FILTERS.sort ? void 0 : filters.sort
240
+ };
241
+ }
242
+ /** Core's selection in the chosen order; most repeated is the view's own order. */
243
+ function selectFriction(view, filters) {
244
+ const shown = selectFriction$1(view, filters);
245
+ if (filters.sort !== "recent") return shown;
246
+ return {
247
+ ...shown,
248
+ groups: shown.groups.toSorted((a, b) => a.lastSeen < b.lastSeen ? 1 : a.lastSeen > b.lastSeen ? -1 : 0)
249
+ };
250
+ }
251
+ // src/views/friction/friction-view.tsx
252
+ var PERIODS = FRICTION_VIEW_DAYS.map((days) => ({
253
+ value: String(days),
254
+ label: `${days} days`
255
+ }));
256
+ var STATES = [
257
+ {
258
+ value: "open",
259
+ label: "Open"
260
+ },
261
+ {
262
+ value: "handled",
263
+ label: "Handled"
264
+ },
265
+ {
266
+ value: "all",
267
+ label: "All"
268
+ }
269
+ ];
270
+ var ANY = "any";
271
+ var KINDS = [{
272
+ value: ANY,
273
+ label: "All kinds"
274
+ }, ...REPORT_KINDS.map((kind) => ({
275
+ value: kind,
276
+ label: kind
277
+ }))];
278
+ var SORTS = [{
279
+ value: "repeats",
280
+ label: "Most repeated in one session"
281
+ }, {
282
+ value: "recent",
283
+ label: "Most recent"
284
+ }];
285
+ var RECORDED_SECTION = {
286
+ id: "friction-recorded",
287
+ title: "Recorded friction"
288
+ };
289
+ var REPORTS_SECTION = {
290
+ id: "friction-agent-reports",
291
+ title: "Agent reports"
292
+ };
293
+ var DATE_TIME = new Intl.DateTimeFormat(void 0, {
294
+ dateStyle: "medium",
295
+ timeStyle: "short"
296
+ });
297
+ /** Filled in after hydration: the server's time zone may differ from the viewer's. */
298
+ function FrictionTime({ at }) {
299
+ const browser = useBrowser();
300
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)("time", {
301
+ dateTime: at,
302
+ children: browser ? DATE_TIME.format(Date.parse(at)) : ""
303
+ });
304
+ }
305
+ var DETAILS = "m-0 grid grid-cols-[max-content_minmax(0,1fr)] items-baseline gap-x-3 gap-y-1 @md:grid-cols-[6rem_minmax(0,1fr)]";
306
+ function Detail({ label, children }) {
307
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_jsx_runtime.Fragment, { children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)("dt", {
308
+ className: "text-muted",
309
+ children: label
310
+ }), /* @__PURE__ */ (0, import_jsx_runtime.jsx)("dd", {
311
+ className: "m-0 min-w-0",
312
+ children
313
+ })] });
314
+ }
315
+ function Counted({ label, counts }) {
316
+ const entries = Object.entries(counts);
317
+ if (entries.length === 0) return null;
318
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Detail, {
319
+ label,
320
+ children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", {
321
+ className: "flex flex-wrap gap-x-3 gap-y-1",
322
+ children: entries.map(([name, count]) => /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("span", {
323
+ className: "font-mono tabular-nums",
324
+ children: [
325
+ name,
326
+ " ",
327
+ /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("span", {
328
+ className: "text-muted",
329
+ children: ["×", count]
330
+ })
331
+ ]
332
+ }, name))
333
+ })
334
+ });
335
+ }
336
+ function ItemFooter({ name, target, item, onMark }) {
337
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", {
338
+ className: "mt-1 grid gap-1.5",
339
+ children: [
340
+ item.state ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(ItemState, {
341
+ state: item.state,
342
+ time: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(FrictionTime, { at: item.state.at })
343
+ }) : null,
344
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(MarkActions, {
345
+ name,
346
+ handled: !item.open,
347
+ onMark
348
+ }),
349
+ /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", {
350
+ role: "group",
351
+ "aria-label": `Triage ${name}`,
352
+ className: "flex flex-wrap items-center gap-x-3 gap-y-2 text-xs",
353
+ children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)("p", {
354
+ className: "m-0 text-muted",
355
+ children: "To investigate this item, run in your own terminal, in a repository of its companion:"
356
+ }), /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", {
357
+ className: "w-full max-w-xl min-w-0",
358
+ children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(CommandLine, {
359
+ text: formatCommand([
360
+ FRAMEWORK_NAME,
361
+ "triage",
362
+ target
363
+ ]),
364
+ label: "command"
365
+ })
366
+ })]
367
+ })
368
+ ]
369
+ });
370
+ }
371
+ function Fields({ fields }) {
372
+ const shown = fields.filter(([, text]) => text);
373
+ if (shown.length === 0) return null;
374
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)("dl", {
375
+ className: cn(DETAILS, "max-w-[70ch] text-sm"),
376
+ children: shown.map(([label, text]) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Detail, {
377
+ label,
378
+ children: text
379
+ }, label))
380
+ });
381
+ }
382
+ function Row({ focusKey, line, summary, children }) {
383
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)("li", {
384
+ className: "border-t border-rule-soft first:border-t-0",
385
+ "data-friction-item": focusKey,
386
+ children: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("details", {
387
+ className: "group/friction",
388
+ children: [/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("summary", {
389
+ className: "grid cursor-pointer list-none grid-cols-[auto_minmax(0,1fr)] gap-x-2 px-4 py-2.5 hover:bg-surface focus-visible:-outline-offset-2 [&::-webkit-details-marker]:hidden",
390
+ children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)(Icon, {
391
+ name: "right",
392
+ className: "mt-1 size-3.5 text-muted transition-transform group-open/friction:rotate-90 motion-reduce:transition-none"
393
+ }), /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", {
394
+ className: cn("flex min-w-0 flex-wrap items-baseline gap-x-4 gap-y-1", line),
395
+ children: summary
396
+ })]
397
+ }), /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", {
398
+ className: "mr-4 mb-3 ml-9.5 grid gap-1.5 border-l border-rule-soft pl-3",
399
+ children
400
+ })]
401
+ })
402
+ });
403
+ }
404
+ var FACTS = "flex flex-wrap items-baseline gap-x-3 gap-y-0.5 font-mono text-xs whitespace-nowrap text-muted tabular-nums";
405
+ var LAST_SEEN_TRACK = "minmax(32ch,max-content)";
406
+ var AT_TRACK = "minmax(22ch,max-content)";
407
+ var STATE_TRACK = "11ch";
408
+ function Gap({ wide }) {
409
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", {
410
+ "aria-hidden": "true",
411
+ className: cn("hidden", wide)
412
+ });
413
+ }
414
+ function groupCounts(group) {
415
+ return [
416
+ `at most ${group.maxPerSession} in one session`,
417
+ plural(group.events, "event"),
418
+ plural(group.sessions, "session"),
419
+ group.reports.length > 0 ? plural(group.reports.length, "report") : null
420
+ ];
421
+ }
422
+ function groupTracks(groups, columns) {
423
+ const counts = groups.map(groupCounts);
424
+ const widest = (column) => Math.max(...counts.map((row) => row[column]?.length ?? 0), 0);
425
+ const tracks = [
426
+ 0,
427
+ 1,
428
+ 2
429
+ ].map((column) => `${widest(column)}ch`);
430
+ if (columns.reports) tracks.push(`${widest(3)}ch`);
431
+ tracks.push(LAST_SEEN_TRACK);
432
+ if (columns.state) tracks.push(STATE_TRACK);
433
+ return tracks.join(" ");
434
+ }
435
+ function reportTracks(stateColumn) {
436
+ return stateColumn ? `${AT_TRACK} ${STATE_TRACK}` : AT_TRACK;
437
+ }
438
+ var factsStyle = (tracks) => ({ "--friction-facts": tracks });
439
+ function StateCell({ state, column, wide }) {
440
+ if (state) return /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", {
441
+ className: "font-sans",
442
+ children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(StateWord, { state })
443
+ });
444
+ return column ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Gap, { wide }) : null;
445
+ }
446
+ function GroupItem({ group, columns, onMark }) {
447
+ const [peak, events, sessions, reports] = groupCounts(group);
448
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(Row, {
449
+ focusKey: group.fingerprint,
450
+ line: "@5xl:grid @5xl:grid-cols-[minmax(0,1fr)_auto]",
451
+ summary: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_jsx_runtime.Fragment, { children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)("h3", {
452
+ className: "m-0 min-w-0 flex-[1_1_16rem] text-base font-semibold",
453
+ children: group.title
454
+ }), /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("span", {
455
+ className: cn(FACTS, "@3xl:grid @3xl:grid-cols-(--friction-facts)"),
456
+ children: [
457
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { children: peak }),
458
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { children: events }),
459
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { children: sessions }),
460
+ reports ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { children: reports }) : columns.reports ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Gap, { wide: "@3xl:block" }) : null,
461
+ /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("span", { children: ["last seen ", /* @__PURE__ */ (0, import_jsx_runtime.jsx)(FrictionTime, { at: group.lastSeen })] }),
462
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(StateCell, {
463
+ state: group.state,
464
+ column: columns.state,
465
+ wide: "@3xl:block"
466
+ })
467
+ ]
468
+ })] }),
469
+ children: [
470
+ /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("dl", {
471
+ className: cn(DETAILS, "text-xs"),
472
+ children: [
473
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Detail, {
474
+ label: "Fingerprint",
475
+ children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)("code", {
476
+ className: "font-mono",
477
+ children: group.fingerprint
478
+ })
479
+ }),
480
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Detail, {
481
+ label: "First seen",
482
+ children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(FrictionTime, { at: group.firstSeen })
483
+ }),
484
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Detail, {
485
+ label: "Last seen",
486
+ children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(FrictionTime, { at: group.lastSeen })
487
+ }),
488
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Counted, {
489
+ label: "Mate",
490
+ counts: group.versions
491
+ }),
492
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Counted, {
493
+ label: "Paths",
494
+ counts: group.paths
495
+ }),
496
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Counted, {
497
+ label: "Flags",
498
+ counts: group.flags
499
+ })
500
+ ]
501
+ }),
502
+ group.reports.length > 0 ? /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("section", {
503
+ "aria-label": `Reports on ${group.title}`,
504
+ className: "mt-1",
505
+ children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)("h4", {
506
+ className: "m-0 text-xs font-semibold text-muted",
507
+ children: plural(group.reports.length, "report")
508
+ }), /* @__PURE__ */ (0, import_jsx_runtime.jsx)("ul", {
509
+ className: "m-0 list-none p-0",
510
+ children: group.reports.map((report) => /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("li", {
511
+ className: "grid gap-1 border-t border-rule-soft py-2 first:border-t-0",
512
+ children: [/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", {
513
+ className: "flex flex-wrap items-baseline gap-x-2 text-xs text-muted",
514
+ children: [
515
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", {
516
+ className: "font-semibold text-text",
517
+ children: report.kind
518
+ }),
519
+ report.cost ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { children: report.cost }) : null,
520
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(FrictionTime, { at: report.at })
521
+ ]
522
+ }), /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Fields, { fields: [
523
+ ["Expected", report.expected],
524
+ ["Evidence", report.evidence],
525
+ ["Workaround", report.workaround]
526
+ ] })]
527
+ }, report.id))
528
+ })]
529
+ }) : null,
530
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(ItemFooter, {
531
+ name: group.title,
532
+ target: group.fingerprint,
533
+ item: group,
534
+ onMark
535
+ })
536
+ ]
537
+ });
538
+ }
539
+ function FreeReportItem({ report, stateColumn, onMark }) {
540
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(Row, {
541
+ focusKey: report.id,
542
+ line: "@3xl:grid @3xl:grid-cols-[minmax(0,1fr)_auto]",
543
+ summary: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_jsx_runtime.Fragment, { children: [/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("span", {
544
+ className: "flex min-w-0 flex-wrap items-baseline gap-x-2 gap-y-1",
545
+ children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)("h3", {
546
+ className: "m-0 min-w-0 font-mono text-sm leading-[1.375rem] font-semibold",
547
+ children: report.subject
548
+ }), /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", {
549
+ className: "rounded-full border border-rule bg-page px-2 font-mono text-[0.7rem] text-text",
550
+ children: report.kind
551
+ })]
552
+ }), /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("span", {
553
+ className: cn(FACTS, "@3xl:grid @3xl:grid-cols-(--friction-facts)"),
554
+ children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)(FrictionTime, { at: report.at }), /* @__PURE__ */ (0, import_jsx_runtime.jsx)(StateCell, {
555
+ state: report.state,
556
+ column: stateColumn,
557
+ wide: "@3xl:block"
558
+ })]
559
+ })] }),
560
+ children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)(Fields, { fields: [
561
+ ["Expected", report.expected],
562
+ ["Cost", report.cost],
563
+ ["Evidence", report.evidence],
564
+ ["Workaround", report.workaround]
565
+ ] }), /* @__PURE__ */ (0, import_jsx_runtime.jsx)(ItemFooter, {
566
+ name: report.subject,
567
+ target: report.id,
568
+ item: report,
569
+ onMark
570
+ })]
571
+ });
572
+ }
573
+ function Hidden({ hidden, onShowAll }) {
574
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_jsx_runtime.Fragment, { children: [
575
+ hidden === 1 ? "1 item is" : `${hidden} items are`,
576
+ " hidden by the filters.",
577
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Button, {
578
+ size: "sm",
579
+ onClick: onShowAll,
580
+ "data-show-all": true,
581
+ "aria-label": `Show all, including ${plural(hidden, "hidden item")}`,
582
+ children: "Show all"
583
+ })
584
+ ] });
585
+ }
586
+ function Overview({ view, shown, empty, onShowAll }) {
587
+ const sections = [[RECORDED_SECTION, shown.groups.length], [REPORTS_SECTION, shown.freeReports.length]];
588
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("section", {
589
+ "aria-label": "Overview",
590
+ className: "grid gap-2 text-sm",
591
+ children: [
592
+ /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", {
593
+ className: "flex flex-wrap items-baseline gap-x-5 gap-y-1",
594
+ children: [/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("p", {
595
+ className: "m-0",
596
+ children: [
597
+ plural(view.events, "event"),
598
+ " in ",
599
+ plural(view.sessions, "session"),
600
+ " in the last",
601
+ " ",
602
+ view.days,
603
+ " days for the selected companion."
604
+ ]
605
+ }), /* @__PURE__ */ (0, import_jsx_runtime.jsx)("nav", {
606
+ "aria-label": "Friction sections",
607
+ className: "flex flex-wrap gap-x-4 gap-y-1",
608
+ children: sections.map(([{ id, title }, count]) => count > 0 ? /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("a", {
609
+ href: `#${id}`,
610
+ className: "inline-flex items-center gap-1.5 rounded-control underline",
611
+ children: [title, /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Count, { value: count })]
612
+ }, id) : null)
613
+ })]
614
+ }),
615
+ !empty && shown.hidden > 0 ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)("p", {
616
+ className: "m-0 flex flex-wrap items-center gap-2 text-muted",
617
+ children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Hidden, {
618
+ hidden: shown.hidden,
619
+ onShowAll
620
+ })
621
+ }) : null,
622
+ /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", {
623
+ className: "flex flex-wrap items-center gap-x-3 gap-y-2",
624
+ children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)("p", {
625
+ className: "m-0 text-muted",
626
+ children: "To investigate, run this in your own terminal, inside the affected repository:"
627
+ }), /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", {
628
+ className: "w-48 max-w-full",
629
+ children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(CommandLine, {
630
+ text: `${FRAMEWORK_NAME} triage`,
631
+ label: "command"
632
+ })
633
+ })]
634
+ })
635
+ ]
636
+ });
637
+ }
638
+ function Recording({ recording, toggle, button }) {
639
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", {
640
+ className: "grid gap-1",
641
+ children: [
642
+ /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", {
643
+ className: "flex flex-wrap items-center gap-3",
644
+ children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)(RecordingState, { recording }), /* @__PURE__ */ (0, import_jsx_runtime.jsx)(RecordingButton, {
645
+ ref: button,
646
+ recording,
647
+ toggle
648
+ })]
649
+ }),
650
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(RecordingReach, {}),
651
+ toggle.error ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)("p", {
652
+ className: "m-0 text-sm text-bad",
653
+ role: "alert",
654
+ children: toggle.error
655
+ }) : null
656
+ ]
657
+ });
658
+ }
659
+ function FilterSelect({ label, options, value, onChange, note, disabled }) {
660
+ const id = (0, import_react.useId)();
661
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", {
662
+ className: "flex items-center gap-2",
663
+ children: [
664
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("label", {
665
+ htmlFor: id,
666
+ className: "text-xs text-muted",
667
+ children: label
668
+ }),
669
+ /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(Select, {
670
+ items: options,
671
+ value,
672
+ disabled,
673
+ onValueChange: (next) => {
674
+ if (next !== null) onChange(next);
675
+ },
676
+ children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)(SelectTrigger, {
677
+ id,
678
+ "aria-describedby": note ? `${id}-note` : void 0,
679
+ className: "h-7 w-auto",
680
+ children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(SelectValue, {})
681
+ }), /* @__PURE__ */ (0, import_jsx_runtime.jsx)(SelectContent, { children: options.map((option) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)(SelectItem, {
682
+ value: option.value,
683
+ children: option.label
684
+ }, option.value)) })]
685
+ }),
686
+ note ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", {
687
+ id: `${id}-note`,
688
+ className: "text-xs text-muted",
689
+ children: note
690
+ }) : null
691
+ ]
692
+ });
693
+ }
694
+ function Filters({ view, shown, filters, onFilters }) {
695
+ const types = [{
696
+ value: ANY,
697
+ label: "All types"
698
+ }, ...shown.types.map((type) => ({
699
+ value: type,
700
+ label: type
701
+ }))];
702
+ const noReports = selectFriction(view, {
703
+ ...filters,
704
+ kind: void 0
705
+ }).freeReports.length === 0;
706
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", {
707
+ className: "flex flex-wrap items-center gap-x-5 gap-y-2",
708
+ children: [
709
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(FilterSelect, {
710
+ label: "Type",
711
+ options: types,
712
+ value: shown.type ?? ANY,
713
+ onChange: (type) => onFilters({
714
+ ...filters,
715
+ type: oneOf(SUBJECT_TYPES, type)
716
+ })
717
+ }),
718
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(FilterSelect, {
719
+ label: "Kind",
720
+ options: KINDS,
721
+ value: filters.kind ?? ANY,
722
+ onChange: (kind) => onFilters({
723
+ ...filters,
724
+ kind: oneOf(REPORT_KINDS, kind)
725
+ }),
726
+ note: "Agent reports only",
727
+ disabled: noReports && filters.kind === void 0
728
+ }),
729
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(FilterSelect, {
730
+ label: "Sort",
731
+ options: SORTS,
732
+ value: filters.sort,
733
+ onChange: (sort) => onFilters({
734
+ ...filters,
735
+ sort
736
+ })
737
+ })
738
+ ]
739
+ });
740
+ }
741
+ function Lists({ shown, empty, markItem, onShowAll }) {
742
+ if (empty) return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(EmptyNote, {
743
+ className: "flex flex-wrap items-center gap-x-3 gap-y-2",
744
+ children: ["No item matches the filters. ", /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Hidden, {
745
+ hidden: shown.hidden,
746
+ onShowAll
747
+ })]
748
+ });
749
+ const groupColumns = {
750
+ reports: shown.groups.some((group) => group.reports.length > 0),
751
+ state: shown.groups.some((group) => group.state !== null)
752
+ };
753
+ const reportState = shown.freeReports.some((report) => report.state !== null);
754
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", {
755
+ className: "grid gap-4",
756
+ children: [shown.groups.length > 0 ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(ListCard, {
757
+ ...RECORDED_SECTION,
758
+ count: shown.groups.length,
759
+ className: "wrap-anywhere",
760
+ children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)("ul", {
761
+ className: "@container m-0 list-none p-0",
762
+ style: factsStyle(groupTracks(shown.groups, groupColumns)),
763
+ children: shown.groups.map((group) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)(GroupItem, {
764
+ group,
765
+ columns: groupColumns,
766
+ onMark: markItem(group.fingerprint, group.title)
767
+ }, group.fingerprint))
768
+ })
769
+ }) : null, shown.freeReports.length > 0 ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(ListCard, {
770
+ ...REPORTS_SECTION,
771
+ count: shown.freeReports.length,
772
+ hint: "These reports are not attached to a recorded event.",
773
+ className: "wrap-anywhere",
774
+ children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)("ul", {
775
+ className: "@container m-0 list-none p-0",
776
+ style: factsStyle(reportTracks(reportState)),
777
+ children: shown.freeReports.map((report) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)(FreeReportItem, {
778
+ report,
779
+ stateColumn: reportState,
780
+ onMark: markItem(report.id, report.subject)
781
+ }, report.id))
782
+ })
783
+ }) : null]
784
+ });
785
+ }
786
+ function FrictionPanel({ view, days, onDays, toggle, filters, onFilters, mark, recordingButton }) {
787
+ const recorded = view.events > 0 || view.freeReports.length > 0;
788
+ const shown = selectFriction(view, filters);
789
+ const [marked, setMarked] = (0, import_react.useState)(null);
790
+ const panel = (0, import_react.useRef)(null);
791
+ (0, import_react.useEffect)(() => {
792
+ if (!marked) return;
793
+ const row = (key) => key === null ? null : panel.current?.querySelector(`[data-friction-item="${CSS.escape(key)}"] summary`);
794
+ (row(marked.key) ?? row(marked.next) ?? panel.current?.querySelector("[data-show-all]"))?.focus();
795
+ }, [marked]);
796
+ const markItem = (key, name) => async (state, input) => {
797
+ const order = [...shown.groups.map((group) => group.fingerprint), ...shown.freeReports.map((report) => report.id)];
798
+ const index = order.indexOf(key);
799
+ const next = order[index + 1] ?? order[index - 1] ?? null;
800
+ let result;
801
+ try {
802
+ result = await mark({
803
+ target: key,
804
+ state,
805
+ ...input
806
+ });
807
+ } catch (error) {
808
+ return `The mark could not be saved: ${error instanceof Error ? error.message : String(error)}`;
809
+ }
810
+ if (!result.ok) return result.reason;
811
+ setMarked((last) => ({
812
+ announcementKey: (last?.announcementKey ?? 0) + 1,
813
+ key,
814
+ next,
815
+ message: `${name}: ${state === "open" ? "reopened" : `marked ${state}`}.`
816
+ }));
817
+ return null;
818
+ };
819
+ const showAll = () => {
820
+ [...panel.current?.querySelectorAll("[aria-label=\"State\"] button") ?? []].find((button) => button.textContent === "All")?.focus();
821
+ onFilters({
822
+ state: "all",
823
+ sort: filters.sort
824
+ });
825
+ };
826
+ const empty = shown.groups.length === 0 && shown.freeReports.length === 0;
827
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", {
828
+ ref: panel,
829
+ className: cn(PAGE_PAD, "grid min-w-0 gap-4 pt-3 pb-6"),
830
+ children: [
831
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Recording, {
832
+ recording: view.recording,
833
+ toggle,
834
+ button: recordingButton
835
+ }),
836
+ /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", {
837
+ className: "grid gap-2",
838
+ children: [/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", {
839
+ className: "flex flex-wrap items-center gap-x-5 gap-y-2",
840
+ children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)(Pills, {
841
+ label: "Period",
842
+ options: PERIODS,
843
+ value: String(days),
844
+ onChange: (value) => onDays(Number(value))
845
+ }), recorded ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Pills, {
846
+ label: "State",
847
+ options: STATES,
848
+ value: filters.state,
849
+ onChange: (state) => onFilters({
850
+ ...filters,
851
+ state
852
+ })
853
+ }) : null]
854
+ }), recorded ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Filters, {
855
+ view,
856
+ shown,
857
+ filters,
858
+ onFilters
859
+ }) : null]
860
+ }),
861
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", {
862
+ "aria-live": "polite",
863
+ className: "sr-only",
864
+ children: marked ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)("p", { children: marked.message }, marked.announcementKey) : null
865
+ }),
866
+ recorded ? /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_jsx_runtime.Fragment, { children: [
867
+ view.recording ? null : /* @__PURE__ */ (0, import_jsx_runtime.jsx)("p", {
868
+ className: "m-0 text-sm text-muted",
869
+ children: "Recording is off: nothing new is recorded. The records below were made while it was on."
870
+ }),
871
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Overview, {
872
+ view,
873
+ shown,
874
+ empty,
875
+ onShowAll: showAll
876
+ }),
877
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Lists, {
878
+ shown,
879
+ empty,
880
+ markItem,
881
+ onShowAll: showAll
882
+ })
883
+ ] }) : /* @__PURE__ */ (0, import_jsx_runtime.jsx)(EmptyNote, { children: view.recording ? `No friction was recorded in the last ${view.days} days.` : `Friction recording shows where Mate gets in an agent's way: its refusals and the ${FRAMEWORK_NAME} commands that fail in agent sessions on this machine. Recording is off; turn it on to start.` })
884
+ ]
885
+ });
886
+ }
887
+ function Friction({ companion, days, onDays, filters, onFilters }) {
888
+ const query = useQuery({
889
+ ...frictionQuery(companion, days),
890
+ enabled: useBrowser(),
891
+ placeholderData: keepPreviousData
892
+ });
893
+ const toggle = useSetFrictionRecording();
894
+ const mark = useMarkFriction();
895
+ const { button: recordingButton, retried } = useRetryFocus(query.isSuccess);
896
+ if (!query.data && !query.isError) return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(ViewLoading, { title: "Reading the Friction Log…" });
897
+ const failed = query.isError ? /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", {
898
+ className: cn(PAGE_PAD, "pt-3 text-sm"),
899
+ role: "alert",
900
+ children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)("p", {
901
+ className: "m-0 text-bad",
902
+ children: "The Friction Log could not be read."
903
+ }), /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Button, {
904
+ className: "mt-3",
905
+ onClick: () => {
906
+ retried();
907
+ query.refetch();
908
+ },
909
+ disabled: query.isFetching,
910
+ children: "Retry"
911
+ })]
912
+ }) : null;
913
+ if (!query.data) return failed;
914
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_jsx_runtime.Fragment, { children: [failed, /* @__PURE__ */ (0, import_jsx_runtime.jsx)(FrictionPanel, {
915
+ view: query.data,
916
+ days,
917
+ onDays,
918
+ toggle,
919
+ filters,
920
+ onFilters,
921
+ mark,
922
+ recordingButton
923
+ })] });
924
+ }
925
+ // src/routes/friction.tsx?tsr-split=component
926
+ var SplitComponent = function FrictionRoute() {
927
+ const search = Route.useSearch();
928
+ const navigate = Route.useNavigate();
929
+ return search.companion ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Friction, {
930
+ companion: search.companion,
931
+ days: search.frictionDays ?? 30,
932
+ onDays: (frictionDays) => void navigate({ search: (previous) => ({
933
+ ...previous,
934
+ frictionDays
935
+ }) }),
936
+ filters: filtersFromSearch(search),
937
+ onFilters: (filters) => void navigate({ search: (previous) => ({
938
+ ...previous,
939
+ ...searchFromFilters(filters)
940
+ }) })
941
+ }, search.companion) : null;
942
+ };
943
+ export { SplitComponent as component };