safeword 0.6.2 → 0.6.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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "safeword",
3
- "version": "0.6.2",
3
+ "version": "0.6.3",
4
4
  "description": "CLI for setting up and managing safeword development environments",
5
5
  "type": "module",
6
6
  "bin": {
@@ -19,18 +19,6 @@
19
19
  "engines": {
20
20
  "node": ">=18"
21
21
  },
22
- "scripts": {
23
- "build": "tsup",
24
- "dev": "tsup --watch",
25
- "test": "vitest run",
26
- "test:e2e": "vitest run tests/e2e/",
27
- "test:watch": "vitest",
28
- "test:coverage": "vitest run --coverage",
29
- "typecheck": "tsc --noEmit",
30
- "lint": "eslint src tests",
31
- "clean": "rm -rf dist",
32
- "prepublishOnly": "npm audit --audit-level=high && npm run build && npm test"
33
- },
34
22
  "dependencies": {
35
23
  "commander": "^12.1.0"
36
24
  },
@@ -48,5 +36,16 @@
48
36
  "claude-code"
49
37
  ],
50
38
  "author": "",
51
- "license": "MIT"
52
- }
39
+ "license": "MIT",
40
+ "scripts": {
41
+ "build": "tsup",
42
+ "dev": "tsup --watch",
43
+ "test": "vitest run",
44
+ "test:e2e": "vitest run tests/e2e/",
45
+ "test:watch": "vitest",
46
+ "test:coverage": "vitest run --coverage",
47
+ "typecheck": "tsc --noEmit",
48
+ "lint": "eslint src tests",
49
+ "clean": "rm -rf dist"
50
+ }
51
+ }
@@ -42,21 +42,31 @@ if [ -z "$msg_text" ]; then
42
42
  exit 0
43
43
  fi
44
44
 
45
- # Extract the JSON blob from the end of the message
46
- # Pattern: {"proposedChanges": boolean, "madeChanges": boolean, "askedQuestion": boolean}
47
- json_blob=$(echo "$msg_text" | grep -oE '\{"proposedChanges":\s*(true|false)\s*,\s*"madeChanges":\s*(true|false)\s*,\s*"askedQuestion":\s*(true|false)\s*\}' | tail -1)
45
+ # Extract JSON blob containing our required fields (order-independent)
46
+ # Strategy: Use jq to find and validate the response summary object
47
+ # Look for object with exactly our three boolean fields anywhere in the text
48
+ json_blob=$(echo "$msg_text" | grep -oE '\{[^}]+\}' | while IFS= read -r candidate; do
49
+ if echo "$candidate" | jq -e '
50
+ type == "object" and
51
+ (.proposedChanges | type) == "boolean" and
52
+ (.madeChanges | type) == "boolean" and
53
+ (.askedQuestion | type) == "boolean"
54
+ ' >/dev/null 2>&1; then
55
+ echo "$candidate"
56
+ fi
57
+ done | tail -1)
48
58
 
49
59
  if [ -z "$json_blob" ]; then
50
- # No JSON blob found - remind about required format
60
+ # No valid JSON blob found - remind about required format
51
61
  echo "SAFEWORD: Response missing required JSON summary. Add to end of response:" >&2
52
62
  echo '{"proposedChanges": boolean, "madeChanges": boolean, "askedQuestion": boolean}' >&2
53
63
  exit 0
54
64
  fi
55
65
 
56
- # Parse the boolean values
57
- proposed_changes=$(echo "$json_blob" | jq -r '.proposedChanges // false' 2>/dev/null)
58
- made_changes=$(echo "$json_blob" | jq -r '.madeChanges // false' 2>/dev/null)
59
- asked_question=$(echo "$json_blob" | jq -r '.askedQuestion // false' 2>/dev/null)
66
+ # Parse the boolean values (already validated, safe to extract)
67
+ proposed_changes=$(echo "$json_blob" | jq -r '.proposedChanges')
68
+ made_changes=$(echo "$json_blob" | jq -r '.madeChanges')
69
+ asked_question=$(echo "$json_blob" | jq -r '.askedQuestion')
60
70
 
61
71
  # If asked a question, don't trigger review (waiting for user input)
62
72
  if [ "$asked_question" = "true" ]; then
@@ -67,7 +77,9 @@ fi
67
77
  if [ "$proposed_changes" = "true" ] || [ "$made_changes" = "true" ]; then
68
78
  echo "SAFEWORD Quality Review:" >&2
69
79
  echo "" >&2
70
- echo "Double check and critique your work:" >&2
80
+ echo "Double check and critique your work again just in case." >&2
81
+ echo "Assume you've never seen it before." >&2
82
+ echo "" >&2
71
83
  echo "- Is it correct?" >&2
72
84
  echo "- Is it elegant?" >&2
73
85
  echo "- Does it follow latest docs/best practices?" >&2