assistant-ui 0.0.106 → 0.0.108

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 (59) hide show
  1. package/dist/codemods/v0-12/assistant-api-to-aui.js.map +1 -1
  2. package/dist/codemods/v0-15/aui-accessor-calls-to-properties.d.ts +5 -0
  3. package/dist/codemods/v0-15/aui-accessor-calls-to-properties.d.ts.map +1 -0
  4. package/dist/codemods/v0-15/aui-accessor-calls-to-properties.js +58 -0
  5. package/dist/codemods/v0-15/aui-accessor-calls-to-properties.js.map +1 -0
  6. package/dist/codemods/v0-8/ui-package-split.js.map +1 -1
  7. package/dist/commands/add.js +1 -1
  8. package/dist/commands/add.js.map +1 -1
  9. package/dist/commands/create.d.ts.map +1 -1
  10. package/dist/commands/create.js +14 -4
  11. package/dist/commands/create.js.map +1 -1
  12. package/dist/commands/doctor.d.ts.map +1 -1
  13. package/dist/commands/doctor.js +11 -10
  14. package/dist/commands/doctor.js.map +1 -1
  15. package/dist/commands/info.d.ts +1 -1
  16. package/dist/commands/info.d.ts.map +1 -1
  17. package/dist/commands/info.js +13 -14
  18. package/dist/commands/info.js.map +1 -1
  19. package/dist/commands/upgrade.js +2 -2
  20. package/dist/commands/upgrade.js.map +1 -1
  21. package/dist/index.d.ts +1 -1
  22. package/dist/index.js +5 -5
  23. package/dist/index.js.map +1 -1
  24. package/dist/lib/create-project.d.ts +7 -2
  25. package/dist/lib/create-project.d.ts.map +1 -1
  26. package/dist/lib/create-project.js +13 -10
  27. package/dist/lib/create-project.js.map +1 -1
  28. package/dist/lib/run-spawn.d.ts.map +1 -1
  29. package/dist/lib/upgrade.d.ts.map +1 -1
  30. package/dist/lib/upgrade.js +2 -1
  31. package/dist/lib/upgrade.js.map +1 -1
  32. package/dist/lib/utils/logger.d.ts.map +1 -1
  33. package/dist/lib/utils/registry.js +2 -1
  34. package/dist/lib/utils/registry.js.map +1 -1
  35. package/dist/lib/utils/workspace.d.ts +6 -0
  36. package/dist/lib/utils/workspace.d.ts.map +1 -0
  37. package/dist/lib/utils/workspace.js +28 -0
  38. package/dist/lib/utils/workspace.js.map +1 -0
  39. package/dist/run.d.ts +5 -0
  40. package/dist/run.d.ts.map +1 -0
  41. package/dist/run.js +9 -0
  42. package/dist/run.js.map +1 -0
  43. package/package.json +4 -4
  44. package/plugin/skills/assistant-ui/SKILL.md +24 -5
  45. package/src/codemods/v0-15/__tests__/aui-accessor-calls-to-properties.test.ts +109 -0
  46. package/src/codemods/v0-15/aui-accessor-calls-to-properties.ts +83 -0
  47. package/src/commands/add.ts +1 -1
  48. package/src/commands/create.ts +16 -4
  49. package/src/commands/doctor.ts +17 -13
  50. package/src/commands/info.ts +21 -20
  51. package/src/commands/upgrade.ts +2 -2
  52. package/src/index.ts +5 -6
  53. package/src/lib/create-project.ts +25 -14
  54. package/src/lib/upgrade.ts +1 -0
  55. package/src/lib/utils/registry.test.ts +8 -2
  56. package/src/lib/utils/registry.ts +5 -1
  57. package/src/lib/utils/workspace.ts +34 -0
  58. package/src/run.test.ts +27 -0
  59. package/src/run.ts +5 -0
@@ -210,22 +210,25 @@ export async function resolvePackageManagerForCwd(
210
210
  }
211
211
  }
212
212
 
