claude-code-session-manager 0.143.0 → 0.145.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 (128) hide show
  1. package/README.md +3 -1
  2. package/dist/assets/AppSettings-BR5b6oof.js +2 -0
  3. package/dist/assets/{History-DTttbvPb.js → History-B4U0mCdK.js} +2 -2
  4. package/dist/assets/HomeClaudeConfig-DQqG7lFE.js +5 -0
  5. package/dist/assets/{Panel-B_D4Bg7L.js → Panel-CwsOJ0nI.js} +1 -1
  6. package/dist/assets/ProjectClaudeConfig-BzRowu8x.js +26 -0
  7. package/dist/assets/Scheduler-dr7CNOcL.js +16 -0
  8. package/dist/assets/{SkillReferenceGraph-D1b2aiol.js → SkillReferenceGraph-CroBPY4C.js} +1 -1
  9. package/dist/assets/{Skills-cfV7sgk6.js → Skills-BiW2lCnD.js} +23 -23
  10. package/dist/assets/{TiptapBody-DVXtEIVy.js → TiptapBody-CYTkQiva.js} +27 -27
  11. package/dist/assets/{Toggle-CYajnSdx.js → Toggle-WFBYo8JI.js} +1 -1
  12. package/dist/assets/{VoiceButton-DJ4gGRuE.js → VoiceButton-DZu8dTpO.js} +1 -1
  13. package/dist/assets/{historyTotals-D3MoHY2U.js → historyTotals-B7KeXLSE.js} +1 -1
  14. package/dist/assets/{index-DVHIHoJf.css → index-BJ5TJvmz.css} +1 -1
  15. package/dist/assets/{index-CdTppjKR.js → index-hXRNm0UJ.js} +698 -697
  16. package/dist/index.html +2 -2
  17. package/dist-web/app.css +1 -1
  18. package/dist-web/app.js +442 -439
  19. package/package.json +4 -2
  20. package/plugins/session-manager-dev/skills/develop/SKILL.md +25 -19
  21. package/plugins/session-manager-dev/skills/maintaining-md-network/SKILL.md +16 -2
  22. package/plugins/session-manager-dev/skills/maintaining-md-network/weekly-consolidation.md +91 -0
  23. package/plugins/session-manager-dev/skills/send-feedback/SKILL.md +9 -6
  24. package/scripts/README.md +1 -1
  25. package/scripts/scheduler-mcp-server.cjs +77 -0
  26. package/src/main/adminRouteRegistry.cjs +6 -0
  27. package/src/main/agentLibrary.cjs +60 -11
  28. package/src/main/agentsIpc.cjs +19 -0
  29. package/src/main/build-info.json +4 -4
  30. package/src/main/chatRunner.cjs +139 -0
  31. package/src/main/config.cjs +12 -0
  32. package/src/main/health.cjs +59 -17
  33. package/src/main/index.cjs +6 -2
  34. package/src/main/ipcSchemas.cjs +55 -1
  35. package/src/main/lib/claude/agentArmory.cjs +128 -0
  36. package/src/main/lib/claude/agentModelResolve.cjs +3 -2
  37. package/src/main/lib/claude/agentSnapshot.cjs +24 -3
  38. package/src/main/lib/claude/builtinTools.cjs +110 -0
  39. package/src/main/lib/claude/environmentProfiles.cjs +1 -1
  40. package/src/main/lib/claude/headlessMcpServers.cjs +138 -0
  41. package/src/main/lib/claude/jobSandboxPolicy.cjs +8 -2
  42. package/src/main/lib/claude/personaToolScope.cjs +100 -14
  43. package/src/main/lib/demo-video-kit/resumableRun.cjs +21 -14
  44. package/src/main/lib/demo-video-kit/seedKit.cjs +2 -2
  45. package/src/main/lib/epic/epicDepsSync.cjs +66 -0
  46. package/src/main/lib/epic/epicOutsideRead.cjs +74 -2
  47. package/src/main/lib/epic/epicSettle.cjs +48 -4
  48. package/src/main/lib/epic/epicSpawnPlan.cjs +3 -1
  49. package/src/main/lib/epic/epicValidationHook.cjs +9 -1
  50. package/src/main/lib/epic/planReviewInput.cjs +125 -0
  51. package/src/main/lib/epic/restorableSessions.cjs +1 -0
  52. package/src/main/lib/epic/scriptStartedBy.cjs +86 -0
  53. package/src/main/lib/externalContract.cjs +12 -0
  54. package/src/main/lib/feedback-remote/createdProjects.cjs +291 -0
  55. package/src/main/lib/feedback-remote/crossProjectFeedback.cjs +108 -14
  56. package/src/main/lib/feedback-remote/localAdminHttp.cjs +5 -1
  57. package/src/main/lib/feedback-remote/macroAdminRoutes.cjs +24 -3
  58. package/src/main/lib/feedback-remote/pendingReplies.cjs +8 -4
  59. package/src/main/lib/feedback-remote/projectCreate.cjs +415 -0
  60. package/src/main/lib/feedback-remote/replyClaims.cjs +15 -6
  61. package/src/main/lib/feedback-remote/serviceMcpSession.cjs +35 -4
  62. package/src/main/lib/feedback-remote/serviceMcpTools.cjs +43 -2
  63. package/src/main/lib/feedback-remote/servicePairLocalRoutes.cjs +91 -0
  64. package/src/main/lib/feedback-remote/servicePairings.cjs +95 -7
  65. package/src/main/lib/feedback-remote/serviceStdioBridge.cjs +104 -1
  66. package/src/main/lib/git/gitWorktree.cjs +1 -1
  67. package/src/main/lib/git/worktreeDeps.cjs +9 -3
  68. package/src/main/lib/mcpToolCatalog.cjs +47 -7
  69. package/src/main/lib/mcpToolsProbe.cjs +19 -2
  70. package/src/main/lib/opsOwnership.cjs +2 -0
  71. package/src/main/lib/packs/packCatalog.cjs +98 -5
  72. package/src/main/lib/persona-macro/agentPersonaSchema.cjs +6 -0
  73. package/src/main/lib/persona-macro/builtinMacros.cjs +6 -4
  74. package/src/main/lib/persona-macro/personaFrontmatterSchema.cjs +9 -0
  75. package/src/main/lib/persona-macro/personaLoadout.cjs +58 -0
  76. package/src/main/lib/persona-macro/personaMerge.cjs +11 -3
  77. package/src/main/lib/persona-macro/personaUpgrade.cjs +96 -0
  78. package/src/main/lib/persona-macro/projectVideoToolCheck.cjs +1 -1
  79. package/src/main/lib/persona-macro/shippedPersonaSeeds.cjs +94 -0
  80. package/src/main/lib/prd/prdCreate.cjs +49 -5
  81. package/src/main/lib/prd/prdFrontmatter.cjs +5 -2
  82. package/src/main/lib/prd/prdMcpReachWarnings.cjs +46 -0
  83. package/src/main/lib/prd/prdSandboxWarnings.cjs +49 -0
  84. package/src/main/lib/process/peerChatSession.cjs +165 -0
  85. package/src/main/lib/project-pages/videoScriptPress.cjs +6 -0
  86. package/src/main/lib/project-pages/videoScriptRunRoute.cjs +24 -4
  87. package/src/main/lib/promptSessionSchema.cjs +2 -0
  88. package/src/main/lib/scheduler/baselineGate.cjs +31 -2
  89. package/src/main/lib/scheduler/planRecordHarvest.cjs +104 -12
  90. package/src/main/lib/scheduler/planReleaseRoute.cjs +110 -0
  91. package/src/main/lib/scheduler/planReviewSchema.cjs +182 -0
  92. package/src/main/lib/scheduler/planReviewStats.cjs +63 -0
  93. package/src/main/lib/scheduler/planReviewStore.cjs +150 -0
  94. package/src/main/lib/scheduler/reviewNotice.cjs +3 -1
  95. package/src/main/lib/scheduler/sandboxEnvironmentLimit.cjs +141 -0
  96. package/src/main/lib/scheduler/scheduleJobSchema.cjs +2 -0
  97. package/src/main/lib/scheduler/upgradeDrain.cjs +32 -5
  98. package/src/main/lib/scheduler/validatorVerdictSchema.cjs +12 -2
  99. package/src/main/lib/tasks/memoryConsolidation.cjs +118 -37
  100. package/src/main/lib/tasks/taskAdminRoutes.cjs +26 -14
  101. package/src/main/lib/tasks/taskRun.cjs +3 -1
  102. package/src/main/lib/tasks/weeklyConsolidationInputs.cjs +298 -0
  103. package/src/main/projectPages.cjs +22 -14
  104. package/src/main/pty.cjs +3 -0
  105. package/src/main/runVerify.cjs +80 -5
  106. package/src/main/scheduler/gitTreeGuard.cjs +6 -0
  107. package/src/main/scheduler/planReviewHold.cjs +146 -0
  108. package/src/main/scheduler/prdParser.cjs +1 -0
  109. package/src/main/scheduler/prdPaths.cjs +10 -1
  110. package/src/main/scheduler/reviewLadder.cjs +2 -0
  111. package/src/main/scheduler/utilizationHold.cjs +7 -2
  112. package/src/main/scheduler.cjs +692 -86
  113. package/src/main/seedAgentPersonas.cjs +11 -6
  114. package/src/main/seedStatus.cjs +1 -1
  115. package/src/main/templates/PRD_AUTHORING.md +17 -2
  116. package/src/main/webRemote.cjs +69 -7
  117. package/src/preload/api.d.ts +79 -1
  118. package/src/preload/apiSurface.json +39 -0
  119. package/src/preload/index.cjs +11 -0
  120. package/src/seed/agents/architect.md +28 -43
  121. package/src/seed/agents/dev-lead.md +3 -1
  122. package/src/seed/agents/md-network-curator.md +27 -0
  123. package/src/seed/agents/plan-reviewer.md +47 -0
  124. package/src/seed/agents/validator.md +2 -1
  125. package/dist/assets/AppSettings-BO4jDVGO.js +0 -2
  126. package/dist/assets/HomeClaudeConfig-DADP5bfn.js +0 -3
  127. package/dist/assets/ProjectClaudeConfig-DPnDJKcr.js +0 -26
  128. package/dist/assets/Scheduler-CNLjn90m.js +0 -16
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "claude-code-session-manager",
3
- "version": "0.143.0",
3
+ "version": "0.145.0",
4
4
  "description": "Free desktop app for Claude Code: run many sessions, each in its own git worktree; queue work that runs headless within your usage limits; agents drive it through an MCP server and skills.",
