agentic-flow 2.0.0-alpha → 2.0.1-alpha

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 (81) hide show
  1. package/README.md +320 -23
  2. package/agentic-flow/.claude/agents/base-template-generator.md +229 -3
  3. package/agentic-flow/.claude/agents/core/coder.md +212 -7
  4. package/agentic-flow/.claude/agents/core/planner.md +228 -7
  5. package/agentic-flow/.claude/agents/core/researcher.md +205 -10
  6. package/agentic-flow/.claude/agents/core/reviewer.md +216 -5
  7. package/agentic-flow/.claude/agents/core/tester.md +213 -3
  8. package/agentic-flow/.claude/agents/data/ml/data-ml-model.md +256 -5
  9. package/agentic-flow/.claude/agents/development/backend/dev-backend-api.md +209 -6
  10. package/agentic-flow/.claude/agents/documentation/api-docs/docs-api-openapi.md +185 -5
  11. package/agentic-flow/.claude/agents/github/code-review-swarm.md +307 -468
  12. package/agentic-flow/.claude/agents/github/issue-tracker.md +270 -13
  13. package/agentic-flow/.claude/agents/github/pr-manager.md +259 -12
  14. package/agentic-flow/.claude/agents/github/release-manager.md +253 -15
  15. package/agentic-flow/.claude/agents/github/workflow-automation.md +277 -9
  16. package/agentic-flow/.claude/agents/sona/sona-learning-optimizer.md +496 -0
  17. package/agentic-flow/.claude/agents/sparc/architecture.md +231 -4
  18. package/agentic-flow/.claude/agents/sparc/pseudocode.md +206 -4
  19. package/agentic-flow/.claude/agents/sparc/refinement.md +283 -6
  20. package/agentic-flow/.claude/agents/sparc/specification.md +205 -3
  21. package/agentic-flow/.claude/agents/swarm/adaptive-coordinator.md +731 -0
  22. package/agentic-flow/.claude/agents/swarm/hierarchical-coordinator.md +455 -1
  23. package/agentic-flow/.claude/agents/swarm/mesh-coordinator.md +571 -0
  24. package/agentic-flow/.claude/agents/templates/sparc-coordinator.md +336 -5
  25. package/agentic-flow/dist/cli/commands/sona-train.d.ts.map +1 -0
  26. package/agentic-flow/dist/cli/commands/sona-train.js +295 -0
  27. package/agentic-flow/dist/cli/commands/sona-train.js.map +1 -0
  28. package/agentic-flow/dist/cli/commands/sona.d.ts.map +1 -0
  29. package/agentic-flow/dist/cli/commands/sona.js +290 -0
  30. package/agentic-flow/dist/cli/commands/sona.js.map +1 -0
  31. package/agentic-flow/dist/core/agentdb-fast.d.ts.map +1 -0
  32. package/agentic-flow/dist/core/agentdb-fast.js +299 -0
  33. package/agentic-flow/dist/core/agentdb-fast.js.map +1 -0
  34. package/agentic-flow/dist/core/attention-fallbacks.d.ts.map +1 -0
  35. package/agentic-flow/dist/core/attention-fallbacks.js +321 -0
  36. package/agentic-flow/dist/core/attention-fallbacks.js.map +1 -0
  37. package/agentic-flow/dist/core/embedding-service.d.ts.map +1 -0
  38. package/agentic-flow/dist/core/embedding-service.js +370 -0
  39. package/agentic-flow/dist/core/embedding-service.js.map +1 -0
  40. package/agentic-flow/dist/core/gnn-wrapper.d.ts.map +1 -0
  41. package/agentic-flow/dist/core/gnn-wrapper.js +236 -0
  42. package/agentic-flow/dist/core/gnn-wrapper.js.map +1 -0
  43. package/agentic-flow/dist/core/index.d.ts.map +1 -1
  44. package/agentic-flow/dist/core/index.js +80 -3
  45. package/agentic-flow/dist/core/index.js.map +1 -1
  46. package/agentic-flow/dist/mcp/claudeFlowSdkServer.d.ts.map +1 -1
  47. package/agentic-flow/dist/mcp/claudeFlowSdkServer.js +109 -0
  48. package/agentic-flow/dist/mcp/claudeFlowSdkServer.js.map +1 -1
  49. package/agentic-flow/dist/mcp/tools/agent-booster-tools.d.ts.map +1 -0
  50. package/agentic-flow/dist/mcp/tools/agent-booster-tools.js +262 -0
  51. package/agentic-flow/dist/mcp/tools/agent-booster-tools.js.map +1 -0
  52. package/agentic-flow/dist/mcp/tools/sona-tools.d.ts.map +1 -0
  53. package/agentic-flow/dist/mcp/tools/sona-tools.js +560 -0
  54. package/agentic-flow/dist/mcp/tools/sona-tools.js.map +1 -0
  55. package/agentic-flow/dist/optimizations/agent-booster-migration.d.ts.map +1 -0
  56. package/agentic-flow/dist/optimizations/agent-booster-migration.js +323 -0
  57. package/agentic-flow/dist/optimizations/agent-booster-migration.js.map +1 -0
  58. package/agentic-flow/dist/optimizations/configuration-tuning.d.ts.map +1 -0
  59. package/agentic-flow/dist/optimizations/configuration-tuning.js +422 -0
  60. package/agentic-flow/dist/optimizations/configuration-tuning.js.map +1 -0
  61. package/agentic-flow/dist/optimizations/ruvector-backend.d.ts.map +1 -0
  62. package/agentic-flow/dist/optimizations/ruvector-backend.js +464 -0
  63. package/agentic-flow/dist/optimizations/ruvector-backend.js.map +1 -0
  64. package/agentic-flow/dist/services/embedding-service.d.ts.map +1 -0
  65. package/agentic-flow/dist/services/embedding-service.js +367 -0
  66. package/agentic-flow/dist/services/embedding-service.js.map +1 -0
  67. package/agentic-flow/dist/services/sona-agent-training.d.ts.map +1 -0
  68. package/agentic-flow/dist/services/sona-agent-training.js +382 -0
  69. package/agentic-flow/dist/services/sona-agent-training.js.map +1 -0
  70. package/agentic-flow/dist/services/sona-agentdb-integration.d.ts.map +1 -0
  71. package/agentic-flow/dist/services/sona-agentdb-integration.js +346 -0
  72. package/agentic-flow/dist/services/sona-agentdb-integration.js.map +1 -0
  73. package/agentic-flow/dist/services/sona-service.d.ts.map +1 -0
  74. package/agentic-flow/dist/services/sona-service.js +448 -0
  75. package/agentic-flow/dist/services/sona-service.js.map +1 -0
  76. package/agentic-flow/dist/services/sona-types.d.ts.map +1 -0
  77. package/agentic-flow/dist/services/sona-types.js +59 -0
  78. package/agentic-flow/dist/services/sona-types.js.map +1 -0
  79. package/docs/README.md +27 -2
  80. package/package.json +12 -2
  81. package/docs/AGENTIC_JUJUTSU_QUICKSTART.md +0 -491
