Skip to content

feat: add fragments support for custom agent instructions#4

Merged
vtemian merged 4 commits intomainfrom
feature/fragments-support
Jan 28, 2026
Merged

feat: add fragments support for custom agent instructions#4
vtemian merged 4 commits intomainfrom
feature/fragments-support

Conversation

@vtemian
Copy link
Owner

@vtemian vtemian commented Jan 28, 2026

Summary

  • 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) + project (.octto/fragments.json)
  • Fragments are merged (global first, project appends) and formatted as XML blocks prepended to agent system prompts
  • Includes typo detection with Levenshtein distance suggestions for unknown agent names

Test plan

  • Run bun test - all 150 tests pass
  • Create test config with visible fragments (emojis)
  • Verify fragments appear in octto agent output
  • Verify fragments appear in probe agent questions
  • Test project-level fragments merge with global

Closes #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

    • Add fragments in global ~/.config/opencode/octto.json and project .octto/fragments.json.
    • Merge order: global first, project appends.
    • Render fragments as a block with bullet points, prepended to the agent prompt.
    • Warn on unknown agent names and suggest likely matches via Levenshtein distance.
  • Bug Fixes

    • Inject fragments at plugin load (agent source), ensuring brainstorming sessions also use the merged fragments.
    • Remove duplicate injection in the config hook to prevent repeated instructions.

Written for commit 9758f1b. Summary will update on new commits.

vtemian and others added 3 commits January 28, 2026 14:16
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>
Copy link

@cubic-dev-ai cubic-dev-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.

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>
@vtemian vtemian merged commit f0d31fd into main Jan 28, 2026
2 checks passed
@vtemian vtemian deleted the feature/fragments-support branch January 28, 2026 16:39
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.

Feature request: Parametrize agents to allow for extra workflow steps / override steps

1 participant