C4Context
Person(user, "User", "Developer or team lead configuring contracts")
System(opencode, "opencode", "Agent runtime with plugin hooks")
System_Ext(anchorRepo, "LLM-Coding/Semantic-Anchors", "Anchor catalog + contract definitions")
System_Ext(agentContract, "agentcontract/spec", "Contract specification standard")
System_Ext(kiros, "Kiros", "Has /steering files (reference concept)")
System_Boundary(plugin, "opencode-semantic-anchors") {
Component(hooks, "Hook Handlers", "tool.execute.before, chat.message, agent.activate")
Component(engine, "Rule Engine", "Evaluates contracts → verdict")
Component(config, "Config Loader", "Reads YAML contract definitions")
Component(tools, "Custom Tools", "/anchor bypass, status, config-reload")
}
Rel(user, opencode, "Uses")
Rel(opencode, plugin, "Loads")
Rel(plugin, anchorRepo, "References terms from", "design-time")
Rel(plugin, agentContract, "Aligns schema with", "design-time")
Rel(kiros, plugin, "Inspiration for", "steering mechanism")
3. System Scope and Context
System Boundary
Inside Scope (Plugin)
The opencode-semantic-anchors plugin covers:
-
Contract enforcement via hooks: Intercepts
tool.execute.before,chat.message,agent.activate -
Rule Engine: Evaluates incoming events against active Structural Coupling Contracts
-
Override mechanism:
/anchor bypass,/anchor status,/anchor config-reload -
Config loading: Reads
opencode-semantic-anchors.yamlwith contract definitions -
Session state: Tracks tool-call counts, override counts, active role
-
Standalone steering rules: Contracts without
anchorRefs— generic rules (e.g., "BLUF", "MECE", language constraints) work identically to Anchor-based contracts
Outside Scope (Plugin does NOT do)
| Not in scope | Handled by |
|---|---|
Anchor recognition evaluation |
LLM-Coding/Semantic-Anchors evaluation framework (Issue #329) |
Contract authoring / template rendering |
LLM-Coding/Semantic-Anchors |
Anchor catalog browsing |
LLM-Coding/Semantic-Anchors website |
CI/CD verdict gating |
|
Multi-agent contract sync |
Semantic-Anchors onboarding skill (Issue #521) |
Take before Buy before Make: The plugin intentionally avoids duplicating these existing solutions. It focuses on the opencode-specific gap — runtime enforcement via plugin hooks — which no existing project covers. Where possible, it aligns terminology with
agentcontract/spec(e.g., YAML-based contracts, BLOCK/WARN modes).
Business Context
Technical Context
Interfaces
| Interface | Direction | Data | Protocol |
|---|---|---|---|
|
opencode → plugin |
|
opencode Plugin SDK |
|
opencode → plugin |
|
opencode Plugin SDK |
|
opencode → plugin |
|
opencode Plugin SDK |
Config file |
filesystem → plugin |
|
YAML file read |
Custom tools |
user → plugin |
|
opencode custom tool API |
Existing Solutions (Take before Buy before Make)
Checked before writing own code:
| Solution | What it does | Why not sufficient alone |
|---|---|---|
|
Full contract spec with pre/post conditions, CI gating |
No opencode plugin hook implementation; designed for CI gates, not runtime agent steering |
|
AGENTS_CONTRACT.md with agent roles |
Prompt-based only, not hook-enforced; no opencode plugin |
Kiros |
Runtime steering files |
Proprietary to Kiros; opencode has no equivalent |
Semantic-Anchors onboarding skill |
Installs anchor blocks into AGENTS.md |
Prompt-only, no enforcement; Claude Code plugin, not opencode |
SpecAnchor |
Three-tier spec system with drift detection |
Not hook-based; no opencode integration |
Decision: The opencode plugin fills a genuine gap — runtime enforcement inside opencode’s plugin system. None of the existing solutions provide this. Alignment with agentcontract/spec terminology is desirable to avoid ecosystem fragmentation.
Position in the Semantic-Anchors Ecosystem
The LLM-Coding/Semantic-Anchors repository already provides integrations for several coding agents:
| Agent | Integration | Type |
|---|---|---|
Claude Code |
|
Plugin + AGENTS.md |
Codex |
AGENTS.md |
Project Context |
Gemini CLI |
GEMINI.md |
Native Context |
Cursor |
|
Path-scoped Rules |
GitHub Copilot |
|
Repo Instructions |
Windsurf |
AGENTS.md + Windsurf Rules |
Project Context |
opencode |
|
Runtime Enforcement via Hooks |
This plugin is the opencode-specific contribution to the Semantic-Anchors ecosystem. It will be contributed as plugins/opencode-semantic-anchors/ into the repository and made available to the opencode community — analogous to the existing Claude Code plugin at plugins/semantic-anchors/.
Take before Buy before Make (applied): Instead of building another "Anchor-Block into AGENTS.md" tool (which already exists in the Onboarding Skill), this plugin focuses on the gap that no existing integration covers: Runtime Enforcement via Plugin Hooks.
Feedback
Was this page helpful?
Glad to hear it! Please tell us how we can improve.
Sorry to hear that. Please tell us how we can improve.