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