@sanity/cli 8.28.1 → 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.
@@ -1,8 +1,7 @@
1
1
  import { subdebug } from '@sanity/cli-core';
2
- import { execa } from 'execa';
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
- * Runs the bundled `skills list -g --json` and returns the set of agent
19
- * display names that have every skill in `skillNames` installed globally.
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. `skills list` only attributes a skill to agents it independently
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 (spawn, parse, timeout, non-zero exit) is debug-logged and
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 stdout;
37
+ let entries;
39
38
  try {
40
- const result = await execa(process.execPath, [
41
- SKILLS_BIN_PATH,
42
- 'list',
43
- '-g',
44
- '--json'
45
- ], {
46
- stdio: 'pipe',
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
- stdout = result.stdout;
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?.name === skillName);
68
- if (!match || !Array.isArray(match.agents)) {
53
+ const match = entries.find((entry)=>entry.name === skillName);
54
+ if (!match) {
69
55
  return new Set();
70
56
  }
71
- return new Set(match.agents.filter((a)=>typeof a === 'string'));
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?.name === skillName);
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 {execa} from 'execa'\n\nimport {\n getSkillsCliAgentDisplayName,\n isUniversalSkillsCliAgentByEditorName,\n UNIVERSAL_SKILLS_DIR,\n} from '../mcp/editorConfigs.js'\nimport {type Editor} from '../mcp/types.js'\nimport {SKILLS_BIN_PATH} from './setupSkills.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` field in `skills list --json`). */\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\ninterface SkillListEntry {\n agents?: unknown\n name?: unknown\n path?: unknown\n}\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: unknown): boolean {\n if (typeof skillPath !== 'string') return false\n return toPosixPath(skillPath).includes(`${UNIVERSAL_SKILLS_DIR}/`)\n}\n\n/**\n * Runs the bundled `skills list -g --json` and returns the set of agent\n * display names that have every skill in `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. `skills list` 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 (spawn, parse, timeout, non-zero exit) 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 stdout: string\n try {\n const result = await execa(process.execPath, [SKILLS_BIN_PATH, 'list', '-g', '--json'], {\n stdio: 'pipe',\n timeout: 10_000,\n })\n stdout = result.stdout\n } catch (error) {\n debug('skills list failed: %O', error)\n return empty\n }\n\n let parsed: unknown\n try {\n parsed = JSON.parse(stdout)\n } catch (error) {\n debug('Failed to parse skills list JSON: %O', error)\n return empty\n }\n\n if (!Array.isArray(parsed)) {\n debug('Unexpected skills list JSON shape (not an array)')\n return empty\n }\n\n const entries = parsed as SkillListEntry[]\n\n const agentSets = skillNames.map((skillName) => {\n const match = entries.find((entry) => entry?.name === skillName)\n if (!match || !Array.isArray(match.agents)) {\n return new Set<string>()\n }\n return new Set(match.agents.filter((a): a is string => typeof a === 'string'))\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","execa","getSkillsCliAgentDisplayName","isUniversalSkillsCliAgentByEditorName","UNIVERSAL_SKILLS_DIR","SKILLS_BIN_PATH","debug","toPosixPath","value","replaceAll","isUniversalSkillPath","skillPath","includes","readSkillState","opts","editors","skillNames","empty","installedAgentDisplayNames","Set","stdout","result","process","execPath","stdio","timeout","error","parsed","JSON","parse","Array","isArray","entries","agentSets","map","skillName","match","find","entry","name","agents","filter","a","installed","agent","every","set","has","allSkillsInUniversalDir","length","path","editor","displayName","add"],"mappings":"AAAA,SAAQA,QAAQ,QAAO,mBAAkB;AACzC,SAAQC,KAAK,QAAO,QAAO;AAE3B,SACEC,4BAA4B,EAC5BC,qCAAqC,EACrCC,oBAAoB,QACf,0BAAyB;AAEhC,SAAQC,eAAe,QAAO,mBAAkB;AAEhD,MAAMC,QAAQN,SAAS;AAwBvB,sEAAsE,GACtE,SAASO,YAAYC,KAAa;IAChC,OAAOA,MAAMC,UAAU,CAAC,MAAM;AAChC;AAEA;;;;CAIC,GACD,SAASC,qBAAqBC,SAAkB;IAC9C,IAAI,OAAOA,cAAc,UAAU,OAAO;IAC1C,OAAOJ,YAAYI,WAAWC,QAAQ,CAAC,GAAGR,qBAAqB,CAAC,CAAC;AACnE;AAEA;;;;;;;;;;;;;;;;CAgBC,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,MAAMC,SAAS,MAAMpB,MAAMqB,QAAQC,QAAQ,EAAE;YAAClB;YAAiB;YAAQ;YAAM;SAAS,EAAE;Y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C5D,IAAIa,aAAaT,UAAUU,GAAG,CAACD;QACjC;IACF;IAEA,OAAO;QAAClC,4BAA4ByB;IAAS;AAC/C"}
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;QAClC,MAAMC,SAAS,MAAMD,WAAW;YAC9BE,OAAO;YACPC,QAAQC,YAAYC,OAAO,CAACpB;QAC9B;QACAc,UAAUE,OAAOK,MAAM;IACzB,EAAE,OAAOC,OAAO;QACdvB,MAAM,0BAA0BuB;QAChC,OAAOX;IACT;IAEA,MAAMY,YAAYb,WAAWc,GAAG,CAAC,CAACC;QAChC,MAAMC,QAAQZ,QAAQa,IAAI,CAAC,CAACC,QAAUA,MAAMC,IAAI,KAAKJ;QACrD,IAAI,CAACC,OAAO;YACV,OAAO,IAAIb;QACb;QACA,kEAAkE;QAClE,OAAO,IAAIA,IACTa,MAAMI,MAAM,CAACN,GAAG,CAAC,CAACO,UAAYnC,iCAAiCmC,YAAYA;IAE/E;IAEA,MAAMC,YAAY,IAAInB,IACpB;WAAKU,SAAS,CAAC,EAAE,IAAI,EAAE;KAAE,CAACU,MAAM,CAAC,CAACC,QAAUX,UAAUY,KAAK,CAAC,CAACC,MAAQA,IAAIC,GAAG,CAACH;IAG/E,4EAA4E;IAC5E,yEAAyE;IACzE,8EAA8E;IAC9E,kEAAkE;IAClE,MAAMI,0BACJ5B,WAAW6B,MAAM,GAAG,KACpB7B,WAAWyB,KAAK,CAAC,CAACV;QAChB,MAAMC,QAAQZ,QAAQa,IAAI,CAAC,CAACC,QAAUA,MAAMC,IAAI,KAAKJ;QACrD,OAAOC,QAAQtB,qBAAqBsB,MAAMc,IAAI,IAAI;IACpD;IAEF,IAAIF,yBAAyB;QAC3B,KAAK,MAAMG,UAAUhC,QAAS;YAC5B,IAAI,CAACZ,sCAAsC4C,OAAOZ,IAAI,GAAG;YACzD,MAAMa,cAAc/C,6BAA6B8C,OAAOZ,IAAI;YAC5D,IAAIa,aAAaV,UAAUW,GAAG,CAACD;QACjC;IACF;IAEA,OAAO;QAAC9B,4BAA4BoB;IAAS;AAC/C"}
@@ -1,21 +1,15 @@
1
- import { fileURLToPath } from 'node:url';
2
1
  import { styleText } from 'node: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` CLI. See https://www.sanity.io/docs/ai/skills. */ export const SANITY_SKILLS_REPO = 'sanity-io/agent-toolkit';
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
- * Runs the bundled `skills add` globally for the given agents. Failures are
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
- const args = [
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
- const result = await execa(process.execPath, args, {
87
- stdio: 'pipe',
88
- timeout: 90_000
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 stdout: %s', result.stdout);
91
- skillsDebug('skills stderr: %s', result.stderr);
80
+ skillsDebug('skills install result: %O', result);
92
81
  spin.stop();
93
- output.log(`${logSymbols.success} Sanity agent skills installed: [${SANITY_SKILL_NAMES.join(', ')}]`);
94
- printInstallSummary(uniqueAgents, output);
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
- installedAgents: uniqueAgents,
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
- if (error && typeof error === 'object') {
105
- const { stderr, stdout } = error;
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 {fileURLToPath} from 'node:url'\nimport {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'\nimport {execa} from 'execa'\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` CLI. 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/**\n * Absolute path to the bundled `skills` CLI bin. Resolved once at module load\n * via `import.meta.resolve` so we run the version pinned in our package.json\n * instead of paying the `npx -y` registry lookup at runtime.\n */\nexport const SKILLS_BIN_PATH = fileURLToPath(\n import.meta.resolve('skills/bin/cli.mjs', import.meta.url),\n)\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` values passed to `skills add`. */\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 * Runs the bundled `skills add` globally for the given agents. 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 const args = [\n SKILLS_BIN_PATH,\n 'add',\n SANITY_SKILLS_REPO,\n '--skill',\n ...SANITY_SKILL_NAMES,\n '-g',\n ...uniqueAgents.flatMap((agent) => ['-a', agent]),\n '-y',\n ]\n\n skillsDebug('Running: %s %s', process.execPath, args.join(' '))\n\n const spin = spinner('Installing Sanity agent skills').start()\n\n try {\n const result = await execa(process.execPath, args, {stdio: 'pipe', timeout: 90_000})\n skillsDebug('skills stdout: %s', result.stdout)\n skillsDebug('skills stderr: %s', result.stderr)\n spin.stop()\n output.log(\n `${logSymbols.success} Sanity agent skills installed: [${SANITY_SKILL_NAMES.join(', ')}]`,\n )\n printInstallSummary(uniqueAgents, output)\n return {installedAgents: uniqueAgents, 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 if (error && typeof error === 'object') {\n const {stderr, stdout} = error as {stderr?: string; stdout?: string}\n if (stdout) output.warn(stdout)\n if (stderr) output.warn(stderr)\n }\n return {error: err, installedAgents: [], skipped: false}\n }\n}\n"],"names":["fileURLToPath","styleText","subdebug","getErrorMessage","toError","logSymbols","spinner","execa","getSkillsCliAgentDisplayNameById","getSkillsCliAgentSkillsDir","UNIVERSAL_SKILLS_DIR","skillsDebug","SANITY_SKILLS_REPO","SANITY_SKILL_NAMES","SKILLS_BIN_PATH","resolve","url","printInstallSummary","agents","output","universal","additional","agent","name","dir","push","length","log","join","setupSkills","options","uniqueAgents","Set","installedAgents","skipped","args","flatMap","process","execPath","spin","start","result","stdio","timeout","stdout","stderr","stop","success","error","err","warn"],"mappings":"AAAA,SAAQA,aAAa,QAAO,WAAU;AACtC,SAAQC,SAAS,QAAO,YAAW;AAEnC,SAAqBC,QAAQ,QAAO,mBAAkB;AACtD,SAAQC,eAAe,EAAEC,OAAO,QAAO,0BAAyB;AAChE,SAAQC,UAAU,EAAEC,OAAO,QAAO,sBAAqB;AACvD,SAAQC,KAAK,QAAO,QAAO;AAE3B,SACEC,gCAAgC,EAChCC,0BAA0B,EAC1BC,oBAAoB,QACf,0BAAyB;AAEhC,MAAMC,cAAcT,SAAS;AAE7B,wFAAwF,GACxF,OAAO,MAAMU,qBAAqB,0BAAyB;AAE3D,gFAAgF,GAChF,OAAO,MAAMC,qBAAqB;IAAC;IAAyB;CAAmB,CAAA;AAE/E;;;;CAIC,GACD,OAAO,MAAMC,kBAAkBd,cAC7B,YAAYe,OAAO,CAAC,sBAAsB,YAAYC,GAAG,GAC1D;AAqBD;;;;;;CAMC,GACD,SAASC,oBAAoBC,MAAgB,EAAEC,MAAc;IAC3D,MAAMC,YAAsB,EAAE;IAC9B,MAAMC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AEH,KAAKP,IAAI,CAAC;IAE1D,MAAMW,OAAOjC,QAAQ,kCAAkCkC,KAAK;IAE5D,IAAI;QACF,MAAMC,SAAS,MAAMlC,MAAM8B,QAAQC,QAAQ,EAAEH,MAAM;YAACO,OAAO;YAAQC,SAAS;QAAM;QAClFhC,YAAY,qBAAqB8B,OAAOG,MAAM;QAC9CjC,YAAY,qBAAqB8B,OAAOI,MAAM;QAC9CN,KAAKO,IAAI;QACT3B,OAAOQ,GAAG,CACR,GAAGtB,WAAW0C,OAAO,CAAC,iCAAiC,EAAElC,mBAAmBe,IAAI,CAAC,MAAM,CAAC,CAAC;QAE3FX,oBAAoBc,cAAcZ;QAClC,OAAO;YAACc,iBAAiBF;YAAcG,SAAS;QAAK;IACvD,EAAE,OAAOc,OAAO;QACdrC,YAAY,8BAA8BqC;QAC1C,MAAMC,MAAM7C,QAAQ4C;QACpBT,KAAKO,IAAI;QACT3B,OAAO+B,IAAI,CAAC,CAAC,uCAAuC,EAAE/C,gBAAgB6C,QAAQ;QAC9E,IAAIA,SAAS,OAAOA,UAAU,UAAU;YACtC,MAAM,EAACH,MAAM,EAAED,MAAM,EAAC,GAAGI;YACzB,IAAIJ,QAAQzB,OAAO+B,IAAI,CAACN;YACxB,IAAIC,QAAQ1B,OAAO+B,IAAI,CAACL;QAC1B;QACA,OAAO;YAACG,OAAOC;YAAKhB,iBAAiB,EAAE;YAAEC,SAAS;QAAK;IACzD;AACF"}
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,sBAAsB;YACvCS,WAAWI,IAAI,CAAC;gBAACD;gBAAKD;YAAI;QAC5B,OAAO;YACLH,UAAUK,IAAI,CAACF;QACjB;IACF;IAEA,IAAIH,UAAUM,MAAM,GAAG,GAAG;QACxBP,OAAOQ,GAAG,CAAC;QACXR,OAAOQ,GAAG,CAACvB,UAAU,OA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