5
5
  "type": "module",
6
6
  "main": "src/main/index.cjs",
@@ -83,8 +83,10 @@
83
83
  "lint:page-stewards": "node scripts/check-page-stewards.cjs",
84
84
  "lint:e2e-budget": "node scripts/check-e2e-budget.cjs",
85
85
  "lint:scroll": "node scripts/check-scroll-into-view.cjs",
86
+ "lint:persona-gear": "node scripts/lint-persona-gear.cjs",
87
+ "report:loadouts": "node scripts/report-persona-loadouts.cjs",
86
88
  "check:frame": "node scripts/frame-integrity.mjs",
87
- "lint": "npm run lint:selectors && npm run lint:hooks && npm run lint:docs && npm run lint:paths && npm run lint:status-writes && npm run lint:event-log && npm run lint:any && npm run lint:main-ts-check && npm run lint:filenames && npm run lint:renderer-storage && npm run lint:test-smells && npm run lint:page-stewards && npm run lint:e2e-budget && npm run lint:scroll && npm run lint:readme",
89
+ "lint": "npm run lint:selectors && npm run lint:hooks && npm run lint:docs && npm run lint:paths && npm run lint:status-writes && npm run lint:event-log && npm run lint:any && npm run lint:main-ts-check && npm run lint:filenames && npm run lint:renderer-storage && npm run lint:test-smells && npm run lint:page-stewards && npm run lint:e2e-budget && npm run lint:scroll && npm run lint:readme && npm run lint:persona-gear",
88
90
  "sync:settings-schema": "node scripts/sync-settings-schema.cjs"
89
91
  },
90
92
  "keywords": [
@@ -32,9 +32,9 @@ new work. **report** = your final message to the human.
32
32
  human settles that code is wanted. An Epic with no tag (No mission) is treated like `discussion`.
33
33
  If `developLoop` is `false`, do not author PRDs (the API refuses them): tell the human this
34
34
  session was started without the develop loop and a new session with it on is needed to queue work. Stop.
35
- 3. **Never hand-implement in this session**, even when the plan is agreed. Why: this session
36
- runs an expensive planner model; a cheaper executor runs each PRD as a headless `claude -p`
37
- job.
35
+ 3. **Never hand-implement a PRD's work in this session**, even when the plan is agreed. Work
36
+ small enough to do inline (the Actor persona's lane rule) never becomes a PRD. Why: this
37
+ session runs an expensive planner model; a cheaper executor runs each PRD headless.
38
38
  4. **Never delegate PRD authoring.** You write scope, title, goal, criteria and notes. Calling
39
39
  `scheduler_create_prd` with your own text is not delegation.
40
40
  5. **Never restate the engineering rules.** They live in `standards.md` beside this file, with
@@ -85,11 +85,13 @@ three failure modes have different fixes:
85
85
  human to start the app, then retry the same call. Why: a PRD file the API did not write is
86
86
  quarantined and never runs.
87
87
  - **(b) Create errors with "did not answer" or "Connection closed".** It may still have been written; retry the same call with the same slug (it returns the existing PRD with `alreadyExisted: true`, or per entry `applied`) and never re-issue it under a new slug. `scheduler_get_prd` accepts the bare slug.
88
- - **(c) Tool ABSENT from your tool list.** The `session-manager-scheduler` MCP server is not
89
- registered: a **misconfiguration**, not an offline app.
90
- **STOP. Do not write any PRD file.** Tell the human. The app registers the server at user
91
- scope the first time it starts. If it is still missing, the human deletes
92
- `~/.claude/session-manager/.scheduler-mcp-seeded`, restarts the app, and opens a new session.
88
+ - **(c) Tool ABSENT from your tool list.** A **misconfiguration**, not an offline app.
89
+ **STOP. Do not write any PRD file.** Diagnose first: run `claude mcp get session-manager-scheduler`.
90
+ If it shows **Connected**, the server is registered and the chat's gear scope hid it: look for
91
+ a `Gear:` notice in the chat and report it to the human as a Session Manager gear bug. Never
92
+ delete the seeded marker or restart for it. Only if it is NOT registered: the app registers it
93
+ at user scope on first start; the human deletes `~/.claude/session-manager/.scheduler-mcp-seeded`,
94
+ restarts the app, and opens a new session.
93
95
  Never add a project `.mcp.json` entry yourself. Why: it brings back per-repo drift.
94
96
 
95
97
  ### Steps
@@ -110,11 +112,9 @@ three failure modes have different fixes:
110
112
  (empty, max, concurrent, malformed, permission, failure); interaction effects (what depends
111
113
  on your change); integration (reuse the existing schema, store, API, primitives);
112
114
  validation (for UI: which screenshot, light and dark, proves which criterion).
113
- 4. **Run a completeness pass** if the ask exceeds one or two PRDs or spans subsystems: start it as a
114
- background sub-agent as soon as the draft list exists (Explore or general-purpose; the ask
115
- verbatim, your draft list, the lenses; ask what is missing) and keep exploring while it runs.
116
- The planner turn is hard-killed at 30 minutes with a warning at 24; late gaps become sibling
117
- PRDs. Fold in real gaps, drop vague ones. Repeat at most once. It reviews; you author.
115
+ 4. **Plans of 3+ PRDs, or any chain, are held for an independent plan review before dispatch**
116
+ (`held: plan-review`). `SM_PLAN_REVIEW=0` is off;
117
+ `SM_PLAN_REVIEW_HOLD_MINUTES` is the timeout.
118
118
  5. **Tests and security go inside the feature's own PRD** as criteria (security when it
119
119
  touches input, auth or data), never as follow-ups. Why: TDD needs the test with the code;
120
120
  security is decided while writing it. Also check quality (performance, error handling).
@@ -126,8 +126,8 @@ three failure modes have different fixes:
126
126
  `manual.json`. Why: a release never finds a gap it can only report.
127
127
  6. **Pick a shape.** Most asks are an independent set. Chain 3–5 PRDs only for truly
128
128
  sequential work: each link `dependsOn` the previous one; its notes name what that link
129
- delivers and say to read the landed code first. Never chain past 5; redo the completeness
130
- pass. Each goal's first sentence names its type, in chain order: `primitive` (new helper
129
+ delivers and say to read the landed code first. Never chain past 5; re-split the plan.
130
+ Each goal's first sentence names its type, in chain order: `primitive` (new helper
131
131
  and its test), `wire` (adopt it at named call sites), `behavior` (one function's logic and
132
132
  its test), `migration` (mechanical change), `doc`, `validate`. A gap you leave out of the
133
133
  first plan is queued in the same turn as a later wave that `dependsOn` the PRDs it builds
@@ -165,7 +165,7 @@ three failure modes have different fixes:
165
165
  change a PRD only to silence a warning. Then post one short message: each PRD's number and
166
166
  slug, the validate slug, and that no per-PRD check will come from this session. Name a
167
167
  warning only if you changed a PRD because of it.
168
- 13. **Never stop for review after queueing.** Why: the validator is the review.
168
+ 13. **Never stop for review after queueing.** Why: the plan reviewer reviews before dispatch and the validator after.
169
169
 
170
170
  ### PRD fields
171
171
 
