Skip to content

Commit 558e682

Browse files
committed
Update for Cursor rules & script path
1 parent 63bc6b4 commit 558e682

File tree

4 files changed

+37
-18
lines changed

4 files changed

+37
-18
lines changed

.github/workflows/scripts/create-release-packages.sh

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -114,12 +114,15 @@ build_variant() {
114114
local plan_tpl="$base_dir/.specify/templates/plan-template.md"
115115
if [[ -f "$plan_tpl" ]]; then
116116
plan_norm=$(tr -d '\r' < "$plan_tpl")
117-
variant_line=$(printf '%s\n' "$plan_norm" | grep -E "<!--[[:space:]]*VARIANT:$script" | head -1 | sed -E "s/.*VARIANT:$script[[:space:]]+//; s/-->.*//; s/^[[:space:]]+//; s/[[:space:]]+$//")
118-
if [[ -n $variant_line ]]; then
117+
# Extract script command from YAML frontmatter
118+
script_command=$(printf '%s\n' "$plan_norm" | awk -v sv="$script" '/^[[:space:]]*'"$script"':[[:space:]]*/ {sub(/^[[:space:]]*'"$script"':[[:space:]]*/, ""); print; exit}')
119+
120+
if [[ -n $script_command ]]; then
119121
tmp_file=$(mktemp)
120-
sed "s|VARIANT-INJECT|${variant_line}|" "$plan_tpl" | tr -d '\r' | sed "s|__AGENT__|${agent}|g" | sed '/<!--[[:space:]]*VARIANT:sh/d' | sed '/<!--[[:space:]]*VARIANT:ps/d' > "$tmp_file" && mv "$tmp_file" "$plan_tpl"
122+
# Replace {SCRIPT} placeholder with the script command and __AGENT__ with agent name
123+
sed "s|{SCRIPT}|${script_command}|g" "$plan_tpl" | tr -d '\r' | sed "s|__AGENT__|${agent}|g" > "$tmp_file" && mv "$tmp_file" "$plan_tpl"
121124
else
122-
echo "Warning: no plan-template variant for $script (pattern not matched)" >&2
125+
echo "Warning: no plan-template script command found for $script in YAML frontmatter" >&2
123126
fi
124127
fi
125128
case $agent in

scripts/bash/update-agent-context.sh

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ REPO_ROOT=$(git rev-parse --show-toplevel)
44
CURRENT_BRANCH=$(git rev-parse --abbrev-ref HEAD)
55
FEATURE_DIR="$REPO_ROOT/specs/$CURRENT_BRANCH"
66
NEW_PLAN="$FEATURE_DIR/plan.md"
7-
CLAUDE_FILE="$REPO_ROOT/CLAUDE.md"; GEMINI_FILE="$REPO_ROOT/GEMINI.md"; COPILOT_FILE="$REPO_ROOT/.github/copilot-instructions.md"
7+
CLAUDE_FILE="$REPO_ROOT/CLAUDE.md"; GEMINI_FILE="$REPO_ROOT/GEMINI.md"; COPILOT_FILE="$REPO_ROOT/.github/copilot-instructions.md"; CURSOR_FILE="$REPO_ROOT/.cursor/rules/specify-rules.mdc"
88
AGENT_TYPE="$1"
99
[ -f "$NEW_PLAN" ] || { echo "ERROR: No plan.md found at $NEW_PLAN"; exit 1; }
1010
echo "=== Updating agent context files for feature $CURRENT_BRANCH ==="
@@ -51,7 +51,12 @@ case "$AGENT_TYPE" in
5151
claude) update_agent_file "$CLAUDE_FILE" "Claude Code" ;;
5252
gemini) update_agent_file "$GEMINI_FILE" "Gemini CLI" ;;
5353
copilot) update_agent_file "$COPILOT_FILE" "GitHub Copilot" ;;
54-
"") [ -f "$CLAUDE_FILE" ] && update_agent_file "$CLAUDE_FILE" "Claude Code"; [ -f "$GEMINI_FILE" ] && update_agent_file "$GEMINI_FILE" "Gemini CLI"; [ -f "$COPILOT_FILE" ] && update_agent_file "$COPILOT_FILE" "GitHub Copilot"; if [ ! -f "$CLAUDE_FILE" ] && [ ! -f "$GEMINI_FILE" ] && [ ! -f "$COPILOT_FILE" ]; then update_agent_file "$CLAUDE_FILE" "Claude Code"; fi ;;
55-
*) echo "ERROR: Unknown agent type '$AGENT_TYPE'"; exit 1 ;;
54+
cursor) update_agent_file "$CURSOR_FILE" "Cursor IDE" ;;
55+
"") [ -f "$CLAUDE_FILE" ] && update_agent_file "$CLAUDE_FILE" "Claude Code"; \
56+
[ -f "$GEMINI_FILE" ] && update_agent_file "$GEMINI_FILE" "Gemini CLI"; \
57+
[ -f "$COPILOT_FILE" ] && update_agent_file "$COPILOT_FILE" "GitHub Copilot"; \
58+
[ -f "$CURSOR_FILE" ] && update_agent_file "$CURSOR_FILE" "Cursor IDE"; \
59+
if [ ! -f "$CLAUDE_FILE" ] && [ ! -f "$GEMINI_FILE" ] && [ ! -f "$COPILOT_FILE" ] && [ ! -f "$CURSOR_FILE" ]; then update_agent_file "$CLAUDE_FILE" "Claude Code"; fi ;;
60+
*) echo "ERROR: Unknown agent type '$AGENT_TYPE' (expected claude|gemini|copilot|cursor)"; exit 1 ;;
5661
esac
57-
echo; echo "Summary of changes:"; [ -n "$NEW_LANG" ] && echo "- Added language: $NEW_LANG"; [ -n "$NEW_FRAMEWORK" ] && echo "- Added framework: $NEW_FRAMEWORK"; [ -n "$NEW_DB" ] && [ "$NEW_DB" != "N/A" ] && echo "- Added database: $NEW_DB"; echo; echo "Usage: $0 [claude|gemini|copilot]"
62+
echo; echo "Summary of changes:"; [ -n "$NEW_LANG" ] && echo "- Added language: $NEW_LANG"; [ -n "$NEW_FRAMEWORK" ] && echo "- Added framework: $NEW_FRAMEWORK"; [ -n "$NEW_DB" ] && [ "$NEW_DB" != "N/A" ] && echo "- Added database: $NEW_DB"; echo; echo "Usage: $0 [claude|gemini|copilot|cursor]"

