Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions src/core/parser-claude.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -483,4 +483,19 @@ describe('parseClaudeSessions', () => {
expect(session.requests[0].skillsUsed).toHaveLength(1);
});
});

it('stores the Claude session cwd as workspaceRootPath', () => {
// The cwd recorded on user records is the project root. Surfacing it as
// workspaceRootPath lets config-health / SDLC workspace scans resolve the
// repo for Claude sessions, the same way the Codex parser already does.
const cwd = fs.mkdtempSync(path.join(os.tmpdir(), 'claude-cwd-test-'));
withProjectsDir('s.jsonl', [
makeUser('hello', '2025-06-15T10:00:00Z', { cwd }),
makeAssistant('hi there'),
], (projectsDir) => {
const session = parseClaudeSessions(projectsDir)[0].sessions[0];
expect(session.workspaceRootPath).toBe(cwd);
});
fs.rmSync(cwd, { recursive: true, force: true });
});
});
1 change: 1 addition & 0 deletions src/core/parser-claude.ts
Original file line number Diff line number Diff line change
Expand Up @@ -675,6 +675,7 @@ function parseClaudeSessionFile(filePath: string, wsId: string, wsName: string):
lastMessageDate: lastTs,
requests,
hasDevcontainer: detectDevcontainerFromRequests(requests, cwd),
workspaceRootPath: cwd || undefined,
launcherKind,
entrypoint,
});
Expand Down
25 changes: 25 additions & 0 deletions src/core/parser-opencode.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -91,4 +91,29 @@ describe('parseOpenCodeSessions', () => {
},
);
});

it('stores the OpenCode session directory as workspaceRootPath', () => {
// rawSession.directory is the project root. Surfacing it as
// workspaceRootPath lets config-health / SDLC workspace scans resolve the
// repo for OpenCode sessions, the same way the Codex parser already does.
const dir = fs.mkdtempSync(path.join(os.tmpdir(), 'opencode-dir-test-'));
withStorage(
{ id: 'sess-dir', directory: dir, time: { created: 1700000000000 } },
[
{ id: 'u1', sessionID: 'sess-dir', role: 'user', time: { created: 1700000000000 }, summary: { title: 'hi' } },
{
id: 'a1', sessionID: 'sess-dir', role: 'assistant', parentID: 'u1',
time: { created: 1700000001000, completed: 1700000002000 },
modelID: 'claude-sonnet-4',
tokens: { input: 100, output: 20 },
},
],
(storageDir) => {
const sessions = parseOpenCodeSessions(storageDir);
expect(sessions).toHaveLength(1);
expect(sessions[0].workspaceRootPath).toBe(dir);
},
);
fs.rmSync(dir, { recursive: true, force: true });
});
});
1 change: 1 addition & 0 deletions src/core/parser-opencode.ts
Original file line number Diff line number Diff line change
Expand Up @@ -300,6 +300,7 @@ function parseOpenCodeSession(rawSession: OcSession, storageDir: string): Sessio
lastMessageDate: lastTs || (rawSession.time?.updated || null),
requests,
hasDevcontainer: detectDevcontainerFromRequests(requests, rawSession.directory),
workspaceRootPath: rawSession.directory || undefined,
});
}

Expand Down
Loading