@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.
- package/README.md +176 -47
- package/bin/cli.js +842 -287
- package/package.json +2 -2
- package/src/activity.js +225 -59
- package/src/adoption-advisor.js +299 -0
- package/src/aider/freshness.js +28 -25
- package/src/aider/techniques.js +16 -11
- package/src/analyze.js +131 -1
- package/src/anti-patterns.js +17 -2
- package/src/audit.js +197 -96
- package/src/behavioral-drift.js +801 -0
- package/src/benchmark.js +15 -10
- package/src/continuous-ops.js +681 -0
- package/src/cost-tracking.js +61 -0
- package/src/cursor/techniques.js +17 -12
- package/src/deep-review.js +83 -0
- package/src/diff-only.js +280 -0
- package/src/doctor.js +118 -55
- package/src/governance.js +72 -50
- package/src/hook-validation.js +342 -0
- package/src/index.js +7 -1
- package/src/integrations.js +144 -60
- package/src/mcp-validation.js +337 -0
- package/src/opencode/techniques.js +12 -7
- package/src/operating-profile.js +574 -0
- package/src/org.js +97 -13
- package/src/permission-rules.js +218 -0
- package/src/plans.js +192 -8
- package/src/platform-change-manifest.js +86 -0
- package/src/policy-layers.js +210 -0
- package/src/profiles.js +4 -1
- package/src/prompt-injection.js +74 -0
- package/src/repo-archetype.js +386 -0
- package/src/secret-patterns.js +9 -0
- package/src/server.js +398 -3
- package/src/setup.js +36 -2
- package/src/source-urls.js +132 -132
- package/src/supplemental-checks.js +13 -12
- package/src/techniques/api.js +407 -0
- package/src/techniques/automation.js +316 -0
- package/src/techniques/compliance.js +257 -0
- package/src/techniques/hygiene.js +294 -0
- package/src/techniques/instructions.js +243 -0
- package/src/techniques/observability.js +226 -0
- package/src/techniques/optimization.js +142 -0
- package/src/techniques/quality.js +317 -0
- package/src/techniques/security.js +237 -0
- package/src/techniques/shared.js +443 -0
- package/src/techniques/stacks.js +2294 -0
- package/src/techniques/tools.js +106 -0
- package/src/techniques/workflow.js +413 -0
- package/src/techniques.js +78 -5611
- package/src/terminology.js +73 -0
- package/src/token-estimate.js +35 -0
- package/src/watch.js +18 -0
- package/src/windsurf/techniques.js +17 -12
- package/src/workspace.js +105 -8
|
@@ -0,0 +1,299 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
const { getMcpPackPreflight } = require('./mcp-packs');
|
|
4
|
+
|
|
5
|
+
const DECISION_ORDER = { adopt: 0, defer: 1, ignore: 2 };
|
|
6
|
+
|
|
7
|
+
function unique(values) {
|
|
8
|
+
return [...new Set((values || []).filter(Boolean))];
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
function makeItem(item) {
|
|
12
|
+
return {
|
|
13
|
+
decision: item.decision,
|
|
14
|
+
kind: item.kind,
|
|
15
|
+
key: item.key,
|
|
16
|
+
label: item.label,
|
|
17
|
+
why: item.why,
|
|
18
|
+
evidence: unique(item.evidence),
|
|
19
|
+
prerequisites: unique(item.prerequisites),
|
|
20
|
+
expectedBenefit: item.expectedBenefit,
|
|
21
|
+
rollbackSafety: item.rollbackSafety,
|
|
22
|
+
};
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
function summarize(items = []) {
|
|
26
|
+
const counts = items.reduce((acc, item) => {
|
|
27
|
+
acc[item.decision] = (acc[item.decision] || 0) + 1;
|
|
28
|
+
return acc;
|
|
29
|
+
}, { adopt: 0, defer: 0, ignore: 0 });
|
|
30
|
+
|
|
31
|
+
return {
|
|
32
|
+
adopt: counts.adopt || 0,
|
|
33
|
+
defer: counts.defer || 0,
|
|
34
|
+
ignore: counts.ignore || 0,
|
|
35
|
+
label: `${counts.adopt || 0} adopt now / ${counts.defer || 0} defer / ${counts.ignore || 0} ignore`,
|
|
36
|
+
};
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
function inferMcpPackPrerequisites(pack, preflightEntry) {
|
|
40
|
+
const prerequisites = [];
|
|
41
|
+
if (preflightEntry && Array.isArray(preflightEntry.missingEnvVars) && preflightEntry.missingEnvVars.length > 0) {
|
|
42
|
+
prerequisites.push(`Provide required env vars: ${preflightEntry.missingEnvVars.join(', ')}`);
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
if (/Pass connection string as CLI argument/i.test(pack.adoption || '')) {
|
|
46
|
+
prerequisites.push('Provide a live connection string or DATABASE_URL before enabling this MCP pack.');
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
if (/Docker running locally/i.test(pack.adoption || '')) {
|
|
50
|
+
prerequisites.push('Docker must be running locally before this MCP pack is useful.');
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
if (/OAuth/i.test(pack.adoption || '')) {
|
|
54
|
+
prerequisites.push('Complete the OAuth or external auth setup before enabling this MCP pack in shared flows.');
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
if (/community-maintained/i.test(pack.adoption || '')) {
|
|
58
|
+
prerequisites.push('Review the package trust/update posture before enabling it in a wider team baseline.');
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
return unique(prerequisites);
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
function buildIgnoreItems(repoArchetype, operatingProfile, recommendedDomainPacks = []) {
|
|
65
|
+
const items = [];
|
|
66
|
+
const domainKeys = new Set((recommendedDomainPacks || []).map((pack) => pack.key));
|
|
67
|
+
|
|
68
|
+
if (operatingProfile.platformSupport.strategy === 'single-platform-baseline') {
|
|
69
|
+
items.push(makeItem({
|
|
70
|
+
decision: 'ignore',
|
|
71
|
+
kind: 'platform-expansion',
|
|
72
|
+
key: 'broad-platform-expansion',
|
|
73
|
+
label: 'Broad multi-platform expansion',
|
|
74
|
+
why: 'This repo should stabilize one governed primary platform before adding more AI surfaces.',
|
|
75
|
+
evidence: [
|
|
76
|
+
`Platform strategy: ${operatingProfile.platformSupport.strategy}`,
|
|
77
|
+
`Archetype: ${repoArchetype.label}`,
|
|
78
|
+
],
|
|
79
|
+
prerequisites: [],
|
|
80
|
+
expectedBenefit: 'Prevents governance drift caused by widening the tool surface too early.',
|
|
81
|
+
rollbackSafety: 'Nothing is applied here; this is an intentional skip until the baseline matures.',
|
|
82
|
+
}));
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
if (repoArchetype.topology.key !== 'monorepo') {
|
|
86
|
+
items.push(makeItem({
|
|
87
|
+
decision: 'ignore',
|
|
88
|
+
kind: 'ci-shape',
|
|
89
|
+
key: 'workspace-pr-gate',
|
|
90
|
+
label: 'Workspace-aware PR gate',
|
|
91
|
+
why: 'Workspace-specific CI complexity does not match a non-monorepo repo shape.',
|
|
92
|
+
evidence: [
|
|
93
|
+
`Topology: ${repoArchetype.topology.label}`,
|
|
94
|
+
'No monorepo-specific governance surface is required.',
|
|
95
|
+
],
|
|
96
|
+
prerequisites: [],
|
|
97
|
+
expectedBenefit: 'Keeps the operating model lean and aligned to the real repo topology.',
|
|
98
|
+
rollbackSafety: 'This is a deliberate skip; no cleanup is required.',
|
|
99
|
+
}));
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
if (repoArchetype.riskProfile.key !== 'regulated' && !domainKeys.has('regulated-lite') && !domainKeys.has('security-focused')) {
|
|
103
|
+
items.push(makeItem({
|
|
104
|
+
decision: 'ignore',
|
|
105
|
+
kind: 'governance-pack',
|
|
106
|
+
key: 'regulated-lite',
|
|
107
|
+
label: 'Regulated-lite governance overhead',
|
|
108
|
+
why: 'The repo does not show regulated or security-heavy signals strong enough to justify this heavier rollout pack.',
|
|
109
|
+
evidence: [
|
|
110
|
+
`Risk posture: ${repoArchetype.riskProfile.label}`,
|
|
111
|
+
],
|
|
112
|
+
prerequisites: [],
|
|
113
|
+
expectedBenefit: 'Preserves a lighter rollout model and avoids over-governing normal product repos.',
|
|
114
|
+
rollbackSafety: 'This is a no-op skip; the repo can adopt a heavier pack later if evidence changes.',
|
|
115
|
+
}));
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
if (repoArchetype.stackFamily.key !== 'mobile' && !domainKeys.has('mobile')) {
|
|
119
|
+
items.push(makeItem({
|
|
120
|
+
decision: 'ignore',
|
|
121
|
+
kind: 'verification',
|
|
122
|
+
key: 'mobile-release-loop',
|
|
123
|
+
label: 'Mobile release workflow extras',
|
|
124
|
+
why: 'Mobile-only analyze/build workflow overhead should not be forced onto a non-mobile repo.',
|
|
125
|
+
evidence: [
|
|
126
|
+
`Stack family: ${repoArchetype.stackFamily.label}`,
|
|
127
|
+
],
|
|
128
|
+
prerequisites: [],
|
|
129
|
+
expectedBenefit: 'Avoids irrelevant workflow ceremony and keeps verification recommendations credible.',
|
|
130
|
+
rollbackSafety: 'No rollback is needed because the capability is being intentionally skipped.',
|
|
131
|
+
}));
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
return items.slice(0, 3);
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
function buildAdoptionAdvisor(options) {
|
|
138
|
+
const {
|
|
139
|
+
platform,
|
|
140
|
+
repoArchetype,
|
|
141
|
+
recommendedOperatingProfile,
|
|
142
|
+
recommendedDomainPacks = [],
|
|
143
|
+
recommendedMcpPacks = [],
|
|
144
|
+
env = {},
|
|
145
|
+
} = options || {};
|
|
146
|
+
|
|
147
|
+
const items = [];
|
|
148
|
+
const mcpPreflightByKey = new Map(
|
|
149
|
+
getMcpPackPreflight((recommendedMcpPacks || []).map((pack) => pack.key), env).map((entry) => [entry.key, entry])
|
|
150
|
+
);
|
|
151
|
+
|
|
152
|
+
items.push(makeItem({
|
|
153
|
+
decision: 'adopt',
|
|
154
|
+
kind: 'platform-strategy',
|
|
155
|
+
key: recommendedOperatingProfile.platformSupport.strategy,
|
|
156
|
+
label: `Platform strategy: ${recommendedOperatingProfile.platformSupport.strategy}`,
|
|
157
|
+
why: recommendedOperatingProfile.platformSupport.why,
|
|
158
|
+
evidence: recommendedOperatingProfile.platformSupport.evidence,
|
|
159
|
+
prerequisites: recommendedOperatingProfile.platformSupport.prerequisites,
|
|
160
|
+
expectedBenefit: recommendedOperatingProfile.platformSupport.expectedBenefit,
|
|
161
|
+
rollbackSafety: recommendedOperatingProfile.platformSupport.rollbackSafety,
|
|
162
|
+
}));
|
|
163
|
+
|
|
164
|
+
if (recommendedOperatingProfile.platformSupport.optionalExpansion) {
|
|
165
|
+
items.push(makeItem({
|
|
166
|
+
decision: 'defer',
|
|
167
|
+
kind: 'platform-expansion',
|
|
168
|
+
key: `secondary-${recommendedOperatingProfile.platformSupport.optionalExpansion}`,
|
|
169
|
+
label: `Add ${recommendedOperatingProfile.platformSupport.optionalExpansion} as a secondary review surface`,
|
|
170
|
+
why: 'A secondary platform could help later, but the repo should stabilize its primary governed posture first.',
|
|
171
|
+
evidence: recommendedOperatingProfile.platformSupport.evidence,
|
|
172
|
+
prerequisites: [
|
|
173
|
+
'Capture tagged baseline and post-fix snapshots first.',
|
|
174
|
+
'Keep Harmony stable across the currently active platform surface.',
|
|
175
|
+
],
|
|
176
|
+
expectedBenefit: 'Adds a complementary advisory surface only after the core posture is already reliable.',
|
|
177
|
+
rollbackSafety: 'Secondary platform expansion is optional and can be removed without changing the app codebase.',
|
|
178
|
+
}));
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
items.push(makeItem({
|
|
182
|
+
decision: 'adopt',
|
|
183
|
+
kind: 'permission-profile',
|
|
184
|
+
key: recommendedOperatingProfile.permissionProfile.key,
|
|
185
|
+
label: `Permission profile: ${recommendedOperatingProfile.permissionProfile.label}`,
|
|
186
|
+
why: recommendedOperatingProfile.permissionProfile.why,
|
|
187
|
+
evidence: recommendedOperatingProfile.permissionProfile.evidence,
|
|
188
|
+
prerequisites: recommendedOperatingProfile.permissionProfile.prerequisites,
|
|
189
|
+
expectedBenefit: recommendedOperatingProfile.permissionProfile.expectedBenefit,
|
|
190
|
+
rollbackSafety: recommendedOperatingProfile.permissionProfile.rollbackSafety,
|
|
191
|
+
}));
|
|
192
|
+
|
|
193
|
+
items.push(makeItem({
|
|
194
|
+
decision: 'adopt',
|
|
195
|
+
kind: 'governance-pack',
|
|
196
|
+
key: recommendedOperatingProfile.governancePack.key,
|
|
197
|
+
label: `Governance pack: ${recommendedOperatingProfile.governancePack.label}`,
|
|
198
|
+
why: recommendedOperatingProfile.governancePack.why,
|
|
199
|
+
evidence: recommendedOperatingProfile.governancePack.evidence,
|
|
200
|
+
prerequisites: recommendedOperatingProfile.governancePack.prerequisites,
|
|
201
|
+
expectedBenefit: recommendedOperatingProfile.governancePack.expectedBenefit,
|
|
202
|
+
rollbackSafety: recommendedOperatingProfile.governancePack.rollbackSafety,
|
|
203
|
+
}));
|
|
204
|
+
|
|
205
|
+
items.push(makeItem({
|
|
206
|
+
decision: 'adopt',
|
|
207
|
+
kind: 'hook-set',
|
|
208
|
+
key: 'starter-hooks',
|
|
209
|
+
label: `Starter hook set: ${recommendedOperatingProfile.hooks.map((hook) => hook.key).join(', ')}`,
|
|
210
|
+
why: 'These hooks are the lowest-friction set that matches the repo trust boundary, logging needs, and review posture.',
|
|
211
|
+
evidence: unique(recommendedOperatingProfile.hooks.flatMap((hook) => hook.evidence || []).slice(0, 5)),
|
|
212
|
+
prerequisites: unique(recommendedOperatingProfile.hooks.flatMap((hook) => hook.prerequisites || [])),
|
|
213
|
+
expectedBenefit: 'Adds secret protection, trust-boundary checks, and durable change evidence without widening the product surface.',
|
|
214
|
+
rollbackSafety: 'Each hook can be removed independently from repo settings if it proves noisy.',
|
|
215
|
+
}));
|
|
216
|
+
|
|
217
|
+
items.push(makeItem({
|
|
218
|
+
decision: 'adopt',
|
|
219
|
+
kind: 'verification-loop',
|
|
220
|
+
key: recommendedOperatingProfile.verification.key,
|
|
221
|
+
label: `Verification loop: ${recommendedOperatingProfile.verification.label}`,
|
|
222
|
+
why: recommendedOperatingProfile.verification.why,
|
|
223
|
+
evidence: recommendedOperatingProfile.verification.evidence,
|
|
224
|
+
prerequisites: recommendedOperatingProfile.verification.prerequisites,
|
|
225
|
+
expectedBenefit: recommendedOperatingProfile.verification.expectedBenefit,
|
|
226
|
+
rollbackSafety: recommendedOperatingProfile.verification.rollbackSafety,
|
|
227
|
+
}));
|
|
228
|
+
|
|
229
|
+
items.push(makeItem({
|
|
230
|
+
decision: 'adopt',
|
|
231
|
+
kind: 'ci-shape',
|
|
232
|
+
key: recommendedOperatingProfile.ciShape.key,
|
|
233
|
+
label: `CI shape: ${recommendedOperatingProfile.ciShape.label}`,
|
|
234
|
+
why: recommendedOperatingProfile.ciShape.why,
|
|
235
|
+
evidence: recommendedOperatingProfile.ciShape.evidence,
|
|
236
|
+
prerequisites: recommendedOperatingProfile.ciShape.prerequisites,
|
|
237
|
+
expectedBenefit: recommendedOperatingProfile.ciShape.expectedBenefit,
|
|
238
|
+
rollbackSafety: recommendedOperatingProfile.ciShape.rollbackSafety,
|
|
239
|
+
}));
|
|
240
|
+
|
|
241
|
+
for (const pack of recommendedDomainPacks) {
|
|
242
|
+
items.push(makeItem({
|
|
243
|
+
decision: 'adopt',
|
|
244
|
+
kind: 'domain-pack',
|
|
245
|
+
key: pack.key,
|
|
246
|
+
label: `Domain pack: ${pack.label}`,
|
|
247
|
+
why: pack.useWhen,
|
|
248
|
+
evidence: unique([...(pack.matchReasons || []), `Archetype: ${repoArchetype.label}`]).slice(0, 5),
|
|
249
|
+
prerequisites: [
|
|
250
|
+
`Review the pack modules before applying them: ${(pack.recommendedModules || []).slice(0, 4).join(', ') || 'no starter modules listed'}`,
|
|
251
|
+
],
|
|
252
|
+
expectedBenefit: (pack.benchmarkFocus || []).length > 0
|
|
253
|
+
? `Improves Nerviq's relevance around ${pack.benchmarkFocus.slice(0, 3).join(', ')}.`
|
|
254
|
+
: 'Makes Nerviq recommendations more domain-aware for this repo.',
|
|
255
|
+
rollbackSafety: 'Domain packs are additive guidance. You can remove a pack from the recommended stack without rewriting the repo.',
|
|
256
|
+
}));
|
|
257
|
+
}
|
|
258
|
+
|
|
259
|
+
if (platform === 'claude') {
|
|
260
|
+
for (const pack of recommendedMcpPacks) {
|
|
261
|
+
const preflight = mcpPreflightByKey.get(pack.key);
|
|
262
|
+
const prerequisites = inferMcpPackPrerequisites(pack, preflight);
|
|
263
|
+
const decision = prerequisites.length > 0 ? 'defer' : 'adopt';
|
|
264
|
+
items.push(makeItem({
|
|
265
|
+
decision,
|
|
266
|
+
kind: 'mcp-pack',
|
|
267
|
+
key: pack.key,
|
|
268
|
+
label: `MCP pack: ${pack.label}`,
|
|
269
|
+
why: pack.useWhen,
|
|
270
|
+
evidence: unique([pack.adoption, `Repo archetype: ${repoArchetype.label}`]).slice(0, 4),
|
|
271
|
+
prerequisites,
|
|
272
|
+
expectedBenefit: pack.adoption,
|
|
273
|
+
rollbackSafety: 'MCP packs are optional integrations; they can be added or removed from settings without changing application source code.',
|
|
274
|
+
}));
|
|
275
|
+
}
|
|
276
|
+
}
|
|
277
|
+
|
|
278
|
+
items.push(...buildIgnoreItems(repoArchetype, recommendedOperatingProfile, recommendedDomainPacks));
|
|
279
|
+
|
|
280
|
+
const sorted = items
|
|
281
|
+
.sort((a, b) => {
|
|
282
|
+
const decisionDiff = (DECISION_ORDER[a.decision] || 99) - (DECISION_ORDER[b.decision] || 99);
|
|
283
|
+
if (decisionDiff !== 0) return decisionDiff;
|
|
284
|
+
return a.label.localeCompare(b.label);
|
|
285
|
+
})
|
|
286
|
+
.map((item, index) => ({
|
|
287
|
+
priority: index + 1,
|
|
288
|
+
...item,
|
|
289
|
+
}));
|
|
290
|
+
|
|
291
|
+
return {
|
|
292
|
+
summary: summarize(sorted),
|
|
293
|
+
items: sorted,
|
|
294
|
+
};
|
|
295
|
+
}
|
|
296
|
+
|
|
297
|
+
module.exports = {
|
|
298
|
+
buildAdoptionAdvisor,
|
|
299
|
+
};
|
package/src/aider/freshness.js
CHANGED
|
@@ -93,11 +93,11 @@ const PROPAGATION_CHECKLIST = [
|
|
|
93
93
|
];
|
|
94
94
|
|
|
95
95
|
/**
|
|
96
|
-
* Check release gate — are all P0 sources fresh?
|
|
97
|
-
*/
|
|
98
|
-
function checkReleaseGate(overrides = {}) {
|
|
99
|
-
const now = new Date();
|
|
100
|
-
const results = P0_SOURCES.map(source => {
|
|
96
|
+
* Check release gate — are all P0 sources fresh?
|
|
97
|
+
*/
|
|
98
|
+
function checkReleaseGate(overrides = {}) {
|
|
99
|
+
const now = new Date();
|
|
100
|
+
const results = P0_SOURCES.map(source => {
|
|
101
101
|
const verifiedAt = overrides[source.key] || source.verifiedAt;
|
|
102
102
|
if (!verifiedAt) {
|
|
103
103
|
return { ...source, status: 'unverified', daysStale: null };
|
|
@@ -114,26 +114,29 @@ function checkReleaseGate(overrides = {}) {
|
|
|
114
114
|
};
|
|
115
115
|
});
|
|
116
116
|
|
|
117
|
-
const
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
117
|
+
const stale = results.filter((result) => result.status === 'stale' || result.status === 'unverified');
|
|
118
|
+
const fresh = results.filter((result) => result.status === 'fresh');
|
|
119
|
+
const allFresh = stale.length === 0;
|
|
120
|
+
|
|
121
|
+
return {
|
|
122
|
+
ready: allFresh,
|
|
123
|
+
stale,
|
|
124
|
+
fresh,
|
|
125
|
+
results,
|
|
126
|
+
nerviqVersion: version,
|
|
127
|
+
checkedAt: now.toISOString(),
|
|
128
|
+
};
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
/**
|
|
132
|
+
* Format release gate for display.
|
|
133
|
+
*/
|
|
134
|
+
function formatReleaseGate(gateResult) {
|
|
135
|
+
const lines = [
|
|
136
|
+
`Aider Release Freshness Gate (nerviq v${version})`,
|
|
137
|
+
`Status: ${gateResult.ready ? 'READY' : 'NOT READY'}`,
|
|
138
|
+
'',
|
|
139
|
+
];
|
|
137
140
|
|
|
138
141
|
for (const result of gateResult.results) {
|
|
139
142
|
const icon = result.status === 'fresh' ? '✓' : result.status === 'stale' ? '✗' : '?';
|
package/src/aider/techniques.js
CHANGED
|
@@ -19,10 +19,11 @@
|
|
|
19
19
|
* Check ID prefix: AD-
|
|
20
20
|
*/
|
|
21
21
|
|
|
22
|
-
const { containsEmbeddedSecret } = require('../secret-patterns');
|
|
23
|
-
const { attachSourceUrls } = require('../source-urls');
|
|
24
|
-
const { buildStackChecks } = require('../stack-checks');
|
|
25
|
-
const { isApiProject, isDatabaseProject, isAuthProject, isMonitoringRelevant } = require('../supplemental-checks');
|
|
22
|
+
const { containsEmbeddedSecret } = require('../secret-patterns');
|
|
23
|
+
const { attachSourceUrls } = require('../source-urls');
|
|
24
|
+
const { buildStackChecks } = require('../stack-checks');
|
|
25
|
+
const { isApiProject, isDatabaseProject, isAuthProject, isMonitoringRelevant } = require('../supplemental-checks');
|
|
26
|
+
const { hasCostBudgetOrUsageTracking } = require('../cost-tracking');
|
|
26
27
|
|
|
27
28
|
const FILLER_PATTERNS = [
|
|
28
29
|
/\bbe helpful\b/i,
|
|
@@ -1724,13 +1725,17 @@ const AIDER_TECHNIQUES = {
|
|
|
1724
1725
|
fix: 'Set `cache-prompts: true` in .aider.conf.yml to reduce API costs.',
|
|
1725
1726
|
template: 'aider-conf-yml', file: () => '.aider.conf.yml', line: () => null,
|
|
1726
1727
|
},
|
|
1727
|
-
aiderCostBudgetDefined: {
|
|
1728
|
-
id: 'AD-T48', name: 'AI cost budget or usage
|
|
1729
|
-
check: (ctx) => {
|
|
1730
|
-
|
|
1731
|
-
|
|
1732
|
-
|
|
1733
|
-
|
|
1728
|
+
aiderCostBudgetDefined: {
|
|
1729
|
+
id: 'AD-T48', name: 'AI cost budget or per-run usage tracking documented',
|
|
1730
|
+
check: (ctx) => {
|
|
1731
|
+
const docs = conventionContent(ctx) + (ctx.fileContent('README.md') || '');
|
|
1732
|
+
if (!docs.trim() && !hasCostBudgetOrUsageTracking('', ctx)) return null;
|
|
1733
|
+
return hasCostBudgetOrUsageTracking(docs, ctx);
|
|
1734
|
+
},
|
|
1735
|
+
impact: 'low', rating: 2, category: 'cost-optimization',
|
|
1736
|
+
fix: 'Document AI cost guardrails or per-run usage tracking so Aider usage is visible run by run.',
|
|
1737
|
+
template: null, file: () => 'README.md', line: () => null,
|
|
1738
|
+
},
|
|
1734
1739
|
|
|
1735
1740
|
// ============================================================
|
|
1736
1741
|
// === PYTHON STACK CHECKS (category: 'python') ===============
|
package/src/analyze.js
CHANGED
|
@@ -11,6 +11,10 @@ const { STACKS } = require('./techniques');
|
|
|
11
11
|
const { detectDomainPacks } = require('./domain-packs');
|
|
12
12
|
const { detectCodexDomainPacks } = require('./codex/domain-packs');
|
|
13
13
|
const { recommendMcpPacks } = require('./mcp-packs');
|
|
14
|
+
const { collectClaudeDenyRules } = require('./permission-rules');
|
|
15
|
+
const { buildRepoArchetypeProfile } = require('./repo-archetype');
|
|
16
|
+
const { buildOperatingProfile } = require('./operating-profile');
|
|
17
|
+
const { buildAdoptionAdvisor } = require('./adoption-advisor');
|
|
14
18
|
|
|
15
19
|
const COLORS = {
|
|
16
20
|
reset: '\x1b[0m',
|
|
@@ -101,6 +105,7 @@ function collectClaudeAssets(ctx) {
|
|
|
101
105
|
const sharedSettings = ctx.jsonFile('.claude/settings.json');
|
|
102
106
|
const localSettings = ctx.jsonFile('.claude/settings.local.json');
|
|
103
107
|
const settings = sharedSettings || localSettings || null;
|
|
108
|
+
const denyRules = collectClaudeDenyRules(ctx);
|
|
104
109
|
|
|
105
110
|
const assetFiles = {
|
|
106
111
|
claudeMd: ctx.fileContent('CLAUDE.md') ? 'CLAUDE.md' : (ctx.fileContent('.claude/CLAUDE.md') ? '.claude/CLAUDE.md' : null),
|
|
@@ -129,7 +134,7 @@ function collectClaudeAssets(ctx) {
|
|
|
129
134
|
},
|
|
130
135
|
permissions: settings && settings.permissions ? {
|
|
131
136
|
defaultMode: settings.permissions.defaultMode || null,
|
|
132
|
-
hasDenyRules:
|
|
137
|
+
hasDenyRules: denyRules.length > 0,
|
|
133
138
|
} : null,
|
|
134
139
|
settingsSource: assetFiles.settings,
|
|
135
140
|
summaryLine: `Commands: ${assetFiles.commands.length} | Rules: ${assetFiles.rules.length} | Hooks: ${assetFiles.hooks.length} | Agents: ${assetFiles.agents.length} | Skills: ${assetFiles.skills.length} | MCP servers: ${settings && settings.mcpServers ? Object.keys(settings.mcpServers).length : 0}`,
|
|
@@ -496,6 +501,30 @@ async function analyzeProject(options) {
|
|
|
496
501
|
? detectCodexDomainPacks(ctx, stacks, assets)
|
|
497
502
|
: detectDomainPacks(ctx, stacks, assets);
|
|
498
503
|
const recommendedMcpPacks = platform === 'claude' ? recommendMcpPacks(stacks, recommendedDomainPacks, { ctx, assets }) : [];
|
|
504
|
+
const repoArchetype = buildRepoArchetypeProfile({
|
|
505
|
+
ctx,
|
|
506
|
+
platform,
|
|
507
|
+
stacks,
|
|
508
|
+
assets,
|
|
509
|
+
recommendedDomainPacks,
|
|
510
|
+
recommendedMcpPacks,
|
|
511
|
+
maturity,
|
|
512
|
+
});
|
|
513
|
+
const recommendedOperatingProfile = buildOperatingProfile({
|
|
514
|
+
dir: options.dir,
|
|
515
|
+
platform,
|
|
516
|
+
repoArchetype,
|
|
517
|
+
recommendedDomainPacks,
|
|
518
|
+
recommendedMcpPacks,
|
|
519
|
+
});
|
|
520
|
+
const adoptionGuidance = buildAdoptionAdvisor({
|
|
521
|
+
platform,
|
|
522
|
+
repoArchetype,
|
|
523
|
+
recommendedOperatingProfile,
|
|
524
|
+
recommendedDomainPacks,
|
|
525
|
+
recommendedMcpPacks,
|
|
526
|
+
env: options.env || {},
|
|
527
|
+
});
|
|
499
528
|
|
|
500
529
|
const report = {
|
|
501
530
|
platform,
|
|
@@ -509,16 +538,28 @@ async function analyzeProject(options) {
|
|
|
509
538
|
stacks: stacks.map(s => s.label),
|
|
510
539
|
domains: recommendedDomainPacks.map(pack => pack.label),
|
|
511
540
|
maturity,
|
|
541
|
+
archetype: repoArchetype.label,
|
|
542
|
+
workflow: repoArchetype.primaryWorkflow.label,
|
|
543
|
+
riskLevel: repoArchetype.riskProfile.label,
|
|
544
|
+
operatingProfile: recommendedOperatingProfile.label,
|
|
545
|
+
adoptionPlan: adoptionGuidance.summary.label,
|
|
512
546
|
score: auditResult.score,
|
|
513
547
|
organicScore: auditResult.organicScore,
|
|
514
548
|
checkCount: auditResult.checkCount,
|
|
515
549
|
},
|
|
516
550
|
platformScopeNote: auditResult.platformScopeNote || null,
|
|
517
551
|
platformCaveats: auditResult.platformCaveats || [],
|
|
552
|
+
repoArchetype,
|
|
553
|
+
recommendedOperatingProfile,
|
|
554
|
+
adoptionGuidance,
|
|
518
555
|
detectedArchitecture: {
|
|
519
556
|
repoType: stacks.length > 0 ? 'stack-detected repo' : 'generic repo',
|
|
520
557
|
mainDirectories: mainDirs,
|
|
521
558
|
stackSignals: stacks.map(s => s.key),
|
|
559
|
+
stackFamily: repoArchetype.stackFamily.label,
|
|
560
|
+
topology: repoArchetype.topology.label,
|
|
561
|
+
workflow: repoArchetype.primaryWorkflow.label,
|
|
562
|
+
riskLevel: repoArchetype.riskProfile.label,
|
|
522
563
|
},
|
|
523
564
|
existingPlatformAssets: assets,
|
|
524
565
|
strengthsPreserved: toStrengths(auditResult.results),
|
|
@@ -583,11 +624,14 @@ function printAnalysis(report, options = {}) {
|
|
|
583
624
|
} else {
|
|
584
625
|
console.log(c(` Platform: ${report.platformLabel}`, 'dim'));
|
|
585
626
|
}
|
|
627
|
+
console.log(c(` Archetype: ${report.repoArchetype.label} | Workflow: ${report.repoArchetype.primaryWorkflow.label} | Risk: ${report.repoArchetype.riskProfile.label}`, 'dim'));
|
|
586
628
|
console.log(c(` Maturity: ${report.projectSummary.maturity} | Score: ${report.projectSummary.score}/100 | Organic: ${report.projectSummary.organicScore}/100`, 'dim'));
|
|
587
629
|
console.log('');
|
|
588
630
|
|
|
589
631
|
console.log(c(' Detected Architecture', 'blue'));
|
|
632
|
+
console.log(c(` Stack family: ${report.repoArchetype.stackFamily.label} | Topology: ${report.repoArchetype.topology.label} | Confidence: ${report.repoArchetype.confidence}`, 'dim'));
|
|
590
633
|
console.log(c(` Main directories: ${report.detectedArchitecture.mainDirectories.join(', ') || 'No strong structure detected yet'}`, 'dim'));
|
|
634
|
+
console.log(c(` Signals: ${report.repoArchetype.signals.join(' | ') || 'No strong archetype signals yet'}`, 'dim'));
|
|
591
635
|
console.log('');
|
|
592
636
|
|
|
593
637
|
console.log(c(` Existing ${report.existingPlatformAssets.label} Assets`, 'blue'));
|
|
@@ -681,6 +725,36 @@ function printAnalysis(report, options = {}) {
|
|
|
681
725
|
console.log('');
|
|
682
726
|
}
|
|
683
727
|
|
|
728
|
+
if (report.recommendedOperatingProfile) {
|
|
729
|
+
console.log(c(' Recommended Operating Profile', 'blue'));
|
|
730
|
+
console.log(` ${report.recommendedOperatingProfile.label}`);
|
|
731
|
+
console.log(c(` Permission: ${report.recommendedOperatingProfile.permissionProfile.label} | Governance pack: ${report.recommendedOperatingProfile.governancePack.label}`, 'dim'));
|
|
732
|
+
console.log(c(` CI shape: ${report.recommendedOperatingProfile.ciShape.label} | Platforms: ${(report.recommendedOperatingProfile.platformSupport.recommended || []).join(', ') || report.platformLabel}`, 'dim'));
|
|
733
|
+
console.log(c(` Hooks: ${report.recommendedOperatingProfile.hooks.map((hook) => hook.key).join(', ')}`, 'dim'));
|
|
734
|
+
console.log(c(` Verification: ${report.recommendedOperatingProfile.verification.required.join(', ')}`, 'dim'));
|
|
735
|
+
console.log('');
|
|
736
|
+
}
|
|
737
|
+
|
|
738
|
+
if (report.adoptionGuidance && Array.isArray(report.adoptionGuidance.items) && report.adoptionGuidance.items.length > 0) {
|
|
739
|
+
console.log(c(' Adopt / Defer / Ignore', 'blue'));
|
|
740
|
+
console.log(c(` ${report.adoptionGuidance.summary.label}`, 'dim'));
|
|
741
|
+
const groups = [
|
|
742
|
+
['adopt', 'Adopt now'],
|
|
743
|
+
['defer', 'Defer until prerequisites are ready'],
|
|
744
|
+
['ignore', 'Ignore for this repo shape'],
|
|
745
|
+
];
|
|
746
|
+
for (const [decision, label] of groups) {
|
|
747
|
+
const items = report.adoptionGuidance.items.filter((item) => item.decision === decision).slice(0, 3);
|
|
748
|
+
if (items.length === 0) continue;
|
|
749
|
+
console.log(` ${label}`);
|
|
750
|
+
for (const item of items) {
|
|
751
|
+
console.log(` - ${item.label}`);
|
|
752
|
+
console.log(c(` ${item.why}`, 'dim'));
|
|
753
|
+
}
|
|
754
|
+
}
|
|
755
|
+
console.log('');
|
|
756
|
+
}
|
|
757
|
+
|
|
684
758
|
if (report.suggestedRolloutOrder.length > 0) {
|
|
685
759
|
console.log(c(' Suggested Rollout Order', 'blue'));
|
|
686
760
|
report.suggestedRolloutOrder.forEach((item, index) => {
|
|
@@ -708,6 +782,11 @@ function exportMarkdown(report) {
|
|
|
708
782
|
if (report.platform === 'claude') {
|
|
709
783
|
lines.push(`**Domain Packs:** ${report.projectSummary.domains.join(', ') || 'Baseline General'}`);
|
|
710
784
|
}
|
|
785
|
+
lines.push(`**Archetype:** ${report.repoArchetype.label}`);
|
|
786
|
+
lines.push(`**Workflow:** ${report.repoArchetype.primaryWorkflow.label}`);
|
|
787
|
+
lines.push(`**Risk posture:** ${report.repoArchetype.riskProfile.label}`);
|
|
788
|
+
lines.push(`**Operating profile:** ${report.recommendedOperatingProfile.label}`);
|
|
789
|
+
lines.push(`**Adoption plan:** ${report.adoptionGuidance.summary.label}`);
|
|
711
790
|
lines.push(`**Maturity:** ${report.projectSummary.maturity}`);
|
|
712
791
|
lines.push('');
|
|
713
792
|
|
|
@@ -728,6 +807,57 @@ function exportMarkdown(report) {
|
|
|
728
807
|
}
|
|
729
808
|
lines.push('');
|
|
730
809
|
|
|
810
|
+
lines.push('## Repo Archetype');
|
|
811
|
+
lines.push('');
|
|
812
|
+
lines.push(`- **Label:** ${report.repoArchetype.label}`);
|
|
813
|
+
lines.push(`- **Summary:** ${report.repoArchetype.summary}`);
|
|
814
|
+
lines.push(`- **Stack family:** ${report.repoArchetype.stackFamily.label}`);
|
|
815
|
+
lines.push(`- **Topology:** ${report.repoArchetype.topology.label}`);
|
|
816
|
+
lines.push(`- **Primary workflow:** ${report.repoArchetype.primaryWorkflow.label}`);
|
|
817
|
+
lines.push(`- **Risk posture:** ${report.repoArchetype.riskProfile.label}`);
|
|
818
|
+
lines.push(`- **Confidence:** ${report.repoArchetype.confidence}`);
|
|
819
|
+
if (report.repoArchetype.signals.length > 0) {
|
|
820
|
+
lines.push(`- **Signals:** ${report.repoArchetype.signals.join(', ')}`);
|
|
821
|
+
}
|
|
822
|
+
lines.push('');
|
|
823
|
+
|
|
824
|
+
lines.push('## Recommended Operating Profile');
|
|
825
|
+
lines.push('');
|
|
826
|
+
lines.push(`- **Label:** ${report.recommendedOperatingProfile.label}`);
|
|
827
|
+
lines.push(`- **Summary:** ${report.recommendedOperatingProfile.summary}`);
|
|
828
|
+
lines.push(`- **Permission profile:** ${report.recommendedOperatingProfile.permissionProfile.label}`);
|
|
829
|
+
lines.push(`- **Governance pack:** ${report.recommendedOperatingProfile.governancePack.label}`);
|
|
830
|
+
lines.push(`- **Platform support:** ${(report.recommendedOperatingProfile.platformSupport.recommended || []).join(', ') || report.platformLabel}`);
|
|
831
|
+
if (report.recommendedOperatingProfile.platformSupport.optionalExpansion) {
|
|
832
|
+
lines.push(`- **Optional expansion:** ${report.recommendedOperatingProfile.platformSupport.optionalExpansion}`);
|
|
833
|
+
}
|
|
834
|
+
lines.push(`- **CI shape:** ${report.recommendedOperatingProfile.ciShape.label}`);
|
|
835
|
+
lines.push(`- **Verification:** ${report.recommendedOperatingProfile.verification.required.join(', ')}`);
|
|
836
|
+
lines.push(`- **Hooks:** ${report.recommendedOperatingProfile.hooks.map((hook) => hook.key).join(', ')}`);
|
|
837
|
+
lines.push('');
|
|
838
|
+
|
|
839
|
+
lines.push('## Adopt / Defer / Ignore');
|
|
840
|
+
lines.push('');
|
|
841
|
+
const decisionGroups = [
|
|
842
|
+
['adopt', 'Adopt now'],
|
|
843
|
+
['defer', 'Defer'],
|
|
844
|
+
['ignore', 'Ignore'],
|
|
845
|
+
];
|
|
846
|
+
for (const [decision, label] of decisionGroups) {
|
|
847
|
+
const items = report.adoptionGuidance.items.filter((item) => item.decision === decision);
|
|
848
|
+
if (items.length === 0) continue;
|
|
849
|
+
lines.push(`### ${label}`);
|
|
850
|
+
lines.push('');
|
|
851
|
+
for (const item of items) {
|
|
852
|
+
lines.push(`- **${item.label}** — ${item.why}`);
|
|
853
|
+
lines.push(` Evidence: ${item.evidence.join(' | ')}`);
|
|
854
|
+
lines.push(` Prerequisites: ${item.prerequisites.length > 0 ? item.prerequisites.join(' | ') : 'None'}`);
|
|
855
|
+
lines.push(` Expected benefit: ${item.expectedBenefit}`);
|
|
856
|
+
lines.push(` Rollback safety: ${item.rollbackSafety}`);
|
|
857
|
+
}
|
|
858
|
+
lines.push('');
|
|
859
|
+
}
|
|
860
|
+
|
|
731
861
|
if (report.strengthsPreserved.length > 0) {
|
|
732
862
|
lines.push('## Strengths Preserved (don\'t change these)');
|
|
733
863
|
lines.push('');
|
package/src/anti-patterns.js
CHANGED
|
@@ -8,6 +8,9 @@ const {
|
|
|
8
8
|
hasDocumentedVerificationGuidance,
|
|
9
9
|
hasDocumentedTestCommand,
|
|
10
10
|
} = require('./instruction-surfaces');
|
|
11
|
+
const { collectClaudeDenyRules } = require('./permission-rules');
|
|
12
|
+
const { containsEmbeddedSecret } = require('./secret-patterns');
|
|
13
|
+
const { containsPromptInjectionPattern } = require('./prompt-injection');
|
|
11
14
|
|
|
12
15
|
const ANTI_PATTERNS = [
|
|
13
16
|
{
|
|
@@ -32,7 +35,7 @@ const ANTI_PATTERNS = [
|
|
|
32
35
|
detect: (ctx) => {
|
|
33
36
|
const settings = ctx.jsonFile('.claude/settings.json') || ctx.jsonFile('.claude/settings.local.json');
|
|
34
37
|
if (!settings || !settings.permissions) return true;
|
|
35
|
-
return
|
|
38
|
+
return collectClaudeDenyRules(ctx).length === 0;
|
|
36
39
|
},
|
|
37
40
|
},
|
|
38
41
|
{
|
|
@@ -216,6 +219,18 @@ const ANTI_PATTERNS = [
|
|
|
216
219
|
return !hasTestInMd && !hasTestScript;
|
|
217
220
|
},
|
|
218
221
|
},
|
|
222
|
+
{
|
|
223
|
+
id: 'AP023',
|
|
224
|
+
name: 'Suspicious prompt-injection phrases in repo instructions',
|
|
225
|
+
severity: 'high',
|
|
226
|
+
description: 'Instruction surfaces that say things like "ignore previous instructions", "bypass guardrails", or "score 100/100" create confusion and downstream trust problems, even when the static audit itself is not LLM-driven.',
|
|
227
|
+
platforms: ['claude', 'codex', 'cursor', 'windsurf', 'copilot', 'gemini', 'aider', 'opencode'],
|
|
228
|
+
fix: 'Remove adversarial phrases from repo instructions and replace them with an explicit trust-boundary note about treating repo/web/MCP content as untrusted data.',
|
|
229
|
+
detect: (ctx) => {
|
|
230
|
+
const content = getRepoInstructionBundle(ctx);
|
|
231
|
+
return containsPromptInjectionPattern(content);
|
|
232
|
+
},
|
|
233
|
+
},
|
|
219
234
|
{
|
|
220
235
|
id: 'AP015',
|
|
221
236
|
name: 'All permissions allowed',
|
|
@@ -322,7 +337,7 @@ const ANTI_PATTERNS = [
|
|
|
322
337
|
];
|
|
323
338
|
for (const file of hookFiles) {
|
|
324
339
|
const content = ctx.fileContent(`.claude/hooks/${file}`) || '';
|
|
325
|
-
if (secretPatterns.some(p => p.test(content))) {
|
|
340
|
+
if (secretPatterns.some(p => p.test(content)) || containsEmbeddedSecret(content)) {
|
|
326
341
|
return true;
|
|
327
342
|
}
|
|
328
343
|
}
|