scripts/powershell/update-agent-context.ps1

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ if (-not (Test-Path $newPlan)) { Write-Error "ERROR: No plan.md found at $newPla
1212
$claudeFile = Join-Path $repoRoot 'CLAUDE.md'
1313
$geminiFile = Join-Path $repoRoot 'GEMINI.md'
1414
$copilotFile = Join-Path $repoRoot '.github/copilot-instructions.md'
15+
$cursorFile = Join-Path $repoRoot '.cursor/rules/specify-rules.mdc'
1516

1617
Write-Output "=== Updating agent context files for feature $currentBranch ==="
1718

@@ -55,7 +56,7 @@ function Update-AgentFile($targetFile, $agentName) {
5556
if ($newDb -and $newDb -ne 'N/A' -and ($content -notmatch [regex]::Escape($newDb))) { $content = $content -replace '(## Active Technologies\n)', "`$1- $newDb ($currentBranch)`n" }
5657
if ($content -match '## Recent Changes\n([\s\S]*?)(\n\n|$)') {
5758
$changesBlock = $matches[1].Trim().Split("`n")
58-
$changesBlock = ,"- $currentBranch: Added $newLang + $newFramework" + $changesBlock
59+
$changesBlock = ,"- ${currentBranch}: Added ${newLang} + ${newFramework}" + $changesBlock
5960
$changesBlock = $changesBlock | Where-Object { $_ } | Select-Object -First 3
6061
$joined = ($changesBlock -join "`n")
6162
$content = [regex]::Replace($content, '## Recent Changes\n([\s\S]*?)(\n\n|$)', "## Recent Changes`n$joined`n`n")
@@ -69,16 +70,22 @@ switch ($AgentType) {
6970
'claude' { Update-AgentFile $claudeFile 'Claude Code' }
7071
'gemini' { Update-AgentFile $geminiFile 'Gemini CLI' }
7172
'copilot' { Update-AgentFile $copilotFile 'GitHub Copilot' }
73+
'cursor' { Update-AgentFile $cursorFile 'Cursor IDE' }
7274
'' {
73-
foreach ($pair in @(@{file=$claudeFile; name='Claude Code'}, @{file=$geminiFile; name='Gemini CLI'}, @{file=$copilotFile; name='GitHub Copilot'})) {
75+
foreach ($pair in @(
76+
@{file=$claudeFile; name='Claude Code'},
77+
@{file=$geminiFile; name='Gemini CLI'},
78+
@{file=$copilotFile; name='GitHub Copilot'},
79+
@{file=$cursorFile; name='Cursor IDE'}
80+
)) {
7481
if (Test-Path $pair.file) { Update-AgentFile $pair.file $pair.name }
7582
}
76-
if (-not (Test-Path $claudeFile) -and -not (Test-Path $geminiFile) -and -not (Test-Path $copilotFile)) {
83+
if (-not (Test-Path $claudeFile) -and -not (Test-Path $geminiFile) -and -not (Test-Path $copilotFile) -and -not (Test-Path $cursorFile)) {
7784
Write-Output 'No agent context files found. Creating Claude Code context file by default.'
7885
Update-AgentFile $claudeFile 'Claude Code'
7986
}
8087
}
81-
Default { Write-Error "ERROR: Unknown agent type '$AgentType'. Use: claude, gemini, copilot, or leave empty for all."; exit 1 }
88+
Default { Write-Error "ERROR: Unknown agent type '$AgentType'. Use: claude, gemini, copilot, cursor or leave empty for all."; exit 1 }
8289
}
8390

8491
Write-Output ''
@@ -88,4 +95,4 @@ if ($newFramework) { Write-Output "- Added framework: $newFramework" }
8895
if ($newDb -and $newDb -ne 'N/A') { Write-Output "- Added database: $newDb" }
8996

9097
Write-Output ''
91-
Write-Output 'Usage: ./update-agent-context.ps1 [claude|gemini|copilot]'
98+
Write-Output 'Usage: ./update-agent-context.ps1 [claude|gemini|copilot|cursor]'

templates/plan-template.md

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,11 @@
1-
# Implementation Plan: [FEATURE]
1+
---
2+
description: "Implementation plan template for feature development"
3+
scripts:
4+
sh: ".specify/scripts/bash/update-agent-context.sh __AGENT__"
5+
ps: ".specify/scripts/powershell/update-agent-context.ps1 -AgentType __AGENT__"
6+
---
27

3-
<!-- VARIANT:sh - Run `/scripts/bash/update-agent-context.sh __AGENT__` for your AI assistant -->
4-
<!-- VARIANT:ps - Run `/scripts/powershell/update-agent-context.ps1 -AgentType __AGENT__` for your AI assistant -->
8+
# Implementation Plan: [FEATURE]
59

610
**Branch**: `[###-feature-name]` | **Date**: [DATE] | **Spec**: [link]
711
**Input**: Feature specification from `/specs/[###-feature-name]/spec.md`
@@ -174,7 +178,7 @@ ios/ or android/
174178
- Quickstart test = story validation steps
175179

176180
5. **Update agent file incrementally** (O(1) operation):
177-
VARIANT-INJECT
181+
- Run {SCRIPT} for your AI assistant
178182
- If exists: Add only NEW tech from current plan
179183
- Preserve manual additions between markers
180184
- Update recent changes (keep last 3)
@@ -187,7 +191,7 @@ ios/ or android/
187191
*This section describes what the /tasks command will do - DO NOT execute during /plan*
188192

189193
**Task Generation Strategy**:
190-
- Load `/templates/tasks-template.md` as base
194+
- Load `.specify/templates/tasks-template.md` as base
191195
- Generate tasks from Phase 1 design docs (contracts, data model, quickstart)
192196
- Each contract → contract test task [P]
193197
- Each entity → model creation task [P]

0 commit comments

Comments
 (0)