@nerviq/cli 1.26.0 → 1.27.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 (59) hide show
  1. package/CHANGELOG.md +1407 -0
  2. package/README.md +4 -4
  3. package/SECURITY.md +82 -0
  4. package/bin/cli.js +13 -1
  5. package/contracts/audit-webhook-event.schema.json +138 -0
  6. package/contracts/pack-contract.schema.json +15 -0
  7. package/contracts/technique-contract.schema.json +18 -0
  8. package/docs/ARCHITECTURE.md +74 -0
  9. package/docs/api-reference.md +356 -0
  10. package/docs/autofix.md +64 -0
  11. package/docs/bitbucket-pipe.yml +57 -0
  12. package/docs/case-studies.md +149 -0
  13. package/docs/category-definition-kit.md +56 -0
  14. package/docs/ci-integration.md +127 -0
  15. package/docs/claude-code-style.md +24 -0
  16. package/docs/claude-maintainer-ops.md +19 -0
  17. package/docs/external-validation.md +78 -0
  18. package/docs/first-tier-integration-gate.md +59 -0
  19. package/docs/getting-started.md +119 -0
  20. package/docs/gitlab-ci-template.yml +54 -0
  21. package/docs/index.html +597 -0
  22. package/docs/integration-contracts.md +287 -0
  23. package/docs/license-faq.md +53 -0
  24. package/docs/maintenance.md +155 -0
  25. package/docs/methodology.md +236 -0
  26. package/docs/new-platform-guide.md +202 -0
  27. package/docs/open-vsx-publishing.md +46 -0
  28. package/docs/platform-change-ingestion.md +46 -0
  29. package/docs/plugins.md +101 -0
  30. package/docs/pre-commit.md +58 -0
  31. package/docs/security-model.md +63 -0
  32. package/docs/shallow-risk.md +246 -0
  33. package/docs/versioning-policy.md +63 -0
  34. package/docs/why-nerviq.md +82 -0
  35. package/package.json +7 -2
  36. package/sdk/README.md +190 -0
  37. package/src/audit/layers.js +180 -179
  38. package/src/audit.js +118 -48
  39. package/src/codex/setup.js +3 -2
  40. package/src/formatters/csv.js +86 -85
  41. package/src/formatters/junit.js +123 -103
  42. package/src/formatters/markdown.js +164 -135
  43. package/src/gemini/setup.js +3 -2
  44. package/src/init.js +4 -3
  45. package/src/opencode/context.js +42 -3
  46. package/src/opencode/techniques.js +198 -142
  47. package/src/output-icons.js +44 -0
  48. package/src/setup/runtime.js +6 -5
  49. package/src/setup.js +4 -3
  50. package/src/shallow-risk/index.js +56 -0
  51. package/src/shallow-risk/patterns/agent-config-cross-platform-drift.js +50 -0
  52. package/src/shallow-risk/patterns/agent-config-dangerous-autoapprove.js +46 -0
  53. package/src/shallow-risk/patterns/agent-config-deprecated-keys.js +46 -0
  54. package/src/shallow-risk/patterns/agent-config-missing-file.js +72 -0
  55. package/src/shallow-risk/patterns/agent-config-secret-literal.js +49 -0
  56. package/src/shallow-risk/patterns/agent-config-stack-contradiction.js +34 -0
  57. package/src/shallow-risk/patterns/hook-script-missing.js +70 -0
  58. package/src/shallow-risk/patterns/mcp-server-no-allowlist.js +52 -0
  59. package/src/shallow-risk/shared.js +520 -0
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.1",
238
+ "timestamp": "2026-04-15T22:00:00.000Z"
239
239
  }
240
240
  }
