agileflow 2.51.0 → 2.56.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 (90) hide show
  1. package/README.md +80 -460
  2. package/package.json +18 -3
  3. package/scripts/agileflow-configure.js +134 -63
  4. package/scripts/agileflow-welcome.js +161 -31
  5. package/scripts/generators/agent-registry.js +45 -57
  6. package/scripts/generators/command-registry.js +48 -32
  7. package/scripts/generators/index.js +2 -6
  8. package/scripts/generators/inject-babysit.js +9 -2
  9. package/scripts/generators/inject-help.js +3 -1
  10. package/scripts/generators/inject-readme.js +7 -3
  11. package/scripts/generators/skill-registry.js +60 -33
  12. package/scripts/get-env.js +13 -12
  13. package/scripts/lib/frontmatter-parser.js +82 -0
  14. package/scripts/obtain-context.js +79 -26
  15. package/scripts/session-coordinator.sh +232 -0
  16. package/scripts/session-manager.js +512 -0
  17. package/src/core/agents/orchestrator.md +275 -0
  18. package/src/core/commands/adr.md +38 -16
  19. package/src/core/commands/agent.md +39 -22
  20. package/src/core/commands/assign.md +17 -0
  21. package/src/core/commands/auto.md +60 -46
  22. package/src/core/commands/babysit.md +302 -637
  23. package/src/core/commands/baseline.md +20 -0
  24. package/src/core/commands/blockers.md +33 -48
  25. package/src/core/commands/board.md +19 -0
  26. package/src/core/commands/changelog.md +20 -0
  27. package/src/core/commands/ci.md +17 -0
  28. package/src/core/commands/context.md +43 -40
  29. package/src/core/commands/debt.md +76 -45
  30. package/src/core/commands/deploy.md +20 -0
  31. package/src/core/commands/deps.md +40 -46
  32. package/src/core/commands/diagnose.md +24 -18
  33. package/src/core/commands/docs.md +18 -0
  34. package/src/core/commands/epic.md +31 -0
  35. package/src/core/commands/feedback.md +33 -21
  36. package/src/core/commands/handoff.md +29 -0
  37. package/src/core/commands/help.md +16 -7
  38. package/src/core/commands/impact.md +31 -61
  39. package/src/core/commands/metrics.md +17 -35
  40. package/src/core/commands/packages.md +21 -0
  41. package/src/core/commands/pr.md +15 -0
  42. package/src/core/commands/readme-sync.md +42 -9
  43. package/src/core/commands/research.md +58 -11
  44. package/src/core/commands/retro.md +42 -50
  45. package/src/core/commands/review.md +22 -27
  46. package/src/core/commands/session/end.md +53 -297
  47. package/src/core/commands/session/history.md +38 -257
  48. package/src/core/commands/session/init.md +44 -446
  49. package/src/core/commands/session/new.md +152 -0
  50. package/src/core/commands/session/resume.md +51 -447
  51. package/src/core/commands/session/status.md +32 -244
  52. package/src/core/commands/sprint.md +33 -0
  53. package/src/core/commands/status.md +18 -0
  54. package/src/core/commands/story-validate.md +32 -0
  55. package/src/core/commands/story.md +21 -6
  56. package/src/core/commands/template.md +18 -0
  57. package/src/core/commands/tests.md +22 -0
  58. package/src/core/commands/update.md +72 -58
  59. package/src/core/commands/validate-expertise.md +25 -37
  60. package/src/core/commands/velocity.md +33 -74
  61. package/src/core/commands/verify.md +16 -0
  62. package/src/core/experts/documentation/expertise.yaml +16 -2
  63. package/src/core/skills/agileflow-retro-facilitator/SKILL.md +57 -219
  64. package/src/core/skills/agileflow-retro-facilitator/cookbook/4ls.md +86 -0
  65. package/src/core/skills/agileflow-retro-facilitator/cookbook/glad-sad-mad.md +79 -0
  66. package/src/core/skills/agileflow-retro-facilitator/cookbook/start-stop-continue.md +142 -0
  67. package/src/core/skills/agileflow-retro-facilitator/prompts/action-items.md +83 -0
  68. package/src/core/skills/writing-skills/SKILL.md +352 -0
  69. package/src/core/skills/writing-skills/testing-skills-with-subagents.md +232 -0
  70. package/tools/cli/agileflow-cli.js +4 -2
  71. package/tools/cli/commands/config.js +20 -13
  72. package/tools/cli/commands/doctor.js +25 -9
  73. package/tools/cli/commands/list.js +10 -6
  74. package/tools/cli/commands/setup.js +54 -3
  75. package/tools/cli/commands/status.js +6 -8
  76. package/tools/cli/commands/uninstall.js +5 -5
  77. package/tools/cli/commands/update.js +51 -7
  78. package/tools/cli/installers/core/installer.js +8 -4
  79. package/tools/cli/installers/ide/_base-ide.js +58 -1
  80. package/tools/cli/installers/ide/claude-code.js +3 -61
  81. package/tools/cli/installers/ide/codex.js +440 -0
  82. package/tools/cli/installers/ide/cursor.js +21 -51
  83. package/tools/cli/installers/ide/manager.js +2 -6
  84. package/tools/cli/installers/ide/windsurf.js +20 -50
  85. package/tools/cli/lib/content-injector.js +26 -49
  86. package/tools/cli/lib/docs-setup.js +3 -2
  87. package/tools/cli/lib/npm-utils.js +39 -12
  88. package/tools/cli/lib/ui.js +31 -10
  89. package/tools/cli/lib/version-checker.js +3 -3
  90. package/tools/postinstall.js +2 -3
