@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,231 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Windsurf Patch Intelligence
|
|
3
|
+
*
|
|
4
|
+
* Safe patching of existing Windsurf files using managed blocks.
|
|
5
|
+
* Supports .windsurf/rules/*.md (HTML comment blocks) and
|
|
6
|
+
* .windsurf/mcp.json (JSON merge).
|
|
7
|
+
*
|
|
8
|
+
* Managed blocks are sections that nerviq controls.
|
|
9
|
+
* Hand-authored content outside managed blocks is preserved.
|
|
10
|
+
*/
|
|
11
|
+
|
|
12
|
+
const fs = require('fs');
|
|
13
|
+
const path = require('path');
|
|
14
|
+
const { writeRollbackArtifact, writeActivityArtifact } = require('../activity');
|
|
15
|
+
|
|
16
|
+
// Managed block markers for Markdown rule files (HTML comments work in Markdown body)
|
|
17
|
+
const MANAGED_START_MD = '<!-- nerviq:managed:start -->';
|
|
18
|
+
const MANAGED_END_MD = '<!-- nerviq:managed:end -->';
|
|
19
|
+
const MANAGED_JSON_KEY = '_claudex_managed';
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* Extract managed blocks from a file.
|
|
23
|
+
*/
|
|
24
|
+
function extractManagedBlock(content, startMarker, endMarker) {
|
|
25
|
+
const startIdx = content.indexOf(startMarker);
|
|
26
|
+
const endIdx = content.indexOf(endMarker);
|
|
27
|
+
|
|
28
|
+
if (startIdx === -1 || endIdx === -1 || endIdx <= startIdx) {
|
|
29
|
+
return { before: content, managed: null, after: '' };
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
return {
|
|
33
|
+
before: content.substring(0, startIdx),
|
|
34
|
+
managed: content.substring(startIdx + startMarker.length, endIdx).trim(),
|
|
35
|
+
after: content.substring(endIdx + endMarker.length),
|
|
36
|
+
};
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
/**
|
|
40
|
+
* Replace or insert a managed block in a file.
|
|
41
|
+
*/
|
|
42
|
+
function upsertManagedBlock(content, newManaged, startMarker, endMarker) {
|
|
43
|
+
const { before, managed, after } = extractManagedBlock(content, startMarker, endMarker);
|
|
44
|
+
|
|
45
|
+
if (managed !== null) {
|
|
46
|
+
return `${before}${startMarker}\n${newManaged}\n${endMarker}${after}`;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
const separator = content.endsWith('\n') ? '\n' : '\n\n';
|
|
50
|
+
return `${content}${separator}${startMarker}\n${newManaged}\n${endMarker}\n`;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
/**
|
|
54
|
+
* Patch .windsurf/rules/*.md with managed sections.
|
|
55
|
+
* Preserves YAML frontmatter and hand-authored content.
|
|
56
|
+
*/
|
|
57
|
+
function patchWindsurfRuleMd(existingContent, managedSections) {
|
|
58
|
+
const newManaged = Object.entries(managedSections)
|
|
59
|
+
.map(([section, content]) => `## ${section}\n${content}`)
|
|
60
|
+
.join('\n\n');
|
|
61
|
+
|
|
62
|
+
return upsertManagedBlock(existingContent, newManaged, MANAGED_START_MD, MANAGED_END_MD);
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
/**
|
|
66
|
+
* Patch .windsurf/mcp.json by safely merging new servers.
|
|
67
|
+
*/
|
|
68
|
+
function patchMcpJson(existingContent, newServers) {
|
|
69
|
+
let existing;
|
|
70
|
+
try {
|
|
71
|
+
existing = JSON.parse(existingContent);
|
|
72
|
+
} catch {
|
|
73
|
+
existing = {};
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
if (!existing.mcpServers) existing.mcpServers = {};
|
|
77
|
+
|
|
78
|
+
const merged = { ...existing };
|
|
79
|
+
for (const [serverName, config] of Object.entries(newServers)) {
|
|
80
|
+
if (!(serverName in merged.mcpServers)) {
|
|
81
|
+
merged.mcpServers[serverName] = config;
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
if (!merged[MANAGED_JSON_KEY]) merged[MANAGED_JSON_KEY] = {};
|
|
86
|
+
merged[MANAGED_JSON_KEY]._updatedAt = new Date().toISOString();
|
|
87
|
+
merged[MANAGED_JSON_KEY]._generator = 'nerviq';
|
|
88
|
+
merged[MANAGED_JSON_KEY]._platform = 'windsurf';
|
|
89
|
+
|
|
90
|
+
return JSON.stringify(merged, null, 2) + '\n';
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
/**
|
|
94
|
+
* Patch .cascadeignore by appending new patterns.
|
|
95
|
+
*/
|
|
96
|
+
function patchCascadeignore(existingContent, newPatterns) {
|
|
97
|
+
const existing = existingContent || '';
|
|
98
|
+
const existingLines = new Set(existing.split('\n').map(l => l.trim()).filter(l => l && !l.startsWith('#')));
|
|
99
|
+
|
|
100
|
+
const toAdd = newPatterns.filter(p => !existingLines.has(p.trim()));
|
|
101
|
+
if (toAdd.length === 0) return existing;
|
|
102
|
+
|
|
103
|
+
const separator = existing.endsWith('\n') ? '' : '\n';
|
|
104
|
+
return `${existing}${separator}\n# Added by nerviq\n${toAdd.join('\n')}\n`;
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
/**
|
|
108
|
+
* Detect if a repo has multiple agent surfaces (Windsurf + Claude + Cursor + Codex + Copilot coexistence).
|
|
109
|
+
*/
|
|
110
|
+
function detectMixedAgentRepo(dir) {
|
|
111
|
+
const hasClaude = fs.existsSync(path.join(dir, 'CLAUDE.md')) || fs.existsSync(path.join(dir, '.claude'));
|
|
112
|
+
const hasCodex = fs.existsSync(path.join(dir, 'AGENTS.md')) || fs.existsSync(path.join(dir, '.codex'));
|
|
113
|
+
const hasGemini = fs.existsSync(path.join(dir, 'GEMINI.md')) || fs.existsSync(path.join(dir, '.gemini'));
|
|
114
|
+
const hasCopilot = fs.existsSync(path.join(dir, '.github', 'copilot-instructions.md')) ||
|
|
115
|
+
fs.existsSync(path.join(dir, '.vscode', 'mcp.json'));
|
|
116
|
+
const hasCursor = fs.existsSync(path.join(dir, '.cursor')) ||
|
|
117
|
+
fs.existsSync(path.join(dir, '.cursorrules'));
|
|
118
|
+
const hasWindsurf = fs.existsSync(path.join(dir, '.windsurf')) ||
|
|
119
|
+
fs.existsSync(path.join(dir, '.windsurfrules'));
|
|
120
|
+
|
|
121
|
+
const platforms = [];
|
|
122
|
+
if (hasClaude) platforms.push('claude');
|
|
123
|
+
if (hasCodex) platforms.push('codex');
|
|
124
|
+
if (hasGemini) platforms.push('gemini');
|
|
125
|
+
if (hasCopilot) platforms.push('copilot');
|
|
126
|
+
if (hasCursor) platforms.push('cursor');
|
|
127
|
+
if (hasWindsurf) platforms.push('windsurf');
|
|
128
|
+
|
|
129
|
+
return {
|
|
130
|
+
isMixed: platforms.length >= 2,
|
|
131
|
+
hasClaude,
|
|
132
|
+
hasCodex,
|
|
133
|
+
hasGemini,
|
|
134
|
+
hasCopilot,
|
|
135
|
+
hasCursor,
|
|
136
|
+
hasWindsurf,
|
|
137
|
+
platforms,
|
|
138
|
+
guidance: platforms.length >= 2
|
|
139
|
+
? `This is a mixed-agent repo (${platforms.join(', ')}). Keep each platform's config in its own directory (.claude/, .cursor/, .windsurf/, .gemini/, .github/). Do not merge them.`
|
|
140
|
+
: null,
|
|
141
|
+
};
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
/**
|
|
145
|
+
* Generate a diff preview for a patch operation.
|
|
146
|
+
*/
|
|
147
|
+
function generatePatchPreview(originalContent, patchedContent, filePath) {
|
|
148
|
+
const origLines = originalContent.split('\n');
|
|
149
|
+
const patchLines = patchedContent.split('\n');
|
|
150
|
+
const lines = [`--- ${filePath} (original)`, `+++ ${filePath} (patched)`];
|
|
151
|
+
|
|
152
|
+
let inChange = false;
|
|
153
|
+
for (let i = 0; i < Math.max(origLines.length, patchLines.length); i++) {
|
|
154
|
+
const orig = origLines[i] || '';
|
|
155
|
+
const patched = patchLines[i] || '';
|
|
156
|
+
if (orig !== patched) {
|
|
157
|
+
if (!inChange) { lines.push(`@@ line ${i + 1} @@`); inChange = true; }
|
|
158
|
+
if (i < origLines.length) lines.push(`-${orig}`);
|
|
159
|
+
if (i < patchLines.length) lines.push(`+${patched}`);
|
|
160
|
+
} else {
|
|
161
|
+
inChange = false;
|
|
162
|
+
}
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
return lines.join('\n');
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
/**
|
|
169
|
+
* Apply a patch to a file with backup and rollback support.
|
|
170
|
+
*/
|
|
171
|
+
function applyPatch(dir, filePath, patchFn, options = {}) {
|
|
172
|
+
const fullPath = path.join(dir, filePath);
|
|
173
|
+
const dryRun = options.dryRun === true;
|
|
174
|
+
|
|
175
|
+
if (!fs.existsSync(fullPath)) {
|
|
176
|
+
return { success: false, reason: `${filePath} does not exist`, preview: null };
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
const original = fs.readFileSync(fullPath, 'utf8');
|
|
180
|
+
const patched = patchFn(original);
|
|
181
|
+
|
|
182
|
+
if (patched === original) {
|
|
183
|
+
return { success: true, reason: 'no changes needed', preview: null, unchanged: true };
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
const preview = generatePatchPreview(original, patched, filePath);
|
|
187
|
+
|
|
188
|
+
if (dryRun) {
|
|
189
|
+
return { success: true, reason: 'dry run', preview, unchanged: false };
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
const backupPath = fullPath + '.claudex-backup';
|
|
193
|
+
fs.writeFileSync(backupPath, original, 'utf8');
|
|
194
|
+
fs.writeFileSync(fullPath, patched, 'utf8');
|
|
195
|
+
|
|
196
|
+
const rollback = writeRollbackArtifact(dir, {
|
|
197
|
+
sourcePlan: 'windsurf-patch',
|
|
198
|
+
patchedFiles: [filePath],
|
|
199
|
+
backupFiles: [{ original: filePath, backup: path.relative(dir, backupPath) }],
|
|
200
|
+
rollbackInstructions: [`Restore ${filePath} from ${path.relative(dir, backupPath)}`],
|
|
201
|
+
});
|
|
202
|
+
|
|
203
|
+
const activity = writeActivityArtifact(dir, 'windsurf-patch', {
|
|
204
|
+
platform: 'windsurf',
|
|
205
|
+
patchedFiles: [filePath],
|
|
206
|
+
rollbackArtifact: rollback.relativePath,
|
|
207
|
+
});
|
|
208
|
+
|
|
209
|
+
return {
|
|
210
|
+
success: true,
|
|
211
|
+
reason: 'patched',
|
|
212
|
+
preview,
|
|
213
|
+
unchanged: false,
|
|
214
|
+
rollbackArtifact: rollback.relativePath,
|
|
215
|
+
activityArtifact: activity.relativePath,
|
|
216
|
+
};
|
|
217
|
+
}
|
|
218
|
+
|
|
219
|
+
module.exports = {
|
|
220
|
+
MANAGED_START_MD,
|
|
221
|
+
MANAGED_END_MD,
|
|
222
|
+
MANAGED_JSON_KEY,
|
|
223
|
+
extractManagedBlock,
|
|
224
|
+
upsertManagedBlock,
|
|
225
|
+
patchWindsurfRuleMd,
|
|
226
|
+
patchMcpJson,
|
|
227
|
+
patchCascadeignore,
|
|
228
|
+
detectMixedAgentRepo,
|
|
229
|
+
generatePatchPreview,
|
|
230
|
+
applyPatch,
|
|
231
|
+
};
|
|
@@ -0,0 +1,247 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Windsurf Proposal Bundle — 9 proposal families.
|
|
3
|
+
*
|
|
4
|
+
* windsurf-rules, windsurf-mcp, windsurf-cascadeignore, windsurf-workflows,
|
|
5
|
+
* windsurf-memories, windsurf-legacy-migration, windsurf-ci-review,
|
|
6
|
+
* windsurf-cascade-guide, windsurf-enterprise
|
|
7
|
+
*/
|
|
8
|
+
|
|
9
|
+
const path = require('path');
|
|
10
|
+
const { version } = require('../../package.json');
|
|
11
|
+
const { audit } = require('../audit');
|
|
12
|
+
const { analyzeProject } = require('../analyze');
|
|
13
|
+
const { buildWindsurfSetupFiles } = require('./setup');
|
|
14
|
+
const { getWindsurfMcpPreflight } = require('./mcp-packs');
|
|
15
|
+
|
|
16
|
+
function maturityFromScore(score) {
|
|
17
|
+
if (score >= 81) return 'mature';
|
|
18
|
+
if (score >= 61) return 'solid';
|
|
19
|
+
if (score >= 41) return 'developing';
|
|
20
|
+
if (score >= 21) return 'weak';
|
|
21
|
+
return 'raw';
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
function triggerMatchesFile(result, filePath) {
|
|
25
|
+
if (filePath.startsWith('.windsurf/rules/')) {
|
|
26
|
+
return result.file === '.windsurf/rules/' || result.category === 'rules' ||
|
|
27
|
+
result.category === 'instructions-quality' || result.category === 'quality-deep';
|
|
28
|
+
}
|
|
29
|
+
if (filePath === '.windsurf/mcp.json' || filePath.includes('MCP')) {
|
|
30
|
+
return result.category === 'mcp';
|
|
31
|
+
}
|
|
32
|
+
if (filePath === '.cascadeignore') {
|
|
33
|
+
return result.category === 'cascadeignore' || result.category === 'trust';
|
|
34
|
+
}
|
|
35
|
+
if (filePath.includes('workflows')) {
|
|
36
|
+
return result.category === 'workflows';
|
|
37
|
+
}
|
|
38
|
+
if (filePath.includes('memories')) {
|
|
39
|
+
return result.category === 'memories';
|
|
40
|
+
}
|
|
41
|
+
if (filePath.includes('windsurf-review')) {
|
|
42
|
+
return result.category === 'cross-surface';
|
|
43
|
+
}
|
|
44
|
+
if (filePath.includes('cascade-guide')) {
|
|
45
|
+
return result.category === 'cascade-agent';
|
|
46
|
+
}
|
|
47
|
+
if (filePath.includes('migration')) {
|
|
48
|
+
return result.id === 'WS-A02' || result.id === 'WS-L02';
|
|
49
|
+
}
|
|
50
|
+
return result.file === filePath;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
function uniqueValues(items = []) {
|
|
54
|
+
return [...new Set(items.filter(Boolean))];
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
function buildDomainPackGuidance(report) {
|
|
58
|
+
return (report.recommendedDomainPacks || []).map((pack) => ({
|
|
59
|
+
key: pack.key,
|
|
60
|
+
label: pack.label,
|
|
61
|
+
useWhen: pack.useWhen,
|
|
62
|
+
matchReasons: pack.matchReasons || [],
|
|
63
|
+
recommendedModules: pack.recommendedModules || [],
|
|
64
|
+
recommendedProposalFamilies: pack.recommendedProposalFamilies || [],
|
|
65
|
+
recommendedSurfaces: pack.recommendedSurfaces || [],
|
|
66
|
+
benchmarkFocus: pack.benchmarkFocus || [],
|
|
67
|
+
}));
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
function selectPackContext(filePath, domainPackGuidance = []) {
|
|
71
|
+
return domainPackGuidance
|
|
72
|
+
.filter((pack) => {
|
|
73
|
+
if (!Array.isArray(pack.recommendedSurfaces) || pack.recommendedSurfaces.length === 0) return true;
|
|
74
|
+
return pack.recommendedSurfaces.some((surface) => filePath === surface || filePath.startsWith(surface));
|
|
75
|
+
})
|
|
76
|
+
.map((pack) => ({
|
|
77
|
+
key: pack.key,
|
|
78
|
+
label: pack.label,
|
|
79
|
+
why: pack.matchReasons[0] || pack.useWhen,
|
|
80
|
+
recommendedModules: (pack.recommendedModules || []).slice(0, 3),
|
|
81
|
+
recommendedProposalFamilies: (pack.recommendedProposalFamilies || []).slice(0, 3),
|
|
82
|
+
benchmarkFocus: (pack.benchmarkFocus || []).slice(0, 2),
|
|
83
|
+
}));
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
const PROPOSAL_FAMILIES = {
|
|
87
|
+
'.windsurf/rules/core.md': {
|
|
88
|
+
id: 'windsurf-rules',
|
|
89
|
+
title: 'Create Windsurf core rules (.md)',
|
|
90
|
+
module: 'rules',
|
|
91
|
+
risk: 'low',
|
|
92
|
+
confidence: 'high',
|
|
93
|
+
},
|
|
94
|
+
'.windsurf/mcp.json': {
|
|
95
|
+
id: 'windsurf-mcp',
|
|
96
|
+
title: 'Create Windsurf MCP configuration',
|
|
97
|
+
module: 'mcp',
|
|
98
|
+
risk: 'medium',
|
|
99
|
+
confidence: 'high',
|
|
100
|
+
},
|
|
101
|
+
'.cascadeignore': {
|
|
102
|
+
id: 'windsurf-cascadeignore',
|
|
103
|
+
title: 'Create .cascadeignore for sensitive file exclusion',
|
|
104
|
+
module: 'cascadeignore',
|
|
105
|
+
risk: 'low',
|
|
106
|
+
confidence: 'high',
|
|
107
|
+
},
|
|
108
|
+
'.windsurf/rules/migration-guide.md': {
|
|
109
|
+
id: 'windsurf-legacy-migration',
|
|
110
|
+
title: 'Create legacy .windsurfrules migration guide',
|
|
111
|
+
module: 'legacy-migration',
|
|
112
|
+
risk: 'low',
|
|
113
|
+
confidence: 'high',
|
|
114
|
+
},
|
|
115
|
+
'.github/workflows/windsurf-review.yml': {
|
|
116
|
+
id: 'windsurf-ci-review',
|
|
117
|
+
title: 'Create Windsurf CI review workflow',
|
|
118
|
+
module: 'ci',
|
|
119
|
+
risk: 'medium',
|
|
120
|
+
confidence: 'medium',
|
|
121
|
+
},
|
|
122
|
+
'.windsurf/rules/cascade-guide.md': {
|
|
123
|
+
id: 'windsurf-cascade-guide',
|
|
124
|
+
title: 'Create Cascade agent usage guide',
|
|
125
|
+
module: 'cascade-guide',
|
|
126
|
+
risk: 'low',
|
|
127
|
+
confidence: 'medium',
|
|
128
|
+
},
|
|
129
|
+
'.windsurf/rules/typescript.md': {
|
|
130
|
+
id: 'windsurf-rules',
|
|
131
|
+
title: 'Create Windsurf TypeScript Auto rule',
|
|
132
|
+
module: 'rules',
|
|
133
|
+
risk: 'low',
|
|
134
|
+
confidence: 'high',
|
|
135
|
+
},
|
|
136
|
+
};
|
|
137
|
+
|
|
138
|
+
function resolveProposalFamily(file) {
|
|
139
|
+
const familyFromFile = file.family
|
|
140
|
+
? Object.values(PROPOSAL_FAMILIES).find(f => f.id === file.family)
|
|
141
|
+
: null;
|
|
142
|
+
return familyFromFile || PROPOSAL_FAMILIES[file.path] || {
|
|
143
|
+
id: 'windsurf-unknown',
|
|
144
|
+
title: `Create ${file.path}`,
|
|
145
|
+
module: 'unknown',
|
|
146
|
+
risk: 'medium',
|
|
147
|
+
confidence: 'low',
|
|
148
|
+
};
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
function proposalForFile(file, auditResult, domainPackGuidance = []) {
|
|
152
|
+
const triggers = auditResult.results
|
|
153
|
+
.filter((result) => result.passed === false && triggerMatchesFile(result, file.path))
|
|
154
|
+
.sort((a, b) => {
|
|
155
|
+
const weight = { critical: 3, high: 2, medium: 1, low: 0 };
|
|
156
|
+
return (weight[b.impact] || 0) - (weight[a.impact] || 0);
|
|
157
|
+
})
|
|
158
|
+
.slice(0, 6)
|
|
159
|
+
.map((result) => ({ key: result.key, name: result.name, impact: result.impact, fix: result.fix }));
|
|
160
|
+
const packContext = selectPackContext(file.path, domainPackGuidance);
|
|
161
|
+
const familyMeta = resolveProposalFamily(file);
|
|
162
|
+
|
|
163
|
+
return {
|
|
164
|
+
id: familyMeta.id,
|
|
165
|
+
title: familyMeta.title,
|
|
166
|
+
module: familyMeta.module,
|
|
167
|
+
risk: familyMeta.risk,
|
|
168
|
+
confidence: familyMeta.confidence,
|
|
169
|
+
triggers,
|
|
170
|
+
rationale: uniqueValues([
|
|
171
|
+
...triggers.map((item) => item.fix),
|
|
172
|
+
...packContext.map((item) => `Supports ${item.label} rollout guidance: ${item.why}`),
|
|
173
|
+
]),
|
|
174
|
+
packContext,
|
|
175
|
+
files: [{
|
|
176
|
+
path: file.path,
|
|
177
|
+
action: file.action,
|
|
178
|
+
currentState: file.currentState,
|
|
179
|
+
proposedState: file.proposedState,
|
|
180
|
+
content: file.content,
|
|
181
|
+
preview: file.content.split('\n').slice(0, 12).join('\n'),
|
|
182
|
+
diffPreview: [`--- missing`, `+++ ${file.path}`, ...file.content.split('\n').slice(0, 12).map((line) => `+${line}`)].join('\n'),
|
|
183
|
+
}],
|
|
184
|
+
readyToApply: true,
|
|
185
|
+
};
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
async function buildWindsurfProposalBundle(options) {
|
|
189
|
+
const auditResult = await audit({ ...options, platform: 'windsurf', silent: true });
|
|
190
|
+
const analysisReport = await analyzeProject({ ...options, platform: 'windsurf', mode: 'suggest-only' });
|
|
191
|
+
const domainPackGuidance = buildDomainPackGuidance(analysisReport);
|
|
192
|
+
const { files } = buildWindsurfSetupFiles(options);
|
|
193
|
+
const proposals = files.map((file) => proposalForFile(file, auditResult, domainPackGuidance));
|
|
194
|
+
|
|
195
|
+
// MCP preflight
|
|
196
|
+
const mcpProposal = proposals.find(p => p.id === 'windsurf-mcp');
|
|
197
|
+
let mcpPreflightWarnings = [];
|
|
198
|
+
if (mcpProposal) {
|
|
199
|
+
const mcpFile = files.find(f => f.family === 'windsurf-mcp');
|
|
200
|
+
if (mcpFile && mcpFile.content) {
|
|
201
|
+
let detectedKeys = [];
|
|
202
|
+
try {
|
|
203
|
+
const parsed = JSON.parse(mcpFile.content);
|
|
204
|
+
detectedKeys = Object.keys(parsed.mcpServers || parsed);
|
|
205
|
+
} catch {
|
|
206
|
+
const keyMatches = mcpFile.content.match(/"([^"]+)"\s*:/g) || [];
|
|
207
|
+
detectedKeys = keyMatches.map(m => m.replace(/[":]/g, '').trim());
|
|
208
|
+
}
|
|
209
|
+
mcpPreflightWarnings = getWindsurfMcpPreflight(detectedKeys)
|
|
210
|
+
.filter(p => !p.safe)
|
|
211
|
+
.map(p => ({ key: p.key, label: p.label, warning: p.warning }));
|
|
212
|
+
}
|
|
213
|
+
}
|
|
214
|
+
|
|
215
|
+
return {
|
|
216
|
+
schemaVersion: 2,
|
|
217
|
+
generatedBy: `nerviq@${version}`,
|
|
218
|
+
createdAt: new Date().toISOString(),
|
|
219
|
+
platform: 'windsurf',
|
|
220
|
+
directory: options.dir,
|
|
221
|
+
projectSummary: {
|
|
222
|
+
name: path.basename(options.dir),
|
|
223
|
+
score: auditResult.score,
|
|
224
|
+
organicScore: auditResult.organicScore,
|
|
225
|
+
maturity: maturityFromScore(auditResult.score),
|
|
226
|
+
domains: analysisReport.projectSummary.domains || [],
|
|
227
|
+
},
|
|
228
|
+
strengthsPreserved: auditResult.results
|
|
229
|
+
.filter((item) => item.passed === true)
|
|
230
|
+
.slice(0, 5)
|
|
231
|
+
.map((item) => item.name),
|
|
232
|
+
topNextActions: auditResult.topNextActions,
|
|
233
|
+
recommendedDomainPacks: domainPackGuidance,
|
|
234
|
+
proposalFamilies: [...new Set(proposals.map(p => p.id))],
|
|
235
|
+
optionalModules: analysisReport.optionalModules || [],
|
|
236
|
+
riskNotes: uniqueValues([
|
|
237
|
+
...(analysisReport.riskNotes || []),
|
|
238
|
+
...((auditResult.platformCaveats || []).map((item) => item.message)),
|
|
239
|
+
]),
|
|
240
|
+
mcpPreflightWarnings,
|
|
241
|
+
proposals,
|
|
242
|
+
};
|
|
243
|
+
}
|
|
244
|
+
|
|
245
|
+
module.exports = {
|
|
246
|
+
buildWindsurfProposalBundle,
|
|
247
|
+
};
|