@nerviq/cli 1.21.0 → 1.22.0

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.
package/README.md CHANGED
@@ -223,8 +223,8 @@ All successful operational responses are wrapped in a JSON envelope:
223
223
  {
224
224
  "data": {},
225
225
  "meta": {
226
- "version": "1.21.0",
227
- "timestamp": "2026-04-14T18:00:00.000Z"
226
+ "version": "1.22.0",
227
+ "timestamp": "2026-04-14T22:00:00.000Z"
228
228
  }
229
229
  }
230
230
  ```
@@ -385,10 +385,28 @@ Levels:
385
385
  | `--auto` | Apply without prompts |
386
386
  | `--only A,B` | Limit apply to selected proposal IDs |
387
387
  | `--format sarif` | SARIF output for code scanning |
388
+ | `--format markdown` | GitHub-flavoured PR-comment report |
389
+ | `--format junit` | JUnit XML for CI test reporters (GitHub Actions, Jenkins, GitLab) |
390
+ | `--format csv` | RFC 4180 CSV, one row per check |
388
391
  | `--platform NAME` | Target platform (claude, codex, gemini, copilot, cursor, windsurf, aider, opencode) |
389
392
  | `--workspace GLOB` | Audit workspaces separately as package-level live audits with summary-only JSON rows (e.g. packages/*) |
390
393
  | `--external PATH` | Benchmark an external repo |
391
394
 
395
+ ### CI output formats
396
+
397
+ Pipe audit output straight into the standard CI surfaces:
398
+
399
+ ```bash
400
+ # PR comment (GitHub-flavoured markdown)
401
+ npx @nerviq/cli audit --format=markdown --out audit.md
402
+
403
+ # CI test report (JUnit XML — Jenkins, GitLab, GitHub Actions reporter)
404
+ npx @nerviq/cli audit --format=junit --out junit.xml
405
+
406
+ # Spreadsheet / dashboard ingestion (RFC 4180 CSV)
407
+ npx @nerviq/cli audit --format=csv --out audit.csv
408
+ ```
409
+
392
410
  Webhook delivery automatically retries transient failures twice by default. For authenticated internal endpoints, you can add custom headers such as:
393
411
 
394
412
  ```bash
