@nerviq/cli 1.29.1 → 1.30.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 (35) hide show
  1. package/CHANGELOG.md +238 -1
  2. package/README.md +24 -6
  3. package/SECURITY.md +4 -8
  4. package/bin/cli.js +281 -5
  5. package/docs/integration-contracts.md +1 -1
  6. package/package.json +10 -2
  7. package/sdk/README.md +12 -3
  8. package/sdk/examples/langchain-integration.md +128 -0
  9. package/sdk/examples/self-governing-agent.js +135 -0
  10. package/sdk/index.d.ts +115 -0
  11. package/sdk/index.js +94 -0
  12. package/sdk/package.json +11 -0
  13. package/src/activity.js +13 -0
  14. package/src/audit.js +116 -15
  15. package/src/auto-suggest.js +9 -2
  16. package/src/behavioral-drift.js +37 -2
  17. package/src/codex/freshness.js +7 -0
  18. package/src/copilot/freshness.js +7 -0
  19. package/src/freshness.js +7 -0
  20. package/src/gemini/freshness.js +9 -9
  21. package/src/safe-glyph.js +97 -0
  22. package/src/setup.js +6 -0
  23. package/src/shallow-risk/index.js +60 -3
  24. package/src/shallow-risk/patterns/agent-config-cross-platform-drift.js +1 -0
  25. package/src/shallow-risk/patterns/agent-config-dangerous-autoapprove.js +1 -0
  26. package/src/shallow-risk/patterns/agent-config-deprecated-keys.js +1 -0
  27. package/src/shallow-risk/patterns/agent-config-framework-version-mismatch.js +138 -0
  28. package/src/shallow-risk/patterns/agent-config-missing-file.js +1 -0
  29. package/src/shallow-risk/patterns/agent-config-script-not-in-package-json.js +108 -0
  30. package/src/shallow-risk/patterns/agent-config-secret-literal.js +3 -0
  31. package/src/shallow-risk/patterns/agent-config-stack-contradiction.js +1 -0
  32. package/src/shallow-risk/patterns/hook-script-missing.js +1 -0
  33. package/src/shallow-risk/patterns/mcp-server-no-allowlist.js +1 -0
  34. package/src/shallow-risk/shared.js +5 -0
  35. package/src/watch.js +46 -0
package/CHANGELOG.md CHANGED
@@ -5,8 +5,244 @@ All notable changes to the **Nerviq** CLI are documented in this file.
5
5
  The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
6
6
  and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
7
7
 
8
+ ## Evidence tiers
9
+
10
+ Per **TRUTH-03** (POS-05 / continuous-governance positioning, 2026-04-29),
11
+ every changelog entry from this release forward is tagged with an explicit
12
+ evidence tier so a buyer / reviewer / contributor can tell at a glance how
13
+ strongly we stand behind the claim:
14
+
15
+ - `[Tested]` — verified in this codebase via `npm test` (canonical or Jest).
16
+ This is the strongest tier; a reproducible test guards against regression.
17
+ - `[Measured]` — backed by a controlled before/after run with declared
18
+ evaluator + cross-model judge, recorded under
19
+ `nerviq-research/research/measurement-runs/`. Strongest external evidence.
20
+ - `[Reported]` — surfaced by an external pilot, user-lab study, or community
21
+ observation; not yet independently re-measured.
22
+ - `[Aspirational]` — directional claim, design intent, or planned behavior.
23
+ Honest but not yet evidence-backed; flagged so it can't masquerade as proof.
24
+
25
+ Untagged historical entries pre-2026-04-29 should be treated as `[Tested]` if
26
+ they describe shipped behavior with regression coverage; the absence of a
27
+ tag is not an evidence-tier downgrade.
28
+
8
29
  ## [Unreleased]
9
30
 
