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
@@ -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);
@@ -99,6 +99,34 @@ const SHIPPED_PERSONA_SEEDS = deepFreeze({
99
99
  tools: "Read, Grep, Glob, Bash, Edit, Write",
100
100
  },
101
101
  },
102
+ {
103
+ commit: "seed-v7-two-lanes",
104
+ bodySha256: "468d365253a94fb7c48ff181a90c1bea133743748a93290dc0f781dcd49fa6c8",
105
+ fm: {
106
+ description: "The primary Actor for an Epic's whole interactive conversation — owns overall plan and decomposition, clarifies scope, searches before building, does operations and small provable tweaks itself, queues substantial work as scheduled PRDs via /develop, tracks them to completion, and verifies before calling anything done. Never implements a queued PRD — that's dev-lead's job, one PRD at a time, headless. Task-type framing is the Epic's Mission tag's job, not this persona's.",
107
+ model: "opus",
108
+ effort: "medium",
109
+ environment: "open-web",
110
+ tags: "feature, bug, discussion, art",
111
+ title: "Engineering — Architect",
112
+ tools: "Read, Grep, Glob, Bash, Edit, Write, WebFetch, WebSearch, Task",
113
+ },
114
+ },
115
+ {
116
+ commit: "seed-v8",
117
+ bodySha256: "468d365253a94fb7c48ff181a90c1bea133743748a93290dc0f781dcd49fa6c8",
118
+ fm: {
119
+ description: "The primary Actor for an Epic's whole interactive conversation — owns overall plan and decomposition, clarifies scope, searches before building, does operations and small provable tweaks itself, queues substantial work as scheduled PRDs via /develop, tracks them to completion, and verifies before calling anything done. Never implements a queued PRD — that's dev-lead's job, one PRD at a time, headless. Task-type framing is the Epic's Mission tag's job, not this persona's.",
120
+ tools: "Read, Grep, Glob, Bash, Edit, Write, WebFetch, WebSearch, Task",
121
+ model: "opus",
122
+ effort: "medium",
123
+ environment: "open-web",
124
+ tags: "feature, bug, discussion, art",
125
+ title: "Engineering — Architect",
126
+ mcpServers: "session-manager-scheduler",
127
+ packs: "session-manager-dev",
128
+ },
129
+ },
102
130
  ],
