@nerviq/cli 0.9.3 → 0.9.4

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/src/migrate.js ADDED
@@ -0,0 +1,354 @@
1
+ /**
2
+ * Nerviq Migrate
3
+ *
4
+ * Helps migrate configuration files from one version/format of a platform
5
+ * to a newer version, applying safe in-place transformations.
6
+ *
7
+ * Supports:
8
+ * cursor v2 → v3 (legacy .cursorrules → .cursor/rules/*.mdc)
9
+ * codex v1 → v2 (AGENTS.md additions, .codex/ bootstrap)
10
+ * aider v0 → v1 (basic .aider.conf.yml creation from CLI pattern)
11
+ * gemini v1 → v2 (.gemini/ settings.json schema update)
12
+ */
13
+
14
+ 'use strict';
15
+
16
+ const fs = require('fs');
17
+ const path = require('path');
18
+
19
+ const COLORS = {
20
+ reset: '\x1b[0m',
21
+ bold: '\x1b[1m',
22
+ dim: '\x1b[2m',
23
+ red: '\x1b[31m',
24
+ green: '\x1b[32m',
25
+ yellow: '\x1b[33m',
26
+ blue: '\x1b[36m',
27
+ };
28
+
29
+ function c(text, color) {
30
+ return `${COLORS[color] || ''}${text}${COLORS.reset}`;
31
+ }
32
+
33
+ // ─── Migration definitions ───────────────────────────────────────────────────
34
+
35
+ const MIGRATIONS = {
36
+ cursor: {
37
+ 'v2→v3': {
38
+ description: 'Migrate legacy .cursorrules to .cursor/rules/*.mdc with proper frontmatter',
39
+ from: 'v2',
40
+ to: 'v3',
41
+ detect: (dir) => {
42
+ const hasLegacy = fs.existsSync(path.join(dir, '.cursorrules'));
43
+ const hasMdc = fs.existsSync(path.join(dir, '.cursor', 'rules'));
44
+ return { applicable: hasLegacy, notes: hasLegacy ? (hasMdc ? 'Legacy .cursorrules present alongside .cursor/rules/ (coexistence)' : 'Legacy .cursorrules present, no .cursor/rules/ yet') : 'No legacy .cursorrules found' };
45
+ },
46
+ apply: (dir, { dryRun = false } = {}) => {
47
+ const legacyPath = path.join(dir, '.cursorrules');
48
+ if (!fs.existsSync(legacyPath)) return { changes: [], warnings: ['No .cursorrules found'] };
49
+
50
+ const content = fs.readFileSync(legacyPath, 'utf8').trim();
51
+ const targetDir = path.join(dir, '.cursor', 'rules');
52
+ const targetFile = path.join(targetDir, 'core.mdc');
53
+
54
+ const mdcContent = [
55
+ '---',
56
+ 'alwaysApply: true',
57
+ '---',
58
+ '',
59
+ content,
60
+ '',
61
+ ].join('\n');
62
+
63
+ const changes = [];
64
+ const warnings = [];
65
+
66
+ if (fs.existsSync(targetFile)) {
67
+ warnings.push('.cursor/rules/core.mdc already exists — skipped to avoid overwrite');
68
+ } else {
69
+ if (!dryRun) {
70
+ fs.mkdirSync(targetDir, { recursive: true });
71
+ fs.writeFileSync(targetFile, mdcContent, 'utf8');
72
+ }
73
+ changes.push({ action: dryRun ? 'would-create' : 'created', file: '.cursor/rules/core.mdc', detail: 'Converted from .cursorrules with alwaysApply: true' });
74
+ }
75
+
76
+ // Optionally rename .cursorrules → .cursorrules.migrated
77
+ const migratedPath = path.join(dir, '.cursorrules.migrated');
78
+ if (!fs.existsSync(migratedPath) && !dryRun) {
79
+ fs.renameSync(legacyPath, migratedPath);
80
+ changes.push({ action: 'renamed', file: '.cursorrules → .cursorrules.migrated', detail: 'Preserved as backup' });
81
+ } else if (dryRun) {
82
+ changes.push({ action: 'would-rename', file: '.cursorrules → .cursorrules.migrated', detail: 'Backup rename' });
83
+ }
84
+
85
+ return { changes, warnings };
86
+ },
87
+ },
88
+ },
89
+
90
+ codex: {
91
+ 'v1→v2': {
92
+ description: 'Bootstrap .codex/ directory with config.toml and update AGENTS.md',
93
+ from: 'v1',
94
+ to: 'v2',
95
+ detect: (dir) => {
96
+ const hasAgents = fs.existsSync(path.join(dir, 'AGENTS.md'));
97
+ const hasCodexDir = fs.existsSync(path.join(dir, '.codex'));
98
+ return {
99
+ applicable: hasAgents && !hasCodexDir,
100
+ notes: !hasAgents
101
+ ? 'No AGENTS.md found'
102
+ : hasCodexDir
103
+ ? '.codex/ already exists'
104
+ : 'AGENTS.md found, .codex/ missing — upgrade applicable',
105
+ };
106
+ },
107
+ apply: (dir, { dryRun = false } = {}) => {
108
+ const changes = [];
109
+ const warnings = [];
110
+ const codexDir = path.join(dir, '.codex');
111
+
112
+ if (!fs.existsSync(codexDir)) {
113
+ const configToml = [
114
+ '# Codex configuration — generated by nerviq migrate',
115
+ '[agent]',
116
+ 'auto_approve = false',
117
+ '',
118
+ '[context]',
119
+ 'files = ["AGENTS.md"]',
120
+ '',
121
+ ].join('\n');
122
+
123
+ if (!dryRun) {
124
+ fs.mkdirSync(codexDir, { recursive: true });
125
+ fs.writeFileSync(path.join(codexDir, 'config.toml'), configToml, 'utf8');
126
+ }
127
+ changes.push({ action: dryRun ? 'would-create' : 'created', file: '.codex/config.toml', detail: 'Codex config with safe defaults' });
128
+ } else {
129
+ warnings.push('.codex/ already exists');
130
+ }
131
+
132
+ return { changes, warnings };
133
+ },
134
+ },
135
+ },
136
+
137
+ aider: {
138
+ 'v0→v1': {
139
+ description: 'Create .aider.conf.yml if missing and add .aider* to .gitignore',
140
+ from: 'v0',
141
+ to: 'v1',
142
+ detect: (dir) => {
143
+ const hasConf = fs.existsSync(path.join(dir, '.aider.conf.yml'));
144
+ return {
145
+ applicable: !hasConf,
146
+ notes: hasConf ? '.aider.conf.yml already exists' : 'No .aider.conf.yml found — migration applicable',
147
+ };
148
+ },
149
+ apply: (dir, { dryRun = false } = {}) => {
150
+ const changes = [];
151
+ const warnings = [];
152
+
153
+ const confPath = path.join(dir, '.aider.conf.yml');
154
+ if (!fs.existsSync(confPath)) {
155
+ const conf = [
156
+ '# Aider configuration — generated by nerviq migrate',
157
+ 'auto-commits: true',
158
+ 'auto-lint: false',
159
+ 'auto-test: false',
160
+ '# model: gpt-4o',
161
+ '# weak-model: gpt-4o-mini',
162
+ '# edit-format: diff',
163
+ ].join('\n') + '\n';
164
+ if (!dryRun) fs.writeFileSync(confPath, conf, 'utf8');
165
+ changes.push({ action: dryRun ? 'would-create' : 'created', file: '.aider.conf.yml', detail: 'Safe defaults with auto-commits enabled' });
166
+ }
167
+
168
+ const gitignorePath = path.join(dir, '.gitignore');
169
+ if (fs.existsSync(gitignorePath)) {
170
+ const gi = fs.readFileSync(gitignorePath, 'utf8');
171
+ if (!/\.aider/i.test(gi)) {
172
+ if (!dryRun) fs.appendFileSync(gitignorePath, '\n# Aider artifacts\n.aider*\n');
173
+ changes.push({ action: dryRun ? 'would-append' : 'appended', file: '.gitignore', detail: 'Added .aider* pattern' });
174
+ } else {
175
+ warnings.push('.gitignore already has .aider* pattern');
176
+ }
177
+ }
178
+
179
+ return { changes, warnings };
180
+ },
181
+ },
182
+ },
183
+
184
+ gemini: {
185
+ 'v1→v2': {
186
+ description: 'Update .gemini/settings.json schema (model field: string → object)',
187
+ from: 'v1',
188
+ to: 'v2',
189
+ detect: (dir) => {
190
+ const settingsPath = path.join(dir, '.gemini', 'settings.json');
191
+ if (!fs.existsSync(settingsPath)) {
192
+ return { applicable: false, notes: 'No .gemini/settings.json found' };
193
+ }
194
+ try {
195
+ const settings = JSON.parse(fs.readFileSync(settingsPath, 'utf8'));
196
+ const needsMigration = typeof settings.model === 'string';
197
+ return {
198
+ applicable: needsMigration,
199
+ notes: needsMigration
200
+ ? `model field is a string "${settings.model}" — needs to be an object`
201
+ : 'model field already uses object format',
202
+ };
203
+ } catch {
204
+ return { applicable: false, notes: 'settings.json is invalid JSON' };
205
+ }
206
+ },
207
+ apply: (dir, { dryRun = false } = {}) => {
208
+ const changes = [];
209
+ const warnings = [];
210
+ const settingsPath = path.join(dir, '.gemini', 'settings.json');
211
+
212
+ if (!fs.existsSync(settingsPath)) {
213
+ warnings.push('.gemini/settings.json not found');
214
+ return { changes, warnings };
215
+ }
216
+
217
+ let settings;
218
+ try {
219
+ settings = JSON.parse(fs.readFileSync(settingsPath, 'utf8'));
220
+ } catch {
221
+ warnings.push('settings.json is invalid JSON — skipped');
222
+ return { changes, warnings };
223
+ }
224
+
225
+ if (typeof settings.model === 'string') {
226
+ const oldModel = settings.model;
227
+ settings.model = { name: oldModel };
228
+ if (!dryRun) fs.writeFileSync(settingsPath, JSON.stringify(settings, null, 2) + '\n', 'utf8');
229
+ changes.push({
230
+ action: dryRun ? 'would-update' : 'updated',
231
+ file: '.gemini/settings.json',
232
+ detail: `model: "${oldModel}" → { name: "${oldModel}" }`,
233
+ });
234
+ } else {
235
+ warnings.push('model field already in correct format');
236
+ }
237
+
238
+ return { changes, warnings };
239
+ },
240
+ },
241
+ },
242
+ };
243
+
244
+ // ─── Main migrate function ────────────────────────────────────────────────────
245
+
246
+ async function runMigrate({ dir = process.cwd(), platform, from: fromVersion, to: toVersion, dryRun = false, json = false } = {}) {
247
+ if (!platform) throw new Error('--platform is required. Example: nerviq migrate --platform cursor --from v2 --to v3');
248
+
249
+ const platformMigrations = MIGRATIONS[platform];
250
+ if (!platformMigrations) {
251
+ throw new Error(`No migrations available for platform '${platform}'. Supported: ${Object.keys(MIGRATIONS).join(', ')}`);
252
+ }
253
+
254
+ // Determine migration key
255
+ let migrationKey = null;
256
+ if (fromVersion && toVersion) {
257
+ migrationKey = `${fromVersion}→${toVersion}`;
258
+ } else {
259
+ // Auto-detect applicable migration
260
+ for (const [key, migration] of Object.entries(platformMigrations)) {
261
+ const detection = migration.detect(dir);
262
+ if (detection.applicable) {
263
+ migrationKey = key;
264
+ break;
265
+ }
266
+ }
267
+ }
268
+
269
+ if (!migrationKey) {
270
+ // Show available migrations
271
+ const availableKeys = Object.keys(platformMigrations);
272
+ const detectionResults = availableKeys.map(key => {
273
+ const detection = platformMigrations[key].detect(dir);
274
+ return { key, ...detection };
275
+ });
276
+
277
+ if (json) {
278
+ return JSON.stringify({ platform, status: 'no-migration-applicable', detectionResults }, null, 2);
279
+ }
280
+
281
+ const lines = [''];
282
+ lines.push(c(` nerviq migrate — ${platform}`, 'bold'));
283
+ lines.push('');
284
+ lines.push(c(' No applicable migration found.', 'yellow'));
285
+ lines.push('');
286
+ lines.push(' Available migrations:');
287
+ for (const r of detectionResults) {
288
+ const icon = r.applicable ? c('✓', 'green') : c('-', 'dim');
289
+ lines.push(` ${icon} ${r.key.padEnd(10)} ${r.notes}`);
290
+ }
291
+ lines.push('');
292
+ return lines.join('\n');
293
+ }
294
+
295
+ const migration = platformMigrations[migrationKey];
296
+ if (!migration) {
297
+ throw new Error(`Migration '${migrationKey}' not found for platform '${platform}'`);
298
+ }
299
+
300
+ const detection = migration.detect(dir);
301
+ const { changes, warnings } = migration.apply(dir, { dryRun });
302
+
303
+ const result = {
304
+ platform,
305
+ migration: migrationKey,
306
+ description: migration.description,
307
+ dryRun,
308
+ applicable: detection.applicable,
309
+ detectionNotes: detection.notes,
310
+ changes,
311
+ warnings,
312
+ };
313
+
314
+ if (json) return JSON.stringify(result, null, 2);
315
+
316
+ const lines = [''];
317
+ lines.push(c(` nerviq migrate ${platform} ${migrationKey}`, 'bold'));
318
+ lines.push(c(' ═══════════════════════════════════════', 'dim'));
319
+ lines.push('');
320
+ lines.push(` ${migration.description}`);
321
+ lines.push(` Directory: ${dir}`);
322
+ lines.push('');
323
+
324
+ if (dryRun) lines.push(c(' Dry run — no files modified', 'yellow'));
325
+
326
+ if (changes.length > 0) {
327
+ lines.push(' Changes:');
328
+ for (const ch of changes) {
329
+ const icon = ch.action.startsWith('would') ? c('→', 'blue') : c('✓', 'green');
330
+ lines.push(` ${icon} [${ch.action}] ${ch.file}`);
331
+ if (ch.detail) lines.push(c(` ${ch.detail}`, 'dim'));
332
+ }
333
+ } else {
334
+ lines.push(c(' No changes made.', 'dim'));
335
+ }
336
+
337
+ if (warnings.length > 0) {
338
+ lines.push('');
339
+ lines.push(' Warnings:');
340
+ for (const w of warnings) lines.push(` ${c('⚠', 'yellow')} ${w}`);
341
+ }
342
+
343
+ lines.push('');
344
+ if (!dryRun && changes.length > 0) {
345
+ lines.push(c(` ✓ Migration complete. Run \`nerviq audit --platform ${platform}\` to verify.`, 'green'));
346
+ } else if (dryRun) {
347
+ lines.push(c(' Run without --dry-run to apply changes.', 'dim'));
348
+ }
349
+ lines.push('');
350
+
351
+ return lines.join('\n');
352
+ }
353
+
354
+ module.exports = { runMigrate, MIGRATIONS };
@@ -23,6 +23,7 @@
23
23
  const os = require('os');
