frizz-server 0.15.49 → 0.15.50

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 (156) hide show
  1. package/dist/acp-daemon.js +39 -5
  2. package/dist/claude-agent-broker.js +55 -17
  3. package/dist/codex-app-server-daemon.js +43 -9
  4. package/dist/dev-child.js +7015 -3069
  5. package/package.json +15 -8
  6. package/runtime/board/agent-status.mjs +3 -3
  7. package/runtime/cc-worker/DECISIONS.md +19 -0
  8. package/runtime/cc-worker/bin/frizz-mcp.mjs +4 -2
  9. package/runtime/cc-worker/bin/frizzctl.mjs +26 -3
  10. package/runtime/cc-worker/hooks/deny-plan.mjs +4 -3
  11. package/runtime/cc-worker/hooks/hooks.json +18 -18
  12. package/runtime/cc-worker/hooks/scratchpad.mjs +10 -6
  13. package/runtime/cc-worker/lib/frizz-tools.mjs +156 -77
  14. package/web-dist/assets/{abnfDiagram-VRR7QNED-J7b3ICAw.js → abnfDiagram-VCTEODGH-CSl-iUaD.js} +1 -1
  15. package/web-dist/assets/{arc-D0znEGMI.js → arc-BSyeo0Gb.js} +1 -1
  16. package/web-dist/assets/architecture-7GRP2DOG-jYpGgJVJ.js +1 -0
  17. package/web-dist/assets/architectureDiagram-5GKGNRK7-Bo_gyMVC.js +36 -0
  18. package/web-dist/assets/blockDiagram-I7D4REHJ-9EtOS1Y1.js +129 -0
  19. package/web-dist/assets/c4Diagram-7LVT6UL2-CE1hW3oj.js +38 -0
  20. package/web-dist/assets/channel-CC-n29cI.js +1 -0
  21. package/web-dist/assets/chunk-2E4U76K2-QqOdoNOR.js +2 -0
  22. package/web-dist/assets/chunk-4HAMMTFA-Df2uLm9r.js +62 -0
  23. package/web-dist/assets/{chunk-ICXQ74PX-Cj1B4Mt1.js → chunk-75Z2AOVW-DF1G6d8q.js} +1 -1
  24. package/web-dist/assets/{chunk-VAUOI2AC-DYUbCOm7.js → chunk-CLGD4ZFX-CMAQm7EJ.js} +1 -1
  25. package/web-dist/assets/chunk-DU6HZSFF-UWY5hXXp.js +127 -0
  26. package/web-dist/assets/{chunk-32BRIVSS-DrQoYPLw.js → chunk-F27PBJKO-C59uYSbj.js} +1 -1
  27. package/web-dist/assets/{chunk-KEIR6QF5-BfrZ3jm6.js → chunk-FOHPRMQF-CyTuVbu3.js} +2 -2
  28. package/web-dist/assets/chunk-GMAD6QVW-BsJsQjY4.js +72 -0
  29. package/web-dist/assets/chunk-GVQU2GXP-BuITwr9r.js +1 -0
  30. package/web-dist/assets/{chunk-EX3LRPZG-CInw3Q3F.js → chunk-IMKFNOWR-5Ui4f5l4.js} +2 -2
  31. package/web-dist/assets/chunk-L3NEJ4N5-BISBblwX.js +1 -0
  32. package/web-dist/assets/chunk-LNGE3PJU-DNNNwF8Y.js +34 -0
  33. package/web-dist/assets/chunk-OSK3NFVY-CZl3XlkY.js +10 -0
  34. package/web-dist/assets/chunk-P2QGCYS3-DoytbW1J.js +1 -0
  35. package/web-dist/assets/{chunk-VR4S4FIN-WE1RlWzZ.js → chunk-POPQ4Y6H-D28hnSIy.js} +1 -1
  36. package/web-dist/assets/{chunk-HOUHSVGY-DozQYa90.js → chunk-PWAF6VOD-CbZvnkji.js} +1 -1
  37. package/web-dist/assets/chunk-SHT3W25Y-DM4ozJwj.js +168 -0
  38. package/web-dist/assets/{chunk-MOJQB5TN-dwysbljv.js → chunk-SVP7TREG-m6oapxSg.js} +1 -1
  39. package/web-dist/assets/{chunk-V7JOEXUC-PEaKX4p_.js → chunk-TICWLB2K-Ochfyos9.js} +1 -1
  40. package/web-dist/assets/chunk-TLUHSLCS-iM7uiuAo.js +2 -0
  41. package/web-dist/assets/{chunk-XXDRQBXY-CuNd86yu.js → chunk-XXDRQBXY-DYlTP5J-.js} +1 -1
  42. package/web-dist/assets/classDiagram-ZZMXUADV-CXJ9OBBD.js +1 -0
  43. package/web-dist/assets/classDiagram-v2-VYDZK3BY-CXJ9OBBD.js +1 -0
  44. package/web-dist/assets/cose-bilkent-JH36ORCC-BUIsLrGc.js +1 -0
  45. package/web-dist/assets/cynefin-OW5HDTMX-XtTYGcIH.js +1 -0
  46. package/web-dist/assets/{cynefinDiagram-TSTJHNR4-BlQjapzH.js → cynefinDiagram-5FMLGOSQ--ClxINOZ.js} +1 -1
  47. package/web-dist/assets/dagre-BJJUWK_n.js +1 -0
  48. package/web-dist/assets/dagre-GXQ25YYZ-CupZ_9Gq.js +4 -0
  49. package/web-dist/assets/{diagram-OA4YK3LP-CaTIfXcU.js → diagram-S7CK7UJ4-BlF7gkGi.js} +4 -4
  50. package/web-dist/assets/diagram-UQ7AKVKN-BMXRmU5D.js +41 -0
  51. package/web-dist/assets/{diagram-FQU43EPY-BOlJtvyz.js → diagram-VSXAHHWV-r5DJsSB3.js} +1 -1
  52. package/web-dist/assets/{diagram-G47NLZAW-DPbXRY-S.js → diagram-VX7I27RA-DxGq7Ln7.js} +1 -1
  53. package/web-dist/assets/{diagram-NH7WQ7WH-B1Nl4A7D.js → diagram-Z3DM3KII-DqXtb_id.js} +1 -1
  54. package/web-dist/assets/dist-DoH_9pyS.js +1 -0
  55. package/web-dist/assets/{ebnfDiagram-CCIWWBDH-BIW4rAiN.js → ebnfDiagram-PWID7BFC-BV_AT7TD.js} +1 -1
  56. package/web-dist/assets/erDiagram-RLTQ6QDP-BV70EqG9.js +99 -0
  57. package/web-dist/assets/eventmodeling-NTZA5JFV-Cw8GwV1a.js +1 -0
  58. package/web-dist/assets/flowDiagram-HODETNUW-B0Q6ZSg0.js +1 -0
  59. package/web-dist/assets/ganttDiagram-EL5Y4UJY-Cvkf14ib.js +292 -0
  60. package/web-dist/assets/gitGraph-4MIJSDKK-XBlZCz1U.js +1 -0
  61. package/web-dist/assets/{gitGraphDiagram-IHSO6WYX-CpPGTKWr.js → gitGraphDiagram-WWUBYQGX-vDyL82tj.js} +1 -1
  62. package/web-dist/assets/index-D-pcMA7P.js +242 -0
  63. package/web-dist/assets/index-DqckQXcp.css +2 -0
  64. package/web-dist/assets/info-A6RAGUB7-DfR7iRgc.js +1 -0
  65. package/web-dist/assets/{infoDiagram-FWYZ7A6U-DUZecEP8.js → infoDiagram-27XIBGKW-BT4k6N6o.js} +1 -1
  66. package/web-dist/assets/{ishikawaDiagram-FXEZZL3T-XAAQSfxB.js → ishikawaDiagram-5VMMS53U-BJIdMG0T.js} +1 -1
  67. package/web-dist/assets/{journeyDiagram-5HDEW3XC-BzWg86Rn.js → journeyDiagram-3NMN7TZE-CUGzIF61.js} +2 -2
  68. package/web-dist/assets/{kanban-definition-HUTT4EX6-B_OPyRDu.js → kanban-definition-UXKFOSKX-DIPC4kv7.js} +2 -2
  69. package/web-dist/assets/{line-MIBXaWt1.js → line-CJKCWj73.js} +1 -1
  70. package/web-dist/assets/{linear-uglE5t1T.js → linear-z2V0wJk9.js} +1 -1
  71. package/web-dist/assets/{mermaid-parser.core-J0F3kyQU.js → mermaid-parser.core-BH-fcjsB.js} +3 -3
  72. package/web-dist/assets/mermaid.core-BSdNmJCs.js +11 -0
  73. package/web-dist/assets/{mindmap-definition-LN4V7U3C-C6t1sDuH.js → mindmap-definition-YA3MSWOX-CJC3zMDF.js} +1 -1
  74. package/web-dist/assets/packet-AYTQ26CC-BET157L_.js +1 -0
  75. package/web-dist/assets/{pegDiagram-2B236MQR-DUx_k0xu.js → pegDiagram-XKGWAZYB-Du8ALEoR.js} +1 -1
  76. package/web-dist/assets/pie-WAS4IAKB-CDs5cIGi.js +1 -0
  77. package/web-dist/assets/{pieDiagram-ENE6RG2P-44mApnR1.js → pieDiagram-E7YTZNPT-BX88bIIM.js} +1 -1
  78. package/web-dist/assets/{quadrantDiagram-ABIIQ3AL-Bt2Yzr6E.js → quadrantDiagram-AXDQQJYC-BkGxldmI.js} +1 -1
  79. package/web-dist/assets/radar-RG4KPBEZ-FMcFyhAF.js +1 -0
  80. package/web-dist/assets/railroad-74A4TZTK-Du0SbLQI.js +1 -0
  81. package/web-dist/assets/railroad-abnf-HS5TGJTU-DRi4RhLb.js +1 -0
  82. package/web-dist/assets/railroad-ebnf-LZEXJU2U-BmBkdsnK.js +1 -0
  83. package/web-dist/assets/railroad-peg-WCYAUIDC-CydTrmQm.js +1 -0
  84. package/web-dist/assets/{railroadDiagram-RFXS5EU6-d8BSz3zX.js → railroadDiagram-O6MQD6OU-CYqN0dL6.js} +1 -1
  85. package/web-dist/assets/{requirementDiagram-TGXJPOKE-DNAaYt1Y.js → requirementDiagram-BXWQKSXE-ClpQ_sLR.js} +2 -2
  86. package/web-dist/assets/rolldown-runtime-Bh1tDfsg.js +1 -0
  87. package/web-dist/assets/{sankeyDiagram-HTMAVEWB-R_lnknB4.js → sankeyDiagram-P5KCCOFB-CEJUF8o9.js} +1 -1
  88. package/web-dist/assets/{sequenceDiagram-DBY2YBRQ-Ba-X-mCo.js → sequenceDiagram-WJ2MYXX4-BpJYUJhB.js} +1 -1
  89. package/web-dist/assets/src-C4XfhTaE.js +1 -0
  90. package/web-dist/assets/{stateDiagram-2N3HPSRC-C51RHuJf.js → stateDiagram-D77RDMKH-BmKLEj9Q.js} +1 -1
  91. package/web-dist/assets/stateDiagram-v2-MP3YSRHH-D_c6vvvW.js +1 -0
  92. package/web-dist/assets/swimlanes-42K2YHIH-CyJxVets.js +1 -0
  93. package/web-dist/assets/swimlanesDiagram-VR7AAH4N-BcVx8rdP.js +8 -0
  94. package/web-dist/assets/threadSurfaces-CYpFDk_e.js +143 -0
  95. package/web-dist/assets/{timeline-definition-FHXFAJF6-DnfNzZjg.js → timeline-definition-24CTP7MA-ChEqw_62.js} +1 -1
  96. package/web-dist/assets/treeView-Q6P3EWNA-l1PaAwLT.js +1 -0
  97. package/web-dist/assets/treemap-WGGIJYW6-CxvHcEiT.js +1 -0
  98. package/web-dist/assets/{vennDiagram-L72KCM5P-b9DhO8LT.js → vennDiagram-4TSXK5OY-DF-yXPNP.js} +1 -1
  99. package/web-dist/assets/wardley-WFR3VGLG-BqkX6NQy.js +1 -0
  100. package/web-dist/assets/{wardleyDiagram-EHGQE667-cCbiyTUT.js → wardleyDiagram-VM6X3IG4-B9LU1bxh.js} +1 -1
  101. package/web-dist/assets/{xychartDiagram-FW5EYKEG-BO5JrKdd.js → xychartDiagram-S5SC5T6Z-Zt_ZqCWS.js} +3 -3
  102. package/web-dist/index.html +3 -2
  103. package/runtime/board/agent-liveness.mjs +0 -367
  104. package/runtime/board/notify-shared.mjs +0 -90
  105. package/runtime/board/notify.mjs +0 -81
  106. package/runtime/board/rest-detect.mjs +0 -213
  107. package/runtime/board/thread-excerpt.mjs +0 -162
  108. package/web-dist/assets/architecture-TIHT7OUA-BZjpcwN0.js +0 -1
  109. package/web-dist/assets/architectureDiagram-ZJ3FMSHR-BLoL7eps.js +0 -36
  110. package/web-dist/assets/blockDiagram-677ZJIJ3-BOiZIgfH.js +0 -132
  111. package/web-dist/assets/c4Diagram-LMCZKHZV-DaL-micl.js +0 -10
  112. package/web-dist/assets/channel-BOY_EM0_.js +0 -1
  113. package/web-dist/assets/chunk-52WLFC77-Bl9DYslI.js +0 -10
  114. package/web-dist/assets/chunk-7BUUIJ7U-Bb538aSH.js +0 -1
  115. package/web-dist/assets/chunk-C7G6YPKG-C8ZxUisf.js +0 -1
  116. package/web-dist/assets/chunk-FWX5IMBZ-Bb3cN9tF.js +0 -2
  117. package/web-dist/assets/chunk-OGEWGWER-BIXFK2Kz.js +0 -1
  118. package/web-dist/assets/chunk-PUDLZKDR-zTbgLDMj.js +0 -156
  119. package/web-dist/assets/chunk-Q4XR5HBZ-BPeZU3L1.js +0 -70
  120. package/web-dist/assets/chunk-RYQCIY6F-B2AmSBtU.js +0 -1
  121. package/web-dist/assets/chunk-WYO6CB5R-Cptxef_j.js +0 -127
  122. package/web-dist/assets/chunk-ZGVPDNZ5-nKibxQuS.js +0 -62
  123. package/web-dist/assets/chunk-ZIRB5QZD-C6fEPe3t.js +0 -32
  124. package/web-dist/assets/classDiagram-OUVF2IWQ-rW3mcevY.js +0 -1
  125. package/web-dist/assets/classDiagram-v2-EOCWNBFH-rW3mcevY.js +0 -1
  126. package/web-dist/assets/cose-bilkent-JH36ORCC-BHapvkAQ.js +0 -1
  127. package/web-dist/assets/cynefin-VYW2F7L2-BefSX6Er.js +0 -1
  128. package/web-dist/assets/dagre-CXRCoUWR.js +0 -1
  129. package/web-dist/assets/dagre-VKFMJZFB-BnFClfBQ.js +0 -4
  130. package/web-dist/assets/diagram-WEI45ONY-CcXbcxic.js +0 -41
  131. package/web-dist/assets/dist-Bsb4JJAO.js +0 -1
  132. package/web-dist/assets/erDiagram-Q63AITRT-BpObPW4X.js +0 -85
  133. package/web-dist/assets/eventmodeling-45OFAUF4-BBdu_FMe.js +0 -1
  134. package/web-dist/assets/flowDiagram-23GEKE2U-JCnBd218.js +0 -1
  135. package/web-dist/assets/ganttDiagram-NO4QXBWP-D6POggnD.js +0 -292
  136. package/web-dist/assets/gitGraph-TEB2WS4Q-YCEfMCFc.js +0 -1
  137. package/web-dist/assets/index-CFXWSXTQ.css +0 -2
  138. package/web-dist/assets/index-CjwFZh5G.js +0 -380
  139. package/web-dist/assets/info-DKCQHKI2-SyitzjWc.js +0 -1
  140. package/web-dist/assets/map-DsCK-0Cs.js +0 -1
  141. package/web-dist/assets/mermaid.core-CJriGaX1.js +0 -11
  142. package/web-dist/assets/packet-7NZHBO7P-BP5kC3mk.js +0 -1
  143. package/web-dist/assets/pie-RZYD4A2V-ehviwJKF.js +0 -1
  144. package/web-dist/assets/radar-I7S5WNFK-DW4R66e1.js +0 -1
  145. package/web-dist/assets/railroad-3IZDKUUU-D08S7ovl.js +0 -1
  146. package/web-dist/assets/railroad-abnf-AHOZXSZD-C9qettXj.js +0 -1
  147. package/web-dist/assets/railroad-ebnf-EBAXGLYW-DJWltGwI.js +0 -1
  148. package/web-dist/assets/railroad-peg-LSFZ7HO6-tqNP6Nvp.js +0 -1
  149. package/web-dist/assets/src-_ShgCKEo.js +0 -1
  150. package/web-dist/assets/stateDiagram-v2-6OUMAXLB-BdAiMi1e.js +0 -1
  151. package/web-dist/assets/swimlanes-5IMT3BWC-6s8xokkg.js +0 -2
  152. package/web-dist/assets/swimlanesDiagram-G3AALYLV-CXOHMq1K.js +0 -8
  153. package/web-dist/assets/treeView-QDETBFTQ-vUI6BtZi.js +0 -1
  154. package/web-dist/assets/treemap-6X3UGDF4-DXAQ9FfS.js +0 -1
  155. package/web-dist/assets/wardley-OPB4EBWU-DcnZYvgN.js +0 -1
  156. /package/web-dist/assets/{sizeCapture-X5ZJPWSS-B0uUizjq.js → sizeCapture-INFHLROL-B0uUizjq.js} +0 -0
