cmp-standards 3.7.0 → 3.8.1

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 (56) hide show
  1. package/dist/hooks/auto-learning-hook.d.ts +48 -0
  2. package/dist/hooks/auto-learning-hook.d.ts.map +1 -0
  3. package/dist/hooks/auto-learning-hook.js +258 -0
  4. package/dist/hooks/auto-learning-hook.js.map +1 -0
  5. package/dist/hooks/cloud-post-tool-use.d.ts.map +1 -1
  6. package/dist/hooks/cloud-post-tool-use.js +20 -3
  7. package/dist/hooks/cloud-post-tool-use.js.map +1 -1
  8. package/dist/hooks/cloud-pre-tool-use.d.ts.map +1 -1
  9. package/dist/hooks/cloud-pre-tool-use.js +27 -16
  10. package/dist/hooks/cloud-pre-tool-use.js.map +1 -1
  11. package/dist/hooks/fast-session-start.d.ts +24 -0
  12. package/dist/hooks/fast-session-start.d.ts.map +1 -0
  13. package/dist/hooks/fast-session-start.js +363 -0
  14. package/dist/hooks/fast-session-start.js.map +1 -0
  15. package/dist/hooks/session-start.d.ts.map +1 -1
  16. package/dist/hooks/session-start.js +24 -1
  17. package/dist/hooks/session-start.js.map +1 -1
  18. package/dist/index.d.ts +12 -0
  19. package/dist/index.d.ts.map +1 -1
  20. package/dist/index.js +17 -0
  21. package/dist/index.js.map +1 -1
  22. package/dist/services/ProjectScaffold.d.ts.map +1 -1
  23. package/dist/services/ProjectScaffold.js +31 -0
  24. package/dist/services/ProjectScaffold.js.map +1 -1
  25. package/dist/services/auto-evolution-trigger.d.ts +101 -0
  26. package/dist/services/auto-evolution-trigger.d.ts.map +1 -0
  27. package/dist/services/auto-evolution-trigger.js +359 -0
  28. package/dist/services/auto-evolution-trigger.js.map +1 -0
  29. package/dist/services/cloud-memory-service.d.ts +101 -0
  30. package/dist/services/cloud-memory-service.d.ts.map +1 -0
  31. package/dist/services/cloud-memory-service.js +363 -0
  32. package/dist/services/cloud-memory-service.js.map +1 -0
  33. package/dist/services/memory-keeper-client.d.ts +106 -0
  34. package/dist/services/memory-keeper-client.d.ts.map +1 -0
  35. package/dist/services/memory-keeper-client.js +319 -0
  36. package/dist/services/memory-keeper-client.js.map +1 -0
  37. package/dist/services/skill-learning-bridge.d.ts +100 -0
  38. package/dist/services/skill-learning-bridge.d.ts.map +1 -0
  39. package/dist/services/skill-learning-bridge.js +331 -0
  40. package/dist/services/skill-learning-bridge.js.map +1 -0
  41. package/dist/services/unified-memory-router.d.ts +123 -0
  42. package/dist/services/unified-memory-router.d.ts.map +1 -0
  43. package/dist/services/unified-memory-router.js +555 -0
  44. package/dist/services/unified-memory-router.js.map +1 -0
  45. package/dist/utils/env-loader.js +1 -1
  46. package/dist/utils/env-loader.js.map +1 -1
  47. package/package.json +1 -1
  48. package/templates/agents/_reasoning-framework.md +250 -0
  49. package/templates/agents/architecture-expert.md +294 -31
  50. package/templates/agents/database-expert.md +297 -34
  51. package/templates/agents/documentation-expert.md +232 -31
  52. package/templates/agents/memory-expert.md +264 -46
  53. package/templates/agents/performance-expert.md +319 -32
  54. package/templates/agents/security-expert.md +258 -30
  55. package/templates/agents/ux-expert.md +293 -35
  56. package/templates/commands/experts.md +322 -85
@@ -1,138 +1,375 @@
1
- ## /experts - AI Code Review System
1
+ ---
2
+ name: experts
3
+ description: Multi-expert code review with rigorous logical reasoning and evidence-based consensus
4
+ arguments:
5
+ - name: target
6
+ description: Files, directories, or task description to review
7
+ required: true
8
+ - name: --only
9
+ description: Comma-separated list of experts to include (security,performance,architecture,ux,database)
10
+ required: false
11
+ - name: --verbose
12
+ description: Show full reasoning chains from each expert
13
+ required: false
14
+ - name: --confidence
15
+ description: Minimum confidence level for findings (CERTAIN,HIGH,MEDIUM)
16
+ default: MEDIUM
17
+ required: false
18
+ ---
19
+
20
+ # /experts - Evidence-Based Code Review System
2
21
 
