claude-code-session-manager 0.141.0 → 0.142.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 (200) hide show
  1. package/README.md +80 -70
  2. package/bin/cli.cjs +11 -0
  3. package/dist/assets/AppSettings-BcZgIvvY.js +2 -0
  4. package/dist/assets/{History-DJMiuXyK.js → History-DpZuJXi1.js} +1 -1
  5. package/dist/assets/HomeClaudeConfig-D32ZJtU-.js +3 -0
  6. package/dist/assets/{Panel-Bf1Cf8UL.js → Panel-BjdJjhqt.js} +1 -1
  7. package/dist/assets/{ProjectClaudeConfig-BWPpypf9.js → ProjectClaudeConfig-BTClYV6i.js} +7 -7
  8. package/dist/assets/Scheduler-DPobKx1Z.js +16 -0
  9. package/dist/assets/{SkillReferenceGraph-Ba4TkX2C.js → SkillReferenceGraph-Cqyu4mef.js} +1 -1
  10. package/dist/assets/{Skills-C1v91GEO.js → Skills-vv0noNVI.js} +5 -5
  11. package/dist/assets/{TiptapBody-BrcWVpiW.js → TiptapBody-CXi8Pvut.js} +1 -1
  12. package/dist/assets/Toggle-CiYCWLjh.js +1 -0
  13. package/dist/assets/{VoiceButton-qivnDV6K.js → VoiceButton-4NKKd1sC.js} +1 -1
  14. package/dist/assets/{historyTotals-CMCPTKqC.js → historyTotals-DDunb8Ch.js} +1 -1
  15. package/dist/assets/index-Cn5E9958.js +3133 -0
  16. package/dist/assets/{index-DKXdXfka.css → index-DVHIHoJf.css} +1 -1
  17. package/dist/index.html +2 -2
  18. package/dist-web/app.css +1 -1
  19. package/dist-web/app.js +496 -484
  20. package/package.json +4 -2
  21. package/plugins/AGENTS.md +4 -3
  22. package/plugins/session-manager-dev/hooks/hooks.json +15 -0
  23. package/plugins/session-manager-dev/hooks/residue-check.cjs +241 -0
  24. package/plugins/session-manager-dev/skills/develop/SKILL.md +52 -18
  25. package/plugins/session-manager-dev/skills/develop/standards.md +3 -2
  26. package/scripts/README.md +1 -0
  27. package/scripts/hooks/guard-tool-risk.cjs +5 -1
  28. package/scripts/hooks/lib/guard-tool-risk-policy.cjs +158 -1
  29. package/scripts/scheduler-mcp-server.cjs +732 -110
  30. package/src/main/adminRouteRegistry.cjs +59 -0
  31. package/src/main/agentLibrary.cjs +72 -4
  32. package/src/main/agentsIpc.cjs +3 -2
  33. package/src/main/build-info.json +4 -4
  34. package/src/main/chatRunner.cjs +231 -16
  35. package/src/main/config.cjs +30 -0
  36. package/src/main/docEdit.cjs +4 -2
  37. package/src/main/health.cjs +91 -0
  38. package/src/main/index.cjs +98 -48
  39. package/src/main/ipcSchemas.cjs +161 -8
  40. package/src/main/lib/AGENTS.md +1 -1
  41. package/src/main/lib/chatBootRecovery.cjs +2 -0
  42. package/src/main/lib/claude/agentModelResolve.cjs +51 -25
  43. package/src/main/lib/claude/agentSnapshot.cjs +186 -0
  44. package/src/main/lib/claude/environmentProfiles.cjs +242 -0
  45. package/src/main/lib/claude/jobSandboxPolicy.cjs +241 -33
  46. package/src/main/lib/claude/personaToolScope.cjs +82 -31
  47. package/src/main/lib/claude/runClaudeP.cjs +4 -2
  48. package/src/main/lib/claude/toolRiskMarks.cjs +41 -1
  49. package/src/main/lib/claude/usageCircuit.cjs +49 -21
  50. package/src/main/lib/claude/vaultRefs.cjs +277 -0
  51. package/src/main/lib/demo-video-kit/capture.cjs +282 -12
  52. package/src/main/lib/demo-video-kit/cast.md +43 -0
  53. package/src/main/lib/demo-video-kit/character.cjs +722 -30
  54. package/src/main/lib/demo-video-kit/checks.cjs +120 -1
  55. package/src/main/lib/demo-video-kit/export.cjs +218 -0
  56. package/src/main/lib/demo-video-kit/frames.cjs +104 -9
  57. package/src/main/lib/demo-video-kit/kind-marketing.md +121 -0
  58. package/src/main/lib/demo-video-kit/kind-tiktok.md +99 -0
  59. package/src/main/lib/demo-video-kit/kokoroSay.cjs +205 -0
  60. package/src/main/lib/demo-video-kit/project-home-html.md +43 -0
  61. package/src/main/lib/demo-video-kit/resumableRun.cjs +298 -0
  62. package/src/main/lib/demo-video-kit/seedKit.cjs +3 -3
  63. package/src/main/lib/demo-video-kit/voiceLane.cjs +233 -0
  64. package/src/main/lib/demo-video-kit/voiceLibrary.cjs +312 -0
  65. package/src/main/lib/epic/artifactAdminRoutes.cjs +211 -0
  66. package/src/main/lib/epic/artifactIpc.cjs +153 -0
  67. package/src/main/lib/epic/artifactNotice.cjs +72 -0
  68. package/src/main/lib/epic/artifactRetention.cjs +310 -0
  69. package/src/main/lib/epic/artifactStore.cjs +392 -0
  70. package/src/main/lib/epic/delegationReadiness.cjs +76 -2
  71. package/src/main/lib/epic/epicAgentRefresh.cjs +97 -0
  72. package/src/main/lib/epic/epicEventLog.cjs +214 -0
  73. package/src/main/lib/epic/epicMint.cjs +43 -1
  74. package/src/main/lib/epic/epicOutsideRead.cjs +1 -0
  75. package/src/main/lib/epic/epicOutsideState.cjs +18 -4
  76. package/src/main/lib/epic/epicPurge.cjs +347 -0
  77. package/src/main/lib/epic/epicReopen.cjs +5 -2
  78. package/src/main/lib/epic/epicSettle.cjs +4 -13
  79. package/src/main/lib/epic/epicSpawnPlan.cjs +57 -4
  80. package/src/main/lib/epic/epicStatusMirror.cjs +34 -1
  81. package/src/main/lib/epic/epicTransitions.cjs +139 -0
  82. package/src/main/lib/epic/epicValidationHook.cjs +81 -2
  83. package/src/main/lib/epic/guardSpawnSettings.cjs +3 -2
  84. package/src/main/lib/externalContract.cjs +37 -4
  85. package/src/main/lib/feedback-remote/crossProjectReply.cjs +389 -126
  86. package/src/main/lib/feedback-remote/customerFeedbackAdminRoutes.cjs +16 -3
  87. package/src/main/lib/feedback-remote/customerFeedbackClient.cjs +11 -6
  88. package/src/main/lib/feedback-remote/customerFeedbackInbox.cjs +26 -1
  89. package/src/main/lib/feedback-remote/customerFeedbackIpc.cjs +5 -2
  90. package/src/main/lib/feedback-remote/feedbackBoxDrain.cjs +409 -0
  91. package/src/main/lib/feedback-remote/feedbackBoxKeys.cjs +218 -0
  92. package/src/main/lib/feedback-remote/feedbackEnvelope.cjs +163 -0
  93. package/src/main/lib/feedback-remote/feedbackRelayClient.cjs +164 -0
  94. package/src/main/lib/feedback-remote/feedbackReport.cjs +234 -0
  95. package/src/main/lib/feedback-remote/feedbackSeal.cjs +217 -0
  96. package/src/main/lib/feedback-remote/localAdminHttp.cjs +108 -2
  97. package/src/main/lib/feedback-remote/macroAdminRoutes.cjs +2 -1
  98. package/src/main/lib/feedback-remote/needsYouIpc.cjs +17 -0
  99. package/src/main/lib/feedback-remote/needsYouStore.cjs +177 -6
  100. package/src/main/lib/feedback-remote/pendingReplies.cjs +189 -0
  101. package/src/main/lib/feedback-remote/projectHomeAdminRoutes.cjs +188 -10
  102. package/src/main/lib/feedback-remote/serviceClient.cjs +429 -0
  103. package/src/main/lib/feedback-remote/serviceMcpSession.cjs +252 -0
  104. package/src/main/lib/feedback-remote/serviceMcpTools.cjs +284 -0
  105. package/src/main/lib/feedback-remote/servicePairings.cjs +313 -0
  106. package/src/main/lib/feedback-remote/serviceStdioBridge.cjs +290 -0
  107. package/src/main/lib/feedback-remote/siteFeedbackAdminRoutes.cjs +295 -0
  108. package/src/main/lib/feedback-remote/siteFeedbackInbox.cjs +598 -0
  109. package/src/main/lib/feedback-remote/siteFeedbackIpc.cjs +86 -0
  110. package/src/main/lib/feedback-remote/siteFeedbackService.cjs +477 -0
  111. package/src/main/lib/git/worktreeDeps.cjs +77 -2
  112. package/src/main/lib/mcpToolCatalog.cjs +304 -28
  113. package/src/main/lib/opsOwnership.cjs +29 -1
  114. package/src/main/lib/opsRetentionSettings.cjs +27 -5
  115. package/src/main/lib/persona-macro/builtinMacros.cjs +7 -2
  116. package/src/main/lib/persona-macro/macroJobDispatch.cjs +52 -8
  117. package/src/main/lib/persona-macro/macroJobIpc.cjs +16 -6
  118. package/src/main/lib/persona-macro/macroLibrary.cjs +49 -7
  119. package/src/main/lib/persona-macro/personaFrontmatterSchema.cjs +83 -0
  120. package/src/main/lib/persona-macro/projectVideoToolCheck.cjs +3 -0
  121. package/src/main/lib/persona-macro/shippedPersonaSeeds.cjs +263 -0
  122. package/src/main/lib/phaseProjection.cjs +103 -0
  123. package/src/main/lib/prd/depSlugResolve.cjs +4 -13
  124. package/src/main/lib/prd/prdBodyPatch.cjs +12 -17
  125. package/src/main/lib/prd/prdCreate.cjs +41 -5
  126. package/src/main/lib/prd/prdCriteria.cjs +225 -0
  127. package/src/main/lib/prd/prdFrontmatter.cjs +43 -3
  128. package/src/main/lib/prd/prdGateFiles.cjs +125 -49
  129. package/src/main/lib/prd/prdSizing.cjs +3 -1
  130. package/src/main/lib/process/cleanEnv.cjs +52 -1
  131. package/src/main/lib/process/leftoverRenice.cjs +178 -0
  132. package/src/main/lib/process/memoryScope.cjs +31 -3
  133. package/src/main/lib/project-pages/pagesLibrary.cjs +72 -6
  134. package/src/main/lib/project-pages/videoReviewIpc.cjs +3 -2
  135. package/src/main/lib/project-pages/voiceAdminRoutes.cjs +175 -0
  136. package/src/main/lib/project-pages/voicePreview.cjs +196 -0
  137. package/src/main/lib/project-pages/voicesIpc.cjs +186 -0
  138. package/src/main/lib/promptSessionSchema.cjs +6 -0
  139. package/src/main/lib/scheduler/cancelledRow.cjs +57 -0
  140. package/src/main/lib/scheduler/cpuSample.cjs +133 -42
  141. package/src/main/lib/scheduler/criteriaChecks.cjs +169 -0
  142. package/src/main/lib/scheduler/definitionOfDone.cjs +44 -5
  143. package/src/main/lib/scheduler/jobMemoryStats.cjs +313 -0
  144. package/src/main/lib/scheduler/loadGate.cjs +82 -4
  145. package/src/main/lib/scheduler/planRecordHarvest.cjs +32 -2
  146. package/src/main/lib/scheduler/prdOutcomeRecord.cjs +133 -0
  147. package/src/main/lib/scheduler/runLogRetention.cjs +42 -1
  148. package/src/main/lib/scheduler/scheduleJobSchema.cjs +5 -0
  149. package/src/main/lib/scheduler/scheduleJobTransitions.cjs +47 -0
  150. package/src/main/lib/scheduler/schedulerConfig.cjs +47 -0
  151. package/src/main/lib/scheduler/schedulerPaths.cjs +0 -3
  152. package/src/main/lib/scheduler/schedulerRuntimeState.cjs +50 -1
  153. package/src/main/lib/scheduler/sessionSlots.cjs +5 -1
  154. package/src/main/lib/scheduler/slotsRoute.cjs +237 -0
  155. package/src/main/lib/scheduler/toolClearance.cjs +258 -0
  156. package/src/main/lib/scheduler/validatorVerdictSchema.cjs +140 -10
  157. package/src/main/lib/tasks/memoryConsolidation.cjs +300 -0
  158. package/src/main/lib/tasks/mitigationReview.cjs +294 -0
  159. package/src/main/lib/tasks/taskAdminRoutes.cjs +312 -22
  160. package/src/main/lib/tasks/taskIpc.cjs +22 -18
  161. package/src/main/lib/tasks/taskLedger.cjs +147 -25
  162. package/src/main/lib/tasks/taskRun.cjs +186 -17
  163. package/src/main/lib/tasks/taskSwitch.cjs +85 -12
  164. package/src/main/lib/tasks/taskSwitchRoute.cjs +172 -0
  165. package/src/main/lib/telemetry/auditEvents.cjs +207 -6
  166. package/src/main/lib/telemetry/eventsAdminRoutes.cjs +198 -6
  167. package/src/main/lib/telemetry/webhookDelivery.cjs +205 -0
  168. package/src/main/lib/telemetry/webhookRegistry.cjs +281 -0
  169. package/src/main/lib/toolUseClassify.cjs +181 -0
  170. package/src/main/lib/util/smfileRange.cjs +77 -0
  171. package/src/main/projectPages.cjs +3 -1
  172. package/src/main/promptSessionEvents.cjs +5 -0
  173. package/src/main/pty.cjs +68 -0
  174. package/src/main/queueOps.cjs +32 -13
  175. package/src/main/runVerify.cjs +74 -9
  176. package/src/main/scheduler/AGENTS.md +1 -0
  177. package/src/main/scheduler/budget.cjs +6 -5
  178. package/src/main/scheduler/prdParser.cjs +46 -13
  179. package/src/main/scheduler/reviewLadder.cjs +9 -25
  180. package/src/main/scheduler/utilizationHold.cjs +101 -0
  181. package/src/main/scheduler.cjs +1414 -189
  182. package/src/main/templates/PRD_AUTHORING.md +5 -2
  183. package/src/main/webRemote.cjs +463 -6
  184. package/src/preload/api.d.ts +529 -38
  185. package/src/preload/apiSurface.json +209 -7
  186. package/src/preload/index.cjs +46 -1
  187. package/src/seed/agents/architect.md +6 -1
  188. package/src/seed/agents/blender-artist.md +2 -1
  189. package/src/seed/agents/competitive-analyst.md +3 -1
  190. package/src/seed/agents/competitive-researcher.md +2 -1
  191. package/src/seed/agents/demo-video-builder.md +87 -83
  192. package/src/seed/agents/dev-lead.md +3 -3
  193. package/src/seed/agents/project-home-builder.md +9 -31
  194. package/src/seed/agents/validator.md +9 -10
  195. package/dist/assets/AppSettings-DExeJhqQ.js +0 -2
  196. package/dist/assets/HomeClaudeConfig-CTp2tkZ4.js +0 -3
  197. package/dist/assets/Scheduler-cyr61UAC.js +0 -16
  198. package/dist/assets/ViewTabs-DXhOWFG0.js +0 -1
  199. package/dist/assets/index-B2TQz3nd.js +0 -3121
  200. package/src/main/lib/epic/epicStateWatcher.cjs +0 -157
