claude-code-session-manager 0.140.0 → 0.141.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 (31) hide show
  1. package/dist/assets/{AppSettings-CMFEM68R.js → AppSettings-DExeJhqQ.js} +1 -1
  2. package/dist/assets/{History--JwsFnbn.js → History-DJMiuXyK.js} +1 -1
  3. package/dist/assets/{HomeClaudeConfig-ijEXs--3.js → HomeClaudeConfig-CTp2tkZ4.js} +2 -2
  4. package/dist/assets/{Panel-CALyU0pe.js → Panel-Bf1Cf8UL.js} +1 -1
  5. package/dist/assets/{ProjectClaudeConfig-sdlA-fUb.js → ProjectClaudeConfig-BWPpypf9.js} +1 -1
  6. package/dist/assets/{Scheduler-YT3j8SUa.js → Scheduler-cyr61UAC.js} +1 -1
  7. package/dist/assets/{SkillReferenceGraph-CxAuwhNN.js → SkillReferenceGraph-Ba4TkX2C.js} +1 -1
  8. package/dist/assets/{Skills-DtRzghn5.js → Skills-C1v91GEO.js} +1 -1
  9. package/dist/assets/{TiptapBody-DApeu7x8.js → TiptapBody-BrcWVpiW.js} +1 -1
  10. package/dist/assets/{ViewTabs-B7qLXRAH.js → ViewTabs-DXhOWFG0.js} +1 -1
  11. package/dist/assets/{VoiceButton-DtStfv1H.js → VoiceButton-qivnDV6K.js} +1 -1
  12. package/dist/assets/{historyTotals-ydfnwepc.js → historyTotals-CMCPTKqC.js} +1 -1
  13. package/dist/assets/{index-CtxruO1L.js → index-B2TQz3nd.js} +3 -3
  14. package/dist/index.html +1 -1
  15. package/dist-web/app.js +1 -1
  16. package/package.json +1 -1
  17. package/plugins/session-manager-dev/skills/builder/SKILL.md +4 -2
  18. package/plugins/session-manager-dev/skills/develop/SKILL.md +3 -0
  19. package/scripts/scheduler-mcp-server.cjs +5 -0
  20. package/src/main/build-info.json +4 -4
  21. package/src/main/ipcSchemas.cjs +10 -0
  22. package/src/main/lib/mcpToolCatalog.cjs +11 -2
  23. package/src/main/lib/prd/prdCreate.cjs +27 -1
  24. package/src/main/lib/prd/prdFrontmatter.cjs +28 -3
  25. package/src/main/lib/scheduler/preflightCheck.cjs +97 -0
  26. package/src/main/lib/scheduler/reviewNotice.cjs +39 -0
  27. package/src/main/scheduler/prdParser.cjs +16 -1
  28. package/src/main/scheduler/reviewLadder.cjs +36 -3
  29. package/src/main/scheduler/starvation.cjs +69 -0
  30. package/src/main/scheduler.cjs +335 -25
  31. package/src/main/templates/PRD_AUTHORING.md +9 -1
@@ -306,10 +306,49 @@ function holdMsFromEnv(env = process.env) {
306
306
  return minutes * 60000;
307
307
  }
308
308
 
309
+ /**
310
+ * buildPreflightHoldNotice({ slug, failText, preflight, heldSlugs, nextAt })
311
+ * → plain-text body for the ONE informational notice an Epic gets the moment
312
+ * a PRD is held on a failing preflight. It states what is missing (failText,
313
+ * quoted verbatim), the preflight command, which PRDs it holds, when the next
314
+ * re-check runs, and that the hold clears on its own. Pure, no I/O. It never
315
+ * asks a question and never carries SM_NEEDS_INPUT — nothing waits on a reply.
316
+ * (failText is quoted as-is; the builder's own wording has no '?'.)
317
+ */
318
+ function buildPreflightHoldNotice({ slug, failText, preflight, heldSlugs, nextAt } = {}) {
319
+ const name = (typeof slug === 'string' && slug.trim()) || 'this PRD';
320
+ const cmd = oneLine(preflight);
321
+ const cmdLabel = cmd ? `\`${cmd}\`` : 'the preflight';
322
+ const missing = typeof failText === 'string' && failText.trim()
323
+ ? `Missing: "${failText}"`
324
+ : `Missing: the preflight exited non-zero with no output.`;
325
+ const held = Array.isArray(heldSlugs) ? heldSlugs.filter((x) => typeof x === 'string' && x) : [];
326
+ const heldList = held.length ? held : [name];
327
+ const when = typeof nextAt === 'string' && nextAt ? nextAt : 'the next scheduler pass';
328
+ return [
329
+ `PRECONDITION HOLD: ${name} is waiting on its preflight.`,
330
+ missing,
331
+ `Preflight: ${cmdLabel}`,
332
+ `Held: ${heldList.join(', ')}`,
333
+ `Next re-check: ${when}.`,
334
+ `The scheduler re-checks on its own and resumes the chain when ${cmdLabel} exits 0. Reset on ${name} re-checks at once.`,
335
+ ].join('\n');
336
+ }
337
+
338
+ /**
339
+ * preflightHoldNoticeKey(slug, since) → dedup key for one preflight hold.
340
+ * Same slug + same hold start = same key, so each hold sends one notice.
341
+ */
342
+ function preflightHoldNoticeKey(slug, since) {
343
+ return `preflight-hold\u0000${slug ?? ''}\u0000${since ?? ''}`;
344
+ }
345
+
309
346
  module.exports = {
310
347
  DEFAULT_HOLD_MINUTES,
311
348
  buildReviewNotice,
312
349
  selectDueReviewNotices,
313
350
  formatReviewNotice,
314
351
  holdMsFromEnv,
352
+ buildPreflightHoldNotice,
353
+ preflightHoldNoticeKey,
315
354
  };