3
- > **Purpose**: Multi-expert code review with consensus voting
4
- > **Usage**: `/experts [files or task description]`
22
+ > **Framework**: All experts use `_reasoning-framework.md` for rigorous logical analysis.
23
+
24
+ Execute this multi-phase expert review following the logical sequence below.
5
25
 
6
26
  ---
7
27
 
8
- ## Overview
28
+ ## PHASE 1: PRE-ANALYSIS (Mandatory First Step)
29
+
30
+ Before invoking ANY expert, complete these checks:
31
+
32
+ ### 1.1 Target Resolution
33
+ ```
34
+ TASK: Resolve $ARGUMENTS.target to actual files
35
+
36
+ STEPS:
37
+ 1. IF target is file path → Verify file exists
38
+ 2. IF target is directory → Glob for relevant files (.ts, .tsx, .js, .jsx)
39
+ 3. IF target is description → Search codebase for relevant files
40
+ 4. IF no files found → STOP with clear error message
41
+
42
+ OUTPUT:
43
+ - files_to_review: [list of absolute paths]
44
+ - total_lines: [estimated line count]
45
+ - file_types: [breakdown by extension]
46
+ ```
9
47
 
10
- The `/experts` command launches a panel of AI experts to review your code:
48
+ ### 1.2 Criticality Assessment
49
+ ```
50
+ PREMISE: IF code_touches_critical_domain THEN requires_unanimous_approval
51
+
52
+ CRITICAL DOMAINS (search for these patterns):
53
+ - Authentication: auth, login, session, token, jwt, oauth
54
+ - Authorization: permission, role, access, admin, rbac
55
+ - Financial: payment, stripe, invoice, billing, transaction
56
+ - Data: migration, schema, DROP, ALTER, DELETE
57
+ - Security: password, secret, encrypt, hash, sanitize
58
+
59
+ ASSESSMENT:
60
+ 1. Grep target files for critical patterns
61
+ 2. Count matches per domain
62
+ 3. Determine criticality level
63
+
64
+ OUTPUT:
65
+ - criticality: CRITICAL | NORMAL
66
+ - critical_domains_found: [list with file:line references]
67
+ - reasoning: "Found X pattern at Y location, therefore Z"
68
+ ```
11
69
 
12
- 1. **Security Expert** - SQL injection, auth, input validation
13
- 2. **Performance Expert** - Waterfalls, N+1, lazy loading
14
- 3. **Architecture Expert** - Types, modules, SOLID principles
15
- 4. **UX Expert** - Accessibility, mobile-first, design tokens
16
- 5. **Database Expert** - Schema, migrations, queries
17
- 6. **Memory Expert** - Pattern detection, auto-improvement
70
+ ### 1.3 Expert Selection
71
+ ```
72
+ PREMISE: Select experts based on actual file content, not assumptions
73
+
74
+ DETECTION RULES:
75
+ - Security Expert: IF (user input handling OR auth code OR data validation)
76
+ - Performance Expert: IF (loops OR async/await OR database queries OR React components)
77
+ - Architecture Expert: IF (type definitions OR imports OR module structure)
78
+ - UX Expert: IF (JSX/TSX OR CSS OR component files)
79
+ - Database Expert: IF (schema files OR query builders OR migrations)
80
+ - Memory Expert: ALWAYS (observes patterns)
81
+ - Documentation Expert: IF (public API changes)
82
+
83
+ PROCESS:
84
+ 1. Read first 100 lines of each file
85
+ 2. Detect patterns matching each expert's domain
86
+ 3. Select experts with HIGH confidence of relevance
87
+ 4. IF --only flag provided, override with specified experts
88
+
89
+ OUTPUT:
90
+ - selected_experts: [list with selection reasoning]
91
+ - excluded_experts: [list with exclusion reasoning]
92
+ ```
18
93
 
19
94
  ---
20
95
 
21
- ## Usage Examples
96
+ ## PHASE 2: PARALLEL EXPERT EXECUTION
22
97
 
