@cratis/pi 7.169.0 → 7.170.1
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/package/corpus/harnesses/copilot/instructions/profiles.instructions.md +8 -10
- package/package/corpus/hooks/README.md +10 -11
- package/package/corpus/hooks/scripts/cratis-guard-writes.sh +5 -33
- package/package/corpus/rules/codescene.md +3 -5
- package/package/corpus/rules/profiles.md +8 -10
- package/package.json +1 -1
|
@@ -241,11 +241,11 @@ floor itself is the universal rule [code-health.md](./code-health.instructions.m
|
|
|
241
241
|
No other profile, including `cratis` and `cratis/full`, composes it.
|
|
242
242
|
|
|
243
243
|
The profile selects the `codescene` stdio server (`cs-mcp`, no arguments) from
|
|
244
|
-
`mcp-servers.json
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
`
|
|
244
|
+
`mcp-servers.json`. The CLI does not register it for Claude, Copilot, Cursor, Codex or OpenCode
|
|
245
|
+
(per-user account, local binary): add it at user level, never in committed project files.
|
|
246
|
+
Pi's `cratis-mcp` extension enables it via `cratis_enable_mcp`, or at session start with
|
|
247
|
+
`mcpServers.codescene.eager: true`; a missing binary fails the enable or is a startup notice, and
|
|
248
|
+
`mcpServers.codescene.enabled: false` opts out.
|
|
249
249
|
CodeScene needs an account and OAuth `login`; without an account or available
|
|
250
250
|
CodeScene tools, skip its steps and say so rather than blocking contributors.
|
|
251
251
|
The MCP catalog has no install-hints field and does not install the executable.
|
|
@@ -258,16 +258,14 @@ The flags keep the browser headless and isolated: no persistent profile, so no
|
|
|
258
258
|
personal cookies or logins are reused. The profile carries no skills or rules beyond the two
|
|
259
259
|
baseline skills, and no other profile composes it.
|
|
260
260
|
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
Each user registers it in their own user-level MCP configuration, never in committed
|
|
264
|
-
project files. For Claude Code:
|
|
261
|
+
`cratis ai install` registers only Screenplay for Claude, Copilot, Cursor, Codex and
|
|
262
|
+
OpenCode; add Playwright at user level, never in project files. For Claude Code:
|
|
265
263
|
|
|
266
264
|
```bash
|
|
267
265
|
claude mcp add --scope user playwright -- npx -y @playwright/mcp@0.0.83 --headless --isolated
|
|
268
266
|
```
|
|
269
267
|
|
|
270
|
-
Pi
|
|
268
|
+
Pi's `cratis-mcp` extension can start it the same way. Use it
|
|
271
269
|
for exploratory browser checks; repeatable checks stay in the repository's own
|
|
272
270
|
Playwright tests. Without the server registered, skip browser steps and say so.
|
|
273
271
|
|
|
@@ -273,8 +273,6 @@ Rule numbers refer to the numbered list in [`../rules/general.md`](../rules/gene
|
|
|
273
273
|
|
|
274
274
|
**Blocked outright** (`PreToolUse`, exit 2):
|
|
275
275
|
|
|
276
|
-
- Editing a file whose header marks it as Cratis-generated output — rule 15 `[contract]`
|
|
277
|
-
- Writing content that opens with such a header (hand-authoring a "generated" proxy)
|
|
278
276
|
- `package.json`, `Directory.Packages.props`, `global.json`, `NuGet.config` (also `NuGet.Config` and `nuget.config`),
|
|
279
277
|
`yarn.lock`, `package-lock.json`, `pnpm-lock.yaml`, `packages.lock.json` — unless the
|
|
280
278
|
repository's dependency-manifest policy allows them (see below)
|
|
@@ -376,13 +374,15 @@ this deliberately over-conservative.
|
|
|
376
374
|
|
|
377
375
|
This is **best-effort, not a sandbox**. Runtime names assembled from variables without a
|
|
378
376
|
protected name appearing literally are out of scope, as are aliases/functions, external
|
|
379
|
-
scripts, tool configuration/hooks and symlinks created during execution.
|
|
380
|
-
|
|
381
|
-
the shell filter. OS permissions/sandboxing remain the primary boundary. Do not use another
|
|
377
|
+
scripts, tool configuration/hooks and symlinks created during execution.
|
|
378
|
+
OS permissions/sandboxing remain the primary boundary. Do not use another
|
|
382
379
|
route to work around a refusal.
|
|
383
380
|
|
|
384
|
-
|
|
385
|
-
|
|
381
|
+
Generated-file headers do not trigger a block in either write guard. Regenerating proxies with
|
|
382
|
+
`dotnet build`, staging, restoring, committing and other Git index/worktree operations, and direct
|
|
383
|
+
writes (including copies, moves and redirections) are allowed for generated files. For durable
|
|
384
|
+
proxy changes, change the C# source and rebuild rather than hand-editing generated output.
|
|
385
|
+
Other protected classes still apply regardless of a generated header.
|
|
386
386
|
|
|
387
387
|
### Dependency-manifest writes
|
|
388
388
|
|
|
@@ -405,9 +405,8 @@ and Pi:
|
|
|
405
405
|
|
|
406
406
|
`false` re-enables the manifest block in a Cratis repository; `true` allows manifest writes
|
|
407
407
|
in any repository. Merge this property into the existing configuration. An absent, malformed,
|
|
408
|
-
or non-boolean setting uses the origin-based default. This setting never permits
|
|
409
|
-
|
|
410
|
-
part of this guard's manifest category.
|
|
408
|
+
or non-boolean setting uses the origin-based default. This setting never permits `.env` writes.
|
|
409
|
+
The protected basename list is unchanged; `package.json` is not part of this guard's manifest category.
|
|
411
410
|
|
|
412
411
|
This allowance is not authorization for unrelated upgrades: keep changes task-focused and
|
|
413
412
|
call out version bumps in the PR description. Other repositories retain the rule requiring
|
|
@@ -936,7 +935,7 @@ Each is an explicit, auditable opt-out — none of them is a default.
|
|
|
936
935
|
|
|
937
936
|
| Variable | Effect |
|
|
938
937
|
|---|---|
|
|
939
|
-
| `CRATIS_HOOKS_ALLOW_PROTECTED_WRITES=1` | bypasses both Write/Edit and shell-write guards, including
|
|
938
|
+
| `CRATIS_HOOKS_ALLOW_PROTECTED_WRITES=1` | bypasses both Write/Edit and shell-write guards, including `.env`, agent controls and installed trees, while set in the harness environment; use only for an explicitly requested protected write. Repository-scoped manifest allowance uses `.cratis/ai.json` instead and never bypasses those protections |
|
|
940
939
|
| `CRATIS_HOOKS_SKIP_SCAN=1` | disables the pattern pass |
|
|
941
940
|
| `CRATIS_HOOKS_SKIP_GATE=1` | disables the quality gate |
|
|
942
941
|
| `CRATIS_HOOKS_GATE_DRYRUN=1` | prints which gates would run, and why, then exits 0 |
|
|
@@ -2,12 +2,10 @@
|
|
|
2
2
|
# PreToolUse hook — hard block on writes that must never happen.
|
|
3
3
|
#
|
|
4
4
|
# Exits 2 (block the tool call, stderr goes back to the model) for:
|
|
5
|
-
# 1.
|
|
6
|
-
# (.cratis/ai/rules/general.md rule 15 [contract])
|
|
7
|
-
# 2. Dependency manifests — Directory.Packages.props, global.json, lockfiles, NuGet config
|
|
5
|
+
# 1. Dependency manifests — Directory.Packages.props, global.json, lockfiles, NuGet config
|
|
8
6
|
# (allowed by default for a github.com/Cratis origin)
|
|
9
|
-
#
|
|
10
|
-
#
|
|
7
|
+
# 2. Environment files — .env and friends (secrets)
|
|
8
|
+
# 3. Agent controls — permissions, hooks and installed managed corpus/adapters
|
|
11
9
|
#
|
|
12
10
|
# While jq is missing the guard cannot read the tool call, so it refuses every call.
|
|
13
11
|
#
|
|
@@ -347,23 +345,7 @@ agent_control_target() {
|
|
|
347
345
|
control_match "$target_rel" "${control_patterns[@]}"
|
|
348
346
|
}
|
|
349
347
|
|
|
350
|
-
# ──
|
|
351
|
-
# The marker must be a real header: a comment opener at the start of one of the first few lines.
|
|
352
|
-
# Merely *mentioning* the string — documentation, a rule file, this corpus — is not a match.
|
|
353
|
-
marker='^[[:space:]]*(//|/\*|#|<!--)[[:space:]]*@generated by Cratis'
|
|
354
|
-
|
|
355
|
-
# True when one of the first five lines of stdin carries the marker (head -n 5 | grep -E, without forks).
|
|
356
|
-
first_lines_carry_marker() {
|
|
357
|
-
local LC_ALL=C line count=0
|
|
358
|
-
while [ "$count" -lt 5 ] && { IFS= read -r line || [ -n "$line" ]; }; do
|
|
359
|
-
count=$((count + 1))
|
|
360
|
-
# shellcheck disable=SC2034
|
|
361
|
-
[[ "$line" =~ $marker ]] && return 0
|
|
362
|
-
done
|
|
363
|
-
return 1
|
|
364
|
-
}
|
|
365
|
-
|
|
366
|
-
# ── 2. Dependency manifests, lockfiles, SDK and NuGet configuration ───────────
|
|
348
|
+
# ── Dependency manifests, lockfiles, SDK and NuGet configuration ──────────────
|
|
367
349
|
manifest_writes_allowed() {
|
|
368
350
|
local setting="" directory policy_root start="$PWD"
|
|
369
351
|
# Authorization belongs to the write target, which may be outside the session's checkout.
|
|
@@ -402,10 +384,6 @@ classify_file() {
|
|
|
402
384
|
if agent_control_target "$file" || { [ -n "$physical_file" ] && agent_control_target "$physical_file"; }; then
|
|
403
385
|
classification=controls; return 0
|
|
404
386
|
fi
|
|
405
|
-
if [ -f "$file" ] && first_lines_carry_marker 2>/dev/null <"$file" && LC_ALL=C grep -Iq . "$file" 2>/dev/null; then
|
|
406
|
-
classification=generated; return 0
|
|
407
|
-
fi
|
|
408
|
-
if [ -n "$new_content" ] && first_lines_carry_marker <<<"$new_content"; then classification=content; return 0; fi
|
|
409
387
|
if names_match "$base" "${manifest_patterns[@]}"; then
|
|
410
388
|
if manifest_writes_allowed; then return 1; fi
|
|
411
389
|
classification=manifest; return 0
|
|
@@ -430,7 +408,7 @@ if [ "$reference_mode" = 1 ]; then
|
|
|
430
408
|
reference_pattern=0
|
|
431
409
|
case "$candidate" in *'*'* | *'?'* | *'['* | *'{'* | *'@('* | *'+('* | *'!('*) reference_pattern=1 ;; esac
|
|
432
410
|
if classify_file "$candidate" "$reference_pattern"; then printf '%s\n' "$candidate"; continue; fi
|
|
433
|
-
#
|
|
411
|
+
# Inspect actual glob matches too, including symlinks to protected targets.
|
|
434
412
|
if [ "$reference_pattern" = 1 ]; then
|
|
435
413
|
count=0
|
|
436
414
|
while IFS= read -r expanded; do
|
|
@@ -448,12 +426,6 @@ case "$classification" in
|
|
|
448
426
|
controls) block \
|
|
449
427
|
"This target controls the agent's permissions or extensions, or belongs to an installed managed corpus/adapter tree. Agent Write/Edit calls may not alter their own controls or managed instructions." \
|
|
450
428
|
"Instead: report the intended change. Use 'cratis ai update' for managed files, or let a person change settings. An explicitly authorized protected write requires CRATIS_HOOKS_ALLOW_PROTECTED_WRITES=1 in the harness environment. Do not retry through a shell write." ;;
|
|
451
|
-
generated) block \
|
|
452
|
-
"This file is generated output (its header marks it as generated by Cratis). Rule 15 [contract] in .cratis/ai/rules/general.md: never edit a generated file — the next build overwrites it." \
|
|
453
|
-
"Instead: change the C# source it is generated from (the [Command] / [ReadModel] record) and rebuild with 'dotnet build -c Debug' to regenerate the proxy." ;;
|
|
454
|
-
content) block \
|
|
455
|
-
"The content being written opens with a Cratis generated-file header. Proxies are produced by the Cratis proxy generator, never hand-written." \
|
|
456
|
-
"Instead: write the C# source and run 'dotnet build -c Debug' to generate the proxy." ;;
|
|
457
429
|
manifest) block \
|
|
458
430
|
"'$base' is a dependency manifest / lockfile / SDK or NuGet configuration file. .cratis/ai/rules/general.md (Source-of-Truth Discipline): don't change these unless explicitly asked." \
|
|
459
431
|
"To allow dependency updates for this repository, set allowDependencyManifestWrites to true in .cratis/ai.json. If the user explicitly asked for this change, re-run the tool call with CRATIS_HOOKS_ALLOW_PROTECTED_WRITES=1 exported. Otherwise take the dependency as given and solve the problem in source." ;;
|
|
@@ -6,11 +6,9 @@ profile: cratis/codescene
|
|
|
6
6
|
|
|
7
7
|
This policy applies only when the repository explicitly selects `cratis/codescene`
|
|
8
8
|
or a descendant profile. It overrides the vendored CodeScene skills where they
|
|
9
|
-
differ.
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
committed project files: `cs-mcp` over stdio (`brew install cs-mcp`), or
|
|
13
|
-
`npx -y @codescene/codehealth-mcp`.
|
|
9
|
+
differ. Only Pi's `cratis-mcp` extension can start the CodeScene MCP server (see
|
|
10
|
+
[profiles.md](./profiles.md)); other harnesses add it at user level, never in committed
|
|
11
|
+
project files: `cs-mcp` over stdio (`brew install cs-mcp`), or `npx -y @codescene/codehealth-mcp`.
|
|
14
12
|
CodeScene needs an account and OAuth `login`. Without an account or available
|
|
15
13
|
CodeScene tools, skip these steps and say so; never block contributors who have
|
|
16
14
|
not opted in.
|
|
@@ -240,11 +240,11 @@ floor itself is the universal rule [code-health.md](./code-health.md); the profi
|
|
|
240
240
|
No other profile, including `cratis` and `cratis/full`, composes it.
|
|
241
241
|
|
|
242
242
|
The profile selects the `codescene` stdio server (`cs-mcp`, no arguments) from
|
|
243
|
-
`mcp-servers.json
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
`
|
|
243
|
+
`mcp-servers.json`. The CLI does not register it for Claude, Copilot, Cursor, Codex or OpenCode
|
|
244
|
+
(per-user account, local binary): add it at user level, never in committed project files.
|
|
245
|
+
Pi's `cratis-mcp` extension enables it via `cratis_enable_mcp`, or at session start with
|
|
246
|
+
`mcpServers.codescene.eager: true`; a missing binary fails the enable or is a startup notice, and
|
|
247
|
+
`mcpServers.codescene.enabled: false` opts out.
|
|
248
248
|
CodeScene needs an account and OAuth `login`; without an account or available
|
|
249
249
|
CodeScene tools, skip its steps and say so rather than blocking contributors.
|
|
250
250
|
The MCP catalog has no install-hints field and does not install the executable.
|
|
@@ -257,16 +257,14 @@ The flags keep the browser headless and isolated: no persistent profile, so no
|
|
|
257
257
|
personal cookies or logins are reused. The profile carries no skills or rules beyond the two
|
|
258
258
|
baseline skills, and no other profile composes it.
|
|
259
259
|
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
Each user registers it in their own user-level MCP configuration, never in committed
|
|
263
|
-
project files. For Claude Code:
|
|
260
|
+
`cratis ai install` registers only Screenplay for Claude, Copilot, Cursor, Codex and
|
|
261
|
+
OpenCode; add Playwright at user level, never in project files. For Claude Code:
|
|
264
262
|
|
|
265
263
|
```bash
|
|
266
264
|
claude mcp add --scope user playwright -- npx -y @playwright/mcp@0.0.83 --headless --isolated
|
|
267
265
|
```
|
|
268
266
|
|
|
269
|
-
Pi
|
|
267
|
+
Pi's `cratis-mcp` extension can start it the same way. Use it
|
|
270
268
|
for exploratory browser checks; repeatable checks stay in the repository's own
|
|
271
269
|
Playwright tests. Without the server registered, skip browser steps and say so.
|
|
272
270
|
|