Repository navigation
feat(import): add codex adapter for native rollout logs - #27
Merged
Merged
Conversation
Add `basou import codex`, the second import adapter, deriving Basou sessions from OpenAI Codex native rollout logs (~/.codex/sessions/<date>/rollout-*.jsonl). Each rollout becomes one imported session carrying session_started / session_ended and command_executed from exec_command calls (bash -c "<line>"), with the real exit_code and duration_ms parsed from the paired command output. Codex stores rollouts by date rather than per project, so discovery walks the tree and matches each rollout's recorded working directory against --project (default: the repository root); only sessions started in that project are imported. File changes and decisions are not derived: Codex applies edits inside exec_command and has no structured question / answer record, so neither has a clean signal to map. The claude-code and codex commands now share a vendor-neutral commit loop (importDerivedSessions): discovery builds the candidates, the shared core dedups, validates, force-replaces, and writes. Adds codex-import to the session source.kind enum. Verified on real data: 38 sessions / 1451 events imported from 45 basou-workspace rollouts (7 skipped as no-action), with exit codes and working-directory sanitization intact.
takashi-matsuyama
added a commit
that referenced
this pull request
Jun 1, 2026
…on (#28) Two refinements to the import adapters surfaced by an adversarial review of the codex adapter (#27): - Scope re-import dedup to the session source kind. loadExistingByExternalId now indexes only sessions whose source.kind matches the adapter being imported, so a Codex import can no longer dedup against (or, under --force, delete) a Claude-derived session that happens to share an id string. The id namespaces stay separate as more adapters are added. - `basou import codex --session <id>` now errors when no rollout in the project matches the id, instead of reporting a silent success. This mirrors the Claude path, which fails on a missing --session transcript. Adds tests for both: cross-kind isolation under --force, and the missing --session error.
6 tasks done
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Adds
basou import codex, the second import adapter, deriving Basou sessions from OpenAI Codex native rollout logs (~/.codex/sessions/<date>/rollout-*.jsonl). This is the multi-vendor follow-up tobasou import claude-code(#16) and makes the vendor-neutral provenance schema concrete across two tools.Event mapping
Each rollout becomes one imported session:
session_started/session_endedfrom the first / last timestamped record.command_executedfrom eachexec_commandfunction call, recorded asbash -c "<line>"(command + workdir from the call's JSONarguments), with the realexit_codeandduration_msparsed from the pairedfunction_call_output(Process exited with code N,Wall time: X seconds).File changes and decisions are deferred: Codex applies edits inside
exec_command(no dedicated edit tool) and records anapproval_policyrather than per-action approvals, so neither has a clean signal to map.Discovery
Codex stores rollouts by date, not per project, so discovery walks the sessions tree and matches each rollout's recorded
session_meta.cwdagainst--project(default: the repository root). Only sessions started in that project are imported; the exact-match is the safety boundary.--all,--session <id>,--force,--dry-run, and--jsonbehave as forimport claude-code.Refactor
The
claude-codeandcodexpaths now share a vendor-neutral commit loop,importDerivedSessions(paths, manifest, options, candidates). Each adapter builds a list of{ externalId, toPayload }candidates from its own discovery and funnels them through the shared core, which dedups, validates, force-replaces, and writes. Re-using the existingimportSessionFromJsonpipeline keeps path sanitization and id minting unchanged.Adds
codex-importto thesource.kindenum (additive) and documents it in the schema spec and CHANGELOG.Verification
pnpm -r build && pnpm typecheck && pnpm test && pnpm lintall green. Tests: core 665 (+8), cli 386 (+9).basou-workspacerollouts (7 skipped as no-action). Exit codes (1372 real / 3 null), working-directory sanitization (~/projects/...), andsession list/handoff generateall confirmed; no raw operator paths in tracked artifacts.🤖 Generated with Claude Code