agileflow 2.92.1 → 2.94.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 (115) hide show
  1. package/CHANGELOG.md +10 -0
  2. package/README.md +3 -3
  3. package/package.json +1 -1
  4. package/scripts/agileflow-statusline.sh +106 -0
  5. package/scripts/agileflow-welcome.js +54 -0
  6. package/scripts/document-repl.js +793 -0
  7. package/scripts/session-manager.js +230 -16
  8. package/scripts/spawn-parallel.js +53 -14
  9. package/src/core/agents/accessibility.md +19 -125
  10. package/src/core/agents/adr-writer.md +18 -1
  11. package/src/core/agents/analytics.md +19 -125
  12. package/src/core/agents/api.md +5 -130
  13. package/src/core/agents/ci.md +26 -131
  14. package/src/core/agents/compliance.md +21 -125
  15. package/src/core/agents/database.md +20 -125
  16. package/src/core/agents/datamigration.md +20 -125
  17. package/src/core/agents/design.md +19 -125
  18. package/src/core/agents/devops.md +12 -129
  19. package/src/core/agents/documentation.md +18 -1
  20. package/src/core/agents/epic-planner.md +31 -10
  21. package/src/core/agents/integrations.md +19 -125
  22. package/src/core/agents/mobile.md +19 -125
  23. package/src/core/agents/monitoring.md +19 -125
  24. package/src/core/agents/performance.md +19 -125
  25. package/src/core/agents/product.md +18 -1
  26. package/src/core/agents/qa.md +21 -125
  27. package/src/core/agents/readme-updater.md +18 -1
  28. package/src/core/agents/refactor.md +19 -125
  29. package/src/core/agents/research.md +3 -1
  30. package/src/core/agents/rlm-subcore.md +202 -0
  31. package/src/core/agents/security.md +7 -125
  32. package/src/core/agents/testing.md +20 -125
  33. package/src/core/agents/ui.md +14 -135
  34. package/src/core/commands/adr/list.md +20 -0
  35. package/src/core/commands/adr/update.md +24 -1
  36. package/src/core/commands/adr/view.md +23 -1
  37. package/src/core/commands/adr.md +2 -2
  38. package/src/core/commands/agent.md +11 -1
  39. package/src/core/commands/assign.md +15 -6
  40. package/src/core/commands/auto.md +11 -1
  41. package/src/core/commands/babysit.md +15 -4
  42. package/src/core/commands/baseline.md +11 -1
  43. package/src/core/commands/batch.md +11 -1
  44. package/src/core/commands/blockers.md +11 -1
  45. package/src/core/commands/board.md +11 -1
  46. package/src/core/commands/changelog.md +11 -0
  47. package/src/core/commands/choose.md +16 -1
  48. package/src/core/commands/ci.md +11 -1
  49. package/src/core/commands/configure.md +73 -2
  50. package/src/core/commands/context/export.md +8 -0
  51. package/src/core/commands/context/full.md +8 -0
  52. package/src/core/commands/context/note.md +8 -0
  53. package/src/core/commands/debt.md +11 -0
  54. package/src/core/commands/deploy.md +10 -0
  55. package/src/core/commands/deps.md +11 -1
  56. package/src/core/commands/diagnose.md +10 -0
  57. package/src/core/commands/docs.md +12 -2
  58. package/src/core/commands/epic/list.md +20 -0
  59. package/src/core/commands/epic/view.md +25 -0
  60. package/src/core/commands/epic.md +5 -6
  61. package/src/core/commands/feedback.md +11 -0
  62. package/src/core/commands/handoff.md +12 -2
  63. package/src/core/commands/help.md +10 -0
  64. package/src/core/commands/ideate.md +10 -0
  65. package/src/core/commands/impact.md +11 -1
  66. package/src/core/commands/metrics.md +11 -1
  67. package/src/core/commands/multi-expert.md +11 -1
  68. package/src/core/commands/packages.md +11 -0
  69. package/src/core/commands/pr.md +10 -0
  70. package/src/core/commands/readme-sync.md +10 -5
  71. package/src/core/commands/research/analyze.md +60 -3
  72. package/src/core/commands/research/ask.md +9 -1
  73. package/src/core/commands/research/import.md +8 -0
  74. package/src/core/commands/research/list.md +8 -0
  75. package/src/core/commands/research/synthesize.md +9 -1
  76. package/src/core/commands/research/view.md +8 -0
  77. package/src/core/commands/retro.md +12 -2
  78. package/src/core/commands/review.md +11 -1
  79. package/src/core/commands/rlm.md +363 -0
  80. package/src/core/commands/roadmap/analyze.md +1 -1
  81. package/src/core/commands/rpi.md +9 -1
  82. package/src/core/commands/session/cleanup.md +250 -0
  83. package/src/core/commands/session/end.md +10 -0
  84. package/src/core/commands/session/history.md +11 -1
  85. package/src/core/commands/session/init.md +10 -0
  86. package/src/core/commands/session/new.md +113 -13
  87. package/src/core/commands/session/resume.md +10 -0
  88. package/src/core/commands/session/spawn.md +8 -0
  89. package/src/core/commands/session/status.md +10 -0
  90. package/src/core/commands/skill/create.md +1 -1
  91. package/src/core/commands/skill/delete.md +11 -1
  92. package/src/core/commands/skill/edit.md +11 -1
  93. package/src/core/commands/skill/test.md +11 -1
  94. package/src/core/commands/skill/upgrade.md +11 -1
  95. package/src/core/commands/sprint.md +14 -3
  96. package/src/core/commands/status.md +15 -6
  97. package/src/core/commands/story/list.md +23 -0
  98. package/src/core/commands/story/view.md +24 -0
  99. package/src/core/commands/story.md +4 -5
  100. package/src/core/commands/template.md +10 -0
  101. package/src/core/commands/tests.md +10 -0
  102. package/src/core/commands/update.md +10 -0
  103. package/src/core/commands/validate-expertise.md +10 -1
  104. package/src/core/commands/velocity.md +11 -1
  105. package/src/core/commands/verify.md +13 -1
  106. package/src/core/commands/whats-new.md +8 -0
  107. package/src/core/commands/workflow.md +16 -1
  108. package/src/core/templates/agent-coordination-pattern.md +38 -0
  109. package/src/core/templates/agileflow-metadata.json +25 -0
  110. package/src/core/templates/preserve-rules-common.md +107 -0
  111. package/src/core/templates/preserve-rules.json +42 -0
  112. package/src/core/templates/proactive-action-spec.md +29 -0
  113. package/src/core/templates/quality-gate-priorities.md +34 -0
  114. package/src/core/templates/session-harness-protocol.md +128 -0
  115. package/tools/cli/lib/content-injector.js +338 -0
@@ -0,0 +1,363 @@
1
+ ---
2
+ description: Analyze complex documents using RLM (Recursive Language Models) pattern
3
+ argument-hint: DOCUMENT=<path> QUERY=<text> [MAX_ITERATIONS=<number>] [DEPTH=<number>]
4
+ compact_context:
5
+ priority: high
6
+ preserve_rules:
7
+ - "ACTIVE COMMAND: /agileflow:rlm - RLM document analysis"
8
+ - "Virtualize document - NEVER load full content into context"
9
+ - "Use document-repl.js for all document operations"
10
+ - "Delegate search to rlm-subcore agent (Haiku) when beneficial"
11
+ - "Synthesize results yourself (Sonnet) - sub-agent only searches"
12
+ - "Respect iteration limits and budget constraints"
13
+ state_fields:
14
+ - document_path
15
+ - document_chars
16
+ - complexity
17
+ - query
18
+ - iteration_count
19
+ - max_iterations
20
+ ---
21
+
22
+ # /agileflow:rlm
23
+
24
+ Analyze complex documents using the RLM (Recursive Language Models) pattern. Virtualizes documents outside context and uses programmatic search instead of loading full content.
25
+
26
+ ---
27
+
28
+ ## When to Use RLM
29
+
30
+ | Scenario | Use RLM? | Why |
31
+ |----------|----------|-----|
32
+ | Document < 10k chars | No | Direct read is fine |
33
+ | Document 10-50k chars, simple query | Maybe | Try direct first |
34
+ | Document 50k+ chars | **Yes** | Context rot risk |
35
+ | High cross-referencing (legal, specs) | **Yes** | Multi-hop reasoning needed |
36
+ | Multiple questions about same doc | **Yes** | REPL state persists |
37
+
38
+ ---
39
+
40
+ ## STEP 0: Gather Context
41
+
42
+ ```bash
43
+ node .agileflow/scripts/obtain-context.js rlm
44
+ ```
45
+
46
+ ---
47
+
48
+ <!-- COMPACT_SUMMARY_START -->
49
+
50
+ ## COMPACT SUMMARY - /agileflow:rlm IS ACTIVE
51
+
52
+ **ROLE**: Analyze complex documents without context rot using REPL + recursion pattern.
53
+
54
+ ### RULE #1: NEVER LOAD FULL DOCUMENT
55
+
56
+ **CRITICAL**: The whole point of RLM is to NOT stuff the document into your context.
57
+
58
+ **WRONG**:
59
+ ```bash
60
+ Read("/path/to/large-contract.pdf") # NO! Context rot!
61
+ ```
62
+
63
+ **RIGHT**:
64
+ ```bash
65
+ node packages/cli/scripts/document-repl.js --load="/path/to/large-contract.pdf" --info
66
+ ```
67
+
68
+ ### RULE #2: WORKFLOW PHASES
69
+
70
+ **Phase 1: Assess**
71
+ ```bash
72
+ # Get document info and complexity
73
+ node packages/cli/scripts/document-repl.js --load="DOCUMENT" --info
74
+ ```
75
+
76
+ If complexity is LOW and chars < 10k, consider direct read instead.
77
+
78
+ **Phase 2: Explore Structure**
79
+ ```bash
80
+ # Get table of contents
81
+ node packages/cli/scripts/document-repl.js --load="DOCUMENT" --toc
82
+ ```
83
+
84
+ **Phase 3: Targeted Search**
85
+ ```bash
86
+ # Search for relevant terms from the query
87
+ node packages/cli/scripts/document-repl.js --load="DOCUMENT" --search="keyword"
88
+ ```
89
+
90
+ **Phase 4: Extract Sections**
91
+ ```bash
92
+ # Get specific sections identified in search
93
+ node packages/cli/scripts/document-repl.js --load="DOCUMENT" --section="Article 7"
94
+ ```
95
+
96
+ **Phase 5: Synthesize**
97
+ - YOU (Sonnet) synthesize the final answer
98
+ - Sub-agent only did search, you do reasoning
99
+
100
+ ### RULE #3: DELEGATION DECISION
101
+
102
+ | Complexity | Chars | Approach |
103
+ |------------|-------|----------|
104
+ | LOW | < 10k | Direct read (no RLM) |
105
+ | LOW | 10-50k | REPL yourself (no sub-agent) |
106
+ | MEDIUM | Any | REPL yourself |
107
+ | HIGH | < 50k | REPL yourself |
108
+ | HIGH | 50k+ | **Delegate to rlm-subcore** |
109
+
110
+ **Delegate when**:
111
+ - Document > 50k chars AND complexity HIGH
112
+ - Multiple search operations needed
113
+ - Budget optimization required
114
+
115
+ ### RULE #4: SUB-AGENT DELEGATION
116
+
117
+ When delegating to rlm-subcore:
118
+
119
+ ```
120
+ Task(
121
+ description: "Search merger agreement for termination clauses",
122
+ prompt: "Use document-repl.js to search '/path/to/doc.pdf' for 'termination'. Return all matches with context. Budget: 10000 chars.",
123
+ subagent_type: "agileflow-rlm-subcore",
124
+ model: "haiku"
125
+ )
126
+ ```
127
+
128
+ **Sub-agent returns**: Structured search results
129
+ **You synthesize**: Use results to answer the original query
130
+
131
+ ### RULE #5: ITERATION LIMITS
132
+
133
+ | Parameter | Default | Purpose |
134
+ |-----------|---------|---------|
135
+ | MAX_ITERATIONS | 10 | Prevent runaway loops |
136
+ | DEPTH | 1 | Recursion depth (sub-agent layers) |
137
+ | BUDGET | 15000 | Chars per operation |
138
+
139
+ **Track iterations**: If approaching MAX_ITERATIONS, summarize what you have.
140
+
141
+ ### RULE #6: ANSWER FORMAT
142
+
143
+ After analysis, provide:
144
+
145
+ ```markdown
146
+ ## RLM Analysis: [Document Name]
147
+
148
+ **Query**: [Original question]
149
+ **Document**: [path] (X chars, Y lines, COMPLEXITY)
150
+ **Iterations**: N of MAX
151
+
152
+ ### Answer
153
+
154
+ [Your synthesized answer based on extracted content]
155
+
156
+ ### Evidence
157
+
158
+ 1. **[Section/Line]**: [relevant excerpt]
159
+ 2. **[Section/Line]**: [relevant excerpt]
160
+
161
+ ### Confidence
162
+
163
+ [HIGH/MEDIUM/LOW] - [reason for confidence level]
164
+ ```
165
+
166
+ ### Anti-Patterns (DON'T)
167
+
168
+ - Load full document with Read tool
169
+ - Skip complexity assessment
170
+ - Let sub-agent do reasoning (they only search)
171
+ - Exceed iteration limits without notice
172
+ - Return raw search results as final answer
173
+
174
+ ### Correct Patterns (DO)
175
+
176
+ - Assess complexity first
177
+ - Use document-repl.js for all doc operations
178
+ - Delegate search to sub-agent when beneficial
179
+ - Synthesize results yourself
180
+ - Track iterations and budget
181
+ - Provide confidence assessment
182
+
183
+ <!-- COMPACT_SUMMARY_END -->
184
+
185
+ ---
186
+
187
+ ## Arguments
188
+
189
+ | Argument | Required | Description |
190
+ |----------|----------|-------------|
191
+ | DOCUMENT | Yes | Path to document file |
192
+ | QUERY | Yes | Question to answer about the document |
193
+ | MAX_ITERATIONS | No | Max search iterations (default: 10) |
194
+ | DEPTH | No | Recursion depth for sub-agents (default: 1) |
195
+
196
+ ---
197
+
198
+ ## IMMEDIATE ACTIONS
199
+
200
+ Upon invocation:
201
+
202
+ ### Step 1: Validate Arguments
203
+
204
+ ```bash
205
+ # Check DOCUMENT exists
206
+ ls -la "DOCUMENT_PATH"
207
+
208
+ # Check format is supported
209
+ # Supported: .txt, .md, .pdf, .docx
210
+ ```
211
+
212
+ If DOCUMENT or QUERY missing, ask user:
213
+ ```xml
214
+ <invoke name="AskUserQuestion">
215
+ <parameter name="questions">[{
216
+ "question": "Please provide the document path and your question.",
217
+ "header": "RLM Input",
218
+ "multiSelect": false,
219
+ "options": [
220
+ {"label": "Enter document path", "description": "Path to .txt, .md, .pdf, or .docx file"},
221
+ {"label": "Cancel", "description": "Exit RLM analysis"}
222
+ ]
223
+ }]</parameter>
224
+ </invoke>
225
+ ```
226
+
227
+ ### Step 2: Assess Document
228
+
229
+ ```bash
230
+ node packages/cli/scripts/document-repl.js --load="DOCUMENT" --info --json
231
+ ```
232
+
233
+ **Decision point**: Based on complexity and size, decide approach:
234
+ - LOW + small → suggest direct read
235
+ - Otherwise → continue with RLM
236
+
237
+ ### Step 3: Explore Structure
238
+
239
+ ```bash
240
+ node packages/cli/scripts/document-repl.js --load="DOCUMENT" --toc
241
+ ```
242
+
243
+ ### Step 4: Search Strategy
244
+
245
+ Based on QUERY, identify search terms:
246
+ 1. Extract key concepts from query
247
+ 2. Search for each term
248
+ 3. Identify relevant sections
249
+
250
+ ```bash
251
+ # For each key term
252
+ node packages/cli/scripts/document-repl.js --load="DOCUMENT" --search="term1"
253
+ node packages/cli/scripts/document-repl.js --load="DOCUMENT" --search="term2"
254
+ ```
255
+
256
+ ### Step 5: Extract Relevant Content
257
+
258
+ Based on search results, extract full sections:
259
+
260
+ ```bash
261
+ node packages/cli/scripts/document-repl.js --load="DOCUMENT" --section="Relevant Section"
262
+ ```
263
+
264
+ Or specific line ranges:
265
+
266
+ ```bash
267
+ node packages/cli/scripts/document-repl.js --load="DOCUMENT" --slice="100-200"
268
+ ```
269
+
270
+ ### Step 6: Synthesize Answer
271
+
272
+ Using ONLY the extracted content (not full document):
273
+ 1. Answer the QUERY
274
+ 2. Cite evidence with line numbers
275
+ 3. Assess confidence
276
+
277
+ ### Step 7: Present Results
278
+
279
+ Format as shown in RULE #6 above.
280
+
281
+ ---
282
+
283
+ ## Example Usage
284
+
285
+ ### Example 1: Legal Document Analysis
286
+
287
+ ```
288
+ /agileflow:rlm DOCUMENT="contracts/merger-agreement.pdf" QUERY="What are the conditions precedent to closing for each party?"
289
+ ```
290
+
291
+ **Workflow**:
292
+ 1. Assess: 429k chars, HIGH complexity
293
+ 2. TOC: Find "Article 7: Conditions Precedent"
294
+ 3. Search: "conditions precedent", "closing", "purchaser", "seller"
295
+ 4. Extract: Article 7 section
296
+ 5. Synthesize: List conditions for each party
297
+
298
+ ### Example 2: Technical Specification
299
+
300
+ ```
301
+ /agileflow:rlm DOCUMENT="specs/api-specification.md" QUERY="What authentication methods are supported?"
302
+ ```
303
+
304
+ **Workflow**:
305
+ 1. Assess: 85k chars, MEDIUM complexity
306
+ 2. TOC: Find "Authentication" section
307
+ 3. Search: "authentication", "auth", "OAuth", "JWT"
308
+ 4. Extract: Authentication section
309
+ 5. Synthesize: List supported methods with details
310
+
311
+ ### Example 3: Research Paper
312
+
313
+ ```
314
+ /agileflow:rlm DOCUMENT="research/rlm-paper.pdf" QUERY="What are the limitations of the RLM approach?"
315
+ ```
316
+
317
+ **Workflow**:
318
+ 1. Assess: 25k chars, LOW complexity
319
+ 2. Search: "limitations", "risks", "guardrails"
320
+ 3. Extract: Limitations section
321
+ 4. Synthesize: Summarize limitations
322
+
323
+ ---
324
+
325
+ ## Integration with Research Commands
326
+
327
+ RLM can be used with research notes:
328
+
329
+ ```
330
+ /agileflow:rlm DOCUMENT="docs/10-research/20260117-rlm-recursive-language-models.md" QUERY="What are the key findings?"
331
+ ```
332
+
333
+ For smaller research notes, `/agileflow:research:view` may be sufficient.
334
+
335
+ ---
336
+
337
+ ## Error Handling
338
+
339
+ | Error | Recovery |
340
+ |-------|----------|
341
+ | Document not found | Ask user for correct path |
342
+ | Unsupported format | Suggest conversion to .txt/.md |
343
+ | PDF parse error | Check pdf-parse installed |
344
+ | DOCX parse error | Check mammoth installed |
345
+ | Budget exceeded | Summarize partial results |
346
+ | Max iterations | Report findings so far |
347
+
348
+ ---
349
+
350
+ ## Related Commands
351
+
352
+ - `/agileflow:research:analyze` - Analyze research notes (uses RLM for large docs)
353
+ - `/agileflow:research:view` - View research notes (direct read)
354
+ - `/agileflow:research:synthesize` - Cross-document analysis
355
+
356
+ ---
357
+
358
+ ## References
359
+
360
+ - Research: `docs/10-research/20260117-rlm-recursive-language-models.md`
361
+ - Research: `docs/10-research/20260119-rlm-claude-code-implementation.md`
362
+ - Sub-agent: `packages/cli/src/core/agents/rlm-subcore.md`
363
+ - Script: `packages/cli/scripts/document-repl.js`
@@ -1,6 +1,6 @@
1
1
  ---
