claude-code-session-manager 0.132.0 → 0.133.1

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 (87) hide show
  1. package/README.md +3 -3
  2. package/dist/assets/{AgentLibrary-C09MlPFx.js → AgentLibrary-BTIBmZkM.js} +2 -2
  3. package/dist/assets/{AppSettings-DvDKsCnD.js → AppSettings-DwnfV9-4.js} +2 -2
  4. package/dist/assets/{Button-BzG_KdBC.js → Button-CObXxw7b.js} +1 -1
  5. package/dist/assets/DocumentEditorPane-CgB5IuOY.js +1 -0
  6. package/dist/assets/{Extensions-DgxKT_OZ.js → Extensions-Fuhshcl6.js} +2 -2
  7. package/dist/assets/{History-Nd3bKjBq.js → History-DbUV4jxK.js} +2 -2
  8. package/dist/assets/{Library-R71t6VAB.js → Library-COr79GyT.js} +1 -1
  9. package/dist/assets/{ListDetail-CG50Ul7c.js → ListDetail-DY53nXya.js} +1 -1
  10. package/dist/assets/{Panel-C7EFG4eU.js → Panel-D7NX5iP8.js} +1 -1
  11. package/dist/assets/{ProjectClaudeConfig-J92iNEGC.js → ProjectClaudeConfig-DuWzM8qA.js} +1 -1
  12. package/dist/assets/{ProvenanceBadge-C3KB3ILO.js → ProvenanceBadge-AnwE1p5X.js} +1 -1
  13. package/dist/assets/{Scheduler-DeYBA7uc.js → Scheduler-BHfx0rXd.js} +9 -9
  14. package/dist/assets/Settings-tt0VZCyz.js +2 -0
  15. package/dist/assets/{SkillReferenceGraph-D7bt3fyB.js → SkillReferenceGraph-D_rxqWgq.js} +1 -1
  16. package/dist/assets/{Skills-GpxtUrFP.js → Skills-BVQPJZaF.js} +1 -1
  17. package/dist/assets/{SourceChip-uyVMCZc7.js → SourceChip-DC5XD8KC.js} +1 -1
  18. package/dist/assets/{SystemPrompt-Cv25uFSM.js → SystemPrompt-XnvP0_cS.js} +1 -1
  19. package/dist/assets/{TiptapBody-uP8fJkbM.js → TiptapBody-B_TNEADm.js} +1 -1
  20. package/dist/assets/{Toggle-DRs80cX-.js → Toggle-CxQO8pGN.js} +1 -1
  21. package/dist/assets/{ViewTabs-BDkvvzJ8.js → ViewTabs-CEjnWPD9.js} +1 -1
  22. package/dist/assets/{VoiceButton-Cmtz2sQt.js → VoiceButton-B-6gdmKe.js} +1 -1
  23. package/dist/assets/{historyTotals-DHwAXunq.js → historyTotals-dT8vcKzX.js} +1 -1
  24. package/dist/assets/{index-oXqzajWV.css → index-5QIl5Kcd.css} +1 -1
  25. package/dist/assets/index-BLORXCcT.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 +4 -2
  30. package/scripts/README.md +1 -0
  31. package/src/main/build-info.json +4 -4
  32. package/src/main/chatRunner.cjs +77 -14
  33. package/src/main/index.cjs +13 -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/remoteIpcDispatch.cjs +2 -0
  61. package/src/main/lib/git/gitExec.cjs +9 -1
  62. package/src/main/lib/git/gitWorktree.cjs +94 -0
  63. package/src/main/lib/git/unifiedDiff.cjs +207 -0
  64. package/src/main/lib/mdDocCensus.cjs +364 -0
  65. package/src/main/lib/mdDocRefs.cjs +249 -0
  66. package/src/main/lib/mdNetworkScan.cjs +158 -15
  67. package/src/main/lib/persona-macro/macroJobDispatch.cjs +4 -1
  68. package/src/main/lib/persona-macro/macroJobIpc.cjs +1 -1
  69. package/src/main/lib/prd/prdCreate.cjs +7 -2
  70. package/src/main/lib/prd/prdFrontmatter.cjs +10 -3
  71. package/src/main/lib/promptSessionSchema.cjs +6 -0
  72. package/src/main/lib/remoteTranscriptTail.cjs +23 -4
  73. package/src/main/lib/scheduler/landedSinceRun.cjs +2 -1
  74. package/src/main/lib/scheduler/scheduleJobSchema.cjs +2 -0
  75. package/src/main/lib/scheduler/schedulerPaths.cjs +3 -0
  76. package/src/main/projectPages.cjs +14 -3
  77. package/src/main/scheduler/gitTreeGuard.cjs +2 -1
  78. package/src/main/scheduler/prdParser.cjs +2 -1
  79. package/src/main/scheduler.cjs +7 -2
  80. package/src/main/transcripts.cjs +18 -4
  81. package/src/main/webRemote.cjs +10 -5
  82. package/src/preload/api.d.ts +147 -2
  83. package/src/preload/apiSurface.json +56 -0
  84. package/src/preload/index.cjs +22 -0
  85. package/dist/assets/DocumentEditorPane-fm6zsnLM.js +0 -1
  86. package/dist/assets/Settings-B6r7N4v-.js +0 -2
  87. package/dist/assets/index-CBCdyHbZ.js +0 -3097
