claude-code-session-manager 0.37.0 → 0.37.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (38) hide show
  1. package/bin/cli.cjs +12 -1
  2. package/dist/assets/{TiptapBody-Cg8YZhVZ.js → TiptapBody-BtrSXTRp.js} +1 -1
  3. package/dist/assets/index-CD_LuJZF.css +32 -0
  4. package/dist/assets/{index-_iBXLuvt.js → index-uVGdpAGF.js} +498 -490
  5. package/dist/index.html +2 -2
  6. package/package.json +2 -1
  7. package/plugins/session-manager-dev/skills/develop/SKILL.md +134 -36
  8. package/plugins/session-manager-dev/skills/develop/standards.md +24 -0
  9. package/plugins/session-manager-dev/skills/requesting-code-review/SKILL.md +20 -17
  10. package/scripts/lib/activeSessions.cjs +117 -0
  11. package/scripts/lib/watchdogHelpers.cjs +829 -0
  12. package/src/main/__tests__/classifyTranscriptLine.test.cjs +90 -0
  13. package/src/main/__tests__/docEdit.test.cjs +164 -2
  14. package/src/main/__tests__/prdCreate.test.cjs +265 -25
  15. package/src/main/__tests__/scheduler-admin-routes.test.cjs +150 -0
  16. package/src/main/__tests__/scheduler-boot-orphans.test.cjs +172 -0
  17. package/src/main/browserAgentServer.cjs +11 -10
  18. package/src/main/chatRunner.cjs +21 -2
  19. package/src/main/docEdit.cjs +125 -5
  20. package/src/main/health.cjs +15 -0
  21. package/src/main/index.cjs +12 -6
  22. package/src/main/ipcSchemas.cjs +14 -0
  23. package/src/main/lib/__tests__/localAdminHttp.test.cjs +120 -0
  24. package/src/main/lib/classifyTranscriptLine.cjs +89 -0
  25. package/src/main/lib/localAdminHttp.cjs +157 -0
  26. package/src/main/lib/personaImportHealth.cjs +161 -0
  27. package/src/main/lib/prdCreate.cjs +107 -17
  28. package/src/main/lib/rcaFeedbackHook.cjs +2 -2
  29. package/src/main/lib/singleInstanceGuard.cjs +20 -0
  30. package/src/main/scheduler.cjs +198 -54
  31. package/src/main/templates/PRD_AUTHORING.md +4 -4
  32. package/src/main/transcripts.cjs +1 -85
  33. package/src/preload/api.d.ts +12 -1
  34. package/src/preload/index.cjs +6 -0
  35. package/dist/assets/index-CTTjT08J.css +0 -32
  36. package/plugins/session-manager-dev/skills/security-review/SKILL.md +0 -105
  37. package/src/main/__tests__/adminServer.test.cjs +0 -380
  38. package/src/main/adminServer.cjs +0 -242
package/dist/index.html CHANGED
@@ -7,10 +7,10 @@
7
7
  <link rel="preconnect" href="https://fonts.googleapis.com">
8
8
  <link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
9
9
  <link href="https://fonts.googleapis.com/css2?family=Newsreader:ital,opsz,wght@0,6..72,400;0,6..72,500;0,6..72,600;0,6..72,700;1,6..72,400&family=Geist:wght@300;400;500;600;700&family=IBM+Plex+Mono:wght@400;500;600&display=swap" rel="stylesheet">
10
- <script type="module" crossorigin src="./assets/index-_iBXLuvt.js"></script>
10
+ <script type="module" crossorigin src="./assets/index-uVGdpAGF.js"></script>
11
11
  <link rel="modulepreload" crossorigin href="./assets/monaco-editor-BW5C4Iv1.js">
12
12
  <link rel="stylesheet" crossorigin href="./assets/monaco-editor-BTnBOi8r.css">
13
- <link rel="stylesheet" crossorigin href="./assets/index-CTTjT08J.css">
13
+ <link rel="stylesheet" crossorigin href="./assets/index-CD_LuJZF.css">
14
14
  </head>
15
15
  <body class="bg-bg text-fg font-sans antialiased">
