@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,226 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copilot config parser.
|
|
3
|
+
*
|
|
4
|
+
* Copilot uses JSON for .vscode/settings.json and .vscode/mcp.json,
|
|
5
|
+
* plus YAML frontmatter in *.instructions.md and *.prompt.md files.
|
|
6
|
+
* This module handles both formats with unified value extraction.
|
|
7
|
+
*/
|
|
8
|
+
|
|
9
|
+
// ─── JSON parsing ────────────────────────────────────────────────────────────
|
|
10
|
+
|
|
11
|
+
function tryParseJson(content) {
|
|
12
|
+
try {
|
|
13
|
+
const data = JSON.parse(content);
|
|
14
|
+
return { ok: true, data, error: null };
|
|
15
|
+
} catch (error) {
|
|
16
|
+
return { ok: false, data: null, error: error.message };
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
// ─── YAML frontmatter parsing ────────────────────────────────────────────────
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* Extract YAML frontmatter from a markdown file.
|
|
24
|
+
* Frontmatter is delimited by --- at the start of the file.
|
|
25
|
+
* Returns { frontmatter: object|null, body: string, raw: string|null }
|
|
26
|
+
*/
|
|
27
|
+
function extractFrontmatter(content) {
|
|
28
|
+
if (!content || typeof content !== 'string') {
|
|
29
|
+
return { frontmatter: null, body: content || '', raw: null };
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
const trimmed = content.trimStart();
|
|
33
|
+
if (!trimmed.startsWith('---')) {
|
|
34
|
+
return { frontmatter: null, body: content, raw: null };
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
const endIdx = trimmed.indexOf('---', 3);
|
|
38
|
+
if (endIdx === -1) {
|
|
39
|
+
return { frontmatter: null, body: content, raw: null };
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
const raw = trimmed.slice(3, endIdx).trim();
|
|
43
|
+
const body = trimmed.slice(endIdx + 3).trim();
|
|
44
|
+
const frontmatter = parseSimpleYaml(raw);
|
|
45
|
+
|
|
46
|
+
return { frontmatter, body, raw };
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
/**
|
|
50
|
+
* Minimal YAML parser for frontmatter fields.
|
|
51
|
+
* Handles: key: value, key: [item1, item2], key: "quoted", booleans, numbers.
|
|
52
|
+
* Does NOT handle nested objects or multi-line values (use a full YAML parser for those).
|
|
53
|
+
*/
|
|
54
|
+
function parseSimpleYaml(yamlStr) {
|
|
55
|
+
if (!yamlStr || typeof yamlStr !== 'string') return {};
|
|
56
|
+
|
|
57
|
+
const result = {};
|
|
58
|
+
const lines = yamlStr.split(/\r?\n/);
|
|
59
|
+
|
|
60
|
+
for (const line of lines) {
|
|
61
|
+
const trimmedLine = line.trim();
|
|
62
|
+
if (!trimmedLine || trimmedLine.startsWith('#')) continue;
|
|
63
|
+
|
|
64
|
+
const colonIdx = trimmedLine.indexOf(':');
|
|
65
|
+
if (colonIdx === -1) continue;
|
|
66
|
+
|
|
67
|
+
const key = trimmedLine.slice(0, colonIdx).trim();
|
|
68
|
+
let value = trimmedLine.slice(colonIdx + 1).trim();
|
|
69
|
+
|
|
70
|
+
if (!key) continue;
|
|
71
|
+
|
|
72
|
+
// Parse value
|
|
73
|
+
if (value === '') {
|
|
74
|
+
result[key] = null;
|
|
75
|
+
} else if (value.startsWith('[') && value.endsWith(']')) {
|
|
76
|
+
// Inline array: [item1, item2]
|
|
77
|
+
const inner = value.slice(1, -1).trim();
|
|
78
|
+
if (!inner) {
|
|
79
|
+
result[key] = [];
|
|
80
|
+
} else {
|
|
81
|
+
result[key] = inner.split(',').map(item => {
|
|
82
|
+
const t = item.trim();
|
|
83
|
+
return stripQuotes(t);
|
|
84
|
+
});
|
|
85
|
+
}
|
|
86
|
+
} else if ((value.startsWith('"') && value.endsWith('"')) ||
|
|
87
|
+
(value.startsWith("'") && value.endsWith("'"))) {
|
|
88
|
+
result[key] = value.slice(1, -1);
|
|
89
|
+
} else if (value === 'true') {
|
|
90
|
+
result[key] = true;
|
|
91
|
+
} else if (value === 'false') {
|
|
92
|
+
result[key] = false;
|
|
93
|
+
} else if (/^-?\d+$/.test(value)) {
|
|
94
|
+
result[key] = parseInt(value, 10);
|
|
95
|
+
} else if (/^-?\d+\.\d+$/.test(value)) {
|
|
96
|
+
result[key] = parseFloat(value);
|
|
97
|
+
} else {
|
|
98
|
+
result[key] = value;
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
return result;
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
function stripQuotes(str) {
|
|
106
|
+
if ((str.startsWith('"') && str.endsWith('"')) ||
|
|
107
|
+
(str.startsWith("'") && str.endsWith("'"))) {
|
|
108
|
+
return str.slice(1, -1);
|
|
109
|
+
}
|
|
110
|
+
return str;
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
// ─── Value extraction ────────────────────────────────────────────────────────
|
|
114
|
+
|
|
115
|
+
function getValueByPath(obj, dottedPath) {
|
|
116
|
+
if (!obj) return undefined;
|
|
117
|
+
const parts = dottedPath.split('.').filter(Boolean);
|
|
118
|
+
let cursor = obj;
|
|
119
|
+
for (const part of parts) {
|
|
120
|
+
if (cursor == null || typeof cursor !== 'object' || !(part in cursor)) {
|
|
121
|
+
return undefined;
|
|
122
|
+
}
|
|
123
|
+
cursor = cursor[part];
|
|
124
|
+
}
|
|
125
|
+
return cursor;
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
// ─── Validation ──────────────────────────────────────────────────────────────
|
|
129
|
+
|
|
130
|
+
const KNOWN_COPILOT_SETTINGS_KEYS = new Set([
|
|
131
|
+
'github.copilot.chat.agent.enabled',
|
|
132
|
+
'github.copilot.chat.codeGeneration.instructions',
|
|
133
|
+
'github.copilot.chat.reviewSelection.instructions',
|
|
134
|
+
'github.copilot.chat.commitMessageGeneration.instructions',
|
|
135
|
+
'github.copilot.chat.pullRequestDescriptionGeneration.instructions',
|
|
136
|
+
'chat.instructionsFilesLocations',
|
|
137
|
+
'chat.tools.terminal.sandbox.enabled',
|
|
138
|
+
'chat.agent.autoApproval.terminalCommands',
|
|
139
|
+
'chat.agent.autoApproval.tools',
|
|
140
|
+
'github.copilot.enable',
|
|
141
|
+
'github.copilot.advanced',
|
|
142
|
+
]);
|
|
143
|
+
|
|
144
|
+
const DEPRECATED_COPILOT_KEYS = new Map([
|
|
145
|
+
['github.copilot.chat.codeGeneration.instructions', 'Deprecated since VS Code 1.102. Use .github/instructions/*.instructions.md instead.'],
|
|
146
|
+
]);
|
|
147
|
+
|
|
148
|
+
/**
|
|
149
|
+
* Validate VS Code settings.json keys for Copilot-specific settings.
|
|
150
|
+
* @param {object} data - Parsed settings object.
|
|
151
|
+
* @returns {{ unknown: string[], deprecated: Array<{key: string, message: string}>, copilotKeys: string[] }}
|
|
152
|
+
*/
|
|
153
|
+
function validateCopilotSettingsKeys(data) {
|
|
154
|
+
if (!data || typeof data !== 'object') {
|
|
155
|
+
return { unknown: [], deprecated: [], copilotKeys: [] };
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
const copilotKeys = [];
|
|
159
|
+
const deprecated = [];
|
|
160
|
+
|
|
161
|
+
function walk(obj, prefix) {
|
|
162
|
+
for (const key of Object.keys(obj)) {
|
|
163
|
+
const fullKey = prefix ? `${prefix}.${key}` : key;
|
|
164
|
+
|
|
165
|
+
// Only track copilot-related keys
|
|
166
|
+
if (fullKey.startsWith('github.copilot') || fullKey.startsWith('chat.')) {
|
|
167
|
+
copilotKeys.push(fullKey);
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
if (DEPRECATED_COPILOT_KEYS.has(fullKey)) {
|
|
171
|
+
deprecated.push({ key: fullKey, message: DEPRECATED_COPILOT_KEYS.get(fullKey) });
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
if (obj[key] && typeof obj[key] === 'object' && !Array.isArray(obj[key])) {
|
|
175
|
+
walk(obj[key], fullKey);
|
|
176
|
+
}
|
|
177
|
+
}
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
walk(data, '');
|
|
181
|
+
return { unknown: [], deprecated, copilotKeys };
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
/**
|
|
185
|
+
* Validate .prompt.md frontmatter for required fields.
|
|
186
|
+
* Valid fields: description, agent, model, tools, mode.
|
|
187
|
+
*/
|
|
188
|
+
function validatePromptFrontmatter(frontmatter) {
|
|
189
|
+
if (!frontmatter) return { valid: false, errors: ['No frontmatter found'] };
|
|
190
|
+
|
|
191
|
+
const errors = [];
|
|
192
|
+
const VALID_PROMPT_FIELDS = new Set(['description', 'agent', 'model', 'tools', 'mode']);
|
|
193
|
+
|
|
194
|
+
for (const key of Object.keys(frontmatter)) {
|
|
195
|
+
if (!VALID_PROMPT_FIELDS.has(key)) {
|
|
196
|
+
errors.push(`Unknown prompt frontmatter field: "${key}"`);
|
|
197
|
+
}
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
return { valid: errors.length === 0, errors };
|
|
201
|
+
}
|
|
202
|
+
|
|
203
|
+
/**
|
|
204
|
+
* Validate .instructions.md frontmatter for required applyTo field.
|
|
205
|
+
*/
|
|
206
|
+
function validateInstructionFrontmatter(frontmatter) {
|
|
207
|
+
if (!frontmatter) return { valid: false, errors: ['No frontmatter found'] };
|
|
208
|
+
|
|
209
|
+
const errors = [];
|
|
210
|
+
|
|
211
|
+
if (!frontmatter.applyTo) {
|
|
212
|
+
errors.push('Missing required "applyTo" glob pattern in frontmatter');
|
|
213
|
+
}
|
|
214
|
+
|
|
215
|
+
return { valid: errors.length === 0, errors };
|
|
216
|
+
}
|
|
217
|
+
|
|
218
|
+
module.exports = {
|
|
219
|
+
tryParseJson,
|
|
220
|
+
extractFrontmatter,
|
|
221
|
+
parseSimpleYaml,
|
|
222
|
+
getValueByPath,
|
|
223
|
+
validateCopilotSettingsKeys,
|
|
224
|
+
validatePromptFrontmatter,
|
|
225
|
+
validateInstructionFrontmatter,
|
|
226
|
+
};
|
|
@@ -0,0 +1,197 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copilot project context.
|
|
3
|
+
*
|
|
4
|
+
* Extends the shared ProjectContext with Copilot-specific file lookups,
|
|
5
|
+
* 3-surface detection (VS Code, cloud agent, CLI), instruction parsing,
|
|
6
|
+
* and per-surface config resolution.
|
|
7
|
+
*/
|
|
8
|
+
|
|
9
|
+
const fs = require('fs');
|
|
10
|
+
const path = require('path');
|
|
11
|
+
const { ProjectContext } = require('../context');
|
|
12
|
+
const { tryParseJson, extractFrontmatter, getValueByPath } = require('./config-parser');
|
|
13
|
+
|
|
14
|
+
function listFiles(fullPath, filter) {
|
|
15
|
+
try {
|
|
16
|
+
const entries = fs.readdirSync(fullPath).filter(f => !f.startsWith('.'));
|
|
17
|
+
return filter ? entries.filter(filter) : entries;
|
|
18
|
+
} catch {
|
|
19
|
+
return [];
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
class CopilotProjectContext extends ProjectContext {
|
|
24
|
+
|
|
25
|
+
// ─── Instructions ─────────────────────────────────────────────────────
|
|
26
|
+
|
|
27
|
+
/**
|
|
28
|
+
* .github/copilot-instructions.md — repo-wide instructions for all surfaces.
|
|
29
|
+
*/
|
|
30
|
+
copilotInstructionsContent() {
|
|
31
|
+
return this.fileContent('.github/copilot-instructions.md');
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
/**
|
|
35
|
+
* .github/instructions/*.instructions.md — path-scoped instructions.
|
|
36
|
+
* Returns array of { name, path, frontmatter, body, applyTo }.
|
|
37
|
+
*/
|
|
38
|
+
scopedInstructions() {
|
|
39
|
+
const dir = path.join(this.dir, '.github', 'instructions');
|
|
40
|
+
const files = listFiles(dir, f => f.endsWith('.instructions.md'));
|
|
41
|
+
return files.map(f => {
|
|
42
|
+
const relPath = `.github/instructions/${f}`;
|
|
43
|
+
const content = this.fileContent(relPath);
|
|
44
|
+
if (!content) return null;
|
|
45
|
+
const parsed = extractFrontmatter(content);
|
|
46
|
+
return {
|
|
47
|
+
name: f.replace('.instructions.md', ''),
|
|
48
|
+
path: relPath,
|
|
49
|
+
frontmatter: parsed.frontmatter,
|
|
50
|
+
body: parsed.body,
|
|
51
|
+
applyTo: parsed.frontmatter ? parsed.frontmatter.applyTo : null,
|
|
52
|
+
};
|
|
53
|
+
}).filter(Boolean);
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
/**
|
|
57
|
+
* .github/prompts/*.prompt.md — reusable prompt templates.
|
|
58
|
+
* Returns array of { name, path, frontmatter, body }.
|
|
59
|
+
*/
|
|
60
|
+
promptFiles() {
|
|
61
|
+
const dir = path.join(this.dir, '.github', 'prompts');
|
|
62
|
+
const files = listFiles(dir, f => f.endsWith('.prompt.md'));
|
|
63
|
+
return files.map(f => {
|
|
64
|
+
const relPath = `.github/prompts/${f}`;
|
|
65
|
+
const content = this.fileContent(relPath);
|
|
66
|
+
if (!content) return null;
|
|
67
|
+
const parsed = extractFrontmatter(content);
|
|
68
|
+
return {
|
|
69
|
+
name: f.replace('.prompt.md', ''),
|
|
70
|
+
path: relPath,
|
|
71
|
+
frontmatter: parsed.frontmatter,
|
|
72
|
+
body: parsed.body,
|
|
73
|
+
};
|
|
74
|
+
}).filter(Boolean);
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
// ─── VS Code settings ─────────────────────────────────────────────────
|
|
78
|
+
|
|
79
|
+
/**
|
|
80
|
+
* .vscode/settings.json parsed — full VS Code settings (Copilot-relevant keys).
|
|
81
|
+
*/
|
|
82
|
+
vscodeSettings() {
|
|
83
|
+
const content = this.fileContent('.vscode/settings.json');
|
|
84
|
+
if (!content) {
|
|
85
|
+
return { ok: false, data: null, error: 'missing .vscode/settings.json', source: '.vscode/settings.json' };
|
|
86
|
+
}
|
|
87
|
+
const parsed = tryParseJson(content);
|
|
88
|
+
return { ...parsed, source: '.vscode/settings.json' };
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
/**
|
|
92
|
+
* Get a specific Copilot-related setting from .vscode/settings.json.
|
|
93
|
+
*/
|
|
94
|
+
copilotSetting(dottedKey) {
|
|
95
|
+
const result = this.vscodeSettings();
|
|
96
|
+
if (!result.ok) return undefined;
|
|
97
|
+
return getValueByPath(result.data, dottedKey);
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
// ─── Cloud agent config ───────────────────────────────────────────────
|
|
101
|
+
|
|
102
|
+
/**
|
|
103
|
+
* copilot-setup-steps.yml — cloud agent environment setup.
|
|
104
|
+
*/
|
|
105
|
+
cloudAgentConfig() {
|
|
106
|
+
return this.fileContent('.github/workflows/copilot-setup-steps.yml') ||
|
|
107
|
+
this.fileContent('copilot-setup-steps.yml');
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
// ─── MCP config ───────────────────────────────────────────────────────
|
|
111
|
+
|
|
112
|
+
/**
|
|
113
|
+
* .vscode/mcp.json — VS Code MCP server configuration.
|
|
114
|
+
* Note: Copilot MCP uses .vscode/mcp.json (separate from settings.json mcpServers).
|
|
115
|
+
*/
|
|
116
|
+
mcpConfig() {
|
|
117
|
+
const content = this.fileContent('.vscode/mcp.json');
|
|
118
|
+
if (!content) {
|
|
119
|
+
return { ok: false, data: null, error: 'missing .vscode/mcp.json', source: '.vscode/mcp.json' };
|
|
120
|
+
}
|
|
121
|
+
const parsed = tryParseJson(content);
|
|
122
|
+
return { ...parsed, source: '.vscode/mcp.json' };
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
/**
|
|
126
|
+
* MCP servers from .vscode/mcp.json.
|
|
127
|
+
*/
|
|
128
|
+
mcpServers() {
|
|
129
|
+
const result = this.mcpConfig();
|
|
130
|
+
if (!result.ok || !result.data) return {};
|
|
131
|
+
return result.data.servers || result.data.mcpServers || {};
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
// ─── Content exclusions ───────────────────────────────────────────────
|
|
135
|
+
|
|
136
|
+
/**
|
|
137
|
+
* Content exclusion patterns from .vscode/settings.json or org-level markers.
|
|
138
|
+
* Returns array of glob patterns, or null if not configured.
|
|
139
|
+
*/
|
|
140
|
+
contentExclusions() {
|
|
141
|
+
const settings = this.vscodeSettings();
|
|
142
|
+
if (!settings.ok) return null;
|
|
143
|
+
|
|
144
|
+
// Check multiple possible config keys for content exclusions
|
|
145
|
+
const exclusions = getValueByPath(settings.data, 'github.copilot.advanced.contentExclusion') ||
|
|
146
|
+
getValueByPath(settings.data, 'github.copilot.contentExclusion') ||
|
|
147
|
+
null;
|
|
148
|
+
|
|
149
|
+
return exclusions;
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
// ─── Workflow files ───────────────────────────────────────────────────
|
|
153
|
+
|
|
154
|
+
workflowFiles() {
|
|
155
|
+
const dir = path.join(this.dir, '.github', 'workflows');
|
|
156
|
+
return listFiles(dir, f => f.endsWith('.yml') || f.endsWith('.yaml'))
|
|
157
|
+
.map(f => `.github/workflows/${f}`);
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
// ─── Surface detection ────────────────────────────────────────────────
|
|
161
|
+
|
|
162
|
+
/**
|
|
163
|
+
* Detect which Copilot surfaces are configured.
|
|
164
|
+
*/
|
|
165
|
+
detectSurfaces() {
|
|
166
|
+
const vscode = Boolean(
|
|
167
|
+
this.fileContent('.vscode/settings.json') ||
|
|
168
|
+
this.fileContent('.vscode/mcp.json')
|
|
169
|
+
);
|
|
170
|
+
const cloudAgent = Boolean(this.cloudAgentConfig());
|
|
171
|
+
const cli = false; // CLI detection is local-only; can't detect from repo files
|
|
172
|
+
|
|
173
|
+
return { vscode, cloudAgent, cli };
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
// ─── Static detection ─────────────────────────────────────────────────
|
|
177
|
+
|
|
178
|
+
static isCopilotRepo(dir) {
|
|
179
|
+
try {
|
|
180
|
+
return fs.existsSync(path.join(dir, '.github', 'copilot-instructions.md')) ||
|
|
181
|
+
fs.existsSync(path.join(dir, '.vscode', 'mcp.json')) ||
|
|
182
|
+
fs.existsSync(path.join(dir, '.github', 'instructions'));
|
|
183
|
+
} catch {
|
|
184
|
+
return false;
|
|
185
|
+
}
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
// ─── Stack detection (reuse shared) ───────────────────────────────────
|
|
189
|
+
|
|
190
|
+
detectStacks(STACKS) {
|
|
191
|
+
return super.detectStacks(STACKS);
|
|
192
|
+
}
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
module.exports = {
|
|
196
|
+
CopilotProjectContext,
|
|
197
|
+
};
|