@sanity/cli 8.32.1 → 8.34.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 +12 -6
  2. package/codemods/dashboardViewsV1.ts +226 -0
  3. package/dist/actions/codemods/dashboard.js +8 -117
  4. package/dist/actions/codemods/dashboard.js.map +1 -1
  5. package/dist/actions/codemods/dashboardViewsV1.js +82 -0
  6. package/dist/actions/codemods/dashboardViewsV1.js.map +1 -0
  7. package/dist/actions/codemods/index.js +2 -0
  8. package/dist/actions/codemods/index.js.map +1 -1
  9. package/dist/actions/codemods/upgradeRequiredPackages.js +121 -0
  10. package/dist/actions/codemods/upgradeRequiredPackages.js.map +1 -0
  11. package/dist/actions/deploy/deployApp.js +3 -3
  12. package/dist/actions/deploy/deployApp.js.map +1 -1
  13. package/dist/actions/deploy/deployStudio.js +2 -3
  14. package/dist/actions/deploy/deployStudio.js.map +1 -1
  15. package/dist/actions/dev/devAction.js +2 -1
  16. package/dist/actions/dev/devAction.js.map +1 -1
  17. package/dist/actions/init/bootstrapLocalTemplate.js +18 -0
  18. package/dist/actions/init/bootstrapLocalTemplate.js.map +1 -1
  19. package/dist/actions/mcp/detectAvailableEditors.js +2 -2
  20. package/dist/actions/mcp/detectAvailableEditors.js.map +1 -1
  21. package/dist/actions/mcp/editorConfigs.js +25 -2
  22. package/dist/actions/mcp/editorConfigs.js.map +1 -1
  23. package/dist/actions/preview/previewAction.js +2 -1
  24. package/dist/actions/preview/previewAction.js.map +1 -1
  25. package/dist/commands/dev.js +1 -1
  26. package/dist/commands/dev.js.map +1 -1
  27. package/dist/commands/mcp/configure.js +1 -1
  28. package/dist/commands/mcp/configure.js.map +1 -1
  29. package/dist/commands/organizations/create.js +2 -2
  30. package/dist/commands/organizations/create.js.map +1 -1
  31. package/dist/commands/organizations/update.js +2 -2
  32. package/dist/commands/organizations/update.js.map +1 -1
  33. package/dist/commands/projects/create.js +54 -5
  34. package/dist/commands/projects/create.js.map +1 -1
  35. package/dist/commands/skills/install.js +1 -1
  36. package/dist/commands/skills/install.js.map +1 -1
  37. package/dist/exports/invokeSanityCli/commandPolicies/mcpPolicy.js +2 -1
  38. package/dist/exports/invokeSanityCli/commandPolicies/mcpPolicy.js.map +1 -1
  39. package/dist/generated/apiRoutes.js +2 -0
  40. package/dist/generated/apiRoutes.js.map +1 -1
  41. package/dist/services/organizations.js.map +1 -1
  42. package/dist/services/projects.js +18 -0
  43. package/dist/services/projects.js.map +1 -1
  44. package/dist/util/telemetry/sanitizeTelemetryEvent.js +2 -2
  45. package/dist/util/telemetry/sanitizeTelemetryEvent.js.map +1 -1
  46. package/oclif.manifest.json +3173 -3151
  47. package/package.json +13 -11
  48. package/templates/app-quickstart/AGENTS.md +11 -0
  49. package/templates/app-sanity-ui/AGENTS.md +11 -0
  50. package/templates/shared/AGENTS.md +14 -0
  51. package/templates/shared/dashboard/app-quickstart/AGENTS.md +11 -0
  52. package/templates/shared/dashboard/app-sanity-ui/AGENTS.md +11 -0
  53. package/dist/actions/organizations/readOrganizationLogo.js +0 -49
  54. package/dist/actions/organizations/readOrganizationLogo.js.map +0 -1
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/actions/dev/devAction.ts"],"sourcesContent":["import {SANITY_CACHE_DIR} from '@sanity/cli-build/_internal/build'\nimport {extractCoreAppManifest} from '@sanity/cli-build/_internal/manifest'\nimport {isWorkbenchApp, isWorkbenchConfig} from '@sanity/workbench-cli'\nimport {startWorkbenchDev, watchForWorkbenchOptIn} from '@sanity/workbench-cli/dev'\n\nimport {checkForDeprecatedAppId} from '../../util/appId.js'\nimport {determineIsApp} from '../../util/determineIsApp.js'\nimport {getSharedServerConfig} from '../../util/getSharedServerConfig.js'\nimport {resolveReactStrictMode} from '../../util/resolveReactStrictMode.js'\nimport {extractStudioManifest} from '../manifest/extractStudioManifest.js'\nimport {startAppDevServer} from './servers/startAppDevServer.js'\nimport {startStudioDevServer} from './servers/startStudioDevServer.js'\nimport {type DevActionOptions} from './types.js'\n\nconst noop = async () => {}\n\n/**\n * Entry point for `sanity dev`. A plain studio/app starts a single dev server, as\n * before workbench existed, and switches to the workbench if `sanity.cli.*` opts\n * in while it runs. A workbench app (via `defineApplication`) delegates to\n * `@sanity/workbench-cli`, injecting the CLI-domain pieces (app server, manifest\n * extraction, app id).\n */\nexport async function devAction(options: DevActionOptions): Promise<{close: () => Promise<void>}> {\n const {cliConfig, output, workDir} = options\n\n // A workbench app (an app to render) or a workbench config (config-only, like\n // the media library, which needs the workbench to render it) both delegate.\n if (isWorkbenchApp(cliConfig?.app) || isWorkbenchConfig(cliConfig?.app)) {\n return startWorkbench(options)\n }\n\n // Plain non-workbench studio/app: one dev server announcing its own URL.\n const result = await (options.isApp ? startAppDevServer : startStudioDevServer)(options)\n if (!result.started) return {close: noop}\n\n return watchForWorkbenchOptIn({\n closePlainServer: result.close,\n output,\n startWorkbench: (freshConfig) =>\n startWorkbench({...options, cliConfig: freshConfig, isApp: determineIsApp(freshConfig)}),\n workDir,\n })\n}\n\nfunction startWorkbench(options: DevActionOptions): Promise<{close: () => Promise<void>}> {\n const {cliConfig, flags, isApp, output, workDir} = options\n const {httpHost, httpPort} = getSharedServerConfig({\n cliConfig,\n flags: {host: flags.host, port: flags.port},\n workDir,\n })\n\n return startWorkbenchDev({\n cacheDir: `${SANITY_CACHE_DIR}/vite`,\n checkForDeprecatedAppId: () => checkForDeprecatedAppId({cliConfig, output}),\n cliConfig,\n extractManifest: isApp\n ? ({workDir: wd}) => extractCoreAppManifest({silent: true, workDir: wd})\n : (params) => extractStudioManifest({...params, silent: true}),\n httpHost,\n httpPort,\n isApp,\n output,\n // Runtime template needs a concrete boolean; collapse an unset config to off.\n reactStrictMode: resolveReactStrictMode(cliConfig) ?? false,\n startAppServer: (params) =>\n (isApp ? startAppDevServer : startStudioDevServer)({...options, ...params}),\n workDir,\n })\n}\n"],"names":["SANITY_CACHE_DIR","extractCoreAppManifest","isWorkbenchApp","isWorkbenchConfig","startWorkbenchDev","watchForWorkbenchOptIn","checkForDeprecatedAppId","determineIsApp","getSharedServerConfig","resolveReactStrictMode","extractStudioManifest","startAppDevServer","startStudioDevServer","noop","devAction","options","cliConfig","output","workDir","app","startWorkbench","result","isApp","started","close","closePlainServer","freshConfig","flags","httpHost","httpPort","host","port","cacheDir","extractManifest","wd","silent","params","reactStrictMode","startAppServer"],"mappings":"AAAA,SAAQA,gBAAgB,QAAO,oCAAmC;AAClE,SAAQC,sBAAsB,QAAO,uCAAsC;AAC3E,SAAQC,cAAc,EAAEC,iBAAiB,QAAO,wBAAuB;AACvE,SAAQC,iBAAiB,EAAEC,sBAAsB,QAAO,4BAA2B;AAEnF,SAAQC,uBAAuB,QAAO,sBAAqB;AAC3D,SAAQC,cAAc,QAAO,+BAA8B;AAC3D,SAAQC,qBAAqB,QAAO,sCAAqC;AACzE,SAAQC,sBAAsB,QAAO,uCAAsC;AAC3E,SAAQC,qBAAqB,QAAO,uCAAsC;AAC1E,SAAQC,iBAAiB,QAAO,iCAAgC;AAChE,SAAQC,oBAAoB,QAAO,oCAAmC;AAGtE,MAAMC,OAAO,WAAa;AAE1B;;;;;;CAMC,GACD,OAAO,eAAeC,UAAUC,OAAyB;IACvD,MAAM,EAACC,SAAS,EAAEC,MAAM,EAAEC,OAAO,EAAC,GAAGH;IAErC,8EAA8E;IAC9E,4EAA4E;IAC5E,IAAIb,eAAec,WAAWG,QAAQhB,kBAAkBa,WAAWG,MAAM;QACvE,OAAOC,eAAeL;IACxB;IAEA,yEAAyE;IACzE,MAAMM,SAAS,MAAM,AAACN,CAAAA,QAAQO,KAAK,GAAGX,oBAAoBC,oBAAmB,EAAGG;IAChF,IAAI,CAACM,OAAOE,OAAO,EAAE,OAAO;QAACC,OAAOX;IAAI;IAExC,OAAOR,uBAAuB;QAC5BoB,kBAAkBJ,OAAOG,KAAK;QAC9BP;QACAG,gBAAgB,CAACM,cACfN,eAAe;gBAAC,GAAGL,OAAO;gBAAEC,WAAWU;gBAAaJ,OAAOf,eAAemB;YAAY;QACxFR;IACF;AACF;AAEA,SAASE,eAAeL,OAAyB;IAC/C,MAAM,EAACC,SAAS,EAAEW,KAAK,EAAEL,KAAK,EAAEL,MAAM,EAAEC,OAAO,EAAC,GAAGH;IACnD,MAAM,EAACa,QAAQ,EAAEC,QAAQ,EAAC,GAAGrB,sBAAsB;QACjDQ;QACAW,OAAO;YAACG,MAAMH,MAAMG,IAAI;YAAEC,MAAMJ,MAAMI,IAAI;QAAA;QAC1Cb;IACF;IAEA,OAAOd,kBAAkB;QACvB4B,UAAU,GAAGhC,iBAAiB,KAAK,CAAC;QACpCM,yBAAyB,IAAMA,wBAAwB;gBAACU;gBAAWC;YAAM;QACzED;QACAiB,iBAAiBX,QACb,CAAC,EAACJ,SAASgB,EAAE,EAAC,GAAKjC,uBAAuB;gBAACkC,QAAQ;gBAAMjB,SAASgB;YAAE,KACpE,CAACE,SAAW1B,sBAAsB;gBAAC,GAAG0B,MAAM;gBAAED,QAAQ;YAAI;QAC9DP;QACAC;QACAP;QACAL;QACA,8EAA8E;QAC9EoB,iBAAiB5B,uBAAuBO,cAAc;QACtDsB,gBAAgB,CAACF,SACf,AAACd,CAAAA,QAAQX,oBAAoBC,oBAAmB,EAAG;gBAAC,GAAGG,OAAO;gBAAE,GAAGqB,MAAM;YAAA;QAC3ElB;IACF;AACF"}
1
+ {"version":3,"sources":["../../../src/actions/dev/devAction.ts"],"sourcesContent":["import {SANITY_CACHE_DIR} from '@sanity/cli-build/_internal/build'\nimport {extractCoreAppManifest} from '@sanity/cli-build/_internal/manifest'\nimport {isWorkbenchApp, isWorkbenchConfig} from '@sanity/workbench-cli'\nimport {startWorkbenchDev, watchForWorkbenchOptIn} from '@sanity/workbench-cli/dev'\n\nimport {checkForDeprecatedAppId} from '../../util/appId.js'\nimport {determineIsApp} from '../../util/determineIsApp.js'\nimport {getSharedServerConfig} from '../../util/getSharedServerConfig.js'\nimport {resolveReactStrictMode} from '../../util/resolveReactStrictMode.js'\nimport {extractStudioManifest} from '../manifest/extractStudioManifest.js'\nimport {startAppDevServer} from './servers/startAppDevServer.js'\nimport {startStudioDevServer} from './servers/startStudioDevServer.js'\nimport {type DevActionOptions} from './types.js'\n\nconst noop = async () => {}\n\n/**\n * Entry point for `sanity dev`. A plain studio/app starts a single dev server, as\n * before workbench existed, and switches to the workbench if `sanity.cli.*` opts\n * in while it runs. A workbench app (via `defineApplication`) delegates to\n * `@sanity/workbench-cli`, injecting the CLI-domain pieces (app server, manifest\n * extraction, app id).\n */\nexport async function devAction(options: DevActionOptions): Promise<{close: () => Promise<void>}> {\n const {cliConfig, output, workDir} = options\n\n // A workbench app (an app to render) or a workbench config (config-only, like\n // the media library, which needs the workbench to render it) both delegate.\n if (isWorkbenchApp(cliConfig?.app) || isWorkbenchConfig(cliConfig?.app)) {\n return startWorkbench(options)\n }\n\n // Plain non-workbench studio/app: one dev server announcing its own URL.\n const result = await (options.isApp ? startAppDevServer : startStudioDevServer)(options)\n if (!result.started) return {close: noop}\n\n return watchForWorkbenchOptIn({\n closePlainServer: result.close,\n output,\n startWorkbench: (freshConfig) =>\n startWorkbench({...options, cliConfig: freshConfig, isApp: determineIsApp(freshConfig)}),\n workDir,\n })\n}\n\nfunction startWorkbench(options: DevActionOptions): Promise<{close: () => Promise<void>}> {\n const {cliConfig, flags, isApp, output, workDir} = options\n const {httpHost, httpPort} = getSharedServerConfig({\n cliConfig,\n flags: {host: flags.host, port: flags.port},\n workDir,\n })\n\n return startWorkbenchDev({\n cacheDir: `${SANITY_CACHE_DIR}/vite`,\n checkForDeprecatedAppId: () => checkForDeprecatedAppId({cliConfig, output}),\n cliConfig,\n extractManifest: isApp\n ? ({iconUrl, workDir: wd}) => extractCoreAppManifest({iconUrl, silent: true, workDir: wd})\n : (params) => extractStudioManifest({...params, silent: true}),\n httpHost,\n httpPort,\n isApp,\n output,\n // Runtime template needs a concrete boolean; collapse an unset config to off.\n reactStrictMode: resolveReactStrictMode(cliConfig) ?? false,\n startAppServer: (params) =>\n (isApp ? startAppDevServer : startStudioDevServer)({...options, ...params}),\n workDir,\n })\n}\n"],"names":["SANITY_CACHE_DIR","extractCoreAppManifest","isWorkbenchApp","isWorkbenchConfig","startWorkbenchDev","watchForWorkbenchOptIn","checkForDeprecatedAppId","determineIsApp","getSharedServerConfig","resolveReactStrictMode","extractStudioManifest","startAppDevServer","startStudioDevServer","noop","devAction","options","cliConfig","output","workDir","app","startWorkbench","result","isApp","started","close","closePlainServer","freshConfig","flags","httpHost","httpPort","host","port","cacheDir","extractManifest","iconUrl","wd","silent","params","reactStrictMode","startAppServer"],"mappings":"AAAA,SAAQA,gBAAgB,QAAO,oCAAmC;AAClE,SAAQC,sBAAsB,QAAO,uCAAsC;AAC3E,SAAQC,cAAc,EAAEC,iBAAiB,QAAO,wBAAuB;AACvE,SAAQC,iBAAiB,EAAEC,sBAAsB,QAAO,4BAA2B;AAEnF,SAAQC,uBAAuB,QAAO,sBAAqB;AAC3D,SAAQC,cAAc,QAAO,+BAA8B;AAC3D,SAAQC,qBAAqB,QAAO,sCAAqC;AACzE,SAAQC,sBAAsB,QAAO,uCAAsC;AAC3E,SAAQC,qBAAqB,QAAO,uCAAsC;AAC1E,SAAQC,iBAAiB,QAAO,iCAAgC;AAChE,SAAQC,oBAAoB,QAAO,oCAAmC;AAGtE,MAAMC,OAAO,WAAa;AAE1B;;;;;;CAMC,GACD,OAAO,eAAeC,UAAUC,OAAyB;IACvD,MAAM,EAACC,SAAS,EAAEC,MAAM,EAAEC,OAAO,EAAC,GAAGH;IAErC,8EAA8E;IAC9E,4EAA4E;IAC5E,IAAIb,eAAec,WAAWG,QAAQhB,kBAAkBa,WAAWG,MAAM;QACvE,OAAOC,eAAeL;IACxB;IAEA,yEAAyE;IACzE,MAAMM,SAAS,MAAM,AAACN,CAAAA,QAAQO,KAAK,GAAGX,oBAAoBC,oBAAmB,EAAGG;IAChF,IAAI,CAACM,OAAOE,OAAO,EAAE,OAAO;QAACC,OAAOX;IAAI;IAExC,OAAOR,uBAAuB;QAC5BoB,kBAAkBJ,OAAOG,KAAK;QAC9BP;QACAG,gBAAgB,CAACM,cACfN,eAAe;gBAAC,GAAGL,OAAO;gBAAEC,WAAWU;gBAAaJ,OAAOf,eAAemB;YAAY;QACxFR;IACF;AACF;AAEA,SAASE,eAAeL,OAAyB;IAC/C,MAAM,EAACC,SAAS,EAAEW,KAAK,EAAEL,KAAK,EAAEL,MAAM,EAAEC,OAAO,EAAC,GAAGH;IACnD,MAAM,EAACa,QAAQ,EAAEC,QAAQ,EAAC,GAAGrB,sBAAsB;QACjDQ;QACAW,OAAO;YAACG,MAAMH,MAAMG,IAAI;YAAEC,MAAMJ,MAAMI,IAAI;QAAA;QAC1Cb;IACF;IAEA,OAAOd,kBAAkB;QACvB4B,UAAU,GAAGhC,iBAAiB,KAAK,CAAC;QACpCM,yBAAyB,IAAMA,wBAAwB;gBAACU;gBAAWC;YAAM;QACzED;QACAiB,iBAAiBX,QACb,CAAC,EAACY,OAAO,EAAEhB,SAASiB,EAAE,EAAC,GAAKlC,uBAAuB;gBAACiC;gBAASE,QAAQ;gBAAMlB,SAASiB;YAAE,KACtF,CAACE,SAAW3B,sBAAsB;gBAAC,GAAG2B,MAAM;gBAAED,QAAQ;YAAI;QAC9DR;QACAC;QACAP;QACAL;QACA,8EAA8E;QAC9EqB,iBAAiB7B,uBAAuBO,cAAc;QACtDuB,gBAAgB,CAACF,SACf,AAACf,CAAAA,QAAQX,oBAAoBC,oBAAmB,EAAG;gBAAC,GAAGG,OAAO;gBAAE,GAAGsB,MAAM;YAAA;QAC3EnB;IACF;AACF"}
@@ -1,3 +1,4 @@
1
+ import { constants as fsConstants } from 'node:fs';
1
2
  import fs from 'node:fs/promises';
2
3
  import path from 'node:path';
3
4
  import { styleText } from 'node:util';
@@ -58,6 +59,12 @@ export async function bootstrapLocalTemplate(opts) {
58
59
  await copy(path.join(sharedDir, 'gitignore.txt'), outputPath, {
59
60
  rename: ()=>'.gitignore'
60
61
  });
62
+ // Studio templates ship no AGENTS.md of their own, so copy the shared
63
+ // agent guide into every non-app scaffold. The normal template copier
64
+ // overwrites, so request exclusive copy to never clobber an AGENTS.md.
65
+ if (!isAppTemplate && !isMediaLibraryTemplate) {
66
+ await copyFileIfNotExists(path.join(sharedDir, 'AGENTS.md'), path.join(outputPath, 'AGENTS.md'));
67
+ }
61
68
  // Dashboard apps dev and deploy differently, so their docs replace the
62
69
  // template's. Studio templates have no overlay.
63
70
  if (isAppTemplate && variables.workbench) {
@@ -173,6 +180,17 @@ export async function bootstrapLocalTemplate(opts) {
173
180
  // Finish up by providing init process with template-specific info
174
181
  spin.succeed();
175
182
  return template;
183
+ async function copyFileIfNotExists(sourcePath, targetPath) {
184
+ try {
185
+ await fs.copyFile(sourcePath, targetPath, fsConstants.COPYFILE_EXCL);
186
+ } catch (err) {
187
+ if (err.code === 'EEXIST') {
188
+ output.warn(`\n${styleText('yellow', '⚠')} File "${targetPath}" already exists, skipping`);
189
+ } else {
190
+ throw err;
191
+ }
192
+ }
193
+ }
176
194
  async function writeFileIfNotExists(fileName, content) {
177
195
  const filePath = path.join(outputPath, fileName);
178
196
  if (opts.overwriteFiles) {
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/actions/init/bootstrapLocalTemplate.ts"],"sourcesContent":["import fs from 'node:fs/promises'\nimport path from 'node:path'\nimport {styleText} from 'node:util'\n\nimport {Output, subdebug} from '@sanity/cli-core'\nimport {spinner} from '@sanity/cli-core/ux'\nimport {toAppSlug} from '@sanity/workbench-cli/init'\nimport deburr from 'lodash-es/deburr.js'\n\nimport {copy} from '../../util/copy.js'\nimport {resolveLatestVersions} from '../../util/resolveLatestVersions.js'\nimport {createAppCliConfig} from './createAppCliConfig.js'\nimport {createCliConfig} from './createCliConfig.js'\nimport {createMediaLibraryCliConfig} from './createMediaLibraryCliConfig.js'\nimport {createPackageManifest} from './createPackageManifest.js'\nimport {createStudioConfig, type GenerateConfigOptions} from './createStudioConfig.js'\nimport {determineAppTemplate} from './determineAppTemplate.js'\nimport {determineMediaLibraryTemplate} from './determineMediaLibraryTemplate.js'\nimport {processTemplate} from './processTemplate.js'\nimport {sdkAppDependencies} from './sdkAppDependencies.js'\nimport {studioDependencies} from './studioDependencies.js'\nimport templates from './templates/index.js'\nimport {type ProjectTemplate} from './types.js'\nimport {updateInitialTemplateMetadata} from './updateInitialTemplateMetadata.js'\n\nconst debug = subdebug('init:bootstrapRemoteTemplate')\n\ninterface BootstrapLocalOptions {\n output: Output\n outputPath: string\n packageName: string\n templateName: string\n useTypeScript: boolean\n variables: GenerateConfigOptions['variables']\n\n overwriteFiles?: boolean\n}\n\nexport async function bootstrapLocalTemplate(\n opts: BootstrapLocalOptions,\n): Promise<ProjectTemplate> {\n const {output, outputPath, packageName, templateName, useTypeScript, variables} = opts\n // packages/@sanity/cli/src/actions/init/ -> packages/@sanity/cli/src/action -> packages/@sanity/cli/src/\n const cliRoot = path.resolve(import.meta.dirname, '../../..')\n const templatesDir = path.join(cliRoot, 'templates')\n const sourceDir = path.join(templatesDir, templateName)\n const sharedDir = path.join(templatesDir, 'shared')\n const isAppTemplate = determineAppTemplate(templateName)\n const isMediaLibraryTemplate = determineMediaLibraryTemplate(templateName)\n // Media Library config apps bring their own dependency set: neither the\n // SDK-app base nor the studio base applies (see templates/mediaLibraryConfig.ts).\n const baseDependencies = isAppTemplate\n ? sdkAppDependencies\n : isMediaLibraryTemplate\n ? {dependencies: {}, devDependencies: {}}\n : studioDependencies\n\n // Check that we have a template info file (dependencies, plugins etc)\n const template = templates[templateName]\n if (!template) {\n throw new Error(`Template \"${templateName}\" not defined`)\n }\n\n // Copy template files\n debug('Copying files from template \"%s\" to \"%s\"', templateName, outputPath)\n let spin = spinner('Bootstrapping files from template').start()\n\n debug(`Copying template from : ${sourceDir}`)\n await copy(sourceDir, outputPath, {\n rename: useTypeScript ? toTypeScriptPath : undefined,\n })\n // The Media Library template ships its own eslint config (a\n // restricted-imports override for field modules), stored as .txt — same\n // trick as shared/gitignore.txt — so the repo's own ESLint doesn't pick it\n // up as the nearest config for the template files.\n if (isMediaLibraryTemplate) {\n await fs.rename(\n path.join(outputPath, 'eslint.config.txt'),\n path.join(outputPath, 'eslint.config.mjs'),\n )\n }\n debug(`Copying shared template code from : ${sharedDir}`)\n await copy(path.join(sharedDir, 'gitignore.txt'), outputPath, {rename: () => '.gitignore'})\n // Dashboard apps dev and deploy differently, so their docs replace the\n // template's. Studio templates have no overlay.\n if (isAppTemplate && variables.workbench) {\n await copy(path.join(sharedDir, 'dashboard', templateName), outputPath)\n }\n\n if (useTypeScript) {\n await fs.copyFile(path.join(sharedDir, 'tsconfig.json'), path.join(outputPath, 'tsconfig.json'))\n }\n\n spin.succeed()\n\n if (isAppTemplate) {\n const appEntryPath = path.join(outputPath, 'src', 'App.tsx')\n const raw = await fs.readFile(appEntryPath, 'utf8')\n const rendered = processTemplate({\n template: raw,\n variables: {\n dataset: variables.dataset ?? '',\n projectId: variables.projectId ?? '',\n },\n })\n await fs.writeFile(appEntryPath, rendered)\n }\n\n // Merge global and template-specific plugins and dependencies\n\n // Resolve latest versions of Sanity-dependencies\n spin = spinner('Resolving latest module versions').start()\n const dependencyVersions = await resolveLatestVersions({\n ...baseDependencies.dependencies,\n ...baseDependencies.devDependencies,\n ...template.dependencies,\n ...template.devDependencies,\n })\n spin.succeed()\n\n // Use the resolved version for the given dependency\n const dependencies: Record<string, string> = {}\n for (const dependency of Object.keys({\n ...baseDependencies.dependencies,\n ...template.dependencies,\n })) {\n dependencies[dependency] = dependencyVersions[dependency]\n }\n\n const devDependencies: Record<string, string> = {}\n for (const dependency of Object.keys({\n ...baseDependencies.devDependencies,\n ...template.devDependencies,\n })) {\n devDependencies[dependency] = dependencyVersions[dependency]\n }\n\n let packageJsonName: string = packageName\n\n /**\n * Currently app init doesn't ask for a name, so we use the last part of the path\n */\n if (isAppTemplate || isMediaLibraryTemplate) {\n packageJsonName = slugify(path.basename(outputPath))\n }\n\n const title = variables.projectName || packageJsonName\n // Default the workbench app `slug` (the hostname the application is created\n // at on deploy). App init never asks for a name (`variables.projectName` is\n // just the cwd basename there), so apps follow their identity — the\n // output-path basename (`packageJsonName`) — while studios slug the entered\n // project name. Fall back to a constant when the source slugifies to\n // nothing (e.g. a fully non-latin name): an empty `slug` fails app config\n // validation, which is exactly what pre-filling it is meant to avoid.\n const slug = toAppSlug(isAppTemplate ? packageJsonName : title) ?? 'sanity-app'\n\n // Now create a package manifest (`package.json`) with the merged dependencies\n spin = spinner('Creating default project files').start()\n const packageManifest = createPackageManifest({\n dependencies,\n devDependencies,\n // Media Library config apps also skip the opinionated prettier config.\n isAppTemplate: isAppTemplate || isMediaLibraryTemplate,\n name: packageJsonName,\n scripts: template.scripts,\n type: template.type,\n })\n\n // ...and a studio config (`sanity.config.[ts|js]`) — only for studio\n // templates. App and media-library scaffolds don't write one, and building\n // it anyway would demand studio variables (projectId) they don't carry.\n const studioConfig =\n isAppTemplate || isMediaLibraryTemplate\n ? null\n : createStudioConfig({\n template: template.configTemplate,\n variables,\n })\n\n // ...and a CLI config (`sanity.cli.[ts|js]`)\n // oxlint-disable-next-line no-nested-ternary -- three scaffold shapes share one write path\n const cliConfig = isMediaLibraryTemplate\n ? createMediaLibraryCliConfig({organizationId: variables.organizationId})\n : isAppTemplate\n ? createAppCliConfig({\n entry: template.entry!,\n isWorkbenchApp: variables.workbench,\n organizationId: variables.organizationId,\n slug,\n title,\n })\n : createCliConfig({\n autoUpdates: variables.autoUpdates,\n dataset: variables.dataset,\n isWorkbenchApp: variables.workbench,\n organizationId: variables.organizationId,\n projectId: variables.projectId,\n slug,\n title,\n })\n\n // Write non-template files to disc\n const codeExt = useTypeScript ? 'ts' : 'js'\n await Promise.all(\n [\n studioConfig === null\n ? Promise.resolve(null)\n : writeFileIfNotExists(`sanity.config.${codeExt}`, studioConfig),\n writeFileIfNotExists(`sanity.cli.${codeExt}`, cliConfig),\n writeFileIfNotExists('package.json', packageManifest),\n\n // The Media Library template ships its own eslint.config.mjs (a\n // restricted-imports override for field modules) in the copied files.\n isMediaLibraryTemplate\n ? Promise.resolve(null)\n : writeFileIfNotExists(\n 'eslint.config.mjs',\n `import studio from '@sanity/eslint-config-studio'\\n\\nexport default [...studio]\\n`,\n ),\n ].filter(Boolean),\n )\n\n debug('Updating initial template metadata')\n if (variables.projectId) {\n await updateInitialTemplateMetadata(variables.projectId, `cli-${templateName}`)\n }\n\n // Finish up by providing init process with template-specific info\n spin.succeed()\n return template\n\n async function writeFileIfNotExists(fileName: string, content: string): Promise<void> {\n const filePath = path.join(outputPath, fileName)\n\n if (opts.overwriteFiles) {\n // If overwrite is enabled, just write the file\n await fs.writeFile(filePath, content)\n return\n }\n\n try {\n await fs.writeFile(filePath, content, {flag: 'wx'})\n } catch (err) {\n if (err.code === 'EEXIST') {\n output.warn(`\\n${styleText('yellow', '⚠')} File \"${filePath}\" already exists, skipping`)\n } else {\n throw err\n }\n }\n }\n}\n\nfunction toTypeScriptPath(originalPath: string): string {\n return originalPath.replace(/\\.js$/, '.ts')\n}\n\n/** Lowercase, deburred, spaces to hyphens, everything else stripped. */\nfunction slugify(value: string): string {\n return deburr(value.toLowerCase())\n .replaceAll(/\\s+/g, '-')\n .replaceAll(/[^a-z0-9-]/g, '')\n}\n"],"names":["fs","path","styleText","subdebug","spinner","toAppSlug","deburr","copy","resolveLatestVersions","createAppCliConfig","createCliConfig","createMediaLibraryCliConfig","createPackageManifest","createStudioConfig","determineAppTemplate","determineMediaLibraryTemplate","processTemplate","sdkAppDependencies","studioDependencies","templates","updateInitialTemplateMetadata","debug","bootstrapLocalTemplate","opts","output","outputPath","packageName","templateName","useTypeScript","variables","cliRoot","resolve","dirname","templatesDir","join","sourceDir","sharedDir","isAppTemplate","isMediaLibraryTemplate","baseDependencies","dependencies","devDependencies","template","Error","spin","start","rename","toTypeScriptPath","undefined","workbench","copyFile","succeed","appEntryPath","raw","readFile","rendered","dataset","projectId","writeFile","dependencyVersions","dependency","Object","keys","packageJsonName","slugify","basename","title","projectName","slug","packageManifest","name","scripts","type","studioConfig","configTemplate","cliConfig","organizationId","entry","isWorkbenchApp","autoUpdates","codeExt","Promise","all","writeFileIfNotExists","filter","Boolean","fileName","content","filePath","overwriteFiles","flag","err","code","warn","originalPath","replace","value","toLowerCase","replaceAll"],"mappings":"AAAA,OAAOA,QAAQ,mBAAkB;AACjC,OAAOC,UAAU,YAAW;AAC5B,SAAQC,SAAS,QAAO,YAAW;AAEnC,SAAgBC,QAAQ,QAAO,mBAAkB;AACjD,SAAQC,OAAO,QAAO,sBAAqB;AAC3C,SAAQC,SAAS,QAAO,6BAA4B;AACpD,OAAOC,YAAY,sBAAqB;AAExC,SAAQC,IAAI,QAAO,qBAAoB;AACvC,SAAQC,qBAAqB,QAAO,sCAAqC;AACzE,SAAQC,kBAAkB,QAAO,0BAAyB;AAC1D,SAAQC,eAAe,QAAO,uBAAsB;AACpD,SAAQC,2BAA2B,QAAO,mCAAkC;AAC5E,SAAQC,qBAAqB,QAAO,6BAA4B;AAChE,SAAQC,kBAAkB,QAAmC,0BAAyB;AACtF,SAAQC,oBAAoB,QAAO,4BAA2B;AAC9D,SAAQC,6BAA6B,QAAO,qCAAoC;AAChF,SAAQC,eAAe,QAAO,uBAAsB;AACpD,SAAQC,kBAAkB,QAAO,0BAAyB;AAC1D,SAAQC,kBAAkB,QAAO,0BAAyB;AAC1D,OAAOC,eAAe,uBAAsB;AAE5C,SAAQC,6BAA6B,QAAO,qCAAoC;AAEhF,MAAMC,QAAQlB,SAAS;AAavB,OAAO,eAAemB,uBACpBC,IAA2B;IAE3B,MAAM,EAACC,MAAM,EAAEC,UAAU,EAAEC,WAAW,EAAEC,YAAY,EAAEC,aAAa,EAAEC,SAAS,EAAC,GAAGN;IAClF,yGAAyG;IACzG,MAAMO,UAAU7B,KAAK8B,OAAO,CAAC,YAAYC,OAAO,EAAE;IAClD,MAAMC,eAAehC,KAAKiC,IAAI,CAACJ,SAAS;IACxC,MAAMK,YAAYlC,KAAKiC,IAAI,CA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qBACE,qBACA,CAAC,iFAAiF,CAAC;KAE1F,CAACC,MAAM,CAACC;IAGXhE,MAAM;IACN,IAAIQ,UAAU4B,SAAS,EAAE;QACvB,MAAMrC,8BAA8BS,UAAU4B,SAAS,EAAE,CAAC,IAAI,EAAE9B,cAAc;IAChF;IAEA,kEAAkE;IAClEiB,KAAKO,OAAO;IACZ,OAAOT;IAEP,eAAeyC,qBAAqBG,QAAgB,EAAEC,OAAe;QACnE,MAAMC,WAAWvF,KAAKiC,IAAI,CAACT,YAAY6D;QAEvC,IAAI/D,KAAKkE,cAAc,EAAE;YACvB,+CAA+C;YAC/C,MAAMzF,GAAG0D,SAAS,CAAC8B,UAAUD;YAC7B;QACF;QAEA,IAAI;YACF,MAAMvF,GAAG0D,SAAS,CAAC8B,UAAUD,SAAS;gBAACG,MAAM;YAAI;QACnD,EAAE,OAAOC,KAAK;YACZ,IAAIA,IAAIC,IAAI,KAAK,UAAU;gBACzBpE,OAAOqE,IAAI,CAAC,CAAC,EAAE,EAAE3F,UAAU,UAAU,KAAK,OAAO,EAAEsF,SAAS,0BAA0B,CAAC;YACzF,OAAO;gBACL,MAAMG;YACR;QACF;IACF;AACF;AAEA,SAAS5C,iBAAiB+C,YAAoB;IAC5C,OAAOA,aAAaC,OAAO,CAAC,SAAS;AACvC;AAEA,sEAAsE,GACtE,SAAS/B,QAAQgC,KAAa;IAC5B,OAAO1F,OAAO0F,MAAMC,WAAW,IAC5BC,UAAU,CAAC,QAAQ,KACnBA,UAAU,CAAC,eAAe;AAC/B"}
1
+ {"version":3,"sources":["../../../src/actions/init/bootstrapLocalTemplate.ts"],"sourcesContent":["import {constants as fsConstants} from 'node:fs'\nimport fs from 'node:fs/promises'\nimport path from 'node:path'\nimport {styleText} from 'node:util'\n\nimport {Output, subdebug} from '@sanity/cli-core'\nimport {spinner} from '@sanity/cli-core/ux'\nimport {toAppSlug} from '@sanity/workbench-cli/init'\nimport deburr from 'lodash-es/deburr.js'\n\nimport {copy} from '../../util/copy.js'\nimport {resolveLatestVersions} from '../../util/resolveLatestVersions.js'\nimport {createAppCliConfig} from './createAppCliConfig.js'\nimport {createCliConfig} from './createCliConfig.js'\nimport {createMediaLibraryCliConfig} from './createMediaLibraryCliConfig.js'\nimport {createPackageManifest} from './createPackageManifest.js'\nimport {createStudioConfig, type GenerateConfigOptions} from './createStudioConfig.js'\nimport {determineAppTemplate} from './determineAppTemplate.js'\nimport {determineMediaLibraryTemplate} from './determineMediaLibraryTemplate.js'\nimport {processTemplate} from './processTemplate.js'\nimport {sdkAppDependencies} from './sdkAppDependencies.js'\nimport {studioDependencies} from './studioDependencies.js'\nimport templates from './templates/index.js'\nimport {type ProjectTemplate} from './types.js'\nimport {updateInitialTemplateMetadata} from './updateInitialTemplateMetadata.js'\n\nconst debug = subdebug('init:bootstrapRemoteTemplate')\n\ninterface BootstrapLocalOptions {\n output: Output\n outputPath: string\n packageName: string\n templateName: string\n useTypeScript: boolean\n variables: GenerateConfigOptions['variables']\n\n overwriteFiles?: boolean\n}\n\nexport async function bootstrapLocalTemplate(\n opts: BootstrapLocalOptions,\n): Promise<ProjectTemplate> {\n const {output, outputPath, packageName, templateName, useTypeScript, variables} = opts\n // packages/@sanity/cli/src/actions/init/ -> packages/@sanity/cli/src/action -> packages/@sanity/cli/src/\n const cliRoot = path.resolve(import.meta.dirname, '../../..')\n const templatesDir = path.join(cliRoot, 'templates')\n const sourceDir = path.join(templatesDir, templateName)\n const sharedDir = path.join(templatesDir, 'shared')\n const isAppTemplate = determineAppTemplate(templateName)\n const isMediaLibraryTemplate = determineMediaLibraryTemplate(templateName)\n // Media Library config apps bring their own dependency set: neither the\n // SDK-app base nor the studio base applies (see templates/mediaLibraryConfig.ts).\n const baseDependencies = isAppTemplate\n ? sdkAppDependencies\n : isMediaLibraryTemplate\n ? {dependencies: {}, devDependencies: {}}\n : studioDependencies\n\n // Check that we have a template info file (dependencies, plugins etc)\n const template = templates[templateName]\n if (!template) {\n throw new Error(`Template \"${templateName}\" not defined`)\n }\n\n // Copy template files\n debug('Copying files from template \"%s\" to \"%s\"', templateName, outputPath)\n let spin = spinner('Bootstrapping files from template').start()\n\n debug(`Copying template from : ${sourceDir}`)\n await copy(sourceDir, outputPath, {\n rename: useTypeScript ? toTypeScriptPath : undefined,\n })\n // The Media Library template ships its own eslint config (a\n // restricted-imports override for field modules), stored as .txt — same\n // trick as shared/gitignore.txt — so the repo's own ESLint doesn't pick it\n // up as the nearest config for the template files.\n if (isMediaLibraryTemplate) {\n await fs.rename(\n path.join(outputPath, 'eslint.config.txt'),\n path.join(outputPath, 'eslint.config.mjs'),\n )\n }\n debug(`Copying shared template code from : ${sharedDir}`)\n await copy(path.join(sharedDir, 'gitignore.txt'), outputPath, {rename: () => '.gitignore'})\n // Studio templates ship no AGENTS.md of their own, so copy the shared\n // agent guide into every non-app scaffold. The normal template copier\n // overwrites, so request exclusive copy to never clobber an AGENTS.md.\n if (!isAppTemplate && !isMediaLibraryTemplate) {\n await copyFileIfNotExists(path.join(sharedDir, 'AGENTS.md'), path.join(outputPath, 'AGENTS.md'))\n }\n // Dashboard apps dev and deploy differently, so their docs replace the\n // template's. Studio templates have no overlay.\n if (isAppTemplate && variables.workbench) {\n await copy(path.join(sharedDir, 'dashboard', templateName), outputPath)\n }\n\n if (useTypeScript) {\n await fs.copyFile(path.join(sharedDir, 'tsconfig.json'), path.join(outputPath, 'tsconfig.json'))\n }\n\n spin.succeed()\n\n if (isAppTemplate) {\n const appEntryPath = path.join(outputPath, 'src', 'App.tsx')\n const raw = await fs.readFile(appEntryPath, 'utf8')\n const rendered = processTemplate({\n template: raw,\n variables: {\n dataset: variables.dataset ?? '',\n projectId: variables.projectId ?? '',\n },\n })\n await fs.writeFile(appEntryPath, rendered)\n }\n\n // Merge global and template-specific plugins and dependencies\n\n // Resolve latest versions of Sanity-dependencies\n spin = spinner('Resolving latest module versions').start()\n const dependencyVersions = await resolveLatestVersions({\n ...baseDependencies.dependencies,\n ...baseDependencies.devDependencies,\n ...template.dependencies,\n ...template.devDependencies,\n })\n spin.succeed()\n\n // Use the resolved version for the given dependency\n const dependencies: Record<string, string> = {}\n for (const dependency of Object.keys({\n ...baseDependencies.dependencies,\n ...template.dependencies,\n })) {\n dependencies[dependency] = dependencyVersions[dependency]\n }\n\n const devDependencies: Record<string, string> = {}\n for (const dependency of Object.keys({\n ...baseDependencies.devDependencies,\n ...template.devDependencies,\n })) {\n devDependencies[dependency] = dependencyVersions[dependency]\n }\n\n let packageJsonName: string = packageName\n\n /**\n * Currently app init doesn't ask for a name, so we use the last part of the path\n */\n if (isAppTemplate || isMediaLibraryTemplate) {\n packageJsonName = slugify(path.basename(outputPath))\n }\n\n const title = variables.projectName || packageJsonName\n // Default the workbench app `slug` (the hostname the application is created\n // at on deploy). App init never asks for a name (`variables.projectName` is\n // just the cwd basename there), so apps follow their identity — the\n // output-path basename (`packageJsonName`) — while studios slug the entered\n // project name. Fall back to a constant when the source slugifies to\n // nothing (e.g. a fully non-latin name): an empty `slug` fails app config\n // validation, which is exactly what pre-filling it is meant to avoid.\n const slug = toAppSlug(isAppTemplate ? packageJsonName : title) ?? 'sanity-app'\n\n // Now create a package manifest (`package.json`) with the merged dependencies\n spin = spinner('Creating default project files').start()\n const packageManifest = createPackageManifest({\n dependencies,\n devDependencies,\n // Media Library config apps also skip the opinionated prettier config.\n isAppTemplate: isAppTemplate || isMediaLibraryTemplate,\n name: packageJsonName,\n scripts: template.scripts,\n type: template.type,\n })\n\n // ...and a studio config (`sanity.config.[ts|js]`) — only for studio\n // templates. App and media-library scaffolds don't write one, and building\n // it anyway would demand studio variables (projectId) they don't carry.\n const studioConfig =\n isAppTemplate || isMediaLibraryTemplate\n ? null\n : createStudioConfig({\n template: template.configTemplate,\n variables,\n })\n\n // ...and a CLI config (`sanity.cli.[ts|js]`)\n // oxlint-disable-next-line no-nested-ternary -- three scaffold shapes share one write path\n const cliConfig = isMediaLibraryTemplate\n ? createMediaLibraryCliConfig({organizationId: variables.organizationId})\n : isAppTemplate\n ? createAppCliConfig({\n entry: template.entry!,\n isWorkbenchApp: variables.workbench,\n organizationId: variables.organizationId,\n slug,\n title,\n })\n : createCliConfig({\n autoUpdates: variables.autoUpdates,\n dataset: variables.dataset,\n isWorkbenchApp: variables.workbench,\n organizationId: variables.organizationId,\n projectId: variables.projectId,\n slug,\n title,\n })\n\n // Write non-template files to disc\n const codeExt = useTypeScript ? 'ts' : 'js'\n await Promise.all(\n [\n studioConfig === null\n ? Promise.resolve(null)\n : writeFileIfNotExists(`sanity.config.${codeExt}`, studioConfig),\n writeFileIfNotExists(`sanity.cli.${codeExt}`, cliConfig),\n writeFileIfNotExists('package.json', packageManifest),\n\n // The Media Library template ships its own eslint.config.mjs (a\n // restricted-imports override for field modules) in the copied files.\n isMediaLibraryTemplate\n ? Promise.resolve(null)\n : writeFileIfNotExists(\n 'eslint.config.mjs',\n `import studio from '@sanity/eslint-config-studio'\\n\\nexport default [...studio]\\n`,\n ),\n ].filter(Boolean),\n )\n\n debug('Updating initial template metadata')\n if (variables.projectId) {\n await updateInitialTemplateMetadata(variables.projectId, `cli-${templateName}`)\n }\n\n // Finish up by providing init process with template-specific info\n spin.succeed()\n return template\n\n async function copyFileIfNotExists(sourcePath: string, targetPath: string): Promise<void> {\n try {\n await fs.copyFile(sourcePath, targetPath, fsConstants.COPYFILE_EXCL)\n } catch (err) {\n if (err.code === 'EEXIST') {\n output.warn(`\\n${styleText('yellow', '⚠')} File \"${targetPath}\" already exists, skipping`)\n } else {\n throw err\n }\n }\n }\n\n async function writeFileIfNotExists(fileName: string, content: string): Promise<void> {\n const filePath = path.join(outputPath, fileName)\n\n if (opts.overwriteFiles) {\n // If overwrite is enabled, just write the file\n await fs.writeFile(filePath, content)\n return\n }\n\n try {\n await fs.writeFile(filePath, content, {flag: 'wx'})\n } catch (err) {\n if (err.code === 'EEXIST') {\n output.warn(`\\n${styleText('yellow', '⚠')} File \"${filePath}\" already exists, skipping`)\n } else {\n throw err\n }\n }\n }\n}\n\nfunction toTypeScriptPath(originalPath: string): string {\n return originalPath.replace(/\\.js$/, '.ts')\n}\n\n/** Lowercase, deburred, spaces to hyphens, everything else stripped. */\nfunction slugify(value: string): string {\n return deburr(value.toLowerCase())\n .replaceAll(/\\s+/g, '-')\n .replaceAll(/[^a-z0-9-]/g, '')\n}\n"],"names":["constants","fsConstants","fs","path","styleText","subdebug","spinner","toAppSlug","deburr","copy","resolveLatestVersions","createAppCliConfig","createCliConfig","createMediaLibraryCliConfig","createPackageManifest","createStudioConfig","determineAppTemplate","determineMediaLibraryTemplate","processTemplate","sdkAppDependencies","studioDependencies","templates","updateInitialTemplateMetadata","debug","bootstrapLocalTemplate","opts","output","outputPath","packageName","templateName","useTypeScript","variables","cliRoot","resolve","dirname","templatesDir","join","sourceDir","sharedDir","isAppTemplate","isMediaLibraryTemplate","baseDependencies","dependencies","devDependencies","template","Error","spin","start","rename","toTypeScriptPath","undefined","copyFileIfNotExists","workbench","copyFile","succeed","appEntryPath","raw","readFile","rendered","dataset","projectId","writeFile","dependencyVersions","dependency","Object","keys","packageJsonName","slugify","basename","title","projectName","slug","packageManifest","name","scripts","type","studioConfig","configTemplate","cliConfig","organizationId","entry","isWorkbenchApp","autoUpdates","codeExt","Promise","all","writeFileIfNotExists","filter","Boolean","sourcePath","targetPath","COPYFILE_EXCL","err","code","warn","fileName","content","filePath","overwriteFiles","flag","originalPath","replace","value","toLowerCase","replaceAll"],"mappings":"AAAA,SAAQA,aAAaC,WAAW,QAAO,UAAS;AAChD,OAAOC,QAAQ,mBAAkB;AACjC,OAAOC,UAAU,YAAW;AAC5B,SAAQC,SAAS,QAAO,YAAW;AAEnC,SAAgBC,QAAQ,QAAO,mBAAkB;AACjD,SAAQC,OAAO,QAAO,sBAAqB;AAC3C,SAAQC,SAAS,QAAO,6BAA4B;AACpD,OAAOC,YAAY,sBAAqB;AAExC,SAAQC,IAAI,QAAO,qBAAoB;AACvC,SAAQC,qBAAqB,QAAO,sCAAqC;AACzE,SAAQC,kBAAkB,QAAO,0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AACoC,YAAYC,YAAYzF,YAAY0F,aAAa;QACrE,EAAE,OAAOC,KAAK;YACZ,IAAIA,IAAIC,IAAI,KAAK,UAAU;gBACzBnE,OAAOoE,IAAI,CAAC,CAAC,EAAE,EAAE1F,UAAU,UAAU,KAAK,OAAO,EAAEsF,WAAW,0BAA0B,CAAC;YAC3F,OAAO;gBACL,MAAME;YACR;QACF;IACF;IAEA,eAAeN,qBAAqBS,QAAgB,EAAEC,OAAe;QACnE,MAAMC,WAAW9F,KAAKiC,IAAI,CAACT,YAAYoE;QAEvC,IAAItE,KAAKyE,cAAc,EAAE;YACvB,+CAA+C;YAC/C,MAAMhG,GAAG2D,SAAS,CAACoC,UAAUD;YAC7B;QACF;QAEA,IAAI;YACF,MAAM9F,GAAG2D,SAAS,CAACoC,UAAUD,SAAS;gBAACG,MAAM;YAAI;QACnD,EAAE,OAAOP,KAAK;YACZ,IAAIA,IAAIC,IAAI,KAAK,UAAU;gBACzBnE,OAAOoE,IAAI,CAAC,CAAC,EAAE,EAAE1F,UAAU,UAAU,KAAK,OAAO,EAAE6F,SAAS,0BAA0B,CAAC;YACzF,OAAO;gBACL,MAAML;YACR;QACF;IACF;AACF;AAEA,SAAS3C,iBAAiBmD,YAAoB;IAC5C,OAAOA,aAAaC,OAAO,CAAC,SAAS;AACvC;AAEA,sEAAsE,GACtE,SAASlC,QAAQmC,KAAa;IAC5B,OAAO9F,OAAO8F,MAAMC,WAAW,IAC5BC,UAAU,CAAC,QAAQ,KACnBA,UAAU,CAAC,eAAe;AAC/B"}
@@ -87,8 +87,8 @@ const debug = subdebug('mcp:detectAvailableEditors');
87
87
  */ export async function detectAvailableEditors(env) {
88
88
  const ctx = env ?? createDetectionEnv();
89
89
  // Detect all editors in parallel to avoid stacking timeouts —
90
- // CLI-based editors (Claude Code, Codex CLI, OpenCode) each have a
91
- // 5s execa timeout, so sequential detection can add ~15s on machines
90
+ // CLI-based editors (Claude Code, Codex CLI, OpenCode, Pi) each have a
91
+ // 5s execa timeout, so sequential detection can add ~20s on machines
92
92
  // where none are installed.
93
93
  const results = await Promise.all(Object.entries(EDITOR_CONFIGS).map(async ([name, config])=>{
94
94
  const configPath = await config.detect(ctx);
@@ -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 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","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;AAE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AiB,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"}
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, Pi) each have a\n // 5s execa timeout, so sequential detection can add ~20s 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","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,EAEdC,cAAc,QACT,qBAAoB;AAG3B,MAAMC,QAAQP,SAAS;AAMvB;;;CAGC,GACD,SAASQ,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,SAASV,UAAUM;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,SAASX,WAAWO,SAASO,QAAQ;QAACC,oBAAoB;IAAI;IAEpE,IAAID,OAAOE,MAAM,GAAG,KAAK,OAAOL,WAAW,YAAYA,WAAW,QAAQC,MAAMC,OAAO,CAACF,SAAS;QAC/F,OAAO,KAAK,eAAe;;IAC7B;IAEA,OAAOA;AACT;AAEA;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7 @@ import { existsSync } from 'node:fs';
2
2
  import os from 'node:os';
3
3
  import path from 'node:path';
4
4
  import { execa } from 'execa';
5
+ import { gte as semverGte, valid as semverValid } from 'semver';
5
6
  import { MCP_SERVER_URL } from '../../services/mcp.js';
6
7
  /** Create the real detection environment backed by process/OS globals. */ export function createDetectionEnv() {
7
8
  return {
@@ -9,7 +10,7 @@ import { MCP_SERVER_URL } from '../../services/mcp.js';
9
10
  execCommand: (cmd, args)=>execa(cmd, args, {
10
11
  stdio: 'pipe',
11
12
  timeout: 5000
12
- }).then(()=>{}),
13
+ }).then((res)=>res.stdout),
13
14
  existsSync,
14
15
  homedir: os.homedir(),
15
16
  platform: process.platform
@@ -95,6 +96,20 @@ async function detectOpenCode(ctx) {
95
96
  return null;
96
97
  }
97
98
  }
99
+ async function detectPi(ctx) {
100
+ try {
101
+ const stdout = await ctx.execCommand('pi', [
102
+ '--version'
103
+ ]);
104
+ const version = semverValid(stdout.trim());
105
+ // Built-in MCP support was introduced in Pi v1
106
+ if (!version || !semverGte(version, '1.0.0')) return null;
107
+ const piDir = ctx.env.PI_CODING_AGENT_DIR || path.join(ctx.homedir, '.pi/agent');
108
+ return path.join(piDir, 'mcp.json');
109
+ } catch {
110
+ return null;
111
+ }
112
+ }
98
113
  async function detectVSCode(ctx) {
99
114
  const configDir = getVSCodeUserDir(ctx);
100
115
  return configDir && ctx.existsSync(configDir) ? path.join(configDir, 'mcp.json') : null;
@@ -279,6 +294,13 @@ function buildZedServerConfig() {
279
294
  detect: detectOpenCode,
280
295
  skillsCliAgent: 'opencode'
281
296
  },
297
+ // Doc: https://github.com/earendil-works/pi/blob/main/packages/coding-agent/docs/mcp.md
298
+ // Path: $PI_CODING_AGENT_DIR || ~/.pi/agent/mcp.json Key: mcpServers
299
+ Pi: {
300
+ ...EDITOR_DEFAULTS,
301
+ detect: detectPi,
302
+ skillsCliAgent: 'pi'
303
+ },
282
304
  // Doc: https://code.visualstudio.com/docs/copilot/chat/mcp-servers
283
305
  // Path: <VS Code User dir>/mcp.json Key: servers
284
306
  // VS Code uses GitHub Copilot for AI features; skills are installed via the
@@ -326,7 +348,8 @@ export function getSkillsCliAgent(editorName) {
326
348
  cursor: 'Cursor',
327
349
  'gemini-cli': 'Gemini CLI',
328
350
  'github-copilot': 'GitHub Copilot',
329
- opencode: 'OpenCode'
351
+ opencode: 'OpenCode',
352
+ pi: 'Pi'
330
353
  };
331
354
  export function isUniversalSkillsCliAgentByEditorName(editorName) {
332
355
  return EDITOR_CONFIGS[editorName]?.skillsDir === UNIVERSAL_SKILLS_DIR;
@@ -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 /**\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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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"}
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'\nimport {gte as semverGte, valid as semverValid} from 'semver'\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 and return its stdout. Rejects on failure. */\n execCommand: (cmd: string, args: string[]) => Promise<string>\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) =>\n execa(cmd, args, {stdio: 'pipe', timeout: 5000}).then((res) => res.stdout),\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 detectPi(ctx: DetectionEnv): Promise<string | null> {\n try {\n const stdout = await ctx.execCommand('pi', ['--version'])\n const version = semverValid(stdout.trim())\n // Built-in MCP support was introduced in Pi v1\n if (!version || !semverGte(version, '1.0.0')) return null\n const piDir = ctx.env.PI_CODING_AGENT_DIR || path.join(ctx.homedir, '.pi/agent')\n return path.join(piDir, 'mcp.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://github.com/earendil-works/pi/blob/main/packages/coding-agent/docs/mcp.md\n // Path: $PI_CODING_AGENT_DIR || ~/.pi/agent/mcp.json Key: mcpServers\n Pi: {\n ...EDITOR_DEFAULTS,\n detect: detectPi,\n skillsCliAgent: 'pi',\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 pi: 'Pi',\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","gte","semverGte","valid","semverValid","MCP_SERVER_URL","createDetectionEnv","env","process","execCommand","cmd","args","stdio","timeout","then","res","stdout","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","detectPi","version","trim","piDir","PI_CODING_AGENT_DIR","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","Pi","Zed","getSkillsCliAgent","editorName","config","undefined","SKILLS_CLI_AGENT_DISPLAY_NAMES","antigravity","cline","codex","cursor","opencode","pi","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;AAC3B,SAAQC,OAAOC,SAAS,EAAEC,SAASC,WAAW,QAAO,SAAQ;AAE7D,SAAQC,cAAc,QAAO,wBAAuB;AAiBpD,wEAAwE,GACxE,OAAO,SAASC;IACd,OAAO;QACLC,KAAKC,QAAQD,GAAG;QAChBE,aAAa,CAACC,KAAKC,OACjBX,MAAMU,KAAKC,MAAM;gBAACC,OAAO;gBAAQC,SAAS;YAAI,GAAGC,IAAI,CAAC,CAACC,MAAQA,IAAIC,MAAM;QAC3EnB;QACAoB,SAASnB,GAAGmB,OAAO;QACnBC,UAAUV,QAAQU,QAAQ;IAC5B;AACF;AAwBA,4EAA4E,GAC5E,MAAMC,oBAAoB,IAAO,CAAA;QAC/BC,MAAM;QACNC,KAAKhB;IACP,CAAA;AAEA,yBAAyB;AAEzB,eAAeiB,iBAAiBC,GAAiB;IAC/C,IAAI;QACF,MAAMA,IAAId,WAAW,CAAC,UAAU;YAAC;SAAY;QAC7C,OAAOV,KAAKyB,IAAI,CAACD,IAAIN,OAA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,SAASA,OAAOT,cAAc,GAAGU;IAC9D;AACF;AAEA;;;;;CAKC,GACD,MAAMC,iCAAyD;IAC7DC,aAAa;IACb,eAAe;IACfC,OAAO;IACPC,OAAO;IACPC,QAAQ;IACR,cAAc;IACd,kBAAkB;IAClBC,UAAU;IACVC,IAAI;AACN;AAEA,OAAO,SAASC,sCAAsCV,UAAsB;IAC1E,OAAOX,cAAc,CAACW,WAAW,EAAEzB,cAAcL;AACnD;AAEA,mFAAmF,GACnF,OAAO,SAASyC,6BAA6BX,UAAsB;IACjE,MAAMY,QAAQb,kBAAkBC;IAChC,OAAOY,QAAQT,8BAA8B,CAACS,MAAM,GAAGV;AACzD;AAEA,2EAA2E,GAC3E,OAAO,SAASW,iCAAiCC,OAAe;IAC9D,OAAOX,8BAA8B,CAACW,QAAQ;AAChD;AAEA;;;;;CAKC,GACD,OAAO,SAASC,2BAA2BC,SAAiB;IAC1D,KAAK,MAAMC,QAAQC,OAAOC,IAAI,CAAC9B,gBAAiC;QAC9D,MAAMY,SAASZ,cAAc,CAAC4B,KAAK;QACnC,MAAML,QAAQb,kBAAkBkB;QAChC,IAAIL,UAAUI,WAAW;YACvB,OAAOf,OAAO1B,SAAS;QACzB;IACF;IACA,OAAO2B;AACT"}
@@ -29,7 +29,8 @@ export async function previewAction(options) {
29
29
  output
30
30
  }),
31
31
  cliConfig,
32
- extractManifest: isApp ? ({ workDir: wd })=>extractCoreAppManifest({
32
+ extractManifest: isApp ? ({ iconUrl, workDir: wd })=>extractCoreAppManifest({
33
+ iconUrl,
33
34
  workDir: wd
34
35
  }) : (params)=>extractStudioManifest(params),
35
36
  httpHost: config.httpHost,
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/actions/preview/previewAction.ts"],"sourcesContent":["import {SANITY_CACHE_DIR} from '@sanity/cli-build/_internal/build'\nimport {extractCoreAppManifest} from '@sanity/cli-build/_internal/manifest'\nimport {type CliConfig, type Output} from '@sanity/cli-core'\nimport {isWorkbenchApp} from '@sanity/workbench-cli'\n\nimport {gracefulServerDeath} from '../../server/gracefulServerDeath.js'\nimport {type PreviewServer, startPreviewServer} from '../../server/previewServer.js'\nimport {checkForDeprecatedAppId} from '../../util/appId.js'\nimport {determineIsApp} from '../../util/determineIsApp.js'\nimport {resolveReactStrictMode} from '../../util/resolveReactStrictMode.js'\nimport {extractStudioManifest} from '../manifest/extractStudioManifest.js'\nimport {getPreviewServerConfig} from './getPreviewServerConfig.js'\nimport {type PreviewFlags} from './types.js'\n\ninterface PreviewActionOptions {\n cliConfig: CliConfig\n flags: PreviewFlags\n outDir: string\n output: Output\n workDir: string\n}\n\nexport async function previewAction(\n options: PreviewActionOptions,\n): Promise<PreviewServer | {close: () => Promise<void>}> {\n const {cliConfig, flags, outDir, output, workDir} = options\n\n const config = getPreviewServerConfig({cliConfig, flags, rootDir: outDir, workDir})\n\n if (isWorkbenchApp(cliConfig?.app)) {\n const isApp = determineIsApp(cliConfig)\n // Lazy so a non-workbench `sanity start` never loads the package. `doImport`\n // is path-based and doesn't apply to a bare specifier.\n // eslint-disable-next-line eslint-js/no-restricted-syntax\n const {startWorkbenchPreview} = await import('@sanity/workbench-cli/preview')\n return startWorkbenchPreview({\n cacheDir: `${SANITY_CACHE_DIR}/vite`,\n checkForDeprecatedAppId: () => checkForDeprecatedAppId({cliConfig, output}),\n cliConfig,\n extractManifest: isApp\n ? ({workDir: wd}) => extractCoreAppManifest({workDir: wd})\n : (params) => extractStudioManifest(params),\n httpHost: config.httpHost,\n httpPort: config.httpPort,\n isApp,\n outDir,\n output,\n reactStrictMode: resolveReactStrictMode(cliConfig) ?? false,\n workDir,\n })\n }\n\n try {\n const server = await startPreviewServer(config)\n return server\n } catch (err) {\n throw gracefulServerDeath('preview', config.httpHost, config.httpPort, err)\n }\n}\n"],"names":["SANITY_CACHE_DIR","extractCoreAppManifest","isWorkbenchApp","gracefulServerDeath","startPreviewServer","checkForDeprecatedAppId","determineIsApp","resolveReactStrictMode","extractStudioManifest","getPreviewServerConfig","previewAction","options","cliConfig","flags","outDir","output","workDir","config","rootDir","app","isApp","startWorkbenchPreview","cacheDir","extractManifest","wd","params","httpHost","httpPort","reactStrictMode","server","err"],"mappings":"AAAA,SAAQA,gBAAgB,QAAO,oCAAmC;AAClE,SAAQC,sBAAsB,QAAO,uCAAsC;AAE3E,SAAQC,cAAc,QAAO,wBAAuB;AAEpD,SAAQC,mBAAmB,QAAO,sCAAqC;AACvE,SAA4BC,kBAAkB,QAAO,gCAA+B;AACpF,SAAQC,uBAAuB,QAAO,sBAAqB;AAC3D,SAAQC,cAAc,QAAO,+BAA8B;AAC3D,SAAQC,sBAAsB,QAAO,uCAAsC;AAC3E,SAAQC,qBAAqB,QAAO,uCAAsC;AAC1E,SAAQC,sBAAsB,QAAO,8BAA6B;AAWlE,OAAO,eAAeC,cACpBC,OAA6B;IAE7B,MAAM,EAACC,SAAS,EAAEC,KAAK,EAAEC,MAAM,EAAEC,MAAM,EAAEC,OAAO,EAAC,GAAGL;IAEpD,MAAMM,SAASR,uBAAuB;QAACG;QAAWC;QAAOK,SAASJ;QAAQE;IAAO;IAEjF,IAAId,eAAeU,WAAWO,MAAM;QAClC,MAAMC,QAAQd,eAAeM;QAC7B,6EAA6E;QAC7E,uDAAuD;QACvD,0DAA0D;QAC1D,MAAM,EAACS,qBAAqB,EAAC,GAAG,MAAM,MAAM,CAAC;QAC7C,OAAOA,sBAAsB;YAC3BC,UAAU,GAAGtB,iBAAiB,KAAK,CAAC;YACpCK,yBAAyB,IAAMA,wBAAwB;oBAACO;oBAAWG;gBAAM;YACzEH;YACAW,iBAAiBH,QACb,CAAC,EAACJ,SAASQ,EAAE,EAAC,GAAKvB,uBAAuB;oBAACe,SAASQ;gBAAE,KACtD,CAACC,SAAWjB,sBAAsBiB;YACtCC,UAAUT,OAAOS,QAAQ;YACzBC,UAAUV,OAAOU,QAAQ;YACzBP;YACAN;YACAC;YACAa,iBAAiBrB,uBAAuBK,cAAc;YACtDI;QACF;IACF;IAEA,IAAI;QACF,MAAMa,SAAS,MAAMzB,mBAAmBa;QACxC,OAAOY;IACT,EAAE,OAAOC,KAAK;QACZ,MAAM3B,oBAAoB,WAAWc,OAAOS,QAAQ,EAAET,OAAOU,QAAQ,EAAEG;IACzE;AACF"}
1
+ {"version":3,"sources":["../../../src/actions/preview/previewAction.ts"],"sourcesContent":["import {SANITY_CACHE_DIR} from '@sanity/cli-build/_internal/build'\nimport {extractCoreAppManifest} from '@sanity/cli-build/_internal/manifest'\nimport {type CliConfig, type Output} from '@sanity/cli-core'\nimport {isWorkbenchApp} from '@sanity/workbench-cli'\n\nimport {gracefulServerDeath} from '../../server/gracefulServerDeath.js'\nimport {type PreviewServer, startPreviewServer} from '../../server/previewServer.js'\nimport {checkForDeprecatedAppId} from '../../util/appId.js'\nimport {determineIsApp} from '../../util/determineIsApp.js'\nimport {resolveReactStrictMode} from '../../util/resolveReactStrictMode.js'\nimport {extractStudioManifest} from '../manifest/extractStudioManifest.js'\nimport {getPreviewServerConfig} from './getPreviewServerConfig.js'\nimport {type PreviewFlags} from './types.js'\n\ninterface PreviewActionOptions {\n cliConfig: CliConfig\n flags: PreviewFlags\n outDir: string\n output: Output\n workDir: string\n}\n\nexport async function previewAction(\n options: PreviewActionOptions,\n): Promise<PreviewServer | {close: () => Promise<void>}> {\n const {cliConfig, flags, outDir, output, workDir} = options\n\n const config = getPreviewServerConfig({cliConfig, flags, rootDir: outDir, workDir})\n\n if (isWorkbenchApp(cliConfig?.app)) {\n const isApp = determineIsApp(cliConfig)\n // Lazy so a non-workbench `sanity start` never loads the package. `doImport`\n // is path-based and doesn't apply to a bare specifier.\n // eslint-disable-next-line eslint-js/no-restricted-syntax\n const {startWorkbenchPreview} = await import('@sanity/workbench-cli/preview')\n return startWorkbenchPreview({\n cacheDir: `${SANITY_CACHE_DIR}/vite`,\n checkForDeprecatedAppId: () => checkForDeprecatedAppId({cliConfig, output}),\n cliConfig,\n extractManifest: isApp\n ? ({iconUrl, workDir: wd}) => extractCoreAppManifest({iconUrl, workDir: wd})\n : (params) => extractStudioManifest(params),\n httpHost: config.httpHost,\n httpPort: config.httpPort,\n isApp,\n outDir,\n output,\n reactStrictMode: resolveReactStrictMode(cliConfig) ?? false,\n workDir,\n })\n }\n\n try {\n const server = await startPreviewServer(config)\n return server\n } catch (err) {\n throw gracefulServerDeath('preview', config.httpHost, config.httpPort, err)\n }\n}\n"],"names":["SANITY_CACHE_DIR","extractCoreAppManifest","isWorkbenchApp","gracefulServerDeath","startPreviewServer","checkForDeprecatedAppId","determineIsApp","resolveReactStrictMode","extractStudioManifest","getPreviewServerConfig","previewAction","options","cliConfig","flags","outDir","output","workDir","config","rootDir","app","isApp","startWorkbenchPreview","cacheDir","extractManifest","iconUrl","wd","params","httpHost","httpPort","reactStrictMode","server","err"],"mappings":"AAAA,SAAQA,gBAAgB,QAAO,oCAAmC;AAClE,SAAQC,sBAAsB,QAAO,uCAAsC;AAE3E,SAAQC,cAAc,QAAO,wBAAuB;AAEpD,SAAQC,mBAAmB,QAAO,sCAAqC;AACvE,SAA4BC,kBAAkB,QAAO,gCAA+B;AACpF,SAAQC,uBAAuB,QAAO,sBAAqB;AAC3D,SAAQC,cAAc,QAAO,+BAA8B;AAC3D,SAAQC,sBAAsB,QAAO,uCAAsC;AAC3E,SAAQC,qBAAqB,QAAO,uCAAsC;AAC1E,SAAQC,sBAAsB,QAAO,8BAA6B;AAWlE,OAAO,eAAeC,cACpBC,OAA6B;IAE7B,MAAM,EAACC,SAAS,EAAEC,KAAK,EAAEC,MAAM,EAAEC,MAAM,EAAEC,OAAO,EAAC,GAAGL;IAEpD,MAAMM,SAASR,uBAAuB;QAACG;QAAWC;QAAOK,SAASJ;QAAQE;IAAO;IAEjF,IAAId,eAAeU,WAAWO,MAAM;QAClC,MAAMC,QAAQd,eAAeM;QAC7B,6EAA6E;QAC7E,uDAAuD;QACvD,0DAA0D;QAC1D,MAAM,EAACS,qBAAqB,EAAC,GAAG,MAAM,MAAM,CAAC;QAC7C,OAAOA,sBAAsB;YAC3BC,UAAU,GAAGtB,iBAAiB,KAAK,CAAC;YACpCK,yBAAyB,IAAMA,wBAAwB;oBAACO;oBAAWG;gBAAM;YACzEH;YACAW,iBAAiBH,QACb,CAAC,EAACI,OAAO,EAAER,SAASS,EAAE,EAAC,GAAKxB,uBAAuB;oBAACuB;oBAASR,SAASS;gBAAE,KACxE,CAACC,SAAWlB,sBAAsBkB;YACtCC,UAAUV,OAAOU,QAAQ;YACzBC,UAAUX,OAAOW,QAAQ;YACzBR;YACAN;YACAC;YACAc,iBAAiBtB,uBAAuBK,cAAc;YACtDI;QACF;IACF;IAEA,IAAI;QACF,MAAMc,SAAS,MAAM1B,mBAAmBa;QACxC,OAAOa;IACT,EAAE,OAAOC,KAAK;QACZ,MAAM5B,oBAAoB,WAAWc,OAAOU,QAAQ,EAAEV,OAAOW,QAAQ,EAAEG;IACzE;AACF"}
@@ -41,7 +41,7 @@ export class DevCommand extends SanityCommand {
41
41
  const cliConfig = await this.getCliConfig();
42
42
  const isApp = determineIsApp(cliConfig);
43
43
  if (shouldWarnDashboardFlagIgnored(cliConfig, flags['load-in-dashboard'])) {
44
- this.output.warn('Ignoring --load-in-dashboard: this app already runs in the local Dashboard');
44
+ this.output.warn('Apps using `defineApplication` always run in the local Dashboard. Remove the --load-in-dashboard flag from your command.');
45
45
  }
46
46
  // load-in-dashboard is defaulted to true for apps.
47
47
  if (isApp && flags['load-in-dashboard'] === undefined) {
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/commands/dev.ts"],"sourcesContent":["import {styleText} from 'node:util'\n\nimport {Flags} from '@oclif/core'\nimport {type CliConfig, exitCodes, SanityCommand} from '@sanity/cli-core'\nimport {isWorkbenchApp} from '@sanity/workbench-cli'\n\nimport {devAction} from '../actions/dev/devAction.js'\nimport {devDebug} from '../actions/dev/devDebug.js'\nimport {determineIsApp} from '../util/determineIsApp.js'\n\n/**\n * Workbench apps never load in the Sanity dashboard, so `--load-in-dashboard`\n * has no effect for them. The flag is defaulted later in `run`, so an\n * `undefined` value here still means the user never passed it.\n */\nexport function shouldWarnDashboardFlagIgnored(\n cliConfig: CliConfig | undefined,\n loadInDashboard: boolean | undefined,\n): boolean {\n return isWorkbenchApp(cliConfig?.app) && loadInDashboard !== undefined\n}\n\nexport class DevCommand extends SanityCommand<typeof DevCommand> {\n static override description = 'Start a local development server with live reloading'\n\n static override examples = [\n '<%= config.bin %> <%= command.id %> --host=0.0.0.0',\n '<%= config.bin %> <%= command.id %> --port=1942',\n '<%= config.bin %> <%= command.id %> --load-in-dashboard',\n ]\n\n static override flags = {\n 'auto-updates': Flags.boolean({\n allowNo: true,\n description: 'Automatically update Sanity Studio dependencies',\n }),\n host: Flags.string({\n description: 'Local network interface to listen on (default: localhost)',\n }),\n 'load-in-dashboard': Flags.boolean({\n allowNo: true,\n description: 'Load the app/studio in the Sanity dashboard',\n }),\n port: Flags.string({\n description: 'TCP port to start server on (default: 3333)',\n }),\n }\n\n public async run(): Promise<{close?: () => Promise<void>}> {\n const {flags} = await this.parse(DevCommand)\n\n const workDir = (await this.getProjectRoot()).directory\n const cliConfig = await this.getCliConfig()\n const isApp = determineIsApp(cliConfig)\n\n if (shouldWarnDashboardFlagIgnored(cliConfig, flags['load-in-dashboard'])) {\n this.output.warn('Ignoring --load-in-dashboard: this app already runs in the local Dashboard')\n }\n\n // load-in-dashboard is defaulted to true for apps.\n if (isApp && flags['load-in-dashboard'] === undefined) {\n flags['load-in-dashboard'] = true\n } else if (flags['load-in-dashboard'] === undefined) {\n // For non-apps, load-in-dashboard is defaulted to false.\n flags['load-in-dashboard'] = false\n }\n\n try {\n const result = await devAction({\n cliConfig,\n flags,\n isApp,\n output: this.output,\n workDir,\n })\n return result\n } catch (error) {\n devDebug(`Failed to start dev server`, error)\n this.output.error(\n styleText(['red', 'bgBlack'], `Failed to start dev server: ${error.message}`),\n {\n exit: exitCodes.RUNTIME_ERROR,\n },\n )\n }\n }\n}\n"],"names":["styleText","Flags","exitCodes","SanityCommand","isWorkbenchApp","devAction","devDebug","determineIsApp","shouldWarnDashboardFlagIgnored","cliConfig","loadInDashboard","app","undefined","DevCommand","description","examples","flags","boolean","allowNo","host","string","port","run","parse","workDir","getProjectRoot","directory","getCliConfig","isApp","output","warn","result","error","message","exit","RUNTIME_ERROR"],"mappings":"AAAA,SAAQA,SAAS,QAAO,YAAW;AAEnC,SAAQC,KAAK,QAAO,cAAa;AACjC,SAAwBC,SAAS,EAAEC,aAAa,QAAO,mBAAkB;AACzE,SAAQC,cAAc,QAAO,wBAAuB;AAEpD,SAAQC,SAAS,QAAO,8BAA6B;AACrD,SAAQC,QAAQ,QAAO,6BAA4B;AACnD,SAAQC,cAAc,QAAO,4BAA2B;AAExD;;;;CAIC,GACD,OAAO,SAASC,+BACdC,SAAgC,EAChCC,eAAoC;IAEpC,OAAON,eAAeK,WAAWE,QAAQD,oBAAoBE;AAC/D;AAEA,OAAO,MAAMC,mBAAmBV;IAC9B,OAAgBW,cAAc,uDAAsD;IAEpF,OAAgBC,WAAW;QACzB;QACA;QACA;KACD,CAAA;IAED,OAAgBC,QAAQ;QACtB,gBAAgBf,MAAMgB,OAAO,CAAC;YAC5BC,SAAS;YACTJ,aAAa;QACf;QACAK,MAAMlB,MAAMmB,MAAM,CAAC;YACjBN,aAAa;QACf;QACA,qBAAqBb,MAAMgB,OAAO,CAAC;YACjCC,SAAS;YACTJ,aAAa;QACf;QACAO,MAAMpB,MAAMmB,MAAM,CAAC;YACjBN,aAAa;QACf;IACF,EAAC;IAED,MAAaQ,MAA8C;QACzD,MAAM,EAACN,KAAK,EAAC,GAAG,MAAM,IAAI,CAACO,KAAK,CAACV;QAEjC,MAAMW,UAAU,AAAC,CAAA,MAAM,IAAI,CAACC,cAAc,EAAC,EAAGC,SAAS;QACvD,MAAMjB,YAAY,MAAM,IAAI,CAACkB,YAAY;QACzC,MAAMC,QAAQrB,eAAeE;QAE7B,IAAID,+BAA+BC,WAAWO,KAAK,CAAC,oBAAoB,GAAG;YACzE,IAAI,CAACa,MAAM,CAACC,IAAI,CAAC;QACnB;QAEA,mDAAmD;QACnD,IAAIF,SAASZ,KAAK,CAAC,oBAAoB,KAAKJ,WAAW;YACrDI,KAAK,CAAC,oBAAoB,GAAG;QAC/B,OAAO,IAAIA,KAAK,CAAC,oBAAoB,KAAKJ,WAAW;YACnD,yDAAyD;YACzDI,KAAK,CAAC,oBAAoB,GAAG;QAC/B;QAEA,IAAI;YACF,MAAMe,SAAS,MAAM1B,UAAU;gBAC7BI;gBACAO;gBACAY;gBACAC,QAAQ,IAAI,CAACA,MAAM;gBACnBL;YACF;YACA,OAAOO;QACT,EAAE,OAAOC,OAAO;YACd1B,SAAS,CAAC,0BAA0B,CAAC,EAAE0B;YACvC,IAAI,CAACH,MAAM,CAACG,KAAK,CACfhC,UAAU;gBAAC;gBAAO;aAAU,EAAE,CAAC,4BAA4B,EAAEgC,MAAMC,OAAO,EAAE,GAC5E;gBACEC,MAAMhC,UAAUiC,aAAa;YAC/B;QAEJ;IACF;AACF"}
1
+ {"version":3,"sources":["../../src/commands/dev.ts"],"sourcesContent":["import {styleText} from 'node:util'\n\nimport {Flags} from '@oclif/core'\nimport {type CliConfig, exitCodes, SanityCommand} from '@sanity/cli-core'\nimport {isWorkbenchApp} from '@sanity/workbench-cli'\n\nimport {devAction} from '../actions/dev/devAction.js'\nimport {devDebug} from '../actions/dev/devDebug.js'\nimport {determineIsApp} from '../util/determineIsApp.js'\n\n/**\n * Workbench apps never load in the Sanity dashboard, so `--load-in-dashboard`\n * has no effect for them. The flag is defaulted later in `run`, so an\n * `undefined` value here still means the user never passed it.\n */\nexport function shouldWarnDashboardFlagIgnored(\n cliConfig: CliConfig | undefined,\n loadInDashboard: boolean | undefined,\n): boolean {\n return isWorkbenchApp(cliConfig?.app) && loadInDashboard !== undefined\n}\n\nexport class DevCommand extends SanityCommand<typeof DevCommand> {\n static override description = 'Start a local development server with live reloading'\n\n static override examples = [\n '<%= config.bin %> <%= command.id %> --host=0.0.0.0',\n '<%= config.bin %> <%= command.id %> --port=1942',\n '<%= config.bin %> <%= command.id %> --load-in-dashboard',\n ]\n\n static override flags = {\n 'auto-updates': Flags.boolean({\n allowNo: true,\n description: 'Automatically update Sanity Studio dependencies',\n }),\n host: Flags.string({\n description: 'Local network interface to listen on (default: localhost)',\n }),\n 'load-in-dashboard': Flags.boolean({\n allowNo: true,\n description: 'Load the app/studio in the Sanity dashboard',\n }),\n port: Flags.string({\n description: 'TCP port to start server on (default: 3333)',\n }),\n }\n\n public async run(): Promise<{close?: () => Promise<void>}> {\n const {flags} = await this.parse(DevCommand)\n\n const workDir = (await this.getProjectRoot()).directory\n const cliConfig = await this.getCliConfig()\n const isApp = determineIsApp(cliConfig)\n\n if (shouldWarnDashboardFlagIgnored(cliConfig, flags['load-in-dashboard'])) {\n this.output.warn(\n 'Apps using `defineApplication` always run in the local Dashboard. Remove the --load-in-dashboard flag from your command.',\n )\n }\n\n // load-in-dashboard is defaulted to true for apps.\n if (isApp && flags['load-in-dashboard'] === undefined) {\n flags['load-in-dashboard'] = true\n } else if (flags['load-in-dashboard'] === undefined) {\n // For non-apps, load-in-dashboard is defaulted to false.\n flags['load-in-dashboard'] = false\n }\n\n try {\n const result = await devAction({\n cliConfig,\n flags,\n isApp,\n output: this.output,\n workDir,\n })\n return result\n } catch (error) {\n devDebug(`Failed to start dev server`, error)\n this.output.error(\n styleText(['red', 'bgBlack'], `Failed to start dev server: ${error.message}`),\n {\n exit: exitCodes.RUNTIME_ERROR,\n },\n )\n }\n }\n}\n"],"names":["styleText","Flags","exitCodes","SanityCommand","isWorkbenchApp","devAction","devDebug","determineIsApp","shouldWarnDashboardFlagIgnored","cliConfig","loadInDashboard","app","undefined","DevCommand","description","examples","flags","boolean","allowNo","host","string","port","run","parse","workDir","getProjectRoot","directory","getCliConfig","isApp","output","warn","result","error","message","exit","RUNTIME_ERROR"],"mappings":"AAAA,SAAQA,SAAS,QAAO,YAAW;AAEnC,SAAQC,KAAK,QAAO,cAAa;AACjC,SAAwBC,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ACF,MAAMe,SAAS,MAAM1B,UAAU;gBAC7BI;gBACAO;gBACAY;gBACAC,QAAQ,IAAI,CAACA,MAAM;gBACnBL;YACF;YACA,OAAOO;QACT,EAAE,OAAOC,OAAO;YACd1B,SAAS,CAAC,0BAA0B,CAAC,EAAE0B;YACvC,IAAI,CAACH,MAAM,CAACG,KAAK,CACfhC,UAAU;gBAAC;gBAAO;aAAU,EAAE,CAAC,4BAA4B,EAAEgC,MAAMC,OAAO,EAAE,GAC5E;gBACEC,MAAMhC,UAAUiC,aAAa;YAC/B;QAEJ;IACF;AACF"}
@@ -3,7 +3,7 @@ import { getErrorMessage, toError } from '@sanity/cli-core/errors';
3
3
  import { setupMCP } from '../../actions/mcp/setupMCP.js';
4
4
  import { MCPConfigureTrace } from '../../telemetry/mcp.telemetry.js';
5
5
  export class ConfigureMcpCommand extends SanityCommand {
6
- static description = 'Configure Sanity MCP server for AI editors (Antigravity, Claude Code, Cline, Codex CLI, Cursor, Gemini CLI, GitHub Copilot CLI, MCPorter, OpenCode, VS Code, VS Code Insiders, Zed)';
6
+ static description = 'Configure Sanity MCP server for AI editors (Antigravity, Claude Code, Cline, Codex CLI, Cursor, Gemini CLI, GitHub Copilot CLI, MCPorter, OpenCode, Pi, VS Code, VS Code Insiders, Zed)';
7
7
  static examples = [
8
8
  {
9
9
  command: '<%= config.bin %> <%= command.id %>',
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/commands/mcp/configure.ts"],"sourcesContent":["import {exitCodes, SanityCommand} from '@sanity/cli-core'\nimport {getErrorMessage, toError} from '@sanity/cli-core/errors'\n\nimport {setupMCP} from '../../actions/mcp/setupMCP.js'\nimport {MCPConfigureTrace} from '../../telemetry/mcp.telemetry.js'\n\nexport class ConfigureMcpCommand extends SanityCommand<typeof ConfigureMcpCommand> {\n static override description =\n 'Configure Sanity MCP server for AI editors (Antigravity, Claude Code, Cline, Codex CLI, Cursor, Gemini CLI, GitHub Copilot CLI, MCPorter, OpenCode, VS Code, VS Code Insiders, Zed)'\n static override examples = [\n {\n command: '<%= config.bin %> <%= command.id %>',\n description: 'Configure Sanity MCP server for detected AI editors',\n },\n ]\n\n public async run(): Promise<void> {\n const trace = this.telemetry.trace(MCPConfigureTrace)\n trace.start()\n\n try {\n const mcpResult = await setupMCP({\n explicit: true,\n mode: this.resolveIsInteractive() ? 'prompt' : 'auto',\n output: this.output,\n skillsMode: 'skip',\n })\n\n trace.log({\n configuredEditors: mcpResult.configuredEditors,\n detectedEditors: mcpResult.detectedEditors,\n })\n\n if (mcpResult.error) {\n trace.error(mcpResult.error)\n } else {\n trace.complete()\n }\n } catch (error) {\n trace.error(toError(error))\n this.error(getErrorMessage(error), {exit: exitCodes.RUNTIME_ERROR})\n }\n }\n}\n"],"names":["exitCodes","SanityCommand","getErrorMessage","toError","setupMCP","MCPConfigureTrace","ConfigureMcpCommand","description","examples","command","run","trace","telemetry","start","mcpResult","explicit","mode","resolveIsInteractive","output","skillsMode","log","configuredEditors","detectedEditors","error","complete","exit","RUNTIME_ERROR"],"mappings":"AAAA,SAAQA,SAAS,EAAEC,aAAa,QAAO,mBAAkB;AACzD,SAAQC,eAAe,EAAEC,OAAO,QAAO,0BAAyB;AAEhE,SAAQC,QAAQ,QAAO,gCAA+B;AACtD,SAAQC,iBAAiB,QAAO,mCAAkC;AAElE,OAAO,MAAMC,4BAA4BL;IACvC,OAAgBM,cACd,sLAAqL;IACvL,OAAgBC,WAAW;QACzB;YACEC,SAAS;YACTF,aAAa;QACf;KACD,CAAA;IAED,MAAaG,MAAqB;QAChC,MAAMC,QAAQ,IAAI,CAACC,SAAS,CAACD,KAAK,CAACN;QACnCM,MAAME,KAAK;QAEX,IAAI;YACF,MAAMC,YAAY,MAAMV,SAAS;gBAC/BW,UAAU;gBACVC,MAAM,IAAI,CAACC,oBAAoB,KAAK,WAAW;gBAC/CC,QAAQ,IAAI,CAACA,MAAM;gBACnBC,YAAY;YACd;YAEAR,MAAMS,GAAG,CAAC;gBACRC,mBAAmBP,UAAUO,iBAAiB;gBAC9CC,iBAAiBR,UAAUQ,eAAe;YAC5C;YAEA,IAAIR,UAAUS,KAAK,EAAE;gBACnBZ,MAAMY,KAAK,CAACT,UAAUS,KAAK;YAC7B,OAAO;gBACLZ,MAAMa,QAAQ;YAChB;QACF,EAAE,OAAOD,OAAO;YACdZ,MAAMY,KAAK,CAACpB,QAAQoB;YACpB,IAAI,CAACA,KAAK,CAACrB,gBAAgBqB,QAAQ;gBAACE,MAAMzB,UAAU0B,aAAa;YAAA;QACnE;IACF;AACF"}
1
+ {"version":3,"sources":["../../../src/commands/mcp/configure.ts"],"sourcesContent":["import {exitCodes, SanityCommand} from '@sanity/cli-core'\nimport {getErrorMessage, toError} from '@sanity/cli-core/errors'\n\nimport {setupMCP} from '../../actions/mcp/setupMCP.js'\nimport {MCPConfigureTrace} from '../../telemetry/mcp.telemetry.js'\n\nexport class ConfigureMcpCommand extends SanityCommand<typeof ConfigureMcpCommand> {\n static override description =\n 'Configure Sanity MCP server for AI editors (Antigravity, Claude Code, Cline, Codex CLI, Cursor, Gemini CLI, GitHub Copilot CLI, MCPorter, OpenCode, Pi, VS Code, VS Code Insiders, Zed)'\n static override examples = [\n {\n command: '<%= config.bin %> <%= command.id %>',\n description: 'Configure Sanity MCP server for detected AI editors',\n },\n ]\n\n public async run(): Promise<void> {\n const trace = this.telemetry.trace(MCPConfigureTrace)\n trace.start()\n\n try {\n const mcpResult = await setupMCP({\n explicit: true,\n mode: this.resolveIsInteractive() ? 'prompt' : 'auto',\n output: this.output,\n skillsMode: 'skip',\n })\n\n trace.log({\n configuredEditors: mcpResult.configuredEditors,\n detectedEditors: mcpResult.detectedEditors,\n })\n\n if (mcpResult.error) {\n trace.error(mcpResult.error)\n } else {\n trace.complete()\n }\n } catch (error) {\n trace.error(toError(error))\n this.error(getErrorMessage(error), {exit: exitCodes.RUNTIME_ERROR})\n }\n }\n}\n"],"names":["exitCodes","SanityCommand","getErrorMessage","toError","setupMCP","MCPConfigureTrace","ConfigureMcpCommand","description","examples","command","run","trace","telemetry","start","mcpResult","explicit","mode","resolveIsInteractive","output","skillsMode","log","configuredEditors","detectedEditors","error","complete","exit","RUNTIME_ERROR"],"mappings":"AAAA,SAAQA,SAAS,EAAEC,aAAa,QAAO,mBAAkB;AACzD,SAAQC,eAAe,EAAEC,OAAO,QAAO,0BAAyB;AAEhE,SAAQC,QAAQ,QAAO,gCAA+B;AACtD,SAAQC,iBAAiB,QAAO,mCAAkC;AAElE,OAAO,MAAMC,4BAA4BL;IACvC,OAAgBM,cACd,0LAAyL;IAC3L,OAAgBC,WAAW;QACzB;YACEC,SAAS;YACTF,aAAa;QACf;KACD,CAAA;IAED,MAAaG,MAAqB;QAChC,MAAMC,QAAQ,IAAI,CAACC,SAAS,CAACD,KAAK,CAACN;QACnCM,MAAME,KAAK;QAEX,IAAI;YACF,MAAMC,YAAY,MAAMV,SAAS;gBAC/BW,UAAU;gBACVC,MAAM,IAAI,CAACC,oBAAoB,KAAK,WAAW;gBAC/CC,QAAQ,IAAI,CAACA,MAAM;gBACnBC,YAAY;YACd;YAEAR,MAAMS,GAAG,CAAC;gBACRC,mBAAmBP,UAAUO,iBAAiB;gBAC9CC,iBAAiBR,UAAUQ,eAAe;YAC5C;YAEA,IAAIR,UAAUS,KAAK,EAAE;gBACnBZ,MAAMY,KAAK,CAACT,UAAUS,KAAK;YAC7B,OAAO;gBACLZ,MAAMa,QAAQ;YAChB;QACF,EAAE,OAAOD,OAAO;YACdZ,MAAMY,KAAK,CAACpB,QAAQoB;YACpB,IAAI,CAACA,KAAK,CAACrB,gBAAgBqB,QAAQ;gBAACE,MAAMzB,UAAU0B,aAAa;YAAA;QACnE;IACF;AACF"}
@@ -2,8 +2,8 @@ import { Flags } from '@oclif/core';
2
2
  import { exitCodes, SanityCommand, subdebug } from '@sanity/cli-core';
3
3
  import { getErrorMessage } from '@sanity/cli-core/errors';
4
4
  import { requiredWhenUnattended } from '@sanity/cli-core/flags';
5
+ import { readImageFile } from '@sanity/cli-core/images';
5
6
  import { spinner } from '@sanity/cli-core/ux';
6
- import { readOrganizationLogo } from '../../actions/organizations/readOrganizationLogo.js';
7
7
  import { validateOrganizationName } from '../../actions/organizations/validateOrganizationName.js';
8
8
  import { promptForOrganizationName } from '../../prompts/promptForOrganizationName.js';
9
9
  import { createOrganization, setOrganizationLogo } from '../../services/organizations.js';
@@ -67,7 +67,7 @@ export class CreateOrganizationCommand extends SanityCommand {
67
67
  });
68
68
  } else if (logoPath !== undefined) {
69
69
  try {
70
- logo = await readOrganizationLogo(logoPath);
70
+ logo = await readImageFile(logoPath);
71
71
  } catch (error) {
72
72
  this.error(getErrorMessage(error), {
73
73
  exit: exitCodes.RUNTIME_ERROR
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/commands/organizations/create.ts"],"sourcesContent":["import {Flags} from '@oclif/core'\nimport {type FlagInput} from '@oclif/core/interfaces'\nimport {exitCodes, SanityCommand, subdebug} from '@sanity/cli-core'\nimport {getErrorMessage} from '@sanity/cli-core/errors'\nimport {requiredWhenUnattended} from '@sanity/cli-core/flags'\nimport {spinner} from '@sanity/cli-core/ux'\n\nimport {\n type OrganizationLogo,\n readOrganizationLogo,\n} from '../../actions/organizations/readOrganizationLogo.js'\nimport {validateOrganizationName} from '../../actions/organizations/validateOrganizationName.js'\nimport {promptForOrganizationName} from '../../prompts/promptForOrganizationName.js'\nimport {\n createOrganization,\n type OrganizationCreateResponse,\n setOrganizationLogo,\n} from '../../services/organizations.js'\nimport {organizationAliases} from '../../util/organizationAliases.js'\nimport {defineCommandTelemetry} from '../../util/telemetry/commandTelemetry.js'\n\nconst createOrgDebug = subdebug('organizations:create')\n\nexport class CreateOrganizationCommand extends SanityCommand<typeof CreateOrganizationCommand> {\n static override description = 'Create a new organization'\n\n static override examples = [\n {\n command: '<%= config.bin %> <%= command.id %>',\n description: 'Interactively create an organization',\n },\n {\n command: '<%= config.bin %> <%= command.id %> --name \"Acme Corp\"',\n description: 'Create an organization named \"Acme Corp\"',\n },\n {\n command: '<%= config.bin %> <%= command.id %> --name \"Acme Corp\" --default-role member',\n description: 'Create an organization with a default member role',\n },\n {\n command: '<%= config.bin %> <%= command.id %> --name \"Acme Corp\" --logo ./logo.png',\n description: 'Create an organization with a logo',\n },\n ]\n\n static override flags = {\n 'default-role': Flags.string({\n description: 'Default role assigned to new members',\n required: false,\n }),\n logo: Flags.string({\n description:\n 'Image file to use as the logo: PNG, JPEG, GIF, WebP, SVG, BMP, TIFF, HEIF or AVIF, at most 5 MB',\n helpValue: '<path>',\n required: false,\n }),\n name: requiredWhenUnattended(\n Flags.string({\n description: 'Organization name',\n }),\n ),\n } satisfies FlagInput\n\n static override hiddenAliases = organizationAliases('create')\n\n static telemetry = defineCommandTelemetry(this.flags, {redact: ['logo', 'name']})\n\n public async run(): Promise<void> {\n const {'default-role': defaultRoleFlag, logo: logoPath, name: nameFlag} = this.flags\n\n const defaultRole = defaultRoleFlag?.trim()\n if (defaultRole === '') {\n this.error('Default role cannot be empty', {exit: exitCodes.RUNTIME_ERROR})\n }\n\n // Read the logo before creating anything, so a bad file doesn't leave an organization without it.\n let logo: OrganizationLogo | undefined\n if (logoPath === '') {\n this.error(\n '--logo needs the path to an image file. To create the organization without a logo, leave out --logo.',\n {exit: exitCodes.RUNTIME_ERROR},\n )\n } else if (logoPath !== undefined) {\n try {\n logo = await readOrganizationLogo(logoPath)\n } catch (error) {\n this.error(getErrorMessage(error), {exit: exitCodes.RUNTIME_ERROR})\n }\n }\n\n let name: string\n if (nameFlag === undefined) {\n name = await promptForOrganizationName()\n } else {\n const trimmedName = nameFlag.trim()\n const validation = validateOrganizationName(trimmedName)\n if (validation !== true) {\n this.error(validation, {exit: exitCodes.RUNTIME_ERROR})\n }\n name = trimmedName\n }\n\n const spin = spinner('Creating organization').start()\n let org: OrganizationCreateResponse\n try {\n org = await createOrganization(name, defaultRole)\n spin.succeed('Organization created')\n this.log(`ID: ${org.id}`)\n this.log(`Name: ${org.name}`)\n } catch (error) {\n spin.fail()\n createOrgDebug('Error creating organization', error)\n this.error(`Failed to create organization: ${getErrorMessage(error)}`, {\n exit: exitCodes.RUNTIME_ERROR,\n })\n }\n\n if (!logo) return\n\n const logoSpin = spinner('Setting logo').start()\n try {\n const {logoUrl} = await setOrganizationLogo(org.id, logo)\n logoSpin.succeed()\n this.log(`Logo: ${logoUrl}`)\n } catch (error) {\n logoSpin.fail()\n createOrgDebug('Error setting organization logo', error)\n this.error(\n `The organization was created, but its logo wasn't set: ${getErrorMessage(error)}\\nTo try again, run: ${this.config.bin} organizations update ${org.id} --logo \"${logoPath}\"`,\n {exit: exitCodes.RUNTIME_ERROR},\n )\n }\n }\n}\n"],"names":["Flags","exitCodes","SanityCommand","subdebug","getErrorMessage","requiredWhenUnattended","spinner","readOrganizationLogo","validateOrganizationName","promptForOrganizationName","createOrganization","setOrganizationLogo","organizationAliases","defineCommandTelemetry","createOrgDebug","CreateOrganizationCommand","description","examples","command","flags","string","required","logo","helpValue","name","hiddenAliases","telemetry","redact","run","defaultRoleFlag","logoPath","nameFlag","defaultRole","trim","error","exit","RUNTIME_ERROR","undefined","trimmedName","validation","spin","start","org","succeed","log","id","fail","logoSpin","logoUrl","config","bin"],"mappings":"AAAA,SAAQA,KAAK,QAAO,cAAa;AAEjC,SAAQC,SAAS,EAAEC,aAAa,EAAEC,QAAQ,QAAO,mBAAkB;AACnE,SAAQC,eAAe,QAAO,0BAAyB;AACvD,SAAQC,sBAAsB,QAAO,yBAAwB;AAC7D,SAAQC,OAAO,QAAO,sBAAqB;AAE3C,SAEEC,oBAAoB,QACf,sDAAqD;AAC5D,SAAQC,wBAAwB,QAAO,0DAAyD;AAChG,SAAQC,yBAAyB,QAAO,6CAA4C;AACpF,SACEC,kBAAkB,EAElBC,mBAAmB,QACd,kCAAiC;AACxC,SAAQC,mBAAmB,QAAO,oCAAmC;AACrE,SAAQC,sBAAsB,QAAO,2CAA0C;AAE/E,MAAMC,iBAAiBX,SAAS;AAEhC,OAAO,MAAMY,kCAAkCb;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version":3,"sources":["../../../src/commands/organizations/create.ts"],"sourcesContent":["import {Flags} from '@oclif/core'\nimport {type FlagInput} from '@oclif/core/interfaces'\nimport {exitCodes, SanityCommand, subdebug} from '@sanity/cli-core'\nimport {getErrorMessage} from '@sanity/cli-core/errors'\nimport {requiredWhenUnattended} from '@sanity/cli-core/flags'\nimport {type ImageFile, readImageFile} from '@sanity/cli-core/images'\nimport {spinner} from '@sanity/cli-core/ux'\n\nimport {validateOrganizationName} from '../../actions/organizations/validateOrganizationName.js'\nimport {promptForOrganizationName} from '../../prompts/promptForOrganizationName.js'\nimport {\n createOrganization,\n type OrganizationCreateResponse,\n setOrganizationLogo,\n} from '../../services/organizations.js'\nimport {organizationAliases} from '../../util/organizationAliases.js'\nimport {defineCommandTelemetry} from '../../util/telemetry/commandTelemetry.js'\n\nconst createOrgDebug = subdebug('organizations:create')\n\nexport class CreateOrganizationCommand extends SanityCommand<typeof CreateOrganizationCommand> {\n static override description = 'Create a new organization'\n\n static override examples = [\n {\n command: '<%= config.bin %> <%= command.id %>',\n description: 'Interactively create an organization',\n },\n {\n command: '<%= config.bin %> <%= command.id %> --name \"Acme Corp\"',\n description: 'Create an organization named \"Acme Corp\"',\n },\n {\n command: '<%= config.bin %> <%= command.id %> --name \"Acme Corp\" --default-role member',\n description: 'Create an organization with a default member role',\n },\n {\n command: '<%= config.bin %> <%= command.id %> --name \"Acme Corp\" --logo ./logo.png',\n description: 'Create an organization with a logo',\n },\n ]\n\n static override flags = {\n 'default-role': Flags.string({\n description: 'Default role assigned to new members',\n required: false,\n }),\n logo: Flags.string({\n description:\n 'Image file to use as the logo: PNG, JPEG, GIF, WebP, SVG, BMP, TIFF, HEIF or AVIF, at most 5 MB',\n helpValue: '<path>',\n required: false,\n }),\n name: requiredWhenUnattended(\n Flags.string({\n description: 'Organization name',\n }),\n ),\n } satisfies FlagInput\n\n static override hiddenAliases = organizationAliases('create')\n\n static telemetry = defineCommandTelemetry(this.flags, {redact: ['logo', 'name']})\n\n public async run(): Promise<void> {\n const {'default-role': defaultRoleFlag, logo: logoPath, name: nameFlag} = this.flags\n\n const defaultRole = defaultRoleFlag?.trim()\n if (defaultRole === '') {\n this.error('Default role cannot be empty', {exit: exitCodes.RUNTIME_ERROR})\n }\n\n // Read the logo before creating anything, so a bad file doesn't leave an organization without it.\n let logo: ImageFile | undefined\n if (logoPath === '') {\n this.error(\n '--logo needs the path to an image file. To create the organization without a logo, leave out --logo.',\n {exit: exitCodes.RUNTIME_ERROR},\n )\n } else if (logoPath !== undefined) {\n try {\n logo = await readImageFile(logoPath)\n } catch (error) {\n this.error(getErrorMessage(error), {exit: exitCodes.RUNTIME_ERROR})\n }\n }\n\n let name: string\n if (nameFlag === undefined) {\n name = await promptForOrganizationName()\n } else {\n const trimmedName = nameFlag.trim()\n const validation = validateOrganizationName(trimmedName)\n if (validation !== true) {\n this.error(validation, {exit: exitCodes.RUNTIME_ERROR})\n }\n name = trimmedName\n }\n\n const spin = spinner('Creating organization').start()\n let org: OrganizationCreateResponse\n try {\n org = await createOrganization(name, defaultRole)\n spin.succeed('Organization created')\n this.log(`ID: ${org.id}`)\n this.log(`Name: ${org.name}`)\n } catch (error) {\n spin.fail()\n createOrgDebug('Error creating organization', error)\n this.error(`Failed to create organization: ${getErrorMessage(error)}`, {\n exit: exitCodes.RUNTIME_ERROR,\n })\n }\n\n if (!logo) return\n\n const logoSpin = spinner('Setting logo').start()\n try {\n const {logoUrl} = await setOrganizationLogo(org.id, logo)\n logoSpin.succeed()\n this.log(`Logo: ${logoUrl}`)\n } catch (error) {\n logoSpin.fail()\n createOrgDebug('Error setting organization logo', error)\n this.error(\n `The organization was created, but its logo wasn't set: ${getErrorMessage(error)}\\nTo try again, run: ${this.config.bin} organizations update ${org.id} --logo \"${logoPath}\"`,\n {exit: exitCodes.RUNTIME_ERROR},\n )\n }\n }\n}\n"],"names":["Flags","exitCodes","SanityCommand","subdebug","getErrorMessage","requiredWhenUnattended","readImageFile","spinner","validateOrganizationName","promptForOrganizationName","createOrganization","setOrganizationLogo","organizationAliases","defineCommandTelemetry","createOrgDebug","CreateOrganizationCommand","description","examples","command","flags","string","required","logo","helpValue","name","hiddenAliases","telemetry","redact","run","defaultRoleFlag","logoPath","nameFlag","defaultRole","trim","error","exit","RUNTIME_ERROR","undefined","trimmedName","validation","spin","start","org","succeed","log","id","fail","logoSpin","logoUrl","config","bin"],"mappings":"AAAA,SAAQA,KAAK,QAAO,cAAa;AAEjC,SAAQC,SAAS,EAAEC,aAAa,EAAEC,QAAQ,QAAO,mBAAkB;AACnE,SAAQC,eAAe,QAAO,0BAAyB;AACvD,SAAQC,sBAAsB,QAAO,yBAAwB;AAC7D,SAAwBC,aAAa,QAAO,0BAAyB;AACrE,SAAQC,OAAO,QAAO,sBAAqB;AAE3C,SAAQC,wBAAwB,QAAO,0DAAyD;AAChG,SAAQC,yBAAyB,QAAO,6CAA4C;AACpF,SACEC,kBAAkB,EAElBC,mBAAmB,QACd,kCAAiC;AACxC,SAAQC,mBAAmB,QAAO,oCAAmC;AACrE,SAAQC,sBAAsB,QAAO,2CAA0C;AAE/E,MAAMC,iBAAiBX,SAAS;AAEhC,OAAO,MAAMY,kCAAkCb;IAC7C,OAAgBc,cAAc,4BAA2B;IAEzD,OAAgBC,WAAW;QACzB;YACEC,SAAS;YACTF,aAAa;QACf;QACA;YACEE,SAAS;YACTF,aAAa;QACf;QACA;YACEE,SAAS;YACTF,aAAa;QACf;QACA;YACEE,SAAS;YACTF,aAAa;QACf;KACD,CAAA;IAED,OAAgBG,QAAQ;QACtB,gBAAgBnB,MAAMoB,MAAM,CAAC;YAC3BJ,aAAa;YACbK,UAAU;QACZ;QACAC,MAAMtB,MAAMoB,MAAM,CAAC;YACjBJ,aACE;YACFO,WAAW;YACXF,UAAU;QACZ;QACAG,MAAMnB,uBACJL,MAAMoB,MAAM,CAAC;YACXJ,aAAa;QACf;IAEJ,EAAqB;IAErB,OAAgBS,gBAAgBb,oBAAoB,UAAS;IAE7D,OAAOc,YAAY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AOU,OAAO;YACdM,KAAKM,IAAI;YACThC,eAAe,+BAA+BoB;YAC9C,IAAI,CAACA,KAAK,CAAC,CAAC,+BAA+B,EAAE9B,gBAAgB8B,QAAQ,EAAE;gBACrEC,MAAMlC,UAAUmC,aAAa;YAC/B;QACF;QAEA,IAAI,CAACd,MAAM;QAEX,MAAMyB,WAAWxC,QAAQ,gBAAgBkC,KAAK;QAC9C,IAAI;YACF,MAAM,EAACO,OAAO,EAAC,GAAG,MAAMrC,oBAAoB+B,IAAIG,EAAE,EAAEvB;YACpDyB,SAASJ,OAAO;YAChB,IAAI,CAACC,GAAG,CAAC,CAAC,MAAM,EAAEI,SAAS;QAC7B,EAAE,OAAOd,OAAO;YACda,SAASD,IAAI;YACbhC,eAAe,mCAAmCoB;YAClD,IAAI,CAACA,KAAK,CACR,CAAC,uDAAuD,EAAE9B,gBAAgB8B,OAAO,qBAAqB,EAAE,IAAI,CAACe,MAAM,CAACC,GAAG,CAAC,sBAAsB,EAAER,IAAIG,EAAE,CAAC,SAAS,EAAEf,SAAS,CAAC,CAAC,EAC7K;gBAACK,MAAMlC,UAAUmC,aAAa;YAAA;QAElC;IACF;AACF"}
@@ -1,9 +1,9 @@
1
1
  import { Args, Flags } from '@oclif/core';
2
2
  import { exitCodes, SanityCommand, subdebug } from '@sanity/cli-core';
3
3
  import { getErrorMessage } from '@sanity/cli-core/errors';
4
+ import { readImageFile } from '@sanity/cli-core/images';
4
5
  import { spinner } from '@sanity/cli-core/ux';
5
6
  import { isHttpError } from '@sanity/client';
6
- import { readOrganizationLogo } from '../../actions/organizations/readOrganizationLogo.js';
7
7
  import { validateOrganizationName } from '../../actions/organizations/validateOrganizationName.js';
8
8
  import { validateOrganizationSlug } from '../../actions/organizations/validateOrganizationSlug.js';
9
9
  import { removeOrganizationLogo, setOrganizationLogo, updateOrganization } from '../../services/organizations.js';
@@ -123,7 +123,7 @@ export class UpdateOrganizationCommand extends SanityCommand {
123
123
  logo = null;
124
124
  } else if (logoPath !== undefined) {
125
125
  try {
126
- logo = await readOrganizationLogo(logoPath);
126
+ logo = await readImageFile(logoPath);
127
127
  } catch (error) {
128
128
  this.error(getErrorMessage(error), {
129
129
  exit: exitCodes.RUNTIME_ERROR