@@ -33,19 +33,66 @@ node .agileflow/scripts/obtain-context.js research
33
33
  ## Compact Summary
34
34
  - **Command**: /agileflow:research-init
35
35
  - **Purpose**: Initialize or save research notes with structured analysis
36
- - **Objective**: Evaluate and organize research findings
37
- - **TodoList**: Required for tracking 5-step workflow
38
- - **Key Actions**:
39
- 1. Ensure docs/10-research/ exists
40
- 2. Create/update docs/10-research/README.md (index table: Date | Topic | Path | Summary)
41
- 3. If pasted research content provided: save to docs/10-research/<YYYYMMDD>-<slug>.md
42
- 4. Add entry to README.md index table (newest first)
43
- 5. Show preview and wait for YES/NO confirmation
44
- - **File Format**: <YYYYMMDD>-<slug>.md (e.g., 20251222-session-tracking.md)
36
+ - **Key Actions**: Ensure docs/10-research/ exists → Create/update index → Save research file → Add index entry → Confirm
37
+
38
+ ### Tool Usage Examples
39
+
40
+ **TodoWrite** (to track research initialization workflow):
41
+ ```xml
42
+ <invoke name="TodoWrite">
43
+ <parameter name="content">1. Ensure docs/10-research/ exists
44
+ 2. Create/update docs/10-research/README.md (if missing)
45
+ 3. If pasted research content provided: save to docs/10-research/<YYYYMMDD>-<slug>.md
46
+ 4. Add entry to README.md index table
47
+ 5. Show preview and wait for YES/NO confirmation</parameter>
48
+ <parameter name="status">in-progress</parameter>
49
+ <parameter name="activeForm">1</parameter>
50
+ </invoke>
51
+ ```
52
+
53
+ **Write** (to create research file):
54
+ ```xml
55
+ <invoke name="Write">
56
+ <parameter name="file_path">/full/path/to/docs/10-research/20251222-session-tracking.md</parameter>
57
+ <parameter name="content"># Session Tracking
58
+
59
+ **Research Date**: 2025-12-22
60
+ **Topic**: Session tracking implementation
61
+ **Sources**: [source citations]
62
+
63
+ ## Summary
64
+ [2-3 paragraph executive summary]
65
+
66
+ ## Key Findings
67
+ - [Main point 1]
68
+ - [Main point 2]
69
+
70
+ ## References
71
+ - [Source 1]
72
+ - [Source 2]</parameter>
73
+ </invoke>
74
+ ```
75
+
76
+ **Edit** (to update README.md index):
77
+ ```xml
78
+ <invoke name="Edit">
79
+ <parameter name="file_path">/full/path/to/docs/10-research/README.md</parameter>
80
+ <parameter name="old_string">| 2025-12-20 | Old Topic | 20251220-old-topic.md | Summary |</parameter>
81
+ <parameter name="new_string">| 2025-12-22 | Session Tracking | 20251222-session-tracking.md | Research findings about tracking sessions |
82
+ | 2025-12-20 | Old Topic | 20251220-old-topic.md | Summary |</parameter>
83
+ </invoke>
84
+ ```
85
+
86
+ **AskUserQuestion** (for confirmation):
87
+ ```xml
88
+ <invoke name="AskUserQuestion">
89
+ <parameter name="questions">[{"question": "Save this research file?", "header": "Preview", "multiSelect": false, "options": [{"label": "Yes, save to docs/10-research/", "description": "Write the research file and update index"}, {"label": "No, abort", "description": "Cancel without saving"}]}]</parameter>
90
+ </invoke>
91
+ ```
92
+
93
+ - **File Format**: <YYYYMMDD>-<slug>.md
45
94
  - **Index Table**: Date | Topic | Path | Summary in README.md
