@cratis/pi 7.170.4 → 7.170.5
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.
|
@@ -282,11 +282,15 @@ Rule numbers refer to the numbered list in [`../rules/general.md`](../rules/gene
|
|
|
282
282
|
repository's dependency-manifest policy allows them (see below)
|
|
283
283
|
- `.env`, `.env.*`, `*.env` — secrets
|
|
284
284
|
- Agent controls: `.claude/settings.json`, `.claude/settings.local.json`, `.mcp.json`,
|
|
285
|
-
`.pi/settings.json` and `.
|
|
286
|
-
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
285
|
+
`.pi/settings.json`, `.pi/extensions/**`, `.cratis/ai.manifest.json` and `.cratis/ai.json`
|
|
286
|
+
- The installed `.cratis/ai/**` corpus, including when its manifest is missing or unreadable.
|
|
287
|
+
Adapter paths in `.claude/**` and `.pi/**` are protected according to the manifest's
|
|
288
|
+
`Integrations` entries. Both addressed paths and symlink destinations are checked, including
|
|
289
|
+
the Claude settings link to the hook template. Without an installation manifest, authored
|
|
290
|
+
corpus and harness adapters remain editable only when Git `HEAD` records the authoring layout:
|
|
291
|
+
`Cratis.AI.slnx`, the guard source and the `@cratis/pi` package in `Source/Pi.Plugin`. Changing a
|
|
292
|
+
remote URL or adding uncommitted files does not establish this source-repository exception.
|
|
293
|
+
The two policy JSON files remain protected in the source repository.
|
|
290
294
|
|
|
291
295
|
For agent controls, report the intended change rather than rewriting permissions or hooks.
|
|
292
296
|
A person edits settings; `cratis ai update` replaces managed files using the CLI's filesystem
|
|
@@ -187,7 +187,7 @@ origin_matches() {
|
|
|
187
187
|
# One policy vocabulary for normal Write/Edit and whole-command reference checks.
|
|
188
188
|
manifest_patterns=(package.json Directory.Packages.props global.json NuGet.config yarn.lock package-lock.json pnpm-lock.yaml packages.lock.json)
|
|
189
189
|
environment_patterns=('.env' '.env.*' '*.env')
|
|
190
|
-
control_patterns=('.claude/settings.json' '.claude/settings.local.json' '.mcp.json' '.pi/settings.json' '.pi/extensions/*')
|
|
190
|
+
control_patterns=('.claude/settings.json' '.claude/settings.local.json' '.mcp.json' '.pi/settings.json' '.pi/extensions/*' '.cratis/ai.manifest.json' '.cratis/ai.json')
|
|
191
191
|
|
|
192
192
|
# Glob-language intersection, not expansion/eval. A star has an epsilon transition and
|
|
193
193
|
# a character loop. The product automaton accepts iff the two patterns share a spelling.
|
|
@@ -209,16 +209,17 @@ function tokens(s, side, i, c, j, k, t, copy, jumps, first, closing) {
|
|
|
209
209
|
if (gsub(/\[/, "[", copy) > 64) exit 2
|
|
210
210
|
first = index(s, "{")
|
|
211
211
|
for (k = length(s); k > first; k--) if (substr(s, k, 1) == "}") { closing = k; break }
|
|
212
|
-
if (first && closing) {
|
|
212
|
+
if (first && closing && s != "{}") {
|
|
213
213
|
if (index(substr(s, first, closing - first + 1), "/")) exit 2
|
|
214
214
|
if (substr(s, first, closing - first + 1) ~ /[$`'"\\]/) exit 2
|
|
215
215
|
if (substr(s, 1, first - 1) substr(s, closing + 1) ~ /[^a-z0-9._\/*?,+=:@%-]/) exit 2
|
|
216
|
-
s = substr(s, 1, first) substr(s, closing)
|
|
216
|
+
s = substr(s, 1, first - 1) "*" substr(s, closing + 1)
|
|
217
217
|
}
|
|
218
218
|
}
|
|
219
219
|
for (i = 1; i <= length(s); i++) {
|
|
220
220
|
c = substr(s, i, 1); t = c; j = i
|
|
221
|
-
|
|
221
|
+
# Only a standalone empty brace argument is literal; path placeholders can expand.
|
|
222
|
+
if (c == "{" && s != "{}") {
|
|
222
223
|
j = index(substr(s, i), "}")
|
|
223
224
|
if (j) { j = i + j - 1; t = "*" } else j = i
|
|
224
225
|
if (side == 1 && index(substr(s, i, j - i + 1), "/")) exit 2
|
|
@@ -292,6 +293,8 @@ control_match() {
|
|
|
292
293
|
local value="$1" reference_pattern="$reference_pattern" pattern LC_ALL=C
|
|
293
294
|
shift
|
|
294
295
|
if names_match "$value" "$@"; then return 0; fi
|
|
296
|
+
# Do not turn a standalone placeholder into a path by appending descendants.
|
|
297
|
+
[ "$value" != '{}' ] || return 1
|
|
295
298
|
[ "$reference_mode" = 1 ] || return 1
|
|
296
299
|
if [ "$reference_pattern" = 0 ]; then
|
|
297
300
|
shopt -s nocasematch
|
|
@@ -305,6 +308,23 @@ control_match() {
|
|
|
305
308
|
}
|
|
306
309
|
|
|
307
310
|
# ── 4. Agent controls and installed managed trees ─────────────────────────────
|
|
311
|
+
# Authoring requires committed framework source, not a mutable remote URL or new files.
|
|
312
|
+
authored_cache_root=""
|
|
313
|
+
authored_cache_status=1
|
|
314
|
+
authored_corpus_repository() {
|
|
315
|
+
if [ "$authored_cache_root" != "$1" ]; then
|
|
316
|
+
authored_cache_root="$1"
|
|
317
|
+
authored_cache_status=1
|
|
318
|
+
if git -C "$1" cat-file -e HEAD:Cratis.AI.slnx 2>/dev/null &&
|
|
319
|
+
git -C "$1" cat-file -e HEAD:.cratis/ai/hooks/scripts/cratis-guard-writes.sh 2>/dev/null &&
|
|
320
|
+
git -C "$1" show HEAD:Source/Pi.Plugin/package.json 2>/dev/null |
|
|
321
|
+
jq -e -s 'length == 1 and .[0].name == "@cratis/pi" and .[0].type == "module"' >/dev/null 2>&1; then
|
|
322
|
+
authored_cache_status=0
|
|
323
|
+
fi
|
|
324
|
+
fi
|
|
325
|
+
return "$authored_cache_status"
|
|
326
|
+
}
|
|
327
|
+
|
|
308
328
|
agent_control_target() {
|
|
309
329
|
local target="$1" directory policy_root target_rel managed pattern
|
|
310
330
|
dir_of "$target"
|
|
@@ -319,9 +339,14 @@ agent_control_target() {
|
|
|
319
339
|
policy_root="$directory"
|
|
320
340
|
relative_to "$target" "$policy_root"
|
|
321
341
|
target_rel="$REPLY"
|
|
322
|
-
|
|
342
|
+
# Policy files remain controls even in the authored corpus repository.
|
|
343
|
+
if control_match "$target_rel" '.cratis/ai.manifest.json' '.cratis/ai.json'; then return 0; fi
|
|
344
|
+
if [ ! -f "$policy_root/.cratis/ai.manifest.json" ] && authored_corpus_repository "$policy_root"; then
|
|
345
|
+
return 1
|
|
346
|
+
fi
|
|
347
|
+
if [ -f "$policy_root/.cratis/ai.manifest.json" ] || [ -d "$policy_root/.cratis/ai" ]; then
|
|
323
348
|
if control_match "$target_rel" '.cratis/ai/*'; then return 0; fi
|
|
324
|
-
if control_match "$target_rel" '.claude/*' '.pi/*'; then
|
|
349
|
+
if [ -f "$policy_root/.cratis/ai.manifest.json" ] && control_match "$target_rel" '.claude/*' '.pi/*'; then
|
|
325
350
|
# Integration paths, not corpus Files, establish adapter ownership.
|
|
326
351
|
managed="$(jq -r '
|
|
327
352
|
(.Integrations // []) | if type != "array" then empty else
|
|
@@ -335,12 +360,6 @@ agent_control_target() {
|
|
|
335
360
|
if control_match "$target_rel" "$pattern"; then return 0; fi
|
|
336
361
|
done <<<"$managed"
|
|
337
362
|
fi
|
|
338
|
-
else
|
|
339
|
-
# The corpus is authored source in Cratis/AI, not a managed installation.
|
|
340
|
-
repository_origin "$policy_root"
|
|
341
|
-
if origin_matches '^(https://github\.com/|git@github\.com:|ssh://git@github\.com(:[0-9]+)?/)cratis/ai(\.git)?/?$'; then
|
|
342
|
-
return 1
|
|
343
|
-
fi
|
|
344
363
|
fi
|
|
345
364
|
control_match "$target_rel" "${control_patterns[@]}"
|
|
346
365
|
}
|