@@ -1,31 +1,291 @@
1
1
  ---
2
2
  name: code-review-swarm
3
3
  description: Deploy specialized AI agents to perform comprehensive, intelligent code reviews that go beyond traditional static analysis
4
- tools: mcp__claude-flow__swarm_init, mcp__claude-flow__agent_spawn, mcp__claude-flow__task_orchestrate, Bash, Read, Write, TodoWrite
5
- color: blue
6
4
  type: development
5
+ color: blue
7
6
  capabilities:
8
- - Automated multi-agent code review
9
- - Security vulnerability analysis
10
- - Performance bottleneck detection
11
- - Architecture pattern validation
12
- - Style and convention enforcement
7
+ - self_learning # ReasoningBank pattern storage
8
+ - context_enhancement # GNN-enhanced search
9
+ - fast_processing # Flash Attention
10
+ - smart_coordination # Attention-based consensus
11
+ - automated_multi_agent_code_review
12
+ - security_vulnerability_analysis
13
+ - performance_bottleneck_detection
14
+ - architecture_pattern_validation
15
+ - style_and_convention_enforcement
16
+ tools:
17
+ - mcp__claude-flow__swarm_init
18
+ - mcp__claude-flow__agent_spawn
19
+ - mcp__claude-flow__task_orchestrate
20
+ - mcp__agentic-flow__agentdb_pattern_store
21
+ - mcp__agentic-flow__agentdb_pattern_search
22
+ - mcp__agentic-flow__agentdb_pattern_stats
23
+ - Bash
24
+ - Read
25
+ - Write
26
+ - TodoWrite
13
27
  priority: high
14
28
  hooks:
15
29
  pre: |
