@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.
Files changed (124) hide show
  1. package/CHANGELOG.md +526 -0
  2. package/LICENSE +21 -0
  3. package/README.md +620 -0
  4. package/bin/devflow-checkpoint.js +10 -0
  5. package/bin/devflow-collab.js +10 -0
  6. package/bin/devflow-cost.js +10 -0
  7. package/bin/devflow-create-persona.js +10 -0
  8. package/bin/devflow-init.js +10 -0
  9. package/bin/devflow-memory.js +10 -0
  10. package/bin/devflow-new-doc.js +10 -0
  11. package/bin/devflow-personalize.js +10 -0
  12. package/bin/devflow-setup-checkpoint.js +10 -0
  13. package/bin/devflow-story.js +10 -0
  14. package/bin/devflow-tech-debt.js +10 -0
  15. package/bin/devflow-validate-overrides.js +10 -0
  16. package/bin/devflow-validate.js +10 -0
  17. package/bin/devflow-version.js +10 -0
  18. package/lib/constants.js +30 -0
  19. package/lib/exec-python.js +78 -0
  20. package/lib/python-check.js +178 -0
  21. package/package.json +64 -0
  22. package/tooling/.automation/agents/architect.md +135 -0
  23. package/tooling/.automation/agents/ba.md +70 -0
  24. package/tooling/.automation/agents/dev.md +79 -0
  25. package/tooling/.automation/agents/maintainer.md +97 -0
  26. package/tooling/.automation/agents/pm.md +116 -0
  27. package/tooling/.automation/agents/reviewer.md +141 -0
  28. package/tooling/.automation/agents/sm.md +61 -0
  29. package/tooling/.automation/agents/writer.md +193 -0
  30. package/tooling/.automation/config.ps1.template +61 -0
  31. package/tooling/.automation/config.sh.template +48 -0
  32. package/tooling/.automation/memory/.gitkeep +6 -0
  33. package/tooling/.automation/memory/knowledge/kg_integration-test.json +94 -0
  34. package/tooling/.automation/memory/knowledge/kg_test-story.json +300 -0
  35. package/tooling/.automation/memory/shared/shared_integration-test.json +30 -0
  36. package/tooling/.automation/memory/shared/shared_test-story.json +78 -0
  37. package/tooling/.automation/overrides/templates/README.md +113 -0
  38. package/tooling/.automation/overrides/templates/architect/README.md +27 -0
  39. package/tooling/.automation/overrides/templates/architect/cloud-native.yaml +92 -0
  40. package/tooling/.automation/overrides/templates/architect/enterprise-architect.yaml +85 -0
  41. package/tooling/.automation/overrides/templates/architect/pragmatic-minimalist.yaml +88 -0
  42. package/tooling/.automation/overrides/templates/ba/README.md +27 -0
  43. package/tooling/.automation/overrides/templates/ba/agile-storyteller.yaml +86 -0
  44. package/tooling/.automation/overrides/templates/ba/domain-expert.yaml +91 -0
  45. package/tooling/.automation/overrides/templates/ba/requirements-engineer.yaml +89 -0
  46. package/tooling/.automation/overrides/templates/dev/README.md +32 -0
  47. package/tooling/.automation/overrides/templates/dev/junior-mentored.yaml +39 -0
  48. package/tooling/.automation/overrides/templates/dev/performance-engineer.yaml +43 -0
  49. package/tooling/.automation/overrides/templates/dev/rapid-prototyper.yaml +52 -0
  50. package/tooling/.automation/overrides/templates/dev/security-focused.yaml +43 -0
  51. package/tooling/.automation/overrides/templates/dev/senior-fullstack.yaml +39 -0
  52. package/tooling/.automation/overrides/templates/maintainer/README.md +27 -0
  53. package/tooling/.automation/overrides/templates/maintainer/devops-maintainer.yaml +113 -0
  54. package/tooling/.automation/overrides/templates/maintainer/legacy-steward.yaml +94 -0
  55. package/tooling/.automation/overrides/templates/maintainer/oss-maintainer.yaml +94 -0
  56. package/tooling/.automation/overrides/templates/pm/README.md +27 -0
  57. package/tooling/.automation/overrides/templates/pm/agile-pm.yaml +91 -0
  58. package/tooling/.automation/overrides/templates/pm/hybrid-delivery.yaml +87 -0
  59. package/tooling/.automation/overrides/templates/pm/traditional-pm.yaml +91 -0
  60. package/tooling/.automation/overrides/templates/reviewer/README.md +11 -0
  61. package/tooling/.automation/overrides/templates/reviewer/mentoring-reviewer.yaml +45 -0
  62. package/tooling/.automation/overrides/templates/reviewer/quick-sanity.yaml +50 -0
  63. package/tooling/.automation/overrides/templates/reviewer/thorough-critic.yaml +48 -0
  64. package/tooling/.automation/overrides/templates/sm/README.md +11 -0
  65. package/tooling/.automation/overrides/templates/sm/agile-coach.yaml +52 -0
  66. package/tooling/.automation/overrides/templates/sm/startup-pm.yaml +50 -0
  67. package/tooling/.automation/overrides/templates/sm/technical-lead.yaml +47 -0
  68. package/tooling/.automation/overrides/templates/user-profile.template.yaml +62 -0
  69. package/tooling/.automation/overrides/templates/writer/README.md +27 -0
  70. package/tooling/.automation/overrides/templates/writer/api-documentarian.yaml +99 -0
  71. package/tooling/.automation/overrides/templates/writer/docs-as-code.yaml +108 -0
  72. package/tooling/.automation/overrides/templates/writer/user-guide-author.yaml +100 -0
  73. package/tooling/completions/DevflowCompletion.ps1 +213 -0
  74. package/tooling/completions/_run-story +116 -0
  75. package/tooling/completions/run-story-completion.bash +136 -0
  76. package/tooling/docs/DOC-STANDARD.md +717 -0
  77. package/tooling/docs/sprint-status.yaml.template +24 -0
  78. package/tooling/docs/templates/bug-report.md +234 -0
  79. package/tooling/docs/templates/migration-spec.md +274 -0
  80. package/tooling/docs/templates/refactor-spec.md +86 -0
  81. package/tooling/docs/templates/tech-debt.md +86 -0
  82. package/tooling/scripts/context_checkpoint.py +556 -0
  83. package/tooling/scripts/cost_dashboard.py +617 -0
  84. package/tooling/scripts/create-persona.py +690 -0
  85. package/tooling/scripts/create-persona.sh +435 -0
  86. package/tooling/scripts/init-project-workflow.ps1 +651 -0
  87. package/tooling/scripts/init-project-workflow.py +70 -0
  88. package/tooling/scripts/init-project-workflow.sh +746 -0
  89. package/tooling/scripts/lib/__init__.py +35 -0
  90. package/tooling/scripts/lib/agent_handoff.py +526 -0
  91. package/tooling/scripts/lib/agent_router.py +698 -0
  92. package/tooling/scripts/lib/checkpoint-integration.ps1 +245 -0
  93. package/tooling/scripts/lib/checkpoint-integration.sh +191 -0
  94. package/tooling/scripts/lib/claude-cli.ps1 +952 -0
  95. package/tooling/scripts/lib/claude-cli.sh +1293 -0
  96. package/tooling/scripts/lib/cost_config.py +222 -0
  97. package/tooling/scripts/lib/cost_display.py +443 -0
  98. package/tooling/scripts/lib/cost_tracker.py +710 -0
  99. package/tooling/scripts/lib/currency_converter.py +328 -0
  100. package/tooling/scripts/lib/errors.py +438 -0
  101. package/tooling/scripts/lib/override-loader.sh +286 -0
  102. package/tooling/scripts/lib/pair_programming.py +589 -0
  103. package/tooling/scripts/lib/shared_memory.py +637 -0
  104. package/tooling/scripts/lib/swarm_orchestrator.py +689 -0
  105. package/tooling/scripts/memory_summarize.py +324 -0
  106. package/tooling/scripts/new-doc.ps1 +405 -0
  107. package/tooling/scripts/new-doc.py +93 -0
  108. package/tooling/scripts/new-doc.sh +534 -0
  109. package/tooling/scripts/personalize_agent.py +385 -0
  110. package/tooling/scripts/rollback-migration.sh +540 -0
  111. package/tooling/scripts/run-collab.ps1 +251 -0
  112. package/tooling/scripts/run-collab.py +605 -0
  113. package/tooling/scripts/run-collab.sh +110 -0
  114. package/tooling/scripts/run-story.ps1 +490 -0
  115. package/tooling/scripts/run-story.py +387 -0
  116. package/tooling/scripts/run-story.sh +467 -0
  117. package/tooling/scripts/setup-checkpoint-service.ps1 +219 -0
  118. package/tooling/scripts/setup-checkpoint-service.py +87 -0
  119. package/tooling/scripts/setup-checkpoint-service.sh +236 -0
  120. package/tooling/scripts/tech-debt-tracker.py +608 -0
  121. package/tooling/scripts/update_version.py +244 -0
  122. package/tooling/scripts/validate-overrides.py +511 -0
  123. package/tooling/scripts/validate-overrides.sh +432 -0
  124. package/tooling/scripts/validate_setup.py +539 -0
