@cratis/pi 7.131.2 → 7.131.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,23 +42,28 @@ parser_failed() {
42
42
 
43
43
  # One jq call reads every field the guard uses. Fields are NUL-terminated (embedded NULs are dropped,
44
44
  # as a command substitution would drop them); a missing, null or false path is empty.
45
- cwd="" file="" notebook="" new_content="" new_string=""
45
+ # The process substitution's exit status does not reach the reading group, and Bash 3.2 (macOS /bin/bash)
46
+ # cannot wait on its PID, so a sentinel field is written only after jq succeeds.
47
+ cwd="" file="" notebook="" new_content="" new_string="" parser_status=""
46
48
  {
47
49
  IFS= read -r -d '' cwd
48
50
  IFS= read -r -d '' file
49
51
  IFS= read -r -d '' notebook
50
52
  IFS= read -r -d '' new_content
51
53
  IFS= read -r -d '' new_string
52
- } < <(jq -j '
54
+ IFS= read -r -d '' parser_status
55
+ } < <(jq -j -s '
53
56
  def field(path): ([try (path // empty) catch empty] | first // "")
54
57
  | if type == "string" then . else tojson end
55
58
  | gsub("\u0000"; "");
56
- [field(.cwd), field(.tool_input.file_path), field(.tool_input.notebook_path),
59
+ # Slurping parses the whole input before any output, and exactly one document is accepted,
60
+ # so no field from a later document can stand in for the sentinel.
61
+ if length == 1 then .[0] else error("expected one JSON document") end
62
+ | [field(.cwd), field(.tool_input.file_path), field(.tool_input.notebook_path),
57
63
  field(.tool_input.content), field(.tool_input.new_string)]
58
64
  | .[] | ., "\u0000"
59
- ' <<<"$input" 2>/dev/null) || parser_failed
60
- # Process substitutions do not propagate their exit status to the reading group.
61
- wait "$!" || parser_failed
65
+ ' <<<"$input" 2>/dev/null && printf 'ok\0') || parser_failed
66
+ [ "$parser_status" = "ok" ] || parser_failed
62
67
  # Command substitution stripped trailing newlines from each field; keep that behaviour.
63
68
  for field_name in cwd file notebook new_content new_string; do
64
69
  while [[ "${!field_name}" == *$'\n' ]]; do printf -v "$field_name" '%s' "${!field_name%$'\n'}"; done
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cratis/pi",
3
- "version": "7.131.2",
3
+ "version": "7.131.3",
4
4
  "description": "Configuration-aware Cratis AI integration for Pi",
5
5
  "type": "module",
6
6
  "files": [