@nerviq/cli 1.26.0 → 1.27.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
@@ -77,9 +77,9 @@ Every Nerviq check is tagged with one of four explicit layers so you know exactl
77
77
  - **governance** — agent configuration posture: presence, content, and quality of agent-instruction files and platform settings.
78
78
  - **drift** — cross-platform consistency: do your configured platforms agree, and does declared state match repo reality?
79
79
  - **hygiene** — repo-level cleanliness adjacent to agents (gitignore, CHANGELOG, SECURITY.md, LICENSE, Node version pinning, etc.).
80
- - **shallow-risk** — reserved for obvious agent-config ↔ codebase boundary issues (CTO-06, not yet populated).
80
+ - **shallow-risk** — obvious agent-config ↔ codebase boundary issues emitted through the experimental `--shallow-risk` lane.
81
81
 
82
- There is deliberately no "deep-review" or general-security-scanning layer — Nerviq is an agent-configuration audit tool, not a code-review tool. The full taxonomy and disambiguation rules live in `docs/integration-contracts.md §8`, and the `layer` field is surfaced in every output format (JSON, CSV, JUnit, Markdown, text).
82
+ There is deliberately no "deep-review" or general-security-scanning layer — Nerviq is an agent-configuration audit tool, not a code-review tool. The experimental `nerviq audit --shallow-risk` pass now adds an opt-in, non-scoring boundary scan on top of the four-layer model. The full taxonomy and disambiguation rules live in `docs/integration-contracts.md §8`, and the `layer` field is surfaced in every output format (JSON, CSV, JUnit, Markdown, text).
83
83
 
84
84
  ## Quick Start
85
85
 
@@ -234,8 +234,8 @@ All successful operational responses are wrapped in a JSON envelope:
234
234
  {
235
235
  "data": {},
236
236
  "meta": {
237
- "version": "1.26.0",
238
- "timestamp": "2026-04-15T14:00:00.000Z"
237
+ "version": "1.27.0",
238
+ "timestamp": "2026-04-15T18:00:00.000Z"
239
239
  }
240
240
  }
241
241
  ```
package/bin/cli.js CHANGED
@@ -579,6 +579,8 @@ const HELP = `
579
579
 
580
580
  DISCOVER
581
581
  nerviq audit Quick scan: score + top 3 gaps (Harmony-first when 2+ platforms detected)
582
+ nerviq audit --shallow-risk Opt-in boundary scan for agent-config <-> codebase red flags (experimental)
583
+ nerviq audit --shallow-risk-only Fast precommit shallow-risk pass without the full governance audit
582
584
  nerviq audit --fix Audit, apply fixable critical fixes, then re-audit
583
585
  nerviq audit --fix --dry-run Show proposed autofix diff without writing
584
586
  nerviq audit --no-harmony-first Skip the cross-platform Harmony header
@@ -709,6 +711,8 @@ const HELP = `
709
711
  --tag LABEL Tag the saved snapshot (use with --snapshot; repeat or comma-separate for more)
710
712
  --milestone NAME Snapshot lifecycle milestone: baseline | post-fix | pre-upgrade | release
711
713
  --campaign A,B Limit plan/apply to named upgrade campaigns
714
+ --shallow-risk Enable experimental shallow-risk hints (parallel, not scored)
715
+ --shallow-risk-only Run only shallow-risk hints and skip the full governance audit
712
716
  --full Show full audit output (all checks, weakest areas, badge)
713
717
  --lite Short top-3 scan (default behavior since v1.5.2)
714
718
  --dry-run Preview changes without writing files
@@ -740,6 +744,7 @@ const HELP = `
740
744
  npx nerviq --lite
741
745
  npx nerviq --platform cursor
