specpulse 1.0.4__py3-none-any.whl → 1.0.5__py3-none-any.whl
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.
- specpulse/__init__.py +1 -1
- specpulse/resources/commands/claude/plan.md +156 -45
- specpulse/resources/commands/claude/pulse.md +63 -24
- specpulse/resources/commands/claude/spec.md +110 -31
- specpulse/resources/commands/claude/task.md +202 -43
- specpulse/resources/commands/gemini/plan.toml +13 -5
- specpulse/resources/commands/gemini/pulse.toml +4 -1
- specpulse/resources/commands/gemini/spec.toml +12 -4
- specpulse/resources/commands/gemini/task.toml +17 -5
- specpulse/resources/memory/constitution.md +2 -2
- specpulse/resources/scripts/pulse-init.ps1 +186 -0
- specpulse/resources/scripts/pulse-init.py +171 -0
- specpulse/resources/scripts/pulse-init.sh +80 -21
- specpulse/resources/scripts/pulse-plan.ps1 +251 -0
- specpulse/resources/scripts/pulse-plan.py +191 -0
- specpulse/resources/scripts/pulse-plan.sh +113 -12
- specpulse/resources/scripts/pulse-spec.ps1 +185 -0
- specpulse/resources/scripts/pulse-spec.py +167 -0
- specpulse/resources/scripts/pulse-spec.sh +86 -11
- specpulse/resources/scripts/pulse-task.ps1 +263 -0
- specpulse/resources/scripts/pulse-task.py +237 -0
- specpulse/resources/scripts/pulse-task.sh +123 -9
- specpulse/resources/templates/plan.md +142 -287
- specpulse/resources/templates/spec.md +80 -246
- specpulse/resources/templates/task.md +114 -93
- {specpulse-1.0.4.dist-info → specpulse-1.0.5.dist-info}/METADATA +29 -10
- specpulse-1.0.5.dist-info/RECORD +41 -0
- specpulse-1.0.4.dist-info/RECORD +0 -33
- {specpulse-1.0.4.dist-info → specpulse-1.0.5.dist-info}/WHEEL +0 -0
- {specpulse-1.0.4.dist-info → specpulse-1.0.5.dist-info}/entry_points.txt +0 -0
- {specpulse-1.0.4.dist-info → specpulse-1.0.5.dist-info}/licenses/LICENSE +0 -0
- {specpulse-1.0.4.dist-info → specpulse-1.0.5.dist-info}/top_level.txt +0 -0
@@ -1,78 +1,237 @@
|
|
1
1
|
---
|
2
2
|
name: task
|
3
|
-
description: Generate and manage task breakdowns
|
3
|
+
description: Generate and manage task breakdowns using AI-optimized templates
|
4
4
|
allowed_tools:
|
5
5
|
- Read
|
6
6
|
- Write
|
7
7
|
- Edit
|
8
8
|
- Bash
|
9
|
+
- TodoWrite
|
9
10
|
---
|
10
11
|
|
11
12
|
# /task Command
|
12
13
|
|
13
|
-
Generate task breakdowns from implementation plans using SpecPulse
|
14
|
+
Generate task breakdowns from implementation plans using SpecPulse methodology with AI-optimized templates and enhanced validation.
|
14
15
|
|
15
16
|
## Usage
|
16
17
|
```
|
17
|
-
/task [action]
|
18
|
+
/task [action] [feature-directory]
|
18
19
|
```
|
19
20
|
|
20
|
-
Actions: `breakdown`, `update`, `status` (defaults to `breakdown`)
|
21
|
+
Actions: `breakdown`, `update`, `status`, `execute` (defaults to `breakdown`)
|
21
22
|
|
22
23
|
## Implementation
|
23
24
|
|
24
25
|
When called with `/task $ARGUMENTS`, I will:
|
25
26
|
|
26
27
|
1. **Parse arguments** to determine action:
|
27
|
-
- If
|
28
|
-
- If
|
28
|
+
- If `update`: Update task status and dependencies
|
29
|
+
- If `status`: Show comprehensive progress with metrics
|
30
|
+
- If `execute`: Execute task with script integration
|
29
31
|
- Otherwise: Generate task breakdown
|
30
32
|
|
31
33
|
2. **For `/task breakdown` or `/task`:**
|
32
34
|
|
33
|
-
a. **
|
35
|
+
a. **Enhanced validation** using cross-platform script:
|
36
|
+
```bash
|
37
|
+
# Cross-platform detection
|
38
|
+
if [[ "$OSTYPE" == "msys" || "$OSTYPE" == "win32" ]]; then
|
39
|
+
powershell scripts/pulse-task.ps1 "$FEATURE_DIR"
|
40
|
+
else
|
41
|
+
bash scripts/pulse-task.sh "$FEATURE_DIR" || python scripts/pulse-task.py "$FEATURE_DIR"
|
42
|
+
fi
|
43
|
+
```
|
34
44
|
|
35
|
-
b. **
|
36
|
-
|
37
|
-
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
45
|
+
b. **Read implementation plan** from `plans/XXX-feature/plan.md`
|
46
|
+
|
47
|
+
c. **Generate AI-optimized tasks** using template variables:
|
48
|
+
```markdown
|
49
|
+
# Task List: {{ feature_name }}
|
50
|
+
## Metadata
|
51
|
+
- **Total Tasks**: {{ task_count }}
|
52
|
+
- **Estimated Duration**: {{ total_duration }}
|
53
|
+
```
|
54
|
+
|
55
|
+
d. **Generate structured task categories**:
|
56
|
+
- **Constitutional Gates Compliance**: Pre-implementation validation
|
57
|
+
- **Critical Path (Phase 0)**: Tasks that impact timeline
|
58
|
+
- **Parallel Groups**: Tasks that can execute simultaneously
|
59
|
+
- **Sequential Tasks**: Tasks with dependencies
|
60
|
+
- **Execution Schedule**: Time-based task organization
|
61
|
+
- **Progress Tracking**: YAML configuration for monitoring
|
62
|
+
|
63
|
+
e. **For each task**, generate comprehensive metadata:
|
64
|
+
- **ID**: T[XXX] format (T001, T002)
|
65
|
+
- **Type**: setup, development, testing, documentation
|
66
|
+
- **Priority**: HIGH, MEDIUM, LOW
|
67
|
+
- **Estimate**: Hours or complexity points
|
68
|
+
- **Dependencies**: Task ID dependencies
|
69
|
+
- **Description**: Clear what needs to be done
|
70
|
+
- **Acceptance**: How to verify completion
|
71
|
+
- **Files**: Files to be created/modified
|
72
|
+
- **Assignable**: Role/skill required
|
73
|
+
- **Parallel**: Whether can run in parallel [P]
|
74
|
+
|
75
|
+
f. **Generate execution commands** with script integration:
|
76
|
+
```bash
|
77
|
+
# Execute parallel tasks
|
78
|
+
parallel_tasks="T001 T002 T003"
|
79
|
+
for task in $parallel_tasks; do
|
80
|
+
./scripts/execute-task.sh "$task" &
|
81
|
+
done
|
82
|
+
wait
|
83
|
+
```
|
84
|
+
|
85
|
+
g. **Write comprehensive task breakdown** to `tasks/XXX-feature/tasks.md`
|
51
86
|
|
52
87
|
3. **For `/task update`:**
|
53
|
-
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
88
|
+
- **Enhanced analysis** using cross-platform script:
|
89
|
+
```bash
|
90
|
+
# Cross-platform detection
|
91
|
+
if [[ "$OSTYPE" == "msys" || "$OSTYPE" == "win32" ]]; then
|
92
|
+
powershell scripts/pulse-task.ps1 "$FEATURE_DIR"
|
93
|
+
else
|
94
|
+
bash scripts/pulse-task.sh "$FEATURE_DIR" || python scripts/pulse-task.py "$FEATURE_DIR"
|
95
|
+
fi
|
96
|
+
```
|
97
|
+
- **Parse current tasks** with comprehensive status:
|
98
|
+
- Total tasks, completed, pending, blocked
|
99
|
+
- Parallel tasks identification
|
100
|
+
- Constitutional gates status
|
101
|
+
- Completion percentage calculation
|
102
|
+
- **Interactive task updates**:
|
103
|
+
- Mark tasks as completed/in-progress/blocked
|
104
|
+
- Update dependencies and blockers
|
105
|
+
- Add newly discovered tasks with proper metadata
|
106
|
+
- Adjust estimates based on actual progress
|
107
|
+
- **Generate updated progress tracking** YAML
|
59
108
|
|
60
109
|
4. **For `/task status`:**
|
61
|
-
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
110
|
+
- **Enhanced reporting** from script output:
|
111
|
+
```bash
|
112
|
+
TOTAL_TASKS=25
|
113
|
+
COMPLETED_TASKS=10
|
114
|
+
COMPLETION_PERCENTAGE=40%
|
115
|
+
CONSTITUTIONAL_GATES_PENDING=2
|
116
|
+
```
|
117
|
+
- **Display comprehensive progress**:
|
118
|
+
- Overall completion percentage
|
119
|
+
- Phase-by-phase progress
|
120
|
+
- Blocker identification and resolution
|
121
|
+
- Velocity metrics and estimates
|
122
|
+
- Constitutional gates compliance status
|
123
|
+
|
124
|
+
5. **For `/task execute`:**
|
125
|
+
- **Validate task readiness** using constitutional gates
|
126
|
+
- **Execute task** with enhanced error handling:
|
127
|
+
```bash
|
128
|
+
./scripts/execute-task.sh "$TASK_ID"
|
129
|
+
```
|
130
|
+
- **Track execution results** and update status
|
131
|
+
- **Update progress tracking** automatically
|
132
|
+
|
133
|
+
## Enhanced Task Format
|
69
134
|
```markdown
|
70
|
-
|
71
|
-
|
72
|
-
-
|
135
|
+
### Parallel Group A
|
136
|
+
#### T001: Initialize project structure
|
137
|
+
- **Type**: setup
|
138
|
+
- **Priority**: HIGH
|
139
|
+
- **Estimate**: 2 hours
|
140
|
+
- **Dependencies**: None
|
141
|
+
- **Description**: Set up project directory structure and configuration
|
142
|
+
- **Acceptance**: All directories exist and config files are valid
|
143
|
+
- **Files**: package.json, README.md, .gitignore
|
144
|
+
- **Assignable**: developer
|
145
|
+
- **Parallel**: [P]
|
146
|
+
|
147
|
+
## Progress Tracking
|
148
|
+
```yaml
|
149
|
+
status:
|
150
|
+
total: 25
|
151
|
+
completed: 10
|
152
|
+
in_progress: 3
|
153
|
+
blocked: 0
|
154
|
+
|
155
|
+
metrics:
|
156
|
+
velocity: 2-3 tasks/day
|
157
|
+
estimated_completion: 2025-09-15
|
158
|
+
completion_percentage: 40%
|
73
159
|
```
|
74
160
|
|
75
|
-
##
|
161
|
+
## Constitutional Gates Integration
|
162
|
+
|
163
|
+
Each task breakdown includes constitutional compliance validation:
|
164
|
+
- **Simplicity Gate**: Tasks avoid unnecessary complexity
|
165
|
+
- **Test-First Gate**: Test tasks before implementation tasks
|
166
|
+
- **Integration-First Gate**: Real service integration preferred
|
167
|
+
- **Research Gate**: Technology research tasks included
|
168
|
+
|
169
|
+
## Examples
|
170
|
+
|
171
|
+
### Generate task breakdown
|
172
|
+
```
|
173
|
+
User: /task breakdown
|
76
174
|
```
|
77
|
-
|
78
|
-
|
175
|
+
I will:
|
176
|
+
- Run: Cross-platform detection and execution
|
177
|
+
```bash
|
178
|
+
# Cross-platform detection
|
179
|
+
if [[ "$OSTYPE" == "msys" || "$OSTYPE" == "win32" ]]; then
|
180
|
+
powershell scripts/pulse-task.ps1 "$FEATURE_DIR"
|
181
|
+
else
|
182
|
+
bash scripts/pulse-task.sh "$FEATURE_DIR" || python scripts/pulse-task.py "$FEATURE_DIR"
|
183
|
+
fi
|
184
|
+
```
|
185
|
+
- Create: AI-optimized task structure with template variables
|
186
|
+
- Output: `TOTAL_TASKS=25, PARALLEL_TASKS=8, STATUS=generated`
|
187
|
+
|
188
|
+
### Update task status
|
189
|
+
```
|
190
|
+
User: /task update mark T001-T005 as completed
|
191
|
+
```
|
192
|
+
I will update task status and recalculate progress metrics.
|
193
|
+
|
194
|
+
### Show comprehensive status
|
195
|
+
```
|
196
|
+
User: /task status
|
197
|
+
```
|
198
|
+
I will display detailed progress with constitutional gates compliance.
|
199
|
+
|
200
|
+
### Execute specific task
|
201
|
+
```
|
202
|
+
User: /task execute T001
|
203
|
+
```
|
204
|
+
I will:
|
205
|
+
- Validate: Constitutional gates compliance and task readiness
|
206
|
+
- Execute: Cross-platform task execution
|
207
|
+
```bash
|
208
|
+
# Cross-platform task execution
|
209
|
+
if [[ "$OSTYPE" == "msys" || "$OSTYPE" == "win32" ]]; then
|
210
|
+
powershell scripts/pulse-task.ps1 "$FEATURE_DIR" "execute:$TASK_ID"
|
211
|
+
else
|
212
|
+
bash scripts/pulse-task.sh "$FEATURE_DIR" "execute:$TASK_ID" || python scripts/pulse-task.py "$FEATURE_DIR" "execute:$TASK_ID"
|
213
|
+
fi
|
214
|
+
```
|
215
|
+
- Track: Results and update progress automatically
|
216
|
+
|
217
|
+
## Enhanced Features
|
218
|
+
|
219
|
+
- **Cross-platform script execution** with automatic detection (PowerShell/Bash/Python)
|
220
|
+
- **AI-optimized templates** with Jinja2-style variables
|
221
|
+
- **Enhanced script integration** for validation and execution
|
222
|
+
- **Constitutional gates compliance** tracking
|
223
|
+
- **Parallel task identification** and execution
|
224
|
+
- **Comprehensive progress tracking** with YAML configuration
|
225
|
+
- **Automatic percentage calculation** and velocity metrics
|
226
|
+
- **Task dependency management** with conflict detection
|
227
|
+
- **Execution command generation** with script integration
|
228
|
+
- **Platform-agnostic operation** for Windows, Linux, and macOS
|
229
|
+
|
230
|
+
## Error Handling
|
231
|
+
|
232
|
+
- Plan existence validation before task generation
|
233
|
+
- Constitutional gates compliance checking
|
234
|
+
- Template structure validation
|
235
|
+
- Dependency conflict detection
|
236
|
+
- Task execution error handling with rollback
|
237
|
+
- Progress tracking validation and correction
|
@@ -29,14 +29,22 @@ Parse arguments to determine action:
|
|
29
29
|
- Create simplification roadmap
|
30
30
|
|
31
31
|
5. Write plan to plans/XXX-feature/plan.md
|
32
|
+
6. Run cross-platform validation:
|
33
|
+
- Windows: !{powershell scripts/pulse-plan.ps1 "XXX-feature"}
|
34
|
+
- Linux/macOS: !{bash scripts/pulse-plan.sh "XXX-feature"}
|
35
|
+
- Fallback: !{python scripts/pulse-plan.py "XXX-feature"}
|
32
36
|
|
33
37
|
## For /plan validate:
|
34
38
|
1. Read existing plan from @{plans/*/plan.md}
|
35
|
-
2.
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
39
|
+
2. Run cross-platform validation:
|
40
|
+
- Windows: !{powershell scripts/pulse-plan.ps1 "XXX-feature"}
|
41
|
+
- Linux/macOS: !{bash scripts/pulse-plan.sh "XXX-feature"}
|
42
|
+
- Fallback: !{python scripts/pulse-plan.py "XXX-feature"}
|
43
|
+
3. Verify Phase Gates compliance
|
44
|
+
4. Check complexity tracking
|
45
|
+
5. Ensure test-first approach
|
46
|
+
6. Validate framework choices
|
47
|
+
7. Report validation results
|
40
48
|
|
41
49
|
Phase Gates (Phase -1) must pass before implementation:
|
42
50
|
- ✅ Using ≤3 projects/modules
|
@@ -5,7 +5,10 @@ Initialize a new SpecPulse feature with the name: {{args}}
|
|
5
5
|
Please follow these steps:
|
6
6
|
|
7
7
|
1. Extract the feature name from the provided arguments
|
8
|
-
2. Run the initialization script
|
8
|
+
2. Run the initialization script with cross-platform detection:
|
9
|
+
- Windows: !{powershell scripts/pulse-init.ps1 "{{args}}"}
|
10
|
+
- Linux/macOS: !{bash scripts/pulse-init.sh "{{args}}"}
|
11
|
+
- Fallback: !{python scripts/pulse-init.py "{{args}"}
|
9
12
|
3. Create the feature structure:
|
10
13
|
- Generate feature ID (001, 002, etc.)
|
11
14
|
- Create directories: specs/XXX-feature/, plans/XXX-feature/, tasks/XXX-feature/
|
@@ -17,6 +17,10 @@ Parse the arguments to determine the action:
|
|
17
17
|
3. Mark any uncertainties with [NEEDS CLARIFICATION: detail]
|
18
18
|
4. Find current feature directory (latest in specs/)
|
19
19
|
5. Write specification to specs/XXX-feature/spec.md
|
20
|
+
6. Run cross-platform validation:
|
21
|
+
- Windows: !{powershell scripts/pulse-spec.ps1 "XXX-feature"}
|
22
|
+
- Linux/macOS: !{bash scripts/pulse-spec.sh "XXX-feature"}
|
23
|
+
- Fallback: !{python scripts/pulse-spec.py "XXX-feature"}
|
20
24
|
|
21
25
|
## For /spec update:
|
22
26
|
1. Read existing specification from @{specs/*/spec.md}
|
@@ -25,10 +29,14 @@ Parse the arguments to determine the action:
|
|
25
29
|
4. Remove resolved [NEEDS CLARIFICATION] markers
|
26
30
|
|
27
31
|
## For /spec validate:
|
28
|
-
1.
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
+
1. Run cross-platform validation:
|
33
|
+
- Windows: !{powershell scripts/pulse-spec.ps1 "XXX-feature"}
|
34
|
+
- Linux/macOS: !{bash scripts/pulse-spec.sh "XXX-feature"}
|
35
|
+
- Fallback: !{python scripts/pulse-spec.py "XXX-feature"}
|
36
|
+
2. Check all required sections are filled
|
37
|
+
3. Count [NEEDS CLARIFICATION] markers
|
38
|
+
4. Verify acceptance criteria are testable
|
39
|
+
5. Report validation results
|
32
40
|
|
33
41
|
Examples:
|
34
42
|
- /spec user authentication with OAuth2 and email/password
|
@@ -26,6 +26,10 @@ Parse arguments to determine action:
|
|
26
26
|
• Assign priority
|
27
27
|
|
28
28
|
3. Write tasks to tasks/XXX-feature/tasks.md
|
29
|
+
4. Run cross-platform validation:
|
30
|
+
- Windows: !{powershell scripts/pulse-task.ps1 "XXX-feature"}
|
31
|
+
- Linux/macOS: !{bash scripts/pulse-task.sh "XXX-feature"}
|
32
|
+
- Fallback: !{python scripts/pulse-task.py "XXX-feature"}
|
29
33
|
|
30
34
|
## For /task update:
|
31
35
|
1. Read current tasks from @{tasks/*/tasks.md}
|
@@ -34,14 +38,22 @@ Parse arguments to determine action:
|
|
34
38
|
4. Add newly discovered tasks
|
35
39
|
5. Update dependencies and blockers
|
36
40
|
6. Save updated task list
|
41
|
+
7. Run cross-platform validation:
|
42
|
+
- Windows: !{powershell scripts/pulse-task.ps1 "XXX-feature"}
|
43
|
+
- Linux/macOS: !{bash scripts/pulse-task.sh "XXX-feature"}
|
44
|
+
- Fallback: !{python scripts/pulse-task.py "XXX-feature"}
|
37
45
|
|
38
46
|
## For /task status:
|
39
47
|
1. Read current tasks
|
40
|
-
2.
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
48
|
+
2. Run cross-platform analysis:
|
49
|
+
- Windows: !{powershell scripts/pulse-task.ps1 "XXX-feature"}
|
50
|
+
- Linux/macOS: !{bash scripts/pulse-task.sh "XXX-feature"}
|
51
|
+
- Fallback: !{python scripts/pulse-task.py "XXX-feature"}
|
52
|
+
3. Count completed vs total
|
53
|
+
4. Show current phase progress
|
54
|
+
5. List any blockers
|
55
|
+
6. Estimate remaining work
|
56
|
+
7. Display progress summary
|
45
57
|
|
46
58
|
Task Format:
|
47
59
|
```markdown
|
@@ -124,7 +124,7 @@ complexity_exceptions:
|
|
124
124
|
violation: "Using 4 projects instead of 3"
|
125
125
|
justification: "Authentication requires separate service for security isolation"
|
126
126
|
approved_by: "Team Lead"
|
127
|
-
date: "
|
127
|
+
date: "2025-09-11"
|
128
128
|
```
|
129
129
|
|
130
130
|
### Amendment Process
|
@@ -233,5 +233,5 @@ While principles are immutable, their application can evolve:
|
|
233
233
|
## Living Constitution
|
234
234
|
This constitution is a living document that learns from experience while maintaining core principles. Each project iteration strengthens these principles through practical application and refinement.
|
235
235
|
|
236
|
-
*Last Updated:
|
236
|
+
*Last Updated: 2025-09-11*
|
237
237
|
*Version: 2.0 - Full SDD Methodology Implementation*
|
@@ -0,0 +1,186 @@
|
|
1
|
+
# SpecPulse Feature Initialization Script
|
2
|
+
# Cross-platform PowerShell equivalent of pulse-init.sh
|
3
|
+
|
4
|
+
param(
|
5
|
+
[Parameter(Mandatory=$true)]
|
6
|
+
[string]$FeatureName,
|
7
|
+
|
8
|
+
[string]$CustomId = ""
|
9
|
+
)
|
10
|
+
|
11
|
+
$ErrorActionPreference = "Stop"
|
12
|
+
$ProgressPreference = "SilentlyContinue"
|
13
|
+
|
14
|
+
# Configuration
|
15
|
+
$ScriptName = $MyInvocation.MyCommand.Name
|
16
|
+
$ProjectRoot = $PSScriptRoot | Split-Path -Parent | Split-Path -Parent
|
17
|
+
$MemoryDir = Join-Path $ProjectRoot "memory"
|
18
|
+
$ContextFile = Join-Path $MemoryDir "context.md"
|
19
|
+
$TemplatesDir = Join-Path $ProjectRoot "resources" "templates"
|
20
|
+
|
21
|
+
function Write-Log {
|
22
|
+
param([string]$Message)
|
23
|
+
$Timestamp = Get-Date -Format "yyyy-MM-dd HH:mm:ss"
|
24
|
+
Write-Host "[$Timestamp] $ScriptName : $Message" -ForegroundColor Yellow
|
25
|
+
}
|
26
|
+
|
27
|
+
function Exit-WithError {
|
28
|
+
param([string]$Message)
|
29
|
+
Write-Log "ERROR: $Message"
|
30
|
+
exit 1
|
31
|
+
}
|
32
|
+
|
33
|
+
function Sanitize-FeatureName {
|
34
|
+
param([string]$Name)
|
35
|
+
|
36
|
+
if ([string]::IsNullOrWhiteSpace($Name)) {
|
37
|
+
Exit-WithError "Feature name cannot be empty"
|
38
|
+
}
|
39
|
+
|
40
|
+
# Convert to lowercase, replace spaces and special chars with hyphens
|
41
|
+
$Sanitized = $Name.ToLower() -replace '[^a-z0-9-]', '-'
|
42
|
+
$Sanitized = $Sanitized -replace '-+', '-' # Remove consecutive hyphens
|
43
|
+
$Sanitized = $Sanitized.Trim('-') # Remove leading/trailing hyphens
|
44
|
+
|
45
|
+
if ([string]::IsNullOrWhiteSpace($Sanitized)) {
|
46
|
+
Exit-WithError "Invalid feature name: '$Name'"
|
47
|
+
}
|
48
|
+
|
49
|
+
return $Sanitized
|
50
|
+
}
|
51
|
+
|
52
|
+
function Get-FeatureId {
|
53
|
+
param([string]$CustomId)
|
54
|
+
|
55
|
+
if ($CustomId) {
|
56
|
+
return "{0:D3}" -f [int]$CustomId
|
57
|
+
}
|
58
|
+
|
59
|
+
# Find existing feature directories
|
60
|
+
$SpecsDir = Join-Path $ProjectRoot "specs"
|
61
|
+
if (Test-Path $SpecsDir) {
|
62
|
+
$Existing = Get-ChildItem -Path $SpecsDir -Directory |
|
63
|
+
Where-Object { $_.Name -match '^\d+$' } |
|
64
|
+
Sort-Object Name
|
65
|
+
$NextId = $Existing.Count + 1
|
66
|
+
} else {
|
67
|
+
$NextId = 1
|
68
|
+
}
|
69
|
+
|
70
|
+
return "{0:D3}" -f $NextId
|
71
|
+
}
|
72
|
+
|
73
|
+
function Create-Directories {
|
74
|
+
param([string]$BranchName)
|
75
|
+
|
76
|
+
$Directories = @(
|
77
|
+
(Join-Path $ProjectRoot "specs" $BranchName),
|
78
|
+
(Join-Path $ProjectRoot "plans" $BranchName),
|
79
|
+
(Join-Path $ProjectRoot "tasks" $BranchName)
|
80
|
+
)
|
81
|
+
|
82
|
+
foreach ($Directory in $Directories) {
|
83
|
+
try {
|
84
|
+
New-Item -ItemType Directory -Path $Directory -Force | Out-Null
|
85
|
+
Write-Log "Created directory: $Directory"
|
86
|
+
} catch {
|
87
|
+
Exit-WithError "Failed to create directory $Directory : $_"
|
88
|
+
}
|
89
|
+
}
|
90
|
+
}
|
91
|
+
|
92
|
+
function Copy-Templates {
|
93
|
+
param([string]$BranchName)
|
94
|
+
|
95
|
+
$Templates = @{
|
96
|
+
"spec.md" = (Join-Path $ProjectRoot "specs" $BranchName "spec.md")
|
97
|
+
"plan.md" = (Join-Path $ProjectRoot "plans" $BranchName "plan.md")
|
98
|
+
"task.md" = (Join-Path $ProjectRoot "tasks" $BranchName "tasks.md")
|
99
|
+
}
|
100
|
+
|
101
|
+
foreach ($Template in $Templates.GetEnumerator()) {
|
102
|
+
$TemplatePath = Join-Path $TemplatesDir $Template.Key
|
103
|
+
$TargetPath = $Template.Value
|
104
|
+
|
105
|
+
if (-not (Test-Path $TemplatePath)) {
|
106
|
+
Exit-WithError "Template not found: $TemplatePath"
|
107
|
+
}
|
108
|
+
|
109
|
+
try {
|
110
|
+
Copy-Item $TemplatePath $TargetPath -Force
|
111
|
+
Write-Log "Copied template to: $TargetPath"
|
112
|
+
} catch {
|
113
|
+
Exit-WithError "Failed to copy template $TemplatePath : $_"
|
114
|
+
}
|
115
|
+
}
|
116
|
+
}
|
117
|
+
|
118
|
+
function Update-Context {
|
119
|
+
param(
|
120
|
+
[string]$FeatureName,
|
121
|
+
[string]$FeatureId,
|
122
|
+
[string]$BranchName
|
123
|
+
)
|
124
|
+
|
125
|
+
try {
|
126
|
+
New-Item -ItemType Directory -Path $MemoryDir -Force | Out-Null
|
127
|
+
|
128
|
+
$ContextEntry = @"
|
129
|
+
|
130
|
+
## Active Feature: $FeatureName
|
131
|
+
- Feature ID: $FeatureId
|
132
|
+
- Branch: $BranchName
|
133
|
+
- Started: $(Get-Date -Format "o")
|
134
|
+
"@
|
135
|
+
|
136
|
+
Add-Content -Path $ContextFile -Value $ContextEntry -Encoding UTF8
|
137
|
+
Write-Log "Updated context file: $ContextFile"
|
138
|
+
} catch {
|
139
|
+
Exit-WithError "Failed to update context file: $_"
|
140
|
+
}
|
141
|
+
}
|
142
|
+
|
143
|
+
function New-GitBranch {
|
144
|
+
param([string]$BranchName)
|
145
|
+
|
146
|
+
$GitDir = Join-Path $ProjectRoot ".git"
|
147
|
+
if (-not (Test-Path $GitDir)) {
|
148
|
+
return
|
149
|
+
}
|
150
|
+
|
151
|
+
try {
|
152
|
+
# Check if branch already exists
|
153
|
+
$ExistingBranch = git branch --list $BranchName
|
154
|
+
if ($ExistingBranch) {
|
155
|
+
Write-Log "Git branch '$BranchName' already exists, checking out"
|
156
|
+
git checkout $BranchName
|
157
|
+
} else {
|
158
|
+
Write-Log "Creating new git branch '$BranchName'"
|
159
|
+
git checkout -b $BranchName
|
160
|
+
}
|
161
|
+
} catch {
|
162
|
+
Exit-WithError "Git operation failed: $_"
|
163
|
+
}
|
164
|
+
}
|
165
|
+
|
166
|
+
# Main execution
|
167
|
+
Write-Log "Initializing feature: $FeatureName"
|
168
|
+
|
169
|
+
# Sanitize and generate identifiers
|
170
|
+
$SanitizedName = Sanitize-FeatureName -Name $FeatureName
|
171
|
+
$FeatureId = Get-FeatureId -CustomId $CustomId
|
172
|
+
$BranchName = "$FeatureId-$SanitizedName"
|
173
|
+
|
174
|
+
# Create structure
|
175
|
+
Create-Directories -BranchName $BranchName
|
176
|
+
Copy-Templates -BranchName $BranchName
|
177
|
+
Update-Context -FeatureName $FeatureName -FeatureId $FeatureId -BranchName $BranchName
|
178
|
+
New-GitBranch -BranchName $BranchName
|
179
|
+
|
180
|
+
# Output results
|
181
|
+
Write-Host "BRANCH_NAME=$BranchName"
|
182
|
+
Write-Host "SPEC_DIR=specs/$BranchName"
|
183
|
+
Write-Host "FEATURE_ID=$FeatureId"
|
184
|
+
Write-Host "STATUS=initialized"
|
185
|
+
|
186
|
+
Write-Log "Successfully initialized feature '$FeatureName' with ID $FeatureId"
|