agentic-qe 2.3.2 → 2.3.3

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 (127) hide show
  1. package/CHANGELOG.md +43 -0
  2. package/README.md +1 -1
  3. package/dist/agents/CoverageAnalyzerAgent.d.ts.map +1 -1
  4. package/dist/agents/CoverageAnalyzerAgent.js +53 -27
  5. package/dist/agents/CoverageAnalyzerAgent.js.map +1 -1
  6. package/dist/agents/FlakyTestHunterAgent.d.ts +5 -0
  7. package/dist/agents/FlakyTestHunterAgent.d.ts.map +1 -1
  8. package/dist/agents/FlakyTestHunterAgent.js +20 -5
  9. package/dist/agents/FlakyTestHunterAgent.js.map +1 -1
  10. package/dist/agents/QualityGateAgent.js +44 -6
  11. package/dist/agents/QualityGateAgent.js.map +1 -1
  12. package/dist/cli/index.js +0 -0
  13. package/dist/cli/init/database-init.js +5 -0
  14. package/dist/cli/init/database-init.js.map +1 -1
  15. package/dist/learning/PerformanceTracker.d.ts +9 -0
  16. package/dist/learning/PerformanceTracker.d.ts.map +1 -1
  17. package/dist/learning/PerformanceTracker.js +26 -2
  18. package/dist/learning/PerformanceTracker.js.map +1 -1
  19. package/dist/mcp/server-instructions.d.ts +1 -1
  20. package/dist/mcp/server-instructions.js +1 -1
  21. package/package.json +3 -1
  22. package/scripts/README.md +352 -0
  23. package/scripts/hooks/capture-task-learning.js +191 -0
  24. package/scripts/hooks/emit-task-complete.sh +35 -0
  25. package/scripts/hooks/emit-task-spawn.sh +27 -0
  26. package/.claude/agents/failing-agent.json +0 -9
  27. package/.claude/agents/test-agent.json +0 -9
  28. package/dist/App.d.ts +0 -5
  29. package/dist/App.d.ts.map +0 -1
  30. package/dist/App.js +0 -15
  31. package/dist/App.js.map +0 -1
  32. package/dist/cli/init/utils.d.ts +0 -183
  33. package/dist/cli/init/utils.d.ts.map +0 -1
  34. package/dist/cli/init/utils.js +0 -354
  35. package/dist/cli/init/utils.js.map +0 -1
  36. package/dist/components/Dashboard/Dashboard.d.ts +0 -4
  37. package/dist/components/Dashboard/Dashboard.d.ts.map +0 -1
  38. package/dist/components/Dashboard/Dashboard.js +0 -148
  39. package/dist/components/Dashboard/Dashboard.js.map +0 -1
  40. package/dist/components/Dashboard/DashboardHeader.d.ts +0 -4
  41. package/dist/components/Dashboard/DashboardHeader.d.ts.map +0 -1
  42. package/dist/components/Dashboard/DashboardHeader.js +0 -138
  43. package/dist/components/Dashboard/DashboardHeader.js.map +0 -1
  44. package/dist/contexts/DashboardContext.d.ts +0 -41
  45. package/dist/contexts/DashboardContext.d.ts.map +0 -1
  46. package/dist/contexts/DashboardContext.js +0 -187
  47. package/dist/contexts/DashboardContext.js.map +0 -1
  48. package/dist/core/transport/QUICTransport.d.ts +0 -320
  49. package/dist/core/transport/QUICTransport.d.ts.map +0 -1
  50. package/dist/core/transport/QUICTransport.js +0 -711
  51. package/dist/core/transport/QUICTransport.js.map +0 -1
  52. package/dist/learning/LearningPersistenceAdapter.d.ts +0 -84
  53. package/dist/learning/LearningPersistenceAdapter.d.ts.map +0 -1
  54. package/dist/learning/LearningPersistenceAdapter.js +0 -202
  55. package/dist/learning/LearningPersistenceAdapter.js.map +0 -1
  56. package/dist/learning/algorithms/QLearning.d.ts +0 -68
  57. package/dist/learning/algorithms/QLearning.d.ts.map +0 -1
  58. package/dist/learning/algorithms/QLearning.js +0 -116
  59. package/dist/learning/algorithms/QLearning.js.map +0 -1
  60. package/dist/mcp/handlers/advanced/requirements-generate-bdd.d.ts +0 -7
  61. package/dist/mcp/handlers/advanced/requirements-generate-bdd.d.ts.map +0 -1
  62. package/dist/mcp/handlers/advanced/requirements-generate-bdd.js +0 -267
  63. package/dist/mcp/handlers/advanced/requirements-generate-bdd.js.map +0 -1
  64. package/dist/mcp/handlers/advanced/requirements-validate.d.ts +0 -7
  65. package/dist/mcp/handlers/advanced/requirements-validate.d.ts.map +0 -1
  66. package/dist/mcp/handlers/advanced/requirements-validate.js +0 -175
  67. package/dist/mcp/handlers/advanced/requirements-validate.js.map +0 -1
  68. package/dist/mcp/handlers/analysis/performance-benchmark-run-handler.d.ts +0 -15
  69. package/dist/mcp/handlers/analysis/performance-benchmark-run-handler.d.ts.map +0 -1
  70. package/dist/mcp/handlers/analysis/performance-benchmark-run-handler.js +0 -43
  71. package/dist/mcp/handlers/analysis/performance-benchmark-run-handler.js.map +0 -1
  72. package/dist/mcp/handlers/analysis/performanceBenchmarkRun.d.ts +0 -58
  73. package/dist/mcp/handlers/analysis/performanceBenchmarkRun.d.ts.map +0 -1
  74. package/dist/mcp/handlers/analysis/performanceBenchmarkRun.js +0 -188
  75. package/dist/mcp/handlers/analysis/performanceBenchmarkRun.js.map +0 -1
  76. package/dist/mcp/handlers/optimize-tests.d.ts +0 -219
  77. package/dist/mcp/handlers/optimize-tests.d.ts.map +0 -1
  78. package/dist/mcp/handlers/optimize-tests.js +0 -533
  79. package/dist/mcp/handlers/optimize-tests.js.map +0 -1
  80. package/dist/mcp/handlers/predict-defects.d.ts +0 -194
  81. package/dist/mcp/handlers/predict-defects.d.ts.map +0 -1
  82. package/dist/mcp/handlers/predict-defects.js +0 -722
  83. package/dist/mcp/handlers/predict-defects.js.map +0 -1
  84. package/dist/mcp/handlers/prediction/regression-risk-analyze.d.ts +0 -199
  85. package/dist/mcp/handlers/prediction/regression-risk-analyze.d.ts.map +0 -1
  86. package/dist/mcp/handlers/prediction/regression-risk-analyze.js +0 -471
  87. package/dist/mcp/handlers/prediction/regression-risk-analyze.js.map +0 -1
  88. package/dist/mcp/handlers/quality/quality-decision-make.d.ts +0 -104
  89. package/dist/mcp/handlers/quality/quality-decision-make.d.ts.map +0 -1
  90. package/dist/mcp/handlers/quality/quality-decision-make.js +0 -408
  91. package/dist/mcp/handlers/quality/quality-decision-make.js.map +0 -1
  92. package/dist/mcp/handlers/quality/quality-gate-execute.d.ts +0 -160
  93. package/dist/mcp/handlers/quality/quality-gate-execute.d.ts.map +0 -1
  94. package/dist/mcp/handlers/quality/quality-gate-execute.js +0 -412
  95. package/dist/mcp/handlers/quality/quality-gate-execute.js.map +0 -1
  96. package/dist/mcp/handlers/quality/quality-policy-check.d.ts +0 -163
  97. package/dist/mcp/handlers/quality/quality-policy-check.d.ts.map +0 -1
  98. package/dist/mcp/handlers/quality/quality-policy-check.js +0 -455
  99. package/dist/mcp/handlers/quality/quality-policy-check.js.map +0 -1
  100. package/dist/mcp/handlers/quality/quality-risk-assess.d.ts +0 -123
  101. package/dist/mcp/handlers/quality/quality-risk-assess.d.ts.map +0 -1
  102. package/dist/mcp/handlers/quality/quality-risk-assess.js +0 -522
  103. package/dist/mcp/handlers/quality/quality-risk-assess.js.map +0 -1
  104. package/dist/mcp/handlers/quality/quality-validate-metrics.d.ts +0 -117
  105. package/dist/mcp/handlers/quality/quality-validate-metrics.d.ts.map +0 -1
  106. package/dist/mcp/handlers/quality/quality-validate-metrics.js +0 -288
  107. package/dist/mcp/handlers/quality/quality-validate-metrics.js.map +0 -1
  108. package/dist/mcp/handlers/quality-analyze.d.ts +0 -279
  109. package/dist/mcp/handlers/quality-analyze.d.ts.map +0 -1
  110. package/dist/mcp/handlers/quality-analyze.js +0 -720
  111. package/dist/mcp/handlers/quality-analyze.js.map +0 -1
  112. package/dist/mcp/handlers/security/check-authz.d.ts +0 -152
  113. package/dist/mcp/handlers/security/check-authz.d.ts.map +0 -1
  114. package/dist/mcp/handlers/security/check-authz.js +0 -434
  115. package/dist/mcp/handlers/security/check-authz.js.map +0 -1
  116. package/dist/mcp/handlers/security/scan-dependencies.d.ts +0 -148
  117. package/dist/mcp/handlers/security/scan-dependencies.d.ts.map +0 -1
  118. package/dist/mcp/handlers/security/scan-dependencies.js +0 -354
  119. package/dist/mcp/handlers/security/scan-dependencies.js.map +0 -1
  120. package/dist/mcp/handlers/security/validate-auth.d.ts +0 -128
  121. package/dist/mcp/handlers/security/validate-auth.d.ts.map +0 -1
  122. package/dist/mcp/handlers/security/validate-auth.js +0 -294
  123. package/dist/mcp/handlers/security/validate-auth.js.map +0 -1
  124. package/dist/mcp/handlers/test-generate.d.ts +0 -107
  125. package/dist/mcp/handlers/test-generate.d.ts.map +0 -1
  126. package/dist/mcp/handlers/test-generate.js +0 -454
  127. package/dist/mcp/handlers/test-generate.js.map +0 -1