23
- ```bash
24
- # Review specific file
25
- /experts src/components/UserForm.tsx
98
+ Launch selected experts in parallel using the Task tool.
26
99
 
27
- # Review directory
28
- /experts src/server/api/routers/
100
+ ### 2.1 Expert Invocation Template
29
101
 
30
- # Review with context
31
- /experts "Review the new authentication flow"
102
+ For EACH selected expert, invoke with this prompt structure:
103
+
104
+ ```
105
+ You are the {EXPERT_NAME} reviewing these files: {FILE_LIST}
106
+
107
+ MANDATORY: Follow the reasoning framework in _reasoning-framework.md
108
+
109
+ FOR EACH FINDING:
110
+ 1. OBSERVE: Quote exact code with file:line
111
+ 2. STATE PREMISE: "IF [condition] THEN [consequence]"
112
+ 3. VERIFY: Show what you searched and found
113
+ 4. FALSIFY: Ask "What would make this NOT an issue?"
114
+ 5. CONCLUDE: State confidence level and severity
115
+
116
+ CONFIDENCE REQUIREMENTS:
117
+ - CERTAIN: Direct observation, reproducible
118
+ - HIGH: Pattern match + context verified
119
+ - MEDIUM: Pattern match, some gaps
120
+ - LOW: Inference only (cannot trigger REJECT)
121
+
122
+ OUTPUT FORMAT (JSON):
123
+ {
124
+ "expert": "{EXPERT_NAME}",
125
+ "vote": "APPROVE|REJECT|ABSTAIN",
126
+ "overall_confidence": "CERTAIN|HIGH|MEDIUM|LOW|UNKNOWN",
127
+ "search_log": {
128
+ "patterns_searched": [],
129
+ "files_checked": [],
130
+ "coverage_percent": 0
131
+ },
132
+ "findings": [
133
+ {
134
+ "severity": "critical|high|medium|low",
135
+ "confidence": "CERTAIN|HIGH|MEDIUM|LOW",
136
+ "file": "path",
137
+ "line": 0,
138
+ "observation": "what I saw",
139
+ "premise": "IF X THEN Y",
140
+ "verification": "how I confirmed",
141
+ "falsification": {"question": "", "status": "verified|disproven|uncertain"},
142
+ "message": "description",
143
+ "fix": "specific fix"
144
+ }
145
+ ],
146
+ "summary": "brief summary with confidence qualification"
147
+ }
148
+ ```
149
+
150
+ ### 2.2 Parallel Execution
151
+ ```
152
+ EXECUTE: Launch all selected experts simultaneously using Task tool
153
+ TIMEOUT: 60 seconds per expert
154
+ FALLBACK: If expert times out, record as ABSTAIN with reason
32
155
  ```
33
156
 
34
157
  ---
35
158
 
36
- ## How It Works
159
+ ## PHASE 3: RESULT SYNTHESIS
160
+
161
+ After all experts complete, synthesize results with logical reasoning.
37
162
 
163
+ ### 3.1 Confidence Aggregation
164
+ ```
165
+ FOR EACH expert_result:
166
+ - Extract vote and confidence
167
+ - Extract all findings with severity >= $ARGUMENTS.confidence
168
+ - Discard findings with confidence < $ARGUMENTS.confidence
169
+
170
+ AGGREGATE:
171
+ - total_findings: count of valid findings
172
+ - high_confidence_issues: findings where confidence >= HIGH AND severity >= HIGH
173
+ - uncertain_findings: findings where confidence = MEDIUM or status = uncertain
38
174
  ```
39
- 1. ANALYZE CODE
40
- • Detect criticality (CRITICAL vs NORMAL)
41
- • Select relevant experts
42
175
 
43
- 2. PARALLEL REVIEW (30-45 seconds)
44
- • Each expert reviews independently
45
- Generates vote and findings
176
+ ### 3.2 Conflict Detection
177
+ ```
178
+ PREMISE: IF expert_A_says_X AND expert_B_says_NOT_X THEN conflict
46
179
 
47
- 3. CONSENSUS VOTING
48
- CRITICAL: Unanimity required (0 REJECT)
49
- NORMAL: Majority required (3/5 APPROVE)
180
+ CHECK FOR:
181
+ - Same file, conflicting assessments
182
+ - Same pattern, different severity ratings
183
+ - Contradicting recommendations
50
184
 