2
2
  description: Automated competitor analysis with feature gap identification
3
- argument-hint: "[COMPETITORS=<keywords>] [FOCUS=all|features|security|perf|ux] [OUTPUT=matrix|report|stories]"
3
+ argument-hint: [COMPETITORS=<text>] [FOCUS=all|features|security|perf|ux] [OUTPUT=matrix|report|stories]
4
4
  compact_context:
5
5
  priority: high
6
6
  preserve_rules:
@@ -1,6 +1,6 @@
1
1
  ---
2
2
  description: Orchestrate Research-Plan-Implement workflow with explicit phase transitions
3
- argument-hint: [TASK=<description>] [PHASE=research|plan|implement] [SKIP_RESEARCH=true]
3
+ argument-hint: [TASK=<text>] [PHASE=research|plan|implement] [SKIP_RESEARCH=true|false]
4
4
  compact_context:
5
5
  priority: critical
6
6
  preserve_rules:
@@ -32,6 +32,14 @@ Guide complex tasks through three phases, each producing a compressed artifact f
32
32
 
33
33
  ---
34
34
 
35
+ ## STEP 0: Gather Context
36
+
37
+ ```bash
38
+ node .agileflow/scripts/obtain-context.js rpi
39
+ ```
40
+
41
+ ---
42
+
35
43
  <!-- COMPACT_SUMMARY_START -->
