npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

opencode-semantic-anchors

v0.1.0

Published

Runtime steering plugin for opencode — enforces Semantic Anchors, contracts, and step confirmations via plugin hooks

Readme

opencode-semantic-anchors

Runtime steering plugin for opencode — enforces Semantic Anchors, contracts, and step confirmations via plugin hooks.

npm version License GitHub


🇬🇧 English

What is it?

opencode-semantic-anchors is a plugin for the opencode AI coding agent that enforces behavioral contracts at runtime. It implements the Semantic Anchors methodology — a set of rules that keep AI agents focused, traceable, and safe.

The plugin monitors:

  • Chat messages — checks every message against configured rules
  • Tool execution — validates tool calls before they run
  • Step confirmation — enforces step-by-step approval with configurable intervals

Features

  • 📋 Contract System — Define contracts that BLOCK or WARN on specific patterns
  • 🧩 Profile System — Built-in profiles (socratic, architecture) with role-based presets
  • 🔍 Source Anchor Enforcement — Require URL-verifiable sources for claims (with requireSource)
  • ⏭️ Override Mechanism — Emergency bypass with configurable maximum (default: 3 per session)
  • 🛑 Step Confirmation — Automatic pause every N steps (configurable interval)
  • 🔧 Three Built-in Toolsanchor-bypass, anchor-status, anchor-config-reload
  • 🔄 Dynamic Role Switching — Contracts re-resolve on setRole() via ContractResolver
  • 📦 Zod-Validated Config — Type-safe YAML configuration with full schema validation

Installation

npm install opencode-semantic-anchors

Then add it to your opencode.jsonc:

{
  "plugin": "opencode-semantic-anchors",
  "config": "path/to/opencode-semantic-anchors.yaml"
}

Quick Start

Create a config file opencode-semantic-anchors.yaml:

version: "1"
profiles:
  - socratic
contracts:
  - id: custom-rule
    mode: WARN
    description: "Agent must always cite its sources"
    triggers:
      - type: message
        pattern: "*"
        requireSource: true
    maxOverrides: 3

Built-in Profiles

| Profile | Description | Anchors | |---------|-------------|---------| | socratic | Basic source verification | Source Anchor, Intent Anchor, Verification Anchor | | architecture | Architecture decisions (⚠️ requires separate PR) | ADR format, Boundary Anchor, Stakeholder Anchor |

Profiles can be combined. Use roleProfiles to assign profiles per role:

roleProfiles:
  developer: ["socratic"]
  architect: ["socratic", "architecture"]

Contracts

A contract defines what the agent must (or must not) do:

| Field | Description | |-------|-------------| | id | Unique identifier | | mode | BLOCK (hard stop) or WARN (soft reminder) | | description | What the contract enforces | | triggers | Patterns that activate the contract | | maxOverrides | How many bypasses allowed per contract |

Tools

The plugin registers three tools in opencode:

| Tool | Description | |------|-------------| | anchor-bypass | Temporarily bypass a blocked contract | | anchor-status | Show active contracts, counters, and current role | | anchor-config-reload | Reload configuration without restart |

Step Confirmation

Every N tool calls (default: 3), the plugin pauses and asks for confirmation before proceeding. Set settings.stepConfirmationInterval to adjust.

Override Mechanism

When a contract blocks an action, the agent can request a one-time override via anchor-bypass. The override counter resets when contracts are reloaded. Maximum overrides per contract is configurable (default: 3).


🇩🇪 Deutsch

Was ist das?

opencode-semantic-anchors ist ein Plugin für den opencode KI-Coding-Agenten, das Verhaltensverträge (Contracts) zur Laufzeit durchsetzt. Es implementiert die Semantic Anchors Methodik — ein Regelwerk, das KI-Agenten fokussiert, nachvollziehbar und sicher hält.