51
- 4. RESULT
52
- APPROVED Verification runs
53
- REJECTED Detailed feedback provided
185
+ FOR EACH conflict:
186
+ - Document both positions
187
+ - Identify which has higher confidence
188
+ - Flag for human review if equal confidence
189
+ ```
190
+
191
+ ### 3.3 Voting Logic
192
+ ```
193
+ IF criticality = CRITICAL:
194
+ REQUIRE: Unanimous approval (0 REJECT votes)
195
+ LOGIC: ALL(votes == APPROVE OR votes == ABSTAIN)
196
+
197
+ IF criticality = NORMAL:
198
+ REQUIRE: Majority approval
199
+ LOGIC: COUNT(APPROVE) > COUNT(REJECT)
200
+
201
+ VOTE WEIGHTING:
202
+ - ABSTAIN votes do not count toward total
203
+ - REJECT with confidence = LOW is logged but doesn't block
204
+ - REJECT with confidence >= HIGH blocks approval
205
+
206
+ FINAL_DECISION:
207
+ IF voting_requirement_met AND no_high_confidence_rejects:
208
+ decision = APPROVED
209
+ ELSE:
210
+ decision = REJECTED
211
+ blocking_reasons = [list of high-confidence rejects]
54
212
  ```
55
213
 
56
214
  ---
57
215
 
58
- ## Criticality Detection
216
+ ## PHASE 4: OUTPUT GENERATION
59
217
 
60
- Code is **CRITICAL** if it involves:
61
- - Authentication/Authorization
62
- - Financial operations
63
- - Database schema changes
64
- - External payment integrations
218
+ Generate structured output with full reasoning chain.
65
219
 
66
- Critical code requires **unanimous approval** (no REJECT votes).
220
+ ### 4.1 Summary Header
221
+ ```markdown
222
+ ## Expert Review Results
67
223
 
68
- ---
224
+ | Metric | Value |
225
+ |--------|-------|
226
+ | Files Reviewed | {count} |
227
+ | Lines Analyzed | {count} |
228
+ | Criticality | {CRITICAL/NORMAL} |
229
+ | Experts Invoked | {list} |
230
+ | Review Duration | {time} |
231
+ ```
69
232
 
70
- ## Expert Responsibilities
233
+ ### 4.2 Voting Summary
234
+ ```markdown
235
+ ## Voting Summary
71
236
 
72
- | Expert | Checks | Rejects On |
73
- |--------|--------|------------|
74
- | Security | SQL injection, auth, validation | Any security hole |
75
- | Performance | N+1, waterfalls, bundle size | Critical perf issues |
76
- | Architecture | Types, modules, SOLID | Type violations |
77
- | UX | A11y, mobile, tokens | Missing accessibility |
78
- | Database | Schema, migrations | Data loss risk |
79
- | Memory | Patterns | Never (ABSTAIN) |
237
+ Decision: {APPROVED / REJECTED ❌}
238
+ Requirement: {Unanimous / Majority}
80
239
 
81
- ---
240
+ | Expert | Vote | Confidence | Key Finding |
241
+ |--------|------|------------|-------------|
242
+ | Security | APPROVE | HIGH | No SQL injection detected |
243
+ | Performance | REJECT | CERTAIN | N+1 query at users.ts:45 |
244
+ | ... | ... | ... | ... |
245
+
246
+ Reasoning Chain:
247
+ 1. [Expert votes and confidence levels]
248
+ 2. [Voting requirement check]
249
+ 3. [Final decision with justification]
250
+ ```
82
251
 
83
- ## Output Example
252
+ ### 4.3 Findings Detail (if --verbose or REJECTED)
253
+ ```markdown
254
+ ## Detailed Findings
84
255
 
256
+ ### Finding 1: [Title]
257
+ - **Expert**: Performance
258
+ - **Severity**: HIGH
259
+ - **Confidence**: CERTAIN
260
+ - **Location**: `src/api/users.ts:45`
261
+
262
+ **Observation**:
263
+ ```typescript
264
+ // Exact code quoted
85
265
  ```
86
- ## Expert Review
87
- Files: 1
88
- Criticality: NORMAL
89
- Experts: Security, Performance, Architecture, UX (4)
90
266
 
91
- [30 seconds - parallel review]
267
+ **Premise**: IF query_in_loop AND n > 20 THEN performance_issue
268
+
269
+ **Verification**:
270
+ - Searched: forEach, map, for patterns with await
271
+ - Found: Query inside forEach iterating over users array
272
+ - Estimated iterations: 50 per page load
273
+
274
+ **Falsification**:
275
+ - Question: "Is this loop executed rarely?"
276
+ - Answer: No, called on every dashboard load
277
+ - Status: Verified issue
278
+
279
+ **Fix**:
280
+ ```typescript
281
+ // Specific fix with code
282
+ ```
283
+ ```
92
284
 
93
- APPROVED (4/4)
94
- Security: ✓ APPROVE
95
- Performance: APPROVE
96
- Architecture: ✓ APPROVE
97
- UX: ✓ APPROVE
285
+ ### 4.4 Conflicts & Uncertainties
286
+ ```markdown
287
+ ## Conflicts & Uncertainties
98
288
 
