@nerviq/cli 0.0.1 → 0.9.0-beta.1
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 +181 -0
- package/LICENSE +21 -0
- package/README.md +447 -0
- package/bin/cli.js +749 -0
- package/content/case-study-template.md +91 -0
- package/content/claims-governance.md +37 -0
- package/content/claude-code/audit-repo/SKILL.md +20 -0
- package/content/claude-native-integration.md +60 -0
- package/content/devto-article.json +9 -0
- package/content/launch-posts.md +226 -0
- package/content/pilot-rollout-kit.md +30 -0
- package/content/release-checklist.md +31 -0
- package/package.json +53 -4
- package/src/activity.js +529 -0
- package/src/aider/activity.js +226 -0
- package/src/aider/config-parser.js +166 -0
- package/src/aider/context.js +158 -0
- package/src/aider/deep-review.js +316 -0
- package/src/aider/domain-packs.js +278 -0
- package/src/aider/freshness.js +168 -0
- package/src/aider/governance.js +253 -0
- package/src/aider/interactive.js +334 -0
- package/src/aider/mcp-packs.js +98 -0
- package/src/aider/patch.js +214 -0
- package/src/aider/plans.js +186 -0
- package/src/aider/premium.js +360 -0
- package/src/aider/setup.js +404 -0
- package/src/aider/techniques.js +1323 -0
- package/src/analyze.js +821 -0
- package/src/audit.js +1003 -0
- package/src/badge.js +13 -0
- package/src/benchmark.js +339 -0
- package/src/claudex-sync.json +7 -0
- package/src/codex/activity.js +324 -0
- package/src/codex/config-parser.js +183 -0
- package/src/codex/context.js +221 -0
- package/src/codex/deep-review.js +493 -0
- package/src/codex/domain-packs.js +372 -0
- package/src/codex/freshness.js +167 -0
- package/src/codex/governance.js +192 -0
- package/src/codex/interactive.js +618 -0
- package/src/codex/mcp-packs.js +660 -0
- package/src/codex/patch.js +209 -0
- package/src/codex/plans.js +251 -0
- package/src/codex/premium.js +614 -0
- package/src/codex/setup.js +603 -0
- package/src/codex/techniques.js +2649 -0
- package/src/context.js +272 -0
- package/src/copilot/activity.js +309 -0
- package/src/copilot/config-parser.js +226 -0
- package/src/copilot/context.js +197 -0
- package/src/copilot/deep-review.js +346 -0
- package/src/copilot/domain-packs.js +350 -0
- package/src/copilot/freshness.js +197 -0
- package/src/copilot/governance.js +222 -0
- package/src/copilot/interactive.js +406 -0
- package/src/copilot/mcp-packs.js +572 -0
- package/src/copilot/patch.js +238 -0
- package/src/copilot/plans.js +253 -0
- package/src/copilot/premium.js +450 -0
- package/src/copilot/setup.js +488 -0
- package/src/copilot/techniques.js +1822 -0
- package/src/cursor/activity.js +301 -0
- package/src/cursor/config-parser.js +265 -0
- package/src/cursor/context.js +236 -0
- package/src/cursor/deep-review.js +334 -0
- package/src/cursor/domain-packs.js +346 -0
- package/src/cursor/freshness.js +214 -0
- package/src/cursor/governance.js +229 -0
- package/src/cursor/interactive.js +391 -0
- package/src/cursor/mcp-packs.js +571 -0
- package/src/cursor/patch.js +243 -0
- package/src/cursor/plans.js +254 -0
- package/src/cursor/premium.js +468 -0
- package/src/cursor/setup.js +488 -0
- package/src/cursor/techniques.js +1786 -0
- package/src/deep-review.js +345 -0
- package/src/domain-packs.js +364 -0
- package/src/formatters/sarif.js +115 -0
- package/src/gemini/activity.js +402 -0
- package/src/gemini/config-parser.js +275 -0
- package/src/gemini/context.js +221 -0
- package/src/gemini/deep-review.js +559 -0
- package/src/gemini/domain-packs.js +371 -0
- package/src/gemini/freshness.js +204 -0
- package/src/gemini/governance.js +201 -0
- package/src/gemini/interactive.js +860 -0
- package/src/gemini/mcp-packs.js +658 -0
- package/src/gemini/patch.js +229 -0
- package/src/gemini/plans.js +269 -0
- package/src/gemini/premium.js +759 -0
- package/src/gemini/setup.js +692 -0
- package/src/gemini/techniques.js +2084 -0
- package/src/governance.js +523 -0
- package/src/harmony/advisor.js +383 -0
- package/src/harmony/audit.js +303 -0
- package/src/harmony/canon.js +444 -0
- package/src/harmony/cli.js +331 -0
- package/src/harmony/drift.js +401 -0
- package/src/harmony/governance.js +313 -0
- package/src/harmony/memory.js +238 -0
- package/src/harmony/sync.js +458 -0
- package/src/harmony/watch.js +336 -0
- package/src/index.js +256 -0
- package/src/insights.js +119 -0
- package/src/interactive.js +118 -0
- package/src/mcp-packs.js +597 -0
- package/src/opencode/activity.js +286 -0
- package/src/opencode/config-parser.js +109 -0
- package/src/opencode/context.js +247 -0
- package/src/opencode/deep-review.js +313 -0
- package/src/opencode/domain-packs.js +240 -0
- package/src/opencode/freshness.js +158 -0
- package/src/opencode/governance.js +159 -0
- package/src/opencode/interactive.js +392 -0
- package/src/opencode/mcp-packs.js +474 -0
- package/src/opencode/patch.js +184 -0
- package/src/opencode/plans.js +231 -0
- package/src/opencode/premium.js +413 -0
- package/src/opencode/setup.js +449 -0
- package/src/opencode/techniques.js +1713 -0
- package/src/plans.js +655 -0
- package/src/secret-patterns.js +30 -0
- package/src/setup.js +1274 -0
- package/src/synergy/adaptive.js +261 -0
- package/src/synergy/compensation.js +156 -0
- package/src/synergy/evidence.js +193 -0
- package/src/synergy/learning.js +184 -0
- package/src/synergy/patterns.js +227 -0
- package/src/synergy/ranking.js +83 -0
- package/src/synergy/report.js +163 -0
- package/src/synergy/routing.js +152 -0
- package/src/techniques.js +1354 -0
- package/src/watch.js +229 -0
- package/src/windsurf/activity.js +302 -0
- package/src/windsurf/config-parser.js +267 -0
- package/src/windsurf/context.js +249 -0
- package/src/windsurf/deep-review.js +337 -0
- package/src/windsurf/domain-packs.js +348 -0
- package/src/windsurf/freshness.js +215 -0
- package/src/windsurf/governance.js +231 -0
- package/src/windsurf/interactive.js +388 -0
- package/src/windsurf/mcp-packs.js +535 -0
- package/src/windsurf/patch.js +231 -0
- package/src/windsurf/plans.js +247 -0
- package/src/windsurf/premium.js +467 -0
- package/src/windsurf/setup.js +471 -0
- package/src/windsurf/techniques.js +1758 -0
|
@@ -0,0 +1,468 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Cursor Premium Operator UX
|
|
3
|
+
*
|
|
4
|
+
* Three subsystems:
|
|
5
|
+
* 1. Multi-Pack Composition Engine — merge domain + MCP packs with dedup, conflict resolution, MDC awareness
|
|
6
|
+
* 2. CI Template Library — 5 GitHub Actions workflow templates for Cursor
|
|
7
|
+
* 3. Adoption Signal Gate — activate features based on local usage telemetry (5 gates)
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
const path = require('path');
|
|
11
|
+
const { CURSOR_DOMAIN_PACKS } = require('./domain-packs');
|
|
12
|
+
const { CURSOR_MCP_PACKS } = require('./mcp-packs');
|
|
13
|
+
|
|
14
|
+
// ---------------------------------------------------------------------------
|
|
15
|
+
// 1. Multi-Pack Composition Engine (with MDC awareness)
|
|
16
|
+
// ---------------------------------------------------------------------------
|
|
17
|
+
|
|
18
|
+
const PACK_DEPENDENCY_ORDER = [
|
|
19
|
+
'baseline-general',
|
|
20
|
+
'backend-api',
|
|
21
|
+
'frontend-ui',
|
|
22
|
+
'infra-platform',
|
|
23
|
+
'monorepo',
|
|
24
|
+
'enterprise-governed',
|
|
25
|
+
];
|
|
26
|
+
|
|
27
|
+
const PACK_SPECIFICITY = {
|
|
28
|
+
'baseline-general': 0,
|
|
29
|
+
'backend-api': 2,
|
|
30
|
+
'frontend-ui': 2,
|
|
31
|
+
'infra-platform': 3,
|
|
32
|
+
'monorepo': 3,
|
|
33
|
+
'enterprise-governed': 4,
|
|
34
|
+
};
|
|
35
|
+
|
|
36
|
+
const DEFAULT_SIZE_BUDGET = 16000;
|
|
37
|
+
|
|
38
|
+
function lookupDomainPack(key) {
|
|
39
|
+
return CURSOR_DOMAIN_PACKS.find(p => p.key === key) || null;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
function lookupMcpPack(key) {
|
|
43
|
+
return CURSOR_MCP_PACKS.find(p => p.key === key) || null;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
/**
|
|
47
|
+
* Compose domain packs and MCP packs into a unified, deduplicated, ordered result.
|
|
48
|
+
* Cursor-specific: tracks backgroundAgentCompatible and MDC rule type distribution.
|
|
49
|
+
*/
|
|
50
|
+
function composePacks(domainPackKeys = [], mcpPackKeys = [], options = {}) {
|
|
51
|
+
const sizeBudget = options.sizeBudget || DEFAULT_SIZE_BUDGET;
|
|
52
|
+
const warnings = [];
|
|
53
|
+
|
|
54
|
+
// --- Resolve domain packs ---
|
|
55
|
+
const seenDomainKeys = new Set();
|
|
56
|
+
const rawDomainPacks = [];
|
|
57
|
+
for (const key of domainPackKeys) {
|
|
58
|
+
if (seenDomainKeys.has(key)) continue;
|
|
59
|
+
seenDomainKeys.add(key);
|
|
60
|
+
const pack = lookupDomainPack(key);
|
|
61
|
+
if (!pack) { warnings.push(`Domain pack "${key}" not found, skipped.`); continue; }
|
|
62
|
+
rawDomainPacks.push(pack);
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
rawDomainPacks.sort((a, b) => {
|
|
66
|
+
const orderA = PACK_DEPENDENCY_ORDER.indexOf(a.key);
|
|
67
|
+
const orderB = PACK_DEPENDENCY_ORDER.indexOf(b.key);
|
|
68
|
+
return (orderA === -1 ? 99 : orderA) - (orderB === -1 ? 99 : orderB);
|
|
69
|
+
});
|
|
70
|
+
|
|
71
|
+
const moduleOwner = new Map();
|
|
72
|
+
for (const pack of rawDomainPacks) {
|
|
73
|
+
const specificity = PACK_SPECIFICITY[pack.key] ?? 1;
|
|
74
|
+
for (const mod of pack.recommendedModules || []) {
|
|
75
|
+
const existing = moduleOwner.get(mod);
|
|
76
|
+
if (!existing || specificity > existing.specificity) {
|
|
77
|
+
moduleOwner.set(mod, { key: pack.key, specificity });
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
const allSurfaces = new Set();
|
|
83
|
+
for (const pack of rawDomainPacks) {
|
|
84
|
+
for (const surface of pack.recommendedSurfaces || []) allSurfaces.add(surface);
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
const allProposalFamilies = new Set();
|
|
88
|
+
for (const pack of rawDomainPacks) {
|
|
89
|
+
for (const family of pack.recommendedProposalFamilies || []) allProposalFamilies.add(family);
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
// --- Resolve MCP packs ---
|
|
93
|
+
const seenMcpKeys = new Set();
|
|
94
|
+
const resolvedMcpPacks = [];
|
|
95
|
+
for (const key of mcpPackKeys) {
|
|
96
|
+
if (seenMcpKeys.has(key)) continue;
|
|
97
|
+
seenMcpKeys.add(key);
|
|
98
|
+
const pack = lookupMcpPack(key);
|
|
99
|
+
if (!pack) { warnings.push(`MCP pack "${key}" not found, skipped.`); continue; }
|
|
100
|
+
resolvedMcpPacks.push(pack);
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
// Cursor-specific: check tool count budget
|
|
104
|
+
const estimatedTools = resolvedMcpPacks.length * 5;
|
|
105
|
+
if (estimatedTools > 35) {
|
|
106
|
+
warnings.push(`Estimated ~${estimatedTools} MCP tools. Cursor hard limit is ~40. Some tools may be silently dropped.`);
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
const mergedExcludeTools = new Set();
|
|
110
|
+
for (const pack of resolvedMcpPacks) {
|
|
111
|
+
for (const tool of pack.excludeTools || []) mergedExcludeTools.add(tool);
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
const mergedRequiredAuth = new Set();
|
|
115
|
+
for (const pack of resolvedMcpPacks) {
|
|
116
|
+
for (const auth of pack.requiredAuth || []) mergedRequiredAuth.add(auth);
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
// Cursor-specific: separate background-compatible from foreground-only MCP packs
|
|
120
|
+
const bgCompatible = resolvedMcpPacks.filter(p => p.backgroundAgentCompatible !== false);
|
|
121
|
+
const fgOnly = resolvedMcpPacks.filter(p => p.backgroundAgentCompatible === false);
|
|
122
|
+
|
|
123
|
+
const estimatedSize = estimateCompositionSize(rawDomainPacks, resolvedMcpPacks);
|
|
124
|
+
const overBudget = estimatedSize > sizeBudget;
|
|
125
|
+
if (overBudget) {
|
|
126
|
+
warnings.push(`Combined instruction size (~${estimatedSize} chars) exceeds budget (${sizeBudget}).`);
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
// MDC-specific: recommend rule type distribution
|
|
130
|
+
const mdcGuidance = {
|
|
131
|
+
alwaysApplyCount: 1, // Core rules only
|
|
132
|
+
autoAttachedCount: rawDomainPacks.length > 1 ? rawDomainPacks.length : 1,
|
|
133
|
+
agentRequestedCount: rawDomainPacks.some(p => p.key === 'enterprise-governed') ? 2 : 0,
|
|
134
|
+
recommendation: 'Keep alwaysApply to 1-2 rules. Use Auto Attached for stack-specific rules. Agent Requested for optional guides.',
|
|
135
|
+
};
|
|
136
|
+
|
|
137
|
+
return {
|
|
138
|
+
domainPacks: rawDomainPacks.map(p => ({
|
|
139
|
+
key: p.key,
|
|
140
|
+
label: p.label,
|
|
141
|
+
modulesOwned: [...moduleOwner.entries()].filter(([, owner]) => owner.key === p.key).map(([mod]) => mod),
|
|
142
|
+
})),
|
|
143
|
+
mcpPacks: resolvedMcpPacks.map(p => ({
|
|
144
|
+
key: p.key,
|
|
145
|
+
label: p.label,
|
|
146
|
+
serverName: p.serverName,
|
|
147
|
+
trustLevel: p.trustLevel,
|
|
148
|
+
backgroundAgentCompatible: p.backgroundAgentCompatible,
|
|
149
|
+
})),
|
|
150
|
+
backgroundCompatibleMcpPacks: bgCompatible.map(p => p.key),
|
|
151
|
+
foregroundOnlyMcpPacks: fgOnly.map(p => p.key),
|
|
152
|
+
merged: {
|
|
153
|
+
surfaces: [...allSurfaces],
|
|
154
|
+
proposalFamilies: [...allProposalFamilies],
|
|
155
|
+
modules: [...moduleOwner.entries()].map(([mod, owner]) => ({ module: mod, owner: owner.key })),
|
|
156
|
+
excludeTools: [...mergedExcludeTools].sort(),
|
|
157
|
+
requiredAuth: [...mergedRequiredAuth].sort(),
|
|
158
|
+
},
|
|
159
|
+
budget: {
|
|
160
|
+
estimatedSize,
|
|
161
|
+
limit: sizeBudget,
|
|
162
|
+
overBudget,
|
|
163
|
+
utilization: Math.round((estimatedSize / sizeBudget) * 100),
|
|
164
|
+
},
|
|
165
|
+
mcpToolEstimate: estimatedTools,
|
|
166
|
+
mcpToolLimit: 40,
|
|
167
|
+
mdcGuidance,
|
|
168
|
+
warnings,
|
|
169
|
+
};
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
function estimateCompositionSize(domainPacks, mcpPacks) {
|
|
173
|
+
let size = 0;
|
|
174
|
+
for (const pack of domainPacks) {
|
|
175
|
+
size += (pack.label || '').length + (pack.useWhen || '').length + (pack.adoption || '').length;
|
|
176
|
+
size += JSON.stringify(pack.recommendedModules || []).length;
|
|
177
|
+
size += JSON.stringify(pack.benchmarkFocus || []).length;
|
|
178
|
+
}
|
|
179
|
+
for (const pack of mcpPacks) {
|
|
180
|
+
size += (pack.label || '').length + (pack.description || '').length;
|
|
181
|
+
size += JSON.stringify(pack.jsonProjection || {}).length;
|
|
182
|
+
size += JSON.stringify(pack.excludeTools || []).length;
|
|
183
|
+
}
|
|
184
|
+
return size;
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
// ---------------------------------------------------------------------------
|
|
188
|
+
// 2. CI Template Library (5 templates)
|
|
189
|
+
// ---------------------------------------------------------------------------
|
|
190
|
+
|
|
191
|
+
const CI_TEMPLATES = [
|
|
192
|
+
{
|
|
193
|
+
key: 'cursor-pr-audit',
|
|
194
|
+
label: 'Cursor PR Audit',
|
|
195
|
+
filename: 'cursor-pr-audit.yml',
|
|
196
|
+
description: 'Runs nerviq audit on pull request diffs.',
|
|
197
|
+
trigger: 'pull_request',
|
|
198
|
+
},
|
|
199
|
+
{
|
|
200
|
+
key: 'cursor-bugbot-review',
|
|
201
|
+
label: 'Cursor BugBot Review',
|
|
202
|
+
filename: 'cursor-bugbot-review.yml',
|
|
203
|
+
description: 'Triggers BugBot code review on pull requests.',
|
|
204
|
+
trigger: 'pull_request',
|
|
205
|
+
},
|
|
206
|
+
{
|
|
207
|
+
key: 'cursor-scheduled-audit',
|
|
208
|
+
label: 'Cursor Scheduled Audit',
|
|
209
|
+
filename: 'cursor-scheduled-audit.yml',
|
|
210
|
+
description: 'Weekly Cursor audit of configuration health.',
|
|
211
|
+
trigger: 'schedule (cron)',
|
|
212
|
+
},
|
|
213
|
+
{
|
|
214
|
+
key: 'cursor-rules-lint',
|
|
215
|
+
label: 'Cursor Rules Lint',
|
|
216
|
+
filename: 'cursor-rules-lint.yml',
|
|
217
|
+
description: 'Validates MDC frontmatter in .cursor/rules/ on change.',
|
|
218
|
+
trigger: 'push (path filter)',
|
|
219
|
+
},
|
|
220
|
+
{
|
|
221
|
+
key: 'cursor-mcp-security',
|
|
222
|
+
label: 'Cursor MCP Security Check',
|
|
223
|
+
filename: 'cursor-mcp-security.yml',
|
|
224
|
+
description: 'Checks MCP config for hardcoded secrets and CVE patterns.',
|
|
225
|
+
trigger: 'push (path filter)',
|
|
226
|
+
},
|
|
227
|
+
];
|
|
228
|
+
|
|
229
|
+
const TEMPLATE_CONTENT = {
|
|
230
|
+
'cursor-pr-audit': `# Cursor PR Audit — generated by nerviq
|
|
231
|
+
name: Cursor PR Audit
|
|
232
|
+
|
|
233
|
+
on:
|
|
234
|
+
pull_request:
|
|
235
|
+
types: [opened, synchronize]
|
|
236
|
+
|
|
237
|
+
permissions:
|
|
238
|
+
contents: read
|
|
239
|
+
pull-requests: write
|
|
240
|
+
|
|
241
|
+
jobs:
|
|
242
|
+
cursor-audit:
|
|
243
|
+
runs-on: ubuntu-latest
|
|
244
|
+
timeout-minutes: 15
|
|
245
|
+
steps:
|
|
246
|
+
- uses: actions/checkout@v4
|
|
247
|
+
- name: Run nerviq Cursor audit
|
|
248
|
+
run: npx nerviq --platform cursor --json > audit-report.json
|
|
249
|
+
- uses: actions/upload-artifact@v4
|
|
250
|
+
with:
|
|
251
|
+
name: cursor-audit-report
|
|
252
|
+
path: audit-report.json
|
|
253
|
+
retention-days: 30
|
|
254
|
+
`,
|
|
255
|
+
|
|
256
|
+
'cursor-bugbot-review': `# Cursor BugBot Review — generated by nerviq
|
|
257
|
+
# NOTE: BugBot is configured per-repo in Cursor settings, not via GitHub Actions.
|
|
258
|
+
# This workflow documents the expected BugBot behavior.
|
|
259
|
+
name: Cursor BugBot Review
|
|
260
|
+
|
|
261
|
+
on:
|
|
262
|
+
pull_request:
|
|
263
|
+
types: [opened, synchronize]
|
|
264
|
+
|
|
265
|
+
permissions:
|
|
266
|
+
contents: read
|
|
267
|
+
|
|
268
|
+
jobs:
|
|
269
|
+
bugbot-check:
|
|
270
|
+
runs-on: ubuntu-latest
|
|
271
|
+
steps:
|
|
272
|
+
- uses: actions/checkout@v4
|
|
273
|
+
- name: Verify BugBot Configuration
|
|
274
|
+
run: |
|
|
275
|
+
echo "BugBot review is configured via Cursor Settings (per-repo)."
|
|
276
|
+
echo "Ensure BugBot is enabled and autofix is configured appropriately."
|
|
277
|
+
`,
|
|
278
|
+
|
|
279
|
+
'cursor-scheduled-audit': `# Cursor Scheduled Audit — generated by nerviq
|
|
280
|
+
name: Cursor Scheduled Audit
|
|
281
|
+
|
|
282
|
+
on:
|
|
283
|
+
schedule:
|
|
284
|
+
- cron: '0 9 * * 1'
|
|
285
|
+
workflow_dispatch:
|
|
286
|
+
|
|
287
|
+
permissions:
|
|
288
|
+
contents: read
|
|
289
|
+
issues: write
|
|
290
|
+
|
|
291
|
+
jobs:
|
|
292
|
+
audit:
|
|
293
|
+
runs-on: ubuntu-latest
|
|
294
|
+
timeout-minutes: 30
|
|
295
|
+
steps:
|
|
296
|
+
- uses: actions/checkout@v4
|
|
297
|
+
- name: Run nerviq audit
|
|
298
|
+
run: npx nerviq --platform cursor --json > audit-report.json
|
|
299
|
+
- uses: actions/upload-artifact@v4
|
|
300
|
+
with:
|
|
301
|
+
name: cursor-audit-report
|
|
302
|
+
path: audit-report.json
|
|
303
|
+
retention-days: 30
|
|
304
|
+
`,
|
|
305
|
+
|
|
306
|
+
'cursor-rules-lint': `# Cursor Rules Lint — generated by nerviq
|
|
307
|
+
name: Cursor Rules Lint
|
|
308
|
+
|
|
309
|
+
on:
|
|
310
|
+
push:
|
|
311
|
+
paths:
|
|
312
|
+
- '.cursor/rules/**'
|
|
313
|
+
- '.cursorrules'
|
|
314
|
+
|
|
315
|
+
permissions:
|
|
316
|
+
contents: read
|
|
317
|
+
|
|
318
|
+
jobs:
|
|
319
|
+
lint-rules:
|
|
320
|
+
runs-on: ubuntu-latest
|
|
321
|
+
steps:
|
|
322
|
+
- uses: actions/checkout@v4
|
|
323
|
+
- name: Check MDC frontmatter
|
|
324
|
+
run: |
|
|
325
|
+
ERRORS=0
|
|
326
|
+
for file in .cursor/rules/*.mdc; do
|
|
327
|
+
[ ! -f "$file" ] && continue
|
|
328
|
+
if ! head -1 "$file" | grep -q "^---"; then
|
|
329
|
+
echo "ERROR: $file missing MDC frontmatter (---)"
|
|
330
|
+
ERRORS=$((ERRORS + 1))
|
|
331
|
+
fi
|
|
332
|
+
done
|
|
333
|
+
if [ -f .cursorrules ]; then
|
|
334
|
+
echo "WARNING: .cursorrules exists — IGNORED by Cursor agent mode!"
|
|
335
|
+
echo "Migrate to .cursor/rules/*.mdc with proper MDC frontmatter."
|
|
336
|
+
fi
|
|
337
|
+
exit $ERRORS
|
|
338
|
+
`,
|
|
339
|
+
|
|
340
|
+
'cursor-mcp-security': `# Cursor MCP Security Check — generated by nerviq
|
|
341
|
+
name: Cursor MCP Security Check
|
|
342
|
+
|
|
343
|
+
on:
|
|
344
|
+
push:
|
|
345
|
+
paths:
|
|
346
|
+
- '.cursor/mcp.json'
|
|
347
|
+
|
|
348
|
+
permissions:
|
|
349
|
+
contents: read
|
|
350
|
+
|
|
351
|
+
jobs:
|
|
352
|
+
mcp-check:
|
|
353
|
+
runs-on: ubuntu-latest
|
|
354
|
+
steps:
|
|
355
|
+
- uses: actions/checkout@v4
|
|
356
|
+
- name: Check for hardcoded secrets
|
|
357
|
+
run: |
|
|
358
|
+
if [ ! -f .cursor/mcp.json ]; then exit 0; fi
|
|
359
|
+
# Check for hardcoded API keys/tokens (should use \${env:VAR})
|
|
360
|
+
if grep -P '"(key|token|secret|password|api)"\s*:\s*"(?!\\\$\\{env:)' .cursor/mcp.json; then
|
|
361
|
+
echo "ERROR: Hardcoded secrets detected in .cursor/mcp.json"
|
|
362
|
+
echo "Use \\\${env:VAR_NAME} syntax instead."
|
|
363
|
+
exit 1
|
|
364
|
+
fi
|
|
365
|
+
echo "MCP config security check passed."
|
|
366
|
+
`,
|
|
367
|
+
};
|
|
368
|
+
|
|
369
|
+
function getCiTemplate(templateKey) {
|
|
370
|
+
const meta = CI_TEMPLATES.find(t => t.key === templateKey);
|
|
371
|
+
if (!meta) return null;
|
|
372
|
+
return TEMPLATE_CONTENT[templateKey] || null;
|
|
373
|
+
}
|
|
374
|
+
|
|
375
|
+
// ---------------------------------------------------------------------------
|
|
376
|
+
// 3. Adoption Signal Gate (5 gates)
|
|
377
|
+
// ---------------------------------------------------------------------------
|
|
378
|
+
|
|
379
|
+
const GATE_THRESHOLDS = {
|
|
380
|
+
'ci-templates': {
|
|
381
|
+
metric: 'auditCount',
|
|
382
|
+
threshold: 3,
|
|
383
|
+
description: 'Activate CI templates after 3+ successful audits.',
|
|
384
|
+
},
|
|
385
|
+
'background-agents': {
|
|
386
|
+
metric: 'auditCount',
|
|
387
|
+
threshold: 2,
|
|
388
|
+
description: 'Activate background agent setup after 2+ audits.',
|
|
389
|
+
},
|
|
390
|
+
'multi-pack': {
|
|
391
|
+
metric: 'auditCount',
|
|
392
|
+
threshold: 2,
|
|
393
|
+
description: 'Activate multi-pack composition after 2+ audits.',
|
|
394
|
+
},
|
|
395
|
+
'automations': {
|
|
396
|
+
metric: 'auditCount',
|
|
397
|
+
threshold: 3,
|
|
398
|
+
description: 'Activate automation templates after 3+ audits.',
|
|
399
|
+
},
|
|
400
|
+
'governance-upgrade': {
|
|
401
|
+
metric: 'averageScore',
|
|
402
|
+
threshold: 70,
|
|
403
|
+
description: 'Suggest governance upgrade when average score exceeds 70.',
|
|
404
|
+
},
|
|
405
|
+
};
|
|
406
|
+
|
|
407
|
+
function getCursorHistory(dir, limit = 20) {
|
|
408
|
+
const fs = require('fs');
|
|
409
|
+
const snapshotDir = path.join(dir, '.claude', 'claudex-setup', 'snapshots');
|
|
410
|
+
try {
|
|
411
|
+
const files = fs.readdirSync(snapshotDir)
|
|
412
|
+
.filter(f => f.endsWith('.json'))
|
|
413
|
+
.sort()
|
|
414
|
+
.slice(-limit);
|
|
415
|
+
|
|
416
|
+
return files.map(f => {
|
|
417
|
+
try {
|
|
418
|
+
const data = JSON.parse(fs.readFileSync(path.join(snapshotDir, f), 'utf8'));
|
|
419
|
+
if (data.platform === 'cursor' || data.summary?.platform === 'cursor') return data;
|
|
420
|
+
return null;
|
|
421
|
+
} catch { return null; }
|
|
422
|
+
}).filter(Boolean);
|
|
423
|
+
} catch {
|
|
424
|
+
return [];
|
|
425
|
+
}
|
|
426
|
+
}
|
|
427
|
+
|
|
428
|
+
function checkAdoptionGate(gateKey, dir) {
|
|
429
|
+
const gate = GATE_THRESHOLDS[gateKey];
|
|
430
|
+
if (!gate) {
|
|
431
|
+
return { activated: false, current: 0, threshold: 0, gate: gateKey, description: `Unknown gate "${gateKey}".` };
|
|
432
|
+
}
|
|
433
|
+
|
|
434
|
+
const history = getCursorHistory(dir, 100);
|
|
435
|
+
let current = 0;
|
|
436
|
+
|
|
437
|
+
switch (gate.metric) {
|
|
438
|
+
case 'auditCount':
|
|
439
|
+
current = history.length;
|
|
440
|
+
break;
|
|
441
|
+
case 'averageScore': {
|
|
442
|
+
const scores = history.map(e => e.summary?.score).filter(s => typeof s === 'number');
|
|
443
|
+
current = scores.length > 0 ? Math.round(scores.reduce((a, b) => a + b, 0) / scores.length) : 0;
|
|
444
|
+
break;
|
|
445
|
+
}
|
|
446
|
+
default:
|
|
447
|
+
current = 0;
|
|
448
|
+
}
|
|
449
|
+
|
|
450
|
+
return {
|
|
451
|
+
activated: current >= gate.threshold,
|
|
452
|
+
current,
|
|
453
|
+
threshold: gate.threshold,
|
|
454
|
+
gate: gateKey,
|
|
455
|
+
description: gate.description,
|
|
456
|
+
};
|
|
457
|
+
}
|
|
458
|
+
|
|
459
|
+
module.exports = {
|
|
460
|
+
composePacks,
|
|
461
|
+
getCiTemplate,
|
|
462
|
+
CI_TEMPLATES,
|
|
463
|
+
checkAdoptionGate,
|
|
464
|
+
GATE_THRESHOLDS,
|
|
465
|
+
PACK_DEPENDENCY_ORDER,
|
|
466
|
+
PACK_SPECIFICITY,
|
|
467
|
+
DEFAULT_SIZE_BUDGET,
|
|
468
|
+
};
|