cc-safe-setup 29.6.7 → 29.6.8
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.
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
#!/bin/bash
|
|
2
|
+
# ================================================================
|
|
3
|
+
# markdown-link-check.sh — Verify local file links in markdown
|
|
4
|
+
# ================================================================
|
|
5
|
+
# PURPOSE:
|
|
6
|
+
# After Claude edits a markdown file, check that all local file
|
|
7
|
+
# references (relative paths) actually exist. Catches broken
|
|
8
|
+
# links to images, other docs, or code files.
|
|
9
|
+
#
|
|
10
|
+
# TRIGGER: PostToolUse
|
|
11
|
+
# MATCHER: "Edit|Write"
|
|
12
|
+
# ================================================================
|
|
13
|
+
|
|
14
|
+
INPUT=$(cat)
|
|
15
|
+
FILE=$(echo "$INPUT" | jq -r '.tool_input.file_path // empty' 2>/dev/null)
|
|
16
|
+
|
|
17
|
+
[ -z "$FILE" ] && exit 0
|
|
18
|
+
echo "$FILE" | grep -qiE '\.md$|\.mdx$' || exit 0
|
|
19
|
+
[ -f "$FILE" ] || exit 0
|
|
20
|
+
|
|
21
|
+
DIR=$(dirname "$FILE")
|
|
22
|
+
BROKEN=0
|
|
23
|
+
|
|
24
|
+
# Extract markdown links: [text](path) — skip URLs and anchors
|
|
25
|
+
while IFS= read -r link; do
|
|
26
|
+
# Skip URLs, anchors, and mailto
|
|
27
|
+
echo "$link" | grep -qE '^(https?://|#|mailto:)' && continue
|
|
28
|
+
# Remove anchor part
|
|
29
|
+
CLEAN=$(echo "$link" | sed 's/#.*//')
|
|
30
|
+
[ -z "$CLEAN" ] && continue
|
|
31
|
+
# Resolve relative path
|
|
32
|
+
TARGET="$DIR/$CLEAN"
|
|
33
|
+
if [ ! -e "$TARGET" ]; then
|
|
34
|
+
echo "⚠ Broken link in $FILE: $link" >&2
|
|
35
|
+
BROKEN=$((BROKEN + 1))
|
|
36
|
+
fi
|
|
37
|
+
done < <(grep -oE '\]\([^)]+\)' "$FILE" 2>/dev/null | sed 's/\](\(.*\))/\1/')
|
|
38
|
+
|
|
39
|
+
if [ "$BROKEN" -gt 0 ]; then
|
|
40
|
+
echo " $BROKEN broken link(s) found." >&2
|
|
41
|
+
fi
|
|
42
|
+
|
|
43
|
+
exit 0
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "cc-safe-setup",
|
|
3
|
-
"version": "29.6.
|
|
4
|
-
"description": "One command to make Claude Code safe.
|
|
3
|
+
"version": "29.6.8",
|
|
4
|
+
"description": "One command to make Claude Code safe. 418 example hooks + 8 built-in. 52 CLI commands. 5646 tests. Works with Auto Mode.",
|
|
5
5
|
"main": "index.mjs",
|
|
6
6
|
"bin": {
|
|
7
7
|
"cc-safe-setup": "index.mjs"
|