16
16
  <div id="root"></div>
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "claude-code-session-manager",
3
- "version": "0.37.0",
3
+ "version": "0.37.2",
4
4
  "description": "Local cockpit for the Claude Code CLI — multi-tab terminal, full config surface, scheduler, voice dictation, and live observability.",
5
5
  "type": "module",
6
6
  "main": "src/main/index.cjs",
@@ -12,6 +12,7 @@
12
12
  ".claude-plugin/",
13
13
  "plugins/",
14
14
  "scripts/postinstall.cjs",
15
+ "scripts/lib/",
15
16
  "src/main/",
16
17
  "src/preload/",
17
18
  "dist/index.html",
@@ -2,9 +2,9 @@
2
2
  name: develop
3
3
  description: >-
4
4
  Lead a software-development task by decomposing a feature/refactor/bugfix prompt into a
5
- series of self-contained PRDs queued for the session-manager scheduler, each carrying the
6
- engineering standards inline so the headless executor honors them — then track those PRDs
7
- to completion, verify them against their acceptance criteria, and report back. Use whenever
5
+ series of self-contained PRDs queued for the session-manager scheduler, each pointing the
6
+ headless executor at the engineering standards file to read at runtime — then track those
7
+ PRDs to completion, verify them against their acceptance criteria, and report back. Use whenever
8
8
  the user says "/develop", "develop X", "build me X", "implement X", "let's code X", or
9
9
  otherwise starts dev work that should run as scheduled PRDs rather than inline now. This
10
10
  skill is the home for the developer-only guidance (performance, debugging, API-reuse, TDD)
@@ -41,16 +41,18 @@ The engineering standards (Performance, Debugging, API reuse / single source of
41
41
  and the executor-facing Execution discipline) live in **`standards.md`** beside this file, in
42
42
  the same skill directory (`.../skills/develop/standards.md` — NOT `~/.claude/skills/develop/`,
43
43
  which is a different, non-existent path; resolve it relative to wherever this SKILL.md itself
44
- was loaded from). **Re-read that file fresh with the Read tool immediately before pasting it
45
- into each PRD (Phase 1 step 4) — never reuse a copy cached earlier in the same conversation.**
46
- A long authoring session can span an edit to `standards.md` (including one autonomously applied
47
- by a prior incident's fix-plan) without the model noticing; pasting a stale in-context copy
48
- silently ships PRDs missing the latest execution-discipline rules. This is exactly the
49
- single-source-of-truth violation the standards themselves warn against don't let it happen to
50
- the standards block itself. (Incident: PRDs 467/468 authored late in a long session carried a
51
- standards.md snapshot from before the "You ARE the executor" guard was added earlier that same
52
- session, so PRD 467's headless run repeated the exact anti-pattern the guard exists to prevent.)
53
- Never restate or fork its content one concept, one implementation.
44
+ was loaded from).
45
+
46
+ **Reference it, don't embed it.** The headless executor (`claude -p`) runs on the same
47
+ filesystem this authoring session does, with full tool access so a PRD only needs to name
48
+ `standards.md`'s absolute path (resolved once, at authoring time, the same way this file already
49
+ resolves it) and instruct the executor to `Read` it before starting. There is now exactly one
50
+ copy of this text on disk, ever no pasted snapshot to go stale, and nothing to re-read fresh
51
+ before writing (an earlier version of this skill pasted the full contents into every PRD and had
52
+ to warn authors to re-read it fresh each time to avoid shipping a stale in-context copy — PRDs
53
+ 467/468 did exactly that and repeated an anti-pattern a guard added earlier the same session was
54
+ meant to prevent. Referencing by path removes the failure mode instead of warning against it).
55
+ Never restate or fork its content — one concept, one implementation, one location.
54
56
 
55
57
  For interactive dev work, also apply the `test-driven-development` and `systematic-debugging`
56
58
  skills; the headless PRDs get the distilled core from `standards.md` instead, since they
@@ -64,21 +66,85 @@ can't load skills.
64
66
  caller is `/process-feedback`, scope is already established by its evaluation — don't
65
67
  re-ask; build from the brief it hands you.)
66
68
 
