@nerviq/cli 1.20.1 → 1.21.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 (181) hide show
  1. package/LICENSE +23 -23
  2. package/README.md +2 -2
  3. package/package.json +1 -1
  4. package/src/activity.js +1039 -1039
  5. package/src/adoption-advisor.js +299 -299
  6. package/src/aider/config-parser.js +166 -166
  7. package/src/aider/context.js +4 -1
  8. package/src/aider/deep-review.js +316 -316
  9. package/src/aider/domain-packs.js +303 -303
  10. package/src/aider/freshness.js +93 -93
  11. package/src/aider/governance.js +253 -253
  12. package/src/aider/interactive.js +334 -334
  13. package/src/aider/mcp-packs.js +329 -329
  14. package/src/aider/patch.js +214 -214
  15. package/src/aider/plans.js +186 -186
  16. package/src/aider/premium.js +360 -360
  17. package/src/aider/setup.js +404 -404
  18. package/src/aider/techniques.js +312 -67
  19. package/src/analyze.js +951 -951
  20. package/src/anti-patterns.js +485 -485
  21. package/src/audit/instruction-files.js +180 -180
  22. package/src/audit/recommendations.js +577 -577
  23. package/src/auto-suggest.js +154 -154
  24. package/src/badge.js +13 -13
  25. package/src/behavioral-drift.js +801 -801
  26. package/src/benchmark.js +67 -67
  27. package/src/catalog.js +103 -103
  28. package/src/certification.js +128 -128
  29. package/src/codex/config-parser.js +183 -183
  30. package/src/codex/context.js +223 -223
  31. package/src/codex/deep-review.js +493 -493
  32. package/src/codex/domain-packs.js +394 -394
  33. package/src/codex/freshness.js +84 -84
  34. package/src/codex/governance.js +192 -192
  35. package/src/codex/interactive.js +618 -618
  36. package/src/codex/mcp-packs.js +914 -914
  37. package/src/codex/patch.js +209 -209
  38. package/src/codex/plans.js +251 -251
  39. package/src/codex/premium.js +614 -614
  40. package/src/codex/setup.js +591 -591
  41. package/src/continuous-ops.js +681 -681
  42. package/src/copilot/activity.js +309 -309
  43. package/src/copilot/deep-review.js +346 -346
  44. package/src/copilot/domain-packs.js +372 -372
  45. package/src/copilot/freshness.js +57 -57
  46. package/src/copilot/governance.js +222 -222
  47. package/src/copilot/interactive.js +406 -406
  48. package/src/copilot/mcp-packs.js +826 -826
  49. package/src/copilot/plans.js +253 -253
  50. package/src/copilot/premium.js +451 -451
  51. package/src/copilot/setup.js +488 -488
  52. package/src/cost-tracking.js +61 -61
  53. package/src/cursor/activity.js +301 -301
  54. package/src/cursor/config-parser.js +265 -265
  55. package/src/cursor/context.js +256 -256
  56. package/src/cursor/deep-review.js +334 -334
  57. package/src/cursor/domain-packs.js +368 -368
  58. package/src/cursor/freshness.js +65 -65
  59. package/src/cursor/governance.js +229 -229
  60. package/src/cursor/interactive.js +391 -391
  61. package/src/cursor/mcp-packs.js +828 -828
  62. package/src/cursor/plans.js +254 -254
  63. package/src/cursor/premium.js +469 -469
  64. package/src/cursor/setup.js +488 -488
  65. package/src/dashboard.js +493 -493
  66. package/src/deep-review.js +428 -428
  67. package/src/deprecation.js +98 -98
  68. package/src/diff-only.js +280 -280
  69. package/src/doctor.js +119 -119
  70. package/src/domain-pack-expansion.js +1033 -1033
  71. package/src/domain-packs.js +387 -387
  72. package/src/feedback.js +178 -178
  73. package/src/fix-engine.js +783 -783
  74. package/src/fix-prompts.js +122 -122
  75. package/src/formatters/sarif.js +115 -115
  76. package/src/freshness.js +74 -74
  77. package/src/gemini/config-parser.js +275 -275
  78. package/src/gemini/deep-review.js +559 -559
  79. package/src/gemini/domain-packs.js +393 -393
  80. package/src/gemini/freshness.js +66 -66
  81. package/src/gemini/governance.js +201 -201
  82. package/src/gemini/interactive.js +860 -860
  83. package/src/gemini/mcp-packs.js +915 -915
  84. package/src/gemini/plans.js +269 -269
  85. package/src/gemini/premium.js +760 -760
  86. package/src/gemini/setup.js +692 -692
  87. package/src/governance.js +72 -72
  88. package/src/harmony/add.js +68 -68
  89. package/src/harmony/advisor.js +333 -333
  90. package/src/harmony/canon.js +565 -565
  91. package/src/harmony/cli.js +591 -591
  92. package/src/harmony/drift.js +401 -401
  93. package/src/harmony/governance.js +313 -313
  94. package/src/harmony/memory.js +239 -239
  95. package/src/harmony/sync.js +475 -475
  96. package/src/harmony/watch.js +370 -370
  97. package/src/hook-validation.js +342 -342
  98. package/src/index.js +271 -271
  99. package/src/init.js +184 -184
  100. package/src/instruction-surfaces.js +185 -185
  101. package/src/integrations.js +144 -144
  102. package/src/interactive.js +118 -118
  103. package/src/locales/en.json +1 -1
  104. package/src/locales/es.json +1 -1
  105. package/src/mcp-packs.js +830 -830
  106. package/src/mcp-server.js +726 -726
  107. package/src/mcp-validation.js +337 -337
  108. package/src/nerviq-sync.json +7 -7
  109. package/src/opencode/config-parser.js +109 -109
  110. package/src/opencode/context.js +247 -247
  111. package/src/opencode/deep-review.js +313 -313
  112. package/src/opencode/domain-packs.js +262 -262
  113. package/src/opencode/freshness.js +66 -66
  114. package/src/opencode/governance.js +159 -159
  115. package/src/opencode/interactive.js +392 -392
  116. package/src/opencode/mcp-packs.js +705 -705
  117. package/src/opencode/patch.js +184 -184
  118. package/src/opencode/plans.js +231 -231
  119. package/src/opencode/premium.js +413 -413
  120. package/src/opencode/setup.js +449 -449
  121. package/src/opencode/techniques.js +27 -27
  122. package/src/operating-profile.js +574 -574
  123. package/src/org.js +152 -152
  124. package/src/permission-rules.js +218 -218
  125. package/src/plans.js +839 -839
  126. package/src/platform-change-manifest.js +86 -86
  127. package/src/plugins.js +110 -110
  128. package/src/policy-layers.js +210 -210
  129. package/src/profiles.js +124 -124
  130. package/src/prompt-injection.js +74 -74
  131. package/src/public-api.js +173 -173
  132. package/src/recommendation-rules.js +84 -84
  133. package/src/repo-archetype.js +386 -386
  134. package/src/secret-patterns.js +39 -39
  135. package/src/server.js +527 -527
  136. package/src/setup/analysis.js +607 -607
  137. package/src/setup/runtime.js +172 -172
  138. package/src/setup.js +677 -677
  139. package/src/shared/capabilities.js +194 -194
  140. package/src/source-urls.js +132 -132
  141. package/src/stack-checks.js +565 -565
  142. package/src/supplemental-checks.js +13 -13
  143. package/src/synergy/adaptive.js +261 -261
  144. package/src/synergy/compensation.js +137 -137
  145. package/src/synergy/evidence.js +193 -193
  146. package/src/synergy/learning.js +199 -199
  147. package/src/synergy/patterns.js +227 -227
  148. package/src/synergy/ranking.js +83 -83
  149. package/src/synergy/report.js +165 -165
  150. package/src/synergy/routing.js +146 -146
  151. package/src/techniques/api.js +407 -407
  152. package/src/techniques/automation.js +316 -316
  153. package/src/techniques/compliance.js +257 -257
  154. package/src/techniques/hygiene.js +294 -294
  155. package/src/techniques/instructions.js +243 -243
  156. package/src/techniques/observability.js +226 -226
  157. package/src/techniques/optimization.js +142 -142
  158. package/src/techniques/quality.js +318 -318
  159. package/src/techniques/security.js +237 -237
  160. package/src/techniques/shared.js +443 -443
  161. package/src/techniques/stacks.js +2294 -2294
  162. package/src/techniques/tools.js +106 -106
  163. package/src/techniques/workflow.js +413 -413
  164. package/src/techniques.js +81 -81
  165. package/src/terminology.js +73 -73
  166. package/src/token-estimate.js +35 -35
  167. package/src/usage-patterns.js +99 -99
  168. package/src/verification-metadata.js +145 -145
  169. package/src/watch.js +247 -247
  170. package/src/windsurf/activity.js +302 -302
  171. package/src/windsurf/config-parser.js +267 -267
  172. package/src/windsurf/deep-review.js +337 -337
  173. package/src/windsurf/domain-packs.js +370 -370
  174. package/src/windsurf/freshness.js +36 -36
  175. package/src/windsurf/governance.js +231 -231
  176. package/src/windsurf/interactive.js +388 -388
  177. package/src/windsurf/mcp-packs.js +792 -792
  178. package/src/windsurf/plans.js +247 -247
  179. package/src/windsurf/premium.js +468 -468
  180. package/src/windsurf/setup.js +471 -471
  181. package/src/workspace.js +375 -375
