@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,110 @@
|
|
|
1
|
+
#!/usr/bin/env bash
|
|
2
|
+
#
|
|
3
|
+
# Devflow Collaborative Story Runner
|
|
4
|
+
# Multi-agent collaboration CLI wrapper for Unix systems
|
|
5
|
+
#
|
|
6
|
+
# Usage:
|
|
7
|
+
# ./run-collab.sh <story-key> [options]
|
|
8
|
+
#
|
|
9
|
+
# Examples:
|
|
10
|
+
# ./run-collab.sh 3-5 --swarm
|
|
11
|
+
# ./run-collab.sh 3-5 --pair
|
|
12
|
+
# ./run-collab.sh "fix auth bug" --auto
|
|
13
|
+
|
|
14
|
+
set -e
|
|
15
|
+
|
|
16
|
+
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
|
17
|
+
PYTHON_SCRIPT="${SCRIPT_DIR}/run-collab.py"
|
|
18
|
+
|
|
19
|
+
# Colors
|
|
20
|
+
RED='\033[0;31m'
|
|
21
|
+
GREEN='\033[0;32m'
|
|
22
|
+
YELLOW='\033[1;33m'
|
|
23
|
+
BLUE='\033[0;34m'
|
|
24
|
+
CYAN='\033[0;36m'
|
|
25
|
+
NC='\033[0m' # No Color
|
|
26
|
+
BOLD='\033[1m'
|
|
27
|
+
|
|
28
|
+
print_banner() {
|
|
29
|
+
echo -e "${CYAN}"
|
|
30
|
+
echo "╔═══════════════════════════════════════════════════════════════╗"
|
|
31
|
+
echo "║ DEVFLOW COLLABORATIVE STORY RUNNER ║"
|
|
32
|
+
echo "╠═══════════════════════════════════════════════════════════════╣"
|
|
33
|
+
echo "║ Multi-agent collaboration with swarm, pair, and auto-routing ║"
|
|
34
|
+
echo "╚═══════════════════════════════════════════════════════════════╝"
|
|
35
|
+
echo -e "${NC}"
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
show_usage() {
|
|
39
|
+
echo "Usage: $0 <story-key> [options]"
|
|
40
|
+
echo ""
|
|
41
|
+
echo "Modes:"
|
|
42
|
+
echo " --auto Auto-route to best agents (default)"
|
|
43
|
+
echo " --swarm Multi-agent debate/consensus"
|
|
44
|
+
echo " --pair DEV + REVIEWER pair programming"
|
|
45
|
+
echo " --sequential Traditional sequential pipeline"
|
|
46
|
+
echo ""
|
|
47
|
+
echo "Options:"
|
|
48
|
+
echo " --agents <list> Comma-separated agent list (for swarm)"
|
|
49
|
+
echo " --max-iterations <n> Max iterations (default: 3)"
|
|
50
|
+
echo " --model <name> Claude model (opus, sonnet, haiku)"
|
|
51
|
+
echo " --budget <amount> Budget limit in USD (default: 20.0)"
|
|
52
|
+
echo " --memory Show shared memory"
|
|
53
|
+
echo " --query <question> Query knowledge graph"
|
|
54
|
+
echo " --route-only Just show routing, don't execute"
|
|
55
|
+
echo " --quiet Reduce verbosity"
|
|
56
|
+
echo ""
|
|
57
|
+
echo "Examples:"
|
|
58
|
+
echo " $0 3-5 --swarm"
|
|
59
|
+
echo " $0 3-5 --pair"
|
|
60
|
+
echo " $0 'fix auth bug' --auto"
|
|
61
|
+
echo " $0 3-5 --swarm --agents ARCHITECT,DEV,REVIEWER"
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
# Check for Python
|
|
65
|
+
detect_python() {
|
|
66
|
+
if command -v python3 &> /dev/null; then
|
|
67
|
+
echo "python3"
|
|
68
|
+
elif command -v python &> /dev/null; then
|
|
69
|
+
# Verify it's Python 3
|
|
70
|
+
if python --version 2>&1 | grep -q "Python 3"; then
|
|
71
|
+
echo "python"
|
|
72
|
+
else
|
|
73
|
+
echo ""
|
|
74
|
+
fi
|
|
75
|
+
else
|
|
76
|
+
echo ""
|
|
77
|
+
fi
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
# Main
|
|
81
|
+
main() {
|
|
82
|
+
# Check for help flag
|
|
83
|
+
if [[ "$1" == "--help" || "$1" == "-h" ]]; then
|
|
84
|
+
show_usage
|
|
85
|
+
exit 0
|
|
86
|
+
fi
|
|
87
|
+
|
|
88
|
+
# Check for Python
|
|
89
|
+
PYTHON_CMD=$(detect_python)
|
|
90
|
+
if [[ -z "$PYTHON_CMD" ]]; then
|
|
91
|
+
echo -e "${RED}Error: Python 3 not found. Please install Python 3.9+${NC}"
|
|
92
|
+
exit 1
|
|
93
|
+
fi
|
|
94
|
+
|
|
95
|
+
# Check if Python script exists
|
|
96
|
+
if [[ ! -f "$PYTHON_SCRIPT" ]]; then
|
|
97
|
+
echo -e "${RED}Error: run-collab.py not found at $PYTHON_SCRIPT${NC}"
|
|
98
|
+
exit 1
|
|
99
|
+
fi
|
|
100
|
+
|
|
101
|
+
# Print banner for non-quiet mode
|
|
102
|
+
if [[ "$*" != *"--quiet"* && "$*" != *"-q"* ]]; then
|
|
103
|
+
print_banner
|
|
104
|
+
fi
|
|
105
|
+
|
|
106
|
+
# Pass all arguments to Python script
|
|
107
|
+
exec "$PYTHON_CMD" "$PYTHON_SCRIPT" "$@"
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
main "$@"
|
|
@@ -0,0 +1,490 @@
|
|
|
1
|
+
<#
|
|
2
|
+
.SYNOPSIS
|
|
3
|
+
RUN-STORY - Automated Story Implementation with Live Monitoring
|
|
4
|
+
|
|
5
|
+
.DESCRIPTION
|
|
6
|
+
Invokes Claude Code to implement a story automatically while keeping
|
|
7
|
+
the main terminal available for live monitoring of context usage,
|
|
8
|
+
costs, and agent status.
|
|
9
|
+
|
|
10
|
+
.PARAMETER StoryKey
|
|
11
|
+
The story key to process (e.g., "3-5" or full key)
|
|
12
|
+
|
|
13
|
+
.PARAMETER Develop
|
|
14
|
+
Run development phase only
|
|
15
|
+
|
|
16
|
+
.PARAMETER Review
|
|
17
|
+
Run review phase only
|
|
18
|
+
|
|
19
|
+
.PARAMETER Context
|
|
20
|
+
Create story context only
|
|
21
|
+
|
|
22
|
+
.PARAMETER NoCommit
|
|
23
|
+
Disable auto-commit after development
|
|
24
|
+
|
|
25
|
+
.PARAMETER WithPR
|
|
26
|
+
Enable auto-PR creation (requires gh CLI)
|
|
27
|
+
|
|
28
|
+
.PARAMETER Model
|
|
29
|
+
Claude model to use (sonnet|opus|haiku)
|
|
30
|
+
|
|
31
|
+
.PARAMETER NoMonitor
|
|
32
|
+
Disable live monitoring (run in foreground)
|
|
33
|
+
|
|
34
|
+
.EXAMPLE
|
|
35
|
+
.\run-story.ps1 -StoryKey "3-5"
|
|
36
|
+
.\run-story.ps1 -StoryKey "3-5" -Develop
|
|
37
|
+
.\run-story.ps1 -StoryKey "3-5" -Model opus -WithPR
|
|
38
|
+
|
|
39
|
+
.NOTES
|
|
40
|
+
Version: 1.0.0
|
|
41
|
+
Core tasks run as background jobs with live monitoring in the main terminal.
|
|
42
|
+
#>
|
|
43
|
+
|
|
44
|
+
#Requires -Version 5.1
|
|
45
|
+
|
|
46
|
+
param(
|
|
47
|
+
[Parameter(Mandatory=$true, Position=0)]
|
|
48
|
+
[string]$StoryKey,
|
|
49
|
+
|
|
50
|
+
[switch]$Develop,
|
|
51
|
+
[switch]$Review,
|
|
52
|
+
[switch]$Context,
|
|
53
|
+
[switch]$NoCommit,
|
|
54
|
+
[switch]$WithPR,
|
|
55
|
+
[switch]$NoMonitor,
|
|
56
|
+
|
|
57
|
+
[ValidateSet("sonnet", "opus", "haiku")]
|
|
58
|
+
[string]$Model = "sonnet"
|
|
59
|
+
)
|
|
60
|
+
|
|
61
|
+
# Script paths
|
|
62
|
+
$script:ScriptDir = $PSScriptRoot
|
|
63
|
+
$script:ProjectRoot = (Get-Item "$script:ScriptDir\.." -ErrorAction SilentlyContinue).FullName
|
|
64
|
+
$script:LogsDir = Join-Path $script:ProjectRoot "tooling\.automation\logs"
|
|
65
|
+
$script:CheckpointDir = Join-Path $script:ProjectRoot "tooling\.automation\checkpoints"
|
|
66
|
+
|
|
67
|
+
# Source libraries
|
|
68
|
+
. (Join-Path $script:ScriptDir "lib\claude-cli.ps1")
|
|
69
|
+
$checkpointLib = Join-Path $script:ScriptDir "lib\checkpoint-integration.ps1"
|
|
70
|
+
if (Test-Path $checkpointLib) {
|
|
71
|
+
. $checkpointLib
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
# Load config
|
|
75
|
+
$configFile = Join-Path $script:ProjectRoot "tooling\.automation\config.ps1"
|
|
76
|
+
if (Test-Path $configFile) {
|
|
77
|
+
. $configFile
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
# Set environment
|
|
81
|
+
$env:CLAUDE_MODEL = $Model
|
|
82
|
+
$env:AUTO_COMMIT = if ($NoCommit) { "false" } else { "true" }
|
|
83
|
+
$env:AUTO_PR = if ($WithPR) { "true" } else { "false" }
|
|
84
|
+
|
|
85
|
+
#region Helper Functions
|
|
86
|
+
|
|
87
|
+
function Expand-StoryKey {
|
|
88
|
+
<#
|
|
89
|
+
.SYNOPSIS
|
|
90
|
+
Expand abbreviated story key (e.g., "3-5" -> full key)
|
|
91
|
+
#>
|
|
92
|
+
param([string]$InputKey)
|
|
93
|
+
|
|
94
|
+
# If already a full key (has more than two dashes)
|
|
95
|
+
if ($InputKey -match '^[0-9]+-[0-9]+-[a-z]') {
|
|
96
|
+
return $InputKey
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
# If abbreviated (e.g., "3-5"), look up full key
|
|
100
|
+
if ($InputKey -match '^[0-9]+-[0-9]+$') {
|
|
101
|
+
$sprintStatus = Join-Path $script:ProjectRoot "docs\sprint-status.yaml"
|
|
102
|
+
if (Test-Path $sprintStatus) {
|
|
103
|
+
$content = Get-Content $sprintStatus -Raw
|
|
104
|
+
$pattern = "^\s+($InputKey-[a-z][^\s:]*):"
|
|
105
|
+
if ($content -match $pattern) {
|
|
106
|
+
return $Matches[1]
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
return $InputKey
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
function Write-Header {
|
|
115
|
+
Clear-Host
|
|
116
|
+
Write-Host ""
|
|
117
|
+
Write-Host ("{0}" -f ("=" * 70)) -ForegroundColor Cyan
|
|
118
|
+
Write-Host " AUTOMATED STORY RUNNER - Live Monitoring" -ForegroundColor Cyan
|
|
119
|
+
Write-Host ("{0}" -f ("=" * 70)) -ForegroundColor Cyan
|
|
120
|
+
Write-Host ""
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
function Write-Status {
|
|
124
|
+
param(
|
|
125
|
+
[string]$StoryKey,
|
|
126
|
+
[string]$Mode,
|
|
127
|
+
[string]$Phase,
|
|
128
|
+
[datetime]$StartTime,
|
|
129
|
+
[int]$ContextPercent = 0,
|
|
130
|
+
[decimal]$CostUSD = 0,
|
|
131
|
+
[string]$AgentStatus = "Initializing"
|
|
132
|
+
)
|
|
133
|
+
|
|
134
|
+
$elapsed = (Get-Date) - $StartTime
|
|
135
|
+
$elapsedStr = "{0:mm\:ss}" -f $elapsed
|
|
136
|
+
|
|
137
|
+
# Context bar
|
|
138
|
+
$contextBar = ""
|
|
139
|
+
$contextColor = "Green"
|
|
140
|
+
if ($ContextPercent -gt 0) {
|
|
141
|
+
$filled = [math]::Floor($ContextPercent / 5)
|
|
142
|
+
$empty = 20 - $filled
|
|
143
|
+
$contextBar = ("[" + ("=" * $filled) + ("-" * $empty) + "]")
|
|
144
|
+
|
|
145
|
+
if ($ContextPercent -ge 85) { $contextColor = "Red" }
|
|
146
|
+
elseif ($ContextPercent -ge 75) { $contextColor = "Yellow" }
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
# Clear and redraw status
|
|
150
|
+
$cursorTop = [Console]::CursorTop
|
|
151
|
+
if ($cursorTop -gt 10) {
|
|
152
|
+
[Console]::SetCursorPosition(0, 10)
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
Write-Host ""
|
|
156
|
+
Write-Host ("{0}" -f ("-" * 70)) -ForegroundColor DarkGray
|
|
157
|
+
Write-Host ""
|
|
158
|
+
Write-Host " Story: " -NoNewline -ForegroundColor Gray
|
|
159
|
+
Write-Host $StoryKey -ForegroundColor White
|
|
160
|
+
Write-Host " Mode: " -NoNewline -ForegroundColor Gray
|
|
161
|
+
Write-Host $Mode -ForegroundColor Cyan
|
|
162
|
+
Write-Host " Phase: " -NoNewline -ForegroundColor Gray
|
|
163
|
+
Write-Host $Phase -ForegroundColor Yellow
|
|
164
|
+
Write-Host " Elapsed: " -NoNewline -ForegroundColor Gray
|
|
165
|
+
Write-Host $elapsedStr -ForegroundColor White
|
|
166
|
+
Write-Host ""
|
|
167
|
+
Write-Host " Agent: " -NoNewline -ForegroundColor Gray
|
|
168
|
+
Write-Host $AgentStatus -ForegroundColor $(if ($AgentStatus -eq "Running") { "Green" } else { "Yellow" })
|
|
169
|
+
Write-Host " Context: " -NoNewline -ForegroundColor Gray
|
|
170
|
+
Write-Host "$contextBar $ContextPercent%" -ForegroundColor $contextColor
|
|
171
|
+
Write-Host " Cost: " -NoNewline -ForegroundColor Gray
|
|
172
|
+
Write-Host ('${0:F2} USD' -f $CostUSD) -ForegroundColor $(if ($CostUSD -gt 10) { "Yellow" } else { "Green" })
|
|
173
|
+
Write-Host ""
|
|
174
|
+
Write-Host ("{0}" -f ("-" * 70)) -ForegroundColor DarkGray
|
|
175
|
+
Write-Host ""
|
|
176
|
+
Write-Host " Press Ctrl+C to stop monitoring (task continues in background)" -ForegroundColor DarkGray
|
|
177
|
+
Write-Host ""
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
function Get-LogStats {
|
|
181
|
+
<#
|
|
182
|
+
.SYNOPSIS
|
|
183
|
+
Parse log file for context usage and cost estimates
|
|
184
|
+
#>
|
|
185
|
+
param([string]$LogFile)
|
|
186
|
+
|
|
187
|
+
$stats = @{
|
|
188
|
+
ContextPercent = 0
|
|
189
|
+
CostUSD = 0.0
|
|
190
|
+
Status = "Unknown"
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
if (-not (Test-Path $LogFile)) {
|
|
194
|
+
return $stats
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
try {
|
|
198
|
+
$content = Get-Content $LogFile -Tail 100 -ErrorAction SilentlyContinue
|
|
199
|
+
|
|
200
|
+
foreach ($line in $content) {
|
|
201
|
+
# Look for context patterns
|
|
202
|
+
if ($line -match 'Context:\s*(\d+)%') {
|
|
203
|
+
$stats.ContextPercent = [int]$Matches[1]
|
|
204
|
+
}
|
|
205
|
+
if ($line -match 'Token usage:\s*(\d+)/(\d+)') {
|
|
206
|
+
$used = [int]$Matches[1]
|
|
207
|
+
$total = [int]$Matches[2]
|
|
208
|
+
$stats.ContextPercent = [math]::Floor(($used / $total) * 100)
|
|
209
|
+
}
|
|
210
|
+
|
|
211
|
+
# Look for cost patterns
|
|
212
|
+
if ($line -match '\$(\d+\.?\d*)') {
|
|
213
|
+
$stats.CostUSD = [decimal]$Matches[1]
|
|
214
|
+
}
|
|
215
|
+
|
|
216
|
+
# Status indicators
|
|
217
|
+
if ($line -match 'PERSONA SWITCH|Starting|Implementing') {
|
|
218
|
+
$stats.Status = "Running"
|
|
219
|
+
}
|
|
220
|
+
if ($line -match 'Complete|Done|Finished') {
|
|
221
|
+
$stats.Status = "Completed"
|
|
222
|
+
}
|
|
223
|
+
if ($line -match 'Error|Failed|Exception') {
|
|
224
|
+
$stats.Status = "Error"
|
|
225
|
+
}
|
|
226
|
+
}
|
|
227
|
+
}
|
|
228
|
+
catch {
|
|
229
|
+
# Ignore errors reading log
|
|
230
|
+
}
|
|
231
|
+
|
|
232
|
+
return $stats
|
|
233
|
+
}
|
|
234
|
+
|
|
235
|
+
function Start-AgentJob {
|
|
236
|
+
<#
|
|
237
|
+
.SYNOPSIS
|
|
238
|
+
Start a Claude agent as a background job
|
|
239
|
+
#>
|
|
240
|
+
param(
|
|
241
|
+
[string]$Phase,
|
|
242
|
+
[string]$StoryKey,
|
|
243
|
+
[string]$LogFile
|
|
244
|
+
)
|
|
245
|
+
|
|
246
|
+
$job = Start-Job -ScriptBlock {
|
|
247
|
+
param($scriptDir, $storyKey, $phase, $logFile)
|
|
248
|
+
|
|
249
|
+
# Source libraries in job context
|
|
250
|
+
. (Join-Path $scriptDir "lib\claude-cli.ps1")
|
|
251
|
+
|
|
252
|
+
$result = 0
|
|
253
|
+
switch ($phase) {
|
|
254
|
+
"context" {
|
|
255
|
+
$result = Invoke-SMStoryContext -StoryKey $storyKey
|
|
256
|
+
}
|
|
257
|
+
"develop" {
|
|
258
|
+
$result = Invoke-DevStory -StoryKey $storyKey
|
|
259
|
+
}
|
|
260
|
+
"review" {
|
|
261
|
+
$result = Invoke-SMCodeReview -StoryKey $storyKey
|
|
262
|
+
}
|
|
263
|
+
}
|
|
264
|
+
|
|
265
|
+
return $result
|
|
266
|
+
} -ArgumentList $script:ScriptDir, $StoryKey, $Phase, $LogFile
|
|
267
|
+
|
|
268
|
+
return $job
|
|
269
|
+
}
|
|
270
|
+
|
|
271
|
+
function Watch-AgentProgress {
|
|
272
|
+
<#
|
|
273
|
+
.SYNOPSIS
|
|
274
|
+
Monitor agent job progress with live updates
|
|
275
|
+
#>
|
|
276
|
+
param(
|
|
277
|
+
[System.Management.Automation.Job]$Job,
|
|
278
|
+
[string]$StoryKey,
|
|
279
|
+
[string]$Mode,
|
|
280
|
+
[string]$Phase,
|
|
281
|
+
[string]$LogFile
|
|
282
|
+
)
|
|
283
|
+
|
|
284
|
+
$startTime = Get-Date
|
|
285
|
+
|
|
286
|
+
Write-Host " >> Agent started for phase: $Phase" -ForegroundColor Cyan
|
|
287
|
+
Write-Host " >> Log: $LogFile" -ForegroundColor Gray
|
|
288
|
+
Write-Host ""
|
|
289
|
+
|
|
290
|
+
while ($Job.State -eq 'Running') {
|
|
291
|
+
$stats = Get-LogStats -LogFile $LogFile
|
|
292
|
+
|
|
293
|
+
Write-Status `
|
|
294
|
+
-StoryKey $StoryKey `
|
|
295
|
+
-Mode $Mode `
|
|
296
|
+
-Phase $Phase `
|
|
297
|
+
-StartTime $startTime `
|
|
298
|
+
-ContextPercent $stats.ContextPercent `
|
|
299
|
+
-CostUSD $stats.CostUSD `
|
|
300
|
+
-AgentStatus "Running"
|
|
301
|
+
|
|
302
|
+
Start-Sleep -Seconds 2
|
|
303
|
+
}
|
|
304
|
+
|
|
305
|
+
# Final status
|
|
306
|
+
$stats = Get-LogStats -LogFile $LogFile
|
|
307
|
+
$finalStatus = if ($Job.State -eq 'Completed') { "Completed" } else { "Failed" }
|
|
308
|
+
|
|
309
|
+
Write-Status `
|
|
310
|
+
-StoryKey $StoryKey `
|
|
311
|
+
-Mode $Mode `
|
|
312
|
+
-Phase $Phase `
|
|
313
|
+
-StartTime $startTime `
|
|
314
|
+
-ContextPercent $stats.ContextPercent `
|
|
315
|
+
-CostUSD $stats.CostUSD `
|
|
316
|
+
-AgentStatus $finalStatus
|
|
317
|
+
|
|
318
|
+
# Get job result
|
|
319
|
+
$result = Receive-Job -Job $Job
|
|
320
|
+
Remove-Job -Job $Job -Force
|
|
321
|
+
|
|
322
|
+
return $result
|
|
323
|
+
}
|
|
324
|
+
|
|
325
|
+
#endregion
|
|
326
|
+
|
|
327
|
+
#region Main Execution
|
|
328
|
+
|
|
329
|
+
function Main {
|
|
330
|
+
# Expand story key
|
|
331
|
+
$fullStoryKey = Expand-StoryKey -InputKey $StoryKey
|
|
332
|
+
|
|
333
|
+
# Determine mode
|
|
334
|
+
$mode = "full"
|
|
335
|
+
if ($Develop) { $mode = "develop" }
|
|
336
|
+
elseif ($Review) { $mode = "review" }
|
|
337
|
+
elseif ($Context) { $mode = "context" }
|
|
338
|
+
|
|
339
|
+
Write-Header
|
|
340
|
+
|
|
341
|
+
Write-Host " Story: $fullStoryKey" -ForegroundColor White
|
|
342
|
+
Write-Host " Mode: $mode" -ForegroundColor Cyan
|
|
343
|
+
Write-Host " Model: $Model" -ForegroundColor Blue
|
|
344
|
+
Write-Host " Auto-Commit: $($env:AUTO_COMMIT)" -ForegroundColor Gray
|
|
345
|
+
Write-Host " Auto-PR: $($env:AUTO_PR)" -ForegroundColor Gray
|
|
346
|
+
Write-Host ""
|
|
347
|
+
|
|
348
|
+
# Check for existing checkpoint
|
|
349
|
+
if (Get-Command Test-HasCheckpoint -ErrorAction SilentlyContinue) {
|
|
350
|
+
if (Test-HasCheckpoint -StoryKey $fullStoryKey) {
|
|
351
|
+
Write-Host " [!] Found existing checkpoint for story: $fullStoryKey" -ForegroundColor Cyan
|
|
352
|
+
$resume = Read-Host " Would you like to resume from checkpoint? (y/n)"
|
|
353
|
+
if ($resume -match '^[Yy]') {
|
|
354
|
+
Resume-FromCheckpoint -StoryKey $fullStoryKey
|
|
355
|
+
return
|
|
356
|
+
}
|
|
357
|
+
Write-Host " >> Starting fresh implementation..." -ForegroundColor Green
|
|
358
|
+
Write-Host ""
|
|
359
|
+
}
|
|
360
|
+
}
|
|
361
|
+
|
|
362
|
+
# Create pre-start checkpoint
|
|
363
|
+
if (Get-Command New-StoryCheckpoint -ErrorAction SilentlyContinue) {
|
|
364
|
+
Write-Host " >> Creating pre-start checkpoint..." -ForegroundColor Blue
|
|
365
|
+
New-StoryCheckpoint -StoryKey $fullStoryKey -Reason "pre-start" | Out-Null
|
|
366
|
+
}
|
|
367
|
+
|
|
368
|
+
$exitCode = 0
|
|
369
|
+
|
|
370
|
+
if ($NoMonitor) {
|
|
371
|
+
# Run in foreground (no monitoring)
|
|
372
|
+
switch ($mode) {
|
|
373
|
+
"context" {
|
|
374
|
+
$exitCode = Invoke-SMStoryContext -StoryKey $fullStoryKey
|
|
375
|
+
}
|
|
376
|
+
"develop" {
|
|
377
|
+
$exitCode = Invoke-DevStory -StoryKey $fullStoryKey
|
|
378
|
+
if ($exitCode -eq 0) {
|
|
379
|
+
Update-StoryStatus -StoryKey $fullStoryKey -NewStatus "review"
|
|
380
|
+
if ($env:AUTO_COMMIT -eq "true") { Invoke-AutoCommit -StoryKey $fullStoryKey }
|
|
381
|
+
if ($env:AUTO_PR -eq "true") { New-AutoPR -StoryKey $fullStoryKey }
|
|
382
|
+
}
|
|
383
|
+
}
|
|
384
|
+
"review" {
|
|
385
|
+
$exitCode = Invoke-SMCodeReview -StoryKey $fullStoryKey
|
|
386
|
+
}
|
|
387
|
+
"full" {
|
|
388
|
+
$exitCode = Start-FullPipeline -StoryKey $fullStoryKey
|
|
389
|
+
}
|
|
390
|
+
}
|
|
391
|
+
}
|
|
392
|
+
else {
|
|
393
|
+
# Run as background jobs with monitoring
|
|
394
|
+
switch ($mode) {
|
|
395
|
+
"context" {
|
|
396
|
+
$logFile = Join-Path $script:LogsDir "$fullStoryKey-context.log"
|
|
397
|
+
$job = Start-AgentJob -Phase "context" -StoryKey $fullStoryKey -LogFile $logFile
|
|
398
|
+
$exitCode = Watch-AgentProgress -Job $job -StoryKey $fullStoryKey -Mode $mode -Phase "Context Creation" -LogFile $logFile
|
|
399
|
+
}
|
|
400
|
+
"develop" {
|
|
401
|
+
$logFile = Join-Path $script:LogsDir "$fullStoryKey-develop.log"
|
|
402
|
+
$job = Start-AgentJob -Phase "develop" -StoryKey $fullStoryKey -LogFile $logFile
|
|
403
|
+
$exitCode = Watch-AgentProgress -Job $job -StoryKey $fullStoryKey -Mode $mode -Phase "Development" -LogFile $logFile
|
|
404
|
+
|
|
405
|
+
if ($exitCode -eq 0) {
|
|
406
|
+
Update-StoryStatus -StoryKey $fullStoryKey -NewStatus "review"
|
|
407
|
+
if ($env:AUTO_COMMIT -eq "true") { Invoke-AutoCommit -StoryKey $fullStoryKey }
|
|
408
|
+
if ($env:AUTO_PR -eq "true") { New-AutoPR -StoryKey $fullStoryKey }
|
|
409
|
+
}
|
|
410
|
+
}
|
|
411
|
+
"review" {
|
|
412
|
+
$logFile = Join-Path $script:LogsDir "$fullStoryKey-review.log"
|
|
413
|
+
$job = Start-AgentJob -Phase "review" -StoryKey $fullStoryKey -LogFile $logFile
|
|
414
|
+
$exitCode = Watch-AgentProgress -Job $job -StoryKey $fullStoryKey -Mode $mode -Phase "Code Review" -LogFile $logFile
|
|
415
|
+
}
|
|
416
|
+
"full" {
|
|
417
|
+
# Full pipeline with monitoring for each phase
|
|
418
|
+
$contextFile = Join-Path $script:ProjectRoot "docs\$fullStoryKey.context.xml"
|
|
419
|
+
|
|
420
|
+
# Phase 1: Context
|
|
421
|
+
if (-not (Test-Path $contextFile)) {
|
|
422
|
+
$logFile = Join-Path $script:LogsDir "$fullStoryKey-context.log"
|
|
423
|
+
$job = Start-AgentJob -Phase "context" -StoryKey $fullStoryKey -LogFile $logFile
|
|
424
|
+
$exitCode = Watch-AgentProgress -Job $job -StoryKey $fullStoryKey -Mode $mode -Phase "1/3: Context Creation" -LogFile $logFile
|
|
425
|
+
if ($exitCode -ne 0) {
|
|
426
|
+
Write-Host "`n [X] Context creation failed" -ForegroundColor Red
|
|
427
|
+
return
|
|
428
|
+
}
|
|
429
|
+
}
|
|
430
|
+
|
|
431
|
+
# Phase 2: Development
|
|
432
|
+
$logFile = Join-Path $script:LogsDir "$fullStoryKey-develop.log"
|
|
433
|
+
$job = Start-AgentJob -Phase "develop" -StoryKey $fullStoryKey -LogFile $logFile
|
|
434
|
+
$exitCode = Watch-AgentProgress -Job $job -StoryKey $fullStoryKey -Mode $mode -Phase "2/3: Development" -LogFile $logFile
|
|
435
|
+
|
|
436
|
+
if ($exitCode -ne 0) {
|
|
437
|
+
Write-Host "`n [X] Development failed" -ForegroundColor Red
|
|
438
|
+
return
|
|
439
|
+
}
|
|
440
|
+
|
|
441
|
+
Update-StoryStatus -StoryKey $fullStoryKey -NewStatus "review"
|
|
442
|
+
if ($env:AUTO_COMMIT -eq "true") { Invoke-AutoCommit -StoryKey $fullStoryKey }
|
|
443
|
+
if ($env:AUTO_PR -eq "true") { New-AutoPR -StoryKey $fullStoryKey }
|
|
444
|
+
|
|
445
|
+
# Phase 3: Review
|
|
446
|
+
$logFile = Join-Path $script:LogsDir "$fullStoryKey-review.log"
|
|
447
|
+
$job = Start-AgentJob -Phase "review" -StoryKey $fullStoryKey -LogFile $logFile
|
|
448
|
+
$exitCode = Watch-AgentProgress -Job $job -StoryKey $fullStoryKey -Mode $mode -Phase "3/3: Code Review" -LogFile $logFile
|
|
449
|
+
|
|
450
|
+
if ($exitCode -eq 0) {
|
|
451
|
+
Update-StoryStatus -StoryKey $fullStoryKey -NewStatus "done"
|
|
452
|
+
}
|
|
453
|
+
}
|
|
454
|
+
}
|
|
455
|
+
}
|
|
456
|
+
|
|
457
|
+
# Create completion checkpoint
|
|
458
|
+
if ($exitCode -eq 0 -and $mode -ne "context") {
|
|
459
|
+
if (Get-Command New-StoryCheckpoint -ErrorAction SilentlyContinue) {
|
|
460
|
+
Write-Host "`n >> Creating completion checkpoint..." -ForegroundColor Blue
|
|
461
|
+
New-StoryCheckpoint -StoryKey $fullStoryKey -Reason "complete" | Out-Null
|
|
462
|
+
}
|
|
463
|
+
}
|
|
464
|
+
|
|
465
|
+
# Cleanup old checkpoints
|
|
466
|
+
if (Get-Command Remove-OldCheckpoints -ErrorAction SilentlyContinue) {
|
|
467
|
+
Remove-OldCheckpoints -KeepCount 10
|
|
468
|
+
}
|
|
469
|
+
|
|
470
|
+
# Final message
|
|
471
|
+
Write-Host ""
|
|
472
|
+
if ($exitCode -eq 0) {
|
|
473
|
+
Write-Host " [OK] Complete!" -ForegroundColor Green
|
|
474
|
+
}
|
|
475
|
+
else {
|
|
476
|
+
Write-Host " [X] Failed with exit code: $exitCode" -ForegroundColor Red
|
|
477
|
+
}
|
|
478
|
+
|
|
479
|
+
Write-Host ""
|
|
480
|
+
Write-Host " Log files: $script:LogsDir" -ForegroundColor Gray
|
|
481
|
+
Write-Host " Checkpoints: $script:CheckpointDir" -ForegroundColor Gray
|
|
482
|
+
Write-Host ""
|
|
483
|
+
|
|
484
|
+
exit $exitCode
|
|
485
|
+
}
|
|
486
|
+
|
|
487
|
+
#endregion
|
|
488
|
+
|
|
489
|
+
# Run main
|
|
490
|
+
Main
|