@sanity/cli 8.28.2 → 8.30.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.
Files changed (54) hide show
  1. package/README.md +6 -6
  2. package/dist/actions/build/buildApp.js +1 -0
  3. package/dist/actions/build/buildApp.js.map +1 -1
  4. package/dist/actions/build/buildStudio.js +1 -0
  5. package/dist/actions/build/buildStudio.js.map +1 -1
  6. package/dist/actions/deploy/createUserApplication.js +4 -1
  7. package/dist/actions/deploy/createUserApplication.js.map +1 -1
  8. package/dist/actions/deploy/deployChecks.js +3 -2
  9. package/dist/actions/deploy/deployChecks.js.map +1 -1
  10. package/dist/actions/deploy/deployRunner.js +3 -2
  11. package/dist/actions/deploy/deployRunner.js.map +1 -1
  12. package/dist/actions/deploy/findUserApplication.js +4 -3
  13. package/dist/actions/deploy/findUserApplication.js.map +1 -1
  14. package/dist/actions/deploy/serviceUnavailable.js +49 -0
  15. package/dist/actions/deploy/serviceUnavailable.js.map +1 -0
  16. package/dist/actions/dev/servers/getDashboardAppUrl.js +2 -2
  17. package/dist/actions/dev/servers/getDashboardAppUrl.js.map +1 -1
  18. package/dist/actions/dev/servers/getDevServerConfig.js +1 -0
  19. package/dist/actions/dev/servers/getDevServerConfig.js.map +1 -1
  20. package/dist/actions/dev/servers/startAppDevServer.js +3 -2
  21. package/dist/actions/dev/servers/startAppDevServer.js.map +1 -1
  22. package/dist/actions/dev/servers/startStudioDevServer.js +4 -2
  23. package/dist/actions/dev/servers/startStudioDevServer.js.map +1 -1
  24. package/dist/actions/documents/validateDocuments.worker.js +34 -30
  25. package/dist/actions/documents/validateDocuments.worker.js.map +1 -1
  26. package/dist/actions/mcp/detectAvailableEditors.js +5 -13
  27. package/dist/actions/mcp/detectAvailableEditors.js.map +1 -1
  28. package/dist/actions/mcp/editorConfigs.js +43 -89
  29. package/dist/actions/mcp/editorConfigs.js.map +1 -1
  30. package/dist/actions/mcp/promptForMCPSetup.js +2 -5
  31. package/dist/actions/mcp/promptForMCPSetup.js.map +1 -1
  32. package/dist/actions/mcp/setupMCP.js +37 -50
  33. package/dist/actions/mcp/setupMCP.js.map +1 -1
  34. package/dist/actions/mcp/types.js.map +1 -1
  35. package/dist/actions/mcp/writeMCPConfig.js +3 -3
  36. package/dist/actions/mcp/writeMCPConfig.js.map +1 -1
  37. package/dist/commands/mcp/configure.js +2 -22
  38. package/dist/commands/mcp/configure.js.map +1 -1
  39. package/dist/commands/skills/install.js +1 -1
  40. package/dist/commands/skills/install.js.map +1 -1
  41. package/dist/exports/invokeSanityCli/index.d.ts +4 -2
  42. package/dist/exports/runtime.d.ts +2 -2
  43. package/dist/exports/runtime.js +1 -1
  44. package/dist/exports/runtime.js.map +1 -1
  45. package/dist/generated/apiRoutes.js +12 -0
  46. package/dist/generated/apiRoutes.js.map +1 -1
  47. package/dist/server/devServer.js +2 -1
  48. package/dist/server/devServer.js.map +1 -1
  49. package/dist/services/mcp.js +1 -73
  50. package/dist/services/mcp.js.map +1 -1
  51. package/oclif.manifest.json +606 -606
  52. package/package.json +27 -25
  53. package/dist/actions/mcp/validateEditorTokens.js +0 -56
  54. package/dist/actions/mcp/validateEditorTokens.js.map +0 -1
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/actions/mcp/detectAvailableEditors.ts"],"sourcesContent":["import {existsSync} from 'node:fs'\nimport fs from 'node:fs/promises'\n\nimport {subdebug} from '@sanity/cli-core'\nimport {type ParseError, parse as parseJsonc} from 'jsonc-parser'\nimport {parse as parseToml} from 'smol-toml'\n\nimport {\n createDetectionEnv,\n type DetectionEnv,\n EDITOR_CONFIGS,\n type EditorName,\n} from './editorConfigs.js'\nimport {type Editor} from './types.js'\n\nconst debug = subdebug('mcp:detectAvailableEditors')\n\ninterface MCPConfig {\n [key: string]: Record<string, unknown> | undefined\n}\n\n/**\n * Safely parse config file content\n * Returns parsed config or null if unparseable\n */\nfunction parseConfig(content: string, format: 'jsonc' | 'toml'): MCPConfig | null {\n const trimmed = content.trim()\n if (trimmed === '') {\n return {} // Empty file - safe to write, treat as empty config\n }\n\n if (format === 'toml') {\n try {\n const parsed = parseToml(content)\n if (typeof parsed !== 'object' || parsed === null || Array.isArray(parsed)) {\n return null\n }\n\n return parsed as MCPConfig\n } catch {\n return null\n }\n }\n\n const errors: ParseError[] = []\n const parsed = parseJsonc(content, errors, {allowTrailingComma: true})\n\n if (errors.length > 0 || typeof parsed !== 'object' || parsed === null || Array.isArray(parsed)) {\n return null // Parse failed\n }\n\n return parsed as MCPConfig\n}\n\n/**\n * Check if an editor's config is usable and whether Sanity MCP is already configured.\n * If configured, extracts the existing auth token.\n * Returns null only if config exists but can't be parsed (to avoid data loss).\n */\nasync function checkEditorConfig(name: EditorName, configPath: string): Promise<Editor | null> {\n const {configKey, format, readToken} = EDITOR_CONFIGS[name]\n\n // Config file doesn't exist - can create it\n if (!existsSync(configPath)) {\n return {configPath, configured: false, name}\n }\n\n // Config exists - try to parse it\n try {\n const content = await fs.readFile(configPath, 'utf8')\n const config = parseConfig(content, format)\n\n if (config === null) {\n debug('Skipping %s: could not parse %s', name, configPath)\n return null // Can't parse - skip this editor\n }\n\n // Check if Sanity MCP is already configured\n const sanityConfig = config[configKey]?.Sanity\n const configured = Boolean(sanityConfig)\n\n // Extract existing token if configured\n let existingToken: string | undefined\n if (configured && typeof sanityConfig === 'object' && sanityConfig !== null) {\n existingToken = readToken(sanityConfig as Record<string, unknown>)\n }\n\n const {oauthOnly} = EDITOR_CONFIGS[name]\n if (configured && !existingToken && oauthOnly) {\n return {authStatus: 'valid', configPath, configured, name}\n }\n\n return {configPath, configured, existingToken, name}\n } catch (err) {\n debug('Skipping %s: could not read %s: %s', name, configPath, err)\n return null\n }\n}\n\n/**\n * Detect which editors are installed and have parseable configs.\n * Editors with unparseable configs are skipped to avoid data loss.\n *\n * Accepts an optional `DetectionEnv` for testability. When omitted,\n * uses the real process/OS environment.\n */\nexport async function detectAvailableEditors(env?: DetectionEnv): Promise<Editor[]> {\n const ctx = env ?? createDetectionEnv()\n\n // Detect all editors in parallel to avoid stacking timeouts —\n // CLI-based editors (Claude Code, Codex CLI, OpenCode) each have a\n // 5s execa timeout, so sequential detection can add ~15s on machines\n // where none are installed.\n const results = await Promise.all(\n Object.entries(EDITOR_CONFIGS).map(async ([name, config]) => {\n const configPath = await config.detect(ctx)\n if (!configPath) return null\n return checkEditorConfig(name as EditorName, configPath)\n }),\n )\n\n return results.filter((editor): editor is Editor => editor !== null)\n}\n"],"names":["existsSync","fs","subdebug","parse","parseJsonc","parseToml","createDetectionEnv","EDITOR_CONFIGS","debug","parseConfig","content","format","trimmed","trim","parsed","Array","isArray","errors","allowTrailingComma","length","checkEditorConfig","name","configPath","configKey","readToken","configured","readFile","config","sanityConfig","Sanity","Boolean","existingToken","oauthOnly","authStatus","err","detectAvailableEditors","env","ctx","results","Promise","all","Object","entries","map","detect","filter","editor"],"mappings":"AAAA,SAAQA,UAAU,QAAO,UAAS;AAClC,OAAOC,QAAQ,mBAAkB;AAEjC,SAAQC,QAAQ,QAAO,mBAAkB;AACzC,SAAyBC,SAASC,UAAU,QAAO,eAAc;AACjE,SAAQD,SAASE,SAAS,QAAO,YAAW;AAE5C,SACEC,kBAAkB,EAElBC,cAAc,QAET,qBAAoB;AAG3B,MAAMC,QAAQN,SAAS;AAMvB;;;CAGC,GACD,SAASO,YAAYC,OAAe,EAAEC,MAAwB;IAC5D,MAAMC,UAAUF,QAAQG,IAAI;IAC5B,IAAID,YAAY,IAAI;QAClB,OAAO,CAAC,EAAE,oDAAoD;;IAChE;IAEA,IAAID,WAAW,QAAQ;QACrB,IAAI;YACF,MAAMG,SAAST,UAAUK;YACzB,IAAI,OAAOI,WAAW,YAAYA,WAAW,QAAQC,MAAMC,OAAO,CAACF,SAAS;gBAC1E,OAAO;YACT;YAEA,OAAOA;QACT,EAAE,OAAM;YACN,OAAO;QACT;IACF;IAEA,MAAMG,SAAuB,EAAE;IAC/B,MAAMH,SAASV,WAAWM,SAASO,QAAQ;QAACC,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EAAmE;IACnE,qEAAqE;IACrE,4BAA4B;IAC5B,MAAMgC,UAAU,MAAMC,QAAQC,GAAG,CAC/BC,OAAOC,OAAO,CAACnC,gBAAgBoC,GAAG,CAAC,OAAO,CAACtB,MAAMM,OAAO;QACtD,MAAML,aAAa,MAAMK,OAAOiB,MAAM,CAACP;QACvC,IAAI,CAACf,YAAY,OAAO;QACxB,OAAOF,kBAAkBC,MAAoBC;IAC/C;IAGF,OAAOgB,QAAQO,MAAM,CAAC,CAACC,SAA6BA,WAAW;AACjE"}
1
+ {"version":3,"sources":["../../../src/actions/mcp/detectAvailableEditors.ts"],"sourcesContent":["import {existsSync} from 'node:fs'\nimport fs from 'node:fs/promises'\n\nimport {subdebug} from '@sanity/cli-core'\nimport {type ParseError, parse as parseJsonc} from 'jsonc-parser'\nimport {parse as parseToml} from 'smol-toml'\n\nimport {\n createDetectionEnv,\n type DetectionEnv,\n EDITOR_CONFIGS,\n type EditorName,\n hasLegacyToken,\n} from './editorConfigs.js'\nimport {type Editor} from './types.js'\n\nconst debug = subdebug('mcp:detectAvailableEditors')\n\ninterface MCPConfig {\n [key: string]: Record<string, unknown> | undefined\n}\n\n/**\n * Safely parse config file content\n * Returns parsed config or null if unparseable\n */\nfunction parseConfig(content: string, format: 'jsonc' | 'toml'): MCPConfig | null {\n const trimmed = content.trim()\n if (trimmed === '') {\n return {} // Empty file - safe to write, treat as empty config\n }\n\n if (format === 'toml') {\n try {\n const parsed = parseToml(content)\n if (typeof parsed !== 'object' || parsed === null || Array.isArray(parsed)) {\n return null\n }\n\n return parsed as MCPConfig\n } catch {\n return null\n }\n }\n\n const errors: ParseError[] = []\n const parsed = parseJsonc(content, errors, {allowTrailingComma: true})\n\n if (errors.length > 0 || typeof parsed !== 'object' || parsed === null || Array.isArray(parsed)) {\n return null // Parse failed\n }\n\n return parsed as MCPConfig\n}\n\n/**\n * Check if an editor's config is usable and whether Sanity MCP is already configured.\n * Returns null only if config exists but can't be parsed (to avoid data loss).\n */\nasync function checkEditorConfig(name: EditorName, configPath: string): Promise<Editor | null> {\n const {configKey, format} = EDITOR_CONFIGS[name]\n\n // Config file doesn't exist - can create it\n if (!existsSync(configPath)) {\n return {configPath, configured: false, name}\n }\n\n // Config exists - try to parse it\n try {\n const content = await fs.readFile(configPath, 'utf8')\n const config = parseConfig(content, format)\n\n if (config === null) {\n debug('Skipping %s: could not parse %s', name, configPath)\n return null // Can't parse - skip this editor\n }\n\n // Check if Sanity MCP is already configured, and whether it still holds a token\n const sanityConfig = config[configKey]?.Sanity\n const configured = Boolean(sanityConfig)\n if (\n typeof sanityConfig === 'object' &&\n sanityConfig !== null &&\n hasLegacyToken(sanityConfig as Record<string, unknown>)\n ) {\n return {configPath, configured, hasLegacyToken: true, name}\n }\n\n return {configPath, configured, name}\n } catch (err) {\n debug('Skipping %s: could not read %s: %s', name, configPath, err)\n return null\n }\n}\n\n/**\n * Detect which editors are installed and have parseable configs.\n * Editors with unparseable configs are skipped to avoid data loss.\n *\n * Accepts an optional `DetectionEnv` for testability. When omitted,\n * uses the real process/OS environment.\n */\nexport async function detectAvailableEditors(env?: DetectionEnv): Promise<Editor[]> {\n const ctx = env ?? createDetectionEnv()\n\n // Detect all editors in parallel to avoid stacking timeouts —\n // CLI-based editors (Claude Code, Codex CLI, OpenCode) each have a\n // 5s execa timeout, so sequential detection can add ~15s on machines\n // where none are installed.\n const results = await Promise.all(\n Object.entries(EDITOR_CONFIGS).map(async ([name, config]) => {\n const configPath = await config.detect(ctx)\n if (!configPath) return null\n return checkEditorConfig(name as EditorName, configPath)\n }),\n )\n\n return results.filter((editor): editor is Editor => editor !== null)\n}\n"],"names":["existsSync","fs","subdebug","parse","parseJsonc","parseToml","createDetectionEnv","EDITOR_CONFIGS","hasLegacyToken","debug","parseConfig","content","format","trimmed","trim","parsed","Array","isArray","errors","allowTrailingComma","length","checkEditorConfig","name","configPath","configKey","configured","readFile","config","sanityConfig","Sanity","Boolean","err","detectAvailableEditors","env","ctx","results","Promise","all","Object","ent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,IAAIe,WAAW,MAAM;YACnBlB,MAAM,mCAAmCa,MAAMC;YAC/C,OAAO,KAAK,iCAAiC;;QAC/C;QAEA,gFAAgF;QAChF,MAAMK,eAAeD,MAAM,CAACH,UAAU,EAAEK;QACxC,MAAMJ,aAAaK,QAAQF;QAC3B,IACE,OAAOA,iBAAiB,YACxBA,iBAAiB,QACjBpB,eAAeoB,eACf;YACA,OAAO;gBAACL;gBAAYE;gBAAYjB,gBAAgB;gBAAMc;YAAI;QAC5D;QAEA,OAAO;YAACC;YAAYE;YAAYH;QAAI;IACtC,EAAE,OAAOS,KAAK;QACZtB,MAAM,sCAAsCa,MAAMC,YAAYQ;QAC9D,OAAO;IACT;AACF;AAEA;;;;;;CAMC,GACD,OAAO,eAAeC,uBAAuBC,GAAkB;IAC7D,MAAMC,MAAMD,OAAO3B;IAEnB,8DAA8D;IAC9D,mEAAmE;IACnE,qEAAqE;IACrE,4BAA4B;IAC5B,MAAM6B,UAAU,MAAMC,QAAQC,GAAG,CAC/BC,OAAOC,OAAO,CAAChC,gBAAgBiC,GAAG,CAAC,OAAO,CAAClB,MAAMK,OAAO;QACtD,MAAMJ,aAAa,MAAMI,OAAOc,MAAM,CAACP;QACvC,IAAI,CAACX,YAAY,OAAO;QACxB,OAAOF,kBAAkBC,MAAoBC;IAC/C;IAGF,OAAOY,QAAQO,MAAM,CAAC,CAACC,SAA6BA,WAAW;AACjE"}
@@ -15,21 +15,10 @@ import { MCP_SERVER_URL } from '../../services/mcp.js';
15
15
  platform: process.platform
16
16
  };
17
17
  }
18
- /**
19
- * The Sanity MCP server uses OAuth by default
20
- * If a token is provided, the server will not use OAuth instead tool calls will use the API token
21
- */ const defaultHttpConfig = (token)=>{
22
- const defaultConfig = {
18
+ /** The Sanity MCP server uses OAuth, so a config only needs to point at it */ const defaultHttpConfig = ()=>({
23
19
  type: 'http',
24
20
  url: MCP_SERVER_URL
25
- };
26
- if (token) {
27
- defaultConfig.headers = {
28
- Authorization: `Bearer ${token}`
29
- };
30
- }
31
- return defaultConfig;
32
- };
21
+ });
33
22
  // -- Detect functions --
34
23
  async function detectClaudeCode(ctx) {
35
24
  try {
@@ -42,8 +31,10 @@ async function detectClaudeCode(ctx) {
42
31
  }
43
32
  }
44
33
  async function detectAntigravity(ctx) {
45
- const antigravityDir = path.join(ctx.homedir, '.gemini/antigravity');
46
- return ctx.existsSync(antigravityDir) ? path.join(antigravityDir, 'mcp_config.json') : null;
34
+ // Shared by the Antigravity app and CLI. The older `~/.gemini/antigravity`
35
+ // location is no longer read.
36
+ const configDir = path.join(ctx.homedir, '.gemini/config');
37
+ return ctx.existsSync(configDir) ? path.join(configDir, 'mcp_config.json') : null;
47
38
  }
48
39
  export function getVSCodeUserDir(ctx, variant = 'stable') {
49
40
  switch(ctx.platform){
@@ -63,12 +54,8 @@ export function getVSCodeUserDir(ctx, variant = 'stable') {
63
54
  }
64
55
  }
65
56
  async function detectCline(ctx) {
66
- const vscodeUserDir = getVSCodeUserDir(ctx);
67
- if (!vscodeUserDir) return null;
68
- const clineConfigDir = path.join(vscodeUserDir, 'globalStorage/saoudrizwan.claude-dev/settings');
69
- return ctx.existsSync(clineConfigDir) ? path.join(clineConfigDir, 'cline_mcp_settings.json') : null;
70
- }
71
- async function detectClineCli(ctx) {
57
+ // Shared by the Cline VS Code extension (4.1+) and Cline CLI. The extension's
58
+ // older `globalStorage/saoudrizwan.claude-dev` file is no longer read.
72
59
  const clineHome = ctx.env.CLINE_DIR || path.join(ctx.homedir, '.cline');
73
60
  if (!ctx.existsSync(clineHome)) return null;
74
61
  return path.join(clineHome, 'data/settings/cline_mcp_settings.json');
@@ -142,22 +129,17 @@ async function detectMCPorter(ctx) {
142
129
  if (ctx.existsSync(jsoncPath)) return jsoncPath;
143
130
  return jsonPath;
144
131
  }
145
- // -- Read token helpers --
132
+ // -- Legacy token detection --
146
133
  /**
147
- * Extract a Bearer token from a headers-like object.
148
- * Looks for `Authorization: "Bearer <token>"` and returns the token portion.
149
- */ function extractBearerToken(headers) {
150
- if (typeof headers !== 'object' || headers === null) return undefined;
151
- const auth = headers.Authorization;
152
- if (typeof auth !== 'string') return undefined;
153
- const match = auth.match(/^Bearer\s+(.+)$/);
154
- return match?.[1];
155
- }
156
- function readTokenFromHeaders(serverConfig) {
157
- return extractBearerToken(serverConfig.headers);
158
- }
159
- function readTokenFromHttpHeaders(serverConfig) {
160
- return extractBearerToken(serverConfig.http_headers);
134
+ * Whether a Sanity server config holds a token in `headers` (or `http_headers`
135
+ * for Codex CLI). Older CLI versions saved a login token there as
136
+ * `Authorization: Bearer <token>`, and users may have added an API token the
137
+ * same way. The two can't be told apart, so both are treated alike.
138
+ */ export function hasLegacyToken(serverConfig) {
139
+ return [
140
+ serverConfig.headers,
141
+ serverConfig.http_headers
142
+ ].some((headers)=>typeof headers === 'object' && headers !== null && typeof headers.Authorization === 'string');
161
143
  }
162
144
  // -- Defaults & build server config functions --
163
145
  export const UNIVERSAL_SKILLS_DIR = '.agents/skills';
@@ -165,45 +147,32 @@ export const UNIVERSAL_SKILLS_DIR = '.agents/skills';
165
147
  buildServerConfig: defaultHttpConfig,
166
148
  configKey: 'mcpServers',
167
149
  format: 'jsonc',
168
- oauthOnly: false,
169
- readToken: readTokenFromHeaders,
170
150
  skillsDir: UNIVERSAL_SKILLS_DIR
171
151
  };
172
- function buildAntigravityServerConfig(token) {
152
+ function buildAntigravityServerConfig() {
173
153
  return {
174
- headers: {
175
- Authorization: `Bearer ${token}`
176
- },
177
154
  serverUrl: MCP_SERVER_URL
178
155
  };
179
156
  }
180
- function buildClineServerConfig(token) {
157
+ function buildClineServerConfig() {
181
158
  return {
182
159
  disabled: false,
183
- headers: {
184
- Authorization: `Bearer ${token}`
185
- },
186
160
  type: 'streamableHttp',
187
161
  url: MCP_SERVER_URL
188
162
  };
189
163
  }
190
- function buildCodexCliServerConfig(token) {
191
- const config = {
164
+ function buildGeminiCliServerConfig() {
165
+ // Without `oauth.enabled`, Gemini CLI waits for the user to run `/mcp auth`
166
+ return {
167
+ oauth: {
168
+ enabled: true
169
+ },
192
170
  type: 'http',
193
171
  url: MCP_SERVER_URL
194
172
  };
195
- if (token) {
196
- config.http_headers = {
197
- Authorization: `Bearer ${token}`
198
- };
199
- }
200
- return config;
201
173
  }
202
- function buildGitHubCopilotCliServerConfig(token) {
174
+ function buildGitHubCopilotCliServerConfig() {
203
175
  return {
204
- headers: {
205
- Authorization: `Bearer ${token}`
206
- },
207
176
  tools: [
208
177
  '*'
209
178
  ],
@@ -211,24 +180,22 @@ function buildGitHubCopilotCliServerConfig(token) {
211
180
  url: MCP_SERVER_URL
212
181
  };
213
182
  }
214
- function buildOpenCodeServerConfig(token) {
215
- const config = {
183
+ function buildMCPorterServerConfig() {
184
+ return {
185
+ auth: 'oauth',
186
+ type: 'http',
187
+ url: MCP_SERVER_URL
188
+ };
189
+ }
190
+ function buildOpenCodeServerConfig() {
191
+ return {
216
192
  type: 'remote',
217
193
  url: MCP_SERVER_URL
218
194
  };
219
- if (token) {
220
- config.headers = {
221
- Authorization: `Bearer ${token}`
222
- };
223
- }
224
- return config;
225
195
  }
226
- function buildZedServerConfig(token) {
196
+ function buildZedServerConfig() {
227
197
  return {
228
198
  enabled: true,
229
- headers: {
230
- Authorization: `Bearer ${token}`
231
- },
232
199
  url: MCP_SERVER_URL
233
200
  };
234
201
  }
@@ -240,7 +207,8 @@ function buildZedServerConfig(token) {
240
207
  * config path and format. When updating a path, verify against the linked
241
208
  * documentation first.
242
209
  */ export const EDITOR_CONFIGS = {
243
- // Doc: https://support.google.com/gemini/answer/16255176 (Antigravity / Project Mariner)
210
+ // Doc: https://antigravity.google/docs/mcp
211
+ // Path: ~/.gemini/config/mcp_config.json Key: mcpServers
244
212
  Antigravity: {
245
213
  ...EDITOR_DEFAULTS,
246
214
  buildServerConfig: buildAntigravityServerConfig,
@@ -252,36 +220,24 @@ function buildZedServerConfig(token) {
252
220
  'Claude Code': {
253
221
  ...EDITOR_DEFAULTS,
254
222
  detect: detectClaudeCode,
255
- oauthOnly: true,
256
223
  skillsCliAgent: 'claude-code',
257
224
  skillsDir: '.claude/skills'
258
225
  },
259
- // Doc: https://github.com/cline/cline — VS Code extension (saoudrizwan.claude-dev)
260
- // Path: <VS Code User>/globalStorage/saoudrizwan.claude-dev/settings/cline_mcp_settings.json
226
+ // Doc: https://github.com/cline/cline — VS Code extension and CLI share one file
227
+ // Path: $CLINE_DIR || ~/.cline/data/settings/cline_mcp_settings.json
261
228
  Cline: {
262
229
  ...EDITOR_DEFAULTS,
263
230
  buildServerConfig: buildClineServerConfig,
264
231
  detect: detectCline,
265
232
  skillsCliAgent: 'cline'
266
233
  },
267
- // Doc: https://github.com/cline/cline — standalone CLI mode
268
- // Path: $CLINE_DIR || ~/.cline/data/settings/cline_mcp_settings.json
269
- 'Cline CLI': {
270
- ...EDITOR_DEFAULTS,
271
- buildServerConfig: buildClineServerConfig,
272
- detect: detectClineCli,
273
- skillsCliAgent: 'cline'
274
- },
275
234
  // Doc: https://platform.openai.com/docs/guides/tools-remote-mcp#codex-cli
276
235
  // Path: $CODEX_HOME || ~/.codex/config.toml Key: mcp_servers Format: TOML
277
236
  'Codex CLI': {
278
237
  ...EDITOR_DEFAULTS,
279
- buildServerConfig: buildCodexCliServerConfig,
280
238
  configKey: 'mcp_servers',
281
239
  detect: detectCodexCli,
282
240
  format: 'toml',
283
- oauthOnly: true,
284
- readToken: readTokenFromHttpHeaders,
285
241
  skillsCliAgent: 'codex'
286
242
  },
287
243
  // Doc: https://docs.cursor.com/context/model-context-protocol
@@ -289,13 +245,13 @@ function buildZedServerConfig(token) {
289
245
  Cursor: {
290
246
  ...EDITOR_DEFAULTS,
291
247
  detect: detectCursor,
292
- oauthOnly: true,
293
248
  skillsCliAgent: 'cursor'
294
249
  },
295
250
  // Doc: https://googlegemini.wiki/gemini-cli/mcp-servers
296
251
  // Path: ~/.gemini/settings.json Key: mcpServers
297
252
  'Gemini CLI': {
298
253
  ...EDITOR_DEFAULTS,
254
+ buildServerConfig: buildGeminiCliServerConfig,
299
255
  detect: detectGeminiCli,
300
256
  skillsCliAgent: 'gemini-cli'
301
257
  },
@@ -311,6 +267,7 @@ function buildZedServerConfig(token) {
311
267
  // Path: ~/.mcporter/mcporter.{json,jsonc} Key: mcpServers
312
268
  MCPorter: {
313
269
  ...EDITOR_DEFAULTS,
270
+ buildServerConfig: buildMCPorterServerConfig,
314
271
  detect: detectMCPorter
315
272
  },
316
273
  // Doc: https://opencode.ai/docs/config
@@ -320,7 +277,6 @@ function buildZedServerConfig(token) {
320
277
  buildServerConfig: buildOpenCodeServerConfig,
321
278
  configKey: 'mcp',
322
279
  detect: detectOpenCode,
323
- oauthOnly: true,
324
280
  skillsCliAgent: 'opencode'
325
281
  },
326
282
  // Doc: https://code.visualstudio.com/docs/copilot/chat/mcp-servers
@@ -331,7 +287,6 @@ function buildZedServerConfig(token) {
331
287
  ...EDITOR_DEFAULTS,
332
288
  configKey: 'servers',
333
289
  detect: detectVSCode,
334
- oauthOnly: true,
335
290
  skillsCliAgent: 'github-copilot'
336
291
  },
337
292
  // Doc: https://code.visualstudio.com/docs/copilot/chat/mcp-servers
@@ -340,7 +295,6 @@ function buildZedServerConfig(token) {
340
295
  ...EDITOR_DEFAULTS,
341
296
  configKey: 'servers',
342
297
  detect: detectVSCodeInsiders,
343
- oauthOnly: true,
344
298
  skillsCliAgent: 'github-copilot'
345
299
  },
346
300
  // Doc: https://zed.dev/docs/assistant/model-context-protocol
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/actions/mcp/editorConfigs.ts"],"sourcesContent":["import {existsSync} from 'node:fs'\nimport os from 'node:os'\nimport path from 'node:path'\n\nimport {execa} from 'execa'\n\nimport {MCP_SERVER_URL} from '../../services/mcp.js'\n\n/**\n * Environment abstraction for editor detection.\n *\n * Detect functions receive this instead of using module-level imports, making\n * each function independently testable without global mocks.\n */\nexport interface DetectionEnv {\n env: Record<string, string | undefined>\n /** Run a CLI command to check if a tool is installed. Rejects on failure. */\n execCommand: (cmd: string, args: string[]) => Promise<void>\n existsSync: (p: string) => boolean\n homedir: string\n platform: NodeJS.Platform\n}\n\n/** Create the real detection environment backed by process/OS globals. */\nexport function createDetectionEnv(): DetectionEnv {\n return {\n env: process.env,\n execCommand: (cmd, args) => execa(cmd, args, {stdio: 'pipe', timeout: 5000}).then(() => {}),\n existsSync,\n homedir: os.homedir(),\n platform: process.platform,\n }\n}\n\ninterface EditorConfig {\n /** Builds the server config with API token. If oauthOnly is true, the token is not used */\n buildServerConfig: (token: string) => Record<string, unknown>\n configKey: string\n /** Returns the config file path if editor is detected, null otherwise */\n detect: (env: DetectionEnv) => Promise<string | null>\n format: 'jsonc' | 'toml'\n /** Extracts the auth token from a parsed Sanity server config block */\n readToken: (serverConfig: Record<string, unknown>) => string | undefined\n\n /** If true, this editor uses OAuth natively and does not need an embedded API token */\n oauthOnly?: boolean\n /**\n * Corresponding `--agent` value for the `skills` CLI (https://github.com/vercel-labs/skills).\n * Omit when the editor has no skills CLI equivalent.\n */\n skillsCliAgent?: string\n /**\n * The directory to install skills to.\n */\n skillsDir?: string\n}\n\n/**\n * The Sanity MCP server uses OAuth by default\n * If a token is provided, the server will not use OAuth instead tool calls will use the API token\n */\nconst defaultHttpConfig = (token?: string) => {\n const defaultConfig: Record<string, unknown> = {\n type: 'http',\n url: MCP_SERVER_URL,\n }\n\n if (token) {\n defaultConfig.headers = {Authorization: `Bearer ${token}`}\n }\n\n return defaultConfig\n}\n\n// -- Detect functions --\n\nasync function detectClaudeCode(ctx: DetectionEnv): Promise<string | null> {\n try {\n await ctx.execCommand('claude', ['--version'])\n return path.join(ctx.homedir, '.claude.json')\n } catch {\n return null\n }\n}\n\nasync function detectAntigravity(ctx: DetectionEnv): Promise<string | null> {\n const antigravityDir = path.join(ctx.homedir, '.gemini/antigravity')\n return ctx.existsSync(antigravityDir) ? path.join(antigravityDir, 'mcp_config.json') : null\n}\n\nexport function getVSCodeUserDir(\n ctx: DetectionEnv,\n variant: 'insiders' | 'stable' = 'stable',\n): string | null {\n switch (ctx.platform) {\n case 'darwin': {\n return path.join(\n ctx.homedir,\n variant === 'insiders'\n ? 'Library/Application Support/Code - Insiders/User'\n : 'Library/Application Support/Code/User',\n )\n }\n case 'win32': {\n if (!ctx.env.APPDATA) return null\n return path.join(\n ctx.env.APPDATA,\n variant === 'insiders' ? 'Code - Insiders/User' : 'Code/User',\n )\n }\n default: {\n return path.join(\n ctx.homedir,\n variant === 'insiders' ? '.config/Code - Insiders/User' : '.config/Code/User',\n )\n }\n }\n}\n\nasync function detectCline(ctx: DetectionEnv): Promise<string | null> {\n const vscodeUserDir = getVSCodeUserDir(ctx)\n if (!vscodeUserDir) return null\n const clineConfigDir = path.join(vscodeUserDir, 'globalStorage/saoudrizwan.claude-dev/settings')\n return ctx.existsSync(clineConfigDir)\n ? path.join(clineConfigDir, 'cline_mcp_settings.json')\n : null\n}\n\nasync function detectClineCli(ctx: DetectionEnv): Promise<string | null> {\n const clineHome = ctx.env.CLINE_DIR || path.join(ctx.homedir, '.cline')\n if (!ctx.existsSync(clineHome)) return null\n return path.join(clineHome, 'data/settings/cline_mcp_settings.json')\n}\n\nasync function detectCodexCli(ctx: DetectionEnv): Promise<string | null> {\n try {\n await ctx.execCommand('codex', ['--version'])\n const codexHome = ctx.env.CODEX_HOME || path.join(ctx.homedir, '.codex')\n return path.join(codexHome, 'config.toml')\n } catch {\n return null\n }\n}\n\nasync function detectCursor(ctx: DetectionEnv): Promise<string | null> {\n const cursorDir = path.join(ctx.homedir, '.cursor')\n return ctx.existsSync(cursorDir) ? path.join(cursorDir, 'mcp.json') : null\n}\n\nasync function detectGeminiCli(ctx: DetectionEnv): Promise<string | null> {\n // Antigravity stores its config under ~/.gemini/antigravity, so checking\n // only the parent ~/.gemini directory causes false Gemini CLI detection.\n const settingsPath = path.join(ctx.homedir, '.gemini/settings.json')\n return ctx.existsSync(settingsPath) ? settingsPath : null\n}\n\nasync function detectGitHubCopilotCli(ctx: DetectionEnv): Promise<string | null> {\n const copilotDir =\n ctx.platform === 'linux' && ctx.env.XDG_CONFIG_HOME\n ? path.join(ctx.env.XDG_CONFIG_HOME, 'copilot')\n : path.join(ctx.homedir, '.copilot')\n return ctx.existsSync(copilotDir) ? path.join(copilotDir, 'mcp-config.json') : null\n}\n\nasync function detectOpenCode(ctx: DetectionEnv): Promise<string | null> {\n try {\n await ctx.execCommand('opencode', ['--version'])\n return path.join(ctx.homedir, '.config/opencode/opencode.json')\n } catch {\n return null\n }\n}\n\nasync function detectVSCode(ctx: DetectionEnv): Promise<string | null> {\n const configDir = getVSCodeUserDir(ctx)\n return configDir && ctx.existsSync(configDir) ? path.join(configDir, 'mcp.json') : null\n}\n\nasync function detectVSCodeInsiders(ctx: DetectionEnv): Promise<string | null> {\n const configDir = getVSCodeUserDir(ctx, 'insiders')\n return configDir && ctx.existsSync(configDir) ? path.join(configDir, 'mcp.json') : null\n}\n\nasync function detectZed(ctx: DetectionEnv): Promise<string | null> {\n let configDir: string | null = null\n switch (ctx.platform) {\n case 'win32': {\n if (ctx.env.APPDATA) {\n configDir = path.join(ctx.env.APPDATA, 'Zed')\n }\n break\n }\n default: {\n configDir = path.join(ctx.homedir, '.config/zed')\n }\n }\n return configDir && ctx.existsSync(configDir) ? path.join(configDir, 'settings.json') : null\n}\n\nasync function detectMCPorter(ctx: DetectionEnv): Promise<string | null> {\n const mcporterDir = path.join(ctx.homedir, '.mcporter')\n if (!ctx.existsSync(mcporterDir)) return null\n\n const jsonPath = path.join(mcporterDir, 'mcporter.json')\n const jsoncPath = path.join(mcporterDir, 'mcporter.jsonc')\n if (ctx.existsSync(jsonPath)) return jsonPath\n if (ctx.existsSync(jsoncPath)) return jsoncPath\n return jsonPath\n}\n\n// -- Read token helpers --\n\n/**\n * Extract a Bearer token from a headers-like object.\n * Looks for `Authorization: \"Bearer <token>\"` and returns the token portion.\n */\nfunction extractBearerToken(headers: unknown): string | undefined {\n if (typeof headers !== 'object' || headers === null) return undefined\n const auth = (headers as Record<string, unknown>).Authorization\n if (typeof auth !== 'string') return undefined\n const match = auth.match(/^Bearer\\s+(.+)$/)\n return match?.[1]\n}\n\nfunction readTokenFromHeaders(serverConfig: Record<string, unknown>): string | undefined {\n return extractBearerToken(serverConfig.headers)\n}\n\nfunction readTokenFromHttpHeaders(serverConfig: Record<string, unknown>): string | undefined {\n return extractBearerToken(serverConfig.http_headers)\n}\n\n// -- Defaults & build server config functions --\n\nexport const UNIVERSAL_SKILLS_DIR = '.agents/skills'\n/** Most editors share these values — entries only need to declare `detect` + any overrides. */\nconst EDITOR_DEFAULTS = {\n buildServerConfig: defaultHttpConfig,\n configKey: 'mcpServers',\n format: 'jsonc' as const,\n oauthOnly: false,\n readToken: readTokenFromHeaders,\n skillsDir: UNIVERSAL_SKILLS_DIR,\n}\n\nfunction buildAntigravityServerConfig(token: string): Record<string, unknown> {\n return {\n headers: {Authorization: `Bearer ${token}`},\n serverUrl: MCP_SERVER_URL,\n }\n}\n\nfunction buildClineServerConfig(token: string): Record<string, unknown> {\n return {\n disabled: false,\n headers: {Authorization: `Bearer ${token}`},\n type: 'streamableHttp',\n url: MCP_SERVER_URL,\n }\n}\n\nfunction buildCodexCliServerConfig(token?: string): Record<string, unknown> {\n const config: Record<string, unknown> = {\n type: 'http',\n url: MCP_SERVER_URL,\n }\n\n if (token) {\n config.http_headers = {Authorization: `Bearer ${token}`}\n }\n\n return config\n}\n\nfunction buildGitHubCopilotCliServerConfig(token: string): Record<string, unknown> {\n return {\n headers: {Authorization: `Bearer ${token}`},\n tools: ['*'],\n type: 'http',\n url: MCP_SERVER_URL,\n }\n}\n\nfunction buildOpenCodeServerConfig(token?: string): Record<string, unknown> {\n const config: Record<string, unknown> = {\n type: 'remote',\n url: MCP_SERVER_URL,\n }\n\n if (token) {\n config.headers = {Authorization: `Bearer ${token}`}\n }\n\n return config\n}\n\nfunction buildZedServerConfig(token: string): Record<string, unknown> {\n return {\n enabled: true,\n headers: {Authorization: `Bearer ${token}`},\n url: MCP_SERVER_URL,\n }\n}\n\n/**\n * Centralized editor configuration including detection logic.\n * To add a new editor: add an entry here — EditorName type is derived automatically.\n *\n * Each entry includes a doc URL pointing to the source of truth for its\n * config path and format. When updating a path, verify against the linked\n * documentation first.\n */\nexport const EDITOR_CONFIGS = {\n // Doc: https://support.google.com/gemini/answer/16255176 (Antigravity / Project Mariner)\n Antigravity: {\n ...EDITOR_DEFAULTS,\n buildServerConfig: buildAntigravityServerConfig,\n detect: detectAntigravity,\n skillsCliAgent: 'antigravity',\n },\n // Doc: https://docs.anthropic.com/en/docs/claude-code/mcp\n // Path: ~/.claude.json Key: mcpServers\n 'Claude Code': {\n ...EDITOR_DEFAULTS,\n detect: detectClaudeCode,\n oauthOnly: true,\n skillsCliAgent: 'claude-code',\n skillsDir: '.claude/skills',\n },\n // Doc: https://github.com/cline/cline — VS Code extension (saoudrizwan.claude-dev)\n // Path: <VS Code User>/globalStorage/saoudrizwan.claude-dev/settings/cline_mcp_settings.json\n Cline: {\n ...EDITOR_DEFAULTS,\n buildServerConfig: buildClineServerConfig,\n detect: detectCline,\n skillsCliAgent: 'cline',\n },\n // Doc: https://github.com/cline/cline — standalone CLI mode\n // Path: $CLINE_DIR || ~/.cline/data/settings/cline_mcp_settings.json\n 'Cline CLI': {\n ...EDITOR_DEFAULTS,\n buildServerConfig: buildClineServerConfig,\n detect: detectClineCli,\n skillsCliAgent: 'cline',\n },\n // Doc: https://platform.openai.com/docs/guides/tools-remote-mcp#codex-cli\n // Path: $CODEX_HOME || ~/.codex/config.toml Key: mcp_servers Format: TOML\n 'Codex CLI': {\n ...EDITOR_DEFAULTS,\n buildServerConfig: buildCodexCliServerConfig,\n configKey: 'mcp_servers',\n detect: detectCodexCli,\n format: 'toml' as const,\n oauthOnly: true,\n readToken: readTokenFromHttpHeaders,\n skillsCliAgent: 'codex',\n },\n // Doc: https://docs.cursor.com/context/model-context-protocol\n // Path: ~/.cursor/mcp.json Key: mcpServers\n Cursor: {\n ...EDITOR_DEFAULTS,\n detect: detectCursor,\n oauthOnly: true,\n skillsCliAgent: 'cursor',\n },\n // Doc: https://googlegemini.wiki/gemini-cli/mcp-servers\n // Path: ~/.gemini/settings.json Key: mcpServers\n 'Gemini CLI': {...EDITOR_DEFAULTS, detect: detectGeminiCli, skillsCliAgent: 'gemini-cli'},\n // Doc: https://docs.github.com/en/copilot/customizing-copilot/extending-copilot-coding-agent-with-mcp\n // Path: ~/.copilot/mcp-config.json (or $XDG_CONFIG_HOME/copilot on Linux) Key: mcpServers\n 'GitHub Copilot CLI': {\n ...EDITOR_DEFAULTS,\n buildServerConfig: buildGitHubCopilotCliServerConfig,\n detect: detectGitHubCopilotCli,\n skillsCliAgent: 'github-copilot',\n },\n // Doc: https://github.com/nicobailon/mcporter\n // Path: ~/.mcporter/mcporter.{json,jsonc} Key: mcpServers\n MCPorter: {...EDITOR_DEFAULTS, detect: detectMCPorter},\n // Doc: https://opencode.ai/docs/config\n // Path: ~/.config/opencode/opencode.json Key: mcp\n OpenCode: {\n ...EDITOR_DEFAULTS,\n buildServerConfig: buildOpenCodeServerConfig,\n configKey: 'mcp',\n detect: detectOpenCode,\n oauthOnly: true,\n skillsCliAgent: 'opencode',\n },\n // Doc: https://code.visualstudio.com/docs/copilot/chat/mcp-servers\n // Path: <VS Code User dir>/mcp.json Key: servers\n // VS Code uses GitHub Copilot for AI features; skills are installed via the\n // `github-copilot` agent (see https://code.visualstudio.com/docs/copilot/customization/agent-skills).\n 'VS Code': {\n ...EDITOR_DEFAULTS,\n configKey: 'servers',\n detect: detectVSCode,\n oauthOnly: true,\n skillsCliAgent: 'github-copilot',\n },\n // Doc: https://code.visualstudio.com/docs/copilot/chat/mcp-servers\n // Path: <VS Code Insiders User dir>/mcp.json Key: servers\n 'VS Code Insiders': {\n ...EDITOR_DEFAULTS,\n configKey: 'servers',\n detect: detectVSCodeInsiders,\n oauthOnly: true,\n skillsCliAgent: 'github-copilot',\n },\n // Doc: https://zed.dev/docs/assistant/model-context-protocol\n // Path: ~/.config/zed/settings.json (or $APPDATA/Zed on Windows) Key: context_servers\n // Zed doesn't support agent skills - https://github.com/zed-industries/zed/issues/49057\n Zed: {\n ...EDITOR_DEFAULTS,\n buildServerConfig: buildZedServerConfig,\n configKey: 'context_servers',\n detect: detectZed,\n },\n} satisfies Record<string, EditorConfig>\n\n/** Derived from EDITOR_CONFIGS keys - add a new editor there and this updates automatically */\nexport type EditorName = keyof typeof EDITOR_CONFIGS\n\nexport function getSkillsCliAgent(editorName: EditorName): string | undefined {\n if (editorName in EDITOR_CONFIGS) {\n const config = EDITOR_CONFIGS[editorName]\n return 'skillsCliAgent' in config ? config.skillsCliAgent : undefined\n }\n}\n\n/**\n * Skills-CLI agent ID → display name. Mirrors `displayName` from\n * `~/git/skills/src/agents.ts` for the subset of agents we install for. Used\n * to match `skills list --json` output (which keys by display name) against\n * our editors.\n */\nconst SKILLS_CLI_AGENT_DISPLAY_NAMES: Record<string, string> = {\n antigravity: 'Antigravity',\n 'claude-code': 'Claude Code',\n cline: 'Cline',\n codex: 'Codex',\n cursor: 'Cursor',\n 'gemini-cli': 'Gemini CLI',\n 'github-copilot': 'GitHub Copilot',\n opencode: 'OpenCode',\n}\n\nexport function isUniversalSkillsCliAgentByEditorName(editorName: EditorName): boolean {\n return EDITOR_CONFIGS[editorName]?.skillsDir === UNIVERSAL_SKILLS_DIR\n}\n\n/** Display name used by the skills CLI for the given editor, if it has a mapping. */\nexport function getSkillsCliAgentDisplayName(editorName: EditorName): string | undefined {\n const agent = getSkillsCliAgent(editorName)\n return agent ? SKILLS_CLI_AGENT_DISPLAY_NAMES[agent] : undefined\n}\n\n/** Display name for a skills-CLI agent ID (e.g. `'cursor'` → `'Cursor'`). */\nexport function getSkillsCliAgentDisplayNameById(agentId: string): string | undefined {\n return SKILLS_CLI_AGENT_DISPLAY_NAMES[agentId]\n}\n\n/**\n * The relative, home-anchored directory the `skills` CLI installs into for a\n * given agent ID (e.g. `'cursor'` → `'.agents/skills'`, `'claude-code'` →\n * `'.claude/skills'`). Derived from `EDITOR_CONFIGS` so it stays a single\n * source of truth.\n */\nexport function getSkillsCliAgentSkillsDir(agentName: string): string | undefined {\n for (const name of Object.keys(EDITOR_CONFIGS) as EditorName[]) {\n const config = EDITOR_CONFIGS[name]\n const agent = getSkillsCliAgent(name)\n if (agent === agentName) {\n return config.skillsDir\n }\n }\n return undefined\n}\n"],"names":["existsSync","os","path","execa","MCP_SERVER_URL","createDetectionEnv","env","process","execCommand","cmd","args","stdio","timeout","then","homedir","platform","defaultHttpConfig","token","defaultConfig","type","url","headers","Authorization","detectClaudeCode","ctx","join","detectAntigravity","antigravityDir","getVSCodeUserDir","variant","APPDATA","detectCline","vscodeUserDir","clineConfigDir","detectClineCli","clineHome","CLINE_DIR","detectCodexCli","codexHome","CODEX_HOME","detectCursor","cursorDir","detectGeminiCli","settingsPath","detectGitHubCopilotCli","copilotDir","XDG_CONFIG_HOME","detectOpenCode","detectVSCode","configDir","detectVSCodeInsiders","detectZed","detectMCPorter","mcporterDir","jsonPath","jsoncPath","extractBearerToken","undefined","auth","match","readTokenFromHeaders","serverConfig","readTokenFromHttpHeaders","http_headers","UNIVERSAL_SKILLS_DIR","EDITOR_DEFAULTS","buildServerConfig","configKey","format","oauthOnly","readToken","skillsDir","buildAntigravityServerConfig","serverUrl","buildClineServerConfig","disabled","buildCodexCliServerConfig","config","buildGitHubCopilotCliServerConfig","tools","buildOpenCodeServerConfig","buildZedServerConfig","enabled","EDITOR_CONFIGS","Antigravity","detect","skillsCliAgent","Cline","Cursor","MCPorter","OpenCode","Zed","getSkillsCliAgent","editorName","SKILLS_CLI_AGENT_DISPLAY_NAMES","antigravity","cline","codex","cursor","opencode","isUniversalSkillsCliAgentByEditorName","getSkillsCliAgentDisplayName","agent","getSkillsCliAgentDisplayNameById","agentId","getSkillsCliAgentSkillsDir","agentName","name","Object","keys"],"mappings":"AAAA,SAAQA,UAAU,QAAO,UAAS;AAClC,OAAOC,QAAQ,UAAS;AACxB,OAAOC,UAAU,YAAW;AAE5B,SAAQC,KAAK,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,SAASA,OAAOS,cAAc,GAAG7B;IAC9D;AACF;AAEA;;;;;CAKC,GACD,MAAMqC,iCAAyD;IAC7DC,aAAa;IACb,eAAe;IACfC,OAAO;IACPC,OAAO;IACPC,QAAQ;IACR,cAAc;IACd,kBAAkB;IAClBC,UAAU;AACZ;AAEA,OAAO,SAASC,sCAAsCP,UAAsB;IAC1E,OAAOV,cAAc,CAACU,WAAW,EAAEtB,cAAcP;AACnD;AAEA,mFAAmF,GACnF,OAAO,SAASqC,6BAA6BR,UAAsB;IACjE,MAAMS,QAAQV,kBAAkBC;IAChC,OAAOS,QAAQR,8BAA8B,CAACQ,MAAM,GAAG7C;AACzD;AAEA,2EAA2E,GAC3E,OAAO,SAAS8C,iCAAiCC,OAAe;IAC9D,OAAOV,8BAA8B,CAACU,QAAQ;AAChD;AAEA;;;;;CAKC,GACD,OAAO,SAASC,2BAA2BC,SAAiB;IAC1D,KAAK,MAAMC,QAAQC,OAAOC,IAAI,CAAC1B,gBAAiC;QAC9D,MAAMN,SAASM,cAAc,CAACwB,KAAK;QACnC,MAAML,QAAQV,kBAAkBe;QAChC,IAAIL,UAAUI,WAAW;YACvB,OAAO7B,OAAON,SAAS;QACzB;IACF;IACA,OAAOd;AACT"}
1
+ {"version":3,"sources":["../../../src/actions/mcp/editorConfigs.ts"],"sourcesContent":["import {existsSync} from 'node:fs'\nimport os from 'node:os'\nimport path from 'node:path'\n\nimport {execa} from 'execa'\n\nimport {MCP_SERVER_URL} from '../../services/mcp.js'\n\n/**\n * Environment abstraction for editor detection.\n *\n * Detect functions receive this instead of using module-level imports, making\n * each function independently testable without global mocks.\n */\nexport interface DetectionEnv {\n env: Record<string, string | undefined>\n /** Run a CLI command to check if a tool is installed. Rejects on failure. */\n execCommand: (cmd: string, args: string[]) => Promise<void>\n existsSync: (p: string) => boolean\n homedir: string\n platform: NodeJS.Platform\n}\n\n/** Create the real detection environment backed by process/OS globals. */\nexport function createDetectionEnv(): DetectionEnv {\n return {\n env: process.env,\n execCommand: (cmd, args) => execa(cmd, args, {stdio: 'pipe', timeout: 5000}).then(() => {}),\n existsSync,\n homedir: os.homedir(),\n platform: process.platform,\n }\n}\n\ninterface EditorConfig {\n /**\n * Builds the Sanity server config. It never contains credentials: every\n * supported editor signs in to the MCP server itself, using OAuth.\n */\n buildServerConfig: () => Record<string, unknown>\n configKey: string\n /** Returns the config file path if editor is detected, null otherwise */\n detect: (env: DetectionEnv) => Promise<string | null>\n format: 'jsonc' | 'toml'\n\n /**\n * Corresponding `--agent` value for the `skills` CLI (https://github.com/vercel-labs/skills).\n * Omit when the editor has no skills CLI equivalent.\n */\n skillsCliAgent?: string\n /**\n * The directory to install skills to.\n */\n skillsDir?: string\n}\n\n/** The Sanity MCP server uses OAuth, so a config only needs to point at it */\nconst defaultHttpConfig = () => ({\n type: 'http',\n url: MCP_SERVER_URL,\n})\n\n// -- Detect functions --\n\nasync function detectClaudeCode(ctx: DetectionEnv): Promise<string | null> {\n try {\n await ctx.execCommand('claude', ['--version'])\n return path.join(ctx.homedir, '.claude.json')\n } catch {\n return null\n }\n}\n\nasync function detectAntigravity(ctx: DetectionEnv): Promise<string | null> {\n // Shared by the Antigravity app and CLI. The older `~/.gemini/antigravity`\n // location is no longer read.\n const configDir = path.join(ctx.homedir, '.gemini/config')\n return ctx.existsSync(configDir) ? path.join(configDir, 'mcp_config.json') : null\n}\n\nexport function getVSCodeUserDir(\n ctx: DetectionEnv,\n variant: 'insiders' | 'stable' = 'stable',\n): string | null {\n switch (ctx.platform) {\n case 'darwin': {\n return path.join(\n ctx.homedir,\n variant === 'insiders'\n ? 'Library/Application Support/Code - Insiders/User'\n : 'Library/Application Support/Code/User',\n )\n }\n case 'win32': {\n if (!ctx.env.APPDATA) return null\n return path.join(\n ctx.env.APPDATA,\n variant === 'insiders' ? 'Code - Insiders/User' : 'Code/User',\n )\n }\n default: {\n return path.join(\n ctx.homedir,\n variant === 'insiders' ? '.config/Code - Insiders/User' : '.config/Code/User',\n )\n }\n }\n}\n\nasync function detectCline(ctx: DetectionEnv): Promise<string | null> {\n // Shared by the Cline VS Code extension (4.1+) and Cline CLI. The extension's\n // older `globalStorage/saoudrizwan.claude-dev` file is no longer read.\n const clineHome = ctx.env.CLINE_DIR || path.join(ctx.homedir, '.cline')\n if (!ctx.existsSync(clineHome)) return null\n return path.join(clineHome, 'data/settings/cline_mcp_settings.json')\n}\n\nasync function detectCodexCli(ctx: DetectionEnv): Promise<string | null> {\n try {\n await ctx.execCommand('codex', ['--version'])\n const codexHome = ctx.env.CODEX_HOME || path.join(ctx.homedir, '.codex')\n return path.join(codexHome, 'config.toml')\n } catch {\n return null\n }\n}\n\nasync function detectCursor(ctx: DetectionEnv): Promise<string | null> {\n const cursorDir = path.join(ctx.homedir, '.cursor')\n return ctx.existsSync(cursorDir) ? path.join(cursorDir, 'mcp.json') : null\n}\n\nasync function detectGeminiCli(ctx: DetectionEnv): Promise<string | null> {\n // Antigravity stores its config under ~/.gemini/antigravity, so checking\n // only the parent ~/.gemini directory causes false Gemini CLI detection.\n const settingsPath = path.join(ctx.homedir, '.gemini/settings.json')\n return ctx.existsSync(settingsPath) ? settingsPath : null\n}\n\nasync function detectGitHubCopilotCli(ctx: DetectionEnv): Promise<string | null> {\n const copilotDir =\n ctx.platform === 'linux' && ctx.env.XDG_CONFIG_HOME\n ? path.join(ctx.env.XDG_CONFIG_HOME, 'copilot')\n : path.join(ctx.homedir, '.copilot')\n return ctx.existsSync(copilotDir) ? path.join(copilotDir, 'mcp-config.json') : null\n}\n\nasync function detectOpenCode(ctx: DetectionEnv): Promise<string | null> {\n try {\n await ctx.execCommand('opencode', ['--version'])\n return path.join(ctx.homedir, '.config/opencode/opencode.json')\n } catch {\n return null\n }\n}\n\nasync function detectVSCode(ctx: DetectionEnv): Promise<string | null> {\n const configDir = getVSCodeUserDir(ctx)\n return configDir && ctx.existsSync(configDir) ? path.join(configDir, 'mcp.json') : null\n}\n\nasync function detectVSCodeInsiders(ctx: DetectionEnv): Promise<string | null> {\n const configDir = getVSCodeUserDir(ctx, 'insiders')\n return configDir && ctx.existsSync(configDir) ? path.join(configDir, 'mcp.json') : null\n}\n\nasync function detectZed(ctx: DetectionEnv): Promise<string | null> {\n let configDir: string | null = null\n switch (ctx.platform) {\n case 'win32': {\n if (ctx.env.APPDATA) {\n configDir = path.join(ctx.env.APPDATA, 'Zed')\n }\n break\n }\n default: {\n configDir = path.join(ctx.homedir, '.config/zed')\n }\n }\n return configDir && ctx.existsSync(configDir) ? path.join(configDir, 'settings.json') : null\n}\n\nasync function detectMCPorter(ctx: DetectionEnv): Promise<string | null> {\n const mcporterDir = path.join(ctx.homedir, '.mcporter')\n if (!ctx.existsSync(mcporterDir)) return null\n\n const jsonPath = path.join(mcporterDir, 'mcporter.json')\n const jsoncPath = path.join(mcporterDir, 'mcporter.jsonc')\n if (ctx.existsSync(jsonPath)) return jsonPath\n if (ctx.existsSync(jsoncPath)) return jsoncPath\n return jsonPath\n}\n\n// -- Legacy token detection --\n\n/**\n * Whether a Sanity server config holds a token in `headers` (or `http_headers`\n * for Codex CLI). Older CLI versions saved a login token there as\n * `Authorization: Bearer <token>`, and users may have added an API token the\n * same way. The two can't be told apart, so both are treated alike.\n */\nexport function hasLegacyToken(serverConfig: Record<string, unknown>): boolean {\n return [serverConfig.headers, serverConfig.http_headers].some(\n (headers) =>\n typeof headers === 'object' &&\n headers !== null &&\n typeof (headers as Record<string, unknown>).Authorization === 'string',\n )\n}\n\n// -- Defaults & build server config functions --\n\nexport const UNIVERSAL_SKILLS_DIR = '.agents/skills'\n/** Most editors share these values — entries only need to declare `detect` + any overrides. */\nconst EDITOR_DEFAULTS = {\n buildServerConfig: defaultHttpConfig,\n configKey: 'mcpServers',\n format: 'jsonc' as const,\n skillsDir: UNIVERSAL_SKILLS_DIR,\n}\n\nfunction buildAntigravityServerConfig(): Record<string, unknown> {\n return {serverUrl: MCP_SERVER_URL}\n}\n\nfunction buildClineServerConfig(): Record<string, unknown> {\n return {\n disabled: false,\n type: 'streamableHttp',\n url: MCP_SERVER_URL,\n }\n}\n\nfunction buildGeminiCliServerConfig(): Record<string, unknown> {\n // Without `oauth.enabled`, Gemini CLI waits for the user to run `/mcp auth`\n return {\n oauth: {enabled: true},\n type: 'http',\n url: MCP_SERVER_URL,\n }\n}\n\nfunction buildGitHubCopilotCliServerConfig(): Record<string, unknown> {\n return {\n tools: ['*'],\n type: 'http',\n url: MCP_SERVER_URL,\n }\n}\n\nfunction buildMCPorterServerConfig(): Record<string, unknown> {\n return {\n auth: 'oauth',\n type: 'http',\n url: MCP_SERVER_URL,\n }\n}\n\nfunction buildOpenCodeServerConfig(): Record<string, unknown> {\n return {\n type: 'remote',\n url: MCP_SERVER_URL,\n }\n}\n\nfunction buildZedServerConfig(): Record<string, unknown> {\n return {\n enabled: true,\n url: MCP_SERVER_URL,\n }\n}\n\n/**\n * Centralized editor configuration including detection logic.\n * To add a new editor: add an entry here — EditorName type is derived automatically.\n *\n * Each entry includes a doc URL pointing to the source of truth for its\n * config path and format. When updating a path, verify against the linked\n * documentation first.\n */\nexport const EDITOR_CONFIGS = {\n // Doc: https://antigravity.google/docs/mcp\n // Path: ~/.gemini/config/mcp_config.json Key: mcpServers\n Antigravity: {\n ...EDITOR_DEFAULTS,\n buildServerConfig: buildAntigravityServerConfig,\n detect: detectAntigravity,\n skillsCliAgent: 'antigravity',\n },\n // Doc: https://docs.anthropic.com/en/docs/claude-code/mcp\n // Path: ~/.claude.json Key: mcpServers\n 'Claude Code': {\n ...EDITOR_DEFAULTS,\n detect: detectClaudeCode,\n skillsCliAgent: 'claude-code',\n skillsDir: '.claude/skills',\n },\n // Doc: https://github.com/cline/cline — VS Code extension and CLI share one file\n // Path: $CLINE_DIR || ~/.cline/data/settings/cline_mcp_settings.json\n Cline: {\n ...EDITOR_DEFAULTS,\n buildServerConfig: buildClineServerConfig,\n detect: detectCline,\n skillsCliAgent: 'cline',\n },\n // Doc: https://platform.openai.com/docs/guides/tools-remote-mcp#codex-cli\n // Path: $CODEX_HOME || ~/.codex/config.toml Key: mcp_servers Format: TOML\n 'Codex CLI': {\n ...EDITOR_DEFAULTS,\n configKey: 'mcp_servers',\n detect: detectCodexCli,\n format: 'toml' as const,\n skillsCliAgent: 'codex',\n },\n // Doc: https://docs.cursor.com/context/model-context-protocol\n // Path: ~/.cursor/mcp.json Key: mcpServers\n Cursor: {\n ...EDITOR_DEFAULTS,\n detect: detectCursor,\n skillsCliAgent: 'cursor',\n },\n // Doc: https://googlegemini.wiki/gemini-cli/mcp-servers\n // Path: ~/.gemini/settings.json Key: mcpServers\n 'Gemini CLI': {\n ...EDITOR_DEFAULTS,\n buildServerConfig: buildGeminiCliServerConfig,\n detect: detectGeminiCli,\n skillsCliAgent: 'gemini-cli',\n },\n // Doc: https://docs.github.com/en/copilot/customizing-copilot/extending-copilot-coding-agent-with-mcp\n // Path: ~/.copilot/mcp-config.json (or $XDG_CONFIG_HOME/copilot on Linux) Key: mcpServers\n 'GitHub Copilot CLI': {\n ...EDITOR_DEFAULTS,\n buildServerConfig: buildGitHubCopilotCliServerConfig,\n detect: detectGitHubCopilotCli,\n skillsCliAgent: 'github-copilot',\n },\n // Doc: https://github.com/nicobailon/mcporter\n // Path: ~/.mcporter/mcporter.{json,jsonc} Key: mcpServers\n MCPorter: {\n ...EDITOR_DEFAULTS,\n buildServerConfig: buildMCPorterServerConfig,\n detect: detectMCPorter,\n },\n // Doc: https://opencode.ai/docs/config\n // Path: ~/.config/opencode/opencode.json Key: mcp\n OpenCode: {\n ...EDITOR_DEFAULTS,\n buildServerConfig: buildOpenCodeServerConfig,\n configKey: 'mcp',\n detect: detectOpenCode,\n skillsCliAgent: 'opencode',\n },\n // Doc: https://code.visualstudio.com/docs/copilot/chat/mcp-servers\n // Path: <VS Code User dir>/mcp.json Key: servers\n // VS Code uses GitHub Copilot for AI features; skills are installed via the\n // `github-copilot` agent (see https://code.visualstudio.com/docs/copilot/customization/agent-skills).\n 'VS Code': {\n ...EDITOR_DEFAULTS,\n configKey: 'servers',\n detect: detectVSCode,\n skillsCliAgent: 'github-copilot',\n },\n // Doc: https://code.visualstudio.com/docs/copilot/chat/mcp-servers\n // Path: <VS Code Insiders User dir>/mcp.json Key: servers\n 'VS Code Insiders': {\n ...EDITOR_DEFAULTS,\n configKey: 'servers',\n detect: detectVSCodeInsiders,\n skillsCliAgent: 'github-copilot',\n },\n // Doc: https://zed.dev/docs/assistant/model-context-protocol\n // Path: ~/.config/zed/settings.json (or $APPDATA/Zed on Windows) Key: context_servers\n // Zed doesn't support agent skills - https://github.com/zed-industries/zed/issues/49057\n Zed: {\n ...EDITOR_DEFAULTS,\n buildServerConfig: buildZedServerConfig,\n configKey: 'context_servers',\n detect: detectZed,\n },\n} satisfies Record<string, EditorConfig>\n\n/** Derived from EDITOR_CONFIGS keys - add a new editor there and this updates automatically */\nexport type EditorName = keyof typeof EDITOR_CONFIGS\n\nexport function getSkillsCliAgent(editorName: EditorName): string | undefined {\n if (editorName in EDITOR_CONFIGS) {\n const config = EDITOR_CONFIGS[editorName]\n return 'skillsCliAgent' in config ? config.skillsCliAgent : undefined\n }\n}\n\n/**\n * Skills-CLI agent ID → display name. Mirrors `displayName` from\n * `~/git/skills/src/agents.ts` for the subset of agents we install for. Used\n * to match `skills list --json` output (which keys by display name) against\n * our editors.\n */\nconst SKILLS_CLI_AGENT_DISPLAY_NAMES: Record<string, string> = {\n antigravity: 'Antigravity',\n 'claude-code': 'Claude Code',\n cline: 'Cline',\n codex: 'Codex',\n cursor: 'Cursor',\n 'gemini-cli': 'Gemini CLI',\n 'github-copilot': 'GitHub Copilot',\n opencode: 'OpenCode',\n}\n\nexport function isUniversalSkillsCliAgentByEditorName(editorName: EditorName): boolean {\n return EDITOR_CONFIGS[editorName]?.skillsDir === UNIVERSAL_SKILLS_DIR\n}\n\n/** Display name used by the skills CLI for the given editor, if it has a mapping. */\nexport function getSkillsCliAgentDisplayName(editorName: EditorName): string | undefined {\n const agent = getSkillsCliAgent(editorName)\n return agent ? SKILLS_CLI_AGENT_DISPLAY_NAMES[agent] : undefined\n}\n\n/** Display name for a skills-CLI agent ID (e.g. `'cursor'` → `'Cursor'`). */\nexport function getSkillsCliAgentDisplayNameById(agentId: string): string | undefined {\n return SKILLS_CLI_AGENT_DISPLAY_NAMES[agentId]\n}\n\n/**\n * The relative, home-anchored directory the `skills` CLI installs into for a\n * given agent ID (e.g. `'cursor'` → `'.agents/skills'`, `'claude-code'` →\n * `'.claude/skills'`). Derived from `EDITOR_CONFIGS` so it stays a single\n * source of truth.\n */\nexport function getSkillsCliAgentSkillsDir(agentName: string): string | undefined {\n for (const name of Object.keys(EDITOR_CONFIGS) as EditorName[]) {\n const config = EDITOR_CONFIGS[name]\n const agent = getSkillsCliAgent(name)\n if (agent === agentName) {\n return config.skillsDir\n }\n }\n return undefined\n}\n"],"names":["existsSync","os","path","execa","MCP_SERVER_URL","createDetectionEnv","env","process","execCommand","cmd","args","stdio","timeout","then","homedir","platform","defaultHttpConfig","type","url","detectClaudeCode","ctx","join","detectAntigravity","configDir","getVSCodeUserDir","variant","APPDATA","detectCline","clineHome","CLINE_DIR","detectCodexCli","codexHome","CODEX_HOME","detectCursor","cursorDir","detectGeminiCli","settingsPath","detectGitHubCopilotCli","copilotDir","XDG_CONFIG_HOME","detectOpenCode","detectVSCode","detectVSCodeInsiders","detectZed","detectMCPorter","mcporterDir","jsonPath","jsoncPath","hasLegacyToken","serverConfig","headers","http_headers","some","Authorization","UNIVERSAL_SKILLS_DIR","EDITOR_DEFAULTS","buildServerConfig","configKey","format","skillsDir","buildAntigravityServerConfig","serverUrl","buildClineServerConfig","disabled","buildGeminiCliServerConfig","oauth","enabled","buildGitHubCopilotCliServerConfig","tools","buildMCPorterServerConfig","auth","buildOpenCodeServerConfig","buildZedServerConfig","EDITOR_CONFIGS","Antigravity","detect","skillsCliAgent","Cline","Cursor","MCPorter","OpenCode","Zed","getSkillsCliAgent","editorName","config","undefined","SKILLS_CLI_AGENT_DISPLAY_NAMES","antigravity","cline","codex","cursor","opencode","isUniversalSkillsCliAgentByEditorName","getSkillsCliAgentDisplayName","agent","getSkillsCliAgentDisplayNameById","agentId","getSkillsCliAgentSkillsDir","agentName","name","Object","keys"],"mappings":"AAAA,SAAQA,UAAU,QAAO,UAAS;AAClC,OAAOC,QAAQ,UAAS;AACxB,OAAOC,UAAU,YAAW;AAE5B,SAAQC,KAAK,QAAO,QAAO;AAE3B,SAAQC,cAAc,QAAO,wBAAuB;AAiBpD,wEAAwE,GACxE,OAAO,SAASC;IACd,OAAO;QACLC,KAAKC,QAAQD,GAAG;QAChBE,aAAa,CAACC,KAAKC,OAASP,MAAMM,KAAKC,MAAM;gBAACC,OAAO;gBAAQC,SAAS;YAAI,GAAGC,IAAI,CAAC,KAAO;QACzFb;QACAc,SAASb,GAAGa,OAAO;QACnBC,UAAUR,QAAQQ,QAAQ;IAC5B;AACF;AAwBA,4EAA4E,GAC5E,MAAMC,oBAAoB,IAAO,CAAA;QAC/BC,MAAM;QACNC,KAAKd;IACP,CAAA;AAEA,yBAAyB;AAEzB,eAAee,iBAAiBC,GAAiB;IAC/C,IAAI;QACF,MAAMA,IAAIZ,WAAW,CAAC,UAAU;YAAC;SAAY;QAC7C,OAAON,KAAKmB,IAAI,CAACD,IAAIN,OAAO,EAAE;IAChC,EAAE,OAAM;QACN,OAAO;IACT;AACF;AAEA,eAAeQ,kBAAkBF,GAAiB;IAChD,2EAA2E;IAC3E,8BAA8B;IAC9B,MAAMG,YAAYrB,KAAKmB,IAAI,CAACD,IAAIN,OAAO,EAAE;IACzC,OAAOM,IAAIpB,UAAU,CAACuB,aAAarB,KAAKmB,IAAI,CAACE,WAAW,qBAAqB;AAC/E;AAEA,OAAO,SAASC,iBACdJ,GAAiB,EACjBK,UAAiC,QAAQ;IAEzC,OAAQL,IAAIL,QAAQ;QAClB,KAAK;YAAU;gBACb,OAAOb,KAAKmB,IAAI,CACdD,IAAIN,OAAO,EACXW,YAAY,aACR,qDACA;YAER;QACA,KAAK;YAAS;gBACZ,IAAI,CAAC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AAwF;IACxFK,KAAK;QACH,GAAG1B,eAAe;QAClBC,mBAAmBgB;QACnBf,WAAW;QACXkB,QAAQhC;IACV;AACF,EAAwC;AAKxC,OAAO,SAASuC,kBAAkBC,UAAsB;IACtD,IAAIA,cAAcV,gBAAgB;QAChC,MAAMW,SAASX,cAAc,CAACU,WAAW;QACzC,OAAO,oBAAoBC,SAASA,OAAOR,cAAc,GAAGS;IAC9D;AACF;AAEA;;;;;CAKC,GACD,MAAMC,iCAAyD;IAC7DC,aAAa;IACb,eAAe;IACfC,OAAO;IACPC,OAAO;IACPC,QAAQ;IACR,cAAc;IACd,kBAAkB;IAClBC,UAAU;AACZ;AAEA,OAAO,SAASC,sCAAsCT,UAAsB;IAC1E,OAAOV,cAAc,CAACU,WAAW,EAAExB,cAAcL;AACnD;AAEA,mFAAmF,GACnF,OAAO,SAASuC,6BAA6BV,UAAsB;IACjE,MAAMW,QAAQZ,kBAAkBC;IAChC,OAAOW,QAAQR,8BAA8B,CAACQ,MAAM,GAAGT;AACzD;AAEA,2EAA2E,GAC3E,OAAO,SAASU,iCAAiCC,OAAe;IAC9D,OAAOV,8BAA8B,CAACU,QAAQ;AAChD;AAEA;;;;;CAKC,GACD,OAAO,SAASC,2BAA2BC,SAAiB;IAC1D,KAAK,MAAMC,QAAQC,OAAOC,IAAI,CAAC5B,gBAAiC;QAC9D,MAAMW,SAASX,cAAc,CAAC0B,KAAK;QACnC,MAAML,QAAQZ,kBAAkBiB;QAChC,IAAIL,UAAUI,WAAW;YACvB,OAAOd,OAAOzB,SAAS;QACzB;IACF;IACA,OAAO0B;AACT"}
@@ -4,11 +4,8 @@ function getEditorLabel(choice) {
4
4
  if (action === 'skill-only') {
5
5
  return `${editor.name} (skills only — MCP already configured)`;
6
6
  }
7
- if (editor.configured && editor.authStatus === 'unauthorized') {
8
- return `${editor.name} (auth expired)`;
9
- }
10
- if (editor.configured && !editor.existingToken) {
11
- return `${editor.name} (missing credentials)`;
7
+ if (editor.hasLegacyToken) {
8
+ return `${editor.name} (replace saved token with OAuth)`;
12
9
  }
13
10
  return editor.name;
14
11
  }
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/actions/mcp/promptForMCPSetup.ts"],"sourcesContent":["import {checkbox} from '@sanity/cli-core/ux'\n\nimport {type Editor} from './types.js'\n\n/** Action to take for an editor in the combined MCP + skills setup prompt. */\nexport type EditorAction = 'mcp-and-skill' | 'mcp-only' | 'skill-only'\n\nexport interface EditorChoice {\n action: EditorAction\n editor: Editor\n}\n\nfunction getEditorLabel(choice: EditorChoice): string {\n const {action, editor} = choice\n if (action === 'skill-only') {\n return `${editor.name} (skills only — MCP already configured)`\n }\n if (editor.configured && editor.authStatus === 'unauthorized') {\n return `${editor.name} (auth expired)`\n }\n if (editor.configured && !editor.existingToken) {\n return `${editor.name} (missing credentials)`\n }\n return editor.name\n}\n\ninterface PromptOptions {\n choices: EditorChoice[]\n message: string\n}\n\n/**\n * Prompt the user to select editors for MCP / skills setup. The caller is\n * responsible for classifying editors into actions (see `EditorAction`) and\n * for choosing an appropriate prompt message.\n *\n * Returns the subset of `choices` the user kept, or `null` when the user\n * deselected everything.\n */\nexport async function promptForMCPSetup({\n choices,\n message,\n}: PromptOptions): Promise<EditorChoice[] | null> {\n const editorChoices = choices.map((choice) => ({\n checked: true,\n name: getEditorLabel(choice),\n value: choice.editor.name,\n }))\n\n const selectedNames = await checkbox({\n choices: editorChoices,\n message,\n })\n\n if (!selectedNames || selectedNames.length === 0) {\n return null\n }\n\n return choices.filter((c) => selectedNames.includes(c.editor.name))\n}\n"],"names":["checkbox","getEditorLabel","choice","action","editor","name","configured","authStatus","existingToken","promptForMCPSetup","choices","message","editorChoices","map","checked","value","selectedNames","length","filter","c","includes"],"mappings":"AAAA,SAAQA,QAAQ,QAAO,sBAAqB;AAY5C,SAASC,eAAeC,MAAoB;IAC1C,MAAM,EAACC,MAAM,EAAEC,MAAM,EAAC,GAAGF;IACzB,IAAIC,WAAW,cAAc;QAC3B,OAAO,GAAGC,OAAOC,IAAI,CAAC,uCAAuC,CAAC;IAChE;IACA,IAAID,OAAOE,UAAU,IAAIF,OAAOG,UAAU,KAAK,gBAAgB;QAC7D,OAAO,GAAGH,OAAOC,IAAI,CAAC,eAAe,CAAC;IACxC;IACA,IAAID,OAAOE,UAAU,IAAI,CAACF,OAAOI,aAAa,EAAE;QAC9C,OAAO,GAAGJ,OAAOC,IAAI,CAAC,sBAAsB,CAAC;IAC/C;IACA,OAAOD,OAAOC,IAAI;AACpB;AAOA;;;;;;;CAOC,GACD,OAAO,eAAeI,kBAAkB,EACtCC,OAAO,EACPC,OAAO,EACO;IACd,MAAMC,gBAAgBF,QAAQG,GAAG,CAAC,CAACX,SAAY,CAAA;YAC7CY,SAAS;YACTT,MAAMJ,eAAeC;YACrBa,OAAOb,OAAOE,MAAM,CAACC,IAAI;QAC3B,CAAA;IAEA,MAAMW,gBAAgB,MAAMhB,SAAS;QACnCU,SAASE;QACTD;IACF;IAEA,IAAI,CAACK,iBAAiBA,cAAcC,MAAM,KAAK,GAAG;QAChD,OAAO;IACT;IAEA,OAAOP,QAAQQ,MAAM,CAAC,CAACC,IAAMH,cAAcI,QAAQ,CAACD,EAAEf,MAAM,CAACC,IAAI;AACnE"}
1
+ {"version":3,"sources":["../../../src/actions/mcp/promptForMCPSetup.ts"],"sourcesContent":["import {checkbox} from '@sanity/cli-core/ux'\n\nimport {type Editor} from './types.js'\n\n/** Action to take for an editor in the combined MCP + skills setup prompt. */\nexport type EditorAction = 'mcp-and-skill' | 'mcp-only' | 'skill-only'\n\nexport interface EditorChoice {\n action: EditorAction\n editor: Editor\n}\n\nfunction getEditorLabel(choice: EditorChoice): string {\n const {action, editor} = choice\n if (action === 'skill-only') {\n return `${editor.name} (skills only — MCP already configured)`\n }\n if (editor.hasLegacyToken) {\n return `${editor.name} (replace saved token with OAuth)`\n }\n return editor.name\n}\n\ninterface PromptOptions {\n choices: EditorChoice[]\n message: string\n}\n\n/**\n * Prompt the user to select editors for MCP / skills setup. The caller is\n * responsible for classifying editors into actions (see `EditorAction`) and\n * for choosing an appropriate prompt message.\n *\n * Returns the subset of `choices` the user kept, or `null` when the user\n * deselected everything.\n */\nexport async function promptForMCPSetup({\n choices,\n message,\n}: PromptOptions): Promise<EditorChoice[] | null> {\n const editorChoices = choices.map((choice) => ({\n checked: true,\n name: getEditorLabel(choice),\n value: choice.editor.name,\n }))\n\n const selectedNames = await checkbox({\n choices: editorChoices,\n message,\n })\n\n if (!selectedNames || selectedNames.length === 0) {\n return null\n }\n\n return choices.filter((c) => selectedNames.includes(c.editor.name))\n}\n"],"names":["checkbox","getEditorLabel","choice","action","editor","name","hasLegacyToken","promptForMCPSetup","choices","message","editorChoices","map","checked","value","selectedNames","length","filter","c","includes"],"mappings":"AAAA,SAAQA,QAAQ,QAAO,sBAAqB;AAY5C,SAASC,eAAeC,MAAoB;IAC1C,MAAM,EAACC,MAAM,EAAEC,MAAM,EAAC,GAAGF;IACzB,IAAIC,WAAW,cAAc;QAC3B,OAAO,GAAGC,OAAOC,IAAI,CAAC,uCAAuC,CAAC;IAChE;IACA,IAAID,OAAOE,cAAc,EAAE;QACzB,OAAO,GAAGF,OAAOC,IAAI,CAAC,iCAAiC,CAAC;IAC1D;IACA,OAAOD,OAAOC,IAAI;AACpB;AAOA;;;;;;;CAOC,GACD,OAAO,eAAeE,kBAAkB,EACtCC,OAAO,EACPC,OAAO,EACO;IACd,MAAMC,gBAAgBF,QAAQG,GAAG,CAAC,CAACT,SAAY,CAAA;YAC7CU,SAAS;YACTP,MAAMJ,eAAeC;YACrBW,OAAOX,OAAOE,MAAM,CAACC,IAAI;QAC3B,CAAA;IAEA,MAAMS,gBAAgB,MAAMd,SAAS;QACnCQ,SAASE;QACTD;IACF;IAEA,IAAI,CAACK,iBAAiBA,cAAcC,MAAM,KAAK,GAAG;QAChD,OAAO;IACT;IAEA,OAAOP,QAAQQ,MAAM,CAAC,CAACC,IAAMH,cAAcI,QAAQ,CAACD,EAAEb,MAAM,CAACC,IAAI;AACnE"}
@@ -1,14 +1,14 @@
1
1
  import { subdebug } from '@sanity/cli-core';
2
2
  import { logSymbols } from '@sanity/cli-core/ux';
3
- import { createMCPToken, MCP_SERVER_URL } from '../../services/mcp.js';
3
+ import { MCP_SERVER_URL } from '../../services/mcp.js';
4
4
  import { getSkillCandidates } from '../skills/skillCandidates.js';
5
5
  import { detectAvailableEditors } from './detectAvailableEditors.js';
6
- import { EDITOR_CONFIGS, getSkillsCliAgent } from './editorConfigs.js';
6
+ import { getSkillsCliAgent } from './editorConfigs.js';
7
7
  import { promptForMCPSetup } from './promptForMCPSetup.js';
8
- import { validateEditorTokens } from './validateEditorTokens.js';
9
8
  import { writeMCPConfig } from './writeMCPConfig.js';
10
9
  const mcpDebug = subdebug('mcp:setup');
11
10
  const NO_EDITORS_DETECTED_MESSAGE = `Couldn't auto-configure Sanity MCP server for your editor. Visit ${MCP_SERVER_URL} for setup instructions.`;
11
+ const SIGN_IN_HINT = 'Sign in to Sanity from your agent the first time it connects to the MCP server.';
12
12
  /**
13
13
  * Classify each editor into one of four actions based on MCP status and
14
14
  * whether the Sanity skills are already installed for its skills-CLI agent.
@@ -16,9 +16,13 @@ const NO_EDITORS_DETECTED_MESSAGE = `Couldn't auto-configure Sanity MCP server f
16
16
  * `skillCandidateNames` is the set of editor names that still want a skills
17
17
  * install (have a skills-CLI mapping AND aren't already installed), derived
18
18
  * once via the shared `getSkillCandidates` primitive.
19
- */ function classifyEditors(editors, skillCandidateNames) {
19
+ *
20
+ * `replaceTokens` decides whether a config holding a token needs MCP setup.
21
+ * The token may be one the user added on purpose, so it is only replaced when
22
+ * the user is asked first.
23
+ */ function classifyEditors(editors, skillCandidateNames, replaceTokens) {
20
24
  return editors.map((editor)=>{
21
- const needsMCP = !editor.configured || editor.authStatus !== 'valid';
25
+ const needsMCP = !editor.configured || Boolean(editor.hasLegacyToken) && replaceTokens;
22
26
  const hasSkillMapping = Boolean(getSkillsCliAgent(editor.name));
23
27
  if (needsMCP) {
24
28
  return {
@@ -126,9 +130,7 @@ function getPromptMessage(mcpMode, skillsMode) {
126
130
  skipped: true
127
131
  };
128
132
  }
129
- // 3. Validate existing tokens against the Sanity API
130
- await validateEditorTokens(editors);
131
- // 4. Read skill state when skills are in scope so classification can dedup
133
+ // 3. Read skill state when skills are in scope so classification can dedup
132
134
  const skillCandidateNames = new Set();
133
135
  if (skillsMode !== 'skip') {
134
136
  const candidates = await getSkillCandidates(editors);
@@ -137,16 +139,22 @@ function getPromptMessage(mcpMode, skillsMode) {
137
139
  skillCandidateNames.add(editor.name);
138
140
  }
139
141
  }
140
- // 5. Classify + mask
141
- const classified = classifyEditors(editors, skillCandidateNames);
142
+ // 4. Classify + mask. Configs holding a token are only replaced when the
143
+ // user is prompted; without a prompt they are left alone and reported.
144
+ const replaceTokens = mcpMode === 'prompt';
145
+ const classified = classifyEditors(editors, skillCandidateNames, replaceTokens);
142
146
  const actionable = applyMasking(classified, mcpMode, skillsMode);
147
+ const keptTokenEditors = mcpMode === 'auto' ? editors.filter((e)=>e.hasLegacyToken).map((e)=>e.name) : [];
148
+ if (keptTokenEditors.length > 0) {
149
+ output.log(`${logSymbols.info} Kept the existing Sanity MCP config with a saved token for ${keptTokenEditors.join(', ')}. To switch to OAuth, run \`sanity mcp configure\` in a terminal.`);
150
+ }
143
151
  // "Already configured" surfaces editors whose MCP setup is valid (skill
144
152
  // state doesn't matter for this signal — that's what skillsToInstall is for).
145
153
  const actionableNames = new Set(actionable.map((c)=>c.editor.name));
146
- const alreadyConfiguredEditors = editors.filter((e)=>e.configured && e.authStatus === 'valid' && !actionableNames.has(e.name)).map((e)=>e.name);
154
+ const alreadyConfiguredEditors = editors.filter((e)=>e.configured && !e.hasLegacyToken && !actionableNames.has(e.name)).map((e)=>e.name);
147
155
  if (actionable.length === 0) {
148
156
  mcpDebug('Nothing actionable after classification + masking');
149
- if (explicit) {
157
+ if (explicit && keptTokenEditors.length === 0) {
150
158
  output.log(`${logSymbols.success} All detected editors are already configured`);
151
159
  }
152
160
  return {
@@ -157,7 +165,7 @@ function getPromptMessage(mcpMode, skillsMode) {
157
165
  skipped: true
158
166
  };
159
167
  }
160
- // 6. Select editors to configure — prompt interactively or auto-select all.
168
+ // 5. Select editors to configure — prompt interactively or auto-select all.
161
169
  // We only auto when neither side wants a prompt: MCP auto, or (MCP skip
162
170
  // + skills auto). Anything that asks `mode: 'prompt'` for MCP wins the
163
171
  // prompt even when skills would have auto-installed.
@@ -176,48 +184,27 @@ function getPromptMessage(mcpMode, skillsMode) {
176
184
  skipped: true
177
185
  };
178
186
  }
179
- // 7. MCP write phase — only for choices that need MCP
187
+ // 6. MCP write phase — only for choices that need MCP
180
188
  const mcpSelected = selected.filter((c)=>c.action === 'mcp-only' || c.action === 'mcp-and-skill');
181
- let token;
182
189
  const configuredEditors = [];
183
190
  let mcpError;
184
- if (mcpSelected.length > 0) {
185
- const validEditor = editors.find((e)=>e.authStatus === 'valid' && e.existingToken);
186
- if (validEditor?.existingToken) {
187
- mcpDebug('Reusing valid token from %s', validEditor.name);
188
- token = validEditor.existingToken;
189
- }
190
- const allOAuth = mcpSelected.every((c)=>EDITOR_CONFIGS[c.editor.name].oauthOnly);
191
- if (!token && !allOAuth) {
192
- try {
193
- token = await createMCPToken();
194
- } catch (error) {
195
- const err = error instanceof Error ? error : new Error(String(error));
196
- mcpDebug('Error creating MCP token', error);
197
- output.warn(`Could not configure MCP: ${err.message}`);
198
- output.warn('You can set up MCP manually later using https://mcp.sanity.io');
199
- mcpError = err;
200
- }
201
- }
202
- if (!mcpError) {
203
- for (const choice of mcpSelected){
204
- try {
205
- await writeMCPConfig(choice.editor, token);
206
- configuredEditors.push(choice.editor.name);
207
- } catch (error) {
208
- const err = error instanceof Error ? error : new Error(String(error));
209
- mcpDebug('Error writing MCP config for %s: %O', choice.editor.name, error);
210
- output.warn(`Could not configure MCP for ${choice.editor.name}: ${err.message}`);
211
- output.warn('You can set up MCP manually later using https://mcp.sanity.io');
212
- mcpError = err;
213
- }
214
- }
215
- }
216
- if (configuredEditors.length > 0) {
217
- output.log(`${logSymbols.success} MCP configured for ${configuredEditors.join(', ')}`);
191
+ for (const choice of mcpSelected){
192
+ try {
193
+ await writeMCPConfig(choice.editor);
194
+ configuredEditors.push(choice.editor.name);
195
+ } catch (error) {
196
+ const err = error instanceof Error ? error : new Error(String(error));
197
+ mcpDebug('Error writing MCP config for %s: %O', choice.editor.name, error);
198
+ output.warn(`Could not configure MCP for ${choice.editor.name}: ${err.message}`);
199
+ output.warn(`You can set up MCP manually later using ${MCP_SERVER_URL}`);
200
+ mcpError = err;
218
201
  }
219
202
  }
220
- // 8. Build skillsToInstall — only for choices the user kept, only when the
203
+ if (configuredEditors.length > 0) {
204
+ output.log(`${logSymbols.success} MCP configured for ${configuredEditors.join(', ')}`);
205
+ output.log(SIGN_IN_HINT);
206
+ }
207
+ // 7. Build skillsToInstall — only for choices the user kept, only when the
221
208
  // associated MCP write succeeded (or wasn't needed).
222
209
  const skillsToInstall = [];
223
210
  if (skillsMode !== 'skip') {