claude-code-session-manager 0.86.0 → 0.88.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 (335) hide show
  1. package/README.md +26 -53
  2. package/dist/assets/AgentLibrary-BZ6IY2g1.js +3 -0
  3. package/dist/assets/{DataModel-Q4jhl24R.js → DataModel-dAoGAODX.js} +1 -1
  4. package/dist/assets/{History-Cj2FejEo.js → History-CF157HyX.js} +2 -2
  5. package/dist/assets/{Hooks-CaelQI6t.js → Hooks-CCPPipBk.js} +3 -3
  6. package/dist/assets/{HostBilko--v7cMR8I.js → HostBilko-Dlmz2m06.js} +1 -1
  7. package/dist/assets/{Library-DgI9oCCZ.js → Library-BaXcboWX.js} +1 -1
  8. package/dist/assets/{ListDetail-DYUZN-x-.js → ListDetail-CoUCzG5S.js} +1 -1
  9. package/dist/assets/MarkdownEditor-DTg3JlOT.js +1 -0
  10. package/dist/assets/{McpServers-ypCYURh3.js → McpServers-DdjY1sA3.js} +2 -2
  11. package/dist/assets/{Memory-C2qYp-3M.js → Memory-BJ3Jlw0C.js} +4 -4
  12. package/dist/assets/{Panel-Cj2kw-Zv.js → Panel-ygRSgc41.js} +1 -1
  13. package/dist/assets/Permissions-m0KAnccF.js +3 -0
  14. package/dist/assets/{Plugins-C1Vj8_dU.js → Plugins-CJRl6B3Q.js} +2 -2
  15. package/dist/assets/{ProvenanceBadge-DczPNM5U.js → ProvenanceBadge-w8cnlVvW.js} +1 -1
  16. package/dist/assets/{SaveBar-Cd_7U6Gb.js → SaveBar-BpyPcUIk.js} +1 -1
  17. package/dist/assets/Scheduler-D2ppxSfy.js +14 -0
  18. package/dist/assets/{ScopeSwitcher-DVSyI44-.js → ScopeSwitcher-EyuIwt-j.js} +1 -1
  19. package/dist/assets/Settings-BHSGGFEc.js +3 -0
  20. package/dist/assets/{SkillReferenceGraph-CUv1_Q2c.js → SkillReferenceGraph-BNaZ2JCF.js} +1 -1
  21. package/dist/assets/{Skills-C_YHkAy-.js → Skills-Dl3q75QV.js} +2 -2
  22. package/dist/assets/{SystemPrompt-B8R7T9xn.js → SystemPrompt-Bg6F-Cyp.js} +1 -1
  23. package/dist/assets/{TagLibrary-dj9YHWyy.js → TagLibrary-BSutflCy.js} +1 -1
  24. package/dist/assets/{TiptapBody-DnSBUjHE.js → TiptapBody-CXih4xrc.js} +1 -1
  25. package/dist/assets/{Toggle-CjV_BJn6.js → Toggle-2qtUHhA9.js} +1 -1
  26. package/dist/assets/{index-CXFQIPhO.js → index-B3emy2oI.js} +583 -583
  27. package/dist/assets/{index-CDo9xBR9.css → index-BHTX4OTc.css} +1 -1
  28. package/dist/assets/settingsSchema-CdzxaqwM.js +3 -0
  29. package/dist/assets/{whisperWorker-Dbia1OpC.js → whisperWorker-C7ZGQwKg.js} +7 -7
  30. package/dist/index.html +2 -2
  31. package/dist/vad/ort-wasm-simd-threaded.asyncify.mjs +106 -110
  32. package/dist/vad/ort-wasm-simd-threaded.asyncify.wasm +0 -0
  33. package/dist/vad/ort-wasm-simd-threaded.jsep.mjs +98 -98
  34. package/dist/vad/ort-wasm-simd-threaded.jsep.wasm +0 -0
  35. package/dist/vad/ort-wasm-simd-threaded.jspi.mjs +99 -102
  36. package/dist/vad/ort-wasm-simd-threaded.jspi.wasm +0 -0
  37. package/dist/vad/ort-wasm-simd-threaded.mjs +46 -46
  38. package/dist/vad/ort-wasm-simd-threaded.wasm +0 -0
  39. package/package.json +14 -17
  40. package/plugins/CLAUDE.md +61 -0
  41. package/plugins/session-manager-dev/.claude-plugin/plugin.json +1 -1
  42. package/plugins/session-manager-dev/skills/builder/4-manual/SKILL.md +1 -1
  43. package/plugins/session-manager-dev/skills/ops-sweep/SKILL.md +1 -1
  44. package/scripts/README.md +59 -0
  45. package/scripts/audit-ops-hygiene.cjs +350 -0
  46. package/scripts/hooks/guard-destructive-git.cjs +10 -34
  47. package/scripts/hooks/guard-inline-implementation.cjs +14 -8
  48. package/scripts/hooks/guard-prd-writes.cjs +7 -36
  49. package/scripts/hooks/guard-self-schedule.cjs +175 -0
  50. package/scripts/ops-sweep.cjs +355 -0
  51. package/scripts/scheduler-mcp-server.cjs +35 -71
  52. package/src/main/__tests__/agentModelResolve.test.cjs +100 -9
  53. package/src/main/__tests__/bilkoHost-integration.test.cjs +3 -3
  54. package/src/main/__tests__/broadcastCoalescer.test.cjs +18 -0
  55. package/src/main/__tests__/chat-cancel-terminal.test.cjs +6 -9
  56. package/src/main/__tests__/chat-exit-close-race.test.cjs +3 -3
  57. package/src/main/__tests__/chat-mcp-consent-notice.test.cjs +4 -5
  58. package/src/main/__tests__/chat-queue.test.cjs +2 -2
  59. package/src/main/__tests__/chat-stop-signal.test.cjs +2 -2
  60. package/src/main/__tests__/dep-orphan-archive-health.test.cjs +77 -0
  61. package/src/main/__tests__/dod-batchkey.test.cjs +2 -2
  62. package/src/main/__tests__/dod-drain-hook.test.cjs +2 -2
  63. package/src/main/__tests__/dod-report.test.cjs +2 -2
  64. package/src/main/__tests__/dod-reverify.test.cjs +2 -2
  65. package/src/main/__tests__/epicMint.test.cjs +4 -4
  66. package/src/main/__tests__/exchanges.test.cjs +2 -2
  67. package/src/main/__tests__/extractJson.test.cjs +2 -2
  68. package/src/main/__tests__/files-reject-credentials.test.cjs +1 -1
  69. package/src/main/__tests__/fixtures/1218-fo-01-move-scripts-lib-into-src-main-lib.log +556 -0
  70. package/src/main/__tests__/health-build-freshness.test.cjs +39 -0
  71. package/src/main/__tests__/health-delegation-chain.test.cjs +17 -2
  72. package/src/main/__tests__/health-queue-dispatch.test.cjs +58 -7
  73. package/src/main/__tests__/health-tick-liveness.test.cjs +11 -3
  74. package/src/main/__tests__/health-usage-poller.test.cjs +70 -23
  75. package/src/main/__tests__/historyRollup.test.cjs +2 -2
  76. package/src/main/__tests__/kg-augment.test.cjs +2 -2
  77. package/src/main/__tests__/mcpStatus.test.cjs +2 -2
  78. package/src/main/__tests__/memoryAggregate.test.cjs +1 -1
  79. package/src/main/__tests__/memoryStale.test.cjs +1 -1
  80. package/src/main/__tests__/needsReviewLedger.test.cjs +162 -0
  81. package/src/main/__tests__/opsErrorLogTelemetryTap.test.cjs +28 -4
  82. package/src/main/__tests__/pollLoop-dispatch-on-failure.test.cjs +48 -4
  83. package/src/main/__tests__/prd-group-allocator.test.cjs +2 -2
  84. package/src/main/__tests__/prdAdminRouteParity.test.cjs +2 -0
  85. package/src/main/__tests__/prdAdminRoutes.test.cjs +14 -2
  86. package/src/main/__tests__/prdAuthoringSeed.test.cjs +39 -0
  87. package/src/main/__tests__/prdCreateDisposition.test.cjs +201 -0
  88. package/src/main/__tests__/prdFrontmatterDisposition.test.cjs +125 -0
  89. package/src/main/__tests__/prdLocations.test.cjs +100 -2
  90. package/src/main/__tests__/prdLocationsArchived.test.cjs +50 -1
  91. package/src/main/__tests__/prdSetDisposition.test.cjs +222 -0
  92. package/src/main/__tests__/proc-role-env.test.cjs +125 -0
  93. package/src/main/__tests__/procname-claude-spawn-sites.test.cjs +304 -0
  94. package/src/main/__tests__/procname-sm-processes.test.cjs +127 -0
  95. package/src/main/__tests__/projectHomeAdminRoutes.test.cjs +81 -401
  96. package/src/main/__tests__/projectPages.test.cjs +63 -149
  97. package/src/main/__tests__/queue-health-verdict.test.cjs +170 -0
  98. package/src/main/__tests__/queue-starvation-dispatch-driver.test.cjs +117 -20
  99. package/src/main/__tests__/queue-starvation-per-project.test.cjs +14 -2
  100. package/src/main/__tests__/queueHistory.test.cjs +65 -2
  101. package/src/main/__tests__/rateLimitPollerStreak.test.cjs +38 -3
  102. package/src/main/__tests__/reconcileTiming.test.cjs +135 -0
  103. package/src/main/__tests__/runVerify-landed-commit-outranks.test.cjs +181 -0
  104. package/src/main/__tests__/runVerify.test.cjs +5 -5
  105. package/src/main/__tests__/scheduleJobStatusDrift.test.cjs +3 -3
  106. package/src/main/__tests__/scheduleJobTransitions.test.cjs +103 -3
  107. package/src/main/__tests__/scheduler-adopted-run-supervision.test.cjs +143 -0
  108. package/src/main/__tests__/scheduler-autofix-select.test.cjs +2 -2
  109. package/src/main/__tests__/scheduler-autopromote.test.cjs +2 -2
  110. package/src/main/__tests__/scheduler-bash-timeout-env.test.cjs +3 -5
  111. package/src/main/__tests__/scheduler-boot-orphans.test.cjs +79 -98
  112. package/src/main/__tests__/scheduler-broadcast-reconcile.test.cjs +121 -0
  113. package/src/main/__tests__/scheduler-cross-project-batch.test.cjs +43 -0
  114. package/src/main/__tests__/scheduler-default-eligible-heal.test.cjs +161 -0
  115. package/src/main/__tests__/scheduler-dispatch-loop.test.cjs +58 -0
  116. package/src/main/__tests__/scheduler-epic-digest.test.cjs +3 -5
  117. package/src/main/__tests__/scheduler-force-tick-outcome.test.cjs +2 -2
  118. package/src/main/__tests__/scheduler-gate-shadow.test.cjs +119 -0
  119. package/src/main/__tests__/scheduler-guard-verdict-autoresolve.test.cjs +390 -0
  120. package/src/main/__tests__/scheduler-heartbeat-payload.test.cjs +80 -0
  121. package/src/main/__tests__/scheduler-inplace-salvage.test.cjs +25 -18
  122. package/src/main/__tests__/scheduler-investigation-prompt.test.cjs +4 -4
  123. package/src/main/__tests__/scheduler-job-budget.test.cjs +172 -0
  124. package/src/main/__tests__/scheduler-launch-failure.test.cjs +3 -5
  125. package/src/main/__tests__/scheduler-looks-done.test.cjs +119 -10
  126. package/src/main/__tests__/scheduler-manual-pause.test.cjs +118 -0
  127. package/src/main/__tests__/scheduler-meta-code-sha.test.cjs +26 -3
  128. package/src/main/__tests__/scheduler-porcelain-rename.test.cjs +164 -0
  129. package/src/main/__tests__/scheduler-prd-missing-skip.test.cjs +17 -2
  130. package/src/main/__tests__/scheduler-prd-persona-spawn.test.cjs +3 -5
  131. package/src/main/__tests__/scheduler-quiet-machine-lease.test.cjs +41 -6
  132. package/src/main/__tests__/scheduler-rate-limit-pause.test.cjs +62 -6
  133. package/src/main/__tests__/scheduler-rate-limit-spin-guard.test.cjs +3 -5
  134. package/src/main/__tests__/scheduler-reap-dead-running-jobs.test.cjs +182 -3
  135. package/src/main/__tests__/scheduler-reaper-helpers-basics.test.cjs +87 -0
  136. package/src/main/__tests__/scheduler-reconcile-cwd-preserve.test.cjs +100 -0
  137. package/src/main/__tests__/scheduler-reconcile-invalid-repair.test.cjs +3 -3
  138. package/src/main/__tests__/scheduler-reconcile-quarantine.test.cjs +4 -4
  139. package/src/main/__tests__/scheduler-shard-quarantine.test.cjs +110 -0
  140. package/src/main/__tests__/scheduler-shared-tree-guard.test.cjs +168 -0
  141. package/src/main/__tests__/scheduler-starve-escalation.test.cjs +18 -8
  142. package/src/main/__tests__/scheduler-stranded-autofix-park.test.cjs +245 -0
  143. package/src/main/__tests__/scheduler-supervisor-record.test.cjs +81 -0
  144. package/src/main/__tests__/scheduler-tick-cancel-token.test.cjs +2 -2
  145. package/src/main/__tests__/scheduler-tick-wedge.test.cjs +172 -0
  146. package/src/main/__tests__/scheduler-transient-failure.test.cjs +2 -2
  147. package/src/main/__tests__/scheduler-worktree-cap-defer.test.cjs +51 -11
  148. package/src/main/__tests__/scheduler-worktree-exec-cwd.test.cjs +3 -5
  149. package/src/main/__tests__/usageSingleFlight.test.cjs +157 -0
  150. package/src/main/__tests__/workTypeLibrary.test.cjs +1 -1
  151. package/src/main/bilkoHost.cjs +16 -7
  152. package/src/main/build-info.json +8 -0
  153. package/src/main/chatRunner.cjs +12 -7
  154. package/src/main/config.cjs +2 -3
  155. package/src/main/docEdit.cjs +4 -2
  156. package/src/main/health.cjs +268 -52
  157. package/src/main/heapSnapshot.cjs +2 -2
  158. package/src/main/historyAggregator.cjs +6 -1
  159. package/src/main/index.cjs +152 -50
  160. package/src/main/ipcSchemas.cjs +53 -17
  161. package/src/main/lib/__tests__/active-sessions.test.cjs +251 -0
  162. package/src/main/lib/__tests__/auditLog.test.cjs +38 -0
  163. package/src/main/lib/__tests__/bootSelfHeal.test.cjs +107 -0
  164. package/src/main/lib/__tests__/buildIdentity.test.cjs +121 -0
  165. package/src/main/lib/__tests__/cwdClassify.test.cjs +111 -0
  166. package/src/main/lib/__tests__/definitionOfDoneSequence.test.cjs +95 -0
  167. package/src/main/lib/__tests__/delegationReadiness.test.cjs +323 -44
  168. package/src/main/lib/__tests__/dispatchLoop.test.cjs +63 -0
  169. package/src/main/lib/__tests__/effectiveModelInfo.test.cjs +239 -0
  170. package/src/main/lib/__tests__/gateFixtures.json +20 -0
  171. package/src/main/lib/__tests__/gitWorktree.test.cjs +97 -1
  172. package/src/main/lib/__tests__/guardShims.test.cjs +151 -0
  173. package/src/main/lib/__tests__/instanceLock.test.cjs +93 -7
  174. package/src/main/lib/__tests__/jobSupervisorRecord.test.cjs +78 -0
  175. package/src/main/lib/__tests__/jobWorktreeBootLive.test.cjs +11 -0
  176. package/src/main/lib/__tests__/localAdminHttp.test.cjs +1 -1
  177. package/src/main/lib/__tests__/mcpToolCatalog.test.cjs +6 -1
  178. package/src/main/lib/__tests__/opsRootAbsoluteCwd.test.cjs +5 -5
  179. package/src/main/lib/__tests__/prdDisposition.test.cjs +224 -0
  180. package/src/main/lib/__tests__/procIdentity.test.cjs +119 -0
  181. package/src/main/lib/__tests__/procName.test.cjs +92 -0
  182. package/src/main/lib/__tests__/queueStoreMachineStateRecovery.test.cjs +67 -0
  183. package/src/main/lib/__tests__/reaperHelpers.test.cjs +179 -1
  184. package/src/main/lib/__tests__/schedulerMcpServerHelp.test.cjs +6 -7
  185. package/src/main/lib/__tests__/schedulerMcpServerProjectHome.test.cjs +37 -204
  186. package/src/main/lib/__tests__/schedulerPaths.test.cjs +226 -0
  187. package/src/main/lib/__tests__/schedulerPathsWorktree.test.cjs +94 -0
  188. package/src/main/lib/__tests__/schedulerRuntimeState.test.cjs +56 -0
  189. package/src/main/lib/__tests__/sessionSlots.test.cjs +45 -0
  190. package/src/main/lib/__tests__/telemetryBacklog.test.cjs +1 -1
  191. package/src/main/lib/__tests__/upgradeDrain.test.cjs +130 -0
  192. package/src/main/lib/__tests__/usageCircuit.test.cjs +285 -0
  193. package/src/main/lib/__tests__/watchdog-helpers.test.cjs +375 -0
  194. package/src/main/lib/__tests__/watchdog-relaunch.test.cjs +266 -0
  195. package/src/main/lib/activeIndexRebuild.cjs +1 -3
  196. package/{scripts → src/main}/lib/activeSessions.cjs +67 -89
  197. package/src/main/lib/adoptedRunSupervisor.cjs +136 -0
  198. package/src/main/lib/agentModelResolve.cjs +94 -24
  199. package/src/main/lib/agentPersonaSchema.cjs +2 -2
  200. package/src/main/lib/auditLog.cjs +30 -5
  201. package/src/main/lib/bootSelfHeal.cjs +88 -0
  202. package/src/main/lib/buildIdentity.cjs +113 -0
  203. package/src/main/lib/classifyPromptTicket.cjs +3 -2
  204. package/src/main/lib/claudeBin.cjs +37 -2
  205. package/src/main/lib/cleanEnv.cjs +27 -1
  206. package/src/main/lib/credentials.cjs +4 -2
  207. package/src/main/lib/cwdClassify.cjs +185 -0
  208. package/src/main/lib/definitionOfDone.cjs +296 -52
  209. package/src/main/lib/delegationReadiness.cjs +290 -225
  210. package/src/main/lib/dispatchLoop.cjs +40 -0
  211. package/src/main/lib/effectiveModelInfo.cjs +332 -0
  212. package/src/main/lib/ephemeralCwd.cjs +7 -28
  213. package/src/main/lib/epicMint.cjs +3 -3
  214. package/src/main/lib/gitWorktree.cjs +136 -19
  215. package/src/main/lib/guardShims.cjs +156 -0
  216. package/src/main/lib/historyRollup.cjs +6 -7
  217. package/src/main/lib/instanceLock.cjs +32 -5
  218. package/src/main/lib/jobDirtFilter.cjs +7 -2
  219. package/src/main/lib/jobSupervisorRecord.cjs +147 -0
  220. package/src/main/lib/jobWorktreeBootLive.cjs +9 -5
  221. package/src/main/lib/launchFailure.cjs +2 -1
  222. package/src/main/lib/localAdminHttp.cjs +9 -27
  223. package/src/main/lib/mcpToolCatalog.cjs +33 -78
  224. package/src/main/lib/needsReviewLedger.cjs +205 -0
  225. package/src/main/lib/opsErrorLog.cjs +1 -1
  226. package/src/main/lib/opsOwnership.cjs +27 -19
  227. package/src/main/lib/prdAuthoringSeed.cjs +36 -0
  228. package/src/main/lib/prdCreate.cjs +56 -1
  229. package/src/main/lib/prdDisposition.cjs +199 -0
  230. package/src/main/lib/prdFrontmatter.cjs +8 -2
  231. package/src/main/lib/prdLocations.cjs +214 -45
  232. package/src/main/lib/procIdentity.cjs +126 -0
  233. package/src/main/lib/procName.cjs +98 -0
  234. package/src/main/lib/projectHomeAdminRoutes.cjs +56 -327
  235. package/src/main/lib/projectRootResolve.cjs +1 -1
  236. package/src/main/lib/queueHistory.cjs +27 -8
  237. package/src/main/lib/queueStore.cjs +63 -38
  238. package/src/main/lib/quietMachineLease.cjs +19 -2
  239. package/src/main/lib/reaperHelpers.cjs +181 -15
  240. package/src/main/lib/reservationExpiry.cjs +30 -0
  241. package/src/main/lib/runClaudeP.cjs +4 -2
  242. package/src/main/lib/runLogRetention.cjs +3 -2
  243. package/src/main/lib/scheduleJobSchema.cjs +10 -2
  244. package/src/main/lib/scheduleJobTransitions.cjs +60 -0
  245. package/src/main/lib/schedulerBatch.cjs +27 -2
  246. package/src/main/lib/schedulerConfig.cjs +24 -0
  247. package/src/main/lib/schedulerPaths.cjs +175 -0
  248. package/src/main/lib/schedulerRuntimeState.cjs +59 -0
  249. package/src/main/lib/sessionSlots.cjs +47 -9
  250. package/src/main/lib/smProcNames.cjs +51 -0
  251. package/src/main/lib/upgradeDrain.cjs +188 -0
  252. package/src/main/lib/usageCircuit.cjs +206 -0
  253. package/{scripts → src/main}/lib/watchdogHelpers.cjs +71 -38
  254. package/src/main/lib/withTimeout.cjs +33 -0
  255. package/src/main/mcpStatus.cjs +4 -2
  256. package/src/main/pluginInstall.cjs +6 -2
  257. package/src/main/projectPages.cjs +41 -145
  258. package/src/main/pty.cjs +8 -1
  259. package/src/main/queueOps.cjs +10 -10
  260. package/src/main/runVerify.cjs +69 -3
  261. package/src/main/scheduler/prdParser.cjs +13 -0
  262. package/src/main/scheduler.cjs +2841 -482
  263. package/src/main/seedAgentPersonas.cjs +1 -1
  264. package/src/main/seedDevPlugin.cjs +1 -1
  265. package/src/main/seedSchedulerMcp.cjs +7 -6
  266. package/src/main/seedStatus.cjs +1 -1
  267. package/src/main/supervisor.cjs +5 -3
  268. package/src/main/templates/PRD_AUTHORING.md +50 -0
  269. package/src/main/usage.cjs +140 -58
  270. package/src/preload/api.d.ts +110 -65
  271. package/src/preload/index.cjs +12 -4
  272. package/src/seed/agents/project-home-builder.md +31 -48
  273. package/dist/assets/AgentLibrary-DTFL7y8G.js +0 -3
  274. package/dist/assets/MarkdownEditor-DCIubYWf.js +0 -1
  275. package/dist/assets/Permissions-BiYZNGYW.js +0 -3
  276. package/dist/assets/Scheduler-DcLBiJBq.js +0 -14
  277. package/dist/assets/Settings-Cv-pRyms.js +0 -3
  278. package/dist/assets/settingsSchema-BJVciriw.js +0 -3
  279. package/screenshots/.gitkeep +0 -0
  280. package/screenshots/README-screenshots.md +0 -13
  281. package/scripts/project-pages-logic/dist/logic.cjs +0 -4709
  282. package/scripts/render-project-pages/dist/renderer.cjs +0 -18900
  283. package/scripts/render-project-pages.cjs +0 -70
  284. package/scripts/validate-project-pages-summary.cjs +0 -62
  285. package/src/main/lib/projectPageSummarySchema.cjs +0 -181
  286. package/src/main/teams.cjs +0 -95
  287. package/src/main/templates/project-pages-catalog.json +0 -741
  288. package/src/main/templates/project-pages-default-home.html +0 -123
  289. package/src/main/templates/project-pages-pipeline.md +0 -417
  290. package/src/seed/prompts/code-review/ac-coverage-check.md +0 -8
  291. package/src/seed/prompts/code-review/correctness-only.md +0 -8
  292. package/src/seed/prompts/code-review/full-spectrum-high.md +0 -8
  293. package/src/seed/prompts/code-review/hallucination-check.md +0 -8
  294. package/src/seed/prompts/code-review/public-api-compat.md +0 -8
  295. package/src/seed/prompts/code-review/readability-naming.md +0 -8
  296. package/src/seed/prompts/debugging/bug-as-failing-test.md +0 -8
  297. package/src/seed/prompts/debugging/git-bisect-regression.md +0 -8
  298. package/src/seed/prompts/debugging/instrument-intermittent-bug.md +0 -8
  299. package/src/seed/prompts/debugging/localize-pipeline-failure.md +0 -8
  300. package/src/seed/prompts/debugging/reproduce-then-diagnose.md +0 -8
  301. package/src/seed/prompts/documentation/adr-from-change.md +0 -8
  302. package/src/seed/prompts/documentation/module-readme.md +0 -8
  303. package/src/seed/prompts/documentation/onboarding-plan.md +0 -8
  304. package/src/seed/prompts/documentation/refresh-claude-md.md +0 -8
  305. package/src/seed/prompts/documentation/tsdoc-public-exports.md +0 -8
  306. package/src/seed/prompts/git-pr/conventional-commit.md +0 -8
  307. package/src/seed/prompts/git-pr/draft-pr-title-body.md +0 -8
  308. package/src/seed/prompts/git-pr/pre-commit-safety-sweep.md +0 -8
  309. package/src/seed/prompts/git-pr/release-notes-block.md +0 -8
  310. package/src/seed/prompts/git-pr/split-large-pr.md +0 -8
  311. package/src/seed/prompts/performance/bundle-startup-audit.md +0 -8
  312. package/src/seed/prompts/performance/complexity-audit.md +0 -8
  313. package/src/seed/prompts/performance/cpu-profile-hot-path.md +0 -8
  314. package/src/seed/prompts/performance/db-query-plan-review.md +0 -8
  315. package/src/seed/prompts/performance/memory-leak-hunt.md +0 -8
  316. package/src/seed/prompts/qa/api-contract-tests.md +0 -8
  317. package/src/seed/prompts/qa/e2e-critical-path.md +0 -8
  318. package/src/seed/prompts/qa/failing-test-for-bug.md +0 -8
  319. package/src/seed/prompts/qa/find-missing-test-coverage.md +0 -8
  320. package/src/seed/prompts/qa/stabilize-flaky-test.md +0 -8
  321. package/src/seed/prompts/qa/tdd-red-first.md +0 -8
  322. package/src/seed/prompts/qa/visual-regression-review.md +0 -8
  323. package/src/seed/prompts/qa/wcag-axe-scan.md +0 -8
  324. package/src/seed/prompts/refactoring/dead-code-sweep.md +0 -8
  325. package/src/seed/prompts/refactoring/extract-duplicated-pattern.md +0 -8
  326. package/src/seed/prompts/refactoring/modernize-legacy-file.md +0 -8
  327. package/src/seed/prompts/refactoring/reduce-cyclomatic-complexity.md +0 -8
  328. package/src/seed/prompts/refactoring/tighten-module-boundaries.md +0 -8
  329. package/src/seed/prompts/security/authz-audit.md +0 -8
  330. package/src/seed/prompts/security/crypto-correctness.md +0 -8
  331. package/src/seed/prompts/security/cwe-top-25-hunt.md +0 -8
  332. package/src/seed/prompts/security/dependency-audit.md +0 -8
  333. package/src/seed/prompts/security/ipc-boundary-hardening.md +0 -8
  334. package/src/seed/prompts/security/owasp-top-10-staged-diff.md +0 -8
  335. package/src/seed/prompts/security/secret-credential-scan.md +0 -8
