@nerviq/cli 1.10.0 → 1.12.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.
Files changed (57) hide show
  1. package/README.md +176 -47
  2. package/bin/cli.js +842 -287
  3. package/package.json +2 -2
  4. package/src/activity.js +225 -59
  5. package/src/adoption-advisor.js +299 -0
  6. package/src/aider/freshness.js +28 -25
  7. package/src/aider/techniques.js +16 -11
  8. package/src/analyze.js +131 -1
  9. package/src/anti-patterns.js +17 -2
  10. package/src/audit.js +197 -96
  11. package/src/behavioral-drift.js +801 -0
  12. package/src/benchmark.js +15 -10
  13. package/src/continuous-ops.js +681 -0
  14. package/src/cost-tracking.js +61 -0
  15. package/src/cursor/techniques.js +17 -12
  16. package/src/deep-review.js +83 -0
  17. package/src/diff-only.js +280 -0
  18. package/src/doctor.js +118 -55
  19. package/src/governance.js +72 -50
  20. package/src/hook-validation.js +342 -0
  21. package/src/index.js +7 -1
  22. package/src/integrations.js +144 -60
  23. package/src/mcp-validation.js +337 -0
  24. package/src/opencode/techniques.js +12 -7
  25. package/src/operating-profile.js +574 -0
  26. package/src/org.js +97 -13
  27. package/src/permission-rules.js +218 -0
  28. package/src/plans.js +192 -8
  29. package/src/platform-change-manifest.js +86 -0
  30. package/src/policy-layers.js +210 -0
  31. package/src/profiles.js +4 -1
  32. package/src/prompt-injection.js +74 -0
  33. package/src/repo-archetype.js +386 -0
  34. package/src/secret-patterns.js +9 -0
  35. package/src/server.js +398 -3
  36. package/src/setup.js +36 -2
  37. package/src/source-urls.js +132 -132
  38. package/src/supplemental-checks.js +13 -12
  39. package/src/techniques/api.js +407 -0
  40. package/src/techniques/automation.js +316 -0
  41. package/src/techniques/compliance.js +257 -0
  42. package/src/techniques/hygiene.js +294 -0
  43. package/src/techniques/instructions.js +243 -0
  44. package/src/techniques/observability.js +226 -0
  45. package/src/techniques/optimization.js +142 -0
  46. package/src/techniques/quality.js +317 -0
  47. package/src/techniques/security.js +237 -0
  48. package/src/techniques/shared.js +443 -0
  49. package/src/techniques/stacks.js +2294 -0
  50. package/src/techniques/tools.js +106 -0
  51. package/src/techniques/workflow.js +413 -0
  52. package/src/techniques.js +78 -5611
  53. package/src/terminology.js +73 -0
  54. package/src/token-estimate.js +35 -0
  55. package/src/watch.js +18 -0
  56. package/src/windsurf/techniques.js +17 -12
  57. package/src/workspace.js +105 -8
package/README.md CHANGED
@@ -4,7 +4,7 @@
4
4
 
