cc-safety-net 2.0.11 → 2.1.1

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 CHANGED
@@ -146,6 +146,50 @@ npx cc-safety-net gui
146
146
 
147
147
  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).
148
148
 
149
+ ## Library API
150
+
151
+ Node.js hosts that need an in-process allow or deny decision can call the command-check
152
+ function directly instead of installing an agent integration:
153
+
154
+ ```bash
155
+ npm install cc-safety-net
156
+ ```
157
+
158
+ ```ts
159
+ import { checkCommand } from 'cc-safety-net/api';
160
+
161
+ function commandIsAllowed(command: string, cwd: string): boolean {
162
+ try {
163
+ const result = checkCommand({ command, cwd });
164
+ if (result.kind === 'allow') return true;
165
+ console.error(result.reason);
166
+ return false;
167
+ } catch (error) {
168
+ console.error('CC Safety Net could not check the command', error);
169
+ return false;
170
+ }
171
+ }
172
+
173
+ if (commandIsAllowed('git status', process.cwd())) {
174
+ // The host can now decide how to run the command.
175
+ }
176
+ ```
177
+
178
+ Usage rules:
179
+
180
+ - Requires Node.js 18 or later and ESM. There is no CommonJS build.
181
+ - `cwd` is required and must be an absolute directory path. It anchors relative command
182
+ targets and selects the project policy, so the API never defaults to hidden process state.
183
+ - The function reads local policy files, filesystem facts, and `CC_SAFETY_NET_*` environment
184
+ settings on each call. An invalid `CC_SAFETY_NET_LEVEL` is ignored and reported to stderr.
185
+ It does not run the command, write audit logs, change configuration, or make network requests.
186
+ - Commands are fully checked, including secret file access performed through commands. The
187
+ host's own non-shell file tools (read, write, edit, search) are not checked by this function.
188
+ - A `deny` result means the host must not execute the command. **If `checkCommand` throws,
189
+ do not execute the command either.**
190
+ - `reason` is display text; do not parse or compare it. Use the `kind` field for the
191
+ decision and treat the optional `ruleId` as diagnostic data only.
192
+
149
193
  ## Limitations
150
194
 
151
195
  CC Safety Net denies a tool call before it runs. It does not enforce filesystem permissions, inspect network egress, or contain a process. Two v2 limits matter. First, the policy and sensitive-path command extractors remain mainly POSIX-oriented. Native PowerShell path expressions such as `Get-Content $HOME\.ssh\id_rsa` can evade static path extraction. Second, policy-file protection is a best-effort exact-path guard. It does not emulate commands. Use operating-system permissions, a sandbox, or equivalent runtime controls when you need complete protection.
@@ -181,8 +225,9 @@ The **[ccsafetynet.com/docs](https://ccsafetynet.com/docs)** site contains the f
181
225
 
182
226
  See [CONTRIBUTING.md](CONTRIBUTING.md) to contribute to the project.
183
227
 
184
- The repository tracks all 11 generated files under `dist/`. They include the library
185
- bundle and its type declarations, the CLI entrypoint, the shared chunks, the vendored Zod copy,
228
+ The repository tracks all 14 generated files under `dist/`. They include the library
229
+ bundle and its type declarations, the command-check API entry and its declaration, the CLI
230
+ entrypoint, the shared chunks, the vendored Zod copy,
186
231
  and the Pi, Amp, and OpenClaw adapter files. Run `bun run verify:package` and
187
232
  `bun run verify:repository-plugin` when changing packaging, integrations, or release automation.
188
233