claude-code-session-manager 0.127.0 → 0.129.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 (91) hide show
  1. package/.claude-plugin/marketplace.json +1 -1
  2. package/README.md +2 -0
  3. package/dist/assets/{AgentLibrary-DKQznr7o.js → AgentLibrary-Cp250YHF.js} +1 -1
  4. package/dist/assets/{Button-CZXqmIiM.js → Button-DU5UF-6L.js} +1 -1
  5. package/dist/assets/{DataModel-piyV33To.js → DataModel-CPf6f17e.js} +1 -1
  6. package/dist/assets/{History-BxwtrKF2.js → History-B2x-LMlT.js} +1 -1
  7. package/dist/assets/{Hooks-DogeSPII.js → Hooks-BWr33C4Q.js} +1 -1
  8. package/dist/assets/{Library-BDt6EeQQ.js → Library-DBNLTAa8.js} +1 -1
  9. package/dist/assets/{ListDetail-CwS-LKar.js → ListDetail-BGBw6egp.js} +1 -1
  10. package/dist/assets/{McpServers-D2HVljgS.js → McpServers-DywZ50Ec.js} +1 -1
  11. package/dist/assets/{Memory-hNzuOGn8.js → Memory-CnalwnFf.js} +1 -1
  12. package/dist/assets/{Panel-BLDrsUeq.js → Panel-BzIklgKf.js} +1 -1
  13. package/dist/assets/{Permissions-DzZ5vaJW.js → Permissions-mgRifwQc.js} +1 -1
  14. package/dist/assets/{Plugins-Cz9yaxzG.js → Plugins-CV42zfid.js} +2 -2
  15. package/dist/assets/{ProvenanceBadge-CCgLO4m9.js → ProvenanceBadge-DYmX4xgB.js} +1 -1
  16. package/dist/assets/{SaveBar-Shmn699J.js → SaveBar-DxrAfnlC.js} +1 -1
  17. package/dist/assets/{Scheduler-Bqr0WHNd.js → Scheduler-iyUl1NDl.js} +1 -1
  18. package/dist/assets/{ScopeSwitcher-CBx1fB5g.js → ScopeSwitcher-CC8BDPgf.js} +1 -1
  19. package/dist/assets/{Settings-Ci8in-yF.js → Settings-CWBnQghD.js} +1 -1
  20. package/dist/assets/{SkillReferenceGraph-BWwljba8.js → SkillReferenceGraph-DOhiCxuL.js} +1 -1
  21. package/dist/assets/{Skills-BON6o-c4.js → Skills-3Er-9YA9.js} +1 -1
  22. package/dist/assets/{SystemPrompt-D5epIYYs.js → SystemPrompt-BLxdvZ9K.js} +1 -1
  23. package/dist/assets/{TagLibrary-C2qDZROJ.js → TagLibrary-BZ6QHYMQ.js} +1 -1
  24. package/dist/assets/{TiptapBody-SZhI3-bW.js → TiptapBody-Du6jRBoW.js} +1 -1
  25. package/dist/assets/{Toggle-C_qFDG0g.js → Toggle-Qdi2Z7VD.js} +1 -1
  26. package/dist/assets/{ViewTabs-C9q5WCEd.js → ViewTabs-BKfFsziD.js} +1 -1
  27. package/dist/assets/{historyTotals-BCl7IOhY.js → historyTotals-8ecP_6wF.js} +1 -1
  28. package/dist/assets/{index-BnKaYERU.css → index-DtdWBGrI.css} +1 -1
  29. package/dist/assets/index-GI6F_j41.js +3083 -0
  30. package/dist/assets/{settingsSchema-BBrRBrBr.js → settingsSchema-lHTHAabD.js} +1 -1
  31. package/dist/assets/{skillFrontmatter-B01qJk6N.js → skillFrontmatter-8X1Uc282.js} +1 -1
  32. package/dist/assets/{useAgentsDirWatch-CuR3GSjS.js → useAgentsDirWatch-CcsoD1bp.js} +1 -1
  33. package/dist/index.html +2 -2
  34. package/dist-web/app.css +1 -1
  35. package/dist-web/app.js +373 -369
  36. package/package.json +1 -1
  37. package/plugins/session-manager-dev/.claude-plugin/plugin.json +1 -1
  38. package/plugins/session-manager-dev/skills/develop/SKILL.md +4 -2
  39. package/scripts/hooks/lib/guard-inline-implementation-policy.cjs +10 -0
  40. package/scripts/scheduler-mcp-server.cjs +170 -6
  41. package/src/main/build-info.json +4 -4
  42. package/src/main/chatRunner.cjs +8 -0
  43. package/src/main/index.cjs +27 -0
  44. package/src/main/ipcSchemas.cjs +110 -1
  45. package/src/main/lib/claude/agentModelResolve.cjs +31 -10
  46. package/src/main/lib/claude/effectiveModelInfo.cjs +14 -4
  47. package/src/main/lib/claude/modelCatalog.cjs +28 -1
  48. package/src/main/lib/claude/personaToolScope.cjs +40 -2
  49. package/src/main/lib/demo-video-kit/capture.cjs +113 -0
  50. package/src/main/lib/demo-video-kit/character.cjs +97 -0
  51. package/src/main/lib/demo-video-kit/checks.cjs +150 -0
  52. package/src/main/lib/demo-video-kit/frames.cjs +200 -0
  53. package/src/main/lib/demo-video-kit/seedKit.cjs +52 -0
  54. package/src/main/lib/demo-video-kit/sound.cjs +312 -0
  55. package/src/main/lib/epic/developLoopSpawn.cjs +18 -0
  56. package/src/main/lib/epic/epicMint.cjs +4 -2
  57. package/src/main/lib/epic/epicValidationHook.cjs +17 -1
  58. package/src/main/lib/epic/promptSessionsCreateEpic.cjs +4 -3
  59. package/src/main/lib/feedback-remote/crossProjectFeedback.cjs +21 -21
  60. package/src/main/lib/feedback-remote/projectHomeAdminRoutes.cjs +185 -34
  61. package/src/main/lib/feedback-remote/remoteIpcDispatch.cjs +15 -0
  62. package/src/main/lib/mcpToolCatalog.cjs +71 -11
  63. package/src/main/lib/opsOwnership.cjs +9 -5
  64. package/src/main/lib/persona-macro/builtinMacros.cjs +19 -5
  65. package/src/main/lib/persona-macro/macroJobDispatch.cjs +116 -0
  66. package/src/main/lib/persona-macro/macroJobIpc.cjs +50 -0
  67. package/src/main/lib/persona-macro/macroJobStatus.cjs +112 -0
  68. package/src/main/lib/persona-macro/macroLibrary.cjs +16 -0
  69. package/src/main/lib/persona-macro/shippedPersonaSeeds.cjs +113 -0
  70. package/src/main/lib/prd/prdCreate.cjs +27 -1
  71. package/src/main/lib/prd/prdFrontmatter.cjs +7 -2
  72. package/src/main/lib/project-pages/pagesLibrary.cjs +171 -0
  73. package/src/main/lib/project-pages/playerBridge.cjs +129 -0
  74. package/src/main/lib/promptSessionSchema.cjs +8 -0
  75. package/src/main/lib/scheduler/scheduleJobSchema.cjs +2 -0
  76. package/src/main/lib/smfileHeaders.cjs +11 -3
  77. package/src/main/projectPages.cjs +107 -30
  78. package/src/main/promptSessionsIpc.cjs +131 -0
  79. package/src/main/scheduler/prdParser.cjs +2 -0
  80. package/src/main/scheduler.cjs +26 -9
  81. package/src/main/seedSchedulerMcp.cjs +10 -1
  82. package/src/main/transcripts.cjs +8 -0
  83. package/src/main/webRemote.cjs +3 -1
  84. package/src/preload/api.d.ts +107 -6
  85. package/src/preload/apiSurface.json +77 -0
  86. package/src/preload/index.cjs +18 -0
  87. package/src/seed/agents/architect.md +8 -8
  88. package/src/seed/agents/demo-video-builder.md +86 -36
  89. package/src/seed/agents/project-home-builder.md +26 -13
  90. package/dist/assets/index-CMIYLbPb.js +0 -3079
  91. package/src/main/lib/epic/epicStandingInstructions.cjs +0 -73