@@ -1,3 +1,8 @@
1
+ const { PROC_NAMES, setProcessTitle, inhibitHolderShell } = require('./lib/smProcNames.cjs');
2
+ // Self-describing `comm` in System Monitor (pn-03). process.argv is a JS copy
3
+ // made at startup, so the argv-memory overwrite below never affects the
4
+ // `process.argv.includes('--simple')` read further down.
5
+ setProcessTitle(PROC_NAMES.main);
1
6
  const { app, BrowserWindow, ipcMain, dialog, Menu, session, systemPreferences, globalShortcut, shell, clipboard, powerSaveBlocker, protocol } = require('electron');
2
7
  const { spawn, execFile, execFileSync } = require('node:child_process');
3
8
  const path = require('node:path');
@@ -37,7 +42,12 @@ const epicWorktreeMint = require('./lib/epicWorktreeMint.cjs');
37
42
  const epicWorktreeMerge = require('./lib/epicWorktreeMerge.cjs');
38
43
  const epicWorktreeProjectConfig = require('./lib/epicWorktreeProjectConfig.cjs');
39
44
  const agentLibrary = require('./agentLibrary.cjs');
40
- const { checkDelegationReadiness, installPrdWriteGuard, installDestructiveGitGuard, installInlineImplementationGuard } = require('./lib/delegationReadiness.cjs');
45
+ const agentModelResolve = require('./lib/agentModelResolve.cjs');
46
+ const { resolveEffectiveModelInfo } = require('./lib/effectiveModelInfo.cjs');
47
+ const { checkDelegationReadiness, ensureGuardsInstalled, installPrdWriteGuard, installDestructiveGitGuard, installInlineImplementationGuard, installSelfScheduleGuard } = require('./lib/delegationReadiness.cjs');
48
+ const { resolveProjectContext } = require('./lib/projectRootResolve.cjs');
49
+ const upgradeDrain = require('./lib/upgradeDrain.cjs');
50
+ const { writeGuardShims } = require('./lib/guardShims.cjs');
41
51
  const { MCP_TOOL_CATALOG, MCP_RECIPES } = require('./lib/mcpToolCatalog.cjs');