5
5
  [![npm version](https://img.shields.io/npm/v/@nerviq/cli)](https://www.npmjs.com/package/@nerviq/cli)
6
6
  [![License: AGPL-3.0](https://img.shields.io/badge/License-AGPL--3.0-blue.svg)](LICENSE)
7
- [![Checks: 2438](https://img.shields.io/badge/checks-2438-brightgreen)](https://github.com/nerviq/nerviq)
7
+ [![Checks: 2441](https://img.shields.io/badge/checks-2441-brightgreen)](https://github.com/nerviq/nerviq)
8
8
 
9
9
  ---
10
10
 
@@ -70,7 +70,11 @@ Nerviq scores your AI coding agent setup from 0 to 100, finds what's missing, an
70
70
  npx @nerviq/cli --beginner # Show only the 5 starter commands
71
71
  npx @nerviq/cli audit # Quick scan: score + top 3 actions
72
72
  npx @nerviq/cli audit --full # Full audit with all checks + badge
73
- npx @nerviq/cli audit --workspace packages/* # Monorepo: root governance + workspace average/package scores
73
+ npx @nerviq/cli audit --snapshot --tag "pre-refactor" # Save a named snapshot for history/compare/trend
74
+ npx @nerviq/cli audit --diff-only # PR/working-tree audit: changed files + linked governance/config surfaces only
75
+ npx @nerviq/cli compare # Detailed per-check diff between latest 2 audit snapshots
76
+ npx @nerviq/cli audit --webhook https://hooks.slack.com/services/... # Push audit results to Slack/Discord/generic HTTP
77
+ npx @nerviq/cli audit --workspace packages/* # Monorepo: root governance + stack-specific workspace profiles
74
78
  npx @nerviq/cli setup # Generate starter-safe baseline
75
79
  npx @nerviq/cli augment # Improvement plan, no writes
76
80
  npx @nerviq/cli governance # Permission profiles + policy packs
@@ -79,6 +83,8 @@ npx @nerviq/cli benchmark # Baseline vs projected score in isolated cop
79
83
 
80
84
  No install required. Zero dependencies.
81
85
 
86
+ Text-mode CLI output explains terms like `MCP`, `hooks`, `deny rules`, and `governance` inline when they appear, so a first audit is easier to read.
87
+
82
88
  If you want the shortest possible command list inside the terminal, start with:
83
89
 
84
90
  ```bash
@@ -93,7 +99,7 @@ npx @nerviq/cli --beginner
93
99
  | **Team lead / DevEx** | `nerviq governance` → `nerviq audit --json` | CI threshold + `nerviq watch` |
94
100
  | **Enterprise / Platform** | `nerviq harmony-audit` → `nerviq harmony-drift` | Policy packs + `nerviq certify` |
95
101
 
96
- ## 2,438 Checks Across 96 Categories (8 Platforms × ~300 Governance Rules)
102
+ ## 2,441 Checks Across 96 Categories (8 Platforms × ~300 Governance Rules)
97
103
 
98
104
  | Category Group | Checks | Examples |
99
105
  |----------------|--------|---------|
@@ -136,22 +142,58 @@ npx @nerviq/cli synergy-report # Multi-agent synergy analysis
136
142
 
137
143
  Synergy evaluates compound audit results, discovers compensation patterns (where one platform covers another's gaps), and ranks recommendations by cross-platform impact.
138
144
 
139
- ## SDK — `@nerviq/sdk` `BETA`
140
-
141
- Programmatic access to all Nerviq capabilities:
142
-
143
- ```js
144
- const { audit, harmonyAudit, synergyReport, detectPlatforms } = require('@nerviq/sdk');
145
-
146
- const result = await audit('.', 'claude');
147
- console.log(`Score: ${result.score}/100`);
148
-
149
- const platforms = detectPlatforms('.');
150
- console.log(`Active platforms: ${platforms.join(', ')}`);
151
-
152
- const harmony = await harmonyAudit('.');
153
- console.log(`Harmony score: ${harmony.harmonyScore}/100`);
154
- ```
145
+ ## SDK — `@nerviq/sdk` `BETA`
146
+
147
+ Programmatic access to all Nerviq capabilities:
148
+
149
+ ```js
150
+ const { audit, harmonyAudit, detectPlatforms } = require('@nerviq/sdk');
151
+
152
+ async function main() {
153
+ try {
154
+ const result = await audit('.', 'claude');
155
+ console.log(`Score: ${result.score}/100`);
156
+
157
+ const platforms = detectPlatforms('.');
158
+ console.log(`Active platforms: ${platforms.join(', ') || 'none detected'}`);
159
+
160
+ const harmony = await harmonyAudit('.');
161
+ console.log(`Harmony score: ${harmony.harmonyScore}/100`);
162
+ } catch (error) {
163
+ console.error(error instanceof Error ? error.message : 'Unknown SDK error');
164
+ process.exitCode = 1;
165
+ }
166
+ }
167
+
168
+ main();
169
+ ```
170
+
171
+ Stable SDK surfaces: `audit`, `harmonyAudit`, `detectPlatforms`, `getCatalog`
172
+ Experimental SDK surfaces: `synergyReport`, `routeTask`
173
+
174
+ See [sdk/README.md](sdk/README.md) for full JavaScript examples, error handling guidance, and TypeScript usage.
175
+
176
+ ## Integration Contract Pack
177
+
178
+ Nerviq publishes a compact integration pack so external systems do not need to scrape CLI text:
179
+
180
+ - OpenAPI 3.1 contract from `nerviq serve` via `GET /api/openapi.json`
181
+ - Generic audit webhook schema at [`contracts/audit-webhook-event.schema.json`](contracts/audit-webhook-event.schema.json)
182
+ - CI reference patterns in [`docs/ci-integration.md`](docs/ci-integration.md)
183
+ - SDK usage guide in [`sdk/README.md`](sdk/README.md)
184
+ - First-tier release gate in [`docs/first-tier-integration-gate.md`](docs/first-tier-integration-gate.md)
185
+
186
+ See [`docs/integration-contracts.md`](docs/integration-contracts.md) for the full pack.
187
+
188
+ ## Category Definition Kit
189
+
190
+ Nerviq is positioned as the control plane for AI-enabled development:
191
+
192
+ - a repo-native governance layer for AI coding agents
193
+ - a cross-platform drift detector and operating model
194
+ - not a full SAST scanner, prompt library, or single-vendor IDE plugin
195
+
196
+ See [`docs/category-definition-kit.md`](docs/category-definition-kit.md) for the category language, comparison matrix, operating model, and adoption playbook.
155
197
 
156
198
  ## MCP Server — `nerviq serve`
157
199
 
@@ -161,11 +203,30 @@ Nerviq ships with a built-in MCP-compatible HTTP server for integration with AI
161
203
  npx @nerviq/cli serve --port 3000
162
204
  ```
163
205
 
164
- Endpoints:
165
- - `GET /api/health` — Server health check
166
- - `GET /api/catalog` — Full check catalog
167
- - `POST /api/audit` — Run audit on a directory
168
- - `GET /api/harmony` — Cross-platform harmony data
206
+ Endpoints:
207
+ - `GET /api/openapi.json` — Live OpenAPI 3.1 contract for this `serve` instance
208
+ - `GET /api/health` — Server health check
209
+ - `GET /api/catalog` — Full check catalog
210
+ - `GET /api/audit` — Run audit on a directory and platform via query params
211
+ - `GET /api/harmony` — Cross-platform harmony data
212
+
213
+ All successful operational responses are wrapped in a JSON envelope:
214
+
215
+ ```json
216
+ {
217
+ "data": {},
218
+ "meta": {
219
+ "version": "1.12.0",
220
+ "timestamp": "2026-04-09T12:00:00.000Z"
221
+ }
222
+ }
223
+ ```
224
+
225
+ Pull the contract directly into Swagger UI, Postman, or internal tooling:
226
+
227
+ ```bash
228
+ curl http://127.0.0.1:3000/api/openapi.json > nerviq-openapi.json
229
+ ```
169
230
 
170
231
  ## Plugin System — `nerviq.config.js`
171
232
 
@@ -232,21 +293,23 @@ Levels:
232
293
 
233
294
  | Command | What it does |
234
295
  |---------|-------------|
235
- | `nerviq audit` | Score 0-100 — quick scan with top 3 actions (default) |
236
- | `nerviq audit --full` | Full audit with all checks, weakest areas, confidence labels |
237
- | `nerviq fix <key>` | Auto-fix a specific check (shows score impact) |
238
- | `nerviq fix --all-critical` | Fix all critical issues at once |
296
+ | `nerviq audit` | Score 0-100 — quick scan with top 3 actions and milestone coaching (default) |
297
+ | `nerviq audit --full` | Full audit with all checks, weakest areas, confidence labels, and milestone coaching |
298
+ | `nerviq audit --diff-only` | Analyze only changed files plus linked governance/config surfaces from git diff / working tree |
299
+ | `nerviq fix <key>` | Auto-fix a specific check (shows score impact) |
300
+ | `nerviq fix --all-critical` | Fix all critical issues at once |
239
301
  | `nerviq rollback` | Undo the most recent apply (delete created files) |
240
302
  | `nerviq rollback --list` | Show available rollback points |
241
- | `nerviq setup` | Generate starter-safe CLAUDE.md + hooks + commands |
242
- | `nerviq augment` | Repo-aware improvement plan (no writes) |
243
- | `nerviq suggest-only` | Structured report for sharing |
303
+ | `nerviq setup` | Generate starter-safe CLAUDE.md + hooks + commands |
304
+ | `nerviq augment` | Repo-aware improvement plan with archetype profiling, operating profile, and adopt/defer/ignore guidance (no writes) |
305
+ | `nerviq suggest-only` | Structured report for sharing, including repo archetype, operating profile, and adopt/defer/ignore guidance |
244
306
  | `nerviq plan` | Export proposal bundles with previews |
245
307
  | `nerviq apply` | Apply proposals with rollback |
246
308
  | `nerviq governance` | Permission profiles, hooks, policy packs |
247
309
  | `nerviq benchmark` | Baseline vs projected score in isolated temp copy |
248
310
  | `nerviq check-health` | Detect regressions between audit snapshots |
249
- | `nerviq deep-review` | AI-powered config review (opt-in) |
311
+ | `nerviq deep-review` | AI-powered config review (opt-in) |
312
+ | `nerviq deep-review --behavioral` | Local behavioral drift review with outcome-layer heuristics |
250
313
  | `nerviq interactive` | Step-by-step guided wizard |
251
314
  | `nerviq watch` | Live monitoring with score delta |
252
315
  | `nerviq history` | Audit snapshot history from saved snapshots |
@@ -256,10 +319,11 @@ Levels:
256
319
  | `nerviq anti-patterns` | Detect anti-patterns in current project |
257
320
  | `nerviq freshness` | Show verification freshness for all checks |
258
321
  | `nerviq rules-export` | Export recommendation rules (human summary or --json) |
259
- | `nerviq badge` | shields.io badge for README |
260
- | `nerviq certify` | Certification level + badge |
261
- | `nerviq scan dir1 dir2` | Compare multiple repos |
262
- | `nerviq org scan dir1 dir2` | Aggregate multiple repos into one score table |
322
+ | `nerviq badge` | shields.io badge for README |
323
+ | `nerviq certify` | Certification level + badge |
324
+ | `nerviq scan dir1 dir2` | Compare multiple repos |
325
+ | `nerviq org scan dir1 dir2` | Aggregate multiple repos into one score table |
326
+ | `nerviq org policy` | Inspect resolved org/team/repo policy layers |
263
327
  | `nerviq harmony-audit` | Cross-platform DX audit |
264
328
  | `nerviq harmony-sync` | Sync config across platforms |
265
329
  | `nerviq harmony-drift` | Detect platform drift |
@@ -268,7 +332,7 @@ Levels:
268
332
  | `nerviq harmony-governance` | Unified platform governance |
269
333
  | `nerviq synergy-report` | Multi-agent synergy analysis |
270
334
  | `nerviq catalog` | Show check catalog for all 8 platforms |
271
- | `nerviq doctor` | Self-diagnostics |
335
+ | `nerviq doctor` | Self-diagnostics for install health, freshness, platform detection, declared MCP servers, and hook runtime |
272
336
  | `nerviq convert` | Convert config between platforms |
273
337
  | `nerviq migrate` | Migrate platform config versions |
274
338
  | `nerviq serve` | Start local MCP-compatible HTTP API |
@@ -277,20 +341,85 @@ Levels:
277
341
 
278
342
  | Flag | Effect |
279
343
  |------|--------|
280
- | `--full` | Full audit output (all checks, weakest areas, confidence labels) |
344
+ | `--full` | Full audit output (all checks, weakest areas, confidence labels, milestone coaching) |
281
345
  | `--verbose` | Full audit + medium-priority recommendations |
282
346
  | `--threshold N` | Exit 1 if score < N (for CI) |
283
347
  | `--json` | Machine-readable JSON output |
284
- | `--out FILE` | Write output to file |
285
- | `--snapshot` | Save audit snapshot for trending |
286
- | `--dry-run` | Preview changes without writing files |
287
- | `--config-only` | Only write config files, never source code |
288
- | `--auto` | Apply without prompts |
348
+ | `--out FILE` | Write output to file |
349
+ | `--webhook URL` | POST audit results to Slack, Discord, or a generic JSON endpoint |
350
+ | `--webhook-header NAME:VALUE` | Add a custom webhook header; repeat the flag for multiple headers |
351
+ | `--webhook-retries N` | Retry transient webhook failures (`429`, `5xx`, timeouts) up to `N` extra times |
352
+ | `--snapshot` | Save audit snapshot for trending |
353
+ | `--tag LABEL` | Label a saved snapshot (repeat the flag for multiple tags) |
354
+ | `--behavioral` | Run the opt-in local behavioral drift review via `deep-review` |
355
+ | `--history` | With `deep-review --behavioral`, show behavioral snapshot history |
356
+ | `--compare` | With `deep-review --behavioral`, compare the latest two behavioral snapshots |
357
+ | `--diff-only` | Run a changed-file audit instead of a full repo audit |
358
+ | `--diff-base SHA` | Base SHA for `--diff-only` PR comparisons (defaults to CI env vars when present) |
359
+ | `--diff-head SHA` | Head SHA for `--diff-only` PR comparisons (defaults to `GITHUB_SHA` or `HEAD`) |
360
+ | `--dry-run` | Preview changes without writing files |
361
+ | `--config-only` | Only write config files, never source code |
362
+ | `--auto` | Apply without prompts |
289
363
  | `--only A,B` | Limit apply to selected proposal IDs |
290
364
  | `--format sarif` | SARIF output for code scanning |
291
365
  | `--platform NAME` | Target platform (claude, codex, gemini, copilot, cursor, windsurf, aider, opencode) |
292
- | `--workspace GLOB` | Audit workspaces separately as package-level live audits (e.g. packages/*) |
293
- | `--external PATH` | Benchmark an external repo |
366
+ | `--workspace GLOB` | Audit workspaces separately as package-level live audits with summary-only JSON rows (e.g. packages/*) |
367
+ | `--external PATH` | Benchmark an external repo |
368
+
369
+ Webhook delivery automatically retries transient failures twice by default. For authenticated internal endpoints, you can add custom headers such as:
370
+
371
+ ```bash
372
+ npx @nerviq/cli audit \
373
+ --webhook https://ops.example.com/nerviq/audit \
374
+ --webhook-header "Authorization: Bearer $NERVIQ_WEBHOOK_TOKEN" \
375
+ --webhook-header "X-Nerviq-Environment: production" \
376
+ --webhook-retries 4
377
+ ```
378
+
379
+ Generic webhook endpoints now receive a stable `nerviq.audit.completed` event envelope with:
380
+
381
+ - backward-compatible top-level `platform`, `score`, `passed`, `failed`, and `results`
382
+ - nested `data` and `meta` blocks for new consumers
383
+ - schema versioning through `schemaVersion`
384
+
385
+ For PR-focused audits, you can scope Nerviq to the working tree or an explicit base/head range:
386
+
387
+ ```bash
388
+ npx @nerviq/cli audit --diff-only
389
+ npx @nerviq/cli audit --diff-only --diff-base origin/main --diff-head HEAD
390
+ ```
391
+
392
+ `--diff-only` is intentionally a scoped review surface. It reports a `diff-only changed-file audit` score, lists the changed files it considered, and reminds you to run a full `nerviq audit` for the complete repo posture. Because diff-only scores are not directly comparable to full audit history, Nerviq blocks `--diff-only --snapshot`.
393
+
394
+ For multi-repo governance, Nerviq also supports inherited policy layers:
395
+
396
+ - `.nerviq/org-policy.json` in an ancestor directory for org defaults
397
+ - `.nerviq/team-policy.json` in the repo for team overrides
398
+ - `.nerviq/repo-policy.json` in the repo for repo-specific overrides
399
+
400
+ Inspect the resolved contract with:
401
+
402
+ ```bash
403
+ npx @nerviq/cli org policy
404
+ npx @nerviq/cli org scan ./app ./api ./infra --json
405
+ ```
406
+
407
+ For opt-in outcome-layer inspection, Nerviq can also run a local behavioral drift review:
408
+
409
+ ```bash
410
+ npx @nerviq/cli deep-review --behavioral
411
+ npx @nerviq/cli deep-review --behavioral --snapshot --milestone baseline --tag "behavioral-baseline"
412
+ npx @nerviq/cli deep-review --behavioral --history
413
+ npx @nerviq/cli deep-review --behavioral --compare
414
+ ```
415
+
416
+ Behavioral drift mode is intentionally guarded:
417
+
418
+ - It analyzes repository structure and instruction-vs-outcome mismatch heuristics
419
+ - It does not claim agent attribution without explicit evidence
420
+ - It is not marketed as SAST, semantic code review, or runtime analysis
421
+
422
+ `nerviq setup` now seeds a trust-boundary section in `CLAUDE.md` and an `injection-defense` starter hook for `WebFetch`, `WebSearch`, `Read`, `Grep`, `Glob`, and MCP-backed external-content flows. `nerviq doctor` validates that the declared starter hook still runs and logs suspicious prompt-injection patterns correctly.
294
423
 
295
424
  ## Backed by Research
296
425
 
@@ -298,7 +427,7 @@ Nerviq is built on the NERVIQ knowledge engine — the largest verified catalog
298
427
 
299
428
  - **448+ research documents** covering all 8 platforms
300
429
  - **332+ experiments** with tested, rated results
301
- - **2,438 checks** across 8 platforms (~300 unique governance rules × 8 platform adaptations), each with `sourceUrl` and `confidence` level (0.0-1.0)
430
+ - **2,441 checks** across 8 platforms (~300 unique governance rules × 8 platform adaptations), each with `sourceUrl` and `confidence` level (0.0-1.0)
302
431
  - Every check is traceable to primary documentation or verified experiment
303
432
  - 90-day freshness cycle: stale findings are re-verified or pruned
304
433
 
@@ -321,7 +450,7 @@ Every write command supports `--snapshot` for automatic backup before changes.
321
450
 
322
451
  - **Zero dependencies** — nothing to audit
323
452
  - **Runs locally** — audit, setup, plan, apply, governance, benchmark all run on your machine
324
- - **Deep review is opt-in** — only `deep-review` sends selected config for AI analysis
453
+ - **Deep review is opt-in** — `deep-review` sends selected config for AI analysis, while `deep-review --behavioral` stays local and uses heuristic outcome-layer analysis only
325
454
  - **AGPL-3.0 Licensed** — open source
326
455
 
327
456
  ## Links