Skip to content

Commit babacd5

Browse files
committed
fix: implementation pre-requesit in build mode
1 parent 5656bcd commit babacd5

File tree

7 files changed

+90
-21
lines changed

7 files changed

+90
-21
lines changed

scripts/bash/check-prerequisites.sh

Lines changed: 23 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -55,10 +55,10 @@ OPTIONS:
5555
--help, -h Show this help message
5656
5757
EXAMPLES:
58-
# Check task prerequisites (plan.md required)
58+
# Check task prerequisites (plan.md required in spec mode)
5959
./check-prerequisites.sh --json
6060
61-
# Check implementation prerequisites (plan.md + tasks.md required)
61+
# Check implementation prerequisites (plan.md required in spec mode, tasks.md always required)
6262
./check-prerequisites.sh --json --require-tasks --include-tasks
6363
6464
# Get feature paths only (no validation)
@@ -219,10 +219,28 @@ if [[ ! -d "$FEATURE_DIR" ]]; then
219219
exit 1
220220
fi
221221

222+
# Check for plan.md (required in spec mode, optional in build mode)
222223
if [[ ! -f "$IMPL_PLAN" ]]; then
223-
echo "ERROR: plan.md not found in $FEATURE_DIR" >&2
224-
echo "Run /speckit.plan first to create the implementation plan." >&2
225-
exit 1
224+
# Get current mode to determine if plan.md is required
225+
local current_mode="spec"
226+
if [[ -f ".specify/config/mode.json" ]]; then
227+
current_mode=$(python3 -c "
228+
import json
229+
try:
230+
with open('.specify/config/mode.json', 'r') as f:
231+
data = json.load(f)
232+
print(data.get('current_mode', 'spec'))
233+
except:
234+
print('spec')
235+
" 2>/dev/null || echo "spec")
236+
fi
237+
238+
if [[ "$current_mode" == "spec" ]]; then
239+
echo "ERROR: plan.md not found in $FEATURE_DIR" >&2
240+
echo "Run /speckit.plan first to create the implementation plan." >&2
241+
exit 1
242+
fi
243+
# In build mode, plan.md is optional - allow implementation to proceed
226244
fi
227245

228246
if [[ ! -f "$CONTEXT" ]]; then

scripts/bash/implement.sh

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -119,8 +119,17 @@ check_checklists_status() {
119119
load_implementation_context() {
120120
log_info "Loading implementation context..."
121121

122-
# Required files
123-
local required_files=("tasks.md" "plan.md" "spec.md")
122+
# Get current workflow mode
123+
local workflow_mode="spec" # Default
124+
if [[ -f ".specify/config/mode.json" ]]; then
125+
workflow_mode=$(jq -r '.current_mode // "spec"' ".specify/config/mode.json" 2>/dev/null || echo "spec")
126+
fi
127+
128+
# Required files (plan.md is optional in build mode)
129+
local required_files=("tasks.md" "spec.md")
130+
if [[ "$workflow_mode" == "spec" ]]; then
131+
required_files+=("plan.md")
132+
fi
124133

125134
for file in "${required_files[@]}"; do
126135
if [[ ! -f "$FEATURE_DIR/$file" ]]; then
@@ -129,6 +138,12 @@ load_implementation_context() {
129138
fi
130139
done
131140

141+
# Optional files (plan.md is optional in build mode)
142+
local optional_files=("data-model.md" "contracts/" "research.md" "quickstart.md")
143+
if [[ "$workflow_mode" == "build" ]]; then
144+
optional_files+=("plan.md")
145+
fi
146+
132147
# Optional files
133148
local optional_files=("data-model.md" "contracts/" "research.md" "quickstart.md")
134149

scripts/powershell/check-prerequisites.ps1

Lines changed: 22 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -40,10 +40,10 @@ OPTIONS:
4040
-Help, -h Show this help message
4141
4242
EXAMPLES:
43-
# Check task prerequisites (plan.md required)
43+
# Check task prerequisites (plan.md required in spec mode)
4444
.\check-prerequisites.ps1 -Json
4545
46-
# Check implementation prerequisites (plan.md + tasks.md required)
46+
# Check implementation prerequisites (plan.md required in spec mode, tasks.md always required)
4747
.\check-prerequisites.ps1 -Json -RequireTasks -IncludeTasks
4848
4949
# Get feature paths only (no validation)
@@ -150,10 +150,27 @@ if (-not (Test-Path $paths.FEATURE_DIR -PathType Container)) {
150150
exit 1
151151
}
152152

153+
# Check for plan.md (required in spec mode, optional in build mode)
153154
if (-not (Test-Path $paths.IMPL_PLAN -PathType Leaf)) {
154-
Write-Output "ERROR: plan.md not found in $($paths.FEATURE_DIR)"
155-
Write-Output "Run /speckit.plan first to create the implementation plan."
156-
exit 1
155+
# Get current mode to determine if plan.md is required
156+
$currentMode = "spec"
157+
$modeFile = ".specify/config/mode.json"
158+
if (Test-Path $modeFile) {
159+
try {
160+
$modeData = Get-Content $modeFile | ConvertFrom-Json
161+
$currentMode = $modeData.current_mode
162+
if (-not $currentMode) { $currentMode = "spec" }
163+
} catch {
164+
$currentMode = "spec"
165+
}
166+
}
167+
168+
if ($currentMode -eq "spec") {
169+
Write-Output "ERROR: plan.md not found in $($paths.FEATURE_DIR)"
170+
Write-Output "Run /speckit.plan first to create the implementation plan."
171+
exit 1
172+
}
173+
# In build mode, plan.md is optional - allow implementation to proceed
157174
}
158175

159176
# Check for tasks.md if required

scripts/powershell/implement.ps1

Lines changed: 22 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -121,8 +121,24 @@ function Test-ChecklistsStatus {
121121
function Import-ImplementationContext {
122122
Write-Info "Loading implementation context..."
123123

124-
# Required files
125-
$requiredFiles = @("tasks.md", "plan.md", "spec.md")
124+
# Get current workflow mode
125+
$workflowMode = "spec" # Default
126+
$modeFile = ".specify/config/mode.json"
127+
if (Test-Path $modeFile) {
128+
try {
129+
$modeData = Get-Content $modeFile | ConvertFrom-Json
130+
$workflowMode = $modeData.current_mode
131+
if (-not $workflowMode) { $workflowMode = "spec" }
132+
} catch {
133+
$workflowMode = "spec"
134+
}
135+
}
136+
137+
# Required files (plan.md is optional in build mode)
138+
$requiredFiles = @("tasks.md", "spec.md")
139+
if ($workflowMode -eq "spec") {
140+
$requiredFiles += "plan.md"
141+
}
126142

127143
foreach ($file in $requiredFiles) {
128144
$filePath = Join-Path $global:FeatureDir $file
@@ -132,8 +148,11 @@ function Import-ImplementationContext {
132148
}
133149
}
134150

135-
# Optional files
151+
# Optional files (plan.md is optional in build mode)
136152
$optionalFiles = @("data-model.md", "contracts", "research.md", "quickstart.md")
153+
if ($workflowMode -eq "build") {
154+
$optionalFiles += "plan.md"
155+
}
137156

138157
foreach ($file in $optionalFiles) {
139158
$filePath = Join-Path $global:FeatureDir $file

spec-driven.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ Once a feature specification exists, this command creates a comprehensive implem
9797

9898
After a plan is created, this command analyzes the plan and related design documents to generate an executable task list:
9999

100-
1. **Inputs**: Reads `plan.md` (required) and, if present, `data-model.md`, `contracts/`, and `research.md`
100+
1. **Inputs**: Reads `plan.md` (required in spec mode, optional in build mode) and, if present, `data-model.md`, `contracts/`, and `research.md`
101101
2. **Task Derivation**: Converts contracts, entities, and scenarios into specific tasks
102102
3. **Parallelization**: Marks independent tasks `[P]` and outlines safe parallel groups
103103
4. **Output**: Writes `tasks.md` in the feature directory, ready for execution by a Task agent

templates/commands/implement.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -78,9 +78,9 @@ You **MUST** consider the user input before proceeding (if not empty).
7878
* Automatically proceed to step 3
7979
8080
3. Load and analyze the implementation context:
81-
- **REQUIRED**: Read tasks.md for the complete task list and execution plan
82-
- **REQUIRED**: Read plan.md for tech stack, architecture, and file structure
83-
- **IF EXISTS**: Read data-model.md for entities and relationships
81+
- **REQUIRED**: Read tasks.md for the complete task list and execution plan
82+
- **REQUIRED**: Read plan.md for tech stack, architecture, and file structure (optional in build mode)
83+
- **IF EXISTS**: Read data-model.md for entities and relationships
8484
- **IF EXISTS**: Read contracts/ for API specifications and test requirements
8585
- **IF EXISTS**: Read research.md for technical decisions and constraints
8686
- **IF EXISTS**: Read quickstart.md for integration scenarios
@@ -104,7 +104,7 @@ You **MUST** consider the user input before proceeding (if not empty).
104104
**If ignore file already exists**: Verify it contains essential patterns, append missing critical patterns only
105105
**If ignore file missing**: Create with full pattern set for detected technology
106106
107-
**Common Patterns by Technology** (from plan.md tech stack):
107+
**Common Patterns by Technology** (from plan.md tech stack if available, otherwise detect from project files):
108108
- **Node.js/JavaScript**: `node_modules/`, `dist/`, `build/`, `*.log`, `.env*`
109109
- **Python**: `__pycache__/`, `*.pyc`, `.venv/`, `venv/`, `dist/`, `*.egg-info/`
110110
- **Java**: `target/`, `*.class`, `*.jar`, `.gradle/`, `build/`

templates/tasks-template.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ description: "Task list template for feature implementation"
55
# Tasks: [FEATURE NAME]
66

77
**Input**: Design documents from `/specs/[###-feature-name]/`
8-
**Prerequisites**: plan.md (required), spec.md (required for user stories), research.md, data-model.md, contracts/
8+
**Prerequisites**: plan.md (required in spec mode, optional in build mode), spec.md (required for user stories), research.md, data-model.md, contracts/
99

1010
**Tests**: The examples below include test tasks. Tests are OPTIONAL - only include them if explicitly requested in the feature specification.
1111

0 commit comments

Comments
 (0)