@uniqbit/mate-core 1.0.0-canary.5 → 1.0.0-canary.7

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 (477) hide show
  1. package/claude-capability-plugins/companion-mentions/.claude-plugin/plugin.json +1 -1
  2. package/claude-capability-plugins/companion-mentions/hooks/register.ts +1 -1
  3. package/claude-plugin/hooks/hooks.json +41 -1
  4. package/claude-plugin/hooks/rtk-worktree-git.mjs +58 -0
  5. package/claude-plugin/hooks/workflow-turn.mjs +68 -0
  6. package/opencode-plugin/src/companion.ts +6 -0
  7. package/opencode-plugin/src/server.ts +33 -2
  8. package/package.json +5 -2
  9. package/src/cli/commands/artifact/apply-context.ts +1 -0
  10. package/src/cli/commands/artifact/artifact.ts +16 -0
  11. package/src/cli/commands/artifact/delivery/archive.ts +37 -112
  12. package/src/cli/commands/artifact/delivery/branch-flags.ts +19 -1
  13. package/src/cli/commands/artifact/delivery/environment.ts +32 -72
  14. package/src/cli/commands/artifact/delivery/link.ts +53 -34
  15. package/src/cli/commands/artifact/delivery/output.ts +25 -4
  16. package/src/cli/commands/artifact/delivery/resolve.ts +101 -0
  17. package/src/cli/commands/artifact/delivery/submit.ts +164 -0
  18. package/src/cli/commands/artifact/delivery/take.ts +45 -0
  19. package/src/cli/commands/artifact/extract-repo-name.ts +1 -1
  20. package/src/cli/commands/artifact/finish/command.ts +455 -43
  21. package/src/cli/commands/artifact/finish/engine.ts +79 -61
  22. package/src/cli/commands/artifact/finish/finisher.ts +5 -12
  23. package/src/cli/commands/artifact/finish/git.ts +9 -10
  24. package/src/cli/commands/artifact/finish/openspec.ts +21 -174
  25. package/src/cli/commands/artifact/finish/secret-scan.ts +5 -43
  26. package/src/cli/commands/artifact/finish/worktree-cleanup.ts +57 -7
  27. package/src/cli/commands/artifact/pending/command.ts +119 -6
  28. package/src/cli/commands/artifact/pending/discovery.ts +7 -11
  29. package/src/cli/commands/artifact/project/command.ts +60 -0
  30. package/src/cli/commands/companion/list.ts +70 -14
  31. package/src/cli/commands/companion/sync.ts +18 -0
  32. package/src/cli/commands/companion/update.ts +4 -19
  33. package/src/cli/commands/doctor.ts +51 -0
  34. package/src/cli/commands/friction.ts +558 -0
  35. package/src/cli/commands/install.ts +48 -36
  36. package/src/cli/commands/launch/claude.ts +2 -0
  37. package/src/cli/commands/launch/shared.ts +33 -6
  38. package/src/cli/commands/plugin/install.ts +27 -11
  39. package/src/cli/commands/report/index.ts +180 -184
  40. package/src/cli/commands/report/markdown.ts +67 -72
  41. package/src/cli/commands/shared/companion-selection.ts +3 -1
  42. package/src/cli/commands/studio/access.ts +6 -14
  43. package/src/cli/commands/studio/areas.ts +112 -33
  44. package/src/cli/commands/studio/companion-add.ts +72 -0
  45. package/src/cli/commands/studio/companion-removal.ts +15 -8
  46. package/src/cli/commands/studio/connection.ts +53 -0
  47. package/src/cli/commands/studio/graph-model.ts +61 -0
  48. package/src/cli/commands/studio/graph.ts +336 -0
  49. package/src/cli/commands/studio/index.ts +4 -4
  50. package/src/{lib/factory/outcomes/sessions.ts → cli/commands/studio/live-sessions.ts} +26 -2
  51. package/src/cli/commands/studio/payload.ts +214 -32
  52. package/src/cli/commands/studio/reports.ts +19 -18
  53. package/src/cli/commands/studio/routes.ts +8 -18
  54. package/src/cli/commands/studio/selection.ts +21 -5
  55. package/src/cli/commands/studio/server.ts +322 -191
  56. package/src/cli/commands/studio/service-host.ts +266 -0
  57. package/src/cli/commands/studio/services.ts +59 -16
  58. package/src/cli/commands/studio/studio-app.ts +1 -0
  59. package/src/cli/commands/studio/terminal.ts +45 -3
  60. package/src/cli/commands/studio/vault.ts +41 -40
  61. package/src/cli/commands/studio/views/model.ts +1 -9
  62. package/src/cli/commands/studio/views/vault/markdown-tree.ts +90 -8
  63. package/src/cli/commands/triage.ts +151 -0
  64. package/src/cli/commands/unwrap.ts +3 -0
  65. package/src/cli/commands/update.ts +2 -0
  66. package/src/cli/commands/vscode/release-vsix.json +4 -0
  67. package/src/cli/commands/vscode/setup.ts +71 -13
  68. package/src/cli/commands/vscode/vsix.ts +48 -7
  69. package/src/cli/commands/workflow/workflow.ts +516 -0
  70. package/src/cli/commands/working/cleanup.ts +40 -8
  71. package/src/cli/commands/working/worktree.ts +176 -35
  72. package/src/cli/main.ts +61 -10
  73. package/src/cli/plugin-commands.ts +6 -1
  74. package/src/cli/repo-list-table.tsx +73 -37
  75. package/src/cli/usage.ts +29 -8
  76. package/src/create-mate.ts +11 -5
  77. package/src/distribution.ts +2 -0
  78. package/src/factory-host.ts +69 -0
  79. package/src/hooks/companion-instructions.ts +19 -8
  80. package/src/hooks/hook-io.ts +3 -1
  81. package/src/hooks/rtk-worktree-git.ts +48 -0
  82. package/src/hooks/session-banner.ts +25 -0
  83. package/src/hooks/validate-artifact-path.ts +108 -26
  84. package/src/hooks/workflow-turn.ts +219 -0
  85. package/src/lib/apply-context/fingerprint.ts +2 -1
  86. package/src/lib/apply-context/protocol.ts +2 -2
  87. package/src/lib/artifact-trailer.ts +27 -0
  88. package/src/lib/change-layout.ts +83 -38
  89. package/src/lib/delivery/branch-template.ts +114 -0
  90. package/src/lib/delivery/branches.ts +21 -16
  91. package/src/lib/delivery/checkout.ts +103 -0
  92. package/src/lib/delivery/environment.ts +131 -7
  93. package/src/lib/delivery/merge-git.ts +282 -26
  94. package/src/lib/delivery/overlap.ts +68 -16
  95. package/src/lib/delivery/record-delivery.ts +178 -37
  96. package/src/lib/delivery/record.ts +201 -27
  97. package/src/lib/delivery/refresh.ts +212 -151
  98. package/src/lib/delivery/remote.ts +66 -0
  99. package/src/lib/delivery/repository-access.ts +19 -60
  100. package/src/lib/delivery/resolve-branch.ts +157 -110
  101. package/src/lib/delivery/stages.ts +83 -50
  102. package/src/lib/delivery/staging/apply-chain.ts +164 -0
  103. package/src/lib/delivery/staging/artifact-type.ts +101 -0
  104. package/src/lib/delivery/staging/declared-type.ts +277 -0
  105. package/src/lib/delivery/staging/naming.ts +64 -0
  106. package/src/lib/delivery/staging/openspec-type.ts +135 -0
  107. package/src/lib/delivery/staging/pending-edit.ts +291 -0
  108. package/src/lib/delivery/staging/pending.ts +780 -0
  109. package/src/lib/delivery/staging/project.ts +373 -0
  110. package/src/lib/delivery/staging/publish.ts +1024 -0
  111. package/src/lib/delivery/staging/refs.ts +258 -0
  112. package/src/lib/delivery/staging/registry.ts +73 -0
  113. package/src/lib/delivery/staging/replay.ts +308 -0
  114. package/src/lib/delivery/staging/requirement-blocks.ts +10 -0
  115. package/src/lib/delivery/staging/resolve.ts +264 -0
  116. package/src/lib/delivery/staging/settle-linked.ts +290 -0
  117. package/src/lib/delivery/staging/submit.ts +929 -0
  118. package/src/lib/delivery/staging/worktree.ts +130 -0
  119. package/src/lib/delivery/submit-change.ts +443 -0
  120. package/src/lib/friction/describe.ts +42 -0
  121. package/src/lib/friction/fields.ts +60 -0
  122. package/src/lib/friction/mark.ts +156 -0
  123. package/src/lib/friction/view/model.ts +67 -0
  124. package/src/lib/friction/view/read.ts +136 -0
  125. package/src/lib/friction/view/select.ts +54 -0
  126. package/src/lib/git-key.ts +15 -0
  127. package/src/lib/install.ts +2 -0
  128. package/src/lib/openspec-canonical-frontmatter.ts +159 -0
  129. package/src/lib/orchestrator/adapters/base.ts +31 -20
  130. package/src/lib/orchestrator/adapters/claude.ts +21 -7
  131. package/src/lib/orchestrator/adapters/opencode.ts +4 -0
  132. package/src/lib/orchestrator/companion-git-sync.ts +152 -16
  133. package/src/lib/orchestrator/companion-hub.ts +6 -1
  134. package/src/lib/orchestrator/engine-floor.ts +48 -0
  135. package/src/lib/orchestrator/framework-context.ts +15 -1
  136. package/src/lib/orchestrator/launcher.ts +34 -1
  137. package/src/lib/orchestrator/projection-claude-commands.ts +2 -2
  138. package/src/lib/orchestrator/projection-claude-entry.ts +42 -21
  139. package/src/lib/orchestrator/projection-claude-links.ts +33 -8
  140. package/src/lib/orchestrator/projection-claude-skills.ts +2 -2
  141. package/src/lib/orchestrator/projection-entries.ts +22 -18
  142. package/src/lib/orchestrator/projection-opencode-copies.ts +65 -21
  143. package/src/lib/orchestrator/projection-runtime-documents.ts +66 -43
  144. package/src/lib/orchestrator/projection-types.ts +28 -1
  145. package/src/lib/orchestrator/refresh-working-claude-links.ts +4 -1
  146. package/src/lib/orchestrator/root-context.ts +23 -6
  147. package/src/lib/orchestrator/session-prepare.ts +17 -2
  148. package/src/lib/orchestrator/setup-compatibilities.ts +1 -1
  149. package/src/lib/orchestrator/types.ts +4 -0
  150. package/src/lib/orchestrator/umbrella-checkouts.ts +102 -0
  151. package/src/lib/orchestrator/working-repo-projection.ts +24 -4
  152. package/src/lib/orchestrator/wrap-pass.ts +1 -0
  153. package/src/lib/package-paths.ts +23 -15
  154. package/src/lib/prebuilt-workspace-prepare.ts +2 -1
  155. package/src/lib/prebuilt-workspace.ts +1 -0
  156. package/src/lib/public-npm.ts +95 -50
  157. package/src/lib/session-attribution.ts +3 -7
  158. package/src/lib/session-state.ts +74 -3
  159. package/src/lib/triage/context.ts +186 -0
  160. package/src/lib/triage/launch.ts +52 -0
  161. package/src/lib/triage/prepare.ts +97 -0
  162. package/src/lib/triage/session.ts +126 -0
  163. package/src/lib/update-checker.ts +7 -1
  164. package/src/lib/usage/aggregate.ts +202 -0
  165. package/src/lib/usage/cache.ts +87 -0
  166. package/src/lib/usage/claude-pricing.ts +71 -0
  167. package/src/lib/usage/claude.ts +189 -0
  168. package/src/lib/usage/collect.ts +56 -0
  169. package/src/lib/usage/opencode.ts +188 -0
  170. package/src/lib/usage/records.ts +80 -0
  171. package/src/lib/usage/rtk-database.ts +72 -0
  172. package/src/lib/usage/savings.ts +209 -0
  173. package/src/lib/usage/scope.ts +182 -0
  174. package/src/lib/usage/source.ts +102 -0
  175. package/src/lib/usage/types.ts +143 -0
  176. package/src/lib/usage/window.ts +37 -0
  177. package/src/lib/workflow/declaration.ts +6 -0
  178. package/src/lib/workflow/handoff.ts +90 -0
  179. package/src/lib/workflow/hook-trust.ts +108 -0
  180. package/src/lib/workflow/position.ts +524 -0
  181. package/src/lib/workflow/report.ts +79 -0
  182. package/src/lib/workflow/work.ts +106 -0
  183. package/src/lib/workset/factory-local.ts +157 -0
  184. package/src/lib/workset/record.ts +25 -11
  185. package/src/lib/workset/repositories.ts +118 -25
  186. package/src/lib/workset/stage.ts +4 -2
  187. package/src/lib/workset/stages.ts +64 -4
  188. package/src/lib/workset/worktree-include.ts +161 -0
  189. package/src/lib/workset/worktree-index.ts +6 -2
  190. package/src/lib/workset/worktree.ts +622 -114
  191. package/src/opencode/companion-hooks.ts +105 -18
  192. package/src/opencode/companion-policy.ts +18 -5
  193. package/src/opencode/enter-worktree.ts +254 -6
  194. package/src/opencode/projected-guidance.ts +7 -2
  195. package/src/opencode/session-register.ts +2 -2
  196. package/src/opencode/turn-hook.ts +241 -0
  197. package/src/playbooks/companion-guidance.ts +7 -4
  198. package/src/plugin-api.ts +47 -0
  199. package/src/runtime/artifact-trailers.ts +63 -0
  200. package/src/runtime/claude-bg-isolation.ts +138 -0
  201. package/src/runtime/claude-hook-group.ts +2 -0
  202. package/src/runtime/command-friction.ts +97 -0
  203. package/src/runtime/companion-git-state.ts +155 -10
  204. package/src/runtime/companion-git.ts +96 -13
  205. package/src/runtime/companion-guidance.ts +136 -20
  206. package/src/runtime/companion-instructions.ts +1 -1
  207. package/src/runtime/companion-sync.ts +109 -21
  208. package/src/runtime/current-branch.ts +16 -2
  209. package/src/runtime/entered-worktree.ts +24 -0
  210. package/src/runtime/env-names.ts +2 -2
  211. package/src/runtime/env.ts +7 -6
  212. package/src/runtime/forge-remote.ts +48 -0
  213. package/src/runtime/friction-fingerprint.ts +35 -0
  214. package/src/runtime/friction-log.ts +352 -0
  215. package/src/runtime/friction-recorder.ts +199 -0
  216. package/src/runtime/friction-retention.ts +1 -0
  217. package/src/runtime/friction-state.ts +110 -0
  218. package/src/runtime/friction-switch.ts +26 -0
  219. package/src/runtime/friction-vocabulary.ts +42 -0
  220. package/src/runtime/git-layout.ts +21 -7
  221. package/src/runtime/git-tracked.ts +60 -0
  222. package/src/runtime/json-fields.ts +8 -0
  223. package/src/runtime/pending-records.ts +533 -0
  224. package/src/runtime/projected-guidance.ts +8 -3
  225. package/src/runtime/publication-secret-scan.ts +45 -0
  226. package/src/runtime/repo-destination.ts +72 -0
  227. package/src/runtime/repo-local.ts +25 -3
  228. package/src/runtime/rtk-git-guard.ts +66 -0
  229. package/src/runtime/runtime-document-manifest.ts +229 -19
  230. package/src/runtime/runtime-document-manifest.typecheck.ts +10 -0
  231. package/src/runtime/secret-guard.ts +9 -2
  232. package/src/runtime/secret-patterns.ts +3 -2
  233. package/src/runtime/secret-policy-weakening.ts +122 -0
  234. package/src/runtime/secret-values.ts +16 -0
  235. package/src/runtime/serving-claude-wrap.ts +15 -2
  236. package/src/runtime/session-id.ts +24 -0
  237. package/src/runtime/session-prepare-runner.ts +3 -0
  238. package/src/runtime/skill-prefix.ts +75 -0
  239. package/src/runtime/submitted-arrivals.ts +547 -0
  240. package/src/runtime/turn-state.d.mts +14 -0
  241. package/src/runtime/turn-state.mjs +93 -0
  242. package/src/runtime/umbrella-children.ts +52 -0
  243. package/src/runtime/umbrella-folder.ts +84 -0
  244. package/src/runtime/workflow/change-folders.ts +66 -0
  245. package/src/runtime/workflow/declaration.ts +720 -0
  246. package/src/runtime/workflow/globs.ts +85 -0
  247. package/src/runtime/workflow/next-handoff-process.ts +99 -0
  248. package/src/runtime/workflow/turn.ts +309 -0
  249. package/src/runtime/workflow/workflow.ts +262 -0
  250. package/src/runtime/wrap-state.ts +5 -13
  251. package/src/studio.ts +112 -19
  252. package/src/templates/capabilities/openspec-cap/{mate-v1 → mate-full}/schema.yaml +3 -3
  253. package/src/templates/capabilities/openspec-cap/{mate-v1 → mate-full}/templates/design.md +1 -1
  254. package/src/templates/capabilities/openspec-cap/{mate-v1 → mate-full}/templates/proposal.md +1 -1
  255. package/src/templates/capabilities/openspec-cap/{mate-v1 → mate-full}/templates/tasks.md +1 -1
  256. package/src/templates/capabilities/openspec-cap/mate-minimal/schema.yaml +3 -3
  257. package/src/templates/mate-skills/agents/mate-apply-change/SKILL.md +103 -30
  258. package/src/templates/mate-skills/agents/mate-apply-change/references/openspec-apply-change.md +1 -1
  259. package/src/templates/mate-skills/agents/mate-archive-change/SKILL.md +7 -70
  260. package/src/templates/mate-skills/agents/mate-clarify-intent/SKILL.md +13 -7
  261. package/src/templates/mate-skills/agents/mate-domain-modeling/SKILL.md +10 -0
  262. package/src/templates/mate-skills/agents/mate-explore-change/SKILL.md +46 -14
  263. package/src/templates/mate-skills/agents/mate-propose-change/SKILL.md +50 -31
  264. package/src/templates/mate-skills/agents/mate-propose-change/references/mate-revise.md +13 -7
  265. package/src/templates/mate-skills/agents/mate-propose-change/references/openspec-update-change.md +1 -1
  266. package/src/templates/mate-skills/agents/mate-publish-artifact/SKILL.md +114 -86
  267. package/src/templates/mate-skills/agents/mate-publish-artifact/references/openspec.md +111 -100
  268. package/src/templates/mate-skills/agents/mate-show-me/SKILL.md +11 -5
  269. package/src/templates/mate-skills/agents/mate-simplify-code/SKILL.md +16 -6
  270. package/src/templates/mate-skills/agents/mate-submit-change/SKILL.md +114 -0
  271. package/src/templates/mate-skills/claude/mate-apply-change/SKILL.md +103 -30
  272. package/src/templates/mate-skills/claude/mate-apply-change/references/openspec-apply-change.md +1 -1
  273. package/src/templates/mate-skills/claude/mate-archive-change/SKILL.md +7 -70
  274. package/src/templates/mate-skills/claude/mate-clarify-intent/SKILL.md +13 -7
  275. package/src/templates/mate-skills/claude/mate-domain-modeling/SKILL.md +10 -0
  276. package/src/templates/mate-skills/claude/mate-explore-change/SKILL.md +46 -14
  277. package/src/templates/mate-skills/claude/mate-propose-change/SKILL.md +50 -31
  278. package/src/templates/mate-skills/claude/mate-propose-change/references/mate-revise.md +13 -7
  279. package/src/templates/mate-skills/claude/mate-propose-change/references/openspec-update-change.md +1 -1
  280. package/src/templates/mate-skills/claude/mate-publish-artifact/SKILL.md +114 -86
  281. package/src/templates/mate-skills/claude/mate-publish-artifact/references/openspec.md +111 -100
  282. package/src/templates/mate-skills/claude/mate-show-me/SKILL.md +11 -5
  283. package/src/templates/mate-skills/claude/mate-simplify-code/SKILL.md +16 -6
  284. package/src/templates/mate-skills/claude/mate-submit-change/SKILL.md +114 -0
  285. package/src/templates/mate-skills/openspec-references.ts +3 -2
  286. package/src/templates/triage/PLAYBOOK.md +112 -0
  287. package/src/tools/setup/__snapshots__/runtime-surface-golden.test.ts.snap +912 -139
  288. package/src/tools/setup/capabilities/openspec.ts +54 -15
  289. package/src/tools/setup/capabilities/rtk.ts +113 -9
  290. package/src/tools/setup/capabilities/tokensave.ts +3 -2
  291. package/src/tools/setup/dynamic-plugins/api.ts +38 -0
  292. package/src/tools/setup/dynamic-plugins/audiences.ts +65 -21
  293. package/src/tools/setup/dynamic-plugins/frozen.ts +32 -13
  294. package/src/tools/setup/dynamic-plugins/host.ts +2 -32
  295. package/src/tools/setup/dynamic-plugins/hydrate.ts +4 -4
  296. package/src/tools/setup/dynamic-plugins/install.ts +24 -22
  297. package/src/tools/setup/dynamic-plugins/loader.ts +11 -7
  298. package/src/tools/setup/dynamic-plugins/paths.ts +30 -10
  299. package/src/tools/setup/dynamic-plugins/verify.ts +10 -7
  300. package/src/tools/setup/dynamic-plugins/workspaces.ts +153 -0
  301. package/src/tools/setup/engine.ts +20 -1
  302. package/src/tools/setup/mate.ts +5 -3
  303. package/src/tools/setup/package-managers/bun.ts +8 -8
  304. package/src/tools/setup/plugin.ts +14 -1
  305. package/src/tools/setup/plugins/gitignore.ts +15 -9
  306. package/src/tools/setup/plugins/guidance.ts +4 -2
  307. package/src/tools/setup/providers/claude-plugin-hooks.ts +30 -0
  308. package/src/tools/setup/providers/claude.ts +43 -6
  309. package/src/tools/setup/service-registry.ts +69 -0
  310. package/src/tools/setup/service.ts +237 -0
  311. package/src/tools/setup/utils.ts +28 -5
  312. package/src/tools/setup/working-repo-cleanup.ts +2 -2
  313. package/src/tools/setup/working-repo-local-state.ts +2 -0
  314. package/src/tools/setup.ts +41 -16
  315. package/studio-dist/client/assets/app-aIwDxf48.css +2 -0
  316. package/studio-dist/client/assets/button-CX0sWAJl.js +1 -0
  317. package/studio-dist/client/assets/combobox-BmA8RjOc.js +1 -0
  318. package/studio-dist/client/assets/companion-view-DINdPF-b.js +1 -0
  319. package/studio-dist/client/assets/fields-BobQ7zRF.js +1 -0
  320. package/studio-dist/client/assets/friction-YdYd3zaz.js +1 -0
  321. package/studio-dist/client/assets/getting-started-CY7NEtTw.js +1 -0
  322. package/studio-dist/client/assets/getting-started-djaQeWlu.js +1 -0
  323. package/studio-dist/client/assets/getting-started._topic-DVB8e5R9.js +1 -0
  324. package/studio-dist/client/assets/getting-started.index-DQvLHEr1.js +1 -0
  325. package/studio-dist/client/assets/graph-DbNnR884.js +2 -0
  326. package/studio-dist/client/assets/graph-canvas-DIcAqwtK.js +3242 -0
  327. package/studio-dist/client/assets/guides-D6T6W_jV.js +1 -0
  328. package/studio-dist/client/assets/index-CysBCSxM.js +40 -0
  329. package/studio-dist/client/assets/jsx-runtime-MZURdZre.js +1 -0
  330. package/studio-dist/client/assets/markdown-view-jMiaBTSO.js +1 -0
  331. package/studio-dist/client/assets/panel-Csr49lBo.js +1 -0
  332. package/studio-dist/client/assets/plugins._service._view-CEA_CcPe.js +1 -0
  333. package/studio-dist/client/assets/{prepaint-CwSrpdFA.js → prepaint-CKsXyJOR.js} +3 -3
  334. package/studio-dist/client/assets/queries-Dfp5deWj.js +1 -0
  335. package/studio-dist/client/assets/react-BYUSgtBs.js +1 -0
  336. package/studio-dist/client/assets/reports-CLdgxxkg.js +1 -0
  337. package/studio-dist/client/assets/routes-DGilWbDE.js +1 -0
  338. package/studio-dist/client/assets/search-CXosfvYh.js +1 -0
  339. package/studio-dist/client/assets/select-DdebbX7K.js +1 -0
  340. package/studio-dist/client/assets/skills-C3zNkU8g.js +1 -0
  341. package/studio-dist/client/assets/specs-Dl8HfGlU.js +1 -0
  342. package/studio-dist/client/assets/specs-view-B_n0Pekv.js +1 -0
  343. package/studio-dist/client/assets/steps-CKUno4lh.js +1 -0
  344. package/studio-dist/client/assets/store-DyXbi6o9.js +1 -0
  345. package/studio-dist/client/assets/studio-0ueISxwP.js +100 -0
  346. package/studio-dist/client/assets/studio-queries-BflKt9va.js +2 -0
  347. package/studio-dist/client/assets/usage-Blcl8kA_.js +55 -0
  348. package/studio-dist/client/assets/useAnchoredPopupScrollLock-BBXJpX5L.js +1 -0
  349. package/studio-dist/client/assets/useBaseQuery-C2cjmeH2.js +1 -0
  350. package/studio-dist/client/assets/useMutation-DI6LbvVa.js +1 -0
  351. package/studio-dist/client/assets/useSelector-AYcH7lB0.js +2 -0
  352. package/studio-dist/client/assets/vault-Cb9DmM1i.js +1 -0
  353. package/studio-dist/client/assets/warnings-B-rvoW8q.js +1 -0
  354. package/studio-dist/client/assets/workflow-DN5T19jd.js +1 -0
  355. package/studio-dist/server/assets/__23tanstack-start-server-fn-resolver-JoHQ5ihx.js +122 -0
  356. package/studio-dist/server/assets/_tanstack-start-manifest_v.js +100 -39
  357. package/studio-dist/server/assets/{button-CIJqAhni.js → button-B7e1fRyW.js} +63 -3574
  358. package/studio-dist/server/assets/combobox--S_OmUfh.js +483 -0
  359. package/studio-dist/server/assets/{companion-view-DISASvdJ.js → companion-view-D-vGM55e.js} +3 -3
  360. package/studio-dist/server/assets/companions-Dr6IpNAb.js +31 -0
  361. package/studio-dist/server/assets/{createServerRpc-tK2lE9R2.js → createServerRpc-bFKFpGFG.js} +1 -1
  362. package/studio-dist/server/assets/fields-B4qM2ZwC.js +1190 -0
  363. package/studio-dist/server/assets/friction-CWOTjpCV.js +62 -0
  364. package/studio-dist/server/assets/friction-sLxaWY-H.js +903 -0
  365. package/studio-dist/server/assets/getting-started-B136TP57.js +4 -0
  366. package/studio-dist/server/assets/getting-started-Cq5Pcnsr.js +67 -0
  367. package/studio-dist/server/assets/getting-started._topic-CmWdl3u3.js +13 -0
  368. package/studio-dist/server/assets/getting-started.index-AB8xpTFY.js +13 -0
  369. package/studio-dist/server/assets/graph-B11ITte0.js +16 -0
  370. package/studio-dist/server/assets/graph-C_Hn-Wf_.js +800 -0
  371. package/studio-dist/server/assets/graph-canvas-BthrSmPS.js +21066 -0
  372. package/studio-dist/server/assets/graph-wire-BdSUx0G5.js +58 -0
  373. package/studio-dist/server/assets/guides-B8HdeK_C.js +13 -0
  374. package/studio-dist/server/assets/guides-BVQ4pt5B.js +5 -0
  375. package/studio-dist/server/assets/guides.server-DqFQAStf.js +66 -0
  376. package/studio-dist/server/assets/jsx-runtime-Bt0s0YKS.js +451 -0
  377. package/studio-dist/server/assets/{markdown-view-Bn7xPdks.js → markdown-view-rwiiVcPC.js} +28 -9
  378. package/studio-dist/server/assets/{panel-3Jmn4awF.js → panel-CUxRIpYL.js} +5 -5
  379. package/studio-dist/server/assets/plugins._service._view-BSvGnlhU.js +94 -0
  380. package/studio-dist/server/assets/{prepaint-DJfTQ_VH.js → prepaint-B28ClcPN.js} +1 -1
  381. package/studio-dist/server/assets/queries-S_Pl90IG.js +32 -0
  382. package/studio-dist/server/assets/{react-Ce6dj15C.js → react-CiBZPDs8.js} +3 -4
  383. package/studio-dist/server/assets/redirect-BaZ_QyqF.js +39 -0
  384. package/studio-dist/server/assets/{reports-C06RXVE2.js → reports-B9k98oE6.js} +3 -3
  385. package/studio-dist/server/assets/{reports-D6YMqhnO.js → reports-CJpAItPk.js} +14 -10
  386. package/studio-dist/server/assets/{router-C8MGqlAY.js → router-DF0etoNa.js} +1322 -3127
  387. package/studio-dist/server/assets/{routes-BcFgvqf7.js → routes-6ylCLkyg.js} +221 -76
  388. package/studio-dist/server/assets/search-b-yQesv3.js +78 -0
  389. package/studio-dist/server/assets/select-CjuKScan.js +1609 -0
  390. package/studio-dist/server/assets/{shell-DS3wUexh.js → shell-DLkP7wG9.js} +15 -6
  391. package/studio-dist/server/assets/{skills-CtrBAtX3.js → skills-DGg0mWDM.js} +3 -3
  392. package/studio-dist/server/assets/{skills-BEnOxiDl.js → skills-zeU80A9S.js} +8 -8
  393. package/studio-dist/server/assets/specs-DDBNT_v1.js +51 -0
  394. package/studio-dist/server/assets/specs-view-exvmWdg0.js +425 -0
  395. package/studio-dist/server/assets/{steps-Dq_CwY_s.js → steps-D1tYAyWZ.js} +88 -45
  396. package/studio-dist/server/assets/store-kS7zk0Hr.js +93 -0
  397. package/studio-dist/server/assets/studio-qRvQjRpz.js +10482 -0
  398. package/studio-dist/server/assets/studio-queries-qOXOYoPt.js +1393 -0
  399. package/studio-dist/server/assets/usage-C2um7YiV.js +25553 -0
  400. package/studio-dist/server/assets/usage-Cwle9-xY.js +24 -0
  401. package/studio-dist/server/assets/useAnchoredPopupScrollLock-kQBB3y_b.js +756 -0
  402. package/studio-dist/server/assets/useBaseQuery--iH3rd-T.js +2051 -0
  403. package/studio-dist/server/assets/useMutation-C-WO6hCM.js +690 -0
  404. package/studio-dist/server/assets/{__23tanstack-start-server-fn-resolver-M2GBs8s3.js → useSelector-DUmCUXAs.js} +4 -668
  405. package/studio-dist/server/assets/{vault-Fvxt2Tzl.js → vault-B8vgVIH9.js} +10 -7
  406. package/studio-dist/server/assets/{vault-BmWnryh3.js → vault-CEBBRLMb.js} +3 -3
  407. package/studio-dist/server/assets/{views-BgYa-za2.js → views-UgO0Qz_g.js} +9 -6
  408. package/studio-dist/server/assets/{warnings-DzR6fyZh.js → warnings-BxK4VfV5.js} +2 -2
  409. package/studio-dist/server/assets/{delivery-path-C29fBynY.js → workflow-BrTK632u.js} +152 -120
  410. package/studio-dist/server/server.js +582 -8
  411. package/src/cli/commands/factory/factory.ts +0 -301
  412. package/src/cli/commands/report/collector.ts +0 -288
  413. package/src/cli/commands/studio/factory-credential.ts +0 -49
  414. package/src/cli/commands/studio/workset-session.ts +0 -131
  415. package/src/lib/delivery/archive-change.ts +0 -165
  416. package/src/lib/delivery/forge.ts +0 -279
  417. package/src/lib/delivery/token.ts +0 -24
  418. package/src/lib/factory/attach-client.ts +0 -113
  419. package/src/lib/factory/attach.ts +0 -178
  420. package/src/lib/factory/broker.ts +0 -190
  421. package/src/lib/factory/bun-commands.ts +0 -39
  422. package/src/lib/factory/client.ts +0 -92
  423. package/src/lib/factory/command.ts +0 -61
  424. package/src/lib/factory/credential-store.ts +0 -153
  425. package/src/lib/factory/frames.ts +0 -77
  426. package/src/lib/factory/ids.ts +0 -58
  427. package/src/lib/factory/outcomes/actions.ts +0 -114
  428. package/src/lib/factory/outcomes/index.ts +0 -391
  429. package/src/lib/factory/outcomes/lifecycle.ts +0 -205
  430. package/src/lib/factory/outcomes/runs.ts +0 -81
  431. package/src/lib/factory/prepare.ts +0 -49
  432. package/src/lib/factory/pty.ts +0 -103
  433. package/src/lib/factory/runner/companion-context.ts +0 -178
  434. package/src/lib/factory/runner/control.ts +0 -92
  435. package/src/lib/factory/runner/harness-agent.ts +0 -250
  436. package/src/lib/factory/runner/live.ts +0 -159
  437. package/src/lib/factory/runner/questions.ts +0 -22
  438. package/src/lib/factory/runner/rank.ts +0 -26
  439. package/src/lib/factory/runner/run-policy.ts +0 -12
  440. package/src/lib/factory/runner/run.ts +0 -199
  441. package/src/lib/factory/runner/scheduler.ts +0 -416
  442. package/src/lib/factory/runner/state.ts +0 -233
  443. package/src/lib/factory/runner/workflow.ts +0 -542
  444. package/src/lib/factory/runtime.ts +0 -981
  445. package/src/lib/factory/sandbox.ts +0 -292
  446. package/src/lib/factory/worktree-branch.ts +0 -17
  447. package/src/templates/capabilities/openspec-cap/mate-v1/templates/explore-brief.md +0 -25
  448. package/studio-dist/client/assets/app-CdPiFv59.css +0 -2
  449. package/studio-dist/client/assets/button-BIIHE0EQ.js +0 -3
  450. package/studio-dist/client/assets/companion-view-DM6YyXaR.js +0 -1
  451. package/studio-dist/client/assets/delivery-path-DELxj0Av.js +0 -1
  452. package/studio-dist/client/assets/factory-BZy0E8ty.js +0 -4
  453. package/studio-dist/client/assets/index-B3wkMzjA.js +0 -40
  454. package/studio-dist/client/assets/markdown-view-pQ2Qp_i5.js +0 -1
  455. package/studio-dist/client/assets/panel-CbajlC3p.js +0 -1
  456. package/studio-dist/client/assets/react-CN2GSx7x.js +0 -1
  457. package/studio-dist/client/assets/reports-DllhYQ5_.js +0 -1
  458. package/studio-dist/client/assets/rolldown-runtime-WkwZ5CU-.js +0 -1
  459. package/studio-dist/client/assets/routes-COm-G3mK.js +0 -1
  460. package/studio-dist/client/assets/skills-DmWAy-jZ.js +0 -1
  461. package/studio-dist/client/assets/specs-BG3Wi3ln.js +0 -1
  462. package/studio-dist/client/assets/steps-DFsH3Neu.js +0 -1
  463. package/studio-dist/client/assets/vault-B2q1nBY5.js +0 -1
  464. package/studio-dist/client/assets/warnings-BSXIyuSQ.js +0 -1
  465. package/studio-dist/client/assets/workflow-DlsQD6Hc.js +0 -1
  466. package/studio-dist/server/assets/actions-Bvgj9eb8.js +0 -54
  467. package/studio-dist/server/assets/companions-BYbHWKOZ.js +0 -15
  468. package/studio-dist/server/assets/createServerFn-F5sAOF8V.js +0 -459
  469. package/studio-dist/server/assets/factory-DGPmNGbo.js +0 -69
  470. package/studio-dist/server/assets/factory-DUTa0eDs.js +0 -2172
  471. package/studio-dist/server/assets/rolldown-runtime-DYf_mQCB.js +0 -34
  472. package/studio-dist/server/assets/search-JAKurDNh.js +0 -36
  473. package/studio-dist/server/assets/specs-C8rv34-5.js +0 -211
  474. package/studio-dist/server/assets/studio-BeltxxKt.js +0 -216
  475. package/studio-dist/server/assets/workflow-liRYecHk.js +0 -73
  476. /package/src/lib/{factory/keyed-serial.ts → keyed-serial.ts} +0 -0
  477. /package/src/templates/capabilities/openspec-cap/{mate-v1 → mate-full}/templates/spec.md +0 -0
