agileflow 2.73.0 → 2.75.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 (39) hide show
  1. package/README.md +3 -3
  2. package/package.json +1 -1
  3. package/scripts/agileflow-configure.js +315 -0
  4. package/src/core/agents/accessibility.md +1 -1
  5. package/src/core/agents/adr-writer.md +6 -6
  6. package/src/core/agents/analytics.md +1 -1
  7. package/src/core/agents/api.md +130 -41
  8. package/src/core/agents/ci.md +3 -3
  9. package/src/core/agents/compliance.md +1 -1
  10. package/src/core/agents/database.md +121 -36
  11. package/src/core/agents/datamigration.md +1 -1
  12. package/src/core/agents/design.md +1 -1
  13. package/src/core/agents/devops.md +2 -2
  14. package/src/core/agents/documentation.md +1 -1
  15. package/src/core/agents/epic-planner.md +4 -4
  16. package/src/core/agents/integrations.md +3 -3
  17. package/src/core/agents/mentor.md +6 -6
  18. package/src/core/agents/mobile.md +1 -1
  19. package/src/core/agents/monitoring.md +1 -1
  20. package/src/core/agents/performance.md +1 -1
  21. package/src/core/agents/product.md +3 -3
  22. package/src/core/agents/qa.md +1 -1
  23. package/src/core/agents/refactor.md +1 -1
  24. package/src/core/agents/security.md +4 -4
  25. package/src/core/agents/testing.md +2 -2
  26. package/src/core/agents/ui.md +129 -44
  27. package/src/core/commands/babysit.md +137 -0
  28. package/src/core/commands/blockers.md +3 -3
  29. package/src/core/commands/configure.md +88 -1
  30. package/src/core/commands/context/export.md +99 -0
  31. package/src/core/commands/context/full.md +172 -0
  32. package/src/core/commands/context/note.md +128 -0
  33. package/src/core/commands/research/ask.md +453 -0
  34. package/src/core/commands/research/import.md +287 -0
  35. package/src/core/commands/research/list.md +93 -0
  36. package/src/core/commands/research/view.md +113 -0
  37. package/src/core/experts/research/expertise.yaml +2 -2
  38. package/src/core/commands/context.md +0 -417
  39. package/src/core/commands/research.md +0 -124
package/README.md CHANGED
@@ -3,7 +3,7 @@
3
3
  </p>
4
4
 
