@sanity/cli 6.6.0 → 6.7.1

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 (183) hide show
  1. package/README.md +12 -4
  2. package/dist/actions/auth/login/login.js +4 -1
  3. package/dist/actions/auth/login/login.js.map +1 -1
  4. package/dist/actions/build/buildApp.js +4 -5
  5. package/dist/actions/build/buildApp.js.map +1 -1
  6. package/dist/actions/build/buildStaticFiles.js +12 -4
  7. package/dist/actions/build/buildStaticFiles.js.map +1 -1
  8. package/dist/actions/build/buildStudio.js +6 -14
  9. package/dist/actions/build/buildStudio.js.map +1 -1
  10. package/dist/actions/build/{getStudioEnvironmentVariables.js → getEnvironmentVariables.js} +15 -19
  11. package/dist/actions/build/getEnvironmentVariables.js.map +1 -0
  12. package/dist/actions/deploy/deployStudio.js +1 -2
  13. package/dist/actions/deploy/deployStudio.js.map +1 -1
  14. package/dist/actions/deploy/deployStudioSchemasAndManifests.js +1 -2
  15. package/dist/actions/deploy/deployStudioSchemasAndManifests.js.map +1 -1
  16. package/dist/actions/deploy/deployStudioSchemasAndManifests.worker.js +1 -1
  17. package/dist/actions/deploy/deployStudioSchemasAndManifests.worker.js.map +1 -1
  18. package/dist/actions/dev/startStudioDevServer.js +1 -1
  19. package/dist/actions/dev/startStudioDevServer.js.map +1 -1
  20. package/dist/actions/documents/validateDocuments.worker.js +1 -2
  21. package/dist/actions/documents/validateDocuments.worker.js.map +1 -1
  22. package/dist/actions/graphql/SchemaError.js +1 -1
  23. package/dist/actions/graphql/SchemaError.js.map +1 -1
  24. package/dist/actions/init/initAction.js +32 -1
  25. package/dist/actions/init/initAction.js.map +1 -1
  26. package/dist/actions/init/scaffoldTemplate.js +32 -18
  27. package/dist/actions/init/scaffoldTemplate.js.map +1 -1
  28. package/dist/actions/init/templates/index.js +2 -0
  29. package/dist/actions/init/templates/index.js.map +1 -1
  30. package/dist/actions/init/templates/pageBuilder.js +32 -0
  31. package/dist/actions/init/templates/pageBuilder.js.map +1 -0
  32. package/dist/actions/init/types.js +2 -1
  33. package/dist/actions/init/types.js.map +1 -1
  34. package/dist/actions/manifest/extractManifest.js +1 -1
  35. package/dist/actions/manifest/extractManifest.js.map +1 -1
  36. package/dist/actions/manifest/extractManifest.worker.js +1 -1
  37. package/dist/actions/manifest/extractManifest.worker.js.map +1 -1
  38. package/dist/actions/mcp/editorConfigs.js +51 -11
  39. package/dist/actions/mcp/editorConfigs.js.map +1 -1
  40. package/dist/actions/mcp/promptForMCPSetup.js +16 -11
  41. package/dist/actions/mcp/promptForMCPSetup.js.map +1 -1
  42. package/dist/actions/mcp/setupMCP.js +180 -61
  43. package/dist/actions/mcp/setupMCP.js.map +1 -1
  44. package/dist/actions/mcp/types.js.map +1 -1
  45. package/dist/actions/schema/deploySchemas.js +1 -1
  46. package/dist/actions/schema/deploySchemas.js.map +1 -1
  47. package/dist/actions/schema/extractSanityWorkspace.worker.js +1 -1
  48. package/dist/actions/schema/extractSanityWorkspace.worker.js.map +1 -1
  49. package/dist/actions/schema/extractSchema.js +1 -4
  50. package/dist/actions/schema/extractSchema.js.map +1 -1
  51. package/dist/actions/schema/extractSchemaWatcher.js +1 -4
  52. package/dist/actions/schema/extractSchemaWatcher.js.map +1 -1
  53. package/dist/actions/schema/getExtractOptions.js +8 -18
  54. package/dist/actions/schema/getExtractOptions.js.map +1 -1
  55. package/dist/actions/schema/types.js +0 -6
  56. package/dist/actions/schema/types.js.map +1 -1
  57. package/dist/actions/schema/validateAction.js +1 -1
  58. package/dist/actions/schema/validateAction.js.map +1 -1
  59. package/dist/actions/schema/validateSchema.worker.js +1 -2
  60. package/dist/actions/schema/validateSchema.worker.js.map +1 -1
  61. package/dist/actions/schema/watchExtractSchema.js +1 -1
  62. package/dist/actions/schema/watchExtractSchema.js.map +1 -1
  63. package/dist/actions/skills/readSkillState.js +54 -0
  64. package/dist/actions/skills/readSkillState.js.map +1 -0
  65. package/dist/actions/skills/setupSkills.js +73 -0
  66. package/dist/actions/skills/setupSkills.js.map +1 -0
  67. package/dist/commands/build.js +9 -22
  68. package/dist/commands/build.js.map +1 -1
  69. package/dist/commands/cors/add.js +5 -5
  70. package/dist/commands/cors/add.js.map +1 -1
  71. package/dist/commands/datasets/export.js +9 -0
  72. package/dist/commands/datasets/export.js.map +1 -1
  73. package/dist/commands/docs/read.js +33 -12
  74. package/dist/commands/docs/read.js.map +1 -1
  75. package/dist/commands/init.js +12 -1
  76. package/dist/commands/init.js.map +1 -1
  77. package/dist/commands/manifest/extract.js +1 -2
  78. package/dist/commands/manifest/extract.js.map +1 -1
  79. package/dist/commands/mcp/configure.js +2 -1
  80. package/dist/commands/mcp/configure.js.map +1 -1
  81. package/dist/commands/schemas/deploy.js +1 -2
  82. package/dist/commands/schemas/deploy.js.map +1 -1
  83. package/dist/exports/_internal.d.ts +2 -1
  84. package/dist/exports/_internal.js +1 -1
  85. package/dist/exports/_internal.js.map +1 -1
  86. package/dist/server/devServer.js +25 -4
  87. package/dist/server/devServer.js.map +1 -1
  88. package/dist/server/previewServer.js +1 -1
  89. package/dist/server/previewServer.js.map +1 -1
  90. package/dist/services/mcp.js +1 -1
  91. package/dist/services/mcp.js.map +1 -1
  92. package/dist/telemetry/init.telemetry.js.map +1 -1
  93. package/oclif.manifest.json +17 -1
  94. package/package.json +17 -18
  95. package/templates/page-builder/README.md +9 -0
  96. package/templates/page-builder/schemaTypes/hero.js +31 -0
  97. package/templates/page-builder/schemaTypes/index.js +19 -0
  98. package/templates/page-builder/static/.gitkeep +0 -0
  99. package/dist/actions/build/buildDebug.js +0 -4
  100. package/dist/actions/build/buildDebug.js.map +0 -1
  101. package/dist/actions/build/buildVendorDependencies.js +0 -149
  102. package/dist/actions/build/buildVendorDependencies.js.map +0 -1
  103. package/dist/actions/build/checkStudioDependencyVersions.js +0 -155
  104. package/dist/actions/build/checkStudioDependencyVersions.js.map +0 -1
  105. package/dist/actions/build/createExternalFromImportMap.js +0 -11
  106. package/dist/actions/build/createExternalFromImportMap.js.map +0 -1
  107. package/dist/actions/build/decorateIndexWithAutoGeneratedWarning.js +0 -13
  108. package/dist/actions/build/decorateIndexWithAutoGeneratedWarning.js.map +0 -1
  109. package/dist/actions/build/decorateIndexWithBridgeScript.js +0 -17
  110. package/dist/actions/build/decorateIndexWithBridgeScript.js.map +0 -1
  111. package/dist/actions/build/decorateIndexWithStagingScript.js +0 -16
  112. package/dist/actions/build/decorateIndexWithStagingScript.js.map +0 -1
  113. package/dist/actions/build/getAppEnvVars.js +0 -9
  114. package/dist/actions/build/getAppEnvVars.js.map +0 -1
  115. package/dist/actions/build/getEntryModule.js +0 -46
  116. package/dist/actions/build/getEntryModule.js.map +0 -1
  117. package/dist/actions/build/getPossibleDocumentComponentLocations.js +0 -11
  118. package/dist/actions/build/getPossibleDocumentComponentLocations.js.map +0 -1
  119. package/dist/actions/build/getStudioEnvVars.js +0 -9
  120. package/dist/actions/build/getStudioEnvVars.js.map +0 -1
  121. package/dist/actions/build/getStudioEnvironmentVariables.js.map +0 -1
  122. package/dist/actions/build/getViteConfig.js +0 -219
  123. package/dist/actions/build/getViteConfig.js.map +0 -1
  124. package/dist/actions/build/normalizeBasePath.js +0 -9
  125. package/dist/actions/build/normalizeBasePath.js.map +0 -1
  126. package/dist/actions/build/renderDocument.js +0 -50
  127. package/dist/actions/build/renderDocument.js.map +0 -1
  128. package/dist/actions/build/renderDocument.worker.js +0 -9
  129. package/dist/actions/build/renderDocument.worker.js.map +0 -1
  130. package/dist/actions/build/renderDocumentWorker/addTimestampImportMapScriptToHtml.js +0 -79
  131. package/dist/actions/build/renderDocumentWorker/addTimestampImportMapScriptToHtml.js.map +0 -1
  132. package/dist/actions/build/renderDocumentWorker/components/BasicDocument.js +0 -61
  133. package/dist/actions/build/renderDocumentWorker/components/BasicDocument.js.map +0 -1
  134. package/dist/actions/build/renderDocumentWorker/components/DefaultDocument.js +0 -165
  135. package/dist/actions/build/renderDocumentWorker/components/DefaultDocument.js.map +0 -1
  136. package/dist/actions/build/renderDocumentWorker/components/Favicons.js +0 -28
  137. package/dist/actions/build/renderDocumentWorker/components/Favicons.js.map +0 -1
  138. package/dist/actions/build/renderDocumentWorker/components/GlobalErrorHandler.js +0 -178
  139. package/dist/actions/build/renderDocumentWorker/components/GlobalErrorHandler.js.map +0 -1
  140. package/dist/actions/build/renderDocumentWorker/components/NoJavascript.js +0 -51
  141. package/dist/actions/build/renderDocumentWorker/components/NoJavascript.js.map +0 -1
  142. package/dist/actions/build/renderDocumentWorker/getDocumentComponent.js +0 -41
  143. package/dist/actions/build/renderDocumentWorker/getDocumentComponent.js.map +0 -1
  144. package/dist/actions/build/renderDocumentWorker/getDocumentHtml.js +0 -55
  145. package/dist/actions/build/renderDocumentWorker/getDocumentHtml.js.map +0 -1
  146. package/dist/actions/build/renderDocumentWorker/renderDocumentWorker.js +0 -31
  147. package/dist/actions/build/renderDocumentWorker/renderDocumentWorker.js.map +0 -1
  148. package/dist/actions/build/renderDocumentWorker/tryLoadDocumentComponent.js +0 -30
  149. package/dist/actions/build/renderDocumentWorker/tryLoadDocumentComponent.js.map +0 -1
  150. package/dist/actions/build/renderDocumentWorker/types.js +0 -5
  151. package/dist/actions/build/renderDocumentWorker/types.js.map +0 -1
  152. package/dist/actions/build/writeSanityRuntime.js +0 -64
  153. package/dist/actions/build/writeSanityRuntime.js.map +0 -1
  154. package/dist/actions/docs/normalizeDocsPath.js +0 -15
  155. package/dist/actions/docs/normalizeDocsPath.js.map +0 -1
  156. package/dist/actions/schema/extractSanitySchema.worker.js +0 -33
  157. package/dist/actions/schema/extractSanitySchema.worker.js.map +0 -1
  158. package/dist/actions/schema/formatSchemaValidation.js +0 -78
  159. package/dist/actions/schema/formatSchemaValidation.js.map +0 -1
  160. package/dist/actions/schema/matchSchemaPattern.js +0 -22
  161. package/dist/actions/schema/matchSchemaPattern.js.map +0 -1
  162. package/dist/actions/schema/runSchemaExtraction.js +0 -39
  163. package/dist/actions/schema/runSchemaExtraction.js.map +0 -1
  164. package/dist/actions/schema/utils/SchemaExtractionError.js +0 -10
  165. package/dist/actions/schema/utils/SchemaExtractionError.js.map +0 -1
  166. package/dist/actions/schema/utils/extractValidationFromSchemaError.js +0 -12
  167. package/dist/actions/schema/utils/extractValidationFromSchemaError.js.map +0 -1
  168. package/dist/constants.js +0 -8
  169. package/dist/constants.js.map +0 -1
  170. package/dist/server/vite/plugin-sanity-build-entries.js +0 -67
  171. package/dist/server/vite/plugin-sanity-build-entries.js.map +0 -1
  172. package/dist/server/vite/plugin-sanity-favicons.js +0 -72
  173. package/dist/server/vite/plugin-sanity-favicons.js.map +0 -1
  174. package/dist/server/vite/plugin-sanity-runtime-rewrite.js +0 -18
  175. package/dist/server/vite/plugin-sanity-runtime-rewrite.js.map +0 -1
  176. package/dist/server/vite/plugin-schema-extraction.js +0 -201
  177. package/dist/server/vite/plugin-schema-extraction.js.map +0 -1
  178. package/dist/telemetry/build.telemetry.js +0 -13
  179. package/dist/telemetry/build.telemetry.js.map +0 -1
  180. package/dist/telemetry/extractSchema.telemetry.js +0 -18
  181. package/dist/telemetry/extractSchema.telemetry.js.map +0 -1
  182. package/dist/util/getWorkspace.js +0 -18
  183. package/dist/util/getWorkspace.js.map +0 -1
@@ -1,8 +1,34 @@
1
1
  import { Args, Flags } from '@oclif/core';
2
2
  import { SanityCommand } from '@sanity/cli-core';
3
3
  import open from 'open';
4
- import { normalizeDocsPath } from '../../actions/docs/normalizeDocsPath.js';
5
4
  import { readDoc } from '../../services/docs.js';