@@ -11,8 +11,12 @@
11
11
  * chatRunner.run() with the same sessionId and a fixed continue prompt, at most once per
12
12
  * session per 24 h.
13
13
  * Touches only the session's own turn: never mints an Epic or edits its title/objective/status.
14
+ * An entry whose Epic runs a non-Claude agent CLI (agentCli) has no Claude JSONL to judge and
15
+ * no `claude --resume` to continue, so it is cleared from the ledger and logged, never re-run.
14
16
  */
15
17
 
18
+ const { isNonClaudeAgentCli } = require('./agent-cli/agentCliEvents.cjs');
19
+
16
20
  const DAY_MS = 24 * 60 * 60 * 1000;
17
21
  const ORPHAN_POLL_MS = 5000;
18
22
 
@@ -25,6 +29,27 @@ function defaultPidAlive(pid) {
25
29
  try { process.kill(pid, 0); return true; } catch (e) { return !!(e && e.code === 'EPERM'); }
26
30
  }
27
31
 
32
+ /**
33
+ * Default Epic lookup for a ledger entry: the project's active index, keyed by promptId
34
+ * (the Epic id) or matched by claudeSessionId. Returns the Epic's agentCli or null.
35
+ */
36
+ function defaultAgentCliOf(entry) {
37
+ try {
38
+ if (!entry || typeof entry.cwd !== 'string' || !entry.cwd) return null;
39
+ const { projectRootOf } = require('./activeSessions.cjs');
40
+ const { readActiveIndex } = require('./epic/epicMint.cjs');
41
+ const sessions = readActiveIndex(projectRootOf(entry.cwd)).sessions || {};
42
+ let rec = entry.promptId && Object.prototype.hasOwnProperty.call(sessions, entry.promptId)
43
+ ? sessions[entry.promptId] : null;
44
+ if (!rec) rec = Object.values(sessions).find((s) => s && s.claudeSessionId === entry.sessionId) || null;
45
+ return rec && typeof rec.agentCli === 'string' ? rec.agentCli : null;
46
+ } catch { return null; }
47
+ }
48
+
49
+ function defaultLog(line) {
50
+ try { require('../logs.cjs').writeLine(line); } catch { /* best-effort */ }
51
+ }
52
+
28
53
  function isChatProcessFor(identity, sessionId) {
29
54
  const cmd = identity && typeof identity.cmdline === 'string' ? identity.cmdline : '';
30
55
  return cmd.includes('sm-claude-chat') && cmd.includes(sessionId);
@@ -57,7 +82,7 @@ function classifyTurnTail(text) {
57
82
  * @param {object} deps
58
83
  * ledger {list,end,markRecovered,recoveredMap}, run(opts), holdOrphan(sid), releaseOrphan(sid),
59
84
  * pidAlive(pid), identityOf(pid), sessionTurnState(entry) → 'finished'|'unfinished'|'missing',
60
- * now(), pollMs, setTimer/clearTimer (tests)
85
+ * now(), pollMs, setTimer/clearTimer (tests), agentCliOf(entry) → agentCli|null, log(line)
61
86
  * @returns {Promise<{ pending: Promise<void>, results: object[] }>} resolves after the first pass;
62
87
  * `pending` settles once every orphan has exited and been handled.
63
88
  */
@@ -68,6 +93,7 @@ async function recoverInflightTurns(deps) {
68
93
  sessionTurnState = async () => 'missing',
69
94
  now = Date.now, pollMs = ORPHAN_POLL_MS,
70
95
  setTimer = setTimeout,
96
+ agentCliOf = defaultAgentCliOf, log = defaultLog,
71
97
  } = deps;
72
98
  const results = [];
73
99
  const waits = [];
@@ -109,6 +135,20 @@ async function recoverInflightTurns(deps) {
109
135
 
110
136
  for (const entry of entries) {
111
137
  if (!entry || !entry.sessionId) continue;
138
+ let agentCli = null;
139
+ try { agentCli = agentCliOf(entry); } catch { agentCli = null; }
140
+ if (isNonClaudeAgentCli(agentCli)) {
141
+ try {
142
+ log({
143
+ scope: 'chat-boot-recovery', level: 'info',
144
+ message: `skipping interrupted ${agentCli} turn for session ${entry.sessionId} (no auto-continue for non-Claude agent CLIs)`,
145
+ meta: { sessionId: entry.sessionId, agentCli },
146
+ });
147
+ } catch { /* best-effort */ }
148
+ try { await ledger.end(entry.sessionId); } catch { /* best-effort */ }
149
+ results.push({ sessionId: entry.sessionId, outcome: 'skipped_agent_cli', agentCli });
150
+ continue;
151
+ }
112
152
  if (isOrphan(entry)) {
113
153
  holdOrphan(entry.sessionId);
114
154
  waits.push(new Promise((resolve) => {
@@ -7,6 +7,10 @@
7
7
  * agentLibrary.cjs's serializePersona; the key is literally `effort`).
8
8
  *
9
9
  * PRECEDENCE (explicit):
10
+ * P. the PRD's own `effort` frontmatter (`prdEffort`, persisted on the queue
11
+ * row as job.effort; source 'prd') beats everything below. Written
12
+ * in-process only when a human pressing a macro chose a lower effort;
13
+ * scheduled PRDs only. A value outside PRD_EFFORT_LEVELS is ignored.
10
14
  * 0. Epic-level `effort` (the New Session card's override, stored on the Epic
11
15
  * record; source 'epic') beats everything below. Only reachable on the
12
16
  * Chat/Terminal path (claudeSessionId) — a scheduled PRD has no Epic record
@@ -34,6 +38,7 @@
34
38
  * Plain sync Node module, never throws (same contract as resolveEpicModel).
35
39
  */
36
40
 
41
+ const { PRD_EFFORT_LEVELS } = require('../prd/prdFrontmatter.cjs');
37
42
  const { findEpicByClaudeSessionId, epicOverrideValue, readOverlayAwarePersona } = require('./agentModelResolve.cjs');
38
43
 
39
44
  // `auto` is a `/effort` RESET verb, not a `--effort` value; it must never reach argv.
@@ -42,15 +47,18 @@ const NON_FLAG_EFFORT = new Set(['inherit', 'auto']);
42
47
  const NO_EFFORT = Object.freeze({ effort: null, source: null });
43
48
 
44
49
  /**
45
- * @param {{ cwd: string, claudeSessionId?: string, agentType?: string|null, deps?: object }} opts
50
+ * @param {{ cwd: string, claudeSessionId?: string, agentType?: string|null, prdEffort?: string|null, deps?: object }} opts
51
+ * `prdEffort` (scheduler PRD path) wins over every other rung when it is a
52
+ * PRD_EFFORT_LEVELS value; any other value is ignored.
46
53
  * `agentType` wins when given (scheduler PRD path); otherwise it is joined
47
54
  * from the Epic's `claudeSessionId` (Chat/Terminal path).
48
- * @returns {{ effort: string|null, source: 'epic'|'persona'|'persona-overlay'|'inherit'|null }}
55
+ * @returns {{ effort: string|null, source: 'prd'|'epic'|'persona'|'persona-overlay'|'inherit'|null }}
49
56
  * source null = no agentType/persona resolved; 'inherit' = persona present
50
57
  * but sets no level.
51
58
  */
52
- function resolveEpicEffort({ cwd, claudeSessionId, agentType, deps = {} } = {}) {
59
+ function resolveEpicEffort({ cwd, claudeSessionId, agentType, prdEffort, deps = {} } = {}) {
53
60
  try {
61
+ if (typeof prdEffort === 'string' && PRD_EFFORT_LEVELS.includes(prdEffort)) return { effort: prdEffort, source: 'prd' };
54
62
  const epic = claudeSessionId ? findEpicByClaudeSessionId(cwd, claudeSessionId, deps) : null;
55
63
  const override = epicOverrideValue(epic, 'effort');
56
64
  if (override && !NON_FLAG_EFFORT.has(override.toLowerCase())) return { effort: override, source: 'epic' };
@@ -59,15 +59,31 @@ function compareEventsChainAware(a, b) {
59
59
  }
60
60
 
61
61
  /**
62
- * mergeActiveIndex(cwd, { sessions, events, removedIds }) → Promise<{ sessions, events }>
62
+ * Default app-preview stop: required lazily so this module never loads
63
+ * app-preview at require time. manager.stop(id) is a no-op for an Epic with
64
+ * nothing running.
65
+ */
66
+ function defaultStopPreview(id) {
67
+ return require('../app-preview/appPreviewIpc.cjs').getAppPreviewManager().stop(id);
68
+ }
69
+
70
+ /**
71
+ * mergeActiveIndex(cwd, { sessions, events, removedIds }, deps?) → Promise<{ sessions, events }>
63
72
  *
64
73
  * `sessions`/`events` are the CALLING renderer's own in-memory contribution
65
74
  * for this cwd only (already filtered to 'active'/'proposed' sessions by
66
75
  * persistActiveIndex) — never a full merged file; disk remains the source of
67
76
  * truth this function reads and reconciles against. Returns the merged
68
77
  * { sessions, events } actually written.
78
+ *
79
+ * deps.stopPreview(id) (default: the app-preview manager's stop) runs
80
+ * fire-and-forget for every removedIds entry AFTER the write lands — the
81
+ * single main-side choke point that stops an Epic's preview whenever it leaves
82
+ * the active index (completion, deletion, stale-row cleanup; desktop or web
83
+ * remote). It never delays or changes the returned result; failures are logged.
69
84
  */
70
- async function mergeActiveIndex(cwd, { sessions: rawMemorySessions = {}, events: rawMemoryEvents = {}, removedIds = [] } = {}) {
85
+ async function mergeActiveIndex(cwd, { sessions: rawMemorySessions = {}, events: rawMemoryEvents = {}, removedIds = [] } = {}, deps = {}) {
86
+ const stopPreview = typeof deps.stopPreview === 'function' ? deps.stopPreview : defaultStopPreview;
71
87
  if (!cwd || typeof cwd !== 'string') throw new Error('mergeActiveIndex: cwd is required');
72
88
  // Register this project's cwd as a write-allowed root (config.cjs's
73
89
  // validateWrite gate) — mirrors the precedent + comment in
@@ -159,6 +175,13 @@ async function mergeActiveIndex(cwd, { sessions: rawMemorySessions = {}, events:
159
175
  // payload, so a compromised/forged renderer call can't claim a
160
176
  // different writer id.
161
177
  await config.writeJson(filePath, index, { writer: 'epics' });
178
+ // App preview stop — fire-and-forget, only after the write succeeded
179
+ // (writeJson throws on failure, so a failed write never reaches here).
180
+ for (const id of removedIds) {
181
+ Promise.resolve()
182
+ .then(() => stopPreview(id))
183
+ .catch((e) => console.warn(`[activeIndexMerge] app preview stop failed for ${id}`, e));
184
+ }
162
185
  // Status mirror (epicStatusMirror.cjs) — this IPC handler is the
163
186
  // renderer-driven persist path (persistActiveIndex), the write site for
164
187
  // both the 'proposed'->'active' start transition (approveProposed) and
@@ -15,6 +15,7 @@ const fs = require('node:fs');
15
15
  const zlib = require('node:zlib');
16
16
  const { assertOpsWrite, opsPath } = require('../opsOwnership.cjs');
17
17
  const atomicFs = require('../util/atomicFs.cjs');
18
+ const { isNonClaudeAgentCli } = require('../agent-cli/agentCliEvents.cjs');
18
19
 
19
20
  const SUBDIR = 'transcripts-archive';
20
21
 
@@ -62,21 +63,53 @@ function readSidecar(cwd, epicId) {
62
63
  }
63
64
 
64
65
  /**
65
- * archiveTranscript({cwd, epicId, claudeSessionId}, {resolvePath}) -> pointer | null.
66
- * Reads the raw Claude JSONL main-side and writes the sidecar; null when the
67
- * JSONL is missing or empty (caller falls back to durableTurns).
66
+ * Default Epic lookup: the agentCli on the Epic's active-index row, else on its
67
+ * status mirror (`<id>.json`, either `{session}`-wrapped or flat). null = Claude.
68
68
  */
69
- function archiveTranscript(args, { resolvePath } = {}) {
69
+ function defaultAgentCliOf(cwd, epicId) {
70
+ try {
71
+ const { readActiveIndex } = require('./epicMint.cjs');
72
+ const row = readActiveIndex(cwd).sessions[epicId];
73
+ if (row && typeof row.agentCli === 'string') return row.agentCli;
74
+ } catch { /* fall through */ }
75
+ try {
76
+ const { epicMirrorPath } = require('./epicStatusMirror.cjs');
77
+ const m = JSON.parse(fs.readFileSync(epicMirrorPath(cwd, epicId), 'utf8'));
78
+ const rec = m && m.session && typeof m.session === 'object' ? m.session : m;
79
+ if (rec && typeof rec.agentCli === 'string') return rec.agentCli;
80
+ } catch { /* absent */ }
81
+ return null;
82
+ }
83
+
84
+ /**
85
+ * archiveTranscript({cwd, epicId, claudeSessionId, agentCli?}, {resolvePath, agentCliOf}) -> pointer | null.
86
+ * Reads the raw transcript main-side and writes the sidecar: the Claude JSONL for a
87
+ * Claude Epic, the agent-CLI transcript (agentCliSessionStore.transcriptPathFor) for an
88
+ * Epic with a non-Claude agentCli. null when the file is missing or empty (caller falls
89
+ * back to durableTurns).
90
+ */
91
+ function archiveTranscript(args, { resolvePath, agentCliOf } = {}) {
70
92
  const { cwd, epicId, claudeSessionId } = args || {};
71
93
  if (typeof cwd !== 'string' || !require('node:path').isAbsolute(cwd)) {
72
94
  throw new Error('archivedTranscript: cwd must be an absolute path');
73
95
  }
74
96
  assertSafeEpicId(epicId);
75
97
  if (typeof claudeSessionId !== 'string' || !claudeSessionId) return null;
76
- const resolve = resolvePath || ((c, s) => require('../../transcripts.cjs').transcriptPath(c, s));
98
+ let agentCli = args && typeof args.agentCli === 'string' ? args.agentCli : null;
99
+ if (!agentCli) {
100
+ try { agentCli = (agentCliOf || defaultAgentCliOf)(cwd, epicId); } catch { agentCli = null; }
101
+ }
102
+ let file;
103
+ try {
104
+ file = isNonClaudeAgentCli(agentCli)
105
+ ? require('../agent-cli/agentCliSessionStore.cjs').transcriptPathFor(claudeSessionId)
106
+ : (resolvePath || ((c, s) => require('../../transcripts.cjs').transcriptPath(c, s)))(cwd, claudeSessionId);
107
+ } catch {
108
+ return null;
109
+ }
77
110
  let text;
78
111
  try {
79
- text = fs.readFileSync(resolve(cwd, claudeSessionId), 'utf8');
112
+ text = fs.readFileSync(file, 'utf8');
80
113
  } catch {
81
114
  return null;
82
115
  }