claude-code-session-manager 0.141.0 → 0.143.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 (223) hide show
  1. package/.claude-plugin/marketplace.json +1 -1
  2. package/README.md +76 -153
  3. package/bin/cli.cjs +11 -0
  4. package/dist/assets/AppSettings-BO4jDVGO.js +2 -0
  5. package/dist/assets/{History-DJMiuXyK.js → History-DTttbvPb.js} +1 -1
  6. package/dist/assets/HomeClaudeConfig-DADP5bfn.js +3 -0
  7. package/dist/assets/{Panel-Bf1Cf8UL.js → Panel-B_D4Bg7L.js} +1 -1
  8. package/dist/assets/{ProjectClaudeConfig-BWPpypf9.js → ProjectClaudeConfig-DPnDJKcr.js} +7 -7
  9. package/dist/assets/Scheduler-CNLjn90m.js +16 -0
  10. package/dist/assets/{SkillReferenceGraph-Ba4TkX2C.js → SkillReferenceGraph-D1b2aiol.js} +1 -1
  11. package/dist/assets/{Skills-C1v91GEO.js → Skills-cfV7sgk6.js} +5 -5
  12. package/dist/assets/{TiptapBody-BrcWVpiW.js → TiptapBody-DVXtEIVy.js} +1 -1
  13. package/dist/assets/Toggle-CYajnSdx.js +1 -0
  14. package/dist/assets/{VoiceButton-qivnDV6K.js → VoiceButton-DJ4gGRuE.js} +1 -1
  15. package/dist/assets/{historyTotals-CMCPTKqC.js → historyTotals-D3MoHY2U.js} +1 -1
  16. package/dist/assets/index-CdTppjKR.js +3133 -0
  17. package/dist/assets/{index-DKXdXfka.css → index-DVHIHoJf.css} +1 -1
  18. package/dist/index.html +2 -2
  19. package/dist-web/app.css +1 -1
  20. package/dist-web/app.js +496 -484
  21. package/package.json +6 -4
  22. package/plugins/AGENTS.md +4 -3
  23. package/plugins/session-manager-dev/.claude-plugin/plugin.json +1 -1
  24. package/plugins/session-manager-dev/hooks/hooks.json +15 -0
  25. package/plugins/session-manager-dev/hooks/residue-check.cjs +241 -0
  26. package/plugins/session-manager-dev/skills/builder/SKILL.md +5 -0
  27. package/plugins/session-manager-dev/skills/develop/SKILL.md +58 -18
  28. package/plugins/session-manager-dev/skills/develop/standards.md +3 -2
  29. package/scripts/README.md +2 -0
  30. package/scripts/hooks/guard-tool-risk.cjs +5 -1
  31. package/scripts/hooks/lib/guard-tool-risk-policy.cjs +158 -1
  32. package/scripts/scheduler-mcp-server.cjs +1032 -112
  33. package/src/main/adminRouteRegistry.cjs +69 -0
  34. package/src/main/agentLibrary.cjs +72 -4
  35. package/src/main/agentsIpc.cjs +3 -2
  36. package/src/main/build-info.json +4 -4
  37. package/src/main/chatRunner.cjs +336 -23
  38. package/src/main/config.cjs +35 -1
  39. package/src/main/docEdit.cjs +4 -2
  40. package/src/main/health.cjs +129 -2
  41. package/src/main/index.cjs +110 -52
  42. package/src/main/ipcSchemas.cjs +172 -8
  43. package/src/main/lib/AGENTS.md +1 -1
  44. package/src/main/lib/chatBootRecovery.cjs +2 -0
  45. package/src/main/lib/claude/agentModelResolve.cjs +51 -25
  46. package/src/main/lib/claude/agentSnapshot.cjs +186 -0
  47. package/src/main/lib/claude/environmentProfiles.cjs +242 -0
  48. package/src/main/lib/claude/jobSandboxPolicy.cjs +241 -33
  49. package/src/main/lib/claude/personaToolScope.cjs +82 -31
  50. package/src/main/lib/claude/runClaudeP.cjs +4 -2
  51. package/src/main/lib/claude/toolRiskMarks.cjs +41 -1
  52. package/src/main/lib/claude/usageCircuit.cjs +49 -21
  53. package/src/main/lib/claude/vaultRefs.cjs +277 -0
  54. package/src/main/lib/demo-video-kit/capture.cjs +282 -12
  55. package/src/main/lib/demo-video-kit/cast.md +52 -0
  56. package/src/main/lib/demo-video-kit/character.cjs +778 -30
  57. package/src/main/lib/demo-video-kit/checks.cjs +120 -1
  58. package/src/main/lib/demo-video-kit/export.cjs +218 -0
  59. package/src/main/lib/demo-video-kit/frames.cjs +104 -9
  60. package/src/main/lib/demo-video-kit/kind-marketing.md +121 -0
  61. package/src/main/lib/demo-video-kit/kind-tiktok.md +103 -0
  62. package/src/main/lib/demo-video-kit/kokoroSay.cjs +205 -0
  63. package/src/main/lib/demo-video-kit/project-home-html.md +43 -0
  64. package/src/main/lib/demo-video-kit/projectSounds.cjs +191 -0
  65. package/src/main/lib/demo-video-kit/resumableRun.cjs +298 -0
  66. package/src/main/lib/demo-video-kit/seedKit.cjs +3 -3
  67. package/src/main/lib/demo-video-kit/sound.cjs +166 -9
  68. package/src/main/lib/demo-video-kit/standalone.cjs +231 -0
  69. package/src/main/lib/demo-video-kit/voiceLane.cjs +233 -0
  70. package/src/main/lib/demo-video-kit/voiceLibrary.cjs +312 -0
  71. package/src/main/lib/epic/activeIndexMerge.cjs +5 -0
  72. package/src/main/lib/epic/artifactAdminRoutes.cjs +211 -0
  73. package/src/main/lib/epic/artifactIpc.cjs +153 -0
  74. package/src/main/lib/epic/artifactNotice.cjs +72 -0
  75. package/src/main/lib/epic/artifactRetention.cjs +356 -0
  76. package/src/main/lib/epic/artifactStore.cjs +435 -0
  77. package/src/main/lib/epic/delegationReadiness.cjs +83 -2
  78. package/src/main/lib/epic/epicAgentRefresh.cjs +97 -0
  79. package/src/main/lib/epic/epicEventLog.cjs +258 -0
  80. package/src/main/lib/epic/epicMint.cjs +43 -1
  81. package/src/main/lib/epic/epicOutsideRead.cjs +1 -0
  82. package/src/main/lib/epic/epicOutsideState.cjs +18 -4
  83. package/src/main/lib/epic/epicPurge.cjs +347 -0
  84. package/src/main/lib/epic/epicReopen.cjs +5 -2
  85. package/src/main/lib/epic/epicSettle.cjs +4 -13
  86. package/src/main/lib/epic/epicSpawnPlan.cjs +57 -4
  87. package/src/main/lib/epic/epicStateEmitter.cjs +248 -0
  88. package/src/main/lib/epic/epicStatusMirror.cjs +34 -1
  89. package/src/main/lib/epic/epicTransitions.cjs +139 -0
  90. package/src/main/lib/epic/epicValidationHook.cjs +94 -4
  91. package/src/main/lib/epic/guardSpawnSettings.cjs +3 -2
  92. package/src/main/lib/externalContract.cjs +48 -4
  93. package/src/main/lib/feedback-remote/autoStartedSession.cjs +1 -1
  94. package/src/main/lib/feedback-remote/crossProjectReply.cjs +478 -127
  95. package/src/main/lib/feedback-remote/customerFeedbackAdminRoutes.cjs +16 -3
  96. package/src/main/lib/feedback-remote/customerFeedbackClient.cjs +11 -6
  97. package/src/main/lib/feedback-remote/customerFeedbackInbox.cjs +26 -1
  98. package/src/main/lib/feedback-remote/customerFeedbackIpc.cjs +5 -2
  99. package/src/main/lib/feedback-remote/feedbackBoxDrain.cjs +409 -0
  100. package/src/main/lib/feedback-remote/feedbackBoxKeys.cjs +218 -0
  101. package/src/main/lib/feedback-remote/feedbackEnvelope.cjs +163 -0
  102. package/src/main/lib/feedback-remote/feedbackRelayClient.cjs +164 -0
  103. package/src/main/lib/feedback-remote/feedbackReport.cjs +234 -0
  104. package/src/main/lib/feedback-remote/feedbackSeal.cjs +217 -0
  105. package/src/main/lib/feedback-remote/localAdminHttp.cjs +108 -2
  106. package/src/main/lib/feedback-remote/macroAdminRoutes.cjs +32 -1
  107. package/src/main/lib/feedback-remote/needsYouIpc.cjs +17 -0
  108. package/src/main/lib/feedback-remote/needsYouStore.cjs +177 -6
  109. package/src/main/lib/feedback-remote/pendingReplies.cjs +207 -0
  110. package/src/main/lib/feedback-remote/projectHomeAdminRoutes.cjs +282 -14
  111. package/src/main/lib/feedback-remote/replyClaims.cjs +159 -0
  112. package/src/main/lib/feedback-remote/serviceClient.cjs +429 -0
  113. package/src/main/lib/feedback-remote/serviceMcpSession.cjs +252 -0
  114. package/src/main/lib/feedback-remote/serviceMcpTools.cjs +284 -0
  115. package/src/main/lib/feedback-remote/servicePairings.cjs +313 -0
  116. package/src/main/lib/feedback-remote/serviceStdioBridge.cjs +290 -0
  117. package/src/main/lib/feedback-remote/siteFeedbackAdminRoutes.cjs +295 -0
  118. package/src/main/lib/feedback-remote/siteFeedbackInbox.cjs +598 -0
  119. package/src/main/lib/feedback-remote/siteFeedbackIpc.cjs +86 -0
  120. package/src/main/lib/feedback-remote/siteFeedbackService.cjs +477 -0
  121. package/src/main/lib/git/gitWorktree.cjs +8 -0
  122. package/src/main/lib/git/runtimeStateUntrack.cjs +15 -1
  123. package/src/main/lib/git/worktreeDeps.cjs +182 -4
  124. package/src/main/lib/mcpToolCatalog.cjs +399 -29
  125. package/src/main/lib/opsOwnership.cjs +141 -28
  126. package/src/main/lib/opsRetentionSettings.cjs +27 -5
  127. package/src/main/lib/persona-macro/builtinMacros.cjs +7 -2
  128. package/src/main/lib/persona-macro/macroJobDispatch.cjs +52 -8
  129. package/src/main/lib/persona-macro/macroJobIpc.cjs +16 -6
  130. package/src/main/lib/persona-macro/macroLibrary.cjs +49 -7
  131. package/src/main/lib/persona-macro/personaFrontmatterSchema.cjs +83 -0
  132. package/src/main/lib/persona-macro/projectVideoToolCheck.cjs +3 -0
  133. package/src/main/lib/persona-macro/shippedPersonaSeeds.cjs +309 -0
  134. package/src/main/lib/phaseProjection.cjs +103 -0
  135. package/src/main/lib/prd/depSlugResolve.cjs +4 -13
  136. package/src/main/lib/prd/prdBodyPatch.cjs +12 -17
  137. package/src/main/lib/prd/prdCreate.cjs +387 -228
  138. package/src/main/lib/prd/prdCriteria.cjs +228 -0
  139. package/src/main/lib/prd/prdFrontmatter.cjs +43 -3
  140. package/src/main/lib/prd/prdGateFiles.cjs +125 -49
  141. package/src/main/lib/prd/prdSizing.cjs +3 -1
  142. package/src/main/lib/process/cleanEnv.cjs +52 -1
  143. package/src/main/lib/process/leftoverRenice.cjs +178 -0
  144. package/src/main/lib/process/memoryScope.cjs +31 -3
  145. package/src/main/lib/project-pages/pagesLibrary.cjs +72 -6
  146. package/src/main/lib/project-pages/videoPressLines.cjs +145 -0
  147. package/src/main/lib/project-pages/videoReviewIpc.cjs +3 -2
  148. package/src/main/lib/project-pages/videoScriptPress.cjs +260 -0
  149. package/src/main/lib/project-pages/videoScriptRunRoute.cjs +351 -0
  150. package/src/main/lib/project-pages/videoScriptSwitchIpc.cjs +49 -0
  151. package/src/main/lib/project-pages/videoScriptSwitchRoute.cjs +173 -0
  152. package/src/main/lib/project-pages/voiceAdminRoutes.cjs +175 -0
  153. package/src/main/lib/project-pages/voicePreview.cjs +196 -0
  154. package/src/main/lib/project-pages/voicesIpc.cjs +186 -0
  155. package/src/main/lib/promptSessionSchema.cjs +6 -0
  156. package/src/main/lib/scheduler/cancelledRow.cjs +57 -0
  157. package/src/main/lib/scheduler/cpuSample.cjs +133 -42
  158. package/src/main/lib/scheduler/criteriaChecks.cjs +313 -0
  159. package/src/main/lib/scheduler/definitionOfDone.cjs +44 -5
  160. package/src/main/lib/scheduler/heldSchedulerTurns.cjs +238 -0
  161. package/src/main/lib/scheduler/jobMemoryStats.cjs +324 -0
  162. package/src/main/lib/scheduler/loadGate.cjs +82 -4
  163. package/src/main/lib/scheduler/planRecordHarvest.cjs +152 -54
  164. package/src/main/lib/scheduler/prdOutcomeRecord.cjs +191 -0
  165. package/src/main/lib/scheduler/queueStore.cjs +16 -0
  166. package/src/main/lib/scheduler/rcaReport.cjs +79 -15
  167. package/src/main/lib/scheduler/runLogRetention.cjs +42 -1
  168. package/src/main/lib/scheduler/scheduleJobSchema.cjs +18 -0
  169. package/src/main/lib/scheduler/scheduleJobTransitions.cjs +47 -0
  170. package/src/main/lib/scheduler/schedulerConfig.cjs +47 -0
  171. package/src/main/lib/scheduler/schedulerPaths.cjs +9 -3
  172. package/src/main/lib/scheduler/schedulerRuntimeState.cjs +50 -1
  173. package/src/main/lib/scheduler/sessionSlots.cjs +5 -1
  174. package/src/main/lib/scheduler/slotsRoute.cjs +251 -0
  175. package/src/main/lib/scheduler/toolClearance.cjs +258 -0
  176. package/src/main/lib/scheduler/usageHoldRoute.cjs +97 -0
  177. package/src/main/lib/scheduler/validatorVerdictSchema.cjs +152 -11
  178. package/src/main/lib/tasks/memoryConsolidation.cjs +312 -0
  179. package/src/main/lib/tasks/mitigationReview.cjs +314 -0
  180. package/src/main/lib/tasks/taskAdminRoutes.cjs +390 -25
  181. package/src/main/lib/tasks/taskIpc.cjs +22 -18
  182. package/src/main/lib/tasks/taskLedger.cjs +147 -25
  183. package/src/main/lib/tasks/taskRun.cjs +186 -17
  184. package/src/main/lib/tasks/taskSwitch.cjs +85 -12
  185. package/src/main/lib/tasks/taskSwitchRoute.cjs +172 -0
  186. package/src/main/lib/telemetry/auditEvents.cjs +204 -6
  187. package/src/main/lib/telemetry/auditLog.cjs +6 -2
  188. package/src/main/lib/telemetry/eventsAdminRoutes.cjs +198 -6
  189. package/src/main/lib/telemetry/webhookDelivery.cjs +205 -0
  190. package/src/main/lib/telemetry/webhookRegistry.cjs +281 -0
  191. package/src/main/lib/toolUseClassify.cjs +181 -0
  192. package/src/main/lib/util/atomicFs.cjs +2 -2
  193. package/src/main/lib/util/smfileRange.cjs +77 -0
  194. package/src/main/projectPages.cjs +3 -1
  195. package/src/main/promptSessionEvents.cjs +21 -1
  196. package/src/main/pty.cjs +77 -0
  197. package/src/main/queueOps.cjs +33 -14
  198. package/src/main/runVerify.cjs +74 -9
  199. package/src/main/scheduler/AGENTS.md +1 -0
  200. package/src/main/scheduler/budget.cjs +6 -5
  201. package/src/main/scheduler/prdParser.cjs +46 -13
  202. package/src/main/scheduler/reviewLadder.cjs +9 -25
  203. package/src/main/scheduler/utilizationHold.cjs +191 -0
  204. package/src/main/scheduler.cjs +1932 -213
  205. package/src/main/templates/PRD_AUTHORING.md +11 -3
  206. package/src/main/webRemote.cjs +463 -6
  207. package/src/preload/api.d.ts +576 -39
  208. package/src/preload/apiSurface.json +223 -7
  209. package/src/preload/index.cjs +48 -1
  210. package/src/seed/agents/architect.md +6 -1
  211. package/src/seed/agents/blender-artist.md +2 -1
  212. package/src/seed/agents/competitive-analyst.md +3 -1
  213. package/src/seed/agents/competitive-researcher.md +2 -1
  214. package/src/seed/agents/demo-video-builder.md +98 -87
  215. package/src/seed/agents/dev-lead.md +3 -3
  216. package/src/seed/agents/project-home-builder.md +9 -31
  217. package/src/seed/agents/validator.md +23 -23
  218. package/dist/assets/AppSettings-DExeJhqQ.js +0 -2
  219. package/dist/assets/HomeClaudeConfig-CTp2tkZ4.js +0 -3
  220. package/dist/assets/Scheduler-cyr61UAC.js +0 -16
  221. package/dist/assets/ViewTabs-DXhOWFG0.js +0 -1
  222. package/dist/assets/index-B2TQz3nd.js +0 -3121
  223. package/src/main/lib/epic/epicStateWatcher.cjs +0 -157