31
+ (no unreleased changes)
32
+
33
+ ## [1.30.0] - 2026-04-29
34
+
35
+ ### Summary
36
+
37
+ Agent-facing surfaces ship: SDK bundled into the CLI tarball (MEMO-03 = B
38
+ decision), GitHub Action wired with full marketplace metadata (MR-06),
39
+ `nerviq certify --agent-ready` hardening gate (AI-13), and a postinstall
40
+ quick-start hint (AI-10). Continuous-governance UX polish carries over
41
+ from the round-5/6 closure waves: `pr-check` composite command (LOOP-02),
42
+ named watch alerts (LOOP-01), stale-reference headline before "Top 3 fixes"
43
+ (PROD-03), Windows mojibake fix (MEMO-16), and OWASP cross-walk on
44
+ shallow-risk findings (POS-01a). Performance: ~17% cut in the
45
+ checkAllTechniques hot loop (AI-12a). All 7 user-lab BUG fixes from the
46
+ 2026-04-28 12-persona study landed (BUG-01..07). Tooling: `publish.js`
47
+ no longer swallows errors (EXP-08).
48
+
49
+ ### Added — Agent-facing surfaces (round-8/9 closures)
50
+
51
+ - `[Tested]` **SDK bundled into the CLI tarball (MEMO-03 a..e).** New
52
+ `package.json` `exports` map exposes `@nerviq/cli`, `@nerviq/cli/sdk`
53
+ (programmatic API), `@nerviq/cli/sdk/types` (TypeScript declarations),
54
+ and `@nerviq/cli/package.json`. The `files` whitelist now includes
55
+ `sdk/`, so `npm pack --dry-run` ships
56
+ `sdk/{index.js,index.d.ts,package.json,README.md}` (266 files,
57
+ 883.1kB). README + `sdk/README.md` rewritten to point at the bundled
58
+ install path; the never-published `@nerviq/sdk` package name is now
59
+ documented as historical only. **Closes the public install-path
60
+ contradiction flagged by the Codex CTO/CEO Market Memo (2026-04-13).**
61
+ - `[Tested]` **`nerviq certify --agent-ready` (AI-13).** New mode under
62
+ the existing `certify` command runs 6 pass/fail criteria
63
+ (`agent-context-present`, `gitignore-blocks-env`,
64
+ `deny-rules-configured`, `no-critical-shallow-risk`,
65
+ `no-stale-references`, `governance-score-floor ≥ 50`). 3 are critical;
66
+ failing any drops the verdict from `agent-ready-full` to
67
+ `agent-ready-with-caveats` or `not-agent-ready`. Distinct shields.io
68
+ badges per verdict. Exit 0 on no-critical-fail, exit 1 otherwise
69
+ (CI-friendly).
70
+ - `[Tested]` **GitHub Action marketplace metadata (MR-06).**
71
+ `action/action.yml` adds the `branding` block (icon: `shield`, color:
72
+ `green`) required for Marketplace listing, expands inputs
73
+ (`threshold` / `platform` / `dir` / `diff-only` / `diff-base`), and
74
+ expands outputs (`score` / `organic-score` / `passed` / `failed` /
75
+ `total` / `stale-references` / `gate`). Invocation now passes
76
+ `--no-harmony-first` so machine output stays parser-safe regardless
77
+ of the harmony-first default. `GITHUB_STEP_SUMMARY` includes
78
+ stale-reference count + gate verdict.
79
+ - `[Tested]` **Postinstall quick-start hint (AI-10).**
80
+ `tools/postinstall.js` runs once after `npm install @nerviq/cli`,
81
+ printing a 4-line "next steps" block (`audit` / `setup --auto` /
82
+ `harmony-audit`). Suppressed in CI / non-TTY / transitive-dep installs
83
+ / when `NERVIQ_POSTINSTALL_QUIET=1` is set. Wired via
84
+ `package.json:postinstall` with a `|| true` failsafe so it never
85
+ breaks an install.
86
+ - `[Tested]` **AI-07 self-governing agent example.**
87
+ `sdk/examples/self-governing-agent.js` is the reference implementation
88
+ of the 5-step pattern documented at `/docs/for-agents`: pre-task
89
+ audit (surface stale references) → harmony check (multi-platform
90
+ only) → actual task → post-task diff audit → outcome record.
91
+ Resolves SDK via `require('@nerviq/cli/sdk')` with an in-repo
92
+ fallback so the example is testable from a checkout.
93
+ - `[Tested]` **AI-08 Nerviq references in generated CLAUDE.md.**
94
+ `src/setup.js` claude-md template now includes a "Governance check
95
+ (Nerviq)" section telling the agent to run `nerviq audit` before
96
+ substantive changes, re-run after editing
97
+ CLAUDE/AGENTS/.cursor/rules/.mcp.json/hooks, use `nerviq watch` for
98
+ continuous-mode workflows, and `nerviq pr-check --threshold 70`
99
+ before opening PRs.
100
+ - `[Tested]` **AI-09 orchestrator integration patterns.**
101
+ `sdk/examples/langchain-integration.md` ships LangChain (Node +
102
+ Python), CrewAI, and generic-orchestrator patterns plus a decision
103
+ matrix for "which tool to call when". Documentation-only; SDK code
104
+ unchanged.
105
+ - `[Tested]` **REL-01 release announcement automation.**
106
+ `tools/announce-release.js` extracts the CHANGELOG entry for a given
107
+ version, counts TRUTH-03 evidence tiers
108
+ (`[Tested]` / `[Measured]` / `[Reported]` / `[Aspirational]`), and
109
+ emits a markdown body for `gh release create --notes`. Wired as
110
+ `npm run announce:release [version]`.
111
+
112
+ ### Performance
113
+
114
+ - `[Tested]` **`checkAllTechniques` partition-before-loop (AI-12a).**
115
+ `src/audit.js` partitions the techniques map into applicable /
116
+ not-applicable arrays in a single pre-pass, then iterates only the
117
+ applicable list in the hot loop. Not-applicable entries get
118
+ fast-pushed to results without per-check work. Bench: **494ms vs
119
+ ~600ms baseline** on a 120-file site repo (~17% cut). Per AI-12
120
+ governance-budget tracking — moves real-repo overhead from ~1.17%
121
+ toward the revised <2% cumulative / <1% per-call envelope.
122
+
123
+ ### Round 6 — Continuous-governance polish (2026-04-29)
124
+
125
+ - `[Tested]` `bin/cli.js` adds the `nerviq pr-check` composite command —
126
+ audit + diff-only + threshold gate + markdown PR-comment + JSON envelope,
127
+ with explicit gate ✅/❌ and exit code 1 on fail. **LOOP-02 closed.**
128
+ - `[Tested]` `src/audit.js` runs the BUG-04 stale-reference patterns
129
+ default-on as a mini-scan. CLI text output prints the
130
+ `📌 Stale references in agent docs: N` block before "Top 3 things to fix"
131
+ so it is the literal first user-visible value. **PROD-03 closed.**
132
+ - `[Tested]` `src/watch.js` emits named `🔔 NEW: …` / `✓ CLEARED: …`
133
+ alerts per change diff (sourced from staleReferences + critical
134
+ shallow-risk hits). `--no-alerts` opt-out flag. **LOOP-01 closed.**
135
+ - `[Tested]` `src/shallow-risk/patterns/*` — every pattern now declares
136
+ an `owaspTags: [...]` array machine-readable cross-walk to OWASP Agentic
137
+ / MCP / Agentic-Skills Top 10 categories. Surfaced through `buildFinding`
138
+ so JSON consumers (`audit --json`, `pr-check --json`) get the tags on
139
+ every shallow-risk finding. **POS-01a closed.**
140
+ - `[Tested]` `src/safe-glyph.js` (new) — Windows mojibake fix. Auto-
141
+ detects modern terminals (Windows Terminal, VS Code, WSL, Git Bash) and
142
+ falls back to ASCII glyphs (`[OK]`, `[X]`, `[!]`) on legacy cmd.exe / PS.
143
+ Override via `NERVIQ_GLYPH=ascii|unicode`. `colorize()` routes all CLI
144
+ output through the helper. **MEMO-16 closed.**
145
+ - `[Reported]` `src/auto-suggest.js` empty-state message now lists explicit
146
+ `missingSignals` + thresholds so users know exactly what's missing if
147
+ the suggest-rules loop is data-starved. Reported by user-lab BUG-07.
148
+ - `[Reported]` `nerviq audit --fix --json` now emits valid JSON with the
149
+ full outcome envelope (mode, exitCode, plan, advisoryOnly, patchArtifact,
150
+ rollbackArtifact, reAudit, unresolvedKeys, branchName, warnings).
151
+ Reported by user-lab BUG-01.
152
+ - `[Reported]` Machine formats (sarif/junit/csv/markdown) no longer get
153
+ contaminated by the Harmony-first banner. Default is parser-safe.
154
+ Reported by user-lab BUG-02.
155
+ - `[Reported]` `deep-review --behavioral` returns `score: null,
156
+ status: "insufficient-signal"` on repos with <5 source files instead of
157
+ the misleading 100/100. Reported by user-lab BUG-05.
158
+ - `[Reported]` `exception list/add --json` emits stable
159
+ `{records, count, generatedAt}` envelope. Reported by user-lab BUG-06.
160
+
161
+
162
+
163
+ ### Research — published evidence surfaces (no CLI code change, 2026-04-17)
164
+
165
+ No product behavior change in this entry. Recording for coherence so
166
+ operators can cite the CLI from the research artifacts that now
167
+ reference it.
168
+
169
+ - **"State of AI Agent Governance 2026-Q2" report** — 20-repo public
170
+ dataset audited with this CLI (v1.29.1). CC0. Published in
171
+ `DnaFin/nerviq-research`.
172
+ - **Harmony value quantified** on 7 archetypes via `nerviq harmony-sync
173
+ --fix` before/after. Lift is bounded above by starting drift
174
+ (low-harmony repos: avg +20.5; high-harmony: avg 0).
175
+ - **Self-dogfood audit** — `nerviq audit` run on the research repo +
176
+ this CLI repo, all numbers published honestly including harmony
177
+ 33/100 on the research repo.
178
+ - **First tier-4 measurements** — catalog items #63 (Meta-prompting)
179
+ and #11 (Chain-of-thought) earned the `📏 Measured` badge via
180
+ cross-model-judge before/after runs.
181
+ - Three CI workflows now live in `DnaFin/nerviq-research`:
182
+ `tier1-runner.yml` (Fri 08:00 UTC), `tier2-runner.yml` (Sat 09:00
183
+ UTC), `tier25-runner.yml` (Sat 10:00 UTC). This CLI is what the
184
+ tier-2.5 workflow drives via subprocess — unchanged here.
185
+
186
+ Public artifacts: https://github.com/DnaFin/nerviq-research
187
+
188
+ ### Documentation & positioning
189
+
190
+ - `[Tested]` **AGENTS.md rewritten as flagship instruction file (DOG-01).**
191
+ The previous placeholder boilerplate is replaced with a real,
192
+ Nerviq-validated agent instruction surface for this CLI repo:
193
+ governance entry-point, single-source-of-truth pointers
194
+ (`package.json`, `release-metadata.json`, `nerviq-state.json`),
195
+ trust-boundary policy on instruction surfaces, and the canonical
196
+ release-prep checklist linked from the repo-boundary policy doc.
197
+ Closes the dogfood trust-break flagged by the 2026-04-28 cross-repo
198
+ project-domain audit.
199
+ - `[Tested]` **README continuous-governance positioning (POS-03 / POS-05).**
200
+ Lede aligned with the COMPLEMENTARY positioning frame (Nerviq sits
201
+ alongside ASTs / linters / SAST, not in place of them). README v2
202
+ qualifies the value claim with the explicit "continuous" qualifier
203
+ so a one-shot reader doesn't mistake the audit-only surface for the
204
+ full product.
205
+ - `[Tested]` **TRUTH-03 evidence-tier convention added to changelog.**
206
+ Every entry from this release forward is tagged with one of
207
+ `[Tested]` / `[Measured]` / `[Reported]` / `[Aspirational]` so a
208
+ buyer / reviewer / contributor can tell at a glance how strongly
209
+ we stand behind the claim. Documented in the file header.
210
+ - `[Tested]` **Freshness watchlist hardening (Claude/Codex/Copilot/Gemini
211
+ provider model pages).** Provider model docs added to each platform's
212
+ freshness module so the daily watch surfaces upstream model-release
213
+ changes instead of going quiet between major doc-site refactors.
214
+ Also: Gemini IDE-integration URL fixed; non-existent "hooks" page
215
+ removed from the Gemini watchlist.
216
+ - `[Tested]` **SECURITY.md internal contradiction fixed.** The supported
217
+ versions table now shows the `1.29.x` line as the active line of
218
+ support, replacing the stale `1.0.x` reference that survived from
219
+ the early-2026-Q2 cleanup pass.
220
+
221
+ ### Infrastructure
222
+
223
+ - `[Tested]` **OIDC trusted publisher migration (`fc6ead3`).**
224
+ `.github/workflows/publish.yml` switched to `npm publish --provenance
225
+ --access public` running under GitHub Actions OIDC against the npmjs
226
+ Trusted Publisher (org `nerviq`, repo `nerviq`, workflow
227
+ `publish.yml`, environment `npm-publish`). No `NPM_TOKEN` in CI;
228
+ local `npm publish` is no longer a valid escape hatch. Provenance
229
+ attestations are generated for every release from this point
230
+ forward.
231
+
232
+ ### Verified
233
+
234
+ - `[Tested]` jest: **475/475** passing (no test count delta from the
235
+ v1.29.0 / v1.29.1 baseline — round-6/8/9 features ship with their
236
+ own regression coverage that landed in the same suite).
237
+ - `[Tested]` canonical CLI tests: **162/162** passing.
238
+ - `[Tested]` `npm pack --dry-run`: clean. Tarball ships
239
+ `bin`, `src`, `sdk`, `docs`, `contracts`, `README.md`,
240
+ `CHANGELOG.md`, `SECURITY.md`, `package.json`.
241
+ - `[Tested]` `node tools/pre-publish.js --ci --expected-version 1.30.0`:
242
+ passes (config + version surfaces aligned).
243
+ - `[Tested]` `node tools/validate-release-metadata.js`: passes against
244
+ `package.json` + `CHANGELOG.md` + research-side `nerviq-state.json`.
245
+
10
246
  ## [1.29.1] - 2026-04-16