24
24
  const path = require('path');
25
25
  const { EMBEDDED_SECRET_PATTERNS, containsEmbeddedSecret } = require('../secret-patterns');
26
+ const { attachSourceUrls } = require('../source-urls');
26
27
 
27
28
  const DEFAULT_PROJECT_DOC_MAX_BYTES = 32768;
28
29
 
@@ -1679,6 +1680,8 @@ const OPENCODE_TECHNIQUES = {
1679
1680
  },
1680
1681
  };
1681
1682
 
1683
+ attachSourceUrls('opencode', OPENCODE_TECHNIQUES);
1684
+
1682
1685
  module.exports = {
1683
1686
  OPENCODE_TECHNIQUES,
1684
1687
  };
@@ -0,0 +1,219 @@
1
+ /**
2
+ * Official source URL registry for platform technique catalogs.
3
+ *
4
+ * These URLs intentionally point to the nearest authoritative official page for
5
+ * a given category or check. Some advisory/internal heuristics do not have a
6
+ * single line-item normative doc, so they fall back to the closest official
7
+ * platform page that governs the surrounding feature area.
8
+ */
9
+
10
+ const SOURCE_URLS = {
11
+ claude: {
12
+ defaultUrl: 'https://code.claude.com/docs/en/overview',
13
+ byCategory: {
14
+ memory: 'https://code.claude.com/docs/en/memory',
15
+ quality: 'https://code.claude.com/docs/en/common-workflows',
16
+ git: 'https://code.claude.com/docs/en/settings',
17
+ workflow: 'https://code.claude.com/docs/en/common-workflows',
18
+ security: 'https://code.claude.com/docs/en/permissions',
19
+ automation: 'https://code.claude.com/docs/en/hooks',
20
+ design: 'https://code.claude.com/docs/en/best-practices',
21
+ devops: 'https://code.claude.com/docs/en/common-workflows',
22
+ hygiene: 'https://code.claude.com/docs/en/overview',
23
+ performance: 'https://code.claude.com/docs/en/memory',
24
+ tools: 'https://code.claude.com/docs/en/mcp',
25
+ prompting: 'https://code.claude.com/docs/en/best-practices',
26
+ features: 'https://code.claude.com/docs/en/commands',
27
+ 'quality-deep': 'https://code.claude.com/docs/en/best-practices',
28
+ },
29
+ byKey: {
30
+ customCommands: 'https://code.claude.com/docs/en/commands',
31
+ multipleCommands: 'https://code.claude.com/docs/en/commands',
32
+ deployCommand: 'https://code.claude.com/docs/en/commands',
33
+ reviewCommand: 'https://code.claude.com/docs/en/commands',
34
+ agents: 'https://code.claude.com/docs/en/sub-agents',
35
+ multipleAgents: 'https://code.claude.com/docs/en/sub-agents',
36
+ agentsHaveMaxTurns: 'https://code.claude.com/docs/en/sub-agents',
37
+ agentHasAllowedTools: 'https://code.claude.com/docs/en/sub-agents',
38
+ skills: 'https://code.claude.com/docs/en/skills',
39
+ multipleSkills: 'https://code.claude.com/docs/en/skills',
40
+ skillUsesPaths: 'https://code.claude.com/docs/en/skills',
41
+ frontendDesignSkill: 'https://code.claude.com/docs/en/skills',
42
+ },
43
+ },
44
+ codex: {
45
+ defaultUrl: 'https://developers.openai.com/codex/cli',
46
+ byCategory: {
47
+ instructions: 'https://developers.openai.com/codex/guides/agents-md',
48
+ config: 'https://developers.openai.com/codex/config-reference',
49
+ trust: 'https://developers.openai.com/codex/agent-approvals-security',
50
+ rules: 'https://developers.openai.com/codex/rules',
51
+ hooks: 'https://developers.openai.com/codex/hooks',
52
+ mcp: 'https://developers.openai.com/codex/mcp',
53
+ skills: 'https://developers.openai.com/codex/skills',
54
+ agents: 'https://developers.openai.com/codex/subagents',
55
+ automation: 'https://developers.openai.com/codex/cli',
56
+ review: 'https://developers.openai.com/codex/cli',
57
+ local: 'https://developers.openai.com/codex/app/local-environments',
58
+ 'quality-deep': 'https://developers.openai.com/codex/feature-maturity',
59
+ advisory: 'https://developers.openai.com/codex/cli',
60
+ 'pack-posture': 'https://developers.openai.com/codex/mcp',
61
+ 'repeat-usage': 'https://developers.openai.com/codex/cli',
62
+ 'release-freshness': 'https://developers.openai.com/codex/changelog',
63
+ },
64
+ byKey: {
65
+ codexAutomationManuallyTested: 'https://developers.openai.com/codex/app/automations',
66
+ codexAutomationAppPrereqAcknowledged: 'https://developers.openai.com/codex/app/automations',
67
+ codexGitHubActionSafeStrategy: 'https://developers.openai.com/codex/github-action',
68
+ codexGitHubActionPromptSourceExclusive: 'https://developers.openai.com/codex/github-action',
69
+ codexGitHubActionTriggerAllowlistsExplicit: 'https://developers.openai.com/codex/github-action',
70
+ codexCiAuthUsesManagedKey: 'https://developers.openai.com/codex/github-action',
71
+ codexPluginConfigValid: 'https://developers.openai.com/codex/skills',
72
+ codexUndoExplicit: 'https://developers.openai.com/codex/config-reference',
73
+ codexWorktreeLifecycleDocumented: 'https://developers.openai.com/codex/app/local-environments',
74
+ },
75
+ },
76
+ gemini: {
77
+ defaultUrl: 'https://geminicli.com/docs/get-started/',
78
+ byCategory: {
79
+ instructions: 'https://geminicli.com/docs/cli/gemini-md/',
80
+ config: 'https://geminicli.com/docs/reference/configuration/',
81
+ trust: 'https://geminicli.com/docs/cli/trusted-folders/',
82
+ hooks: 'https://geminicli.com/docs/hooks/reference/',
83
+ mcp: 'https://geminicli.com/docs/tools/mcp-server/',
84
+ sandbox: 'https://geminicli.com/docs/cli/sandbox/',
85
+ agents: 'https://geminicli.com/docs/core/subagents/',
86
+ skills: 'https://geminicli.com/docs/cli/skills/',
87
+ automation: 'https://google-gemini.github.io/gemini-cli/docs/cli/headless.html',
88
+ extensions: 'https://geminicli.com/docs/extensions/',
89
+ review: 'https://ai.google.dev/gemini-api/docs/coding-agents',
90
+ 'quality-deep': 'https://geminicli.com/docs/get-started/',
91
+ commands: 'https://geminicli.com/docs/cli/custom-commands/',
92
+ advisory: 'https://geminicli.com/docs/get-started/',
93
+ 'pack-posture': 'https://geminicli.com/docs/tools/mcp-server/',
94
+ 'repeat-usage': 'https://geminicli.com/docs/cli/session-management/',
95
+ 'release-freshness': 'https://geminicli.com/docs/changelogs/latest/',
96
+ },
97
+ },
98
+ copilot: {
99
+ defaultUrl: 'https://docs.github.com/copilot',
100
+ byCategory: {
101
+ instructions: 'https://docs.github.com/copilot/customizing-copilot/adding-custom-instructions-for-github-copilot',
102
+ config: 'https://code.visualstudio.com/docs/copilot/customization/custom-instructions',
103
+ trust: 'https://code.visualstudio.com/docs/copilot/security',
104
+ mcp: 'https://code.visualstudio.com/docs/copilot/chat/mcp-servers',
105
+ 'cloud-agent': 'https://docs.github.com/en/copilot/concepts/agents/coding-agent/about-coding-agent',
106
+ organization: 'https://docs.github.com/en/copilot/how-tos/administer-copilot/manage-for-organization/manage-policies',
107
+ 'prompt-files': 'https://code.visualstudio.com/docs/copilot/customization/prompt-files',
108
+ 'skills-agents': 'https://code.visualstudio.com/docs/copilot/agents/overview',
109
+ 'ci-automation': 'https://docs.github.com/en/copilot/how-tos/use-copilot-agents/coding-agent/customize-the-agent-environment',
110
+ enterprise: 'https://docs.github.com/en/copilot/how-tos/administer-copilot/manage-for-enterprise',
111
+ extensions: 'https://docs.github.com/en/copilot/building-copilot-extensions/about-building-copilot-extensions',
112
+ 'quality-deep': 'https://docs.github.com/copilot',
113
+ advisory: 'https://docs.github.com/copilot',
114
+ freshness: 'https://github.blog/changelog/',
115
+ },
116
+ },
117
+ cursor: {
118
+ defaultUrl: 'https://cursor.com/docs',
119
+ byCategory: {
120
+ rules: 'https://cursor.com/docs/context/rules',
121
+ config: 'https://cursor.com/docs',
122
+ trust: 'https://cursor.com/docs/enterprise/privacy-and-data-governance',
123
+ 'agent-mode': 'https://docs.cursor.com/en/chat/agent',
124
+ mcp: 'https://cursor.com/docs/cli/mcp',
125
+ 'instructions-quality': 'https://docs.cursor.com/guides/working-with-context',
126
+ 'background-agents': 'https://docs.cursor.com/en/background-agents',
127
+ automations: 'https://cursor.com/docs/cloud-agent/automations',
128
+ enterprise: 'https://cursor.com/docs/enterprise',
129
+ bugbot: 'https://cursor.com/docs/bugbot',
130
+ 'cross-surface': 'https://cursor.com/docs',
131
+ 'quality-deep': 'https://docs.cursor.com/guides/working-with-context',
132
+ advisory: 'https://cursor.com/docs',
133
+ freshness: 'https://cursor.com/changelog',
134
+ },
135
+ },
136
+ windsurf: {
137
+ defaultUrl: 'https://docs.windsurf.com/windsurf/cascade',
138
+ byCategory: {
139
+ rules: 'https://windsurf.com/university/general-education/intro-rules-memories',
140
+ config: 'https://docs.windsurf.com/windsurf/cascade/cascade',
141
+ trust: 'https://windsurf.com/security',
142
+ 'cascade-agent': 'https://docs.windsurf.com/windsurf/cascade/agents-md',
143
+ mcp: 'https://docs.windsurf.com/windsurf/cascade/mcp',
144
+ 'instructions-quality': 'https://docs.windsurf.com/windsurf/cascade/agents-md',
145
+ workflows: 'https://docs.windsurf.com/windsurf/cascade/workflows',
146
+ memories: 'https://docs.windsurf.com/windsurf/cascade/memories',
147
+ enterprise: 'https://windsurf.com/security',
148
+ cascadeignore: 'https://docs.windsurf.com/windsurf/cascade/cascade',
149
+ 'cross-surface': 'https://docs.windsurf.com/windsurf/cascade/cascade',
150
+ 'quality-deep': 'https://docs.windsurf.com/windsurf/cascade/cascade',
151
+ advisory: 'https://docs.windsurf.com/windsurf/cascade/cascade',
152
+ freshness: 'https://windsurf.com/changelog',
153
+ },
154
+ },
155
+ aider: {
156
+ defaultUrl: 'https://aider.chat/docs/',
157
+ byCategory: {
158
+ config: 'https://aider.chat/docs/config.html',
159
+ 'advanced-config': 'https://aider.chat/docs/config/aider_conf.html',
160
+ 'git-safety': 'https://aider.chat/docs/git.html',
161
+ 'model-config': 'https://aider.chat/docs/config/adv-model-settings.html',
162
+ conventions: 'https://aider.chat/docs/usage/conventions.html',
163
+ architecture: 'https://aider.chat/docs/usage/modes.html',
164
+ security: 'https://aider.chat/docs/config/dotenv.html',
165
+ ci: 'https://aider.chat/docs/scripting.html',
166
+ quality: 'https://aider.chat/docs/usage/lint-test.html',
167
+ 'workflow-patterns': 'https://aider.chat/docs/usage/modes.html',
168
+ 'editor-integration': 'https://aider.chat/docs/config/editor.html',
169
+ 'release-readiness': 'https://aider.chat/docs/',
170
+ },
171
+ },
172
+ opencode: {
173
+ defaultUrl: 'https://opencode.ai/docs/',
174
+ byCategory: {
175
+ instructions: 'https://opencode.ai/docs/rules/',
176
+ config: 'https://opencode.ai/docs/config/',
177
+ permissions: 'https://opencode.ai/docs/permissions',
178
+ plugins: 'https://opencode.ai/docs/plugins/',
179
+ security: 'https://opencode.ai/docs/tools/',
180
+ mcp: 'https://opencode.ai/docs/mcp-servers/',
181
+ ci: 'https://opencode.ai/docs/github/',
182
+ 'quality-deep': 'https://opencode.ai/docs/',
183
+ skills: 'https://opencode.ai/docs/skills/',
184
+ agents: 'https://opencode.ai/docs/agents/',
185
+ commands: 'https://opencode.ai/docs/commands/',
186
+ tui: 'https://opencode.ai/docs/themes/',
187
+ governance: 'https://opencode.ai/docs/github/',
188
+ 'release-freshness': 'https://opencode.ai/docs/',
189
+ 'mixed-agent': 'https://opencode.ai/docs/modes/',
190
+ propagation: 'https://opencode.ai/docs/config/',
191
+ },
192
+ },
193
+ };
194
+
195
+ function attachSourceUrls(platform, techniques) {
196
+ const mapping = SOURCE_URLS[platform];
197
+ if (!mapping) {
198
+ throw new Error(`Unknown source-url platform '${platform}'`);
199
+ }
200
+
201
+ for (const [key, technique] of Object.entries(techniques)) {
202
+ if (technique.sourceUrl) continue;
203
+ const resolved =
204
+ mapping.byKey?.[key] ||
205
+ mapping.byCategory?.[technique.category] ||
206
+ mapping.defaultUrl;
207
+ if (!resolved) {
208
+ throw new Error(`No sourceUrl mapping found for ${platform}:${key}`);
209
+ }
210
+ technique.sourceUrl = resolved;
211
+ }
212
+
213
+ return techniques;
214
+ }
215
+
216
+ module.exports = {
217
+ SOURCE_URLS,
218
+ attachSourceUrls,
219
+ };
package/src/techniques.js CHANGED
@@ -11,6 +11,7 @@ function hasFrontendSignals(ctx) {
11
11
  }