@@ -0,0 +1,903 @@
1
+ import { S as useRetryFocus, _ as useMarkFriction, b as RecordingReach, f as Route, g as frictionQuery, h as useBrowser, v as useSetFrictionRecording, x as RecordingState, y as RecordingButton } from "./router-DF0etoNa.js";
2
+ import { B as keepPreviousData } from "./studio-queries-qOXOYoPt.js";
3
+ import { Lr as cn, 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, zr as useQuery } from "./button-B7e1fRyW.js";
4
+ import { _ as REPORT_KINDS, h as FRICTION_STATES, m as selectFriction$1, y as SUBJECT_TYPES } from "./studio-qRvQjRpz.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-CjuKScan.js";
7
+ import { a as FRICTION_VIEW_DAYS, n as oneOf } from "./search-b-yQesv3.js";
8
+ import { t as Input } from "./fields-B4qM2ZwC.js";
9
+ // ../mate-core/src/runtime/framework.ts
10
+ /**
11
+ * Framework identity: names everything identity-shaped — state directories
12
+ * (`~/.mate`, `.mate/`), managed-block markers, `MATE_*` env values, usage
13
+ * output, command hints, error prefixes, agent guidance, and permission
14
+ * entries. The distribution is always invoked as `mate`.
15
+ *
16
+ * Lives under `runtime/` because the import-isolated runtime subpath derives
17
+ * repo-local `.mate/` paths from it; `../framework` re-exports it.
18
+ */
19
+ var FRAMEWORK_NAME = "mate";
20
+ // src/views/friction/mark-actions.tsx
21
+ var import_react = /* @__PURE__ */ __toESM(require_react(), 1);
22
+ var import_jsx_runtime = require_jsx_runtime();
23
+ var STATE_WORDS = {
24
+ fixed: {
25
+ label: "Fixed",
26
+ marker: "done"
27
+ },
28
+ reported: {
29
+ label: "Reported",
30
+ marker: "review"
31
+ },
32
+ dismissed: {
33
+ label: "Dismissed",
34
+ marker: "idle"
35
+ }
36
+ };
37
+ var BY = {
38
+ person: "by a person",
39
+ triage: "by triage",
40
+ studio: "in Studio"
41
+ };
42
+ var plural = (count, noun) => `${count} ${noun}${count === 1 ? "" : "s"}`;
43
+ /** The item's Friction State as one word with its marker; nothing for an unmarked item. */
44
+ function StateWord({ state }) {
45
+ if (!state) return null;
46
+ const word = STATE_WORDS[state.state];
47
+ return state.reopened ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(StatusWord, {
48
+ marker: "warn",
49
+ children: "Reopened"
50
+ }) : /* @__PURE__ */ (0, import_jsx_runtime.jsx)(StatusWord, {
51
+ marker: word.marker,
52
+ children: word.label
53
+ });
54
+ }
55
+ function ItemState({ state, time }) {
56
+ const word = STATE_WORDS[state.state];
57
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("p", {
58
+ className: "m-0 flex flex-wrap items-baseline gap-x-3 gap-y-1 text-xs text-muted",
59
+ children: [
60
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(StateWord, { state }),
61
+ /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("span", { children: [
62
+ state.reopened ? "Fixed, then recorded again; marked " : `${word.label} `,
63
+ BY[state.by],
64
+ " ",
65
+ time
66
+ ] }),
67
+ state.state === "reported" && state.eventsSince !== void 0 ? /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("span", {
68
+ className: "tabular-nums",
69
+ children: [plural(state.eventsSince, "event"), " since reported"]
70
+ }) : null,
71
+ state.link ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)("a", {
72
+ href: state.link,
73
+ target: "_blank",
74
+ rel: "noreferrer",
75
+ className: "text-text underline",
76
+ children: state.link
77
+ }) : null,
78
+ state.note ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", {
79
+ className: "text-text",
80
+ children: state.note
81
+ }) : null
82
+ ]
83
+ });
84
+ }
85
+ var NOTE = {
86
+ label: "Note (optional)",
87
+ key: "note",
88
+ type: "text"
89
+ };
90
+ var MARKS = {
91
+ fixed: {
92
+ action: "Mark fixed",
93
+ field: NOTE
94
+ },
95
+ reported: {
96
+ action: "Mark reported",
97
+ field: {
98
+ label: "Issue link (optional)",
99
+ key: "link",
100
+ type: "url"
101
+ }
102
+ },
103
+ dismissed: {
104
+ action: "Dismiss",
105
+ field: NOTE
106
+ }
107
+ };
108
+ function MarkActions({ name, handled, onMark }) {
109
+ const [draft, setDraft] = (0, import_react.useState)(null);
110
+ const [text, setText] = (0, import_react.useState)("");
111
+ const [pending, setPending] = (0, import_react.useState)(false);
112
+ const [refusal, setRefusal] = (0, import_react.useState)(null);
113
+ const fieldId = (0, import_react.useId)();
114
+ const field = (0, import_react.useRef)(null);
115
+ const openers = (0, import_react.useRef)({});
116
+ const cancelled = (0, import_react.useRef)(null);
117
+ (0, import_react.useEffect)(() => {
118
+ if (draft) field.current?.focus();
119
+ else if (cancelled.current) openers.current[cancelled.current]?.focus();
120
+ cancelled.current = null;
121
+ }, [draft]);
122
+ const close = () => {
123
+ setDraft(null);
124
+ setText("");
125
+ setRefusal(null);
126
+ };
127
+ const cancel = () => {
128
+ if (pending) return;
129
+ cancelled.current = draft;
130
+ close();
131
+ };
132
+ async function submit(state, input = {}) {
133
+ setPending(true);
134
+ setRefusal(null);
135
+ const refused = await onMark(state, input);
136
+ setPending(false);
137
+ if (refused) setRefusal(refused);
138
+ else close();
139
+ }
140
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", {
141
+ className: "grid gap-1.5",
142
+ children: [draft ? /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("form", {
143
+ "aria-label": `${MARKS[draft].action}: ${name}`,
144
+ className: "flex flex-wrap items-end gap-2",
145
+ onSubmit: (event) => {
146
+ event.preventDefault();
147
+ submit(draft, { [MARKS[draft].field.key]: text });
148
+ },
149
+ onKeyDown: (event) => {
150
+ if (event.key === "Escape") cancel();
151
+ },
152
+ children: [
153
+ /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("label", {
154
+ htmlFor: fieldId,
155
+ className: "grid gap-1 text-xs text-muted",
156
+ children: [MARKS[draft].field.label, /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Input, {
157
+ id: fieldId,
158
+ ref: field,
159
+ type: MARKS[draft].field.type,
160
+ value: text,
161
+ onChange: (event) => setText(event.target.value),
162
+ className: "h-8 w-72 max-w-full"
163
+ })]
164
+ }),
165
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Button, {
166
+ size: "sm",
167
+ variant: "primary",
168
+ type: "submit",
169
+ disabled: pending,
170
+ children: MARKS[draft].action
171
+ }),
172
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Button, {
173
+ size: "sm",
174
+ onClick: cancel,
175
+ disabled: pending,
176
+ children: "Cancel"
177
+ })
178
+ ]
179
+ }) : /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", {
180
+ role: "group",
181
+ "aria-label": `Mark ${name}`,
182
+ className: "flex flex-wrap gap-2",
183
+ children: [FRICTION_STATES.map((state) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Button, {
184
+ ref: (button) => {
185
+ openers.current[state] = button;
186
+ },
187
+ size: "sm",
188
+ disabled: pending,
189
+ onClick: () => setDraft(state),
190
+ children: MARKS[state].action
191
+ }, state)), handled ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Button, {
192
+ size: "sm",
193
+ disabled: pending,
194
+ onClick: () => void submit("open"),
195
+ children: "Reopen"
196
+ }) : null]
197
+ }), refusal ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)("p", {
198
+ className: "m-0 max-w-[70ch] text-xs text-bad",
199
+ role: "alert",
200
+ children: refusal
201
+ }) : null]
202
+ });
203
+ }
204
+ // src/views/friction/select-friction.ts
205
+ var DEFAULT_FRICTION_FILTERS = {
206
+ state: "open",
207
+ sort: "repeats"
208
+ };
209
+ function filtersFromSearch(search) {
210
+ return {
211
+ state: search.frictionState ?? DEFAULT_FRICTION_FILTERS.state,
212
+ type: search.frictionType,
213
+ kind: search.frictionKind,
214
+ sort: search.frictionSort ?? DEFAULT_FRICTION_FILTERS.sort
215
+ };
216
+ }
217
+ /** Defaults leave the address, so it stays short. */
218
+ function searchFromFilters(filters) {
219
+ return {
220
+ frictionState: filters.state === DEFAULT_FRICTION_FILTERS.state ? void 0 : filters.state,
221
+ frictionType: filters.type,
222
+ frictionKind: filters.kind,
223
+ frictionSort: filters.sort === DEFAULT_FRICTION_FILTERS.sort ? void 0 : filters.sort
224
+ };
225
+ }
226
+ /** Core's selection in the chosen order; most repeated is the view's own order. */
227
+ function selectFriction(view, filters) {
228
+ const shown = selectFriction$1(view, filters);
229
+ if (filters.sort !== "recent") return shown;
230
+ return {
231
+ ...shown,
232
+ groups: shown.groups.toSorted((a, b) => a.lastSeen < b.lastSeen ? 1 : a.lastSeen > b.lastSeen ? -1 : 0)
233
+ };
234
+ }
235
+ // src/views/friction/friction-view.tsx
236
+ var PERIODS = FRICTION_VIEW_DAYS.map((days) => ({
237
+ value: String(days),
238
+ label: `${days} days`
239
+ }));
240
+ var STATES = [
241
+ {
242
+ value: "open",
243
+ label: "Open"
244
+ },
245
+ {
246
+ value: "handled",
247
+ label: "Handled"
248
+ },
249
+ {
250
+ value: "all",
251
+ label: "All"
252
+ }
253
+ ];
254
+ var ANY = "any";
255
+ var KINDS = [{
256
+ value: ANY,
257
+ label: "All kinds"
258
+ }, ...REPORT_KINDS.map((kind) => ({
259
+ value: kind,
260
+ label: kind
261
+ }))];
262
+ var SORTS = [{
263
+ value: "repeats",
264
+ label: "Most repeated in one session"
265
+ }, {
266
+ value: "recent",
267
+ label: "Most recent"
268
+ }];
269
+ var RECORDED_SECTION = {
270
+ id: "friction-recorded",
271
+ title: "Recorded friction"
272
+ };
273
+ var REPORTS_SECTION = {
274
+ id: "friction-agent-reports",
275
+ title: "Agent reports"
276
+ };
277
+ var DATE_TIME = new Intl.DateTimeFormat(void 0, {
278
+ dateStyle: "medium",
279
+ timeStyle: "short"
280
+ });
281
+ /** Filled in after hydration: the server's time zone may differ from the viewer's. */
282
+ function FrictionTime({ at }) {
283
+ const browser = useBrowser();
284
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)("time", {
285
+ dateTime: at,
286
+ children: browser ? DATE_TIME.format(Date.parse(at)) : ""
287
+ });
288
+ }
289
+ 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)]";
290
+ function Detail({ label, children }) {
291
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_jsx_runtime.Fragment, { children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)("dt", {
292
+ className: "text-muted",
293
+ children: label
294
+ }), /* @__PURE__ */ (0, import_jsx_runtime.jsx)("dd", {
295
+ className: "m-0 min-w-0",
296
+ children
297
+ })] });
298
+ }
299
+ function Counted({ label, counts }) {
300
+ const entries = Object.entries(counts);
301
+ if (entries.length === 0) return null;
302
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Detail, {
303
+ label,
304
+ children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", {
305
+ className: "flex flex-wrap gap-x-3 gap-y-1",
306
+ children: entries.map(([name, count]) => /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("span", {
307
+ className: "font-mono tabular-nums",
308
+ children: [
309
+ name,
310
+ " ",
311
+ /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("span", {
312
+ className: "text-muted",
313
+ children: ["×", count]
314
+ })
315
+ ]
316
+ }, name))
317
+ })
318
+ });
319
+ }
320
+ function ItemFooter({ name, item, onMark }) {
321
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", {
322
+ className: "mt-1 grid gap-1.5",
323
+ children: [item.state ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(ItemState, {
324
+ state: item.state,
325
+ time: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(FrictionTime, { at: item.state.at })
326
+ }) : null, /* @__PURE__ */ (0, import_jsx_runtime.jsx)(MarkActions, {
327
+ name,
328
+ handled: !item.open,
329
+ onMark
330
+ })]
331
+ });
332
+ }
333
+ function Fields({ fields }) {
334
+ const shown = fields.filter(([, text]) => text);
335
+ if (shown.length === 0) return null;
336
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)("dl", {
337
+ className: cn(DETAILS, "max-w-[70ch] text-sm"),
338
+ children: shown.map(([label, text]) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Detail, {
339
+ label,
340
+ children: text
341
+ }, label))
342
+ });
343
+ }
344
+ function Row({ focusKey, line, summary, children }) {
345
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)("li", {
346
+ className: "border-t border-rule-soft first:border-t-0",
347
+ "data-friction-item": focusKey,
348
+ children: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("details", {
349
+ className: "group/friction",
350
+ children: [/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("summary", {
351
+ 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",
352
+ children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)(Icon, {
353
+ name: "right",
354
+ className: "mt-1 size-3.5 text-muted transition-transform group-open/friction:rotate-90 motion-reduce:transition-none"
355
+ }), /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", {
356
+ className: cn("flex min-w-0 flex-wrap items-baseline gap-x-4 gap-y-1", line),
357
+ children: summary
358
+ })]
359
+ }), /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", {
360
+ className: "mr-4 mb-3 ml-9.5 grid gap-1.5 border-l border-rule-soft pl-3",
361
+ children
362
+ })]
363
+ })
364
+ });
365
+ }
366
+ var FACTS = "flex flex-wrap items-baseline gap-x-3 gap-y-0.5 font-mono text-xs whitespace-nowrap text-muted tabular-nums";
367
+ var LAST_SEEN_TRACK = "minmax(32ch,max-content)";
368
+ var AT_TRACK = "minmax(22ch,max-content)";
369
+ var STATE_TRACK = "11ch";
370
+ function Gap({ wide }) {
371
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", {
372
+ "aria-hidden": "true",
373
+ className: cn("hidden", wide)
374
+ });
375
+ }
376
+ function groupCounts(group) {
377
+ return [
378
+ `at most ${group.maxPerSession} in one session`,
379
+ plural(group.events, "event"),
380
+ plural(group.sessions, "session"),
381
+ group.reports.length > 0 ? plural(group.reports.length, "report") : null
382
+ ];
383
+ }
384
+ function groupTracks(groups, columns) {
385
+ const counts = groups.map(groupCounts);
386
+ const widest = (column) => Math.max(...counts.map((row) => row[column]?.length ?? 0), 0);
387
+ const tracks = [
388
+ 0,
389
+ 1,
390
+ 2
391
+ ].map((column) => `${widest(column)}ch`);
392
+ if (columns.reports) tracks.push(`${widest(3)}ch`);
393
+ tracks.push(LAST_SEEN_TRACK);
394
+ if (columns.state) tracks.push(STATE_TRACK);
395
+ return tracks.join(" ");
396
+ }
397
+ function reportTracks(stateColumn) {
398
+ return stateColumn ? `${AT_TRACK} ${STATE_TRACK}` : AT_TRACK;
399
+ }
400
+ var factsStyle = (tracks) => ({ "--friction-facts": tracks });
401
+ function StateCell({ state, column, wide }) {
402
+ if (state) return /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", {
403
+ className: "font-sans",
404
+ children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(StateWord, { state })
405
+ });
406
+ return column ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Gap, { wide }) : null;
407
+ }
408
+ function GroupItem({ group, columns, onMark }) {
409
+ const [peak, events, sessions, reports] = groupCounts(group);
410
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(Row, {
411
+ focusKey: group.fingerprint,
412
+ line: "@5xl:grid @5xl:grid-cols-[minmax(0,1fr)_auto]",
413
+ summary: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_jsx_runtime.Fragment, { children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)("h3", {
414
+ className: "m-0 min-w-0 flex-[1_1_16rem] text-base font-semibold",
415
+ children: group.title
416
+ }), /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("span", {
417
+ className: cn(FACTS, "@3xl:grid @3xl:grid-cols-(--friction-facts)"),
418
+ children: [
419
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { children: peak }),
420
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { children: events }),
421
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { children: sessions }),
422
+ reports ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { children: reports }) : columns.reports ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Gap, { wide: "@3xl:block" }) : null,
423
+ /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("span", { children: ["last seen ", /* @__PURE__ */ (0, import_jsx_runtime.jsx)(FrictionTime, { at: group.lastSeen })] }),
424
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(StateCell, {
425
+ state: group.state,
426
+ column: columns.state,
427
+ wide: "@3xl:block"
428
+ })
429
+ ]
430
+ })] }),
431
+ children: [
432
+ /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("dl", {
433
+ className: cn(DETAILS, "text-xs"),
434
+ children: [
435
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Detail, {
436
+ label: "Fingerprint",
437
+ children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)("code", {
438
+ className: "font-mono",
439
+ children: group.fingerprint
440
+ })
441
+ }),
442
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Detail, {
443
+ label: "First seen",
444
+ children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(FrictionTime, { at: group.firstSeen })
445
+ }),
446
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Detail, {
447
+ label: "Last seen",
448
+ children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(FrictionTime, { at: group.lastSeen })
449
+ }),
450
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Counted, {
451
+ label: "Mate",
452
+ counts: group.versions
453
+ }),
454
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Counted, {
455
+ label: "Paths",
456
+ counts: group.paths
457
+ }),
458
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Counted, {
459
+ label: "Flags",
460
+ counts: group.flags
461
+ })
462
+ ]
463
+ }),
464
+ group.reports.length > 0 ? /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("section", {
465
+ "aria-label": `Reports on ${group.title}`,
466
+ className: "mt-1",
467
+ children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)("h4", {
468
+ className: "m-0 text-xs font-semibold text-muted",
469
+ children: plural(group.reports.length, "report")
470
+ }), /* @__PURE__ */ (0, import_jsx_runtime.jsx)("ul", {
471
+ className: "m-0 list-none p-0",
472
+ children: group.reports.map((report) => /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("li", {
473
+ className: "grid gap-1 border-t border-rule-soft py-2 first:border-t-0",
474
+ children: [/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", {
475
+ className: "flex flex-wrap items-baseline gap-x-2 text-xs text-muted",
476
+ children: [
477
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", {
478
+ className: "font-semibold text-text",
479
+ children: report.kind
480
+ }),
481
+ report.cost ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { children: report.cost }) : null,
482
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(FrictionTime, { at: report.at })
483
+ ]
484
+ }), /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Fields, { fields: [
485
+ ["Expected", report.expected],
486
+ ["Evidence", report.evidence],
487
+ ["Workaround", report.workaround]
488
+ ] })]
489
+ }, report.id))
490
+ })]
491
+ }) : null,
492
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(ItemFooter, {
493
+ name: group.title,
494
+ item: group,
495
+ onMark
496
+ })
497
+ ]
498
+ });
499
+ }
500
+ function FreeReportItem({ report, stateColumn, onMark }) {
501
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(Row, {
502
+ focusKey: report.id,
503
+ line: "@3xl:grid @3xl:grid-cols-[minmax(0,1fr)_auto]",
504
+ summary: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_jsx_runtime.Fragment, { children: [/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("span", {
505
+ className: "flex min-w-0 flex-wrap items-baseline gap-x-2 gap-y-1",
506
+ children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)("h3", {
507
+ className: "m-0 min-w-0 font-mono text-sm leading-[1.375rem] font-semibold",
508
+ children: report.subject
509
+ }), /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", {
510
+ className: "rounded-full border border-rule bg-page px-2 font-mono text-[0.7rem] text-text",
511
+ children: report.kind
512
+ })]
513
+ }), /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("span", {
514
+ className: cn(FACTS, "@3xl:grid @3xl:grid-cols-(--friction-facts)"),
515
+ children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)(FrictionTime, { at: report.at }), /* @__PURE__ */ (0, import_jsx_runtime.jsx)(StateCell, {
516
+ state: report.state,
517
+ column: stateColumn,
518
+ wide: "@3xl:block"
519
+ })]
520
+ })] }),
521
+ children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)(Fields, { fields: [
522
+ ["Expected", report.expected],
523
+ ["Cost", report.cost],
524
+ ["Evidence", report.evidence],
525
+ ["Workaround", report.workaround]
526
+ ] }), /* @__PURE__ */ (0, import_jsx_runtime.jsx)(ItemFooter, {
527
+ name: report.subject,
528
+ item: report,
529
+ onMark
530
+ })]
531
+ });
532
+ }
533
+ function Hidden({ hidden, onShowAll }) {
534
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_jsx_runtime.Fragment, { children: [
535
+ hidden === 1 ? "1 item is" : `${hidden} items are`,
536
+ " hidden by the filters.",
537
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Button, {
538
+ size: "sm",
539
+ onClick: onShowAll,
540
+ "data-show-all": true,
541
+ "aria-label": `Show all, including ${plural(hidden, "hidden item")}`,
542
+ children: "Show all"
543
+ })
544
+ ] });
545
+ }
546
+ function Overview({ view, shown, empty, onShowAll }) {
547
+ const sections = [[RECORDED_SECTION, shown.groups.length], [REPORTS_SECTION, shown.freeReports.length]];
548
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("section", {
549
+ "aria-label": "Overview",
550
+ className: "grid gap-2 text-sm",
551
+ children: [
552
+ /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", {
553
+ className: "flex flex-wrap items-baseline gap-x-5 gap-y-1",
554
+ children: [/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("p", {
555
+ className: "m-0",
556
+ children: [
557
+ plural(view.events, "event"),
558
+ " in ",
559
+ plural(view.sessions, "session"),
560
+ " in the last",
561
+ " ",
562
+ view.days,
563
+ " days for the selected companion."
564
+ ]
565
+ }), /* @__PURE__ */ (0, import_jsx_runtime.jsx)("nav", {
566
+ "aria-label": "Friction sections",
567
+ className: "flex flex-wrap gap-x-4 gap-y-1",
568
+ children: sections.map(([{ id, title }, count]) => count > 0 ? /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("a", {
569
+ href: `#${id}`,
570
+ className: "inline-flex items-center gap-1.5 rounded-control underline",
571
+ children: [title, /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Count, { value: count })]
572
+ }, id) : null)
573
+ })]
574
+ }),
575
+ !empty && shown.hidden > 0 ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)("p", {
576
+ className: "m-0 flex flex-wrap items-center gap-2 text-muted",
577
+ children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Hidden, {
578
+ hidden: shown.hidden,
579
+ onShowAll
580
+ })
581
+ }) : null,
582
+ /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", {
583
+ className: "flex flex-wrap items-center gap-x-3 gap-y-2",
584
+ children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)("p", {
585
+ className: "m-0 text-muted",
586
+ children: "To investigate, run this in your own terminal, inside the affected repository:"
587
+ }), /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", {
588
+ className: "w-48 max-w-full",
589
+ children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(CommandLine, {
590
+ text: `${FRAMEWORK_NAME} triage`,
591
+ label: "command"
592
+ })
593
+ })]
594
+ })
595
+ ]
596
+ });
597
+ }
598
+ function Recording({ recording, toggle, button }) {
599
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", {
600
+ className: "grid gap-1",
601
+ children: [
602
+ /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", {
603
+ className: "flex flex-wrap items-center gap-3",
604
+ children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)(RecordingState, { recording }), /* @__PURE__ */ (0, import_jsx_runtime.jsx)(RecordingButton, {
605
+ ref: button,
606
+ recording,
607
+ toggle
608
+ })]
609
+ }),
610
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(RecordingReach, {}),
611
+ toggle.error ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)("p", {
612
+ className: "m-0 text-sm text-bad",
613
+ role: "alert",
614
+ children: toggle.error
615
+ }) : null
616
+ ]
617
+ });
618
+ }
619
+ function FilterSelect({ label, options, value, onChange, note, disabled }) {
620
+ const id = (0, import_react.useId)();
621
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", {
622
+ className: "flex items-center gap-2",
623
+ children: [
624
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("label", {
625
+ htmlFor: id,
626
+ className: "text-xs text-muted",
627
+ children: label
628
+ }),
629
+ /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(Select, {
630
+ items: options,
631
+ value,
632
+ disabled,
633
+ onValueChange: (next) => {
634
+ if (next !== null) onChange(next);
635
+ },
636
+ children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)(SelectTrigger, {
637
+ id,
638
+ "aria-describedby": note ? `${id}-note` : void 0,
639
+ className: "h-7 w-auto",
640
+ children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(SelectValue, {})
641
+ }), /* @__PURE__ */ (0, import_jsx_runtime.jsx)(SelectContent, { children: options.map((option) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)(SelectItem, {
642
+ value: option.value,
643
+ children: option.label
644
+ }, option.value)) })]
645
+ }),
646
+ note ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", {
647
+ id: `${id}-note`,
648
+ className: "text-xs text-muted",
649
+ children: note
650
+ }) : null
651
+ ]
652
+ });
653
+ }
654
+ function Filters({ view, shown, filters, onFilters }) {
655
+ const types = [{
656
+ value: ANY,
657
+ label: "All types"
658
+ }, ...shown.types.map((type) => ({
659
+ value: type,
660
+ label: type
661
+ }))];
662
+ const noReports = selectFriction(view, {
663
+ ...filters,
664
+ kind: void 0
665
+ }).freeReports.length === 0;
666
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", {
667
+ className: "flex flex-wrap items-center gap-x-5 gap-y-2",
668
+ children: [
669
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(FilterSelect, {
670
+ label: "Type",
671
+ options: types,
672
+ value: shown.type ?? ANY,
673
+ onChange: (type) => onFilters({
674
+ ...filters,
675
+ type: oneOf(SUBJECT_TYPES, type)
676
+ })
677
+ }),
678
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(FilterSelect, {
679
+ label: "Kind",
680
+ options: KINDS,
681
+ value: filters.kind ?? ANY,
682
+ onChange: (kind) => onFilters({
683
+ ...filters,
684
+ kind: oneOf(REPORT_KINDS, kind)
685
+ }),
686
+ note: "Agent reports only",
687
+ disabled: noReports && filters.kind === void 0
688
+ }),
689
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(FilterSelect, {
690
+ label: "Sort",
691
+ options: SORTS,
692
+ value: filters.sort,
693
+ onChange: (sort) => onFilters({
694
+ ...filters,
695
+ sort
696
+ })
697
+ })
698
+ ]
699
+ });
700
+ }
701
+ function Lists({ shown, empty, markItem, onShowAll }) {
702
+ if (empty) return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(EmptyNote, {
703
+ className: "flex flex-wrap items-center gap-x-3 gap-y-2",
704
+ children: ["No item matches the filters. ", /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Hidden, {
705
+ hidden: shown.hidden,
706
+ onShowAll
707
+ })]
708
+ });
709
+ const groupColumns = {
710
+ reports: shown.groups.some((group) => group.reports.length > 0),
711
+ state: shown.groups.some((group) => group.state !== null)
712
+ };
713
+ const reportState = shown.freeReports.some((report) => report.state !== null);
714
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", {
715
+ className: "grid gap-4",
716
+ children: [shown.groups.length > 0 ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(ListCard, {
717
+ ...RECORDED_SECTION,
718
+ count: shown.groups.length,
719
+ className: "wrap-anywhere",
720
+ children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)("ul", {
721
+ className: "@container m-0 list-none p-0",
722
+ style: factsStyle(groupTracks(shown.groups, groupColumns)),
723
+ children: shown.groups.map((group) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)(GroupItem, {
724
+ group,
725
+ columns: groupColumns,
726
+ onMark: markItem(group.fingerprint, group.title)
727
+ }, group.fingerprint))
728
+ })
729
+ }) : null, shown.freeReports.length > 0 ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(ListCard, {
730
+ ...REPORTS_SECTION,
731
+ count: shown.freeReports.length,
732
+ hint: "These reports are not attached to a recorded event.",
733
+ className: "wrap-anywhere",
734
+ children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)("ul", {
735
+ className: "@container m-0 list-none p-0",
736
+ style: factsStyle(reportTracks(reportState)),
737
+ children: shown.freeReports.map((report) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)(FreeReportItem, {
738
+ report,
739
+ stateColumn: reportState,
740
+ onMark: markItem(report.id, report.subject)
741
+ }, report.id))
742
+ })
743
+ }) : null]
744
+ });
745
+ }
746
+ function FrictionPanel({ view, days, onDays, toggle, filters, onFilters, mark, recordingButton }) {
747
+ const recorded = view.events > 0 || view.freeReports.length > 0;
748
+ const shown = selectFriction(view, filters);
749
+ const [marked, setMarked] = (0, import_react.useState)(null);
750
+ const panel = (0, import_react.useRef)(null);
751
+ (0, import_react.useEffect)(() => {
752
+ if (!marked) return;
753
+ const row = (key) => key === null ? null : panel.current?.querySelector(`[data-friction-item="${CSS.escape(key)}"] summary`);
754
+ (row(marked.key) ?? row(marked.next) ?? panel.current?.querySelector("[data-show-all]"))?.focus();
755
+ }, [marked]);
756
+ const markItem = (key, name) => async (state, input) => {
757
+ const order = [...shown.groups.map((group) => group.fingerprint), ...shown.freeReports.map((report) => report.id)];
758
+ const index = order.indexOf(key);
759
+ const next = order[index + 1] ?? order[index - 1] ?? null;
760
+ let result;
761
+ try {
762
+ result = await mark({
763
+ target: key,
764
+ state,
765
+ ...input
766
+ });
767
+ } catch (error) {
768
+ return `The mark could not be saved: ${error instanceof Error ? error.message : String(error)}`;
769
+ }
770
+ if (!result.ok) return result.reason;
771
+ setMarked((last) => ({
772
+ announcementKey: (last?.announcementKey ?? 0) + 1,
773
+ key,
774
+ next,
775
+ message: `${name}: ${state === "open" ? "reopened" : `marked ${state}`}.`
776
+ }));
777
+ return null;
778
+ };
779
+ const showAll = () => {
780
+ [...panel.current?.querySelectorAll("[aria-label=\"State\"] button") ?? []].find((button) => button.textContent === "All")?.focus();
781
+ onFilters({
782
+ state: "all",
783
+ sort: filters.sort
784
+ });
785
+ };
786
+ const empty = shown.groups.length === 0 && shown.freeReports.length === 0;
787
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", {
788
+ ref: panel,
789
+ className: cn(PAGE_PAD, "grid min-w-0 gap-4 pt-3 pb-6"),
790
+ children: [
791
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Recording, {
792
+ recording: view.recording,
793
+ toggle,
794
+ button: recordingButton
795
+ }),
796
+ /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", {
797
+ className: "grid gap-2",
798
+ children: [/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", {
799
+ className: "flex flex-wrap items-center gap-x-5 gap-y-2",
800
+ children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)(Pills, {
801
+ label: "Period",
802
+ options: PERIODS,
803
+ value: String(days),
804
+ onChange: (value) => onDays(Number(value))
805
+ }), recorded ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Pills, {
806
+ label: "State",
807
+ options: STATES,
808
+ value: filters.state,
809
+ onChange: (state) => onFilters({
810
+ ...filters,
811
+ state
812
+ })
813
+ }) : null]
814
+ }), recorded ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Filters, {
815
+ view,
816
+ shown,
817
+ filters,
818
+ onFilters
819
+ }) : null]
820
+ }),
821
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", {
822
+ "aria-live": "polite",
823
+ className: "sr-only",
824
+ children: marked ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)("p", { children: marked.message }, marked.announcementKey) : null
825
+ }),
826
+ recorded ? /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_jsx_runtime.Fragment, { children: [
827
+ view.recording ? null : /* @__PURE__ */ (0, import_jsx_runtime.jsx)("p", {
828
+ className: "m-0 text-sm text-muted",
829
+ children: "Recording is off: nothing new is recorded. The records below were made while it was on."
830
+ }),
831
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Overview, {
832
+ view,
833
+ shown,
834
+ empty,
835
+ onShowAll: showAll
836
+ }),
837
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Lists, {
838
+ shown,
839
+ empty,
840
+ markItem,
841
+ onShowAll: showAll
842
+ })
843
+ ] }) : /* @__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.` })
844
+ ]
845
+ });
846
+ }
847
+ function Friction({ companion, days, onDays, filters, onFilters }) {
848
+ const query = useQuery({
849
+ ...frictionQuery(companion, days),
850
+ enabled: useBrowser(),
851
+ placeholderData: keepPreviousData
852
+ });
853
+ const toggle = useSetFrictionRecording();
854
+ const mark = useMarkFriction();
855
+ const { button: recordingButton, retried } = useRetryFocus(query.isSuccess);
856
+ if (!query.data && !query.isError) return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(ViewLoading, { title: "Reading the Friction Log…" });
857
+ const failed = query.isError ? /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", {
858
+ className: cn(PAGE_PAD, "pt-3 text-sm"),
859
+ role: "alert",
860
+ children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)("p", {
861
+ className: "m-0 text-bad",
862
+ children: "The Friction Log could not be read."
863
+ }), /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Button, {
864
+ className: "mt-3",
865
+ onClick: () => {
866
+ retried();
867
+ query.refetch();
868
+ },
869
+ disabled: query.isFetching,
870
+ children: "Retry"
871
+ })]
872
+ }) : null;
873
+ if (!query.data) return failed;
874
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_jsx_runtime.Fragment, { children: [failed, /* @__PURE__ */ (0, import_jsx_runtime.jsx)(FrictionPanel, {
875
+ view: query.data,
876
+ days,
877
+ onDays,
878
+ toggle,
879
+ filters,
880
+ onFilters,
881
+ mark,
882
+ recordingButton
883
+ })] });
884
+ }
885
+ // src/routes/friction.tsx?tsr-split=component
886
+ var SplitComponent = function FrictionRoute() {
887
+ const search = Route.useSearch();
888
+ const navigate = Route.useNavigate();
889
+ return search.companion ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Friction, {
890
+ companion: search.companion,
891
+ days: search.frictionDays ?? 30,
892
+ onDays: (frictionDays) => void navigate({ search: (previous) => ({
893
+ ...previous,
894
+ frictionDays
895
+ }) }),
896
+ filters: filtersFromSearch(search),
897
+ onFilters: (filters) => void navigate({ search: (previous) => ({
898
+ ...previous,
899
+ ...searchFromFilters(filters)
900
+ }) })
901
+ }, search.companion) : null;
902
+ };
903
+ export { SplitComponent as component };