11
247
 
12
248
  ### Fixed — UX polish from external pilot feedback
@@ -1449,7 +1685,8 @@ Closes #35
1449
1685
  - Landing page (GitHub Pages ready)
1450
1686
  - Launch content and community posts
1451
1687
 
1452
- [Unreleased]: https://github.com/nerviq/nerviq/compare/v1.29.1...HEAD
1688
+ [Unreleased]: https://github.com/nerviq/nerviq/compare/v1.30.0...HEAD
1689
+ [1.30.0]: https://github.com/nerviq/nerviq/compare/v1.29.1...v1.30.0
1453
1690
  [1.29.1]: https://github.com/nerviq/nerviq/compare/v1.29.0...v1.29.1
1454
1691
  [1.29.0]: https://github.com/nerviq/nerviq/compare/v1.28.0...v1.29.0
1455
1692
  [1.28.0]: https://github.com/nerviq/nerviq/compare/v1.27.1...v1.28.0
package/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # Nerviq
2
2
 
3
- > Standardize and govern your AI coding agent setup score, fix, and align across 8 platforms.
3
+ > **Continuous** cross-platform configuration governance for AI coding agents. Audit, score, and align agent config across 8 platforms — at config-time, before runtime, as a recurring layer (not a one-shot audit). Four lifecycle loops: local dev watch → PR/CI gate → org fleet posture → AI behavior compliance. (Pre-runtime config layer; complements runtime governance like Microsoft AGT and code-quality tools like SonarQube.)
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)
@@ -44,6 +44,17 @@ Nerviq audits, sets up, and governs AI coding agent configurations for **8 platf
44
44
 