@@ -0,0 +1,69 @@
1
+ 'use strict';
2
+ // The one list of loopback admin routes the app registers. index.cjs calls
3
+ // registerAppAdminRoutes once at boot; tests call it with a recording fake to see
4
+ // exactly what the running app serves. Every module is required INSIDE the
5
+ // function, so requiring this file has no side effect.
6
+
7
+ /**
8
+ * @param {{ registerRoute: Function }} adminHttp
9
+ * @param {{ onMacrosChanged?: Function, onNeedsYouChanged?: Function }} [deps]
10
+ */
11
+ function registerAppAdminRoutes(adminHttp, deps = {}) {
12
+ const scheduler = require('./scheduler.cjs');
13
+ const chatRunner = require('./chatRunner.cjs');
14
+ scheduler.registerAdminRoutes(adminHttp);
15
+ // GET/POST /admin/scheduler/slots — read the slot cap; change it only on the human's verified words.
16
+ require('./lib/scheduler/slotsRoute.cjs').registerSlotsRoute(adminHttp);
17
+ // GET /admin/usage-hold — the 'pause above' hold POST /admin/tasks refuses on, for runners that start claude -p directly (read-only).
18
+ require('./lib/scheduler/usageHoldRoute.cjs').registerUsageHoldRoute(adminHttp);
19
+ require('./lib/prd/prdCreate.cjs').registerAdminRoute(adminHttp, scheduler.remote);
20
+ require('./lib/prd/prdAdminRoutes.cjs').registerAdminRoute(adminHttp, scheduler.remote);
21
+ require('./lib/feedback-remote/projectHomeAdminRoutes.cjs').registerAdminRoute(adminHttp);
22
+ // GET /admin/voices + POST /admin/voices/preview — voice library reads for agents; no route changes a voice.
23
+ require('./lib/project-pages/voiceAdminRoutes.cjs').registerAdminRoute(adminHttp);
24
+ // POST /admin/project-home/videos/script-switch — 'Scripts may run Demo Video', only on the human's verified words.
25
+ require('./lib/project-pages/videoScriptSwitchRoute.cjs').registerVideoScriptSwitchRoute(adminHttp);
26
+ // POST /admin/project-home/videos/run — a project's own script presses Demo Video, only while that switch is on.
27
+ require('./lib/project-pages/videoScriptRunRoute.cjs').registerAdminRoute(adminHttp, {
28
+ startExternalNewSession: chatRunner.startExternalNewSession,
29
+ isTabBusy: chatRunner.isTabBusy,
30
+ listJobRows: () => scheduler.remote.listJobRows(),
31
+ });
32
+ require('./lib/feedback-remote/macroAdminRoutes.cjs').registerAdminRoute(adminHttp, {
33
+ onChanged: deps.onMacrosChanged,
34
+ startExternalNewSession: chatRunner.startExternalNewSession,
35
+ isTabBusy: chatRunner.isTabBusy,
36
+ });
37
+ chatRunner.registerAdminRoute(adminHttp);
38
+ // Outside apps' "Needs you" items (lib/feedback-remote/needsYouStore.cjs); changes broadcast `needsYou:changed`.
39
+ require('./lib/feedback-remote/needsYouAdminRoutes.cjs').registerAdminRoute(adminHttp, {
40
+ onChanged: deps.onNeedsYouChanged,
41
+ });
42
+ // Project-to-project feedback conduit — the app is the only process holding
43
+ // several projects' operations roots open, so it performs the cross-folder
44
+ // write (lib/feedback-remote/crossProjectFeedback.cjs).
45
+ require('./lib/feedback-remote/crossProjectFeedback.cjs').registerAdminRoute(adminHttp);
46
+ // Its return leg: the receiving session answers INTO the Epic that asked
47
+ // (lib/feedback-remote/crossProjectReply.cjs).
48
+ require('./lib/feedback-remote/crossProjectReply.cjs').registerAdminRoute(adminHttp);
49
+ require('./lib/feedback-remote/customerFeedbackAdminRoutes.cjs').registerAdminRoute(adminHttp);
50
+ // Website-feedback widgets + their decrypted inbox, behind the Feedback MCP tools.
51
+ require('./lib/feedback-remote/siteFeedbackAdminRoutes.cjs').registerAdminRoute(adminHttp);
52
+ // Per-project Artifacts store (publish + list), behind the artifact MCP tool.
53
+ require('./lib/epic/artifactAdminRoutes.cjs').registerAdminRoute(adminHttp);
54
+ // Cursor read over the audit log for outside scripts (read-only).
55
+ require('./lib/telemetry/eventsAdminRoutes.cjs').registerAdminRoute(adminHttp);
56
+ // Outside-facing Epic records for scripts/other projects (read-only).
57
+ require('./lib/epic/epicAdminRoutes.cjs').registerAdminRoute(adminHttp, {
58
+ isTabBusy: chatRunner.isTabBusy,
59
+ listJobs: () => scheduler.remote.listJobRows(),
60
+ });
61
+ // Validator quality numbers per project for outside callers (read-only).
62
+ require('./validationQualityHandlers.cjs').registerAdminRoute(adminHttp);
63
+ // Persona roster + per-project effective model/effort for outside apps (read-only).
64
+ require('./lib/persona-macro/agentAdminRoutes.cjs').registerAdminRoute(adminHttp);
65
+ // Task primitive: one headless claude -p run for a project, under the slot cap (POST /admin/tasks).
66
+ require('./lib/tasks/taskAdminRoutes.cjs').registerAdminRoute(adminHttp);
67
+ }
68
+
69
+ module.exports = { registerAppAdminRoutes };
@@ -33,6 +33,24 @@ function parseTools(raw) {
33
33
  return raw.split(',').map((t) => t.trim()).filter(Boolean);
34
34
  }
