feat(opencode): agent-driven context editing with CAS, edit graph, and focus agent#1
Merged
feat(opencode): agent-driven context editing with CAS, edit graph, and focus agent#1
Conversation
A fork of anomalyco/opencode that adds surgical, reversible context editing with content-addressable storage and a conversation history graph. New capabilities: - CAS (SQLite): content-addressable store preserving original content - Edit operations: hide, unhide, replace, annotate, externalize - Edit graph: DAG of edit versions with branching and checkout - Focus agent: hidden post-turn agent that parks off-topic side threads - Side threads: project-level deferred findings (SQLite) - Objective tracker: extracts and tracks the user's goal - Tools: context_edit, context_deref, context_history, thread_park, thread_list - Plugin hooks: context.edit.before / context.edit.after - CI: stripped to test + typecheck on ubuntu-latest (no third-party runners) 13 new files, 8 modified files, ~1365 lines of new code. All 1310 existing tests pass.
- Use SessionID.make(), MessageID.make(), PartID.ascending() instead of plain strings for branded type safety - Add context.edit.before/after hooks to plugin Hooks interface - Wire Plugin.trigger() calls in context-edit operations
e6qu
added a commit
that referenced
this pull request
Mar 18, 2026
…d focus agent (#1) * feat: Frankencode — agent-driven context editing on top of OpenCode A fork of anomalyco/opencode that adds surgical, reversible context editing with content-addressable storage and a conversation history graph. New capabilities: - CAS (SQLite): content-addressable store preserving original content - Edit operations: hide, unhide, replace, annotate, externalize - Edit graph: DAG of edit versions with branching and checkout - Focus agent: hidden post-turn agent that parks off-topic side threads - Side threads: project-level deferred findings (SQLite) - Objective tracker: extracts and tracks the user's goal - Tools: context_edit, context_deref, context_history, thread_park, thread_list - Plugin hooks: context.edit.before / context.edit.after - CI: stripped to test + typecheck on ubuntu-latest (no third-party runners) 13 new files, 8 modified files, ~1365 lines of new code. All 1310 existing tests pass. * fix: type safety for branded IDs and plugin hooks - Use SessionID.make(), MessageID.make(), PartID.ascending() instead of plain strings for branded type safety - Add context.edit.before/after hooks to plugin Hooks interface - Wire Plugin.trigger() calls in context-edit operations * ci: add pre-commit hooks for typecheck, tests, and conventional commits --------- Co-authored-by: Adrian Mârza <adi11235 at gmail dot com>
3 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Issue for this PR
N/A — founding feature for the Frankencode fork.
Type of change
What does this PR do?
Adds agent-driven context editing to OpenCode. Agents can surgically edit their own conversation context — hiding stale tool output, replacing incorrect statements, externalizing verbose content to a content-addressable store — while preserving all original content in a git-like versioned DAG. A focus agent runs post-turn to keep conversations on-topic by parking side discoveries.
Components:
cas_objecttable stores original content by SHA-256 hash. Atomic with part updates viaDatabase.transaction().hide,unhide,replace,annotate,externalizewith ownership validation, budget enforcement (max 10/turn, 70% cap), recency protection (last 2 turns immutable).edit_graph_node+edit_graph_headtables model edit history as a DAG with parent pointers, named branches, checkout, fork.OPENCODE_EXPERIMENTAL_FOCUS_AGENT=1.side_threadtable for deferred discoveries that survive across sessions.context.edit.before/context.edit.after.New tools:
context_edit,context_deref,context_history,thread_park,thread_listNew files: 13 new files, 8 modified, ~1365 LOC. All paths under
packages/opencode/src/.How did you verify your code works?
bun test)bun turbo typecheck— all 13 packages)Screenshots / recordings
N/A — backend/tooling change, no UI modifications.
Checklist