42
52
  const { sendIfAlive } = require('./lib/sendToRenderer.cjs');
43
53
  const { resolveBuildTarget } = require('./lib/buildTarget.cjs');
@@ -54,7 +64,6 @@ chatRunner.registerAdminRoute(adminHttp);
54
64
  crossProjectFeedback.registerAdminRoute(adminHttp);
55
65
  const supervisor = require('./supervisor.cjs');
56
66
  const watchers = require('./watchers.cjs');
57
- const teams = require('./teams.cjs');
58
67
  const queueOps = require('./queueOps.cjs');
59
68
  const pluginInstall = require('./pluginInstall.cjs');
60
69
  const { seedDevPlugin } = require('./seedDevPlugin.cjs');
@@ -70,7 +79,7 @@ const telemetryConsent = require('./lib/telemetryConsent.cjs');
70
79
  const { registerHistoryAggregatorHandlers, finalizeClosedDays, refreshIntradayToday } = require('./historyAggregator.cjs');
71
80
  const runLogRetention = require('./lib/runLogRetention.cjs');
72
81
  const { registerHistoryDashboardHandlers } = require('./historyDashboard.cjs');
73
- const { tryAcquireLock, releaseLock, DEFAULT_LOCK_PATH } = require('../../scripts/lib/watchdogHelpers.cjs');
82
+ const { tryAcquireLock, releaseLock, DEFAULT_LOCK_PATH } = require('./lib/watchdogHelpers.cjs');
74
83
  const schedulerConfig = require('./lib/schedulerConfig.cjs');
