Skip to content

Commit 583851e

Browse files
author
maodao
committed
fix: resolve conflict
2 parents 39e3be7 + b18ef20 commit 583851e

File tree

5 files changed

+53
-56
lines changed

5 files changed

+53
-56
lines changed

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

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -114,12 +114,19 @@ 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+
if [[ -n $script_command ]]; then
120+
# Always prefix with .specify/ for plan usage
121+
script_command=".specify/$script_command"
119122
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"
123+
# Replace {SCRIPT} placeholder with the script command and __AGENT__ with agent name
124+
substituted=$(sed "s|{SCRIPT}|${script_command}|g" "$plan_tpl" | tr -d '\r' | sed "s|__AGENT__|${agent}|g")
125+
# Strip YAML frontmatter from plan template output (keep body only)
126+
stripped=$(printf '%s\n' "$substituted" | awk 'BEGIN{fm=0;dash=0} /^---$/ {dash++; if(dash==1){fm=1; next} else if(dash==2){fm=0; next}} {if(!fm) print}')
127+
printf '%s\n' "$stripped" > "$plan_tpl"
121128
else
122-
echo "Warning: no plan-template variant for $script (pattern not matched)" >&2
129+
echo "Warning: no plan-template script command found for $script in YAML frontmatter" >&2
123130
fi
124131
fi
125132
case $agent in

scripts/bash/update-agent-context.sh

Lines changed: 11 additions & 5 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"; IFLOW_FILE="$REPO_ROOT/IFLOW.md"
7+
CLAUDE_FILE="$REPO_ROOT/CLAUDE.md"; GEMINI_FILE="$REPO_ROOT/GEMINI.md"; COPILOT_FILE="$REPO_ROOT/.github/copilot-instructions.md"; IFLOW_FILE="$REPO_ROOT/IFLOW.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 ==="
@@ -13,7 +13,7 @@ NEW_FRAMEWORK=$(grep "^**Primary Dependencies**: " "$NEW_PLAN" 2>/dev/null | hea
1313
NEW_DB=$(grep "^**Storage**: " "$NEW_PLAN" 2>/dev/null | head -1 | sed 's/^**Storage**: //' | grep -v "N/A" | grep -v "NEEDS CLARIFICATION" || echo "")
1414
NEW_PROJECT_TYPE=$(grep "^**Project Type**: " "$NEW_PLAN" 2>/dev/null | head -1 | sed 's/^**Project Type**: //' || echo "")
1515
update_agent_file() { local target_file="$1" agent_name="$2"; echo "Updating $agent_name context file: $target_file"; local temp_file=$(mktemp); if [ ! -f "$target_file" ]; then
16-
echo "Creating new $agent_name context file..."; if [ -f "$REPO_ROOT/templates/agent-file-template.md" ]; then cp "$REPO_ROOT/templates/agent-file-template.md" "$temp_file"; else echo "ERROR: Template not found"; return 1; fi;
16+
echo "Creating new $agent_name context file..."; if [ -f "$REPO_ROOT/.specify/templates/agent-file-template.md" ]; then cp "$REPO_ROOT/templates/agent-file-template.md" "$temp_file"; else echo "ERROR: Template not found"; return 1; fi;
1717
sed -i.bak "s/\[PROJECT NAME\]/$(basename $REPO_ROOT)/" "$temp_file"; sed -i.bak "s/\[DATE\]/$(date +%Y-%m-%d)/" "$temp_file"; sed -i.bak "s/\[EXTRACTED FROM ALL PLAN.MD FILES\]/- $NEW_LANG + $NEW_FRAMEWORK ($CURRENT_BRANCH)/" "$temp_file";
1818
if [[ "$NEW_PROJECT_TYPE" == *"web"* ]]; then sed -i.bak "s|\[ACTUAL STRUCTURE FROM PLANS\]|backend/\nfrontend/\ntests/|" "$temp_file"; else sed -i.bak "s|\[ACTUAL STRUCTURE FROM PLANS\]|src/\ntests/|" "$temp_file"; fi;
1919
if [[ "$NEW_LANG" == *"Python"* ]]; then COMMANDS="cd src && pytest && ruff check ."; elif [[ "$NEW_LANG" == *"Rust"* ]]; then COMMANDS="cargo test && cargo clippy"; elif [[ "$NEW_LANG" == *"JavaScript"* ]] || [[ "$NEW_LANG" == *"TypeScript"* ]]; then COMMANDS="npm test && npm run lint"; else COMMANDS="# Add commands for $NEW_LANG"; fi; sed -i.bak "s|\[ONLY COMMANDS FOR ACTIVE TECHNOLOGIES\]|$COMMANDS|" "$temp_file";
@@ -52,7 +52,13 @@ case "$AGENT_TYPE" in
5252
gemini) update_agent_file "$GEMINI_FILE" "Gemini CLI" ;;
5353
copilot) update_agent_file "$COPILOT_FILE" "GitHub Copilot" ;;
5454
iflow) update_agent_file "$IFLOW_FILE" "iFlow CLI" ;;
55-
"") [ -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"; [ -f "$IFLOW_FILE" ] && update_agent_file "$IFLOW_FILE" "iFlow CLI"; if [ ! -f "$CLAUDE_FILE" ] && [ ! -f "$GEMINI_FILE" ] && [ ! -f "$COPILOT_FILE" ] && [ ! -f "$IFLOW_FILE" ]; then update_agent_file "$CLAUDE_FILE" "Claude Code"; fi ;;
56-
*) echo "ERROR: Unknown agent type '$AGENT_TYPE'"; exit 1 ;;
55+
cursor) update_agent_file "$CURSOR_FILE" "Cursor IDE" ;;
56+
"") [ -f "$CLAUDE_FILE" ] && update_agent_file "$CLAUDE_FILE" "Claude Code"; \
57+
[ -f "$GEMINI_FILE" ] && update_agent_file "$GEMINI_FILE" "Gemini CLI"; \
58+
[ -f "$COPILOT_FILE" ] && update_agent_file "$COPILOT_FILE" "GitHub Copilot"; \
59+
[ -f "$IFLOW_FILE" ] && update_agent_file "$IFLOW_FILE" "iFlow CLI"; \
60+
[ -f "$CURSOR_FILE" ] && update_agent_file "$CURSOR_FILE" "Cursor IDE"; \
61+
if [ ! -f "$CLAUDE_FILE" ] && [ ! -f "$GEMINI_FILE" ] && [ ! -f "$COPILOT_FILE" ] && [ ! -f "$IFLOW_FILE" ] && [ ! -f "$CURSOR_FILE" ]; then update_agent_file "$CLAUDE_FILE" "Claude Code"; fi ;;
62+
*) echo "ERROR: Unknown agent type '$AGENT_TYPE' (expected claude|gemini|copilot|iflow|cursor)"; exit 1 ;;
5763
esac
58-
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|iflow]"
64+
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|iflow|cursor]"