@@ -1,388 +1,388 @@
1
- /**
2
- * Windsurf Interactive Wizard — 10-stage guided setup.
3
- *
4
- * Adapted for Windsurf's architecture (foreground Cascade, memories, workflows).
5
- *
6
- * Stages:
7
- * 1. Project detection (stacks, existing .windsurf/, .windsurfrules)
8
- * 2. Rule type selection (Always, Auto, Agent-Requested, Manual)
9
- * 3. Legacy migration (.windsurfrules -> .windsurf/rules/)
10
- * 4. Cascadeignore setup
11
- * 5. Domain pack selection
12
- * 6. MCP pack selection
13
- * 7. Workflow config
14
- * 8. Memories config
15
- * 9. Team & 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 { WindsurfProjectContext } = require('./context');
25
- const { WINDSURF_TECHNIQUES } = require('./techniques');
26
- const { WINDSURF_DOMAIN_PACKS, detectWindsurfDomainPacks } = require('./domain-packs');
27
- const { recommendWindsurfMcpPacks, WINDSURF_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
- 'Cascadeignore Setup',
49
- 'Domain Pack Selection',
50
- 'MCP Pack Selection',
51
- 'Workflow Config',
52
- 'Memories Config',
53
- 'Team & 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.windsurfRules ? ctx.windsurfRules() : [];
68
- const hasLegacy = ctx.hasLegacyRules ? ctx.hasLegacyRules() : false;
69
- const hasMcpJson = ctx.mcpConfig().ok;
70
- const workflows = ctx.workflowFiles ? ctx.workflowFiles() : [];
71
- const memories = ctx.memoryFiles ? ctx.memoryFiles() : [];
72
- const hasCascadeignore = ctx.hasCascadeignore ? ctx.hasCascadeignore() : false;
73
- const surfaces = ctx.detectSurfaces();
74
-
75
- const auditResults = [];
76
- for (const [key, technique] of Object.entries(WINDSURF_TECHNIQUES)) {
77
- auditResults.push({ key, ...technique, passed: technique.check(ctx) });
78
- }
79
- const passed = auditResults.filter(r => r.passed === true);
80
- const failed = auditResults.filter(r => r.passed === false);
81
-
82
- return { stacks, rules, hasLegacy, hasMcpJson, workflows, memories, hasCascadeignore, surfaces, auditResults, passed, failed };
83
- }
84
-
85
- async function stageProjectDetection(rl, ctx, state) {
86
- printStageHeader(0);
87
- const det = runProjectDetection(ctx);
88
- Object.assign(state, det);
89
-
90
- if (det.stacks.length > 0) console.log(c(` Detected stacks: ${det.stacks.map(s => s.label).join(', ')}`, 'blue'));
91
- else console.log(c(' No specific stack detected — will use baseline defaults.', 'dim'));
92
-
93
- console.log(c(` Working directory: ${ctx.dir}`, 'dim'));
94
- console.log('');
95
- console.log(` ${c(`${det.passed.length}/${det.auditResults.length}`, 'bold')} Windsurf checks passing.`);
96
- console.log(` ${c(String(det.failed.length), 'yellow')} improvements available.`);
97
- console.log('');
98
- console.log(` Surfaces: FG ${det.surfaces.foreground ? c('Y', 'green') : c('N', 'red')} | WF ${det.surfaces.workflows ? c('Y', 'green') : c('N', 'red')} | Mem ${det.surfaces.memories ? c('Y', 'green') : c('N', 'red')} | CI ${det.hasCascadeignore ? c('Y', 'green') : c('N', 'red')}`);
99
- console.log(` Rules: ${det.rules.length} .md files${det.hasLegacy ? c(' + .windsurfrules (legacy!)', 'red') : ''}`);
100
-
101
- if (det.rules.length > 0 || det.hasLegacy) {
102
- console.log('');
103
- if (det.hasLegacy) console.log(c(' WARNING: .windsurfrules found — this is the legacy format!', 'red'));
104
- if (det.rules.length > 0) console.log(c(` ${det.rules.length} .md rule files in .windsurf/rules/`, 'dim'));
105
- if (det.hasMcpJson) console.log(c(' .windsurf/mcp.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 Windsurf 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(' Windsurf supports 4 rule activation modes. Which do you want to generate?');
127
- console.log('');
128
- console.log(` ${c('1', 'bold')}. ${c('Always only', 'blue')} — Core rules for every Cascade interaction.`);
129
- console.log(` ${c('2', 'bold')}. ${c('Always + Auto', 'blue')} — Core + file-type-specific rules.`);
130
- console.log(` ${c('3', 'bold')}. ${c('Full set', 'blue')} — Always + Auto + 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');
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(' WARNING: .windsurfrules file detected!', 'red'));
155
- console.log('');
156
- console.log(' The .windsurfrules file is the legacy format.');
157
- console.log(' Migrate to .windsurf/rules/*.md with YAML frontmatter for best results.');
158
- console.log('');
159
- console.log(` ${c('1', 'bold')}. ${c('Auto-migrate', 'blue')} — Convert .windsurfrules content to .md format.`);
160
- console.log(` ${c('2', 'bold')}. ${c('Keep both', 'yellow')} — Generate new .md rules alongside .windsurfrules.`);
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: Cascadeignore Setup ---
176
-
177
- async function stageCascadeignore(rl, _ctx, state) {
178
- printStageHeader(3);
179
-
180
- console.log(' Configure .cascadeignore for sensitive file exclusion?');
181
- console.log('');
182
- console.log(c(' .cascadeignore uses gitignore syntax to prevent Cascade from accessing files.', 'dim'));
183
- console.log(c(' Recommended patterns: .env, secrets/, credentials/, .aws/, .ssh/', 'dim'));
184
- console.log('');
185
-
186
- const answer = await ask(rl, c(' Generate .cascadeignore? (y/n, or b=back, q=quit) [y]: ', 'magenta'));
187
- const trimmed = answer.trim().toLowerCase();
188
- if (trimmed === 'b') return 'back';
189
- if (trimmed === 'q') return 'quit';
190
-
191
- state.generateCascadeignore = trimmed !== 'n';
192
- console.log(c(` → Cascadeignore: ${state.generateCascadeignore ? 'will configure' : 'skip'}`, 'green'));
193
- return 'next';
194
- }
195
-
196
- // --- Stage 5: Domain Pack Selection ---
197
-
198
- async function stageDomainPacks(rl, ctx, state) {
199
- printStageHeader(4);
200
-
201
- const detected = detectWindsurfDomainPacks(ctx, state.stacks || []);
202
- state.domainPacks = detected;
203
-
204
- console.log(` Detected ${detected.length} domain pack(s):`);
205
- console.log('');
206
- detected.forEach((pack, i) => {
207
- console.log(` ${c(`${i + 1}`, 'bold')}. ${c(pack.label, 'blue')} — ${pack.matchReasons[0] || pack.useWhen}`);
208
- });
209
- console.log('');
210
-
211
- const answer = await ask(rl, c(' Accept detected packs? (y/n, or b=back, q=quit) [y]: ', 'magenta'));
212
- const trimmed = answer.trim().toLowerCase();
213
- if (trimmed === 'b') return 'back';
214
- if (trimmed === 'q') return 'quit';
215
- if (trimmed === 'n') state.domainPacks = [];
216
-
217
- console.log(c(` → Domain packs: ${state.domainPacks.map(p => p.label).join(', ') || 'none'}`, 'green'));
218
- return 'next';
219
- }
220
-
221
- // --- Stage 6: MCP Pack Selection ---
222
-
223
- async function stageMcpPacks(rl, ctx, state) {
224
- printStageHeader(5);
225
-
226
- const recommended = recommendWindsurfMcpPacks(state.stacks || [], state.domainPacks || [], { ctx });
227
- state.mcpPacks = recommended;
228
-
229
- console.log(` Recommended ${recommended.length} MCP pack(s):`);
230
- console.log('');
231
- recommended.forEach((pack, i) => {
232
- console.log(` ${c(`${i + 1}`, 'bold')}. ${c(pack.label, 'blue')} — ${pack.description}`);
233
- });
234
- console.log('');
235
-
236
- const answer = await ask(rl, c(' Accept recommended packs? (y/n, or b=back, q=quit) [y]: ', 'magenta'));
237
- const trimmed = answer.trim().toLowerCase();
238
- if (trimmed === 'b') return 'back';
239
- if (trimmed === 'q') return 'quit';
240
- if (trimmed === 'n') state.mcpPacks = [];
241
-
242
- console.log(c(` → MCP packs: ${state.mcpPacks.map(p => p.label).join(', ') || 'none'}`, 'green'));
243
- return 'next';
244
- }
245
-
246
- // --- Stage 7: Workflow Config ---
247
-
248
- async function stageWorkflowConfig(rl, _ctx, state) {
249
- printStageHeader(6);
250
-
251
- console.log(' Configure Windsurf workflows (slash commands)?');
252
- console.log('');
253
- console.log(c(' Workflows define reusable slash commands for Cascade.', 'dim'));
254
- console.log(c(' Stored in .windsurf/workflows/*.md', 'dim'));
255
- console.log('');
256
-
257
- const answer = await ask(rl, c(' Set up starter workflows? (y/n, or b=back, q=quit) [n]: ', 'magenta'));
258
- const trimmed = answer.trim().toLowerCase();
259
- if (trimmed === 'b') return 'back';
260
- if (trimmed === 'q') return 'quit';
261
-
262
- state.generateWorkflows = trimmed === 'y';
263
- console.log(c(` → Workflows: ${state.generateWorkflows ? 'will configure' : 'skip'}`, 'green'));
264
- return 'next';
265
- }
266
-
267
- // --- Stage 8: Memories Config ---
268
-
269
- async function stageMemoriesConfig(rl, _ctx, state) {
270
- printStageHeader(7);
271
-
272
- console.log(' Configure Windsurf memories (persistent context)?');
273
- console.log('');
274
- console.log(c(' Memories provide persistent context that syncs across team members.', 'dim'));
275
- console.log(c(' IMPORTANT: Never put secrets or PII in memories — they sync to all team members!', 'yellow'));
276
- console.log('');
277
-
278
- const answer = await ask(rl, c(' Generate starter memories? (y/n, or b=back, q=quit) [n]: ', 'magenta'));
279
- const trimmed = answer.trim().toLowerCase();
280
- if (trimmed === 'b') return 'back';
281
- if (trimmed === 'q') return 'quit';
282
-
283
- state.generateMemories = trimmed === 'y';
284
- console.log(c(` → Memories: ${state.generateMemories ? 'will configure' : 'skip'}`, 'green'));
285
- return 'next';
286
- }
287
-
288
- // --- Stage 9: Team & Security ---
289
-
290
- async function stageTeamSecurity(rl, _ctx, state) {
291
- printStageHeader(8);
292
-
293
- console.log(' Review team and security considerations:');
294
- console.log('');
295
- console.log(c(' 1. Memories sync across team — check for secrets/PII', 'yellow'));
296
- console.log(c(' 2. MCP servers can be whitelisted at team level', 'dim'));
297
- console.log(c(' 3. .cascadeignore protects sensitive files from Cascade', 'dim'));
298
- console.log(c(' 4. Each rule file has a 10K character limit', 'dim'));
299
- console.log('');
300
-
301
- const answer = await ask(rl, c(' Acknowledge team/security considerations? (y/n, or b=back, q=quit) [y]: ', 'magenta'));
302
- const trimmed = answer.trim().toLowerCase();
303
- if (trimmed === 'b') return 'back';
304
- if (trimmed === 'q') return 'quit';
305
- if (trimmed === 'n') return 'quit';
306
-
307
- state.securityAcknowledged = true;
308
- console.log(c(' → Team/security considerations acknowledged.', 'yellow'));
309
- return 'next';
310
- }
311
-
312
- // --- Stage 10: Review & Generate ---
313
-
314
- async function stageReviewGenerate(rl, _ctx, state) {
315
- printStageHeader(9);
316
-
317
- console.log(' Summary of your Windsurf setup:');
318
- console.log('');
319
- console.log(` Rule types: ${(state.ruleTypes || []).join(', ')}`);
320
- console.log(` Legacy migration: ${state.legacyMigration || 'N/A'}`);
321
- console.log(` Cascadeignore: ${state.generateCascadeignore ? 'yes' : 'no'}`);
322
- console.log(` Domain packs: ${(state.domainPacks || []).map(p => p.label).join(', ') || 'none'}`);
323
- console.log(` MCP packs: ${(state.mcpPacks || []).map(p => p.label).join(', ') || 'none'}`);
324
- console.log(` Workflows: ${state.generateWorkflows ? 'yes' : 'no'}`);
325
- console.log(` Memories: ${state.generateMemories ? 'yes' : 'no'}`);
326
- console.log('');
327
-
328
- const answer = await ask(rl, c(' Generate files? (y/n, or b=back, q=quit) [y]: ', 'magenta'));
329
- const trimmed = answer.trim().toLowerCase();
330
- if (trimmed === 'b') return 'back';
331
- if (trimmed === 'q') return 'quit';
332
- if (trimmed === 'n') return 'quit';
333
-
334
- state.confirmed = true;
335
- return 'done';
336
- }
337
-
338
- // --- Main Wizard ---
339
-
340
- const STAGES = [
341
- stageProjectDetection,
342
- stageRuleTypeSelection,
343
- stageLegacyMigration,
344
- stageCascadeignore,
345
- stageDomainPacks,
346
- stageMcpPacks,
347
- stageWorkflowConfig,
348
- stageMemoriesConfig,
349
- stageTeamSecurity,
350
- stageReviewGenerate,
351
- ];
352
-
353
- async function runWindsurfWizard(options) {
354
- if (!isTTY()) {
355
- console.log('Interactive wizard requires a TTY. Use --non-interactive or pipe mode instead.');
356
- return null;
357
- }
358
-
359
- const rl = readline.createInterface({ input: process.stdin, output: process.stdout });
360
- const ctx = new WindsurfProjectContext(options.dir);
361
- const state = {};
362
-
363
- console.log('');
364
- console.log(c(' nerviq windsurf interactive wizard', 'bold'));
365
- console.log(c(' ═══════════════════════════════════════', 'dim'));
366
-
367
- let stageIndex = 0;
368
-
369
- try {
370
- while (stageIndex < STAGES.length) {
371
- const result = await STAGES[stageIndex](rl, ctx, state);
372
- if (result === 'quit') { rl.close(); return null; }
373
- if (result === 'back') { stageIndex = Math.max(0, stageIndex - 1); continue; }
374
- if (result === 'done') break;
375
- stageIndex++;
376
- }
377
- } finally {
378
- rl.close();
379
- }
380
-
381
- if (!state.confirmed) return null;
382
- return state;
383
- }
384
-
385
- module.exports = {
386
- runWindsurfWizard,
387
- runProjectDetection,
388
- };
1
+ /**
2
+ * Windsurf Interactive Wizard — 10-stage guided setup.
3
+ *
4
+ * Adapted for Windsurf's architecture (foreground Cascade, memories, workflows).
5
+ *
6
+ * Stages:
7
+ * 1. Project detection (stacks, existing .windsurf/, .windsurfrules)
8
+ * 2. Rule type selection (Always, Auto, Agent-Requested, Manual)
9
+ * 3. Legacy migration (.windsurfrules -> .windsurf/rules/)
10
+ * 4. Cascadeignore setup
11
+ * 5. Domain pack selection
12
+ * 6. MCP pack selection
13
+ * 7. Workflow config
14
+ * 8. Memories config
15
+ * 9. Team & 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 { WindsurfProjectContext } = require('./context');
25
+ const { WINDSURF_TECHNIQUES } = require('./techniques');
26
+ const { WINDSURF_DOMAIN_PACKS, detectWindsurfDomainPacks } = require('./domain-packs');
27
+ const { recommendWindsurfMcpPacks, WINDSURF_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
+ 'Cascadeignore Setup',
49
+ 'Domain Pack Selection',
50
+ 'MCP Pack Selection',
51
+ 'Workflow Config',
52
+ 'Memories Config',
53
+ 'Team & 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.windsurfRules ? ctx.windsurfRules() : [];
68
+ const hasLegacy = ctx.hasLegacyRules ? ctx.hasLegacyRules() : false;
69
+ const hasMcpJson = ctx.mcpConfig().ok;
70
+ const workflows = ctx.workflowFiles ? ctx.workflowFiles() : [];
71
+ const memories = ctx.memoryFiles ? ctx.memoryFiles() : [];
72
+ const hasCascadeignore = ctx.hasCascadeignore ? ctx.hasCascadeignore() : false;
73
+ const surfaces = ctx.detectSurfaces();
74
+
75
+ const auditResults = [];
76
+ for (const [key, technique] of Object.entries(WINDSURF_TECHNIQUES)) {
77
+ auditResults.push({ key, ...technique, passed: technique.check(ctx) });
78
+ }
79
+ const passed = auditResults.filter(r => r.passed === true);
80
+ const failed = auditResults.filter(r => r.passed === false);
81
+
82
+ return { stacks, rules, hasLegacy, hasMcpJson, workflows, memories, hasCascadeignore, surfaces, auditResults, passed, failed };
83
+ }
84
+
85
+ async function stageProjectDetection(rl, ctx, state) {
86
+ printStageHeader(0);
87
+ const det = runProjectDetection(ctx);
88
+ Object.assign(state, det);
89
+
90
+ if (det.stacks.length > 0) console.log(c(` Detected stacks: ${det.stacks.map(s => s.label).join(', ')}`, 'blue'));
91
+ else console.log(c(' No specific stack detected — will use baseline defaults.', 'dim'));
92
+
93
+ console.log(c(` Working directory: ${ctx.dir}`, 'dim'));
94
+ console.log('');
95
+ console.log(` ${c(`${det.passed.length}/${det.auditResults.length}`, 'bold')} Windsurf checks passing.`);
96
+ console.log(` ${c(String(det.failed.length), 'yellow')} improvements available.`);
97
+ console.log('');
98
+ console.log(` Surfaces: FG ${det.surfaces.foreground ? c('Y', 'green') : c('N', 'red')} | WF ${det.surfaces.workflows ? c('Y', 'green') : c('N', 'red')} | Mem ${det.surfaces.memories ? c('Y', 'green') : c('N', 'red')} | CI ${det.hasCascadeignore ? c('Y', 'green') : c('N', 'red')}`);
99
+ console.log(` Rules: ${det.rules.length} .md files${det.hasLegacy ? c(' + .windsurfrules (legacy!)', 'red') : ''}`);
100
+
101
+ if (det.rules.length > 0 || det.hasLegacy) {
102
+ console.log('');
103
+ if (det.hasLegacy) console.log(c(' WARNING: .windsurfrules found — this is the legacy format!', 'red'));
104
+ if (det.rules.length > 0) console.log(c(` ${det.rules.length} .md rule files in .windsurf/rules/`, 'dim'));
105
+ if (det.hasMcpJson) console.log(c(' .windsurf/mcp.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 Windsurf 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(' Windsurf supports 4 rule activation modes. Which do you want to generate?');
127
+ console.log('');
128
+ console.log(` ${c('1', 'bold')}. ${c('Always only', 'blue')} — Core rules for every Cascade interaction.`);
129
+ console.log(` ${c('2', 'bold')}. ${c('Always + Auto', 'blue')} — Core + file-type-specific rules.`);
130
+ console.log(` ${c('3', 'bold')}. ${c('Full set', 'blue')} — Always + Auto + 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');
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(' WARNING: .windsurfrules file detected!', 'red'));
155
+ console.log('');
156
+ console.log(' The .windsurfrules file is the legacy format.');
157
+ console.log(' Migrate to .windsurf/rules/*.md with YAML frontmatter for best results.');
158
+ console.log('');
159
+ console.log(` ${c('1', 'bold')}. ${c('Auto-migrate', 'blue')} — Convert .windsurfrules content to .md format.`);
160
+ console.log(` ${c('2', 'bold')}. ${c('Keep both', 'yellow')} — Generate new .md rules alongside .windsurfrules.`);
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: Cascadeignore Setup ---
176
+
177
+ async function stageCascadeignore(rl, _ctx, state) {
178
+ printStageHeader(3);
179
+
180
+ console.log(' Configure .cascadeignore for sensitive file exclusion?');
181
+ console.log('');
182
+ console.log(c(' .cascadeignore uses gitignore syntax to prevent Cascade from accessing files.', 'dim'));
183
+ console.log(c(' Recommended patterns: .env, secrets/, credentials/, .aws/, .ssh/', 'dim'));
184
+ console.log('');
185
+
186
+ const answer = await ask(rl, c(' Generate .cascadeignore? (y/n, or b=back, q=quit) [y]: ', 'magenta'));
187
+ const trimmed = answer.trim().toLowerCase();
188
+ if (trimmed === 'b') return 'back';
189
+ if (trimmed === 'q') return 'quit';
190
+
191
+ state.generateCascadeignore = trimmed !== 'n';
192
+ console.log(c(` → Cascadeignore: ${state.generateCascadeignore ? 'will configure' : 'skip'}`, 'green'));
193
+ return 'next';
194
+ }
195
+
196
+ // --- Stage 5: Domain Pack Selection ---
197
+
198
+ async function stageDomainPacks(rl, ctx, state) {
199
+ printStageHeader(4);
200
+
201
+ const detected = detectWindsurfDomainPacks(ctx, state.stacks || []);
202
+ state.domainPacks = detected;
203
+
204
+ console.log(` Detected ${detected.length} domain pack(s):`);
205
+ console.log('');
206
+ detected.forEach((pack, i) => {
207
+ console.log(` ${c(`${i + 1}`, 'bold')}. ${c(pack.label, 'blue')} — ${pack.matchReasons[0] || pack.useWhen}`);
208
+ });
209
+ console.log('');
210
+
211
+ const answer = await ask(rl, c(' Accept detected packs? (y/n, or b=back, q=quit) [y]: ', 'magenta'));
212
+ const trimmed = answer.trim().toLowerCase();
213
+ if (trimmed === 'b') return 'back';
214
+ if (trimmed === 'q') return 'quit';
215
+ if (trimmed === 'n') state.domainPacks = [];
216
+
217
+ console.log(c(` → Domain packs: ${state.domainPacks.map(p => p.label).join(', ') || 'none'}`, 'green'));
218
+ return 'next';
219
+ }
220
+
221
+ // --- Stage 6: MCP Pack Selection ---
222
+
223
+ async function stageMcpPacks(rl, ctx, state) {
224
+ printStageHeader(5);
225
+
226
+ const recommended = recommendWindsurfMcpPacks(state.stacks || [], state.domainPacks || [], { ctx });
227
+ state.mcpPacks = recommended;
228
+
229
+ console.log(` Recommended ${recommended.length} MCP pack(s):`);
230
+ console.log('');
231
+ recommended.forEach((pack, i) => {
232
+ console.log(` ${c(`${i + 1}`, 'bold')}. ${c(pack.label, 'blue')} — ${pack.description}`);
233
+ });
234
+ console.log('');
235
+
236
+ const answer = await ask(rl, c(' Accept recommended packs? (y/n, or b=back, q=quit) [y]: ', 'magenta'));
237
+ const trimmed = answer.trim().toLowerCase();
238
+ if (trimmed === 'b') return 'back';
239
+ if (trimmed === 'q') return 'quit';
240
+ if (trimmed === 'n') state.mcpPacks = [];
241
+
242
+ console.log(c(` → MCP packs: ${state.mcpPacks.map(p => p.label).join(', ') || 'none'}`, 'green'));
243
+ return 'next';
244
+ }
245
+
246
+ // --- Stage 7: Workflow Config ---
247
+
248
+ async function stageWorkflowConfig(rl, _ctx, state) {
249
+ printStageHeader(6);
250
+
251
+ console.log(' Configure Windsurf workflows (slash commands)?');
252
+ console.log('');
253
+ console.log(c(' Workflows define reusable slash commands for Cascade.', 'dim'));
254
+ console.log(c(' Stored in .windsurf/workflows/*.md', 'dim'));
255
+ console.log('');
256
+
257
+ const answer = await ask(rl, c(' Set up starter workflows? (y/n, or b=back, q=quit) [n]: ', 'magenta'));
258
+ const trimmed = answer.trim().toLowerCase();
259
+ if (trimmed === 'b') return 'back';
260
+ if (trimmed === 'q') return 'quit';
261
+
262
+ state.generateWorkflows = trimmed === 'y';
263
+ console.log(c(` → Workflows: ${state.generateWorkflows ? 'will configure' : 'skip'}`, 'green'));
264
+ return 'next';
265
+ }
266
+
267
+ // --- Stage 8: Memories Config ---
268
+
269
+ async function stageMemoriesConfig(rl, _ctx, state) {
270
+ printStageHeader(7);
271
+
272
+ console.log(' Configure Windsurf memories (persistent context)?');
273
+ console.log('');
274
+ console.log(c(' Memories provide persistent context that syncs across team members.', 'dim'));
275
+ console.log(c(' IMPORTANT: Never put secrets or PII in memories — they sync to all team members!', 'yellow'));
276
+ console.log('');
277
+
278
+ const answer = await ask(rl, c(' Generate starter memories? (y/n, or b=back, q=quit) [n]: ', 'magenta'));
279
+ const trimmed = answer.trim().toLowerCase();
280
+ if (trimmed === 'b') return 'back';
281
+ if (trimmed === 'q') return 'quit';
282
+
283
+ state.generateMemories = trimmed === 'y';
284
+ console.log(c(` → Memories: ${state.generateMemories ? 'will configure' : 'skip'}`, 'green'));
285
+ return 'next';
286
+ }
287
+
288
+ // --- Stage 9: Team & Security ---
289
+
290
+ async function stageTeamSecurity(rl, _ctx, state) {
291
+ printStageHeader(8);
292
+
293
+ console.log(' Review team and security considerations:');
294
+ console.log('');
295
+ console.log(c(' 1. Memories sync across team — check for secrets/PII', 'yellow'));
296
+ console.log(c(' 2. MCP servers can be whitelisted at team level', 'dim'));
297
+ console.log(c(' 3. .cascadeignore protects sensitive files from Cascade', 'dim'));
298
+ console.log(c(' 4. Each rule file has a 10K character limit', 'dim'));
299
+ console.log('');
300
+
301
+ const answer = await ask(rl, c(' Acknowledge team/security considerations? (y/n, or b=back, q=quit) [y]: ', 'magenta'));
302
+ const trimmed = answer.trim().toLowerCase();
303
+ if (trimmed === 'b') return 'back';
304
+ if (trimmed === 'q') return 'quit';
305
+ if (trimmed === 'n') return 'quit';
306
+
307
+ state.securityAcknowledged = true;
308
+ console.log(c(' → Team/security considerations acknowledged.', 'yellow'));
309
+ return 'next';
310
+ }
311
+
312
+ // --- Stage 10: Review & Generate ---
313
+
314
+ async function stageReviewGenerate(rl, _ctx, state) {
315
+ printStageHeader(9);
316
+
317
+ console.log(' Summary of your Windsurf setup:');
318
+ console.log('');
319
+ console.log(` Rule types: ${(state.ruleTypes || []).join(', ')}`);
320
+ console.log(` Legacy migration: ${state.legacyMigration || 'N/A'}`);
321
+ console.log(` Cascadeignore: ${state.generateCascadeignore ? 'yes' : 'no'}`);
322
+ console.log(` Domain packs: ${(state.domainPacks || []).map(p => p.label).join(', ') || 'none'}`);
323
+ console.log(` MCP packs: ${(state.mcpPacks || []).map(p => p.label).join(', ') || 'none'}`);
324
+ console.log(` Workflows: ${state.generateWorkflows ? 'yes' : 'no'}`);
325
+ console.log(` Memories: ${state.generateMemories ? 'yes' : 'no'}`);
326
+ console.log('');
327
+
328
+ const answer = await ask(rl, c(' Generate files? (y/n, or b=back, q=quit) [y]: ', 'magenta'));
329
+ const trimmed = answer.trim().toLowerCase();
330
+ if (trimmed === 'b') return 'back';
331
+ if (trimmed === 'q') return 'quit';
332
+ if (trimmed === 'n') return 'quit';
333
+
334
+ state.confirmed = true;
335
+ return 'done';
336
+ }
337
+
338
+ // --- Main Wizard ---
339
+
340
+ const STAGES = [
341
+ stageProjectDetection,
342
+ stageRuleTypeSelection,
343
+ stageLegacyMigration,
344
+ stageCascadeignore,
345
+ stageDomainPacks,
346
+ stageMcpPacks,
347
+ stageWorkflowConfig,
348
+ stageMemoriesConfig,
349
+ stageTeamSecurity,
350
+ stageReviewGenerate,
351
+ ];
352
+
353
+ async function runWindsurfWizard(options) {
354
+ if (!isTTY()) {
355
+ console.log('Interactive wizard requires a TTY. Use --non-interactive or pipe mode instead.');
356
+ return null;
357
+ }
358
+
359
+ const rl = readline.createInterface({ input: process.stdin, output: process.stdout });
360
+ const ctx = new WindsurfProjectContext(options.dir);
361
+ const state = {};
362
+
363
+ console.log('');
364
+ console.log(c(' nerviq windsurf interactive wizard', 'bold'));
365
+ console.log(c(' ═══════════════════════════════════════', 'dim'));
366
+
367
+ let stageIndex = 0;
368
+
369
+ try {
370
+ while (stageIndex < STAGES.length) {
371
+ const result = await STAGES[stageIndex](rl, ctx, state);
372
+ if (result === 'quit') { rl.close(); return null; }
373
+ if (result === 'back') { stageIndex = Math.max(0, stageIndex - 1); continue; }
374
+ if (result === 'done') break;
375
+ stageIndex++;
376
+ }
377
+ } finally {
378
+ rl.close();
379
+ }
380
+
381
+ if (!state.confirmed) return null;
382
+ return state;
383
+ }
384
+
385
+ module.exports = {
386
+ runWindsurfWizard,
387
+ runProjectDetection,
388
+ };