@@ -17,7 +17,7 @@ const fs = require('node:fs');
17
17
  const fsp = require('node:fs/promises');
18
18
  const os = require('node:os');
19
19
  const path = require('node:path');
20
- const { splitFrontmatter, parseInlineList, parseFixes, PRD_EFFORT_LEVELS } = require('../lib/prd/prdFrontmatter.cjs');
20
+ const { splitFrontmatter, parseInlineList, parseFixes, parsePreflightValue, PRD_EFFORT_LEVELS } = require('../lib/prd/prdFrontmatter.cjs');
21
21
  const { deriveEpicIdFromPrdPath } = require('../lib/prd/prdLocations.cjs');
22
22
  const { parseFilesSection } = require('../lib/prd/prdGateFiles.cjs');
23
23
  const { reportDanglingAgentTypeOnce } = require('../lib/prd/prdAgentType.cjs');
@@ -153,6 +153,9 @@ async function parsePrdRaw(filePath) {
153
153
  deliverable: (typeof fm.deliverable === 'string' && fm.deliverable.trim() === 'artifact') ? 'artifact' : null,
154
154
  artifactPaths: parseArtifactPaths(fm.artifactPaths),
155
155
  effort: (typeof fm.effort === 'string' && PRD_EFFORT_LEVELS.includes(fm.effort.trim())) ? fm.effort.trim() : null,
156
+ // Optional precondition command (preflightCheck.cjs); reconcile copies it
157
+ // onto the queue row so spawnJob can hold the job while it exits non-zero.
158
+ preflight: typeof fm.preflight === 'string' ? parsePreflightValue(rawFrontmatterValue(text, 'preflight')) : null,
156
159
  // Opt-in exclusive-lease flag (PRD 1107, quietMachineLease.cjs +
157
160
  // schedulerBatch.cjs's pickNextBatch). Only a literal `true` opts in —
158
161
  // matches prdFrontmatter.cjs's applyKey semantics for this field.
@@ -166,6 +169,18 @@ async function parsePrdRaw(filePath) {
166
169
  };
167
170
  }
168
171
 
172
+ /**
173
+ * The unstripped value of one frontmatter key. splitFrontmatter strips a
174
+ * value's outer quotes, which breaks a JSON-string `preflight` with escaped
175
+ * inner quotes; parsePreflightValue needs the raw form.
176
+ */
177
+ function rawFrontmatterValue(text, key) {
178
+ const end = text.indexOf('\n---', 4);
179
+ const block = end === -1 ? '' : text.slice(4, end);
180
+ const m = block.match(new RegExp(`^${key}\\s*:\\s*(.*?)\\s*$`, 'm'));
181
+ return m ? m[1] : '';
182
+ }
183
+
169
184
  /** `[a, b]` / `a, b` / `a` → ['a','b']; anything else → []. */
