@kaynooo/cli-guard 0.14.0 → 0.14.3
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 +5 -5
- package/dist/cli.js +874 -385
- package/package.json +11 -11
package/README.md
CHANGED
|
@@ -13,10 +13,10 @@ guard check --json --cwd "$PWD" - < command.txt
|
|
|
13
13
|
| Rule | Refuses | Lives in |
|
|
14
14
|
| --- | --- | --- |
|
|
15
15
|
| `remote` | `ssh`, `scp`, `sftp`, `mosh`, `rsync` to a host, `DOCKER_HOST=ssh://`, `docker -H ssh://` | `src/remote.ts` |
|
|
16
|
-
| `git` | `git stash` (pointing at `proof`, `base`, a commit first or `git worktree add`), `git add -A`/`.`/`-u`, `git commit -a` in any flag cluster, `git push` the user did not ask for, `git push --tags` without `--atomic` | `src/git.ts` |
|
|
17
|
-
| `destructive` | `git reset --hard`, discarding the whole tree (`checkout -- .`, `checkout -f`, `restore .`, `switch -f`), `git clean -f`, a force push (`--force`, `-f`, `--mirror`, `+refspec`; `--force-with-lease` passes), `git branch -D`, a `git rebase` (`--continue` and `--abort` pass), `filter-branch`, `rm -r` on `/`, `~`, `$HOME
|
|
16
|
+
| `git` | `git stash` (pointing at `base proof`, `base`, a commit first or `git worktree add`), `git add -A`/`.`/`-u`, `git commit -a` in any flag cluster, `git push` the user did not ask for, `git push --tags` without `--atomic` | `src/git.ts` |
|
|
17
|
+
| `destructive` | `git reset --hard`, discarding the whole tree (`checkout -- .`, `checkout -f`, `restore .`, `switch -f`), `git clean -f`, a force push (`--force`, `-f`, `--mirror`, `+refspec`; `--force-with-lease` passes), `git branch -D`, a `git rebase` (`--continue` and `--abort` pass), `filter-branch`, `rm -r` on `/`, `~`, `$HOME` or the home by its path, `.`, `..`, `*`, a top-level directory or a system folder's child (`/usr/lib`, `/var/lib`), a download piped into a shell (`curl ... \| sh`, `bash <(curl ...)`), `dl --exec --yes` on a script no `--sha256` or `--sums` pins; each refusal names the safe route: a commit with `gc` first, `base`, `git worktree add`, `--force-with-lease`, `dl <url>` then `dl <url> --exec --sha256 <sha>` | `src/destructive.ts` |
|
|
18
18
|
| `commit` | a commit message breaking the format: no Conventional Commit title, a trailer, a body over two lines, a bullet list, a hard wrap; `-m`, `-F <file>` and `-F -` with a heredoc are read; the refusal spells the rule out and points at `gc` | `src/commit.ts`, the validator in `@kaynooo/cli-git` |
|
|
19
|
-
| `sql` | a SQL client, console or dump tool fed a write (INSERT, UPDATE, DELETE, DDL, migrations, fixtures) outside a test database | `@kaynooo/cli-db` (`src/clients.ts`, `src/guard.ts`) |
|
|
19
|
+
| `sql` | a SQL client, console or dump tool fed a write (INSERT, UPDATE, DELETE, DDL, migrations, fixtures) outside a test database, the database being the one the client connects to (`-d` or a conninfo `dbname` over `PGDATABASE`), and on a test database a write naming another one (a qualified name, `USE`, `CREATE` or `DROP DATABASE`) | `@kaynooo/cli-db` (`src/clients.ts`, `src/guard.ts`) |
|
|
20
20
|
| `env` | a command reading, writing or printing an env file or the whole environment; `guard path` refuses a file tool opening one | `@kaynooo/cli-env` (`src/guard.ts`) |
|
|
21
21
|
| `package-manager` | an install with another manager than the nearest lockfile pins, when it cannot be translated | `@kaynooo/cli-pkg` (`src/pin.ts`) |
|
|
22
22
|
| `pkg` | on the hook only, an install `pkg check` refuses or cannot check, pointing at `pkg <name>` before adding it | `@kaynooo/cli-pkg` |
|
|
@@ -39,7 +39,7 @@ Every rule reads the command with one shell parser (`packages/kit/src/shell.ts`)
|
|
|
39
39
|
|
|
40
40
|
`guard hook <event>` speaks Claude Code's hook protocol, the event JSON on stdin and the reply JSON on stdout; the `cli-hooks` plugin at the repo root registers it (see the root README).
|
|
41
41
|
|
|
42
|
-
- `pre-tool-use`: a Bash call breaking a rule is denied with the routes, an install with the wrong manager with the command to run instead, an install `pkg` refuses with its report; a Read, Edit
|
|
42
|
+
- `pre-tool-use`: a Bash call breaking a rule is denied with the routes, an install with the wrong manager with the command to run instead, an install `pkg` refuses (or fails to check) with its report; a file tool (Read, Edit, MultiEdit, Write, NotebookEdit, Grep, Glob) reaching an env file is denied.
|
|
43
43
|
- `user-prompt-submit`: a prompt naming a push lets `git push` through until the next prompt; the state sits in `$XDG_STATE_HOME/guard/push-asked/<session>`, an empty file left behind by each session that ended on such a prompt. Claude Code sends no origin with the event, so a prompt it sends itself (a notification, a peer session's message) counts too, where the dotfiles mod counts only what the user typed.
|
|
44
|
-
- `session-start`: the installed
|
|
44
|
+
- `session-start`: the installed `@kaynooo/cli-*` bins, one line each, handed to Claude as context.
|
|
45
45
|
- Nothing printed lets the call go ahead. Any failure exits 1, which Claude Code reports without blocking, never 2, which would block.
|