@@ -25,6 +25,45 @@ function hostRoot(host, home, env) {
2525 throw new Error ( `GLOBAL_HOST_UNSUPPORTED: ${ host } ` )
2626}
2727
28+ /**
29+ * VS Code user-profile MCP config (global, all workspaces).
30+ * Prefer paths under the resolved home so tests with a temp home never touch real APPDATA.
31+ * Override: DEVCODEX_VSCODE_MCP_PATH (single file) or DEVCODEX_VSCODE_USER_DIR.
32+ */
33+ function resolveVscodeAppDataRoot ( home , env = process . env ) {
34+ const homeAbs = path . resolve ( home )
35+ if ( process . platform === 'win32' ) {
36+ const appData = env . APPDATA && isUnder ( homeAbs , env . APPDATA )
37+ ? path . resolve ( env . APPDATA )
38+ : path . join ( homeAbs , 'AppData' , 'Roaming' )
39+ return appData
40+ }
41+ if ( process . platform === 'darwin' ) {
42+ return path . join ( homeAbs , 'Library' , 'Application Support' )
43+ }
44+ const xdg = env . XDG_CONFIG_HOME && isUnder ( homeAbs , env . XDG_CONFIG_HOME )
45+ ? path . resolve ( env . XDG_CONFIG_HOME )
46+ : path . join ( homeAbs , '.config' )
47+ return xdg
48+ }
49+
50+ function resolveVscodeUserMcpPaths ( home , env = process . env , fsImpl = fs ) {
51+ if ( env . DEVCODEX_VSCODE_MCP_PATH ) {
52+ return [ path . resolve ( env . DEVCODEX_VSCODE_MCP_PATH ) ]
53+ }
54+ if ( env . DEVCODEX_VSCODE_USER_DIR ) {
55+ return [ path . join ( path . resolve ( env . DEVCODEX_VSCODE_USER_DIR ) , 'mcp.json' ) ]
56+ }
57+ const appData = resolveVscodeAppDataRoot ( home , env )
58+ const paths = [ path . join ( appData , 'Code' , 'User' , 'mcp.json' ) ]
59+ // Also refresh Insiders when that product tree already exists (do not create product shell only for us)
60+ const insidersUser = path . join ( appData , 'Code - Insiders' , 'User' )
61+ if ( fsImpl . existsSync ( path . join ( appData , 'Code - Insiders' ) ) || fsImpl . existsSync ( insidersUser ) ) {
62+ paths . push ( path . join ( insidersUser , 'mcp.json' ) )
63+ }
64+ return paths
65+ }
66+
2867function resolveGlobalSharedTarget ( home , env = process . env ) {
2968 const root = path . resolve ( env . DEVCODEX_GLOBAL_SHARED_ROOT || path . join ( home , '.agents' ) )
3069 // SCAN root (host L1). Optional DEVCODEX_GLOBAL_SKILLS_ROOT still overrides scan path for legacy tests.
@@ -126,16 +165,22 @@ function resolveGlobalHostTarget(host, options = {}) {
126165 }
127166
128167 if ( normalized === 'copilot' ) {
168+ const vscodeMcpPaths = resolveVscodeUserMcpPaths ( home , env )
169+ const vscodeUserDirs = [ ...new Set ( vscodeMcpPaths . map ( file => path . dirname ( file ) ) ) ]
129170 return assertTargetBoundary ( {
130171 ...common ,
131172 support : 'contract-fixture' ,
132- evidenceCeiling : 'Copilot CLI user instructions, Hooks, MCP, and Skills; direct CLI execution is environment-dependent ' ,
173+ evidenceCeiling : 'Copilot CLI user instructions, Hooks, MCP, and Skills; VS Code user mcp.json is co-refreshed with apply ' ,
133174 files : {
134175 instructions : path . join ( root , 'copilot-instructions.md' ) ,
135176 hooks : path . join ( root , 'hooks' , 'devcodex.json' ) ,
136177 mcp : path . join ( root , 'mcp-config.json' ) ,
137- skills : path . join ( root , 'skills' )
138- }
178+ skills : path . join ( root , 'skills' ) ,
179+ // Primary VS Code User MCP (first path); extras go via additionalFiles
180+ vscodeMcp : vscodeMcpPaths [ 0 ]
181+ } ,
182+ additionalRoots : [ shared . root , ...vscodeUserDirs ] ,
183+ additionalFiles : vscodeMcpPaths . slice ( 1 )
139184 } )
140185 }
141186 if ( normalized === 'claude' ) {
@@ -205,6 +250,8 @@ module.exports = {
205250 resolveGlobalHostTarget,
206251 resolveGlobalHostTargets,
207252 resolveHome,
253+ resolveVscodeAppDataRoot,
254+ resolveVscodeUserMcpPaths,
208255 samePath,
209256 targetAcceptsPath
210257}
0 commit comments