safeword 0.4.0 → 0.4.1
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 +1 -1
- package/templates/hooks/stop-quality.sh +23 -18
package/package.json
CHANGED
|
@@ -5,40 +5,45 @@
|
|
|
5
5
|
# Change to project directory if set
|
|
6
6
|
[ -n "$CLAUDE_PROJECT_DIR" ] && cd "$CLAUDE_PROJECT_DIR"
|
|
7
7
|
|
|
8
|
+
# Default JSON response (no changes)
|
|
9
|
+
json_response() {
|
|
10
|
+
local msg="$1"
|
|
11
|
+
if [ -n "$msg" ]; then
|
|
12
|
+
echo "{\"proposedChanges\": false, \"madeChanges\": false, \"askedQuestion\": false, \"message\": \"$msg\"}"
|
|
13
|
+
else
|
|
14
|
+
echo '{"proposedChanges": false, "madeChanges": false, "askedQuestion": false}'
|
|
15
|
+
fi
|
|
16
|
+
}
|
|
17
|
+
|
|
8
18
|
if [ ! -d ".safeword" ]; then
|
|
19
|
+
json_response
|
|
9
20
|
exit 0
|
|
10
21
|
fi
|
|
11
22
|
|
|
12
23
|
# Check if there are uncommitted changes
|
|
13
24
|
if ! command -v git &> /dev/null; then
|
|
25
|
+
json_response
|
|
14
26
|
exit 0
|
|
15
27
|
fi
|
|
16
28
|
|
|
17
29
|
if [ ! -d ".git" ]; then
|
|
30
|
+
json_response
|
|
18
31
|
exit 0
|
|
19
32
|
fi
|
|
20
33
|
|
|
21
34
|
# Check for modified files
|
|
22
|
-
changed_files=$(git diff --name-only 2>/dev/null | head -
|
|
23
|
-
staged_files=$(git diff --staged --name-only 2>/dev/null | head -
|
|
35
|
+
changed_files=$(git diff --name-only 2>/dev/null | head -10)
|
|
36
|
+
staged_files=$(git diff --staged --name-only 2>/dev/null | head -10)
|
|
24
37
|
|
|
25
38
|
if [ -n "$changed_files" ] || [ -n "$staged_files" ]; then
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
echo "
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
done
|
|
35
|
-
fi
|
|
36
|
-
|
|
37
|
-
if [ -n "$changed_files" ]; then
|
|
38
|
-
echo "$changed_files" | while read -r file; do
|
|
39
|
-
echo " $file"
|
|
40
|
-
done
|
|
41
|
-
fi
|
|
39
|
+
# Build file list for message
|
|
40
|
+
file_count=0
|
|
41
|
+
[ -n "$staged_files" ] && file_count=$((file_count + $(echo "$staged_files" | wc -l)))
|
|
42
|
+
[ -n "$changed_files" ] && file_count=$((file_count + $(echo "$changed_files" | wc -l)))
|
|
43
|
+
|
|
44
|
+
json_response "SAFEWORD: $file_count file(s) modified. Consider '/quality-review' before committing."
|
|
45
|
+
else
|
|
46
|
+
json_response
|
|
42
47
|
fi
|
|
43
48
|
|
|
44
49
|
exit 0
|