Add a true OpenCode semantic extraction backend in graphify/llm.py
Summary
Graphify currently supports OpenCode as a platform install and assistant-skill orchestration path, but not as a true direct semantic backend in graphify/llm.py.
Today:
graphify/llm.pysupportsclaudeandkimigraphify/skill-opencode.mduses OpenCode agent orchestrationgraphify updateremains AST-only- OpenCode install writes
AGENTS.mdplus a bash-only plugin reminder
This leaves a gap for OpenCode users who want a first-class direct semantic backend, similar to the current direct backend layer, without depending on Claude-specific auth or the assistant-skill path.
Motivation
- OpenCode is already a documented first-class platform in Graphify.
- The current architecture has an asymmetry: OpenCode exists as orchestration/install support, but not as a direct backend entry in
graphify/llm.py. - The current code/comments/docs can be confusing because backend capability, assistant orchestration, and AST-only update behavior are described in different places.
Proposed Solution
Add backend="opencode" to graphify/llm.py as a direct semantic extraction backend.
MVP scope:
- Implement the backend via
opencode run --format json - Reuse the existing
_EXTRACTION_SYSTEMand_read_files(...)prompt-building flow - Parse OpenCode JSON event streams and extract the final assistant
textpayload - Pass that payload through the existing
_parse_llm_json(...)normalization path - Keep
extract_corpus_parallel(...)behavior unchanged apart from supporting the new backend
Acceptance Criteria
- [ ]
graphify.llm.extract_files_direct(..., backend="opencode")returns valid Graphify extraction fragments - [ ]
graphify.llm.extract_corpus_parallel(..., backend="opencode")works with existing chunk merge behavior and callbacks - [ ] Subprocess failure, missing CLI, missing text payload, and malformed JSON outputs fail with deterministic errors
- [ ] README and OpenCode skill docs clearly distinguish direct backend support from assistant orchestration and from AST-only
graphify update - [ ] Tests cover success and failure cases for the new backend transport
Non-Goals
- Do not implement
opencode servein the first PR - Do not redesign
graphify updateinto a full semantic-update CLI - Do not rely on
--file/--attachin the MVP transport - Do not remove the existing
skill-opencode.mdorchestration path
Alternatives Considered
opencode serve/ SDK transport first: more moving parts, larger scope- Keep OpenCode as skill-only orchestration: preserves the current backend gap
- Attachment-based transport: local validation suggests inline prompt text is the safer first step
Notes
During local validation, opencode run --format json --pure --dangerously-skip-permissions already produced a machine-readable JSON event stream with a final text event, which makes it a plausible MVP transport.
Also worth noting: graphify/llm.py comments currently imply a public direct-backend usage path, but the visible CLI path in __main__.py does not currently expose a general --backend switch. If maintainers agree, this issue can stay scoped to the backend-layer MVP and leave CLI exposure/docs cleanup as follow-up or adjacent work.
Closing this because I am no longer pursuing the OpenCode semantic backend work.