agileflow 3.0.1 → 3.1.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 (69) hide show
  1. package/CHANGELOG.md +10 -0
  2. package/README.md +8 -8
  3. package/lib/api-server.js +3 -2
  4. package/lib/feedback.js +9 -2
  5. package/lib/flag-detection.js +4 -2
  6. package/lib/git-operations.js +4 -2
  7. package/lib/lazy-require.js +59 -0
  8. package/lib/process-executor.js +24 -9
  9. package/lib/skill-loader.js +11 -3
  10. package/package.json +1 -1
  11. package/scripts/agileflow-configure.js +12 -0
  12. package/scripts/agileflow-welcome.js +146 -90
  13. package/scripts/claude-tmux.sh +42 -6
  14. package/scripts/damage-control-multi-agent.js +14 -10
  15. package/scripts/lib/bus-utils.js +3 -1
  16. package/scripts/lib/configure-detect.js +12 -9
  17. package/scripts/lib/configure-features.js +128 -7
  18. package/scripts/lib/configure-repair.js +6 -5
  19. package/scripts/lib/context-formatter.js +13 -3
  20. package/scripts/lib/damage-control-utils.js +5 -1
  21. package/scripts/lib/lifecycle-detector.js +5 -3
  22. package/scripts/lib/process-cleanup.js +8 -4
  23. package/scripts/lib/scale-detector.js +47 -8
  24. package/scripts/lib/signal-detectors.js +117 -59
  25. package/scripts/lib/task-registry.js +5 -1
  26. package/scripts/lib/team-events.js +4 -4
  27. package/scripts/messaging-bridge.js +7 -1
  28. package/scripts/ralph-loop.js +10 -8
  29. package/scripts/smart-detect.js +32 -11
  30. package/scripts/team-manager.js +86 -1
  31. package/scripts/tmux-task-name.sh +105 -0
  32. package/scripts/tmux-task-watcher.sh +344 -0
  33. package/src/core/agents/legal-analyzer-a11y.md +110 -0
  34. package/src/core/agents/legal-analyzer-ai.md +117 -0
  35. package/src/core/agents/legal-analyzer-consumer.md +108 -0
  36. package/src/core/agents/legal-analyzer-content.md +113 -0
  37. package/src/core/agents/legal-analyzer-international.md +115 -0
  38. package/src/core/agents/legal-analyzer-licensing.md +115 -0
  39. package/src/core/agents/legal-analyzer-privacy.md +108 -0
  40. package/src/core/agents/legal-analyzer-security.md +112 -0
  41. package/src/core/agents/legal-analyzer-terms.md +111 -0
  42. package/src/core/agents/legal-consensus.md +242 -0
  43. package/src/core/agents/team-lead.md +50 -13
  44. package/src/core/commands/babysit.md +75 -42
  45. package/src/core/commands/blockers.md +7 -7
  46. package/src/core/commands/configure.md +15 -61
  47. package/src/core/commands/discovery/brief.md +363 -0
  48. package/src/core/commands/discovery/new.md +395 -0
  49. package/src/core/commands/ideate/new.md +5 -5
  50. package/src/core/commands/legal/audit.md +446 -0
  51. package/src/core/commands/logic/audit.md +5 -5
  52. package/src/core/commands/review.md +7 -1
  53. package/src/core/commands/rpi.md +61 -26
  54. package/src/core/commands/sprint.md +7 -6
  55. package/src/core/commands/team/start.md +36 -7
  56. package/src/core/commands/team/stop.md +5 -2
  57. package/src/core/templates/product-brief.md +136 -0
  58. package/tools/cli/installers/ide/claude-code.js +69 -2
  59. package/src/core/agents/configuration/archival.md +0 -350
  60. package/src/core/agents/configuration/attribution.md +0 -343
  61. package/src/core/agents/configuration/ci.md +0 -1103
  62. package/src/core/agents/configuration/damage-control.md +0 -375
  63. package/src/core/agents/configuration/git-config.md +0 -537
  64. package/src/core/agents/configuration/hooks.md +0 -623
  65. package/src/core/agents/configuration/precompact.md +0 -302
  66. package/src/core/agents/configuration/status-line.md +0 -557
  67. package/src/core/agents/configuration/verify.md +0 -618
  68. package/src/core/agents/configuration-damage-control.md +0 -259
  69. package/src/core/agents/configuration-visual-e2e.md +0 -339
