@cratis/pi 7.188.2 → 7.188.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.
@@ -5,10 +5,9 @@ applyTo: "**/*"
5
5
 
6
6
  # Operational safety
7
7
 
8
- Operation-specific invariants that hold before any skill is chosen or file is open. Authority comes
9
- from [`capability-is-not-authority.md`](./capability-is-not-authority.instructions.md); credentials and data
10
- channels from [`secrets.md`](./secrets.instructions.md). All lines are **[contract]** (see
11
- [`general.md`](../../../rules/general.md)). They are policy, not a sandbox: none is mechanically enforced.
8
+ Before skills/files: [authority](./capability-is-not-authority.instructions.md), [credentials/data channels](./secrets.instructions.md).
9
+ All are **[contract]** ([general.md](../../../rules/general.md)): policy, not enforcement or a sandbox.
10
+ [Inline guards](../../../hooks/README.md#inline-interpreter-policy) are not sandboxes.
12
11
 
13
12
  ## Screenplay models and rendering
14
13
 
@@ -19,4 +19,4 @@ paths:
19
19
  - Use a C# file-based app (`dotnet run --file tool.cs`, `#:package` pinned) when the script needs .NET or Cratis libraries or shares types with the product. Do not use one in hooks or on per-call hot paths.
20
20
  - Hooks under `.cratis/ai/hooks` are POSIX sh compatible with bash 3.2, or Node. Read stdin with `IFS= read -r -d '' x || true`, never `$(</dev/stdin)`.
21
21
  - Do not add Python scripts or `python3` workflow steps to Cratis repositories unless the project itself is Python (for example the Chronicle Python client). Existing Python scripts are ported to Node opportunistically: when you substantially change one, port it in the same PR. There is no bulk port.
22
- - Agents: edit files with the edit/write tools, query JSON with `gh --jq`/`jq`, and use `node -e` or `node --input-type=module - <<'EOF'` for ad-hoc logic. Never `python3 -c`, and never rewrite files by script.
22
+ - Agents: edit files with the edit/write tools, query JSON with `gh --jq`/`jq`, and use `node -e` or `node --input-type=module - <<'EOF'` for trigger-free ad-hoc logic. Never `python3 -c`, and never rewrite files by script.
@@ -23,6 +23,7 @@ they also hold without it.
23
23
  - **[contract] Command-text checks cannot see** shell-piped code (`… | sh`, `bash -c "$(…)"`),
24
24
  recursive searches without filenames (`grep -r PASSWORD .`), or paths hidden in variables,
25
25
  aliases or scripts. The rules still apply; output redaction is the backstop.
26
+ - **[contract] Inline refusals:** Read exact non-credential files.
26
27
  - **[contract] After a guard block, narrowing to literal non-credential files is supported remediation,
27
28
  not a workaround.** Follow `Use instead`; never disguise the same secret read.
28
29
 
@@ -19,6 +19,29 @@ Three layers:
19
19
  | Quality gate (Pi) | explicit `cratis_quality_gate` tool | same script | only at a requested verification checkpoint | error on failure; no turn-end hook |
20
20
  | Handoff checker | not wired: run by the skill | `scripts/cratis-check-handoff.mjs` | local files and git only | errors fail; warnings are advisory unless `--strict` |
21
21
 
22
+ ### Inline interpreter policy
23
+
24
+ Inline interpreter argv programs (`node -e`/`--eval`/`-p`/`--print`, Python `-c`, Ruby/Perl/Lua/
25
+ osascript `-e`, Perl `-E`, PHP `-r`, Deno `eval`, Bun/tsx/ts-node eval/print, PowerShell
26
+ `-Command`/`-c`, and shell `-c` including `-lc`) and executable interpreter heredocs share a
27
+ boundary-aware protected-file vocabulary. When a parsed invocation and a vocabulary hit occur anywhere
28
+ in the Bash call, the guard refuses the call, even for comments, output strings or aliases of read APIs.
29
+ Wrappers and absolute executable paths are recognized; script operands and words merely mentioning an
30
+ interpreter are not inline invocations. Python `-m <module>` and Node `--test` are file-running modes,
31
+ not inline programs; eval flags and executable heredocs still receive the inline checks. Unknown startup
32
+ options fail closed when vocabulary is present.
33
+ The vocabulary combines the protected file stems above with `.aws/`, `credentials.json`, `secrets.yaml`
34
+ and `secrets.yml`; `credentials` needs word boundaries and `.pem` must not continue into an identifier.
35
+ Thus `withCredentials`, `RecordingCredentials` and `.pembroke` are allowed in heredocs, while the bare
36
+ word in Python `from google.oauth2 import credentials` is refused. File-shaped key extensions count,
37
+ but `Object.keys`, JSON, `process.env.NAME`, bare key properties and `.env.example` are not new triggers.
38
+ Existing argv taint refusals remain in force.
39
+ Quoted heredoc delimiters disable shell expansion, not interpreter execution. Plain-consumer heredocs
40
+ remain data. Use the read (Claude: Read) tool for an exact non-credential file after this refusal; splitting
41
+ or disguising the same interpreter read is not remediation. This best-effort text filter is **not a sandbox**:
42
+ encoded or split paths, external helper scripts and generated stdin can evade text analysis. OS-level
43
+ sandboxing or file permissions are the protection boundary; literal shell reads remain supported.
44
+
22
45
  For false positives, a literal-prefix trailing `*`, including literal directory components, can be
23
46
  resolved in a known, readable cwd and parent directory. A single reader may stand alone or appear in
24
47
  an `&&` chain of literal read-only Git metadata commands, optionally after a literal leading `cd`.
@@ -15,7 +15,10 @@
15
15
  # aliases, functions, script files and recursive searches without named files remain outside its text analysis.
16
16
  # Allowlisted safe shapes (each commented where it is implemented, each with specs): source-file names classified by
17
17
  # real secret patterns, a leading plain NAME=VALUE, quoted commit and pull request text, literal here-document
18
- # text, and link-target checks. Anything else naming a protected file is refused.
18
+ # text for plain consumers, and link-target checks. Inline interpreter programs and executable heredocs share
19
+ # boundary-aware protected file vocabulary. This text filter is not a sandbox: encoded paths, external scripts
20
+ # and arbitrarily assembled names need OS-level protection. See ../README.md#inline-interpreter-policy.
21
+ # Anything else naming a protected file is refused.
19
22
  #
20
23
  # Escape hatch for a human who authorized the read — set in the environment the agent harness was started
21
24
  # from, never inside the command (an assignment in the command is ignored):
@@ -806,15 +809,42 @@ function interpreter_hit(body, t, k, stem, from, p, before, after, kind) {
806
809
  before = (p > 1) ? substr(t, p - 1, 1) : ""
807
810
  after = substr(t, p + length(stem), 1)
808
811
  kind = INTERP_KIND[k]
812
+ # Template filenames and bare properties are not protected file vocabulary. Existing argv
813
+ # taint checks remain independent; process.env.NAME and data.key in heredocs are not reads.
814
+ if (stem == ".env" && substr(t, p + length(stem)) ~ /^\.(example|sample|template|dist|defaults)([^a-z0-9_]|$)/) { from = p + 1; continue }
809
815
  if (kind == "env" && before !~ /[]a-z0-9_)]/ && after !~ /[a-z0-9_]/) return stem