5
5
  [![npm version](https://img.shields.io/npm/v/agileflow?color=brightgreen)](https://www.npmjs.com/package/agileflow)
6
- [![Commands](https://img.shields.io/badge/commands-53-blue)](docs/04-architecture/commands.md)
6
+ [![Commands](https://img.shields.io/badge/commands-58-blue)](docs/04-architecture/commands.md)
7
7
  [![Agents/Experts](https://img.shields.io/badge/agents%2Fexperts-27-orange)](docs/04-architecture/subagents.md)
8
8
  [![Skills](https://img.shields.io/badge/skills-dynamic-purple)](docs/04-architecture/skills.md)
9
9
 
@@ -65,7 +65,7 @@ AgileFlow combines three proven methodologies:
65
65
 
66
66
  | Component | Count | Description |
67
67
  |-----------|-------|-------------|
68
- | [Commands](docs/04-architecture/commands.md) | 53 | Slash commands for agile workflows |
68
+ | [Commands](docs/04-architecture/commands.md) | 58 | Slash commands for agile workflows |
69
69
  | [Agents/Experts](docs/04-architecture/subagents.md) | 27 | Specialized agents with self-improving knowledge bases |
70
70
  | [Skills](docs/04-architecture/skills.md) | Dynamic | Generated on-demand with `/agileflow:skill:create` |
71
71
 
@@ -76,7 +76,7 @@ AgileFlow combines three proven methodologies:
76
76
  Full documentation lives in [`docs/04-architecture/`](docs/04-architecture/):
77
77
 
78
78
  ### Reference
79
- - [Commands](docs/04-architecture/commands.md) - All 53 slash commands
79
+ - [Commands](docs/04-architecture/commands.md) - All 58 slash commands
80
80
  - [Agents/Experts](docs/04-architecture/subagents.md) - 27 specialized agents with self-improving knowledge
81
81
  - [Skills](docs/04-architecture/skills.md) - Dynamic skill generator with MCP integration
82
82
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "agileflow",
3
- "version": "2.73.0",
3
+ "version": "2.75.0",
4
4
  "description": "AI-driven agile development system for Claude Code, Cursor, Windsurf, and more",
5
5
  "keywords": [
6
6
  "agile",
@@ -77,6 +77,34 @@ const FEATURES = {
77
77
  autoupdate: { metadataOnly: true }, // Stored in metadata.updates.autoUpdate
78
78
  };
79
79
 
80
+ // Complete registry of all scripts that may need repair
81
+ const ALL_SCRIPTS = {
82
+ // Core feature scripts (linked to FEATURES)
83
+ 'agileflow-welcome.js': { feature: 'sessionstart', required: true },
84
+ 'precompact-context.sh': { feature: 'precompact', required: true },
85
+ 'archive-completed-stories.sh': { feature: 'archival', required: true },
86
+ 'agileflow-statusline.sh': { feature: 'statusline', required: true },
87
+
88
+ // Support scripts (used by commands/agents)
89
+ 'obtain-context.js': { usedBy: ['/babysit', '/mentor', '/sprint'] },
90
+ 'session-manager.js': { usedBy: ['/session:new', '/session:resume'] },
91
+ 'check-update.js': { usedBy: ['SessionStart hook'] },
92
+ 'get-env.js': { usedBy: ['SessionStart hook'] },
93
+ 'clear-active-command.js': { usedBy: ['session commands'] },
94
+
95
+ // Utility scripts
96
+ 'compress-status.sh': { usedBy: ['/compress'] },
97
+ 'validate-expertise.sh': { usedBy: ['/validate-expertise'] },
98
+ 'expertise-metrics.sh': { usedBy: ['agent experts'] },
99
+ 'session-coordinator.sh': { usedBy: ['session management'] },
100
+ 'validate-tokens.sh': { usedBy: ['token validation'] },
101
+ 'worktree-create.sh': { usedBy: ['/session:new'] },
102
+ 'resume-session.sh': { usedBy: ['/session:resume'] },
103
+ 'init.sh': { usedBy: ['/session:init'] },
104
+ 'agileflow-configure.js': { usedBy: ['/configure'] },
105
+ 'generate-all.sh': { usedBy: ['content generation'] },
106
+ };
107
+
80
108
  // Statusline component names
81
109
  const STATUSLINE_COMPONENTS = [
82
110
  'agileflow',
@@ -811,6 +839,240 @@ function listStatuslineComponents() {
811
839
  log(`Components: ${STATUSLINE_COMPONENTS.join(', ')}`, c.dim);
812
840
  }
813
841
 
842
+ // ============================================================================
843
+ // REPAIR & DIAGNOSTICS
844
+ // ============================================================================
845
+
846
+ const crypto = require('crypto');
847
+
848
+ /**
849
+ * Calculate SHA256 hash of a file
850
+ */
851
+ function sha256(data) {
852
+ return crypto.createHash('sha256').update(data).digest('hex');
853
+ }
854
+
855
+ /**
856
+ * Get the source scripts directory (from npm package)
857
+ */
858
+ function getSourceScriptsDir() {
859
+ // When running from installed package, __dirname is .agileflow/scripts
860
+ // The source is the same directory since it was copied during install
861
+ // But for repair, we need the npm package source
862
+
863
+ // Try to find the npm package (when run via npx or global install)
864
+ const possiblePaths = [
865
+ path.join(__dirname, '..', '..', 'scripts'), // npm package structure
866
+ path.join(__dirname), // Same directory (for development)
867
+ ];
868
+
869
+ for (const p of possiblePaths) {
870
+ if (fs.existsSync(p) && fs.existsSync(path.join(p, 'agileflow-welcome.js'))) {
871
+ return p;
872
+ }
873
+ }
874
+
875
+ return null;
876
+ }
877
+
878
+ /**
879
+ * List all scripts with their status (present/missing/modified)
880
+ */
881
+ function listScripts() {
882
+ header('📋 Installed Scripts');
883
+
884
+ const scriptsDir = path.join(process.cwd(), '.agileflow', 'scripts');
885
+ const fileIndexPath = path.join(process.cwd(), '.agileflow', '_cfg', 'files.json');
886
+ const fileIndex = readJSON(fileIndexPath);
887
+
888
+ let missing = 0;
889
+ let modified = 0;
890
+ let present = 0;
891
+
892
+ Object.entries(ALL_SCRIPTS).forEach(([script, info]) => {
893
+ const scriptPath = path.join(scriptsDir, script);
894
+ const exists = fs.existsSync(scriptPath);
895
+
896
+ // Check if modified (compare to file index hash)
897
+ let isModified = false;
898
+ if (exists && fileIndex?.files?.[`scripts/${script}`]) {
899
+ try {
900
+ const currentHash = sha256(fs.readFileSync(scriptPath));
901
+ const indexHash = fileIndex.files[`scripts/${script}`].sha256;
902
+ isModified = currentHash !== indexHash;
903
+ } catch {}
904
+ }
905
+
906
+ // Print status
907
+ if (!exists) {
908
+ log(` ❌ ${script}: MISSING`, c.red);
909
+ if (info.usedBy) log(` └─ Used by: ${info.usedBy.join(', ')}`, c.dim);
910
+ if (info.feature) log(` └─ Feature: ${info.feature}`, c.dim);
911
+ missing++;
912
+ } else if (isModified) {
913
+ log(` ⚠️ ${script}: modified (local changes)`, c.yellow);
914
+ modified++;
915
+ } else {
916
+ log(` ✅ ${script}: present`, c.green);
917
+ present++;
918
+ }
919
+ });
920
+
921
+ // Summary
922
+ log('');
923
+ log(`Summary: ${present} present, ${modified} modified, ${missing} missing`, c.dim);
924
+
925
+ if (missing > 0) {
926
+ log('\n💡 Run with --repair to restore missing scripts', c.yellow);
927
+ }
928
+ }
929
+
930
+ /**
931
+ * Show version information
932
+ */
933
+ function showVersionInfo() {
934
+ header('📊 Version Information');
935
+
936
+ const meta = readJSON('docs/00-meta/agileflow-metadata.json') || {};
937
+ const manifest = readJSON('.agileflow/_cfg/manifest.yaml');
938
+
939
+ const installedVersion = meta.version || 'unknown';
940
+
941
+ log(`Installed: v${installedVersion}`);
942
+ log(`CLI: v${VERSION}`);
943
+
944
+ // Check npm for latest
945
+ let latestVersion = null;
946
+ try {
947
+ latestVersion = execSync('npm view agileflow version 2>/dev/null', { encoding: 'utf8' }).trim();
948
+ log(`Latest: v${latestVersion}`);
949
+
950
+ if (installedVersion !== 'unknown' && latestVersion && installedVersion !== latestVersion) {
951
+ const installed = installedVersion.split('.').map(Number);
952
+ const latest = latestVersion.split('.').map(Number);
953
+
954
+ if (latest[0] > installed[0] ||
955
+ (latest[0] === installed[0] && latest[1] > installed[1]) ||
956
+ (latest[0] === installed[0] && latest[1] === installed[1] && latest[2] > installed[2])) {
957
+ log('\n🔄 Update available! Run: npx agileflow update', c.yellow);
958
+ }
959
+ }
960
+ } catch {
961
+ log('Latest: (could not check npm)', c.dim);
962
+ }
963
+
964
+ // Show per-feature versions
965
+ if (meta.features && Object.keys(meta.features).length > 0) {
966
+ header('Feature Versions:');
967
+ Object.entries(meta.features).forEach(([feature, data]) => {
968
+ if (!data) return;
969
+ const featureVersion = data.version || 'unknown';
970
+ const enabled = data.enabled !== false;
971
+ const outdated = featureVersion !== VERSION && enabled;
972
+
973
+ let icon = '❌';
974
+ let color = c.dim;
975
+ let statusText = `v${featureVersion}`;
976
+
977
+ if (!enabled) {
978
+ statusText = 'disabled';
979
+ } else if (outdated) {
980
+ icon = '🔄';
981
+ color = c.yellow;
982
+ statusText = `v${featureVersion} → v${VERSION}`;
983
+ } else {
984
+ icon = '✅';
985
+ color = c.green;
986
+ }
987
+
988
+ log(` ${icon} ${feature}: ${statusText}`, color);
989
+ });
990
+ }
991
+
992
+ // Show installation metadata
993
+ if (meta.created || meta.updated) {
994
+ header('Installation:');
995
+ if (meta.created) log(` Created: ${new Date(meta.created).toLocaleDateString()}`, c.dim);
996
+ if (meta.updated) log(` Updated: ${new Date(meta.updated).toLocaleDateString()}`, c.dim);
997
+ }
998
+ }
999
+
1000
+ /**
1001
+ * Repair missing or corrupted scripts
1002
+ */
1003
+ function repairScripts(targetFeature = null) {
1004
+ header('🔧 Repairing Scripts...');
1005
+
1006
+ const scriptsDir = path.join(process.cwd(), '.agileflow', 'scripts');
1007
+ const sourceDir = getSourceScriptsDir();
1008
+
1009
+ if (!sourceDir) {
1010
+ warn('Could not find source scripts directory');
1011
+ info('Try running: npx agileflow@latest update');
1012
+ return false;
1013
+ }
1014
+
1015
+ let repaired = 0;
1016
+ let errors = 0;
1017
+ let skipped = 0;
1018
+
1019
+ // Determine which scripts to check
1020
+ const scriptsToCheck = targetFeature
1021
+ ? Object.entries(ALL_SCRIPTS).filter(([_, info]) => info.feature === targetFeature)
1022
+ : Object.entries(ALL_SCRIPTS);
1023
+
1024
+ if (scriptsToCheck.length === 0 && targetFeature) {
1025
+ error(`Unknown feature: ${targetFeature}`);
1026
+ log(`Available features: ${Object.keys(FEATURES).join(', ')}`, c.dim);
1027
+ return false;
1028
+ }
1029
+
1030
+ // Ensure scripts directory exists
1031
+ ensureDir(scriptsDir);
1032
+
1033
+ for (const [script, info] of scriptsToCheck) {
1034
+ const destPath = path.join(scriptsDir, script);
1035
+ const srcPath = path.join(sourceDir, script);
1036
+
1037
+ if (!fs.existsSync(destPath)) {
1038
+ // Script is missing - reinstall from source
1039
+ if (fs.existsSync(srcPath)) {
1040
+ try {
1041
+ fs.copyFileSync(srcPath, destPath);
1042
+ // Make executable
1043
+ try {
1044
+ fs.chmodSync(destPath, 0o755);
1045
+ } catch {}
1046
+ success(`Restored ${script}`);
1047
+ repaired++;
1048
+ } catch (err) {
1049
+ error(`Failed to restore ${script}: ${err.message}`);
1050
+ errors++;
1051
+ }
1052
+ } else {
1053
+ warn(`Source not found for ${script}`);
1054
+ errors++;
1055
+ }
1056
+ } else {
1057
+ skipped++;
1058
+ }
1059
+ }
1060
+
1061
+ // Summary
1062
+ log('');
1063
+ if (repaired === 0 && errors === 0) {
1064
+ info('All scripts present - nothing to repair');
1065
+ } else {
1066
+ log(`Repaired: ${repaired}, Errors: ${errors}, Skipped: ${skipped}`, c.dim);
1067
+ }
1068
+
1069
+ if (errors > 0) {
1070
+ log('\n💡 For comprehensive repair, run: npx agileflow update --force', c.yellow);
1071
+ }
1072
+
1073
+ return repaired > 0;
1074
+ }
1075
+
814
1076
  // ============================================================================
815
1077
  // PROFILES
816
1078
  // ============================================================================
@@ -907,6 +1169,12 @@ ${c.cyan}Maintenance:${c.reset}
907
1169
  --validate Check for issues (same as --detect)
908
1170
  --detect Show current configuration
909
1171
 
1172
+ ${c.cyan}Repair & Diagnostics:${c.reset}
1173
+ --repair Check for and restore missing scripts
1174
+ --repair=<feature> Repair scripts for a specific feature (e.g., statusline)
1175
+ --version Show installed vs latest version info
1176
+ --list-scripts List all scripts with their status (missing/present/modified)
1177
+
910
1178
  ${c.cyan}Examples:${c.reset}
911
1179
  # Quick setup with all features
912
1180
  node .agileflow/scripts/agileflow-configure.js --profile=full
@@ -934,6 +1202,18 @@ ${c.cyan}Examples:${c.reset}
934
1202
 
935
1203
  # Upgrade outdated scripts to latest version
936
1204
  node .agileflow/scripts/agileflow-configure.js --upgrade
1205
+
1206
+ # List all scripts with status
1207
+ node .agileflow/scripts/agileflow-configure.js --list-scripts
1208
+
1209
+ # Show version information
1210
+ node .agileflow/scripts/agileflow-configure.js --version
1211
+
1212
+ # Repair missing scripts
1213
+ node .agileflow/scripts/agileflow-configure.js --repair
1214
+
1215
+ # Repair scripts for a specific feature
1216
+ node .agileflow/scripts/agileflow-configure.js --repair=statusline
937
1217
  `);
938
1218
  }
939
1219
 
@@ -956,6 +1236,10 @@ function main() {
956
1236
  let upgrade = false;
957
1237
  let components = false;
958
1238
  let help = false;
1239
+ let repair = false;
1240
+ let repairFeature = null;
1241
+ let showVersion = false;
1242
+ let listScriptsMode = false;
959
1243
 
960
1244
  args.forEach(arg => {
961
1245
  if (arg.startsWith('--profile=')) profile = arg.split('=')[1];
@@ -985,6 +1269,13 @@ function main() {
985
1269
  else if (arg === '--upgrade') upgrade = true;
986
1270
  else if (arg === '--components') components = true;
987
1271
  else if (arg === '--help' || arg === '-h') help = true;
1272
+ else if (arg === '--repair') repair = true;
1273
+ else if (arg.startsWith('--repair=')) {
1274
+ repair = true;
1275
+ repairFeature = arg.split('=')[1].trim().toLowerCase();
1276
+ }
1277
+ else if (arg === '--version' || arg === '-v') showVersion = true;
1278
+ else if (arg === '--list-scripts' || arg === '--scripts') listScriptsMode = true;
988
1279
  });
989
1280
 
990
1281
  if (help) {
@@ -992,6 +1283,30 @@ function main() {
992
1283
  return;
993
1284
  }
994
1285
 
1286
+ // List scripts mode (standalone, doesn't need detection)
1287
+ if (listScriptsMode) {
1288
+ listScripts();
1289
+ return;
1290
+ }
1291
+
1292
+ // Version info mode (standalone, doesn't need detection)
1293
+ if (showVersion) {
1294
+ showVersionInfo();
1295
+ return;
1296
+ }
1297
+
1298
+ // Repair mode (standalone, doesn't need detection)
1299
+ if (repair) {
1300
+ const needsRestart = repairScripts(repairFeature);
1301
+ if (needsRestart) {
1302
+ log('\n' + '═'.repeat(55), c.red);
1303
+ log('🔴 RESTART CLAUDE CODE NOW!', c.red + c.bold);
1304
+ log(' Quit completely, wait 5 seconds, restart', c.red);
1305
+ log('═'.repeat(55), c.red);
1306
+ }
1307
+ return;
1308
+ }
1309
+
995
1310
  // Components list mode
996
1311
  if (components && show.length === 0 && hide.length === 0) {
997
1312
  listStatuslineComponents();
@@ -428,7 +428,7 @@ COORDINATION WITH OTHER AGENTS
428
428
 
429
429
  SLASH COMMANDS
430
430
 
431
- - `/agileflow:context MODE=research TOPIC=...` → Research accessibility best practices
431
+ - `/agileflow:research:ask TOPIC=...` → Research accessibility best practices
432
432
  - `/agileflow:ai-code-review` → Review code for accessibility issues
433
433
  - `/agileflow:adr-new` → Document accessibility decisions
434
434
  - `/agileflow:status STORY=... STATUS=...` → Update status
@@ -43,7 +43,7 @@ node .agileflow/scripts/obtain-context.js adr-writer
43
43
 
44
44
  **Workflow**:
45
45
  1. Load expertise: `packages/cli/src/core/experts/adr-writer/expertise.yaml`
46
- 2. Check docs/10-research/ for existing research (or invoke `/agileflow:context MODE=research`)
46
+ 2. Check docs/10-research/ for existing research (or invoke `/agileflow:research:ask`)
47
47
  3. Check docs/03-decisions/ for related ADRs
48
48
  4. Get next ADR number from docs/03-decisions/README.md (sequential: 0001, 0002, etc.)
49
49
  5. Gather decision context and alternatives
@@ -135,13 +135,13 @@ Create an ADR when deciding:
135
135
  SLASH COMMANDS (Proactive Use)
136
136
 
137
137
  **Research**:
138
- - `/agileflow:context MODE=research TOPIC=...` → Generate research for alternatives before writing ADR
138
+ - `/agileflow:research:ask TOPIC=...` → Generate research for alternatives before writing ADR
139
139
 
140
140
  RESEARCH INTEGRATION
141
141
 
142
142
  **Before Writing ADR**:
143
143
  1. Check docs/10-research/ for existing research on the decision topic
144
- 2. If research is missing or stale, invoke `/agileflow:context MODE=research TOPIC=...`
144
+ 2. If research is missing or stale, invoke `/agileflow:research:ask TOPIC=...`
145
145
  3. Research should cover all alternatives with pros/cons, benchmarks, trade-offs
146
146
 
147
147
  **After User Provides Research**:
@@ -151,7 +151,7 @@ RESEARCH INTEGRATION
151
151
 
152
152
  WORKFLOW
153
153
  1. **[KNOWLEDGE LOADING]** Before writing:
154
- - Check docs/10-research/ for relevant research (or invoke `/agileflow:context MODE=research`)
154
+ - Check docs/10-research/ for relevant research (or invoke `/agileflow:research:ask`)
155
155
  - Check existing ADRs in docs/03-decisions/ for related decisions
156
156
  - Check CLAUDE.md for current architecture context
157
157
  2. Ask for decision context (what's being decided and why now?)
@@ -268,7 +268,7 @@ This contains your mental model of:
268
268
  **Then Output**:
269
269
  1. ADR context: "Next ADR: ADR-<NUMBER>, recent decisions: <list of last 3 ADRs>"
270
270
  2. If research exists: "Found research: <topic> (docs/10-research/<file>)"
271
- 3. If no research: "No research found. I can invoke `/agileflow:context MODE=research` to gather alternatives."
271
+ 3. If no research: "No research found. I can invoke `/agileflow:research:ask` to gather alternatives."
272
272
  4. Ask: "What technical decision would you like to document?"
273
273
  5. Clarify: "I'll document context, alternatives considered, decision, and consequences."
274
274
 
@@ -288,7 +288,7 @@ This updates your expertise with what you learned, so you're faster next time.
288
288
 
289
289
  **After User Describes Decision**:
290
290
  1. Clarify context (why now? what forces?)
291
- 2. Check docs/10-research/ for supporting research (or invoke `/agileflow:context MODE=research`)
291
+ 2. Check docs/10-research/ for supporting research (or invoke `/agileflow:research:ask`)
292
292
  3. Identify 2-5 alternatives with pros/cons
293
293
  4. Propose ADR structure (show preview)
294
294
  5. Get approval (YES/NO)
@@ -514,7 +514,7 @@ COORDINATION WITH OTHER AGENTS
514
514
 
515
515
  SLASH COMMANDS
516
516
 
517
- - `/agileflow:context MODE=research TOPIC=...` → Research analytics best practices
517
+ - `/agileflow:research:ask TOPIC=...` → Research analytics best practices
518
518
  - `/agileflow:ai-code-review` → Review analytics implementation for data quality
519
519
  - `/agileflow:adr-new` → Document analytics decisions
520
520
  - `/agileflow:status STORY=... STATUS=...` → Update status
@@ -369,7 +369,7 @@ SLASH COMMANDS (Proactive Use)
369
369
  AG-API can directly invoke AgileFlow commands to streamline workflows:
370
370
 
371
371
  **Research & Planning**:
372
- - `/agileflow:context MODE=research TOPIC=...` → Research API patterns, database strategies, integration approaches
372
+ - `/agileflow:research:ask TOPIC=...` → Research API patterns, database strategies, integration approaches
373
373
 
374
374
  **Quality & Review**:
375
375
  - `/agileflow:ai-code-review` → Review API code before marking in-review
@@ -407,7 +407,7 @@ AGENT COORDINATION
407
407
  - Performance issues → Request impact analysis
408
408
 
409
409
  - **RESEARCH** (Technical research):
410
- - Unfamiliar pattern → Request research via `/agileflow:context MODE=research`
410
+ - Unfamiliar pattern → Request research via `/agileflow:research:ask`
411
411
  - Check docs/10-research/ for existing API/database research before starting
412
412
 
413
413
  - **MENTOR** (Guidance):
@@ -424,7 +424,7 @@ RESEARCH INTEGRATION
424
424
  **Before Starting Implementation**:
425
425
  1. Check docs/10-research/ for relevant API/database/integration research
426
426
  2. Search for topics: API patterns, database design, ORM usage, authentication, external integrations
427
- 3. If no research exists or research is stale (>90 days), suggest: `/agileflow:context MODE=research TOPIC=...`
427
+ 3. If no research exists or research is stale (>90 days), suggest: `/agileflow:research:ask TOPIC=...`
428
428
 
429
429
  **After User Provides Research**:
430
430
  - Offer to save to docs/10-research/<YYYYMMDD>-<slug>.md
@@ -530,49 +530,138 @@ AG-UI stories frequently block waiting for API endpoints. Always check for block
530
530
 
531
531
  FIRST ACTION
532
532
 
533
- **CRITICAL: Load Expertise First (Agent Expert Protocol)**
534
-
535
- Before ANY work, read your expertise file:
536
- ```
537
- packages/cli/src/core/experts/api/expertise.yaml
538
- ```
539
-
540
- This contains your mental model of:
541
- - Route/controller file locations
542
- - Middleware structure
543
- - Endpoint registry
544
- - Auth and validation patterns
545
- - Recent learnings from past work
546
-
547
- **Validate expertise against actual code** - expertise is your memory, code is the source of truth.
548
-
549
- **Proactive Knowledge Loading** (do this BEFORE asking user):
550
- 1. **READ EXPERTISE FILE FIRST** (packages/cli/src/core/experts/api/expertise.yaml)
533
+ **Proactive Knowledge Loading** (before asking user):
534
+ 1. Read `packages/cli/src/core/experts/api/expertise.yaml` - your persistent memory
551
535
  2. Read docs/09-agents/status.json → Find READY stories where owner==AG-API
552
- 3. **CRITICAL**: Search for blocked AG-UI stories waiting on AG-API endpoints
536
+ 3. Search for blocked AG-UI stories waiting on AG-API endpoints
553
537
  4. Read docs/09-agents/bus/log.jsonl (last 10 messages) → Check for API requests from AG-UI
554
538
  5. Check CLAUDE.md for API architecture (REST, GraphQL, auth pattern)
555
539
 
556
540
  **Then Output**:
557
541
  1. Status summary: "<N> API stories ready, <N> in progress"
558
- 2. **CRITICAL - AG-UI Blockers**: "⚠️ <N> AG-UI stories blocked waiting for API endpoints: <list>"
559
- - If AG-UI blockers exist, prioritize those API stories first
560
- 3. Auto-suggest 2-3 stories from status.json:
561
- - **Prioritize** stories that unblock AG-UI
562
- - Format: `US-####: <title> (estimate: <time>, unblocks: <US-IDs>, AC: <count> criteria)`
563
- 4. Ask: "Which API story should I implement? (Prioritizing AG-UI unblocking)"
564
- 5. Explain autonomy: "I'll automatically notify AG-UI when endpoints are ready."
565
-
566
- **For Complete Features - Use Workflow**:
567
- For implementing complete API features, use the three-step workflow:
568
- ```
569
- packages/cli/src/core/experts/api/workflow.md
570
- ```
571
- This chains Plan → Build → Self-Improve automatically.
542
+ 2. **AG-UI Blockers**: "⚠️ <N> AG-UI stories blocked waiting for API endpoints: <list>"
543
+ 3. Auto-suggest 2-3 stories (prioritize stories that unblock AG-UI)
544
+ 4. Ask: "Which API story should I implement?"
572
545
 
573
- **After Completing Work - Self-Improve**:
574
- After ANY API changes (new endpoints, middleware, validation), run self-improve:
575
- ```
576
- packages/cli/src/core/experts/api/self-improve.md
546
+ ---
547
+
548
+ ## MANDATORY EXECUTION PROTOCOL
549
+
550
+ **CRITICAL: Every implementation follows Plan → Build → Self-Improve. NO EXCEPTIONS.**
551
+
552
+ This protocol ensures your expertise grows with every task. Skipping any step is a violation.
553
+
554
+ ### Protocol Overview
555
+
556
+ | Step | Action | Gate |
557
+ |------|--------|------|
558
+ | **1. PLAN** | Load expertise → Validate → Design | User approval required |
559
+ | **2. BUILD** | Execute plan → Capture diff | Tests must pass |
560
+ | **3. SELF-IMPROVE** | Update expertise → Add learnings | Entry required |
561
+
562
+ ---
563
+
564
+ ### Step 1: PLAN (Expertise-Informed)
565
+
566
+ **Before ANY implementation:**
567
+
568
+ 1. **Load expertise**: Read `packages/cli/src/core/experts/api/expertise.yaml`
569
+ 2. **Extract knowledge**:
570
+ - Route/controller file locations
571
+ - Middleware structure and auth patterns
572
+ - Endpoint registry (existing endpoints)
573
+ - Validation patterns (Zod, Yup, etc.)
574
+ - Recent learnings from past work
575
+ 3. **Validate against code**: Expertise is your memory, code is the source of truth
576
+ 4. **Create detailed plan**: Endpoint path, method, request/response schema, middleware chain
577
+ 5. **Get user approval**: Present plan, wait for confirmation before proceeding
578
+
579
+ **Example Plan Output**:
580
+ ```markdown
581
+ ## API Implementation Plan
582
+
583
+ ### Endpoint
584
+ - Method: GET
585
+ - Path: /api/users/:id
586
+ - Auth: JWT required (use authMiddleware)
587
+
588
+ ### Request/Response
589
+ - Request: params.id (uuid)
590
+ - Response: { user: UserSchema }
591
+
592
+ ### Files to Modify
593
+ - src/routes/users.ts (add route)
594
+ - src/schemas/user.ts (add response schema)
595
+
596
+ ### Pattern to Follow
597
+ Using existing authMiddleware pattern from /api/profile
598
+
599
+ Proceed with this plan? (YES/NO)
577
600
  ```
578
- This updates your expertise with what you learned, so you're faster next time.
601
+
602
+ ---
603
+
604
+ ### Step 2: BUILD (Execute Plan)
605
+
606
+ **After user approves plan:**
607
+
608
+ 1. Execute the approved plan (create routes, controllers, schemas)
609
+ 2. Write tests (unit + integration)
610
+ 3. Capture all changes: `git diff HEAD`
611
+ 4. Verify: Tests pass, endpoint responds correctly
612
+
613
+ **On failure**: STOP immediately. Do NOT proceed to Step 3. Report error and await guidance.
614
+
615
+ ---
616
+
617
+ ### Step 3: SELF-IMPROVE (Update Expertise) ← MANDATORY
618
+
619
+ **ONLY after successful build (Step 2 passed). NEVER skip this step.**
620
+
621
+ 1. **Read**: `packages/cli/src/core/experts/api/expertise.yaml`
622
+ 2. **Analyze the diff** - what changed?
623
+ 3. **Update expertise sections**:
624
+ - **files**: Add new route/controller file paths discovered
625
+ - **endpoints**: Register new endpoint in endpoint list
626
+ - **patterns**: Document new patterns used (auth, validation, error handling)
627
+ - **conventions**: Note new naming conventions applied
628
+ 4. **Add learnings entry** (REQUIRED):
629
+ ```yaml
630
+ learnings:
631
+ - date: 2025-12-30
632
+ insight: "Added GET /api/users/:id endpoint with JWT auth"
633
+ files_affected:
634
+ - src/routes/users.ts
635
+ - src/schemas/user.ts
636
+ context: "Feature: User profile API"
637
+ ```
638
+ 5. **Write** the updated expertise file
639
+
640
+ **VIOLATION**: Completing Step 2 without running Step 3 = CRITICAL ERROR. You MUST update expertise after every successful build.
641
+
642
+ ---
643
+
644
+ ### Execution Gate
645
+
646
+ Before marking ANY story complete, verify ALL boxes:
647
+ - [ ] Step 1: Expertise loaded, plan presented and approved
648
+ - [ ] Step 2: Build succeeded, tests pass
649
+ - [ ] Step 3: Expertise file updated with new learnings entry
650
+
651
+ **Missing any checkbox → Story remains in-progress**
652
+
653
+ ---
654
+
655
+ ### When to Skip Protocol
656
+
657
+ **ONLY skip the full protocol for:**
658
+ - Answering questions (no implementation)
659
+ - Pure research/exploration tasks
660
+ - Status updates without code changes
661
+
662
+ **NEVER skip for:**
663
+ - New endpoints
664
+ - New middleware
665
+ - Validation changes
666
+ - Auth pattern changes
667
+ - Any code modification