claude-code-session-manager 0.131.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 (90) hide show
  1. package/README.md +3 -3
  2. package/dist/assets/{AgentLibrary-CYXre0J-.js → AgentLibrary-DOAG-mcG.js} +1 -1
  3. package/dist/assets/{AppSettings-xNSfCj8e.js → AppSettings-BHKM_AKh.js} +2 -2
  4. package/dist/assets/{Button-BWljh5IK.js → Button-CmO1wmPw.js} +1 -1
  5. package/dist/assets/{DocumentEditorPane-FUC2hZlp.js → DocumentEditorPane-8QMNrNRt.js} +1 -1
  6. package/dist/assets/{Extensions-CsyUoklz.js → Extensions-Boo21B3b.js} +2 -2
  7. package/dist/assets/{History-BvNmY9OQ.js → History-C4epd1hp.js} +1 -1
  8. package/dist/assets/{Library-DVXk77zA.js → Library-CrgzRQzL.js} +1 -1
  9. package/dist/assets/{ListDetail-DAAx__24.js → ListDetail-DA7y1DQ-.js} +1 -1
  10. package/dist/assets/{Panel-g2D-e-RM.js → Panel-D-WMBhKH.js} +1 -1
  11. package/dist/assets/{ProjectClaudeConfig-BDuHJwaO.js → ProjectClaudeConfig-CuUADpIu.js} +1 -1
  12. package/dist/assets/{ProvenanceBadge-wew4_nf3.js → ProvenanceBadge-B7AsoRk6.js} +1 -1
  13. package/dist/assets/{Scheduler-CbeUIqD-.js → Scheduler-C86gRh51.js} +1 -1
  14. package/dist/assets/{Settings-B23RsRfm.js → Settings-B4Q9DwVS.js} +1 -1
  15. package/dist/assets/{SkillReferenceGraph-BxQPCfsg.js → SkillReferenceGraph-DX4ZgvlY.js} +1 -1
  16. package/dist/assets/{Skills-4AR2FQrI.js → Skills-DqKI37yi.js} +1 -1
  17. package/dist/assets/{SourceChip-jrC0vjfw.js → SourceChip-C974LROr.js} +1 -1
  18. package/dist/assets/{SystemPrompt-hHoBEnYb.js → SystemPrompt-C502jIwO.js} +1 -1
  19. package/dist/assets/{TiptapBody-FkUqxO9u.js → TiptapBody-DwNXN6Ki.js} +1 -1
  20. package/dist/assets/{Toggle-DQMNWZKT.js → Toggle-C2OsxnPK.js} +1 -1
  21. package/dist/assets/{ViewTabs-DGU0ZuxB.js → ViewTabs-DBxKGbAK.js} +1 -1
  22. package/dist/assets/{VoiceButton-BPPvDllh.js → VoiceButton-C680wpmX.js} +1 -1
  23. package/dist/assets/{historyTotals-D8Oc3wUK.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 +428 -414
  29. package/package.json +1 -1
  30. package/scripts/scheduler-mcp-server.cjs +12 -4
  31. package/src/main/build-info.json +4 -4
  32. package/src/main/chatRunner.cjs +77 -14
  33. package/src/main/index.cjs +15 -0
  34. package/src/main/ipcSchemas.cjs +54 -0
  35. package/src/main/lib/CLAUDE.md +2 -0
  36. package/src/main/lib/agent-cli/adapters/antigravity.cjs +147 -0
  37. package/src/main/lib/agent-cli/adapters/codex.cjs +170 -0
  38. package/src/main/lib/agent-cli/adapters/cursor.cjs +138 -0
  39. package/src/main/lib/agent-cli/adapters/gemini.cjs +119 -0
  40. package/src/main/lib/agent-cli/adapters/opencode.cjs +117 -0
  41. package/src/main/lib/agent-cli/agentCliEvents.cjs +94 -0
  42. package/src/main/lib/agent-cli/agentCliIpc.cjs +109 -0
  43. package/src/main/lib/agent-cli/agentCliRegistry.cjs +213 -0
  44. package/src/main/lib/agent-cli/agentCliSessionStore.cjs +152 -0
  45. package/src/main/lib/agent-cli/agentCliTurn.cjs +99 -0
  46. package/src/main/lib/app-preview/appPreviewIpc.cjs +125 -0
  47. package/src/main/lib/app-preview/appPreviewManager.cjs +317 -0
  48. package/src/main/lib/app-preview/appPreviewScripts.cjs +106 -0
  49. package/src/main/lib/app-preview/appPreviewSweep.cjs +92 -0
  50. package/src/main/lib/chatBootRecovery.cjs +41 -1
  51. package/src/main/lib/claude/agentEffortResolve.cjs +11 -3
  52. package/src/main/lib/epic/activeIndexMerge.cjs +25 -2
  53. package/src/main/lib/epic/archivedTranscript.cjs +39 -6
  54. package/src/main/lib/epic/epicChanges.cjs +466 -0
  55. package/src/main/lib/epic/epicMint.cjs +45 -1
  56. package/src/main/lib/epic/epicReopen.cjs +8 -2
  57. package/src/main/lib/epic/epicSpawnPlan.cjs +12 -0
  58. package/src/main/lib/epic/epicWorktreeMerge.cjs +39 -4
  59. package/src/main/lib/epic/promptSessionsCreateEpic.cjs +9 -4
  60. package/src/main/lib/feedback-remote/macroAdminRoutes.cjs +36 -13
  61. package/src/main/lib/feedback-remote/remoteIpcDispatch.cjs +2 -0
  62. package/src/main/lib/git/gitExec.cjs +9 -1
  63. package/src/main/lib/git/gitWorktree.cjs +94 -0
  64. package/src/main/lib/git/unifiedDiff.cjs +207 -0
  65. package/src/main/lib/mcpToolCatalog.cjs +15 -6
  66. package/src/main/lib/mdDocCensus.cjs +364 -0
  67. package/src/main/lib/mdDocRefs.cjs +249 -0
  68. package/src/main/lib/mdNetworkScan.cjs +158 -15
  69. package/src/main/lib/persona-macro/builtinMacros.cjs +17 -0
  70. package/src/main/lib/persona-macro/macroJobDispatch.cjs +4 -1
  71. package/src/main/lib/persona-macro/macroJobIpc.cjs +57 -11
  72. package/src/main/lib/persona-macro/macroLibrary.cjs +40 -10
  73. package/src/main/lib/prd/prdCreate.cjs +7 -2
  74. package/src/main/lib/prd/prdFrontmatter.cjs +10 -3
  75. package/src/main/lib/promptSessionSchema.cjs +6 -0
  76. package/src/main/lib/remoteTranscriptTail.cjs +23 -4
  77. package/src/main/lib/scheduler/landedSinceRun.cjs +2 -1
  78. package/src/main/lib/scheduler/scheduleJobSchema.cjs +2 -0
  79. package/src/main/lib/scheduler/schedulerPaths.cjs +3 -0
  80. package/src/main/projectPages.cjs +19 -4
  81. package/src/main/promptSessionEvents.cjs +10 -6
  82. package/src/main/scheduler/gitTreeGuard.cjs +2 -1
  83. package/src/main/scheduler/prdParser.cjs +2 -1
  84. package/src/main/scheduler.cjs +7 -2
  85. package/src/main/transcripts.cjs +18 -4
  86. package/src/main/webRemote.cjs +10 -5
  87. package/src/preload/api.d.ts +150 -3
  88. package/src/preload/apiSurface.json +56 -0
  89. package/src/preload/index.cjs +22 -0
  90. package/dist/assets/index-9ajPMXBg.js +0 -3097
@@ -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';
@@ -124,7 +135,10 @@ async function matrix({ cwd }) {
124
135
  function isLibraryPath(rel) {
125
136
  const parts = rel.split(path.sep);
126
137
  if (parts.length === 1) return parts[0] === 'home.html';
127
- if (parts.length === 2) return parts[0] === 'demo-video' && parts[1] === 'index.html';
138
+ if (parts.length === 2) {
139
+ if (parts[0] === 'matrix' && parts[1] === 'matrix.json') return true;
140
+ return parts[0] === 'demo-video' && parts[1] === 'index.html';
141
+ }
128
142
  if (parts.length === 3 && (parts[0] === 'knowledge' || parts[0] === 'videos')) {
129
143
  return parts[1] !== '_character' && (parts[2] === 'index.html' || parts[2] === 'meta.json');
130
144
  }
@@ -291,7 +305,7 @@ async function deleteEntry(input) {
291
305
  function registerProjectPagesIpc() {
292
306
  const { schemas: s, validated: v } = require('./ipcSchemas.cjs');
293
307
  ipcMain.handle('project-pages:get', v(s.projectPagesCwd, get));
294
- ipcMain.handle('project-pages:md-network', v(s.projectPagesCwd, mdNetwork));
308
+ ipcMain.handle('project-pages:md-network', v(s.projectPagesMdNetwork, mdNetwork));
295
309
  ipcMain.handle('project-pages:matrix', v(s.projectPagesCwd, matrix));
296
310
  ipcMain.handle('project-pages:watch', v(s.projectPagesCwd, ({ cwd }) => watchOutput(cwd)));
297
311
  ipcMain.handle('project-pages:rename', v(s.projectPagesRename, renameEntry));
@@ -308,6 +322,7 @@ module.exports = {
308
322
  get,
309
323
  mdNetwork,
310
324
  matrix,
325
+ isLibraryPath,
311
326
  renameEntry,
312
327
  deleteEntry,
313
328
  watchOutput,
@@ -2,9 +2,11 @@
2
2
  const { sendIfAlive } = require('./lib/sendToRenderer.cjs');
3
3
 
4
4
  /**
5
- * Main-process counterpart to promptSessions.ts's event chain, used ONLY by
6
- * the scheduler's PRD-finished notification path (notifyOriginatingTab,
7
- * scheduler.cjs). The renderer owns the live in-memory PromptSession store
5
+ * Main-process counterpart to promptSessions.ts's event chain, used by the
6
+ * scheduler's PRD-finished notification path (notifyOriginatingTab,
7
+ * scheduler.cjs) and by macros:dispatch-job (macroJobIpc.cjs), which appends a
8
+ * durable 'job-not-queued' notice when a macro's background build could not be
9
+ * queued for its Epic (PRD 2950). The renderer owns the live in-memory PromptSession store
8
10
  * and its own persistActiveIndex; this module never touches that store — it
9
11
  * reads/writes the SAME on-disk active-index.json directly, read-modify-
10
12
  * write, so a scheduler job (which runs in the main process, with no
@@ -23,8 +25,8 @@ const config = require('./config.cjs');
23
25
  const { activeIndexPath: promptSessionActiveIndexPath, withPathLock } = require('./lib/epic/epicMint.cjs');
24
26
 
25
27
  // IPC channel broadcast whenever an event is appended to a PromptSession's
26
- // chain from the main process (currently only the scheduler's response-event
27
- // append below). Mirrors chatRunner.cjs's attachWindow/broadcast pattern.
28
+ // chain from the main process (the scheduler's and macroJobIpc's
29
+ // response-event appends below). Mirrors chatRunner.cjs's attachWindow/broadcast pattern.
28
30
  const EVENT_APPENDED_CHANNEL = 'promptSession:event-appended';
29
31
 
30
32
  let mainWindow = null;
@@ -68,7 +70,8 @@ function mintEventId() {
68
70
  * regardless of the job's self-reported outcome; the authoring Epic's own
69
71
  * validation pass is what may later move it to 'verified'/'refuted'. `agentType`
70
72
  * (the job's agent) and `digestKey` (the settle digest's stable key) ride the
71
- * same meta arg and are copied the same way. All
73
+ * same meta arg and are copied the same way, as is `notice` (PRD 2950 — a
74
+ * marker like 'job-not-queued' the renderer turns into a distinct notice). All
72
75
  * keys are added to the event object only when present in `meta`, never as
73
76
  * `undefined`-valued keys, so events appended without them serialize
74
77
  * identically to before.
@@ -100,6 +103,7 @@ async function appendResponseEventWithReason(cwd, sourcePromptId, text, meta = {
100
103
  if (meta && meta.validation) event.validation = meta.validation;
101
104
  if (meta && meta.agentType) event.agentType = meta.agentType;
102
105
  if (meta && meta.digestKey) event.digestKey = meta.digestKey;
106
+ if (meta && meta.notice) event.notice = meta.notice;
103
107
  data.events[sourcePromptId] = [...events, event];
104
108
  await config.writeJson(path, data, { writer: 'scheduler' });
105
109
  broadcast(EVENT_APPENDED_CHANNEL, { cwd, promptSessionId: sourcePromptId, event });
@@ -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 };
@@ -628,11 +628,13 @@ async function tailLines(filePath, fromOffset) {
628
628
  async function pollSessionWatcher(w) {
629
629
  // The transcript may not exist yet (new session) or may live under another
630
630
  // project/worktree encoding: re-resolve while the watched file is missing.
631
+ // An agent-CLI (non-Claude) Epic's transcript lives under agentCliSessionStore.
631
632
  if (!fs.existsSync(w.filePath)) {
632
633
  try {
633
- const next = require('./transcripts.cjs').transcriptPath(w.cwd, w.sessionId);
634
+ const agentPath = require('./lib/remoteTranscriptTail.cjs').agentCliTranscriptPath(w.sessionId);
635
+ const next = agentPath ?? require('./transcripts.cjs').transcriptPath(w.cwd, w.sessionId);
634
636
  if (next && next !== w.filePath) {
635
- validatePath(next);
637
+ if (!agentPath) validatePath(next);
636
638
  w.filePath = next;
637
639
  w.offset = null;
638
640
  w.inode = undefined;
@@ -674,11 +676,14 @@ async function pollSessionWatcher(w) {
674
676
 
675
677
  function startSessionWatch(tabId, cwd, sessionId = tabId) {
676
678
  if (_sessionWatchers.has(tabId)) return;
677
- const filePath = require('./transcripts.cjs').transcriptPath(cwd, sessionId);
679
+ const claudePath = require('./transcripts.cjs').transcriptPath(cwd, sessionId);
678
680
  // Defense in depth: the schema restricts tabId charset, but re-validate the
679
681
  // FINAL joined path against the home-dir boundary (validatePath resolves
680
682
  // symlinks + rejects escapes) before any fs read. Throws → dispatch drops it.
681
- validatePath(filePath);
683
+ validatePath(claudePath);
684
+ // Agent-CLI Epics: the store builds this path from a UUID-validated id under
685
+ // its own state root (never throws — a bad id resolves to null).
686
+ const filePath = require('./lib/remoteTranscriptTail.cjs').agentCliTranscriptPath(sessionId) ?? claudePath;
682
687
  const w = {
683
688
  tabId, cwd, sessionId, filePath,
684
689
  offset: null, // null → first poll reads a bounded tail then tracks EOF
@@ -1212,7 +1217,7 @@ function getDispatchMap() {
1212
1217
  if (!filePath || !sessionId) return { messages: [], hasMore: false, nextBefore: null };
1213
1218
  validatePath(filePath);
1214
1219
  const exchanges = await listExchanges({ cwd: parsed.cwd, sessionId, limit: limit + 1, offset: before });
1215
- const tail = before === 0 ? await readRecentChatMessages(filePath, { limit: 30 }) : [];
1220
+ const tail = before === 0 ? await readRecentChatMessages(filePath, { limit: 30, claudeSessionId: sessionId }) : [];
1216
1221
  return buildRemoteConversation({ exchanges, tail, limit, before });
1217
1222
  },
1218
1223
 
@@ -309,6 +309,37 @@ export interface McpCatalogResult {
309
309
  export type AgentPersonaTag = 'feature' | 'bug' | 'discussion' | 'build' | 'project-home-builder' | 'art' | 'portfolio';
310
310
 
311
311
  /** One declared `{{name}}` argument of a macro prompt (macroLibrary.cjs `MacroInputSchema`). */
312
+ export type AppPreviewStatus = 'starting' | 'running' | 'failed' | 'stopped';
313
+
314
+ /** One Epic's dev-server preview. cwd = project root, dir = folder the dev command runs in,
315
+ * command = the script text from package.json, startedAt = ISO time. */
316
+ export interface AppPreviewState {
317
+ epicId: string;
318
+ cwd: string;
319
+ dir: string;
320
+ script: string;
321
+ command: string;
322
+ port: number;
323
+ url: string | null;
324
+ status: AppPreviewStatus;
325
+ error: string | null;
326
+ pid: number | null;
327
+ startedAt: string;
328
+ }
329
+
330
+ export interface AppPreviewScript {
331
+ name: string;
332
+ command: string;
333
+ }
334
+
335
+ export type AppPreviewScriptsResult =
336
+ | { ok: true; dir: string; inWorktree: boolean; scripts: AppPreviewScript[]; suggested: string | null }
337
+ | { ok: false; error: string };
338
+
339
+ export type AppPreviewStartResult =
340
+ | { ok: true; state: AppPreviewState }
341
+ | { ok: false; error: string };
342
+
312
343
  export interface MacroInput {
313
344
  name: string;
314
345
  label: string;
@@ -328,6 +359,9 @@ export interface MacroJobDispatchInput {
328
359
  macroId: string;
329
360
  epicId: string;
330
361
  extraInstructions?: string;
362
+ /** Per-launch effort chosen in the high-effort cost dialog: one of low, medium, high, xhigh, max;
363
+ * main refuses anything else. Omitted = the persona's own effort. */
364
+ effort?: string;
331
365
  }
332
366
 
333
367
  export type MacroJobDispatchResult =
@@ -347,7 +381,7 @@ export interface MacroJobStatus {
347
381
  finishedAt: string | null;
348
382
  }
349
383
 
350
- /** One user-defined sidebar HOT KEYS macro (macroLibrary.cjs). `projects` = absolute cwds or `'*'` (every project). */
384
+ /** One user-defined sidebar HOT KEYS macro (macroLibrary.cjs). `projects` = absolute cwds or `'*'` (every project); a surface `'project-home'` macro is always `['*']` (only its generated artifacts are per project). */
351
385
  export interface Macro {
352
386
  id: string;
353
387
  label: string;
@@ -397,6 +431,23 @@ export interface MacroSaveInput {
397
431
  autoStartTargets?: string[];
398
432
  }
399
433
 
434
+ /** One `agentCli.detect` row — a non-Claude agent CLI and whether it is installed. */
435
+ export interface AgentCliDetectRow {
436
+ id: 'codex' | 'gemini' | 'antigravity' | 'cursor' | 'opencode';
437
+ label: string;
438
+ installed: boolean;
439
+ path: string | null;
440
+ version: string | null;
441
+ install: string | null;
442
+ docs: string;
443
+ login: string | null;
444
+ }
445
+
446
+ /** `agentCli.terminalCommand` result: a single-quoted shell line, or why there is none. */
447
+ export type AgentCliTerminalCommandResult =
448
+ | { ok: true; command: string }
449
+ | { ok: false; message: string };
450
+
400
451
  /** One global `~/.claude/agents/<name>.md` persona, per the Agent Library nav page. */
401
452
  export interface AgentPersona {
402
453
  name: string;
@@ -1684,7 +1735,11 @@ export interface MdNetworkOrphan {
1684
1735
  /** Broken links come first (in walk order), then orphan groups (by folder). */
1685
1736
  export type MdNetworkFinding = MdNetworkBrokenLink | MdNetworkOrphan;
1686
1737
 
1687
- /** A project's markdown link network, mapped from its root CLAUDE.md. */
1738
+ /**
1739
+ * A project's markdown link network, mapped from its root CLAUDE.md, plus a per-doc
1740
+ * census of every tracked .md (role, size, git recency, dead/stale refs, code mentions).
1741
+ * Orphan findings leave out docs the census puts in a record collection.
1742
+ */
1688
1743
  export interface MdNetwork {
1689
1744
  ok: true;
1690
1745
  /** The root doc, 'CLAUDE.md'. */
@@ -1699,11 +1754,27 @@ export interface MdNetwork {
1699
1754
  links: number;
1700
1755
  /** Top-level folders holding reachable docs, each with a trailing slash, sorted. */
1701
1756
  scopes: string[];
1757
+ /** Every tracked .md; docs left unread past the 2000 cap have `lines`/`bytes` null. A failed git call adds a `warnings` entry, never an error. */
1758
+ census: MdCensus;
1702
1759
  }
1703
1760
 
1704
1761
  /** `{ ok: false, error }` when there is nothing to map or the scan failed (not a git repo, no root CLAUDE.md, an ephemeral cwd). */
1705
1762
  export type MdNetworkResult = MdNetwork | { ok: false; error: string };
1706
1763
 
1764
+ // ────────────────────────────────────────────── Project Pages: markdown doc census
1765
+ // Mirrors the JSDoc typedefs in src/main/lib/mdDocCensus.cjs.
1766
+ // Every path is repo-relative POSIX; folder strings end with '/'.
1767
+
1768
+ /** How agents meet a doc: 'map' = the root + its @-imports; 'scoped' = another CLAUDE.md / AGENTS.md / CLAUDE.local.md; 'agent' = .claude/, skills/, plugin agents/commands; 'record' = in a record collection and unreachable; 'doc' = anything else. */
1769
+ export type MdDocRole = 'map' | 'scoped' | 'agent' | 'record' | 'doc';
1770
+
1771
+ export interface MdDoc { path: string; role: MdDocRole; depth: number | null; lines: number | null; bytes: number | null; lastCommitMs: number | null; commits: number; linkedFrom: number; codeRefs: number; codeRefFiles: string[]; deadRefs: string[]; changedSince: { path: string; ms: number }[]; collection: string | null; }
1772
+
1773
+ /** A folder of machine-written, write-once, unlinked docs (e.g. validation records). */
1774
+ export interface MdRecordCollection { folder: string; docs: number; linked: number; lastCommitMs: number | null; source: 'heuristic' | 'override'; }
1775
+
1776
+ export interface MdCensus { docs: MdDoc[]; collections: MdRecordCollection[]; counts: { tracked: number; network: number; records: number; unlinked: number; byRole: Record<MdDocRole, number> }; gitWindow: { commits: number; oldestMs: number | null }; warnings: string[]; }
1777
+
1707
1778
  // ────────────────────────────────────────────── Competitor matrix
1708
1779
  // Mirrors CompetitiveMatrixSchema in src/main/lib/project-pages/competitiveMatrix.cjs — keep field-for-field.
1709
1780
 
@@ -1824,6 +1895,52 @@ export interface GitFileStatus {
1824
1895
  workTreeStatus: string;
1825
1896
  }
1826
1897
 
1898
+ /** One line of a unified-diff hunk. `oldNo`/`newNo` are null on the side the line doesn't exist. */
1899
+ export interface DiffLine {
1900
+ kind: 'add' | 'del' | 'ctx';
1901
+ oldNo: number | null;
1902
+ newNo: number | null;
1903
+ text: string;
1904
+ }
1905
+
1906
+ export interface DiffHunk {
1907
+ header: string;
1908
+ oldStart: number;
1909
+ oldLines: number;
1910
+ newStart: number;
1911
+ newLines: number;
1912
+ lines: DiffLine[];
1913
+ }
1914
+
1915
+ export interface DiffFile {
1916
+ path: string;
1917
+ oldPath: string | null;
1918
+ status: 'added' | 'deleted' | 'modified' | 'renamed';
1919
+ binary: boolean;
1920
+ additions: number;
1921
+ deletions: number;
1922
+ hunks: DiffHunk[];
1923
+ truncated: boolean;
1924
+ tooLarge?: boolean;
1925
+ }
1926
+
1927
+ /** One reviewable slice of an Epic's changes: the session's own worktree work, or one landed PRD. */
1928
+ export interface EpicChangeSection {
1929
+ kind: 'session' | 'prd';
1930
+ key: string;
1931
+ label: string;
1932
+ slug?: string;
1933
+ base: string | null;
1934
+ head: string | null;
1935
+ live: boolean;
1936
+ files: DiffFile[];
1937
+ error?: string;
1938
+ }
1939
+
1940
+ export type EpicChanges =
1941
+ | { ok: true; epicId: string; status: string; sections: EpicChangeSection[]; truncated: boolean }
1942
+ | { ok: false; reason: string };
1943
+
1827
1944
  export interface GitStatusResult {
1828
1945
  branch: string;
1829
1946
  ahead: number;
@@ -2142,6 +2259,13 @@ export interface SessionManagerAPI {
2142
2259
  /** Desktop-only: the web remote is denied it (apiSurface remote: deny) — it spawns the server. */
2143
2260
  checkServer: (req: McpCheckRequest) => Promise<McpCheckResult>;
2144
2261
  };
2262
+ /** Non-Claude agent CLIs (main-side registry + adapters). Desktop-only: not exposed to the web remote. */
2263
+ agentCli: {
2264
+ /** One row per non-Claude CLI; cached 60 s in main unless `refresh`. Never rejects. */
2265
+ detect: (payload?: { refresh?: boolean }) => Promise<AgentCliDetectRow[]>;
2266
+ /** The exact shell line (no trailing CR) the Epic Terminal pane types to launch/resume this Epic's CLI. */
2267
+ terminalCommand: (payload: { cwd: string; claudeSessionId: string }) => Promise<AgentCliTerminalCommandResult>;
2268
+ };
2145
2269
  agents: {
2146
2270
  listPersonas: () => Promise<AgentPersona[]>;
2147
2271
  savePersona: (payload: AgentPersonaSaveInput) => Promise<{ ok: boolean; path: string }>;
@@ -2206,6 +2330,18 @@ export interface SessionManagerAPI {
2206
2330
  /** Fires after any save/delete/setProject — re-fetch list(). */
2207
2331
  onChanged: (handler: () => void) => () => void;
2208
2332
  };
2333
+ appPreview: {
2334
+ /** The Epic's package.json scripts (dir = worktree when it has one) plus a suggested dev script. */
2335
+ scripts: (payload: { cwd: string; epicId: string }) => Promise<AppPreviewScriptsResult>;
2336
+ /** Spawns the Epic's dev script on a free port after the user confirmed it; desktop only. */
2337
+ start: (payload: { cwd: string; epicId: string; script: string }) => Promise<AppPreviewStartResult>;
2338
+ /** Stops the Epic's preview process, if any. */
2339
+ stop: (payload: { epicId: string }) => Promise<{ ok: true }>;
2340
+ /** Every tracked preview, one per Epic. */
2341
+ list: () => Promise<AppPreviewState[]>;
2342
+ /** Fires on every preview state change with the new state. */
2343
+ onChanged(handler: (state: AppPreviewState) => void): () => void;
2344
+ };
2209
2345
  models: {
2210
2346
  /** Live model/effort catalog (`modelCatalog.cjs`'s `resolveModelCatalog`). Never rejects from
2211
2347
  * the resolver itself — a failed probe degrades down cache → floor and sets `degraded`.
@@ -2523,7 +2659,7 @@ export interface SessionManagerAPI {
2523
2659
  /** Read the project-pages library (knowledge/<id>/ pages and videos/<id>/ videos, each with its meta) as a `ProjectPagesGetResult`; empty lists if nothing exists yet. Never fires an LLM call. */
2524
2660
  get: (cwd: string) => Promise<ProjectPagesGetResult>;
2525
2661
  /** Map the project's markdown link network from its root CLAUDE.md (read-only, bounded, no LLM) for the Tools pane. Scans on every call — no watcher, no cache. `ok:false` (with `error`) for a cwd `get` answers with empty lists (tmpdir / linked worktree), a folder that is not a git repo, or no root CLAUDE.md; rejects on an invalid cwd, like `get`. */
2526
- mdNetwork: (payload: { cwd: string }) => Promise<MdNetworkResult>;
2662
+ mdNetwork: (payload: { cwd: string; recordFolders?: string[]; docFolders?: string[] }) => Promise<MdNetworkResult>;
2527
2663
  /** Read the saved Competitor matrix (project-pages/matrix/matrix.json) — read-only; writes go through project_matrix_write. */
2528
2664
  matrix: (payload: { cwd: string }) => Promise<CompetitorMatrixResult>;
2529
2665
  /** Start pushing `onChanged` events for this cwd's output dir. Refcounted per cwd; `ok:false` (reason 'ephemeral'|'invalid-cwd') means no live updates are possible, not an error. */
@@ -2554,6 +2690,11 @@ export interface SessionManagerAPI {
2554
2690
  * Read-only, no new writer — reads zero on any missing/unreadable state, never throws. */
2555
2691
  get: (cwd: string, epicId: string, claudeSessionId?: string | null) => Promise<{ prdsQueued: number; inlineEdits: number }>;
2556
2692
  };
2693
+ epicChanges: {
2694
+ /** Read-only diff of an Epic's changes, sectioned by session pin and per-PRD landed commit.
2695
+ * Never throws for a missing Epic/worktree — resolves `{ ok: false, reason }`. */
2696
+ get: (args: { cwd: string; epicId: string }) => Promise<EpicChanges>;
2697
+ };
2557
2698
  auditLog: {
2558
2699
  /** Append one Epic-lifecycle audit event to ~/.claude/session-manager/audit-log.jsonl.
2559
2700
  * Kind allowlist is enforced main-side (ipcSchemas.cjs) — this channel is
@@ -2751,6 +2892,10 @@ export interface PromptSessionsCreateEpicPayload {
2751
2892
  }>;
2752
2893
  /** Adopt an existing CLI session of this project instead of minting one. */
2753
2894
  restoreSessionId?: string;
2895
+ /** Agent CLI driving this Epic; absent = Claude Code. Non-Claude forces developLoop false and refuses restore. */
2896
+ agentCli?: 'claude' | 'codex' | 'gemini' | 'antigravity' | 'cursor' | 'opencode';
2897
+ /** Model for a non-Claude CLI; absent = that CLI's default. */
2898
+ agentCliModel?: string;
2754
2899
  }
2755
2900
 
2756
2901
  export interface PromptSessionsCreateEpicResult {
@@ -2848,6 +2993,8 @@ export interface PromptSessionEventAppendedPayload {
2848
2993
  at: string;
2849
2994
  prdSlug?: string;
2850
2995
  text?: string;
2996
+ /** 'job-not-queued' = a macro's background build could not be queued for this Epic (macroJobIpc.cjs). */
2997
+ notice?: 'job-not-queued';
2851
2998
  };
2852
2999
  }
2853
3000
 
@@ -356,6 +356,20 @@
356
356
  "kind": "invoke",
357
357
  "remote": "deny"
358
358
  },
359
+ {
360
+ "ns": "agentCli",
361
+ "method": "detect",
362
+ "channel": "agentCli:detect",
363
+ "kind": "invoke",
364
+ "remote": "deny"
365
+ },
366
+ {
367
+ "ns": "agentCli",
368
+ "method": "terminalCommand",
369
+ "channel": "agentCli:terminal-command",
370
+ "kind": "invoke",
371
+ "remote": "deny"
372
+ },
359
373
  {
360
374
  "ns": "agents",
361
375
  "method": "listPersonas",
@@ -475,6 +489,41 @@
475
489
  "kind": "on",
476
490
  "remote": "read"
477
491
  },
492
+ {
493
+ "ns": "appPreview",
494
+ "method": "scripts",
495
+ "channel": "appPreview:scripts",
496
+ "kind": "invoke",
497
+ "remote": "deny"
498
+ },
499
+ {
500
+ "ns": "appPreview",
501
+ "method": "start",
502
+ "channel": "appPreview:start",
503
+ "kind": "invoke",
504
+ "remote": "deny"
505
+ },
506
+ {
507
+ "ns": "appPreview",
508
+ "method": "stop",
509
+ "channel": "appPreview:stop",
510
+ "kind": "invoke",
511
+ "remote": "mutate"
512
+ },
513
+ {
514
+ "ns": "appPreview",
515
+ "method": "list",
516
+ "channel": "appPreview:list",
517
+ "kind": "invoke",
518
+ "remote": "read"
519
+ },
520
+ {
521
+ "ns": "appPreview",
522
+ "method": "onChanged",
523
+ "channel": "appPreview:changed",
524
+ "kind": "on",
525
+ "remote": "read"
526
+ },
478
527
  {
479
528
  "ns": "models",
480
529
  "method": "catalog",
@@ -1448,6 +1497,13 @@
1448
1497
  "kind": "invoke",
1449
1498
  "remote": "read"
1450
1499
  },
1500
+ {
1501
+ "ns": "epicChanges",
1502
+ "method": "get",
1503
+ "channel": "epicChanges:get",
1504
+ "kind": "invoke",
1505
+ "remote": "read"
1506
+ },
1451
1507
  {
1452
1508
  "ns": "auditLog",
1453
1509
  "method": "append",