810
816
  if (kind == "ext" && (after == "\"" || after == "\047" || after == "`")) return stem
811
- if (kind == "name" && after !~ /[a-z0-9_]/) return stem
817
+ if (kind == "word" && before !~ /[a-z0-9_]/ && after !~ /[a-z0-9_]/) return stem
818
+ if (kind == "path" || kind ~ /^(name|suffix)$/ && after !~ /[a-z0-9_]/) return stem
812
819
  from = p + 1
813
820
  }
814
821
  }
815
822
  return ""
816
823
  }
817
- function read_heredocs(s, i, n, h, e, line, cmp, body, hit) {
824
+ function interpreter_name(b) {
825
+ return b ~ /^(node(js)?|deno|bun|python[0-9.]*|ruby|perl|php|lua|osascript|pwsh|powershell|dotnet|java|jshell|rscript|tclsh|julia|groovy|tsx|ts-node|bash|sh|zsh|dash|ksh)$/
826
+ }
827
+ # Inspect only the executable selected after shell wrappers; later script operands are data, not flags.
828
+ # Unknown startup switches fail closed when vocabulary is present rather than guessing their arity.
829
+ function interpreter_invocation(A, s, n, b, k, option) {
830
+ if (nheredoc > 0) { hd_interp = 1; INLINE = 1 }
831
+ if (b ~ /^(bash|sh|zsh|dash|ksh)$/) return
832
+ for (k = s + 1; k <= n; k++) {
833
+ option = tolower(A[k])
834
+ if (option == "--" || b ~ /^python/ && option ~ /^-m/) return
835
+ if (b ~ /^node(js)?$/ && option == "--test") continue
836
+ if (b == "deno" && option == "eval") { INLINE = 1; return }
837
+ if (b ~ /^(pwsh|powershell)$/ && option ~ /^-(c|command)$/) { INLINE = 1; return }
838
+ if (b ~ /^python/ && option ~ /^-c/ || b == "php" && option ~ /^-r/ ||
839
+ b ~ /^(node(js)?|bun|ruby|perl|lua|osascript|tsx|ts-node)$/ && option ~ /^-[ep]/ ||
840
+ b ~ /^(node(js)?|bun|tsx|ts-node)$/ && option ~ /^--(eval|print)(=|$)/) { INLINE = 1; return }
841
+ if (option !~ /^-/ || option == "-") return
842
+ if (option ~ /^--(input-type|require|loader|import)$/ || b ~ /^(node(js)?|bun|tsx|ts-node)$/ && option == "-r") { k++; continue }
843
+ if (option ~ /^--(input-type|require|loader|import)=/ || option ~ /^--(no-config|no-warnings|quiet)$/) continue
844
+ INLINE = 1; return
845
+ }
846
+ }
847
+ function read_heredocs(s, i, n, h, e, line, cmp, body) {
818
848
  for (h = 1; h <= nheredoc; h++) {
819
849
  body = ""
820
850
  while (i <= n) {
@@ -825,11 +855,9 @@ function read_heredocs(s, i, n, h, e, line, cmp, body, hit) {
825
855
  if (cmp == HD[h]) break
826
856
  body = body line "\n"
827
857
  }
858
+ if (hd_interp && interpreter_hit(body) != "") INLINE_HIT = 1
828
859
  if (hd_shell) enqueue(body)
829
- else {
830
- if (!HDQ[h]) heredoc_substitutions(body)
831
- if (hd_interp && (hit = interpreter_hit(body)) != "") { complex = 1; if (TAINT == "") TAINT = hit }
832
- }
860
+ else if (!HDQ[h]) heredoc_substitutions(body)
833
861
  }
834
862
  nheredoc = 0; hd_shell = 0; hd_interp = 0
835
863
  return i
@@ -1609,7 +1637,7 @@ function shell_invocation(A, s, n, k, j, flags, c, script) {
1609
1637
  if (j != length(flags) || expands(A[k + 1], mask_of(A, k + 1)) || !allowed_option(A[k + 1])) config_report()
1610
1638
  k++; break
1611
1639
  }
1612
- if (script) { enqueue(A[k + 1]); return }
1640
+ if (script) { INLINE = 1; enqueue(A[k + 1]); return }
1613
1641
  }
1614
1642
  if (nheredoc > 0) hd_shell = 1
1615
1643
  }
@@ -2102,6 +2130,8 @@ function git_content(A, s, n, subcommand, k, w, kind, ended, pathspec) {
2102
2130
  }
2103
2131
  }
