cc-safety-net 0.6.2 → 0.7.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.
Files changed (44) hide show
  1. package/README.md +81 -1
  2. package/dist/bin/cc-safety-net.js +4252 -2934
  3. package/dist/bin/commands/claude-code.d.ts +2 -0
  4. package/dist/bin/commands/copilot-cli.d.ts +2 -0
  5. package/dist/bin/commands/custom-rules-doc.d.ts +2 -0
  6. package/dist/bin/commands/doctor.d.ts +2 -0
  7. package/dist/bin/commands/explain.d.ts +2 -0
  8. package/dist/bin/commands/gemini-cli.d.ts +2 -0
  9. package/dist/bin/commands/index.d.ts +18 -0
  10. package/dist/bin/commands/statusline.d.ts +2 -0
  11. package/dist/bin/commands/types.d.ts +34 -0
  12. package/dist/bin/commands/verify-config.d.ts +2 -0
  13. package/dist/bin/doctor/activity.d.ts +1 -1
  14. package/dist/bin/doctor/config.d.ts +1 -1
  15. package/dist/bin/doctor/environment.d.ts +1 -1
  16. package/dist/bin/doctor/flags.d.ts +5 -0
  17. package/dist/bin/doctor/format.d.ts +1 -1
  18. package/dist/bin/doctor/hooks.d.ts +2 -2
  19. package/dist/bin/doctor/index.d.ts +2 -1
  20. package/dist/bin/doctor/system-info.d.ts +1 -1
  21. package/dist/bin/doctor/updates.d.ts +1 -1
  22. package/dist/bin/explain/analyze.d.ts +5 -0
  23. package/dist/bin/explain/config.d.ts +23 -0
  24. package/dist/bin/explain/flags.d.ts +9 -0
  25. package/dist/bin/explain/format-helpers.d.ts +35 -0
  26. package/dist/bin/explain/format.d.ts +8 -0
  27. package/dist/bin/explain/index.d.ts +7 -0
  28. package/dist/bin/explain/redact.d.ts +20 -0
  29. package/dist/bin/explain/segment.d.ts +11 -0
  30. package/dist/bin/help.d.ts +17 -0
  31. package/dist/bin/hooks/copilot-cli.d.ts +1 -0
  32. package/dist/bin/utils/colors.d.ts +36 -0
  33. package/dist/core/analyze/analyze-command.d.ts +2 -1
  34. package/dist/core/analyze/segment.d.ts +3 -1
  35. package/dist/core/analyze.d.ts +7 -7
  36. package/dist/core/config.d.ts +1 -1
  37. package/dist/core/rules-custom.d.ts +1 -1
  38. package/dist/features/builtin-commands/commands.d.ts +1 -1
  39. package/dist/features/builtin-commands/index.d.ts +2 -2
  40. package/dist/index.js +386 -373
  41. package/dist/types.d.ts +111 -0
  42. package/package.json +4 -3
  43. /package/dist/bin/{claude-code.d.ts → hooks/claude-code.d.ts} +0 -0
  44. /package/dist/bin/{gemini-cli.d.ts → hooks/gemini-cli.d.ts} +0 -0
