claude-code-session-manager 0.138.0 → 0.140.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 (194) hide show
  1. package/.claude-plugin/marketplace.json +1 -1
  2. package/README.md +352 -79
  3. package/dist/assets/AppSettings-CMFEM68R.js +2 -0
  4. package/dist/assets/History--JwsFnbn.js +2 -0
  5. package/dist/assets/HomeClaudeConfig-ijEXs--3.js +3 -0
  6. package/dist/assets/{Panel-CeDiyuNn.js → Panel-CALyU0pe.js} +1 -1
  7. package/dist/assets/ProjectClaudeConfig-sdlA-fUb.js +26 -0
  8. package/dist/assets/Scheduler-YT3j8SUa.js +16 -0
  9. package/dist/assets/{SkillReferenceGraph-CFMK8NJh.js → SkillReferenceGraph-CxAuwhNN.js} +1 -1
  10. package/dist/assets/Skills-DtRzghn5.js +67 -0
  11. package/dist/assets/{TiptapBody-D1kTj-tn.js → TiptapBody-DApeu7x8.js} +60 -54
  12. package/dist/assets/ViewTabs-B7qLXRAH.js +1 -0
  13. package/dist/assets/{VoiceButton-CZeyPM31.js → VoiceButton-DtStfv1H.js} +1 -1
  14. package/dist/assets/{historyTotals-B00l64Jw.js → historyTotals-ydfnwepc.js} +1 -1
  15. package/dist/assets/index-CtxruO1L.js +3121 -0
  16. package/dist/assets/{index-62tyjEQB.css → index-DKXdXfka.css} +1 -1
  17. package/dist/index.html +2 -2
  18. package/dist-web/app.css +1 -1
  19. package/dist-web/app.js +467 -451
  20. package/package.json +17 -6
  21. package/plugins/AGENTS.md +60 -0
  22. package/plugins/CLAUDE.md +1 -60
  23. package/plugins/session-manager-dev/.claude-plugin/plugin.json +1 -1
  24. package/plugins/session-manager-dev/skills/builder/SKILL.md +12 -4
  25. package/plugins/session-manager-dev/skills/builder/scripts/publish-preflight.cjs +255 -0
  26. package/plugins/session-manager-dev/skills/develop/SKILL.md +36 -22
  27. package/plugins/session-manager-dev/skills/maintaining-md-network/SKILL.md +5 -4
  28. package/plugins/session-manager-dev/skills/maintaining-md-network/audit.md +4 -2
  29. package/plugins/session-manager-dev/skills/maintaining-md-network/drift-check.md +16 -12
  30. package/plugins/session-manager-dev/skills/maintaining-md-network/migrate-to-agents-md.md +15 -0
  31. package/plugins/session-manager-dev/skills/maintaining-md-network/placement.md +50 -2
  32. package/plugins/session-manager-dev/skills/maintaining-md-network/plan.md +10 -10
  33. package/plugins/session-manager-dev/skills/maintaining-md-network/scripts/drift-check.cjs +117 -112
  34. package/plugins/session-manager-dev/skills/maintaining-md-network/scripts/mdDuplicates.cjs +182 -0
  35. package/plugins/session-manager-dev/skills/maintaining-md-network/scripts/mdLinks.cjs +340 -0
  36. package/scripts/README.md +2 -0
  37. package/scripts/hooks/guard-tool-risk.cjs +91 -0
  38. package/scripts/hooks/lib/guard-tool-risk-policy.cjs +217 -0
  39. package/scripts/ops-sweep.cjs +53 -23
  40. package/scripts/scheduler-mcp-server.cjs +360 -35
  41. package/src/main/build-info.json +4 -4
  42. package/src/main/chatRunner.cjs +2 -2
  43. package/src/main/config.cjs +112 -8
  44. package/src/main/docEdit.cjs +6 -1
  45. package/src/main/exchanges.cjs +70 -5
  46. package/src/main/files.cjs +7 -27
  47. package/src/main/health.cjs +48 -15
  48. package/src/main/historyAggregator.cjs +172 -63
  49. package/src/main/historyDashboard.cjs +87 -17
  50. package/src/main/index.cjs +78 -4
  51. package/src/main/ipcSchemas.cjs +233 -20
  52. package/src/main/lib/AGENTS.md +54 -0
  53. package/src/main/lib/CLAUDE.md +1 -54
  54. package/src/main/lib/agent-cli/adapters/codex.cjs +5 -2
  55. package/src/main/lib/agent-cli/agentCliIpc.cjs +18 -2
  56. package/src/main/lib/agent-cli/agentCliSessionStore.cjs +1 -0
  57. package/src/main/lib/agent-cli/agentCliTurn.cjs +20 -2
  58. package/src/main/lib/agent-cli/geminiContextDefaults.cjs +94 -0
  59. package/src/main/lib/claude/effectiveModelInfo.cjs +92 -22
  60. package/src/main/lib/claude/jobSandboxPolicy.cjs +202 -0
  61. package/src/main/lib/claude/modelPricing.cjs +148 -0
  62. package/src/main/lib/claude/personaToolScope.cjs +12 -6
  63. package/src/main/lib/claude/rateLimitDetect.cjs +13 -2
  64. package/src/main/lib/claude/runClaudeP.cjs +6 -1
  65. package/src/main/lib/claude/toolRiskIpc.cjs +177 -0
  66. package/src/main/lib/claude/toolRiskMarks.cjs +373 -0
  67. package/src/main/lib/demo-video-kit/seedKit.cjs +27 -6
  68. package/src/main/lib/ephemeralCwd.cjs +37 -2
  69. package/src/main/lib/epic/delegationReadiness.cjs +42 -9
  70. package/src/main/lib/epic/epicAdminRoutes.cjs +121 -0
  71. package/src/main/lib/epic/epicJobReceipt.cjs +87 -0
  72. package/src/main/lib/epic/epicOutsideRead.cjs +423 -0
  73. package/src/main/lib/epic/epicOutsideState.cjs +233 -0
  74. package/src/main/lib/epic/epicSettle.cjs +1 -1
  75. package/src/main/lib/epic/epicStateWatcher.cjs +157 -0
  76. package/src/main/lib/epic/epicSweepValidator.cjs +7 -2
  77. package/src/main/lib/epic/epicValidationHook.cjs +24 -4
  78. package/src/main/lib/epic/externalRef.cjs +37 -0
  79. package/src/main/lib/epic/externalRefIndex.cjs +136 -0
  80. package/src/main/lib/epic/guardSpawnSettings.cjs +57 -1
  81. package/src/main/lib/epic/restorableSessions.cjs +151 -17
  82. package/src/main/lib/epic/transcriptUsage.cjs +197 -0
  83. package/src/main/lib/externalContract.cjs +137 -0
  84. package/src/main/lib/feedback-remote/crossProjectFeedback.cjs +176 -5
  85. package/src/main/lib/feedback-remote/crossProjectReply.cjs +186 -9
  86. package/src/main/lib/feedback-remote/customerFeedbackAdminRoutes.cjs +16 -6
  87. package/src/main/lib/feedback-remote/customerFeedbackClient.cjs +50 -8
  88. package/src/main/lib/feedback-remote/customerFeedbackInbox.cjs +218 -4
  89. package/src/main/lib/feedback-remote/customerFeedbackIpc.cjs +19 -3
  90. package/src/main/lib/feedback-remote/feedbackImages.cjs +171 -0
  91. package/src/main/lib/feedback-remote/localAdminHttp.cjs +11 -10
  92. package/src/main/lib/feedback-remote/macroAdminRoutes.cjs +167 -21
  93. package/src/main/lib/feedback-remote/needsYouAdminRoutes.cjs +133 -0
  94. package/src/main/lib/feedback-remote/needsYouIpc.cjs +50 -0
  95. package/src/main/lib/feedback-remote/needsYouStore.cjs +285 -0
  96. package/src/main/lib/feedback-remote/projectHomeAdminRoutes.cjs +98 -1
  97. package/src/main/lib/feedback-remote/remoteIpcDispatch.cjs +5 -0
  98. package/src/main/lib/git/branchSweep.cjs +209 -4
  99. package/src/main/lib/git/gitWorktree.cjs +41 -5
  100. package/src/main/lib/guardShims.cjs +1 -1
  101. package/src/main/lib/historyRollup.cjs +58 -5
  102. package/src/main/lib/insideHome.cjs +27 -1
  103. package/src/main/lib/mcpToolCatalog.cjs +232 -25
  104. package/src/main/lib/mdDocCensus.cjs +59 -78
  105. package/src/main/lib/mdDocRefs.cjs +71 -93
  106. package/src/main/lib/mdNetworkScan.cjs +245 -250
  107. package/src/main/lib/mdReviewRecord.cjs +22 -9
  108. package/src/main/lib/memoryMdNetwork.cjs +5 -12
  109. package/src/main/lib/opsOwnership.cjs +18 -2
  110. package/src/main/lib/opsRetentionSettings.cjs +28 -4
  111. package/src/main/lib/persona-macro/agentAdminRoutes.cjs +121 -0
  112. package/src/main/lib/persona-macro/macroJobDispatch.cjs +90 -20
  113. package/src/main/lib/persona-macro/macroJobIpc.cjs +144 -46
  114. package/src/main/lib/persona-macro/macroJobStatus.cjs +87 -9
  115. package/src/main/lib/persona-macro/macroLibrary.cjs +95 -5
  116. package/src/main/lib/persona-macro/personaImportHealth.cjs +78 -17
  117. package/src/main/lib/persona-macro/projectVideoToolCheck.cjs +96 -0
  118. package/src/main/lib/persona-macro/shippedPersonaSeeds.cjs +11 -0
  119. package/src/main/lib/prd/depSlugResolve.cjs +104 -4
  120. package/src/main/lib/prd/prdAdminRoutes.cjs +35 -2
  121. package/src/main/lib/prd/prdCreate.cjs +351 -23
  122. package/src/main/lib/prd/prdDisposition.cjs +11 -2
  123. package/src/main/lib/prd/prdFrontmatter.cjs +96 -3
  124. package/src/main/lib/process/loginItem.cjs +171 -0
  125. package/src/main/lib/process/loginItemPlan.cjs +193 -0
  126. package/src/main/lib/project-pages/playerBridge.cjs +4 -0
  127. package/src/main/lib/project-pages/videoReview.cjs +268 -0
  128. package/src/main/lib/project-pages/videoReviewIpc.cjs +229 -0
  129. package/src/main/lib/promptSessionSchema.cjs +4 -0
  130. package/src/main/lib/remoteTranscriptTail.cjs +32 -1
  131. package/src/main/lib/scheduler/cpuSample.cjs +131 -4
  132. package/src/main/lib/scheduler/fixPlanSlug.cjs +4 -3
  133. package/src/main/lib/scheduler/loadGate.cjs +24 -6
  134. package/src/main/lib/scheduler/planRecordHarvest.cjs +108 -0
  135. package/src/main/lib/scheduler/planRecordRetention.cjs +144 -0
  136. package/src/main/lib/scheduler/queueStore.cjs +7 -0
  137. package/src/main/lib/scheduler/rcaReport.cjs +21 -1
  138. package/src/main/lib/scheduler/reaperHelpers.cjs +35 -5
  139. package/src/main/lib/scheduler/runLogRetention.cjs +104 -3
  140. package/src/main/lib/scheduler/scheduleJobSchema.cjs +3 -0
  141. package/src/main/lib/scheduler/schedulerBatch.cjs +25 -48
  142. package/src/main/lib/scheduler/schedulerPaths.cjs +12 -0
  143. package/src/main/lib/scheduler/sessionSlots.cjs +176 -21
  144. package/src/main/lib/scheduler/validationQuality.cjs +282 -0
  145. package/src/main/lib/scheduler/validatorVerdictSchema.cjs +254 -0
  146. package/src/main/lib/tasks/taskAdminRoutes.cjs +641 -0
  147. package/src/main/lib/tasks/taskIpc.cjs +80 -0
  148. package/src/main/lib/tasks/taskLedger.cjs +502 -0
  149. package/src/main/lib/tasks/taskRun.cjs +313 -0
  150. package/src/main/lib/tasks/taskSwitch.cjs +120 -0
  151. package/src/main/lib/telemetry/auditEvents.cjs +176 -0
  152. package/src/main/lib/telemetry/eventsAdminRoutes.cjs +45 -0
  153. package/src/main/loginItemIpc.cjs +35 -0
  154. package/src/main/loopEfficiencyHandlers.cjs +11 -2
  155. package/src/main/projectPages.cjs +6 -15
  156. package/src/main/promptSessionEvents.cjs +9 -1
  157. package/src/main/queueOps.cjs +260 -3
  158. package/src/main/runVerify.cjs +53 -25
  159. package/src/main/scheduler/AGENTS.md +26 -0
  160. package/src/main/scheduler/CLAUDE.md +1 -26
  161. package/src/main/scheduler/budget.cjs +239 -9
  162. package/src/main/scheduler/cancelDependents.cjs +154 -0
  163. package/src/main/scheduler/prdParser.cjs +4 -1
  164. package/src/main/scheduler/starvation.cjs +20 -18
  165. package/src/main/scheduler.cjs +774 -64
  166. package/src/main/supervisor.cjs +5 -1
  167. package/src/main/templates/PRD_AUTHORING.md +7 -1
  168. package/src/main/transcripts.cjs +62 -7
  169. package/src/main/validationQualityHandlers.cjs +199 -0
  170. package/src/main/webRemote.cjs +132 -20
  171. package/src/preload/api.d.ts +434 -28
  172. package/src/preload/apiSurface.cjs +7 -0
  173. package/src/preload/apiSurface.json +485 -81
  174. package/src/preload/index.cjs +38 -5
  175. package/src/seed/agents/validator.md +19 -8
  176. package/dist/assets/AgentLibrary-C1d_D7uQ.js +0 -2
  177. package/dist/assets/AppSettings-CgDhqrsU.js +0 -2
  178. package/dist/assets/Button-Bk23rEnZ.js +0 -1
  179. package/dist/assets/DocumentEditorPane-BqY5Nq6W.js +0 -1
  180. package/dist/assets/Extensions-CXem-uwI.js +0 -2
  181. package/dist/assets/History-BwO3coo4.js +0 -2
  182. package/dist/assets/Library-BDV69fSe.js +0 -32
  183. package/dist/assets/ListDetail-CD-Fm6mh.js +0 -1
  184. package/dist/assets/ProjectClaudeConfig-NjdKdwe8.js +0 -25
  185. package/dist/assets/ProvenanceBadge-Bu8NmI_R.js +0 -1
  186. package/dist/assets/Scheduler-CkhTvG7C.js +0 -16
  187. package/dist/assets/Settings-COT34hBF.js +0 -2
  188. package/dist/assets/Skills-BgexoUkQ.js +0 -29
  189. package/dist/assets/SourceChip-BXjcdeb1.js +0 -1
  190. package/dist/assets/SystemPrompt-CeeH3EeW.js +0 -1
  191. package/dist/assets/Toggle-CENi19iK.js +0 -1
  192. package/dist/assets/ViewTabs-DDBb0x96.js +0 -1
  193. package/dist/assets/claude-settings-schema-COigsajx.js +0 -3
  194. package/dist/assets/index-CgCxpunJ.js +0 -3116
