@pjmendonca/devflow 1.9.0
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.
- package/CHANGELOG.md +526 -0
- package/LICENSE +21 -0
- package/README.md +620 -0
- package/bin/devflow-checkpoint.js +10 -0
- package/bin/devflow-collab.js +10 -0
- package/bin/devflow-cost.js +10 -0
- package/bin/devflow-create-persona.js +10 -0
- package/bin/devflow-init.js +10 -0
- package/bin/devflow-memory.js +10 -0
- package/bin/devflow-new-doc.js +10 -0
- package/bin/devflow-personalize.js +10 -0
- package/bin/devflow-setup-checkpoint.js +10 -0
- package/bin/devflow-story.js +10 -0
- package/bin/devflow-tech-debt.js +10 -0
- package/bin/devflow-validate-overrides.js +10 -0
- package/bin/devflow-validate.js +10 -0
- package/bin/devflow-version.js +10 -0
- package/lib/constants.js +30 -0
- package/lib/exec-python.js +78 -0
- package/lib/python-check.js +178 -0
- package/package.json +64 -0
- package/tooling/.automation/agents/architect.md +135 -0
- package/tooling/.automation/agents/ba.md +70 -0
- package/tooling/.automation/agents/dev.md +79 -0
- package/tooling/.automation/agents/maintainer.md +97 -0
- package/tooling/.automation/agents/pm.md +116 -0
- package/tooling/.automation/agents/reviewer.md +141 -0
- package/tooling/.automation/agents/sm.md +61 -0
- package/tooling/.automation/agents/writer.md +193 -0
- package/tooling/.automation/config.ps1.template +61 -0
- package/tooling/.automation/config.sh.template +48 -0
- package/tooling/.automation/memory/.gitkeep +6 -0
- package/tooling/.automation/memory/knowledge/kg_integration-test.json +94 -0
- package/tooling/.automation/memory/knowledge/kg_test-story.json +300 -0
- package/tooling/.automation/memory/shared/shared_integration-test.json +30 -0
- package/tooling/.automation/memory/shared/shared_test-story.json +78 -0
- package/tooling/.automation/overrides/templates/README.md +113 -0
- package/tooling/.automation/overrides/templates/architect/README.md +27 -0
- package/tooling/.automation/overrides/templates/architect/cloud-native.yaml +92 -0
- package/tooling/.automation/overrides/templates/architect/enterprise-architect.yaml +85 -0
- package/tooling/.automation/overrides/templates/architect/pragmatic-minimalist.yaml +88 -0
- package/tooling/.automation/overrides/templates/ba/README.md +27 -0
- package/tooling/.automation/overrides/templates/ba/agile-storyteller.yaml +86 -0
- package/tooling/.automation/overrides/templates/ba/domain-expert.yaml +91 -0
- package/tooling/.automation/overrides/templates/ba/requirements-engineer.yaml +89 -0
- package/tooling/.automation/overrides/templates/dev/README.md +32 -0
- package/tooling/.automation/overrides/templates/dev/junior-mentored.yaml +39 -0
- package/tooling/.automation/overrides/templates/dev/performance-engineer.yaml +43 -0
- package/tooling/.automation/overrides/templates/dev/rapid-prototyper.yaml +52 -0
- package/tooling/.automation/overrides/templates/dev/security-focused.yaml +43 -0
- package/tooling/.automation/overrides/templates/dev/senior-fullstack.yaml +39 -0
- package/tooling/.automation/overrides/templates/maintainer/README.md +27 -0
- package/tooling/.automation/overrides/templates/maintainer/devops-maintainer.yaml +113 -0
- package/tooling/.automation/overrides/templates/maintainer/legacy-steward.yaml +94 -0
- package/tooling/.automation/overrides/templates/maintainer/oss-maintainer.yaml +94 -0
- package/tooling/.automation/overrides/templates/pm/README.md +27 -0
- package/tooling/.automation/overrides/templates/pm/agile-pm.yaml +91 -0
- package/tooling/.automation/overrides/templates/pm/hybrid-delivery.yaml +87 -0
- package/tooling/.automation/overrides/templates/pm/traditional-pm.yaml +91 -0
- package/tooling/.automation/overrides/templates/reviewer/README.md +11 -0
- package/tooling/.automation/overrides/templates/reviewer/mentoring-reviewer.yaml +45 -0
- package/tooling/.automation/overrides/templates/reviewer/quick-sanity.yaml +50 -0
- package/tooling/.automation/overrides/templates/reviewer/thorough-critic.yaml +48 -0
- package/tooling/.automation/overrides/templates/sm/README.md +11 -0
- package/tooling/.automation/overrides/templates/sm/agile-coach.yaml +52 -0
- package/tooling/.automation/overrides/templates/sm/startup-pm.yaml +50 -0
- package/tooling/.automation/overrides/templates/sm/technical-lead.yaml +47 -0
- package/tooling/.automation/overrides/templates/user-profile.template.yaml +62 -0
- package/tooling/.automation/overrides/templates/writer/README.md +27 -0
- package/tooling/.automation/overrides/templates/writer/api-documentarian.yaml +99 -0
- package/tooling/.automation/overrides/templates/writer/docs-as-code.yaml +108 -0
- package/tooling/.automation/overrides/templates/writer/user-guide-author.yaml +100 -0
- package/tooling/completions/DevflowCompletion.ps1 +213 -0
- package/tooling/completions/_run-story +116 -0
- package/tooling/completions/run-story-completion.bash +136 -0
- package/tooling/docs/DOC-STANDARD.md +717 -0
- package/tooling/docs/sprint-status.yaml.template +24 -0
- package/tooling/docs/templates/bug-report.md +234 -0
- package/tooling/docs/templates/migration-spec.md +274 -0
- package/tooling/docs/templates/refactor-spec.md +86 -0
- package/tooling/docs/templates/tech-debt.md +86 -0
- package/tooling/scripts/context_checkpoint.py +556 -0
- package/tooling/scripts/cost_dashboard.py +617 -0
- package/tooling/scripts/create-persona.py +690 -0
- package/tooling/scripts/create-persona.sh +435 -0
- package/tooling/scripts/init-project-workflow.ps1 +651 -0
- package/tooling/scripts/init-project-workflow.py +70 -0
- package/tooling/scripts/init-project-workflow.sh +746 -0
- package/tooling/scripts/lib/__init__.py +35 -0
- package/tooling/scripts/lib/agent_handoff.py +526 -0
- package/tooling/scripts/lib/agent_router.py +698 -0
- package/tooling/scripts/lib/checkpoint-integration.ps1 +245 -0
- package/tooling/scripts/lib/checkpoint-integration.sh +191 -0
- package/tooling/scripts/lib/claude-cli.ps1 +952 -0
- package/tooling/scripts/lib/claude-cli.sh +1293 -0
- package/tooling/scripts/lib/cost_config.py +222 -0
- package/tooling/scripts/lib/cost_display.py +443 -0
- package/tooling/scripts/lib/cost_tracker.py +710 -0
- package/tooling/scripts/lib/currency_converter.py +328 -0
- package/tooling/scripts/lib/errors.py +438 -0
- package/tooling/scripts/lib/override-loader.sh +286 -0
- package/tooling/scripts/lib/pair_programming.py +589 -0
- package/tooling/scripts/lib/shared_memory.py +637 -0
- package/tooling/scripts/lib/swarm_orchestrator.py +689 -0
- package/tooling/scripts/memory_summarize.py +324 -0
- package/tooling/scripts/new-doc.ps1 +405 -0
- package/tooling/scripts/new-doc.py +93 -0
- package/tooling/scripts/new-doc.sh +534 -0
- package/tooling/scripts/personalize_agent.py +385 -0
- package/tooling/scripts/rollback-migration.sh +540 -0
- package/tooling/scripts/run-collab.ps1 +251 -0
- package/tooling/scripts/run-collab.py +605 -0
- package/tooling/scripts/run-collab.sh +110 -0
- package/tooling/scripts/run-story.ps1 +490 -0
- package/tooling/scripts/run-story.py +387 -0
- package/tooling/scripts/run-story.sh +467 -0
- package/tooling/scripts/setup-checkpoint-service.ps1 +219 -0
- package/tooling/scripts/setup-checkpoint-service.py +87 -0
- package/tooling/scripts/setup-checkpoint-service.sh +236 -0
- package/tooling/scripts/tech-debt-tracker.py +608 -0
- package/tooling/scripts/update_version.py +244 -0
- package/tooling/scripts/validate-overrides.py +511 -0
- package/tooling/scripts/validate-overrides.sh +432 -0
- package/tooling/scripts/validate_setup.py +539 -0
|
@@ -0,0 +1,952 @@
|
|
|
1
|
+
<#
|
|
2
|
+
.SYNOPSIS
|
|
3
|
+
Claude CLI Integration Library for Windows
|
|
4
|
+
|
|
5
|
+
.DESCRIPTION
|
|
6
|
+
Wrapper functions for invoking Claude Code CLI to execute workflows.
|
|
7
|
+
PowerShell equivalent of claude-cli.sh for Windows compatibility.
|
|
8
|
+
|
|
9
|
+
.NOTES
|
|
10
|
+
Version: 1.0.0
|
|
11
|
+
Requires: PowerShell 5.1+, Claude Code CLI
|
|
12
|
+
#>
|
|
13
|
+
|
|
14
|
+
#Requires -Version 5.1
|
|
15
|
+
|
|
16
|
+
# Script paths
|
|
17
|
+
$script:ScriptDir = Split-Path -Parent $MyInvocation.MyCommand.Path
|
|
18
|
+
$script:ProjectRoot = (Get-Item "$script:ScriptDir\..\..\.." -ErrorAction SilentlyContinue).FullName
|
|
19
|
+
if (-not $script:ProjectRoot) {
|
|
20
|
+
$script:ProjectRoot = (Get-Location).Path
|
|
21
|
+
}
|
|
22
|
+
$script:AutomationDir = Join-Path $script:ProjectRoot ".automation"
|
|
23
|
+
$script:AgentsDir = Join-Path $script:AutomationDir "agents"
|
|
24
|
+
$script:LogsDir = Join-Path $script:AutomationDir "logs"
|
|
25
|
+
$script:StoriesDir = Join-Path $script:ProjectRoot "docs"
|
|
26
|
+
|
|
27
|
+
# Source dependencies (silently continue if not found)
|
|
28
|
+
$checkpointIntegration = Join-Path $script:ScriptDir "checkpoint-integration.ps1"
|
|
29
|
+
if (Test-Path $checkpointIntegration) {
|
|
30
|
+
. $checkpointIntegration
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
# Claude CLI configuration
|
|
34
|
+
$script:ClaudeCLI = if ($env:CLAUDE_CLI) { $env:CLAUDE_CLI } else { "claude" }
|
|
35
|
+
$script:ClaudeModel = if ($env:CLAUDE_MODEL) { $env:CLAUDE_MODEL } else { "sonnet" }
|
|
36
|
+
$script:PermissionMode = if ($env:PERMISSION_MODE) { $env:PERMISSION_MODE } else { "dangerouslySkipPermissions" }
|
|
37
|
+
|
|
38
|
+
#region Helper Functions
|
|
39
|
+
|
|
40
|
+
function Get-PermissionFlags {
|
|
41
|
+
<#
|
|
42
|
+
.SYNOPSIS
|
|
43
|
+
Build permission flags based on mode
|
|
44
|
+
#>
|
|
45
|
+
switch ($script:PermissionMode) {
|
|
46
|
+
{ $_ -in "dangerouslySkipPermissions", "skip" } {
|
|
47
|
+
return "--dangerously-skip-permissions"
|
|
48
|
+
}
|
|
49
|
+
default {
|
|
50
|
+
return "--permission-mode $script:PermissionMode"
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
function Read-FileContent {
|
|
56
|
+
<#
|
|
57
|
+
.SYNOPSIS
|
|
58
|
+
Read file content for prompt
|
|
59
|
+
#>
|
|
60
|
+
param([string]$FilePath)
|
|
61
|
+
|
|
62
|
+
if (Test-Path $FilePath) {
|
|
63
|
+
return Get-Content $FilePath -Raw
|
|
64
|
+
}
|
|
65
|
+
return "[File not found: $FilePath]"
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
function Build-Prompt {
|
|
69
|
+
<#
|
|
70
|
+
.SYNOPSIS
|
|
71
|
+
Create a combined prompt from agent and workflow
|
|
72
|
+
#>
|
|
73
|
+
param(
|
|
74
|
+
[string]$AgentFile,
|
|
75
|
+
[string]$TaskDescription
|
|
76
|
+
)
|
|
77
|
+
|
|
78
|
+
$agentPrompt = ""
|
|
79
|
+
if (Test-Path $AgentFile) {
|
|
80
|
+
$agentPrompt = Get-Content $AgentFile -Raw
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
return @"
|
|
84
|
+
$agentPrompt
|
|
85
|
+
|
|
86
|
+
---
|
|
87
|
+
|
|
88
|
+
## Current Task
|
|
89
|
+
|
|
90
|
+
$TaskDescription
|
|
91
|
+
"@
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
#endregion
|
|
95
|
+
|
|
96
|
+
#region Persona Banner Functions
|
|
97
|
+
|
|
98
|
+
function Write-PersonaBanner {
|
|
99
|
+
<#
|
|
100
|
+
.SYNOPSIS
|
|
101
|
+
Print a colored persona banner for agent switches
|
|
102
|
+
#>
|
|
103
|
+
param(
|
|
104
|
+
[string]$Persona,
|
|
105
|
+
[string]$Role,
|
|
106
|
+
[string]$Color = "Cyan",
|
|
107
|
+
[string]$Model = ""
|
|
108
|
+
)
|
|
109
|
+
|
|
110
|
+
Write-Host ""
|
|
111
|
+
Write-Host ("{0}" -f ("=" * 65)) -ForegroundColor $Color
|
|
112
|
+
Write-Host " PERSONA SWITCH" -ForegroundColor $Color
|
|
113
|
+
Write-Host ("{0}" -f ("=" * 65)) -ForegroundColor $Color
|
|
114
|
+
Write-Host " Agent: " -NoNewline -ForegroundColor $Color
|
|
115
|
+
Write-Host $Persona
|
|
116
|
+
Write-Host " Role: " -NoNewline -ForegroundColor $Color
|
|
117
|
+
Write-Host $Role
|
|
118
|
+
if ($Model) {
|
|
119
|
+
Write-Host " Model: " -NoNewline -ForegroundColor $Color
|
|
120
|
+
Write-Host $Model
|
|
121
|
+
}
|
|
122
|
+
Write-Host ("{0}" -f ("=" * 65)) -ForegroundColor $Color
|
|
123
|
+
Write-Host ""
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
#endregion
|
|
127
|
+
|
|
128
|
+
#region Workflow Invocation Functions
|
|
129
|
+
|
|
130
|
+
function Invoke-SMStoryContext {
|
|
131
|
+
<#
|
|
132
|
+
.SYNOPSIS
|
|
133
|
+
SM agent for story context creation
|
|
134
|
+
#>
|
|
135
|
+
param([string]$StoryKey)
|
|
136
|
+
|
|
137
|
+
$storyFile = Join-Path $script:StoriesDir "$StoryKey.md"
|
|
138
|
+
$contextFile = Join-Path $script:StoriesDir "$StoryKey.context.xml"
|
|
139
|
+
$logFile = Join-Path $script:LogsDir "$StoryKey-context.log"
|
|
140
|
+
$model = "sonnet"
|
|
141
|
+
|
|
142
|
+
Write-PersonaBanner -Persona "SM (Scrum Master)" -Role "Story Context Creation & Planning" -Color "Yellow" -Model $model
|
|
143
|
+
|
|
144
|
+
Write-Host ">> Creating story context for: $StoryKey" -ForegroundColor Cyan
|
|
145
|
+
|
|
146
|
+
if (-not (Test-Path $storyFile)) {
|
|
147
|
+
Write-Host "X Story file not found: $storyFile" -ForegroundColor Red
|
|
148
|
+
return 1
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
$storyContent = Get-Content $storyFile -Raw
|
|
152
|
+
|
|
153
|
+
$prompt = @"
|
|
154
|
+
Create a technical context file for implementing this story.
|
|
155
|
+
|
|
156
|
+
## Story Specification
|
|
157
|
+
$storyContent
|
|
158
|
+
|
|
159
|
+
## Instructions
|
|
160
|
+
1. Read the story requirements carefully
|
|
161
|
+
2. Explore the codebase to find relevant patterns and existing code
|
|
162
|
+
3. Identify files that need to be created or modified
|
|
163
|
+
4. Create the context file at: $contextFile
|
|
164
|
+
|
|
165
|
+
The context.xml should include:
|
|
166
|
+
- story-key, title, status
|
|
167
|
+
- files-to-create list
|
|
168
|
+
- files-to-modify list
|
|
169
|
+
- dependencies
|
|
170
|
+
- testing-requirements
|
|
171
|
+
- project-paths (app-root: app, lib-path: app/lib, test-path: app/test)
|
|
172
|
+
|
|
173
|
+
After creating the context file, update sprint-status.yaml to set this story to 'ready-for-dev'.
|
|
174
|
+
"@
|
|
175
|
+
|
|
176
|
+
$agentFile = Join-Path $script:AgentsDir "sm.md"
|
|
177
|
+
$agentPrompt = ""
|
|
178
|
+
if (Test-Path $agentFile) {
|
|
179
|
+
$agentPrompt = Get-Content $agentFile -Raw
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
$permFlags = Get-PermissionFlags
|
|
183
|
+
|
|
184
|
+
Push-Location $script:ProjectRoot
|
|
185
|
+
try {
|
|
186
|
+
$prompt | & $script:ClaudeCLI -p `
|
|
187
|
+
--model $model `
|
|
188
|
+
$permFlags `
|
|
189
|
+
--append-system-prompt $agentPrompt `
|
|
190
|
+
--tools "Read,Write,Edit,Grep,Glob,Bash" `
|
|
191
|
+
--max-budget-usd 3.00 2>&1 | Tee-Object -FilePath $logFile
|
|
192
|
+
|
|
193
|
+
return $LASTEXITCODE
|
|
194
|
+
}
|
|
195
|
+
finally {
|
|
196
|
+
Pop-Location
|
|
197
|
+
}
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
function Invoke-DevStory {
|
|
201
|
+
<#
|
|
202
|
+
.SYNOPSIS
|
|
203
|
+
DEV agent for story implementation
|
|
204
|
+
#>
|
|
205
|
+
param([string]$StoryKey)
|
|
206
|
+
|
|
207
|
+
$storyFile = Join-Path $script:StoriesDir "$StoryKey.md"
|
|
208
|
+
$contextFile = Join-Path $script:StoriesDir "$StoryKey.context.xml"
|
|
209
|
+
$logFile = Join-Path $script:LogsDir "$StoryKey-develop.log"
|
|
210
|
+
$model = "opus"
|
|
211
|
+
|
|
212
|
+
Write-PersonaBanner -Persona "DEV (Developer)" -Role "Story Implementation & Coding" -Color "Green" -Model $model
|
|
213
|
+
|
|
214
|
+
Write-Host ">> Implementing story: $StoryKey" -ForegroundColor Cyan
|
|
215
|
+
|
|
216
|
+
if (-not (Test-Path $storyFile)) {
|
|
217
|
+
Write-Host "X Story file not found: $storyFile" -ForegroundColor Red
|
|
218
|
+
return 1
|
|
219
|
+
}
|
|
220
|
+
|
|
221
|
+
if (-not (Test-Path $contextFile)) {
|
|
222
|
+
Write-Host "X Context file not found: $contextFile" -ForegroundColor Red
|
|
223
|
+
return 1
|
|
224
|
+
}
|
|
225
|
+
|
|
226
|
+
Write-Host ">> Checking context feasibility..." -ForegroundColor Blue
|
|
227
|
+
|
|
228
|
+
$storyContent = Get-Content $storyFile -Raw
|
|
229
|
+
$contextContent = Get-Content $contextFile -Raw
|
|
230
|
+
|
|
231
|
+
$prompt = @"
|
|
232
|
+
IMPLEMENT THIS STORY NOW. Create all required files and code.
|
|
233
|
+
|
|
234
|
+
$storyContent
|
|
235
|
+
|
|
236
|
+
---
|
|
237
|
+
|
|
238
|
+
CONTEXT (files to create/modify):
|
|
239
|
+
$contextContent
|
|
240
|
+
|
|
241
|
+
---
|
|
242
|
+
|
|
243
|
+
START IMMEDIATELY:
|
|
244
|
+
1. Read existing code in app/lib/features/ to understand patterns
|
|
245
|
+
2. Create ALL files listed in files-to-create using the Write tool
|
|
246
|
+
3. Modify files listed in files-to-modify using the Edit tool
|
|
247
|
+
4. Write tests in app/test/
|
|
248
|
+
5. Run: cd app && flutter test
|
|
249
|
+
|
|
250
|
+
DO NOT explain or ask questions. Just implement the code.
|
|
251
|
+
"@
|
|
252
|
+
|
|
253
|
+
# Start checkpoint monitor if available
|
|
254
|
+
if (Get-Command Start-CheckpointMonitor -ErrorAction SilentlyContinue) {
|
|
255
|
+
Start-CheckpointMonitor -LogFile $logFile -SessionId $StoryKey
|
|
256
|
+
Write-CheckpointInfo -LogFile $logFile
|
|
257
|
+
}
|
|
258
|
+
|
|
259
|
+
# Create symlink to current.log
|
|
260
|
+
$currentLog = Join-Path $script:LogsDir "current.log"
|
|
261
|
+
if (Test-Path $currentLog) { Remove-Item $currentLog -Force }
|
|
262
|
+
try {
|
|
263
|
+
New-Item -ItemType SymbolicLink -Path $currentLog -Target $logFile -Force -ErrorAction SilentlyContinue | Out-Null
|
|
264
|
+
} catch {
|
|
265
|
+
# Symlinks may require admin on Windows, fallback to copy later
|
|
266
|
+
}
|
|
267
|
+
|
|
268
|
+
$agentFile = Join-Path $script:AgentsDir "dev.md"
|
|
269
|
+
$agentPrompt = ""
|
|
270
|
+
if (Test-Path $agentFile) {
|
|
271
|
+
$agentPrompt = Get-Content $agentFile -Raw
|
|
272
|
+
}
|
|
273
|
+
|
|
274
|
+
$permFlags = Get-PermissionFlags
|
|
275
|
+
|
|
276
|
+
Push-Location $script:ProjectRoot
|
|
277
|
+
try {
|
|
278
|
+
$prompt | & $script:ClaudeCLI -p `
|
|
279
|
+
--model $model `
|
|
280
|
+
$permFlags `
|
|
281
|
+
--append-system-prompt $agentPrompt `
|
|
282
|
+
--tools "Read,Write,Edit,Grep,Glob,Bash" `
|
|
283
|
+
--max-budget-usd 15.00 2>&1 | Tee-Object -FilePath $logFile
|
|
284
|
+
|
|
285
|
+
$exitCode = $LASTEXITCODE
|
|
286
|
+
|
|
287
|
+
# Stop checkpoint monitor if available
|
|
288
|
+
if (Get-Command Stop-CheckpointMonitor -ErrorAction SilentlyContinue) {
|
|
289
|
+
Stop-CheckpointMonitor -LogFile $logFile
|
|
290
|
+
}
|
|
291
|
+
|
|
292
|
+
return $exitCode
|
|
293
|
+
}
|
|
294
|
+
finally {
|
|
295
|
+
Pop-Location
|
|
296
|
+
}
|
|
297
|
+
}
|
|
298
|
+
|
|
299
|
+
function Invoke-SMCodeReview {
|
|
300
|
+
<#
|
|
301
|
+
.SYNOPSIS
|
|
302
|
+
SM agent for code review
|
|
303
|
+
#>
|
|
304
|
+
param([string]$StoryKey)
|
|
305
|
+
|
|
306
|
+
$storyFile = Join-Path $script:StoriesDir "$StoryKey.md"
|
|
307
|
+
$reviewFile = Join-Path $script:StoriesDir "$StoryKey.code-review.md"
|
|
308
|
+
$logFile = Join-Path $script:LogsDir "$StoryKey-review.log"
|
|
309
|
+
$model = "opus"
|
|
310
|
+
|
|
311
|
+
Write-PersonaBanner -Persona "SM (Scrum Master)" -Role "Code Review & Quality Assurance" -Color "Magenta" -Model $model
|
|
312
|
+
|
|
313
|
+
Write-Host ">> Reviewing implementation: $StoryKey" -ForegroundColor Cyan
|
|
314
|
+
|
|
315
|
+
if (-not (Test-Path $storyFile)) {
|
|
316
|
+
Write-Host "X Story file not found: $storyFile" -ForegroundColor Red
|
|
317
|
+
return 1
|
|
318
|
+
}
|
|
319
|
+
|
|
320
|
+
$storyContent = Get-Content $storyFile -Raw
|
|
321
|
+
|
|
322
|
+
$prompt = @"
|
|
323
|
+
Perform a code review for this implemented story.
|
|
324
|
+
|
|
325
|
+
## Story Specification
|
|
326
|
+
$storyContent
|
|
327
|
+
|
|
328
|
+
## Instructions
|
|
329
|
+
1. Read all acceptance criteria in the story
|
|
330
|
+
2. For each AC, verify it has been implemented correctly
|
|
331
|
+
3. Check code quality and patterns
|
|
332
|
+
4. Run 'cd app && flutter test' to verify tests pass
|
|
333
|
+
5. Create a review report at: $reviewFile
|
|
334
|
+
|
|
335
|
+
The review file should include:
|
|
336
|
+
- Overall verdict: APPROVED or CHANGES REQUESTED
|
|
337
|
+
- Score out of 100
|
|
338
|
+
- AC verification checklist (each AC marked as met/not met)
|
|
339
|
+
- Code quality notes
|
|
340
|
+
- Any issues found
|
|
341
|
+
|
|
342
|
+
If APPROVED, update sprint-status.yaml to 'done'.
|
|
343
|
+
If CHANGES REQUESTED, update sprint-status.yaml to 'in-progress' and list required changes.
|
|
344
|
+
"@
|
|
345
|
+
|
|
346
|
+
# Start checkpoint monitor if available
|
|
347
|
+
if (Get-Command Start-CheckpointMonitor -ErrorAction SilentlyContinue) {
|
|
348
|
+
Start-CheckpointMonitor -LogFile $logFile -SessionId $StoryKey
|
|
349
|
+
Write-CheckpointInfo -LogFile $logFile
|
|
350
|
+
}
|
|
351
|
+
|
|
352
|
+
# Create symlink to current.log
|
|
353
|
+
$currentLog = Join-Path $script:LogsDir "current.log"
|
|
354
|
+
if (Test-Path $currentLog) { Remove-Item $currentLog -Force }
|
|
355
|
+
try {
|
|
356
|
+
New-Item -ItemType SymbolicLink -Path $currentLog -Target $logFile -Force -ErrorAction SilentlyContinue | Out-Null
|
|
357
|
+
} catch {}
|
|
358
|
+
|
|
359
|
+
$agentFile = Join-Path $script:AgentsDir "sm.md"
|
|
360
|
+
$agentPrompt = ""
|
|
361
|
+
if (Test-Path $agentFile) {
|
|
362
|
+
$agentPrompt = Get-Content $agentFile -Raw
|
|
363
|
+
}
|
|
364
|
+
|
|
365
|
+
$permFlags = Get-PermissionFlags
|
|
366
|
+
|
|
367
|
+
Push-Location $script:ProjectRoot
|
|
368
|
+
try {
|
|
369
|
+
$prompt | & $script:ClaudeCLI -p `
|
|
370
|
+
--model $model `
|
|
371
|
+
$permFlags `
|
|
372
|
+
--append-system-prompt $agentPrompt `
|
|
373
|
+
--tools "Read,Write,Edit,Grep,Glob,Bash" `
|
|
374
|
+
--max-budget-usd 5.00 2>&1 | Tee-Object -FilePath $logFile
|
|
375
|
+
|
|
376
|
+
$exitCode = $LASTEXITCODE
|
|
377
|
+
|
|
378
|
+
if (Get-Command Stop-CheckpointMonitor -ErrorAction SilentlyContinue) {
|
|
379
|
+
Stop-CheckpointMonitor -LogFile $logFile
|
|
380
|
+
}
|
|
381
|
+
|
|
382
|
+
return $exitCode
|
|
383
|
+
}
|
|
384
|
+
finally {
|
|
385
|
+
Pop-Location
|
|
386
|
+
}
|
|
387
|
+
}
|
|
388
|
+
|
|
389
|
+
function Invoke-SMDraftStory {
|
|
390
|
+
<#
|
|
391
|
+
.SYNOPSIS
|
|
392
|
+
SM agent for story drafting
|
|
393
|
+
#>
|
|
394
|
+
param([string]$StoryKey)
|
|
395
|
+
|
|
396
|
+
$storyFile = Join-Path $script:StoriesDir "$StoryKey.md"
|
|
397
|
+
$epicsFile = Join-Path $script:ProjectRoot "docs\epics.md"
|
|
398
|
+
$logFile = Join-Path $script:LogsDir "$StoryKey-draft.log"
|
|
399
|
+
$model = "sonnet"
|
|
400
|
+
|
|
401
|
+
Write-PersonaBanner -Persona "SM (Scrum Master)" -Role "Story Drafting & Specification" -Color "Yellow" -Model $model
|
|
402
|
+
|
|
403
|
+
Write-Host ">> Drafting story: $StoryKey" -ForegroundColor Cyan
|
|
404
|
+
|
|
405
|
+
# Extract epic number from story key
|
|
406
|
+
$epicNum = ($StoryKey -split '-')[0]
|
|
407
|
+
|
|
408
|
+
$prompt = @"
|
|
409
|
+
Draft a detailed story specification.
|
|
410
|
+
|
|
411
|
+
Story Key: $StoryKey
|
|
412
|
+
Epic: $epicNum
|
|
413
|
+
|
|
414
|
+
## Instructions
|
|
415
|
+
1. Read the epics file at $epicsFile to understand the epic context
|
|
416
|
+
2. Find the story entry for $StoryKey in the epic
|
|
417
|
+
3. Create a detailed story specification at: $storyFile
|
|
418
|
+
|
|
419
|
+
The story file should include:
|
|
420
|
+
- # Title
|
|
421
|
+
- ## Summary
|
|
422
|
+
- ## Acceptance Criteria (numbered as AC X.Y.Z)
|
|
423
|
+
- ## Technical Notes
|
|
424
|
+
- ## Dependencies (if any)
|
|
425
|
+
- ## Testing Requirements
|
|
426
|
+
|
|
427
|
+
After creating the story, update sprint-status.yaml to set this story to 'drafted'.
|
|
428
|
+
"@
|
|
429
|
+
|
|
430
|
+
$agentFile = Join-Path $script:AgentsDir "sm.md"
|
|
431
|
+
$agentPrompt = ""
|
|
432
|
+
if (Test-Path $agentFile) {
|
|
433
|
+
$agentPrompt = Get-Content $agentFile -Raw
|
|
434
|
+
}
|
|
435
|
+
|
|
436
|
+
$permFlags = Get-PermissionFlags
|
|
437
|
+
|
|
438
|
+
Push-Location $script:ProjectRoot
|
|
439
|
+
try {
|
|
440
|
+
$prompt | & $script:ClaudeCLI -p `
|
|
441
|
+
--model $model `
|
|
442
|
+
$permFlags `
|
|
443
|
+
--append-system-prompt $agentPrompt `
|
|
444
|
+
--tools "Read,Write,Edit,Grep,Glob" `
|
|
445
|
+
--max-budget-usd 2.00 2>&1 | Tee-Object -FilePath $logFile
|
|
446
|
+
|
|
447
|
+
return $LASTEXITCODE
|
|
448
|
+
}
|
|
449
|
+
finally {
|
|
450
|
+
Pop-Location
|
|
451
|
+
}
|
|
452
|
+
}
|
|
453
|
+
|
|
454
|
+
function Invoke-BARequirements {
|
|
455
|
+
<#
|
|
456
|
+
.SYNOPSIS
|
|
457
|
+
BA agent for requirements analysis
|
|
458
|
+
#>
|
|
459
|
+
param([string]$FeatureName)
|
|
460
|
+
|
|
461
|
+
$outputFile = Join-Path $script:ProjectRoot "docs\requirements\$FeatureName.md"
|
|
462
|
+
$logFile = Join-Path $script:LogsDir "$FeatureName-requirements.log"
|
|
463
|
+
$model = "sonnet"
|
|
464
|
+
|
|
465
|
+
Write-PersonaBanner -Persona "BA (Business Analyst)" -Role "Requirements Analysis & User Stories" -Color "Blue" -Model $model
|
|
466
|
+
|
|
467
|
+
Write-Host ">> Analyzing requirements for: $FeatureName" -ForegroundColor Cyan
|
|
468
|
+
|
|
469
|
+
# Ensure directory exists
|
|
470
|
+
$reqDir = Join-Path $script:ProjectRoot "docs\requirements"
|
|
471
|
+
if (-not (Test-Path $reqDir)) {
|
|
472
|
+
New-Item -ItemType Directory -Path $reqDir -Force | Out-Null
|
|
473
|
+
}
|
|
474
|
+
|
|
475
|
+
$prompt = @"
|
|
476
|
+
Analyze and document requirements for the feature: $FeatureName
|
|
477
|
+
|
|
478
|
+
## Instructions
|
|
479
|
+
1. Read the PRD at tooling/docs/prd.md for product context
|
|
480
|
+
2. Read the epics at tooling/docs/epics.md for feature context
|
|
481
|
+
3. Create a detailed requirements document at: $outputFile
|
|
482
|
+
|
|
483
|
+
The requirements document should include:
|
|
484
|
+
- User stories with acceptance criteria
|
|
485
|
+
- Business rules
|
|
486
|
+
- Data requirements
|
|
487
|
+
- Edge cases and error scenarios
|
|
488
|
+
- Dependencies
|
|
489
|
+
|
|
490
|
+
Use the INVEST criteria for user stories.
|
|
491
|
+
"@
|
|
492
|
+
|
|
493
|
+
$agentFile = Join-Path $script:AgentsDir "ba.md"
|
|
494
|
+
$agentPrompt = ""
|
|
495
|
+
if (Test-Path $agentFile) {
|
|
496
|
+
$agentPrompt = Get-Content $agentFile -Raw
|
|
497
|
+
}
|
|
498
|
+
|
|
499
|
+
$permFlags = Get-PermissionFlags
|
|
500
|
+
|
|
501
|
+
Push-Location $script:ProjectRoot
|
|
502
|
+
try {
|
|
503
|
+
$prompt | & $script:ClaudeCLI -p `
|
|
504
|
+
--model $model `
|
|
505
|
+
$permFlags `
|
|
506
|
+
--append-system-prompt $agentPrompt `
|
|
507
|
+
--tools "Read,Write,Edit,Grep,Glob" `
|
|
508
|
+
--max-budget-usd 3.00 2>&1 | Tee-Object -FilePath $logFile
|
|
509
|
+
|
|
510
|
+
return $LASTEXITCODE
|
|
511
|
+
}
|
|
512
|
+
finally {
|
|
513
|
+
Pop-Location
|
|
514
|
+
}
|
|
515
|
+
}
|
|
516
|
+
|
|
517
|
+
function Invoke-ArchitectDesign {
|
|
518
|
+
<#
|
|
519
|
+
.SYNOPSIS
|
|
520
|
+
Architect agent for technical design
|
|
521
|
+
#>
|
|
522
|
+
param([string]$FeatureName)
|
|
523
|
+
|
|
524
|
+
$outputFile = Join-Path $script:StoriesDir "tech-spec-$FeatureName.md"
|
|
525
|
+
$logFile = Join-Path $script:LogsDir "$FeatureName-architecture.log"
|
|
526
|
+
$model = "sonnet"
|
|
527
|
+
|
|
528
|
+
Write-PersonaBanner -Persona "ARCHITECT" -Role "Technical Design & Architecture" -Color "Cyan" -Model $model
|
|
529
|
+
|
|
530
|
+
Write-Host ">> Creating technical specification for: $FeatureName" -ForegroundColor Cyan
|
|
531
|
+
|
|
532
|
+
$prompt = @"
|
|
533
|
+
Create a technical specification for: $FeatureName
|
|
534
|
+
|
|
535
|
+
## Instructions
|
|
536
|
+
1. Read the architecture documentation at tooling/docs/architecture.md
|
|
537
|
+
2. Explore the existing codebase to understand current patterns
|
|
538
|
+
3. Read any related story or epic files
|
|
539
|
+
4. Create a technical specification at: $outputFile
|
|
540
|
+
|
|
541
|
+
The tech spec should include:
|
|
542
|
+
- Component architecture
|
|
543
|
+
- Data model and database schema
|
|
544
|
+
- API design (if applicable)
|
|
545
|
+
- Non-functional requirements
|
|
546
|
+
- Implementation notes
|
|
547
|
+
- Risks and mitigations
|
|
548
|
+
|
|
549
|
+
Follow the existing project structure and patterns.
|
|
550
|
+
"@
|
|
551
|
+
|
|
552
|
+
$agentFile = Join-Path $script:AgentsDir "architect.md"
|
|
553
|
+
$agentPrompt = ""
|
|
554
|
+
if (Test-Path $agentFile) {
|
|
555
|
+
$agentPrompt = Get-Content $agentFile -Raw
|
|
556
|
+
}
|
|
557
|
+
|
|
558
|
+
$permFlags = Get-PermissionFlags
|
|
559
|
+
|
|
560
|
+
Push-Location $script:ProjectRoot
|
|
561
|
+
try {
|
|
562
|
+
$prompt | & $script:ClaudeCLI -p `
|
|
563
|
+
--model $model `
|
|
564
|
+
$permFlags `
|
|
565
|
+
--append-system-prompt $agentPrompt `
|
|
566
|
+
--tools "Read,Write,Edit,Grep,Glob" `
|
|
567
|
+
--max-budget-usd 5.00 2>&1 | Tee-Object -FilePath $logFile
|
|
568
|
+
|
|
569
|
+
return $LASTEXITCODE
|
|
570
|
+
}
|
|
571
|
+
finally {
|
|
572
|
+
Pop-Location
|
|
573
|
+
}
|
|
574
|
+
}
|
|
575
|
+
|
|
576
|
+
function Invoke-PMEpic {
|
|
577
|
+
<#
|
|
578
|
+
.SYNOPSIS
|
|
579
|
+
PM agent for epic planning
|
|
580
|
+
#>
|
|
581
|
+
param([string]$EpicNum)
|
|
582
|
+
|
|
583
|
+
$epicsFile = Join-Path $script:ProjectRoot "docs\epics.md"
|
|
584
|
+
$logFile = Join-Path $script:LogsDir "epic-$EpicNum-planning.log"
|
|
585
|
+
$model = "sonnet"
|
|
586
|
+
|
|
587
|
+
Write-PersonaBanner -Persona "PM (Product Manager)" -Role "Epic Planning & Prioritization" -Color "Red" -Model $model
|
|
588
|
+
|
|
589
|
+
Write-Host ">> Planning epic: $EpicNum" -ForegroundColor Cyan
|
|
590
|
+
|
|
591
|
+
$prompt = @"
|
|
592
|
+
Plan and refine Epic $EpicNum
|
|
593
|
+
|
|
594
|
+
## Instructions
|
|
595
|
+
1. Read the PRD at tooling/docs/prd.md for product context
|
|
596
|
+
2. Read the current epics file at $epicsFile
|
|
597
|
+
3. Analyze Epic $EpicNum and refine its definition
|
|
598
|
+
4. Break down into well-defined stories
|
|
599
|
+
5. Update the epics file with refined content
|
|
600
|
+
|
|
601
|
+
Ensure each story is:
|
|
602
|
+
- Clearly defined with user value
|
|
603
|
+
- Appropriately sized (1-3 days of work)
|
|
604
|
+
- Properly sequenced with dependencies
|
|
605
|
+
|
|
606
|
+
Use RICE scoring to prioritize stories within the epic.
|
|
607
|
+
"@
|
|
608
|
+
|
|
609
|
+
$agentFile = Join-Path $script:AgentsDir "pm.md"
|
|
610
|
+
$agentPrompt = ""
|
|
611
|
+
if (Test-Path $agentFile) {
|
|
612
|
+
$agentPrompt = Get-Content $agentFile -Raw
|
|
613
|
+
}
|
|
614
|
+
|
|
615
|
+
$permFlags = Get-PermissionFlags
|
|
616
|
+
|
|
617
|
+
Push-Location $script:ProjectRoot
|
|
618
|
+
try {
|
|
619
|
+
$prompt | & $script:ClaudeCLI -p `
|
|
620
|
+
--model $model `
|
|
621
|
+
$permFlags `
|
|
622
|
+
--append-system-prompt $agentPrompt `
|
|
623
|
+
--tools "Read,Write,Edit,Grep,Glob" `
|
|
624
|
+
--max-budget-usd 3.00 2>&1 | Tee-Object -FilePath $logFile
|
|
625
|
+
|
|
626
|
+
return $LASTEXITCODE
|
|
627
|
+
}
|
|
628
|
+
finally {
|
|
629
|
+
Pop-Location
|
|
630
|
+
}
|
|
631
|
+
}
|
|
632
|
+
|
|
633
|
+
function Invoke-WriterDocs {
|
|
634
|
+
<#
|
|
635
|
+
.SYNOPSIS
|
|
636
|
+
Writer agent for documentation
|
|
637
|
+
#>
|
|
638
|
+
param(
|
|
639
|
+
[string]$DocType,
|
|
640
|
+
[string]$Subject
|
|
641
|
+
)
|
|
642
|
+
|
|
643
|
+
$outputDir = Join-Path $script:ProjectRoot "docs"
|
|
644
|
+
$logFile = Join-Path $script:LogsDir "$Subject-docs.log"
|
|
645
|
+
$model = "sonnet"
|
|
646
|
+
|
|
647
|
+
Write-PersonaBanner -Persona "WRITER (Technical Writer)" -Role "Documentation & Content Creation" -Color "White" -Model $model
|
|
648
|
+
|
|
649
|
+
Write-Host ">> Creating documentation: $DocType for $Subject" -ForegroundColor Cyan
|
|
650
|
+
|
|
651
|
+
$prompt = @"
|
|
652
|
+
Create $DocType documentation for: $Subject
|
|
653
|
+
|
|
654
|
+
## Instructions
|
|
655
|
+
1. Explore the codebase to understand the implementation
|
|
656
|
+
2. Read any existing documentation for context
|
|
657
|
+
3. Create appropriate documentation
|
|
658
|
+
|
|
659
|
+
Documentation type: $DocType
|
|
660
|
+
|
|
661
|
+
For user guides: Write step-by-step instructions with examples
|
|
662
|
+
For API docs: Document endpoints, parameters, and responses
|
|
663
|
+
For release notes: Summarize changes in user-friendly language
|
|
664
|
+
For README: Create a comprehensive project overview
|
|
665
|
+
|
|
666
|
+
Save the documentation to an appropriate location in $outputDir/
|
|
667
|
+
"@
|
|
668
|
+
|
|
669
|
+
$agentFile = Join-Path $script:AgentsDir "writer.md"
|
|
670
|
+
$agentPrompt = ""
|
|
671
|
+
if (Test-Path $agentFile) {
|
|
672
|
+
$agentPrompt = Get-Content $agentFile -Raw
|
|
673
|
+
}
|
|
674
|
+
|
|
675
|
+
$permFlags = Get-PermissionFlags
|
|
676
|
+
|
|
677
|
+
Push-Location $script:ProjectRoot
|
|
678
|
+
try {
|
|
679
|
+
$prompt | & $script:ClaudeCLI -p `
|
|
680
|
+
--model $model `
|
|
681
|
+
$permFlags `
|
|
682
|
+
--append-system-prompt $agentPrompt `
|
|
683
|
+
--tools "Read,Write,Edit,Grep,Glob" `
|
|
684
|
+
--max-budget-usd 3.00 2>&1 | Tee-Object -FilePath $logFile
|
|
685
|
+
|
|
686
|
+
return $LASTEXITCODE
|
|
687
|
+
}
|
|
688
|
+
finally {
|
|
689
|
+
Pop-Location
|
|
690
|
+
}
|
|
691
|
+
}
|
|
692
|
+
|
|
693
|
+
#endregion
|
|
694
|
+
|
|
695
|
+
#region Sprint Status Management
|
|
696
|
+
|
|
697
|
+
function Update-StoryStatus {
|
|
698
|
+
<#
|
|
699
|
+
.SYNOPSIS
|
|
700
|
+
Update story status in sprint-status.yaml
|
|
701
|
+
#>
|
|
702
|
+
param(
|
|
703
|
+
[string]$StoryKey,
|
|
704
|
+
[string]$NewStatus
|
|
705
|
+
)
|
|
706
|
+
|
|
707
|
+
$sprintStatusFile = Join-Path $script:ProjectRoot "docs\sprint-status.yaml"
|
|
708
|
+
|
|
709
|
+
Write-Host ">> Updating sprint status: $StoryKey -> $NewStatus" -ForegroundColor Cyan
|
|
710
|
+
|
|
711
|
+
if (-not (Test-Path $sprintStatusFile)) {
|
|
712
|
+
Write-Host "!! Sprint status file not found: $sprintStatusFile" -ForegroundColor Yellow
|
|
713
|
+
return 1
|
|
714
|
+
}
|
|
715
|
+
|
|
716
|
+
$content = Get-Content $sprintStatusFile -Raw
|
|
717
|
+
|
|
718
|
+
# Check if story exists
|
|
719
|
+
if ($content -notmatch "^\s+${StoryKey}:") {
|
|
720
|
+
Write-Host "!! Story $StoryKey not found in sprint-status.yaml" -ForegroundColor Yellow
|
|
721
|
+
return 1
|
|
722
|
+
}
|
|
723
|
+
|
|
724
|
+
# Update status
|
|
725
|
+
$pattern = "(?m)^(\s+${StoryKey}:)\s*.*$"
|
|
726
|
+
$replacement = "`$1 $NewStatus"
|
|
727
|
+
$newContent = $content -replace $pattern, $replacement
|
|
728
|
+
|
|
729
|
+
# Update timestamp
|
|
730
|
+
$today = (Get-Date).ToString("yyyy-MM-dd")
|
|
731
|
+
$newContent = $newContent -replace "(?m)^#?\s*updated:.*$", "updated: $today"
|
|
732
|
+
|
|
733
|
+
Set-Content -Path $sprintStatusFile -Value $newContent -NoNewline
|
|
734
|
+
|
|
735
|
+
Write-Host "[OK] Status updated: $StoryKey -> $NewStatus" -ForegroundColor Green
|
|
736
|
+
return 0
|
|
737
|
+
}
|
|
738
|
+
|
|
739
|
+
#endregion
|
|
740
|
+
|
|
741
|
+
#region Auto-Commit and PR Functions
|
|
742
|
+
|
|
743
|
+
function Invoke-AutoCommit {
|
|
744
|
+
<#
|
|
745
|
+
.SYNOPSIS
|
|
746
|
+
Auto-commit changes after development
|
|
747
|
+
#>
|
|
748
|
+
param([string]$StoryKey)
|
|
749
|
+
|
|
750
|
+
$storyFile = Join-Path $script:StoriesDir "$StoryKey.md"
|
|
751
|
+
|
|
752
|
+
Write-Host ">> Auto-committing changes..." -ForegroundColor Cyan
|
|
753
|
+
|
|
754
|
+
Push-Location $script:ProjectRoot
|
|
755
|
+
try {
|
|
756
|
+
# Check for changes
|
|
757
|
+
$status = git status --porcelain
|
|
758
|
+
if (-not $status) {
|
|
759
|
+
Write-Host "[i] No changes to commit" -ForegroundColor Blue
|
|
760
|
+
return 0
|
|
761
|
+
}
|
|
762
|
+
|
|
763
|
+
Write-Host "[i] Detected changes to commit" -ForegroundColor Blue
|
|
764
|
+
|
|
765
|
+
# Extract story title
|
|
766
|
+
$storyTitle = $StoryKey
|
|
767
|
+
if (Test-Path $storyFile) {
|
|
768
|
+
$firstLine = (Get-Content $storyFile -First 1) -replace '^#\s*', ''
|
|
769
|
+
if ($firstLine) { $storyTitle = $firstLine }
|
|
770
|
+
}
|
|
771
|
+
|
|
772
|
+
# Stage all changes
|
|
773
|
+
git add -A
|
|
774
|
+
|
|
775
|
+
# Create commit message
|
|
776
|
+
$commitMsg = @"
|
|
777
|
+
feat: $storyTitle
|
|
778
|
+
|
|
779
|
+
Automated implementation via Claude Code CLI
|
|
780
|
+
|
|
781
|
+
Story: $StoryKey
|
|
782
|
+
|
|
783
|
+
Generated with Claude Code (https://claude.com/claude-code)
|
|
784
|
+
|
|
785
|
+
Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
|
|
786
|
+
"@
|
|
787
|
+
|
|
788
|
+
git commit -m $commitMsg
|
|
789
|
+
|
|
790
|
+
if ($LASTEXITCODE -eq 0) {
|
|
791
|
+
$shortHash = git rev-parse --short HEAD
|
|
792
|
+
Write-Host "[OK] Changes committed successfully" -ForegroundColor Green
|
|
793
|
+
Write-Host "[i] Commit: $shortHash" -ForegroundColor Blue
|
|
794
|
+
return 0
|
|
795
|
+
}
|
|
796
|
+
else {
|
|
797
|
+
Write-Host "!! Commit failed or no changes to commit" -ForegroundColor Yellow
|
|
798
|
+
return 1
|
|
799
|
+
}
|
|
800
|
+
}
|
|
801
|
+
finally {
|
|
802
|
+
Pop-Location
|
|
803
|
+
}
|
|
804
|
+
}
|
|
805
|
+
|
|
806
|
+
function New-AutoPR {
|
|
807
|
+
<#
|
|
808
|
+
.SYNOPSIS
|
|
809
|
+
Create pull request after commit
|
|
810
|
+
#>
|
|
811
|
+
param([string]$StoryKey)
|
|
812
|
+
|
|
813
|
+
$storyFile = Join-Path $script:StoriesDir "$StoryKey.md"
|
|
814
|
+
|
|
815
|
+
Write-Host ">> Creating pull request..." -ForegroundColor Cyan
|
|
816
|
+
|
|
817
|
+
# Check if gh CLI is available
|
|
818
|
+
if (-not (Get-Command gh -ErrorAction SilentlyContinue)) {
|
|
819
|
+
Write-Host "!! GitHub CLI (gh) not found. Skipping PR creation." -ForegroundColor Yellow
|
|
820
|
+
Write-Host " Install with: winget install GitHub.cli" -ForegroundColor Blue
|
|
821
|
+
return 1
|
|
822
|
+
}
|
|
823
|
+
|
|
824
|
+
Push-Location $script:ProjectRoot
|
|
825
|
+
try {
|
|
826
|
+
$currentBranch = git rev-parse --abbrev-ref HEAD
|
|
827
|
+
|
|
828
|
+
# Extract title and body
|
|
829
|
+
$prTitle = $StoryKey
|
|
830
|
+
$prBody = "Story: $StoryKey`n`nGenerated via Claude Code CLI automation"
|
|
831
|
+
|
|
832
|
+
if (Test-Path $storyFile) {
|
|
833
|
+
$content = Get-Content $storyFile -Raw
|
|
834
|
+
$firstLine = (Get-Content $storyFile -First 1) -replace '^#\s*', ''
|
|
835
|
+
if ($firstLine) { $prTitle = $firstLine }
|
|
836
|
+
|
|
837
|
+
$prBody = @"
|
|
838
|
+
## Story: $StoryKey
|
|
839
|
+
|
|
840
|
+
$content
|
|
841
|
+
|
|
842
|
+
---
|
|
843
|
+
|
|
844
|
+
Auto-generated via Claude Code CLI automation
|
|
845
|
+
"@
|
|
846
|
+
}
|
|
847
|
+
|
|
848
|
+
gh pr create --title $prTitle --body $prBody --base main --head $currentBranch
|
|
849
|
+
|
|
850
|
+
if ($LASTEXITCODE -eq 0) {
|
|
851
|
+
Write-Host "[OK] Pull request created" -ForegroundColor Green
|
|
852
|
+
return 0
|
|
853
|
+
}
|
|
854
|
+
else {
|
|
855
|
+
Write-Host "!! PR creation failed. Create manually with:" -ForegroundColor Yellow
|
|
856
|
+
Write-Host " gh pr create --title `"$prTitle`" --base main" -ForegroundColor Blue
|
|
857
|
+
return 1
|
|
858
|
+
}
|
|
859
|
+
}
|
|
860
|
+
finally {
|
|
861
|
+
Pop-Location
|
|
862
|
+
}
|
|
863
|
+
}
|
|
864
|
+
|
|
865
|
+
#endregion
|
|
866
|
+
|
|
867
|
+
#region Full Pipeline
|
|
868
|
+
|
|
869
|
+
function Start-FullPipeline {
|
|
870
|
+
<#
|
|
871
|
+
.SYNOPSIS
|
|
872
|
+
Run complete story pipeline
|
|
873
|
+
#>
|
|
874
|
+
param([string]$StoryKey)
|
|
875
|
+
|
|
876
|
+
$autoCommit = if ($env:AUTO_COMMIT) { $env:AUTO_COMMIT -eq "true" } else { $true }
|
|
877
|
+
$autoPR = if ($env:AUTO_PR) { $env:AUTO_PR -eq "true" } else { $false }
|
|
878
|
+
|
|
879
|
+
Write-Host ""
|
|
880
|
+
Write-Host ("{0}" -f ("=" * 65)) -ForegroundColor Cyan
|
|
881
|
+
Write-Host " AUTOMATED STORY PIPELINE: $StoryKey" -ForegroundColor Cyan
|
|
882
|
+
Write-Host ("{0}" -f ("=" * 65)) -ForegroundColor Cyan
|
|
883
|
+
Write-Host ""
|
|
884
|
+
|
|
885
|
+
# Phase 1: Create context if needed
|
|
886
|
+
$contextFile = Join-Path $script:StoriesDir "$StoryKey.context.xml"
|
|
887
|
+
if (-not (Test-Path $contextFile)) {
|
|
888
|
+
Write-Host ">> Phase 1: Creating story context..." -ForegroundColor Yellow
|
|
889
|
+
$result = Invoke-SMStoryContext -StoryKey $StoryKey
|
|
890
|
+
if ($result -ne 0) {
|
|
891
|
+
Write-Host "X Context creation failed" -ForegroundColor Red
|
|
892
|
+
return 1
|
|
893
|
+
}
|
|
894
|
+
Write-Host "[OK] Context created" -ForegroundColor Green
|
|
895
|
+
Write-Host ""
|
|
896
|
+
}
|
|
897
|
+
else {
|
|
898
|
+
Write-Host "[OK] Context already exists, skipping..." -ForegroundColor Green
|
|
899
|
+
Write-Host ""
|
|
900
|
+
}
|
|
901
|
+
|
|
902
|
+
# Phase 2: Development
|
|
903
|
+
Write-Host ">> Phase 2: Implementing story..." -ForegroundColor Yellow
|
|
904
|
+
$result = Invoke-DevStory -StoryKey $StoryKey
|
|
905
|
+
if ($result -ne 0) {
|
|
906
|
+
Write-Host "X Development failed" -ForegroundColor Red
|
|
907
|
+
return 1
|
|
908
|
+
}
|
|
909
|
+
Write-Host "[OK] Development complete" -ForegroundColor Green
|
|
910
|
+
Write-Host ""
|
|
911
|
+
|
|
912
|
+
# Phase 2.5: Update status to 'review'
|
|
913
|
+
Update-StoryStatus -StoryKey $StoryKey -NewStatus "review"
|
|
914
|
+
Write-Host ""
|
|
915
|
+
|
|
916
|
+
# Phase 2.6: Auto-commit
|
|
917
|
+
if ($autoCommit) {
|
|
918
|
+
Invoke-AutoCommit -StoryKey $StoryKey
|
|
919
|
+
Write-Host ""
|
|
920
|
+
}
|
|
921
|
+
|
|
922
|
+
# Phase 2.7: Auto-PR
|
|
923
|
+
if ($autoPR) {
|
|
924
|
+
New-AutoPR -StoryKey $StoryKey
|
|
925
|
+
Write-Host ""
|
|
926
|
+
}
|
|
927
|
+
|
|
928
|
+
# Phase 3: Code review
|
|
929
|
+
Write-Host ">> Phase 3: Code review..." -ForegroundColor Yellow
|
|
930
|
+
$result = Invoke-SMCodeReview -StoryKey $StoryKey
|
|
931
|
+
if ($result -ne 0) {
|
|
932
|
+
Write-Host "X Code review failed" -ForegroundColor Red
|
|
933
|
+
return 1
|
|
934
|
+
}
|
|
935
|
+
Write-Host "[OK] Code review complete" -ForegroundColor Green
|
|
936
|
+
Write-Host ""
|
|
937
|
+
|
|
938
|
+
# Phase 4: Update status to 'done'
|
|
939
|
+
Update-StoryStatus -StoryKey $StoryKey -NewStatus "done"
|
|
940
|
+
Write-Host ""
|
|
941
|
+
|
|
942
|
+
Write-Host ("{0}" -f ("=" * 65)) -ForegroundColor Cyan
|
|
943
|
+
Write-Host " PIPELINE COMPLETE" -ForegroundColor Cyan
|
|
944
|
+
Write-Host ("{0}" -f ("=" * 65)) -ForegroundColor Cyan
|
|
945
|
+
|
|
946
|
+
return 0
|
|
947
|
+
}
|
|
948
|
+
|
|
949
|
+
#endregion
|
|
950
|
+
|
|
951
|
+
# Export functions for use when dot-sourcing
|
|
952
|
+
Export-ModuleMember -Function * -ErrorAction SilentlyContinue
|