claude-code-session-manager 0.126.0 → 0.127.0

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 (75) hide show
  1. package/bin/cli.cjs +71 -9
  2. package/bin/supervise.cjs +84 -0
  3. package/dist/assets/{AgentLibrary-bzeuZN4F.js → AgentLibrary-DKQznr7o.js} +1 -1
  4. package/dist/assets/{Button-8dWfDDuQ.js → Button-CZXqmIiM.js} +1 -1
  5. package/dist/assets/{DataModel-D4ybBPZN.js → DataModel-piyV33To.js} +1 -1
  6. package/dist/assets/{History-hsztE6yh.js → History-BxwtrKF2.js} +1 -1
  7. package/dist/assets/{Hooks-CRmZMQaW.js → Hooks-DogeSPII.js} +1 -1
  8. package/dist/assets/{Library-Czt3Bojd.js → Library-BDt6EeQQ.js} +1 -1
  9. package/dist/assets/{ListDetail-Cr6Ct_WX.js → ListDetail-CwS-LKar.js} +1 -1
  10. package/dist/assets/{McpServers-CeXJ2bng.js → McpServers-D2HVljgS.js} +1 -1
  11. package/dist/assets/{Memory-caujO8O3.js → Memory-hNzuOGn8.js} +1 -1
  12. package/dist/assets/{Panel-D64i9tGz.js → Panel-BLDrsUeq.js} +1 -1
  13. package/dist/assets/{Permissions-DpWOIrvr.js → Permissions-DzZ5vaJW.js} +1 -1
  14. package/dist/assets/{Plugins-Bd1ekP5P.js → Plugins-Cz9yaxzG.js} +2 -2
  15. package/dist/assets/{ProvenanceBadge-B96A_uZf.js → ProvenanceBadge-CCgLO4m9.js} +1 -1
  16. package/dist/assets/{SaveBar-D0Y2t-Ao.js → SaveBar-Shmn699J.js} +1 -1
  17. package/dist/assets/{Scheduler-Y5_YbNrC.js → Scheduler-Bqr0WHNd.js} +1 -1
  18. package/dist/assets/{ScopeSwitcher-BmWA_dP9.js → ScopeSwitcher-CBx1fB5g.js} +1 -1
  19. package/dist/assets/{Settings-Bcf65bpL.js → Settings-Ci8in-yF.js} +1 -1
  20. package/dist/assets/{SkillReferenceGraph-BeSNXloA.js → SkillReferenceGraph-BWwljba8.js} +1 -1
  21. package/dist/assets/{Skills-DwnQKJVc.js → Skills-BON6o-c4.js} +1 -1
  22. package/dist/assets/{SystemPrompt-Dih6SCmL.js → SystemPrompt-D5epIYYs.js} +1 -1
  23. package/dist/assets/{TagLibrary-BZ-Kp10P.js → TagLibrary-C2qDZROJ.js} +1 -1
  24. package/dist/assets/{TiptapBody-C2nEUmF7.js → TiptapBody-SZhI3-bW.js} +1 -1
  25. package/dist/assets/{Toggle-Dw8-zNQo.js → Toggle-C_qFDG0g.js} +1 -1
  26. package/dist/assets/{ViewTabs-CoYPKGN-.js → ViewTabs-C9q5WCEd.js} +1 -1
  27. package/dist/assets/{historyTotals-BbKcNpV7.js → historyTotals-BCl7IOhY.js} +1 -1
  28. package/dist/assets/{index-DgPUERhe.js → index-CMIYLbPb.js} +73 -73
  29. package/dist/assets/{settingsSchema-6doG_61l.js → settingsSchema-BBrRBrBr.js} +1 -1
  30. package/dist/assets/{skillFrontmatter-BYMYWDfb.js → skillFrontmatter-B01qJk6N.js} +1 -1
  31. package/dist/assets/{useAgentsDirWatch-Cqabjieh.js → useAgentsDirWatch-CuR3GSjS.js} +1 -1
  32. package/dist/index.html +1 -1
  33. package/dist-web/app.js +307 -307
  34. package/package.json +1 -1
  35. package/plugins/session-manager-dev/skills/develop/SKILL.md +3 -2
  36. package/scripts/scheduler-mcp-server.cjs +39 -1
  37. package/src/main/build-info.json +4 -4
  38. package/src/main/chatRunner.cjs +37 -4
  39. package/src/main/crashDiagnostics.cjs +83 -8
  40. package/src/main/health.cjs +16 -5
  41. package/src/main/index.cjs +32 -0
  42. package/src/main/lib/chatBootRecovery.cjs +136 -0
  43. package/src/main/lib/chatInflight.cjs +88 -0
  44. package/src/main/lib/epic/epicDelegationStats.cjs +1 -0
  45. package/src/main/lib/epic/epicSweepValidator.cjs +60 -6
  46. package/src/main/lib/epic/epicValidationHook.cjs +14 -2
  47. package/src/main/lib/feedback-remote/macroAdminRoutes.cjs +71 -15
  48. package/src/main/lib/mcpToolCatalog.cjs +22 -3
  49. package/src/main/lib/persona-macro/builtinMacros.cjs +12 -1
  50. package/src/main/lib/persona-macro/macroLibrary.cjs +57 -3
  51. package/src/main/lib/persona-macro/shippedPersonaSeeds.cjs +11 -0
  52. package/src/main/lib/prd/prdCreate.cjs +5 -1
  53. package/src/main/lib/process/childWithLog.cjs +38 -95
  54. package/src/main/lib/process/memoryScope.cjs +140 -0
  55. package/src/main/lib/process/ozonePlatform.cjs +15 -0
  56. package/src/main/lib/process/procIdentity.cjs +10 -3
  57. package/src/main/lib/process/scopeOomPolicy.cjs +69 -0
  58. package/src/main/lib/scheduler/cpuSample.cjs +147 -0
  59. package/src/main/lib/scheduler/definitionOfDone.cjs +40 -0
  60. package/src/main/lib/scheduler/jobLeftovers.cjs +204 -0
  61. package/src/main/lib/scheduler/jobSupervisorRecord.cjs +2 -1
  62. package/src/main/lib/scheduler/loadGate.cjs +116 -45
  63. package/src/main/lib/scheduler/queueStore.cjs +5 -2
  64. package/src/main/lib/scheduler/schedulerBatch.cjs +10 -3
  65. package/src/main/lib/scheduler/schedulerConfig.cjs +7 -2
  66. package/src/main/lib/telemetry/crashTelemetry.cjs +8 -4
  67. package/src/main/scheduler/budget.cjs +31 -0
  68. package/src/main/scheduler/prdPaths.cjs +54 -0
  69. package/src/main/scheduler/reviewLadder.cjs +17 -0
  70. package/src/main/scheduler/starvation.cjs +22 -0
  71. package/src/main/scheduler.cjs +522 -68
  72. package/src/main/templates/PRD_AUTHORING.md +5 -2
  73. package/src/main/usage.cjs +4 -2
  74. package/src/preload/api.d.ts +12 -2
  75. package/src/seed/agents/demo-video-builder.md +62 -14