742
746
  npx nerviq audit --workspace packages/*
747
+ npx nerviq audit --shallow-risk
743
748
  npx nerviq baseline init
744
749
  npx nerviq audit --diff-only --drift-mode ci
745
750
  npx nerviq --platform codex augment
@@ -819,11 +824,16 @@ async function main() {
819
824
  process.exit(0);
820
825
  }
821
826
 
827
+ const shallowRiskRequested = (flags.includes('--shallow-risk') || flags.includes('--shallow-risk-only')) &&
828
+ process.env.NERVIQ_SHALLOW_RISK !== 'off';
829
+ const shallowRiskOnlyRequested = flags.includes('--shallow-risk-only') &&
830
+ process.env.NERVIQ_SHALLOW_RISK !== 'off';
831
+
822
832
  const options = {
823
833
  verbose: flags.includes('--verbose'),
824
834
  json: flags.includes('--json'),
825
835
  auto: flags.includes('--auto'),
826
- lite: flags.includes('--full') || flags.includes('--verbose') ? false : true,
836
+ lite: flags.includes('--full') || flags.includes('--verbose') || shallowRiskRequested ? false : true,
827
837
  full: flags.includes('--full'),
828
838
  showDeprecated: flags.includes('--show-deprecated'),
829
839
  snapshot: flags.includes('--snapshot'),
@@ -860,6 +870,8 @@ async function main() {
860
870
  compareView: flags.includes('--compare'),
861
871
  diffOnly: flags.includes('--diff-only'),
862
872
  noHarmonyFirst: flags.includes('--no-harmony-first'),
873
+ shallowRisk: shallowRiskRequested,
874
+ shallowRiskOnly: shallowRiskOnlyRequested,
863
875
  diffBase: parsed.diffBase || null,
864
876
  diffHead: parsed.diffHead || null,
865
877
  driftMode: parsed.driftMode || null,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nerviq/cli",
3
- "version": "1.26.0",
3
+ "version": "1.27.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": {
@@ -1,179 +1,180 @@
1
- /**
2
- * CTO-08 — 5-layer scope clarity.
3
- *
4
- * Every check in the NERVIQ audit is tagged with exactly one layer so
5
- * customers and evaluators get an explicit map of what NERVIQ covers and
6
- * what it does not. The 4 positive layers below intentionally exclude any
7
- * "deep-review" / general-security-scanning lane: NERVIQ is an
8
- * agent-configuration audit tool, not a code-review tool.
9
- *
10
- * Taxonomy (canonical — mirrored in docs/integration-contracts.md §8):
11
- *
12
- * governance — Agent configuration posture: presence, content, and
13
- * quality of agent-instruction files and platform
14
- * settings. Answers "does my agent know X?".
15
- *
16
- * drift — Cross-platform consistency: do multiple platform
17
- * configs agree? Does the declared state match the
18
- * repo reality? Answers "do two places agree on X?".
19
- *
20
- * hygiene — Repo-level cleanliness and operational basics
21
- * adjacent to agents (gitignore, CHANGELOG, SECURITY.md,
22
- * CI, Dependabot, license, editorconfig, Node version
23
- * pinning, etc.). Answers "does the repo have standard
24
- * engineering hygiene that makes the agent's job
25
- * easier?".
26
- *
27
- * shallow-risk — Reserved for CTO-06. No checks currently live in
28
- * this layer; the constant exists so formatters and
29
- * types know about it.
30
- *
31
- * Disambiguation rule-of-thumb when a check could plausibly belong to
32
- * more than one layer: prefer the most specific layer (drift > hygiene
33
- * > governance). If in doubt, default to hygiene a mild
34
- * misclassification is recoverable; a missing tag breaks the coverage
35
- * test.
36
- */
37
-
38
- 'use strict';
39
-
40
- const LAYERS = Object.freeze({
41
- GOVERNANCE: 'governance',
42
- DRIFT: 'drift',
43
- HYGIENE: 'hygiene',
44
- SHALLOW_RISK: 'shallow-risk',
45
- });
46
-
47
- const LAYER_DEFINITIONS = Object.freeze({
48
- [LAYERS.GOVERNANCE]: 'Agent configuration posture: presence, content, and quality of agent-instruction files and platform settings.',
49
- [LAYERS.DRIFT]: 'Cross-platform consistency: do multiple platform configs agree, and does the declared state match repo reality?',
50
- [LAYERS.HYGIENE]: 'Repo-level cleanliness and operational basics adjacent to agents (gitignore, CHANGELOG, SECURITY.md, CI, license, etc.).',
51
- [LAYERS.SHALLOW_RISK]: 'Reserved for shallow-risk boundary checks (CTO-06). No checks currently populate this layer.',
52
- });
53
-
54
- const VALID_LAYER_VALUES = new Set(Object.values(LAYERS));
55
-
56
- function isValidLayer(value) {
57
- return typeof value === 'string' && VALID_LAYER_VALUES.has(value);
58
- }
59
-
60
- /**
61
- * Name/id patterns that strongly indicate a drift check. Applied only as
62
- * a heuristic when tagging existing check bags (see assignLayers).
63
- */
64
- const DRIFT_PATTERNS = [
65
- /drift/i,
66
- /harmony/i,
67
- /\bpropagation\b/i,
68
- /consisten(t|cy)/i,
69
- /cross[- ]?platform/i,
70
- /across (surfaces|platforms|all .* surfaces)/i,
71
- /\bpacks are consistent\b/i,
72
- /propagation (checklist|completeness|delay)/i,
73
- ];
74
-
75
- /**
76
- * Hygiene name patterns — used to upgrade a check from a default
77
- * governance bag into hygiene when the check is clearly about repo
78
- * engineering hygiene rather than agent config.
79
- */
80
- const HYGIENE_PATTERNS = [
81
- /\.gitignore/i,
82
- /\bCHANGELOG\b/i,
83
- /\bCONTRIBUTING\b/i,
84
- /\bLICENSE\b/i,
85
- /\.editorconfig/i,
86
- /\bEditorConfig\b/i,
87
- /\bSECURITY\.md\b/i,
88
- /\bCODE_OF_CONDUCT\b/i,
89
- /\bDependabot\b/i,
90
- /\bNode version pinned\b/i,
91
- /\bREADME\b.*\b(install|usage|contributing|sections|section)\b/i,
92
- /\blockfile\b/i,
93
- /\bcargo-audit\b/i,
94
- /\bDockerfile\b/i,
95
- /\bCI (is configured|configured|pipeline|workflow)/i,
96
- /\bGitHub Actions\b/i,
97
- /\b\.github\/workflows\b/i,
98
- /\bpre-commit\b/i,
99
- /\b(poetry|uv|pipenv|npm|pnpm|yarn|bun)\.lock/i,
100
- /\brenovate\b/i,
101
- /\bsemver\b/i,
102
- /\brelease automation\b/i,
103
- ];
104
-
105
- /**
106
- * Check categories that strongly indicate repo-hygiene rather than
107
- * agent-configuration. These cover the stack-specific engineering
108
- * baselines (Python lockfile, Rust target/ in .gitignore, etc.) that
109
- * ship via the stacks checks.
110
- */
111
- const HYGIENE_CATEGORIES = new Set([
112
- 'dependency-management', 'supply-chain', 'release-freshness',
113
- 'docker', 'ci', 'ci-cd',
114
- 'git', // the cross-platform hygiene.js checks live here
115
- ]);
116
-
117
- function inferLayerForCheck(check, defaultLayer) {
118
- const probe = `${check.name || ''} ${check.id || ''} ${check.key || ''}`;
119
- if (DRIFT_PATTERNS.some((re) => re.test(probe))) return LAYERS.DRIFT;
120
- if (defaultLayer === LAYERS.GOVERNANCE) {
121
- if (HYGIENE_PATTERNS.some((re) => re.test(probe))) return LAYERS.HYGIENE;
122
- if (check.category && HYGIENE_CATEGORIES.has(check.category)) return LAYERS.HYGIENE;
123
- }
124
- return defaultLayer;
125
- }
126
-
127
- /**
128
- * Mutates `bag` (a technique dictionary of { key: { name, id, ... } })
129
- * so every entry has a `layer` field. Existing `layer` values on
130
- * individual checks are respected.
131
- *
132
- * @param {Object} bag technique dictionary
133
- * @param {string} defaultLayer one of LAYERS.*, used when heuristics don't fire
134
- * @returns {Object} the same bag, for chaining
135
- */
136
- function assignLayers(bag, defaultLayer = LAYERS.GOVERNANCE) {
137
- if (!bag || typeof bag !== 'object') return bag;
138
- if (!isValidLayer(defaultLayer)) {
139
- throw new Error(`assignLayers: invalid defaultLayer "${defaultLayer}"`);
140
- }
141
- for (const [key, check] of Object.entries(bag)) {
142
- if (!check || typeof check !== 'object') continue;
143
- if (isValidLayer(check.layer)) continue;
144
- const withKey = { ...check, key };
145
- check.layer = inferLayerForCheck(withKey, defaultLayer);
146
- }
147
- return bag;
148
- }
149
-
150
- /**
151
- * Summary helper — counts checks per layer in a results array. Used by
152
- * the audit text renderer and by the coverage test.
153
- */
154
- function summarizeLayers(results) {
155
- const summary = {
156
- [LAYERS.GOVERNANCE]: { total: 0, passed: 0, failed: 0, skipped: 0 },
157
- [LAYERS.DRIFT]: { total: 0, passed: 0, failed: 0, skipped: 0 },
158
- [LAYERS.HYGIENE]: { total: 0, passed: 0, failed: 0, skipped: 0 },
159
- [LAYERS.SHALLOW_RISK]: { total: 0, passed: 0, failed: 0, skipped: 0 },
160
- };
161
- for (const r of results || []) {
162
- const layer = isValidLayer(r.layer) ? r.layer : LAYERS.HYGIENE;
163
- const bucket = summary[layer];
164
- bucket.total += 1;
165
- if (r.passed === true) bucket.passed += 1;
166
- else if (r.passed === false) bucket.failed += 1;
167
- else bucket.skipped += 1;
168
- }
169
- return summary;
170
- }
171
-
172
- module.exports = {
173
- LAYERS,
174
- LAYER_DEFINITIONS,
175
- isValidLayer,
176
- assignLayers,
177
- summarizeLayers,
178
- inferLayerForCheck,
179
- };
1
+ /**
2
+ * CTO-08 — 5-layer scope clarity.
3
+ *
4
+ * Every check in the NERVIQ audit is tagged with exactly one layer so
5
+ * customers and evaluators get an explicit map of what NERVIQ covers and
6
+ * what it does not. The 4 positive layers below intentionally exclude any
7
+ * "deep-review" / general-security-scanning lane: NERVIQ is an
8
+ * agent-configuration audit tool, not a code-review tool.
9
+ *
10
+ * Taxonomy (canonical — mirrored in docs/integration-contracts.md §8):
11
+ *
12
+ * governance — Agent configuration posture: presence, content, and
13
+ * quality of agent-instruction files and platform
14
+ * settings. Answers "does my agent know X?".
15
+ *
16
+ * drift — Cross-platform consistency: do multiple platform
17
+ * configs agree? Does the declared state match the
18
+ * repo reality? Answers "do two places agree on X?".
19
+ *
20
+ * hygiene — Repo-level cleanliness and operational basics
21
+ * adjacent to agents (gitignore, CHANGELOG, SECURITY.md,
22
+ * CI, Dependabot, license, editorconfig, Node version
23
+ * pinning, etc.). Answers "does the repo have standard
24
+ * engineering hygiene that makes the agent's job
25
+ * easier?".
26
+ *
27
+ * shallow-risk — Parallel, opt-in boundary checks that sit at the
28
+ * agent-config <-> codebase edge. Findings are emitted
29
+ * through `auditResult.shallowRiskHints[]` and are not
30
+ * folded into governance scoring.
31
+ *
32
+ * Disambiguation rule-of-thumb when a check could plausibly belong to
33
+ * more than one layer: prefer the most specific layer (drift > hygiene
34
+ * > governance). If in doubt, default to hygiene — a mild
35
+ * misclassification is recoverable; a missing tag breaks the coverage
36
+ * test.
37
+ */
38
+
39
+ 'use strict';
40
+
41
+ const LAYERS = Object.freeze({
42
+ GOVERNANCE: 'governance',
43
+ DRIFT: 'drift',
44
+ HYGIENE: 'hygiene',
45
+ SHALLOW_RISK: 'shallow-risk',
46
+ });
47
+
48
+ const LAYER_DEFINITIONS = Object.freeze({
49
+ [LAYERS.GOVERNANCE]: 'Agent configuration posture: presence, content, and quality of agent-instruction files and platform settings.',
50
+ [LAYERS.DRIFT]: 'Cross-platform consistency: do multiple platform configs agree, and does the declared state match repo reality?',
51
+ [LAYERS.HYGIENE]: 'Repo-level cleanliness and operational basics adjacent to agents (gitignore, CHANGELOG, SECURITY.md, CI, license, etc.).',
52
+ [LAYERS.SHALLOW_RISK]: 'Parallel, opt-in boundary checks emitted via auditResult.shallowRiskHints[]; shown separately and excluded from governance scoring.',
53
+ });
54
+
55
+ const VALID_LAYER_VALUES = new Set(Object.values(LAYERS));
56
+
57
+ function isValidLayer(value) {
58
+ return typeof value === 'string' && VALID_LAYER_VALUES.has(value);
59
+ }
60
+
61
+ /**
62
+ * Name/id patterns that strongly indicate a drift check. Applied only as
63
+ * a heuristic when tagging existing check bags (see assignLayers).
64
+ */
65
+ const DRIFT_PATTERNS = [
66
+ /drift/i,
67
+ /harmony/i,
68
+ /\bpropagation\b/i,
69
+ /consisten(t|cy)/i,
70
+ /cross[- ]?platform/i,
71
+ /across (surfaces|platforms|all .* surfaces)/i,
72
+ /\bpacks are consistent\b/i,
73
+ /propagation (checklist|completeness|delay)/i,
74
+ ];
75
+
76
+ /**
77
+ * Hygiene name patterns used to upgrade a check from a default
78
+ * governance bag into hygiene when the check is clearly about repo
79
+ * engineering hygiene rather than agent config.
80
+ */
81
+ const HYGIENE_PATTERNS = [
82
+ /\.gitignore/i,
83
+ /\bCHANGELOG\b/i,
84
+ /\bCONTRIBUTING\b/i,
85
+ /\bLICENSE\b/i,
86
+ /\.editorconfig/i,
87
+ /\bEditorConfig\b/i,
88
+ /\bSECURITY\.md\b/i,
89
+ /\bCODE_OF_CONDUCT\b/i,
90
+ /\bDependabot\b/i,
91
+ /\bNode version pinned\b/i,
92
+ /\bREADME\b.*\b(install|usage|contributing|sections|section)\b/i,
93
+ /\blockfile\b/i,
94
+ /\bcargo-audit\b/i,
95
+ /\bDockerfile\b/i,
96
+ /\bCI (is configured|configured|pipeline|workflow)/i,
97
+ /\bGitHub Actions\b/i,
98
+ /\b\.github\/workflows\b/i,
99
+ /\bpre-commit\b/i,
100
+ /\b(poetry|uv|pipenv|npm|pnpm|yarn|bun)\.lock/i,
101
+ /\brenovate\b/i,
102
+ /\bsemver\b/i,
103
+ /\brelease automation\b/i,
104
+ ];
105
+
106
+ /**
107
+ * Check categories that strongly indicate repo-hygiene rather than
108
+ * agent-configuration. These cover the stack-specific engineering
109
+ * baselines (Python lockfile, Rust target/ in .gitignore, etc.) that
110
+ * ship via the stacks checks.
111
+ */
112
+ const HYGIENE_CATEGORIES = new Set([
113
+ 'dependency-management', 'supply-chain', 'release-freshness',
114
+ 'docker', 'ci', 'ci-cd',
115
+ 'git', // the cross-platform hygiene.js checks live here
116
+ ]);
117
+
118
+ function inferLayerForCheck(check, defaultLayer) {
119
+ const probe = `${check.name || ''} ${check.id || ''} ${check.key || ''}`;
120
+ if (DRIFT_PATTERNS.some((re) => re.test(probe))) return LAYERS.DRIFT;
121
+ if (defaultLayer === LAYERS.GOVERNANCE) {
122
+ if (HYGIENE_PATTERNS.some((re) => re.test(probe))) return LAYERS.HYGIENE;
123
+ if (check.category && HYGIENE_CATEGORIES.has(check.category)) return LAYERS.HYGIENE;
124
+ }
125
+ return defaultLayer;
126
+ }
127
+
128
+ /**
129
+ * Mutates `bag` (a technique dictionary of { key: { name, id, ... } })
130
+ * so every entry has a `layer` field. Existing `layer` values on
131
+ * individual checks are respected.
132
+ *
133
+ * @param {Object} bag technique dictionary
134
+ * @param {string} defaultLayer one of LAYERS.*, used when heuristics don't fire
135
+ * @returns {Object} the same bag, for chaining
136
+ */
137
+ function assignLayers(bag, defaultLayer = LAYERS.GOVERNANCE) {
138
+ if (!bag || typeof bag !== 'object') return bag;
139
+ if (!isValidLayer(defaultLayer)) {
140
+ throw new Error(`assignLayers: invalid defaultLayer "${defaultLayer}"`);
141
+ }
142
+ for (const [key, check] of Object.entries(bag)) {
143
+ if (!check || typeof check !== 'object') continue;
144
+ if (isValidLayer(check.layer)) continue;
145
+ const withKey = { ...check, key };
146
+ check.layer = inferLayerForCheck(withKey, defaultLayer);
147
+ }
148
+ return bag;
149
+ }
150
+
151
+ /**
152
+ * Summary helper counts checks per layer in a results array. Used by
153
+ * the audit text renderer and by the coverage test.
154
+ */
155
+ function summarizeLayers(results) {
156
+ const summary = {
157
+ [LAYERS.GOVERNANCE]: { total: 0, passed: 0, failed: 0, skipped: 0 },
158
+ [LAYERS.DRIFT]: { total: 0, passed: 0, failed: 0, skipped: 0 },
159
+ [LAYERS.HYGIENE]: { total: 0, passed: 0, failed: 0, skipped: 0 },
160
+ [LAYERS.SHALLOW_RISK]: { total: 0, passed: 0, failed: 0, skipped: 0 },
161
+ };
162
+ for (const r of results || []) {
163
+ const layer = isValidLayer(r.layer) ? r.layer : LAYERS.HYGIENE;
164
+ const bucket = summary[layer];
165
+ bucket.total += 1;
166
+ if (r.passed === true) bucket.passed += 1;
167
+ else if (r.passed === false) bucket.failed += 1;
168
+ else bucket.skipped += 1;
169
+ }
170
+ return summary;
171
+ }
172
+
173
+ module.exports = {
174
+ LAYERS,
175
+ LAYER_DEFINITIONS,
176
+ isValidLayer,
177
+ assignLayers,
178
+ summarizeLayers,
179
+ inferLayerForCheck,
180
+ };