assistant-ui 0.0.121 → 0.0.123

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 (56) hide show
  1. package/dist/commands/add.d.ts.map +1 -1
  2. package/dist/commands/add.js +1 -2
  3. package/dist/commands/add.js.map +1 -1
  4. package/dist/commands/create.d.ts.map +1 -1
  5. package/dist/commands/create.js +2 -2
  6. package/dist/commands/create.js.map +1 -1
  7. package/dist/commands/info.js +1 -1
  8. package/dist/commands/init.d.ts.map +1 -1
  9. package/dist/commands/init.js +1 -2
  10. package/dist/commands/init.js.map +1 -1
  11. package/dist/commands/mcp.d.ts.map +1 -1
  12. package/dist/commands/mcp.js +95 -23
  13. package/dist/commands/mcp.js.map +1 -1
  14. package/dist/lib/agent-skill.d.ts +2 -2
  15. package/dist/lib/agent-skill.d.ts.map +1 -1
  16. package/dist/lib/agent-skill.js +10 -28
  17. package/dist/lib/agent-skill.js.map +1 -1
  18. package/dist/lib/create-project.d.ts +0 -9
  19. package/dist/lib/create-project.d.ts.map +1 -1
  20. package/dist/lib/create-project.js +15 -46
  21. package/dist/lib/create-project.js.map +1 -1
  22. package/dist/lib/transform.d.ts +0 -4
  23. package/dist/lib/transform.d.ts.map +1 -1
  24. package/dist/lib/transform.js +7 -16
  25. package/dist/lib/transform.js.map +1 -1
  26. package/dist/lib/utils/download.d.ts +5 -0
  27. package/dist/lib/utils/download.d.ts.map +1 -0
  28. package/dist/lib/utils/download.js +41 -0
  29. package/dist/lib/utils/download.js.map +1 -0
  30. package/dist/lib/utils/file-scanner.d.ts +0 -1
  31. package/dist/lib/utils/file-scanner.d.ts.map +1 -1
  32. package/dist/lib/utils/file-scanner.js +1 -16
  33. package/dist/lib/utils/file-scanner.js.map +1 -1
  34. package/dist/lib/utils/package-manager.d.ts +7 -0
  35. package/dist/lib/utils/package-manager.d.ts.map +1 -1
  36. package/dist/lib/utils/package-manager.js +15 -1
  37. package/dist/lib/utils/package-manager.js.map +1 -1
  38. package/package.json +3 -3
  39. package/src/commands/add.ts +2 -1
  40. package/src/commands/create.ts +5 -3
  41. package/src/commands/init.ts +5 -2
  42. package/src/commands/mcp.ts +223 -56
  43. package/src/lib/agent-skill.ts +18 -44
  44. package/src/lib/create-project.test.ts +0 -17
  45. package/src/lib/create-project.ts +33 -98
  46. package/src/lib/transform-files.test.ts +1 -3
  47. package/src/lib/transform.ts +6 -20
  48. package/src/lib/utils/download.ts +57 -0
  49. package/src/lib/utils/file-scanner.ts +0 -26
  50. package/src/lib/utils/package-manager.ts +26 -0
  51. package/src/lib/utils/registry.test.ts +0 -6
  52. package/templates/cloud-harness/app/api/chat/route.ts +1 -0
  53. package/templates/cloud-harness/components/assistant-ui/elements/collapsible-root.tsx +19 -0
  54. package/templates/cloud-harness/components/assistant-ui/elements/markdown-text.tsx +1 -1
  55. package/templates/cloud-harness/components/assistant-ui/elements/tool-fallback.aui.tsx +198 -30
  56. package/templates/cloud-harness/package.json +12 -12