46
- - **Output**: Research note saved to docs/10-research/ with index entry
47
95
  - **Workflow**: Diff-first, then YES/NO confirmation
48
- - **Related**: docs/10-research/ structure, research organization
49
96
  <!-- COMPACT_SUMMARY_END -->
50
97
 
51
98
  ---
@@ -24,70 +24,62 @@ Automated retrospective generator that analyzes patterns and surfaces insights f
24
24
 
25
25
  ## Compact Summary
26
26
 
27
- **Command Purpose**: Automated retrospective generator that analyzes AgileFlow project data to surface insights, patterns, and actionable improvements using the Start/Stop/Continue format.
27
+ **Command Purpose**: Automated retrospective generator analyzing AgileFlow data to surface insights, patterns, and actionable improvements using Start/Stop/Continue format.
28
28
 
29
29
  **Role**: Retrospective Facilitator
30
30
 
31
31
  **Critical Behavioral Rules**:
32
- - ALWAYS create TodoWrite task list at the start (9 steps: load data, analyze wins, analyze improvements, detect patterns, generate actions, create celebration section, generate report, save file, update index)
32
+ - ALWAYS create TodoWrite task list at start (9 steps)
33
33
  - Focus on TEAM-LEVEL patterns, never individual blame
34
- - Balance positive insights (Continue) with improvements (Start/Stop)
35
- - Use DATA to drive insights - no subjective opinions without evidence
34
+ - Balance positive (Continue) with improvements (Start/Stop)
35
+ - Use DATA to drive insights (no subjective opinions without evidence)
36
36
  - Prioritize action items by impact (HIGH/MEDIUM/LOW)
37
37
  - ALWAYS celebrate wins, even small ones
38
- - End with forward-looking predictions for next sprint
39
38
  - Save automatically to docs/08-project/retrospectives/ unless SAVE=false
40
39
 
41
40
  **Key Data Sources**:
42
41
  1. docs/09-agents/bus/log.jsonl - Event patterns, status transitions, blocking events
43
- 2. docs/09-agents/status.json - Current state snapshot, WIP levels, owner distribution
42
+ 2. docs/09-agents/status.json - Current state, WIP levels, owner distribution
44
43
  3. docs/06-stories/**/US-*.md - Story completion, estimates vs actuals, AC rates
45
- 4. Velocity data - Points completed, throughput trends from bus analysis
44
+ 4. Velocity data - Points completed, throughput trends
45
+
46
+ **TodoWrite Task List** (create at start):
47
+ ```
48
+ TodoWrite tool usage:
49
+ - content: "1. Load data sources\n2. Analyze what went well\n3. Analyze improvements\n4. Detect patterns\n5. Generate action items\n6. Create celebration section\n7. Generate report\n8. Save file\n9. Update index"
50
+ - status: "in-progress"
51
+ - activeForm: true
52
+ ```
46
53
 
47
54
  **Workflow Steps**:
48
- 1. Load and analyze data sources (bus logs, status, stories, velocity)
49
- 2. Identify "What Went Well" patterns (high velocity, fast cycle times, epic completions, good estimation, balanced workload)
50
- 3. Identify "What Needs Improvement" patterns (velocity drops, long cycles, high WIP, frequent blocking, poor estimation, bottlenecks)
51
- 4. Detect advanced patterns (recurring blockers, day-of-week trends, handoff patterns, story size correlations)
52
- 5. Generate prioritized action items (HIGH: immediate problems, MEDIUM: process improvements, LOW: long-term)
53
- 6. Create celebration moments section (epic completions, velocity milestones, zero bugs, fast deliveries)
54
- 7. Generate comprehensive ASCII report with sprint summary, insights, actions, team contributions, predictions
55
- 8. Save to docs/08-project/retrospectives/retro-YYYYMMDD.md
56
- 9. Update retrospectives/README.md index
57
-
58
- **Output Format Requirements**:
59
- - DEFAULT: ASCII box format with Unicode characters (╔═╗║╚╝)
60
- - Sections: Sprint Summary → What Went Well → What Needs Improvement → Action Items → Team Contributions → Predictions
61
- - Use icons: ✅ (Continue), ⚠️ (Improvement), 🛑 (Stop), ▶️ (Start), 🎯 (Actions), 📊 (Summary), 🔮 (Predictions), 🎉 (Celebrate)
62
- - Action items as checkboxes [ ] for tracking
63
- - Include velocity trends, cycle times, completion rates, blocking events
64
- - Show team contributions as horizontal bar charts
65
- - End with "Next Steps" recommendations
66
-
67
- **Pattern Analysis Examples**:
68
- - CONTINUE: Velocity increased, fast cycle times (<2d), zero blocked stories, epic completions, good estimation (<20% variance), balanced workload
69
- - START/STOP: Velocity drops, long cycle times (>5d), high WIP, frequent blocking, long review times, poor estimation (>50% variance), agent bottlenecks, stale stories (>10d in-progress)
70
-
71
- **Optional Inputs**:
72
- - TIMEFRAME: sprint|2weeks|30d|90d (default: 2weeks)
73
- - EPIC: <EP_ID> (retrospective for specific epic only)
74
- - FORMAT: ascii|markdown|html (default: ascii)
75
- - SAVE: true|false (default: true)
76
-
77
- **Integration Points**:
78
- - After /agileflow:metrics to contextualize data
79
- - Before sprint planning to apply learnings
80
- - With /agileflow:velocity to use trends
81
- - In /agileflow:babysit to suggest at sprint boundaries
82
-
83
- **Success Criteria**:
84
- - Comprehensive data analysis from all 4 sources
85
- - Balanced Continue/Start/Stop sections (not all negative)
86
- - Specific, actionable items (not vague suggestions)
87
- - Celebration section highlights wins
88
- - Predictions based on current velocity and epic progress
89
- - File saved to retrospectives/ directory with date stamp
90
- - Index updated with latest retrospective entry
55
+ 1. Create TodoWrite task list → Load and analyze data sources
56
+ 2. Identify "What Went Well" patterns (velocity, cycles, completions, estimation, workload)
57
+ 3. Identify "What Needs Improvement" patterns (velocity drops, cycles, WIP, blocking, bottlenecks)
58
+ 4. Detect advanced patterns (recurring blockers, handoffs, story size correlations)
59
+ 5. Generate prioritized action items (HIGH/MEDIUM/LOW) Create celebration section
60
+ 6. Generate ASCII report Save to retrospectives/ Update index
61
+
62
+ **Inputs** (optional):
63
+ - `TIMEFRAME`: sprint|2weeks|30d|90d (default: 2weeks)
64
+ - `EPIC`: <EP_ID> (epic-specific retrospective)
65
+ - `FORMAT`: ascii|markdown|html (default: ascii)
66
+ - `SAVE`: true|false (default: true)
67
+
68
+ **Output Format**:
69
+ - ASCII box with Unicode (╔═╗║╚╝)
70
+ - Sections: Summary What Went Well What Needs Improvement → Actions → Team Contributions → Predictions
71
+ - Icons: ⚠️ 🛑 ▶️ 🎯 📊 🔮 🎉
72
+
73
+ **Example Usage**:
74
+ ```bash
75
+ /agileflow:retro
76
+ /agileflow:retro TIMEFRAME=30d
77
+ /agileflow:retro EPIC=EP-0010 FORMAT=markdown
78
+ ```
79
+
80
+ **Success Criteria**: Comprehensive data analysis, balanced Continue/Start/Stop, specific actionable items, celebration section, predictions, file saved with date stamp
81
+
82
+ **Integration**: After `/metrics`, before sprint planning, with `/velocity`, in `/babysit`
91
83
 
92
84
  <!-- COMPACT_SUMMARY_END -->
93
85
 
