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
@@ -313,6 +313,59 @@ async function resolveBareSlugFile(slug, cwd) {
313
313
  return { ok: true, path: safe, dir: only.dir };
314
314
  }
315
315
 
316
+ /**
317
+ * Text of each named PRD of one Epic, wherever it lives now: its prds/, its
318
+ * prds-archived/, each direct subfolder of prds-archived/ (newest name first),
319
+ * then the same for ancestor-folder copies of the Epic. First match wins; an
320
+ * exact `<slug>.md` beats a bare-slug match (`fix-x` finds `872-fix-x.md`).
321
+ * Slugs are only compared with readdir names, never joined into a path; only
322
+ * regular `.md` files are read. Never rejects. Returns Map<inputSlug, text>.
323
+ */
324
+ async function readEpicPrdTexts(cwd, epicId, slugs) {
325
+ const out = new Map();
326
+ try {
327
+ if (typeof cwd !== 'string' || !cwd || !Array.isArray(slugs) || slugs.length === 0) return out;
328
+ if (!isSafeEpicId(epicId)) return out;
329
+ const root = projectRootOf(cwd);
330
+ const live = resolveEpicPrdWriteDir(root, epicId);
331
+ const archived = path.join(path.dirname(live), 'prds-archived');
332
+ const dirs = [];
333
+ const addWithSubs = async (dir) => {
334
+ dirs.push(dir);
335
+ const ents = await fsp.readdir(dir, { withFileTypes: true }).catch(() => []);
336
+ const subs = ents.filter((e) => e.isDirectory()).map((e) => e.name).sort().reverse();
337
+ for (const s of subs) dirs.push(path.join(dir, s));
338
+ };
339
+ dirs.push(live);
340
+ await addWithSubs(archived);
341
+ for (const d of ancestorEpicPrdDirs(root, epicId)) dirs.push(d);
342
+ for (const d of ancestorEpicArchivedPrdDirs(root, epicId)) await addWithSubs(d);
343
+ const index = new Map();
344
+ for (const dir of dirs) {
345
+ let ents;
346
+ try { ents = await fsp.readdir(dir, { withFileTypes: true }); } catch { continue; }
347
+ for (const e of ents) {
348
+ if (!e.isFile() || !e.name.endsWith('.md')) continue;
349
+ const key = e.name.slice(0, -3);
350
+ if (!index.has(key)) index.set(key, path.join(dir, e.name));
351
+ }
352
+ }
353
+ for (const slug of slugs) {
354
+ if (typeof slug !== 'string' || !slug || out.has(slug)) continue;
355
+ let file = index.get(slug);
356
+ if (!file) {
357
+ const bare = bareSlug(slug);
358
+ for (const [key, p] of index) {
359
+ if (bareSlug(key) === bare) { file = p; break; }
360
+ }
361
+ }
362
+ if (!file) continue;
363
+ try { out.set(slug, await fsp.readFile(file, 'utf8')); } catch { /* unreadable — no entry */ }
364
+ }
365
+ } catch { /* never rejects */ }
366
+ return out;
367
+ }
368
+
316
369
  /**
317
370
  * The two distinct failure modes safeSlugPath collapses into one nullable
318
371
  * return (the defect this fixes — see the PRD that added this helper's
@@ -568,6 +621,7 @@ module.exports = {
568
621
  realPrdsDir,
569
622
  safeSlugPath,
570
623
  resolveBareSlugFile,
624
+ readEpicPrdTexts,
571
625
  resolveSlugOrReason,
572
626
  jobMatchesSlugAndCwd,
573
627
  unknownSlugMessage,
@@ -1009,7 +1009,24 @@ function selectGateShadowTarget(jobs, headByCwd, { authorityDisabled = false, ba
1009
1009
  return eligible.find((j) => !j.gateShadow) ?? null;
1010
1010
  }
1011
1011
 
1012
+ /**
1013
+ * Resume-recovery rows a periodic pass may launch: every row
1014
+ * selectResumeRecoveryTarget accepts, or only the first when the CPU is
1015
+ * saturated (the rest stay eligible for the next pass).
1016
+ */
1017
+ function selectResumeRecoveryBatch(jobs, { saturated = false } = {}) {
1018
+ const batch = [];
1019
+ for (const job of jobs ?? []) {
1020
+ const target = selectResumeRecoveryTarget(job);
1021
+ if (!target) continue;
1022
+ batch.push({ job, target });
1023
+ if (saturated) break;
1024
+ }
1025
+ return batch;
1026
+ }
1027
+
1012
1028
  module.exports = {
1029
+ selectResumeRecoveryBatch,
1013
1030
  isRefireCapped,
1014
1031
  isCancelledJob,
1015
1032
  selectResumeRecoveryTarget,
@@ -6,6 +6,7 @@
6
6
  'use strict';
7
7
 
8
8
  const launchFailure = require('../lib/scheduler/launchFailure.cjs');
9
+ const { findBlockingDep, DEP_HISTORY_FAIL_OPEN } = require('../lib/scheduler/schedulerBatch.cjs');
9
10
  const { STARVE_ESCALATION_MS } = require('../lib/scheduler/schedulerConfig.cjs');
10
11
 
11
12
  /**
@@ -132,6 +133,26 @@ function launchBlockedSlugs(jobs, launchBlocks) {
132
133
  return out;
133
134
  }
134
135
 
136
+ /**
137
+ * describeStarveHold({ projectRows, launchBlocks, lastTick, lastHoldTick }) → string
138
+ *
139
+ * Pure. Names the real limiter for a starved project: its own dependency wait,
140
+ * then a launch breaker, then the last tick's reason (or the last hold carried
141
+ * past a fired tick). 'unknown' only when the scheduler has not ticked.
142
+ */
143
+ function describeStarveHold({ projectRows = [], launchBlocks = {}, lastTick = null, lastHoldTick = null } = {}) {
144
+ const rows = Array.isArray(projectRows) ? projectRows : [];
145
+ const pending = rows.filter((j) => j && j.status === 'pending');
146
+ if (pending.length) {
147
+ if (pending.every((j) => findBlockingDep(j, rows, DEP_HISTORY_FAIL_OPEN))) return 'dependency-blocked';
148
+ const blocked = launchBlockedSlugs(pending, launchBlocks);
149
+ if (pending.every((j) => blocked.has(j.slug))) return 'launch-blocked';
150
+ }
151
+ if (!lastTick) return 'unknown';
152
+ if (!lastTick.fired && lastTick.reason) return lastTick.reason;
153
+ return lastHoldTick?.reason ?? 'dispatching-elsewhere';
154
+ }
155
+
135
156
  /**
136
157
  * classifyQueueStarvation({ jobs, paused, runningCount, lastRunAtMs, now, thresholdMs })
137
158
  * → null | { kind: 'starved' | 'blocked', pending, dispatchable, blockedChains, idleMs }
@@ -383,6 +404,7 @@ module.exports = {
383
404
  STARVE_ESCALATION_MS,
384
405
  dispatchIdleMs,
385
406
  launchBlockedSlugs,
407
+ describeStarveHold,
386
408
  classifyQueueStarvation,
387
409
  classifyQueueStarvationByProject,
388
410
  classifyQueueHealth,