@nerviq/cli 1.29.0 → 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 (93) hide show
  1. package/CHANGELOG.md +1764 -1493
  2. package/README.md +568 -538
  3. package/SECURITY.md +78 -82
  4. package/bin/cli.js +2838 -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 +75 -67
  17. package/sdk/README.md +12 -3
  18. package/sdk/examples/langchain-integration.md +128 -0
  19. package/sdk/examples/self-governing-agent.js +135 -0
  20. package/sdk/index.d.ts +115 -0
  21. package/sdk/index.js +94 -0
  22. package/sdk/package.json +11 -0
  23. package/src/activity.js +13 -0
  24. package/src/aider/activity.js +226 -226
  25. package/src/aider/context.js +162 -162
  26. package/src/aider/freshness.js +123 -123
  27. package/src/aider/techniques.js +3465 -3465
  28. package/src/audit/layers.js +180 -180
  29. package/src/audit.js +1133 -1032
  30. package/src/auto-suggest.js +9 -2
  31. package/src/behavioral-drift.js +37 -2
  32. package/src/benchmark.js +299 -299
  33. package/src/codex/activity.js +324 -324
  34. package/src/codex/freshness.js +149 -142
  35. package/src/codex/techniques.js +4895 -4895
  36. package/src/context.js +326 -326
  37. package/src/continuous-ops.js +11 -1
  38. package/src/convert.js +340 -340
  39. package/src/copilot/config-parser.js +280 -280
  40. package/src/copilot/context.js +218 -218
  41. package/src/copilot/freshness.js +184 -177
  42. package/src/copilot/patch.js +238 -238
  43. package/src/copilot/techniques.js +3578 -3578
  44. package/src/cursor/freshness.js +194 -194
  45. package/src/cursor/patch.js +243 -243
  46. package/src/cursor/techniques.js +3735 -3735
  47. package/src/doctor.js +201 -201
  48. package/src/fix-engine.js +511 -8
  49. package/src/formatters/csv.js +86 -86
  50. package/src/formatters/junit.js +123 -123
  51. package/src/formatters/markdown.js +164 -164
  52. package/src/formatters/otel.js +151 -151
  53. package/src/freshness.js +163 -156
  54. package/src/gemini/activity.js +402 -402
  55. package/src/gemini/context.js +290 -290
  56. package/src/gemini/freshness.js +188 -188
  57. package/src/gemini/patch.js +229 -229
  58. package/src/gemini/techniques.js +3811 -3811
  59. package/src/governance.js +533 -533
  60. package/src/harmony/audit.js +306 -306
  61. package/src/i18n.js +63 -63
  62. package/src/insights.js +119 -119
  63. package/src/integrations.js +134 -134
  64. package/src/locales/en.json +33 -33
  65. package/src/locales/es.json +33 -33
  66. package/src/migrate.js +354 -354
  67. package/src/opencode/activity.js +286 -286
  68. package/src/opencode/freshness.js +137 -137
  69. package/src/opencode/techniques.js +3450 -3450
  70. package/src/safe-glyph.js +97 -0
  71. package/src/setup/analysis.js +12 -12
  72. package/src/setup.js +13 -6
  73. package/src/shallow-risk/index.js +113 -56
  74. package/src/shallow-risk/patterns/agent-config-cross-platform-drift.js +51 -50
  75. package/src/shallow-risk/patterns/agent-config-dangerous-autoapprove.js +47 -46
  76. package/src/shallow-risk/patterns/agent-config-deprecated-keys.js +47 -46
  77. package/src/shallow-risk/patterns/agent-config-framework-version-mismatch.js +138 -0
  78. package/src/shallow-risk/patterns/agent-config-missing-file.js +318 -317
  79. package/src/shallow-risk/patterns/agent-config-script-not-in-package-json.js +108 -0
  80. package/src/shallow-risk/patterns/agent-config-secret-literal.js +52 -49
  81. package/src/shallow-risk/patterns/agent-config-stack-contradiction.js +35 -34
  82. package/src/shallow-risk/patterns/hook-script-missing.js +71 -70
  83. package/src/shallow-risk/patterns/mcp-server-no-allowlist.js +53 -52
  84. package/src/shallow-risk/shared.js +653 -648
  85. package/src/source-urls.js +295 -295
  86. package/src/state-paths.js +85 -85
  87. package/src/supplemental-checks.js +805 -805
  88. package/src/telemetry.js +160 -160
  89. package/src/watch.js +46 -0
  90. package/src/windsurf/context.js +359 -359
  91. package/src/windsurf/freshness.js +194 -194
  92. package/src/windsurf/patch.js +231 -231
  93. package/src/windsurf/techniques.js +3779 -3779
