@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,267 @@
1
+ /**
2
+ * Windsurf config parser.
3
+ *
4
+ * Windsurf uses Markdown + YAML frontmatter for .windsurf/rules/*.md,
5
+ * and JSON for .windsurf/mcp.json and other config.
6
+ * Key difference from Cursor: NO MDC format — standard Markdown with YAML frontmatter.
7
+ * 4 activation modes: Always, Auto, Agent-Requested, Manual.
8
+ * 10K char rule limit per file.
9
+ * This module handles both formats with unified value extraction.
10
+ */
11
+
12
+ // ─── JSON parsing ────────────────────────────────────────────────────────────
13
+
14
+ function tryParseJson(content) {
15
+ try {
16
+ const data = JSON.parse(content);
17
+ return { ok: true, data, error: null };
18
+ } catch (error) {
19
+ return { ok: false, data: null, error: error.message };
20
+ }
21
+ }
22
+
23
+ // ─── YAML frontmatter parsing (Markdown files) ─────────────────────────────
24
+
25
+ /**
26
+ * Parse a Windsurf rule file (YAML frontmatter delimited by --- + Markdown body).
27
+ * Returns { frontmatter: object|null, body: string, raw: string|null }
28
+ */
29
+ function parseWindsurfRule(content) {
30
+ if (!content || typeof content !== 'string') {
31
+ return { frontmatter: null, body: content || '', raw: null };
32
+ }
33
+
34
+ const trimmed = content.trimStart();
35
+ if (!trimmed.startsWith('---')) {
36
+ return { frontmatter: null, body: content, raw: null };
37
+ }
38
+
39
+ const endIdx = trimmed.indexOf('---', 3);
40
+ if (endIdx === -1) {
41
+ return { frontmatter: null, body: content, raw: null };
42
+ }
43
+
44
+ const raw = trimmed.slice(3, endIdx).trim();
45
+ const body = trimmed.slice(endIdx + 3).trim();
46
+ const frontmatter = parseSimpleYaml(raw);
47
+
48
+ return { frontmatter, body, raw };
49
+ }
50
+
51
+ /**
52
+ * Minimal YAML parser for Windsurf rule frontmatter fields.
53
+ * Handles: key: value, key: [item1, item2], key: "quoted", booleans, numbers.
54
+ * Also handles multi-line array syntax (indented with -).
55
+ */
56
+ function parseSimpleYaml(yamlStr) {
57
+ if (!yamlStr || typeof yamlStr !== 'string') return {};
58
+
59
+ const result = {};
60
+ const lines = yamlStr.split(/\r?\n/);
61
+ let currentKey = null;
62
+ let currentArray = null;
63
+
64
+ for (const line of lines) {
65
+ const trimmedLine = line.trim();
66
+ if (!trimmedLine || trimmedLine.startsWith('#')) continue;
67
+
68
+ // Check for multi-line array item ( - "value")
69
+ if (currentKey && currentArray !== null && /^\s*-\s+/.test(line)) {
70
+ const itemValue = trimmedLine.slice(1).trim();
71
+ currentArray.push(stripQuotes(itemValue));
72
+ continue;
73
+ }
74
+
75
+ // If we were collecting an array, commit it
76
+ if (currentKey && currentArray !== null) {
77
+ result[currentKey] = currentArray;
78
+ currentKey = null;
79
+ currentArray = null;
80
+ }
81
+
82
+ const colonIdx = trimmedLine.indexOf(':');
83
+ if (colonIdx === -1) continue;
84
+
85
+ const key = trimmedLine.slice(0, colonIdx).trim();
86
+ let value = trimmedLine.slice(colonIdx + 1).trim();
87
+
88
+ if (!key) continue;
89
+
90
+ // Parse value
91
+ if (value === '') {
92
+ // Could be start of multi-line array
93
+ currentKey = key;
94
+ currentArray = [];
95
+ } else if (value.startsWith('[') && value.endsWith(']')) {
96
+ // Inline array: [item1, item2]
97
+ const inner = value.slice(1, -1).trim();
98
+ if (!inner) {
99
+ result[key] = [];
100
+ } else {
101
+ result[key] = inner.split(',').map(item => {
102
+ const t = item.trim();
103
+ return stripQuotes(t);
104
+ });
105
+ }
106
+ } else if ((value.startsWith('"') && value.endsWith('"')) ||
107
+ (value.startsWith("'") && value.endsWith("'"))) {
108
+ result[key] = value.slice(1, -1);
109
+ } else if (value === 'true') {
110
+ result[key] = true;
111
+ } else if (value === 'false') {
112
+ result[key] = false;
113
+ } else if (/^-?\d+$/.test(value)) {
114
+ result[key] = parseInt(value, 10);
115
+ } else if (/^-?\d+\.\d+$/.test(value)) {
116
+ result[key] = parseFloat(value);
117
+ } else {
118
+ result[key] = value;
119
+ }
120
+ }
121
+
122
+ // Commit any remaining array
123
+ if (currentKey && currentArray !== null) {
124
+ result[currentKey] = currentArray;
125
+ }
126
+
127
+ return result;
128
+ }
129
+
130
+ function stripQuotes(str) {
131
+ if ((str.startsWith('"') && str.endsWith('"')) ||
132
+ (str.startsWith("'") && str.endsWith("'"))) {
133
+ return str.slice(1, -1);
134
+ }
135
+ return str;
136
+ }
137
+
138
+ // ─── Windsurf rule type detection ───────────────────────────────────────────
139
+
140
+ /**
141
+ * Determine the Windsurf rule activation mode from frontmatter fields.
142
+ *
143
+ * Windsurf 4 activation modes:
144
+ * Always: trigger: always
145
+ * Auto: trigger: auto, globs set
146
+ * Agent-Requested: trigger: agent_requested, description set
147
+ * Manual: trigger: manual (or no trigger field)
148
+ */
149
+ function detectRuleType(frontmatter) {
150
+ if (!frontmatter) return 'manual';
151
+
152
+ const trigger = (frontmatter.trigger || '').toLowerCase().trim();
153
+
154
+ if (trigger === 'always') return 'always';
155
+ if (trigger === 'auto' || trigger === 'auto_attached') return 'auto';
156
+ if (trigger === 'agent_requested' || trigger === 'agent-requested') return 'agent-requested';
157
+ if (trigger === 'manual') return 'manual';
158
+
159
+ // Fallback heuristic based on fields
160
+ const hasGlobs = Array.isArray(frontmatter.globs)
161
+ ? frontmatter.globs.length > 0
162
+ : Boolean(frontmatter.globs);
163
+ const hasDescription = Boolean(frontmatter.description && String(frontmatter.description).trim());
164
+
165
+ if (hasGlobs) return 'auto';
166
+ if (hasDescription && !hasGlobs) return 'agent-requested';
167
+ return 'manual';
168
+ }
169
+
170
+ // ─── Value extraction ────────────────────────────────────────────────────────
171
+
172
+ function getValueByPath(obj, dottedPath) {
173
+ if (!obj) return undefined;
174
+ const parts = dottedPath.split('.').filter(Boolean);
175
+ let cursor = obj;
176
+ for (const part of parts) {
177
+ if (cursor == null || typeof cursor !== 'object' || !(part in cursor)) {
178
+ return undefined;
179
+ }
180
+ cursor = cursor[part];
181
+ }
182
+ return cursor;
183
+ }
184
+
185
+ // ─── Windsurf frontmatter validation ────────────────────────────────────────
186
+
187
+ const VALID_WINDSURF_FIELDS = new Set(['trigger', 'description', 'globs', 'name']);
188
+
189
+ /**
190
+ * Validate Windsurf rule file frontmatter.
191
+ * Returns { valid, errors, ruleType }.
192
+ */
193
+ function validateWindsurfFrontmatter(frontmatter) {
194
+ if (!frontmatter) return { valid: false, errors: ['No frontmatter found'], ruleType: 'manual' };
195
+
196
+ const errors = [];
197
+
198
+ for (const key of Object.keys(frontmatter)) {
199
+ if (!VALID_WINDSURF_FIELDS.has(key)) {
200
+ errors.push(`Unknown Windsurf frontmatter field: "${key}"`);
201
+ }
202
+ }
203
+
204
+ // Validate trigger field
205
+ const validTriggers = ['always', 'auto', 'auto_attached', 'agent_requested', 'agent-requested', 'manual'];
206
+ if (frontmatter.trigger && !validTriggers.includes(String(frontmatter.trigger).toLowerCase().trim())) {
207
+ errors.push(`Invalid trigger value: "${frontmatter.trigger}". Must be one of: always, auto, agent_requested, manual`);
208
+ }
209
+
210
+ // Validate globs is an array if present
211
+ if (frontmatter.globs !== undefined && !Array.isArray(frontmatter.globs) && typeof frontmatter.globs !== 'string') {
212
+ errors.push('globs must be a string or array of strings');
213
+ }
214
+
215
+ // Warn on 10K char limit
216
+ const ruleType = detectRuleType(frontmatter);
217
+
218
+ return { valid: errors.length === 0, errors, ruleType };
219
+ }
220
+
221
+ // ─── MCP config validation ──────────────────────────────────────────────────
222
+
223
+ /**
224
+ * Count total MCP tools across all servers.
225
+ * Windsurf has team-level MCP whitelisting.
226
+ */
227
+ function countMcpTools(mcpData) {
228
+ if (!mcpData || !mcpData.mcpServers) return 0;
229
+
230
+ let total = 0;
231
+ for (const server of Object.values(mcpData.mcpServers)) {
232
+ // Each server exposes tools; estimate ~5 per server if no explicit count
233
+ const toolCount = server.tools ? Object.keys(server.tools).length : 5;
234
+ total += toolCount;
235
+ }
236
+ return total;
237
+ }
238
+
239
+ /**
240
+ * Validate MCP env vars use proper syntax (not hardcoded secrets).
241
+ */
242
+ function validateMcpEnvVars(mcpData) {
243
+ if (!mcpData || !mcpData.mcpServers) return { valid: true, hardcodedVars: [] };
244
+
245
+ const hardcodedVars = [];
246
+ for (const [serverName, config] of Object.entries(mcpData.mcpServers)) {
247
+ if (!config.env) continue;
248
+ for (const [key, value] of Object.entries(config.env)) {
249
+ if (typeof value === 'string' && !value.startsWith('${env:') && /key|token|secret|password|api/i.test(key)) {
250
+ hardcodedVars.push({ server: serverName, key, value: '[REDACTED]' });
251
+ }
252
+ }
253
+ }
254
+
255
+ return { valid: hardcodedVars.length === 0, hardcodedVars };
256
+ }
257
+
258
+ module.exports = {
259
+ tryParseJson,
260
+ parseWindsurfRule,
261
+ parseSimpleYaml,
262
+ detectRuleType,
263
+ getValueByPath,
264
+ validateWindsurfFrontmatter,
265
+ countMcpTools,
266
+ validateMcpEnvVars,
267
+ };
@@ -0,0 +1,249 @@
1
+ /**
2
+ * Windsurf project context.
3
+ *
4
+ * Extends the shared ProjectContext with Windsurf-specific file lookups:
5
+ * - .windsurf/rules/*.md (Markdown + YAML frontmatter, NOT MDC)
6
+ * - .windsurfrules (legacy, flat file)
7
+ * - .windsurf/mcp.json (MCP server config with team whitelist)
8
+ * - .windsurf/workflows/*.md (slash commands / workflows)
9
+ * - .windsurf/memories/ (team-syncable memories)
10
+ * - .cascadeignore (gitignore-like for Cascade agent)
11
+ */
12
+
13
+ const fs = require('fs');
14
+ const os = require('os');
15
+ const path = require('path');
16
+ const { ProjectContext } = require('../context');
17
+ const { tryParseJson, parseWindsurfRule, detectRuleType, getValueByPath } = require('./config-parser');
18
+
19
+ function listFiles(fullPath, filter) {
20
+ try {
21
+ const entries = fs.readdirSync(fullPath).filter(f => !f.startsWith('.'));
22
+ return filter ? entries.filter(filter) : entries;
23
+ } catch {
24
+ return [];
25
+ }
26
+ }
27
+
28
+ class WindsurfProjectContext extends ProjectContext {
29
+
30
+ // ─── Rules (.windsurf/rules/*.md) ──────────────────────────────────────
31
+
32
+ /**
33
+ * List all .md rule files in .windsurf/rules/.
34
+ * Returns array of { name, path, frontmatter, body, ruleType }.
35
+ *
36
+ * Windsurf uses Markdown + YAML frontmatter (NOT MDC like Cursor).
37
+ * 4 activation modes: Always, Auto, Agent-Requested, Manual.
38
+ * 10K char limit per rule file.
39
+ */
40
+ windsurfRules() {
41
+ const dir = path.join(this.dir, '.windsurf', 'rules');
42
+ const files = listFiles(dir, f => f.endsWith('.md'));
43
+ return files.map(f => {
44
+ const relPath = `.windsurf/rules/${f}`;
45
+ const content = this.fileContent(relPath);
46
+ if (!content) return null;
47
+ const parsed = parseWindsurfRule(content);
48
+ const ruleType = detectRuleType(parsed.frontmatter);
49
+ return {
50
+ name: f.replace('.md', ''),
51
+ path: relPath,
52
+ frontmatter: parsed.frontmatter,
53
+ body: parsed.body,
54
+ ruleType,
55
+ charCount: (content || '').length,
56
+ overLimit: (content || '').length > 10000,
57
+ };
58
+ }).filter(Boolean);
59
+ }
60
+
61
+ /**
62
+ * Get rules filtered by type.
63
+ */
64
+ alwaysRules() {
65
+ return this.windsurfRules().filter(r => r.ruleType === 'always');
66
+ }
67
+
68
+ autoRules() {
69
+ return this.windsurfRules().filter(r => r.ruleType === 'auto');
70
+ }
71
+
72
+ agentRequestedRules() {
73
+ return this.windsurfRules().filter(r => r.ruleType === 'agent-requested');
74
+ }
75
+
76
+ manualRules() {
77
+ return this.windsurfRules().filter(r => r.ruleType === 'manual');
78
+ }
79
+
80
+ // ─── Legacy .windsurfrules ────────────────────────────────────────────
81
+
82
+ /**
83
+ * .windsurfrules content (deprecated).
84
+ */
85
+ legacyWindsurfrules() {
86
+ return this.fileContent('.windsurfrules');
87
+ }
88
+
89
+ hasLegacyRules() {
90
+ return Boolean(this.legacyWindsurfrules());
91
+ }
92
+
93
+ // ─── MCP config (.windsurf/mcp.json) ──────────────────────────────────
94
+
95
+ /**
96
+ * .windsurf/mcp.json parsed.
97
+ * Windsurf MCP format: { mcpServers: { name: { command, args, env } } }
98
+ * Supports team-level whitelist.
99
+ */
100
+ mcpConfig() {
101
+ const content = this.fileContent('.windsurf/mcp.json');
102
+ if (!content) {
103
+ return { ok: false, data: null, error: 'missing .windsurf/mcp.json', source: '.windsurf/mcp.json' };
104
+ }
105
+ const parsed = tryParseJson(content);
106
+ return { ...parsed, source: '.windsurf/mcp.json' };
107
+ }
108
+
109
+ /**
110
+ * Global MCP config (~/.windsurf/mcp.json).
111
+ */
112
+ globalMcpConfig() {
113
+ const homeDir = os.homedir();
114
+ const globalPath = path.join(homeDir, '.windsurf', 'mcp.json');
115
+ try {
116
+ const content = fs.readFileSync(globalPath, 'utf8');
117
+ const parsed = tryParseJson(content);
118
+ return { ...parsed, source: globalPath };
119
+ } catch {
120
+ return { ok: false, data: null, error: 'missing global mcp.json', source: globalPath };
121
+ }
122
+ }
123
+
124
+ /**
125
+ * MCP servers from .windsurf/mcp.json.
126
+ */
127
+ mcpServers() {
128
+ const result = this.mcpConfig();
129
+ if (!result.ok || !result.data) return {};
130
+ return result.data.mcpServers || {};
131
+ }
132
+
133
+ /**
134
+ * Count total MCP tools across all servers.
135
+ */
136
+ totalMcpTools() {
137
+ const servers = this.mcpServers();
138
+ let total = 0;
139
+ for (const server of Object.values(servers)) {
140
+ const toolCount = server.tools ? Object.keys(server.tools).length : 5;
141
+ total += toolCount;
142
+ }
143
+ return total;
144
+ }
145
+
146
+ // ─── Workflows (.windsurf/workflows/*.md) ─────────────────────────────
147
+
148
+ /**
149
+ * Workflow files (slash commands).
150
+ * Windsurf workflows are Markdown files that define slash commands.
151
+ */
152
+ workflowFiles() {
153
+ const dir = path.join(this.dir, '.windsurf', 'workflows');
154
+ return listFiles(dir, f => f.endsWith('.md'))
155
+ .map(f => `.windsurf/workflows/${f}`);
156
+ }
157
+
158
+ // ─── Memories (.windsurf/memories/) ───────────────────────────────────
159
+
160
+ /**
161
+ * Memory files (team-syncable persistent context).
162
+ */
163
+ memoryFiles() {
164
+ const dir = path.join(this.dir, '.windsurf', 'memories');
165
+ return listFiles(dir, f => f.endsWith('.md') || f.endsWith('.json'));
166
+ }
167
+
168
+ memoryContents() {
169
+ const dir = path.join(this.dir, '.windsurf', 'memories');
170
+ const files = this.memoryFiles();
171
+ return files.map(f => {
172
+ const relPath = `.windsurf/memories/${f}`;
173
+ const content = this.fileContent(relPath);
174
+ return { name: f, path: relPath, content };
175
+ }).filter(item => item.content);
176
+ }
177
+
178
+ // ─── Cascadeignore (.cascadeignore) ───────────────────────────────────
179
+
180
+ /**
181
+ * .cascadeignore content (gitignore-like for Cascade agent).
182
+ */
183
+ cascadeignoreContent() {
184
+ return this.fileContent('.cascadeignore');
185
+ }
186
+
187
+ hasCascadeignore() {
188
+ return Boolean(this.cascadeignoreContent());
189
+ }
190
+
191
+ // ─── VS Code compat (.vscode/settings.json) ──────────────────────────
192
+
193
+ vscodeSettings() {
194
+ const content = this.fileContent('.vscode/settings.json');
195
+ if (!content) {
196
+ return { ok: false, data: null, error: 'missing .vscode/settings.json', source: '.vscode/settings.json' };
197
+ }
198
+ const parsed = tryParseJson(content);
199
+ return { ...parsed, source: '.vscode/settings.json' };
200
+ }
201
+
202
+ // ─── CI Workflow files ────────────────────────────────────────────────
203
+
204
+ ciWorkflowFiles() {
205
+ const dir = path.join(this.dir, '.github', 'workflows');
206
+ return listFiles(dir, f => f.endsWith('.yml') || f.endsWith('.yaml'))
207
+ .map(f => `.github/workflows/${f}`);
208
+ }
209
+
210
+ // ─── Surface detection ────────────────────────────────────────────────
211
+
212
+ /**
213
+ * Detect which Windsurf surfaces are configured.
214
+ * Windsurf has NO background agents (unlike Cursor).
215
+ */
216
+ detectSurfaces() {
217
+ const foreground = Boolean(
218
+ this.windsurfRules().length > 0 ||
219
+ this.legacyWindsurfrules() ||
220
+ this.mcpConfig().ok
221
+ );
222
+ const workflows = this.workflowFiles().length > 0;
223
+ const memories = this.memoryFiles().length > 0;
224
+ const cascadeignore = this.hasCascadeignore();
225
+
226
+ return { foreground, workflows, memories, cascadeignore };
227
+ }
228
+
229
+ // ─── Static detection ─────────────────────────────────────────────────
230
+
231
+ static isWindsurfRepo(dir) {
232
+ try {
233
+ return fs.existsSync(path.join(dir, '.windsurf')) ||
234
+ fs.existsSync(path.join(dir, '.windsurfrules'));
235
+ } catch {
236
+ return false;
237
+ }
238
+ }
239
+
240
+ // ─── Stack detection (reuse shared) ───────────────────────────────────
241
+
242
+ detectStacks(STACKS) {
243
+ return super.detectStacks(STACKS);
244
+ }
245
+ }
246
+
247
+ module.exports = {
248
+ WindsurfProjectContext,
249
+ };