@@ -87,6 +87,18 @@ const SHIPPED_PERSONA_SEEDS = deepFreeze({
87
87
  tools: "Read, Grep, Glob, Bash, Edit, Write",
88
88
  },
89
89
  },
90
+ {
91
+ commit: "3861-finish-whole-job",
92
+ bodySha256: "c769191b123d30ab967e89066171e3ff73bb90b3fc403c0939bb3a5c394304a1",
93
+ fm: {
94
+ description: "The primary Actor for an Epic's whole interactive conversation — owns overall plan and decomposition, clarifies scope, searches before building, decomposes work into scheduled PRDs via /develop, tracks them to completion, and verifies before calling anything done. Never implements a PRD itself — that's dev-lead's job, one PRD at a time, headless. Task-type framing is the Epic's Mission tag's job, not this persona's.",
95
+ model: "opus",
96
+ effort: "medium",
97
+ tags: "feature, bug, discussion, art",
98
+ title: "Engineering — Architect",
99
+ tools: "Read, Grep, Glob, Bash, Edit, Write",
100
+ },
101
+ },
90
102
  ],
91
103
  "dev-lead": [
92
104
  {
@@ -195,6 +207,30 @@ const SHIPPED_PERSONA_SEEDS = deepFreeze({
195
207
  tools: "Read, Grep, Glob, Bash, Edit, Write",
196
208
  },
197
209
  },
210
+ {
211
+ "commit": "mm-registry",
212
+ "bodySha256": "049f6a9a8578638dd426defd430ba481e1aea9073241ff0ee2b0e094924e3086",
213
+ "fm": {
214
+ "description": "Executes exactly one already-scoped PRD at a time, headless, start to finish — reads the PRD's Goal/Acceptance Criteria/Implementation notes and standards.md, implements it, verifies against its own AC, and reports. Has no visibility into the overall plan — that's architect's job. This is the default persona a scheduled PRD runs as: the scheduler resolves a PRD's `agentType` frontmatter field (default `dev-lead`) to this file and launches the headless executor AS this persona via `--append-system-prompt`.",
215
+ "effort": "medium",
216
+ "executorOnly": "true",
217
+ "model": "sonnet",
218
+ "title": "Engineering — Software Engineer",
219
+ "tools": "Read, Grep, Glob, Bash, Edit, Write"
220
+ }
221
+ },
222
+ {
223
+ commit: "followup-commit-trailers",
224
+ bodySha256: "ca65b05026e3d9f603c5a6efeb0d456686d4413089080ad7596cb9f051162646",
225
+ fm: {
226
+ description: "Executes exactly one already-scoped PRD at a time, headless, start to finish — reads the PRD's Goal/Acceptance Criteria/Implementation notes and standards.md, implements it, verifies against its own AC, and reports. Has no visibility into the overall plan — that's architect's job. This is the default persona a scheduled PRD runs as: the scheduler resolves a PRD's `agentType` frontmatter field (default `dev-lead`) to this file and launches the headless executor AS this persona via `--append-system-prompt`.",
227
+ effort: "medium",
228
+ executorOnly: "true",
229
+ model: "sonnet",
230
+ title: "Engineering — Software Engineer",
231
+ tools: "Read, Grep, Glob, Bash, Edit, Write",
232
+ },
233
+ },
198
234
  ],
199
235
  "project-home-builder": [
200
236
  // Not from src/seed git history: this body was written to ~/.claude/agents by this repo's own
@@ -282,6 +318,30 @@ const SHIPPED_PERSONA_SEEDS = deepFreeze({
282
318
  effort: "medium",
283
319
  },
284
320
  },
321
+ {
322
+ commit: "seed-v7",
323
+ bodySha256: "69890c9b83fb8f2f3a10ab2e0b6a932c3f86be9d7c1d40276113d08fc4d5ba28",
324
+ fm: {
325
+ description: "Reads a project and writes ONE Knowledge Page (Overview by default, or How it works, FAQ, or a custom topic) for its Project Home tab, then saves it with a single project_page_write call.",
326
+ tools: "Read, Grep, Glob, Bash, Write, Edit, mcp__session-manager-scheduler__project_home_write, mcp__session-manager-scheduler__project_page_write",
327
+ mcpServers: "session-manager-scheduler",
328
+ title: "Project Home — Builder",
329
+ model: "sonnet",
330
+ effort: "medium",
331
+ },
332
+ },
333
+ {
334
+ commit: "seed-v8",
335
+ bodySha256: "05dce94b324b8df98e74121fd1156d7b35dad78e92261275d81ba7bf5ee890c0",
336
+ fm: {
337
+ description: "Reads a project and writes ONE Knowledge Page (Overview by default, or How it works, FAQ, or a custom topic) for its Project Home tab, then saves it with a single project_page_write call.",
338
+ tools: "Read, Grep, Glob, Bash, Write, Edit, mcp__session-manager-scheduler__project_home_write, mcp__session-manager-scheduler__project_page_write",
339
+ mcpServers: "session-manager-scheduler",
340
+ title: "Project Home — Builder",
341
+ model: "sonnet",
342
+ effort: "medium",
343
+ },
344
+ },
285
345
  ],
286
346
  "validator": [
287
347
  {
@@ -388,6 +448,50 @@ const SHIPPED_PERSONA_SEEDS = deepFreeze({
388
448
  tools: "Read, Grep, Glob, Bash",
389
449
  },
390
450
  },
451
+ {
452
+ "commit": "mm-registry",
453
+ "bodySha256": "85760d6b48408f97271c21b7eb5bee51a866265a34a2f4ea8578fa99b2fcd533",
454
+ "fm": {
455
+ "description": "Validates a finished PLAN (the PRDs its validate PRD lists) once, after its last PRD lands — re-runs each PRD's gate, checks every acceptance criterion against the real tree, reviews the plan's combined diff, and reports one VERIFIED/REFUTED verdict per PRD as checked JSON (the CLI enforces the schema). Runs headless as a scheduled PRD (agentType: validator); never edits product code and never queues work.",
456
+ "executorOnly": "true",
457
+ "model": "sonnet",
458
+ "title": "Engineering — Plan Validator",
459
+ "tools": "Read, Grep, Glob, Bash"
460
+ }
461
+ },
462
+ {
463
+ commit: "validator-verdict-criteria",
464
+ bodySha256: "e61b8d66ca07b7edd96bb16b0721f2afa1b7626a432d2528dacc1bfd80ae3c71",
465
+ fm: {
466
+ description: "Validates a finished PLAN (the PRDs its validate PRD lists) once, after its last PRD lands — re-runs each PRD's gate, checks every acceptance criterion against the real tree, reviews the plan's combined diff, and reports one VERIFIED/REFUTED verdict per PRD as checked JSON (the CLI enforces the schema). Runs headless as a scheduled PRD (agentType: validator); never edits product code and never queues work.",
467
+ executorOnly: "true",
468
+ model: "sonnet",
469
+ title: "Engineering — Plan Validator",
470
+ tools: "Read, Grep, Glob, Bash",
471
+ },
472
+ },
473
+ {
474
+ commit: "validator-self-review-only",
475
+ bodySha256: "8177df9ecd027d28ad91f353fd1786076515fcc187d6ce98178af3b5047835c4",
476
+ fm: {
477
+ description: "Validates a finished PLAN (the PRDs its validate PRD lists) once, after its last PRD lands — re-runs each PRD's gate, checks every acceptance criterion against the real tree, reviews the plan's combined diff, and reports one VERIFIED/REFUTED verdict per PRD as checked JSON (the CLI enforces the schema). Runs headless as a scheduled PRD (agentType: validator); never edits product code and never queues work.",
478
+ executorOnly: "true",
479
+ model: "sonnet",
480
+ title: "Engineering — Plan Validator",
481
+ tools: "Read, Grep, Glob, Bash",
482
+ },
483
+ },
484
+ {
485
+ commit: "validator-reads-followup-trailers",
486
+ bodySha256: "55c48dee7ee34391b369abb2998c4be5008738f9df5e803623e38ade0de03977",
487
+ fm: {
488
+ description: "Validates a finished PLAN (the PRDs its validate PRD lists) once, after its last PRD lands — re-runs each PRD's gate, checks every acceptance criterion against the real tree, reviews the plan's combined diff, and reports one VERIFIED/REFUTED verdict per PRD as checked JSON (the CLI enforces the schema). Runs headless as a scheduled PRD (agentType: validator); never edits product code and never queues work.",
489
+ executorOnly: "true",
490
+ model: "sonnet",
491
+ title: "Engineering — Plan Validator",
492
+ tools: "Read, Grep, Glob, Bash",
493
+ },
494
+ },
391
495
  ],
392
496
  "demo-video-builder": [
393
497
  {
@@ -577,6 +681,112 @@ const SHIPPED_PERSONA_SEEDS = deepFreeze({
577
681
  effort: "max",
578
682
  },
579
683
  },
684
+ {
685
+ commit: "seed-v15",
686
+ bodySha256: "b75f3f3bb195fef2b6c451fd6e20c54132764bff4d11253371b948fab4396a5f",
687
+ fm: {
688
+ description: "30-second or 1-minute self-contained HTML/JS demo video for Project Home, saved via project_video_write.",
689
+ tools: "Read, Grep, Glob, Bash, Write, Edit, mcp__session-manager-scheduler__project_demo_video_write, mcp__session-manager-scheduler__project_video_write, mcp__session-manager-scheduler__project_character_write, mcp__session-manager-scheduler__project_video_review_write",
690
+ title: "Project Home — Demo Video",
691
+ model: "opus",
692
+ effort: "max",
693
+ },
694
+ },
695
+ {
696
+ "commit": "mm-registry",
697
+ "bodySha256": "a8e9aaeef7efa62c9efaa3b0338b593516bd75e139058db5dd5cf0082c9e4c12",
698
+ "fm": {
699
+ "description": "30-second or 1-minute self-contained HTML/JS demo video for Project Home, saved via project_video_write.",
700
+ "effort": "max",
701
+ "model": "opus",
702
+ "title": "Project Home — Demo Video",
703
+ "tools": "Read, Grep, Glob, Bash, Write, Edit, mcp__session-manager-scheduler__project_demo_video_write, mcp__session-manager-scheduler__project_video_write, mcp__session-manager-scheduler__project_character_write, mcp__session-manager-scheduler__project_video_review_write"
704
+ }
705
+ },
706
+ {
707
+ commit: "seed-v17",
708
+ bodySha256: "a8e9aaeef7efa62c9efaa3b0338b593516bd75e139058db5dd5cf0082c9e4c12",
709
+ fm: {
710
+ description: "30-second or 1-minute self-contained HTML/JS demo video for Project Home, saved via project_video_write.",
711
+ tools: "Read, Grep, Glob, Bash, Write, Edit, mcp__session-manager-scheduler__project_demo_video_write, mcp__session-manager-scheduler__project_video_write, mcp__session-manager-scheduler__project_character_write, mcp__session-manager-scheduler__project_video_review_write",
712
+ mcpServers: "session-manager-scheduler",
713
+ title: "Project Home — Demo Video",
714
+ model: "opus",
715
+ effort: "max",
716
+ },
717
+ },
718
+ {
719
+ commit: "seed-v18",
720
+ bodySha256: "282b99ac85c30ba6c6075597732cb212e9f1e70d8970643a2a270efe36d5a03d",
721
+ fm: {
722
+ description: "30-second or 1-minute self-contained HTML/JS demo video for Project Home, saved via project_video_write.",
723
+ tools: "Read, Grep, Glob, Bash, Write, Edit, mcp__session-manager-scheduler__project_demo_video_write, mcp__session-manager-scheduler__project_video_write, mcp__session-manager-scheduler__project_character_write, mcp__session-manager-scheduler__project_video_review_write, mcp__session-manager-scheduler__project_video_outcome_write",
724
+ mcpServers: "session-manager-scheduler",
725
+ title: "Project Home — Demo Video",
726
+ model: "opus",
727
+ effort: "max",
728
+ },
729
+ },
730
+ {
731
+ commit: "seed-v19",
732
+ bodySha256: "a6478eea07eaac1665847e08ae1f42bdb0d7b8bddfbcfc491d29ea842771602f",
733
+ fm: {
734
+ description: "30-second or 1-minute self-contained HTML/JS demo video for Project Home, saved via project_video_write.",
735
+ tools: "Read, Grep, Glob, Bash, Write, Edit, mcp__session-manager-scheduler__project_demo_video_write, mcp__session-manager-scheduler__project_video_write, mcp__session-manager-scheduler__project_character_write, mcp__session-manager-scheduler__project_video_review_write, mcp__session-manager-scheduler__project_video_outcome_write",
736
+ mcpServers: "session-manager-scheduler",
737
+ title: "Project Home — Demo Video",
738
+ model: "opus",
739
+ effort: "max",
740
+ },
741
+ },
742
+ {
743
+ commit: "seed-v20",
744
+ bodySha256: "1ec4facff8cf740f57313ffca32fc0abd1dce7438c2642097b530f5b2ed48d0b",
745
+ fm: {
746
+ description: "30-second or 1-minute self-contained HTML/JS demo video for Project Home, saved via project_video_write.",
747
+ tools: "Read, Grep, Glob, Bash, Write, Edit, mcp__session-manager-scheduler__project_demo_video_write, mcp__session-manager-scheduler__project_video_write, mcp__session-manager-scheduler__project_character_write, mcp__session-manager-scheduler__project_video_review_write, mcp__session-manager-scheduler__project_video_outcome_write",
748
+ mcpServers: "session-manager-scheduler",
749
+ title: "Project Home — Demo Video",
750
+ model: "opus",
751
+ effort: "max",
752
+ },
753
+ },
754
+ {
755
+ commit: "seed-v21",
756
+ bodySha256: "f8bd1686767fe0105211d59d48ce5676fa40d0948eb2a496080b57534965ed76",
757
+ fm: {
758
+ description: "30-second or 1-minute self-contained HTML/JS demo video for Project Home, saved via project_video_write.",
759
+ tools: "Read, Grep, Glob, Bash, Write, Edit, mcp__session-manager-scheduler__project_demo_video_write, mcp__session-manager-scheduler__project_video_write, mcp__session-manager-scheduler__project_character_write, mcp__session-manager-scheduler__project_video_review_write, mcp__session-manager-scheduler__project_video_outcome_write",
760
+ mcpServers: "session-manager-scheduler",
761
+ title: "Project Home — Demo Video",
762
+ model: "opus",
763
+ effort: "max",
764
+ },
765
+ },
766
+ {
767
+ commit: "seed-v22",
768
+ bodySha256: "5401a01bcc363cae894655faa613119193e432e28641f8bf4004be3b6b7a8c49",
769
+ fm: {
770
+ description: "30-second or 1-minute self-contained HTML/JS demo video for Project Home, saved via project_video_write.",
771
+ tools: "Read, Grep, Glob, Bash, Write, Edit, mcp__session-manager-scheduler__project_demo_video_write, mcp__session-manager-scheduler__project_video_write, mcp__session-manager-scheduler__project_character_write, mcp__session-manager-scheduler__project_video_review_write, mcp__session-manager-scheduler__project_video_outcome_write",
772
+ mcpServers: "session-manager-scheduler",
773
+ title: "Project Home — Demo Video",
774
+ model: "opus",
775
+ effort: "max",
776
+ },
777
+ },
778
+ {
779
+ commit: "seed-v23",
780
+ bodySha256: "a2a8606a00002f7836fcf680206d37153dd2c31dd7528389402485d0b4e02fb0",
781
+ fm: {
782
+ description: "30-second or 1-minute self-contained HTML/JS demo video for Project Home, saved via project_video_write.",
783
+ tools: "Read, Grep, Glob, Bash, Write, Edit, mcp__session-manager-scheduler__project_demo_video_write, mcp__session-manager-scheduler__project_video_write, mcp__session-manager-scheduler__project_character_write, mcp__session-manager-scheduler__project_video_review_write, mcp__session-manager-scheduler__project_video_outcome_write",
784
+ mcpServers: "session-manager-scheduler",
785
+ title: "Project Home — Demo Video",
786
+ model: "opus",
787
+ effort: "max",
788
+ },
789
+ },
580
790
  ],
581
791
  "blender-artist": [
582
792
  {
@@ -592,6 +802,20 @@ const SHIPPED_PERSONA_SEEDS = deepFreeze({
592
802
  executorOnly: "true",
593
803
  },
594
804
  },
805
+ {
806
+ commit: "seed-v2",
807
+ bodySha256: "9cc52c7a1e35f81a158cccfd6b05974ed7a95e23cb98666c8f68dab54c9a6b5a",
808
+ fm: {
809
+ description: "Expert 3D character artist for games — modeling, rigging, skinning, shape keys and keyframe animation in Blender, driven headlessly through Blender's Python API and the Blender MCP, verified in-engine with the Godot CLI. Executes exactly one already-scoped art PRD at a time (the dev-lead equivalent for 3D assets). Use for any change whose source of truth is a .blend file.",
810
+ tools: "Read, Grep, Glob, Bash, Edit, Write, mcp__blender__execute_blender_code_for_cli, mcp__blender__get_blendfile_summary_datablocks_for_cli, mcp__blender__get_blendfile_summary_usage_guess_for_cli, mcp__blender__get_blendfile_summary_missing_files_for_cli, mcp__blender__get_python_api_docs, mcp__blender__search_api_docs, mcp__blender__search_manual_docs, mcp__blender__render_thumbnail_to_path, mcp__blender__render_viewport_to_path, mcp__blender__execute_blender_code, mcp__blender__get_objects_summary, mcp__blender__get_object_detail_summary, mcp__blender__get_screenshot_of_area_as_image",
811
+ mcpServers: "blender",
812
+ model: "opus",
813
+ effort: "high",
814
+ tags: "art",
815
+ title: "Games — 3D Character Artist (Blender)",
816
+ executorOnly: "true",
817
+ },
818
+ },
595
819
  ],
596
820
  "competitive-researcher": [
597
821
  {
@@ -605,6 +829,18 @@ const SHIPPED_PERSONA_SEEDS = deepFreeze({
605
829
  effort: "low",
606
830
  },
607
831
  },
832
+ {
833
+ commit: "seed-v2",
834
+ bodySha256: "4c6df5cb5a6486ea507fd6f985f324c9bd2557f1aed50ebd30dd666662267fda",
835
+ fm: {
836
+ description: "The Haiku collector for the Competitor matrix — run as a subagent by competitive-analyst, it researches ONE product's official announcements, dev blogs, changelogs and docs plus what users rave about or ask for, and writes cited JSON findings to the path it is given.",
837
+ tools: "WebSearch, WebFetch, Read, Write",
838
+ title: "Research — Competitor collector",
839
+ model: "haiku",
840
+ effort: "low",
841
+ environment: "open-web",
842
+ },
843
+ },
608
844
  ],
609
845
  "competitive-analyst": [
610
846
  {
@@ -619,6 +855,33 @@ const SHIPPED_PERSONA_SEEDS = deepFreeze({
619
855
  tags: "project-home-builder",
620
856
  },
621
857
  },
858
+ {
859
+ commit: "seed-v2",
860
+ bodySha256: "8e72237e9b743bb8c26cc701d3ebd6c65212ebf777de37f9eb5f40aeaf224fae",
861
+ fm: {
862
+ description: "The Opus analyst and executor of the Competitor matrix macro — warm-starts from the saved matrix, settles 1..4 competitors, inventories this project's real features, fans out Haiku competitive-researcher subagents, then merges everything into a grouped feature matrix with sentiment and prioritized recommendations and saves it once with project_matrix_write.",
863
+ tools: "Read, Grep, Glob, Bash, Write, WebSearch, WebFetch, Agent, mcp__session-manager-scheduler__project_matrix_read, mcp__session-manager-scheduler__project_matrix_write",
864
+ mcpServers: "session-manager-scheduler",
865
+ title: "Research — Competitor analyst",
866
+ model: "opus",
867
+ effort: "high",
868
+ tags: "project-home-builder",
869
+ },
870
+ },
871
+ {
872
+ commit: "seed-v3",
873
+ bodySha256: "8e72237e9b743bb8c26cc701d3ebd6c65212ebf777de37f9eb5f40aeaf224fae",
874
+ fm: {
875
+ description: "The Opus analyst and executor of the Competitor matrix macro — warm-starts from the saved matrix, settles 1..4 competitors, inventories this project's real features, fans out Haiku competitive-researcher subagents, then merges everything into a grouped feature matrix with sentiment and prioritized recommendations and saves it once with project_matrix_write.",
876
+ tools: "Read, Grep, Glob, Bash, Write, WebSearch, WebFetch, Agent, mcp__session-manager-scheduler__project_matrix_read, mcp__session-manager-scheduler__project_matrix_write",
877
+ mcpServers: "session-manager-scheduler",
878
+ title: "Research — Competitor analyst",
879
+ model: "opus",
880
+ effort: "high",
881
+ tags: "project-home-builder",
882
+ environment: "open-web",
883
+ },
884
+ },
622
885
  ],
623
886
  });
624
887
 
@@ -0,0 +1,103 @@
1
+ 'use strict';
2
+
3
+ /**
4
+ * phaseProjection.cjs — one outside "phase" for every Epic, scheduler job and Task.
5
+ *
6
+ * Top-level in lib/ (not under epic/, scheduler/ or tasks/) because it spans
7
+ * all three domains: each has its own status vocabulary, and an outside
8
+ * reader needs ONE small answer to "is anything happening, and is it mine to
9
+ * act on?". Pure: no fs, no clock, no mutation.
10
+ *
11
+ * idle — nothing is running and nothing is asked of anyone
12
+ * running — work is in flight (or queued to run)
13
+ * rescheduling — something stopped and the scheduler's own recovery
14
+ * ladder is still working on it
15
+ * waiting_on_human — a real question is open, or the ladder gave up
16
+ * terminated — finished for good (done, skipped, cancelled, closed)
17
+ *
18
+ * Matches src/renderer/lib/needsHuman.ts: a needs_review park is the
19
+ * scheduler's job ("being fixed"), never the human's — UNTIL the ladder gives
20
+ * up. The ladder's give-up signal is the grouped review notice going out
21
+ * (reviewNotice.sentAt — sent only when the ladder fails or the hold window
22
+ * ends; lib/scheduler/reviewNotice.cjs), or a park the ladder never touches
23
+ * by design (verdict 'refire_capped', see scheduler/reviewLadder.cjs
24
+ * isRefireCapped). A run that asked a question (verdict 'needs_human') and an
25
+ * Epic chat with an open question (needs-input) are real questions.
26
+ */
27
+
28
+ const { isCancelledRow } = require('./scheduler/cancelledRow.cjs');
29
+
30
+ const PHASES = Object.freeze(['idle', 'running', 'rescheduling', 'waiting_on_human', 'terminated']);
31
+
32
+ /** Precedence when several jobs make up one Epic: the first match wins. */
33
+ const EPIC_PRECEDENCE = Object.freeze(['waiting_on_human', 'rescheduling', 'running']);
34
+
35
+ const isObj = (v) => v != null && typeof v === 'object';
36
+
37
+ /** True when a needs_review row is no longer the ladder's to fix. */
38
+ function ladderGaveUp(job) {
39
+ if (job.verifierVerdict === 'refire_capped') return true;
40
+ const n = isObj(job.reviewNotice) ? job.reviewNotice : null;
41
+ return !!(n && typeof n.sentAt === 'string' && n.sentAt);
42
+ }
43
+
44
+ /**
45
+ * @param {any} job a scheduler queue row (or any { status, ... } shape)
46
+ * @returns {'idle'|'running'|'rescheduling'|'waiting_on_human'|'terminated'}
47
+ */
48
+ function phaseOfJob(job) {
49
+ if (!isObj(job)) return 'idle';
50
+ const status = typeof job.status === 'string' ? job.status : '';
51
+ if (isCancelledRow(job)) return 'terminated';
52
+ switch (status) {
53
+ case 'pending': return 'idle';
54
+ case 'running': return 'running';
55
+ // An auto-fix investigation and a quarantine are both ladder rungs.
56
+ case 'investigating':
57
+ case 'quarantined': return 'rescheduling';
58
+ case 'failed': return ladderGaveUp(job) ? 'waiting_on_human' : 'rescheduling';
59
+ case 'needs_review':
60
+ if (job.verifierVerdict === 'needs_human') return 'waiting_on_human';
61
+ return ladderGaveUp(job) ? 'waiting_on_human' : 'rescheduling';
62
+ case 'completed':
63
+ case 'skipped': return 'terminated';
64
+ default: return 'idle';
65
+ }
66
+ }
67
+
68
+ /**
69
+ * @param {{ status?: string, needsInput?: boolean, chatBusy?: boolean, jobPhases?: string[], refuted?: number }} [args]
70
+ * status — the Epic's lifecycle status (proposed / active / completed)
71
+ * jobPhases — phaseOfJob of each of the Epic's known PRDs
72
+ * refuted — count of PRDs whose newest verdict is refuted (the Epic's
73
+ * automated turn queues their fix, so: rescheduling)
74
+ * @returns {'idle'|'running'|'rescheduling'|'waiting_on_human'|'terminated'}
75
+ */
76
+ function phaseOfEpic(args) {
77
+ const a = isObj(args) ? args : {};
78
+ if (a.status === 'completed') return 'terminated';
79
+ // A proposed Epic waits for a human to approve it.
80
+ if (a.status === 'proposed') return 'waiting_on_human';
81
+ if (a.needsInput === true && a.chatBusy !== true) return 'waiting_on_human';
82
+ const phases = Array.isArray(a.jobPhases) ? a.jobPhases : [];
83
+ if (phases.includes('waiting_on_human')) return 'waiting_on_human';
84
+ if (phases.includes('rescheduling') || (typeof a.refuted === 'number' && a.refuted > 0)) return 'rescheduling';
85
+ // A queued (idle) PRD inside an active Epic is work about to run.
86
+ if (a.chatBusy === true || phases.includes('running') || phases.includes('idle')) return 'running';
87
+ return 'idle';
88
+ }
89
+
90
+ /**
91
+ * @param {any} task a folded Task ledger row ({ status: 'running' | an end status })
92
+ * @returns {'idle'|'running'|'rescheduling'|'waiting_on_human'|'terminated'}
93
+ */
94
+ function phaseOfTask(task) {
95
+ const status = isObj(task) && typeof task.status === 'string' ? task.status : '';
96
+ if (!status) return 'idle';
97
+ if (status === 'running') return 'running';
98
+ // Every other Task status is a terminal end status (taskLedger.cjs
99
+ // TERMINAL_STATUSES); a Task is never retried by Session Manager.
100
+ return 'terminated';
101
+ }
102
+
103
+ module.exports = { PHASES, EPIC_PRECEDENCE, phaseOfJob, phaseOfEpic, phaseOfTask };
@@ -16,6 +16,8 @@
16
16
  * record and Epic ordering on top of the same bare-name rule.
17
17
  */
18
18
 
19
+ const { isCancelledRow } = require('../scheduler/cancelledRow.cjs');
20
+
19
21
  /** Strip one leading `NN-` prefix, if present. */
20
22
  function bareSlug(slug) {
21
23
  return String(slug ?? '').replace(/^\d+-/, '');
@@ -86,17 +88,6 @@ function findNearMatches(depSlug, candidateSlugs, limit = 3) {
86
88
  .map((entry) => entry.slug);
87
89
  }
88
90
 
89
- /**
90
- * Was this row cancelled by a human (admin API cancel), rather than failing on
91
- * its own? scheduler.cjs's cancel handler stamps `cancelledAt` and an error
92
- * starting 'cancelled via admin API'; either marker counts.
93
- */
94
- function isCancelledRow(row) {
95
- if (!row) return false;
96
- if (typeof row.cancelledAt === 'string' ? row.cancelledAt.length > 0 : row.cancelledAt != null) return true;
97
- return typeof row.error === 'string' && row.error.startsWith('cancelled via admin API');
98
- }
99
-
100
91
  /** The Epic a queue row belongs to: `epicId`, else its `sourcePromptId`. */
101
92
  function epicOf(job) {
102
93
  return job?.epicId ?? job?.sourcePromptId ?? null;
@@ -125,7 +116,7 @@ function isPrefixedSlug(slug) {
125
116
  * dependent's Epic → 'row'
126
117
  * 5. bare dep: a satisfied record with that bare name → 'satisfied'
127
118
  * 6. → 'unresolved'
128
- * In steps 3-4 a cancelled row (isCancelledRow) is dropped when a satisfied
119
+ * In steps 3-4 a cancelled row (isCancelledRow, lib/scheduler/cancelledRow.cjs) is dropped when a satisfied
129
120
  * record shares its bare name — a human-cancelled duplicate must never freeze
130
121
  * the dependents of the PRD that genuinely finished (Self, 2026-11-22: the
131
122
  * cancelled 1056-sm-contract-client froze 16 dependents of the completed
@@ -183,5 +174,5 @@ function makeDepResolver(projectJobs, satisfiedSlugs = new Set(), opts = {}) {
183
174
  }
184
175
 
185
176
  module.exports = {
186
- bareSlug, resolveDepSlug, findNearMatches, isSatisfiedDepRow, isCancelledRow, epicOf, makeDepResolver,
177
+ bareSlug, resolveDepSlug, findNearMatches, isSatisfiedDepRow, epicOf, makeDepResolver,
187
178
  };
@@ -8,6 +8,7 @@
8
8
 
9
9
  const { validateGate, validateFiles, renderFilesSection, renderGateSection } = require('./prdGateFiles.cjs');
10
10
  const { resolveGate, parseChain, isNoneGate } = require('../scheduler/definitionOfDone.cjs');
11
+ const { validateCriteria, renderCriteriaLines } = require('./prdCriteria.cjs');
11
12
 
12
13
  const H_AC = '# Acceptance criteria';
13
14
  const H_FILES = '# Files';
@@ -58,8 +59,11 @@ function gateSignature(body) {
58
59
 
59
60
  /**
60
61
  * @param {string} body
61
- * @param {{gate?: string[], files?: string[], acceptanceCriteria?: string[]}} patch
62
- * @returns {{ok:true, body:string, warnings:string[]}|{ok:false, error:string}}
62
+ * @param {{gate?: string[], files?: string[], acceptanceCriteria?: unknown[], previousCriteria?: unknown}} patch
63
+ * acceptanceCriteria entries are strings or structured criteria (prdCriteria.cjs);
64
+ * previousCriteria (the PRD's frontmatter `criteria`) keeps ids stable.
65
+ * @returns {{ok:true, body:string, warnings:string[], criteria?: object[]}|{ok:false, error:string}}
66
+ * `criteria` (when acceptanceCriteria was patched) is what the caller writes to frontmatter.
63
67
  */
64
68
  function applyStructuredPrdPatch(body, patch) {
65
69
  if (typeof body !== 'string') return { ok: false, error: 'body must be a string.' };
@@ -87,21 +91,12 @@ function applyStructuredPrdPatch(body, patch) {
87
91
  if (!f.ok) return { ok: false, error: f.error };
88
92
  filesList = f.files;
89
93
  }
94
+ let criteria = null;
90
95
  if (hasAc) {
91
- const ac = patch.acceptanceCriteria;
92
- if (!Array.isArray(ac) || ac.length === 0) {
93
- return { ok: false, error: 'acceptanceCriteria must be a non-empty array of strings.' };
94
- }
95
- acLines = [];
96
- for (let i = 0; i < ac.length; i++) {
97
- if (typeof ac[i] !== 'string' || ac[i].trim() === '') {
98
- return { ok: false, error: `acceptanceCriteria entry ${i + 1}: must be a non-empty string.` };
99
- }
100
- if (/[\r\n]/.test(ac[i])) {
101
- return { ok: false, error: `acceptanceCriteria entry ${i + 1}: must not contain a newline.` };
102
- }
103
- acLines.push(`- [ ] ${ac[i].trim()}`);
104
- }
96
+ const cv = validateCriteria(patch.acceptanceCriteria, { previous: patch.previousCriteria });
97
+ if (!cv.ok) return { ok: false, error: `acceptanceCriteria: ${cv.error}` };
98
+ criteria = cv.criteria;
99
+ acLines = renderCriteriaLines(criteria);
105
100
  }
106
101
 
107
102
  const lines = body.split('\n');
@@ -132,7 +127,7 @@ function applyStructuredPrdPatch(body, patch) {
132
127
  return { ok: false, error: 'The patch would change how the scheduler reads the PRD gate (stray gate fence in the new text).' };
133
128
  }
134
129
 
135
- return { ok: true, body: next, warnings };
130
+ return criteria ? { ok: true, body: next, warnings, criteria } : { ok: true, body: next, warnings };
136
131
  }
137
132
 
138
133
  module.exports = { applyStructuredPrdPatch };
@@ -81,7 +81,8 @@ const telemetryCounters = require('../telemetry/telemetryCounters.cjs');
81
81
  const { execGit } = require('../git/gitExec.cjs');
82
82
  const { extractRepoPathCandidates, worktreeReachWarnings } = require('./prdWorktreeReach.cjs');
83
83
  const { isSweepValidatorSlug } = require('../epic/epicSweepValidator.cjs');
84
- const { validateGate, validateFiles, renderFilesSection, renderGateSection, parseFilesSection } = require('./prdGateFiles.cjs');
84
+ const { NONE_GATE_WARNING, validateGate, validateFiles, renderFilesSection, renderGateSection, parseFilesSection } = require('./prdGateFiles.cjs');
85
+ const { normalizeCriteria, validateCriteria, serializeCriteria, renderCriteriaLines } = require('./prdCriteria.cjs');
85
86
  const { filesOverlap } = require('../scheduler/schedulerBatch.cjs');
86
87
  const { resolveGate, parseChain, isNoneGate } = require('../scheduler/definitionOfDone.cjs');
87
88
  const { MISS_KINDS } = require('../scheduler/validatorVerdictSchema.cjs');
@@ -127,6 +128,8 @@ function deriveSlugFromTitle(title) {
127
128
  * Engineering standards, in order.
128
129
  */
129
130
  const MACRO_ID_RE = /^[A-Za-z0-9][A-Za-z0-9._-]{0,127}$/;
131
+ // Voice-library id pattern: the one owner is voiceLibrary.cjs.
132
+ const { VOICE_ID_RE } = require('../demo-video-kit/voiceLibrary.cjs');
130
133
  function isValidMacroId(id) {
131
134
  return typeof id === 'string' && MACRO_ID_RE.test(id);
132
135
  }
@@ -134,9 +137,13 @@ function isValidMacroId(id) {
134
137
  function buildPrdBody(input) {
135
138
  const {
136
139
  title, cwd, estimateMinutes, goal, acceptanceCriteria,
137
- implementationNotes, outOfScope, sourcePromptId, sourceTabId, tag, agentType, dependsOn, quietMachine, disposition, deliverable, artifactPaths, planId, macroId, effort, riskTools, preflight,
140
+ implementationNotes, outOfScope, sourcePromptId, sourceTabId, tag, agentType, dependsOn, quietMachine, disposition, deliverable, artifactPaths, planId, macroId, effort, voiceId, riskTools, preflight,
138
141
  gate, files, budgetExempt, fixes,
139
142
  } = input;
143
+ // Structured criteria (prdCriteria.cjs): createPrd() normalizes once and
144
+ // passes `criteria`; a direct caller with only string criteria gets the
145
+ // same normalization here, so every PRD carries ids.
146
+ const criteria = Array.isArray(input.criteria) ? input.criteria : normalizeCriteria(acceptanceCriteria);
140
147
 
141
148
  // No `parallelGroup` frontmatter key (PRD_AUTHORING.md §5) — the NN-
142
149
  // filename prefix is the single source of truth for grouping; adding a
@@ -193,6 +200,7 @@ function buildPrdBody(input) {
193
200
  // prdFrontmatter.cjs's applyKey for the matching "only true opts in" parse.
194
201
  if (isValidMacroId(macroId)) fmLines.push(`macroId: ${macroId}`);
195
202
  if (PRD_EFFORT_LEVELS.includes(effort)) fmLines.push(`effort: ${effort}`);
203
+ if (typeof voiceId === 'string' && VOICE_ID_RE.test(voiceId)) fmLines.push(`voiceId: ${voiceId}`);
196
204
  // Risky tools this PRD is cleared to call — validated + de-duplicated by createPrd().
197
205
  if (Array.isArray(riskTools) && riskTools.length) fmLines.push(`riskTools: ${formatQuotedInlineList(riskTools)}`);
198
206
  // Precondition command — validated by createPrd() via normalizePreflightField.
@@ -202,9 +210,11 @@ function buildPrdBody(input) {
202
210
  // Budget exemption is for a sweep validator that cannot be split further;
203
211
  // every other caller's budgetExempt is ignored.
204
212
  if (budgetExempt === true && agentType === 'validator' && isSweepValidatorSlug(input.slug)) fmLines.push('budgetExempt: true');
213
+ // Normalized criteria as one-line JSON — [{ id, statement, check: { kind, spec? } }].
214
+ fmLines.push(`criteria: ${serializeCriteria(criteria)}`);
205
215
  fmLines.push('---', '');
206
216
 
207
- const acLines = acceptanceCriteria.map((line) => `- [ ] ${line}`).join('\n');
217
+ const acLines = renderCriteriaLines(criteria).join('\n');
208
218
  const oosSource = outOfScope && outOfScope.length ? outOfScope : ['(none)'];
209
219
  const oosLines = oosSource.map((line) => `- ${line}`).join('\n');
210
220
 
@@ -670,6 +680,11 @@ async function createPrdInner(input, remote, ctl, opts = {}) {
670
680
  if (input.effort != null && !PRD_EFFORT_LEVELS.includes(input.effort)) {
671
681
  return { ok: false, applied: false, status: 400, error: 'effort must be one of low, medium, high, xhigh, max when given' };
672
682
  }
683
+ // voiceId (in-process callers only, like effort — the schedulerCreatePrd
684
+ // schema has no voiceId, so the HTTP/MCP path strips a caller-supplied one).
685
+ if (input.voiceId != null && !(typeof input.voiceId === 'string' && VOICE_ID_RE.test(input.voiceId))) {
686
+ return { ok: false, applied: false, status: 400, error: `voiceId must match /${VOICE_ID_RE.source}/ when given` };
687
+ }
673
688
  // riskTools: tool-risk rule strings (toolRiskMarks.parseRule grammar) this PRD
674
689
  // is cleared to call. Refused before NN allocation; de-duplicated in order.
675
690
  if (input.riskTools != null) {
@@ -685,6 +700,16 @@ async function createPrdInner(input, remote, ctl, opts = {}) {
685
700
  input = { ...input, preflight: pf.value || undefined };
686
701
  }
687
702
 
703
+ // Structured criteria (prdCriteria.cjs): strings become manual ac-<n>
704
+ // criteria; objects are checked per kind. Refused before NN allocation.
705
+ // acceptanceCriteria is rewritten to the plain statements so every
706
+ // string-only consumer below (heading guard, sizing, worktree reach) works.
707
+ {
708
+ const cv = validateCriteria(input.acceptanceCriteria);
709
+ if (!cv.ok) return { ok: false, applied: false, status: 400, error: `acceptance ${cv.error}` };
710
+ input = { ...input, criteria: cv.criteria, acceptanceCriteria: cv.criteria.map((c) => c.statement) };
711
+ }
712
+
688
713
  // Fake-heading guard (gate-and-files-in-PRD-body unit): a caller-supplied
689
714
  // free-text field that itself contains a "# Gate" or "# Files" heading line
690
715
  // would, after buildPrdBody splices in the real section below, read as TWO
@@ -731,7 +756,11 @@ async function createPrdInner(input, remote, ctl, opts = {}) {
731
756
  return { ok: false, applied: false, status: 400, error: gateValidation.error };
732
757
  }
733
758
  gateCommands = gateValidation.commands;
734
- extraWarnings.push(...gateValidation.warnings);
759
+ // A validator PRD's gate is always none (it re-runs the plan's gates itself),
760
+ // so the none-gate warning is expected noise for it — drop only that one.
761
+ extraWarnings.push(...gateValidation.warnings.filter(
762
+ (w) => !(input.agentType === 'validator' && w === NONE_GATE_WARNING),
763
+ ));
735
764
  } else {
736
765
  extraWarnings.push('No gate: the scheduler cannot re-check this PRD.');
737
766
  }
@@ -1101,6 +1130,9 @@ async function createPrdInner(input, remote, ctl, opts = {}) {
1101
1130
  commands: gateCommands || [],
1102
1131
  },
1103
1132
  files: filesList || [],
1133
+ // The preflight actually written (null = no key) — the MCP server checks
1134
+ // it against what the caller sent, so a dropped key is never silent.
1135
+ preflight: input.preflight || null,
1104
1136
  // Advisory only (PRD 1403 sizing warnings + gate-and-files-in-PRD-body
1105
1137
  // absent/none-gate warnings) — never blocks the write. See prdSizing.cjs
1106
1138
  // and prdGateFiles.cjs.
@@ -1215,10 +1247,13 @@ async function createPrdBatch(inputs, remote, opts = {}) {
1215
1247
  nn = nns[i];
1216
1248
  filenameSlug = `${nn}-${p.slug}`;
1217
1249
  const body = buildPrdBody({ ...p.input, dependsOn: fullDeps(p.input.dependsOn), planId, gate: p.gateCommands, files: p.filesList });
1250
+ // A validated preflight must reach the file (PRD 3805 ran unheld when one
1251
+ // was lost); a body without the line rolls the whole batch back.
1252
+ if (p.input.preflight && !/^preflight: /m.test(body)) throw new Error('preflight was not written to the PRD frontmatter');
1218
1253
  const w = await remote.writePrd(filenameSlug, body, p.input.cwd);
1219
1254
  if (!w?.ok) throw new Error(w?.error ?? 'write failed');
1220
1255
  written.push({ filenameSlug, path: w.path ?? null, cwd: p.input.cwd });
1221
- results.push({ slug: p.slug, nn, filename: `${filenameSlug}.md`, warnings: p.warnings });
1256
+ results.push({ slug: p.slug, nn, filename: `${filenameSlug}.md`, preflight: p.input.preflight || null, warnings: p.warnings });
1222
1257
  } catch (e) {
1223
1258
  await rollback();
1224
1259
  return fail([{ index: i, slug: p.slug, error: `write failed (batch rolled back): ${e?.message ?? e}` }]);
@@ -1301,6 +1336,7 @@ function registerAdminRoute(adminHttp, remote) {
1301
1336
  note: result.note,
1302
1337
  gate: result.gate,
1303
1338
  files: result.files,
1339
+ preflight: result.preflight ?? null,
1304
1340
  warnings: result.warnings,
1305
1341
  });
1306
1342
  });