claude-code-session-manager 0.130.3 → 0.132.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 (78) hide show
  1. package/dist/assets/{AgentLibrary-BmrXNwK8.js → AgentLibrary-C09MlPFx.js} +2 -2
  2. package/dist/assets/AppSettings-DvDKsCnD.js +2 -0
  3. package/dist/assets/{Button-UUr5giu8.js → Button-BzG_KdBC.js} +1 -1
  4. package/dist/assets/{DocumentEditorPane-C46Hj0lz.js → DocumentEditorPane-fm6zsnLM.js} +1 -1
  5. package/dist/assets/Extensions-DgxKT_OZ.js +2 -0
  6. package/dist/assets/{History-Bndupj87.js → History-Nd3bKjBq.js} +2 -2
  7. package/dist/assets/{Library-DFn0YPIW.js → Library-R71t6VAB.js} +12 -12
  8. package/dist/assets/{ListDetail-DjMn8a_3.js → ListDetail-CG50Ul7c.js} +1 -1
  9. package/dist/assets/{Panel-CIvb-XXN.js → Panel-C7EFG4eU.js} +1 -1
  10. package/dist/assets/{ProjectClaudeConfig-BQQRtMdK.js → ProjectClaudeConfig-J92iNEGC.js} +7 -7
  11. package/dist/assets/{ProvenanceBadge-ej8W2ZIK.js → ProvenanceBadge-C3KB3ILO.js} +1 -1
  12. package/dist/assets/Scheduler-DeYBA7uc.js +16 -0
  13. package/dist/assets/{Settings-DqxUna06.js → Settings-B6r7N4v-.js} +1 -1
  14. package/dist/assets/{SkillReferenceGraph-BEMTdxdD.js → SkillReferenceGraph-D7bt3fyB.js} +1 -1
  15. package/dist/assets/Skills-GpxtUrFP.js +29 -0
  16. package/dist/assets/{SourceChip-BrPci8FX.js → SourceChip-uyVMCZc7.js} +1 -1
  17. package/dist/assets/{SystemPrompt-B43hNP0X.js → SystemPrompt-Cv25uFSM.js} +1 -1
  18. package/dist/assets/{TiptapBody-B-R2Bpda.js → TiptapBody-uP8fJkbM.js} +1 -1
  19. package/dist/assets/{Toggle-DKb4x1BP.js → Toggle-DRs80cX-.js} +1 -1
  20. package/dist/assets/{ViewTabs-CcJdFZgv.js → ViewTabs-BDkvvzJ8.js} +1 -1
  21. package/dist/assets/{VoiceButton-BSH0UI3u.js → VoiceButton-Cmtz2sQt.js} +1 -1
  22. package/dist/assets/{historyTotals-5oUEu_fe.js → historyTotals-DHwAXunq.js} +1 -1
  23. package/dist/assets/index-CBCdyHbZ.js +3097 -0
  24. package/dist/assets/{index-CMCcT2yg.css → index-oXqzajWV.css} +1 -1
  25. package/dist/index.html +2 -2
  26. package/dist-web/app.css +1 -1
  27. package/dist-web/app.js +414 -390
  28. package/package.json +1 -1
  29. package/scripts/scheduler-mcp-server.cjs +83 -4
  30. package/src/main/build-info.json +4 -4
  31. package/src/main/index.cjs +11 -0
  32. package/src/main/ipcSchemas.cjs +28 -1
  33. package/src/main/lib/epic/epicMint.cjs +61 -6
  34. package/src/main/lib/epic/epicWorktreeMint.cjs +45 -4
  35. package/src/main/lib/epic/promptSessionsCreateEpic.cjs +32 -5
  36. package/src/main/lib/epic/restorableSessions.cjs +749 -0
  37. package/src/main/lib/feedback-remote/macroAdminRoutes.cjs +36 -13
  38. package/src/main/lib/feedback-remote/projectHomeAdminRoutes.cjs +61 -0
  39. package/src/main/lib/feedback-remote/remoteIpcDispatch.cjs +2 -0
  40. package/src/main/lib/git/branchSweep.cjs +9 -3
  41. package/src/main/lib/git/gitExec.cjs +8 -1
  42. package/src/main/lib/git/gitWorktree.cjs +564 -62
  43. package/src/main/lib/git/jobWorktree.cjs +3 -0
  44. package/src/main/lib/git/jobWorktreeBootLive.cjs +14 -2
  45. package/src/main/lib/mcpToolCatalog.cjs +43 -6
  46. package/src/main/lib/mcpToolsProbe.cjs +831 -0
  47. package/src/main/lib/persona-macro/builtinMacros.cjs +33 -0
  48. package/src/main/lib/persona-macro/macroJobDispatch.cjs +8 -0
  49. package/src/main/lib/persona-macro/macroJobIpc.cjs +57 -11
  50. package/src/main/lib/persona-macro/macroLibrary.cjs +40 -10
  51. package/src/main/lib/persona-macro/shippedPersonaSeeds.cjs +38 -0
  52. package/src/main/lib/project-pages/competitiveMatrix.cjs +258 -0
  53. package/src/main/lib/project-pages/matrixHtml.cjs +239 -0
  54. package/src/main/lib/project-pages/matrixStore.cjs +112 -0
  55. package/src/main/lib/promptSessionSchema.cjs +5 -0
  56. package/src/main/lib/scheduler/fixPlanSlug.cjs +15 -1
  57. package/src/main/lib/scheduler/reaperHelpers.cjs +35 -0
  58. package/src/main/lib/scheduler/scheduleJobSchema.cjs +2 -0
  59. package/src/main/lib/scheduler/scheduleJobTransitions.cjs +8 -7
  60. package/src/main/projectPages.cjs +25 -2
  61. package/src/main/promptSessionEvents.cjs +10 -6
  62. package/src/main/runVerify.cjs +8 -3
  63. package/src/main/scheduler/budget.cjs +146 -7
  64. package/src/main/scheduler/gitTreeGuard.cjs +10 -11
  65. package/src/main/scheduler/reviewLadder.cjs +60 -0
  66. package/src/main/scheduler.cjs +461 -48
  67. package/src/main/seedAgentPersonas.cjs +1 -1
  68. package/src/preload/api.d.ts +162 -2
  69. package/src/preload/apiSurface.json +21 -0
  70. package/src/preload/index.cjs +5 -0
  71. package/src/seed/agents/competitive-analyst.md +69 -0
  72. package/src/seed/agents/competitive-researcher.md +75 -0
  73. package/src/seed/agents/validator.md +2 -2
  74. package/dist/assets/AppSettings-Cs4POznd.js +0 -2
  75. package/dist/assets/Extensions-B9QdiNOV.js +0 -2
  76. package/dist/assets/Scheduler-DSVBWqRK.js +0 -16
  77. package/dist/assets/Skills-DTXehVS7.js +0 -12
  78. package/dist/assets/index-C9w-dVzo.js +0 -3090
