@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,86 +1,86 @@
1
- /**
2
- * CSV Formatter (RFC 4180)
3
- *
4
- * One row per check in a nerviq audit result.
5
- * Columns: key,id,name,category,layer,rating,severity,passed,file,line,sourceUrl,fix
6
- *
7
- * The `layer` column (added in CTO-08) is one of 'governance',
8
- * 'drift', 'hygiene', or 'shallow-risk' — see docs/integration-contracts.md §8.
9
- *
10
- * Quoting rules (RFC 4180):
11
- * - Fields containing comma, double-quote, CR, or LF are wrapped in
12
- * double-quotes.
13
- * - Internal double-quotes are escaped by doubling them.
14
- * - Header row is emitted first.
15
- * - No UTF-8 BOM (some consumers mishandle it).
16
- * - Line separator: LF (consumers accept LF; JUnit/XLSX/csv parsers
17
- * normalize both).
18
- */
19
-
20
- 'use strict';
21
-
22
- const COLUMNS = [
23
- 'key',
24
- 'id',
25
- 'name',
26
- 'category',
27
- 'layer',
28
- 'rating',
29
- 'severity',
30
- 'passed',
31
- 'file',
32
- 'line',
33
- 'sourceUrl',
34
- 'fix',
35
- 'projectedScoreDelta',
36
- 'projectedScoreAfter',
37
- ];
38
-
39
- function csvEscape(value) {
40
- if (value === null || value === undefined) return '';
41
- const s = String(value);
42
- if (/[",\r\n]/.test(s)) {
43
- return `"${s.replace(/"/g, '""')}"`;
44
- }
45
- return s;
46
- }
47
-
48
- function rowFor(r, projections = null) {
49
- const severity = r.severity || r.impact || '';
50
- const proj = r.layer === 'shallow-risk' ? null : (projections && projections.get(r.key));
51
- const cells = [
52
- r.key ?? '',
53
- r.id ?? '',
54
- r.name ?? '',
55
- r.category ?? '',
56
- r.layer ?? '',
57
- r.rating ?? '',
58
- severity,
59
- r.passed === null || r.passed === undefined ? '' : String(r.passed),
60
- r.file ?? '',
61
- r.line ?? '',
62
- r.sourceUrl ?? '',
63
- r.fix ?? '',
64
- proj && Number.isFinite(proj.projectedScoreDelta) ? String(proj.projectedScoreDelta) : '',
65
- proj && Number.isFinite(proj.projectedScoreAfter) ? String(proj.projectedScoreAfter) : '',
66
- ];
67
- return cells.map(csvEscape).join(',');
68
- }
69
-
70
- function formatCsv(auditResult) {
71
- const results = Array.isArray(auditResult.results) ? auditResult.results : [];
72
- const shallowRiskHints = Array.isArray(auditResult.shallowRiskHints) ? auditResult.shallowRiskHints : [];
73
- const projections = new Map();
74
- if (Array.isArray(auditResult.topNextActions)) {
75
- for (const item of auditResult.topNextActions) {
76
- if (item && item.key) projections.set(item.key, item);
77
- }
78
- }
79
- const lines = [COLUMNS.join(',')];
80
- for (const r of [...results, ...shallowRiskHints]) {
81
- lines.push(rowFor(r, projections));
82
- }
83
- return lines.join('\n');
84
- }
85
-
86
- module.exports = { formatCsv, CSV_COLUMNS: COLUMNS };
1
+ /**
2
+ * CSV Formatter (RFC 4180)
3
+ *
4
+ * One row per check in a nerviq audit result.
5
+ * Columns: key,id,name,category,layer,rating,severity,passed,file,line,sourceUrl,fix
6
+ *
7
+ * The `layer` column (added in CTO-08) is one of 'governance',
8
+ * 'drift', 'hygiene', or 'shallow-risk' — see docs/integration-contracts.md §8.
9
+ *
10
+ * Quoting rules (RFC 4180):
11
+ * - Fields containing comma, double-quote, CR, or LF are wrapped in
12
+ * double-quotes.
13
+ * - Internal double-quotes are escaped by doubling them.
14
+ * - Header row is emitted first.
15
+ * - No UTF-8 BOM (some consumers mishandle it).
16
+ * - Line separator: LF (consumers accept LF; JUnit/XLSX/csv parsers
17
+ * normalize both).
18
+ */
19
+
20
+ 'use strict';
21
+
22
+ const COLUMNS = [
23
+ 'key',
24
+ 'id',
25
+ 'name',
26
+ 'category',
27
+ 'layer',
28
+ 'rating',
29
+ 'severity',
30
+ 'passed',
31
+ 'file',
32
+ 'line',
33
+ 'sourceUrl',
34
+ 'fix',
35
+ 'projectedScoreDelta',
36
+ 'projectedScoreAfter',
37
+ ];
38
+
39
+ function csvEscape(value) {
40
+ if (value === null || value === undefined) return '';
41
+ const s = String(value);
42
+ if (/[",\r\n]/.test(s)) {
43
+ return `"${s.replace(/"/g, '""')}"`;
44
+ }
45
+ return s;
46
+ }
47
+
48
+ function rowFor(r, projections = null) {
49
+ const severity = r.severity || r.impact || '';
50
+ const proj = r.layer === 'shallow-risk' ? null : (projections && projections.get(r.key));
51
+ const cells = [
52
+ r.key ?? '',
53
+ r.id ?? '',
54
+ r.name ?? '',
55
+ r.category ?? '',
56
+ r.layer ?? '',
57
+ r.rating ?? '',
58
+ severity,
59
+ r.passed === null || r.passed === undefined ? '' : String(r.passed),
60
+ r.file ?? '',
61
+ r.line ?? '',
62
+ r.sourceUrl ?? '',
63
+ r.fix ?? '',
64
+ proj && Number.isFinite(proj.projectedScoreDelta) ? String(proj.projectedScoreDelta) : '',
65
+ proj && Number.isFinite(proj.projectedScoreAfter) ? String(proj.projectedScoreAfter) : '',
66
+ ];
67
+ return cells.map(csvEscape).join(',');
68
+ }
69
+
70
+ function formatCsv(auditResult) {
71
+ const results = Array.isArray(auditResult.results) ? auditResult.results : [];
72
+ const shallowRiskHints = Array.isArray(auditResult.shallowRiskHints) ? auditResult.shallowRiskHints : [];
73
+ const projections = new Map();
74
+ if (Array.isArray(auditResult.topNextActions)) {
75
+ for (const item of auditResult.topNextActions) {
76
+ if (item && item.key) projections.set(item.key, item);
77
+ }
78
+ }
79
+ const lines = [COLUMNS.join(',')];
80
+ for (const r of [...results, ...shallowRiskHints]) {
81
+ lines.push(rowFor(r, projections));
82
+ }
83
+ return lines.join('\n');
84
+ }
85
+
86
+ module.exports = { formatCsv, CSV_COLUMNS: COLUMNS };
@@ -1,123 +1,123 @@
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 shallowRiskHints = Array.isArray(auditResult.shallowRiskHints) ? auditResult.shallowRiskHints : [];
49
- const timestamp = auditResult.timestamp || new Date().toISOString();
50
- const platform = auditResult.platform || 'claude';
51
-
52
- const totalTests = allResults.length + shallowRiskHints.length;
53
- const totalFailures = allResults.filter((r) => r.passed === false).length + shallowRiskHints.length;
54
- const totalSkipped = allResults.filter((r) => r.passed === null || r.skipped === true).length;
55
-
56
- const byCategory = groupByCategory(allResults);
57
-
58
- const lines = [];
59
- lines.push('<?xml version="1.0" encoding="UTF-8"?>');
60
- lines.push(
61
- `<testsuites name="nerviq" tests="${totalTests}" failures="${totalFailures}" skipped="${totalSkipped}" time="0">`,
62
- );
63
-
64
- for (const [category, checks] of byCategory) {
65
- const suiteFailures = checks.filter((r) => r.passed === false).length;
66
- const suiteSkipped = checks.filter((r) => r.passed === null || r.skipped === true).length;
67
- lines.push(
68
- ` <testsuite name="${escapeXml(category)}" tests="${checks.length}" failures="${suiteFailures}" skipped="${suiteSkipped}" time="0" timestamp="${escapeXml(timestamp)}" package="nerviq.${escapeXml(platform)}">`,
69
- );
70
-
71
- for (const r of checks) {
72
- const classname = escapeXml(r.category || 'uncategorized');
73
- const name = escapeXml(r.key || r.id || r.name || 'unknown');
74
- // CTO-08: surface scope layer as a testcase attribute so JUnit
75
- // consumers (GitHub Actions, Jenkins, GitLab) can filter/group.
76
- const layerAttr = r.layer ? ` layer="${escapeXml(r.layer)}"` : '';
77
- if (r.passed === false) {
78
- const msg = escapeXml(r.fix || r.name || r.key || 'check failed');
79
- const type = escapeXml(severityFor(r));
80
- let body = `${r.name || ''}`;
81
- if (r.file) body += ` at ${r.file}${r.line ? ':' + r.line : ''}`;
82
- if (r.sourceUrl) body += ` (${r.sourceUrl})`;
83
- if (r.snippet) body += `\n---\n${r.snippet}`;
84
- lines.push(` <testcase classname="${classname}" name="${name}"${layerAttr} time="0">`);
85
- lines.push(` <failure message="${msg}" type="${type}">${escapeXml(body)}</failure>`);
86
- lines.push(` </testcase>`);
87
- } else if (r.passed === null || r.skipped === true) {
88
- lines.push(` <testcase classname="${classname}" name="${name}"${layerAttr} time="0">`);
89
- lines.push(` <skipped/>`);
90
- lines.push(` </testcase>`);
91
- } else {
92
- lines.push(` <testcase classname="${classname}" name="${name}"${layerAttr} time="0"/>`);
93
- }
94
- }
95
-
96
- lines.push(' </testsuite>');
97
- }
98
-
99
- if (Array.isArray(auditResult.shallowRiskHints)) {
100
- lines.push(
101
- ` <testsuite name="shallow-risk" tests="${shallowRiskHints.length}" failures="${shallowRiskHints.length}" skipped="0" time="0" timestamp="${escapeXml(timestamp)}" package="nerviq.${escapeXml(platform)}.shallow-risk">`,
102
- );
103
- for (const hint of shallowRiskHints) {
104
- const name = escapeXml(hint.key || hint.name || 'shallow-risk');
105
- const msg = escapeXml(hint.fix || hint.name || hint.key || 'shallow risk hint');
106
- const type = escapeXml(severityFor(hint));
107
- let body = `${hint.name || hint.key || ''}`;
108
- if (hint.file) body += ` at ${hint.file}${hint.line ? ':' + hint.line : ''}`;
109
- if (hint.sourceUrl) body += ` (${hint.sourceUrl})`;
110
- if (hint.snippet) body += `\n---\n${hint.snippet}`;
111
- lines.push(` <testcase classname="shallow-risk" name="${name}" layer="shallow-risk" time="0">`);
112
- lines.push(` <failure message="${msg}" type="${type}">${escapeXml(body)}</failure>`);
113
- lines.push(' </testcase>');
114
- }
115
- lines.push(' </testsuite>');
116
- }
117
-
118
- lines.push('</testsuites>');
119
- lines.push(`<!-- nerviq v${escapeXml(auditResult.version || nerviqVersion)} -->`);
120
- return lines.join('\n');
121
- }
122
-
123
- module.exports = { formatJUnit };
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 shallowRiskHints = Array.isArray(auditResult.shallowRiskHints) ? auditResult.shallowRiskHints : [];
49
+ const timestamp = auditResult.timestamp || new Date().toISOString();
50
+ const platform = auditResult.platform || 'claude';
51
+
52
+ const totalTests = allResults.length + shallowRiskHints.length;
53
+ const totalFailures = allResults.filter((r) => r.passed === false).length + shallowRiskHints.length;
54
+ const totalSkipped = allResults.filter((r) => r.passed === null || r.skipped === true).length;
55
+
56
+ const byCategory = groupByCategory(allResults);
57
+
58
+ const lines = [];
59
+ lines.push('<?xml version="1.0" encoding="UTF-8"?>');
60
+ lines.push(
61
+ `<testsuites name="nerviq" tests="${totalTests}" failures="${totalFailures}" skipped="${totalSkipped}" time="0">`,
62
+ );
63
+
64
+ for (const [category, checks] of byCategory) {
65
+ const suiteFailures = checks.filter((r) => r.passed === false).length;
66
+ const suiteSkipped = checks.filter((r) => r.passed === null || r.skipped === true).length;
67
+ lines.push(
68
+ ` <testsuite name="${escapeXml(category)}" tests="${checks.length}" failures="${suiteFailures}" skipped="${suiteSkipped}" time="0" timestamp="${escapeXml(timestamp)}" package="nerviq.${escapeXml(platform)}">`,
69
+ );
70
+
71
+ for (const r of checks) {
72
+ const classname = escapeXml(r.category || 'uncategorized');
73
+ const name = escapeXml(r.key || r.id || r.name || 'unknown');
74
+ // CTO-08: surface scope layer as a testcase attribute so JUnit
75
+ // consumers (GitHub Actions, Jenkins, GitLab) can filter/group.
76
+ const layerAttr = r.layer ? ` layer="${escapeXml(r.layer)}"` : '';
77
+ if (r.passed === false) {
78
+ const msg = escapeXml(r.fix || r.name || r.key || 'check failed');
79
+ const type = escapeXml(severityFor(r));
80
+ let body = `${r.name || ''}`;
81
+ if (r.file) body += ` at ${r.file}${r.line ? ':' + r.line : ''}`;
82
+ if (r.sourceUrl) body += ` (${r.sourceUrl})`;
83
+ if (r.snippet) body += `\n---\n${r.snippet}`;
84
+ lines.push(` <testcase classname="${classname}" name="${name}"${layerAttr} time="0">`);
85
+ lines.push(` <failure message="${msg}" type="${type}">${escapeXml(body)}</failure>`);
86
+ lines.push(` </testcase>`);
87
+ } else if (r.passed === null || r.skipped === true) {
88
+ lines.push(` <testcase classname="${classname}" name="${name}"${layerAttr} time="0">`);
89
+ lines.push(` <skipped/>`);
90
+ lines.push(` </testcase>`);
91
+ } else {
92
+ lines.push(` <testcase classname="${classname}" name="${name}"${layerAttr} time="0"/>`);
93
+ }
94
+ }
95
+
96
+ lines.push(' </testsuite>');
97
+ }
98
+
99
+ if (Array.isArray(auditResult.shallowRiskHints)) {
100
+ lines.push(
101
+ ` <testsuite name="shallow-risk" tests="${shallowRiskHints.length}" failures="${shallowRiskHints.length}" skipped="0" time="0" timestamp="${escapeXml(timestamp)}" package="nerviq.${escapeXml(platform)}.shallow-risk">`,
102
+ );
103
+ for (const hint of shallowRiskHints) {
104
+ const name = escapeXml(hint.key || hint.name || 'shallow-risk');
105
+ const msg = escapeXml(hint.fix || hint.name || hint.key || 'shallow risk hint');
106
+ const type = escapeXml(severityFor(hint));
107
+ let body = `${hint.name || hint.key || ''}`;
108
+ if (hint.file) body += ` at ${hint.file}${hint.line ? ':' + hint.line : ''}`;
109
+ if (hint.sourceUrl) body += ` (${hint.sourceUrl})`;
110
+ if (hint.snippet) body += `\n---\n${hint.snippet}`;
111
+ lines.push(` <testcase classname="shallow-risk" name="${name}" layer="shallow-risk" time="0">`);
112
+ lines.push(` <failure message="${msg}" type="${type}">${escapeXml(body)}</failure>`);
113
+ lines.push(' </testcase>');
114
+ }
115
+ lines.push(' </testsuite>');
116
+ }
117
+
118
+ lines.push('</testsuites>');
119
+ lines.push(`<!-- nerviq v${escapeXml(auditResult.version || nerviqVersion)} -->`);
120
+ return lines.join('\n');
121
+ }
122
+
123
+ module.exports = { formatJUnit };