@@ -1,367 +0,0 @@
1
- // @ts-check
2
- /**
3
- * frizz — agent-liveness helper for the Stop hook.
4
- *
5
- * Background sub-agents are bound to their thread AUTOMATICALLY: the `agent-bind`
6
- * PostToolUse hook records `agentId → thread` into `.frizz/.agent-bindings.jsonl` at
7
- * dispatch (see `./agent-bindings.mjs`). This module reads that ephemeral binding to learn
8
- * which agents serve which thread, then DERIVES each one's real liveness from ground truth
9
- * and returns reminder LINES for the Stop hook to surface. Hooks cannot call
10
- * SendMessage/Agent, so this is detect-and-remind only — exactly the ask. (The old
11
- * hand-maintained `agents: [{id, label}]` thread frontmatter is GONE — never read; a
12
- * lingering one in an old thread file is an ignored no-op.)
13
- *
14
- * COMPUTE, DON'T STORE. The binding supplies only the id↔thread mapping; it carries no
15
- * per-agent state. State comes from `deriveAgentState`
16
- * (`./agent-status.mjs`) over two ground-truth signals:
17
- * 1. The session tasks dir, derived from the Stop payload's `transcript_path`
18
- * (`~/.claude/projects/<slug>/<session>.jsonl`). The per-agent activity files
19
- * live at `<tmp>/claude-<uid>/<slug>/<session>/tasks/<agentId>.output`, where
20
- * `<tmp>` is `/tmp` or `/private/tmp` and `<uid>` varies — so we GLOB the
21
- * `claude-*` dirs under both bases rather than hard-code the uid. The `.output`
22
- * entries are SYMLINKS to the subagent transcript jsonl; we `statSync` (follows
23
- * the link) so the age reflects the TARGET's real last-write, not the stale
24
- * symlink mtime. The mtime → idle/frozen age.
25
- * 2. The owning THREAD's own `status:` frontmatter (done/dismissed = terminal) — the
26
- * orchestrator's deliberate "I reconciled this" signal, and the ONLY mutable bit.
27
- *
28
- * THREAD-CENTRIC, LOW-NOISE. For each `active` thread we consider ONLY its NEWEST bound agent
29
- * (a superseded older agent is never flagged) and SUPPRESS the thread entirely when a PR is
30
- * landing for it via the merge cascade (it's active for the merge, not a stuck agent). The bar
31
- * is "better to miss a soft case than nag a benign one":
32
- * - ⚠ ACTIVE THREAD, NO LIVE AGENT (state 'dropped'): an active, non-downstream thread whose
33
- * NEWEST agent is quiet beyond DROPPED_MIN AND has rested (ended a turn) — the
34
- * high-confidence "this thread is stuck active with nobody on it" signal. Calm wording.
35
- * - a soft idle note (state 'idle'): quiet but not confidently dropped — fine if it's
36
- * watching CI or mid-build. Informational only.
37
- * - (thread terminal / parked / downstream / fresh agent → say nothing.)
38
- *
39
- * Thresholds (minutes), tunable via env for experimentation:
40
- * FRIZZ_IDLE_MIN (default 10) — quiet this long → soft idle note.
41
- * FRIZZ_DROPPED_MIN (default 45, FRIZZ_FROZEN_MIN honored as the old alias) — quiet this long
42
- * AND rested → call it dropped. Deliberately generous: a real agent legitimately arms a
43
- * CI watcher and sits silent for 30–40 min, so 45 min lets the watcher fire and resume it
44
- * before we ever flag. Tune via the env var for faster- or slower-paced repos.
45
- *
46
- * FAIL-OPEN ABSOLUTELY: any error (no tasks dir, no bindings file, unparseable frontmatter,
47
- * unreadable file) → return [] (no lines). This must NEVER throw or block end-of-turn.
48
- */
49
- import { readFileSync, readdirSync, statSync, existsSync } from 'node:fs';
50
- import { join } from 'node:path';
51
- import { deriveAgentState, findAgentOutputAge, IDLE_MIN, DROPPED_MIN, LONG_RUNTIME_MIN } from './agent-status.mjs';
52
- import { newestBindingByThread, downstreamThreads, restedAgentIds } from './agent-bindings.mjs';
53
-
54
- // Thread-level terminal statuses (frontmatter `status:`), matching scripts/frizz TERMINAL.
55
- const TERMINAL_THREAD = new Set(['done', 'dismissed']);
56
-
57
- /**
58
- * Derive the session tasks dir from a Stop payload's transcript_path.
59
- * @param {string|undefined|null} transcriptPath
60
- * @returns {string|null}
61
- */
62
- export function deriveTasksDir(transcriptPath) {
63
- try {
64
- if (!transcriptPath || typeof transcriptPath !== 'string') return null;
65
- const parts = transcriptPath.split('/');
66
- const sessionFile = parts.pop(); // <session>.jsonl
67
- const slug = parts.pop(); // <project-slug>
68
- if (!sessionFile || !slug) return null;
69
- const session = sessionFile.replace(/\.jsonl$/, '');
70
- if (!session) return null;
71
- for (const base of ['/tmp', '/private/tmp']) {
72
- let dirs;
73
- try {
74
- dirs = readdirSync(base).filter((d) => d.startsWith('claude-'));
75
- } catch {
76
- continue;
77
- }
78
- for (const d of dirs) {
79
- const cand = join(base, d, slug, session, 'tasks');
80
- if (existsSync(cand)) return cand;
81
- }
82
- }
83
- } catch {
84
- /* fail-open */
85
- }
86
- return null;
87
- }
88
-
89
- /**
90
- * GROUND-TRUTH age (minutes) of an agent's last activity. Prefers the exact session's tasks
91
- * dir (fast, one statSync) when we have it; falls back to the session-independent glob whenever
92
- * the agent's `.output` isn't in THIS session's tasks dir — either there's no transcript_path,
93
- * OR the binding is from a PRIOR session (e.g. after a restart), where the cross-session glob is
94
- * what keeps anti-drop working across restarts. Returns null when no output file exists.
95
- * @param {string} agentId
96
- * @param {string|null} tasksDir
97
- * @param {number} now
98
- * @returns {number|null}
99
- */
100
- function agentAge(agentId, tasksDir, now) {
101
- if (tasksDir) {
102
- try {
103
- const st = statSync(join(tasksDir, `${agentId}.output`)); // follows the symlink → target mtime
104
- return (now - st.mtimeMs) / 60000;
105
- } catch {
106
- /* not in this session's tasks dir → fall through to the glob */
107
- }
108
- }
109
- return findAgentOutputAge(agentId, now);
110
- }
111
-
112
- /**
113
- * Compute thread-centric liveness lines, DERIVED purely from ground truth (newest-binding age +
114
- * rest log + thread status + merge-queue) — never a stored per-agent flag. At most ONE line per
115
- * thread, keyed on the thread's NEWEST agent only, with downstream (mid-merge) threads
116
- * suppressed. The loud "ACTIVE THREAD, NO LIVE AGENT" lines come first, then soft idle notes.
117
- * @param {{transcriptPath?: string|null, projectDir: string, now?: number}} args
118
- * @returns {string[]} reminder lines (possibly empty)
119
- */
120
- export function agentLivenessLines({ transcriptPath, projectDir, now = Date.now() }) {
121
- /** @type {string[]} */
122
- const dropped = [];
123
- /** @type {string[]} */
124
- const idle = [];
125
- try {
126
- const tasksDir = deriveTasksDir(transcriptPath); // may be null → agentAge falls back to glob
127
- const frizzDir = join(projectDir, '.frizz');
128
-
129
- // AUTOMATIC binding: the NEWEST agent serving each thread (a superseded older agent is
130
- // never considered). Plus the merge-cascade set (suppress mid-merge threads) and the rest
131
- // log (separate a parked agent from one still inside a long tool call).
132
- const newest = newestBindingByThread(projectDir);
133
- const downstream = downstreamThreads(projectDir);
134
- const rested = restedAgentIds(projectDir);
135
-
136
- let files;
137
- try {
138
- files = readdirSync(frizzDir).filter((f) => f.endsWith('.md') && !f.startsWith('_') && !f.startsWith('.'));
139
- } catch {
140
- return dropped;
141
- }
142
-
143
- for (const f of files) {
144
- const slug = f.replace(/\.md$/, '');
145
- const binding = newest.get(slug);
146
- if (!binding) continue; // no agent ever bound to this thread → nothing to judge
147
-
148
- let src;
149
- try {
150
- src = readFileSync(join(frizzDir, f), 'utf8');
151
- } catch {
152
- continue;
153
- }
154
- const threadStatus = src.match(/^status:\s*(\S+)/m)?.[1] ?? '';
155
- const threadTerminal = TERMINAL_THREAD.has(threadStatus);
156
- const threadActive = threadStatus === 'active'; // ONLY active threads can strand an agent; parked phases holding a done agent are EXPECTED
157
- if (threadTerminal || !threadActive) continue;
158
- // PR landing via the cascade → legitimately active, suppress. Skip BEFORE agentAge so a
159
- // mid-merge thread never pays the (potentially full-/tmp-glob) age lookup just to be
160
- // dropped by deriveAgentState's downstream short-circuit anyway.
161
- if (downstream.has(slug)) continue;
162
-
163
- const ageMin = agentAge(binding.id, tasksDir, now);
164
- const hasRested = rested.has(binding.id);
165
- const state = deriveAgentState({ ageMin, threadTerminal, threadActive, hasRested, idleMin: IDLE_MIN, droppedMin: DROPPED_MIN }); // downstream already short-circuited above
166
- const who = `${binding.label ? `${binding.label} ` : ''}[${binding.id.slice(0, 9)}]`;
167
-
168
- if (state === 'dropped') {
169
- dropped.push(`⚠ ACTIVE THREAD, NO LIVE AGENT: ${slug} — its newest agent ${who} has been quiet ${Math.round(ageMin ?? 0)}m with no PR/merge in flight, so it likely finished or dropped. Fold its report and flip the thread to done, or resume it (SendMessage ${binding.id.slice(0, 9)}) if it's still mid-task.`);
170
- } else if (state === 'idle') {
171
- idle.push(`frizz: thread ${slug} — agent ${who} quiet ${Math.round(ageMin ?? 0)}m. Fine if it's watching CI or mid-build; check in (SendMessage) if that's unexpected.`);
172
- }
173
- // 'terminal' (reconciled / parked / downstream), 'fresh' (working), 'unknown' (no file) → say nothing.
174
- }
175
- } catch {
176
- /* fail-open: return whatever we have */
177
- }
178
- return [...dropped, ...idle];
179
- }
180
-
181
- /**
182
- * The SHARED in-flight predicate: is a bound agent still live (not paused/done, not stale)?
183
- * "Not rested" is the primary signal — a rest is the ONLY completion mark, so its absence
184
- * means still-in-flight; age is the secondary guard — fresh output (age < DROPPED_MIN) OR no
185
- * output file yet (age == null → just launched). A quiet-past-DROPPED_MIN + never-rested agent
186
- * is the 'dropped' case agentLivenessLines flags, so it is NOT counted live here. Terminal-thread
187
- * exclusion is the caller's job (this predicate only judges the agent). One code path shared by
188
- * runningAgentCount and liveBoundAgentForThread so the two never drift.
189
- * @param {string} agentId
190
- * @param {string|null} tasksDir
191
- * @param {Set<string>} rested
192
- * @param {number} now
193
- * @returns {boolean}
194
- */
195
- function isAgentInFlight(agentId, tasksDir, rested, now) {
196
- if (rested.has(agentId)) return false;
197
- const ageMin = agentAge(agentId, tasksDir, now);
198
- return ageMin == null || ageMin < DROPPED_MIN;
199
- }
200
-
201
- /**
202
- * The single LIVE agent bound to `slug`, or null. "Live" = the thread's NEWEST binding, on a
203
- * non-terminal thread, still in flight per {@link isAgentInFlight} (not rested, not stale). Same
204
- * logic/thresholds as {@link runningAgentCount}, scoped to one thread — the thread-edit-steer
205
- * hook uses it to decide whether an orchestrator edit needs a SendMessage steer.
206
- * @param {{slug: string, transcriptPath?: string|null, projectDir: string, now?: number}} args
207
- * @returns {{id: string, label: string|null} | null}
208
- */
209
- export function liveBoundAgentForThread({ slug, transcriptPath, projectDir, now = Date.now() }) {
210
- try {
211
- const binding = newestBindingByThread(projectDir).get(slug);
212
- if (!binding) return null;
213
- let src;
214
- try {
215
- src = readFileSync(join(projectDir, '.frizz', `${slug}.md`), 'utf8');
216
- } catch {
217
- return null; // no thread file → nothing to steer
218
- }
219
- const threadStatus = src.match(/^status:\s*(\S+)/m)?.[1] ?? '';
220
- if (TERMINAL_THREAD.has(threadStatus)) return null; // done/dismissed → no live agent
221
- const tasksDir = deriveTasksDir(transcriptPath);
222
- if (!isAgentInFlight(binding.id, tasksDir, restedAgentIds(projectDir), now)) return null;
223
- return { id: binding.id, label: binding.label };
224
- } catch {
225
- return null; // fail-open
226
- }
227
- }
228
-
229
- /**
230
- * Count of dispatched agents currently RUNNING — the "Waiting for N background agents" case.
231
- * An agent counts as running when: it's the NEWEST binding for its thread, it has NOT rested
232
- * (no completion recorded → still in flight, not paused/done), its thread isn't terminal, and
233
- * it isn't a long-dead stale binding. "Not rested" is the primary signal — a rest is the ONLY
234
- * completion mark, so its absence means the agent is still in flight; age is a secondary guard:
235
- * count when the output is fresh (age < DROPPED_MIN) OR there's no output file yet (age == null →
236
- * JUST launched, definitely running), and drop only the clearly-stale (quiet past DROPPED_MIN and
237
- * never rested → agentLivenessLines already flags that as 'dropped', so we don't double-count it
238
- * as "working"). This is DISTINCT from agentLivenessLines (which flags STRANDED active threads);
239
- * here we count live in-flight work so the Stop hook can surface "N still working" before the
240
- * unhookable idle-wait. Fail-open → 0. Never throws.
241
- * @param {{transcriptPath?: string|null, projectDir: string, now?: number}} args
242
- * @returns {number}
243
- */
244
- export function runningAgentCount({ transcriptPath, projectDir, now = Date.now() }) {
245
- try {
246
- const tasksDir = deriveTasksDir(transcriptPath);
247
- const frizzDir = join(projectDir, '.frizz');
248
- const newest = newestBindingByThread(projectDir);
249
- const rested = restedAgentIds(projectDir);
250
- let files;
251
- try {
252
- files = readdirSync(frizzDir).filter((f) => f.endsWith('.md') && !f.startsWith('_') && !f.startsWith('.'));
253
- } catch {
254
- return 0;
255
- }
256
- let count = 0;
257
- const seen = new Set();
258
- for (const f of files) {
259
- const slug = f.replace(/\.md$/, '');
260
- const binding = newest.get(slug);
261
- if (!binding || seen.has(binding.id)) continue; // one count per agent even if it serves >1 thread
262
- seen.add(binding.id);
263
- let src;
264
- try {
265
- src = readFileSync(join(frizzDir, f), 'utf8');
266
- } catch {
267
- continue;
268
- }
269
- const threadStatus = src.match(/^status:\s*(\S+)/m)?.[1] ?? '';
270
- if (TERMINAL_THREAD.has(threadStatus)) continue; // done/dismissed → not running
271
- if (isAgentInFlight(binding.id, tasksDir, rested, now)) count++; // shared predicate (not rested + fresh/just-launched)
272
- }
273
- return count;
274
- } catch {
275
- return 0;
276
- }
277
- }
278
-
279
- /**
280
- * The high-confidence subset of {@link agentLivenessLines}: ONLY the "ACTIVE THREAD, NO LIVE
281
- * AGENT" lines. Used by the per-turn reminder, where surfacing the soft idle notes every prompt
282
- * would be noise — but a genuinely stranded active thread SHOULD nag every turn until reconciled
283
- * (that is the anti-drop signal), and it's rare by construction, so it won't cry wolf.
284
- * @param {{transcriptPath?: string|null, projectDir: string, now?: number}} args
285
- * @returns {string[]}
286
- */
287
- export function strandedThreadLines(args) {
288
- return agentLivenessLines(args).filter((l) => l.startsWith('⚠ ACTIVE THREAD'));
289
- }
290
-
291
- /**
292
- * THE WATCHER/AGENT DROP-GUARD (2026-07-06, the #327 forcing function). For each `active`,
293
- * non-downstream thread whose NEWEST agent was dispatched > LONG_RUNTIME_MIN ago AND is STILL
294
- * emitting output (age < DROPPED_MIN → looks alive) yet has produced NO terminal thread result,
295
- * emit a LOUD "VERIFY DIRECTLY" line. This is the case the existing 'dropped' signal CANNOT catch:
296
- * a `ci-watch` hung on a nameless ghost check keeps polling, so its output stays fresh and it never
297
- * looks stranded — it just never terminates, and "watcher running = fine" gets trusted for hours
298
- * (PR #327 sat effectively-green + stranded). The forcing function turns "a watcher can hang" from
299
- * a RULE into a hook-surfaced nudge: go check the target rollup YOURSELF.
300
- *
301
- * Runtime is measured from the binding `ts` (dispatch time), NOT output age — a watcher looks
302
- * "fresh" precisely because it is polling; the giveaway is the long total RUNTIME with no result.
303
- * Distinct from 'dropped' (stale + rested): the two bands don't overlap (this requires fresh
304
- * output, that requires stale). Structured return (slug/agentId/runtimeMin/tier/line) so a consumer
305
- * can dedupe by agentId AND re-arm per `tier` — `tier = floor(runtimeMin / LONG_RUNTIME_MIN)`, the
306
- * coarse 1×/2×/3× runtime multiple. Re-arming per tier is load-bearing for a PURE idle-wait (no
307
- * user prompts → the per-turn reminder never fires): a permanent agent-id dedup would block the
308
- * idle exactly ONCE at ~1× and let a genuinely-hung watcher be rationalized as "still fine" forever
309
- * (the #327 trap); re-blocking at each new tier forces a multi-hour hung watcher back into view
310
- * while a normal long-but-progressing agent still only crosses a tier occasionally. Fail-open → [].
311
- * @param {{transcriptPath?: string|null, projectDir: string, now?: number}} args
312
- * @returns {{slug:string, agentId:string, runtimeMin:number, tier:number, line:string}[]}
313
- */
314
- export function longRunningAgentLines({ transcriptPath, projectDir, now = Date.now() }) {
315
- /** @type {{slug:string, agentId:string, runtimeMin:number, line:string}[]} */
316
- const out = [];
317
- try {
318
- const tasksDir = deriveTasksDir(transcriptPath);
319
- const frizzDir = join(projectDir, '.frizz');
320
- const newest = newestBindingByThread(projectDir);
321
- const downstream = downstreamThreads(projectDir);
322
- let files;
323
- try {
324
- files = readdirSync(frizzDir).filter((f) => f.endsWith('.md') && !f.startsWith('_') && !f.startsWith('.'));
325
- } catch {
326
- return out;
327
- }
328
- for (const f of files) {
329
- const slug = f.replace(/\.md$/, '');
330
- const binding = newest.get(slug);
331
- if (!binding) continue;
332
- let src;
333
- try {
334
- src = readFileSync(join(frizzDir, f), 'utf8');
335
- } catch {
336
- continue;
337
- }
338
- const threadStatus = src.match(/^status:\s*(\S+)/m)?.[1] ?? '';
339
- if (threadStatus !== 'active') continue; // only an active thread can strand a running agent
340
- if (downstream.has(slug)) continue; // PR landing via the cascade → legitimately long, suppress
341
- const dispatchedMs = Date.parse(binding.ts ?? '');
342
- if (!Number.isFinite(dispatchedMs)) continue; // no dispatch time → can't judge runtime
343
- const runtimeMin = (now - dispatchedMs) / 60_000;
344
- if (runtimeMin <= LONG_RUNTIME_MIN) continue; // not long-running yet
345
- const ageMin = agentAge(binding.id, tasksDir, now);
346
- // Must still LOOK alive (fresh output): a STALE agent is the 'dropped' case, not this one; a
347
- // null age (no output file → likely a dead prior-session binding) can't confirm alive → skip.
348
- if (ageMin == null || ageMin >= DROPPED_MIN) continue;
349
- const who = `${binding.label ? `${binding.label} ` : ''}[${binding.id.slice(0, 9)}]`;
350
- out.push({
351
- slug,
352
- agentId: binding.id,
353
- runtimeMin: Math.round(runtimeMin),
354
- tier: Math.floor(runtimeMin / LONG_RUNTIME_MIN), // coarse 1×/2×/3× runtime multiple → per-tier re-arm
355
- line:
356
- `⚠ VERIFY DIRECTLY — ${slug}: agent ${who} has run ${Math.round(runtimeMin)}m with NO terminal result ` +
357
- `(last output ${Math.round(ageMin)}m ago, so it LOOKS alive). A watcher can HANG on a stuck/ghost CI check ` +
358
- `(a nameless check-run that never reports) and look alive while stranded — check its PR/target rollup YOURSELF ` +
359
- `(e.g. \`gh pr view <n> --json statusCheckRollup -q '.statusCheckRollup[]|select(.status!="COMPLETED")'\`) and act; ` +
360
- `do NOT trust that it's still progressing.`,
361
- });
362
- }
363
- } catch {
364
- /* fail-open */
365
- }
366
- return out;
367
- }
@@ -1,90 +0,0 @@
1
- // @ts-check
2
- // Shared storage + rendering for the frizz durable notification queue. Imported by both the
3
- // CLI (`notify.mjs`) and the Stop hook (`frizz-notify-surface.mjs`) so the on-disk shape and
4
- // the human-facing markdown render are defined in ONE place and can't drift.
5
- //
6
- // Queue item shape (one JSON object per line in `.frizz/notify-queue.jsonl`):
7
- // { id, ts, kind, title, body, status: "open"|"dismissed", surfaced: bool }
8
- // `title` is a short heading; `body` is the prose context the human reads to decide.
9
- // Legacy items carry a single `text` field instead of title/body — the renderer degrades
10
- // gracefully (derives a heading from the first clause, keeps the rest as the body).
11
- import { readFileSync, writeFileSync, mkdirSync } from 'node:fs';
12
- import { existsSync } from 'node:fs';
13
- import { dirname } from 'node:path';
14
-
15
- export const KINDS = new Set(['WIN', 'DECISION', 'BLOCKER', 'FYI']);
16
-
17
- // Section order is deliberate: what the human must ACT on first (blockers, decisions),
18
- // then what's purely informational (wins, fyi).
19
- const SECTIONS = [
20
- ['BLOCKER', 'Blockers'],
21
- ['DECISION', 'Decisions'],
22
- ['WIN', 'Wins'],
23
- ['FYI', 'FYI'],
24
- ];
25
-
26
- /** @param {string} file @returns {any[]} */
27
- export function readQueue(file) {
28
- if (!existsSync(file)) return [];
29
- return readFileSync(file, 'utf8')
30
- .split('\n')
31
- .filter((l) => l.trim())
32
- .map((l) => {
33
- try {
34
- return JSON.parse(l);
35
- } catch {
36
- return null;
37
- }
38
- })
39
- .filter(Boolean);
40
- }
41
-
42
- /** @param {string} file @param {any[]} items */
43
- export function writeQueue(file, items) {
44
- mkdirSync(dirname(file), { recursive: true });
45
- writeFileSync(file, items.map((i) => JSON.stringify(i)).join('\n') + (items.length ? '\n' : ''));
46
- }
47
-
48
- function titleOf(i) {
49
- if (i.title) return String(i.title).trim();
50
- const t = String(i.text || '').trim();
51
- const head = t.split(/ — | – |: |\. /)[0] || t; // legacy: first clause as the heading
52
- return head.slice(0, 90).trim();
53
- }
54
-
55
- function bodyOf(i) {
56
- if (i.body != null) return String(i.body).trim();
57
- if (i.title) return '';
58
- const t = String(i.text || '').trim();
59
- const ti = titleOf(i);
60
- return t.startsWith(ti) ? t.slice(ti.length).replace(/^[\s—–:.-]+/, '').trim() : t;
61
- }
62
-
63
- /**
64
- * Render the OPEN items as scannable, sectioned markdown for the human — grouped by kind,
65
- * each item a `###` heading + its prose body + a subtle id tag. This is the surface the
66
- * human reads to decide; it is NOT a terse log line. (Authors should write each item's
67
- * title/body per the prose skill — terse, factual, enough context to decide.)
68
- * @param {any[]} open @returns {string}
69
- */
70
- export function renderMarkdown(open) {
71
- const n = open.length;
72
- const intro =
73
- `📌 ${n} item${n === 1 ? '' : 's'} waiting on you — surfaced here so they don't scroll away. ` +
74
- `Nothing to run in a terminal: just tell me your call in chat and I'll clear each one.`;
75
-
76
- const parts = [intro];
77
- for (const [kind, heading] of SECTIONS) {
78
- const rows = open.filter((i) => i.kind === kind);
79
- if (!rows.length) continue;
80
- parts.push(`\n## ${heading}`);
81
- for (const i of rows) {
82
- const title = titleOf(i);
83
- const body = bodyOf(i);
84
- let block = `\n### ${title} · ${i.id}`;
85
- if (body) block += `\n\n${body}`;
86
- parts.push(block);
87
- }
88
- }
89
- return parts.join('\n');
90
- }
@@ -1,81 +0,0 @@
1
- #!/usr/bin/env node
2
- // @ts-check
3
- // frizz notify — a DURABLE, human-facing notification queue for the orchestrator.
4
- //
5
- // The problem it fixes: in a long autonomous session, the things the human most needs to
6
- // see — a headline WIN that landed, a DECISION that's genuinely theirs, a BLOCKER — get
7
- // buried under per-turn status churn and scroll out of reach. This queue is written the
8
- // instant something noteworthy happens, persists until DISMISSED, and is re-surfaced when
9
- // the orchestrator goes idle by the companion Stop hook (`hooks/frizz-notify-surface.mjs`).
10
- //
11
- // The hook SURFACES each item to the human directly (rich, sectioned markdown via
12
- // `systemMessage`). The orchestrator does NOT relay or regurgitate the queue in chat — the
13
- // human already sees it. The orchestrator's only job is to DISMISS an item once the human
14
- // has addressed it in conversation (the human has no terminal): `frizz-notify dismiss <id>`.
15
- //
16
- // Each item carries a short `title` (the heading the human scans) and a prose `body` (the
17
- // context they read to decide) — author BOTH per the prose skill: terse, factual, enough to
18
- // make the call without opening a file. Storage: the PROJECT's `.frizz/notify-queue.jsonl`
19
- // (resolved from CLAUDE_PROJECT_DIR, or cwd when run by hand), one JSON object per line:
20
- // {id, ts, kind, title, body, status: "open"|"dismissed", surfaced: bool}
21
- // kind ∈ WIN | DECISION | BLOCKER | FYI. `surfaced` is stamped by the Stop hook once it has
22
- // shown the item, so a new item interrupts idle exactly once, then persists quietly.
23
- //
24
- // Usage (bare command on PATH via bin/frizz-notify while the plugin is enabled):
25
- // frizz-notify add <WIN|DECISION|BLOCKER|FYI> "<title>" "<body>" # body optional; prints the id
26
- // frizz-notify list [--all] # rendered markdown (open, or all)
27
- // frizz-notify dismiss <id>[ <id> ...] | --all
28
- // Robust: a malformed queue line is skipped, never fatal.
29
- import { join } from 'node:path';
30
- import { KINDS, readQueue, writeQueue, renderMarkdown } from './notify-shared.mjs';
31
-
32
- const PROJECT_DIR = process.env.CLAUDE_PROJECT_DIR || process.cwd();
33
- const QUEUE = join(PROJECT_DIR, '.frizz', 'notify-queue.jsonl');
34
-
35
- function newId(items) {
36
- const n = items.reduce((m, i) => Math.max(m, Number(String(i.id).replace(/\D/g, '')) || 0), 0);
37
- return 'n' + (n + 1);
38
- }
39
-
40
- function main() {
41
- const [cmd, ...rest] = process.argv.slice(2);
42
- const items = readQueue(QUEUE);
43
-
44
- if (cmd === 'add') {
45
- const kind = (rest[0] || '').toUpperCase();
46
- const title = (rest[1] || '').trim();
47
- const body = rest.slice(2).join(' ').trim();
48
- if (!KINDS.has(kind) || !title) {
49
- console.error('usage: frizz-notify add <WIN|DECISION|BLOCKER|FYI> "<title>" "<body>"');
50
- process.exit(1);
51
- }
52
- const id = newId(items);
53
- items.push({ id, ts: new Date().toISOString(), kind, title, body, status: 'open', surfaced: false });
54
- writeQueue(QUEUE, items);
55
- console.log(id);
56
- } else if (cmd === 'list') {
57
- const all = rest.includes('--all');
58
- const rows = items.filter((i) => all || i.status === 'open');
59
- console.log(rows.length ? renderMarkdown(rows) : '(no notifications)');
60
- } else if (cmd === 'dismiss') {
61
- const all = rest.includes('--all');
62
- const ids = new Set(rest);
63
- let n = 0;
64
- for (const i of items) {
65
- if (i.status === 'open' && (all || ids.has(i.id))) {
66
- i.status = 'dismissed';
67
- n++;
68
- }
69
- }
70
- writeQueue(QUEUE, items);
71
- console.log(`dismissed ${n}`);
72
- } else {
73
- console.error('usage: frizz-notify <add|list|dismiss> …');
74
- process.exit(1);
75
- }
76
- }
77
-
78
- // Run the CLI. This module is the command entry point (invoked directly as `node notify.mjs`
79
- // or via the bin shim's dynamic import); helpers live in notify-shared.mjs, so nothing imports
80
- // this file for its functions — running unconditionally is correct.
81
- main();