Skip to content

Discovery adapter: Claude Code (JSONL) #18

@leefaus

Description

@leefaus

Part of #11

Summary

Implement TraceDiscovery for Claude Code. Reads trace history from ~/.claude/ JSONL files.

Storage Details

Aspect Detail
Storage path ~/.claude (overridable via env var)
Detection .claude, .claude/settings.json
History file ~/.claude/history.jsonl
Project sessions ~/.claude/projects/<project_hash>/<session_id>.jsonl
Format JSONL — one JSON object per line

Event Parsing

  • Roles: user, assistant
  • Tool events: blocks with type: "tool_use", type: "tool_result", linked via tool_use_id
  • Thinking: extended thinking blocks

Notes

Claude Code already has a real-time AgentHook in hooks/claude_code.rs. This discovery adapter enables:

  1. Backfilling traces from before Atomic was installed
  2. Post-record hook matching (find which trace was active during a recording)

Acceptance Criteria

  • list_traces() enumerates sessions from ~/.claude/projects/
  • read_events() parses JSONL into DiscoveredEvents with correct types
  • Tool calls include tool_name, tool_call_id, and are classifiable
  • Unit tests with JSONL fixture files

Estimated Effort

0.5-1 day

Metadata

Metadata

Assignees

No one assigned

    Labels

    agent-discoveryAgent trace discovery and import into provenance graphenhancementNew feature or request

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions