claude-code-session-manager 0.132.0 → 0.133.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.
Files changed (84) hide show
  1. package/README.md +3 -3
  2. package/dist/assets/{AgentLibrary-C09MlPFx.js → AgentLibrary-DOAG-mcG.js} +1 -1
  3. package/dist/assets/{AppSettings-DvDKsCnD.js → AppSettings-BHKM_AKh.js} +2 -2
  4. package/dist/assets/{Button-BzG_KdBC.js → Button-CmO1wmPw.js} +1 -1
  5. package/dist/assets/{DocumentEditorPane-fm6zsnLM.js → DocumentEditorPane-8QMNrNRt.js} +1 -1
  6. package/dist/assets/{Extensions-DgxKT_OZ.js → Extensions-Boo21B3b.js} +2 -2
  7. package/dist/assets/{History-Nd3bKjBq.js → History-C4epd1hp.js} +1 -1
  8. package/dist/assets/{Library-R71t6VAB.js → Library-CrgzRQzL.js} +1 -1
  9. package/dist/assets/{ListDetail-CG50Ul7c.js → ListDetail-DA7y1DQ-.js} +1 -1
  10. package/dist/assets/{Panel-C7EFG4eU.js → Panel-D-WMBhKH.js} +1 -1
  11. package/dist/assets/{ProjectClaudeConfig-J92iNEGC.js → ProjectClaudeConfig-CuUADpIu.js} +1 -1
  12. package/dist/assets/{ProvenanceBadge-C3KB3ILO.js → ProvenanceBadge-B7AsoRk6.js} +1 -1
  13. package/dist/assets/{Scheduler-DeYBA7uc.js → Scheduler-C86gRh51.js} +1 -1
  14. package/dist/assets/{Settings-B6r7N4v-.js → Settings-B4Q9DwVS.js} +1 -1
  15. package/dist/assets/{SkillReferenceGraph-D7bt3fyB.js → SkillReferenceGraph-DX4ZgvlY.js} +1 -1
  16. package/dist/assets/{Skills-GpxtUrFP.js → Skills-DqKI37yi.js} +1 -1
  17. package/dist/assets/{SourceChip-uyVMCZc7.js → SourceChip-C974LROr.js} +1 -1
  18. package/dist/assets/{SystemPrompt-Cv25uFSM.js → SystemPrompt-C502jIwO.js} +1 -1
  19. package/dist/assets/{TiptapBody-uP8fJkbM.js → TiptapBody-DwNXN6Ki.js} +1 -1
  20. package/dist/assets/{Toggle-DRs80cX-.js → Toggle-C2OsxnPK.js} +1 -1
  21. package/dist/assets/{ViewTabs-BDkvvzJ8.js → ViewTabs-DBxKGbAK.js} +1 -1
  22. package/dist/assets/{VoiceButton-Cmtz2sQt.js → VoiceButton-C680wpmX.js} +1 -1
  23. package/dist/assets/{historyTotals-DHwAXunq.js → historyTotals-Cz-VYPEc.js} +1 -1
  24. package/dist/assets/{index-oXqzajWV.css → index-CMwAikUb.css} +1 -1
  25. package/dist/assets/index-Dh5geJe3.js +3111 -0
  26. package/dist/index.html +2 -2
  27. package/dist-web/app.css +1 -1
  28. package/dist-web/app.js +427 -413
  29. package/package.json +1 -1
  30. package/src/main/build-info.json +4 -4
  31. package/src/main/chatRunner.cjs +77 -14
  32. package/src/main/index.cjs +13 -0
  33. package/src/main/ipcSchemas.cjs +54 -0
  34. package/src/main/lib/CLAUDE.md +2 -0
  35. package/src/main/lib/agent-cli/adapters/antigravity.cjs +147 -0
  36. package/src/main/lib/agent-cli/adapters/codex.cjs +170 -0
  37. package/src/main/lib/agent-cli/adapters/cursor.cjs +138 -0
  38. package/src/main/lib/agent-cli/adapters/gemini.cjs +119 -0
  39. package/src/main/lib/agent-cli/adapters/opencode.cjs +117 -0
  40. package/src/main/lib/agent-cli/agentCliEvents.cjs +94 -0
  41. package/src/main/lib/agent-cli/agentCliIpc.cjs +109 -0
  42. package/src/main/lib/agent-cli/agentCliRegistry.cjs +213 -0
  43. package/src/main/lib/agent-cli/agentCliSessionStore.cjs +152 -0
  44. package/src/main/lib/agent-cli/agentCliTurn.cjs +99 -0
  45. package/src/main/lib/app-preview/appPreviewIpc.cjs +125 -0
  46. package/src/main/lib/app-preview/appPreviewManager.cjs +317 -0
  47. package/src/main/lib/app-preview/appPreviewScripts.cjs +106 -0
  48. package/src/main/lib/app-preview/appPreviewSweep.cjs +92 -0
  49. package/src/main/lib/chatBootRecovery.cjs +41 -1
  50. package/src/main/lib/claude/agentEffortResolve.cjs +11 -3
  51. package/src/main/lib/epic/activeIndexMerge.cjs +25 -2
  52. package/src/main/lib/epic/archivedTranscript.cjs +39 -6
  53. package/src/main/lib/epic/epicChanges.cjs +466 -0
  54. package/src/main/lib/epic/epicMint.cjs +45 -1
  55. package/src/main/lib/epic/epicReopen.cjs +8 -2
  56. package/src/main/lib/epic/epicSpawnPlan.cjs +12 -0
  57. package/src/main/lib/epic/epicWorktreeMerge.cjs +39 -4
  58. package/src/main/lib/epic/promptSessionsCreateEpic.cjs +9 -4
  59. package/src/main/lib/feedback-remote/remoteIpcDispatch.cjs +2 -0
  60. package/src/main/lib/git/gitExec.cjs +9 -1
  61. package/src/main/lib/git/gitWorktree.cjs +94 -0
  62. package/src/main/lib/git/unifiedDiff.cjs +207 -0
  63. package/src/main/lib/mdDocCensus.cjs +364 -0
  64. package/src/main/lib/mdDocRefs.cjs +249 -0
  65. package/src/main/lib/mdNetworkScan.cjs +158 -15
  66. package/src/main/lib/persona-macro/macroJobDispatch.cjs +4 -1
  67. package/src/main/lib/persona-macro/macroJobIpc.cjs +1 -1
  68. package/src/main/lib/prd/prdCreate.cjs +7 -2
  69. package/src/main/lib/prd/prdFrontmatter.cjs +10 -3
  70. package/src/main/lib/promptSessionSchema.cjs +6 -0
  71. package/src/main/lib/remoteTranscriptTail.cjs +23 -4
  72. package/src/main/lib/scheduler/landedSinceRun.cjs +2 -1
  73. package/src/main/lib/scheduler/scheduleJobSchema.cjs +2 -0
  74. package/src/main/lib/scheduler/schedulerPaths.cjs +3 -0
  75. package/src/main/projectPages.cjs +14 -3
  76. package/src/main/scheduler/gitTreeGuard.cjs +2 -1
  77. package/src/main/scheduler/prdParser.cjs +2 -1
  78. package/src/main/scheduler.cjs +7 -2
  79. package/src/main/transcripts.cjs +18 -4
  80. package/src/main/webRemote.cjs +10 -5
  81. package/src/preload/api.d.ts +147 -2
  82. package/src/preload/apiSurface.json +56 -0
  83. package/src/preload/index.cjs +22 -0
  84. package/dist/assets/index-CBCdyHbZ.js +0 -3097
