cc-safety-net 0.7.1 → 0.8.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 +64 -11
- package/dist/bin/cc-safety-net.js +830 -54
- package/dist/bin/doctor/hooks.d.ts +1 -0
- package/dist/bin/doctor/types.d.ts +4 -1
- package/dist/core/shell.d.ts +3 -1
- package/dist/index.js +585 -44
- package/package.json +4 -2
package/README.md
CHANGED
|
@@ -203,22 +203,29 @@ Install the cc-safety-net plugin in `~/.config/opencode/opencode.json` (or `.jso
|
|
|
203
203
|
gemini extensions install https://github.com/kenryu42/gemini-safety-net
|
|
204
204
|
```
|
|
205
205
|
|
|
206
|
-
> [!IMPORTANT]
|
|
207
|
-
> You need to set the following settings in `.gemini/settings.json` to enable hooks:
|
|
208
|
-
> ```json
|
|
209
|
-
> {
|
|
210
|
-
> "tools": {
|
|
211
|
-
> "enableHooks": true
|
|
212
|
-
> }
|
|
213
|
-
> }
|
|
214
|
-
> ```
|
|
215
|
-
|
|
216
206
|
---
|
|
217
207
|
|
|
218
208
|
### GitHub Copilot CLI Installation
|
|
219
209
|
|
|
220
210
|
Safety Net supports GitHub Copilot CLI via its [hooks system](https://docs.github.com/en/copilot/concepts/agents/coding-agent/about-hooks).
|
|
221
211
|
|
|
212
|
+
> [!NOTE]
|
|
213
|
+
> Copilot CLI currently supports two hook configuration styles:
|
|
214
|
+
>
|
|
215
|
+
> - Hook files:
|
|
216
|
+
> - repository: `.github/hooks/*.json`
|
|
217
|
+
> - user: `~/.copilot/hooks/*.json` on Copilot CLI `0.0.422+`
|
|
218
|
+
> - Inline `hooks` inside Copilot config files on Copilot CLI `1.0.8+`:
|
|
219
|
+
> - user: `~/.copilot/config.json`
|
|
220
|
+
> - repository: `.github/copilot/settings.json`
|
|
221
|
+
> - local override: `.github/copilot/settings.local.json`
|
|
222
|
+
>
|
|
223
|
+
> Copilot settings cascade from user -> repository -> local (later files override earlier ones, so local overrides repository overrides user). `disableAllHooks: true` disables both repo-level and user-level hooks. If you use `COPILOT_HOME`, replace `~/.copilot` with that directory.
|
|
224
|
+
|
|
225
|
+
#### Option A: Hook Files
|
|
226
|
+
|
|
227
|
+
This is the classic hook-file format. It still works, and it is the easiest shared setup for a repository.
|
|
228
|
+
|
|
222
229
|
1. **Create the hooks directory** in your repository:
|
|
223
230
|
|
|
224
231
|
```bash
|
|
@@ -243,7 +250,52 @@ Safety Net supports GitHub Copilot CLI via its [hooks system](https://docs.githu
|
|
|
243
250
|
}
|
|
244
251
|
```
|
|
245
252
|
|
|
246
|
-
|
|
253
|
+
3. **Restart Copilot CLI** — hooks are loaded at session start.
|
|
254
|
+
|
|
255
|
+
The hook will intercept shell commands and block destructive operations before they execute.
|
|
256
|
+
|
|
257
|
+
To install the same hook globally for your user account on Copilot CLI `0.0.422+`, place the same JSON file in:
|
|
258
|
+
|
|
259
|
+
- `~/.copilot/hooks/safety-net.json`
|
|
260
|
+
|
|
261
|
+
#### Option B: Inline Hooks In Copilot Settings
|
|
262
|
+
|
|
263
|
+
On Copilot CLI `1.0.8+`, you can define the same hook inline in Copilot settings files instead of a separate `.json` file under `.github/hooks` or `~/.copilot/hooks`.
|
|
264
|
+
|
|
265
|
+
```json
|
|
266
|
+
{
|
|
267
|
+
"hooks": {
|
|
268
|
+
"preToolUse": [
|
|
269
|
+
{
|
|
270
|
+
"type": "command",
|
|
271
|
+
"bash": "npx -y cc-safety-net --copilot-cli",
|
|
272
|
+
"cwd": ".",
|
|
273
|
+
"timeoutSec": 15
|
|
274
|
+
}
|
|
275
|
+
]
|
|
276
|
+
}
|
|
277
|
+
}
|
|
278
|
+
```
|
|
279
|
+
|
|
280
|
+
Use that schema in one of these files:
|
|
281
|
+
|
|
282
|
+
- `~/.copilot/config.json`
|
|
283
|
+
- `.github/copilot/settings.json`
|
|
284
|
+
- `.github/copilot/settings.local.json`
|
|
285
|
+
|
|
286
|
+
Recommended usage:
|
|
287
|
+
|
|
288
|
+
- Use `~/.copilot/config.json` for your personal default across repositories.
|
|
289
|
+
- Use `.github/copilot/settings.json` for a committed repository-wide setup.
|
|
290
|
+
- Use `.github/copilot/settings.local.json` for personal repo-specific overrides, and add it to `.gitignore`.
|
|
291
|
+
|
|
292
|
+
If you need to turn hooks off explicitly, set:
|
|
293
|
+
|
|
294
|
+
```json
|
|
295
|
+
{
|
|
296
|
+
"disableAllHooks": true
|
|
297
|
+
}
|
|
298
|
+
```
|
|
247
299
|
|
|
248
300
|
## Status Line Integration
|
|
249
301
|
|
|
@@ -395,6 +447,7 @@ npx cc-safety-net explain --cwd /tmp "git status"
|
|
|
395
447
|
|-----------------|-------------------|
|
|
396
448
|
| git checkout -- files | Discards uncommitted changes permanently |
|
|
397
449
|
| git checkout \<ref\> -- \<path\> | Overwrites working tree with ref version |
|
|
450
|
+
| git checkout \<ref\> \<path\> | May overwrite working tree when Git disambiguates ref vs pathspec |
|
|
398
451
|
| git restore files | Discards uncommitted changes |
|
|
399
452
|
| git restore --worktree | Explicitly discards working tree changes |
|
|
400
453
|
| git reset --hard | Destroys all uncommitted changes |
|