2104
2132
  function analyze(A, s, n, w, b, k, names, p, config, get, show, first) {
2133
+ # Preserve decoded evidence before search-pattern, Git-path and source/template exemptions.
2134
+ for (k = s; k <= n; k++) if (interpreter_hit(A[k]) != "") INLINE_HIT = 1
2105
2135
  nrt = 0; nwrap = 0; delete REDIRECT_TOKENS; delete ROFF; first = s
2106
2136
  while (s <= n) {
2107
2137
  w = A[s]; b = base(w)
@@ -2139,7 +2169,7 @@ function analyze(A, s, n, w, b, k, names, p, config, get, show, first) {
2139
2169
  }
2140
2170
  if (expands(A[s], mask_of(A, s))) return dyn_command(A, s, n)
2141
2171
  b = base(A[s])
2142
- if (nheredoc > 0 && b ~ /^(node|nodejs|deno|bun|python[0-9.]*|ruby|perl|php|lua|osascript|pwsh|powershell|dotnet|java|jshell|rscript|tclsh|julia|groovy|tsx|ts-node)$/) hd_interp = 1
2172
+ if (interpreter_name(b)) interpreter_invocation(A, s, n, b)
2143
2173
  if (b == "cd" || b == "pushd" || b == "popd") { change_directory(A, s, n, b); return }
2144
2174
  check_bulk_roots(A, s, n, b)
2145
2175
  if (A[s] == "git") git_content(A, s, n)
@@ -2233,18 +2263,20 @@ BEGIN {
2233
2263
  }
2234
2264
  nextension = split("pem key p12 pfx jks keystore kdbx kubeconfig env", EXT, " ")
2235
2265
  ndispatch = split("cat tac nl less more head tail bat batcat strings xxd od hexdump cut sort uniq base64 wc dd cp mv ln rsync scp tar zip shopt set setopt unsetopt emulate grep egrep fgrep rg ag sed awk gawk mawk nawk busybox jq yq gojq jaq kubectl oc docker podman docker-compose gh vault aws az gcloud pulumi cratis printenv export declare typeset env bash sh zsh dash ksh eval", DN, " ")
2236
- ninterp = split(".env|env .env.local|name .env.production|name .envrc|name id_rsa|name id_ed25519|name id_ecdsa|name id_dsa|name .netrc|name .npmrc|name .pgpass|name .pypirc|name .git-credentials|name kubeconfig|name .kube/|name .aws/|name .docker/config.json|name credentials.json|name secrets.yaml|name secrets.yml|name .pem|ext .key|ext .p12|ext .pfx|ext .jks|ext .keystore|ext .kdbx|ext", INTERP_SPEC, " ")
2266
+ ninterp = split(".env|env .env.local|name .env.production|name .envrc|name id_rsa|name id_ed25519|name id_ecdsa|name id_dsa|name .netrc|name .npmrc|name .pgpass|name .pypirc|name .git-credentials|name kubeconfig|name .kube/|path .aws/|path .docker/|path credentials|word credential|word secrets.yaml|name secrets.yml|name /environ|name run/secrets|path .pem|suffix .key|ext .p12|ext .pfx|ext .jks|ext .keystore|ext .kdbx|ext", INTERP_SPEC, " ")
2237
2267
  for (i = 1; i <= ninterp; i++) { split(INTERP_SPEC[i], L, "|"); INTERP[i] = L[1]; INTERP_KIND[i] = L[2] }
2238
2268
  nstem = split(".env .pem .key .p12 .pfx .jks .keystore .kdbx id_rsa id_ed25519 id_ecdsa id_dsa .netrc .npmrc .pgpass .pypirc .git-credentials .kube/ kubeconfig credentials credential secrets.yaml secrets.yml .docker/ /environ run/secrets", STEM, " ")
2239
2269
  CMD = ENVIRON["GS_COMMAND"]
2240
2270
  for (pass = 1; pass <= 2; pass++) {
2241
2271
  delete queue; delete QUEUE_DIR; delete QUEUE_COUNT; queued = 0; qi = 0; delete seen; reports = ""
2242
2272
  delete CWD; ncd = 1; nwrap = 0; CWD[1] = ENVIRON["GS_CWD_FALLBACK"]; effective_dir = CWD[1]
2243
- nheredoc = 0; hd_shell = 0; hd_interp = 0; commands = 0; complex = 0; simple_ok = 1; TAINT = ""
2273
+ nheredoc = 0; hd_shell = 0; hd_interp = 0; INLINE = 0; INLINE_HIT = interpreter_hit(CMD) != ""; commands = 0; complex = 0; simple_ok = 1; TAINT = ""
2244
2274
  enqueue(CMD)
2245
2275
  while (qi < queued) { qi++; tokenize(queue[qi]) }
2246
2276
  if (pass == 1 && bindings > 0) continue
2247
- if (TAINT != "" && (complex || queued != 1 || commands != 1 || !simple_ok)) {
2277
+ if (INLINE && INLINE_HIT) {
2278
+ report("inline interpreter programs with protected file vocabulary cannot be checked safely", "the read (Claude: Read) tool for an exact non-credential file; use find/ls to locate files first. Never read credential files or disguise the same read in a variable, encoded string or script file")
2279
+ } else if (TAINT != "" && (complex || queued != 1 || commands != 1 || !simple_ok)) {
2248
2280
  other_reports = reports; reports = ""
2249
2281
  report("the command names a protected file (" TAINT ") and is not a single literal read", "run the read on its own with literal paths, e.g. cat .env.example; split compound commands into separate calls; do not build the name with variables, globs, loops, pipes, redirections or nested shells; for a commit message or PR body that mentions the name, write the text to a file with the file tool and pass the file")
2250
2282
  reports = reports other_reports
@@ -4,10 +4,9 @@ applyTo: "**/*"
4
4
 
5
5
  # Operational safety
6
6
 
7
- Operation-specific invariants that hold before any skill is chosen or file is open. Authority comes
8
- from [`capability-is-not-authority.md`](./capability-is-not-authority.md); credentials and data
9
- channels from [`secrets.md`](./secrets.md). All lines are **[contract]** (see
10
- [`general.md`](./general.md)). They are policy, not a sandbox: none is mechanically enforced.
7
+ Before skills/files: [authority](./capability-is-not-authority.md), [credentials/data channels](./secrets.md).
8
+ All are **[contract]** ([general.md](./general.md)): policy, not enforcement or a sandbox.
9
+ [Inline guards](../hooks/README.md#inline-interpreter-policy) are not sandboxes.
11
10
 
12
11
  ## Screenplay models and rendering
13
12
 
@@ -18,4 +18,4 @@ paths:
18
18
  - Use a C# file-based app (`dotnet run --file tool.cs`, `#:package` pinned) when the script needs .NET or Cratis libraries or shares types with the product. Do not use one in hooks or on per-call hot paths.
19
19
  - Hooks under `.cratis/ai/hooks` are POSIX sh compatible with bash 3.2, or Node. Read stdin with `IFS= read -r -d '' x || true`, never `$(</dev/stdin)`.
20
20
  - Do not add Python scripts or `python3` workflow steps to Cratis repositories unless the project itself is Python (for example the Chronicle Python client). Existing Python scripts are ported to Node opportunistically: when you substantially change one, port it in the same PR. There is no bulk port.
21
- - Agents: edit files with the edit/write tools, query JSON with `gh --jq`/`jq`, and use `node -e` or `node --input-type=module - <<'EOF'` for ad-hoc logic. Never `python3 -c`, and never rewrite files by script.
21
+ - Agents: edit files with the edit/write tools, query JSON with `gh --jq`/`jq`, and use `node -e` or `node --input-type=module - <<'EOF'` for trigger-free ad-hoc logic. Never `python3 -c`, and never rewrite files by script.
@@ -22,6 +22,7 @@ they also hold without it.
22
22
  - **[contract] Command-text checks cannot see** shell-piped code (`… | sh`, `bash -c "$(…)"`),
23
23
  recursive searches without filenames (`grep -r PASSWORD .`), or paths hidden in variables,
24
24
  aliases or scripts. The rules still apply; output redaction is the backstop.
25
+ - **[contract] Inline refusals:** Read exact non-credential files.
25
26
  - **[contract] After a guard block, narrowing to literal non-credential files is supported remediation,
26
27
  not a workaround.** Follow `Use instead`; never disguise the same secret read.
27
28
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cratis/pi",
3
- "version": "7.188.2",
3
+ "version": "7.188.3",
4
4
  "description": "Configuration-aware Cratis AI integration for Pi",
5
5
  "type": "module",
6
6
  "files": [