claude-code-session-manager 0.142.0 → 0.144.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 (162) hide show
  1. package/.claude-plugin/marketplace.json +1 -1
  2. package/README.md +22 -107
  3. package/dist/assets/AppSettings-Z68gQiVE.js +2 -0
  4. package/dist/assets/{History-DpZuJXi1.js → History-C3E6y_7t.js} +2 -2
  5. package/dist/assets/HomeClaudeConfig-Yd1vXzBn.js +5 -0
  6. package/dist/assets/{Panel-BjdJjhqt.js → Panel-CnfWs46Z.js} +1 -1
  7. package/dist/assets/ProjectClaudeConfig-CP0Wsg-H.js +26 -0
  8. package/dist/assets/Scheduler-D8un7N3B.js +16 -0
  9. package/dist/assets/{SkillReferenceGraph-Cqyu4mef.js → SkillReferenceGraph-DRtZV1Al.js} +1 -1
  10. package/dist/assets/{Skills-vv0noNVI.js → Skills-Bg5O2Hyn.js} +23 -23
  11. package/dist/assets/{TiptapBody-CXi8Pvut.js → TiptapBody-BdzoBmqu.js} +27 -27
  12. package/dist/assets/{Toggle-CiYCWLjh.js → Toggle-Dt5K1OXt.js} +1 -1
  13. package/dist/assets/{VoiceButton-4NKKd1sC.js → VoiceButton-CTLyRgdF.js} +1 -1
  14. package/dist/assets/{historyTotals-DDunb8Ch.js → historyTotals-B2_KWBga.js} +1 -1
  15. package/dist/assets/{index-Cn5E9958.js → index-446b69rr.js} +715 -714
  16. package/dist/assets/{index-DVHIHoJf.css → index-BJ5TJvmz.css} +1 -1
  17. package/dist/index.html +2 -2
  18. package/dist-web/app.css +1 -1
  19. package/dist-web/app.js +438 -435
  20. package/package.json +6 -4
  21. package/plugins/session-manager-dev/.claude-plugin/plugin.json +1 -1
  22. package/plugins/session-manager-dev/skills/builder/SKILL.md +5 -0
  23. package/plugins/session-manager-dev/skills/develop/SKILL.md +23 -16
  24. package/plugins/session-manager-dev/skills/maintaining-md-network/SKILL.md +16 -2
  25. package/plugins/session-manager-dev/skills/maintaining-md-network/weekly-consolidation.md +87 -0
  26. package/scripts/README.md +1 -0
  27. package/scripts/scheduler-mcp-server.cjs +381 -6
  28. package/src/main/adminRouteRegistry.cjs +16 -0
  29. package/src/main/agentLibrary.cjs +60 -11
  30. package/src/main/agentsIpc.cjs +19 -0
  31. package/src/main/build-info.json +4 -4
  32. package/src/main/chatRunner.cjs +214 -7
  33. package/src/main/config.cjs +5 -1
  34. package/src/main/health.cjs +92 -14
  35. package/src/main/index.cjs +16 -4
  36. package/src/main/ipcSchemas.cjs +61 -1
  37. package/src/main/lib/claude/agentArmory.cjs +128 -0
  38. package/src/main/lib/claude/agentModelResolve.cjs +3 -2
  39. package/src/main/lib/claude/agentSnapshot.cjs +24 -3
  40. package/src/main/lib/claude/builtinTools.cjs +110 -0
  41. package/src/main/lib/claude/environmentProfiles.cjs +1 -1
  42. package/src/main/lib/claude/headlessMcpServers.cjs +138 -0
  43. package/src/main/lib/claude/jobSandboxPolicy.cjs +8 -2
  44. package/src/main/lib/claude/personaToolScope.cjs +77 -6
  45. package/src/main/lib/demo-video-kit/cast.md +10 -1
  46. package/src/main/lib/demo-video-kit/character.cjs +77 -21
  47. package/src/main/lib/demo-video-kit/kind-tiktok.md +5 -1
  48. package/src/main/lib/demo-video-kit/projectSounds.cjs +191 -0
  49. package/src/main/lib/demo-video-kit/seedKit.cjs +3 -3
  50. package/src/main/lib/demo-video-kit/sound.cjs +166 -9
  51. package/src/main/lib/demo-video-kit/standalone.cjs +231 -0
  52. package/src/main/lib/epic/activeIndexMerge.cjs +5 -0
  53. package/src/main/lib/epic/artifactRetention.cjs +55 -9
  54. package/src/main/lib/epic/artifactStore.cjs +78 -35
  55. package/src/main/lib/epic/delegationReadiness.cjs +10 -3
  56. package/src/main/lib/epic/epicDepsSync.cjs +66 -0
  57. package/src/main/lib/epic/epicEventLog.cjs +45 -1
  58. package/src/main/lib/epic/epicOutsideRead.cjs +38 -1
  59. package/src/main/lib/epic/epicSettle.cjs +48 -4
  60. package/src/main/lib/epic/epicSpawnPlan.cjs +3 -1
  61. package/src/main/lib/epic/epicStateEmitter.cjs +248 -0
  62. package/src/main/lib/epic/epicValidationHook.cjs +22 -3
  63. package/src/main/lib/epic/planReviewInput.cjs +123 -0
  64. package/src/main/lib/epic/restorableSessions.cjs +1 -0
  65. package/src/main/lib/epic/scriptStartedBy.cjs +71 -0
  66. package/src/main/lib/externalContract.cjs +24 -1
  67. package/src/main/lib/feedback-remote/autoStartedSession.cjs +1 -1
  68. package/src/main/lib/feedback-remote/createdProjects.cjs +291 -0
  69. package/src/main/lib/feedback-remote/crossProjectFeedback.cjs +24 -2
  70. package/src/main/lib/feedback-remote/crossProjectReply.cjs +96 -8
  71. package/src/main/lib/feedback-remote/macroAdminRoutes.cjs +54 -3
  72. package/src/main/lib/feedback-remote/pendingReplies.cjs +22 -0
  73. package/src/main/lib/feedback-remote/projectCreate.cjs +415 -0
  74. package/src/main/lib/feedback-remote/projectHomeAdminRoutes.cjs +94 -4
  75. package/src/main/lib/feedback-remote/replyClaims.cjs +168 -0
  76. package/src/main/lib/feedback-remote/serviceMcpSession.cjs +29 -1
  77. package/src/main/lib/feedback-remote/serviceMcpTools.cjs +43 -2
  78. package/src/main/lib/feedback-remote/servicePairLocalRoutes.cjs +91 -0
  79. package/src/main/lib/feedback-remote/servicePairings.cjs +47 -7
  80. package/src/main/lib/feedback-remote/serviceStdioBridge.cjs +99 -1
  81. package/src/main/lib/git/gitWorktree.cjs +8 -0
  82. package/src/main/lib/git/runtimeStateUntrack.cjs +15 -1
  83. package/src/main/lib/git/worktreeDeps.cjs +119 -10
  84. package/src/main/lib/mcpToolCatalog.cjs +144 -12
  85. package/src/main/lib/mcpToolsProbe.cjs +19 -2
  86. package/src/main/lib/opsOwnership.cjs +113 -28
  87. package/src/main/lib/packs/packCatalog.cjs +98 -5
  88. package/src/main/lib/persona-macro/agentPersonaSchema.cjs +6 -0
  89. package/src/main/lib/persona-macro/builtinMacros.cjs +6 -4
  90. package/src/main/lib/persona-macro/personaFrontmatterSchema.cjs +9 -0
  91. package/src/main/lib/persona-macro/personaLoadout.cjs +58 -0
  92. package/src/main/lib/persona-macro/personaMerge.cjs +11 -3
  93. package/src/main/lib/persona-macro/personaUpgrade.cjs +96 -0
  94. package/src/main/lib/persona-macro/projectVideoToolCheck.cjs +1 -1
  95. package/src/main/lib/persona-macro/shippedPersonaSeeds.cjs +140 -0
  96. package/src/main/lib/prd/prdCreate.cjs +395 -229
  97. package/src/main/lib/prd/prdCriteria.cjs +7 -4
  98. package/src/main/lib/prd/prdFrontmatter.cjs +5 -2
  99. package/src/main/lib/prd/prdMcpReachWarnings.cjs +44 -0
  100. package/src/main/lib/prd/prdSandboxWarnings.cjs +49 -0
  101. package/src/main/lib/process/peerChatSession.cjs +165 -0
  102. package/src/main/lib/project-pages/videoPressLines.cjs +145 -0
  103. package/src/main/lib/project-pages/videoScriptPress.cjs +266 -0
  104. package/src/main/lib/project-pages/videoScriptRunRoute.cjs +371 -0
  105. package/src/main/lib/project-pages/videoScriptSwitchIpc.cjs +49 -0
  106. package/src/main/lib/project-pages/videoScriptSwitchRoute.cjs +173 -0
  107. package/src/main/lib/promptSessionSchema.cjs +2 -0
  108. package/src/main/lib/scheduler/baselineGate.cjs +31 -2
  109. package/src/main/lib/scheduler/criteriaChecks.cjs +164 -20
  110. package/src/main/lib/scheduler/heldSchedulerTurns.cjs +238 -0
  111. package/src/main/lib/scheduler/jobMemoryStats.cjs +13 -2
  112. package/src/main/lib/scheduler/planRecordHarvest.cjs +215 -55
  113. package/src/main/lib/scheduler/planReleaseRoute.cjs +110 -0
  114. package/src/main/lib/scheduler/planReviewSchema.cjs +182 -0
  115. package/src/main/lib/scheduler/planReviewStats.cjs +63 -0
  116. package/src/main/lib/scheduler/planReviewStore.cjs +128 -0
  117. package/src/main/lib/scheduler/prdOutcomeRecord.cjs +60 -2
  118. package/src/main/lib/scheduler/queueStore.cjs +16 -0
  119. package/src/main/lib/scheduler/rcaReport.cjs +79 -15
  120. package/src/main/lib/scheduler/sandboxEnvironmentLimit.cjs +141 -0
  121. package/src/main/lib/scheduler/scheduleJobSchema.cjs +15 -0
  122. package/src/main/lib/scheduler/schedulerPaths.cjs +9 -0
  123. package/src/main/lib/scheduler/slotsRoute.cjs +101 -87
  124. package/src/main/lib/scheduler/upgradeDrain.cjs +32 -5
  125. package/src/main/lib/scheduler/usageHoldRoute.cjs +97 -0
  126. package/src/main/lib/scheduler/validatorVerdictSchema.cjs +28 -7
  127. package/src/main/lib/tasks/memoryConsolidation.cjs +123 -39
  128. package/src/main/lib/tasks/mitigationReview.cjs +21 -1
  129. package/src/main/lib/tasks/taskAdminRoutes.cjs +104 -17
  130. package/src/main/lib/tasks/taskLedger.cjs +2 -2
  131. package/src/main/lib/tasks/taskRun.cjs +3 -1
  132. package/src/main/lib/tasks/weeklyConsolidationInputs.cjs +178 -0
  133. package/src/main/lib/telemetry/auditEvents.cjs +21 -24
  134. package/src/main/lib/telemetry/auditLog.cjs +6 -2
  135. package/src/main/lib/util/atomicFs.cjs +2 -2
  136. package/src/main/projectPages.cjs +22 -14
  137. package/src/main/promptSessionEvents.cjs +16 -1
  138. package/src/main/pty.cjs +14 -2
  139. package/src/main/queueOps.cjs +1 -1
  140. package/src/main/runVerify.cjs +4 -3
  141. package/src/main/scheduler/planReviewHold.cjs +140 -0
  142. package/src/main/scheduler/prdParser.cjs +1 -0
  143. package/src/main/scheduler/reviewLadder.cjs +2 -0
  144. package/src/main/scheduler/utilizationHold.cjs +101 -6
  145. package/src/main/scheduler.cjs +1055 -107
  146. package/src/main/seedAgentPersonas.cjs +11 -6
  147. package/src/main/seedStatus.cjs +1 -1
  148. package/src/main/templates/PRD_AUTHORING.md +22 -2
  149. package/src/main/webRemote.cjs +47 -7
  150. package/src/preload/api.d.ts +118 -2
  151. package/src/preload/apiSurface.json +42 -0
  152. package/src/preload/index.cjs +11 -0
  153. package/src/seed/agents/architect.md +28 -43
  154. package/src/seed/agents/demo-video-builder.md +15 -8
  155. package/src/seed/agents/dev-lead.md +3 -1
  156. package/src/seed/agents/md-network-curator.md +27 -0
  157. package/src/seed/agents/plan-reviewer.md +47 -0
  158. package/src/seed/agents/validator.md +21 -19
  159. package/dist/assets/AppSettings-BcZgIvvY.js +0 -2
  160. package/dist/assets/HomeClaudeConfig-D32ZJtU-.js +0 -3
  161. package/dist/assets/ProjectClaudeConfig-BTClYV6i.js +0 -26
  162. package/dist/assets/Scheduler-DPobKx1Z.js +0 -16