@@ -1 +1 @@
1
- {"version":3,"file":"transform.js","names":["fs","globSync"],"sources":["../../src/lib/transform.ts"],"sourcesContent":["import debug from \"debug\";\nimport path from \"node:path\";\nimport type { TransformOptions } from \"./transform-options\";\nimport { fileURLToPath } from \"node:url\";\nimport * as fs from \"node:fs\";\nimport { sync as globSync } from \"glob\";\nimport { runSpawnCapture, SpawnExitError, SpawnSignalError } from \"./run-spawn\";\n\nconst log = debug(\"codemod:transform\");\n\nconst __filename = fileURLToPath(import.meta.url);\nconst __dirname = path.dirname(__filename);\n\n/**\n * Gets relevant source files from an explicit file or directory target.\n * Directory scans only include files containing \"assistant-ui\".\n */\nexport function getRelevantFiles(source: string): string[] {\n const target = path.resolve(source);\n if (fs.statSync(target).isFile()) {\n return /\\.(js|jsx|ts|tsx)$/.test(target) ? [target] : [];\n }\n\n const pattern = \"**/*.{js,jsx,ts,tsx}\";\n const files = globSync(pattern, {\n cwd: target,\n ignore: [\n \"**/node_modules/**\",\n \"**/dist/**\",\n \"**/build/**\",\n \"**/*.min.js\",\n \"**/*.bundle.js\",\n ],\n }).map((file) => path.join(target, file));\n\n const relevantFiles = files.filter((file) => {\n try {\n const content = fs.readFileSync(file, \"utf8\");\n return content.includes(\"assistant-ui\");\n } catch {\n return false;\n }\n });\n\n return relevantFiles;\n}\n\n/**\n * Counts the number of files that need to be processed\n */\nexport function countFilesToProcess(source: string): number {\n return getRelevantFiles(source).length;\n}\n\nfunction buildCommand(\n codemodPath: string,\n targetFiles: string[],\n options: TransformOptions,\n): string[] {\n const command = [\n \"npx\",\n \"jscodeshift\",\n \"-t\",\n codemodPath,\n ...targetFiles,\n \"--parser\",\n \"tsx\",\n \"--fail-on-error\",\n ];\n\n if (options.dry) {\n command.push(\"--dry\");\n }\n\n if (options.print) {\n command.push(\"--print\");\n }\n\n if (options.verbose) {\n command.push(\"--verbose\");\n }\n\n if (options.jscodeshift) {\n command.push(options.jscodeshift);\n }\n\n return command;\n}\n\nexport type TransformErrors = {\n transform: string;\n filename: string;\n summary: string;\n}[];\n\nexport async function transform(\n codemod: string,\n source: string,\n transformOptions: TransformOptions,\n options: {\n logStatus: boolean;\n onProgress?: (processedFiles: number) => void;\n relevantFiles?: string[];\n } = { logStatus: true },\n): Promise<TransformErrors> {\n if (options.logStatus) {\n log(`Applying codemod '${codemod}': ${source}`);\n }\n const codemodPath = path.resolve(__dirname, `../codemods/${codemod}.js`);\n\n // Use pre-computed relevant files if provided, otherwise get them\n const targetFiles = options.relevantFiles || getRelevantFiles(source);\n\n if (targetFiles.length === 0) {\n log(`No relevant files found for codemod '${codemod}'`);\n return [];\n }\n\n log(`Found ${targetFiles.length} relevant files for codemod '${codemod}'`);\n\n const command = buildCommand(codemodPath, targetFiles, transformOptions);\n\n const result = await runSpawnCapture(command[0]!, command.slice(1));\n if (result.signal !== null) {\n throw new SpawnSignalError(result.signal, false);\n }\n if (result.code !== 0) {\n const failure = new SpawnExitError(\n result.code || 1,\n result.stderr,\n result.stdout,\n );\n failure.message = `Codemod '${codemod}' failed\\n${failure.message}`;\n throw failure;\n }\n\n const { stdout } = result;\n\n if (options.onProgress) {\n const processedFiles = (stdout.match(/Processing file/g) || []).length;\n options.onProgress(processedFiles);\n }\n\n return [];\n}\n"],"mappings":";;;;;;;AAQA,MAAM,MAAM,MAAM,mBAAmB;AAErC,MAAM,aAAa,cAAc,YAAY,GAAG;AAChD,MAAM,YAAY,KAAK,QAAQ,UAAU;;;;;AAMzC,SAAgB,iBAAiB,QAA0B;CACzD,MAAM,SAAS,KAAK,QAAQ,MAAM;CAClC,IAAIA,KAAG,SAAS,MAAM,CAAC,CAAC,OAAO,GAC7B,OAAO,qBAAqB,KAAK,MAAM,IAAI,CAAC,MAAM,IAAI,CAAC;CAwBzD,OApBcC,KAAS,wBAAS;EAC9B,KAAK;EACL,QAAQ;GACN;GACA;GACA;GACA;GACA;EACF;CACF,CAAC,CAAC,CAAC,KAAK,SAAS,KAAK,KAAK,QAAQ,IAAI,CAEb,CAAC,CAAC,QAAQ,SAAS;EAC3C,IAAI;GAEF,OADgBD,KAAG,aAAa,MAAM,MACzB,CAAC,CAAC,SAAS,cAAc;EACxC,QAAQ;GACN,OAAO;EACT;CACF,CAEmB;AACrB;;;;AAKA,SAAgB,oBAAoB,QAAwB;CAC1D,OAAO,iBAAiB,MAAM,CAAC,CAAC;AAClC;AAEA,SAAS,aACP,aACA,aACA,SACU;CACV,MAAM,UAAU;EACd;EACA;EACA;EACA;EACA,GAAG;EACH;EACA;EACA;CACF;CAEA,IAAI,QAAQ,KACV,QAAQ,KAAK,OAAO;CAGtB,IAAI,QAAQ,OACV,QAAQ,KAAK,SAAS;CAGxB,IAAI,QAAQ,SACV,QAAQ,KAAK,WAAW;CAG1B,IAAI,QAAQ,aACV,QAAQ,KAAK,QAAQ,WAAW;CAGlC,OAAO;AACT;AAQA,eAAsB,UACpB,SACA,QACA,kBACA,UAII,EAAE,WAAW,KAAK,GACI;CAC1B,IAAI,QAAQ,WACV,IAAI,qBAAqB,QAAQ,KAAK,QAAQ;CAEhD,MAAM,cAAc,KAAK,QAAQ,WAAW,eAAe,QAAQ,IAAI;CAGvE,MAAM,cAAc,QAAQ,iBAAiB,iBAAiB,MAAM;CAEpE,IAAI,YAAY,WAAW,GAAG;EAC5B,IAAI,wCAAwC,QAAQ,EAAE;EACtD,OAAO,CAAC;CACV;CAEA,IAAI,SAAS,YAAY,OAAO,+BAA+B,QAAQ,EAAE;CAEzE,MAAM,UAAU,aAAa,aAAa,aAAa,gBAAgB;CAEvE,MAAM,SAAS,MAAM,gBAAgB,QAAQ,IAAK,QAAQ,MAAM,CAAC,CAAC;CAClE,IAAI,OAAO,WAAW,MACpB,MAAM,IAAI,iBAAiB,OAAO,QAAQ,KAAK;CAEjD,IAAI,OAAO,SAAS,GAAG;EACrB,MAAM,UAAU,IAAI,eAClB,OAAO,QAAQ,GACf,OAAO,QACP,OAAO,MACT;EACA,QAAQ,UAAU,YAAY,QAAQ,YAAY,QAAQ;EAC1D,MAAM;CACR;CAEA,MAAM,EAAE,WAAW;CAEnB,IAAI,QAAQ,YAAY;EACtB,MAAM,kBAAkB,OAAO,MAAM,kBAAkB,KAAK,CAAC,EAAA,CAAG;EAChE,QAAQ,WAAW,cAAc;CACnC;CAEA,OAAO,CAAC;AACV"}
1
+ {"version":3,"file":"transform.js","names":["fs"],"sources":["../../src/lib/transform.ts"],"sourcesContent":["import debug from \"debug\";\nimport path from \"node:path\";\nimport type { TransformOptions } from \"./transform-options\";\nimport { fileURLToPath } from \"node:url\";\nimport * as fs from \"node:fs\";\nimport { runSpawnCapture, SpawnExitError, SpawnSignalError } from \"./run-spawn\";\nimport { readProjectFiles } from \"./utils/file-scanner\";\n\nconst log = debug(\"codemod:transform\");\n\nconst __filename = fileURLToPath(import.meta.url);\nconst __dirname = path.dirname(__filename);\n\n/**\n * Gets relevant source files from an explicit file or directory target.\n * Directory scans only include files containing \"assistant-ui\".\n */\nexport function getRelevantFiles(source: string): string[] {\n const target = path.resolve(source);\n if (fs.statSync(target).isFile()) {\n return /\\.(js|jsx|ts|tsx)$/.test(target) ? [target] : [];\n }\n\n const pattern = \"**/*.{js,jsx,ts,tsx}\";\n const relevantFiles: string[] = [];\n for (const { fullPath, content } of readProjectFiles(pattern, {\n cwd: target,\n ignore: [\n \"**/node_modules/**\",\n \"**/dist/**\",\n \"**/build/**\",\n \"**/*.min.js\",\n \"**/*.bundle.js\",\n ],\n })) {\n if (content.includes(\"assistant-ui\")) relevantFiles.push(fullPath);\n }\n return relevantFiles;\n}\n\nfunction buildCommand(\n codemodPath: string,\n targetFiles: string[],\n options: TransformOptions,\n): string[] {\n const command = [\n \"npx\",\n \"jscodeshift\",\n \"-t\",\n codemodPath,\n ...targetFiles,\n \"--parser\",\n \"tsx\",\n \"--fail-on-error\",\n ];\n\n if (options.dry) {\n command.push(\"--dry\");\n }\n\n if (options.print) {\n command.push(\"--print\");\n }\n\n if (options.verbose) {\n command.push(\"--verbose\");\n }\n\n if (options.jscodeshift) {\n command.push(options.jscodeshift);\n }\n\n return command;\n}\n\nexport type TransformErrors = {\n transform: string;\n filename: string;\n summary: string;\n}[];\n\nexport async function transform(\n codemod: string,\n source: string,\n transformOptions: TransformOptions,\n options: {\n logStatus: boolean;\n onProgress?: (processedFiles: number) => void;\n relevantFiles?: string[];\n } = { logStatus: true },\n): Promise<TransformErrors> {\n if (options.logStatus) {\n log(`Applying codemod '${codemod}': ${source}`);\n }\n const codemodPath = path.resolve(__dirname, `../codemods/${codemod}.js`);\n\n // Use pre-computed relevant files if provided, otherwise get them\n const targetFiles = options.relevantFiles || getRelevantFiles(source);\n\n if (targetFiles.length === 0) {\n log(`No relevant files found for codemod '${codemod}'`);\n return [];\n }\n\n log(`Found ${targetFiles.length} relevant files for codemod '${codemod}'`);\n\n const command = buildCommand(codemodPath, targetFiles, transformOptions);\n\n const result = await runSpawnCapture(command[0]!, command.slice(1));\n if (result.signal !== null) {\n throw new SpawnSignalError(result.signal, false);\n }\n if (result.code !== 0) {\n const failure = new SpawnExitError(\n result.code || 1,\n result.stderr,\n result.stdout,\n );\n failure.message = `Codemod '${codemod}' failed\\n${failure.message}`;\n throw failure;\n }\n\n const { stdout } = result;\n\n if (options.onProgress) {\n const processedFiles = (stdout.match(/Processing file/g) || []).length;\n options.onProgress(processedFiles);\n }\n\n return [];\n}\n"],"mappings":";;;;;;;AAQA,MAAM,MAAM,MAAM,mBAAmB;AAErC,MAAM,aAAa,cAAc,YAAY,GAAG;AAChD,MAAM,YAAY,KAAK,QAAQ,UAAU;;;;;AAMzC,SAAgB,iBAAiB,QAA0B;CACzD,MAAM,SAAS,KAAK,QAAQ,MAAM;CAClC,IAAIA,KAAG,SAAS,MAAM,CAAC,CAAC,OAAO,GAC7B,OAAO,qBAAqB,KAAK,MAAM,IAAI,CAAC,MAAM,IAAI,CAAC;CAGzD,MAAM,UAAU;CAChB,MAAM,gBAA0B,CAAC;CACjC,KAAK,MAAM,EAAE,UAAU,aAAa,iBAAiB,SAAS;EAC5D,KAAK;EACL,QAAQ;GACN;GACA;GACA;GACA;GACA;EACF;CACF,CAAC,GACC,IAAI,QAAQ,SAAS,cAAc,GAAG,cAAc,KAAK,QAAQ;CAEnE,OAAO;AACT;AAEA,SAAS,aACP,aACA,aACA,SACU;CACV,MAAM,UAAU;EACd;EACA;EACA;EACA;EACA,GAAG;EACH;EACA;EACA;CACF;CAEA,IAAI,QAAQ,KACV,QAAQ,KAAK,OAAO;CAGtB,IAAI,QAAQ,OACV,QAAQ,KAAK,SAAS;CAGxB,IAAI,QAAQ,SACV,QAAQ,KAAK,WAAW;CAG1B,IAAI,QAAQ,aACV,QAAQ,KAAK,QAAQ,WAAW;CAGlC,OAAO;AACT;AAQA,eAAsB,UACpB,SACA,QACA,kBACA,UAII,EAAE,WAAW,KAAK,GACI;CAC1B,IAAI,QAAQ,WACV,IAAI,qBAAqB,QAAQ,KAAK,QAAQ;CAEhD,MAAM,cAAc,KAAK,QAAQ,WAAW,eAAe,QAAQ,IAAI;CAGvE,MAAM,cAAc,QAAQ,iBAAiB,iBAAiB,MAAM;CAEpE,IAAI,YAAY,WAAW,GAAG;EAC5B,IAAI,wCAAwC,QAAQ,EAAE;EACtD,OAAO,CAAC;CACV;CAEA,IAAI,SAAS,YAAY,OAAO,+BAA+B,QAAQ,EAAE;CAEzE,MAAM,UAAU,aAAa,aAAa,aAAa,gBAAgB;CAEvE,MAAM,SAAS,MAAM,gBAAgB,QAAQ,IAAK,QAAQ,MAAM,CAAC,CAAC;CAClE,IAAI,OAAO,WAAW,MACpB,MAAM,IAAI,iBAAiB,OAAO,QAAQ,KAAK;CAEjD,IAAI,OAAO,SAAS,GAAG;EACrB,MAAM,UAAU,IAAI,eAClB,OAAO,QAAQ,GACf,OAAO,QACP,OAAO,MACT;EACA,QAAQ,UAAU,YAAY,QAAQ,YAAY,QAAQ;EAC1D,MAAM;CACR;CAEA,MAAM,EAAE,WAAW;CAEnB,IAAI,QAAQ,YAAY;EACtB,MAAM,kBAAkB,OAAO,MAAM,kBAAkB,KAAK,CAAC,EAAA,CAAG;EAChE,QAAQ,WAAW,cAAc;CACnC;CAEA,OAAO,CAAC;AACV"}
@@ -0,0 +1,5 @@
1
+ import { downloadTemplate } from "giget";
2
+ export declare const DOWNLOAD_TIMEOUT_MS = 30000;
3
+ export declare function resolveGitHubAuthToken(): string | undefined;
4
+ export declare function withStagedDownload<T>(source: string, options: NonNullable<Parameters<typeof downloadTemplate>[1]>, timeoutMessage: string, cleanup: () => void | Promise<void>, consumeDownload: (download: Promise<unknown>) => Promise<T>): Promise<T>;
5
+ //# sourceMappingURL=download.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"download.d.ts","sourceRoot":"","sources":["../../../src/lib/utils/download.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,OAAO,CAAC;AAEzC,eAAO,MAAM,mBAAmB,QAAS,CAAC;AAE1C,wBAAgB,sBAAsB,IAAI,MAAM,GAAG,SAAS,CAK3D;AAED,wBAAsB,kBAAkB,CAAC,CAAC,EACxC,MAAM,EAAE,MAAM,EACd,OAAO,EAAE,WAAW,CAAC,UAAU,CAAC,OAAO,gBAAgB,CAAC,CAAC,CAAC,CAAC,CAAC,EAC5D,cAAc,EAAE,MAAM,EACtB,OAAO,EAAE,MAAM,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,EACnC,eAAe,EAAE,CAAC,QAAQ,EAAE,OAAO,CAAC,OAAO,CAAC,KAAK,OAAO,CAAC,CAAC,CAAC,GAC1D,OAAO,CAAC,CAAC,CAAC,CAuCZ"}
@@ -0,0 +1,41 @@
1
+ import { downloadTemplate } from "giget";
2
+ //#region src/lib/utils/download.ts
3
+ const DOWNLOAD_TIMEOUT_MS = 3e4;
4
+ function resolveGitHubAuthToken() {
5
+ return (process.env.GIGET_AUTH ?? process.env.GITHUB_TOKEN ?? process.env.GH_TOKEN)?.trim() || void 0;
6
+ }
7
+ async function withStagedDownload(source, options, timeoutMessage, cleanup, consumeDownload) {
8
+ const origDebug = process.env.DEBUG;
9
+ delete process.env.DEBUG;
10
+ let download;
11
+ let settled = false;
12
+ try {
13
+ const authToken = resolveGitHubAuthToken();
14
+ download = downloadTemplate(source, {
15
+ ...options,
16
+ ...authToken ? { auth: authToken } : {}
17
+ }).finally(() => {
18
+ settled = true;
19
+ });
20
+ let timer;
21
+ const timeout = new Promise((_, reject) => {
22
+ timer = setTimeout(() => reject(new Error(timeoutMessage)), DOWNLOAD_TIMEOUT_MS);
23
+ });
24
+ try {
25
+ return await consumeDownload(Promise.race([download, timeout]));
26
+ } finally {
27
+ clearTimeout(timer);
28
+ }
29
+ } finally {
30
+ try {
31
+ if (!download || settled) await cleanup();
32
+ else download.then(cleanup, cleanup);
33
+ } finally {
34
+ if (origDebug !== void 0) process.env.DEBUG = origDebug;
35
+ }
36
+ }
37
+ }
38
+ //#endregion
39
+ export { DOWNLOAD_TIMEOUT_MS, resolveGitHubAuthToken, withStagedDownload };
40
+
41
+ //# sourceMappingURL=download.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"download.js","names":[],"sources":["../../../src/lib/utils/download.ts"],"sourcesContent":["import { downloadTemplate } from \"giget\";\n\nexport const DOWNLOAD_TIMEOUT_MS = 30_000;\n\nexport function resolveGitHubAuthToken(): string | undefined {\n const token =\n process.env.GIGET_AUTH ?? process.env.GITHUB_TOKEN ?? process.env.GH_TOKEN;\n const trimmed = token?.trim();\n return trimmed || undefined;\n}\n\nexport async function withStagedDownload<T>(\n source: string,\n options: NonNullable<Parameters<typeof downloadTemplate>[1]>,\n timeoutMessage: string,\n cleanup: () => void | Promise<void>,\n consumeDownload: (download: Promise<unknown>) => Promise<T>,\n): Promise<T> {\n // giget logs to console.debug whenever DEBUG is set, which the `debug`\n // package does at module load for an unrelated namespace.\n const origDebug = process.env.DEBUG;\n delete process.env.DEBUG;\n let download: Promise<unknown> | undefined;\n let settled = false;\n try {\n const authToken = resolveGitHubAuthToken();\n download = downloadTemplate(source, {\n ...options,\n ...(authToken ? { auth: authToken } : {}),\n }).finally(() => {\n settled = true;\n });\n\n let timer: ReturnType<typeof setTimeout>;\n const timeout = new Promise<never>((_, reject) => {\n timer = setTimeout(\n () => reject(new Error(timeoutMessage)),\n DOWNLOAD_TIMEOUT_MS,\n );\n });\n try {\n return await consumeDownload(Promise.race([download, timeout]));\n } finally {\n clearTimeout(timer!);\n }\n } finally {\n try {\n if (!download || settled) {\n await cleanup();\n } else {\n void download.then(cleanup, cleanup);\n }\n } finally {\n if (origDebug !== undefined) process.env.DEBUG = origDebug;\n }\n }\n}\n"],"mappings":";;AAEA,MAAa,sBAAsB;AAEnC,SAAgB,yBAA6C;CAI3D,QAFE,QAAQ,IAAI,cAAc,QAAQ,IAAI,gBAAgB,QAAQ,IAAI,SAAA,EAC7C,KAAK,KACV,KAAA;AACpB;AAEA,eAAsB,mBACpB,QACA,SACA,gBACA,SACA,iBACY;CAGZ,MAAM,YAAY,QAAQ,IAAI;CAC9B,OAAO,QAAQ,IAAI;CACnB,IAAI;CACJ,IAAI,UAAU;CACd,IAAI;EACF,MAAM,YAAY,uBAAuB;EACzC,WAAW,iBAAiB,QAAQ;GAClC,GAAG;GACH,GAAI,YAAY,EAAE,MAAM,UAAU,IAAI,CAAC;EACzC,CAAC,CAAC,CAAC,cAAc;GACf,UAAU;EACZ,CAAC;EAED,IAAI;EACJ,MAAM,UAAU,IAAI,SAAgB,GAAG,WAAW;GAChD,QAAQ,iBACA,OAAO,IAAI,MAAM,cAAc,CAAC,GACtC,mBACF;EACF,CAAC;EACD,IAAI;GACF,OAAO,MAAM,gBAAgB,QAAQ,KAAK,CAAC,UAAU,OAAO,CAAC,CAAC;EAChE,UAAU;GACR,aAAa,KAAM;EACrB;CACF,UAAU;EACR,IAAI;GACF,IAAI,CAAC,YAAY,SACf,MAAM,QAAQ;QAEd,SAAc,KAAK,SAAS,OAAO;EAEvC,UAAU;GACR,IAAI,cAAc,KAAA,GAAW,QAAQ,IAAI,QAAQ;EACnD;CACF;AACF"}
@@ -12,5 +12,4 @@ export declare function readProjectFiles(pattern: string, options: {
12
12
  content: string;
13
13
  }>;
14
14
  export declare function scanForImport(importPattern: string | string[], options?: ScanOptions): boolean;
15
- export declare function getFilesContaining(searchString: string, options?: ScanOptions): string[];
16
15
  //# sourceMappingURL=file-scanner.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"file-scanner.d.ts","sourceRoot":"","sources":["../../../src/lib/utils/file-scanner.ts"],"names":[],"mappings":"AAIA,MAAM,WAAW,WAAW;IAC1B,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,MAAM,CAAC,EAAE,MAAM,EAAE,CAAC;CACnB;AAED,wBAAiB,gBAAgB,CAC/B,OAAO,EAAE,MAAM,EACf,OAAO,EAAE;IAAE,GAAG,EAAE,MAAM,CAAC;IAAC,MAAM,CAAC,EAAE,MAAM,EAAE,CAAA;CAAE,GAC1C,SAAS,CAAC;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,QAAQ,EAAE,MAAM,CAAC;IAAC,OAAO,EAAE,MAAM,CAAA;CAAE,CAAC,CAYhE;AAED,wBAAgB,aAAa,CAC3B,aAAa,EAAE,MAAM,GAAG,MAAM,EAAE,EAChC,OAAO,GAAE,WAAgB,GACxB,OAAO,CAoBT;AAED,wBAAgB,kBAAkB,CAChC,YAAY,EAAE,MAAM,EACpB,OAAO,GAAE,WAAgB,GACxB,MAAM,EAAE,CAqBV"}
1
+ {"version":3,"file":"file-scanner.d.ts","sourceRoot":"","sources":["../../../src/lib/utils/file-scanner.ts"],"names":[],"mappings":"AAIA,MAAM,WAAW,WAAW;IAC1B,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,MAAM,CAAC,EAAE,MAAM,EAAE,CAAC;CACnB;AAED,wBAAiB,gBAAgB,CAC/B,OAAO,EAAE,MAAM,EACf,OAAO,EAAE;IAAE,GAAG,EAAE,MAAM,CAAC;IAAC,MAAM,CAAC,EAAE,MAAM,EAAE,CAAA;CAAE,GAC1C,SAAS,CAAC;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,QAAQ,EAAE,MAAM,CAAC;IAAC,OAAO,EAAE,MAAM,CAAA;CAAE,CAAC,CAYhE;AAED,wBAAgB,aAAa,CAC3B,aAAa,EAAE,MAAM,GAAG,MAAM,EAAE,EAChC,OAAO,GAAE,WAAgB,GACxB,OAAO,CAoBT"}
@@ -32,22 +32,7 @@ function scanForImport(importPattern, options = {}) {
32
32
  })) if (patterns.some((p) => content.includes(p))) return true;