35
35
 
36
+ /**
37
+ * A declared-capability frontmatter value (`mcpServers:` / `packs:`) as a
38
+ * list: a comma string ("a, b") or a string list (structured callers).
39
+ * Trimmed, deduped, order-preserving; anything else → [].
40
+ * @param {unknown} raw
41
+ * @returns {string[]}
42
+ */
43
+ function parseCapabilityList(raw) {
44
+ const items = Array.isArray(raw) ? raw : typeof raw === 'string' ? raw.split(',') : [];
45
+ const out = [];
46
+ for (const it of items) {
47
+ if (typeof it !== 'string') continue;
48
+ const v = it.trim();
49
+ if (v && !out.includes(v)) out.push(v);
50
+ }
51
+ return out;
52
+ }
53
+
36
54
  /** Sentinel `projects:` entry meaning "this agent's Action button shows in every project". */
37
55
  const ALL_PROJECTS = '*';
38
56
 
@@ -75,8 +93,18 @@ function decodeLine(s) {
75
93
  *
76
94
  * `agentCli` / `agentCliModel` are this app's extension too: the persona's
77
95
  * default agent CLI (and its model) for New Session — Claude Code ignores them.
96
+ *
97
+ * `mcpServers` / `packs` are the persona's declared capabilities (comma
98
+ * lists): the exact MCP servers and context packs a scheduler job running as
99
+ * this persona loads (personaToolScope.cjs passes them under
100
+ * --strict-mcp-config; an unknown name parks the job). The Agent Library form
101
+ * has no field for them, so savePersona carries the file's values over.
102
+ *
103
+ * `environment` names the persona's declared environment profile
104
+ * (lib/claude/environmentProfiles.cjs; absent = headless-default). Same
105
+ * carry-over rule as mcpServers/packs.
78
106
  */
