@nerviq/cli 1.20.1 → 1.21.0
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/LICENSE +23 -23
- package/README.md +2 -2
- package/package.json +1 -1
- package/src/activity.js +1039 -1039
- package/src/adoption-advisor.js +299 -299
- package/src/aider/config-parser.js +166 -166
- package/src/aider/context.js +4 -1
- package/src/aider/deep-review.js +316 -316
- package/src/aider/domain-packs.js +303 -303
- package/src/aider/freshness.js +93 -93
- package/src/aider/governance.js +253 -253
- package/src/aider/interactive.js +334 -334
- package/src/aider/mcp-packs.js +329 -329
- package/src/aider/patch.js +214 -214
- package/src/aider/plans.js +186 -186
- package/src/aider/premium.js +360 -360
- package/src/aider/setup.js +404 -404
- package/src/aider/techniques.js +312 -67
- package/src/analyze.js +951 -951
- package/src/anti-patterns.js +485 -485
- package/src/audit/instruction-files.js +180 -180
- package/src/audit/recommendations.js +577 -577
- package/src/auto-suggest.js +154 -154
- package/src/badge.js +13 -13
- package/src/behavioral-drift.js +801 -801
- package/src/benchmark.js +67 -67
- package/src/catalog.js +103 -103
- package/src/certification.js +128 -128
- package/src/codex/config-parser.js +183 -183
- package/src/codex/context.js +223 -223
- package/src/codex/deep-review.js +493 -493
- package/src/codex/domain-packs.js +394 -394
- package/src/codex/freshness.js +84 -84
- package/src/codex/governance.js +192 -192
- package/src/codex/interactive.js +618 -618
- package/src/codex/mcp-packs.js +914 -914
- package/src/codex/patch.js +209 -209
- package/src/codex/plans.js +251 -251
- package/src/codex/premium.js +614 -614
- package/src/codex/setup.js +591 -591
- package/src/continuous-ops.js +681 -681
- package/src/copilot/activity.js +309 -309
- package/src/copilot/deep-review.js +346 -346
- package/src/copilot/domain-packs.js +372 -372
- package/src/copilot/freshness.js +57 -57
- package/src/copilot/governance.js +222 -222
- package/src/copilot/interactive.js +406 -406
- package/src/copilot/mcp-packs.js +826 -826
- package/src/copilot/plans.js +253 -253
- package/src/copilot/premium.js +451 -451
- package/src/copilot/setup.js +488 -488
- package/src/cost-tracking.js +61 -61
- package/src/cursor/activity.js +301 -301
- package/src/cursor/config-parser.js +265 -265
- package/src/cursor/context.js +256 -256
- package/src/cursor/deep-review.js +334 -334
- package/src/cursor/domain-packs.js +368 -368
- package/src/cursor/freshness.js +65 -65
- package/src/cursor/governance.js +229 -229
- package/src/cursor/interactive.js +391 -391
- package/src/cursor/mcp-packs.js +828 -828
- package/src/cursor/plans.js +254 -254
- package/src/cursor/premium.js +469 -469
- package/src/cursor/setup.js +488 -488
- package/src/dashboard.js +493 -493
- package/src/deep-review.js +428 -428
- package/src/deprecation.js +98 -98
- package/src/diff-only.js +280 -280
- package/src/doctor.js +119 -119
- package/src/domain-pack-expansion.js +1033 -1033
- package/src/domain-packs.js +387 -387
- package/src/feedback.js +178 -178
- package/src/fix-engine.js +783 -783
- package/src/fix-prompts.js +122 -122
- package/src/formatters/sarif.js +115 -115
- package/src/freshness.js +74 -74
- package/src/gemini/config-parser.js +275 -275
- package/src/gemini/deep-review.js +559 -559
- package/src/gemini/domain-packs.js +393 -393
- package/src/gemini/freshness.js +66 -66
- package/src/gemini/governance.js +201 -201
- package/src/gemini/interactive.js +860 -860
- package/src/gemini/mcp-packs.js +915 -915
- package/src/gemini/plans.js +269 -269
- package/src/gemini/premium.js +760 -760
- package/src/gemini/setup.js +692 -692
- package/src/governance.js +72 -72
- package/src/harmony/add.js +68 -68
- package/src/harmony/advisor.js +333 -333
- package/src/harmony/canon.js +565 -565
- package/src/harmony/cli.js +591 -591
- package/src/harmony/drift.js +401 -401
- package/src/harmony/governance.js +313 -313
- package/src/harmony/memory.js +239 -239
- package/src/harmony/sync.js +475 -475
- package/src/harmony/watch.js +370 -370
- package/src/hook-validation.js +342 -342
- package/src/index.js +271 -271
- package/src/init.js +184 -184
- package/src/instruction-surfaces.js +185 -185
- package/src/integrations.js +144 -144
- package/src/interactive.js +118 -118
- package/src/locales/en.json +1 -1
- package/src/locales/es.json +1 -1
- package/src/mcp-packs.js +830 -830
- package/src/mcp-server.js +726 -726
- package/src/mcp-validation.js +337 -337
- package/src/nerviq-sync.json +7 -7
- package/src/opencode/config-parser.js +109 -109
- package/src/opencode/context.js +247 -247
- package/src/opencode/deep-review.js +313 -313
- package/src/opencode/domain-packs.js +262 -262
- package/src/opencode/freshness.js +66 -66
- package/src/opencode/governance.js +159 -159
- package/src/opencode/interactive.js +392 -392
- package/src/opencode/mcp-packs.js +705 -705
- package/src/opencode/patch.js +184 -184
- package/src/opencode/plans.js +231 -231
- package/src/opencode/premium.js +413 -413
- package/src/opencode/setup.js +449 -449
- package/src/opencode/techniques.js +27 -27
- package/src/operating-profile.js +574 -574
- package/src/org.js +152 -152
- package/src/permission-rules.js +218 -218
- package/src/plans.js +839 -839
- package/src/platform-change-manifest.js +86 -86
- package/src/plugins.js +110 -110
- package/src/policy-layers.js +210 -210
- package/src/profiles.js +124 -124
- package/src/prompt-injection.js +74 -74
- package/src/public-api.js +173 -173
- package/src/recommendation-rules.js +84 -84
- package/src/repo-archetype.js +386 -386
- package/src/secret-patterns.js +39 -39
- package/src/server.js +527 -527
- package/src/setup/analysis.js +607 -607
- package/src/setup/runtime.js +172 -172
- package/src/setup.js +677 -677
- package/src/shared/capabilities.js +194 -194
- package/src/source-urls.js +132 -132
- package/src/stack-checks.js +565 -565
- package/src/supplemental-checks.js +13 -13
- package/src/synergy/adaptive.js +261 -261
- package/src/synergy/compensation.js +137 -137
- package/src/synergy/evidence.js +193 -193
- package/src/synergy/learning.js +199 -199
- package/src/synergy/patterns.js +227 -227
- package/src/synergy/ranking.js +83 -83
- package/src/synergy/report.js +165 -165
- package/src/synergy/routing.js +146 -146
- package/src/techniques/api.js +407 -407
- package/src/techniques/automation.js +316 -316
- package/src/techniques/compliance.js +257 -257
- package/src/techniques/hygiene.js +294 -294
- package/src/techniques/instructions.js +243 -243
- package/src/techniques/observability.js +226 -226
- package/src/techniques/optimization.js +142 -142
- package/src/techniques/quality.js +318 -318
- package/src/techniques/security.js +237 -237
- package/src/techniques/shared.js +443 -443
- package/src/techniques/stacks.js +2294 -2294
- package/src/techniques/tools.js +106 -106
- package/src/techniques/workflow.js +413 -413
- package/src/techniques.js +81 -81
- package/src/terminology.js +73 -73
- package/src/token-estimate.js +35 -35
- package/src/usage-patterns.js +99 -99
- package/src/verification-metadata.js +145 -145
- package/src/watch.js +247 -247
- package/src/windsurf/activity.js +302 -302
- package/src/windsurf/config-parser.js +267 -267
- package/src/windsurf/deep-review.js +337 -337
- package/src/windsurf/domain-packs.js +370 -370
- package/src/windsurf/freshness.js +36 -36
- package/src/windsurf/governance.js +231 -231
- package/src/windsurf/interactive.js +388 -388
- package/src/windsurf/mcp-packs.js +792 -792
- package/src/windsurf/plans.js +247 -247
- package/src/windsurf/premium.js +468 -468
- package/src/windsurf/setup.js +471 -471
- package/src/workspace.js +375 -375
|
@@ -1,406 +1,406 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Copilot Interactive Wizard — 10-stage guided setup.
|
|
3
|
-
*
|
|
4
|
-
* Adapted for Copilot's 3-surface architecture (VS Code, cloud, CLI).
|
|
5
|
-
*
|
|
6
|
-
* Stages:
|
|
7
|
-
* 1. Project detection (stacks, existing .github/, .vscode/)
|
|
8
|
-
* 2. Surface selection (VS Code / cloud agent / both)
|
|
9
|
-
* 3. Trust & sandbox (OS-aware, Windows warning)
|
|
10
|
-
* 4. Auto-approval configuration
|
|
11
|
-
* 5. Domain pack selection
|
|
12
|
-
* 6. MCP pack selection
|
|
13
|
-
* 7. Instruction structure (repo-wide + scoped + prompts)
|
|
14
|
-
* 8. Cloud agent configuration
|
|
15
|
-
* 9. Org policy awareness
|
|
16
|
-
* 10. Review & generate
|
|
17
|
-
*/
|
|
18
|
-
|
|
19
|
-
const fs = require('fs');
|
|
20
|
-
const os = require('os');
|
|
21
|
-
const path = require('path');
|
|
22
|
-
const readline = require('readline');
|
|
23
|
-
const { STACKS } = require('../techniques');
|
|
24
|
-
const { CopilotProjectContext } = require('./context');
|
|
25
|
-
const { COPILOT_TECHNIQUES } = require('./techniques');
|
|
26
|
-
const { COPILOT_DOMAIN_PACKS, detectCopilotDomainPacks } = require('./domain-packs');
|
|
27
|
-
const { recommendCopilotMcpPacks, COPILOT_MCP_PACKS } = require('./mcp-packs');
|
|
28
|
-
|
|
29
|
-
const COLORS = {
|
|
30
|
-
reset: '\x1b[0m', bold: '\x1b[1m', dim: '\x1b[2m',
|
|
31
|
-
red: '\x1b[31m', green: '\x1b[32m', yellow: '\x1b[33m',
|
|
32
|
-
blue: '\x1b[36m', magenta: '\x1b[35m',
|
|
33
|
-
};
|
|
34
|
-
const c = (text, color) => `${COLORS[color] || ''}${text}${COLORS.reset}`;
|
|
35
|
-
|
|
36
|
-
function ask(rl, question) {
|
|
37
|
-
return new Promise(resolve => rl.question(question, resolve));
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
function isTTY() {
|
|
41
|
-
return Boolean(process.stdin.isTTY && process.stdout.isTTY);
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
const STAGE_NAMES = [
|
|
45
|
-
'Project Detection',
|
|
46
|
-
'Surface Selection',
|
|
47
|
-
'Trust & Sandbox',
|
|
48
|
-
'Auto-Approval Config',
|
|
49
|
-
'Domain Pack Selection',
|
|
50
|
-
'MCP Pack Selection',
|
|
51
|
-
'Instruction Structure',
|
|
52
|
-
'Cloud Agent Config',
|
|
53
|
-
'Org Policy Awareness',
|
|
54
|
-
'Review & Generate',
|
|
55
|
-
];
|
|
56
|
-
|
|
57
|
-
function printStageHeader(index) {
|
|
58
|
-
console.log('');
|
|
59
|
-
console.log(c(` ── Stage ${index + 1}/${STAGE_NAMES.length}: ${STAGE_NAMES[index]} ──`, 'magenta'));
|
|
60
|
-
console.log('');
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
// --- Stage 1: Project Detection ---
|
|
64
|
-
|
|
65
|
-
function runProjectDetection(ctx) {
|
|
66
|
-
const stacks = ctx.detectStacks(STACKS);
|
|
67
|
-
const hasCopilotInstructions = Boolean(ctx.copilotInstructionsContent());
|
|
68
|
-
const hasVscodeSettings = Boolean(ctx.fileContent('.vscode/settings.json'));
|
|
69
|
-
const hasMcpJson = Boolean(ctx.fileContent('.vscode/mcp.json'));
|
|
70
|
-
const hasCloudSetup = Boolean(ctx.cloudAgentConfig());
|
|
71
|
-
const surfaces = ctx.detectSurfaces();
|
|
72
|
-
|
|
73
|
-
const auditResults = [];
|
|
74
|
-
for (const [key, technique] of Object.entries(COPILOT_TECHNIQUES)) {
|
|
75
|
-
auditResults.push({ key, ...technique, passed: technique.check(ctx) });
|
|
76
|
-
}
|
|
77
|
-
const passed = auditResults.filter(r => r.passed === true);
|
|
78
|
-
const failed = auditResults.filter(r => r.passed === false);
|
|
79
|
-
|
|
80
|
-
return { stacks, hasCopilotInstructions, hasVscodeSettings, hasMcpJson, hasCloudSetup, surfaces, auditResults, passed, failed };
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
async function stageProjectDetection(rl, ctx, state) {
|
|
84
|
-
printStageHeader(0);
|
|
85
|
-
const det = runProjectDetection(ctx);
|
|
86
|
-
Object.assign(state, det);
|
|
87
|
-
|
|
88
|
-
if (det.stacks.length > 0) console.log(c(` Detected stacks: ${det.stacks.map(s => s.label).join(', ')}`, 'blue'));
|
|
89
|
-
else console.log(c(' No specific stack detected — will use baseline defaults.', 'dim'));
|
|
90
|
-
|
|
91
|
-
console.log(c(` Working directory: ${ctx.dir}`, 'dim'));
|
|
92
|
-
console.log('');
|
|
93
|
-
console.log(` ${c(`${det.passed.length}/${det.auditResults.length}`, 'bold')} Copilot checks passing.`);
|
|
94
|
-
console.log(` ${c(String(det.failed.length), 'yellow')} improvements available.`);
|
|
95
|
-
console.log('');
|
|
96
|
-
console.log(` Surfaces: VS Code ${det.surfaces.vscode ? c('Y', 'green') : c('N', 'red')} | Cloud ${det.surfaces.cloudAgent ? c('Y', 'green') : c('N', 'red')} | CLI ${det.surfaces.cli ? c('Y', 'green') : c('N', 'red')}`);
|
|
97
|
-
|
|
98
|
-
if (det.hasCopilotInstructions || det.hasVscodeSettings) {
|
|
99
|
-
console.log('');
|
|
100
|
-
console.log(c(' Existing Copilot configuration detected:', 'yellow'));
|
|
101
|
-
if (det.hasCopilotInstructions) console.log(c(' .github/copilot-instructions.md found', 'dim'));
|
|
102
|
-
if (det.hasVscodeSettings) console.log(c(' .vscode/settings.json found', 'dim'));
|
|
103
|
-
if (det.hasMcpJson) console.log(c(' .vscode/mcp.json found', 'dim'));
|
|
104
|
-
if (det.hasCloudSetup) console.log(c(' copilot-setup-steps.yml found', 'dim'));
|
|
105
|
-
console.log('');
|
|
106
|
-
|
|
107
|
-
const answer = await ask(rl, c(' Merge with existing config or replace? (merge/replace/quit) ', 'magenta'));
|
|
108
|
-
const choice = answer.trim().toLowerCase();
|
|
109
|
-
if (choice === 'quit' || choice === 'q') return 'quit';
|
|
110
|
-
state.migrationMode = choice === 'replace' ? 'replace' : 'merge';
|
|
111
|
-
} else {
|
|
112
|
-
state.migrationMode = 'create';
|
|
113
|
-
console.log('');
|
|
114
|
-
console.log(c(' No existing Copilot config — will create fresh setup.', 'dim'));
|
|
115
|
-
}
|
|
116
|
-
|
|
117
|
-
return 'next';
|
|
118
|
-
}
|
|
119
|
-
|
|
120
|
-
// --- Stage 2: Surface Selection ---
|
|
121
|
-
|
|
122
|
-
async function stageSurfaceSelection(rl, _ctx, state) {
|
|
123
|
-
printStageHeader(1);
|
|
124
|
-
|
|
125
|
-
console.log(' Which Copilot surfaces do you want to configure?');
|
|
126
|
-
console.log('');
|
|
127
|
-
console.log(` ${c('1', 'bold')}. ${c('VS Code only', 'blue')} — Local IDE agent mode.`);
|
|
128
|
-
console.log(` ${c('2', 'bold')}. ${c('VS Code + Cloud agent', 'blue')} — IDE + GitHub cloud agent for automated tasks.`);
|
|
129
|
-
console.log(` ${c('3', 'bold')}. ${c('All surfaces', 'blue')} — VS Code + Cloud + CLI.`);
|
|
130
|
-
console.log('');
|
|
131
|
-
|
|
132
|
-
const answer = await ask(rl, c(' Choice (1-3, or b=back, q=quit) [2]: ', 'magenta'));
|
|
133
|
-
const trimmed = answer.trim().toLowerCase();
|
|
134
|
-
if (trimmed === 'b') return 'back';
|
|
135
|
-
if (trimmed === 'q') return 'quit';
|
|
136
|
-
|
|
137
|
-
const index = parseInt(trimmed, 10);
|
|
138
|
-
const surfaceChoices = { 1: ['vscode'], 2: ['vscode', 'cloud'], 3: ['vscode', 'cloud', 'cli'] };
|
|
139
|
-
state.selectedSurfaces = surfaceChoices[index] || surfaceChoices[2];
|
|
140
|
-
console.log(c(` → Surfaces: ${state.selectedSurfaces.join(', ')}`, 'green'));
|
|
141
|
-
|
|
142
|
-
return 'next';
|
|
143
|
-
}
|
|
144
|
-
|
|
145
|
-
// --- Stage 3: Trust & Sandbox ---
|
|
146
|
-
|
|
147
|
-
async function stageTrustSandbox(rl, _ctx, state) {
|
|
148
|
-
printStageHeader(2);
|
|
149
|
-
|
|
150
|
-
const detectedOS = os.platform() === 'darwin' ? 'macOS' : os.platform() === 'linux' ? 'Linux' : os.platform() === 'win32' ? 'Windows' : os.platform();
|
|
151
|
-
state.detectedOS = detectedOS;
|
|
152
|
-
|
|
153
|
-
console.log(c(` Detected OS: ${detectedOS}`, 'blue'));
|
|
154
|
-
if (detectedOS === 'Windows') {
|
|
155
|
-
console.log('');
|
|
156
|
-
console.log(c(' WARNING: Terminal sandbox is NOT available on native Windows!', 'red'));
|
|
157
|
-
console.log(c(' Consider using WSL2 or Docker for sandboxed Copilot agent execution.', 'yellow'));
|
|
158
|
-
}
|
|
159
|
-
console.log('');
|
|
160
|
-
console.log(' Enable terminal sandbox? (Recommended for macOS/Linux/WSL2)');
|
|
161
|
-
console.log('');
|
|
162
|
-
|
|
163
|
-
const answer = await ask(rl, c(` Enable sandbox? (y/n, or b=back, q=quit) [${detectedOS === 'Windows' ? 'n' : 'y'}]: `, 'magenta'));
|
|
164
|
-
const trimmed = answer.trim().toLowerCase();
|
|
165
|
-
if (trimmed === 'b') return 'back';
|
|
166
|
-
if (trimmed === 'q') return 'quit';
|
|
167
|
-
|
|
168
|
-
state.sandboxEnabled = trimmed === 'y' || (trimmed === '' && detectedOS !== 'Windows');
|
|
169
|
-
console.log(c(` → Sandbox: ${state.sandboxEnabled ? 'enabled' : 'disabled'}`, state.sandboxEnabled ? 'green' : 'yellow'));
|
|
170
|
-
|
|
171
|
-
return 'next';
|
|
172
|
-
}
|
|
173
|
-
|
|
174
|
-
// --- Stage 4: Auto-Approval ---
|
|
175
|
-
|
|
176
|
-
async function stageAutoApproval(rl, _ctx, state) {
|
|
177
|
-
printStageHeader(3);
|
|
178
|
-
|
|
179
|
-
console.log(' Configure auto-approval for terminal commands?');
|
|
180
|
-
console.log('');
|
|
181
|
-
console.log(` ${c('1', 'bold')}. ${c('No auto-approval', 'blue')} — All commands require confirmation (safest).`);
|
|
182
|
-
console.log(` ${c('2', 'bold')}. ${c('Safe commands only', 'blue')} — Auto-approve test/lint/build patterns.`);
|
|
183
|
-
console.log(` ${c('3', 'bold')}. ${c('Custom patterns', 'blue')} — Enter your own auto-approval patterns.`);
|
|
184
|
-
console.log('');
|
|
185
|
-
|
|
186
|
-
const answer = await ask(rl, c(' Choice (1-3, or b=back, q=quit) [1]: ', 'magenta'));
|
|
187
|
-
const trimmed = answer.trim().toLowerCase();
|
|
188
|
-
if (trimmed === 'b') return 'back';
|
|
189
|
-
if (trimmed === 'q') return 'quit';
|
|
190
|
-
|
|
191
|
-
const choice = parseInt(trimmed, 10);
|
|
192
|
-
if (choice === 2) {
|
|
193
|
-
state.autoApprovalPatterns = ['npm test', 'npm run lint', 'npm run build'];
|
|
194
|
-
} else if (choice === 3) {
|
|
195
|
-
const patterns = await ask(rl, c(' Enter patterns (comma-separated): ', 'magenta'));
|
|
196
|
-
state.autoApprovalPatterns = patterns.split(',').map(p => p.trim()).filter(Boolean);
|
|
197
|
-
} else {
|
|
198
|
-
state.autoApprovalPatterns = [];
|
|
199
|
-
}
|
|
200
|
-
|
|
201
|
-
console.log(c(` → Auto-approval: ${state.autoApprovalPatterns.length === 0 ? 'none' : state.autoApprovalPatterns.join(', ')}`, 'green'));
|
|
202
|
-
return 'next';
|
|
203
|
-
}
|
|
204
|
-
|
|
205
|
-
// --- Stage 5: Domain Pack Selection ---
|
|
206
|
-
|
|
207
|
-
async function stageDomainPacks(rl, ctx, state) {
|
|
208
|
-
printStageHeader(4);
|
|
209
|
-
|
|
210
|
-
const detected = detectCopilotDomainPacks(ctx, state.stacks || []);
|
|
211
|
-
state.domainPacks = detected;
|
|
212
|
-
|
|
213
|
-
console.log(` Detected ${detected.length} domain pack(s):`);
|
|
214
|
-
console.log('');
|
|
215
|
-
detected.forEach((pack, i) => {
|
|
216
|
-
console.log(` ${c(`${i + 1}`, 'bold')}. ${c(pack.label, 'blue')} — ${pack.matchReasons[0] || pack.useWhen}`);
|
|
217
|
-
});
|
|
218
|
-
console.log('');
|
|
219
|
-
|
|
220
|
-
const answer = await ask(rl, c(' Accept detected packs? (y/n, or b=back, q=quit) [y]: ', 'magenta'));
|
|
221
|
-
const trimmed = answer.trim().toLowerCase();
|
|
222
|
-
if (trimmed === 'b') return 'back';
|
|
223
|
-
if (trimmed === 'q') return 'quit';
|
|
224
|
-
if (trimmed === 'n') state.domainPacks = [];
|
|
225
|
-
|
|
226
|
-
console.log(c(` → Domain packs: ${state.domainPacks.map(p => p.label).join(', ') || 'none'}`, 'green'));
|
|
227
|
-
return 'next';
|
|
228
|
-
}
|
|
229
|
-
|
|
230
|
-
// --- Stage 6: MCP Pack Selection ---
|
|
231
|
-
|
|
232
|
-
async function stageMcpPacks(rl, ctx, state) {
|
|
233
|
-
printStageHeader(5);
|
|
234
|
-
|
|
235
|
-
const cloudOnly = state.selectedSurfaces && !state.selectedSurfaces.includes('vscode');
|
|
236
|
-
const recommended = recommendCopilotMcpPacks(state.stacks || [], state.domainPacks || [], { ctx, cloudOnly });
|
|
237
|
-
state.mcpPacks = recommended;
|
|
238
|
-
|
|
239
|
-
console.log(` Recommended ${recommended.length} MCP pack(s):`);
|
|
240
|
-
console.log('');
|
|
241
|
-
recommended.forEach((pack, i) => {
|
|
242
|
-
const cloudIcon = pack.cloudAgentCompatible === false ? c(' [VS Code only]', 'yellow') : '';
|
|
243
|
-
console.log(` ${c(`${i + 1}`, 'bold')}. ${c(pack.label, 'blue')}${cloudIcon} — ${pack.description}`);
|
|
244
|
-
});
|
|
245
|
-
console.log('');
|
|
246
|
-
|
|
247
|
-
const answer = await ask(rl, c(' Accept recommended packs? (y/n, or b=back, q=quit) [y]: ', 'magenta'));
|
|
248
|
-
const trimmed = answer.trim().toLowerCase();
|
|
249
|
-
if (trimmed === 'b') return 'back';
|
|
250
|
-
if (trimmed === 'q') return 'quit';
|
|
251
|
-
if (trimmed === 'n') state.mcpPacks = [];
|
|
252
|
-
|
|
253
|
-
console.log(c(` → MCP packs: ${state.mcpPacks.map(p => p.label).join(', ') || 'none'}`, 'green'));
|
|
254
|
-
return 'next';
|
|
255
|
-
}
|
|
256
|
-
|
|
257
|
-
// --- Stage 7: Instruction Structure ---
|
|
258
|
-
|
|
259
|
-
async function stageInstructionStructure(rl, _ctx, state) {
|
|
260
|
-
printStageHeader(6);
|
|
261
|
-
|
|
262
|
-
console.log(' What instruction structure do you want?');
|
|
263
|
-
console.log('');
|
|
264
|
-
console.log(` ${c('1', 'bold')}. ${c('Basic', 'blue')} — copilot-instructions.md only.`);
|
|
265
|
-
console.log(` ${c('2', 'bold')}. ${c('Scoped', 'blue')} — copilot-instructions.md + path-scoped .instructions.md files.`);
|
|
266
|
-
console.log(` ${c('3', 'bold')}. ${c('Full', 'blue')} — All of the above + prompt templates (.prompt.md).`);
|
|
267
|
-
console.log('');
|
|
268
|
-
|
|
269
|
-
const answer = await ask(rl, c(' Choice (1-3, or b=back, q=quit) [3]: ', 'magenta'));
|
|
270
|
-
const trimmed = answer.trim().toLowerCase();
|
|
271
|
-
if (trimmed === 'b') return 'back';
|
|
272
|
-
if (trimmed === 'q') return 'quit';
|
|
273
|
-
|
|
274
|
-
const choice = parseInt(trimmed, 10);
|
|
275
|
-
state.instructionModules = ['copilot-instructions'];
|
|
276
|
-
if (choice >= 2 || trimmed === '') state.instructionModules.push('scoped-instructions');
|
|
277
|
-
if (choice >= 3 || trimmed === '') state.instructionModules.push('prompts');
|
|
278
|
-
|
|
279
|
-
console.log(c(` → Instructions: ${state.instructionModules.join(', ')}`, 'green'));
|
|
280
|
-
return 'next';
|
|
281
|
-
}
|
|
282
|
-
|
|
283
|
-
// --- Stage 8: Cloud Agent Config ---
|
|
284
|
-
|
|
285
|
-
async function stageCloudAgent(rl, _ctx, state) {
|
|
286
|
-
if (!state.selectedSurfaces || !state.selectedSurfaces.includes('cloud')) return 'next';
|
|
287
|
-
|
|
288
|
-
printStageHeader(7);
|
|
289
|
-
|
|
290
|
-
console.log(' Cloud agent configuration:');
|
|
291
|
-
console.log('');
|
|
292
|
-
console.log(c(' Important: Cloud agent cold-boot takes ~90 seconds.', 'yellow'));
|
|
293
|
-
console.log(c(' Content exclusions are NOT enforced on the cloud agent.', 'red'));
|
|
294
|
-
console.log('');
|
|
295
|
-
|
|
296
|
-
const answer = await ask(rl, c(' Generate copilot-setup-steps.yml? (y/n, or b=back, q=quit) [y]: ', 'magenta'));
|
|
297
|
-
const trimmed = answer.trim().toLowerCase();
|
|
298
|
-
if (trimmed === 'b') return 'back';
|
|
299
|
-
if (trimmed === 'q') return 'quit';
|
|
300
|
-
|
|
301
|
-
state.generateCloudSetup = trimmed !== 'n';
|
|
302
|
-
console.log(c(` → Cloud setup: ${state.generateCloudSetup ? 'will generate' : 'skip'}`, 'green'));
|
|
303
|
-
return 'next';
|
|
304
|
-
}
|
|
305
|
-
|
|
306
|
-
// --- Stage 9: Org Policy Awareness ---
|
|
307
|
-
|
|
308
|
-
async function stageOrgPolicy(rl, _ctx, state) {
|
|
309
|
-
printStageHeader(8);
|
|
310
|
-
|
|
311
|
-
console.log(' Is this repo part of a GitHub Organization with Copilot policies?');
|
|
312
|
-
console.log('');
|
|
313
|
-
console.log(` ${c('1', 'bold')}. ${c('No / Unknown', 'blue')} — Individual or personal repo.`);
|
|
314
|
-
console.log(` ${c('2', 'bold')}. ${c('Yes (Business)', 'blue')} — Org with Business plan and policies.`);
|
|
315
|
-
console.log(` ${c('3', 'bold')}. ${c('Yes (Enterprise)', 'blue')} — Enterprise with audit logs, BYOK, full governance.`);
|
|
316
|
-
console.log('');
|
|
317
|
-
|
|
318
|
-
const answer = await ask(rl, c(' Choice (1-3, or b=back, q=quit) [1]: ', 'magenta'));
|
|
319
|
-
const trimmed = answer.trim().toLowerCase();
|
|
320
|
-
if (trimmed === 'b') return 'back';
|
|
321
|
-
if (trimmed === 'q') return 'quit';
|
|
322
|
-
|
|
323
|
-
const choice = parseInt(trimmed, 10);
|
|
324
|
-
state.orgTier = choice === 3 ? 'enterprise' : choice === 2 ? 'business' : 'individual';
|
|
325
|
-
console.log(c(` → Org tier: ${state.orgTier}`, 'green'));
|
|
326
|
-
return 'next';
|
|
327
|
-
}
|
|
328
|
-
|
|
329
|
-
// --- Stage 10: Review & Generate ---
|
|
330
|
-
|
|
331
|
-
async function stageReviewGenerate(rl, _ctx, state) {
|
|
332
|
-
printStageHeader(9);
|
|
333
|
-
|
|
334
|
-
console.log(' Summary of your Copilot setup:');
|
|
335
|
-
console.log('');
|
|
336
|
-
console.log(` Surfaces: ${(state.selectedSurfaces || []).join(', ')}`);
|
|
337
|
-
console.log(` Sandbox: ${state.sandboxEnabled ? 'enabled' : 'disabled'}`);
|
|
338
|
-
console.log(` Auto-approval: ${(state.autoApprovalPatterns || []).length === 0 ? 'none' : (state.autoApprovalPatterns || []).join(', ')}`);
|
|
339
|
-
console.log(` Domain packs: ${(state.domainPacks || []).map(p => p.label).join(', ') || 'none'}`);
|
|
340
|
-
console.log(` MCP packs: ${(state.mcpPacks || []).map(p => p.label).join(', ') || 'none'}`);
|
|
341
|
-
console.log(` Instructions: ${(state.instructionModules || []).join(', ')}`);
|
|
342
|
-
console.log(` Cloud setup: ${state.generateCloudSetup ? 'yes' : 'no'}`);
|
|
343
|
-
console.log(` Org tier: ${state.orgTier || 'individual'}`);
|
|
344
|
-
console.log('');
|
|
345
|
-
|
|
346
|
-
const answer = await ask(rl, c(' Generate files? (y/n, or b=back, q=quit) [y]: ', 'magenta'));
|
|
347
|
-
const trimmed = answer.trim().toLowerCase();
|
|
348
|
-
if (trimmed === 'b') return 'back';
|
|
349
|
-
if (trimmed === 'q') return 'quit';
|
|
350
|
-
if (trimmed === 'n') return 'quit';
|
|
351
|
-
|
|
352
|
-
state.confirmed = true;
|
|
353
|
-
return 'done';
|
|
354
|
-
}
|
|
355
|
-
|
|
356
|
-
// --- Main Wizard ---
|
|
357
|
-
|
|
358
|
-
const STAGES = [
|
|
359
|
-
stageProjectDetection,
|
|
360
|
-
stageSurfaceSelection,
|
|
361
|
-
stageTrustSandbox,
|
|
362
|
-
stageAutoApproval,
|
|
363
|
-
stageDomainPacks,
|
|
364
|
-
stageMcpPacks,
|
|
365
|
-
stageInstructionStructure,
|
|
366
|
-
stageCloudAgent,
|
|
367
|
-
stageOrgPolicy,
|
|
368
|
-
stageReviewGenerate,
|
|
369
|
-
];
|
|
370
|
-
|
|
371
|
-
async function runCopilotWizard(options) {
|
|
372
|
-
if (!isTTY()) {
|
|
373
|
-
console.log('Interactive wizard requires a TTY. Use --non-interactive or pipe mode instead.');
|
|
374
|
-
return null;
|
|
375
|
-
}
|
|
376
|
-
|
|
377
|
-
const rl = readline.createInterface({ input: process.stdin, output: process.stdout });
|
|
378
|
-
const ctx = new CopilotProjectContext(options.dir);
|
|
379
|
-
const state = {};
|
|
380
|
-
|
|
381
|
-
console.log('');
|
|
382
|
-
console.log(c(' nerviq copilot interactive wizard', 'bold'));
|
|
383
|
-
console.log(c(' ═══════════════════════════════════════', 'dim'));
|
|
384
|
-
|
|
385
|
-
let stageIndex = 0;
|
|
386
|
-
|
|
387
|
-
try {
|
|
388
|
-
while (stageIndex < STAGES.length) {
|
|
389
|
-
const result = await STAGES[stageIndex](rl, ctx, state);
|
|
390
|
-
if (result === 'quit') { rl.close(); return null; }
|
|
391
|
-
if (result === 'back') { stageIndex = Math.max(0, stageIndex - 1); continue; }
|
|
392
|
-
if (result === 'done') break;
|
|
393
|
-
stageIndex++;
|
|
394
|
-
}
|
|
395
|
-
} finally {
|
|
396
|
-
rl.close();
|
|
397
|
-
}
|
|
398
|
-
|
|
399
|
-
if (!state.confirmed) return null;
|
|
400
|
-
return state;
|
|
401
|
-
}
|
|
402
|
-
|
|
403
|
-
module.exports = {
|
|
404
|
-
runCopilotWizard,
|
|
405
|
-
runProjectDetection,
|
|
406
|
-
};
|
|
1
|
+
/**
|
|
2
|
+
* Copilot Interactive Wizard — 10-stage guided setup.
|
|
3
|
+
*
|
|
4
|
+
* Adapted for Copilot's 3-surface architecture (VS Code, cloud, CLI).
|
|
5
|
+
*
|
|
6
|
+
* Stages:
|
|
7
|
+
* 1. Project detection (stacks, existing .github/, .vscode/)
|
|
8
|
+
* 2. Surface selection (VS Code / cloud agent / both)
|
|
9
|
+
* 3. Trust & sandbox (OS-aware, Windows warning)
|
|
10
|
+
* 4. Auto-approval configuration
|
|
11
|
+
* 5. Domain pack selection
|
|
12
|
+
* 6. MCP pack selection
|
|
13
|
+
* 7. Instruction structure (repo-wide + scoped + prompts)
|
|
14
|
+
* 8. Cloud agent configuration
|
|
15
|
+
* 9. Org policy awareness
|
|
16
|
+
* 10. Review & generate
|
|
17
|
+
*/
|
|
18
|
+
|
|
19
|
+
const fs = require('fs');
|
|
20
|
+
const os = require('os');
|
|
21
|
+
const path = require('path');
|
|
22
|
+
const readline = require('readline');
|
|
23
|
+
const { STACKS } = require('../techniques');
|
|
24
|
+
const { CopilotProjectContext } = require('./context');
|
|
25
|
+
const { COPILOT_TECHNIQUES } = require('./techniques');
|
|
26
|
+
const { COPILOT_DOMAIN_PACKS, detectCopilotDomainPacks } = require('./domain-packs');
|
|
27
|
+
const { recommendCopilotMcpPacks, COPILOT_MCP_PACKS } = require('./mcp-packs');
|
|
28
|
+
|
|
29
|
+
const COLORS = {
|
|
30
|
+
reset: '\x1b[0m', bold: '\x1b[1m', dim: '\x1b[2m',
|
|
31
|
+
red: '\x1b[31m', green: '\x1b[32m', yellow: '\x1b[33m',
|
|
32
|
+
blue: '\x1b[36m', magenta: '\x1b[35m',
|
|
33
|
+
};
|
|
34
|
+
const c = (text, color) => `${COLORS[color] || ''}${text}${COLORS.reset}`;
|
|
35
|
+
|
|
36
|
+
function ask(rl, question) {
|
|
37
|
+
return new Promise(resolve => rl.question(question, resolve));
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
function isTTY() {
|
|
41
|
+
return Boolean(process.stdin.isTTY && process.stdout.isTTY);
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
const STAGE_NAMES = [
|
|
45
|
+
'Project Detection',
|
|
46
|
+
'Surface Selection',
|
|
47
|
+
'Trust & Sandbox',
|
|
48
|
+
'Auto-Approval Config',
|
|
49
|
+
'Domain Pack Selection',
|
|
50
|
+
'MCP Pack Selection',
|
|
51
|
+
'Instruction Structure',
|
|
52
|
+
'Cloud Agent Config',
|
|
53
|
+
'Org Policy Awareness',
|
|
54
|
+
'Review & Generate',
|
|
55
|
+
];
|
|
56
|
+
|
|
57
|
+
function printStageHeader(index) {
|
|
58
|
+
console.log('');
|
|
59
|
+
console.log(c(` ── Stage ${index + 1}/${STAGE_NAMES.length}: ${STAGE_NAMES[index]} ──`, 'magenta'));
|
|
60
|
+
console.log('');
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
// --- Stage 1: Project Detection ---
|
|
64
|
+
|
|
65
|
+
function runProjectDetection(ctx) {
|
|
66
|
+
const stacks = ctx.detectStacks(STACKS);
|
|
67
|
+
const hasCopilotInstructions = Boolean(ctx.copilotInstructionsContent());
|
|
68
|
+
const hasVscodeSettings = Boolean(ctx.fileContent('.vscode/settings.json'));
|
|
69
|
+
const hasMcpJson = Boolean(ctx.fileContent('.vscode/mcp.json'));
|
|
70
|
+
const hasCloudSetup = Boolean(ctx.cloudAgentConfig());
|
|
71
|
+
const surfaces = ctx.detectSurfaces();
|
|
72
|
+
|
|
73
|
+
const auditResults = [];
|
|
74
|
+
for (const [key, technique] of Object.entries(COPILOT_TECHNIQUES)) {
|
|
75
|
+
auditResults.push({ key, ...technique, passed: technique.check(ctx) });
|
|
76
|
+
}
|
|
77
|
+
const passed = auditResults.filter(r => r.passed === true);
|
|
78
|
+
const failed = auditResults.filter(r => r.passed === false);
|
|
79
|
+
|
|
80
|
+
return { stacks, hasCopilotInstructions, hasVscodeSettings, hasMcpJson, hasCloudSetup, surfaces, auditResults, passed, failed };
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
async function stageProjectDetection(rl, ctx, state) {
|
|
84
|
+
printStageHeader(0);
|
|
85
|
+
const det = runProjectDetection(ctx);
|
|
86
|
+
Object.assign(state, det);
|
|
87
|
+
|
|
88
|
+
if (det.stacks.length > 0) console.log(c(` Detected stacks: ${det.stacks.map(s => s.label).join(', ')}`, 'blue'));
|
|
89
|
+
else console.log(c(' No specific stack detected — will use baseline defaults.', 'dim'));
|
|
90
|
+
|
|
91
|
+
console.log(c(` Working directory: ${ctx.dir}`, 'dim'));
|
|
92
|
+
console.log('');
|
|
93
|
+
console.log(` ${c(`${det.passed.length}/${det.auditResults.length}`, 'bold')} Copilot checks passing.`);
|
|
94
|
+
console.log(` ${c(String(det.failed.length), 'yellow')} improvements available.`);
|
|
95
|
+
console.log('');
|
|
96
|
+
console.log(` Surfaces: VS Code ${det.surfaces.vscode ? c('Y', 'green') : c('N', 'red')} | Cloud ${det.surfaces.cloudAgent ? c('Y', 'green') : c('N', 'red')} | CLI ${det.surfaces.cli ? c('Y', 'green') : c('N', 'red')}`);
|
|
97
|
+
|
|
98
|
+
if (det.hasCopilotInstructions || det.hasVscodeSettings) {
|
|
99
|
+
console.log('');
|
|
100
|
+
console.log(c(' Existing Copilot configuration detected:', 'yellow'));
|
|
101
|
+
if (det.hasCopilotInstructions) console.log(c(' .github/copilot-instructions.md found', 'dim'));
|
|
102
|
+
if (det.hasVscodeSettings) console.log(c(' .vscode/settings.json found', 'dim'));
|
|
103
|
+
if (det.hasMcpJson) console.log(c(' .vscode/mcp.json found', 'dim'));
|
|
104
|
+
if (det.hasCloudSetup) console.log(c(' copilot-setup-steps.yml found', 'dim'));
|
|
105
|
+
console.log('');
|
|
106
|
+
|
|
107
|
+
const answer = await ask(rl, c(' Merge with existing config or replace? (merge/replace/quit) ', 'magenta'));
|
|
108
|
+
const choice = answer.trim().toLowerCase();
|
|
109
|
+
if (choice === 'quit' || choice === 'q') return 'quit';
|
|
110
|
+
state.migrationMode = choice === 'replace' ? 'replace' : 'merge';
|
|
111
|
+
} else {
|
|
112
|
+
state.migrationMode = 'create';
|
|
113
|
+
console.log('');
|
|
114
|
+
console.log(c(' No existing Copilot config — will create fresh setup.', 'dim'));
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
return 'next';
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
// --- Stage 2: Surface Selection ---
|
|
121
|
+
|
|
122
|
+
async function stageSurfaceSelection(rl, _ctx, state) {
|
|
123
|
+
printStageHeader(1);
|
|
124
|
+
|
|
125
|
+
console.log(' Which Copilot surfaces do you want to configure?');
|
|
126
|
+
console.log('');
|
|
127
|
+
console.log(` ${c('1', 'bold')}. ${c('VS Code only', 'blue')} — Local IDE agent mode.`);
|
|
128
|
+
console.log(` ${c('2', 'bold')}. ${c('VS Code + Cloud agent', 'blue')} — IDE + GitHub cloud agent for automated tasks.`);
|
|
129
|
+
console.log(` ${c('3', 'bold')}. ${c('All surfaces', 'blue')} — VS Code + Cloud + CLI.`);
|
|
130
|
+
console.log('');
|
|
131
|
+
|
|
132
|
+
const answer = await ask(rl, c(' Choice (1-3, or b=back, q=quit) [2]: ', 'magenta'));
|
|
133
|
+
const trimmed = answer.trim().toLowerCase();
|
|
134
|
+
if (trimmed === 'b') return 'back';
|
|
135
|
+
if (trimmed === 'q') return 'quit';
|
|
136
|
+
|
|
137
|
+
const index = parseInt(trimmed, 10);
|
|
138
|
+
const surfaceChoices = { 1: ['vscode'], 2: ['vscode', 'cloud'], 3: ['vscode', 'cloud', 'cli'] };
|
|
139
|
+
state.selectedSurfaces = surfaceChoices[index] || surfaceChoices[2];
|
|
140
|
+
console.log(c(` → Surfaces: ${state.selectedSurfaces.join(', ')}`, 'green'));
|
|
141
|
+
|
|
142
|
+
return 'next';
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
// --- Stage 3: Trust & Sandbox ---
|
|
146
|
+
|
|
147
|
+
async function stageTrustSandbox(rl, _ctx, state) {
|
|
148
|
+
printStageHeader(2);
|
|
149
|
+
|
|
150
|
+
const detectedOS = os.platform() === 'darwin' ? 'macOS' : os.platform() === 'linux' ? 'Linux' : os.platform() === 'win32' ? 'Windows' : os.platform();
|
|
151
|
+
state.detectedOS = detectedOS;
|
|
152
|
+
|
|
153
|
+
console.log(c(` Detected OS: ${detectedOS}`, 'blue'));
|
|
154
|
+
if (detectedOS === 'Windows') {
|
|
155
|
+
console.log('');
|
|
156
|
+
console.log(c(' WARNING: Terminal sandbox is NOT available on native Windows!', 'red'));
|
|
157
|
+
console.log(c(' Consider using WSL2 or Docker for sandboxed Copilot agent execution.', 'yellow'));
|
|
158
|
+
}
|
|
159
|
+
console.log('');
|
|
160
|
+
console.log(' Enable terminal sandbox? (Recommended for macOS/Linux/WSL2)');
|
|
161
|
+
console.log('');
|
|
162
|
+
|
|
163
|
+
const answer = await ask(rl, c(` Enable sandbox? (y/n, or b=back, q=quit) [${detectedOS === 'Windows' ? 'n' : 'y'}]: `, 'magenta'));
|
|
164
|
+
const trimmed = answer.trim().toLowerCase();
|
|
165
|
+
if (trimmed === 'b') return 'back';
|
|
166
|
+
if (trimmed === 'q') return 'quit';
|
|
167
|
+
|
|
168
|
+
state.sandboxEnabled = trimmed === 'y' || (trimmed === '' && detectedOS !== 'Windows');
|
|
169
|
+
console.log(c(` → Sandbox: ${state.sandboxEnabled ? 'enabled' : 'disabled'}`, state.sandboxEnabled ? 'green' : 'yellow'));
|
|
170
|
+
|
|
171
|
+
return 'next';
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
// --- Stage 4: Auto-Approval ---
|
|
175
|
+
|
|
176
|
+
async function stageAutoApproval(rl, _ctx, state) {
|
|
177
|
+
printStageHeader(3);
|
|
178
|
+
|
|
179
|
+
console.log(' Configure auto-approval for terminal commands?');
|
|
180
|
+
console.log('');
|
|
181
|
+
console.log(` ${c('1', 'bold')}. ${c('No auto-approval', 'blue')} — All commands require confirmation (safest).`);
|
|
182
|
+
console.log(` ${c('2', 'bold')}. ${c('Safe commands only', 'blue')} — Auto-approve test/lint/build patterns.`);
|
|
183
|
+
console.log(` ${c('3', 'bold')}. ${c('Custom patterns', 'blue')} — Enter your own auto-approval patterns.`);
|
|
184
|
+
console.log('');
|
|
185
|
+
|
|
186
|
+
const answer = await ask(rl, c(' Choice (1-3, or b=back, q=quit) [1]: ', 'magenta'));
|
|
187
|
+
const trimmed = answer.trim().toLowerCase();
|
|
188
|
+
if (trimmed === 'b') return 'back';
|
|
189
|
+
if (trimmed === 'q') return 'quit';
|
|
190
|
+
|
|
191
|
+
const choice = parseInt(trimmed, 10);
|
|
192
|
+
if (choice === 2) {
|
|
193
|
+
state.autoApprovalPatterns = ['npm test', 'npm run lint', 'npm run build'];
|
|
194
|
+
} else if (choice === 3) {
|
|
195
|
+
const patterns = await ask(rl, c(' Enter patterns (comma-separated): ', 'magenta'));
|
|
196
|
+
state.autoApprovalPatterns = patterns.split(',').map(p => p.trim()).filter(Boolean);
|
|
197
|
+
} else {
|
|
198
|
+
state.autoApprovalPatterns = [];
|
|
199
|
+
}
|
|
200
|
+
|
|
201
|
+
console.log(c(` → Auto-approval: ${state.autoApprovalPatterns.length === 0 ? 'none' : state.autoApprovalPatterns.join(', ')}`, 'green'));
|
|
202
|
+
return 'next';
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
// --- Stage 5: Domain Pack Selection ---
|
|
206
|
+
|
|
207
|
+
async function stageDomainPacks(rl, ctx, state) {
|
|
208
|
+
printStageHeader(4);
|
|
209
|
+
|
|
210
|
+
const detected = detectCopilotDomainPacks(ctx, state.stacks || []);
|
|
211
|
+
state.domainPacks = detected;
|
|
212
|
+
|
|
213
|
+
console.log(` Detected ${detected.length} domain pack(s):`);
|
|
214
|
+
console.log('');
|
|
215
|
+
detected.forEach((pack, i) => {
|
|
216
|
+
console.log(` ${c(`${i + 1}`, 'bold')}. ${c(pack.label, 'blue')} — ${pack.matchReasons[0] || pack.useWhen}`);
|
|
217
|
+
});
|
|
218
|
+
console.log('');
|
|
219
|
+
|
|
220
|
+
const answer = await ask(rl, c(' Accept detected packs? (y/n, or b=back, q=quit) [y]: ', 'magenta'));
|
|
221
|
+
const trimmed = answer.trim().toLowerCase();
|
|
222
|
+
if (trimmed === 'b') return 'back';
|
|
223
|
+
if (trimmed === 'q') return 'quit';
|
|
224
|
+
if (trimmed === 'n') state.domainPacks = [];
|
|
225
|
+
|
|
226
|
+
console.log(c(` → Domain packs: ${state.domainPacks.map(p => p.label).join(', ') || 'none'}`, 'green'));
|
|
227
|
+
return 'next';
|
|
228
|
+
}
|
|
229
|
+
|
|
230
|
+
// --- Stage 6: MCP Pack Selection ---
|
|
231
|
+
|
|
232
|
+
async function stageMcpPacks(rl, ctx, state) {
|
|
233
|
+
printStageHeader(5);
|
|
234
|
+
|
|
235
|
+
const cloudOnly = state.selectedSurfaces && !state.selectedSurfaces.includes('vscode');
|
|
236
|
+
const recommended = recommendCopilotMcpPacks(state.stacks || [], state.domainPacks || [], { ctx, cloudOnly });
|
|
237
|
+
state.mcpPacks = recommended;
|
|
238
|
+
|
|
239
|
+
console.log(` Recommended ${recommended.length} MCP pack(s):`);
|
|
240
|
+
console.log('');
|
|
241
|
+
recommended.forEach((pack, i) => {
|
|
242
|
+
const cloudIcon = pack.cloudAgentCompatible === false ? c(' [VS Code only]', 'yellow') : '';
|
|
243
|
+
console.log(` ${c(`${i + 1}`, 'bold')}. ${c(pack.label, 'blue')}${cloudIcon} — ${pack.description}`);
|
|
244
|
+
});
|
|
245
|
+
console.log('');
|
|
246
|
+
|
|
247
|
+
const answer = await ask(rl, c(' Accept recommended packs? (y/n, or b=back, q=quit) [y]: ', 'magenta'));
|
|
248
|
+
const trimmed = answer.trim().toLowerCase();
|
|
249
|
+
if (trimmed === 'b') return 'back';
|
|
250
|
+
if (trimmed === 'q') return 'quit';
|
|
251
|
+
if (trimmed === 'n') state.mcpPacks = [];
|
|
252
|
+
|
|
253
|
+
console.log(c(` → MCP packs: ${state.mcpPacks.map(p => p.label).join(', ') || 'none'}`, 'green'));
|
|
254
|
+
return 'next';
|
|
255
|
+
}
|
|
256
|
+
|
|
257
|
+
// --- Stage 7: Instruction Structure ---
|
|
258
|
+
|
|
259
|
+
async function stageInstructionStructure(rl, _ctx, state) {
|
|
260
|
+
printStageHeader(6);
|
|
261
|
+
|
|
262
|
+
console.log(' What instruction structure do you want?');
|
|
263
|
+
console.log('');
|
|
264
|
+
console.log(` ${c('1', 'bold')}. ${c('Basic', 'blue')} — copilot-instructions.md only.`);
|
|
265
|
+
console.log(` ${c('2', 'bold')}. ${c('Scoped', 'blue')} — copilot-instructions.md + path-scoped .instructions.md files.`);
|
|
266
|
+
console.log(` ${c('3', 'bold')}. ${c('Full', 'blue')} — All of the above + prompt templates (.prompt.md).`);
|
|
267
|
+
console.log('');
|
|
268
|
+
|
|
269
|
+
const answer = await ask(rl, c(' Choice (1-3, or b=back, q=quit) [3]: ', 'magenta'));
|
|
270
|
+
const trimmed = answer.trim().toLowerCase();
|
|
271
|
+
if (trimmed === 'b') return 'back';
|
|
272
|
+
if (trimmed === 'q') return 'quit';
|
|
273
|
+
|
|
274
|
+
const choice = parseInt(trimmed, 10);
|
|
275
|
+
state.instructionModules = ['copilot-instructions'];
|
|
276
|
+
if (choice >= 2 || trimmed === '') state.instructionModules.push('scoped-instructions');
|
|
277
|
+
if (choice >= 3 || trimmed === '') state.instructionModules.push('prompts');
|
|
278
|
+
|
|
279
|
+
console.log(c(` → Instructions: ${state.instructionModules.join(', ')}`, 'green'));
|
|
280
|
+
return 'next';
|
|
281
|
+
}
|
|
282
|
+
|
|
283
|
+
// --- Stage 8: Cloud Agent Config ---
|
|
284
|
+
|
|
285
|
+
async function stageCloudAgent(rl, _ctx, state) {
|
|
286
|
+
if (!state.selectedSurfaces || !state.selectedSurfaces.includes('cloud')) return 'next';
|
|
287
|
+
|
|
288
|
+
printStageHeader(7);
|
|
289
|
+
|
|
290
|
+
console.log(' Cloud agent configuration:');
|
|
291
|
+
console.log('');
|
|
292
|
+
console.log(c(' Important: Cloud agent cold-boot takes ~90 seconds.', 'yellow'));
|
|
293
|
+
console.log(c(' Content exclusions are NOT enforced on the cloud agent.', 'red'));
|
|
294
|
+
console.log('');
|
|
295
|
+
|
|
296
|
+
const answer = await ask(rl, c(' Generate copilot-setup-steps.yml? (y/n, or b=back, q=quit) [y]: ', 'magenta'));
|
|
297
|
+
const trimmed = answer.trim().toLowerCase();
|
|
298
|
+
if (trimmed === 'b') return 'back';
|
|
299
|
+
if (trimmed === 'q') return 'quit';
|
|
300
|
+
|
|
301
|
+
state.generateCloudSetup = trimmed !== 'n';
|
|
302
|
+
console.log(c(` → Cloud setup: ${state.generateCloudSetup ? 'will generate' : 'skip'}`, 'green'));
|
|
303
|
+
return 'next';
|
|
304
|
+
}
|
|
305
|
+
|
|
306
|
+
// --- Stage 9: Org Policy Awareness ---
|
|
307
|
+
|
|
308
|
+
async function stageOrgPolicy(rl, _ctx, state) {
|
|
309
|
+
printStageHeader(8);
|
|
310
|
+
|
|
311
|
+
console.log(' Is this repo part of a GitHub Organization with Copilot policies?');
|
|
312
|
+
console.log('');
|
|
313
|
+
console.log(` ${c('1', 'bold')}. ${c('No / Unknown', 'blue')} — Individual or personal repo.`);
|
|
314
|
+
console.log(` ${c('2', 'bold')}. ${c('Yes (Business)', 'blue')} — Org with Business plan and policies.`);
|
|
315
|
+
console.log(` ${c('3', 'bold')}. ${c('Yes (Enterprise)', 'blue')} — Enterprise with audit logs, BYOK, full governance.`);
|
|
316
|
+
console.log('');
|
|
317
|
+
|
|
318
|
+
const answer = await ask(rl, c(' Choice (1-3, or b=back, q=quit) [1]: ', 'magenta'));
|
|
319
|
+
const trimmed = answer.trim().toLowerCase();
|
|
320
|
+
if (trimmed === 'b') return 'back';
|
|
321
|
+
if (trimmed === 'q') return 'quit';
|
|
322
|
+
|
|
323
|
+
const choice = parseInt(trimmed, 10);
|
|
324
|
+
state.orgTier = choice === 3 ? 'enterprise' : choice === 2 ? 'business' : 'individual';
|
|
325
|
+
console.log(c(` → Org tier: ${state.orgTier}`, 'green'));
|
|
326
|
+
return 'next';
|
|
327
|
+
}
|
|
328
|
+
|
|
329
|
+
// --- Stage 10: Review & Generate ---
|
|
330
|
+
|
|
331
|
+
async function stageReviewGenerate(rl, _ctx, state) {
|
|
332
|
+
printStageHeader(9);
|
|
333
|
+
|
|
334
|
+
console.log(' Summary of your Copilot setup:');
|
|
335
|
+
console.log('');
|
|
336
|
+
console.log(` Surfaces: ${(state.selectedSurfaces || []).join(', ')}`);
|
|
337
|
+
console.log(` Sandbox: ${state.sandboxEnabled ? 'enabled' : 'disabled'}`);
|
|
338
|
+
console.log(` Auto-approval: ${(state.autoApprovalPatterns || []).length === 0 ? 'none' : (state.autoApprovalPatterns || []).join(', ')}`);
|
|
339
|
+
console.log(` Domain packs: ${(state.domainPacks || []).map(p => p.label).join(', ') || 'none'}`);
|
|
340
|
+
console.log(` MCP packs: ${(state.mcpPacks || []).map(p => p.label).join(', ') || 'none'}`);
|
|
341
|
+
console.log(` Instructions: ${(state.instructionModules || []).join(', ')}`);
|
|
342
|
+
console.log(` Cloud setup: ${state.generateCloudSetup ? 'yes' : 'no'}`);
|
|
343
|
+
console.log(` Org tier: ${state.orgTier || 'individual'}`);
|
|
344
|
+
console.log('');
|
|
345
|
+
|
|
346
|
+
const answer = await ask(rl, c(' Generate files? (y/n, or b=back, q=quit) [y]: ', 'magenta'));
|
|
347
|
+
const trimmed = answer.trim().toLowerCase();
|
|
348
|
+
if (trimmed === 'b') return 'back';
|
|
349
|
+
if (trimmed === 'q') return 'quit';
|
|
350
|
+
if (trimmed === 'n') return 'quit';
|
|
351
|
+
|
|
352
|
+
state.confirmed = true;
|
|
353
|
+
return 'done';
|
|
354
|
+
}
|
|
355
|
+
|
|
356
|
+
// --- Main Wizard ---
|
|
357
|
+
|
|
358
|
+
const STAGES = [
|
|
359
|
+
stageProjectDetection,
|
|
360
|
+
stageSurfaceSelection,
|
|
361
|
+
stageTrustSandbox,
|
|
362
|
+
stageAutoApproval,
|
|
363
|
+
stageDomainPacks,
|
|
364
|
+
stageMcpPacks,
|
|
365
|
+
stageInstructionStructure,
|
|
366
|
+
stageCloudAgent,
|
|
367
|
+
stageOrgPolicy,
|
|
368
|
+
stageReviewGenerate,
|
|
369
|
+
];
|
|
370
|
+
|
|
371
|
+
async function runCopilotWizard(options) {
|
|
372
|
+
if (!isTTY()) {
|
|
373
|
+
console.log('Interactive wizard requires a TTY. Use --non-interactive or pipe mode instead.');
|
|
374
|
+
return null;
|
|
375
|
+
}
|
|
376
|
+
|
|
377
|
+
const rl = readline.createInterface({ input: process.stdin, output: process.stdout });
|
|
378
|
+
const ctx = new CopilotProjectContext(options.dir);
|
|
379
|
+
const state = {};
|
|
380
|
+
|
|
381
|
+
console.log('');
|
|
382
|
+
console.log(c(' nerviq copilot interactive wizard', 'bold'));
|
|
383
|
+
console.log(c(' ═══════════════════════════════════════', 'dim'));
|
|
384
|
+
|
|
385
|
+
let stageIndex = 0;
|
|
386
|
+
|
|
387
|
+
try {
|
|
388
|
+
while (stageIndex < STAGES.length) {
|
|
389
|
+
const result = await STAGES[stageIndex](rl, ctx, state);
|
|
390
|
+
if (result === 'quit') { rl.close(); return null; }
|
|
391
|
+
if (result === 'back') { stageIndex = Math.max(0, stageIndex - 1); continue; }
|
|
392
|
+
if (result === 'done') break;
|
|
393
|
+
stageIndex++;
|
|
394
|
+
}
|
|
395
|
+
} finally {
|
|
396
|
+
rl.close();
|
|
397
|
+
}
|
|
398
|
+
|
|
399
|
+
if (!state.confirmed) return null;
|
|
400
|
+
return state;
|
|
401
|
+
}
|
|
402
|
+
|
|
403
|
+
module.exports = {
|
|
404
|
+
runCopilotWizard,
|
|
405
|
+
runProjectDetection,
|
|
406
|
+
};
|