33
33
  return false;
34
34
  }
35
- function getFilesContaining(searchString, options = {}) {
36
- const cwd = options.cwd || process.cwd();
37
- const pattern = options.pattern || "**/*.{js,jsx,ts,tsx}";
38
- const ignore = options.ignore || [
39
- "**/node_modules/**",
40
- "**/dist/**",
41
- "**/build/**"
42
- ];
43
- const result = [];
44
- for (const { fullPath, content } of readProjectFiles(pattern, {
45
- cwd,
46
- ignore
47
- })) if (content.includes(searchString)) result.push(fullPath);
48
- return result;
49
- }
50
35
  //#endregion
51
- export { getFilesContaining, readProjectFiles, scanForImport };
36
+ export { readProjectFiles, scanForImport };
52
37
 
53
38
  //# sourceMappingURL=file-scanner.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"file-scanner.js","names":["globSync","path","fs"],"sources":["../../../src/lib/utils/file-scanner.ts"],"sourcesContent":["import * as fs from \"node:fs\";\nimport * as path from \"node:path\";\nimport { sync as globSync } from \"glob\";\n\nexport interface ScanOptions {\n cwd?: string;\n pattern?: string;\n ignore?: string[];\n}\n\nexport function* readProjectFiles(\n pattern: string,\n options: { cwd: string; ignore?: string[] },\n): Generator<{ file: string; fullPath: string; content: string }> {\n const files = globSync(pattern, options);\n\n for (const file of files) {\n const fullPath = path.join(options.cwd, file);\n try {\n const content = fs.readFileSync(fullPath, \"utf8\");\n yield { file, fullPath, content };\n } catch {\n continue;\n }\n }\n}\n\nexport function scanForImport(\n importPattern: string | string[],\n options: ScanOptions = {},\n): boolean {\n const cwd = options.cwd || process.cwd();\n const pattern = options.pattern || \"**/*.{js,jsx,ts,tsx}\";\n const ignore = options.ignore || [\n \"**/node_modules/**\",\n \"**/dist/**\",\n \"**/build/**\",\n ];\n\n const patterns = Array.isArray(importPattern)\n ? importPattern\n : [importPattern];\n\n for (const { content } of readProjectFiles(pattern, { cwd, ignore })) {\n if (patterns.some((p) => content.includes(p))) {\n return true;\n }\n }\n\n return false;\n}\n\nexport function getFilesContaining(\n searchString: string,\n options: ScanOptions = {},\n): string[] {\n const cwd = options.cwd || process.cwd();\n const pattern = options.pattern || \"**/*.{js,jsx,ts,tsx}\";\n const ignore = options.ignore || [\n \"**/node_modules/**\",\n \"**/dist/**\",\n \"**/build/**\",\n ];\n\n const result: string[] = [];\n\n for (const { fullPath, content } of readProjectFiles(pattern, {\n cwd,\n ignore,\n })) {\n if (content.includes(searchString)) {\n result.push(fullPath);\n }\n }\n\n return result;\n}\n"],"mappings":";;;;AAUA,UAAiB,iBACf,SACA,SACgE;CAChE,MAAM,QAAQA,KAAS,SAAS,OAAO;CAEvC,KAAK,MAAM,QAAQ,OAAO;EACxB,MAAM,WAAWC,OAAK,KAAK,QAAQ,KAAK,IAAI;EAC5C,IAAI;GAEF,MAAM;IAAE;IAAM;IAAU,SADRC,KAAG,aAAa,UAAU,MACZ;GAAE;EAClC,QAAQ;GACN;EACF;CACF;AACF;AAEA,SAAgB,cACd,eACA,UAAuB,CAAC,GACf;CACT,MAAM,MAAM,QAAQ,OAAO,QAAQ,IAAI;CACvC,MAAM,UAAU,QAAQ,WAAW;CACnC,MAAM,SAAS,QAAQ,UAAU;EAC/B;EACA;EACA;CACF;CAEA,MAAM,WAAW,MAAM,QAAQ,aAAa,IACxC,gBACA,CAAC,aAAa;CAElB,KAAK,MAAM,EAAE,aAAa,iBAAiB,SAAS;EAAE;EAAK;CAAO,CAAC,GACjE,IAAI,SAAS,MAAM,MAAM,QAAQ,SAAS,CAAC,CAAC,GAC1C,OAAO;CAIX,OAAO;AACT;AAEA,SAAgB,mBACd,cACA,UAAuB,CAAC,GACd;CACV,MAAM,MAAM,QAAQ,OAAO,QAAQ,IAAI;CACvC,MAAM,UAAU,QAAQ,WAAW;CACnC,MAAM,SAAS,QAAQ,UAAU;EAC/B;EACA;EACA;CACF;CAEA,MAAM,SAAmB,CAAC;CAE1B,KAAK,MAAM,EAAE,UAAU,aAAa,iBAAiB,SAAS;EAC5D;EACA;CACF,CAAC,GACC,IAAI,QAAQ,SAAS,YAAY,GAC/B,OAAO,KAAK,QAAQ;CAIxB,OAAO;AACT"}