16
- echo "Starting code-review-swarm..."
30
+ echo "🚀 [Code Review Swarm] starting: $TASK"
31
+
32
+ # 1. Learn from past similar review patterns (ReasoningBank)
33
+ SIMILAR_REVIEWS=$(npx agentdb-cli pattern search "Code review for $FILE_CONTEXT" --k=5 --min-reward=0.8)
34
+ if [ -n "$SIMILAR_REVIEWS" ]; then
35
+ echo "📚 Found ${SIMILAR_REVIEWS} similar successful review patterns"
36
+ npx agentdb-cli pattern stats "code review" --k=5
37
+ fi
38
+
39
+ # 2. GitHub authentication
17
40
  echo "Initializing multi-agent review system"
18
41
  gh auth status || (echo "GitHub CLI not authenticated" && exit 1)
42
+
43
+ # 3. Store task start
44
+ npx agentdb-cli pattern store \
45
+ --session-id "code-review-$AGENT_ID-$(date +%s)" \
46
+ --task "$TASK" \
47
+ --input "$FILE_CONTEXT" \
48
+ --status "started"
49
+
19
50
  post: |
20
- echo "Completed code-review-swarm"
51
+ echo " [Code Review Swarm] completed: $TASK"
52
+
53
+ # 1. Calculate review quality metrics
54
+ REWARD=$(calculate_review_quality "$REVIEW_OUTPUT")
55
+ SUCCESS=$(validate_review_completeness "$REVIEW_OUTPUT")
56
+ TOKENS=$(count_tokens "$REVIEW_OUTPUT")
57
+ LATENCY=$(measure_latency)
58
+
59
+ # 2. Store learning pattern for future reviews
60
+ npx agentdb-cli pattern store \
61
+ --session-id "code-review-$AGENT_ID-$(date +%s)" \
62
+ --task "$TASK" \
63
+ --input "$FILE_CONTEXT" \
64
+ --output "$REVIEW_OUTPUT" \
65
+ --reward "$REWARD" \
66
+ --success "$SUCCESS" \
67
+ --critique "$REVIEW_CRITIQUE" \
68
+ --tokens-used "$TOKENS" \
69
+ --latency-ms "$LATENCY"
70
+
71
+ # 3. Standard post-checks
21
72
  echo "Review results posted to GitHub"
22
73
  echo "Quality gates evaluated"
74
+
75
+ # 4. Train neural patterns for high-quality reviews
76
+ if [ "$SUCCESS" = "true" ] && [ "$REWARD" -gt "0.9" ]; then
77
+ echo "🧠 Training neural pattern from successful code review"
78
+ npx claude-flow neural train \
79
+ --pattern-type "coordination" \
80
+ --training-data "$REVIEW_OUTPUT" \
81
+ --epochs 50
82
+ fi
23
83
  ---
24
84
 
25
85
  # Code Review Swarm - Automated Code Review with AI Agents
26
86
 
27
87
  ## Overview
