assistant-ui 0.0.74 → 0.0.76

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 +1 @@
1
- {"version":3,"file":"create.d.ts","sourceRoot":"","sources":["../../src/commands/create.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAMpC,eAAO,MAAM,MAAM,SAwFf,CAAC"}
1
+ {"version":3,"file":"create.d.ts","sourceRoot":"","sources":["../../src/commands/create.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAiBpC,eAAO,MAAM,MAAM,SAgFf,CAAC"}
@@ -3,12 +3,21 @@ import chalk from "chalk";
3
3
  import { spawn } from "cross-spawn";
4
4
  import { logger } from "../lib/utils/logger.js";
5
5
  import { createFromExample } from "../lib/create-from-example.js";
6
+ // Keep in sync with packages/create-assistant-ui/src/index.ts
7
+ const templates = {
8
+ default: "https://github.com/assistant-ui/assistant-ui-starter",
9
+ minimal: "https://github.com/assistant-ui/assistant-ui-starter-minimal",
10
+ cloud: "https://github.com/assistant-ui/assistant-ui-starter-cloud",
11
+ langgraph: "https://github.com/assistant-ui/assistant-ui-starter-langgraph",
12
+ mcp: "https://github.com/assistant-ui/assistant-ui-starter-mcp",
13
+ };
14
+ const templateNames = Object.keys(templates);
6
15
  export const create = new Command()
7
16
  .name("create")
8
17
  .description("create a new project")
9
18
  .argument("[project-directory]")
10
19
  .usage(`${chalk.green("[project-directory]")} [options]`)
11
- .option("-t, --template <template>", "template to use (default, cloud, langgraph, mcp)")
20
+ .option("-t, --template <template>", `template to use (${templateNames.join(", ")})`)
12
21
  .option("-e, --example <example>", "create from an example (e.g., with-langgraph, with-ai-sdk-v6)")
13
22
  .option("--use-npm", "explicitly use npm")
14
23
  .option("--use-pnpm", "explicitly use pnpm")
@@ -31,18 +40,12 @@ export const create = new Command()
31
40
  });
32
41
  return;
33
42
  }
34
- // Handle --template option (existing logic)
35
- const templates = {
36
- default: "https://github.com/assistant-ui/assistant-ui-starter",
37
- cloud: "https://github.com/assistant-ui/assistant-ui-starter-cloud",
38
- langgraph: "https://github.com/assistant-ui/assistant-ui-starter-langgraph",
39
- mcp: "https://github.com/assistant-ui/assistant-ui-starter-mcp",
40
- };
43
+ // Handle --template option
41
44
  const templateName = opts.template ?? "default";
42
45
  const templateUrl = templates[templateName];
43
46
  if (!templateUrl) {
44
47
  logger.error(`Unknown template: ${opts.template}`);
45
- logger.info(`Available templates: ${Object.keys(templates).join(", ")}`);
48
+ logger.info(`Available templates: ${templateNames.join(", ")}`);
46
49
  process.exit(1);
47
50
  }
48
51
  logger.info(`Creating project with template: ${templateName}`);
@@ -1 +1 @@
1
- {"version":3,"file":"create.js","sourceRoot":"","sources":["../../src/commands/create.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAE,KAAK,EAAE,MAAM,aAAa,CAAC;AACpC,OAAO,EAAE,MAAM,EAAE,+BAA4B;AAC7C,OAAO,EAAE,iBAAiB,EAAE,sCAAmC;AAE/D,MAAM,CAAC,MAAM,MAAM,GAAG,IAAI,OAAO,EAAE;KAChC,IAAI,CAAC,QAAQ,CAAC;KACd,WAAW,CAAC,sBAAsB,CAAC;KACnC,QAAQ,CAAC,qBAAqB,CAAC;KAC/B,KAAK,CAAC,GAAG,KAAK,CAAC,KAAK,CAAC,qBAAqB,CAAC,YAAY,CAAC;KACxD,MAAM,CACL,2BAA2B,EAC3B,kDAAkD,CACnD;KACA,MAAM,CACL,yBAAyB,EACzB,+DAA+D,CAChE;KACA,MAAM,CAAC,WAAW,EAAE,oBAAoB,CAAC;KACzC,MAAM,CAAC,YAAY,EAAE,qBAAqB,CAAC;KAC3C,MAAM,CAAC,YAAY,EAAE,qBAAqB,CAAC;KAC3C,MAAM,CAAC,WAAW,EAAE,o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MAAM,KAAK,GAAG,KAAK,CACjB,KAAK,EACL,CAAC,wBAAwB,EAAE,GAAG,YAAY,EAAE,IAAI,EAAE,WAAW,CAAC,EAC9D;QACE,KAAK,EAAE,SAAS;KACjB,CACF,CAAC;IAEF,KAAK,CAAC,EAAE,CAAC,OAAO,EAAE,CAAC,KAAK,EAAE,EAAE;QAC1B,MAAM,CAAC,KAAK,CAAC,6BAA6B,KAAK,CAAC,OAAO,EAAE,CAAC,CAAC;QAC3D,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;IAClB,CAAC,CAAC,CAAC;IAEH,KAAK,CAAC,EAAE,CAAC,OAAO,EAAE,CAAC,IAAI,EAAE,EAAE;QACzB,IAAI,IAAI,KAAK,CAAC,EAAE,CAAC;YACf,MAAM,CAAC,KAAK,CAAC,qCAAqC,IAAI,EAAE,CAAC,CAAC;YAC1D,OAAO,CAAC,IAAI,CAAC,IAAI,IAAI,CAAC,CAAC,CAAC;QAC1B,CAAC;aAAM,CAAC;YACN,MAAM,CAAC,KAAK,EAAE,CAAC;YACf,MAAM,CAAC,OAAO,CAAC,+BAA+B,CAAC,CAAC;QAClD,CAAC;IACH,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"init.d.ts","sourceRoot":"","sources":["../../src/commands/init.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAWpC,eAAO,MAAM,IAAI,SA8Db,CAAC"}
1
+ {"version":3,"file":"init.d.ts","sourceRoot":"","sources":["../../src/commands/init.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAqBpC,eAAO,MAAM,IAAI,SAiHb,CAAC"}
@@ -2,24 +2,42 @@ import { Command } from "commander";
2
2
  import { spawn } from "cross-spawn";
3
3
  import fs from "node:fs";
4
4
  import path from "node:path";
5
- import { create } from "./create.js";
6
5
  import { logger } from "../lib/utils/logger.js";
7
6
  import { hasConfig } from "../lib/utils/config.js";
8
7
  const DEFAULT_REGISTRY_URL = "https://r.assistant-ui.com/chat/b/ai-sdk-quick-start/json";
8
+ // Keep in sync with packages/create-assistant-ui/src/index.ts
9
+ const templates = {
10
+ default: "https://github.com/assistant-ui/assistant-ui-starter",
11
+ minimal: "https://github.com/assistant-ui/assistant-ui-starter-minimal",
12
+ cloud: "https://github.com/assistant-ui/assistant-ui-starter-cloud",
13
+ langgraph: "https://github.com/assistant-ui/assistant-ui-starter-langgraph",
14
+ mcp: "https://github.com/assistant-ui/assistant-ui-starter-mcp",
15
+ };
16
+ const templateNames = Object.keys(templates);
9
17
  export const init = new Command()
10
18
  .name("init")
11
19
  .description("initialize assistant-ui in a new or existing project")
20
+ .argument("[project-directory]", "directory for the new project")
12
21
  .option("-c, --cwd <cwd>", "the working directory. defaults to the current directory.", process.cwd())
13
22
  .option("-p, --preset <url>", "preset URL from playground (e.g., https://www.assistant-ui.com/playground/init?preset=chatgpt)")
14
- .action(async (opts) => {
23
+ .option("-t, --template <template>", `template to use (${templateNames.join(", ")})`, "minimal")
24
+ .option("--use-npm", "explicitly use npm")
25
+ .option("--use-pnpm", "explicitly use pnpm")
26
+ .option("--use-yarn", "explicitly use yarn")
27
+ .option("--use-bun", "explicitly use bun")
28
+ .option("--skip-install", "skip installing packages")
29
+ .action(async (projectDirectory, opts) => {
15
30
  const cwd = opts.cwd;
31
+ const targetDir = projectDirectory
32
+ ? path.resolve(cwd, projectDirectory)
33
+ : cwd;
16
34
  const presetUrl = opts.preset;
17
- if (hasConfig(cwd)) {
35
+ if (hasConfig(targetDir)) {
18
36
  logger.warn("Project is already initialized.");
19
37
  logger.info("Use 'assistant-ui add' to add more components.");
20
38
  return;
21
39
  }
22
- const packageJsonPath = path.join(cwd, "package.json");
40
+ const packageJsonPath = path.join(targetDir, "package.json");
23
41
  const packageJsonExists = fs.existsSync(packageJsonPath);
24
42
  if (packageJsonExists) {
25
43
  const registryUrl = presetUrl ?? DEFAULT_REGISTRY_URL;
@@ -32,7 +50,7 @@ export const init = new Command()
32
50
  logger.break();
33
51
  const child = spawn("npx", [`shadcn@latest`, "add", registryUrl], {
34
52
  stdio: "inherit",
35
- cwd,
53
+ cwd: targetDir,
36
54
  });
37
55
  child.on("error", (error) => {
38
56
  logger.error(`Failed to initialize: ${error.message}`);
@@ -51,9 +69,43 @@ export const init = new Command()
51
69
  });
52
70
  }
53
71
  else {
54
- logger.info("Creating a new assistant-ui project...");
72
+ const templateName = opts.template;
73
+ const templateUrl = templates[templateName];
74
+ if (!templateUrl) {
75
+ logger.error(`Unknown template: ${opts.template}`);
76
+ logger.info(`Available templates: ${templateNames.join(", ")}`);
77
+ process.exit(1);
78
+ }
79
+ logger.info(`Creating a new assistant-ui project (template: ${templateName})...`);
55
80
  logger.break();
56
- await create.parseAsync([]);
81
+ const cnaArgs = ["create-next-app@latest"];
82
+ cnaArgs.push(projectDirectory || ".");
83
+ cnaArgs.push("-e", templateUrl);
84
+ if (opts.useNpm)
85
+ cnaArgs.push("--use-npm");
86
+ if (opts.usePnpm)
87
+ cnaArgs.push("--use-pnpm");
88
+ if (opts.useYarn)
89
+ cnaArgs.push("--use-yarn");
90
+ if (opts.useBun)
91
+ cnaArgs.push("--use-bun");
92
+ if (opts.skipInstall)
93
+ cnaArgs.push("--skip-install");
94
+ const child = spawn("npx", cnaArgs, { stdio: "inherit", cwd });
95
+ child.on("error", (error) => {
96
+ logger.error(`Failed to create project: ${error.message}`);
97
+ process.exit(1);
98
+ });
99
+ child.on("close", (code) => {
100
+ if (code !== 0) {
101
+ logger.error(`Project creation failed with code ${code}`);
102
+ process.exit(code || 1);
103
+ }
104
+ else {
105
+ logger.break();
106
+ logger.success("Project created successfully!");
107
+ }
108
+ });
57
109
  }
58
110
  });
59
111
  //# sourceMappingURL=init.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"init.js","sourceRoot":"","sources":["../../src/commands/init.ts"],"names":[],"mappings":"AAAA,OAAO,EAA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,OAAO,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC;QAC3C,IAAI,IAAI,CAAC,WAAW;YAAE,OAAO,CAAC,IAAI,CAAC,gBAAgB,CAAC,CAAC;QAErD,MAAM,KAAK,GAAG,KAAK,CAAC,KAAK,EAAE,OAAO,EAAE,EAAE,KAAK,EAAE,SAAS,EAAE,GAAG,EAAE,CAAC,CAAC;QAE/D,KAAK,CAAC,EAAE,CAAC,OAAO,EAAE,CAAC,KAAK,EAAE,EAAE;YAC1B,MAAM,CAAC,KAAK,CAAC,6BAA6B,KAAK,CAAC,OAAO,EAAE,CAAC,CAAC;YAC3D,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;QAClB,CAAC,CAAC,CAAC;QAEH,KAAK,CAAC,EAAE,CAAC,OAAO,EAAE,CAAC,IAAI,EAAE,EAAE;YACzB,IAAI,IAAI,KAAK,CAAC,EAAE,CAAC;gBACf,MAAM,CAAC,KAAK,CAAC,qCAAqC,IAAI,EAAE,CAAC,CAAC;gBAC1D,OAAO,CAAC,IAAI,CAAC,IAAI,IAAI,CAAC,CAAC,CAAC;YAC1B,CAAC;iBAAM,CAAC;gBACN,MAAM,CAAC,KAAK,EAAE,CAAC;gBACf,MAAM,CAAC,OAAO,CAAC,+BAA+B,CAAC,CAAC;YAClD,CAAC;QACH,CAAC,CAAC,CAAC;IACL,CAAC;AACH,CAAC,CAAC,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "assistant-ui",
3
- "version": "0.0.74",
3
+ "version": "0.0.76",
4
4
  "description": "CLI for assistant-ui",
5
5
  "keywords": [
6
6
  "cli",
@@ -24,7 +24,7 @@
24
24
  ],
25
25
  "sideEffects": false,
26
26
  "dependencies": {
27
- "@clack/prompts": "^0.10.0",
27
+ "@clack/prompts": "^0.11.0",
28
28
  "chalk": "^5.6.2",
29
29
  "cli-progress": "^3.12.0",
30
30
  "commander": "^14.0.2",
@@ -39,9 +39,9 @@
39
39
  "@types/cross-spawn": "^6.0.6",
40
40
  "@types/debug": "^4.1.12",
41
41
  "@types/jscodeshift": "^17.3.0",
42
- "@types/node": "^25.0.9",
43
- "@vitest/coverage-v8": "^4.0.17",
44
- "vitest": "^4.0.17",
42
+ "@types/node": "^25.0.10",
43
+ "@vitest/coverage-v8": "^4.0.18",
44
+ "vitest": "^4.0.18",
45
45
  "@assistant-ui/x-buildutils": "0.0.1"
46
46
  },
47
47
  "publishConfig": {
@@ -4,6 +4,17 @@ import { spawn } from "cross-spawn";
4
4
  import { logger } from "../lib/utils/logger";
5
5
  import { createFromExample } from "../lib/create-from-example";
6
6
 
7
+ // Keep in sync with packages/create-assistant-ui/src/index.ts
8
+ const templates = {
9
+ default: "https://github.com/assistant-ui/assistant-ui-starter",
10
+ minimal: "https://github.com/assistant-ui/assistant-ui-starter-minimal",
11
+ cloud: "https://github.com/assistant-ui/assistant-ui-starter-cloud",
12
+ langgraph: "https://github.com/assistant-ui/assistant-ui-starter-langgraph",
13
+ mcp: "https://github.com/assistant-ui/assistant-ui-starter-mcp",
14
+ };
15
+
16
+ const templateNames = Object.keys(templates);
17
+
7
18
  export const create = new Command()
8
19
  .name("create")
9
20
  .description("create a new project")
@@ -11,7 +22,7 @@ export const create = new Command()
11
22
  .usage(`${chalk.green("[project-directory]")} [options]`)
12
23
  .option(
13
24
  "-t, --template <template>",
14
- "template to use (default, cloud, langgraph, mcp)",
25
+ `template to use (${templateNames.join(", ")})`,
15
26
  )
16
27
  .option(
17
28
  "-e, --example <example>",
@@ -40,21 +51,13 @@ export const create = new Command()
40
51
  return;
41
52
  }
42
53
 
43
- // Handle --template option (existing logic)
44
- const templates = {
45
- default: "https://github.com/assistant-ui/assistant-ui-starter",
46
- cloud: "https://github.com/assistant-ui/assistant-ui-starter-cloud",
47
- langgraph:
48
- "https://github.com/assistant-ui/assistant-ui-starter-langgraph",
49
- mcp: "https://github.com/assistant-ui/assistant-ui-starter-mcp",
50
- };
51
-
54
+ // Handle --template option
52
55
  const templateName = (opts.template as keyof typeof templates) ?? "default";
53
56
  const templateUrl = templates[templateName];
54
57
 
55
58
  if (!templateUrl) {
56
59
  logger.error(`Unknown template: ${opts.template}`);
57
- logger.info(`Available templates: ${Object.keys(templates).join(", ")}`);
60
+ logger.info(`Available templates: ${templateNames.join(", ")}`);
58
61
  process.exit(1);
59
62
  }
60
63
 
@@ -2,16 +2,27 @@ import { Command } from "commander";
2
2
  import { spawn } from "cross-spawn";
3
3
  import fs from "node:fs";
4
4
  import path from "node:path";
5
- import { create } from "./create";
6
5
  import { logger } from "../lib/utils/logger";
7
6
  import { hasConfig } from "../lib/utils/config";
8
7
 
9
8
  const DEFAULT_REGISTRY_URL =
10
9
  "https://r.assistant-ui.com/chat/b/ai-sdk-quick-start/json";
11
10
 
11
+ // Keep in sync with packages/create-assistant-ui/src/index.ts
12
+ const templates = {
13
+ default: "https://github.com/assistant-ui/assistant-ui-starter",
14
+ minimal: "https://github.com/assistant-ui/assistant-ui-starter-minimal",
15
+ cloud: "https://github.com/assistant-ui/assistant-ui-starter-cloud",
16
+ langgraph: "https://github.com/assistant-ui/assistant-ui-starter-langgraph",
17
+ mcp: "https://github.com/assistant-ui/assistant-ui-starter-mcp",
18
+ };
19
+
20
+ const templateNames = Object.keys(templates);
21
+
12
22
  export const init = new Command()
13
23
  .name("init")
14
24
  .description("initialize assistant-ui in a new or existing project")
25
+ .argument("[project-directory]", "directory for the new project")
15
26
  .option(
16
27
  "-c, --cwd <cwd>",
17
28
  "the working directory. defaults to the current directory.",
@@ -21,17 +32,30 @@ export const init = new Command()
21
32
  "-p, --preset <url>",
22
33
  "preset URL from playground (e.g., https://www.assistant-ui.com/playground/init?preset=chatgpt)",
23
34
  )
24
- .action(async (opts) => {
35
+ .option(
36
+ "-t, --template <template>",
37
+ `template to use (${templateNames.join(", ")})`,
38
+ "minimal",
39
+ )
40
+ .option("--use-npm", "explicitly use npm")
41
+ .option("--use-pnpm", "explicitly use pnpm")
42
+ .option("--use-yarn", "explicitly use yarn")
43
+ .option("--use-bun", "explicitly use bun")
44
+ .option("--skip-install", "skip installing packages")
45
+ .action(async (projectDirectory, opts) => {
25
46
  const cwd = opts.cwd;
47
+ const targetDir = projectDirectory
48
+ ? path.resolve(cwd, projectDirectory)
49
+ : cwd;
26
50
  const presetUrl = opts.preset;
27
51
 
28
- if (hasConfig(cwd)) {
52
+ if (hasConfig(targetDir)) {
29
53
  logger.warn("Project is already initialized.");
30
54
  logger.info("Use 'assistant-ui add' to add more components.");
31
55
  return;
32
56
  }
33
57
 
34
- const packageJsonPath = path.join(cwd, "package.json");
58
+ const packageJsonPath = path.join(targetDir, "package.json");
35
59
  const packageJsonExists = fs.existsSync(packageJsonPath);
36
60
 
37
61
  if (packageJsonExists) {
@@ -46,7 +70,7 @@ export const init = new Command()
46
70
 
47
71
  const child = spawn("npx", [`shadcn@latest`, "add", registryUrl], {
48
72
  stdio: "inherit",
49
- cwd,
73
+ cwd: targetDir,
50
74
  });
51
75
 
52
76
  child.on("error", (error) => {
@@ -67,8 +91,45 @@ export const init = new Command()
67
91
  }
68
92
  });
69
93
  } else {
70
- logger.info("Creating a new assistant-ui project...");
94
+ const templateName = opts.template as keyof typeof templates;
95
+ const templateUrl = templates[templateName];
96
+
97
+ if (!templateUrl) {
98
+ logger.error(`Unknown template: ${opts.template}`);
99
+ logger.info(`Available templates: ${templateNames.join(", ")}`);
100
+ process.exit(1);
101
+ }
102
+
103
+ logger.info(
104
+ `Creating a new assistant-ui project (template: ${templateName})...`,
105
+ );
71
106
  logger.break();
72
- await create.parseAsync([]);
107
+
108
+ const cnaArgs: string[] = ["create-next-app@latest"];
109
+ cnaArgs.push(projectDirectory || ".");
110
+ cnaArgs.push("-e", templateUrl);
111
+
112
+ if (opts.useNpm) cnaArgs.push("--use-npm");
113
+ if (opts.usePnpm) cnaArgs.push("--use-pnpm");
114
+ if (opts.useYarn) cnaArgs.push("--use-yarn");
115
+ if (opts.useBun) cnaArgs.push("--use-bun");
116
+ if (opts.skipInstall) cnaArgs.push("--skip-install");
117
+
118
+ const child = spawn("npx", cnaArgs, { stdio: "inherit", cwd });
119
+
120
+ child.on("error", (error) => {
121
+ logger.error(`Failed to create project: ${error.message}`);
122
+ process.exit(1);
123
+ });
124
+
125
+ child.on("close", (code) => {
126
+ if (code !== 0) {
127
+ logger.error(`Project creation failed with code ${code}`);
128
+ process.exit(code || 1);
129
+ } else {
130
+ logger.break();
131
+ logger.success("Project created successfully!");
132
+ }
133
+ });
73
134
  }
74
135
  });