claude-code-session-manager 0.143.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/README.md +3 -1
- package/dist/assets/AppSettings-Z68gQiVE.js +2 -0
- package/dist/assets/{History-DTttbvPb.js → History-C3E6y_7t.js} +2 -2
- package/dist/assets/HomeClaudeConfig-Yd1vXzBn.js +5 -0
- package/dist/assets/{Panel-B_D4Bg7L.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-D1b2aiol.js → SkillReferenceGraph-DRtZV1Al.js} +1 -1
- package/dist/assets/{Skills-cfV7sgk6.js → Skills-Bg5O2Hyn.js} +23 -23
- package/dist/assets/{TiptapBody-DVXtEIVy.js → TiptapBody-BdzoBmqu.js} +27 -27
- package/dist/assets/{Toggle-CYajnSdx.js → Toggle-Dt5K1OXt.js} +1 -1
- package/dist/assets/{VoiceButton-DJ4gGRuE.js → VoiceButton-CTLyRgdF.js} +1 -1
- package/dist/assets/{historyTotals-D3MoHY2U.js → historyTotals-B2_KWBga.js} +1 -1
- package/dist/assets/{index-CdTppjKR.js → index-446b69rr.js} +698 -697
- 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 +439 -436
- package/package.json +4 -2
- package/plugins/session-manager-dev/skills/develop/SKILL.md +14 -13
- 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 -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 +109 -0
- package/src/main/health.cjs +59 -17
- package/src/main/index.cjs +4 -0
- package/src/main/ipcSchemas.cjs +50 -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/epic/epicDepsSync.cjs +66 -0
- 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/epicValidationHook.cjs +9 -1
- 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 +12 -0
- 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/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 +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 +1 -1
- package/src/main/lib/git/worktreeDeps.cjs +9 -3
- package/src/main/lib/mcpToolCatalog.cjs +43 -5
- package/src/main/lib/mcpToolsProbe.cjs +19 -2
- 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 +48 -5
- 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/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 +128 -0
- 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 +109 -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 +178 -0
- package/src/main/projectPages.cjs +22 -14
- package/src/main/pty.cjs +3 -0
- package/src/main/runVerify.cjs +3 -2
- 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 +7 -2
- package/src/main/scheduler.cjs +532 -78
- package/src/main/seedAgentPersonas.cjs +11 -6
- package/src/main/seedStatus.cjs +1 -1
- package/src/main/templates/PRD_AUTHORING.md +16 -1
- package/src/main/webRemote.cjs +47 -7
- package/src/preload/api.d.ts +71 -1
- package/src/preload/apiSurface.json +28 -0
- package/src/preload/index.cjs +9 -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
|
@@ -116,7 +116,7 @@ const BUILTIN_ENVIRONMENTS = deepFreeze({
|
|
|
116
116
|
osSandboxRequired: true,
|
|
117
117
|
permissionMode: 'acceptEdits',
|
|
118
118
|
writeRoots: [...JOB_WRITE_ROOTS],
|
|
119
|
-
network: { mode: 'allowlist', hosts: ['registry.npmjs.org'] },
|
|
119
|
+
network: { mode: 'allowlist', hosts: ['registry.npmjs.org', 'api.github.com'] },
|
|
120
120
|
secretDenyPaths: [...SANDBOX_SECRET_PATHS],
|
|
121
121
|
webFetch: false,
|
|
122
122
|
webSearch: false,
|
|
@@ -0,0 +1,138 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
// The one map of MCP server definitions a headless job, Task or geared chat
|
|
4
|
+
// turn may load. Reads the same scopes the CLI does (user < project < local)
|
|
5
|
+
// and refuses credential-bearing entries so no secret reaches a job's argv.
|
|
6
|
+
|
|
7
|
+
const fs = require('node:fs');
|
|
8
|
+
const os = require('node:os');
|
|
9
|
+
const path = require('node:path');
|
|
10
|
+
const seed = require('../../seedSchedulerMcp.cjs');
|
|
11
|
+
const { SECRET_KEY_RE } = require('../process/cleanEnv.cjs');
|
|
12
|
+
|
|
13
|
+
const has = (o, k) => Object.prototype.hasOwnProperty.call(o, k);
|
|
14
|
+
const isPlain = (v) => !!v && typeof v === 'object' && !Array.isArray(v);
|
|
15
|
+
|
|
16
|
+
function readJson(file) {
|
|
17
|
+
try {
|
|
18
|
+
const parsed = JSON.parse(fs.readFileSync(file, 'utf8'));
|
|
19
|
+
return isPlain(parsed) ? parsed : null;
|
|
20
|
+
} catch {
|
|
21
|
+
return null;
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
/** Plain-object entries of a plain-object mcpServers map; else {}. */
|
|
26
|
+
function serversOf(map) {
|
|
27
|
+
const out = {};
|
|
28
|
+
if (!isPlain(map)) return out;
|
|
29
|
+
for (const name of Object.keys(map)) {
|
|
30
|
+
if (has(map, name) && isPlain(map[name])) out[name] = map[name];
|
|
31
|
+
}
|
|
32
|
+
return out;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
const SECRET_FLAG_RE = /^--(api-key|apikey|token|access-token|secret|password|auth|pat)(=|$)/i;
|
|
36
|
+
const EXTRA_KEY_RE = /(^|_)(PAT|CREDENTIALS?|PRIVATE_KEY)$/i;
|
|
37
|
+
const QUERY_KEY_RE = /(token|key|secret|password|sig|signature|auth)/i;
|
|
38
|
+
const USERINFO_RE = /[a-z][a-z0-9+.-]*:\/\/[^/\s:@]+:[^/\s@]*@/i;
|
|
39
|
+
const HINT = 'move the secret to a vault ref (environment profile) or run it outside the job';
|
|
40
|
+
|
|
41
|
+
function secretKey(key) {
|
|
42
|
+
return SECRET_KEY_RE.test(key) || EXTRA_KEY_RE.test(key) || /authorization/i.test(key);
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
function argsReason(name, args) {
|
|
46
|
+
if (!Array.isArray(args)) return null;
|
|
47
|
+
for (let i = 0; i < args.length; i++) {
|
|
48
|
+
const a = args[i];
|
|
49
|
+
if (typeof a !== 'string') continue;
|
|
50
|
+
const m = SECRET_FLAG_RE.exec(a);
|
|
51
|
+
if (m) {
|
|
52
|
+
const flag = `--${m[1].toLowerCase()}`;
|
|
53
|
+
if (m[2] === '=' || i + 1 < args.length) {
|
|
54
|
+
return `${name} carries secret flag ${flag} in its args; ${HINT}`;
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
if (USERINFO_RE.test(a)) {
|
|
58
|
+
return `${name} carries URL userinfo in its args; ${HINT}`;
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
return null;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
function urlReason(name, url) {
|
|
65
|
+
if (typeof url !== 'string') return null;
|
|
66
|
+
if (USERINFO_RE.test(url)) return `${name} carries URL userinfo in its url; ${HINT}`;
|
|
67
|
+
let parsed;
|
|
68
|
+
try {
|
|
69
|
+
parsed = new URL(url);
|
|
70
|
+
} catch {
|
|
71
|
+
return null;
|
|
72
|
+
}
|
|
73
|
+
if (parsed.username || parsed.password) return `${name} carries URL userinfo in its url; ${HINT}`;
|
|
74
|
+
for (const key of parsed.searchParams.keys()) {
|
|
75
|
+
if (QUERY_KEY_RE.test(key)) return `${name} carries credential query key ${key} in its url; ${HINT}`;
|
|
76
|
+
}
|
|
77
|
+
return null;
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
function credentialReason(name, entry) {
|
|
81
|
+
for (const field of ['env', 'headers']) {
|
|
82
|
+
const obj = entry[field];
|
|
83
|
+
if (!isPlain(obj)) continue;
|
|
84
|
+
for (const key of Object.keys(obj)) {
|
|
85
|
+
if (secretKey(key)) {
|
|
86
|
+
return `${name} carries credential key ${key} in its ${field}; ${HINT}`;
|
|
87
|
+
}
|
|
88
|
+
if (typeof obj[key] === 'string' && USERINFO_RE.test(obj[key])) {
|
|
89
|
+
return `${name} carries URL userinfo in ${field} value ${key}; ${HINT}`;
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
return argsReason(name, entry.args) || urlReason(name, entry.url);
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
/**
|
|
97
|
+
* @param {{ cwd?: string, projectRoot?: string, home?: string }} [opts]
|
|
98
|
+
* @returns {{ known: Record<string, object>, credentialed: Record<string, string> }}
|
|
99
|
+
*/
|
|
100
|
+
function resolveHeadlessMcpServers({ cwd, projectRoot, home = os.homedir() } = {}) {
|
|
101
|
+
/** @type {Record<string, any>} */
|
|
102
|
+
const merged = {};
|
|
103
|
+
try {
|
|
104
|
+
const absCwd = typeof cwd === 'string' && path.isAbsolute(cwd);
|
|
105
|
+
const userCfg = readJson(path.join(home, '.claude.json'));
|
|
106
|
+
Object.assign(merged, serversOf(userCfg && userCfg.mcpServers));
|
|
107
|
+
if (absCwd) {
|
|
108
|
+
const proj = readJson(path.join(cwd, '.mcp.json'));
|
|
109
|
+
Object.assign(merged, serversOf(proj && proj.mcpServers));
|
|
110
|
+
const projects = userCfg && userCfg.projects;
|
|
111
|
+
const scopes = [];
|
|
112
|
+
if (typeof projectRoot === 'string' && path.isAbsolute(projectRoot) && projectRoot !== cwd) scopes.push(projectRoot);
|
|
113
|
+
scopes.push(cwd);
|
|
114
|
+
for (const key of scopes) {
|
|
115
|
+
if (isPlain(projects) && has(projects, key) && isPlain(projects[key])) {
|
|
116
|
+
Object.assign(merged, serversOf(projects[key].mcpServers));
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
} catch {
|
|
121
|
+
/* contribute nothing */
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
/** @type {Record<string, object>} */
|
|
125
|
+
const known = {};
|
|
126
|
+
/** @type {Record<string, string>} */
|
|
127
|
+
const credentialed = {};
|
|
128
|
+
for (const name of Object.keys(merged)) {
|
|
129
|
+
const reason = credentialReason(name, merged[name]);
|
|
130
|
+
if (reason) credentialed[name] = reason;
|
|
131
|
+
else known[name] = merged[name];
|
|
132
|
+
}
|
|
133
|
+
known[seed.SERVER_NAME] = seed.schedulerServerEntry();
|
|
134
|
+
delete credentialed[seed.SERVER_NAME];
|
|
135
|
+
return { known, credentialed };
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
module.exports = { resolveHeadlessMcpServers };
|
|
@@ -383,7 +383,8 @@ function wouldBlockRecord({ slug, persona, environment, what, detail, mode }) {
|
|
|
383
383
|
/**
|
|
384
384
|
* Env vars a job's child process needs for its sandbox level. An os-sandbox
|
|
385
385
|
* job gets TMPDIR/TMP/TEMP pointed at its private temp dir (the only tmp
|
|
386
|
-
* write root its settings declare)
|
|
386
|
+
* write root its settings declare) and, with an allowlist network,
|
|
387
|
+
* NODE_USE_ENV_PROXY=1; tool-rules jobs get no env change.
|
|
387
388
|
*
|
|
388
389
|
* @param {{ level?: string }|null|undefined} policy
|
|
389
390
|
* @param {string} tmpDir
|
|
@@ -391,7 +392,12 @@ function wouldBlockRecord({ slug, persona, environment, what, detail, mode }) {
|
|
|
391
392
|
*/
|
|
392
393
|
function sandboxChildEnv(policy, tmpDir) {
|
|
393
394
|
if (!policy || policy.level !== 'os-sandbox') return {};
|
|
394
|
-
|
|
395
|
+
const env = { TMPDIR: tmpDir, TMP: tmpDir, TEMP: tmpDir };
|
|
396
|
+
// Node's https ignores HTTPS_PROXY unless asked; inside the sandbox the proxy
|
|
397
|
+
// is the only route to an allow-listed host.
|
|
398
|
+
const hosts = policy.summary && policy.summary.network;
|
|
399
|
+
if (Array.isArray(hosts) && hosts.length > 0) env.NODE_USE_ENV_PROXY = '1';
|
|
400
|
+
return env;
|
|
395
401
|
}
|
|
396
402
|
|
|
397
403
|
module.exports = {
|
|
@@ -31,23 +31,29 @@ const HEADLESS_SCOPE_AGENT_NAME = 'sm-headless-scoped';
|
|
|
31
31
|
|
|
32
32
|
/**
|
|
33
33
|
* @param {readonly string[]|null|undefined} tools persona `tools:` list
|
|
34
|
-
* @param {{ disallowed?: readonly string[], structuredOutput?: boolean }} [opts]
|
|
34
|
+
* @param {{ loadout?: 'undecided'|'bare'|'equipped'|'unbound', disallowed?: readonly string[], structuredOutput?: boolean }} [opts]
|
|
35
35
|
* structuredOutput: also grant the CLI's StructuredOutput tool (a --json-schema
|
|
36
36
|
* run). Probe 2026-11-22 (CLI 2.1.325): a scoped run without it ends
|
|
37
37
|
* 'success' with structured_output null — the schema is silently skipped.
|
|
38
38
|
* @returns {{ tools: string[] }|null} null = persona declares no restriction
|
|
39
39
|
*/
|
|
40
|
-
function buildPersonaToolScope(tools, { disallowed = [], structuredOutput = false } = {}) {
|
|
41
|
-
|
|
42
|
-
|
|
40
|
+
function buildPersonaToolScope(tools, { loadout, disallowed = [], structuredOutput = false } = {}) {
|
|
41
|
+
// `loadout` (personaLoadout.cjs) wins when given: Bare = floor only even for
|
|
42
|
+
// an empty list; Unbound/Undecided = unscoped.
|
|
43
|
+
if (loadout === 'unbound' || loadout === 'undecided') return null;
|
|
44
|
+
const bare = loadout === 'bare';
|
|
45
|
+
const list = Array.isArray(tools) ? tools : [];
|
|
46
|
+
if (!bare && list.length === 0) return null;
|
|
47
|
+
const names = list
|
|
43
48
|
.filter((t) => typeof t === 'string')
|
|
44
49
|
.map((t) => t.trim())
|
|
45
50
|
.filter(Boolean);
|
|
46
|
-
if (names.
|
|
51
|
+
if (names.includes('*')) return null;
|
|
52
|
+
if (!bare && names.length === 0) return null;
|
|
47
53
|
const blocked = new Set(disallowed);
|
|
48
54
|
const out = [];
|
|
49
55
|
const extra = structuredOutput === true ? ['StructuredOutput'] : [];
|
|
50
|
-
for (const name of [...names, ...HEADLESS_TOOL_FLOOR, ...extra]) {
|
|
56
|
+
for (const name of [...(bare ? [] : names), ...HEADLESS_TOOL_FLOOR, ...extra]) {
|
|
51
57
|
if (blocked.has(name) || out.includes(name)) continue;
|
|
52
58
|
out.push(name);
|
|
53
59
|
}
|
|
@@ -158,12 +164,77 @@ function personaToolScopeEnv(scope) {
|
|
|
158
164
|
return { [JOB_MCP_TOOLS_ENV]: JSON.stringify(mcp) };
|
|
159
165
|
}
|
|
160
166
|
|
|
167
|
+
/**
|
|
168
|
+
* The `--disallowedTools=Skill(<name>)` argv that refuses every installed
|
|
169
|
+
* skill a persona's equipped packs do not carry. Skills ride only inside packs.
|
|
170
|
+
* Verified on CLI 2.1.330: a denied Skill call fails with 'Skill execution
|
|
171
|
+
* blocked by permission rules'. Always the --flag=value form (only the first
|
|
172
|
+
* value after a variadic flag is literal). Pure: the caller passes the catalog.
|
|
173
|
+
*
|
|
174
|
+
* Unbound/undecided loadouts deny nothing; Bare ignores equipped packs. CLI-bundled
|
|
175
|
+
* skills follow the built-in tool decision and are never denied; `alwaysAllowed`
|
|
176
|
+
* (finish protocol: code-review, security-review) never are either.
|
|
177
|
+
*
|
|
178
|
+
* @param {{ installedSkills?: readonly string[], equippedPacks?: readonly string[],
|
|
179
|
+
* packCatalog?: readonly { id: string, skills?: readonly string[] }[],
|
|
180
|
+
* bundledSkills?: readonly string[], loadout?: string,
|
|
181
|
+
* alwaysAllowed?: readonly string[] }} [opts]
|
|
182
|
+
* @returns {string[]}
|
|
183
|
+
*/
|
|
184
|
+
function skillDenyArgs({
|
|
185
|
+
installedSkills = [], equippedPacks = [], packCatalog = [], bundledSkills = [],
|
|
186
|
+
loadout, alwaysAllowed = ['code-review', 'security-review'],
|
|
187
|
+
} = {}) {
|
|
188
|
+
if (loadout === 'unbound' || loadout === 'undecided') return [];
|
|
189
|
+
const allowed = new Set([...bundledSkills, ...alwaysAllowed].map(String));
|
|
190
|
+
if (loadout !== 'bare') {
|
|
191
|
+
const equipped = new Set(equippedPacks.map(String));
|
|
192
|
+
for (const pack of packCatalog) {
|
|
193
|
+
if (!pack || !equipped.has(String(pack.id))) continue;
|
|
194
|
+
for (const s of pack.skills || []) allowed.add(String(s));
|
|
195
|
+
}
|
|
196
|
+
}
|
|
197
|
+
const out = [];
|
|
198
|
+
for (const raw of installedSkills) {
|
|
199
|
+
const name = String(raw).trim();
|
|
200
|
+
if (!name || allowed.has(name) || out.includes(`--disallowedTools=Skill(${name})`)) continue;
|
|
201
|
+
out.push(`--disallowedTools=Skill(${name})`);
|
|
202
|
+
}
|
|
203
|
+
return out;
|
|
204
|
+
}
|
|
205
|
+
|
|
206
|
+
/**
|
|
207
|
+
* The skill-deny argv for one unattended spawn (job or Task): the real catalogs
|
|
208
|
+
* (packs, loose skills, CLI-bundled skills) fed to skillDenyArgs. Never throws;
|
|
209
|
+
* a catalog failure denies nothing (same as an unbound loadout).
|
|
210
|
+
* @param {{ packs?: readonly string[], loadout?: string|null, deps?: Record<string, any> }} [o]
|
|
211
|
+
* @returns {Promise<{ args: string[], denied: number }>}
|
|
212
|
+
*/
|
|
213
|
+
async function resolveSkillDeny({ packs = [], loadout, deps } = {}) {
|
|
214
|
+
const d = deps || {};
|
|
215
|
+
try {
|
|
216
|
+
if (!loadout) return { args: [], denied: 0 };
|
|
217
|
+
const catalog = require('../packs/packCatalog.cjs');
|
|
218
|
+
const packCatalog = (d.listPacks || catalog.listPacks)().packs || [];
|
|
219
|
+
const unpacked = [...(d.listUnpackedSkills || catalog.listUnpackedSkills)()];
|
|
220
|
+
const builtin = await (d.getBuiltinTools || require('./builtinTools.cjs').getBuiltinTools)();
|
|
221
|
+
const bundledSkills = (builtin && builtin.skills) || [];
|
|
222
|
+
const installedSkills = [...new Set([...packCatalog.flatMap((p) => p.skills || []), ...unpacked])];
|
|
223
|
+
const args = skillDenyArgs({ installedSkills, equippedPacks: packs, packCatalog, bundledSkills, loadout });
|
|
224
|
+
return { args, denied: args.length };
|
|
225
|
+
} catch {
|
|
226
|
+
return { args: [], denied: 0 };
|
|
227
|
+
}
|
|
228
|
+
}
|
|
229
|
+
|
|
161
230
|
module.exports = {
|
|
231
|
+
resolveSkillDeny,
|
|
162
232
|
JOB_MCP_TOOLS_ENV,
|
|
163
233
|
personaToolScopeEnv,
|
|
164
234
|
HEADLESS_TOOL_FLOOR,
|
|
165
235
|
HEADLESS_SCOPE_AGENT_NAME,
|
|
166
236
|
buildPersonaToolScope,
|
|
237
|
+
skillDenyArgs,
|
|
167
238
|
personaToolScopeArgs,
|
|
168
239
|
resolvedMcpServerNames,
|
|
169
240
|
};
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* epicDepsSync.cjs — refresh an Epic worktree's per-entry node_modules links each
|
|
3
|
+
* time its CLI is spawned there (Chat: chatRunner executeRun; Terminal: pty spawn).
|
|
4
|
+
*
|
|
5
|
+
* Why: syncNodeModulesLinks otherwise runs only when createWorktree reuses the
|
|
6
|
+
* worktree (approve / reopen), so a long-lived Epic never sees a package added to
|
|
7
|
+
* the main checkout later. Both spawn paths are synchronous, so this is
|
|
8
|
+
* fire-and-forget: the sync runs on a later tick and its result is never awaited.
|
|
9
|
+
* Throttled to once per worktree per THROTTLE_MS so rapid turns don't rescan.
|
|
10
|
+
* Never throws; failures are logged.
|
|
11
|
+
*/
|
|
12
|
+
'use strict';
|
|
13
|
+
|
|
14
|
+
const worktreeDeps = require('../git/worktreeDeps.cjs');
|
|
15
|
+
|
|
16
|
+
const THROTTLE_MS = 30_000;
|
|
17
|
+
|
|
18
|
+
/** @type {Map<string, number>} worktreeCwd → last sync start (ms) */
|
|
19
|
+
const lastSyncAt = new Map();
|
|
20
|
+
|
|
21
|
+
function logFailure(worktreeCwd, err) {
|
|
22
|
+
try {
|
|
23
|
+
require('../../logs.cjs').writeLine({
|
|
24
|
+
scope: 'epicDepsSync',
|
|
25
|
+
level: 'warn',
|
|
26
|
+
message: `node_modules link sync failed for ${worktreeCwd}: ${err?.message || String(err)}`,
|
|
27
|
+
meta: { worktreeCwd },
|
|
28
|
+
});
|
|
29
|
+
} catch {
|
|
30
|
+
try { console.warn(`[epicDepsSync] sync failed for ${worktreeCwd}:`, err?.message || err); } catch { /* never throw */ }
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
/**
|
|
35
|
+
* Fire-and-forget refresh of a worktree's node_modules links from the project checkout.
|
|
36
|
+
* @param {{ projectCwd: string, worktreeCwd: string, now?: number }} opts
|
|
37
|
+
* @returns {boolean} true when a sync was scheduled
|
|
38
|
+
*/
|
|
39
|
+
function syncEpicWorktreeDeps({ projectCwd, worktreeCwd, now } = /** @type {any} */ ({})) {
|
|
40
|
+
try {
|
|
41
|
+
if (process.env.SM_WORKTREE_DEP_LINK_DISABLE === '1') return false;
|
|
42
|
+
if (!projectCwd || !worktreeCwd || worktreeCwd === projectCwd) return false;
|
|
43
|
+
const t = typeof now === 'number' ? now : Date.now();
|
|
44
|
+
const prev = lastSyncAt.get(worktreeCwd);
|
|
45
|
+
if (prev !== undefined && t - prev < THROTTLE_MS) return false;
|
|
46
|
+
lastSyncAt.set(worktreeCwd, t);
|
|
47
|
+
setImmediate(() => {
|
|
48
|
+
let p;
|
|
49
|
+
try {
|
|
50
|
+
p = worktreeDeps.syncNodeModulesLinks({ mainCwd: projectCwd, worktreeCwd });
|
|
51
|
+
} catch (e) {
|
|
52
|
+
logFailure(worktreeCwd, e);
|
|
53
|
+
return;
|
|
54
|
+
}
|
|
55
|
+
Promise.resolve(p).catch((e) => logFailure(worktreeCwd, e));
|
|
56
|
+
});
|
|
57
|
+
return true;
|
|
58
|
+
} catch (e) {
|
|
59
|
+
logFailure(worktreeCwd, e);
|
|
60
|
+
return false;
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
function __resetForTests() { lastSyncAt.clear(); }
|
|
65
|
+
|
|
66
|
+
module.exports = { syncEpicWorktreeDeps, THROTTLE_MS, __resetForTests };
|
|
@@ -25,12 +25,16 @@ const { readArchived, defaultProjectRoots, makeRegisteredRootsCache } = require(
|
|
|
25
25
|
const { gatherEpicJobReceipt } = require('./epicJobReceipt.cjs');
|
|
26
26
|
const { summarizeTranscriptFile } = require('./transcriptUsage.cjs');
|
|
27
27
|
const { resolveEpicTranscriptPath } = require('./epicTranscriptPath.cjs');
|
|
28
|
+
const { StartedBySchema } = require('./scriptStartedBy.cjs');
|
|
28
29
|
const { isSafeEpicId } = require('../prd/prdLocations.cjs');
|
|
29
30
|
const fs = require('node:fs');
|
|
30
31
|
const { opsPath } = require('../opsOwnership.cjs');
|
|
31
32
|
const { readJsonOrSync } = require('../util/atomicFs.cjs');
|
|
32
33
|
const { parseValidatorVerdict } = require('../scheduler/validatorVerdictSchema.cjs');
|
|
33
34
|
const { bareSlug } = require('../prd/depSlugResolve.cjs');
|
|
35
|
+
const { readPlanReviewFiles } = require('../scheduler/planReviewStore.cjs');
|
|
36
|
+
const { splitFrontmatter, parseFixes } = require('../prd/prdFrontmatter.cjs');
|
|
37
|
+
const { planReviewStats } = require('../scheduler/planReviewStats.cjs');
|
|
34
38
|
|
|
35
39
|
const DEFAULT_LIMIT = 50;
|
|
36
40
|
const MAX_LIMIT = 200;
|
|
@@ -207,10 +211,40 @@ function readVerdictFiles(cwd, epicId) {
|
|
|
207
211
|
}
|
|
208
212
|
}
|
|
209
213
|
|
|
214
|
+
/** Re-sanitize a stored startedBy; anything invalid or absent reads as null (a person pressed it). */
|
|
215
|
+
function startedByOf(raw) {
|
|
216
|
+
if (raw == null) return null;
|
|
217
|
+
const r = StartedBySchema.safeParse(raw);
|
|
218
|
+
return r.success ? r.data : null;
|
|
219
|
+
}
|
|
220
|
+
|
|
221
|
+
/** fixes[] ({ prd, missKind }) from this Epic's PRD files (prds/ and prds-archived/); [] on any failure. */
|
|
222
|
+
function readEpicFixes(cwd, epicId) {
|
|
223
|
+
const out = [];
|
|
224
|
+
try {
|
|
225
|
+
if (!isSafeEpicId(epicId)) return out;
|
|
226
|
+
const base = path.join(opsPath(cwd, 'scheduler', 'epics'), epicId);
|
|
227
|
+
for (const sub of ['prds', 'prds-archived']) {
|
|
228
|
+
let names;
|
|
229
|
+
try { names = fs.readdirSync(path.join(base, sub)); } catch { continue; }
|
|
230
|
+
for (const n of names.filter((x) => x.endsWith('.md')).sort()) {
|
|
231
|
+
try {
|
|
232
|
+
const { fm } = splitFrontmatter(fs.readFileSync(path.join(base, sub, n), 'utf8'));
|
|
233
|
+
const list = typeof fm.fixes === 'string' ? parseFixes(fm.fixes) : null;
|
|
234
|
+
for (const f of list || []) out.push({ prd: f.prd, missKind: f.missKind });
|
|
235
|
+
} catch { /* skip unreadable PRD */ }
|
|
236
|
+
}
|
|
237
|
+
}
|
|
238
|
+
} catch { /* none */ }
|
|
239
|
+
return out;
|
|
240
|
+
}
|
|
241
|
+
|
|
210
242
|
function buildRecord(cwd, epicId, session, events, jobs, needsInput, chatBusy) {
|
|
211
243
|
const computed = computeEpicOutsideState({ session: { ...session, id: epicId }, events, jobs, needsInput, chatBusy });
|
|
212
244
|
const source = isObj(session.source) ? session.source : {};
|
|
213
245
|
const { title, goal } = splitGoal(session.goalText);
|
|
246
|
+
const verdicts = readVerdictFiles(cwd, epicId);
|
|
247
|
+
const planReviews = readPlanReviewFiles(cwd, epicId);
|
|
214
248
|
return {
|
|
215
249
|
epicId,
|
|
216
250
|
cwd: str(session.cwd) || cwd,
|
|
@@ -232,10 +266,13 @@ function buildRecord(cwd, epicId, session, events, jobs, needsInput, chatBusy) {
|
|
|
232
266
|
fromCwd: str(source.fromCwd),
|
|
233
267
|
fromEpicId: str(source.fromEpicId),
|
|
234
268
|
macroId: str(source.macroId),
|
|
269
|
+
startedBy: startedByOf(source.startedBy),
|
|
235
270
|
},
|
|
236
271
|
createdAt: str(session.createdAt),
|
|
237
272
|
completedAt: str(session.completedAt),
|
|
238
|
-
verdicts
|
|
273
|
+
verdicts,
|
|
274
|
+
planReviews,
|
|
275
|
+
planReviewStats: planReviewStats({ planReviews, verdictFiles: verdicts, fixes: readEpicFixes(cwd, epicId) }),
|
|
239
276
|
};
|
|
240
277
|
}
|
|
241
278
|
|
|
@@ -4,7 +4,8 @@
|
|
|
4
4
|
* epicSettle.cjs — pure settle evaluator for one Epic.
|
|
5
5
|
*
|
|
6
6
|
* Given the Epic's event chain and the scheduler queue rows, says whether the
|
|
7
|
-
* Epic has settled (no
|
|
7
|
+
* Epic has settled (no running PRD, and no pending PRD other than ones held
|
|
8
|
+
* on a preflight precondition or waiting only on such held rows) and which finished PRDs no
|
|
8
9
|
* validator has checked yet. No fs; only the pure lib/scheduler/cancelledRow
|
|
9
10
|
* predicate, never the scheduler itself.
|
|
10
11
|
*/
|
|
@@ -35,7 +36,50 @@ function evaluateEpicSettle({ epicId, cwd, events, jobs, now, horizonMs } = {})
|
|
|
35
36
|
const epicRows = rows.filter(
|
|
36
37
|
(r) => r && (r.epicId === epicId || r.sourcePromptId === epicId) && (r.cwd == null || cwd == null || r.cwd === cwd),
|
|
37
38
|
);
|
|
38
|
-
|
|
39
|
+
// A pending row is held when its preflight parked it, or when every one of its
|
|
40
|
+
// unfinished dependencies is itself held. Held rows run on their own later, so
|
|
41
|
+
// they do not hold back the settle digest; the digest names them instead.
|
|
42
|
+
const byBare = new Map();
|
|
43
|
+
for (const r of epicRows) if (r && r.slug != null) byBare.set(bareSlug(String(r.slug)), r);
|
|
44
|
+
const isFinished = (r) => r.status === 'completed' || r.status === 'skipped';
|
|
45
|
+
const heldMemo = new Map(); // row -> reason string | null
|
|
46
|
+
/** @returns {string|null} the held reason, or null when the row is not held */
|
|
47
|
+
const heldReasonOf = (row, seen) => {
|
|
48
|
+
if (!row || row.status !== 'pending') return null;
|
|
49
|
+
if (heldMemo.has(row)) return heldMemo.get(row);
|
|
50
|
+
if (row.preflightHold || (typeof row.heldReason === 'string' && row.heldReason.startsWith('held: plan-review'))) {
|
|
51
|
+
const reason = typeof row.heldReason === 'string' && row.heldReason ? row.heldReason : 'waiting on precondition';
|
|
52
|
+
heldMemo.set(row, reason);
|
|
53
|
+
return reason;
|
|
54
|
+
}
|
|
55
|
+
if (seen.has(row)) return null;
|
|
56
|
+
seen.add(row);
|
|
57
|
+
const deps = Array.isArray(row.dependsOn) ? row.dependsOn : [];
|
|
58
|
+
let firstHeld = null;
|
|
59
|
+
let result = null;
|
|
60
|
+
let anyUnfinished = false;
|
|
61
|
+
let allHeld = true;
|
|
62
|
+
for (const d of deps) {
|
|
63
|
+
const dep = byBare.get(bareSlug(String(d)));
|
|
64
|
+
if (!dep || isFinished(dep)) continue;
|
|
65
|
+
anyUnfinished = true;
|
|
66
|
+
if (heldReasonOf(dep, seen) == null) { allHeld = false; break; }
|
|
67
|
+
if (firstHeld == null) firstHeld = String(dep.slug);
|
|
68
|
+
}
|
|
69
|
+
if (anyUnfinished && allHeld) result = `waiting on ${firstHeld}`;
|
|
70
|
+
seen.delete(row);
|
|
71
|
+
heldMemo.set(row, result);
|
|
72
|
+
return result;
|
|
73
|
+
};
|
|
74
|
+
const held = epicRows
|
|
75
|
+
.filter((r) => r.status === 'pending')
|
|
76
|
+
.map((r) => ({ slug: String(r.slug), reason: heldReasonOf(r, new Set()) }))
|
|
77
|
+
.filter((h) => h.reason != null)
|
|
78
|
+
.sort((a, b) => (a.slug < b.slug ? -1 : a.slug > b.slug ? 1 : 0));
|
|
79
|
+
const heldSet = new Set(held.map((h) => h.slug));
|
|
80
|
+
const settled = !epicRows.some(
|
|
81
|
+
(r) => r.status === 'running' || (r.status === 'pending' && !heldSet.has(String(r.slug))),
|
|
82
|
+
);
|
|
39
83
|
const cancelled = epicRows
|
|
40
84
|
.filter(isCancelledRow)
|
|
41
85
|
.map((r) => String(r.slug))
|
|
@@ -101,12 +145,12 @@ function evaluateEpicSettle({ epicId, cwd, events, jobs, now, horizonMs } = {})
|
|
|
101
145
|
failed.sort();
|
|
102
146
|
|
|
103
147
|
const digestKey = createHash('sha1')
|
|
104
|
-
.update(JSON.stringify({ verified, refuted, failed, parked, cancelled, uncovered: uncovered.map((u) => u.slug) }))
|
|
148
|
+
.update(JSON.stringify({ verified, refuted, failed, parked, cancelled, uncovered: uncovered.map((u) => u.slug), held: held.map((h) => h.slug) }))
|
|
105
149
|
.digest('hex')
|
|
106
150
|
.slice(0, 16);
|
|
107
151
|
const hasContent = [uncovered, verified, refuted, failed, parked, cancelled].some((l) => l.length > 0);
|
|
108
152
|
|
|
109
|
-
return { settled, uncovered, verified, refuted, failed, parked, cancelled, digestKey, hasContent };
|
|
153
|
+
return { settled, held, uncovered, verified, refuted, failed, parked, cancelled, digestKey, hasContent };
|
|
110
154
|
}
|
|
111
155
|
|
|
112
156
|
module.exports = { evaluateEpicSettle, DEFAULT_SETTLE_HORIZON_MS };
|
|
@@ -47,7 +47,7 @@ const { isNonClaudeAgentCli } = require('../agent-cli/agentCliEvents.cjs');
|
|
|
47
47
|
|
|
48
48
|
/**
|
|
49
49
|
* The persona (body + model) this turn runs with — see the header's "Persona pin".
|
|
50
|
-
* @returns {{ source: 'snapshot'|'live', agentSnapshotId: string|null, body: string|null, model: string, snapshotMissing?: true } | null}
|
|
50
|
+
* @returns {{ source: 'snapshot'|'live', agentSnapshotId: string|null, body: string|null, model: string, snapshot?: any, snapshotMissing?: true } | null}
|
|
51
51
|
*/
|
|
52
52
|
function resolveTurnPersona(cwd, claudeSessionId, epic, deps) {
|
|
53
53
|
if (epic && isNonClaudeAgentCli(epic.agentCli)) return null;
|
|
@@ -70,6 +70,8 @@ function resolveTurnPersona(cwd, claudeSessionId, epic, deps) {
|
|
|
70
70
|
agentSnapshotId: id,
|
|
71
71
|
body: typeof snap.body === 'string' && snap.body ? snap.body : null,
|
|
72
72
|
model: model || modelResolve.FALLBACK_MODEL,
|
|
73
|
+
// The pinned snapshot itself: chatRunner reads gearBindsChat/loadout/tools/mcpServers/packs from it.
|
|
74
|
+
snapshot: snap,
|
|
73
75
|
};
|
|
74
76
|
}
|
|
75
77
|
|
|
@@ -143,8 +143,16 @@ function buildSettledDigest(settle, { epicId, notValidatedReason, cwd, findings
|
|
|
143
143
|
const parked = s.parked || [];
|
|
144
144
|
const cancelled = s.cancelled || [];
|
|
145
145
|
const notValidated = (s.uncovered || []).map((u) => (typeof u === 'string' ? u : u.slug));
|
|
146
|
+
const held = Array.isArray(s.held) ? s.held : [];
|
|
147
|
+
const head = held.length
|
|
148
|
+
? [
|
|
149
|
+
`PLAN SETTLED — nothing of this session is running; ${held.length} PRD(s) are held on a precondition and will run on their own:`,
|
|
150
|
+
...held.map((h) => `- ${h.slug}${h.reason ? ` — ${h.reason}` : ''}`),
|
|
151
|
+
'This is ONE digest, not a per-PRD request.',
|
|
152
|
+
]
|
|
153
|
+
: [`PLAN SETTLED — no PRD of this session is pending or running. This is ONE digest, not a per-PRD request.`];
|
|
146
154
|
const lines = [
|
|
147
|
-
|
|
155
|
+
...head,
|
|
148
156
|
...recordFolderLines(cwd, epicId),
|
|
149
157
|
'Do NOT re-verify VERIFIED PRDs — a validator already checked them.',
|
|
150
158
|
];
|
|
@@ -0,0 +1,123 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* planReviewInput.cjs — pure builder for the scheduler_create_prd input of one
|
|
5
|
+
* plan-review job (agentType plan-reviewer), plus a deterministic structural
|
|
6
|
+
* pre-check whose findings go into the job's notes. Pure: no fs, no child_process.
|
|
7
|
+
*/
|
|
8
|
+
|
|
9
|
+
const { bareSlug } = require('../prd/depSlugResolve.cjs');
|
|
10
|
+
|
|
11
|
+
const PERSONA_LINE = 'Work as the plan-reviewer persona — the procedure is your system prompt.';
|
|
12
|
+
|
|
13
|
+
/** @param {any} m */
|
|
14
|
+
function isDocMember(m) {
|
|
15
|
+
const goal = typeof m.goal === 'string' ? m.goal.trim().toLowerCase() : '';
|
|
16
|
+
if (goal.startsWith('doc')) return true;
|
|
17
|
+
const files = Array.isArray(m.files) ? m.files : [];
|
|
18
|
+
return files.length > 0 && files.every((f) => typeof f === 'string' && /\.md$/i.test(f));
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* @param {Array<any>} members
|
|
23
|
+
* @returns {Array<{ check: string, slug: string, detail: string }>}
|
|
24
|
+
*/
|
|
25
|
+
function structuralFindings(members) {
|
|
26
|
+
const list = Array.isArray(members) ? members : [];
|
|
27
|
+
const bySlug = new Map(list.map((m) => [bareSlug(m.slug), m]));
|
|
28
|
+
const findings = [];
|
|
29
|
+
|
|
30
|
+
/** @param {any} start */
|
|
31
|
+
const reachesNonDoc = (start) => {
|
|
32
|
+
const seen = new Set();
|
|
33
|
+
const stack = [...(start.dependsOn || [])];
|
|
34
|
+
while (stack.length) {
|
|
35
|
+
const b = bareSlug(stack.pop());
|
|
36
|
+
if (seen.has(b)) continue;
|
|
37
|
+
seen.add(b);
|
|
38
|
+
const m = bySlug.get(b);
|
|
39
|
+
if (!m) continue;
|
|
40
|
+
if (!isDocMember(m)) return true;
|
|
41
|
+
stack.push(...(m.dependsOn || []));
|
|
42
|
+
}
|
|
43
|
+
return false;
|
|
44
|
+
};
|
|
45
|
+
|
|
46
|
+
for (const m of list) {
|
|
47
|
+
if (isDocMember(m) && !reachesNonDoc(m)) {
|
|
48
|
+
findings.push({
|
|
49
|
+
check: 'doc-after-code',
|
|
50
|
+
slug: m.slug,
|
|
51
|
+
detail: `doc PRD ${m.slug} does not depend (transitively) on any code PRD in the plan`,
|
|
52
|
+
});
|
|
53
|
+
}
|
|
54
|
+
for (const d of m.dependsOn || []) {
|
|
55
|
+
if (!bySlug.has(bareSlug(d))) {
|
|
56
|
+
findings.push({
|
|
57
|
+
check: 'depends-on',
|
|
58
|
+
slug: m.slug,
|
|
59
|
+
detail: `${m.slug} dependsOn ${d}, which is not in the plan`,
|
|
60
|
+
});
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
return findings;
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
/**
|
|
68
|
+
* @param {{ epicId: string, cwd: string, epicGoal?: string, validateSlug: string,
|
|
69
|
+
* members: Array<any>, baseSha?: string | null, round?: number }} args
|
|
70
|
+
*/
|
|
71
|
+
function buildPlanReviewInput({ epicId, cwd, epicGoal, validateSlug, members, baseSha, round }) {
|
|
72
|
+
const list = Array.isArray(members) ? members : [];
|
|
73
|
+
const bare = bareSlug(validateSlug);
|
|
74
|
+
const slug = `plan-review-${bare}${round && round >= 2 ? `-r${round}` : ''}`;
|
|
75
|
+
const recordPath = `session-manager-operations/plan-records/${epicId}/${validateSlug}.plan-review.md`;
|
|
76
|
+
|
|
77
|
+
const acceptanceCriteria = list.map((m) => `Review ${m.slug}`);
|
|
78
|
+
acceptanceCriteria.push(`Record written at ${recordPath}, relative to the job worktree's repository root (git rev-parse --show-toplevel), never relative to a subdirectory you cd'd into. Do not git add or commit it — the scheduler copies it to the main checkout`);
|
|
79
|
+
|
|
80
|
+
const lines = [
|
|
81
|
+
PERSONA_LINE,
|
|
82
|
+
`Epic goal: ${epicGoal || 'unknown'}`,
|
|
83
|
+
baseSha ? `Base: ${baseSha}` : 'Base: unknown',
|
|
84
|
+
'',
|
|
85
|
+
'Plan members:',
|
|
86
|
+
];
|
|
87
|
+
for (const m of list) {
|
|
88
|
+
lines.push(
|
|
89
|
+
`- ${m.slug}${m.title ? ` — ${m.title}` : ''}`,
|
|
90
|
+
` PRD file: ${m.prdPath}`,
|
|
91
|
+
` Goal: ${m.goal || ''}`,
|
|
92
|
+
' Acceptance criteria:',
|
|
93
|
+
...(m.acceptanceCriteria || []).map((c) => ` - ${c}`),
|
|
94
|
+
` Files: ${(m.files || []).join(', ') || '(none)'}`,
|
|
95
|
+
` Gate: ${(m.gate || []).join(' ; ') || '(none)'}`,
|
|
96
|
+
` dependsOn: ${(m.dependsOn || []).join(', ') || '(none)'}`,
|
|
97
|
+
);
|
|
98
|
+
}
|
|
99
|
+
const findings = structuralFindings(list);
|
|
100
|
+
lines.push('', 'Structural pre-check:');
|
|
101
|
+
if (findings.length === 0) lines.push('- no findings');
|
|
102
|
+
for (const f of findings) lines.push(`- [${f.check}] ${f.detail}`);
|
|
103
|
+
lines.push('', 'Created automatically by the scheduler; no human or planner wrote this PRD.');
|
|
104
|
+
|
|
105
|
+
return {
|
|
106
|
+
title: `Plan review: ${bare}${round && round >= 2 ? ` (round ${round})` : ''}`,
|
|
107
|
+
slug,
|
|
108
|
+
goal: `review. Independent review of this Epic's plan before its PRDs dispatch: ${list.map((m) => m.slug).join(', ')}.`,
|
|
109
|
+
acceptanceCriteria,
|
|
110
|
+
implementationNotes: lines.join('\n'),
|
|
111
|
+
outOfScope: ['Editing product code', 'Queuing fix PRDs'],
|
|
112
|
+
gate: ['none'],
|
|
113
|
+
files: [recordPath],
|
|
114
|
+
deliverable: 'artifact',
|
|
115
|
+
artifactPaths: [recordPath],
|
|
116
|
+
agentType: 'plan-reviewer',
|
|
117
|
+
tag: 'build',
|
|
118
|
+
sourcePromptId: epicId,
|
|
119
|
+
cwd,
|
|
120
|
+
};
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
module.exports = { buildPlanReviewInput, structuralFindings };
|