Skip to content

refactor(audit): extract agent adapter registry for Claude and Codex - #2

Merged
Neal006 merged 2 commits into
mainfrom
feat/npm-prep-publish
Nov 10, 2026
Merged

Neal006 merged 2 commits into
mainfrom
feat/npm-prep-publish

Conversation

@nandinirathod2321

@nandinirathod2321 nandinirathod2321 commented Nov 10, 2026 •

Copy link
Copy Markdown
Collaborator

Moves transcript discovery and parsing for each agent into a small adapter registry under src/audit/agents/, so new agents can be added one file at a time instead of through if (agent === "codex") branches in the audit command.

What changed

  • AgentAdapter interface and registry (src/audit/agents/index.ts) with getAdapter() and supportedAgents().
  • Adapters for Claude Code and Codex, wrapping the existing parsers and billing models.
  • deja audit resolves --agent through the registry; error messages and help text come from it.
  • discoverTranscripts accepts an optional extensions list (default .jsonl, unchanged).
  • An adapter with no default history folder now fails with "pass --dir" instead of scanning the current folder.

Behaviour

No change to audit results: deja audit --json output is byte-identical to main on real transcripts, in normal, --tune and --uncached modes. One small difference: --agent is now case-insensitive (--agent CODEX works).

Tests

New test/agents.test.ts (registry, metadata, error paths, --dir handling) and a custom-extensions case in test/discover.test.ts. Full suite and CI pass on all 9 jobs.

Next: one PR per new agent (Cline, Aider, Antigravity), each with a real anonymised fixture.


Generated by Claude Code

@Neal006 Neal006 left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for this, Nandini. The adapter registry is a good direction, and the new refactor-pipeline bench task is solid: it fails at the start and has a clear checker. The PR can't merge in its current form, though. Here is what we need.

Please split this PR

It bundles five unrelated changes into one commit. Please open separate PRs so each one can be reviewed and reverted on its own:

  1. Agent adapter registry plus the Claude and Codex adapters (pure refactor, no behaviour change)
  2. One PR per new agent (Antigravity, Cline, Aider), each once it meets the bar below
  3. The refactor-pipeline bench task (can merge almost as is)
  4. Release automation, if still wanted (see below)

Blockers

1. Existing test fails. test/wrap.e2e.test.ts > deja audit --agent codex fails on this branch and after merging with main: the report name changed from "Codex" to "Codex CLI". Please keep name: "Codex" for output compatibility, or update the test in the same commit with a reason. Please run the full suite (npm test), not only test/agents.test.ts.

2. Merge conflict. CONTRIBUTING.md conflicts with main, so CI never ran on this PR. Please rebase on main.

3. Aider adapter parses unrelated files. With extensions: [".md"] and a default directory of process.cwd(), discovery parses every Markdown file. Running deja audit --agent aider --dir . on this repo reports 23 "Aider sessions" built from the README and docs. Discovery has to match the file name .aider.chat.history.md exactly. Please also check the turn mapping against a real history file: as far as I know, Aider writes user prompts as #### lines and its own tool messages as > quotes, which is the reverse of what the parser assumes. Because Aider records no tool calls or results, please also show what deja can actually save on a real Aider history before we add it.

4. Antigravity pairs tool output with the wrong call. Only lastToolCallId gets a result, so when one PLANNER_RESPONSE makes several tool calls, every GENERIC output is attached to the last call and the earlier calls get none. This changes which output dedup and decay act on. There is also an unused appData variable in defaultDir.

5. Cline reads every .json file in a task folder (ui_messages.json, task metadata), not only api_conversation_history.json. Please match that file name. Cline records no timestamps, so idle and cache-expiry modelling can't work; please say so in the docs.

6. Validation claims need evidence. Antigravity and Cline are marked validated: true and "Production", but the tests use synthetic fixtures only. Our own rule in your CONTRIBUTING text says to add at least one real, anonymised fixture before claiming validation. Until then, please set validated: false and mark them Beta. The "-27.6% across 16 sessions" figure also needs a reproducible source, or it should be removed.

