Skip to content

Conversation

@mattzcarey
Copy link
Owner

@mattzcarey mattzcarey commented Jan 9, 2026

Summary

This PR adds the --session flag to zagi log for viewing AI conversation transcripts stored in git notes, along with session checkpoint support for efficient delta-based storage.

Features

Session Transcripts (--session flag)

  • View AI conversation transcripts with zagi log --session
  • Transcripts stored as collapsible GitHub-flavored markdown in refs/notes/session
  • Shows user prompts, assistant responses, and tool usage summaries

Delta-Based Storage (Checkpoints)

  • Only stores new session entries since the last commit (not the entire transcript)
  • Tracks checkpoint UUIDs in refs/notes/session-checkpoint
  • Reduces storage overhead from 10+ MB per commit to just the delta

Session Parsing

  • Claude Code: Parses JSONL files from ~/.claude/projects/
  • OpenCode: Parses session files from ~/.opencode/sessions/
  • Flexible JSON parsing handles varying content formats

Bug Fixes

  • Fix JSONL parsing for Claude session files (content can be string or array)
  • Fix session lookup in git worktrees
  • Add --dangerously-skip-permissions to Claude executor for headless mode
  • Add optional [prompt] argument to git agent run for operator guidance

Documentation

  • docs/plan-session-checkpoints.md - Design document
  • docs/ralph.md - RALPH agent loop documentation

Key Changes

File Changes
src/cmds/detect.zig Session parsing, markdown formatting, checkpoint filtering
src/cmds/commit.zig Checkpoint reading/writing, session storage
src/cmds/log.zig --session flag display
src/cmds/agent.zig Executor flags, optional prompt support

Usage

# View session transcripts for recent commits
zagi log --session

# View raw session note for a specific commit
git notes --ref=session show <commit>

# Run agent with guidance
git agent run "focus on error handling"

Test Plan

  • All 261 integration tests pass
  • All Zig unit tests pass (including new tests for JSONL parsing, markdown formatting)
  • Session notes created on commits with --prompt
  • Checkpoint filtering verified (only new entries stored)
  • zagi log --session displays transcripts correctly
  • Claude executor uses --dangerously-skip-permissions -p
  • OpenCode executor uses run subcommand

🤖 Generated with Claude Code

- Use std.json.Value for flexible content parsing (content can be string or array)
- Increase file read limit from 10MB to 500MB for large session files
- Remove unused struct types (JsonMessage, JsonContent, JsonContentBlock, JsonEntry)

The previous approach using typed structs with union(enum) for content
didn't work because Zig's JSON parser cannot automatically determine
which union variant to use from raw JSON. Using std.json.Value allows
manual type checking and proper handling of both string and array content.
- Add revision range support (e.g., origin/main..HEAD)
- Add --session flag to show session summary table
- Show prompts per commit in markdown table format
- Useful for generating PR descriptions with AI context
Tests for parseJsonlEntry, formatTimestamp, and formatSessionMarkdown
functions used in session checkpoint tracking.
Implement readOpenCodeEntriesAfter function to parse OpenCode session
data with checkpoint support, similar to the existing Claude
implementation.

OpenCode stores session data in:
- ~/.local/share/opencode/storage/session/{project_id}/{session_id}.json
- ~/.local/share/opencode/storage/message/{session_id}/msg_*.json
- ~/.local/share/opencode/storage/part/{message_id}/prt_*.json

Key changes:
- Add readOpenCodeEntriesAfter to parse OpenCode sessions
- Add findOpenCodeSession to locate sessions by working directory
- Add parseOpenCodeMessage to parse message files and their parts
- Add formatEpochMs to convert OpenCode epoch timestamps to ISO format
- Add tests for all new OpenCode parsing functions
Add tests for parseOpenCodeMessage edge cases:
- String timestamp fallback behavior
- Empty time object handling
- Extra/unknown fields gracefully ignored

Add tests for convertJsonlToArray:
- Single line conversion
- Multiple lines conversion
- Empty input handling
- Blank lines filtering
- Trailing newline handling
- Nested JSON structure preservation
…ompt

- Claude headless mode now uses --dangerously-skip-permissions -p
- Add optional [prompt] argument to git agent run for operator guidance
- Create docs/ralph.md documenting the RALPH agent spawning process
- Update integration tests to expect new Claude flags
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.

2 participants