@nerviq/cli 1.29.0 → 1.29.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 (80) hide show
  1. package/CHANGELOG.md +1527 -1493
  2. package/README.md +550 -538
  3. package/SECURITY.md +82 -82
  4. package/bin/cli.js +2562 -2558
  5. package/docs/api-reference.md +356 -356
  6. package/docs/audit-fix.md +109 -0
  7. package/docs/autofix.md +3 -62
  8. package/docs/getting-started.md +1 -1
  9. package/docs/index.html +592 -592
  10. package/docs/integration-contracts.md +287 -287
  11. package/docs/maintenance.md +128 -128
  12. package/docs/new-platform-guide.md +202 -202
  13. package/docs/release-process.md +63 -0
  14. package/docs/shallow-risk.md +244 -244
  15. package/docs/why-nerviq.md +82 -82
  16. package/package.json +67 -67
  17. package/src/aider/activity.js +226 -226
  18. package/src/aider/context.js +162 -162
  19. package/src/aider/freshness.js +123 -123
  20. package/src/aider/techniques.js +3465 -3465
  21. package/src/audit/layers.js +180 -180
  22. package/src/audit.js +1032 -1032
  23. package/src/benchmark.js +299 -299
  24. package/src/codex/activity.js +324 -324
  25. package/src/codex/freshness.js +142 -142
  26. package/src/codex/techniques.js +4895 -4895
  27. package/src/context.js +326 -326
  28. package/src/continuous-ops.js +11 -1
  29. package/src/convert.js +340 -340
  30. package/src/copilot/config-parser.js +280 -280
  31. package/src/copilot/context.js +218 -218
  32. package/src/copilot/freshness.js +177 -177
  33. package/src/copilot/patch.js +238 -238
  34. package/src/copilot/techniques.js +3578 -3578
  35. package/src/cursor/freshness.js +194 -194
  36. package/src/cursor/patch.js +243 -243
  37. package/src/cursor/techniques.js +3735 -3735
  38. package/src/doctor.js +201 -201
  39. package/src/fix-engine.js +511 -8
  40. package/src/formatters/csv.js +86 -86
  41. package/src/formatters/junit.js +123 -123
  42. package/src/formatters/markdown.js +164 -164
  43. package/src/formatters/otel.js +151 -151
  44. package/src/freshness.js +156 -156
  45. package/src/gemini/activity.js +402 -402
  46. package/src/gemini/context.js +290 -290
  47. package/src/gemini/freshness.js +183 -183
  48. package/src/gemini/patch.js +229 -229
  49. package/src/gemini/techniques.js +3811 -3811
  50. package/src/governance.js +533 -533
  51. package/src/harmony/audit.js +306 -306
  52. package/src/i18n.js +63 -63
  53. package/src/insights.js +119 -119
  54. package/src/integrations.js +134 -134
  55. package/src/locales/en.json +33 -33
  56. package/src/locales/es.json +33 -33
  57. package/src/migrate.js +354 -354
  58. package/src/opencode/activity.js +286 -286
  59. package/src/opencode/freshness.js +137 -137
  60. package/src/opencode/techniques.js +3450 -3450
  61. package/src/setup/analysis.js +12 -12
  62. package/src/setup.js +7 -6
  63. package/src/shallow-risk/index.js +56 -56
  64. package/src/shallow-risk/patterns/agent-config-cross-platform-drift.js +50 -50
  65. package/src/shallow-risk/patterns/agent-config-dangerous-autoapprove.js +46 -46
  66. package/src/shallow-risk/patterns/agent-config-deprecated-keys.js +46 -46
  67. package/src/shallow-risk/patterns/agent-config-missing-file.js +317 -317
  68. package/src/shallow-risk/patterns/agent-config-secret-literal.js +49 -49
  69. package/src/shallow-risk/patterns/agent-config-stack-contradiction.js +34 -34
  70. package/src/shallow-risk/patterns/hook-script-missing.js +70 -70
  71. package/src/shallow-risk/patterns/mcp-server-no-allowlist.js +52 -52
  72. package/src/shallow-risk/shared.js +648 -648
  73. package/src/source-urls.js +295 -295
  74. package/src/state-paths.js +85 -85
  75. package/src/supplemental-checks.js +805 -805
  76. package/src/telemetry.js +160 -160
  77. package/src/windsurf/context.js +359 -359
  78. package/src/windsurf/freshness.js +194 -194
  79. package/src/windsurf/patch.js +231 -231
  80. package/src/windsurf/techniques.js +3779 -3779