36
44
 
37
45
  ## COMPACT SUMMARY - RPI WORKFLOW ACTIVE
@@ -0,0 +1,250 @@
1
+ ---
2
+ description: Interactive session cleanup with AI assessment
3
+ argument-hint: (no arguments)
4
+ compact_context:
5
+ priority: high
6
+ preserve_rules:
7
+ - "ACTIVE COMMAND: /agileflow:session:cleanup - Review and clean up sessions"
8
+ - "Walk through EACH session with issues one-by-one"
9
+ - "Show file changes with AI assessment (SAFE/IMPORTANT)"
10
+ - "Use AskUserQuestion for EACH session with recommended action"
11
+ - "Recommended action based on allTrivial flag from health --detailed"
12
+ - "Track: deleted count, kept count, skipped count"
13
+ state_fields:
14
+ - health_report
15
+ - current_session_index
16
+ - total_sessions
17
+ - deleted_count
18
+ - kept_count
19
+ ---
20
+
21
+ # /agileflow:session:cleanup
22
+
23
+ Interactive session cleanup - review each session with health issues and decide what to do.
24
+
25
+ ---
26
+
27
+ ## Purpose
28
+
29
+ When you have forgotten sessions with uncommitted changes, stale entries, or orphaned worktrees, this command:
30
+ - Shows you what changed in each session
31
+ - Analyzes whether changes are important or trivial
32
+ - Provides AI recommendation for each session
33
+ - Lets you decide one-by-one what to clean up
34
+
35
+ ---
36
+
37
+ ## IMMEDIATE ACTIONS
38
+
39
+ ### Step 1: Get Detailed Health Report
40
+
41
+ ```bash
42
+ node .agileflow/scripts/session-manager.js health --detailed
43
+ ```
44
+
45
+ Parse the JSON output and count total issues:
46
+ - `uncommitted.length` - Sessions with uncommitted changes
47
+ - `stale.length` - Sessions inactive for 7+ days
48
+ - `orphanedRegistry.length` - Registry entries with missing paths
49
+ - `orphanedWorktrees.length` - Worktrees not in registry
50
+
51
+ If total is 0, display:
52
+ ```
53
+ ✅ All sessions healthy! Nothing to clean up.
54
+ ```
55
+ And exit.
56
+
57
+ ### Step 2: Display Overview
58
+
59
+ ```
60
+ 📋 Session Health Check
61
+ =======================
62
+
63
+ Found {total_issues} issue(s) across {total_sessions} session(s).
64
+ Let's go through each one.
65
+ ```
66
+
67
+ ### Step 3: Process Each Session with Uncommitted Changes
68
+
69
+ For each session in `uncommitted` array:
70
+
71
+ #### Step 3a: Display Session Header
72
+
73
+ ```
74
+ ─────────────────────────────────────────────────────────────
75
+ Session {id} "{nickname}" ({current}/{total})
76
+ ─────────────────────────────────────────────────────────────
77
+ ```
78
+
79
+ #### Step 3b: Display Files Changed
80
+
81
+ ```
82
+ 📝 {changeCount} uncommitted file(s):
83
+ ```
84
+
85
+ For each file in `fileDetails`:
86
+ - `M` status: ` M {file}` and if `trivial: true` add `(~{diffLines} lines - trivial)`
87
+ - `??` status: ` ?? {file}` and if `existsInMain: true` add `(exists in main)`
88
+ - Other: ` {status} {file}`
89
+
90
+ #### Step 3c: Display AI Assessment
91
+
92
+ If `allTrivial` is true:
93
+ ```
94
+ 🤖 Assessment: SAFE TO DELETE
95
+ No unique work - all changes are trivial or already in main.
96
+ ```
97
+
98
+ If `allTrivial` is false:
99
+ ```
100
+ 🤖 Assessment: IMPORTANT - KEEP
101
+ This session has unique changes that may be valuable.
102
+ ```
103
+
104
+ #### Step 3d: Ask User with AskUserQuestion
105
+
106
+ **If SAFE (allTrivial: true):**
107
+ ```
108
+ AskUserQuestion:
109
+ question: "Session {id} - What would you like to do?"
110
+ header: "Cleanup"
111
+ multiSelect: false
112
+ options:
113
+ - label: "Delete session (Recommended)"
114
+ description: "Remove session and worktree - no unique work"
115
+ - label: "Keep this session"
116
+ description: "Leave it as-is"
117
+ - label: "Stop cleanup"
118
+ description: "Exit and show summary"
119
+ ```
120
+
121
+ **If IMPORTANT (allTrivial: false):**
122
+ ```
123
+ AskUserQuestion:
124
+ question: "Session {id} - What would you like to do?"
125
+ header: "Cleanup"
126
+ multiSelect: false
127
+ options:
128
+ - label: "Keep this session (Recommended)"
129
+ description: "Preserve unique work"
130
+ - label: "Delete anyway"
131
+ description: "Remove session and lose changes"
132
+ - label: "Stop cleanup"
133
+ description: "Exit and show summary"
134
+ ```
135
+
136
+ #### Step 3e: Execute User Choice
137
+
138
+ **If "Delete" chosen:**
139
+ ```bash
140
+ node .agileflow/scripts/session-manager.js delete {session_id} --remove-worktree
141
+ ```
142
+
143
+ Display: `✓ Session {id} deleted`
144
+ Increment deleted_count.
145
+
146
+ **If "Keep" chosen:**
147
+ Display: `→ Session {id} kept`
148
+ Increment kept_count.
149
+
150
+ **If "Stop cleanup" chosen:**
151
+ Go to Step 6 (Final Summary).
152
+
153
+ ### Step 4: Process Orphaned Registry Entries
154
+
155
+ For each entry in `orphanedRegistry`:
156
+
157
+ ```
158
+ ─────────────────────────────────────────────────────────────
159
+ Orphaned Registry: Session {id} ({current}/{total})
160
+ ─────────────────────────────────────────────────────────────
161
+
162
+ 🗑️ Registry entry exists but path is missing:
163
+ Path: {path}
164
+ Branch: {branch}
165
+
166
+ AskUserQuestion:
167
+ question: "Remove orphaned registry entry {id}?"
168
+ header: "Cleanup"
169
+ multiSelect: false
170
+ options:
171
+ - label: "Remove from registry (Recommended)"
172
+ description: "Clean up stale entry"
173
+ - label: "Skip"
174
+ description: "Leave in registry"
175
+ - label: "Stop cleanup"
176
+ description: "Exit and show summary"
177
+ ```
178
+
179
+ **If "Remove" chosen:**
180
+ Remove the entry from `.agileflow/sessions/registry.json`:
181
+ ```bash
182
+ node .agileflow/scripts/session-manager.js delete {session_id}
183
+ ```
184
+
185
+ ### Step 5: Process Orphaned Worktrees
186
+
187
+ For each entry in `orphanedWorktrees`:
188
+
189
+ ```
190
+ ─────────────────────────────────────────────────────────────
191
+ Orphaned Worktree ({current}/{total})
192
+ ─────────────────────────────────────────────────────────────
193
+
194
+ 🗑️ Git worktree exists but not in registry:
195
+ Path: {path}
196
+
197
+ AskUserQuestion:
198
+ question: "Remove orphaned worktree?"
199
+ header: "Cleanup"
200
+ multiSelect: false
201
+ options:
202
+ - label: "Remove worktree (Recommended)"
203
+ description: "Delete directory and prune git"
204
+ - label: "Skip"
205
+ description: "Leave worktree"
206
+ - label: "Stop cleanup"
207
+ description: "Exit and show summary"
208
+ ```
209
+
210
+ **If "Remove" chosen:**
211
+ ```bash
212
+ git worktree remove --force "{path}"
213
+ ```
214
+
215
+ ### Step 6: Final Summary
216
+
217
+ ```
218
+ ═══════════════════════════════════════════════════════════════
219
+ Session Cleanup Complete
220
+ ═══════════════════════════════════════════════════════════════
221
+
222
+ ✓ Deleted: {deleted_count} session(s)
223
+ → Kept: {kept_count} session(s)
224
+ ○ Skipped: {skipped_count} item(s)
225
+
226
+ Run /agileflow:session:status to see remaining sessions.
227
+ ```
228
+
229
+ ---
230
+
231
+ ## Edge Cases
232
+
233
+ ### No Issues Found
234
+ ```
235
+ ✅ All sessions healthy! Nothing to clean up.
236
+ ```
237
+
238
+ ### User Stops Early
239
+ Show partial summary with what was processed.
240
+
241
+ ### Main Session Protection
242
+ The health check already excludes main session, so it won't appear in cleanup list.
243
+
244
+ ---
245
+
246
+ ## Related Commands
247
+
248
+ - `/agileflow:session:status` - View all sessions
249
+ - `/agileflow:session:end` - End current session with merge option
250
+ - `/agileflow:session:new` - Create new parallel session
@@ -31,6 +31,16 @@ When you're done with a session, this command:
31
31
  - Optionally removes the git worktree directory