12
12
 
13
13
  const { containsEmbeddedSecret } = require('./secret-patterns');
14
+ const { attachSourceUrls } = require('./source-urls');
14
15
 
15
16
  const TECHNIQUES = {
16
17
  // ============================================================
@@ -1443,4 +1444,6 @@ const STACKS = {
1443
1444
  dotnet: { files: ['global.json', 'Directory.Build.props'], content: {}, label: '.NET' },
1444
1445
  };
1445
1446
 
1447
+ attachSourceUrls('claude', TECHNIQUES);
1448
+
1446
1449
  module.exports = { TECHNIQUES, STACKS, containsEmbeddedSecret };
@@ -28,6 +28,7 @@ const os = require('os');
28
28
  const path = require('path');
29
29
  const { WindsurfProjectContext } = require('./context');
30
30
  const { EMBEDDED_SECRET_PATTERNS, containsEmbeddedSecret } = require('../secret-patterns');
31
+ const { attachSourceUrls } = require('../source-urls');
31
32
  const { tryParseJson, validateMcpEnvVars } = require('./config-parser');
32
33
 
33
34
  // ─── Shared helpers ─────────────────────────────────────────────────────────
@@ -1826,6 +1827,8 @@ const WINDSURF_TECHNIQUES = {
1826
1827
  },
1827
1828
  };
1828
1829
 
1830
+ attachSourceUrls('windsurf', WINDSURF_TECHNIQUES);
1831
+
1829
1832
  module.exports = {
1830
1833
  WINDSURF_TECHNIQUES,
1831
1834
  };