@@ -21,41 +21,36 @@ AI Code Reviewer that analyzes git diffs for quality, security, performance, and
21
21
  - **Provide specific fixes** - Include code snippets, not just descriptions
22
22
 
23
23
  ### Core Workflow
24
- 1. Get git diff: `git diff <BASE>...<BRANCH>`
24
+ 1. Get git diff: `git diff <BASE>...<BRANCH>` (shell command)
25
25
  2. Analyze changes across 6 categories: Code Quality, Security, Performance, Best Practices, Testing, Documentation
26
26
  3. Generate structured report with issue count by severity (CRITICAL/HIGH/MEDIUM/LOW)
27
27
  4. Calculate code quality score (0-100) with breakdown by category
28
- 5. Ask user about actions: auto-fix issues, create follow-up stories, block merge
28
+ 5. Optionally ask user to auto-fix issues, create follow-up stories, block merge
29
29
  6. Save report to `docs/08-project/code-reviews/<YYYYMMDD>-<BRANCH>.md`
30
30
 
31
- ### Key Files
32
- - **Input**: Git diff between BASE and BRANCH
33
- - **Custom rules**: `.agileflow/review-rules.md`, `docs/02-practices/code-standards.md`
31
+ ### Key Files & Parsing
32
+ - **Input**: Git diff between BASE and BRANCH (parse changed files and hunks)
33
+ - **Custom rules**: `.agileflow/review-rules.md`, `docs/02-practices/code-standards.md` (YAML/markdown parsing)
34
34
  - **Output**: `docs/08-project/code-reviews/<YYYYMMDD>-<BRANCH>.md`
35
35
 
36
36
  ### Optional Arguments
37
- - `BRANCH=<name>` - Branch to review (default: current)
38
- - `BASE=<branch>` - Base branch for comparison (default: main/master)
39
- - `FOCUS=all|security|performance|style|tests` - Review scope (default: all)
40
- - `SEVERITY=critical|high|medium|low|all` - Filter by severity (default: all)
41
-
42
- ### Security Checks
43
- - SQL injection, XSS vulnerabilities
44
- - Hardcoded secrets/credentials
45
- - Insecure dependencies, unsafe deserialization
46
- - Missing input validation, authentication/authorization issues
47
-
48
- ### Performance Checks
49
- - N+1 query problems
50
- - Inefficient algorithms (O(n²) vs O(n))
51
- - Missing database indexes
52
- - Memory leaks, large bundle sizes
53
-
54
- ### Quality Metrics
55
- - Cyclomatic complexity (threshold: 10)
56
- - Function length (target: <50 lines)
57
- - File length (target: <500 lines)
58
- - Test coverage (aim: >80%)
37
+ - `BRANCH`: <name> (branch to review, default: current)
38
+ - `BASE`: <branch> (base branch for comparison, default: main/master)
39
+ - `FOCUS`: all|security|performance|style|tests (review scope, default: all)
40
+ - `SEVERITY`: critical|high|medium|low|all (filter by severity, default: all)
41
+
42
+ ### Analysis Techniques
43
+ - **Static Analysis**: AST parsing for complexity, duplication detection
44
+ - **Pattern Matching**: Security regex patterns (hardcoded keys, SQL injection, XSS)
45
+ - **Code Metrics**: Cyclomatic complexity (threshold: 10), function length (<50 lines), file length (<500 lines)
46
+ - **Test Coverage**: Parse coverage reports (coverage/lcov.info) to map changed lines to tests
47
+
48
+ ### Example Usage**:
49
+ ```bash
50
+ /agileflow:ai-code-review
51
+ /agileflow:ai-code-review BRANCH=feature/auth BASE=main
52
+ /agileflow:ai-code-review FOCUS=security SEVERITY=critical
53
+ ```
59
54
 
60
55
  <!-- COMPACT_SUMMARY_END -->
61
56
 
@@ -3,344 +3,100 @@ description: Cleanly end session and record summary
3
3
  argument-hint: (no arguments)
4
4
  ---
5
5
 
6
- # End Session
6
+ # /agileflow:session:end
7
7
 
8
- You are running the `/agileflow:session:end` command to cleanly close the current AgileFlow session.
8
+ End the current session and optionally clean up the worktree.
9
9
 
