@broskees/opencode-codebase-graph
v0.2.0
Published
OpenCode plugin that injects a live codebase structural map into the system prompt
Maintainers
Readme
@broskees/opencode-codebase-graph
OpenCode plugin that injects a live codebase structural map into every LLM system prompt.
How It Works
- On plugin load, spawns
codebase-graph --watchas a child process to keep.codebase.mdup to date - On every LLM call, reads
.codebase.mdfrom disk and pushes it onto the system prompt - The agent always has a current structural map of the codebase — modules, symbols, hierarchies, dependencies
Installation
1. Install the CLI tool
pip install codebase-graph2. Add the plugin to OpenCode
In your opencode.json:
{
"$schema": "https://opencode.ai/config.json",
"plugin": ["@broskees/opencode-codebase-graph"]
}That's it. The plugin auto-starts the watcher and injects the map on every LLM call.
Verifying It Works
- Start OpenCode in a project directory
- Check that
.codebase.mdappears in the project root (may take a moment on first run) - The structural map is automatically included in every LLM call — no action needed
Troubleshooting
.codebase.md not appearing
- Ensure
codebase-graphis in your PATH:which codebase-graph - Try running it manually:
codebase-graph --watch --dir . - Check that the project directory contains supported files (
.py,.ts,.tsx,.js,.jsx)
Plugin not loading
- Check OpenCode logs for plugin errors
- Ensure
@opencode-ai/pluginpeer dependency is satisfied
How It Integrates
codebase-graph --watch → writes .codebase.md on disk
↓
OpenCode plugin hook → reads .codebase.md on every LLM call
↓
System prompt → agent sees live structural mapThe plugin is ~25 lines of TypeScript. All the heavy lifting (parsing, watching, TOON serialization) happens in the codebase-graph binary.
