Skip to content

Commit 27dffdb

Browse files
christsoclaude
andauthored
fix: add --session-id to codex, remove --discover latest from all import commands (#953)
- Add --session-id <uuid> to agentv import codex for parity with claude and copilot - Remove --discover latest from all three import commands (redundant with --list + --session-id) - Update docs and examples Closes #952 Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent decc906 commit 27dffdb

9 files changed

Lines changed: 93 additions & 89 deletions

File tree

apps/cli/src/commands/import/claude.ts

Lines changed: 4 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,6 @@ export const importClaudeCommand = command({
1717
long: 'session-id',
1818
description: 'UUID of the Claude Code session to import',
1919
}),
20-
discover: option({
21-
type: optional(string),
22-
long: 'discover',
23-
description: 'Discovery mode: "latest" to import the most recent session',
24-
}),
2520
projectPath: option({
2621
type: optional(string),
2722
long: 'project-path',
@@ -44,7 +39,7 @@ export const importClaudeCommand = command({
4439
description: 'List available sessions instead of importing',
4540
}),
4641
},
47-
handler: async ({ sessionId, discover, projectPath, output, projectsDir, list }) => {
42+
handler: async ({ sessionId, projectPath, output, projectsDir, list }) => {
4843
if (list) {
4944
const sessions = await discoverClaudeSessions({
5045
projectPath,
@@ -81,22 +76,10 @@ export const importClaudeCommand = command({
8176
process.exit(1);
8277
}
8378
sessionFilePath = sessions[0].filePath;
84-
} else if (discover === 'latest') {
85-
const sessions = await discoverClaudeSessions({
86-
projectPath,
87-
projectsDir,
88-
latest: true,
89-
});
90-
91-
if (sessions.length === 0) {
92-
console.error('Error: no Claude Code sessions found.');
93-
process.exit(1);
94-
}
95-
sessionFilePath = sessions[0].filePath;
96-
sessionId = sessions[0].sessionId;
97-
console.log(`Discovered latest session: ${sessionId}`);
9879
} else {
99-
console.error('Error: specify --session-id <uuid> or --discover latest to select a session.');
80+
console.error(
81+
'Error: specify --session-id <uuid> to select a session. Use --list to see available sessions.',
82+
);
10083
process.exit(1);
10184
}
10285

apps/cli/src/commands/import/codex.ts

Lines changed: 21 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,10 @@ export const importCodexCommand = command({
1212
name: 'codex',
1313
description: 'Import a Codex CLI session transcript for offline grading',
1414
args: {
15-
discover: option({
15+
sessionId: option({
1616
type: optional(string),
17-
long: 'discover',
18-
description: 'Discovery mode: "latest" to import the most recent session',
17+
long: 'session-id',
18+
description: 'UUID of the Codex CLI session to import',
1919
}),
2020
date: option({
2121
type: optional(string),
@@ -38,7 +38,7 @@ export const importCodexCommand = command({
3838
description: 'List available sessions instead of importing',
3939
}),
4040
},
41-
handler: async ({ discover, date, output, sessionsDir, list }) => {
41+
handler: async ({ sessionId, date, output, sessionsDir, list }) => {
4242
if (list) {
4343
const sessions = await discoverCodexSessions({
4444
date,
@@ -59,25 +59,27 @@ export const importCodexCommand = command({
5959
return;
6060
}
6161

62-
if (discover !== 'latest') {
63-
console.error('Error: specify --discover latest to select a session.');
64-
process.exit(1);
65-
}
66-
67-
const sessions = await discoverCodexSessions({
68-
date,
69-
sessionsDir,
70-
latest: true,
71-
});
62+
let session: Awaited<ReturnType<typeof discoverCodexSessions>>[number];
7263

73-
if (sessions.length === 0) {
74-
console.error('Error: no Codex CLI sessions found.');
64+
if (sessionId) {
65+
const sessions = await discoverCodexSessions({
66+
date,
67+
sessionsDir,
68+
limit: 100,
69+
});
70+
const match = sessions.find((s) => s.sessionId === sessionId);
71+
if (!match) {
72+
console.error(`Error: session ${sessionId} not found.`);
73+
process.exit(1);
74+
}
75+
session = match;
76+
} else {
77+
console.error(
78+
'Error: specify --session-id <uuid> to select a session. Use --list to see available sessions.',
79+
);
7580
process.exit(1);
7681
}
7782

78-
const session = sessions[0];
79-
console.log(`Discovered latest session: ${session.filename}`);
80-
8183
// Parse the session
8284
const rawJsonl = await readTranscriptFile(session.filePath);
8385
const transcript = parseCodexSession(rawJsonl);

apps/cli/src/commands/import/copilot.ts

Lines changed: 4 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,6 @@ export const importCopilotCommand = command({
1212
long: 'session-id',
1313
description: 'UUID of the Copilot CLI session to import',
1414
}),
15-
discover: option({
16-
type: optional(string),
17-
long: 'discover',
18-
description: 'Discovery mode: "latest" to import the most recent session',
19-
}),
2015
output: option({
2116
type: optional(string),
2217
long: 'output',
@@ -34,7 +29,7 @@ export const importCopilotCommand = command({
3429
description: 'List available sessions instead of importing',
3530
}),
3631
},
37-
handler: async ({ sessionId, discover, output, sessionStateDir, list }) => {
32+
handler: async ({ sessionId, output, sessionStateDir, list }) => {
3833
if (list) {
3934
const sessions = await discoverCopilotSessions({
4035
sessionStateDir,
@@ -70,21 +65,10 @@ export const importCopilotCommand = command({
7065
}
7166
sessionDir = match.sessionDir;
7267
resolvedSessionId = sessionId;
73-
} else if (discover === 'latest') {
74-
const sessions = await discoverCopilotSessions({
75-
sessionStateDir,
76-
limit: 1,
77-
});
78-
79-
if (sessions.length === 0) {
80-
console.error('Error: no Copilot CLI sessions found.');
81-
process.exit(1);
82-
}
83-
sessionDir = sessions[0].sessionDir;
84-
resolvedSessionId = sessions[0].sessionId;
85-
console.log(`Discovered latest session: ${resolvedSessionId}`);
8668
} else {
87-
console.error('Error: specify --session-id <uuid> or --discover latest to select a session.');
69+
console.error(
70+
'Error: specify --session-id <uuid> to select a session. Use --list to see available sessions.',
71+
);
8872
process.exit(1);
8973
}
9074

apps/web/src/content/docs/docs/evaluation/running-evals.mdx

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -306,8 +306,9 @@ This is the same interface that agent-orchestrated evals use — the EVAL.yaml t
306306
Grade existing agent sessions without re-running them. Import a transcript, then run deterministic evaluators:
307307

308308
```bash
309-
# Import a Claude Code session
310-
agentv import claude --discover latest
309+
# List sessions and import one
310+
agentv import claude --list
311+
agentv import claude --session-id <uuid>
311312
312313
# Run evaluators against the imported transcript
313314
agentv eval evals/my-eval.yaml --transcript .agentv/transcripts/claude-<id>.jsonl

apps/web/src/content/docs/docs/guides/agent-skills-evals.mdx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,8 @@ Grade existing agent sessions offline using `agentv import` to convert transcrip
8585

8686
```bash
8787
# Import a Claude Code session transcript
88-
agentv import claude --discover latest
88+
agentv import claude --list
89+
agentv import claude --session-id <uuid>
8990

9091
# Run deterministic evaluators against the imported transcript
9192
agentv eval evals.json --target copilot-log

apps/web/src/content/docs/docs/guides/skill-improvement-workflow.mdx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,8 @@ Or grade existing sessions offline (no API keys required):
123123

124124
```bash
125125
# Import a Claude Code session transcript
126-
agentv import claude --discover latest
126+
agentv import claude --list
127+
agentv import claude --session-id <uuid>
127128

128129
# Run deterministic evaluators against the imported transcript
129130
agentv eval evals.json --target copilot-log

apps/web/src/content/docs/docs/tools/import.mdx

Lines changed: 56 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -12,14 +12,14 @@ The `import` command converts agent session transcripts into AgentV's `Message[]
1212
| Provider | Command | Source |
1313
|----------|---------|--------|
1414
| Claude Code | `agentv import claude` | `~/.claude/projects/<path>/<uuid>.jsonl` |
15-
16-
Codex and Copilot importers are planned for future releases.
15+
| Codex CLI | `agentv import codex` | `~/.codex/sessions/<YYYY>/<MM>/<DD>/rollout-*.jsonl` |
16+
| Copilot CLI | `agentv import copilot` | `~/.copilot/session-state/<uuid>/events.jsonl` |
1717

1818
## `import claude`
1919

2020
Import a Claude Code session transcript.
2121

22-
### Discover available sessions
22+
### List available sessions
2323

2424
```bash
2525
agentv import claude --list
@@ -35,12 +35,6 @@ Found 5 session(s):
3535
ed8b8c62-4414-49fb-8739-006d809c8588 3h ago -home-user-other-project
3636
```
3737

38-
### Import latest session
39-
40-
```bash
41-
agentv import claude --discover latest
42-
```
43-
4438
### Import a specific session
4539

4640
```bash
@@ -50,27 +44,68 @@ agentv import claude --session-id 4c4f9e4e-e6f1-490b-a1b1-9aef543ebf22
5044
### Filter by project path
5145

5246
```bash
53-
agentv import claude --discover latest --project-path /home/user/myproject
47+
agentv import claude --list --project-path /home/user/myproject
5448
```
5549

5650
### Custom output path
5751

5852
```bash
59-
agentv import claude --discover latest -o transcripts/my-session.jsonl
53+
agentv import claude --session-id <uuid> -o transcripts/my-session.jsonl
6054
```
6155

6256
Default output: `.agentv/transcripts/claude-<session-id-short>.jsonl`
6357

58+
## `import codex`
59+
60+
Import a Codex CLI session transcript.
61+
62+
### List available sessions
63+
64+
```bash
65+
agentv import codex --list
66+
```
67+
68+
### Import a specific session
69+
70+
```bash
71+
agentv import codex --session-id 019d5cff-9f02-7bc3-8f98-2071ba17ef0e
72+
```
73+
74+
## `import copilot`
75+
76+
Import a Copilot CLI session transcript.
77+
78+
### List available sessions
79+
80+
```bash
81+
agentv import copilot --list
82+
```
83+
84+
### Import a specific session
85+
86+
```bash
87+
agentv import copilot --session-id 9ca6d90c-1d80-40d1-b805-c59ee31fc007
88+
```
89+
6490
## Options
6591

92+
All three providers share the same core flags:
93+
6694
| Flag | Description |
6795
|------|-------------|
6896
| `--session-id <uuid>` | Import a specific session by UUID |
69-
| `--discover latest` | Import the most recent session |
70-
| `--project-path <path>` | Filter sessions by project path |
71-
| `--output, -o <path>` | Custom output file path |
72-
| `--projects-dir <dir>` | Override `~/.claude/projects` directory |
7397
| `--list` | List available sessions instead of importing |
98+
| `--output, -o <path>` | Custom output file path |
99+
100+
Provider-specific flags:
101+
102+
| Flag | Provider | Description |
103+
|------|----------|-------------|
104+
| `--project-path <path>` | Claude | Filter sessions by project path |
105+
| `--projects-dir <dir>` | Claude | Override `~/.claude/projects` directory |
106+
| `--date <YYYY-MM-DD>` | Codex | Filter sessions by date |
107+
| `--sessions-dir <dir>` | Codex | Override `~/.codex/sessions` directory |
108+
| `--session-state-dir <dir>` | Copilot | Override `~/.copilot/session-state` directory |
74109

75110
## Output Format
76111

@@ -101,10 +136,13 @@ Token usage is aggregated from the final cumulative value per LLM request. Durat
101136
Import a session, then run evaluators against it:
102137

103138
```bash
104-
# 1. Import the latest Claude Code session
105-
agentv import claude --discover latest
139+
# 1. List sessions and pick one
140+
agentv import claude --list
141+
142+
# 2. Import a session by ID
143+
agentv import claude --session-id 4c4f9e4e-e6f1-490b-a1b1-9aef543ebf22
106144

107-
# 2. Run evaluators against the imported transcript
145+
# 3. Run evaluators against the imported transcript
108146
agentv eval evals/my-eval.yaml --transcript .agentv/transcripts/claude-4c4f9e4e.jsonl
109147
```
110148

examples/features/import-claude/README.md

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -18,12 +18,6 @@ claude -p "List all TypeScript files in this project"
1818

1919
### 2. Import the session transcript
2020

21-
```bash
22-
agentv import claude --discover latest -o transcripts/session.jsonl
23-
```
24-
25-
Or import a specific session:
26-
2721
```bash
2822
# List available sessions
2923
agentv import claude --list

plugins/agentv-dev/skills/agentv-eval-writer/SKILL.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -539,7 +539,7 @@ agentv eval <file.yaml> --otel-file traces/eval.otlp.json
539539
agentv eval assert <grader-name> --agent-output "..." --agent-input "..."
540540
541541
# Import agent transcripts for offline grading
542-
agentv import claude --discover latest
542+
agentv import claude --session-id <uuid>
543543
544544
# Re-run only execution errors from a previous run
545545
agentv eval <file.yaml> --retry-errors .agentv/results/runs/<timestamp>/index.jsonl

0 commit comments

Comments
 (0)