@@ -0,0 +1,138 @@
1
+ 'use strict';
2
+
3
+ const {
4
+ SHALLOW_RISK_DOC_URL,
5
+ fileExists,
6
+ getAgentConfigEntries,
7
+ getScannableLines,
8
+ } = require('../shared');
9
+
10
+ // Frameworks we know how to cross-check against package.json. The label is
11
+ // what we expect to see in agent docs (case-insensitive); the depKey is the
12
+ // npm package name to look up.
13
+ //
14
+ // Conservative on purpose: we only flag mismatches for frameworks where a
15
+ // version bump is meaningful (Next.js / React / Tailwind / Vue / Angular /
16
+ // TypeScript / Vite / Express / Fastify / NestJS). Adding noisy frameworks
17
+ // here will create FPs.
18
+ const FRAMEWORK_DEPS = [
19
+ { label: 'Next.js', altLabels: ['Next', 'NextJS'], depKey: 'next' },
20
+ { label: 'React', altLabels: [], depKey: 'react' },
21
+ { label: 'Tailwind', altLabels: ['Tailwind CSS', 'TailwindCSS'], depKey: 'tailwindcss' },
22
+ { label: 'Vue', altLabels: ['Vue.js', 'VueJS'], depKey: 'vue' },
23
+ { label: 'Angular', altLabels: [], depKey: '@angular/core' },
24
+ { label: 'TypeScript', altLabels: ['TS'], depKey: 'typescript' },
25
+ { label: 'Vite', altLabels: [], depKey: 'vite' },
26
+ { label: 'Express', altLabels: [], depKey: 'express' },
27
+ { label: 'Fastify', altLabels: [], depKey: 'fastify' },
28
+ { label: 'NestJS', altLabels: ['Nest.js', 'Nest'], depKey: '@nestjs/core' },
29
+ ];
30
+
31
+ function readPackageDeps(ctx) {
32
+ if (ctx.__nerviqPackageJsonDeps !== undefined) {
33
+ return ctx.__nerviqPackageJsonDeps;
34
+ }
35
+ if (!fileExists(ctx, 'package.json')) {
36
+ ctx.__nerviqPackageJsonDeps = null;
37
+ return null;
38
+ }
39
+ const raw = ctx.fileContent('package.json');
40
+ if (!raw) {
41
+ ctx.__nerviqPackageJsonDeps = null;
42
+ return null;
43
+ }
44
+ try {
45
+ const pkg = JSON.parse(raw);
46
+ const deps = {
47
+ ...(pkg.dependencies || {}),
48
+ ...(pkg.devDependencies || {}),
49
+ ...(pkg.peerDependencies || {}),
50
+ ...(pkg.optionalDependencies || {}),
51
+ };
52
+ ctx.__nerviqPackageJsonDeps = deps;
53
+ return deps;
54
+ } catch {
55
+ ctx.__nerviqPackageJsonDeps = null;
56
+ return null;
57
+ }
58
+ }
59
+
60
+ function extractMajor(versionRange) {
61
+ if (!versionRange || typeof versionRange !== 'string') return null;
62
+ // Strip leading range operators: ^, ~, >=, >, =, etc.
63
+ const m = versionRange.match(/(\d+)/);
64
+ if (!m) return null;
65
+ return parseInt(m[1], 10);
66
+ }
67
+
68
+ module.exports = {
69
+ key: 'agent-config-framework-version-mismatch',
70
+ name: 'Agent config references stale framework version',
71
+ severity: 'high',
72
+ layer: 'shallow-risk',
73
+ sourceUrl: SHALLOW_RISK_DOC_URL,
74
+ owaspTags: ['agentic-top-10:tool-instruction-integrity'],
75
+ run(ctx) {
76
+ const deps = readPackageDeps(ctx);
77
+ if (!deps) return [];
78
+
79
+ // Build framework lookup with the actual installed major version.
80
+ const installed = [];
81
+ for (const fw of FRAMEWORK_DEPS) {
82
+ const range = deps[fw.depKey];
83
+ if (!range) continue;
84
+ const major = extractMajor(range);
85
+ if (major === null) continue;
86
+ installed.push({ ...fw, range, major });
87
+ }
88
+ if (installed.length === 0) return [];
89
+
90
+ const findings = [];
91
+ const seen = new Set();
92
+
93
+ for (const entry of getAgentConfigEntries(ctx)) {
94
+ const lines = getScannableLines(entry.content);
95
+ for (const { lineNumber, text } of lines) {
96
+ for (const fw of installed) {
97
+ // Build a regex that matches: "Next.js 15", "Next 16", "next.js v15",
98
+ // "Next.js 15.0.0", "Tailwind 4", etc. We require a version number
99
+ // immediately after the framework label (with optional "v" prefix
100
+ // and optional whitespace).
101
+ const labelAlternatives = [fw.label, ...(fw.altLabels || [])]
102
+ .map((s) => s.replace(/[.*+?^${}()|[\]\\]/g, '\\$&'))
103
+ .join('|');
104
+ const versionRe = new RegExp(`\\b(${labelAlternatives})\\s+v?(\\d+)(?:\\.(\\d+))?(?:\\.(\\d+))?\\b`, 'gi');
105
+
106
+ let match;
107
+ while ((match = versionRe.exec(text)) !== null) {
108
+ const claimedMajor = parseInt(match[2], 10);
109
+ if (!Number.isFinite(claimedMajor)) continue;
110
+ if (claimedMajor === fw.major) continue;
111
+
112
+ // Skip historical references (e.g., "we migrated from Next 14 to
113
+ // Next 16" — both versions appear, only the lower one is stale,
114
+ // but flagging would cause FPs on legitimate migration notes).
115
+ // Heuristic: if the same line mentions the correct major number,
116
+ // assume migration context and skip.
117
+ if (new RegExp(`\\b${fw.major}\\b`).test(text)) continue;
118
+ // Skip lines explicitly noting the mismatch as a corrective note.
119
+ if (/\b(?:was|previously|used to|formerly|before)\b/i.test(text)) continue;
120
+ if (/\bdoes\s+(?:not|n['’]?t)\b/i.test(text)) continue;
121
+
122
+ const dedupeKey = `${entry.path}|${fw.depKey}`;
123
+ if (seen.has(dedupeKey)) continue;
124
+ seen.add(dedupeKey);
125
+
126
+ findings.push({
127
+ file: entry.path,
128
+ line: lineNumber,
129
+ fix: `${entry.path} references ${fw.label} ${claimedMajor}, but package.json declares ${fw.depKey}@${fw.range} (major ${fw.major}). Update the agent guidance to match the installed version.`,
130
+ });
131
+ }
132
+ }
133
+ }
134
+ }
135
+
136
+ return findings;
137
+ },
138
+ };