45
45
  Most repos use **more than one** AI coding agent — Claude and Cursor, Copilot and Codex, Gemini and Windsurf. Their configs drift silently. Nerviq is the neutral control plane that detects that drift, scores it, and helps align it.
46
46
 
47
+ ### Headline value: stale-reference detection
48
+
49
+ `nerviq audit` runs a deterministic mini-scan on every invocation that catches the most common form of agent-config rot:
50
+
51
+ - **Scripts that don't exist.** Your `AGENTS.md` says "run `npm test`" but `scripts.test` isn't defined in `package.json`. Flagged.
52
+ - **Framework versions that drifted.** Your `CLAUDE.md` says "this is a Next.js 15 app" but `package.json` declares `next@^16.x`. Flagged.
53
+
54
+ These checks run without a flag, with near-zero false positives, and are surfaced as a top-line section in audit output. Buyers and reviewers can verify each finding in 30 seconds — `cat package.json` against the agent doc. This is what cross-platform configuration governance looks like at the file boundary.
55
+
56
+ ### Cross-platform Harmony
57
+
47
58
  When your repo has 2+ platforms configured, `nerviq audit` leads with the Harmony Score — cross-platform alignment — before any single-platform results. Single-platform repos still get a normal per-platform audit.
48
59
 
49
60
  ```
@@ -172,12 +183,17 @@ npx @nerviq/cli synergy-report # Multi-agent synergy analysis
172
183
 
173
184
  Synergy evaluates compound audit results, discovers compensation patterns (where one platform covers another's gaps), and ranks recommendations by cross-platform impact.
174
185
 
175
- ## SDK — `@nerviq/sdk` `BETA`
186
+ ## SDK — `@nerviq/cli/sdk` `BETA`
187
+
188
+ Programmatic access to all Nerviq capabilities. The SDK ships **inside** the `@nerviq/cli` package (no separate install) per MEMO-03 (B = BUNDLE, signed 2026-04-28).
176
189
 
177
- Programmatic access to all Nerviq capabilities:
190
+ **Recommended (single install):**
178
191
 
179
192
  ```js