32
32
  - Updates the registry with last active timestamp
33
33
 
34
+ ---
35
+
36
+ ## STEP 0: Gather Context
37
+
38
+ ```bash
39
+ node .agileflow/scripts/obtain-context.js session:end
40
+ ```
41
+
42
+ ---
43
+
34
44
  ## IMMEDIATE ACTIONS
35
45
 
36
46
  ### Step 1: Get Current Session
@@ -1,6 +1,6 @@
1
1
  ---
2
2
  description: View past session history and metrics
3
- argument-hint: "[DAYS=7|30|90|all]"
3
+ argument-hint: [DAYS=7|30|90|all]
4
4
  compact_context:
5
5
  priority: medium
6
6
  preserve_rules:
@@ -27,6 +27,16 @@ View historical session data and metrics.
27
27
 
28
28
  Show all sessions (active and inactive) with creation dates, last activity, and work done.
29
29
 
30
+ ---
31
+
32
+ ## STEP 0: Gather Context
33
+
34
+ ```bash
35
+ node .agileflow/scripts/obtain-context.js session:history
36
+ ```
37
+
38
+ ---
39
+
30
40
  ## Arguments
31
41
 
32
42
  | Argument | Default | Description |
@@ -32,6 +32,16 @@ Sets up session tracking infrastructure:
32
32
 
33
33
  This command is typically called automatically by the SessionStart hook.
34
34
 
35
+ ---
36
+
37
+ ## STEP 0: Gather Context
38
+
39
+ ```bash
40
+ node .agileflow/scripts/obtain-context.js session:init
41
+ ```
42
+
43
+ ---
44
+
35
45
  ## IMMEDIATE ACTIONS
36
46
 
37
47
  ### Step 1: Ensure Session Infrastructure