@cratis/pi 7.170.0 → 7.170.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.
@@ -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`, but neither the Cratis CLI nor any harness registers it,
245
- because it needs a per-user CodeScene account and a locally installed binary.
246
- Each user registers it in their own user-level MCP configuration, never in
247
- committed project files: `cs-mcp` over stdio (`brew install cs-mcp`), or
248
- `npx -y @codescene/codehealth-mcp`.
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
- Today `cratis ai install` registers only Screenplay and Pi's `cratis-mcp` extension
262
- loads only Screenplay, so Playwright, like CodeScene, is not registered for you.
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 users register it through a Pi MCP adapter or extension of their choice. Use it
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
 
@@ -66,6 +66,8 @@ suffix that follows a slash in it (`$PWD/.cratis/x` and `~+/.cratis/x` are treat
66
66
  directory), without parsing the expansion, and refused if a suffix is protected, which includes a read of a protected path through a variable. This is a
67
67
  best-effort lexical check, not enforcement: a variable holding the whole path still passes.
68
68
 
69
+ Git reflog selectors with unprotected prefixes (`stash@{0}`, `HEAD@{1}`, `branch@{upstream}`) are revisions, not paths.
70
+
69
71
  The shell-write reference scan keeps conservative leading-dot intersections: a tool named `Bash`,
70
72
  `SHELL`, and the hook process's options do not establish the execution shell's options. Globbed writes
71
73
  therefore remain blocked. Read operands under protected paths are not write targets: `rg -n`/`-l`,
@@ -273,8 +275,6 @@ Rule numbers refer to the numbered list in [`../rules/general.md`](../rules/gene
273
275
 
274
276
  **Blocked outright** (`PreToolUse`, exit 2):
275
277
 
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
278
  - `package.json`, `Directory.Packages.props`, `global.json`, `NuGet.config` (also `NuGet.Config` and `nuget.config`),
279
279
  `yarn.lock`, `package-lock.json`, `pnpm-lock.yaml`, `packages.lock.json` — unless the
280
280
  repository's dependency-manifest policy allows them (see below)
@@ -376,13 +376,15 @@ this deliberately over-conservative.
376
376
 
377
377
  This is **best-effort, not a sandbox**. Runtime names assembled from variables without a
378
378
  protected name appearing literally are out of scope, as are aliases/functions, external
379
- scripts, tool configuration/hooks and symlinks created during execution. Existing generated
380
- headers are classified; content that would create a new generated header is not inspected by
381
- the shell filter. OS permissions/sandboxing remain the primary boundary. Do not use another
379
+ scripts, tool configuration/hooks and symlinks created during execution.
380
+ OS permissions/sandboxing remain the primary boundary. Do not use another
382
381
  route to work around a refusal.
383
382
 
384
- The generated-file check is anchored: the marker must be a comment opener at the start of one of
385
- the first five lines. A rule file or a document that merely *mentions* the marker is not blocked.
383
+ Generated-file headers do not trigger a block in either write guard. Regenerating proxies with
384
+ `dotnet build`, staging, restoring, committing and other Git index/worktree operations, and direct
385
+ writes (including copies, moves and redirections) are allowed for generated files. For durable
386
+ proxy changes, change the C# source and rebuild rather than hand-editing generated output.
387
+ Other protected classes still apply regardless of a generated header.
386
388
 
387
389
  ### Dependency-manifest writes
388
390
 
@@ -405,9 +407,8 @@ and Pi:
405
407
 
406
408
  `false` re-enables the manifest block in a Cratis repository; `true` allows manifest writes
407
409
  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 generated
409
- output or `.env` writes. The protected basename list is unchanged; `package.json` is not
410
- part of this guard's manifest category.
410
+ or non-boolean setting uses the origin-based default. This setting never permits `.env` writes.
411
+ The protected basename list is unchanged; `package.json` is not part of this guard's manifest category.
411
412
 
412
413
  This allowance is not authorization for unrelated upgrades: keep changes task-focused and
413
414
  call out version bumps in the PR description. Other repositories retain the rule requiring
@@ -936,7 +937,7 @@ Each is an explicit, auditable opt-out — none of them is a default.
936
937
 
937
938
  | Variable | Effect |
938
939
  |---|---|
939
- | `CRATIS_HOOKS_ALLOW_PROTECTED_WRITES=1` | bypasses both Write/Edit and shell-write guards, including generated files, `.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
+ | `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
941
  | `CRATIS_HOOKS_SKIP_SCAN=1` | disables the pattern pass |
941
942
  | `CRATIS_HOOKS_SKIP_GATE=1` | disables the quality gate |
942
943
  | `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. Generated files — anything whose header marks it as Cratis-generated output
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
- # 3. Environment files — .env and friends (secrets)
10
- # 4. Agent controls — permissions, hooks and installed managed corpus/adapters
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
- # ── 1. Generated files ────────────────────────────────────────────────────────
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
@@ -427,10 +405,13 @@ if [ "$reference_mode" = 1 ]; then
427
405
  unset 'candidates[last]'
428
406
  new_content=""
429
407
  for candidate in "${candidates[@]}"; do
408
+ # Reflog selectors name revisions, unless the prefix or the literal path (or its symlink target) is protected.
409
+ if [[ "$candidate" =~ ^[A-Za-z0-9._/-]*@\{(-?[0-9]+|upstream|push|u)\}$ ]] \
410
+ && ! classify_file "${candidate%@*}" && ! classify_file "$candidate"; then continue; fi
430
411
  reference_pattern=0
431
412
  case "$candidate" in *'*'* | *'?'* | *'['* | *'{'* | *'@('* | *'+('* | *'!('*) reference_pattern=1 ;; esac
432
413
  if classify_file "$candidate" "$reference_pattern"; then printf '%s\n' "$candidate"; continue; fi
433
- # Existing generated files can have arbitrary names; inspect actual glob matches too.
414
+ # Inspect actual glob matches too, including symlinks to protected targets.
434
415
  if [ "$reference_pattern" = 1 ]; then
435
416
  count=0
436
417
  while IFS= read -r expanded; do
@@ -448,12 +429,6 @@ case "$classification" in
448
429
  controls) block \
449
430
  "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
431
  "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
432
  manifest) block \
458
433
  "'$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
434
  "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. Neither the Cratis CLI nor any harness registers the CodeScene MCP server,
10
- because it needs a per-user CodeScene account and a locally installed binary.
11
- Each user registers it in their own user-level MCP configuration, never in
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`, but neither the Cratis CLI nor any harness registers it,
244
- because it needs a per-user CodeScene account and a locally installed binary.
245
- Each user registers it in their own user-level MCP configuration, never in
246
- committed project files: `cs-mcp` over stdio (`brew install cs-mcp`), or
247
- `npx -y @codescene/codehealth-mcp`.
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
- Today `cratis ai install` registers only Screenplay and Pi's `cratis-mcp` extension
261
- loads only Screenplay, so Playwright, like CodeScene, is not registered for you.
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 users register it through a Pi MCP adapter or extension of their choice. Use it
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
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cratis/pi",
3
- "version": "7.170.0",
3
+ "version": "7.170.2",
4
4
  "description": "Configuration-aware Cratis AI integration for Pi",
5
5
  "type": "module",
6
6
  "files": [