180
- const { audit, harmonyAudit, detectPlatforms } = require('@nerviq/sdk');
193
+ // Both forms work — same code path, both exported from @nerviq/cli.
194
+ const { audit, harmonyAudit, detectPlatforms } = require('@nerviq/cli');
195
+ // OR for explicit SDK-shape (input validation, typed):
196
+ const sdk = require('@nerviq/cli/sdk');
181
197
 
182
198
  async function main() {
183
199
  try {
@@ -198,6 +214,8 @@ async function main() {
198
214
  main();
199
215
  ```
200
216
 
217
+ > **Migration note (2026-04-29):** Earlier docs referenced `require('@nerviq/sdk')` as a separate npm package. That package was never published. The SDK now ships bundled inside `@nerviq/cli` (zero additional install). Existing `require('@nerviq/sdk')` calls will fail with module-not-found; switch to `require('@nerviq/cli')` or `require('@nerviq/cli/sdk')`. See `research/memo-03-sdk-decision-2026-04-28.md` for the rationale.
218
+
201
219
  Stable SDK surfaces: `audit`, `harmonyAudit`, `detectPlatforms`, `getCatalog`
202
220
  Experimental SDK surfaces: `synergyReport`, `routeTask`
203
221
 
@@ -247,8 +265,8 @@ All successful operational responses are wrapped in a JSON envelope:
247
265
  {
248
266
  "data": {},
249
267
  "meta": {
250
- "version": "1.29.1",
251
- "timestamp": "2026-04-16T08:00:00.000Z"
268
+ "version": "1.30.0",
269
+ "timestamp": "2026-04-29T12:00:00.000Z"
252
270
  }
253
271
  }
254
272
  ```
package/SECURITY.md CHANGED
@@ -28,14 +28,10 @@ Please include:
28
28
 
29
29
  | Version | Supported |
30
30
  |---------|-----------|
31
- | 1.29.x | Yes |
32
- | 1.28.x | Yes |
33
- | 1.27.x | Yes |
34
- | 1.26.x | Yes |
35
- | < 1.26 | No |
36
- | < 1.29 | No |
37
-
38
- Only the latest patch release of each supported major.minor line receives security updates.
31
+ | 1.30.x | Yes |
32
+ | < 1.30 | No |
33
+
34
+ Only the latest patch release of each supported major.minor line receives security updates. Older minors are out of scope — upgrade to a supported line for fixes.
39
35
 
40
36
  ## Dependency Policy
41
37