@weave_protocol/adapter-qoder
v0.1.2
Published
Weave Protocol adapter for Qoder CLI - enforces WARD.md policies via Qoder CLI's PreToolUse hook
Maintainers
Readme
🛡️ @weave_protocol/adapter-qoder
Enforce WARD.md in Qoder CLI, Alibaba's Qoder coding agent, in the terminal, with its
PreToolUsehook. Every tool call the agent makes is checked against your policy before it runs.
This adapter is for Qoder CLI only. The same WARD.md works in every Weave adapter.
Quick start
npm i -g @weave_protocol/adapter-qoder
weave-qoder init # adds the hook to ~/.qoder/settings.json
weave-qoder status # hook installed? which WARD.md is active?Then restart Qoder CLI. Add a WARD.md to your project (npx @weave_protocol/ward init), or a user-wide one at ~/.qoder/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. The Qoder IDE and JetBrains plugin's native names map to the same capabilities (run_in_terminal→shell_exec,search_replace/create_file/edit_file→file_write,delete_file→file_delete,read_file,grep_code,list_dir,fetch_content, …), so a rule holds whichever name the IDE reports. - 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.
A WARD deny holds even in Qoder's bypass_permissions mode.
Decisions
| WARD decision | What Qoder CLI sees |
|---|---|
| allow | nothing ({}): Qoder CLI'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 |
Qoder CLI 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-qoder init --fail-closedmakes them deny.
WARD.md is looked up in this order:
$WEAVE_WARD_PATH<project>/WARD.md<project>/.qoder/WARD.md<project>/.weave/WARD.md~/.qoder/WARD.md
Commands
weave-qoder init [--matcher=REGEX] [--timeout=SECONDS] [--fail-closed]
weave-qoder disable
weave-qoder status
weave-qoder test Read --input='{"file_path":"secrets/key"}' # dry run
weave-qoder hook pre-tool-use # what Qoder CLI 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 qoder. 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 Qoder CLI's hooks guide and reference.
Live-checked in Qoder CLI 1.1.83, signed in to a Qoder account with a real model, in a throwaway workspace with its own WARD.md and a project-level hook. Every decision was confirmed by Ward's signed receipts (4 verified: 2 allow, 2 deny):
- an allowed
Readwent through, and aReadofsecrets/keywas blocked with the WARD reason; - with a user rule in
.qoder/settings.jsonallowingBash(curl:*), Ward still blockedcurlto an unlisted host and allowed it to a listed one.
Also live-checked in the Qoder desktop app 0.5.11, signed in, with Auto approve on, using the same project hook. The app reads the hooks in .qoder/settings.json and sends the same tool names as the CLI (Read, Bash). Ward blocked a Read of secrets/key, a curl to an unlisted host, and the agent's attempt to read the policy file, and allowed the rest. The receipt chain verified.
Two things we learned in the app:
- It runs each new chat in an empty folder of its own (
~/Documents/Qoder/…), where your project's.qoder/settings.jsonand WARD.md aren't present. Add the project with Workspaces > + and start tasks inside it, or install the hook user-wide withweave-qoder init. Restart the app after any hook change. - The agent reads WARD.md and holds back on its own. That's good, but it means a test where the agent can read the policy proves nothing about Ward. For the curl check, we kept the policy outside the workspace with
WEAVE_WARD_PATH, so only Ward could stop the call.
Qoder IDE and JetBrains plugin: fixed in 0.1.2. Their hooks don't always use the names Qoder's hooks docs list. The docs give native names (run_in_terminal, search_replace) and Claude Code-compatible ones (Bash, Edit), but a live check in the IDE showed it sending SearchReplace for an edit. 0.1.0 mapped neither native name, and two policies failed open:
run_in_terminalescaped adeny: shell_execcapability rule;- an edit (
search_replace/SearchReplace) was checked as a read, so it could change files that only had read access.
0.1.1 mapped the documented native names but not SearchReplace, and the live check still got an edit through. 0.1.2 matches tool names ignoring case, _ and - (MCP tools excepted), and Ward 0.3.16 treats any unmapped tool named for replacing, patching or updating as a write. Path, URL and shell-command checks were never affected. Live-checked in the Qoder IDE: a shell command was denied (Bash), reads were allowed (Read), and the edit is re-checked after this release. Advisory: GHSA-83gf-j63m-v8h5.
🕸️ 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
