claude-code-session-manager 0.135.1 → 0.136.1

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 (75) hide show
  1. package/.claude-plugin/marketplace.json +1 -1
  2. package/dist/assets/{AgentLibrary-BBY7E1ag.js → AgentLibrary-DsJcjUSt.js} +1 -1
  3. package/dist/assets/{AppSettings-vMiIi0xn.js → AppSettings-DS_d4o5R.js} +1 -1
  4. package/dist/assets/{Button-C0Z090Ui.js → Button-CVbZqtPJ.js} +1 -1
  5. package/dist/assets/{DocumentEditorPane-Ds10W8SZ.js → DocumentEditorPane-C4G5oeng.js} +1 -1
  6. package/dist/assets/{Extensions-CjPiz2I5.js → Extensions-ifcqZDuK.js} +2 -2
  7. package/dist/assets/{History-Bm3KXXs1.js → History-CBFAmFB7.js} +1 -1
  8. package/dist/assets/{Library-D-khizDg.js → Library-DlUH_fFF.js} +1 -1
  9. package/dist/assets/{ListDetail-CJYpp8fW.js → ListDetail-DrzkqaSM.js} +1 -1
  10. package/dist/assets/{Panel-BHFGylfy.js → Panel-Bjr5sT2j.js} +1 -1
  11. package/dist/assets/{ProjectClaudeConfig-DIzNAala.js → ProjectClaudeConfig-BEJAWpS2.js} +1 -1
  12. package/dist/assets/{ProvenanceBadge-CYryeTYF.js → ProvenanceBadge-Dlq0DSL2.js} +1 -1
  13. package/dist/assets/{Scheduler-BS82wfRP.js → Scheduler-CdwNo2AT.js} +1 -1
  14. package/dist/assets/{Settings-DWPHJ94d.js → Settings-BMy1KcDY.js} +1 -1
  15. package/dist/assets/{SkillReferenceGraph-Cf2M7YNq.js → SkillReferenceGraph-CqngCjO5.js} +1 -1
  16. package/dist/assets/{Skills-DLq55Odf.js → Skills-DCoKjG_1.js} +1 -1
  17. package/dist/assets/{SourceChip-CHxAzRlD.js → SourceChip-mjf4AO7V.js} +1 -1
  18. package/dist/assets/{SystemPrompt-BYtKMAr3.js → SystemPrompt-BDv0OwoH.js} +1 -1
  19. package/dist/assets/{TiptapBody-O_Gfq0Ha.js → TiptapBody-BdPKStNP.js} +1 -1
  20. package/dist/assets/{Toggle-BJOUI5NY.js → Toggle-CaLQyunk.js} +1 -1
  21. package/dist/assets/{ViewTabs-kkvNGu-S.js → ViewTabs-DVLIAjik.js} +1 -1
  22. package/dist/assets/{VoiceButton-3i-6ju2L.js → VoiceButton-CUXKeY0C.js} +1 -1
  23. package/dist/assets/{historyTotals-CHrIptK1.js → historyTotals-07_oiLDE.js} +1 -1
  24. package/dist/assets/{index-CjQ_p5y7.css → index-62tyjEQB.css} +1 -1
  25. package/dist/assets/index-CgSMvkqr.js +3116 -0
  26. package/dist/index.html +2 -2
  27. package/dist-web/app.css +1 -1
  28. package/dist-web/app.js +412 -412
  29. package/package.json +1 -1
  30. package/plugins/CLAUDE.md +2 -0
  31. package/plugins/packs/apple-design/.claude-plugin/plugin.json +6 -0
  32. package/plugins/packs/apple-design/laws.md +14 -0
  33. package/plugins/packs/apple-design/skills/hig-layout-and-accessibility/SKILL.md +152 -0
  34. package/plugins/packs/apple-design/skills/liquid-glass-adoption/SKILL.md +132 -0
  35. package/plugins/packs/apple-design/sm-pack.json +5 -0
  36. package/plugins/packs/apple-swift-core/.claude-plugin/plugin.json +12 -0
  37. package/plugins/packs/apple-swift-core/laws.md +13 -0
  38. package/plugins/packs/apple-swift-core/skills/swift-concurrency/SKILL.md +160 -0
  39. package/plugins/packs/apple-swift-core/skills/swiftui-state-and-navigation/SKILL.md +165 -0
  40. package/plugins/packs/apple-swift-core/sm-pack.json +5 -0
  41. package/plugins/session-manager-dev/.claude-plugin/plugin.json +1 -1
  42. package/plugins/session-manager-dev/skills/builder/SKILL.md +23 -0
  43. package/plugins/session-manager-dev/skills/maintaining-md-network/SKILL.md +9 -0
  44. package/plugins/session-manager-dev/skills/maintaining-md-network/drift-check.md +5 -2
  45. package/plugins/session-manager-dev/skills/maintaining-md-network/scripts/drift-check.cjs +100 -5
  46. package/plugins/session-manager-dev/skills/send-feedback/SKILL.md +52 -3
  47. package/scripts/scheduler-mcp-server.cjs +71 -5
  48. package/src/main/build-info.json +4 -4
  49. package/src/main/chatRunner.cjs +26 -2
  50. package/src/main/index.cjs +4 -0
  51. package/src/main/ipcSchemas.cjs +13 -0
  52. package/src/main/lib/claude/agentModelResolve.cjs +23 -0
  53. package/src/main/lib/epic/epicMint.cjs +12 -6
  54. package/src/main/lib/epic/promptSessionsCreateEpic.cjs +8 -4
  55. package/src/main/lib/feedback-remote/crossProjectFeedback.cjs +204 -8
  56. package/src/main/lib/feedback-remote/crossProjectReply.cjs +375 -0
  57. package/src/main/lib/feedback-remote/remoteIpcDispatch.cjs +2 -0
  58. package/src/main/lib/mcpToolCatalog.cjs +40 -4
  59. package/src/main/lib/mdNetworkScan.cjs +61 -11
  60. package/src/main/lib/mdReviewRecord.cjs +287 -0
  61. package/src/main/lib/packs/packCatalog.cjs +120 -0
  62. package/src/main/lib/packs/packSpawnArgs.cjs +59 -0
  63. package/src/main/lib/packs/packsIpc.cjs +76 -0
  64. package/src/main/lib/persona-macro/builtinMacros.cjs +3 -2
  65. package/src/main/lib/persona-macro/shippedPersonaSeeds.cjs +11 -0
  66. package/src/main/lib/prd/prdCreate.cjs +2 -2
  67. package/src/main/lib/promptSessionSchema.cjs +8 -0
  68. package/src/main/projectPages.cjs +19 -0
  69. package/src/main/promptSessionEvents.cjs +8 -1
  70. package/src/main/scheduler.cjs +23 -2
  71. package/src/preload/api.d.ts +71 -0
  72. package/src/preload/apiSurface.json +21 -0
  73. package/src/preload/index.cjs +7 -0
  74. package/src/seed/agents/demo-video-builder.md +5 -3
  75. package/dist/assets/index-D9qgN9_V.js +0 -3116
