claude-code-session-manager 0.143.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 (119) hide show
  1. package/README.md +3 -1
  2. package/dist/assets/AppSettings-Z68gQiVE.js +2 -0
  3. package/dist/assets/{History-DTttbvPb.js → History-C3E6y_7t.js} +2 -2
  4. package/dist/assets/HomeClaudeConfig-Yd1vXzBn.js +5 -0
  5. package/dist/assets/{Panel-B_D4Bg7L.js → Panel-CnfWs46Z.js} +1 -1
  6. package/dist/assets/ProjectClaudeConfig-CP0Wsg-H.js +26 -0
  7. package/dist/assets/Scheduler-D8un7N3B.js +16 -0
  8. package/dist/assets/{SkillReferenceGraph-D1b2aiol.js → SkillReferenceGraph-DRtZV1Al.js} +1 -1
  9. package/dist/assets/{Skills-cfV7sgk6.js → Skills-Bg5O2Hyn.js} +23 -23
  10. package/dist/assets/{TiptapBody-DVXtEIVy.js → TiptapBody-BdzoBmqu.js} +27 -27
  11. package/dist/assets/{Toggle-CYajnSdx.js → Toggle-Dt5K1OXt.js} +1 -1
  12. package/dist/assets/{VoiceButton-DJ4gGRuE.js → VoiceButton-CTLyRgdF.js} +1 -1
  13. package/dist/assets/{historyTotals-D3MoHY2U.js → historyTotals-B2_KWBga.js} +1 -1
  14. package/dist/assets/{index-CdTppjKR.js → index-446b69rr.js} +698 -697
  15. package/dist/assets/{index-DVHIHoJf.css → index-BJ5TJvmz.css} +1 -1
  16. package/dist/index.html +2 -2
  17. package/dist-web/app.css +1 -1
  18. package/dist-web/app.js +439 -436
  19. package/package.json +4 -2
  20. package/plugins/session-manager-dev/skills/develop/SKILL.md +14 -13
  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 +87 -0
  23. package/scripts/README.md +1 -1
  24. package/scripts/scheduler-mcp-server.cjs +77 -0
  25. package/src/main/adminRouteRegistry.cjs +6 -0
  26. package/src/main/agentLibrary.cjs +60 -11
  27. package/src/main/agentsIpc.cjs +19 -0
  28. package/src/main/build-info.json +4 -4
  29. package/src/main/chatRunner.cjs +109 -0
  30. package/src/main/health.cjs +59 -17
  31. package/src/main/index.cjs +4 -0
  32. package/src/main/ipcSchemas.cjs +50 -1
  33. package/src/main/lib/claude/agentArmory.cjs +128 -0
  34. package/src/main/lib/claude/agentModelResolve.cjs +3 -2
  35. package/src/main/lib/claude/agentSnapshot.cjs +24 -3
  36. package/src/main/lib/claude/builtinTools.cjs +110 -0
  37. package/src/main/lib/claude/environmentProfiles.cjs +1 -1
  38. package/src/main/lib/claude/headlessMcpServers.cjs +138 -0
  39. package/src/main/lib/claude/jobSandboxPolicy.cjs +8 -2
  40. package/src/main/lib/claude/personaToolScope.cjs +77 -6
  41. package/src/main/lib/epic/epicDepsSync.cjs +66 -0
  42. package/src/main/lib/epic/epicOutsideRead.cjs +38 -1
  43. package/src/main/lib/epic/epicSettle.cjs +48 -4
  44. package/src/main/lib/epic/epicSpawnPlan.cjs +3 -1
  45. package/src/main/lib/epic/epicValidationHook.cjs +9 -1
  46. package/src/main/lib/epic/planReviewInput.cjs +123 -0
  47. package/src/main/lib/epic/restorableSessions.cjs +1 -0
  48. package/src/main/lib/epic/scriptStartedBy.cjs +71 -0
  49. package/src/main/lib/externalContract.cjs +12 -0
  50. package/src/main/lib/feedback-remote/createdProjects.cjs +291 -0
  51. package/src/main/lib/feedback-remote/crossProjectFeedback.cjs +24 -2
  52. package/src/main/lib/feedback-remote/macroAdminRoutes.cjs +24 -3
  53. package/src/main/lib/feedback-remote/pendingReplies.cjs +8 -4
  54. package/src/main/lib/feedback-remote/projectCreate.cjs +415 -0
  55. package/src/main/lib/feedback-remote/replyClaims.cjs +15 -6
  56. package/src/main/lib/feedback-remote/serviceMcpSession.cjs +29 -1
  57. package/src/main/lib/feedback-remote/serviceMcpTools.cjs +43 -2
  58. package/src/main/lib/feedback-remote/servicePairLocalRoutes.cjs +91 -0
  59. package/src/main/lib/feedback-remote/servicePairings.cjs +47 -7
  60. package/src/main/lib/feedback-remote/serviceStdioBridge.cjs +99 -1
  61. package/src/main/lib/git/gitWorktree.cjs +1 -1
  62. package/src/main/lib/git/worktreeDeps.cjs +9 -3
  63. package/src/main/lib/mcpToolCatalog.cjs +43 -5
  64. package/src/main/lib/mcpToolsProbe.cjs +19 -2
  65. package/src/main/lib/packs/packCatalog.cjs +98 -5
  66. package/src/main/lib/persona-macro/agentPersonaSchema.cjs +6 -0
  67. package/src/main/lib/persona-macro/builtinMacros.cjs +6 -4
  68. package/src/main/lib/persona-macro/personaFrontmatterSchema.cjs +9 -0
  69. package/src/main/lib/persona-macro/personaLoadout.cjs +58 -0
  70. package/src/main/lib/persona-macro/personaMerge.cjs +11 -3
  71. package/src/main/lib/persona-macro/personaUpgrade.cjs +96 -0
  72. package/src/main/lib/persona-macro/projectVideoToolCheck.cjs +1 -1
  73. package/src/main/lib/persona-macro/shippedPersonaSeeds.cjs +94 -0
  74. package/src/main/lib/prd/prdCreate.cjs +48 -5
  75. package/src/main/lib/prd/prdFrontmatter.cjs +5 -2
  76. package/src/main/lib/prd/prdMcpReachWarnings.cjs +44 -0
  77. package/src/main/lib/prd/prdSandboxWarnings.cjs +49 -0
  78. package/src/main/lib/process/peerChatSession.cjs +165 -0
  79. package/src/main/lib/project-pages/videoScriptPress.cjs +6 -0
  80. package/src/main/lib/project-pages/videoScriptRunRoute.cjs +24 -4
  81. package/src/main/lib/promptSessionSchema.cjs +2 -0
  82. package/src/main/lib/scheduler/baselineGate.cjs +31 -2
  83. package/src/main/lib/scheduler/planRecordHarvest.cjs +104 -12
  84. package/src/main/lib/scheduler/planReleaseRoute.cjs +110 -0
  85. package/src/main/lib/scheduler/planReviewSchema.cjs +182 -0
  86. package/src/main/lib/scheduler/planReviewStats.cjs +63 -0
  87. package/src/main/lib/scheduler/planReviewStore.cjs +128 -0
  88. package/src/main/lib/scheduler/sandboxEnvironmentLimit.cjs +141 -0
  89. package/src/main/lib/scheduler/scheduleJobSchema.cjs +2 -0
  90. package/src/main/lib/scheduler/upgradeDrain.cjs +32 -5
  91. package/src/main/lib/scheduler/validatorVerdictSchema.cjs +12 -2
  92. package/src/main/lib/tasks/memoryConsolidation.cjs +109 -37
  93. package/src/main/lib/tasks/taskAdminRoutes.cjs +26 -14
  94. package/src/main/lib/tasks/taskRun.cjs +3 -1
  95. package/src/main/lib/tasks/weeklyConsolidationInputs.cjs +178 -0
  96. package/src/main/projectPages.cjs +22 -14
  97. package/src/main/pty.cjs +3 -0
  98. package/src/main/runVerify.cjs +3 -2
  99. package/src/main/scheduler/planReviewHold.cjs +140 -0
  100. package/src/main/scheduler/prdParser.cjs +1 -0
  101. package/src/main/scheduler/reviewLadder.cjs +2 -0
  102. package/src/main/scheduler/utilizationHold.cjs +7 -2
  103. package/src/main/scheduler.cjs +532 -78
  104. package/src/main/seedAgentPersonas.cjs +11 -6
  105. package/src/main/seedStatus.cjs +1 -1
  106. package/src/main/templates/PRD_AUTHORING.md +16 -1
  107. package/src/main/webRemote.cjs +47 -7
  108. package/src/preload/api.d.ts +71 -1
  109. package/src/preload/apiSurface.json +28 -0
  110. package/src/preload/index.cjs +9 -0
  111. package/src/seed/agents/architect.md +28 -43
  112. package/src/seed/agents/dev-lead.md +3 -1
  113. package/src/seed/agents/md-network-curator.md +27 -0
  114. package/src/seed/agents/plan-reviewer.md +47 -0
  115. package/src/seed/agents/validator.md +2 -1
  116. package/dist/assets/AppSettings-BO4jDVGO.js +0 -2
  117. package/dist/assets/HomeClaudeConfig-DADP5bfn.js +0 -3
  118. package/dist/assets/ProjectClaudeConfig-DPnDJKcr.js +0 -26
  119. package/dist/assets/Scheduler-CNLjn90m.js +0 -16
