agileflow 2.91.0 → 2.92.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 (99) hide show
  1. package/CHANGELOG.md +5 -0
  2. package/README.md +3 -3
  3. package/lib/README.md +178 -0
  4. package/lib/codebase-indexer.js +31 -23
  5. package/lib/colors.js +190 -12
  6. package/lib/consent.js +232 -0
  7. package/lib/correlation.js +277 -0
  8. package/lib/error-codes.js +46 -0
  9. package/lib/errors.js +48 -6
  10. package/lib/file-cache.js +182 -0
  11. package/lib/format-error.js +156 -0
  12. package/lib/path-resolver.js +155 -7
  13. package/lib/paths.js +212 -20
  14. package/lib/placeholder-registry.js +205 -0
  15. package/lib/registry-di.js +358 -0
  16. package/lib/result-schema.js +363 -0
  17. package/lib/result.js +210 -0
  18. package/lib/session-registry.js +13 -0
  19. package/lib/session-state-machine.js +465 -0
  20. package/lib/validate-commands.js +308 -0
  21. package/lib/validate.js +116 -52
  22. package/package.json +1 -1
  23. package/scripts/af +34 -0
  24. package/scripts/agent-loop.js +63 -9
  25. package/scripts/agileflow-configure.js +2 -2
  26. package/scripts/agileflow-welcome.js +435 -23
  27. package/scripts/archive-completed-stories.sh +57 -11
  28. package/scripts/claude-tmux.sh +102 -0
  29. package/scripts/damage-control-bash.js +3 -70
  30. package/scripts/damage-control-edit.js +3 -20
  31. package/scripts/damage-control-write.js +3 -20
  32. package/scripts/dependency-check.js +310 -0
  33. package/scripts/get-env.js +11 -4
  34. package/scripts/lib/configure-detect.js +23 -1
  35. package/scripts/lib/configure-features.js +43 -2
  36. package/scripts/lib/context-formatter.js +771 -0
  37. package/scripts/lib/context-loader.js +699 -0
  38. package/scripts/lib/damage-control-utils.js +107 -0
  39. package/scripts/lib/json-utils.sh +162 -0
  40. package/scripts/lib/state-migrator.js +353 -0
  41. package/scripts/lib/story-state-machine.js +437 -0
  42. package/scripts/obtain-context.js +80 -1248
  43. package/scripts/pre-push-check.sh +46 -0
  44. package/scripts/precompact-context.sh +23 -10
  45. package/scripts/query-codebase.js +122 -14
  46. package/scripts/ralph-loop.js +5 -5
  47. package/scripts/session-manager.js +220 -42
  48. package/scripts/spawn-parallel.js +651 -0
  49. package/scripts/tui/blessed/data/watcher.js +20 -15
  50. package/scripts/tui/blessed/index.js +2 -2
  51. package/scripts/tui/blessed/panels/output.js +14 -8
  52. package/scripts/tui/blessed/panels/sessions.js +22 -15
  53. package/scripts/tui/blessed/panels/trace.js +14 -8
  54. package/scripts/tui/blessed/ui/help.js +3 -3
  55. package/scripts/tui/blessed/ui/screen.js +4 -4
  56. package/scripts/tui/blessed/ui/statusbar.js +5 -9
  57. package/scripts/tui/blessed/ui/tabbar.js +11 -11
  58. package/scripts/validators/component-validator.js +41 -14
  59. package/scripts/validators/json-schema-validator.js +11 -4
  60. package/scripts/validators/markdown-validator.js +1 -2
  61. package/scripts/validators/migration-validator.js +17 -5
  62. package/scripts/validators/security-validator.js +137 -33
  63. package/scripts/validators/story-format-validator.js +31 -10
  64. package/scripts/validators/test-result-validator.js +19 -4
  65. package/scripts/validators/workflow-validator.js +12 -5
  66. package/src/core/agents/codebase-query.md +24 -0
  67. package/src/core/commands/adr.md +114 -0
  68. package/src/core/commands/agent.md +120 -0
  69. package/src/core/commands/assign.md +145 -0
  70. package/src/core/commands/babysit.md +32 -5
  71. package/src/core/commands/changelog.md +118 -0
  72. package/src/core/commands/configure.md +42 -6
  73. package/src/core/commands/diagnose.md +114 -0
  74. package/src/core/commands/epic.md +113 -0
  75. package/src/core/commands/handoff.md +128 -0
  76. package/src/core/commands/help.md +75 -0
  77. package/src/core/commands/pr.md +96 -0
  78. package/src/core/commands/roadmap/analyze.md +400 -0
  79. package/src/core/commands/session/new.md +113 -6
  80. package/src/core/commands/session/spawn.md +197 -0
  81. package/src/core/commands/sprint.md +22 -0
  82. package/src/core/commands/status.md +74 -0
  83. package/src/core/commands/story.md +143 -4
  84. package/src/core/templates/agileflow-metadata.json +55 -2
  85. package/src/core/templates/plan-template.md +125 -0
  86. package/src/core/templates/story-lifecycle.md +213 -0
  87. package/src/core/templates/story-template.md +4 -0
  88. package/src/core/templates/tdd-test-template.js +241 -0
  89. package/tools/cli/commands/setup.js +86 -0
  90. package/tools/cli/installers/core/installer.js +94 -0
  91. package/tools/cli/installers/ide/_base-ide.js +20 -11
  92. package/tools/cli/installers/ide/codex.js +29 -47
  93. package/tools/cli/lib/config-manager.js +17 -2
  94. package/tools/cli/lib/content-transformer.js +271 -0
  95. package/tools/cli/lib/error-handler.js +14 -22
  96. package/tools/cli/lib/ide-error-factory.js +421 -0
  97. package/tools/cli/lib/ide-health-monitor.js +364 -0
  98. package/tools/cli/lib/ide-registry.js +114 -1
  99. package/tools/cli/lib/ui.js +14 -25
