cc-safety-net 0.8.1 → 0.9.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 CHANGED
@@ -7,6 +7,7 @@
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
9
  [![Copilot CLI](https://img.shields.io/badge/Copilot%20CLI-4EA5C9)](#github-copilot-cli-installation)
10
+ [![Codex](https://img.shields.io/badge/Codex-white)](#codex-installation)
10
11
  [![License: MIT](https://img.shields.io/badge/License-MIT-red.svg)](https://opensource.org/licenses/MIT)
11
12
 
12
13
  <div align="center">
@@ -28,6 +29,7 @@ A Claude Code plugin that acts as a safety net, catching destructive git and fil
28
29
  - [OpenCode Installation](#opencode-installation)
29
30
  - [Gemini CLI Installation](#gemini-cli-installation)
30
31
  - [GitHub Copilot CLI Installation](#github-copilot-cli-installation)
32
+ - [Codex Installation](#codex-installation)
31
33
  - [Status Line Integration](#status-line-integration)
32
34
  - [Setup via Slash Command](#setup-via-slash-command)
33
35
  - [Manual Setup](#manual-setup)
@@ -48,6 +50,7 @@ A Claude Code plugin that acts as a safety net, catching destructive git and fil
48
50
  - [Advanced Features](#advanced-features)
49
51
  - [Strict Mode](#strict-mode)
50
52
  - [Paranoid Mode](#paranoid-mode)
53
+ - [Worktree Mode](#worktree-mode)
51
54
  - [Shell Wrapper Detection](#shell-wrapper-detection)
52
55
  - [Interpreter One-Liner Detection](#interpreter-one-liner-detection)
53
56
  - [Secret Redaction](#secret-redaction)
@@ -214,25 +217,31 @@ gemini extensions install https://github.com/kenryu42/gemini-safety-net
214
217
 
215
218
  ---
216
219
 
217
- ## Status Line Integration
220
+ ### Codex Installation
218
221
 
219
- Safety Net can display its status in Claude Code's status line, showing whether protection is active and which modes are enabled.
222
+ 1. Enable Codex plugin hooks in `~/.codex/config.toml`:
220
223
 
221
- ### Setup via Slash Command
224
+ ```toml
225
+ [features]
226
+ plugin_hooks = true
227
+ ```
222
228
 
223
- The easiest way to configure the status line is using the built-in slash command:
229
+ 2. Add the marketplace:
224
230
 
225
- ```
226
- /set-statusline
227
- ```
231
+ ```bash
232
+ codex plugin marketplace add kenryu42/cc-marketplace
233
+ ```
234
+
235
+ 3. Start Codex.
236
+ 4. In the TUI, run `/plugins`.
237
+ 5. Use arrow keys to select `[cc-marketplace]`.
238
+ 6. Press Enter to install the plugin.
228
239
 
229
- This interactive command will:
230
- 1. Ask whether you prefer `bunx` or `npx`
231
- 2. Check for existing status line configuration
232
- 3. Offer to replace or pipe with existing commands
233
- 4. Write the configuration to `~/.claude/settings.json`
240
+ ---
234
241
 
235
- ### Manual Setup
242
+ ## Status Line Integration
243
+
244
+ Safety Net can display its status in Claude Code's status line, showing whether protection is active and which modes are enabled.
236
245
 
237
246
  Add the following to your `~/.claude/settings.json`:
238
247
 
@@ -300,6 +309,7 @@ The status line displays different emojis based on the current configuration:
300
309
  | Paranoid mode | `🛡️ Safety Net 👁️` | `SAFETY_NET_PARANOID=1` — all paranoid checks enabled |
301
310
  | Paranoid RM only | `🛡️ Safety Net 🗑️` | `SAFETY_NET_PARANOID_RM=1` — blocks `rm -rf` even within cwd |
302
311
  | Paranoid interpreters only | `🛡️ Safety Net 🐚` | `SAFETY_NET_PARANOID_INTERPRETERS=1` — blocks interpreter one-liners |
312
+ | Worktree mode | `🛡️ Safety Net 🌳` | `SAFETY_NET_WORKTREE=1` — relax local git discards inside linked worktrees |
303
313
  | Strict + Paranoid | `🛡️ Safety Net 🔒👁️` | Both strict and paranoid modes enabled |
304
314
 
305
315
  Multiple mode emojis are combined when multiple environment variables are set.
@@ -398,6 +408,7 @@ npx cc-safety-net explain --cwd /tmp "git status"
398
408
  | rm -rf /var/tmp/... | System temp directory |
399
409
  | rm -rf $TMPDIR/... | User's temp directory |
400
410
  | rm -rf ./... (within cwd) | Limited to current working directory |
411
+ | git restore / checkout -- / reset --hard / clean -f (in linked worktree) | Relaxed only when `SAFETY_NET_WORKTREE=1` and cwd is a linked worktree |
401
412
 
402
413
  ## What Happens When Blocked
403
414
 
@@ -435,9 +446,9 @@ See [CONTRIBUTING.md](CONTRIBUTING.md) for details on how to contribute to this
435
446
  Beyond the built-in protections, you can define your own blocking rules to enforce team conventions or project-specific safety policies.
436
447
 
437
448
  > [!TIP]
438
- > Use `/set-custom-rules` to create custom rules interactively with natural language.
449
+ > Use the `set-custom-rules` skill to create custom rules interactively with natural language.
439
450
  >
440
- > **GitHub Copilot CLI users**: Since Copilot CLI doesn't support custom slash commands, prompt your agent with:
451
+ > If your agent does not support skills, prompt it with:
441
452
  > ```text
442
453
  > run npx cc-safety-net --custom-rules-doc and help me set up custom rules
443
454
  > ```
@@ -585,7 +596,7 @@ Custom rules use **silent fallback** error handling. If your config file is inva
585
596
 
586
597
 
587
598
  > [!IMPORTANT]
588
- > If you add or modify custom rules manually, always validate them with `npx -y cc-safety-net --verify-config` or `/verify-custom-rules` slash command in your coding agent.
599
+ > If you add or modify custom rules manually, always validate them with `npx -y cc-safety-net --verify-config` or the `verify-custom-rules` skill in your coding agent.
589
600
 
590
601
  ### Block Output Format
591
602
 
@@ -631,6 +642,48 @@ Paranoid behavior:
631
642
  - **interpreters**: blocks interpreter one-liners like `python -c`, `node -e`, `ruby -e`,
632
643
  and `perl -e` (these can hide destructive commands).
633
644
 
645
+ ### Worktree Mode
646
+
647
+ Linked git worktrees are designed as disposable, isolated workspaces — discarding
648
+ changes inside one doesn't risk the main working tree. Worktree mode relaxes
649
+ local-discard rules when (and only when) the command is proven to run inside a
650
+ linked worktree:
651
+
652
+ ```bash
653
+ export SAFETY_NET_WORKTREE=1
654
+ ```
655
+
656
+ When enabled, these commands are allowed inside a linked worktree:
657
+
658
+ - `git restore <file>` and `git restore --worktree <file>`
659
+ - `git checkout -- <file>`, `git checkout <ref> -- <file>`, `git checkout --force`,
660
+ and ambiguous multi-positional checkout forms
661
+ - `git switch --discard-changes` and `git switch -f / --force`
662
+ - `git reset --hard` and `git reset --merge`
663
+ - `git clean -f` (and combined short flags like `-fd`)
664
+
665
+ These remain blocked even in linked worktrees because they reach beyond the
666
+ local working tree:
667
+
668
+ - `git push --force` (affects remote)
669
+ - `git branch -D` (affects shared refs)
670
+ - `git stash drop` / `git stash clear` (stash is shared across worktrees)
671
+ - `git worktree remove --force` (could delete another worktree)
672
+
673
+ Detection is fail-closed and mostly filesystem-based:
674
+
675
+ - A linked worktree is identified by a `.git` *file* containing `gitdir:` whose
676
+ resolved git directory contains a `commondir` file. Main worktrees and
677
+ submodules don't satisfy this and are not relaxed.
678
+ - The cwd walk uses `realpath` so symlinked paths resolve correctly.
679
+ - `git -C <path>` (including chained `-C` and attached `-Cpath`) is honored;
680
+ unresolved targets keep the command blocked.
681
+ - Relaxation is disabled if cwd becomes unknown (e.g., after `cd`/`pushd`),
682
+ if `--git-dir` / `--work-tree` is passed, or if `GIT_DIR` / `GIT_WORK_TREE`
683
+ / `GIT_COMMON_DIR` is set in the environment.
684
+ - Git may be invoked from a trusted system path to inspect effective config that
685
+ could make submodule operations recursive.
686
+
634
687
  ### Shell Wrapper Detection
635
688
 
636
689
  The guard recursively analyzes commands wrapped in shells: