claude-code-session-manager 0.130.2 → 0.131.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 (88) hide show
  1. package/.claude-plugin/marketplace.json +1 -1
  2. package/bin/cli.cjs +19 -2
  3. package/dist/assets/AgentLibrary-CYXre0J-.js +2 -0
  4. package/dist/assets/{AppSettings-Bpwynea4.js → AppSettings-xNSfCj8e.js} +2 -2
  5. package/dist/assets/{Button-DSoqrxCB.js → Button-BWljh5IK.js} +1 -1
  6. package/dist/assets/DocumentEditorPane-FUC2hZlp.js +1 -0
  7. package/dist/assets/Extensions-CsyUoklz.js +2 -0
  8. package/dist/assets/{History-DzMo9Otn.js → History-BvNmY9OQ.js} +2 -2
  9. package/dist/assets/{Library-C5wKMTSn.js → Library-DVXk77zA.js} +12 -12
  10. package/dist/assets/{ListDetail-DDQ1S0yu.js → ListDetail-DAAx__24.js} +1 -1
  11. package/dist/assets/{Panel-B-3NWUlv.js → Panel-g2D-e-RM.js} +1 -1
  12. package/dist/assets/ProjectClaudeConfig-BDuHJwaO.js +25 -0
  13. package/dist/assets/{ProvenanceBadge-CUChwz4Z.js → ProvenanceBadge-wew4_nf3.js} +1 -1
  14. package/dist/assets/Scheduler-CbeUIqD-.js +16 -0
  15. package/dist/assets/Settings-B23RsRfm.js +2 -0
  16. package/dist/assets/{SkillReferenceGraph-C6JEdypC.js → SkillReferenceGraph-BxQPCfsg.js} +1 -1
  17. package/dist/assets/Skills-4AR2FQrI.js +29 -0
  18. package/dist/assets/{SourceChip-DcBNYYhe.js → SourceChip-jrC0vjfw.js} +1 -1
  19. package/dist/assets/SystemPrompt-hHoBEnYb.js +1 -0
  20. package/dist/assets/{TiptapBody-DiVYC-_O.js → TiptapBody-FkUqxO9u.js} +1 -1
  21. package/dist/assets/{Toggle-Cs3k6I96.js → Toggle-DQMNWZKT.js} +1 -1
  22. package/dist/assets/ViewTabs-DGU0ZuxB.js +1 -0
  23. package/dist/assets/{VoiceButton-C3NLotUZ.js → VoiceButton-BPPvDllh.js} +1 -1
  24. package/dist/assets/{historyTotals-f-E0L9Xw.js → historyTotals-D8Oc3wUK.js} +1 -1
  25. package/dist/assets/index-9ajPMXBg.js +3097 -0
  26. package/dist/assets/{index-Bp8XE9A6.css → index-oXqzajWV.css} +1 -1
  27. package/dist/index.html +2 -2
  28. package/dist-web/app.css +1 -1
  29. package/dist-web/app.js +455 -427
  30. package/package.json +1 -1
  31. package/plugins/session-manager-dev/.claude-plugin/plugin.json +1 -1
  32. package/plugins/session-manager-dev/skills/maintaining-md-network/drift-check.md +15 -5
  33. package/plugins/session-manager-dev/skills/maintaining-md-network/scripts/drift-check.cjs +8 -4
  34. package/scripts/scheduler-mcp-server.cjs +71 -0
  35. package/src/main/agentLibrary.cjs +81 -29
  36. package/src/main/agentsIpc.cjs +21 -16
  37. package/src/main/build-info.json +4 -4
  38. package/src/main/index.cjs +9 -0
  39. package/src/main/ipcSchemas.cjs +35 -2
  40. package/src/main/lib/epic/epicMint.cjs +61 -6
  41. package/src/main/lib/epic/epicWorktreeMerge.cjs +11 -9
  42. package/src/main/lib/epic/epicWorktreeMint.cjs +45 -4
  43. package/src/main/lib/epic/promptSessionsCreateEpic.cjs +32 -5
  44. package/src/main/lib/epic/restorableSessions.cjs +749 -0
  45. package/src/main/lib/feedback-remote/projectHomeAdminRoutes.cjs +61 -0
  46. package/src/main/lib/feedback-remote/remoteIpcDispatch.cjs +4 -0
  47. package/src/main/lib/git/branchSweep.cjs +9 -3
  48. package/src/main/lib/git/gitExec.cjs +8 -1
  49. package/src/main/lib/git/gitWorktree.cjs +771 -96
  50. package/src/main/lib/git/jobWorktree.cjs +3 -0
  51. package/src/main/lib/git/jobWorktreeBootLive.cjs +14 -2
  52. package/src/main/lib/mcpToolCatalog.cjs +28 -0
  53. package/src/main/lib/mcpToolsProbe.cjs +831 -0
  54. package/src/main/lib/mdNetworkScan.cjs +555 -0
  55. package/src/main/lib/persona-macro/agentPersonaSchema.cjs +18 -5
  56. package/src/main/lib/persona-macro/builtinMacros.cjs +22 -4
  57. package/src/main/lib/persona-macro/macroJobDispatch.cjs +17 -2
  58. package/src/main/lib/persona-macro/shippedPersonaSeeds.cjs +38 -0
  59. package/src/main/lib/project-pages/competitiveMatrix.cjs +258 -0
  60. package/src/main/lib/project-pages/matrixHtml.cjs +239 -0
  61. package/src/main/lib/project-pages/matrixStore.cjs +112 -0
  62. package/src/main/lib/promptSessionSchema.cjs +5 -0
  63. package/src/main/lib/scheduler/fixPlanSlug.cjs +15 -1
  64. package/src/main/lib/scheduler/reaperHelpers.cjs +35 -0
  65. package/src/main/lib/scheduler/scheduleJobSchema.cjs +2 -0
  66. package/src/main/lib/scheduler/scheduleJobTransitions.cjs +8 -7
  67. package/src/main/lib/scheduler/terminalRunOutcome.cjs +61 -15
  68. package/src/main/projectPages.cjs +51 -7
  69. package/src/main/runVerify.cjs +8 -3
  70. package/src/main/scheduler/budget.cjs +146 -7
  71. package/src/main/scheduler/gitTreeGuard.cjs +92 -20
  72. package/src/main/scheduler/reviewLadder.cjs +60 -0
  73. package/src/main/scheduler.cjs +477 -53
  74. package/src/main/seedAgentPersonas.cjs +1 -1
  75. package/src/preload/api.d.ts +250 -7
  76. package/src/preload/apiSurface.json +28 -0
  77. package/src/preload/index.cjs +6 -0
  78. package/src/seed/agents/competitive-analyst.md +69 -0
  79. package/src/seed/agents/competitive-researcher.md +75 -0
  80. package/src/seed/agents/validator.md +2 -2
  81. package/dist/assets/AgentLibrary-Bfj862qf.js +0 -2
  82. package/dist/assets/Extensions-BziIutWV.js +0 -13
  83. package/dist/assets/Memory-Bq5T33d2.js +0 -25
  84. package/dist/assets/Scheduler-CkGHMXvo.js +0 -16
  85. package/dist/assets/Settings-DGxvyajs.js +0 -2
  86. package/dist/assets/SystemPrompt-CfozyVQx.js +0 -1
  87. package/dist/assets/ViewTabs-DFXH03tb.js +0 -1
  88. package/dist/assets/index-CuAfFXNd.js +0 -3086
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "claude-code-session-manager",
3
- "version": "0.130.2",
3
+ "version": "0.131.0",
4
4
  "description": "Local cockpit for the Claude Code CLI — multi-tab terminal, full config surface, scheduler, voice dictation, and live observability.",
5
5
  "type": "module",
6
6
  "main": "src/main/index.cjs",
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "session-manager-dev",
3
3
  "description": "The default end-to-end development skillset for the Claude Code Session Manager: decompose work into scheduler PRDs and track them to a validated finish (/develop), publish releases to npm (/builder), hand a finding to another project on this machine (/send-feedback), and review or drift-check a project's CLAUDE.md/markdown network (/maintaining-md-network). Together with the session-manager scheduler these form a develop → queue → validate → release loop.",
4
- "version": "0.3.5",
4
+ "version": "0.3.6",
5
5
  "author": {
6
6
  "name": "Bilko Bibitkov",
7
7
  "email": "BilkoBibitkov2000@gmail.com",
@@ -22,7 +22,7 @@ node <skill base dir>/scripts/drift-check.cjs --root <repo>
22
22
  | Flag | Meaning |
23
23
  | --- | --- |
24
24
  | `--root <dir>` | Repo to check. Defaults to the current directory. Must be a directory. |
25
- | `--map <path>` | The entry map. Default: the CLAUDE.md or AGENTS.md at the root that holds the maintainer comment (see below). |
25
+ | `--map <path>` | The entry map. Default: the first file that holds the maintainer comment, searched in this order: the root CLAUDE.md, the root AGENTS.md, then the `.md` files those two import directly with at-sign imports (see below). |
26
26
  | `--file <path>` | Check only this file. Repeat for each file. Default: every tracked `.md` file (all `.md` files outside `.git` and `node_modules` when the repo is not git). |
27
27
  | `--exclude <prefix>` | Skip files whose repo-relative path starts with the prefix. Repeat as needed. |
28
28
  | `--checks <list>` | Comma list from `links`, `paths`, `limits`, `contents`. Default: all four. |
@@ -32,14 +32,16 @@ A flag that needs a value fails if the value is missing or starts with `--`.
32
32
 
33
33
  ### Output
34
34
 
35
- One JSON object on stdout:
35
+ One JSON object on stdout, with its keys in this order:
36
36
 
37
37
  - `root`: the resolved repo root.
38
38
  - `map`: the map file used, or null.
39
39
  - `notes`: plain-text caveats, such as `no md-network-map comment found; the 70-line map limit was not applied`. Read it: an empty map means the map limit never ran.
40
- - `checkedFiles`: the repo-relative files checked.
41
40
  - `findings`: a list, sorted by file then line.
42
41
  - `counts`: findings per kind.
42
+ - `checkedFiles`: the repo-relative files checked.
43
+
44
+ `checkedFiles` comes last, so a long file list never hides the findings in a cut-off view of the output.
43
45
 
44
46
  ### Finding kinds
45
47
 
@@ -59,7 +61,7 @@ Rules the script applies:
59
61
  - Site route: a link starting with a single slash that does not exist under the repo root is treated as a website route and skipped. `--strict-paths` turns that skip off.
60
62
  - Ignore marker: a line that contains the marker `<!-- drift-check-ignore -->` is skipped by the link and path checks.
61
63
  - Ellipsis rule: a span with a `...` segment, such as src/.../x.ts, is a placeholder and is skipped.
62
- - Map detection: without `--map`, the script looks for the maintainer comment in the root CLAUDE.md and AGENTS.md, then in the `.md` files they import with at-sign imports. The first file with the comment is the map.
64
+ - Map detection: without `--map`, the script looks for the maintainer comment in the root CLAUDE.md and AGENTS.md, then in the `.md` files inside the repo that they import directly with at-sign imports. Only those direct imports (one hop) are searched, not the files they import in turn. The first file with the comment is the map.
63
65
 
64
66
  ## Path conventions
65
67
 
@@ -180,4 +182,12 @@ The map carries one HTML comment, so the script and the next reviewer can find i
180
182
  <!-- md-network-map owner: <name> last-review: <YYYY-MM-DD> -->
181
183
  ```
182
184
 
183
- Without `--map`, the script looks for this comment in CLAUDE.md, then AGENTS.md, at the repo root. The first file that has it is the map, and it gets the 70-line limit. Update `last-review` in the same commit as each review record. HTML comments are stripped before the model reads the file, so the comment costs no context.
185
+ Put the comment in the map file itself. The map may be an imported file: when the root CLAUDE.md pulls in docs/map.md with an at-sign import, the comment goes in docs/map.md.
186
+
187
+ Without `--map`, the script searches the root CLAUDE.md, then the root AGENTS.md, then the `.md` files those two import directly with at-sign imports. The first file that has the comment is the map, and it gets the 70-line limit.
188
+
189
+ Do not put the comment in a CLAUDE.md that only imports the map. That makes CLAUDE.md the map, so CLAUDE.md plus everything it imports is held to the 70-line limit, and the real map gets no limit of its own. On the Bilko repo, moving the comment from docs/map.md to CLAUDE.md gave a false over-line-limit finding: CLAUDE.md had 45 lines, 93 with its imports, against a limit of 70.
190
+
191
+ Update `last-review` in the same commit as each review record.
192
+
193
+ Claude Code strips block-level HTML comments, such as this one on its own line, from CLAUDE.md and from the files it imports before the model reads them. There the comment costs no context. A tool that returns the raw file text does not strip it: the Read tool, an MCP server, or a script. If a project's tool serves the map to a model, strip the comment in that tool.
@@ -6,7 +6,7 @@
6
6
  * node drift-check.cjs [--root <dir>] [--map <path>] [--file <path>]...
7
7
  * [--exclude <prefix>]... [--checks links,paths,limits,contents] [--strict-paths]
8
8
  *
9
- * Prints one JSON object { root, map, notes, checkedFiles, findings, counts } to stdout.
9
+ * Prints one JSON object { root, map, notes, findings, counts, checkedFiles } to stdout.
10
10
  * Exit 0 = no findings, 1 = findings, 2 = usage error / missing root.
11
11
  */
12
12
 
@@ -377,9 +377,12 @@ function runDriftCheck(options) {
377
377
  findings.sort((x, y) => (x.file < y.file ? -1 : x.file > y.file ? 1 : (x.line || 0) - (y.line || 0)));
378
378
  const counts = {};
379
379
  for (const f of findings) counts[f.kind] = (counts[f.kind] || 0) + 1;
380
- return { root: toPosix(root), map, notes, checkedFiles: docs, findings, counts };
380
+ // checkedFiles last: a long file list must not push findings and counts out of a truncated view.
381
+ return { root: toPosix(root), map, notes, findings, counts, checkedFiles: docs };
381
382
  }
382
383
 
384
+ // Set process.exitCode, never process.exit(): stdout/stderr to a pipe are async on POSIX, and
385
+ // process.exit() drops whatever has not drained (a report cut at the 64 KiB pipe buffer).
383
386
  function main() {
384
387
  let result;
385
388
  try {
@@ -387,12 +390,13 @@ function main() {
387
390
  } catch (err) {
388
391
  if (err instanceof UsageError) {
389
392
  process.stderr.write(`drift-check: ${err.message}\n`);
390
- process.exit(2);
393
+ process.exitCode = 2;
394
+ return;
391
395
  }
392
396
  throw err;
393
397
  }
394
398
  process.stdout.write(JSON.stringify(result, null, 2) + '\n');
395
- process.exit(result.findings.length ? 1 : 0);
399
+ process.exitCode = result.findings.length ? 1 : 0;
396
400
  }
397
401
 
398
402
  module.exports = { runDriftCheck, parseArgs };
@@ -14,6 +14,8 @@
14
14
  * project_home_write({ cwd?, html }) -> POST /admin/project-home/write
15
15
  * project_demo_video_write({ cwd?, html? | htmlPath? }) -> POST /admin/project-home/demo-video/write
16
16
  * project_page_write({ cwd?, pageId, title, topic?, html? | htmlPath? }) -> POST /admin/project-home/pages/write
17
+ * project_matrix_read({ cwd? }) -> POST /admin/project-home/matrix/read
18
+ * project_matrix_write({ cwd?, matrix? | matrixPath?, model? }) -> POST /admin/project-home/matrix/write
17
19
  * project_character_write({ cwd?, json, js? | jsPath?, replace? }) -> POST /admin/project-home/character/write
18
20
  * project_video_write({ cwd?, videoId, title, kind, lengthS, html? | htmlPath?, meta? }) -> POST /admin/project-home/videos/write
19
21
  *
@@ -64,6 +66,7 @@ function withPointer(text) {
64
66
 
65
67
  const MAX_DEMO_VIDEO_BYTES = 2 * 1024 * 1024;
66
68
  const MAX_CHARACTER_JS_BYTES = 300 * 1024;
69
+ const MAX_MATRIX_JSON_BYTES = 1048576;
67
70
 
68
71
  /** Reads a local .js file for project_character_write; errors carry only the reason, never file contents. */
69
72
  async function readCharacterJsFile(p) {
@@ -107,6 +110,37 @@ async function resolveHtmlArg(args) {
107
110
  return { html: args.html };
108
111
  }
109
112
 
113
+ /** Reads + parses a local .json file for project_matrix_write; errors carry only the reason, never file contents. */
114
+ async function readMatrixJsonFile(p) {
115
+ if (typeof p !== 'string' || !path.isAbsolute(p)) return { error: 'matrixPath must be an absolute path' };
116
+ if (!/\.json$/i.test(p)) return { error: 'matrixPath must end in .json' };
117
+ let raw;
118
+ try {
119
+ const st = await fsp.stat(p);
120
+ if (!st.isFile()) return { error: 'matrixPath is not a regular file' };
121
+ if (st.size > MAX_MATRIX_JSON_BYTES) return { error: `matrixPath file exceeds ${MAX_MATRIX_JSON_BYTES} bytes` };
122
+ raw = await fsp.readFile(p, 'utf8');
123
+ } catch (err) {
124
+ return { error: `cannot read matrixPath: ${err && err.code ? err.code : 'read failed'}` };
125
+ }
126
+ let parsed;
127
+ try { parsed = JSON.parse(raw); } catch (err) {
128
+ return { error: `matrixPath is not valid JSON: ${err && err.message ? err.message : 'parse failed'}` };
129
+ }
130
+ if (!parsed || typeof parsed !== 'object' || Array.isArray(parsed)) return { error: 'matrixPath must hold a JSON object' };
131
+ return { matrix: parsed };
132
+ }
133
+
134
+ /** Resolves exactly one of matrix / matrixPath into { matrix } or { error }. */
135
+ async function resolveJsonArg(args) {
136
+ const hasMatrix = !!args && args.matrix !== undefined && args.matrix !== null && args.matrix !== '';
137
+ const hasPath = !!args && args.matrixPath !== undefined && args.matrixPath !== null && args.matrixPath !== '';
138
+ if (hasMatrix === hasPath) return { error: 'provide exactly one of matrix or matrixPath' };
139
+ if (hasPath) return readMatrixJsonFile(args.matrixPath);
140
+ if (typeof args.matrix !== 'object' || Array.isArray(args.matrix)) return { error: 'matrix must be a JSON object' };
141
+ return { matrix: args.matrix };
142
+ }
143
+
110
144
  function errorResult(text) {
111
145
  return { content: [{ type: 'text', text: withPointer(text) }], isError: true };
112
146
  }
@@ -569,6 +603,29 @@ const TOOLS = [
569
603
  required: ['pageId', 'title'],
570
604
  },
571
605
  },
606
+ {
607
+ name: 'project_matrix_read',
608
+ description: descriptionFor('project_matrix_read'),
609
+ inputSchema: {
610
+ type: 'object',
611
+ properties: {
612
+ cwd: { type: 'string', description: "Optional: absolute path to the target project. Defaults to the calling session's own project root (SM_PROJECT_ROOT or process.cwd()) when omitted." },
613
+ },
614
+ },
615
+ },
616
+ {
617
+ name: 'project_matrix_write',
618
+ description: descriptionFor('project_matrix_write'),
619
+ inputSchema: {
620
+ type: 'object',
621
+ properties: {
622
+ cwd: { type: 'string', description: "Optional: absolute path to the target project. Defaults to the calling session's own project root (SM_PROJECT_ROOT or process.cwd()) when omitted." },
623
+ matrix: { type: 'object', description: 'The whole competitive feature matrix as a JSON object matching the schema project_matrix_read returns (<= 1MB). Replaces the stored matrix.' },
624
+ matrixPath: { type: 'string', description: 'Absolute path to a local .json file holding the matrix (<= 1MB, parsed as JSON; same rules as matrix). Give exactly one of matrix / matrixPath.' },
625
+ model: { type: 'string', description: 'Optional: id of the model that produced this matrix, recorded with the save.' },
626
+ },
627
+ },
628
+ },
572
629
  {
573
630
  name: 'project_video_write',
574
631
  description: descriptionFor('project_video_write'),
@@ -1031,6 +1088,20 @@ async function handleCallTool(request) {
1031
1088
  const result = await adminRequest('POST', '/admin/project-home/pages/write', body);
1032
1089
  return { content: [{ type: 'text', text: JSON.stringify(result) }] };
1033
1090
  }
1091
+ if (name === 'project_matrix_read') {
1092
+ const cwd = resolveCwdArg(args);
1093
+ const result = await adminRequest('POST', '/admin/project-home/matrix/read', { cwd });
1094
+ return { content: [{ type: 'text', text: JSON.stringify(result) }] };
1095
+ }
1096
+ if (name === 'project_matrix_write') {
1097
+ const loaded = await resolveJsonArg(args);
1098
+ if (loaded.error) return errorResult(loaded.error);
1099
+ const cwd = resolveCwdArg(args);
1100
+ const body = { cwd, matrix: loaded.matrix };
1101
+ if (typeof args.model === 'string' && args.model) body.model = args.model;
1102
+ const result = await adminRequest('POST', '/admin/project-home/matrix/write', body);
1103
+ return { content: [{ type: 'text', text: JSON.stringify(result) }] };
1104
+ }
1034
1105
  if (name === 'project_video_write') {
1035
1106
  if (!args || typeof args.videoId !== 'string' || !args.videoId || typeof args.title !== 'string' || !args.title
1036
1107
  || typeof args.kind !== 'string' || !args.kind || typeof args.lengthS !== 'number' || !Number.isFinite(args.lengthS)) {
@@ -112,26 +112,63 @@ function serializePersona({ name, description, tools, model, effort, color, tags
112
112
  return lines.join('\n') + (body || '').trim() + '\n';
113
113
  }
114
114
 
115
+ /**
116
+ * The cwd form every override key is compared in: repeated `/` collapsed,
117
+ * trailing `/` stripped, root kept as `/`. Same rule as the renderer's
118
+ * `normalizeCwd` (src/renderer/lib/knownProjectAggregate.ts — main must not
119
+ * import renderer code) minus its `trim()`: a cwd with edge whitespace then
120
+ * fails closed as "project not open" instead of resolving to a sibling dir.
121
+ */
122
+ function normalizeCwd(cwd) {
123
+ const collapsed = String(cwd).replace(/\/{2,}/g, '/');
124
+ if (collapsed === '/') return '/';
125
+ return collapsed.replace(/\/+$/, '');
126
+ }
127
+
128
+ /**
129
+ * The open project (`{ cwd, name }` from `openProjects`) whose normalized cwd
130
+ * equals `projectCwd`'s. Matched by cwd, never by folder name — two open
131
+ * projects can share one (`/a/proj`, `/b/proj`). Throws
132
+ * `project not open: <cwd>` for an unknown, empty or non-string value, so an
133
+ * override call can never land in some other project's (or the global) file.
134
+ */
135
+ async function findOpenProject(projectCwd, loadSessions) {
136
+ const key = typeof projectCwd === 'string' && projectCwd !== '' ? normalizeCwd(projectCwd) : null;
137
+ const project = key === null ? undefined : (await openProjects({ loadSessions })).find((p) => p.cwd === key);
138
+ if (!project) throw new Error(`project not open: ${projectCwd}`);
139
+ return project;
140
+ }
141
+
115
142
  /**
116
143
  * Project OVERRIDE write: a frontmatter-only overlay at
117
- * `<cwd>/.claude/agents/<name>.md` carrying ONLY the overridden `model` /
144
+ * `<projectCwd>/.claude/agents/<name>.md` carrying ONLY the overridden `model` /
118
145
  * `effort` keys and no body (lib/persona-macro/personaMerge.cjs inherits everything else
119
- * from the global persona). Keys already in an existing frontmatter-only
146
+ * from the global persona). `projectCwd` must be an OPEN project's cwd (see
147
+ * findOpenProject). Keys already in an existing frontmatter-only
120
148
  * overlay are preserved; an existing overlay that has a BODY is refused so a
121
149
  * full-body overlay is never silently converted. Both keys unset removes the
122
150
  * file (same as `removeOverride`) rather than leaving an empty overlay.
151
+ *
152
+ * Registers the open project's root via `addAllowedRoot` before touching the
153
+ * overlay: config.cjs's validateWrite allows `<root>/.claude/` writes only under
154
+ * a registered root, and a dormant tab (no terminal running — every tab
155
+ * restored after a restart) has no pty-registered one. The cwd has already
156
+ * passed validatePath, so this widens nothing a terminal spawn in that project
157
+ * would not (same precedent as projectBrief.cjs's `allowBriefWrites`). An
158
+ * unknown or empty `projectCwd` throws in findOpenProject first, so nothing is
159
+ * registered for it.
123
160
  */
124
- async function saveOverlay({ name, projectName, model, effort, loadSessions, validatePath, writeTextAtomic }) {
125
- const projects = await openProjects({ loadSessions });
126
- const project = projects.find((p) => p.name === projectName);
127
- if (!project) throw new Error(`project not open: ${projectName}`);
161
+ async function saveOverlay({ name, projectCwd, model, effort, loadSessions, validatePath, writeTextAtomic, addAllowedRoot }) {
162
+ const project = await findOpenProject(projectCwd, loadSessions);
163
+ // Dormant tab = no pty-registered root; see JSDoc + projectBrief.cjs allowBriefWrites.
164
+ addAllowedRoot(validatePath(project.cwd));
128
165
  const target = validatePath(path.join(project.cwd, '.claude', 'agents', `${name}.md`));
129
166
  let preserved = [];
130
167
  try {
131
168
  const rawExisting = await fsp.readFile(target, 'utf8');
132
169
  const existing = splitFrontmatter(rawExisting);
133
170
  if (existing.body.trim() !== '') {
134
- throw new Error(`${name} has a full-body override in ${projectName} — edit ${target} directly; it is not converted to a frontmatter-only override`);
171
+ throw new Error(`${name} has a full-body override in ${project.name} — edit ${target} directly; it is not converted to a frontmatter-only override`);
135
172
  }
136
173
  preserved = extractUnmanagedLines(rawExisting, new Set(['model', 'effort']));
137
174
  } catch (e) {
@@ -142,7 +179,7 @@ async function saveOverlay({ name, projectName, model, effort, loadSessions, val
142
179
  if (v && v !== 'inherit') managedLines.push(`${k}: ${v}`);
143
180
  }
144
181
  if (managedLines.length === 0 && preserved.length === 0) {
145
- await removeOverride({ name, projectName, loadSessions, validatePath });
182
+ await removeOverride({ name, projectCwd: project.cwd, loadSessions, validatePath });
146
183
  return { ok: true, path: target, removed: true };
147
184
  }
148
185
  const lines = ['---', ...managedLines, ...preserved, '---', ''];
@@ -154,9 +191,12 @@ async function saveOverlay({ name, projectName, model, effort, loadSessions, val
154
191
  * Writes a global persona `.md` file — `~/.claude/agents/<name>.md`. Pass
155
192
  * `originalName` when renaming an existing persona so the old file is
156
193
  * removed once the new one is written (no-op if names match). Pass
157
- * `projectName` (an open project) to instead write that project's
158
- * frontmatter-only OVERRIDE of the persona — see saveOverlay; only `model` and
159
- * `effort` are read in that mode.
194
+ * `projectCwd` (an OPEN project's absolute cwd) to instead write that
195
+ * project's frontmatter-only OVERRIDE of the persona — see saveOverlay; only
196
+ * `model` and `effort` are read in that mode. Routing is on
197
+ * `projectCwd !== undefined`, not truthiness: an empty/null cwd throws
198
+ * `project not open` rather than falling through to the global write with the
199
+ * override call's blank description/tools/body.
160
200
  */
161
201
  async function savePersona({
162
202
  name,
@@ -174,17 +214,18 @@ async function savePersona({
174
214
  seedVersion,
175
215
  executorOnly,
176
216
  body,
177
- projectName,
217
+ projectCwd,
178
218
  globalDir = path.join(os.homedir(), '.claude', 'agents'),
179
219
  loadSessions = sessionsStore.load,
180
220
  validatePath = configMgr.validatePath,
181
221
  writeTextAtomic = configMgr.writeTextAtomic,
222
+ addAllowedRoot = configMgr.addAllowedRoot,
182
223
  } = {}) {
183
224
  if (!PERSONA_NAME_RE.test(name || '')) {
184
225
  throw new Error('agent name must be lowercase, hyphenated (e.g. "my-agent")');
185
226
  }
186
- if (projectName) {
187
- return saveOverlay({ name, projectName, model, effort, loadSessions, validatePath, writeTextAtomic });
227
+ if (projectCwd !== undefined) {
228
+ return saveOverlay({ name, projectCwd, model, effort, loadSessions, validatePath, writeTextAtomic, addAllowedRoot });
188
229
  }
189
230
  const target = validatePath(path.join(globalDir, `${name}.md`));
190
231
  // A caller that omits seedVersion/title/projects/action/actionLabel (the
@@ -229,12 +270,19 @@ async function savePersona({
229
270
  return { ok: true, path: target };
230
271
  }
231
272
 
232
- /** Deletes a global persona `.md` file. Idempotent — missing file is not an error. */
273
+ /**
274
+ * Deletes a global persona `.md` file. Idempotent — missing file is not an error.
275
+ * A non-kebab-case `name` (e.g. `../../notes/x`) throws before any path is built,
276
+ * so it can never unlink a `.md` outside `globalDir`.
277
+ */
233
278
  async function deletePersona({
234
279
  name,
235
280
  globalDir = path.join(os.homedir(), '.claude', 'agents'),
236
281
  validatePath = configMgr.validatePath,
237
282
  } = {}) {
283
+ if (!PERSONA_NAME_RE.test(name || '')) {
284
+ throw new Error('agent name must be lowercase, hyphenated (e.g. "my-agent")');
285
+ }
238
286
  const target = validatePath(path.join(globalDir, `${name}.md`));
239
287
  try {
240
288
  await fsp.unlink(target);
@@ -245,19 +293,19 @@ async function deletePersona({
245
293
  }
246
294
 
247
295
  /**
248
- * Drops a project's local override (`<cwd>/.claude/agents/<name>.md`) so the
249
- * global definition applies there again. `projectName` is resolved against
250
- * currently-open tabs (same source `listPersonas` uses for overridingProjects).
296
+ * Drops a project's local override (`<projectCwd>/.claude/agents/<name>.md`)
297
+ * so the global definition applies there again. `projectCwd` is resolved by
298
+ * normalized cwd against currently-open tabs (findOpenProject — the same
299
+ * `openProjects` source `listPersonas` reports each overrideDetails `cwd` from);
300
+ * an unknown or empty cwd throws `project not open` and deletes nothing.
251
301
  */
252
302
  async function removeOverride({
253
303
  name,
254
- projectName,
304
+ projectCwd,
255
305
  loadSessions = sessionsStore.load,
256
306
  validatePath = configMgr.validatePath,
257
307
  } = {}) {
258
- const projects = await openProjects({ loadSessions });
259
- const project = projects.find((p) => p.name === projectName);
260
- if (!project) throw new Error(`project not open: ${projectName}`);
308
+ const project = await findOpenProject(projectCwd, loadSessions);
261
309
  const target = validatePath(path.join(project.cwd, '.claude', 'agents', `${name}.md`));
262
310
  try {
263
311
  await fsp.unlink(target);
@@ -268,9 +316,10 @@ async function removeOverride({
268
316
  }
269
317
 
270
318
  /**
271
- * Currently-open project tabs, deduped by cwd, as `{ cwd, name }` — `name`
272
- * is the last path segment (matches the `projectNameFromCwd` convention used
273
- * by the Scheduler's ProjectTag primitive). `loadSessions` is injectable
319
+ * Currently-open project tabs, deduped by NORMALIZED cwd (normalizeCwd), as
320
+ * `{ cwd, name }` — `cwd` is that normalized form (the override key callers
321
+ * match on); `name` is the last path segment, display-only and never a key
322
+ * (two open projects can share it). `loadSessions` is injectable
274
323
  * (mirrors scheduler.cjs's notifyOriginatingTab) so tests can exercise the
275
324
  * dedup/naming logic without touching the real persisted tabs.json.
276
325
  */
@@ -279,9 +328,11 @@ async function openProjects({ loadSessions = sessionsStore.load } = {}) {
279
328
  const seen = new Set();
280
329
  const projects = [];
281
330
  for (const t of tabs ?? []) {
282
- if (!t || typeof t.cwd !== 'string' || !t.cwd || seen.has(t.cwd)) continue;
283
- seen.add(t.cwd);
284
- projects.push({ cwd: t.cwd, name: path.basename(t.cwd.replace(/\/+$/, '')) || t.cwd });
331
+ if (!t || typeof t.cwd !== 'string' || !t.cwd) continue;
332
+ const cwd = normalizeCwd(t.cwd);
333
+ if (seen.has(cwd)) continue;
334
+ seen.add(cwd);
335
+ projects.push({ cwd, name: path.basename(cwd) || cwd });
285
336
  }
286
337
  return projects;
287
338
  }
@@ -340,7 +391,8 @@ async function listPersonas({
340
391
  const merged = resolveMergedPersona(p.cwd, path.basename(file, '.md'), { validatePath, globalDir });
341
392
  const fields = merged ? Object.keys(merged.provenance).filter((k) => merged.provenance[k] === 'overlay') : [];
342
393
  overrideDetails.push({
343
- project: p.name,
394
+ project: p.name, // display label only
395
+ cwd: p.cwd, // the override key (removeOverride / savePersona's projectCwd)
344
396
  fields,
345
397
  // The project's value for each overridden key (the UI renders global → project).
346
398
  values: merged ? Object.fromEntries(fields.map((k) => [k, merged.fm[k]])) : {},
@@ -2,7 +2,8 @@
2
2
 
3
3
  /**
4
4
  * agentsIpc.cjs — registers the `agents:*` IPC handlers (Agent Library CRUD + persona/model/effort
5
- * resolvers). Moved verbatim out of index.cjs; handler bodies and zod wrappers are unchanged.
5
+ * resolvers). Every handler that takes a payload parses it through ipcSchemas.cjs's
6
+ * `validated(...)` before agentLibrary (or a resolver) sees it.
6
7
  */
7
8
 
8
9
  const { schemas, validated } = require('./ipcSchemas.cjs');
@@ -16,18 +17,22 @@ const { sendIfAlive } = require('./lib/sendToRenderer.cjs');
16
17
  * @param {{ ipcMain: any, getWindow: () => any }} opts
17
18
  */
18
19
  function registerAgentsHandlers({ ipcMain, getWindow }) {
19
- // Agent Library nav page (Home face only): global `~/.claude/agents/*.md`
20
- // personas plus, per currently-open project tab, whether that project
21
- // overlays the same agent name at `<cwd>/.claude/agents/<name>.md`. Read-only.
20
+ // Agent Library nav page (Home face only) — its one read: every global
21
+ // `~/.claude/agents/*.md` persona plus, per currently-open project, that
22
+ // project's override at `<cwd>/.claude/agents/<name>.md` (overrideDetails,
23
+ // keyed by the project's cwd — the `projectCwd` the writes below take).
22
24
  ipcMain.handle('agents:list-personas', () => agentLibrary.listPersonas());
23
- // Agent Library CRUD — global personas only (`~/.claude/agents/*.md`); a
24
- // project's local overlay can only be removed here (removeOverride), never
25
- // created, since Agent Library is a Home-face, machine-wide surface with no
26
- // per-tab cwd context of its own. Each mutation broadcasts `agents:changed`
27
- // so Agent Library and Tag Library — two independently-mounted dockview
28
- // panels, each with its own component-local `listPersonas()` snapshot —
29
- // both refresh off the one file on disk instead of one panel going stale
30
- // after the other edits the agent<->tag relationship.
25
+ // Agent Library CRUD. Global personas (`~/.claude/agents/*.md`) are written
26
+ // by `agents:save-persona` and removed by `agents:delete-persona`. For a
27
+ // per-project override the page picks one of the open projects:
28
+ // `agents:save-persona` with that project's `projectCwd` writes its
29
+ // frontmatter-only override (model/effort only, at
30
+ // `<projectCwd>/.claude/agents/<name>.md`), and `agents:remove-override`
31
+ // with the same `projectCwd` drops it. Each mutation broadcasts
32
+ // `agents:changed` so Agent Library and Tag Library — two independently-
33
+ // mounted dockview panels, each with its own component-local
34
+ // `listPersonas()` snapshot — both refresh off the one file on disk instead
35
+ // of one panel going stale after the other edits the agent<->tag relationship.
31
36
  function broadcastAgentsChanged() {
32
37
  sendIfAlive(getWindow(), 'agents:changed', {});
33
38
  }
@@ -36,16 +41,16 @@ function registerAgentsHandlers({ ipcMain, getWindow }) {
36
41
  broadcastAgentsChanged();
37
42
  return result;
38
43
  }));
39
- ipcMain.handle('agents:delete-persona', async (_e, payload) => {
44
+ ipcMain.handle('agents:delete-persona', validated(schemas.agentsDeletePersona, async (payload) => {
40
45
  const result = await agentLibrary.deletePersona(payload);
41
46
  broadcastAgentsChanged();
42
47
  return result;
43
- });
44
- ipcMain.handle('agents:remove-override', async (_e, payload) => {
48
+ }));
49
+ ipcMain.handle('agents:remove-override', validated(schemas.agentsRemoveOverride, async (payload) => {
45
50
  const result = await agentLibrary.removeOverride(payload);
46
51
  broadcastAgentsChanged();
47
52
  return result;
48
- });
53
+ }));
49
54
  // New Epic AIM composer (epicIntake.ts's `agentBody`/`agentPath`): unlike
50
55
  // list-personas above (global dir only), this honors the project-overlay-
51
56
  // then-global precedence so an Epic's opening prompt carries the persona
@@ -1,8 +1,8 @@
1
1
  {
2
- "version": "0.130.2",
3
- "gitSha": "664aefcb5f51fbfb3e4c341ead029cce9da06edd",
4
- "gitShortSha": "664aefcb",
2
+ "version": "0.131.0",
3
+ "gitSha": "75165413d7e1a27fb22e9fd8dd33bd79a3575f07",
4
+ "gitShortSha": "75165413",
5
5
  "gitBranch": "HEAD",
6
- "builtAt": "2026-11-07T09:03:19.022Z",
6
+ "builtAt": "2026-11-08T19:23:10.874Z",
7
7
  "dirty": false
8
8
  }
@@ -38,6 +38,7 @@ const sessionsStore = require('./sessionsStore.cjs');
38
38
  const layoutStore = require('./layoutStore.cjs');
39
39
  const billing = require('./usage.cjs');
40
40
  const { probeMcpStatus } = require('./mcpStatus.cjs');
41
+ const { checkConfiguredMcpServer } = require('./lib/mcpToolsProbe.cjs');
41
42
  const logs = require('./logs.cjs');
42
43
  const crashDiagnostics = require('./crashDiagnostics.cjs');
43
44
  // Start the local minidump collector before app-ready (required by Electron).
@@ -593,6 +594,14 @@ ipcMain.handle('app:launch-mode', () => ({
593
594
  // `claude mcp list`. Read-only, single in-flight call — no polling.
594
595
  ipcMain.handle('mcp:status', () => probeMcpStatus());
595
596
 
597
+ // Extensions MCP detail: check ONE configured server on demand (initialize →
598
+ // tools/list, lib/mcpToolsProbe.cjs). The payload only NAMES the server; its
599
+ // config is read from disk in main, so the renderer can't choose what is spawned.
600
+ ipcMain.handle('mcp:check-server', validated(schemas.mcpCheckServer, async (p) => {
601
+ if (p.source === 'project') configMgr.validatePath(p.cwd);
602
+ return checkConfiguredMcpServer(p, { clientVersion: app.getVersion() });
603
+ }));
604
+
596
605
  // The Dashboard's "Agent tools" section (HomeAgentTools): the same catalog data
597
606
  // GET /admin/mcp/catalog serves to external callers, read in-process here so
598
607
  // the renderer never makes a direct HTTP call. Static data, no cwd needed.
@@ -12,9 +12,11 @@ const path = require('node:path');
12
12
  const { PromptSessionSchema, EpicTagSchema, EpicSourceSchema, EpicIntakeSectionSchema } = require('./lib/promptSessionSchema.cjs');
13
13
  const { PrdWorkTypeSchema } = require('./lib/prd/workTypeLibrary.cjs');
14
14
  const { PERSONA_NAME_RE } = require('./agentLibrary.cjs');
15
- const { AgentPersonaSaveSchema } = require('./lib/persona-macro/agentPersonaSchema.cjs');
15
+ const { AgentPersonaSaveSchema, PersonaNameSchema, ProjectCwdSchema } = require('./lib/persona-macro/agentPersonaSchema.cjs');
16
16
  const { MacroSaveSchema, MacroDeleteSchema, MacroSetProjectSchema, MacroRemoveFromProjectSchema, MacroInputSchema } = require('./lib/persona-macro/macroLibrary.cjs');
17
17
  const { MAX_SLOTS } = require('./lib/scheduler/sessionSlots.cjs');
18
+ // Aliased: this file already has a looser, exchanges-only SESSION_ID_RE (Exchanges section).
19
+ const { SESSION_ID_RE: RESTORABLE_SESSION_ID_RE } = require('./lib/epic/restorableSessions.cjs');
18
20
 
19
21
  // ──────────────────────────────────────────── PTY
20
22
  const ptySpawn = z.object({
@@ -235,8 +237,17 @@ const promptSessionsCreateEpic = z.object({
235
237
  // future scripted Epic) composes a full opening prompt.
236
238
  openingPrompt: z.string().max(200000).optional(),
237
239
  sections: z.array(EpicIntakeSectionSchema).max(200).optional(),
240
+ // Restore: adopt this project's existing Claude Code CLI session (a UUID —
241
+ // it becomes a transcript filename) instead of minting a fresh one. Absent =
242
+ // a normal mint; ensureEpic's restore gate decides whether the id may be adopted.
243
+ restoreSessionId: z.string().regex(RESTORABLE_SESSION_ID_RE).optional(),
238
244
  });
239
245
 
246
+ // Renderer entry point for the "Restore a session" picker: this project's CLI
247
+ // sessions no Epic owns yet (lib/epic/restorableSessions.cjs). The handler runs
248
+ // `cwd` through config.cjs's validatePath before any transcript dir is read.
249
+ const promptSessionsListRestorable = z.object({ cwd: z.string().min(1).max(4096) }).strict();
250
+
240
251
  // Renderer entry point for creating an Epic's isolated git worktree
241
252
  // (lib/epic/epicWorktreeMint.cjs) at the proposed->active transition — PRD 1033.
242
253
  const promptSessionsCreateWorktree = z.object({
@@ -663,6 +674,10 @@ const setSessionSlotsSchema = z.object({
663
674
  // Full field-level rules live in lib/persona-macro/agentPersonaSchema.cjs, mirroring
664
675
  // AgentPersonaSaveInput (src/preload/api.d.ts) field-for-field.
665
676
  const agentsSavePersona = AgentPersonaSaveSchema;
677
+ // agents:remove-override — an OPEN project's override, keyed by its absolute cwd (never a folder name).
678
+ const agentsRemoveOverride = z.object({ name: PersonaNameSchema, projectCwd: ProjectCwdSchema }).strict();
679
+ // agents:delete-persona — a kebab-case name only; `.strict()` also bars deletePersona's injectable `globalDir`.
680
+ const agentsDeletePersona = z.object({ name: PersonaNameSchema }).strict();
666
681
  // claudeConfig:read / claudeConfig:patch — mirrors ClaudeConfigReadInput /
667
682
  // ClaudeConfigPatchInput (src/preload/api.d.ts). fileId comes from the registry in
668
683
  // lib/claudeConfig.cjs; `value` absent => delete the key.
@@ -678,6 +693,20 @@ const claudeConfigPatch = z.object({
678
693
  keyPath: z.array(z.string().min(1).max(256)).min(1).max(8),
679
694
  value: z.unknown().optional(),
680
695
  }).strict();
696
+ // mcp:check-server — names WHICH configured server to check, never its config:
697
+ // main reads that from disk (lib/mcpToolsProbe.cjs checkConfiguredMcpServer), so
698
+ // the renderer can't make main spawn a command of its choosing. A project server
699
+ // needs its project's absolute cwd, a plugin server its installed key; neither
700
+ // field moves a server of another source.
701
+ const PLUGIN_KEY_RE = /^[a-z0-9][a-z0-9._\-]*@[a-z0-9][a-z0-9._\-]*$/i; // name@marketplace, as in installed_plugins.json
702
+ const mcpCheckServer = z.object({
703
+ source: z.enum(['user', 'project', 'plugin']),
704
+ name: z.string().min(1).max(128),
705
+ cwd: z.string().min(1).max(4096).refine((s) => path.isAbsolute(s), 'cwd must be absolute').optional(),
706
+ pluginKey: z.string().regex(PLUGIN_KEY_RE).max(256).optional(),
707
+ }).strict()
708
+ .refine((p) => p.source !== 'project' || p.cwd !== undefined, 'a project server needs its cwd')
709
+ .refine((p) => p.source !== 'plugin' || p.pluginKey !== undefined, 'a plugin server needs its pluginKey');
681
710
  const macrosSave = MacroSaveSchema;
682
711
  const macrosDelete = MacroDeleteSchema;
683
712
  const macrosSetProject = MacroSetProjectSchema;
@@ -1276,7 +1305,7 @@ const pluginsAbort = z.object({
1276
1305
  }).passthrough();
1277
1306
  const pluginsList = z.object({}).strict();
1278
1307
  const pluginsSetEnabled = z.object({
1279
- key: z.string().regex(/^[a-z0-9][a-z0-9._\-]*@[a-z0-9][a-z0-9._\-]*$/i).max(256),
1308
+ key: z.string().regex(PLUGIN_KEY_RE).max(256),
1280
1309
  enabled: z.boolean(),
1281
1310
  }).strict();
1282
1311
  const pluginsUninstall = z.object({
@@ -1496,6 +1525,7 @@ module.exports = {
1496
1525
  promptSessionsMergeActiveIndex,
1497
1526
  promptSessionsWriteArchive,
1498
1527
  promptSessionsCreateEpic,
1528
+ promptSessionsListRestorable,
1499
1529
  promptSessionsCreateWorktree,
1500
1530
  promptSessionsReopen,
1501
1531
  promptSessionsCwd,
@@ -1524,8 +1554,11 @@ module.exports = {
1524
1554
  remoteSessionPrds,
1525
1555
  exchangesList,
1526
1556
  agentsSavePersona,
1557
+ agentsRemoveOverride,
1558
+ agentsDeletePersona,
1527
1559
  claudeConfigRead,
1528
1560
  claudeConfigPatch,
1561
+ mcpCheckServer,
1529
1562
  macrosSave,
1530
1563
  macrosDelete,
1531
1564
  macrosSetProject,