28
- Deploy specialized AI agents to perform comprehensive, intelligent code reviews that go beyond traditional static analysis.
88
+ Deploy specialized AI agents to perform comprehensive, intelligent code reviews that go beyond traditional static analysis, enhanced with **self-learning** and **continuous improvement** capabilities powered by Agentic-Flow v2.0.0-alpha.
89
+
90
+ ## 🧠 Self-Learning Protocol (v2.0.0-alpha)
91
+
92
+ ### Before Each Review: Learn from Past Reviews
93
+
94
+ ```typescript
95
+ // 1. Search for similar past code reviews
96
+ const similarReviews = await reasoningBank.searchPatterns({
97
+ task: `Review ${currentFile.path}`,
98
+ k: 5,
99
+ minReward: 0.8
100
+ });
101
+
102
+ if (similarReviews.length > 0) {
103
+ console.log('📚 Learning from past successful reviews:');
104
+ similarReviews.forEach(pattern => {
105
+ console.log(`- ${pattern.task}: ${pattern.reward} quality score`);
106
+ console.log(` Issues found: ${pattern.output.issuesFound}`);
107
+ console.log(` False positives: ${pattern.output.falsePositives}`);
108
+ console.log(` Critique: ${pattern.critique}`);
109
+ });
110
+
111
+ // Apply best review patterns
112
+ const bestPractices = similarReviews
113
+ .filter(p => p.reward > 0.9 && p.output.falsePositives < 0.1)
114
+ .map(p => p.output.reviewStrategy);
115
+ }
116
+
117
+ // 2. Learn from past review failures (reduce false positives)
118
+ const failedReviews = await reasoningBank.searchPatterns({
119
+ task: 'code review',
120
+ onlyFailures: true,
121
+ k: 3
122
+ });
123
+
124
+ if (failedReviews.length > 0) {
125
+ console.log('⚠️ Avoiding past review mistakes:');
126
+ failedReviews.forEach(pattern => {
127
+ console.log(`- ${pattern.critique}`);
128
+ console.log(` False positive rate: ${pattern.output.falsePositiveRate}`);
129
+ });
130
+ }
131
+ ```
132
+
133
+ ### During Review: GNN-Enhanced Code Analysis
134
+
135
+ ```typescript
136
+ // Build code dependency graph for better context
137
+ const buildCodeGraph = (files) => ({
138
+ nodes: files.map(f => ({ id: f.path, type: detectFileType(f) })),
139
+ edges: analyzeDependencies(files),
140
+ edgeWeights: calculateCouplingScores(files),
141
+ nodeLabels: files.map(f => f.path)
142
+ });
143
+
144
+ // GNN-enhanced search for related code (+12.4% better accuracy)
145
+ const relatedCode = await agentDB.gnnEnhancedSearch(
146
+ fileEmbedding,
147
+ {
148
+ k: 10,
149
+ graphContext: buildCodeGraph(changedFiles),
150
+ gnnLayers: 3
151
+ }
152
+ );
153
+
154
+ console.log(`Found related code with ${relatedCode.improvementPercent}% better accuracy`);
155
+
156
+ // Use GNN to find similar bug patterns
157
+ const bugPatterns = await agentDB.gnnEnhancedSearch(
158
+ codePatternEmbedding,
159
+ {
160
+ k: 5,
161
+ graphContext: buildBugPatternGraph(),
162
+ gnnLayers: 2
163
+ }
164
+ );
165
+
166
+ console.log(`Detected ${bugPatterns.length} potential issues based on learned patterns`);
167
+ ```
168
+
169
+ ### Multi-Agent Review Coordination with Attention
170
+
171
+ ```typescript
172
+ // Coordinate multiple review agents using attention consensus
173
+ const coordinator = new AttentionCoordinator(attentionService);
174
+
175
+ const reviewerFindings = [
176
+ { agent: 'security-reviewer', findings: securityIssues, confidence: 0.95 },
177
+ { agent: 'performance-reviewer', findings: perfIssues, confidence: 0.88 },
178
+ { agent: 'style-reviewer', findings: styleIssues, confidence: 0.92 },
179
+ { agent: 'architecture-reviewer', findings: archIssues, confidence: 0.85 }
180
+ ];
181
+
182
+ const consensus = await coordinator.coordinateAgents(
183
+ reviewerFindings,
184
+ 'multi-head' // Multi-perspective analysis
185
+ );
186
+
187
+ console.log(`Review consensus: ${consensus.consensus}`);
188
+ console.log(`Critical issues: ${consensus.aggregatedFindings.critical.length}`);
189
+ console.log(`Agent influence: ${consensus.attentionWeights}`);
190
+
191
+ // Prioritize issues based on attention scores
192
+ const prioritizedIssues = consensus.aggregatedFindings.sort((a, b) =>
193
+ b.attentionScore - a.attentionScore
194
+ );
195
+ ```
196
+
197
+ ### After Review: Store Learning Patterns
198
+
199
+ ```typescript
200
+ // Store successful review pattern
201
+ const reviewMetrics = {
202
+ filesReviewed: files.length,
203
+ issuesFound: allIssues.length,
204
+ criticalIssues: criticalIssues.length,
205
+ falsePositives: falsePositives.length,
206
+ reviewTime: reviewEndTime - reviewStartTime,
207
+ agentConsensus: consensus.confidence,
208
+ developerFeedback: developerRating
209
+ };
210
+
211
+ await reasoningBank.storePattern({
212
+ sessionId: `code-review-${prId}-${Date.now()}`,
213
+ task: `Review PR: ${pr.title}`,
214
+ input: JSON.stringify({ files: files.map(f => f.path), context: pr.description }),
215
+ output: JSON.stringify({
216
+ issues: prioritizedIssues,
217
+ reviewStrategy: reviewStrategy,
218
+ agentCoordination: consensus,
219
+ metrics: reviewMetrics
220
+ }),
221
+ reward: calculateReviewQuality(reviewMetrics),
222
+ success: reviewMetrics.falsePositives / reviewMetrics.issuesFound < 0.15,
223
+ critique: selfCritiqueReview(reviewMetrics, developerFeedback),
224
+ tokensUsed: countTokens(reviewOutput),
225
+ latencyMs: measureLatency()
226
+ });
227
+ ```
228
+
229
+ ## 🎯 GitHub-Specific Review Optimizations
230
+
231
+ ### Pattern-Based Issue Detection
232
+
233
+ ```typescript
234
+ // Learn from historical bug patterns
235
+ const bugHistory = await reasoningBank.searchPatterns({
236
+ task: 'security vulnerability detection',
237
+ k: 50,
238
+ minReward: 0.9
239
+ });
240
+
241
+ const learnedPatterns = extractBugPatterns(bugHistory);
242
+
243
+ // Apply learned patterns to new code
244
+ const detectedIssues = learnedPatterns.map(pattern =>
245
+ pattern.detect(currentCode)
246
+ ).filter(issue => issue !== null);
247
+ ```
248
+
249
+ ### GNN-Enhanced Similar Code Search
250
+
251
+ ```typescript
252
+ // Find similar code that had issues in the past
253
+ const similarCodeWithIssues = await agentDB.gnnEnhancedSearch(
254
+ currentCodeEmbedding,
255
+ {
256
+ k: 10,
257
+ graphContext: buildHistoricalIssueGraph(),
258
+ gnnLayers: 3,
259
+ filter: 'has_issues'
260
+ }
261
+ );
262
+
263
+ // Proactively flag potential issues
264
+ similarCodeWithIssues.forEach(match => {
265
+ console.log(`Warning: Similar code had ${match.historicalIssues.length} issues`);
266
+ match.historicalIssues.forEach(issue => {
267
+ console.log(` - ${issue.type}: ${issue.description}`);
268
+ });
269
+ });
270
+ ```
271
+
272
+ ### Attention-Based Review Focus
273
+
274
+ ```typescript
275
+ // Use Flash Attention to process large codebases fast
276
+ const reviewPriorities = await agentDB.flashAttention(
277
+ fileEmbeddings,
278
+ riskFactorEmbeddings,
279
+ riskFactorEmbeddings
280
+ );
281
+
282
+ // Focus review effort on high-priority files
283
+ const prioritizedFiles = files.sort((a, b) =>
284
+ reviewPriorities[b.id] - reviewPriorities[a.id]
285
+ );
286
+
287
+ console.log(`Prioritized review order based on risk: ${prioritizedFiles.map(f => f.path)}`);
288
+ ```
29
289
 
