@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
@@ -1,306 +1,306 @@
1
- /**
2
- * Harmony Audit — Cross-Platform DX Audit
3
- *
4
- * Runs AFTER per-platform audits and evaluates how well the project's
5
- * AI coding platforms are aligned with each other.
6
- *
7
- * Produces a harmony score (0-100), per-platform scores, drift analysis,
8
- * and cross-platform recommendations.
9
- */
10
-
11
- const { buildCanonicalModel, detectActivePlatforms } = require('./canon');
12
- const { detectDrift, formatDriftReport } = require('./drift');
13
- const { audit: platformAudit } = require('../audit');
14
-
15
- const COLORS = {
16
- reset: '\x1b[0m',
17
- bold: '\x1b[1m',
18
- dim: '\x1b[2m',
19
- red: '\x1b[31m',
20
- green: '\x1b[32m',
21
- yellow: '\x1b[33m',
22
- blue: '\x1b[36m',
23
- magenta: '\x1b[35m',
24
- };
25
-
26
- function colorize(text, color) {
27
- return `${COLORS[color] || ''}${text}${COLORS.reset}`;
28
- }
29
-
30
- function progressBar(score, max = 100, width = 20) {
31
- const filled = Math.round((score / max) * width);
32
- const empty = width - filled;
33
- const color = score >= 70 ? 'green' : score >= 40 ? 'yellow' : 'red';
34
- return colorize('\u2588'.repeat(filled), color) + colorize('\u2591'.repeat(empty), 'dim');
35
- }
36
-
37
- // ─── Platform key to audit platform name mapping ────────────────────────────
38
-
39
- const PLATFORM_AUDIT_MAP = {
40
- claude: 'claude',
41
- codex: 'codex',
42
- gemini: 'gemini',
43
- copilot: 'copilot',
44
- cursor: 'cursor',
45
- windsurf: 'windsurf',
46
- aider: 'aider',
47
- opencode: 'opencode',
48
- };
49
-
50
- // ─── Cross-platform recommendations ────────────────────────────────────────
51
-
52
- function generateRecommendations(model, drift, platformScores) {
53
- const recommendations = [];
54
- const platforms = model.activePlatforms.map(p => p.platform);
55
-
56
- // 1. If only one platform detected, recommend adding another
57
- if (platforms.length === 1) {
58
- recommendations.push({
59
- priority: 'medium',
60
- category: 'expansion',
61
- message: `Only ${platforms[0]} is configured. Consider adding a second platform for redundancy and team flexibility.`,
62
- });
63
- }
64
-
65
- // 2. If any platform scores below 40, flag it
66
- for (const [platform, score] of Object.entries(platformScores)) {
67
- if (score !== null && score < 40) {
68
- recommendations.push({
69
- priority: 'high',
70
- category: 'quality',
71
- message: `${platform} scores ${score}/100. Run \`nerviq audit --platform ${platform}\` and address critical gaps.`,
72
- });
73
- }
74
- }
75
-
76
- // 3. If trust drift is critical, recommend alignment
77
- const trustDrifts = drift.drifts.filter(d => d.type === 'trust-drift' && d.severity === 'critical');
78
- if (trustDrifts.length > 0) {
79
- recommendations.push({
80
- priority: 'critical',
81
- category: 'security',
82
- message: 'Critical trust posture mismatch. One platform has full autonomy while another is restricted. Align before production use.',
83
- });
84
- }
85
-
86
- // 4. Recommend shared MCP servers
87
- const mcpDrifts = drift.drifts.filter(d => d.type === 'mcp-drift');
88
- if (mcpDrifts.length > 2) {
89
- recommendations.push({
90
- priority: 'medium',
91
- category: 'tooling',
92
- message: `${mcpDrifts.length} MCP alignment issues. Use \`nerviq harmony sync\` to propagate MCP servers across platforms.`,
93
- });
94
- }
95
-
96
- // 5. Coverage gap recommendations
97
- const coverageGaps = drift.drifts.filter(d => d.type === 'coverage-gap' && d.severity === 'high');
98
- for (const gap of coverageGaps) {
99
- recommendations.push({
100
- priority: 'high',
101
- category: 'coverage',
102
- message: gap.description + '. ' + gap.recommendation,
103
- });
104
- }
105
-
106
- // 6. If harmony score is high and all platforms score well, celebrate
107
- if (drift.harmonyScore >= 90 && Object.values(platformScores).every(s => s === null || s >= 70)) {
108
- recommendations.push({
109
- priority: 'low',
110
- category: 'status',
111
- message: 'Excellent cross-platform alignment. All platforms are well-configured and consistent.',
112
- });
113
- }
114
-
115
- // Sort: critical > high > medium > low
116
- const priorityOrder = { critical: 3, high: 2, medium: 1, low: 0 };
117
- recommendations.sort((a, b) => (priorityOrder[b.priority] || 0) - (priorityOrder[a.priority] || 0));
118
-
119
- return recommendations;
120
- }
121
-
122
- // ─── Main audit function ────────────────────────────────────────────────────
123
-
124
- /**
125
- * Run a cross-platform harmony audit.
126
- *
127
- * Builds a canonical model, runs per-platform audits, detects drift,
128
- * and generates cross-platform recommendations.
129
- *
130
- * @param {object} options - { dir: string, silent?: boolean, verbose?: boolean }
131
- * @returns {object} Harmony audit result
132
- */
133
- async function harmonyAudit(options) {
134
- const { dir, silent = false, verbose = false } = options;
135
-
136
- // 1. Build canonical model
137
- const model = buildCanonicalModel(dir);
138
- const platformKeys = model.activePlatforms.map(p => p.platform);
139
-
140
- if (platformKeys.length === 0) {
141
- return {
142
- harmonyScore: 0,
143
- platformScores: {},
144
- drift: { drifts: [], summary: { total: 0, critical: 0, high: 0, medium: 0, low: 0 }, harmonyScore: 0 },
145
- recommendations: [{
146
- priority: 'high',
147
- category: 'coverage',
148
- message: 'No AI coding platforms detected. Run `nerviq init` to set up Claude, or add another platform.',
149
- }],
150
- activePlatforms: [],
151
- model,
152
- };
153
- }
154
-
155
- // 2. Run per-platform audits (silent mode to avoid console noise)
156
- const platformScores = {};
157
- const platformResults = {};
158
- for (const key of platformKeys) {
159
- const auditPlatform = PLATFORM_AUDIT_MAP[key];
160
- if (auditPlatform) {
161
- try {
162
- const result = await platformAudit({ dir, platform: auditPlatform, silent: true });
163
- platformScores[key] = result.score;
164
- platformResults[key] = result;
165
- } catch {
166
- platformScores[key] = null;
167
- platformResults[key] = null;
168
- }
169
- } else {
170
- platformScores[key] = null;
171
- }
172
- }
173
-
174
- // 3. Detect drift
175
- const drift = detectDrift(model);
176
-
177
- // 4. Calculate overall harmony score
178
- // Blend of drift harmony score and average platform scores
179
- const validScores = Object.values(platformScores).filter(s => s !== null);
180
- const avgPlatformScore = validScores.length > 0
181
- ? Math.round(validScores.reduce((a, b) => a + b, 0) / validScores.length)
182
- : 0;
183
-
184
- // Harmony = 60% drift alignment + 40% average platform quality
185
- const harmonyScore = Math.round(drift.harmonyScore * 0.6 + avgPlatformScore * 0.4);
186
-
187
- // 5. Generate recommendations
188
- const recommendations = generateRecommendations(model, drift, platformScores);
189
-
190
- const result = {
191
- harmonyScore,
192
- platformScores,
193
- platformResults,
194
- drift,
195
- recommendations,
196
- activePlatforms: model.activePlatforms,
197
- model,
198
- };
199
-
200
- // 6. Print report if not silent
201
- if (!silent) {
202
- printHarmonyReport(result, { verbose });
203
- }
204
-
205
- return result;
206
- }
207
-
208
- // ─── Report printer ─────────────────────────────────────────────────────────
209
-
210
- function printHarmonyReport(result, options = {}) {
211
- const { verbose = false } = options;
212
- const c = colorize;
213
-
214
- console.log('');
215
- console.log(c(' ══════════════════════════════════════════════════════', 'dim'));
216
- console.log(c(' HARMONY AUDIT — Cross-Platform DX Report', 'bold'));
217
- console.log(c(' ══════════════════════════════════════════════════════', 'dim'));
218
- console.log('');
219
-
220
- // Active platforms
221
- console.log(c(' Active platforms:', 'bold'));
222
- for (const ap of result.activePlatforms) {
223
- const score = result.platformScores[ap.platform];
224
- const scoreStr = score !== null ? `${score}/100` : 'n/a';
225
- const scoreColor = score >= 70 ? 'green' : score >= 40 ? 'yellow' : 'red';
226
- console.log(` ${ap.label}: ${c(scoreStr, score !== null ? scoreColor : 'dim')}`);
227
- }
228
- console.log('');
229
-
230
- // Harmony score
231
- const hs = result.harmonyScore;
232
- const hsColor = hs >= 80 ? 'green' : hs >= 50 ? 'yellow' : 'red';
233
- console.log(` Harmony Score: ${progressBar(hs)} ${c(hs + '/100', hsColor)}`);
234
- console.log('');
235
-
236
- // Drift summary
237
- if (result.drift.drifts.length > 0) {
238
- console.log(formatDriftReport(result.drift, { color: true, verbose }));
239
- } else {
240
- console.log(c(' No cross-platform drift detected.', 'green'));
241
- console.log('');
242
- }
243
-
244
- // Recommendations
245
- if (result.recommendations.length > 0) {
246
- console.log(c(' Recommendations:', 'bold'));
247
- const priorityIcons = { critical: '\u2718', high: '!', medium: '~', low: '\u2713' };
248
- const priorityColors = { critical: 'red', high: 'yellow', medium: 'blue', low: 'green' };
249
-
250
- for (const rec of result.recommendations) {
251
- const icon = priorityIcons[rec.priority] || '-';
252
- const pColor = priorityColors[rec.priority] || 'dim';
253
- console.log(` ${c(icon, pColor)} [${rec.category}] ${rec.message}`);
254
- }
255
- console.log('');
256
- }
257
-
258
- console.log(c(' Powered by NERVIQ cross-platform intelligence', 'dim'));
259
- console.log(c(' https://github.com/nerviq/nerviq', 'dim'));
260
- console.log('');
261
- }
262
-
263
- /**
264
- * Format the harmony audit result as a structured report string (no ANSI colors).
265
- *
266
- * @param {object} result - Output of harmonyAudit()
267
- * @returns {string} Plain-text report
268
- */
269
- function formatHarmonyAuditReport(result) {
270
- const lines = [];
271
-
272
- lines.push('HARMONY AUDIT — Cross-Platform DX Report');
273
- lines.push('========================================');
274
- lines.push('');
275
-
276
- lines.push('Active platforms:');
277
- for (const ap of result.activePlatforms) {
278
- const score = result.platformScores[ap.platform];
279
- lines.push(` ${ap.label}: ${score !== null ? score + '/100' : 'n/a'}`);
280
- }
281
- lines.push('');
282
-
283
- lines.push(`Harmony Score: ${result.harmonyScore}/100`);
284
- lines.push('');
285
-
286
- if (result.drift.drifts.length > 0) {
287
- lines.push(formatDriftReport(result.drift, { color: false, verbose: true }));
288
- } else {
289
- lines.push('No cross-platform drift detected.');
290
- }
291
- lines.push('');
292
-
293
- if (result.recommendations.length > 0) {
294
- lines.push('Recommendations:');
295
- for (const rec of result.recommendations) {
296
- lines.push(` [${rec.priority.toUpperCase()}] [${rec.category}] ${rec.message}`);
297
- }
298
- }
299
-
300
- return lines.join('\n');
301
- }
302
-
303
- module.exports = {
304
- harmonyAudit,
305
- formatHarmonyAuditReport,
306
- };
1
+ /**
2
+ * Harmony Audit — Cross-Platform DX Audit
3
+ *
4
+ * Runs AFTER per-platform audits and evaluates how well the project's
5
+ * AI coding platforms are aligned with each other.
6
+ *
7
+ * Produces a harmony score (0-100), per-platform scores, drift analysis,
8
+ * and cross-platform recommendations.
9
+ */
10
+
11
+ const { buildCanonicalModel, detectActivePlatforms } = require('./canon');
12
+ const { detectDrift, formatDriftReport } = require('./drift');
13
+ const { audit: platformAudit } = require('../audit');
14
+
15
+ const COLORS = {
16
+ reset: '\x1b[0m',
17
+ bold: '\x1b[1m',
18
+ dim: '\x1b[2m',
19
+ red: '\x1b[31m',
20
+ green: '\x1b[32m',
21
+ yellow: '\x1b[33m',
22
+ blue: '\x1b[36m',
23
+ magenta: '\x1b[35m',
24
+ };
25
+
26
+ function colorize(text, color) {
27
+ return `${COLORS[color] || ''}${text}${COLORS.reset}`;
28
+ }
29
+
30
+ function progressBar(score, max = 100, width = 20) {
31
+ const filled = Math.round((score / max) * width);
32
+ const empty = width - filled;
33
+ const color = score >= 70 ? 'green' : score >= 40 ? 'yellow' : 'red';
34
+ return colorize('\u2588'.repeat(filled), color) + colorize('\u2591'.repeat(empty), 'dim');
35
+ }
36
+
37
+ // ─── Platform key to audit platform name mapping ────────────────────────────
38
+
39
+ const PLATFORM_AUDIT_MAP = {
40
+ claude: 'claude',
41
+ codex: 'codex',
42
+ gemini: 'gemini',
43
+ copilot: 'copilot',
44
+ cursor: 'cursor',
45
+ windsurf: 'windsurf',
46
+ aider: 'aider',
47
+ opencode: 'opencode',
48
+ };
49
+
50
+ // ─── Cross-platform recommendations ────────────────────────────────────────
51
+
52
+ function generateRecommendations(model, drift, platformScores) {
53
+ const recommendations = [];
54
+ const platforms = model.activePlatforms.map(p => p.platform);
55
+
56
+ // 1. If only one platform detected, recommend adding another
57
+ if (platforms.length === 1) {
58
+ recommendations.push({
59
+ priority: 'medium',
60
+ category: 'expansion',
61
+ message: `Only ${platforms[0]} is configured. Consider adding a second platform for redundancy and team flexibility.`,
62
+ });
63
+ }
64
+
65
+ // 2. If any platform scores below 40, flag it
66
+ for (const [platform, score] of Object.entries(platformScores)) {
67
+ if (score !== null && score < 40) {
68
+ recommendations.push({
69
+ priority: 'high',
70
+ category: 'quality',
71
+ message: `${platform} scores ${score}/100. Run \`nerviq audit --platform ${platform}\` and address critical gaps.`,
72
+ });
73
+ }
74
+ }
75
+
76
+ // 3. If trust drift is critical, recommend alignment
77
+ const trustDrifts = drift.drifts.filter(d => d.type === 'trust-drift' && d.severity === 'critical');
78
+ if (trustDrifts.length > 0) {
79
+ recommendations.push({
80
+ priority: 'critical',
81
+ category: 'security',
82
+ message: 'Critical trust posture mismatch. One platform has full autonomy while another is restricted. Align before production use.',
83
+ });
84
+ }
85
+
86
+ // 4. Recommend shared MCP servers
87
+ const mcpDrifts = drift.drifts.filter(d => d.type === 'mcp-drift');
88
+ if (mcpDrifts.length > 2) {
89
+ recommendations.push({
90
+ priority: 'medium',
91
+ category: 'tooling',
92
+ message: `${mcpDrifts.length} MCP alignment issues. Use \`nerviq harmony sync\` to propagate MCP servers across platforms.`,
93
+ });
94
+ }
95
+
96
+ // 5. Coverage gap recommendations
97
+ const coverageGaps = drift.drifts.filter(d => d.type === 'coverage-gap' && d.severity === 'high');
98
+ for (const gap of coverageGaps) {
99
+ recommendations.push({
100
+ priority: 'high',
101
+ category: 'coverage',
102
+ message: gap.description + '. ' + gap.recommendation,
103
+ });
104
+ }
105
+
106
+ // 6. If harmony score is high and all platforms score well, celebrate
107
+ if (drift.harmonyScore >= 90 && Object.values(platformScores).every(s => s === null || s >= 70)) {
108
+ recommendations.push({
109
+ priority: 'low',
110
+ category: 'status',
111
+ message: 'Excellent cross-platform alignment. All platforms are well-configured and consistent.',
112
+ });
113
+ }
114
+
115
+ // Sort: critical > high > medium > low
116
+ const priorityOrder = { critical: 3, high: 2, medium: 1, low: 0 };
117
+ recommendations.sort((a, b) => (priorityOrder[b.priority] || 0) - (priorityOrder[a.priority] || 0));
118
+
119
+ return recommendations;
120
+ }
121
+
122
+ // ─── Main audit function ────────────────────────────────────────────────────
123
+
124
+ /**
125
+ * Run a cross-platform harmony audit.
126
+ *
127
+ * Builds a canonical model, runs per-platform audits, detects drift,
128
+ * and generates cross-platform recommendations.
129
+ *
130
+ * @param {object} options - { dir: string, silent?: boolean, verbose?: boolean }
131
+ * @returns {object} Harmony audit result
132
+ */
133
+ async function harmonyAudit(options) {
134
+ const { dir, silent = false, verbose = false } = options;
135
+
136
+ // 1. Build canonical model
137
+ const model = buildCanonicalModel(dir);
138
+ const platformKeys = model.activePlatforms.map(p => p.platform);
139
+
140
+ if (platformKeys.length === 0) {
141
+ return {
142
+ harmonyScore: 0,
143
+ platformScores: {},
144
+ drift: { drifts: [], summary: { total: 0, critical: 0, high: 0, medium: 0, low: 0 }, harmonyScore: 0 },
145
+ recommendations: [{
146
+ priority: 'high',
147
+ category: 'coverage',
148
+ message: 'No AI coding platforms detected. Run `nerviq init` to set up Claude, or add another platform.',
149
+ }],
150
+ activePlatforms: [],
151
+ model,
152
+ };
153
+ }
154
+
155
+ // 2. Run per-platform audits (silent mode to avoid console noise)
156
+ const platformScores = {};
157
+ const platformResults = {};
158
+ for (const key of platformKeys) {
159
+ const auditPlatform = PLATFORM_AUDIT_MAP[key];
160
+ if (auditPlatform) {
161
+ try {
162
+ const result = await platformAudit({ dir, platform: auditPlatform, silent: true });
163
+ platformScores[key] = result.score;
164
+ platformResults[key] = result;
165
+ } catch {
166
+ platformScores[key] = null;
167
+ platformResults[key] = null;
168
+ }
169
+ } else {
170
+ platformScores[key] = null;
171
+ }
172
+ }
173
+
174
+ // 3. Detect drift
175
+ const drift = detectDrift(model);
176
+
177
+ // 4. Calculate overall harmony score
178
+ // Blend of drift harmony score and average platform scores
179
+ const validScores = Object.values(platformScores).filter(s => s !== null);
180
+ const avgPlatformScore = validScores.length > 0
181
+ ? Math.round(validScores.reduce((a, b) => a + b, 0) / validScores.length)
182
+ : 0;
183
+
184
+ // Harmony = 60% drift alignment + 40% average platform quality
185
+ const harmonyScore = Math.round(drift.harmonyScore * 0.6 + avgPlatformScore * 0.4);
186
+
187
+ // 5. Generate recommendations
188
+ const recommendations = generateRecommendations(model, drift, platformScores);
189
+
190
+ const result = {
191
+ harmonyScore,
192
+ platformScores,
193
+ platformResults,
194
+ drift,
195
+ recommendations,
196
+ activePlatforms: model.activePlatforms,
197
+ model,
198
+ };
199
+
200
+ // 6. Print report if not silent
201
+ if (!silent) {
202
+ printHarmonyReport(result, { verbose });
203
+ }
204
+
205
+ return result;
206
+ }
207
+
208
+ // ─── Report printer ─────────────────────────────────────────────────────────
209
+
210
+ function printHarmonyReport(result, options = {}) {
211
+ const { verbose = false } = options;
212
+ const c = colorize;
213
+
214
+ console.log('');
215
+ console.log(c(' ══════════════════════════════════════════════════════', 'dim'));
216
+ console.log(c(' HARMONY AUDIT — Cross-Platform DX Report', 'bold'));
217
+ console.log(c(' ══════════════════════════════════════════════════════', 'dim'));
218
+ console.log('');
219
+
220
+ // Active platforms
221
+ console.log(c(' Active platforms:', 'bold'));
222
+ for (const ap of result.activePlatforms) {
223
+ const score = result.platformScores[ap.platform];
224
+ const scoreStr = score !== null ? `${score}/100` : 'n/a';
225
+ const scoreColor = score >= 70 ? 'green' : score >= 40 ? 'yellow' : 'red';
226
+ console.log(` ${ap.label}: ${c(scoreStr, score !== null ? scoreColor : 'dim')}`);
227
+ }
228
+ console.log('');
229
+
230
+ // Harmony score
231
+ const hs = result.harmonyScore;
232
+ const hsColor = hs >= 80 ? 'green' : hs >= 50 ? 'yellow' : 'red';
233
+ console.log(` Harmony Score: ${progressBar(hs)} ${c(hs + '/100', hsColor)}`);
234
+ console.log('');
235
+
236
+ // Drift summary
237
+ if (result.drift.drifts.length > 0) {
238
+ console.log(formatDriftReport(result.drift, { color: true, verbose }));
239
+ } else {
240
+ console.log(c(' No cross-platform drift detected.', 'green'));
241
+ console.log('');
242
+ }
243
+
244
+ // Recommendations
245
+ if (result.recommendations.length > 0) {
246
+ console.log(c(' Recommendations:', 'bold'));
247
+ const priorityIcons = { critical: '\u2718', high: '!', medium: '~', low: '\u2713' };
248
+ const priorityColors = { critical: 'red', high: 'yellow', medium: 'blue', low: 'green' };
249
+
250
+ for (const rec of result.recommendations) {
251
+ const icon = priorityIcons[rec.priority] || '-';
252
+ const pColor = priorityColors[rec.priority] || 'dim';
253
+ console.log(` ${c(icon, pColor)} [${rec.category}] ${rec.message}`);
254
+ }
255
+ console.log('');
256
+ }
257
+
258
+ console.log(c(' Powered by NERVIQ cross-platform intelligence', 'dim'));
259
+ console.log(c(' https://github.com/nerviq/nerviq', 'dim'));
260
+ console.log('');
261
+ }
262
+
263
+ /**
264
+ * Format the harmony audit result as a structured report string (no ANSI colors).
265
+ *
266
+ * @param {object} result - Output of harmonyAudit()
267
+ * @returns {string} Plain-text report
268
+ */
269
+ function formatHarmonyAuditReport(result) {
270
+ const lines = [];
271
+
272
+ lines.push('HARMONY AUDIT — Cross-Platform DX Report');
273
+ lines.push('========================================');
274
+ lines.push('');
275
+
276
+ lines.push('Active platforms:');
277
+ for (const ap of result.activePlatforms) {
278
+ const score = result.platformScores[ap.platform];
279
+ lines.push(` ${ap.label}: ${score !== null ? score + '/100' : 'n/a'}`);
280
+ }
281
+ lines.push('');
282
+
283
+ lines.push(`Harmony Score: ${result.harmonyScore}/100`);
284
+ lines.push('');
285
+
286
+ if (result.drift.drifts.length > 0) {
287
+ lines.push(formatDriftReport(result.drift, { color: false, verbose: true }));
288
+ } else {
289
+ lines.push('No cross-platform drift detected.');
290
+ }
291
+ lines.push('');
292
+
293
+ if (result.recommendations.length > 0) {
294
+ lines.push('Recommendations:');
295
+ for (const rec of result.recommendations) {
296
+ lines.push(` [${rec.priority.toUpperCase()}] [${rec.category}] ${rec.message}`);
297
+ }
298
+ }
299
+
300
+ return lines.join('\n');
301
+ }
302
+
303
+ module.exports = {
304
+ harmonyAudit,
305
+ formatHarmonyAuditReport,
306
+ };