@@ -0,0 +1,400 @@
1
+ ---
2
+ description: Automated competitor analysis with feature gap identification
3
+ argument-hint: "[COMPETITORS=<keywords>] [FOCUS=all|features|security|perf|ux] [OUTPUT=matrix|report|stories]"
4
+ compact_context:
5
+ priority: high
6
+ preserve_rules:
7
+ - "ACTIVE COMMAND: /agileflow:roadmap:analyze - Competitor analysis orchestrator"
8
+ - "CRITICAL: Use WebSearch for each competitor (max 5 competitors)"
9
+ - "CRITICAL: Compare against current project capabilities from codebase"
10
+ - "MUST categorize features: must-have (2+ competitors) vs nice-to-have (1 competitor)"
11
+ - "MUST include confidence levels: HIGH (verified), MEDIUM (inferred), LOW (uncertain)"
12
+ - "Show preview BEFORE saving (diff-first pattern)"
13
+ - "Output to docs/08-project/roadmap-{YYYYMMDD}.md"
14
+ state_fields:
15
+ - competitors_list
16
+ - focus_area
17
+ - output_mode
18
+ - features_found
19
+ - gaps_identified
20
+ ---
21
+
22
+ # /agileflow:roadmap:analyze
23
+
24
+ Automated competitor analysis that uses WebSearch to find competitors, analyzes their features, compares against your current project capabilities, and generates a prioritized roadmap with must-have vs nice-to-have recommendations.
25
+
26
+ **Inspired by**: AutoClaude's roadmap feature (see ADR-0010)
27
+
28
+ ---
29
+
30
+ ## STEP 0: Gather Context (MANDATORY)
31
+
32
+ ```bash
33
+ node .agileflow/scripts/obtain-context.js roadmap
34
+ ```
35
+
36
+ This provides: project overview, tech stack, current features from README/CLAUDE.md.
37
+
38
+ ---
39
+
40
+ <!-- COMPACT_SUMMARY_START -->
41
+
42
+ ## Compact Summary - /agileflow:roadmap:analyze IS ACTIVE
43
+
44
+ **Command**: `/agileflow:roadmap:analyze` - Automated competitor analysis
45
+
46
+ **Quick Usage**:
47
+ ```
48
+ /agileflow:roadmap:analyze COMPETITORS=cursor,windsurf,aider FOCUS=features OUTPUT=report
49
+ ```
50
+
51
+ **What It Does**:
52
+ 1. Analyze current project capabilities
53
+ 2. WebSearch for each competitor
54
+ 3. Extract features from search results
55
+ 4. Generate comparison matrix
56
+ 5. Categorize: must-have vs nice-to-have
57
+ 6. Output roadmap report
58
+
59
+ **Arguments**:
60
+ - `COMPETITORS=<keywords>` - Comma-separated competitor names (default: auto-detect from project type)
61
+ - `FOCUS=all|features|security|perf|ux` - Analysis focus (default: all)
62
+ - `OUTPUT=matrix|report|stories` - Output format (default: report)
63
+
64
+ ### Tool Usage Examples
65
+
66
+ **WebSearch** (research competitor):
67
+ ```xml
68
+ <invoke name="WebSearch">
69
+ <parameter name="query">{competitor} features pricing 2026</parameter>
70
+ </invoke>
71
+ ```
72
+
73
+ **Write** (save roadmap):
74
+ ```xml
75
+ <invoke name="Write">
76
+ <parameter name="file_path">/path/to/docs/08-project/roadmap-YYYYMMDD.md</parameter>
77
+ <parameter name="content"># Competitive Roadmap Analysis...</parameter>
78
+ </invoke>
79
+ ```
80
+
81
+ **AskUserQuestion** (next steps):
82
+ ```xml
83
+ <invoke name="AskUserQuestion">
84
+ <parameter name="questions">[{"question": "What would you like to do with this roadmap?", "header": "Next Steps", "multiSelect": false, "options": [{"label": "Create epic for must-have features", "description": "Generate epic + stories in status.json"}, {"label": "Research specific feature", "description": "Deep-dive into one gap"}, {"label": "Save and done", "description": "Keep the report"}]}]</parameter>
85
+ </invoke>
86
+ ```
87
+
88
+ **Output**: `docs/08-project/roadmap-{YYYYMMDD}.md`
89
+ **Categories**: Must-have (2+ competitors), Nice-to-have (1 competitor), Competitive Advantage (we have, they don't)
90
+
91
+ <!-- COMPACT_SUMMARY_END -->
92
+
93
+ ---
94
+
95
+ ## How It Works
96
+
97
+ ```
98
+ ┌─────────────────────────────────────────────────────────────┐
99
+ │ USER: /agileflow:roadmap:analyze │
100
+ │ COMPETITORS=X,Y,Z FOCUS=features │
101
+ └─────────────────────────────────────────────────────────────┘
102
+
103
+
104
+ ┌─────────────────────────────────────────────────────────────┐
105
+ │ ROADMAP ANALYST │
106
+ │ 1. Parse arguments (COMPETITORS, FOCUS, OUTPUT) │
107
+ │ 2. Analyze current project from CLAUDE.md/README │
108
+ │ 3. WebSearch each competitor (max 5) │
109
+ │ 4. Extract features from search results │
110
+ │ 5. Build comparison matrix │
111
+ │ 6. Categorize gaps by priority │
112
+ │ 7. Generate roadmap report │
113
+ └─────────────────────────────────────────────────────────────┘
114
+
115
+ ┌───────────────────┼───────────────────┐
116
+ ▼ ▼ ▼
117
+ ┌───────────────┐ ┌───────────────┐ ┌───────────────┐
118
+ │ WebSearch │ │ WebSearch │ │ WebSearch │
119
+ │ Competitor 1 │ │ Competitor 2 │ │ Competitor 3 │
120
+ │ │ │ │ │ │
121
+ │ Features, │ │ Features, │ │ Features, │
122
+ │ pricing, │ │ pricing, │ │ pricing, │
123
+ │ strengths │ │ strengths │ │ strengths │
124
+ └───────────────┘ └───────────────┘ └───────────────┘
125
+ │ │ │
126
+ └───────────────────┼───────────────────┘
127
+
128
+ ┌─────────────────────────────────────────────────────────────┐
129
+ │ COMPARISON ENGINE │
130
+ │ • Map features across competitors │
131
+ │ • Identify gaps (they have, we don't) │
132
+ │ • Identify advantages (we have, they don't) │
133
+ │ • Must-have: 2+ competitors have it │
134
+ │ • Nice-to-have: 1 competitor has it │
135
+ └─────────────────────────────────────────────────────────────┘
136
+
137
+
138
+ ┌─────────────────────────────────────────────────────────────┐
139
+ │ ROADMAP REPORT │
140
+ │ 📊 Competitors Analyzed: 3 │
141
+ │ 🎯 Must-Have Gaps: 4 features │
142
+ │ 💡 Nice-to-Have: 6 features │
143
+ │ 🏆 Competitive Advantages: 2 features │
144
+ │ 📋 Feature Matrix with checkmarks │
145
+ │ 🚀 Recommended Next Steps │
146
+ └─────────────────────────────────────────────────────────────┘
147
+ ```
148
+
149
+ ---
150
+
151
+ ## Prompt
152
+
153
+ **ROLE**: Roadmap Analyst
154
+
155
+ You analyze competitor products via WebSearch and compare them against the current project to identify feature gaps and competitive advantages. Your output is an actionable roadmap prioritizing must-have features.
156
+
157
+ ---
158
+
159
+ ## Workflow Phases
160
+
161
+ ### Phase 1: Parse Arguments & Validate
162
+
163
+ 1. Extract COMPETITORS, FOCUS, OUTPUT from arguments
164
+ 2. If COMPETITORS not provided:
165
+ - Read CLAUDE.md/README.md to understand project type
166
+ - Suggest 3-5 likely competitors based on project category
167
+ - Ask user to confirm or provide alternatives
168
+
169
+ **Auto-detection heuristics:**
170
+ | Project Type | Likely Competitors |
171
+ |--------------|-------------------|
172
+ | CLI tool for AI coding | cursor, windsurf, aider, copilot |
173
+ | React component library | shadcn, radix, chakra, mantine |
174
+ | API framework | fastapi, express, hono, elysia |
175
+ | Documentation site | docusaurus, nextra, fumadocs, gitbook |
176
+
177
+ ### Phase 2: Analyze Current Project
178
+
179
+ 1. Read CLAUDE.md and README.md
180
+ 2. Extract:
181
+ - Project name and description
182
+ - Key features (look for feature lists, bullet points)
183
+ - Tech stack
184
+ - Target audience
185
+ 3. Create internal feature list for comparison
186
+
187
+ ### Phase 3: Competitor Research (WebSearch)
188
+
189
+ For each competitor (max 5):
190
+
191
+ ```xml
192
+ <invoke name="WebSearch">
193
+ <parameter name="query">{competitor} features pricing comparison 2026</parameter>
194
+ </invoke>
195
+ ```
196
+
197
+ Extract from results:
198
+ - Feature list
199
+ - Pricing model (free/paid/freemium)
200
+ - Key strengths mentioned
201
+ - Target audience
202
+ - Notable limitations
203
+
204
+ **Important**: Include sources with URLs in final report.
205
+
206
+ ### Phase 4: Feature Matrix Generation
207
+
208
+ Build comparison table:
209
+
210
+ | Feature Category | Feature | Our Project | Comp 1 | Comp 2 | Comp 3 |
211
+ |------------------|---------|-------------|--------|--------|--------|
212
+ | Core | Feature A | Y | Y | Y | Y |
213
+ | Core | Feature B | N | Y | Y | N |
214
+ | Advanced | Feature C | Y | N | N | N |
215
+
216
+ Legend:
217
+ - Y = Has feature
218
+ - N = Doesn't have feature
219
+ - ? = Unknown/unclear
220
+
221
+ ### Phase 5: Gap Analysis & Prioritization
222
+
223
+ **Must-Have (Priority 1)**:
224
+ - Features that 2+ competitors have
225
+ - We don't have
226
+ - High impact for users
227
+
228
+ **Nice-to-Have (Priority 2)**:
229
+ - Features only 1 competitor has
230
+ - OR features that are niche/specialized
231
+ - Lower impact but differentiating
232
+
233
+ **Competitive Advantages**:
234
+ - Features WE have that competitors lack
235
+ - Highlight these as strengths
236
+
237
+ ### Phase 6: Output Generation
238
+
239
+ **Show preview BEFORE saving (diff-first).**
240
+
241
+ Generate report following the Output Template below.
242
+
243
+ Ask for confirmation:
244
+ ```xml
245
+ <invoke name="AskUserQuestion">
246
+ <parameter name="questions">[{"question": "Save this roadmap analysis?", "header": "Confirm", "multiSelect": false, "options": [{"label": "Yes, save to docs/08-project/", "description": "Write roadmap-YYYYMMDD.md"}, {"label": "Modify first", "description": "I want to adjust something"}, {"label": "Cancel", "description": "Don't save"}]}]</parameter>
247
+ </invoke>
248
+ ```
249
+
250
+ ### Phase 7: Optional Artifact Creation (if OUTPUT=stories)
251
+
252
+ If user selected OUTPUT=stories:
253
+ 1. Create epic for "Competitive Feature Parity"
254
+ 2. Generate stories for each must-have feature
255
+ 3. Add to status.json
256
+
257
+ ---
258
+
259
+ ## Output Template
260
+
261
+ ```markdown
262
+ # Competitive Roadmap Analysis
263
+
264
+ **Generated**: {YYYY-MM-DD}
265
+ **Project**: {project name}
266
+ **Competitors Analyzed**: {competitor1}, {competitor2}, {competitor3}
267
+ **Focus Area**: {focus}
268
+
269
+ ---
270
+
271
+ ## Executive Summary
272
+
273
+ {2-3 paragraph overview of findings}
274
+
275
+ Key findings:
276
+ - {X} features where we lag behind competitors (must-have gaps)
277
+ - {Y} features unique to single competitors (nice-to-have)
278
+ - {Z} features where we have competitive advantage
279
+
280
+ ---
281
+
282
+ ## Current Project Capabilities
283
+
284
+ **Project**: {name}
285
+ **Description**: {from README/CLAUDE.md}
286
+
287
+ **Current Features**:
288
+ - {Feature 1}
289
+ - {Feature 2}
290
+ - {Feature 3}
291
+
292
+ ---
293
+
294
+ ## Competitor Analysis
295
+
296
+ ### {Competitor 1}
297
+
298
+ **Search Query**: "{query used}"
299
+ **Key Features**:
300
+ - {Feature A}
301
+ - {Feature B}
302
+ - {Feature C}
303
+
304
+ **Strengths**: {what they do well}
305
+ **Weaknesses**: {gaps or limitations}
306
+ **Pricing**: {model if found}
307
+
308
+ ### {Competitor 2}
309
+
310
+ [Same structure]
311
+
312
+ ### {Competitor 3}
313
+
314
+ [Same structure]
315
+
316
+ ---
317
+
318
+ ## Feature Comparison Matrix
319
+
320
+ | Category | Feature | {Project} | {Comp1} | {Comp2} | {Comp3} | Gap Type |
321
+ |----------|---------|-----------|---------|---------|---------|----------|
322
+ | Core | Feature A | Y | Y | Y | Y | None |
323
+ | Core | Feature B | N | Y | Y | N | Must-Have |
324
+ | Core | Feature C | N | Y | N | N | Nice-to-Have |
325
+ | Advanced | Feature D | Y | N | N | N | Advantage |
326
+
327
+ ---
328
+
329
+ ## Recommendations
330
+
331
+ ### Must-Have Features (High Priority)
332
+
333
+ Features that 2+ competitors have that we lack:
334
+
335
+ 1. **{Feature Name}**
336
+ - Found in: {Competitor1}, {Competitor2}
337
+ - Impact: {why users need this}
338
+ - Effort estimate: {Low/Medium/High}
339
+
340
+ 2. **{Feature Name}**
341
+ - Found in: {Competitor1}, {Competitor3}
342
+ - Impact: {why users need this}
343
+ - Effort estimate: {Low/Medium/High}
344
+
345
+ ### Nice-to-Have Features (Medium Priority)
346
+
347
+ Unique features from single competitors worth considering:
348
+
349
+ 1. **{Feature Name}**
350
+ - Found in: {Competitor only}
351
+ - Impact: {potential value}
352
+ - Effort estimate: {Low/Medium/High}
353
+
354
+ ### Competitive Advantages (Maintain & Promote)
355
+
356
+ Features we have that competitors lack:
357
+
358
+ 1. **{Feature Name}**
359
+ - Our advantage over: {all/specific competitors}
360
+ - Why it matters: {user value}
361
+
362
+ ---
363
+
364
+ ## Suggested Next Steps
365
+
366
+ - [ ] Prioritize must-have features for next quarter
367
+ - [ ] Create epic for competitive feature parity
368
+ - [ ] Research implementation approaches for top 3 gaps
369
+ - [ ] Document competitive advantages in marketing materials
370
+
371
+ ---
372
+
373
+ ## Sources
374
+
375
+ - [{Competitor 1} - {page title}]({url})
376
+ - [{Competitor 2} - {page title}]({url})
377
+ - [{Competitor 3} - {page title}]({url})
378
+
379
+ ---
380
+
381
+ *Generated by /agileflow:roadmap:analyze on {date}*
382
+ ```
383
+
384
+ ---
385
+
386
+ ## Anti-Patterns
387
+
388
+ - Search too many competitors (>5 = slow, unfocused)
389
+ - Skip project analysis (can't compare without baseline)
390
+ - Save without preview (diff-first is mandatory)
391
+ - Vague feature descriptions ("better UX" vs "keyboard shortcuts for all actions")
392
+ - Missing sources (always include WebSearch URLs)
393
+
394
+ ---
395
+
396
+ ## Related Commands
397
+
398
+ - `/agileflow:ideate` - Generate improvement ideas from internal analysis
399
+ - `/agileflow:research:ask` - Generate detailed research prompts
400
+ - `/agileflow:epic` - Create epic for implementing roadmap items
@@ -43,7 +43,23 @@ git rev-parse --is-inside-work-tree
43
43
 
44
44
  If not in a git repo, display error and exit.
45
45
 
46
- ### Step 2: Run Session Manager to Get Current State
46
+ ### Step 1.5: Check if Inside Tmux Session
47
+
48
+ ```bash
49
+ # Check if $TMUX environment variable is set
50
+ echo $TMUX
51
+ ```
52
+
53
+ **If INSIDE tmux** (TMUX is not empty):
54
+ - Use the simplified tmux add-window flow (see Step 2B below)
55
+ - This adds a new window to the CURRENT tmux session instead of creating external worktree
56
+
57
+ **If NOT inside tmux**:
58
+ - Continue with the standard flow (Step 2A below)
59
+
60
+ ### Step 2A: Standard Flow (NOT in tmux)
61
+
62
+ Run Session Manager to Get Current State:
47
63
 
48
64
  ```bash
49
65
  node .agileflow/scripts/session-manager.js status
@@ -51,7 +67,48 @@ node .agileflow/scripts/session-manager.js status
51
67
 
52
68
  Parse the JSON output to understand current sessions.
53
69
 
54
- ### Step 3: Present Options with AskUserQuestion
70
+ ### Step 2B: Tmux Flow (INSIDE tmux)
71
+
72
+ When inside tmux, use the simplified add-window flow:
73
+
74
+ ```
75
+ AskUserQuestion:
76
+ question: "Name for the new session window?"
77
+ header: "New window"
78
+ multiSelect: false
79
+ options:
80
+ - label: "Auto-generate name"
81
+ description: "Creates parallel-{timestamp} automatically"
82
+ - label: "auth"
83
+ description: "Authentication work"
84
+ - label: "feature"
85
+ description: "New feature development"
86
+ - label: "bugfix"
87
+ description: "Bug fixing"
88
+ ```
89
+
90
+ Then run:
91
+
92
+ ```bash
93
+ # If auto-generate selected:
94
+ node .agileflow/scripts/spawn-parallel.js add-window
95
+
96
+ # If named option selected:
97
+ node .agileflow/scripts/spawn-parallel.js add-window --name {selected_name}
98
+
99
+ # If "Other" with custom input:
100
+ node .agileflow/scripts/spawn-parallel.js add-window --name {custom_name}
101
+ ```
102
+
103
+ The script will:
104
+ 1. Create a new git worktree
105
+ 2. Add a new tmux window to the current session
106
+ 3. Start Claude in that window
107
+ 4. Output the Alt+N shortcut to switch to it
108
+
109
+ Display success and exit - skip remaining steps.
110
+
111
+ ### Step 3: Present Options with AskUserQuestion (Standard flow only)
55
112
 
56
113
  Use AskUserQuestion to let user choose how to create the session:
57
114
 
@@ -187,11 +244,58 @@ To switch to this session, run:
187
244
 
188
245
  ## ⚠️ COMPACT SUMMARY - /agileflow:session:new IS ACTIVE
189
246
 
190
- **CRITICAL**: This command creates new parallel sessions with git worktrees. Three-step process: validate → present options → create.
247
+ **CRITICAL**: This command creates new parallel sessions with git worktrees.
248
+
249
+ **TWO MODES:**
250
+ 1. **In tmux**: Adds a new window to current session (fast, Alt+N to switch)
251
+ 2. **Not in tmux**: Creates worktree with /add-dir navigation
252
+
253
+ ---
254
+
255
+ ### 🚨 RULE #0: CHECK IF IN TMUX FIRST
256
+
257
+ ```bash
258
+ echo $TMUX
259
+ ```
260
+
261
+ **If TMUX is NOT empty** → Use TMUX FLOW (Rule #1B)
262
+ **If TMUX is empty** → Use STANDARD FLOW (Rule #1A onwards)
263
+
264
+ ---
265
+
266
+ ### 🚨 RULE #1B: TMUX FLOW (when in tmux)
267
+
268
+ Ask for session name:
269
+ ```xml
270
+ <invoke name="AskUserQuestion">
271
+ <parameter name="questions">[{
272
+ "question": "Name for the new session window?",
273
+ "header": "New window",
274
+ "multiSelect": false,
275
+ "options": [
276
+ {"label": "Auto-generate name", "description": "Creates parallel-{timestamp} automatically"},
277
+ {"label": "auth", "description": "Authentication work"},
278
+ {"label": "feature", "description": "New feature development"},
279
+ {"label": "bugfix", "description": "Bug fixing"}
280
+ ]
281
+ }]</parameter>
282
+ </invoke>
283
+ ```
284
+
285
+ Then run:
286
+ ```bash
287
+ # Auto-generate:
288
+ node .agileflow/scripts/spawn-parallel.js add-window
289
+
290
+ # Named:
291
+ node .agileflow/scripts/spawn-parallel.js add-window --name {name}
292
+ ```
293
+
294
+ The script outputs the Alt+N shortcut. **DONE - skip remaining rules.**
191
295
 
192
296
  ---
193
297
 
194
- ### 🚨 RULE #1: VALIDATE PREREQUISITES
298
+ ### 🚨 RULE #1A: VALIDATE PREREQUISITES (standard flow)
195
299
 
196
300
  Before doing anything, check:
197
301
  ```bash
@@ -475,8 +579,11 @@ To switch to this session, run:
475
579
  ### REMEMBER AFTER COMPACTION
476
580
 
477
581
  - `/agileflow:session:new` IS ACTIVE
478
- - ALWAYS validate git repo first
479
- - Present 3 options: auto-create / named / existing branch
582
+ - **CHECK $TMUX FIRST** - determines which flow to use
583
+ - **In tmux**: Use `spawn-parallel.js add-window` fast, Alt+N to switch
584
+ - **Not in tmux**: Standard worktree flow → /add-dir to switch
585
+ - ALWAYS validate git repo first (for standard flow)
586
+ - Present 3 options: auto-create / named / existing branch (standard flow)
480
587
  - Each option leads to different flow
481
588
  - Use AskUserQuestion for user selections
482
589
  - Handle all error cases (directory, branch, git)