@@ -56,13 +56,42 @@ If no argument given, use AskUserQuestion to let user choose.
56
56
 
57
57
  ### Native Mode (Agent Teams enabled)
58
58
 
59
- When Agent Teams is enabled, operate as the **team lead** in delegate mode:
60
-
61
- 1. Read the template JSON from `.agileflow/teams/<template>.json`
62
- 2. Announce the team composition to the user
63
- 3. Create tasks for each teammate using the native task list
64
- 4. Spawn teammate sessions as defined in the template
65
- 5. Monitor progress and coordinate handoffs
59
+ When Agent Teams is enabled, use native tools to create and coordinate the team:
60
+
61
+ 1. **Run the team-manager script** to load the template and build the native payload:
62
+ ```bash
63
+ node .agileflow/scripts/team-manager.js start <template-name>
64
+ ```
65
+ Parse the JSON output. The `native_payload` field contains the team configuration.
66
+
67
+ 2. **Announce the team composition** to the user — list each teammate's name, role, and domain.
68
+
69
+ 3. **Spawn teammates using the Task tool with native parameters**:
70
+ For each teammate in `native_payload.teammates`:
71
+ ```
72
+ Task tool call:
73
+ subagent_type: <teammate.name> (e.g. "agileflow-api")
74
+ description: "<role> - <domain>"
75
+ prompt: <built from teammate instructions + project context>
76
+ ```
77
+ The prompt for each teammate should include:
78
+ - Their role and domain from the template
79
+ - The specific task or story they should work on
80
+ - A pointer to read CLAUDE.md and check `docs/09-agents/status.json` for context
81
+ - Quality gate requirements from the template
82
+
83
+ 4. **If native tools fail** (e.g., TeamCreate not available, tool not found errors):
84
+ - Log a warning: "Native Agent Teams tools not available. Falling back to subagent mode."
85
+ - Proceed with the **Fallback Mode** instructions below instead
86
+ - Update `session-state.json` to reflect `mode: "subagent"`
87
+
88
+ 5. **Create shared tasks** using TaskCreate for the work to be done:
89
+ - One task per teammate with clear acceptance criteria
90
+ - Set up dependencies (e.g., UI tasks blocked by API tasks)
91
+
92
+ 6. **Report** which mode was actually used (native vs fallback) and the spawned teammates.
93
+
94
+ > **Tip**: For teams with 3+ teammates, consider using tmux sessions (`/agileflow:session:spawn`) to run teammates in parallel windows for better visibility.
66
95
 
67
96
  ### Fallback Mode (Agent Teams disabled)
68
97
 
@@ -43,8 +43,11 @@ Before stopping:
43
43
 
44
44
  ### Native Mode
45
45
 
46
- Teammates will be stopped when the team lead session ends.
47
- The native Agent Teams runtime handles cleanup.
46
+ When `active_team.mode === "native"` in session-state.json:
47
+
48
+ 1. **Stop running teammate tasks**: Use `TaskStop` for any background teammate tasks still running
49
+ 2. **Attempt TeamDelete**: If the `TeamDelete` tool is available in your tool list, call it with the team name from `active_team.native_payload.name` to clean up the native team session
50
+ 3. **If TeamDelete is not available**: This is fine — teammate sessions will end naturally when their tasks complete. Log: "TeamDelete not available, teammates will complete naturally."
48
51
 
49
52
  ### Subagent Mode
50
53
 
@@ -0,0 +1,136 @@
1
+ ---
2
+ brief_id: {{BRIEF_ID}}
3
+ topic: {{TOPIC}}
4
+ depth: {{DEPTH}}
5
+ created: {{CREATED}}
6
+ status: draft
7
+ ideation_source: {{IDEATION_SOURCE}}
8
+ research_sources: {{RESEARCH_SOURCES}}
9
+ ---
10
+
11
+ # Product Brief: {{TOPIC}}
12
+
13
+ ## Executive Summary
14
+
15
+ {{EXECUTIVE_SUMMARY}}
16
+
17
+ ---
18
+
19
+ ## Problem Statement
20
+
21
+ ### What Problem Are We Solving?
22
+
23
+ {{PROBLEM_DESCRIPTION}}
24
+
25
+ ### Why Now?
26
+
27
+ {{WHY_NOW}}
28
+
29
+ ### Who Has This Problem?
30
+
31
+ {{TARGET_USERS}}
32
+
33
+ ---
34
+
35
+ ## User Personas
36
+
37
+ ### Persona 1: {{PERSONA_1_NAME}}
38
+
39
+ - **Role**: {{PERSONA_1_ROLE}}
40
+ - **Pain Points**: {{PERSONA_1_PAINS}}
41
+ - **Goals**: {{PERSONA_1_GOALS}}
42
+ - **Current Workaround**: {{PERSONA_1_WORKAROUND}}
43
+
44
+ ### Persona 2: {{PERSONA_2_NAME}}
45
+
46
+ - **Role**: {{PERSONA_2_ROLE}}
47
+ - **Pain Points**: {{PERSONA_2_PAINS}}
48
+ - **Goals**: {{PERSONA_2_GOALS}}
49
+ - **Current Workaround**: {{PERSONA_2_WORKAROUND}}
50
+
51
+ ---
52
+
53
+ ## Key Features (MoSCoW)
54
+
55
+ ### MUST HAVE (High-Confidence / Core Value)
56
+
57
+ | # | Feature | Rationale | Source |
58
+ |---|---------|-----------|--------|
59
+ | 1 | {{MUST_1}} | {{RATIONALE}} | {{SOURCE}} |
60
+ | 2 | {{MUST_2}} | {{RATIONALE}} | {{SOURCE}} |
61
+
62
+ ### SHOULD HAVE (Medium-Confidence / Important)
63
+
64
+ | # | Feature | Rationale | Source |
65
+ |---|---------|-----------|--------|
66
+ | 1 | {{SHOULD_1}} | {{RATIONALE}} | {{SOURCE}} |
67
+ | 2 | {{SHOULD_2}} | {{RATIONALE}} | {{SOURCE}} |
68
+
69
+ ### COULD HAVE (Nice-to-Have / Differentiators)
70
+
71
+ | # | Feature | Rationale | Source |
72
+ |---|---------|-----------|--------|
73
+ | 1 | {{COULD_1}} | {{RATIONALE}} | {{SOURCE}} |
74
+
75
+ ### WON'T HAVE (Explicit Out-of-Scope)
76
+
77
+ | # | Feature | Rationale |
78
+ |---|---------|-----------|
79
+ | 1 | {{WONT_1}} | {{RATIONALE}} |
80
+
81
+ ---
82
+
83
+ ## Success Metrics
84
+
85
+ | Metric | Target | How to Measure |
86
+ |--------|--------|----------------|
87
+ | {{METRIC_1}} | {{TARGET_1}} | {{MEASURE_1}} |
88
+ | {{METRIC_2}} | {{TARGET_2}} | {{MEASURE_2}} |
89
+ | {{METRIC_3}} | {{TARGET_3}} | {{MEASURE_3}} |
90
+
91
+ ---
92
+
93
+ ## Business Case (Simple ROI)
94
+
95
+ - **Effort Estimate**: {{EFFORT_ESTIMATE}}
96
+ - **Expected Benefit**: {{EXPECTED_BENEFIT}}
97
+ - **Payback Period**: {{PAYBACK_PERIOD}}
98
+ - **Confidence Level**: {{ROI_CONFIDENCE}}
99
+
100
+ ---
101
+
102
+ ## Competitive Context
103
+
104
+ ### Existing Alternatives
105
+
106
+ | Alternative | Strengths | Weaknesses | Our Differentiator |
107
+ |-------------|-----------|------------|-------------------|
108
+ | {{ALT_1}} | {{STRENGTHS}} | {{WEAKNESSES}} | {{DIFFERENTIATOR}} |
109
+ | {{ALT_2}} | {{STRENGTHS}} | {{WEAKNESSES}} | {{DIFFERENTIATOR}} |
110
+
111
+ ### Positioning Statement
112
+
113
+ {{POSITIONING}}
114
+
115
+ ---
116
+
117
+ ## Risks and Edge Cases
118
+
119
+ | Risk | Severity | Likelihood | Mitigation |
120
+ |------|----------|------------|------------|
121
+ | {{RISK_1}} | {{SEV}} | {{LIKE}} | {{MITIGATION}} |
122
+ | {{RISK_2}} | {{SEV}} | {{LIKE}} | {{MITIGATION}} |
123
+
124
+ ---
125
+
126
+ ## Technical Considerations
127
+
128
+ {{TECHNICAL_NOTES}}
129
+
130
+ ---
131
+
132
+ ## Next Steps
133
+
134
+ 1. Create epic: `/agileflow:epic "{{TOPIC}}"`
135
+ 2. Generate stories: `/agileflow:auto`
136
+ 3. Implement: `/agileflow:babysit`
@@ -61,9 +61,12 @@ class ClaudeCodeSetup extends BaseIdeSetup {
61
61
  // Claude Code specific: Setup damage control hooks
62
62
  await this.setupDamageControl(projectDir, agileflowDir, ideDir, options);
63
63
 
64
- // Claude Code specific: Setup SessionStart hooks (welcome, archive, context-loader)
64
+ // Claude Code specific: Setup SessionStart hooks (welcome, archive, context-loader, tmux-task-watcher)
65
65
  await this.setupSessionStartHooks(projectDir, agileflowDir, ideDir, options);
66
66
 
67
+ // Claude Code specific: Setup Stop hooks (tmux-task-watcher cleanup)
68
+ await this.setupStopHooks(projectDir, agileflowDir, ideDir, options);
69
+
67
70
  return result;
68
71
  }
