Skip to content

Commit 9186509

Browse files
committed
Add .syncignore support to convention-sync; remove hudl WIP files
1 parent 71feaa2 commit 9186509

File tree

4 files changed

+39
-609
lines changed

4 files changed

+39
-609
lines changed

.cursor/commands/convention-sync.md

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,12 +31,15 @@ Sync summary (user → repo):
3131
New: file1, file2
3232
Modified: file3, file4
3333
Deleted: file5
34+
Ignored: file6, file7 (via .syncignore)
3435
3536
PR #N: Will update description from README.md (or "No open PR")
3637
3738
Commit and push? [y/N]
3839
```
3940

41+
If `ignored` array is empty, omit the Ignored line.
42+
4043
If the user provided a commit message in their prompt, skip the confirmation and proceed.
4144
</step>
4245

@@ -62,6 +65,6 @@ cd <repo-dir> && gh pr edit --body-file .cursor/README.md
6265

6366
<edge-cases>
6467
<case name="Reverse sync (repo → user)">If the user says "pull from repo" or "update my local", run with `--repo-to-user --stage` instead. No git operations needed.</case>
65-
<case name="Selective sync">If the user says to exclude specific files, note them but still run the full diff. The script syncs everything — manually skip files by not confirming, or remove them from staging with `git reset HEAD .cursor/<file>` before committing.</case>
68+
<case name="Selective sync">To permanently exclude files, add glob patterns to `~/.cursor/.syncignore` (one per line, `#` comments). The script skips matching entries and reports them in the `ignored` array. To exclude ad-hoc, remove files from staging with `git reset HEAD .cursor/<file>` before committing.</case>
6669
<case name="No README">If `.cursor/README.md` doesn't exist, skip PR description update and warn the user.</case>
6770
</edge-cases>

.cursor/commands/convention-sync.sh

Lines changed: 35 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -37,19 +37,43 @@ fi
3737
USER_DIR="$HOME/.cursor"
3838
REPO_CURSOR="$REPO_DIR/.cursor"
3939
DIRS="commands rules skills"
40+
SYNCIGNORE="$USER_DIR/.syncignore"
41+
42+
# Load ignore patterns from .syncignore (one glob per line, # comments, blank lines skipped)
43+
ignore_patterns=()
44+
if [[ -f "$SYNCIGNORE" ]]; then
45+
while IFS= read -r line; do
46+
line="${line%%#*}" # strip comments
47+
line="${line%"${line##*[![:space:]]}"}" # strip trailing whitespace
48+
[[ -z "$line" ]] && continue
49+
ignore_patterns+=("$line")
50+
done < "$SYNCIGNORE"
51+
fi
52+
53+
is_ignored() {
54+
local entry="$1"
55+
for pattern in "${ignore_patterns[@]+"${ignore_patterns[@]}"}"; do
56+
# shellcheck disable=SC2254
57+
if [[ "$entry" == $pattern ]]; then
58+
return 0
59+
fi
60+
done
61+
return 1
62+
}
4063

4164
new_json="[]"
4265
mod_json="[]"
4366
del_json="[]"
67+
ignored_json="[]"
4468

4569
# Check README.md separately (single file, not a directory)
46-
if [[ -f "$USER_DIR/README.md" ]]; then
70+
if [[ -f "$USER_DIR/README.md" ]] && ! is_ignored "README.md"; then
4771
if [[ ! -f "$REPO_CURSOR/README.md" ]]; then
4872
new_json=$(echo "$new_json" | jq '. + ["README.md"]')
4973
elif ! diff -q "$USER_DIR/README.md" "$REPO_CURSOR/README.md" >/dev/null 2>&1; then
5074
mod_json=$(echo "$mod_json" | jq '. + ["README.md"]')
5175
fi
52-
elif [[ -f "$REPO_CURSOR/README.md" ]]; then
76+
elif [[ -f "$REPO_CURSOR/README.md" ]] && ! is_ignored "README.md"; then
5377
del_json=$(echo "$del_json" | jq '. + ["README.md"]')
5478
fi
5579

@@ -61,8 +85,12 @@ for dir in $DIRS; do
6185

6286
while IFS= read -r rel; do
6387
[[ -z "$rel" ]] && continue
64-
repo_file="$repo_path/$rel"
6588
entry="$dir/$rel"
89+
if is_ignored "$entry"; then
90+
ignored_json=$(echo "$ignored_json" | jq --arg f "$entry" '. + [$f]')
91+
continue
92+
fi
93+
repo_file="$repo_path/$rel"
6694
if [[ ! -f "$repo_file" ]]; then
6795
new_json=$(echo "$new_json" | jq --arg f "$entry" '. + [$f]')
6896
elif ! diff -q "$user_path/$rel" "$repo_file" >/dev/null 2>&1; then
@@ -73,8 +101,9 @@ for dir in $DIRS; do
73101
if [[ -d "$repo_path" ]]; then
74102
while IFS= read -r rel; do
75103
[[ -z "$rel" ]] && continue
76-
user_file="$user_path/$rel"
77104
entry="$dir/$rel"
105+
is_ignored "$entry" && continue
106+
user_file="$user_path/$rel"
78107
if [[ ! -f "$user_file" ]]; then
79108
del_json=$(echo "$del_json" | jq --arg f "$entry" '. + [$f]')
80109
fi
@@ -141,7 +170,8 @@ jq -n \
141170
--argjson new "$new_json" \
142171
--argjson modified "$mod_json" \
143172
--argjson deleted "$del_json" \
173+
--argjson ignored "$ignored_json" \
144174
--argjson total "$total" \
145175
--arg staged "$DO_STAGE" \
146176
--arg committed "$DO_COMMIT" \
147-
'{total: $total, new: $new, modified: $modified, deleted: $deleted, staged: ($staged == "true"), committed: ($committed == "true")}'
177+
'{total: $total, new: $new, modified: $modified, deleted: $deleted, ignored: $ignored, staged: ($staged == "true"), committed: ($committed == "true")}'

0 commit comments

Comments
 (0)