package/bin/cli.js CHANGED
@@ -694,7 +694,7 @@ const HELP = `
694
694
  --team-profile N Load a saved team profile for audit (overrides threshold/platform)
695
695
  --mcp-pack A,B Merge MCP packs into setup (live tool connectors; e.g. context7-docs,next-devtools)
696
696
  --check-version V Pin catalog to a specific version (warn on mismatch)
697
- --format NAME Output format: json | sarif | otel
697
+ --format NAME Output format: json | sarif | otel | markdown | junit | csv
698
698
  --webhook URL Send audit results to a webhook (Slack/Discord/generic JSON)
699
699
  --webhook-header H Add a custom webhook header (repeat; format: Name: Value)
700
700
  --webhook-retries N Retry transient webhook failures N times (default: 2)
@@ -956,8 +956,8 @@ async function main() {
956
956
  process.exit(1);
957
957
  }
958
958
 
959
- if (options.format !== null && !['json', 'sarif', 'otel'].includes(options.format)) {
960
- console.error(`\n Error: Unsupported format '${options.format}'. Use 'json', 'sarif', or 'otel'.\n`);
959
+ if (options.format !== null && !['json', 'sarif', 'otel', 'markdown', 'junit', 'csv'].includes(options.format)) {
960
+ console.error(`\n Error: Unsupported format '${options.format}'. Use 'json', 'sarif', 'otel', 'markdown', 'junit', or 'csv'.\n`);
961
961
  process.exit(1);
962
962
  }
963
963
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nerviq/cli",
3
- "version": "1.21.0",
3
+ "version": "1.22.0",
4
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
5
  "main": "src/index.js",
6
6
  "bin": {
package/src/audit.js CHANGED
@@ -28,6 +28,9 @@ const { getRecommendationOutcomeSummary } = require('./activity');
28
28
  const { getFeedbackSummary } = require('./feedback');
29
29
  const { formatSarif } = require('./formatters/sarif');
30
30
  const { formatOtelMetrics } = require('./formatters/otel');
31
+ const { formatMarkdown } = require('./formatters/markdown');
32
+ const { formatJUnit } = require('./formatters/junit');
33
+ const { formatCsv } = require('./formatters/csv');
31
34
  const { collectAuditTerminology, formatTerminologyLines } = require('./terminology');
32
35
  const { loadPlugins, mergePluginChecks } = require('./plugins');
33
36
  const { detectDeprecationWarnings } = require('./deprecation');
@@ -645,6 +648,23 @@ async function audit(options) {
645
648
  return result;
646
649
  }
647
650
 
651
+ if (options.format === 'markdown') {
652
+ const enriched = { version: packageVersion, timestamp: new Date().toISOString(), ...result };
653
+ console.log(formatMarkdown(enriched, { dir: options.dir }));
654
+ return result;
655
+ }
656
+
657
+ if (options.format === 'junit') {
658
+ const enriched = { version: packageVersion, timestamp: new Date().toISOString(), ...result };
659
+ console.log(formatJUnit(enriched));
660
+ return result;
661
+ }
662
+
663
+ if (options.format === 'csv') {
664
+ console.log(formatCsv(result));
665
+ return result;
666
+ }
667
+
648
668
  if (options.lite) {
649
669
  printLiteAudit(result, options.dir);
650
670
  sendInsights(result);
@@ -0,0 +1,69 @@
1
+ /**
2
+ * CSV Formatter (RFC 4180)
3
+ *
4
+ * One row per check in a nerviq audit result.
5
+ * Columns: key,id,name,category,rating,severity,passed,file,line,sourceUrl,fix
6
+ *
7
+ * Quoting rules (RFC 4180):
8
+ * - Fields containing comma, double-quote, CR, or LF are wrapped in
9
+ * double-quotes.
10
+ * - Internal double-quotes are escaped by doubling them.
11
+ * - Header row is emitted first.
12
+ * - No UTF-8 BOM (some consumers mishandle it).
13
+ * - Line separator: LF (consumers accept LF; JUnit/XLSX/csv parsers
14
+ * normalize both).
15
+ */
16
+
17
+ 'use strict';
18
+
19
+ const COLUMNS = [
20
+ 'key',
21
+ 'id',
22
+ 'name',
23
+ 'category',
24
+ 'rating',
25
+ 'severity',
26
+ 'passed',
27
+ 'file',
28
+ 'line',
29
+ 'sourceUrl',
30
+ 'fix',
31
+ ];
32
+
33
+ function csvEscape(value) {
34
+ if (value === null || value === undefined) return '';
35
+ const s = String(value);
36
+ if (/[",\r\n]/.test(s)) {
37
+ return `"${s.replace(/"/g, '""')}"`;
38
+ }
39
+ return s;
40
+ }
41
+
42
+ function rowFor(r) {
43
+ const severity = r.severity || r.impact || '';
44
+ const cells = [
45
+ r.key ?? '',
46
+ r.id ?? '',
47
+ r.name ?? '',
48
+ r.category ?? '',
49
+ r.rating ?? '',
50
+ severity,
51
+ r.passed === null || r.passed === undefined ? '' : String(r.passed),
52
+ r.file ?? '',
53
+ r.line ?? '',
54
+ r.sourceUrl ?? '',
55
+ r.fix ?? '',
56
+ ];
57
+ return cells.map(csvEscape).join(',');
58
+ }
59
+
60
+ function formatCsv(auditResult) {
61
+ const results = Array.isArray(auditResult.results) ? auditResult.results : [];
62
+ const lines = [COLUMNS.join(',')];
63
+ for (const r of results) {
64
+ lines.push(rowFor(r));
65
+ }
66
+ return lines.join('\n');
67
+ }
68
+
69
+ module.exports = { formatCsv, CSV_COLUMNS: COLUMNS };
@@ -0,0 +1,99 @@
1
+ /**
2
+ * JUnit XML Formatter
3
+ *
4
+ * Converts a nerviq audit result into Jenkins-compatible JUnit XML.
5
+ * Schema: <testsuites><testsuite><testcase><failure/></testcase></testsuite></testsuites>
6
+ *
7
+ * - One <testsuite> per check category.
8
+ * - Each check becomes a <testcase> (classname = category, name = key).
9
+ * - Failed checks emit a <failure message="..." type="..."/> where:
10
+ * - message = check.fix || check.name
11
+ * - type = severity (check.severity || check.impact)
12
+ * - Skipped checks emit <skipped/>.
13
+ *
14
+ * Parses with any standard JUnit XML consumer (GitHub Actions test
15
+ * reporter, Jenkins, GitLab CI, CircleCI).
16
+ */
17
+
18
+ 'use strict';
19
+
20
+ const { version: nerviqVersion } = require('../../package.json');
21
+
22
+ function escapeXml(value) {
23
+ if (value === null || value === undefined) return '';
24
+ return String(value)
25
+ .replace(/&/g, '&amp;')
26
+ .replace(/</g, '&lt;')
27
+ .replace(/>/g, '&gt;')
28
+ .replace(/"/g, '&quot;')
29
+ .replace(/'/g, '&apos;');
30
+ }
31
+
32
+ function severityFor(r) {
33
+ return r.severity || r.impact || 'medium';
34
+ }
35
+
36
+ function groupByCategory(results) {
37
+ const map = new Map();
38
+ for (const r of results) {
39
+ const cat = r.category || 'uncategorized';
40
+ if (!map.has(cat)) map.set(cat, []);
41
+ map.get(cat).push(r);
42
+ }
43
+ return map;
44
+ }
45
+
46
+ function formatJUnit(auditResult) {
47
+ const allResults = Array.isArray(auditResult.results) ? auditResult.results : [];
48
+ const timestamp = auditResult.timestamp || new Date().toISOString();
49
+ const platform = auditResult.platform || 'claude';
50
+
51
+ const totalTests = allResults.length;
52
+ const totalFailures = allResults.filter((r) => r.passed === false).length;
53
+ const totalSkipped = allResults.filter((r) => r.passed === null || r.skipped === true).length;
54
+
55
+ const byCategory = groupByCategory(allResults);
56
+
57
+ const lines = [];
58
+ lines.push('<?xml version="1.0" encoding="UTF-8"?>');
59
+ lines.push(
60
+ `<testsuites name="nerviq" tests="${totalTests}" failures="${totalFailures}" skipped="${totalSkipped}" time="0">`,
61
+ );
62
+
63
+ for (const [category, checks] of byCategory) {
64
+ const suiteFailures = checks.filter((r) => r.passed === false).length;
65
+ const suiteSkipped = checks.filter((r) => r.passed === null || r.skipped === true).length;
66
+ lines.push(
67
+ ` <testsuite name="${escapeXml(category)}" tests="${checks.length}" failures="${suiteFailures}" skipped="${suiteSkipped}" time="0" timestamp="${escapeXml(timestamp)}" package="nerviq.${escapeXml(platform)}">`,
68
+ );
69
+
70
+ for (const r of checks) {
71
+ const classname = escapeXml(r.category || 'uncategorized');
72
+ const name = escapeXml(r.key || r.id || r.name || 'unknown');
73
+ if (r.passed === false) {
74
+ const msg = escapeXml(r.fix || r.name || r.key || 'check failed');
75
+ const type = escapeXml(severityFor(r));
76
+ let body = `${r.name || ''}`;
77
+ if (r.file) body += ` at ${r.file}${r.line ? ':' + r.line : ''}`;
78
+ if (r.sourceUrl) body += ` (${r.sourceUrl})`;
79
+ lines.push(` <testcase classname="${classname}" name="${name}" time="0">`);
80
+ lines.push(` <failure message="${msg}" type="${type}">${escapeXml(body)}</failure>`);
81
+ lines.push(` </testcase>`);
82
+ } else if (r.passed === null || r.skipped === true) {
83
+ lines.push(` <testcase classname="${classname}" name="${name}" time="0">`);
84
+ lines.push(` <skipped/>`);
85
+ lines.push(` </testcase>`);
86
+ } else {
87
+ lines.push(` <testcase classname="${classname}" name="${name}" time="0"/>`);
88
+ }
89
+ }
90
+
91
+ lines.push(' </testsuite>');
92
+ }
93
+
94
+ lines.push('</testsuites>');
95
+ lines.push(`<!-- nerviq v${escapeXml(auditResult.version || nerviqVersion)} -->`);
96
+ return lines.join('\n');
97
+ }
98
+
99
+ module.exports = { formatJUnit };
@@ -0,0 +1,118 @@
1
+ /**
2
+ * Markdown Formatter
3
+ *
4
+ * Converts a nerviq audit result into GitHub-flavoured markdown suitable
5
+ * for posting as a PR comment. Structure:
6
+ *
7
+ * - Header with score badge and pass/fail/skip counts
8
+ * - Top 5 topNextActions as a GitHub task-list checklist
9
+ * - Collapsible <details> block with the full failed-checks table
10
+ * - Footer with Nerviq link, version, timestamp
11
+ *
12
+ * Output is plain GitHub-flavoured markdown. The only HTML used is
13
+ * <details>/<summary>, which GitHub renders natively.
14
+ */
15
+
16
+ 'use strict';
17
+
18
+ const { version: nerviqVersion } = require('../../package.json');
19
+
20
+ function escapeCell(value) {
21
+ if (value === null || value === undefined) return '';
22
+ return String(value)
23
+ .replace(/\r?\n/g, ' ')
24
+ .replace(/\|/g, '\\|');
25
+ }
26
+
27
+ function escapeInline(value) {
28
+ if (value === null || value === undefined) return '';
29
+ return String(value).replace(/\r?\n/g, ' ');
30
+ }
31
+
32
+ function scoreBadge(score) {
33
+ const s = Number.isFinite(score) ? Math.round(score) : 0;
34
+ let color;
35
+ if (s >= 80) color = 'brightgreen';
36
+ else if (s >= 60) color = 'yellow';
37
+ else color = 'red';
38
+ return `![score](https://img.shields.io/badge/nerviq_score-${s}%2F100-${color})`;
39
+ }
40
+
41
+ function severityFor(item) {
42
+ return item.severity || item.impact || 'medium';
43
+ }
44
+
45
+ function formatMarkdown(auditResult, options = {}) {
46
+ const platformLabel = auditResult.platformLabel || auditResult.platform || 'claude';
47
+ const score = auditResult.score ?? 0;
48
+ const passed = auditResult.passed ?? 0;
49
+ const failed = auditResult.failed ?? 0;
50
+ const skipped = auditResult.skipped ?? 0;
51
+ const version = auditResult.version || nerviqVersion;
52
+ const timestamp = auditResult.timestamp || new Date().toISOString();
53
+
54
+ const lines = [];
55
+
56
+ lines.push(`## Score: ${score}/100 ${scoreBadge(score)}`);
57
+ lines.push('');
58
+ lines.push(`**Platform:** ${platformLabel} `);
59
+ lines.push(`**Checks:** ${passed} passed, ${failed} failed, ${skipped} skipped`);
60
+ lines.push('');
61
+
62
+ const top = Array.isArray(auditResult.topNextActions)
63
+ ? auditResult.topNextActions.slice(0, 5)
64
+ : [];
65
+
66
+ if (top.length > 0) {
67
+ lines.push('### Top next actions');
68
+ lines.push('');
69
+ for (const item of top) {
70
+ const sev = severityFor(item).toString().toUpperCase();
71
+ const title = escapeInline(item.name || item.title || item.key);
72
+ const key = escapeInline(item.key || item.id || '');
73
+ let loc = '';
74
+ if (item.file) {
75
+ loc = ` — \`${escapeInline(item.file)}${item.line ? ':' + item.line : ''}\``;
76
+ }
77
+ lines.push(`- [ ] **[${sev}] ${title}** (\`${key}\`)${loc}`);
78
+ const hint = item.fix || item.hint || '';
79
+ if (hint) {
80
+ lines.push(` - ${escapeInline(hint)}`);
81
+ }
82
+ }
83
+ lines.push('');
84
+ }
85
+
86
+ const failedResults = Array.isArray(auditResult.results)
87
+ ? auditResult.results.filter((r) => r.passed === false)
88
+ : [];
89
+
90
+ if (failedResults.length > 0) {
91
+ lines.push('<details>');
92
+ lines.push(`<summary>All failed checks (${failedResults.length})</summary>`);
93
+ lines.push('');
94
+ lines.push('| key | name | category | rating | file | line |');
95
+ lines.push('| --- | --- | --- | --- | --- | --- |');
96
+ for (const r of failedResults) {
97
+ const row = [
98
+ escapeCell(r.key),
99
+ escapeCell(r.name),
100
+ escapeCell(r.category),
101
+ escapeCell(r.rating ?? ''),
102
+ escapeCell(r.file || ''),
103
+ escapeCell(r.line || ''),
104
+ ];
105
+ lines.push(`| ${row.join(' | ')} |`);
106
+ }
107
+ lines.push('');
108
+ lines.push('</details>');
109
+ lines.push('');
110
+ }
111
+
112
+ lines.push(`---`);
113
+ lines.push(`Generated by [Nerviq](https://nerviq.net) v${version} · ${timestamp}`);
114
+
115
+ return lines.join('\n');
116
+ }
117
+
118
+ module.exports = { formatMarkdown };