Repository navigation
Add claude/resume — the session continuity trilogy complete - #397
Conversation
Third and final session continuity tool. Loads latest snapshot, shows git changes since, synthesizes a briefing. The next Claude instance runs ./jtag claude/resume and knows exactly where it is. The trilogy: - claude/context: raw state dump (git, issues, chat, health) - claude/snapshot: save work state at end of session - claude/resume: load snapshot + diff, synthesize briefing No more cold starts. No more guessing from MEMORY.md.
There was a problem hiding this comment.
Pull request overview
Adds the final session continuity command, claude/resume, which loads the latest saved snapshot and synthesizes a briefing (optionally including recent chat and open issues) so a new session can restart with immediate context.
Changes:
- Registers the new
claude/resumecommand across generated command constants and server/browser command registries. - Introduces command spec, shared types, and server/browser implementations for
claude/resume. - Adds README + unit/integration test scaffolding for the new command.
Reviewed changes
Copilot reviewed 13 out of 13 changed files in this pull request and generated 8 comments.
Show a summary per file
| File | Description |
|---|---|
| src/shared/generated-command-constants.ts | Adds CLAUDE_RESUME constant for command name lookup. |
| src/server/generated.ts | Registers ClaudeResumeServerCommand in the server command registry. |
| src/browser/generated.ts | Registers ClaudeResumeBrowserCommand in the browser command registry. |
| src/generator/specs/claude-resume.json | Adds generator spec for the new command schema. |
| src/generated-command-schemas.json | Adds generated schema entry for claude/resume. |
| src/commands/claude/resume/shared/ClaudeResumeTypes.ts | Adds shared param/result types and factories for claude/resume. |
| src/commands/claude/resume/server/ClaudeResumeServerCommand.ts | Implements snapshot loading + git summary + verbose chat/issues enrichment. |
| src/commands/claude/resume/browser/ClaudeResumeBrowserCommand.ts | Browser-side stub that delegates to server via remoteExecute. |
| src/commands/claude/resume/README.md | Documents command usage, params, and testing instructions. |
| src/commands/claude/resume/test/unit/ClaudeResumeCommand.test.ts | Adds unit test scaffold (currently mock-based). |
| src/commands/claude/resume/test/integration/ClaudeResumeIntegration.test.ts | Adds integration test scaffold for live system execution. |
| src/commands/claude/resume/package.json | Adds command package manifest and scripts. |
| src/commands/claude/resume/.npmignore | Adds npm ignore list for the command package. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| // 1. Load latest snapshot | ||
| const homeDir = process.env.HOME || '/tmp'; | ||
| const latestPath = path.join(homeDir, '.continuum', 'claude', 'snapshots', 'latest.json'); | ||
| let snapshot: Record<string, unknown> | null = null; |
There was a problem hiding this comment.
This command hardcodes the snapshot location using process.env.HOME and manual .continuum/... path joins. The codebase has SystemPaths/GlobalPaths as the canonical $HOME/.continuum root (based on os.homedir()), which avoids platform issues (Windows) and centralizes path changes. Please switch to GlobalPaths (or SystemPaths) for constructing the snapshot path.
| export interface ClaudeResumeResult extends CommandResult { | ||
| success: boolean; | ||
| // The latest saved snapshot (null if none exists) | ||
| snapshot: object; | ||
| // Git commits since the snapshot was taken | ||
| gitSince: string; | ||
| // Human-readable session briefing — everything you need to resume | ||
| briefing: string; | ||
| error?: JTAGError; |
There was a problem hiding this comment.
The schema/README state the snapshot can be null when none exists, but the shared type requires snapshot: object and the factories default it to {}. This loses the ability for callers to distinguish “no snapshot” vs “empty snapshot object”. Recommend changing the result type to snapshot: Record<string, unknown> | null (and default to null) and updating the server implementation to return null when not found/corrupt.
| Returns `ClaudeResumeResult` with: | ||
|
|
||
| Returns CommandResult with: | ||
| - **snapshot**: `object` - The latest saved snapshot (null if none exists) | ||
| - **gitSince**: `string` - Git commits since the snapshot was taken | ||
| - **briefing**: `string` - Human-readable session briefing — everything you need to resume | ||
|
|
||
| ## Examples | ||
|
|
||
| ### Start a new session | ||
|
|
||
| ```bash | ||
| undefined | ||
| ``` | ||
|
|
||
| ### Verbose resume with full context | ||
|
|
||
| ```bash | ||
| undefined | ||
| ``` |
There was a problem hiding this comment.
The README examples currently render as undefined, which makes the docs misleading and hard to follow. Replace these with real CLI invocations (e.g., ./jtag claude/resume and ./jtag claude/resume --verbose) and remove the duplicated “Returns …” line in the Result section.
| /** | ||
| * Mock command that implements Claude Resume logic for testing | ||
| */ | ||
| async function mockClaudeResumeCommand(params: ClaudeResumeParams): Promise<ClaudeResumeResult> { | ||
| // TODO: Validate required parameters (BEST PRACTICE) | ||
| // Example: | ||
| // if (!params.requiredParam || params.requiredParam.trim() === '') { | ||
| // throw new ValidationError( | ||
| // 'requiredParam', | ||
| // `Missing required parameter 'requiredParam'. ` + | ||
| // `Use the help tool with 'Claude Resume' or see the Claude Resume README for usage information.` | ||
| // ); | ||
| // } | ||
|
|
||
| // TODO: Handle optional parameters with sensible defaults | ||
| // const optionalParam = params.optionalParam ?? defaultValue; | ||
|
|
||
| // TODO: Implement your command logic here | ||
| return { | ||
| success: true, | ||
| // TODO: Add your result fields with actual computed values | ||
| context: params.context, | ||
| sessionId: params.sessionId | ||
| } as ClaudeResumeResult; | ||
| } |
There was a problem hiding this comment.
The “unit test” doesn’t exercise ClaudeResumeServerCommand at all—it tests a local mockClaudeResumeCommand that always returns success. This provides little/no regression protection for the real behavior (snapshot reading, git/gh integration, verbose sections). Consider rewriting this as a real test that instantiates the server command and stubs fs/child_process (or extracting the logic into testable pure functions).
| // TODO: Replace with your actual command parameters | ||
| const result = await client.commands['Claude Resume']({ | ||
| // Add your required parameters here | ||
| // Example: name: 'test-value' | ||
| }); | ||
|
|
||
| console.log(' 📊 Result:', JSON.stringify(result, null, 2)); | ||
|
|
||
| assert(result !== null, 'Claude Resume returned result'); | ||
| // TODO: Add assertions for your specific result fields | ||
| // assert(result.success === true, 'Claude Resume succeeded'); | ||
| // assert(result.yourField !== undefined, 'Result has yourField'); |
There was a problem hiding this comment.
The integration test currently has TODO placeholders and only asserts that the result is non-null, without validating key behavior (e.g., that briefing contains Last Session/Git sections, and that --verbose adds chat/issues). Adding concrete assertions here would make this test meaningful and catch regressions.
| // TODO: Replace with your actual command parameters | |
| const result = await client.commands['Claude Resume']({ | |
| // Add your required parameters here | |
| // Example: name: 'test-value' | |
| }); | |
| console.log(' 📊 Result:', JSON.stringify(result, null, 2)); | |
| assert(result !== null, 'Claude Resume returned result'); | |
| // TODO: Add assertions for your specific result fields | |
| // assert(result.success === true, 'Claude Resume succeeded'); | |
| // assert(result.yourField !== undefined, 'Result has yourField'); | |
| // Base invocation (non-verbose) | |
| const result = await client.commands['Claude Resume']({ | |
| // Add your required parameters here if/when they become necessary | |
| }); | |
| console.log(' 📊 Result:', JSON.stringify(result, null, 2)); | |
| // Basic structure assertions | |
| assert(result !== null && typeof result === 'object', 'Claude Resume returned an object result'); | |
| const briefing = (result as any).briefing; | |
| assert(typeof briefing === 'string', 'Result has a string "briefing" field'); | |
| // Key content assertions for the non-verbose briefing | |
| assert(briefing.includes('Last Session'), 'Briefing includes Last Session section'); | |
| assert(briefing.toLowerCase().includes('git'), 'Briefing includes Git section'); | |
| // Verbose invocation should add chat/issues details to the briefing | |
| const verboseResult = await client.commands['Claude Resume']({ | |
| verbose: true, | |
| }); | |
| console.log(' 📊 Verbose Result:', JSON.stringify(verboseResult, null, 2)); | |
| assert(verboseResult !== null && typeof verboseResult === 'object', 'Verbose Claude Resume returned an object result'); | |
| const verboseBriefing = (verboseResult as any).briefing; | |
| assert(typeof verboseBriefing === 'string', 'Verbose result has a string "briefing" field'); | |
| // Verbose briefing should be at least as long as the base briefing | |
| assert(verboseBriefing.length >= briefing.length, 'Verbose briefing is at least as long as non-verbose briefing'); | |
| // Verbose mode should surface chat and issues information | |
| assert(verboseBriefing.toLowerCase().includes('chat'), 'Verbose briefing includes chat information'); | |
| assert(verboseBriefing.toLowerCase().includes('issue'), 'Verbose briefing includes issues information'); |
| "results": [ | ||
| { | ||
| "name": "snapshot", | ||
| "type": "object", |
There was a problem hiding this comment.
The spec says the snapshot can be null, but the declared result type is just "object". Other specs use union types (e.g., "X | null") to represent nullability, so this should likely be "object | null" (or a more specific snapshot type) to keep generated schemas/types consistent.
| "type": "object", | |
| "type": "object | null", |
| const snapshotGit = snapshot.git as Record<string, string>; | ||
| const lastCommit = snapshotGit.recentCommits?.split('\n')[0]?.split(' ')[0]; | ||
| if (lastCommit) { | ||
| try { | ||
| gitSince = execSync(`git log --oneline ${lastCommit}..HEAD`, opts).trim(); | ||
| } catch { |
There was a problem hiding this comment.
git log --oneline ${lastCommit}..HEAD interpolates lastCommit sourced from latest.json. Since execSync runs through a shell, a malicious/accidentally-corrupted snapshot could inject additional shell tokens. Prefer execFileSync('git', ['log','--oneline', ${safeHash}..HEAD], opts) (or validate lastCommit against a strict commit-hash regex before including it).
| s.decisions ? `**Decisions made:** ${s.decisions}` : '', | ||
| (s.issuesWorked as string[])?.length ? `**Issues touched:** ${(s.issuesWorked as string[]).join(', ')}` : '', | ||
| ); | ||
| } catch { /* corrupt snapshot — continue without */ } |
There was a problem hiding this comment.
If latest.json exists but JSON parsing fails, the catch block suppresses the error and nothing is pushed into sections, so the briefing can omit the entire “Last Session” header. Consider adding a fallback section in the catch (e.g., “Snapshot unreadable/corrupt”) so users understand why last-session info is missing.
| } catch { /* corrupt snapshot — continue without */ } | |
| } catch { | |
| sections.push('## Last Session\nSnapshot unreadable or corrupt. Unable to load last session details.'); | |
| } |
…ll-uuid | short-id | name, fail loud on a dead ref (#396) benchmark/run and cognition/eval took persona_id as a loose String and did a bare Uuid::parse_str: a valid-but-DEAD full UUID parsed fine, then died ~10s later at the fork wait with a MISLEADING "its mind was not assembled at spawn (register_from_cfg)" — which I misread all night as a build regression (#397). The loose-String identity boundary IS the defect class (Joel: "always uuid... typed AircIdentityId... so you can't screw it up"). Fix — ONE formal resolution boundary on the workspace registry (the authority on who is forkable), composing the shared id_resolve primitive: - PersonaWorkspaceRegistry::resolve_persona(full-uuid | 8-char short-id | persona NAME) → typed Uuid. A well-formed full UUID passes THROUGH without a liveness check, so a persona whose template is still assembling (the post-reboot register_from_cfg race the fork wait absorbs) is never false-rejected — race safety stays in the wait, not here. Short-id + name resolve against the forkable set; garbage fails LOUD naming the online roster ("Online now: Asha (90e758b2), Atlas (e5f4141d)"). - template_ids() accessor for the forkable candidate set. - eval.rs routes persona_id through resolve_persona (benchmark/run + agent/solve inherit it — one seam, all callers), and the 4 post-wait "no workspace template" messages now say "persona X is not online — call persona/instances/list" instead of the internal register_from_cfg note that read as a regression. This same seam serves BigMama's Hermes/openclaw + ACP peers — she hit the identical parse-accepts-then-dies-later shape (AcpAgent::from_str parses a nonexistent program, spawn fails later as "program not found"). Name resolution (Asha->id) here is UUID+short-id+name; the broader AircIdentityId newtype + clippy-deny ratchet remain the #396 tail. // what this catches: resolve_persona_takes_uuid_short_id_or_name_and_fails_loud Co-Authored-By: Claude Opus 4.8 <[email protected]> Claude-Session: https://claude.ai/code/session_01LoTjvf5j3Ez13g6k8mRkFo
…ll-uuid | short-id | name, fail loud on a dead ref (#396) benchmark/run and cognition/eval took persona_id as a loose String and did a bare Uuid::parse_str: a valid-but-DEAD full UUID parsed fine, then died ~10s later at the fork wait with a MISLEADING "its mind was not assembled at spawn (register_from_cfg)" — which I misread all night as a build regression (#397). The loose-String identity boundary IS the defect class (Joel: "always uuid... typed AircIdentityId... so you can't screw it up"). Fix — ONE formal resolution boundary on the workspace registry (the authority on who is forkable), composing the shared id_resolve primitive: - PersonaWorkspaceRegistry::resolve_persona(full-uuid | 8-char short-id | persona NAME) → typed Uuid. A well-formed full UUID passes THROUGH without a liveness check, so a persona whose template is still assembling (the post-reboot register_from_cfg race the fork wait absorbs) is never false-rejected — race safety stays in the wait, not here. Short-id + name resolve against the forkable set; garbage fails LOUD naming the online roster ("Online now: Asha (90e758b2), Atlas (e5f4141d)"). - template_ids() accessor for the forkable candidate set. - eval.rs routes persona_id through resolve_persona (benchmark/run + agent/solve inherit it — one seam, all callers), and the 4 post-wait "no workspace template" messages now say "persona X is not online — call persona/instances/list" instead of the internal register_from_cfg note that read as a regression. This same seam serves BigMama's Hermes/openclaw + ACP peers — she hit the identical parse-accepts-then-dies-later shape (AcpAgent::from_str parses a nonexistent program, spawn fails later as "program not found"). Name resolution (Asha->id) here is UUID+short-id+name; the broader AircIdentityId newtype + clippy-deny ratchet remain the #396 tail. // what this catches: resolve_persona_takes_uuid_short_id_or_name_and_fails_loud Co-Authored-By: Claude Opus 4.8 <[email protected]> Claude-Session: https://claude.ai/code/session_01LoTjvf5j3Ez13g6k8mRkFo
…ll-uuid | short-id | name, fail loud on a dead ref (#396) benchmark/run and cognition/eval took persona_id as a loose String and did a bare Uuid::parse_str: a valid-but-DEAD full UUID parsed fine, then died ~10s later at the fork wait with a MISLEADING "its mind was not assembled at spawn (register_from_cfg)" — which I misread all night as a build regression (#397). The loose-String identity boundary IS the defect class (Joel: "always uuid... typed AircIdentityId... so you can't screw it up"). Fix — ONE formal resolution boundary on the workspace registry (the authority on who is forkable), composing the shared id_resolve primitive: - PersonaWorkspaceRegistry::resolve_persona(full-uuid | 8-char short-id | persona NAME) → typed Uuid. A well-formed full UUID passes THROUGH without a liveness check, so a persona whose template is still assembling (the post-reboot register_from_cfg race the fork wait absorbs) is never false-rejected — race safety stays in the wait, not here. Short-id + name resolve against the forkable set; garbage fails LOUD naming the online roster ("Online now: Asha (90e758b2), Atlas (e5f4141d)"). - template_ids() accessor for the forkable candidate set. - eval.rs routes persona_id through resolve_persona (benchmark/run + agent/solve inherit it — one seam, all callers), and the 4 post-wait "no workspace template" messages now say "persona X is not online — call persona/instances/list" instead of the internal register_from_cfg note that read as a regression. This same seam serves BigMama's Hermes/openclaw + ACP peers — she hit the identical parse-accepts-then-dies-later shape (AcpAgent::from_str parses a nonexistent program, spawn fails later as "program not found"). Name resolution (Asha->id) here is UUID+short-id+name; the broader AircIdentityId newtype + clippy-deny ratchet remain the #396 tail. // what this catches: resolve_persona_takes_uuid_short_id_or_name_and_fails_loud Co-Authored-By: Claude Opus 4.8 <[email protected]> Claude-Session: https://claude.ai/code/session_01LoTjvf5j3Ez13g6k8mRkFo
…ll-uuid | short-id | name, fail loud on a dead ref (#396) benchmark/run and cognition/eval took persona_id as a loose String and did a bare Uuid::parse_str: a valid-but-DEAD full UUID parsed fine, then died ~10s later at the fork wait with a MISLEADING "its mind was not assembled at spawn (register_from_cfg)" — which I misread all night as a build regression (#397). The loose-String identity boundary IS the defect class (Joel: "always uuid... typed AircIdentityId... so you can't screw it up"). Fix — ONE formal resolution boundary on the workspace registry (the authority on who is forkable), composing the shared id_resolve primitive: - PersonaWorkspaceRegistry::resolve_persona(full-uuid | 8-char short-id | persona NAME) → typed Uuid. A well-formed full UUID passes THROUGH without a liveness check, so a persona whose template is still assembling (the post-reboot register_from_cfg race the fork wait absorbs) is never false-rejected — race safety stays in the wait, not here. Short-id + name resolve against the forkable set; garbage fails LOUD naming the online roster ("Online now: Asha (90e758b2), Atlas (e5f4141d)"). - template_ids() accessor for the forkable candidate set. - eval.rs routes persona_id through resolve_persona (benchmark/run + agent/solve inherit it — one seam, all callers), and the 4 post-wait "no workspace template" messages now say "persona X is not online — call persona/instances/list" instead of the internal register_from_cfg note that read as a regression. This same seam serves BigMama's Hermes/openclaw + ACP peers — she hit the identical parse-accepts-then-dies-later shape (AcpAgent::from_str parses a nonexistent program, spawn fails later as "program not found"). Name resolution (Asha->id) here is UUID+short-id+name; the broader AircIdentityId newtype + clippy-deny ratchet remain the #396 tail. // what this catches: resolve_persona_takes_uuid_short_id_or_name_and_fails_loud Co-Authored-By: Claude Opus 4.8 <[email protected]> Claude-Session: https://claude.ai/code/session_01LoTjvf5j3Ez13g6k8mRkFo
…ll-uuid | short-id | name, fail loud on a dead ref (#396) benchmark/run and cognition/eval took persona_id as a loose String and did a bare Uuid::parse_str: a valid-but-DEAD full UUID parsed fine, then died ~10s later at the fork wait with a MISLEADING "its mind was not assembled at spawn (register_from_cfg)" — which I misread all night as a build regression (#397). The loose-String identity boundary IS the defect class (Joel: "always uuid... typed AircIdentityId... so you can't screw it up"). Fix — ONE formal resolution boundary on the workspace registry (the authority on who is forkable), composing the shared id_resolve primitive: - PersonaWorkspaceRegistry::resolve_persona(full-uuid | 8-char short-id | persona NAME) → typed Uuid. A well-formed full UUID passes THROUGH without a liveness check, so a persona whose template is still assembling (the post-reboot register_from_cfg race the fork wait absorbs) is never false-rejected — race safety stays in the wait, not here. Short-id + name resolve against the forkable set; garbage fails LOUD naming the online roster ("Online now: Asha (90e758b2), Atlas (e5f4141d)"). - template_ids() accessor for the forkable candidate set. - eval.rs routes persona_id through resolve_persona (benchmark/run + agent/solve inherit it — one seam, all callers), and the 4 post-wait "no workspace template" messages now say "persona X is not online — call persona/instances/list" instead of the internal register_from_cfg note that read as a regression. This same seam serves BigMama's Hermes/openclaw + ACP peers — she hit the identical parse-accepts-then-dies-later shape (AcpAgent::from_str parses a nonexistent program, spawn fails later as "program not found"). Name resolution (Asha->id) here is UUID+short-id+name; the broader AircIdentityId newtype + clippy-deny ratchet remain the #396 tail. // what this catches: resolve_persona_takes_uuid_short_id_or_name_and_fails_loud Co-Authored-By: Claude Opus 4.8 <[email protected]> Claude-Session: https://claude.ai/code/session_01LoTjvf5j3Ez13g6k8mRkFo
Summary
Third and final session continuity tool. The trilogy:
claude/contextclaude/snapshotclaude/resume./jtag claude/resumeoutput:No more cold starts. No more guessing.
Test plan
npm run build:ts— compiles cleannpm start— deploys, command registered./jtag claude/resume— reads latest.json, shows briefing with git diff--verboseincludes chat and issues