@@ -1,4 +1,4 @@
1
- <!-- PRD_AUTHORING.md v16 -->
1
+ <!-- PRD_AUTHORING.md v18 -->
2
2
  # PRD Authoring Guide — Scheduler Safety Rules
3
3
 
4
4
  Rule: every PRD you queue follows the rules below.
@@ -69,7 +69,7 @@ if (!found) {
69
69
  Rule: every PRD needs these fields.
70
70
  1. `title` — one line, plain English.
71
71
  2. `cwd` — the Epic's project root, as an absolute path or `~/…`. The API always sets it to the Epic's project, whatever you pass. To work in another project, open an Epic in that project. The folder must exist when you queue.
72
- 3. `estimateMinutes` — optional; omit it. A run without one gets its persona's `defaultEstimateMinutes`, else the 45-minute floor. Pass one only if the run legitimately needs longer. Most PRDs take 5–10 minutes (§8).
72
+ 3. `estimateMinutes` — optional; omit it. A run without one gets its persona's `defaultEstimateMinutes`, else the 45-minute floor. Pass one only if the run legitimately needs longer. A validator with no estimate is sized from the gates it must re-run. Most PRDs take 5–10 minutes (§8).
73
73
 
74
74
  `parallelGroup` is deprecated and ignored. `dependsOn: [<slug>, ...]` is the only ordering primitive.
75
75
 
@@ -132,6 +132,9 @@ The executor can't ask you anything: no `ScheduleWakeup`, Cron, Monitor, `AskUse
132
132
  Worktree reach: every PRD runs in an isolated git worktree holding tracked files plus `node_modules` and non-uv `.venv`/`venv` symlinked from the main checkout; pnpm projects (pnpm-lock.yaml) get a worktree-local `node_modules` installed offline from the store, and uv projects (uv.lock) get a worktree-local env built by an offline frozen `uv sync`, not a symlink. Why: a pnpm install through the symlink purged the main checkout's node_modules (Bilko-Game-Academy 2026-10-18). A step that needs gitignored runtime state (databases, `downloads/`, browser profiles, logs) or a live side effect must address the main checkout by absolute path (e.g. `$HOME/Projects/<repo>/...`), be artifact-only (a deliverable artifact + `artifactPaths`, no tracked edits), and `dependsOn` the PRD that lands its tracked edits. A project may declare `worktreeSetup` gate-syntax commands in a tracked `.session-manager.json` at the repo root; they run once per fresh job worktree and baseline scratch worktree, before the executor starts, with cwd = the worktree root (a project in a subfolder names it, e.g. `timeout 600 godot --headless --path game --import`). Setups run one at a time per project and are never skipped; they must write only inside the worktree (node_modules and non-uv venvs are symlinks into the main checkout). The outcome is the `[scheduler] worktree setup:` lines at the top of the run log plus `worktreeSetup` in the run's meta.json. Host crontab installs stay human-only (see §14).
133
133
  Why: burrow PRD 1516 halted because its relative `.venv` python against `downloads/fb-tracker.db`, `scripts/install-cron.sh` and `pipeline-cron.sh --now` resolved inside the worktree (no runtime state; install-cron would bake a temporary worktree path into crontab), while sibling 1494 succeeded the same day using an absolute main-checkout path and artifact-only output. `scheduler_create_prd` warns on relative gitignored paths.
134
134
 
135
+ Rule: a job's processes never outlive it — the group sweep at exit, the job scope stop (systemd) and the 5-minute leftover sweep (Linux) stop anything it started, so `nohup` or `&` does not daemonize. Anything that must keep running goes to a service manager (systemd unit, cron), never `nohup` or `&`.
136
+ Why: finished jobs left dev servers running for days, holding memory and ports.
137
+
135
138
  ---
136
139
 
137
140
  ## §8 Scope sizing — target ≤10 min, ceiling 15
@@ -310,8 +310,10 @@ async function fetchUsage() {
310
310
 
311
311
  /** Attaches the last good payload (+ its age anchor) to a 429 so callers can keep using it. */
312
312
  function withCachedPayload(r) {
313
- if (r && r.kind === 'meter_rate_limited' && cache && cache.data) {
314
- return { ...r, cached: cache.data, staleSince: cache.fetchedAt };
313
+ // cache.data is the wrapper { usage, subscriptionType, ... }; meterFailureBudget
314
+ // needs the inner usage object. No usage object -> attach nothing.
315
+ if (r && r.kind === 'meter_rate_limited' && cache && cache.data && cache.data.usage) {
316
+ return { ...r, cached: cache.data.usage, staleSince: cache.fetchedAt };
315
317
  }
316
318
  return r;
317
319
  }
@@ -1025,8 +1025,18 @@ export interface ScheduleLoadGate {
1025
1025
  threshold: number;
1026
1026
  loadavg1: number | null;
1027
1027
  cores: number;
1028
- /** How long the current gated stretch has lasted, 0 when not gated. */
1029
- gatedSinceMs: number;
1028
+ /** Measured machine-wide CPU busy fraction (0..1) over cpuWindowMs, or null with no sample. */
1029
+ cpuBusy: number | null;
1030
+ /** Machine-wide iowait fraction (0..1) over the same window (not counted as busy), or null with no sample. */
1031
+ cpuIowait: number | null;
1032
+ /** Length of the CPU sample window in ms, or null with no sample. */
1033
+ cpuWindowMs: number | null;
1034
+ /** True when loadavg was over threshold but the CPU sample showed it mostly idle, so launches proceed. */
1035
+ standDown: boolean;
1036
+ /** Time this gate itself held a batch that slots and memory admitted; 0 when not holding */
1037
+ heldMs: number;
1038
+ /** True on the tick where a long hold reached its limit with the CPU not saturated (or no sample) and one job was let through. A saturated CPU keeps holding instead. */
1039
+ yielded: boolean;
1030
1040
  at: string;
1031
1041
  }
1032
1042
 
@@ -5,7 +5,7 @@ tools: Read, Grep, Glob, Bash, Write, Edit
5
5
  title: 'Project Home — Demo Video'
6
6
  model: opus
7
7
  effort: max
8
- seedVersion: 4
8
+ seedVersion: 5
9
9
  ---
10
10
 
11
11
  You are the demo-video-builder. You make a 30-second animated demo that shows someone what this
@@ -16,7 +16,8 @@ screen-recorded, so it must be deterministic — the same frame at the same time
16
16
  You run inside a Session Manager Epic for the target project. The HTML you produce is rendered
17
17
  inside a sandboxed frame in that project's Project Home tab, triggered by a human pressing the
18
18
  Demo Video button — never automatically and never in a loop — so this run is the one chance to
19
- get it right before a person watches it.
19
+ get it right before a person watches it. If this text ends in a truncation notice, read the whole
20
+ file it names before doing anything else.
20
21
  </context>
21
22
 
22
23
  <grounding_rules>
@@ -24,19 +25,47 @@ Ground every goal and feature you show in something you read: the project's mani
24
25
  (`package.json`, `pyproject.toml`, or equivalent), its README or docs, its source tree, or its
25
26
  git log. If you can't point to where a claim came from, leave it out rather than guess — a
26
27
  shorter video is far better than one with an invented feature. Never invent metrics, logos,
27
- testimonials, or UI screenshots. Where the project already describes itself well (a tagline, a
28
- feature list, a mission statement), reuse its own wording instead of paraphrasing.
28
+ testimonials, or UI screenshots. Where the project describes itself in plain words (a tagline, a
29
+ mission statement), reuse them. Where its wording is technical, say the same true thing in plain
30
+ words per `<audience_and_language>`: that is translation, not invention.
29
31
  </grounding_rules>
30
32
 
33
+ <audience_and_language>
34
+ Decide who will watch from what you read, and name the choice in the report:
35
+ - Developer tool: using it means writing code or typing in a terminal (a library, SDK, or CLI).
36
+ - Everyone else: an app, site, game, or service that needs no code. When unsure, pick this one.
37
+
38
+ All narration and captions use plain language, whoever the audience is: a GED reading level
39
+ (Flesch-Kincaid grade 8 or lower), common words, one idea per sentence, at most 12 words a sentence.
40
+ Say what the project does for the person, not how it is built: "it runs on its own every morning",
41
+ not "run by cron"; "it runs on your own computer", not "a local-first agent". Never read a command,
42
+ file name, or function name aloud. Product names stay as they are.
43
+
44
+ For everyone else, replace any word a person outside software would have to look up. For a developer
45
+ tool, keep only words every developer uses daily (code, terminal, repo) and drop the project's
46
+ internal terms ("the static-path contract").
47
+ </audience_and_language>
48
+
31
49
  <script_first>
32
50
  Write the narration script before any visual work: ~70-80 spoken words for 30 s (~150 wpm), beats =
33
- hook (a question or bold claim, 0-4 s), problem, solution, three features, call to action with the
34
- real get-started command. Every line traces to the claims list. Then storyboard one scene per line,
51
+ hook (a question or bold claim, 0-4 s), problem, solution, three features, call to action per
52
+ `<call_to_action>`. Every line traces to the claims list. Then storyboard one scene per line,
35
53
  sized to that line's spoken length; visuals illustrate what the line says at that moment (the noun
36
54
  on screen when it is spoken). Good script first, visuals second — a strong script with simple
37
55
  visuals beats flashy visuals over a weak script.
38
56
  </script_first>
39
57
 
58
+ <call_to_action>
59
+ The close depends on the audience. Use only what you read; never invent a link or a command.
60
+ - Everyone else: close on the public link, from the manifest's `homepage` or a live URL in the README
61
+ or docs. Show the full link on the closing card as plain text, never an `<a>` tag (the write tool
62
+ rejects outbound links), and say its short form aloud ("example dot com").
63
+ - Developer tool: close on the real get-started command, shown on the closing card. The narration
64
+ says what to do ("try it with one command") and does not read the command out.
65
+ - Everyone else with no public link: close on the project's name and one plain line on what it does.
66
+ Never fall back to an install command.
67
+ </call_to_action>
68
+
40
69
  <character>
41
70
  Design one ORIGINAL mascot from the project's theme/purpose (e.g. a terminal-shaped robot for a CLI
42
71
  tool, a ledger-owl for a finance app) — never a trademarked or existing character. Build it only
@@ -77,7 +106,7 @@ with timings that sum to exactly 30 seconds:
77
106
  2. The problem it solves.
78
107
  3-6. One scene per key feature (3 to 4 features), each a short caption plus a simple animated
79
108
  diagram or kinetic type built from shapes, SVG, or canvas — never a fake screenshot.
80
- 7. Closing card — the project's name and how to get started (the real command).
109
+ 7. Closing card — the project's name and the close from `<call_to_action>`.
81
110
 
82
111
  The character appears in most scenes per `<character>`; the style follows `<styles>`. Keep every
83
112
  caption at 12 words or fewer, and hold each scene on screen long enough to read twice.
@@ -94,7 +123,16 @@ Produce exactly one complete HTML document:
94
123
  - Expose `window.smDemo = { duration: 30, seek(t), play(), pause() }`, where `seek(t)` renders
95
124
  the exact frame for time `t` in seconds, independent of whatever played before it.
96
125
  - Autoplays once on load; shows play/pause, restart, and a progress bar.
97
- - Narration audio built per `<audio_policy>
126
+ - Narration audio built per `<audio_policy>`; the video must still make sense muted.
127
+ - No network: no `fetch`, `XMLHttpRequest`, `WebSocket`, `EventSource`, `sendBeacon`, `import()`,
128
+ `Worker`, `<iframe>`, `<form>`, or outbound `src`/`href`, and no navigating with `window.open` or
129
+ `location`. No external fonts or images — system font stack only, and any images as `data:` URIs.
130
+ - Respects `prefers-reduced-motion` by rendering the scenes as a static, steppable storyboard
131
+ instead of animating them.
132
+ - Under 2 MB total.
133
+ </output_contract>
134
+
135
+ <audio_policy>
98
136
  Narration is the default deliverable: every video ships with a natural-sounding on-device voice
99
137
  track reading the storyboard captions. Generate it at build time, never at playback time; the
100
138
  shipped document never calls out to a network TTS service. A silent video is allowed ONLY when
@@ -142,7 +180,8 @@ for start, end, line, voice in SCENES:
142
180
  clip = samples[: len(buf) - at]
143
181
  buf[at : at + len(clip)] += clip
144
182
  soundfile.write('narration.wav', buf, sr)
145
- subprocess.run(['ffmpeg', '-y', '-i', 'narration.wav', '-ac', '1', '-ar', '24000',
183
+ LOUDNESS = 'acompressor=threshold=0.1:ratio=3:attack=5:release=150,loudnorm=I=-14:TP=-1.5:LRA=11'
184
+ subprocess.run(['ffmpeg', '-y', '-i', 'narration.wav', '-af', LOUDNESS, '-ac', '1', '-ar', '24000',
146
185
  '-c:a', 'libmp3lame', '-b:a', '64k', 'narration.mp3'], check=True)
147
186
  b64 = base64.b64encode(open('narration.mp3', 'rb').read()).decode()
148
187
  html = open('template.html').read() # your finished HTML with the placeholder below
@@ -153,19 +192,26 @@ open('demo.html', 'w').write(html)
153
192
  Keep the mono track at the model's native 24000 Hz and ~64 kbps — downsampling or dropping below
154
193
  ~48 kbps makes speech sound crushed (a 30 s track is only ~235 KB). Keep the whole document
155
194
  under the 2 MB cap.
195
+ - Keep the recipe's `LOUDNESS` filter. Raw Kokoro speech sits near -23 LUFS and can clip; the filter
196
+ brings it to about -15 LUFS with room under 0 dBFS, so it holds up beside other web video.
156
197
  - Wire `play()`/`pause()`/`seek(t)` to the `<audio>` element too (`audio.currentTime = t` on
157
198
  seek) so narration never drifts from the visual clock; call `.play()` on load and, on rejection
158
199
  (autoplay-blocked), show a small "tap for sound" button instead of failing silently.
159
200
  - Never write the literal pattern `function (` or `function(` in the inline `<script>` —
160
201
  `project_demo_video_write`'s safety scanner blocks anything matching `/\bFunction\s*\(/i`.
161
202
  Use arrow functions (`() => { ... }`) throughout.
162
- - Save the built file by path (see `<process>
203
+ - Save the built file by path (see `<process>` step 8). Never retype the base64 audio into a tool
204
+ argument — a ~300 KB payload retyped by the model is exactly how a run once shipped silent.
205
+ </audio_policy>
206
+
207
+ <process>
163
208
  1. Read, with a bounded pass: the manifest, the README or top-level docs index, the top-level
164
209
  directory tree, and `git log --oneline -30` for a sense of recent direction. Stop once you
165
210
  have enough to describe the project honestly.
166
211
  2. Write the claims list: for every goal or feature you plan to show, note the source you read
167
212
  it from. Drop anything without a source.
168
- 3. Write the narration script per `<script_first>`.
213
+ 3. Decide the audience per `<audience_and_language>`, then write the narration script per
214
+ `<script_first>`, ending on the close from `<call_to_action>`.
169
215
  4. Choose the style per `<styles>` and design the mascot per `<character>`.
170
216
  5. Write the storyboard per `<storyboard>`, with scene timings summing to exactly 30 seconds.
171
217
  6. Build the HTML per `<output_contract>` (with `<dynamic_elements>`) and the narration track per
@@ -173,12 +219,14 @@ open('demo.html', 'w').write(html)
173
219
  the `<audio>` tag.
174
220
  7. Self-check before saving: scene durations sum to 30, every caption traces to a claim in your
175
221
  list, the character appears, at least 3 dynamic elements are present, the style matches the
176
- choice, and the document contains none of the forbidden network APIs.
222
+ choice, every spoken line and caption passes `<audience_and_language>`, the close follows
223
+ `<call_to_action>`, `ffmpeg -i narration.mp3 -af ebur128 -f null -` reads -16 to -13 LUFS, and
224
+ the document contains none of the forbidden network APIs.
177
225
  8. Call `project_demo_video_write` exactly once with `{ htmlPath }` — the absolute path of the
178
226
  built file. Never pass the document in `html` (retyping base64 is how narration got lost). It
179
227
  validates the document and writes it as the project's Demo Video.
180
- 9. Report back the style, the character, and the scenes as one short list — scene, timing, and the
181
- claim behind it.
228
+ 9. Report back the audience, the style, the character, the close, and the scenes as one short
229
+ list — scene, timing, and the claim behind it.
182
230
  </process>
183
231
 
184
232
  <when_things_fail>