@mallardbay/cursor-rules 1.0.15 → 1.0.18
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/bin/setup-cursor.sh +79 -5
- package/package.json +1 -1
package/bin/setup-cursor.sh
CHANGED
|
@@ -16,13 +16,61 @@ fi
|
|
|
16
16
|
PROJECT_DIR="$(pwd)"
|
|
17
17
|
echo "Setting up in project directory: $PROJECT_DIR"
|
|
18
18
|
|
|
19
|
-
# Get the real path of the script (
|
|
19
|
+
# Get the real path of the script, following symlinks (for npx compatibility)
|
|
20
|
+
# When run via npx, $0 points to a symlink in the npx cache
|
|
20
21
|
get_real_path() {
|
|
21
22
|
local path="$1"
|
|
23
|
+
# Try readlink -f (Linux) or readlink with manual resolution (macOS)
|
|
24
|
+
if command -v readlink >/dev/null 2>&1; then
|
|
25
|
+
local resolved
|
|
26
|
+
resolved=$(readlink "$path" 2>/dev/null)
|
|
27
|
+
if [ -n "$resolved" ]; then
|
|
28
|
+
# If relative symlink, resolve relative to directory of original path
|
|
29
|
+
if [[ "$resolved" != /* ]]; then
|
|
30
|
+
resolved="$(cd "$(dirname "$path")" && cd "$(dirname "$resolved")" && pwd -P)/$(basename "$resolved")"
|
|
31
|
+
fi
|
|
32
|
+
path="$resolved"
|
|
33
|
+
fi
|
|
34
|
+
fi
|
|
22
35
|
cd "$(dirname "$path")" && echo "$(pwd -P)/$(basename "$path")"
|
|
23
36
|
}
|
|
37
|
+
|
|
24
38
|
SCRIPT_PATH="$(get_real_path "$0")"
|
|
25
|
-
|
|
39
|
+
SCRIPT_DIR="$(cd "$(dirname "$SCRIPT_PATH")" && pwd -P)"
|
|
40
|
+
|
|
41
|
+
# The script is at bin/setup-cursor.sh, so go up one level to get package root
|
|
42
|
+
SRC_DIR="$(cd "$SCRIPT_DIR/.." && pwd -P)"
|
|
43
|
+
|
|
44
|
+
# When run via npx, if .cursor doesn't exist at SRC_DIR, find the actual package location
|
|
45
|
+
if [ ! -d "$SRC_DIR/.cursor/shared/skills" ]; then
|
|
46
|
+
# Try multiple possible locations for the package
|
|
47
|
+
# When SRC_DIR is node_modules, package is at SRC_DIR/@mallardbay/cursor-rules
|
|
48
|
+
# When SRC_DIR is _npx cache, package might be at SRC_DIR/node_modules/@mallardbay/cursor-rules
|
|
49
|
+
POSSIBLE_LOCATIONS=(
|
|
50
|
+
"$SRC_DIR/@mallardbay/cursor-rules"
|
|
51
|
+
"$SRC_DIR/node_modules/@mallardbay/cursor-rules"
|
|
52
|
+
"$(dirname "$SRC_DIR")/@mallardbay/cursor-rules"
|
|
53
|
+
"$(dirname "$(dirname "$SRC_DIR"))/@mallardbay/cursor-rules"
|
|
54
|
+
)
|
|
55
|
+
|
|
56
|
+
for location in "${POSSIBLE_LOCATIONS[@]}"; do
|
|
57
|
+
if [ -d "$location/.cursor/shared/skills" ]; then
|
|
58
|
+
SRC_DIR="$location"
|
|
59
|
+
break
|
|
60
|
+
fi
|
|
61
|
+
done
|
|
62
|
+
|
|
63
|
+
# If still not found, search for package.json with our name
|
|
64
|
+
if [ ! -d "$SRC_DIR/.cursor/shared/skills" ]; then
|
|
65
|
+
PACKAGE_ROOT=$(find "$(dirname "$SRC_DIR")" -maxdepth 5 -type f -name "package.json" -exec grep -l '"name":\s*"@mallardbay/cursor-rules"' {} \; 2>/dev/null | head -1 | xargs dirname 2>/dev/null)
|
|
66
|
+
if [ -n "$PACKAGE_ROOT" ] && [ -d "$PACKAGE_ROOT/.cursor/shared/skills" ]; then
|
|
67
|
+
SRC_DIR="$PACKAGE_ROOT"
|
|
68
|
+
fi
|
|
69
|
+
fi
|
|
70
|
+
fi
|
|
71
|
+
|
|
72
|
+
echo "DEBUG: Final SRC_DIR=$SRC_DIR"
|
|
73
|
+
echo "DEBUG: Checking if .cursor/shared/skills exists: $([ -d "$SRC_DIR/.cursor/shared/skills" ] && echo "YES" || echo "NO")"
|
|
26
74
|
|
|
27
75
|
SHARED_DIR="$SRC_DIR/.cursor/shared/rules"
|
|
28
76
|
FRONTEND_DIR="$SRC_DIR/.cursor/frontend/rules"
|
|
@@ -50,23 +98,47 @@ copy_rules() {
|
|
|
50
98
|
|
|
51
99
|
copy_skills() {
|
|
52
100
|
local DIR="$1"
|
|
101
|
+
echo "DEBUG: Checking skills directory: $DIR"
|
|
53
102
|
if [ -d "$DIR" ]; then
|
|
54
103
|
echo "Copying skills from: $DIR"
|
|
55
104
|
# Ensure target directories exist
|
|
56
105
|
mkdir -p "$PROJECT_DIR/.cursor/skills" "$PROJECT_DIR/.claude/skills" "$PROJECT_DIR/.codex/skills"
|
|
57
106
|
# Copy each skill directory to all three locations for cross-platform compatibility
|
|
107
|
+
local skill_count=0
|
|
58
108
|
for skill_dir in "$DIR"/*; do
|
|
59
109
|
if [ -d "$skill_dir" ] && [ -f "$skill_dir/SKILL.md" ]; then
|
|
60
110
|
skill_name=$(basename "$skill_dir")
|
|
61
111
|
echo " - Copying skill: $skill_name"
|
|
112
|
+
skill_count=$((skill_count + 1))
|
|
62
113
|
# Copy to Cursor, Claude, and Codex skill directories
|
|
63
|
-
cp -r "$skill_dir" "$PROJECT_DIR/.cursor/skills/"
|
|
64
|
-
|
|
65
|
-
|
|
114
|
+
if cp -r "$skill_dir" "$PROJECT_DIR/.cursor/skills/"; then
|
|
115
|
+
echo " ✓ Copied to .cursor/skills/"
|
|
116
|
+
else
|
|
117
|
+
echo " ✗ Failed to copy to .cursor/skills/"
|
|
118
|
+
fi
|
|
119
|
+
if cp -r "$skill_dir" "$PROJECT_DIR/.claude/skills/"; then
|
|
120
|
+
echo " ✓ Copied to .claude/skills/"
|
|
121
|
+
else
|
|
122
|
+
echo " ✗ Failed to copy to .claude/skills/"
|
|
123
|
+
fi
|
|
124
|
+
if cp -r "$skill_dir" "$PROJECT_DIR/.codex/skills/"; then
|
|
125
|
+
echo " ✓ Copied to .codex/skills/"
|
|
126
|
+
else
|
|
127
|
+
echo " ✗ Failed to copy to .codex/skills/"
|
|
128
|
+
fi
|
|
129
|
+
else
|
|
130
|
+
echo " - Skipping (not a valid skill): $(basename "$skill_dir")"
|
|
66
131
|
fi
|
|
67
132
|
done
|
|
133
|
+
if [ $skill_count -eq 0 ]; then
|
|
134
|
+
echo " Warning: No skills found in $DIR"
|
|
135
|
+
echo " Contents of $DIR:"
|
|
136
|
+
ls -la "$DIR" || echo " (directory listing failed)"
|
|
137
|
+
fi
|
|
68
138
|
else
|
|
69
139
|
echo "Warning: Skills directory not found: $DIR"
|
|
140
|
+
echo "DEBUG: SRC_DIR=$SRC_DIR"
|
|
141
|
+
echo "DEBUG: SHARED_SKILLS_DIR=$SHARED_SKILLS_DIR"
|
|
70
142
|
fi
|
|
71
143
|
}
|
|
72
144
|
|
|
@@ -98,6 +170,8 @@ copy_rules "$SHARED_DIR"
|
|
|
98
170
|
append_to_claude_md "$SHARED_DIR"
|
|
99
171
|
|
|
100
172
|
# Always include shared skills
|
|
173
|
+
echo "DEBUG: SRC_DIR=$SRC_DIR"
|
|
174
|
+
echo "DEBUG: SHARED_SKILLS_DIR=$SHARED_SKILLS_DIR"
|
|
101
175
|
copy_skills "$SHARED_SKILLS_DIR"
|
|
102
176
|
|
|
103
177
|
# Inheritance handling
|