75
84
  const memoryTool = require('./memoryTool.cjs');
76
85
  const { registerMemoryAggregateIpc } = require('./memoryAggregate.cjs');
@@ -90,7 +99,8 @@ const { checkInsideHome, assertInsideHome } = require('./lib/insideHome.cjs');
90
99
  const { openInEditor, openFileInEditor, openInFinder, openInTerminal } = require('./lib/openExternalApp.cjs');
91
100
  const { rebuildActiveIndex } = require('./lib/activeIndexRebuild.cjs');
92
101
  const { activeIndexPath: promptSessionsActiveIndexPath } = require('./lib/epicMint.cjs');
93
- const { allProjectCwds } = require('../../scripts/lib/activeSessions.cjs');
102
+ const { allProjectCwds } = require('./lib/activeSessions.cjs');
103
+ const { scheduleBootSelfHeal } = require('./lib/bootSelfHeal.cjs');
94
104
 
95
105
  let mainWindow = null;
96
106
  let rebooting = false;
@@ -130,7 +140,10 @@ function startSystemdInhibit() {
130
140
  '--who=Claude Session Manager',
131
141
  '--why=Scheduler polling and claude -p jobs must survive idle',
132
142
  '--mode=block',
133
- 'sh', '-c', `while kill -0 ${process.pid} 2>/dev/null; do sleep 5; done`,
143
+ // sm-inhibit-hold: aliased shell so the permanent holder is attributable
144
+ // in System Monitor (its `sleep 5` child stays a bare `sleep`, parented
145
+ // under it). Falls back to plain /bin/sh if the alias can't be made.
146
+ inhibitHolderShell(), '-c', `while kill -0 ${process.pid} 2>/dev/null; do sleep 5; done`,
134
147
  ], { stdio: 'ignore', detached: false });