@@ -112,16 +112,49 @@ const OWNERS = Object.freeze({
112
112
  });
113
113
 
114
114
  /**
115
- * Machine-local RUNTIME namespaces: regenerable/ephemeral state that must never
116
- * be committed. Mirrors this repo's root .gitignore. Everything else in OWNERS
117
- * (reviews, architecture, project-brief, project-pages, ...) is authored.
118
- * `feedback` has no OWNERS entry (nothing writes it through the gate) but is
119
- * runtime state all the same, so it lives only in this set.
115
+ * namespace -> its git class, one entry per namespace Session Manager defines.
116
+ * - 'runtime': machine-local state, never committed. Each dir self-ignores
117
+ * with its own `*` .gitignore (ensureRuntimeIgnores).
118
+ * - 'tracked': the project's own authored output (Project Home pages and
119
+ * videos, the Brief, docs), committed like docs. Session Manager never
120
+ * writes an ignore file there; a project that wants it out of git adds its
121
+ * own rule.
122
+ * A folder not listed here (feedback/, retired 2026-08-02, or any folder a
123
+ * project made itself) belongs to the project: a project's feedback/ is its
124
+ * own folder, and Session Manager never writes, ignores, bans from commits or
125
+ * untracks it.
120
126
  */
121
- const RUNTIME_NAMESPACES = Object.freeze([
122
- 'scheduler', 'prompt-sessions', 'feedback', 'logs', 'ui-prefs', 'memory-clusters', 'tasks',
123
- 'plan-records', 'events', 'agents', 'webhooks', 'feedback-inbox', 'artifacts',
124
- ]);
127
+ const GIT_CLASS = Object.freeze({
128
+ scheduler: 'runtime',
129
+ 'prompt-sessions': 'runtime',
130
+ logs: 'runtime',
131
+ 'ui-prefs': 'runtime',
132
+ 'memory-clusters': 'runtime',
133
+ tasks: 'runtime',
134
+ 'plan-records': 'runtime',
135
+ events: 'runtime',
136
+ agents: 'runtime',
137
+ webhooks: 'runtime',
138
+ 'feedback-inbox': 'runtime',
139
+ artifacts: 'runtime',
140
+ 'project-brief': 'tracked',
141
+ 'project-pages': 'tracked',
142
+ architecture: 'tracked',
143
+ 'design-mocks': 'tracked',
144
+ HUMAN_LEARN: 'tracked',
145
+ manual: 'tracked',
146
+ reviews: 'tracked',
147
+ });
148
+
149
+ /**
150
+ * Machine-local RUNTIME namespaces, derived from GIT_CLASS. Every consumer
151
+ * (self-ignore sweep, worktree carry, finish-protocol commit ban, health,
152
+ * runtime-state untrack) reads this list. This repo's root .gitignore lists
153
+ * each one too (plus its own retired feedback/ folder, which is not runtime).
154
+ */
155
+ const RUNTIME_NAMESPACES = Object.freeze(
156
+ Object.keys(GIT_CLASS).filter((ns) => GIT_CLASS[ns] === 'runtime'),
157
+ );
125
158
 