99
- Running verification...
100
- typecheck passed
101
- lint passed
289
+ ### Conflict 1: [Description]
290
+ - Expert A says: [X]
291
+ - Expert B says: [Y]
292
+ - Resolution: [Higher confidence wins / Needs human review]
102
293
 
103
- All checks passed!
294
+ ### Uncertain Findings (require manual verification)
295
+ - [Finding with confidence = MEDIUM and status = uncertain]
104
296
  ```
105
297
 
106
298
  ---
107
299
 
108
- ## When to Use
300
+ ## PHASE 5: POST-REVIEW ACTIONS
109
301
 
110
- **Use /experts for:**
111
- - Critical changes (auth, payments, schema)
112
- - Before submitting PRs
113
- - Large refactors
114
- - Learning (get feedback)
302
+ ### 5.1 If APPROVED
303
+ ```
304
+ EXECUTE:
305
+ 1. Run typecheck: npm run typecheck
306
+ 2. Run lint: npm run lint
307
+ 3. Report any new errors
308
+ 4. IF all pass → "Ready for commit"
309
+ 5. IF any fail → Document failures, do NOT change decision
310
+ ```
115
311
 
116
- **Don't use for:**
117
- - WIP code
118
- - Trivial changes (typos)
119
- - Generated code
312
+ ### 5.2 If REJECTED
313
+ ```
314
+ OUTPUT:
315
+ 1. List all blocking issues with fixes
316
+ 2. Prioritize by: confidence DESC, severity DESC
317
+ 3. Provide actionable next steps
318
+ 4. Memory Expert logs patterns for future prevention
319
+ ```
320
+
321
+ ### 5.3 Memory Expert Handoff
322
+ ```
323
+ ALWAYS:
324
+ - Pass all findings to Memory Expert
325
+ - Memory Expert checks for patterns (>= 3 occurrences)
326
+ - If threshold met, propose auto-improvement
327
+ - Log decision in cloud database
328
+ ```
120
329
 
121
330
  ---
122
331
 
123
- ## Advanced Options
332
+ ## QUICK REFERENCE
333
+
334
+ ### Confidence Levels
335
+ | Level | Meaning | Can Block? |
336
+ |-------|---------|------------|
337
+ | CERTAIN | Direct evidence, verified | YES |
338
+ | HIGH | Pattern + context verified | YES |
339
+ | MEDIUM | Pattern match, gaps exist | Only if CRITICAL severity |
340
+ | LOW | Inference only | NO |
341
+
342
+ ### Severity Levels
343
+ | Level | Examples |
344
+ |-------|----------|
345
+ | CRITICAL | SQL injection, auth bypass, data loss |
346
+ | HIGH | N+1 queries, missing validation, type unsafety |
347
+ | MEDIUM | Code smells, minor performance, missing a11y |
348
+ | LOW | Style issues, minor improvements |
349
+
350
+ ### Expert Quick Guide
351
+ | Expert | Domain | Blocks On |
352
+ |--------|--------|-----------|
353
+ | Security | SQL, auth, XSS, validation | Any HIGH+ security issue |
354
+ | Performance | N+1, waterfalls, bundle | Quantified impact > threshold |
355
+ | Architecture | Types, modules, SOLID | Type violations, circulars |
356
+ | UX | A11y, mobile, tokens | WCAG violations |
357
+ | Database | Schema, migrations | Data loss risk |
358
+ | Memory | Patterns | Never (ABSTAIN only) |
359
+ | Documentation | Docs accuracy | Never (ABSTAIN only) |
124
360
 
125
- ```bash
126
- # Review specific experts only
127
- /experts src/file.ts --only security,architecture
361
+ ---
128
362
 
129
- # Verbose output (show reasoning)
130
- /experts src/file.ts --verbose
363
+ ## ANTI-PATTERNS TO AVOID
131
364
 
132
- # Dry run (no auto-improvements)
133
- /experts src/file.ts --dry-run
134
- ```
365
+ | Wrong | Right |
366
+ |-------|-------|
367
+ | "Looks good" | "Reviewed X files, Y patterns checked, Z findings with confidence levels" |
368
+ | "Security approved" | "Security: No SQL injection (searched 5 patterns), auth middleware verified on 3 routes" |
369
+ | "REJECTED" | "REJECTED: N+1 at file.ts:45 (confidence: CERTAIN, impact: 50 queries/page)" |
370
+ | Skip pre-analysis | ALWAYS run Phase 1 before invoking experts |
371
+ | Ignore ABSTAIN | Document why expert abstained for transparency |
135
372
 
136
373
  ---
137
374
 
138
- *Part of cmp-memory-system - MetaNautical Group*
375
+ *Expert Review System v2.0 - Evidence-Based Code Analysis*