Skip to content

Conversation

@harshav167
Copy link

Summary

Add support for OpenCode AI coding assistant, enabling discovery and parsing of OpenCode logs stored in XDG-compliant paths.

Changes

1. AiTool Enum (src/models.rs)

  • Added OpenCode variant
  • Added path detection for /opencode/ patterns (XDG paths)

2. Discovery Patterns (src/discovery.rs)

  • Added 4 search patterns:
    • ~/.local/share/opencode/ (data)
    • ~/.config/opencode/ (config)
    • ~/.local/state/opencode/ (state)
    • ~/.cache/opencode/ (cache)
  • Added 9 subdirectory mappings:
    • storage/ → Session
    • log/ → Debug
    • snapshot/ → FileHistory
    • tool-output/ → Debug
    • prompt-history.jsonl → History
    • kv.json, model.json, frecency.jsonl → Cache

3. OpenCode Parser (src/parsers/opencode.rs)

  • New 350-line parser for OpenCode's storage structure
  • Parses session/message/part JSON files
  • Parses prompt-history.jsonl (JSONL format)
  • Handles timestamp formats (RFC3339, Unix millis)
  • Includes analyze_opencode_logs() for statistics

4. Formatting (style commit)

  • Applied cargo fmt across codebase for consistent style

OpenCode Storage Structure Parsed

~/.local/share/opencode/
├── storage/
│   ├── session/{projectID}/{sessionID}.json
│   ├── message/{sessionID}/{messageID}.json
│   ├── part/{messageID}/{partID}.json
│   ├── project/{projectID}.json
│   └── todo/*.json
├── log/
├── snapshot/
└── tool-output/

~/.local/state/opencode/
├── prompt-history.jsonl
├── kv.json
├── model.json
└── frecency.jsonl

Testing

$ ./target/release/claudev discover
...
│ OpenCode    ┆ Session       ┆ ~/.local/share/opencode/storage   ┆ 10.61 GB  ┆ 316K  │
│ OpenCode    ┆ FileHistory   ┆ ~/.local/share/opencode/snapshot  ┆ 7.13 GB   ┆ 190K  │
│ OpenCode    ┆ Debug         ┆ ~/.local/share/opencode/log       ┆ 10.81 MB  ┆ 11    │
│ OpenCode    ┆ History       ┆ ~/.local/state/opencode/prompt-history.jsonl │ 20.72 KB │
...
🔧 Tools Detected:
  • Claude Code
  • Cursor
  • OpenCode

Build passes with cargo build --release.

Add support for OpenCode AI coding assistant:
- Add OpenCode variant to AiTool enum with path detection
- Add XDG-compliant search patterns (~/.local/share/opencode, ~/.config/opencode, etc.)
- Add subdirectory patterns for storage, log, snapshot, tool-output, prompt-history.jsonl
- Create dedicated OpenCode parser for session/message/part JSON files

OpenCode storage structure parsed:
- storage/session/{projectID}/{sessionID}.json - Session metadata
- storage/message/{sessionID}/{messageID}.json - Messages
- storage/part/{messageID}/{partID}.json - Message parts
- prompt-history.jsonl - Prompt history (JSONL format)
Run cargo fmt to enforce consistent code style:
- Alphabetize imports
- Wrap long lines (100 char limit)
- Format array elements
- Format method chains
@devloai
Copy link

devloai bot commented Jan 12, 2026

Unable to trigger custom agent "Code Reviewer"You have run out of credits 😔
Please upgrade your plan or buy additional credits from the subscription page.

Copy link

@sourcery-ai sourcery-ai bot left a comment

Choose a reason for hiding this comment

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

Sorry @harshav167, your pull request is larger than the review limit of 150000 diff characters

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