@@ -14,7 +14,10 @@
14
14
  * cwd resolution matches projectHomeAdminRoutes.cjs's resolveCwd exactly
15
15
  * (reused, not copied). `surface` ('sessions' | 'project-home') is accepted on
16
16
  * create and update; a create defaults it to 'sessions' and `projects` to
17
- * [resolvedCwd]. `projects` is accepted ONLY as exactly ["*"] (show in every
17
+ * [resolvedCwd]. A Project Home tool is part of Session Manager and shown in
18
+ * every project's Project Home, so any save whose resulting surface is
19
+ * 'project-home' stores projects ["*"]; only what it generates is per project.
20
+ * `projects` is accepted ONLY as exactly ["*"] (show in every
18
21
  * project); anything else is a 400. An update without `projects` leaves them
19
22
  * unchanged. An update is refused (400) if the macro is not visible to the
20
23
  * resolved cwd (macroLibrary.macroVisibleIn, so '*' macros are reachable), if
@@ -24,7 +27,7 @@
24
27
  * A save whose existing or resulting macro is shown in every project needs a
25
28
  * VERIFIED human request: body.humanRequestQuote must appear in a prompt the
26
29
  * human typed into body.originClaudeSessionId (humanPromptLedger) AND name
27
- * every/all projects. Otherwise 400, no write, no onChanged, no audit.
30
+ * every/all projects (or, for a 'project-home' macro, Project Home). Otherwise 400, no write, no onChanged, no audit.
28
31
  *
29
32
  * Every successful save appends one `admin_macro_save` audit event and calls
30
33
  * `onChanged()` exactly once so the Sessions HOT KEYS strip updates live,
@@ -47,23 +50,36 @@ function quoteNamesEveryProject(quote) {
47
50
  return EVERY_PROJECT_RE.test(q) || /(^|[^a-z0-9])everywhere($|[^a-z0-9])/.test(q);
48
51
  }
49
52
 
53
+ const PROJECT_HOME_RE = /(^|[^a-z0-9])project\s*home($|[^a-z0-9])/;
54
+
55
+ /** True when the quote names Project Home (project home / project-home / project_home). */
56
+ function quoteNamesProjectHome(quote) {
57
+ if (typeof quote !== 'string') return false;
58
+ const q = quote.toLowerCase().replace(/[-_]/g, ' ');
59
+ return PROJECT_HOME_RE.test(q);
60
+ }
61
+
50
62
  const HUMAN_HINT = "the human can set 'Show in every project' in the macro editor";
63
+ const PROJECT_HOME_HINT =
64
+ "a Project Home tool is shown in every project's Project Home, so it needs humanRequestQuote (the human's words asking for a Project Home tool); the human can add one from Project Home ▸ Tools ▸ Add a tool";
51
65
 
52
- /** Fail-closed check that a human asked for an all-projects macro. */
53
- function verifyAllProjectsRequest(body) {
66
+ /** Fail-closed check that a human asked for an all-projects macro (or a Project Home tool). */
67
+ function verifyAllProjectsRequest(body, { projectHome = false } = {}) {
68
+ const hint = projectHome ? PROJECT_HOME_HINT : HUMAN_HINT;
54
69
  const quote = body.humanRequestQuote;
55
70
  if (typeof quote !== 'string' || !quote.trim()) {
56
- return { ok: false, reason: `a macro shown in every project needs humanRequestQuote (a verbatim human request); ${HUMAN_HINT}` };
71
+ return { ok: false, reason: `a macro shown in every project needs humanRequestQuote (a verbatim human request); ${hint}` };
57
72
  }
58
73
  const origin = body.originClaudeSessionId;
59
74
  if (typeof origin !== 'string' || origin.length < 1 || origin.length > 128) {
60
- return { ok: false, reason: `a macro shown in every project needs originClaudeSessionId (1-128 chars); ${HUMAN_HINT}` };
75
+ return { ok: false, reason: `a macro shown in every project needs originClaudeSessionId (1-128 chars); ${hint}` };
61
76
  }
62
77
  if (!findHumanPromptContaining(origin, quote)) {
63
- return { ok: false, reason: `humanRequestQuote was not found in a prompt the human typed in this session; ${HUMAN_HINT}` };
78
+ return { ok: false, reason: `humanRequestQuote was not found in a prompt the human typed in this session; ${hint}` };
64
79
  }
65
- if (!quoteNamesEveryProject(quote)) {
66
- return { ok: false, reason: `humanRequestQuote does not name every/all projects; ${HUMAN_HINT}` };
80
+ if (!quoteNamesEveryProject(quote) && !(projectHome && quoteNamesProjectHome(quote))) {
81
+ const named = projectHome ? 'Project Home or every/all projects' : 'every/all projects';
82
+ return { ok: false, reason: `humanRequestQuote does not name ${named}; ${hint}` };
67
83
  }
68
84
  return { ok: true, quote };
69
85
  }
@@ -153,10 +169,12 @@ function saveHandler(onChanged, libOpts) {
153
169
  return;
154
170
  }
155
171
  }
156
- const allProjects = Boolean(existing?.projects.includes(macroLibrary.ALL_PROJECTS)) || wantsAll;
172
+ const resultSurface = input.surface ?? existing?.surface ?? 'sessions';
173
+ const projectHome = resultSurface === 'project-home';
174
+ const allProjects = Boolean(existing?.projects.includes(macroLibrary.ALL_PROJECTS)) || wantsAll || projectHome;
157
175
  let quote = null;
158
176
  if (allProjects) {
159
- const v = verifyAllProjectsRequest(body);
177
+ const v = verifyAllProjectsRequest(body, { projectHome });
160
178
  if (!v.ok) {
161
179
  sendJson(res, 400, { ok: false, error: v.reason });
162
180
  return;
@@ -164,8 +182,12 @@ function saveHandler(onChanged, libOpts) {
164
182
  quote = v.quote;
165
183
  }
166
184
  if (!input.id) {
167
- input = { ...input, projects: wantsAll ? [macroLibrary.ALL_PROJECTS] : [resolved.cwd], surface: input.surface ?? 'sessions' };
168
- } else if (wantsAll) {
185
+ input = {
186
+ ...input,
187
+ projects: wantsAll || projectHome ? [macroLibrary.ALL_PROJECTS] : [resolved.cwd],
188
+ surface: input.surface ?? 'sessions',
189
+ };
190
+ } else if (wantsAll || projectHome) {
169
191
  input = { ...input, projects: [macroLibrary.ALL_PROJECTS] };
170
192
  }
171
193
  let macro;
@@ -238,4 +260,5 @@ function registerAdminRoute(adminHttp, { onChanged } = {}, opts = {}) {
238
260
  module.exports = {
239
261
  registerAdminRoute,
240
262
  quoteNamesEveryProject,
263
+ quoteNamesProjectHome,
241
264
  };
@@ -4,6 +4,8 @@
4
4
  * POST /admin/project-home/videos/write -> project-pages/videos/<videoId>/{index.html,meta.json}
5
5
  * POST /admin/project-home/write alias: {cwd, html} -> knowledge/overview/
6
6
  * POST /admin/project-home/demo-video/write alias: {cwd, html} -> a new videos/vid-<id>/ project-demo entry
7
+ * POST /admin/project-home/matrix/read {cwd} -> project-pages/matrix/matrix.json (+ its JSON Schema)
8
+ * POST /admin/project-home/matrix/write {cwd, matrix, model?} -> matrixStore.writeMatrix
7
9
  * all owned by writer 'project-home' (see opsOwnership.cjs). Registered
8
10
  * against the same injected localAdminHttp.cjs transport as
9
11
  * prdAdminRoutes.cjs.
@@ -32,6 +34,8 @@ const { schemas, ENTRY_ID_RE } = require('../../ipcSchemas.cjs');
32
34
  const { validateCharacterJson, validateCharacterJs, readCharacter, characterDir, MAX_JS_BYTES: MAX_CHARACTER_JS_BYTES } = require('../demo-video-kit/character.cjs');
33
35
  const { checkHtmlLimits } = require('../demo-video-kit/checks.cjs');
34
36
  const { injectPlayerBridge } = require('../project-pages/playerBridge.cjs');
37
+ const { readMatrix, matrixJsonSchema, MAX_MATRIX_BYTES } = require('../project-pages/competitiveMatrix.cjs');
38
+ const { writeMatrix } = require('../project-pages/matrixStore.cjs');
35
39
 
36
40
  const MAX_HTML_BYTES = 1024 * 1024;
37
41
  const MAX_DEMO_VIDEO_BYTES = 2 * 1024 * 1024;
@@ -228,8 +232,14 @@ function maxVideoBytes(lengthS) {
228
232
  return Math.ceil(lengthS / 30) * MAX_DEMO_VIDEO_BYTES;
229
233
  }
230
234
 
235
+ // Owned by the Competitor matrix store (project-pages/matrixStore.cjs writes
236
+ // knowledge/<id>/ directly). Kept local on purpose; macroJobDispatch.cjs holds
237
+ // the same constant so the builder never derives this id.
238
+ const MATRIX_PAGE_ID = 'competitive-matrix';
239
+
231
240
  function buildPage(input, { pageId, title, topic }) {
232
241
  if (!ENTRY_ID_RE.test(pageId)) return { error: 'invalid pageId' };
242
+ if (pageId === MATRIX_PAGE_ID) return { error: `pageId '${MATRIX_PAGE_ID}' is reserved for the Competitor matrix (written by project_matrix_write)` };
233
243
  const rejection = validateHomeHtml(input.html);
234
244
  if (rejection) return { error: rejection };
235
245
  return {
@@ -330,6 +340,57 @@ function registerAdminRoute(adminHttp) {
330
340
 
331
341
  // POST /admin/project-home/character/write {cwd, json, js, replace?} -> videos/_character/
332
342
  adminHttp.registerRoute('POST', '/admin/project-home/character/write', characterWriteHandler);
343
+
344
+ // POST /admin/project-home/matrix/read {cwd?} -> {ok, matrix|null, error, path, schema}
345
+ adminHttp.registerRoute('POST', '/admin/project-home/matrix/read', makeMatrixHandler(async (cwd) => {
346
+ const r = await readMatrix(cwd);
347
+ return { status: 200, body: { ok: true, matrix: r.matrix, error: r.error, path: r.path, schema: matrixJsonSchema() } };
348
+ }));
349
+
350
+ // POST /admin/project-home/matrix/write {cwd?, matrix, model?} -> writeMatrix's result
351
+ adminHttp.registerRoute('POST', '/admin/project-home/matrix/write', makeMatrixHandler(async (cwd, body) => {
352
+ if (body.model !== undefined && typeof body.model !== 'string') {
353
+ return { status: 400, body: { ok: false, error: 'model must be a string' } };
354
+ }
355
+ config.addAllowedRoot(cwd);
356
+ const r = await writeMatrix(cwd, body.matrix, { model: body.model ?? '' });
357
+ return { status: r.ok ? 200 : 400, body: r };
358
+ }));
359
+ }
360
+
361
+ /** JSON body (capped at MAX_MATRIX_BYTES + 64 KB) + resolveCwd, then `run(cwd, body)` -> {status, body}. */
362
+ function makeMatrixHandler(run) {
363
+ return async (req, res) => {
364
+ let raw;
365
+ try {
366
+ raw = await readBody(req, MAX_MATRIX_BYTES + 64 * 1024);
367
+ } catch (e) {
368
+ sendJson(res, 413, { ok: false, error: `request body rejected: ${e?.message ?? 'unreadable'} (matrix limit is ${MAX_MATRIX_BYTES} bytes)` });
369
+ return;
370
+ }
371
+ let body;
372
+ try {
373
+ body = raw ? JSON.parse(raw) : {};
374
+ } catch {
375
+ sendJson(res, 400, { ok: false, error: 'invalid JSON body' });
376
+ return;
377
+ }
378
+ if (!body || typeof body !== 'object' || Array.isArray(body)) {
379
+ sendJson(res, 400, { ok: false, error: 'invalid payload' });
380
+ return;
381
+ }
382
+ const resolved = resolveCwd(body.cwd);
383
+ if (!resolved.ok) {
384
+ sendJson(res, resolved.status, { ok: false, error: resolved.error });
385
+ return;
386
+ }
387
+ try {
388
+ const out = await run(resolved.cwd, body);
389
+ sendJson(res, out.status, out.body);
390
+ } catch (e) {
391
+ sendJson(res, 500, { ok: false, error: e?.message ?? 'matrix route failed' });
392
+ }
393
+ };
333
394
  }
334
395
 
335
396
  async function characterWriteHandler(req, res) {
@@ -62,6 +62,8 @@ const PATH_FENCED_CHANNELS = Object.freeze({
62
62
  'promptSessions:read-session-transcript': { field: 'cwd', mode: 'root' },
63
63
  // Project Home > Tools > Review MD network link map (main/projectPages.cjs): cwd inside a registered root.
64
64
  'project-pages:md-network': { field: 'cwd', mode: 'root' },
65
+ // Project Home ▸ Tools ▸ Competitor matrix (main/projectPages.cjs): read-only, cwd inside a registered root.
66
+ 'project-pages:matrix': { field: 'cwd', mode: 'root' },
65
67
  })
66
68
 
67
69
  const SECRET_DIRS = new Set(['.ssh', '.gnupg', '.aws', '.kube', '.docker', '.password-store', '.azure', '.terraform.d'])
@@ -90,12 +90,18 @@ async function sweepStrandedJobBranches({ cwd, jobs, attemptedBranches }) {
90
90
  results.push({ branch, slug, action: 'skip-checked-out' });
91
91
  continue;
92
92
  }
93
- const merged = await gitWorktree.isBranchMergedIntoHead(cwd, branch);
93
+ const row = slug ? jobsBySlug.get(slug) : null;
94
+ // forkSha bounds both the merged check and integration at the branch's own
95
+ // commits: after main is rebased/reset, the pre-rewrite commits it inherited
96
+ // must neither be replayed back nor keep a replay-landed branch "unmerged".
97
+ const forkSha = await gitWorktree.resolveForkSha({
98
+ cwd, branch, recorded: (row && row.worktreeForkSha) || null,
99
+ });
100
+ const merged = await gitWorktree.isBranchMergedIntoHead(cwd, branch, forkSha);
94
101
  if (merged) {
95
102
  results.push({ branch, slug, action: 'no-op-merged' });
96
103
  continue;
97
104
  }
98
- const row = slug ? jobsBySlug.get(slug) : null;
99
105
  const terminalOrMissing = !row || TERMINAL_JOB_STATUSES.has(row.status);
100
106
  if (!terminalOrMissing) {
101
107
  results.push({ branch, slug, action: 'skip-active-row' });
@@ -114,7 +120,7 @@ async function sweepStrandedJobBranches({ cwd, jobs, attemptedBranches }) {
114
120
  // branch (no row at all) has nothing to read, so it falls back to
115
121
  // resolveDefaultBranch(cwd), same as before.
116
122
  const integration = await gitWorktree.integrateJobBranch({
117
- cwd, branch, slug: slug || branch, baseBranch: (row && row.worktreeBaseBranch) || null,
123
+ cwd, branch, slug: slug || branch, baseBranch: (row && row.worktreeBaseBranch) || null, forkSha,
118
124
  });
119
125
  results.push({ branch, slug, action: integration.ok ? 'integrated' : 'conflict', integration });
120
126
  }
@@ -76,4 +76,11 @@ function parseWorktreePorcelain(text) {
76
76
  */
77
77
  const STRANDED_REF_PREFIX = 'refs/sm-stranded/';
78
78
 
79
- module.exports = { execGit, parseWorktreePorcelain, STRANDED_REF_PREFIX };
79
+ /**
80
+ * Namespace for snapshot commits of a checkout's UNCOMMITTED work, taken just
81
+ * before the checkout is removed (gitWorktree.snapshotUncommittedWork). Same
82
+ * outside-refs/heads reasoning as STRANDED_REF_PREFIX.
83
+ */
84
+ const UNCOMMITTED_REF_PREFIX = 'refs/sm-uncommitted/';
85
+
86
+ module.exports = { execGit, parseWorktreePorcelain, STRANDED_REF_PREFIX, UNCOMMITTED_REF_PREFIX };