1
+ {"version":3,"file":"file-scanner.js","names":["globSync","path","fs"],"sources":["../../../src/lib/utils/file-scanner.ts"],"sourcesContent":["import * as fs from \"node:fs\";\nimport * as path from \"node:path\";\nimport { sync as globSync } from \"glob\";\n\nexport interface ScanOptions {\n cwd?: string;\n pattern?: string;\n ignore?: string[];\n}\n\nexport function* readProjectFiles(\n pattern: string,\n options: { cwd: string; ignore?: string[] },\n): Generator<{ file: string; fullPath: string; content: string }> {\n const files = globSync(pattern, options);\n\n for (const file of files) {\n const fullPath = path.join(options.cwd, file);\n try {\n const content = fs.readFileSync(fullPath, \"utf8\");\n yield { file, fullPath, content };\n } catch {\n continue;\n }\n }\n}\n\nexport function scanForImport(\n importPattern: string | string[],\n options: ScanOptions = {},\n): boolean {\n const cwd = options.cwd || process.cwd();\n const pattern = options.pattern || \"**/*.{js,jsx,ts,tsx}\";\n const ignore = options.ignore || [\n \"**/node_modules/**\",\n \"**/dist/**\",\n \"**/build/**\",\n ];\n\n const patterns = Array.isArray(importPattern)\n ? importPattern\n : [importPattern];\n\n for (const { content } of readProjectFiles(pattern, { cwd, ignore })) {\n if (patterns.some((p) => content.includes(p))) {\n return true;\n }\n }\n\n return false;\n}\n"],"mappings":";;;;AAUA,UAAiB,iBACf,SACA,SACgE;CAChE,MAAM,QAAQA,KAAS,SAAS,OAAO;CAEvC,KAAK,MAAM,QAAQ,OAAO;EACxB,MAAM,WAAWC,OAAK,KAAK,QAAQ,KAAK,IAAI;EAC5C,IAAI;GAEF,MAAM;IAAE;IAAM;IAAU,SADRC,KAAG,aAAa,UAAU,MACZ;GAAE;EAClC,QAAQ;GACN;EACF;CACF;AACF;AAEA,SAAgB,cACd,eACA,UAAuB,CAAC,GACf;CACT,MAAM,MAAM,QAAQ,OAAO,QAAQ,IAAI;CACvC,MAAM,UAAU,QAAQ,WAAW;CACnC,MAAM,SAAS,QAAQ,UAAU;EAC/B;EACA;EACA;CACF;CAEA,MAAM,WAAW,MAAM,QAAQ,aAAa,IACxC,gBACA,CAAC,aAAa;CAElB,KAAK,MAAM,EAAE,aAAa,iBAAiB,SAAS;EAAE;EAAK;CAAO,CAAC,GACjE,IAAI,SAAS,MAAM,MAAM,QAAQ,SAAS,CAAC,CAAC,GAC1C,OAAO;CAIX,OAAO;AACT"}
@@ -1,4 +1,11 @@
1
1
  export type PackageManagerName = "npm" | "pnpm" | "yarn" | "bun";