10
- ## IMMEDIATE ACTIONS
11
-
12
- **Execute these steps NOW in order:**
13
-
14
- ### Step 1: Read session-state.json
15
- ```bash
16
- cat docs/09-agents/session-state.json
17
- ```
18
- If `current_session` is null, display "No active session" and stop.
19
-
20
- ### Step 2: Get end timestamp and calculate duration
21
- ```bash
22
- date -u +%Y-%m-%dT%H:%M:%SZ
23
- ```
24
- Calculate duration from `current_session.started_at` to now.
25
-
26
- ### Step 3: Get git activity since session start
27
- ```bash
28
- git log --oneline HEAD~20..HEAD 2>/dev/null | head -10
29
- git diff --stat --shortstat 2>/dev/null | tail -1
30
- ```
31
-
32
- ### Step 4: Check status.json for completed stories
33
- Read `docs/09-agents/status.json` and identify stories with `status: "done"` that were completed during this session.
34
-
35
- ### Step 5: Update session-state.json
36
- Use the Write tool to update the file:
37
- - Move `current_session` data to `last_session`
38
- - Add `ended_at` and `duration_minutes` to `last_session`
39
- - Add `stories_completed` array with story IDs completed this session
40
- - Set `current_session` to `null`
41
- - Append to `session_history` array (daily aggregate)
42
-
43
- ### Step 6: Display session summary
44
- Output a formatted summary showing:
45
- - Session duration
46
- - Stories completed
47
- - Commits made
48
- - What to work on next
49
-
50
- ## TODO LIST TRACKING
51
-
52
- **CRITICAL**: Immediately create a todo list using TodoWrite tool:
53
- ```
54
- 1. Read session-state.json (check for active session)
55
- 2. Calculate session duration
56
- 3. Get git activity
57
- 4. Check completed stories
58
- 5. Update session-state.json (move current to last)
59
- 6. Display session summary
60
- ```
10
+ ---
61
11
 
62
- ## When to Use
12
+ ## Purpose
63
13
 
64
- - End of work day
65
- - Before stepping away for extended time
66
- - After completing a major milestone
67
- - Before switching to a different project
14
+ When you're done with a session, this command:
15
+ - Removes the session's lock file (marks it inactive)
16
+ - Optionally removes the git worktree directory
17
+ - Updates the registry with last active timestamp
68
18
 
69
- ## Execution Flow
19
+ ## IMMEDIATE ACTIONS
70
20
 
71
- ### 1. Check Active Session
21
+ ### Step 1: Get Current Session
72
22
 
73
23
  ```bash
74
- if [ ! -f "docs/09-agents/session-state.json" ]; then
75
- echo "⚠️ No active session to end"
76
- echo ""
77
- echo "Run /agileflow:session:resume to start a session first"
78
- exit 0
79
- fi
80
-
81
- CURRENT_SESSION=$(jq -r '.current_session.id' docs/09-agents/session-state.json)
82
-
83
- if [ "$CURRENT_SESSION" == "null" ]; then
84
- echo "⚠️ No active session"
85
- exit 0
86
- fi
24
+ node .agileflow/scripts/session-manager.js status
87
25
  ```
88
26
 
89
- ### 2. Gather Session Metrics
27
+ If no current session is registered, display message and exit.
90
28
 
91
- ```bash
92
- # Session timing
93
- STARTED_AT=$(jq -r '.current_session.started_at' docs/09-agents/session-state.json)
94
- ENDED_AT=$(date -u +%Y-%m-%dT%H:%M:%SZ)
95
- DURATION=$(calculate_duration "$STARTED_AT" "$ENDED_AT")
29
+ ### Step 2: Present Options with AskUserQuestion
96
30
 
97
- # Git activity
98
- BASELINE_COMMIT=$(jq -r '.current_session.baseline_commit // "HEAD~50"' docs/09-agents/session-state.json)
99
- COMMITS=$(git rev-list --oneline $BASELINE_COMMIT..HEAD 2>/dev/null | head -20)
100
- COMMIT_COUNT=$(echo "$COMMITS" | grep -c . || echo "0")
101
-
102
- # Files changed
103
- FILES_CHANGED=$(git diff --stat $BASELINE_COMMIT..HEAD 2>/dev/null | tail -1)
104
31
  ```