package/package.json CHANGED
@@ -1,67 +1,67 @@
1
- {
2
- "name": "@nerviq/cli",
3
- "version": "1.29.0",
4
- "description": "The intelligent nervous system for AI coding agents — 2,441 checks (8 platforms × ~300 governance rules), 10 languages, 62 domain packs. Audit, align, and amplify.",
5
- "main": "src/index.js",
6
- "bin": {
7
- "nerviq": "bin/cli.js",
8
- "@nerviq/cli": "bin/cli.js",
9
- "nerviq-mcp": "src/mcp-server.js"
10
- },
11
- "files": [
12
- "bin",
13
- "src",
14
- "README.md",
15
- "docs",
16
- "contracts",
17
- "sdk/README.md",
18
- "CHANGELOG.md",
19
- "SECURITY.md"
20
- ],
21
- "scripts": {
22
- "start": "node bin/cli.js",
23
- "build": "npm pack --dry-run",
24
- "test": "node test/run.js",
25
- "verify:release-metadata": "node tools/validate-release-metadata.js",
26
- "prepublish:check": "node tools/pre-publish.js",
27
- "prepublishOnly": "node tools/pre-publish.js",
28
- "test:jest": "jest",
29
- "test:coverage": "jest --coverage",
30
- "test:all": "npm test && npx jest && node test/check-matrix.js && node test/codex-check-matrix.js && node test/gemini-check-matrix.js && node test/copilot-check-matrix.js && node test/cursor-check-matrix.js && node test/windsurf-check-matrix.js && node test/aider-check-matrix.js && node test/opencode-check-matrix.js && node test/golden-matrix.js && node test/codex-golden-matrix.js && node test/gemini-golden-matrix.js && node test/copilot-golden-matrix.js && node test/cursor-golden-matrix.js && node test/windsurf-golden-matrix.js && node test/aider-golden-matrix.js && node test/opencode-golden-matrix.js",
31
- "benchmark:perf": "node tools/benchmark.js",
32
- "catalog": "node -e \"const {generateCatalog}=require('./src/catalog');console.log(JSON.stringify(generateCatalog(),null,2))\""
33
- },
34
- "keywords": [
35
- "nerviq",
36
- "ai-agents",
37
- "agent-governance",
38
- "agent-config",
39
- "harmony",
40
- "synergy",
41
- "audit",
42
- "claude",
43
- "codex",
44
- "gemini",
45
- "copilot",
46
- "cursor",
47
- "windsurf",
48
- "aider",
49
- "developer-tools",
50
- "cli",
51
- "mcp",
52
- "multi-agent"
53
- ],
54
- "author": "Nerviq <hello@nerviq.net>",
55
- "license": "AGPL-3.0",
56
- "repository": {
57
- "type": "git",
58
- "url": "git+https://github.com/nerviq/nerviq.git"
59
- },
60
- "homepage": "https://nerviq.net",
61
- "engines": {
62
- "node": ">=18.0.0"
63
- },
64
- "devDependencies": {
65
- "jest": "^30.3.0"
66
- }
67
- }
1
+ {
2
+ "name": "@nerviq/cli",
3
+ "version": "1.29.1",
4
+ "description": "The intelligent nervous system for AI coding agents — 2,441 checks (8 platforms × ~300 governance rules), 10 languages, 62 domain packs. Audit, align, and amplify.",
5
+ "main": "src/index.js",
6
+ "bin": {
7
+ "nerviq": "bin/cli.js",
8
+ "@nerviq/cli": "bin/cli.js",
9
+ "nerviq-mcp": "src/mcp-server.js"
10
+ },
11
+ "files": [
12
+ "bin",
13
+ "src",
14
+ "README.md",
15
+ "docs",
16
+ "contracts",
17
+ "sdk/README.md",
18
+ "CHANGELOG.md",
19
+ "SECURITY.md"
20
+ ],
21
+ "scripts": {
22
+ "start": "node bin/cli.js",
23
+ "build": "npm pack --dry-run",
24
+ "test": "node test/run.js",
25
+ "verify:release-metadata": "node tools/validate-release-metadata.js",
26
+ "prepublish:check": "node tools/pre-publish.js",
27
+ "prepublishOnly": "node tools/pre-publish.js",
28
+ "test:jest": "jest",
29
+ "test:coverage": "jest --coverage",
30
+ "test:all": "npm test && npx jest && node test/check-matrix.js && node test/codex-check-matrix.js && node test/gemini-check-matrix.js && node test/copilot-check-matrix.js && node test/cursor-check-matrix.js && node test/windsurf-check-matrix.js && node test/aider-check-matrix.js && node test/opencode-check-matrix.js && node test/golden-matrix.js && node test/codex-golden-matrix.js && node test/gemini-golden-matrix.js && node test/copilot-golden-matrix.js && node test/cursor-golden-matrix.js && node test/windsurf-golden-matrix.js && node test/aider-golden-matrix.js && node test/opencode-golden-matrix.js",
31
+ "benchmark:perf": "node tools/benchmark.js",
32
+ "catalog": "node -e \"const {generateCatalog}=require('./src/catalog');console.log(JSON.stringify(generateCatalog(),null,2))\""
33
+ },
34
+ "keywords": [
35
+ "nerviq",
36
+ "ai-agents",
37
+ "agent-governance",
38
+ "agent-config",
39
+ "harmony",
40
+ "synergy",
41
+ "audit",
42
+ "claude",
43
+ "codex",
44
+ "gemini",
45
+ "copilot",
46
+ "cursor",
47
+ "windsurf",
48
+ "aider",
49
+ "developer-tools",
50
+ "cli",
51
+ "mcp",
52
+ "multi-agent"
53
+ ],
54
+ "author": "Nerviq <hello@nerviq.net>",
55
+ "license": "AGPL-3.0",
56
+ "repository": {
57
+ "type": "git",
58
+ "url": "git+https://github.com/nerviq/nerviq.git"
59
+ },
60
+ "homepage": "https://nerviq.net",
61
+ "engines": {
62
+ "node": ">=18.0.0"
63
+ },
64
+ "devDependencies": {
65
+ "jest": "^30.3.0"
66
+ }
67
+ }
@@ -1,226 +1,226 @@
1
- /**
2
- * Aider Repeat-Usage Surfaces — 6 activity surfaces
3
- *
4
- * Adapts the shared activity/snapshot backend for Aider platform.
5
- * Provides: history, compare, trend, watch, feedback, insights.
6
- *
7
- * Aider snapshots stored in .nerviq/snapshots/ (legacy: .claude/nerviq-cli/snapshots/) filtered by platform='aider'.
8
- */
9
-
10
- const path = require('path');
11
- const {
12
- getHistory: getSharedHistory,
13
- compareLatest: sharedCompareLatest,
14
- readSnapshotIndex,
15
- writeSnapshotArtifact,
16
- exportTrendReport: sharedExportTrendReport,
17
- recordRecommendationOutcome,
18
- readOutcomeIndex,
19
- summarizeOutcomeEntries,
20
- } = require('../activity');
21
- const { version } = require('../../package.json');
22
-
23
- // --- History ---
24
-
25
- function getAiderHistory(dir, limit = 20) {
26
- const entries = readSnapshotIndex(dir);
27
- return entries
28
- .filter(e => e.snapshotKind === 'audit' && (e.platform === 'aider' || e.summary?.platform === 'aider'))
29
- .sort((a, b) => new Date(b.createdAt) - new Date(a.createdAt))
30
- .slice(0, limit);
31
- }
32
-
33
- function formatAiderHistory(dir) {
34
- const history = getAiderHistory(dir, 10);
35
- if (history.length === 0) {
36
- return 'No Aider snapshots found. Run `npx nerviq --platform aider --snapshot` to save one.';
37
- }
38
-
39
- const lines = ['Aider Score History (most recent first):', ''];
40
- for (const entry of history) {
41
- const date = entry.createdAt?.split('T')[0] || 'unknown';
42
- const score = entry.summary?.score ?? '?';
43
- const passed = entry.summary?.passed ?? '?';
44
- const total = entry.summary?.checkCount ?? '?';
45
- lines.push(` ${date} ${score}/100 (${passed}/${total} passing)`);
46
- }
47
-
48
- const comparison = compareAiderLatest(dir);
49
- if (comparison) {
50
- lines.push('');
51
- const sign = comparison.delta.score >= 0 ? '+' : '';
52
- lines.push(` Trend: ${comparison.trend} (${sign}${comparison.delta.score} since previous)`);
53
- if (comparison.improvements.length > 0) {
54
- lines.push(` Fixed: ${comparison.improvements.join(', ')}`);
55
- }
56
- if (comparison.regressions.length > 0) {
57
- lines.push(` New gaps: ${comparison.regressions.join(', ')}`);
58
- }
59
- }
60
-
61
- return lines.join('\n');
62
- }
63
-
64
- // --- Compare ---
65
-
66
- function compareAiderLatest(dir) {
67
- const audits = getAiderHistory(dir, 2);
68
- if (audits.length < 2) return null;
69
-
70
- const current = audits[0];
71
- const previous = audits[1];
72
-
73
- const currentPassed = new Set(current.summary?.passedIds || []);
74
- const previousPassed = new Set(previous.summary?.passedIds || []);
75
-
76
- const improvements = [];
77
- const regressions = [];
78
-
79
- for (const id of currentPassed) {
80
- if (!previousPassed.has(id)) improvements.push(id);
81
- }
82
- for (const id of previousPassed) {
83
- if (!currentPassed.has(id)) regressions.push(id);
84
- }
85
-
86
- const scoreDelta = (current.summary?.score ?? 0) - (previous.summary?.score ?? 0);
87
-
88
- return {
89
- trend: scoreDelta > 0 ? 'improving' : scoreDelta < 0 ? 'regressing' : 'stable',
90
- delta: { score: scoreDelta },
91
- improvements,
92
- regressions,
93
- currentSnapshot: current,
94
- previousSnapshot: previous,
95
- };
96
- }
97
-
98
- // --- Trend Export ---
99
-
100
- function exportAiderTrendReport(dir) {
101
- const history = getAiderHistory(dir, 50);
102
- if (history.length === 0) return null;
103
-
104
- return {
105
- platform: 'aider',
106
- generatedAt: new Date().toISOString(),
107
- nerviqVersion: version,
108
- snapshotCount: history.length,
109
- dataPoints: history.map(entry => ({
110
- date: entry.createdAt,
111
- score: entry.summary?.score ?? null,
112
- passed: entry.summary?.passed ?? null,
113
- checkCount: entry.summary?.checkCount ?? null,
114
- })),
115
- };
116
- }
117
-
118
- // --- Feedback ---
119
-
120
- function recordAiderFeedback(dir, recommendationId, outcome, notes = '') {
121
- return recordRecommendationOutcome(dir, {
122
- platform: 'aider',
123
- recommendationId,
124
- outcome,
125
- notes,
126
- });
127
- }
128
-
129
- function getAiderFeedbackSummary(dir) {
130
- const entries = readOutcomeIndex(dir);
131
- const aiderEntries = entries.filter(e => e.platform === 'aider');
132
- return summarizeOutcomeEntries(aiderEntries);
133
- }
134
-
135
- function formatAiderFeedback(dir) {
136
- const summary = getAiderFeedbackSummary(dir);
137
- if (summary.total === 0) {
138
- return 'No Aider recommendation feedback recorded yet.';
139
- }
140
-
141
- const lines = [
142
- 'Aider Recommendation Feedback:',
143
- '',
144
- ` Total: ${summary.total}`,
145
- ` Accepted: ${summary.accepted}`,
146
- ` Rejected: ${summary.rejected}`,
147
- ` Deferred: ${summary.deferred}`,
148
- ];
149
-
150
- if (summary.acceptanceRate !== null) {
151
- lines.push(` Acceptance rate: ${(summary.acceptanceRate * 100).toFixed(0)}%`);
152
- }
153
-
154
- return lines.join('\n');
155
- }
156
-
157
- // --- Insights ---
158
-
159
- function generateAiderInsights(dir) {
160
- const history = getAiderHistory(dir, 10);
161
- const feedback = getAiderFeedbackSummary(dir);
162
- const insights = [];
163
-
164
- if (history.length >= 3) {
165
- const recent = history.slice(0, 3);
166
- const avgScore = recent.reduce((sum, e) => sum + (e.summary?.score ?? 0), 0) / recent.length;
167
-
168
- if (avgScore < 40) {
169
- insights.push({
170
- severity: 'high',
171
- message: 'Aider setup score consistently low — prioritize .aider.conf.yml and CONVENTIONS.md.',
172
- });
173
- }
174
-
175
- const comparison = compareAiderLatest(dir);
176
- if (comparison && comparison.regressions.length > 2) {
177
- insights.push({
178
- severity: 'medium',
179
- message: `${comparison.regressions.length} checks regressed since last snapshot.`,
180
- });
181
- }
182
- }
183
-
184
- if (feedback.total > 5 && feedback.acceptanceRate !== null && feedback.acceptanceRate < 0.5) {
185
- insights.push({
186
- severity: 'medium',
187
- message: 'Low recommendation acceptance rate — review convention file relevance.',
188
- });
189
- }
190
-
191
- return {
192
- platform: 'aider',
193
- insights,
194
- summary: insights.length === 0
195
- ? 'No actionable Aider insights at this time.'
196
- : `${insights.length} Aider insight(s) found.`,
197
- };
198
- }
199
-
200
- function formatAiderInsights(dir) {
201
- const result = generateAiderInsights(dir);
202
- if (result.insights.length === 0) {
203
- return result.summary;
204
- }
205
-
206
- const lines = ['Aider Insights:', ''];
207
- for (const insight of result.insights) {
208
- const severity = insight.severity.toUpperCase();
209
- lines.push(` [${severity}] ${insight.message}`);
210
- }
211
- lines.push('');
212
- lines.push(result.summary);
213
- return lines.join('\n');
214
- }
215
-
216
- module.exports = {
217
- getAiderHistory,
218
- formatAiderHistory,
219
- compareAiderLatest,
220
- exportAiderTrendReport,
221
- recordAiderFeedback,
222
- getAiderFeedbackSummary,
223
- formatAiderFeedback,
224
- generateAiderInsights,
225
- formatAiderInsights,
226
- };
1
+ /**
2
+ * Aider Repeat-Usage Surfaces — 6 activity surfaces
3
+ *
4
+ * Adapts the shared activity/snapshot backend for Aider platform.
5
+ * Provides: history, compare, trend, watch, feedback, insights.
6
+ *
7
+ * Aider snapshots stored in .nerviq/snapshots/ (legacy: .claude/nerviq-cli/snapshots/) filtered by platform='aider'.
8
+ */
9
+
10
+ const path = require('path');
11
+ const {
12
+ getHistory: getSharedHistory,
13
+ compareLatest: sharedCompareLatest,
14
+ readSnapshotIndex,
15
+ writeSnapshotArtifact,
16
+ exportTrendReport: sharedExportTrendReport,
17
+ recordRecommendationOutcome,
18
+ readOutcomeIndex,
19
+ summarizeOutcomeEntries,
20
+ } = require('../activity');
21
+ const { version } = require('../../package.json');
22
+
23
+ // --- History ---
24
+
25
+ function getAiderHistory(dir, limit = 20) {
26
+ const entries = readSnapshotIndex(dir);
27
+ return entries
28
+ .filter(e => e.snapshotKind === 'audit' && (e.platform === 'aider' || e.summary?.platform === 'aider'))
29
+ .sort((a, b) => new Date(b.createdAt) - new Date(a.createdAt))
30
+ .slice(0, limit);
31
+ }
32
+
33
+ function formatAiderHistory(dir) {
34
+ const history = getAiderHistory(dir, 10);
35
+ if (history.length === 0) {
36
+ return 'No Aider snapshots found. Run `npx nerviq --platform aider --snapshot` to save one.';
37
+ }
38
+
39
+ const lines = ['Aider Score History (most recent first):', ''];
40
+ for (const entry of history) {
41
+ const date = entry.createdAt?.split('T')[0] || 'unknown';
42
+ const score = entry.summary?.score ?? '?';
43
+ const passed = entry.summary?.passed ?? '?';
44
+ const total = entry.summary?.checkCount ?? '?';
45
+ lines.push(` ${date} ${score}/100 (${passed}/${total} passing)`);
46
+ }
47
+
48
+ const comparison = compareAiderLatest(dir);
49
+ if (comparison) {
50
+ lines.push('');
51
+ const sign = comparison.delta.score >= 0 ? '+' : '';
52
+ lines.push(` Trend: ${comparison.trend} (${sign}${comparison.delta.score} since previous)`);
53
+ if (comparison.improvements.length > 0) {
54
+ lines.push(` Fixed: ${comparison.improvements.join(', ')}`);
55
+ }
56
+ if (comparison.regressions.length > 0) {
57
+ lines.push(` New gaps: ${comparison.regressions.join(', ')}`);
58
+ }
59
+ }
60
+
61
+ return lines.join('\n');
62
+ }
63
+
64
+ // --- Compare ---
65
+
66
+ function compareAiderLatest(dir) {
67
+ const audits = getAiderHistory(dir, 2);
68
+ if (audits.length < 2) return null;
69
+
70
+ const current = audits[0];
71
+ const previous = audits[1];
72
+
73
+ const currentPassed = new Set(current.summary?.passedIds || []);
74
+ const previousPassed = new Set(previous.summary?.passedIds || []);
75
+
76
+ const improvements = [];
77
+ const regressions = [];
78
+
79
+ for (const id of currentPassed) {
80
+ if (!previousPassed.has(id)) improvements.push(id);
81
+ }
82
+ for (const id of previousPassed) {
83
+ if (!currentPassed.has(id)) regressions.push(id);
84
+ }
85
+
86
+ const scoreDelta = (current.summary?.score ?? 0) - (previous.summary?.score ?? 0);
87
+
88
+ return {
89
+ trend: scoreDelta > 0 ? 'improving' : scoreDelta < 0 ? 'regressing' : 'stable',
90
+ delta: { score: scoreDelta },
91
+ improvements,
92
+ regressions,
93
+ currentSnapshot: current,
94
+ previousSnapshot: previous,
95
+ };
96
+ }
97
+
98
+ // --- Trend Export ---
99
+
100
+ function exportAiderTrendReport(dir) {
101
+ const history = getAiderHistory(dir, 50);
102
+ if (history.length === 0) return null;
103
+
104
+ return {
105
+ platform: 'aider',
106
+ generatedAt: new Date().toISOString(),
107
+ nerviqVersion: version,
108
+ snapshotCount: history.length,
109
+ dataPoints: history.map(entry => ({
110
+ date: entry.createdAt,
111
+ score: entry.summary?.score ?? null,
112
+ passed: entry.summary?.passed ?? null,
113
+ checkCount: entry.summary?.checkCount ?? null,
114
+ })),
115
+ };
116
+ }
117
+
118
+ // --- Feedback ---
119
+
120
+ function recordAiderFeedback(dir, recommendationId, outcome, notes = '') {
121
+ return recordRecommendationOutcome(dir, {
122
+ platform: 'aider',
123
+ recommendationId,
124
+ outcome,
125
+ notes,
126
+ });
127
+ }
128
+
129
+ function getAiderFeedbackSummary(dir) {
130
+ const entries = readOutcomeIndex(dir);
131
+ const aiderEntries = entries.filter(e => e.platform === 'aider');
132
+ return summarizeOutcomeEntries(aiderEntries);
133
+ }
134
+
135
+ function formatAiderFeedback(dir) {
136
+ const summary = getAiderFeedbackSummary(dir);
137
+ if (summary.total === 0) {
138
+ return 'No Aider recommendation feedback recorded yet.';
139
+ }
140
+
141
+ const lines = [
142
+ 'Aider Recommendation Feedback:',
143
+ '',
144
+ ` Total: ${summary.total}`,
145
+ ` Accepted: ${summary.accepted}`,
146
+ ` Rejected: ${summary.rejected}`,
147
+ ` Deferred: ${summary.deferred}`,
148
+ ];
149
+
150
+ if (summary.acceptanceRate !== null) {
151
+ lines.push(` Acceptance rate: ${(summary.acceptanceRate * 100).toFixed(0)}%`);
152
+ }
153
+
154
+ return lines.join('\n');
155
+ }
156
+
157
+ // --- Insights ---
158
+
159
+ function generateAiderInsights(dir) {
160
+ const history = getAiderHistory(dir, 10);
161
+ const feedback = getAiderFeedbackSummary(dir);
162
+ const insights = [];
163
+
164
+ if (history.length >= 3) {
165
+ const recent = history.slice(0, 3);
166
+ const avgScore = recent.reduce((sum, e) => sum + (e.summary?.score ?? 0), 0) / recent.length;
167
+
168
+ if (avgScore < 40) {
169
+ insights.push({
170
+ severity: 'high',
171
+ message: 'Aider setup score consistently low — prioritize .aider.conf.yml and CONVENTIONS.md.',
172
+ });
173
+ }
174
+
175
+ const comparison = compareAiderLatest(dir);
176
+ if (comparison && comparison.regressions.length > 2) {
177
+ insights.push({
178
+ severity: 'medium',
179
+ message: `${comparison.regressions.length} checks regressed since last snapshot.`,
180
+ });
181
+ }
182
+ }
183
+
184
+ if (feedback.total > 5 && feedback.acceptanceRate !== null && feedback.acceptanceRate < 0.5) {
185
+ insights.push({
186
+ severity: 'medium',
187
+ message: 'Low recommendation acceptance rate — review convention file relevance.',
188
+ });
189
+ }
190
+
191
+ return {
192
+ platform: 'aider',
193
+ insights,
194
+ summary: insights.length === 0
195
+ ? 'No actionable Aider insights at this time.'
196
+ : `${insights.length} Aider insight(s) found.`,
197
+ };
198
+ }
199
+
200
+ function formatAiderInsights(dir) {
201
+ const result = generateAiderInsights(dir);
202
+ if (result.insights.length === 0) {
203
+ return result.summary;
204
+ }
205
+
206
+ const lines = ['Aider Insights:', ''];
207
+ for (const insight of result.insights) {
208
+ const severity = insight.severity.toUpperCase();
209
+ lines.push(` [${severity}] ${insight.message}`);
210
+ }
211
+ lines.push('');
212
+ lines.push(result.summary);
213
+ return lines.join('\n');
214
+ }
215
+
216
+ module.exports = {
217
+ getAiderHistory,
218
+ formatAiderHistory,
219
+ compareAiderLatest,
220
+ exportAiderTrendReport,
221
+ recordAiderFeedback,
222
+ getAiderFeedbackSummary,
223
+ formatAiderFeedback,
224
+ generateAiderInsights,
225
+ formatAiderInsights,
226
+ };