package/README.md CHANGED
@@ -6,6 +6,7 @@
6
6
  [![Claude Code](https://img.shields.io/badge/Claude%20Code-D27656)](#claude-code-installation)
7
7
  [![OpenCode](https://img.shields.io/badge/OpenCode-black)](#opencode-installation)
8
8
  [![Gemini CLI](https://img.shields.io/badge/Gemini%20CLI-678AE3)](#gemini-cli-installation)
9
+ [![Copilot CLI](https://img.shields.io/badge/Copilot%20CLI-4EA5C9)](#github-copilot-cli-installation)
9
10
  [![License: MIT](https://img.shields.io/badge/License-MIT-red.svg)](https://opensource.org/licenses/MIT)
10
11
 
11
12
  <div align="center">
@@ -26,11 +27,13 @@ A Claude Code plugin that acts as a safety net, catching destructive git and fil
26
27
  - [Claude Code Installation](#claude-code-installation)
27
28
  - [OpenCode Installation](#opencode-installation)
28
29
  - [Gemini CLI Installation](#gemini-cli-installation)
30
+ - [GitHub Copilot CLI Installation](#github-copilot-cli-installation)
29
31
  - [Status Line Integration](#status-line-integration)
30
32
  - [Setup via Slash Command](#setup-via-slash-command)
31
33
  - [Manual Setup](#manual-setup)
32
34
  - [Emoji Mode Indicators](#emoji-mode-indicators)
33
35
  - [Diagnostics](#diagnostics)
36
+ - [Explain (Debug Analysis)](#explain-debug-analysis)
34
37
  - [Commands Blocked](#commands-blocked)
35
38
  - [Commands Allowed](#commands-allowed)
36
39
  - [What Happens When Blocked](#what-happens-when-blocked)
@@ -210,6 +213,38 @@ gemini extensions install https://github.com/kenryu42/gemini-safety-net
210
213
  > }
211
214
  > ```
212
215
 
216
+ ---
217
+
218
+ ### GitHub Copilot CLI Installation
219
+
220
+ Safety Net supports GitHub Copilot CLI via its [hooks system](https://docs.github.com/en/copilot/concepts/agents/coding-agent/about-hooks).
221
+
222
+ 1. **Create the hooks directory** in your repository:
223
+
224
+ ```bash
225
+ mkdir -p .github/hooks
226
+ ```
227
+
228
+ 2. **Create `.github/hooks/safety-net.json`**:
229
+
230
+ ```json
231
+ {
232
+ "version": 1,
233
+ "hooks": {
234
+ "preToolUse": [
235
+ {
236
+ "type": "command",
237
+ "bash": "npx -y cc-safety-net --copilot-cli",
238
+ "cwd": ".",
239
+ "timeoutSec": 15
240
+ }
241
+ ]
242
+ }
243
+ }
244
+ ```
245
+
246
+ The hook will intercept bash commands and block destructive operations before they execute.
247
+
213
248
  ## Status Line Integration
214
249
 
215
250
  Safety Net can display its status in Claude Code's status line, showing whether protection is active and which modes are enabled.
@@ -243,7 +278,22 @@ Add the following to your `~/.claude/settings.json`:
243
278
  }
244
279
  ```
245
280
 
246
- **Using npm:**
281
+ **Using Claude X:**
282
+
283
+ ```json
284
+ {
285
+ "statusLine": {
286
+ "type": "command",
287
+ "command": "BUN_BE_BUN=1 claude x cc-safety-net --statusline"
288
+ }
289
+ }
290
+ ```
291
+ > [!NOTE]
292
+ > The `claude x` command is only compatible with the native version of Claude Code. If you installed via npm, please use `npx` or `bunx` instead.
293
+
294
+
295
+
296
+ **Using NPM:**
247
297
 
248
298
  ```json
249
299
  {
@@ -314,6 +364,31 @@ The doctor command checks:
314
364
  | `--json` | Output in JSON format (useful for sharing in bug reports) |
315
365
  | `--skip-update-check` | Skip the npm version check |
316
366
 
367
+ ## Explain (Debug Analysis)
368
+
369
+ Trace how Safety Net analyzes a command step-by-step. Useful for debugging why a command is blocked or allowed, or when developing custom rules.
370
+
371
+ ```bash
372
+ npx cc-safety-net explain "git reset --hard"
373
+ # or with bun
374
+ bunx cc-safety-net explain "git reset --hard"
375
+ ```
376
+
377
+ ### Options
378
+
379
+ | Flag | Description |
380
+ |------|-------------|
381
+ | `--json` | Output analysis as JSON |
382
+ | `--cwd <path>` | Use custom working directory for analysis |
383
+
384
+ ### Examples
385
+
386
+ ```bash
387
+ npx cc-safety-net explain "rm -rf /"
388
+ npx cc-safety-net explain --json "git checkout -- file.txt"
389
+ npx cc-safety-net explain --cwd /tmp "git status"
390
+ ```
391
+
317
392
  ## Commands Blocked
318
393
 
319
394
  | Command Pattern | Why It's Dangerous |
@@ -391,6 +466,11 @@ Beyond the built-in protections, you can define your own blocking rules to enfor
391
466
 
392
467
  > [!TIP]
393
468
  > Use `/set-custom-rules` to create custom rules interactively with natural language.
469
+ >
470
+ > **GitHub Copilot CLI users**: Since Copilot CLI doesn't support custom slash commands, prompt your agent with:
471
+ > ```text
472
+ > run npx cc-safety-net --custom-rules-doc and help me set up custom rules
473
+ > ```
394
474
 
395
475
  ### Quick Example
396
476