105
-
106
- ### 3. Identify Completed Stories
107
-
108
- Check `docs/09-agents/status.json` for stories that changed to `completed` or `in-review` during this session:
109
-
110
- ```bash
111
- # Compare to session start snapshot
112
- # Identify stories that moved to completed/in-review
32
+ AskUserQuestion:
33
+ question: "End Session {id}?"
34
+ header: "End session"
35
+ multiSelect: false
36
+ options:
37
+ - label: "Yes, end session"
38
+ description: "Mark session inactive (keep worktree for later)"
39
+ - label: "End and delete worktree"
40
+ description: "Remove session and its directory completely"
41
+ - label: "Cancel"
42
+ description: "Keep session active"
113
43
  ```
114
44
 
115
- ### 4. Run Final Test Check (Optional)
45
+ Note: Don't show "delete worktree" option for main session (is_main: true).
116
46
 
117
- ```
118
- Run final test verification before ending session? [Y/n]: _
119
- ```
120
-
121
- If yes:
122
- ```
123
- 🧪 Running final tests...
124
- ✅ All passing (42/42)
47
+ ### Step 3a: If "End session" Selected
125
48
 
126
- Final test status recorded.
49
+ ```bash
50
+ node .agileflow/scripts/session-manager.js unregister {session_id}
127
51
  ```
128
52
 
129
- ### 5. Update Session State
130
-
131
- Update `docs/09-agents/session-state.json`:
132
-
133
- ```json
134
- {
135
- "current_session": null,
136
- "last_session": {
137
- "id": "sess-20251216-140000",
138
- "started_at": "2025-12-16T14:00:00Z",
139
- "ended_at": "2025-12-16T18:30:00Z",
140
- "duration_minutes": 270,
141
- "stories_completed": ["US-0043"],
142
- "stories_progressed": ["US-0044"],
143
- "final_test_status": "passing",
144
- "commits": ["abc123", "def456", "ghi789"],
145
- "files_changed": 12,
146
- "lines_added": 450,
147
- "lines_removed": 120
148
- },
149
- "session_history": [
150
- {
151
- "date": "2025-12-16",
152
- "sessions": 1,
153
- "total_duration_minutes": 270,
154
- "stories_completed": 1,
155
- "commits": 3,
156
- "test_regressions": 0
157
- },
158
- // ... previous days
159
- ]
160
- }
53
+ Display:
161
54
  ```
55
+ ✓ Session {id} ended
162
56
 
163
- ### 6. Display Session Summary
57
+ Branch: {branch}
58
+ Story: {story_id} (status unchanged)
59
+ Worktree kept at: {path}
164
60
 
61
+ To resume later: cd {path} && claude
165
62
  ```
166
- ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
167
- ✅ Session Ended
168
- ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
169
-
170
- Session: sess-20251216-140000
171
- Duration: 4 hours 30 minutes
172
- Date: December 16, 2025
173
63
 
174
- ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
175
- 📊 Accomplishments
176
- ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
64
+ ### Step 3b: If "End and delete worktree" Selected
177
65
 
178
- Stories Completed (1):
179
- US-0043: Add user profile settings page
180
-
181
- Stories Progressed (1):
182
- 🔄 US-0044: Implement password reset flow
183
- Progress: 2/4 acceptance criteria
184
-
185
- ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
186
- 📁 Code Changes
187
- ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
188
-
189
- Commits: 3
190
- abc123 - feat: add profile form component
191
- def456 - test: add profile validation tests
192
- ghi789 - fix: profile image upload
193
-
194
- Files changed: 12
195
- Lines: +450 / -120
196
-
197
- ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
198
- 🧪 Test Status
199
- ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
200
-
201
- Final: ✅ All Passing (42/42)
202
- No regressions introduced ✅
203
-
204
- ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
205
- 📈 Session Stats
206
- ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
207
-
208
- This session:
209
- • Duration: 4h 30m
210
- • Stories completed: 1
211
- • Commits: 3
212
- • Productivity: 0.22 stories/hour
213
-
214
- Today (all sessions):
215
- • Total time: 4h 30m
216
- • Stories completed: 1
217
- • Sessions: 1
218
-
219
- ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
220
- 📋 For Next Session
221
- ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
222
-
223
- Continue with:
224
- 🔄 US-0044: Implement password reset flow
225
- Remaining: Email template, Token validation
226
-
227
- Ready to pick up:
228
- • US-0045: Add email verification
229
- • US-0046: Create admin dashboard
230
-
231
- Run /agileflow:session:resume to start next session
232
-
233
- ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
66
+ ```bash
67
+ node .agileflow/scripts/session-manager.js delete {session_id} --remove-worktree
234
68
  ```