@@ -188,7 +188,7 @@ Never pass `parallelGroup`; it is ignored. The API writes the frontmatter, `# Fi
188
188
  ### gate and files rules
189
189
 
190
190
  The syntax rules for `gate` and `files` are in PRD_AUTHORING.md §6, and the API enforces them: it
191
- refuses a bad gate or path and returns warnings — read them and fix the input. Two rules only you
191
+ refuses a bad gate or path and returns warnings — read them and fix the input. Three rules only you
192
192
  can apply, because they depend on the repo at authoring time:
193
193
 
194
194
  1. Before queueing, run each gate command once at the current HEAD in the main checkout. If it
@@ -200,6 +200,9 @@ can apply, because they depend on the repo at authoring time:
200
200
  criterion; keep them out of PRDs at authoring time (PRD_AUTHORING.md §14, No human-only gates).
201
201
  Live-run steps that need gitignored state follow PRD_AUTHORING.md §7 (absolute main-checkout
202
202
  paths, artifact-only).
203
+ 3. Never list a path under `.claude/agents`, `commands`, `skills`, `hooks` or `settings*.json` in
204
+ `files`: the job sandbox refuses every write there, so the architect makes that edit inline
205
+ in the Epic chat (PRD_AUTHORING.md#job-sandbox-limits).
203
206
 
204
207
  ### What a headless run cannot do
205
208
 
@@ -246,7 +249,7 @@ scheduler saves it as `session-manager-operations/plan-records/<epic-id>/<valida
246
249
  `GET /admin/epic` serves it as `verdicts`. Queue the validate PRD in the same `scheduler_create_prds` call as the plan (its `dependsOn` may name that call's entries); with single creates it goes last: in a single `scheduler_create_prd`, `dependsOn` accepts only slugs that already exist. The
247
250
  scheduler sends no per-PRD validation prompt. When the Epic has no pending or running PRD for
248
251
  `SM_EPIC_SETTLE_SECONDS` (default 120), it queues one `validate-sweep-*` validator for completed
249
- PRDs no validator checked (a large sweep becomes several sweeps in turn), then sends one PLAN SETTLED digest. Several validators in one Epic
252
+ PRDs no validator checked (a large sweep becomes several sweeps in turn), then sends one PLAN SETTLED digest. PRDs held on a precondition, and validators waiting only on them, do not hold back the digest, which lists them. Several validators in one Epic
250
253
  are fine: each runs headless.
251
254
 
252
255
  If the API rejects `agentType: "validator"`, the persona is not installed: keep the plan
@@ -299,7 +302,10 @@ Rules:
299
302
  under Needs you (rule 6) with the validator's reason and what was tried. Why: a second miss on the same criterion means the plan is wrong, and another
300
303
  wave would repeat it. A Not validated list means validate exactly those PRDs here. All
301
304
  `VERIFIED` with nothing open means Done: write the final report.
302
- 3. **A `PRECONDITION HOLD` notice** is not a park and not a fix-wave trigger. Do nothing — no
305
+ 3. **A PLAN REVIEWED digest.** Apply amendments via `scheduler_update_prd`, give a one-line
306
+ reason per rejected finding, then release with one `scheduler_release_plan` call
307
+ (`rereview` only after a block, once).
308
+ 4. **A `PRECONDITION HOLD` notice** is not a park and not a fix-wave trigger. Do nothing — no
303
309
  reset, no edit, no fix PRD; the scheduler re-checks the preflight on its own. State the
304
310
  missing precondition in the report. Why: only a person can supply it.
305
311
  4. **Done** = the latest validator marked every PRD `VERIFIED`, including each PRD an earlier
@@ -7,7 +7,7 @@ description: >-
7
7
  place, with nothing stale. Use when the user asks to review, audit, clean up,
8
8
  restructure or drift-check a project's CLAUDE.md or docs, when the Review MD
9
9
  network macro runs, or says "/maintaining-md-network". Takes a Scope and a
10
- Mode (Full review or Drift check).
10
+ Mode (Full review, Drift check or Weekly consolidation).
11
11
  ---
12
12
 
13
13
  # maintaining-md-network
@@ -17,7 +17,7 @@ description: >-
17
17
  ## Inputs
18
18
 
19
19
  - **Scope:** a folder, or the whole project (default).
20
- - **Mode:** Full review or Drift check.
20
+ - **Mode:** Full review, Drift check or Weekly consolidation.
21
21
 
22
22
  ## Rule
23
23
 
@@ -40,6 +40,7 @@ Each is one level deep; none links another, except audit.md's census step, which
40
40
  - [audit.md](audit.md): read for steps 1-4 (census, audiences, links, truth check), the time box and the subagent brief.
41
41
  - [plan.md](plan.md): read for the report contents, verdicts, history and runtime state, the `/develop` order and cross-repo routing.
42
42
  - [drift-check.md](drift-check.md): read for Drift check mode, running the script and the review record.
43
+ - [weekly-consolidation.md](weekly-consolidation.md): read for Weekly consolidation mode: inputs, change kinds, caps, the record and apply.
43
44
  - [migrate-to-agents-md.md](migrate-to-agents-md.md): read when moving a project's CLAUDE.md text into AGENTS.md.
44
45
 
45
46
  The script is `<skill base dir>/scripts/drift-check.cjs`.
@@ -70,3 +71,16 @@ Drift check
70
71
  - [ ] Report findings; change no files until approved
71
72
  - [ ] After approval, fix with /develop and write a new review record (drift-check.md)
72
73
  ```
74
+
75
+ ## Weekly consolidation
76
+
77
+ Copy this checklist and tick it off:
78
+
79
+ ```
80
+ Weekly consolidation
81
+ - [ ] Look for a pending weekly Task record; walk it if found (weekly-consolidation.md)
82
+ - [ ] Else gather memory, network, transcripts, Lessons blocks, steering file
83
+ - [ ] Subagents find patterns; keep those seen in 2+ sessions
84
+ - [ ] Write the record: verify, organize, enrich, procedure changes plus housekeeping
85
+ - [ ] Owner accepts or rejects each change; apply only accepted ones, commit the record
86
+ ```
@@ -0,0 +1,91 @@
1
+ # Weekly consolidation
2
+
3
+ ## Contents
4
+
5
+ - [Inputs](#inputs)
6
+ - [Read-only](#read-only)
7
+ - [Orchestrator and subagents](#orchestrator-and-subagents)
8
+ - [Change kinds](#change-kinds)
9
+ - [Keep learnings few](#keep-learnings-few)
10
+ - [Housekeeping](#housekeeping)
11
+ - [The record](#the-record)
12
+ - [Apply](#apply)
13
+ - [Steering file](#steering-file)
14
+
15
+ One out-of-band pass that curates the markdown network and the project's auto memory together, fed by the week's session transcripts. It proposes; the owner accepts one change at a time.
16
+
17
+ ## Inputs
18
+
19
+ - The project's auto memory folder: `~/.claude/projects/<slug>/memory`.
20
+ - Its markdown network (the census in audit.md).
21
+ - Its own session transcripts since the previous consolidation: the project root's transcript folder plus the folders of its Epic and job worktrees. Never another project's.
22
+ - The Lessons blocks headless jobs handed over in that window.
23
+ - The optional steering file (see Steering file).
24
+
25
+ Read tool calls and tool errors, not only messages. A tool call that keeps failing is a main signal.
26
+
27
+ ## Read-only
28
+
29
+ The pass changes nothing live. As the scheduled Task it has only read tools. When a human presses the macro, research and report first and change no file until accepted (SKILL.md's Rule). The memory law holds: upkeep proposes, never deletes. A removal is applied only after the owner's accept.
30
+
31
+ ## Orchestrator and subagents
32
+
33
+ 1. One subagent per transcript, or per small batch (about 5), returns candidate patterns. Each carries the session id(s) it was seen in.
34
+ 2. The orchestrator keeps only patterns seen in at least 2 sessions. A pattern seen in fewer produces no change.
35
+
36
+ ## Change kinds
37
+
38
+ Each kept pattern becomes ONE change of one kind:
39
+
40
+ - **verify:** a memory or doc line no longer true is fixed or removed.
41
+ - **organize:** duplicates are merged; a lasting fact moves from memory into the doc that owns it (placement.md).
42
+ - **enrich:** a missing lesson is added.
43
+ - **procedure:** a new skill or small tool is proposed for a multi-step procedure that was worked out by hand (the same steps rebuilt from scratch, not run from a doc) in at least 2 sessions in the window. The proposal names the skill's path, when to use it, its steps, and the files or commands it relies on; a tool instead names its path and the README line that lists it. Before you propose one, search the project's existing skills (`.claude/skills/`, `plugins/*/skills/`), tools and docs for the same procedure. If one already covers it, propose an edit to that file as **organize** instead, never a second skill. A pattern that repeats a single step, or that only produced a lesson, stays enrich.
44
+
45
+ ## Keep learnings few
46
+
47
+ - At most 5 adds per run: enrich and procedure together.
48
+ - At most 1 procedure per run. If more than one qualifies, propose the one seen in the most sessions; the rest produce no change.
49
+ - A run with no procedure rebuilt by hand in 2+ sessions proposes none.
50
+ - Merges and removals are unlimited.
51
+ - Prefer pruning.
52
+
53
+ ## Housekeeping
54
+
55
+ Always proposed, outside the cap:
56
+
57
+ - Older dated usage-reviewer statuses in memory are removed, so only the newest per report remains.
58
+ - Every memory file missing `originSessionId` or `modified` in its frontmatter metadata gets them filled. Take `originSessionId` from the transcript that wrote the file when known.
59
+
60
+ No write log, no hash, no hook.
61
+
62
+ ## The record
63
+
64
+ Template:
65
+
66
+ ```
67
+ # Markdown network weekly consolidation <YYYY-MM-DD>
68
+
69
+ - Transcripts read: <count>, <first date> to <last date>
70
+ - Lessons blocks consumed: <job/PRD ids, or none>
71
+ - Totals: adds N, merges N, removals N
72
+
73
+ | Id | Kind | Target file | Change | Example sessions | Count |
74
+ | --- | --- | --- | --- | --- | --- |
75
+ | c1 | verify / organize / enrich | <path> | <the change> | <id>, <id> | <N, at least 2> |
76
+ | c2 | procedure | <proposed skill or tool path> | <name; when to use it; steps; files or commands it relies on; README line for a tool> | <id>, <id> | <N, at least 2> |
77
+ ```
78
+
79
+ Every row names at least 2 session ids. A procedure row counts as an add in Totals.
80
+
81
+ ## Apply
82
+
83
+ 1. The owner accepts or rejects each change. Only accepted changes are applied.
84
+ 2. The architect applies them in the Epic the owner opened with the macro: memory edits inline; doc changes inline when small and provable, otherwise `/develop`. An accepted procedure row whose path is under `.claude/` (a skill) is written from the Epic chat, never by a PRD: headless job sandboxes mount `.claude/` read-only. A tool outside `.claude/` may go through `/develop`.
85
+ 3. Commit the record as session-manager-operations/reviews/docs/<YYYY-MM-DD>-md-network-weekly.md, following the record rules in drift-check.md.
86
+
87
+ When pressed with Mode 'Weekly consolidation', first look for the newest pending weekly Task (`task_list` with pipeline memory-consolidation, then `task_get` for its output) and walk its record. If none is pending, run the pass in the Epic.
88
+
89
+ ## Steering file
90
+
91
+ Optional: session-manager-operations/md-network/steering.md. A human writes it and tracks it in git; it says what the owner thinks matters and does not. The app reads it through `opsPath()`; it is declared `tracked` in `GIT_CLASS` with an ops AGENTS.md row. It has no owning writer (human-authored), so it gets no `OWNERS` entry.
@@ -241,9 +241,12 @@ Two distinct failure modes — don't conflate them:
241
241
  `active-index.json` is exactly the racing second writer the single-writer law
242
242
  exists to prevent. Tell the human to start the app, and report the finding to
243
243
  them in the meantime so it isn't lost.
244
- - **`feedback_open_session` is absent from your tool list entirely** — the
245
- `session-manager-scheduler` MCP server isn't registered for this project.
246
- That's a misconfiguration, not an offline app. Tell the human: the app
247
- registers the server at user scope the first time it starts; if it is still
248
- missing, delete `~/.claude/session-manager/.scheduler-mcp-seeded`, restart the
249
- app, and open a new session. Never add an MCP entry yourself.
244
+ - **`feedback_open_session` is absent from your tool list entirely** —
245
+ a misconfiguration, not an offline app. STOP: never hand-write the session.
246
+ Diagnose first: run `claude mcp get session-manager-scheduler`. If it shows
247
+ **Connected**, the server is registered and the chat's gear scope hid it —
248
+ look for a `Gear:` notice in the chat and report it to the human as a Session
249
+ Manager gear bug; never delete the seeded marker or restart for it. Only if it
250
+ is NOT registered: the app registers it at user scope on first start; delete
251
+ `~/.claude/session-manager/.scheduler-mcp-seeded`, restart the app, and open a
252
+ new session. Never add a project `.mcp.json` / MCP entry yourself.
package/scripts/README.md CHANGED
@@ -32,7 +32,7 @@ scripts/lib was moved into src/main/lib (2026-09); nothing under src/ may requir
32
32
  | ops-sweep.cjs | manual; `node scripts/ops-sweep.cjs <cwd>` | yes |
33
33
  | postinstall.cjs | npm `postinstall` | yes |
34
34
  | purge-dry-run.cjs | manual / validators, read-only; `node scripts/purge-dry-run.cjs <cwd> <epicId>` prints `purgeEpic({ dryRun: true })` JSON (artifacts by kind + counts), deletes nothing; a real purge stays the epic:purge IPC | no |
35
- | release-notes.cjs | `.github/workflows/release.yml` finalize-release job, and manual; `node scripts/release-notes.cjs --tag <ref> [--prev <tag>]` prints the GitHub release body (upgrade note from the tag tree + commit subjects since prev) — convention in [release-notes/README.md](../release-notes/README.md) | no |
35
+ | release-notes.cjs | `.github/workflows/release.yml` finalize-release job, and manual; `node scripts/release-notes.cjs --tag <ref> [--prev <tag>] [--max-chars <n>]` prints the GitHub release body (upgrade note from the tag tree, its relative links made github.com blob URLs at `<ref>` and its headings demoted two levels, + commit subjects since prev); `--max-chars` = positive integer body cap (default 120000), anything else exits 1 — convention in [release-notes/README.md](../release-notes/README.md) | no |
36
36
  | refresh-vad-assets.mjs | `npm run refresh:vad-assets` | no |
37
37
  | replay-verdicts.cjs | manual, dev-only, read-only | no |
38
38
  | scheduler-mcp-server.cjs | registered as an MCP server (`seedSchedulerMcp.cjs`, `send-feedback` SKILL.md) | yes |
@@ -78,6 +78,7 @@ const { MCP_TOOL_CATALOG, MCP_RECIPES, composeDescription, FIXES_INPUT_SCHEMA }
78
78
  const {
79
79
  FEEDBACK_LIST_PROJECTS_INPUT_SCHEMA, FEEDBACK_OPEN_SESSION_INPUT_SCHEMA, MACRO_LIST_INPUT_SCHEMA, EPIC_GET_INPUT_SCHEMA,
80
80
  } = require('../src/main/lib/feedback-remote/serviceMcpTools.cjs');
81
+ const { SERVICE_TOOL_NAMES } = require('../src/main/lib/feedback-remote/servicePairings.cjs');
81
82
  const { EPIC_OUTSIDE_STATES } = require('../src/main/lib/epic/epicOutsideState.cjs');
82
83
  const { KINDS: ARTIFACT_KINDS } = require('../src/main/lib/epic/artifactStore.cjs');
83
84
  const { REVIEW_TEXT_MAX, REVIEW_IMAGES_MAX, REVIEW_IMAGE_BYTES_MAX } = require('../src/main/lib/project-pages/videoReview.cjs');
@@ -693,6 +694,30 @@ const TOOLS = [
693
694
  required: ['prds'],
694
695
  },
695
696
  },
697
+ {
698
+ name: 'scheduler_release_plan',
699
+ description: descriptionFor('scheduler_release_plan'),
700
+ inputSchema: {
701
+ type: 'object',
702
+ properties: {
703
+ epicId: { type: 'string', description: 'The Epic id the plan belongs to.' },
704
+ validateSlug: { type: 'string', description: "The plan's validate PRD slug." },
705
+ accepted: { type: 'number', description: 'How many review findings you accepted.' },
706
+ rejected: {
707
+ type: 'array',
708
+ description: 'Each rejected finding with a one-line reason (reason must be non-empty).',
709
+ items: {
710
+ type: 'object',
711
+ properties: { finding: { type: 'string' }, reason: { type: 'string' } },
712
+ required: ['finding', 'reason'],
713
+ },
714
+ },
715
+ rereview: { type: 'boolean', description: 'Instead of releasing, request the single re-review after a block (once per plan).' },
716
+ cwd: { type: 'string', description: 'Optional: project cwd; defaults to this process cwd.' },
717
+ },
718
+ required: ['epicId', 'validateSlug'],
719
+ },
720
+ },
696
721
  {
697
722
  name: 'scheduler_list_prds',
698
723
  description: descriptionFor('scheduler_list_prds'),
@@ -965,6 +990,25 @@ const TOOLS = [
965
990
  description: descriptionFor('feedback_open_session'),
966
991
  inputSchema: FEEDBACK_OPEN_SESSION_INPUT_SCHEMA,
967
992
  },
993
+ {
994
+ name: 'service_pair_local',
995
+ description: descriptionFor('service_pair_local'),
996
+ inputSchema: {
997
+ type: 'object',
998
+ properties: {
999
+ stateDir: { type: 'string', description: 'Absolute path of the directory where the service keeps its pairing state.' },
1000
+ name: { type: 'string', description: 'Display name of the service.' },
1001
+ homeCwd: { type: 'string', description: 'Absolute path of the service\'s home project.' },
1002
+ tools: {
1003
+ type: 'array', minItems: 1,
1004
+ items: { type: 'string', enum: [...SERVICE_TOOL_NAMES] },
1005
+ description: 'The Session Manager tools the service may call.',
1006
+ },
1007
+ projectRoot: { type: 'string', description: 'Optional: the service\'s project root.' },
1008
+ },
1009
+ required: ['stateDir', 'name', 'homeCwd', 'tools'],
1010
+ },
1011
+ },
968
1012
  {
969
1013
  name: 'feedback_reply',
970
1014
  description: descriptionFor('feedback_reply'),
@@ -2025,6 +2069,8 @@ async function handleCallTool(request) {
2025
2069
  if (issueLines) {
2026
2070
  text += `\nFix these fields and call again:\n${issueLines.join('\n')}`;
2027
2071
  }
2072
+ // A refusal wrote nothing: return it as an error like scheduler_create_prds does.
2073
+ if (result?.ok === false) return errorResult(text);
2028
2074
  return { content: [{ type: 'text', text }] };
2029
2075
  }
2030
2076
  if (name === 'scheduler_create_prds') {
@@ -2071,6 +2117,21 @@ async function handleCallTool(request) {
2071
2117
  }
2072
2118
  return { content: [{ type: 'text', text }] };
2073
2119
  }
2120
+ if (name === 'scheduler_release_plan') {
2121
+ const refusal = headlessQueueRefusal('scheduler_release_plan');
2122
+ if (refusal) return refusal;
2123
+ const body = {
2124
+ cwd: typeof args?.cwd === 'string' && args.cwd ? args.cwd : process.cwd(),
2125
+ epicId: args?.epicId,
2126
+ validateSlug: args?.validateSlug,
2127
+ rejected: Array.isArray(args?.rejected) ? args.rejected : [],
2128
+ accepted: typeof args?.accepted === 'number' ? args.accepted : 0,
2129
+ ...(args?.rereview === true ? { rereview: true } : {}),
2130
+ };
2131
+ const result = await adminRequest('POST', '/admin/scheduler/release-plan', body);
2132
+ if (result?.ok === false) return errorResult(`scheduler_release_plan refused: ${result.reason ?? result.error ?? JSON.stringify(result)}`);
2133
+ return { content: [{ type: 'text', text: JSON.stringify(result) }] };
2134
+ }
2074
2135
  if (name === 'feedback_list_projects') {
2075
2136
  const result = await adminRequest('GET', '/admin/feedback/targets');
2076
2137
  return { content: [{ type: 'text', text: JSON.stringify(result) }] };
@@ -2121,6 +2182,22 @@ async function handleCallTool(request) {
2121
2182
  }
2122
2183
  return { content: [{ type: 'text', text: JSON.stringify(result) + note }] };
2123
2184
  }
2185
+ if (name === 'service_pair_local') {
2186
+ const refused = humanSessionRefusal('refused: service_pair_local runs only in a Session Manager chat or terminal session where the human asked for the pairing; '
2187
+ + 'say in your final result which service the human should pair.');
2188
+ if (refused) return refused;
2189
+ if (process.env.SM_KG_INTERNAL === '1') return errorResult('refused: service_pair_local is not available to internal headless runs.');
2190
+ for (const key of ['stateDir', 'name', 'homeCwd']) {
2191
+ if (!args || typeof args[key] !== 'string' || !args[key].trim()) return errorResult(`missing required argument: ${key}`);
2192
+ }
2193
+ if (!path.isAbsolute(args.stateDir)) return errorResult('stateDir must be an absolute path');
2194
+ if (!Array.isArray(args.tools) || args.tools.length === 0) return errorResult('missing required argument: tools');
2195
+ const opts = { stateDir: args.stateDir, name: args.name, homeCwd: args.homeCwd, tools: args.tools };
2196
+ if (typeof args.projectRoot === 'string' && args.projectRoot.trim()) opts.projectRoot = args.projectRoot;
2197
+ const r = await require('../src/main/lib/feedback-remote/serviceStdioBridge.cjs').pairLocal(opts);
2198
+ if (!r || r.ok !== true) return errorResult(String((r && r.error) || 'pairing failed'));
2199
+ return { content: [{ type: 'text', text: JSON.stringify({ ok: true, service: r.service }) }] };
2200
+ }
2124
2201
  if (name === 'feedback_reply') {
2125
2202
  // Only the Epic's own interactive session can reply: a scheduled job has
2126
2203
  // no chat identity, and its work is reported in its result instead.
@@ -14,6 +14,8 @@ function registerAppAdminRoutes(adminHttp, deps = {}) {
14
14
  scheduler.registerAdminRoutes(adminHttp);
15
15
  // GET/POST /admin/scheduler/slots — read the slot cap; change it only on the human's verified words.
16
16
  require('./lib/scheduler/slotsRoute.cjs').registerSlotsRoute(adminHttp);
17
+ // POST /admin/scheduler/release-plan — the planner releases a plan held for review (or asks one re-review).
18
+ require('./lib/scheduler/planReleaseRoute.cjs').registerPlanReleaseRoute(adminHttp);
17
19
  // GET /admin/usage-hold — the 'pause above' hold POST /admin/tasks refuses on, for runners that start claude -p directly (read-only).
18
20
  require('./lib/scheduler/usageHoldRoute.cjs').registerUsageHoldRoute(adminHttp);
19
21
  require('./lib/prd/prdCreate.cjs').registerAdminRoute(adminHttp, scheduler.remote);
@@ -43,6 +45,10 @@ function registerAppAdminRoutes(adminHttp, deps = {}) {
43
45
  // several projects' operations roots open, so it performs the cross-folder
44
46
  // write (lib/feedback-remote/crossProjectFeedback.cjs).
45
47
  require('./lib/feedback-remote/crossProjectFeedback.cjs').registerAdminRoute(adminHttp);
48
+ // POST /admin/projects/create — a paired service's new local (+ private GitHub) project; broadcasts `projects:created`.
49
+ require('./lib/feedback-remote/projectCreate.cjs').registerAdminRoute(adminHttp);
50
+ // POST /admin/services/pair-local[/confirm] — same-machine service pairing with no window step.
51
+ require('./lib/feedback-remote/servicePairLocalRoutes.cjs').registerAdminRoute(adminHttp);
46
52
  // Its return leg: the receiving session answers INTO the Epic that asked
47
53
  // (lib/feedback-remote/crossProjectReply.cjs).
48
54
  require('./lib/feedback-remote/crossProjectReply.cjs').registerAdminRoute(adminHttp);
@@ -24,15 +24,21 @@ const os = require('node:os');
24
24
  const { splitFrontmatter } = require('./lib/prd/prdFrontmatter.cjs');
25
25
  const { resolveMergedPersona, PERSONA_NAME_RE } = require('./lib/persona-macro/personaMerge.cjs');
26
26
  const { isNonClaudeAgentCli, isAgentCliModel } = require('./lib/agent-cli/agentCliEvents.cjs');
27
+ const { loadoutState, encodeLoadout } = require('./lib/persona-macro/personaLoadout.cjs');
28
+ const { mcpServersFromTools } = require('./lib/claude/agentSnapshot.cjs');
29
+ const { personaUpgradeFor, readDismissals } = require('./lib/persona-macro/personaUpgrade.cjs');
27
30
  const configMgr = require('./config.cjs');
28
31
  const sessionsStore = require('./sessionsStore.cjs');
29
32
 
30
33
  /** Parses the frontmatter `tools` field ("Read, Grep, Glob, Bash") into a list. */
31
34
  function parseTools(raw) {
32
35
  if (!raw) return [];
33
- return raw.split(',').map((t) => t.trim()).filter(Boolean);
36
+ return raw.split(',').map((t) => t.trim()).filter((t) => t && t !== '[]');
34
37
  }
35
38
 
39
+ /** Explicit-empty marker for a gear list: `mcpServers: []` / `packs: []` = replace with none. */
40
+ const EMPTY_LIST_ENCODING = '[]';
41
+
36
42
  /**
37
43
  * A declared-capability frontmatter value (`mcpServers:` / `packs:`) as a
38
44
  * list: a comma string ("a, b") or a string list (structured callers).
@@ -46,7 +52,7 @@ function parseCapabilityList(raw) {
46
52
  for (const it of items) {
47
53
  if (typeof it !== 'string') continue;
48
54
  const v = it.trim();
49
- if (v && !out.includes(v)) out.push(v);
55
+ if (v && v !== EMPTY_LIST_ENCODING && !out.includes(v)) out.push(v);
50
56
  }
51
57
  return out;
52
58
  }
@@ -125,10 +131,12 @@ function extractUnmanagedLines(raw, managed) {
125
131
  return out;
126
132
  }
127
133
 
128
- function serializePersona({ name, description, tools, model, effort, color, tags, projects, action, actionLabel, title, seedVersion, executorOnly, agentCli, agentCliModel, mcpServers, packs, environment, body, preservedLines }) {
134
+ function serializePersona({ name, description, tools, loadout, model, effort, color, tags, projects, action, actionLabel, title, seedVersion, executorOnly, agentCli, agentCliModel, mcpServers, packs, environment, body, preservedLines }) {
129
135
  const lines = ['---', `name: ${name}`];
130
136
  if (description) lines.push(`description: ${description}`);
131
- if (tools && tools.length) lines.push(`tools: ${tools.join(', ')}`);
137
+ // `loadout` (bare/unbound/equipped/undecided) wins; absent, `tools` is the decision (['*'] = unbound).
138
+ const toolsValue = loadout ? encodeLoadout(loadout, tools) : (tools && tools.length ? tools.join(', ') : null);
139
+ if (toolsValue) lines.push(`tools: ${toolsValue}`);
132
140
  if (model && model !== 'inherit') lines.push(`model: ${model}`);
133
141
  if (effort && effort !== 'inherit') lines.push(`effort: ${effort}`);
134
142
  if (isNonClaudeAgentCli(agentCli)) {
@@ -144,8 +152,8 @@ function serializePersona({ name, description, tools, model, effort, color, tags
144
152
  if (title) lines.push(`title: ${title}`);
145
153
  if (typeof seedVersion === 'number' && Number.isFinite(seedVersion)) lines.push(`seedVersion: ${seedVersion}`);
146
154
  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(', ')}`);
155
+ if (Array.isArray(mcpServers)) lines.push(`mcpServers: ${mcpServers.length ? mcpServers.join(', ') : EMPTY_LIST_ENCODING}`);
156
+ if (Array.isArray(packs)) lines.push(`packs: ${packs.length ? packs.join(', ') : EMPTY_LIST_ENCODING}`);
149
157
  if (typeof environment === 'string' && environment.trim()) lines.push(`environment: ${environment.trim()}`);
150
158
  if (Array.isArray(preservedLines) && preservedLines.length) lines.push(...preservedLines);
151
159
  lines.push('---', '');
@@ -179,10 +187,22 @@ async function findOpenProject(projectCwd, loadSessions) {
179
187
  return project;
180
188
  }
181
189
 
190
+ /** Frontmatter keys a project overlay may carry (everything else in an overlay is preserved verbatim). */
191
+ const OVERLAY_KEYS = new Set(['model', 'effort', 'tools', 'mcpServers', 'packs', 'environment']);
192
+
193
+ /** Throws when an overlay's managed lines fail the persona schema's per-key rules (a placeholder model stands in for the global one). */
194
+ function assertValidOverlayKeys(name, managedLines) {
195
+ const { validatePersonaFrontmatter } = require('./lib/persona-macro/personaFrontmatterSchema.cjs');
196
+ const fm = { ...splitFrontmatter(['---', ...managedLines, '---', ''].join('\n')).fm };
197
+ if (!('model' in fm) || fm.model === undefined) fm.model = 'sonnet';
198
+ const result = validatePersonaFrontmatter(fm);
199
+ if (!result.ok) throw new Error(`invalid project override for ${name}: ${result.errors.join('; ')}`);
200
+ }
201
+
182
202
  /**
183
203
  * Project OVERRIDE write: a frontmatter-only overlay at
184
204
  * `<projectCwd>/.claude/agents/<name>.md` carrying ONLY the overridden `model` /
185
- * `effort` keys and no body (lib/persona-macro/personaMerge.cjs inherits everything else
205
+ * `effort` / `tools` / `mcpServers` / `packs` / `environment` keys and no body (lib/persona-macro/personaMerge.cjs inherits everything else
186
206
  * from the global persona). `projectCwd` must be an OPEN project's cwd (see
187
207
  * findOpenProject). Keys already in an existing frontmatter-only
188
208
  * overlay are preserved; an existing overlay that has a BODY is refused so a
@@ -198,7 +218,7 @@ async function findOpenProject(projectCwd, loadSessions) {
198
218
  * unknown or empty `projectCwd` throws in findOpenProject first, so nothing is
199
219
  * registered for it.
200
220
  */
201
- async function saveOverlay({ name, projectCwd, model, effort, loadSessions, validatePath, writeTextAtomic, addAllowedRoot }) {
221
+ async function saveOverlay({ name, projectCwd, model, effort, tools, loadout, mcpServers, packs, environment, loadSessions, validatePath, writeTextAtomic, addAllowedRoot }) {
202
222
  const project = await findOpenProject(projectCwd, loadSessions);
203
223
  // Dormant tab = no pty-registered root; see JSDoc + projectBrief.cjs allowBriefWrites.
204
224
  addAllowedRoot(validatePath(project.cwd));
@@ -210,7 +230,7 @@ async function saveOverlay({ name, projectCwd, model, effort, loadSessions, vali
210
230
  if (existing.body.trim() !== '') {
211
231
  throw new Error(`${name} has a full-body override in ${project.name} — edit ${target} directly; it is not converted to a frontmatter-only override`);
212
232
  }
213
- preserved = extractUnmanagedLines(rawExisting, new Set(['model', 'effort']));
233
+ preserved = extractUnmanagedLines(rawExisting, OVERLAY_KEYS);
214
234
  } catch (e) {
215
235
  if (e.code !== 'ENOENT') throw e;
216
236
  }
@@ -218,6 +238,15 @@ async function saveOverlay({ name, projectCwd, model, effort, loadSessions, vali
218
238
  for (const [k, v] of [['model', model], ['effort', effort]]) {
219
239
  if (v && v !== 'inherit') managedLines.push(`${k}: ${v}`);
220
240
  }
241
+ // Gear keys REPLACE the global value for this project (personaMerge.cjs). Unset = no line = inherit.
242
+ // `tools: []` alone is the override call's dummy value, so Bare/Unbound need an explicit `loadout`.
243
+ const toolsValue = loadout ? encodeLoadout(loadout, tools) : (Array.isArray(tools) && tools.length ? encodeLoadout('equipped', tools) : null);
244
+ if (toolsValue) managedLines.push(`tools: ${toolsValue}`);
245
+ // An explicit [] is written as `[]` = replace the global value with none (personaMerge); undefined = inherit.
246
+ if (Array.isArray(mcpServers)) managedLines.push(`mcpServers: ${mcpServers.length ? mcpServers.join(', ') : EMPTY_LIST_ENCODING}`);
247
+ if (Array.isArray(packs)) managedLines.push(`packs: ${packs.length ? packs.join(', ') : EMPTY_LIST_ENCODING}`);
248
+ if (typeof environment === 'string' && environment.trim()) managedLines.push(`environment: ${environment.trim()}`);
249
+ if (managedLines.length) assertValidOverlayKeys(name, managedLines);
221
250
  if (managedLines.length === 0 && preserved.length === 0) {
222
251
  await removeOverride({ name, projectCwd: project.cwd, loadSessions, validatePath });
223
252
  return { ok: true, path: target, removed: true };
@@ -283,6 +312,7 @@ async function savePersona({
283
312
  mcpServers,
284
313
  packs,
285
314
  environment,
315
+ loadout,
286
316
  body,
287
317
  projectCwd,
288
318
  globalDir = path.join(os.homedir(), '.claude', 'agents'),
@@ -295,7 +325,7 @@ async function savePersona({
295
325
  throw new Error('agent name must be lowercase, hyphenated (e.g. "my-agent")');
296
326
  }
297
327
  if (projectCwd !== undefined) {
298
- return saveOverlay({ name, projectCwd, model, effort, loadSessions, validatePath, writeTextAtomic, addAllowedRoot });
328
+ return saveOverlay({ name, projectCwd, model, effort, tools, loadout, mcpServers, packs, environment, loadSessions, validatePath, writeTextAtomic, addAllowedRoot });
299
329
  }
300
330
  const target = validatePath(path.join(globalDir, `${name}.md`));
301
331
  // A caller that omits seedVersion/title/projects/action/actionLabel (the
@@ -341,7 +371,13 @@ async function savePersona({
341
371
  if (resolvedEnvironment === undefined && typeof fm.environment === 'string' && fm.environment.trim()) resolvedEnvironment = fm.environment.trim();
342
372
  } catch { /* no existing file (or unreadable) — nothing to carry over */ }
343
373
  }
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 });
374
+ // One write: mcpServers = caller's/carried servers ∪ servers named by mcp__<server>__<tool> tools
375
+ // (a server with no tool of its own is a whole-server grant and is kept).
376
+ const derivedServers = mcpServersFromTools(tools);
377
+ if (derivedServers.length) {
378
+ resolvedMcpServers = [...new Set([...(Array.isArray(resolvedMcpServers) ? resolvedMcpServers : []), ...derivedServers])];
379
+ }
380
+ const text = serializePersona({ name, description, tools, loadout, 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
381
  assertValidPersonaText(name, text, preservedLines);
346
382
  await writeTextAtomic(target, text);
347
383
  if (originalName && originalName !== name) {
@@ -432,6 +468,7 @@ async function listPersonas({
432
468
  globalDir = path.join(os.homedir(), '.claude', 'agents'),
433
469
  loadSessions = sessionsStore.load,
434
470
  validatePath = configMgr.validatePath,
471
+ upgradeDeps,
435
472
  } = {}) {
436
473
  let files;
437
474
  try {
@@ -443,6 +480,7 @@ async function listPersonas({
443
480
 
444
481
  const projects = await openProjects({ loadSessions });
445
482
  const personas = [];
483
+ const dismissals = upgradeDeps?.dismissals ?? readDismissals();
446
484
 
447
485
  for (const file of files.sort()) {
448
486
  const fallbackName = file.replace(/\.md$/, '');
@@ -488,10 +526,20 @@ async function listPersonas({
488
526
 
489
527
  const trimmedCli = typeof fm.agentCli === 'string' ? fm.agentCli.trim() : '';
490
528
  const listedCli = isNonClaudeAgentCli(trimmedCli) ? trimmedCli : null;
529
+ let upgrade = null;
530
+ try {
531
+ upgrade = personaUpgradeFor(fallbackName, text, { ...upgradeDeps, dismissals }) ?? null;
532
+ } catch {
533
+ upgrade = null;
534
+ }
491
535
  personas.push({
492
536
  name: fm.name || fallbackName,
493
537
  description: fm.description || null,
494
538
  tools: parseTools(fm.tools),
539
+ loadout: loadoutState(fm),
540
+ mcpServers: parseCapabilityList(fm.mcpServers),
541
+ packs: parseCapabilityList(fm.packs),
542
+ environment: typeof fm.environment === 'string' && fm.environment.trim() ? fm.environment.trim() : null,
495
543
  model: fm.model || null,
496
544
  effort: fm.effort || null,
497
545
  color: fm.color || null,
@@ -508,6 +556,7 @@ async function listPersonas({
508
556
  body: body.trim(),
509
557
  overridingProjects,
510
558
  overrideDetails,
559
+ upgrade,
511
560
  });
512
561
  }
513
562