Das Plugin überwacht:

  • Chat-Nachrichten — prüft jede Nachricht gegen konfigurierte Regeln
  • Tool-Ausführung — validiert Tool-Aufrufe bevor sie ausgeführt werden
  • Schritt-Bestätigung — erzwingt schrittweise Freigabe mit konfigurierbaren Intervallen

Funktionen

  • 📋 Vertragssystem — Definiere Contracts, die bestimmte Muster BLOCKieren oder WARNen
  • 🧩 Profilsystem — Vorgefertigte Profile (socratic, architecture) mit rollenbasierten Presets
  • 🔍 Source Anchor Enforcement — Erzwinge URL-überprüfbare Quellenangaben (mit requireSource)
  • ⏭️ Override-Mechanismus — Notfall-Bypass mit konfigurierbarem Maximum (Standard: 3 pro Session)
  • 🛑 Schritt-Bestätigung — Automatische Pause alle N Schritte (konfigurierbares Intervall)
  • 🔧 Drei Built-in-Toolsanchor-bypass, anchor-status, anchor-config-reload
  • 🔄 Dynamischer Rollenwechsel — Contracts werden bei setRole() via ContractResolver neu aufgelöst
  • 📦 Zod-validierte Config — Typsichere YAML-Konfiguration mit vollständiger Schema-Validierung

Installation

npm install opencode-semantic-anchors

Danach in der opencode.jsonc einbinden:

{
  "plugin": "opencode-semantic-anchors",
  "config": "path/to/opencode-semantic-anchors.yaml"
}

Schnellstart

Erstelle eine Konfigurationsdatei opencode-semantic-anchors.yaml:

version: "1"
profiles:
  - socratic
contracts:
  - id: custom-rule
    mode: WARN
    description: "Agent muss immer seine Quellen angeben"
    triggers:
      - type: message
        pattern: "*"
        requireSource: true
    maxOverrides: 3

Vorgefertigte Profile

| Profil | Beschreibung | Anchors | |--------|-------------|---------| | socratic | Basis-Quellenprüfung | Source Anchor, Intent Anchor, Verification Anchor | | architecture | Architekturentscheidungen (⚠️ erfordert separaten PR) | ADR-Format, Boundary Anchor, Stakeholder Anchor |

Profile können kombiniert werden. Mit roleProfiles lassen sich Profile pro Rolle zuweisen:

roleProfiles:
  developer: ["socratic"]
  architect: ["socratic", "architecture"]

Contracts (Verträge)

Ein Contract definiert, was der Agent tun (oder nicht tun) darf:

| Feld | Beschreibung | |------|-------------| | id | Eindeutige Kennung | | mode | BLOCK (hartes Stopp) oder WARN (weiche Erinnerung) | | description | Was der Contract durchsetzt | | triggers | Muster, die den Contract aktivieren | | maxOverrides | Wie viele Bypässe pro Contract erlaubt sind |

Tools

Das Plugin registriert drei Tools in opencode:

| Tool | Beschreibung | |------|-------------| | anchor-bypass | Temporär einen blockierten Contract umgehen | | anchor-status | Aktive Contracts, Zähler und aktuelle Rolle anzeigen | | anchor-config-reload | Konfiguration ohne Neustart neu laden |

Schritt-Bestätigung

Alle N Tool-Aufrufe (Standard: 3) pausiert das Plugin und fragt nach Bestätigung. Einstellbar über settings.stepConfirmationInterval.

Override-Mechanismus

Wenn ein Contract eine Aktion blockiert, kann der Agent einen einmaligen Override via anchor-bypass anfordern. Der Override-Zähler wird beim Neuladen der Contracts zurückgesetzt. Die maximale Anzahl Overrides pro Contract ist konfigurierbar (Standard: 3).


📚 Documentation

Full documentation, including the arc42 architecture documentation, is available in the docs/ directory.

🤝 Contributing

Contributions are welcome! Please read CONTRIBUTING.md and the Code of Conduct.

Security issues — please report via GitHub Private Vulnerability Reporting (see SECURITY.md).

📄 License

Apache-2.0 — see LICENSE.