79
- const MANAGED_PERSONA_KEYS = new Set(['name', 'description', 'tools', 'model', 'effort', 'color', 'tags', 'projects', 'action', 'actionLabel', 'title', 'seedVersion', 'executorOnly', 'agentCli', 'agentCliModel']);
107
+ const MANAGED_PERSONA_KEYS = new Set(['name', 'description', 'tools', 'model', 'effort', 'color', 'tags', 'projects', 'action', 'actionLabel', 'title', 'seedVersion', 'executorOnly', 'agentCli', 'agentCliModel', 'mcpServers', 'packs', 'environment']);
80
108
 
81
109
  /**
82
110
  * Raw text lines of every top-level frontmatter key block in `raw` whose key
@@ -97,7 +125,7 @@ function extractUnmanagedLines(raw, managed) {
97
125
  return out;
98
126
  }
99
127
 
100
- function serializePersona({ name, description, tools, model, effort, color, tags, projects, action, actionLabel, title, seedVersion, executorOnly, agentCli, agentCliModel, body, preservedLines }) {
128
+ function serializePersona({ name, description, tools, model, effort, color, tags, projects, action, actionLabel, title, seedVersion, executorOnly, agentCli, agentCliModel, mcpServers, packs, environment, body, preservedLines }) {
101
129
  const lines = ['---', `name: ${name}`];
102
130
  if (description) lines.push(`description: ${description}`);
103
131
  if (tools && tools.length) lines.push(`tools: ${tools.join(', ')}`);
@@ -116,6 +144,9 @@ function serializePersona({ name, description, tools, model, effort, color, tags
116
144
  if (title) lines.push(`title: ${title}`);
117
145
  if (typeof seedVersion === 'number' && Number.isFinite(seedVersion)) lines.push(`seedVersion: ${seedVersion}`);
118
146
  if (executorOnly === true) lines.push('executorOnly: true');
147
+ if (Array.isArray(mcpServers) && mcpServers.length) lines.push(`mcpServers: ${mcpServers.join(', ')}`);
148
+ if (Array.isArray(packs) && packs.length) lines.push(`packs: ${packs.join(', ')}`);
149
+ if (typeof environment === 'string' && environment.trim()) lines.push(`environment: ${environment.trim()}`);
119
150
  if (Array.isArray(preservedLines) && preservedLines.length) lines.push(...preservedLines);
120
151
  lines.push('---', '');
121
152
  return lines.join('\n') + (body || '').trim() + '\n';
@@ -196,6 +227,31 @@ async function saveOverlay({ name, projectCwd, model, effort, loadSessions, vali
196
227
  return { ok: true, path: target };
197
228
  }
198
229
 
230
+ /**
231
+ * Throws (before anything is written) when the persona text about to be
232
+ * written fails validatePersonaFrontmatter, naming every failing key. The
233
+ * checked object is the frontmatter as it will land on disk — managed keys
234
+ * re-parsed from the serialized text, plus every preserved unmanaged key
235
+ * (an unmanaged key is by definition unknown to the schema, so it fails).
236
+ * Required lazily: personaFrontmatterSchema.cjs imports MANAGED_PERSONA_KEYS
237
+ * from this module.
238
+ * @param {string} name
239
+ * @param {string} text
240
+ * @param {string[]} preservedLines
241
+ */
242
+ function assertValidPersonaText(name, text, preservedLines) {
243
+ const { validatePersonaFrontmatter } = require('./lib/persona-macro/personaFrontmatterSchema.cjs');
244
+ const fm = { ...splitFrontmatter(text).fm };
245
+ for (const line of preservedLines) {
246
+ const m = line.match(/^([A-Za-z][A-Za-z0-9_-]*)\s*:/);
247
+ if (m && !(m[1] in fm)) fm[m[1]] = '';
248
+ }
249
+ const result = validatePersonaFrontmatter(fm);
250
+ if (!result.ok) {
251
+ throw new Error(`invalid persona frontmatter for ${name}: ${result.errors.join('; ')}`);
252
+ }
253
+ }
254
+
199
255
  /**
200
256
  * Writes a global persona `.md` file — `~/.claude/agents/<name>.md`. Pass
201
257
  * `originalName` when renaming an existing persona so the old file is
@@ -224,6 +280,9 @@ async function savePersona({
224
280
  executorOnly,
225
281
  agentCli,
226
282
  agentCliModel,
283
+ mcpServers,
284
+ packs,
285
+ environment,
227
286
  body,
228
287
  projectCwd,
229
288
  globalDir = path.join(os.homedir(), '.claude', 'agents'),
@@ -253,11 +312,14 @@ async function savePersona({
253
312
  // agentCli undefined = carry the file's pair over; 'claude' (or any non-CLI value) = write neither line.
254
313
  let resolvedAgentCli = agentCli;
255
314
  let resolvedAgentCliModel = agentCliModel;
315
+ let resolvedMcpServers = mcpServers;
316
+ let resolvedPacks = packs;
317
+ let resolvedEnvironment = environment;
256
318
  let preservedLines = [];
257
319
  try {
258
320
  preservedLines = extractUnmanagedLines(fsSync.readFileSync(target, 'utf8'), MANAGED_PERSONA_KEYS);
259
321
  } catch { /* no existing file — nothing to preserve */ }