@@ -19,7 +19,8 @@ const fs = require('node:fs');
19
19
  const fsp = require('node:fs/promises');
20
20
  const path = require('node:path');
21
21
  const os = require('node:os');
22
- const { assertOpsWrite, opsPath, OWNERS } = require('./lib/opsOwnership.cjs');
22
+ const { assertOpsWrite, opsPath, OWNERS, OPS_ROOT_DIR } = require('./lib/opsOwnership.cjs');
23
+ const { walkImports } = require('./lib/persona-macro/personaImportHealth.cjs');
23
24
  const chokidar = require('chokidar');
24
25
  const logs = require('./logs.cjs');
25
26
  const { sendIfAlive } = require('./lib/sendToRenderer.cjs');
@@ -193,6 +194,82 @@ function validateWrite(realAbs) {
193
194
  throw new Error(`Write outside allowed write boundaries: ${realAbs}`);
194
195
  }
195
196
 
197
+ // ── Renderer instruction-file writes ────────────────────────────────────────
198
+ // The renderer's config:write-text (and only it) may also save instruction
199
+ // files: any CLAUDE.md / CLAUDE.local.md inside the read boundary, and any file
200
+ // main itself proves sits in the @-import closure of a CLAUDE.md /
201
+ // CLAUDE.local.md the caller names as `importedBy`. Main's own writers
202
+ // (writeTextAtomic, writeJson, writeJsonSync, writeBinaryAtomic) never take
203
+ // this path — they keep validateWrite's strict boundary.
204
+ const INSTRUCTION_FILE_NAMES = new Set(['CLAUDE.md', 'CLAUDE.local.md']);
205
+
206
+ function isInstructionFileName(p) {
207
+ return INSTRUCTION_FILE_NAMES.has(pathFor().basename(p));
208
+ }
209
+
210
+ /** True when any path segment is the ops root dir (single-writer law territory). */
211
+ function isInsideOpsRoot(realAbs) {
212
+ return realAbs.split(/[\\/]/).includes(OPS_ROOT_DIR);
213
+ }
214
+
215
+ /**
216
+ * Instruction-file rule for renderer writes. `realAbs` must already have
217
+ * passed validatePath (it is the realpath).
218
+ * @param {string} realAbs
219
+ * @param {{ importedBy?: string }} [opts]
220
+ * @returns {{ ok: true } | { ok: false, reason: 'sensitive' | 'ops-root' | 'not-imported' }}
221
+ */
222
+ function checkInstructionWrite(realAbs, { importedBy } = {}) {
223
+ let realHome;
224
+ try { realHome = canon(os.homedir()); } catch { realHome = os.homedir(); }
225
+ try {
226
+ insideHome.assertNotSensitiveWrite(realAbs, realHome);
227
+ } catch {
228
+ return { ok: false, reason: 'sensitive' };
229
+ }
230
+ if (isInsideOpsRoot(realAbs)) return { ok: false, reason: 'ops-root' };
231
+ if (isInstructionFileName(realAbs)) return { ok: true };
232
+ if (typeof importedBy === 'string' && importedBy) {
233
+ let realImporter = null;
234
+ try { realImporter = validatePath(expandHome(importedBy)); } catch { realImporter = null; }
235
+ if (realImporter && isInstructionFileName(realImporter)) {
236
+ for (const entry of walkImports(realImporter)) {
237
+ if (!entry.exists) continue;
238
+ let realImport;
239
+ try { realImport = canon(entry.importPath); } catch { continue; }
240
+ if (realImport === realAbs) return { ok: true };
241
+ }
242
+ }
243
+ }
244
+ return { ok: false, reason: 'not-imported' };
245
+ }
246
+
247
+ /**
248
+ * The one decision both config:write-text and config:can-write use for a
249
+ * realpath that already passed validatePath: the strict validateWrite
250
+ * boundary, else the instruction-file rule.
251
+ */
252
+ function decideRendererWrite(real, importedBy) {
253
+ try {
254
+ validateWrite(real);
255
+ return { ok: true };
256
+ } catch {
257
+ return checkInstructionWrite(real, { importedBy });
258
+ }
259
+ }
260
+
261
+ /** config:write-text's writer — validateWrite OR checkInstructionWrite, then the ops law + atomic write. */
262
+ async function writeRendererText(abs, text, { writer, importedBy } = {}) {
263
+ const real = validatePath(expandHome(abs));
264
+ if (!decideRendererWrite(real, importedBy).ok) {
265
+ throw new Error(`Write outside allowed write boundaries: ${real}`);
266
+ }
267
+ assertOpsWrite(real, writer);
268
+ await atomicFs.writeTextAtomic(real, text, {});
269
+ const stat = await fsp.stat(real);
270
+ return { ok: true, mtimeMs: stat.mtimeMs };
271
+ }
272
+
196
273
  async function readJson(abs) {
197
274
  try {
198
275
  abs = validatePath(expandHome(abs));
@@ -358,14 +435,38 @@ async function listDir(abs, { filesOnly = false, dirsOnly = false, includeHidden
358
435
  }
359
436
  }
360
437
 
361
- /** True only when writeTextAtomic would pass its path checks (validatePath + validateWrite). */
362
- function canWrite(abs) {
438
+ /**
439
+ * Whether config:write-text would accept `abs` — same decision as
440
+ * writeRendererText, plus a W_OK probe on the file (or its nearest existing
441
+ * parent folder when it does not exist yet).
442
+ * @returns {Promise<{ ok: boolean, reason?: 'outside-boundary' | 'sensitive' | 'ops-root' | 'not-imported' | 'permission' }>}
443
+ */
444
+ async function canWrite(abs, { importedBy } = {}) {
445
+ let real;
363
446
  try {
364
- validateWrite(validatePath(expandHome(abs)));
365
- return true;
447
+ real = validatePath(expandHome(abs));
366
448
  } catch {
367
- return false;
449
+ return { ok: false, reason: 'outside-boundary' };
450
+ }
451
+ const decision = decideRendererWrite(real, importedBy);
452
+ if (!decision.ok) return decision;
453
+ let probe = real;
454
+ for (;;) {
455
+ try {
456
+ await fsp.access(probe, fs.constants.F_OK);
457
+ break;
458
+ } catch {
459
+ const parent = path.dirname(probe);
460
+ if (parent === probe) break;
461
+ probe = parent;
462
+ }
463
+ }
464
+ try {
465
+ await fsp.access(probe, fs.constants.W_OK);
466
+ } catch {
467
+ return { ok: false, reason: 'permission' };
368
468
  }
469
+ return { ok: true };
369
470
  }
370
471
 
371
472
  async function exists(abs) {
@@ -530,9 +631,9 @@ function registerConfigHandlers() {
530
631
  registerPromptSessionsRoot(p);
531
632
  return writeJson(p, data, { writer });
532
633
  }));
533
- ipcMain.handle('config:write-text', v(s.configWriteText, ({ path: p, text, writer }) => writeTextAtomic(p, text, { writer })));
634
+ ipcMain.handle('config:write-text', v(s.configWriteText, ({ path: p, text, writer, importedBy }) => writeRendererText(p, text, { writer, importedBy })));
534
635
  ipcMain.handle('config:list-dir', v(s.configListDir, ({ path: p, opts }) => listDir(p, opts || {})));
535
- ipcMain.handle('config:can-write', v(s.configPath, ({ path: p }) => canWrite(p)));
636
+ ipcMain.handle('config:can-write', v(s.configCanWrite, ({ path: p, importedBy }) => canWrite(p, { importedBy })));
536
637
  ipcMain.handle('config:exists', v(s.configPath, ({ path: p }) => exists(p)));
537
638
  ipcMain.handle('config:parse-imports', v(s.configParseImports, async ({ path: p }) => {
538
639
  try {
@@ -563,6 +664,9 @@ module.exports = {
563
664
  migrateLegacyHomeFile,
564
665
  writeTextAtomic,
565
666
  writeBinaryAtomic,
667
+ writeRendererText,
668
+ checkInstructionWrite,
669
+ canWrite,
566
670
  listDir,
567
671
  exists,
568
672
  addAllowedRoot,
@@ -18,8 +18,10 @@ const { sendIfAlive } = require('./lib/sendToRenderer.cjs');
18
18
  const { ipcMain } = require('electron');
19
19
  const { spawn } = require('node:child_process');
20
20
  const crypto = require('node:crypto');
21
+ const os = require('node:os');
21
22
  const { resolveClaudeBin, claudeSpawnTarget } = require('./lib/claude/claudeBin.cjs');
22
23
  const { headlessPermissionArgs, ensureCliCapsProbed } = require('./lib/claude/claudeCliCaps.cjs');
24
+ const { buildJobSandboxSettings } = require('./lib/claude/jobSandboxPolicy.cjs');
23
25
  const { feedChildStdin } = require('./lib/process/childStdin.cjs');
24
26
  const { withProcRole } = require('./lib/process/cleanEnv.cjs');
25
27
  const { extractJson } = require('./lib/util/extractJson.cjs');
@@ -94,10 +96,13 @@ async function runClaude(prompt, { model = 'sonnet', timeoutMs = 90_000, systemP
94
96
  return new Promise((resolve) => {
95
97
  let bin;
96
98
  try { bin = resolveClaudeBin(); } catch (e) { resolve({ ok: false, error: `claude not found: ${e?.message}` }); return; }
99
+ // No spawn cwd is set, so the child inherits process.cwd() — the sandbox roots there.
100
+ const sandboxDir = process.cwd();
101
+ const sandbox = buildJobSandboxSettings({ agentType: 'aux', worktreeDir: sandboxDir, projectRoot: sandboxDir, homeDir: os.homedir(), tmpDir: os.tmpdir(), deps: { available: false, missing: [] } });
97
102
  const args = [
98
103
  '-p',
99
104
  '--model', model,
100
- '--dangerously-skip-permissions',
105
+ ...sandbox.argv,
101
106
  ...headlessPermissionArgs(),
102
107
  '--strict-mcp-config',
103
108
  '--output-format', 'text',
@@ -78,13 +78,13 @@ const MAX_TAIL_BYTES = 8 * 1024 * 1024;
78
78
  const DEFAULT_LIMIT = 100;
79
79
 
80
80
  /**
81
- * Read exchanges for a project, newest-first. Bounded to MAX_TAIL_BYTES from
82
- * the end of the file so large logs never block the main thread.
81
+ * Parse the last MAX_TAIL_BYTES of the project's exchanges.jsonl into records,
82
+ * oldest-first. Missing/unreadable file → []. Malformed lines are skipped.
83
83
  *
84
- * @param {{ cwd: string, sessionId?: string, limit?: number, offset?: number }}
84
+ * @param {string} cwd
85
85
  * @returns {Promise<object[]>}
86
86
  */
87
- async function listExchanges({ cwd, sessionId, limit = DEFAULT_LIMIT, offset = 0 }) {
87
+ async function readTailRecords(cwd) {
88
88
  const filePath = exchangesFilePath(cwd);
89
89
 
90
90
  let stat;
@@ -122,6 +122,18 @@ async function listExchanges({ cwd, sessionId, limit = DEFAULT_LIMIT, offset = 0
122
122
  if (rec && typeof rec.ts === 'string') records.push(rec);
123
123
  } catch { /* skip malformed */ }
124
124
  }
125
+ return records;
126
+ }
127
+
128
+ /**
129
+ * Read exchanges for a project, newest-first. Bounded to MAX_TAIL_BYTES from
130
+ * the end of the file so large logs never block the main thread.
131
+ *
132
+ * @param {{ cwd: string, sessionId?: string, limit?: number, offset?: number }}
133
+ * @returns {Promise<object[]>}
134
+ */
135
+ async function listExchanges({ cwd, sessionId, limit = DEFAULT_LIMIT, offset = 0 }) {
136
+ const records = await readTailRecords(cwd);
125
137
 
126
138
  // Newest-first
127
139
  records.reverse();
@@ -133,4 +145,57 @@ async function listExchanges({ cwd, sessionId, limit = DEFAULT_LIMIT, offset = 0
133
145
  return filtered.slice(offset, offset + limit);
134
146
  }
135
147
 
136
- module.exports = { recordExchange, listExchanges };
148
+ // The needs-input marker. chatRunner.cjs records a turn that ended by asking
149
+ // the human questions as `<answerBody>\n\n[asked: q1 | q2]`; this is its one home.
150
+ const ASKED_PREFIX = '\n\n[asked: ';
151
+ const ASKED_SEPARATOR = ' | ';
152
+
153
+ /**
154
+ * Build the `result` string recorded for a needs-input turn.
155
+ *
156
+ * @param {string} answerBody
157
+ * @param {string[]} questions
158
+ * @returns {string}
159
+ */
160
+ function formatAskedResult(answerBody, questions) {
161
+ return `${answerBody}${ASKED_PREFIX}${questions.join(ASKED_SEPARATOR)}]`;
162
+ }
163
+
164
+ /**
165
+ * True only for a string that ends with the `[asked: ...]` marker block.
166
+ *
167
+ * @param {unknown} result
168
+ * @returns {boolean}
169
+ */
170
+ function resultAwaitsInput(result) {
171
+ if (typeof result !== 'string' || !result.endsWith(']')) return false;
172
+ const at = result.lastIndexOf(ASKED_PREFIX);
173
+ if (at === -1) return false;
174
+ // The marker block is a single line — nothing after it may start a new one.
175
+ return !result.slice(at + ASKED_PREFIX.length).includes('\n');
176
+ }
177
+
178
+ /**
179
+ * Sessions (Claude session ids) whose newest exchange in this project is still
180
+ * waiting for the human's answer. Reads at most MAX_TAIL_BYTES of the log.
181
+ *
182
+ * @param {string} cwd
183
+ * @returns {Promise<Set<string>>}
184
+ */
185
+ async function awaitingInputSessions(cwd) {
186
+ const waiting = new Set();
187
+ for (const rec of await readTailRecords(cwd)) {
188
+ if (typeof rec.sessionId !== 'string' || !rec.sessionId) continue;
189
+ if (resultAwaitsInput(rec.result)) waiting.add(rec.sessionId);
190
+ else waiting.delete(rec.sessionId);
191
+ }
192
+ return waiting;
193
+ }
194
+
195
+ module.exports = {
196
+ recordExchange,
197
+ listExchanges,
198
+ formatAskedResult,
199
+ resultAwaitsInput,
200
+ awaitingInputSessions,
201
+ };
@@ -20,7 +20,7 @@ const path = require('node:path');
20
20
  const os = require('node:os');
21
21
 
22
22
  const { z } = require('zod');
23
- const { assertInsideHomeOrRoots } = require('./lib/insideHome.cjs');
23
+ const { assertInsideHomeOrRoots, assertNotSensitiveWrite } = require('./lib/insideHome.cjs');
24
24
  const { getAllowedRoots } = require('./config.cjs');
25
25
  const { expandHome } = require('./lib/util/expandHome.cjs');
26
26
  const atomicFs = require('./lib/util/atomicFs.cjs');
@@ -36,25 +36,6 @@ function validateHomePath(abs) {
36
36
  return assertInsideHomeOrRoots(expandHome(abs), getAllowedRoots()).realPath;
37
37
  }
38
38
 
39
- /** Reject .credentials.json writes regardless of where they sit. */
40
- function rejectCredentials(real) {
41
- if (path.basename(real) === '.credentials.json') {
42
- throw new Error('Write to .credentials.json denied');
43
- }
44
- // Defense-in-depth: files:* is renderer-only (not web-remote reachable), but a
45
- // renderer compromise could otherwise write code-execution-persistence or
46
- // credential material a cockpit file browser has no business modifying. Block
47
- // WRITES to these (reads are unaffected — they don't call this). Shell rc files
48
- // are deliberately NOT blocked; developers legitimately edit those.
49
- const rel = path.relative(os.homedir(), real);
50
- if (rel === '.ssh' || rel.startsWith('.ssh' + path.sep)) {
51
- throw new Error('Write inside ~/.ssh denied');
52
- }
53
- if (rel.startsWith(path.join('.config', 'autostart') + path.sep)) {
54
- throw new Error('Write to ~/.config/autostart denied');
55
- }
56
- }
57
-
58
39
  // Invalid characters for file/folder names (cross-platform).
59
40
  const INVALID_NAME_CHARS = /[<>:"/\\|?*\x00-\x1f]/;
60
41
  const RESERVED_NAMES = /^(con|prn|aux|nul|com[1-9]|lpt[1-9])$/i;
@@ -160,7 +141,7 @@ async function writeFile(filePath, content) {
160
141
  let resolved;
161
142
  try {
162
143
  resolved = validateHomePath(filePath);
163
- rejectCredentials(resolved);
144
+ assertNotSensitiveWrite(resolved);
164
145
  } catch (e) {
165
146
  return { ok: false, error: e.message };
166
147
  }
@@ -185,7 +166,7 @@ async function createEntry(parentPath, name, kind) {
185
166
  // produce something outside parent (defense in depth).
186
167
  try { validateHomePath(target); }
187
168
  catch (e) { return { ok: false, error: e.message }; }
188
- try { rejectCredentials(target); }
169
+ try { assertNotSensitiveWrite(target); }
189
170
  catch (e) { return { ok: false, error: e.message }; }
190
171
 
191
172
  try {
@@ -222,7 +203,7 @@ async function renameEntry(oldPath, newName) {
222
203
  const newPath = path.join(path.dirname(resolvedOld), newName);
223
204
  try { validateHomePath(newPath); }
224
205
  catch (e) { return { ok: false, error: e.message }; }
225
- try { rejectCredentials(newPath); }
206
+ try { assertNotSensitiveWrite(newPath); }
226
207
  catch (e) { return { ok: false, error: e.message }; }
227
208
 
228
209
  try {
@@ -256,7 +237,7 @@ async function duplicateEntry(filePath) {
256
237
  let resolved;
257
238
  try { resolved = validateHomePath(filePath); }
258
239
  catch (e) { return { ok: false, error: e.message }; }
259
- try { rejectCredentials(resolved); }
240
+ try { assertNotSensitiveWrite(resolved); }
260
241
  catch (e) { return { ok: false, error: e.message }; }
261
242
 
262
243
  let st;
@@ -273,7 +254,7 @@ async function duplicateEntry(filePath) {
273
254
 
274
255
  const target = path.join(dir, nameResult.name);
275
256
  try { validateHomePath(target); } catch (e) { return { ok: false, error: e.message }; }
276
- try { rejectCredentials(target); } catch (e) { return { ok: false, error: e.message }; }
257
+ try { assertNotSensitiveWrite(target); } catch (e) { return { ok: false, error: e.message }; }
277
258
 
278
259
  try {
279
260
  await fsp.copyFile(resolved, target, fs.constants.COPYFILE_EXCL);
@@ -302,7 +283,7 @@ async function deleteEntry(filePath) {
302
283
  if (isCriticalPath(resolved)) {
303
284
  return { ok: false, error: 'Cannot delete system-critical paths' };
304
285
  }
305
- try { rejectCredentials(resolved); }
286
+ try { assertNotSensitiveWrite(resolved); }
306
287
  catch (e) { return { ok: false, error: e.message }; }
307
288
 
308
289
  try {
@@ -423,7 +404,6 @@ module.exports = {
423
404
  openExternal,
424
405
  showInFinder,
425
406
  // exported for tests
426
- rejectCredentials,
427
407
  validateHomePath,
428
408
  isCriticalPath,
429
409
  listDir,
@@ -22,6 +22,7 @@ const { evaluateDispatchLiveness } = require('./lib/scheduler/watchdogHelpers.cj
22
22
  const { computeStallSummary, computeDepHistorySatisfaction, FAILURE_STREAK_ESCALATION_MS } = require('./scheduler/budget.cjs');
23
23
  const { classifyQueueStarvation, launchBlockedSlugs, STARVE_ESCALATION_MS } = require('./scheduler/starvation.cjs');
24
24
  const { REVERIFY_INTERVAL_MS } = require('./scheduler/reviewLadder.cjs');
25
+ const { makeDepResolver } = require('./lib/prd/depSlugResolve.cjs');
25
26
  const { findStarvedProjects, findUnresolvableDepRoots, DEFAULT_PROJECT_CWD, DEP_HISTORY_FAIL_OPEN } = require('./lib/scheduler/schedulerBatch.cjs');
26
27
  const { auditLogPath, readTail } = require('./lib/telemetry/auditLog.cjs');
27
28
  const { checkMainDependencyHealth } = require('./lib/git/depHealth.cjs');
@@ -116,8 +117,10 @@ function evaluateTickLiveness(queueState, heartbeat, now, runningCount) {
116
117
  // The scheduler's private concurrencyCap is retired — the machine-wide
117
118
  // sessionSlots pool is the only limit. Read it lazily so this stays a pure
118
119
  // function of its args when a caller supplies slotCap explicitly.
120
+ // jobCapacity() = cap minus the held interactive-Task slot, so a held slot
121
+ // never reads as a stall.
119
122
  const concurrencyCap = queueState.slotCap
120
- ?? (() => { try { return require('./lib/scheduler/sessionSlots.cjs').totalSlots(); } catch { return Infinity; } })();
123
+ ?? (() => { try { return require('./lib/scheduler/sessionSlots.cjs').jobCapacity(); } catch { return Infinity; } })();
121
124
 
122
125
  if (pending.length === 0) return { stalled: false, reason: 'no-pending-jobs' };
123
126
  if (effectivePaused(queueState)) return { stalled: false, reason: queueState.paused ? 'paused' : 'draining' };
@@ -274,7 +277,7 @@ function parseClaudeMdBudget(text) {
274
277
  // Pure comparison of CLAUDE.md's actual byte size against its self-declared
275
278
  // budget (see parseClaudeMdBudget). budget === null means "no budget
276
279
  // declared" — skip silently rather than treating it as 0 or infinite.
277
- function evaluateClaudeMdBudget(chars, budget) {
280
+ function evaluateClaudeMdBudget(chars, budget, label = 'CLAUDE.md', mapName = 'CLAUDE.md') {
278
281
  if (budget == null) return { ok: true, applicable: false };
279
282
  const overage = chars - budget;
280
283
  if (overage <= 0) return { ok: true, applicable: true, chars, budget };
@@ -284,10 +287,40 @@ function evaluateClaudeMdBudget(chars, budget) {
284
287
  chars,
285
288
  budget,
286
289
  overage,
287
- message: `CLAUDE.md is ${chars} chars, over its ${budget}-char budget by ${overage} (see the SIZE BUDGET note in CLAUDE.md)`,
290
+ message: `${label} is ${chars} chars, over its ${budget}-char budget by ${overage} (see the SIZE BUDGET note in ${mapName})`,
288
291
  };
289
292
  }
290
293
 
294
+ // Measures a project root's entry-map pair. The map is AGENTS.md when it
295
+ // exists (CLAUDE.md is then a one-line @AGENTS.md stub), else CLAUDE.md. The
296
+ // SIZE BUDGET is parsed from the map; the size counted is CLAUDE.md +
297
+ // AGENTS.md together, since the CLI loads both every turn. Returns null when
298
+ // neither file exists.
299
+ function measureRootClaudeMdPair(rootDir) {
300
+ const read = (name) => {
301
+ try { return fs.readFileSync(path.join(rootDir, name), 'utf8'); } catch { return null; }
302
+ };
303
+ const claude = read('CLAUDE.md');
304
+ const agents = read('AGENTS.md');
305
+ if (claude == null && agents == null) return null;
306
+ const mapName = agents != null ? 'AGENTS.md' : 'CLAUDE.md';
307
+ const present = [claude != null && 'CLAUDE.md', agents != null && 'AGENTS.md'].filter(Boolean);
308
+ const chars = Buffer.byteLength(claude || '', 'utf8') + Buffer.byteLength(agents || '', 'utf8');
309
+ return {
310
+ mapName,
311
+ label: present.join(' + '),
312
+ chars,
313
+ budget: parseClaudeMdBudget(agents != null ? agents : claude),
314
+ };
315
+ }
316
+
317
+ // Root pair (measureRootClaudeMdPair) evaluated against the map's budget.
318
+ function evaluateRootClaudeMdBudget(rootDir) {
319
+ const m = measureRootClaudeMdPair(rootDir);
320
+ if (!m) return { ok: true, applicable: false };
321
+ return evaluateClaudeMdBudget(m.chars, m.budget, m.label, m.mapName);
322
+ }
323
+
291
324
  // Pure evaluator over migratePrds()'s { moved, skipped, unresolved } result —
292
325
  // kept separate from the fs-touching check() call site so it's directly
293
326
  // unit-testable, matching evaluateTickLiveness's pattern.
@@ -602,7 +635,8 @@ function evaluateUnresolvableDepHealth(jobs, satisfiedSlugsByCwd) {
602
635
  const roots = findUnresolvableDepRoots(rows, satisfied);
603
636
  if (roots.length === 0) continue;
604
637
  const rootSet = new Set(roots);
605
- const bare = (x) => String(x ?? '').replace(/^\d+-/, '');
638
+ // Same resolver dispatch uses (depSlugResolve.cjs makeDepResolver).
639
+ const { rowsForDep } = makeDepResolver(rows, satisfied);
606
640
  const held = new Set();
607
641
  let grew = true;
608
642
  while (grew) {
@@ -610,7 +644,7 @@ function evaluateUnresolvableDepHealth(jobs, satisfiedSlugsByCwd) {
610
644
  for (const j of pending) {
611
645
  if (held.has(j.slug)) continue;
612
646
  const isHeld = (j.dependsOn ?? []).some((d) => rootSet.has(d)
613
- || pending.some((p) => held.has(p.slug) && (p.slug === d || bare(p.slug) === bare(d))));
647
+ || rowsForDep(d, j).some((p) => p.status === 'pending' && held.has(p.slug)));
614
648
  if (isHeld) { held.add(j.slug); grew = true; }
615
649
  }
616
650
  }
@@ -806,8 +840,8 @@ function loadUsagePollerState(statePath) {
806
840
  *
807
841
  * Pure. A `needs_review` row parked longer than one full periodic-reverify
808
842
  * interval that STILL holds >= 1 pending dependent (transitively, through
809
- * pending rows, via dependsOn — exact or bare slug, same matching as the
810
- * picker) is a silently-blocking park: the self-heal ladder had a full pass
843
+ * pending rows, via dependsOn — resolved by depSlugResolve.cjs
844
+ * makeDepResolver, the picker's own rule) is a silently-blocking park: the self-heal ladder had a full pass
811
845
  * and did not release it. 2026-09-18: 1229-fo-03 held 19 of 20 pending rows
812
846
  * while every other component read GREEN. Parked-since is the row's last
813
847
  * `to: needs_review` statusHistory entry (fallback finishedAt); a row with no
@@ -815,7 +849,6 @@ function loadUsagePollerState(statePath) {
815
849
  */
816
850
  function evaluateBlockingParkHealth(jobs, now, thresholdMs = REVERIFY_INTERVAL_MS) {
817
851
  const rows = (Array.isArray(jobs) ? jobs : []).filter(Boolean);
818
- const bare = (x) => String(x ?? '').replace(/^\d+-/, '');
819
852
  const byCwd = new Map();
820
853
  for (const j of rows) {
821
854
  const cwd = j.cwd || DEFAULT_PROJECT_CWD;
@@ -826,6 +859,8 @@ function evaluateBlockingParkHealth(jobs, now, thresholdMs = REVERIFY_INTERVAL_M
826
859
  for (const [cwd, group] of byCwd) {
827
860
  const pending = group.filter((j) => j.status === 'pending');
828
861
  if (pending.length === 0) continue;
862
+ // Same resolver dispatch uses (depSlugResolve.cjs makeDepResolver).
863
+ const { rowsForDep } = makeDepResolver(group);
829
864
  for (const park of group) {
830
865
  if (park.status !== 'needs_review') continue;
831
866
  const history = Array.isArray(park.statusHistory) ? park.statusHistory : [];
@@ -836,13 +871,13 @@ function evaluateBlockingParkHealth(jobs, now, thresholdMs = REVERIFY_INTERVAL_M
836
871
  const since = Date.parse(at ?? park.finishedAt ?? '');
837
872
  if (Number.isNaN(since) || now - since <= thresholdMs) continue;
838
873
  const held = new Set();
839
- const heldBy = (d, root) => root.slug === d || bare(root.slug) === bare(d);
840
874
  let grew = true;
841
875
  while (grew) {
842
876
  grew = false;
843
877
  for (const j of pending) {
844
878
  if (held.has(j.slug)) continue;
845
- if ((j.dependsOn ?? []).some((d) => heldBy(d, park) || pending.some((p) => held.has(p.slug) && heldBy(d, p)))) {
879
+ if ((j.dependsOn ?? []).some((d) => rowsForDep(d, j)
880
+ .some((p) => p === park || (p.status === 'pending' && held.has(p.slug))))) {
846
881
  held.add(j.slug);
847
882
  grew = true;
848
883
  }
@@ -1222,11 +1257,7 @@ async function check(opts = {}) {
1222
1257
  // header (see the CLAUDE.md size-budget note). Skips silently when no
1223
1258
  // budget line is present — this is not required for every project.
1224
1259
  try {
1225
- const claudeMdPath = path.join(PROJECT_ROOT, 'CLAUDE.md');
1226
- const claudeMdText = fs.readFileSync(claudeMdPath, 'utf8');
1227
- const chars = Buffer.byteLength(claudeMdText, 'utf8');
1228
- const budget = parseClaudeMdBudget(claudeMdText);
1229
- const budgetResult = evaluateClaudeMdBudget(chars, budget);
1260
+ const budgetResult = evaluateRootClaudeMdBudget(PROJECT_ROOT);
1230
1261
  status.components.claude_md_budget = budgetResult;
1231
1262
  if (!budgetResult.ok) {
1232
1263
  status.issues.push(budgetResult.message);
@@ -1463,6 +1494,8 @@ module.exports = {
1463
1494
  evaluatePerProjectStall,
1464
1495
  parseClaudeMdBudget,
1465
1496
  evaluateClaudeMdBudget,
1497
+ measureRootClaudeMdPair,
1498
+ evaluateRootClaudeMdBudget,
1466
1499
  evaluateUsagePollerHealth,
1467
1500
  loadUsagePollerState,
1468
1501
  evaluateQueueDispatchHealth,