7. Please remove the npm publishing section from CONTRIBUTING.md. Package ownership is handled by the maintainer and is never changed through a PR, so the npm owner add ... instruction must go. Its "before the first publish" steps are also out of date, because 0.1.0 is already on npm.

Smaller items

  • readAny in worker.ts hardcodes claude, codex, aider in its error message. Please use supportedAgents().
  • --agent help text lists only three of the five agents.
  • .npmignore has no effect, because package.json files already limits the package to dist, README.md and LICENSE. Please drop it.
  • publish.yml: we may want tag-based publishing later, but not in this PR. If you'd like to propose it, please open an issue first.
  • docs/launch-announcements.md: launch posts don't belong in the repo. Please remove the file.
  • The CONTRIBUTING roadmap edit drops "Support the OpenAI Responses API in the proxy". Please keep that line.

Once the adapter-registry PR is green with no behaviour change, the per-agent PRs can follow one by one. Thanks again for the effort here; the structure is the right one.


Generated by Claude Code

@Neal006 Neal006 left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for reworking this, Nandini. Cutting it down to the registry refactor was the right call, and everything from the last review that still applies has been addressed: the report name is back to Codex, the branch is rebased with CI green on all 9 jobs, the npm publishing section and the extra files are gone, and the error message and help text now come from the registry.

I checked the branch locally:

  • typecheck, build and the full suite pass (650/650)
  • deja audit --json gives byte-identical output on main and on this branch for the same 8 real transcripts, in normal, --tune and --uncached modes, so this is a pure refactor as intended

Before merge

1. Update the PR title and description. They still describe the original PR: Antigravity, Cline, Aider, the publish workflow, .npmignore, the bench task and the "−27.6% across 16 sessions" figure. None of that is in the diff any more. main only allows squash merges, so the title can end up as the commit message. Please change the title to match the commit:

refactor(audit): extract agent adapter registry for Claude and Codex

and replace the description with a short summary of what is actually here (registry, two adapters, no behaviour change, 4 new tests).

Small fixes, in this PR or a follow-up

2. Don't fall back to the current directory. In src/cli/commands/audit.ts:

const root = flagString(args.flags, "dir") ?? adapter.defaultDir() ?? process.cwd();

If a future adapter returns undefined from defaultDir(), the audit silently scans whatever folder the user is in. That is how the earlier Aider adapter ended up reporting the README and docs as sessions. Both adapters return a directory today, so nothing is broken, but please make this an error instead ("this agent has no default history location, pass --dir") before the first new agent lands.

3. Help text alignment. --agent claude|codex audit: … in src/cli/help.ts breaks the column. Something like this keeps it aligned:

  --agent <name>     audit: whose history to replay: claude (default) or codex

4. extensions is unused. Neither adapter sets it. It's fine to keep since the next adapters need it, but then please add a test for discoverTranscripts with a custom extensions list so the new branch is covered.

5. Note the case-insensitive lookup. --agent CODEX is now accepted. That's a harmless behaviour change, but worth one line in the description since the PR says "no behaviour change".

Once item 1 is done this is good to merge. The per-agent PRs (Cline, Aider, Antigravity) can then follow one at a time, each with a real anonymised fixture as discussed.

@nandinirathod2321

nandinirathod2321 commented Nov 10, 2026 •

Copy link
Copy Markdown
Collaborator Author

@Neal006 I have made the required changes pls check

@Neal006 Neal006 changed the title feat: multi-agent compatibility, npm publish workflow, and launch rea… refactor(audit): extract agent adapter registry for Claude and Codex Nov 10, 2026

@Neal006 Neal006 left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks Nandini, this is exactly the scope we wanted: a clean registry with no behaviour change, good tests, and CI green everywhere. I updated the title and description to match the final diff. Looking forward to the per-agent PRs.


Generated by Claude Code

@Neal006
Neal006 merged commit 689d991 into main Nov 10, 2026
9 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants