@alexkroman1/aai-cli 0.12.1 → 0.12.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/cli.mjs CHANGED
@@ -35,7 +35,7 @@ function findPkgJson(dir) {
35
35
  const VERSION = JSON.parse(findPkgJson(cliDir)).version;
36
36
  async function ensureAgent(cwd, yes) {
37
37
  if (!await fileExists(path.join(cwd, "agent.ts"))) {
38
- const { runInitCommand } = await import("./init-DTfpWUv8.mjs");
38
+ const { runInitCommand } = await import("./init-BYX6pxjd.mjs");
39
39
  return runInitCommand({ yes }, { quiet: true });
40
40
  }
41
41
  return cwd;
@@ -47,6 +47,16 @@ async function setup(args, opts) {
47
47
  if (opts?.apiKey) await ensureApiKeyInEnv();
48
48
  return cwd;
49
49
  }
50
+ /** Catch command errors and display a clean message instead of a raw stack trace. */
51
+ async function handleErrors(fn) {
52
+ try {
53
+ await fn();
54
+ } catch (err) {
55
+ const { log } = await import("./_ui-DWGXImbO.mjs");
56
+ log.error(err instanceof Error ? err.message : String(err));
57
+ process.exit(1);
58
+ }
59
+ }
50
60
  const init = defineCommand({
51
61
  meta: {
52
62
  name: "init",
@@ -68,6 +78,7 @@ const init = defineCommand({
68
78
  alias: "f",
69
79
  description: "Overwrite existing files"
70
80
  },
81
+ server: sharedArgs.server,
71
82
  yes: sharedArgs.yes,
72
83
  skipApi: {
73
84
  type: "boolean",
@@ -79,14 +90,17 @@ const init = defineCommand({
79
90
  }
80
91
  },
81
92
  async run({ args }) {
82
- const { runInitCommand } = await import("./init-DTfpWUv8.mjs");
83
- await runInitCommand({
84
- dir: args.dir,
85
- template: args.template,
86
- force: args.force,
87
- yes: args.yes,
88
- skipApi: args.skipApi,
89
- skipDeploy: args.skipDeploy
93
+ await handleErrors(async () => {
94
+ const { runInitCommand } = await import("./init-BYX6pxjd.mjs");
95
+ await runInitCommand({
96
+ dir: args.dir,
97
+ template: args.template,
98
+ force: args.force,
99
+ yes: args.yes,
100
+ skipApi: args.skipApi,
101
+ skipDeploy: args.skipDeploy,
102
+ server: args.server
103
+ });
90
104
  });
91
105
  }
92
106
  });
@@ -97,17 +111,20 @@ const dev = defineCommand({
97
111
  },
98
112
  args: {
99
113
  port: sharedArgs.port,
114
+ server: sharedArgs.server,
100
115
  yes: sharedArgs.yes
101
116
  },
102
117
  async run({ args }) {
103
- const cwd = await setup(args, {
104
- agent: true,
105
- apiKey: true
106
- });
107
- const { runDevCommand } = await import("./dev-DEZKrw8v.mjs");
108
- await runDevCommand({
109
- cwd,
110
- port: args.port
118
+ await handleErrors(async () => {
119
+ const cwd = await setup(args, {
120
+ agent: true,
121
+ apiKey: true
122
+ });
123
+ const { runDevCommand } = await import("./dev-DEZKrw8v.mjs");
124
+ await runDevCommand({
125
+ cwd,
126
+ port: args.port
127
+ });
111
128
  });
112
129
  }
113
130
  });
@@ -117,9 +134,11 @@ const test = defineCommand({
117
134
  description: "Run agent tests"
118
135
  },
119
136
  async run() {
120
- const cwd = await setup();
121
- const { runTestCommand } = await import("./test-CYoqKJP0.mjs");
122
- await runTestCommand(cwd);
137
+ await handleErrors(async () => {
138
+ const cwd = await setup();
139
+ const { runTestCommand } = await import("./test-CYoqKJP0.mjs");
140
+ await runTestCommand(cwd);
141
+ });
123
142
  }
124
143
  });
125
144
  const build = defineCommand({
@@ -128,6 +147,7 @@ const build = defineCommand({
128
147
  description: "Bundle agent without deploying"
129
148
  },
130
149
  args: {
150
+ server: sharedArgs.server,
131
151
  yes: sharedArgs.yes,
132
152
  skipTests: {
133
153
  type: "boolean",
@@ -135,13 +155,15 @@ const build = defineCommand({
135
155
  }
136
156
  },
137
157
  async run({ args }) {
138
- const cwd = await setup(args, { agent: true });
139
- if (!args.skipTests) {
140
- const { runVitest } = await import("./test-CYoqKJP0.mjs");
141
- runVitest(cwd);
142
- }
143
- const { runBuildCommand } = await import("./_bundler-2yKukgnU.mjs");
144
- await runBuildCommand(cwd);
158
+ await handleErrors(async () => {
159
+ const cwd = await setup(args, { agent: true });
160
+ if (!args.skipTests) {
161
+ const { runVitest } = await import("./test-CYoqKJP0.mjs");
162
+ runVitest(cwd);
163
+ }
164
+ const { runBuildCommand } = await import("./_bundler-2yKukgnU.mjs");
165
+ await runBuildCommand(cwd);
166
+ });
145
167
  }
146
168
  });
147
169
  const deploy = defineCommand({
@@ -158,19 +180,15 @@ const deploy = defineCommand({
158
180
  yes: sharedArgs.yes
159
181
  },
160
182
  async run({ args }) {
161
- const cwd = await setup(args, { agent: true });
162
- const { runDeployCommand } = await import("./deploy-CnscqVZv.mjs");
163
- try {
183
+ await handleErrors(async () => {
184
+ const cwd = await setup(args, { agent: true });
185
+ const { runDeployCommand } = await import("./deploy-CnscqVZv.mjs");
164
186
  await runDeployCommand({
165
187
  cwd,
166
188
  ...args.server ? { server: args.server } : {},
167
189
  ...args.dryRun ? { dryRun: args.dryRun } : {}
168
190
  });
169
- } catch (err) {
170
- const { log } = await import("./_ui-DWGXImbO.mjs");
171
- log.error(err instanceof Error ? err.message : String(err));
172
- process.exit(1);
173
- }
191
+ });
174
192
  }
175
193
  });
176
194
  const del = defineCommand({
@@ -180,11 +198,13 @@ const del = defineCommand({
180
198
  },
181
199
  args: { server: sharedArgs.server },
182
200
  async run({ args }) {
183
- const cwd = await setup();
184
- const { runDeleteCommand } = await import("./delete-BvRel3Tw.mjs");
185
- await runDeleteCommand({
186
- cwd,
187
- ...args.server ? { server: args.server } : {}
201
+ await handleErrors(async () => {
202
+ const cwd = await setup();
203
+ const { runDeleteCommand } = await import("./delete-BvRel3Tw.mjs");
204
+ await runDeleteCommand({
205
+ cwd,
206
+ ...args.server ? { server: args.server } : {}
207
+ });
188
208
  });
189
209
  }
190
210
  });
@@ -205,9 +225,11 @@ const secret = defineCommand({
205
225
  required: true
206
226
  } },
207
227
  async run({ args }) {
208
- const cwd = await setup(void 0, { apiKey: true });
209
- const { runSecretPut } = await import("./secret-DLosn47q.mjs");
210
- await runSecretPut(cwd, args.name);
228
+ await handleErrors(async () => {
229
+ const cwd = await setup(void 0, { apiKey: true });
230
+ const { runSecretPut } = await import("./secret-DLosn47q.mjs");
231
+ await runSecretPut(cwd, args.name);
232
+ });
211
233
  }
212
234
  }),
213
235
  delete: defineCommand({
@@ -221,9 +243,11 @@ const secret = defineCommand({
221
243
  required: true
222
244
  } },
223
245
  async run({ args }) {
224
- const cwd = await setup(void 0, { apiKey: true });
225
- const { runSecretDelete } = await import("./secret-DLosn47q.mjs");
226
- await runSecretDelete(cwd, args.name);
246
+ await handleErrors(async () => {
247
+ const cwd = await setup(void 0, { apiKey: true });
248
+ const { runSecretDelete } = await import("./secret-DLosn47q.mjs");
249
+ await runSecretDelete(cwd, args.name);
250
+ });
227
251
  }
228
252
  }),
229
253
  list: defineCommand({
@@ -232,9 +256,11 @@ const secret = defineCommand({
232
256
  description: "List all secrets"
233
257
  },
234
258
  async run() {
235
- const cwd = await setup(void 0, { apiKey: true });
236
- const { runSecretList } = await import("./secret-DLosn47q.mjs");
237
- await runSecretList(cwd);
259
+ await handleErrors(async () => {
260
+ const cwd = await setup(void 0, { apiKey: true });
261
+ const { runSecretList } = await import("./secret-DLosn47q.mjs");
262
+ await runSecretList(cwd);
263
+ });
238
264
  }
239
265
  })
240
266
  }
@@ -13,14 +13,6 @@ import { promisify } from "node:util";
13
13
  const execFileAsync = promisify(execFile);
14
14
  const DEFAULT_PROJECT_NAME = "my-voice-agent";
15
15
  const DEFAULT_TEMPLATE = "simple";
16
- /** Detect the package manager from the environment. */
17
- function detectPackageManager() {
18
- const ua = process.env.npm_config_user_agent ?? "";
19
- if (ua.startsWith("pnpm")) return "pnpm";
20
- if (ua.startsWith("yarn")) return "yarn";
21
- if (ua.startsWith("bun")) return "bun";
22
- return "npm";
23
- }
24
16
  /** Prompt for project name or return default when --yes is set. */
25
17
  async function promptProjectName(yes) {
26
18
  if (yes) return DEFAULT_PROJECT_NAME;
@@ -54,8 +46,14 @@ async function promptTemplate(yes) {
54
46
  }
55
47
  return result;
56
48
  }
57
- /** Install deps via the detected package manager. */
58
- async function installDeps(cwd, pm) {
49
+ /** Enable corepack so pnpm is available (scaffold declares packageManager: pnpm). */
50
+ async function ensurePnpm() {
51
+ try {
52
+ await execFileAsync("corepack", ["enable"]);
53
+ } catch {}
54
+ }
55
+ /** Install deps with pnpm (scaffold declares packageManager: pnpm). */
56
+ async function installDeps(cwd) {
59
57
  if (await fileExists(path.join(cwd, "node_modules"))) return;
60
58
  let pkgJson;
61
59
  try {
@@ -66,16 +64,17 @@ async function installDeps(cwd, pm) {
66
64
  const deps = Object.keys(pkgJson.dependencies ?? {});
67
65
  const devDeps = Object.keys(pkgJson.devDependencies ?? {});
68
66
  if (deps.length === 0 && devDeps.length === 0) return;
67
+ await ensurePnpm();
69
68
  const s = p.spinner();
70
- s.start(`Installing dependencies with ${pm}`);
69
+ s.start("Installing dependencies with pnpm");
71
70
  try {
72
- await execFileAsync(pm, ["install"], { cwd });
71
+ await execFileAsync("pnpm", ["install", "--ignore-workspace"], { cwd });
73
72
  s.stop("Dependencies installed");
74
73
  } catch (err) {
75
74
  const msg = errorMessage(err);
76
75
  s.stop("Dependency install failed");
77
- log.warn(`${pm} install failed: ${msg}`);
78
- log.warn(`Run \`${pm} install\` manually in the project directory.`);
76
+ log.warn(`pnpm install failed: ${msg}`);
77
+ log.warn("Run `corepack enable && pnpm install` manually in the project directory.");
79
78
  }
80
79
  }
81
80
  /** Format the dev command for the "Next steps" note. */
@@ -83,7 +82,6 @@ function devCommand() {
83
82
  return "aai dev";
84
83
  }
85
84
  async function runInitCommand(opts, extra) {
86
- const pm = detectPackageManager();
87
85
  if (!extra?.quiet) p.intro(colorize("cyanBright", "Create a new voice agent"));
88
86
  if (!opts.skipApi) await ensureApiKeyInEnv();
89
87
  const dir = opts.dir ?? await promptProjectName(opts.yes);
@@ -98,10 +96,13 @@ async function runInitCommand(opts, extra) {
98
96
  template
99
97
  });
100
98
  s.stop("Project created");
101
- await installDeps(cwd, pm);
99
+ await installDeps(cwd);
102
100
  if (!(opts.skipDeploy || extra?.quiet)) {
103
101
  const { runDeployCommand } = await import("./deploy-CnscqVZv.mjs");
104
- await runDeployCommand({ cwd });
102
+ await runDeployCommand({
103
+ cwd,
104
+ ...opts.server ? { server: opts.server } : {}
105
+ });
105
106
  }
106
107
  if (!extra?.quiet) {
107
108
  log.success(`Created ${dir}`);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@alexkroman1/aai-cli",
3
- "version": "0.12.1",
3
+ "version": "0.12.2",
4
4
  "type": "module",
5
5
  "bin": {
6
6
  "aai": "dist/cli.mjs"
@@ -16,7 +16,7 @@
16
16
  "human-id": "^4.1.3",
17
17
  "vite": "^8.0.3",
18
18
  "zod": "^4.3.6",
19
- "@alexkroman1/aai": "0.12.1"
19
+ "@alexkroman1/aai": "0.12.2"
20
20
  },
21
21
  "devDependencies": {
22
22
  "playwright": "^1.58.2",