@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,467 @@
|
|
|
1
|
+
#!/usr/bin/env bash
|
|
2
|
+
################################################################################
|
|
3
|
+
# RUN-STORY - Simple Automated Story Implementation
|
|
4
|
+
#
|
|
5
|
+
# This script invokes Claude Code to implement a story automatically.
|
|
6
|
+
#
|
|
7
|
+
# Usage:
|
|
8
|
+
# ./run-story.sh <story-key> # Full pipeline (context + dev + review)
|
|
9
|
+
# ./run-story.sh <story-key> --develop # Development only
|
|
10
|
+
# ./run-story.sh <story-key> --review # Review only
|
|
11
|
+
#
|
|
12
|
+
# Examples:
|
|
13
|
+
# ./run-story.sh 3-5 # Run full automation for story 3-5
|
|
14
|
+
# ./run-story.sh 3-5 --develop # Just run development phase
|
|
15
|
+
#
|
|
16
|
+
################################################################################
|
|
17
|
+
|
|
18
|
+
set -e
|
|
19
|
+
|
|
20
|
+
# Colors
|
|
21
|
+
RED='\033[0;31m'
|
|
22
|
+
GREEN='\033[0;32m'
|
|
23
|
+
YELLOW='\033[1;33m'
|
|
24
|
+
BLUE='\033[0;34m'
|
|
25
|
+
CYAN='\033[0;36m'
|
|
26
|
+
NC='\033[0m'
|
|
27
|
+
|
|
28
|
+
SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)"
|
|
29
|
+
PROJECT_ROOT="$(cd "$SCRIPT_DIR/.." && pwd)"
|
|
30
|
+
SPRINT_STATUS="$PROJECT_ROOT/docs/sprint-status.yaml"
|
|
31
|
+
|
|
32
|
+
# Load configuration (with existence check)
|
|
33
|
+
CONFIG_FILE="$PROJECT_ROOT/.automation/config.sh"
|
|
34
|
+
if [[ -f "$CONFIG_FILE" ]]; then
|
|
35
|
+
source "$CONFIG_FILE"
|
|
36
|
+
else
|
|
37
|
+
echo -e "${YELLOW}Warning: Configuration file not found at $CONFIG_FILE${NC}"
|
|
38
|
+
echo -e "${YELLOW}Using default settings. Run init-project-workflow.sh to set up configuration.${NC}"
|
|
39
|
+
# Set defaults
|
|
40
|
+
AUTO_COMMIT=${AUTO_COMMIT:-false}
|
|
41
|
+
DEFAULT_MODEL=${DEFAULT_MODEL:-sonnet}
|
|
42
|
+
fi
|
|
43
|
+
|
|
44
|
+
# Load CLI library (with existence check)
|
|
45
|
+
CLI_LIB="$SCRIPT_DIR/lib/claude-cli.sh"
|
|
46
|
+
if [[ -f "$CLI_LIB" ]]; then
|
|
47
|
+
source "$CLI_LIB"
|
|
48
|
+
else
|
|
49
|
+
echo -e "${RED}Error: Required library not found at $CLI_LIB${NC}"
|
|
50
|
+
echo -e "${RED}Please ensure the Devflow installation is complete.${NC}"
|
|
51
|
+
exit 1
|
|
52
|
+
fi
|
|
53
|
+
|
|
54
|
+
# Expand abbreviated story key (e.g., "3-5" -> "3-5-build-goal-detail-screen-with-edit-delete")
|
|
55
|
+
expand_story_key() {
|
|
56
|
+
local input_key="$1"
|
|
57
|
+
|
|
58
|
+
# If already a full key (has more than two dashes), return as-is
|
|
59
|
+
if [[ "$input_key" =~ ^[0-9]+-[0-9]+-[a-z] ]]; then
|
|
60
|
+
echo "$input_key"
|
|
61
|
+
return
|
|
62
|
+
fi
|
|
63
|
+
|
|
64
|
+
# If abbreviated (e.g., "3-5"), look up full key
|
|
65
|
+
if [[ "$input_key" =~ ^[0-9]+-[0-9]+$ ]]; then
|
|
66
|
+
local full_key=$(grep -E "^ $input_key-[a-z]" "$SPRINT_STATUS" 2>/dev/null | head -1 | awk '{print $1}' | sed 's/://' || echo "")
|
|
67
|
+
|
|
68
|
+
if [[ -n "$full_key" ]]; then
|
|
69
|
+
echo "$full_key"
|
|
70
|
+
return
|
|
71
|
+
fi
|
|
72
|
+
fi
|
|
73
|
+
|
|
74
|
+
echo "$input_key"
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
print_header() {
|
|
78
|
+
echo ""
|
|
79
|
+
echo -e "${CYAN}═══════════════════════════════════════════════════════════════${NC}"
|
|
80
|
+
echo -e "${CYAN} AUTOMATED STORY RUNNER${NC}"
|
|
81
|
+
echo -e "${CYAN}═══════════════════════════════════════════════════════════════${NC}"
|
|
82
|
+
echo ""
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
print_usage() {
|
|
86
|
+
echo "Usage: ./run-story.sh <key> [options]"
|
|
87
|
+
echo ""
|
|
88
|
+
echo "GREENFIELD MODES (New Features):"
|
|
89
|
+
echo " (default) Run full pipeline (context + dev + review + commit)"
|
|
90
|
+
echo " --develop Run development phase only"
|
|
91
|
+
echo " --review Run review phase only"
|
|
92
|
+
echo " --adversarial Run adversarial review (critical, finds problems)"
|
|
93
|
+
echo " --context Create story context only"
|
|
94
|
+
echo ""
|
|
95
|
+
echo "COLLABORATIVE MODES (Multi-Agent):"
|
|
96
|
+
echo " --swarm Multi-agent debate/consensus mode"
|
|
97
|
+
echo " --pair DEV + REVIEWER pair programming"
|
|
98
|
+
echo " --auto-route Auto-select best agents for the task"
|
|
99
|
+
echo ""
|
|
100
|
+
echo "BROWNFIELD MODES (Existing Codebase):"
|
|
101
|
+
echo " --bugfix Fix a bug (key = bug ID or description)"
|
|
102
|
+
echo " --refactor Refactor code (key = refactor target or ID)"
|
|
103
|
+
echo " --investigate Investigate codebase (key = topic to explore)"
|
|
104
|
+
echo " --quickfix Quick, minimal change (key = description)"
|
|
105
|
+
echo " --migrate Run a migration (key = migration ID)"
|
|
106
|
+
echo " --tech-debt Resolve technical debt (key = debt ID)"
|
|
107
|
+
echo ""
|
|
108
|
+
echo "OPTIONS:"
|
|
109
|
+
echo " --no-commit Disable auto-commit after changes"
|
|
110
|
+
echo " --with-pr Enable auto-PR creation (requires gh CLI)"
|
|
111
|
+
echo " --model <name> Use specific Claude model (sonnet|opus|haiku)"
|
|
112
|
+
echo " --agents <list> Comma-separated agent list (for swarm mode)"
|
|
113
|
+
echo " --max-iter <n> Max iterations for swarm/pair modes (default: 3)"
|
|
114
|
+
echo ""
|
|
115
|
+
echo "Environment Variables:"
|
|
116
|
+
echo " AUTO_COMMIT=true|false Enable/disable auto-commit (default: true)"
|
|
117
|
+
echo " AUTO_PR=true|false Enable/disable auto-PR (default: false)"
|
|
118
|
+
echo " CLAUDE_MODEL=<name> Set Claude model (default: sonnet)"
|
|
119
|
+
echo ""
|
|
120
|
+
echo "GREENFIELD EXAMPLES:"
|
|
121
|
+
echo " ./run-story.sh 3-5 # Full story pipeline"
|
|
122
|
+
echo " ./run-story.sh 3-5 --develop # Development only"
|
|
123
|
+
echo " ./run-story.sh 3-5 --model opus # Use Claude Opus"
|
|
124
|
+
echo ""
|
|
125
|
+
echo "COLLABORATIVE EXAMPLES:"
|
|
126
|
+
echo " ./run-story.sh 3-5 --swarm # Multi-agent debate"
|
|
127
|
+
echo " ./run-story.sh 3-5 --pair # DEV+REVIEWER pair"
|
|
128
|
+
echo " ./run-story.sh 3-5 --swarm --agents DEV,REVIEWER # Custom agents"
|
|
129
|
+
echo " ./run-story.sh 'fix auth bug' --auto-route # Auto-select agents"
|
|
130
|
+
echo ""
|
|
131
|
+
echo "BROWNFIELD EXAMPLES:"
|
|
132
|
+
echo " ./run-story.sh login-crash --bugfix # Fix bug"
|
|
133
|
+
echo " ./run-story.sh auth-service --refactor # Refactor code"
|
|
134
|
+
echo " ./run-story.sh payment-flow --investigate # Investigate code"
|
|
135
|
+
echo " ./run-story.sh 'fix typo in header' --quickfix # Quick fix"
|
|
136
|
+
echo " ./run-story.sh react-18 --migrate # Run migration"
|
|
137
|
+
echo " ./run-story.sh legacy-api --tech-debt # Fix tech debt"
|
|
138
|
+
echo ""
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
main() {
|
|
142
|
+
if [[ $# -eq 0 ]]; then
|
|
143
|
+
print_usage
|
|
144
|
+
exit 1
|
|
145
|
+
fi
|
|
146
|
+
|
|
147
|
+
# Expand abbreviated story key
|
|
148
|
+
local story_key=$(expand_story_key "$1")
|
|
149
|
+
shift
|
|
150
|
+
|
|
151
|
+
# Parse options
|
|
152
|
+
local mode="full"
|
|
153
|
+
local collab_agents=""
|
|
154
|
+
local max_iterations=3
|
|
155
|
+
export AUTO_COMMIT="${AUTO_COMMIT:-true}"
|
|
156
|
+
export AUTO_PR="${AUTO_PR:-false}"
|
|
157
|
+
|
|
158
|
+
while [[ $# -gt 0 ]]; do
|
|
159
|
+
case "$1" in
|
|
160
|
+
# Greenfield modes
|
|
161
|
+
"--develop"|"--dev")
|
|
162
|
+
mode="develop"
|
|
163
|
+
;;
|
|
164
|
+
"--review")
|
|
165
|
+
mode="review"
|
|
166
|
+
;;
|
|
167
|
+
"--context")
|
|
168
|
+
mode="context"
|
|
169
|
+
;;
|
|
170
|
+
"--adversarial"|"--adv")
|
|
171
|
+
mode="adversarial"
|
|
172
|
+
;;
|
|
173
|
+
# Collaborative modes
|
|
174
|
+
"--swarm")
|
|
175
|
+
mode="swarm"
|
|
176
|
+
;;
|
|
177
|
+
"--pair")
|
|
178
|
+
mode="pair"
|
|
179
|
+
;;
|
|
180
|
+
"--auto-route"|"--auto")
|
|
181
|
+
mode="auto-route"
|
|
182
|
+
;;
|
|
183
|
+
"--agents")
|
|
184
|
+
shift
|
|
185
|
+
if [[ $# -eq 0 ]]; then
|
|
186
|
+
echo "Error: --agents requires an argument"
|
|
187
|
+
print_usage
|
|
188
|
+
exit 1
|
|
189
|
+
fi
|
|
190
|
+
collab_agents="$1"
|
|
191
|
+
;;
|
|
192
|
+
"--max-iter"|"--max-iterations")
|
|
193
|
+
shift
|
|
194
|
+
if [[ $# -eq 0 ]]; then
|
|
195
|
+
echo "Error: --max-iter requires an argument"
|
|
196
|
+
print_usage
|
|
197
|
+
exit 1
|
|
198
|
+
fi
|
|
199
|
+
max_iterations="$1"
|
|
200
|
+
;;
|
|
201
|
+
# Brownfield modes
|
|
202
|
+
"--bugfix"|"--bug")
|
|
203
|
+
mode="bugfix"
|
|
204
|
+
;;
|
|
205
|
+
"--refactor")
|
|
206
|
+
mode="refactor"
|
|
207
|
+
;;
|
|
208
|
+
"--investigate"|"--explore")
|
|
209
|
+
mode="investigate"
|
|
210
|
+
;;
|
|
211
|
+
"--quickfix"|"--quick")
|
|
212
|
+
mode="quickfix"
|
|
213
|
+
;;
|
|
214
|
+
"--migrate"|"--migration")
|
|
215
|
+
mode="migrate"
|
|
216
|
+
;;
|
|
217
|
+
"--tech-debt"|"--debt")
|
|
218
|
+
mode="tech-debt"
|
|
219
|
+
;;
|
|
220
|
+
# Options
|
|
221
|
+
"--no-commit")
|
|
222
|
+
AUTO_COMMIT="false"
|
|
223
|
+
;;
|
|
224
|
+
"--with-pr")
|
|
225
|
+
AUTO_PR="true"
|
|
226
|
+
;;
|
|
227
|
+
"--model")
|
|
228
|
+
shift
|
|
229
|
+
if [[ $# -eq 0 ]]; then
|
|
230
|
+
echo "Error: --model requires an argument (sonnet|opus|haiku)"
|
|
231
|
+
print_usage
|
|
232
|
+
exit 1
|
|
233
|
+
fi
|
|
234
|
+
export CLAUDE_MODEL="$1"
|
|
235
|
+
;;
|
|
236
|
+
*)
|
|
237
|
+
echo "Unknown option: $1"
|
|
238
|
+
print_usage
|
|
239
|
+
exit 1
|
|
240
|
+
;;
|
|
241
|
+
esac
|
|
242
|
+
shift
|
|
243
|
+
done
|
|
244
|
+
|
|
245
|
+
print_header
|
|
246
|
+
echo -e "${BLUE}Story:${NC} $story_key"
|
|
247
|
+
echo -e "${BLUE}Mode:${NC} $mode"
|
|
248
|
+
echo -e "${BLUE}Model:${NC} $CLAUDE_MODEL"
|
|
249
|
+
echo -e "${BLUE}Auto-commit:${NC} $AUTO_COMMIT"
|
|
250
|
+
echo -e "${BLUE}Auto-PR:${NC} $AUTO_PR"
|
|
251
|
+
echo ""
|
|
252
|
+
|
|
253
|
+
# Check for existing checkpoint and offer to resume
|
|
254
|
+
if type has_checkpoint &>/dev/null && has_checkpoint "$story_key"; then
|
|
255
|
+
echo -e "${CYAN}📂 Found existing checkpoint for story: $story_key${NC}"
|
|
256
|
+
echo -e "${YELLOW}Would you like to resume from the checkpoint? (y/n)${NC}"
|
|
257
|
+
read -r RESUME_CHOICE
|
|
258
|
+
|
|
259
|
+
if [[ "$RESUME_CHOICE" =~ ^[Yy]$ ]]; then
|
|
260
|
+
if type resume_from_checkpoint &>/dev/null; then
|
|
261
|
+
resume_from_checkpoint "$story_key"
|
|
262
|
+
return 0
|
|
263
|
+
fi
|
|
264
|
+
else
|
|
265
|
+
echo -e "${GREEN}Starting fresh implementation...${NC}"
|
|
266
|
+
echo ""
|
|
267
|
+
fi
|
|
268
|
+
fi
|
|
269
|
+
|
|
270
|
+
# Create pre-start checkpoint
|
|
271
|
+
if type create_story_checkpoint &>/dev/null; then
|
|
272
|
+
echo -e "${CYAN}💾 Creating pre-start checkpoint...${NC}"
|
|
273
|
+
create_story_checkpoint "$story_key" "pre-start" 2>&1 | grep -v "Could not export"
|
|
274
|
+
echo ""
|
|
275
|
+
fi
|
|
276
|
+
|
|
277
|
+
case "$mode" in
|
|
278
|
+
# ═══════════════════════════════════════════════════════════════
|
|
279
|
+
# COLLABORATIVE MODES - Multi-agent collaboration
|
|
280
|
+
# ═══════════════════════════════════════════════════════════════
|
|
281
|
+
"swarm")
|
|
282
|
+
echo -e "${YELLOW}▶ Running swarm mode (multi-agent debate)...${NC}"
|
|
283
|
+
echo ""
|
|
284
|
+
local swarm_args="$story_key --swarm"
|
|
285
|
+
if [[ -n "$collab_agents" ]]; then
|
|
286
|
+
swarm_args="$swarm_args --agents $collab_agents"
|
|
287
|
+
fi
|
|
288
|
+
swarm_args="$swarm_args --max-iterations $max_iterations"
|
|
289
|
+
python3 "$SCRIPT_DIR/run-collab.py" $swarm_args
|
|
290
|
+
local exit_code=$?
|
|
291
|
+
|
|
292
|
+
if [[ $exit_code -eq 0 && "$AUTO_COMMIT" == "true" ]]; then
|
|
293
|
+
auto_commit_changes "$story_key"
|
|
294
|
+
fi
|
|
295
|
+
;;
|
|
296
|
+
"pair")
|
|
297
|
+
echo -e "${YELLOW}▶ Running pair programming mode (DEV + REVIEWER)...${NC}"
|
|
298
|
+
echo ""
|
|
299
|
+
python3 "$SCRIPT_DIR/run-collab.py" "$story_key" --pair --max-revisions "$max_iterations"
|
|
300
|
+
local exit_code=$?
|
|
301
|
+
|
|
302
|
+
if [[ $exit_code -eq 0 && "$AUTO_COMMIT" == "true" ]]; then
|
|
303
|
+
auto_commit_changes "$story_key"
|
|
304
|
+
fi
|
|
305
|
+
;;
|
|
306
|
+
"auto-route")
|
|
307
|
+
echo -e "${YELLOW}▶ Running auto-route mode (intelligent agent selection)...${NC}"
|
|
308
|
+
echo ""
|
|
309
|
+
python3 "$SCRIPT_DIR/run-collab.py" "$story_key" --auto
|
|
310
|
+
local exit_code=$?
|
|
311
|
+
|
|
312
|
+
if [[ $exit_code -eq 0 && "$AUTO_COMMIT" == "true" ]]; then
|
|
313
|
+
auto_commit_changes "$story_key"
|
|
314
|
+
fi
|
|
315
|
+
;;
|
|
316
|
+
|
|
317
|
+
# ═══════════════════════════════════════════════════════════════
|
|
318
|
+
# GREENFIELD MODES - New feature development
|
|
319
|
+
# ═══════════════════════════════════════════════════════════════
|
|
320
|
+
"develop")
|
|
321
|
+
echo -e "${YELLOW}▶ Running development phase...${NC}"
|
|
322
|
+
echo ""
|
|
323
|
+
invoke_dev_story "$story_key"
|
|
324
|
+
local exit_code=$?
|
|
325
|
+
|
|
326
|
+
# Update status to 'review' if successful
|
|
327
|
+
if [[ $exit_code -eq 0 ]]; then
|
|
328
|
+
update_story_status "$story_key" "review"
|
|
329
|
+
fi
|
|
330
|
+
|
|
331
|
+
# Auto-commit after dev if enabled
|
|
332
|
+
if [[ $exit_code -eq 0 && "$AUTO_COMMIT" == "true" ]]; then
|
|
333
|
+
auto_commit_changes "$story_key"
|
|
334
|
+
fi
|
|
335
|
+
|
|
336
|
+
# Auto-PR if enabled
|
|
337
|
+
if [[ $exit_code -eq 0 && "$AUTO_PR" == "true" ]]; then
|
|
338
|
+
auto_create_pr "$story_key"
|
|
339
|
+
fi
|
|
340
|
+
;;
|
|
341
|
+
"review")
|
|
342
|
+
echo -e "${YELLOW}▶ Running review phase...${NC}"
|
|
343
|
+
echo ""
|
|
344
|
+
invoke_sm_code_review "$story_key"
|
|
345
|
+
exit_code=$?
|
|
346
|
+
;;
|
|
347
|
+
"adversarial")
|
|
348
|
+
echo -e "${YELLOW}▶ Running adversarial review (Opus)...${NC}"
|
|
349
|
+
echo ""
|
|
350
|
+
invoke_adversarial_review "$story_key"
|
|
351
|
+
exit_code=$?
|
|
352
|
+
;;
|
|
353
|
+
"context")
|
|
354
|
+
echo -e "${YELLOW}▶ Creating story context...${NC}"
|
|
355
|
+
echo ""
|
|
356
|
+
invoke_sm_story_context "$story_key"
|
|
357
|
+
exit_code=$?
|
|
358
|
+
;;
|
|
359
|
+
|
|
360
|
+
# ═══════════════════════════════════════════════════════════════
|
|
361
|
+
# BROWNFIELD MODES - Existing codebase maintenance
|
|
362
|
+
# ═══════════════════════════════════════════════════════════════
|
|
363
|
+
"bugfix")
|
|
364
|
+
echo -e "${YELLOW}▶ Running bug fix workflow...${NC}"
|
|
365
|
+
echo ""
|
|
366
|
+
invoke_bugfix "$story_key"
|
|
367
|
+
exit_code=$?
|
|
368
|
+
|
|
369
|
+
# Auto-commit after bugfix if enabled
|
|
370
|
+
if [[ $exit_code -eq 0 && "$AUTO_COMMIT" == "true" ]]; then
|
|
371
|
+
auto_commit_changes "$story_key"
|
|
372
|
+
fi
|
|
373
|
+
;;
|
|
374
|
+
"refactor")
|
|
375
|
+
echo -e "${YELLOW}▶ Running refactoring workflow...${NC}"
|
|
376
|
+
echo ""
|
|
377
|
+
invoke_refactor "$story_key"
|
|
378
|
+
exit_code=$?
|
|
379
|
+
|
|
380
|
+
# Auto-commit after refactor if enabled
|
|
381
|
+
if [[ $exit_code -eq 0 && "$AUTO_COMMIT" == "true" ]]; then
|
|
382
|
+
auto_commit_changes "$story_key"
|
|
383
|
+
fi
|
|
384
|
+
;;
|
|
385
|
+
"investigate")
|
|
386
|
+
echo -e "${YELLOW}▶ Running investigation workflow...${NC}"
|
|
387
|
+
echo ""
|
|
388
|
+
invoke_investigate "$story_key"
|
|
389
|
+
exit_code=$?
|
|
390
|
+
# No auto-commit for investigation (read-only)
|
|
391
|
+
;;
|
|
392
|
+
"quickfix")
|
|
393
|
+
echo -e "${YELLOW}▶ Running quick fix...${NC}"
|
|
394
|
+
echo ""
|
|
395
|
+
invoke_quickfix "$story_key"
|
|
396
|
+
exit_code=$?
|
|
397
|
+
|
|
398
|
+
# Auto-commit after quickfix if enabled
|
|
399
|
+
if [[ $exit_code -eq 0 && "$AUTO_COMMIT" == "true" ]]; then
|
|
400
|
+
auto_commit_changes "$story_key"
|
|
401
|
+
fi
|
|
402
|
+
;;
|
|
403
|
+
"migrate")
|
|
404
|
+
echo -e "${YELLOW}▶ Running migration workflow...${NC}"
|
|
405
|
+
echo ""
|
|
406
|
+
invoke_migrate "$story_key"
|
|
407
|
+
exit_code=$?
|
|
408
|
+
|
|
409
|
+
# Auto-commit after migration if enabled
|
|
410
|
+
if [[ $exit_code -eq 0 && "$AUTO_COMMIT" == "true" ]]; then
|
|
411
|
+
auto_commit_changes "$story_key"
|
|
412
|
+
fi
|
|
413
|
+
;;
|
|
414
|
+
"tech-debt")
|
|
415
|
+
echo -e "${YELLOW}▶ Running technical debt resolution...${NC}"
|
|
416
|
+
echo ""
|
|
417
|
+
invoke_tech_debt "$story_key"
|
|
418
|
+
exit_code=$?
|
|
419
|
+
|
|
420
|
+
# Auto-commit after tech-debt resolution if enabled
|
|
421
|
+
if [[ $exit_code -eq 0 && "$AUTO_COMMIT" == "true" ]]; then
|
|
422
|
+
auto_commit_changes "$story_key"
|
|
423
|
+
fi
|
|
424
|
+
;;
|
|
425
|
+
|
|
426
|
+
# ═══════════════════════════════════════════════════════════════
|
|
427
|
+
# DEFAULT - Full greenfield pipeline
|
|
428
|
+
# ═══════════════════════════════════════════════════════════════
|
|
429
|
+
*)
|
|
430
|
+
echo -e "${YELLOW}▶ Running full pipeline...${NC}"
|
|
431
|
+
echo ""
|
|
432
|
+
run_full_pipeline "$story_key"
|
|
433
|
+
exit_code=$?
|
|
434
|
+
;;
|
|
435
|
+
esac
|
|
436
|
+
|
|
437
|
+
# Create completion checkpoint if successful
|
|
438
|
+
if [[ $exit_code -eq 0 && "$mode" != "context" ]]; then
|
|
439
|
+
if type create_story_checkpoint &>/dev/null; then
|
|
440
|
+
echo -e "${CYAN}💾 Creating completion checkpoint...${NC}"
|
|
441
|
+
create_story_checkpoint "$story_key" "complete" 2>&1 | grep -v "Could not export"
|
|
442
|
+
echo ""
|
|
443
|
+
fi
|
|
444
|
+
fi
|
|
445
|
+
|
|
446
|
+
# Cleanup old checkpoints (keep last 10)
|
|
447
|
+
if type cleanup_old_checkpoints &>/dev/null; then
|
|
448
|
+
cleanup_old_checkpoints 10 2>&1 | grep -E "^(🧹|✅|Deleted)"
|
|
449
|
+
echo ""
|
|
450
|
+
fi
|
|
451
|
+
|
|
452
|
+
echo ""
|
|
453
|
+
if [[ $exit_code -eq 0 ]]; then
|
|
454
|
+
echo -e "${GREEN}✅ Complete!${NC}"
|
|
455
|
+
else
|
|
456
|
+
echo -e "${RED}❌ Failed with exit code: $exit_code${NC}"
|
|
457
|
+
fi
|
|
458
|
+
|
|
459
|
+
echo ""
|
|
460
|
+
echo -e "${BLUE}Log files:${NC} $PROJECT_ROOT/.automation/logs/"
|
|
461
|
+
echo -e "${BLUE}Checkpoints:${NC} $PROJECT_ROOT/.automation/checkpoints/"
|
|
462
|
+
echo ""
|
|
463
|
+
|
|
464
|
+
return $exit_code
|
|
465
|
+
}
|
|
466
|
+
|
|
467
|
+
main "$@"
|
|
@@ -0,0 +1,219 @@
|
|
|
1
|
+
<#
|
|
2
|
+
.SYNOPSIS
|
|
3
|
+
Setup Checkpoint Service - Windows Task Scheduler
|
|
4
|
+
|
|
5
|
+
.DESCRIPTION
|
|
6
|
+
Creates a scheduled task that monitors Claude sessions for context warnings
|
|
7
|
+
and automatically creates checkpoints.
|
|
8
|
+
|
|
9
|
+
.PARAMETER Action
|
|
10
|
+
The action to perform: install, uninstall, or status
|
|
11
|
+
|
|
12
|
+
.EXAMPLE
|
|
13
|
+
.\setup-checkpoint-service.ps1 -Action install
|
|
14
|
+
.\setup-checkpoint-service.ps1 -Action uninstall
|
|
15
|
+
.\setup-checkpoint-service.ps1 -Action status
|
|
16
|
+
|
|
17
|
+
.NOTES
|
|
18
|
+
Version: 1.0.0
|
|
19
|
+
Requires: PowerShell 5.1+, Python 3.9+, Administrator rights for install/uninstall
|
|
20
|
+
#>
|
|
21
|
+
|
|
22
|
+
#Requires -Version 5.1
|
|
23
|
+
|
|
24
|
+
param(
|
|
25
|
+
[ValidateSet("install", "uninstall", "status")]
|
|
26
|
+
[string]$Action = "install"
|
|
27
|
+
)
|
|
28
|
+
|
|
29
|
+
# Configuration
|
|
30
|
+
$script:ProjectRoot = (Get-Item "$PSScriptRoot\.." -ErrorAction SilentlyContinue).FullName
|
|
31
|
+
$script:ScriptPath = Join-Path $script:ProjectRoot "tooling\scripts\context_checkpoint.py"
|
|
32
|
+
$script:TaskName = "ClaudeCheckpointService"
|
|
33
|
+
$script:LogDir = Join-Path $script:ProjectRoot "tooling\.automation\logs"
|
|
34
|
+
|
|
35
|
+
function Write-Header {
|
|
36
|
+
Write-Host ""
|
|
37
|
+
Write-Host ("{0}" -f ("=" * 65)) -ForegroundColor Blue
|
|
38
|
+
Write-Host " Context Checkpoint Service Setup (Windows)" -ForegroundColor Blue
|
|
39
|
+
Write-Host ("{0}" -f ("=" * 65)) -ForegroundColor Blue
|
|
40
|
+
Write-Host ""
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
function Test-Prerequisites {
|
|
44
|
+
Write-Host "[i] Checking prerequisites..." -ForegroundColor Blue
|
|
45
|
+
|
|
46
|
+
# Check Python
|
|
47
|
+
$python = Get-Command python -ErrorAction SilentlyContinue
|
|
48
|
+
if (-not $python) {
|
|
49
|
+
Write-Host "X Python 3 is required but not installed" -ForegroundColor Red
|
|
50
|
+
Write-Host " Install from: https://www.python.org/downloads/" -ForegroundColor Yellow
|
|
51
|
+
return $false
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
# Check script exists
|
|
55
|
+
if (-not (Test-Path $script:ScriptPath)) {
|
|
56
|
+
Write-Host "X Checkpoint script not found at: $script:ScriptPath" -ForegroundColor Red
|
|
57
|
+
return $false
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
Write-Host "[OK] Prerequisites OK" -ForegroundColor Green
|
|
61
|
+
return $true
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
function Install-CheckpointService {
|
|
65
|
+
Write-Host "[i] Creating Windows Task Scheduler task..." -ForegroundColor Blue
|
|
66
|
+
|
|
67
|
+
# Ensure log directory exists
|
|
68
|
+
if (-not (Test-Path $script:LogDir)) {
|
|
69
|
+
New-Item -ItemType Directory -Path $script:LogDir -Force | Out-Null
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
# Check if task already exists
|
|
73
|
+
$existingTask = Get-ScheduledTask -TaskName $script:TaskName -ErrorAction SilentlyContinue
|
|
74
|
+
if ($existingTask) {
|
|
75
|
+
Write-Host "[i] Removing existing task..." -ForegroundColor Yellow
|
|
76
|
+
Unregister-ScheduledTask -TaskName $script:TaskName -Confirm:$false
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
# Create the action
|
|
80
|
+
$watchLog = Join-Path $script:LogDir "current.log"
|
|
81
|
+
$pythonPath = (Get-Command python).Source
|
|
82
|
+
$arguments = "`"$script:ScriptPath`" --watch-log `"$watchLog`""
|
|
83
|
+
|
|
84
|
+
$action = New-ScheduledTaskAction `
|
|
85
|
+
-Execute $pythonPath `
|
|
86
|
+
-Argument $arguments `
|
|
87
|
+
-WorkingDirectory $script:ProjectRoot
|
|
88
|
+
|
|
89
|
+
# Create trigger (at logon)
|
|
90
|
+
$trigger = New-ScheduledTaskTrigger -AtLogOn -User $env:USERNAME
|
|
91
|
+
|
|
92
|
+
# Create settings
|
|
93
|
+
$settings = New-ScheduledTaskSettingsSet `
|
|
94
|
+
-AllowStartIfOnBatteries `
|
|
95
|
+
-DontStopIfGoingOnBatteries `
|
|
96
|
+
-StartWhenAvailable `
|
|
97
|
+
-RestartCount 3 `
|
|
98
|
+
-RestartInterval (New-TimeSpan -Minutes 1) `
|
|
99
|
+
-ExecutionTimeLimit (New-TimeSpan -Days 365)
|
|
100
|
+
|
|
101
|
+
# Create principal (run as current user)
|
|
102
|
+
$principal = New-ScheduledTaskPrincipal `
|
|
103
|
+
-UserId $env:USERNAME `
|
|
104
|
+
-LogonType Interactive `
|
|
105
|
+
-RunLevel Limited
|
|
106
|
+
|
|
107
|
+
try {
|
|
108
|
+
# Register the task
|
|
109
|
+
Register-ScheduledTask `
|
|
110
|
+
-TaskName $script:TaskName `
|
|
111
|
+
-Action $action `
|
|
112
|
+
-Trigger $trigger `
|
|
113
|
+
-Settings $settings `
|
|
114
|
+
-Principal $principal `
|
|
115
|
+
-Description "Monitors Claude Code sessions for context warnings and creates checkpoints" `
|
|
116
|
+
-Force | Out-Null
|
|
117
|
+
|
|
118
|
+
Write-Host "[OK] Task created: $script:TaskName" -ForegroundColor Green
|
|
119
|
+
|
|
120
|
+
# Start the task
|
|
121
|
+
Start-ScheduledTask -TaskName $script:TaskName -ErrorAction SilentlyContinue
|
|
122
|
+
Write-Host "[OK] Task started" -ForegroundColor Green
|
|
123
|
+
|
|
124
|
+
return $true
|
|
125
|
+
}
|
|
126
|
+
catch {
|
|
127
|
+
Write-Host "X Failed to create task: $_" -ForegroundColor Red
|
|
128
|
+
Write-Host ""
|
|
129
|
+
Write-Host "Try running PowerShell as Administrator" -ForegroundColor Yellow
|
|
130
|
+
return $false
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
function Uninstall-CheckpointService {
|
|
135
|
+
Write-Host "[i] Uninstalling checkpoint service..." -ForegroundColor Blue
|
|
136
|
+
|
|
137
|
+
$task = Get-ScheduledTask -TaskName $script:TaskName -ErrorAction SilentlyContinue
|
|
138
|
+
if ($task) {
|
|
139
|
+
# Stop the task if running
|
|
140
|
+
Stop-ScheduledTask -TaskName $script:TaskName -ErrorAction SilentlyContinue
|
|
141
|
+
|
|
142
|
+
# Unregister the task
|
|
143
|
+
Unregister-ScheduledTask -TaskName $script:TaskName -Confirm:$false
|
|
144
|
+
Write-Host "[OK] Service uninstalled" -ForegroundColor Green
|
|
145
|
+
}
|
|
146
|
+
else {
|
|
147
|
+
Write-Host "[i] Task not found, nothing to uninstall" -ForegroundColor Yellow
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
function Get-ServiceStatus {
|
|
152
|
+
Write-Host "[i] Checking service status..." -ForegroundColor Blue
|
|
153
|
+
Write-Host ""
|
|
154
|
+
|
|
155
|
+
$task = Get-ScheduledTask -TaskName $script:TaskName -ErrorAction SilentlyContinue
|
|
156
|
+
|
|
157
|
+
if (-not $task) {
|
|
158
|
+
Write-Host "Status: NOT INSTALLED" -ForegroundColor Yellow
|
|
159
|
+
Write-Host ""
|
|
160
|
+
Write-Host "To install, run:" -ForegroundColor Gray
|
|
161
|
+
Write-Host " .\setup-checkpoint-service.ps1 -Action install" -ForegroundColor Cyan
|
|
162
|
+
return
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
$taskInfo = Get-ScheduledTaskInfo -TaskName $script:TaskName -ErrorAction SilentlyContinue
|
|
166
|
+
|
|
167
|
+
Write-Host "Task Name: $($task.TaskName)" -ForegroundColor White
|
|
168
|
+
Write-Host "State: $($task.State)" -ForegroundColor $(if ($task.State -eq 'Running') { 'Green' } else { 'Yellow' })
|
|
169
|
+
Write-Host "Last Run: $($taskInfo.LastRunTime)" -ForegroundColor Gray
|
|
170
|
+
Write-Host "Next Run: $($taskInfo.NextRunTime)" -ForegroundColor Gray
|
|
171
|
+
Write-Host "Last Result: $($taskInfo.LastTaskResult)" -ForegroundColor $(if ($taskInfo.LastTaskResult -eq 0) { 'Green' } else { 'Yellow' })
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
function Write-Usage {
|
|
175
|
+
Write-Host ""
|
|
176
|
+
Write-Host ("{0}" -f ("=" * 65)) -ForegroundColor Green
|
|
177
|
+
Write-Host " Setup Complete!" -ForegroundColor Green
|
|
178
|
+
Write-Host ("{0}" -f ("=" * 65)) -ForegroundColor Green
|
|
179
|
+
Write-Host ""
|
|
180
|
+
Write-Host "The context checkpoint service is now running as a scheduled task."
|
|
181
|
+
Write-Host ""
|
|
182
|
+
Write-Host "Service Management:" -ForegroundColor Blue
|
|
183
|
+
Write-Host " * Start: Start-ScheduledTask -TaskName '$script:TaskName'"
|
|
184
|
+
Write-Host " * Stop: Stop-ScheduledTask -TaskName '$script:TaskName'"
|
|
185
|
+
Write-Host " * Status: .\setup-checkpoint-service.ps1 -Action status"
|
|
186
|
+
Write-Host " * Remove: .\setup-checkpoint-service.ps1 -Action uninstall"
|
|
187
|
+
Write-Host ""
|
|
188
|
+
Write-Host "Or use Task Scheduler GUI:" -ForegroundColor Blue
|
|
189
|
+
Write-Host " taskschd.msc"
|
|
190
|
+
Write-Host ""
|
|
191
|
+
Write-Host "Logs:" -ForegroundColor Blue
|
|
192
|
+
Write-Host " * Watch log: $script:LogDir\current.log"
|
|
193
|
+
Write-Host " * Checkpoints: tooling\.automation\checkpoints\"
|
|
194
|
+
Write-Host ""
|
|
195
|
+
Write-Host "Quick Commands:" -ForegroundColor Blue
|
|
196
|
+
Write-Host " * Create checkpoint: python tooling\scripts\context_checkpoint.py --checkpoint"
|
|
197
|
+
Write-Host " * List checkpoints: python tooling\scripts\context_checkpoint.py --list"
|
|
198
|
+
Write-Host " * Resume session: python tooling\scripts\context_checkpoint.py --resume <id>"
|
|
199
|
+
Write-Host ""
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
# Main execution
|
|
203
|
+
Write-Header
|
|
204
|
+
|
|
205
|
+
switch ($Action) {
|
|
206
|
+
"install" {
|
|
207
|
+
if (Test-Prerequisites) {
|
|
208
|
+
if (Install-CheckpointService) {
|
|
209
|
+
Write-Usage
|
|
210
|
+
}
|
|
211
|
+
}
|
|
212
|
+
}
|
|
213
|
+
"uninstall" {
|
|
214
|
+
Uninstall-CheckpointService
|
|
215
|
+
}
|
|
216
|
+
"status" {
|
|
217
|
+
Get-ServiceStatus
|
|
218
|
+
}
|
|
219
|
+
}
|