assistant-ui 0.0.112 → 0.0.114
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/dist/codemods/v0-12/assistant-api-to-aui.d.ts.map +1 -1
- package/dist/codemods/v0-12/assistant-api-to-aui.js +87 -62
- package/dist/codemods/v0-12/assistant-api-to-aui.js.map +1 -1
- package/dist/codemods/v0-12/primitive-if-to-aui-if.d.ts.map +1 -1
- package/dist/codemods/v0-12/primitive-if-to-aui-if.js +31 -45
- package/dist/codemods/v0-12/primitive-if-to-aui-if.js.map +1 -1
- package/dist/commands/add.d.ts +1 -1
- package/dist/commands/add.d.ts.map +1 -1
- package/dist/commands/add.js +4 -2
- package/dist/commands/add.js.map +1 -1
- package/dist/commands/create.d.ts.map +1 -1
- package/dist/commands/create.js +33 -10
- package/dist/commands/create.js.map +1 -1
- package/dist/commands/info.d.ts.map +1 -1
- package/dist/commands/info.js +2 -1
- package/dist/commands/info.js.map +1 -1
- package/dist/commands/init.d.ts.map +1 -1
- package/dist/commands/init.js +4 -2
- package/dist/commands/init.js.map +1 -1
- package/dist/commands/mcp.d.ts.map +1 -1
- package/dist/commands/mcp.js +52 -40
- package/dist/commands/mcp.js.map +1 -1
- package/dist/commands/update.js +6 -7
- package/dist/commands/update.js.map +1 -1
- package/dist/commands/upgrade.d.ts.map +1 -1
- package/dist/commands/upgrade.js +5 -2
- package/dist/commands/upgrade.js.map +1 -1
- package/dist/index.js +2 -6
- package/dist/index.js.map +1 -1
- package/dist/lib/agent-skill.d.ts +1 -1
- package/dist/lib/agent-skill.d.ts.map +1 -1
- package/dist/lib/agent-skill.js.map +1 -1
- package/dist/lib/create-project.d.ts +11 -3
- package/dist/lib/create-project.d.ts.map +1 -1
- package/dist/lib/create-project.js +127 -43
- package/dist/lib/create-project.js.map +1 -1
- package/dist/lib/handle-cli-error.d.ts +5 -0
- package/dist/lib/handle-cli-error.d.ts.map +1 -0
- package/dist/lib/handle-cli-error.js +17 -0
- package/dist/lib/handle-cli-error.js.map +1 -0
- package/dist/lib/install-ai-sdk-lib.js +8 -1
- package/dist/lib/install-ai-sdk-lib.js.map +1 -1
- package/dist/lib/install-edge-lib.js +4 -8
- package/dist/lib/install-edge-lib.js.map +1 -1
- package/dist/lib/run-spawn.d.ts +16 -2
- package/dist/lib/run-spawn.d.ts.map +1 -1
- package/dist/lib/run-spawn.js +87 -9
- package/dist/lib/run-spawn.js.map +1 -1
- package/dist/lib/transform.d.ts +1 -1
- package/dist/lib/transform.d.ts.map +1 -1
- package/dist/lib/transform.js +12 -25
- package/dist/lib/transform.js.map +1 -1
- package/dist/lib/upgrade.js +20 -16
- package/dist/lib/upgrade.js.map +1 -1
- package/dist/lib/utils/file-scanner.d.ts +9 -1
- package/dist/lib/utils/file-scanner.d.ts.map +1 -1
- package/dist/lib/utils/file-scanner.js +22 -20
- package/dist/lib/utils/file-scanner.js.map +1 -1
- package/dist/lib/utils/package-installer.js +1 -1
- package/dist/lib/utils/package-manager.d.ts +3 -1
- package/dist/lib/utils/package-manager.d.ts.map +1 -1
- package/dist/lib/utils/package-manager.js +22 -10
- package/dist/lib/utils/package-manager.js.map +1 -1
- package/package.json +7 -7
- package/plugin/skills/assistant-ui/SKILL.md +4 -4
- package/src/codemods/v0-12/__tests__/assistant-api-to-aui.test.ts +370 -0
- package/src/codemods/v0-12/__tests__/primitive-if-to-aui-if.test.ts +100 -0
- package/src/codemods/v0-12/assistant-api-to-aui.ts +227 -134
- package/src/codemods/v0-12/primitive-if-to-aui-if.ts +44 -72
- package/src/commands/add.ts +5 -5
- package/src/commands/create.ts +41 -7
- package/src/commands/info.ts +1 -0
- package/src/commands/init.ts +4 -6
- package/src/commands/mcp.ts +57 -41
- package/src/commands/update.ts +6 -8
- package/src/commands/upgrade.ts +5 -2
- package/src/index.ts +2 -7
- package/src/lib/agent-skill.ts +2 -1
- package/src/lib/create-project.test.ts +175 -0
- package/src/lib/create-project.ts +189 -59
- package/src/lib/handle-cli-error.test.ts +67 -0
- package/src/lib/handle-cli-error.ts +17 -0
- package/src/lib/install-ai-sdk-lib.ts +13 -1
- package/src/lib/install-edge-lib.ts +7 -8
- package/src/lib/run-spawn.test.ts +148 -0
- package/src/lib/run-spawn.ts +121 -11
- package/src/lib/transform.test.ts +87 -0
- package/src/lib/transform.ts +21 -37
- package/src/lib/upgrade.ts +23 -19
- package/src/lib/utils/file-scanner.ts +26 -20
- package/src/lib/utils/package-manager.ts +29 -12
|
@@ -2,6 +2,21 @@ import * as fs$1 from "node:fs";
|
|
|
2
2
|
import * as path$1 from "node:path";
|
|
3
3
|
import { sync } from "glob";
|
|
4
4
|
//#region src/lib/utils/file-scanner.ts
|
|
5
|
+
function* readProjectFiles(pattern, options) {
|
|
6
|
+
const files = sync(pattern, options);
|
|
7
|
+
for (const file of files) {
|
|
8
|
+
const fullPath = path$1.join(options.cwd, file);
|
|
9
|
+
try {
|
|
10
|
+
yield {
|
|
11
|
+
file,
|
|
12
|
+
fullPath,
|
|
13
|
+
content: fs$1.readFileSync(fullPath, "utf8")
|
|
14
|
+
};
|
|
15
|
+
} catch {
|
|
16
|
+
continue;
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
}
|
|
5
20
|
function scanForImport(importPattern, options = {}) {
|
|
6
21
|
const cwd = options.cwd || process.cwd();
|
|
7
22
|
const pattern = options.pattern || "**/*.{js,jsx,ts,tsx}";
|
|
@@ -10,18 +25,11 @@ function scanForImport(importPattern, options = {}) {
|
|
|
10
25
|
"**/dist/**",
|
|
11
26
|
"**/build/**"
|
|
12
27
|
];
|
|
13
|
-
const
|
|
28
|
+
const patterns = Array.isArray(importPattern) ? importPattern : [importPattern];
|
|
29
|
+
for (const { content } of readProjectFiles(pattern, {
|
|
14
30
|
cwd,
|
|
15
31
|
ignore
|
|
16
|
-
});
|
|
17
|
-
const patterns = Array.isArray(importPattern) ? importPattern : [importPattern];
|
|
18
|
-
for (const file of files) {
|
|
19
|
-
const fullPath = path$1.join(cwd, file);
|
|
20
|
-
try {
|
|
21
|
-
const content = fs$1.readFileSync(fullPath, "utf8");
|
|
22
|
-
if (patterns.some((p) => content.includes(p))) return true;
|
|
23
|
-
} catch {}
|
|
24
|
-
}
|
|
32
|
+
})) if (patterns.some((p) => content.includes(p))) return true;
|
|
25
33
|
return false;
|
|
26
34
|
}
|
|
27
35
|
function getFilesContaining(searchString, options = {}) {
|
|
@@ -32,20 +40,14 @@ function getFilesContaining(searchString, options = {}) {
|
|
|
32
40
|
"**/dist/**",
|
|
33
41
|
"**/build/**"
|
|
34
42
|
];
|
|
35
|
-
const
|
|
43
|
+
const result = [];
|
|
44
|
+
for (const { fullPath, content } of readProjectFiles(pattern, {
|
|
36
45
|
cwd,
|
|
37
46
|
ignore
|
|
38
|
-
});
|
|
39
|
-
const result = [];
|
|
40
|
-
for (const file of files) {
|
|
41
|
-
const fullPath = path$1.join(cwd, file);
|
|
42
|
-
try {
|
|
43
|
-
if (fs$1.readFileSync(fullPath, "utf8").includes(searchString)) result.push(fullPath);
|
|
44
|
-
} catch {}
|
|
45
|
-
}
|
|
47
|
+
})) if (content.includes(searchString)) result.push(fullPath);
|
|
46
48
|
return result;
|
|
47
49
|
}
|
|
48
50
|
//#endregion
|
|
49
|
-
export { getFilesContaining, scanForImport };
|
|
51
|
+
export { getFilesContaining, readProjectFiles, scanForImport };
|
|
50
52
|
|
|
51
53
|
//# 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 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
|
|
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,6 +1,6 @@
|
|
|
1
1
|
import { logger } from "./logger.js";
|
|
2
|
-
import { scanForImport } from "./file-scanner.js";
|
|
3
2
|
import { askQuestion, installPackage, isPackageInstalled } from "./package-manager.js";
|
|
3
|
+
import { scanForImport } from "./file-scanner.js";
|
|
4
4
|
//#region src/lib/utils/package-installer.ts
|
|
5
5
|
async function installPackageIfNeeded(config) {
|
|
6
6
|
if (!scanForImport(config.importPatterns)) {
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
//#region src/lib/utils/package-manager.d.ts
|
|
2
|
+
type PackageManagerName = "npm" | "pnpm" | "yarn" | "bun";
|
|
2
3
|
declare function askQuestion(query: string): Promise<string>;
|
|
3
4
|
declare function isPackageInstalled(pkg: string, cwd?: string): boolean;
|
|
4
5
|
interface InstallCommand {
|
|
@@ -6,7 +7,8 @@ interface InstallCommand {
|
|
|
6
7
|
args: string[];
|
|
7
8
|
}
|
|
8
9
|
declare function getInstallCommand(packageName: string | string[], cwd?: string): Promise<InstallCommand>;
|
|
10
|
+
declare function resolvePackageManagerForCwd(cwd: string, packageManager?: PackageManagerName): Promise<PackageManagerName>;
|
|
9
11
|
declare function installPackage(packageName: string, cwd?: string): Promise<boolean>;
|
|
10
12
|
//#endregion
|
|
11
|
-
export { InstallCommand, askQuestion, getInstallCommand, installPackage, isPackageInstalled };
|
|
13
|
+
export { InstallCommand, PackageManagerName, askQuestion, getInstallCommand, installPackage, isPackageInstalled, resolvePackageManagerForCwd };
|
|
12
14
|
//# sourceMappingURL=package-manager.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"package-manager.d.ts","names":[],"sources":["../../../src/lib/utils/package-manager.ts"],"mappings":";
|
|
1
|
+
{"version":3,"file":"package-manager.d.ts","names":[],"sources":["../../../src/lib/utils/package-manager.ts"],"mappings":";KAOY;iBAEI,YAAY,gBAAgB;iBAa5B,mBACd,aACA;UAmBe;EACf;EACA;;iBAGoB,kBACpB,gCACA,eACC,QAAQ;iBAyBW,4BACpB,aACA,iBAAiB,qBAChB,QAAQ;iBAWW,eACpB,qBACA,eACC"}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
+
import { SpawnSignalError, runSpawn } from "../run-spawn.js";
|
|
1
2
|
import { logger } from "./logger.js";
|
|
2
3
|
import * as fs$1 from "node:fs";
|
|
3
4
|
import * as path$1 from "node:path";
|
|
4
5
|
import { detect } from "detect-package-manager";
|
|
5
|
-
import { spawnSync } from "node:child_process";
|
|
6
6
|
import * as readline from "node:readline";
|
|
7
7
|
//#region src/lib/utils/package-manager.ts
|
|
8
8
|
function askQuestion(query) {
|
|
@@ -52,24 +52,36 @@ async function getInstallCommand(packageName, cwd) {
|
|
|
52
52
|
};
|
|
53
53
|
}
|
|
54
54
|
}
|
|
55
|
+
function detectFromUserAgent() {
|
|
56
|
+
const ua = process.env.npm_config_user_agent;
|
|
57
|
+
if (!ua) return void 0;
|
|
58
|
+
if (ua.startsWith("bun/")) return "bun";
|
|
59
|
+
if (ua.startsWith("pnpm/")) return "pnpm";
|
|
60
|
+
if (ua.startsWith("yarn/")) return "yarn";
|
|
61
|
+
if (ua.startsWith("npm/")) return "npm";
|
|
62
|
+
}
|
|
63
|
+
async function resolvePackageManagerForCwd(cwd, packageManager) {
|
|
64
|
+
if (packageManager) return packageManager;
|
|
65
|
+
const fromAgent = detectFromUserAgent();
|
|
66
|
+
if (fromAgent) return fromAgent;
|
|
67
|
+
try {
|
|
68
|
+
return await detect({ cwd });
|
|
69
|
+
} catch {
|
|
70
|
+
return "npm";
|
|
71
|
+
}
|
|
72
|
+
}
|
|
55
73
|
async function installPackage(packageName, cwd) {
|
|
56
74
|
try {
|
|
57
75
|
const { command, args } = await getInstallCommand(packageName, cwd);
|
|
58
|
-
|
|
59
|
-
stdio: "inherit",
|
|
60
|
-
cwd
|
|
61
|
-
});
|
|
62
|
-
if (result.error || result.status !== 0) {
|
|
63
|
-
logger.error(`Installation failed${result.error ? `: ${String(result.error)}` : "."}`);
|
|
64
|
-
return false;
|
|
65
|
-
}
|
|
76
|
+
await runSpawn(command, args, cwd);
|
|
66
77
|
return true;
|
|
67
78
|
} catch (e) {
|
|
79
|
+
if (e instanceof SpawnSignalError) throw e;
|
|
68
80
|
logger.error(`Installation failed: ${String(e)}`);
|
|
69
81
|
return false;
|
|
70
82
|
}
|
|
71
83
|
}
|
|
72
84
|
//#endregion
|
|
73
|
-
export { askQuestion, getInstallCommand, installPackage, isPackageInstalled };
|
|
85
|
+
export { askQuestion, getInstallCommand, installPackage, isPackageInstalled, resolvePackageManagerForCwd };
|
|
74
86
|
|
|
75
87
|
//# 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 {
|
|
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 const rl = readline.createInterface({\n input: process.stdin,\n output: process.stdout,\n });\n rl.question(query, (answer) => {\n rl.close();\n resolve(answer);\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;EAC9B,MAAM,KAAK,SAAS,gBAAgB;GAClC,OAAO,QAAQ;GACf,QAAQ,QAAQ;EAClB,CAAC;EACD,GAAG,SAAS,QAAQ,WAAW;GAC7B,GAAG,MAAM;GACT,QAAQ,MAAM;EAChB,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"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "assistant-ui",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.114",
|
|
4
4
|
"description": "CLI for assistant-ui",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"cli",
|
|
@@ -26,6 +26,7 @@
|
|
|
26
26
|
],
|
|
27
27
|
"sideEffects": false,
|
|
28
28
|
"dependencies": {
|
|
29
|
+
"@assistant-ui/agent-launcher": "^0.1.14",
|
|
29
30
|
"@clack/prompts": "^1.7.0",
|
|
30
31
|
"chalk": "^6.0.0",
|
|
31
32
|
"cli-progress": "^3.12.0",
|
|
@@ -37,19 +38,18 @@
|
|
|
37
38
|
"glob": "^13.0.6",
|
|
38
39
|
"jscodeshift": "^17.4.0",
|
|
39
40
|
"jsonc-parser": "^3.3.1",
|
|
40
|
-
"semver": "^7.8.5"
|
|
41
|
-
"@assistant-ui/agent-launcher": "0.1.12"
|
|
41
|
+
"semver": "^7.8.5"
|
|
42
42
|
},
|
|
43
43
|
"devDependencies": {
|
|
44
|
+
"@assistant-ui/x-buildutils": "0.0.25",
|
|
44
45
|
"@types/cli-progress": "^3.11.6",
|
|
45
46
|
"@types/cross-spawn": "^6.0.6",
|
|
46
47
|
"@types/debug": "^4.1.13",
|
|
47
48
|
"@types/jscodeshift": "^17.3.0",
|
|
48
|
-
"@types/node": "^26.
|
|
49
|
+
"@types/node": "^26.4.0",
|
|
49
50
|
"@types/semver": "^7.8.0",
|
|
50
|
-
"@vitest/coverage-v8": "^4.1.
|
|
51
|
-
"vitest": "^4.1.
|
|
52
|
-
"@assistant-ui/x-buildutils": "0.0.23"
|
|
51
|
+
"@vitest/coverage-v8": "^4.1.11",
|
|
52
|
+
"vitest": "^4.1.11"
|
|
53
53
|
},
|
|
54
54
|
"publishConfig": {
|
|
55
55
|
"access": "public",
|
|
@@ -67,7 +67,7 @@ assistant-ui requires a runtime. The most common setup uses AI SDK:
|
|
|
67
67
|
|
|
68
68
|
Install the integration package:
|
|
69
69
|
```bash
|
|
70
|
-
npm install @assistant-ui/
|
|
70
|
+
npm install @assistant-ui/ai-sdk
|
|
71
71
|
```
|
|
72
72
|
|
|
73
73
|
Create a chat API route (Next.js App Router):
|
|
@@ -98,8 +98,8 @@ Create the assistant component:
|
|
|
98
98
|
"use client";
|
|
99
99
|
|
|
100
100
|
import { AssistantRuntimeProvider } from "@assistant-ui/react";
|
|
101
|
-
import { useChatRuntime } from "@assistant-ui/
|
|
102
|
-
import { Thread } from "@/components/assistant-ui/thread";
|
|
101
|
+
import { useChatRuntime } from "@assistant-ui/ai-sdk";
|
|
102
|
+
import { Thread } from "@/components/assistant-ui/elements/thread.aui";
|
|
103
103
|
|
|
104
104
|
export const Assistant = () => {
|
|
105
105
|
const runtime = useChatRuntime({
|
|
@@ -188,7 +188,7 @@ Do not use `makeAssistantToolUI`, `useAssistantToolUI`, `makeAssistantTool`, or
|
|
|
188
188
|
| Package | Purpose |
|
|
189
189
|
|---------|---------|
|
|
190
190
|
| `@assistant-ui/react` | Core React components and primitives |
|
|
191
|
-
| `@assistant-ui/
|
|
191
|
+
| `@assistant-ui/ai-sdk` | Vercel AI SDK integration |
|
|
192
192
|
| `@assistant-ui/react-markdown` | Markdown rendering |
|
|
193
193
|
| `@assistant-ui/react-syntax-highlighter` | Code highlighting |
|
|
194
194
|
| `@assistant-ui/ui` | Pre-built shadcn/ui component set |
|
|
@@ -592,3 +592,373 @@ function MyComponent() {
|
|
|
592
592
|
expect(output?.trim()).toBe(expected.trim());
|
|
593
593
|
});
|
|
594
594
|
});
|
|
595
|
+
|
|
596
|
+
describe("api bindings unrelated to useAssistantApi", () => {
|
|
597
|
+
it("does not rename a destructured api from another source", () => {
|
|
598
|
+
const input = `
|
|
599
|
+
import { useAssistantApi } from "@assistant-ui/react";
|
|
600
|
+
|
|
601
|
+
function MyComponent() {
|
|
602
|
+
const api = useAssistantApi();
|
|
603
|
+
return api.thread();
|
|
604
|
+
}
|
|
605
|
+
|
|
606
|
+
function loadData() {
|
|
607
|
+
const { api } = createClient();
|
|
608
|
+
return api.fetchStuff();
|
|
609
|
+
}
|
|
610
|
+
`;
|
|
611
|
+
|
|
612
|
+
const output = applyTransform(input);
|
|
613
|
+
expect(output).toContain("const { api } = createClient()");
|
|
614
|
+
expect(output).toContain("api.fetchStuff()");
|
|
615
|
+
expect(output).toContain("const aui = useAui()");
|
|
616
|
+
});
|
|
617
|
+
|
|
618
|
+
it("does not rename a function parameter named api", () => {
|
|
619
|
+
const input = `
|
|
620
|
+
import { useAssistantApi } from "@assistant-ui/react";
|
|
621
|
+
|
|
622
|
+
function MyComponent() {
|
|
623
|
+
const api = useAssistantApi();
|
|
624
|
+
return api.thread();
|
|
625
|
+
}
|
|
626
|
+
|
|
627
|
+
function callRemote(api: RemoteApi) {
|
|
628
|
+
return api.send();
|
|
629
|
+
}
|
|
630
|
+
`;
|
|
631
|
+
|
|
632
|
+
const output = applyTransform(input);
|
|
633
|
+
expect(output).toContain("function callRemote(api: RemoteApi)");
|
|
634
|
+
expect(output).toContain("return api.send()");
|
|
635
|
+
});
|
|
636
|
+
|
|
637
|
+
it("expands shorthand object properties instead of renaming the key", () => {
|
|
638
|
+
const input = `
|
|
639
|
+
import { useAssistantApi } from "@assistant-ui/react";
|
|
640
|
+
|
|
641
|
+
function MyComponent() {
|
|
642
|
+
const api = useAssistantApi();
|
|
643
|
+
return register({ api });
|
|
644
|
+
}
|
|
645
|
+
`;
|
|
646
|
+
|
|
647
|
+
const output = applyTransform(input);
|
|
648
|
+
expect(output).toContain("register({ api: aui })");
|
|
649
|
+
});
|
|
650
|
+
});
|
|
651
|
+
|
|
652
|
+
describe("JSX and export positions", () => {
|
|
653
|
+
it("does not rename JSX member properties or intrinsic tags", () => {
|
|
654
|
+
const input = `
|
|
655
|
+
import { useAssistantApi } from "@assistant-ui/react";
|
|
656
|
+
|
|
657
|
+
function MyComponent() {
|
|
658
|
+
const api = useAssistantApi();
|
|
659
|
+
void api.thread();
|
|
660
|
+
return (
|
|
661
|
+
<div>
|
|
662
|
+
<config.api />
|
|
663
|
+
<api />
|
|
664
|
+
</div>
|
|
665
|
+
);
|
|
666
|
+
}
|
|
667
|
+
`;
|
|
668
|
+
|
|
669
|
+
const output = applyTransform(input);
|
|
670
|
+
expect(output).toContain("<config.api />");
|
|
671
|
+
expect(output).toContain("<api />");
|
|
672
|
+
expect(output).toContain("void aui.thread()");
|
|
673
|
+
});
|
|
674
|
+
|
|
675
|
+
it("preserves the public name of a re-exported api", () => {
|
|
676
|
+
const input = `
|
|
677
|
+
import { useAssistantApi } from "@assistant-ui/react";
|
|
678
|
+
|
|
679
|
+
const api = useAssistantApi();
|
|
680
|
+
|
|
681
|
+
export { api };
|
|
682
|
+
`;
|
|
683
|
+
|
|
684
|
+
const output = applyTransform(input);
|
|
685
|
+
expect(output).toContain("export { aui as api }");
|
|
686
|
+
expect(output).toContain("const aui = useAui()");
|
|
687
|
+
});
|
|
688
|
+
});
|
|
689
|
+
|
|
690
|
+
describe("aliased and source-bearing exports", () => {
|
|
691
|
+
it("preserves aliased public names", () => {
|
|
692
|
+
const input = `
|
|
693
|
+
import { useAssistantApi } from "@assistant-ui/react";
|
|
694
|
+
|
|
695
|
+
const api = useAssistantApi();
|
|
696
|
+
|
|
697
|
+
export { api as default };
|
|
698
|
+
export { api as clientApi };
|
|
699
|
+
`;
|
|
700
|
+
|
|
701
|
+
const output = applyTransform(input);
|
|
702
|
+
expect(output).toContain("export { aui as default }");
|
|
703
|
+
expect(output).toContain("export { aui as clientApi }");
|
|
704
|
+
});
|
|
705
|
+
|
|
706
|
+
it("leaves source-bearing re-exports untouched", () => {
|
|
707
|
+
const input = `
|
|
708
|
+
import { useAssistantApi } from "@assistant-ui/react";
|
|
709
|
+
|
|
710
|
+
const api = useAssistantApi();
|
|
711
|
+
void api.thread();
|
|
712
|
+
|
|
713
|
+
export { api } from "./other-module";
|
|
714
|
+
`;
|
|
715
|
+
|
|
716
|
+
const output = applyTransform(input);
|
|
717
|
+
expect(output).toContain('export { api } from "./other-module"');
|
|
718
|
+
expect(output).toContain("void aui.thread()");
|
|
719
|
+
});
|
|
720
|
+
|
|
721
|
+
it("leaves type-only api exports untouched", () => {
|
|
722
|
+
const input = `
|
|
723
|
+
import { useAssistantApi } from "@assistant-ui/react";
|
|
724
|
+
|
|
725
|
+
const api = useAssistantApi();
|
|
726
|
+
void api.thread();
|
|
727
|
+
|
|
728
|
+
type api = { x: number };
|
|
729
|
+
export type { api };
|
|
730
|
+
export { type api as ApiType };
|
|
731
|
+
`;
|
|
732
|
+
|
|
733
|
+
const output = applyTransform(input);
|
|
734
|
+
expect(output).toContain("export type { api }");
|
|
735
|
+
expect(output).toContain("export { type api as ApiType }");
|
|
736
|
+
expect(output).toContain("void aui.thread()");
|
|
737
|
+
});
|
|
738
|
+
});
|
|
739
|
+
|
|
740
|
+
describe("block-scoped shadowing", () => {
|
|
741
|
+
it("does not rename a block-scoped api inside the same function", () => {
|
|
742
|
+
const input = `
|
|
743
|
+
import { useAssistantApi } from "@assistant-ui/react";
|
|
744
|
+
|
|
745
|
+
function MyComponent() {
|
|
746
|
+
const api = useAssistantApi();
|
|
747
|
+
void api.thread();
|
|
748
|
+
{
|
|
749
|
+
const api = createOther();
|
|
750
|
+
void api.other();
|
|
751
|
+
}
|
|
752
|
+
if (true) {
|
|
753
|
+
const { api } = createClient();
|
|
754
|
+
void api.fetchStuff();
|
|
755
|
+
}
|
|
756
|
+
return null;
|
|
757
|
+
}
|
|
758
|
+
`;
|
|
759
|
+
|
|
760
|
+
const output = applyTransform(input);
|
|
761
|
+
expect(output).toContain("void aui.thread()");
|
|
762
|
+
expect(output).toContain("const api = createOther()");
|
|
763
|
+
expect(output).toContain("void api.other()");
|
|
764
|
+
expect(output).toContain("const { api } = createClient()");
|
|
765
|
+
expect(output).toContain("void api.fetchStuff()");
|
|
766
|
+
});
|
|
767
|
+
});
|
|
768
|
+
|
|
769
|
+
describe("binding positions beyond plain declarations", () => {
|
|
770
|
+
it("does not rename method parameters named api", () => {
|
|
771
|
+
const input = `
|
|
772
|
+
import { useAssistantApi } from "@assistant-ui/react";
|
|
773
|
+
|
|
774
|
+
function MyComponent() {
|
|
775
|
+
const api = useAssistantApi();
|
|
776
|
+
void api.thread();
|
|
777
|
+
const handlers = {
|
|
778
|
+
load(api: RemoteApi) {
|
|
779
|
+
return api.send();
|
|
780
|
+
},
|
|
781
|
+
};
|
|
782
|
+
class Client {
|
|
783
|
+
call(api: RemoteApi) {
|
|
784
|
+
return api.send();
|
|
785
|
+
}
|
|
786
|
+
}
|
|
787
|
+
return handlers;
|
|
788
|
+
}
|
|
789
|
+
`;
|
|
790
|
+
|
|
791
|
+
const output = applyTransform(input);
|
|
792
|
+
expect(output).toContain("load(api: RemoteApi)");
|
|
793
|
+
expect(output).toContain("call(api: RemoteApi)");
|
|
794
|
+
expect(output?.match(/return api\.send\(\)/g)).toHaveLength(2);
|
|
795
|
+
expect(output).toContain("void aui.thread()");
|
|
796
|
+
});
|
|
797
|
+
|
|
798
|
+
it("does not rename constructor parameter properties named api", () => {
|
|
799
|
+
const input = `
|
|
800
|
+
import { useAssistantApi } from "@assistant-ui/react";
|
|
801
|
+
|
|
802
|
+
function MyComponent() {
|
|
803
|
+
const api = useAssistantApi();
|
|
804
|
+
void api.thread();
|
|
805
|
+
class Client {
|
|
806
|
+
constructor(public api: RemoteApi) {
|
|
807
|
+
return api.send();
|
|
808
|
+
}
|
|
809
|
+
}
|
|
810
|
+
return Client;
|
|
811
|
+
}
|
|
812
|
+
`;
|
|
813
|
+
|
|
814
|
+
const output = applyTransform(input);
|
|
815
|
+
expect(output).toContain("constructor(public api: RemoteApi)");
|
|
816
|
+
expect(output).toContain("return api.send()");
|
|
817
|
+
expect(output).toContain("void aui.thread()");
|
|
818
|
+
});
|
|
819
|
+
|
|
820
|
+
it("treats function and class declarations named api as shadows", () => {
|
|
821
|
+
const input = `
|
|
822
|
+
import { useAssistantApi } from "@assistant-ui/react";
|
|
823
|
+
|
|
824
|
+
const api = useAssistantApi();
|
|
825
|
+
void api.thread();
|
|
826
|
+
|
|
827
|
+
function outer() {
|
|
828
|
+
function api() {}
|
|
829
|
+
return api();
|
|
830
|
+
}
|
|
831
|
+
|
|
832
|
+
function other() {
|
|
833
|
+
class api {}
|
|
834
|
+
return new api();
|
|
835
|
+
}
|
|
836
|
+
`;
|
|
837
|
+
|
|
838
|
+
const output = applyTransform(input);
|
|
839
|
+
expect(output).toContain("void aui.thread()");
|
|
840
|
+
expect(output).toContain("function api() {}");
|
|
841
|
+
expect(output).toContain("return api()");
|
|
842
|
+
expect(output).toContain("class api {}");
|
|
843
|
+
expect(output).toContain("new api()");
|
|
844
|
+
});
|
|
845
|
+
|
|
846
|
+
it("recognizes for-initializer and switch-case declarations", () => {
|
|
847
|
+
const input = `
|
|
848
|
+
import { useAssistantApi } from "@assistant-ui/react";
|
|
849
|
+
|
|
850
|
+
function MyComponent() {
|
|
851
|
+
const api = useAssistantApi();
|
|
852
|
+
void api.thread();
|
|
853
|
+
for (let api = start(); api.more(); api = api.next()) {
|
|
854
|
+
use(api);
|
|
855
|
+
}
|
|
856
|
+
switch (kind) {
|
|
857
|
+
case "a": {
|
|
858
|
+
const api = other();
|
|
859
|
+
return api.load();
|
|
860
|
+
}
|
|
861
|
+
}
|
|
862
|
+
}
|
|
863
|
+
`;
|
|
864
|
+
|
|
865
|
+
const output = applyTransform(input);
|
|
866
|
+
expect(output).toContain("void aui.thread()");
|
|
867
|
+
expect(output).toContain(
|
|
868
|
+
"for (let api = start(); api.more(); api = api.next())",
|
|
869
|
+
);
|
|
870
|
+
expect(output).toContain("use(api)");
|
|
871
|
+
expect(output).toContain("const api = other()");
|
|
872
|
+
expect(output).toContain("return api.load()");
|
|
873
|
+
});
|
|
874
|
+
|
|
875
|
+
it("handles export const api declarations", () => {
|
|
876
|
+
const input = `
|
|
877
|
+
import { useAssistantApi } from "@assistant-ui/react";
|
|
878
|
+
|
|
879
|
+
export const api = useAssistantApi();
|
|
880
|
+
|
|
881
|
+
export function helper() {
|
|
882
|
+
return api.thread();
|
|
883
|
+
}
|
|
884
|
+
`;
|
|
885
|
+
|
|
886
|
+
const output = applyTransform(input);
|
|
887
|
+
expect(output).toContain("export const aui = useAui()");
|
|
888
|
+
expect(output).toContain("return aui.thread()");
|
|
889
|
+
});
|
|
890
|
+
});
|
|
891
|
+
|
|
892
|
+
describe("keys and type-only declarations", () => {
|
|
893
|
+
it("does not rename method or class-member keys named api", () => {
|
|
894
|
+
const input = `
|
|
895
|
+
import { useAssistantApi } from "@assistant-ui/react";
|
|
896
|
+
|
|
897
|
+
function MyComponent() {
|
|
898
|
+
const api = useAssistantApi();
|
|
899
|
+
void api.thread();
|
|
900
|
+
const handlers = {
|
|
901
|
+
api() {
|
|
902
|
+
return 1;
|
|
903
|
+
},
|
|
904
|
+
};
|
|
905
|
+
class Client {
|
|
906
|
+
api = 1;
|
|
907
|
+
api2() {
|
|
908
|
+
return this.api;
|
|
909
|
+
}
|
|
910
|
+
}
|
|
911
|
+
return { handlers, Client };
|
|
912
|
+
}
|
|
913
|
+
`;
|
|
914
|
+
|
|
915
|
+
const output = applyTransform(input);
|
|
916
|
+
expect(output).toContain("api() {");
|
|
917
|
+
expect(output).toContain("api = 1;");
|
|
918
|
+
expect(output).toContain("return this.api");
|
|
919
|
+
expect(output).toContain("void aui.thread()");
|
|
920
|
+
});
|
|
921
|
+
|
|
922
|
+
it("does not treat type-only declarations as value shadows", () => {
|
|
923
|
+
const input = `
|
|
924
|
+
import { useAssistantApi } from "@assistant-ui/react";
|
|
925
|
+
|
|
926
|
+
function MyComponent() {
|
|
927
|
+
const api = useAssistantApi();
|
|
928
|
+
type api2 = string;
|
|
929
|
+
{
|
|
930
|
+
type api = { x: number };
|
|
931
|
+
interface apiShape {}
|
|
932
|
+
void api.thread();
|
|
933
|
+
}
|
|
934
|
+
return null;
|
|
935
|
+
}
|
|
936
|
+
`;
|
|
937
|
+
|
|
938
|
+
const output = applyTransform(input);
|
|
939
|
+
expect(output).toContain("void aui.thread()");
|
|
940
|
+
expect(output).toContain("type api = { x: number }");
|
|
941
|
+
});
|
|
942
|
+
});
|
|
943
|
+
|
|
944
|
+
describe("named expressions", () => {
|
|
945
|
+
it("does not rename the self-reference of a named function expression", () => {
|
|
946
|
+
const input = `
|
|
947
|
+
import { useAssistantApi } from "@assistant-ui/react";
|
|
948
|
+
|
|
949
|
+
function MyComponent() {
|
|
950
|
+
const api = useAssistantApi();
|
|
951
|
+
void api.thread();
|
|
952
|
+
const run = function api() {
|
|
953
|
+
return api;
|
|
954
|
+
};
|
|
955
|
+
return run;
|
|
956
|
+
}
|
|
957
|
+
`;
|
|
958
|
+
|
|
959
|
+
const output = applyTransform(input);
|
|
960
|
+
expect(output).toContain("function api() {");
|
|
961
|
+
expect(output).toContain("return api;");
|
|
962
|
+
expect(output).toContain("void aui.thread()");
|
|
963
|
+
});
|
|
964
|
+
});
|