claude-code-session-manager 0.142.0 → 0.144.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 +22 -107
- package/dist/assets/AppSettings-Z68gQiVE.js +2 -0
- package/dist/assets/{History-DpZuJXi1.js → History-C3E6y_7t.js} +2 -2
- package/dist/assets/HomeClaudeConfig-Yd1vXzBn.js +5 -0
- package/dist/assets/{Panel-BjdJjhqt.js → Panel-CnfWs46Z.js} +1 -1
- package/dist/assets/ProjectClaudeConfig-CP0Wsg-H.js +26 -0
- package/dist/assets/Scheduler-D8un7N3B.js +16 -0
- package/dist/assets/{SkillReferenceGraph-Cqyu4mef.js → SkillReferenceGraph-DRtZV1Al.js} +1 -1
- package/dist/assets/{Skills-vv0noNVI.js → Skills-Bg5O2Hyn.js} +23 -23
- package/dist/assets/{TiptapBody-CXi8Pvut.js → TiptapBody-BdzoBmqu.js} +27 -27
- package/dist/assets/{Toggle-CiYCWLjh.js → Toggle-Dt5K1OXt.js} +1 -1
- package/dist/assets/{VoiceButton-4NKKd1sC.js → VoiceButton-CTLyRgdF.js} +1 -1
- package/dist/assets/{historyTotals-DDunb8Ch.js → historyTotals-B2_KWBga.js} +1 -1
- package/dist/assets/{index-Cn5E9958.js → index-446b69rr.js} +715 -714
- package/dist/assets/{index-DVHIHoJf.css → index-BJ5TJvmz.css} +1 -1
- package/dist/index.html +2 -2
- package/dist-web/app.css +1 -1
- package/dist-web/app.js +438 -435
- package/package.json +6 -4
- package/plugins/session-manager-dev/.claude-plugin/plugin.json +1 -1
- package/plugins/session-manager-dev/skills/builder/SKILL.md +5 -0
- package/plugins/session-manager-dev/skills/develop/SKILL.md +23 -16
- package/plugins/session-manager-dev/skills/maintaining-md-network/SKILL.md +16 -2
- package/plugins/session-manager-dev/skills/maintaining-md-network/weekly-consolidation.md +87 -0
- package/scripts/README.md +1 -0
- package/scripts/scheduler-mcp-server.cjs +381 -6
- package/src/main/adminRouteRegistry.cjs +16 -0
- package/src/main/agentLibrary.cjs +60 -11
- package/src/main/agentsIpc.cjs +19 -0
- package/src/main/build-info.json +4 -4
- package/src/main/chatRunner.cjs +214 -7
- package/src/main/config.cjs +5 -1
- package/src/main/health.cjs +92 -14
- package/src/main/index.cjs +16 -4
- package/src/main/ipcSchemas.cjs +61 -1
- package/src/main/lib/claude/agentArmory.cjs +128 -0
- package/src/main/lib/claude/agentModelResolve.cjs +3 -2
- package/src/main/lib/claude/agentSnapshot.cjs +24 -3
- package/src/main/lib/claude/builtinTools.cjs +110 -0
- package/src/main/lib/claude/environmentProfiles.cjs +1 -1
- package/src/main/lib/claude/headlessMcpServers.cjs +138 -0
- package/src/main/lib/claude/jobSandboxPolicy.cjs +8 -2
- package/src/main/lib/claude/personaToolScope.cjs +77 -6
- package/src/main/lib/demo-video-kit/cast.md +10 -1
- package/src/main/lib/demo-video-kit/character.cjs +77 -21
- package/src/main/lib/demo-video-kit/kind-tiktok.md +5 -1
- package/src/main/lib/demo-video-kit/projectSounds.cjs +191 -0
- package/src/main/lib/demo-video-kit/seedKit.cjs +3 -3
- package/src/main/lib/demo-video-kit/sound.cjs +166 -9
- package/src/main/lib/demo-video-kit/standalone.cjs +231 -0
- package/src/main/lib/epic/activeIndexMerge.cjs +5 -0
- package/src/main/lib/epic/artifactRetention.cjs +55 -9
- package/src/main/lib/epic/artifactStore.cjs +78 -35
- package/src/main/lib/epic/delegationReadiness.cjs +10 -3
- package/src/main/lib/epic/epicDepsSync.cjs +66 -0
- package/src/main/lib/epic/epicEventLog.cjs +45 -1
- package/src/main/lib/epic/epicOutsideRead.cjs +38 -1
- package/src/main/lib/epic/epicSettle.cjs +48 -4
- package/src/main/lib/epic/epicSpawnPlan.cjs +3 -1
- package/src/main/lib/epic/epicStateEmitter.cjs +248 -0
- package/src/main/lib/epic/epicValidationHook.cjs +22 -3
- package/src/main/lib/epic/planReviewInput.cjs +123 -0
- package/src/main/lib/epic/restorableSessions.cjs +1 -0
- package/src/main/lib/epic/scriptStartedBy.cjs +71 -0
- package/src/main/lib/externalContract.cjs +24 -1
- package/src/main/lib/feedback-remote/autoStartedSession.cjs +1 -1
- package/src/main/lib/feedback-remote/createdProjects.cjs +291 -0
- package/src/main/lib/feedback-remote/crossProjectFeedback.cjs +24 -2
- package/src/main/lib/feedback-remote/crossProjectReply.cjs +96 -8
- package/src/main/lib/feedback-remote/macroAdminRoutes.cjs +54 -3
- package/src/main/lib/feedback-remote/pendingReplies.cjs +22 -0
- package/src/main/lib/feedback-remote/projectCreate.cjs +415 -0
- package/src/main/lib/feedback-remote/projectHomeAdminRoutes.cjs +94 -4
- package/src/main/lib/feedback-remote/replyClaims.cjs +168 -0
- package/src/main/lib/feedback-remote/serviceMcpSession.cjs +29 -1
- package/src/main/lib/feedback-remote/serviceMcpTools.cjs +43 -2
- package/src/main/lib/feedback-remote/servicePairLocalRoutes.cjs +91 -0
- package/src/main/lib/feedback-remote/servicePairings.cjs +47 -7
- package/src/main/lib/feedback-remote/serviceStdioBridge.cjs +99 -1
- package/src/main/lib/git/gitWorktree.cjs +8 -0
- package/src/main/lib/git/runtimeStateUntrack.cjs +15 -1
- package/src/main/lib/git/worktreeDeps.cjs +119 -10
- package/src/main/lib/mcpToolCatalog.cjs +144 -12
- package/src/main/lib/mcpToolsProbe.cjs +19 -2
- package/src/main/lib/opsOwnership.cjs +113 -28
- package/src/main/lib/packs/packCatalog.cjs +98 -5
- package/src/main/lib/persona-macro/agentPersonaSchema.cjs +6 -0
- package/src/main/lib/persona-macro/builtinMacros.cjs +6 -4
- package/src/main/lib/persona-macro/personaFrontmatterSchema.cjs +9 -0
- package/src/main/lib/persona-macro/personaLoadout.cjs +58 -0
- package/src/main/lib/persona-macro/personaMerge.cjs +11 -3
- package/src/main/lib/persona-macro/personaUpgrade.cjs +96 -0
- package/src/main/lib/persona-macro/projectVideoToolCheck.cjs +1 -1
- package/src/main/lib/persona-macro/shippedPersonaSeeds.cjs +140 -0
- package/src/main/lib/prd/prdCreate.cjs +395 -229
- package/src/main/lib/prd/prdCriteria.cjs +7 -4
- package/src/main/lib/prd/prdFrontmatter.cjs +5 -2
- package/src/main/lib/prd/prdMcpReachWarnings.cjs +44 -0
- package/src/main/lib/prd/prdSandboxWarnings.cjs +49 -0
- package/src/main/lib/process/peerChatSession.cjs +165 -0
- package/src/main/lib/project-pages/videoPressLines.cjs +145 -0
- package/src/main/lib/project-pages/videoScriptPress.cjs +266 -0
- package/src/main/lib/project-pages/videoScriptRunRoute.cjs +371 -0
- package/src/main/lib/project-pages/videoScriptSwitchIpc.cjs +49 -0
- package/src/main/lib/project-pages/videoScriptSwitchRoute.cjs +173 -0
- package/src/main/lib/promptSessionSchema.cjs +2 -0
- package/src/main/lib/scheduler/baselineGate.cjs +31 -2
- package/src/main/lib/scheduler/criteriaChecks.cjs +164 -20
- package/src/main/lib/scheduler/heldSchedulerTurns.cjs +238 -0
- package/src/main/lib/scheduler/jobMemoryStats.cjs +13 -2
- package/src/main/lib/scheduler/planRecordHarvest.cjs +215 -55
- package/src/main/lib/scheduler/planReleaseRoute.cjs +110 -0
- package/src/main/lib/scheduler/planReviewSchema.cjs +182 -0
- package/src/main/lib/scheduler/planReviewStats.cjs +63 -0
- package/src/main/lib/scheduler/planReviewStore.cjs +128 -0
- package/src/main/lib/scheduler/prdOutcomeRecord.cjs +60 -2
- package/src/main/lib/scheduler/queueStore.cjs +16 -0
- package/src/main/lib/scheduler/rcaReport.cjs +79 -15
- package/src/main/lib/scheduler/sandboxEnvironmentLimit.cjs +141 -0
- package/src/main/lib/scheduler/scheduleJobSchema.cjs +15 -0
- package/src/main/lib/scheduler/schedulerPaths.cjs +9 -0
- package/src/main/lib/scheduler/slotsRoute.cjs +101 -87
- package/src/main/lib/scheduler/upgradeDrain.cjs +32 -5
- package/src/main/lib/scheduler/usageHoldRoute.cjs +97 -0
- package/src/main/lib/scheduler/validatorVerdictSchema.cjs +28 -7
- package/src/main/lib/tasks/memoryConsolidation.cjs +123 -39
- package/src/main/lib/tasks/mitigationReview.cjs +21 -1
- package/src/main/lib/tasks/taskAdminRoutes.cjs +104 -17
- package/src/main/lib/tasks/taskLedger.cjs +2 -2
- package/src/main/lib/tasks/taskRun.cjs +3 -1
- package/src/main/lib/tasks/weeklyConsolidationInputs.cjs +178 -0
- package/src/main/lib/telemetry/auditEvents.cjs +21 -24
- package/src/main/lib/telemetry/auditLog.cjs +6 -2
- package/src/main/lib/util/atomicFs.cjs +2 -2
- package/src/main/projectPages.cjs +22 -14
- package/src/main/promptSessionEvents.cjs +16 -1
- package/src/main/pty.cjs +14 -2
- package/src/main/queueOps.cjs +1 -1
- package/src/main/runVerify.cjs +4 -3
- package/src/main/scheduler/planReviewHold.cjs +140 -0
- package/src/main/scheduler/prdParser.cjs +1 -0
- package/src/main/scheduler/reviewLadder.cjs +2 -0
- package/src/main/scheduler/utilizationHold.cjs +101 -6
- package/src/main/scheduler.cjs +1055 -107
- package/src/main/seedAgentPersonas.cjs +11 -6
- package/src/main/seedStatus.cjs +1 -1
- package/src/main/templates/PRD_AUTHORING.md +22 -2
- package/src/main/webRemote.cjs +47 -7
- package/src/preload/api.d.ts +118 -2
- package/src/preload/apiSurface.json +42 -0
- package/src/preload/index.cjs +11 -0
- package/src/seed/agents/architect.md +28 -43
- package/src/seed/agents/demo-video-builder.md +15 -8
- package/src/seed/agents/dev-lead.md +3 -1
- package/src/seed/agents/md-network-curator.md +27 -0
- package/src/seed/agents/plan-reviewer.md +47 -0
- package/src/seed/agents/validator.md +21 -19
- package/dist/assets/AppSettings-BcZgIvvY.js +0 -2
- package/dist/assets/HomeClaudeConfig-D32ZJtU-.js +0 -3
- package/dist/assets/ProjectClaudeConfig-BTClYV6i.js +0 -26
- package/dist/assets/Scheduler-DPobKx1Z.js +0 -16
|
@@ -41,6 +41,7 @@ const USAGE = [
|
|
|
41
41
|
'usage:',
|
|
42
42
|
' claude-code-session-manager service pair --code <code> --name <name> --state-dir <dir> [--device <prefix>] [--timeout <seconds>]',
|
|
43
43
|
' claude-code-session-manager service mcp --state-dir <dir>',
|
|
44
|
+
' claude-code-session-manager service pair-local --state-dir <dir> --name <name> --home <cwd> --tools a,b,c [--project-root <dir>] [--timeout <seconds>]',
|
|
44
45
|
].join('\n');
|
|
45
46
|
|
|
46
47
|
/** Parses `--key value` / `--key=value` pairs. Returns { flags } or { error }. */
|
|
@@ -132,6 +133,100 @@ async function runPair(args, { stdout, stderr, clientFactory }) {
|
|
|
132
133
|
}
|
|
133
134
|
}
|
|
134
135
|
|
|
136
|
+
const NOT_RUNNING_MSG = 'session manager is not running (no admin-api.json)';
|
|
137
|
+
|
|
138
|
+
function errText(err) { return err && err.message ? err.message : String(err); }
|
|
139
|
+
|
|
140
|
+
/**
|
|
141
|
+
* Pairs a same-machine service through the loopback admin API, no window step.
|
|
142
|
+
* @param {{ stateDir: string, name: string, homeCwd: string, tools: string[], projectRoot?: string, timeoutS?: number, fetchImpl?: Function, clientFactory?: Function, adminApiPath?: string }} opts
|
|
143
|
+
* @returns {Promise<{ ok: true, service: any } | { ok: false, error: string }>}
|
|
144
|
+
*/
|
|
145
|
+
async function pairLocal(opts) {
|
|
146
|
+
const { stateDir, name, homeCwd, tools, projectRoot, timeoutS = DEFAULT_PAIR_TIMEOUT_S } = opts || {};
|
|
147
|
+
const fetchImpl = (opts && opts.fetchImpl) || globalThis.fetch;
|
|
148
|
+
const clientFactory = (opts && opts.clientFactory) || defaultClientFactory;
|
|
149
|
+
let admin;
|
|
150
|
+
try {
|
|
151
|
+
const adminApiPath = (opts && opts.adminApiPath) || require('../scheduler/schedulerPaths.cjs').adminTokenPath();
|
|
152
|
+
admin = require('../util/atomicFs.cjs').readJsonOrSync(adminApiPath, null);
|
|
153
|
+
} catch { return { ok: false, error: NOT_RUNNING_MSG }; }
|
|
154
|
+
if (!admin || !admin.port || !admin.token) return { ok: false, error: NOT_RUNNING_MSG };
|
|
155
|
+
const base = `http://127.0.0.1:${admin.port}/admin/services/pair-local`;
|
|
156
|
+
|
|
157
|
+
const post = async (url, body) => {
|
|
158
|
+
let res;
|
|
159
|
+
try {
|
|
160
|
+
res = await fetchImpl(url, {
|
|
161
|
+
method: 'POST',
|
|
162
|
+
headers: { 'content-type': 'application/json', authorization: `Bearer ${admin.token}` },
|
|
163
|
+
body: JSON.stringify(body),
|
|
164
|
+
});
|
|
165
|
+
} catch (err) { return { ok: false, error: `admin api unreachable: ${errText(err)}` }; }
|
|
166
|
+
let json = null;
|
|
167
|
+
try { json = await res.json(); } catch { /* non-JSON */ }
|
|
168
|
+
if (!res.ok || !json || json.ok === false) return { ok: false, error: (json && json.error) || `admin api HTTP ${res.status}` };
|
|
169
|
+
return json;
|
|
170
|
+
};
|
|
171
|
+
|
|
172
|
+
let client;
|
|
173
|
+
let timer = null;
|
|
174
|
+
try {
|
|
175
|
+
const startBody = { name, homeCwd, tools };
|
|
176
|
+
if (projectRoot) startBody.projectRoot = projectRoot;
|
|
177
|
+
const started = await post(base, startBody);
|
|
178
|
+
if (!started.ok) return { ok: false, error: started.error };
|
|
179
|
+
|
|
180
|
+
let rejectConfirm;
|
|
181
|
+
const confirmFailed = new Promise((_, rej) => { rejectConfirm = rej; });
|
|
182
|
+
confirmFailed.catch(() => {});
|
|
183
|
+
let confirmP = null;
|
|
184
|
+
const onSas = (sas) => {
|
|
185
|
+
if (confirmP || !sas) return;
|
|
186
|
+
confirmP = post(`${base}/confirm`, { pairingId: started.pairingId, sas: String(sas).replace(/\D/g, '') });
|
|
187
|
+
confirmP.then((r) => { if (!r.ok) rejectConfirm(new Error(r.error)); });
|
|
188
|
+
};
|
|
189
|
+
client = clientFactory({ stateDir, onSas });
|
|
190
|
+
await client.pair({ code: started.code, name });
|
|
191
|
+
const timeout = new Promise((_, reject) => {
|
|
192
|
+
timer = setTimeout(() => reject(new Error(`timed out after ${timeoutS} s waiting for pairing to confirm`)), timeoutS * 1000);
|
|
193
|
+
});
|
|
194
|
+
const res = await Promise.race([client.connect(), confirmFailed, timeout]);
|
|
195
|
+
if (res && res.sas) onSas(res.sas);
|
|
196
|
+
const confirmed = confirmP ? await confirmP : { ok: false, error: 'no SAS was derived' };
|
|
197
|
+
if (!confirmed.ok) return { ok: false, error: confirmed.error };
|
|
198
|
+
return { ok: true, service: confirmed.service };
|
|
199
|
+
} catch (err) {
|
|
200
|
+
return { ok: false, error: errText(err) };
|
|
201
|
+
} finally {
|
|
202
|
+
clearTimeout(timer);
|
|
203
|
+
try { if (client) client.close(); } catch { /* best-effort */ }
|
|
204
|
+
}
|
|
205
|
+
}
|
|
206
|
+
|
|
207
|
+
async function runPairLocal(args, { stdout, stderr, clientFactory, fetchImpl, adminApiPath }) {
|
|
208
|
+
const parsed = parseFlags(args, ['state-dir', 'name', 'home', 'tools', 'project-root', 'timeout']);
|
|
209
|
+
if (parsed.error) { line(stderr, `${parsed.error}\n${USAGE}`); return EXIT_USAGE; }
|
|
210
|
+
const { flags } = parsed;
|
|
211
|
+
for (const k of ['state-dir', 'name', 'home', 'tools']) {
|
|
212
|
+
if (!flags[k]) { line(stderr, `missing --${k}\n${USAGE}`); return EXIT_USAGE; }
|
|
213
|
+
}
|
|
214
|
+
const tools = flags.tools.split(',').map((t) => t.trim()).filter(Boolean);
|
|
215
|
+
if (!tools.length) { line(stderr, `missing --tools\n${USAGE}`); return EXIT_USAGE; }
|
|
216
|
+
let timeoutS = DEFAULT_PAIR_TIMEOUT_S;
|
|
217
|
+
if (flags.timeout !== undefined) {
|
|
218
|
+
timeoutS = Number(flags.timeout);
|
|
219
|
+
if (!Number.isFinite(timeoutS) || timeoutS <= 0) { line(stderr, `--timeout must be a positive number of seconds\n${USAGE}`); return EXIT_USAGE; }
|
|
220
|
+
}
|
|
221
|
+
const r = await pairLocal({
|
|
222
|
+
stateDir: flags['state-dir'], name: flags.name, homeCwd: flags.home, tools,
|
|
223
|
+
projectRoot: flags['project-root'], timeoutS, clientFactory, fetchImpl, adminApiPath,
|
|
224
|
+
});
|
|
225
|
+
if (!r.ok) { line(stderr, `service pair-local: ${r.error}`); return EXIT_FAIL; }
|
|
226
|
+
line(stdout, `Paired locally: ${flags.name}`);
|
|
227
|
+
return EXIT_OK;
|
|
228
|
+
}
|
|
229
|
+
|
|
135
230
|
function runMcp(args, { stdin, stdout, stderr, clientFactory }) {
|
|
136
231
|
const parsed = parseFlags(args, ['state-dir']);
|
|
137
232
|
if (parsed.error) { line(stderr, `${parsed.error}\n${USAGE}`); return Promise.resolve(EXIT_USAGE); }
|
|
@@ -279,12 +374,15 @@ async function runServiceCli(argv, io = {}) {
|
|
|
279
374
|
stdout: io.stdout || process.stdout,
|
|
280
375
|
stderr: io.stderr || process.stderr,
|
|
281
376
|
clientFactory: io.clientFactory || defaultClientFactory,
|
|
377
|
+
fetchImpl: io.fetchImpl,
|
|
378
|
+
adminApiPath: io.adminApiPath,
|
|
282
379
|
};
|
|
283
380
|
const [sub, ...rest] = Array.isArray(argv) ? argv : [];
|
|
284
381
|
if (sub === 'pair') return runPair(rest, deps);
|
|
382
|
+
if (sub === 'pair-local') return runPairLocal(rest, deps);
|
|
285
383
|
if (sub === 'mcp') return runMcp(rest, deps);
|
|
286
384
|
line(deps.stderr, sub ? `unknown service subcommand: ${sub}\n${USAGE}` : USAGE);
|
|
287
385
|
return EXIT_USAGE;
|
|
288
386
|
}
|
|
289
387
|
|
|
290
|
-
module.exports = { runServiceCli, USAGE, CONFIRM_HINT, REVOKED_MSG, EXIT_OK, EXIT_FAIL, EXIT_USAGE, EXIT_REVOKED };
|
|
388
|
+
module.exports = { runServiceCli, pairLocal, USAGE, CONFIRM_HINT, REVOKED_MSG, EXIT_OK, EXIT_FAIL, EXIT_USAGE, EXIT_REVOKED };
|
|
@@ -980,6 +980,14 @@ async function createWorktree({ kind, cwd, key, fromRef }) {
|
|
|
980
980
|
const epicDir = worktreeDirFor(kind, cwd, key);
|
|
981
981
|
const epicBranch = branchNameFor(kind, key);
|
|
982
982
|
if (fs.existsSync(epicDir) && await isRegisteredWorktreeOnBranch(cwd, epicDir, epicBranch)) {
|
|
983
|
+
// node_modules links are a snapshot from mint time: pick up packages main gained
|
|
984
|
+
// since (and drop links main lost). Best-effort — never fails the reuse.
|
|
985
|
+
try {
|
|
986
|
+
const sync = await require('./worktreeDeps.cjs').syncNodeModulesLinks({ mainCwd: cwd, worktreeCwd: epicDir });
|
|
987
|
+
if (sync && (sync.added || sync.removed || sync.kept)) console.log(`[gitWorktree] synced dep links: +${sync.added} -${sync.removed} kept=${sync.kept} -> ${epicDir}`);
|
|
988
|
+
} catch (err) {
|
|
989
|
+
console.warn(`[gitWorktree] dep link sync failed for ${epicDir}: ${(err && err.message) || err}`);
|
|
990
|
+
}
|
|
983
991
|
return { ok: true, dir: epicDir, branch: epicBranch, baseCwd: cwd, reused: true };
|
|
984
992
|
}
|
|
985
993
|
}
|
|
@@ -34,6 +34,20 @@ async function findTrackedRuntimeState(projectRoot) {
|
|
|
34
34
|
return out.split('\0').filter((p) => p && path.posix.basename(p) !== 'README.md');
|
|
35
35
|
}
|
|
36
36
|
|
|
37
|
+
/**
|
|
38
|
+
* Untracked runtime paths (repo-relative, posix) that git can see — i.e. not
|
|
39
|
+
* ignored by any .gitignore. Each one is a namespace missing its self-ignore.
|
|
40
|
+
*/
|
|
41
|
+
async function findVisibleRuntimeState(projectRoot) {
|
|
42
|
+
let out;
|
|
43
|
+
try {
|
|
44
|
+
out = await execGit(projectRoot, ['ls-files', '-z', '--others', '--exclude-standard', '--', ...nsPathspecs()], { maxBuffer: 64 * 1024 * 1024 });
|
|
45
|
+
} catch {
|
|
46
|
+
return [];
|
|
47
|
+
}
|
|
48
|
+
return out.split('\0').filter(Boolean);
|
|
49
|
+
}
|
|
50
|
+
|
|
37
51
|
/** Sorted list of every file on disk under the runtime namespaces. */
|
|
38
52
|
function listRuntimeFilesOnDisk(projectRoot) {
|
|
39
53
|
const found = [];
|
|
@@ -121,4 +135,4 @@ async function untrackRuntimeState(projectRoot, opts = {}) {
|
|
|
121
135
|
}
|
|
122
136
|
}
|
|
123
137
|
|
|
124
|
-
module.exports = { findTrackedRuntimeState, untrackRuntimeState, listRuntimeFilesOnDisk };
|
|
138
|
+
module.exports = { findTrackedRuntimeState, findVisibleRuntimeState, untrackRuntimeState, listRuntimeFilesOnDisk };
|
|
@@ -1,7 +1,18 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* worktreeDeps.cjs —
|
|
2
|
+
* worktreeDeps.cjs — link the main checkout's gitignored top-level
|
|
3
3
|
* dependency dirs (node_modules, .venv, venv) into a fresh worktree.
|
|
4
4
|
*
|
|
5
|
+
* node_modules is never linked whole: the worktree gets a REAL node_modules
|
|
6
|
+
* folder holding one symlink per entry of the main checkout's node_modules
|
|
7
|
+
* (packages, scope folders such as @types linked whole, and .bin; other dot
|
|
8
|
+
* entries — .vite, .cache, .package-lock.json — are not linked, so caches and
|
|
9
|
+
* npm's hidden lockfile stay worktree-local). Why: npm ci reads node_modules'
|
|
10
|
+
* entries and removes each one; through a whole-folder link that deletes the
|
|
11
|
+
* main checkout's packages (2026-11-24: a widget gate's
|
|
12
|
+
* `npm --prefix web/feedback-widget ci` emptied the main checkout's
|
|
13
|
+
* web/feedback-widget/node_modules). With per-entry links an install removes
|
|
14
|
+
* only links. .venv/venv keep the whole-folder link.
|
|
15
|
+
*
|
|
5
16
|
* `git worktree add` checks out tracked files only, so a job worktree has no
|
|
6
17
|
* dependencies and executors park needs_review. A gitignore pattern like
|
|
7
18
|
* `node_modules/` (trailing slash) matches directories only and a symlink is
|
|
@@ -41,11 +52,15 @@
|
|
|
41
52
|
* NESTED_MAX_DEPTH segments deep (never under node_modules), at most
|
|
42
53
|
* NESTED_MAX_PACKAGES of the eligible ones (main has `<dir>/node_modules`, it is
|
|
43
54
|
* gitignored there, the worktree has none — filtered before the cap), the dir is
|
|
44
|
-
*
|
|
55
|
+
* built from per-entry links to the main checkout's (as above) and `/<dir>/node_modules` goes to info/exclude
|
|
45
56
|
* after the link succeeds. Ineligible packages are not reported as skipped. pnpm projects skip this — their
|
|
46
57
|
* offline install already builds every workspace node_modules per worktree.
|
|
47
58
|
*
|
|
48
|
-
*
|
|
59
|
+
* syncNodeModulesLinks refreshes those per-entry links on a reused Epic worktree (the
|
|
60
|
+
* links are a snapshot; the old whole-folder link saw packages added to main later).
|
|
61
|
+
*
|
|
62
|
+
* Never throws; failures land in `skipped` (nested entries as `<rel> (<reason>)`);
|
|
63
|
+
* a failed node_modules build is removed again (links only, never their targets).
|
|
49
64
|
*/
|
|
50
65
|
'use strict';
|
|
51
66
|
|
|
@@ -67,6 +82,49 @@ function exists(p) {
|
|
|
67
82
|
try { fs.lstatSync(p); return true; } catch { return false; }
|
|
68
83
|
}
|
|
69
84
|
|
|
85
|
+
/** True for a node_modules entry that gets a link: anything not dot-prefixed, plus `.bin`. */
|
|
86
|
+
function isLinkedModulesEntry(name) {
|
|
87
|
+
return !name.startsWith('.') || name === '.bin';
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
/**
|
|
91
|
+
* Link every linked entry of `src` (a main-checkout node_modules) that `dest` (a real
|
|
92
|
+
* worktree node_modules folder) lacks. Existing dest entries — links or real — are never
|
|
93
|
+
* touched. `strict` rethrows a symlink failure (initial build); otherwise failures are
|
|
94
|
+
* skipped per entry. Returns the count of links made.
|
|
95
|
+
*/
|
|
96
|
+
function linkMissingModulesEntries(src, dest, strict) {
|
|
97
|
+
let added = 0;
|
|
98
|
+
for (const e of fs.readdirSync(src, { withFileTypes: true })) {
|
|
99
|
+
if (!isLinkedModulesEntry(e.name)) continue;
|
|
100
|
+
const link = path.join(dest, e.name);
|
|
101
|
+
if (exists(link)) continue;
|
|
102
|
+
const target = path.join(src, e.name);
|
|
103
|
+
try {
|
|
104
|
+
fs.symlinkSync(target, link, isDir(target) ? 'dir' : 'file');
|
|
105
|
+
added++;
|
|
106
|
+
} catch (err) {
|
|
107
|
+
if (strict) throw err;
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
return added;
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
/**
|
|
114
|
+
* Create `dest` as a real directory holding one symlink per linked entry of `src` (a
|
|
115
|
+
* node_modules folder). Throws on failure after removing whatever it created at `dest`;
|
|
116
|
+
* removal unlinks links only — it never follows them into `src`.
|
|
117
|
+
*/
|
|
118
|
+
function linkModulesEntries(src, dest) {
|
|
119
|
+
fs.mkdirSync(dest);
|
|
120
|
+
try {
|
|
121
|
+
linkMissingModulesEntries(src, dest, true);
|
|
122
|
+
} catch (err) {
|
|
123
|
+
try { fs.rmSync(dest, { recursive: true, force: true }); } catch { /* best-effort */ }
|
|
124
|
+
throw err;
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
|
|
70
128
|
async function isIgnored(cwd, name) {
|
|
71
129
|
try {
|
|
72
130
|
await execGit(cwd, ['check-ignore', '-q', name], { timeout: 10_000 });
|
|
@@ -222,12 +280,12 @@ async function nestedPackageDirs(worktreeCwd) {
|
|
|
222
280
|
}
|
|
223
281
|
|
|
224
282
|
/**
|
|
225
|
-
*
|
|
283
|
+
* Build `<dir>/node_modules` (per-entry links) for nested npm packages; pushes into linked/skipped. Never throws.
|
|
226
284
|
* Filter first (main has it, it is gitignored, the worktree has none), then cap at
|
|
227
285
|
* NESTED_MAX_PACKAGES, so ineligible packages never take a slot and never appear in
|
|
228
286
|
* `skipped`. `skipped` gets only eligible packages left unlinked, as `<rel> (<reason>)`.
|
|
229
|
-
* The info/exclude line is written only after the
|
|
230
|
-
* the
|
|
287
|
+
* The info/exclude line is written only after the links succeed; if that write fails
|
|
288
|
+
* the folder of links is removed again so status stays clean.
|
|
231
289
|
*/
|
|
232
290
|
async function linkNestedNodeModules(mainCwd, worktreeCwd, linked, skipped) {
|
|
233
291
|
try {
|
|
@@ -248,7 +306,7 @@ async function linkNestedNodeModules(mainCwd, worktreeCwd, linked, skipped) {
|
|
|
248
306
|
const src = path.join(mainCwd, rel);
|
|
249
307
|
const dest = path.join(worktreeCwd, rel);
|
|
250
308
|
try {
|
|
251
|
-
|
|
309
|
+
linkModulesEntries(src, dest);
|
|
252
310
|
} catch (err) {
|
|
253
311
|
skipped.push(`${rel} (symlink failed: ${(err && err.code) || (err && err.message) || err})`);
|
|
254
312
|
continue;
|
|
@@ -257,7 +315,7 @@ async function linkNestedNodeModules(mainCwd, worktreeCwd, linked, skipped) {
|
|
|
257
315
|
await addExcludes(mainCwd, [rel]);
|
|
258
316
|
linked.push(rel);
|
|
259
317
|
} catch (err) {
|
|
260
|
-
try { fs.
|
|
318
|
+
try { fs.rmSync(dest, { recursive: true, force: true }); } catch { /* best-effort */ }
|
|
261
319
|
skipped.push(`${rel} (exclude write failed: ${(err && err.code) || (err && err.message) || err})`);
|
|
262
320
|
}
|
|
263
321
|
}
|
|
@@ -293,7 +351,8 @@ async function linkDependencyDirs({ mainCwd, worktreeCwd, names = DEFAULT_DEP_DI
|
|
|
293
351
|
}
|
|
294
352
|
// Exclude first: a link without its exclude line would dirty status.
|
|
295
353
|
await addExcludes(mainCwd, [name]);
|
|
296
|
-
|
|
354
|
+
if (name === 'node_modules') linkModulesEntries(src, dest);
|
|
355
|
+
else fs.symlinkSync(src, dest, 'dir');
|
|
297
356
|
linked.push(name);
|
|
298
357
|
} catch {
|
|
299
358
|
skipped.push(name);
|
|
@@ -313,4 +372,54 @@ async function linkDependencyDirs({ mainCwd, worktreeCwd, names = DEFAULT_DEP_DI
|
|
|
313
372
|
return { linked, skipped, installed, setup };
|
|
314
373
|
}
|
|
315
374
|
|
|
316
|
-
|
|
375
|
+
/**
|
|
376
|
+
* Refresh one worktree node_modules (`rel`) against the main checkout's: link entries main
|
|
377
|
+
* gained since the snapshot, unlink dangling worktree links whose target lay inside main's
|
|
378
|
+
* `rel` (others are kept, counted in `counts.kept`). Skips unless the
|
|
379
|
+
* worktree folder is a real directory (a whole-folder symlink is left alone). Reads main
|
|
380
|
+
* only. Never throws.
|
|
381
|
+
*/
|
|
382
|
+
function syncModulesDir(mainCwd, worktreeCwd, rel, counts) {
|
|
383
|
+
try {
|
|
384
|
+
const dest = path.join(worktreeCwd, rel);
|
|
385
|
+
const st = fs.lstatSync(dest);
|
|
386
|
+
if (st.isSymbolicLink() || !st.isDirectory()) return;
|
|
387
|
+
const src = path.join(mainCwd, rel);
|
|
388
|
+
if (isDir(src)) counts.added += linkMissingModulesEntries(src, dest, false);
|
|
389
|
+
const ownPrefix = path.resolve(src) + path.sep; // trailing sep: main/node_modules-x is not inside
|
|
390
|
+
for (const name of fs.readdirSync(dest)) {
|
|
391
|
+
const link = path.join(dest, name);
|
|
392
|
+
try {
|
|
393
|
+
if (!fs.lstatSync(link).isSymbolicLink() || fs.existsSync(link)) continue;
|
|
394
|
+
const target = path.resolve(dest, fs.readlinkSync(link));
|
|
395
|
+
if (!target.startsWith(ownPrefix)) { counts.kept++; continue; } // not linker-made: leave it
|
|
396
|
+
fs.unlinkSync(link); // removes the dangling link itself, never a target
|
|
397
|
+
counts.removed++;
|
|
398
|
+
} catch { /* best-effort per entry */ }
|
|
399
|
+
}
|
|
400
|
+
} catch { /* absent or unreadable */ }
|
|
401
|
+
}
|
|
402
|
+
|
|
403
|
+
/**
|
|
404
|
+
* Bring a reused (long-lived Epic) worktree's per-entry node_modules links up to date with
|
|
405
|
+
* the main checkout — root plus each nested npm package (same set linkNestedNodeModules
|
|
406
|
+
* considers). pnpm projects are skipped (their worktree node_modules is a real install).
|
|
407
|
+
* No-op under SM_WORKTREE_DEP_LINK_DISABLE=1. Never throws.
|
|
408
|
+
* @param {{ mainCwd: string, worktreeCwd: string }} opts
|
|
409
|
+
* Only dangling links into the main checkout's matching node_modules (the linker's own) are
|
|
410
|
+
* removed; any other dangling link (e.g. a workspace package mid-build) is kept and counted.
|
|
411
|
+
* @returns {Promise<{ added: number, removed: number, kept: number }>}
|
|
412
|
+
*/
|
|
413
|
+
async function syncNodeModulesLinks({ mainCwd, worktreeCwd }) {
|
|
414
|
+
const counts = { added: 0, removed: 0, kept: 0 };
|
|
415
|
+
try {
|
|
416
|
+
if (process.env.SM_WORKTREE_DEP_LINK_DISABLE === '1') return counts;
|
|
417
|
+
if (!mainCwd || !worktreeCwd || isPnpmProject(mainCwd)) return counts;
|
|
418
|
+
const rels = ['node_modules'];
|
|
419
|
+
for (const dir of await nestedPackageDirs(worktreeCwd)) rels.push(`${dir}/node_modules`);
|
|
420
|
+
for (const rel of rels) syncModulesDir(mainCwd, worktreeCwd, rel, counts);
|
|
421
|
+
} catch { /* best-effort */ }
|
|
422
|
+
return counts;
|
|
423
|
+
}
|
|
424
|
+
|
|
425
|
+
module.exports = { linkDependencyDirs, syncNodeModulesLinks, isPnpmProject, isUvProject, DEFAULT_DEP_DIRS, NESTED_MAX_PACKAGES };
|
|
@@ -21,6 +21,7 @@
|
|
|
21
21
|
|
|
22
22
|
const { z } = require('zod');
|
|
23
23
|
const { MISS_KINDS } = require('./scheduler/validatorVerdictSchema.cjs');
|
|
24
|
+
const { KINDS: ARTIFACT_KINDS } = require('./epic/artifactStore.cjs');
|
|
24
25
|
|
|
25
26
|
const CatalogEntrySchema = z.object({
|
|
26
27
|
name: z.string().min(1),
|
|
@@ -189,6 +190,24 @@ const MCP_TOOL_CATALOG = [
|
|
|
189
190
|
},
|
|
190
191
|
notes: 'See /develop.',
|
|
191
192
|
},
|
|
193
|
+
{
|
|
194
|
+
name: 'scheduler_release_plan',
|
|
195
|
+
group: 'scheduler',
|
|
196
|
+
purpose: 'Release a plan held for independent review via the session-manager app admin API (POST /admin/scheduler/release-plan). '
|
|
197
|
+
+ 'Records the accepted finding count and one non-empty reason per rejected finding, then lets the plan\'s PRDs dispatch. '
|
|
198
|
+
+ 'A second call returns alreadyReleased. With rereview: true it instead asks for ONE more review after a block '
|
|
199
|
+
+ '(allowed only when the latest review has a block decision and the plan is at round 1; at most once per plan).',
|
|
200
|
+
summary: 'Release a reviewed plan, or request its single re-review.',
|
|
201
|
+
whenToUse: 'Use after reading the plan review: call once with accepted (count) and rejected [{ finding, reason }], or with rereview: true after a block.',
|
|
202
|
+
whenNotToUse: 'Not callable from inside a headless scheduled job (same refusal as scheduler_create_prds). Do not use to edit PRDs or to request a second re-review.',
|
|
203
|
+
exampleArgs: {
|
|
204
|
+
epicId: 'abc123',
|
|
205
|
+
validateSlug: 'validate-my-plan',
|
|
206
|
+
accepted: 2,
|
|
207
|
+
rejected: [{ finding: 'prd-3: add a failure-path test', reason: 'covered by the gate in prd-2' }],
|
|
208
|
+
},
|
|
209
|
+
notes: null,
|
|
210
|
+
},
|
|
192
211
|
{
|
|
193
212
|
name: 'scheduler_list_prds',
|
|
194
213
|
group: 'scheduler',
|
|
@@ -264,6 +283,22 @@ const MCP_TOOL_CATALOG = [
|
|
|
264
283
|
exampleArgs: { slug: 'add-mcp-tool-catalog' },
|
|
265
284
|
notes: null,
|
|
266
285
|
},
|
|
286
|
+
{
|
|
287
|
+
name: 'scheduler_dismiss_cancelled',
|
|
288
|
+
group: 'scheduler',
|
|
289
|
+
purpose: "THE ONLY SUPPORTED WAY to dismiss a cancelled scheduler row via the session-manager app's admin API "
|
|
290
|
+
+ '(POST /admin/scheduler/dismiss-cancelled). Removes the cancelled row from the live queue and files its PRD '
|
|
291
|
+
+ 'under prds-cancelled/, which never satisfies a dependsOn (scheduler_archive_prd refuses cancelled rows, '
|
|
292
|
+
+ 'because prds-archived/ does satisfy one). Refuses a row with no cancel marker. If the row has pending '
|
|
293
|
+
+ 'dependents the dismiss is refused and lists them; call again with dependents: { action: "cascade" } '
|
|
294
|
+
+ '(cancel them too), { action: "repoint", to: "<slug>" } (depend on another PRD instead) or '
|
|
295
|
+
+ '{ action: "clear" } (drop the dependency).',
|
|
296
|
+
summary: 'Clear a cancelled job out of the queue.',
|
|
297
|
+
whenToUse: 'Use when a cancelled job still shows in the queue and scheduler_archive_prd refused it as cancelled.',
|
|
298
|
+
whenNotToUse: 'Do not use on a real failure that should run again (use scheduler_reset_job) or on finished work (use scheduler_archive_prd).',
|
|
299
|
+
exampleArgs: { slug: 'add-mcp-tool-catalog' },
|
|
300
|
+
notes: null,
|
|
301
|
+
},
|
|
267
302
|
{
|
|
268
303
|
name: 'scheduler_retag_prd',
|
|
269
304
|
group: 'scheduler',
|
|
@@ -371,7 +406,37 @@ const MCP_TOOL_CATALOG = [
|
|
|
371
406
|
+ 'deliverWhen { appVersionAbove }: hold this reply until Session Manager runs a version above '
|
|
372
407
|
+ 'appVersionAbove (give the version running now); it then sends itself, even after this Epic closes; '
|
|
373
408
|
+ '`{version}` in the message becomes that version. A held reply returns delivery "scheduled" and '
|
|
374
|
-
+ 'counts toward the 3-reply cap at once.'
|
|
409
|
+
+ 'counts toward the 3-reply cap at once. deliverWhen needs Session Manager v0.142.0 or later running; '
|
|
410
|
+
+ 'an older app is refused before the call. '
|
|
411
|
+
+ 'release { commits } (Session Manager repo only; 7-40 hex hashes of the work that shipped) makes a '
|
|
412
|
+
+ 'Session Manager release claim checkable. Live (no deliverWhen): the running app must report a version, '
|
|
413
|
+
+ 'tag v<running version> must contain every commit, and the message may name no other Session Manager '
|
|
414
|
+
+ 'version, else it is refused; `{version}` is then filled with the running version. Held (with deliverWhen): '
|
|
415
|
+
+ 'it is sent only once the running release tag contains every commit (it waits, no attempt spent), and it '
|
|
416
|
+
+ 'needs an app newer than v0.142.0 running — 0.142.0 or older holds by version only, so the call is refused; '
|
|
417
|
+
+ 'send it live with release.commits once that release runs. A message with an unfilled placeholder '
|
|
418
|
+
+ '(`{{appVersion}}`, `<semver>`, `${release}`, ...) is refused; `{version}` is allowed only with deliverWhen '
|
|
419
|
+
+ 'or release. A done reply that names a Session Manager version must carry release.commits (or it is '
|
|
420
|
+
+ 'refused): write `{version}`, never hand-type a version.',
|
|
421
|
+
},
|
|
422
|
+
{
|
|
423
|
+
name: 'service_pair_local',
|
|
424
|
+
group: 'feedback',
|
|
425
|
+
purpose: 'Pair a service that runs on THIS machine with Session Manager in one call, with no window step: '
|
|
426
|
+
+ 'the same pairing as `service pair-local`, through the loopback admin API. Returns the paired service (never its key).',
|
|
427
|
+
summary: 'Pair a same-machine service with Session Manager, no window step.',
|
|
428
|
+
whenToUse: 'Use when the human asked you to pair a service running on this same machine (for example Kiln). '
|
|
429
|
+
+ 'Give the absolute stateDir the service keeps its pairing in, a name, its homeCwd, and the tools it may call.',
|
|
430
|
+
whenNotToUse: 'Do not use for a service on another machine (that needs the window pairing). Web remote must be on or the '
|
|
431
|
+
+ 'call is refused. Refused inside a scheduled job and outside a Session Manager chat or terminal session. '
|
|
432
|
+
+ 'The pairing can be revoked in App Settings → Web remote.',
|
|
433
|
+
exampleArgs: {
|
|
434
|
+
stateDir: '/home/bilko/.local/state/kiln',
|
|
435
|
+
name: 'Kiln',
|
|
436
|
+
homeCwd: '/home/bilko/Projects/kiln',
|
|
437
|
+
tools: ['feedback_list_projects', 'feedback_open_session'],
|
|
438
|
+
},
|
|
439
|
+
notes: 'Result: { ok: true, service } or an error with the route\'s refusal text. Report only what was paired; the human revokes it in App Settings → Web remote.',
|
|
375
440
|
},
|
|
376
441
|
{
|
|
377
442
|
name: 'project_home_write',
|
|
@@ -511,12 +576,18 @@ const MCP_TOOL_CATALOG = [
|
|
|
511
576
|
+ 'its approval, is refused by name) and an optional `personality` {who, speech, readingLevel, neverSay[]}; the look lives in character.js. '
|
|
512
577
|
+ 'An optional `cast` lists up to 8 supporting characters, each {name, voice?, note?}: names are unique and different from the host\'s, a voice uses '
|
|
513
578
|
+ 'the same two engines or a {voiceId} reference, and a member without a voice never speaks. '
|
|
579
|
+
+ 'An optional `sounds` block declares the persona\'s own sound effects (`sfx`: [{name, note?}], up to 16) and music beds (`beds`: [{name, note?, command?}], up to 8): '
|
|
580
|
+
+ 'lowercase names, unique, never a built-in sound or style. Every effect, and every bed without a `command`, is a WAV you pass in `soundPaths` '
|
|
581
|
+
+ '({name: absolute .wav path}; an effect <= 1 MiB, a bed <= 12 MiB, 32 MiB in all), saved as videos/_character/sounds/<name>.wav; a bed `command` '
|
|
582
|
+
+ 'is an argv with {lengthS} and {out} placeholders (optional {name} and {seed}) that renders the bed at mix time, run with no shell in the project root. '
|
|
583
|
+
+ 'A cast member\'s optional `sfx` lists its signature sounds (built-in or the persona\'s own); a member without a voice is heard only through them. '
|
|
514
584
|
+ 'A saved persona hosts every Demo Video unless a press turns Character off. Each narration line is spoken in its own speaker\'s voice (the host\'s '
|
|
515
585
|
+ 'when the line names no speaker) with no fallback voice: a failing command (non-zero exit or no WAV written) fails the run. '
|
|
516
586
|
+ 'The exact field rules are validateCharacterJson in demo-video-kit/character.cjs.',
|
|
517
587
|
summary: "Save the reusable character used in this project's videos.",
|
|
518
588
|
whenToUse: 'Use once per project, before building character videos, to save the mascot you designed. Pass `json` (the descriptor object or its JSON text) '
|
|
519
|
-
+ 'and the module as `js` or — preferred for large modules — an absolute `jsPath` to a local .js file.
|
|
589
|
+
+ 'and the module as `js` or — preferred for large modules — an absolute `jsPath` to a local .js file. When the json declares file-backed sounds, pass their WAVs in `soundPaths`. '
|
|
590
|
+
+ 'Pass `replace: true` only to deliberately overwrite an existing character.',
|
|
520
591
|
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, '
|
|
521
592
|
+ 'and for invalid `json`, `js` over 300KB, or `js` with remote references or network-capable APIs.',
|
|
522
593
|
exampleArgs: {
|
|
@@ -533,7 +604,8 @@ const MCP_TOOL_CATALOG = [
|
|
|
533
604
|
},
|
|
534
605
|
notes: "cwd is optional — defaults to the calling session's own project root (SM_PROJECT_ROOT or process.cwd()) when omitted. "
|
|
535
606
|
+ 'Give exactly one of `js` / `jsPath` (absolute .js file, <= 300KB). The saved character.json must fit in 16 KB. '
|
|
536
|
-
+ 'An existing character — even an unusable one — is refused (409) unless `replace: true` is set.'
|
|
607
|
+
+ 'An existing character — even an unusable one — is refused (409) unless `replace: true` is set. '
|
|
608
|
+
+ 'Every call that declares file-backed sounds sends all their WAVs in `soundPaths`; a replace drops WAVs no longer declared.',
|
|
537
609
|
},
|
|
538
610
|
{
|
|
539
611
|
name: 'project_video_review_write',
|
|
@@ -864,12 +936,12 @@ const MCP_TOOL_CATALOG = [
|
|
|
864
936
|
purpose: "Read-only list of one project's open Epics (sessions) via the session-manager app's admin API "
|
|
865
937
|
+ '(GET /admin/epics) — the same outside-facing records a script gets: each Epic\'s epicId, title, '
|
|
866
938
|
+ 'outside-facing state and PRD progress. Optionally filter by `state`. Results are paginated (default limit 50, '
|
|
867
|
-
+ 'max 200) — check `hasMore`/`total` before assuming you received every Epic; page further with `offset`.'
|
|
939
|
+
+ 'max 200) — check `hasMore`/`total` before assuming you received every Epic; page further with `offset`. '
|
|
940
|
+
+ 'Each record\'s source.startedBy is absent/null when a person pressed New Epic; otherwise a script started it, with its caller and fromEpicId.',
|
|
868
941
|
summary: 'List the open sessions of one project and what state each is in.',
|
|
869
942
|
whenToUse: 'Use to survey which Epics a project has open and which need input, review or approval, before '
|
|
870
943
|
+ 'reading one in full with epic_get.',
|
|
871
|
-
whenNotToUse: 'Do not use this to create, approve or change an Epic — it is read-only
|
|
872
|
-
+ 'ever created by a human pressing New Epic. Do not use it for PRD status; use scheduler_list_prds.',
|
|
944
|
+
whenNotToUse: 'Do not use this to create, approve or change an Epic — it is read-only. Do not use it for PRD status; use scheduler_list_prds.',
|
|
873
945
|
exampleArgs: { cwd: '/home/bilko/Projects/session-manager', state: 'needs_input' },
|
|
874
946
|
notes: 'A partial page carries a `note` naming how many Epics were returned out of `total`.',
|
|
875
947
|
},
|
|
@@ -878,7 +950,8 @@ const MCP_TOOL_CATALOG = [
|
|
|
878
950
|
group: 'epics',
|
|
879
951
|
purpose: "Read-only fetch of one Epic's outside-facing record via the session-manager app's admin API "
|
|
880
952
|
+ '(GET /admin/epic), looked up in project `cwd` by exactly one of `id` (the Epic id) or `externalRef` '
|
|
881
|
-
+ '(the reference it was opened with). Returns `{ ok: true, epic }`, or `{ ok: false, error: "not found" }`.'
|
|
953
|
+
+ '(the reference it was opened with). Returns `{ ok: true, epic }`, or `{ ok: false, error: "not found" }`. '
|
|
954
|
+
+ 'epic.source.startedBy is absent/null when a person pressed New Epic; otherwise a script started it, with its caller and fromEpicId.',
|
|
882
955
|
summary: 'Read one session by its id or by the outside reference it was opened with.',
|
|
883
956
|
whenToUse: 'Use after epic_list, or when you already hold an Epic id or external reference, to read that '
|
|
884
957
|
+ "one Epic's state and progress.",
|
|
@@ -961,6 +1034,27 @@ const MCP_TOOL_CATALOG = [
|
|
|
961
1034
|
+ 'human_request_unverified / quote_does_not_name_switch / quote_does_not_name_project, 409 '
|
|
962
1035
|
+ 'request_older_than_switch) carries error and reason; show the reason to the human.',
|
|
963
1036
|
},
|
|
1037
|
+
{
|
|
1038
|
+
name: 'video_script_switch_set',
|
|
1039
|
+
group: 'project-home',
|
|
1040
|
+
purpose: "Turn one project's 'Scripts may run Demo Video' switch on or off via the session-manager app's admin API "
|
|
1041
|
+
+ '(POST /admin/project-home/videos/script-switch), on behalf of the human in this chat. Runs only in a Session '
|
|
1042
|
+
+ 'Manager chat or terminal session; a scheduled job, a Task or any other internal headless run is refused before '
|
|
1043
|
+
+ 'any request. The caller identity is taken from this session, never from arguments. `cwd` is optional and '
|
|
1044
|
+
+ "defaults to this session's project.",
|
|
1045
|
+
summary: 'Turn Scripts may run Demo Video on or off when the human asks.',
|
|
1046
|
+
whenToUse: 'Use only when the human asked in this chat to turn the switch on or off, and pass their words '
|
|
1047
|
+
+ 'verbatim as `humanRequestQuote` — the route checks the quote against this session\'s transcript and '
|
|
1048
|
+
+ 'that it names the switch and the project.',
|
|
1049
|
+
whenNotToUse: 'Never on your own initiative, never from a job or script, and never to get past a 403 '
|
|
1050
|
+
+ "scripts_not_allowed without the human's words. Do not use it to press Demo Video — a script does that with "
|
|
1051
|
+
+ 'POST /admin/project-home/videos/run (recipe script-press-demo-video).',
|
|
1052
|
+
exampleArgs: { enabled: true, humanRequestQuote: "turn on 'Scripts may run Demo Video' for burrow" },
|
|
1053
|
+
notes: 'One instruction allows one change: do not reuse a quote to flip the switch again. Returns '
|
|
1054
|
+
+ '{ ok: true, cwd, enabled, changedAt, by, previous }. A refusal (400 invalid_request, 403 '
|
|
1055
|
+
+ 'human_request_unverified / quote_does_not_name_switch / quote_does_not_name_project, 409 '
|
|
1056
|
+
+ 'request_older_than_switch) carries error and reason; show the reason to the human.',
|
|
1057
|
+
},
|
|
964
1058
|
{
|
|
965
1059
|
name: 'scheduler_slots_get',
|
|
966
1060
|
group: 'scheduler',
|
|
@@ -974,6 +1068,23 @@ const MCP_TOOL_CATALOG = [
|
|
|
974
1068
|
exampleArgs: {},
|
|
975
1069
|
notes: 'Read-only. Returns { ok: true, cap, min, max, inUse, available }.',
|
|
976
1070
|
},
|
|
1071
|
+
{
|
|
1072
|
+
name: 'usage_hold_get',
|
|
1073
|
+
group: 'scheduler',
|
|
1074
|
+
purpose: "Read the usage hold Session Manager is applying right now to automatic claude -p work ('pause above') "
|
|
1075
|
+
+ "via the session-manager app's admin API (GET /admin/usage-hold): whether automatic runs are held, why, "
|
|
1076
|
+
+ 'and until when, plus the saved pause-above threshold.',
|
|
1077
|
+
summary: 'See if automatic runs are on hold.',
|
|
1078
|
+
whenToUse: 'Use before starting or asking for automatic claude -p work (a Task, a queued PRD), or to explain '
|
|
1079
|
+
+ 'why scheduled jobs or Tasks are not starting.',
|
|
1080
|
+
whenNotToUse: 'Do not use it to change the threshold or lift the hold — this tool only reads. Not needed '
|
|
1081
|
+
+ 'before replying in a human chat.',
|
|
1082
|
+
exampleArgs: {},
|
|
1083
|
+
notes: 'Read-only, no arguments. Returns the route\'s answer unchanged: { ok: true, hold, threshold }. hold null = '
|
|
1084
|
+
+ 'no hold; otherwise { reason, window, percent, threshold, resetsAt, detail }, with resetsAt the time the hold '
|
|
1085
|
+
+ 'ends. The hold applies to every automatic claude -p start (scheduler ticks and Tasks), not to human chats. '
|
|
1086
|
+
+ 'A failed read (503 usage_hold_error) comes back as an error.',
|
|
1087
|
+
},
|
|
977
1088
|
{
|
|
978
1089
|
name: 'scheduler_slots_set',
|
|
979
1090
|
group: 'scheduler',
|
|
@@ -983,12 +1094,17 @@ const MCP_TOOL_CATALOG = [
|
|
|
983
1094
|
+ 'is taken from this session, never from arguments, and a scheduled job is refused.',
|
|
984
1095
|
summary: 'Raise or lower the session limit when the human asks.',
|
|
985
1096
|
whenToUse: "Use only when the human asked in this session for a new limit. It needs the human's own words "
|
|
986
|
-
+ 'naming the limit and the number, quoted verbatim from this session, as `quote
|
|
987
|
-
+ '
|
|
988
|
-
+ '
|
|
1097
|
+
+ 'naming the limit and the number, quoted verbatim from this session, as `quote`, and `cap` set to that '
|
|
1098
|
+
+ 'number. One sentence of the quote must be exactly this form: [please|ok|okay|so|now|then] '
|
|
1099
|
+
+ 'set|raise|increase|bump|lower|reduce|change [the|our] [session|slot|parallel] limit|cap|slots to '
|
|
1100
|
+
+ '<number in digits> [sessions|slots] — nothing else in the sentence, a comma only right after the '
|
|
1101
|
+
+ 'lead-in word, no question mark; e.g. "raise the limit to 14". The whole sentence the human typed '
|
|
1102
|
+
+ 'around the quote must be that form too, so "don\'t raise the limit to 14" or "raise the limit to 14?" '
|
|
1103
|
+
+ 'is refused. Anything else is refused. The route checks the quote against what the human typed in this session; '
|
|
1104
|
+
+ 'if the human said it another way, ask them to say it in that form.',
|
|
989
1105
|
whenNotToUse: 'Never on your own initiative, never from a job or script, and never with words you wrote or '
|
|
990
1106
|
+ 'paraphrased. Do not use it just to read the limit — use scheduler_slots_get.',
|
|
991
|
-
exampleArgs: { cap: 14, quote: 'raise the limit to 14
|
|
1107
|
+
exampleArgs: { cap: 14, quote: 'raise the limit to 14' },
|
|
992
1108
|
notes: 'One instruction allows one change. Returns { ok: true, from, to }. A refusal (400 invalid_request — '
|
|
993
1109
|
+ 'cap outside [min, max]; 403 called_from_headless_job / human_request_unverified / '
|
|
994
1110
|
+ 'quote_does_not_name_slots) carries error and reason; show the reason to the human.',
|
|
@@ -1024,7 +1140,8 @@ const MCP_TOOL_CATALOG = [
|
|
|
1024
1140
|
summary: 'Publish a file for review.',
|
|
1025
1141
|
whenToUse: 'Call it for every file a human should review: renders, audio takes, reports, contact sheets, screenshots, exports. '
|
|
1026
1142
|
+ 'Publish each file the moment it is done, then name the returned storedPath in your reply. `path` is absolute, or relative '
|
|
1027
|
-
+ 'to your Epic worktree; `title` is the human label; `kind` is
|
|
1143
|
+
+ 'to your Epic worktree; `title` is the human label; `kind` is optional, one of ' + ARTIFACT_KINDS.join(', ')
|
|
1144
|
+
+ ' (a report is doc), and is inferred from the file extension when omitted.',
|
|
1028
1145
|
whenNotToUse: 'Do not use for scratch or intermediate files nobody needs to see, for Project Home pages or videos (use '
|
|
1029
1146
|
+ 'project_page_write / project_video_write), or to move source code — commit that instead. Refused inside a scheduled job '
|
|
1030
1147
|
+ 'with no Epic session: a job writes to SM_ARTIFACTS_DIR and is harvested for you.',
|
|
@@ -1101,6 +1218,21 @@ const MCP_RECIPES = [
|
|
|
1101
1218
|
'A repoPaths run must land a commit under those paths (the saved video entry itself is never committed); without repoPaths the run is artifact-only. Only the human approves, asks for changes or retries — in Project Home ▸ Video; no tool can.',
|
|
1102
1219
|
],
|
|
1103
1220
|
},
|
|
1221
|
+
{
|
|
1222
|
+
id: 'script-press-demo-video',
|
|
1223
|
+
title: "Let a project's own script press Demo Video and read the outcome",
|
|
1224
|
+
steps: [
|
|
1225
|
+
"A human turns on 'Scripts may run Demo Video' for the project — in Project Home > Video, or by asking in a chat session, where the agent calls video_script_switch_set with their words verbatim as humanRequestQuote. No script, job or Task can turn it on; while it is off the run route answers 403 scripts_not_allowed.",
|
|
1226
|
+
'The script POSTs /admin/project-home/videos/run with the port and token from ~/.claude/session-manager/admin-api.json, e.g. for a blog post (target = the post URL, externalRef = the post slug): '
|
|
1227
|
+
+ 'curl -s -X POST "http://127.0.0.1:$(jq -r .port ~/.claude/session-manager/admin-api.json)/admin/project-home/videos/run" '
|
|
1228
|
+
+ '-H "Authorization: Bearer $(jq -r .token ~/.claude/session-manager/admin-api.json)" -H \'Content-Type: application/json\' '
|
|
1229
|
+
+ '-d \'{"cwd":"/abs/project","kind":"Blog post","target":"https://example.com/blog/hello","externalRef":"hello"}\'. '
|
|
1230
|
+
+ 'Optional keys: length, style, character, voiceId, focus, reviewFirst, and caller { pipeline, runId, step, attempt } (recorded on the Epic as source.startedBy.caller), e.g. "caller":{"pipeline":"blog-videos","runId":"run-42","step":"render","attempt":1}; a press from an SM chat records that chat\'s Epic automatically (fromEpicId). Success is { ok, entryId, epicId, slug, stage }; the same externalRef again answers { ok, existing: true, entryId, epicId } instead of a second run.',
|
|
1231
|
+
'Read the outcome with GET /admin/project-home/videos/status?cwd=<encoded>&id=<entryId> (same bearer token): state is queued, running, awaiting_review, saved (files.index/meta/mp4/poster, absolute paths), season-complete or failed (reason).',
|
|
1232
|
+
'409 already_building means a Demo Video job for this project is already pending or running — retry later; never loop tightly.',
|
|
1233
|
+
'With Review first (reviewFirst: true) the run stops at awaiting_review: only the human approves or asks for changes in Project Home > Video, then the final video builds. A script just keeps reading the status.',
|
|
1234
|
+
],
|
|
1235
|
+
},
|
|
1104
1236
|
];
|
|
1105
1237
|
|
|
1106
1238
|
for (const entry of MCP_TOOL_CATALOG) {
|
|
@@ -825,7 +825,24 @@ async function checkConfiguredMcpServer(request, options) {
|
|
|
825
825
|
const { home, check = checkMcpServer, timeoutMs, clientVersion } = options || {};
|
|
826
826
|
const target = await resolveMcpServerConfig(request, { home });
|
|
827
827
|
if (!target) return { ok: false, status: 'failed', error: 'server not found', checkedAt: Date.now() };
|
|
828
|
-
|
|
828
|
+
const result = await check(target.server, { timeoutMs, clientVersion, cwd: target.cwd });
|
|
829
|
+
const { source, name } = request;
|
|
830
|
+
if (typeof name === 'string' && typeof source === 'string') lastProbes.set(`${source}\u0000${name}`, { scope: source, name, result });
|
|
831
|
+
return result;
|
|
829
832
|
}
|
|
830
833
|
|
|
831
|
-
|
|
834
|
+
/** Last checkConfiguredMcpServer result per (scope, name), this process only. */
|
|
835
|
+
const lastProbes = new Map();
|
|
836
|
+
|
|
837
|
+
/** @returns {object | null} the last result for the server, or null if never checked. */
|
|
838
|
+
function lastProbe(scope, name) {
|
|
839
|
+
const hit = lastProbes.get(`${scope}\u0000${name}`);
|
|
840
|
+
return hit ? hit.result : null;
|
|
841
|
+
}
|
|
842
|
+
|
|
843
|
+
/** @param {string} scope @returns {{ name: string, scope: string }[]} servers with a stored result in the scope. */
|
|
844
|
+
function probedServers(scope) {
|
|
845
|
+
return [...lastProbes.values()].filter((e) => e.scope === scope).map((e) => ({ name: e.name, scope: e.scope }));
|
|
846
|
+
}
|
|
847
|
+
|
|
848
|
+
module.exports = { checkMcpServer, resolveMcpServerConfig, checkConfiguredMcpServer, lastProbe, probedServers };
|