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