claude-code-session-manager 0.130.2 → 0.131.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.claude-plugin/marketplace.json +1 -1
- package/bin/cli.cjs +19 -2
- package/dist/assets/AgentLibrary-CYXre0J-.js +2 -0
- package/dist/assets/{AppSettings-Bpwynea4.js → AppSettings-xNSfCj8e.js} +2 -2
- package/dist/assets/{Button-DSoqrxCB.js → Button-BWljh5IK.js} +1 -1
- package/dist/assets/DocumentEditorPane-FUC2hZlp.js +1 -0
- package/dist/assets/Extensions-CsyUoklz.js +2 -0
- package/dist/assets/{History-DzMo9Otn.js → History-BvNmY9OQ.js} +2 -2
- package/dist/assets/{Library-C5wKMTSn.js → Library-DVXk77zA.js} +12 -12
- package/dist/assets/{ListDetail-DDQ1S0yu.js → ListDetail-DAAx__24.js} +1 -1
- package/dist/assets/{Panel-B-3NWUlv.js → Panel-g2D-e-RM.js} +1 -1
- package/dist/assets/ProjectClaudeConfig-BDuHJwaO.js +25 -0
- package/dist/assets/{ProvenanceBadge-CUChwz4Z.js → ProvenanceBadge-wew4_nf3.js} +1 -1
- package/dist/assets/Scheduler-CbeUIqD-.js +16 -0
- package/dist/assets/Settings-B23RsRfm.js +2 -0
- package/dist/assets/{SkillReferenceGraph-C6JEdypC.js → SkillReferenceGraph-BxQPCfsg.js} +1 -1
- package/dist/assets/Skills-4AR2FQrI.js +29 -0
- package/dist/assets/{SourceChip-DcBNYYhe.js → SourceChip-jrC0vjfw.js} +1 -1
- package/dist/assets/SystemPrompt-hHoBEnYb.js +1 -0
- package/dist/assets/{TiptapBody-DiVYC-_O.js → TiptapBody-FkUqxO9u.js} +1 -1
- package/dist/assets/{Toggle-Cs3k6I96.js → Toggle-DQMNWZKT.js} +1 -1
- package/dist/assets/ViewTabs-DGU0ZuxB.js +1 -0
- package/dist/assets/{VoiceButton-C3NLotUZ.js → VoiceButton-BPPvDllh.js} +1 -1
- package/dist/assets/{historyTotals-f-E0L9Xw.js → historyTotals-D8Oc3wUK.js} +1 -1
- package/dist/assets/index-9ajPMXBg.js +3097 -0
- package/dist/assets/{index-Bp8XE9A6.css → index-oXqzajWV.css} +1 -1
- package/dist/index.html +2 -2
- package/dist-web/app.css +1 -1
- package/dist-web/app.js +455 -427
- package/package.json +1 -1
- package/plugins/session-manager-dev/.claude-plugin/plugin.json +1 -1
- package/plugins/session-manager-dev/skills/maintaining-md-network/drift-check.md +15 -5
- package/plugins/session-manager-dev/skills/maintaining-md-network/scripts/drift-check.cjs +8 -4
- package/scripts/scheduler-mcp-server.cjs +71 -0
- package/src/main/agentLibrary.cjs +81 -29
- package/src/main/agentsIpc.cjs +21 -16
- package/src/main/build-info.json +4 -4
- package/src/main/index.cjs +9 -0
- package/src/main/ipcSchemas.cjs +35 -2
- package/src/main/lib/epic/epicMint.cjs +61 -6
- package/src/main/lib/epic/epicWorktreeMerge.cjs +11 -9
- package/src/main/lib/epic/epicWorktreeMint.cjs +45 -4
- package/src/main/lib/epic/promptSessionsCreateEpic.cjs +32 -5
- package/src/main/lib/epic/restorableSessions.cjs +749 -0
- package/src/main/lib/feedback-remote/projectHomeAdminRoutes.cjs +61 -0
- package/src/main/lib/feedback-remote/remoteIpcDispatch.cjs +4 -0
- package/src/main/lib/git/branchSweep.cjs +9 -3
- package/src/main/lib/git/gitExec.cjs +8 -1
- package/src/main/lib/git/gitWorktree.cjs +771 -96
- package/src/main/lib/git/jobWorktree.cjs +3 -0
- package/src/main/lib/git/jobWorktreeBootLive.cjs +14 -2
- package/src/main/lib/mcpToolCatalog.cjs +28 -0
- package/src/main/lib/mcpToolsProbe.cjs +831 -0
- package/src/main/lib/mdNetworkScan.cjs +555 -0
- package/src/main/lib/persona-macro/agentPersonaSchema.cjs +18 -5
- package/src/main/lib/persona-macro/builtinMacros.cjs +22 -4
- package/src/main/lib/persona-macro/macroJobDispatch.cjs +17 -2
- package/src/main/lib/persona-macro/shippedPersonaSeeds.cjs +38 -0
- package/src/main/lib/project-pages/competitiveMatrix.cjs +258 -0
- package/src/main/lib/project-pages/matrixHtml.cjs +239 -0
- package/src/main/lib/project-pages/matrixStore.cjs +112 -0
- package/src/main/lib/promptSessionSchema.cjs +5 -0
- package/src/main/lib/scheduler/fixPlanSlug.cjs +15 -1
- package/src/main/lib/scheduler/reaperHelpers.cjs +35 -0
- package/src/main/lib/scheduler/scheduleJobSchema.cjs +2 -0
- package/src/main/lib/scheduler/scheduleJobTransitions.cjs +8 -7
- package/src/main/lib/scheduler/terminalRunOutcome.cjs +61 -15
- package/src/main/projectPages.cjs +51 -7
- package/src/main/runVerify.cjs +8 -3
- package/src/main/scheduler/budget.cjs +146 -7
- package/src/main/scheduler/gitTreeGuard.cjs +92 -20
- package/src/main/scheduler/reviewLadder.cjs +60 -0
- package/src/main/scheduler.cjs +477 -53
- package/src/main/seedAgentPersonas.cjs +1 -1
- package/src/preload/api.d.ts +250 -7
- package/src/preload/apiSurface.json +28 -0
- package/src/preload/index.cjs +6 -0
- package/src/seed/agents/competitive-analyst.md +69 -0
- package/src/seed/agents/competitive-researcher.md +75 -0
- package/src/seed/agents/validator.md +2 -2
- package/dist/assets/AgentLibrary-Bfj862qf.js +0 -2
- package/dist/assets/Extensions-BziIutWV.js +0 -13
- package/dist/assets/Memory-Bq5T33d2.js +0 -25
- package/dist/assets/Scheduler-CkGHMXvo.js +0 -16
- package/dist/assets/Settings-DGxvyajs.js +0 -2
- package/dist/assets/SystemPrompt-CfozyVQx.js +0 -1
- package/dist/assets/ViewTabs-DFXH03tb.js +0 -1
- package/dist/assets/index-CuAfFXNd.js +0 -3086
|
@@ -212,7 +212,32 @@ function withPathLock(lockPath, task) {
|
|
|
212
212
|
}
|
|
213
213
|
|
|
214
214
|
/**
|
|
215
|
-
*
|
|
215
|
+
* restoreRefusal(cwd, index, restoreSessionId, mintAuthority, deps) — why
|
|
216
|
+
* ensureEpic must NOT adopt `restoreSessionId` as a new Epic's
|
|
217
|
+
* claudeSessionId, or null when it may. Runs inside ensureEpic's withPathLock
|
|
218
|
+
* task against the index that task just read, so of two mints restoring the
|
|
219
|
+
* same id the second always sees the row the first wrote.
|
|
220
|
+
*/
|
|
221
|
+
function restoreRefusal(cwd, index, restoreSessionId, mintAuthority, deps) {
|
|
222
|
+
if (mintAuthority !== MINT_AUTHORITY_NEW_EPIC_UI) {
|
|
223
|
+
return "restoring a Claude Code session as an Epic is the New Epic UI's alone (mintAuthority "
|
|
224
|
+
+ `'${MINT_AUTHORITY_NEW_EPIC_UI}'), not '${mintAuthority}'`;
|
|
225
|
+
}
|
|
226
|
+
const owner = Object.entries(index.sessions)
|
|
227
|
+
.find(([, s]) => s && typeof s === 'object' && s.claudeSessionId === restoreSessionId);
|
|
228
|
+
if (owner) {
|
|
229
|
+
return `claude session ${restoreSessionId} already belongs to Epic ${owner[0]} in this project `
|
|
230
|
+
+ '(EPIC : claude-session is 1:1)';
|
|
231
|
+
}
|
|
232
|
+
// Lazy: restorableSessions.cjs requires this module at load time, so a
|
|
233
|
+
// top-level require here would hand it a half-built exports object.
|
|
234
|
+
const { checkRestorableSessionSync } = require('./restorableSessions.cjs');
|
|
235
|
+
const check = checkRestorableSessionSync(cwd, restoreSessionId, deps);
|
|
236
|
+
return check.ok ? null : check.message;
|
|
237
|
+
}
|
|
238
|
+
|
|
239
|
+
/**
|
|
240
|
+
* ensureEpic(cwd, { epicId?, goalText, tag?, status?, openingPrompt?, source?, agentType?, model?, effort?, developLoop?, mintAuthority?, restoreSessionId? }, deps?) → Promise<{ epicId, prdDir, created }>
|
|
216
241
|
*
|
|
217
242
|
* Two behaviors, and only two:
|
|
218
243
|
* - JOIN (the default, for every automated caller): `epicId` names an Epic
|
|
@@ -222,6 +247,15 @@ function withPathLock(lockPath, task) {
|
|
|
222
247
|
* creates a brand-new Epic. No similarity/keyword matching runs first — the
|
|
223
248
|
* human asked for a new Epic, so they get a new Epic.
|
|
224
249
|
*
|
|
250
|
+
* RESTORE is a MINT whose `restoreSessionId` (default null) names an existing
|
|
251
|
+
* Claude Code CLI session: the new Epic adopts it as its claudeSessionId and is
|
|
252
|
+
* marked `restoredSession: true`, so a human can carry a plain-CLI conversation
|
|
253
|
+
* on as an Epic. Any non-null value is a restore request; it is refused unless
|
|
254
|
+
* mintAuthority is MINT_AUTHORITY_NEW_EPIC_UI, no Epic of this project already
|
|
255
|
+
* owns the id (EPIC : claude-session stays 1:1), and restorableSessions.cjs's
|
|
256
|
+
* checkRestorableSessionSync finds the transcript under this project's own
|
|
257
|
+
* `~/.claude/projects/<encodeCwd(cwd)>/` dir (`deps.homeDir` moves HOME for tests).
|
|
258
|
+
*
|
|
225
259
|
* Every Epic is BORN 'proposed'; `status` defaults to it and the mint branch
|
|
226
260
|
* rejects any other value outright (fail-closed, mirroring opsOwnership.cjs's
|
|
227
261
|
* assertOpsWrite). Activation ('proposed' → 'active') happens exactly once, in
|
|
@@ -231,7 +265,7 @@ function withPathLock(lockPath, task) {
|
|
|
231
265
|
* The Epic's id doubles as its directory name under scheduler/epics/, so the
|
|
232
266
|
* PromptSession ↔ on-disk Epic mapping is 1:1 with no lookup table.
|
|
233
267
|
*/
|
|
234
|
-
function ensureEpic(cwd, { goalText, tag, epicId: explicitEpicId, status = 'proposed', openingPrompt = null, sections = null, source = null, agentType = null, model = null, effort = null, developLoop = null, mintAuthority = null } = {}, deps = {}) {
|
|
268
|
+
function ensureEpic(cwd, { goalText, tag, epicId: explicitEpicId, status = 'proposed', openingPrompt = null, sections = null, source = null, agentType = null, model = null, effort = null, developLoop = null, mintAuthority = null, restoreSessionId = null } = {}, deps = {}) {
|
|
235
269
|
if (!cwd || typeof cwd !== 'string') throw new Error('ensureEpic: cwd is required');
|
|
236
270
|
// A relative cwd (e.g. a caller passing '.') would otherwise get stored
|
|
237
271
|
// verbatim on the minted Epic's `cwd` field — the renderer's EpicsWorkspace
|
|
@@ -309,15 +343,28 @@ function ensureEpic(cwd, { goalText, tag, epicId: explicitEpicId, status = 'prop
|
|
|
309
343
|
}
|
|
310
344
|
}
|
|
311
345
|
|
|
346
|
+
// RESTORE GATE (see restoreRefusal and the JSDoc above). An empty or
|
|
347
|
+
// malformed id is refused, never quietly swapped for a fresh session.
|
|
348
|
+
const restoring = restoreSessionId !== null;
|
|
349
|
+
if (restoring) {
|
|
350
|
+
const reason = restoreRefusal(cwd, index, restoreSessionId, mintAuthority, deps);
|
|
351
|
+
if (reason) {
|
|
352
|
+
appendAuditEvent('epic_mint_refused', { cwd, epicId: null, status, reason });
|
|
353
|
+
throw new Error(`ensureEpic: ${reason}`);
|
|
354
|
+
}
|
|
355
|
+
}
|
|
356
|
+
|
|
312
357
|
const epicId = `${slugify(goalText)}-${crypto.randomUUID().slice(0, 8)}`;
|
|
313
358
|
const now = new Date().toISOString();
|
|
314
359
|
const session = {
|
|
315
360
|
id: epicId,
|
|
316
361
|
cwd,
|
|
317
362
|
goalText: String(goalText || ''),
|
|
318
|
-
//
|
|
319
|
-
//
|
|
320
|
-
|
|
363
|
+
// A fresh UUID, never shared with a SessionTab. A restored Epic instead
|
|
364
|
+
// adopts an existing CLI session that no Epic or SessionTab owns (the
|
|
365
|
+
// RESTORE GATE above refuses an id any Epic of this project holds).
|
|
366
|
+
claudeSessionId: restoring ? restoreSessionId : crypto.randomUUID(),
|
|
367
|
+
...(restoring ? { restoredSession: true } : {}),
|
|
321
368
|
// 'proposed' files the Epic WITHOUT starting it — nothing runs until the
|
|
322
369
|
// human presses Approve & start in the Epics workspace.
|
|
323
370
|
status,
|
|
@@ -386,7 +433,15 @@ function ensureEpic(cwd, { goalText, tag, epicId: explicitEpicId, status = 'prop
|
|
|
386
433
|
|
|
387
434
|
// Every mint is logged — the trace-back point for "who created this Epic"
|
|
388
435
|
// (see auditLog.cjs).
|
|
389
|
-
appendAuditEvent('epic_mint', {
|
|
436
|
+
appendAuditEvent('epic_mint', {
|
|
437
|
+
cwd,
|
|
438
|
+
epicId,
|
|
439
|
+
status,
|
|
440
|
+
tag: tag ?? null,
|
|
441
|
+
goalText: session.goalText,
|
|
442
|
+
source: source ?? null,
|
|
443
|
+
...(restoring ? { restoredSession: true } : {}),
|
|
444
|
+
});
|
|
390
445
|
|
|
391
446
|
const prdDir = resolveEpicPrdWriteDir(cwd, epicId);
|
|
392
447
|
fs.mkdirSync(prdDir, { recursive: true });
|
|
@@ -7,12 +7,13 @@
|
|
|
7
7
|
* epic-worktree-isolation chain started by PRD 1032/1033).
|
|
8
8
|
*
|
|
9
9
|
* This is the ONLY point where that per-Epic isolation resolves back into
|
|
10
|
-
* the shared tree — never mid-session (see gitWorktree.cjs's
|
|
11
|
-
*
|
|
12
|
-
* reuses verbatim
|
|
13
|
-
*
|
|
14
|
-
* `
|
|
15
|
-
*
|
|
10
|
+
* the shared tree — never mid-session (see gitWorktree.cjs's `integrateBranch`
|
|
11
|
+
* for the ff-only -> linear replay -> merge-commit fallback -> abort-and-flag
|
|
12
|
+
* algorithm this reuses verbatim, and scheduler-operations.md §5a for every
|
|
13
|
+
* case that still writes a merge commit). The single caller is
|
|
14
|
+
* `markCompleted`'s merge-before-archive checkpoint (via
|
|
15
|
+
* `attemptMergeToMainInternal` in `src/renderer/state/promptSessions.ts`);
|
|
16
|
+
* there is no explicit "merge to main" action.
|
|
16
17
|
*
|
|
17
18
|
* On success the worktree checkout is torn down (cleanupEpicWorktree) since
|
|
18
19
|
* its content now safely lives on the main tree. On a real conflict, the
|
|
@@ -53,9 +54,10 @@ async function mergeEpicToMainViaIpc(cwd, epicId, branch, dir, carriedPaths) {
|
|
|
53
54
|
console.log(`[epicWorktreeMerge] ${epicId}: needs manual resolution (${outcome.reason})`);
|
|
54
55
|
return { ok: false, status: 'needs_merge_resolution', reason: outcome.reason };
|
|
55
56
|
}
|
|
56
|
-
// Clean ff-only
|
|
57
|
-
// no-op — either way the branch's content
|
|
58
|
-
// never ahead), so the checkout has nothing
|
|
57
|
+
// Clean landing (ff-only, linear replay, or the merge-commit fallback),
|
|
58
|
+
// or a legitimate no-new-commits no-op — either way the branch's content
|
|
59
|
+
// is safely reflected (or was never ahead), so the checkout has nothing
|
|
60
|
+
// left to guard.
|
|
59
61
|
await cleanupEpicWorktree({ cwd, dir, branch, keepBranch: false });
|
|
60
62
|
return { ok: true, status: 'merged', integrated: outcome.integrated };
|
|
61
63
|
}
|
|
@@ -19,13 +19,23 @@
|
|
|
19
19
|
* isolation — its outstanding diff is carried into the fresh worktree
|
|
20
20
|
* instead (gitWorktree.cjs's createWorktree).
|
|
21
21
|
*
|
|
22
|
+
* A restored Epic (`restoredSession: true`, minted around an existing CLI
|
|
23
|
+
* session) is never isolated, at approve or reopen: its transcript lives under
|
|
24
|
+
* the project checkout's ~/.claude/projects encoding and its history (and any
|
|
25
|
+
* uncommitted work) refers to the main checkout, so planEpicSpawn resumes it
|
|
26
|
+
* from the project cwd — a worktree would sit unused while its queue row
|
|
27
|
+
* falsely showed isolation.
|
|
28
|
+
*
|
|
22
29
|
* Mirrors promptSessionsCreateEpic.cjs's shape: `validatePath(cwd)` closes
|
|
23
30
|
* the same "arbitrary renderer-supplied cwd" gap that handler documents,
|
|
24
31
|
* since this is likewise reachable from the renderer over IPC.
|
|
25
32
|
*/
|
|
26
33
|
|
|
27
34
|
const path = require('node:path');
|
|
28
|
-
|
|
35
|
+
// Called through the module object (not destructured) so tests can observe
|
|
36
|
+
// and substitute createEpicWorktree — gitWorktree.cjs does the same for
|
|
37
|
+
// captureAndCarryBaseDiff.
|
|
38
|
+
const gitWorktree = require('../git/gitWorktree.cjs');
|
|
29
39
|
const { validatePath } = require('../../config.cjs');
|
|
30
40
|
|
|
31
41
|
/**
|
|
@@ -33,8 +43,9 @@ const { validatePath } = require('../../config.cjs');
|
|
|
33
43
|
*
|
|
34
44
|
* Returns the `worktree` field shape (`{ dir, branch, baseCwd, status,
|
|
35
45
|
* carriedPaths }`) ready to persist onto the Epic record on success, or
|
|
36
|
-
* `null` on any failure — createEpicWorktree/
|
|
37
|
-
*
|
|
46
|
+
* `null` for a restored Epic or on any failure — createEpicWorktree/
|
|
47
|
+
* createWorktree never throw, and neither does isRestoredEpic, so this
|
|
48
|
+
* never does either.
|
|
38
49
|
*/
|
|
39
50
|
/** In-flight mints, keyed by resolved cwd + epicId (turn 1 awaits these — awaitPendingEpicWorktree). */
|
|
40
51
|
const pendingMints = new Map();
|
|
@@ -83,8 +94,38 @@ function __resetPendingForTests() {
|
|
|
83
94
|
pendingMints.clear();
|
|
84
95
|
}
|
|
85
96
|
|
|
97
|
+
const isFlaggedRestored = (record) => !!record && typeof record === 'object' && record.restoredSession === true;
|
|
98
|
+
|
|
99
|
+
/**
|
|
100
|
+
* isRestoredEpic(cwd, epicId) → boolean. Reads the Epic's row from
|
|
101
|
+
* active-index.json (approve: the proposed row is there). When the index has
|
|
102
|
+
* no row, reads the Epic's own prompt-sessions/<epicId>.json instead
|
|
103
|
+
* (reopen: completion tombstones the Epic out of the index, and epicReopen's
|
|
104
|
+
* provisionWorktree mints before writing the row back — the archive holds
|
|
105
|
+
* the record under `session`, a live mirror holds it flat). Never throws —
|
|
106
|
+
* an unreadable record proceeds as today (not restored).
|
|
107
|
+
*/
|
|
108
|
+
function isRestoredEpic(cwd, epicId) {
|
|
109
|
+
try {
|
|
110
|
+
// Lazy: requiring epicMint.cjs at load would risk a require cycle.
|
|
111
|
+
const { readActiveIndex } = require('./epicMint.cjs');
|
|
112
|
+
const { sessions } = readActiveIndex(cwd);
|
|
113
|
+
if (Object.prototype.hasOwnProperty.call(sessions, epicId)) return isFlaggedRestored(sessions[epicId]);
|
|
114
|
+
const { epicMirrorPath } = require('./epicStatusMirror.cjs');
|
|
115
|
+
const { readJsonOrSync } = require('../util/atomicFs.cjs');
|
|
116
|
+
const mirror = readJsonOrSync(epicMirrorPath(cwd, epicId), null);
|
|
117
|
+
return isFlaggedRestored(mirror) || isFlaggedRestored(mirror && mirror.session);
|
|
118
|
+
} catch {
|
|
119
|
+
return false;
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
|
|
86
123
|
async function mintEpicWorktree(cwd, epicId) {
|
|
87
|
-
|
|
124
|
+
if (isRestoredEpic(cwd, epicId)) {
|
|
125
|
+
console.log(`[epicWorktreeMint] ${epicId}: not isolated (restored-session)`);
|
|
126
|
+
return null;
|
|
127
|
+
}
|
|
128
|
+
const result = await gitWorktree.createEpicWorktree({ cwd, epicId });
|
|
88
129
|
if (!result.ok) {
|
|
89
130
|
console.log(`[epicWorktreeMint] ${epicId}: not isolated (${result.reason})`);
|
|
90
131
|
return null;
|
|
@@ -11,13 +11,18 @@
|
|
|
11
11
|
* "own file, own register*Handlers export, wired from index.cjs" shape for
|
|
12
12
|
* the neighboring active-index merge IPC) rather than growing epicMint.cjs
|
|
13
13
|
* itself, since this is IPC-registration plumbing, not Epic-minting logic.
|
|
14
|
+
*
|
|
15
|
+
* Also home to 'promptSessions:list-restorable', the New Session card's
|
|
16
|
+
* "Restore a session" picker, whose pick comes back as create-epic's
|
|
17
|
+
* `restoreSessionId`.
|
|
14
18
|
*/
|
|
15
19
|
|
|
16
20
|
const { ensureEpic, readActiveIndex, MINT_AUTHORITY_NEW_EPIC_UI } = require('./epicMint.cjs');
|
|
21
|
+
const { listRestorableSessions } = require('./restorableSessions.cjs');
|
|
17
22
|
const { validatePath } = require('../../config.cjs');
|
|
18
23
|
|
|
19
24
|
/**
|
|
20
|
-
* createEpicViaIpc(cwd, { goalText, tag?, agentType?, source? }) → Promise<{ epicId, session }>
|
|
25
|
+
* createEpicViaIpc(cwd, { goalText, tag?, agentType?, source?, restoreSessionId? }) → Promise<{ epicId, session }>
|
|
21
26
|
*
|
|
22
27
|
* THE one Epic-creation path (epicMint.cjs's SINGLE-CREATOR LAW): this handler
|
|
23
28
|
* holds `MINT_AUTHORITY_NEW_EPIC_UI`, the token that unlocks ensureEpic's mint
|
|
@@ -40,8 +45,12 @@ const { validatePath } = require('../../config.cjs');
|
|
|
40
45
|
* filesystem location — the same boundary every other renderer-facing path
|
|
41
46
|
* IPC (config:read-json/write-json, lib/epic/activeIndexMerge.cjs's own merge) is
|
|
42
47
|
* already required to pass through.
|
|
48
|
+
*
|
|
49
|
+
* `restoreSessionId` (absent = a normal mint) asks ensureEpic to adopt that
|
|
50
|
+
* existing Claude Code CLI session as the new Epic's claudeSessionId. ensureEpic's
|
|
51
|
+
* restore gate decides; a refused id rejects the call, never mints a fresh session.
|
|
43
52
|
*/
|
|
44
|
-
async function createEpicViaIpc(cwd, { goalText, tag, agentType, model, effort, developLoop, source, openingPrompt, sections } = {}) {
|
|
53
|
+
async function createEpicViaIpc(cwd, { goalText, tag, agentType, model, effort, developLoop, source, openingPrompt, sections, restoreSessionId } = {}) {
|
|
45
54
|
validatePath(cwd);
|
|
46
55
|
const { epicId } = await ensureEpic(cwd, {
|
|
47
56
|
goalText,
|
|
@@ -53,6 +62,7 @@ async function createEpicViaIpc(cwd, { goalText, tag, agentType, model, effort,
|
|
|
53
62
|
source,
|
|
54
63
|
openingPrompt,
|
|
55
64
|
sections,
|
|
65
|
+
restoreSessionId,
|
|
56
66
|
mintAuthority: MINT_AUTHORITY_NEW_EPIC_UI,
|
|
57
67
|
status: 'proposed',
|
|
58
68
|
});
|
|
@@ -60,14 +70,31 @@ async function createEpicViaIpc(cwd, { goalText, tag, agentType, model, effort,
|
|
|
60
70
|
return { epicId, session: index.sessions[epicId] };
|
|
61
71
|
}
|
|
62
72
|
|
|
73
|
+
/**
|
|
74
|
+
* listRestorableViaIpc(cwd) → Promise<RestorableList>
|
|
75
|
+
*
|
|
76
|
+
* This project's Claude Code CLI sessions that no Epic owns yet, newest first
|
|
77
|
+
* (restorableSessions.cjs's listRestorableSessions). `cwd` is renderer-supplied,
|
|
78
|
+
* so it passes the same validatePath boundary as createEpicViaIpc before any
|
|
79
|
+
* transcript dir is read; an out-of-bounds cwd rejects.
|
|
80
|
+
*/
|
|
81
|
+
async function listRestorableViaIpc(cwd) {
|
|
82
|
+
validatePath(cwd);
|
|
83
|
+
return listRestorableSessions({ cwd });
|
|
84
|
+
}
|
|
85
|
+
|
|
63
86
|
function registerPromptSessionsCreateEpicHandlers() {
|
|
64
87
|
const { ipcMain } = require('electron');
|
|
65
88
|
const { schemas: s, validated: v } = require('../../ipcSchemas.cjs');
|
|
66
89
|
ipcMain.handle(
|
|
67
90
|
'promptSessions:create-epic',
|
|
68
|
-
v(s.promptSessionsCreateEpic, ({ cwd, goalText, tag, agentType, model, effort, developLoop, source, openingPrompt, sections }) =>
|
|
69
|
-
createEpicViaIpc(cwd, { goalText, tag, agentType, model, effort, developLoop, source, openingPrompt, sections })),
|
|
91
|
+
v(s.promptSessionsCreateEpic, ({ cwd, goalText, tag, agentType, model, effort, developLoop, source, openingPrompt, sections, restoreSessionId }) =>
|
|
92
|
+
createEpicViaIpc(cwd, { goalText, tag, agentType, model, effort, developLoop, source, openingPrompt, sections, restoreSessionId })),
|
|
93
|
+
);
|
|
94
|
+
ipcMain.handle(
|
|
95
|
+
'promptSessions:list-restorable',
|
|
96
|
+
v(s.promptSessionsListRestorable, ({ cwd }) => listRestorableViaIpc(cwd)),
|
|
70
97
|
);
|
|
71
98
|
}
|
|
72
99
|
|
|
73
|
-
module.exports = { createEpicViaIpc, registerPromptSessionsCreateEpicHandlers };
|
|
100
|
+
module.exports = { createEpicViaIpc, listRestorableViaIpc, registerPromptSessionsCreateEpicHandlers };
|