126
159
  /** Writer id for the per-namespace self-ignore file. */
127
160
  const RUNTIME_IGNORE_WRITER = 'runtime-ignore';
@@ -133,9 +166,10 @@ const RUNTIME_IGNORE_WRITER = 'runtime-ignore';
133
166
  * code review, not discovered later in a race.
134
167
  */
135
168
  const DELEGATIONS_BASE = {
136
- // Each runtime namespace carries its own `.gitignore` (content `*`) so the
137
- // project's root .gitignore needs no edit. Only that one file, only
138
- // ensureRuntimeIgnores writes it.
169
+ // Each runtime namespace (GIT_CLASS 'runtime', all owned) carries its own
170
+ // `.gitignore` (content `*`) so the project's root .gitignore needs no edit.
171
+ // Only that one file, only ensureRuntimeIgnores writes it. Tracked and
172
+ // project-owned folders get no delegation.
139
173
  ...Object.fromEntries(RUNTIME_NAMESPACES.map((ns) => [ns, []])),
140
174
  'prompt-sessions': Object.freeze([
141
175
  Object.freeze({
@@ -211,6 +245,8 @@ function checkOpsWrite(absPath, writer) {
211
245
 
212
246
  const owner = OWNERS[namespace];
213
247
  if (!owner) {
248
+ // Fail closed: an owner-less folder (a project's own feedback/, say) is
249
+ // the project's, never Session Manager's — no writer, no delegation.
214
250
  return {
215
251
  ok: false,
216
252
  error:
@@ -371,34 +407,83 @@ function opsPath(cwd, ...segments) {
371
407
  }
372
408
 
373
409
  /**
374
- * ensureRuntimeIgnores(projectRoot) → string[] of `.gitignore` paths written.
375
- * For each runtime namespace dir that already exists under the project's ops
376
- * root and has no `.gitignore`, write one containing `*` (which also ignores
377
- * itself). Never creates a namespace dir, never runs git. Idempotent.
410
+ * ensureRuntimeIgnore(projectRoot, ns) → the `.gitignore` path written, or null.
411
+ * When `<projectRoot>/session-manager-operations/<ns>/` is a directory with no
412
+ * `.gitignore` file, write one containing `*` (which also ignores itself).
413
+ * Null when the file already exists or the namespace dir is absent. Throws on
414
+ * a non-runtime `ns`, an ownership refusal, or an IO error (including a
415
+ * non-file sitting at the `.gitignore` path). Never creates the namespace dir.
378
416
  * `projectRoot` must already be resolved (resolveProjectRoot/projectRootOf).
379
417
  */
380
- function ensureRuntimeIgnores(projectRoot) {
418
+ function ensureRuntimeIgnore(projectRoot, ns) {
419
+ if (!RUNTIME_NAMESPACES.includes(ns)) {
420
+ throw new Error(`'${ns}' is not a runtime namespace (RUNTIME_NAMESPACES in lib/opsOwnership.cjs)`);
421
+ }
422
+ const dir = path.join(projectRoot, OPS_ROOT_DIR, ns);
423
+ let isDir = false;
424
+ try { isDir = fs.statSync(dir).isDirectory(); } catch { /* absent */ }
425
+ if (!isDir) return null;
426
+ const file = path.join(dir, '.gitignore');
427
+ let st = null;
428
+ try { st = fs.statSync(file); } catch { /* absent */ }
429
+ if (st && st.isFile()) return null;
430
+ const verdict = checkOpsWrite(file, RUNTIME_IGNORE_WRITER);
431
+ if (!verdict.ok) throw new Error(verdict.error);
381
432
  const { writeTextAtomicSync } = require('./util/atomicFs.cjs');
382
- const opsRoot = path.join(projectRoot, OPS_ROOT_DIR);
433
+ writeTextAtomicSync(file, '*\n');
434
+ return file;
435
+ }
436
+
437
+ /**
438
+ * ensureRuntimeIgnoreForPath(absPath) → the `.gitignore` path written, or null.
439
+ * For a path inside a RUNTIME namespace of an ops root (innermost
440
+ * session-manager-operations segment, same rule as parseOpsPath), create the
441
+ * namespace dir if missing and self-ignore it. Null for a path outside any ops
442
+ * root, in an authored namespace, or that IS the namespace `.gitignore`.
443
+ * Throws on refusal or IO error.
444
+ */
445
+ function ensureRuntimeIgnoreForPath(absPath) {
446
+ if (!absPath || typeof absPath !== 'string') return null;
447
+ const resolved = path.resolve(absPath);
448
+ const segs = resolved.split(path.sep);
449
+ const idx = segs.lastIndexOf(OPS_ROOT_DIR);
450
+ if (idx === -1) return null;
451
+ const ns = segs[idx + 1];
452
+ if (!ns || !RUNTIME_NAMESPACES.includes(ns)) return null;
453
+ const rest = segs.slice(idx + 2).filter(Boolean);
454
+ if (rest.length === 1 && rest[0] === '.gitignore') return null;
455
+ const projectRoot = segs.slice(0, idx).join(path.sep) || path.sep;
456
+ fs.mkdirSync(path.join(projectRoot, OPS_ROOT_DIR, ns), { recursive: true });
457
+ return ensureRuntimeIgnore(projectRoot, ns);
458
+ }
459
+
460
+ /**
461
+ * ensureRuntimeIgnores(projectRoot) → string[] of `.gitignore` paths written.
462
+ * ensureRuntimeIgnore for every runtime namespace, each isolated: one
463
+ * namespace's failure never stops the others. After the loop, throws one
464
+ * Error naming every failed namespace and its reason. Idempotent.
465
+ */
466
+ function ensureRuntimeIgnores(projectRoot) {
383
467
  const written = [];
468
+ const failures = [];
384
469
  for (const ns of RUNTIME_NAMESPACES) {
385
- const dir = path.join(opsRoot, ns);
386
- let isDir = false;
387
- try { isDir = fs.statSync(dir).isDirectory(); } catch { /* absent */ }
388
- if (!isDir) continue;
389
- const file = path.join(dir, '.gitignore');
390
- if (fs.existsSync(file)) continue;
391
- const verdict = checkOpsWrite(file, RUNTIME_IGNORE_WRITER);
392
- if (!verdict.ok) throw new Error(verdict.error);
393
- writeTextAtomicSync(file, '*\n');
394
- written.push(file);
470
+ try {
471
+ const file = ensureRuntimeIgnore(projectRoot, ns);
472
+ if (file) written.push(file);
473
+ } catch (e) {
474
+ failures.push(`${ns}: ${(e && e.message) || String(e)}`);
475
+ }
395
476
  }
477
+ if (failures.length) throw new Error(`runtime self-ignore failed: ${failures.join('; ')}`);
396
478
  return written;
397
479
  }
398
480
 
399
481
  module.exports = {
482
+ GIT_CLASS,
400
483
  RUNTIME_NAMESPACES,
401
484
  RUNTIME_IGNORE_WRITER,
485
+ ensureRuntimeIgnore,
486
+ ensureRuntimeIgnoreForPath,
402
487
  ensureRuntimeIgnores,
403
488
  OPS_ROOT_DIR,
404
489
  OWNERS,
@@ -11,6 +11,7 @@
11
11
  * a malformed pack becomes an `{ dir, error }` entry, never a crash. No caching.
12
12
  */
13
13
  const fs = require('fs');
14
+ const os = require('os');
14
15
  const path = require('path');
15
16
  const { z } = require('zod');
16
17
 
@@ -28,7 +29,8 @@ const PackManifestSchema = z.object({
28
29
  /**
29
30
  * @typedef {{ platform?: 'darwin'|'linux'|'win32' }} PackRequires
30
31
  * @typedef {{ id: string, label: string, description: string, dir: string,
31
- * pluginName: string, laws: string, requires: PackRequires }} Pack
32
+ * pluginName: string, laws: string, requires: PackRequires, source: 'shipped'|'plugin',
33
+ * skills: string[] }} Pack
32
34
  * @typedef {{ dir: string, error: string }} PackError
33
35
  */
34
36
 
@@ -75,15 +77,106 @@ function readPack(dir) {
75
77
  pluginName,
76
78
  laws,
77
79
  requires: m.requires ? { ...m.requires } : {},
80
+ source: 'shipped',
81
+ skills: listSkillsIn(path.join(dir, 'skills'), pluginName),
78
82
  };
79
83
  }
80
84
 
85
+ /** Folder names under `skillsDir` holding a SKILL.md; prefixed `<prefix>:` when given. Never throws.
86
+ * @param {string} skillsDir @param {string} [prefix] @returns {string[]} */
87
+ function listSkillsIn(skillsDir, prefix) {
88
+ try {
89
+ return fs.readdirSync(skillsDir, { withFileTypes: true })
90
+ .filter((e) => (e.isDirectory() || e.isSymbolicLink()) && fs.existsSync(path.join(skillsDir, e.name, 'SKILL.md')))
91
+ .map((e) => (prefix ? `${prefix}:${e.name}` : e.name))
92
+ .sort();
93
+ } catch { return []; }
94
+ }
95
+
96
+ /** Loose ~/.claude/skills folders: visible but not equippable (not in a pack).
97
+ * @param {{ home?: string }} [opts] @returns {string[]} */
98
+ function listUnpackedSkills({ home = os.homedir() } = {}) {
99
+ return listSkillsIn(path.join(home, '.claude', 'skills'));
100
+ }
101
+
102
+ /** @param {string} dir @param {string} id @returns {Pack} */
103
+ function readPluginPack(dir, id) {
104
+ const plugin = readJson(path.join(dir, '.claude-plugin', 'plugin.json'), '.claude-plugin/plugin.json');
105
+ if (!plugin || typeof plugin !== 'object' || Array.isArray(plugin)) throw new Error('.claude-plugin/plugin.json must be an object');
106
+ const pluginName = typeof plugin.name === 'string' && plugin.name ? plugin.name : id;
107
+ return {
108
+ id,
109
+ label: id,
110
+ description: typeof plugin.description === 'string' ? plugin.description : '',
111
+ dir,
112
+ pluginName,
113
+ laws: '',
114
+ requires: {},
115
+ source: 'plugin',
116
+ skills: listSkillsIn(path.join(dir, 'skills'), pluginName),
117
+ };
118
+ }
119
+
120
+ /** Installed Claude Code plugins from installed_plugins.json. Never throws.
121
+ * @param {string} file @returns {{ packs: Pack[], errors: PackError[] }} */
122
+ function listPluginPacks(file) {
123
+ /** @type {Pack[]} */ const packs = [];
124
+ /** @type {PackError[]} */ const errors = [];
125
+ let raw;
126
+ try { raw = fs.readFileSync(file, 'utf8'); } catch (e) {
127
+ if (/** @type {NodeJS.ErrnoException} */ (e).code !== 'ENOENT') errors.push({ dir: file, error: `cannot read installed_plugins.json: ${/** @type {Error} */ (e).message}` });
128
+ return { packs, errors };
129
+ }
130
+ let data;
131
+ try { data = JSON.parse(raw); } catch (e) {
132
+ errors.push({ dir: file, error: `installed_plugins.json is not valid JSON: ${/** @type {Error} */ (e).message}` });
133
+ return { packs, errors };
134
+ }
135
+ const plugins = data && typeof data === 'object' ? data.plugins : null;
136
+ if (!plugins || typeof plugins !== 'object' || Array.isArray(plugins)) {
137
+ errors.push({ dir: file, error: 'installed_plugins.json has no plugins object' });
138
+ return { packs, errors };
139
+ }
140
+ for (const [key, installs] of Object.entries(plugins)) {
141
+ const id = key.split('@')[0];
142
+ const list = Array.isArray(installs) ? installs : [];
143
+ const last = list[list.length - 1];
144
+ const installPath = last && typeof last.installPath === 'string' ? last.installPath : '';
145
+ if (!installPath) { errors.push({ dir: file, error: `plugin "${key}" has no installPath` }); continue; }
146
+ try {
147
+ if (!fs.statSync(installPath).isDirectory()) throw new Error('not a directory');
148
+ } catch { errors.push({ dir: installPath, error: `plugin "${key}" installPath is missing` }); continue; }
149
+ try { packs.push(readPluginPack(installPath, id)); } catch (e) {
150
+ errors.push({ dir: installPath, error: String((e && /** @type {Error} */ (e).message) || e) });
151
+ }
152
+ }
153
+ return { packs, errors };
154
+ }
155
+
81
156
  /**
82
157
  * List every pack under `packsDir`. Never throws.
83
- * @param {{ packsDir?: string }} [opts]
158
+ * Installed plugins are added unless `packsDir` is given without `home`/`pluginsFile`
159
+ * (a fixture-only call must not read the real ~/.claude).
160
+ * @param {{ packsDir?: string, home?: string, pluginsFile?: string }} [opts]
84
161
  * @returns {{ packs: Pack[], errors: PackError[] }}
85
162
  */
86
- function listPacks({ packsDir = bundledPacksDir() } = {}) {
163
+ function listPacks({ packsDir, home, pluginsFile } = {}) {
164
+ const withPlugins = packsDir === undefined || home !== undefined || pluginsFile !== undefined;
165
+ const r = listShipped(packsDir === undefined ? bundledPacksDir() : packsDir);
166
+ if (!withPlugins) return r;
167
+ const file = pluginsFile || path.join(home || os.homedir(), '.claude', 'plugins', 'installed_plugins.json');
168
+ const pl = listPluginPacks(file);
169
+ for (const p of pl.packs) {
170
+ if (r.packs.some((x) => x.id === p.id)) r.errors.push({ dir: p.dir, error: `plugin id "${p.id}" collides with a shipped pack; shipped pack kept` });
171
+ else r.packs.push(p);
172
+ }
173
+ r.errors.push(...pl.errors);
174
+ r.packs.sort((a, b) => (a.id < b.id ? -1 : a.id > b.id ? 1 : 0));
175
+ return r;
176
+ }
177
+
178
+ /** @param {string} packsDir @returns {{ packs: Pack[], errors: PackError[] }} */
179
+ function listShipped(packsDir) {
87
180
  /** @type {Pack[]} */ const packs = [];
88
181
  /** @type {PackError[]} */ const errors = [];
89
182
  const root = path.resolve(packsDir);
@@ -110,11 +203,11 @@ function listPacks({ packsDir = bundledPacksDir() } = {}) {
110
203
 
111
204
  /**
112
205
  * @param {string} id
113
- * @param {{ packsDir?: string }} [opts]
206
+ * @param {{ packsDir?: string, home?: string, pluginsFile?: string }} [opts]
114
207
  * @returns {Pack|null}
115
208
  */
116
209
  function getPack(id, opts) {
117
210
  return listPacks(opts).packs.find((p) => p.id === id) || null;
118
211
  }
119
212
 
120
- module.exports = { listPacks, getPack, bundledPacksDir, PACK_LAWS_CHAR_CAP };
213
+ module.exports = { listPacks, listUnpackedSkills, getPack, bundledPacksDir, PACK_LAWS_CHAR_CAP };
@@ -97,6 +97,12 @@ const AgentPersonaSaveSchema = z.object({
97
97
  agentCli: z.enum(/** @type {[string, ...string[]]} */ ([...AGENT_CLI_IDS])).optional(),
98
98
  // Model handed to that CLI; same rule as epicMint.
99
99
  agentCliModel: z.string().regex(AGENT_CLI_MODEL_RE).optional(),
100
+ // Gear (global save): declared MCP servers / context packs / environment profile, and the
101
+ // loadout decision that encodes `tools:`. An explicit [] means "none" (written as `[]`).
102
+ mcpServers: z.array(z.string().trim().min(1).max(200)).max(64).optional(),
103
+ packs: z.array(z.string().trim().min(1).max(200)).max(64).optional(),
104
+ environment: z.string().trim().regex(/^[a-z0-9][a-z0-9-]*$/, 'environment must be a lowercase, hyphenated profile name').optional(),
105
+ loadout: z.enum(['bare', 'unbound', 'equipped']).optional(),
100
106
  // Unbounded — a persona's body is arbitrary system-prompt prose.
101
107
  body: z.string(),
102
108
  }).strict().superRefine((p, ctx) => {
@@ -82,21 +82,23 @@ const BUILTIN_MACROS = Object.freeze([
82
82
  tag: 'discussion',
83
83
  surface: 'project-home',
84
84
  projects: ['*'],
85
- builtinVersion: 1,
85
+ builtinVersion: 2,
86
86
  inputs: Object.freeze([
87
87
  Object.freeze({ name: 'scope', label: 'Scope', default: 'the whole project', required: true }),
88
88
  Object.freeze({
89
89
  name: 'mode',
90
90
  label: 'Mode',
91
- options: Object.freeze(['Full review', 'Drift check']),
91
+ options: Object.freeze(['Full review', 'Drift check', 'Weekly consolidation']),
92
92
  default: 'Full review',
93
93
  required: true,
94
94
  }),
95
95
  ]),
96
96
  supersedes: Object.freeze(['review-md-network-d38ffd']),
97
- priorPrompts: Object.freeze([]),
98
- prompt:
97
+ priorPrompts: Object.freeze([
99
98
  "Use the session-manager-dev:maintaining-md-network skill to review this project's markdown network. Scope: {{scope}}. Mode: {{mode}}.",
99
+ ]),
100
+ prompt:
101
+ "Use the session-manager-dev:maintaining-md-network skill to review this project's markdown network. Scope: {{scope}}. Mode: {{mode}}. Modes: Full review, Drift check, Weekly consolidation.",
100
102
  }),
101
103
  Object.freeze({
102
104
  id: 'builtin-competitor-matrix',
@@ -24,6 +24,7 @@
24
24
 
25
25
  const { z } = require('zod');
26
26
  const { MANAGED_PERSONA_KEYS } = require('../../agentLibrary.cjs');
27
+ const { UNBOUND_TOOL } = require('./personaLoadout.cjs');
27
28
 
28
29
  // Parsed frontmatter values are strings; structured callers may pass
29
30
  // numbers (seedVersion), booleans (executorOnly) or string lists (tools/tags).
@@ -61,6 +62,14 @@ shape.environment = z
61
62
  // reads it at dispatch, so a dispatch-time validation must admit it.
62
63
  shape.defaultEstimateMinutes = FmValue.optional();
63
64
 
65
+ // Loadout encodings (personaLoadout.cjs): `[]` / an empty line = Bare, `*` = Unbound;
66
+ // `*` stands alone — mixed with other tools the decision is ambiguous.
67
+ shape.tools = FmValue.optional().refine((v) => {
68
+ const names = (Array.isArray(v) ? v : typeof v === 'string' ? v.split(',') : []).map((t) => String(t).trim()).filter(Boolean);
69
+ if (names.length < 2) return true;
70
+ return !names.some((t) => t === UNBOUND_TOOL);
71
+ }, 'tools: "*" (Unbound) must stand alone, not be mixed with other tools');
72
+
64
73
  const PersonaFrontmatterSchema = z.object(shape).strict();
65
74
 
66
75
  /**
@@ -0,0 +1,58 @@
1
+ 'use strict';
2
+
3
+ /**
4
+ * personaLoadout.cjs — the four loadout states of an agent's `tools:` decision
5
+ * and their one on-disk encoding, read the same way by Session Manager and
6
+ * Claude Code's own subagent loader.
7
+ *
8
+ * Verified offline against the CLI 2.1.330 binary (agent parse: `Ygt(r.tools)`
9
+ * over `Cdn`): key absent = all tools; `tools:` (null), `""` or `[]` = ZERO
10
+ * tools; any `*` = all tools.
11
+ *
12
+ * undecided `tools` key absent. Runs as today (all tools); reports Undecided.
13
+ * bare `tools: []` — zero granted tools beyond the headless floor.
14
+ * An empty `tools:` line and `""` mean the same to the loader.
15
+ * equipped `tools: A, B, C` — exactly those tools.
16
+ * unbound `tools: *` — every tool, an explicit decision.
17
+ *
18
+ * SM's frontmatter parser has no flow arrays: `tools: []` arrives as "[]".
19
+ */
20
+
21
+ const BARE_ENCODING = '[]';
22
+ const UNBOUND_TOOL = '*';
23
+
24
+ /** @param {unknown} raw frontmatter `tools` (comma string or string list) */
25
+ function toolNames(raw) {
26
+ const items = Array.isArray(raw) ? raw : typeof raw === 'string' ? raw.split(',') : [];
27
+ return items.filter((t) => typeof t === 'string').map((t) => t.trim()).filter(Boolean).filter((t) => t !== BARE_ENCODING);
28
+ }
29
+
30
+ /**
31
+ * @param {{ tools?: unknown }|null|undefined} fm parsed frontmatter
32
+ * @returns {'undecided'|'bare'|'equipped'|'unbound'}
33
+ */
34
+ function loadoutState(fm) {
35
+ if (!fm || fm.tools === undefined || !('tools' in fm)) return 'undecided';
36
+ const names = toolNames(fm.tools);
37
+ if (names.includes(UNBOUND_TOOL)) return 'unbound';
38
+ return names.length === 0 ? 'bare' : 'equipped';
39
+ }
40
+
41
+ /**
42
+ * The `tools:` value to write, or null for no line (undecided, or equipped
43
+ * with no tools).
44
+ * @param {'undecided'|'bare'|'equipped'|'unbound'} state
45
+ * @param {readonly string[]|null|undefined} tools
46
+ * @returns {string|null}
47
+ */
48
+ function encodeLoadout(state, tools) {
49
+ if (state === 'bare') return BARE_ENCODING;
50
+ if (state === 'unbound') return UNBOUND_TOOL;
51
+ if (state === 'equipped') {
52
+ const names = toolNames(tools).filter((t) => t !== UNBOUND_TOOL);
53
+ return names.length ? names.join(', ') : null;
54
+ }
55
+ return null;
56
+ }
57
+
58
+ module.exports = { BARE_ENCODING, UNBOUND_TOOL, loadoutState, encodeLoadout };
@@ -11,6 +11,12 @@
11
11
  * MERGE RULES
12
12
  * - Frontmatter: overlay keys override the global's; a key absent from the
13
13
  * overlay (or present with an empty value) falls back to the global.
14
+ * - Gear keys (`tools`, `mcpServers`, `packs`, `environment`) REPLACE the
15
+ * global value wholesale — never a union (a Bare `tools: []` overlay wins;
16
+ * likewise `mcpServers: []` / `packs: []` = replace with none, a non-empty
17
+ * value that survives the empty-value skip below;
18
+ * over the global's tools); absent keys inherit. `loadout` on the result is
19
+ * computed from the MERGED `tools`.
14
20
  * - Body: an overlay with a non-empty body replaces the global body wholesale
15
21
  * (the pre-merge behavior); a frontmatter-only overlay (`body.trim() === ''`)
16
22
  * inherits the global body.
@@ -36,6 +42,7 @@ const fs = require('node:fs');
36
42
  const { splitFrontmatter } = require('../prd/prdFrontmatter.cjs');
37
43
  const { resolvePersonaPaths } = require('../epic/epicMint.cjs');
38
44
  const configMgr = require('../../config.cjs');
45
+ const { loadoutState } = require('./personaLoadout.cjs');
39
46
 
40
47
  /** Filename-safe persona name: lowercase, hyphenated, matches the `.md` files on disk. */
41
48
  const PERSONA_NAME_RE = /^[a-z][a-z0-9-]*$/;
@@ -93,7 +100,7 @@ function serializeMerged(fm, body) {
93
100
  * @returns {null | {
94
101
  * fm: Record<string,string>, body: string, text: string, path: string,
95
102
  * overlayPath: string|null, globalPath: string|null,
96
- * fromOverlay: boolean, bodySource: 'overlay'|'global',
103
+ * loadout: 'undecided'|'bare'|'equipped'|'unbound', fromOverlay: boolean, bodySource: 'overlay'|'global',
97
104
  * provenance: Record<string,'overlay'|'global'>, overlayIssue: string|null,
98
105
  * }}
99
106
  * `path` is the file the BODY came from; `text` is that file's raw text when
@@ -128,11 +135,11 @@ function resolveMergedPersona(cwd, agentType, deps = {}) {
128
135
  if (!overlay && !global) return null;
129
136
  if (!overlay) {
130
137
  const provenance = Object.fromEntries(Object.keys(global.fm).map((k) => [k, 'global']));
131
- return { ...base, fm: global.fm, body: global.body, text: global.text, path: global.path, fromOverlay: false, bodySource: 'global', provenance };
138
+ return { ...base, fm: global.fm, body: global.body, text: global.text, path: global.path, loadout: loadoutState(global.fm), fromOverlay: false, bodySource: 'global', provenance };
132
139
  }
133
140
  if (!global) {
134
141
  const provenance = Object.fromEntries(Object.keys(overlay.fm).map((k) => [k, 'overlay']));
135
- return { ...base, fm: overlay.fm, body: overlay.body, text: overlay.text, path: overlay.path, fromOverlay: true, bodySource: 'overlay', provenance };
142
+ return { ...base, fm: overlay.fm, body: overlay.body, text: overlay.text, path: overlay.path, loadout: loadoutState(overlay.fm), fromOverlay: true, bodySource: 'overlay', provenance };
136
143
  }
137
144
 
138
145
  const fm = { ...global.fm };
@@ -154,6 +161,7 @@ function resolveMergedPersona(cwd, agentType, deps = {}) {
154
161
  body,
155
162
  text,
156
163
  path: overlayHasBody ? overlay.path : global.path,
164
+ loadout: loadoutState(fm),
157
165
  fromOverlay: true,
158
166
  bodySource,
159
167
  provenance,
@@ -0,0 +1,96 @@
1
+ 'use strict';
2
+ /**
3
+ * The one place that decides whether an installed bundled persona is behind the bundled
4
+ * seedVersion, and performs the two user actions: take the bundled version (backup first,
5
+ * user frontmatter edits kept) or keep mine (dismissed until the next seedVersion bump).
6
+ * Boot upgrade pass: ../../seedAgentPersonas.cjs.
7
+ */
8
+ const fs = require('node:fs');
9
+ const path = require('node:path');
10
+ const {
11
+ PERSONAS, readSeedVersion, personaBodyHash, normalizeNewlines, buildUpgradedPersona,
12
+ backupPathFor, bundledSourceDir, destAgentsDir,
13
+ } = require('../../seedAgentPersonas.cjs');
14
+ const { schedulerHome } = require('../scheduler/schedulerPaths.cjs');
15
+ const { SHIPPED_PERSONA_SEEDS } = require('./shippedPersonaSeeds.cjs');
16
+ const { splitFrontmatter } = require('../prd/prdFrontmatter.cjs');
17
+ const { writeTextAtomic, validatePath, validateWrite } = require('../../config.cjs');
18
+
19
+ function dismissalsPath() {
20
+ return path.join(schedulerHome(), 'persona-upgrade-dismissals.json');
21
+ }
22
+
23
+ /** { [name]: bundledVersion } — {} for a missing or malformed file; invalid values dropped. */
24
+ function readDismissals() {
25
+ try {
26
+ const raw = JSON.parse(fs.readFileSync(dismissalsPath(), 'utf8'));
27
+ if (!raw || typeof raw !== 'object' || Array.isArray(raw)) return {};
28
+ const out = {};
29
+ for (const [k, v] of Object.entries(raw)) if (Number.isInteger(v) && v >= 1) out[k] = v;
30
+ return out;
31
+ } catch {
32
+ return {};
33
+ }
34
+ }
35
+
36
+ /** Status for an installed persona that is behind its bundled version, else null. Never throws. */
37
+ function personaUpgradeFor(name, installedText, { shippedSeeds = SHIPPED_PERSONA_SEEDS, srcDir = bundledSourceDir(), dismissals = readDismissals() } = {}) {
38
+ try {
39
+ if (!PERSONAS.includes(name)) return null;
40
+ const bundledText = fs.readFileSync(path.join(srcDir, `${name}.md`), 'utf8');
41
+ const installedVersion = readSeedVersion(installedText);
42
+ const bundledVersion = readSeedVersion(bundledText);
43
+ if (installedVersion >= bundledVersion) return null;
44
+ if ((dismissals[name] ?? 0) >= bundledVersion) return null;
45
+ const hash = personaBodyHash(installedText);
46
+ const edited = !(shippedSeeds[name] ?? []).some((e) => e.bodySha256 === hash);
47
+ const bundledBody = splitFrontmatter(normalizeNewlines(bundledText)).body.trim();
48
+ return { installedVersion, bundledVersion, edited, bundledBody };
49
+ } catch {
50
+ return null;
51
+ }
52
+ }
53
+
54
+ /** Keep mine: remember that `name` was dismissed at `bundledVersion`. */
55
+ async function dismissPersonaUpgrade(name, bundledVersion) {
56
+ if (!PERSONAS.includes(name)) throw new Error(`not a bundled persona: ${name}`);
57
+ if (!Number.isInteger(bundledVersion) || bundledVersion < 1) throw new Error('bundledVersion must be an integer >= 1');
58
+ const file = dismissalsPath();
59
+ fs.mkdirSync(path.dirname(file), { recursive: true });
60
+ await writeTextAtomic(file, JSON.stringify({ ...readDismissals(), [name]: bundledVersion }, null, 2));
61
+ return { ok: true };
62
+ }
63
+
64
+ /** Take the bundled version: back up the installed file, keep the user's changed frontmatter lines. */
65
+ async function takeBundledPersona(name, { shippedSeeds = SHIPPED_PERSONA_SEEDS, srcDir = bundledSourceDir(), destDir = destAgentsDir() } = {}) {
66
+ if (!PERSONAS.includes(name)) throw new Error(`not a bundled persona: ${name}`);
67
+ const destPath = path.join(destDir, `${name}.md`);
68
+ if (!fs.existsSync(destPath)) throw new Error(`${name}.md is not installed`);
69
+ const installedBytes = fs.readFileSync(destPath);
70
+ const installedText = installedBytes.toString('utf8');
71
+ const bundledText = fs.readFileSync(path.join(srcDir, `${name}.md`), 'utf8');
72
+ const seedVersion = readSeedVersion(bundledText);
73
+ if (readSeedVersion(installedText) >= seedVersion) throw new Error(`${name}.md is not behind the bundled version`);
74
+
75
+ validateWrite(validatePath(destPath)); // before any write, so a doomed write leaves no orphan backup
76
+
77
+ const backupPath = backupPathFor(name, installedBytes);
78
+ if (!fs.existsSync(backupPath)) {
79
+ fs.mkdirSync(path.dirname(backupPath), { recursive: true });
80
+ await writeTextAtomic(backupPath, installedBytes);
81
+ }
82
+
83
+ const { fm } = splitFrontmatter(normalizeNewlines(bundledText));
84
+ const { name: _n, seedVersion: _s, ...bundledFm } = fm;
85
+ const baseline = [...(shippedSeeds[name] ?? []), { fm: bundledFm }];
86
+ await writeTextAtomic(destPath, buildUpgradedPersona(bundledText, installedText, baseline));
87
+
88
+ const dismissals = readDismissals();
89
+ if (name in dismissals) {
90
+ delete dismissals[name];
91
+ await writeTextAtomic(dismissalsPath(), JSON.stringify(dismissals, null, 2));
92
+ }
93
+ return { backupPath, seedVersion };
94
+ }
95
+
96
+ module.exports = { personaUpgradeFor, readDismissals, dismissPersonaUpgrade, takeBundledPersona };
@@ -75,7 +75,7 @@ async function checkProjectVideoToolRunnable({ cwd, agentName, job } = /** @type
75
75
  return { ok: false, error: `${PERSONA_PREFIX} persona '${agentName}' could not be read.` };
76
76
  }
77
77
 
78
- const scope = buildPersonaToolScope(persona.tools);
78
+ const scope = buildPersonaToolScope(persona.tools, { loadout: persona.loadout });
79
79
  if (!scope) return { ok: true };
80
80
 
81
81
  const names = mcpToolNamesFromScope(scope);