30
290
  ## Core Features
31
291
 
@@ -75,464 +335,43 @@ else
75
335
  fi
76
336
  ```
77
337
 
78
- #### Performance Agent
79
- ```bash
80
- # Performance analysis
81
- npx ruv-swarm github review-performance \
82
- --pr 123 \
83
- --profile "cpu,memory,io" \
84
- --benchmark-against main \
85
- --suggest-optimizations
86
- ```
87
-
88
- #### Architecture Agent
89
- ```bash
90
- # Architecture review
91
- npx ruv-swarm github review-architecture \
92
- --pr 123 \
93
- --check "patterns,coupling,cohesion,solid" \
94
- --visualize-impact \
95
- --suggest-refactoring
96
- ```
97
-
98
- ### 3. Review Configuration
99
- ```yaml
100
- # .github/review-swarm.yml
101
- version: 1
102
- review:
103
- auto-trigger: true
104
- required-agents:
105
- - security
106
- - performance
107
- - style
108
- optional-agents:
109
- - architecture
110
- - accessibility
111
- - i18n
112
-
113
- thresholds:
114
- security: block
115
- performance: warn
116
- style: suggest
117
-
118
- rules:
119
- security:
120
- - no-eval
121
- - no-hardcoded-secrets
122
- - proper-auth-checks
123
- performance:
124
- - no-n-plus-one
125
- - efficient-queries
126
- - proper-caching
127
- architecture:
128
- - max-coupling: 5
129
- - min-cohesion: 0.7
130
- - follow-patterns
131
- ```
132
-
133
- ## Review Agents
134
-
135
- ### Security Review Agent
136
- ```javascript
137
- // Security checks performed
138
- {
139
- "checks": [
140
- "SQL injection vulnerabilities",
141
- "XSS attack vectors",
142
- "Authentication bypasses",
143
- "Authorization flaws",
144
- "Cryptographic weaknesses",
145
- "Dependency vulnerabilities",
146
- "Secret exposure",
147
- "CORS misconfigurations"
148
- ],
149
- "actions": [
150
- "Block PR on critical issues",
151
- "Suggest secure alternatives",
152
- "Add security test cases",
153
- "Update security documentation"
154
- ]
155
- }
156
- ```
157
-
158
- ### Performance Review Agent
159
- ```javascript
160
- // Performance analysis
161
- {
162
- "metrics": [
163
- "Algorithm complexity",
164
- "Database query efficiency",
165
- "Memory allocation patterns",
166
- "Cache utilization",
167
- "Network request optimization",
168
- "Bundle size impact",
169
- "Render performance"
170
- ],
171
- "benchmarks": [
172
- "Compare with baseline",
173
- "Load test simulations",
174
- "Memory leak detection",
175
- "Bottleneck identification"
176
- ]
338
+ ## 📈 Performance Targets
339
+
340
+ | Metric | Target | Enabled By |
341
+ |--------|--------|------------|
342
+ | **Review Accuracy** | +12.4% vs baseline | GNN Search |
343
+ | **False Positive Reduction** | <15% | ReasoningBank Learning |
344
+ | **Review Speed** | 2.49x-7.47x faster | Flash Attention |
345
+ | **Issue Detection Rate** | >95% | Combined capabilities |
346
+ | **Developer Satisfaction** | >90% | Attention Consensus |
347
+
348
+ ## 🔧 Implementation Examples
349
+
350
+ ### Example: Security Review with Learning
351
+
352
+ ```typescript
353
+ // Before review: Learn from past security reviews
354
+ const pastSecurityReviews = await reasoningBank.searchPatterns({
355
+ task: 'security vulnerability review',
356
+ k: 10,
357
+ minReward: 0.9
358
+ });
359
+
360
+ // Apply learned security patterns
361
+ const knownVulnerabilities = extractVulnerabilityPatterns(pastSecurityReviews);
362
+
363
+ // Review code with GNN-enhanced context
364
+ const securityIssues = await reviewSecurityWithGNN(code, knownVulnerabilities);
365
+
366
+ // Store new security patterns
367
+ if (securityIssues.length > 0) {
368
+ await reasoningBank.storePattern({
369
+ task: 'security vulnerability detected',
370
+ output: JSON.stringify(securityIssues),
371
+ reward: calculateSecurityReviewQuality(securityIssues),
372
+ success: true
373
+ });
177
374
  }
178
375
  ```
179
376
 
180
- ### Style & Convention Agent
181
- ```javascript
182
- // Style enforcement
183
- {
184
- "checks": [
185
- "Code formatting",
186
- "Naming conventions",
187
- "Documentation standards",
188
- "Comment quality",
189
- "Test coverage",
190
- "Error handling patterns",
191
- "Logging standards"
192
- ],
193
- "auto-fix": [
194
- "Formatting issues",
195
- "Import organization",
196
- "Trailing whitespace",
197
- "Simple naming issues"
198
- ]
199
- }
200
- ```
201
-
202
- ### Architecture Review Agent
203
- ```javascript
204
- // Architecture analysis
205
- {
206
- "patterns": [
207
- "Design pattern adherence",
208
- "SOLID principles",
209
- "DRY violations",
210
- "Separation of concerns",
211
- "Dependency injection",
212
- "Layer violations",
213
- "Circular dependencies"
214
- ],
215
- "metrics": [
216
- "Coupling metrics",
217
- "Cohesion scores",
218
- "Complexity measures",
219
- "Maintainability index"
220
- ]
221
- }
222
- ```
223
-
224
- ## Advanced Review Features
225
-
226
- ### 1. Context-Aware Reviews
227
- ```bash
228
- # Review with full context
229
- npx ruv-swarm github review-context \
230
- --pr 123 \
231
- --load-related-prs \
232
- --analyze-impact \
233
- --check-breaking-changes
234
- ```
235
-
236
- ### 2. Learning from History
237
- ```bash
238
- # Learn from past reviews
239
- npx ruv-swarm github review-learn \
240
- --analyze-past-reviews \
241
- --identify-patterns \
242
- --improve-suggestions \
243
- --reduce-false-positives
244
- ```
245
-
246
- ### 3. Cross-PR Analysis
247
- ```bash
248
- # Analyze related PRs together
249
- npx ruv-swarm github review-batch \
250
- --prs "123,124,125" \
251
- --check-consistency \
252
- --verify-integration \
253
- --combined-impact
254
- ```
255
-
256
- ## Review Automation
257
-
258
- ### Auto-Review on Push
259
- ```yaml
260
- # .github/workflows/auto-review.yml
261
- name: Automated Code Review
262
- on:
263
- pull_request:
264
- types: [opened, synchronize]
265
-
266
- jobs:
267
- swarm-review:
268
- runs-on: ubuntu-latest
269
- steps:
270
- - uses: actions/checkout@v3
271
- with:
272
- fetch-depth: 0
273
-
274
- - name: Setup GitHub CLI
275
- run: echo "${{ secrets.GITHUB_TOKEN }}" | gh auth login --with-token
276
-
277
- - name: Run Review Swarm
278
- run: |
279
- # Get PR context with gh CLI
280
- PR_NUM=${{ github.event.pull_request.number }}
281
- PR_DATA=$(gh pr view $PR_NUM --json files,title,body,labels)
282
-
283
- # Run swarm review
284
- REVIEW_OUTPUT=$(npx ruv-swarm github review-all \
285
- --pr $PR_NUM \
286
- --pr-data "$PR_DATA" \
287
- --agents "security,performance,style,architecture")
288
-
289
- # Post review results
290
- echo "$REVIEW_OUTPUT" | gh pr review $PR_NUM --comment -F -
291
-
292
- # Update PR status
293
- if echo "$REVIEW_OUTPUT" | grep -q "approved"; then
294
- gh pr review $PR_NUM --approve
295
- elif echo "$REVIEW_OUTPUT" | grep -q "changes-requested"; then
296
- gh pr review $PR_NUM --request-changes -b "See review comments above"
297
- fi
298
- ```
299
-
300
- ### Review Triggers
301
- ```javascript
302
- // Custom review triggers
303
- {
304
- "triggers": {
305
- "high-risk-files": {
306
- "paths": ["**/auth/**", "**/payment/**"],
307
- "agents": ["security", "architecture"],
308
- "depth": "comprehensive"
309
- },
310
- "performance-critical": {
311
- "paths": ["**/api/**", "**/database/**"],
312
- "agents": ["performance", "database"],
313
- "benchmarks": true
314
- },
315
- "ui-changes": {
316
- "paths": ["**/components/**", "**/styles/**"],
317
- "agents": ["accessibility", "style", "i18n"],
318
- "visual-tests": true
319
- }
320
- }
321
- }
322
- ```
323
-
324
- ## Review Comments
325
-
326
- ### Intelligent Comment Generation
327
- ```bash
328
- # Generate contextual review comments with gh CLI
329
- # Get PR diff with context
330
- PR_DIFF=$(gh pr diff 123 --color never)
331
- PR_FILES=$(gh pr view 123 --json files)
332
-
333
- # Generate review comments
334
- COMMENTS=$(npx ruv-swarm github review-comment \
335
- --pr 123 \
336
- --diff "$PR_DIFF" \
337
- --files "$PR_FILES" \
338
- --style "constructive" \
339
- --include-examples \
340
- --suggest-fixes)
341
-
342
- # Post comments using gh CLI
343
- echo "$COMMENTS" | jq -c '.[]' | while read -r comment; do
344
- FILE=$(echo "$comment" | jq -r '.path')
345
- LINE=$(echo "$comment" | jq -r '.line')
346
- BODY=$(echo "$comment" | jq -r '.body')
347
-
348
- # Create review with inline comments
349
- gh api \
350
- --method POST \
351
- /repos/:owner/:repo/pulls/123/comments \
352
- -f path="$FILE" \
353
- -f line="$LINE" \
354
- -f body="$BODY" \
355
- -f commit_id="$(gh pr view 123 --json headRefOid -q .headRefOid)"
356
- done
357
- ```
358
-
359
- ### Comment Templates
360
- ```markdown
361
- <!-- Security Issue Template -->
362
- 🔒 **Security Issue: [Type]**
363
-
364
- **Severity**: 🔴 Critical / 🟡 High / 🟢 Low
365
-
366
- **Description**:
367
- [Clear explanation of the security issue]
368
-
369
- **Impact**:
370
- [Potential consequences if not addressed]
371
-
372
- **Suggested Fix**:
373
- ```language
374
- [Code example of the fix]
375
- ```
376
-
377
- **References**:
378
- - [OWASP Guide](link)
379
- - [Security Best Practices](link)
380
- ```
381
-
382
- ### Batch Comment Management
383
- ```bash
384
- # Manage review comments efficiently
385
- npx ruv-swarm github review-comments \
386
- --pr 123 \
387
- --group-by "agent,severity" \
388
- --summarize \
389
- --resolve-outdated
390
- ```
391
-
392
- ## Integration with CI/CD
393
-
394
- ### Status Checks
395
- ```yaml
396
- # Required status checks
397
- protection_rules:
398
- required_status_checks:
399
- contexts:
400
- - "review-swarm/security"
401
- - "review-swarm/performance"
402
- - "review-swarm/architecture"
403
- ```
404
-
405
- ### Quality Gates
406
- ```bash
407
- # Define quality gates
408
- npx ruv-swarm github quality-gates \
409
- --define '{
410
- "security": {"threshold": "no-critical"},
411
- "performance": {"regression": "<5%"},
412
- "coverage": {"minimum": "80%"},
413
- "architecture": {"complexity": "<10"}
414
- }'
415
- ```
416
-
417
- ### Review Metrics
418
- ```bash
419
- # Track review effectiveness
420
- npx ruv-swarm github review-metrics \
421
- --period 30d \
422
- --metrics "issues-found,false-positives,fix-rate" \
423
- --export-dashboard
424
- ```
425
-
426
- ## Best Practices
427
-
428
- ### 1. Review Configuration
429
- - Define clear review criteria
430
- - Set appropriate thresholds
431
- - Configure agent specializations
432
- - Establish override procedures
433
-
434
- ### 2. Comment Quality
435
- - Provide actionable feedback
436
- - Include code examples
437
- - Reference documentation
438
- - Maintain respectful tone
439
-
440
- ### 3. Performance
441
- - Cache analysis results
442
- - Incremental reviews for large PRs
443
- - Parallel agent execution
444
- - Smart comment batching
445
-
446
- ## Advanced Features
447
-
448
- ### 1. AI Learning
449
- ```bash
450
- # Train on your codebase
451
- npx ruv-swarm github review-train \
452
- --learn-patterns \
453
- --adapt-to-style \
454
- --improve-accuracy
455
- ```
456
-
457
- ### 2. Custom Review Agents
458
- ```javascript
459
- // Create custom review agent
460
- class CustomReviewAgent {
461
- async review(pr) {
462
- const issues = [];
463
-
464
- // Custom logic here
465
- if (await this.checkCustomRule(pr)) {
466
- issues.push({
467
- severity: 'warning',
468
- message: 'Custom rule violation',
469
- suggestion: 'Fix suggestion'
470
- });
471
- }
472
-
473
- return issues;
474
- }
475
- }
476
- ```
477
-
478
- ### 3. Review Orchestration
479
- ```bash
480
- # Orchestrate complex reviews
481
- npx ruv-swarm github review-orchestrate \
482
- --strategy "risk-based" \
483
- --allocate-time-budget \
484
- --prioritize-critical
485
- ```
486
-
487
- ## Examples
488
-
489
- ### Security-Critical PR
490
- ```bash
491
- # Auth system changes
492
- npx ruv-swarm github review-init \
493
- --pr 456 \
494
- --agents "security,authentication,audit" \
495
- --depth "maximum" \
496
- --require-security-approval
497
- ```
498
-
499
- ### Performance-Sensitive PR
500
- ```bash
501
- # Database optimization
502
- npx ruv-swarm github review-init \
503
- --pr 789 \
504
- --agents "performance,database,caching" \
505
- --benchmark \
506
- --profile
507
- ```
508
-
509
- ### UI Component PR
510
- ```bash
511
- # New component library
512
- npx ruv-swarm github review-init \
513
- --pr 321 \
514
- --agents "accessibility,style,i18n,docs" \
515
- --visual-regression \
516
- --component-tests
517
- ```
518
-
519
- ## Monitoring & Analytics
520
-
521
- ### Review Dashboard
522
- ```bash
523
- # Launch review dashboard
524
- npx ruv-swarm github review-dashboard \
525
- --real-time \
526
- --show "agent-activity,issue-trends,fix-rates"
527
- ```
528
-
529
- ### Review Reports
530
- ```bash
531
- # Generate review reports
532
- npx ruv-swarm github review-report \
533
- --format "markdown" \
534
- --include "summary,details,trends" \
535
- --email-stakeholders
536
- ```
537
-
538
- See also: [swarm-pr.md](./swarm-pr.md), [workflow-automation.md](./workflow-automation.md)
377
+ See also: [swarm-pr.md](./swarm-pr.md), [workflow-automation.md](./workflow-automation.md)