170
185
  function parseDependsOn(raw) {
171
186
  if (!raw || typeof raw !== 'string') return [];
@@ -441,13 +441,29 @@ function isStrandedAutoFixPark(job, jobsInProject) {
441
441
  return !liveOrQueuedChild;
442
442
  }
443
443
 
444
+ /**
445
+ * Pure predicate, no I/O: a needs_review row that is itself a fix plan
446
+ * (resolveIsFixPlan — persisted isFixPlan stamp, else the slug heuristic)
447
+ * and never went through auto-fix. selectAutoFixTargets excludes fix plans
448
+ * (no recursion), so autoFixAttempted is never set and none of the other
449
+ * doors admit it — rung 6 never runs and its dependsOn chain waits forever
450
+ * (starry-night-2 852-fix-ios-asc-profile, sentinel_fail, 2026-11-22).
451
+ * Exported for tests.
452
+ */
453
+ function isFixPlanParkWithoutAutoFix(job) {
454
+ if (!job || job.status !== 'needs_review') return false;
455
+ if (job.autoFixAttempted === true) return false;
456
+ return resolveIsFixPlan(job.slug, job.isFixPlan);
457
+ }
458
+
444
459
  /**
445
460
  * Pure predicate, no I/O: is this needs_review row eligible for the bounded
446
461
  * auto-resolve ladder at all — either because its auto-fix path is genuinely
447
462
  * spent (isExhaustedAutoFix), because it was parked by a GUARD verdict that
448
463
  * never entered auto-fix in the first place (isGuardParkedWithoutAutoFix),
449
- * or because its auto-fix investigation ran but was stranded before
450
- * recording any outcome (isStrandedAutoFixPark). All three classes share ONE
464
+ * because its auto-fix investigation ran but was stranded before
465
+ * recording any outcome (isStrandedAutoFixPark), or because it is a fix plan
466
+ * that auto-fix never admits (isFixPlanParkWithoutAutoFix). All four classes share ONE
451
467
  * ladder (applyNeedsReviewAutoResolve) rather than a duplicated one — the
452
468
  * ladder itself doesn't care which door a row came through, only whether it
453
469
  * now carries completion evidence (job.looksDone). `jobsInProject` is only
@@ -457,7 +473,10 @@ function isStrandedAutoFixPark(job, jobsInProject) {
457
473
  */
458
474
  function isEligibleForNeedsReviewAutoResolve(job, jobsInProject = []) {
459
475
  if (isRefireCapped(job)) return false;
460
- return isExhaustedAutoFix(job) || isGuardParkedWithoutAutoFix(job) || isStrandedAutoFixPark(job, jobsInProject);
476
+ return isExhaustedAutoFix(job)
477
+ || isGuardParkedWithoutAutoFix(job)
478
+ || isStrandedAutoFixPark(job, jobsInProject)
479
+ || isFixPlanParkWithoutAutoFix(job);
461
480
  }
462
481
 
463
482
  /**
@@ -495,9 +514,21 @@ function isFixPlanDead(job, jobsInProject) {
495
514
  const fixSlug = fixSlugFor(job);
496
515
  const child = (jobsInProject || []).find((j) => j.slug === fixSlug);
497
516
  if (!child) return false;
517
+ // A child waiting on its own red preflight is not dead: the precondition,
518
+ // not the plan, is the blocker — reopening it would spend a probe for nothing.
519
+ if (hasActivePreflightHold(child)) return false;
498
520
  return DEAD_FIX_CHILD_STATUSES.has(child.status);
499
521
  }
500
522
 
523
+ /**
524
+ * Pure predicate: the row is waiting on its own red `preflight` (a
525
+ * preflightHold is armed). Such a row spends nothing on the model ladder —
526
+ * no investigation probe, no dead-fix-plan reopen. Exported for tests.
527
+ */
528
+ function hasActivePreflightHold(job) {
529
+ return !!(job && job.preflightHold && typeof job.preflightHold === 'object');
530
+ }
531
+
501
532
  /**
502
533
  * Pure predicate: is this job eligible for the boot re-verify self-heal? Only
503
534
  * needs_review jobs with a run log (own or backfilled via resolveRunId) AND a
@@ -1107,10 +1138,12 @@ module.exports = {
1107
1138
  GUARD_VERDICT_EVIDENCE_ELIGIBLE,
1108
1139
  isGuardParkedWithoutAutoFix,
1109
1140
  isStrandedAutoFixPark,
1141
+ isFixPlanParkWithoutAutoFix,
1110
1142
  isEligibleForNeedsReviewAutoResolve,
1111
1143
  isPlanUnqueued,
1112
1144
  DEAD_FIX_CHILD_STATUSES,
1113
1145
  isFixPlanDead,
1146
+ hasActivePreflightHold,
1114
1147
  NO_ATTRIBUTABLE_COMMIT_VERDICTS,
1115
1148
  healRefusalReason,
1116
1149
  isFailedUnverifiedShaped,
@@ -155,6 +155,73 @@ function describeStarveHold({ projectRows = [], launchBlocks = {}, lastTick = nu
155
155
  return lastHoldTick?.reason ?? 'dispatching-elsewhere';
156
156
  }
157
157
 
158
+ /** Max dependency links findRootBlocker follows before giving up on a chain. */
159
+ const ROOT_BLOCKER_MAX_DEPTH = 50;
160
+
161
+ /** Root row's human reason: heldReason, else its last statusHistory reason, else null. */
162
+ function rootBlockerReason(row) {
163
+ if (typeof row.heldReason === 'string' && row.heldReason) return row.heldReason;
164
+ const h = Array.isArray(row.statusHistory) ? row.statusHistory : [];
165
+ const last = h[h.length - 1];
166
+ return last && typeof last.reason === 'string' && last.reason ? last.reason : null;
167
+ }
168
+
169
+ function rootBlockerRow(job, rows, resolver) {
170
+ const visited = new Set([job.slug]);
171
+ let cur = job;
172
+ for (let depth = 0; depth < ROOT_BLOCKER_MAX_DEPTH; depth++) {
173
+ const depSlug = findBlockingDep(cur, rows, DEP_HISTORY_FAIL_OPEN, resolver);
174
+ if (!depSlug) return cur === job ? null : cur;
175
+ const next = resolver.rowsForDep(depSlug, cur).find((r) => !isSatisfiedDepRow(r));
176
+ if (!next || visited.has(next.slug)) return cur === job ? null : cur; // cycle: stop at last new row
177
+ visited.add(next.slug);
178
+ cur = next;
179
+ }
180
+ return cur === job ? null : cur;
181
+ }
182
+
183
+ /**
184
+ * findRootBlocker(job, rows) → null | { slug, status, reason, preflightHeld }
185
+ *
186
+ * Pure. Walks findBlockingDep (fail-open history, as describeStarveHold does)
187
+ * transitively to the first row that is not itself waiting on a dependency —
188
+ * the row a starved chain actually waits on. Cycle-safe; stops at depth 50
189
+ * and reports the deepest row reached. null when `job` has no blocking dep.
190
+ */
191
+ function findRootBlocker(job, rows, resolver = null) {
192
+ if (!job) return null;
193
+ const list = (Array.isArray(rows) ? rows : []).filter(Boolean);
194
+ const res = resolver ?? makeDepResolver(list, new Set(), { failOpen: true });
195
+ const root = rootBlockerRow(job, list, res);
196
+ if (!root) return null;
197
+ return {
198
+ slug: root.slug,
199
+ status: root.status,
200
+ reason: rootBlockerReason(root),
201
+ preflightHeld: !!root.preflightHold && typeof root.preflightHold === 'object',
202
+ };
203
+ }
204
+
205
+ /**
206
+ * rootBlockersForProject(projectRows) → [{ slug, status, reason, preflightHeld, heldSlugs }]
207
+ *
208
+ * Pure. Distinct root blockers over every dependency-blocked pending row,
209
+ * in first-seen order; `heldSlugs` lists the pending rows each one holds.
210
+ */
211
+ function rootBlockersForProject(projectRows) {
212
+ const rows = (Array.isArray(projectRows) ? projectRows : []).filter(Boolean);
213
+ const resolver = makeDepResolver(rows, new Set(), { failOpen: true });
214
+ const bySlug = new Map();
215
+ for (const j of rows) {
216
+ if (j.status !== 'pending') continue;
217
+ const root = findRootBlocker(j, rows, resolver);
218
+ if (!root) continue;
219
+ if (!bySlug.has(root.slug)) bySlug.set(root.slug, { ...root, heldSlugs: [] });
220
+ bySlug.get(root.slug).heldSlugs.push(j.slug);
221
+ }
222
+ return [...bySlug.values()];
223
+ }
224
+
158
225
  /**
159
226
  * classifyQueueStarvation({ jobs, paused, runningCount, lastRunAtMs, now, thresholdMs })
160
227
  * → null | { kind: 'starved' | 'blocked', pending, dispatchable, blockedChains, idleMs }
@@ -407,6 +474,8 @@ module.exports = {
407
474
  dispatchIdleMs,
408
475
  launchBlockedSlugs,
409
476
  describeStarveHold,
477
+ findRootBlocker,
478
+ rootBlockersForProject,
410
479
  classifyQueueStarvation,
411
480
  classifyQueueStarvationByProject,
412
481
  classifyQueueHealth,