@cratis/pi 7.150.1 → 7.150.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.
@@ -42,16 +42,76 @@ function candidate(s) {
42
42
  # A generic attached option prefix must not hide a path spelling (-t.pi/...).
43
43
  if (s ~ /^-/ && match(s, /[.\/]/) && RSTART > 1) candidate(substr(s, RSTART))
44
44
  }
45
- function scan(s, n, i, c, word, whole) {
45
+ # An extended-glob group (`@(a|b)`, `*(x)`) is also read as one star, so `.e@(n)v` meets `.env`.
46
+ # A word with a brace span and quoting or expansion syntax is also kept whole, so the classifier sees it unsplit.
47
+ # Whole-quoted words and `${...}` parameter expansions do not brace-expand and are not kept.
48
+ function extglob_star(s, guard) {
49
+ while (guard++ < 64 && match(s, /[@?*+!]\([^()]*\)/)) s = substr(s, 1, RSTART - 1) "*" substr(s, RSTART + RLENGTH)
50
+ return s
51
+ }
52
+ # Quoted text never brace-expands or opens an extended glob, so its quoting, expansion and group syntax is
53
+ # neutralized before the classifier, which refuses that syntax in an unquoted spelling.
54
+ function quoted_literal(s) {
55
+ if (index(s, "{")) gsub(/[$`"\047\\]/, "_", s)
56
+ gsub(/[@?*+!]\(/, "__", s)
57
+ return s
58
+ }
59
+ function raw_brace_word(w, quote, first, bare) {
60
+ if (!(w ~ /[$`"\047\\]/)) return
61
+ first = substr(w, 1, 1); quote = (first == "\047" || first == "\"") ? first : ""
62
+ if (quote != "" && substr(w, length(w), 1) == quote && index(substr(w, 2, length(w) - 2), quote) == 0) return
63
+ bare = w; gsub(/\$\{/, "", bare)
64
+ if (index(bare, "{")) candidate(w)
65
+ }
66
+ function raw_brace_scan(s, n, i, c, word) {
46
67
  n = length(s)
47
68
  for (i = 1; i <= n; i++) {
48
69
  c = substr(s, i, 1)
49
- if (c ~ /[ \t\n\r;|&<>()\047"`$=\\]/) { candidate(word); word = "" }
70
+ if (c ~ /[ \t\n\r;|&<>]/) { raw_brace_word(word); word = "" }
71
+ else word = word c
72
+ }
73
+ raw_brace_word(word)
74
+ }
75
+ # After an expansion (or a leading tilde) the prefix of a path is unknown and could be the repository root, so the
76
+ # literal remainder is also judged as a path relative to the working directory: the word without its variable name
77
+ # and every suffix that starts after a slash. A variable holding a whole protected path stays unseen.
78
+ function remainder(word, rest, tail, count, slash) {
79
+ if (word == "") return
80
+ rest = word
81
+ if (!sub(/^\{[^}]*\}/, "", rest)) sub(/^[A-Za-z0-9_~]+/, "", rest)
82
+ candidate(rest)
83
+ tail = word
84
+ while (count++ < 16 && (slash = index(tail, "/")) > 0) { tail = substr(tail, slash + 1); candidate(tail) }
85
+ }
86
+ # Expansion syntax is not parsed: a whitespace-delimited chunk holding any of $ ` ~ ( ) { } is judged by every
87
+ # suffix that follows a slash in it, so a path after a substitution, a tilde form or a nested expansion is seen
88
+ # even when the lexer split the substitution at an inner space.
89
+ function chunk_suffixes(chunk, slash, count) {
90
+ gsub(/["\047\\]/, "", chunk)
91
+ if (chunk !~ /[$`~(){}]/) return
92
+ while (count++ < 16 && (slash = index(chunk, "/")) > 0) { chunk = substr(chunk, slash + 1); candidate(chunk) }
93
+ }
94
+ function scan(s, n, i, c, word, whole, flat, expanded, chunk) {
95
+ flat = extglob_star(s)
96
+ if (flat != s) scan(flat)
97
+ n = length(s)
98
+ for (i = 1; i <= n; i++) {
99
+ c = substr(s, i, 1)
100
+ if (c ~ /[ \t\n\r;|&<>]/) { chunk_suffixes(chunk); chunk = "" }
101
+ else chunk = chunk c
102
+ if (c ~ /[ \t\n\r;|&<>()\047"`$=\\]/) {
103
+ candidate(word)
104
+ if (expanded || word ~ /^~/) remainder(word)
105
+ word = ""
106
+ if (c ~ /[`$]/) expanded = 1
107
+ else if (c ~ /[ \t\n\r;|&<>]/) expanded = 0
108
+ }
50
109
  else word = word c
51
110
  if (c ~ /[ \t\n\r;|&<>()\047"`$]/) { candidate(whole); whole = "" }
52
111
  else whole = whole c
53
112
  }
54
- candidate(word); candidate(whole)
113
+ candidate(word); candidate(whole); chunk_suffixes(chunk)
114
+ if (expanded || word ~ /^~/) remainder(word)
55
115
  # Braces have a second boundary view; retain the original pattern above too.
56
116
  if (s ~ /[{}]/) { gsub(/[{}]/, " ", s); scan(s) }
57
117
  }
@@ -84,7 +144,7 @@ function unquote(s, i, c, c2, q, out, quoted) {
84
144
  if (c == "$" && c2 == "\047" && q != "\047") { i = ansi(s, i + 2) - 1; out = out ansi_word; continue }
85
145
  if (c == "\\" && q != "\047") { if (c2 != "\n") { out = out c2; quoted = quoted c2 }; i++; continue }
86
146
  if ((c == "\047" || c == "\"") && (q == "" || q == c)) {
87
- if (q == c) { candidate(quoted); quoted = ""; q = "" } else q = c
147
+ if (q == c) { candidate(quoted_literal(quoted)); quoted = ""; q = "" } else q = c
88
148
  continue
89
149
  }
90
150
  out = out c; if (q != "") quoted = quoted c
@@ -92,20 +152,29 @@ function unquote(s, i, c, c2, q, out, quoted) {
92
152
  return out
93
153
  }
94
154
  function protected(s) { return s in protected_paths }
155
+ # A lexical or structural failure: the command text is not modeled, so write-target mode falls back to
156
+ # classifying the whole text. A command the policy does not accept (cmd_failed) does the same: a protected
157
+ # reference anywhere in a command that is not entirely read-only must keep refusing it.
158
+ # Only when every command is accepted are the words of pure readers dropped from classification.
159
+ function fail() { bad = unparsed = 1 }
160
+ # Reference extraction for one stretch of raw command text.
161
+ function emit_text(t) { scan(t); scan(unquote(t)); raw_brace_scan(t) }
95
162
  function endword() {
96
163
  if (!inword) return
97
164
  if (redirect) {
98
165
  if (!(redirect == 2 && word ~ /^([0-9]+|-)$/)) {
99
166
  file_redirect = 1
100
- if (changed_cwd || word ~ /[$`*?\[{]/ || protected(word)) bad = 1
167
+ if (changed_cwd || lead_glob) unparsed = 1
168
+ if (changed_cwd || word ~ /[$`*?\[{~()]/ || protected(word)) bad = 1
101
169
  }
102
170
  redirect = 0
103
171
  } else {
104
- if (++argc > 256) bad = 1
172
+ if (++argc > 256) fail()
105
173
  W[argc] = word
106
174
  globbed[argc] = glob
175
+ leading[argc] = lead_glob
107
176
  }
108
- word = ""; inword = glob = 0
177
+ word = ""; inword = glob = lead_glob = 0
109
178
  }
110
179
  # Each exemption permits only the reviewed read/presentation options below. No unknown
111
180
  # options, long-option abbreviations or implicit value-taking short clusters are accepted.
@@ -150,6 +219,8 @@ function options_allowed(verb, first, i, w) {
150
219
  if (w == "-m" || w == "--message") { if (++i > argc) return 0; continue }
151
220
  if (w ~ /^-m./) continue
152
221
  if (w == "-F") {
222
+ # Whether the file is protected is decided from the reference list, so its words are kept.
223
+ force_emit = 1
153
224
  if (++i > argc || W[i] ~ /[$`*?\[{]/ || protected(W[i])) return 0
154
225
  continue
155
226
  }
@@ -162,6 +233,20 @@ function options_allowed(verb, first, i, w) {
162
233
  }
163
234
  return 1
164
235
  }
236
+ # awk is read-only only for the shape awk [-F sep] 'program' operands. Every other option (-f, -v, -e, -i,
237
+ # --include, --, ...) is refused. awk output, execution and file reads need one of > | system getline close
238
+ # fflush or the gawk @ directives; a program containing any of them (in any letter case) is not accepted.
239
+ # This deny-list relies on awk having no other output primitive, which holds for POSIX, gawk, mawk and BSD awk.
240
+ function awk_allowed( i, w, program) {
241
+ i = 2
242
+ if (W[i] == "-F") { if (++i > argc || W[i] ~ /[$`]/ || globbed[i]) return 0; i++ }
243
+ else if (W[i] ~ /^-F/) { if (W[i] ~ /[$`]/ || globbed[i]) return 0; i++ }
244
+ if (i > argc || W[i] ~ /^-/ || globbed[i]) return 0
245
+ program = tolower(W[i])
246
+ if (program ~ /[>|@]/ || index(program, "system") || index(program, "getline") || index(program, "close") || index(program, "fflush")) return 0
247
+ for (i++; i <= argc; i++) if (W[i] ~ /^-/ && W[i] != "-") return 0
248
+ return 1
249
+ }
165
250
  # Only literal git -C metadata (with exact arity) or staging/commit commands
166
251
  # (with their normal option checks) are exempt; no other global option is.
167
252
  # -C gives no protection from hostile repository config (fsmonitor, hooks, pager,
@@ -181,72 +266,114 @@ function print_only_sed( i, ended) {
181
266
  }
182
267
  return 1
183
268
  }
184
- function allow_command( verb, first) {
269
+ # Verbs whose reviewed options are display flags only: a word-leading glob that expands to an option-shaped
270
+ # file name can change what they print, never what they write or run. Every other verb refuses a leading glob.
271
+ function glob_safe() {
272
+ return W[1] ~ /^(cat|head|tail|wc|ls|grep|egrep|fgrep)$/ || (W[1] == "git" && W[2] == "ls-files")
273
+ }
274
+ # The two managed corpus scripts are admitted for execution only by exact literal spelling: the path is
275
+ # compared as a whole word (no ./, .., variable, glob or quoting variant can equal it), every other word must
276
+ # be one of the script's own documented options, and nothing is admitted after a directory change, which
277
+ # would select a different checkout's copy. Redirects stay classified by the caller.
278
+ function managed_script( i) {
279
+ if (changed_cwd) return 0
280
+ if (W[1] == "node" && W[2] == ".cratis/ai/hooks/scripts/cratis-check-pr.mjs") {
281
+ for (i = 3; i <= argc; i++) {
282
+ if (W[i] == "--strict") continue
283
+ if (W[i] !~ /^--(body-file|label|add-label|remove-label|pr|base|repo)$/) return 0
284
+ if (++i > argc || W[i] == "" || W[i] ~ /^-/ || globbed[i]) return 0
285
+ }
286
+ return 1
287
+ }
288
+ if (W[1] == "bash" && W[2] == ".cratis/ai/hooks/scripts/cratis-cleanup-worktrees.sh") {
289
+ for (i = 3; i <= argc; i++) if (W[i] !~ /^--(dry-run|quiet|no-fetch)$/) return 0
290
+ return 1
291
+ }
292
+ return 0
293
+ }
294
+ function allow_command( verb, first, i) {
185
295
  if (!argc) return
186
- if (++commands > 64) { bad = 1; return }
296
+ if (++commands > 64) { fail(); return }
297
+ for (i = 1; i <= argc; i++) if (leading[i] && !glob_safe()) { cmd_failed = 1; return }
298
+ if (managed_script()) return
187
299
  verb = W[1]; first = 2
188
300
  if (verb == "cd") {
189
301
  directory_only = 1
190
- if (argc != 2 || W[2] == "" || W[2] ~ /^-/ || globbed[2] || file_redirect) bad = 1
302
+ if (argc != 2 || W[2] == "" || W[2] ~ /^-/ || globbed[2] || file_redirect) fail()
191
303
  changed_cwd = 1
192
304
  return
193
305
  }
194
- if (verb == "sed") { if (!print_only_sed()) bad = 1; return }
306
+ if (verb == "sed") { if (!print_only_sed()) cmd_failed = 1; return }
195
307
  if (verb == "git" && W[2] == "-C") {
196
308
  if (argc >= 4 && W[3] != "" && W[3] !~ /^-/ && !globbed[3] && W[4] ~ /^(add|commit)$/) {
197
309
  verb = verb " " W[4]; first = 5
198
310
  } else {
199
- if (!directory_metadata()) bad = 1
311
+ if (!directory_metadata()) cmd_failed = 1
200
312
  return
201
313
  }
202
314
  } else if (verb == "git") { verb = verb " " W[2]; first = 3 }
203
315
  if (verb == "git add" || verb == "git commit") changed_index = 1
204
316
  if (verb == "git branch") {
205
317
  conditional_only = 1
206
- if (argc != 3 || W[3] != "--show-current") { bad = 1; return }
318
+ if (argc != 3 || W[3] != "--show-current") { cmd_failed = 1; return }
207
319
  }
208
- if (!(verb in verbs) || !options_allowed(verb, first)) bad = 1
320
+ if (verb == "awk") { if (!awk_allowed()) cmd_failed = 1; return }
321
+ if (!(verb in verbs) || !options_allowed(verb, first)) cmd_failed = 1
209
322
  }
210
- function command_end(separator) {
211
- endword(); allow_command()
212
- if (W[1] == "cd" && (separator == "|" || previous_pipe)) bad = 1
323
+ # `upto` is the index just past the command's raw text; `resume` is where the next command's raw text starts.
324
+ # A command whose policy accepts it, with no redirect and no directory change, is a pure reader and its words
325
+ # are not write targets; every other command keeps all of its raw text classified.
326
+ function command_end(separator, upto, resume, silent) {
327
+ endword(); cmd_failed = 0; allow_command()
328
+ if (cmd_failed) { bad = 1; unparsed = 1 }
329
+ if (W[1] == "cd" && (separator == "|" || previous_pipe)) fail()
330
+ silent = argc && !cmd_failed && !cmd_redirect && !force_emit && W[1] != "cd"
331
+ if (!silent && upto > seg_start) emitted[++emitted_count] = substr(lexed, seg_start, upto - seg_start)
332
+ seg_start = resume
213
333
  previous_pipe = (separator == "|")
214
- delete W; delete globbed; argc = 0
334
+ cmd_redirect = force_emit = 0
335
+ delete W; delete globbed; delete leading; argc = 0
215
336
  }
216
337
  function readonly(s, i, c, c2, sq, dq) {
338
+ lexed = s; seg_start = 1
217
339
  for (i = 1; i <= length(s); i++) {
218
340
  c = substr(s, i, 1); c2 = substr(s, i + 1, 1)
219
341
  if (sq) { if (c == "\047") sq = 0; else word = word c; continue }
220
- if (c == "\\") { if (c2 != "\n") { word = word c2; inword = 1 }; i++; continue }
342
+ if (c == "\\") { if (c2 != "\n") { word = word c2; inword = 1 } else unparsed = 1; i++; continue }
221
343
  if (c == "\047" && !dq) { sq = inword = 1; continue }
222
344
  if (c == "\"") { dq = !dq; inword = 1; continue }
223
345
  # Expansions and globs can supply option words the per-verb tables never see.
224
- if (c == "`" || c == "$") bad = 1
346
+ if (c == "`" || c == "$") fail()
225
347
  if (dq) { word = word c; continue }
226
348
  # Directory metadata requires a literal -C operand, not a pathname expansion.
227
349
  if (c == "*" || c == "?" || c == "[") glob = 1
228
350
  # A glob that starts a word, or follows a leading dash, may expand to an option word.
229
- if ((c == "*" || c == "?" || c == "[") && (word == "" ? !(c == "[" && c2 ~ /[ \t]/) : substr(word, 1, 1) == "-")) bad = 1
351
+ # Only a word-leading * or ? is deferred to the per-verb rule; one after a leading dash, or a leading
352
+ # bracket class (`[-]*` can name an option), is refused outright.
353
+ if ((c == "*" || c == "?" || c == "[") && (word == "" ? !(c == "[" && c2 ~ /[ \t]/) : substr(word, 1, 1) == "-")) {
354
+ if (c == "[" || word != "") fail(); else lead_glob = 1
355
+ }
230
356
  if (c == "#" && !inword) { while (i <= length(s) && substr(s, i, 1) != "\n") i++; c = "\n" }
231
- if (c == "(" || c == ")" || c == "{" || c == "}") bad = 1
357
+ if (c == "(" || c == ")" || c == "{" || c == "}") fail()
232
358
  if (c == ">" || c == "<" || (c == "&" && c2 == ">")) {
359
+ cmd_redirect = 1
233
360
  if (inword && word ~ /^[0-9]+$/) { word = ""; inword = 0 } else endword()
234
- if (redirect) bad = 1
235
- if (c == "<" && (c2 == "<" || c2 == "(")) bad = 1
361
+ if (redirect) fail()
362
+ if (c == "<" && (c2 == "<" || c2 == "(")) fail()
236
363
  redirect = c == ">" || c == "&" || (c == "<" && c2 == ">")
237
364
  if (c == ">" && c2 == "&") redirect = 2
238
365
  if (c2 ~ /[><&|]/) { i++; if (substr(s, i + 1, 1) == ">") i++ }
239
366
  continue
240
367
  }
241
- if (c == "&" && c2 == "&") { command_end("&&"); if (redirect) bad = 1; i++; continue }
242
- if (c == "|" && c2 != "|") { has_pipeline = 1; command_end("|"); if (redirect) bad = 1; continue }
243
- if (c ~ /[;|&\n]/) { nonconditional_separator = 1; command_end(c); if (redirect) bad = 1; continue }
368
+ if (c == "&" && c2 == "&") { command_end("&&", i, i + 2); if (redirect) fail(); i++; continue }
369
+ if (c == "|" && c2 != "|") { has_pipeline = 1; command_end("|", i, i + 1); if (redirect) fail(); continue }
370
+ if (c ~ /[;|&\n]/) { nonconditional_separator = 1; command_end(c, i, i + 1); if (redirect) fail(); continue }
244
371
  if (c ~ /[ \t\r]/) { endword(); continue }
245
372
  word = word c; inword = 1
246
373
  }
247
- command_end()
374
+ command_end("", length(s) + 1, length(s) + 1)
248
375
  if (sq || dq || redirect || (conditional_only && (nonconditional_separator || has_pipeline)) ||
249
- (directory_only && (nonconditional_separator || (has_pipeline && changed_index)))) bad = 1
376
+ (directory_only && (nonconditional_separator || (has_pipeline && changed_index)))) fail()
250
377
  return !bad
251
378
  }
252
379
  BEGIN {
@@ -260,6 +387,10 @@ BEGIN {
260
387
  policy("printf", "", ""); policy("test", "", ""); policy("[", "", "")
261
388
  policy("true", "", ""); policy("false", "", ""); policy("pwd", "", "")
262
389
  policy("df", "h", "")
390
+ # jq has no file-write or exec primitive (output goes to stdout, debug to stderr), so its filter is a plain
391
+ # operand. No value-taking option is accepted (--arg, -f, -L, --rawfile, --slurpfile, --from-file, --indent).
392
+ policy("jq", "rcesnRSjaMC", "--raw-output --compact-output --slurp --null-input --exit-status --raw-input --sort-keys --join-output --ascii-output --monochrome-output --tab")
393
+ policy("awk", "", "")
263
394
  policy("git status", "sb", "--short --porcelain")
264
395
  policy("git diff", "p", "--stat --numstat --name-only --name-status --cached --staged --check --no-color --cc")
265
396
  policy("git log", "p", "--oneline --stat --name-only --no-color --follow")
@@ -271,12 +402,18 @@ BEGIN {
271
402
  for (i = 0; i < 16; i++) HEX[substr("0123456789abcdef", i + 1, 1)] = i
272
403
  ESC["n"] = 10; ESC["r"] = 13; ESC["t"] = 9; ESC["\\"] = 92; ESC["\047"] = 39; ESC["\""] = 34
273
404
  text = ENVIRON["GSW_COMMAND"]
274
- if (ENVIRON["GSW_MODE"] == "references") { scan(text); scan(unquote(text)); exit 0 }
405
+ if (ENVIRON["GSW_MODE"] == "references") { emit_text(text); exit 0 }
406
+ if (ENVIRON["GSW_MODE"] == "targets") {
407
+ readonly(text)
408
+ if (unparsed) emit_text(text)
409
+ else for (i = 1; i <= emitted_count; i++) emit_text(emitted[i])
410
+ exit 0
411
+ }
275
412
  n = split(ENVIRON["GSW_PROTECTED"], a, "\n"); for (i = 1; i <= n; i++) protected_paths[a[i]] = 1
276
413
  exit readonly(text) ? 0 : 1
277
414
  }
278
415
  AWK
279
- candidates_text="$(GSW_COMMAND="$command_text" GSW_MODE=references LC_ALL=C awk "$program" </dev/null)" || parser_failed
416
+ candidates_text="$(GSW_COMMAND="$command_text" GSW_MODE=targets LC_ALL=C awk "$program" </dev/null)" || parser_failed
280
417
  [ -n "$candidates_text" ] || exit 0
281
418
  candidates=()
282
419
  while IFS= read -r candidate; do candidates[${#candidates[@]}]="$candidate"; done <<<"$candidates_text"
@@ -288,11 +425,21 @@ classifier="$script_directory/cratis-guard-writes.sh"
288
425
  classifier_input="$(jq -nc --arg cwd "$cwd" --args '{cwd:$cwd,tool_input:{file_paths:$ARGS.positional}}' -- "${candidates[@]}")" || parser_failed
289
426
  # Tool labels and this hook shell do not establish the execution shell options.
290
427
  # Keep conservative dotfile intersections for every command, especially mutators.
291
- references="$("$BASH" "$classifier" --references <<<"$classifier_input")" || {
428
+ classifier_error="$(mktemp)" || parser_failed
429
+ trap 'rm -f "$classifier_error"' EXIT
430
+ references="$("$BASH" "$classifier" --references <<<"$classifier_input" 2>"$classifier_error")" || {
431
+ # A command that is not read-only is refused whatever the classifier could model, so an unmodeled word
432
+ # (for example program text inside an interpreter heredoc) must not hide the refusal behind a parser
433
+ # failure. A read-only command keeps the fail-closed parser failure.
434
+ if ! GSW_COMMAND="$command_text" GSW_MODE=readonly GSW_PROTECTED="" LC_ALL=C awk "$program" </dev/null; then
435
+ printf '%s\n' 'BLOCKED by cratis-guard-shell-writes: this command is not read-only and its references could not all be modeled; use the edit/write tools, or report the intended change.' >&2
436
+ exit 2
437
+ fi
438
+ cat "$classifier_error" >&2
292
439
  printf '%s\n' 'BLOCKED by cratis-guard-shell-writes: could not check references (write guard failed).' >&2
293
440
  exit 2
294
441
  }
295
442
  [ -n "$references" ] || exit 0
296
443
  if GSW_COMMAND="$command_text" GSW_MODE=readonly GSW_PROTECTED="$references" LC_ALL=C awk "$program" </dev/null; then exit 0; fi
297
- printf "BLOCKED by cratis-guard-shell-writes: protected reference '%s' (cratis-guard-writes). Use the edit/write tools, or report the intended change.\n" "${references%%$'\n'*}" >&2
444
+ printf "BLOCKED by cratis-guard-shell-writes: protected reference '%s' (cratis-guard-writes). Use the edit/write tools, or report the intended change; for a read, name literal paths or use the Read/Grep tools.\n" "${references%%$'\n'*}" >&2
298
445
  exit 2
@@ -206,12 +206,14 @@ function tokens(s, side, i, c, j, k, t, copy, jumps, first, closing) {
206
206
  s = tolower(s)
207
207
  if (side == 1) {
208
208
  copy = s
209
+ if (s ~ /[@?*+!]\(/) exit 2
209
210
  if (index(s, "{") && index(s, "[")) exit 2
210
211
  if (gsub(/\[/, "[", copy) > 64) exit 2
211
212
  first = index(s, "{")
212
213
  for (k = length(s); k > first; k--) if (substr(s, k, 1) == "}") { closing = k; break }
213
214
  if (first && closing) {
214
215
  if (index(substr(s, first, closing - first + 1), "/")) exit 2
216
+ if (substr(s, first, closing - first + 1) ~ /[$`'"\\]/) exit 2
215
217
  if (substr(s, 1, first - 1) substr(s, closing + 1) ~ /[^a-z0-9._\/*?,+=:@%-]/) exit 2
216
218
  s = substr(s, 1, first) substr(s, closing)
217
219
  }
@@ -425,7 +427,7 @@ if [ "$reference_mode" = 1 ]; then
425
427
  new_content=""
426
428
  for candidate in "${candidates[@]}"; do
427
429
  reference_pattern=0
428
- case "$candidate" in *'*'* | *'?'* | *'['* | *'{'*) reference_pattern=1 ;; esac
430
+ case "$candidate" in *'*'* | *'?'* | *'['* | *'{'* | *'@('* | *'+('* | *'!('*) reference_pattern=1 ;; esac
429
431
  if classify_file "$candidate" "$reference_pattern"; then printf '%s\n' "$candidate"; continue; fi
430
432
  # Existing generated files can have arbitrary names; inspect actual glob matches too.
431
433
  if [ "$reference_pattern" = 1 ]; then
@@ -25,7 +25,7 @@
25
25
  - Formatting and recovery limits
26
26
  - Code attachments
27
27
 
28
- The standalone MCP server lists 47 tools from Screenplay 6.0 (including the MCP-Apps visualization tool and `migrate`); `tools/list` is the authority for the installed server, and the CLI-bundled MCP (`cratis screenplay mcp`) can be an older Screenplay that lacks newer tools.
28
+ The standalone MCP server lists 48 tools as of Screenplay 6.11 (including the MCP-Apps visualization tool, `migrate` and `list-storylines`); `tools/list` is the authority for the installed server, and the CLI-bundled MCP (`cratis screenplay mcp`) can be an older Screenplay that lacks newer tools.
29
29
 
30
30
  The supported CLI launch is `cratis screenplay mcp <model-root>`, or `cratis screenplay mcp`
31
31
  alone inside a project, where the CLI reuses existing model/workspace roots.
@@ -66,7 +66,7 @@ the [MCP loop](mcp-loop.md).
66
66
 
67
67
  | Group | Tools | Intent |
68
68
  | --- | --- | --- |
69
- | Understanding | `describe-application`, `search-declarations`, `find-declaration`, `declaration-details` | Navigate logical hierarchy and inspect bounded details |
69
+ | Understanding | `describe-application`, `search-declarations`, `find-declaration`, `declaration-details`, `list-storylines` (one optional argument) | Navigate logical hierarchy, inspect bounded details and list storylines |
70
70
  | References and examples | `find-references`, `dependencies`, `dependency-graph`, `find-fixtures`, `find-assertion-gaps`, `find-specification-obligations`, `find-modeling-smells`, `trace-lineage`, `semantic-diff` | Inspect declared relationships and authored examples, not executed coverage |
71
71
  | Source and validation | `diagnostics`, `ui-profiles` (also the design system, themes and resolved values per mode), `read-document`, `merged-document`, `syntax-schema` | Read exact source or typed structure and diagnose problems |
72
72
  | Workspace inspection | `open-workspace`, `read-workspace`, `read-ast`, `workspace-state`, `export-workspace`, `repair-capabilities` | Obtain current identities, handles, readiness, code attachment requirements, source-map locations, durable-state status and the repair catalog |