claude-code-session-manager 0.143.0 → 0.145.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 +3 -1
- package/dist/assets/AppSettings-BR5b6oof.js +2 -0
- package/dist/assets/{History-DTttbvPb.js → History-B4U0mCdK.js} +2 -2
- package/dist/assets/HomeClaudeConfig-DQqG7lFE.js +5 -0
- package/dist/assets/{Panel-B_D4Bg7L.js → Panel-CwsOJ0nI.js} +1 -1
- package/dist/assets/ProjectClaudeConfig-BzRowu8x.js +26 -0
- package/dist/assets/Scheduler-dr7CNOcL.js +16 -0
- package/dist/assets/{SkillReferenceGraph-D1b2aiol.js → SkillReferenceGraph-CroBPY4C.js} +1 -1
- package/dist/assets/{Skills-cfV7sgk6.js → Skills-BiW2lCnD.js} +23 -23
- package/dist/assets/{TiptapBody-DVXtEIVy.js → TiptapBody-CYTkQiva.js} +27 -27
- package/dist/assets/{Toggle-CYajnSdx.js → Toggle-WFBYo8JI.js} +1 -1
- package/dist/assets/{VoiceButton-DJ4gGRuE.js → VoiceButton-DZu8dTpO.js} +1 -1
- package/dist/assets/{historyTotals-D3MoHY2U.js → historyTotals-B7KeXLSE.js} +1 -1
- package/dist/assets/{index-DVHIHoJf.css → index-BJ5TJvmz.css} +1 -1
- package/dist/assets/{index-CdTppjKR.js → index-hXRNm0UJ.js} +698 -697
- package/dist/index.html +2 -2
- package/dist-web/app.css +1 -1
- package/dist-web/app.js +442 -439
- package/package.json +4 -2
- package/plugins/session-manager-dev/skills/develop/SKILL.md +25 -19
- 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 +91 -0
- package/plugins/session-manager-dev/skills/send-feedback/SKILL.md +9 -6
- package/scripts/README.md +1 -1
- package/scripts/scheduler-mcp-server.cjs +77 -0
- package/src/main/adminRouteRegistry.cjs +6 -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 +139 -0
- package/src/main/config.cjs +12 -0
- package/src/main/health.cjs +59 -17
- package/src/main/index.cjs +6 -2
- package/src/main/ipcSchemas.cjs +55 -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 +100 -14
- package/src/main/lib/demo-video-kit/resumableRun.cjs +21 -14
- package/src/main/lib/demo-video-kit/seedKit.cjs +2 -2
- package/src/main/lib/epic/epicDepsSync.cjs +66 -0
- package/src/main/lib/epic/epicOutsideRead.cjs +74 -2
- package/src/main/lib/epic/epicSettle.cjs +48 -4
- package/src/main/lib/epic/epicSpawnPlan.cjs +3 -1
- package/src/main/lib/epic/epicValidationHook.cjs +9 -1
- package/src/main/lib/epic/planReviewInput.cjs +125 -0
- package/src/main/lib/epic/restorableSessions.cjs +1 -0
- package/src/main/lib/epic/scriptStartedBy.cjs +86 -0
- package/src/main/lib/externalContract.cjs +12 -0
- package/src/main/lib/feedback-remote/createdProjects.cjs +291 -0
- package/src/main/lib/feedback-remote/crossProjectFeedback.cjs +108 -14
- package/src/main/lib/feedback-remote/localAdminHttp.cjs +5 -1
- package/src/main/lib/feedback-remote/macroAdminRoutes.cjs +24 -3
- package/src/main/lib/feedback-remote/pendingReplies.cjs +8 -4
- package/src/main/lib/feedback-remote/projectCreate.cjs +415 -0
- package/src/main/lib/feedback-remote/replyClaims.cjs +15 -6
- package/src/main/lib/feedback-remote/serviceMcpSession.cjs +35 -4
- 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 +95 -7
- package/src/main/lib/feedback-remote/serviceStdioBridge.cjs +104 -1
- package/src/main/lib/git/gitWorktree.cjs +1 -1
- package/src/main/lib/git/worktreeDeps.cjs +9 -3
- package/src/main/lib/mcpToolCatalog.cjs +47 -7
- package/src/main/lib/mcpToolsProbe.cjs +19 -2
- package/src/main/lib/opsOwnership.cjs +2 -0
- 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 +94 -0
- package/src/main/lib/prd/prdCreate.cjs +49 -5
- package/src/main/lib/prd/prdFrontmatter.cjs +5 -2
- package/src/main/lib/prd/prdMcpReachWarnings.cjs +46 -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/videoScriptPress.cjs +6 -0
- package/src/main/lib/project-pages/videoScriptRunRoute.cjs +24 -4
- package/src/main/lib/promptSessionSchema.cjs +2 -0
- package/src/main/lib/scheduler/baselineGate.cjs +31 -2
- package/src/main/lib/scheduler/planRecordHarvest.cjs +104 -12
- 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 +150 -0
- package/src/main/lib/scheduler/reviewNotice.cjs +3 -1
- package/src/main/lib/scheduler/sandboxEnvironmentLimit.cjs +141 -0
- package/src/main/lib/scheduler/scheduleJobSchema.cjs +2 -0
- package/src/main/lib/scheduler/upgradeDrain.cjs +32 -5
- package/src/main/lib/scheduler/validatorVerdictSchema.cjs +12 -2
- package/src/main/lib/tasks/memoryConsolidation.cjs +118 -37
- package/src/main/lib/tasks/taskAdminRoutes.cjs +26 -14
- package/src/main/lib/tasks/taskRun.cjs +3 -1
- package/src/main/lib/tasks/weeklyConsolidationInputs.cjs +298 -0
- package/src/main/projectPages.cjs +22 -14
- package/src/main/pty.cjs +3 -0
- package/src/main/runVerify.cjs +80 -5
- package/src/main/scheduler/gitTreeGuard.cjs +6 -0
- package/src/main/scheduler/planReviewHold.cjs +146 -0
- package/src/main/scheduler/prdParser.cjs +1 -0
- package/src/main/scheduler/prdPaths.cjs +10 -1
- package/src/main/scheduler/reviewLadder.cjs +2 -0
- package/src/main/scheduler/utilizationHold.cjs +7 -2
- package/src/main/scheduler.cjs +692 -86
- package/src/main/seedAgentPersonas.cjs +11 -6
- package/src/main/seedStatus.cjs +1 -1
- package/src/main/templates/PRD_AUTHORING.md +17 -2
- package/src/main/webRemote.cjs +69 -7
- package/src/preload/api.d.ts +79 -1
- package/src/preload/apiSurface.json +39 -0
- package/src/preload/index.cjs +11 -0
- package/src/seed/agents/architect.md +28 -43
- 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 +2 -1
- package/dist/assets/AppSettings-BO4jDVGO.js +0 -2
- package/dist/assets/HomeClaudeConfig-DADP5bfn.js +0 -3
- package/dist/assets/ProjectClaudeConfig-DPnDJKcr.js +0 -26
- package/dist/assets/Scheduler-CNLjn90m.js +0 -16
|
@@ -1,16 +1,19 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
|
-
* projectPages.cjs —
|
|
5
|
-
*
|
|
6
|
-
* `
|
|
7
|
-
*
|
|
8
|
-
*
|
|
9
|
-
*
|
|
10
|
-
*
|
|
11
|
-
*
|
|
12
|
-
*
|
|
13
|
-
*
|
|
4
|
+
* projectPages.cjs — main-process backend for Project Home. Its content is a
|
|
5
|
+
* library under `session-manager-operations/project-pages/`: one folder per
|
|
6
|
+
* entry in `knowledge/<id>/` and `videos/<id>/` (index.html + meta.json),
|
|
7
|
+
* listed by lib/project-pages/pagesLibrary.cjs listLibrary(). get() first runs
|
|
8
|
+
* migrateLegacy(), which moves the two legacy files (`home.html`,
|
|
9
|
+
* `demo-video/index.html`) into the library once, then returns { knowledge,
|
|
10
|
+
* videos, html, mtimeMs, demoVideo } (+ persona/outcomes when present); html
|
|
11
|
+
* is the `overview` page and demoVideo the newest video, kept for the phone
|
|
12
|
+
* remote. watchOutput()/unwatchOutput() run a refcounted per-cwd watcher that
|
|
13
|
+
* pushes get()'s result as `project-pages:changed` on library (and legacy or
|
|
14
|
+
* matrix.json) changes. renameEntry() rewrites one entry's meta.json title and
|
|
15
|
+
* deleteEntry() removes one entry folder (writer 'project-home'). mdNetwork()
|
|
16
|
+
* maps the project's markdown link network on demand
|
|
14
17
|
* (lib/mdNetworkScan.cjs) for the Tools pane. matrix() reads the saved
|
|
15
18
|
* Competitor matrix (lib/project-pages/competitiveMatrix.cjs readMatrix).
|
|
16
19
|
* mdReview() reads the newest Review MD network record plus each review
|
|
@@ -159,13 +162,18 @@ function isLibraryPath(rel) {
|
|
|
159
162
|
//
|
|
160
163
|
// project-pages:get is a one-shot pull; this adds a per-cwd chokidar watcher
|
|
161
164
|
// on the project-pages dir that recomputes get() and pushes it to the
|
|
162
|
-
// renderer
|
|
163
|
-
//
|
|
164
|
-
//
|
|
165
|
+
// renderer whenever a path isLibraryPath accepts is added, changed or removed:
|
|
166
|
+
// knowledge/<id>/ and videos/<id>/ index.html or meta.json, the two legacy
|
|
167
|
+
// files home.html and demo-video/index.html, and matrix/matrix.json.
|
|
168
|
+
// Map<realCwd, { watcher, refCount }> — refcounted so several mounted
|
|
169
|
+
// components watching the same cwd share one chokidar instance.
|
|
165
170
|
const outputWatchers = new Map();
|
|
166
171
|
|
|
167
172
|
/**
|
|
168
|
-
* Watch `cwd`'s
|
|
173
|
+
* Watch `cwd`'s project-pages dir: recomputes get() and pushes it whenever a
|
|
174
|
+
* path isLibraryPath accepts is added, changed or removed (knowledge/<id>/ and
|
|
175
|
+
* videos/<id>/ index.html or meta.json, the legacy home.html and
|
|
176
|
+
* demo-video/index.html, and matrix/matrix.json). Resolves `{ ok: true }` once watching is live (or
|
|
169
177
|
* already watching), or `{ ok: false, reason: 'ephemeral' | 'invalid-cwd' }`
|
|
170
178
|
* when there is nothing safe to watch — not an error, just "no live updates
|
|
171
179
|
* for this cwd". Waits for chokidar's 'ready' so a write landing right after
|
package/src/main/pty.cjs
CHANGED
|
@@ -25,6 +25,7 @@ const { sendIfAlive } = require('./lib/sendToRenderer.cjs');
|
|
|
25
25
|
const opsErrorLog = require('./lib/telemetry/opsErrorLog.cjs');
|
|
26
26
|
const { planEpicSpawn } = require('./lib/epic/epicSpawnPlan.cjs');
|
|
27
27
|
const { resolveEpicSpawnCwd } = require('./lib/epic/epicSpawnCwd.cjs');
|
|
28
|
+
const epicDepsSync = require('./lib/epic/epicDepsSync.cjs');
|
|
28
29
|
const telemetryCounters = require('./lib/telemetry/telemetryCounters.cjs');
|
|
29
30
|
const artifactStore = require('./lib/epic/artifactStore.cjs');
|
|
30
31
|
const artifactNotice = require('./lib/epic/artifactNotice.cjs');
|
|
@@ -338,6 +339,8 @@ class PtyManager {
|
|
|
338
339
|
}
|
|
339
340
|
if (spawnCwd !== cwd) {
|
|
340
341
|
console.log(`[pty] tabId=${tabId} isolated in worktree ${spawnCwd}`);
|
|
342
|
+
// Refresh the worktree's node_modules links (fire-and-forget, throttled).
|
|
343
|
+
epicDepsSync.syncEpicWorktreeDeps({ projectCwd: cwd, worktreeCwd: spawnCwd });
|
|
341
344
|
}
|
|
342
345
|
let proc;
|
|
343
346
|
try {
|
package/src/main/runVerify.cjs
CHANGED
|
@@ -99,14 +99,15 @@ function extractContent(item) {
|
|
|
99
99
|
*
|
|
100
100
|
* O(N) where N = log line count.
|
|
101
101
|
*
|
|
102
|
-
* @returns {{ events: object[], resultEvent: object|null, error: string|null }}
|
|
102
|
+
* @returns {{ events: object[], resultEvent: object|null, error: string|null, transcriptCommitLanded?: boolean, transcriptCommitShas: string[], transcriptCommitOutputShas: string[] }}
|
|
103
|
+
* transcriptCommitOutputShas: SHAs git printed in the tool_result of a Bash `git commit` call (a claim, not proof).
|
|
103
104
|
*/
|
|
104
105
|
function parseLog(logPath) {
|
|
105
106
|
let text;
|
|
106
107
|
try {
|
|
107
108
|
text = fs.readFileSync(logPath, 'utf8');
|
|
108
109
|
} catch (e) {
|
|
109
|
-
return { events: [], resultEvent: null, error: e.message, transcriptCommitShas: [] };
|
|
110
|
+
return { events: [], resultEvent: null, error: e.message, transcriptCommitShas: [], transcriptCommitOutputShas: [] };
|
|
110
111
|
}
|
|
111
112
|
|
|
112
113
|
const events = [];
|
|
@@ -192,7 +193,79 @@ function parseLog(logPath) {
|
|
|
192
193
|
}
|
|
193
194
|
}
|
|
194
195
|
|
|
195
|
-
return {
|
|
196
|
+
return {
|
|
197
|
+
events,
|
|
198
|
+
resultEvent,
|
|
199
|
+
error: null,
|
|
200
|
+
transcriptCommitLanded,
|
|
201
|
+
transcriptCommitShas: [...transcriptCommitShaSet],
|
|
202
|
+
transcriptCommitOutputShas: collectCommitOutputShas(events),
|
|
203
|
+
};
|
|
204
|
+
}
|
|
205
|
+
|
|
206
|
+
const GIT_COMMIT_CMD_RE = /\bgit\s+(?:-C\s+\S+\s+)?commit\b/;
|
|
207
|
+
const COMMIT_SUMMARY_RE = /^\[[^\]\s]+(?: \(root-commit\))? ([0-9a-f]{7,40})\]/i;
|
|
208
|
+
const SHA_SUBJECT_RE = /^([0-9a-f]{7,40}) (.+)$/i;
|
|
209
|
+
|
|
210
|
+
const COMMIT_MESSAGE_ARG_RE = /(?:^|\s)(?:-[abd-su-zABDEG-Z]*m|--message)(?:=|\s+|(?=["']))(?:"?\$\(cat <<-?\s*['"]?(\w+)['"]?\n([\s\S]*?)\n\s*\1\s*\)"?|"((?:[^"\\]|\\.)*)"|'([^']*)')/g;
|
|
211
|
+
|
|
212
|
+
/**
|
|
213
|
+
* First lines (trimmed) of every commit-message argument in a git command.
|
|
214
|
+
* Accepted forms: `-m` / `--message` with a space or `=` before the value;
|
|
215
|
+
* short-flag clusters ending in m (e.g. `-am`, `-qam`), excluding clusters with a
|
|
216
|
+
* value-taking letter (C, c, F, t) before the m, so `-Cm` is not a message flag;
|
|
217
|
+
* a value attached to the flag (`-m"subj"`, `-m'subj'`); and `$(cat <<EOF ... EOF)`
|
|
218
|
+
* heredoc values (first non-empty line).
|
|
219
|
+
* @param {string} command
|
|
220
|
+
* @returns {string[]}
|
|
221
|
+
*/
|
|
222
|
+
function commitMessageSubjects(command) {
|
|
223
|
+
/** @type {string[]} */
|
|
224
|
+
const out = [];
|
|
225
|
+
if (typeof command !== 'string') return out;
|
|
226
|
+
for (const m of command.matchAll(COMMIT_MESSAGE_ARG_RE)) {
|
|
227
|
+
let body = m[2] !== undefined ? m[2] : m[3] !== undefined ? m[3].replace(/\\(.)/g, '$1') : (m[4] || '');
|
|
228
|
+
const first = body.split('\n').map((l) => l.trim()).find((l) => l.length > 0);
|
|
229
|
+
if (first) out.push(first);
|
|
230
|
+
}
|
|
231
|
+
return out;
|
|
232
|
+
}
|
|
233
|
+
|
|
234
|
+
/**
|
|
235
|
+
* SHAs git printed in the tool_result of a Bash call running `git commit`.
|
|
236
|
+
* A CLAIM only — the scheduler must check it against the run's own HEAD range.
|
|
237
|
+
* @param {any[]} events
|
|
238
|
+
* @returns {string[]}
|
|
239
|
+
*/
|
|
240
|
+
function collectCommitOutputShas(events) {
|
|
241
|
+
/** @type {Map<string, string>} */
|
|
242
|
+
const commitCmds = new Map();
|
|
243
|
+
for (const ev of events) {
|
|
244
|
+
if (ev.kind === 'tool_use' && ev.toolName === 'Bash' && ev.toolUseId
|
|
245
|
+
&& typeof ev.command === 'string' && GIT_COMMIT_CMD_RE.test(ev.command)) {
|
|
246
|
+
commitCmds.set(ev.toolUseId, ev.command);
|
|
247
|
+
}
|
|
248
|
+
}
|
|
249
|
+
/** @type {Set<string>} */
|
|
250
|
+
const shas = new Set();
|
|
251
|
+
if (commitCmds.size === 0) return [];
|
|
252
|
+
for (const ev of events) {
|
|
253
|
+
if (ev.kind !== 'tool_result') continue;
|
|
254
|
+
const cmd = commitCmds.get(ev.toolUseId);
|
|
255
|
+
if (cmd === undefined || typeof ev.content !== 'string') continue;
|
|
256
|
+
const subjects = commitMessageSubjects(cmd);
|
|
257
|
+
for (const raw of ev.content.split('\n')) {
|
|
258
|
+
const ln = raw.trim();
|
|
259
|
+
const m1 = COMMIT_SUMMARY_RE.exec(ln);
|
|
260
|
+
if (m1) { shas.add(m1[1].toLowerCase()); continue; }
|
|
261
|
+
const m2 = SHA_SUBJECT_RE.exec(ln);
|
|
262
|
+
if (m2) {
|
|
263
|
+
const subject = m2[2].trim();
|
|
264
|
+
if (subject.length >= 8 && subjects.includes(subject)) shas.add(m2[1].toLowerCase());
|
|
265
|
+
}
|
|
266
|
+
}
|
|
267
|
+
}
|
|
268
|
+
return [...shas];
|
|
196
269
|
}
|
|
197
270
|
|
|
198
271
|
// Stable, narrow substrings of the harness's auto-background tool_result text
|
|
@@ -341,8 +414,9 @@ function scanHaltLine(text) {
|
|
|
341
414
|
}
|
|
342
415
|
|
|
343
416
|
/**
|
|
344
|
-
* One-line reason after `SCHEDULER_VERDICT: FAIL` (same
|
|
345
|
-
* as scanSentinel)
|
|
417
|
+
* One-line reason after `SCHEDULER_VERDICT: FAIL` or `NEEDS_HUMAN` (same
|
|
418
|
+
* two-source scan order as scanSentinel), so it also returns NEEDS_HUMAN
|
|
419
|
+
* reasons. Trimmed, capped at 300 chars; '' when absent.
|
|
346
420
|
*/
|
|
347
421
|
function scanSentinelReason(resultEvent, events) {
|
|
348
422
|
const RE = /^SCHEDULER_VERDICT:\s*(?:FAIL|NEEDS_HUMAN)\b[ \t]*([^\n]*)/m;
|
|
@@ -1059,6 +1133,7 @@ module.exports = {
|
|
|
1059
1133
|
isPolicyDenial,
|
|
1060
1134
|
checkDeps,
|
|
1061
1135
|
parseLog,
|
|
1136
|
+
commitMessageSubjects,
|
|
1062
1137
|
scanSentinel,
|
|
1063
1138
|
scanHaltLine,
|
|
1064
1139
|
scanSentinelReason,
|
|
@@ -473,6 +473,12 @@ function strandedCommitVerdict({ worktreeHead, landedCommit } = {}) {
|
|
|
473
473
|
* main checkout with concurrent jobs, so a HEAD move there may be someone else's
|
|
474
474
|
* integration — credit comes only from this run's own integration result. An
|
|
475
475
|
* in-place run keeps the HEAD-delta / time-window behaviour.
|
|
476
|
+
*
|
|
477
|
+
* `transcriptCommitShas` carries two evidence sources, unioned by the caller:
|
|
478
|
+
* the harness-reported commit shas (parseLog `transcriptCommitShas`) and the
|
|
479
|
+
* shas git printed for the run's own `git commit` call (parseLog
|
|
480
|
+
* `transcriptCommitOutputShas`). Both are claims: credit goes only to a commit
|
|
481
|
+
* inside `rangeCommits` (headBefore..headAtExit).
|
|
476
482
|
*/
|
|
477
483
|
function resolveRunCommitAttribution({
|
|
478
484
|
ranInWorktree, integratedSha, headBefore, headAtExit, committedInWindow,
|
|
@@ -0,0 +1,146 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* planReviewHold.cjs — pure rule deciding which plans need an independent plan
|
|
5
|
+
* review, which pending rows are held 'held: plan-review' until it lands, and
|
|
6
|
+
* which holds have timed out. Shaped like computePreflightHolds so the tick can
|
|
7
|
+
* merge `held` into heldSlugs. No fs: the caller passes queue rows and the
|
|
8
|
+
* stored review records ({ [bareValidateSlug]: record }).
|
|
9
|
+
*
|
|
10
|
+
* Record fields read (all optional): `release` (non-null object, as planReviewStore.recordPlanRelease writes it = released),
|
|
11
|
+
* `firstReviewAt` / `reviews[0].at` (hold start when a review exists).
|
|
12
|
+
* Hold-start fields, in order: review record, then validator row `queuedAt`
|
|
13
|
+
* (stamped at enqueue), `planReviewHeldAt`, `createdAt`.
|
|
14
|
+
*/
|
|
15
|
+
|
|
16
|
+
const { bareSlug } = require('../lib/prd/depSlugResolve.cjs');
|
|
17
|
+
|
|
18
|
+
const DEFAULT_HOLD_MINUTES = 240;
|
|
19
|
+
const REVIEWER_AGENT = 'plan-reviewer';
|
|
20
|
+
|
|
21
|
+
function holdMsFromEnv(env = process.env) {
|
|
22
|
+
const n = Number(env.SM_PLAN_REVIEW_HOLD_MINUTES);
|
|
23
|
+
const minutes = Number.isFinite(n) && n > 0 ? n : DEFAULT_HOLD_MINUTES;
|
|
24
|
+
return minutes * 60 * 1000;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
function planReviewEnabled(env = process.env) {
|
|
28
|
+
return String(env.SM_PLAN_REVIEW ?? '') !== '0';
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
/**
|
|
32
|
+
* Transitive dependsOn walk from a validator row. Same-cwd only (a row with no
|
|
33
|
+
* cwd is kept), bare-slug matching. Excludes the validator and reviewer rows.
|
|
34
|
+
* @param {any} validateRow
|
|
35
|
+
* @param {any[]} rows
|
|
36
|
+
* @returns {any[]}
|
|
37
|
+
*/
|
|
38
|
+
function planMembers(validateRow, rows) {
|
|
39
|
+
if (!validateRow || !Array.isArray(rows)) return [];
|
|
40
|
+
const scoped = rows.filter((r) => r && (!validateRow.cwd || r.cwd == null || r.cwd === validateRow.cwd));
|
|
41
|
+
const byBare = new Map();
|
|
42
|
+
for (const r of scoped) {
|
|
43
|
+
const b = bareSlug(r.slug);
|
|
44
|
+
if (!byBare.has(b)) byBare.set(b, []);
|
|
45
|
+
byBare.get(b).push(r);
|
|
46
|
+
}
|
|
47
|
+
const members = [];
|
|
48
|
+
const seen = new Set();
|
|
49
|
+
const visited = new Set();
|
|
50
|
+
const queue = Array.isArray(validateRow.dependsOn) ? [...validateRow.dependsOn] : [];
|
|
51
|
+
while (queue.length) {
|
|
52
|
+
const dep = bareSlug(queue.shift());
|
|
53
|
+
if (visited.has(dep)) continue;
|
|
54
|
+
visited.add(dep);
|
|
55
|
+
for (const row of byBare.get(dep) ?? []) {
|
|
56
|
+
if (row === validateRow || row.slug === validateRow.slug) continue;
|
|
57
|
+
if (row.agentType === REVIEWER_AGENT || row.agentType === 'validator') continue;
|
|
58
|
+
if (!seen.has(row.slug)) {
|
|
59
|
+
seen.add(row.slug);
|
|
60
|
+
members.push(row);
|
|
61
|
+
}
|
|
62
|
+
for (const d of row.dependsOn ?? []) if (!visited.has(bareSlug(d))) queue.push(d);
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
return members;
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
/** True when >= 3 members, or any member depends on another member. */
|
|
69
|
+
function qualifiesForReview(members) {
|
|
70
|
+
if (!Array.isArray(members)) return false;
|
|
71
|
+
if (members.length >= 3) return true;
|
|
72
|
+
const bares = new Set(members.map((m) => bareSlug(m.slug)));
|
|
73
|
+
return members.some((m) => (m.dependsOn ?? []).some(
|
|
74
|
+
(d) => bares.has(bareSlug(d)) && bareSlug(d) !== bareSlug(m.slug),
|
|
75
|
+
));
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
function isReleased(record) {
|
|
79
|
+
return !!record && record.release != null && typeof record.release === 'object';
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
function holdStartMs(validateRow, record) {
|
|
83
|
+
const candidates = [
|
|
84
|
+
record?.firstReviewAt, record?.reviews?.[0]?.at,
|
|
85
|
+
validateRow?.queuedAt, validateRow?.planReviewHeldAt, validateRow?.createdAt,
|
|
86
|
+
];
|
|
87
|
+
for (const c of candidates) {
|
|
88
|
+
const t = Date.parse(c ?? '');
|
|
89
|
+
if (Number.isFinite(t)) return t;
|
|
90
|
+
}
|
|
91
|
+
return null;
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
/**
|
|
95
|
+
* @param {any[]} rows
|
|
96
|
+
* @param {Record<string, any>} reviewsByValidateSlug keyed by bare validate slug
|
|
97
|
+
* @param {{ now?: number, holdMs?: number }} [opts]
|
|
98
|
+
* @returns {{ held: Map<string, string>, needsReview: string[], expired: string[] }}
|
|
99
|
+
*/
|
|
100
|
+
function computePlanReviewHolds(rows, reviewsByValidateSlug, opts = {}) {
|
|
101
|
+
const now = opts.now ?? Date.now();
|
|
102
|
+
const holdMs = opts.holdMs ?? holdMsFromEnv();
|
|
103
|
+
const held = new Map();
|
|
104
|
+
const needsReview = [];
|
|
105
|
+
const expired = [];
|
|
106
|
+
const reviews = reviewsByValidateSlug || {};
|
|
107
|
+
for (const v of rows || []) {
|
|
108
|
+
if (!v || v.status !== 'pending' || v.agentType !== 'validator' || v.planReview !== 'required') continue;
|
|
109
|
+
const members = planMembers(v, rows);
|
|
110
|
+
if (!qualifiesForReview(members)) continue;
|
|
111
|
+
const record = reviews[bareSlug(v.slug)];
|
|
112
|
+
if (isReleased(record)) continue;
|
|
113
|
+
const hasReview = !!record && (record.firstReviewAt || (Array.isArray(record.reviews) && record.reviews.length > 0));
|
|
114
|
+
if (!hasReview) needsReview.push(v.slug);
|
|
115
|
+
const start = holdStartMs(v, record);
|
|
116
|
+
if (start != null && now - start > holdMs) expired.push(v.slug);
|
|
117
|
+
const reason = `held: plan-review — waiting on independent review of plan ${bareSlug(v.slug)}`;
|
|
118
|
+
for (const m of members) {
|
|
119
|
+
if (m.status === 'pending') held.set(m.slug, reason);
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
return { held, needsReview, expired };
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
const MODEL_FAMILIES = ['opus', 'sonnet', 'haiku', 'fable'];
|
|
126
|
+
function familyOf(model) {
|
|
127
|
+
const m = String(model ?? '').toLowerCase();
|
|
128
|
+
return MODEL_FAMILIES.find((f) => m.includes(f)) || null;
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
/**
|
|
132
|
+
* The reviewer must not share the planner's model family: personaModel is kept
|
|
133
|
+
* unless it matches plannerModel's family, then 'opus' (persona sonnet) else 'sonnet'.
|
|
134
|
+
*/
|
|
135
|
+
function reviewerModelFor(personaModel, plannerModel) {
|
|
136
|
+
const persona = String(personaModel ?? '').trim();
|
|
137
|
+
const pf = familyOf(persona);
|
|
138
|
+
const lf = familyOf(plannerModel);
|
|
139
|
+
if (persona && !(pf && lf && pf === lf)) return persona;
|
|
140
|
+
return pf === 'sonnet' ? 'opus' : 'sonnet';
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
module.exports = {
|
|
144
|
+
reviewerModelFor,
|
|
145
|
+
planMembers, qualifiesForReview, computePlanReviewHolds, holdMsFromEnv, planReviewEnabled,
|
|
146
|
+
};
|
|
@@ -160,6 +160,7 @@ async function parsePrdRaw(filePath) {
|
|
|
160
160
|
// Optional precondition command (preflightCheck.cjs); reconcile copies it
|
|
161
161
|
// onto the queue row so spawnJob can hold the job while it exits non-zero.
|
|
162
162
|
preflight: typeof fm.preflight === 'string' ? parsePreflightValue(rawFrontmatterValue(text, 'preflight')) : null,
|
|
163
|
+
planReview: typeof fm.planReview === 'string' && fm.planReview.trim().toLowerCase() === 'required' ? 'required' : null,
|
|
163
164
|
// Opt-in exclusive-lease flag (PRD 1107, quietMachineLease.cjs +
|
|
164
165
|
// schedulerBatch.cjs's pickNextBatch). Only a literal `true` opts in —
|
|
165
166
|
// matches prdFrontmatter.cjs's applyKey semantics for this field.
|
|
@@ -322,6 +322,14 @@ async function resolveBareSlugFile(slug, cwd) {
|
|
|
322
322
|
* regular `.md` files are read. Never rejects. Returns Map<inputSlug, text>.
|
|
323
323
|
*/
|
|
324
324
|
async function readEpicPrdTexts(cwd, epicId, slugs) {
|
|
325
|
+
const files = await readEpicPrdFiles(cwd, epicId, slugs);
|
|
326
|
+
const out = new Map();
|
|
327
|
+
for (const [k, v] of files) out.set(k, v.text);
|
|
328
|
+
return out;
|
|
329
|
+
}
|
|
330
|
+
|
|
331
|
+
/** Same lookup as readEpicPrdTexts, but Map<inputSlug, { text, path }> so path and text cannot disagree. */
|
|
332
|
+
async function readEpicPrdFiles(cwd, epicId, slugs) {
|
|
325
333
|
const out = new Map();
|
|
326
334
|
try {
|
|
327
335
|
if (typeof cwd !== 'string' || !cwd || !Array.isArray(slugs) || slugs.length === 0) return out;
|
|
@@ -360,7 +368,7 @@ async function readEpicPrdTexts(cwd, epicId, slugs) {
|
|
|
360
368
|
}
|
|
361
369
|
}
|
|
362
370
|
if (!file) continue;
|
|
363
|
-
try { out.set(slug, await fsp.readFile(file, 'utf8')); } catch { /* unreadable — no entry */ }
|
|
371
|
+
try { out.set(slug, { text: await fsp.readFile(file, 'utf8'), path: file }); } catch { /* unreadable — no entry */ }
|
|
364
372
|
}
|
|
365
373
|
} catch { /* never rejects */ }
|
|
366
374
|
return out;
|
|
@@ -622,6 +630,7 @@ module.exports = {
|
|
|
622
630
|
safeSlugPath,
|
|
623
631
|
resolveBareSlugFile,
|
|
624
632
|
readEpicPrdTexts,
|
|
633
|
+
readEpicPrdFiles,
|
|
625
634
|
resolveSlugOrReason,
|
|
626
635
|
jobMatchesSlugAndCwd,
|
|
627
636
|
unknownSlugMessage,
|
|
@@ -942,6 +942,8 @@ function selectAutoFixTargets(jobs, { fixSlugExists, resolveJobRunId = resolveRu
|
|
|
942
942
|
// fix-plan investigation to diagnose — there is no code defect to
|
|
943
943
|
// author a PRD against, only another job's still-uncommitted tree.
|
|
944
944
|
if (job.blockedByForeignWip === true) return false;
|
|
945
|
+
// The job sandbox refused it (environmentLimit): an investigation runs in the same sandbox and hits the same wall.
|
|
946
|
+
if (job.environmentLimit) return false;
|
|
945
947
|
// A budget-killed job parks for a human/ladder decision, never an
|
|
946
948
|
// auto-fix investigation or auto-retry — the run didn't fail, it simply
|
|
947
949
|
// overran its own estimate; there's no code defect to diagnose (Out of
|
|
@@ -48,8 +48,13 @@ function resetMs(resetsAt) {
|
|
|
48
48
|
const DAY_MS = 24 * 60 * 60 * 1000;
|
|
49
49
|
const HOUR_MS = 60 * 60 * 1000;
|
|
50
50
|
|
|
51
|
-
/**
|
|
52
|
-
|
|
51
|
+
/**
|
|
52
|
+
* The pro-rated threshold reaches this in a window's final stretch. 99, not
|
|
53
|
+
* 100: automatic work stops one point short of the account limit so
|
|
54
|
+
* interactive chats keep working until the reset (owner's choice, 2026-11-24).
|
|
55
|
+
* A saved 'pause above' at or above it is returned unchanged.
|
|
56
|
+
*/
|
|
57
|
+
const PRO_RATE_CEILING = 99;
|
|
53
58
|
/** Share of a window left at which the threshold reaches the ceiling (last 2 days of a week). */
|
|
54
59
|
const PRO_RATE_FULL_FRACTION = 2 / 7;
|
|
55
60
|
/** Length of each usage window kind. */
|