@@ -186,23 +186,20 @@ function seriesLine(series) {
186
186
  * → { goalText, openingPrompt, sections }
187
187
  *
188
188
  * Pure. Mirrors the renderer's `composeEpicIntake` (lib/epicIntake.ts) —
189
- * same `EpicIntakeSection` shape, same emission order, same '\n\n' joins — so
190
- * the receiving Epic's first turn renders the identical AIM briefing card as a
191
- * hand-created one. It cannot import that module (TS, renderer-side), so it
192
- * deliberately emits only the section kinds whose text it OWNS:
189
+ * same `EpicIntakeSection` shape: kind = AIM slot (actor | input | mission)
190
+ * plus `part`. It cannot import that module (TS, renderer-side), so it emits
191
+ * only the parts whose text it OWNS, in AIM order:
193
192
  *
194
- * actor — the persona line, same sentence template as composeEpicIntake
195
- * input — AIM's Input axis: what grounds this session. For an inbound
196
- * report that is literally "an external report from Project-A",
197
- * which is this module's own fact to state.
198
- * goal — the report itself.
199
- * reference — attached paths.
193
+ * actor / persona — the persona line, same sentence template
194
+ * input / grounding — "an external report from Project-A", this module's fact
195
+ * input / reference — attached paths (before the report)
196
+ * mission / goal — the report itself
200
197
  *
201
- * There is NO `mission` section, on purpose. A mission section's text is the
202
- * tag's `initialPromptTemplate`, which lives in agentTagDefs.ts; re-typing it
203
- * here would be a second, drifting copy of a tag's meaning — the exact thing
204
- * CLAUDE.md forbids. The Epic still carries its `tag` field, so every surface
205
- * that renders a tag's meaning keeps reading it through `agentTagDef(tag)`.
198
+ * There is NO job-type part, on purpose. Its text is the tag's
199
+ * `initialPromptTemplate`, which lives in renderer-only agentTagDefs.ts;
200
+ * re-typing it here would be a second, drifting copy of a tag's meaning, and
201
+ * the auto-start path recomposes the full prompt through composeEpicIntake.
202
+ * The Epic still carries its `tag` field.
206
203
  *
207
204
  * Complexity: O(n) in the number of references.
208
205
  */
@@ -228,6 +225,7 @@ function composeFeedbackIntake({
228
225
  if (agentName && agentDescription) {
229
226
  sections.push({
230
227
  kind: 'actor',
228
+ part: 'persona',
231
229
  label: 'Actor',
232
230
  text: `You are acting as the "${singleLine(agentName)}" agent: ${singleLine(agentDescription)}`,
233
231
  source: agentName,
@@ -242,7 +240,8 @@ function composeFeedbackIntake({
242
240
  const askClause = originAsk ? ` It was raised while working on: ${singleLine(originAsk)}.` : '';
243
241
  sections.push({
244
242
  kind: 'input',
245
- label: 'Input',
243
+ part: 'grounding',
244
+ label: 'Grounding',
246
245
  text:
247
246
  `This session is INBOUND FEEDBACK from another project: ${origin}.${askClause} `
248
247
  + 'Nobody in this project wrote the report below — an agent working in that project did, and it '
@@ -263,18 +262,19 @@ function composeFeedbackIntake({
263
262
  blocks.push(`## Details\n${trimmedBody}`);
264
263
  const structured = blocks.join('\n\n');
265
264
 
266
- const goalBody = trimmedTitle ? `Goal: ${trimmedTitle}\n\n${structured}` : structured;
267
- sections.push({ kind: 'goal', label: 'Goal', text: goalBody });
268
-
269
265
  for (const p of referencePaths) {
270
- sections.push({ kind: 'reference', label: 'Reference', text: `Reference: ${singleLine(p)}`, source: p });
266
+ sections.push({ kind: 'input', part: 'reference', label: 'Reference', text: `Reference: ${singleLine(p)}`, source: p });
271
267
  }
272
268
 
269
+ const goalBody = trimmedTitle ? `Goal: ${trimmedTitle}\n\n${structured}` : structured;
270
+ sections.push({ kind: 'mission', part: 'goal', label: 'Goal', text: goalBody });
271
+
272
+ // Part names are string literals: keep in step with AimPart in src/renderer/lib/epicIntake.ts.
273
273
  // Same join rule as epicIntake.ts's joinSections: '\n\n' everywhere except
274
274
  // between two consecutive reference lines, which stay one visual block.
275
275
  const openingPrompt = sections.reduce((out, s, i) => {
276
276
  if (i === 0) return s.text;
277
- const sep = s.kind === 'reference' && sections[i - 1].kind === 'reference' ? '\n' : '\n\n';
277
+ const sep = s.part === 'reference' && sections[i - 1].part === 'reference' ? '\n' : '\n\n';
278
278
  return out + sep + s.text;
279
279
  }, '');
280
280
 
@@ -1,9 +1,10 @@
1
1
  /**
2
- * projectHomeAdminRoutes.cjs — the two admin routes behind the
3
- * project_home_write MCP tool and its demo-video sibling:
4
- * POST /admin/project-home/write {cwd, html} -> project-pages/home.html
5
- * POST /admin/project-home/demo-video/write {cwd, html} -> project-pages/demo-video/index.html
6
- * both owned by writer 'project-home' (see opsOwnership.cjs). Registered
2
+ * projectHomeAdminRoutes.cjs — admin routes behind Project Home's library:
3
+ * POST /admin/project-home/pages/write -> project-pages/knowledge/<pageId>/{index.html,meta.json}
4
+ * POST /admin/project-home/videos/write -> project-pages/videos/<videoId>/{index.html,meta.json}
5
+ * POST /admin/project-home/write alias: {cwd, html} -> knowledge/overview/
6
+ * POST /admin/project-home/demo-video/write alias: {cwd, html} -> a new videos/vid-<id>/ project-demo entry
7
+ * all owned by writer 'project-home' (see opsOwnership.cjs). Registered
7
8
  * against the same injected localAdminHttp.cjs transport as
8
9
  * prdAdminRoutes.cjs.
9
10
  *
@@ -22,11 +23,15 @@
22
23
 
23
24
  const fs = require('node:fs');
24
25
  const path = require('node:path');
26
+ const crypto = require('node:crypto');
25
27
  const { readBody, sendJson } = require('./localAdminHttp.cjs');
26
28
  const { resolveProjectContext } = require('../projectRootResolve.cjs');
27
29
  const { opsPath, OPS_ROOT_DIR } = require('../opsOwnership.cjs');
28
30
  const config = require('../../config.cjs');
29
- const { schemas } = require('../../ipcSchemas.cjs');
31
+ const { schemas, ENTRY_ID_RE } = require('../../ipcSchemas.cjs');
32
+ const { validateCharacterJson, validateCharacterJs, readCharacter, characterDir, MAX_JS_BYTES: MAX_CHARACTER_JS_BYTES } = require('../demo-video-kit/character.cjs');
33
+ const { checkHtmlLimits } = require('../demo-video-kit/checks.cjs');
34
+ const { injectPlayerBridge } = require('../project-pages/playerBridge.cjs');
30
35
 
31
36
  const MAX_HTML_BYTES = 1024 * 1024;
32
37
  const MAX_DEMO_VIDEO_BYTES = 2 * 1024 * 1024;
@@ -72,7 +77,7 @@ const NETWORK_CHECKS = [
72
77
 
73
78
  const DURATION_META_RE = /<meta\b[^>]*\bname\s*=\s*["']sm-demo-duration["'][^>]*\bcontent\s*=\s*["'](\d+)["'][^>]*>/i;
74
79
  const MIN_DEMO_DURATION_S = 5;
75
- const MAX_DEMO_DURATION_S = 30;
80
+ const MAX_DEMO_DURATION_S = 60;
76
81
 
77
82
  const DEMO_VIDEO_CSP = '<meta http-equiv="Content-Security-Policy" content="default-src \'none\'; script-src \'unsafe-inline\'; style-src \'unsafe-inline\'; img-src data: blob:; media-src data: blob:; font-src data:; connect-src \'none\'">';
78
83
 
@@ -87,9 +92,9 @@ function validateHomeHtml(html) {
87
92
  }
88
93
 
89
94
  /** -> null when `html` is acceptable, else a human-readable rejection reason. */
90
- function validateDemoVideoHtml(html) {
95
+ function validateDemoVideoHtml(html, maxBytes = MAX_DEMO_VIDEO_BYTES) {
91
96
  if (typeof html !== 'string' || html.trim().length === 0) return 'html must be a non-empty string';
92
- if (Buffer.byteLength(html, 'utf8') > MAX_DEMO_VIDEO_BYTES) return `html exceeds the ${MAX_DEMO_VIDEO_BYTES}-byte limit`;
97
+ if (Buffer.byteLength(html, 'utf8') > maxBytes) return `html exceeds the ${maxBytes}-byte limit`;
93
98
  for (const { re, message } of REMOTE_REFERENCE_CHECKS) {
94
99
  if (re.test(html)) return `html must be self-contained: ${message}`;
95
100
  }
@@ -162,19 +167,20 @@ function resolveCwd(rawCwd) {
162
167
  }
163
168
 
164
169
  /**
165
- * Builds a POST handler shared by both routes: read+parse the body, validate
166
- * against `schema`, resolve cwd, run `validate(html)`, optionally `transform`
167
- * the html (CSP injection), then write it atomically as writer 'project-home'.
170
+ * Builds a POST handler shared by every route: read+parse the body, validate
171
+ * against `schema`, resolve cwd, then `build(input)` -> {error} | {dir, html,
172
+ * meta}. The entry folder gets index.html then meta.json, both atomically as
173
+ * writer 'project-home'. Responds {ok, path (index.html), bytes}.
168
174
  */
169
- function makeWriteHandler({ schema, maxBytes, validate, transform, targetPath }) {
175
+ function makeWriteHandler({ schema, bodyLimit, build }) {
170
176
  return async (req, res) => {
171
- // Allow headroom over maxBytes for JSON escaping; the html byte limit
172
- // itself is enforced by `validate` below.
177
+ // Headroom over the html limit for JSON escaping; the html byte limit
178
+ // itself is enforced by `build`.
173
179
  let raw;
174
180
  try {
175
- raw = await readBody(req, maxBytes * 2 + 4096);
181
+ raw = await readBody(req, bodyLimit * 2 + 4096);
176
182
  } catch (e) {
177
- sendJson(res, 400, { ok: false, error: `request body rejected: ${e?.message ?? 'unreadable'} (html limit is ${maxBytes} bytes)` });
183
+ sendJson(res, 400, { ok: false, error: `request body rejected: ${e?.message ?? 'unreadable'} (html limit is ${bodyLimit} bytes)` });
178
184
  return;
179
185
  }
180
186
  let body;
@@ -196,43 +202,187 @@ function makeWriteHandler({ schema, maxBytes, validate, transform, targetPath })
196
202
  sendJson(res, resolved.status, { ok: false, error: resolved.error });
197
203
  return;
198
204
  }
199
- const rejection = validate(input.html);
200
- if (rejection) {
201
- sendJson(res, 400, { ok: false, error: rejection });
205
+ const built = build(input);
206
+ if (built.error) {
207
+ sendJson(res, 400, { ok: false, error: built.error });
202
208
  return;
203
209
  }
204
210
  // Only a route that is actually about to write widens config.cjs's
205
211
  // write boundary to this project root.
206
212
  config.addAllowedRoot(resolved.cwd);
207
- const finalHtml = transform ? transform(input.html) : input.html;
208
213
  try {
209
- const abs = targetPath(resolved.cwd);
210
- await fs.promises.mkdir(path.dirname(abs), { recursive: true });
211
- await config.writeTextAtomic(abs, finalHtml, { writer: 'project-home' });
212
- sendJson(res, 200, { ok: true, path: abs, bytes: Buffer.byteLength(finalHtml, 'utf8') });
214
+ const dir = opsPath(resolved.cwd, 'project-pages', ...built.dirParts);
215
+ await fs.promises.mkdir(dir, { recursive: true });
216
+ const abs = path.join(dir, 'index.html');
217
+ await config.writeTextAtomic(abs, built.html, { writer: 'project-home' });
218
+ await config.writeTextAtomic(path.join(dir, 'meta.json'), JSON.stringify(built.meta, null, 2) + '\n', { writer: 'project-home' });
219
+ sendJson(res, 200, { ok: true, path: abs, bytes: Buffer.byteLength(built.html, 'utf8'), id: built.meta.id });
213
220
  } catch (e) {
214
221
  sendJson(res, 500, { ok: false, error: e?.message ?? 'write failed' });
215
222
  }
216
223
  };
217
224
  }
218
225
 
226
+ /** Size cap for a video of `lengthS` seconds: 2 MiB per started 30 s. */
227
+ function maxVideoBytes(lengthS) {
228
+ return Math.ceil(lengthS / 30) * MAX_DEMO_VIDEO_BYTES;
229
+ }
230
+
231
+ function buildPage(input, { pageId, title, topic }) {
232
+ if (!ENTRY_ID_RE.test(pageId)) return { error: 'invalid pageId' };
233
+ const rejection = validateHomeHtml(input.html);
234
+ if (rejection) return { error: rejection };
235
+ return {
236
+ dirParts: ['knowledge', pageId],
237
+ html: input.html,
238
+ meta: schemas.projectPageMeta.parse({ id: pageId, title, topic, createdAt: new Date().toISOString(), model: '' }),
239
+ };
240
+ }
241
+
242
+ /** Shared video path. `meta` is the full video meta minus id/createdAt/report.bytes. */
243
+ function buildVideo(input, { videoId, title, kind, lengthS, meta }) {
244
+ if (!ENTRY_ID_RE.test(videoId)) return { error: 'invalid videoId' };
245
+ const cap = maxVideoBytes(lengthS);
246
+ const rejection = validateDemoVideoHtml(input.html, cap);
247
+ if (rejection) return { error: rejection };
248
+ const declared = Number(input.html.match(DURATION_META_RE)[1]);
249
+ if (declared !== lengthS) return { error: `sm-demo-duration (${declared}) must equal lengthS (${lengthS})` };
250
+ const html = injectPlayerBridge(injectCsp(input.html));
251
+ const bytes = Buffer.byteLength(html, 'utf8');
252
+ return {
253
+ dirParts: ['videos', videoId],
254
+ html,
255
+ meta: schemas.projectVideoMeta.parse({
256
+ ...meta,
257
+ id: videoId,
258
+ title,
259
+ kind,
260
+ lengthS,
261
+ createdAt: new Date().toISOString(),
262
+ report: { ...meta.report, bytes },
263
+ }),
264
+ };
265
+ }
266
+
267
+ function newVideoId() {
268
+ const alphabet = 'abcdefghijklmnopqrstuvwxyz0123456789';
269
+ const bytes = crypto.randomBytes(3);
270
+ let rnd = '';
271
+ for (const b of bytes) rnd += alphabet[b % alphabet.length];
272
+ return `vid-${Date.now().toString(36)}${rnd}`;
273
+ }
274
+
219
275
  function registerAdminRoute(adminHttp) {
220
- // POST /admin/project-home/write {cwd, html}
276
+ // POST /admin/project-home/pages/write {cwd, pageId, title, topic?, html}
277
+ adminHttp.registerRoute('POST', '/admin/project-home/pages/write', makeWriteHandler({
278
+ schema: schemas.projectPageAdminWriteBody,
279
+ bodyLimit: MAX_HTML_BYTES,
280
+ build: (i) => buildPage(i, { pageId: i.pageId, title: i.title, topic: i.topic ?? '' }),
281
+ }));
282
+
283
+ // POST /admin/project-home/videos/write {cwd, videoId, title, kind, lengthS, html, meta}
284
+ adminHttp.registerRoute('POST', '/admin/project-home/videos/write', makeWriteHandler({
285
+ schema: schemas.projectVideoAdminWriteBody,
286
+ bodyLimit: maxVideoBytes(MAX_DEMO_DURATION_S),
287
+ build: (i) => {
288
+ // Cheap kit checks re-run server-side; the alias route is exempt (Burrow sends no report).
289
+ const failed = (i.meta?.report?.checks ?? []).find((c) => c.ok === false);
290
+ if (failed) return { error: `report.checks failed: ${failed.id}${failed.detail ? ` (${failed.detail})` : ''}` };
291
+ const limits = checkHtmlLimits({ html: i.html, lengthS: i.lengthS });
292
+ if (!limits.ok) return { error: `${limits.id} check failed: ${limits.detail}` };
293
+ return buildVideo(i, i);
294
+ },
295
+ }));
296
+
297
+ // Alias: POST /admin/project-home/write {cwd, html} -> knowledge/overview/
221
298
  adminHttp.registerRoute('POST', '/admin/project-home/write', makeWriteHandler({
222
299
  schema: schemas.projectHomeAdminWriteBody,
223
- maxBytes: MAX_HTML_BYTES,
224
- validate: validateHomeHtml,
225
- targetPath: (cwd) => opsPath(cwd, 'project-pages', 'home.html'),
300
+ bodyLimit: MAX_HTML_BYTES,
301
+ build: (i) => buildPage(i, { pageId: 'overview', title: 'Overview', topic: 'overview' }),
226
302
  }));
227
303
 
228
- // POST /admin/project-home/demo-video/write {cwd, html}
304
+ // Alias: POST /admin/project-home/demo-video/write {cwd, html} -> a NEW videos/vid-*/ entry
229
305
  adminHttp.registerRoute('POST', '/admin/project-home/demo-video/write', makeWriteHandler({
230
306
  schema: schemas.projectDemoVideoAdminWriteBody,
231
- maxBytes: MAX_DEMO_VIDEO_BYTES,
232
- validate: validateDemoVideoHtml,
233
- transform: injectCsp,
234
- targetPath: (cwd) => opsPath(cwd, 'project-pages', 'demo-video', 'index.html'),
307
+ bodyLimit: maxVideoBytes(MAX_DEMO_DURATION_S),
308
+ build: (i) => {
309
+ const rejection = validateDemoVideoHtml(i.html, maxVideoBytes(MAX_DEMO_DURATION_S));
310
+ if (rejection) return { error: rejection };
311
+ const lengthS = Number(i.html.match(DURATION_META_RE)[1]);
312
+ return buildVideo(i, {
313
+ videoId: newVideoId(),
314
+ title: 'Demo video',
315
+ kind: 'project-demo',
316
+ lengthS,
317
+ meta: {
318
+ style: '',
319
+ character: null,
320
+ sources: [],
321
+ report: { lufs: null, truePeakDb: null, speechS: null, readingGrade: null, checks: [] },
322
+ macroVersion: 0,
323
+ seedVersion: 0,
324
+ model: '',
325
+ effort: '',
326
+ },
327
+ });
328
+ },
235
329
  }));
330
+
331
+ // POST /admin/project-home/character/write {cwd, json, js, replace?} -> videos/_character/
332
+ adminHttp.registerRoute('POST', '/admin/project-home/character/write', characterWriteHandler);
333
+ }
334
+
335
+ async function characterWriteHandler(req, res) {
336
+ let raw;
337
+ try {
338
+ raw = await readBody(req, MAX_CHARACTER_JS_BYTES * 2 + 64 * 1024);
339
+ } catch (e) {
340
+ sendJson(res, 400, { ok: false, error: `request body rejected: ${e?.message ?? 'unreadable'}` });
341
+ return;
342
+ }
343
+ let body;
344
+ try {
345
+ body = raw ? JSON.parse(raw) : {};
346
+ } catch {
347
+ sendJson(res, 400, { ok: false, error: 'invalid JSON body' });
348
+ return;
349
+ }
350
+ if (!body || typeof body !== 'object' || Array.isArray(body)) {
351
+ sendJson(res, 400, { ok: false, error: 'invalid payload' });
352
+ return;
353
+ }
354
+ const resolved = resolveCwd(body.cwd);
355
+ if (!resolved.ok) {
356
+ sendJson(res, resolved.status, { ok: false, error: resolved.error });
357
+ return;
358
+ }
359
+ const json = body.json;
360
+ const jsonObj = typeof json === 'string' ? (() => { try { return JSON.parse(json); } catch { return null; } })() : json;
361
+ const jsonErr = validateCharacterJson(jsonObj);
362
+ if (jsonErr) {
363
+ sendJson(res, 400, { ok: false, error: `character.json invalid: ${jsonErr}` });
364
+ return;
365
+ }
366
+ const jsErr = validateCharacterJs(body.js, [...REMOTE_REFERENCE_CHECKS, ...NETWORK_CHECKS]);
367
+ if (jsErr) {
368
+ sendJson(res, 400, { ok: false, error: jsErr });
369
+ return;
370
+ }
371
+ if (!body.replace && readCharacter(resolved.cwd)) {
372
+ sendJson(res, 409, { ok: false, error: 'a character already exists — pass replace: true to overwrite it' });
373
+ return;
374
+ }
375
+ config.addAllowedRoot(resolved.cwd);
376
+ try {
377
+ const dir = characterDir(resolved.cwd);
378
+ await fs.promises.mkdir(dir, { recursive: true });
379
+ const jsPath = path.join(dir, 'character.js');
380
+ await config.writeTextAtomic(jsPath, body.js, { writer: 'project-home' });
381
+ await config.writeTextAtomic(path.join(dir, 'character.json'), JSON.stringify(jsonObj, null, 2) + '\n', { writer: 'project-home' });
382
+ sendJson(res, 200, { ok: true, path: dir, bytes: Buffer.byteLength(body.js, 'utf8') });
383
+ } catch (e) {
384
+ sendJson(res, 500, { ok: false, error: e?.message ?? 'write failed' });
385
+ }
236
386
  }
237
387
 
238
388
  module.exports = {
@@ -240,6 +390,7 @@ module.exports = {
240
390
  validateHomeHtml,
241
391
  validateDemoVideoHtml,
242
392
  injectCsp,
393
+ maxVideoBytes,
243
394
  DEMO_VIDEO_CSP,
244
395
  MAX_HTML_BYTES,
245
396
  MAX_DEMO_VIDEO_BYTES,
@@ -27,6 +27,15 @@ function captureIpcHandlers(ipcMain) {
27
27
  handlers.set(channel, fn)
28
28
  return original(channel, fn)
29
29
  }
30
+ // Send-kind rows (renderer ipcRenderer.send, e.g. log:write) are served by ipcMain.on
31
+ // listeners. Capture the first listener per channel; an invoke handler always wins.
32
+ if (typeof ipcMain.on === 'function') {
33
+ const originalOn = ipcMain.on.bind(ipcMain)
34
+ ipcMain.on = (channel, fn) => {
35
+ if (!handlers.has(channel) && typeof fn === 'function') handlers.set(channel, fn)
36
+ return originalOn(channel, fn)
37
+ }
38
+ }
30
39
  return handlers
31
40
  }
32
41
 
@@ -44,7 +53,13 @@ const PATH_FENCED_CHANNELS = Object.freeze({
44
53
  'files:list': { field: 'path', mode: 'root', allowHomeListing: true },
45
54
  'transcript:readRef': { field: 'filePath', mode: 'secret' },
46
55
  'transcript:path': { field: 'cwd', mode: 'secret' },
56
+ 'transcript:exists': { field: 'cwd', mode: 'secret' },
47
57
  'memory:read': { field: 'cwd', mode: 'secret' },
58
+ // Sessions read tier (main/promptSessionsIpc.cjs): cwd must sit inside a registered project root.
59
+ 'promptSessions:load-active-index': { field: 'cwd', mode: 'root' },
60
+ 'promptSessions:list-archived': { field: 'cwd', mode: 'root' },
61
+ 'promptSessions:read-archived': { field: 'cwd', mode: 'root' },
62
+ 'promptSessions:read-session-transcript': { field: 'cwd', mode: 'root' },
48
63
  })
49
64
 
50
65
  const SECRET_DIRS = new Set(['.ssh', '.gnupg', '.aws', '.kube', '.docker', '.password-store', '.azure', '.terraform.d'])
@@ -305,27 +305,69 @@ const MCP_TOOL_CATALOG = [
305
305
  {
306
306
  name: 'project_home_write',
307
307
  group: 'project-home',
308
- purpose: "Write this project's Project Home page — ONE self-contained HTML document — to "
309
- + "session-manager-operations/project-pages/home.html via the session-manager app's admin API. "
310
- + 'The only write path for Project Home.',
311
- whenToUse: 'Use when asked to generate or refresh the project home page. Compose the whole page yourself '
312
- + '(inline <style>/<script>, data: URIs for assets) from what is really true about the project, then '
308
+ purpose: "ALIAS of project_page_write for the Overview page: write this project's Project Home Overview page — ONE self-contained HTML document — to "
309
+ + "session-manager-operations/project-pages/knowledge/overview/ via the session-manager app's admin API. "
310
+ + 'Prefer project_page_write for any new knowledge page.',
311
+ whenToUse: 'Use when asked to generate or refresh the project home Overview page. Compose the whole page yourself '
312
+ + '(inline <style> only — scripts never run in a page; data: URIs for assets) from what is really true about the project, then '
313
313
  + 'pass the full document as `html`.',
314
314
  whenNotToUse: 'Never fabricate content — every claim must trace to something concrete in the project. The '
315
- + 'document must be self-contained: the call is rejected for empty input, more than 1MB, any '
315
+ + 'document must be self-contained and script-free: the call is rejected for empty input, more than 1MB, any '
316
316
  + '<script src>, <link href="http…">, @import, or url(http…) — no network egress.',
317
- exampleArgs: { cwd: '/home/bilko/Projects/session-manager', html: '<!DOCTYPE html><html><body><h1>Example</h1></body></html>' },
317
+ exampleArgs: { cwd: '/home/bilko/Projects/session-manager', html: '<!DOCTYPE html><html><head><style>body{font:16px sans-serif}</style></head><body><h1>Example</h1></body></html>' },
318
318
  notes: "cwd is optional — defaults to the calling session's own project root (SM_PROJECT_ROOT or process.cwd()) when omitted.",
319
319
  },
320
+ {
321
+ name: 'project_page_write',
322
+ group: 'project-home',
323
+ purpose: "Write one knowledge page for this project's Project Home — ONE self-contained HTML document identified by `pageId` — "
324
+ + "via the session-manager app's admin API. Writing an existing pageId replaces that page.",
325
+ whenToUse: 'Use when asked to document a topic of the project as a page (architecture, how-to, status). Compose the whole page yourself '
326
+ + 'with inline <style> only — scripts never run in a page — from what is really true about the project, then pass it as `html` '
327
+ + 'or, for a large document, write it to a local .html file and pass its absolute path as `htmlPath`.',
328
+ whenNotToUse: 'Never fabricate content. Do not use for videos — use project_video_write. The call is rejected for empty input, more than 1MB, '
329
+ + 'any <script src>, <link href="http…">, @import, or url(http…) — no network egress.',
330
+ exampleArgs: {
331
+ cwd: '/home/bilko/Projects/session-manager',
332
+ pageId: 'architecture',
333
+ title: 'Architecture',
334
+ topic: 'How the app is put together',
335
+ html: '<!DOCTYPE html><html><head><style>body{font:16px sans-serif}</style></head><body><h1>Architecture</h1></body></html>',
336
+ },
337
+ notes: "cwd is optional — defaults to the calling session's own project root (SM_PROJECT_ROOT or process.cwd()) when omitted. "
338
+ + 'Give exactly one of `html` / `htmlPath` (absolute .html/.htm file, <= 2MB read limit).',
339
+ },
340
+ {
341
+ name: 'project_video_write',
342
+ group: 'project-home',
343
+ purpose: "Write one video for this project's Project Home — ONE self-contained HTML/JS document identified by `videoId` — "
344
+ + "via the session-manager app's admin API. Writing an existing videoId replaces that video.",
345
+ whenToUse: 'Use when asked to make a project video (demo, marketing). Compose the whole document yourself (inline <style>/<script>, '
346
+ + 'data: URIs for assets, CSS/JS-driven animation) from what is really true about the project, declare `kind` and `lengthS`, '
347
+ + 'then pass the document as `html` or — preferred when it embeds a base64 audio/image data URI — as an absolute `htmlPath`.',
348
+ whenNotToUse: 'Never fabricate content. Do not use for static knowledge pages — use project_page_write. The document must be self-contained '
349
+ + 'and non-network-capable: the call is rejected for empty input, more than 2MB, remote references, or network-capable APIs.',
350
+ exampleArgs: {
351
+ cwd: '/home/bilko/Projects/session-manager',
352
+ videoId: 'demo-30s',
353
+ title: 'Product demo',
354
+ kind: 'project-demo',
355
+ lengthS: 30,
356
+ html: '<!DOCTYPE html><html><head><meta name="sm-demo-duration" content="30"></head><body><h1>Example</h1></body></html>',
357
+ meta: {},
358
+ },
359
+ notes: "cwd is optional — defaults to the calling session's own project root (SM_PROJECT_ROOT or process.cwd()) when omitted. "
360
+ + 'Give exactly one of `html` / `htmlPath` (absolute .html/.htm file, <= 2MB).',
361
+ },
320
362
  {
321
363
  name: 'project_demo_video_write',
322
364
  group: 'project-home',
323
- purpose: "Write this project's 30-second demo video — ONE self-contained HTML/JS document — to "
324
- + "session-manager-operations/project-pages/demo-video/index.html via the session-manager app's admin API. "
325
- + 'The only write path for the demo video.',
365
+ purpose: "ALIAS of project_video_write that adds a project-demo video: write this project's demo video (30 seconds or 1 minute) — ONE self-contained HTML/JS document — as a new "
366
+ + "project-demo entry under session-manager-operations/project-pages/videos/<id>/ via the session-manager app's admin API. "
367
+ + 'project_video_write is the primary video tool; use this alias only for a quick project-demo.',
326
368
  whenToUse: 'Use when asked to generate or refresh the demo video. Compose the whole document yourself '
327
369
  + '(inline <style>/<script>, data: URIs for assets, CSS/JS-driven animation) from what is really true about '
328
- + 'the project, declare its length with <meta name="sm-demo-duration" content="N"> (5-30 seconds), then '
370
+ + 'the project, declare its length with <meta name="sm-demo-duration" content="N"> (5-60 seconds), then '
329
371
  + 'pass the document as `html` or — preferred when it embeds a base64 audio/image data URI — write it to a '
330
372
  + 'local .html file and pass its absolute path as `htmlPath`.',
331
373
  whenNotToUse: 'Never fabricate content — every claim must trace to something concrete in the project. The '
@@ -342,6 +384,24 @@ const MCP_TOOL_CATALOG = [
342
384
  + 'Give exactly one of `html` / `htmlPath` (absolute .html/.htm file, <= 2MB); prefer `htmlPath` for base64 data URIs. '
343
385
  + 'The document is CSP-stamped after it is written, so the viewer sandbox is the real network fence — these checks are defence in depth.',
344
386
  },
387
+ {
388
+ name: 'project_character_write',
389
+ group: 'project-home',
390
+ purpose: "Write this project's reusable video character — a `character.json` descriptor plus a `character.js` drawing module — to "
391
+ + "the project's videos/_character/ folder via the session-manager app's admin API, so every later video can reuse the same mascot.",
392
+ whenToUse: 'Use once per project, before building character videos, to save the mascot you designed. Pass `json` (the descriptor object or its JSON text) '
393
+ + 'and the module as `js` or — preferred for large modules — an absolute `jsPath` to a local .js file. Pass `replace: true` only to deliberately overwrite an existing character.',
394
+ whenNotToUse: 'Never fabricate content. Do not use to write a video — use project_video_write. The call is rejected (409) when a character already exists and `replace` is not set, '
395
+ + 'and for invalid `json`, `js` over 300KB, or `js` with remote references or network-capable APIs.',
396
+ exampleArgs: {
397
+ cwd: '/home/bilko/Projects/session-manager',
398
+ json: { name: 'Bit', voice: 'af_heart' },
399
+ js: 'export function draw(ctx, t) {}',
400
+ replace: false,
401
+ },
402
+ notes: "cwd is optional — defaults to the calling session's own project root (SM_PROJECT_ROOT or process.cwd()) when omitted. "
403
+ + 'Give exactly one of `js` / `jsPath` (absolute .js file, <= 300KB).',
404
+ },
345
405
  {
346
406
  name: 'customer_feedback_list',
347
407
  group: 'customer-feedback',
@@ -48,11 +48,15 @@ const OWNERS = Object.freeze({
48
48
  'scheduler': 'scheduler',
49
49
  // Project Home owns the synthesized Brief (generate + hand-edit).
50
50
  'project-brief': 'project-home',
51
- // Project Home owns project-pages/home.html and project-pages/demo-video/
52
- // index.html, written only via the project_home_write ->
53
- // /admin/project-home/write and project_demo_video_write ->
54
- // /admin/project-home/demo-video/write routes (config.cjs's
55
- // writeTextAtomic). See session-manager-operations/project-pages/README.md.
51
+ // Project Home owns the project-pages library: knowledge/<id>/ pages,
52
+ // videos/<id>/ videos and videos/_character/. Written only via the
53
+ // /admin/project-home/pages/write, /videos/write and /character/write
54
+ // routes (project_page_write, project_video_write, project_character_write),
55
+ // plus the two alias routes /admin/project-home/write (project_home_write ->
56
+ // knowledge/overview/) and /admin/project-home/demo-video/write
57
+ // (project_demo_video_write -> a project-demo entry under videos/<id>/),
58
+ // all via config.cjs's writeTextAtomic.
59
+ // See session-manager-operations/project-pages/README.md.
56
60
  'project-pages': 'project-home',
57
61
  // Structured per-tab error log lines (JSONL), tagged for tracing/analysis.
58
62
  'logs': 'logs',
@@ -24,10 +24,17 @@ const BUILTIN_MACROS = Object.freeze([
24
24
  tag: 'project-home-builder',
25
25
  surface: 'project-home',
26
26
  projects: ['*'],
27
- builtinVersion: 1,
28
- priorPrompts: Object.freeze([]),
29
- prompt:
27
+ builtinVersion: 2,
28
+ job: Object.freeze({
29
+ estimateMinutes: 20,
30
+ entryKind: 'knowledge',
31
+ artifactPaths: Object.freeze(['session-manager-operations/project-pages/knowledge/{id}/index.html']),
32
+ }),
33
+ priorPrompts: Object.freeze([
30
34
  "Generate this project's Project Home page: one self-contained HTML overview (what it is, who it is for, key features, structure, how to run it, key commands), grounded only in what you read in the repository. Save it with a single project_home_write call.",
35
+ ]),
36
+ prompt:
37
+ "Generate ONE Knowledge Page for this project as one self-contained HTML page, grounded only in what you read in the repository. The page is named on a 'Page: <name>' line in the additional instructions: Overview (the default when there is no Page line: what it is, who it is for, key features, structure, how to run it, key commands), How it works (architecture and main flows), FAQ (common questions with answers), or 'Custom topic: <text>' (a page about that topic). Build only that page; other pages stay untouched. Save it with a single project_page_write call, passing pageId equal to the id on the 'Entry id' line.",
31
38
  }),
32
39
  Object.freeze({
33
40
  id: 'builtin-demo-video',
@@ -36,14 +43,21 @@ const BUILTIN_MACROS = Object.freeze([
36
43
  tag: 'project-home-builder',
37
44
  surface: 'project-home',
38
45
  projects: ['*'],
39
- builtinVersion: 4,
46
+ builtinVersion: 6,
47
+ job: Object.freeze({
48
+ estimateMinutes: 60,
49
+ entryKind: 'video',
50
+ artifactPaths: Object.freeze(['session-manager-operations/project-pages/videos/{id}/index.html']),
51
+ }),
40
52
  priorPrompts: Object.freeze([
41
53
  'Generate a 30-second demo video for this project as one self-contained HTML/JavaScript animation that presents its main goals and key features, grounded only in what you read in the repository. Save it with a single project_demo_video_write call.',
42
54
  'Generate a 30-second demo video for this project as one self-contained HTML/JavaScript animation that presents its main goals and key features, grounded only in what you read in the repository, with a matching on-device narration track per the audio policy in the persona. Save it with a single project_demo_video_write call.',
43
55
  'Generate a 30-second demo video for this project as one self-contained HTML/JavaScript animation that presents its main goals and key features, grounded only in what you read in the repository, with a matching on-device narration track: narrate with Kokoro (kokoro-onnx) using a natural female (af_heart) or male (am_michael) voice per the audio policy in the persona. Save it with a single project_demo_video_write call passing htmlPath.',
56
+ "Generate a character and cute animated JavaScript video: a 30-second demo of this project as one self-contained HTML/JavaScript animation. Ground everything in what you read in the repository — invent an original mascot character whose look, name and personality match the project's theme and purpose, and tell the project's real goals and key features through it. The character, story and visuals must match the project's theme and purpose as read from the repository. Write the narration script first (hook, problem, solution, three features, call to action), then build every scene to match its line, with fun dynamic elements per the persona. Use the style named on a 'Video style: <name>' line in the additional instructions — Professional, Fun, Animated whiteboard, or Kinetic typography — otherwise pick the one that best fits the project. Narrate with Kokoro (kokoro-onnx) using a natural female (af_heart) or male (am_michael) voice per the audio policy in the persona. Save it with a single project_demo_video_write call passing htmlPath.",
57
+ "Generate a character and cute animated JavaScript video: a demo of this project as one self-contained HTML/JavaScript animation, 60 seconds long when the additional instructions carry a 'Video length: 60' line and 30 seconds otherwise. Ground everything in what you read in the repository — invent an original mascot character whose look, name and personality match the project's theme and purpose, and tell the project's real goals and key features through it. The character, story and visuals must match the project's theme and purpose as read from the repository. Write the narration script first (hook, problem, solution, key features, call to action), then build every keystone to match its lines, with the pacing and fun dynamic elements per the persona. Use the style named on a 'Video style: <name>' line in the additional instructions — Professional, Fun, Animated whiteboard, or Kinetic typography — otherwise pick the one that best fits the project. Narrate with Kokoro (kokoro-onnx) using a natural female (af_heart) or male (am_michael) voice per the audio policy in the persona. Save it with a single project_demo_video_write call passing htmlPath.",
44
58
  ]),
45
59
  prompt:
46
- "Generate a character and cute animated JavaScript video: a 30-second demo of this project as one self-contained HTML/JavaScript animation. Ground everything in what you read in the repository — invent an original mascot character whose look, name and personality match the project's theme and purpose, and tell the project's real goals and key features through it. The character, story and visuals must match the project's theme and purpose as read from the repository. Write the narration script first (hook, problem, solution, three features, call to action), then build every scene to match its line, with fun dynamic elements per the persona. Use the style named on a 'Video style: <name>' line in the additional instructions — Professional, Fun, Animated whiteboard, or Kinetic typography — otherwise pick the one that best fits the project. Narrate with Kokoro (kokoro-onnx) using a natural female (af_heart) or male (am_michael) voice per the audio policy in the persona. Save it with a single project_demo_video_write call passing htmlPath.",
60
+ "Generate a character and cute animated JavaScript video as one self-contained HTML/JavaScript animation, 60 seconds long when the additional instructions carry a 'Video length: 60' line and 30 seconds otherwise. The video kind is named on a 'Video kind: <name>' line in the additional instructions: Blog post (a video that presents the blog post named on the 'Video target:' line — a post path in this repository or a URL; read it and tell its real content) or Feature (a video about the feature named on the 'Video target:' line, found in the repository); with no Video kind line, make a Project demo of the whole project's main goals and key features. Ground everything in what you read in the repository (and the target) — invent an original mascot character whose look, name and personality match the subject's theme and purpose, and tell its real story through it. Write the narration script first (hook, problem, solution, key points, call to action), then build every keystone to match its lines, with the pacing and fun dynamic elements per the persona. Use the style named on a 'Video style: <name>' line in the additional instructions — Professional, Fun, Animated whiteboard, or Kinetic typography — otherwise pick the one that best fits. Narrate with Kokoro (kokoro-onnx) using a natural female (af_heart) or male (am_michael) voice per the audio policy in the persona. Save it with a single project_video_write call passing the htmlPath and the id on the 'Entry id' line.",
47
61
  }),
48
62
  ]);
49
63