scripts/powershell/update-agent-context.ps1

Lines changed: 13 additions & 6 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

@@ -30,7 +31,7 @@ $newProjectType = Get-PlanValue 'Project Type'
3031

3132
function Initialize-AgentFile($targetFile, $agentName) {
3233
if (Test-Path $targetFile) { return }
33-
$template = Join-Path $repoRoot 'templates/agent-file-template.md'
34+
$template = Join-Path $repoRoot '.specify/templates/agent-file-template.md'
3435
if (-not (Test-Path $template)) { Write-Error "Template not found: $template"; return }
3536
$content = Get-Content $template -Raw
3637
$content = $content.Replace('[PROJECT NAME]', (Split-Path $repoRoot -Leaf))
@@ -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/commands/plan.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ Given the implementation details provided as an argument, do this:
1919
4. Execute the implementation plan template:
2020
- Load `/templates/plan-template.md` (already copied to IMPL_PLAN path)
2121
- Set Input path to FEATURE_SPEC
22-
- Run the Execution Flow (main) function steps 1-10
22+
- Run the Execution Flow (main) function steps 1-9
2323
- The template is self-contained and executable
2424
- Follow error handling and gate checks as specified
2525
- Let the template guide artifact generation in $SPECS_DIR:

templates/plan-template.md

Lines changed: 17 additions & 40 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: scripts/bash/update-agent-context.sh __AGENT__
5+
ps: 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`
@@ -13,18 +17,19 @@
1317
2. Fill Technical Context (scan for NEEDS CLARIFICATION)
1418
→ Detect Project Type from context (web=frontend+backend, mobile=app+api)
1519
→ Set Structure Decision based on project type
16-
3. Evaluate Constitution Check section below
20+
3. Fill the Constitution Check section based on the content of the constitution document.
21+
4. Evaluate Constitution Check section below
1722
→ If violations exist: Document in Complexity Tracking
1823
→ If no justification possible: ERROR "Simplify approach first"
1924
→ Update Progress Tracking: Initial Constitution Check
20-
4. Execute Phase 0 → research.md
25+
5. Execute Phase 0 → research.md
2126
→ If NEEDS CLARIFICATION remain: ERROR "Resolve unknowns"
22-
5. Execute Phase 1 → contracts, data-model.md, quickstart.md, agent-specific template file (e.g., `CLAUDE.md` for Claude Code, `.github/copilot-instructions.md` for GitHub Copilot, `GEMINI.md` for Gemini CLI, or `IFLOW.md` for iFlow CLI).
23-
6. Re-evaluate Constitution Check section
27+
6. Execute Phase 1 → contracts, data-model.md, quickstart.md, agent-specific template file (e.g., `CLAUDE.md` for Claude Code, `.github/copilot-instructions.md` for GitHub Copilot, `GEMINI.md` for Gemini CLI, or `IFLOW.md` for iFlow CLI).
28+
7. Re-evaluate Constitution Check section
2429
→ If new violations: Refactor design, return to Phase 1
2530
→ Update Progress Tracking: Post-Design Constitution Check
26-
7. Plan Phase 2 → Describe task generation approach (DO NOT create tasks.md)
27-
8. STOP - Ready for /tasks command
31+
8. Plan Phase 2 → Describe task generation approach (DO NOT create tasks.md)
32+
9. STOP - Ready for /tasks command
2833
```
2934

3035
**IMPORTANT**: The /plan command STOPS at step 7. Phases 2-4 are executed by other commands:
@@ -48,35 +53,7 @@
4853
## Constitution Check
4954
*GATE: Must pass before Phase 0 research. Re-check after Phase 1 design.*
5055

51-
**Simplicity**:
52-
- Projects: [#] (max 3 - e.g., api, cli, tests)
53-
- Using framework directly? (no wrapper classes)
54-
- Single data model? (no DTOs unless serialization differs)
55-
- Avoiding patterns? (no Repository/UoW without proven need)
56-
57-
**Architecture**:
58-
- EVERY feature as library? (no direct app code)
59-
- Libraries listed: [name + purpose for each]
60-
- CLI per library: [commands with --help/--version/--format]
61-
- Library docs: llms.txt format planned?
62-
63-
**Testing (NON-NEGOTIABLE)**:
64-
- RED-GREEN-Refactor cycle enforced? (test MUST fail first)
65-
- Git commits show tests before implementation?
66-
- Order: Contract→Integration→E2E→Unit strictly followed?
67-
- Real dependencies used? (actual DBs, not mocks)
68-
- Integration tests for: new libraries, contract changes, shared schemas?
69-
- FORBIDDEN: Implementation before test, skipping RED phase
70-
71-
**Observability**:
72-
- Structured logging included?
73-
- Frontend logs → backend? (unified stream)
74-
- Error context sufficient?
75-
76-
**Versioning**:
77-
- Version number assigned? (MAJOR.MINOR.BUILD)
78-
- BUILD increments on every change?
79-
- Breaking changes handled? (parallel tests, migration plan)
56+
[Gates determined based on constitution file]
8057

8158
## Project Structure
8259

@@ -174,7 +151,7 @@ ios/ or android/
174151
- Quickstart test = story validation steps
175152

176153
5. **Update agent file incrementally** (O(1) operation):
177-
VARIANT-INJECT
154+
- Run `{SCRIPT}` for your AI assistant
178155
- If exists: Add only NEW tech from current plan
179156
- Preserve manual additions between markers
180157
- Update recent changes (keep last 3)
@@ -187,7 +164,7 @@ ios/ or android/
187164
*This section describes what the /tasks command will do - DO NOT execute during /plan*
188165

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

0 commit comments

Comments
 (0)