Ver código fonte

fix(installer): warn that copilot-vscode global installs need an open folder

VS Code refuses to start a user-level MCP server whose entry uses
${workspaceFolder} in a window with no folder open, surfacing only a
cryptic "Variable workspaceFolder can not be resolved" toast (hit live
during validation). Global installs now note this up front.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Colby McHenry 1 mês atrás
pai
commit
73313213e1

+ 10 - 0
__tests__/installer-targets.test.ts

@@ -2095,6 +2095,16 @@ describe('Installer targets — Copilot family', () => {
     expect(result.notes?.join(' ')).toMatch(/[Rr]estart VS Code/);
   });
 
+  it('copilot-vscode: global install warns that ${workspaceFolder} needs an open folder; local does not', () => {
+    const t = getTarget('copilot-vscode')!;
+    // VS Code refuses to start a user-level server whose entry uses
+    // ${workspaceFolder} when no folder is open — surface that up front.
+    const globalNotes = t.install('global', { autoAllow: true }).notes?.join(' ');
+    expect(globalNotes).toMatch(/open a folder/i);
+    const localNotes = t.install('local', { autoAllow: true }).notes?.join(' ');
+    expect(localNotes).not.toMatch(/open a folder/i);
+  });
+
   // ---- copilot-cli ----
 
   it('copilot-cli: global install writes ~/.copilot/mcp-config.json with the documented entry shape (tools: ["*"])', () => {

+ 8 - 1
src/installer/targets/copilot-vscode.ts

@@ -127,9 +127,16 @@ class CopilotVscodeTarget implements AgentTarget {
   }
 
   install(loc: Location, _opts: InstallOptions): WriteResult {
+    const notes = ['Restart VS Code for MCP changes to take effect.'];
+    if (loc === 'global') {
+      // The global entry pins --path via ${workspaceFolder}; VS Code
+      // refuses to start it in a window with no folder open, with a
+      // cryptic "Variable workspaceFolder can not be resolved" toast.
+      notes.push('VS Code: the server starts per-workspace — open a folder (File → Open Folder) before starting it; a no-folder window reports "Variable workspaceFolder can not be resolved".');
+    }
     return {
       files: [writeMcpEntry(loc)],
-      notes: ['Restart VS Code for MCP changes to take effect.'],
+      notes,
     };
   }