@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,222 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copilot Governance Module
|
|
3
|
+
*
|
|
4
|
+
* 6 permission profiles, 7 hook equivalents, 5 policy packs.
|
|
5
|
+
*
|
|
6
|
+
* Copilot-specific differences from Gemini/Codex:
|
|
7
|
+
* - Org policies are admin-managed, not file-based
|
|
8
|
+
* - 3 separate surfaces (VS Code, cloud, CLI) with different trust models
|
|
9
|
+
* - Terminal sandbox is macOS/Linux/WSL2 only (NOT native Windows)
|
|
10
|
+
* - Content exclusions are glob-based, NOT enforced on cloud agent
|
|
11
|
+
*/
|
|
12
|
+
|
|
13
|
+
const { COPILOT_DOMAIN_PACKS } = require('./domain-packs');
|
|
14
|
+
const { COPILOT_MCP_PACKS } = require('./mcp-packs');
|
|
15
|
+
|
|
16
|
+
const COPILOT_PERMISSION_PROFILES = [
|
|
17
|
+
{
|
|
18
|
+
key: 'locked-down',
|
|
19
|
+
label: 'Locked Down',
|
|
20
|
+
risk: 'low',
|
|
21
|
+
defaultSandbox: 'terminal-sandbox-enabled',
|
|
22
|
+
approvalPolicy: 'always-confirm',
|
|
23
|
+
useWhen: 'First contact with a repo, security review, or regulated environments.',
|
|
24
|
+
behavior: 'Terminal sandbox enabled, no auto-approval, content exclusions active. All tool calls require user confirmation.',
|
|
25
|
+
surfaces: ['vscode'],
|
|
26
|
+
},
|
|
27
|
+
{
|
|
28
|
+
key: 'standard',
|
|
29
|
+
label: 'Standard',
|
|
30
|
+
risk: 'medium',
|
|
31
|
+
defaultSandbox: 'terminal-sandbox-enabled',
|
|
32
|
+
approvalPolicy: 'selective-approval',
|
|
33
|
+
useWhen: 'Default product work where Copilot edits locally but risky commands still need review.',
|
|
34
|
+
behavior: 'Terminal sandbox enabled. Specific safe commands (test, lint) can be auto-approved. Edits require confirmation.',
|
|
35
|
+
surfaces: ['vscode'],
|
|
36
|
+
},
|
|
37
|
+
{
|
|
38
|
+
key: 'agent-mode',
|
|
39
|
+
label: 'Agent Mode',
|
|
40
|
+
risk: 'medium',
|
|
41
|
+
defaultSandbox: 'terminal-sandbox-enabled',
|
|
42
|
+
approvalPolicy: 'auto-approve-safe',
|
|
43
|
+
useWhen: 'Trusted repos where Copilot agent mode is the primary workflow.',
|
|
44
|
+
behavior: 'Full agent mode enabled. Auto-approval for safe terminal patterns. Terminal sandbox protects against escapes.',
|
|
45
|
+
surfaces: ['vscode'],
|
|
46
|
+
},
|
|
47
|
+
{
|
|
48
|
+
key: 'cloud-agent',
|
|
49
|
+
label: 'Cloud Agent',
|
|
50
|
+
risk: 'high',
|
|
51
|
+
defaultSandbox: 'ephemeral-vm',
|
|
52
|
+
approvalPolicy: 'pr-gate',
|
|
53
|
+
useWhen: 'Cloud agent tasks assigned via GitHub Issues. Ephemeral VM provides containment.',
|
|
54
|
+
behavior: 'Runs on GitHub Actions runner (Ubuntu). PRs created for review. Content exclusions NOT enforced. Cold-boot ~90 seconds.',
|
|
55
|
+
surfaces: ['cloud'],
|
|
56
|
+
},
|
|
57
|
+
{
|
|
58
|
+
key: 'enterprise-managed',
|
|
59
|
+
label: 'Enterprise Managed',
|
|
60
|
+
risk: 'low',
|
|
61
|
+
defaultSandbox: 'org-policy-enforced',
|
|
62
|
+
approvalPolicy: 'org-admin-controlled',
|
|
63
|
+
useWhen: 'Enterprise tier with org-level policies, audit logs, and model access controls.',
|
|
64
|
+
behavior: 'Admin-managed policies override individual settings. Audit logs enabled. MCP allowlist enforced. BYOK optional.',
|
|
65
|
+
surfaces: ['vscode', 'cloud', 'cli'],
|
|
66
|
+
},
|
|
67
|
+
{
|
|
68
|
+
key: 'no-sandbox-windows',
|
|
69
|
+
label: 'No Sandbox (Windows)',
|
|
70
|
+
risk: 'critical',
|
|
71
|
+
defaultSandbox: 'none',
|
|
72
|
+
approvalPolicy: 'always-confirm',
|
|
73
|
+
useWhen: 'Native Windows environment where terminal sandbox is unavailable.',
|
|
74
|
+
behavior: 'Terminal sandbox NOT available on native Windows. All terminal commands must be manually reviewed. Consider WSL2 for sandboxed execution.',
|
|
75
|
+
surfaces: ['vscode'],
|
|
76
|
+
},
|
|
77
|
+
];
|
|
78
|
+
|
|
79
|
+
const COPILOT_HOOK_REGISTRY = [
|
|
80
|
+
{
|
|
81
|
+
key: 'auto-approval-terminal',
|
|
82
|
+
file: '.vscode/settings.json',
|
|
83
|
+
triggerPoint: 'chat.agent.autoApproval.terminalCommands',
|
|
84
|
+
matcher: 'terminal command patterns',
|
|
85
|
+
purpose: 'Auto-approve specific terminal command patterns without user confirmation.',
|
|
86
|
+
risk: 'high',
|
|
87
|
+
},
|
|
88
|
+
{
|
|
89
|
+
key: 'auto-approval-tools',
|
|
90
|
+
file: '.vscode/settings.json',
|
|
91
|
+
triggerPoint: 'chat.agent.autoApproval.tools',
|
|
92
|
+
matcher: 'tool name patterns',
|
|
93
|
+
purpose: 'Auto-approve specific tool invocations in agent mode.',
|
|
94
|
+
risk: 'high',
|
|
95
|
+
},
|
|
96
|
+
{
|
|
97
|
+
key: 'review-instructions',
|
|
98
|
+
file: '.vscode/settings.json',
|
|
99
|
+
triggerPoint: 'github.copilot.chat.reviewSelection.instructions',
|
|
100
|
+
matcher: 'code review context',
|
|
101
|
+
purpose: 'Inject custom review instructions when Copilot reviews selected code.',
|
|
102
|
+
risk: 'low',
|
|
103
|
+
},
|
|
104
|
+
{
|
|
105
|
+
key: 'commit-message-instructions',
|
|
106
|
+
file: '.vscode/settings.json',
|
|
107
|
+
triggerPoint: 'github.copilot.chat.commitMessageGeneration.instructions',
|
|
108
|
+
matcher: 'commit context',
|
|
109
|
+
purpose: 'Guide commit message generation format and conventions.',
|
|
110
|
+
risk: 'low',
|
|
111
|
+
},
|
|
112
|
+
{
|
|
113
|
+
key: 'pr-description-instructions',
|
|
114
|
+
file: '.vscode/settings.json',
|
|
115
|
+
triggerPoint: 'github.copilot.chat.pullRequestDescriptionGeneration.instructions',
|
|
116
|
+
matcher: 'PR context',
|
|
117
|
+
purpose: 'Guide pull request description generation.',
|
|
118
|
+
risk: 'low',
|
|
119
|
+
},
|
|
120
|
+
{
|
|
121
|
+
key: 'content-exclusion',
|
|
122
|
+
file: 'org-admin-settings',
|
|
123
|
+
triggerPoint: 'content-exclusion-patterns',
|
|
124
|
+
matcher: 'file glob patterns',
|
|
125
|
+
purpose: 'Prevent Copilot from reading sensitive files. NOTE: Not enforced on cloud agent.',
|
|
126
|
+
risk: 'medium',
|
|
127
|
+
},
|
|
128
|
+
{
|
|
129
|
+
key: 'cloud-setup-steps',
|
|
130
|
+
file: '.github/workflows/copilot-setup-steps.yml',
|
|
131
|
+
triggerPoint: 'cloud-agent-boot',
|
|
132
|
+
matcher: 'environment setup',
|
|
133
|
+
purpose: 'Configure cloud agent environment: install dependencies, set env vars, prepare test commands.',
|
|
134
|
+
risk: 'medium',
|
|
135
|
+
},
|
|
136
|
+
];
|
|
137
|
+
|
|
138
|
+
const COPILOT_POLICY_PACKS = [
|
|
139
|
+
{
|
|
140
|
+
key: 'baseline-safe',
|
|
141
|
+
label: 'Baseline Safe',
|
|
142
|
+
modules: ['copilot-instructions.md baseline', 'sandbox enabled', 'no wildcard auto-approval', 'content exclusions for .env'],
|
|
143
|
+
useWhen: 'Default local Copilot rollout.',
|
|
144
|
+
},
|
|
145
|
+
{
|
|
146
|
+
key: 'cloud-agent-safe',
|
|
147
|
+
label: 'Cloud Agent Safe',
|
|
148
|
+
modules: ['copilot-setup-steps.yml configured', 'PR review gate', 'content exclusion gap documented', 'signed commits enabled'],
|
|
149
|
+
useWhen: 'Repos using the Copilot cloud agent for automated tasks.',
|
|
150
|
+
},
|
|
151
|
+
{
|
|
152
|
+
key: 'multi-surface-consistent',
|
|
153
|
+
label: 'Multi-Surface Consistent',
|
|
154
|
+
modules: ['instructions consistent across surfaces', 'MCP aligned across surfaces', 'security posture consistent'],
|
|
155
|
+
useWhen: 'Repos using both VS Code agent and cloud agent.',
|
|
156
|
+
},
|
|
157
|
+
{
|
|
158
|
+
key: 'enterprise-governed',
|
|
159
|
+
label: 'Enterprise Governed',
|
|
160
|
+
modules: ['org policies configured', 'audit logs enabled', 'MCP allowlist', 'model access policy', 'data training opt-out'],
|
|
161
|
+
useWhen: 'Enterprise/Business tier repos with strict governance requirements.',
|
|
162
|
+
},
|
|
163
|
+
{
|
|
164
|
+
key: 'privacy-first',
|
|
165
|
+
label: 'Privacy First',
|
|
166
|
+
modules: ['content exclusions active', 'data training opt-out', 'no secrets in instructions', 'cloud gap documented'],
|
|
167
|
+
useWhen: 'Repos handling sensitive data (PII, PHI, financial) where data privacy is paramount.',
|
|
168
|
+
},
|
|
169
|
+
];
|
|
170
|
+
|
|
171
|
+
const COPILOT_PILOT_ROLLOUT_KIT = {
|
|
172
|
+
recommendedScope: [
|
|
173
|
+
'Start with audit and setup on one trusted repo before enabling cloud agent.',
|
|
174
|
+
'Keep copilot-instructions.md and .vscode/settings.json in version control.',
|
|
175
|
+
'Test cloud agent on a non-critical repo first (90s cold-boot per task).',
|
|
176
|
+
'Document content exclusion limitations for the team.',
|
|
177
|
+
'If on Windows, document that terminal sandbox is unavailable.',
|
|
178
|
+
],
|
|
179
|
+
approvals: [
|
|
180
|
+
'Engineering owner approves sandbox mode and auto-approval patterns.',
|
|
181
|
+
'Security owner approves content exclusion configuration and cloud agent usage.',
|
|
182
|
+
'Pilot owner records before/after audit deltas and rollback expectations.',
|
|
183
|
+
'Org admin approves third-party agent policy and MCP allowlist.',
|
|
184
|
+
],
|
|
185
|
+
successMetrics: [
|
|
186
|
+
'Audit score delta',
|
|
187
|
+
'Surface coverage (VS Code + cloud + CLI)',
|
|
188
|
+
'Time to first useful Copilot agent task',
|
|
189
|
+
'No-overwrite rate on existing repo files',
|
|
190
|
+
'Content exclusion coverage for sensitive paths',
|
|
191
|
+
],
|
|
192
|
+
rollbackExpectations: [
|
|
193
|
+
'Every Copilot setup/apply write path should emit a rollback artifact.',
|
|
194
|
+
'Re-run audit after rollback to confirm the repo returned to the expected state.',
|
|
195
|
+
'Cloud agent can be disabled via org settings without affecting VS Code config.',
|
|
196
|
+
],
|
|
197
|
+
};
|
|
198
|
+
|
|
199
|
+
function getCopilotGovernanceSummary() {
|
|
200
|
+
return {
|
|
201
|
+
platform: 'copilot',
|
|
202
|
+
platformLabel: 'GitHub Copilot',
|
|
203
|
+
permissionProfiles: COPILOT_PERMISSION_PROFILES,
|
|
204
|
+
hookRegistry: COPILOT_HOOK_REGISTRY,
|
|
205
|
+
policyPacks: COPILOT_POLICY_PACKS,
|
|
206
|
+
domainPacks: COPILOT_DOMAIN_PACKS,
|
|
207
|
+
mcpPacks: COPILOT_MCP_PACKS,
|
|
208
|
+
pilotRolloutKit: COPILOT_PILOT_ROLLOUT_KIT,
|
|
209
|
+
platformCaveats: [
|
|
210
|
+
{ id: 'cloud-content-exclusion', severity: 'critical', message: 'Content exclusions are NOT enforced on the cloud agent.' },
|
|
211
|
+
{ id: 'cold-boot', severity: 'medium', message: 'Cloud agent cold-boot takes ~90 seconds per task.' },
|
|
212
|
+
{ id: 'no-windows-sandbox', severity: 'high', message: 'Terminal sandbox is unavailable on native Windows. macOS/Linux/WSL2 only.' },
|
|
213
|
+
{ id: 'data-training', severity: 'medium', message: 'Interaction data used for training since April 24, 2026 (opt-out required on Free/Pro/Pro+).' },
|
|
214
|
+
{ id: 'agents-md-off', severity: 'high', message: 'AGENTS.md support is off by default in VS Code — must be explicitly enabled.' },
|
|
215
|
+
{ id: 'deprecated-codegen', severity: 'medium', message: 'codeGeneration.instructions is deprecated since VS Code 1.102 — silently ignored.' },
|
|
216
|
+
],
|
|
217
|
+
};
|
|
218
|
+
}
|
|
219
|
+
|
|
220
|
+
module.exports = {
|
|
221
|
+
getCopilotGovernanceSummary,
|
|
222
|
+
};
|
|
@@ -0,0 +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
|
+
};
|