cc-safety-net 2.2.1 → 2.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +37 -53
- package/dist/amp/cc-safety-net/index.ts +55 -55
- package/dist/api.js +1 -1
- package/dist/bin/cc-safety-net.js +761 -142
- package/dist/chunks/index-et11dxs1.js +46 -0
- package/dist/chunks/{index-64gcamd4.js → index-qxyh7m59.js} +2 -2
- package/dist/chunks/index-y9vmf6ts.js +2 -0
- package/dist/index.js +1 -1
- package/dist/openclaw/cc-safety-net/index.js +55 -55
- package/dist/openclaw/cc-safety-net/openclaw.plugin.json +1 -1
- package/dist/openclaw/cc-safety-net/package.json +1 -1
- package/dist/pi/index.js +2 -2
- package/package.json +2 -2
- package/dist/chunks/index-25nh5wqs.js +0 -45
- package/dist/chunks/index-z08yh4sm.js +0 -46
package/README.md
CHANGED
|
@@ -28,20 +28,6 @@ CC Safety Net is short for Coding CLI Safety Net. It is a PreToolUse hook that b
|
|
|
28
28
|
|
|
29
29
|
We built CC Safety Net after an agent [wiped hours of work](https://www.reddit.com/r/ClaudeAI/comments/1pgxckk/claude_cli_deleted_my_entire_home_directory_wiped/) with one `rm -rf ~/` or `git checkout --`. Instructions did not stop it. Rules in `CLAUDE.md` or `AGENTS.md` can guide an agent, but they cannot enforce a technical limit. CC Safety Net watches relevant tool calls and blocks destructive commands and secret access before they reach the shell. See [What is CC Safety Net](https://ccsafetynet.com/docs/introduction) for the full background.
|
|
30
30
|
|
|
31
|
-
## What's new in v2.0.0
|
|
32
|
-
|
|
33
|
-
> [!TIP]
|
|
34
|
-
> **Already running v1?** Run `npx -y cc-safety-net@latest update` to upgrade every installed integration to v2. If you defined custom rules under v1, also read [Upgrading from an older version](#upgrading-from-an-older-version).
|
|
35
|
-
|
|
36
|
-
- **Evaluation engine.** A canonical command IR, policy snapshots that remain immutable at every nested level, and an ordered guard pipeline now support decision tracing through `explain`.
|
|
37
|
-
- **Secret protection.** Built-in rules block content access to SSH keys, `.env` files, cloud credentials, and coding-CLI credential stores through shell commands and file tools.
|
|
38
|
-
- **Always-on protections.** Every mode blocks recursive deletion of root or home, Git metadata changes to the `.git` control plane, hooks, worktrees, or submodules, and changes to the user policy file. Overrides do not disable these rules.
|
|
39
|
-
- **Safety presets.** The `standard`, `strict`, and `paranoid` levels support per-rule overrides and trusted delete allow-paths. Safety-level and capability environment variables can only raise protection. `CC_SAFETY_NET_WORKTREE` is the one exception. It allows local Git discards in linked worktrees.
|
|
40
|
-
- **Policy GUI.** `cc-safety-net gui` runs a local, token-authenticated editor with a live preset preview.
|
|
41
|
-
- **Universal installer.** Interactive `install` and `uninstall` commands support all twelve coding CLIs. The `update` command updates installed integrations.
|
|
42
|
-
- **Command-decision audit trail.** CC Safety Net records allowed and blocked decisions in local per-project JSONL. It redacts secrets, keeps records for 30 days by default, and shows them through `cc-safety-net logs`.
|
|
43
|
-
- **Threat model.** [SECURITY.md](SECURITY.md) defines the mode contract and resource limits. Its residual-risk registry records decisions for bypass families.
|
|
44
|
-
|
|
45
31
|
## Quick start
|
|
46
32
|
|
|
47
33
|
You need Node.js 18 or higher.
|
|
@@ -58,21 +44,7 @@ To update every installed integration:
|
|
|
58
44
|
npx -y cc-safety-net@latest update
|
|
59
45
|
```
|
|
60
46
|
|
|
61
|
-
Keep the `@latest` qualifier
|
|
62
|
-
copy from the npx cache instead of the current release.
|
|
63
|
-
|
|
64
|
-
To remove integrations interactively:
|
|
65
|
-
|
|
66
|
-
```bash
|
|
67
|
-
npx -y cc-safety-net uninstall
|
|
68
|
-
```
|
|
69
|
-
|
|
70
|
-
If you use the CLI often, install it globally to get `ccsn`, a shorter alias for the same commands:
|
|
71
|
-
|
|
72
|
-
```bash
|
|
73
|
-
npm install -g cc-safety-net
|
|
74
|
-
ccsn doctor
|
|
75
|
-
```
|
|
47
|
+
Keep the `@latest` qualifier; a bare `cc-safety-net` spec can run an older cached copy from the npx cache. `npx -y cc-safety-net uninstall` removes integrations interactively, and `npm install -g cc-safety-net` gives you `ccsn`, a shorter alias for the same commands.
|
|
76
48
|
|
|
77
49
|
## Supported coding CLIs
|
|
78
50
|
|
|
@@ -91,9 +63,9 @@ CC Safety Net supports the coding agent CLIs below on Windows, macOS, and Linux.
|
|
|
91
63
|
<td align="center"><a href="https://ccsafetynet.com/docs/installation#github-copilot-cli-installation"><picture><source media="(prefers-color-scheme: dark)" srcset="./.github/assets/copilot-cli-dark.svg"><img alt="GitHub Copilot CLI" src="./.github/assets/copilot-cli-light.svg" height="32"></picture><br>GitHub Copilot CLI</a></td>
|
|
92
64
|
<td align="center"><a href="https://ccsafetynet.com/docs/installation#grok-build-installation"><picture><source media="(prefers-color-scheme: dark)" srcset="./.github/assets/grok-build-dark.svg"><img alt="Grok Build" src="./.github/assets/grok-build-light.svg" height="32"></picture><br>Grok Build</a></td>
|
|
93
65
|
<td align="center"><a href="https://ccsafetynet.com/docs/installation#hermes-agent-installation"><img alt="Hermes Agent" src="./.github/assets/hermes.png" height="32"><br>Hermes Agent</a></td>
|
|
66
|
+
<td align="center"><a href="https://ccsafetynet.com/docs/installation#kimi-code-installation"><img alt="Kimi Code" src="./.github/assets/kimi-cli.png" height="32"><br>Kimi Code</a></td>
|
|
94
67
|
</tr>
|
|
95
68
|
<tr>
|
|
96
|
-
<td align="center"><a href="https://ccsafetynet.com/docs/installation#kimi-code-installation"><img alt="Kimi Code" src="./.github/assets/kimi-cli.png" height="32"><br>Kimi Code</a></td>
|
|
97
69
|
<td align="center"><a href="https://ccsafetynet.com/docs/installation#openclaw-installation"><img alt="OpenClaw" src="./.github/assets/openclaw.png" height="32"><br>OpenClaw</a></td>
|
|
98
70
|
<td align="center"><a href="https://ccsafetynet.com/docs/installation#opencode-installation"><picture><source media="(prefers-color-scheme: dark)" srcset="./.github/assets/opencode-dark.svg"><img alt="OpenCode" src="./.github/assets/opencode-light.svg" height="32"></picture><br>OpenCode</a></td>
|
|
99
71
|
<td align="center"><a href="https://ccsafetynet.com/docs/installation#pi-installation"><picture><source media="(prefers-color-scheme: dark)" srcset="./.github/assets/pi-dark.svg"><img alt="Pi" src="./.github/assets/pi-light.svg" height="32"></picture><br>Pi</a></td>
|
|
@@ -109,11 +81,25 @@ CC Safety Net supports the coding agent CLIs below on Windows, macOS, and Linux.
|
|
|
109
81
|
| **Interpreter one-liners** | Finds destructive code in `python -c`, `node -e`, `ruby -e`, and `perl -e` one-liners such as `os.system("rm -rf /")`. |
|
|
110
82
|
| **Fail-closed by default** | Blocks malformed hook input and, in strict mode, commands it cannot parse. Invalid configuration never blocks. CC Safety Net drops an unverifiable rule source and uses protective defaults when it cannot read `policy.json`. It reports these states in block messages, `doctor`, the status line, and the GUI. |
|
|
111
83
|
| **Secret protection** | Blocks content access to SSH keys, `.env` files, `~/.aws`, Kubernetes, Docker, and gcloud configuration, and coding-CLI credential stores. The rules apply to shell commands and read, edit, write, and search tools. |
|
|
112
|
-
| **Custom rules via rulebooks** | Lets you add blocking rules at user or project scope.
|
|
84
|
+
| **Custom rules via rulebooks** | Lets you add blocking rules at user or project scope. Rulebooks are live JSON files: local ones are authored in place, and rulebooks fetched from GitHub are validated and vendored into your own configuration, updating only when you run `rule update`. |
|
|
113
85
|
| **Audit logging** | Writes allowed and blocked command decisions to local per-project JSONL, redacts secrets, and keeps records for 30 days by default. Browse them with `npx cc-safety-net logs`, or review them in the Activity view of `npx cc-safety-net gui`. |
|
|
114
86
|
|
|
115
87
|
Full rule catalogs: [Blocked Commands](https://ccsafetynet.com/docs/reference/blocked-commands) · [Allowed Commands](https://ccsafetynet.com/docs/reference/allowed-commands) · [Secret Protection](https://ccsafetynet.com/docs/reference/secret-protection).
|
|
116
88
|
|
|
89
|
+
## Official rulebooks for AWS, Terraform, gcloud, and Azure
|
|
90
|
+
|
|
91
|
+
The [cc-safety-net/rulebooks](https://github.com/cc-safety-net/rulebooks) repository publishes curated rulebooks that block recognizable destructive infrastructure CLI operations: `terraform destroy` and `terraform state rm`, `aws s3 rm` and `aws ec2 terminate-instances`, `gcloud projects delete` and `gcloud storage rm`, `az group delete` and `az keyvault purge`, and more. Safe previews such as `--dryrun` and `-dry-run` stay allowed. Install a selection with one command:
|
|
92
|
+
|
|
93
|
+
```bash
|
|
94
|
+
npx -y cc-safety-net rule add --only terraform aws --global
|
|
95
|
+
```
|
|
96
|
+
|
|
97
|
+
Rulebooks are JSON data: never executed, only adding denials, unable to weaken built-in protections. Installing vendors the files into your own configuration; nothing updates in the background. See [Official Rulebooks](https://ccsafetynet.com/docs/configuration/rulebooks).
|
|
98
|
+
|
|
99
|
+
## Team setup
|
|
100
|
+
|
|
101
|
+
Members who install CC Safety Net once per machine are protected in every repository at the standard preset, so the minimum team setup is automating that install in your project's existing bootstrap step, such as an npm `postinstall` script. To standardize more than the defaults, a team lead commits a project policy and project-scoped rulebooks under `.cc-safety-net/`, and every clone picks them up with no member action. Policy changes stay human-approved: `policy apply` requires a terminal confirmation and refuses agent invocations, and any field a project policy relaxes below a member's own policy is reported line by line in `status`, `doctor`, and the GUI. See [Team Setup](https://ccsafetynet.com/docs/guides/team-setup).
|
|
102
|
+
|
|
117
103
|
## Why not just use a sandbox?
|
|
118
104
|
|
|
119
105
|
A workspace-writable sandbox still permits `git reset --hard`, `git push --force`, and `rm -rf .` inside the project directory. The operating system sees writes to an allowed path. A sandbox limits where a process can write. CC Safety Net blocks destructive operations inside that allowed area. Use both. See [vs Sandboxing](https://ccsafetynet.com/docs/guides/vs-sandboxing).
|
|
@@ -143,10 +129,24 @@ npx cc-safety-net logs
|
|
|
143
129
|
npx cc-safety-net gui
|
|
144
130
|
```
|
|
145
131
|
|
|
146
|
-
`doctor`, `explain`, and `logs` support `--json` for machine-readable output. The audit trail stays on your machine. It records command decisions, but it does not record command output or prompts.
|
|
132
|
+
`doctor`, `explain`, and `logs` support `--json` for machine-readable output. The audit trail stays on your machine. It records command decisions, but it does not record command output or prompts.
|
|
147
133
|
|
|
148
134
|
Details: [CLI Commands](https://ccsafetynet.com/docs/reference/cli-commands) · [Explain Trace](https://ccsafetynet.com/docs/reference/explain-trace) · [Audit Log](https://ccsafetynet.com/docs/reference/audit-log) · [Dashboard](https://ccsafetynet.com/docs/guides/dashboard) · [Configuration Recovery](https://ccsafetynet.com/docs/configuration/recovery).
|
|
149
135
|
|
|
136
|
+
## The /cc-safety-net skill
|
|
137
|
+
|
|
138
|
+
The plugin ships a skill that turns your coding agent into a CC Safety Net operator. It never triggers on its own; you invoke it by typing `/cc-safety-net` in the agent (Claude Code lists it under its plugin namespace as `cc-safety-net:cc-safety-net`; Pi and OpenCode register it as a built-in `/cc-safety-net` command).
|
|
139
|
+
|
|
140
|
+
Reach for it when:
|
|
141
|
+
|
|
142
|
+
- A command was just refused with `BLOCKED by CC Safety Net` and you want the step-by-step reason.
|
|
143
|
+
- A block looks wrong and you want it triaged: reproduce the decision, fix the responsible custom rule, or report a built-in false positive.
|
|
144
|
+
- You want custom blocking rules written, edited, or migrated for you.
|
|
145
|
+
- You want CC Safety Net installed into, updated in, or removed from another agent CLI.
|
|
146
|
+
- A rule you added does not fire, or you want to confirm protection is active.
|
|
147
|
+
|
|
148
|
+
Anything you type after the command becomes the request, e.g. `/cc-safety-net why was my last git command blocked` or `/cc-safety-net block terraform destroy in this project`.
|
|
149
|
+
|
|
150
150
|
## Library API
|
|
151
151
|
|
|
152
152
|
Node.js hosts that need an in-process allow or deny decision can call the command-check
|
|
@@ -178,18 +178,10 @@ if (commandIsAllowed('git status', process.cwd())) {
|
|
|
178
178
|
|
|
179
179
|
Usage rules:
|
|
180
180
|
|
|
181
|
-
- Requires Node.js 18 or later and ESM. There is no CommonJS build.
|
|
182
181
|
- `cwd` is required and must be an absolute directory path. It anchors relative command
|
|
183
|
-
targets and selects the project policy
|
|
184
|
-
- The function reads local policy files, filesystem facts, and `CC_SAFETY_NET_*` environment
|
|
185
|
-
settings on each call. An invalid `CC_SAFETY_NET_LEVEL` is ignored and reported to stderr.
|
|
186
|
-
It does not run the command, write audit logs, change configuration, or make network requests.
|
|
187
|
-
- Commands are fully checked, including secret file access performed through commands. The
|
|
188
|
-
host's own non-shell file tools (read, write, edit, search) are not checked by this function.
|
|
182
|
+
targets and selects the project policy.
|
|
189
183
|
- A `deny` result means the host must not execute the command. **If `checkCommand` throws,
|
|
190
184
|
do not execute the command either.**
|
|
191
|
-
- `reason` is display text; do not parse or compare it. Use the `kind` field for the
|
|
192
|
-
decision and treat the optional `ruleId` as diagnostic data only.
|
|
193
185
|
|
|
194
186
|
## Limitations
|
|
195
187
|
|
|
@@ -201,11 +193,9 @@ Codex has one integration-specific limit. Its unified exec path is the default o
|
|
|
201
193
|
|
|
202
194
|
## Upgrading from an older version
|
|
203
195
|
|
|
204
|
-
|
|
196
|
+
Run the `update` command from [Quick start](#quick-start) to upgrade every installed integration to the current release.
|
|
205
197
|
|
|
206
|
-
|
|
207
|
-
npx -y cc-safety-net@latest update
|
|
208
|
-
```
|
|
198
|
+
If you installed rulebooks from GitHub on version 2.2 or earlier, run `npx -y cc-safety-net rule sync` once per scope (add `--global` for user-scope sources) after upgrading. Rulebooks are now live vendored files instead of lock-and-cache state; the command migrates each cached rulebook into its live location and removes the leftovers. Until then, those GitHub-sourced rules are inactive and `status` and `doctor` report the degraded sources.
|
|
209
199
|
|
|
210
200
|
> [!WARNING]
|
|
211
201
|
> If you defined custom rules in a legacy inline config such as `.safety-net.json` or `~/.cc-safety-net/config.json`, CC Safety Net no longer loads those files at runtime. Their rules enforce nothing. Normal use does not show this failure because the commands now run. Run `npx -y cc-safety-net rule migrate` to convert the rules to the rulebook layout. Then run `npx -y cc-safety-net doctor` and confirm that the runtime is `ready`. See the [migration guide](https://ccsafetynet.com/docs/configuration/custom-rules#migrate-legacy-configuration).
|
|
@@ -216,8 +206,8 @@ The **[ccsafetynet.com/docs](https://ccsafetynet.com/docs)** site contains the f
|
|
|
216
206
|
|
|
217
207
|
| Area | Pages |
|
|
218
208
|
|---|---|
|
|
219
|
-
| Get started | [Introduction](https://ccsafetynet.com/docs/introduction) · [Installation](https://ccsafetynet.com/docs/installation) · [Quickstart](https://ccsafetynet.com/docs/quickstart) · [How It Works](https://ccsafetynet.com/docs/guides/how-it-works) · [Dashboard](https://ccsafetynet.com/docs/guides/dashboard) |
|
|
220
|
-
| Configuration | [Modes](https://ccsafetynet.com/docs/configuration/modes) · [Policy](https://ccsafetynet.com/docs/configuration/policy) · [Environment](https://ccsafetynet.com/docs/configuration/environment) · [Custom Rules](https://ccsafetynet.com/docs/configuration/custom-rules) · [Status Line](https://ccsafetynet.com/docs/configuration/status-line) · [Configuration Recovery](https://ccsafetynet.com/docs/configuration/recovery) |
|
|
209
|
+
| Get started | [Introduction](https://ccsafetynet.com/docs/introduction) · [Installation](https://ccsafetynet.com/docs/installation) · [Quickstart](https://ccsafetynet.com/docs/quickstart) · [Team Setup](https://ccsafetynet.com/docs/guides/team-setup) · [How It Works](https://ccsafetynet.com/docs/guides/how-it-works) · [Dashboard](https://ccsafetynet.com/docs/guides/dashboard) |
|
|
210
|
+
| Configuration | [Modes](https://ccsafetynet.com/docs/configuration/modes) · [Policy](https://ccsafetynet.com/docs/configuration/policy) · [Environment](https://ccsafetynet.com/docs/configuration/environment) · [Custom Rules](https://ccsafetynet.com/docs/configuration/custom-rules) · [Official Rulebooks](https://ccsafetynet.com/docs/configuration/rulebooks) · [Status Line](https://ccsafetynet.com/docs/configuration/status-line) · [Configuration Recovery](https://ccsafetynet.com/docs/configuration/recovery) |
|
|
221
211
|
| Reference | [Blocked Commands](https://ccsafetynet.com/docs/reference/blocked-commands) · [Allowed Commands](https://ccsafetynet.com/docs/reference/allowed-commands) · [Secret Protection](https://ccsafetynet.com/docs/reference/secret-protection) · [Audit Log](https://ccsafetynet.com/docs/reference/audit-log) · [CLI Commands](https://ccsafetynet.com/docs/reference/cli-commands) · [Explain Trace](https://ccsafetynet.com/docs/reference/explain-trace) · [Glossary](https://ccsafetynet.com/docs/reference/glossary) |
|
|
222
212
|
| Guides | [Architecture](https://ccsafetynet.com/docs/guides/architecture) · [Analysis Engine](https://ccsafetynet.com/docs/guides/analysis-engine) · [Design Principles](https://ccsafetynet.com/docs/guides/design-principles) · [Security Model](https://ccsafetynet.com/docs/guides/security-model) · [vs Sandboxing](https://ccsafetynet.com/docs/guides/vs-sandboxing) · [Integration Architecture](https://ccsafetynet.com/docs/guides/integration-architecture) · [Known Limitations](https://ccsafetynet.com/docs/guides/known-limitations) · [Troubleshooting](https://ccsafetynet.com/docs/guides/troubleshooting) |
|
|
223
213
|
| Project | [Contributing](https://ccsafetynet.com/docs/contributing) · [Security Policy](https://ccsafetynet.com/docs/security) |
|
|
@@ -226,12 +216,6 @@ The **[ccsafetynet.com/docs](https://ccsafetynet.com/docs)** site contains the f
|
|
|
226
216
|
|
|
227
217
|
See [CONTRIBUTING.md](CONTRIBUTING.md) to contribute to the project.
|
|
228
218
|
|
|
229
|
-
The repository tracks all 14 generated files under `dist/`. They include the library
|
|
230
|
-
bundle and its type declarations, the command-check API entry and its declaration, the CLI
|
|
231
|
-
entrypoint, the shared chunks, the vendored Zod copy,
|
|
232
|
-
and the Pi, Amp, and OpenClaw adapter files. Run `bun run verify:package` and
|
|
233
|
-
`bun run verify:repository-plugin` when changing packaging, integrations, or release automation.
|
|
234
|
-
|
|
235
219
|
## License
|
|
236
220
|
|
|
237
221
|
MIT
|