@weave_protocol/adapter-codebuddy
v0.1.0
Published
Weave Protocol adapter for CodeBuddy Code - enforces WARD.md policies via CodeBuddy Code's PreToolUse hook
Maintainers
Readme
🛡️ @weave_protocol/adapter-codebuddy
Enforce WARD.md in CodeBuddy Code, Tencent's coding agent CLI, with its
PreToolUsehook. Every tool call the agent makes is checked against your policy before it runs.
This adapter is for CodeBuddy Code only. The same WARD.md works in every Weave adapter.
Quick start
npm i -g @weave_protocol/adapter-codebuddy
weave-codebuddy init # adds the hook to ~/.codebuddy/settings.json
weave-codebuddy status # hook installed? which WARD.md is active?Then open /hooks in CodeBuddy Code and approve the new hook. CodeBuddy Code doesn't load edited hooks until you review them there. Add a WARD.md to your project (npx @weave_protocol/ward init), or a user-wide one at ~/.codebuddy/WARD.md.
What it checks
The hook uses Ward's shared evaluator, so the rules match the other adapters exactly. That includes session and spend limits, the payment guard, outbound-data checks, model endpoints by jurisdiction, signed policies and decision receipts.
- Capability: the tool's WARD capability (
Bash→shell_exec,Read→file_read,Write/Edit→file_write, …) or its raw name. - Arguments: every path and URL argument, with
..and~normalized. - Shell commands: every URL and every absolute or
~path inBash. - MCP tools (
mcp__<server>__<tool>): by name, plus their path and URL arguments.
CodeBuddy Code runs PreToolUse hooks before its own permission prompts. An explicit allow would skip those prompts, so this adapter never sends one; your permission rules still apply to every call Ward allows.
Decisions
| WARD decision | What CodeBuddy Code sees |
|---|---|
| allow | nothing ({}): CodeBuddy Code's own permission rules and prompts still apply |
| deny | permissionDecision: "deny" with the reason; the agent gets it as the tool result |
| require_approval | permissionDecision: "ask": you're asked to confirm |
CodeBuddy Code lets a call through if a hook crashes, times out or exits with anything but 2. So this hook never exits non-zero; every outcome is an explicit decision:
- An invalid or unreadable WARD.md always denies, so a typo can't silently switch enforcement off.
- No WARD.md anywhere means no enforcement.
- Malformed payloads and evaluator errors allow by default, like Weave's other adapters.
weave-codebuddy init --fail-closedmakes them deny.
WARD.md is looked up in this order:
$WEAVE_WARD_PATH<project>/WARD.md<project>/.codebuddy/WARD.md<project>/.weave/WARD.md~/.codebuddy/WARD.md
Commands
weave-codebuddy init [--matcher=REGEX] [--timeout=SECONDS] [--fail-closed]
weave-codebuddy disable
weave-codebuddy status
weave-codebuddy test Read --input='{"file_path":"secrets/key"}' # dry run
weave-codebuddy hook pre-tool-use # what CodeBuddy Code runsinit backs up the config file and edits it atomically. It finds its own entry by its command, so your other hooks and settings are untouched. The default timeout is 10 seconds.
Dashboard
Set WEAVE_DASHBOARD_URL (and WEAVE_API_KEY) where you run the agent, and each decision is reported to a local Weave API dashboard as codebuddy. Only the decision and the tool name are sent, never command or argument contents. Reporting never changes a decision and gives up after 250 ms.
Verified
Built against CodeBuddy Code's hooks reference.
Live-checked in CodeBuddy Code 2.180.0. It ran headless (-p) against a local scripted model configured in ~/.codebuddy/models.json, so no login or API key was involved, and every decision was confirmed by Ward's signed receipts:
- a
Readof a denied path and aGrepinto it were blocked, and the model got the WARD reason ("PreToolUse:Read hook blocked this tool call: WARD: …"); - an allowed
Readwent through; - with a user rule in
settings.jsonallowingcurl, Ward still blockedcurlto an unlisted host and allowed it to a listed one.
🕸️ Part of Weave Protocol
One WARD.md policy for every agent you run, locally or at scale, plus the tools around it.
| Package | What it does | |---|---| | Ward | The WARD.md policy standard and the tool-call evaluator every adapter shares | | Mund | Scans content for prompt injection (English and Chinese), secrets, PII and exfiltration | | Hord | Encrypted vaults, PII tokenization, sandboxes, capability tokens, attestations | | Dōmere | Audit threads, compliance checkpoints, GDPR and CCPA records, anchoring | | Witan | Multi-agent consensus and spending caps | | Hundredmen | MCP proxy that enforces WARD.md on tool calls | | Tollere | Supply-chain checks: typosquats, CVEs, suspicious version diffs | | Browser | WARD.md and injection scanning for Playwright browser agents | | Adapters | WARD.md in Claude Code, Antigravity, MSAF, Gemini CLI, Codex, OpenCode, Cursor, Qwen Code, CodeBuddy Code, Qoder and TRAE | | Adversary · AgentSecBench | Red-team engine and locked benchmark | | API · CLI · LangChain | REST API and dashboard, setup CLI, LangChain.js integration | | full | Every defensive package in one install | | Yoxallismus | Post-quantum hybrid cipher (experimental beta) |
License
Apache-2.0
