@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,471 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Windsurf Setup Module
|
|
3
|
+
*
|
|
4
|
+
* 8 setup families:
|
|
5
|
+
* 1. .windsurf/rules/*.md (core + stack-specific)
|
|
6
|
+
* 2. Legacy migration (.windsurfrules -> .windsurf/rules/)
|
|
7
|
+
* 3. .windsurf/mcp.json
|
|
8
|
+
* 4. .windsurf/workflows/ (slash commands)
|
|
9
|
+
* 5. .windsurf/memories/ (team-syncable)
|
|
10
|
+
* 6. .cascadeignore
|
|
11
|
+
* 7. CI workflow (GitHub Actions)
|
|
12
|
+
* 8. Cascade guide
|
|
13
|
+
*/
|
|
14
|
+
|
|
15
|
+
const fs = require('fs');
|
|
16
|
+
const path = require('path');
|
|
17
|
+
const os = require('os');
|
|
18
|
+
const { version } = require('../../package.json');
|
|
19
|
+
const { STACKS } = require('../techniques');
|
|
20
|
+
const { writeActivityArtifact, writeRollbackArtifact } = require('../activity');
|
|
21
|
+
const { WindsurfProjectContext } = require('./context');
|
|
22
|
+
const { recommendWindsurfMcpPacks, packToJson } = require('./mcp-packs');
|
|
23
|
+
|
|
24
|
+
function detectScripts(ctx) {
|
|
25
|
+
const pkg = ctx.jsonFile('package.json');
|
|
26
|
+
if (!pkg || !pkg.scripts) return {};
|
|
27
|
+
return pkg.scripts;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
function detectProjectName(ctx) {
|
|
31
|
+
const pkg = ctx.jsonFile('package.json');
|
|
32
|
+
if (pkg && pkg.name) return pkg.name;
|
|
33
|
+
return path.basename(ctx.dir);
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
function hasStack(stacks, key) {
|
|
37
|
+
return stacks.some((item) => item.key === key);
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
function buildMermaid(stacks) {
|
|
41
|
+
if (hasStack(stacks, 'nextjs')) {
|
|
42
|
+
return ['```mermaid', 'graph TD', ' UI[App Router / Pages] --> Logic[Server Actions or API Routes]', ' Logic --> Data[Data Layer]', ' Data --> External[External Services / DB]', '```'].join('\n');
|
|
43
|
+
}
|
|
44
|
+
if (hasStack(stacks, 'fastapi') || hasStack(stacks, 'django') || hasStack(stacks, 'python')) {
|
|
45
|
+
return ['```mermaid', 'graph TD', ' API[API / CLI Entry] --> Services[Service Layer]', ' Services --> Models[Models / Schemas]', ' Models --> Data[Database or External APIs]', '```'].join('\n');
|
|
46
|
+
}
|
|
47
|
+
if (hasStack(stacks, 'go')) {
|
|
48
|
+
return ['```mermaid', 'graph TD', ' Cmd[cmd/ or main package] --> Internal[internal/ packages]', ' Internal --> Data[Storage / APIs]', '```'].join('\n');
|
|
49
|
+
}
|
|
50
|
+
if (hasStack(stacks, 'rust')) {
|
|
51
|
+
return ['```mermaid', 'graph TD', ' Bin[src/main.rs] --> Core[src/lib.rs]', ' Core --> Modules[domain / adapters / services]', '```'].join('\n');
|
|
52
|
+
}
|
|
53
|
+
return ['```mermaid', 'graph TD', ' Entry[Entry Point] --> Core[Core Logic]', ' Core --> Data[Data / External Services]', '```'].join('\n');
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
function buildVerificationCommands(ctx) {
|
|
57
|
+
const scripts = detectScripts(ctx);
|
|
58
|
+
const commands = [];
|
|
59
|
+
if (scripts.test) commands.push('- Test: `npm test`');
|
|
60
|
+
if (scripts.lint) commands.push('- Lint: `npm run lint`');
|
|
61
|
+
if (scripts.build) commands.push('- Build: `npm run build`');
|
|
62
|
+
if (commands.length === 0 && ctx.fileContent('pyproject.toml')) commands.push('- Test: `python -m pytest`');
|
|
63
|
+
if (commands.length === 0 && ctx.fileContent('requirements.txt')) commands.push('- Test: `python -m pytest`');
|
|
64
|
+
if (commands.length === 0 && ctx.fileContent('go.mod')) { commands.push('- Test: `go test ./...`'); commands.push('- Build: `go build ./...`'); }
|
|
65
|
+
if (commands.length === 0 && ctx.fileContent('Cargo.toml')) { commands.push('- Test: `cargo test`'); commands.push('- Build: `cargo build`'); }
|
|
66
|
+
if (commands.length === 0) { commands.push('- Test: add the repo test command'); commands.push('- Lint: add the repo lint command'); commands.push('- Build: add the repo build command'); }
|
|
67
|
+
return commands;
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
function buildCodingConventions(stacks) {
|
|
71
|
+
const lines = [];
|
|
72
|
+
if (hasStack(stacks, 'typescript')) lines.push('- Keep TypeScript strict and prefer typed boundaries over implicit `any`.');
|
|
73
|
+
if (hasStack(stacks, 'react') || hasStack(stacks, 'nextjs')) lines.push('- Prefer small, reviewable component changes and document risky UI state assumptions.');
|
|
74
|
+
if (hasStack(stacks, 'python') || hasStack(stacks, 'fastapi') || hasStack(stacks, 'django')) lines.push('- Prefer explicit validation, typed schemas, and focused service functions.');
|
|
75
|
+
if (hasStack(stacks, 'go')) lines.push('- Keep packages small, avoid cross-package cycles, and prefer table-driven tests.');
|
|
76
|
+
if (hasStack(stacks, 'rust')) lines.push('- Prefer explicit ownership-safe refactors and small module-scoped changes.');
|
|
77
|
+
if (hasStack(stacks, 'terraform') || hasStack(stacks, 'kubernetes')) lines.push('- Treat infrastructure changes as high-risk: prefer diffs that are easy to plan and roll back.');
|
|
78
|
+
if (lines.length === 0) lines.push('- Prefer small, reviewable diffs and explicit reasoning over broad rewrites.');
|
|
79
|
+
return lines;
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
function buildCoreRuleMd(ctx, stacks) {
|
|
83
|
+
const stackLabels = stacks.map((item) => item.label).join(', ') || 'General repo';
|
|
84
|
+
const verificationCommands = buildVerificationCommands(ctx);
|
|
85
|
+
const codingConventions = buildCodingConventions(stacks);
|
|
86
|
+
|
|
87
|
+
return [
|
|
88
|
+
'---',
|
|
89
|
+
'trigger: always',
|
|
90
|
+
'description: "Core project rules — always active for Cascade"',
|
|
91
|
+
'---',
|
|
92
|
+
'',
|
|
93
|
+
`# ${detectProjectName(ctx)} — Core Rules`,
|
|
94
|
+
'',
|
|
95
|
+
'## Scope',
|
|
96
|
+
'- Primary platform: Windsurf (Cascade agent)',
|
|
97
|
+
`- Detected stack: ${stackLabels}`,
|
|
98
|
+
'',
|
|
99
|
+
'## Architecture',
|
|
100
|
+
buildMermaid(stacks),
|
|
101
|
+
'- Replace the default diagram with the real entry points and boundaries for this repo.',
|
|
102
|
+
'',
|
|
103
|
+
'## Verification',
|
|
104
|
+
...verificationCommands,
|
|
105
|
+
'',
|
|
106
|
+
'Before completing any task:',
|
|
107
|
+
'1. Run tests — all must pass',
|
|
108
|
+
'2. Run lint — no errors',
|
|
109
|
+
'3. Verify build succeeds',
|
|
110
|
+
'',
|
|
111
|
+
'## Coding Conventions',
|
|
112
|
+
...codingConventions,
|
|
113
|
+
'',
|
|
114
|
+
'## Security',
|
|
115
|
+
'- Never commit secrets, tokens, or `.env` values into tracked files.',
|
|
116
|
+
'- Use .cascadeignore to exclude sensitive files from Cascade access.',
|
|
117
|
+
'- Prefer the repo verification commands before handoff.',
|
|
118
|
+
'',
|
|
119
|
+
'## Platform Awareness',
|
|
120
|
+
'- **Cascade**: Autonomous agent with multi-file editing capabilities.',
|
|
121
|
+
'- **Memories**: Team-syncable persistent context in .windsurf/memories/.',
|
|
122
|
+
'- **Workflows**: Slash commands in .windsurf/workflows/.',
|
|
123
|
+
'- **10K char limit**: Each rule file must be under 10,000 characters.',
|
|
124
|
+
'- **Session drift**: Long sessions may lose context — start fresh if instructions are forgotten.',
|
|
125
|
+
'',
|
|
126
|
+
`_Generated by nerviq v${version} for Windsurf. Customize before production use._`,
|
|
127
|
+
'',
|
|
128
|
+
].join('\n');
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
function buildStackRuleMd(stacks) {
|
|
132
|
+
if (hasStack(stacks, 'typescript')) {
|
|
133
|
+
return [
|
|
134
|
+
'---',
|
|
135
|
+
'trigger: auto',
|
|
136
|
+
'description: "TypeScript-specific conventions"',
|
|
137
|
+
'globs:',
|
|
138
|
+
' - "**/*.ts"',
|
|
139
|
+
' - "**/*.tsx"',
|
|
140
|
+
'---',
|
|
141
|
+
'',
|
|
142
|
+
'# TypeScript Rules',
|
|
143
|
+
'',
|
|
144
|
+
'- Use strict mode',
|
|
145
|
+
'- Prefer named exports over default exports',
|
|
146
|
+
'- Use explicit return types on public functions',
|
|
147
|
+
'- Avoid `any` — use `unknown` or proper types',
|
|
148
|
+
'- Prefer interfaces over types for public APIs',
|
|
149
|
+
'',
|
|
150
|
+
`_Generated by nerviq v${version}_`,
|
|
151
|
+
'',
|
|
152
|
+
].join('\n');
|
|
153
|
+
}
|
|
154
|
+
return null;
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
function buildMcpJson(ctx, stacks, domainPacks) {
|
|
158
|
+
const mcpRecs = recommendWindsurfMcpPacks(stacks, domainPacks || [], { ctx });
|
|
159
|
+
const mcpServers = Object.assign({}, ...mcpRecs.map(p => packToJson(p)));
|
|
160
|
+
return JSON.stringify({ mcpServers }, null, 2) + '\n';
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
function buildLegacyMigrationGuide() {
|
|
164
|
+
return [
|
|
165
|
+
'---',
|
|
166
|
+
'trigger: agent_requested',
|
|
167
|
+
'description: "Legacy .windsurfrules migration guide"',
|
|
168
|
+
'---',
|
|
169
|
+
'',
|
|
170
|
+
'# Legacy Migration Guide',
|
|
171
|
+
'',
|
|
172
|
+
'## .windsurfrules Migration',
|
|
173
|
+
'',
|
|
174
|
+
'The `.windsurfrules` file is the legacy format.',
|
|
175
|
+
'Migrate to `.windsurf/rules/*.md` files with proper YAML frontmatter.',
|
|
176
|
+
'',
|
|
177
|
+
'## Migration steps',
|
|
178
|
+
'',
|
|
179
|
+
'1. Copy `.windsurfrules` content to `.windsurf/rules/core.md`',
|
|
180
|
+
'2. Add YAML frontmatter with `trigger: always`',
|
|
181
|
+
'3. Delete `.windsurfrules` (or rename to `.windsurfrules.bak`)',
|
|
182
|
+
'4. Verify Cascade sees the rules',
|
|
183
|
+
'',
|
|
184
|
+
'## Rule activation reference',
|
|
185
|
+
'',
|
|
186
|
+
'| Mode | trigger | globs | description |',
|
|
187
|
+
'|------|:-------:|:-----:|:-----------:|',
|
|
188
|
+
'| Always | always | any | any |',
|
|
189
|
+
'| Auto | auto | set | optional |',
|
|
190
|
+
'| Agent-Requested | agent_requested | empty | set |',
|
|
191
|
+
'| Manual | manual | empty | empty |',
|
|
192
|
+
'',
|
|
193
|
+
`_Generated by nerviq v${version}_`,
|
|
194
|
+
'',
|
|
195
|
+
].join('\n');
|
|
196
|
+
}
|
|
197
|
+
|
|
198
|
+
function buildCascadeignore() {
|
|
199
|
+
return [
|
|
200
|
+
'# Cascade agent file exclusions (gitignore syntax)',
|
|
201
|
+
'# Files listed here will not be accessible to Cascade',
|
|
202
|
+
'',
|
|
203
|
+
'# Environment and secrets',
|
|
204
|
+
'.env',
|
|
205
|
+
'.env.*',
|
|
206
|
+
'*.key',
|
|
207
|
+
'*.pem',
|
|
208
|
+
'',
|
|
209
|
+
'# Credentials',
|
|
210
|
+
'.aws/',
|
|
211
|
+
'.ssh/',
|
|
212
|
+
'credentials/',
|
|
213
|
+
'secrets/',
|
|
214
|
+
'',
|
|
215
|
+
'# Build artifacts',
|
|
216
|
+
'node_modules/',
|
|
217
|
+
'dist/',
|
|
218
|
+
'.next/',
|
|
219
|
+
'',
|
|
220
|
+
`# Generated by nerviq v${version} for Windsurf`,
|
|
221
|
+
'',
|
|
222
|
+
].join('\n');
|
|
223
|
+
}
|
|
224
|
+
|
|
225
|
+
function buildCiReviewWorkflow() {
|
|
226
|
+
return [
|
|
227
|
+
'name: Windsurf Code Review',
|
|
228
|
+
'',
|
|
229
|
+
'on:',
|
|
230
|
+
' pull_request:',
|
|
231
|
+
' types: [opened, synchronize]',
|
|
232
|
+
'',
|
|
233
|
+
'permissions:',
|
|
234
|
+
' contents: read',
|
|
235
|
+
' pull-requests: write',
|
|
236
|
+
'',
|
|
237
|
+
'jobs:',
|
|
238
|
+
' windsurf-review:',
|
|
239
|
+
' runs-on: ubuntu-latest',
|
|
240
|
+
' steps:',
|
|
241
|
+
' - uses: actions/checkout@v4',
|
|
242
|
+
' - name: Run nerviq audit',
|
|
243
|
+
' run: npx nerviq --platform windsurf --json > audit-report.json',
|
|
244
|
+
' - uses: actions/upload-artifact@v4',
|
|
245
|
+
' with:',
|
|
246
|
+
' name: windsurf-audit-report',
|
|
247
|
+
' path: audit-report.json',
|
|
248
|
+
' retention-days: 30',
|
|
249
|
+
'',
|
|
250
|
+
`# Generated by nerviq v${version} for Windsurf.`,
|
|
251
|
+
'',
|
|
252
|
+
].join('\n');
|
|
253
|
+
}
|
|
254
|
+
|
|
255
|
+
function buildCascadeGuide() {
|
|
256
|
+
return [
|
|
257
|
+
'---',
|
|
258
|
+
'trigger: agent_requested',
|
|
259
|
+
'description: "Cascade agent usage guide and best practices"',
|
|
260
|
+
'---',
|
|
261
|
+
'',
|
|
262
|
+
'# Cascade Agent Guide',
|
|
263
|
+
'',
|
|
264
|
+
'## What is Cascade?',
|
|
265
|
+
'Cascade is Windsurf\'s autonomous AI agent with multi-file editing capabilities.',
|
|
266
|
+
'It can perform complex, multi-step tasks across your entire codebase.',
|
|
267
|
+
'',
|
|
268
|
+
'## Key Features',
|
|
269
|
+
'- **Multi-file editing**: Cascade can edit multiple files in a single action.',
|
|
270
|
+
'- **Steps**: Automated multi-step workflows for complex tasks.',
|
|
271
|
+
'- **Skills**: Configurable capabilities (web search, terminal, etc.).',
|
|
272
|
+
'- **Memories**: Persistent context that syncs across team members.',
|
|
273
|
+
'',
|
|
274
|
+
'## Best Practices',
|
|
275
|
+
'- Use @-mentions to reference specific files or context.',
|
|
276
|
+
'- Keep sessions focused — start fresh for unrelated tasks.',
|
|
277
|
+
'- Review Cascade\'s multi-file changes before committing.',
|
|
278
|
+
'- Use .cascadeignore to protect sensitive files.',
|
|
279
|
+
'',
|
|
280
|
+
`_Generated by nerviq v${version}_`,
|
|
281
|
+
'',
|
|
282
|
+
].join('\n');
|
|
283
|
+
}
|
|
284
|
+
|
|
285
|
+
function buildWindsurfSetupFiles(options = {}) {
|
|
286
|
+
const ctx = new WindsurfProjectContext(options.dir);
|
|
287
|
+
const stacks = ctx.detectStacks(STACKS);
|
|
288
|
+
const files = [];
|
|
289
|
+
|
|
290
|
+
// 1. Core rules (.windsurf/rules/core.md)
|
|
291
|
+
const coreRulePath = path.join(options.dir, '.windsurf', 'rules', 'core.md');
|
|
292
|
+
if (!fs.existsSync(coreRulePath)) {
|
|
293
|
+
files.push({
|
|
294
|
+
path: '.windsurf/rules/core.md',
|
|
295
|
+
action: 'create',
|
|
296
|
+
family: 'windsurf-rules',
|
|
297
|
+
content: buildCoreRuleMd(ctx, stacks),
|
|
298
|
+
currentState: '.windsurf/rules/core.md is missing',
|
|
299
|
+
proposedState: 'create a core rules file with trigger: always, verification, and architecture guidance',
|
|
300
|
+
});
|
|
301
|
+
}
|
|
302
|
+
|
|
303
|
+
// Stack-specific rule
|
|
304
|
+
const stackRule = buildStackRuleMd(stacks);
|
|
305
|
+
if (stackRule) {
|
|
306
|
+
const stackRulePath = path.join(options.dir, '.windsurf', 'rules', 'typescript.md');
|
|
307
|
+
if (!fs.existsSync(stackRulePath)) {
|
|
308
|
+
files.push({
|
|
309
|
+
path: '.windsurf/rules/typescript.md',
|
|
310
|
+
action: 'create',
|
|
311
|
+
family: 'windsurf-rules',
|
|
312
|
+
content: stackRule,
|
|
313
|
+
currentState: '.windsurf/rules/typescript.md is missing',
|
|
314
|
+
proposedState: 'create Auto TypeScript rules with glob pattern',
|
|
315
|
+
});
|
|
316
|
+
}
|
|
317
|
+
}
|
|
318
|
+
|
|
319
|
+
// 2. Legacy migration
|
|
320
|
+
const legacyPath = path.join(options.dir, '.windsurfrules');
|
|
321
|
+
if (fs.existsSync(legacyPath)) {
|
|
322
|
+
const migrationPath = path.join(options.dir, '.windsurf', 'rules', 'migration-guide.md');
|
|
323
|
+
if (!fs.existsSync(migrationPath)) {
|
|
324
|
+
files.push({
|
|
325
|
+
path: '.windsurf/rules/migration-guide.md',
|
|
326
|
+
action: 'create',
|
|
327
|
+
family: 'windsurf-legacy-migration',
|
|
328
|
+
content: buildLegacyMigrationGuide(),
|
|
329
|
+
currentState: '.windsurfrules exists — legacy format',
|
|
330
|
+
proposedState: 'create migration guide to help move .windsurfrules content to .windsurf/rules/*.md',
|
|
331
|
+
});
|
|
332
|
+
}
|
|
333
|
+
}
|
|
334
|
+
|
|
335
|
+
const modules = options.modules || 'all';
|
|
336
|
+
const wantModule = (name) => modules === 'all' || (Array.isArray(modules) && modules.includes(name));
|
|
337
|
+
|
|
338
|
+
// 3. MCP config
|
|
339
|
+
if (wantModule('mcp')) {
|
|
340
|
+
const mcpPath = path.join(options.dir, '.windsurf', 'mcp.json');
|
|
341
|
+
if (!fs.existsSync(mcpPath)) {
|
|
342
|
+
const domainPacks = options.domainPacks || [];
|
|
343
|
+
files.push({
|
|
344
|
+
path: '.windsurf/mcp.json',
|
|
345
|
+
action: 'create',
|
|
346
|
+
family: 'windsurf-mcp',
|
|
347
|
+
content: buildMcpJson(ctx, stacks, domainPacks),
|
|
348
|
+
currentState: '.windsurf/mcp.json is missing',
|
|
349
|
+
proposedState: 'create MCP config with recommended packs',
|
|
350
|
+
});
|
|
351
|
+
}
|
|
352
|
+
}
|
|
353
|
+
|
|
354
|
+
// 4. Cascadeignore
|
|
355
|
+
if (wantModule('cascadeignore')) {
|
|
356
|
+
const ignorePath = path.join(options.dir, '.cascadeignore');
|
|
357
|
+
if (!fs.existsSync(ignorePath)) {
|
|
358
|
+
files.push({
|
|
359
|
+
path: '.cascadeignore',
|
|
360
|
+
action: 'create',
|
|
361
|
+
family: 'windsurf-cascadeignore',
|
|
362
|
+
content: buildCascadeignore(),
|
|
363
|
+
currentState: '.cascadeignore is missing',
|
|
364
|
+
proposedState: 'create .cascadeignore for sensitive file exclusion from Cascade',
|
|
365
|
+
});
|
|
366
|
+
}
|
|
367
|
+
}
|
|
368
|
+
|
|
369
|
+
// 5. CI workflow
|
|
370
|
+
if (wantModule('ci')) {
|
|
371
|
+
const ciPath = path.join(options.dir, '.github', 'workflows', 'windsurf-review.yml');
|
|
372
|
+
if (!fs.existsSync(ciPath)) {
|
|
373
|
+
files.push({
|
|
374
|
+
path: '.github/workflows/windsurf-review.yml',
|
|
375
|
+
action: 'create',
|
|
376
|
+
family: 'windsurf-ci-review',
|
|
377
|
+
content: buildCiReviewWorkflow(),
|
|
378
|
+
currentState: 'No Windsurf CI review workflow exists',
|
|
379
|
+
proposedState: 'create a GitHub Actions workflow for Windsurf-based audit on PRs',
|
|
380
|
+
});
|
|
381
|
+
}
|
|
382
|
+
}
|
|
383
|
+
|
|
384
|
+
// 6. Cascade guide
|
|
385
|
+
if (wantModule('cascade-guide')) {
|
|
386
|
+
const guidePath = path.join(options.dir, '.windsurf', 'rules', 'cascade-guide.md');
|
|
387
|
+
if (!fs.existsSync(guidePath)) {
|
|
388
|
+
files.push({
|
|
389
|
+
path: '.windsurf/rules/cascade-guide.md',
|
|
390
|
+
action: 'create',
|
|
391
|
+
family: 'windsurf-cascade-guide',
|
|
392
|
+
content: buildCascadeGuide(),
|
|
393
|
+
currentState: 'No Cascade guide',
|
|
394
|
+
proposedState: 'create Cascade agent usage guide as an Agent-Requested rule',
|
|
395
|
+
});
|
|
396
|
+
}
|
|
397
|
+
}
|
|
398
|
+
|
|
399
|
+
return { ctx, stacks, files };
|
|
400
|
+
}
|
|
401
|
+
|
|
402
|
+
async function setupWindsurf(options) {
|
|
403
|
+
const silent = options.silent === true;
|
|
404
|
+
const { ctx, stacks, files } = buildWindsurfSetupFiles(options);
|
|
405
|
+
const writtenFiles = [];
|
|
406
|
+
const preservedFiles = [];
|
|
407
|
+
|
|
408
|
+
function log(message = '') { if (!silent) console.log(message); }
|
|
409
|
+
|
|
410
|
+
log('');
|
|
411
|
+
log('\x1b[1m nerviq windsurf setup\x1b[0m');
|
|
412
|
+
log('\x1b[2m ═══════════════════════════════════════\x1b[0m');
|
|
413
|
+
if (stacks.length > 0) log(`\x1b[36m Detected: ${stacks.map((s) => s.label).join(', ')}\x1b[0m`);
|
|
414
|
+
log('');
|
|
415
|
+
|
|
416
|
+
for (const file of files) {
|
|
417
|
+
const fullPath = path.join(options.dir, file.path);
|
|
418
|
+
if (fs.existsSync(fullPath)) {
|
|
419
|
+
preservedFiles.push(file.path);
|
|
420
|
+
log(` \x1b[2m Skipped ${file.path} (already exists)\x1b[0m`);
|
|
421
|
+
continue;
|
|
422
|
+
}
|
|
423
|
+
fs.mkdirSync(path.dirname(fullPath), { recursive: true });
|
|
424
|
+
fs.writeFileSync(fullPath, file.content, 'utf8');
|
|
425
|
+
writtenFiles.push(file.path);
|
|
426
|
+
log(` \x1b[32m Created ${file.path}\x1b[0m`);
|
|
427
|
+
}
|
|
428
|
+
|
|
429
|
+
let rollbackArtifact = null;
|
|
430
|
+
let activityArtifact = null;
|
|
431
|
+
if (writtenFiles.length > 0) {
|
|
432
|
+
rollbackArtifact = writeRollbackArtifact(options.dir, {
|
|
433
|
+
sourcePlan: 'windsurf-setup',
|
|
434
|
+
createdFiles: writtenFiles,
|
|
435
|
+
patchedFiles: [],
|
|
436
|
+
rollbackInstructions: writtenFiles.map((file) => `Delete ${file}`),
|
|
437
|
+
});
|
|
438
|
+
activityArtifact = writeActivityArtifact(options.dir, 'windsurf-setup', {
|
|
439
|
+
platform: 'windsurf',
|
|
440
|
+
createdFiles: writtenFiles,
|
|
441
|
+
preservedFiles,
|
|
442
|
+
stackLabels: stacks.map((item) => item.label),
|
|
443
|
+
rollbackArtifact: rollbackArtifact.relativePath,
|
|
444
|
+
});
|
|
445
|
+
}
|
|
446
|
+
|
|
447
|
+
log('');
|
|
448
|
+
log(` \x1b[1m${writtenFiles.length} files created.\x1b[0m`);
|
|
449
|
+
if (preservedFiles.length > 0) log(` \x1b[2m${preservedFiles.length} existing files preserved.\x1b[0m`);
|
|
450
|
+
if (rollbackArtifact) log(` Rollback: \x1b[1m${rollbackArtifact.relativePath}\x1b[0m`);
|
|
451
|
+
if (activityArtifact) log(` Activity log: \x1b[1m${activityArtifact.relativePath}\x1b[0m`);
|
|
452
|
+
log('');
|
|
453
|
+
log(' Run \x1b[1mnpx nerviq --platform windsurf\x1b[0m to audit your Windsurf setup.');
|
|
454
|
+
log('');
|
|
455
|
+
|
|
456
|
+
return {
|
|
457
|
+
created: writtenFiles.length,
|
|
458
|
+
skipped: preservedFiles.length,
|
|
459
|
+
writtenFiles,
|
|
460
|
+
preservedFiles,
|
|
461
|
+
stacks,
|
|
462
|
+
rollbackArtifact: rollbackArtifact ? rollbackArtifact.relativePath : null,
|
|
463
|
+
activityArtifact: activityArtifact ? activityArtifact.relativePath : null,
|
|
464
|
+
};
|
|
465
|
+
}
|
|
466
|
+
|
|
467
|
+
module.exports = {
|
|
468
|
+
buildCoreRuleMd,
|
|
469
|
+
buildWindsurfSetupFiles,
|
|
470
|
+
setupWindsurf,
|
|
471
|
+
};
|