claude-code-session-manager 0.125.0 → 0.126.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.claude-plugin/marketplace.json +4 -3
- package/dist/assets/{AgentLibrary-CcnnJg8P.js → AgentLibrary-bzeuZN4F.js} +1 -1
- package/dist/assets/{Button-sA4lqAao.js → Button-8dWfDDuQ.js} +1 -1
- package/dist/assets/{DataModel-BSTejIBU.js → DataModel-D4ybBPZN.js} +1 -1
- package/dist/assets/{History-DuwlZsQ5.js → History-hsztE6yh.js} +1 -1
- package/dist/assets/{Hooks-DHDSoDJ_.js → Hooks-CRmZMQaW.js} +1 -1
- package/dist/assets/{Library-XA9osRfi.js → Library-Czt3Bojd.js} +1 -1
- package/dist/assets/{ListDetail-B3goE3Wc.js → ListDetail-Cr6Ct_WX.js} +1 -1
- package/dist/assets/{McpServers-cMZTsPS6.js → McpServers-CeXJ2bng.js} +1 -1
- package/dist/assets/{Memory-D6qntpZ0.js → Memory-caujO8O3.js} +1 -1
- package/dist/assets/{Panel-DIyJXHfp.js → Panel-D64i9tGz.js} +1 -1
- package/dist/assets/{Permissions-DJda4Aii.js → Permissions-DpWOIrvr.js} +1 -1
- package/dist/assets/{Plugins-DcdRVBnU.js → Plugins-Bd1ekP5P.js} +2 -2
- package/dist/assets/{ProvenanceBadge-BSI_2wAv.js → ProvenanceBadge-B96A_uZf.js} +1 -1
- package/dist/assets/{SaveBar-CeL4vXRp.js → SaveBar-D0Y2t-Ao.js} +1 -1
- package/dist/assets/{Scheduler-CTd19y5U.js → Scheduler-Y5_YbNrC.js} +1 -1
- package/dist/assets/{ScopeSwitcher-BMiHySnz.js → ScopeSwitcher-BmWA_dP9.js} +1 -1
- package/dist/assets/{Settings-D-oIEKZy.js → Settings-Bcf65bpL.js} +1 -1
- package/dist/assets/{SkillReferenceGraph-B_7WfFjn.js → SkillReferenceGraph-BeSNXloA.js} +1 -1
- package/dist/assets/{Skills-CKpgxhSS.js → Skills-DwnQKJVc.js} +1 -1
- package/dist/assets/{SystemPrompt-BjJPTx_a.js → SystemPrompt-Dih6SCmL.js} +1 -1
- package/dist/assets/{TagLibrary-DJBB4gL0.js → TagLibrary-BZ-Kp10P.js} +1 -1
- package/dist/assets/{TiptapBody-C9Cu2GBL.js → TiptapBody-C2nEUmF7.js} +1 -1
- package/dist/assets/{Toggle-DbIRTOix.js → Toggle-Dw8-zNQo.js} +1 -1
- package/dist/assets/{ViewTabs-BDpHur6l.js → ViewTabs-CoYPKGN-.js} +1 -1
- package/dist/assets/{historyTotals-WCJHsBMq.js → historyTotals-BbKcNpV7.js} +1 -1
- package/dist/assets/{index-BD0ufZqe.js → index-DgPUERhe.js} +581 -581
- package/dist/assets/{settingsSchema-DmjBj3q7.js → settingsSchema-6doG_61l.js} +1 -1
- package/dist/assets/{skillFrontmatter-Tn_XHajE.js → skillFrontmatter-BYMYWDfb.js} +1 -1
- package/dist/assets/{useAgentsDirWatch-Vz2iXtsQ.js → useAgentsDirWatch-Cqabjieh.js} +1 -1
- package/dist/index.html +1 -1
- package/dist-web/{assets/app.js → app.js} +350 -350
- package/dist-web/index.html +2 -2
- package/package.json +4 -2
- package/plugins/session-manager-dev/.claude-plugin/plugin.json +4 -3
- package/plugins/session-manager-dev/skills/develop/SKILL.md +2 -1
- package/plugins/session-manager-dev/skills/send-feedback/SKILL.md +10 -2
- package/scripts/README.md +3 -1
- package/scripts/scheduler-mcp-server.cjs +17 -4
- package/src/main/build-info.json +4 -4
- package/src/main/chatRunner.cjs +36 -2
- package/src/main/lib/epic/epicMint.cjs +6 -0
- package/src/main/lib/epic/epicSweepValidator.cjs +1 -1
- package/src/main/lib/epic/epicValidationHook.cjs +1 -1
- package/src/main/lib/epic/epicWorktreeMerge.cjs +9 -1
- package/src/main/lib/feedback-remote/autoStartedSession.cjs +102 -0
- package/src/main/lib/feedback-remote/crossProjectFeedback.cjs +130 -15
- package/src/main/lib/feedback-remote/remoteAssets.cjs +25 -1
- package/src/main/lib/feedback-remote/remoteIpcDispatch.cjs +13 -2
- package/src/main/lib/git/gitExec.cjs +11 -1
- package/src/main/lib/git/gitWorktree.cjs +255 -9
- package/src/main/lib/git/jobWorktree.cjs +5 -0
- package/src/main/lib/mcpToolCatalog.cjs +9 -3
- package/src/main/lib/persona-macro/macroLibrary.cjs +21 -0
- package/src/main/lib/prd/prdDeclaredPaths.cjs +29 -2
- package/src/main/lib/promptSessionSchema.cjs +6 -1
- package/src/main/lib/scheduler/landedSinceRun.cjs +13 -5
- package/src/main/lib/scheduler/rcaReport.cjs +1 -0
- package/src/main/lib/scheduler/reviewNotice.cjs +1 -0
- package/src/main/runVerify.cjs +59 -110
- package/src/main/scheduler/gitTreeGuard.cjs +51 -1
- package/src/main/scheduler/reviewLadder.cjs +11 -5
- package/src/main/scheduler.cjs +140 -22
- package/src/main/templates/PRD_AUTHORING.md +6 -2
- package/src/main/webRemote.cjs +9 -0
- package/src/preload/api.d.ts +7 -1
- /package/dist-web/{assets/app.css → app.css} +0 -0
|
@@ -92,7 +92,31 @@ function readAsset(name) {
|
|
|
92
92
|
};
|
|
93
93
|
}
|
|
94
94
|
|
|
95
|
+
/**
|
|
96
|
+
* Basenames of local stylesheet/script references in dist-web/index.html that the manifest
|
|
97
|
+
* cannot serve (e.g. nested under assets/). ['index.html'] when the root or index.html is absent.
|
|
98
|
+
*/
|
|
99
|
+
function missingEntryFiles() {
|
|
100
|
+
let html;
|
|
101
|
+
try { html = fs.readFileSync(path.join(webRoot(), 'index.html'), 'utf8'); } catch { return ['index.html']; }
|
|
102
|
+
const served = new Set(assetManifest().files.map((f) => f.name));
|
|
103
|
+
const refs = [];
|
|
104
|
+
for (const m of html.matchAll(/<script\b[^>]*?\bsrc\s*=\s*["']([^"']+)["']/gi)) refs.push(m[1]);
|
|
105
|
+
for (const m of html.matchAll(/<link\b[^>]*>/gi)) {
|
|
106
|
+
if (!/\brel\s*=\s*["']?stylesheet/i.test(m[0])) continue;
|
|
107
|
+
const h = /\bhref\s*=\s*["']([^"']+)["']/i.exec(m[0]);
|
|
108
|
+
if (h) refs.push(h[1]);
|
|
109
|
+
}
|
|
110
|
+
const missing = [];
|
|
111
|
+
for (const ref of refs) {
|
|
112
|
+
if (/^(https?:)?\/\//i.test(ref) || /^[a-z][a-z0-9+.-]*:/i.test(ref)) continue;
|
|
113
|
+
const name = path.basename(ref.split(/[?#]/)[0]);
|
|
114
|
+
if (name && !served.has(name) && !missing.includes(name)) missing.push(name);
|
|
115
|
+
}
|
|
116
|
+
return missing;
|
|
117
|
+
}
|
|
118
|
+
|
|
95
119
|
module.exports = {
|
|
96
|
-
assetManifest, readAsset, MAX_ASSET_BYTES,
|
|
120
|
+
assetManifest, readAsset, missingEntryFiles, MAX_ASSET_BYTES,
|
|
97
121
|
__test: { setRoot: (p) => { _rootOverride = p; } },
|
|
98
122
|
};
|
|
@@ -185,11 +185,22 @@ function chunkFrames(value, maxBytes = DEFAULT_FRAME_BYTES) {
|
|
|
185
185
|
const json = JSON.stringify(value === undefined ? null : value)
|
|
186
186
|
const buf = Buffer.from(json, 'utf8')
|
|
187
187
|
if (buf.length > MAX_VALUE_BYTES) return { ok: false, reason: 'too_large' }
|
|
188
|
-
|
|
188
|
+
// Budget is the JSON-escaped size of each slice (quotes/backslashes double,
|
|
189
|
+
// control bytes become \\n or \\u00XX) because the frame is re-stringified
|
|
190
|
+
// and then base64url-encoded inside an e2e:box.
|
|
191
|
+
const limit = Math.max(12, maxBytes - 1)
|
|
189
192
|
const slices = []
|
|
190
193
|
let start = 0
|
|
191
194
|
while (start < buf.length) {
|
|
192
|
-
let end =
|
|
195
|
+
let end = start
|
|
196
|
+
let cost = 0
|
|
197
|
+
while (end < buf.length) {
|
|
198
|
+
const b = buf[end]
|
|
199
|
+
const c = b === 0x22 || b === 0x5c ? 2 : b < 0x20 ? (b === 0x0a || b === 0x0d || b === 0x09 || b === 0x08 || b === 0x0c ? 2 : 6) : 1
|
|
200
|
+
if (cost + c > limit) break
|
|
201
|
+
cost += c
|
|
202
|
+
end++
|
|
203
|
+
}
|
|
193
204
|
if (end < buf.length) {
|
|
194
205
|
while (end > start && (buf[end] & 0xc0) === 0x80) end--
|
|
195
206
|
}
|
|
@@ -66,4 +66,14 @@ function parseWorktreePorcelain(text) {
|
|
|
66
66
|
return entries;
|
|
67
67
|
}
|
|
68
68
|
|
|
69
|
-
|
|
69
|
+
/**
|
|
70
|
+
* Namespace for durable pins on commits a checkout holds but no branch does
|
|
71
|
+
* (a job that left its branch via `git checkout HEAD~0` then committed).
|
|
72
|
+
* Deliberately NOT under refs/heads/sm-job: branchSweep.cjs merges that
|
|
73
|
+
* namespace forward and deletes it, which would silently drop the pin. A
|
|
74
|
+
* ref outside refs/heads, refs/tags and refs/remotes is still a GC root but
|
|
75
|
+
* invisible to branch listings and sweeps.
|
|
76
|
+
*/
|
|
77
|
+
const STRANDED_REF_PREFIX = 'refs/sm-stranded/';
|
|
78
|
+
|
|
79
|
+
module.exports = { execGit, parseWorktreePorcelain, STRANDED_REF_PREFIX };
|
|
@@ -329,6 +329,7 @@ function branchNameFor(kind, key) {
|
|
|
329
329
|
* never be destroyed by this call.
|
|
330
330
|
*/
|
|
331
331
|
async function removeWorktreeDir(cwd, dir) {
|
|
332
|
+
await pinStrandedHead({ cwd, dir });
|
|
332
333
|
try {
|
|
333
334
|
await execGit(['worktree', 'remove', '--force', dir], { cwd, timeout: 15_000 });
|
|
334
335
|
} catch {
|
|
@@ -408,6 +409,7 @@ async function mainTreeFromWorktreeGitFile(dir) {
|
|
|
408
409
|
*/
|
|
409
410
|
async function teardownOrphanedCheckout(dir) {
|
|
410
411
|
const mainTree = await mainTreeFromWorktreeGitFile(dir);
|
|
412
|
+
await pinStrandedHead({ cwd: mainTree || dir, dir });
|
|
411
413
|
if (mainTree) {
|
|
412
414
|
try {
|
|
413
415
|
await execGit(['worktree', 'remove', '--force', dir], { cwd: mainTree, timeout: 15_000 });
|
|
@@ -872,7 +874,7 @@ async function createWorktree({ kind, cwd, key, fromRef }) {
|
|
|
872
874
|
// can legitimately re-fire after a transient failure) must not collide
|
|
873
875
|
// with `git worktree add`'s own branch/path checks.
|
|
874
876
|
await removeWorktreeDir(cwd, dir);
|
|
875
|
-
|
|
877
|
+
await deleteBranchKeepingUniqueCommits({ cwd, branch, key });
|
|
876
878
|
await execGit(['worktree', 'add', '-b', branch, dir, worktreeSource], { cwd, timeout: 30_000 });
|
|
877
879
|
} catch (e) {
|
|
878
880
|
activeWorktreeCount[kind] = Math.max(0, activeWorktreeCount[kind] - 1);
|
|
@@ -957,6 +959,37 @@ async function pathsIdenticalToBranch({ cwd, branch, paths }) {
|
|
|
957
959
|
return true;
|
|
958
960
|
}
|
|
959
961
|
|
|
962
|
+
/**
|
|
963
|
+
* Returns the entries of `paths` whose bytes in `dir` still equal the bytes in
|
|
964
|
+
* `cwd` (carried-but-untouched), plus entries absent from both (a carried
|
|
965
|
+
* deletion). Any read error, or a path resolving outside cwd/dir, leaves that
|
|
966
|
+
* path out. Never throws. Complexity: O(paths) — each file is read twice.
|
|
967
|
+
*/
|
|
968
|
+
async function unchangedCarriedPaths({ cwd, dir, paths }) {
|
|
969
|
+
const out = [];
|
|
970
|
+
if (!Array.isArray(paths) || !paths.length || !cwd || !dir) return out;
|
|
971
|
+
const inside = (root, abs) => {
|
|
972
|
+
const rel = path.relative(root, abs);
|
|
973
|
+
return rel !== '' && !rel.startsWith('..') && !path.isAbsolute(rel);
|
|
974
|
+
};
|
|
975
|
+
const readOrMissing = async (file) => {
|
|
976
|
+
try { return await fsp.readFile(file); }
|
|
977
|
+
catch (err) { if (err && err.code === 'ENOENT') return null; throw err; }
|
|
978
|
+
};
|
|
979
|
+
for (const p of paths) {
|
|
980
|
+
try {
|
|
981
|
+
if (typeof p !== 'string' || !p) continue;
|
|
982
|
+
const a = path.resolve(cwd, p);
|
|
983
|
+
const b = path.resolve(dir, p);
|
|
984
|
+
if (!inside(path.resolve(cwd), a) || !inside(path.resolve(dir), b)) continue;
|
|
985
|
+
const [baseBuf, wtBuf] = await Promise.all([readOrMissing(a), readOrMissing(b)]);
|
|
986
|
+
if (baseBuf === null && wtBuf === null) out.push(p);
|
|
987
|
+
else if (baseBuf !== null && wtBuf !== null && baseBuf.equals(wtBuf)) out.push(p);
|
|
988
|
+
} catch { /* read error: leave the path out */ }
|
|
989
|
+
}
|
|
990
|
+
return out;
|
|
991
|
+
}
|
|
992
|
+
|
|
960
993
|
/**
|
|
961
994
|
* Parses the path lists out of git's refusal to merge over dirty working-tree
|
|
962
995
|
* files. Git emits up to two distinct blocks — tracked paths under "local
|
|
@@ -1001,7 +1034,9 @@ function parseBlockingMergePaths(stderrText) {
|
|
|
1001
1034
|
* integrateBranch's `ok: false` results (the `reason` string is untouched).
|
|
1002
1035
|
* 'blocking_paths' = git refused up-front over dirty/untracked paths
|
|
1003
1036
|
* (auto-resolvable, PRD 1125); 'content_conflict' = a genuine 3-way
|
|
1004
|
-
* `CONFLICT (` (deterministic on every retry); '
|
|
1037
|
+
* `CONFLICT (` (deterministic on every retry); 'hook_rejected' = a git hook
|
|
1038
|
+
* (the identity guard) refused the commit — deterministic too; 'other' =
|
|
1039
|
+
* anything else.
|
|
1005
1040
|
* For content_conflict, reads the unmerged paths — MUST be called before
|
|
1006
1041
|
* `git merge --abort`, which clears them. Never throws; a failed read
|
|
1007
1042
|
* yields `conflictedPaths: []`. O(p log p) in the conflicted-path count.
|
|
@@ -1009,6 +1044,7 @@ function parseBlockingMergePaths(stderrText) {
|
|
|
1009
1044
|
async function classifyMergeFailure({ cwd, stderrText, stdoutText }) {
|
|
1010
1045
|
const blocking = parseBlockingMergePaths(stderrText);
|
|
1011
1046
|
if (blocking) return { failureKind: 'blocking_paths', blockingPaths: blocking };
|
|
1047
|
+
if (/identity-guard:/.test(`${stdoutText || ''}\n${stderrText || ''}`)) return { failureKind: 'hook_rejected' };
|
|
1012
1048
|
// git prints `CONFLICT (...)` lines on STDOUT, not stderr.
|
|
1013
1049
|
if (/CONFLICT \(/m.test(`${stdoutText || ''}\n${stderrText || ''}`)) {
|
|
1014
1050
|
let conflictedPaths = [];
|
|
@@ -1025,6 +1061,12 @@ async function classifyMergeFailure({ cwd, stderrText, stdoutText }) {
|
|
|
1025
1061
|
// a merge: one conflicted path outside this list means no auto-resolve at all.
|
|
1026
1062
|
const AUTO_RESOLVE_EXTENSIONS = new Set(['.md', '.markdown', '.txt', '.rst']);
|
|
1027
1063
|
|
|
1064
|
+
function mergeFailureReason(failureKind, text) {
|
|
1065
|
+
return failureKind === 'hook_rejected'
|
|
1066
|
+
? `merge blocked by a git hook: ${text}`
|
|
1067
|
+
: `merge failed (likely a real content conflict): ${text}`;
|
|
1068
|
+
}
|
|
1069
|
+
|
|
1028
1070
|
/**
|
|
1029
1071
|
* Renders `git merge-file -p --diff3` over the index's three conflict stages
|
|
1030
1072
|
* of `p`. Returns the merged text (with markers), or null when any stage is
|
|
@@ -1474,7 +1516,7 @@ async function integrateBranch({ cwd, branch, key, kind, carriedPaths, baseBranc
|
|
|
1474
1516
|
const retryText = (retryErr && (retryErr.stderrText || retryErr.message)) || String(retryErr);
|
|
1475
1517
|
const retryClass = await classifyMergeFailure({ cwd, stderrText: retryText, stdoutText: retryErr && retryErr.stdoutText });
|
|
1476
1518
|
try { await execGit(['merge', '--abort'], { cwd, timeout: 10_000 }); } catch { /* nothing to abort */ }
|
|
1477
|
-
return { ok: false, reason:
|
|
1519
|
+
return { ok: false, reason: mergeFailureReason(retryClass.failureKind, retryText), ...retryClass, baseHeadSha: await readHeadSha(cwd) };
|
|
1478
1520
|
}
|
|
1479
1521
|
}
|
|
1480
1522
|
}
|
|
@@ -1496,11 +1538,18 @@ async function integrateBranch({ cwd, branch, key, kind, carriedPaths, baseBranc
|
|
|
1496
1538
|
await execGit(['commit', '-m', mergeMessage], { cwd, timeout: 30_000 });
|
|
1497
1539
|
return { ok: true, integrated: true, mergeCommit: true, sha: await readHeadSha(cwd), autoResolved: 'pure_addition_concat', resolvedPaths: paths };
|
|
1498
1540
|
}
|
|
1499
|
-
} catch {
|
|
1541
|
+
} catch (autoErr) {
|
|
1542
|
+
const autoText = [autoErr && autoErr.stderrText, autoErr && autoErr.stdoutText, autoErr && autoErr.message].filter(Boolean).join('\n');
|
|
1543
|
+
if (autoText.includes('identity-guard:')) {
|
|
1544
|
+
try { await execGit(['merge', '--abort'], { cwd, timeout: 10_000 }); } catch { /* nothing to abort */ }
|
|
1545
|
+
return { ok: false, reason: mergeFailureReason('hook_rejected', autoText), failureKind: 'hook_rejected', baseHeadSha: await readHeadSha(cwd) };
|
|
1546
|
+
}
|
|
1547
|
+
/* otherwise fall through to the abort */
|
|
1548
|
+
}
|
|
1500
1549
|
}
|
|
1501
1550
|
// Abort a half-applied merge so `cwd` isn't left in a mid-merge state.
|
|
1502
1551
|
try { await execGit(['merge', '--abort'], { cwd, timeout: 10_000 }); } catch { /* nothing to abort */ }
|
|
1503
|
-
return { ok: false, reason:
|
|
1552
|
+
return { ok: false, reason: mergeFailureReason(failureClass.failureKind, stderrText), ...failureClass, baseHeadSha: await readHeadSha(cwd) };
|
|
1504
1553
|
}
|
|
1505
1554
|
}
|
|
1506
1555
|
|
|
@@ -1769,7 +1818,7 @@ async function reclaimTerminalJobOrphans({ cwd, terminalSlugs, isLive }) {
|
|
|
1769
1818
|
|
|
1770
1819
|
await removeWorktreeDir(cwd, entry.worktree);
|
|
1771
1820
|
if (entry.branch) {
|
|
1772
|
-
|
|
1821
|
+
await deleteBranchKeepingUniqueCommits({ cwd, branch: entry.branch, key: slug });
|
|
1773
1822
|
}
|
|
1774
1823
|
reclaimed.push(slug);
|
|
1775
1824
|
}
|
|
@@ -1829,15 +1878,19 @@ async function reconcileWorktreesOnBoot(cwds, opts = {}) {
|
|
|
1829
1878
|
const entries = parseWorktreeListPorcelain(out);
|
|
1830
1879
|
for (const entry of entries) {
|
|
1831
1880
|
if (!entry.worktree || !entry.worktree.startsWith(root + path.sep)) continue;
|
|
1832
|
-
const
|
|
1881
|
+
const branchKey = keyFromBranch(kind, entry.branch);
|
|
1882
|
+
// Worktree dirs are <root>/<hash>/<key>, so the basename is the slug/epic id
|
|
1883
|
+
// even when the checkout is detached or on a branch we do not own.
|
|
1884
|
+
const key = branchKey || path.basename(entry.worktree);
|
|
1833
1885
|
if (isLive && key && (await isLive(key, entry))) continue;
|
|
1834
1886
|
await removeWorktreeDir(cwd, entry.worktree);
|
|
1835
1887
|
checkoutsRemoved++;
|
|
1836
1888
|
// sm-land/* is the per-Epic integration branch, never a throwaway
|
|
1837
1889
|
// worktree branch — even if something else checked it out onto a
|
|
1838
1890
|
// worktree under this kind's root, this sweep must never delete it.
|
|
1839
|
-
|
|
1840
|
-
|
|
1891
|
+
// Only a branch of this kind's own prefix is ours to delete.
|
|
1892
|
+
if (branchKey && !entry.branch.startsWith(LAND_BRANCH_PREFIX)) {
|
|
1893
|
+
await deleteBranchKeepingUniqueCommits({ cwd, branch: entry.branch, key: branchKey });
|
|
1841
1894
|
}
|
|
1842
1895
|
}
|
|
1843
1896
|
try { await execGit(['worktree', 'prune'], { cwd, timeout: 10_000 }); } catch { /* best effort */ }
|
|
@@ -2274,7 +2327,197 @@ async function cleanupEpicWorktree({ cwd, dir, branch, keepBranch }) {
|
|
|
2274
2327
|
return cleanupWorktree({ kind: 'epic', cwd, dir, branch, keepBranch });
|
|
2275
2328
|
}
|
|
2276
2329
|
|
|
2330
|
+
// ──────────────────────────────────────────── stranded-HEAD reconciliation
|
|
2331
|
+
|
|
2332
|
+
function safePinKey(key) {
|
|
2333
|
+
return String(key || 'unknown').replace(/[^A-Za-z0-9._-]/g, '_').replace(/^\.+/, '_') || 'unknown';
|
|
2334
|
+
}
|
|
2335
|
+
|
|
2336
|
+
/** Pins `sha` under STRANDED_REF_PREFIX/<key>/<sha>; returns the ref or null. Never throws. */
|
|
2337
|
+
async function pinCommit({ cwd, key, sha }) {
|
|
2338
|
+
try {
|
|
2339
|
+
const safeKey = safePinKey(key);
|
|
2340
|
+
const ref = `${sharedGitExec.STRANDED_REF_PREFIX}${safeKey}/${sha}`;
|
|
2341
|
+
await execGit(['update-ref', ref, sha], { cwd, timeout: 10_000 });
|
|
2342
|
+
return ref;
|
|
2343
|
+
} catch {
|
|
2344
|
+
return null;
|
|
2345
|
+
}
|
|
2346
|
+
}
|
|
2347
|
+
|
|
2348
|
+
/**
|
|
2349
|
+
* Deletes `branch` (`git branch -D`), first pinning its tip under
|
|
2350
|
+
* refs/sm-stranded/<key>/ when it holds commits no other branch, tag or remote
|
|
2351
|
+
* has. A failed uniqueness check also pins (fail-safe). Never throws.
|
|
2352
|
+
*/
|
|
2353
|
+
async function deleteBranchKeepingUniqueCommits({ cwd, branch, key }) {
|
|
2354
|
+
try {
|
|
2355
|
+
let tip = null;
|
|
2356
|
+
try {
|
|
2357
|
+
tip = (await execGit(['rev-parse', '--verify', '--quiet', `refs/heads/${branch}^{commit}`], { cwd, timeout: 10_000 })).trim() || null;
|
|
2358
|
+
} catch { tip = null; }
|
|
2359
|
+
if (tip) {
|
|
2360
|
+
let unique = true;
|
|
2361
|
+
try {
|
|
2362
|
+
const out = await execGit(
|
|
2363
|
+
['rev-list', '--count', `refs/heads/${branch}`, '--not', `--exclude=${branch}`, '--branches', '--tags', '--remotes'],
|
|
2364
|
+
{ cwd, timeout: 10_000 }
|
|
2365
|
+
);
|
|
2366
|
+
const n = Number.parseInt(String(out).trim(), 10);
|
|
2367
|
+
unique = Number.isFinite(n) ? n > 0 : true;
|
|
2368
|
+
} catch { unique = true; }
|
|
2369
|
+
if (unique) await pinCommit({ cwd, key, sha: tip });
|
|
2370
|
+
}
|
|
2371
|
+
} catch { /* fall through to delete */ }
|
|
2372
|
+
try { await execGit(['branch', '-D', branch], { cwd, timeout: 10_000 }); } catch { /* already gone */ }
|
|
2373
|
+
}
|
|
2374
|
+
|
|
2375
|
+
/**
|
|
2376
|
+
* Pins under refs/sm-stranded/<key>/ whose commit date is >= sinceMs and that
|
|
2377
|
+
* no branch, tag or remote holds. Returns [{ sha, ref }]; [] on any error.
|
|
2378
|
+
*/
|
|
2379
|
+
async function listStrandedPins({ cwd, key, sinceMs }) {
|
|
2380
|
+
try {
|
|
2381
|
+
const prefix = `${sharedGitExec.STRANDED_REF_PREFIX}${safePinKey(key)}/`;
|
|
2382
|
+
const out = await execGit(
|
|
2383
|
+
['for-each-ref', '--format=%(objectname)%09%(refname)%09%(committerdate:unix)', prefix],
|
|
2384
|
+
{ cwd, timeout: 10_000 }
|
|
2385
|
+
);
|
|
2386
|
+
const since = Number.isFinite(sinceMs) ? sinceMs : 0;
|
|
2387
|
+
const pins = [];
|
|
2388
|
+
for (const line of String(out).split('\n')) {
|
|
2389
|
+
if (!line.trim()) continue;
|
|
2390
|
+
const [sha, ref, ts] = line.split('\t');
|
|
2391
|
+
if (!sha || !ref) continue;
|
|
2392
|
+
if (Number(ts) * 1000 < since) continue;
|
|
2393
|
+
if ((await countCommitsOnNoRef(cwd, sha)) <= 0) continue;
|
|
2394
|
+
pins.push({ sha, ref });
|
|
2395
|
+
}
|
|
2396
|
+
return pins;
|
|
2397
|
+
} catch {
|
|
2398
|
+
return [];
|
|
2399
|
+
}
|
|
2400
|
+
}
|
|
2401
|
+
|
|
2402
|
+
/** True/false for `git merge-base --is-ancestor a b`; null on a real failure. */
|
|
2403
|
+
async function isAncestorOf(cwd, a, b) {
|
|
2404
|
+
try {
|
|
2405
|
+
await execGit(['merge-base', '--is-ancestor', a, b], { cwd, timeout: 10_000 });
|
|
2406
|
+
return true;
|
|
2407
|
+
} catch (e) {
|
|
2408
|
+
return e && e.code === 1 ? false : null;
|
|
2409
|
+
}
|
|
2410
|
+
}
|
|
2411
|
+
|
|
2412
|
+
/** Commits reachable from `sha` that no branch, tag or remote holds; -1 on failure. Never throws. */
|
|
2413
|
+
async function countCommitsOnNoRef(cwd, sha) {
|
|
2414
|
+
try {
|
|
2415
|
+
const out = await execGit(['rev-list', '--count', sha, '--not', '--branches', '--tags', '--remotes'], { cwd, timeout: 10_000 });
|
|
2416
|
+
const n = Number.parseInt(String(out).trim(), 10);
|
|
2417
|
+
return Number.isFinite(n) ? n : -1;
|
|
2418
|
+
} catch {
|
|
2419
|
+
return -1;
|
|
2420
|
+
}
|
|
2421
|
+
}
|
|
2422
|
+
|
|
2423
|
+
/** Commits in `from..to`; -1 on failure. Never throws. */
|
|
2424
|
+
async function countRange(cwd, from, to) {
|
|
2425
|
+
try {
|
|
2426
|
+
const out = await execGit(['rev-list', '--count', `${from}..${to}`], { cwd, timeout: 10_000 });
|
|
2427
|
+
const n = Number.parseInt(String(out).trim(), 10);
|
|
2428
|
+
return Number.isFinite(n) ? n : -1;
|
|
2429
|
+
} catch {
|
|
2430
|
+
return -1;
|
|
2431
|
+
}
|
|
2432
|
+
}
|
|
2433
|
+
|
|
2434
|
+
/**
|
|
2435
|
+
* Compares a worktree's HEAD with its branch. aligned: HEAD is the tip or
|
|
2436
|
+
* behind it. on-other-ref: HEAD is held by some other branch/tag/remote (a PR
|
|
2437
|
+
* branch); no git writes. fast-forwarded: branch tip is an ancestor of HEAD and
|
|
2438
|
+
* every commit between is the run's own (held by no ref), so the branch ref
|
|
2439
|
+
* moved to HEAD (compare-and-swap update-ref). diverged: HEAD is pinned,
|
|
2440
|
+
* branch untouched. unknown: a ref did not resolve; no git writes.
|
|
2441
|
+
* Never throws.
|
|
2442
|
+
*/
|
|
2443
|
+
async function reconcileWorktreeHead({ cwd, dir, branch, key }) {
|
|
2444
|
+
let finalHead = null;
|
|
2445
|
+
let branchTip = null;
|
|
2446
|
+
try {
|
|
2447
|
+
finalHead = await tryResolveCommit(dir, 'HEAD^{commit}');
|
|
2448
|
+
branchTip = await tryResolveCommit(cwd, `refs/heads/${branch}^{commit}`);
|
|
2449
|
+
if (!finalHead || !branchTip) return { action: 'unknown', finalHead, branchTip, pinnedRef: null };
|
|
2450
|
+
if (finalHead === branchTip || (await isAncestorOf(cwd, finalHead, branchTip)) === true) {
|
|
2451
|
+
return { action: 'aligned', finalHead, branchTip, pinnedRef: null };
|
|
2452
|
+
}
|
|
2453
|
+
const unheld = await countCommitsOnNoRef(cwd, finalHead);
|
|
2454
|
+
if (unheld === 0) return { action: 'on-other-ref', finalHead, branchTip, pinnedRef: null };
|
|
2455
|
+
if (unheld > 0 && (await isAncestorOf(cwd, branchTip, finalHead)) === true
|
|
2456
|
+
&& (await countRange(cwd, branchTip, finalHead)) === unheld) {
|
|
2457
|
+
try {
|
|
2458
|
+
await execGit(['update-ref', `refs/heads/${branch}`, finalHead, branchTip], { cwd, timeout: 10_000 });
|
|
2459
|
+
return { action: 'fast-forwarded', finalHead, branchTip, pinnedRef: null };
|
|
2460
|
+
} catch { /* refused (branch moved) — fall through to diverged */ }
|
|
2461
|
+
}
|
|
2462
|
+
const pinnedRef = await pinCommit({ cwd, key: key || branch, sha: finalHead });
|
|
2463
|
+
return { action: 'diverged', finalHead, branchTip, pinnedRef };
|
|
2464
|
+
} catch {
|
|
2465
|
+
return { action: 'unknown', finalHead, branchTip, pinnedRef: null };
|
|
2466
|
+
}
|
|
2467
|
+
}
|
|
2468
|
+
|
|
2469
|
+
/**
|
|
2470
|
+
* Pins commits recorded in the worktree's HEAD reflog (commit, cherry-pick,
|
|
2471
|
+
* revert) that no branch, tag or remote holds. A predecessor of a
|
|
2472
|
+
* `commit (amend)` entry is superseded and skipped. Newest first, capped at 20.
|
|
2473
|
+
* Returns [{ sha, ref }]; [] on any error. A failed count keeps the commit.
|
|
2474
|
+
*/
|
|
2475
|
+
async function pinUnlandedWorktreeCommits({ cwd, dir, branch, key }) {
|
|
2476
|
+
try {
|
|
2477
|
+
const out = await execGit(['reflog', 'show', '--format=%H%x09%gs', '-n', '200', 'HEAD'], { cwd: dir, timeout: 15_000 });
|
|
2478
|
+
const entries = out.split('\n').filter(Boolean).map((l) => {
|
|
2479
|
+
const i = l.indexOf('\t');
|
|
2480
|
+
return { sha: l.slice(0, i), subject: l.slice(i + 1) };
|
|
2481
|
+
});
|
|
2482
|
+
const candidates = [];
|
|
2483
|
+
const superseded = new Set();
|
|
2484
|
+
for (let i = 0; i < entries.length; i++) {
|
|
2485
|
+
const e = entries[i];
|
|
2486
|
+
if (!/^(commit|cherry-pick|revert)\b/.test(e.subject)) continue;
|
|
2487
|
+
if (/^commit \(amend\)/.test(e.subject) && entries[i + 1]) superseded.add(entries[i + 1].sha);
|
|
2488
|
+
candidates.push(e.sha);
|
|
2489
|
+
}
|
|
2490
|
+
const seen = new Set();
|
|
2491
|
+
const pinned = [];
|
|
2492
|
+
for (const sha of candidates) {
|
|
2493
|
+
if (pinned.length >= 20) break;
|
|
2494
|
+
if (seen.has(sha) || superseded.has(sha)) continue;
|
|
2495
|
+
seen.add(sha);
|
|
2496
|
+
if (!((await countCommitsOnNoRef(cwd, sha)) !== 0)) continue;
|
|
2497
|
+
const ref = await pinCommit({ cwd, key: key || branch, sha });
|
|
2498
|
+
if (ref) pinned.push({ sha, ref });
|
|
2499
|
+
}
|
|
2500
|
+
return pinned;
|
|
2501
|
+
} catch {
|
|
2502
|
+
return [];
|
|
2503
|
+
}
|
|
2504
|
+
}
|
|
2505
|
+
|
|
2506
|
+
/** Pins `dir`'s HEAD when no branch/tag/remote holds it. Swallows every error. */
|
|
2507
|
+
async function pinStrandedHead({ cwd, dir }) {
|
|
2508
|
+
try {
|
|
2509
|
+
if (!fs.existsSync(dir)) return;
|
|
2510
|
+
const out = (await execGit(['rev-list', '-1', 'HEAD', '--not', '--branches', '--tags', '--remotes'], { cwd: dir, timeout: 10_000 })).trim();
|
|
2511
|
+
if (!out) return;
|
|
2512
|
+
const head = (await execGit(['rev-parse', 'HEAD'], { cwd: dir, timeout: 10_000 })).trim();
|
|
2513
|
+
if (head) await pinCommit({ cwd: cwd || dir, key: path.basename(dir), sha: head });
|
|
2514
|
+
} catch { /* best-effort */ }
|
|
2515
|
+
}
|
|
2516
|
+
|
|
2277
2517
|
module.exports = {
|
|
2518
|
+
reconcileWorktreeHead,
|
|
2519
|
+
pinUnlandedWorktreeCommits,
|
|
2520
|
+
resolveDefaultBranch,
|
|
2278
2521
|
KIND_CONFIG,
|
|
2279
2522
|
worktreeRootFor,
|
|
2280
2523
|
isWorktreeDisabled,
|
|
@@ -2289,6 +2532,7 @@ module.exports = {
|
|
|
2289
2532
|
createWorktree,
|
|
2290
2533
|
captureAndCarryBaseDiff,
|
|
2291
2534
|
pathsIdenticalToBranch,
|
|
2535
|
+
unchangedCarriedPaths,
|
|
2292
2536
|
resolveDefaultBranch,
|
|
2293
2537
|
getCurrentBranch,
|
|
2294
2538
|
isCarriedWipOnly,
|
|
@@ -2301,6 +2545,8 @@ module.exports = {
|
|
|
2301
2545
|
listCwdHolders,
|
|
2302
2546
|
hasLiveHolder,
|
|
2303
2547
|
reconcileWorktreesOnBoot,
|
|
2548
|
+
deleteBranchKeepingUniqueCommits,
|
|
2549
|
+
listStrandedPins,
|
|
2304
2550
|
sweepStaleWorktreeCheckouts,
|
|
2305
2551
|
mainTreeFromWorktreeGitFile,
|
|
2306
2552
|
getObservedWorktreeCount,
|
|
@@ -64,9 +64,14 @@ module.exports = {
|
|
|
64
64
|
cleanupJobWorktree: gitWorktree.cleanupJobWorktree,
|
|
65
65
|
salvageJobWorktreeDiff: gitWorktree.salvageJobWorktreeDiff,
|
|
66
66
|
salvageJobDirtyDelta: gitWorktree.salvageJobDirtyDelta,
|
|
67
|
+
reconcileWorktreeHead: gitWorktree.reconcileWorktreeHead,
|
|
68
|
+
listStrandedPins: gitWorktree.listStrandedPins,
|
|
69
|
+
pinUnlandedWorktreeCommits: gitWorktree.pinUnlandedWorktreeCommits,
|
|
70
|
+
resolveDefaultBranch: gitWorktree.resolveDefaultBranch,
|
|
67
71
|
parseWorktreeListPorcelain: gitWorktree.parseWorktreeListPorcelain,
|
|
68
72
|
reconcileWorktreesOnBoot: (cwds, opts = {}) => gitWorktree.reconcileWorktreesOnBoot(cwds, { kind: KIND, isLive: opts.isLive }),
|
|
69
73
|
reclaimTerminalJobOrphans: gitWorktree.reclaimTerminalJobOrphans,
|
|
74
|
+
unchangedCarriedPaths: gitWorktree.unchangedCarriedPaths,
|
|
70
75
|
// Test-only escape hatch for the in-memory concurrency counter.
|
|
71
76
|
_resetActiveWorktreeCountForTests(n = 0) { gitWorktree._resetActiveWorktreeCountForTests(KIND, n); },
|
|
72
77
|
_getActiveWorktreeCountForTests() { return gitWorktree._getActiveWorktreeCountForTests(KIND); },
|
|
@@ -271,11 +271,14 @@ const MCP_TOOL_CATALOG = [
|
|
|
271
271
|
+ '`acceptanceCriteria`; put evidence, symptom and references in `body`. Name the file in THEIR repo '
|
|
272
272
|
+ 'that looks responsible if you know it. When one request is split into several proposals, send '
|
|
273
273
|
+ 'them ALL with one shared `series` {key, title, total} (plus each one\'s `index`) and summarise '
|
|
274
|
-
+ 'the overall plan in each motivation.
|
|
274
|
+
+ 'the overall plan in each motivation. THREE MODES: (1) agent-initiated (your own idea) = PROPOSED, a '
|
|
275
275
|
+ 'human in the receiving project must approve it; pass neither autoStart nor humanRequestQuote. '
|
|
276
276
|
+ '(2) human-requested = the human in THIS conversation explicitly asked for the work in that other '
|
|
277
277
|
+ 'project: pass `autoStart: true` plus `humanRequestQuote`, copied VERBATIM from their own message, '
|
|
278
|
-
+ '
|
|
278
|
+
+ 'whose quoted words themselves must name the target project. An unverified request silently falls back to PROPOSED. '
|
|
279
|
+
+ '(3) macro auto-start = a session launched from a macro with "Can start work in other projects" on '
|
|
280
|
+
+ 'auto-starts sends tagged `bug` or `feature` to allowed projects with no flag and no quote; otherwise it stays '
|
|
281
|
+
+ 'a proposal. Pass tag `bug` or `feature` for work you want started.',
|
|
279
282
|
whenNotToUse: 'WHEN NOT TO USE IT: for work in the project you are ALREADY in, run /develop inside the Epic you '
|
|
280
283
|
+ 'are already in — this tool refuses toCwd === fromCwd outright.',
|
|
281
284
|
exampleArgs: {
|
|
@@ -349,7 +352,10 @@ const MCP_TOOL_CATALOG = [
|
|
|
349
352
|
+ 'Turning an item into an Epic is done by the human via Open as Epic in the {F} feedback panel — there is no tool '
|
|
350
353
|
+ 'for it. A finding that belongs to another local project uses feedback_open_session instead.',
|
|
351
354
|
exampleArgs: { pull: true, includeHidden: false },
|
|
352
|
-
notes: 'Returns { ok, items, pulled? }. Not-configured machines get { ok:false, error } as an error result.'
|
|
355
|
+
notes: 'Returns { ok, items, pulled? }. Not-configured machines get { ok:false, error } as an error result. '
|
|
356
|
+
+ 'A customer machine stays not-configured by design. Owner setup is one-time per machine: the host token goes in '
|
|
357
|
+
+ '~/.claude/session-manager/customer-feedback-owner.json; it cannot be minted locally. Steps: '
|
|
358
|
+
+ 'session-manager-operations/architecture/customer-feedback.md, Owner setup.',
|
|
353
359
|
},
|
|
354
360
|
{
|
|
355
361
|
name: 'customer_feedback_set_status',
|
|
@@ -161,6 +161,8 @@ const MacroSchema = z.object({
|
|
|
161
161
|
createdAt: z.string().min(1).max(64),
|
|
162
162
|
updatedAt: z.string().min(1).max(64),
|
|
163
163
|
inputs: MacroInputsSchema.optional(),
|
|
164
|
+
// Projects this macro's session may start work in without approval. Set only by the app's IPC save.
|
|
165
|
+
autoStartTargets: MacroProjectsSchema.optional(),
|
|
164
166
|
}).superRefine(refineInputs);
|
|
165
167
|
|
|
166
168
|
const MacroSaveSchema = z.object({
|
|
@@ -176,6 +178,8 @@ const MacroSaveSchema = z.object({
|
|
|
176
178
|
surface: MacroSurfaceSchema.optional(),
|
|
177
179
|
// Omitted keeps the stored list on update; `[]` clears it.
|
|
178
180
|
inputs: MacroInputsSchema.optional(),
|
|
181
|
+
// Omitted keeps the stored list on update; `[]` clears it.
|
|
182
|
+
autoStartTargets: MacroProjectsSchema.optional(),
|
|
179
183
|
}).superRefine(refineInputs);
|
|
180
184
|
|
|
181
185
|
const MacroDeleteSchema = z.object({ id: MacroIdSchema });
|
|
@@ -212,6 +216,12 @@ function macroVisibleIn(macro, cwd) {
|
|
|
212
216
|
return projects.includes(ALL_PROJECTS) || projects.includes(normalizeCwd(cwd));
|
|
213
217
|
}
|
|
214
218
|
|
|
219
|
+
/** True iff the macro may auto-start work in `toCwd`: autoStartTargets includes '*' or the normalized cwd. */
|
|
220
|
+
function macroAllowsAutoStart(macro, toCwd) {
|
|
221
|
+
const targets = (macro && macro.autoStartTargets) || [];
|
|
222
|
+
return targets.includes(ALL_PROJECTS) || targets.includes(normalizeCwd(toCwd));
|
|
223
|
+
}
|
|
224
|
+
|
|
215
225
|
function normalizeProjects(projects) {
|
|
216
226
|
const out = [];
|
|
217
227
|
for (const p of projects || []) {
|
|
@@ -511,6 +521,13 @@ async function saveMacro(input, opts = {}) {
|
|
|
511
521
|
} else {
|
|
512
522
|
saved.inputs = parsed.inputs;
|
|
513
523
|
}
|
|
524
|
+
if (parsed.autoStartTargets === undefined) {
|
|
525
|
+
// keep whatever the spread carried over
|
|
526
|
+
} else if (parsed.autoStartTargets.length === 0) {
|
|
527
|
+
delete saved.autoStartTargets;
|
|
528
|
+
} else {
|
|
529
|
+
saved.autoStartTargets = normalizeProjects(parsed.autoStartTargets);
|
|
530
|
+
}
|
|
514
531
|
assertPlaceholdersDeclared(saved);
|
|
515
532
|
macros[idx] = saved;
|
|
516
533
|
} else {
|
|
@@ -527,6 +544,9 @@ async function saveMacro(input, opts = {}) {
|
|
|
527
544
|
updatedAt: now,
|
|
528
545
|
};
|
|
529
546
|
if (parsed.inputs && parsed.inputs.length > 0) saved.inputs = parsed.inputs;
|
|
547
|
+
if (parsed.autoStartTargets && parsed.autoStartTargets.length > 0) {
|
|
548
|
+
saved.autoStartTargets = normalizeProjects(parsed.autoStartTargets);
|
|
549
|
+
}
|
|
530
550
|
assertPlaceholdersDeclared(saved);
|
|
531
551
|
macros.push(saved);
|
|
532
552
|
}
|
|
@@ -593,6 +613,7 @@ module.exports = {
|
|
|
593
613
|
defaultMacroValues,
|
|
594
614
|
renderMacroPrompt,
|
|
595
615
|
macroVisibleIn,
|
|
616
|
+
macroAllowsAutoStart,
|
|
596
617
|
listMacros,
|
|
597
618
|
saveMacro,
|
|
598
619
|
deleteMacro,
|
|
@@ -4,6 +4,9 @@
|
|
|
4
4
|
* prdDeclaredPaths.cjs — derive the file paths a PRD declares it touches, for
|
|
5
5
|
* the reverify self-heal pass's widened evidence window (PRD 1102).
|
|
6
6
|
*
|
|
7
|
+
* The PRD's `# Files` list is the declared change set and wins when present;
|
|
8
|
+
* the backtick scan of notes/criteria is only for PRDs with no Files section.
|
|
9
|
+
*
|
|
7
10
|
* Reuses definitionOfDone.cjs's existing `extractSection` (already the PRD
|
|
8
11
|
* markdown section parser used by flagRiskySurfaces) rather than
|
|
9
12
|
* re-implementing one — see standards.md's API-reuse rule.
|
|
@@ -12,6 +15,7 @@
|
|
|
12
15
|
const fs = require('node:fs');
|
|
13
16
|
const { splitFrontmatter } = require('./prdFrontmatter.cjs');
|
|
14
17
|
const { extractSection } = require('../scheduler/definitionOfDone.cjs');
|
|
18
|
+
const { parseFilesSection } = require('./prdGateFiles.cjs');
|
|
15
19
|
|
|
16
20
|
// Backtick-quoted, extension-bearing relative paths, e.g. `src/main/scheduler.cjs`
|
|
17
21
|
// or `src/main/scheduler.cjs:490` (trailing :line dropped). Requires at least
|
|
@@ -20,7 +24,9 @@ const PATH_RE = /`([a-zA-Z0-9_][\w.-]*(?:\/[\w.-]+)+\.[a-zA-Z0-9]+)(?::\d+)?`/g;
|
|
|
20
24
|
|
|
21
25
|
/**
|
|
22
26
|
* Extract declared file paths from a PRD body (frontmatter already
|
|
23
|
-
* stripped).
|
|
27
|
+
* stripped). When a `# Files` section exists, returns its file entries
|
|
28
|
+
* (folder entries ending in `/` dropped; a folders-only section yields []).
|
|
29
|
+
* Otherwise (legacy PRDs) scans the `# Implementation notes` and `# Acceptance criteria`
|
|
24
30
|
* sections only — the same sections flagRiskySurfaces and the PRD-authoring
|
|
25
31
|
* convention already treat as where files-touched are named. Returns `[]`
|
|
26
32
|
* (never fabricates a path) when neither section names one.
|
|
@@ -30,6 +36,9 @@ const PATH_RE = /`([a-zA-Z0-9_][\w.-]*(?:\/[\w.-]+)+\.[a-zA-Z0-9]+)(?::\d+)?`/g;
|
|
|
30
36
|
*/
|
|
31
37
|
function extractDeclaredPaths(prdBody) {
|
|
32
38
|
if (!prdBody || typeof prdBody !== 'string') return [];
|
|
39
|
+
if (/^#\s+Files\s*$/m.test(prdBody)) {
|
|
40
|
+
return parseFilesSection(prdBody).filter((f) => !f.endsWith('/'));
|
|
41
|
+
}
|
|
33
42
|
const text = [
|
|
34
43
|
extractSection(prdBody, 'Implementation notes'),
|
|
35
44
|
extractSection(prdBody, 'Acceptance criteria'),
|
|
@@ -67,4 +76,22 @@ function declaredPathsForPrd(prdPath) {
|
|
|
67
76
|
return extractDeclaredPaths(body);
|
|
68
77
|
}
|
|
69
78
|
|
|
70
|
-
|
|
79
|
+
/**
|
|
80
|
+
* The PRD's frontmatter `issuedAt` string, or null. Never throws — a missing
|
|
81
|
+
* or unreadable PRD, or one without the field, resolves to null.
|
|
82
|
+
*
|
|
83
|
+
* @param {string|null} prdPath
|
|
84
|
+
* @returns {string|null}
|
|
85
|
+
*/
|
|
86
|
+
function issuedAtForPrd(prdPath) {
|
|
87
|
+
if (!prdPath) return null;
|
|
88
|
+
try {
|
|
89
|
+
const { fm } = splitFrontmatter(fs.readFileSync(prdPath, 'utf8'));
|
|
90
|
+
const v = fm && fm.issuedAt;
|
|
91
|
+
return typeof v === 'string' && v ? v : (v instanceof Date && !Number.isNaN(v.getTime()) ? v.toISOString() : null);
|
|
92
|
+
} catch {
|
|
93
|
+
return null;
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
module.exports = { extractDeclaredPaths, declaredPathsForPrd, issuedAtForPrd };
|
|
@@ -31,7 +31,7 @@ const LegacyAwareEpicTagSchema = z.preprocess(
|
|
|
31
31
|
EpicTagSchema.optional(),
|
|
32
32
|
);
|
|
33
33
|
|
|
34
|
-
// Mirrors EpicSource (src/renderer/state/promptSessions.ts
|
|
34
|
+
// Mirrors EpicSource (`export interface EpicSource` in src/renderer/state/promptSessions.ts).
|
|
35
35
|
const EpicSourceSchema = z.object({
|
|
36
36
|
producer: z.enum(['new-epic-ui', 'scheduler-dispatch', 'cross-project-feedback']),
|
|
37
37
|
prdSlug: z.string().optional(),
|
|
@@ -43,6 +43,11 @@ const EpicSourceSchema = z.object({
|
|
|
43
43
|
// there is no cross-project registry anywhere else.
|
|
44
44
|
fromCwd: z.string().optional(),
|
|
45
45
|
fromEpicId: z.string().optional(),
|
|
46
|
+
// The macro that launched this Epic (new-epic-ui Epics only).
|
|
47
|
+
macroId: z.string().optional(),
|
|
48
|
+
// Zod strips undeclared keys on the merge path; a stricter shape could make dropInvalidSessions (ipcSchemas.cjs) drop a whole row holding an older or malformed value.
|
|
49
|
+
proposal: z.unknown().optional(),
|
|
50
|
+
autoApprove: z.unknown().optional(),
|
|
46
51
|
});
|
|
47
52
|
|
|
48
53
|
// Mirrors EpicIntakeSection (src/renderer/lib/epicIntake.ts) — the labeled
|