@@ -11,12 +11,20 @@
11
11
  * (git only lists the files), and it does I/O, so it is not util/. It sits
12
12
  * beside memoryMdNetwork.cjs, the other reader of the same docs network.
13
13
  *
14
- * - buildMdNetwork({ files, root, exists }) — pure graph builder over in-memory docs.
15
- * - scanMdNetwork(cwd, deps) — thin I/O wrapper: one `git ls-files -z`, at most
16
- * MAX_DOCS docs read (the root, then breadth-first along its links, then the
17
- * rest shallowest-first, so the cap drops unreachable docs before reachable
14
+ * - buildMdNetwork({ files, root, exists, records }) — pure graph builder over
15
+ * in-memory docs; `records` paths never appear in orphan findings.
16
+ * - scanMdNetwork(cwd, deps, opts) — thin I/O wrapper: one `git ls-files -z`, at
17
+ * most MAX_DOCS docs read (the root, then breadth-first along its links, then
18
+ * the rest shallowest-first, so the cap drops unreachable docs before reachable
18
19
  * ones), at most MAX_DOC_BYTES each, READ_BATCH reads in parallel, async fs only.
19
20
  * Untracked link targets (e.g. gitignored files) are checked on disk.
21
+ * It also attaches a per-doc census (mdDocCensus.cjs + mdDocRefs.cjs) over
22
+ * every tracked .md: one `git log --max-count=2000 --name-only` (64 MB buffer)
23
+ * for recency, one `git grep -F -o` over non-.md files (16 MB buffer) for code
24
+ * mentions, and at most MAX_REF_PROBES on-disk probes (READ_BATCH at a time)
25
+ * for backticked paths git does not vouch for — unprobed ones count as
26
+ * existing. A failing git call degrades to a census warning, never an error.
27
+ * Docs in record collections (opts.recordFolders / heuristic) leave orphans.
20
28
  *
21
29
  * Followed: inline `[text](target)` links (images too) and `<target.md>`
22
30
  * autolinks, outside code fences, inline code and HTML comments. Ignored: any
@@ -29,6 +37,8 @@
29
37
  const fs = require('node:fs');
30
38
  const path = require('node:path');
31
39
  const { execGit } = require('./git/gitExec.cjs');
40
+ const { censusMdDocs, parseGitLog } = require('./mdDocCensus.cjs');
41
+ const { backtickPaths, assessRefs, mentionPatterns, parseMentions } = require('./mdDocRefs.cjs');
32
42
 
33
43
  const ROOT_DOC = 'CLAUDE.md';
34
44
  const MAX_DOCS = 2000;
@@ -38,6 +48,11 @@ const READ_BATCH = 32;
38
48
  const MAX_LINK_CHARS = 1024;
39
49
  /** `git ls-files -z` stdout cap; node's 1 MB default overflows near 15k tracked files. */
40
50
  const LS_FILES_MAX_BUFFER = 64 * 1024 * 1024;
51
+ const LOG_ARGS = ['log', '--max-count=2000', '--no-renames', '--format=%x01%ct', '--name-only', '-z'];
52
+ const LOG_MAX_BUFFER = 64 * 1024 * 1024;
53
+ const GREP_MAX_BUFFER = 16 * 1024 * 1024;
54
+ /** On-disk probes for backticked paths git does not vouch for, per scan. */
55
+ const MAX_REF_PROBES = 500;
41
56
  const OWNER_NAMES = new Set(['CLAUDE.md', 'README.md', 'AGENTS.md']);
42
57
  const MISSING_CODES = new Set(['ENOENT', 'ENOTDIR', 'EISDIR']);
43
58
  const DETAIL_MISSING = 'The link target doesn’t exist.';
@@ -60,8 +75,12 @@ const AUTOLINK_RE = /<([^<>\s]{1,1024})>/g;
60
75
  * @typedef {{ type: 'broken-link', file: string, line: number, target: string, to: string, where: string, detail: string }} MdNetworkBrokenLink
61
76
  * @typedef {{ type: 'orphan', where: string, count: number, paths: string[], detail: string }} MdNetworkOrphan
62
77
  * @typedef {MdNetworkBrokenLink | MdNetworkOrphan} MdNetworkFinding
63
- * @typedef {{ ok: true, root: string, nodes: MdNetworkNode[], edges: MdNetworkEdge[], findings: MdNetworkFinding[], docs: number, links: number, scopes: string[] }} MdNetwork
78
+ * @typedef {{ ok: true, root: string, nodes: MdNetworkNode[], edges: MdNetworkEdge[], findings: MdNetworkFinding[], docs: number, links: number, scopes: string[] }} MdLinkNetwork
79
+ * @typedef {MdLinkNetwork | { ok: false, error: string }} MdLinkNetworkResult
80
+ * @typedef {import('./mdDocCensus.cjs').MdCensus} MdCensus
81
+ * @typedef {MdLinkNetwork & { census: MdCensus }} MdNetwork
64
82
  * @typedef {MdNetwork | { ok: false, error: string }} MdNetworkResult
83
+ * @typedef {{ recordFolders?: string[], docFolders?: string[] }} ScanOpts
65
84
  * @typedef {{ fence: string, inComment: boolean }} LineState an open code fence / HTML comment
66
85
  */
67
86
 
@@ -289,7 +308,7 @@ function orphanDetail(root, count) {
289
308
  : `No link path from ${root} reaches these ${count} docs, so agents starting there never find them.`;
290
309
  }
291
310
 
292
- /** @param {string} root @returns {MdNetworkResult} */
311
+ /** @param {string} root @returns {{ ok: false, error: string }} */
293
312
  function missingRoot(root) {
294
313
  return { ok: false, error: `no ${root} at the project root` };
295
314
  }
@@ -298,11 +317,12 @@ function missingRoot(root) {
298
317
  * Pure: the link network reachable from `root` over in-memory docs.
299
318
  * `exists(relPath)` vouches for link targets that are neither one of `files`
300
319
  * nor a folder holding one (code files, docs left unread, untracked files);
301
- * without it such targets are missing.
302
- * @param {{ files?: MdFile[], root?: string, exists?: (relPath: string) => boolean }} [input]
303
- * @returns {MdNetworkResult}
320
+ * without it such targets are missing. `records` (record-collection docs, not
321
+ * meant to be linked) are left out of orphan groups.
322
+ * @param {{ files?: MdFile[], root?: string, exists?: (relPath: string) => boolean, records?: ReadonlySet<string> }} [input]
323
+ * @returns {MdLinkNetworkResult}
304
324
  */
305
- function buildMdNetwork({ files = [], root = ROOT_DOC, exists } = {}) {
325
+ function buildMdNetwork({ files = [], root = ROOT_DOC, exists, records } = {}) {
306
326
  try {
307
327
  const rootPath = toRepoPath(root);
308
328
  /** @type {Map<string, MdFile>} */
@@ -367,7 +387,7 @@ function buildMdNetwork({ files = [], root = ROOT_DOC, exists } = {}) {
367
387
  /** @type {Map<string, string[]>} */
368
388
  const orphans = new Map();
369
389
  for (const p of docs.keys()) {
370
- if (depth.has(p)) continue;
390
+ if (depth.has(p) || (records !== undefined && records.has(p))) continue;
371
391
  const top = topFolder(p);
372
392
  const group = orphans.get(top);
373
393
  if (group) group.push(p);
@@ -429,9 +449,10 @@ function gitFailure(err) {
429
449
  * I/O: scans the git project at `cwd` and builds its network. Never throws.
430
450
  * @param {string} cwd the project root (`git ls-files` paths are relative to it)
431
451
  * @param {ScanDeps} [deps] injectable I/O; defaults are git + async fs
452
+ * @param {ScanOpts} [opts] record-collection overrides for the census
432
453
  * @returns {Promise<MdNetworkResult>}
433
454
  */
434
- async function scanMdNetwork(cwd, deps = {}) {
455
+ async function scanMdNetwork(cwd, deps = {}, opts = {}) {
435
456
  try {
436
457
  if (typeof cwd !== 'string' || cwd === '') return { ok: false, error: 'cwd must be a non-empty path' };
437
458
  /** @type {NonNullable<ScanDeps['execGit']>} */
@@ -542,11 +563,133 @@ async function scanMdNetwork(cwd, deps = {}) {
542
563
  });
543
564
  }
544
565
 
545
- return buildMdNetwork({
546
- files,
566
+ /** @param {string} p */
567
+ const vouched = (p) => !gone.has(p) && (trackedSet.has(p) || trackedFolders.has(p));
568
+ /** @param {string} p */
569
+ const present = (p) => onDisk.has(p) || vouched(p);
570
+ const network = buildMdNetwork({ files, root: ROOT_DOC, exists: present });
571
+ if (!network.ok) return network;
572
+
573
+ // ── Census ──
574
+ /** @type {string[]} */
575
+ const warnings = [];
576
+
577
+ // Recency: one capped git log; newest first, so the first sighting wins.
578
+ /** @type {import('./mdDocCensus.cjs').GitLogEntry[]} */
579
+ let log = [];
580
+ try {
581
+ const out = String(await runGit(cwd, LOG_ARGS, { maxBuffer: LOG_MAX_BUFFER }));
582
+ log = parseGitLog(out);
583
+ if (log.length === 0 && out.trim() !== '') warnings.push('git history unavailable: unparseable git log output');
584
+ } catch (err) {
585
+ warnings.push(`git history unavailable: ${gitFailure(err)}`);
586
+ }
587
+ /** @type {Map<string, number>} */
588
+ const lastCommit = new Map();
589
+ for (const entry of log) {
590
+ for (const f of entry.files) if (!lastCommit.has(f)) lastCommit.set(f, entry.ms);
591
+ }
592
+ /** @param {string} p */
593
+ const lastCommitOf = (p) => lastCommit.get(p) ?? null;
594
+
595
+ /** @type {Map<string, { depth: number, linkedFrom: number }>} */
596
+ const reachable = new Map(network.nodes.map((n) => [n.path, { depth: n.depth, linkedFrom: n.linkedFrom }]));
597
+ /** @type {Map<string, MdFile>} */
598
+ const readByPath = new Map(files.map((f) => [f.path, f]));
599
+
600
+ // Backticked paths git does not vouch for: probed on disk, capped; the rest count as existing.
601
+ /** @type {Map<string, boolean>} */
602
+ const probed = new Map();
603
+ /** @type {string[]} */
604
+ const toProbe = [];
605
+ const queuedProbes = new Set();
606
+ /** @type {Map<MdFile, string[]>} */
607
+ const tokensOf = new Map();
608
+ for (const file of files) {
609
+ const tokens = backtickPaths(file.text);
610
+ tokensOf.set(file, tokens);
611
+ const dir = path.posix.dirname(file.path);
612
+ for (const tok of tokens) {
613
+ const rootForm = toRepoPath(tok);
614
+ const forms = dir === '.' ? [rootForm] : [rootForm, toRepoPath(path.posix.join(dir, tok))];
615
+ for (const rel of forms) {
616
+ if (rel === '.' || rel === '..' || rel.startsWith('../')) continue;
617
+ if (vouched(rel)) break; // assessRefs takes the first existing form
618
+ if (onDisk.has(rel) || queuedProbes.has(rel) || toProbe.length >= MAX_REF_PROBES) continue;
619
+ queuedProbes.add(rel);
620
+ toProbe.push(rel);
621
+ }
622
+ }
623
+ }
624
+ for (let i = 0; i < toProbe.length; i += READ_BATCH) {
625
+ const batch = toProbe.slice(i, i + READ_BATCH);
626
+ const hits = await Promise.all(batch.map(probe));
627
+ batch.forEach((rel, k) => probed.set(rel, hits[k]));
628
+ }
629
+ /** @param {string} p */
630
+ const refExists = (p) => {
631
+ if (present(p)) return true;
632
+ if (gone.has(p)) return false;
633
+ const hit = probed.get(p);
634
+ return hit === undefined ? true : hit;
635
+ };
636
+
637
+ /** @type {Map<string, import('./mdDocCensus.cjs').MdDocRefs>} */
638
+ const refs = new Map();
639
+ for (const file of files) {
640
+ const linkTargets = linksOf(file)
641
+ .filter((l) => !l.escapes && present(l.to))
642
+ .map((l) => l.to);
643
+ refs.set(
644
+ file.path,
645
+ assessRefs({
646
+ docPath: file.path,
647
+ linkTargets,
648
+ tokens: tokensOf.get(file) ?? [],
649
+ docMs: lastCommitOf(file.path),
650
+ exists: refExists,
651
+ lastCommitOf,
652
+ }),
653
+ );
654
+ }
655
+
656
+ // Code mentions: one git grep over every non-.md tracked file.
657
+ /** @type {Map<string, string[]>} */
658
+ let codeMentions = new Map();
659
+ const { patterns, owner } = mentionPatterns(docPaths);
660
+ if (patterns.length > 0) {
661
+ const grepArgs = ['grep', '--no-color', '-I', '-F', '-o', '--null', ...patterns.flatMap((p) => ['-e', p]), '--', '.', ':(exclude)*.md'];
662
+ try {
663
+ codeMentions = parseMentions(String(await runGit(cwd, grepArgs, { maxBuffer: GREP_MAX_BUFFER })), owner);
664
+ } catch (err) {
665
+ const stderr = errorField(err, 'stderrText');
666
+ const noMatches = errorField(err, 'code') === 1 && !(typeof stderr === 'string' && stderr.trim() !== '');
667
+ if (!noMatches) warnings.push(`code mentions unavailable: ${gitFailure(err)}`);
668
+ }
669
+ }
670
+
671
+ const docs = docPaths.map((p) => {
672
+ const file = readByPath.get(p);
673
+ if (!file) return { path: p, text: null, lines: null, bytes: null };
674
+ const { text } = file;
675
+ return { path: p, text, lines: text === '' ? 0 : text.split('\n').length, bytes: Buffer.byteLength(text) };
676
+ });
677
+ const census = censusMdDocs({
547
678
  root: ROOT_DOC,
548
- exists: (p) => onDisk.has(p) || (!gone.has(p) && (trackedSet.has(p) || trackedFolders.has(p))),
679
+ docs,
680
+ reachable,
681
+ log,
682
+ refs,
683
+ codeMentions,
684
+ recordFolders: opts.recordFolders,
685
+ docFolders: opts.docFolders,
549
686
  });
687
+ census.warnings.unshift(...warnings);
688
+
689
+ const records = new Set(census.docs.filter((d) => d.role === 'record').map((d) => d.path));
690
+ if (records.size === 0) return { ...network, census };
691
+ const pruned = buildMdNetwork({ files, root: ROOT_DOC, exists: present, records });
692
+ return pruned.ok ? { ...pruned, census } : pruned;
550
693
  } catch (err) {
551
694
  return { ok: false, error: errorText(err) };
552
695
  }
@@ -5,6 +5,7 @@
5
5
  * scheduler PRD inside an existing Epic, so the build runs headless as the
6
6
  * macro's persona under the scheduler's budget instead of a chat turn.
7
7
  * Never mints an Epic (single-creator law): the caller supplies epicId.
8
+ * A press may carry a lower per-run effort, written as the PRD's `effort` frontmatter.
8
9
  *
9
10
  * Plain Node, no Electron imports; all I/O is injected.
10
11
  */
@@ -12,6 +13,7 @@
12
13
  const path = require('node:path');
13
14
  const { BUILTIN_MACROS } = require('./builtinMacros.cjs');
14
15
  const { kebabCase } = require('../util/kebabCase.cjs');
16
+ const { PRD_EFFORT_LEVELS } = require('../prd/prdFrontmatter.cjs');
15
17
 
16
18
  const ACTIVE = new Set(['pending', 'held', 'running']);
17
19
  const RETRYABLE = new Set(['needs_review', 'failed']);
@@ -54,7 +56,7 @@ function rawEntryIdFor(kind, extra, t) {
54
56
  }
55
57
 
56
58
  async function dispatchMacroJob(
57
- { cwd, macroId, epicId, extraInstructions } = {},
59
+ { cwd, macroId, epicId, extraInstructions, effort } = {},
58
60
  { createPrd, listRows, archivePrd, builtins = BUILTIN_MACROS, now = Date.now } = {},
59
61
  ) {
60
62
  const macro = (builtins || []).find((m) => m && m.id === macroId);
@@ -117,6 +119,7 @@ async function dispatchMacroJob(
117
119
  + 'Build outside the repository (mktemp -d under ~/.cache). SM_PROJECT_ROOT is the project main checkout; the save tool writes there, so omit its cwd.',
118
120
  gate: absPaths.map((p) => buildGate(p, t)),
119
121
  };
122
+ if (typeof effort === 'string' && PRD_EFFORT_LEVELS.includes(effort)) input.effort = effort;
120
123
 
121
124
  let res;
122
125
  try {
@@ -66,7 +66,7 @@ function registerMacroJobIpc(ipcMain, deps = {}) {
66
66
  let result;
67
67
  try {
68
68
  result = await dispatch(
69
- { cwd, macroId: payload.macroId, epicId: payload.epicId, extraInstructions: payload.extraInstructions },
69
+ { cwd, macroId: payload.macroId, epicId: payload.epicId, extraInstructions: payload.extraInstructions, effort: payload.effort },
70
70
  {
71
71
  createPrd: deps.createPrd,
72
72
  listRows: async () => deps.loadJobs(),
@@ -32,7 +32,7 @@ const { resolveDepSlug, findNearMatches } = require('./depSlugResolve.cjs');
32
32
  const { resolveEpicPrdWriteDir } = require('./prdLocations.cjs');
33
33
  const { isFixPlanSlug } = require('../scheduler/fixPlanSlug.cjs');
34
34
  const { isIncomplete, resolveChainTerminals, isValidPlanId, mintPlanId, resolveInheritedPlanId } = require('./prdDisposition.cjs');
35
- const { splitFrontmatter } = require('./prdFrontmatter.cjs');
35
+ const { splitFrontmatter, PRD_EFFORT_LEVELS } = require('./prdFrontmatter.cjs');
36
36
  const { sizingWarnings } = require('./prdSizing.cjs');
37
37
  const telemetryCounters = require('../telemetry/telemetryCounters.cjs');
38
38
  const { execGit } = require('../git/gitExec.cjs');
@@ -89,7 +89,7 @@ function isValidMacroId(id) {
89
89
  function buildPrdBody(input) {
90
90
  const {
91
91
  title, cwd, estimateMinutes, goal, acceptanceCriteria,
92
- implementationNotes, outOfScope, sourcePromptId, sourceTabId, tag, agentType, dependsOn, quietMachine, disposition, deliverable, artifactPaths, planId, macroId,
92
+ implementationNotes, outOfScope, sourcePromptId, sourceTabId, tag, agentType, dependsOn, quietMachine, disposition, deliverable, artifactPaths, planId, macroId, effort,
93
93
  gate, files, budgetExempt,
94
94
  } = input;
95
95
 
@@ -143,6 +143,7 @@ function buildPrdBody(input) {
143
143
  // sibling jobs would otherwise invalidate. Only emitted when true — see
144
144
  // prdFrontmatter.cjs's applyKey for the matching "only true opts in" parse.
145
145
  if (isValidMacroId(macroId)) fmLines.push(`macroId: ${macroId}`);
146
+ if (PRD_EFFORT_LEVELS.includes(effort)) fmLines.push(`effort: ${effort}`);
146
147
  if (quietMachine === true) fmLines.push('quietMachine: true');
147
148
  // Budget exemption is for a sweep validator that cannot be split further;
148
149
  // every other caller's budgetExempt is ignored.
@@ -429,6 +430,10 @@ async function createPrdInner(input, remote, ctl, opts = {}) {
429
430
  if (input.macroId != null && !isValidMacroId(input.macroId)) {
430
431
  return { ok: false, applied: false, status: 400, error: 'macroId must match /^[A-Za-z0-9][A-Za-z0-9._-]{0,127}$/ when given' };
431
432
  }
433
+ // effort (in-process callers only: macroJobDispatch.cjs)
434
+ if (input.effort != null && !PRD_EFFORT_LEVELS.includes(input.effort)) {
435
+ return { ok: false, applied: false, status: 400, error: 'effort must be one of low, medium, high, xhigh, max when given' };
436
+ }
432
437
 
433
438
  // Fake-heading guard (gate-and-files-in-PRD-body unit): a caller-supplied
434
439
  // free-text field that itself contains a "# Gate" or "# Files" heading line
@@ -77,8 +77,11 @@ function splitFrontmatter(raw) {
77
77
  * never emitted, which is how `scheduler_update_prd` clears a dependency.
78
78
  */
79
79
 
80
- const RECOGNIZED_KEYS = new Set(['title', 'cwd', 'estimateMinutes', 'parallelGroup', 'sourcePromptId', 'sourceTabId', 'tag', 'agentType', 'createdVia', 'issuedAt', 'dependsOn', 'quietMachine', 'disposition', 'planId', 'deliverable', 'artifactPaths', 'macroId']);
81
- const EMIT_ORDER = ['title', 'cwd', 'estimateMinutes', 'parallelGroup', 'sourcePromptId', 'sourceTabId', 'tag', 'agentType', 'createdVia', 'issuedAt', 'dependsOn', 'quietMachine', 'disposition', 'planId', 'deliverable', 'artifactPaths', 'macroId'];
80
+ const RECOGNIZED_KEYS = new Set(['title', 'cwd', 'estimateMinutes', 'parallelGroup', 'sourcePromptId', 'sourceTabId', 'tag', 'agentType', 'createdVia', 'issuedAt', 'dependsOn', 'quietMachine', 'disposition', 'planId', 'deliverable', 'artifactPaths', 'macroId', 'effort']);
81
+ const EMIT_ORDER = ['title', 'cwd', 'estimateMinutes', 'parallelGroup', 'sourcePromptId', 'sourceTabId', 'tag', 'agentType', 'createdVia', 'issuedAt', 'dependsOn', 'quietMachine', 'disposition', 'planId', 'deliverable', 'artifactPaths', 'macroId', 'effort'];
82
+ // Mirrors modelCatalog.cjs CATALOG_FLOOR.effortLevels. A closed set so the
83
+ // value is always safe as a frontmatter line and as a --effort argv token.
84
+ const PRD_EFFORT_LEVELS = Object.freeze(['low', 'medium', 'high', 'xhigh', 'max']);
82
85
  const MACRO_ID_RE = /^[A-Za-z0-9][A-Za-z0-9._-]{0,127}$/;
83
86
  const FRONTMATTER_RE = /^---\r?\n([\s\S]*?)\r?\n---\r?\n?([\s\S]*)$/;
84
87
 
@@ -199,6 +202,10 @@ function applyKey(fm, key, after) {
199
202
  // Id of the macro whose press dispatched this PRD; anything off-pattern is dropped.
200
203
  if (typeof v === 'string' && MACRO_ID_RE.test(v.trim())) fm.macroId = v.trim();
201
204
  return;
205
+ case 'effort':
206
+ // In-process-only per-PRD effort override; anything outside PRD_EFFORT_LEVELS is dropped.
207
+ if (typeof v === 'string' && PRD_EFFORT_LEVELS.includes(v.trim())) fm.effort = v.trim();
208
+ return;
202
209
  case 'artifactPaths': {
203
210
  // Inline `[a, b]` list, same shape as dependsOn.
204
211
  const list = parseInlineList(after);
@@ -315,4 +322,4 @@ function serializePrdFile(fm, body) {
315
322
  return `---\n${fmText}\n---\n${body}`;
316
323
  }
317
324
 
318
- module.exports = { splitFrontmatter, parsePrdFile, serializePrdFile, RECOGNIZED_KEYS };
325
+ module.exports = { splitFrontmatter, parsePrdFile, serializePrdFile, RECOGNIZED_KEYS, PRD_EFFORT_LEVELS };
@@ -97,6 +97,12 @@ const PromptSessionSchema = z.object({
97
97
  // false = started with the develop loop (/develop skill, delegation guard, PRD queueing) switched off;
98
98
  // fixed for the life of its session; absent = on; only false is ever written.
99
99
  developLoop: z.boolean().optional(),
100
+ // The agent CLI that runs this Epic's session; absent = Claude Code. Fixed for the life of the
101
+ // session. Deliberately a bounded string, not an enum: a row written by a newer build naming a CLI
102
+ // this build doesn't know must never be dropped by dropInvalidSessions (ipcSchemas.cjs).
103
+ agentCli: z.string().max(32).optional(),
104
+ // Optional model string passed to that CLI; absent = the CLI's own default.
105
+ agentCliModel: z.string().max(128).optional(),
100
106
  // true = this Epic adopted an existing CLI session as its claudeSessionId
101
107
  // (ensureEpic's restoreSessionId) instead of a fresh one; absent otherwise.
102
108
  // Only true is ever written: a false would fail here, and dropInvalidSessions
@@ -6,6 +6,7 @@
6
6
  // Top-level (no domain fits: epic/ transcripts are path-only; util/ is domain-free).
7
7
  // Transcripts reach hundreds of MB, so cost is O(maxBytes), never O(file).
8
8
 
9
+ const fs = require('node:fs');
9
10
  const fsp = require('node:fs/promises');
10
11
 
11
12
  const DEFAULT_LIMIT = 30;
@@ -58,12 +59,30 @@ function toChatMessage(line) {
58
59
  }
59
60
 
60
61
  /**
61
- * @param {string} filePath
62
- * @param {{ limit?: number, maxBytes?: number }} [opts]
62
+ * Agent-CLI (non-Claude) Epics write a Claude-compatible transcript under
63
+ * agentCliSessionStore instead of ~/.claude/projects.
64
+ * @param {unknown} claudeSessionId
65
+ * @returns {string|null} that file's path when it exists; null otherwise,
66
+ * including for a non-UUID id (the store's validation error is swallowed).
67
+ */
68
+ function agentCliTranscriptPath(claudeSessionId) {
69
+ if (typeof claudeSessionId !== 'string' || !claudeSessionId) return null;
70
+ try {
71
+ const p = require('./agent-cli/agentCliSessionStore.cjs').transcriptPathFor(claudeSessionId);
72
+ return fs.existsSync(p) ? p : null;
73
+ } catch {
74
+ return null;
75
+ }
76
+ }
77
+
78
+ /**
79
+ * @param {string} filePath the Claude transcript path (used when no agent-CLI file exists)
80
+ * @param {{ limit?: number, maxBytes?: number, claudeSessionId?: string }} [opts]
63
81
  * @returns {Promise<Array<{ role: 'user'|'assistant', text: string, ts: string|null, uuid: string|null }>>}
64
82
  * oldest first; [] on any read failure.
65
83
  */
66
- async function readRecentChatMessages(filePath, { limit = DEFAULT_LIMIT, maxBytes = DEFAULT_MAX_BYTES } = {}) {
84
+ async function readRecentChatMessages(filePath, { limit = DEFAULT_LIMIT, maxBytes = DEFAULT_MAX_BYTES, claudeSessionId } = {}) {
85
+ filePath = agentCliTranscriptPath(claudeSessionId) ?? filePath;
67
86
  if (typeof filePath !== 'string' || !filePath) return [];
68
87
  const n = Math.floor(Number(limit));
69
88
  const lim = Number.isFinite(n) ? Math.min(MAX_LIMIT, Math.max(1, n)) : DEFAULT_LIMIT;
@@ -154,4 +173,4 @@ function buildRemoteConversation({ exchanges = [], tail = [], limit = 10, before
154
173
  return { messages: [...history, ...live], hasMore, nextBefore: hasMore ? b + returned : null };
155
174
  }
156
175
 
157
- module.exports = { readRecentChatMessages, buildRemoteConversation };
176
+ module.exports = { readRecentChatMessages, buildRemoteConversation, agentCliTranscriptPath };
@@ -44,7 +44,8 @@ function landedSinceRun(cwd, sinceIso, paths, { timeoutMs = LANDED_SINCE_RUN_TIM
44
44
  }
45
45
  execFile(
46
46
  'git',
47
- ['-C', cwd, 'log', `--exclude=${STRANDED_REF_PREFIX}*`, '--all', `--since=${sinceIso}`, '--format=%H', '--', ...paths],
47
+ // refs/sm-epic-review/* holds Epic Changes pin/snapshot commits — never a job's evidence.
48
+ ['-C', cwd, 'log', `--exclude=${STRANDED_REF_PREFIX}*`, '--exclude=refs/sm-epic-review/*', '--all', `--since=${sinceIso}`, '--format=%H', '--', ...paths],
48
49
  { timeout: timeoutMs, windowsHide: true },
49
50
  (err, stdout) => {
50
51
  if (err) { resolve([]); return; }
@@ -95,6 +95,8 @@ const ScheduleJobSchema = z
95
95
  epicId: z.string().nullable().optional(),
96
96
  // Macro press this job's PRD came from (PRD frontmatter `macroId`).
97
97
  macroId: z.string().nullable().optional(),
98
+ // PRD frontmatter `effort` — a per-run level from a macro press (outranks the persona's).
99
+ effort: z.string().nullable().optional(),
98
100
  statusHistory: z.array(ScheduleJobStatusHistoryEntrySchema).optional(),
99
101
  // Opt-in exclusive-lease PRD flag (PRD 1107) — serializes this job against
100
102
  // every other job machine-wide for its run so a timing-sensitive gate
@@ -123,6 +123,8 @@ function historyRollupCursorPath() { return assertNotLiveRoot(path.join(schedule
123
123
  function historyRollupLockPath() { return assertNotLiveRoot(path.join(schedulerHome(), 'history-rollup.lock'), 'historyRollupLockPath'); }
124
124
  function historyRollupPath() { return path.join(schedulerHome(), 'history-rollup.jsonl'); }
125
125
  function auditLogPath() { return path.join(schedulerHome(), 'audit-log.jsonl'); }
126
+ /** Non-Claude agent-CLI session sidecars and transcripts (agent-cli/agentCliSessionStore.cjs). */
127
+ function agentCliStateRoot() { return assertNotLiveRoot(path.join(schedulerHome(), 'agent-cli'), 'agentCliStateRoot'); }
126
128
  function procnamesRoot() { return path.join(schedulerHome(), 'procnames'); }
127
129
  /** Legacy global history sidecar (read-only; new appends go to per-project shards). */
128
130
  function queueHistoryPath() { return path.join(scheduledPlansRoot(), 'history.jsonl'); }
@@ -212,6 +214,7 @@ module.exports = {
212
214
  historyRollupPath,
213
215
  auditLogPath,
214
216
  procnamesRoot,
217
+ agentCliStateRoot,
215
218
  queueHistoryPath,
216
219
  instanceLockPath,
217
220
  heapSnapshotDir,
@@ -93,16 +93,27 @@ async function get({ cwd }) {
93
93
 
94
94
  const MD_NETWORK_EPHEMERAL = 'refusing an ephemeral cwd (tmpdir or linked git worktree): no project to scan';
95
95
 
96
+ /** Strip trailing slashes ('docs/' -> 'docs'); undefined stays undefined. */
97
+ const stripTrailingSlashes = (folders) => folders && folders.map((f) => f.replace(/\/+$/, ''));
98
+
96
99
  /**
97
100
  * -> MdNetworkResult: the project's markdown link network from its root
98
101
  * CLAUDE.md, scanned once per call (no watcher, no cache). `cwd` is validated
99
102
  * like get() (an invalid path rejects); a cwd get() answers with EMPTY() gets
100
103
  * `{ ok: false, error }`.
104
+ *
105
+ * `recordFolders` / `docFolders` are a human's census overrides (mark a folder
106
+ * as machine-written records, or as real docs). They are only repo-relative
107
+ * path prefixes for classification and never reach the file system — only
108
+ * `cwd` is a path that is resolved or read.
101
109
  */
102
- async function mdNetwork({ cwd }) {
110
+ async function mdNetwork({ cwd, recordFolders, docFolders }) {
103
111
  const { root, ephemeral } = tryProjectRoot(config.validatePath(cwd));
104
112
  if (ephemeral) return { ok: false, error: MD_NETWORK_EPHEMERAL };
105
- return scanMdNetwork(root);
113
+ return scanMdNetwork(root, {}, {
114
+ recordFolders: stripTrailingSlashes(recordFolders),
115
+ docFolders: stripTrailingSlashes(docFolders),
116
+ });
106
117
  }
107
118
 
108
119
  const MATRIX_EPHEMERAL = 'refusing an ephemeral cwd (tmpdir or linked git worktree): no project matrix';
@@ -294,7 +305,7 @@ async function deleteEntry(input) {
294
305
  function registerProjectPagesIpc() {
295
306
  const { schemas: s, validated: v } = require('./ipcSchemas.cjs');
296
307
  ipcMain.handle('project-pages:get', v(s.projectPagesCwd, get));
297
- ipcMain.handle('project-pages:md-network', v(s.projectPagesCwd, mdNetwork));
308
+ ipcMain.handle('project-pages:md-network', v(s.projectPagesMdNetwork, mdNetwork));
298
309
  ipcMain.handle('project-pages:matrix', v(s.projectPagesCwd, matrix));
299
310
  ipcMain.handle('project-pages:watch', v(s.projectPagesCwd, ({ cwd }) => watchOutput(cwd)));
300
311
  ipcMain.handle('project-pages:rename', v(s.projectPagesRename, renameEntry));
@@ -418,7 +418,8 @@ async function committedInWindow(cwd, startedAt, finishedAt) {
418
418
  : new Date().toISOString();
419
419
  execFile(
420
420
  'git',
421
- ['-C', cwd, 'log', `--exclude=${sharedGitExec.STRANDED_REF_PREFIX}*`, '--all', '--format=%H', `--since=${startedAt}`, `--until=${until}`],
421
+ // refs/sm-epic-review/* holds Epic Changes pin/snapshot commits — never a job's evidence.
422
+ ['-C', cwd, 'log', `--exclude=${sharedGitExec.STRANDED_REF_PREFIX}*`, '--exclude=refs/sm-epic-review/*', '--all', '--format=%H', `--since=${startedAt}`, `--until=${until}`],
422
423
  { timeout: 10_000, windowsHide: true },
423
424
  (err, stdout) => { resolve(!err && String(stdout || '').trim().length > 0); },
424
425
  );
@@ -17,7 +17,7 @@ const fs = require('node:fs');
17
17
  const fsp = require('node:fs/promises');
18
18
  const os = require('node:os');
19
19
  const path = require('node:path');
20
- const { splitFrontmatter } = require('../lib/prd/prdFrontmatter.cjs');
20
+ const { splitFrontmatter, PRD_EFFORT_LEVELS } = require('../lib/prd/prdFrontmatter.cjs');
21
21
  const { deriveEpicIdFromPrdPath } = require('../lib/prd/prdLocations.cjs');
22
22
  const { parseFilesSection } = require('../lib/prd/prdGateFiles.cjs');
23
23
  const { reportDanglingAgentTypeOnce } = require('../lib/prd/prdAgentType.cjs');
@@ -133,6 +133,7 @@ async function parsePrdRaw(filePath) {
133
133
  planId: (typeof fm.planId === 'string' && /^[A-Za-z0-9][A-Za-z0-9_-]{0,63}$/.test(fm.planId)) ? fm.planId : null,
134
134
  // Macro press that minted this PRD (prdFrontmatter.cjs MACRO_ID_RE); malformed reads as absent.
135
135
  macroId: (typeof fm.macroId === 'string' && /^[A-Za-z0-9][A-Za-z0-9._-]{0,127}$/.test(fm.macroId.trim())) ? fm.macroId.trim() : null,
136
+ effort: (typeof fm.effort === 'string' && PRD_EFFORT_LEVELS.includes(fm.effort.trim())) ? fm.effort.trim() : null,
136
137
  // Opt-in exclusive-lease flag (PRD 1107, quietMachineLease.cjs +
137
138
  // schedulerBatch.cjs's pickNextBatch). Only a literal `true` opts in —
138
139
  // matches prdFrontmatter.cjs's applyKey semantics for this field.
@@ -1850,6 +1850,7 @@ async function reconcilePass(state) {
1850
1850
  bodyPreview: p.body.split('\n').slice(0, 6).join('\n'),
1851
1851
  agentType: p.agentType ?? job.agentType ?? null,
1852
1852
  macroId: p.macroId ?? job.macroId ?? null,
1853
+ effort: p.effort ?? job.effort ?? null,
1853
1854
  };
1854
1855
  // Adopt path: a row parked 'quarantined' (no createdVia provenance when
1855
1856
  // discovered) whose PRD file now carries a stamp — written via the
@@ -1974,6 +1975,7 @@ async function reconcilePass(state) {
1974
1975
  bodyPreview: p.body.split('\n').slice(0, 6).join('\n'),
1975
1976
  agentType: p.agentType ?? inv.row?.agentType ?? null,
1976
1977
  macroId: p.macroId ?? inv.row?.macroId ?? null,
1978
+ effort: p.effort ?? inv.row?.effort ?? null,
1977
1979
  };
1978
1980
  const reason = `reconcile: repaired invalid status ${JSON.stringify(oldStatus)}`;
1979
1981
  // A repair is not a lifecycle transition — the corrupted `status` was
@@ -2126,6 +2128,7 @@ async function reconcilePass(state) {
2126
2128
  bodyPreview: p.body.split('\n').slice(0, 6).join('\n'),
2127
2129
  agentType: p.agentType ?? null,
2128
2130
  macroId: p.macroId ?? null,
2131
+ effort: p.effort ?? null,
2129
2132
  status: 'pending',
2130
2133
  // Enqueue time (PRD 1086/1087): the cross-project fairness tiebreak and
2131
2134
  // the starvation escalation both need a provable age for a pending row;
@@ -4910,9 +4913,10 @@ async function executeJob(job, runDir, defaultCwd, onPid, execCwd, resumeTarget
4910
4913
  // a dangling/absent agentType falls back to no persona + FALLBACK_MODEL
4911
4914
  // and is logged once by resolvePrdPersonaForSpawn itself.
4912
4915
  const personaResolution = await agentModelResolve.resolvePrdPersonaForSpawn({ cwd, agentType: job.agentType });
4913
- const personaEffort = resolveEpicEffort({ cwd, agentType: job.agentType }).effort;
4916
+ const effortResolution = resolveEpicEffort({ cwd, agentType: job.agentType, prdEffort: job.effort });
4917
+ const personaEffort = effortResolution.effort;
4914
4918
  const personaToolScope = buildPersonaToolScope(personaResolution.tools, { disallowed: HEADLESS_DISALLOWED_TOOLS });
4915
- safeLog(`[scheduler] agentType=${job.agentType || '(none)'} persona=${personaResolution.personaPath || '(fallback — no persona applied)'} model=${personaResolution.model}${personaEffort ? ` effort=${personaEffort}` : ''} ${personaToolScope ? `tools=${personaToolScope.tools.length} scoped` : 'tools=unscoped'}\n`);
4919
+ safeLog(`[scheduler] agentType=${job.agentType || '(none)'} persona=${personaResolution.personaPath || '(fallback — no persona applied)'} model=${personaResolution.model}${personaEffort ? ` effort=${personaEffort}${effortResolution.source === 'prd' ? ' (prd)' : ''}` : ''} ${personaToolScope ? `tools=${personaToolScope.tools.length} scoped` : 'tools=unscoped'}\n`);
4916
4920
 
4917
4921
  // Authoritative guarantee that buildClaudeSpawnArgs (a pure sync helper,
4918
4922
  // called below via withChildAndLog) sees a resolved --permission-prompts
@@ -11603,6 +11607,7 @@ async function listPrdsInternal({ cwd: rawCwd } = {}) {
11603
11607
  dependsOn: parsed.dependsOn ?? null,
11604
11608
  agentType: parsed.agentType ?? null,
11605
11609
  macroId: parsed.macroId ?? null,
11610
+ effort: parsed.effort ?? null,
11606
11611
  disposition: parsed.disposition ?? null,
11607
11612
  planId: parsed.planId ?? null,
11608
11613
  mtimeMs: stat.mtimeMs,
@@ -40,14 +40,28 @@ const { encodeCwd } = require('./lib/util/encodeCwd.cjs');
40
40
  const { LRUCache } = require('./lib/util/lruCache.cjs');
41
41
  const { classifyLine } = require('./lib/classifyTranscriptLine.cjs');
42
42
  const { resolveEpicTranscriptPath } = require('./lib/epic/epicTranscriptPath.cjs');
43
+ const agentCliSessionStore = require('./lib/agent-cli/agentCliSessionStore.cjs');
44
+
45
+ /** Agent-CLI (non-Claude) Epic transcript path when that file exists, else null. Never throws. */
46
+ function agentCliTranscriptIfExists(sessionUuid) {
47
+ try {
48
+ const p = agentCliSessionStore.transcriptPathFor(sessionUuid);
49
+ return fs.existsSync(p) ? p : null;
50
+ } catch {
51
+ return null; // invalid (non-UUID) id — not an agent-CLI session
52
+ }
53
+ }
43
54
 
44
55
  /**
45
- * Where the CLI's JSONL for this session lives. Epic sessions run in a
46
- * worktree, so the resolver checks the worktree encoding as well as the
47
- * project one; a non-Epic tab resolves to the plain project-encoded path.
48
- * Sync + absolute always (falls back to the plain path on invalid input).
56
+ * Where the CLI's JSONL for this session lives. A non-Claude agent-CLI Epic's
57
+ * Claude-compatible JSONL (agentCliSessionStore) wins when it exists. Epic
58
+ * sessions run in a worktree, so the resolver checks the worktree encoding as
59
+ * well as the project one; a non-Epic tab resolves to the plain project-encoded
60
+ * path. Sync + absolute always (falls back to the plain path on invalid input).
49
61
  */
50
62
  function resolveTranscript(cwd, sessionUuid) {
63
+ const agentPath = agentCliTranscriptIfExists(sessionUuid);
64
+ if (agentPath) return { filePath: agentPath, existsAnywhere: true };
51
65
  const r = resolveEpicTranscriptPath({ cwd, claudeSessionId: sessionUuid });
52
66
  const filePath = r.path || path.join(os.homedir(), '.claude', 'projects', encodeCwd(cwd), `${sessionUuid}.jsonl`);
53
67
  return { filePath, existsAnywhere: !!r.existsAnywhere };