Skip to content

refactor(adapter): shared helpers + tool-call pairing contract [2/3] - #26

Open
LarsArtmann wants to merge 2 commits into
cosmtrek:masterfrom
LarsArtmann:adapter-shared-contract
Open

LarsArtmann wants to merge 2 commits into
cosmtrek:masterfrom
LarsArtmann:adapter-shared-contract

Conversation

@LarsArtmann

@LarsArtmann LarsArtmann commented Sep 9, 2026 •

Copy link
Copy Markdown

Why

The three JSONL adapters (claudecode, codex, pi) each re-implement the same ceremony: resolving ~/.harness directories, opening session files with a deferred close, probing readable directories, and formatting not-a-session errors. Meanwhile the shared adapter.go had grown into a monolith. And result pairing is positional today — when a harness splits a tool_call and its tool_result across messages, index alignment silently drops the outcome.

What changed

  • Behavior-preserving helpers, migrated at every call site: HomePath, UserHomeDir, ReadableDir, OpenFile, NormalizePath, NotRecognizedErr.
  • adapter.go split into topic files (home.go, input.go, title.go, agent_launch.go).
  • Contract additions (consumed by part 3/3): ToolResult.ToolCallID for explicit by-ID pairing, ToolCall.ProviderExecuted, Closer (adapters holding connection pools), DiagnosticsSource + FilesystemDiagnostics (health checks).
  • go.mod: go 1.26.5 directive (tests use new(expr)) and go-humanize (PluralWord in agent-launch summaries).

No production behavior changes — the full suite passes unchanged.

Series

Part 2/3, stacks on #25:

  • 3/3 crush-adapter-core — the adapter that exercises ToolCallID, Closer, and DiagnosticsSource

Validation

  • go build ./...
  • go test -count=1 ./... — green at the branch tip
  • Diff vs parent is helper extraction + additive types only (verified per-file)

💘 Generated with Crush


Reviewing this stacked series

GitHub shows the cumulative diff against master, so "Files changed" also includes part 1 (#25). This PR's own delta is just the second commit, refactor(adapter): shared helpers + tool-call pairing contract — reviewing that single commit gives the actual scope of this change.

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.

1 participant