@@ -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 };
@@ -35,6 +35,7 @@ const { isIncomplete, resolveChainTerminals, isValidPlanId, mintPlanId, resolveI
35
35
  const { splitFrontmatter, PRD_EFFORT_LEVELS, formatQuotedInlineList } = require('./prdFrontmatter.cjs');
36
36
  const { parseRule: parseToolRiskRule } = require('../claude/toolRiskMarks.cjs');
37
37
  const { normalizePreflight } = require('../scheduler/preflightCheck.cjs');
38
+ const { qualifiesForReview, planReviewEnabled } = require('../../scheduler/planReviewHold.cjs');
38
39
 
39
40
  // Cap on riskTools entries — mirrors ipcSchemas.cjs RiskToolsSchema.
40
41
  const RISK_TOOLS_MAX = 20;
@@ -77,6 +78,24 @@ function normalizeRiskTools(value) {
77
78
  return { ok: true, value: seen };
78
79
  }
79
80
  const { sizingWarnings } = require('./prdSizing.cjs');
81
+ const { sandboxWarnings } = require('./prdSandboxWarnings.cjs');
82
+ const { mcpReachWarnings } = require('./prdMcpReachWarnings.cjs');
83
+
84
+ /** Real deps for mcpReachWarnings: persona servers resolved the way the scheduler snapshot does. Never throws. */
85
+ const mcpReachDeps = {
86
+ resolve: (o) => require('../claude/headlessMcpServers.cjs').resolveHeadlessMcpServers(o),
87
+ readPersonaServers: (input) => {
88
+ try {
89
+ const { readOverlayAwarePersona, DEFAULT_PRD_AGENT_TYPE: dflt } = require('../claude/agentModelResolve.cjs');
90
+ const { parseTools, parseCapabilityList } = require('../../agentLibrary.cjs');
91
+ const { resolvedMcpServerNames } = require('../claude/personaToolScope.cjs');
92
+ const fm = (readOverlayAwarePersona(input.agentType || dflt, { cwd: input.cwd }) || {}).fm;
93
+ if (!fm) return null;
94
+ const tools = parseTools(typeof fm.tools === 'string' ? fm.tools : '');
95
+ return resolvedMcpServerNames(tools, parseCapabilityList(fm.mcpServers));
96
+ } catch { return null; }
97
+ },
98
+ };
80
99
  const telemetryCounters = require('../telemetry/telemetryCounters.cjs');
81
100
  const { execGit } = require('../git/gitExec.cjs');
82
101
  const { extractRepoPathCandidates, worktreeReachWarnings } = require('./prdWorktreeReach.cjs');
@@ -137,7 +156,7 @@ function isValidMacroId(id) {
137
156
  function buildPrdBody(input) {
138
157
  const {
139
158
  title, cwd, estimateMinutes, goal, acceptanceCriteria,
140
- implementationNotes, outOfScope, sourcePromptId, sourceTabId, tag, agentType, dependsOn, quietMachine, disposition, deliverable, artifactPaths, planId, macroId, effort, voiceId, riskTools, preflight,
159
+ implementationNotes, outOfScope, sourcePromptId, sourceTabId, tag, agentType, dependsOn, quietMachine, disposition, deliverable, artifactPaths, planId, macroId, effort, voiceId, riskTools, preflight, planReview,
141
160
  gate, files, budgetExempt, fixes,
142
161
  } = input;
143
162
  // Structured criteria (prdCriteria.cjs): createPrd() normalizes once and
@@ -206,6 +225,7 @@ function buildPrdBody(input) {
206
225
  // Precondition command — validated by createPrd() via normalizePreflightField.
207
226
  // JSON-string form, matching prdFrontmatter.cjs's serializer.
208
227
  if (typeof preflight === 'string' && preflight) fmLines.push(`preflight: ${JSON.stringify(preflight)}`);
228
+ if (planReview === 'required') fmLines.push('planReview: required');
209
229
  if (quietMachine === true) fmLines.push('quietMachine: true');
210
230
  // Budget exemption is for a sweep validator that cannot be split further;
211
231
  // every other caller's budgetExempt is ignored.
@@ -1093,7 +1113,7 @@ async function createPrdInner(input, remote, ctl, opts = {}) {
1093
1113
  if (opts.dryRun) {
1094
1114
  return {
1095
1115
  ok: true, dryRun: true, slug, input, gateCommands, filesList,
1096
- inheritedPlanId, duplicateAllowed, warnings: [...extraWarnings, ...sizingWarnings(input)],
1116
+ inheritedPlanId, duplicateAllowed, warnings: [...extraWarnings, ...sizingWarnings(input), ...sandboxWarnings(input), ...mcpReachWarnings(input, mcpReachDeps)],
1097
1117
  };
1098
1118
  }
1099
1119
 
@@ -1185,7 +1205,7 @@ async function createPrdInner(input, remote, ctl, opts = {}) {
1185
1205
  // Advisory only (PRD 1403 sizing warnings + gate-and-files-in-PRD-body
1186
1206
  // absent/none-gate warnings) — never blocks the write. See prdSizing.cjs
1187
1207
  // and prdGateFiles.cjs.
1188
- warnings: [...extraWarnings, ...sizingWarnings(input)],
1208
+ warnings: [...extraWarnings, ...sizingWarnings(input), ...sandboxWarnings(input), ...mcpReachWarnings(input, mcpReachDeps)],
1189
1209
  };
1190
1210
  }
1191
1211
 
@@ -1276,6 +1296,26 @@ async function createPrdBatch(inputs, remote, opts = {}) {
1276
1296
  return fail([{ index: at, slug: cycle[0], error: `dependsOn cycle inside batch: ${cycle.join(' -> ')}` }]);
1277
1297
  }
1278
1298
 
1299
+ // Plan review: stamp planReview: required on each validator whose in-batch
1300
+ // dependsOn closure qualifies (planReviewHold.qualifiesForReview). Batch-only.
1301
+ const stampReview = new Set();
1302
+ if (planReviewEnabled()) {
1303
+ prepared.forEach((p, i) => {
1304
+ if (p.input.agentType !== 'validator') return;
1305
+ const seen = new Set();
1306
+ const stack = [...edges[i]];
1307
+ while (stack.length) {
1308
+ const n = stack.pop();
1309
+ if (seen.has(n)) continue;
1310
+ seen.add(n);
1311
+ stack.push(...edges[n]);
1312
+ }
1313
+ const members = [...seen].filter((n) => prepared[n].input.agentType !== 'validator')
1314
+ .map((n) => ({ slug: slugs[n], dependsOn: edges[n].map((m) => slugs[m]) }));
1315
+ if (qualifiesForReview(members)) stampReview.add(i);
1316
+ });
1317
+ }
1318
+
1279
1319
  // One planId for the whole batch unless an entry inherits one from existing deps.
1280
1320
  const planId = prepared.map((p) => p.inheritedPlanId).find(Boolean) || mintPlanId();
1281
1321
 
@@ -1364,14 +1404,16 @@ async function createPrdBatch(inputs, remote, opts = {}) {
1364
1404
  try {
1365
1405
  nn = nns[i];
1366
1406
  filenameSlug = `${nn}-${p.slug}`;
1367
- const body = buildPrdBody({ ...p.input, dependsOn: fullDeps(p.input.dependsOn), planId, gate: p.gateCommands, files: p.filesList });
1407
+ const body = buildPrdBody({ ...p.input, dependsOn: fullDeps(p.input.dependsOn), planId, planReview: stampReview.has(i) ? 'required' : undefined, gate: p.gateCommands, files: p.filesList });
1368
1408
  // A validated preflight must reach the file (PRD 3805 ran unheld when one
1369
1409
  // was lost); a body without the line rolls the whole batch back.
1370
1410
  if (p.input.preflight && !/^preflight: /m.test(body)) throw new Error('preflight was not written to the PRD frontmatter');
1371
1411
  const w = await remote.writePrd(filenameSlug, body, p.input.cwd);
1372
1412
  if (!w?.ok) throw new Error(w?.error ?? 'write failed');
1373
1413
  written.push({ filenameSlug, path: w.path ?? null, cwd: p.input.cwd });
1374
- results.push({ slug: p.slug, nn, filename: `${filenameSlug}.md`, preflight: p.input.preflight || null, warnings: [...p.warnings, ...overlapWarnings[i]] });
1414
+ results.push({ slug: p.slug, nn, filename: `${filenameSlug}.md`, preflight: p.input.preflight || null,
1415
+ ...(stampReview.has(i) ? { planReview: 'required' } : {}),
1416
+ warnings: [...p.warnings, ...overlapWarnings[i], ...(stampReview.has(i) ? ['plan held for plan review before dispatch'] : [])] });
1375
1417
  } catch (e) {
1376
1418
  await rollback();
1377
1419
  return { failed: fail([{ index: i, slug: p.slug, error: `write failed (batch rolled back): ${e?.message ?? e}` }]) };
@@ -1491,6 +1533,7 @@ function registerAdminRoute(adminHttp, remote) {
1491
1533
  }
1492
1534
 
1493
1535
  module.exports = {
1536
+ mcpReachDeps,
1494
1537
  crossEpicFilesOverlapWarnings,
1495
1538
  PRD_CREATE_SLUG_RE,
1496
1539
  STANDARDS_PATH,
@@ -83,8 +83,8 @@ function splitFrontmatter(raw) {
83
83
  * JSON array of { id, statement, check: { kind, spec? } } — see parseCriteria.
84
84
  */
85
85
 
86
- const RECOGNIZED_KEYS = new Set(['title', 'cwd', 'estimateMinutes', 'parallelGroup', 'sourcePromptId', 'sourceTabId', 'tag', 'agentType', 'createdVia', 'issuedAt', 'dependsOn', 'fixes', 'quietMachine', 'disposition', 'planId', 'deliverable', 'artifactPaths', 'macroId', 'effort', 'voiceId', 'riskTools', 'preflight', 'criteria']);
87
- const EMIT_ORDER = ['title', 'cwd', 'estimateMinutes', 'parallelGroup', 'sourcePromptId', 'sourceTabId', 'tag', 'agentType', 'createdVia', 'issuedAt', 'dependsOn', 'fixes', 'quietMachine', 'disposition', 'planId', 'deliverable', 'artifactPaths', 'macroId', 'effort', 'voiceId', 'riskTools', 'preflight', 'criteria'];
86
+ const RECOGNIZED_KEYS = new Set(['title', 'cwd', 'estimateMinutes', 'parallelGroup', 'sourcePromptId', 'sourceTabId', 'tag', 'agentType', 'createdVia', 'issuedAt', 'dependsOn', 'fixes', 'quietMachine', 'disposition', 'planId', 'deliverable', 'artifactPaths', 'macroId', 'effort', 'voiceId', 'riskTools', 'preflight', 'criteria', 'planReview']);
87
+ const EMIT_ORDER = ['title', 'cwd', 'estimateMinutes', 'parallelGroup', 'sourcePromptId', 'sourceTabId', 'tag', 'agentType', 'createdVia', 'issuedAt', 'dependsOn', 'fixes', 'quietMachine', 'disposition', 'planId', 'deliverable', 'artifactPaths', 'macroId', 'effort', 'voiceId', 'riskTools', 'preflight', 'criteria', 'planReview'];
88
88
  // Mirrors modelCatalog.cjs CATALOG_FLOOR.effortLevels. A closed set so the
89
89
  // value is always safe as a frontmatter line and as a --effort argv token.
90
90
  const PRD_EFFORT_LEVELS = Object.freeze(['low', 'medium', 'high', 'xhigh', 'max']);
@@ -274,6 +274,9 @@ function applyKey(fm, key, after) {
274
274
  // round-trips the string.
275
275
  fm.agentType = String(v);
276
276
  return;
277
+ case 'planReview':
278
+ if (String(v) === 'required') fm.planReview = 'required';
279
+ return;
277
280
  case 'createdVia':
278
281
  fm.createdVia = String(v);
279
282
  return;
@@ -0,0 +1,44 @@
1
+ /**
2
+ * prdMcpReachWarnings.cjs — advisory rule: a PRD whose persona (declared mcpServers + mcp__<server>__
3
+ * tools) or riskTools name an MCP server a headless job cannot load (undefined for the cwd, or
4
+ * credential-bearing) will park capability_unknown / capability_credentialed. Never blocks a write,
5
+ * never throws (an unreadable persona or resolver yields no warning).
6
+ */
7
+ 'use strict';
8
+
9
+ const RISK_MCP_RE = /^mcp__([^_](?:[^_]|_(?!_))*)__/;
10
+
11
+ /**
12
+ * @param {any} input createPrd()'s input shape.
13
+ * @param {{ resolve: (o: { cwd?: string }) => { known: Record<string, any>, credentialed: Record<string, string> },
14
+ * readPersonaServers: (input: any) => string[]|null }} deps
15
+ * @returns {string[]}
16
+ */
17
+ function mcpReachWarnings(input, deps) {
18
+ try {
19
+ const personaServers = deps.readPersonaServers(input);
20
+ if (!Array.isArray(personaServers)) return [];
21
+ const { known, credentialed } = deps.resolve({ cwd: input?.cwd });
22
+ const out = [];
23
+ for (const name of personaServers) {
24
+ if (Object.prototype.hasOwnProperty.call(credentialed || {}, name)) {
25
+ out.push(`persona MCP server \`${name}\` is credential-bearing (${credentialed[name]}) — the job will park capability_credentialed. Move the secret to a vault ref (environment profile) or drop the server from the persona.`);
26
+ } else if (!Object.prototype.hasOwnProperty.call(known || {}, name)) {
27
+ out.push(`persona MCP server \`${name}\` is not defined in ~/.claude.json, <cwd>/.mcp.json or the local project scope for this cwd — the job will park capability_unknown. Define the server there or remove it from the persona's tools/mcpServers.`);
28
+ }
29
+ }
30
+ const seen = new Set();
31
+ const risk = Array.isArray(input?.riskTools) ? input.riskTools : [];
32
+ for (const rule of risk) {
33
+ const m = typeof rule === 'string' ? RISK_MCP_RE.exec(rule) : null;
34
+ if (!m || seen.has(m[1]) || personaServers.includes(m[1])) continue;
35
+ seen.add(m[1]);
36
+ out.push(`riskTools clears \`${rule}\` but the persona never loads MCP server \`${m[1]}\` — the tool is cleared yet unreachable. Add it to the persona's tools or mcpServers.`);
37
+ }
38
+ return out;
39
+ } catch {
40
+ return [];
41
+ }
42
+ }
43
+
44
+ module.exports = { mcpReachWarnings };
@@ -0,0 +1,49 @@
1
+ /**
2
+ * prdSandboxWarnings.cjs — pure advisory rule: a PRD that lists a path under `.claude/` in its
3
+ * files AND mentions `git mv` / `git rm` / `rm` in its goal, notes or criteria will park, because
4
+ * job Bash cannot write under `.claude/` in the sandbox (Self PRD 1326). Any path under
5
+ * `.claude/agents/` or `.claude/commands/` warns unconditionally (no verb needed): all writes there
6
+ * are refused, Edit/Write included. Never blocks a write.
7
+ */
8
+ 'use strict';
9
+
10
+ const VERB_RE = /\bgit\s+(mv|rm)\b|(^|[\s`'"(;&|])rm(?=$|[\s.,;:)`'"])/m;
11
+
12
+ /** @param {unknown} p */
13
+ function isClaudePath(p) {
14
+ return typeof p === 'string' && p.split('/').some((seg) => seg === '.claude');
15
+ }
16
+
17
+ /** `.claude` followed by agents, commands, skills, hooks or settings*.json: every write there is refused (Bash, Edit, Write). */
18
+ function isProtectedClaudePath(p) {
19
+ if (typeof p !== 'string') return false;
20
+ const segs = p.split('/');
21
+ return segs.some((seg, i) => seg === '.claude' && (['agents', 'commands', 'skills', 'hooks'].includes(segs[i + 1]) || /^settings[^/]*\.json$/.test(segs[i + 1] ?? '')));
22
+ }
23
+
24
+ /**
25
+ * Returns `[]` or a one-element array holding the warning (spread-compatible with sizingWarnings).
26
+ * @param {any} input createPrd()'s input shape.
27
+ * @returns {string[]}
28
+ */
29
+ function sandboxWarnings(input) {
30
+ const files = Array.isArray(input?.files) ? input.files : [];
31
+ const protectedPaths = files.filter(isProtectedClaudePath);
32
+ if (protectedPaths.length > 0) {
33
+ return [
34
+ `files lists ${protectedPaths.map((p) => `\`${p}\``).join(', ')} under .claude/agents, .claude/commands, .claude/skills, .claude/hooks or .claude/settings*.json — the job sandbox cannot write there (Bash, Edit and Write are all refused), so the job will fail. Remove the path from files; the architect must edit these inline. See PRD_AUTHORING.md#job-sandbox-limits.`,
35
+ ];
36
+ }
37
+ const bad = files.filter(isClaudePath);
38
+ if (bad.length === 0) return [];
39
+ const ac = Array.isArray(input?.acceptanceCriteria) ? input.acceptanceCriteria : [];
40
+ const text = [input?.goal, input?.implementationNotes, ...ac]
41
+ .filter((s) => typeof s === 'string')
42
+ .join('\n');
43
+ if (!VERB_RE.test(text)) return [];
44
+ return [
45
+ `files lists ${bad.map((p) => `\`${p}\``).join(', ')} under .claude/ and the PRD mentions git mv / git rm / rm — Bash writes there are refused by the job sandbox, so the job will park. Remove the verb or the path; the architect edits protected .claude/ paths inline. See PRD_AUTHORING.md#job-sandbox-limits.`,
46
+ ];
47
+ }
48
+
49
+ module.exports = { sandboxWarnings };