103
131
  "dev-lead": [
104
132
  {
@@ -231,6 +259,32 @@ const SHIPPED_PERSONA_SEEDS = deepFreeze({
231
259
  tools: "Read, Grep, Glob, Bash, Edit, Write",
232
260
  },
233
261
  },
262
+ {
263
+ commit: "seed-v9",
264
+ bodySha256: "ca65b05026e3d9f603c5a6efeb0d456686d4413089080ad7596cb9f051162646",
265
+ fm: {
266
+ description: "Executes exactly one already-scoped PRD at a time, headless, start to finish — reads the PRD's Goal/Acceptance Criteria/Implementation notes and standards.md, implements it, verifies against its own AC, and reports. Has no visibility into the overall plan — that's architect's job. This is the default persona a scheduled PRD runs as: the scheduler resolves a PRD's `agentType` frontmatter field (default `dev-lead`) to this file and launches the headless executor AS this persona via `--append-system-prompt`.",
267
+ tools: "Read, Grep, Glob, Bash, Edit, Write",
268
+ model: "sonnet",
269
+ effort: "medium",
270
+ title: "Engineering — Software Engineer",
271
+ packs: "session-manager-dev",
272
+ executorOnly: "true",
273
+ },
274
+ },
275
+ {
276
+ commit: "seed-v10",
277
+ bodySha256: "8a3753ff3a737f2b9b6611c007240e0e6fffc34667fec8efbd266dee535a11e6",
278
+ fm: {
279
+ description: "Executes exactly one already-scoped PRD at a time, headless, start to finish — reads the PRD's Goal/Acceptance Criteria/Implementation notes and standards.md, implements it, verifies against its own AC, and reports. Has no visibility into the overall plan — that's architect's job. This is the default persona a scheduled PRD runs as: the scheduler resolves a PRD's `agentType` frontmatter field (default `dev-lead`) to this file and launches the headless executor AS this persona via `--append-system-prompt`.",
280
+ tools: "Read, Grep, Glob, Bash, Edit, Write",
281
+ model: "sonnet",
282
+ effort: "medium",
283
+ title: "Engineering — Software Engineer",
284
+ packs: "session-manager-dev",
285
+ executorOnly: "true",
286
+ },
287
+ },
234
288
  ],
235
289
  "project-home-builder": [
236
290
  // Not from src/seed git history: this body was written to ~/.claude/agents by this repo's own
@@ -514,6 +568,17 @@ const SHIPPED_PERSONA_SEEDS = deepFreeze({
514
568
  tools: "Read, Grep, Glob, Bash",
515
569
  },
516
570
  },
571
+ {
572
+ commit: "seed-v15",
573
+ bodySha256: "9b0c82b66ae9f681d7784e06cdbd52275902cbbf0c293c5560961e4cf3a56510",
574
+ fm: {
575
+ description: "Validates a finished PLAN (the PRDs its validate PRD lists) once, after its last PRD lands — re-runs each PRD's gate, checks every acceptance criterion against the real tree, reviews the plan's combined diff, and reports one VERIFIED/REFUTED verdict per PRD as checked JSON (the CLI enforces the schema). Runs headless as a scheduled PRD (agentType: validator); never edits product code and never queues work.",
576
+ tools: "Read, Grep, Glob, Bash",
577
+ model: "sonnet",
578
+ title: "Engineering — Plan Validator",
579
+ executorOnly: "true",
580
+ },
581
+ },
517
582
  ],
518
583
  "demo-video-builder": [
519
584
  {
@@ -929,6 +994,35 @@ const SHIPPED_PERSONA_SEEDS = deepFreeze({
929
994
  },
930
995
  },
931
996
  ],
997
+ "plan-reviewer": [
998
+ {
999
+ commit: "seed-v1",
1000
+ bodySha256: "267ccfbbe5767ac2673bdf412c35444677145f9ec7f71d2accfd550d1051e412",
1001
+ fm: {
1002
+ description: "Reviews a queued plan's PRD text BEFORE dispatch — runs a fixed checklist over every PRD, optionally runs each gate read-only at the plan's base commit, and returns checked JSON per PRD (ok / amend / block with concrete suggested edits) plus plan-level findings. Never edits PRDs or code and never queues work.",
1003
+ tools: "Read, Grep, Glob, Bash",
1004
+ model: "sonnet",
1005
+ effort: "high",
1006
+ title: "Engineering — Plan Reviewer",
1007
+ executorOnly: "true",
1008
+ },
1009
+ },
1010
+ ],
1011
+ "md-network-curator": [
1012
+ {
1013
+ commit: "seed-v1",
1014
+ bodySha256: "04d9ad2c67c7ba55c68661b02883a2a9496a0582571c844022c3f3d3ae53ea41",
1015
+ fm: {
1016
+ description: "Out-of-band weekly curator of a project's markdown network and memory. Runs the maintaining-md-network Weekly consolidation pass headless and read-only, fans out one subagent per transcript batch, and answers with a record of proposed changes. Only proposes; never edits, deletes or queues.",
1017
+ tools: "Read, Grep, Glob, Agent",
1018
+ model: "fable",
1019
+ effort: "max",
1020
+ title: "Engineering — MD Network Curator",
1021
+ packs: "session-manager-dev",
1022
+ executorOnly: "true",
1023
+ },
1024
+ },
1025
+ ],
932
1026
  });
933
1027
 
934
1028
  module.exports = { SHIPPED_PERSONA_SEEDS };