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.
- package/.claude-plugin/marketplace.json +1 -1
- package/README.md +2 -0
- package/dist/assets/{AgentLibrary-DKQznr7o.js → AgentLibrary-Cp250YHF.js} +1 -1
- package/dist/assets/{Button-CZXqmIiM.js → Button-DU5UF-6L.js} +1 -1
- package/dist/assets/{DataModel-piyV33To.js → DataModel-CPf6f17e.js} +1 -1
- package/dist/assets/{History-BxwtrKF2.js → History-B2x-LMlT.js} +1 -1
- package/dist/assets/{Hooks-DogeSPII.js → Hooks-BWr33C4Q.js} +1 -1
- package/dist/assets/{Library-BDt6EeQQ.js → Library-DBNLTAa8.js} +1 -1
- package/dist/assets/{ListDetail-CwS-LKar.js → ListDetail-BGBw6egp.js} +1 -1
- package/dist/assets/{McpServers-D2HVljgS.js → McpServers-DywZ50Ec.js} +1 -1
- package/dist/assets/{Memory-hNzuOGn8.js → Memory-CnalwnFf.js} +1 -1
- package/dist/assets/{Panel-BLDrsUeq.js → Panel-BzIklgKf.js} +1 -1
- package/dist/assets/{Permissions-DzZ5vaJW.js → Permissions-mgRifwQc.js} +1 -1
- package/dist/assets/{Plugins-Cz9yaxzG.js → Plugins-CV42zfid.js} +2 -2
- package/dist/assets/{ProvenanceBadge-CCgLO4m9.js → ProvenanceBadge-DYmX4xgB.js} +1 -1
- package/dist/assets/{SaveBar-Shmn699J.js → SaveBar-DxrAfnlC.js} +1 -1
- package/dist/assets/{Scheduler-Bqr0WHNd.js → Scheduler-iyUl1NDl.js} +1 -1
- package/dist/assets/{ScopeSwitcher-CBx1fB5g.js → ScopeSwitcher-CC8BDPgf.js} +1 -1
- package/dist/assets/{Settings-Ci8in-yF.js → Settings-CWBnQghD.js} +1 -1
- package/dist/assets/{SkillReferenceGraph-BWwljba8.js → SkillReferenceGraph-DOhiCxuL.js} +1 -1
- package/dist/assets/{Skills-BON6o-c4.js → Skills-3Er-9YA9.js} +1 -1
- package/dist/assets/{SystemPrompt-D5epIYYs.js → SystemPrompt-BLxdvZ9K.js} +1 -1
- package/dist/assets/{TagLibrary-C2qDZROJ.js → TagLibrary-BZ6QHYMQ.js} +1 -1
- package/dist/assets/{TiptapBody-SZhI3-bW.js → TiptapBody-Du6jRBoW.js} +1 -1
- package/dist/assets/{Toggle-C_qFDG0g.js → Toggle-Qdi2Z7VD.js} +1 -1
- package/dist/assets/{ViewTabs-C9q5WCEd.js → ViewTabs-BKfFsziD.js} +1 -1
- package/dist/assets/{historyTotals-BCl7IOhY.js → historyTotals-8ecP_6wF.js} +1 -1
- package/dist/assets/{index-BnKaYERU.css → index-DtdWBGrI.css} +1 -1
- package/dist/assets/index-GI6F_j41.js +3083 -0
- package/dist/assets/{settingsSchema-BBrRBrBr.js → settingsSchema-lHTHAabD.js} +1 -1
- package/dist/assets/{skillFrontmatter-B01qJk6N.js → skillFrontmatter-8X1Uc282.js} +1 -1
- package/dist/assets/{useAgentsDirWatch-CuR3GSjS.js → useAgentsDirWatch-CcsoD1bp.js} +1 -1
- package/dist/index.html +2 -2
- package/dist-web/app.css +1 -1
- package/dist-web/app.js +373 -369
- package/package.json +1 -1
- package/plugins/session-manager-dev/.claude-plugin/plugin.json +1 -1
- package/plugins/session-manager-dev/skills/develop/SKILL.md +4 -2
- package/scripts/hooks/lib/guard-inline-implementation-policy.cjs +10 -0
- package/scripts/scheduler-mcp-server.cjs +170 -6
- package/src/main/build-info.json +4 -4
- package/src/main/chatRunner.cjs +8 -0
- package/src/main/index.cjs +27 -0
- package/src/main/ipcSchemas.cjs +110 -1
- package/src/main/lib/claude/agentModelResolve.cjs +31 -10
- package/src/main/lib/claude/effectiveModelInfo.cjs +14 -4
- package/src/main/lib/claude/modelCatalog.cjs +28 -1
- package/src/main/lib/claude/personaToolScope.cjs +40 -2
- package/src/main/lib/demo-video-kit/capture.cjs +113 -0
- package/src/main/lib/demo-video-kit/character.cjs +97 -0
- package/src/main/lib/demo-video-kit/checks.cjs +150 -0
- package/src/main/lib/demo-video-kit/frames.cjs +200 -0
- package/src/main/lib/demo-video-kit/seedKit.cjs +52 -0
- package/src/main/lib/demo-video-kit/sound.cjs +312 -0
- package/src/main/lib/epic/developLoopSpawn.cjs +18 -0
- package/src/main/lib/epic/epicMint.cjs +4 -2
- package/src/main/lib/epic/epicValidationHook.cjs +17 -1
- package/src/main/lib/epic/promptSessionsCreateEpic.cjs +4 -3
- package/src/main/lib/feedback-remote/crossProjectFeedback.cjs +21 -21
- package/src/main/lib/feedback-remote/projectHomeAdminRoutes.cjs +185 -34
- package/src/main/lib/feedback-remote/remoteIpcDispatch.cjs +15 -0
- package/src/main/lib/mcpToolCatalog.cjs +71 -11
- package/src/main/lib/opsOwnership.cjs +9 -5
- package/src/main/lib/persona-macro/builtinMacros.cjs +19 -5
- package/src/main/lib/persona-macro/macroJobDispatch.cjs +116 -0
- package/src/main/lib/persona-macro/macroJobIpc.cjs +50 -0
- package/src/main/lib/persona-macro/macroJobStatus.cjs +112 -0
- package/src/main/lib/persona-macro/macroLibrary.cjs +16 -0
- package/src/main/lib/persona-macro/shippedPersonaSeeds.cjs +113 -0
- package/src/main/lib/prd/prdCreate.cjs +27 -1
- package/src/main/lib/prd/prdFrontmatter.cjs +7 -2
- package/src/main/lib/project-pages/pagesLibrary.cjs +171 -0
- package/src/main/lib/project-pages/playerBridge.cjs +129 -0
- package/src/main/lib/promptSessionSchema.cjs +8 -0
- package/src/main/lib/scheduler/scheduleJobSchema.cjs +2 -0
- package/src/main/lib/smfileHeaders.cjs +11 -3
- package/src/main/projectPages.cjs +107 -30
- package/src/main/promptSessionsIpc.cjs +131 -0
- package/src/main/scheduler/prdParser.cjs +2 -0
- package/src/main/scheduler.cjs +26 -9
- package/src/main/seedSchedulerMcp.cjs +10 -1
- package/src/main/transcripts.cjs +8 -0
- package/src/main/webRemote.cjs +3 -1
- package/src/preload/api.d.ts +107 -6
- package/src/preload/apiSurface.json +77 -0
- package/src/preload/index.cjs +18 -0
- package/src/seed/agents/architect.md +8 -8
- package/src/seed/agents/demo-video-builder.md +86 -36
- package/src/seed/agents/project-home-builder.md +26 -13
- package/dist/assets/index-CMIYLbPb.js +0 -3079
- package/src/main/lib/epic/epicStandingInstructions.cjs +0 -73
|
@@ -0,0 +1,171 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* pagesLibrary.cjs — Project Home library storage. One folder per entry under
|
|
5
|
+
* `project-pages/knowledge/<id>/` and `project-pages/videos/<id>/`, each with
|
|
6
|
+
* `index.html` + `meta.json`. The folder listing IS the library (no manifest).
|
|
7
|
+
* listLibrary() reads it newest-first; migrateLegacy() moves the old single
|
|
8
|
+
* `home.html` and `demo-video/index.html` into it exactly once, keeping the
|
|
9
|
+
* originals as `<name>.migrated`. All writes go through config.writeTextAtomic
|
|
10
|
+
* with writer 'project-home' (single-writer law, opsOwnership.cjs).
|
|
11
|
+
*/
|
|
12
|
+
|
|
13
|
+
const fs = require('node:fs');
|
|
14
|
+
const fsp = require('node:fs/promises');
|
|
15
|
+
const path = require('node:path');
|
|
16
|
+
const crypto = require('node:crypto');
|
|
17
|
+
const config = require('../../config.cjs');
|
|
18
|
+
const { opsPath, assertOpsWrite } = require('../opsOwnership.cjs');
|
|
19
|
+
const { injectPlayerBridge } = require('./playerBridge.cjs');
|
|
20
|
+
|
|
21
|
+
const WRITER = 'project-home';
|
|
22
|
+
const MAX_ENTRIES = 500;
|
|
23
|
+
const SKIP_DIRS = new Set(['_character']);
|
|
24
|
+
const KINDS = /** @type {const} */ (['knowledge', 'videos']);
|
|
25
|
+
|
|
26
|
+
/** opsPath, with the ephemeral-cwd throw mapped to null ("nothing to do"). */
|
|
27
|
+
function pagesPath(realCwd, ...parts) {
|
|
28
|
+
try {
|
|
29
|
+
return opsPath(realCwd, 'project-pages', ...parts);
|
|
30
|
+
} catch (e) {
|
|
31
|
+
if (e && e.ephemeral) return null;
|
|
32
|
+
throw e;
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
function oneLine(msg) {
|
|
37
|
+
return String(msg).replace(/\s+/g, ' ').trim().slice(0, 200) || 'invalid meta';
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
async function readEntry(kind, dir, id) {
|
|
41
|
+
const file = path.join(dir, 'index.html');
|
|
42
|
+
let st;
|
|
43
|
+
try {
|
|
44
|
+
st = await fsp.stat(file);
|
|
45
|
+
} catch {
|
|
46
|
+
return null; // folder without index.html is not an entry
|
|
47
|
+
}
|
|
48
|
+
const { schemas } = require('../../ipcSchemas.cjs');
|
|
49
|
+
const schema = kind === 'videos' ? schemas.projectVideoMeta : schemas.projectPageMeta;
|
|
50
|
+
let meta = null;
|
|
51
|
+
let error = null;
|
|
52
|
+
try {
|
|
53
|
+
const raw = await fsp.readFile(path.join(dir, 'meta.json'), 'utf8');
|
|
54
|
+
const parsed = schema.safeParse(JSON.parse(raw));
|
|
55
|
+
if (parsed.success) meta = parsed.data;
|
|
56
|
+
else error = oneLine(`meta.json invalid: ${parsed.error.issues[0]?.path.join('.') || ''} ${parsed.error.issues[0]?.message || ''}`);
|
|
57
|
+
} catch (e) {
|
|
58
|
+
error = oneLine(e && e.code === 'ENOENT' ? 'meta.json missing' : `meta.json unreadable: ${e && e.message}`);
|
|
59
|
+
}
|
|
60
|
+
return { id, path: file, mtimeMs: st.mtimeMs, meta, error };
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
async function listKind(realCwd, kind) {
|
|
64
|
+
const root = pagesPath(realCwd, kind);
|
|
65
|
+
if (!root) return [];
|
|
66
|
+
let dirents;
|
|
67
|
+
try {
|
|
68
|
+
dirents = await fsp.readdir(root, { withFileTypes: true });
|
|
69
|
+
} catch (e) {
|
|
70
|
+
if (e.code === 'ENOENT') return [];
|
|
71
|
+
throw e;
|
|
72
|
+
}
|
|
73
|
+
const dirs = dirents.filter((d) => d.isDirectory() && !SKIP_DIRS.has(d.name)).slice(0, MAX_ENTRIES);
|
|
74
|
+
const entries = (await Promise.all(dirs.map((d) => readEntry(kind, path.join(root, d.name), d.name)))).filter(Boolean);
|
|
75
|
+
const stamp = (e) => {
|
|
76
|
+
const t = e.meta ? Date.parse(e.meta.createdAt) : NaN;
|
|
77
|
+
return Number.isFinite(t) ? t : e.mtimeMs;
|
|
78
|
+
};
|
|
79
|
+
return entries.sort((a, b) => stamp(b) - stamp(a));
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
/** -> { knowledge: Entry[], videos: Entry[] }, newest first. */
|
|
83
|
+
async function listLibrary(realCwd) {
|
|
84
|
+
const [knowledge, videos] = await Promise.all(KINDS.map((k) => listKind(realCwd, k)));
|
|
85
|
+
return { knowledge, videos };
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
/** Write `outBuf` into `destDir/index.html` + meta; true only after a byte-equal verified write. */
|
|
89
|
+
async function copyIntoEntry(outBuf, destDir, meta) {
|
|
90
|
+
const dest = path.join(destDir, 'index.html');
|
|
91
|
+
await config.writeTextAtomic(dest, outBuf.toString('utf8'), { writer: WRITER });
|
|
92
|
+
const back = await fsp.readFile(dest);
|
|
93
|
+
if (!back.equals(outBuf)) return false;
|
|
94
|
+
await config.writeTextAtomic(path.join(destDir, 'meta.json'), JSON.stringify(meta, null, 2) + '\n', { writer: WRITER });
|
|
95
|
+
return true;
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
/** Rename through the same validation + ownership check writeTextAtomic uses. */
|
|
99
|
+
async function renameMigrated(file) {
|
|
100
|
+
const real = config.validatePath(file);
|
|
101
|
+
config.validateWrite(real);
|
|
102
|
+
assertOpsWrite(real, WRITER);
|
|
103
|
+
const target = `${real}.migrated`;
|
|
104
|
+
config.validateWrite(target);
|
|
105
|
+
assertOpsWrite(target, WRITER);
|
|
106
|
+
await fsp.rename(real, target);
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
async function readIfFile(file) {
|
|
110
|
+
try {
|
|
111
|
+
return await fsp.readFile(file);
|
|
112
|
+
} catch (e) {
|
|
113
|
+
if (e.code === 'ENOENT') return null;
|
|
114
|
+
throw e;
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
function demoLengthS(html) {
|
|
119
|
+
const m = /<meta\s+name=["']sm-demo-duration["']\s+content=["'](\d+(?:\.\d+)?)["']/i.exec(html);
|
|
120
|
+
const n = m ? Math.round(Number(m[1])) : NaN;
|
|
121
|
+
return Number.isFinite(n) && n >= 5 && n <= 60 ? n : 30;
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
/** One-shot move of the legacy home.html / demo-video/index.html into the library. Idempotent. */
|
|
125
|
+
async function migrateLegacy(realCwd) {
|
|
126
|
+
const home = pagesPath(realCwd, 'home.html');
|
|
127
|
+
if (!home) return;
|
|
128
|
+
|
|
129
|
+
// home.html -> knowledge/overview/
|
|
130
|
+
const overviewDir = pagesPath(realCwd, 'knowledge', 'overview');
|
|
131
|
+
const homeBuf = await readIfFile(home);
|
|
132
|
+
if (homeBuf && !fs.existsSync(overviewDir)) {
|
|
133
|
+
const st = await fsp.stat(home);
|
|
134
|
+
const meta = {
|
|
135
|
+
id: 'overview',
|
|
136
|
+
title: 'Overview',
|
|
137
|
+
topic: 'overview',
|
|
138
|
+
createdAt: new Date(st.mtimeMs).toISOString(),
|
|
139
|
+
model: 'unknown',
|
|
140
|
+
};
|
|
141
|
+
if (await copyIntoEntry(homeBuf, overviewDir, meta)) await renameMigrated(home);
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
// demo-video/index.html -> videos/legacy-<sha10>/
|
|
145
|
+
const demo = pagesPath(realCwd, 'demo-video', 'index.html');
|
|
146
|
+
const demoBuf = await readIfFile(demo);
|
|
147
|
+
if (demoBuf) {
|
|
148
|
+
const st = await fsp.stat(demo);
|
|
149
|
+
const id = `legacy-${crypto.createHash('sha256').update(demoBuf).digest('hex').slice(0, 10)}`;
|
|
150
|
+
// Bridge goes into the migrated copy only; the id hashes the ORIGINAL bytes.
|
|
151
|
+
const bridgedBuf = Buffer.from(injectPlayerBridge(demoBuf.toString('utf8')), 'utf8');
|
|
152
|
+
const meta = {
|
|
153
|
+
id,
|
|
154
|
+
title: 'Demo video',
|
|
155
|
+
kind: 'project-demo',
|
|
156
|
+
style: 'legacy',
|
|
157
|
+
lengthS: demoLengthS(demoBuf.toString('utf8')),
|
|
158
|
+
createdAt: new Date(st.mtimeMs).toISOString(),
|
|
159
|
+
character: null,
|
|
160
|
+
sources: [],
|
|
161
|
+
report: { lufs: null, truePeakDb: null, speechS: null, readingGrade: null, checks: [], bytes: bridgedBuf.length },
|
|
162
|
+
macroVersion: 0,
|
|
163
|
+
seedVersion: 0,
|
|
164
|
+
model: 'unknown',
|
|
165
|
+
effort: 'unknown',
|
|
166
|
+
};
|
|
167
|
+
if (await copyIntoEntry(bridgedBuf, pagesPath(realCwd, 'videos', id), meta)) await renameMigrated(demo);
|
|
168
|
+
}
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
module.exports = { listLibrary, migrateLegacy };
|
|
@@ -0,0 +1,129 @@
|
|
|
1
|
+
// @ts-check
|
|
2
|
+
// Inline postMessage bridge injected next to the CSP so Project Home can drive
|
|
3
|
+
// a sandboxed (no same-origin) demo video. Replies go to event.source only.
|
|
4
|
+
// Must stay clean under validateDemoVideoHtml's NETWORK_CHECKS.
|
|
5
|
+
|
|
6
|
+
const BRIDGE_JS = `(() => {
|
|
7
|
+
var timer = null;
|
|
8
|
+
var flag = false;
|
|
9
|
+
var muted = false;
|
|
10
|
+
const demo = () => { return window.smDemo || null; }
|
|
11
|
+
const num = (v, d) => { return typeof v === 'number' && isFinite(v) ? v : d; }
|
|
12
|
+
const call = (name, arg) => {
|
|
13
|
+
var d = demo();
|
|
14
|
+
if (d && typeof d[name] === 'function') { d[name](arg); return true; }
|
|
15
|
+
return false;
|
|
16
|
+
}
|
|
17
|
+
const media = () => { return document.querySelectorAll('audio,video'); }
|
|
18
|
+
const duration = () => {
|
|
19
|
+
var d = demo();
|
|
20
|
+
if (d) {
|
|
21
|
+
var v = typeof d.duration === 'function' ? d.duration() : d.duration;
|
|
22
|
+
if (typeof v === 'number' && isFinite(v) && v > 0) return v;
|
|
23
|
+
}
|
|
24
|
+
var m = document.querySelector('meta[name="sm-demo-duration"]');
|
|
25
|
+
if (m) { var n = Number(m.getAttribute('content')); if (isFinite(n) && n > 0) return n; }
|
|
26
|
+
var els = media();
|
|
27
|
+
for (var i = 0; i < els.length; i++) { if (isFinite(els[i].duration) && els[i].duration > 0) return els[i].duration; }
|
|
28
|
+
return 0;
|
|
29
|
+
}
|
|
30
|
+
const now = () => {
|
|
31
|
+
var d = demo();
|
|
32
|
+
if (d) {
|
|
33
|
+
if (typeof d.getTime === 'function') return num(d.getTime(), 0);
|
|
34
|
+
if (typeof d.t === 'number') return d.t;
|
|
35
|
+
if (typeof d.time === 'number') return d.time;
|
|
36
|
+
}
|
|
37
|
+
var el = media()[0];
|
|
38
|
+
return el ? num(el.currentTime, 0) : 0;
|
|
39
|
+
}
|
|
40
|
+
const playing = () => {
|
|
41
|
+
var d = demo();
|
|
42
|
+
if (d) {
|
|
43
|
+
if (typeof d.isPlaying === 'function') return !!d.isPlaying();
|
|
44
|
+
if (typeof d.playing === 'boolean') return d.playing;
|
|
45
|
+
}
|
|
46
|
+
return flag;
|
|
47
|
+
}
|
|
48
|
+
const scenes = () => {
|
|
49
|
+
var d = demo();
|
|
50
|
+
var out = [];
|
|
51
|
+
var src = d && Array.isArray(d.scenes) ? d.scenes : [];
|
|
52
|
+
for (var i = 0; i < src.length; i++) {
|
|
53
|
+
var s = src[i] || {};
|
|
54
|
+
var t = typeof s.t === 'number' ? s.t : s.start;
|
|
55
|
+
var label = s.label != null ? s.label : s.title;
|
|
56
|
+
if (typeof t === 'number' && isFinite(t)) out.push({ t: t, label: label == null ? '' : String(label) });
|
|
57
|
+
}
|
|
58
|
+
return out;
|
|
59
|
+
}
|
|
60
|
+
const snapshot = () => {
|
|
61
|
+
return { smPlayer: 1, type: 'state', duration: duration(), t: now(), playing: playing(), muted: muted, scenes: scenes() };
|
|
62
|
+
}
|
|
63
|
+
const stopTimer = () => { if (timer !== null) { clearInterval(timer); timer = null; } }
|
|
64
|
+
const reply = (src) => {
|
|
65
|
+
if (!src || typeof src.postMessage !== 'function') return;
|
|
66
|
+
var s = snapshot();
|
|
67
|
+
src.postMessage(s, '*');
|
|
68
|
+
if (!s.playing) stopTimer();
|
|
69
|
+
}
|
|
70
|
+
const startTimer = (src) => {
|
|
71
|
+
stopTimer();
|
|
72
|
+
timer = setInterval(() => { reply(src); }, 250);
|
|
73
|
+
}
|
|
74
|
+
const setMuted = (m) => {
|
|
75
|
+
muted = m;
|
|
76
|
+
var els = media();
|
|
77
|
+
for (var i = 0; i < els.length; i++) els[i].muted = m;
|
|
78
|
+
call('setMuted', m);
|
|
79
|
+
}
|
|
80
|
+
window.addEventListener('message', (e) => {
|
|
81
|
+
var data = e && e.data;
|
|
82
|
+
if (!data || typeof data !== 'object' || data.smPlayer !== 1) return;
|
|
83
|
+
var cmd = data.cmd;
|
|
84
|
+
if (cmd === 'play') {
|
|
85
|
+
flag = true;
|
|
86
|
+
if (!call('play')) { var el = media()[0]; if (el && typeof el.play === 'function') el.play(); }
|
|
87
|
+
} else if (cmd === 'pause') {
|
|
88
|
+
flag = false;
|
|
89
|
+
if (!call('pause')) { var el2 = media()[0]; if (el2 && typeof el2.pause === 'function') el2.pause(); }
|
|
90
|
+
} else if (cmd === 'restart') {
|
|
91
|
+
flag = true;
|
|
92
|
+
if (!call('restart')) { call('seek', 0); call('play'); }
|
|
93
|
+
} else if (cmd === 'seek') {
|
|
94
|
+
call('seek', num(data.t, 0));
|
|
95
|
+
} else if (cmd === 'mute') {
|
|
96
|
+
setMuted(true);
|
|
97
|
+
} else if (cmd === 'unmute') {
|
|
98
|
+
setMuted(false);
|
|
99
|
+
} else if (cmd !== 'hello') {
|
|
100
|
+
return;
|
|
101
|
+
}
|
|
102
|
+
reply(e.source);
|
|
103
|
+
if (playing() && e.source) startTimer(e.source);
|
|
104
|
+
});
|
|
105
|
+
})();`;
|
|
106
|
+
|
|
107
|
+
const PLAYER_BRIDGE_SCRIPT = `<script data-sm-player-bridge>${BRIDGE_JS}</script>`;
|
|
108
|
+
|
|
109
|
+
const CSP_META_RE = /<meta\b[^>]*\bhttp-equiv\s*=\s*["']Content-Security-Policy["'][^>]*>/i;
|
|
110
|
+
|
|
111
|
+
/**
|
|
112
|
+
* Inserts the bridge right after the CSP meta. Idempotent. If no CSP meta is
|
|
113
|
+
* present the bridge goes after a leading doctype (or at the very start).
|
|
114
|
+
* @param {string} html
|
|
115
|
+
* @returns {string}
|
|
116
|
+
*/
|
|
117
|
+
function injectPlayerBridge(html) {
|
|
118
|
+
if (typeof html !== 'string' || html.includes('data-sm-player-bridge')) return html;
|
|
119
|
+
const m = CSP_META_RE.exec(html);
|
|
120
|
+
if (m) {
|
|
121
|
+
const at = m.index + m[0].length;
|
|
122
|
+
return html.slice(0, at) + PLAYER_BRIDGE_SCRIPT + html.slice(at);
|
|
123
|
+
}
|
|
124
|
+
const dt = /^\s*<!DOCTYPE\b[^>]*>/i.exec(html);
|
|
125
|
+
const at = dt ? dt[0].length : 0;
|
|
126
|
+
return html.slice(0, at) + PLAYER_BRIDGE_SCRIPT + html.slice(at);
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
module.exports = { PLAYER_BRIDGE_SCRIPT, injectPlayerBridge };
|
|
@@ -59,6 +59,11 @@ const EpicIntakeSectionSchema = z.object({
|
|
|
59
59
|
label: z.string(),
|
|
60
60
|
text: z.string(),
|
|
61
61
|
source: z.string().optional(),
|
|
62
|
+
// Mirrors AimPart in src/renderer/lib/epicIntake.ts (main cannot import the
|
|
63
|
+
// renderer module). Optional because Epics minted before AIM sections carry
|
|
64
|
+
// none. NEVER narrow the kind enum above — dropInvalidSessions in
|
|
65
|
+
// ipcSchemas.cjs drops a whole stored Epic whose record fails this schema.
|
|
66
|
+
part: z.enum(['persona', 'grounding', 'injection', 'reference', 'job-type', 'goal']).optional(),
|
|
62
67
|
});
|
|
63
68
|
|
|
64
69
|
// Mirrors PromptSession's `worktree` field (src/renderer/state/
|
|
@@ -89,6 +94,9 @@ const PromptSessionSchema = z.object({
|
|
|
89
94
|
// Per-Epic runtime overrides chosen on the New Session card; absent = the persona's own value.
|
|
90
95
|
model: z.string().optional(),
|
|
91
96
|
effort: z.string().optional(),
|
|
97
|
+
// false = started with the develop loop (/develop skill, delegation guard, PRD queueing) switched off;
|
|
98
|
+
// fixed for the life of its session; absent = on; only false is ever written.
|
|
99
|
+
developLoop: z.boolean().optional(),
|
|
92
100
|
// Absent on Epics minted before this field existed — those fall back to
|
|
93
101
|
// rendering the flat `openingPrompt` as a single block (see
|
|
94
102
|
// ChatTranscriptTurn.tsx's EpicIntakeCard).
|
|
@@ -93,6 +93,8 @@ const ScheduleJobSchema = z
|
|
|
93
93
|
sourceTabId: z.string().nullable().optional(),
|
|
94
94
|
sourcePromptId: z.string().nullable().optional(),
|
|
95
95
|
epicId: z.string().nullable().optional(),
|
|
96
|
+
// Macro press this job's PRD came from (PRD frontmatter `macroId`).
|
|
97
|
+
macroId: z.string().nullable().optional(),
|
|
96
98
|
statusHistory: z.array(ScheduleJobStatusHistoryEntrySchema).optional(),
|
|
97
99
|
// Opt-in exclusive-lease PRD flag (PRD 1107) — serializes this job against
|
|
98
100
|
// every other job machine-wide for its run so a timing-sensitive gate
|
|
@@ -15,6 +15,14 @@ const DEMO_VIDEO_CSP_HEADER = [
|
|
|
15
15
|
].join('; ');
|
|
16
16
|
|
|
17
17
|
const DEMO_VIDEO_PATH_MARKER = '/session-manager-operations/project-pages/demo-video/';
|
|
18
|
+
const VIDEOS_PATH_MARKER = '/session-manager-operations/project-pages/videos/';
|
|
19
|
+
// Legacy demo-video marker stays until the videos/ migration has run everywhere.
|
|
20
|
+
const PATH_MARKERS = [DEMO_VIDEO_PATH_MARKER, VIDEOS_PATH_MARKER];
|
|
21
|
+
|
|
22
|
+
/** @param {string} normalised forward-slash path */
|
|
23
|
+
function matchesFence(normalised) {
|
|
24
|
+
return PATH_MARKERS.some((m) => normalised.includes(m));
|
|
25
|
+
}
|
|
18
26
|
|
|
19
27
|
/**
|
|
20
28
|
* Response headers for a file served over the smfile:// protocol. A file
|
|
@@ -27,7 +35,7 @@ const DEMO_VIDEO_PATH_MARKER = '/session-manager-operations/project-pages/demo-v
|
|
|
27
35
|
function smfileResponseHeaders(realPath, contentType) {
|
|
28
36
|
const normalised = String(realPath).replace(/\\/g, '/');
|
|
29
37
|
const headers = { 'content-type': contentType };
|
|
30
|
-
if (normalised
|
|
38
|
+
if (matchesFence(normalised)) {
|
|
31
39
|
headers['content-security-policy'] = DEMO_VIDEO_CSP_HEADER;
|
|
32
40
|
}
|
|
33
41
|
return headers;
|
|
@@ -55,7 +63,7 @@ function shouldBlockFrameNavigation({ isMainFrame, currentUrl, targetUrl }) {
|
|
|
55
63
|
} catch {
|
|
56
64
|
return false;
|
|
57
65
|
}
|
|
58
|
-
if (!pathname
|
|
66
|
+
if (!matchesFence(pathname)) return false;
|
|
59
67
|
|
|
60
68
|
if (typeof targetUrl !== 'string') return false;
|
|
61
69
|
if (targetUrl.startsWith('smfile:')) return false;
|
|
@@ -79,4 +87,4 @@ function smfileUrlToPath(pathname, platform = process.platform) {
|
|
|
79
87
|
return require('node:path').win32.normalize(stripped);
|
|
80
88
|
}
|
|
81
89
|
|
|
82
|
-
module.exports = { DEMO_VIDEO_CSP_HEADER, smfileResponseHeaders, shouldBlockFrameNavigation, smfileUrlToPath };
|
|
90
|
+
module.exports = { DEMO_VIDEO_CSP_HEADER, VIDEOS_PATH_MARKER, smfileResponseHeaders, shouldBlockFrameNavigation, smfileUrlToPath };
|
|
@@ -17,8 +17,9 @@ const fs = require('node:fs');
|
|
|
17
17
|
const path = require('node:path');
|
|
18
18
|
const chokidar = require('chokidar');
|
|
19
19
|
const config = require('./config.cjs');
|
|
20
|
-
const { opsPath } = require('./lib/opsOwnership.cjs');
|
|
20
|
+
const { opsPath, assertOpsWrite } = require('./lib/opsOwnership.cjs');
|
|
21
21
|
const { sendIfAlive } = require('./lib/sendToRenderer.cjs');
|
|
22
|
+
const { listLibrary, migrateLegacy } = require('./lib/project-pages/pagesLibrary.cjs');
|
|
22
23
|
|
|
23
24
|
let mainWindow = null;
|
|
24
25
|
function attachWindow(window) {
|
|
@@ -33,18 +34,6 @@ function demoVideoPath(cwd) {
|
|
|
33
34
|
return opsPath(cwd, 'project-pages', 'demo-video', 'index.html');
|
|
34
35
|
}
|
|
35
36
|
|
|
36
|
-
/** -> { path: string, mtimeMs: number } | null */
|
|
37
|
-
async function getDemoVideo(realCwd) {
|
|
38
|
-
const file = demoVideoPath(realCwd);
|
|
39
|
-
try {
|
|
40
|
-
const stat = await fs.promises.stat(file);
|
|
41
|
-
return { path: file, mtimeMs: stat.mtimeMs };
|
|
42
|
-
} catch (e) {
|
|
43
|
-
if (e.code === 'ENOENT') return null;
|
|
44
|
-
throw e;
|
|
45
|
-
}
|
|
46
|
-
}
|
|
47
|
-
|
|
48
37
|
/**
|
|
49
38
|
* Resolve `cwd`'s home.html path, treating the opsOwnership "ephemeral cwd"
|
|
50
39
|
* throw (a tmpdir/linked-worktree project root) as "no path available"
|
|
@@ -59,15 +48,47 @@ function tryHomePath(realCwd) {
|
|
|
59
48
|
}
|
|
60
49
|
}
|
|
61
50
|
|
|
62
|
-
|
|
51
|
+
const EMPTY = () => ({ knowledge: [], videos: [], html: null, mtimeMs: null, demoVideo: null });
|
|
52
|
+
|
|
53
|
+
/**
|
|
54
|
+
* -> { knowledge, videos, html, mtimeMs, demoVideo }. Runs the one-shot legacy
|
|
55
|
+
* migration first. html/mtimeMs come from the `overview` knowledge page and
|
|
56
|
+
* demoVideo from the newest video (both kept for the phone remote).
|
|
57
|
+
*/
|
|
63
58
|
async function get({ cwd }) {
|
|
64
59
|
const realCwd = config.validatePath(cwd);
|
|
65
|
-
const {
|
|
66
|
-
if (ephemeral) return
|
|
67
|
-
|
|
68
|
-
const
|
|
69
|
-
|
|
70
|
-
|
|
60
|
+
const { ephemeral } = tryHomePath(realCwd);
|
|
61
|
+
if (ephemeral) return EMPTY();
|
|
62
|
+
await migrateLegacy(realCwd);
|
|
63
|
+
const { knowledge, videos } = await listLibrary(realCwd);
|
|
64
|
+
const overview = knowledge.find((k) => k.id === 'overview');
|
|
65
|
+
let html = null;
|
|
66
|
+
if (overview) {
|
|
67
|
+
try {
|
|
68
|
+
html = await fs.promises.readFile(overview.path, 'utf8');
|
|
69
|
+
} catch (e) {
|
|
70
|
+
if (e.code !== 'ENOENT') throw e;
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
const newest = videos[0];
|
|
74
|
+
return {
|
|
75
|
+
knowledge,
|
|
76
|
+
videos,
|
|
77
|
+
html,
|
|
78
|
+
mtimeMs: html === null ? null : overview.mtimeMs,
|
|
79
|
+
demoVideo: newest ? { path: newest.path, mtimeMs: newest.mtimeMs } : null,
|
|
80
|
+
};
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
/** True for paths whose change should refresh the library (relative to project-pages/). */
|
|
84
|
+
function isLibraryPath(rel) {
|
|
85
|
+
const parts = rel.split(path.sep);
|
|
86
|
+
if (parts.length === 1) return parts[0] === 'home.html';
|
|
87
|
+
if (parts.length === 2) return parts[0] === 'demo-video' && parts[1] === 'index.html';
|
|
88
|
+
if (parts.length === 3 && (parts[0] === 'knowledge' || parts[0] === 'videos')) {
|
|
89
|
+
return parts[1] !== '_character' && (parts[2] === 'index.html' || parts[2] === 'meta.json');
|
|
90
|
+
}
|
|
91
|
+
return false;
|
|
71
92
|
}
|
|
72
93
|
|
|
73
94
|
// ─── Push channel ─────────────────────────────────────────────────────────
|
|
@@ -110,13 +131,9 @@ async function watchOutput(cwd) {
|
|
|
110
131
|
const dir = path.dirname(file);
|
|
111
132
|
fs.mkdirSync(dir, { recursive: true });
|
|
112
133
|
|
|
113
|
-
const demoVideoFile = demoVideoPath(realCwd);
|
|
114
134
|
const push = async (changedPath) => {
|
|
115
|
-
// Only
|
|
116
|
-
if (changedPath)
|
|
117
|
-
const resolved = path.resolve(changedPath);
|
|
118
|
-
if (resolved !== path.resolve(file) && resolved !== path.resolve(demoVideoFile)) return;
|
|
119
|
-
}
|
|
135
|
+
// Only library files (and the two legacy ones) — ignore everything else.
|
|
136
|
+
if (changedPath && !isLibraryPath(path.relative(dir, path.resolve(changedPath)))) return;
|
|
120
137
|
let result;
|
|
121
138
|
try {
|
|
122
139
|
result = await get({ cwd: realCwd });
|
|
@@ -125,16 +142,15 @@ async function watchOutput(cwd) {
|
|
|
125
142
|
}
|
|
126
143
|
sendIfAlive(mainWindow, 'project-pages:changed', {
|
|
127
144
|
cwd: realCwd,
|
|
128
|
-
|
|
129
|
-
mtimeMs: result.mtimeMs,
|
|
130
|
-
demoVideo: result.demoVideo,
|
|
145
|
+
...result,
|
|
131
146
|
});
|
|
132
147
|
};
|
|
133
148
|
|
|
134
149
|
const watcher = chokidar.watch(dir, {
|
|
135
150
|
ignoreInitial: true,
|
|
136
151
|
persistent: true,
|
|
137
|
-
depth:
|
|
152
|
+
depth: 3,
|
|
153
|
+
ignored: (p) => p.split(path.sep).includes('_character'),
|
|
138
154
|
// Same 50ms/25ms shape config.cjs's generic watcher uses.
|
|
139
155
|
awaitWriteFinish: { stabilityThreshold: 50, pollInterval: 25 },
|
|
140
156
|
});
|
|
@@ -175,10 +191,69 @@ function closeAllOutputWatchers() {
|
|
|
175
191
|
outputWatchers.clear();
|
|
176
192
|
}
|
|
177
193
|
|
|
194
|
+
const WRITER = 'project-home';
|
|
195
|
+
|
|
196
|
+
/**
|
|
197
|
+
* Resolve one library entry folder for rename/delete. Refuses a bad id,
|
|
198
|
+
* '_character', a missing entry, and anything whose realpath is not a direct
|
|
199
|
+
* child (same name) of the kind folder — a symlink escape.
|
|
200
|
+
*/
|
|
201
|
+
async function resolveEntry({ cwd, kind, id }) {
|
|
202
|
+
const { schemas, ENTRY_ID_RE } = require('./ipcSchemas.cjs');
|
|
203
|
+
if (kind !== 'knowledge' && kind !== 'video') throw new Error('invalid kind');
|
|
204
|
+
if (typeof id !== 'string' || id === '_character' || !ENTRY_ID_RE.test(id)) throw new Error('invalid entry id');
|
|
205
|
+
const realCwd = config.validatePath(cwd);
|
|
206
|
+
const folder = kind === 'video' ? 'videos' : 'knowledge';
|
|
207
|
+
const kindDir = opsPath(realCwd, 'project-pages', folder);
|
|
208
|
+
const dir = path.join(kindDir, id);
|
|
209
|
+
let realDir;
|
|
210
|
+
let realKind;
|
|
211
|
+
try {
|
|
212
|
+
realDir = await fs.promises.realpath(dir);
|
|
213
|
+
realKind = await fs.promises.realpath(kindDir);
|
|
214
|
+
} catch (e) {
|
|
215
|
+
if (e.code === 'ENOENT') throw new Error('entry not found');
|
|
216
|
+
throw e;
|
|
217
|
+
}
|
|
218
|
+
if (path.dirname(realDir) !== realKind || path.basename(realDir) !== id) {
|
|
219
|
+
throw new Error('entry resolves outside its kind folder');
|
|
220
|
+
}
|
|
221
|
+
const st = await fs.promises.stat(realDir);
|
|
222
|
+
if (!st.isDirectory()) throw new Error('entry not found');
|
|
223
|
+
return { dir: realDir, schema: kind === 'video' ? schemas.projectVideoMeta : schemas.projectPageMeta };
|
|
224
|
+
}
|
|
225
|
+
|
|
226
|
+
/** Rewrite one entry's meta.json title (schema-validated before and after). */
|
|
227
|
+
async function renameEntry(input) {
|
|
228
|
+
const { dir, schema } = await resolveEntry(input);
|
|
229
|
+
const metaFile = path.join(dir, 'meta.json');
|
|
230
|
+
let raw;
|
|
231
|
+
try {
|
|
232
|
+
raw = JSON.parse(await fs.promises.readFile(metaFile, 'utf8'));
|
|
233
|
+
} catch (e) {
|
|
234
|
+
throw new Error(`meta.json unreadable: ${e.code === 'ENOENT' ? 'missing' : e.message}`);
|
|
235
|
+
}
|
|
236
|
+
const current = schema.safeParse(raw);
|
|
237
|
+
if (!current.success) throw new Error('meta.json invalid');
|
|
238
|
+
const next = schema.parse({ ...current.data, title: input.title });
|
|
239
|
+
await config.writeTextAtomic(metaFile, JSON.stringify(next, null, 2) + '\n', { writer: WRITER });
|
|
240
|
+
return { ok: true, title: next.title };
|
|
241
|
+
}
|
|
242
|
+
|
|
243
|
+
/** Remove exactly one entry folder. */
|
|
244
|
+
async function deleteEntry(input) {
|
|
245
|
+
const { dir } = await resolveEntry(input);
|
|
246
|
+
assertOpsWrite(dir, WRITER);
|
|
247
|
+
await fs.promises.rm(dir, { recursive: true, force: false });
|
|
248
|
+
return { ok: true };
|
|
249
|
+
}
|
|
250
|
+
|
|
178
251
|
function registerProjectPagesIpc() {
|
|
179
252
|
const { schemas: s, validated: v } = require('./ipcSchemas.cjs');
|
|
180
253
|
ipcMain.handle('project-pages:get', v(s.projectPagesCwd, get));
|
|
181
254
|
ipcMain.handle('project-pages:watch', v(s.projectPagesCwd, ({ cwd }) => watchOutput(cwd)));
|
|
255
|
+
ipcMain.handle('project-pages:rename', v(s.projectPagesRename, renameEntry));
|
|
256
|
+
ipcMain.handle('project-pages:delete', v(s.projectPagesDelete, deleteEntry));
|
|
182
257
|
ipcMain.handle('project-pages:unwatch', v(s.projectPagesCwd, ({ cwd }) => {
|
|
183
258
|
unwatchOutput(cwd);
|
|
184
259
|
return { ok: true };
|
|
@@ -189,6 +264,8 @@ module.exports = {
|
|
|
189
264
|
attachWindow,
|
|
190
265
|
registerProjectPagesIpc,
|
|
191
266
|
get,
|
|
267
|
+
renameEntry,
|
|
268
|
+
deleteEntry,
|
|
192
269
|
watchOutput,
|
|
193
270
|
unwatchOutput,
|
|
194
271
|
closeAllOutputWatchers,
|