5
+ function isSanityHostname(hostname) {
6
+ return hostname === 'sanity.io' || hostname.endsWith('.sanity.io');
7
+ }
8
+ function parseDocsInput(input) {
9
+ try {
10
+ const url = new URL(input);
11
+ if (isSanityHostname(url.hostname)) {
12
+ return {
13
+ readPath: url.pathname,
14
+ webPath: `${url.pathname}${url.search}${url.hash}`
15
+ };
16
+ }
17
+ } catch {
18
+ // Input is not an absolute URL.
19
+ }
20
+ if (input.startsWith('/') && !input.startsWith('//')) {
21
+ const url = new URL(input, 'https://www.sanity.io');
22
+ return {
23
+ readPath: url.pathname,
24
+ webPath: `${url.pathname}${url.search}${url.hash}`
25
+ };
26
+ }
27
+ return {
28
+ readPath: input,
29
+ webPath: input
30
+ };
31
+ }
6
32
  export class DocsReadCommand extends SanityCommand {
7
33
  static args = {
8
34
  path: Args.string({
@@ -41,32 +67,27 @@ export class DocsReadCommand extends SanityCommand {
41
67
  const { args, flags } = await this.parse(DocsReadCommand);
42
68
  const { path: input } = args;
43
69
  const { web } = flags;
44
- // Normalize URL to path
45
- const path = normalizeDocsPath(input);
46
- // Validate the normalized path
47
- if (!path.startsWith('/')) {
70
+ const { readPath, webPath } = parseDocsInput(input);
71
+ if (!readPath.startsWith('/')) {
48
72
  this.error('Invalid path or URL. Expected a Sanity docs path or URL.\nExamples:\n /docs/studio/installation\n https://www.sanity.io/docs/studio/installation', {
49
73
  exit: 1
50
74
  });
51
75
  }
52
- // Enhanced validation for security and correctness
53
- if (path.includes('..') || !path.startsWith('/docs/')) {
76
+ if (readPath.includes('..') || !readPath.startsWith('/docs/')) {
54
77
  this.error('Invalid path. Must be a valid Sanity docs path starting with /docs/\nExample: /docs/studio/installation', {
55
78
  exit: 1
56
79
  });
57
80
  }
58
- // Open in web browser if --web or -w flag is provided
59
81
  if (web) {
60
- const url = `https://www.sanity.io${path}`;
82
+ const url = `https://www.sanity.io${webPath}`;
61
83
  this.log(`Opening ${url}`);
62
84
  await open(url);
63
85
  return;
64
86
  }
65
- // Default behavior: read as markdown in terminal
66
- this.log(`Reading article: ${path}`);
87
+ this.log(`Reading article: ${readPath}`);
67
88
  try {
68
89
  const content = await readDoc({
69
- path
90
+ path: readPath
70
91
  });
71
92
  this.log('\n---\n');
72
93
  this.log(content);
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/commands/docs/read.ts"],"sourcesContent":["import {Args, Flags} from '@oclif/core'\nimport {SanityCommand} from '@sanity/cli-core'\nimport open from 'open'\n\nimport {normalizeDocsPath} from '../../actions/docs/normalizeDocsPath.js'\nimport {readDoc} from '../../services/docs.js'\n\nexport class DocsReadCommand extends SanityCommand<typeof DocsReadCommand> {\n static override args = {\n path: Args.string({\n description: 'Path or URL to article, found in search results and docs content as links',\n required: true,\n }),\n }\n\n static override description = 'Read an article in terminal'\n\n static override examples = [\n {\n command: '<%= config.bin %> <%= command.id %> /docs/studio/installation',\n description: 'Read as markdown in terminal',\n },\n {\n command: '<%= config.bin %> <%= command.id %> https://www.sanity.io/docs/studio/installation',\n description: 'Read using full URL',\n },\n {\n command: '<%= config.bin %> <%= command.id %> /docs/studio/installation --web',\n description: 'Open in web browser',\n },\n {\n command:\n '<%= config.bin %> <%= command.id %> https://www.sanity.io/docs/studio/installation -w',\n description: 'Open using full URL in web browser',\n },\n ]\n\n static override flags = {\n web: Flags.boolean({\n aliases: ['w'],\n description: 'Open in a web browser',\n }),\n }\n\n public async run(): Promise<void> {\n const {args, flags} = await this.parse(DocsReadCommand)\n const {path: input} = args\n const {web} = flags\n\n // Normalize URL to path\n const path = normalizeDocsPath(input)\n\n // Validate the normalized path\n if (!path.startsWith('/')) {\n this.error(\n 'Invalid path or URL. Expected a Sanity docs path or URL.\\nExamples:\\n /docs/studio/installation\\n https://www.sanity.io/docs/studio/installation',\n {\n exit: 1,\n },\n )\n }\n\n // Enhanced validation for security and correctness\n if (path.includes('..') || !path.startsWith('/docs/')) {\n this.error(\n 'Invalid path. Must be a valid Sanity docs path starting with /docs/\\nExample: /docs/studio/installation',\n {\n exit: 1,\n },\n )\n }\n\n // Open in web browser if --web or -w flag is provided\n if (web) {\n const url = `https://www.sanity.io${path}`\n this.log(`Opening ${url}`)\n await open(url)\n return\n }\n\n // Default behavior: read as markdown in terminal\n this.log(`Reading article: ${path}`)\n\n try {\n const content = await readDoc({path})\n this.log('\\n---\\n')\n this.log(content)\n } catch (error) {\n this.error(error instanceof Error ? error.message : 'Failed to read article', {\n exit: 1,\n })\n }\n }\n}\n"],"names":["Args","Flags","SanityCommand","open","normalizeDocsPath","readDoc","DocsReadCommand","args","path","string","description","required","examples","command","flags","web","boolean","aliases","run","parse","input","startsWith","error","exit","includes","url","log","content","Error","message"],"mappings":"AAAA,SAAQA,IAAI,EAAEC,KAAK,QAAO,cAAa;AACvC,SAAQC,aAAa,QAAO,mBAAkB;AAC9C,OAAOC,UAAU,OAAM;AAEvB,SAAQC,iBAAiB,QAAO,0CAAyC;AACzE,SAAQC,OAAO,QAAO,yBAAwB;AAE9C,OAAO,MAAMC,wBAAwBJ;IACnC,OAAgBK,OAAO;QACrBC,MAAMR,KAAKS,MAAM,CAAC;YAChBC,aAAa;YACbC,UAAU;QACZ;IACF,EAAC;IAED,OAAgBD,cAAc,8BAA6B;IAE3D,OAAgBE,WAAW;QACzB;YACEC,SAAS;YACTH,aAAa;QACf;QACA;YACEG,SAAS;YACTH,aAAa;QACf;QACA;YACEG,SAAS;YACTH,aAAa;QACf;QACA;YACEG,SACE;YACFH,aAAa;QACf;KACD,CAAA;IAED,OAAgBI,QAAQ;QACtBC,KAAKd,MAAMe,OAAO,CAAC;YACjBC,SAAS;gBAAC;aAAI;YACdP,aAAa;QACf;IACF,EAAC;IAED,MAAaQ,MAAqB;QAChC,MAAM,EAACX,IAAI,EAAEO,KAAK,EAAC,GAAG,MAAM,IAAI,CAACK,KAAK,CAACb;QACvC,MAAM,EAACE,MAAMY,KAAK,EAAC,GAAGb;QACtB,MAAM,EAACQ,GAAG,EAAC,GAAGD;QAEd,wBAAwB;QACxB,MAAMN,OAAOJ,kBAAkBgB;QAE/B,+BAA+B;QAC/B,IAAI,CAACZ,KAAKa,UAAU,CAAC,MAAM;YACzB,IAAI,CAACC,KAAK,CACR,sJACA;gBACEC,MAAM;YACR;QAEJ;QAEA,mDAAmD;QACnD,IAAIf,KAAKgB,QAAQ,CAAC,SAAS,CAAChB,KAAKa,UAAU,CAAC,WAAW;YACrD,IAAI,CAACC,KAAK,CACR,2GACA;gBACEC,MAAM;YACR;QAEJ;QAEA,sDAAsD;QACtD,IAAIR,KAAK;YACP,MAAMU,MAAM,CAAC,qBAAqB,EAAEjB,MAAM;YAC1C,IAAI,CAACkB,GAAG,CAAC,CAAC,QAAQ,EAAED,KAAK;YACzB,MAAMtB,KAAKsB;YACX;QACF;QAEA,iDAAiD;QACjD,IAAI,CAACC,GAAG,CAAC,CAAC,iBAAiB,EAAElB,MAAM;QAEnC,IAAI;YACF,MAAMmB,UAAU,MAAMtB,QAAQ;gBAACG;YAAI;YACnC,IAAI,CAACkB,GAAG,CAAC;YACT,IAAI,CAACA,GAAG,CAACC;QACX,EAAE,OAAOL,OAAO;YACd,IAAI,CAACA,KAAK,CAACA,iBAAiBM,QAAQN,MAAMO,OAAO,GAAG,0BAA0B;gBAC5EN,MAAM;YACR;QACF;IACF;AACF"}
1
+ {"version":3,"sources":["../../../src/commands/docs/read.ts"],"sourcesContent":["import {Args, Flags} from '@oclif/core'\nimport {SanityCommand} from '@sanity/cli-core'\nimport open from 'open'\n\nimport {readDoc} from '../../services/docs.js'\n\ninterface DocsInput {\n readPath: string\n webPath: string\n}\n\nfunction isSanityHostname(hostname: string): boolean {\n return hostname === 'sanity.io' || hostname.endsWith('.sanity.io')\n}\n\nfunction parseDocsInput(input: string): DocsInput {\n try {\n const url = new URL(input)\n\n if (isSanityHostname(url.hostname)) {\n return {\n readPath: url.pathname,\n webPath: `${url.pathname}${url.search}${url.hash}`,\n }\n }\n } catch {\n // Input is not an absolute URL.\n }\n\n if (input.startsWith('/') && !input.startsWith('//')) {\n const url = new URL(input, 'https://www.sanity.io')\n\n return {\n readPath: url.pathname,\n webPath: `${url.pathname}${url.search}${url.hash}`,\n }\n }\n\n return {\n readPath: input,\n webPath: input,\n }\n}\n\nexport class DocsReadCommand extends SanityCommand<typeof DocsReadCommand> {\n static override args = {\n path: Args.string({\n description: 'Path or URL to article, found in search results and docs content as links',\n required: true,\n }),\n }\n\n static override description = 'Read an article in terminal'\n\n static override examples = [\n {\n command: '<%= config.bin %> <%= command.id %> /docs/studio/installation',\n description: 'Read as markdown in terminal',\n },\n {\n command: '<%= config.bin %> <%= command.id %> https://www.sanity.io/docs/studio/installation',\n description: 'Read using full URL',\n },\n {\n command: '<%= config.bin %> <%= command.id %> /docs/studio/installation --web',\n description: 'Open in web browser',\n },\n {\n command:\n '<%= config.bin %> <%= command.id %> https://www.sanity.io/docs/studio/installation -w',\n description: 'Open using full URL in web browser',\n },\n ]\n\n static override flags = {\n web: Flags.boolean({\n aliases: ['w'],\n description: 'Open in a web browser',\n }),\n }\n\n public async run(): Promise<void> {\n const {args, flags} = await this.parse(DocsReadCommand)\n const {path: input} = args\n const {web} = flags\n\n const {readPath, webPath} = parseDocsInput(input)\n\n if (!readPath.startsWith('/')) {\n this.error(\n 'Invalid path or URL. Expected a Sanity docs path or URL.\\nExamples:\\n /docs/studio/installation\\n https://www.sanity.io/docs/studio/installation',\n {\n exit: 1,\n },\n )\n }\n\n if (readPath.includes('..') || !readPath.startsWith('/docs/')) {\n this.error(\n 'Invalid path. Must be a valid Sanity docs path starting with /docs/\\nExample: /docs/studio/installation',\n {\n exit: 1,\n },\n )\n }\n\n if (web) {\n const url = `https://www.sanity.io${webPath}`\n this.log(`Opening ${url}`)\n await open(url)\n return\n }\n\n this.log(`Reading article: ${readPath}`)\n\n try {\n const content = await readDoc({path: readPath})\n this.log('\\n---\\n')\n this.log(content)\n } catch (error) {\n this.error(error instanceof Error ? error.message : 'Failed to read article', {\n exit: 1,\n })\n }\n }\n}\n"],"names":["Args","Flags","SanityCommand","open","readDoc","isSanityHostname","hostname","endsWith","parseDocsInput","input","url","URL","readPath","pathname","webPath","search","hash","startsWith","DocsReadCommand","args","path","string","description","required","examples","command","flags","web","boolean","aliases","run","parse","error","exit","includes","log","content","Error","message"],"mappings":"AAAA,SAAQA,IAAI,EAAEC,KAAK,QAAO,cAAa;AACvC,SAAQC,aAAa,QAAO,mBAAkB;AAC9C,OAAOC,UAAU,OAAM;AAEvB,SAAQC,OAAO,QAAO,yBAAwB;AAO9C,SAASC,iBAAiBC,QAAgB;IACxC,OAA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EAAC,GAAGD;QAEd,MAAM,EAACd,QAAQ,EAAEE,OAAO,EAAC,GAAGN,eAAeC;QAE3C,IAAI,CAACG,SAASK,UAAU,CAAC,MAAM;YAC7B,IAAI,CAACe,KAAK,CACR,sJACA;gBACEC,MAAM;YACR;QAEJ;QAEA,IAAIrB,SAASsB,QAAQ,CAAC,SAAS,CAACtB,SAASK,UAAU,CAAC,WAAW;YAC7D,IAAI,CAACe,KAAK,CACR,2GACA;gBACEC,MAAM;YACR;QAEJ;QAEA,IAAIN,KAAK;YACP,MAAMjB,MAAM,CAAC,qBAAqB,EAAEI,SAAS;YAC7C,IAAI,CAACqB,GAAG,CAAC,CAAC,QAAQ,EAAEzB,KAAK;YACzB,MAAMP,KAAKO;YACX;QACF;QAEA,IAAI,CAACyB,GAAG,CAAC,CAAC,iBAAiB,EAAEvB,UAAU;QAEvC,IAAI;YACF,MAAMwB,UAAU,MAAMhC,QAAQ;gBAACgB,MAAMR;YAAQ;YAC7C,IAAI,CAACuB,GAAG,CAAC;YACT,IAAI,CAACA,GAAG,CAACC;QACX,EAAE,OAAOJ,OAAO;YACd,IAAI,CAACA,KAAK,CAACA,iBAAiBK,QAAQL,MAAMM,OAAO,GAAG,0BAA0B;gBAC5EL,MAAM;YACR;QACF;IACF;AACF"}
@@ -202,6 +202,11 @@ export class InitCommand extends SanityCommand {
202
202
  description: 'Reconfigure an existing project',
203
203
  hidden: true
204
204
  }),
205
+ skills: Flags.boolean({
206
+ allowNo: true,
207
+ default: true,
208
+ description: 'Install Sanity agent skills globally for detected AI editors'
209
+ }),
205
210
  template: Flags.string({
206
211
  description: 'Project template to use [default: "clean"]',
207
212
  exclusive: [
@@ -244,8 +249,14 @@ export class InitCommand extends SanityCommand {
244
249
  } else if (this.flags.yes) {
245
250
  mcpMode = 'auto';
246
251
  }
252
+ // Mirror MCP's environment gating: skip skills install in non-production
253
+ // Sanity envs so e2e / UI tests don't run the bundled skills CLI.
254
+ let skillsMode = 'auto';
255
+ if (!this.flags.skills || !this.resolveIsInteractive() || getSanityEnv() !== 'production') {
256
+ skillsMode = 'skip';
257
+ }
247
258
  try {
248
- await initAction(flagsToInitOptions(this.flags, this.isUnattended(), this.args, mcpMode), {
259
+ await initAction(flagsToInitOptions(this.flags, this.isUnattended(), this.args, mcpMode, skillsMode), {
249
260
  output: this.output,
250
261
  telemetry: this.telemetry,
251
262
  workDir: process.cwd()
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/commands/init.ts"],"sourcesContent":["import {Args, Command, Flags} from '@oclif/core'\nimport {CLIError} from '@oclif/core/errors'\nimport {SanityCommand} from '@sanity/cli-core'\n\nimport {initAction} from '../actions/init/initAction.js'\nimport {InitError} from '../actions/init/initError.js'\nimport {flagsToInitOptions} from '../actions/init/types.js'\nimport {getSanityEnv} from '../util/getSanityEnv.js'\n\nexport class InitCommand extends SanityCommand<typeof InitCommand> {\n static override args = {type: Args.string({hidden: true})}\n static override description = 'Initialize a new Sanity Studio, project and/or app'\n static override enableJsonFlag = true\n\n static override examples = [\n '<%= config.bin %> <%= command.id %>',\n {\n command: '<%= config.bin %> <%= command.id %> --dataset-default',\n description: 'Initialize a new project with a public dataset named \"production\"',\n },\n {\n command:\n '<%= config.bin %> <%= command.id %> -y --project abc123 --dataset production --output-path ~/myproj',\n description: 'Initialize a project with the given project ID and dataset to the given path',\n },\n {\n command:\n '<%= config.bin %> <%= command.id %> -y --project abc123 --dataset staging --template moviedb --output-path .',\n description:\n 'Initialize a project with the given project ID and dataset using the moviedb template to the given path',\n },\n {\n command:\n '<%= config.bin %> <%= command.id %> -y --project-name \"Movies Unlimited\" --dataset moviedb --visibility private --template moviedb --output-path /Users/espenh/movies-unlimited',\n description: 'Create a brand new project with name \"Movies Unlimited\"',\n },\n ] satisfies Array<Command.Example>\n\n static override flags = {\n 'auto-updates': Flags.boolean({\n allowNo: true,\n default: true,\n description: 'Enable auto updates of studio versions',\n exclusive: ['bare'],\n }),\n bare: Flags.boolean({\n description:\n 'Skip the Studio initialization and only print the selected project ID and dataset name to stdout',\n }),\n coupon: Flags.string({\n description:\n 'Optionally select a coupon for a new project (cannot be used with --project-plan)',\n exclusive: ['project-plan'],\n helpValue: '<code>',\n }),\n 'create-project': Flags.string({\n deprecated: {message: 'Use --project-name instead'},\n description: 'Create a new project with the given name',\n helpValue: '<name>',\n hidden: true,\n }),\n dataset: Flags.string({\n description: 'Dataset name for the studio',\n exclusive: ['dataset-default'],\n helpValue: '<name>',\n }),\n 'dataset-default': Flags.boolean({\n description: 'Set up a project with a public dataset named \"production\"',\n }),\n env: Flags.string({\n description: 'Write environment variables to file',\n exclusive: ['bare'],\n helpValue: '<filename>',\n parse: async (input) => {\n if (!input.startsWith('.env')) {\n throw new CLIError('Env filename (`--env`) must start with `.env`')\n }\n return input\n },\n }),\n 'from-create': Flags.boolean({\n description: 'Internal flag to indicate that the command is run from create-sanity',\n hidden: true,\n }),\n git: Flags.string({\n default: undefined,\n description: 'Specify a commit message for initial commit, or disable git init',\n exclusive: ['bare'],\n // oclif doesn't indent correctly with custom help labels, thus leading space :/\n helpLabel: ' --[no-]git',\n helpValue: '<message>',\n }),\n 'import-dataset': Flags.boolean({\n allowNo: true,\n default: undefined,\n description: 'Import template sample dataset',\n }),\n mcp: Flags.boolean({\n allowNo: true,\n default: true,\n description: 'Enable AI editor integration (MCP) setup',\n }),\n 'nextjs-add-config-files': Flags.boolean({\n allowNo: true,\n default: undefined,\n description: 'Add config files to Next.js project',\n helpGroup: 'Next.js',\n }),\n 'nextjs-append-env': Flags.boolean({\n allowNo: true,\n default: undefined,\n description: 'Append project ID and dataset to .env file',\n helpGroup: 'Next.js',\n }),\n 'nextjs-embed-studio': Flags.boolean({\n allowNo: true,\n default: undefined,\n description: 'Embed the Studio in Next.js application',\n helpGroup: 'Next.js',\n }),\n // oclif doesn't support a boolean/string flag combination, but listing both a\n // `--git` and a `--no-git` flag in help breaks conventions, so we hide this one,\n // but use it to \"combine\" the two in the actual logic.\n 'no-git': Flags.boolean({\n description: 'Disable git initialization',\n exclusive: ['git'],\n hidden: true,\n }),\n organization: Flags.string({\n description: 'Organization ID to use for the project',\n helpValue: '<id>',\n }),\n 'output-path': Flags.string({\n description: 'Path to write studio project to',\n exclusive: ['bare'],\n helpValue: '<path>',\n }),\n 'overwrite-files': Flags.boolean({\n allowNo: true,\n default: undefined,\n description: 'Overwrite existing files',\n }),\n 'package-manager': Flags.string({\n description: 'Specify which package manager to use [allowed: npm, yarn, pnpm]',\n exclusive: ['bare'],\n helpValue: '<manager>',\n options: ['npm', 'yarn', 'pnpm'],\n }),\n project: Flags.string({\n aliases: ['project-id'],\n description: 'Project ID to use for the studio',\n exclusive: ['create-project', 'project-name'],\n helpValue: '<id>',\n }),\n 'project-name': Flags.string({\n description: 'Create a new project with the given name',\n exclusive: ['project', 'create-project'],\n helpValue: '<name>',\n }),\n 'project-plan': Flags.string({\n description: 'Optionally select a plan for a new project',\n helpValue: '<name>',\n }),\n provider: Flags.string({\n description: 'Login provider to use',\n helpValue: '<provider>',\n }),\n quickstart: Flags.boolean({\n deprecated: true,\n description:\n 'Used for initializing a project from a server schema that is saved in the Journey API',\n hidden: true,\n }),\n reconfigure: Flags.boolean({\n deprecated: {\n message: 'This flag is no longer supported',\n version: '3.0.0',\n },\n description: 'Reconfigure an existing project',\n hidden: true,\n }),\n template: Flags.string({\n description: 'Project template to use [default: \"clean\"]',\n exclusive: ['bare'],\n helpValue: '<template>',\n }),\n // Porting over a beta flag\n // Oclif doesn't seem to support something in beta so hiding for now\n 'template-token': Flags.string({\n description: 'Used for accessing private GitHub repo templates',\n hidden: true,\n }),\n typescript: Flags.boolean({\n allowNo: true,\n default: undefined,\n description: 'Enable TypeScript support',\n exclusive: ['bare'],\n }),\n visibility: Flags.string({\n description: 'Visibility mode for dataset',\n helpValue: '<mode>',\n options: ['public', 'private'],\n }),\n yes: Flags.boolean({\n char: 'y',\n default: false,\n description:\n 'Unattended mode, answers \"yes\" to any \"yes/no\" prompt and otherwise uses defaults',\n }),\n }\n\n public async run(): Promise<void> {\n let mcpMode: 'auto' | 'prompt' | 'skip' = 'prompt'\n if (!this.flags.mcp || !this.resolveIsInteractive() || getSanityEnv() !== 'production') {\n mcpMode = 'skip'\n } else if (this.flags.yes) {\n mcpMode = 'auto'\n }\n\n try {\n await initAction(flagsToInitOptions(this.flags, this.isUnattended(), this.args, mcpMode), {\n output: this.output,\n telemetry: this.telemetry,\n workDir: process.cwd(),\n })\n } catch (error) {\n if (error instanceof InitError) {\n this.error(error.message, {exit: error.exitCode})\n }\n throw error\n }\n }\n}\n"],"names":["Args","Flags","CLIError","SanityCommand","initAction","InitError","flagsToInitOptions","getSanityEnv","InitCommand","args","type","string","hidden","description","enableJsonFlag","examples","command","flags","boolean","allowNo","default","exclusive","bare","coupon","helpValue","deprecated","message","dataset","env","parse","input","startsWith","git","undefined","helpLabel","mcp","helpGroup","organization","options","project","aliases","provider","quickstart","reconfigure","version","template","typescript","visibility","yes","char","run","mcpMode","resolveIsInteractive","isUnattended","output","telemetry","workDir","process","cwd","error","exit","exitCode"],"mappings":"AAAA,SAAQA,IAAI,EAAWC,KAAK,QAAO,cAAa;AAChD,SAAQC,QAAQ,QAAO,qBAAoB;AAC3C,SAAQC,aAAa,QAAO,mBAAkB;AAE9C,SAAQC,UAAU,QAAO,gCAA+B;AACxD,SAAQC,SAAS,QAAO,+BAA8B;AACtD,SAAQC,kBAAkB,QAAO,2BAA0B;AAC3D,SAAQC,YAAY,QAAO,0BAAyB;AAEpD,OAAO,MAAMC,oBAAoBL;IAC/B,OAAgBM,OAAO;QAACC,MAAMV,KAAKW,MAAM,CAAC;YAACC,QAAQ;QAAI;IAAE,EAAC;IAC1D,OAAgBC,cAAc,qDAAoD;IAClF,OAAgBC,iBAAiB,KAAI;IAErC,OAAgBC,WAAW;QACzB;QACA;YACEC,SAAS;YACTH,aAAa;QACf;QACA;YACEG,SACE;YACFH,aAAa;QACf;QACA;YACEG,SACE;YACFH,aACE;QACJ;QACA;YACEG,SACE;YACFH,aAAa;Q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QACAiC,UAAU5C,MAAMU,MAAM,CAAC;YACrBE,aAAa;YACbQ,WAAW;gBAAC;aAAO;YACnBG,WAAW;QACb;QACA,2BAA2B;QAC3B,oEAAoE;QACpE,kBAAkBvB,MAAMU,MAAM,CAAC;YAC7BE,aAAa;YACbD,QAAQ;QACV;QACAkC,YAAY7C,MAAMiB,OAAO,CAAC;YACxBC,SAAS;YACTC,SAASa;YACTpB,aAAa;YACbQ,WAAW;gBAAC;aAAO;QACrB;QACA0B,YAAY9C,MAAMU,MAAM,CAAC;YACvBE,aAAa;YACbW,WAAW;YACXc,SAAS;gBAAC;gBAAU;aAAU;QAChC;QACAU,KAAK/C,MAAMiB,OAAO,CAAC;YACjB+B,MAAM;YACN7B,SAAS;YACTP,aACE;QACJ;IACF,EAAC;IAED,MAAaqC,MAAqB;QAChC,IAAIC,UAAsC;QAC1C,IAAI,CAAC,IAAI,CAAClC,KAAK,CAACkB,GAAG,IAAI,CAAC,IAAI,CAACiB,oBAAoB,MAAM7C,mBAAmB,cAAc;YACtF4C,UAAU;QACZ,OAAO,IAAI,IAAI,CAAClC,KAAK,CAAC+B,GAAG,EAAE;YACzBG,UAAU;QACZ;QAEA,IAAI;YACF,MAAM/C,WAAWE,mBAAmB,IAAI,CAACW,KAAK,EAAE,IAAI,CAACoC,YAAY,IAAI,IAAI,CAAC5C,IAAI,EAAE0C,UAAU;gBACxFG,QAAQ,IAAI,CAACA,MAAM;gBACnBC,WAAW,IAAI,CAACA,SAAS;gBACzBC,SAASC,QAAQC,GAAG;YACtB;QACF,EAAE,OAAOC,OAAO;YACd,IAAIA,iBAAiBtD,WAAW;gBAC9B,IAAI,CAACsD,KAAK,CAACA,MAAMjC,OAAO,EAAE;oBAACkC,MAAMD,MAAME,QAAQ;gBAAA;YACjD;YACA,MAAMF;QACR;IACF;AACF"}
1
+ {"version":3,"sources":["../../src/commands/init.ts"],"sourcesContent":["import {Args, Command, Flags} from '@oclif/core'\nimport {CLIError} from '@oclif/core/errors'\nimport {SanityCommand} from '@sanity/cli-core'\n\nimport {initAction} from '../actions/init/initAction.js'\nimport {InitError} from '../actions/init/initError.js'\nimport {flagsToInitOptions} from '../actions/init/types.js'\nimport {getSanityEnv} from '../util/getSanityEnv.js'\n\nexport class InitCommand extends SanityCommand<typeof InitCommand> {\n static override args = {type: Args.string({hidden: true})}\n static override description = 'Initialize a new Sanity Studio, project and/or app'\n static override enableJsonFlag = true\n\n static override examples = [\n '<%= config.bin %> <%= command.id %>',\n {\n command: '<%= config.bin %> <%= command.id %> --dataset-default',\n description: 'Initialize a new project with a public dataset named \"production\"',\n },\n {\n command:\n '<%= config.bin %> <%= command.id %> -y --project abc123 --dataset production --output-path ~/myproj',\n description: 'Initialize a project with the given project ID and dataset to the given path',\n },\n {\n command:\n '<%= config.bin %> <%= command.id %> -y --project abc123 --dataset staging --template moviedb --output-path .',\n description:\n 'Initialize a project with the given project ID and dataset using the moviedb template to the given path',\n },\n {\n command:\n '<%= config.bin %> <%= command.id %> -y --project-name \"Movies Unlimited\" --dataset moviedb --visibility private --template moviedb --output-path /Users/espenh/movies-unlimited',\n description: 'Create a brand new project with name \"Movies Unlimited\"',\n },\n ] satisfies Array<Command.Example>\n\n static override flags = {\n 'auto-updates': Flags.boolean({\n allowNo: true,\n default: true,\n description: 'Enable auto updates of studio versions',\n exclusive: ['bare'],\n }),\n bare: Flags.boolean({\n description:\n 'Skip the Studio initialization and only print the selected project ID and dataset name to stdout',\n }),\n coupon: Flags.string({\n description:\n 'Optionally select a coupon for a new project (cannot be used with --project-plan)',\n exclusive: ['project-plan'],\n helpValue: '<code>',\n }),\n 'create-project': Flags.string({\n deprecated: {message: 'Use --project-name instead'},\n description: 'Create a new project with the given name',\n helpValue: '<name>',\n hidden: true,\n }),\n dataset: Flags.string({\n description: 'Dataset name for the studio',\n exclusive: ['dataset-default'],\n helpValue: '<name>',\n }),\n 'dataset-default': Flags.boolean({\n description: 'Set up a project with a public dataset named \"production\"',\n }),\n env: Flags.string({\n description: 'Write environment variables to file',\n exclusive: ['bare'],\n helpValue: '<filename>',\n parse: async (input) => {\n if (!input.startsWith('.env')) {\n throw new CLIError('Env filename (`--env`) must start with `.env`')\n }\n return input\n },\n }),\n 'from-create': Flags.boolean({\n description: 'Internal flag to indicate that the command is run from create-sanity',\n hidden: true,\n }),\n git: Flags.string({\n default: undefined,\n description: 'Specify a commit message for initial commit, or disable git init',\n exclusive: ['bare'],\n // oclif doesn't indent correctly with custom help labels, thus leading space :/\n helpLabel: ' --[no-]git',\n helpValue: '<message>',\n }),\n 'import-dataset': Flags.boolean({\n allowNo: true,\n default: undefined,\n description: 'Import template sample dataset',\n }),\n mcp: Flags.boolean({\n allowNo: true,\n default: true,\n description: 'Enable AI editor integration (MCP) setup',\n }),\n 'nextjs-add-config-files': Flags.boolean({\n allowNo: true,\n default: undefined,\n description: 'Add config files to Next.js project',\n helpGroup: 'Next.js',\n }),\n 'nextjs-append-env': Flags.boolean({\n allowNo: true,\n default: undefined,\n description: 'Append project ID and dataset to .env file',\n helpGroup: 'Next.js',\n }),\n 'nextjs-embed-studio': Flags.boolean({\n allowNo: true,\n default: undefined,\n description: 'Embed the Studio in Next.js application',\n helpGroup: 'Next.js',\n }),\n // oclif doesn't support a boolean/string flag combination, but listing both a\n // `--git` and a `--no-git` flag in help breaks conventions, so we hide this one,\n // but use it to \"combine\" the two in the actual logic.\n 'no-git': Flags.boolean({\n description: 'Disable git initialization',\n exclusive: ['git'],\n hidden: true,\n }),\n organization: Flags.string({\n description: 'Organization ID to use for the project',\n helpValue: '<id>',\n }),\n 'output-path': Flags.string({\n description: 'Path to write studio project to',\n exclusive: ['bare'],\n helpValue: '<path>',\n }),\n 'overwrite-files': Flags.boolean({\n allowNo: true,\n default: undefined,\n description: 'Overwrite existing files',\n }),\n 'package-manager': Flags.string({\n description: 'Specify which package manager to use [allowed: npm, yarn, pnpm]',\n exclusive: ['bare'],\n helpValue: '<manager>',\n options: ['npm', 'yarn', 'pnpm'],\n }),\n project: Flags.string({\n aliases: ['project-id'],\n description: 'Project ID to use for the studio',\n exclusive: ['create-project', 'project-name'],\n helpValue: '<id>',\n }),\n 'project-name': Flags.string({\n description: 'Create a new project with the given name',\n exclusive: ['project', 'create-project'],\n helpValue: '<name>',\n }),\n 'project-plan': Flags.string({\n description: 'Optionally select a plan for a new project',\n helpValue: '<name>',\n }),\n provider: Flags.string({\n description: 'Login provider to use',\n helpValue: '<provider>',\n }),\n quickstart: Flags.boolean({\n deprecated: true,\n description:\n 'Used for initializing a project from a server schema that is saved in the Journey API',\n hidden: true,\n }),\n reconfigure: Flags.boolean({\n deprecated: {\n message: 'This flag is no longer supported',\n version: '3.0.0',\n },\n description: 'Reconfigure an existing project',\n hidden: true,\n }),\n skills: Flags.boolean({\n allowNo: true,\n default: true,\n description: 'Install Sanity agent skills globally for detected AI editors',\n }),\n template: Flags.string({\n description: 'Project template to use [default: \"clean\"]',\n exclusive: ['bare'],\n helpValue: '<template>',\n }),\n // Porting over a beta flag\n // Oclif doesn't seem to support something in beta so hiding for now\n 'template-token': Flags.string({\n description: 'Used for accessing private GitHub repo templates',\n hidden: true,\n }),\n typescript: Flags.boolean({\n allowNo: true,\n default: undefined,\n description: 'Enable TypeScript support',\n exclusive: ['bare'],\n }),\n visibility: Flags.string({\n description: 'Visibility mode for dataset',\n helpValue: '<mode>',\n options: ['public', 'private'],\n }),\n yes: Flags.boolean({\n char: 'y',\n default: false,\n description:\n 'Unattended mode, answers \"yes\" to any \"yes/no\" prompt and otherwise uses defaults',\n }),\n }\n\n public async run(): Promise<void> {\n let mcpMode: 'auto' | 'prompt' | 'skip' = 'prompt'\n if (!this.flags.mcp || !this.resolveIsInteractive() || getSanityEnv() !== 'production') {\n mcpMode = 'skip'\n } else if (this.flags.yes) {\n mcpMode = 'auto'\n }\n\n // Mirror MCP's environment gating: skip skills install in non-production\n // Sanity envs so e2e / UI tests don't run the bundled skills CLI.\n let skillsMode: 'auto' | 'prompt' | 'skip' = 'auto'\n if (!this.flags.skills || !this.resolveIsInteractive() || getSanityEnv() !== 'production') {\n skillsMode = 'skip'\n }\n\n try {\n await initAction(\n flagsToInitOptions(this.flags, this.isUnattended(), this.args, mcpMode, skillsMode),\n {\n output: this.output,\n telemetry: this.telemetry,\n workDir: process.cwd(),\n },\n )\n } catch (error) {\n if (error instanceof InitError) {\n this.error(error.message, {exit: error.exitCode})\n }\n throw error\n }\n }\n}\n"],"names":["Args","Flags","CLIError","SanityCommand","initAction","InitError","flagsToInitOptions","getSanityEnv","InitCommand","args","type","string","hidden","description","enableJsonFlag","examples","command","flags","boolean","allowNo","default","exclusive","bare","coupon","helpValue","deprecated","message","dataset","env","parse","input","startsWith","git","undefined","helpLabel","mcp","helpGroup","organization","options","project","aliases","provider","quickstart","reconfigure","version","skills","template","typescript","visibility","yes","char","run","mcpMode","resolveIsInteractive","skillsMode","isUnattended","output","telemetry","workDir","process","cwd","error","exit","exitCode"],"mappings":"AAAA,SAAQA,IAAI,EAAWC,KAAK,QAAO,cAAa;AAChD,SAAQC,QAAQ,QAAO,qBAAoB;AAC3C,SAAQC,aAAa,QAAO,mBAAkB;AAE9C,SAAQC,UAAU,QAAO,gCAA+B;AACxD,SAAQC,SAAS,QAAO,+BAA8B;AACtD,SAAQC,kBAAkB,QAAO,2BAA0B;AAC3D,SAAQC,YAAY,QAAO,0BAAyB;AAEpD,OAAO,MAAMC,oBAAoBL;IAC/B,OAAgBM,OAAO;QAACC,MAAMV,KAAKW,MAAM,CAAC;YAACC,QAAQ;QAAI;IAAE,EAAC;IAC1D,OAAgBC,cAAc,qDAAoD;IAClF,OAAgBC,iBAAiB,KAAI;IAErC,OAAgBC,WAAW;QACzB;QACA;YACEC,SAAS;YACTH,aAAa;QACf;QACA;YACEG,SACE;YACFH,aAAa;QACf;QACA;YACEG,SACE;YACFH,aACE;QACJ;QACA;YACEG,SACE;YACFH,aAAa;QACf;KACD,CAAiC;IAElC,OAAgBI,QAAQ;QACtB,gBAAgBhB,MAAMiB,OAAO,CAAC;YAC5BC,SA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E;oBAACoC,MAAMD,MAAME,QAAQ;gBAAA;YACjD;YACA,MAAMF;QACR;IACF;AACF"}
@@ -1,9 +1,8 @@
1
1
  import { Flags } from '@oclif/core';
2
+ import { formatSchemaValidation, SchemaExtractionError } from '@sanity/cli-build/_internal/extract';
2
3
  import { SanityCommand } from '@sanity/cli-core';
3
4
  import { manifestDebug } from '../../actions/manifest/debug.js';
4
5
  import { extractManifest } from '../../actions/manifest/extractManifest.js';
5
- import { formatSchemaValidation } from '../../actions/schema/formatSchemaValidation.js';
6
- import { SchemaExtractionError } from '../../actions/schema/utils/SchemaExtractionError.js';
7
6
  const description = `
8
7
  Extract studio configuration as JSON manifest files.
9
8
 
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/commands/manifest/extract.ts"],"sourcesContent":["import {Flags} from '@oclif/core'\nimport {SanityCommand} from '@sanity/cli-core'\n\nimport {manifestDebug} from '../../actions/manifest/debug.js'\nimport {extractManifest} from '../../actions/manifest/extractManifest.js'\nimport {formatSchemaValidation} from '../../actions/schema/formatSchemaValidation.js'\nimport {SchemaExtractionError} from '../../actions/schema/utils/SchemaExtractionError.js'\n\nconst description = `\nExtract studio configuration as JSON manifest files.\n\nNote: This command is experimental and subject to change. It is currently intended for use with Create only.\n`.trim()\n\nexport class ExtractManifestCommand extends SanityCommand<typeof ExtractManifestCommand> {\n static override description = description\n\n static override examples = [\n {\n command: '<%= config.bin %> <%= command.id %>',\n description: 'Extracts manifests',\n },\n {\n command: '<%= config.bin %> <%= command.id %> --path /public/static',\n description: 'Extracts manifests into /public/static',\n },\n ]\n\n static override flags = {\n path: Flags.string({\n default: 'dist/static',\n description: 'Optional path to specify destination directory of the manifest files',\n }),\n }\n\n public async run(): Promise<void> {\n const {flags} = await this.parse(ExtractManifestCommand)\n\n try {\n await extractManifest(flags.path)\n } catch (error) {\n manifestDebug('Error extracting manifest in command', error)\n if (\n error instanceof SchemaExtractionError &&\n error.validation &&\n error.validation.length > 0\n ) {\n this.output.log(formatSchemaValidation(error.validation))\n this.exit(1)\n }\n\n this.error(\n `Failed to extract manifest:\\n${error instanceof Error ? error.message : String(error)}`,\n {exit: 1},\n )\n }\n }\n}\n"],"names":["Flags","SanityCommand","manifestDebug","extractManifest","formatSchemaValidation","SchemaExtractionError","description","trim","ExtractManifestCommand","examples","command","flags","path","string","default","run","parse","error","validation","length","output","log","exit","Error","message","String"],"mappings":"AAAA,SAAQA,KAAK,QAAO,cAAa;AACjC,SAAQC,aAAa,QAAO,mBAAkB;AAE9C,SAAQC,aAAa,QAAO,kCAAiC;AAC7D,SAAQC,eAAe,QAAO,4CAA2C;AACzE,SAAQC,sBAAsB,QAAO,iDAAgD;AACrF,SAAQC,qBAAqB,QAAO,sDAAqD;AAEzF,MAAMC,cAAc,CAAC;;;;AAIrB,CAAC,CAACC,IAAI;AAEN,OAAO,MAAMC,+BAA+BP;IAC1C,OAAgBK,cAAcA,YAAW;IAEzC,OAAgBG,WAAW;QACzB;YACEC,SAAS;YACTJ,aAAa;QACf;QACA;YACEI,SAAS;YACTJ,aAAa;QACf;KACD,CAAA;IAED,OAAgBK,QAAQ;QACtBC,MAAMZ,MAAMa,MAAM,CAAC;YACjBC,SAAS;YACTR,aAAa;QACf;IACF,EAAC;IAED,MAAaS,MAAqB;QAChC,MAAM,EAACJ,KAAK,EAAC,GAAG,MAAM,IAAI,CAACK,KAAK,CAACR;QAEjC,IAAI;YACF,MAAML,gBAAgBQ,MAAMC,IAAI;QAClC,EAAE,OAAOK,OAAO;YACdf,cAAc,wCAAwCe;YACtD,IACEA,iBAAiBZ,yBACjBY,MAAMC,UAAU,IAChBD,MAAMC,UAAU,CAACC,MAAM,GAAG,GAC1B;gBACA,IAAI,CAACC,MAAM,CAACC,GAAG,CAACjB,uBAAuBa,MAAMC,UAAU;gBACvD,IAAI,CAACI,IAAI,CAAC;YACZ;YAEA,IAAI,CAACL,KAAK,CACR,CAAC,6BAA6B,EAAEA,iBAAiBM,QAAQN,MAAMO,OAAO,GAAGC,OAAOR,QAAQ,EACxF;gBAACK,MAAM;YAAC;QAEZ;IACF;AACF"}
1
+ {"version":3,"sources":["../../../src/commands/manifest/extract.ts"],"sourcesContent":["import {Flags} from '@oclif/core'\nimport {formatSchemaValidation, SchemaExtractionError} from '@sanity/cli-build/_internal/extract'\nimport {SanityCommand} from '@sanity/cli-core'\n\nimport {manifestDebug} from '../../actions/manifest/debug.js'\nimport {extractManifest} from '../../actions/manifest/extractManifest.js'\n\nconst description = `\nExtract studio configuration as JSON manifest files.\n\nNote: This command is experimental and subject to change. It is currently intended for use with Create only.\n`.trim()\n\nexport class ExtractManifestCommand extends SanityCommand<typeof ExtractManifestCommand> {\n static override description = description\n\n static override examples = [\n {\n command: '<%= config.bin %> <%= command.id %>',\n description: 'Extracts manifests',\n },\n {\n command: '<%= config.bin %> <%= command.id %> --path /public/static',\n description: 'Extracts manifests into /public/static',\n },\n ]\n\n static override flags = {\n path: Flags.string({\n default: 'dist/static',\n description: 'Optional path to specify destination directory of the manifest files',\n }),\n }\n\n public async run(): Promise<void> {\n const {flags} = await this.parse(ExtractManifestCommand)\n\n try {\n await extractManifest(flags.path)\n } catch (error) {\n manifestDebug('Error extracting manifest in command', error)\n if (\n error instanceof SchemaExtractionError &&\n error.validation &&\n error.validation.length > 0\n ) {\n this.output.log(formatSchemaValidation(error.validation))\n this.exit(1)\n }\n\n this.error(\n `Failed to extract manifest:\\n${error instanceof Error ? error.message : String(error)}`,\n {exit: 1},\n )\n }\n }\n}\n"],"names":["Flags","formatSchemaValidation","SchemaExtractionError","SanityCommand","manifestDebug","extractManifest","description","trim","ExtractManifestCommand","examples","command","flags","path","string","default","run","parse","error","validation","length","output","log","exit","Error","message","String"],"mappings":"AAAA,SAAQA,KAAK,QAAO,cAAa;AACjC,SAAQC,sBAAsB,EAAEC,qBAAqB,QAAO,sCAAqC;AACjG,SAAQC,aAAa,QAAO,mBAAkB;AAE9C,SAAQC,aAAa,QAAO,kCAAiC;AAC7D,SAAQC,eAAe,QAAO,4CAA2C;AAEzE,MAAMC,cAAc,CAAC;;;;AAIrB,CAAC,CAACC,IAAI;AAEN,OAAO,MAAMC,+BAA+BL;IAC1C,OAAgBG,cAAcA,YAAW;IAEzC,OAAgBG,WAAW;QACzB;YACEC,SAAS;YACTJ,aAAa;QACf;QACA;YACEI,SAAS;YACTJ,aAAa;QACf;KACD,CAAA;IAED,OAAgBK,QAAQ;QACtBC,MAAMZ,MAAMa,MAAM,CAAC;YACjBC,SAAS;YACTR,aAAa;QACf;IACF,EAAC;IAED,MAAaS,MAAqB;QAChC,MAAM,EAACJ,KAAK,EAAC,GAAG,MAAM,IAAI,CAACK,KAAK,CAACR;QAEjC,IAAI;YACF,MAAMH,gBAAgBM,MAAMC,IAAI;QAClC,EAAE,OAAOK,OAAO;YACdb,cAAc,wCAAwCa;YACtD,IACEA,iBAAiBf,yBACjBe,MAAMC,UAAU,IAChBD,MAAMC,UAAU,CAACC,MAAM,GAAG,GAC1B;gBACA,IAAI,CAACC,MAAM,CAACC,GAAG,CAACpB,uBAAuBgB,MAAMC,UAAU;gBACvD,IAAI,CAACI,IAAI,CAAC;YACZ;YAEA,IAAI,CAACL,KAAK,CACR,CAAC,6BAA6B,EAAEA,iBAAiBM,QAAQN,MAAMO,OAAO,GAAGC,OAAOR,QAAQ,EACxF;gBAACK,MAAM;YAAC;QAEZ;IACF;AACF"}
@@ -36,7 +36,8 @@ export class ConfigureMcpCommand extends SanityCommand {
36
36
  try {
37
37
  const mcpResult = await setupMCP({
38
38
  explicit: true,
39
- mode: isInteractive() ? 'prompt' : 'auto'
39
+ mode: isInteractive() ? 'prompt' : 'auto',
40
+ skillsMode: 'skip'
40
41
  });
41
42
  trace.log({
42
43
  configuredEditors: mcpResult.configuredEditors,
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/commands/mcp/configure.ts"],"sourcesContent":["import {isInteractive, SanityCommand, subdebug} from '@sanity/cli-core'\n\nimport {ensureAuthenticated} from '../../actions/auth/ensureAuthenticated.js'\nimport {setupMCP} from '../../actions/mcp/setupMCP.js'\nimport {LoginError} from '../../errors/LoginError.js'\nimport {MCPConfigureTrace} from '../../telemetry/mcp.telemetry.js'\nimport {getErrorMessage, toError} from '../../util/getErrorMessage.js'\n\nconst debug = subdebug('mcp:configure')\n\nexport class ConfigureMcpCommand extends SanityCommand<typeof ConfigureMcpCommand> {\n static override description =\n 'Configure Sanity MCP server for AI editors (Antigravity, Claude Code, Cline, Cline CLI, Codex CLI, Cursor, Gemini CLI, GitHub Copilot CLI, MCPorter, OpenCode, VS Code, VS Code Insiders, Zed)'\n\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 await ensureAuthenticated({output: this.output, telemetry: this.telemetry})\n } catch (error) {\n debug('Authentication check failed: %O', error)\n trace.error(toError(error))\n\n if (error instanceof LoginError) {\n this.error(\n `Failed to verify authentication credentials: ${error.message}. Try running \\`sanity login\\`.`,\n {exit: 1},\n )\n }\n\n this.error(`Failed to check authentication: ${getErrorMessage(error)}`, {exit: 1})\n }\n\n try {\n const mcpResult = await setupMCP({explicit: true, mode: isInteractive() ? 'prompt' : 'auto'})\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: 1})\n }\n }\n}\n"],"names":["isInteractive","SanityCommand","subdebug","ensureAuthenticated","setupMCP","LoginError","MCPConfigureTrace","getErrorMessage","toError","debug","ConfigureMcpCommand","description","examples","command","run","trace","telemetry","start","output","error","message","exit","mcpResult","explicit","mode","log","configuredEditors","detectedEditors","complete"],"mappings":"AAAA,SAAQA,aAAa,EAAEC,aAAa,EAAEC,QAAQ,QAAO,mBAAkB;AAEvE,SAAQC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AQW;YACpB,IAAI,CAACA,KAAK,CAACZ,gBAAgBY,QAAQ;gBAACE,MAAM;YAAC;QAC7C;IACF;AACF"}
1
+ {"version":3,"sources":["../../../src/commands/mcp/configure.ts"],"sourcesContent":["import {isInteractive, SanityCommand, subdebug} from '@sanity/cli-core'\n\nimport {ensureAuthenticated} from '../../actions/auth/ensureAuthenticated.js'\nimport {setupMCP} from '../../actions/mcp/setupMCP.js'\nimport {LoginError} from '../../errors/LoginError.js'\nimport {MCPConfigureTrace} from '../../telemetry/mcp.telemetry.js'\nimport {getErrorMessage, toError} from '../../util/getErrorMessage.js'\n\nconst debug = subdebug('mcp:configure')\n\nexport class ConfigureMcpCommand extends SanityCommand<typeof ConfigureMcpCommand> {\n static override description =\n 'Configure Sanity MCP server for AI editors (Antigravity, Claude Code, Cline, Cline CLI, Codex CLI, Cursor, Gemini CLI, GitHub Copilot CLI, MCPorter, OpenCode, VS Code, VS Code Insiders, Zed)'\n\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 await ensureAuthenticated({output: this.output, telemetry: this.telemetry})\n } catch (error) {\n debug('Authentication check failed: %O', error)\n trace.error(toError(error))\n\n if (error instanceof LoginError) {\n this.error(\n `Failed to verify authentication credentials: ${error.message}. Try running \\`sanity login\\`.`,\n {exit: 1},\n )\n }\n\n this.error(`Failed to check authentication: ${getErrorMessage(error)}`, {exit: 1})\n }\n\n try {\n const mcpResult = await setupMCP({\n explicit: true,\n mode: isInteractive() ? 'prompt' : 'auto',\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: 1})\n }\n }\n}\n"],"names":["isInteractive","SanityCommand","subdebug","ensureAuthenticated","setupMCP","LoginError","MCPConfigureTrace","getErrorMessage","toError","debug","ConfigureMcpCommand","description","examples","command","run","trace","telemetry","start","output","error","message","exit","mcpResult","explicit","mode","skillsMode","log","configuredEditors","detectedEditors","complete"],"mappings":"AAAA,SAAQA,aAAa,EAAEC,aAAa,EAAEC,QAAQ,QAAO,mBAAkB;AAEvE,SAAQC,mBAAmB,QAAO,4CAA2C;AAC7E,SAAQC,QAAQ,QAAO,gCAA+B;AACtD,SAAQC,UAAU,QAAO,6BAA4B;AACrD,SAAQC,iBAAiB,QAAO,mCAAkC;AAClE,SAAQC,eAAe,EAAEC,OAAO,QAAO,gCAA+B;AAEtE,MAAMC,QAAQP,SAAS;AAEvB,OAAO,MAAMQ,4BAA4BT;IACvC,OAAgBU,cACd,iMAAgM;IAElM,OAAgBC,WAAW;QACzB;YACEC,SAAS;YACTF,aAAa;QACf;KACD,CAAA;IAED,MAAaG,MAAqB;QAChC,MAAMC,QAAQ,IAAI,CAACC,SAAS,CAACD,KAAK,CAACT;QACnCS,MAAME,KAAK;QAEX,IAAI;YACF,MAAMd,oBAAoB;gBAACe,QAAQ,IAAI,CAACA,MAAM;gBAAEF,WAAW,IAAI,CAACA,SAAS;YAAA;QAC3E,EAAE,OAAOG,OAAO;YACdV,MAAM,mCAAmCU;YACzCJ,MAAMI,KAAK,CAACX,QAAQW;YAEpB,IAAIA,iBAAiBd,YAAY;gBAC/B,IAAI,CAACc,KAAK,CACR,CAAC,6CAA6C,EAAEA,MAAMC,OAAO,CAAC,+BAA+B,CAAC,EAC9F;oBAACC,MAAM;gBAAC;YAEZ;YAEA,IAAI,CAACF,KAAK,CAAC,CAAC,gCAAgC,EAAEZ,gBAAgBY,QAAQ,EAAE;gBAACE,MAAM;YAAC;QAClF;QAEA,IAAI;YACF,MAAMC,YAAY,MAAMlB,SAAS;gBAC/BmB,UAAU;gBACVC,MAAMxB,kBAAkB,WAAW;gBACnCyB,YAAY;YACd;YAEAV,MAAMW,GAAG,CAAC;gBACRC,mBAAmBL,UAAUK,iBAAiB;gBAC9CC,iBAAiBN,UAAUM,eAAe;YAC5C;YAEA,IAAIN,UAAUH,KAAK,EAAE;gBACnBJ,MAAMI,KAAK,CAACG,UAAUH,KAAK;YAC7B,OAAO;gBACLJ,MAAMc,QAAQ;YAChB;QACF,EAAE,OAAOV,OAAO;YACdJ,MAAMI,KAAK,CAACX,QAAQW;YACpB,IAAI,CAACA,KAAK,CAACZ,gBAAgBY,QAAQ;gBAACE,MAAM;YAAC;QAC7C;IACF;AACF"}
@@ -1,11 +1,10 @@
1
1
  import { styleText } from 'node:util';
2
2
  import { Flags } from '@oclif/core';
3
3
  import { CLIError } from '@oclif/core/errors';
4
+ import { formatSchemaValidation, SchemaExtractionError } from '@sanity/cli-build/_internal/extract';
4
5
  import { SanityCommand } from '@sanity/cli-core';
5
6
  import { deploySchemas } from '../../actions/schema/deploySchemas.js';
6
- import { formatSchemaValidation } from '../../actions/schema/formatSchemaValidation.js';
7
7
  import { schemasDeployDebug } from '../../actions/schema/utils/debug.js';
8
- import { SchemaExtractionError } from '../../actions/schema/utils/SchemaExtractionError.js';
9
8
  import { parseTag } from '../../actions/schema/utils/schemaStoreValidation.js';
10
9
  const description = `
11
10
  Deploy schema documents into workspace datasets.
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/commands/schemas/deploy.ts"],"sourcesContent":["import {styleText} from 'node:util'\n\nimport {Flags} from '@oclif/core'\nimport {CLIError} from '@oclif/core/errors'\nimport {SanityCommand} from '@sanity/cli-core'\n\nimport {deploySchemas} from '../../actions/schema/deploySchemas.js'\nimport {formatSchemaValidation} from '../../actions/schema/formatSchemaValidation.js'\nimport {schemasDeployDebug} from '../../actions/schema/utils/debug.js'\nimport {SchemaExtractionError} from '../../actions/schema/utils/SchemaExtractionError.js'\nimport {parseTag} from '../../actions/schema/utils/schemaStoreValidation.js'\n\nconst description = `\nDeploy schema documents into workspace datasets.\n\nNote: This command is experimental and subject to change.\n\nRegenerates a manifest file by default. To re-use an existing manifest, use --no-extract-manifest.\n`.trim()\n\nexport class DeploySchemaCommand extends SanityCommand<typeof DeploySchemaCommand> {\n static override description = description\n\n static override examples = [\n {\n command: '<%= config.bin %> <%= command.id %>',\n description: 'Deploy all workspace schemas',\n },\n {\n command: '<%= config.bin %> <%= command.id %> --workspace default',\n description: 'Deploy the schema for only the workspace \"default\"',\n },\n ]\n\n static override flags = {\n 'extract-manifest': Flags.boolean({\n allowNo: true,\n default: true,\n description: 'Regenerate manifest before deploying (use --no-extract-manifest to skip)',\n }),\n 'manifest-dir': Flags.directory({\n default: './dist/static',\n description: 'Directory containing manifest file',\n helpValue: '<directory>',\n }),\n tag: Flags.string({\n description: 'Add a tag suffix to the schema id',\n helpValue: '<tag>',\n parse: parseTag,\n }),\n verbose: Flags.boolean({\n default: false,\n description: 'Print detailed information during deployment',\n }),\n workspace: Flags.string({\n description: 'The name of the workspace to deploy a schema for',\n helpValue: '<name>',\n parse: async (input) => {\n if (!input) throw new CLIError('workspace argument cannot be empty if specified', {exit: 1})\n return input\n },\n }),\n }\n\n static override hiddenAliases: string[] = ['schema:deploy']\n\n public async run(): Promise<void> {\n const {flags} = await this.parse(DeploySchemaCommand)\n const {tag, workspace} = flags\n\n try {\n const workDir = (await this.getProjectRoot()).directory\n\n await deploySchemas({\n tag,\n verbose: flags['verbose'],\n workDir,\n workspaceName: workspace,\n })\n\n this.log(\n `${styleText('gray', '↳ List deployed schemas with:')} ${styleText('cyan', 'sanity schema list')}`,\n )\n } catch (error) {\n if (\n error instanceof SchemaExtractionError &&\n error.validation &&\n error.validation.length > 0\n ) {\n this.output.log(formatSchemaValidation(error.validation))\n this.exit(1)\n }\n\n schemasDeployDebug('Failed to deploy schemas', error)\n const errorMessage = error instanceof Error ? error.message : String(error)\n this.error(`Failed to deploy schemas:\\n${errorMessage}`, {exit: 1})\n }\n }\n}\n"],"names":["styleText","Flags","CLIError","SanityCommand","deploySchemas","formatSchemaValidation","schemasDeployDebug","SchemaExtractionError","parseTag","description","trim","DeploySchemaCommand","examples","command","flags","boolean","allowNo","default","directory","helpValue","tag","string","parse","verbose","workspace","input","exit","hiddenAliases","run","workDir","getProjectRoot","workspaceName","log","error","validation","length","output","errorMessage","Error","message","String"],"mappings":"AAAA,SAAQA,SAAS,QAAO,YAAW;AAEnC,SAAQC,KAAK,QAAO,cAAa;AACjC,SAAQC,QAAQ,QAAO,qBAAoB;AAC3C,SAAQC,aAAa,QAAO,mBAAkB;AAE9C,SAAQC,aAAa,QAAO,wCAAuC;AACnE,SAAQC,sBAAsB,QAAO,iDAAgD;AACrF,SAAQC,kBAAkB,QAAO,sCAAqC;AACtE,SAAQC,qBAAqB,QAAO,sDAAqD;AACzF,SAAQC,QAAQ,QAAO,sDAAqD;AAE5E,MAAMC,cAAc,CAAC;;;;;;AAMrB,CAAC,CAACC,IAAI;AAEN,OAAO,MAAMC,4BAA4BR;IACvC,OAAgBM,cAAcA,YAAW;IAEzC,OAAgBG,WAAW;QACzB;YACEC,SAAS;YACTJ,aAAa;QACf;QACA;YACEI,SAAS;YACTJ,aAAa;QACf;KACD,CAAA;IAED,OAAgBK,QAAQ;QACtB,oBAAoBb,MAAMc,OAAO,CAAC;YAChCC,SAAS;YACTC,SAAS;YACTR,aAAa;QACf;QACA,gBAAgBR,MAAMiB,SAAS,CAAC;YAC9BD,SAAS;YACTR,aAAa;YACbU,WAAW;QACb;QACAC,KAAKnB,MAAMoB,MAAM,CAAC;YAChBZ,aAAa;YACbU,WAAW;YACXG,OAAOd;QACT;QACAe,SAAStB,MAAMc,OAAO,CAAC;YACrBE,SAAS;YACTR,aAAa;QACf;QACAe,WAAWvB,MAAMoB,MAAM,CAAC;YACtBZ,aAAa;YACbU,WAAW;YACXG,OAAO,OAAOG;gBACZ,IAAI,CAACA,OAAO,MAAM,IAAIvB,SAAS,mDAAmD;oBAACwB,MAAM;gBAAC;gBAC1F,OAAOD;YACT;QACF;IACF,EAAC;IAED,OAAgBE,gBAA0B;QAAC;KAAgB,CAAA;IAE3D,MAAaC,MAAqB;QAChC,MAAM,EAACd,KAAK,EAAC,GAAG,MAAM,IAAI,CAACQ,KAAK,CAACX;QACjC,MAAM,EAACS,GAAG,EAAEI,SAAS,EAAC,GAAGV;QAEzB,IAAI;YACF,MAAMe,UAAU,AAAC,CAAA,MAAM,IAAI,CAACC,cAAc,EAAC,EAAGZ,SAAS;YAEvD,MAAMd,cAAc;gBAClBgB;gBACAG,SAAST,KAAK,CAAC,UAAU;gBACzBe;gBACAE,eAAeP;YACjB;YAEA,IAAI,CAACQ,GAAG,CACN,GAAGhC,UAAU,QAAQ,iCAAiC,CAAC,EAAEA,UAAU,QAAQ,uBAAuB;QAEtG,EAAE,OAAOiC,OAAO;YACd,IACEA,iBAAiB1B,yBACjB0B,MAAMC,UAAU,IAChBD,MAAMC,UAAU,CAACC,MAAM,GAAG,GAC1B;gBACA,IAAI,CAACC,MAAM,CAACJ,GAAG,CAAC3B,uBAAuB4B,MAAMC,UAAU;gBACvD,IAAI,CAACR,IAAI,CAAC;YACZ;YAEApB,mBAAmB,4BAA4B2B;YAC/C,MAAMI,eAAeJ,iBAAiBK,QAAQL,MAAMM,OAAO,GAAGC,OAAOP;YACrE,IAAI,CAACA,KAAK,CAAC,CAAC,2BAA2B,EAAEI,cAAc,EAAE;gBAACX,MAAM;YAAC;QACnE;IACF;AACF"}
1
+ {"version":3,"sources":["../../../src/commands/schemas/deploy.ts"],"sourcesContent":["import {styleText} from 'node:util'\n\nimport {Flags} from '@oclif/core'\nimport {CLIError} from '@oclif/core/errors'\nimport {formatSchemaValidation, SchemaExtractionError} from '@sanity/cli-build/_internal/extract'\nimport {SanityCommand} from '@sanity/cli-core'\n\nimport {deploySchemas} from '../../actions/schema/deploySchemas.js'\nimport {schemasDeployDebug} from '../../actions/schema/utils/debug.js'\nimport {parseTag} from '../../actions/schema/utils/schemaStoreValidation.js'\n\nconst description = `\nDeploy schema documents into workspace datasets.\n\nNote: This command is experimental and subject to change.\n\nRegenerates a manifest file by default. To re-use an existing manifest, use --no-extract-manifest.\n`.trim()\n\nexport class DeploySchemaCommand extends SanityCommand<typeof DeploySchemaCommand> {\n static override description = description\n\n static override examples = [\n {\n command: '<%= config.bin %> <%= command.id %>',\n description: 'Deploy all workspace schemas',\n },\n {\n command: '<%= config.bin %> <%= command.id %> --workspace default',\n description: 'Deploy the schema for only the workspace \"default\"',\n },\n ]\n\n static override flags = {\n 'extract-manifest': Flags.boolean({\n allowNo: true,\n default: true,\n description: 'Regenerate manifest before deploying (use --no-extract-manifest to skip)',\n }),\n 'manifest-dir': Flags.directory({\n default: './dist/static',\n description: 'Directory containing manifest file',\n helpValue: '<directory>',\n }),\n tag: Flags.string({\n description: 'Add a tag suffix to the schema id',\n helpValue: '<tag>',\n parse: parseTag,\n }),\n verbose: Flags.boolean({\n default: false,\n description: 'Print detailed information during deployment',\n }),\n workspace: Flags.string({\n description: 'The name of the workspace to deploy a schema for',\n helpValue: '<name>',\n parse: async (input) => {\n if (!input) throw new CLIError('workspace argument cannot be empty if specified', {exit: 1})\n return input\n },\n }),\n }\n\n static override hiddenAliases: string[] = ['schema:deploy']\n\n public async run(): Promise<void> {\n const {flags} = await this.parse(DeploySchemaCommand)\n const {tag, workspace} = flags\n\n try {\n const workDir = (await this.getProjectRoot()).directory\n\n await deploySchemas({\n tag,\n verbose: flags['verbose'],\n workDir,\n workspaceName: workspace,\n })\n\n this.log(\n `${styleText('gray', '↳ List deployed schemas with:')} ${styleText('cyan', 'sanity schema list')}`,\n )\n } catch (error) {\n if (\n error instanceof SchemaExtractionError &&\n error.validation &&\n error.validation.length > 0\n ) {\n this.output.log(formatSchemaValidation(error.validation))\n this.exit(1)\n }\n\n schemasDeployDebug('Failed to deploy schemas', error)\n const errorMessage = error instanceof Error ? error.message : String(error)\n this.error(`Failed to deploy schemas:\\n${errorMessage}`, {exit: 1})\n }\n }\n}\n"],"names":["styleText","Flags","CLIError","formatSchemaValidation","SchemaExtractionError","SanityCommand","deploySchemas","schemasDeployDebug","parseTag","description","trim","DeploySchemaCommand","examples","command","flags","boolean","allowNo","default","directory","helpValue","tag","string","parse","verbose","workspace","input","exit","hiddenAliases","run","workDir","getProjectRoot","workspaceName","log","error","validation","length","output","errorMessage","Error","message","String"],"mappings":"AAAA,SAAQA,SAAS,QAAO,YAAW;AAEnC,SAAQC,KAAK,QAAO,cAAa;AACjC,SAAQC,QAAQ,QAAO,qBAAoB;AAC3C,SAAQC,sBAAsB,EAAEC,qBAAqB,QAAO,sCAAqC;AACjG,SAAQC,aAAa,QAAO,mBAAkB;AAE9C,SAAQC,aAAa,QAAO,wCAAuC;AACnE,SAAQC,kBAAkB,QAAO,sCAAqC;AACtE,SAAQC,QAAQ,QAAO,sDAAqD;AAE5E,MAAMC,cAAc,CAAC;;;;;;AAMrB,CAAC,CAACC,IAAI;AAEN,OAAO,MAAMC,4BAA4BN;IACvC,OAAgBI,cAAcA,YAAW;IAEzC,OAAgBG,WAAW;QACzB;YACEC,SAAS;YACTJ,aAAa;QACf;QACA;YACEI,SAAS;YACTJ,aAAa;QACf;KACD,CAAA;IAED,OAAgBK,QAAQ;QACtB,oBAAoBb,MAAMc,OAAO,CAAC;YAChCC,SAAS;YACTC,SAAS;YACTR,aAAa;QACf;QACA,gBAAgBR,MAAMiB,SAAS,CAAC;YAC9BD,SAAS;YACTR,aAAa;YACbU,WAAW;QACb;QACAC,KAAKnB,MAAMoB,MAAM,CAAC;YAChBZ,aAAa;YACbU,WAAW;YACXG,OAAOd;QACT;QACAe,SAAStB,MAAMc,OAAO,CAAC;YACrBE,SAAS;YACTR,aAAa;QACf;QACAe,WAAWvB,MAAMoB,MAAM,CAAC;YACtBZ,aAAa;YACbU,WAAW;YACXG,OAAO,OAAOG;gBACZ,IAAI,CAACA,OAAO,MAAM,IAAIvB,SAAS,mDAAmD;oBAACwB,MAAM;gBAAC;gBAC1F,OAAOD;YACT;QACF;IACF,EAAC;IAED,OAAgBE,gBAA0B;QAAC;KAAgB,CAAA;IAE3D,MAAaC,MAAqB;QAChC,MAAM,EAACd,KAAK,EAAC,GAAG,MAAM,IAAI,CAACQ,KAAK,CAACX;QACjC,MAAM,EAACS,GAAG,EAAEI,SAAS,EAAC,GAAGV;QAEzB,IAAI;YACF,MAAMe,UAAU,AAAC,CAAA,MAAM,IAAI,CAACC,cAAc,EAAC,EAAGZ,SAAS;YAEvD,MAAMZ,cAAc;gBAClBc;gBACAG,SAAST,KAAK,CAAC,UAAU;gBACzBe;gBACAE,eAAeP;YACjB;YAEA,IAAI,CAACQ,GAAG,CACN,GAAGhC,UAAU,QAAQ,iCAAiC,CAAC,EAAEA,UAAU,QAAQ,uBAAuB;QAEtG,EAAE,OAAOiC,OAAO;YACd,IACEA,iBAAiB7B,yBACjB6B,MAAMC,UAAU,IAChBD,MAAMC,UAAU,CAACC,MAAM,GAAG,GAC1B;gBACA,IAAI,CAACC,MAAM,CAACJ,GAAG,CAAC7B,uBAAuB8B,MAAMC,UAAU;gBACvD,IAAI,CAACR,IAAI,CAAC;YACZ;YAEAnB,mBAAmB,4BAA4B0B;YAC/C,MAAMI,eAAeJ,iBAAiBK,QAAQL,MAAMM,OAAO,GAAGC,OAAOP;YACrE,IAAI,CAACA,KAAK,CAAC,CAAC,2BAA2B,EAAEI,cAAc,EAAE;gBAACX,MAAM;YAAC;QACnE;IACF;AACF"}
@@ -100,7 +100,8 @@ declare type ManifestValidationRule = {
100
100
  };
101
101
 
102
102
  /**
103
- * The params for the `getStudioEnvironmentVariables` function that gets Studio focused environment variables.
103
+ * The params for the `getStudioEnvironmentVariables` and `getAppEnvironmentVariables` function
104
+ * that gets Studio/App-focused environment variables.
104
105
  *
105
106
  * @public
106
107
  */
@@ -1,4 +1,4 @@
1
- export { getStudioEnvironmentVariables } from '../actions/build/getStudioEnvironmentVariables.js';
1
+ export { getStudioEnvironmentVariables } from '../actions/build/getEnvironmentVariables.js';
2
2
  export { extractManifestSchemaTypes } from '../actions/manifest/extractWorkspaceManifest.js';
3
3
 
4
4
  //# sourceMappingURL=_internal.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/exports/_internal.ts"],"sourcesContent":["export {getStudioEnvironmentVariables} from '../actions/build/getStudioEnvironmentVariables.js'\nexport type {StudioEnvVariablesOptions} from '../actions/build/getStudioEnvironmentVariables.js'\nexport {extractManifestSchemaTypes} from '../actions/manifest/extractWorkspaceManifest.js'\n"],"names":["getStudioEnvironmentVariables","extractManifestSchemaTypes"],"mappings":"AAAA,SAAQA,6BAA6B,QAAO,oDAAmD;AAE/F,SAAQC,0BAA0B,QAAO,kDAAiD"}
1
+ {"version":3,"sources":["../../src/exports/_internal.ts"],"sourcesContent":["export {getStudioEnvironmentVariables} from '../actions/build/getEnvironmentVariables.js'\nexport type {StudioEnvVariablesOptions} from '../actions/build/getEnvironmentVariables.js'\nexport {extractManifestSchemaTypes} from '../actions/manifest/extractWorkspaceManifest.js'\n"],"names":["getStudioEnvironmentVariables","extractManifestSchemaTypes"],"mappings":"AAAA,SAAQA,6BAA6B,QAAO,8CAA6C;AAEzF,SAAQC,0BAA0B,QAAO,kDAAiD"}
@@ -1,7 +1,9 @@
1
+ import { extendViteConfigWithUserConfig, getViteConfig, writeSanityRuntime } from '@sanity/cli-build/_internal/build';
2
+ import { getCliTelemetry } from '@sanity/cli-core';
1
3
  import { createServer } from 'vite';
2
- import { extendViteConfigWithUserConfig, getViteConfig } from '../actions/build/getViteConfig.js';
3
- import { writeSanityRuntime } from '../actions/build/writeSanityRuntime.js';
4
+ import { getAppEnvironmentVariables, getStudioEnvironmentVariables } from '../actions/build/getEnvironmentVariables.js';
4
5
  import { serverDebug } from './serverDebug.js';
6
+ import { sanityTypegenPlugin } from './vite/plugin-typegen.js';
5
7
  const debug = serverDebug.extend('dev');
6
8
  export async function startDevServer(options) {
7
9
  const { appTitle, basePath, cwd, entry, httpHost, httpPort, isApp, reactCompiler, reactStrictMode, schemaExtraction, typegen, vite: extendViteConfig } = options;
@@ -17,9 +19,29 @@ export async function startDevServer(options) {
17
19
  });
18
20
  debug('Resolving vite config');
19
21
  const mode = 'development';
22
+ function getEnvironmentVariables() {
23
+ return isApp ? getAppEnvironmentVariables({
24
+ jsonEncode: true,
25
+ prefix: 'process.env.'
26
+ }) : getStudioEnvironmentVariables({
27
+ jsonEncode: true,
28
+ prefix: 'process.env.'
29
+ });
30
+ }
20
31
  let viteConfig = await getViteConfig({
32
+ additionalPlugins: [
33
+ // Add typegen when enabled
34
+ ...typegen?.enabled ? [
35
+ sanityTypegenPlugin({
36
+ config: typegen,
37
+ telemetryLogger: getCliTelemetry(),
38
+ workDir: cwd
39
+ })
40
+ ] : []
41
+ ],
21
42
  basePath,
22
43
  cwd,
44
+ getEnvironmentVariables,
23
45
  isApp,
24
46
  mode: 'development',
25
47
  reactCompiler,
@@ -27,8 +49,7 @@ export async function startDevServer(options) {
27
49
  server: {
28
50
  host: httpHost,
29
51
  port: httpPort
30
- },
31
- typegen
52
+ }
32
53
  });
33
54
  // Extend Vite configuration with user-provided config
34
55
  if (extendViteConfig) {
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/server/devServer.ts"],"sourcesContent":["import {CliConfig, type UserViteConfig} from '@sanity/cli-core'\nimport {type PluginOptions as ReactCompilerConfig} from 'babel-plugin-react-compiler'\nimport {type FSWatcher} from 'chokidar'\nimport {createServer, type InlineConfig, type ViteDevServer} from 'vite'\n\nimport {extendViteConfigWithUserConfig, getViteConfig} from '../actions/build/getViteConfig.js'\nimport {writeSanityRuntime} from '../actions/build/writeSanityRuntime.js'\nimport {serverDebug} from './serverDebug.js'\n\nconst debug = serverDebug.extend('dev')\n\nexport interface DevServerOptions {\n basePath: string\n cwd: string\n httpPort: number\n\n reactCompiler: ReactCompilerConfig | undefined\n reactStrictMode: boolean\n\n staticPath: string\n\n appTitle?: string\n entry?: string\n httpHost?: string\n isApp?: boolean\n projectName?: string\n schemaExtraction?: CliConfig['schemaExtraction']\n typegen?: CliConfig['typegen']\n vite?: UserViteConfig\n}\n\ninterface DevServer {\n close(): Promise<void>\n server: ViteDevServer\n\n watcher?: FSWatcher\n}\n\nexport async function startDevServer(options: DevServerOptions): Promise<DevServer> {\n const {\n appTitle,\n basePath,\n cwd,\n entry,\n httpHost,\n httpPort,\n isApp,\n reactCompiler,\n reactStrictMode,\n schemaExtraction,\n typegen,\n vite: extendViteConfig,\n } = options\n\n debug('Writing Sanity runtime files')\n const watcher = await writeSanityRuntime({\n appTitle,\n basePath,\n cwd,\n entry,\n isApp,\n reactStrictMode,\n watch: true,\n })\n\n debug('Resolving vite config')\n const mode = 'development'\n\n let viteConfig: InlineConfig = await getViteConfig({\n basePath,\n cwd,\n isApp,\n mode: 'development',\n reactCompiler,\n schemaExtraction,\n server: {host: httpHost, port: httpPort},\n typegen,\n })\n\n // Extend Vite configuration with user-provided config\n if (extendViteConfig) {\n viteConfig = await extendViteConfigWithUserConfig(\n {command: 'serve', mode},\n viteConfig,\n extendViteConfig,\n )\n }\n\n debug('Creating vite server')\n const server = await createServer(viteConfig)\n\n debug('Listening on specified port')\n await server.listen()\n\n return {\n close: async () => {\n if (watcher) {\n await watcher.close()\n }\n await server.close()\n },\n server,\n watcher,\n }\n}\n"],"names":["createServer","extendViteConfigWithUserConfig","getViteConfig","writeSanityRuntime","serverDebug","debug","extend","startDevServer","options","appTitle","basePath","cwd","entry","httpHost","httpPort","isApp","reactCompiler","reactStrictMode","schemaExtraction","typegen","vite","extendViteConfig","watcher","watch","mode","viteConfig","server","host","port","command","listen","close"],"mappings":"AAGA,SAAQA,YAAY,QAA8C,OAAM;AAExE,SAAQC,8BAA8B,EAAEC,aAAa,QAAO,oCAAmC;AAC/F,SAAQC,kBAAkB,QAAO,yCAAwC;AACzE,SAAQC,WAAW,QAAO,mBAAkB;AAE5C,MAAMC,QAAQD,YAAYE,MAAM,CAAC;AA6BjC,OAAO,eAAeC,eAAeC,OAAyB;IAC5D,MAAM,EACJC,QAAQ,EACRC,QAAQ,EACRC,GAAG,EACHC,KAAK,EACLC,QAAQ,EACRC,QAAQ,EACRC,KAAK,EACLC,aAAa,EACbC,eAAe,EACfC,gBAAgB,EAChBC,OAAO,EACPC,MAAMC,gBAAgB,EACvB,GAAGb;IAEJH,MAAM;IACN,MAAMiB,UAAU,MAAMnB,mBAAmB;QACvCM;QACAC;QACAC;QACAC;QACAG;QACAE;QACAM,OAAO;IACT;IAEAlB,MAAM;IACN,MAAMmB,OAAO;IAEb,IAAIC,aAA2B,MAAMvB,cAAc;QACjDQ;QACAC;QACAI;QACAS,MAAM;QACNR;QACAE;QACAQ,QAAQ;YAACC,MAAMd;YAAUe,MAAMd;QAAQ;QACvCK;IACF;IAEA,sDAAsD;IACtD,IAAIE,kBAAkB;QACpBI,aAAa,MAAMxB,+BACjB;YAAC4B,SAAS;YAASL;QAAI,GACvBC,YACAJ;IAEJ;IAEAhB,MAAM;IACN,MAAMqB,SAAS,MAAM1B,aAAayB;IAElCpB,MAAM;IACN,MAAMqB,OAAOI,MAAM;IAEnB,OAAO;QACLC,OAAO;YACL,IAAIT,SAAS;gBACX,MAAMA,QAAQS,KAAK;YACrB;YACA,MAAML,OAAOK,KAAK;QACpB;QACAL;QACAJ;IACF;AACF"}
1
+ {"version":3,"sources":["../../src/server/devServer.ts"],"sourcesContent":["import {\n extendViteConfigWithUserConfig,\n getViteConfig,\n writeSanityRuntime,\n} from '@sanity/cli-build/_internal/build'\nimport {CliConfig, getCliTelemetry, type UserViteConfig} from '@sanity/cli-core'\nimport {type PluginOptions as ReactCompilerConfig} from 'babel-plugin-react-compiler'\nimport {type FSWatcher} from 'chokidar'\nimport {createServer, type InlineConfig, type ViteDevServer} from 'vite'\n\nimport {\n getAppEnvironmentVariables,\n getStudioEnvironmentVariables,\n} from '../actions/build/getEnvironmentVariables.js'\nimport {serverDebug} from './serverDebug.js'\nimport {sanityTypegenPlugin} from './vite/plugin-typegen.js'\n\nconst debug = serverDebug.extend('dev')\n\nexport interface DevServerOptions {\n basePath: string\n cwd: string\n httpPort: number\n\n reactCompiler: ReactCompilerConfig | undefined\n reactStrictMode: boolean\n\n staticPath: string\n\n appTitle?: string\n entry?: string\n httpHost?: string\n isApp?: boolean\n projectName?: string\n schemaExtraction?: CliConfig['schemaExtraction']\n typegen?: CliConfig['typegen']\n vite?: UserViteConfig\n}\n\ninterface DevServer {\n close(): Promise<void>\n server: ViteDevServer\n\n watcher?: FSWatcher\n}\n\nexport async function startDevServer(options: DevServerOptions): Promise<DevServer> {\n const {\n appTitle,\n basePath,\n cwd,\n entry,\n httpHost,\n httpPort,\n isApp,\n reactCompiler,\n reactStrictMode,\n schemaExtraction,\n typegen,\n vite: extendViteConfig,\n } = options\n\n debug('Writing Sanity runtime files')\n const watcher = await writeSanityRuntime({\n appTitle,\n basePath,\n cwd,\n entry,\n isApp,\n reactStrictMode,\n watch: true,\n })\n\n debug('Resolving vite config')\n const mode = 'development'\n\n function getEnvironmentVariables() {\n return isApp\n ? getAppEnvironmentVariables({jsonEncode: true, prefix: 'process.env.'})\n : getStudioEnvironmentVariables({jsonEncode: true, prefix: 'process.env.'})\n }\n\n let viteConfig: InlineConfig = await getViteConfig({\n additionalPlugins: [\n // Add typegen when enabled\n ...(typegen?.enabled\n ? [\n sanityTypegenPlugin({\n config: typegen,\n telemetryLogger: getCliTelemetry(),\n workDir: cwd,\n }),\n ]\n : []),\n ],\n basePath,\n cwd,\n getEnvironmentVariables,\n isApp,\n mode: 'development',\n reactCompiler,\n schemaExtraction,\n server: {host: httpHost, port: httpPort},\n })\n\n // Extend Vite configuration with user-provided config\n if (extendViteConfig) {\n viteConfig = await extendViteConfigWithUserConfig(\n {command: 'serve', mode},\n viteConfig,\n extendViteConfig,\n )\n }\n\n debug('Creating vite server')\n const server = await createServer(viteConfig)\n\n debug('Listening on specified port')\n await server.listen()\n\n return {\n close: async () => {\n if (watcher) {\n await watcher.close()\n }\n await server.close()\n },\n server,\n watcher,\n }\n}\n"],"names":["extendViteConfigWithUserConfig","getViteConfig","writeSanityRuntime","getCliTelemetry","createServer","getAppEnvironmentVariables","getStudioEnvironmentVariables","serverDebug","sanityTypegenPlugin","debug","extend","startDevServer","options","appTitle","basePath","cwd","entry","httpHost","httpPort","isApp","reactCompiler","reactStrictMode","schemaExtraction","typegen","vite","extendViteConfig","watcher","watch","mode","getEnvironmentVariables","jsonEncode","prefix","viteConfig","additionalPlugins","enabled","config","telemetryLogger","workDir","server","host","port","command","listen","close"],"mappings":"AAAA,SACEA,8BAA8B,EAC9BC,aAAa,EACbC,kBAAkB,QACb,oCAAmC;AAC1C,SAAmBC,eAAe,QAA4B,mBAAkB;AAGhF,SAAQC,YAAY,QAA8C,OAAM;AAExE,SACEC,0BAA0B,EAC1BC,6BAA6B,QACxB,8CAA6C;AACpD,SAAQC,WAAW,QAAO,mBAAkB;AAC5C,SAAQC,mBAAmB,QAAO,2BAA0B;AAE5D,MAAMC,QAAQF,YAAYG,MAAM,CAAC;AA6BjC,OAAO,eAAeC,eAAeC,OAAyB;IAC5D,MAAM,EACJC,QAAQ,EACRC,QAAQ,EACRC,GAAG,EACHC,KAAK,EACLC,QAAQ,EACRC,QAAQ,EACRC,KAAK,EACLC,aAAa,EACbC,eAAe,EACfC,gBAAgB,EAChBC,OAAO,EACPC,MAAMC,gBAAgB,EACvB,GAAGb;IAEJH,MAAM;IACN,MAAMiB,UAAU,MAAMxB,mBAAmB;QACvCW;QACAC;QACAC;QACAC;QACAG;QACAE;QACAM,OAAO;IACT;IAEAlB,MAAM;IACN,MAAMmB,OAAO;IAEb,SAASC;QACP,OAAOV,QACHd,2BAA2B;YAACyB,YAAY;YAAMC,QAAQ;QAAc,KACpEzB,8BAA8B;YAACwB,YAAY;YAAMC,QAAQ;QAAc;IAC7E;IAEA,IAAIC,aAA2B,MAAM/B,cAAc;QACjDgC,mBAAmB;YACjB,2BAA2B;eACvBV,SAASW,UACT;gBACE1B,oBAAoB;oBAClB2B,QAAQZ;oBACRa,iBAAiBjC;oBACjBkC,SAAStB;gBACX;aACD,GACD,EAAE;SACP;QACDD;QACAC;QACAc;QACAV;QACAS,MAAM;QACNR;QACAE;QACAgB,QAAQ;YAACC,MAAMtB;YAAUuB,MAAMtB;QAAQ;IACzC;IAEA,sDAAsD;IACtD,IAAIO,kBAAkB;QACpBO,aAAa,MAAMhC,+BACjB;YAACyC,SAAS;YAASb;QAAI,GACvBI,YACAP;IAEJ;IAEAhB,MAAM;IACN,MAAM6B,SAAS,MAAMlC,aAAa4B;IAElCvB,MAAM;IACN,MAAM6B,OAAOI,MAAM;IAEnB,OAAO;QACLC,OAAO;YACL,IAAIjB,SAAS;gBACX,MAAMA,QAAQiB,KAAK;YACrB;YACA,MAAML,OAAOK,KAAK;QACpB;QACAL;QACAZ;IACF;AACF"}
@@ -1,9 +1,9 @@
1
1
  import { readFile } from 'node:fs/promises';
2
2
  import path from 'node:path';
3
3
  import { styleText } from 'node:util';
4
+ import { extendViteConfigWithUserConfig } from '@sanity/cli-build/_internal/build';
4
5
  import { getLocalPackageVersion } from '@sanity/cli-core';
5
6
  import { preview } from 'vite';
6
- import { extendViteConfigWithUserConfig } from '../actions/build/getViteConfig.js';
7
7
  import { serverDebug } from './serverDebug.js';
8
8
  import { sanityBasePathRedirectPlugin } from './vite/plugin-sanity-basepath-redirect.js';
9
9
  const debug = serverDebug.extend('preview');
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/server/previewServer.ts"],"sourcesContent":["import {readFile} from 'node:fs/promises'\nimport path from 'node:path'\nimport {styleText} from 'node:util'\n\nimport {getLocalPackageVersion, type UserViteConfig} from '@sanity/cli-core'\nimport {type InlineConfig, preview} from 'vite'\n\nimport {extendViteConfigWithUserConfig} from '../actions/build/getViteConfig.js'\nimport {serverDebug} from './serverDebug.js'\nimport {sanityBasePathRedirectPlugin} from './vite/plugin-sanity-basepath-redirect.js'\n\nconst debug = serverDebug.extend('preview')\n\n/**\n * @internal\n */\nexport interface PreviewServer {\n close(): Promise<void>\n urls: {local: string[]; network: string[]}\n}\n\ninterface PreviewServerOptions {\n cwd: string\n httpPort: number\n\n root: string\n\n workDir: string\n\n httpHost?: string\n isApp?: boolean\n vite?: UserViteConfig\n}\n\n/**\n * Starts a Vite preview server for the given build output directory\n *\n * @param options - Preview server options\n * @returns A promise that resolves to the started preview server\n * @internal\n */\nexport async function startPreviewServer(options: PreviewServerOptions): Promise<PreviewServer> {\n const {httpHost, httpPort, isApp, root, vite: extendViteConfig, workDir} = options\n const startTime = Date.now()\n\n const indexPath = path.join(root, 'index.html')\n let basePath: string | undefined\n try {\n const index = await readFile(indexPath, 'utf8')\n basePath = tryResolveBasePathFromIndex(index)\n } catch (err: unknown) {\n if (err instanceof Error && 'code' in err && err.code === 'ENOENT') {\n const error = new Error(`Could not find a production build in the '${root}' directory.`)\n error.name = 'BUILD_NOT_FOUND'\n throw error\n }\n\n throw err\n }\n\n const mode = 'production'\n let previewConfig: InlineConfig = {\n base: basePath || '/',\n // Needed for vite to not serve `root/dist`\n build: {\n outDir: root,\n },\n configFile: false,\n mode,\n plugins: [sanityBasePathRedirectPlugin(basePath)],\n preview: {\n host: httpHost,\n port: httpPort,\n strictPort: true,\n },\n root: workDir,\n }\n\n // Extend Vite configuration with user-provided config\n if (extendViteConfig) {\n previewConfig = await extendViteConfigWithUserConfig(\n {command: 'serve', mode},\n previewConfig,\n extendViteConfig,\n )\n }\n\n debug('Creating vite server')\n const server = await preview(previewConfig)\n const warn = server.config.logger.warn\n const info = server.config.logger.info\n const url = server.resolvedUrls!.local[0]\n\n if (basePath === undefined) {\n warn('Could not determine base path from index.html, using \"/\" as default')\n } else if (basePath && basePath !== '/') {\n info(`Using resolved base path from static build: ${styleText('cyan', basePath)}`)\n }\n\n const startupDuration = Date.now() - startTime\n\n const viteVersion = await getLocalPackageVersion('vite', import.meta.url)\n\n info(\n `Sanity ${isApp ? 'application' : 'Studio'} ` +\n `using ${styleText('cyan', `vite@${viteVersion}`)} ` +\n `ready in ${styleText('cyan', `${Math.ceil(startupDuration)}ms`)} ` +\n `and running at ${styleText('cyan', url)} (production preview mode)`,\n )\n\n return {\n close: () =>\n new Promise((resolve, reject) =>\n server.httpServer.close((err) => (err ? reject(err) : resolve())),\n ),\n urls: server.resolvedUrls!,\n }\n}\n\nfunction tryResolveBasePathFromIndex(index: string): string | undefined {\n // <script ... src=\"/some-base-path/static/sanity-a3cc3d86.js\"></script>\n const basePath = index.match(/<script[^>]+src=\"(.*?)\\/static\\/sanity-/)?.[1]\n\n // We _expect_ to be able to find the base path. If we can't, we should warn.\n // Note that we're checking for `undefined` here, since an empty string is a\n // valid base path.\n if (basePath === undefined) {\n return undefined\n }\n\n // In the case of an empty base path, we still want to return `/` to indicate\n // that we _found_ the basepath - it just happens to be empty. Eg:\n // <script ... src = \"/static/sanity-a3cc3d86.js\"></script>\n // Which differs from not being able to find the script tag at all, in which\n // case we'll want to show a warning to indicate that it is an abnormality.\n return basePath === '' ? '/' : basePath\n}\n"],"names":["readFile","path","styleText","getLocalPackageVersion","preview","extendViteConfigWithUserConfig","serverDebug","sanityBasePathRedirectPlugin","debug","extend","startPreviewServer","options","httpHost","httpPort","isApp","root","vite","extendViteConfig","workDir","startTime","Date","now","indexPath","join","basePath","index","tryResolveBasePathFromIndex","err","Error","code","error","name","mode","previewConfig","base","build","outDir","configFile","plugins","host","port","strictPort","command","server","warn","config","logger","info","url","resolvedUrls","local","undefined","startupDuration","viteVersion","Math","ceil","close","Promise","resolve","reject","httpServer","urls","match"],"mappings":"AAAA,SAAQA,QAAQ,QAAO,mBAAkB;AACzC,OAAOC,UAAU,YAAW;AAC5B,SAAQC,SAAS,QAAO,YAAW;AAEnC,SAAQC,sBAAsB,QAA4B,mBAAkB;AAC5E,SAA2BC,OAAO,QAAO,OAAM;AAE/C,SAAQC,8BAA8B,QAAO,oCAAmC;AAChF,SAAQC,WAAW,QAAO,mBAAkB;AAC5C,SAAQC,4BAA4B,QAAO,4CAA2C;AAEtF,MAAMC,QAAQF,YAAYG,MAAM,CAAC;AAuBjC;;;;;;CAMC,GACD,OAAO,eAAeC,mBAAmBC,O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UAAU,QAAQsB,WAAW;IACnF;IAEA,MAAM4B,kBAAkBhC,KAAKC,GAAG,KAAKF;IAErC,MAAMkC,cAAc,MAAMlD,uBAAuB,QAAQ,YAAY6C,GAAG;IAExED,KACE,CAAC,OAAO,EAAEjC,QAAQ,gBAAgB,SAAS,CAAC,CAAC,GAC3C,CAAC,MAAM,EAAEZ,UAAU,QAAQ,CAAC,KAAK,EAAEmD,aAAa,EAAE,CAAC,CAAC,GACpD,CAAC,SAAS,EAAEnD,UAAU,QAAQ,GAAGoD,KAAKC,IAAI,CAACH,iBAAiB,EAAE,CAAC,EAAE,CAAC,CAAC,GACnE,CAAC,eAAe,EAAElD,UAAU,QAAQ8C,KAAK,0BAA0B,CAAC;IAGxE,OAAO;QACLQ,OAAO,IACL,IAAIC,QAAQ,CAACC,SAASC,SACpBhB,OAAOiB,UAAU,CAACJ,KAAK,CAAC,CAAC7B,MAASA,MAAMgC,OAAOhC,OAAO+B;QAE1DG,MAAMlB,OAAOM,YAAY;IAC3B;AACF;AAEA,SAASvB,4BAA4BD,KAAa;IAChD,wEAAwE;IACxE,MAAMD,WAAWC,MAAMqC,KAAK,CAAC,4CAA4C,CAAC,EAAE;IAE5E,6EAA6E;IAC7E,4EAA4E;IAC5E,mBAAmB;IACnB,IAAItC,aAAa2B,WAAW;QAC1B,OAAOA;IACT;IAEA,6EAA6E;IAC7E,kEAAkE;IAClE,2DAA2D;IAC3D,4EAA4E;IAC5E,2EAA2E;IAC3E,OAAO3B,aAAa,KAAK,MAAMA;AACjC"}
1
+ {"version":3,"sources":["../../src/server/previewServer.ts"],"sourcesContent":["import {readFile} from 'node:fs/promises'\nimport path from 'node:path'\nimport {styleText} from 'node:util'\n\nimport {extendViteConfigWithUserConfig} from '@sanity/cli-build/_internal/build'\nimport {getLocalPackageVersion, type UserViteConfig} from '@sanity/cli-core'\nimport {type InlineConfig, preview} from 'vite'\n\nimport {serverDebug} from './serverDebug.js'\nimport {sanityBasePathRedirectPlugin} from './vite/plugin-sanity-basepath-redirect.js'\n\nconst debug = serverDebug.extend('preview')\n\n/**\n * @internal\n */\nexport interface PreviewServer {\n close(): Promise<void>\n urls: {local: string[]; network: string[]}\n}\n\ninterface PreviewServerOptions {\n cwd: string\n httpPort: number\n\n root: string\n\n workDir: string\n\n httpHost?: string\n isApp?: boolean\n vite?: UserViteConfig\n}\n\n/**\n * Starts a Vite preview server for the given build output directory\n *\n * @param options - Preview server options\n * @returns A promise that resolves to the started preview server\n * @internal\n */\nexport async function startPreviewServer(options: PreviewServerOptions): Promise<PreviewServer> {\n const {httpHost, httpPort, isApp, root, vite: extendViteConfig, workDir} = options\n const startTime = Date.now()\n\n const indexPath = path.join(root, 'index.html')\n let basePath: string | undefined\n try {\n const index = await readFile(indexPath, 'utf8')\n basePath = tryResolveBasePathFromIndex(index)\n } catch (err: unknown) {\n if (err instanceof Error && 'code' in err && err.code === 'ENOENT') {\n const error = new Error(`Could not find a production build in the '${root}' directory.`)\n error.name = 'BUILD_NOT_FOUND'\n throw error\n }\n\n throw err\n }\n\n const mode = 'production'\n let previewConfig: InlineConfig = {\n base: basePath || '/',\n // Needed for vite to not serve `root/dist`\n build: {\n outDir: root,\n },\n configFile: false,\n mode,\n plugins: [sanityBasePathRedirectPlugin(basePath)],\n preview: {\n host: httpHost,\n port: httpPort,\n strictPort: true,\n },\n root: workDir,\n }\n\n // Extend Vite configuration with user-provided config\n if (extendViteConfig) {\n previewConfig = await extendViteConfigWithUserConfig(\n {command: 'serve', mode},\n previewConfig,\n extendViteConfig,\n )\n }\n\n debug('Creating vite server')\n const server = await preview(previewConfig)\n const warn = server.config.logger.warn\n const info = server.config.logger.info\n const url = server.resolvedUrls!.local[0]\n\n if (basePath === undefined) {\n warn('Could not determine base path from index.html, using \"/\" as default')\n } else if (basePath && basePath !== '/') {\n info(`Using resolved base path from static build: ${styleText('cyan', basePath)}`)\n }\n\n const startupDuration = Date.now() - startTime\n\n const viteVersion = await getLocalPackageVersion('vite', import.meta.url)\n\n info(\n `Sanity ${isApp ? 'application' : 'Studio'} ` +\n `using ${styleText('cyan', `vite@${viteVersion}`)} ` +\n `ready in ${styleText('cyan', `${Math.ceil(startupDuration)}ms`)} ` +\n `and running at ${styleText('cyan', url)} (production preview mode)`,\n )\n\n return {\n close: () =>\n new Promise((resolve, reject) =>\n server.httpServer.close((err) => (err ? reject(err) : resolve())),\n ),\n urls: server.resolvedUrls!,\n }\n}\n\nfunction tryResolveBasePathFromIndex(index: string): string | undefined {\n // <script ... src=\"/some-base-path/static/sanity-a3cc3d86.js\"></script>\n const basePath = index.match(/<script[^>]+src=\"(.*?)\\/static\\/sanity-/)?.[1]\n\n // We _expect_ to be able to find the base path. If we can't, we should warn.\n // Note that we're checking for `undefined` here, since an empty string is a\n // valid base path.\n if (basePath === undefined) {\n return undefined\n }\n\n // In the case of an empty base path, we still want to return `/` to indicate\n // that we _found_ the basepath - it just happens to be empty. Eg:\n // <script ... src = \"/static/sanity-a3cc3d86.js\"></script>\n // Which differs from not being able to find the script tag at all, in which\n // case we'll want to show a warning to indicate that it is an abnormality.\n return basePath === '' ? '/' : basePath\n}\n"],"names":["readFile","path","styleText","extendViteConfigWithUserConfig","getLocalPackageVersion","preview","serverDebug","sanityBasePathRedirectPlugin","debug","extend","startPreviewServer","options","httpHost","httpPort","isApp","root","vite","extendViteConfig","workDir","startTime","Date","now","indexPath","join","basePath","index","tryResolveBasePathFromIndex","err","Error","code","error","name","mode","previewConfig","base","build","outDir","configFile","plugins","host","port","strictPort","command","server","warn","config","logger","info","url","resolvedUrls","local","undefined","startupDuration","viteVersion","Math","ceil","close","Promise","resolve","reject","httpServer","urls","match"],"mappings":"AAAA,SAAQA,QAAQ,QAAO,mBAAkB;AACzC,OAAOC,UAAU,YAAW;AAC5B,SAAQC,SAAS,QAAO,YAAW;AAEnC,SAAQC,8BAA8B,QAAO,oCAAmC;AAChF,SAAQC,sBAAsB,QAA4B,mBAAkB;AAC5E,SAA2BC,OAAO,QAAO,OAAM;AAE/C,SAAQC,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Y,CAAEC,KAAK,CAAC,EAAE;IAEzC,IAAI1B,aAAa2B,WAAW;QAC1BP,KAAK;IACP,OAAO,IAAIpB,YAAYA,aAAa,KAAK;QACvCuB,KAAK,CAAC,4CAA4C,EAAE7C,UAAU,QAAQsB,WAAW;IACnF;IAEA,MAAM4B,kBAAkBhC,KAAKC,GAAG,KAAKF;IAErC,MAAMkC,cAAc,MAAMjD,uBAAuB,QAAQ,YAAY4C,GAAG;IAExED,KACE,CAAC,OAAO,EAAEjC,QAAQ,gBAAgB,SAAS,CAAC,CAAC,GAC3C,CAAC,MAAM,EAAEZ,UAAU,QAAQ,CAAC,KAAK,EAAEmD,aAAa,EAAE,CAAC,CAAC,GACpD,CAAC,SAAS,EAAEnD,UAAU,QAAQ,GAAGoD,KAAKC,IAAI,CAACH,iBAAiB,EAAE,CAAC,EAAE,CAAC,CAAC,GACnE,CAAC,eAAe,EAAElD,UAAU,QAAQ8C,KAAK,0BAA0B,CAAC;IAGxE,OAAO;QACLQ,OAAO,IACL,IAAIC,QAAQ,CAACC,SAASC,SACpBhB,OAAOiB,UAAU,CAACJ,KAAK,CAAC,CAAC7B,MAASA,MAAMgC,OAAOhC,OAAO+B;QAE1DG,MAAMlB,OAAOM,YAAY;IAC3B;AACF;AAEA,SAASvB,4BAA4BD,KAAa;IAChD,wEAAwE;IACxE,MAAMD,WAAWC,MAAMqC,KAAK,CAAC,4CAA4C,CAAC,EAAE;IAE5E,6EAA6E;IAC7E,4EAA4E;IAC5E,mBAAmB;IACnB,IAAItC,aAAa2B,WAAW;QAC1B,OAAOA;IACT;IAEA,6EAA6E;IAC7E,kEAAkE;IAClE,2DAA2D;IAC3D,4EAA4E;IAC5E,2EAA2E;IAC3E,OAAO3B,aAAa,KAAK,MAAMA;AACjC"}
@@ -1,6 +1,6 @@
1
1
  import { getGlobalCliClient, subdebug } from '@sanity/cli-core';
2
2
  import { isHttpError } from '@sanity/client';
3
- export const MCP_API_VERSION = '2025-12-09';
3
+ const MCP_API_VERSION = '2025-12-09';
4
4
  export const MCP_SERVER_URL = 'https://mcp.sanity.io';
5
5
  export const MCP_JOURNEY_API_VERSION = 'v2024-02-23';
6
6
  const debug = subdebug('mcp:service');
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/services/mcp.ts"],"sourcesContent":["import {getGlobalCliClient, subdebug} from '@sanity/cli-core'\nimport {isHttpError} from '@sanity/client'\n\nexport const MCP_API_VERSION = '2025-12-09'\nexport const MCP_SERVER_URL = 'https://mcp.sanity.io'\nexport const MCP_JOURNEY_API_VERSION = 'v2024-02-23'\n\nconst debug = subdebug('mcp:service')\n\ninterface PostInitPromptResponse {\n message?: string\n}\n\n/**\n * Create a child token for MCP usage\n * This token is tied to the parent CLI token and will be invalidated\n * when the parent token is invalidated (e.g., on logout)\n *\n * @returns The MCP token string\n * @internal\n */\nexport async function createMCPToken(): Promise<string> {\n const client = await getGlobalCliClient({\n apiVersion: MCP_API_VERSION,\n requireUser: true,\n })\n\n const sessionResponse = await client.request<{id: string; sid: string}>({\n body: {\n sourceId: 'sanity-mcp',\n withStamp: false,\n },\n method: 'POST',\n uri: '/auth/session/create',\n })\n\n const tokenResponse = await client.request<{label: string; token: string}>({\n method: 'GET',\n query: {sid: sessionResponse.sid},\n uri: '/auth/fetch',\n })\n\n return tokenResponse.token\n}\n\n/**\n * Validate an MCP token by checking it against the Sanity API.\n *\n * MCP tokens are standard Sanity session tokens (`sk…`), so we validate\n * by calling `/users/me` on `api.sanity.io`. A 200 means the token is\n * alive; a 401/403 means it is dead and the caller should prompt for\n * re-configuration.\n *\n * Transient errors (5xx, network failures, timeouts) are rethrown so the\n * caller can decide how to handle them — typically by assuming the token\n * is still valid rather than falsely marking it as expired.\n *\n * We intentionally do NOT probe `mcp.sanity.io` because the MCP server\n * lets invalid bearer tokens through for protocol-compatibility reasons,\n * which causes the CLI to falsely treat dead tokens as valid.\n *\n * @internal\n */\nexport async function validateMCPToken(token: string): Promise<boolean> {\n const client = await getGlobalCliClient({\n apiVersion: MCP_API_VERSION,\n requireUser: false,\n token,\n })\n\n try {\n await client.request({timeout: 2500, uri: '/users/me'})\n return true\n } catch (err) {\n // 401/403 definitively mean \"dead token\"\n if (isHttpError(err) && (err.statusCode === 401 || err.statusCode === 403)) {\n debug('MCP token validation failed with %d', err.statusCode)\n return false\n }\n\n // Everything else (5xx, network errors, timeouts) is rethrown so the\n // caller can decide — typically assumes valid rather than forcing re-auth.\n throw err\n }\n}\n\n/**\n * Fetches the post-init MCP prompt from the Journey API and interpolates editor names.\n * Falls back to a hardcoded default if the API call fails, times out, or returns empty.\n * Text wrapped in **markers** will be formatted with cyan color.\n */\nexport async function getPostInitPrompt() {\n const client = await getGlobalCliClient({apiVersion: MCP_JOURNEY_API_VERSION, requireUser: false})\n return await client.request<PostInitPromptResponse | null>({\n method: 'GET',\n timeout: 1000,\n uri: '/journey/mcp/post-init-prompt',\n })\n}\n"],"names":["getGlobalCliClient","subdebug","isHttpError","MCP_API_VERSION","MCP_SERVER_URL","MCP_JOURNEY_API_VERSION","debug","createMCPToken","client","apiVersion","requireUser","sessionResponse","request","body","sourceId","withStamp","method","uri","tokenResponse","query","sid","token","validateMCPToken","timeout","err","statusCode","getPostInitPrompt"],"mappings":"AAAA,SAAQA,kBAAkB,EAAEC,QAAQ,QAAO,mBAAkB;AAC7D,SAAQC,WAAW,QAAO,iBAAgB;AAE1C,OAAO,MAAMC,kBAAkB,aAAY;AAC3C,OAAO,MAAMC,iBAAiB,wBAAuB;AACrD,OAAO,MAAMC,0BAA0B,cAAa;AAEpD,MAAMC,QAAQL,SAAS;AAMvB;;;;;;;CAOC,GACD,OAAO,eAAeM;IACpB,MAAMC,SAAS,MAAMR,mBAAmB;QACtCS,YAAYN;QACZO,aAAa;IACf;IAEA,MAAMC,kBAAkB,MAAMH,OAAOI,OAAO,CAA4B;QACtEC,MAAM;YACJC,UAAU;YACVC,WAAW;QACb;QACAC,QAAQ;QACRC,KAAK;IACP;IAEA,MAAMC,gBAAgB,MAAMV,OAAOI,OAAO,CAAiC;QACzEI,QAAQ;QACRG,OAAO;YAACC,KAAKT,gBAAgBS,GAAG;QAAA;QAChCH,KAAK;IACP;IAEA,OAAOC,cAAcG,KAAK;AAC5B;AAEA;;;;;;;;;;;;;;;;;CAiBC,GACD,OAAO,eAAeC,iBAAiBD,KAAa;IAClD,MAAMb,SAAS,MAAMR,mBAAmB;QACtCS,YAAYN;QACZO,aAAa;QACbW;IACF;IAEA,IAAI;QACF,MAAMb,OAAOI,OAAO,CAAC;YAACW,SAAS;YAAMN,KAAK;QAAW;QACrD,OAAO;IACT,EAAE,OAAOO,KAAK;QACZ,yCAAyC;QACzC,IAAItB,YAAYsB,QAASA,CAAAA,IAAIC,UAAU,KAAK,OAAOD,IAAIC,UAAU,KAAK,GAAE,GAAI;YAC1EnB,MAAM,uCAAuCkB,IAAIC,UAAU;YAC3D,OAAO;QACT;QAEA,qEAAqE;QACrE,2EAA2E;QAC3E,MAAMD;IACR;AACF;AAEA;;;;CAIC,GACD,OAAO,eAAeE;IACpB,MAAMlB,SAAS,MAAMR,mBAAmB;QAACS,YAAYJ;QAAyBK,aAAa;IAAK;IAChG,OAAO,MAAMF,OAAOI,OAAO,CAAgC;QACzDI,QAAQ;QACRO,SAAS;QACTN,KAAK;IACP;AACF"}
1
+ {"version":3,"sources":["../../src/services/mcp.ts"],"sourcesContent":["import {getGlobalCliClient, subdebug} from '@sanity/cli-core'\nimport {isHttpError} from '@sanity/client'\n\nconst MCP_API_VERSION = '2025-12-09'\nexport const MCP_SERVER_URL = 'https://mcp.sanity.io'\nexport const MCP_JOURNEY_API_VERSION = 'v2024-02-23'\n\nconst debug = subdebug('mcp:service')\n\ninterface PostInitPromptResponse {\n message?: string\n}\n\n/**\n * Create a child token for MCP usage\n * This token is tied to the parent CLI token and will be invalidated\n * when the parent token is invalidated (e.g., on logout)\n *\n * @returns The MCP token string\n * @internal\n */\nexport async function createMCPToken(): Promise<string> {\n const client = await getGlobalCliClient({\n apiVersion: MCP_API_VERSION,\n requireUser: true,\n })\n\n const sessionResponse = await client.request<{id: string; sid: string}>({\n body: {\n sourceId: 'sanity-mcp',\n withStamp: false,\n },\n method: 'POST',\n uri: '/auth/session/create',\n })\n\n const tokenResponse = await client.request<{label: string; token: string}>({\n method: 'GET',\n query: {sid: sessionResponse.sid},\n uri: '/auth/fetch',\n })\n\n return tokenResponse.token\n}\n\n/**\n * Validate an MCP token by checking it against the Sanity API.\n *\n * MCP tokens are standard Sanity session tokens (`sk…`), so we validate\n * by calling `/users/me` on `api.sanity.io`. A 200 means the token is\n * alive; a 401/403 means it is dead and the caller should prompt for\n * re-configuration.\n *\n * Transient errors (5xx, network failures, timeouts) are rethrown so the\n * caller can decide how to handle them — typically by assuming the token\n * is still valid rather than falsely marking it as expired.\n *\n * We intentionally do NOT probe `mcp.sanity.io` because the MCP server\n * lets invalid bearer tokens through for protocol-compatibility reasons,\n * which causes the CLI to falsely treat dead tokens as valid.\n *\n * @internal\n */\nexport async function validateMCPToken(token: string): Promise<boolean> {\n const client = await getGlobalCliClient({\n apiVersion: MCP_API_VERSION,\n requireUser: false,\n token,\n })\n\n try {\n await client.request({timeout: 2500, uri: '/users/me'})\n return true\n } catch (err) {\n // 401/403 definitively mean \"dead token\"\n if (isHttpError(err) && (err.statusCode === 401 || err.statusCode === 403)) {\n debug('MCP token validation failed with %d', err.statusCode)\n return false\n }\n\n // Everything else (5xx, network errors, timeouts) is rethrown so the\n // caller can decide — typically assumes valid rather than forcing re-auth.\n throw err\n }\n}\n\n/**\n * Fetches the post-init MCP prompt from the Journey API and interpolates editor names.\n * Falls back to a hardcoded default if the API call fails, times out, or returns empty.\n * Text wrapped in **markers** will be formatted with cyan color.\n */\nexport async function getPostInitPrompt() {\n const client = await getGlobalCliClient({apiVersion: MCP_JOURNEY_API_VERSION, requireUser: false})\n return await client.request<PostInitPromptResponse | null>({\n method: 'GET',\n timeout: 1000,\n uri: '/journey/mcp/post-init-prompt',\n })\n}\n"],"names":["getGlobalCliClient","subdebug","isHttpError","MCP_API_VERSION","MCP_SERVER_URL","MCP_JOURNEY_API_VERSION","debug","createMCPToken","client","apiVersion","requireUser","sessionResponse","request","body","sourceId","withStamp","method","uri","tokenResponse","query","sid","token","validateMCPToken","timeout","err","statusCode","getPostInitPrompt"],"mappings":"AAAA,SAAQA,kBAAkB,EAAEC,QAAQ,QAAO,mBAAkB;AAC7D,SAAQC,WAAW,QAAO,iBAAgB;AAE1C,MAAMC,kBAAkB;AACxB,OAAO,MAAMC,iBAAiB,wBAAuB;AACrD,OAAO,MAAMC,0BAA0B,cAAa;AAEpD,MAAMC,QAAQL,SAAS;AAMvB;;;;;;;CAOC,GACD,OAAO,eAAeM;IACpB,MAAMC,SAAS,MAAMR,mBAAmB;QACtCS,YAAYN;QACZO,aAAa;IACf;IAEA,MAAMC,kBAAkB,MAAMH,OAAOI,OAAO,CAA4B;QACtEC,MAAM;YACJC,UAAU;YACVC,WAAW;QACb;QACAC,QAAQ;QACRC,KAAK;IACP;IAEA,MAAMC,gBAAgB,MAAMV,OAAOI,OAAO,CAAiC;QACzEI,QAAQ;QACRG,OAAO;YAACC,KAAKT,gBAAgBS,GAAG;QAAA;QAChCH,KAAK;IACP;IAEA,OAAOC,cAAcG,KAAK;AAC5B;AAEA;;;;;;;;;;;;;;;;;CAiBC,GACD,OAAO,eAAeC,iBAAiBD,KAAa;IAClD,MAAMb,SAAS,MAAMR,mBAAmB;QACtCS,YAAYN;QACZO,aAAa;QACbW;IACF;IAEA,IAAI;QACF,MAAMb,OAAOI,OAAO,CAAC;YAACW,SAAS;YAAMN,KAAK;QAAW;QACrD,OAAO;IACT,EAAE,OAAOO,KAAK;QACZ,yCAAyC;QACzC,IAAItB,YAAYsB,QAASA,CAAAA,IAAIC,UAAU,KAAK,OAAOD,IAAIC,UAAU,KAAK,GAAE,GAAI;YAC1EnB,MAAM,uCAAuCkB,IAAIC,UAAU;YAC3D,OAAO;QACT;QAEA,qEAAqE;QACrE,2EAA2E;QAC3E,MAAMD;IACR;AACF;AAEA;;;;CAIC,GACD,OAAO,eAAeE;IACpB,MAAMlB,SAAS,MAAMR,mBAAmB;QAACS,YAAYJ;QAAyBK,aAAa;IAAK;IAChG,OAAO,MAAMF,OAAOI,OAAO,CAAgC;QACzDI,QAAQ;QACRO,SAAS;QACTN,KAAK;IACP;AACF"}
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/telemetry/init.telemetry.ts"],"sourcesContent":["import {defineTrace} from '@sanity/telemetry'\n\nimport {type EditorName} from '../actions/mcp/editorConfigs.js'\n\ninterface StartStep {\n flags: Record<string, boolean | number | string | undefined>\n step: 'start'\n}\n\ninterface LoginStep {\n step: 'login'\n\n alreadyLoggedIn?: boolean\n}\n\ninterface FetchJourneyConfigStep {\n datasetName: string\n displayName: string\n isFirstProject: boolean\n projectId: string\n step: 'fetchJourneyConfig'\n}\n\ninterface CreateOrSelectProjectStep {\n projectId: string\n selectedOption: 'create' | 'none' | 'select'\n step: 'createOrSelectProject'\n}\n\ninterface CreateOrSelectDatasetStep {\n datasetName: string\n selectedOption: 'create' | 'none' | 'select'\n step: 'createOrSelectDataset'\n\n visibility?: 'private' | 'public'\n}\n\ninterface UseDefaultPlanCoupon {\n selectedOption: 'no' | 'yes'\n step: 'useDefaultPlanCoupon'\n\n coupon?: string\n}\n\ninterface UseDefaultPlanId {\n selectedOption: 'no' | 'yes'\n step: 'useDefaultPlanId'\n\n planId?: string\n}\n\ninterface UseDetectedFrameworkStep {\n selectedOption: 'no' | 'yes'\n step: 'useDetectedFramework'\n\n detectedFramework?: string\n}\n\ninterface UseTypeScriptStep {\n selectedOption: 'no' | 'yes'\n step: 'useTypeScript'\n}\n\ninterface SelectTemplateStep {\n selectedOption: string\n step: 'selectProjectTemplate'\n}\ninterface ImportTemplateDatasetStep {\n selectedOption: 'no' | 'yes'\n step: 'importTemplateDataset'\n}\n\ninterface SendCommunityInviteStep {\n selectedOption: 'no' | 'yes'\n step: 'sendCommunityInvite'\n}\n\ninterface SelectPackageManagerStep {\n selectedOption: string\n step: 'selectPackageManager'\n}\n\ninterface MCPSetupStep {\n configuredEditors: EditorName[]\n detectedEditors: EditorName[]\n skipped: boolean\n step: 'mcpSetup'\n}\n\ninterface ConfigureAppProjectStep {\n selectedOption: 'create' | 'existing' | 'skip'\n step: 'configureAppProject'\n}\n\nexport type InitStepResult =\n | ConfigureAppProjectStep\n | CreateOrSelectDatasetStep\n | CreateOrSelectProjectStep\n | FetchJourneyConfigStep\n | ImportTemplateDatasetStep\n | LoginStep\n | MCPSetupStep\n | SelectPackageManagerStep\n | SelectTemplateStep\n | SendCommunityInviteStep\n | StartStep\n | UseDefaultPlanCoupon\n | UseDefaultPlanId\n | UseDetectedFrameworkStep\n | UseTypeScriptStep\n\nexport const CLIInitStepCompleted = defineTrace<InitStepResult>({\n description: 'User completed a step in the CLI init flow',\n name: 'CLI Init Step Completed',\n version: 1,\n})\n"],"names":["defineTrace","CLIInitStepCompleted","description","name","version"],"mappings":"AAAA,SAAQA,WAAW,QAAO,oBAAmB;AA+G7C,OAAO,MAAMC,uBAAuBD,YAA4B;IAC9DE,aAAa;IACbC,MAAM;IACNC,SAAS;AACX,GAAE"}
1
+ {"version":3,"sources":["../../src/telemetry/init.telemetry.ts"],"sourcesContent":["import {defineTrace} from '@sanity/telemetry'\n\nimport {type EditorName} from '../actions/mcp/editorConfigs.js'\n\ninterface StartStep {\n flags: Record<string, boolean | number | string | undefined>\n step: 'start'\n}\n\ninterface LoginStep {\n step: 'login'\n\n alreadyLoggedIn?: boolean\n}\n\ninterface FetchJourneyConfigStep {\n datasetName: string\n displayName: string\n isFirstProject: boolean\n projectId: string\n step: 'fetchJourneyConfig'\n}\n\ninterface CreateOrSelectProjectStep {\n projectId: string\n selectedOption: 'create' | 'none' | 'select'\n step: 'createOrSelectProject'\n}\n\ninterface CreateOrSelectDatasetStep {\n datasetName: string\n selectedOption: 'create' | 'none' | 'select'\n step: 'createOrSelectDataset'\n\n visibility?: 'private' | 'public'\n}\n\ninterface UseDefaultPlanCoupon {\n selectedOption: 'no' | 'yes'\n step: 'useDefaultPlanCoupon'\n\n coupon?: string\n}\n\ninterface UseDefaultPlanId {\n selectedOption: 'no' | 'yes'\n step: 'useDefaultPlanId'\n\n planId?: string\n}\n\ninterface UseDetectedFrameworkStep {\n selectedOption: 'no' | 'yes'\n step: 'useDetectedFramework'\n\n detectedFramework?: string\n}\n\ninterface UseTypeScriptStep {\n selectedOption: 'no' | 'yes'\n step: 'useTypeScript'\n}\n\ninterface SelectTemplateStep {\n selectedOption: string\n step: 'selectProjectTemplate'\n}\ninterface ImportTemplateDatasetStep {\n selectedOption: 'no' | 'yes'\n step: 'importTemplateDataset'\n}\n\ninterface SendCommunityInviteStep {\n selectedOption: 'no' | 'yes'\n step: 'sendCommunityInvite'\n}\n\ninterface SelectPackageManagerStep {\n selectedOption: string\n step: 'selectPackageManager'\n}\n\ninterface MCPSetupStep {\n configuredEditors: EditorName[]\n detectedEditors: EditorName[]\n skipped: boolean\n step: 'mcpSetup'\n}\n\ninterface SkillsSetupStep {\n /** `--agent` values that received the Sanity skills bundle */\n installedAgents: string[]\n skipped: boolean\n step: 'skillsSetup'\n}\n\ninterface ConfigureAppProjectStep {\n selectedOption: 'create' | 'existing' | 'skip'\n step: 'configureAppProject'\n}\n\nexport type InitStepResult =\n | ConfigureAppProjectStep\n | CreateOrSelectDatasetStep\n | CreateOrSelectProjectStep\n | FetchJourneyConfigStep\n | ImportTemplateDatasetStep\n | LoginStep\n | MCPSetupStep\n | SelectPackageManagerStep\n | SelectTemplateStep\n | SendCommunityInviteStep\n | SkillsSetupStep\n | StartStep\n | UseDefaultPlanCoupon\n | UseDefaultPlanId\n | UseDetectedFrameworkStep\n | UseTypeScriptStep\n\nexport const CLIInitStepCompleted = defineTrace<InitStepResult>({\n description: 'User completed a step in the CLI init flow',\n name: 'CLI Init Step Completed',\n version: 1,\n})\n"],"names":["defineTrace","CLIInitStepCompleted","description","name","version"],"mappings":"AAAA,SAAQA,WAAW,QAAO,oBAAmB;AAuH7C,OAAO,MAAMC,uBAAuBD,YAA4B;IAC9DE,aAAa;IACbC,MAAM;IACNC,SAAS;AACX,GAAE"}
@@ -675,6 +675,12 @@
675
675
  "allowNo": false,
676
676
  "type": "boolean"
677
677
  },
678
+ "skills": {
679
+ "description": "Install Sanity agent skills globally for detected AI editors",
680
+ "name": "skills",
681
+ "allowNo": true,
682
+ "type": "boolean"
683
+ },
678
684
  "template": {
679
685
  "description": "Project template to use [default: \"clean\"]",
680
686
  "exclusive": [
@@ -1767,6 +1773,10 @@
1767
1773
  {
1768
1774
  "command": "<%= config.bin %> <%= command.id %> staging staging.tar.gz --types products,shops",
1769
1775
  "description": "Export specific document types"
1776
+ },
1777
+ {
1778
+ "command": "<%= config.bin %> <%= command.id %> moviedb moviedb.tar.gz --no-strict-asset-verification",
1779
+ "description": "Export dataset without aborting on asset verification failures"
1770
1780
  }
1771
1781
  ],
1772
1782
  "flags": {
@@ -1818,6 +1828,12 @@
1818
1828
  "allowNo": false,
1819
1829
  "type": "boolean"
1820
1830
  },
1831
+ "no-strict-asset-verification": {
1832
+ "description": "Do not abort the export when an asset fails hash or content-length verification",
1833
+ "name": "no-strict-asset-verification",
1834
+ "allowNo": false,
1835
+ "type": "boolean"
1836
+ },
1821
1837
  "overwrite": {
1822
1838
  "description": "Overwrite any file with the same name",
1823
1839
  "name": "overwrite",
@@ -5098,5 +5114,5 @@
5098
5114
  ]
5099
5115
  }
5100
5116
  },
5101
- "version": "6.6.0"
5117
+ "version": "6.7.1"
5102
5118
  }