@@ -0,0 +1,352 @@
1
+ # Documentation Verification Scripts
2
+
3
+ Automated scripts to prevent documentation drift and verify feature claims.
4
+
5
+ ## Overview
6
+
7
+ These scripts ensure that documentation (README.md, CLAUDE.md, package.json) stays accurate as the project evolves by:
8
+ - Automatically counting skills, agents, and MCP tools
9
+ - Verifying agent skill references
10
+ - Validating feature implementation against claims
11
+ - Providing automated updates and continuous monitoring
12
+
13
+ ## Scripts
14
+
15
+ ### 1. verify-counts.ts
16
+
17
+ Counts skills, agents, and MCP tools, then compares against documentation claims.
18
+
19
+ **Usage:**
20
+ ```bash
21
+ npm run verify:counts
22
+ npm run verify:counts -- --verbose
23
+ npm run verify:counts -- --json
24
+ ```
25
+
26
+ **What it checks:**
27
+ - Total skills count
28
+ - QE skills count
29
+ - Phase 1 skills count
30
+ - Phase 2 skills count
31
+ - Claude Flow skills count
32
+ - QE agents count
33
+ - MCP tools count
34
+
35
+ **Exit codes:**
36
+ - `0` - All counts match documentation
37
+ - `1` - Mismatches found
38
+
39
+ **Output:**
40
+ ```
41
+ ✅ Skill Count Verification
42
+ - Total Skills: 60 (✓ matches documentation)
43
+ - QE Skills: 35 (✓ matches documentation)
44
+ - Phase 1 Skills: 18 (✓ matches documentation)
45
+ - Phase 2 Skills: 17 (✓ matches documentation)
46
+
47
+ ⚠️ MCP Tools Count Mismatch
48
+ - Actual: 61 tools
49
+ - README.md line 14: claims 52 tools ❌
50
+ ```
51
+
52
+ ### 2. verify-agent-skills.ts
53
+
54
+ Validates that agent skill references exist and suggests additions based on specialization.
55
+
56
+ **Usage:**
57
+ ```bash
58
+ npm run verify:agent-skills
59
+ npm run verify:agent-skills -- --verbose
60
+ npm run verify:agent-skills -- --json
61
+ npm run verify:agent-skills -- --agent=qe-test-generator
62
+ ```
63
+
64
+ **What it checks:**
65
+ - Skill references in agent markdown files
66
+ - Whether referenced skills exist in `.claude/skills/`
67
+ - Phase 2 skill adoption
68
+ - Skill suggestions based on agent specialization
69
+
70
+ **Exit codes:**
71
+ - `0` - All agent skills valid
72
+ - `1` - Missing or broken skill references found
73
+
74
+ **Output:**
75
+ ```
76
+ 🤖 Agent: qe-test-generator
77
+ Skills Referenced: 5
78
+ Valid References: 5
79
+ Broken References: 0
80
+ Phase 2 Skills: 0
81
+
82
+ ⚠️ No Phase 2 skills referenced
83
+
84
+ 💡 SUGGESTED ADDITIONS:
85
+ - shift-left-testing (matches specialization)
86
+ - test-design-techniques (matches specialization)
87
+ - test-data-management (matches specialization)
88
+ ```
89
+
90
+ ### 3. update-documentation-counts.ts
91
+
92
+ Automatically updates counts in documentation files based on actual counts.
93
+
94
+ **Usage:**
95
+ ```bash
96
+ npm run update:counts # Apply updates
97
+ npm run update:counts -- --dry-run # Preview changes
98
+ npm run update:counts -- --verbose # Detailed output
99
+ ```
100
+
101
+ **What it updates:**
102
+ - README.md: Skills, agents, and MCP tools counts
103
+ - CLAUDE.md: QE skills and agents counts
104
+ - package.json: MCP tools count in description
105
+
106
+ **Safety features:**
107
+ - Creates backups before modification (`.backup-TIMESTAMP`)
108
+ - Dry-run mode to preview changes
109
+ - Detailed changelog of updates
110
+
111
+ **Output:**
112
+ ```
113
+ 📊 Current Counts:
114
+ Skills (Total): 60
115
+ Skills (QE): 35
116
+ Skills (Phase 1): 18
117
+ Skills (Phase 2): 17
118
+ Agents (QE): 18
119
+ MCP Tools: 61
120
+
121
+ ✅ Operations to apply: 8
122
+
123
+ 📄 README.md
124
+ ✓ Update MCP tools count in README header
125
+ ✓ Update total QE skills
126
+ ✓ Update Phase 1 skills count
127
+ ✓ Update Phase 2 skills count
128
+ ```
129
+
130
+ ### 4. verify-features.ts
131
+
132
+ Comprehensive verification of feature claims against actual implementation.
133
+
134
+ **Usage:**
135
+ ```bash
136
+ npm run verify:features
137
+ npm run verify:features -- --verbose
138
+ npm run verify:features -- --json
139
+ npm run verify:features -- --feature=multi-model-router
140
+ ```
141
+
142
+ **What it verifies:**
143
+ 1. **Multi-Model Router** (70-81% cost savings)
144
+ - AdaptiveModelRouter class exists
145
+ - Configuration file exists
146
+ - Cost tracking implemented
147
+ - Tests exist
148
+
149
+ 2. **Learning System** (20% improvement target)
150
+ - LearningEngine class exists
151
+ - Q-learning algorithm implemented
152
+ - Experience replay buffer
153
+ - Tests exist
154
+
155
+ 3. **Pattern Bank** (85%+ matching accuracy)
156
+ - QEReasoningBank class exists
157
+ - Pattern extraction works
158
+ - Pattern matching implemented
159
+ - Cross-project sharing
160
+
161
+ 4. **ML Flaky Detection** (100% accuracy claim)
162
+ - FlakyTestDetector class exists
163
+ - ML model implemented
164
+ - Root cause analysis
165
+ - Fix recommendations
166
+
167
+ 5. **Streaming API** (real-time progress)
168
+ - Streaming handlers exist
169
+ - AsyncGenerator pattern used
170
+ - Progress events emitted
171
+
172
+ 6. **AgentDB Integration**
173
+ - AgentDB installed
174
+ - QUIC sync configured
175
+ - Vector search works
176
+ - Learning plugins exist
177
+
178
+ 7. **61 MCP Tools**
179
+ - Count actual tool definitions
180
+ - Verify each tool exported
181
+ - Check handler existence
182
+
183
+ 8. **Performance Claims**
184
+ - Test generation: 1000+ tests/minute
185
+ - Coverage analysis: O(log n) complexity
186
+ - Data generation: 10,000+ records/second
187
+ - Pattern matching: <50ms p95
188
+
189
+ **Exit codes:**
190
+ - `0` - All features verified (≥80% confidence)
191
+ - `1` - Features missing or low confidence
192
+
193
+ **Output:**
194
+ ```
195
+ ✅ Multi-Model Router
196
+ Claimed: 70-81% cost savings, intelligent model selection
197
+ Status: VERIFIED (87.5% confidence)
198
+
199
+ Checks: 7 passed, 1 failed, 0 warnings
200
+
201
+ ⚠️ Learning System
202
+ Claimed: 20% improvement target, Q-learning algorithm
203
+ Status: PARTIAL (62.5% confidence)
204
+
205
+ Detailed Checks:
206
+ ✓ LearningEngine class found
207
+ ✓ Q-learning implemented
208
+ ✗ Experience replay tests missing
209
+ ✓ Improvement tracking works
210
+
211
+ 💡 Action Required:
212
+ • Add tests for experience replay buffer
213
+ ```
214
+
215
+ ## Continuous Integration
216
+
217
+ All scripts run automatically in CI/CD via GitHub Actions.
218
+
219
+ **Workflow:** `.github/workflows/verify-documentation.yml`
220
+
221
+ **Triggers:**
222
+ - Push to main/develop/testing-with-qe branches
223
+ - Pull requests to main/develop
224
+ - Daily scheduled check (2 AM UTC)
225
+ - Manual workflow dispatch
226
+
227
+ **On failure:**
228
+ - PR gets comment with results
229
+ - Workflow artifacts contain detailed reports
230
+ - Daily check creates GitHub issue
231
+
232
+ ## Reports
233
+
234
+ All scripts generate JSON reports saved to `/reports/` directory:
235
+ - `verification-counts-{timestamp}.json`
236
+ - `verification-agent-skills-{timestamp}.json`
237
+ - `verification-features-{timestamp}.json`
238
+ - `update-counts-{timestamp}.json`
239
+
240
+ ## Best Practices
241
+
242
+ 1. **Run verification before committing:**
243
+ ```bash
244
+ npm run verify:all
245
+ ```
246
+
247
+ 2. **Fix count mismatches automatically:**
248
+ ```bash
249
+ npm run update:counts --dry-run # Preview
250
+ npm run update:counts # Apply
251
+ ```
252
+
253
+ 3. **Check feature claims before release:**
254
+ ```bash
255
+ npm run verify:features
256
+ ```
257
+
258
+ 4. **Review agent skill references quarterly:**
259
+ ```bash
260
+ npm run verify:agent-skills --verbose
261
+ ```
262
+
263
+ ## Development
264
+
265
+ ### Adding New Checks
266
+
267
+ **verify-counts.ts:**
268
+ ```typescript
269
+ // Add new category to count
270
+ const newCategory = extractCountFromDocs(
271
+ readmePath,
272
+ /(\d+)\s+New\s+Category/i
273
+ );
274
+
275
+ results.push({
276
+ type: 'new-category',
277
+ category: 'total',
278
+ actual: actualCount,
279
+ expected: newCategory || undefined,
280
+ source: 'README.md',
281
+ status: newCategory !== null && actualCount === newCategory ? 'match' : 'mismatch'
282
+ });
283
+ ```
284
+
285
+ **verify-features.ts:**
286
+ ```typescript
287
+ function verifyNewFeature(): FeatureVerification {
288
+ const checks: FeatureCheck[] = [
289
+ checkClassExists('src/new/Feature.ts', 'Feature'),
290
+ checkTestsExist('*new-feature*.test.ts'),
291
+ // ... more checks
292
+ ];
293
+
294
+ const passCount = checks.filter(c => c.status === 'pass').length;
295
+ const confidence = (passCount / checks.length) * 100;
296
+
297
+ return {
298
+ feature: 'New Feature',
299
+ description: 'Description of new feature',
300
+ claimed: 'What the docs claim',
301
+ checks,
302
+ overallStatus: confidence >= 80 ? 'verified' :
303
+ confidence >= 50 ? 'partial' : 'missing',
304
+ confidence
305
+ };
306
+ }
307
+ ```
308
+
309
+ ### Testing
310
+
311
+ All scripts include comprehensive error handling and can be tested independently:
312
+
313
+ ```bash
314
+ # Test count verification
315
+ npm run verify:counts
316
+
317
+ # Test with verbose output
318
+ npm run verify:counts -- --verbose
319
+
320
+ # Test update in dry-run mode
321
+ npm run update:counts -- --dry-run
322
+
323
+ # Test specific agent
324
+ npm run verify:agent-skills -- --agent=qe-test-generator
325
+
326
+ # Test specific feature
327
+ npm run verify:features -- --feature=multi-model-router
328
+ ```
329
+
330
+ ## Troubleshooting
331
+
332
+ ### "Pattern not found" warnings
333
+ If update script can't find a pattern, the documentation format may have changed. Update the regex pattern in `update-documentation-counts.ts`.
334
+
335
+ ### "File not found" errors
336
+ Ensure project structure hasn't changed. Update file paths in verification scripts.
337
+
338
+ ### CI failing but local passing
339
+ Check that all files are committed, especially in `.claude/` directories which might be gitignored.
340
+
341
+ ## Dependencies
342
+
343
+ - **tsx**: TypeScript execution
344
+ - **fs**: File system operations
345
+ - **path**: Path manipulation
346
+ - **child_process**: For running shell commands
347
+
348
+ No external dependencies required beyond Node.js built-ins.
349
+
350
+ ## License
351
+
352
+ MIT - Part of Agentic QE Fleet System
@@ -0,0 +1,191 @@
1
+ #!/usr/bin/env node
2
+ /**
3
+ * PostToolUse Hook: Automatic Task Learning Capture
4
+ *
5
+ * This hook automatically captures learnings from completed Task agents
6
+ * and persists them to memory.db. It provides a safety net ensuring
7
+ * learnings are captured even when agents don't explicitly call MCP tools.
8
+ *
9
+ * Input (via stdin): PostToolUse JSON with tool_input and tool_response
10
+ * Output: Stores learning_experience record to .agentic-qe/memory.db
11
+ *
12
+ * @module hooks/capture-task-learning
13
+ */
14
+
15
+ const fs = require('fs');
16
+ const path = require('path');
17
+
18
+ // Read stdin
19
+ let input = '';
20
+ process.stdin.setEncoding('utf8');
21
+ process.stdin.on('data', chunk => input += chunk);
22
+ process.stdin.on('end', () => processTaskLearning(input));
23
+
24
+ async function processTaskLearning(jsonInput) {
25
+ try {
26
+ const data = JSON.parse(jsonInput);
27
+
28
+ // Only process completed Task tools
29
+ if (data.tool_name !== 'Task' || data.tool_response?.status !== 'completed') {
30
+ return;
31
+ }
32
+
33
+ // Extract key information
34
+ const agentType = data.tool_input?.subagent_type || 'unknown';
35
+ const taskDescription = data.tool_input?.description || '';
36
+ const prompt = data.tool_input?.prompt || '';
37
+ const agentOutput = data.tool_response?.content?.[0]?.text || '';
38
+ const durationMs = data.tool_response?.totalDurationMs || 0;
39
+ const totalTokens = data.tool_response?.totalTokens || 0;
40
+ const toolUseCount = data.tool_response?.totalToolUseCount || 0;
41
+ const agentId = data.tool_response?.agentId || 'unknown';
42
+ const cwd = data.cwd || process.cwd();
43
+
44
+ // Skip if no meaningful output
45
+ if (!agentOutput || agentOutput.length < 20) {
46
+ return;
47
+ }
48
+
49
+ // Determine task type from agent type
50
+ const taskTypeMap = {
51
+ 'qe-test-generator': 'test-generation',
52
+ 'qe-coverage-analyzer': 'coverage-analysis',
53
+ 'qe-security-scanner': 'security-scan',
54
+ 'qe-performance-tester': 'performance-test',
55
+ 'qe-flaky-test-hunter': 'flaky-detection',
56
+ 'qe-chaos-engineer': 'chaos-testing',
57
+ 'qe-code-complexity': 'complexity-analysis',
58
+ 'qe-quality-gate': 'quality-gate',
59
+ 'qe-regression-risk-analyzer': 'regression-analysis',
60
+ 'qe-requirements-validator': 'requirements-validation',
61
+ 'qe-test-data-architect': 'test-data-generation',
62
+ 'qe-visual-tester': 'visual-testing',
63
+ 'qe-api-contract-validator': 'contract-validation',
64
+ 'qe-fleet-commander': 'fleet-coordination',
65
+ 'qe-test-executor': 'test-execution',
66
+ 'qe-quality-analyzer': 'quality-analysis',
67
+ 'qe-deployment-readiness': 'deployment-readiness',
68
+ 'qe-production-intelligence': 'production-intelligence',
69
+ 'qx-partner': 'qx-analysis',
70
+ 'researcher': 'research',
71
+ 'coder': 'implementation',
72
+ 'tester': 'testing',
73
+ 'reviewer': 'code-review'
74
+ };
75
+ const taskType = taskTypeMap[agentType] || agentType;
76
+
77
+ // Calculate reward based on output quality indicators
78
+ let reward = 0.7; // Base reward for completion
79
+
80
+ // Increase reward for comprehensive output
81
+ if (agentOutput.length > 500) reward += 0.05;
82
+ if (agentOutput.length > 1000) reward += 0.05;
83
+ if (agentOutput.length > 2000) reward += 0.05;
84
+
85
+ // Increase reward for tool usage (indicates thorough work)
86
+ if (toolUseCount > 0) reward += 0.05;
87
+ if (toolUseCount > 5) reward += 0.05;
88
+
89
+ // Check for success indicators in output
90
+ const successIndicators = ['✓', '✅', 'success', 'complete', 'passed', 'found', 'created', 'generated'];
91
+ const failureIndicators = ['❌', 'failed', 'error', 'could not', 'unable to'];
92
+
93
+ const hasSuccess = successIndicators.some(ind => agentOutput.toLowerCase().includes(ind.toLowerCase()));
94
+ const hasFailure = failureIndicators.some(ind => agentOutput.toLowerCase().includes(ind.toLowerCase()));
95
+
96
+ if (hasSuccess && !hasFailure) reward += 0.1;
97
+ if (hasFailure) reward -= 0.2;
98
+
99
+ // Cap reward between 0.1 and 1.0
100
+ reward = Math.max(0.1, Math.min(1.0, reward));
101
+
102
+ // Find memory.db path
103
+ const dbPath = path.join(cwd, '.agentic-qe', 'memory.db');
104
+
105
+ // Check if database exists
106
+ if (!fs.existsSync(dbPath)) {
107
+ // Try to find it relative to this script
108
+ const altPath = path.join(__dirname, '../../.agentic-qe/memory.db');
109
+ if (!fs.existsSync(altPath)) {
110
+ console.error('💡 Learning: memory.db not found, skipping capture');
111
+ return;
112
+ }
113
+ }
114
+
115
+ // Store learning experience
116
+ const Database = require('better-sqlite3');
117
+ const db = new Database(dbPath);
118
+
119
+ // Note: Table should already exist from aqe init
120
+ // Schema: id, agent_id, task_id, task_type, state, action, reward, next_state, episode_id, metadata, created_at, timestamp
121
+
122
+ // DEDUPLICATION: Check if agent already stored learning via MCP in last 60 seconds
123
+ // This prevents double-storing when agents properly call MCP learning tools
124
+ const recentLearning = db.prepare(`
125
+ SELECT id, metadata FROM learning_experiences
126
+ WHERE agent_id = ?
127
+ AND created_at > datetime('now', '-60 seconds')
128
+ ORDER BY created_at DESC
129
+ LIMIT 1
130
+ `).get(agentType);
131
+
132
+ if (recentLearning) {
133
+ // Check if it was stored by the agent (not by hook)
134
+ try {
135
+ const meta = JSON.parse(recentLearning.metadata || '{}');
136
+ if (meta.capturedBy !== 'PostToolUse-hook') {
137
+ // Agent already stored learning via MCP - skip duplicate
138
+ console.log(`📚 Learning: Agent ${agentType} already stored learning via MCP - skipping hook capture`);
139
+ db.close();
140
+ return;
141
+ }
142
+ } catch { /* ignore parse errors */ }
143
+ }
144
+
145
+ // Extract outcome summary (first 500 chars of output)
146
+ const outcomeSummary = agentOutput.substring(0, 500).replace(/\n/g, ' ').trim();
147
+
148
+ // Insert learning experience (matching actual schema)
149
+ const stmt = db.prepare(`
150
+ INSERT INTO learning_experiences (agent_id, task_id, task_type, state, action, reward, next_state, episode_id, metadata)
151
+ VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)
152
+ `);
153
+
154
+ const metadata = JSON.stringify({
155
+ taskDescription,
156
+ durationMs,
157
+ totalTokens,
158
+ toolUseCount,
159
+ outputLength: agentOutput.length,
160
+ outputSummary: outcomeSummary,
161
+ success: hasSuccess && !hasFailure,
162
+ capturedBy: 'PostToolUse-hook',
163
+ sessionAgentId: agentId
164
+ });
165
+
166
+ const taskId = `task-${Date.now()}-${Math.random().toString(36).substr(2, 9)}`;
167
+ const episodeId = `episode-${new Date().toISOString().slice(0, 10)}`;
168
+
169
+ stmt.run(
170
+ agentType,
171
+ taskId,
172
+ taskType,
173
+ 'task-started',
174
+ 'execute-task',
175
+ reward,
176
+ 'task-completed',
177
+ episodeId,
178
+ metadata
179
+ );
180
+
181
+ db.close();
182
+
183
+ // Output confirmation (visible in hook output)
184
+ console.log(`📚 Learning captured: ${agentType} → ${taskType} (reward: ${reward.toFixed(2)})`);
185
+
186
+ } catch (error) {
187
+ // Silently fail - don't break the workflow
188
+ // Uncomment for debugging:
189
+ // console.error('Hook error:', error.message);
190
+ }
191
+ }
@@ -0,0 +1,35 @@
1
+ #!/bin/bash
2
+ # Hook: Post-Task - Emit agent completion event to visualization
3
+ # Receives JSON via stdin from Claude Code hook system
4
+
5
+ # Read input from stdin
6
+ INPUT=$(cat)
7
+
8
+ # Try to get the agent ID from the temp file or generate from description
9
+ if [ -f "/tmp/aqe-viz/current-agent-$$" ]; then
10
+ AGENT_ID=$(cat "/tmp/aqe-viz/current-agent-$$")
11
+ rm -f "/tmp/aqe-viz/current-agent-$$"
12
+ else
13
+ # Fallback: extract from input
14
+ DESC=$(echo "$INPUT" | jq -r '.tool_input.description // .tool_input.prompt // "task-agent"' 2>/dev/null | head -c 50)
15
+ AGENT_ID=$(echo "$DESC" | tr ' ' '-' | tr '[:upper:]' '[:lower:]' | sed 's/[^a-z0-9-]//g' | head -c 30)
16
+ AGENT_ID="${AGENT_ID:-task-agent}-recent"
17
+ fi
18
+
19
+ # Check if task was successful (from tool response)
20
+ SUCCESS=$(echo "$INPUT" | jq -r '.tool_response.success // .result.success // "unknown"' 2>/dev/null)
21
+
22
+ # Calculate approximate duration (we don't have exact timing, use 0)
23
+ DURATION=0
24
+
25
+ # Emit completion or error event based on success status (non-blocking, background)
26
+ (
27
+ if [ "$SUCCESS" = "false" ]; then
28
+ ERROR_MSG=$(echo "$INPUT" | jq -r '.tool_response.error // .result.error // "Task failed"' 2>/dev/null)
29
+ npx tsx scripts/emit-agent-event.ts error "$AGENT_ID" "$ERROR_MSG" 2>/dev/null
30
+ else
31
+ npx tsx scripts/emit-agent-event.ts complete "$AGENT_ID" "$DURATION" 2>/dev/null
32
+ fi
33
+ ) &
34
+
35
+ exit 0
@@ -0,0 +1,27 @@
1
+ #!/bin/bash
2
+ # Hook: Pre-Task - Emit agent spawn event to visualization
3
+ # Receives JSON via stdin from Claude Code hook system
4
+
5
+ # Read input from stdin
6
+ INPUT=$(cat)
7
+
8
+ # Extract task description and agent type from hook input
9
+ DESC=$(echo "$INPUT" | jq -r '.tool_input.description // .tool_input.prompt // "task-agent"' 2>/dev/null | head -c 50)
10
+ AGENT_TYPE=$(echo "$INPUT" | jq -r '.tool_input.subagent_type // .tool_input.agent // "coder"' 2>/dev/null)
11
+
12
+ # Generate agent ID from description
13
+ AGENT_ID=$(echo "$DESC" | tr ' ' '-' | tr '[:upper:]' '[:lower:]' | sed 's/[^a-z0-9-]//g' | head -c 30)
14
+ AGENT_ID="${AGENT_ID:-task-agent}-$(date +%s)"
15
+
16
+ # Store agent ID in temp file for completion hook
17
+ mkdir -p /tmp/aqe-viz
18
+ echo "$AGENT_ID" > "/tmp/aqe-viz/current-agent-$$"
19
+ echo "$AGENT_ID" >> "/tmp/aqe-viz/agent-registry"
20
+
21
+ # Emit spawn and start events (non-blocking, background)
22
+ (
23
+ npx tsx scripts/emit-agent-event.ts spawn "$AGENT_ID" "$AGENT_TYPE" 2>/dev/null
24
+ npx tsx scripts/emit-agent-event.ts start "$AGENT_ID" 2>/dev/null
25
+ ) &
26
+
27
+ exit 0
@@ -1,9 +0,0 @@
1
- {
2
- "name": "failing-agent",
3
- "capabilities": [
4
- "debug",
5
- "test"
6
- ],
7
- "status": "active",
8
- "tasks": []
9
- }
@@ -1,9 +0,0 @@
1
- {
2
- "name": "test-agent",
3
- "capabilities": [
4
- "debug",
5
- "test"
6
- ],
7
- "status": "active",
8
- "tasks": []
9
- }
package/dist/App.d.ts DELETED
@@ -1,5 +0,0 @@
1
- import React from 'react';
2
- import './App.css';
3
- declare const App: React.FC;
4
- export default App;
5
- //# sourceMappingURL=App.d.ts.map
package/dist/App.d.ts.map DELETED
@@ -1 +0,0 @@
1
- {"version":3,"file":"App.d.ts","sourceRoot":"","sources":["../src/App.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAG1B,OAAO,WAAW,CAAC;AAEnB,QAAA,MAAM,GAAG,EAAE,KAAK,CAAC,EAMhB,CAAC;AAEF,eAAe,GAAG,CAAC"}
package/dist/App.js DELETED
@@ -1,15 +0,0 @@
1
- "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- const react_1 = __importDefault(require("react"));
7
- const DashboardContext_1 = require("./contexts/DashboardContext");
8
- const Dashboard_1 = require("./components/Dashboard/Dashboard");
9
- require("./App.css");
10
- const App = () => {
11
- return (react_1.default.createElement(DashboardContext_1.DashboardProvider, null,
12
- react_1.default.createElement(Dashboard_1.Dashboard, null)));
13
- };
14
- exports.default = App;
15
- //# sourceMappingURL=App.js.map
package/dist/App.js.map DELETED
@@ -1 +0,0 @@
1
- {"version":3,"file":"App.js","sourceRoot":"","sources":["../src/App.tsx"],"names":[],"mappings":";;;;;AAAA,kDAA0B;AAC1B,kEAAgE;AAChE,gEAA6D;AAC7D,qBAAmB;AAEnB,MAAM,GAAG,GAAa,GAAG,EAAE;IACzB,OAAO,CACL,8BAAC,oCAAiB;QAChB,8BAAC,qBAAS,OAAG,CACK,CACrB,CAAC;AACJ,CAAC,CAAC;AAEF,kBAAe,GAAG,CAAC"}