235
69
 
236
- ## Output Variations
237
-
238
- ### Session With Uncommitted Changes
70
+ Display:
239
71
  ```
240
- ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
241
- ⚠️ Uncommitted Changes Detected
242
- ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
72
+ ✓ Session {id} ended and removed
243
73
 
244
- You have 3 uncommitted files:
245
- M src/components/ProfileForm.tsx
246
- M src/api/user.ts
247
- ? src/utils/validation.ts
74
+ Branch: {branch}
75
+ Worktree removed: {path}
248
76
 
249
- Options:
250
- 1. Commit changes now
251
- 2. End session anyway (changes preserved)
252
- 3. Cancel and continue working
253
-
254
- Choice [1/2/3]: _
77
+ 💡 The branch still exists. To delete it:
78
+ git branch -d {branch}
255
79
  ```
256
80
 
257
- ### Short Session Warning
258
- ```
259
- ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
260
- 📊 Session Summary
261
- ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
81
+ ### Step 3c: If "Cancel" Selected
262
82
 
263
- Session Duration: 15 minutes
264
-
265
- ℹ️ Short session - minimal changes recorded.
266
-
267
- Commits: 0
268
- Stories completed: 0
269
-
270
- End this session? [y/N]: _
271
83
  ```
272
-
273
- ### Session With Failing Tests
84
+ Session remains active.
274
85
  ```
275
- ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
276
- ⚠️ Tests Failing
277
- ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
278
-
279
- Current test status: ❌ FAILING (40/42)
280
86
 
281
- Failed tests:
282
- ❌ auth.test.ts:42
283
- ❌ auth.test.ts:67
87
+ ## Main Session Warning
284
88
 
285
- Ending session with failing tests will:
286
- • Record "failing" as final test status
287
- • Flag potential regression for next session
89
+ If current session is the main project (is_main: true):
288
90
 
289
- Options:
290
- 1. Fix tests first (recommended)
291
- 2. End session with failing tests
292
- 3. Cancel
293
-
294
- Choice [1/2/3]: _
295
91
  ```
92
+ ⚠️ This is the main project session.
296
93
 
297
- ### Productive Session
298
- ```
299
- ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
300
- 🎉 Great Session!
301
- ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
302
-
303
- Duration: 6 hours
304
- Stories completed: 3
305
- Commits: 12
306
- Tests: ✅ All passing
307
-
308
- Above average productivity! 🚀
309
-
310
- Completed:
311
- ✅ US-0043: Add user profile settings page
312
- ✅ US-0044: Implement password reset flow
313
- ✅ US-0045: Add email verification
314
-
315
- ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
94
+ You can only end this session (mark inactive), not delete the directory.
95
+ The main project is not a worktree and cannot be removed.
316
96
  ```
317
97
 
318
98
  ## Related Commands
319
99
 
320
- | Command | Purpose |
321
- |---------|---------|
322
- | `/agileflow:session:init` | One-time setup of session harness |
323
- | `/agileflow:session:resume` | Start session with verification |
324
- | `/agileflow:session:status` | Quick view of current session |
325
- | `/agileflow:session:history` | View past sessions and analytics |
326
-
327
- ## Integration Points
328
-
329
- ### Reads
330
- - `docs/09-agents/session-state.json` - Current session
331
- - `docs/09-agents/status.json` - Story status
332
- - Git log - Commits during session
333
-
334
- ### Updates
335
- - `docs/09-agents/session-state.json` - Moves current to last, updates history
336
-
337
- ### Optionally Runs
338
- - `/agileflow:verify` - Final test check
339
-
340
- ## Implementation Notes
341
-
342
- 1. **Safe**: Never loses work - only records metadata
343
- 2. **Summarizing**: Provides clear recap of accomplishments
344
- 3. **Forward-Looking**: Suggests what to work on next
345
- 4. **Flexible**: Can end with failing tests or uncommitted changes
346
- 5. **Analytics-Ready**: Updates history for tracking over time
100
+ - `/agileflow:session:new` - Create new session
101
+ - `/agileflow:session:resume` - Switch sessions
102
+ - `/agileflow:session:status` - View all sessions