@@ -0,0 +1,746 @@
1
+ #!/usr/bin/env bash
2
+ ################################################################################
3
+ # INIT-PROJECT-WORKFLOW - Claude Code Workflow Initialization
4
+ #
5
+ # Sets up automated development workflow for any project using Claude Code CLI
6
+ #
7
+ # Usage:
8
+ # ./init-project-workflow.sh
9
+ #
10
+ ################################################################################
11
+
12
+ set -e
13
+
14
+ # Colors
15
+ RED='\033[0;31m'
16
+ GREEN='\033[0;32m'
17
+ YELLOW='\033[1;33m'
18
+ BLUE='\033[0;34m'
19
+ CYAN='\033[0;36m'
20
+ MAGENTA='\033[1;35m'
21
+ NC='\033[0m'
22
+
23
+ SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)"
24
+
25
+ ################################################################################
26
+ # Helper Functions
27
+ ################################################################################
28
+
29
+ print_banner() {
30
+ echo ""
31
+ echo -e "${CYAN}╔═══════════════════════════════════════════════════════════════╗${NC}"
32
+ echo -e "${CYAN}║ CLAUDE CODE WORKFLOW INITIALIZATION ║${NC}"
33
+ echo -e "${CYAN}╠═══════════════════════════════════════════════════════════════╣${NC}"
34
+ echo -e "${CYAN}║ Automated Development Workflow Setup ║${NC}"
35
+ echo -e "${CYAN}║ Version 1.7.0 ║${NC}"
36
+ echo -e "${CYAN}╚═══════════════════════════════════════════════════════════════╝${NC}"
37
+ echo ""
38
+ }
39
+
40
+ print_step() {
41
+ local step_num="$1"
42
+ local step_title="$2"
43
+ echo ""
44
+ echo -e "${MAGENTA}═══════════════════════════════════════════════════════════════${NC}"
45
+ echo -e "${MAGENTA} STEP $step_num: $step_title${NC}"
46
+ echo -e "${MAGENTA}═══════════════════════════════════════════════════════════════${NC}"
47
+ echo ""
48
+ }
49
+
50
+ prompt_input() {
51
+ local prompt="$1"
52
+ local default="$2"
53
+ local result
54
+
55
+ if [[ -n "$default" ]]; then
56
+ echo -e "${YELLOW}$prompt${NC} ${BLUE}(default: $default)${NC}"
57
+ else
58
+ echo -e "${YELLOW}$prompt${NC}"
59
+ fi
60
+
61
+ read -r result
62
+ echo "${result:-$default}"
63
+ }
64
+
65
+ prompt_yes_no() {
66
+ local prompt="$1"
67
+ local default="${2:-y}"
68
+
69
+ echo -e "${YELLOW}$prompt (y/n)${NC} ${BLUE}[default: $default]${NC}"
70
+ read -r response
71
+
72
+ response="${response:-$default}"
73
+ [[ "$response" =~ ^[Yy]$ ]]
74
+ }
75
+
76
+ ################################################################################
77
+ # Setup Steps
78
+ ################################################################################
79
+
80
+ detect_project_type() {
81
+ echo -e "${BLUE}▶ Detecting project type...${NC}"
82
+
83
+ local project_type="generic"
84
+
85
+ if [[ -f "package.json" ]]; then
86
+ project_type="node"
87
+ elif [[ -f "pubspec.yaml" ]]; then
88
+ project_type="flutter"
89
+ elif [[ -f "Cargo.toml" ]]; then
90
+ project_type="rust"
91
+ elif [[ -f "go.mod" ]]; then
92
+ project_type="go"
93
+ elif [[ -f "requirements.txt" ]] || [[ -f "pyproject.toml" ]]; then
94
+ project_type="python"
95
+ elif [[ -f "Gemfile" ]]; then
96
+ project_type="ruby"
97
+ elif [[ -f "pom.xml" ]] || [[ -f "build.gradle" ]] || [[ -f "build.gradle.kts" ]]; then
98
+ # Check if it's Android or pure Java/Kotlin
99
+ if [[ -d "app/src/main/java" ]] || [[ -d "app/src/main/kotlin" ]]; then
100
+ project_type="android"
101
+ else
102
+ project_type="java"
103
+ fi
104
+ elif [[ -f "Package.swift" ]] || [[ -d "*.xcodeproj" ]] || [[ -d "*.xcworkspace" ]]; then
105
+ project_type="swift"
106
+ elif [[ -f "settings.gradle.kts" ]] && [[ -f "build.gradle.kts" ]]; then
107
+ project_type="kotlin"
108
+ fi
109
+
110
+ echo -e "${GREEN} Detected: $project_type${NC}"
111
+ echo "$project_type"
112
+ }
113
+
114
+ setup_directory_structure() {
115
+ local project_root="$1"
116
+ local workflow_mode="${2:-both}" # greenfield, brownfield, or both
117
+
118
+ echo -e "${BLUE}▶ Creating directory structure...${NC}"
119
+
120
+ # Core directories (always created)
121
+ mkdir -p "$project_root/tooling/.automation/agents"
122
+ mkdir -p "$project_root/tooling/.automation/checkpoints"
123
+ mkdir -p "$project_root/tooling/.automation/logs"
124
+ mkdir -p "$project_root/tooling/.automation/costs"
125
+ mkdir -p "$project_root/tooling/scripts/lib"
126
+ mkdir -p "$project_root/tooling/docs"
127
+
128
+ # Greenfield directories (for new feature development)
129
+ if [[ "$workflow_mode" == "greenfield" || "$workflow_mode" == "both" ]]; then
130
+ # Stories directory is the main docs directory
131
+ echo -e "${BLUE} Creating greenfield structure...${NC}"
132
+ fi
133
+
134
+ # Brownfield directories (for existing codebase maintenance)
135
+ if [[ "$workflow_mode" == "brownfield" || "$workflow_mode" == "both" ]]; then
136
+ mkdir -p "$project_root/tooling/docs/bugs"
137
+ mkdir -p "$project_root/tooling/docs/refactors"
138
+ mkdir -p "$project_root/tooling/docs/investigations"
139
+ mkdir -p "$project_root/tooling/docs/migrations"
140
+ mkdir -p "$project_root/tooling/docs/tech-debt"
141
+ echo -e "${BLUE} Creating brownfield structure...${NC}"
142
+ fi
143
+
144
+ echo -e "${GREEN} ✅ Directories created${NC}"
145
+ }
146
+
147
+ copy_core_scripts() {
148
+ local project_root="$1"
149
+ local source_dir="$2"
150
+
151
+ echo -e "${BLUE}▶ Copying core automation scripts...${NC}"
152
+
153
+ # Core library scripts
154
+ cp "$source_dir/lib/claude-cli.sh" "$project_root/tooling/scripts/lib/"
155
+ cp "$source_dir/lib/checkpoint-integration.sh" "$project_root/tooling/scripts/lib/"
156
+
157
+ # Main workflow scripts
158
+ cp "$source_dir/run-story.sh" "$project_root/tooling/scripts/"
159
+ cp "$source_dir/context_checkpoint.py" "$project_root/tooling/scripts/"
160
+ cp "$source_dir/setup-checkpoint-service.sh" "$project_root/tooling/scripts/"
161
+ cp "$source_dir/new-doc.sh" "$project_root/tooling/scripts/"
162
+
163
+ # Make executable
164
+ chmod +x "$project_root/tooling/scripts/"*.sh
165
+ chmod +x "$project_root/tooling/scripts/"*.py
166
+ chmod +x "$project_root/tooling/scripts/lib/"*.sh
167
+
168
+ echo -e "${GREEN} ✅ Scripts copied${NC}"
169
+ }
170
+
171
+ create_config_file() {
172
+ local project_root="$1"
173
+ local project_name="$2"
174
+ local project_type="$3"
175
+ local model_dev="$4"
176
+ local model_planning="$5"
177
+ local display_currency="${6:-USD}"
178
+
179
+ echo -e "${BLUE}▶ Creating configuration file...${NC}"
180
+
181
+ cat > "$project_root/tooling/.automation/config.sh" << EOF
182
+ #!/bin/zsh
183
+ ################################################################################
184
+ # Automation Configuration
185
+ # Generated: $(date +%Y-%m-%d)
186
+ ################################################################################
187
+
188
+ # Project settings
189
+ export PROJECT_NAME="$project_name"
190
+ export PROJECT_TYPE="$project_type"
191
+
192
+ # Claude Code CLI settings
193
+ export CLAUDE_CLI="\${CLAUDE_CLI:-claude}"
194
+ export CLAUDE_MODEL_DEV="$model_dev"
195
+ export CLAUDE_MODEL_PLANNING="$model_planning"
196
+
197
+ # Default model (can be overridden by individual tasks)
198
+ export CLAUDE_MODEL="\${CLAUDE_MODEL:-$model_planning}"
199
+
200
+ # Permission mode for automation
201
+ export PERMISSION_MODE="\${PERMISSION_MODE:-dangerouslySkipPermissions}"
202
+
203
+ # Auto-commit settings
204
+ export AUTO_COMMIT="\${AUTO_COMMIT:-true}"
205
+ export AUTO_PR="\${AUTO_PR:-false}"
206
+
207
+ # Budget limits (USD)
208
+ export MAX_BUDGET_CONTEXT=3.00
209
+ export MAX_BUDGET_DEV=15.00
210
+ export MAX_BUDGET_REVIEW=5.00
211
+
212
+ # Cost display settings
213
+ export COST_DISPLAY_CURRENCY="$display_currency"
214
+ export COST_WARNING_PERCENT=75
215
+ export COST_CRITICAL_PERCENT=90
216
+ export COST_AUTO_STOP="true"
217
+
218
+ # Paths
219
+ export AUTOMATION_DIR="\$(cd "\$(dirname "\${BASH_SOURCE[0]}")" && pwd)"
220
+ export PROJECT_ROOT="\$(cd "\$AUTOMATION_DIR/../.." && pwd)"
221
+ export SCRIPTS_DIR="\$PROJECT_ROOT/tooling/scripts"
222
+ export DOCS_DIR="\$PROJECT_ROOT/tooling/docs"
223
+
224
+ # Tool configurations
225
+ export CHECKPOINT_THRESHOLDS="75,85,95" # Warning, Critical, Emergency
226
+ EOF
227
+
228
+ chmod +x "$project_root/tooling/.automation/config.sh"
229
+
230
+ echo -e "${GREEN} ✅ Configuration created${NC}"
231
+ }
232
+
233
+ create_agent_personas() {
234
+ local project_root="$1"
235
+
236
+ echo -e "${BLUE}▶ Creating agent persona definitions...${NC}"
237
+
238
+ # SM (Scrum Master) Agent
239
+ cat > "$project_root/tooling/.automation/agents/sm.md" << 'EOF'
240
+ # Scrum Master Agent
241
+
242
+ You are an experienced Scrum Master overseeing development workflow.
243
+
244
+ ## Responsibilities
245
+ - Story context creation and planning
246
+ - Code review and quality assurance
247
+ - Story drafting and specification
248
+ - Sprint status management
249
+
250
+ ## Approach
251
+ - Be thorough but efficient
252
+ - Focus on quality and completeness
253
+ - Follow Agile best practices
254
+ - Ensure acceptance criteria are met
255
+
256
+ ## Communication Style
257
+ - Clear and professional
258
+ - Action-oriented
259
+ - Provide constructive feedback
260
+ EOF
261
+
262
+ # DEV (Developer) Agent
263
+ cat > "$project_root/tooling/.automation/agents/dev.md" << 'EOF'
264
+ # Developer Agent
265
+
266
+ You are a senior software developer implementing features.
267
+
268
+ ## Responsibilities
269
+ - Implement stories according to specifications
270
+ - Write clean, maintainable code
271
+ - Create comprehensive tests
272
+ - Follow project patterns and conventions
273
+
274
+ ## Approach
275
+ - Code first, explain later
276
+ - Prioritize working solutions
277
+ - Write self-documenting code
278
+ - Ensure tests pass before completion
279
+
280
+ ## Communication Style
281
+ - Concise and technical
282
+ - Focus on implementation details
283
+ - Proactive problem-solving
284
+ EOF
285
+
286
+ # BA (Business Analyst) Agent
287
+ cat > "$project_root/tooling/.automation/agents/ba.md" << 'EOF'
288
+ # Business Analyst Agent
289
+
290
+ You are a Business Analyst specializing in requirements gathering.
291
+
292
+ ## Responsibilities
293
+ - Analyze and document requirements
294
+ - Create user stories with INVEST criteria
295
+ - Define acceptance criteria
296
+ - Identify edge cases and business rules
297
+
298
+ ## Approach
299
+ - User-centric thinking
300
+ - Detailed documentation
301
+ - Clear acceptance criteria
302
+ - Consider all scenarios
303
+
304
+ ## Communication Style
305
+ - Clear and structured
306
+ - Business-focused
307
+ - Comprehensive but concise
308
+ EOF
309
+
310
+ # ARCHITECT Agent
311
+ cat > "$project_root/tooling/.automation/agents/architect.md" << 'EOF'
312
+ # Architect Agent
313
+
314
+ You are a Software Architect designing technical solutions.
315
+
316
+ ## Responsibilities
317
+ - Create technical specifications
318
+ - Design system architecture
319
+ - Define data models and APIs
320
+ - Identify technical risks
321
+
322
+ ## Approach
323
+ - Think holistically
324
+ - Follow architectural patterns
325
+ - Consider scalability and maintainability
326
+ - Balance pragmatism with quality
327
+
328
+ ## Communication Style
329
+ - Technical and precise
330
+ - Diagram-driven when helpful
331
+ - Consider trade-offs
332
+ EOF
333
+
334
+ # MAINTAINER Agent (for brownfield work)
335
+ cat > "$project_root/tooling/.automation/agents/maintainer.md" << 'EOF'
336
+ # Maintainer Agent
337
+
338
+ You are a senior software maintainer specializing in existing codebase management.
339
+
340
+ ## Primary Focus
341
+ Brownfield development - working with existing, production code.
342
+
343
+ ## Responsibilities
344
+ - Bug investigation and root cause analysis
345
+ - Minimal, targeted bug fixes
346
+ - Code refactoring with safety nets
347
+ - Technical debt resolution
348
+ - Codebase investigation and documentation
349
+ - Migration planning and execution
350
+
351
+ ## Core Principles
352
+
353
+ ### Understand Before Changing
354
+ - ALWAYS explore the codebase before making changes
355
+ - Trace code paths to understand impact
356
+ - Read related tests to understand expected behavior
357
+
358
+ ### Minimal Changes
359
+ - Make the smallest change that fixes the issue
360
+ - Avoid "while I'm here" improvements
361
+ - One concern per change
362
+
363
+ ### Safety First
364
+ - Run existing tests before and after changes
365
+ - Add regression tests for bugs
366
+ - Ensure backwards compatibility
367
+
368
+ ## Communication Style
369
+ - Precise and technical
370
+ - Focus on what changed and why
371
+ - Clear about risks and tradeoffs
372
+ EOF
373
+
374
+ echo -e "${GREEN} ✅ Agent personas created${NC}"
375
+ }
376
+
377
+ create_sprint_status() {
378
+ local project_root="$1"
379
+ local project_name="$2"
380
+
381
+ echo -e "${BLUE}▶ Creating sprint status tracker...${NC}"
382
+
383
+ cat > "$project_root/tooling/docs/sprint-status.yaml" << EOF
384
+ # Sprint Status - $project_name
385
+ # Updated: $(date +%Y-%m-%d)
386
+
387
+ sprint:
388
+ number: 1
389
+ start: $(date +%Y-%m-%d)
390
+ end: $(date -v+14d +%Y-%m-%d 2>/dev/null || date -d "+14 days" +%Y-%m-%d 2>/dev/null)
391
+
392
+ # Story Status Values:
393
+ # - backlog: Not yet started
394
+ # - drafted: Story specification created
395
+ # - ready-for-dev: Context created, ready for implementation
396
+ # - in-progress: Currently being worked on
397
+ # - review: Implementation complete, awaiting review
398
+ # - done: Reviewed and approved
399
+
400
+ stories:
401
+ # Add your stories here in format:
402
+ # story-key: status
403
+ # Example:
404
+ # 1-1-setup-project: done
405
+ # 1-2-implement-auth: in-progress
406
+ EOF
407
+
408
+ echo -e "${GREEN} ✅ Sprint status created${NC}"
409
+ }
410
+
411
+ create_documentation_standard() {
412
+ local project_root="$1"
413
+ local source_dir="$2"
414
+
415
+ echo -e "${BLUE}▶ Creating documentation standard...${NC}"
416
+
417
+ # Copy DOC-STANDARD if it exists, otherwise create basic one
418
+ if [[ -f "$source_dir/../docs/DOC-STANDARD.md" ]]; then
419
+ cp "$source_dir/../docs/DOC-STANDARD.md" "$project_root/tooling/docs/"
420
+ else
421
+ cat > "$project_root/tooling/docs/DOC-STANDARD.md" << 'EOF'
422
+ # Documentation Standard
423
+
424
+ **Version**: 1.0
425
+ **Last Updated**: $(date +%Y-%m-%d)
426
+
427
+ ## File Naming
428
+
429
+ Format: `[TYPE]-[descriptive-name].md`
430
+
431
+ Types:
432
+ - GUIDE - User-facing guides
433
+ - SPEC - Technical specifications
434
+ - STATUS - Status reports
435
+ - REFERENCE - Quick reference sheets
436
+
437
+ ## Required Sections
438
+
439
+ 1. Title (H1)
440
+ 2. Metadata block
441
+ 3. Purpose
442
+ 4. Main content
443
+ 5. Related documents (if any)
444
+
445
+ ## Example
446
+
447
+ ```markdown
448
+ # Feature Name
449
+
450
+ **Type**: Guide
451
+ **Version**: 1.0
452
+ **Last Updated**: YYYY-MM-DD
453
+ **Status**: Active
454
+
455
+ ## Purpose
456
+
457
+ Brief description of what this document covers.
458
+
459
+ ## Content
460
+
461
+ ...
462
+ ```
463
+ EOF
464
+ fi
465
+
466
+ echo -e "${GREEN} ✅ Documentation standard created${NC}"
467
+ }
468
+
469
+ setup_checkpoint_service() {
470
+ local project_root="$1"
471
+
472
+ echo -e "${BLUE}▶ Setting up checkpoint service...${NC}"
473
+
474
+ if prompt_yes_no "Install checkpoint service as macOS LaunchAgent?"; then
475
+ cd "$project_root/tooling/scripts"
476
+ ./setup-checkpoint-service.sh
477
+ echo -e "${GREEN} ✅ Checkpoint service installed${NC}"
478
+ else
479
+ echo -e "${YELLOW} ⊘ Skipped checkpoint service installation${NC}"
480
+ echo -e "${BLUE} You can install it later with: ./tooling/scripts/setup-checkpoint-service.sh${NC}"
481
+ fi
482
+ }
483
+
484
+ create_readme() {
485
+ local project_root="$1"
486
+ local project_name="$2"
487
+
488
+ echo -e "${BLUE}▶ Creating workflow README...${NC}"
489
+
490
+ cat > "$project_root/tooling/README.md" << EOF
491
+ # $project_name - Development Workflow
492
+
493
+ Automated development workflow powered by Claude Code CLI.
494
+
495
+ ## Quick Start
496
+
497
+ ### Run a Story
498
+
499
+ \`\`\`bash
500
+ cd tooling/scripts
501
+ ./run-story.sh <story-key>
502
+ \`\`\`
503
+
504
+ ### Available Commands
505
+
506
+ \`\`\`bash
507
+ # Full pipeline (context + dev + review)
508
+ ./run-story.sh 1-1
509
+
510
+ # Development only
511
+ ./run-story.sh 1-1 --develop
512
+
513
+ # Review only
514
+ ./run-story.sh 1-1 --review
515
+
516
+ # Context creation only
517
+ ./run-story.sh 1-1 --context
518
+ \`\`\`
519
+
520
+ ### Checkpoint Management
521
+
522
+ \`\`\`bash
523
+ # List checkpoints
524
+ ./tooling/scripts/checkpoint --list
525
+
526
+ # Create manual checkpoint
527
+ ./tooling/scripts/checkpoint --checkpoint
528
+
529
+ # Resume from checkpoint
530
+ ./tooling/scripts/checkpoint --resume <checkpoint-id>
531
+ \`\`\`
532
+
533
+ ### Create New Documentation
534
+
535
+ \`\`\`bash
536
+ ./tooling/scripts/new-doc.sh --type guide --name "my-guide"
537
+ \`\`\`
538
+
539
+ ## Directory Structure
540
+
541
+ \`\`\`
542
+ tooling/
543
+ ├── .automation/
544
+ │ ├── agents/ # Agent persona definitions
545
+ │ ├── checkpoints/ # Context checkpoints
546
+ │ ├── logs/ # Execution logs
547
+ │ └── config.sh # Configuration
548
+ ├── scripts/
549
+ │ ├── lib/ # Script libraries
550
+ │ ├── run-story.sh # Main automation runner
551
+ │ ├── checkpoint # Checkpoint CLI (symlink)
552
+ │ └── new-doc.sh # Documentation generator
553
+ └── docs/
554
+ ├── DOC-STANDARD.md # Documentation standard
555
+ └── sprint-status.yaml # Sprint tracking
556
+ \`\`\`
557
+
558
+ ## Configuration
559
+
560
+ Edit \`tooling/.automation/config.sh\` to customize:
561
+ - Claude Code models (Opus for dev, Sonnet for planning)
562
+ - Budget limits
563
+ - Auto-commit settings
564
+ - Permission modes
565
+
566
+ ## Agent Personas
567
+
568
+ The workflow uses multiple agent personas:
569
+ - **SM (Scrum Master)**: Planning, context creation, code review
570
+ - **DEV (Developer)**: Story implementation
571
+ - **BA (Business Analyst)**: Requirements analysis
572
+ - **ARCHITECT**: Technical design
573
+
574
+ Each persona uses the appropriate Claude model for optimal cost/quality.
575
+
576
+ ## Next Steps
577
+
578
+ 1. Add your stories to \`tooling/docs/sprint-status.yaml\`
579
+ 2. Create story specifications in \`tooling/docs/\`
580
+ 3. Run your first story: \`./run-story.sh <story-key>\`
581
+
582
+ ## Support
583
+
584
+ - Documentation: \`tooling/docs/\`
585
+ - Logs: \`tooling/.automation/logs/\`
586
+ - Checkpoints: \`tooling/.automation/checkpoints/\`
587
+ EOF
588
+
589
+ echo -e "${GREEN} ✅ README created${NC}"
590
+ }
591
+
592
+ ################################################################################
593
+ # Main Setup Flow
594
+ ################################################################################
595
+
596
+ main() {
597
+ print_banner
598
+
599
+ echo -e "${BLUE}This wizard will set up automated development workflow for your project.${NC}"
600
+ echo -e "${BLUE}You'll be guided through the configuration process.${NC}"
601
+ echo ""
602
+
603
+ if ! prompt_yes_no "Continue with setup?"; then
604
+ echo -e "${YELLOW}Setup cancelled.${NC}"
605
+ exit 0
606
+ fi
607
+
608
+ # STEP 1: Project Information
609
+ print_step "1" "Project Information"
610
+
611
+ local project_root=$(prompt_input "Enter project root directory:" "$PWD")
612
+ local project_name=$(prompt_input "Enter project name:" "$(basename "$project_root")")
613
+ local project_type=$(detect_project_type)
614
+
615
+ if ! prompt_yes_no "Is this correct? Type: $project_type"; then
616
+ project_type=$(prompt_input "Enter project type manually:" "$project_type")
617
+ fi
618
+
619
+ # STEP 1.5: Workflow Mode Selection
620
+ echo ""
621
+ echo -e "${CYAN}═══════════════════════════════════════════════════════════════${NC}"
622
+ echo -e "${CYAN} WORKFLOW MODE${NC}"
623
+ echo -e "${CYAN}═══════════════════════════════════════════════════════════════${NC}"
624
+ echo ""
625
+ echo -e "${BLUE}Select your primary workflow mode:${NC}"
626
+ echo ""
627
+ echo -e " ${YELLOW}1. Greenfield${NC} - New project development"
628
+ echo -e " Best for: Starting fresh, new features, full sprint workflow"
629
+ echo ""
630
+ echo -e " ${YELLOW}2. Brownfield${NC} - Existing codebase maintenance"
631
+ echo -e " Best for: Bug fixes, refactoring, tech debt, migrations"
632
+ echo ""
633
+ echo -e " ${YELLOW}3. Both${NC} - Full workflow support (recommended)"
634
+ echo -e " Best for: Teams doing both new features and maintenance"
635
+ echo ""
636
+
637
+ local mode_choice=$(prompt_input "Enter choice (1-3):" "3")
638
+
639
+ local workflow_mode="both"
640
+ case "$mode_choice" in
641
+ 1) workflow_mode="greenfield" ;;
642
+ 2) workflow_mode="brownfield" ;;
643
+ 3) workflow_mode="both" ;;
644
+ *) workflow_mode="both" ;;
645
+ esac
646
+
647
+ echo -e "${GREEN} Selected: $workflow_mode${NC}"
648
+
649
+ # STEP 2: Model Configuration
650
+ print_step "2" "Claude Model Configuration"
651
+
652
+ echo -e "${BLUE}For optimal cost/quality balance:${NC}"
653
+ echo -e "${BLUE} - Use Opus for code development and review (higher quality)${NC}"
654
+ echo -e "${BLUE} - Use Sonnet for planning and context creation (cost-effective)${NC}"
655
+ echo ""
656
+
657
+ local model_dev=$(prompt_input "Model for development/review:" "opus")
658
+ local model_planning=$(prompt_input "Model for planning/context:" "sonnet")
659
+
660
+ # Currency Selection
661
+ echo ""
662
+ echo -e "${BLUE}Select your preferred currency for cost display:${NC}"
663
+ echo -e " 1. USD - US Dollar (\$)"
664
+ echo -e " 2. EUR - Euro (€)"
665
+ echo -e " 3. GBP - British Pound (£)"
666
+ echo -e " 4. BRL - Brazilian Real (R\$)"
667
+ echo -e " 5. CAD - Canadian Dollar (C\$)"
668
+ echo -e " 6. AUD - Australian Dollar (A\$)"
669
+ echo ""
670
+
671
+ local currency_choice=$(prompt_input "Enter choice (1-6):" "1")
672
+
673
+ local display_currency="USD"
674
+ case "$currency_choice" in
675
+ 1) display_currency="USD" ;;
676
+ 2) display_currency="EUR" ;;
677
+ 3) display_currency="GBP" ;;
678
+ 4) display_currency="BRL" ;;
679
+ 5) display_currency="CAD" ;;
680
+ 6) display_currency="AUD" ;;
681
+ *) display_currency="USD" ;;
682
+ esac
683
+
684
+ echo -e "${GREEN} Selected: $display_currency${NC}"
685
+
686
+ # STEP 3: Directory Structure
687
+ print_step "3" "Directory Structure"
688
+
689
+ setup_directory_structure "$project_root" "$workflow_mode"
690
+
691
+ # STEP 4: Copy Scripts
692
+ print_step "4" "Core Scripts"
693
+
694
+ local source_dir="$SCRIPT_DIR"
695
+ copy_core_scripts "$project_root" "$source_dir"
696
+
697
+ # STEP 5: Configuration
698
+ print_step "5" "Configuration Files"
699
+
700
+ create_config_file "$project_root" "$project_name" "$project_type" "$model_dev" "$model_planning" "$display_currency"
701
+ create_agent_personas "$project_root"
702
+ create_sprint_status "$project_root" "$project_name"
703
+ create_documentation_standard "$project_root" "$source_dir"
704
+
705
+ # STEP 6: Checkpoint Service
706
+ print_step "6" "Checkpoint Service (Optional)"
707
+
708
+ echo -e "${BLUE}The checkpoint service monitors Claude sessions and auto-saves context.${NC}"
709
+ echo -e "${BLUE}This prevents losing progress when context windows fill up.${NC}"
710
+ echo ""
711
+
712
+ setup_checkpoint_service "$project_root"
713
+
714
+ # STEP 7: Documentation
715
+ print_step "7" "Documentation"
716
+
717
+ create_readme "$project_root" "$project_name"
718
+
719
+ # STEP 8: Finalize
720
+ print_step "8" "Setup Complete!"
721
+
722
+ echo -e "${GREEN}✅ Workflow initialization complete!${NC}"
723
+ echo ""
724
+ echo -e "${CYAN}═══════════════════════════════════════════════════════════════${NC}"
725
+ echo -e "${CYAN} NEXT STEPS${NC}"
726
+ echo -e "${CYAN}═══════════════════════════════════════════════════════════════${NC}"
727
+ echo ""
728
+ echo -e "${YELLOW}1. Review configuration:${NC}"
729
+ echo -e " ${BLUE}$project_root/tooling/.automation/config.sh${NC}"
730
+ echo ""
731
+ echo -e "${YELLOW}2. Add your first story:${NC}"
732
+ echo -e " ${BLUE}Edit: $project_root/tooling/docs/sprint-status.yaml${NC}"
733
+ echo -e " ${BLUE}Create: $project_root/tooling/docs/1-1-your-story.md${NC}"
734
+ echo ""
735
+ echo -e "${YELLOW}3. Run your first story:${NC}"
736
+ echo -e " ${BLUE}cd $project_root/tooling/scripts${NC}"
737
+ echo -e " ${BLUE}./run-story.sh 1-1${NC}"
738
+ echo ""
739
+ echo -e "${YELLOW}4. Read the workflow guide:${NC}"
740
+ echo -e " ${BLUE}$project_root/tooling/README.md${NC}"
741
+ echo ""
742
+ echo -e "${GREEN}Happy coding! 🚀${NC}"
743
+ echo ""
744
+ }
745
+
746
+ main "$@"