241
241
  ```
package/SECURITY.md ADDED
@@ -0,0 +1,82 @@
1
+ # Security Policy
2
+
3
+ ## Reporting a Vulnerability
4
+
5
+ If you discover a security vulnerability in Nerviq, please report it responsibly.
6
+
7
+ **Email:** [business@nerviq.net](mailto:business@nerviq.net) (subject: SECURITY)
8
+
9
+ Please include:
10
+
11
+ - Description of the vulnerability
12
+ - Steps to reproduce
13
+ - Affected version(s)
14
+ - Impact assessment (if known)
15
+
16
+ **Do not** open a public GitHub issue for security vulnerabilities.
17
+
18
+ ## Response SLA
19
+
20
+ | Severity | Response Time | Fix Timeline |
21
+ |----------|--------------|--------------|
22
+ | **Critical** (RCE, data exfiltration) | < 24 hours | < 48 hours |
23
+ | **High** (privilege escalation, auth bypass) | < 48 hours | < 7 days |
24
+ | **Medium** (information disclosure, DoS) | < 7 days | < 30 days |
25
+ | **Low** (minor issues, hardening) | < 14 days | Next release |
26
+
27
+ ## Supported Versions
28
+
29
+ | Version | Supported |
30
+ |---------|-----------|
31
+ | 1.27.x | Yes |
32
+ | 1.26.x | Yes |
33
+ | 1.25.x | Yes |
34
+ | 1.24.x | Yes |
35
+ | < 1.24 | No |
36
+ | < 1.27 | No |
37
+
38
+ Only the latest patch release of each supported major.minor line receives security updates.
39
+
40
+ ## Dependency Policy
41
+
42
+ - **Zero runtime dependencies.** Nerviq ships with no production `node_modules` — only Node.js (>=18) is required.
43
+ - **devDependencies audited monthly** using `npm audit` and reviewed for known CVEs.
44
+ - **SBOM published** with every release (`sbom.cdx.json`) in CycloneDX format for full dependency transparency.
45
+ - **Lockfile integrity** checked in CI to prevent supply-chain tampering.
46
+ - **npm provenance attestation** — every release published via the GitHub Actions release workflow is signed with an npm provenance attestation (`npm publish --provenance`). This cryptographically links the published package to a specific GitHub Actions run, repository, and commit. Consumers can verify the attestation with `npm audit signatures @nerviq/cli`.
47
+
48
+ ## Security Architecture
49
+
50
+ - All operations run **locally** — no data is sent to external servers by default.
51
+ - The `nerviq serve` command binds to **localhost only** (127.0.0.1), never to 0.0.0.0.
52
+ - `deep-review` (opt-in) redacts secrets and credentials before sending config snippets to any AI provider.
53
+ - No secrets, tokens, or API keys are stored by Nerviq.
54
+
55
+ ## Reporting False Positives in Checks
56
+
57
+ If a Nerviq audit check produces a false positive (flags something that is not actually a problem):
58
+
59
+ 1. Run `nerviq audit --verbose` to identify the exact check key (e.g., `permissionDeny`).
60
+ 2. Open a GitHub issue with:
61
+ - The check key
62
+ - Your project structure (relevant files only)
63
+ - Why you believe it is a false positive
64
+ 3. Alternatively, use `nerviq feedback --key <checkKey> --status rejected --effect neutral --notes "false positive: <reason>"` to record it locally.
65
+
66
+ False positive reports help us improve check accuracy for all users.
67
+
68
+ ## Acknowledgments
69
+
70
+ We gratefully acknowledge security researchers who responsibly disclose vulnerabilities. With your permission, we will list you in our security acknowledgments.
71
+
72
+ ## Internal Response Process
73
+
74
+ When a vulnerability report arrives:
75
+
76
+ 1. **Acknowledge** — Reply within the SLA above confirming receipt
77
+ 2. **Triage** — Classify severity (Critical/High/Medium/Low), assign to founder
78
+ 3. **Reproduce** — Verify the vulnerability exists in the latest supported version
79
+ 4. **Fix** — Develop fix on a private branch, add regression test
80
+ 5. **Release** — Publish patched version to npm, tag in GitHub
81
+ 6. **Disclose** — Notify reporter, update CHANGELOG.md with security tag, credit reporter if permitted
82
+ 7. **Post-mortem** — For Critical/High: document root cause and prevention measures in `research/`
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,
@@ -0,0 +1,138 @@
1
+ {
2
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
3
+ "$id": "https://nerviq.net/contracts/audit-webhook-event.schema.json",
4
+ "title": "Nerviq Audit Webhook Event",
5
+ "type": "object",
6
+ "additionalProperties": true,
7
+ "required": [
8
+ "event",
9
+ "schemaVersion",
10
+ "generatedAt",
11
+ "platform",
12
+ "score",
13
+ "passed",
14
+ "failed",
15
+ "results",
16
+ "data",
17
+ "meta"
18
+ ],
19
+ "properties": {
20
+ "event": {
21
+ "const": "nerviq.audit.completed"
22
+ },
23
+ "schemaVersion": {
24
+ "type": "string",
25
+ "const": "1.0"
26
+ },
27
+ "generatedAt": {
28
+ "type": "string",
29
+ "format": "date-time"
30
+ },
31
+ "platform": {
32
+ "type": "string"
33
+ },
34
+ "score": {
35
+ "type": "number"
36
+ },
37
+ "passed": {
38
+ "type": "integer"
39
+ },
40
+ "failed": {
41
+ "type": "integer"
42
+ },
43
+ "results": {
44
+ "type": "array"
45
+ },
46
+ "data": {
47
+ "type": "object",
48
+ "additionalProperties": true,
49
+ "required": [
50
+ "platform",
51
+ "score",
52
+ "scoreType",
53
+ "passed",
54
+ "failed",
55
+ "checkCount",
56
+ "topNextActions",
57
+ "quickWins",
58
+ "scoreCoaching"
59
+ ],
60
+ "properties": {
61
+ "platform": {
62
+ "type": "string"
63
+ },
64
+ "platformLabel": {
65
+ "type": [
66
+ "string",
67
+ "null"
68
+ ]
69
+ },
70
+ "score": {
71
+ "type": "number"
72
+ },
73
+ "scoreType": {
74
+ "type": "string"
75
+ },
76
+ "organicScore": {
77
+ "type": [
78
+ "number",
79
+ "null"
80
+ ]
81
+ },
82
+ "passed": {
83
+ "type": "integer"
84
+ },
85
+ "failed": {
86
+ "type": "integer"
87
+ },
88
+ "skipped": {
89
+ "type": [
90
+ "integer",
91
+ "null"
92
+ ]
93
+ },
94
+ "checkCount": {
95
+ "type": "integer"
96
+ },
97
+ "topNextActions": {
98
+ "type": "array"
99
+ },
100
+ "quickWins": {
101
+ "type": "array"
102
+ },
103
+ "scoreCoaching": {
104
+ "type": [
105
+ "object",
106
+ "null"
107
+ ]
108
+ },
109
+ "suggestedNextCommand": {
110
+ "type": [
111
+ "string",
112
+ "null"
113
+ ]
114
+ }
115
+ }
116
+ },
117
+ "meta": {
118
+ "type": "object",
119
+ "additionalProperties": true,
120
+ "required": [
121
+ "cliVersion",
122
+ "source",
123
+ "webhookFormat"
124
+ ],
125
+ "properties": {
126
+ "cliVersion": {
127
+ "type": "string"
128
+ },
129
+ "source": {
130
+ "const": "nerviq-cli"
131
+ },
132
+ "webhookFormat": {
133
+ "const": "generic-audit-event"
134
+ }
135
+ }
136
+ }
137
+ }
138
+ }
@@ -0,0 +1,15 @@
1
+ {
2
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
3
+ "title": "Nerviq Domain/MCP Pack",
4
+ "type": "object",
5
+ "required": ["key", "label"],
6
+ "properties": {
7
+ "key": { "type": "string", "pattern": "^[a-z][a-z0-9-]*$" },
8
+ "label": { "type": "string" },
9
+ "description": { "type": "string" },
10
+ "useWhen": { "type": "string" },
11
+ "adoption": { "type": "string" },
12
+ "recommendedModules": { "type": "array", "items": { "type": "string" } },
13
+ "benchmarkFocus": { "type": "array", "items": { "type": "string" } }
14
+ }
15
+ }
@@ -0,0 +1,18 @@
1
+ {
2
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
3
+ "title": "Nerviq Technique",
4
+ "type": "object",
5
+ "required": ["id", "name", "check", "impact", "category", "fix"],
6
+ "properties": {
7
+ "id": { "type": ["string", "integer"] },
8
+ "name": { "type": "string", "minLength": 3 },
9
+ "check": { "description": "Function (ctx) => boolean|null" },
10
+ "impact": { "type": "string", "enum": ["critical", "high", "medium", "low"] },
11
+ "category": { "type": "string", "minLength": 2 },
12
+ "fix": { "type": "string", "minLength": 5 },
13
+ "rating": { "type": "integer", "minimum": 1, "maximum": 5 },
14
+ "confidence": { "type": "number", "minimum": 0, "maximum": 1 },
15
+ "sourceUrl": { "type": "string", "format": "uri" },
16
+ "template": {}
17
+ }
18
+ }
@@ -0,0 +1,74 @@
1
+ # Architecture
2
+
3
+ ## Data Flow
4
+
5
+ ```mermaid
6
+ graph LR
7
+ CLI[bin/cli.js] --> Audit[audit.js]
8
+ CLI --> Setup[setup.js]
9
+ CLI --> Analyze[analyze.js]
10
+ CLI --> Plans[plans.js]
11
+ CLI --> Gov[governance.js]
12
+ CLI --> Bench[benchmark.js]
13
+
14
+ Context[context.js] --> Audit
15
+ Context --> Setup
16
+ Context --> Analyze
17
+
18
+ Techniques[techniques.js<br/>84 checks + 30 stacks] --> Audit
19
+ Techniques --> Setup
20
+
21
+ DomainPacks[domain-packs.js<br/>16 domains] --> Analyze
22
+ DomainPacks --> Gov
23
+
24
+ McpPacks[mcp-packs.js<br/>26 MCP packs] --> Analyze
25
+ McpPacks --> Gov
26
+ McpPacks --> Plans
27
+
28
+ Audit --> Activity[activity.js<br/>snapshots + history]
29
+ Bench --> Activity
30
+ Analyze --> Activity
31
+ ```
32
+
33
+ ## Module Responsibilities
34
+
35
+ | Module | Role | I/O |
36
+ |--------|------|-----|
37
+ | **context.js** | Scans project directory, caches file reads | Dir path → ProjectContext |
38
+ | **techniques.js** | Defines 84 checks + 30 stacks. The knowledge base | ProjectContext → check results |
39
+ | **audit.js** | Runs checks, calculates score, builds topNextActions | Options → scored result |
40
+ | **analyze.js** | Augment/suggest-only analysis with strengths, gaps, domains | Options → analysis report |
41
+ | **plans.js** | Generates proposal bundles, applies with rollback | Audit result → proposals |
42
+ | **setup.js** | Generates CLAUDE.md, hooks, commands, agents, skills, rules | Stacks + context → files |
43
+ | **governance.js** | Permission profiles, hook registry, policy packs | Config → governance summary |
44
+ | **benchmark.js** | Isolated before/after in temp copy | Options → benchmark report |
45
+ | **domain-packs.js** | Detects repo type from signals | Context + stacks → domain matches |
46
+ | **mcp-packs.js** | Recommends MCP servers per domain | Domains + signals → MCP packs |
47
+ | **activity.js** | Snapshots, history, compare, trend export | Payloads → artifact files |
48
+
49
+ ## Scoring
50
+
51
+ ```
52
+ Score = (earned / max) * 100
53
+
54
+ Weights: critical=15, high=10, medium=5, low=2
55
+ Organic score: excludes checks that nerviq itself generated
56
+ ```
57
+
58
+ Checks return `true` (pass), `false` (fail), or `null` (not applicable / skip).
59
+
60
+ ## Trust-First Flow
61
+
62
+ ```
63
+ User runs audit → sees score + gaps
64
+
65
+ User runs plan → sees file previews + rationale
66
+
67
+ User reviews → approves specific bundles
68
+
69
+ apply writes files → rollback manifest created
70
+
71
+ User runs audit again → sees improvement
72
+ ```
73
+
74
+ No step writes without the previous step's output being reviewed.