@cratis/pi 7.131.0 → 7.131.2

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 (18) hide show
  1. package/package/corpus/hooks/README.md +6 -4
  2. package/package/corpus/hooks/scripts/cratis-guard-secrets.sh +790 -61
  3. package/package/corpus/hooks/scripts/cratis-guard-store-mutations.sh +89 -28
  4. package/package/corpus/hooks/scripts/cratis-guard-writes.sh +18 -11
  5. package/package/corpus/hooks/scripts/hook-lib.sh +17 -2
  6. package/package/corpus/skills/cratis-screenplay-automations-and-translations/SKILL.md +1 -0
  7. package/package/corpus/skills/cratis-screenplay-automations-and-translations/references/public-events-and-direction.md +3 -0
  8. package/package/corpus/skills/cratis-screenplay-automations-and-translations/references/realization-and-gap-fill.md +2 -1
  9. package/package/corpus/skills/cratis-screenplay-captures-and-reactions/SKILL.md +2 -2
  10. package/package/corpus/skills/cratis-screenplay-model-review/references/report-template.md +1 -1
  11. package/package/corpus/skills/cratis-screenplay-read-surface/references/screen-patterns.md +5 -0
  12. package/package/corpus/skills/cratis-screenplay-specifications/references/actions-beyond-commands.md +1 -1
  13. package/package/corpus/skills/cratis-screenplay-specifications/references/source-notes.md +2 -1
  14. package/package/corpus/skills/cratis-screenplay-specifications/references/vocabulary.md +3 -2
  15. package/package/corpus/skills/cratis-screenplay-toolchain/references/diagnostics.md +3 -1
  16. package/package/corpus/skills/cratis-screenplay-toolchain/references/executable-subset.md +2 -2
  17. package/package/corpus/skills/cratis-screenplay-toolchain/references/traps.md +3 -3
  18. package/package.json +1 -1
@@ -11,7 +11,7 @@ Three layers:
11
11
  | Pattern pass | `PostToolUse` on a write | `scripts/cratis-pattern-scan.sh` | zero tokens until a match | appends a one-line reminder to context, never blocks |
12
12
  | Hard block | `PreToolUse` on a write | `scripts/cratis-guard-writes.sh` | zero | exits **2** — the write does not happen |
13
13
  | Hard block | `PreToolUse` on `Bash` | `scripts/cratis-guard-store-mutations.sh` | zero; parses only commands that mention `cratis` | exits **2** — the store-changing `cratis chronicle` command does not run |
14
- | Hard block | `PreToolUse` on `Bash` | `scripts/cratis-guard-secrets.sh` | zero; parses only commands that mention a credential-bearing tool or file | exits **2** — a command that prints credentials (full `kubectl` specs and secrets, `env`/`printenv`, `docker inspect`, secret-manager reads, `cratis config get --show-secret`, `.env`/kubeconfig/key files; also behind `/usr/bin/env`, `command`, attached options such as `-ePATTERN`, a bare `{.}` projection) does not run unless it projects a field; piped shells and recursive searches with no named file stay uncovered; see [`secrets.md`](../rules/secrets.md) |
14
+ | Hard block | `PreToolUse` on `Bash` | `scripts/cratis-guard-secrets.sh` | zero; parses only commands that mention a credential-bearing tool or file | exits **2** — the guard is a **best-effort, defense-in-depth text filter, NOT a sandbox**: it refuses some harmless commands rather than model the whole shell. Real protection requires **OS-level sandboxing or file permissions**. A command is *tainted* when a protected file-name stem appears in any token, including option values, in any letter case, after quotes, backslashes and line continuations are removed. Only search regex text is exempt: `-e`/`--regexp` values, or the first operand when neither `-e` nor `-f` is present. `-f`/`--file` values and all other operands are paths, not exempt patterns. The stems are `.env`, `.pem`, `.p12`, `.pfx`, `id_rsa`, `id_ed25519`, `id_ecdsa`, `id_dsa`, `.netrc`, `.npmrc`, `.pgpass`, `.pypirc`, `.git-credentials`, `.kube/`, `kubeconfig`, `credentials`, `.docker/`, `/environ` and `run/secrets`. Stars, question marks, bracket expressions and grouped pathname patterns count as the characters they can match when the pattern retains at least two literal stem characters. A command is also tainted when an assignment value or any expanded word can contain a stem. A tainted command runs only when it is a single simple command with every word literal: `cat`, `head`, `tail`, `less`, `more`, `wc`, `grep`, `egrep`, `fgrep` or `rg` of paths that are not protected (such as `cat .env.example`); `test` of literal paths; or `cp SOURCE DEST` with no options and a source that is not protected (such as `cp .env.example .env`). A single simple `ls` or `stat` may also take glob operands, but not variables, substitutions, wrappers or other shell structure. Tainted searches cannot recurse, search a directory with `rg`, omit `rg` path operands, or use value-taking options other than `-e`/`--regexp`. Every other tainted command is refused, including variables, command substitution, globs for content readers, loops, conditionals, pipes, redirections, here-strings, here-documents, wrappers, `bash -c`, `eval` and transfer tools. Shell-option changes are checked even without a protected stem: modifying `shopt`, `setopt`, `unsetopt` and `emulate` are refused. `extglob` is refused as an option, not merely as text. Shell invocation `-o`/`-O` options, including clustered flags, must name a supported option. Expanded `set` arguments are refused. Only `set` flags `e`, `u`, `x`, `f`, `v`, `E`, `T` and named options `errexit`, `nounset`, `pipefail`, `xtrace`, `verbose`, `noglob`, `errtrace`, `functrace` (including their `+` forms) are supported. The message names the stem: run the read on its own with literal paths, or put long text that mentions the name in a file. Commands without a stem keep the full analysis. In that analysis a variable can hold any value the command assigns to it anywhere, a positional parameter or an unquoted expansion with glob or space characters is unknown, and an unknown file operand is refused. Residual classes include **shell glob grammar across bash and zsh, option toggles, option arity and quote concatenation**, as well as runtime-generated names, inherited state, filesystem indirection, user-defined commands, external programs and scripts, and searches without a named protected path. These classes are not modeled exhaustively. Use OS-level sandboxing or file permissions, harness isolation and least privilege as the primary boundary. Token files and key-extension globs (`*.key`, `*.jks`) are refused only through the listed reader, input, `dd` and transfer commands; see [`secrets.md`](../rules/secrets.md) |
15
15
  | Hard block | `PreToolUse` on `Bash` | `scripts/cratis-guard-pr-body.sh` | fetches shared rules only for `gh pr create/edit` | exits **2** for inline bodies, invalid notes or conflicting release labels; warns and allows when offline with no cache |
16
16
  | Cleanup of delivered work | `PostToolUse` on `Bash` (`gh pr merge`, `git pull/merge/worktree`) and `SessionStart` (Pi: `tool_result` and `session_start`) | `scripts/cratis-cleanup-worktrees.sh --hook` | zero when the command is unrelated | never blocks; removes delivered worktrees and branches, reports what it kept |
17
17
  | Quality gate (Claude) | `Stop` | `scripts/cratis-quality-gate.sh` | one build/test run, only when relevant files changed | exits **2** — the turn does not end |
@@ -95,7 +95,7 @@ This is a guardrail, **not absolute enforcement**. Node, Bash and Git are requir
95
95
  launch the adapter; native callback failure, crash, timeout, or malformed-response behavior
96
96
  can fail open before a supported denial is received. Other local hook configurations and
97
97
  specialized tool paths are outside this adapter's control. The existing scripts retain
98
- their own deliberate allowances and limits: missing `jq` skips the store guard; PR checks
98
+ their own deliberate allowances and limits: missing `jq` makes the store, secret and write guards refuse every call; PR checks
99
99
  can allow with an unchecked/offline warning; command-text parsing cannot see all indirect
100
100
  execution. Inherited `CRATIS_HOOKS_ALLOW_STORE_MUTATIONS=1` and existing script configuration
101
101
  are preserved. An adapter exit **0** is not proof that every underlying check ran.
@@ -725,8 +725,10 @@ Each is an explicit, auditable opt-out — none of them is a default.
725
725
  (macOS system bash) — no `mapfile`, no associative arrays, no GNU-only flags, `LC_ALL=C` on
726
726
  every sort and compare.
727
727
  - **Gate commands are an argv array**, executed directly. They never pass through a shell.
728
- - **`jq` is the dependency for the write, store-mutation, pattern and quality hooks.** They
729
- degrade to a silent no-op when it is missing — a hook must never break a session. The
728
+ - **`jq` is the dependency for the write, store-mutation, secret, pattern and quality hooks.** The
729
+ write, store-mutation and secret guards refuse every call while it is missing (exit 2, with the
730
+ reason and the install hint on stderr); the pattern and quality hooks degrade to a silent no-op,
731
+ because those must never break a session. The
730
732
  PR-body hook uses Node instead, and the checker uses Git and `gh` as described above.
731
733
  - **Fail safe.** Malformed config, empty stdin, a missing file, a binary file, a file over 2 MB:
732
734
  all exit 0 silently. The one deliberate exception is the store-mutation guard's command lists: