@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,1293 @@
|
|
|
1
|
+
#!/usr/bin/env bash
|
|
2
|
+
################################################################################
|
|
3
|
+
# Claude CLI Integration Library
|
|
4
|
+
#
|
|
5
|
+
# Wrapper functions for invoking Claude Code CLI to execute workflows
|
|
6
|
+
# Uses the actual Claude Code CLI syntax
|
|
7
|
+
################################################################################
|
|
8
|
+
|
|
9
|
+
SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)"
|
|
10
|
+
PROJECT_ROOT="$(cd "$SCRIPT_DIR/../.." && pwd)"
|
|
11
|
+
AUTOMATION_DIR="$PROJECT_ROOT/.automation"
|
|
12
|
+
AGENTS_DIR="$AUTOMATION_DIR/agents"
|
|
13
|
+
LOGS_DIR="$AUTOMATION_DIR/logs"
|
|
14
|
+
STORIES_DIR="$PROJECT_ROOT/docs"
|
|
15
|
+
|
|
16
|
+
# Source dependencies
|
|
17
|
+
source "$SCRIPT_DIR/session-manager.sh" 2>/dev/null || true
|
|
18
|
+
source "$SCRIPT_DIR/track-tokens.sh" 2>/dev/null || true
|
|
19
|
+
source "$SCRIPT_DIR/context-monitor.sh" 2>/dev/null || true
|
|
20
|
+
source "$SCRIPT_DIR/checkpoint-integration.sh" 2>/dev/null || true
|
|
21
|
+
source "$SCRIPT_DIR/override-loader.sh" 2>/dev/null || true
|
|
22
|
+
|
|
23
|
+
# Claude CLI path
|
|
24
|
+
CLAUDE_CLI="${CLAUDE_CLI:-claude}"
|
|
25
|
+
|
|
26
|
+
# Default model (can be overridden)
|
|
27
|
+
CLAUDE_MODEL="${CLAUDE_MODEL:-sonnet}"
|
|
28
|
+
|
|
29
|
+
# Permission mode for automation (bypasses interactive permission prompts)
|
|
30
|
+
# Options: "default", "acceptEdits", "bypassPermissions", "plan", "dangerouslySkipPermissions"
|
|
31
|
+
PERMISSION_MODE="${PERMISSION_MODE:-dangerouslySkipPermissions}"
|
|
32
|
+
|
|
33
|
+
# Build permission flags based on mode
|
|
34
|
+
get_permission_flags() {
|
|
35
|
+
case "$PERMISSION_MODE" in
|
|
36
|
+
"dangerouslySkipPermissions"|"skip")
|
|
37
|
+
echo "--dangerously-skip-permissions"
|
|
38
|
+
;;
|
|
39
|
+
*)
|
|
40
|
+
echo "--permission-mode $PERMISSION_MODE"
|
|
41
|
+
;;
|
|
42
|
+
esac
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
################################################################################
|
|
46
|
+
# Helper Functions
|
|
47
|
+
################################################################################
|
|
48
|
+
|
|
49
|
+
# Read file content for prompt
|
|
50
|
+
read_file_content() {
|
|
51
|
+
local file="$1"
|
|
52
|
+
if [[ -f "$file" ]]; then
|
|
53
|
+
cat "$file"
|
|
54
|
+
else
|
|
55
|
+
echo "[File not found: $file]"
|
|
56
|
+
fi
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
# Create a combined prompt from agent and workflow
|
|
60
|
+
build_prompt() {
|
|
61
|
+
local agent_file="$1"
|
|
62
|
+
local task_description="$2"
|
|
63
|
+
|
|
64
|
+
local agent_prompt=""
|
|
65
|
+
if [[ -f "$agent_file" ]]; then
|
|
66
|
+
agent_prompt=$(cat "$agent_file")
|
|
67
|
+
fi
|
|
68
|
+
|
|
69
|
+
echo "$agent_prompt
|
|
70
|
+
|
|
71
|
+
---
|
|
72
|
+
|
|
73
|
+
## Current Task
|
|
74
|
+
|
|
75
|
+
$task_description"
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
# Get agent prompt with overrides applied
|
|
79
|
+
# Usage: get_agent_prompt "dev" -> returns agent + user profile + overrides + memory
|
|
80
|
+
get_agent_prompt() {
|
|
81
|
+
local agent_name="$1"
|
|
82
|
+
|
|
83
|
+
# Try to use override loader if available
|
|
84
|
+
if type load_agent_with_overrides &>/dev/null; then
|
|
85
|
+
load_agent_with_overrides "$agent_name"
|
|
86
|
+
else
|
|
87
|
+
# Fallback to basic agent loading
|
|
88
|
+
cat "$AGENTS_DIR/${agent_name}.md" 2>/dev/null
|
|
89
|
+
fi
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
# Get model for agent (with override support)
|
|
93
|
+
# Usage: get_agent_model "dev" "opus" -> returns override model or fallback
|
|
94
|
+
get_agent_model() {
|
|
95
|
+
local agent_name="$1"
|
|
96
|
+
local default_model="$2"
|
|
97
|
+
|
|
98
|
+
# Check for override
|
|
99
|
+
if type get_agent_model_override &>/dev/null; then
|
|
100
|
+
local override=$(get_agent_model_override "$agent_name")
|
|
101
|
+
if [[ -n "$override" ]]; then
|
|
102
|
+
echo "$override"
|
|
103
|
+
return
|
|
104
|
+
fi
|
|
105
|
+
fi
|
|
106
|
+
|
|
107
|
+
# Use default or global CLAUDE_MODEL
|
|
108
|
+
echo "${default_model:-$CLAUDE_MODEL}"
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
# Get budget for agent (with override support)
|
|
112
|
+
get_agent_budget() {
|
|
113
|
+
local agent_name="$1"
|
|
114
|
+
local default_budget="$2"
|
|
115
|
+
|
|
116
|
+
# Check for override
|
|
117
|
+
if type get_agent_budget_override &>/dev/null; then
|
|
118
|
+
local override=$(get_agent_budget_override "$agent_name")
|
|
119
|
+
if [[ -n "$override" ]]; then
|
|
120
|
+
echo "$override"
|
|
121
|
+
return
|
|
122
|
+
fi
|
|
123
|
+
fi
|
|
124
|
+
|
|
125
|
+
echo "$default_budget"
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
################################################################################
|
|
129
|
+
# Persona Banner Functions
|
|
130
|
+
################################################################################
|
|
131
|
+
|
|
132
|
+
print_persona_banner() {
|
|
133
|
+
local persona="$1"
|
|
134
|
+
local role="$2"
|
|
135
|
+
local color="${3:-\033[1;36m}" # Default: bright cyan
|
|
136
|
+
local model="${4:-}" # Optional model parameter
|
|
137
|
+
local reset='\033[0m'
|
|
138
|
+
|
|
139
|
+
echo ""
|
|
140
|
+
echo -e "${color}╔═══════════════════════════════════════════════════════════════╗${reset}"
|
|
141
|
+
echo -e "${color}║ PERSONA SWITCH ║${reset}"
|
|
142
|
+
echo -e "${color}╠═══════════════════════════════════════════════════════════════╣${reset}"
|
|
143
|
+
echo -e "${color}║ Agent:${reset} $persona"
|
|
144
|
+
echo -e "${color}║ Role:${reset} $role"
|
|
145
|
+
if [[ -n "$model" ]]; then
|
|
146
|
+
echo -e "${color}║ Model:${reset} $model"
|
|
147
|
+
fi
|
|
148
|
+
echo -e "${color}╚═══════════════════════════════════════════════════════════════╝${reset}"
|
|
149
|
+
echo ""
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
################################################################################
|
|
153
|
+
# Workflow Invocation Functions
|
|
154
|
+
################################################################################
|
|
155
|
+
|
|
156
|
+
invoke_sm_story_context() {
|
|
157
|
+
local story_key="$1"
|
|
158
|
+
local story_file="$STORIES_DIR/${story_key}.md"
|
|
159
|
+
local context_file="$STORIES_DIR/${story_key}.context.xml"
|
|
160
|
+
local log_file="$LOGS_DIR/${story_key}-context.log"
|
|
161
|
+
local model="sonnet" # Use Sonnet for planning/context tasks
|
|
162
|
+
|
|
163
|
+
# Show persona switch
|
|
164
|
+
print_persona_banner "SM (Scrum Master)" "Story Context Creation & Planning" "\033[1;33m" "$model"
|
|
165
|
+
|
|
166
|
+
echo "▶ Creating story context for: $story_key"
|
|
167
|
+
|
|
168
|
+
# Check if story file exists
|
|
169
|
+
if [[ ! -f "$story_file" ]]; then
|
|
170
|
+
echo "❌ Story file not found: $story_file"
|
|
171
|
+
return 1
|
|
172
|
+
fi
|
|
173
|
+
|
|
174
|
+
local story_content=$(cat "$story_file")
|
|
175
|
+
|
|
176
|
+
local prompt="Create a technical context file for implementing this story.
|
|
177
|
+
|
|
178
|
+
## Story Specification
|
|
179
|
+
$story_content
|
|
180
|
+
|
|
181
|
+
## Instructions
|
|
182
|
+
1. Read the story requirements carefully
|
|
183
|
+
2. Explore the codebase to find relevant patterns and existing code
|
|
184
|
+
3. Identify files that need to be created or modified
|
|
185
|
+
4. Create the context file at: $context_file
|
|
186
|
+
|
|
187
|
+
The context.xml should include:
|
|
188
|
+
- story-key, title, status
|
|
189
|
+
- files-to-create list
|
|
190
|
+
- files-to-modify list
|
|
191
|
+
- dependencies
|
|
192
|
+
- testing-requirements
|
|
193
|
+
- project-paths (app-root: app, lib-path: app/lib, test-path: app/test)
|
|
194
|
+
|
|
195
|
+
After creating the context file, update sprint-status.yaml to set this story to 'ready-for-dev'."
|
|
196
|
+
|
|
197
|
+
# Invoke Claude CLI from project root
|
|
198
|
+
(
|
|
199
|
+
cd "$PROJECT_ROOT" || exit 1
|
|
200
|
+
echo "$prompt" | $CLAUDE_CLI -p \
|
|
201
|
+
--model "$(get_agent_model "sm" "$model")" \
|
|
202
|
+
$(get_permission_flags) \
|
|
203
|
+
--append-system-prompt "$(get_agent_prompt "sm")" \
|
|
204
|
+
--tools "Read,Write,Edit,Grep,Glob,Bash" \
|
|
205
|
+
--max-budget-usd "$(get_agent_budget "sm" "3.00")"
|
|
206
|
+
) 2>&1 | tee "$log_file"
|
|
207
|
+
|
|
208
|
+
return ${PIPESTATUS[0]}
|
|
209
|
+
}
|
|
210
|
+
|
|
211
|
+
invoke_dev_story() {
|
|
212
|
+
local story_key="$1"
|
|
213
|
+
local story_file="$STORIES_DIR/${story_key}.md"
|
|
214
|
+
local context_file="$STORIES_DIR/${story_key}.context.xml"
|
|
215
|
+
local log_file="$LOGS_DIR/${story_key}-develop.log"
|
|
216
|
+
local model="opus" # Use Opus for code development
|
|
217
|
+
|
|
218
|
+
# Show persona switch
|
|
219
|
+
print_persona_banner "DEV (Developer)" "Story Implementation & Coding" "\033[1;32m" "$model"
|
|
220
|
+
|
|
221
|
+
echo "▶ Implementing story: $story_key"
|
|
222
|
+
|
|
223
|
+
# Check required files
|
|
224
|
+
if [[ ! -f "$story_file" ]]; then
|
|
225
|
+
echo "❌ Story file not found: $story_file"
|
|
226
|
+
return 1
|
|
227
|
+
fi
|
|
228
|
+
|
|
229
|
+
if [[ ! -f "$context_file" ]]; then
|
|
230
|
+
echo "❌ Context file not found: $context_file"
|
|
231
|
+
return 1
|
|
232
|
+
fi
|
|
233
|
+
|
|
234
|
+
# Pre-flight context check
|
|
235
|
+
echo "📊 Checking context feasibility..."
|
|
236
|
+
check_context_feasibility "$story_file" "$context_file"
|
|
237
|
+
echo ""
|
|
238
|
+
|
|
239
|
+
local story_content=$(cat "$story_file")
|
|
240
|
+
local context_content=$(cat "$context_file")
|
|
241
|
+
|
|
242
|
+
local prompt="IMPLEMENT THIS STORY NOW. Create all required files and code.
|
|
243
|
+
|
|
244
|
+
$story_content
|
|
245
|
+
|
|
246
|
+
---
|
|
247
|
+
|
|
248
|
+
CONTEXT (files to create/modify):
|
|
249
|
+
$context_content
|
|
250
|
+
|
|
251
|
+
---
|
|
252
|
+
|
|
253
|
+
START IMMEDIATELY:
|
|
254
|
+
1. Read existing code in app/lib/features/ to understand patterns
|
|
255
|
+
2. Create ALL files listed in files-to-create using the Write tool
|
|
256
|
+
3. Modify files listed in files-to-modify using the Edit tool
|
|
257
|
+
4. Write tests in app/test/
|
|
258
|
+
5. Run: cd app && flutter test
|
|
259
|
+
|
|
260
|
+
DO NOT explain or ask questions. Just implement the code."
|
|
261
|
+
|
|
262
|
+
# Start context monitor in background
|
|
263
|
+
local monitor_pid=""
|
|
264
|
+
if type start_context_monitor &>/dev/null; then
|
|
265
|
+
monitor_pid=$(start_context_monitor "$log_file" "$story_key")
|
|
266
|
+
fi
|
|
267
|
+
|
|
268
|
+
# Start checkpoint monitor in background
|
|
269
|
+
if type start_checkpoint_monitor &>/dev/null; then
|
|
270
|
+
start_checkpoint_monitor "$log_file" "$story_key"
|
|
271
|
+
log_checkpoint_info "$log_file"
|
|
272
|
+
fi
|
|
273
|
+
|
|
274
|
+
# Create symlink to current.log for service monitoring
|
|
275
|
+
ln -sf "$log_file" "$LOGS_DIR/current.log"
|
|
276
|
+
|
|
277
|
+
# Invoke Claude CLI with full toolset from project root
|
|
278
|
+
(
|
|
279
|
+
cd "$PROJECT_ROOT" || exit 1
|
|
280
|
+
echo "$prompt" | $CLAUDE_CLI -p \
|
|
281
|
+
--model "$(get_agent_model "dev" "$model")" \
|
|
282
|
+
$(get_permission_flags) \
|
|
283
|
+
--append-system-prompt "$(get_agent_prompt "dev")" \
|
|
284
|
+
--tools "Read,Write,Edit,Grep,Glob,Bash" \
|
|
285
|
+
--max-budget-usd "$(get_agent_budget "dev" "15.00")"
|
|
286
|
+
) 2>&1 | tee "$log_file"
|
|
287
|
+
|
|
288
|
+
local exit_code=${PIPESTATUS[0]}
|
|
289
|
+
|
|
290
|
+
# Stop context monitor
|
|
291
|
+
if [[ -n "$monitor_pid" ]]; then
|
|
292
|
+
stop_context_monitor "$monitor_pid"
|
|
293
|
+
fi
|
|
294
|
+
|
|
295
|
+
# Stop checkpoint monitor
|
|
296
|
+
if type stop_checkpoint_monitor &>/dev/null; then
|
|
297
|
+
stop_checkpoint_monitor "$log_file"
|
|
298
|
+
fi
|
|
299
|
+
|
|
300
|
+
return $exit_code
|
|
301
|
+
}
|
|
302
|
+
|
|
303
|
+
invoke_sm_code_review() {
|
|
304
|
+
local story_key="$1"
|
|
305
|
+
local story_file="$STORIES_DIR/${story_key}.md"
|
|
306
|
+
local review_file="$STORIES_DIR/${story_key}.code-review.md"
|
|
307
|
+
local log_file="$LOGS_DIR/${story_key}-review.log"
|
|
308
|
+
local model="opus" # Use Opus for code review
|
|
309
|
+
|
|
310
|
+
# Show persona switch
|
|
311
|
+
print_persona_banner "SM (Scrum Master)" "Code Review & Quality Assurance" "\033[1;35m" "$model"
|
|
312
|
+
|
|
313
|
+
echo "▶ Reviewing implementation: $story_key"
|
|
314
|
+
|
|
315
|
+
if [[ ! -f "$story_file" ]]; then
|
|
316
|
+
echo "❌ Story file not found: $story_file"
|
|
317
|
+
return 1
|
|
318
|
+
fi
|
|
319
|
+
|
|
320
|
+
local story_content=$(cat "$story_file")
|
|
321
|
+
|
|
322
|
+
local prompt="Perform a code review for this implemented story.
|
|
323
|
+
|
|
324
|
+
## Story Specification
|
|
325
|
+
$story_content
|
|
326
|
+
|
|
327
|
+
## Instructions
|
|
328
|
+
1. Read all acceptance criteria in the story
|
|
329
|
+
2. For each AC, verify it has been implemented correctly
|
|
330
|
+
3. Check code quality and patterns
|
|
331
|
+
4. Run 'cd app && flutter test' to verify tests pass
|
|
332
|
+
5. Create a review report at: $review_file
|
|
333
|
+
|
|
334
|
+
The review file should include:
|
|
335
|
+
- Overall verdict: APPROVED or CHANGES REQUESTED
|
|
336
|
+
- Score out of 100
|
|
337
|
+
- AC verification checklist (each AC marked as met/not met)
|
|
338
|
+
- Code quality notes
|
|
339
|
+
- Any issues found
|
|
340
|
+
|
|
341
|
+
If APPROVED, update sprint-status.yaml to 'done'.
|
|
342
|
+
If CHANGES REQUESTED, update sprint-status.yaml to 'in-progress' and list required changes."
|
|
343
|
+
|
|
344
|
+
# Start context monitor in background
|
|
345
|
+
local monitor_pid=""
|
|
346
|
+
if type start_context_monitor &>/dev/null; then
|
|
347
|
+
monitor_pid=$(start_context_monitor "$log_file" "$story_key")
|
|
348
|
+
fi
|
|
349
|
+
|
|
350
|
+
# Start checkpoint monitor in background
|
|
351
|
+
if type start_checkpoint_monitor &>/dev/null; then
|
|
352
|
+
start_checkpoint_monitor "$log_file" "$story_key"
|
|
353
|
+
log_checkpoint_info "$log_file"
|
|
354
|
+
fi
|
|
355
|
+
|
|
356
|
+
# Create symlink to current.log for service monitoring
|
|
357
|
+
ln -sf "$log_file" "$LOGS_DIR/current.log"
|
|
358
|
+
|
|
359
|
+
(
|
|
360
|
+
cd "$PROJECT_ROOT" || exit 1
|
|
361
|
+
echo "$prompt" | $CLAUDE_CLI -p \
|
|
362
|
+
--model "$(get_agent_model "sm" "$model")" \
|
|
363
|
+
$(get_permission_flags) \
|
|
364
|
+
--append-system-prompt "$(get_agent_prompt "sm")" \
|
|
365
|
+
--tools "Read,Write,Edit,Grep,Glob,Bash" \
|
|
366
|
+
--max-budget-usd "$(get_agent_budget "sm" "5.00")"
|
|
367
|
+
) 2>&1 | tee "$log_file"
|
|
368
|
+
|
|
369
|
+
local exit_code=${PIPESTATUS[0]}
|
|
370
|
+
|
|
371
|
+
# Stop context monitor
|
|
372
|
+
if [[ -n "$monitor_pid" ]]; then
|
|
373
|
+
stop_context_monitor "$monitor_pid"
|
|
374
|
+
fi
|
|
375
|
+
|
|
376
|
+
# Stop checkpoint monitor
|
|
377
|
+
if type stop_checkpoint_monitor &>/dev/null; then
|
|
378
|
+
stop_checkpoint_monitor "$log_file"
|
|
379
|
+
fi
|
|
380
|
+
|
|
381
|
+
return $exit_code
|
|
382
|
+
}
|
|
383
|
+
|
|
384
|
+
# Adversarial code review - uses the critical reviewer agent
|
|
385
|
+
invoke_adversarial_review() {
|
|
386
|
+
local story_key="$1"
|
|
387
|
+
local story_file="$STORIES_DIR/${story_key}.md"
|
|
388
|
+
local review_file="$STORIES_DIR/${story_key}.adversarial-review.md"
|
|
389
|
+
local log_file="$LOGS_DIR/${story_key}-adversarial-review.log"
|
|
390
|
+
local model="opus" # Adversarial reviews use Opus for deeper analysis
|
|
391
|
+
|
|
392
|
+
# Show persona switch
|
|
393
|
+
print_persona_banner "REVIEWER (Adversarial)" "Critical Code Analysis" "\033[1;31m" "$model"
|
|
394
|
+
|
|
395
|
+
echo "▶ Running adversarial review: $story_key"
|
|
396
|
+
|
|
397
|
+
if [[ ! -f "$story_file" ]]; then
|
|
398
|
+
echo "❌ Story file not found: $story_file"
|
|
399
|
+
return 1
|
|
400
|
+
fi
|
|
401
|
+
|
|
402
|
+
local story_content=$(cat "$story_file")
|
|
403
|
+
|
|
404
|
+
local prompt="CRITICALLY REVIEW this implementation. Your job is to FIND PROBLEMS.
|
|
405
|
+
|
|
406
|
+
## Story Specification
|
|
407
|
+
$story_content
|
|
408
|
+
|
|
409
|
+
## Instructions
|
|
410
|
+
1. Read all acceptance criteria carefully
|
|
411
|
+
2. For EACH criterion, verify it is ACTUALLY met (not just superficially)
|
|
412
|
+
3. Look for edge cases that aren't handled
|
|
413
|
+
4. Check for security vulnerabilities
|
|
414
|
+
5. Verify error handling is comprehensive
|
|
415
|
+
6. Look for race conditions in async code
|
|
416
|
+
7. Check that tests cover failure paths, not just happy paths
|
|
417
|
+
8. Run 'cd app && flutter test' to verify tests pass
|
|
418
|
+
|
|
419
|
+
Create your adversarial review at: $review_file
|
|
420
|
+
|
|
421
|
+
BE CRITICAL. If you can't find issues, look harder. Every implementation has room for improvement.
|
|
422
|
+
|
|
423
|
+
Verdict options:
|
|
424
|
+
- APPROVED (rare - only for truly solid implementations)
|
|
425
|
+
- CHANGES REQUIRED (most common - list specific issues)
|
|
426
|
+
- BLOCKED (serious issues that must be addressed)"
|
|
427
|
+
|
|
428
|
+
# Create symlink to current.log for monitoring
|
|
429
|
+
ln -sf "$log_file" "$LOGS_DIR/current.log"
|
|
430
|
+
|
|
431
|
+
(
|
|
432
|
+
cd "$PROJECT_ROOT" || exit 1
|
|
433
|
+
echo "$prompt" | $CLAUDE_CLI -p \
|
|
434
|
+
--model "$(get_agent_model "reviewer" "$model")" \
|
|
435
|
+
$(get_permission_flags) \
|
|
436
|
+
--append-system-prompt "$(get_agent_prompt "reviewer")" \
|
|
437
|
+
--tools "Read,Write,Edit,Grep,Glob,Bash" \
|
|
438
|
+
--max-budget-usd "$(get_agent_budget "reviewer" "8.00")"
|
|
439
|
+
) 2>&1 | tee "$log_file"
|
|
440
|
+
|
|
441
|
+
return ${PIPESTATUS[0]}
|
|
442
|
+
}
|
|
443
|
+
|
|
444
|
+
invoke_sm_draft_story() {
|
|
445
|
+
local story_key="$1"
|
|
446
|
+
local story_file="$STORIES_DIR/${story_key}.md"
|
|
447
|
+
local epics_file="$PROJECT_ROOT/docs/epics.md"
|
|
448
|
+
local log_file="$LOGS_DIR/${story_key}-draft.log"
|
|
449
|
+
local model="sonnet" # Use Sonnet for story drafting
|
|
450
|
+
|
|
451
|
+
# Show persona switch
|
|
452
|
+
print_persona_banner "SM (Scrum Master)" "Story Drafting & Specification" "\033[1;33m" "$model"
|
|
453
|
+
|
|
454
|
+
echo "▶ Drafting story: $story_key"
|
|
455
|
+
|
|
456
|
+
# Extract epic number from story key (e.g., 3-5 -> 3)
|
|
457
|
+
local epic_num=$(echo "$story_key" | cut -d'-' -f1)
|
|
458
|
+
|
|
459
|
+
local prompt="Draft a detailed story specification.
|
|
460
|
+
|
|
461
|
+
Story Key: $story_key
|
|
462
|
+
Epic: $epic_num
|
|
463
|
+
|
|
464
|
+
## Instructions
|
|
465
|
+
1. Read the epics file at $epics_file to understand the epic context
|
|
466
|
+
2. Find the story entry for $story_key in the epic
|
|
467
|
+
3. Create a detailed story specification at: $story_file
|
|
468
|
+
|
|
469
|
+
The story file should include:
|
|
470
|
+
- # Title
|
|
471
|
+
- ## Summary
|
|
472
|
+
- ## Acceptance Criteria (numbered as AC X.Y.Z)
|
|
473
|
+
- ## Technical Notes
|
|
474
|
+
- ## Dependencies (if any)
|
|
475
|
+
- ## Testing Requirements
|
|
476
|
+
|
|
477
|
+
After creating the story, update sprint-status.yaml to set this story to 'drafted'."
|
|
478
|
+
|
|
479
|
+
(
|
|
480
|
+
cd "$PROJECT_ROOT" || exit 1
|
|
481
|
+
echo "$prompt" | $CLAUDE_CLI -p \
|
|
482
|
+
--model "$model" \
|
|
483
|
+
$(get_permission_flags) \
|
|
484
|
+
--append-system-prompt "$(cat "$AGENTS_DIR/sm.md" 2>/dev/null)" \
|
|
485
|
+
--tools "Read,Write,Edit,Grep,Glob" \
|
|
486
|
+
--max-budget-usd 2.00
|
|
487
|
+
) 2>&1 | tee "$log_file"
|
|
488
|
+
|
|
489
|
+
return ${PIPESTATUS[0]}
|
|
490
|
+
}
|
|
491
|
+
|
|
492
|
+
################################################################################
|
|
493
|
+
# Additional Agent Workflows
|
|
494
|
+
################################################################################
|
|
495
|
+
|
|
496
|
+
invoke_ba_requirements() {
|
|
497
|
+
local feature_name="$1"
|
|
498
|
+
local output_file="$PROJECT_ROOT/docs/requirements/${feature_name}.md"
|
|
499
|
+
local log_file="$LOGS_DIR/${feature_name}-requirements.log"
|
|
500
|
+
local model="sonnet" # Use Sonnet for requirements analysis
|
|
501
|
+
|
|
502
|
+
# Show persona switch
|
|
503
|
+
print_persona_banner "BA (Business Analyst)" "Requirements Analysis & User Stories" "\033[1;34m" "$model"
|
|
504
|
+
|
|
505
|
+
echo "▶ Analyzing requirements for: $feature_name"
|
|
506
|
+
|
|
507
|
+
mkdir -p "$PROJECT_ROOT/docs/requirements"
|
|
508
|
+
|
|
509
|
+
local prompt="Analyze and document requirements for the feature: $feature_name
|
|
510
|
+
|
|
511
|
+
## Instructions
|
|
512
|
+
1. Read the PRD at tooling/docs/prd.md for product context
|
|
513
|
+
2. Read the epics at tooling/docs/epics.md for feature context
|
|
514
|
+
3. Create a detailed requirements document at: $output_file
|
|
515
|
+
|
|
516
|
+
The requirements document should include:
|
|
517
|
+
- User stories with acceptance criteria
|
|
518
|
+
- Business rules
|
|
519
|
+
- Data requirements
|
|
520
|
+
- Edge cases and error scenarios
|
|
521
|
+
- Dependencies
|
|
522
|
+
|
|
523
|
+
Use the INVEST criteria for user stories."
|
|
524
|
+
|
|
525
|
+
(
|
|
526
|
+
cd "$PROJECT_ROOT" || exit 1
|
|
527
|
+
echo "$prompt" | $CLAUDE_CLI -p \
|
|
528
|
+
--model "$model" \
|
|
529
|
+
$(get_permission_flags) \
|
|
530
|
+
--append-system-prompt "$(cat "$AGENTS_DIR/ba.md" 2>/dev/null)" \
|
|
531
|
+
--tools "Read,Write,Edit,Grep,Glob" \
|
|
532
|
+
--max-budget-usd 3.00
|
|
533
|
+
) 2>&1 | tee "$log_file"
|
|
534
|
+
|
|
535
|
+
return ${PIPESTATUS[0]}
|
|
536
|
+
}
|
|
537
|
+
|
|
538
|
+
invoke_architect_design() {
|
|
539
|
+
local feature_name="$1"
|
|
540
|
+
local output_file="$STORIES_DIR/tech-spec-${feature_name}.md"
|
|
541
|
+
local log_file="$LOGS_DIR/${feature_name}-architecture.log"
|
|
542
|
+
local model="sonnet" # Use Sonnet for technical design
|
|
543
|
+
|
|
544
|
+
# Show persona switch
|
|
545
|
+
print_persona_banner "ARCHITECT" "Technical Design & Architecture" "\033[1;36m" "$model"
|
|
546
|
+
|
|
547
|
+
echo "▶ Creating technical specification for: $feature_name"
|
|
548
|
+
|
|
549
|
+
local prompt="Create a technical specification for: $feature_name
|
|
550
|
+
|
|
551
|
+
## Instructions
|
|
552
|
+
1. Read the architecture documentation at tooling/docs/architecture.md
|
|
553
|
+
2. Explore the existing codebase to understand current patterns
|
|
554
|
+
3. Read any related story or epic files
|
|
555
|
+
4. Create a technical specification at: $output_file
|
|
556
|
+
|
|
557
|
+
The tech spec should include:
|
|
558
|
+
- Component architecture
|
|
559
|
+
- Data model and database schema
|
|
560
|
+
- API design (if applicable)
|
|
561
|
+
- Non-functional requirements
|
|
562
|
+
- Implementation notes
|
|
563
|
+
- Risks and mitigations
|
|
564
|
+
|
|
565
|
+
Follow the existing project structure and patterns."
|
|
566
|
+
|
|
567
|
+
(
|
|
568
|
+
cd "$PROJECT_ROOT" || exit 1
|
|
569
|
+
echo "$prompt" | $CLAUDE_CLI -p \
|
|
570
|
+
--model "$model" \
|
|
571
|
+
$(get_permission_flags) \
|
|
572
|
+
--append-system-prompt "$(cat "$AGENTS_DIR/architect.md" 2>/dev/null)" \
|
|
573
|
+
--tools "Read,Write,Edit,Grep,Glob" \
|
|
574
|
+
--max-budget-usd 5.00
|
|
575
|
+
) 2>&1 | tee "$log_file"
|
|
576
|
+
|
|
577
|
+
return ${PIPESTATUS[0]}
|
|
578
|
+
}
|
|
579
|
+
|
|
580
|
+
invoke_pm_epic() {
|
|
581
|
+
local epic_num="$1"
|
|
582
|
+
local epics_file="$PROJECT_ROOT/docs/epics.md"
|
|
583
|
+
local log_file="$LOGS_DIR/epic-${epic_num}-planning.log"
|
|
584
|
+
local model="sonnet" # Use Sonnet for epic planning
|
|
585
|
+
|
|
586
|
+
# Show persona switch
|
|
587
|
+
print_persona_banner "PM (Product Manager)" "Epic Planning & Prioritization" "\033[1;31m" "$model"
|
|
588
|
+
|
|
589
|
+
echo "▶ Planning epic: $epic_num"
|
|
590
|
+
|
|
591
|
+
local prompt="Plan and refine Epic $epic_num
|
|
592
|
+
|
|
593
|
+
## Instructions
|
|
594
|
+
1. Read the PRD at tooling/docs/prd.md for product context
|
|
595
|
+
2. Read the current epics file at $epics_file
|
|
596
|
+
3. Analyze Epic $epic_num and refine its definition
|
|
597
|
+
4. Break down into well-defined stories
|
|
598
|
+
5. Update the epics file with refined content
|
|
599
|
+
|
|
600
|
+
Ensure each story is:
|
|
601
|
+
- Clearly defined with user value
|
|
602
|
+
- Appropriately sized (1-3 days of work)
|
|
603
|
+
- Properly sequenced with dependencies
|
|
604
|
+
|
|
605
|
+
Use RICE scoring to prioritize stories within the epic."
|
|
606
|
+
|
|
607
|
+
(
|
|
608
|
+
cd "$PROJECT_ROOT" || exit 1
|
|
609
|
+
echo "$prompt" | $CLAUDE_CLI -p \
|
|
610
|
+
--model "$model" \
|
|
611
|
+
$(get_permission_flags) \
|
|
612
|
+
--append-system-prompt "$(cat "$AGENTS_DIR/pm.md" 2>/dev/null)" \
|
|
613
|
+
--tools "Read,Write,Edit,Grep,Glob" \
|
|
614
|
+
--max-budget-usd 3.00
|
|
615
|
+
) 2>&1 | tee "$log_file"
|
|
616
|
+
|
|
617
|
+
return ${PIPESTATUS[0]}
|
|
618
|
+
}
|
|
619
|
+
|
|
620
|
+
invoke_writer_docs() {
|
|
621
|
+
local doc_type="$1"
|
|
622
|
+
local subject="$2"
|
|
623
|
+
local output_dir="$PROJECT_ROOT/docs"
|
|
624
|
+
local log_file="$LOGS_DIR/${subject}-docs.log"
|
|
625
|
+
local model="sonnet" # Use Sonnet for documentation
|
|
626
|
+
|
|
627
|
+
# Show persona switch
|
|
628
|
+
print_persona_banner "WRITER (Technical Writer)" "Documentation & Content Creation" "\033[1;37m" "$model"
|
|
629
|
+
|
|
630
|
+
echo "▶ Creating documentation: $doc_type for $subject"
|
|
631
|
+
|
|
632
|
+
local prompt="Create $doc_type documentation for: $subject
|
|
633
|
+
|
|
634
|
+
## Instructions
|
|
635
|
+
1. Explore the codebase to understand the implementation
|
|
636
|
+
2. Read any existing documentation for context
|
|
637
|
+
3. Create appropriate documentation
|
|
638
|
+
|
|
639
|
+
Documentation type: $doc_type
|
|
640
|
+
|
|
641
|
+
For user guides: Write step-by-step instructions with examples
|
|
642
|
+
For API docs: Document endpoints, parameters, and responses
|
|
643
|
+
For release notes: Summarize changes in user-friendly language
|
|
644
|
+
For README: Create a comprehensive project overview
|
|
645
|
+
|
|
646
|
+
Save the documentation to an appropriate location in $output_dir/"
|
|
647
|
+
|
|
648
|
+
(
|
|
649
|
+
cd "$PROJECT_ROOT" || exit 1
|
|
650
|
+
echo "$prompt" | $CLAUDE_CLI -p \
|
|
651
|
+
--model "$model" \
|
|
652
|
+
$(get_permission_flags) \
|
|
653
|
+
--append-system-prompt "$(cat "$AGENTS_DIR/writer.md" 2>/dev/null)" \
|
|
654
|
+
--tools "Read,Write,Edit,Grep,Glob" \
|
|
655
|
+
--max-budget-usd 3.00
|
|
656
|
+
) 2>&1 | tee "$log_file"
|
|
657
|
+
|
|
658
|
+
return ${PIPESTATUS[0]}
|
|
659
|
+
}
|
|
660
|
+
|
|
661
|
+
################################################################################
|
|
662
|
+
# Background Execution
|
|
663
|
+
################################################################################
|
|
664
|
+
|
|
665
|
+
execute_workflow_background() {
|
|
666
|
+
local workflow_name="$1"
|
|
667
|
+
local story_key="$2"
|
|
668
|
+
shift 2
|
|
669
|
+
local workflow_args=("$@")
|
|
670
|
+
|
|
671
|
+
local log_file="$LOGS_DIR/${story_key}-${workflow_name}.log"
|
|
672
|
+
|
|
673
|
+
echo "▶ Starting background workflow: $workflow_name for $story_key"
|
|
674
|
+
|
|
675
|
+
# Execute in background
|
|
676
|
+
(
|
|
677
|
+
local exit_code=0
|
|
678
|
+
|
|
679
|
+
case "$workflow_name" in
|
|
680
|
+
"story_context")
|
|
681
|
+
invoke_sm_story_context "$story_key" || exit_code=$?
|
|
682
|
+
;;
|
|
683
|
+
"dev_story")
|
|
684
|
+
invoke_dev_story "$story_key" || exit_code=$?
|
|
685
|
+
;;
|
|
686
|
+
"code_review")
|
|
687
|
+
invoke_sm_code_review "$story_key" || exit_code=$?
|
|
688
|
+
;;
|
|
689
|
+
"draft_story")
|
|
690
|
+
invoke_sm_draft_story "$story_key" || exit_code=$?
|
|
691
|
+
;;
|
|
692
|
+
*)
|
|
693
|
+
echo "Unknown workflow: $workflow_name"
|
|
694
|
+
exit_code=1
|
|
695
|
+
;;
|
|
696
|
+
esac
|
|
697
|
+
|
|
698
|
+
exit $exit_code
|
|
699
|
+
) > "$log_file" 2>&1 &
|
|
700
|
+
|
|
701
|
+
local bg_pid=$!
|
|
702
|
+
echo "Background PID: $bg_pid"
|
|
703
|
+
echo "Log file: $log_file"
|
|
704
|
+
|
|
705
|
+
return 0
|
|
706
|
+
}
|
|
707
|
+
|
|
708
|
+
################################################################################
|
|
709
|
+
# Full Pipeline
|
|
710
|
+
################################################################################
|
|
711
|
+
|
|
712
|
+
################################################################################
|
|
713
|
+
# Sprint Status Management
|
|
714
|
+
################################################################################
|
|
715
|
+
|
|
716
|
+
# Update story status in sprint-status.yaml
|
|
717
|
+
update_story_status() {
|
|
718
|
+
local story_key="$1"
|
|
719
|
+
local new_status="$2"
|
|
720
|
+
local sprint_status_file="$PROJECT_ROOT/docs/sprint-status.yaml"
|
|
721
|
+
|
|
722
|
+
echo "▶ Updating sprint status: $story_key → $new_status"
|
|
723
|
+
|
|
724
|
+
if [[ ! -f "$sprint_status_file" ]]; then
|
|
725
|
+
echo "⚠️ Sprint status file not found: $sprint_status_file"
|
|
726
|
+
return 1
|
|
727
|
+
fi
|
|
728
|
+
|
|
729
|
+
# Check if story exists in file
|
|
730
|
+
if ! grep -q "^ $story_key:" "$sprint_status_file"; then
|
|
731
|
+
echo "⚠️ Story $story_key not found in sprint-status.yaml"
|
|
732
|
+
return 1
|
|
733
|
+
fi
|
|
734
|
+
|
|
735
|
+
# Update the status using sed
|
|
736
|
+
if [[ "$OSTYPE" == "darwin"* ]]; then
|
|
737
|
+
# macOS
|
|
738
|
+
sed -i '' "s/^ $story_key:.*$/ $story_key: $new_status/" "$sprint_status_file"
|
|
739
|
+
else
|
|
740
|
+
# Linux
|
|
741
|
+
sed -i "s/^ $story_key:.*$/ $story_key: $new_status/" "$sprint_status_file"
|
|
742
|
+
fi
|
|
743
|
+
|
|
744
|
+
if [[ $? -eq 0 ]]; then
|
|
745
|
+
echo "✅ Status updated: $story_key → $new_status"
|
|
746
|
+
|
|
747
|
+
# Update the 'updated' timestamp
|
|
748
|
+
local today=$(date +%Y-%m-%d)
|
|
749
|
+
if [[ "$OSTYPE" == "darwin"* ]]; then
|
|
750
|
+
sed -i '' "s/^# updated:.*$/# updated: $today/" "$sprint_status_file"
|
|
751
|
+
sed -i '' "s/^updated:.*$/updated: $today/" "$sprint_status_file"
|
|
752
|
+
else
|
|
753
|
+
sed -i "s/^# updated:.*$/# updated: $today/" "$sprint_status_file"
|
|
754
|
+
sed -i "s/^updated:.*$/updated: $today/" "$sprint_status_file"
|
|
755
|
+
fi
|
|
756
|
+
|
|
757
|
+
return 0
|
|
758
|
+
else
|
|
759
|
+
echo "❌ Failed to update status"
|
|
760
|
+
return 1
|
|
761
|
+
fi
|
|
762
|
+
}
|
|
763
|
+
|
|
764
|
+
################################################################################
|
|
765
|
+
# Auto-Commit and PR Functions
|
|
766
|
+
################################################################################
|
|
767
|
+
|
|
768
|
+
# Auto-commit changes after development
|
|
769
|
+
auto_commit_changes() {
|
|
770
|
+
local story_key="$1"
|
|
771
|
+
local story_file="$STORIES_DIR/${story_key}.md"
|
|
772
|
+
|
|
773
|
+
echo "▶ Auto-committing changes..."
|
|
774
|
+
|
|
775
|
+
# Check if there are changes to commit
|
|
776
|
+
cd "$PROJECT_ROOT" || return 1
|
|
777
|
+
|
|
778
|
+
if ! git diff --quiet || ! git diff --cached --quiet || [[ -n $(git ls-files --others --exclude-standard) ]]; then
|
|
779
|
+
echo "📝 Detected changes to commit"
|
|
780
|
+
|
|
781
|
+
# Extract story title from story file
|
|
782
|
+
local story_title=""
|
|
783
|
+
if [[ -f "$story_file" ]]; then
|
|
784
|
+
story_title=$(grep -m 1 "^# " "$story_file" | sed 's/^# //' || echo "$story_key")
|
|
785
|
+
else
|
|
786
|
+
story_title="$story_key"
|
|
787
|
+
fi
|
|
788
|
+
|
|
789
|
+
# Stage all changes
|
|
790
|
+
git add -A
|
|
791
|
+
|
|
792
|
+
# Create commit message
|
|
793
|
+
local commit_msg="feat: $story_title
|
|
794
|
+
|
|
795
|
+
Automated implementation via Claude Code CLI
|
|
796
|
+
|
|
797
|
+
Story: $story_key
|
|
798
|
+
|
|
799
|
+
🤖 Generated with [Claude Code](https://claude.com/claude-code)
|
|
800
|
+
|
|
801
|
+
Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>"
|
|
802
|
+
|
|
803
|
+
# Commit
|
|
804
|
+
git commit -m "$commit_msg"
|
|
805
|
+
|
|
806
|
+
if [[ $? -eq 0 ]]; then
|
|
807
|
+
echo "✅ Changes committed successfully"
|
|
808
|
+
echo "📋 Commit: $(git rev-parse --short HEAD)"
|
|
809
|
+
return 0
|
|
810
|
+
else
|
|
811
|
+
echo "⚠️ Commit failed or no changes to commit"
|
|
812
|
+
return 1
|
|
813
|
+
fi
|
|
814
|
+
else
|
|
815
|
+
echo "ℹ️ No changes to commit"
|
|
816
|
+
return 0
|
|
817
|
+
fi
|
|
818
|
+
}
|
|
819
|
+
|
|
820
|
+
# Create pull request after commit
|
|
821
|
+
auto_create_pr() {
|
|
822
|
+
local story_key="$1"
|
|
823
|
+
local story_file="$STORIES_DIR/${story_key}.md"
|
|
824
|
+
local branch_name="feature/$story_key"
|
|
825
|
+
|
|
826
|
+
echo "▶ Creating pull request..."
|
|
827
|
+
|
|
828
|
+
cd "$PROJECT_ROOT" || return 1
|
|
829
|
+
|
|
830
|
+
# Check if gh CLI is available
|
|
831
|
+
if ! command -v gh &> /dev/null; then
|
|
832
|
+
echo "⚠️ GitHub CLI (gh) not found. Skipping PR creation."
|
|
833
|
+
echo " Install with: brew install gh"
|
|
834
|
+
return 1
|
|
835
|
+
fi
|
|
836
|
+
|
|
837
|
+
# Get current branch
|
|
838
|
+
local current_branch=$(git rev-parse --abbrev-ref HEAD)
|
|
839
|
+
|
|
840
|
+
# Extract story title and summary
|
|
841
|
+
local pr_title=""
|
|
842
|
+
local pr_body=""
|
|
843
|
+
|
|
844
|
+
if [[ -f "$story_file" ]]; then
|
|
845
|
+
pr_title=$(grep -m 1 "^# " "$story_file" | sed 's/^# //' || echo "$story_key")
|
|
846
|
+
|
|
847
|
+
# Build PR body from story file
|
|
848
|
+
pr_body="## Story: $story_key
|
|
849
|
+
|
|
850
|
+
$(cat "$story_file")
|
|
851
|
+
|
|
852
|
+
---
|
|
853
|
+
|
|
854
|
+
🤖 Auto-generated via Claude Code CLI automation"
|
|
855
|
+
else
|
|
856
|
+
pr_title="$story_key implementation"
|
|
857
|
+
pr_body="Story: $story_key
|
|
858
|
+
|
|
859
|
+
🤖 Auto-generated via Claude Code CLI automation"
|
|
860
|
+
fi
|
|
861
|
+
|
|
862
|
+
# Create PR
|
|
863
|
+
gh pr create \
|
|
864
|
+
--title "$pr_title" \
|
|
865
|
+
--body "$pr_body" \
|
|
866
|
+
--base main \
|
|
867
|
+
--head "$current_branch" 2>&1
|
|
868
|
+
|
|
869
|
+
if [[ $? -eq 0 ]]; then
|
|
870
|
+
echo "✅ Pull request created"
|
|
871
|
+
return 0
|
|
872
|
+
else
|
|
873
|
+
echo "⚠️ PR creation failed. You can create it manually with:"
|
|
874
|
+
echo " gh pr create --title \"$pr_title\" --base main"
|
|
875
|
+
return 1
|
|
876
|
+
fi
|
|
877
|
+
}
|
|
878
|
+
|
|
879
|
+
run_full_pipeline() {
|
|
880
|
+
local story_key="$1"
|
|
881
|
+
local auto_commit="${AUTO_COMMIT:-true}" # Default to true
|
|
882
|
+
local auto_pr="${AUTO_PR:-false}" # Default to false
|
|
883
|
+
|
|
884
|
+
echo ""
|
|
885
|
+
echo "═══════════════════════════════════════════════════════════════"
|
|
886
|
+
echo " AUTOMATED STORY PIPELINE: $story_key"
|
|
887
|
+
echo "═══════════════════════════════════════════════════════════════"
|
|
888
|
+
echo ""
|
|
889
|
+
|
|
890
|
+
# Phase 1: Create context if needed
|
|
891
|
+
local context_file="$STORIES_DIR/${story_key}.context.xml"
|
|
892
|
+
if [[ ! -f "$context_file" ]]; then
|
|
893
|
+
echo "▶ Phase 1: Creating story context..."
|
|
894
|
+
invoke_sm_story_context "$story_key"
|
|
895
|
+
if [[ $? -ne 0 ]]; then
|
|
896
|
+
echo "❌ Context creation failed"
|
|
897
|
+
return 1
|
|
898
|
+
fi
|
|
899
|
+
echo "✅ Context created"
|
|
900
|
+
echo ""
|
|
901
|
+
else
|
|
902
|
+
echo "✓ Context already exists, skipping..."
|
|
903
|
+
echo ""
|
|
904
|
+
fi
|
|
905
|
+
|
|
906
|
+
# Phase 2: Development
|
|
907
|
+
echo "▶ Phase 2: Implementing story..."
|
|
908
|
+
invoke_dev_story "$story_key"
|
|
909
|
+
if [[ $? -ne 0 ]]; then
|
|
910
|
+
echo "❌ Development failed"
|
|
911
|
+
return 1
|
|
912
|
+
fi
|
|
913
|
+
echo "✅ Development complete"
|
|
914
|
+
echo ""
|
|
915
|
+
|
|
916
|
+
# Phase 2.5: Update status to 'review'
|
|
917
|
+
update_story_status "$story_key" "review"
|
|
918
|
+
echo ""
|
|
919
|
+
|
|
920
|
+
# Phase 2.6: Auto-commit (if enabled)
|
|
921
|
+
if [[ "$auto_commit" == "true" ]]; then
|
|
922
|
+
auto_commit_changes "$story_key"
|
|
923
|
+
echo ""
|
|
924
|
+
fi
|
|
925
|
+
|
|
926
|
+
# Phase 2.7: Auto-PR (if enabled)
|
|
927
|
+
if [[ "$auto_pr" == "true" ]]; then
|
|
928
|
+
auto_create_pr "$story_key"
|
|
929
|
+
echo ""
|
|
930
|
+
fi
|
|
931
|
+
|
|
932
|
+
# Phase 3: Code review
|
|
933
|
+
echo "▶ Phase 3: Code review..."
|
|
934
|
+
invoke_sm_code_review "$story_key"
|
|
935
|
+
if [[ $? -ne 0 ]]; then
|
|
936
|
+
echo "❌ Code review failed"
|
|
937
|
+
return 1
|
|
938
|
+
fi
|
|
939
|
+
echo "✅ Code review complete"
|
|
940
|
+
echo ""
|
|
941
|
+
|
|
942
|
+
# Phase 4: Update status to 'done' (if review passed)
|
|
943
|
+
update_story_status "$story_key" "done"
|
|
944
|
+
echo ""
|
|
945
|
+
|
|
946
|
+
echo "═══════════════════════════════════════════════════════════════"
|
|
947
|
+
echo " PIPELINE COMPLETE"
|
|
948
|
+
echo "═══════════════════════════════════════════════════════════════"
|
|
949
|
+
|
|
950
|
+
return 0
|
|
951
|
+
}
|
|
952
|
+
|
|
953
|
+
################################################################################
|
|
954
|
+
# BROWNFIELD WORKFLOWS - Bug fixes, refactoring, investigations, maintenance
|
|
955
|
+
################################################################################
|
|
956
|
+
|
|
957
|
+
invoke_bugfix() {
|
|
958
|
+
local bug_id="$1"
|
|
959
|
+
local bug_file="$STORIES_DIR/bugs/${bug_id}.md"
|
|
960
|
+
local log_file="$LOGS_DIR/${bug_id}-bugfix.log"
|
|
961
|
+
local model="${CLAUDE_MODEL_DEV:-opus}"
|
|
962
|
+
|
|
963
|
+
# Show persona switch
|
|
964
|
+
print_persona_banner "MAINTAINER" "Bug Investigation & Fix" "\033[1;31m" "$model"
|
|
965
|
+
|
|
966
|
+
echo "▶ Investigating and fixing bug: $bug_id"
|
|
967
|
+
|
|
968
|
+
# Build prompt based on whether bug file exists
|
|
969
|
+
local prompt=""
|
|
970
|
+
if [[ -f "$bug_file" ]]; then
|
|
971
|
+
local bug_content=$(cat "$bug_file")
|
|
972
|
+
prompt="FIX THIS BUG.
|
|
973
|
+
|
|
974
|
+
## Bug Report
|
|
975
|
+
$bug_content
|
|
976
|
+
|
|
977
|
+
## Instructions
|
|
978
|
+
1. First, understand the bug by reading the report carefully
|
|
979
|
+
2. Explore the codebase to find the root cause
|
|
980
|
+
3. Identify all affected files
|
|
981
|
+
4. Implement the fix with minimal changes
|
|
982
|
+
5. Add tests to prevent regression
|
|
983
|
+
6. Run existing tests to ensure no regressions
|
|
984
|
+
|
|
985
|
+
DO NOT over-engineer. Make the minimal change needed to fix the bug.
|
|
986
|
+
After fixing, create a brief summary at: $STORIES_DIR/bugs/${bug_id}.fix-summary.md"
|
|
987
|
+
else
|
|
988
|
+
prompt="INVESTIGATE AND FIX BUG: $bug_id
|
|
989
|
+
|
|
990
|
+
## Instructions
|
|
991
|
+
1. Search the codebase for code related to: $bug_id
|
|
992
|
+
2. Identify potential issues based on the bug description
|
|
993
|
+
3. Explore related code paths and error handling
|
|
994
|
+
4. Implement a fix with minimal changes
|
|
995
|
+
5. Add tests to prevent regression
|
|
996
|
+
6. Run existing tests to ensure no regressions
|
|
997
|
+
|
|
998
|
+
Bug ID/Description: $bug_id
|
|
999
|
+
|
|
1000
|
+
After investigating, create:
|
|
1001
|
+
- $STORIES_DIR/bugs/${bug_id}.md (bug report if not exists)
|
|
1002
|
+
- $STORIES_DIR/bugs/${bug_id}.fix-summary.md (fix summary)"
|
|
1003
|
+
fi
|
|
1004
|
+
|
|
1005
|
+
# Ensure bugs directory exists
|
|
1006
|
+
mkdir -p "$STORIES_DIR/bugs"
|
|
1007
|
+
|
|
1008
|
+
# Create symlink to current.log for monitoring
|
|
1009
|
+
ln -sf "$log_file" "$LOGS_DIR/current.log"
|
|
1010
|
+
|
|
1011
|
+
(
|
|
1012
|
+
cd "$PROJECT_ROOT" || exit 1
|
|
1013
|
+
echo "$prompt" | $CLAUDE_CLI -p \
|
|
1014
|
+
--model "$model" \
|
|
1015
|
+
$(get_permission_flags) \
|
|
1016
|
+
--append-system-prompt "$(cat "$AGENTS_DIR/maintainer.md" 2>/dev/null || cat "$AGENTS_DIR/dev.md" 2>/dev/null)" \
|
|
1017
|
+
--tools "Read,Write,Edit,Grep,Glob,Bash" \
|
|
1018
|
+
--max-budget-usd 10.00
|
|
1019
|
+
) 2>&1 | tee "$log_file"
|
|
1020
|
+
|
|
1021
|
+
return ${PIPESTATUS[0]}
|
|
1022
|
+
}
|
|
1023
|
+
|
|
1024
|
+
invoke_refactor() {
|
|
1025
|
+
local refactor_id="$1"
|
|
1026
|
+
local refactor_file="$STORIES_DIR/refactors/${refactor_id}.md"
|
|
1027
|
+
local log_file="$LOGS_DIR/${refactor_id}-refactor.log"
|
|
1028
|
+
local model="${CLAUDE_MODEL_DEV:-opus}"
|
|
1029
|
+
|
|
1030
|
+
# Show persona switch
|
|
1031
|
+
print_persona_banner "MAINTAINER" "Code Refactoring & Improvement" "\033[1;35m" "$model"
|
|
1032
|
+
|
|
1033
|
+
echo "▶ Refactoring: $refactor_id"
|
|
1034
|
+
|
|
1035
|
+
local prompt=""
|
|
1036
|
+
if [[ -f "$refactor_file" ]]; then
|
|
1037
|
+
local refactor_content=$(cat "$refactor_file")
|
|
1038
|
+
prompt="REFACTOR THIS CODE.
|
|
1039
|
+
|
|
1040
|
+
## Refactoring Specification
|
|
1041
|
+
$refactor_content
|
|
1042
|
+
|
|
1043
|
+
## Instructions
|
|
1044
|
+
1. Read and understand the refactoring goals
|
|
1045
|
+
2. Analyze the current code structure
|
|
1046
|
+
3. Plan the refactoring steps (smallest possible changes)
|
|
1047
|
+
4. Implement changes incrementally
|
|
1048
|
+
5. Run tests after each significant change
|
|
1049
|
+
6. Ensure all tests pass before completion
|
|
1050
|
+
|
|
1051
|
+
IMPORTANT: Make changes incrementally. Ensure tests pass between changes.
|
|
1052
|
+
Create a summary at: $STORIES_DIR/refactors/${refactor_id}.summary.md"
|
|
1053
|
+
else
|
|
1054
|
+
prompt="REFACTOR: $refactor_id
|
|
1055
|
+
|
|
1056
|
+
## Instructions
|
|
1057
|
+
1. Search the codebase for code related to: $refactor_id
|
|
1058
|
+
2. Analyze the current implementation
|
|
1059
|
+
3. Identify improvement opportunities (readability, performance, maintainability)
|
|
1060
|
+
4. Plan incremental refactoring steps
|
|
1061
|
+
5. Implement changes one at a time
|
|
1062
|
+
6. Run tests after each change
|
|
1063
|
+
|
|
1064
|
+
Target: $refactor_id
|
|
1065
|
+
|
|
1066
|
+
Create:
|
|
1067
|
+
- $STORIES_DIR/refactors/${refactor_id}.md (refactoring plan)
|
|
1068
|
+
- $STORIES_DIR/refactors/${refactor_id}.summary.md (what was changed)"
|
|
1069
|
+
fi
|
|
1070
|
+
|
|
1071
|
+
# Ensure refactors directory exists
|
|
1072
|
+
mkdir -p "$STORIES_DIR/refactors"
|
|
1073
|
+
|
|
1074
|
+
ln -sf "$log_file" "$LOGS_DIR/current.log"
|
|
1075
|
+
|
|
1076
|
+
(
|
|
1077
|
+
cd "$PROJECT_ROOT" || exit 1
|
|
1078
|
+
echo "$prompt" | $CLAUDE_CLI -p \
|
|
1079
|
+
--model "$model" \
|
|
1080
|
+
$(get_permission_flags) \
|
|
1081
|
+
--append-system-prompt "$(cat "$AGENTS_DIR/maintainer.md" 2>/dev/null || cat "$AGENTS_DIR/dev.md" 2>/dev/null)" \
|
|
1082
|
+
--tools "Read,Write,Edit,Grep,Glob,Bash" \
|
|
1083
|
+
--max-budget-usd 12.00
|
|
1084
|
+
) 2>&1 | tee "$log_file"
|
|
1085
|
+
|
|
1086
|
+
return ${PIPESTATUS[0]}
|
|
1087
|
+
}
|
|
1088
|
+
|
|
1089
|
+
invoke_investigate() {
|
|
1090
|
+
local topic="$1"
|
|
1091
|
+
local output_file="$STORIES_DIR/investigations/${topic}.md"
|
|
1092
|
+
local log_file="$LOGS_DIR/${topic}-investigate.log"
|
|
1093
|
+
local model="${CLAUDE_MODEL_PLANNING:-sonnet}" # Use Sonnet for investigation (read-heavy)
|
|
1094
|
+
|
|
1095
|
+
# Show persona switch
|
|
1096
|
+
print_persona_banner "MAINTAINER" "Codebase Investigation & Analysis" "\033[1;36m" "$model"
|
|
1097
|
+
|
|
1098
|
+
echo "▶ Investigating: $topic"
|
|
1099
|
+
|
|
1100
|
+
local prompt="INVESTIGATE AND DOCUMENT: $topic
|
|
1101
|
+
|
|
1102
|
+
## Instructions
|
|
1103
|
+
1. Explore the codebase thoroughly to understand: $topic
|
|
1104
|
+
2. Trace code paths, data flows, and dependencies
|
|
1105
|
+
3. Document what you find in a comprehensive report
|
|
1106
|
+
4. Include:
|
|
1107
|
+
- How the feature/component works
|
|
1108
|
+
- Key files and their responsibilities
|
|
1109
|
+
- Data flows and state management
|
|
1110
|
+
- External dependencies
|
|
1111
|
+
- Potential issues or technical debt
|
|
1112
|
+
- Recommendations for improvements
|
|
1113
|
+
|
|
1114
|
+
Create a detailed investigation report at: $output_file
|
|
1115
|
+
|
|
1116
|
+
DO NOT make any code changes. This is a read-only investigation."
|
|
1117
|
+
|
|
1118
|
+
# Ensure investigations directory exists
|
|
1119
|
+
mkdir -p "$STORIES_DIR/investigations"
|
|
1120
|
+
|
|
1121
|
+
ln -sf "$log_file" "$LOGS_DIR/current.log"
|
|
1122
|
+
|
|
1123
|
+
(
|
|
1124
|
+
cd "$PROJECT_ROOT" || exit 1
|
|
1125
|
+
echo "$prompt" | $CLAUDE_CLI -p \
|
|
1126
|
+
--model "$model" \
|
|
1127
|
+
$(get_permission_flags) \
|
|
1128
|
+
--append-system-prompt "$(cat "$AGENTS_DIR/maintainer.md" 2>/dev/null || cat "$AGENTS_DIR/architect.md" 2>/dev/null)" \
|
|
1129
|
+
--tools "Read,Grep,Glob" \
|
|
1130
|
+
--max-budget-usd 5.00
|
|
1131
|
+
) 2>&1 | tee "$log_file"
|
|
1132
|
+
|
|
1133
|
+
return ${PIPESTATUS[0]}
|
|
1134
|
+
}
|
|
1135
|
+
|
|
1136
|
+
invoke_quickfix() {
|
|
1137
|
+
local description="$1"
|
|
1138
|
+
local log_file="$LOGS_DIR/quickfix-$(date +%Y%m%d-%H%M%S).log"
|
|
1139
|
+
local model="${CLAUDE_MODEL_PLANNING:-sonnet}" # Use Sonnet for quick fixes
|
|
1140
|
+
|
|
1141
|
+
# Show persona switch
|
|
1142
|
+
print_persona_banner "MAINTAINER" "Quick Fix" "\033[1;33m" "$model"
|
|
1143
|
+
|
|
1144
|
+
echo "▶ Quick fix: $description"
|
|
1145
|
+
|
|
1146
|
+
local prompt="QUICK FIX: $description
|
|
1147
|
+
|
|
1148
|
+
## Instructions
|
|
1149
|
+
1. Make the requested change with minimal modifications
|
|
1150
|
+
2. Only change what is absolutely necessary
|
|
1151
|
+
3. Run tests if applicable
|
|
1152
|
+
4. Do not refactor unrelated code
|
|
1153
|
+
5. Do not add unnecessary comments or documentation
|
|
1154
|
+
|
|
1155
|
+
This is a quick, focused change. Be efficient."
|
|
1156
|
+
|
|
1157
|
+
ln -sf "$log_file" "$LOGS_DIR/current.log"
|
|
1158
|
+
|
|
1159
|
+
(
|
|
1160
|
+
cd "$PROJECT_ROOT" || exit 1
|
|
1161
|
+
echo "$prompt" | $CLAUDE_CLI -p \
|
|
1162
|
+
--model "$model" \
|
|
1163
|
+
$(get_permission_flags) \
|
|
1164
|
+
--append-system-prompt "$(cat "$AGENTS_DIR/maintainer.md" 2>/dev/null || cat "$AGENTS_DIR/dev.md" 2>/dev/null)" \
|
|
1165
|
+
--tools "Read,Write,Edit,Grep,Glob,Bash" \
|
|
1166
|
+
--max-budget-usd 3.00
|
|
1167
|
+
) 2>&1 | tee "$log_file"
|
|
1168
|
+
|
|
1169
|
+
return ${PIPESTATUS[0]}
|
|
1170
|
+
}
|
|
1171
|
+
|
|
1172
|
+
invoke_migrate() {
|
|
1173
|
+
local migration_id="$1"
|
|
1174
|
+
local migration_file="$STORIES_DIR/migrations/${migration_id}.md"
|
|
1175
|
+
local log_file="$LOGS_DIR/${migration_id}-migrate.log"
|
|
1176
|
+
local model="${CLAUDE_MODEL_DEV:-opus}"
|
|
1177
|
+
|
|
1178
|
+
# Show persona switch
|
|
1179
|
+
print_persona_banner "MAINTAINER" "Migration & Upgrade" "\033[1;34m" "$model"
|
|
1180
|
+
|
|
1181
|
+
echo "▶ Running migration: $migration_id"
|
|
1182
|
+
|
|
1183
|
+
local prompt=""
|
|
1184
|
+
if [[ -f "$migration_file" ]]; then
|
|
1185
|
+
local migration_content=$(cat "$migration_file")
|
|
1186
|
+
prompt="EXECUTE THIS MIGRATION.
|
|
1187
|
+
|
|
1188
|
+
## Migration Specification
|
|
1189
|
+
$migration_content
|
|
1190
|
+
|
|
1191
|
+
## Instructions
|
|
1192
|
+
1. Read the migration plan carefully
|
|
1193
|
+
2. Back up any critical data/configuration if needed
|
|
1194
|
+
3. Execute the migration steps in order
|
|
1195
|
+
4. Run tests after each major step
|
|
1196
|
+
5. Document any issues encountered
|
|
1197
|
+
6. Verify the migration is complete
|
|
1198
|
+
|
|
1199
|
+
Create a migration log at: $STORIES_DIR/migrations/${migration_id}.log.md"
|
|
1200
|
+
else
|
|
1201
|
+
prompt="PLAN AND EXECUTE MIGRATION: $migration_id
|
|
1202
|
+
|
|
1203
|
+
## Instructions
|
|
1204
|
+
1. Analyze what needs to be migrated based on: $migration_id
|
|
1205
|
+
2. Create a migration plan
|
|
1206
|
+
3. Execute the migration with careful testing
|
|
1207
|
+
4. Document all changes made
|
|
1208
|
+
|
|
1209
|
+
Create:
|
|
1210
|
+
- $STORIES_DIR/migrations/${migration_id}.md (migration plan)
|
|
1211
|
+
- $STORIES_DIR/migrations/${migration_id}.log.md (execution log)"
|
|
1212
|
+
fi
|
|
1213
|
+
|
|
1214
|
+
# Ensure migrations directory exists
|
|
1215
|
+
mkdir -p "$STORIES_DIR/migrations"
|
|
1216
|
+
|
|
1217
|
+
ln -sf "$log_file" "$LOGS_DIR/current.log"
|
|
1218
|
+
|
|
1219
|
+
(
|
|
1220
|
+
cd "$PROJECT_ROOT" || exit 1
|
|
1221
|
+
echo "$prompt" | $CLAUDE_CLI -p \
|
|
1222
|
+
--model "$model" \
|
|
1223
|
+
$(get_permission_flags) \
|
|
1224
|
+
--append-system-prompt "$(cat "$AGENTS_DIR/maintainer.md" 2>/dev/null || cat "$AGENTS_DIR/architect.md" 2>/dev/null)" \
|
|
1225
|
+
--tools "Read,Write,Edit,Grep,Glob,Bash" \
|
|
1226
|
+
--max-budget-usd 15.00
|
|
1227
|
+
) 2>&1 | tee "$log_file"
|
|
1228
|
+
|
|
1229
|
+
return ${PIPESTATUS[0]}
|
|
1230
|
+
}
|
|
1231
|
+
|
|
1232
|
+
invoke_tech_debt() {
|
|
1233
|
+
local debt_id="$1"
|
|
1234
|
+
local debt_file="$STORIES_DIR/tech-debt/${debt_id}.md"
|
|
1235
|
+
local log_file="$LOGS_DIR/${debt_id}-tech-debt.log"
|
|
1236
|
+
local model="${CLAUDE_MODEL_DEV:-opus}"
|
|
1237
|
+
|
|
1238
|
+
# Show persona switch
|
|
1239
|
+
print_persona_banner "MAINTAINER" "Technical Debt Resolution" "\033[1;35m" "$model"
|
|
1240
|
+
|
|
1241
|
+
echo "▶ Resolving technical debt: $debt_id"
|
|
1242
|
+
|
|
1243
|
+
local prompt=""
|
|
1244
|
+
if [[ -f "$debt_file" ]]; then
|
|
1245
|
+
local debt_content=$(cat "$debt_file")
|
|
1246
|
+
prompt="RESOLVE THIS TECHNICAL DEBT.
|
|
1247
|
+
|
|
1248
|
+
## Technical Debt Item
|
|
1249
|
+
$debt_content
|
|
1250
|
+
|
|
1251
|
+
## Instructions
|
|
1252
|
+
1. Understand the scope of the technical debt
|
|
1253
|
+
2. Identify all affected areas
|
|
1254
|
+
3. Plan incremental improvements
|
|
1255
|
+
4. Implement fixes while maintaining backwards compatibility
|
|
1256
|
+
5. Add tests where missing
|
|
1257
|
+
6. Run all tests to ensure no regressions
|
|
1258
|
+
|
|
1259
|
+
Document resolution at: $STORIES_DIR/tech-debt/${debt_id}.resolved.md"
|
|
1260
|
+
else
|
|
1261
|
+
prompt="IDENTIFY AND RESOLVE TECHNICAL DEBT: $debt_id
|
|
1262
|
+
|
|
1263
|
+
## Instructions
|
|
1264
|
+
1. Search for code related to: $debt_id
|
|
1265
|
+
2. Identify technical debt (poor patterns, missing tests, outdated code)
|
|
1266
|
+
3. Prioritize fixes by impact
|
|
1267
|
+
4. Implement improvements incrementally
|
|
1268
|
+
5. Run tests after each change
|
|
1269
|
+
|
|
1270
|
+
Create:
|
|
1271
|
+
- $STORIES_DIR/tech-debt/${debt_id}.md (debt identification)
|
|
1272
|
+
- $STORIES_DIR/tech-debt/${debt_id}.resolved.md (resolution summary)"
|
|
1273
|
+
fi
|
|
1274
|
+
|
|
1275
|
+
# Ensure tech-debt directory exists
|
|
1276
|
+
mkdir -p "$STORIES_DIR/tech-debt"
|
|
1277
|
+
|
|
1278
|
+
ln -sf "$log_file" "$LOGS_DIR/current.log"
|
|
1279
|
+
|
|
1280
|
+
(
|
|
1281
|
+
cd "$PROJECT_ROOT" || exit 1
|
|
1282
|
+
echo "$prompt" | $CLAUDE_CLI -p \
|
|
1283
|
+
--model "$model" \
|
|
1284
|
+
$(get_permission_flags) \
|
|
1285
|
+
--append-system-prompt "$(cat "$AGENTS_DIR/maintainer.md" 2>/dev/null || cat "$AGENTS_DIR/dev.md" 2>/dev/null)" \
|
|
1286
|
+
--tools "Read,Write,Edit,Grep,Glob,Bash" \
|
|
1287
|
+
--max-budget-usd 12.00
|
|
1288
|
+
) 2>&1 | tee "$log_file"
|
|
1289
|
+
|
|
1290
|
+
return ${PIPESTATUS[0]}
|
|
1291
|
+
}
|
|
1292
|
+
|
|
1293
|
+
# Functions are available when this file is sourced
|