Deny writes to protected files (.env/secrets/keys) and dangerous Bash patterns, with a toast explaining why

Coding-agent harness for Claude Code (and friends): inject skills, commands, agents, hooks, and an MCP surface into any project, and watch what the agent does from a local dashboard.
npm install -g @weavecode/weave
weave init # scaffold a project
weave dashboard # start the daemon (if it is not running) and open the UI
weave init — writes the harness files a project needs (.claude/ helpers, hooks, settings, .mcp.json), merging into user files instead of overwriting them. Multi-harness: Claude Code and Codex.weave daemon — a local daemon (HTTP + SQLite) that ingests hook events, stores sessions, and serves the dashboard. Hooks never call it over HTTP: events append to <configDir>/weave/hooks/inbox/ (a daemon worker thread claims and ingests them, then deletes the file), so collection and rule-driven injection keep working while the daemon is down. Upgrade note: a project's .claude/helpers/hook-handler.cjs is only refreshed by weave init, so re-run it in projects initialized before this change (older scripts post to a removed endpoint and would report nothing).weave dashboard — a web UI for projects, sessions, hooks, plugins, and installs. Served by the daemon itself.weave scan / weave status — project discovery and harness status.weave chpass).Everything weave ships — the weave init commands and agents, the built-in skills/hooks/rules plugin packs, and the rule packs loaded into the engine — lives in one marketplace-shaped directory:
packages/weave-templates/src/resources/weave-market/
├── .claude-plugin/marketplace.json # the repo's own manifest
├── plugins/<scope>/<pack>/ # toolkit packages (skills, hooks, mods)
├── rules/<pack>/ # rule packs loaded by the weave engine
└── init/{commands,agents}/ # what `weave init` copies in
On daemon start it is materialized at <configDir>/weave/market/weave/ as a link to that directory (a copy where links are unavailable), and it is the single source for scanning, listing and installing:
src/resources/…, so content edits are live for the next scan/restart; pnpm build copies it to dist/resources/… for the published package;External repos are separate: import them through the dashboard's resource market (<configDir>/weave/market/<id>/), and their packages show up as their own namespace block next to the built-in weave one.
| Command | What it does | ||
|---|---|---|---|
weave init | Scaffold harness files into a project | ||
weave scan | Discover and register projects | ||
weave status | Show harness status for a project | ||
weave doctor | Diagnose local wiring (registration, token, daemon) | ||
| `weave daemon start\ | stop\ | status` | Manage the local daemon |
weave dashboard | Open the dashboard in a browser (starting the daemon if needed) | ||
weave chpass <new password> | Change the dashboard login password (locally, no old password needed) | ||
weave uninstall | Remove weave's init outputs from a project (rolls back the init commit when it is HEAD, otherwise commits the removal) |
One artifact is published — @weavecode/weave, a self-contained bundle: the compiled CLI, daemon, dashboard and built-in resources, with every runtime dependency packed inside the tarball, so a global install needs nothing else from the registry. The repo's layers below are private and are never published on their own.
| Package | Role |
|---|---|
packages/weave (@weavecode/weave) | The published bundle: CLI + daemon + dashboard + resources |
packages/weave-cli (@weavecode/cli) | CLI entry point (weave command) |
packages/weave-server (@weavecode/server) | Daemon: HTTP, SQLite, hook ingestion, dashboard host |
packages/weave-harness (@weavecode/harness) | Harness drivers and the init pipeline |
packages/weave-templates (@weavecode/templates) | Built-in market (skills, commands, agents, rules) |
packages/weave-core (@weavecode/core) | Shared types and tables |
node:sqlite).PATH — weave drives them, it does not bundle them.pnpm install
pnpm build # tsc -b + template/preset copy
pnpm build:web # dashboard bundle → packages/weave-server/web/dist
pnpm test
pnpm dev # CLI from source
pnpm dev:server # daemon from source
pnpm dev:web # dashboard on :9527
Requires Node.js >= 22.5 (uses node:sqlite).
node scripts/release.mjs <version> # bump every package, build, publish components with pnpm, then publish the umbrella tgz
Packages publish under the @weavecode scope to the public npm registry. workspace: dependencies are rewritten by pnpm publish — do not use npm publish directly.
Apache-2.0. See LICENSE and THIRD_PARTY_NOTICES.md.
hooks/register.tsx 35 lines1import type { Register } from 'claude-code'
2
3// 敏感路径:.env / .env.*、secrets/、PEM 私钥、SSH 私钥。
4const PROTECTED = /(^|\/)\.env(\.|$)|(^|\/)secrets(\/|$)|\.pem$|(^|\/)id_(rsa|ed25519)(\.|$)/
5
6// 高危 Bash 模式:递归强删根/家目录、force push、格式化/整盘写、fork 炸弹。
7const DANGEROUS =
8 /(^|\s)rm\s+-r[f]*\s+(\/|~|\$HOME)(\s|$)|git\s+push\s+([^&|;]*\s(-f|--force)\b)|mkfs|dd\s+if=|:\(\)\s*\{\s*:\|:\s*&\s*\}\s*;/
9
10function deny($: { plugin: { name: string }; ui: { toast(t: string): void } }, reason: string) {
11 const text = `${$.plugin.name}: ${reason}`
12 $.ui.toast(text)
13 return { deny: text }
14}
15
16export const register: Register = on => {
17 on('tool.call', { tool: 'Edit' }, ($, e, next) =>
18 PROTECTED.test(e.file_path)
19 ? deny($, `已拦截对 ${e.file_path} 的编辑(敏感文件受保护)`)
20 : next(e),
21 )
22
23 on('tool.call', { tool: 'Write' }, ($, e, next) =>
24 PROTECTED.test(e.file_path)
25 ? deny($, `已拦截对 ${e.file_path} 的写入(敏感文件受保护)`)
26 : next(e),
27 )
28
29 on('tool.call', { tool: 'Bash' }, ($, e, next) =>
30 DANGEROUS.test(e.command)
31 ? deny($, `已拦截高危命令:${e.command.slice(0, 80)}`)
32 : next(e),
33 )
34}
35