@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
@@ -0,0 +1,106 @@
1
+ /**
2
+ * Tools technique fragments.
3
+ * Generated mechanically from the legacy techniques.js monolith during HR-09.
4
+ */
5
+
6
+ const {
7
+ } = require('./shared');
8
+
9
+ module.exports = {
10
+ mcpServers: {
11
+ id: 18,
12
+ name: 'MCP servers configured',
13
+ check: (ctx) => {
14
+ // MCP now lives in .mcp.json (project) and ~/.claude.json (user), NOT settings.json
15
+ const mcpJson = ctx.jsonFile('.mcp.json');
16
+ if (mcpJson && mcpJson.mcpServers && Object.keys(mcpJson.mcpServers).length > 0) return true;
17
+ // Fallback: check settings for legacy format
18
+ const settings = ctx.jsonFile('.claude/settings.local.json') || ctx.jsonFile('.claude/settings.json');
19
+ return !!(settings && settings.mcpServers && Object.keys(settings.mcpServers).length > 0);
20
+ },
21
+ impact: 'medium',
22
+ rating: 3,
23
+ category: 'tools',
24
+ fix: 'Configure MCP servers in .mcp.json at project root. Use `claude mcp add` to add servers. Project-level MCP is committed to git for team sharing.',
25
+ template: null
26
+ },
27
+
28
+ multipleMcpServers: {
29
+ id: 1801,
30
+ name: '2+ MCP servers for rich tooling',
31
+ check: (ctx) => {
32
+ let count = 0;
33
+ const mcpJson = ctx.jsonFile('.mcp.json');
34
+ if (mcpJson && mcpJson.mcpServers) count += Object.keys(mcpJson.mcpServers).length;
35
+ const settings = ctx.jsonFile('.claude/settings.local.json') || ctx.jsonFile('.claude/settings.json');
36
+ if (settings && settings.mcpServers) count += Object.keys(settings.mcpServers).length;
37
+ return count >= 2;
38
+ },
39
+ impact: 'medium',
40
+ rating: 4,
41
+ category: 'tools',
42
+ fix: 'Add at least 2 MCP servers for broader tool coverage (e.g. database + search).',
43
+ template: null
44
+ },
45
+
46
+ context7Mcp: {
47
+ id: 110,
48
+ name: 'Context7 MCP for real-time docs',
49
+ check: (ctx) => {
50
+ const shared = ctx.jsonFile('.claude/settings.json') || {};
51
+ const local = ctx.jsonFile('.claude/settings.local.json') || {};
52
+ const mcp = ctx.jsonFile('.mcp.json') || {};
53
+ const all = { ...(shared.mcpServers || {}), ...(local.mcpServers || {}), ...(mcp.mcpServers || {}) };
54
+ if (Object.keys(all).length === 0) return false;
55
+ return Object.keys(all).some(k => /context7/i.test(k));
56
+ },
57
+ impact: 'medium',
58
+ rating: 4,
59
+ category: 'tools',
60
+ fix: 'Add Context7 MCP server for real-time documentation lookup (always up-to-date library docs).',
61
+ template: null
62
+ },
63
+
64
+ mcpHasEnvConfig: {
65
+ id: 2027,
66
+ name: 'MCP servers have environment configuration',
67
+ check: (ctx) => {
68
+ const shared = ctx.jsonFile('.claude/settings.json') || {};
69
+ const local = ctx.jsonFile('.claude/settings.local.json') || {};
70
+ const mcp = ctx.jsonFile('.mcp.json') || {};
71
+ const allServers = { ...(shared.mcpServers || {}), ...(local.mcpServers || {}), ...(mcp.mcpServers || {}) };
72
+ if (Object.keys(allServers).length === 0) return null;
73
+ return Object.values(allServers).some(s => s.env && Object.keys(s.env).length > 0);
74
+ },
75
+ impact: 'low', rating: 3, category: 'tools',
76
+ fix: 'Configure environment variables for MCP servers that need authentication (e.g. GITHUB_TOKEN).',
77
+ template: null
78
+ },
79
+
80
+ mcpJsonProject: {
81
+ id: 2032,
82
+ name: 'Project-level .mcp.json exists',
83
+ check: (ctx) => ctx.files.includes('.mcp.json'),
84
+ impact: 'medium',
85
+ rating: 3,
86
+ category: 'tools',
87
+ fix: 'Create .mcp.json at project root for team-shared MCP servers. Use `claude mcp add --project` to add servers.',
88
+ template: null
89
+ },
90
+
91
+ mcpBudgetHealthy: {
92
+ id: 110002,
93
+ name: 'MCP budget not over-provisioned (≤10 servers, ≤80 tools)',
94
+ check: (ctx) => {
95
+ const settings = ctx.jsonFile('.claude/settings.json') || {};
96
+ const mcp = ctx.jsonFile('.mcp.json') || {};
97
+ const mcpServers = Object.keys(settings.mcpServers || {}).length + Object.keys(mcp.mcpServers || {}).length;
98
+ if (mcpServers === 0) return null;
99
+ return mcpServers <= 10;
100
+ },
101
+ impact: 'medium', rating: 4, category: 'tools',
102
+ fix: 'Too many MCP servers (>10) degrades performance. Remove unused servers or consolidate.',
103
+ template: null,
104
+ confidence: 0.9,
105
+ },
106
+ };
@@ -0,0 +1,413 @@
1
+ /**
2
+ * Workflow technique fragments.
3
+ * Generated mechanically from the legacy techniques.js monolith during HR-09.
4
+ */
5
+
6
+ const {
7
+ fs,
8
+ path,
9
+ hasProjectFile,
10
+ readProjectFiles,
11
+ getWorkflowContent,
12
+ resolveProjectStateReadPath,
13
+ } = require('./shared');
14
+
15
+ module.exports = {
16
+ customCommands: {
17
+ id: 20,
18
+ name: 'Custom slash commands',
19
+ check: (ctx) => ctx.hasDir('.claude/commands') && ctx.dirFiles('.claude/commands').length > 0,
20
+ impact: 'high',
21
+ rating: 4,
22
+ category: 'workflow',
23
+ fix: 'Create custom commands for repeated workflows (/test, /deploy, /review).',
24
+ template: 'commands'
25
+ },
26
+
27
+ multipleCommands: {
28
+ id: 20001,
29
+ name: '3+ slash commands for rich workflow',
30
+ check: (ctx) => ctx.hasDir('.claude/commands') && ctx.dirFiles('.claude/commands').length >= 3,
31
+ impact: 'medium',
32
+ rating: 4,
33
+ category: 'workflow',
34
+ fix: 'Add at least 3 slash commands to cover your main workflows (test, deploy, review, etc.).',
35
+ template: 'commands'
36
+ },
37
+
38
+ deployCommand: {
39
+ id: 20002,
40
+ name: 'Has /deploy or /release command',
41
+ check: (ctx) => {
42
+ if (!ctx.hasDir('.claude/commands')) return false;
43
+ const files = ctx.dirFiles('.claude/commands');
44
+ return files.some(f => /deploy|release/i.test(f));
45
+ },
46
+ impact: 'medium',
47
+ rating: 4,
48
+ category: 'workflow',
49
+ fix: 'Create a /deploy or /release command for one-click deployments.',
50
+ template: null
51
+ },
52
+
53
+ reviewCommand: {
54
+ id: 20003,
55
+ name: 'Has /review command',
56
+ check: (ctx) => {
57
+ if (!ctx.hasDir('.claude/commands')) return false;
58
+ const files = ctx.dirFiles('.claude/commands');
59
+ return files.some(f => /review/i.test(f));
60
+ },
61
+ impact: 'medium',
62
+ rating: 4,
63
+ category: 'workflow',
64
+ fix: 'Create a /review command for code review workflows.',
65
+ template: null
66
+ },
67
+
68
+ skills: {
69
+ id: 21,
70
+ name: 'Custom skills',
71
+ check: (ctx) => {
72
+ // Skills use directory-per-skill structure: .claude/skills/<name>/SKILL.md
73
+ if (!ctx.hasDir('.claude/skills')) return false;
74
+ const dirs = ctx.dirFiles('.claude/skills');
75
+ // Check for SKILL.md inside skill directories
76
+ for (const d of dirs) {
77
+ if (ctx.fileContent(`.claude/skills/${d}/SKILL.md`)) return true;
78
+ }
79
+ // Fallback: any files in skills dir (legacy .claude/commands/ also works)
80
+ return dirs.length > 0;
81
+ },
82
+ impact: 'medium',
83
+ rating: 4,
84
+ category: 'workflow',
85
+ fix: 'Create skills at .claude/skills/<name>/SKILL.md with YAML frontmatter (name, description). Each skill is a directory with a SKILL.md file.',
86
+ template: 'skills'
87
+ },
88
+
89
+ multipleSkills: {
90
+ id: 2101,
91
+ name: '2+ skills for specialization',
92
+ check: (ctx) => {
93
+ if (!ctx.hasDir('.claude/skills')) return false;
94
+ return ctx.dirFiles('.claude/skills').length >= 2;
95
+ },
96
+ impact: 'medium',
97
+ rating: 4,
98
+ category: 'workflow',
99
+ fix: 'Add at least 2 skills covering different workflows (e.g. code-review, test-writer).',
100
+ template: 'skills'
101
+ },
102
+
103
+ agents: {
104
+ id: 22,
105
+ name: 'Custom agents',
106
+ check: (ctx) => ctx.hasDir('.claude/agents') && ctx.dirFiles('.claude/agents').length > 0,
107
+ impact: 'medium',
108
+ rating: 4,
109
+ category: 'workflow',
110
+ fix: 'Create specialized agents (security-reviewer, test-writer) in .claude/agents/.',
111
+ template: 'agents'
112
+ },
113
+
114
+ multipleAgents: {
115
+ id: 2201,
116
+ name: '2+ agents for delegation',
117
+ check: (ctx) => ctx.hasDir('.claude/agents') && ctx.dirFiles('.claude/agents').length >= 2,
118
+ impact: 'medium',
119
+ rating: 4,
120
+ category: 'workflow',
121
+ fix: 'Add at least 2 agents for specialized tasks (e.g. security-reviewer, test-writer).',
122
+ template: 'agents'
123
+ },
124
+
125
+ multipleRules: {
126
+ id: 301,
127
+ name: '2+ rules files for granular control',
128
+ check: (ctx) => ctx.hasDir('.claude/rules') && ctx.dirFiles('.claude/rules').length >= 2,
129
+ impact: 'medium',
130
+ rating: 4,
131
+ category: 'workflow',
132
+ fix: 'Add path-specific rules for different parts of the codebase (frontend, backend, tests).',
133
+ template: 'rules'
134
+ },
135
+
136
+ channelsAwareness: {
137
+ id: 1102,
138
+ name: 'Claude Code Channels awareness',
139
+ check: (ctx) => {
140
+ const md = ctx.claudeMdContent() || '';
141
+ const settings = ctx.jsonFile('.claude/settings.local.json') || ctx.jsonFile('.claude/settings.json');
142
+ const settingsStr = JSON.stringify(settings || {});
143
+ return /\bchannels?\b.*\b(telegram|discord|imessage|slack|bridge)\b|\b(telegram|discord|imessage|slack|bridge)\b.*\bchannels?\b/i.test(md) || settingsStr.includes('channels');
144
+ },
145
+ impact: 'low',
146
+ rating: 3,
147
+ category: 'features',
148
+ fix: 'Claude Code Channels (v2.1.80+) bridges Telegram/Discord/iMessage to your session.',
149
+ template: null
150
+ },
151
+
152
+ agentHasAllowedTools: {
153
+ id: 2011,
154
+ name: 'At least one subagent restricts tools',
155
+ check: (ctx) => {
156
+ if (!ctx.hasDir('.claude/agents')) return null;
157
+ const files = ctx.dirFiles('.claude/agents');
158
+ if (files.length === 0) return null;
159
+ for (const f of files) {
160
+ const content = ctx.fileContent(`.claude/agents/${f}`) || '';
161
+ // Current frontmatter uses allowed-tools (also accept legacy tools:)
162
+ if (/allowed-tools:/i.test(content) || /tools:\s*\[/.test(content)) return true;
163
+ }
164
+ return false;
165
+ },
166
+ impact: 'medium', rating: 3, category: 'workflow',
167
+ fix: 'Add allowed-tools to subagent frontmatter (e.g. allowed-tools: Read Grep Bash) for safer delegation.',
168
+ template: null
169
+ },
170
+
171
+ hasSnapshotHistory: {
172
+ id: 2017,
173
+ name: 'Audit snapshot history exists',
174
+ check: (ctx) => {
175
+ const fs = require('fs');
176
+ return fs.existsSync(resolveProjectStateReadPath(ctx.dir, 'snapshots', 'index.json'));
177
+ },
178
+ impact: 'low', rating: 3, category: 'workflow',
179
+ fix: 'Run `npx nerviq --snapshot` to start tracking your setup score over time.',
180
+ template: null
181
+ },
182
+
183
+ worktreeAwareness: {
184
+ id: 2018,
185
+ name: 'Worktree or parallel sessions mentioned',
186
+ check: (ctx) => {
187
+ const md = ctx.claudeMdContent() || '';
188
+ const shared = ctx.jsonFile('.claude/settings.json') || {};
189
+ return /worktree|parallel.*session/i.test(md) || !!shared.worktree;
190
+ },
191
+ impact: 'low', rating: 3, category: 'features',
192
+ fix: 'Claude Code supports git worktrees for parallel isolated sessions. Mention if relevant.',
193
+ template: null
194
+ },
195
+
196
+ skillUsesPaths: {
197
+ id: 2026,
198
+ name: 'At least one skill uses paths for scoping',
199
+ check: (ctx) => {
200
+ if (!ctx.hasDir('.claude/skills')) return null;
201
+ const entries = ctx.dirFiles('.claude/skills');
202
+ if (entries.length === 0) return null;
203
+ for (const entry of entries) {
204
+ // Skills can be files or dirs with SKILL.md inside
205
+ const direct = ctx.fileContent(`.claude/skills/${entry}`) || '';
206
+ if (/paths:/i.test(direct)) return true;
207
+ const nested = ctx.fileContent(`.claude/skills/${entry}/SKILL.md`) || '';
208
+ if (/paths:/i.test(nested)) return true;
209
+ }
210
+ return false;
211
+ },
212
+ impact: 'low', rating: 3, category: 'workflow',
213
+ fix: 'Add paths to skill frontmatter to scope when skills activate (e.g. paths: ["src/**/*.ts"]).',
214
+ template: null
215
+ },
216
+
217
+ rulesDirectory: {
218
+ id: 2035,
219
+ name: 'Path-specific rules in .claude/rules/',
220
+ check: (ctx) => ctx.hasDir('.claude/rules') && ctx.dirFiles('.claude/rules').length > 0,
221
+ impact: 'medium',
222
+ rating: 3,
223
+ category: 'workflow',
224
+ fix: 'Create .claude/rules/ with path-specific rules for different parts of your codebase (e.g. frontend.md, backend.md).',
225
+ template: null
226
+ },
227
+
228
+ hasLlmsTxt: {
229
+ id: 110001,
230
+ name: 'Has /llms.txt or llms.txt for LLM context',
231
+ check: (ctx) => {
232
+ return ctx.files.some(f => /^(public\/)?llms\.txt$/i.test(f) || /^llms-full\.txt$/i.test(f));
233
+ },
234
+ impact: 'low', rating: 3, category: 'features',
235
+ fix: 'Add llms.txt to provide LLM-friendly project context. See llmstxt.org for the standard.',
236
+ template: null,
237
+ confidence: 0.8,
238
+ },
239
+
240
+ instinctToSkillProgression: {
241
+ id: 110006,
242
+ name: 'Instinct-to-skill progression documented',
243
+ check: (ctx) => {
244
+ const md = ctx.claudeMdContent() || '';
245
+ return /progressive learning|instinct[- ]to[- ]skill|instinct.{0,40}skill|skill.{0,40}instinct|graduated|phased approach/i.test(md);
246
+ },
247
+ impact: 'low', rating: 3, category: 'features',
248
+ fix: 'Document a progressive learning path that turns repeated instincts into reusable skills or phased practices.',
249
+ template: null,
250
+ confidence: 0.7,
251
+ },
252
+
253
+ featureFlagService: {
254
+ id: 130141,
255
+ name: 'Feature flag service in dependencies',
256
+ check: (ctx) => {
257
+ const pkg = ctx.fileContent('package.json') || '';
258
+ if (/launchdarkly|unleash|flagsmith|growthbook|@split/i.test(pkg)) return true;
259
+ const py = readProjectFiles(ctx, /(^|\/)pyproject\.toml$/i) + readProjectFiles(ctx, /(^|\/)requirements[^/]*\.txt$/i);
260
+ if (/launchdarkly|unleash|flagsmith|growthbook/i.test(py)) return true;
261
+ return false;
262
+ },
263
+ impact: 'medium',
264
+ category: 'feature-flags',
265
+ fix: 'Add a feature flag service (LaunchDarkly, Unleash, Flagsmith, GrowthBook) for safe feature rollouts.',
266
+ confidence: 0.7,
267
+ },
268
+
269
+ featureFlagConfig: {
270
+ id: 130142,
271
+ name: 'Feature flag config files exist',
272
+ check: (ctx) => {
273
+ return hasProjectFile(ctx, /(^|\/)flags\.json$/i) ||
274
+ hasProjectFile(ctx, /(^|\/)features\.json$/i) ||
275
+ hasProjectFile(ctx, /(^|\/)feature-flags\//i);
276
+ },
277
+ impact: 'low',
278
+ category: 'feature-flags',
279
+ fix: 'Add feature flag configuration files (flags.json, features.json, or feature-flags/ directory).',
280
+ confidence: 0.7,
281
+ },
282
+
283
+ featureFlagTests: {
284
+ id: 130143,
285
+ name: 'Feature flag testing present',
286
+ check: (ctx) => {
287
+ const testFiles = readProjectFiles(ctx, /(test|spec)\.(jsx?|tsx?|py|go|java|rb)$/i, 30);
288
+ return /flag|feature.*toggle|variation/i.test(testFiles);
289
+ },
290
+ impact: 'low',
291
+ category: 'feature-flags',
292
+ fix: 'Add tests for feature flag variations to verify behavior under different flag states.',
293
+ confidence: 0.7,
294
+ },
295
+
296
+ flagLifecycle: {
297
+ id: 130144,
298
+ name: 'Flag lifecycle management',
299
+ check: (ctx) => {
300
+ return hasProjectFile(ctx, /flag-audit|remove-flag|flag.*cleanup/i) ||
301
+ /flag.*lifecycle|flag.*cleanup|stale.*flag/i.test(readProjectFiles(ctx, /\.(md|txt|json)$/i, 10));
302
+ },
303
+ impact: 'low',
304
+ category: 'feature-flags',
305
+ fix: 'Add flag lifecycle scripts or docs (flag-audit, remove-flag) to prevent stale flag accumulation.',
306
+ confidence: 0.7,
307
+ },
308
+
309
+ envBasedFlags: {
310
+ id: 130145,
311
+ name: 'Environment-based feature toggles',
312
+ check: (ctx) => {
313
+ const envFiles = readProjectFiles(ctx, /(^|\/)(\.env|\.env\.\w+)$/i);
314
+ const config = readProjectFiles(ctx, /\.(json|ya?ml|toml)$/i, 15);
315
+ return /FEATURE_|ENABLE_|FF_/i.test(envFiles + config);
316
+ },
317
+ impact: 'low',
318
+ category: 'feature-flags',
319
+ fix: 'Use environment-based feature toggles (FEATURE_, ENABLE_, FF_ prefixes) for deployment-time configuration.',
320
+ confidence: 0.7,
321
+ },
322
+
323
+ monorepoTool: {
324
+ id: 130161,
325
+ name: 'Monorepo tool configured',
326
+ check: (ctx) => {
327
+ const pkg = ctx.fileContent('package.json') || '';
328
+ const hasMonorepo = /workspaces/i.test(pkg) || ctx.files.includes('lerna.json') ||
329
+ ctx.files.includes('nx.json') || ctx.files.includes('turbo.json') ||
330
+ hasProjectFile(ctx, /(^|\/)pnpm-workspace\.yaml$/i);
331
+ if (!hasMonorepo) return null;
332
+ return /turborepo|turbo|"nx"|lerna|rush|bazel/i.test(pkg) ||
333
+ ctx.files.includes('nx.json') || ctx.files.includes('turbo.json') ||
334
+ ctx.files.includes('lerna.json') || ctx.files.includes('rush.json');
335
+ },
336
+ impact: 'medium',
337
+ category: 'monorepo',
338
+ fix: 'Configure a monorepo orchestration tool (Turborepo, Nx, Lerna, Rush) for efficient multi-package builds.',
339
+ confidence: 0.7,
340
+ },
341
+
342
+ workspaceDeps: {
343
+ id: 130162,
344
+ name: 'Workspace dependency management configured',
345
+ check: (ctx) => {
346
+ const pkg = ctx.fileContent('package.json') || '';
347
+ const hasMonorepo = /workspaces/i.test(pkg) || ctx.files.includes('lerna.json') ||
348
+ ctx.files.includes('nx.json') || ctx.files.includes('turbo.json') ||
349
+ hasProjectFile(ctx, /(^|\/)pnpm-workspace\.yaml$/i);
350
+ if (!hasMonorepo) return null;
351
+ return hasProjectFile(ctx, /(^|\/)pnpm-workspace\.yaml$/i) || /workspaces/i.test(pkg);
352
+ },
353
+ impact: 'medium',
354
+ category: 'monorepo',
355
+ fix: 'Configure workspace dependencies (pnpm-workspace.yaml or workspaces in package.json) for cross-package linking.',
356
+ confidence: 0.7,
357
+ },
358
+
359
+ changesetsConfigured: {
360
+ id: 130163,
361
+ name: 'Changesets or conventional commits for versioning',
362
+ check: (ctx) => {
363
+ const pkg = ctx.fileContent('package.json') || '';
364
+ const hasMonorepo = /workspaces/i.test(pkg) || ctx.files.includes('lerna.json') ||
365
+ ctx.files.includes('nx.json') || ctx.files.includes('turbo.json') ||
366
+ hasProjectFile(ctx, /(^|\/)pnpm-workspace\.yaml$/i);
367
+ if (!hasMonorepo) return null;
368
+ return /@changesets\/cli|changeset/i.test(pkg) || ctx.hasDir('.changeset') ||
369
+ hasProjectFile(ctx, /(^|\/)\.changeset\//i);
370
+ },
371
+ impact: 'low',
372
+ category: 'monorepo',
373
+ fix: 'Add @changesets/cli or conventional commits for coordinated versioning across packages.',
374
+ confidence: 0.7,
375
+ },
376
+
377
+ monorepoCI: {
378
+ id: 130164,
379
+ name: 'CI uses affected/changed detection',
380
+ check: (ctx) => {
381
+ const pkg = ctx.fileContent('package.json') || '';
382
+ const hasMonorepo = /workspaces/i.test(pkg) || ctx.files.includes('lerna.json') ||
383
+ ctx.files.includes('nx.json') || ctx.files.includes('turbo.json') ||
384
+ hasProjectFile(ctx, /(^|\/)pnpm-workspace\.yaml$/i);
385
+ if (!hasMonorepo) return null;
386
+ const ci = getWorkflowContent(ctx);
387
+ return /nx affected|turbo.*--filter|lerna changed|lerna run.*--since/i.test(ci);
388
+ },
389
+ impact: 'medium',
390
+ category: 'monorepo',
391
+ fix: 'Use affected/changed detection in CI (nx affected, turbo --filter) to only build what changed.',
392
+ confidence: 0.7,
393
+ },
394
+
395
+ sharedConfigs: {
396
+ id: 130165,
397
+ name: 'Shared configs across packages',
398
+ check: (ctx) => {
399
+ const pkg = ctx.fileContent('package.json') || '';
400
+ const hasMonorepo = /workspaces/i.test(pkg) || ctx.files.includes('lerna.json') ||
401
+ ctx.files.includes('nx.json') || ctx.files.includes('turbo.json') ||
402
+ hasProjectFile(ctx, /(^|\/)pnpm-workspace\.yaml$/i);
403
+ if (!hasMonorepo) return null;
404
+ return hasProjectFile(ctx, /(^|\/)packages\/.*eslint/i) ||
405
+ hasProjectFile(ctx, /(^|\/)packages\/.*tsconfig/i) ||
406
+ hasProjectFile(ctx, /shared.*config/i);
407
+ },
408
+ impact: 'low',
409
+ category: 'monorepo',
410
+ fix: 'Create shared config packages (eslint, tsconfig) referenced across monorepo packages for consistency.',
411
+ confidence: 0.7,
412
+ },
413
+ };