260
- if ([seedVersion, title, projects, action, actionLabel, executorOnly, agentCli].some((v) => v === undefined)) {
322
+ if ([seedVersion, title, projects, action, actionLabel, executorOnly, agentCli, mcpServers, packs, environment].some((v) => v === undefined)) {
261
323
  try {
262
324
  const { fm } = splitFrontmatter(fsSync.readFileSync(target, 'utf8'));
263
325
  if (resolvedSeedVersion === undefined) {
@@ -274,9 +336,13 @@ async function savePersona({
274
336
  if (resolvedProjects === undefined && fm.projects) resolvedProjects = parseTools(fm.projects);
275
337
  if (resolvedAction === undefined && fm.action) resolvedAction = decodeLine(fm.action);
276
338
  if (resolvedActionLabel === undefined && fm.actionLabel) resolvedActionLabel = decodeLine(fm.actionLabel);
339
+ if (resolvedMcpServers === undefined && fm.mcpServers) resolvedMcpServers = parseCapabilityList(fm.mcpServers);
340
+ if (resolvedPacks === undefined && fm.packs) resolvedPacks = parseCapabilityList(fm.packs);
341
+ if (resolvedEnvironment === undefined && typeof fm.environment === 'string' && fm.environment.trim()) resolvedEnvironment = fm.environment.trim();
277
342
  } catch { /* no existing file (or unreadable) — nothing to carry over */ }
278
343
  }
279
- const text = serializePersona({ name, description, tools, model, effort, color, tags, projects: resolvedProjects, action: resolvedAction, actionLabel: resolvedActionLabel, title: resolvedTitle, seedVersion: resolvedSeedVersion, executorOnly: resolvedExecutorOnly, agentCli: resolvedAgentCli, agentCliModel: resolvedAgentCliModel, body, preservedLines });
344
+ const text = serializePersona({ name, description, tools, model, effort, color, tags, projects: resolvedProjects, action: resolvedAction, actionLabel: resolvedActionLabel, title: resolvedTitle, seedVersion: resolvedSeedVersion, executorOnly: resolvedExecutorOnly, agentCli: resolvedAgentCli, agentCliModel: resolvedAgentCliModel, mcpServers: resolvedMcpServers, packs: resolvedPacks, environment: resolvedEnvironment, body, preservedLines });
345
+ assertValidPersonaText(name, text, preservedLines);
280
346
  await writeTextAtomic(target, text);
281
347
  if (originalName && originalName !== name) {
282
348
  const oldReal = validatePath(path.join(globalDir, `${originalName}.md`));
@@ -485,4 +551,6 @@ module.exports = {
485
551
  getPersonaBody,
486
552
  PERSONA_NAME_RE,
487
553
  ALL_PROJECTS,
554
+ MANAGED_PERSONA_KEYS,
555
+ parseCapabilityList,
488
556
  };
@@ -63,9 +63,10 @@ function registerAgentsHandlers({ ipcMain, getWindow }) {
63
63
  // (agentModelResolve.cjs's resolveEpicModel), reached here so Terminal's
64
64
  // launch (EpicTerminalPane.tsx, a renderer module with no fs access) agrees
65
65
  // with Chat by calling the identical function rather than a second one that
66
- // is merely supposed to. Never throws (resolveEpicModel's own contract).
66
+ // is merely supposed to. Pinned Epics (agentSnapshotId) read the model from
67
+ // their AgentSnapshot (epicSpawnPlan.cjs's resolveEpicTurnModel). Never throws.
67
68
  ipcMain.handle('agents:resolve-epic-model', validated(schemas.agentsResolveEpicModel, (payload) =>
68
- agentModelResolve.resolveEpicModel(payload)));
69
+ require('./lib/epic/epicSpawnPlan.cjs').resolveEpicTurnModel(payload)));
69
70
  // Effort twin of the above (agentEffortResolve.cjs): Terminal appends
70
71
  // `--effort <level>` only when `effort` is non-null. Never throws.
71
72
  ipcMain.handle('agents:resolve-epic-effort', validated(schemas.agentsResolveEpicEffort, (payload) =>
@@ -1,8 +1,8 @@
1
1
  {
2
- "version": "0.141.0",
3
- "gitSha": "0db73892da43176f003e4495092dfb8283045331",
4
- "gitShortSha": "0db73892",
2
+ "version": "0.143.0",
3
+ "gitSha": "9e3a35ddcda5eb03942c74a5c9f9777e31fd81ab",
4
+ "gitShortSha": "9e3a35dd",
5
5
  "gitBranch": "HEAD",
6
- "builtAt": "2026-11-23T02:26:13.633Z",
6
+ "builtAt": "2026-11-25T04:24:39.027Z",
7
7
  "dirty": false
8
8
  }