69
72
 
@@ -256,6 +259,12 @@ class ClaudeCodeSetup extends BaseIdeSetup {
256
259
  'node $CLAUDE_PROJECT_DIR/.agileflow/scripts/context-loader.js 2>/dev/null || true',
257
260
  timeout: 5000,
258
261
  },
262
+ {
263
+ type: 'command',
264
+ command:
265
+ 'bash $CLAUDE_PROJECT_DIR/.agileflow/scripts/tmux-task-watcher.sh 2>/dev/null || true',
266
+ timeout: 5000,
267
+ },
259
268
  ];
260
269
 
261
270
  // Check if SessionStart hooks already exist
@@ -285,7 +294,65 @@ class ClaudeCodeSetup extends BaseIdeSetup {
285
294
 
286
295
  // Write settings
287
296
  await fs.writeFile(settingsPath, JSON.stringify(settings, null, 2));
288
- console.log(chalk.dim(` - SessionStart hooks: welcome, archive, context-loader`));
297
+ console.log(
298
+ chalk.dim(` - SessionStart hooks: welcome, archive, context-loader, tmux-task-watcher`)
299
+ );
300
+ }
301
+
302
+ /**
303
+ * Setup Stop hooks (tmux-task-watcher cleanup)
304
+ * @param {string} projectDir - Project directory
305
+ * @param {string} agileflowDir - AgileFlow installation directory
306
+ * @param {string} claudeDir - .claude directory path
307
+ * @param {Object} options - Setup options
308
+ */
309
+ async setupStopHooks(projectDir, agileflowDir, claudeDir, options = {}) {
310
+ const settingsPath = path.join(claudeDir, 'settings.json');
311
+ let settings = {};
312
+
313
+ if (fs.existsSync(settingsPath)) {
314
+ try {
315
+ settings = JSON.parse(fs.readFileSync(settingsPath, 'utf8'));
316
+ } catch (e) {
317
+ settings = {};
318
+ }
319
+ }
320
+
321
+ if (!settings.hooks) settings.hooks = {};
322
+ if (!settings.hooks.Stop) settings.hooks.Stop = [];
323
+
324
+ const stopHooks = [
325
+ {
326
+ type: 'command',
327
+ command:
328
+ 'bash $CLAUDE_PROJECT_DIR/.agileflow/scripts/tmux-task-watcher.sh stop 2>/dev/null || true',
329
+ timeout: 3000,
330
+ },
331
+ ];
332
+
333
+ const existingEntry = settings.hooks.Stop.find(
334
+ h => h.matcher === '' || h.matcher === undefined
335
+ );
336
+
337
+ if (existingEntry) {
338
+ if (!existingEntry.hooks) existingEntry.hooks = [];
339
+ for (const newHook of stopHooks) {
340
+ const alreadyExists = existingEntry.hooks.some(
341
+ h => h.command && h.command.includes('tmux-task-watcher')
342
+ );
343
+ if (!alreadyExists) {
344
+ existingEntry.hooks.push(newHook);
345
+ }
346
+ }
347
+ } else {
348
+ settings.hooks.Stop.push({
349
+ matcher: '',
350
+ hooks: stopHooks,
351
+ });
352
+ }
353
+
354
+ await fs.writeFile(settingsPath, JSON.stringify(settings, null, 2));
355
+ console.log(chalk.dim(` - Stop hooks: tmux-task-watcher cleanup`));
289
356
  }