67
- 2. **Explore the target repo.** Identify the absolute `cwd`, existing patterns/utilities to
68
- reuse (per the API-reuse standard — search before writing new code), the test command, and
69
- any constraints. Capture exact file paths and signatures; they go straight into the PRDs.
70
-
71
- 3. **Decompose into a series of SMALL, bounded PRDs.** Split a large ask into multiple PRDs and
72
- sequence them. To pick each PRD's `NN` (parallel group), **compute the highest in-use number
73
- deterministically never eyeball or narrow-grep the `ls`** (a narrowed pattern like
74
- `'^10[0-9]'` silently misses `110+` and collides):
69
+ 2. **Explore the target repo broadly, not just the obvious file.** Identify the absolute
70
+ `cwd`, existing patterns/utilities to reuse (per the API-reuse standard — search before
71
+ writing new code), the test command, and any constraints. Capture exact file paths and
72
+ signatures; they go straight into the PRDs. Don't stop at the first component that looks
73
+ relevant check its siblings too (does the same pattern appear in 2-3 similar components?
74
+ do they actually share the same shape, or only look similar confirm by reading, don't
75
+ assume: a wrong assumption here means an inaccurate PRD, discovered only after the executor
76
+ runs it), check existing tests for the area, and check whether a prior PRD already touched
77
+ this subsystem (`ls ~/.claude/session-manager/scheduled-plans/prds/` for related slugs) —
78
+ duplicating or contradicting a still-queued PRD is a real failure mode, not a hypothetical one.
79
+
80
+ 3. **Draft a candidate decomposition, then run a completeness pass before finalizing it.** This
81
+ step exists because small, bounded individual PRDs (step 4) are correct and non-negotiable —
82
+ but a *set* of small PRDs can still be incomplete if the upfront decomposition missed
83
+ something. Keeping PRDs small is not a substitute for getting the decomposition right; it's a
84
+ separate concern, and this step is where decomposition quality gets checked.
85
+ - For a **genuinely trivial ask** (one obvious PRD, no cross-file consequences) — skip
86
+ straight to step 4, no ceremony needed.
87
+ - For anything **larger than one or two obvious PRDs, or touching more than one
88
+ component/subsystem** — before finalizing, dispatch a second, independent agent (the Agent
89
+ tool, `subagent_type: "Explore"` or `"general-purpose"` — this is a single extra dispatch,
90
+ not the full multi-agent Workflow tool, and needs no special opt-in) with: the original ask
91
+ verbatim, your draft PRD list (titles + one-line goals), and the instruction to find what's
92
+ missing — uncovered edge cases, error-handling paths, tests, cross-file consequences,
93
+ components that share the same pattern but weren't included, anything the draft assumed
94
+ without verifying. Treat its findings as a second opinion to weigh, not an automatic
95
+ addition — fold real, concrete gaps into the PRD set (add, split, or adjust a PRD); dismiss
96
+ vague or speculative ones. For a large, multi-subsystem ask, it's fine to repeat this once
97
+ more after folding in the first round's findings (a second completeness pass on the revised
98
+ set) — stop once a pass turns up nothing new, don't loop indefinitely.
99
+ - **Check each drafted PRD against explicit concern dimensions, not just "does the feature
100
+ work"**: missing features/edge cases beyond the happy path, tests, security, and quality
101
+ (perf, error handling). This is where depth actually comes from — a decomposition that only
102
+ ever asks "what file does this touch" produces exactly the narrow, single-concern PRDs this
103
+ step exists to catch.
104
+ - **Tests and security are NOT separate follow-up PRDs — they are mandatory AC lines inside
105
+ the SAME PRD as the feature they belong to.** This is non-negotiable: `standards.md`'s TDD
106
+ rule requires the test before/with the implementation, not after, and a security concern
107
+ (input validation at a boundary, auth checks, no string-built queries) is a decision made
108
+ while writing the code — a later "security review PRD" would just end up re-touching the
109
+ same lines, doubling work and leaving the shipped code insecure in the meantime. Every
110
+ feature PRD's own Acceptance Criteria must include its test command AND, when it touches
111
+ input/auth/data, the relevant security checks — don't spin these out.
112
+ - **Genuinely separable work MAY become its own sibling PRD**: deeper edge-case coverage
113
+ beyond what the core AC needs to prove correctness, performance/observability hardening,
114
+ docs. Splitting these out is exactly the "more isolated, narrower PRDs" instinct — apply
115
+ it here, where a dedicated PRD adds real value, not to tests/security where it subtracts
116
+ from correctness.
117
+ - This is a planning-quality step, not an execution step — it happens entirely in the
118
+ interactive main-loop session, before anything gets written to disk or queued.
119
+
120
+ 4. **Decompose into a series of SMALL, bounded PRDs.** Split the (now completeness-checked)
121
+ decomposition into individually small PRDs and sequence them.
122
+
123
+ **Prefer creating each PRD via the `scheduler_create_prd` MCP tool**
124
+ (`mcp__session-manager-scheduler__scheduler_create_prd`) over hand-writing the file. Its input
125
+ (`title`, `cwd`, `estimateMinutes`, `goal`, `acceptanceCriteria[]`, `implementationNotes`,
126
+ `outOfScope[]`) maps directly onto the sections below — pass them straight through. It
127
+ allocates the parallel-group `NN` atomically (no read-then-write race against another
128
+ concurrent `/develop`/`/process-feedback` invocation), derives and collision-checks the slug,
129
+ and embeds the standards pointer for you. Set `parallelGroup` explicitly only when this PRD
130
+ must share an existing sibling's `NN` (a logically independent PRD that can run in parallel
131
+ with one already queued); omit it to get the next free `NN` atomically.
132
+
133
+ **Fallback — only when the tool errors with "app not running" / admin API unreachable**
134
+ (the session-manager Electron app must be running for this MCP tool to work; if it isn't,
135
+ don't block on it): compute the highest in-use number deterministically yourself — never
136
+ eyeball or narrow-grep the `ls` (a narrowed pattern like `'^10[0-9]'` silently misses `110+`
137
+ and collides):
75
138
  ```bash
76
139
  ls ~/.claude/session-manager/scheduled-plans/prds/ | grep -oE '^[0-9]+' | sort -n | uniq | tail -5
77
140
  ```
78
141
  The last line is the current max. Then: same `NN` as a logically independent sibling that
79
142
  can run in parallel; **next free `NN` = max+1** when this PRD hard-depends on prior work or
80
- is unrelated to every existing group. Record each cross-PRD dependency in the dependent
81
- PRD's notes.
143
+ is unrelated to every existing group. This manual path has a small, accepted race (two
144
+ concurrent authors could compute the same "next free" `NN`) — cosmetic (two unrelated groups
145
+ end up sharing a number) rather than destructive, and only reachable when the atomic tool
146
+ path above isn't available. Record each cross-PRD dependency in the dependent PRD's notes
147
+ either way.
82
148
 
83
149
  ### PRD structure and location
84
150
 
@@ -166,12 +232,24 @@ can't load skills.
166
232
  failure** — it's the scheduler's designed auto-pause; the job auto-resumes at the next
167
233
  window reset. Don't add retry logic for it.
168
234
 
169
- 4. **Emit each PRD** to the canonical path and structure above, then **append `## Engineering
170
- standards` and paste the full contents of `standards.md` verbatim.** This is the
171
- load-bearing step it's the only way the standards (incl. Execution discipline) reach the
172
- headless run. Honor the `PRD_AUTHORING.md` §10 pre-queue checklist.
235
+ 5. **Emit each PRD.** If you used `scheduler_create_prd`, this step is already done the tool
236
+ wrote the file to the canonical path with the standards pointer included; skip to step 5.
237
+ **Fallback path only:** write to the canonical path and structure above, then **append `##
238
+ Engineering standards` with a one-line pointer**, not the file's contents:
239
+ ```markdown
240
+ ## Engineering standards
241
+
242
+ Before writing any code, read `<absolute path to standards.md, resolved above>` — it has the
243
+ Performance, Debugging, API-reuse, TDD, and Execution-discipline rules that apply to this PRD.
244
+ Every rule in it is mandatory, especially Execution discipline (bounded commands, verify
245
+ before done, the finish-protocol sentinel).
246
+ ```
247
+ This is the load-bearing step — it's the only way the standards (incl. Execution discipline)
248
+ reach the headless run, and it now stays current automatically since the executor reads the
249
+ live file rather than a snapshot taken at authoring time. Honor the `PRD_AUTHORING.md` §10
250
+ pre-queue checklist.
173
251
 
174
- 5. **Confirm to the user**, per emitted PRD: filename, chosen `NN` + rationale
252
+ 6. **Confirm to the user**, per emitted PRD: filename, chosen `NN` + rationale
175
253
  (parallel-with-X / serial-after-Y), `cwd`, and an ETA + token-cost ballpark. Note they can
176
254
  "Run now" in the SchedulePanel or wait for `when-available` polling.
177
255
 
@@ -181,7 +259,7 @@ The queued PRDs run headlessly and can take a while. Don't fire-and-forget, and
181
259
  hand off to a recurring check. `/process-feedback` delegates to this exact phase, so it is the
182
260
  single definition of "tracked to done" for both entry paths.
183
261
 
184
- 6. **Watch the scheduler every ~30 min.** Start a 30-minute monitoring loop (`/loop 30m` over
262
+ 7. **Watch the scheduler every ~30 min.** Start a 30-minute monitoring loop (`/loop 30m` over
185
263
  this watch step, or a `ScheduleWakeup` at 1800s if self-pacing) scoped to the PRD ids you
186
264
  emitted. On each tick, read the scheduler's job status (queue + run history under
187
265
  `~/.claude/session-manager/scheduled-plans/`, or the SchedulePanel) and branch:
@@ -195,22 +273,42 @@ single definition of "tracked to done" for both entry paths.
195
273
  your report rather than re-deriving the analysis, and let `/process-feedback` fold its
196
274
  prevention hint back into future PRD authoring. A `rateLimited` exit-1 is the
197
275
  scheduler's benign auto-pause (auto-resumes next window) — keep waiting, don't escalate.
198
- - **All PRDs completed successfully** — go to step 7.
276
+ - **All PRDs completed successfully** — go to step 8.
199
277
 
200
- 7. **Gate: definition of done** (same for both entry paths). Once the code has landed:
278
+ 8. **Gate: definition of done** (same for both entry paths). Once the code has landed:
201
279
  - **Verify live against each PRD's acceptance criteria** — run the health check, hit the
202
280
  endpoint, show before/after. The headless run asserted its own test command; this is the
203
281
  interactive confirmation it actually does what was asked.
204
- - For a **major feature or risky change**, dispatch a review via the
205
- `requesting-code-review` skill before calling it done; fix Critical/Important findings.
206
- - **Report back**: what landed, PRD/commit refs, verification result, anything left open.
282
+ - **Route to the specialist that actually matches what changed** not always the generic
283
+ reviewer. This environment has dedicated agents that sit unused unless explicitly called;
284
+ match the PRD's surface to the right one before calling a major/risky change done:
285
+ - Touches an API's request/response shape, REST/GraphQL contract, or endpoint design →
286
+ dispatch `api-designer` (Agent tool).
287
+ - Touches auth, input handling, secrets, or data storage → dispatch `security-auditor` in
288
+ addition to the mandatory security AC the PRD's own execution already required — the
289
+ auditor catches what the executor's self-check might miss.
290
+ - Is a structural refactor (no behavior change intended) → dispatch `refactorer`.
291
+ - Is performance-sensitive or touches a hot path → dispatch `perf-profiler`.
292
+ - Adds or updates a dependency → dispatch `dependency-auditor`.
293
+ - Touches a database schema, migration, or table design → **no specialist exists for this
294
+ in this environment today.** Don't silently let the generic code-reviewer stand in for a
295
+ schema review it isn't specialized for — say so explicitly in your report ("schema change,
296
+ no dedicated reviewer available, manual review recommended") rather than implying coverage
297
+ that isn't there.
298
+ - Anything else, or a **major feature/risky change** not covered above — dispatch the
299
+ generic `requesting-code-review` skill (`code-reviewer` agent) as the default.
300
+ Fix Critical/Important findings from whichever specialist(s) ran before calling it done.
301
+ - **Report back**: what landed, PRD/commit refs, which specialist(s) reviewed it (or the
302
+ explicit "no specialist available" note), verification result, anything left open.
207
303
 
208
304
  ## References (reuse, don't duplicate)
209
305
 
210
306
  - `~/.claude/session-manager/scheduled-plans/PRD_AUTHORING.md` — the §1–§10 safety rules.
211
- - `standards.md` beside this file — the engineering + execution-discipline rules inlined into every PRD. Re-read fresh each time (see "Standards" above) don't reuse a cached copy.
307
+ - `standards.md` beside this file — the engineering + execution-discipline rules. Every PRD points the executor at its absolute path (see "Standards" above) rather than embedding a copy.
212
308
  - `test-driven-development`, `systematic-debugging` — interactive dev sessions.
213
- - `requesting-code-review` — the Phase-2 review gate.
309
+ - `requesting-code-review` — the Phase-2 default review gate; `api-designer`, `security-auditor`,
310
+ `refactorer`, `perf-profiler`, `dependency-auditor` — specialist agents routed to by surface
311
+ area (see step 8) rather than always defaulting to the generic reviewer.
214
312
 
215
313
  ## Notes
216
314
 
@@ -50,6 +50,30 @@
50
50
  - (Interactive sessions: the `test-driven-development` skill has the full red-green-refactor
51
51
  workflow. Headless PRD runs can't load it — the three rules above are the load-bearing core.)
52
52
 
53
+ ## Visual design (UI/visual acceptance criteria)
54
+
55
+ When a PRD's acceptance criteria touch UI or visual output and no design brief is given,
56
+ resolve the visual direction in this priority order — never substitute a generic default when
57
+ a higher-priority source exists:
58
+
59
+ 1. **User-supplied design.** If the PRD or the conversation that spawned it includes a design
60
+ brief, mockup, brand palette, or explicit visual direction, use it verbatim.
61
+ 2. **Existing project design system.** Before reaching for any external skill, check the repo
62
+ itself for an existing theme — CSS custom-property blocks, `tailwind.config.js`, a
63
+ design-tokens file, a component library already in use. Reuse and extend what's there
64
+ rather than introducing a second visual language into the same project.
65
+ 3. **Only if neither exists**, invoke a design-oriented skill rather than eyeballing colors
66
+ from memory or hand-picking hex values (e.g. the bundled `dataviz` skill for
67
+ chart/table/dashboard work, or a `frontend-design`-class skill for overall aesthetic
68
+ direction) — and **render + screenshot both light and dark color-scheme modes** before
69
+ calling the work done. A palette validator that checks categorical/series colors does not
70
+ cover surrounding chrome tokens (panel/page/border) — those need their own contrast check
71
+ (WCAG relative luminance) and a visual look in each mode. "I checked light mode" is not "I
72
+ checked dark mode"; verify both, don't assume palette-reference hex values are safe by
73
+ construction. (Incident: a dashboard shipped with panel/page background contrast of
74
+ 1.12:1 and a border at 1.34:1 in dark mode — both invisible — because only light mode was
75
+ ever rendered before the work was marked done.)
76
+
53
77
  ## Execution discipline (headless runs)
54
78
 
55
79
  Data-driven from 400+ scheduler runs: long hangs (not bad code) are the dominant real failure, and "exited clean but left a red test" is the top verifier downgrade. These rules run at execution time — they are inlined into every PRD because the headless executor reads nothing else.
@@ -5,7 +5,7 @@ description: Use when completing tasks, implementing major features, or before m
5
5
 
6
6
  # Requesting Code Review
7
7
 
8
- Dispatch superpowers:code-reviewer subagent to catch issues before they cascade.
8
+ Dispatch the native `code-reviewer` subagent (via the Agent tool, `subagent_type: "code-reviewer"`) to catch issues before they cascade.
9
9
 
10
10
  **Core principle:** Review early, review often.
11
11
 
@@ -31,7 +31,7 @@ HEAD_SHA=$(git rev-parse HEAD)
31
31
 
32
32
  **2. Dispatch code-reviewer subagent:**
33
33
 
34
- Use Task tool with superpowers:code-reviewer type, fill template at `code-reviewer.md`
34
+ Use the Agent tool with `subagent_type: "code-reviewer"`, filling the template at `code-reviewer.md`
35
35
 
36
36
  **Placeholders:**
37
37
  - `{WHAT_WAS_IMPLEMENTED}` - What you just built
@@ -56,7 +56,7 @@ You: Let me request code review before proceeding.
56
56
  BASE_SHA=$(git log --oneline | grep "Task 1" | head -1 | awk '{print $1}')
57
57
  HEAD_SHA=$(git rev-parse HEAD)
58
58
 
59
- [Dispatch superpowers:code-reviewer subagent]
59
+ [Dispatch code-reviewer subagent via the Agent tool]
60
60
  WHAT_WAS_IMPLEMENTED: Verification and repair functions for conversation index
61
61
  PLAN_OR_REQUIREMENTS: Task 2 from docs/plans/deployment-plan.md
62
62
  BASE_SHA: a7981ec
@@ -74,20 +74,23 @@ You: [Fix progress indicators]
74
74
  [Continue to Task 3]
75
75
  ```
76
76
 
77
- ## Integration with Workflows
78
-
79
- **Subagent-Driven Development:**
80
- - Review after EACH task
81
- - Catch issues before they compound
82
- - Fix before moving to next task
83
-
84
- **Executing Plans:**
85
- - Review after each batch (3 tasks)
86
- - Get feedback, apply, continue
87
-
88
- **Ad-Hoc Development:**
89
- - Review before merge
90
- - Review when stuck
77
+ ## Integration with /develop
78
+
79
+ This is the **default** reviewer at `/develop`'s Phase 2 done-gate (step 8) — but not the only
80
+ one. `/develop` routes to a matching specialist first when a PRD's surface calls for it
81
+ (`api-designer` for API-contract changes, `security-auditor` for auth/input/data, `refactorer`
82
+ for structural refactors, `perf-profiler` for hot-path changes, `dependency-auditor` for
83
+ dependency bumps) and only falls back to this generic reviewer for everything else or when no
84
+ specialist fits. Don't treat this skill as covering ground those specialists already own.
85
+
86
+ Since this project's actual unit of work is a scheduler PRD (not a live multi-task session), the
87
+ review point is per-PRD, at its own commit range — `BASE_SHA`/`HEAD_SHA` above are that PRD's
88
+ commit(s), not an arbitrary task boundary from a different workflow shape. Review:
89
+ - **After a PRD completes**, as part of `/develop`'s definition-of-done gate (step 8) — every
90
+ major/risky PRD, before calling it done.
91
+ - **When a PRD comes back `needs_review`** — read the scheduler's auto-filed RCA first
92
+ (`rcaFeedbackHook`'s `<date>-rca-<slug>-<runId>.md`), then use this review to confirm the fix
93
+ if one gets queued.
91
94
 
92
95
  ## Red Flags
93
96
 
@@ -0,0 +1,117 @@
1
+ 'use strict';
2
+
3
+ // activeSessions.cjs — returns distinct on-disk project cwds with an active
4
+ // session within maxAgeMin minutes. Used by the feedback sweep (PRD 102) to
5
+ // narrow scanning to projects the user is actually working in.
6
+ //
7
+ // Detection is transcript-based only (scans ~/.claude/projects/*/*.jsonl
8
+ // mtimes). It has zero dependency on ~/.claude/knowledge-log/prompts.jsonl,
9
+ // which PRD 356-retire purges along with its capture hook.
10
+
11
+ const fs = require('node:fs');
12
+ const os = require('node:os');
13
+ const path = require('node:path');
14
+
15
+ const HOME = os.homedir();
16
+
17
+ // Transcript reads only need the last line with a `cwd` field — a few dozen
18
+ // lines is always enough. 64 KB keeps peak RSS proportionate.
19
+ const TAIL_BYTES = 64 * 1024;
20
+
21
+ // Safety cap on distinct cwds to bound result set size. O(1) extra space.
22
+ const MAX_CWDS = 50;
23
+
24
+ /**
25
+ * readTailLines(filePath, maxBytes) → string[]
26
+ * Reads at most maxBytes from the END of filePath and splits into non-empty lines.
27
+ * O(1) in file size (bounded read). Returns [] on any I/O error.
28
+ */
29
+ function readTailLines(filePath, maxBytes) {
30
+ let buf;
31
+ try {
32
+ const stat = fs.statSync(filePath);
33
+ if (stat.size === 0) return [];
34
+ const readSize = Math.min(maxBytes, stat.size);
35
+ const fd = fs.openSync(filePath, 'r');
36
+ try {
37
+ buf = Buffer.alloc(readSize);
38
+ fs.readSync(fd, buf, 0, readSize, stat.size - readSize);
39
+ } finally {
40
+ fs.closeSync(fd);
41
+ }
42
+ } catch {
43
+ return [];
44
+ }
45
+ return buf.toString('utf8').split('\n').filter((l) => l.trim());
46
+ }
47
+
48
+ /**
49
+ * activeProjectCwds(maxAgeMin = 90, opts?) → string[]
50
+ *
51
+ * Returns distinct, on-disk project cwds that have an open/active session
52
+ * within the last maxAgeMin minutes.
53
+ *
54
+ * Sole detection path: scan ~/.claude/projects/*​/ for transcript *.jsonl
55
+ * files modified within maxAgeMin, read `cwd` from the last parseable line
56
+ * of the newest transcript per project dir.
57
+ * Complexity: O(P × L) over P project dirs, each bounded-tail read (64 KB).
58
+ *
59
+ * opts (for testing):
60
+ * projectsDir — override the default ~/.claude/projects path
61
+ */
62
+ function activeProjectCwds(maxAgeMin = 90, {
63
+ projectsDir = path.join(HOME, '.claude', 'projects'),
64
+ } = {}) {
65
+ const cutoffMs = Date.now() - maxAgeMin * 60 * 1000;
66
+ const seen = new Set();
67
+ const result = [];
68
+
69
+ function addCwd(cwd) {
70
+ if (!cwd || typeof cwd !== 'string') return;
71
+ if (seen.has(cwd) || result.length >= MAX_CWDS) return;
72
+ try { fs.statSync(cwd); } catch { return; } // must exist on disk
73
+ seen.add(cwd);
74
+ result.push(cwd);
75
+ }
76
+
77
+ // Scan ~/.claude/projects/*/ transcript *.jsonl files.
78
+ let slugs;
79
+ try { slugs = fs.readdirSync(projectsDir); } catch { return result; }
80
+
81
+ for (const slug of slugs) {
82
+ if (result.length >= MAX_CWDS) break;
83
+ const projDir = path.join(projectsDir, slug);
84
+ let entries;
85
+ try {
86
+ entries = fs.readdirSync(projDir).filter((f) => f.endsWith('.jsonl'));
87
+ } catch { continue; }
88
+
89
+ // Find the most recently modified transcript in this project dir.
90
+ let newestPath = null;
91
+ let newestMtimeMs = 0;
92
+ for (const tf of entries) {
93
+ const fp = path.join(projDir, tf);
94
+ try {
95
+ const st = fs.statSync(fp);
96
+ if (st.mtimeMs > newestMtimeMs) {
97
+ newestMtimeMs = st.mtimeMs;
98
+ newestPath = fp;
99
+ }
100
+ } catch { continue; }
101
+ }
102
+
103
+ if (!newestPath || newestMtimeMs < cutoffMs) continue;
104
+
105
+ // Read `cwd` from the last parseable line of the transcript.
106
+ const tlines = readTailLines(newestPath, TAIL_BYTES);
107
+ for (let i = tlines.length - 1; i >= 0; i--) {
108
+ let row;
109
+ try { row = JSON.parse(tlines[i]); } catch { continue; }
110
+ if (row.cwd) { addCwd(row.cwd); break; }
111
+ }
112
+ }
113
+
114
+ return result;
115
+ }
116
+
117
+ module.exports = { activeProjectCwds };