2
+ export declare function dlxCommand(pm: PackageManagerName): [string, string[]];
3
+ export declare function resolvePackageManager(opts: {
4
+ useNpm?: boolean;
5
+ usePnpm?: boolean;
6
+ useYarn?: boolean;
7
+ useBun?: boolean;
8
+ }): PackageManagerName | undefined;
2
9
  export declare function askQuestion(query: string): Promise<string>;
3
10
  export declare function isPackageInstalled(pkg: string, cwd?: string): boolean;
4
11
  export interface InstallCommand {
@@ -1 +1 @@
1
- {"version":3,"file":"package-manager.d.ts","sourceRoot":"","sources":["../../../src/lib/utils/package-manager.ts"],"names":[],"mappings":"AAOA,MAAM,MAAM,kBAAkB,GAAG,KAAK,GAAG,MAAM,GAAG,MAAM,GAAG,KAAK,CAAC;AAEjE,wBAAgB,WAAW,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CAkC1D;AAED,wBAAgB,kBAAkB,CAChC,GAAG,EAAE,MAAM,EACX,GAAG,GAAE,MAAsB,GAC1B,OAAO,CAgBT;AAED,MAAM,WAAW,cAAc;IAC7B,OAAO,EAAE,MAAM,CAAC;IAChB,IAAI,EAAE,MAAM,EAAE,CAAC;CAChB;AAED,wBAAsB,iBAAiB,CACrC,WAAW,EAAE,MAAM,GAAG,MAAM,EAAE,EAC9B,GAAG,CAAC,EAAE,MAAM,GACX,OAAO,CAAC,cAAc,CAAC,CAazB;AAYD,wBAAsB,2BAA2B,CAC/C,GAAG,EAAE,MAAM,EACX,cAAc,CAAC,EAAE,kBAAkB,GAClC,OAAO,CAAC,kBAAkB,CAAC,CAS7B;AAED,wBAAsB,cAAc,CAClC,WAAW,EAAE,MAAM,EACnB,GAAG,CAAC,EAAE,MAAM,GACX,OAAO,CAAC,OAAO,CAAC,CAUlB"}
1
+ {"version":3,"file":"package-manager.d.ts","sourceRoot":"","sources":["../../../src/lib/utils/package-manager.ts"],"names":[],"mappings":"AAOA,MAAM,MAAM,kBAAkB,GAAG,KAAK,GAAG,MAAM,GAAG,MAAM,GAAG,KAAK,CAAC;AAEjE,wBAAgB,UAAU,CAAC,EAAE,EAAE,kBAAkB,GAAG,CAAC,MAAM,EAAE,MAAM,EAAE,CAAC,CAWrE;AAED,wBAAgB,qBAAqB,CAAC,IAAI,EAAE;IAC1C,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,MAAM,CAAC,EAAE,OAAO,CAAC;CAClB,GAAG,kBAAkB,GAAG,SAAS,CAMjC;AAED,wBAAgB,WAAW,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CAkC1D;AAED,wBAAgB,kBAAkB,CAChC,GAAG,EAAE,MAAM,EACX,GAAG,GAAE,MAAsB,GAC1B,OAAO,CAgBT;AAED,MAAM,WAAW,cAAc;IAC7B,OAAO,EAAE,MAAM,CAAC;IAChB,IAAI,EAAE,MAAM,EAAE,CAAC;CAChB;AAED,wBAAsB,iBAAiB,CACrC,WAAW,EAAE,MAAM,GAAG,MAAM,EAAE,EAC9B,GAAG,CAAC,EAAE,MAAM,GACX,OAAO,CAAC,cAAc,CAAC,CAazB;AAYD,wBAAsB,2BAA2B,CAC/C,GAAG,EAAE,MAAM,EACX,cAAc,CAAC,EAAE,kBAAkB,GAClC,OAAO,CAAC,kBAAkB,CAAC,CAS7B;AAED,wBAAsB,cAAc,CAClC,WAAW,EAAE,MAAM,EACnB,GAAG,CAAC,EAAE,MAAM,GACX,OAAO,CAAC,OAAO,CAAC,CAUlB"}
@@ -5,6 +5,20 @@ import * as path$1 from "node:path";
5
5
  import { detect } from "detect-package-manager";
6
6
  import * as readline from "node:readline";
7
7
  //#region src/lib/utils/package-manager.ts
8
+ function dlxCommand(pm) {
9
+ switch (pm) {
10
+ case "pnpm": return ["pnpm", ["dlx"]];
11
+ case "yarn": return ["yarn", ["dlx"]];
12
+ case "bun": return ["bunx", []];
13
+ case "npm": return ["npx", ["--yes"]];
14
+ }
15
+ }
16
+ function resolvePackageManager(opts) {
17
+ if (opts.useNpm) return "npm";
18
+ if (opts.usePnpm) return "pnpm";
19
+ if (opts.useYarn) return "yarn";
20
+ if (opts.useBun) return "bun";
21
+ }
8
22
  function askQuestion(query) {
9
23
  return new Promise((resolve) => {
10
24
  if (process.stdin.readableEnded) {
@@ -93,6 +107,6 @@ async function installPackage(packageName, cwd) {
93
107
  }
94
108
  }
95
109
  //#endregion
96
- export { askQuestion, getInstallCommand, installPackage, isPackageInstalled, resolvePackageManagerForCwd };
110
+ export { askQuestion, dlxCommand, getInstallCommand, installPackage, isPackageInstalled, resolvePackageManager, resolvePackageManagerForCwd };
97
111
 
98
112
  //# sourceMappingURL=package-manager.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"package-manager.js","names":["path","fs"],"sources":["../../../src/lib/utils/package-manager.ts"],"sourcesContent":["import * as fs from \"node:fs\";\nimport * as path from \"node:path\";\nimport { detect } from \"detect-package-manager\";\nimport * as readline from \"node:readline\";\nimport { logger } from \"./logger\";\nimport { runSpawn, SpawnSignalError } from \"../run-spawn\";\n\nexport type PackageManagerName = \"npm\" | \"pnpm\" | \"yarn\" | \"bun\";\n\nexport function askQuestion(query: string): Promise<string> {\n return new Promise((resolve) => {\n // A stream only reaches EOF once, so a run that already consumed stdin gets\n // no further `end` and an interface built over it would wait on a `close`\n // that cannot arrive. An upgrade asks up to three questions.\n if (process.stdin.readableEnded) {\n resolve(\"\");\n return;\n }\n const rl = readline.createInterface({\n input: process.stdin,\n output: process.stdout,\n });\n // stdin at EOF (a piped or CI run) emits `close` without a `line`, so the\n // question callback alone would leave this pending forever and the process\n // would exit 0 with the remaining work silently skipped. An empty answer is\n // what pressing Enter sends, so EOF lands on the prompt's own default.\n // A final answer with no trailing newline arrives as `line` instead of\n // through the callback, and has to win over that default.\n // Ctrl-C in raw mode is delivered as this event rather than as a signal,\n // and without a listener readline answers it by closing — which the EOF\n // default would then read as approval. A cancelled prompt declines.\n let cancelled = false;\n rl.on(\"SIGINT\", () => {\n cancelled = true;\n rl.close();\n });\n rl.on(\"line\", resolve);\n rl.on(\"close\", () => resolve(cancelled ? \"n\" : \"\"));\n rl.question(query, (answer) => {\n resolve(answer);\n rl.close();\n });\n });\n}\n\nexport function isPackageInstalled(\n pkg: string,\n cwd: string = process.cwd(),\n): boolean {\n try {\n const pkgJsonPath = path.join(cwd, \"package.json\");\n if (fs.existsSync(pkgJsonPath)) {\n const pkgJson = JSON.parse(fs.readFileSync(pkgJsonPath, \"utf8\"));\n const deps = pkgJson.dependencies || {};\n const devDeps = pkgJson.devDependencies || {};\n if (deps[pkg] || devDeps[pkg]) {\n return true;\n }\n }\n } catch {\n // Fall back to node_modules check below.\n }\n const modulePath = path.join(cwd, \"node_modules\", ...pkg.split(\"/\"));\n return fs.existsSync(modulePath);\n}\n\nexport interface InstallCommand {\n command: string;\n args: string[];\n}\n\nexport async function getInstallCommand(\n packageName: string | string[],\n cwd?: string,\n): Promise<InstallCommand> {\n const pm = await detect({ cwd });\n const packages = Array.isArray(packageName) ? packageName : [packageName];\n switch (pm) {\n case \"yarn\":\n return { command: \"yarn\", args: [\"add\", ...packages] };\n case \"pnpm\":\n return { command: \"pnpm\", args: [\"add\", ...packages] };\n case \"bun\":\n return { command: \"bun\", args: [\"add\", ...packages] };\n default:\n return { command: \"npm\", args: [\"install\", ...packages] };\n }\n}\n\nfunction detectFromUserAgent(): PackageManagerName | undefined {\n const ua = process.env.npm_config_user_agent;\n if (!ua) return undefined;\n if (ua.startsWith(\"bun/\")) return \"bun\";\n if (ua.startsWith(\"pnpm/\")) return \"pnpm\";\n if (ua.startsWith(\"yarn/\")) return \"yarn\";\n if (ua.startsWith(\"npm/\")) return \"npm\";\n return undefined;\n}\n\nexport async function resolvePackageManagerForCwd(\n cwd: string,\n packageManager?: PackageManagerName,\n): Promise<PackageManagerName> {\n if (packageManager) return packageManager;\n const fromAgent = detectFromUserAgent();\n if (fromAgent) return fromAgent;\n try {\n return await detect({ cwd });\n } catch {\n return \"npm\";\n }\n}\n\nexport async function installPackage(\n packageName: string,\n cwd?: string,\n): Promise<boolean> {\n try {\n const { command, args } = await getInstallCommand(packageName, cwd);\n await runSpawn(command, args, cwd);\n return true;\n } catch (e) {\n if (e instanceof SpawnSignalError) throw e;\n logger.error(`Installation failed: ${String(e)}`);\n return false;\n }\n}\n"],"mappings":";;;;;;;AASA,SAAgB,YAAY,OAAgC;CAC1D,OAAO,IAAI,SAAS,YAAY;EAI9B,IAAI,QAAQ,MAAM,eAAe;GAC/B,QAAQ,EAAE;GACV;EACF;EACA,MAAM,KAAK,SAAS,gBAAgB;GAClC,OAAO,QAAQ;GACf,QAAQ,QAAQ;EAClB,CAAC;EAUD,IAAI,YAAY;EAChB,GAAG,GAAG,gBAAgB;GACpB,YAAY;GACZ,GAAG,MAAM;EACX,CAAC;EACD,GAAG,GAAG,QAAQ,OAAO;EACrB,GAAG,GAAG,eAAe,QAAQ,YAAY,MAAM,EAAE,CAAC;EAClD,GAAG,SAAS,QAAQ,WAAW;GAC7B,QAAQ,MAAM;GACd,GAAG,MAAM;EACX,CAAC;CACH,CAAC;AACH;AAEA,SAAgB,mBACd,KACA,MAAc,QAAQ,IAAI,GACjB;CACT,IAAI;EACF,MAAM,cAAcA,OAAK,KAAK,KAAK,cAAc;EACjD,IAAIC,KAAG,WAAW,WAAW,GAAG;GAC9B,MAAM,UAAU,KAAK,MAAMA,KAAG,aAAa,aAAa,MAAM,CAAC;GAC/D,MAAM,OAAO,QAAQ,gBAAgB,CAAC;GACtC,MAAM,UAAU,QAAQ,mBAAmB,CAAC;GAC5C,IAAI,KAAK,QAAQ,QAAQ,MACvB,OAAO;EAEX;CACF,QAAQ,CAER;CACA,MAAM,aAAaD,OAAK,KAAK,KAAK,gBAAgB,GAAG,IAAI,MAAM,GAAG,CAAC;CACnE,OAAOC,KAAG,WAAW,UAAU;AACjC;AAOA,eAAsB,kBACpB,aACA,KACyB;CACzB,MAAM,KAAK,MAAM,OAAO,EAAE,IAAI,CAAC;CAC/B,MAAM,WAAW,MAAM,QAAQ,WAAW,IAAI,cAAc,CAAC,WAAW;CACxE,QAAQ,IAAR;EACE,KAAK,QACH,OAAO;GAAE,SAAS;GAAQ,MAAM,CAAC,OAAO,GAAG,QAAQ;EAAE;EACvD,KAAK,QACH,OAAO;GAAE,SAAS;GAAQ,MAAM,CAAC,OAAO,GAAG,QAAQ;EAAE;EACvD,KAAK,OACH,OAAO;GAAE,SAAS;GAAO,MAAM,CAAC,OAAO,GAAG,QAAQ;EAAE;EACtD,SACE,OAAO;GAAE,SAAS;GAAO,MAAM,CAAC,WAAW,GAAG,QAAQ;EAAE;CAC5D;AACF;AAEA,SAAS,sBAAsD;CAC7D,MAAM,KAAK,QAAQ,IAAI;CACvB,IAAI,CAAC,IAAI,OAAO,KAAA;CAChB,IAAI,GAAG,WAAW,MAAM,GAAG,OAAO;CAClC,IAAI,GAAG,WAAW,OAAO,GAAG,OAAO;CACnC,IAAI,GAAG,WAAW,OAAO,GAAG,OAAO;CACnC,IAAI,GAAG,WAAW,MAAM,GAAG,OAAO;AAEpC;AAEA,eAAsB,4BACpB,KACA,gBAC6B;CAC7B,IAAI,gBAAgB,OAAO;CAC3B,MAAM,YAAY,oBAAoB;CACtC,IAAI,WAAW,OAAO;CACtB,IAAI;EACF,OAAO,MAAM,OAAO,EAAE,IAAI,CAAC;CAC7B,QAAQ;EACN,OAAO;CACT;AACF;AAEA,eAAsB,eACpB,aACA,KACkB;CAClB,IAAI;EACF,MAAM,EAAE,SAAS,SAAS,MAAM,kBAAkB,aAAa,GAAG;EAClE,MAAM,SAAS,SAAS,MAAM,GAAG;EACjC,OAAO;CACT,SAAS,GAAG;EACV,IAAI,aAAa,kBAAkB,MAAM;EACzC,OAAO,MAAM,wBAAwB,OAAO,CAAC,GAAG;EAChD,OAAO;CACT;AACF"}
1
+ {"version":3,"file":"package-manager.js","names":["path","fs"],"sources":["../../../src/lib/utils/package-manager.ts"],"sourcesContent":["import * as fs from \"node:fs\";\nimport * as path from \"node:path\";\nimport { detect } from \"detect-package-manager\";\nimport * as readline from \"node:readline\";\nimport { logger } from \"./logger\";\nimport { runSpawn, SpawnSignalError } from \"../run-spawn\";\n\nexport type PackageManagerName = \"npm\" | \"pnpm\" | \"yarn\" | \"bun\";\n\nexport function dlxCommand(pm: PackageManagerName): [string, string[]] {\n switch (pm) {\n case \"pnpm\":\n return [\"pnpm\", [\"dlx\"]];\n case \"yarn\":\n return [\"yarn\", [\"dlx\"]];\n case \"bun\":\n return [\"bunx\", []];\n case \"npm\":\n return [\"npx\", [\"--yes\"]];\n }\n}\n\nexport function resolvePackageManager(opts: {\n useNpm?: boolean;\n usePnpm?: boolean;\n useYarn?: boolean;\n useBun?: boolean;\n}): PackageManagerName | undefined {\n if (opts.useNpm) return \"npm\";\n if (opts.usePnpm) return \"pnpm\";\n if (opts.useYarn) return \"yarn\";\n if (opts.useBun) return \"bun\";\n return undefined;\n}\n\nexport function askQuestion(query: string): Promise<string> {\n return new Promise((resolve) => {\n // A stream only reaches EOF once, so a run that already consumed stdin gets\n // no further `end` and an interface built over it would wait on a `close`\n // that cannot arrive. An upgrade asks up to three questions.\n if (process.stdin.readableEnded) {\n resolve(\"\");\n return;\n }\n const rl = readline.createInterface({\n input: process.stdin,\n output: process.stdout,\n });\n // stdin at EOF (a piped or CI run) emits `close` without a `line`, so the\n // question callback alone would leave this pending forever and the process\n // would exit 0 with the remaining work silently skipped. An empty answer is\n // what pressing Enter sends, so EOF lands on the prompt's own default.\n // A final answer with no trailing newline arrives as `line` instead of\n // through the callback, and has to win over that default.\n // Ctrl-C in raw mode is delivered as this event rather than as a signal,\n // and without a listener readline answers it by closing — which the EOF\n // default would then read as approval. A cancelled prompt declines.\n let cancelled = false;\n rl.on(\"SIGINT\", () => {\n cancelled = true;\n rl.close();\n });\n rl.on(\"line\", resolve);\n rl.on(\"close\", () => resolve(cancelled ? \"n\" : \"\"));\n rl.question(query, (answer) => {\n resolve(answer);\n rl.close();\n });\n });\n}\n\nexport function isPackageInstalled(\n pkg: string,\n cwd: string = process.cwd(),\n): boolean {\n try {\n const pkgJsonPath = path.join(cwd, \"package.json\");\n if (fs.existsSync(pkgJsonPath)) {\n const pkgJson = JSON.parse(fs.readFileSync(pkgJsonPath, \"utf8\"));\n const deps = pkgJson.dependencies || {};\n const devDeps = pkgJson.devDependencies || {};\n if (deps[pkg] || devDeps[pkg]) {\n return true;\n }\n }\n } catch {\n // Fall back to node_modules check below.\n }\n const modulePath = path.join(cwd, \"node_modules\", ...pkg.split(\"/\"));\n return fs.existsSync(modulePath);\n}\n\nexport interface InstallCommand {\n command: string;\n args: string[];\n}\n\nexport async function getInstallCommand(\n packageName: string | string[],\n cwd?: string,\n): Promise<InstallCommand> {\n const pm = await detect({ cwd });\n const packages = Array.isArray(packageName) ? packageName : [packageName];\n switch (pm) {\n case \"yarn\":\n return { command: \"yarn\", args: [\"add\", ...packages] };\n case \"pnpm\":\n return { command: \"pnpm\", args: [\"add\", ...packages] };\n case \"bun\":\n return { command: \"bun\", args: [\"add\", ...packages] };\n default:\n return { command: \"npm\", args: [\"install\", ...packages] };\n }\n}\n\nfunction detectFromUserAgent(): PackageManagerName | undefined {\n const ua = process.env.npm_config_user_agent;\n if (!ua) return undefined;\n if (ua.startsWith(\"bun/\")) return \"bun\";\n if (ua.startsWith(\"pnpm/\")) return \"pnpm\";\n if (ua.startsWith(\"yarn/\")) return \"yarn\";\n if (ua.startsWith(\"npm/\")) return \"npm\";\n return undefined;\n}\n\nexport async function resolvePackageManagerForCwd(\n cwd: string,\n packageManager?: PackageManagerName,\n): Promise<PackageManagerName> {\n if (packageManager) return packageManager;\n const fromAgent = detectFromUserAgent();\n if (fromAgent) return fromAgent;\n try {\n return await detect({ cwd });\n } catch {\n return \"npm\";\n }\n}\n\nexport async function installPackage(\n packageName: string,\n cwd?: string,\n): Promise<boolean> {\n try {\n const { command, args } = await getInstallCommand(packageName, cwd);\n await runSpawn(command, args, cwd);\n return true;\n } catch (e) {\n if (e instanceof SpawnSignalError) throw e;\n logger.error(`Installation failed: ${String(e)}`);\n return false;\n }\n}\n"],"mappings":"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"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "assistant-ui",
3
- "version": "0.0.121",
3
+ "version": "0.0.123",
4
4
  "description": "CLI for assistant-ui",
5
5
  "keywords": [
6
6
  "cli",
@@ -49,7 +49,7 @@
49
49
  "@types/cross-spawn": "^6.0.6",
50
50
  "@types/debug": "^4.1.13",
51
51
  "@types/jscodeshift": "^17.3.0",
52
- "@types/node": "^26.6.3",
52
+ "@types/node": "^26.6.4",
53
53
  "@types/semver": "^7.8.0",
54
54
  "@vitest/coverage-v8": "^5.0.3",
55
55
  "vitest": "^5.0.3"
@@ -70,7 +70,7 @@
70
70
  "scripts": {
71
71
  "build": "aui-build && node scripts/copy-cloud-harness-template.mjs",
72
72
  "test": "vitest run && node --test scripts/copy-cloud-harness-template.test.mjs",
73
- "test:coverage": "vitest run --coverage --coverage.reporter=text --coverage.reporter=html --coverage.reporter=json-summary",
73
+ "test:coverage": "vitest run --coverage --coverage.reporter=text --coverage.reporter=html --coverage.reporter=json-summary && node --test scripts/copy-cloud-harness-template.test.mjs",
74
74
  "typecheck": "tsc --noEmit && tsc --noEmit -p tsconfig.test.json",
75
75
  "test:watch": "vitest"
76
76
  }
@@ -6,9 +6,10 @@ import {
6
6
  getComponentsJsonStyle,
7
7
  resolveRegistryItemUrl,
8
8
  } from "../lib/utils/registry";
9
- import { dlxCommand, resolvePackageManager } from "../lib/create-project";
10
9
  import { runSpawn, SpawnExitError, SpawnSignalError } from "../lib/run-spawn";
11
10
  import {
11
+ dlxCommand,
12
+ resolvePackageManager,
12
13
  type PackageManagerName,
13
14
  resolvePackageManagerForCwd,
14
15
  } from "../lib/utils/package-manager";
@@ -6,10 +6,8 @@ import * as p from "@clack/prompts";
6
6
  import { logger } from "../lib/utils/logger";
7
7
  import {
8
8
  cleanupPendingProjectDownloads,
9
- dlxCommand,
10
9
  downloadProject,
11
10
  resolveLatestReleaseRef,
12
- resolvePackageManager,
13
11
  scaffoldProject,
14
12
  transformProject,
15
13
  type TransformResult,
@@ -20,7 +18,11 @@ import {
20
18
  SpawnExitError,
21
19
  SpawnSignalError,
22
20
  } from "../lib/run-spawn";
23
- import { resolvePackageManagerForCwd } from "../lib/utils/package-manager";
21
+ import {
22
+ dlxCommand,
23
+ resolvePackageManager,
24
+ resolvePackageManagerForCwd,
25
+ } from "../lib/utils/package-manager";
24
26
  import {
25
27
  buildSkillsAddCommand,
26
28
  resolveSkillsInstall,
@@ -1,10 +1,13 @@
1
1
  import { Command, Option } from "commander";
2
2
  import fs from "node:fs";
3
3
  import path from "node:path";
4
- import { dlxCommand, resolvePackageManager } from "../lib/create-project";
5
4
  import { runSpawn, SpawnExitError, SpawnSignalError } from "../lib/run-spawn";
6
5
  import { logger } from "../lib/utils/logger";
7
- import { resolvePackageManagerForCwd } from "../lib/utils/package-manager";
6
+ import {
7
+ dlxCommand,
8
+ resolvePackageManager,
9
+ resolvePackageManagerForCwd,
10
+ } from "../lib/utils/package-manager";
8
11
  import {
9
12
  getComponentsJsonStyle,
10
13
  resolveQuickStartRegistryUrl,