@sanity/cli 8.28.0 → 8.28.2
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.
- package/README.md +22 -38
- package/dist/actions/dev/servers/startStudioDevServer.js +4 -1
- package/dist/actions/dev/servers/startStudioDevServer.js.map +1 -1
- package/dist/actions/skills/readSkillState.js +21 -34
- package/dist/actions/skills/readSkillState.js.map +1 -1
- package/dist/actions/skills/setupSkills.js +36 -36
- package/dist/actions/skills/setupSkills.js.map +1 -1
- package/oclif.manifest.json +3193 -3193
- package/package.json +9 -9
package/README.md
CHANGED
|
@@ -1274,8 +1274,8 @@ List documents
|
|
|
1274
1274
|
|
|
1275
1275
|
```
|
|
1276
1276
|
USAGE
|
|
1277
|
-
$ sanity context documents list KNOWLEDGEBASEID [--json] [--
|
|
1278
|
-
<value>]
|
|
1277
|
+
$ sanity context documents list KNOWLEDGEBASEID [--json] [--limit <value>] [--source <value>] [--state
|
|
1278
|
+
active|missing|deleted] [--ids <value>]
|
|
1279
1279
|
|
|
1280
1280
|
ARGUMENTS
|
|
1281
1281
|
KNOWLEDGEBASEID The knowledge base's ID (`kb...`), its `publicId`. Its UUID `id` is also accepted.
|
|
@@ -1283,6 +1283,7 @@ ARGUMENTS
|
|
|
1283
1283
|
FLAGS
|
|
1284
1284
|
--ids=<value> Comma-separated IDs of the documents to return, up to 200, in any state. Use it to look up the
|
|
1285
1285
|
documents entry citations point at.
|
|
1286
|
+
--limit=<value> The maximum number of items to return.
|
|
1286
1287
|
--source=<value> Return only the documents of this source.
|
|
1287
1288
|
--state=<option> Return only documents in this state. Without it, `deleted` documents are left out.
|
|
1288
1289
|
<options: active|missing|deleted>
|
|
@@ -1808,11 +1809,12 @@ List knowledge bases
|
|
|
1808
1809
|
|
|
1809
1810
|
```
|
|
1810
1811
|
USAGE
|
|
1811
|
-
$ sanity context list [--json] [--include-drafts] [--organization <id>]
|
|
1812
|
+
$ sanity context list [--json] [--limit <value>] [--include-drafts] [--organization <id>]
|
|
1812
1813
|
|
|
1813
1814
|
FLAGS
|
|
1814
1815
|
--[no-]include-drafts Set to `true` to also list the organization's drafts, which have `state` set to `draft`. Drafts
|
|
1815
1816
|
count toward the plan's knowledge base limit, and `createdBy` says who started each one.
|
|
1817
|
+
--limit=<value> The maximum number of items to return.
|
|
1816
1818
|
|
|
1817
1819
|
GLOBAL FLAGS
|
|
1818
1820
|
--json Format output as json.
|
|
@@ -1944,42 +1946,18 @@ Get an MCP endpoint's initial context
|
|
|
1944
1946
|
|
|
1945
1947
|
```
|
|
1946
1948
|
USAGE
|
|
1947
|
-
$ sanity context mcp initial-context MCPENDPOINT [--json] [--
|
|
1948
|
-
<
|
|
1949
|
-
[--workspace <value>] [--heading_offset <value>] [--organization <id>]
|
|
1949
|
+
$ sanity context mcp initial-context MCPENDPOINT [--json] [--link-resolver <value>] [--heading_offset <value>] [--organization
|
|
1950
|
+
<id>]
|
|
1950
1951
|
|
|
1951
1952
|
ARGUMENTS
|
|
1952
1953
|
MCPENDPOINT The MCP endpoint's name, set when the endpoint was created.
|
|
1953
1954
|
|
|
1954
1955
|
FLAGS
|
|
1955
|
-
--
|
|
1956
|
-
|
|
1957
|
-
|
|
1958
|
-
|
|
1959
|
-
|
|
1960
|
-
on the MCP endpoint instead.
|
|
1961
|
-
--heading_offset=<value> How many levels to shift markdown headings down, from `0` to `6`. Defaults to `1`, so `#`
|
|
1962
|
-
becomes `##`.
|
|
1963
|
-
--instructions=<value> Agent instructions that replace the endpoint's configured instructions for this request.
|
|
1964
|
-
Deprecated: refused from API version `v2026-11-03`. Configure it on the MCP endpoint
|
|
1965
|
-
instead.
|
|
1966
|
-
--knowledge-bases=<value> Comma-separated knowledge base public IDs (`kb...`) that replace the endpoint's knowledge
|
|
1967
|
-
base sources for this request. Deprecated: refused from API version `v2026-11-03`.
|
|
1968
|
-
Configure it on the MCP endpoint instead.
|
|
1969
|
-
--link-resolver=<value> A JSON array that adds `_url` fields to query results. Each item has `types` (document
|
|
1970
|
-
types), `baseUrl`, and an optional `slugExpression`, a GROQ expression that defaults to
|
|
1971
|
-
`slug.current`. Invalid JSON is ignored.
|
|
1972
|
-
--mode=<option> Serves only one side of the endpoint for this request: `knowledge_base` serves its
|
|
1973
|
-
knowledge bases and `groq` serves its dataset. Omit it to serve every source the endpoint
|
|
1974
|
-
has. A request whose chosen side the endpoint doesn't have is refused. Deprecated: refused
|
|
1975
|
-
from API version `v2026-11-03`. Configure it on the MCP endpoint instead.
|
|
1976
|
-
<options: knowledge_base|groq>
|
|
1977
|
-
--perspective=<value> The perspective for GROQ queries: `published` (default), `previewDrafts`, `raw`, or a
|
|
1978
|
-
release. Deprecated: refused from API version `v2026-11-03`. Configure it on the MCP
|
|
1979
|
-
endpoint instead.
|
|
1980
|
-
--workspace=<value> The studio workspace to use. Replaces the dataset source's workspace for this request.
|
|
1981
|
-
Deprecated: refused from API version `v2026-11-03`. Configure it on the MCP endpoint
|
|
1982
|
-
instead.
|
|
1956
|
+
--heading_offset=<value> How many levels to shift markdown headings down, from `0` to `6`. Defaults to `1`, so `#`
|
|
1957
|
+
becomes `##`.
|
|
1958
|
+
--link-resolver=<value> A JSON array that adds `_url` fields to query results. Each item has `types` (document
|
|
1959
|
+
types), `baseUrl`, and an optional `slugExpression`, a GROQ expression that defaults to
|
|
1960
|
+
`slug.current`. Invalid JSON is ignored.
|
|
1983
1961
|
|
|
1984
1962
|
GLOBAL FLAGS
|
|
1985
1963
|
--json Format output as json.
|
|
@@ -2183,8 +2161,8 @@ FLAGS
|
|
|
2183
2161
|
--max-depth=<value> How many levels deep the crawl goes from the root URL. Only for type web.
|
|
2184
2162
|
--page-limit=<value> The maximum number of pages to crawl. The crawl can stop sooner when the knowledge
|
|
2185
2163
|
base reaches its source limit. Only for type web.
|
|
2186
|
-
--query=<value> A GROQ query that selects the documents, with an optional projection.
|
|
2187
|
-
|
|
2164
|
+
--query=<value> A GROQ query that selects the documents, with an optional projection. Each sync runs
|
|
2165
|
+
it again. Only for type sanity-dataset.
|
|
2188
2166
|
--sanity-dataset-id=<value> The dataset to read documents from. Only for type sanity-dataset.
|
|
2189
2167
|
--sanity-project-id=<value> The ID of the Sanity project to read documents from. You need full read access to the
|
|
2190
2168
|
dataset and, on its project, the Administrator or Developer role or a custom role that
|
|
@@ -2379,11 +2357,14 @@ List sources
|
|
|
2379
2357
|
|
|
2380
2358
|
```
|
|
2381
2359
|
USAGE
|
|
2382
|
-
$ sanity context sources list KNOWLEDGEBASEID [--json]
|
|
2360
|
+
$ sanity context sources list KNOWLEDGEBASEID [--json] [--limit <value>]
|
|
2383
2361
|
|
|
2384
2362
|
ARGUMENTS
|
|
2385
2363
|
KNOWLEDGEBASEID The knowledge base's ID (`kb...`), its `publicId`. Its UUID `id` is also accepted.
|
|
2386
2364
|
|
|
2365
|
+
FLAGS
|
|
2366
|
+
--limit=<value> The maximum number of items to return.
|
|
2367
|
+
|
|
2387
2368
|
GLOBAL FLAGS
|
|
2388
2369
|
--json Format output as json.
|
|
2389
2370
|
|
|
@@ -2550,12 +2531,15 @@ List a source's syncs
|
|
|
2550
2531
|
|
|
2551
2532
|
```
|
|
2552
2533
|
USAGE
|
|
2553
|
-
$ sanity context sources syncs list KNOWLEDGEBASEID SOURCEID [--json]
|
|
2534
|
+
$ sanity context sources syncs list KNOWLEDGEBASEID SOURCEID [--json] [--limit <value>]
|
|
2554
2535
|
|
|
2555
2536
|
ARGUMENTS
|
|
2556
2537
|
KNOWLEDGEBASEID The knowledge base's ID (`kb...`), its `publicId`. Its UUID `id` is also accepted.
|
|
2557
2538
|
SOURCEID The source's ID.
|
|
2558
2539
|
|
|
2540
|
+
FLAGS
|
|
2541
|
+
--limit=<value> The maximum number of items to return.
|
|
2542
|
+
|
|
2559
2543
|
GLOBAL FLAGS
|
|
2560
2544
|
--json Format output as json.
|
|
2561
2545
|
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { styleText } from 'node:util';
|
|
2
|
-
import { checkRequiredDependencies, checkStudioDependencyVersions, compareDependencyVersions } from '@sanity/cli-build/_internal/build';
|
|
2
|
+
import { checkRequiredDependencies, checkStudioDependencyVersions, compareDependencyVersions, getUnavailableVersionsWarning } from '@sanity/cli-build/_internal/build';
|
|
3
3
|
import { exitCodes, getLocalPackageVersion, isInteractive } from '@sanity/cli-core';
|
|
4
4
|
import { confirm, logSymbols, spinner } from '@sanity/cli-core/ux';
|
|
5
5
|
import { isWorkbenchApp } from '@sanity/workbench-cli';
|
|
@@ -62,6 +62,9 @@ export async function startStudioDevServer(options) {
|
|
|
62
62
|
} catch (err) {
|
|
63
63
|
output.warn(`Failed to compare local versions against auto-updating versions: ${err}`);
|
|
64
64
|
}
|
|
65
|
+
if (result?.unavailable?.length) {
|
|
66
|
+
output.warn(getUnavailableVersionsWarning(result.unavailable));
|
|
67
|
+
}
|
|
65
68
|
if (result?.unresolvedPrerelease.length) {
|
|
66
69
|
for (const mod of result.unresolvedPrerelease){
|
|
67
70
|
output.warn(`Your local version of ${mod.pkg} (${mod.version}) is a prerelease not available on the auto-updates CDN. The locally installed version will be used.`);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/actions/dev/servers/startStudioDevServer.ts"],"sourcesContent":["import {styleText} from 'node:util'\n\nimport {\n checkRequiredDependencies,\n checkStudioDependencyVersions,\n compareDependencyVersions,\n} from '@sanity/cli-build/_internal/build'\nimport {exitCodes, getLocalPackageVersion, isInteractive} from '@sanity/cli-core'\nimport {confirm, logSymbols, spinner} from '@sanity/cli-core/ux'\nimport {isWorkbenchApp} from '@sanity/workbench-cli'\nimport {parse as semverParse} from 'semver'\n\nimport {startDevServer} from '../../../server/devServer.js'\nimport {gracefulServerDeath} from '../../../server/gracefulServerDeath.js'\nimport {getProjectById} from '../../../services/projects.js'\nimport {getAppId} from '../../../util/appId.js'\nimport {getPackageManagerChoice} from '../../../util/packageManager/packageManagerChoice.js'\nimport {upgradePackages} from '../../../util/packageManager/upgradePackages.js'\nimport {hasLocalUnclaimedProject} from '../../../util/unclaimedProjects.js'\nimport {checkDependenciesEventListenerFactory} from '../../build/eventListenerFactory.js'\nimport {shouldAutoUpdate} from '../../build/shouldAutoUpdate.js'\nimport {devDebug} from '../devDebug.js'\nimport {type DevActionOptions, type StartDevServerResult} from '../types.js'\nimport {getDashboardAppURL} from './getDashboardAppUrl.js'\nimport {getDevServerConfig} from './getDevServerConfig.js'\n\nexport async function startStudioDevServer(\n options: DevActionOptions,\n): Promise<StartDevServerResult> {\n const {announceUrl = true, cliConfig, flags, httpPort, output, workDir} = options\n const projectId = cliConfig?.api?.projectId\n let organizationId: string | undefined\n\n // Workbench apps don't load through the dashboard, so the flag has no\n // meaning for them and is ignored.\n const loadInDashboard = flags['load-in-dashboard'] && !isWorkbenchApp(cliConfig?.app)\n\n // Check studio dependency versions\n await checkStudioDependencyVersions(workDir, output)\n\n const {installedSanityVersion} = await checkRequiredDependencies({\n ...options,\n ...checkDependenciesEventListenerFactory(output),\n })\n\n // Check if auto-updates are enabled\n const autoUpdatesEnabled = shouldAutoUpdate({cliConfig, flags, output})\n\n if (autoUpdatesEnabled) {\n // Get the clean version without build metadata: https://semver.org/#spec-item-10\n const cleanSanityVersion = semverParse(installedSanityVersion)?.version\n if (!cleanSanityVersion) {\n throw new Error(`Failed to parse installed Sanity version: ${installedSanityVersion}`)\n }\n\n const sanityDependencies = [\n {name: 'sanity', version: cleanSanityVersion},\n {name: '@sanity/vision', version: cleanSanityVersion},\n ]\n\n output.log(`${logSymbols.info} Running with auto-updates enabled`)\n\n // Check local versions against deployed versions\n let result: Awaited<ReturnType<typeof compareDependencyVersions>> | undefined\n\n const appId = getAppId(cliConfig)\n\n try {\n result = await compareDependencyVersions(sanityDependencies, workDir, {appId})\n } catch (err) {\n output.warn(`Failed to compare local versions against auto-updating versions: ${err}`)\n }\n\n if (result?.unresolvedPrerelease.length) {\n for (const mod of result.unresolvedPrerelease) {\n output.warn(\n `Your local version of ${mod.pkg} (${mod.version}) is a prerelease not available on the auto-updates CDN. The locally installed version will be used.`,\n )\n }\n }\n\n // mismatch between local and auto-updating dependencies\n if (result?.mismatched.length) {\n const message =\n `The following local package versions are different from the versions currently served at runtime.\\n` +\n `When using auto updates, we recommend that you run with the same versions locally as will be used when deploying.\\n\\n` +\n `${result.mismatched.map((mod) => ` - ${mod.pkg} (local version: ${mod.installed}, runtime version: ${mod.remote})`).join('\\n')}\\n\\n`\n\n if (isInteractive()) {\n const shouldUpgrade = await confirm({\n default: true,\n message: styleText('yellow', `${message}Do you want to upgrade local versions?`),\n })\n if (shouldUpgrade) {\n await upgradePackages(\n {\n packageManager: (await getPackageManagerChoice(workDir, {interactive: false})).chosen,\n packages: result.mismatched.map((res) => [res.pkg, res.remote]),\n },\n {output, workDir},\n )\n }\n } else {\n // In this case we warn the user but we don't ask them if they want to upgrade because it's not interactive.\n output.log(styleText('yellow', message))\n }\n }\n }\n\n if (cliConfig?.schemaExtraction?.enabled) {\n output.log(`${logSymbols.info} Running dev server with schema extraction enabled`)\n }\n\n const config = getDevServerConfig({cliConfig, flags, httpPort, output, workDir})\n\n if (loadInDashboard) {\n if (!projectId) {\n output.error('Project Id is required to load in dashboard', {exit: exitCodes.RUNTIME_ERROR})\n }\n\n try {\n const project = await getProjectById(projectId!)\n organizationId = project.organizationId!\n } catch (error) {\n devDebug('Error getting organization id from project id', error)\n output.error('Failed to get organization id from project id', {exit: exitCodes.RUNTIME_ERROR})\n }\n }\n\n try {\n const startTime = Date.now()\n const spin = spinner('Starting dev server').start()\n const {close, server} = await startDevServer(config)\n\n const {info: loggerInfo} = server.config.logger\n const {port} = server.config.server\n const httpHost = config.httpHost || 'localhost'\n\n if (loadInDashboard) {\n spin.succeed()\n\n output.log(`Dev server started on port ${port}`)\n output.log(`View your studio in the Sanity dashboard here:`)\n output.log(\n styleText(\n ['blue', 'underline'],\n await getDashboardAppURL({\n httpHost,\n httpPort: port,\n organizationId: organizationId!,\n }),\n ),\n )\n } else {\n const startupDuration = Date.now() - startTime\n const url = withUnclaimedSignInHash(\n `http://${httpHost || 'localhost'}:${port}${config.basePath}`,\n projectId,\n )\n const appType = 'Sanity Studio'\n\n const viteVersion = await getLocalPackageVersion('vite', import.meta.url)\n spin.succeed()\n\n loggerInfo(\n `${appType} ` +\n `using ${styleText('cyan', `vite@${viteVersion}`)} ` +\n `ready in ${styleText('cyan', `${Math.ceil(startupDuration)}ms`)}` +\n (announceUrl ? ` and running at ${styleText('cyan', url)}` : ''),\n )\n }\n\n return {close, server, started: true}\n } catch (err) {\n devDebug('Error starting studio dev server', err)\n throw gracefulServerDeath('dev', config.httpHost, config.httpPort, err)\n }\n}\n\nfunction withUnclaimedSignInHash(url: string, projectId: string | undefined): string {\n const token = process.env.SANITY_AUTH_TOKEN\n if (!token || !projectId || !hasLocalUnclaimedProject(projectId)) return url\n return `${url}#token=${encodeURIComponent(token)}`\n}\n"],"names":["styleText","checkRequiredDependencies","checkStudioDependencyVersions","compareDependencyVersions","exitCodes","getLocalPackageVersion","isInteractive","confirm","logSymbols","spinner","isWorkbenchApp","parse","semverParse","startDevServer","gracefulServerDeath","getProjectById","getAppId","getPackageManagerChoice","upgradePackages","hasLocalUnclaimedProject","checkDependenciesEventListenerFactory","shouldAutoUpdate","devDebug","getDashboardAppURL","getDevServerConfig","startStudioDevServer","options","announceUrl","cliConfig","flags","httpPort","output","workDir","projectId","api","organizationId","loadInDashboard","app","installedSanityVersion","autoUpdatesEnabled","cleanSanityVersion","version","Error","sanityDependencies","name","log","info","result","appId","err","warn","unresolvedPrerelease","length","mod","pkg","mismatched","message","map","installed","remote","join","shouldUpgrade","default","packageManager","interactive","chosen","packages","res","schemaExtraction","enabled","config","error","exit","RUNTIME_ERROR","project","startTime","Date","now","spin","start","close","server","loggerInfo","logger","port","httpHost","succeed","startupDuration","url","withUnclaimedSignInHash","basePath","appType","viteVersion","Math","ceil","started","token","process","env","SANITY_AUTH_TOKEN","encodeURIComponent"],"mappings":"AAAA,SAAQA,SAAS,QAAO,YAAW;AAEnC,SACEC,yB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,GAAGA,IAAI,OAAO,EAAEY,mBAAmBJ,QAAQ;AACpD"}
|
|
1
|
+
{"version":3,"sources":["../../../../src/actions/dev/servers/startStudioDevServer.ts"],"sourcesContent":["import {styleText} from 'node:util'\n\nimport {\n checkRequiredDependencies,\n checkStudioDependencyVersions,\n compareDependencyVersions,\n getUnavailableVersionsWarning,\n} from '@sanity/cli-build/_internal/build'\nimport {exitCodes, getLocalPackageVersion, isInteractive} from '@sanity/cli-core'\nimport {confirm, logSymbols, spinner} from '@sanity/cli-core/ux'\nimport {isWorkbenchApp} from '@sanity/workbench-cli'\nimport {parse as semverParse} from 'semver'\n\nimport {startDevServer} from '../../../server/devServer.js'\nimport {gracefulServerDeath} from '../../../server/gracefulServerDeath.js'\nimport {getProjectById} from '../../../services/projects.js'\nimport {getAppId} from '../../../util/appId.js'\nimport {getPackageManagerChoice} from '../../../util/packageManager/packageManagerChoice.js'\nimport {upgradePackages} from '../../../util/packageManager/upgradePackages.js'\nimport {hasLocalUnclaimedProject} from '../../../util/unclaimedProjects.js'\nimport {checkDependenciesEventListenerFactory} from '../../build/eventListenerFactory.js'\nimport {shouldAutoUpdate} from '../../build/shouldAutoUpdate.js'\nimport {devDebug} from '../devDebug.js'\nimport {type DevActionOptions, type StartDevServerResult} from '../types.js'\nimport {getDashboardAppURL} from './getDashboardAppUrl.js'\nimport {getDevServerConfig} from './getDevServerConfig.js'\n\nexport async function startStudioDevServer(\n options: DevActionOptions,\n): Promise<StartDevServerResult> {\n const {announceUrl = true, cliConfig, flags, httpPort, output, workDir} = options\n const projectId = cliConfig?.api?.projectId\n let organizationId: string | undefined\n\n // Workbench apps don't load through the dashboard, so the flag has no\n // meaning for them and is ignored.\n const loadInDashboard = flags['load-in-dashboard'] && !isWorkbenchApp(cliConfig?.app)\n\n // Check studio dependency versions\n await checkStudioDependencyVersions(workDir, output)\n\n const {installedSanityVersion} = await checkRequiredDependencies({\n ...options,\n ...checkDependenciesEventListenerFactory(output),\n })\n\n // Check if auto-updates are enabled\n const autoUpdatesEnabled = shouldAutoUpdate({cliConfig, flags, output})\n\n if (autoUpdatesEnabled) {\n // Get the clean version without build metadata: https://semver.org/#spec-item-10\n const cleanSanityVersion = semverParse(installedSanityVersion)?.version\n if (!cleanSanityVersion) {\n throw new Error(`Failed to parse installed Sanity version: ${installedSanityVersion}`)\n }\n\n const sanityDependencies = [\n {name: 'sanity', version: cleanSanityVersion},\n {name: '@sanity/vision', version: cleanSanityVersion},\n ]\n\n output.log(`${logSymbols.info} Running with auto-updates enabled`)\n\n // Check local versions against deployed versions\n let result: Awaited<ReturnType<typeof compareDependencyVersions>> | undefined\n\n const appId = getAppId(cliConfig)\n\n try {\n result = await compareDependencyVersions(sanityDependencies, workDir, {appId})\n } catch (err) {\n output.warn(`Failed to compare local versions against auto-updating versions: ${err}`)\n }\n\n if (result?.unavailable?.length) {\n output.warn(getUnavailableVersionsWarning(result.unavailable))\n }\n\n if (result?.unresolvedPrerelease.length) {\n for (const mod of result.unresolvedPrerelease) {\n output.warn(\n `Your local version of ${mod.pkg} (${mod.version}) is a prerelease not available on the auto-updates CDN. The locally installed version will be used.`,\n )\n }\n }\n\n // mismatch between local and auto-updating dependencies\n if (result?.mismatched.length) {\n const message =\n `The following local package versions are different from the versions currently served at runtime.\\n` +\n `When using auto updates, we recommend that you run with the same versions locally as will be used when deploying.\\n\\n` +\n `${result.mismatched.map((mod) => ` - ${mod.pkg} (local version: ${mod.installed}, runtime version: ${mod.remote})`).join('\\n')}\\n\\n`\n\n if (isInteractive()) {\n const shouldUpgrade = await confirm({\n default: true,\n message: styleText('yellow', `${message}Do you want to upgrade local versions?`),\n })\n if (shouldUpgrade) {\n await upgradePackages(\n {\n packageManager: (await getPackageManagerChoice(workDir, {interactive: false})).chosen,\n packages: result.mismatched.map((res) => [res.pkg, res.remote]),\n },\n {output, workDir},\n )\n }\n } else {\n // In this case we warn the user but we don't ask them if they want to upgrade because it's not interactive.\n output.log(styleText('yellow', message))\n }\n }\n }\n\n if (cliConfig?.schemaExtraction?.enabled) {\n output.log(`${logSymbols.info} Running dev server with schema extraction enabled`)\n }\n\n const config = getDevServerConfig({cliConfig, flags, httpPort, output, workDir})\n\n if (loadInDashboard) {\n if (!projectId) {\n output.error('Project Id is required to load in dashboard', {exit: exitCodes.RUNTIME_ERROR})\n }\n\n try {\n const project = await getProjectById(projectId!)\n organizationId = project.organizationId!\n } catch (error) {\n devDebug('Error getting organization id from project id', error)\n output.error('Failed to get organization id from project id', {exit: exitCodes.RUNTIME_ERROR})\n }\n }\n\n try {\n const startTime = Date.now()\n const spin = spinner('Starting dev server').start()\n const {close, server} = await startDevServer(config)\n\n const {info: loggerInfo} = server.config.logger\n const {port} = server.config.server\n const httpHost = config.httpHost || 'localhost'\n\n if (loadInDashboard) {\n spin.succeed()\n\n output.log(`Dev server started on port ${port}`)\n output.log(`View your studio in the Sanity dashboard here:`)\n output.log(\n styleText(\n ['blue', 'underline'],\n await getDashboardAppURL({\n httpHost,\n httpPort: port,\n organizationId: organizationId!,\n }),\n ),\n )\n } else {\n const startupDuration = Date.now() - startTime\n const url = withUnclaimedSignInHash(\n `http://${httpHost || 'localhost'}:${port}${config.basePath}`,\n projectId,\n )\n const appType = 'Sanity Studio'\n\n const viteVersion = await getLocalPackageVersion('vite', import.meta.url)\n spin.succeed()\n\n loggerInfo(\n `${appType} ` +\n `using ${styleText('cyan', `vite@${viteVersion}`)} ` +\n `ready in ${styleText('cyan', `${Math.ceil(startupDuration)}ms`)}` +\n (announceUrl ? ` and running at ${styleText('cyan', url)}` : ''),\n )\n }\n\n return {close, server, started: true}\n } catch (err) {\n devDebug('Error starting studio dev server', err)\n throw gracefulServerDeath('dev', config.httpHost, config.httpPort, err)\n }\n}\n\nfunction withUnclaimedSignInHash(url: string, projectId: string | undefined): string {\n const token = process.env.SANITY_AUTH_TOKEN\n if (!token || !projectId || !hasLocalUnclaimedProject(projectId)) return url\n return `${url}#token=${encodeURIComponent(token)}`\n}\n"],"names":["styleText","checkRequiredDependencies","checkStudioDependencyVersions","compareDependencyVersions","getUnavailableVersionsWarning","exitCodes","getLocalPackageVersion","isInteractive","confirm","logSymbols","spinner","isWorkbenchApp","parse","semverParse","startDevServer","gracefulServerDeath","getProjectById","getAppId","getPackageManagerChoice","upgradePackages","hasLocalUnclaimedProject","checkDependenciesEventListenerFactory","shouldAutoUpdate","devDebug","getDashboardAppURL","getDevServerConfig","startStudioDevServer","options","announceUrl","cliConfig","flags","httpPort","output","workDir","projectId","api","organizationId","loadInDashboard","app","installedSanityVersion","autoUpdatesEnabled","cleanSanityVersion","version","Error","sanityDependencies","name","log","info","result","appId","err","warn","unavailable","length","unresolvedPrerelease","mod","pkg","mismatched","message","map","installed","remote","join","shouldUpgrade","default","packageManager","interactive","chosen","packages","res","schemaExtraction","enabled","config","error","exit","RUNTIME_ERROR","project","startTime","Date","now","spin","start","close","server","loggerInfo","logger","port","httpHost","succeed","startupDuration","url","withUnclaimedSignInHash","basePath","appType","viteVersion","Math","ceil","started","token","process","env","SANITY_AUTH_TOKEN","encodeURIComponent"],"mappings":"AAAA,SAAQA,SAAS,QAAO,YAAW;AAEnC,SACEC,yBAAyB,EACzBC,6BAA6B,EAC7BC,yBAAyB,EACzBC,6BAA6B,QACxB,oCAAmC;AAC1C,SAAQC,SAAS,EAAEC,sBAAsB,EAAEC,aAAa,QAAO,mBAAkB;AACjF,SAAQC,OAAO,EAAEC,UAAU,EAAEC,OAAO,QAAO,sBAAqB;AAChE,SAAQC,cAAc,QAAO,wBAAuB;AACpD,SAAQC,SAASC,WAAW,QAAO,SAAQ;AAE3C,SAAQC,cAAc,QAAO,+BAA8B;AAC3D,SAAQC,mBAAmB,QAAO,yCAAwC;AAC1E,SAAQC,cAAc,QAAO,gCAA+B;AAC5D,SAAQC,QAAQ,QAAO,yBAAwB;AAC/C,SAAQC,uBAAuB,QAAO,uDAAsD;AAC5F,SAAQC,eAAe,QAAO,kDAAiD;AAC/E,SAAQC,wBAAwB,QAAO,qCAAoC;AAC3E,SAAQC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AY,CAAC,EAAED,OAAOd,OAAOoB,QAAQ,EAAE,EAC7D1D;YAEF,MAAM2D,UAAU;YAEhB,MAAMC,cAAc,MAAMxF,uBAAuB,QAAQ,YAAYoF,GAAG;YACxEV,KAAKQ,OAAO;YAEZJ,WACE,GAAGS,QAAQ,CAAC,CAAC,GACX,CAAC,MAAM,EAAE7F,UAAU,QAAQ,CAAC,KAAK,EAAE8F,aAAa,EAAE,CAAC,CAAC,GACpD,CAAC,SAAS,EAAE9F,UAAU,QAAQ,GAAG+F,KAAKC,IAAI,CAACP,iBAAiB,EAAE,CAAC,GAAG,GACjE7D,CAAAA,cAAc,CAAC,gBAAgB,EAAE5B,UAAU,QAAQ0F,MAAM,GAAG,EAAC;QAEpE;QAEA,OAAO;YAACR;YAAOC;YAAQc,SAAS;QAAI;IACtC,EAAE,OAAO/C,KAAK;QACZ3B,SAAS,oCAAoC2B;QAC7C,MAAMnC,oBAAoB,OAAOyD,OAAOe,QAAQ,EAAEf,OAAOzC,QAAQ,EAAEmB;IACrE;AACF;AAEA,SAASyC,wBAAwBD,GAAW,EAAExD,SAA6B;IACzE,MAAMgE,QAAQC,QAAQC,GAAG,CAACC,iBAAiB;IAC3C,IAAI,CAACH,SAAS,CAAChE,aAAa,CAACd,yBAAyBc,YAAY,OAAOwD;IACzE,OAAO,GAAGA,IAAI,OAAO,EAAEY,mBAAmBJ,QAAQ;AACpD"}
|
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
import { subdebug } from '@sanity/cli-core';
|
|
2
|
-
import {
|
|
3
|
-
import { getSkillsCliAgentDisplayName, isUniversalSkillsCliAgentByEditorName, UNIVERSAL_SKILLS_DIR } from '../mcp/editorConfigs.js';
|
|
4
|
-
import { SKILLS_BIN_PATH } from './setupSkills.js';
|
|
2
|
+
import { getSkillsCliAgentDisplayName, getSkillsCliAgentDisplayNameById, isUniversalSkillsCliAgentByEditorName, UNIVERSAL_SKILLS_DIR } from '../mcp/editorConfigs.js';
|
|
5
3
|
const debug = subdebug('skills:state');
|
|
4
|
+
/** Upper bound for reading the global skill state (checked between steps). */ const LIST_TIMEOUT_MS = 10_000;
|
|
6
5
|
/** Normalizes path separators to `/` so comparisons are OS-agnostic. */ function toPosixPath(value) {
|
|
7
6
|
return value.replaceAll('\\', '/');
|
|
8
7
|
}
|
|
@@ -11,22 +10,22 @@ const debug = subdebug('skills:state');
|
|
|
11
10
|
* path is under `.agents/skills`. The `skills` CLI installs universal-agent
|
|
12
11
|
* skills there directly (rather than under an agent-specific directory).
|
|
13
12
|
*/ function isUniversalSkillPath(skillPath) {
|
|
14
|
-
if (typeof skillPath !== 'string') return false;
|
|
15
13
|
return toPosixPath(skillPath).includes(`${UNIVERSAL_SKILLS_DIR}/`);
|
|
16
14
|
}
|
|
17
15
|
/**
|
|
18
|
-
*
|
|
19
|
-
* display names that have every skill in
|
|
16
|
+
* Lists global skills via the bundled `skills` package's `listSkills` and
|
|
17
|
+
* returns the set of agent display names that have every skill in
|
|
18
|
+
* `skillNames` installed globally.
|
|
20
19
|
* Agents missing any of the skills are excluded, so they get a (idempotent)
|
|
21
20
|
* re-install that fills the gap.
|
|
22
21
|
*
|
|
23
22
|
* "Universal" agents (those whose `skillsDir` is the shared `.agents/skills`
|
|
24
23
|
* directory) are credited whenever every requested skill lives in that shared
|
|
25
|
-
* directory. `
|
|
24
|
+
* directory. `listSkills` only attributes a skill to agents it independently
|
|
26
25
|
* detects, so a universal editor we detected may be absent from the output even
|
|
27
26
|
* though it reads from the shared directory and already has the skills.
|
|
28
27
|
*
|
|
29
|
-
* Any failure (
|
|
28
|
+
* Any failure (import, read, timeout) is debug-logged and
|
|
30
29
|
* resolved with an empty set. Callers should treat that as "treat all agents
|
|
31
30
|
* as not installed" — re-installing is idempotent, so over-installing is
|
|
32
31
|
* safer than skipping based on a flaky probe.
|
|
@@ -35,40 +34,28 @@ const debug = subdebug('skills:state');
|
|
|
35
34
|
const empty = {
|
|
36
35
|
installedAgentDisplayNames: new Set()
|
|
37
36
|
};
|
|
38
|
-
let
|
|
37
|
+
let entries;
|
|
39
38
|
try {
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
timeout: 10_000
|
|
39
|
+
// Loaded lazily so a problem with the `skills` package only affects this
|
|
40
|
+
// best-effort probe, not every command that imports this module.
|
|
41
|
+
// eslint-disable-next-line no-restricted-syntax -- package import, not a file path
|
|
42
|
+
const { listSkills } = await import('skills');
|
|
43
|
+
const result = await listSkills({
|
|
44
|
+
scope: 'global',
|
|
45
|
+
signal: AbortSignal.timeout(LIST_TIMEOUT_MS)
|
|
48
46
|
});
|
|
49
|
-
|
|
47
|
+
entries = result.skills;
|
|
50
48
|
} catch (error) {
|
|
51
49
|
debug('skills list failed: %O', error);
|
|
52
50
|
return empty;
|
|
53
51
|
}
|
|
54
|
-
let parsed;
|
|
55
|
-
try {
|
|
56
|
-
parsed = JSON.parse(stdout);
|
|
57
|
-
} catch (error) {
|
|
58
|
-
debug('Failed to parse skills list JSON: %O', error);
|
|
59
|
-
return empty;
|
|
60
|
-
}
|
|
61
|
-
if (!Array.isArray(parsed)) {
|
|
62
|
-
debug('Unexpected skills list JSON shape (not an array)');
|
|
63
|
-
return empty;
|
|
64
|
-
}
|
|
65
|
-
const entries = parsed;
|
|
66
52
|
const agentSets = skillNames.map((skillName)=>{
|
|
67
|
-
const match = entries.find((entry)=>entry
|
|
68
|
-
if (!match
|
|
53
|
+
const match = entries.find((entry)=>entry.name === skillName);
|
|
54
|
+
if (!match) {
|
|
69
55
|
return new Set();
|
|
70
56
|
}
|
|
71
|
-
|
|
57
|
+
// `listSkills` reports agent IDs; callers match on display names.
|
|
58
|
+
return new Set(match.agents.map((agentId)=>getSkillsCliAgentDisplayNameById(agentId) ?? agentId));
|
|
72
59
|
});
|
|
73
60
|
const installed = new Set([
|
|
74
61
|
...agentSets[0] ?? []
|
|
@@ -78,7 +65,7 @@ const debug = subdebug('skills:state');
|
|
|
78
65
|
// detected universal editor that the `skills` CLI didn't independently detect
|
|
79
66
|
// would be treated as missing and trigger a redundant re-install.
|
|
80
67
|
const allSkillsInUniversalDir = skillNames.length > 0 && skillNames.every((skillName)=>{
|
|
81
|
-
const match = entries.find((entry)=>entry
|
|
68
|
+
const match = entries.find((entry)=>entry.name === skillName);
|
|
82
69
|
return match ? isUniversalSkillPath(match.path) : false;
|
|
83
70
|
});
|
|
84
71
|
if (allSkillsInUniversalDir) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/actions/skills/readSkillState.ts"],"sourcesContent":["import {subdebug} from '@sanity/cli-core'\nimport {
|
|
1
|
+
{"version":3,"sources":["../../../src/actions/skills/readSkillState.ts"],"sourcesContent":["import {subdebug} from '@sanity/cli-core'\nimport {type InstalledSkillInfo} from 'skills'\n\nimport {\n getSkillsCliAgentDisplayName,\n getSkillsCliAgentDisplayNameById,\n isUniversalSkillsCliAgentByEditorName,\n UNIVERSAL_SKILLS_DIR,\n} from '../mcp/editorConfigs.js'\nimport {type Editor} from '../mcp/types.js'\n\nconst debug = subdebug('skills:state')\n\ninterface ReadSkillStateOptions {\n /**\n * Detected editors. Used to credit \"universal\" agents (those that read from\n * the shared `.agents/skills` directory) when the skills live there — see\n * note in `readSkillState`.\n */\n editors: Editor[]\n /** Names of the skills to look up (match the `name` of `listSkills()` entries). */\n skillNames: string[]\n}\n\ninterface SkillState {\n /** Display names of agents that have all of these skills installed globally. */\n installedAgentDisplayNames: Set<string>\n}\n\n/** Upper bound for reading the global skill state (checked between steps). */\nconst LIST_TIMEOUT_MS = 10_000\n\n/** Normalizes path separators to `/` so comparisons are OS-agnostic. */\nfunction toPosixPath(value: string): string {\n return value.replaceAll('\\\\', '/')\n}\n\n/**\n * A skill lives in the shared universal skills directory when its canonical\n * path is under `.agents/skills`. The `skills` CLI installs universal-agent\n * skills there directly (rather than under an agent-specific directory).\n */\nfunction isUniversalSkillPath(skillPath: string): boolean {\n return toPosixPath(skillPath).includes(`${UNIVERSAL_SKILLS_DIR}/`)\n}\n\n/**\n * Lists global skills via the bundled `skills` package's `listSkills` and\n * returns the set of agent display names that have every skill in\n * `skillNames` installed globally.\n * Agents missing any of the skills are excluded, so they get a (idempotent)\n * re-install that fills the gap.\n *\n * \"Universal\" agents (those whose `skillsDir` is the shared `.agents/skills`\n * directory) are credited whenever every requested skill lives in that shared\n * directory. `listSkills` only attributes a skill to agents it independently\n * detects, so a universal editor we detected may be absent from the output even\n * though it reads from the shared directory and already has the skills.\n *\n * Any failure (import, read, timeout) is debug-logged and\n * resolved with an empty set. Callers should treat that as \"treat all agents\n * as not installed\" — re-installing is idempotent, so over-installing is\n * safer than skipping based on a flaky probe.\n */\nexport async function readSkillState(opts: ReadSkillStateOptions): Promise<SkillState> {\n const {editors, skillNames} = opts\n const empty: SkillState = {installedAgentDisplayNames: new Set()}\n\n let entries: readonly InstalledSkillInfo[]\n try {\n // Loaded lazily so a problem with the `skills` package only affects this\n // best-effort probe, not every command that imports this module.\n // eslint-disable-next-line no-restricted-syntax -- package import, not a file path\n const {listSkills} = await import('skills')\n const result = await listSkills({\n scope: 'global',\n signal: AbortSignal.timeout(LIST_TIMEOUT_MS),\n })\n entries = result.skills\n } catch (error) {\n debug('skills list failed: %O', error)\n return empty\n }\n\n const agentSets = skillNames.map((skillName) => {\n const match = entries.find((entry) => entry.name === skillName)\n if (!match) {\n return new Set<string>()\n }\n // `listSkills` reports agent IDs; callers match on display names.\n return new Set(\n match.agents.map((agentId) => getSkillsCliAgentDisplayNameById(agentId) ?? agentId),\n )\n })\n\n const installed = new Set(\n [...(agentSets[0] ?? [])].filter((agent) => agentSets.every((set) => set.has(agent))),\n )\n\n // Universal agents share the `.agents/skills` directory. If every requested\n // skill lives there, credit each detected universal editor — otherwise a\n // detected universal editor that the `skills` CLI didn't independently detect\n // would be treated as missing and trigger a redundant re-install.\n const allSkillsInUniversalDir =\n skillNames.length > 0 &&\n skillNames.every((skillName) => {\n const match = entries.find((entry) => entry.name === skillName)\n return match ? isUniversalSkillPath(match.path) : false\n })\n\n if (allSkillsInUniversalDir) {\n for (const editor of editors) {\n if (!isUniversalSkillsCliAgentByEditorName(editor.name)) continue\n const displayName = getSkillsCliAgentDisplayName(editor.name)\n if (displayName) installed.add(displayName)\n }\n }\n\n return {installedAgentDisplayNames: installed}\n}\n"],"names":["subdebug","getSkillsCliAgentDisplayName","getSkillsCliAgentDisplayNameById","isUniversalSkillsCliAgentByEditorName","UNIVERSAL_SKILLS_DIR","debug","LIST_TIMEOUT_MS","toPosixPath","value","replaceAll","isUniversalSkillPath","skillPath","includes","readSkillState","opts","editors","skillNames","empty","installedAgentDisplayNames","Set","entries","listSkills","result","scope","signal","AbortSignal","timeout","skills","error","agentSets","map","skillName","match","find","entry","name","agents","agentId","installed","filter","agent","every","set","has","allSkillsInUniversalDir","length","path","editor","displayName","add"],"mappings":"AAAA,SAAQA,QAAQ,QAAO,mBAAkB;AAGzC,SACEC,4BAA4B,EAC5BC,gCAAgC,EAChCC,qCAAqC,EACrCC,oBAAoB,QACf,0BAAyB;AAGhC,MAAMC,QAAQL,SAAS;AAkBvB,4EAA4E,GAC5E,MAAMM,kBAAkB;AAExB,sEAAsE,GACtE,SAASC,YAAYC,KAAa;IAChC,OAAOA,MAAMC,UAAU,CAAC,MAAM;AAChC;AAEA;;;;CAIC,GACD,SAASC,qBAAqBC,SAAiB;IAC7C,OAAOJ,YAAYI,WAAWC,QAAQ,CAAC,GAAGR,qBAAqB,CAAC,CAAC;AACnE;AAEA;;;;;;;;;;;;;;;;;CAiBC,GACD,OAAO,eAAeS,eAAeC,IAA2B;IAC9D,MAAM,EAACC,OAAO,EAAEC,UAAU,EAAC,GAAGF;IAC9B,MAAMG,QAAoB;QAACC,4BAA4B,IAAIC;IAAK;IAEhE,IAAIC;IACJ,IAAI;QACF,yEAAyE;QACzE,iEAAiE;QACjE,mFAAmF;QACnF,MAAM,EAACC,UAAU,EAAC,GAAG,MAAM,MAAM,CAAC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util';
|
|
3
2
|
import { subdebug } from '@sanity/cli-core';
|
|
4
3
|
import { getErrorMessage, toError } from '@sanity/cli-core/errors';
|
|
5
4
|
import { logSymbols, spinner } from '@sanity/cli-core/ux';
|
|
6
|
-
import { execa } from 'execa';
|
|
7
5
|
import { getSkillsCliAgentDisplayNameById, getSkillsCliAgentSkillsDir, UNIVERSAL_SKILLS_DIR } from '../mcp/editorConfigs.js';
|
|
8
6
|
const skillsDebug = subdebug('skills:setup');
|
|
9
|
-
/** Source repo for the bundled `skills`
|
|
7
|
+
/** Source repo for the bundled `skills` package. See https://www.sanity.io/docs/ai/skills. */ export const SANITY_SKILLS_REPO = 'sanity-io/agent-toolkit';
|
|
10
8
|
/** Names of the skills we install — must match the entries in the source repo. */ export const SANITY_SKILL_NAMES = [
|
|
11
9
|
'sanity-best-practices',
|
|
12
10
|
'sanity-migration'
|
|
13
11
|
];
|
|
14
|
-
/**
|
|
15
|
-
* Absolute path to the bundled `skills` CLI bin. Resolved once at module load
|
|
16
|
-
* via `import.meta.resolve` so we run the version pinned in our package.json
|
|
17
|
-
* instead of paying the `npx -y` registry lookup at runtime.
|
|
18
|
-
*/ export const SKILLS_BIN_PATH = fileURLToPath(import.meta.resolve('skills/bin/cli.mjs', import.meta.url));
|
|
12
|
+
/** Upper bound for fetching and installing the skills (checked between steps). */ const INSTALL_TIMEOUT_MS = 90_000;
|
|
19
13
|
/**
|
|
20
14
|
* Prints a short summary beneath the success line: the skills that were
|
|
21
15
|
* installed, grouped by where they live. Universal agents share
|
|
@@ -52,7 +46,9 @@ const skillsDebug = subdebug('skills:setup');
|
|
|
52
46
|
output.log('');
|
|
53
47
|
}
|
|
54
48
|
/**
|
|
55
|
-
*
|
|
49
|
+
* Installs the Sanity skills globally for the given agents using the bundled
|
|
50
|
+
* `skills` package's programmatic API (equivalent to
|
|
51
|
+
* `skills add <repo> --skill <names> -g -a <agent>... -y`). Failures are
|
|
56
52
|
* surfaced as warnings and never throw — skills install is best-effort and
|
|
57
53
|
* must not abort `sanity init`.
|
|
58
54
|
*/ export async function setupSkills(options) {
|
|
@@ -67,33 +63,40 @@ const skillsDebug = subdebug('skills:setup');
|
|
|
67
63
|
skipped: true
|
|
68
64
|
};
|
|
69
65
|
}
|
|
70
|
-
|
|
71
|
-
SKILLS_BIN_PATH,
|
|
72
|
-
'add',
|
|
73
|
-
SANITY_SKILLS_REPO,
|
|
74
|
-
'--skill',
|
|
75
|
-
...SANITY_SKILL_NAMES,
|
|
76
|
-
'-g',
|
|
77
|
-
...uniqueAgents.flatMap((agent)=>[
|
|
78
|
-
'-a',
|
|
79
|
-
agent
|
|
80
|
-
]),
|
|
81
|
-
'-y'
|
|
82
|
-
];
|
|
83
|
-
skillsDebug('Running: %s %s', process.execPath, args.join(' '));
|
|
66
|
+
skillsDebug('Installing %s from %s globally for agents: %s', SANITY_SKILL_NAMES.join(', '), SANITY_SKILLS_REPO, uniqueAgents.join(', '));
|
|
84
67
|
const spin = spinner('Installing Sanity agent skills').start();
|
|
85
68
|
try {
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
69
|
+
// Loaded lazily so a problem with the `skills` package only affects this
|
|
70
|
+
// best-effort step, not every command that imports this module.
|
|
71
|
+
// eslint-disable-next-line no-restricted-syntax -- package import, not a file path
|
|
72
|
+
const { installSkills } = await import('skills');
|
|
73
|
+
const result = await installSkills(SANITY_SKILLS_REPO, {
|
|
74
|
+
agents: uniqueAgents,
|
|
75
|
+
onWarning: (warning)=>skillsDebug('skills warning: %s', warning.message),
|
|
76
|
+
scope: 'global',
|
|
77
|
+
signal: AbortSignal.timeout(INSTALL_TIMEOUT_MS),
|
|
78
|
+
skills: SANITY_SKILL_NAMES
|
|
89
79
|
});
|
|
90
|
-
skillsDebug('skills
|
|
91
|
-
skillsDebug('skills stderr: %s', result.stderr);
|
|
80
|
+
skillsDebug('skills install result: %O', result);
|
|
92
81
|
spin.stop();
|
|
93
|
-
|
|
94
|
-
|
|
82
|
+
const failedAgents = new Set(result.failed.map((failure)=>failure.agent));
|
|
83
|
+
const installedAgents = uniqueAgents.filter((agent)=>!failedAgents.has(agent));
|
|
84
|
+
if (installedAgents.length > 0) {
|
|
85
|
+
output.log(`${logSymbols.success} Sanity agent skills installed: [${SANITY_SKILL_NAMES.join(', ')}]`);
|
|
86
|
+
printInstallSummary(installedAgents, output);
|
|
87
|
+
}
|
|
88
|
+
if (result.failed.length === 0) {
|
|
89
|
+
return {
|
|
90
|
+
installedAgents,
|
|
91
|
+
skipped: false
|
|
92
|
+
};
|
|
93
|
+
}
|
|
94
|
+
const failureMessages = result.failed.map((failure)=>failure.message);
|
|
95
|
+
output.warn(installedAgents.length > 0 ? 'Could not install Sanity agent skills for some agents:' : 'Could not install Sanity agent skills:');
|
|
96
|
+
for (const message of failureMessages)output.warn(message);
|
|
95
97
|
return {
|
|
96
|
-
|
|
98
|
+
error: new Error(failureMessages.join('\n')),
|
|
99
|
+
installedAgents,
|
|
97
100
|
skipped: false
|
|
98
101
|
};
|
|
99
102
|
} catch (error) {
|
|
@@ -101,11 +104,8 @@ const skillsDebug = subdebug('skills:setup');
|
|
|
101
104
|
const err = toError(error);
|
|
102
105
|
spin.stop();
|
|
103
106
|
output.warn(`Could not install Sanity agent skills: ${getErrorMessage(error)}`);
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
if (stdout) output.warn(stdout);
|
|
107
|
-
if (stderr) output.warn(stderr);
|
|
108
|
-
}
|
|
107
|
+
const fix = error?.fix;
|
|
108
|
+
if (typeof fix === 'string' && fix) output.warn(fix);
|
|
109
109
|
return {
|
|
110
110
|
error: err,
|
|
111
111
|
installedAgents: [],
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/actions/skills/setupSkills.ts"],"sourcesContent":["import {
|
|
1
|
+
{"version":3,"sources":["../../../src/actions/skills/setupSkills.ts"],"sourcesContent":["import {styleText} from 'node:util'\n\nimport {type Output, subdebug} from '@sanity/cli-core'\nimport {getErrorMessage, toError} from '@sanity/cli-core/errors'\nimport {logSymbols, spinner} from '@sanity/cli-core/ux'\n\nimport {\n getSkillsCliAgentDisplayNameById,\n getSkillsCliAgentSkillsDir,\n UNIVERSAL_SKILLS_DIR,\n} from '../mcp/editorConfigs.js'\n\nconst skillsDebug = subdebug('skills:setup')\n\n/** Source repo for the bundled `skills` package. See https://www.sanity.io/docs/ai/skills. */\nexport const SANITY_SKILLS_REPO = 'sanity-io/agent-toolkit'\n\n/** Names of the skills we install — must match the entries in the source repo. */\nexport const SANITY_SKILL_NAMES = ['sanity-best-practices', 'sanity-migration']\n\n/** Upper bound for fetching and installing the skills (checked between steps). */\nconst INSTALL_TIMEOUT_MS = 90_000\n\ninterface SetupSkillsOptions {\n /** Skills-CLI agent IDs (e.g. 'cursor', 'claude-code') to install for. */\n agents: string[]\n\n /**\n * Output to use for user-facing messages, so they go through the calling\n * command rather than directly to stdout/stderr.\n */\n output: Output\n}\n\ninterface SetupSkillsResult {\n /** Deduplicated agent IDs the skills were installed for. */\n installedAgents: string[]\n skipped: boolean\n\n error?: Error\n}\n\n/**\n * Prints a short summary beneath the success line: the skills that were\n * installed, grouped by where they live. Universal agents share\n * `~/.agents/skills`, so they're listed together under one header; any agent\n * with its own directory (e.g. Claude Code) is listed separately with its\n * location. Global (`-g`) installs are home-anchored, so locations show `~/`.\n */\nfunction printInstallSummary(agents: string[], output: Output): void {\n const universal: string[] = []\n const additional: {dir: string; name: string}[] = []\n\n for (const agent of agents) {\n const name = getSkillsCliAgentDisplayNameById(agent) ?? agent\n const dir = getSkillsCliAgentSkillsDir(agent)\n if (dir && dir !== UNIVERSAL_SKILLS_DIR) {\n additional.push({dir, name})\n } else {\n universal.push(name)\n }\n }\n\n if (universal.length > 0) {\n output.log('')\n output.log(styleText('dim', ` Universal (~/${UNIVERSAL_SKILLS_DIR})`))\n output.log(styleText('dim', ` ${universal.join(', ')}`))\n }\n\n if (additional.length > 0) {\n output.log('')\n output.log(styleText('dim', ' Additional agents'))\n for (const {dir, name} of additional) {\n output.log(styleText('dim', ` ${name} (~/${dir})`))\n }\n }\n output.log('')\n}\n\n/**\n * Installs the Sanity skills globally for the given agents using the bundled\n * `skills` package's programmatic API (equivalent to\n * `skills add <repo> --skill <names> -g -a <agent>... -y`). Failures are\n * surfaced as warnings and never throw — skills install is best-effort and\n * must not abort `sanity init`.\n */\nexport async function setupSkills(options: SetupSkillsOptions): Promise<SetupSkillsResult> {\n const {output} = options\n const uniqueAgents = [...new Set(options.agents)]\n\n if (uniqueAgents.length === 0) {\n skillsDebug('No agents passed — skipping skills install')\n return {installedAgents: [], skipped: true}\n }\n\n skillsDebug(\n 'Installing %s from %s globally for agents: %s',\n SANITY_SKILL_NAMES.join(', '),\n SANITY_SKILLS_REPO,\n uniqueAgents.join(', '),\n )\n\n const spin = spinner('Installing Sanity agent skills').start()\n\n try {\n // Loaded lazily so a problem with the `skills` package only affects this\n // best-effort step, not every command that imports this module.\n // eslint-disable-next-line no-restricted-syntax -- package import, not a file path\n const {installSkills} = await import('skills')\n const result = await installSkills(SANITY_SKILLS_REPO, {\n agents: uniqueAgents,\n onWarning: (warning) => skillsDebug('skills warning: %s', warning.message),\n scope: 'global',\n signal: AbortSignal.timeout(INSTALL_TIMEOUT_MS),\n skills: SANITY_SKILL_NAMES,\n })\n skillsDebug('skills install result: %O', result)\n spin.stop()\n\n const failedAgents = new Set(result.failed.map((failure) => failure.agent))\n const installedAgents = uniqueAgents.filter((agent) => !failedAgents.has(agent))\n\n if (installedAgents.length > 0) {\n output.log(\n `${logSymbols.success} Sanity agent skills installed: [${SANITY_SKILL_NAMES.join(', ')}]`,\n )\n printInstallSummary(installedAgents, output)\n }\n\n if (result.failed.length === 0) {\n return {installedAgents, skipped: false}\n }\n\n const failureMessages = result.failed.map((failure) => failure.message)\n output.warn(\n installedAgents.length > 0\n ? 'Could not install Sanity agent skills for some agents:'\n : 'Could not install Sanity agent skills:',\n )\n for (const message of failureMessages) output.warn(message)\n return {error: new Error(failureMessages.join('\\n')), installedAgents, skipped: false}\n } catch (error) {\n skillsDebug('Error installing skills %O', error)\n const err = toError(error)\n spin.stop()\n output.warn(`Could not install Sanity agent skills: ${getErrorMessage(error)}`)\n const fix = (error as {fix?: unknown} | null)?.fix\n if (typeof fix === 'string' && fix) output.warn(fix)\n return {error: err, installedAgents: [], skipped: false}\n }\n}\n"],"names":["styleText","subdebug","getErrorMessage","toError","logSymbols","spinner","getSkillsCliAgentDisplayNameById","getSkillsCliAgentSkillsDir","UNIVERSAL_SKILLS_DIR","skillsDebug","SANITY_SKILLS_REPO","SANITY_SKILL_NAMES","INSTALL_TIMEOUT_MS","printInstallSummary","agents","output","universal","additional","agent","name","dir","push","length","log","join","setupSkills","options","uniqueAgents","Set","installedAgents","skipped","spin","start","installSkills","result","onWarning","warning","message","scope","signal","AbortSignal","timeout","skills","stop","failedAgents","failed","map","failure","filter","has","success","failureMessages","warn","error","Error","err","fix"],"mappings":"AAAA,SAAQA,SAAS,QAAO,YAAW;AAEnC,SAAqBC,QAAQ,QAAO,mBAAkB;AACtD,SAAQC,eAAe,EAAEC,OAAO,QAAO,0BAAyB;AAChE,SAAQC,UAAU,EAAEC,OAAO,QAAO,sBAAqB;AAEvD,SACEC,gCAAgC,EAChCC,0BAA0B,EAC1BC,oBAAoB,QACf,0BAAyB;AAEhC,MAAMC,cAAcR,SAAS;AAE7B,4FAA4F,GAC5F,OAAO,MAAMS,qBAAqB,0BAAyB;AAE3D,gFAAgF,GAChF,OAAO,MAAMC,qBAAqB;IAAC;IAAyB;CAAmB,CAAA;AAE/E,gFAAgF,GAChF,MAAMC,qBAAqB;AAqB3B;;;;;;CAMC,GACD,SAASC,oBAAoBC,MAAgB,EAAEC,MAAc;IAC3D,MAAMC,YAAsB,EAAE;IAC9B,MAAMC,aAA4C,EAAE;IAEpD,KAAK,MAAMC,SAASJ,OAAQ;QAC1B,MAAMK,OAAOb,iCAAiCY,UAAUA;QACxD,MAAME,MAAMb,2BAA2BW;QACvC,IAAIE,OAAOA,QAAQZ,sBAA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