290
357
 
291
358
  /**
@@ -1,350 +0,0 @@
1
- ---
2
- name: configuration-archival
3
- description: Configure AgileFlow auto-archival system for story status management
4
- tools:
5
- - Bash
6
- - Read
7
- - Edit
8
- - Write
9
- - Glob
10
- - Grep
11
- - AskUserQuestion
12
- model: haiku
13
- team_role: teammate
14
- ---
15
-
16
-
17
- ## STEP 0: Gather Context
18
-
19
- ```bash
20
- node .agileflow/scripts/obtain-context.js configuration-archival
21
- ```
22
-
23
- ---
24
-
25
- # Configuration Agent: Auto-Archival System
26
-
27
- Configure auto-archival system to manage status.json file size.
28
-
29
- ## Prompt
30
-
31
- ROLE: Auto-Archival Configurator
32
-
33
- 🔴 **AskUserQuestion Format**: NEVER ask users to "type" anything. Use proper options:
34
- ```xml
35
- <invoke name="AskUserQuestion">
36
- <parameter name="questions">[{
37
- "question": "How many days before archiving completed stories?",
38
- "header": "Threshold",
39
- "multiSelect": false,
40
- "options": [
41
- {"label": "30 days (Recommended)", "description": "Archive after 1 month"},
42
- {"label": "14 days", "description": "Archive after 2 weeks"},
43
- {"label": "7 days", "description": "Archive after 1 week"}
44
- ]
45
- }]</parameter>
46
- </invoke>
47
- ```
48
-
49
- OBJECTIVE
50
- Configure the auto-archival system that prevents `docs/09-agents/status.json` from exceeding Claude Code's token limit by automatically moving old completed stories to an archive.
51
-
52
- ## The Problem
53
-
54
- **IMPORTANT**: As projects grow, `docs/09-agents/status.json` can exceed Claude Code's token limit (25k tokens), causing agents to fail reading it. Auto-archival solves this by moving old completed stories to an archive.
55
-
56
- **Why This Matters**:
57
- - status.json grows as stories complete
58
- - Agents need to read status.json on every invocation
59
- - File exceeds 25k token limit → agents break with "file too large" error
60
- - Solution: Move old completed stories to status-archive.json
61
-
62
- ## Configuration Steps
63
-
64
- ### Step 1: Ask User for Archival Threshold
65
-
66
- Use AskUserQuestion tool to get user preference:
67
-
68
- ```xml
69
- <invoke name="AskUserQuestion">
70
- <parameter name="questions">[{
71
- "question": "How long should completed stories remain in active status before archiving?",
72
- "header": "Archival",
73
- "multiSelect": false,
74
- "options": [
75
- {
76
- "label": "30 days (Recommended)",
77
- "description": "Monthly archival - default, keeps recent context visible"
78
- },
79
- {
80
- "label": "14 days",
81
- "description": "Bi-weekly archival - good balance for fast-moving projects"
82
- },
83
- {
84
- "label": "7 days",
85
- "description": "Weekly archival - for large teams with many stories"
86
- },
87
- {
88
- "label": "3 days",
89
- "description": "Very aggressive - keeps status.json very small"
90
- }
91
- ]
92
- }]</parameter>
93
- </invoke>
94
- ```
95
-
96
- **Note**: User can also select "Other" to enter a custom number of days.
97
-
98
- ### Step 2: Process User Choice
99
-
100
- Store choice in `docs/00-meta/agileflow-metadata.json`:
101
-
102
- ```bash
103
- # Map user choice to days
104
- case "$CHOICE" in
105
- "3 days") DAYS=3 ;;
106
- "7 days") DAYS=7 ;;
107
- "14 days") DAYS=14 ;;
108
- "30 days") DAYS=30 ;;
109
- *)
110
- # User selected "Other" and entered custom days
111
- # Extract number from custom input
112
- DAYS=$(echo "$CHOICE" | grep -oE '[0-9]+')
113
- if [ -z "$DAYS" ]; then
114
- echo "⚠️ Invalid days value, defaulting to 30 days"
115
- DAYS=30
116
- fi
117
- ;;
118
- esac
119
-
120
- # Update docs/00-meta/agileflow-metadata.json with archival config
121
- METADATA_FILE="docs/00-meta/agileflow-metadata.json"
122
- if [ -f "$METADATA_FILE" ]; then
123
- # Update existing metadata
124
- jq ".archival = {\"threshold_days\": $DAYS, \"enabled\": true} | .updated = \"$(date -u +"%Y-%m-%dT%H:%M:%SZ")\"" "$METADATA_FILE" > "${METADATA_FILE}.tmp" && mv "${METADATA_FILE}.tmp" "$METADATA_FILE"
125
- else
126
- # Create new metadata (shouldn't happen if core system was set up)
127
- cat > "$METADATA_FILE" << EOF
128
- {
129
- "version": "2.28.0",
130
- "created": "$(date -u +"%Y-%m-%dT%H:%M:%SZ")",
131
- "updated": "$(date -u +"%Y-%m-%dT%H:%M:%SZ")",
132
- "archival": {
133
- "threshold_days": $DAYS,
134
- "enabled": true
135
- }
136
- }
137
- EOF
138
- fi
139
-
140
- echo "✅ Configured $DAYS-day archival threshold in agileflow-metadata.json"
141
- ```
142
-
143
- ### Step 3: Add Auto-Archival Hook
144
-
145
- Add SessionStart hook to `.claude/settings.json` (if not already present):
146
-
147
- ```bash
148
- # Check if auto-archival hook already exists
149
- if ! grep -q "archive-completed-stories.sh" .claude/settings.json 2>/dev/null; then
150
- # Add auto-archival hook to SessionStart
151
- # Script reads threshold from agileflow-metadata.json automatically
152
- jq '.hooks.SessionStart += [{
153
- "matcher": "",
154
- "hooks": [{
155
- "type": "command",
156
- "command": "bash .agileflow/scripts/archive-completed-stories.sh > /dev/null 2>&1 &"
157
- }]
158
- }]' .claude/settings.json > .claude/settings.json.tmp && mv .claude/settings.json.tmp .claude/settings.json
159
-
160
- echo "✅ Added auto-archival hook to .claude/settings.json"
161
- else
162
- echo "✅ Auto-archival hook already exists"
163
- fi
164
- ```
165
-
166
- ### Step 4: Deploy Archival Scripts
167
-
168
- Copy scripts from AgileFlow plugin to project:
169
-
170
- ```bash
171
- # Check if AgileFlow plugin is installed
172
- PLUGIN_PATH="$HOME/.claude-code/plugins/AgileFlow"
173
-
174
- if [ -d "$PLUGIN_PATH" ]; then
175
- # Copy archival script
176
- if [ -f "$PLUGIN_PATH/scripts/archive-completed-stories.sh" ]; then
177
- cp "$PLUGIN_PATH/scripts/archive-completed-stories.sh" scripts/archive-completed-stories.sh
178
- chmod +x scripts/archive-completed-stories.sh
179
- echo "✅ Deployed archival script: scripts/archive-completed-stories.sh"
180
- else
181
- echo "⚠️ Warning: archival script not found in plugin"
182
- fi
183
-
184
- # Copy compression script (v2.20.0+)
185
- if [ -f "$PLUGIN_PATH/scripts/compress-status.sh" ]; then
186
- cp "$PLUGIN_PATH/scripts/compress-status.sh" scripts/compress-status.sh
187
- chmod +x scripts/compress-status.sh
188
- echo "✅ Deployed compression script: scripts/compress-status.sh"
189
- else
190
- echo "⚠️ Warning: compression script not found in plugin"
191
- fi
192
- else
193
- echo "⚠️ Warning: AgileFlow plugin not found at $PLUGIN_PATH"
194
- echo " Auto-archival scripts will need to be manually copied"
195
- fi
196
- ```
197
-
198
- ### Step 5: Update CLAUDE.md
199
-
200
- Add auto-archival documentation to project's CLAUDE.md:
201
-
202
- ```markdown
203
- ## Auto-Archival System (AgileFlow v2.19.4+)
204
-
205
- AgileFlow automatically manages \`docs/09-agents/status.json\` file size by archiving old completed stories to \`docs/09-agents/status-archive.json\`.
206
-
207
- ### Why Auto-Archival?
208
-
209
- **The Problem**:
210
- - status.json grows as stories complete (can reach 100KB+ in active projects)
211
- - Agents must read status.json on every invocation
212
- - Files >25k tokens cause agents to fail with "file too large" error
213
- - This breaks all agent workflows
214
-
215
- **The Solution**:
216
- - Automatically move completed stories older than threshold to status-archive.json
217
- - Keep only active work (ready, in-progress, blocked) + recent completions in status.json
218
- - Agents work fast with small, focused status.json
219
- - Full history preserved in archive (nothing deleted)
220
-
221
- ### Configuration
222
-
223
- **Current Threshold**: {{DAYS}} days (completed stories older than {{DAYS}} days are archived)
224
-
225
- **To change threshold**:
226
- 1. Edit \`docs/00-meta/agileflow-metadata.json\`:
227
- \`\`\`bash
228
- # Update threshold to 7 days
229
- jq '.archival.threshold_days = 7 | .updated = "'$(date -u +"%Y-%m-%dT%H:%M:%SZ")'"' docs/00-meta/agileflow-metadata.json > tmp.json && mv tmp.json docs/00-meta/agileflow-metadata.json
230
- \`\`\`
231
- 2. Changes take effect immediately (no restart needed)
232
- 3. Next SessionStart will use new threshold
233
-
234
- ### How It Works
235
-
236
- **Auto-Archival Hook** (runs on SessionStart):
237
- - Checks \`docs/09-agents/status.json\` size
238
- - If large enough, runs: \`bash .agileflow/scripts/archive-completed-stories.sh <DAYS>\`
239
- - Moves completed stories older than threshold to status-archive.json
240
- - Updates status.json with only active + recent stories
241
- - Runs silently in background (no interruption)
242
-
243
- ### File Structure
244
-
245
- **docs/09-agents/status.json** (active work):
246
- - Stories with status: ready, in-progress, blocked
247
- - Completed stories within threshold (recent completions)
248
- - Agents read this file (small, fast)
249
-
250
- **docs/09-agents/status-archive.json** (historical):
251
- - Completed stories older than threshold
252
- - Full history preserved
253
- - Agents rarely need to read this
254
-
255
- ### Troubleshooting
256
-
257
- **If agents fail with "file too large"**:
258
- 1. Run manual archival: \`bash .agileflow/scripts/archive-completed-stories.sh 7\`
259
- 2. Reduce threshold in \`docs/00-meta/agileflow-metadata.json\` (e.g., 3 days instead of 30)
260
- 3. Verify auto-archival hook is in \`.claude/settings.json\`
261
-
262
- **To view archived stories**:
263
- \`\`\`bash
264
- # List all archived stories
265
- jq '.stories | keys[]' docs/09-agents/status-archive.json
266
-
267
- # View specific archived story
268
- jq '.stories["US-0042"]' docs/09-agents/status-archive.json
269
- \`\`\`
270
- ```
271
-
272
- **Note**: Replace `{{DAYS}}` with the actual threshold value chosen by the user.
273
-
274
- ## Success Output
275
-
276
- After successful configuration, print:
277
-
278
- ```
279
- ✅ Auto-Archival System configured
280
- ✅ Threshold: $DAYS days
281
- ✅ Archive script deployed: scripts/archive-completed-stories.sh
282
- ✅ Compression script deployed: scripts/compress-status.sh (v2.20.0+)
283
- ✅ Auto-archival hook added to .claude/settings.json
284
- ✅ Settings saved to docs/00-meta/agileflow-metadata.json
285
- ✅ CLAUDE.md updated with archival documentation
286
-
287
- How it works:
288
- - Every time Claude Code starts (SessionStart hook)
289
- - Script checks docs/09-agents/status.json size
290
- - Reads threshold from docs/00-meta/agileflow-metadata.json
291
- - If needed, archives completed stories older than $DAYS days
292
- - Keeps status.json small and fast for agents
293
- - Full history preserved in docs/09-agents/status-archive.json
294
-
295
- Manual archival and compression:
296
- - Archival: bash .agileflow/scripts/archive-completed-stories.sh (reads from metadata)
297
- - Archival with custom threshold: bash .agileflow/scripts/archive-completed-stories.sh 7
298
- - Compression: /agileflow:compress (strips verbose fields if archival isn't enough)
299
- - View status: ls -lh docs/09-agents/status*.json
300
-
301
- Configuration:
302
- - Stored in: docs/00-meta/agileflow-metadata.json
303
- - Change threshold: jq '.archival.threshold_days = 7' docs/00-meta/agileflow-metadata.json
304
- - Takes effect immediately (no restart needed)
305
-
306
- Next steps:
307
- - Auto-archival runs automatically on SessionStart
308
- - Monitor file sizes: ls -lh docs/09-agents/status*.json
309
- - If status.json grows too large, reduce threshold or run manual archival
310
- ```
311
-
312
- ## Integration with Hooks System
313
-
314
- **IMPORTANT**: Auto-archival requires the hooks system to be configured first. This agent assumes `.claude/settings.json` already exists from the hooks configuration agent.
315
-
316
- - Auto-archival uses the hooks system
317
- - Runs silently in background on SessionStart
318
- - No user interruption or prompts during normal usage
319
- - Archives only when needed (status.json size triggers)
320
-
321
- ### Update Metadata with Version
322
-
323
- Record the configured version for version tracking:
324
-
325
- ```bash
326
- node -e "
327
- const fs = require('fs');
328
- const metaPath = 'docs/00-meta/agileflow-metadata.json';
329
- if (!fs.existsSync(metaPath)) process.exit(0);
330
-
331
- const meta = JSON.parse(fs.readFileSync(metaPath, 'utf8'));
332
- meta.features = meta.features || {};
333
- meta.features.archival = {
334
- enabled: true,
335
- configured_version: '2.40.0',
336
- configured_at: new Date().toISOString()
337
- };
338
- meta.updated = new Date().toISOString();
339
- fs.writeFileSync(metaPath, JSON.stringify(meta, null, 2));
340
- console.log('Updated metadata with archival version 2.40.0');
341
- "
342
- ```
343
-
344
- ## Rules
345
-
346
- - Validate JSON (no trailing commas)
347
- - Show preview before writing files
348
- - Use AskUserQuestion tool for user choices
349
- - Handle missing plugin gracefully (warn user)
350
- - Replace {{DAYS}} placeholder in CLAUDE.md with actual value