@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.
- package/CHANGELOG.md +1764 -1493
- package/README.md +568 -538
- package/SECURITY.md +78 -82
- package/bin/cli.js +2838 -2558
- package/docs/api-reference.md +356 -356
- package/docs/audit-fix.md +109 -0
- package/docs/autofix.md +3 -62
- package/docs/getting-started.md +1 -1
- package/docs/index.html +592 -592
- package/docs/integration-contracts.md +287 -287
- package/docs/maintenance.md +128 -128
- package/docs/new-platform-guide.md +202 -202
- package/docs/release-process.md +63 -0
- package/docs/shallow-risk.md +244 -244
- package/docs/why-nerviq.md +82 -82
- package/package.json +75 -67
- package/sdk/README.md +12 -3
- package/sdk/examples/langchain-integration.md +128 -0
- package/sdk/examples/self-governing-agent.js +135 -0
- package/sdk/index.d.ts +115 -0
- package/sdk/index.js +94 -0
- package/sdk/package.json +11 -0
- package/src/activity.js +13 -0
- package/src/aider/activity.js +226 -226
- package/src/aider/context.js +162 -162
- package/src/aider/freshness.js +123 -123
- package/src/aider/techniques.js +3465 -3465
- package/src/audit/layers.js +180 -180
- package/src/audit.js +1133 -1032
- package/src/auto-suggest.js +9 -2
- package/src/behavioral-drift.js +37 -2
- package/src/benchmark.js +299 -299
- package/src/codex/activity.js +324 -324
- package/src/codex/freshness.js +149 -142
- package/src/codex/techniques.js +4895 -4895
- package/src/context.js +326 -326
- package/src/continuous-ops.js +11 -1
- package/src/convert.js +340 -340
- package/src/copilot/config-parser.js +280 -280
- package/src/copilot/context.js +218 -218
- package/src/copilot/freshness.js +184 -177
- package/src/copilot/patch.js +238 -238
- package/src/copilot/techniques.js +3578 -3578
- package/src/cursor/freshness.js +194 -194
- package/src/cursor/patch.js +243 -243
- package/src/cursor/techniques.js +3735 -3735
- package/src/doctor.js +201 -201
- package/src/fix-engine.js +511 -8
- package/src/formatters/csv.js +86 -86
- package/src/formatters/junit.js +123 -123
- package/src/formatters/markdown.js +164 -164
- package/src/formatters/otel.js +151 -151
- package/src/freshness.js +163 -156
- package/src/gemini/activity.js +402 -402
- package/src/gemini/context.js +290 -290
- package/src/gemini/freshness.js +188 -188
- package/src/gemini/patch.js +229 -229
- package/src/gemini/techniques.js +3811 -3811
- package/src/governance.js +533 -533
- package/src/harmony/audit.js +306 -306
- package/src/i18n.js +63 -63
- package/src/insights.js +119 -119
- package/src/integrations.js +134 -134
- package/src/locales/en.json +33 -33
- package/src/locales/es.json +33 -33
- package/src/migrate.js +354 -354
- package/src/opencode/activity.js +286 -286
- package/src/opencode/freshness.js +137 -137
- package/src/opencode/techniques.js +3450 -3450
- package/src/safe-glyph.js +97 -0
- package/src/setup/analysis.js +12 -12
- package/src/setup.js +13 -6
- package/src/shallow-risk/index.js +113 -56
- package/src/shallow-risk/patterns/agent-config-cross-platform-drift.js +51 -50
- package/src/shallow-risk/patterns/agent-config-dangerous-autoapprove.js +47 -46
- package/src/shallow-risk/patterns/agent-config-deprecated-keys.js +47 -46
- package/src/shallow-risk/patterns/agent-config-framework-version-mismatch.js +138 -0
- package/src/shallow-risk/patterns/agent-config-missing-file.js +318 -317
- package/src/shallow-risk/patterns/agent-config-script-not-in-package-json.js +108 -0
- package/src/shallow-risk/patterns/agent-config-secret-literal.js +52 -49
- package/src/shallow-risk/patterns/agent-config-stack-contradiction.js +35 -34
- package/src/shallow-risk/patterns/hook-script-missing.js +71 -70
- package/src/shallow-risk/patterns/mcp-server-no-allowlist.js +53 -52
- package/src/shallow-risk/shared.js +653 -648
- package/src/source-urls.js +295 -295
- package/src/state-paths.js +85 -85
- package/src/supplemental-checks.js +805 -805
- package/src/telemetry.js +160 -160
- package/src/watch.js +46 -0
- package/src/windsurf/context.js +359 -359
- package/src/windsurf/freshness.js +194 -194
- package/src/windsurf/patch.js +231 -231
- 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
|
+
};
|