feat: add fragments support for custom agent instructions#4
Merged
Conversation
Port the fragments pattern from micode, allowing users to inject custom
instructions into agent prompts via config files.
Two-layer configuration:
- Global: ~/.config/opencode/octto.json with fragments: { "agent": ["..."] }
- Project: .octto/fragments.json with same structure
Global fragments load first, project fragments append. Fragments are
formatted as XML blocks prepended to agent system prompts.
Includes:
- FragmentsSchema validation in config
- Fragment-injector hook with Levenshtein distance typo detection
- Comprehensive test coverage
Closes #3
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
The config hook modification wasn't affecting brainstorming sessions because they use customConfig.agents directly. Now fragments are injected into customConfig.agents at plugin load time. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
There was a problem hiding this comment.
1 issue found across 9 files
Prompt for AI agents (all issues)
Check if these issues are valid — if so, understand the root cause of each and fix them.
<file name="src/index.ts">
<violation number="1" location="src/index.ts:21">
P2: Custom-configured agent prompts get fragment prefixes twice (once when mutating customConfig, again in config()), leading to duplicated instructions. Apply fragment injection in only one place or avoid mutating customConfig.</violation>
</file>
Reply with feedback, questions, or to request a fix. Tag @cubic-dev-ai to re-run a review.
Fragments are already injected into customConfig.agents at plugin load. The config hook was injecting them again after spreading customConfig.agents into config.agent, causing duplicate instructions. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
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.
Summary
~/.config/opencode/octto.json) + project (.octto/fragments.json)Test plan
bun test- all 150 tests passCloses #3
Summary by cubic
Adds “fragments” support to inject custom instructions into agent system prompts via config, merged globally and per-project and rendered as an XML block. Fulfills Linear #3 by enabling per-agent prompt customization with typo detection for agent names.
New Features
Bug Fixes
Written for commit 9758f1b. Summary will update on new commits.