@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,229 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Cursor Governance Module
|
|
3
|
+
*
|
|
4
|
+
* 6 permission profiles, 7 hook equivalents, 5 policy packs.
|
|
5
|
+
*
|
|
6
|
+
* Cursor-specific differences from Copilot/Gemini:
|
|
7
|
+
* - 3 execution surfaces: foreground (IDE), background (cloud VM), automations (event-driven)
|
|
8
|
+
* - Privacy Mode OFF by default (code sent to model providers)
|
|
9
|
+
* - No terminal sandbox (unlike Copilot's VS Code sandbox)
|
|
10
|
+
* - Settings stored in SQLite (state.vscdb), NOT JSON
|
|
11
|
+
* - Automations run without approval — trigger misconfiguration = runaway agents
|
|
12
|
+
* - MCP hard limit ~40 tools, silent drop beyond
|
|
13
|
+
* - Background agent has full home directory read access (security finding Nov 2025)
|
|
14
|
+
*/
|
|
15
|
+
|
|
16
|
+
const { CURSOR_DOMAIN_PACKS } = require('./domain-packs');
|
|
17
|
+
const { CURSOR_MCP_PACKS } = require('./mcp-packs');
|
|
18
|
+
|
|
19
|
+
const CURSOR_PERMISSION_PROFILES = [
|
|
20
|
+
{
|
|
21
|
+
key: 'read-only',
|
|
22
|
+
label: 'Read Only',
|
|
23
|
+
risk: 'low',
|
|
24
|
+
defaultSandbox: 'no-writes',
|
|
25
|
+
approvalPolicy: 'always-confirm',
|
|
26
|
+
useWhen: 'First contact with a repo, security review, or auditing.',
|
|
27
|
+
behavior: 'Agent can read and suggest, but all edits and terminal commands require explicit confirmation.',
|
|
28
|
+
surfaces: ['foreground'],
|
|
29
|
+
},
|
|
30
|
+
{
|
|
31
|
+
key: 'standard',
|
|
32
|
+
label: 'Standard',
|
|
33
|
+
risk: 'medium',
|
|
34
|
+
defaultSandbox: 'user-approval',
|
|
35
|
+
approvalPolicy: 'selective-approval',
|
|
36
|
+
useWhen: 'Default product work where agent edits locally but risky commands need review.',
|
|
37
|
+
behavior: 'Agent proposes edits. Terminal commands require per-command approval unless auto-run enabled.',
|
|
38
|
+
surfaces: ['foreground'],
|
|
39
|
+
},
|
|
40
|
+
{
|
|
41
|
+
key: 'agent-mode',
|
|
42
|
+
label: 'Agent Mode',
|
|
43
|
+
risk: 'medium',
|
|
44
|
+
defaultSandbox: 'auto-run-trusted',
|
|
45
|
+
approvalPolicy: 'auto-approve-safe',
|
|
46
|
+
useWhen: 'Trusted repos where full agent mode is the primary workflow.',
|
|
47
|
+
behavior: 'Full agent mode. Auto-run for trusted commands. YOLO mode available but discouraged.',
|
|
48
|
+
surfaces: ['foreground'],
|
|
49
|
+
},
|
|
50
|
+
{
|
|
51
|
+
key: 'background-agent',
|
|
52
|
+
label: 'Background Agent',
|
|
53
|
+
risk: 'high',
|
|
54
|
+
defaultSandbox: 'ephemeral-vm',
|
|
55
|
+
approvalPolicy: 'pr-gate',
|
|
56
|
+
useWhen: 'Async tasks that create branches and PRs. Privacy Mode must be disabled.',
|
|
57
|
+
behavior: 'Runs on ephemeral Ubuntu VM. Auto-approved terminal. Creates branch + PR. Full home directory readable (security finding). No max tool call limit.',
|
|
58
|
+
surfaces: ['background'],
|
|
59
|
+
},
|
|
60
|
+
{
|
|
61
|
+
key: 'automation',
|
|
62
|
+
label: 'Automation',
|
|
63
|
+
risk: 'high',
|
|
64
|
+
defaultSandbox: 'ephemeral-vm',
|
|
65
|
+
approvalPolicy: 'event-triggered',
|
|
66
|
+
useWhen: 'Event-driven triggers (push, PR, Slack, timer). No human approval before execution.',
|
|
67
|
+
behavior: 'Cloud VM per run. 30-minute cap. Diffs staged for review. Secrets via vault only. Can run hundreds per hour.',
|
|
68
|
+
surfaces: ['automations'],
|
|
69
|
+
},
|
|
70
|
+
{
|
|
71
|
+
key: 'enterprise',
|
|
72
|
+
label: 'Enterprise',
|
|
73
|
+
risk: 'low',
|
|
74
|
+
defaultSandbox: 'org-policy-enforced',
|
|
75
|
+
approvalPolicy: 'org-admin-controlled',
|
|
76
|
+
useWhen: 'Enterprise tier with SSO, SCIM, audit logs, MCP/model allowlists.',
|
|
77
|
+
behavior: 'Admin-managed policies. Privacy Mode enforced org-wide. Audit logs and AI code tracking APIs. BugBot for automated PR review.',
|
|
78
|
+
surfaces: ['foreground', 'background', 'automations'],
|
|
79
|
+
},
|
|
80
|
+
];
|
|
81
|
+
|
|
82
|
+
const CURSOR_HOOK_REGISTRY = [
|
|
83
|
+
{
|
|
84
|
+
key: 'always-apply-rules',
|
|
85
|
+
file: '.cursor/rules/*.mdc',
|
|
86
|
+
triggerPoint: 'alwaysApply: true',
|
|
87
|
+
matcher: 'every chat and agent message',
|
|
88
|
+
purpose: 'Inject core instructions into every agent interaction.',
|
|
89
|
+
risk: 'low',
|
|
90
|
+
},
|
|
91
|
+
{
|
|
92
|
+
key: 'auto-attached-rules',
|
|
93
|
+
file: '.cursor/rules/*.mdc',
|
|
94
|
+
triggerPoint: 'globs match',
|
|
95
|
+
matcher: 'file glob patterns',
|
|
96
|
+
purpose: 'Inject context-specific rules when matching files are open or referenced.',
|
|
97
|
+
risk: 'low',
|
|
98
|
+
},
|
|
99
|
+
{
|
|
100
|
+
key: 'auto-run-terminal',
|
|
101
|
+
file: 'Cursor Settings (SQLite)',
|
|
102
|
+
triggerPoint: 'terminal command execution',
|
|
103
|
+
matcher: 'terminal command patterns',
|
|
104
|
+
purpose: 'Auto-approve terminal commands without user confirmation (YOLO mode).',
|
|
105
|
+
risk: 'critical',
|
|
106
|
+
},
|
|
107
|
+
{
|
|
108
|
+
key: 'automation-trigger',
|
|
109
|
+
file: '.cursor/automations/*.yaml',
|
|
110
|
+
triggerPoint: 'event (push, PR, Slack, timer, webhook)',
|
|
111
|
+
matcher: 'event configuration',
|
|
112
|
+
purpose: 'Trigger cloud agent execution on specified events. Runs WITHOUT approval.',
|
|
113
|
+
risk: 'high',
|
|
114
|
+
},
|
|
115
|
+
{
|
|
116
|
+
key: 'bugbot-review',
|
|
117
|
+
file: 'BugBot config (per-repo)',
|
|
118
|
+
triggerPoint: 'PR opened/updated',
|
|
119
|
+
matcher: 'PR diff',
|
|
120
|
+
purpose: 'Automated code review on PRs. Can spawn cloud agent for auto-fixes.',
|
|
121
|
+
risk: 'medium',
|
|
122
|
+
},
|
|
123
|
+
{
|
|
124
|
+
key: 'environment-setup',
|
|
125
|
+
file: '.cursor/environment.json',
|
|
126
|
+
triggerPoint: 'background agent boot',
|
|
127
|
+
matcher: 'VM configuration',
|
|
128
|
+
purpose: 'Configure background agent VM: base image, env vars, persisted dirs, processes.',
|
|
129
|
+
risk: 'medium',
|
|
130
|
+
},
|
|
131
|
+
{
|
|
132
|
+
key: 'mcp-tool-approval',
|
|
133
|
+
file: '.cursor/mcp.json',
|
|
134
|
+
triggerPoint: 'MCP tool invocation',
|
|
135
|
+
matcher: 'tool name/server',
|
|
136
|
+
purpose: 'Control which MCP tools are available. Auto-run model for approved tools.',
|
|
137
|
+
risk: 'medium',
|
|
138
|
+
},
|
|
139
|
+
];
|
|
140
|
+
|
|
141
|
+
const CURSOR_POLICY_PACKS = [
|
|
142
|
+
{
|
|
143
|
+
key: 'baseline-safe',
|
|
144
|
+
label: 'Baseline Safe',
|
|
145
|
+
modules: ['.cursor/rules/ with alwaysApply', 'no .cursorrules', 'Privacy Mode awareness', 'no secrets in rules'],
|
|
146
|
+
useWhen: 'Default local Cursor rollout.',
|
|
147
|
+
},
|
|
148
|
+
{
|
|
149
|
+
key: 'background-agent-safe',
|
|
150
|
+
label: 'Background Agent Safe',
|
|
151
|
+
modules: ['environment.json configured', 'PR review gate', 'KMS secrets only', 'no direct push to main'],
|
|
152
|
+
useWhen: 'Repos using background agents for async tasks.',
|
|
153
|
+
},
|
|
154
|
+
{
|
|
155
|
+
key: 'automation-safe',
|
|
156
|
+
label: 'Automation Safe',
|
|
157
|
+
modules: ['scoped triggers (no wildcards)', 'debounce on frequent events', 'error notification', 'rate limits documented'],
|
|
158
|
+
useWhen: 'Repos using event-driven automations.',
|
|
159
|
+
},
|
|
160
|
+
{
|
|
161
|
+
key: 'enterprise-governed',
|
|
162
|
+
label: 'Enterprise Governed',
|
|
163
|
+
modules: ['SSO configured', 'audit logs enabled', 'MCP allowlist', 'Privacy Mode enforced', 'model access policy'],
|
|
164
|
+
useWhen: 'Enterprise tier repos with strict governance requirements.',
|
|
165
|
+
},
|
|
166
|
+
{
|
|
167
|
+
key: 'privacy-first',
|
|
168
|
+
label: 'Privacy First',
|
|
169
|
+
modules: ['Privacy Mode enabled', 'no secrets in any Cursor config', 'MCP env vars use ${env:} syntax', 'background agent home dir exposure documented'],
|
|
170
|
+
useWhen: 'Repos handling sensitive data where Privacy Mode and data protection are paramount.',
|
|
171
|
+
},
|
|
172
|
+
];
|
|
173
|
+
|
|
174
|
+
const CURSOR_PILOT_ROLLOUT_KIT = {
|
|
175
|
+
recommendedScope: [
|
|
176
|
+
'Start with audit and setup on one trusted repo before enabling background agents.',
|
|
177
|
+
'Keep .cursor/rules/ and .cursor/mcp.json in version control.',
|
|
178
|
+
'Enable Privacy Mode before using with sensitive code.',
|
|
179
|
+
'Migrate .cursorrules to .cursor/rules/*.mdc before relying on agent mode.',
|
|
180
|
+
'Test background agents on a non-critical repo first.',
|
|
181
|
+
'If using automations, start with manual triggers before event-driven.',
|
|
182
|
+
],
|
|
183
|
+
approvals: [
|
|
184
|
+
'Engineering owner approves auto-run terminal policy and background agent usage.',
|
|
185
|
+
'Security owner approves Privacy Mode status and MCP server allowlist.',
|
|
186
|
+
'Pilot owner records before/after audit deltas and rollback expectations.',
|
|
187
|
+
'Org admin approves automation trigger scope and model access policy.',
|
|
188
|
+
],
|
|
189
|
+
successMetrics: [
|
|
190
|
+
'Audit score delta',
|
|
191
|
+
'Surface coverage (foreground + background + automations)',
|
|
192
|
+
'Time to first useful agent task',
|
|
193
|
+
'No-overwrite rate on existing repo files',
|
|
194
|
+
'Legacy .cursorrules migration completion',
|
|
195
|
+
'MCP tool count within 40-tool limit',
|
|
196
|
+
],
|
|
197
|
+
rollbackExpectations: [
|
|
198
|
+
'Every Cursor setup/apply write path should emit a rollback artifact.',
|
|
199
|
+
'Re-run audit after rollback to confirm the repo returned to expected state.',
|
|
200
|
+
'Background agents can be disabled by removing .cursor/environment.json.',
|
|
201
|
+
'Automations can be disabled by removing .cursor/automations/ directory.',
|
|
202
|
+
],
|
|
203
|
+
};
|
|
204
|
+
|
|
205
|
+
function getCursorGovernanceSummary() {
|
|
206
|
+
return {
|
|
207
|
+
platform: 'cursor',
|
|
208
|
+
platformLabel: 'Cursor AI',
|
|
209
|
+
permissionProfiles: CURSOR_PERMISSION_PROFILES,
|
|
210
|
+
hookRegistry: CURSOR_HOOK_REGISTRY,
|
|
211
|
+
policyPacks: CURSOR_POLICY_PACKS,
|
|
212
|
+
domainPacks: CURSOR_DOMAIN_PACKS,
|
|
213
|
+
mcpPacks: CURSOR_MCP_PACKS,
|
|
214
|
+
pilotRolloutKit: CURSOR_PILOT_ROLLOUT_KIT,
|
|
215
|
+
platformCaveats: [
|
|
216
|
+
{ id: 'cursorrules-ignored', severity: 'critical', message: 'Agent mode ignores .cursorrules — only .cursor/rules/*.mdc files work.' },
|
|
217
|
+
{ id: 'privacy-off', severity: 'high', message: 'Privacy Mode OFF by default — code sent to model providers without zero-retention.' },
|
|
218
|
+
{ id: 'mcp-tool-limit', severity: 'medium', message: 'MCP hard limit ~40 tools. Exceeding silently drops tools without warning.' },
|
|
219
|
+
{ id: 'code-reversion', severity: 'critical', message: 'Code reversion risk from agent review + format-on-save + cloud sync conflict.' },
|
|
220
|
+
{ id: 'no-terminal-sandbox', severity: 'high', message: 'No terminal sandbox equivalent (unlike Copilot). All terminal commands execute directly.' },
|
|
221
|
+
{ id: 'bg-agent-home-dir', severity: 'critical', message: 'Background agents have full read access to home directory (~/.ssh/, ~/.aws/credentials, ~/.npmrc).' },
|
|
222
|
+
{ id: 'automation-no-approval', severity: 'high', message: 'Automations run without human approval. Misconfigured triggers = uncontrolled execution.' },
|
|
223
|
+
],
|
|
224
|
+
};
|
|
225
|
+
}
|
|
226
|
+
|
|
227
|
+
module.exports = {
|
|
228
|
+
getCursorGovernanceSummary,
|
|
229
|
+
};
|
|
@@ -0,0 +1,391 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Cursor Interactive Wizard — 10-stage guided setup.
|
|
3
|
+
*
|
|
4
|
+
* Adapted for Cursor's 3-surface architecture (foreground, background, automations).
|
|
5
|
+
*
|
|
6
|
+
* Stages:
|
|
7
|
+
* 1. Project detection (stacks, existing .cursor/, .cursorrules)
|
|
8
|
+
* 2. Rule type selection (Always, Auto Attached, Agent Requested, Manual)
|
|
9
|
+
* 3. Legacy migration (.cursorrules → .cursor/rules/)
|
|
10
|
+
* 4. Background agent setup
|
|
11
|
+
* 5. Domain pack selection
|
|
12
|
+
* 6. MCP pack selection
|
|
13
|
+
* 7. Automation config
|
|
14
|
+
* 8. BugBot configuration
|
|
15
|
+
* 9. Privacy & security
|
|
16
|
+
* 10. Review & generate
|
|
17
|
+
*/
|
|
18
|
+
|
|
19
|
+
const fs = require('fs');
|
|
20
|
+
const os = require('os');
|
|
21
|
+
const path = require('path');
|
|
22
|
+
const readline = require('readline');
|
|
23
|
+
const { STACKS } = require('../techniques');
|
|
24
|
+
const { CursorProjectContext } = require('./context');
|
|
25
|
+
const { CURSOR_TECHNIQUES } = require('./techniques');
|
|
26
|
+
const { CURSOR_DOMAIN_PACKS, detectCursorDomainPacks } = require('./domain-packs');
|
|
27
|
+
const { recommendCursorMcpPacks, CURSOR_MCP_PACKS } = require('./mcp-packs');
|
|
28
|
+
|
|
29
|
+
const COLORS = {
|
|
30
|
+
reset: '\x1b[0m', bold: '\x1b[1m', dim: '\x1b[2m',
|
|
31
|
+
red: '\x1b[31m', green: '\x1b[32m', yellow: '\x1b[33m',
|
|
32
|
+
blue: '\x1b[36m', magenta: '\x1b[35m',
|
|
33
|
+
};
|
|
34
|
+
const c = (text, color) => `${COLORS[color] || ''}${text}${COLORS.reset}`;
|
|
35
|
+
|
|
36
|
+
function ask(rl, question) {
|
|
37
|
+
return new Promise(resolve => rl.question(question, resolve));
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
function isTTY() {
|
|
41
|
+
return Boolean(process.stdin.isTTY && process.stdout.isTTY);
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
const STAGE_NAMES = [
|
|
45
|
+
'Project Detection',
|
|
46
|
+
'Rule Type Selection',
|
|
47
|
+
'Legacy Migration',
|
|
48
|
+
'Background Agent Setup',
|
|
49
|
+
'Domain Pack Selection',
|
|
50
|
+
'MCP Pack Selection',
|
|
51
|
+
'Automation Config',
|
|
52
|
+
'BugBot Configuration',
|
|
53
|
+
'Privacy & Security',
|
|
54
|
+
'Review & Generate',
|
|
55
|
+
];
|
|
56
|
+
|
|
57
|
+
function printStageHeader(index) {
|
|
58
|
+
console.log('');
|
|
59
|
+
console.log(c(` ── Stage ${index + 1}/${STAGE_NAMES.length}: ${STAGE_NAMES[index]} ──`, 'magenta'));
|
|
60
|
+
console.log('');
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
// --- Stage 1: Project Detection ---
|
|
64
|
+
|
|
65
|
+
function runProjectDetection(ctx) {
|
|
66
|
+
const stacks = ctx.detectStacks(STACKS);
|
|
67
|
+
const rules = ctx.cursorRules ? ctx.cursorRules() : [];
|
|
68
|
+
const hasLegacy = ctx.hasLegacyRules ? ctx.hasLegacyRules() : false;
|
|
69
|
+
const hasMcpJson = ctx.mcpConfig().ok;
|
|
70
|
+
const hasEnvJson = ctx.environmentJson().ok;
|
|
71
|
+
const automations = ctx.automationsConfig ? ctx.automationsConfig() : [];
|
|
72
|
+
const surfaces = ctx.detectSurfaces();
|
|
73
|
+
|
|
74
|
+
const auditResults = [];
|
|
75
|
+
for (const [key, technique] of Object.entries(CURSOR_TECHNIQUES)) {
|
|
76
|
+
auditResults.push({ key, ...technique, passed: technique.check(ctx) });
|
|
77
|
+
}
|
|
78
|
+
const passed = auditResults.filter(r => r.passed === true);
|
|
79
|
+
const failed = auditResults.filter(r => r.passed === false);
|
|
80
|
+
|
|
81
|
+
return { stacks, rules, hasLegacy, hasMcpJson, hasEnvJson, automations, surfaces, auditResults, passed, failed };
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
async function stageProjectDetection(rl, ctx, state) {
|
|
85
|
+
printStageHeader(0);
|
|
86
|
+
const det = runProjectDetection(ctx);
|
|
87
|
+
Object.assign(state, det);
|
|
88
|
+
|
|
89
|
+
if (det.stacks.length > 0) console.log(c(` Detected stacks: ${det.stacks.map(s => s.label).join(', ')}`, 'blue'));
|
|
90
|
+
else console.log(c(' No specific stack detected — will use baseline defaults.', 'dim'));
|
|
91
|
+
|
|
92
|
+
console.log(c(` Working directory: ${ctx.dir}`, 'dim'));
|
|
93
|
+
console.log('');
|
|
94
|
+
console.log(` ${c(`${det.passed.length}/${det.auditResults.length}`, 'bold')} Cursor checks passing.`);
|
|
95
|
+
console.log(` ${c(String(det.failed.length), 'yellow')} improvements available.`);
|
|
96
|
+
console.log('');
|
|
97
|
+
console.log(` Surfaces: FG ${det.surfaces.foreground ? c('Y', 'green') : c('N', 'red')} | BG ${det.surfaces.background ? c('Y', 'green') : c('N', 'red')} | Auto ${det.surfaces.automations ? c('Y', 'green') : c('N', 'red')}`);
|
|
98
|
+
console.log(` Rules: ${det.rules.length} .mdc files${det.hasLegacy ? c(' + .cursorrules (IGNORED by agents!)', 'red') : ''}`);
|
|
99
|
+
|
|
100
|
+
if (det.rules.length > 0 || det.hasLegacy) {
|
|
101
|
+
console.log('');
|
|
102
|
+
if (det.hasLegacy) console.log(c(' CRITICAL: .cursorrules found — this file is IGNORED by agent mode!', 'red'));
|
|
103
|
+
if (det.rules.length > 0) console.log(c(` ${det.rules.length} .mdc rule files in .cursor/rules/`, 'dim'));
|
|
104
|
+
if (det.hasMcpJson) console.log(c(' .cursor/mcp.json found', 'dim'));
|
|
105
|
+
if (det.hasEnvJson) console.log(c(' .cursor/environment.json found', 'dim'));
|
|
106
|
+
console.log('');
|
|
107
|
+
|
|
108
|
+
const answer = await ask(rl, c(' Merge with existing config or replace? (merge/replace/quit) ', 'magenta'));
|
|
109
|
+
const choice = answer.trim().toLowerCase();
|
|
110
|
+
if (choice === 'quit' || choice === 'q') return 'quit';
|
|
111
|
+
state.migrationMode = choice === 'replace' ? 'replace' : 'merge';
|
|
112
|
+
} else {
|
|
113
|
+
state.migrationMode = 'create';
|
|
114
|
+
console.log('');
|
|
115
|
+
console.log(c(' No existing Cursor rules — will create fresh setup.', 'dim'));
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
return 'next';
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
// --- Stage 2: Rule Type Selection ---
|
|
122
|
+
|
|
123
|
+
async function stageRuleTypeSelection(rl, _ctx, state) {
|
|
124
|
+
printStageHeader(1);
|
|
125
|
+
|
|
126
|
+
console.log(' Cursor supports 4 rule types. Which do you want to generate?');
|
|
127
|
+
console.log('');
|
|
128
|
+
console.log(` ${c('1', 'bold')}. ${c('Always Apply only', 'blue')} — Core rules for every interaction.`);
|
|
129
|
+
console.log(` ${c('2', 'bold')}. ${c('Always + Auto Attached', 'blue')} — Core + file-type-specific rules.`);
|
|
130
|
+
console.log(` ${c('3', 'bold')}. ${c('Full set', 'blue')} — Always + Auto Attached + Agent Requested.`);
|
|
131
|
+
console.log('');
|
|
132
|
+
|
|
133
|
+
const answer = await ask(rl, c(' Choice (1-3, or b=back, q=quit) [2]: ', 'magenta'));
|
|
134
|
+
const trimmed = answer.trim().toLowerCase();
|
|
135
|
+
if (trimmed === 'b') return 'back';
|
|
136
|
+
if (trimmed === 'q') return 'quit';
|
|
137
|
+
|
|
138
|
+
const choice = parseInt(trimmed, 10);
|
|
139
|
+
state.ruleTypes = ['always'];
|
|
140
|
+
if (choice >= 2 || trimmed === '') state.ruleTypes.push('auto-attached');
|
|
141
|
+
if (choice >= 3) state.ruleTypes.push('agent-requested');
|
|
142
|
+
|
|
143
|
+
console.log(c(` → Rule types: ${state.ruleTypes.join(', ')}`, 'green'));
|
|
144
|
+
return 'next';
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
// --- Stage 3: Legacy Migration ---
|
|
148
|
+
|
|
149
|
+
async function stageLegacyMigration(rl, ctx, state) {
|
|
150
|
+
if (!state.hasLegacy) return 'next';
|
|
151
|
+
|
|
152
|
+
printStageHeader(2);
|
|
153
|
+
|
|
154
|
+
console.log(c(' CRITICAL: .cursorrules file detected!', 'red'));
|
|
155
|
+
console.log('');
|
|
156
|
+
console.log(' Agent mode COMPLETELY IGNORES .cursorrules.');
|
|
157
|
+
console.log(' Only .cursor/rules/*.mdc files with MDC frontmatter reach agents.');
|
|
158
|
+
console.log('');
|
|
159
|
+
console.log(` ${c('1', 'bold')}. ${c('Auto-migrate', 'blue')} — Convert .cursorrules content to .mdc format.`);
|
|
160
|
+
console.log(` ${c('2', 'bold')}. ${c('Keep both', 'yellow')} — Generate new .mdc rules alongside .cursorrules.`);
|
|
161
|
+
console.log(` ${c('3', 'bold')}. ${c('Skip', 'dim')} — Handle migration manually later.`);
|
|
162
|
+
console.log('');
|
|
163
|
+
|
|
164
|
+
const answer = await ask(rl, c(' Choice (1-3, or b=back, q=quit) [1]: ', 'magenta'));
|
|
165
|
+
const trimmed = answer.trim().toLowerCase();
|
|
166
|
+
if (trimmed === 'b') return 'back';
|
|
167
|
+
if (trimmed === 'q') return 'quit';
|
|
168
|
+
|
|
169
|
+
const choice = parseInt(trimmed, 10);
|
|
170
|
+
state.legacyMigration = choice === 3 ? 'skip' : choice === 2 ? 'keep-both' : 'auto-migrate';
|
|
171
|
+
console.log(c(` → Legacy migration: ${state.legacyMigration}`, 'green'));
|
|
172
|
+
return 'next';
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
// --- Stage 4: Background Agent Setup ---
|
|
176
|
+
|
|
177
|
+
async function stageBackgroundAgent(rl, _ctx, state) {
|
|
178
|
+
printStageHeader(3);
|
|
179
|
+
|
|
180
|
+
console.log(' Configure background agent environment?');
|
|
181
|
+
console.log('');
|
|
182
|
+
console.log(c(' Background agents run on ephemeral Ubuntu VMs.', 'dim'));
|
|
183
|
+
console.log(c(' SECURITY: They have full home directory read access.', 'yellow'));
|
|
184
|
+
console.log(c(' Privacy Mode must be DISABLED to use background agents.', 'yellow'));
|
|
185
|
+
console.log('');
|
|
186
|
+
|
|
187
|
+
const answer = await ask(rl, c(' Generate .cursor/environment.json? (y/n, or b=back, q=quit) [y]: ', 'magenta'));
|
|
188
|
+
const trimmed = answer.trim().toLowerCase();
|
|
189
|
+
if (trimmed === 'b') return 'back';
|
|
190
|
+
if (trimmed === 'q') return 'quit';
|
|
191
|
+
|
|
192
|
+
state.generateEnvironment = trimmed !== 'n';
|
|
193
|
+
console.log(c(` → Background agent: ${state.generateEnvironment ? 'will configure' : 'skip'}`, 'green'));
|
|
194
|
+
return 'next';
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
// --- Stage 5: Domain Pack Selection ---
|
|
198
|
+
|
|
199
|
+
async function stageDomainPacks(rl, ctx, state) {
|
|
200
|
+
printStageHeader(4);
|
|
201
|
+
|
|
202
|
+
const detected = detectCursorDomainPacks(ctx, state.stacks || []);
|
|
203
|
+
state.domainPacks = detected;
|
|
204
|
+
|
|
205
|
+
console.log(` Detected ${detected.length} domain pack(s):`);
|
|
206
|
+
console.log('');
|
|
207
|
+
detected.forEach((pack, i) => {
|
|
208
|
+
console.log(` ${c(`${i + 1}`, 'bold')}. ${c(pack.label, 'blue')} — ${pack.matchReasons[0] || pack.useWhen}`);
|
|
209
|
+
});
|
|
210
|
+
console.log('');
|
|
211
|
+
|
|
212
|
+
const answer = await ask(rl, c(' Accept detected packs? (y/n, or b=back, q=quit) [y]: ', 'magenta'));
|
|
213
|
+
const trimmed = answer.trim().toLowerCase();
|
|
214
|
+
if (trimmed === 'b') return 'back';
|
|
215
|
+
if (trimmed === 'q') return 'quit';
|
|
216
|
+
if (trimmed === 'n') state.domainPacks = [];
|
|
217
|
+
|
|
218
|
+
console.log(c(` → Domain packs: ${state.domainPacks.map(p => p.label).join(', ') || 'none'}`, 'green'));
|
|
219
|
+
return 'next';
|
|
220
|
+
}
|
|
221
|
+
|
|
222
|
+
// --- Stage 6: MCP Pack Selection ---
|
|
223
|
+
|
|
224
|
+
async function stageMcpPacks(rl, ctx, state) {
|
|
225
|
+
printStageHeader(5);
|
|
226
|
+
|
|
227
|
+
const backgroundOnly = state.generateEnvironment && !state.surfaces?.foreground;
|
|
228
|
+
const recommended = recommendCursorMcpPacks(state.stacks || [], state.domainPacks || [], { ctx, backgroundOnly });
|
|
229
|
+
state.mcpPacks = recommended;
|
|
230
|
+
|
|
231
|
+
console.log(` Recommended ${recommended.length} MCP pack(s):`);
|
|
232
|
+
console.log(c(` (Cursor hard limit: ~40 tools total — estimated: ~${recommended.length * 5} tools)`, 'yellow'));
|
|
233
|
+
console.log('');
|
|
234
|
+
recommended.forEach((pack, i) => {
|
|
235
|
+
const bgIcon = pack.backgroundAgentCompatible === false ? c(' [FG only]', 'yellow') : '';
|
|
236
|
+
console.log(` ${c(`${i + 1}`, 'bold')}. ${c(pack.label, 'blue')}${bgIcon} — ${pack.description}`);
|
|
237
|
+
});
|
|
238
|
+
console.log('');
|
|
239
|
+
|
|
240
|
+
const answer = await ask(rl, c(' Accept recommended packs? (y/n, or b=back, q=quit) [y]: ', 'magenta'));
|
|
241
|
+
const trimmed = answer.trim().toLowerCase();
|
|
242
|
+
if (trimmed === 'b') return 'back';
|
|
243
|
+
if (trimmed === 'q') return 'quit';
|
|
244
|
+
if (trimmed === 'n') state.mcpPacks = [];
|
|
245
|
+
|
|
246
|
+
console.log(c(` → MCP packs: ${state.mcpPacks.map(p => p.label).join(', ') || 'none'}`, 'green'));
|
|
247
|
+
return 'next';
|
|
248
|
+
}
|
|
249
|
+
|
|
250
|
+
// --- Stage 7: Automation Config ---
|
|
251
|
+
|
|
252
|
+
async function stageAutomationConfig(rl, _ctx, state) {
|
|
253
|
+
printStageHeader(6);
|
|
254
|
+
|
|
255
|
+
console.log(' Configure event-driven automations?');
|
|
256
|
+
console.log('');
|
|
257
|
+
console.log(c(' Automations run WITHOUT human approval.', 'red'));
|
|
258
|
+
console.log(c(' Supported triggers: cron, GitHub events, Slack, Linear, webhook, etc.', 'dim'));
|
|
259
|
+
console.log(c(' Each run has a 30-minute cap and fresh container.', 'dim'));
|
|
260
|
+
console.log('');
|
|
261
|
+
|
|
262
|
+
const answer = await ask(rl, c(' Set up automations? (y/n, or b=back, q=quit) [n]: ', 'magenta'));
|
|
263
|
+
const trimmed = answer.trim().toLowerCase();
|
|
264
|
+
if (trimmed === 'b') return 'back';
|
|
265
|
+
if (trimmed === 'q') return 'quit';
|
|
266
|
+
|
|
267
|
+
state.generateAutomations = trimmed === 'y';
|
|
268
|
+
console.log(c(` → Automations: ${state.generateAutomations ? 'will configure' : 'skip'}`, 'green'));
|
|
269
|
+
return 'next';
|
|
270
|
+
}
|
|
271
|
+
|
|
272
|
+
// --- Stage 8: BugBot ---
|
|
273
|
+
|
|
274
|
+
async function stageBugbot(rl, _ctx, state) {
|
|
275
|
+
printStageHeader(7);
|
|
276
|
+
|
|
277
|
+
console.log(' Configure BugBot for automated PR review?');
|
|
278
|
+
console.log('');
|
|
279
|
+
console.log(c(' BugBot processes 2M+ PRs/month. Can auto-fix >70% of issues.', 'dim'));
|
|
280
|
+
console.log(c(' Pricing: $40/user/month for up to 200 PRs/month.', 'dim'));
|
|
281
|
+
console.log('');
|
|
282
|
+
|
|
283
|
+
const answer = await ask(rl, c(' Generate BugBot configuration guide? (y/n, or b=back, q=quit) [y]: ', 'magenta'));
|
|
284
|
+
const trimmed = answer.trim().toLowerCase();
|
|
285
|
+
if (trimmed === 'b') return 'back';
|
|
286
|
+
if (trimmed === 'q') return 'quit';
|
|
287
|
+
|
|
288
|
+
state.generateBugbot = trimmed !== 'n';
|
|
289
|
+
console.log(c(` → BugBot: ${state.generateBugbot ? 'will configure' : 'skip'}`, 'green'));
|
|
290
|
+
return 'next';
|
|
291
|
+
}
|
|
292
|
+
|
|
293
|
+
// --- Stage 9: Privacy & Security ---
|
|
294
|
+
|
|
295
|
+
async function stagePrivacySecurity(rl, _ctx, state) {
|
|
296
|
+
printStageHeader(8);
|
|
297
|
+
|
|
298
|
+
console.log(c(' IMPORTANT: Privacy Mode is OFF by default in Cursor!', 'red'));
|
|
299
|
+
console.log('');
|
|
300
|
+
console.log(' When Privacy Mode is off, your code is sent to model providers.');
|
|
301
|
+
console.log(' Enable in: Cursor Settings > General > Privacy Mode');
|
|
302
|
+
console.log('');
|
|
303
|
+
|
|
304
|
+
const answer = await ask(rl, c(' Acknowledge privacy risk and continue? (y/n, or b=back, q=quit) [y]: ', 'magenta'));
|
|
305
|
+
const trimmed = answer.trim().toLowerCase();
|
|
306
|
+
if (trimmed === 'b') return 'back';
|
|
307
|
+
if (trimmed === 'q') return 'quit';
|
|
308
|
+
if (trimmed === 'n') return 'quit';
|
|
309
|
+
|
|
310
|
+
state.privacyAcknowledged = true;
|
|
311
|
+
console.log(c(' → Privacy risk acknowledged. Remember to enable Privacy Mode for sensitive repos.', 'yellow'));
|
|
312
|
+
return 'next';
|
|
313
|
+
}
|
|
314
|
+
|
|
315
|
+
// --- Stage 10: Review & Generate ---
|
|
316
|
+
|
|
317
|
+
async function stageReviewGenerate(rl, _ctx, state) {
|
|
318
|
+
printStageHeader(9);
|
|
319
|
+
|
|
320
|
+
console.log(' Summary of your Cursor setup:');
|
|
321
|
+
console.log('');
|
|
322
|
+
console.log(` Rule types: ${(state.ruleTypes || []).join(', ')}`);
|
|
323
|
+
console.log(` Legacy migration: ${state.legacyMigration || 'N/A'}`);
|
|
324
|
+
console.log(` Background agent: ${state.generateEnvironment ? 'yes' : 'no'}`);
|
|
325
|
+
console.log(` Domain packs: ${(state.domainPacks || []).map(p => p.label).join(', ') || 'none'}`);
|
|
326
|
+
console.log(` MCP packs: ${(state.mcpPacks || []).map(p => p.label).join(', ') || 'none'}`);
|
|
327
|
+
console.log(` Automations: ${state.generateAutomations ? 'yes' : 'no'}`);
|
|
328
|
+
console.log(` BugBot: ${state.generateBugbot ? 'yes' : 'no'}`);
|
|
329
|
+
console.log('');
|
|
330
|
+
|
|
331
|
+
const answer = await ask(rl, c(' Generate files? (y/n, or b=back, q=quit) [y]: ', 'magenta'));
|
|
332
|
+
const trimmed = answer.trim().toLowerCase();
|
|
333
|
+
if (trimmed === 'b') return 'back';
|
|
334
|
+
if (trimmed === 'q') return 'quit';
|
|
335
|
+
if (trimmed === 'n') return 'quit';
|
|
336
|
+
|
|
337
|
+
state.confirmed = true;
|
|
338
|
+
return 'done';
|
|
339
|
+
}
|
|
340
|
+
|
|
341
|
+
// --- Main Wizard ---
|
|
342
|
+
|
|
343
|
+
const STAGES = [
|
|
344
|
+
stageProjectDetection,
|
|
345
|
+
stageRuleTypeSelection,
|
|
346
|
+
stageLegacyMigration,
|
|
347
|
+
stageBackgroundAgent,
|
|
348
|
+
stageDomainPacks,
|
|
349
|
+
stageMcpPacks,
|
|
350
|
+
stageAutomationConfig,
|
|
351
|
+
stageBugbot,
|
|
352
|
+
stagePrivacySecurity,
|
|
353
|
+
stageReviewGenerate,
|
|
354
|
+
];
|
|
355
|
+
|
|
356
|
+
async function runCursorWizard(options) {
|
|
357
|
+
if (!isTTY()) {
|
|
358
|
+
console.log('Interactive wizard requires a TTY. Use --non-interactive or pipe mode instead.');
|
|
359
|
+
return null;
|
|
360
|
+
}
|
|
361
|
+
|
|
362
|
+
const rl = readline.createInterface({ input: process.stdin, output: process.stdout });
|
|
363
|
+
const ctx = new CursorProjectContext(options.dir);
|
|
364
|
+
const state = {};
|
|
365
|
+
|
|
366
|
+
console.log('');
|
|
367
|
+
console.log(c(' nerviq cursor interactive wizard', 'bold'));
|
|
368
|
+
console.log(c(' ═══════════════════════════════════════', 'dim'));
|
|
369
|
+
|
|
370
|
+
let stageIndex = 0;
|
|
371
|
+
|
|
372
|
+
try {
|
|
373
|
+
while (stageIndex < STAGES.length) {
|
|
374
|
+
const result = await STAGES[stageIndex](rl, ctx, state);
|
|
375
|
+
if (result === 'quit') { rl.close(); return null; }
|
|
376
|
+
if (result === 'back') { stageIndex = Math.max(0, stageIndex - 1); continue; }
|
|
377
|
+
if (result === 'done') break;
|
|
378
|
+
stageIndex++;
|
|
379
|
+
}
|
|
380
|
+
} finally {
|
|
381
|
+
rl.close();
|
|
382
|
+
}
|
|
383
|
+
|
|
384
|
+
if (!state.confirmed) return null;
|
|
385
|
+
return state;
|
|
386
|
+
}
|
|
387
|
+
|
|
388
|
+
module.exports = {
|
|
389
|
+
runCursorWizard,
|
|
390
|
+
runProjectDetection,
|
|
391
|
+
};
|