claude-code-session-manager 0.139.0 → 0.141.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/README.md +20 -4
- package/dist/assets/AppSettings-DExeJhqQ.js +2 -0
- package/dist/assets/History-DJMiuXyK.js +2 -0
- package/dist/assets/{HomeClaudeConfig-CGD2Onjv.js → HomeClaudeConfig-CTp2tkZ4.js} +2 -2
- package/dist/assets/{Panel-Csyd9HbD.js → Panel-Bf1Cf8UL.js} +1 -1
- package/dist/assets/{ProjectClaudeConfig-C-jlYpC_.js → ProjectClaudeConfig-BWPpypf9.js} +1 -1
- package/dist/assets/Scheduler-cyr61UAC.js +16 -0
- package/dist/assets/{SkillReferenceGraph-DcscPXAG.js → SkillReferenceGraph-Ba4TkX2C.js} +1 -1
- package/dist/assets/{Skills-BpGRKOcY.js → Skills-C1v91GEO.js} +26 -26
- package/dist/assets/{TiptapBody-DSU3769X.js → TiptapBody-BrcWVpiW.js} +1 -1
- package/dist/assets/{ViewTabs-C0PRZx4_.js → ViewTabs-DXhOWFG0.js} +1 -1
- package/dist/assets/{VoiceButton-D2rMurNg.js → VoiceButton-qivnDV6K.js} +1 -1
- package/dist/assets/{historyTotals-TcIQs2sh.js → historyTotals-CMCPTKqC.js} +1 -1
- package/dist/assets/index-B2TQz3nd.js +3121 -0
- package/dist/assets/{index-BCySPdtU.css → index-DKXdXfka.css} +1 -1
- package/dist/index.html +2 -2
- package/dist-web/app.css +1 -1
- package/dist-web/app.js +423 -426
- package/package.json +5 -2
- package/plugins/AGENTS.md +60 -0
- package/plugins/CLAUDE.md +1 -60
- package/plugins/session-manager-dev/skills/builder/SKILL.md +4 -2
- package/plugins/session-manager-dev/skills/develop/SKILL.md +29 -19
- package/plugins/session-manager-dev/skills/maintaining-md-network/SKILL.md +5 -4
- package/plugins/session-manager-dev/skills/maintaining-md-network/audit.md +4 -2
- package/plugins/session-manager-dev/skills/maintaining-md-network/drift-check.md +16 -12
- package/plugins/session-manager-dev/skills/maintaining-md-network/migrate-to-agents-md.md +15 -0
- package/plugins/session-manager-dev/skills/maintaining-md-network/placement.md +50 -2
- package/plugins/session-manager-dev/skills/maintaining-md-network/plan.md +10 -10
- package/plugins/session-manager-dev/skills/maintaining-md-network/scripts/drift-check.cjs +117 -112
- package/plugins/session-manager-dev/skills/maintaining-md-network/scripts/mdDuplicates.cjs +182 -0
- package/plugins/session-manager-dev/skills/maintaining-md-network/scripts/mdLinks.cjs +340 -0
- package/scripts/README.md +1 -0
- package/scripts/hooks/guard-tool-risk.cjs +91 -0
- package/scripts/hooks/lib/guard-tool-risk-policy.cjs +217 -0
- package/scripts/ops-sweep.cjs +53 -23
- package/scripts/scheduler-mcp-server.cjs +205 -18
- package/src/main/build-info.json +4 -4
- package/src/main/config.cjs +112 -8
- package/src/main/docEdit.cjs +6 -1
- package/src/main/files.cjs +7 -27
- package/src/main/health.cjs +48 -15
- package/src/main/historyAggregator.cjs +88 -5
- package/src/main/historyDashboard.cjs +69 -4
- package/src/main/index.cjs +56 -2
- package/src/main/ipcSchemas.cjs +122 -16
- package/src/main/lib/AGENTS.md +54 -0
- package/src/main/lib/CLAUDE.md +1 -54
- package/src/main/lib/agent-cli/adapters/codex.cjs +5 -2
- package/src/main/lib/agent-cli/agentCliIpc.cjs +18 -2
- package/src/main/lib/agent-cli/agentCliSessionStore.cjs +1 -0
- package/src/main/lib/agent-cli/agentCliTurn.cjs +20 -2
- package/src/main/lib/agent-cli/geminiContextDefaults.cjs +94 -0
- package/src/main/lib/claude/effectiveModelInfo.cjs +90 -20
- package/src/main/lib/claude/jobSandboxPolicy.cjs +202 -0
- package/src/main/lib/claude/personaToolScope.cjs +12 -6
- package/src/main/lib/claude/rateLimitDetect.cjs +13 -2
- package/src/main/lib/claude/runClaudeP.cjs +6 -1
- package/src/main/lib/claude/toolRiskIpc.cjs +177 -0
- package/src/main/lib/claude/toolRiskMarks.cjs +373 -0
- package/src/main/lib/demo-video-kit/seedKit.cjs +27 -6
- package/src/main/lib/ephemeralCwd.cjs +37 -2
- package/src/main/lib/epic/delegationReadiness.cjs +42 -9
- package/src/main/lib/epic/epicAdminRoutes.cjs +25 -5
- package/src/main/lib/epic/epicOutsideRead.cjs +118 -1
- package/src/main/lib/epic/epicOutsideState.cjs +2 -2
- package/src/main/lib/epic/epicSweepValidator.cjs +7 -2
- package/src/main/lib/epic/epicValidationHook.cjs +24 -4
- package/src/main/lib/epic/guardSpawnSettings.cjs +57 -1
- package/src/main/lib/externalContract.cjs +31 -5
- package/src/main/lib/feedback-remote/crossProjectFeedback.cjs +55 -1
- package/src/main/lib/feedback-remote/crossProjectReply.cjs +106 -11
- package/src/main/lib/feedback-remote/macroAdminRoutes.cjs +47 -19
- package/src/main/lib/feedback-remote/needsYouStore.cjs +6 -2
- package/src/main/lib/feedback-remote/projectHomeAdminRoutes.cjs +98 -1
- package/src/main/lib/feedback-remote/remoteIpcDispatch.cjs +5 -0
- package/src/main/lib/git/branchSweep.cjs +209 -4
- package/src/main/lib/git/gitWorktree.cjs +41 -5
- package/src/main/lib/guardShims.cjs +1 -1
- package/src/main/lib/historyRollup.cjs +26 -0
- package/src/main/lib/insideHome.cjs +27 -1
- package/src/main/lib/mcpToolCatalog.cjs +132 -13
- package/src/main/lib/mdDocCensus.cjs +59 -78
- package/src/main/lib/mdDocRefs.cjs +71 -93
- package/src/main/lib/mdNetworkScan.cjs +245 -250
- package/src/main/lib/mdReviewRecord.cjs +22 -9
- package/src/main/lib/memoryMdNetwork.cjs +5 -12
- package/src/main/lib/opsOwnership.cjs +18 -2
- package/src/main/lib/opsRetentionSettings.cjs +28 -4
- package/src/main/lib/persona-macro/macroJobDispatch.cjs +90 -20
- package/src/main/lib/persona-macro/macroJobIpc.cjs +144 -46
- package/src/main/lib/persona-macro/macroJobStatus.cjs +87 -9
- package/src/main/lib/persona-macro/macroLibrary.cjs +95 -5
- package/src/main/lib/persona-macro/personaImportHealth.cjs +78 -17
- package/src/main/lib/persona-macro/projectVideoToolCheck.cjs +96 -0
- package/src/main/lib/persona-macro/shippedPersonaSeeds.cjs +11 -0
- package/src/main/lib/prd/depSlugResolve.cjs +104 -4
- package/src/main/lib/prd/prdAdminRoutes.cjs +35 -2
- package/src/main/lib/prd/prdCreate.cjs +377 -23
- package/src/main/lib/prd/prdDisposition.cjs +11 -2
- package/src/main/lib/prd/prdFrontmatter.cjs +121 -3
- package/src/main/lib/process/loginItem.cjs +171 -0
- package/src/main/lib/process/loginItemPlan.cjs +193 -0
- package/src/main/lib/project-pages/playerBridge.cjs +4 -0
- package/src/main/lib/project-pages/videoReview.cjs +268 -0
- package/src/main/lib/project-pages/videoReviewIpc.cjs +229 -0
- package/src/main/lib/scheduler/cpuSample.cjs +131 -4
- package/src/main/lib/scheduler/fixPlanSlug.cjs +4 -3
- package/src/main/lib/scheduler/loadGate.cjs +24 -6
- package/src/main/lib/scheduler/planRecordHarvest.cjs +108 -0
- package/src/main/lib/scheduler/planRecordRetention.cjs +144 -0
- package/src/main/lib/scheduler/preflightCheck.cjs +97 -0
- package/src/main/lib/scheduler/queueStore.cjs +7 -0
- package/src/main/lib/scheduler/rcaReport.cjs +21 -1
- package/src/main/lib/scheduler/reaperHelpers.cjs +35 -5
- package/src/main/lib/scheduler/reviewNotice.cjs +39 -0
- package/src/main/lib/scheduler/runLogRetention.cjs +104 -3
- package/src/main/lib/scheduler/scheduleJobSchema.cjs +3 -0
- package/src/main/lib/scheduler/schedulerBatch.cjs +25 -48
- package/src/main/lib/scheduler/schedulerPaths.cjs +3 -0
- package/src/main/lib/scheduler/sessionSlots.cjs +176 -21
- package/src/main/lib/scheduler/validationQuality.cjs +282 -0
- package/src/main/lib/scheduler/validatorVerdictSchema.cjs +254 -0
- package/src/main/lib/tasks/taskAdminRoutes.cjs +641 -0
- package/src/main/lib/tasks/taskIpc.cjs +80 -0
- package/src/main/lib/tasks/taskLedger.cjs +502 -0
- package/src/main/lib/tasks/taskRun.cjs +313 -0
- package/src/main/lib/tasks/taskSwitch.cjs +120 -0
- package/src/main/loginItemIpc.cjs +35 -0
- package/src/main/loopEfficiencyHandlers.cjs +10 -1
- package/src/main/projectPages.cjs +6 -15
- package/src/main/promptSessionEvents.cjs +9 -1
- package/src/main/queueOps.cjs +260 -3
- package/src/main/runVerify.cjs +53 -25
- package/src/main/scheduler/AGENTS.md +26 -0
- package/src/main/scheduler/CLAUDE.md +1 -26
- package/src/main/scheduler/budget.cjs +239 -9
- package/src/main/scheduler/cancelDependents.cjs +154 -0
- package/src/main/scheduler/prdParser.cjs +19 -1
- package/src/main/scheduler/reviewLadder.cjs +36 -3
- package/src/main/scheduler/starvation.cjs +89 -18
- package/src/main/scheduler.cjs +1080 -89
- package/src/main/supervisor.cjs +5 -1
- package/src/main/templates/PRD_AUTHORING.md +14 -1
- package/src/main/validationQualityHandlers.cjs +199 -0
- package/src/main/webRemote.cjs +10 -2
- package/src/preload/api.d.ts +364 -21
- package/src/preload/apiSurface.json +89 -10
- package/src/preload/index.cjs +23 -2
- package/src/seed/agents/validator.md +19 -8
- package/dist/assets/AppSettings-CUfWY9vN.js +0 -2
- package/dist/assets/History-DDnqaLyw.js +0 -2
- package/dist/assets/Scheduler-NLs08fx7.js +0 -16
- package/dist/assets/index-C-d0DCre.js +0 -3124
|
@@ -8,6 +8,16 @@
|
|
|
8
8
|
* re-exported from historyAggregator.cjs (date math) plus lib/claude/modelPricing.cjs (cost) — never
|
|
9
9
|
* fs/promises, never PROJECTS_DIR. See historyDashboard.test.cjs's zero-scan
|
|
10
10
|
* guarantee test.
|
|
11
|
+
*
|
|
12
|
+
* The one non-rollup input is the Task ledger (lib/tasks/taskLedger.cjs
|
|
13
|
+
* readTaskUsageDays, for every project in lib/tasks/taskSwitch.cjs
|
|
14
|
+
* listTaskProjects, switch on or off). It is still no transcript scan and no
|
|
15
|
+
* PROJECTS_DIR: each project's own session-manager-operations/tasks/ day files.
|
|
16
|
+
* Its spend lands as rows keyed 'sm-task:<absolute cwd>' so the renderer fold
|
|
17
|
+
* puts it on that project's row. Nothing counts twice: Tasks run with
|
|
18
|
+
* --no-session-persistence and write no transcript, and historyAggregator.cjs
|
|
19
|
+
* skips the transcript of any Task that did persist (sibling PRD
|
|
20
|
+
* task-history-skip-task-transcripts), so no rollup line carries Task usage.
|
|
11
21
|
*/
|
|
12
22
|
|
|
13
23
|
'use strict';
|
|
@@ -22,6 +32,58 @@ const { schemas } = require('./ipcSchemas.cjs');
|
|
|
22
32
|
// after this, so it's an effective "no lower bound".
|
|
23
33
|
const EARLIEST_DATE = '1970-01-01';
|
|
24
34
|
|
|
35
|
+
/** Prefix of a Task project's row key in days[].byProject: 'sm-task:' + absolute cwd. */
|
|
36
|
+
const TASK_PROJECT_PREFIX = 'sm-task:';
|
|
37
|
+
|
|
38
|
+
/**
|
|
39
|
+
* Default Task readers, required lazily so a dashboard that never reaches
|
|
40
|
+
* them (and the zero-scan test's module graph) stays as it was.
|
|
41
|
+
*/
|
|
42
|
+
function defaultTaskDeps() {
|
|
43
|
+
return {
|
|
44
|
+
listTaskProjects: () => require('./lib/tasks/taskSwitch.cjs').listTaskProjects(),
|
|
45
|
+
readTaskUsageDays: (cwd, range) => require('./lib/tasks/taskLedger.cjs').readTaskUsageDays(cwd, range),
|
|
46
|
+
};
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
/**
|
|
50
|
+
* Task ledger days → buckets shaped like rollup lines: per day, one totals
|
|
51
|
+
* bucket (promptCount = sessionCount = task count) and one bucket per model,
|
|
52
|
+
* so they go through the same fold + cost path as transcript rows.
|
|
53
|
+
*/
|
|
54
|
+
async function readTaskBuckets(from, to, deps) {
|
|
55
|
+
const listTaskProjects = deps.listTaskProjects ?? defaultTaskDeps().listTaskProjects;
|
|
56
|
+
const readTaskUsageDays = deps.readTaskUsageDays ?? defaultTaskDeps().readTaskUsageDays;
|
|
57
|
+
const buckets = [];
|
|
58
|
+
for (const { cwd } of listTaskProjects() || []) {
|
|
59
|
+
if (typeof cwd !== 'string' || !cwd) continue;
|
|
60
|
+
let days;
|
|
61
|
+
try {
|
|
62
|
+
days = await readTaskUsageDays(cwd, { sinceDate: from, untilDate: to });
|
|
63
|
+
} catch (err) {
|
|
64
|
+
console.warn(`[historyDashboard] Task ledger read failed for ${cwd}:`, err);
|
|
65
|
+
continue;
|
|
66
|
+
}
|
|
67
|
+
const projectDir = TASK_PROJECT_PREFIX + cwd;
|
|
68
|
+
for (const d of days || []) {
|
|
69
|
+
buckets.push({
|
|
70
|
+
date: d.date, projectDir, modelId: historyRollup.TOTALS_MODEL_ID,
|
|
71
|
+
promptCount: d.tasks || 0, sessionCount: d.tasks || 0,
|
|
72
|
+
});
|
|
73
|
+
for (const [modelId, m] of Object.entries(d.byModel || {})) {
|
|
74
|
+
buckets.push({
|
|
75
|
+
date: d.date, projectDir, modelId,
|
|
76
|
+
inputTokens: m.input_tokens || 0,
|
|
77
|
+
outputTokens: m.output_tokens || 0,
|
|
78
|
+
cacheReadTokens: m.cache_read_input_tokens || 0,
|
|
79
|
+
cacheCreationTokens: m.cache_creation_input_tokens || 0,
|
|
80
|
+
});
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
return buckets;
|
|
85
|
+
}
|
|
86
|
+
|
|
25
87
|
function emptyProjectRow(date, projectDir) {
|
|
26
88
|
return {
|
|
27
89
|
date,
|
|
@@ -117,10 +179,11 @@ function addRowToTotals(totals, row) {
|
|
|
117
179
|
}
|
|
118
180
|
|
|
119
181
|
/**
|
|
120
|
-
* Answer the History dashboard's full request
|
|
121
|
-
* O(rollup lines in range) — no transcript file is
|
|
182
|
+
* Answer the History dashboard's full request from rollup lines plus the Task
|
|
183
|
+
* ledger. O(rollup lines + Task ledger lines in range) — no transcript file is
|
|
184
|
+
* ever opened. `deps` ({ listTaskProjects, readTaskUsageDays }) is for tests.
|
|
122
185
|
*/
|
|
123
|
-
async function computeDashboard(req) {
|
|
186
|
+
async function computeDashboard(req, deps = {}) {
|
|
124
187
|
const rangeDays = req?.rangeDays ?? 30;
|
|
125
188
|
const isAll = rangeDays === 0;
|
|
126
189
|
const today = localDate(new Date());
|
|
@@ -131,12 +194,13 @@ async function computeDashboard(req) {
|
|
|
131
194
|
const readFrom = isAll ? EARLIEST_DATE : prevFrom;
|
|
132
195
|
|
|
133
196
|
const map = await historyRollup.readRollup(readFrom, to);
|
|
197
|
+
const taskBuckets = await readTaskBuckets(readFrom, to, deps);
|
|
134
198
|
|
|
135
199
|
const daysMap = new Map(); // date -> Map(projectDir -> row)
|
|
136
200
|
const prevRow = emptyProjectRow('', '');
|
|
137
201
|
const finalizedDates = new Set();
|
|
138
202
|
|
|
139
|
-
for (const bucket of map.values()) {
|
|
203
|
+
for (const bucket of [...map.values(), ...taskBuckets]) {
|
|
140
204
|
if (bucket.projectDir === historyRollup.FINALIZED_PROJECT_ID && bucket.modelId === historyRollup.FINALIZED_MODEL_ID) {
|
|
141
205
|
if (bucket.finalizedAt) finalizedDates.add(bucket.date);
|
|
142
206
|
continue;
|
|
@@ -228,4 +292,5 @@ function registerHistoryDashboardHandlers() {
|
|
|
228
292
|
module.exports = {
|
|
229
293
|
registerHistoryDashboardHandlers,
|
|
230
294
|
computeDashboard,
|
|
295
|
+
TASK_PROJECT_PREFIX,
|
|
231
296
|
};
|
package/src/main/index.cjs
CHANGED
|
@@ -126,8 +126,12 @@ require('./lib/epic/epicAdminRoutes.cjs').registerAdminRoute(adminHttp, {
|
|
|
126
126
|
isTabBusy: chatRunner.isTabBusy,
|
|
127
127
|
listJobs: () => scheduler.remote.listJobs(),
|
|
128
128
|
});
|
|
129
|
+
// Validator quality numbers per project for outside callers (read-only).
|
|
130
|
+
require('./validationQualityHandlers.cjs').registerAdminRoute(adminHttp);
|
|
129
131
|
// Persona roster + per-project effective model/effort for outside apps (read-only).
|
|
130
132
|
require('./lib/persona-macro/agentAdminRoutes.cjs').registerAdminRoute(adminHttp);
|
|
133
|
+
// Task primitive: one headless claude -p run for a project, under the slot cap (POST /admin/tasks).
|
|
134
|
+
require('./lib/tasks/taskAdminRoutes.cjs').registerAdminRoute(adminHttp);
|
|
131
135
|
// The scheduler tick turns Epic state changes into epic_state_changed audit rows.
|
|
132
136
|
require('./lib/epic/epicStateWatcher.cjs').configureEpicStateWatcher({ isTabBusy: chatRunner.isTabBusy });
|
|
133
137
|
const supervisor = require('./supervisor.cjs');
|
|
@@ -146,6 +150,7 @@ const { registerHistoryAggregatorHandlers, finalizeClosedDays, refreshIntradayTo
|
|
|
146
150
|
const runLogRetention = require('./lib/scheduler/runLogRetention.cjs');
|
|
147
151
|
const { registerHistoryDashboardHandlers } = require('./historyDashboard.cjs');
|
|
148
152
|
const { registerLoopEfficiencyHandlers } = require('./loopEfficiencyHandlers.cjs');
|
|
153
|
+
const { registerValidationQualityHandlers } = require('./validationQualityHandlers.cjs');
|
|
149
154
|
const { tryAcquireLock, releaseLock, DEFAULT_LOCK_PATH } = require('./lib/scheduler/watchdogHelpers.cjs');
|
|
150
155
|
const { createIntradayRefresh } = require('./lib/intradayRefresh.cjs');
|
|
151
156
|
const schedulerConfig = require('./lib/scheduler/schedulerConfig.cjs');
|
|
@@ -181,6 +186,7 @@ const webRemote = require('./webRemote.cjs');
|
|
|
181
186
|
const { registerAgentsHandlers } = require('./agentsIpc.cjs');
|
|
182
187
|
const { registerTelemetryHandlers } = require('./telemetryIpc.cjs');
|
|
183
188
|
const { registerUpdaterIpc } = require('./updaterIpc.cjs');
|
|
189
|
+
const { registerLoginItemIpc } = require('./loginItemIpc.cjs');
|
|
184
190
|
const { listExchanges } = require('./exchanges.cjs');
|
|
185
191
|
const { resolveClaudeBin } = require('./lib/claude/claudeBin.cjs');
|
|
186
192
|
const { checkInsideHome, assertInsideHome } = require('./lib/insideHome.cjs');
|
|
@@ -642,7 +648,7 @@ function broadcastMacrosChanged() {
|
|
|
642
648
|
ipcMain.handle('macros:list', () => macroLibrary.listMacros());
|
|
643
649
|
// Background macro jobs: dispatch a built-in macro as a scheduler PRD inside an existing Epic.
|
|
644
650
|
// createPrd is wired exactly as chat:create-prd (below) so its own reconcile request queues the row.
|
|
645
|
-
|
|
651
|
+
const macroJobIpcDeps = {
|
|
646
652
|
schemas,
|
|
647
653
|
validatePath: require('./config.cjs').validatePath,
|
|
648
654
|
readActiveIndex: require('./lib/epic/epicMint.cjs').readActiveIndex,
|
|
@@ -651,7 +657,11 @@ require('./lib/persona-macro/macroJobIpc.cjs').registerMacroJobIpc(ipcMain, {
|
|
|
651
657
|
archivePrd: (slug, cwd) => queueOps.archiveMany([slug], cwd),
|
|
652
658
|
// Durable 'job-not-queued' notice on the Epic when a dispatch fails (PRD 2950).
|
|
653
659
|
appendResponseEventWithReason: promptSessionEvents.appendResponseEventWithReason,
|
|
654
|
-
}
|
|
660
|
+
};
|
|
661
|
+
require('./lib/persona-macro/macroJobIpc.cjs').registerMacroJobIpc(ipcMain, macroJobIpcDeps);
|
|
662
|
+
// Project Video review step: list + human decide (approve / ask for changes). Same deps
|
|
663
|
+
// as macroJobIpc — a decision dispatches through runToolJob. Renderer IPC only.
|
|
664
|
+
require('./lib/project-pages/videoReviewIpc.cjs').registerVideoReviewIpc(ipcMain, macroJobIpcDeps);
|
|
655
665
|
// claudeConfig (lib/claudeConfig.cjs): key-scoped read/patch of Claude's JSON config files.
|
|
656
666
|
// A successful patch broadcasts `config:changed` so renderer state refreshes.
|
|
657
667
|
ipcMain.handle('claudeConfig:read', validated(schemas.claudeConfigRead, async (p) => {
|
|
@@ -666,7 +676,27 @@ ipcMain.handle('claudeConfig:patch', validated(schemas.claudeConfigPatch, async
|
|
|
666
676
|
sendIfAlive(mainWindow, 'config:changed', { path: result.path, mtimeMs, kind: 'change' });
|
|
667
677
|
return result;
|
|
668
678
|
}));
|
|
679
|
+
// toolRisk (lib/claude/toolRiskIpc.cjs): System/Project tool-risk marks + the Project
|
|
680
|
+
// interactive opt-in that installs/removes guard-tool-risk in <cwd>/.claude/settings.json.
|
|
681
|
+
require('./lib/claude/toolRiskIpc.cjs').registerToolRiskIpc(ipcMain, {
|
|
682
|
+
schemas,
|
|
683
|
+
validated,
|
|
684
|
+
validatePath: configMgr.validatePath,
|
|
685
|
+
onChanged: ({ path: changedPath }) => sendIfAlive(mainWindow, 'config:changed', { path: changedPath, mtimeMs: Date.now(), kind: 'change' }),
|
|
686
|
+
});
|
|
669
687
|
ipcMain.handle('macros:save', validated(schemas.macrosSave, async (payload) => {
|
|
688
|
+
// A Project Video tool with a job must be runnable by its persona (projectVideoToolCheck.cjs);
|
|
689
|
+
// a refusal throws so the editor shows the reason. Every other save is unchanged.
|
|
690
|
+
const existing = payload.id ? (await macroLibrary.listMacros()).find((m) => m.id === payload.id) : undefined;
|
|
691
|
+
const surface = payload.surface ?? existing?.surface;
|
|
692
|
+
const job = payload.job !== undefined ? payload.job : existing?.job;
|
|
693
|
+
const projects = payload.projects ?? existing?.projects;
|
|
694
|
+
if (surface === 'project-video' && job && typeof job === 'object'
|
|
695
|
+
&& Array.isArray(projects) && projects.length === 1 && projects[0] !== macroLibrary.ALL_PROJECTS) {
|
|
696
|
+
const { checkProjectVideoToolRunnable } = require('./lib/persona-macro/projectVideoToolCheck.cjs');
|
|
697
|
+
const verdict = await checkProjectVideoToolRunnable({ cwd: projects[0], agentName: payload.agentName, job });
|
|
698
|
+
if (!verdict.ok) throw new Error(verdict.error);
|
|
699
|
+
}
|
|
670
700
|
const macro = await macroLibrary.saveMacro(payload);
|
|
671
701
|
broadcastMacrosChanged();
|
|
672
702
|
return macro;
|
|
@@ -1103,6 +1133,7 @@ queueOps.registerQueueOpsHandlers({ retireCompletedSlugs: scheduler.retireComple
|
|
|
1103
1133
|
registerHistoryAggregatorHandlers();
|
|
1104
1134
|
registerHistoryDashboardHandlers();
|
|
1105
1135
|
registerLoopEfficiencyHandlers();
|
|
1136
|
+
registerValidationQualityHandlers();
|
|
1106
1137
|
pluginInstall.registerPluginInstallHandlers();
|
|
1107
1138
|
memoryTool.registerMemoryHandlers();
|
|
1108
1139
|
activeIndexMerge.registerActiveIndexMergeHandlers();
|
|
@@ -1119,6 +1150,7 @@ epicWorktreeProjectConfig.registerEpicWorktreeProjectConfigHandlers();
|
|
|
1119
1150
|
registerMemoryAggregateIpc();
|
|
1120
1151
|
registerProjectBriefIpc();
|
|
1121
1152
|
registerProjectPagesIpc();
|
|
1153
|
+
require('./lib/tasks/taskIpc.cjs').registerTaskIpc({ ipcMain });
|
|
1122
1154
|
ipcMain.handle('promptSessionTranscript:append', validated(schemas.promptSessionTranscriptAppend, async ({ cwd, epicId, role, text, at, eventId }) => {
|
|
1123
1155
|
const ok = await promptSessionTranscript.appendTurn(cwd, epicId, { role, text, at, eventId });
|
|
1124
1156
|
return { ok };
|
|
@@ -1150,6 +1182,25 @@ try {
|
|
|
1150
1182
|
} catch (e) {
|
|
1151
1183
|
logs.writeLine({ scope: 'main', level: 'error', message: 'updater IPC registration failed', meta: { error: e?.message } });
|
|
1152
1184
|
}
|
|
1185
|
+
try {
|
|
1186
|
+
const { createLoginItem } = require('./lib/process/loginItem.cjs');
|
|
1187
|
+
const loginItem = createLoginItem({
|
|
1188
|
+
app,
|
|
1189
|
+
platform: process.platform,
|
|
1190
|
+
packaged: isPackagedApp(),
|
|
1191
|
+
dev: process.env.SM_DEV === '1' || process.env.SM_E2E === '1',
|
|
1192
|
+
homeDir: os.homedir(),
|
|
1193
|
+
env: process.env,
|
|
1194
|
+
appId: 'run.bilko.session-manager',
|
|
1195
|
+
resolveNpx,
|
|
1196
|
+
warn: (message, meta) => logs.writeLine({ scope: 'main', level: 'warn', message, meta }),
|
|
1197
|
+
});
|
|
1198
|
+
registerLoginItemIpc({ ipcMain, loginItem });
|
|
1199
|
+
// Bring an enabled login item up to this build's script + entry; not awaited, never throws.
|
|
1200
|
+
void loginItem.refreshIfStale();
|
|
1201
|
+
} catch (e) {
|
|
1202
|
+
logs.writeLine({ scope: 'main', level: 'error', message: 'login item IPC registration failed', meta: { error: e?.message } });
|
|
1203
|
+
}
|
|
1153
1204
|
try {
|
|
1154
1205
|
require('./lib/opsRetentionSettings.cjs').registerIpc(ipcMain);
|
|
1155
1206
|
} catch (e) {
|
|
@@ -1279,6 +1330,9 @@ function runRunLogRetentionPass() {
|
|
|
1279
1330
|
removedFiles: (result.removedFiles || 0) + tmp.removedFiles + archive.removedFiles,
|
|
1280
1331
|
freedBytes: (result.freedBytes || 0) + tmp.freedBytes + archive.freedBytes,
|
|
1281
1332
|
errorCount: (result.errors ? result.errors.length : 0) + tmp.errors.length + archive.errors.length,
|
|
1333
|
+
// plan-records/<epic-id>/ of completed/orphan Epics, pruned inside runBootSweep
|
|
1334
|
+
// for the same project list readMergedSync swept (planRecordsDays knob).
|
|
1335
|
+
planRecords: result.planRecords || null,
|
|
1282
1336
|
},
|
|
1283
1337
|
});
|
|
1284
1338
|
} catch (e) {
|
package/src/main/ipcSchemas.cjs
CHANGED
|
@@ -16,6 +16,7 @@ const { AgentPersonaSaveSchema, PersonaNameSchema, ProjectCwdSchema } = require(
|
|
|
16
16
|
const { MacroSaveSchema, MacroDeleteSchema, MacroSetProjectSchema, MacroRemoveFromProjectSchema, MacroInputSchema } = require('./lib/persona-macro/macroLibrary.cjs');
|
|
17
17
|
const { MAX_SLOTS } = require('./lib/scheduler/sessionSlots.cjs');
|
|
18
18
|
const { PRD_EFFORT_LEVELS } = require('./lib/prd/prdFrontmatter.cjs');
|
|
19
|
+
const { MISS_KINDS } = require('./lib/scheduler/validatorVerdictSchema.cjs');
|
|
19
20
|
// Aliased: this file already has a looser, exchanges-only SESSION_ID_RE (Exchanges section).
|
|
20
21
|
const { SESSION_ID_RE: RESTORABLE_SESSION_ID_RE } = require('./lib/epic/restorableSessions.cjs');
|
|
21
22
|
|
|
@@ -127,10 +128,19 @@ const configWriteJson = z.object({
|
|
|
127
128
|
writer: z.string().min(1).max(64).optional(),
|
|
128
129
|
});
|
|
129
130
|
|
|
131
|
+
// `importedBy`: a CLAUDE.md / CLAUDE.local.md whose @-import closure main
|
|
132
|
+
// checks to allow writing an imported instruction file (config.cjs
|
|
133
|
+
// checkInstructionWrite). Main proves the import; the renderer only names it.
|
|
130
134
|
const configWriteText = z.object({
|
|
131
135
|
path: z.string().min(1).max(4096),
|
|
132
136
|
text: z.string(),
|
|
133
137
|
writer: z.string().min(1).max(64).optional(),
|
|
138
|
+
importedBy: z.string().min(1).max(4096).optional(),
|
|
139
|
+
});
|
|
140
|
+
|
|
141
|
+
const configCanWrite = z.object({
|
|
142
|
+
path: z.string().min(1).max(4096),
|
|
143
|
+
importedBy: z.string().min(1).max(4096).optional(),
|
|
134
144
|
});
|
|
135
145
|
|
|
136
146
|
const configListDir = z.object({
|
|
@@ -425,6 +435,15 @@ const DepSlugSchema = z.string().min(1).max(160).regex(/^[A-Za-z0-9][\w.-]*$/);
|
|
|
425
435
|
// large /develop plan depends on every other slug in the plan, so this must
|
|
426
436
|
// stay well above the largest plan size the PRD authoring flow allows.
|
|
427
437
|
const MAX_DEPENDS_ON = 100;
|
|
438
|
+
// Tool-risk rule strings a PRD is cleared to call — shared by schedulerCreatePrd
|
|
439
|
+
// and adminPrdFrontmatterPatch so create and update accept the same shape.
|
|
440
|
+
// The rule grammar (toolRiskMarks.parseRule), de-dup and cap are re-checked by
|
|
441
|
+
// prdCreate.cjs's normalizeRiskTools on both paths.
|
|
442
|
+
const RiskToolsSchema = z.array(z.string().min(1).max(200)).max(20);
|
|
443
|
+
// A PRD's optional preflight command — shared by schedulerCreatePrd (hence
|
|
444
|
+
// every adminCreatePrds entry) and adminPrdFrontmatterPatch. One gate-syntax
|
|
445
|
+
// command; its grammar is re-checked by the PRD library, not here.
|
|
446
|
+
const PreflightSchema = z.string().max(500);
|
|
428
447
|
// Wave-authoring decision (scheduler wave-disposition PRD), shared between
|
|
429
448
|
// schedulerCreatePrd (authoring time) and adminPrdFrontmatterPatch (the
|
|
430
449
|
// after-the-fact change path) so both can never disagree on what a valid
|
|
@@ -450,6 +469,18 @@ const schedulerCreatePrd = z.object({
|
|
|
450
469
|
// Explicit ordering (PRD 832): slugs that must complete before this PRD
|
|
451
470
|
// becomes eligible. Written to frontmatter as `dependsOn: [a, b]`.
|
|
452
471
|
dependsOn: z.array(DepSlugSchema).max(MAX_DEPENDS_ON).optional(),
|
|
472
|
+
// Deliberate cross-Epic duplicate: exact NN slugs of other Epics' PRDs that
|
|
473
|
+
// share this PRD's bare slug. createPrd refuses such a duplicate (409) unless
|
|
474
|
+
// this lists every one of them (prdCreate.cjs findCrossEpicDuplicates).
|
|
475
|
+
allowDuplicateOf: z.array(z.string().min(1).max(160).regex(/^\d+-[A-Za-z0-9][\w.-]*$/, 'must be an exact NN-prefixed slug')).max(MAX_DEPENDS_ON).optional(),
|
|
476
|
+
// The earlier PRDs this PRD repairs (PRD prd-fixes-field). Bounds mirror
|
|
477
|
+
// prdCreate.cjs FIXES_MAX / FIX_REASON_MAX; createPrd resolves each prd to an
|
|
478
|
+
// existing NN slug and re-checks the shape (validateFixesShape).
|
|
479
|
+
fixes: z.array(z.object({
|
|
480
|
+
prd: z.string().min(1).max(160),
|
|
481
|
+
missKind: z.enum(/** @type {[string, ...string[]]} */ ([...MISS_KINDS])),
|
|
482
|
+
reason: z.string().min(1).max(200),
|
|
483
|
+
})).min(1).max(20).optional(),
|
|
453
484
|
// Explicit wave-authoring decision (scheduler wave-disposition PRD) — only
|
|
454
485
|
// meaningful (and only stamped) when this PRD joins an Epic that already
|
|
455
486
|
// has incomplete PRDs and lands as a wave root (no dependsOn of its own);
|
|
@@ -459,6 +490,13 @@ const schedulerCreatePrd = z.object({
|
|
|
459
490
|
// Artifact-only PRD declaration — cross-field rules enforced in prdCreate.cjs.
|
|
460
491
|
deliverable: z.literal('artifact').optional(),
|
|
461
492
|
artifactPaths: z.array(z.string().min(1).max(1024).regex(NO_NEWLINE_RE, 'must not contain newlines')).max(50).optional(),
|
|
493
|
+
// Tool-risk rule strings this PRD is cleared to call (toolRiskMarks.parseRule
|
|
494
|
+
// grammar, re-checked + de-duplicated in prdCreate.cjs; written as `riskTools`).
|
|
495
|
+
riskTools: RiskToolsSchema.optional(),
|
|
496
|
+
// Read-only, shell-free precondition command in gate syntax (PRD
|
|
497
|
+
// preflight-api-schemas). Passed through unchanged; prdCreate.cjs owns the
|
|
498
|
+
// grammar check and writes it as `preflight` frontmatter.
|
|
499
|
+
preflight: PreflightSchema.optional(),
|
|
462
500
|
// An EXISTING Epic's promptSessionId (PRD 748) — NOT a PromptTicket.id.
|
|
463
501
|
// ensureEpic() (epicMint.cjs) joins the Epic whose active-index.json
|
|
464
502
|
// sessions key literally equals this value; the renderer only ever sends
|
|
@@ -622,8 +660,10 @@ const adminListAgentsQuery = z.object({
|
|
|
622
660
|
cwd: z.string().min(1).max(4096).optional(),
|
|
623
661
|
});
|
|
624
662
|
|
|
663
|
+
// cwd is optional only for a lookup by id: Session Manager then finds the
|
|
664
|
+
// Epic among its registered projects (epicOutsideRead.findEpicProject).
|
|
625
665
|
const adminGetEpicQuery = z.object({
|
|
626
|
-
cwd: z.string().min(1).max(4096),
|
|
666
|
+
cwd: z.string().min(1).max(4096).optional(),
|
|
627
667
|
id: z.string().min(1).max(200).optional(),
|
|
628
668
|
externalRef: z.string().max(1000).optional().transform((v, ctx) => {
|
|
629
669
|
if (v === undefined) return undefined;
|
|
@@ -638,6 +678,8 @@ const adminGetEpicQuery = z.object({
|
|
|
638
678
|
receipt: z.string().max(10).optional().transform((v) => v === '1' || v === 'true'),
|
|
639
679
|
}).refine((v) => (v.id === undefined) !== (v.externalRef === undefined), {
|
|
640
680
|
message: 'exactly one of id or externalRef is required',
|
|
681
|
+
}).refine((v) => v.externalRef === undefined || v.cwd !== undefined, {
|
|
682
|
+
message: 'externalRef requires cwd',
|
|
641
683
|
});
|
|
642
684
|
|
|
643
685
|
// Partial frontmatter patch for update-prd — same recognized-key set as
|
|
@@ -679,6 +721,12 @@ const adminPrdFrontmatterPatch = z.object({
|
|
|
679
721
|
// chain) rewrites this alongside dependsOn via the same
|
|
680
722
|
// schedule:set-prd-disposition path (see prdDisposition.cjs).
|
|
681
723
|
disposition: PrdDispositionSchema.optional(),
|
|
724
|
+
// Patchable after creation too, with the SAME shape as create. updatePrd
|
|
725
|
+
// re-checks a non-empty list with normalizeRiskTools; an explicit `[]`
|
|
726
|
+
// removes the key from the PRD file.
|
|
727
|
+
riskTools: RiskToolsSchema.optional(),
|
|
728
|
+
// Patchable after creation too, same shape as create (see PreflightSchema).
|
|
729
|
+
preflight: PreflightSchema.optional(),
|
|
682
730
|
});
|
|
683
731
|
|
|
684
732
|
const adminUpdatePrd = z.object({
|
|
@@ -703,9 +751,15 @@ const adminUpdatePrd = z.object({
|
|
|
703
751
|
'body cannot be combined with gate, files or acceptanceCriteria',
|
|
704
752
|
);
|
|
705
753
|
|
|
754
|
+
// `dependents` (PRD 3499): what happens to pending PRDs that depend on the
|
|
755
|
+
// cancelled job — required by remote.cancelJob whenever any exist.
|
|
706
756
|
const adminCancelJob = z.object({
|
|
707
757
|
slug: z.string().regex(SCHEDULE_SLUG_RE),
|
|
708
758
|
cwd: z.string().min(1).max(4096).optional(),
|
|
759
|
+
dependents: z.object({
|
|
760
|
+
action: z.enum(['cascade', 'repoint', 'clear']),
|
|
761
|
+
to: z.string().min(1).max(200).optional(),
|
|
762
|
+
}).strict().refine((d) => d.action !== 'repoint' || d.to !== undefined, 'dependents.to is required for action "repoint"').optional(),
|
|
709
763
|
});
|
|
710
764
|
|
|
711
765
|
// ──────────────────────────────────────────── Projects
|
|
@@ -784,6 +838,19 @@ const claudeConfigPatch = z.object({
|
|
|
784
838
|
keyPath: z.array(z.string().min(1).max(256)).min(1).max(8),
|
|
785
839
|
value: z.unknown().optional(),
|
|
786
840
|
}).strict();
|
|
841
|
+
// toolRisk:read / toolRisk:write — mirrors ToolRiskReadInput / ToolRiskWriteInput
|
|
842
|
+
// (src/preload/api.d.ts). Rule/mark validity is toolRiskMarks.cjs's job (so its
|
|
843
|
+
// error text reaches the UI); here only the shape is pinned.
|
|
844
|
+
const toolRiskBase = {
|
|
845
|
+
scope: z.enum(['user', 'project']),
|
|
846
|
+
cwd: z.string().min(1).max(4096).nullish(),
|
|
847
|
+
};
|
|
848
|
+
const toolRiskRead = z.object(toolRiskBase).strict();
|
|
849
|
+
const toolRiskWrite = z.object({
|
|
850
|
+
...toolRiskBase,
|
|
851
|
+
marks: z.record(z.string().max(1024), z.unknown()),
|
|
852
|
+
interactive: z.boolean().optional(),
|
|
853
|
+
}).strict();
|
|
787
854
|
// mcp:check-server — names WHICH configured server to check, never its config:
|
|
788
855
|
// main reads that from disk (lib/mcpToolsProbe.cjs checkConfiguredMcpServer), so
|
|
789
856
|
// the renderer can't make main spawn a command of its choosing. A project server
|
|
@@ -802,12 +869,17 @@ const macrosSave = MacroSaveSchema;
|
|
|
802
869
|
const macrosDelete = MacroDeleteSchema;
|
|
803
870
|
const macrosSetProject = MacroSetProjectSchema;
|
|
804
871
|
const macrosRemoveFromProject = MacroRemoveFromProjectSchema;
|
|
805
|
-
// Background macro job (macroJobIpc.cjs): press a built-in macro as a scheduler PRD inside an existing Epic.
|
|
872
|
+
// Background macro job (macroJobIpc.cjs): press a built-in macro or project Video tool as a scheduler PRD inside an existing Epic.
|
|
806
873
|
const macrosDispatchJob = z.object({
|
|
807
874
|
cwd: z.string().min(1).max(4096),
|
|
808
875
|
macroId: z.string().min(1).max(128),
|
|
809
876
|
epicId: z.string().min(1).max(200),
|
|
810
877
|
extraInstructions: z.string().max(4000).optional(),
|
|
878
|
+
// A project Video tool's input values. No `review` key: an unknown key is
|
|
879
|
+
// stripped, so only the main-side review-decision IPC can pass a decision.
|
|
880
|
+
inputValues: z.record(z.string().max(128), z.string().max(4000))
|
|
881
|
+
.refine((o) => Object.keys(o).length <= 20, 'at most 20 input values')
|
|
882
|
+
.optional(),
|
|
811
883
|
effort: z.enum(/** @type {[string, ...string[]]} */ ([...PRD_EFFORT_LEVELS])).optional(),
|
|
812
884
|
});
|
|
813
885
|
const macrosJobStatus = z.object({ cwd: z.string().min(1).max(4096) });
|
|
@@ -1002,22 +1074,15 @@ const projectPagesCwd = z.object({
|
|
|
1002
1074
|
cwd: z.string().min(1).max(4096),
|
|
1003
1075
|
}).strict();
|
|
1004
1076
|
|
|
1005
|
-
// project-pages:md-network — cwd
|
|
1006
|
-
//
|
|
1007
|
-
//
|
|
1008
|
-
const mdNetworkFolder = z.string().min(1).max(512).refine(
|
|
1009
|
-
(f) => !f.startsWith('/') && !f.includes('\\') && !f.includes('\0') && !f.split('/').includes('..'),
|
|
1010
|
-
{ message: "folder must be repo-relative (no leading '/', backslash, NUL or '..' segment)" },
|
|
1011
|
-
);
|
|
1012
|
-
const mdNetworkFolderList = z.array(mdNetworkFolder).max(50);
|
|
1077
|
+
// project-pages:md-network — cwd only. History folders come from the tracked
|
|
1078
|
+
// .session-manager.json mdNetwork.history and the census heuristic; the IPC
|
|
1079
|
+
// carries no folder overrides (.strict() rejects recordFolders/docFolders).
|
|
1013
1080
|
const projectPagesMdNetwork = z.object({
|
|
1014
1081
|
cwd: z.string().min(1).max(4096),
|
|
1015
|
-
recordFolders: mdNetworkFolderList.optional(),
|
|
1016
|
-
docFolders: mdNetworkFolderList.optional(),
|
|
1017
1082
|
}).strict();
|
|
1018
1083
|
|
|
1019
|
-
// project-pages:md-review — cwd plus optional
|
|
1020
|
-
// reviews/validation/<id>/ folders to list. Ids are joined onto
|
|
1084
|
+
// project-pages:md-review — cwd plus optional Epic ids whose plan-records/<id>/
|
|
1085
|
+
// + legacy reviews/validation/<id>/ folders to list. Ids are joined onto fs; the
|
|
1021
1086
|
// slug regex (same as lib/mdReviewRecord.cjs EPIC_ID_RE) is load-bearing.
|
|
1022
1087
|
const projectPagesMdReview = z.object({
|
|
1023
1088
|
cwd: z.string().min(1).max(4096),
|
|
@@ -1044,6 +1109,15 @@ const projectDemoVideoAdminWriteBody = z.object({
|
|
|
1044
1109
|
// never match.
|
|
1045
1110
|
const ENTRY_ID_RE = /^[a-z0-9][a-z0-9-]{0,63}$/;
|
|
1046
1111
|
const entryId = z.string().regex(ENTRY_ID_RE);
|
|
1112
|
+
// Project Video review step (project-pages/videoReviewIpc.cjs): renderer IPC only.
|
|
1113
|
+
const projectVideosReviewList = z.object({ cwd: z.string().min(1).max(4096) }).strict();
|
|
1114
|
+
const projectVideosReviewDecide = z.object({
|
|
1115
|
+
cwd: z.string().min(1).max(4096),
|
|
1116
|
+
entryId,
|
|
1117
|
+
decision: z.enum(['approve', 'changes']),
|
|
1118
|
+
note: z.string().max(2000).optional(),
|
|
1119
|
+
}).strict();
|
|
1120
|
+
const projectVideosReviewRetry = z.object({ cwd: z.string().min(1).max(4096), entryId }).strict();
|
|
1047
1121
|
const projectVideoReportFields = {
|
|
1048
1122
|
lufs: z.number().nullable(),
|
|
1049
1123
|
truePeakDb: z.number().nullable(),
|
|
@@ -1058,8 +1132,10 @@ const projectVideoReportFields = {
|
|
|
1058
1132
|
const projectVideoMeta = z.object({
|
|
1059
1133
|
id: entryId,
|
|
1060
1134
|
title: z.string().min(1).max(120),
|
|
1061
|
-
kind: z.enum(['project-demo', 'blog-post', 'feature']),
|
|
1135
|
+
kind: z.enum(['project-demo', 'blog-post', 'feature', 'episode']),
|
|
1062
1136
|
target: z.string().max(300).optional(),
|
|
1137
|
+
// From the document's sm-demo-aspect tag; absent on older entries (treat as '16:9').
|
|
1138
|
+
aspect: z.enum(['16:9', '9:16']).optional(),
|
|
1063
1139
|
style: z.string().max(40),
|
|
1064
1140
|
lengthS: z.number().int().min(5).max(60),
|
|
1065
1141
|
createdAt: z.string().datetime(),
|
|
@@ -1106,7 +1182,7 @@ const projectVideoAdminWriteBody = z.object({
|
|
|
1106
1182
|
cwd: z.string().min(1).max(4096).optional(),
|
|
1107
1183
|
videoId: entryId,
|
|
1108
1184
|
title: z.string().min(1).max(120),
|
|
1109
|
-
kind: z.enum(['project-demo', 'blog-post', 'feature']),
|
|
1185
|
+
kind: z.enum(['project-demo', 'blog-post', 'feature', 'episode']),
|
|
1110
1186
|
lengthS: z.number().int().min(5).max(60),
|
|
1111
1187
|
html: z.string(),
|
|
1112
1188
|
meta: projectVideoMeta.omit({ id: true, createdAt: true }).extend({
|
|
@@ -1386,6 +1462,26 @@ const historyDashboard = z.object({
|
|
|
1386
1462
|
rangeDays: z.union([z.literal(30), z.literal(60), z.literal(90), z.literal(0)]),
|
|
1387
1463
|
}).strict();
|
|
1388
1464
|
|
|
1465
|
+
// ──────────────────────────────────────────── Tasks (lib/tasks/taskIpc.cjs)
|
|
1466
|
+
const TaskCwd = z.string().min(1).max(4096).refine((s) => path.isAbsolute(s), 'cwd must be absolute');
|
|
1467
|
+
const TaskFilter = z.string().min(1).max(512).optional();
|
|
1468
|
+
const TaskListQuery = z.object({
|
|
1469
|
+
cwd: TaskCwd,
|
|
1470
|
+
since: TaskFilter,
|
|
1471
|
+
until: TaskFilter,
|
|
1472
|
+
pipeline: TaskFilter,
|
|
1473
|
+
runId: TaskFilter,
|
|
1474
|
+
step: TaskFilter,
|
|
1475
|
+
agent: TaskFilter,
|
|
1476
|
+
status: TaskFilter,
|
|
1477
|
+
source: TaskFilter,
|
|
1478
|
+
limit: z.number().int().min(1).max(200).optional(),
|
|
1479
|
+
offset: z.number().int().min(0).optional(),
|
|
1480
|
+
}).strict();
|
|
1481
|
+
const TaskGetQuery = z.object({ cwd: TaskCwd, id: z.string().min(1).max(200) }).strict();
|
|
1482
|
+
const TaskSwitchQuery = z.object({ cwd: TaskCwd }).strict();
|
|
1483
|
+
const TaskSwitchSet = z.object({ cwd: TaskCwd, enabled: z.boolean() }).strict();
|
|
1484
|
+
|
|
1389
1485
|
// ──────────────────────────────────────────── Voice (F1/F5/F7/F8)
|
|
1390
1486
|
// Mirrors voiceSettings.cjs isValidConfig / isValidDevicePref / isValid…
|
|
1391
1487
|
// validators (ad-hoc on disk). Schemas here gate the IPC boundary so a
|
|
@@ -1642,6 +1738,7 @@ module.exports = {
|
|
|
1642
1738
|
configReadText,
|
|
1643
1739
|
configWriteJson,
|
|
1644
1740
|
configWriteText,
|
|
1741
|
+
configCanWrite,
|
|
1645
1742
|
configListDir,
|
|
1646
1743
|
configWatch,
|
|
1647
1744
|
configWatchOpts,
|
|
@@ -1671,6 +1768,10 @@ module.exports = {
|
|
|
1671
1768
|
archiveProject,
|
|
1672
1769
|
historyAggregate,
|
|
1673
1770
|
historyDashboard,
|
|
1771
|
+
TaskListQuery,
|
|
1772
|
+
TaskGetQuery,
|
|
1773
|
+
TaskSwitchQuery,
|
|
1774
|
+
TaskSwitchSet,
|
|
1674
1775
|
voiceSetHotkey,
|
|
1675
1776
|
voiceSetDevicePref,
|
|
1676
1777
|
voiceSetTurnDetector,
|
|
@@ -1756,6 +1857,8 @@ module.exports = {
|
|
|
1756
1857
|
agentsDeletePersona,
|
|
1757
1858
|
claudeConfigRead,
|
|
1758
1859
|
claudeConfigPatch,
|
|
1860
|
+
toolRiskRead,
|
|
1861
|
+
toolRiskWrite,
|
|
1759
1862
|
mcpCheckServer,
|
|
1760
1863
|
macrosSave,
|
|
1761
1864
|
macrosDelete,
|
|
@@ -1763,6 +1866,9 @@ module.exports = {
|
|
|
1763
1866
|
macrosRemoveFromProject,
|
|
1764
1867
|
macrosDispatchJob,
|
|
1765
1868
|
macrosJobStatus,
|
|
1869
|
+
projectVideosReviewList,
|
|
1870
|
+
projectVideosReviewDecide,
|
|
1871
|
+
projectVideosReviewRetry,
|
|
1766
1872
|
needsYouList,
|
|
1767
1873
|
needsYouAnswer,
|
|
1768
1874
|
agentsGetPersonaBody,
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
# src/main/lib/ — scoped context
|
|
2
|
+
|
|
3
|
+
Shared main-process helpers (CommonJS `.cjs`). Layout source of truth: `scripts/lib-layout.json`.
|
|
4
|
+
|
|
5
|
+
## What's here
|
|
6
|
+
|
|
7
|
+
- `agent-cli/` — other agent CLIs: registry, adapters, session store, turn planner, IPC.
|
|
8
|
+
- `app-preview/` — Epic dev-server preview processes (spawn, URL detect, stop, orphan sweep).
|
|
9
|
+
- `claude/` — claude CLI binary, caps, model/effort resolution.
|
|
10
|
+
- `demo-video-kit/` — demo-video build tools (capture, sound, frames, checks), seeded to `~/.claude/session-manager/demo-video-kit/`.
|
|
11
|
+
- `epic/` — Epic mint, worktrees, active index, spawn plan/cwd, transcripts.
|
|
12
|
+
- `feedback-remote/` — cross-project and customer feedback conduits.
|
|
13
|
+
- `git/` — git exec, worktrees, branch sweeps, job worktrees.
|
|
14
|
+
- `persona-macro/` — agent persona schema/merge, macro library, builtin macros.
|
|
15
|
+
- `prd/` — PRD parsing helpers, admin routes, dep-slug resolution, plan validation.
|
|
16
|
+
- `process/` — child processes, kill tree, env cleaning, pid liveness, instance lock.
|
|
17
|
+
- `project-pages/` — Project Home pages library, competitor matrix store/HTML, player bridge.
|
|
18
|
+
- `scheduler/` — dispatch loop, session slots, gates, supervisors, queue helpers.
|
|
19
|
+
- `tasks/` — Task ledger, switch, runner, admin routes and IPC (one headless claude -p run per project); store: [`tasks/README.md`](../../../session-manager-operations/tasks/README.md).
|
|
20
|
+
- `telemetry/` — audit/ops error logs, crash and OTLP telemetry.
|
|
21
|
+
- `util/` — generic pure helpers (atomic fs, kebab, home/cwd encoding, JSON extract, tail).
|
|
22
|
+
- top-level files — cross-cutting modules that fit no domain (`opsOwnership`, `activeSessions`, `projectRootResolve`, `cwdClassify`).
|
|
23
|
+
- `__tests__/` — tests for top-level modules; subfolders carry their own.
|
|
24
|
+
|
|
25
|
+
## Where a new module goes
|
|
26
|
+
|
|
27
|
+
Put it in the subfolder whose domain it serves; pure and domain-free goes in `util/`.
|
|
28
|
+
A new top-level `lib/` module needs a stated reason (no domain fits) in its header comment,
|
|
29
|
+
and a `scripts/lib-layout.json` entry. Never add a subfolder for one file.
|
|
30
|
+
|
|
31
|
+
## Reuse before writing
|
|
32
|
+
|
|
33
|
+
Each of these was found duplicated once. Grep first; extend the canonical one.
|
|
34
|
+
|
|
35
|
+
| Need | Canonical | Function |
|
|
36
|
+
| --- | --- | --- |
|
|
37
|
+
| Atomic write (tmp+rename) | `util/atomicFs.cjs` | `writeTextAtomic[Sync]`, `writeJsonAtomic[Sync]` |
|
|
38
|
+
| JSON read with fallback | `util/atomicFs.cjs` | `readJsonOr`, `readJsonOrSync` |
|
|
39
|
+
| PID liveness | `process/pidAlive.cjs` | `pidAlive` |
|
|
40
|
+
| Kebab / slug | `util/kebabCase.cjs` | `kebabCase` |
|
|
41
|
+
| Project root, read-only/total (never throws) | `activeSessions.cjs` | `projectRootOf` |
|
|
42
|
+
| Project root, validated; `opsInternal:'refuse'` for writers | `opsOwnership.cjs` | `resolveProjectRoot` |
|
|
43
|
+
| Project root + Epic from session/epic hints | `projectRootResolve.cjs` | `resolveProjectContext` |
|
|
44
|
+
| Ops-root path (single-writer law) | `opsOwnership.cjs` | `opsPath` |
|
|
45
|
+
| Run git | `git/gitExec.cjs` | `execGit` |
|
|
46
|
+
| Spawn `claude -p` (only machine-wide cap) | `scheduler/sessionSlots.cjs` | `acquire`, `release` |
|
|
47
|
+
|
|
48
|
+
Pin `--model` on every `claude -p` spawn.
|
|
49
|
+
|
|
50
|
+
## What must NOT be assumed
|
|
51
|
+
|
|
52
|
+
- No private process caps, no hand-rolled tmp+rename, no new `JSON.parse(readFileSync)` fallbacks.
|
|
53
|
+
- Never call `activeSessions.cjs` `allProjectCwds`/`activeProjectCwds` on an IPC, boot or timer hot path: they scan `~/.claude/projects` synchronously (7k+ dirs, 0.3-4 s; the 2026-10-25 OOM crashes).
|
|
54
|
+
- `ipcSchemas.cjs` `validated()` passes the zod-parsed payload, which strips unknown keys: an IPC key rename the schema misses silently drops the key (2026-11-07 persona wipe). Rename keys and schema in one PRD; prefer `.strict()`.
|
package/src/main/lib/CLAUDE.md
CHANGED
|
@@ -1,54 +1 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
Shared main-process helpers (CommonJS `.cjs`). Layout source of truth: `scripts/lib-layout.json`.
|
|
4
|
-
|
|
5
|
-
## What's here
|
|
6
|
-
|
|
7
|
-
- `agent-cli/` — other agent CLIs: registry, adapters, session store, turn planner, IPC.
|
|
8
|
-
- `app-preview/` — Epic dev-server preview processes (spawn, URL detect, stop, orphan sweep).
|
|
9
|
-
- `claude/` — claude CLI binary, caps, model/effort resolution.
|
|
10
|
-
- `demo-video-kit/` — demo-video build tools (capture, sound, frames, checks), seeded to `~/.claude/session-manager/demo-video-kit/`.
|
|
11
|
-
- `epic/` — Epic mint, worktrees, active index, spawn plan/cwd, transcripts.
|
|
12
|
-
- `feedback-remote/` — cross-project and customer feedback conduits.
|
|
13
|
-
- `git/` — git exec, worktrees, branch sweeps, job worktrees.
|
|
14
|
-
- `persona-macro/` — agent persona schema/merge, macro library, builtin macros.
|
|
15
|
-
- `prd/` — PRD parsing helpers, admin routes, dep-slug resolution, plan validation.
|
|
16
|
-
- `process/` — child processes, kill tree, env cleaning, pid liveness, instance lock.
|
|
17
|
-
- `project-pages/` — Project Home pages library, competitor matrix store/HTML, player bridge.
|
|
18
|
-
- `scheduler/` — dispatch loop, session slots, gates, supervisors, queue helpers.
|
|
19
|
-
- `telemetry/` — audit/ops error logs, crash and OTLP telemetry.
|
|
20
|
-
- `util/` — generic pure helpers (atomic fs, kebab, home/cwd encoding, JSON extract, tail).
|
|
21
|
-
- top-level files — cross-cutting modules that fit no domain (`opsOwnership`, `activeSessions`, `projectRootResolve`, `cwdClassify`).
|
|
22
|
-
- `__tests__/` — tests for top-level modules; subfolders carry their own.
|
|
23
|
-
|
|
24
|
-
## Where a new module goes
|
|
25
|
-
|
|
26
|
-
Put it in the subfolder whose domain it serves; pure and domain-free goes in `util/`.
|
|
27
|
-
A new top-level `lib/` module needs a stated reason (no domain fits) in its header comment,
|
|
28
|
-
and a `scripts/lib-layout.json` entry. Never add a subfolder for one file.
|
|
29
|
-
|
|
30
|
-
## Reuse before writing
|
|
31
|
-
|
|
32
|
-
Each of these was found duplicated once. Grep first; extend the canonical one.
|
|
33
|
-
|
|
34
|
-
| Need | Canonical | Function |
|
|
35
|
-
| --- | --- | --- |
|
|
36
|
-
| Atomic write (tmp+rename) | `util/atomicFs.cjs` | `writeTextAtomic[Sync]`, `writeJsonAtomic[Sync]` |
|
|
37
|
-
| JSON read with fallback | `util/atomicFs.cjs` | `readJsonOr`, `readJsonOrSync` |
|
|
38
|
-
| PID liveness | `process/pidAlive.cjs` | `pidAlive` |
|
|
39
|
-
| Kebab / slug | `util/kebabCase.cjs` | `kebabCase` |
|
|
40
|
-
| Project root, read-only/total (never throws) | `activeSessions.cjs` | `projectRootOf` |
|
|
41
|
-
| Project root, validated; `opsInternal:'refuse'` for writers | `opsOwnership.cjs` | `resolveProjectRoot` |
|
|
42
|
-
| Project root + Epic from session/epic hints | `projectRootResolve.cjs` | `resolveProjectContext` |
|
|
43
|
-
| Ops-root path (single-writer law) | `opsOwnership.cjs` | `opsPath` |
|
|
44
|
-
| Run git | `git/gitExec.cjs` | `execGit` |
|
|
45
|
-
| Spawn `claude -p` (only machine-wide cap) | `scheduler/sessionSlots.cjs` | `acquire`, `release` |
|
|
46
|
-
|
|
47
|
-
Pin `--model` on every `claude -p` spawn.
|
|
48
|
-
|
|
49
|
-
## What must NOT be assumed
|
|
50
|
-
|
|
51
|
-
- Never `path.join` an agent cwd to build an ops path — use `opsPath`.
|
|
52
|
-
- No private process caps, no hand-rolled tmp+rename, no new `JSON.parse(readFileSync)` fallbacks.
|
|
53
|
-
- Never call `activeSessions.cjs` `allProjectCwds`/`activeProjectCwds` on an IPC, boot or timer hot path: they scan `~/.claude/projects` synchronously (7k+ dirs, 0.3-4 s; the 2026-10-25 OOM crashes).
|
|
54
|
-
- `ipcSchemas.cjs` `validated()` passes the zod-parsed payload, which strips unknown keys: an IPC key rename the schema misses silently drops the key (2026-11-07 persona wipe). Rename keys and schema in one PRD; prefer `.strict()`.
|
|
1
|
+
@AGENTS.md
|