@@ -0,0 +1,287 @@
1
+ // @ts-check
2
+ 'use strict';
3
+
4
+ /**
5
+ * mdReviewRecord.cjs — reads the review record the maintaining-md-network skill
6
+ * commits (session-manager-operations/reviews/docs/<YYYY-MM-DD>-md-network.md,
7
+ * a second record on one date taking -2, -3, ...), so Project Home can show
8
+ * what a review produced. Read-only: fs.promises reads only, never a write, so
9
+ * reading reviews/ needs no ownership change.
10
+ *
11
+ * Top-level in lib/ because no subfolder fits: like mdNetworkScan.cjs (which it
12
+ * sits beside), it reads the same project's own review docs, so it is neither
13
+ * project-pages/ (the generated pages library) nor git/, and it does I/O, so it
14
+ * is not util/.
15
+ *
16
+ * - newestRecordName(names) — pure: the newest record file name, or null.
17
+ * - parseReviewRecord(text) — pure: the template fields; never throws.
18
+ * - readMdReview(root, { epicIds }) — newest record + validation record paths
19
+ * under reviews/validation/<epicId>/ for each safe Epic id.
20
+ */
21
+
22
+ const fsp = require('node:fs/promises');
23
+ const path = require('node:path');
24
+ const { opsPath, resolveProjectRoot } = require('./opsOwnership.cjs');
25
+
26
+ const RECORD_RE = /^(\d{4}-\d{2}-\d{2})-md-network(?:-(\d+))?\.md$/;
27
+ const EPIC_ID_RE = /^[a-z0-9][a-z0-9-]{0,127}$/;
28
+ const DATE_RE = /\d{4}-\d{2}-\d{2}/;
29
+ const MAX_RECORD_BYTES = 256 * 1024;
30
+
31
+ /**
32
+ * @typedef {{ doc: string, verdict: string, owner: string }} ReviewVerdict
33
+ * @typedef {{
34
+ * date: string | null,
35
+ * mode: string | null,
36
+ * modeKind: 'Full review' | 'Drift check' | null,
37
+ * scope: string | null,
38
+ * session: string | null,
39
+ * baseCommit: string | null,
40
+ * owner: string | null,
41
+ * map: string | null,
42
+ * driftCheckCommand: string | null,
43
+ * findingsCounts: Record<string, number>,
44
+ * censusSummary: string | null,
45
+ * verdicts: ReviewVerdict[],
46
+ * decisions: string[],
47
+ * followUpPrds: string[],
48
+ * nextReviewDue: string | null,
49
+ * nextReviewNote: string | null,
50
+ * }} ReviewRecord
51
+ * @typedef {{
52
+ * ok: true,
53
+ * record: ReviewRecord | null,
54
+ * recordPath: string | null,
55
+ * validation: Record<string, string[]>,
56
+ * }} MdReviewOk
57
+ * @typedef {{ ok: false, error: string }} MdReviewErr
58
+ */
59
+
60
+ /**
61
+ * The newest review record name: newest date first, then the highest numeric
62
+ * suffix (-10 beats -9; any suffix beats none). Non-matching names are ignored.
63
+ * @param {readonly string[]} names
64
+ * @returns {string | null}
65
+ */
66
+ function newestRecordName(names) {
67
+ /** @type {{ name: string, date: string, n: number } | null} */
68
+ let best = null;
69
+ for (const name of Array.isArray(names) ? names : []) {
70
+ if (typeof name !== 'string') continue;
71
+ const m = RECORD_RE.exec(name);
72
+ if (!m) continue;
73
+ const date = m[1];
74
+ const n = m[2] ? Number(m[2]) : 0;
75
+ if (!best || date > best.date || (date === best.date && n > best.n)) best = { name, date, n };
76
+ }
77
+ return best ? best.name : null;
78
+ }
79
+
80
+ /** @type {Record<string, 'date' | 'mode' | 'scope' | 'session' | 'baseCommit' | 'owner' | 'map' | 'driftCheckCommand' | 'censusSummary'>} */
81
+ const FIELD_KEYS = {
82
+ date: 'date',
83
+ mode: 'mode',
84
+ scope: 'scope',
85
+ session: 'session',
86
+ 'base commit': 'baseCommit',
87
+ owner: 'owner',
88
+ map: 'map',
89
+ 'drift-check command': 'driftCheckCommand',
90
+ 'census summary': 'censusSummary',
91
+ };
92
+
93
+ /** @param {string} line @returns {string[] | null} */
94
+ function tableCells(line) {
95
+ const t = line.trim();
96
+ if (!t.startsWith('|')) return null;
97
+ const inner = t.replace(/^\|/, '').replace(/\|$/, '');
98
+ return inner.split('|').map((c) => c.trim());
99
+ }
100
+
101
+ /** @param {string} s */
102
+ function listItem(s) {
103
+ const m = /^\s*[-*]\s+(.*)$/.exec(s);
104
+ return m ? m[1].trim() : null;
105
+ }
106
+
107
+ /**
108
+ * Parse a review record. Missing fields are null or empty; never throws.
109
+ * @param {unknown} text
110
+ * @returns {ReviewRecord}
111
+ */
112
+ function parseReviewRecord(text) {
113
+ /** @type {ReviewRecord} */
114
+ const rec = {
115
+ date: null,
116
+ mode: null,
117
+ modeKind: null,
118
+ scope: null,
119
+ session: null,
120
+ baseCommit: null,
121
+ owner: null,
122
+ map: null,
123
+ driftCheckCommand: null,
124
+ findingsCounts: {},
125
+ censusSummary: null,
126
+ verdicts: [],
127
+ decisions: [],
128
+ followUpPrds: [],
129
+ nextReviewDue: null,
130
+ nextReviewNote: null,
131
+ };
132
+ const src = typeof text === 'string' ? text : '';
133
+ /** @type {string | null} */
134
+ let section = null;
135
+ /** @type {string[]} */
136
+ const nextLines = [];
137
+ for (const raw of src.split(/\r?\n/)) {
138
+ const line = raw.replace(/\s+$/, '');
139
+ const h = /^##\s+(.+)$/.exec(line);
140
+ if (h) {
141
+ section = h[1].trim().toLowerCase();
142
+ continue;
143
+ }
144
+ if (/^#\s/.test(line)) continue;
145
+ if (section === null) {
146
+ const f = /^\s*[-*]\s+([^:]+):\s*(.*)$/.exec(line);
147
+ if (!f) continue;
148
+ const key = f[1].trim().toLowerCase();
149
+ const value = f[2].trim();
150
+ if (key === 'findings counts') {
151
+ for (const part of value.split(',')) {
152
+ const m = /^\s*([A-Za-z][\w-]*)\s+(\d+)\s*$/.exec(part);
153
+ if (m) rec.findingsCounts[m[1]] = Number(m[2]);
154
+ }
155
+ continue;
156
+ }
157
+ const field = FIELD_KEYS[key];
158
+ if (!field || !value) continue;
159
+ rec[field] = value;
160
+ continue;
161
+ }
162
+ if (section === 'verdicts') {
163
+ const cells = tableCells(line);
164
+ if (!cells || cells.length < 3) continue;
165
+ if (cells.every((c) => /^:?-{3,}:?$/.test(c))) continue;
166
+ if (cells[0].toLowerCase() === 'doc' && cells[1].toLowerCase() === 'verdict') continue;
167
+ if (!cells[0] || !cells[1]) continue;
168
+ rec.verdicts.push({ doc: cells[0], verdict: cells[1], owner: cells.slice(2).join(' | ') });
169
+ } else if (section === 'decisions') {
170
+ const item = listItem(line);
171
+ if (item) rec.decisions.push(item);
172
+ } else if (section === 'follow-up prds') {
173
+ const item = listItem(line);
174
+ if (item && item.toLowerCase() !== 'none' && item.toLowerCase() !== '"none"') rec.followUpPrds.push(item);
175
+ } else if (section === 'next review due') {
176
+ if (line.trim()) nextLines.push(line.trim());
177
+ }
178
+ }
179
+ if (rec.mode) {
180
+ if (/^full review\b/i.test(rec.mode)) rec.modeKind = 'Full review';
181
+ else if (/^drift check\b/i.test(rec.mode)) rec.modeKind = 'Drift check';
182
+ }
183
+ if (nextLines.length) {
184
+ const note = nextLines.join(' ');
185
+ rec.nextReviewNote = note;
186
+ const d = DATE_RE.exec(note);
187
+ rec.nextReviewDue = d ? d[0] : null;
188
+ }
189
+ return rec;
190
+ }
191
+
192
+ /**
193
+ * @param {string} dir
194
+ * @returns {Promise<import('node:fs').Dirent[]>}
195
+ */
196
+ async function listDir(dir) {
197
+ try {
198
+ return await fsp.readdir(dir, { withFileTypes: true });
199
+ } catch {
200
+ return [];
201
+ }
202
+ }
203
+
204
+ /**
205
+ * Read at most MAX_RECORD_BYTES of a file as utf8.
206
+ * @param {string} file
207
+ * @returns {Promise<string | null>}
208
+ */
209
+ async function readCapped(file) {
210
+ /** @type {import('node:fs/promises').FileHandle | null} */
211
+ let fh = null;
212
+ try {
213
+ fh = await fsp.open(file, 'r');
214
+ const buf = Buffer.alloc(MAX_RECORD_BYTES);
215
+ let total = 0;
216
+ while (total < MAX_RECORD_BYTES) {
217
+ const { bytesRead } = await fh.read(buf, total, MAX_RECORD_BYTES - total, total);
218
+ if (bytesRead === 0) break;
219
+ total += bytesRead;
220
+ }
221
+ return buf.subarray(0, total).toString('utf8');
222
+ } catch {
223
+ return null;
224
+ } finally {
225
+ if (fh) await fh.close().catch(() => {});
226
+ }
227
+ }
228
+
229
+ /** @param {string} root @param {string} abs */
230
+ function rel(root, abs) {
231
+ return path.relative(root, abs).split(path.sep).join('/');
232
+ }
233
+
234
+ /**
235
+ * The project's newest markdown-network review record plus its validation
236
+ * record paths for the given Epic ids. A missing folder gives record null.
237
+ * @param {string} root project root (absolute)
238
+ * @param {{ epicIds?: readonly string[] }} [opts]
239
+ * @returns {Promise<MdReviewOk | MdReviewErr>}
240
+ */
241
+ async function readMdReview(root, opts = {}) {
242
+ /** @type {string} */
243
+ let projectRoot;
244
+ /** @type {string} */
245
+ let docsDir;
246
+ /** @type {string} */
247
+ let validationDir;
248
+ try {
249
+ projectRoot = resolveProjectRoot(root);
250
+ docsDir = opsPath(root, 'reviews', 'docs');
251
+ validationDir = opsPath(root, 'reviews', 'validation');
252
+ } catch (err) {
253
+ return { ok: false, error: err instanceof Error ? err.message : String(err) };
254
+ }
255
+
256
+ const entries = await listDir(docsDir);
257
+ const name = newestRecordName(entries.filter((e) => e.isFile()).map((e) => e.name));
258
+ /** @type {ReviewRecord | null} */
259
+ let record = null;
260
+ /** @type {string | null} */
261
+ let recordPath = null;
262
+ if (name) {
263
+ const abs = path.join(docsDir, name);
264
+ const text = await readCapped(abs);
265
+ if (text !== null) {
266
+ record = parseReviewRecord(text);
267
+ recordPath = rel(projectRoot, abs);
268
+ }
269
+ }
270
+
271
+ /** @type {Record<string, string[]>} */
272
+ const validation = {};
273
+ const ids = Array.isArray(opts.epicIds) ? opts.epicIds : [];
274
+ for (const id of ids) {
275
+ if (typeof id !== 'string' || !EPIC_ID_RE.test(id) || validation[id]) continue;
276
+ const dir = path.join(validationDir, id);
277
+ const files = (await listDir(dir))
278
+ .filter((e) => e.isFile() && e.name.endsWith('.md'))
279
+ .map((e) => rel(projectRoot, path.join(dir, e.name)))
280
+ .sort();
281
+ validation[id] = files;
282
+ }
283
+
284
+ return { ok: true, record, recordPath, validation };
285
+ }
286
+
287
+ module.exports = { newestRecordName, parseReviewRecord, readMdReview, MAX_RECORD_BYTES };
@@ -0,0 +1,120 @@
1
+ 'use strict';
2
+ /**
3
+ * packCatalog.cjs — the one reader of Session Manager's shipped context packs.
4
+ *
5
+ * A pack is a Claude Code plugin directory under `plugins/packs/<id>/` plus:
6
+ * - `sm-pack.json` — { id, label, description, requires?: { platform? } }
7
+ * - `laws.md` — optional always-on rules (≤ PACK_LAWS_CHAR_CAP chars)
8
+ * - `.claude-plugin/plugin.json` — the plugin manifest `claude --plugin-dir` loads
9
+ *
10
+ * Spawn code and the New Session card share this one catalog. It never throws:
11
+ * a malformed pack becomes an `{ dir, error }` entry, never a crash. No caching.
12
+ */
13
+ const fs = require('fs');
14
+ const path = require('path');
15
+ const { z } = require('zod');
16
+
17
+ const PACK_LAWS_CHAR_CAP = 2000;
18
+
19
+ const PackManifestSchema = z.object({
20
+ id: z.string().max(40).regex(/^[a-z0-9]+(?:-[a-z0-9]+)*$/, 'id must be kebab-case'),
21
+ label: z.string().min(1).max(60),
22
+ description: z.string().max(300),
23
+ requires: z.object({
24
+ platform: z.enum(['darwin', 'linux', 'win32']).optional(),
25
+ }).optional(),
26
+ });
27
+
28
+ /**
29
+ * @typedef {{ platform?: 'darwin'|'linux'|'win32' }} PackRequires
30
+ * @typedef {{ id: string, label: string, description: string, dir: string,
31
+ * pluginName: string, laws: string, requires: PackRequires }} Pack
32
+ * @typedef {{ dir: string, error: string }} PackError
33
+ */
34
+
35
+ /** Absolute path to the shipped packs: the package root (same as
36
+ * pluginInstall.cjs bundledMarketplaceDir()) + plugins/packs. */
37
+ function bundledPacksDir() {
38
+ return path.join(__dirname, '..', '..', '..', '..', 'plugins', 'packs');
39
+ }
40
+
41
+ /** @param {string} file @param {string} what */
42
+ function readJson(file, what) {
43
+ let raw;
44
+ try { raw = fs.readFileSync(file, 'utf8'); } catch { throw new Error(`${what} missing`); }
45
+ try { return JSON.parse(raw); } catch (e) { throw new Error(`${what} is not valid JSON: ${/** @type {Error} */ (e).message}`); }
46
+ }
47
+
48
+ /** @param {string} dir @returns {Pack} */
49
+ function readPack(dir) {
50
+ const parsed = PackManifestSchema.safeParse(readJson(path.join(dir, 'sm-pack.json'), 'sm-pack.json'));
51
+ if (!parsed.success) {
52
+ const msg = parsed.error.issues.map((i) => `${i.path.join('.') || '(root)'}: ${i.message}`).join('; ');
53
+ throw new Error(`sm-pack.json invalid: ${msg}`);
54
+ }
55
+ const m = parsed.data;
56
+ if (m.id !== path.basename(dir)) throw new Error(`sm-pack.json id "${m.id}" must equal its directory name "${path.basename(dir)}"`);
57
+
58
+ const plugin = readJson(path.join(dir, '.claude-plugin', 'plugin.json'), '.claude-plugin/plugin.json');
59
+ if (!plugin || typeof plugin !== 'object' || Array.isArray(plugin)) throw new Error('.claude-plugin/plugin.json must be an object');
60
+ const pluginName = plugin.name;
61
+ if (typeof pluginName !== 'string' || !pluginName) throw new Error('.claude-plugin/plugin.json has no name');
62
+ if (pluginName.startsWith('claude')) throw new Error(`plugin name "${pluginName}" must not start with "claude"`);
63
+ if (plugin.defaultEnabled === false) throw new Error('plugin.json sets defaultEnabled:false — an inline --plugin-dir plugin would not load');
64
+
65
+ let laws = '';
66
+ const lawsFile = path.join(dir, 'laws.md');
67
+ if (fs.existsSync(lawsFile)) laws = fs.readFileSync(lawsFile, 'utf8').trim();
68
+ if (laws.length > PACK_LAWS_CHAR_CAP) throw new Error(`laws.md is ${laws.length} chars, over the ${PACK_LAWS_CHAR_CAP} cap`);
69
+
70
+ return {
71
+ id: m.id,
72
+ label: m.label,
73
+ description: m.description,
74
+ dir,
75
+ pluginName,
76
+ laws,
77
+ requires: m.requires ? { ...m.requires } : {},
78
+ };
79
+ }
80
+
81
+ /**
82
+ * List every pack under `packsDir`. Never throws.
83
+ * @param {{ packsDir?: string }} [opts]
84
+ * @returns {{ packs: Pack[], errors: PackError[] }}
85
+ */
86
+ function listPacks({ packsDir = bundledPacksDir() } = {}) {
87
+ /** @type {Pack[]} */ const packs = [];
88
+ /** @type {PackError[]} */ const errors = [];
89
+ const root = path.resolve(packsDir);
90
+ let entries;
91
+ try {
92
+ entries = fs.readdirSync(root, { withFileTypes: true });
93
+ } catch (e) {
94
+ const code = /** @type {NodeJS.ErrnoException} */ (e).code;
95
+ if (code !== 'ENOENT') errors.push({ dir: root, error: `cannot read packs directory: ${/** @type {Error} */ (e).message}` });
96
+ return { packs, errors };
97
+ }
98
+ for (const ent of entries) {
99
+ if (!ent.isDirectory()) continue;
100
+ const dir = path.join(root, ent.name);
101
+ try {
102
+ packs.push(readPack(dir));
103
+ } catch (e) {
104
+ errors.push({ dir, error: String((e && /** @type {Error} */ (e).message) || e) });
105
+ }
106
+ }
107
+ packs.sort((a, b) => (a.id < b.id ? -1 : a.id > b.id ? 1 : 0));
108
+ return { packs, errors };
109
+ }
110
+
111
+ /**
112
+ * @param {string} id
113
+ * @param {{ packsDir?: string }} [opts]
114
+ * @returns {Pack|null}
115
+ */
116
+ function getPack(id, opts) {
117
+ return listPacks(opts).packs.find((p) => p.id === id) || null;
118
+ }
119
+
120
+ module.exports = { listPacks, getPack, bundledPacksDir, PACK_LAWS_CHAR_CAP };
@@ -0,0 +1,59 @@
1
+ 'use strict';
2
+ /**
3
+ * packSpawnArgs.cjs — turn an Epic's selected context-pack ids into Claude CLI
4
+ * arguments. Pure and never throws; both spawn paths (chat turns, PRD jobs) call it.
5
+ *
6
+ * pluginDirArgs — ['--plugin-dir', <abs dir>, ...], one per known pack, in order, deduped
7
+ * laws — the packs' always-on rules as one `--append-system-prompt` text ('' if none)
8
+ * unknown — ids not in the catalog, or whose requires.platform ≠ platform
9
+ *
10
+ * A directory only ever comes from a catalog entry — an id is never joined into a path.
11
+ */
12
+ const { listPacks } = require('./packCatalog.cjs');
13
+
14
+ const LAWS_HEADER = '# Context packs for this session';
15
+
16
+ /** @param {unknown} p */
17
+ function isUsablePack(p) {
18
+ if (!p || typeof p !== 'object') return false;
19
+ const o = /** @type {Record<string, unknown>} */ (p);
20
+ return typeof o.id === 'string' && typeof o.dir === 'string' && o.dir.length > 0;
21
+ }
22
+
23
+ /**
24
+ * @param {{ packIds?: unknown, catalog?: unknown, platform?: string }} [opts]
25
+ * @returns {{ pluginDirArgs: string[], laws: string, unknown: string[] }}
26
+ */
27
+ function composePackSpawnArgs({ packIds, catalog, platform = process.platform } = {}) {
28
+ /** @type {string[]} */ const pluginDirArgs = [];
29
+ /** @type {string[]} */ const unknown = [];
30
+ /** @type {string[]} */ const lawSections = [];
31
+ if (!Array.isArray(packIds) || packIds.length === 0) return { pluginDirArgs, laws: '', unknown };
32
+
33
+ let entries = catalog;
34
+ if (entries === undefined) {
35
+ try { entries = listPacks().packs; } catch { entries = []; }
36
+ }
37
+ /** @type {Map<string, any>} */ const byId = new Map();
38
+ if (Array.isArray(entries)) {
39
+ for (const p of entries) if (isUsablePack(p) && !byId.has(p.id)) byId.set(p.id, p);
40
+ }
41
+
42
+ const seen = new Set();
43
+ for (const raw of packIds) {
44
+ const id = String(raw);
45
+ if (seen.has(id)) continue;
46
+ seen.add(id);
47
+ const pack = typeof raw === 'string' ? byId.get(raw) : undefined;
48
+ const need = pack && pack.requires && typeof pack.requires === 'object' ? pack.requires.platform : undefined;
49
+ if (!pack || (need && need !== platform)) { unknown.push(id); continue; }
50
+ pluginDirArgs.push('--plugin-dir', pack.dir);
51
+ const laws = typeof pack.laws === 'string' ? pack.laws.trim() : '';
52
+ if (laws) lawSections.push(`## ${typeof pack.label === 'string' && pack.label ? pack.label : pack.id} pack`, laws);
53
+ }
54
+
55
+ const laws = lawSections.length ? [LAWS_HEADER, ...lawSections].join('\n\n') : '';
56
+ return { pluginDirArgs, laws, unknown };
57
+ }
58
+
59
+ module.exports = { composePackSpawnArgs, LAWS_HEADER };
@@ -0,0 +1,76 @@
1
+ 'use strict';
2
+
3
+ /**
4
+ * packsIpc.cjs — `packs:list`: the shipped context-pack catalog as DISPLAY data
5
+ * for the New Session picker. Returns only { id, label, description, requires,
6
+ * hasLaws } per pack — never the pack dir, plugin name, or laws text, which stay
7
+ * main-side (spawn args are built in packSpawnArgs.cjs). Catalog load errors are
8
+ * dropped here because they carry absolute paths.
9
+ *
10
+ * `packs:terminal-args` — the pack part of an Epic Terminal pane's `claude` line
11
+ * ({ cwd, claudeSessionId } → { ok: true, args }), so Terminal loads the same
12
+ * packs as the Epic's chat turns. Main composes it because only main knows pack
13
+ * dirs. Never fails: agent-CLI Epics, Epics without packs, and lookup errors all
14
+ * return { ok: true, args: [] }.
15
+ */
16
+
17
+ function toDisplay(p) {
18
+ return {
19
+ id: p.id,
20
+ label: p.label,
21
+ description: p.description,
22
+ requires: p.requires && typeof p.requires === 'object' ? { ...p.requires } : {},
23
+ hasLaws: typeof p.laws === 'string' && p.laws.length > 0,
24
+ };
25
+ }
26
+
27
+ /** True for an Epic run by a non-Claude agent CLI (absent agentCli = Claude Code). */
28
+ function isAgentCliEpic(epic) {
29
+ const cli = epic && typeof epic.agentCli === 'string' ? epic.agentCli.trim() : '';
30
+ return cli !== '' && cli !== 'claude';
31
+ }
32
+
33
+ /**
34
+ * @param {{ cwd?: unknown, claudeSessionId?: unknown }} payload
35
+ * @param {{ findEpic?: Function, composePackSpawnArgs?: Function }} [deps]
36
+ * @returns {{ ok: true, args: string[] }}
37
+ */
38
+ function buildTerminalPackArgs(payload, deps = {}) {
39
+ try {
40
+ const cwd = payload && typeof payload.cwd === 'string' ? payload.cwd : '';
41
+ const claudeSessionId = payload && typeof payload.claudeSessionId === 'string' ? payload.claudeSessionId : '';
42
+ if (!cwd || !claudeSessionId) return { ok: true, args: [] };
43
+ const findEpic = deps.findEpic || require('../claude/agentModelResolve.cjs').findEpicByClaudeSessionId;
44
+ const compose = deps.composePackSpawnArgs || require('./packSpawnArgs.cjs').composePackSpawnArgs;
45
+ const epic = findEpic(cwd, claudeSessionId);
46
+ if (!epic || isAgentCliEpic(epic)) return { ok: true, args: [] };
47
+ if (!Array.isArray(epic.packs) || epic.packs.length === 0) return { ok: true, args: [] };
48
+ const { pluginDirArgs, laws } = compose({ packIds: epic.packs });
49
+ const args = Array.isArray(pluginDirArgs) ? pluginDirArgs.map(String) : [];
50
+ if (typeof laws === 'string' && laws.length > 0) args.push('--append-system-prompt', laws);
51
+ return { ok: true, args };
52
+ } catch {
53
+ return { ok: true, args: [] };
54
+ }
55
+ }
56
+
57
+ /**
58
+ * @param {{ ipcMain?: any, listPacks?: () => { packs: any[] }, findEpic?: Function, composePackSpawnArgs?: Function }} [opts]
59
+ */
60
+ function registerPacksHandlers(opts = {}) {
61
+ const ipcMain = opts.ipcMain || require('electron').ipcMain;
62
+ const listPacks = opts.listPacks || require('./packCatalog.cjs').listPacks;
63
+ ipcMain.handle('packs:list', async () => {
64
+ try {
65
+ const res = listPacks();
66
+ const packs = (res && Array.isArray(res.packs) ? res.packs : []).map(toDisplay);
67
+ return { ok: true, packs };
68
+ } catch (e) {
69
+ return { ok: false, error: e && e.message ? e.message : String(e) };
70
+ }
71
+ });
72
+ ipcMain.handle('packs:terminal-args', async (_e, payload) =>
73
+ buildTerminalPackArgs(payload, { findEpic: opts.findEpic, composePackSpawnArgs: opts.composePackSpawnArgs }));
74
+ }
75
+
76
+ module.exports = { registerPacksHandlers, buildTerminalPackArgs };
@@ -51,7 +51,7 @@ const BUILTIN_MACROS = Object.freeze([
51
51
  tag: 'project-home-builder',
52
52
  surface: 'project-home',
53
53
  projects: ['*'],
54
- builtinVersion: 8,
54
+ builtinVersion: 9,
55
55
  job: Object.freeze({
56
56
  estimateMinutes: 60,
57
57
  entryKind: 'video',
@@ -65,9 +65,10 @@ const BUILTIN_MACROS = Object.freeze([
65
65
  "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.",
66
66
  "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.",
67
67
  "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; a 'Video length: 30' line means 30 seconds. 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. A 'Video kind: Project demo' line means that same whole-project demo. 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. A 'Character: off' line means no mascot: make a type-led animation in the chosen style that tells the same real story through moving type and shapes, skip the character wherever the persona uses one (design, _character, project_character_write, lip-sync, the character self-check) and save meta.character as null; a 'Character: on' line or no Character line keeps the mascot. 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. A 'Video style: Auto' line means the same: pick the style 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.",
68
+ "Generate a cute animated JavaScript video with an original mascot character unless a Character: off line says otherwise, as one self-contained HTML/JavaScript animation, 60 seconds long when the additional instructions carry a 'Video length: 60' line and 30 seconds otherwise; a 'Video length: 30' line means 30 seconds. 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. A 'Video kind: Project demo' line means that same whole-project demo. 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. A 'Character: off' line means no mascot: make a type-led animation in the chosen style that tells the same real story through moving type and shapes, skip the character wherever the persona uses one (design, _character, project_character_write, lip-sync, the character self-check) and save meta.character as null; a 'Character: on' line or no Character line keeps the mascot. 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. A 'Video style: Auto' line means the same: pick the style 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.",
68
69
  ]),
69
70
  prompt:
70
- "Generate a cute animated JavaScript video with an original mascot character unless a Character: off line says otherwise, as one self-contained HTML/JavaScript animation, 60 seconds long when the additional instructions carry a 'Video length: 60' line and 30 seconds otherwise; a 'Video length: 30' line means 30 seconds. 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. A 'Video kind: Project demo' line means that same whole-project demo. 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. A 'Character: off' line means no mascot: make a type-led animation in the chosen style that tells the same real story through moving type and shapes, skip the character wherever the persona uses one (design, _character, project_character_write, lip-sync, the character self-check) and save meta.character as null; a 'Character: on' line or no Character line keeps the mascot. 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. A 'Video style: Auto' line means the same: pick the style 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.",
71
+ "Generate a cute animated JavaScript video with an original mascot character unless a Character: off line says otherwise, as one self-contained HTML/JavaScript animation, 60 seconds long when the additional instructions carry a 'Video length: 60' line and 30 seconds otherwise; a 'Video length: 30' line means 30 seconds. 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. A 'Video kind: Project demo' line means that same whole-project demo. A Blog post or Feature kind with no 'Video target:' line, or with a target you cannot find in the repository or read at its URL, also means that same whole-project demo: never pick a post or feature yourself, say so in your report, and save the kind as project-demo. When the target makes claims about how this project works, check each one against the code: drop a claim the code contradicts or attribute it to the post, and never narrate it as fact about the project. 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. A 'Character: off' line means no mascot: make a type-led animation in the chosen style that tells the same real story through moving type and shapes, skip the character wherever the persona uses one (design, _character, project_character_write, lip-sync, the character self-check) and save meta.character as null; a 'Character: on' line or no Character line keeps the mascot. 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. A 'Video style: Auto' line means the same: pick the style 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."
71
72
  }),
72
73
  Object.freeze({
73
74
  id: 'builtin-review-md-network',
@@ -544,6 +544,17 @@ const SHIPPED_PERSONA_SEEDS = deepFreeze({
544
544
  tools: "Read, Grep, Glob, Bash, Write, Edit, mcp__session-manager-scheduler__project_demo_video_write, mcp__session-manager-scheduler__project_video_write, mcp__session-manager-scheduler__project_character_write",
545
545
  },
546
546
  },
547
+ {
548
+ commit: "seed-v13",
549
+ bodySha256: "c2d469bb8386e19c1e2f0de79e7c891eed3a10bc81d0ac4ab93436beca286080",
550
+ fm: {
551
+ description: "30-second or 1-minute self-contained HTML/JS demo video for Project Home, saved via project_video_write.",
552
+ tools: "Read, Grep, Glob, Bash, Write, Edit, mcp__session-manager-scheduler__project_demo_video_write, mcp__session-manager-scheduler__project_video_write, mcp__session-manager-scheduler__project_character_write",
553
+ title: "Project Home — Demo Video",
554
+ model: "opus",
555
+ effort: "max",
556
+ },
557
+ },
547
558
  ],
548
559
  "blender-artist": [
549
560
  {
@@ -323,8 +323,8 @@ async function createPrdInner(input, remote, ctl, opts = {}) {
323
323
  if (row && row.developLoop === false) {
324
324
  return {
325
325
  ok: false, applied: false, status: 409,
326
- error: `Epic ${input.sourcePromptId} was started with the develop loop off, so it cannot queue PRDs. `
327
- + 'Start a new session with the develop loop on to queue this work.',
326
+ error: `Epic ${input.sourcePromptId} was started as a just Claude session (develop loop off), so it cannot queue PRDs. `
327
+ + "Start a new session with 'just Claude' turned off to queue this work.",
328
328
  };
329
329
  }
330
330
  }
@@ -48,6 +48,10 @@ const EpicSourceSchema = z.object({
48
48
  // Zod strips undeclared keys on the merge path; a stricter shape could make dropInvalidSessions (ipcSchemas.cjs) drop a whole row holding an older or malformed value.
49
49
  proposal: z.unknown().optional(),
50
50
  autoApprove: z.unknown().optional(),
51
+ // Cross-project thread: replyTo = the asking Epic a reply goes back to
52
+ // ({ cwd, epicId, claudeSessionId }); replyOf = the Epic a reply answers.
53
+ replyTo: z.unknown().optional(),
54
+ replyOf: z.unknown().optional(),
51
55
  });
52
56
 
53
57
  // Mirrors EpicIntakeSection (src/renderer/lib/epicIntake.ts) — the labeled
@@ -103,6 +107,10 @@ const PromptSessionSchema = z.object({
103
107
  agentCli: z.string().max(32).optional(),
104
108
  // Optional model string passed to that CLI; absent = the CLI's own default.
105
109
  agentCliModel: z.string().max(128).optional(),
110
+ // Selected context pack ids. Set at creation (no mid-Epic edit path in v1); absent = no packs.
111
+ // Unknown ids are kept (bounded strings, never an enum) so dropInvalidSessions (ipcSchemas.cjs)
112
+ // never drops a row for a pack id a newer build ships and this one does not know.
113
+ packs: z.array(z.string().min(1).max(64)).max(16).optional(),
106
114
  // true = this Epic adopted an existing CLI session as its claudeSessionId
107
115
  // (ensureEpic's restoreSessionId) instead of a fresh one; absent otherwise.
108
116
  // Only true is ever written: a false would fail here, and dropInvalidSessions