135
148
  child.on('error', (e) => {
136
149
  logs.writeLine({ scope: 'main', level: 'warn', message: 'systemd-inhibit spawn failed', meta: { error: e?.message } });
@@ -303,7 +316,26 @@ function relaunchViaNpx() {
303
316
  return child;
304
317
  }
305
318
 
306
- async function rebootApp() {
319
+ /**
320
+ * rebootApp({force}) — restart is a REQUEST that drains first and never kills
321
+ * (lib/upgradeDrain.cjs): dispatch pauses, running jobs finish, then the
322
+ * scheduler's heartbeat-driven drain calls performReboot(). `force: true`
323
+ * keeps the old immediate behaviour (kills running executors) for humans who
324
+ * accept the cost.
325
+ */
326
+ async function rebootApp({ force = false } = {}) {
327
+ if (force) {
328
+ logReboot('force reboot requested — immediate, not draining');
329
+ return performReboot();
330
+ }
331
+ const request = upgradeDrain.requestRestart({ reason: 'user-reboot', requestedBy: 'user' });
332
+ logReboot(`restart requested (drain first): ${request.requestedAt}`);
333
+ }
334
+
335
+ // Registered as the scheduler's drain-complete exit path (zero running jobs).
336
+ scheduler.setRestartHandler(() => performReboot());
337
+
338
+ async function performReboot() {
307
339
  ptyManager.killAll();
308
340
  configMgr.closeAllWatchers();
309
341
  closeAllProjectPagesWatchers();
@@ -338,6 +370,9 @@ async function rebootApp() {
338
370
  return;
339
371
  }
340
372
 
373
+ // Bounded-lifetime marker: the watchdog must not relaunch a second instance
374
+ // during this deliberate exit window (single-instance-lock race).
375
+ upgradeDrain.markRestarting();
341
376
  let childOk = false;
342
377
  try {
343
378
  const child = relaunchViaNpx();
@@ -520,12 +555,88 @@ ipcMain.handle('agents:remove-override', async (_e, payload) => {
520
555
  ipcMain.handle('agents:get-persona-body', validated(schemas.agentsGetPersonaBody, (payload) =>
521
556
  agentLibrary.getPersonaBody(payload)));
522
557
 
558
+ // "What will this Epic's launch actually use for --model?" — the SAME
559
+ // resolver chatRunner.cjs's Chat-view launch calls in-process
560
+ // (agentModelResolve.cjs's resolveEpicModel), reached here so Terminal's
561
+ // launch (EpicTerminalPane.tsx, a renderer module with no fs access) agrees
562
+ // with Chat by calling the identical function rather than a second one that
563
+ // is merely supposed to. Never throws (resolveEpicModel's own contract).
564
+ ipcMain.handle('agents:resolve-epic-model', validated(schemas.agentsResolveEpicModel, (payload) =>
565
+ agentModelResolve.resolveEpicModel(payload)));
566
+
567
+ // "What will this Epic actually run as?" (PRD: effective-model-resolver) —
568
+ // persona alias + evidence-based concrete model id + provenance, for a given
569
+ // (cwd, agentType). Read-only observer; never affects what a launch resolves.
570
+ ipcMain.handle('agents:resolve-model-info', validated(schemas.agentsResolveModelInfo, (payload) =>
571
+ resolveEffectiveModelInfo(payload)));
572
+
523
573
  // "Can this project actually delegate?" probe (PRD: delegation-readiness).
524
574
  // Structured data over the preconditions for scheduler_create_prd being in an
525
575
  // agent's tool list at all — surfacing it in the UI is a sibling PRD.
526
- ipcMain.handle('app:delegation-readiness', validated(schemas.delegationReadinessCwd, async (payload) =>
527
- checkDelegationReadiness(payload)
528
- ));
576
+ //
577
+ // Self-heals BEFORE computing the checks (PRD: guards-auto-install) — Fix It
578
+ // used to be the only call site for the three guard installers, so every
579
+ // project the human opened started red and demanded three manual clicks.
580
+ // ensureGuardsInstalled never rejects on its own, but it is still awaited
581
+ // inside a try/catch here so a future change to it can never turn this into
582
+ // a rejected IPC handler.
583
+ //
584
+ // `cwd` is normalized to its real project root via the SAME resolver
585
+ // prdAdminRoutes.cjs's session_manager_help readiness route already uses
586
+ // (projectRootResolve.cjs's resolveProjectContext) before either the install
587
+ // or the read-back check runs, so a worktree/ops-internal cwd can't install
588
+ // into one path while the banner reads another.
589
+ ipcMain.handle('app:delegation-readiness', validated(schemas.delegationReadinessCwd, async (payload) => {
590
+ const resolved = resolveProjectContext({ cwd: payload.cwd });
591
+ const cwd = resolved.cwd || payload.cwd;
592
+ try {
593
+ await ensureGuardsInstalled(cwd);
594
+ } catch { /* auto-install must never block the readiness probe itself */ }
595
+ return checkDelegationReadiness({ ...payload, cwd });
596
+ }));
597
+
598
+ // Every guard-install attempt is logged from MAIN, not the renderer — a
599
+ // press that never reaches this process (e.g. a renderer talking to an
600
+ // older main with no handler for the channel, Electron's own "No handler
601
+ // registered for ..." rejection) leaves no line here, which is exactly what
602
+ // makes it distinguishable from a press that reached main and failed. Uses
603
+ // opsErrorLog.appendError (the sole writer of the `logs` ops namespace) so
604
+ // the record lands in the project's own
605
+ // session-manager-operations/logs/errors-<date>.jsonl, same shape as every
606
+ // other structured error line.
607
+ function logGuardInstallAttempt(guard, cwd, outcome) {
608
+ const opsErrorLog = require('./lib/opsErrorLog.cjs');
609
+ opsErrorLog.appendError({
610
+ cwd,
611
+ scope: 'delegationReadinessGuardInstall',
612
+ level: outcome.ok ? 'info' : 'error',
613
+ message: outcome.ok
614
+ ? `${guard} install ${outcome.action}`
615
+ : `${guard} install failed: ${outcome.error || 'unknown error'}`,
616
+ meta: { guard, ...outcome },
617
+ });
618
+ }
619
+
620
+ async function handleGuardInstall(guard, installFn, payload) {
621
+ // Normalized the SAME way the sibling app:delegation-readiness handler
622
+ // above normalizes cwd, before either installing or logging — without
623
+ // this, a worktree/ops-internal cwd installs the guard into an ephemeral
624
+ // `.claude/settings.json` that vanishes with the worktree (this repo's
625
+ // "Worktree cwd ops-root hazard" incident class), diverging from the
626
+ // main-tree root the readiness banner (and its own auto-heal path,
627
+ // ensureGuardsInstalled) actually reads.
628
+ const resolved = resolveProjectContext({ cwd: payload.cwd });
629
+ const cwd = resolved.cwd || payload.cwd;
630
+ const normalizedPayload = { ...payload, cwd };
631
+ try {
632
+ const result = await installFn(normalizedPayload);
633
+ logGuardInstallAttempt(guard, cwd, result);
634
+ return result;
635
+ } catch (err) {
636
+ logGuardInstallAttempt(guard, cwd, { ok: false, action: 'error', error: err?.message ?? String(err) });
637
+ throw err;
638
+ }
639
+ }
529
640
 
530
641
  // The three readiness checks with a sanctioned one-press install. Session
531
642
  // Manager standardizes on the REFERENCE approach (absolute path to this
@@ -536,13 +647,16 @@ ipcMain.handle('app:delegation-readiness', validated(schemas.delegationReadiness
536
647
  // header. inline-implementation-guard shares prd-write-guard's matcher, so
537
648
  // its installer appends into that SAME matcher's `hooks` array instead.
538
649
  ipcMain.handle('app:install-prd-write-guard', validated(schemas.delegationReadinessCwd, (payload) =>
539
- installPrdWriteGuard(payload)
650
+ handleGuardInstall('prd-write-guard', installPrdWriteGuard, payload)
540
651
  ));
541
652
  ipcMain.handle('app:install-destructive-git-guard', validated(schemas.delegationReadinessCwd, (payload) =>
542
- installDestructiveGitGuard(payload)
653
+ handleGuardInstall('destructive-git-guard', installDestructiveGitGuard, payload)
543
654
  ));
544
655
  ipcMain.handle('app:install-inline-implementation-guard', validated(schemas.delegationReadinessCwd, (payload) =>
545
- installInlineImplementationGuard(payload)
656
+ handleGuardInstall('inline-implementation-guard', installInlineImplementationGuard, payload)
657
+ ));
658
+ ipcMain.handle('app:install-self-schedule-guard', validated(schemas.delegationReadinessCwd, (payload) =>
659
+ handleGuardInstall('self-schedule-guard', installSelfScheduleGuard, payload)
546
660
  ));
547
661
 
548
662
  ipcMain.handle('app:engage-rules-path', () => process.env.SESSION_MANAGER_ENGAGE_RULES || null);
@@ -570,7 +684,7 @@ ipcMain.handle('app:pick-directory', async () => {
570
684
  return result.filePaths[0];
571
685
  });
572
686
 
573
- ipcMain.on('app:reboot-app', () => rebootApp());
687
+ ipcMain.on('app:reboot-app', (_e, opts) => { rebootApp({ force: opts?.force === true }).catch((e) => logReboot(`reboot failed: ${e?.message}`)); });
574
688
 
575
689
  // Image paste — Ctrl+V in the Terminal pane. Reads the OS clipboard via
576
690
  // Electron's native API (renderer's navigator.clipboard.read() doesn't expose
@@ -845,7 +959,6 @@ voiceHotkey.registerHotkeyHandlers();
845
959
  voiceWizard.registerWizardHandlers();
846
960
  scheduler.registerScheduleHandlers();
847
961
  watchers.registerWatcherHandlers();
848
- teams.registerTeamsHandlers();
849
962
  queueOps.registerQueueOpsHandlers({ retireCompletedSlugs: scheduler.retireCompletedSlugs });
850
963
  registerHistoryAggregatorHandlers();
851
964
  registerHistoryDashboardHandlers();
@@ -1164,6 +1277,7 @@ app.whenReady().then(async () => {
1164
1277
 
1165
1278
  const heapSnapshotMenuItem = heapSnapshot.buildMenuItem(() => mainWindow);
1166
1279
 
1280
+ // Application menu rules + rationale: session-manager-operations/architecture/application-menu.md
1167
1281
  const template = [
1168
1282
  {
1169
1283
  label: 'Session Manager',
@@ -1180,7 +1294,7 @@ app.whenReady().then(async () => {
1180
1294
  {
1181
1295
  label: 'Restart Session Manager App',
1182
1296
  accelerator: 'CmdOrCtrl+Shift+R',
1183
- click: rebootApp,
1297
+ click: () => { rebootApp().catch((e) => logReboot(`reboot failed: ${e?.message}`)); },
1184
1298
  },
1185
1299
  {
1186
1300
  label: 'Restart Terminal in Active Tab',
@@ -1274,42 +1388,22 @@ app.whenReady().then(async () => {
1274
1388
  seedSchedulerMcp({ logger: console, writeLog: logs.writeLine }).catch((e) => {
1275
1389
  logs.writeLine({ scope: 'seed-scheduler-mcp', level: 'error', message: 'seed failed', meta: { error: e?.message } });
1276
1390
  });
1391
+ // Rewrite the stable guard-hook shims (~/.claude/session-manager/hooks/) to
1392
+ // point at THIS running app's root, on every boot. An already-installed
1393
+ // project hook resolves through the shim at invocation time, so an app
1394
+ // upgrade (a new npx hash dir) just follows along with no re-install — see
1395
+ // guardShims.cjs's header.
1396
+ writeGuardShims().catch((e) => {
1397
+ logs.writeLine({ scope: 'guard-shims', level: 'error', message: 'writeGuardShims failed', meta: { error: e?.message } });
1398
+ });
1277
1399
  // Epic index self-heal: a project whose active-index.json is MISSING or
1278
1400
  // fails to parse has lost every open Epic's status unless the per-Epic
1279
- // status mirror (epicStatusMirror.cjs) can rebuild it. Runs once per boot,
1280
- // fire-and-forget, and only touches a project whose index reads unclean —
1281
- // a clean index is never rewritten here. See activeIndexRebuild.cjs.
1282
- try {
1283
- for (const projectCwd of allProjectCwds()) {
1284
- const indexPath = promptSessionsActiveIndexPath(projectCwd);
1285
- let unclean = false;
1286
- let parseError = null;
1287
- if (!fs.existsSync(indexPath)) {
1288
- unclean = true;
1289
- } else {
1290
- try {
1291
- JSON.parse(fs.readFileSync(indexPath, 'utf8'));
1292
- } catch (e) {
1293
- unclean = true;
1294
- parseError = e.message;
1295
- }
1296
- }
1297
- if (!unclean) continue;
1298
- try {
1299
- const { rows, skipped } = rebuildActiveIndex(projectCwd);
1300
- logs.writeLine({
1301
- scope: 'active-index-rebuild',
1302
- level: 'info',
1303
- message: 'rebuilt active-index.json from status mirrors',
1304
- meta: { cwd: projectCwd, parseError, restored: rows.length, skipped: skipped.length },
1305
- });
1306
- } catch (e) {
1307
- logs.writeLine({ scope: 'active-index-rebuild', level: 'error', message: 'rebuild failed', meta: { cwd: projectCwd, error: e?.message } });
1308
- }
1309
- }
1310
- } catch (e) {
1311
- logs.writeLine({ scope: 'active-index-rebuild', level: 'error', message: 'boot sweep failed', meta: { error: e?.message } });
1312
- }
1401
+ // status mirror (epicStatusMirror.cjs) can rebuild it. Runs once per boot
1402
+ // and only touches a project whose index reads unclean — a clean index is
1403
+ // never rewritten. Deferred until the window paints (did-finish-load) so
1404
+ // the ~270ms allProjectCwds() scan doesn't compete with the renderer's
1405
+ // first IPC round trips for the event loop — see bootSelfHeal.cjs.
1406
+ scheduleBootSelfHeal(mainWindow, { fs, allProjectCwds, promptSessionsActiveIndexPath, rebuildActiveIndex, logs });
1313
1407
  // History rollup finalize pass: deferred 30s past boot so it never competes
1314
1408
  // with first-paint, fire-and-forget (cron/offline refresh is PRD 651 — this
1315
1409
  // is just the one-shot in-app pass).
@@ -1340,7 +1434,7 @@ app.whenReady().then(async () => {
1340
1434
  }, 30_000);
1341
1435
  // Keep TODAY's rollup line current so the History dashboard never needs to
1342
1436
  // fall back to a live transcript scan. Shares the same O_EXCL lock file as
1343
- // the external watchdog's finalize pass (scripts/lib/watchdogHelpers.cjs)
1437
+ // the external watchdog's finalize pass (src/main/lib/watchdogHelpers.cjs)
1344
1438
  // so the two never interleave writes to the rollup; a contended lock just
1345
1439
  // means this tick's refresh is skipped (harmless — the next tick retries).
1346
1440
  const intradayTimer = setInterval(runIntradayRefresh, schedulerConfig.HISTORY_INTRADAY_REFRESH_MS);
@@ -1392,6 +1486,14 @@ function runShutdownCleanup() {
1392
1486
  // Mark a clean exit so the next boot can distinguish a graceful quit from an
1393
1487
  // OOM-kill / native crash (which leaves the sentinel `open`).
1394
1488
  crashDiagnostics.markCleanShutdown();
1489
+ // Release scheduler ownership on every teardown path, not just before-quit
1490
+ // — the app.exit() sites (in-app reboot, dist-missing abort) bypass
1491
+ // before-quit entirely and previously left a stale lock behind (fail-closed
1492
+ // proc-identity recovery covers a hard crash, but a clean app.exit() should
1493
+ // never need it). Pid-scoped and idempotent, so a redundant call from a
1494
+ // later before-quit/will-quit firing is a safe no-op.
1495
+ releaseSchedulerOwnership();
1496
+ try { scheduler.stop(); } catch { /* */ }
1395
1497
  // PRD F1 v2 §IPC plumbing: must unregisterAll on will-quit.
1396
1498
  try { globalShortcut.unregisterAll(); } catch { /* */ }
1397
1499
  voiceHotkey.disposeOnQuit();
@@ -320,6 +320,11 @@ const PrdAgentTypeSchema = z.string().regex(PERSONA_NAME_RE, 'agent name must be
320
320
  // call site since update also allows an explicit empty array to CLEAR the
321
321
  // dependency, which create has no reason to accept.
322
322
  const DepSlugSchema = z.string().min(1).max(160).regex(/^[A-Za-z0-9][\w.-]*$/);
323
+ // Wave-authoring decision (scheduler wave-disposition PRD), shared between
324
+ // schedulerCreatePrd (authoring time) and adminPrdFrontmatterPatch (the
325
+ // after-the-fact change path) so both can never disagree on what a valid
326
+ // disposition value is.
327
+ const PrdDispositionSchema = z.enum(['append', 'new-head']);
323
328
  const schedulerCreatePrd = z.object({
324
329
  title: z.string().min(1).max(200).regex(NO_NEWLINE_RE, 'must not contain newlines'),
325
330
  // Optional (PRD: worktree-cwd Epic-lookup hazard) — when omitted, prdCreate.cjs's
@@ -340,6 +345,12 @@ const schedulerCreatePrd = z.object({
340
345
  // Explicit ordering (PRD 832): slugs that must complete before this PRD
341
346
  // becomes eligible. Written to frontmatter as `dependsOn: [a, b]`.
342
347
  dependsOn: z.array(DepSlugSchema).max(20).optional(),
348
+ // Explicit wave-authoring decision (scheduler wave-disposition PRD) — only
349
+ // meaningful (and only stamped) when this PRD joins an Epic that already
350
+ // has incomplete PRDs and lands as a wave root (no dependsOn of its own);
351
+ // createPrd() requires it in that situation for an interactive caller and
352
+ // defaults to 'append' (logged as a default) for a non-interactive one.
353
+ disposition: PrdDispositionSchema.optional(),
343
354
  // An EXISTING Epic's promptSessionId (PRD 748) — NOT a PromptTicket.id.
344
355
  // ensureEpic() (epicMint.cjs) joins the Epic whose active-index.json
345
356
  // sessions key literally equals this value; the renderer only ever sends
@@ -387,6 +398,19 @@ const schedulerCreatePrd = z.object({
387
398
  quietMachine: z.boolean().optional(),
388
399
  });
389
400
 
401
+ // Renderer-facing counterpart to adminPrdFrontmatterPatch's dependsOn/
402
+ // disposition patch (scheduler wave-disposition PRD) — backs the Scheduler
403
+ // UI's "change disposition" action. `dependsOn` is the caller's already-
404
+ // computed target (from the SAME backlog tree the UI renders — see
405
+ // lib/backlogTree.ts); the main-process handler only validates the rewrite
406
+ // is safe (prdDisposition.cjs), never re-derives "the" terminal itself.
407
+ const scheduleSetPrdDisposition = z.object({
408
+ slug: z.string().regex(SCHEDULE_SLUG_RE),
409
+ cwd: z.string().min(1).max(4096).optional(),
410
+ disposition: PrdDispositionSchema,
411
+ dependsOn: z.array(DepSlugSchema).max(20).optional(),
412
+ });
413
+
390
414
  // Bulk archive: slug list, capped to limit unbounded retag/archive payloads.
391
415
  // Optional cwd narrows every slug's directory search to one project (same
392
416
  // role as scheduler_get_prd/scheduler_update_prd's cwd hint) — omitted, the
@@ -469,6 +493,11 @@ const adminPrdFrontmatterPatch = z.object({
469
493
  // (depSlugResolve.cjs) scheduler_create_prd uses, so update and create
470
494
  // can never disagree about what a dependsOn entry resolves to.
471
495
  dependsOn: z.array(DepSlugSchema).max(20).optional(),
496
+ // Patchable after creation too — the Scheduler UI's "change disposition"
497
+ // action (promote a wave to its own head, or attach it behind another
498
+ // chain) rewrites this alongside dependsOn via the same
499
+ // schedule:set-prd-disposition path (see prdDisposition.cjs).
500
+ disposition: PrdDispositionSchema.optional(),
472
501
  });
473
502
 
474
503
  const adminUpdatePrd = z.object({
@@ -623,28 +652,34 @@ const agentsGetPersonaBody = z.object({
623
652
  name: z.string().min(1).max(200),
624
653
  }).strict();
625
654
 
626
- // ──────────────────────────────────────────── Project Pages (PRD 932)
627
- // Same validation split as projectBriefCwd above: real path validation is
628
- // config.cjs's validatePath at first fs access in projectPages.cjs.
629
- const projectPagesCwd = z.object({
655
+ // ──────────────────────────────────────────── Effective model info (PRD: what-will-this-run-as)
656
+ const agentsResolveModelInfo = z.object({
630
657
  cwd: z.string().min(1).max(4096),
658
+ agentType: z.string().min(1).max(200),
631
659
  }).strict();
632
660
 
633
- // ──────────────────────────────────────────── Project Home admin routes
634
- // (PRD: project-home-admin-routes). Same validation split as
635
- // projectPagesCwd above: real path validation is projectRootResolve.cjs +
636
- // config.cjs's validatePath at first fs access.
637
- const projectHomeAdminCwdQuery = z.object({
661
+ // ──────────────────────────────────────────── Epic launch model (PRD: unify-epic-model-resolution)
662
+ // Terminal's (EpicTerminalPane.tsx) call into agentModelResolve.cjs's
663
+ // resolveEpicModel — the same launch-model authority chatRunner.cjs's Chat
664
+ // path calls in-process, reached here over IPC since the renderer has no fs.
665
+ const agentsResolveEpicModel = z.object({
638
666
  cwd: z.string().min(1).max(4096),
667
+ claudeSessionId: z.string().min(1).max(200),
639
668
  }).strict();
640
- const projectHomeAdminValidateSummaryBody = z.object({
669
+
670
+ // ──────────────────────────────────────────── Project Pages (PRD 932)
671
+ // Same validation split as projectBriefCwd above: real path validation is
672
+ // config.cjs's validatePath at first fs access in projectPages.cjs.
673
+ const projectPagesCwd = z.object({
641
674
  cwd: z.string().min(1).max(4096),
642
- summary: z.unknown(),
643
675
  }).strict();
644
- const projectHomeAdminRenderBody = z.object({
676
+
677
+ // ──────────────────────────────────────────── Project Home admin route
678
+ // Real path validation is projectRootResolve.cjs + config.cjs's validatePath;
679
+ // html content limits live in projectHomeAdminRoutes.cjs's validateHomeHtml.
680
+ const projectHomeAdminWriteBody = z.object({
645
681
  cwd: z.string().min(1).max(4096),
646
- summary: z.unknown(),
647
- picks: z.unknown(),
682
+ html: z.string(),
648
683
  }).strict();
649
684
 
650
685
  // ──────────────────────────────────────────── Host on Bilko.run
@@ -1037,6 +1072,7 @@ module.exports = {
1037
1072
  scheduleReadLog,
1038
1073
  scheduleWritePrd,
1039
1074
  schedulerCreatePrd,
1075
+ scheduleSetPrdDisposition,
1040
1076
  scheduleArchivePrd,
1041
1077
  scheduleRetagPrd,
1042
1078
  adminListPrdsQuery,
@@ -1070,9 +1106,7 @@ module.exports = {
1070
1106
  memoryStale,
1071
1107
  projectBriefCwd,
1072
1108
  projectPagesCwd,
1073
- projectHomeAdminCwdQuery,
1074
- projectHomeAdminValidateSummaryBody,
1075
- projectHomeAdminRenderBody,
1109
+ projectHomeAdminWriteBody,
1076
1110
  bilkoHostCwd,
1077
1111
  bilkoHostPrepareBundle,
1078
1112
  bilkoHostAddDocument,
@@ -1108,6 +1142,8 @@ module.exports = {
1108
1142
  exchangesList,
1109
1143
  agentsSavePersona,
1110
1144
  agentsGetPersonaBody,
1145
+ agentsResolveModelInfo,
1146
+ agentsResolveEpicModel,
1111
1147
  delegationReadinessCwd,
1112
1148
  telemetrySetConfig,
1113
1149
  },