213
+ export interface TransformResult {
214
+ registryInstallFailure?: { retryCommand: string };
215
+ }
216
+
213
217
  export async function transformProject(
214
218
  projectDir: string,
215
219
  opts: TransformOptions,
216
- ): Promise<void> {
220
+ ): Promise<TransformResult> {
217
221
  logger.step("Transforming package.json...");
218
222
  transformPackageJson(projectDir);
219
223
 
224
+ logger.step("Transforming project files...");
225
+ transformTsConfig(projectDir);
226
+ transformCssFiles(projectDir);
227
+
220
228
  let assistantUI: string[] | undefined;
221
229
  let shadcnUI: string[] | undefined;
222
230
 
223
231
  if (!opts.hasLocalComponents) {
224
- logger.step("Transforming project files...");
225
-
226
- transformTsConfig(projectDir);
227
- transformCssFiles(projectDir);
228
-
229
232
  const components = scanRequiredComponents(projectDir);
230
233
  assistantUI = components.assistantUI;
231
234
  shadcnUI = components.shadcnUI;
@@ -249,8 +252,15 @@ export async function transformProject(
249
252
  const auiComponents = assistantUI.map((c) => `@assistant-ui/${c}`);
250
253
  const components = [...allShadcn, ...auiComponents];
251
254
  logger.step(`Installing components: ${components.join(", ")}...`);
252
- await installShadcnRegistry(projectDir, components, "components", pm);
255
+ const failure = await installShadcnRegistry(
256
+ projectDir,
257
+ components,
258
+ "components",
259
+ pm,
260
+ );
261
+ if (failure) return { registryInstallFailure: failure };
253
262
  }
263
+ return {};
254
264
  }
255
265
 
256
266
  function transformPackageJson(projectDir: string): void {
@@ -326,7 +336,8 @@ function transformTsConfig(projectDir: string): void {
326
336
  Array.isArray(targets) &&
327
337
  targets.some(
328
338
  (target) =>
329
- typeof target === "string" && target.includes("packages/ui/"),
339
+ typeof target === "string" &&
340
+ (target.includes("packages/ui/") || target.startsWith("../")),
330
341
  );
331
342
  if (workspaceKeys.has(key) || targetsWorkspace) {
332
343
  delete tsconfig.compilerOptions.paths[key];
@@ -461,20 +472,20 @@ async function installShadcnRegistry(
461
472
  components: string[],
462
473
  label: string,
463
474
  pm: PackageManagerName,
464
- ): Promise<void> {
475
+ ): Promise<{ retryCommand: string } | undefined> {
465
476
  const [cmd, dlxArgs] = dlxCommand(pm);
466
477
  // For npm, dlxArgs may already include `--yes` for npx auto-install.
467
478
  // The trailing `--yes` is for shadcn's own confirmation prompt.
468
- const addArgs = [...dlxArgs, "shadcn@latest", "add", ...components, "--yes"];
479
+ const retryArgs = [...dlxArgs, "shadcn@latest", "add", ...components];
480
+ const addArgs = [...retryArgs, "--yes"];
469
481
 
470
482
  try {
471
483
  await runSpawn(cmd, addArgs, projectDir);
484
+ return undefined;
472
485
  } catch (error) {
473
486
  if (error instanceof SpawnExitError) {
474
- logger.warn(
475
- `shadcn exited with code ${error.code}. Run the following to retry:\n ${cmd} ${addArgs.slice(0, -1).join(" ")}`,
476
- );
477
- return;
487
+ logger.warn(`shadcn exited with code ${error.code}.`);
488
+ return { retryCommand: `${cmd} ${retryArgs.join(" ")}` };
478
489
  }
479
490
 
480
491
  const message = error instanceof Error ? error.message : String(error);
@@ -14,6 +14,7 @@ const bundle = [
14
14
  "v0-12/assistant-api-to-aui",
15
15
  "v0-12/event-names-to-camelcase",
16
16
  "v0-12/primitive-if-to-aui-if",
17
+ "v0-15/aui-accessor-calls-to-properties",
17
18
  ];
18
19
 
19
20
  const log = debug("codemod:upgrade");
@@ -94,9 +94,15 @@ describe("resolveRegistryItemUrl", () => {
94
94
  );
95
95
  });
96
96
 
97
- it("uses the plain URL without a style", () => {
97
+ it("uses the base URL without a style", () => {
98
98
  expect(resolveRegistryItemUrl("thread")).toBe(
99
- "https://r.assistant-ui.com/thread.json",
99
+ "https://r.assistant-ui.com/base/thread.json",
100
+ );
101
+ });
102
+
103
+ it("uses the base URL for an explicit undefined style", () => {
104
+ expect(resolveRegistryItemUrl("thread", undefined)).toBe(
105
+ "https://r.assistant-ui.com/base/thread.json",
100
106
  );
101
107
  });
102
108
 
@@ -31,7 +31,11 @@ export function resolveRegistryItemUrl(
31
31
  component: string,
32
32
  style?: string,
33
33
  ): string {
34
- const registryUrl = style?.startsWith("base-")
34
+ if (style === undefined) {
35
+ return `${REGISTRY_BASE_URL}/base/${encodeURIComponent(component)}.json`;
36
+ }
37
+
38
+ const registryUrl = style.startsWith("base-")
35
39
  ? `${REGISTRY_BASE_URL}/styles/${encodeURIComponent(style)}`
36
40
  : REGISTRY_BASE_URL;
37
41
 
@@ -0,0 +1,34 @@
1
+ import * as fs from "node:fs";
2
+ import * as path from "node:path";
3
+
4
+ export function resolveRealPath(inputPath: string): string {
5
+ const resolved = path.resolve(inputPath);
6
+
7
+ try {
8
+ return fs.realpathSync(resolved);
9
+ } catch {
10
+ return resolved;
11
+ }
12
+ }
13
+
14
+ export function findWorkspaceRoot(cwd: string): string | null {
15
+ let dir = path.resolve(cwd);
16
+ const root = path.parse(dir).root;
17
+
18
+ while (true) {
19
+ if (fs.existsSync(path.join(dir, "pnpm-workspace.yaml"))) return dir;
20
+
21
+ const pkgPath = path.join(dir, "package.json");
22
+ if (fs.existsSync(pkgPath)) {
23
+ try {
24
+ const pkg = JSON.parse(fs.readFileSync(pkgPath, "utf8"));
25
+ if (pkg.workspaces) return dir;
26
+ } catch {
27
+ // Malformed package manifests are not workspace markers.
28
+ }
29
+ }
30
+
31
+ if (dir === root) return null;
32
+ dir = path.dirname(dir);
33
+ }
34
+ }
@@ -0,0 +1,27 @@
1
+ import { beforeEach, describe, expect, it, vi } from "vitest";
2
+
3
+ const mocks = vi.hoisted(() => ({
4
+ parseAsync: vi.fn(),
5
+ }));
6
+
7
+ vi.mock("./program", () => ({
8
+ buildProgram: () => ({
9
+ parseAsync: mocks.parseAsync,
10
+ }),
11
+ }));
12
+
13
+ import { runCli } from "./run";
14
+
15
+ describe("runCli", () => {
16
+ beforeEach(() => {
17
+ vi.clearAllMocks();
18
+ });
19
+
20
+ it("awaits and propagates asynchronous command failures", async () => {
21
+ const error = new Error("command failed");
22
+ mocks.parseAsync.mockRejectedValue(error);
23
+
24
+ await expect(runCli()).rejects.toBe(error);
25
+ expect(mocks.parseAsync).toHaveBeenCalledOnce();
26
+ });
27
+ });
package/src/run.ts ADDED
@@ -0,0 +1,5 @@
1
+ import { buildProgram } from "./program";
2
+
3
+ export async function runCli(): Promise<void> {
4
+ await buildProgram().parseAsync();
5
+ }