@alexkroman1/aai-cli 13.2.0 → 14.0.0

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 (152) hide show
  1. package/bin.mjs +1 -1
  2. package/dist/{_agent-BTwZJu4P.mjs → _agent-BzUeqOdj.mjs} +33 -10
  3. package/dist/_agent.d.ts +23 -0
  4. package/dist/{_bundler-C31rlcYz.mjs → _bundler-DolUCMxu.mjs} +9 -8
  5. package/dist/_cli-common.d.ts +45 -6
  6. package/dist/{_config-CmJOFsAP.mjs → _config-DYzC6WMD.mjs} +7 -4
  7. package/dist/_config.d.ts +25 -1
  8. package/dist/_dev-env.d.ts +1 -1
  9. package/dist/{_dev-server-DWvkNoIS.mjs → _dev-server-CSMqF8PN.mjs} +28 -30
  10. package/dist/_dev-vite-config.d.ts +3 -3
  11. package/dist/_e2e-test-utils.d.ts +15 -7
  12. package/dist/{_init-BURbdHNM.mjs → _init-CQ8idAwo.mjs} +64 -30
  13. package/dist/{_output-CKkmWs7i.mjs → _output-DBP9Op_d.mjs} +43 -3
  14. package/dist/_output.d.ts +24 -7
  15. package/dist/{_preflight-Co1G9Jww.mjs → _preflight-CcAR577V.mjs} +3 -3
  16. package/dist/_resource-commands.d.ts +9 -9
  17. package/dist/{_server-common-6e0QI4mq.mjs → _server-common-vILJp3it.mjs} +3 -3
  18. package/dist/{_slug-api-CfGQq1Tt.mjs → _slug-api-CGvc2YSQ.mjs} +19 -10
  19. package/dist/_slug-api.d.ts +19 -0
  20. package/dist/{_studio-B1waXMuR.mjs → _studio-DnR_BqFp.mjs} +9 -5
  21. package/dist/_studio-commands.d.ts +13 -13
  22. package/dist/{_templates-0Zr2z6yA.mjs → _templates-CK4oKoeX.mjs} +3 -3
  23. package/dist/{_typecheck-gate-BXvUNnfs.mjs → _typecheck-gate-U3jcil8L.mjs} +5 -4
  24. package/dist/_typecheck-gate.d.ts +3 -1
  25. package/dist/{_ui-u7T4YooX.mjs → _ui-DCt4qZrk.mjs} +1 -1
  26. package/dist/{_utils-B8QmtFhK.mjs → _utils-D5JGcjiW.mjs} +44 -2
  27. package/dist/_utils.d.ts +35 -0
  28. package/dist/{_vite-env-D9Qj6KPX.mjs → _vite-env-kejF0p2L.mjs} +1 -1
  29. package/dist/{_workflow-determinism-f9J-5Zlj.mjs → _workflow-determinism-CvpqMpdh.mjs} +19 -27
  30. package/dist/_workflow-determinism.d.ts +3 -3
  31. package/dist/build-Mxk8gWvX.mjs +108 -0
  32. package/dist/build.d.ts +5 -0
  33. package/dist/cli.mjs +172 -116
  34. package/dist/{client-bundler-j5c46x0G.mjs → client-bundler-BJgREAh6.mjs} +4 -4
  35. package/dist/client-bundler.mjs +1 -1
  36. package/dist/{delete-X_CRgCf6.mjs → delete-BdFnbnVR.mjs} +6 -6
  37. package/dist/{deploy-BzZ-r4iM.mjs → deploy-uAJ4NukN.mjs} +14 -14
  38. package/dist/{dev-BDykFvcc.mjs → dev-DApPSaE_.mjs} +5 -5
  39. package/dist/{eval-0qEOdm0l.mjs → eval-BK47A_K5.mjs} +27 -11
  40. package/dist/eval.d.ts +2 -0
  41. package/dist/{init-BtJI306C.mjs → init-DukDxECd.mjs} +13 -21
  42. package/dist/{login-DeUETobb.mjs → login-DaLrPOFg.mjs} +6 -8
  43. package/dist/{logs-hWnJ66Bl.mjs → logs-7BRwq0cG.mjs} +22 -15
  44. package/dist/project-config.mjs +1 -1
  45. package/dist/scaffold/.env.example +17 -1
  46. package/dist/scaffold/CLAUDE.md +84 -56
  47. package/dist/scaffold/package.json +6 -5
  48. package/dist/scaffold/server.mjs +129 -25
  49. package/dist/secret-Cjp912yF.mjs +162 -0
  50. package/dist/secret.d.ts +48 -13
  51. package/dist/{studio-BxAS_FQQ.mjs → studio-CpHlNHUZ.mjs} +15 -17
  52. package/dist/templates/briefing-desk/agent.test.ts +7 -3
  53. package/dist/templates/call-audit/agent.test.ts +25 -9
  54. package/dist/templates/call-audit/agent.ts +2 -2
  55. package/dist/templates/call-audit/client.tsx +40 -58
  56. package/dist/templates/call-audit/workflows/audit.ts +7 -5
  57. package/dist/templates/call-audit/workflows/ingest.ts +7 -7
  58. package/dist/templates/call-audit/workflows/media.ts +12 -37
  59. package/dist/templates/call-audit/workflows/summarize.ts +8 -8
  60. package/dist/templates/call-audit/workflows/sync-api.ts +3 -3
  61. package/dist/templates/dispatch-center/agent.test.ts +7 -7
  62. package/dist/templates/dispatch-center/client.tsx +53 -61
  63. package/dist/templates/dispatch-center/shared.ts +0 -8
  64. package/dist/templates/dispatch-center/tools/ops_dashboard.ts +4 -1
  65. package/dist/templates/embedded-assets/agent.eval.test.ts +4 -2
  66. package/dist/templates/embedded-assets/agent.test.ts +7 -1
  67. package/dist/templates/health-assistant/agent.eval.test.ts +4 -2
  68. package/dist/templates/health-assistant/agent.test.ts +8 -4
  69. package/dist/templates/infocom-adventure/client.tsx +40 -36
  70. package/dist/templates/link-digest/agent.test.ts +10 -4
  71. package/dist/templates/link-digest/agent.ts +2 -2
  72. package/dist/templates/link-digest/client.tsx +42 -36
  73. package/dist/templates/link-digest/workflows/digest.ts +13 -16
  74. package/dist/templates/night-owl/agent.eval.test.ts +4 -2
  75. package/dist/templates/night-owl/agent.test.ts +6 -1
  76. package/dist/templates/night-owl/client.tsx +8 -2
  77. package/dist/templates/pipeline-simple/agent.test.ts +33 -16
  78. package/dist/templates/pizza-ordering/client.tsx +5 -4
  79. package/dist/templates/pizza-ordering/shared.ts +3 -8
  80. package/dist/templates/pizza-ordering/tools/add_pizza.ts +3 -2
  81. package/dist/templates/pizza-ordering/tools/place_order.ts +3 -2
  82. package/dist/templates/pizza-ordering/tools/remove_pizza.ts +3 -2
  83. package/dist/templates/pizza-ordering/tools/update_pizza.ts +3 -2
  84. package/dist/templates/pizza-ordering/tools/view_order.ts +3 -2
  85. package/dist/templates/plan-and-execute/agent.test.ts +10 -5
  86. package/dist/templates/plan-and-execute/client.tsx +2 -2
  87. package/dist/templates/podcast-digest/agent.test.ts +33 -14
  88. package/dist/templates/podcast-digest/client.tsx +27 -36
  89. package/dist/templates/podcast-digest/workflows/digest.ts +21 -19
  90. package/dist/templates/podcast-digest/workflows/feeds.ts +61 -33
  91. package/dist/templates/podcast-digest/workflows/slack.ts +7 -7
  92. package/dist/templates/recap-workflow/agent.eval.test.ts +21 -13
  93. package/dist/templates/recap-workflow/agent.test.ts +49 -32
  94. package/dist/templates/recap-workflow/workflows/recap.ts +24 -28
  95. package/dist/templates/redline/agent.eval.test.ts +5 -8
  96. package/dist/templates/redline/agent.test.ts +8 -2
  97. package/dist/templates/redline/client.tsx +47 -48
  98. package/dist/templates/redline/workflows/redline.ts +17 -17
  99. package/dist/templates/research-workflow/agent.eval.test.ts +5 -5
  100. package/dist/templates/research-workflow/agent.test.ts +17 -8
  101. package/dist/templates/research-workflow/workflows/research.ts +28 -30
  102. package/dist/templates/retail/agent.test.ts +17 -15
  103. package/dist/templates/retail/cancel.ts +7 -6
  104. package/dist/templates/retail/client.tsx +39 -58
  105. package/dist/templates/retail/payment.ts +4 -3
  106. package/dist/templates/retail/pending.test.ts +19 -19
  107. package/dist/templates/retail/registry.test.ts +99 -58
  108. package/dist/templates/retail/store.test.ts +5 -5
  109. package/dist/templates/retail/swap.ts +8 -11
  110. package/dist/templates/simple/agent.test.ts +39 -6
  111. package/dist/templates/solo-rpg/agent.eval.test.ts +2 -16
  112. package/dist/templates/solo-rpg/agent.test.ts +12 -12
  113. package/dist/templates/solo-rpg/client.tsx +3 -3
  114. package/dist/templates/spoken-summary/agent.test.ts +21 -12
  115. package/dist/templates/spoken-summary/agent.ts +3 -3
  116. package/dist/templates/spoken-summary/client.tsx +36 -47
  117. package/dist/templates/spoken-summary/workflows/summarize.ts +11 -11
  118. package/dist/templates/spoken-summary/workflows/transcribe.ts +14 -14
  119. package/dist/templates/support-line/client.tsx +4 -3
  120. package/dist/templates/support-line/prompts.ts +0 -2
  121. package/dist/templates/transcription-workflow/agent.test.ts +36 -20
  122. package/dist/templates/transcription-workflow/agent.ts +2 -2
  123. package/dist/templates/transcription-workflow/client.tsx +34 -40
  124. package/dist/templates/transcription-workflow/recover.ts +1 -1
  125. package/dist/templates/transcription-workflow/run-panel.tsx +34 -14
  126. package/dist/templates/transcription-workflow/total-latency.tsx +46 -20
  127. package/dist/templates/transcription-workflow/workflows/batch.ts +15 -15
  128. package/dist/templates/transcription-workflow/workflows/downsample.ts +1 -1
  129. package/dist/templates/transcription-workflow/workflows/normalize.ts +15 -19
  130. package/dist/templates/transcription-workflow/workflows/stream.ts +12 -12
  131. package/dist/templates/transcription-workflow/workflows/sync-api.ts +3 -3
  132. package/dist/templates/transcription-workflow/workflows/transcribe.ts +23 -34
  133. package/dist/templates/travel-concierge/agent.eval.test.ts +2 -2
  134. package/dist/templates/travel-concierge/agent.test.ts +15 -7
  135. package/dist/templates/travel-concierge/client.tsx +2 -2
  136. package/dist/templates/travel-concierge/shared.ts +10 -14
  137. package/dist/templates/travel-concierge/tools/lookup_booking.ts +4 -3
  138. package/dist/templates/travel-concierge/tools/search_car_rentals.ts +3 -2
  139. package/dist/templates/travel-concierge/tools/search_excursions.ts +3 -2
  140. package/dist/templates/travel-concierge/tools/search_flights.ts +3 -2
  141. package/dist/templates/travel-concierge/tools/search_hotels.ts +3 -2
  142. package/dist/test-D032V2cA.mjs +242 -0
  143. package/dist/test.d.ts +97 -31
  144. package/dist/typecheck.mjs +2 -2
  145. package/dist/worker-bundler.mjs +3 -3
  146. package/dist/{workflow-BBu5oEDw.mjs → workflow-CVioyO3V.mjs} +8 -7
  147. package/package.json +10 -10
  148. package/dist/bin.d.mts +0 -2
  149. package/dist/build-BLlLOrng.mjs +0 -66
  150. package/dist/secret-B-3T5tvr.mjs +0 -61
  151. package/dist/test-CiLab-AA.mjs +0 -182
  152. package/dist/tsdown.config.d.ts +0 -2
package/dist/cli.mjs CHANGED
@@ -1,13 +1,13 @@
1
1
  #!/usr/bin/env node
2
- import { i as installStdoutGuard, n as fail, o as writeLine, r as getOutputMode, t as CliError } from "./_output-CKkmWs7i.mjs";
3
- import { n as log, o as silenceOutput } from "./_ui-u7T4YooX.mjs";
4
- import { d as resolveCwd, o as errorMessage$1, s as fileExists, t as AGENT_ENTRY, u as readPackageJson } from "./_utils-B8QmtFhK.mjs";
2
+ import { i as installStdoutGuard, n as fail, o as writeLine, r as getOutputMode, t as CliError } from "./_output-DBP9Op_d.mjs";
3
+ import { n as log, o as silenceOutput } from "./_ui-DCt4qZrk.mjs";
4
+ import { c as fileExists, f as readPackageJson, p as resolveCwd, s as errorMessage$1, t as AGENT_ENTRY } from "./_utils-D5JGcjiW.mjs";
5
5
  import { existsSync } from "node:fs";
6
6
  import path from "node:path";
7
7
  import { fileURLToPath } from "node:url";
8
+ import { isRecord, plural } from "@alexkroman1/aai/utils";
8
9
  import { defineCommand, runMain, showUsage } from "citty";
9
- import { isRecord } from "@alexkroman1/aai/utils";
10
- //#region _cli-common.ts
10
+ //#region src/_cli-common.ts
11
11
  /** Shared arg definitions for citty commands. */
12
12
  const sharedArgs = {
13
13
  server: {
@@ -25,6 +25,19 @@ const sharedArgs = {
25
25
  description: "Output JSON (auto-detected in non-TTY)"
26
26
  }
27
27
  };
28
+ /**
29
+ * What every PLATFORM command accepts — the pair, as a group to spread.
30
+ *
31
+ * `sharedArgs` supplies the field VALUES, so each of the twelve credentialed
32
+ * commands still restated the shape (`server: sharedArgs.server, json:
33
+ * sharedArgs.json`). A flag all of them should take is then twelve edits, and
34
+ * `assertKnownArgv` refuses the flag on whichever one was missed — after
35
+ * release. `cli-workflow.ts`'s `workflowArgs` is the same pattern for its group.
36
+ */
37
+ const platformArgs = {
38
+ server: sharedArgs.server,
39
+ json: sharedArgs.json
40
+ };
28
41
  /** Flags citty handles itself, so no command declares them. */
29
42
  const BUILTIN_FLAGS = /* @__PURE__ */ new Set([
30
43
  "help",
@@ -106,31 +119,42 @@ function commandPath(cmd, parent) {
106
119
  return named.startsWith("aai") ? named : `aai ${named}`.trim();
107
120
  }
108
121
  /**
109
- * Unknown flags in `argv` for whichever (possibly nested) subcommand it
110
- * selects `[]` when everything is declared.
122
+ * Walk the real command tree for `argv` and report everything the pre-parse
123
+ * guards in `cli.ts` need: which command it selects, what that command
124
+ * declares, and whether a token mistyped a subcommand.
111
125
  *
112
- * Walks the real command tree rather than re-listing flags, so this cannot
113
- * drift from what the commands accept. An unknown SUBCOMMAND is not reported:
114
- * citty already answers that with usage text and a non-zero exit.
126
+ * ONE walk, because there used to be two this one and a copy in `cli.ts`,
127
+ * each with its own `Resolvable` narrowing, whose only difference was the
128
+ * terminal action. The copies also had an ORDERING dependency nothing
129
+ * enforced: the flag guard reports nothing for a mistyped subcommand (the
130
+ * flags would be matched against the wrong command's definition), which is
131
+ * only safe because the command guard ran first. Answering both from one
132
+ * result removes the ordering rather than documenting it.
115
133
  */
116
- async function unknownFlagsForArgv(root, argv) {
134
+ async function resolveArgv(root, argv) {
117
135
  let cmd = root;
136
+ const named = ["aai"];
118
137
  let i = 0;
119
138
  for (; i < argv.length; i++) {
120
139
  const token = argv[i];
121
140
  if (token === void 0 || token.startsWith("-")) break;
122
141
  const subCommands = await resolve(cmd.subCommands);
123
- const next = subCommands?.[token];
124
- if (next === void 0) {
125
- if (subCommands && Object.keys(subCommands).length > 0) return [];
126
- break;
127
- }
128
- const resolved = await resolve(next);
129
- if (resolved === void 0) break;
130
- cmd = resolved;
142
+ if (!subCommands || Object.keys(subCommands).length === 0) break;
143
+ const next = await resolve(subCommands[token]);
144
+ if (next === void 0) return {
145
+ named,
146
+ unknownCommand: token,
147
+ argsDef: await resolve(cmd.args) ?? {},
148
+ rest: []
149
+ };
150
+ cmd = next;
151
+ named.push(token);
131
152
  }
132
- const argsDef = await resolve(cmd.args) ?? {};
133
- return findUnknownFlags(argv.slice(i), argsDef);
153
+ return {
154
+ named,
155
+ argsDef: await resolve(cmd.args) ?? {},
156
+ rest: argv.slice(i)
157
+ };
134
158
  }
135
159
  /** Shared command setup: resolve cwd, optionally require agent.ts. */
136
160
  async function setup(opts) {
@@ -238,26 +262,42 @@ function defineExec(spec) {
238
262
  });
239
263
  }
240
264
  //#endregion
241
- //#region _resource-commands.ts
265
+ //#region src/_resource-commands.ts
266
+ /**
267
+ * Refuse `aai secret put NAME value` instead of dropping the value.
268
+ *
269
+ * `value` is not a declared positional, and citty drops an undeclared one
270
+ * silently — so the natural guess set the secret to whatever stdin later
271
+ * yielded (usually nothing) and reported no problem, which is the same class
272
+ * of failure as the unknown flag `assertKnownFlags` exists for.
273
+ *
274
+ * REFUSED rather than accepted, deliberately: a value in argv is in the
275
+ * user's shell history and in `ps` output for every process on the machine,
276
+ * and this is the command whose whole subject is a credential. The extra
277
+ * token is NOT echoed back for the same reason.
278
+ */
279
+ function refuseValueInArgv(positionals) {
280
+ if (!positionals || positionals.length <= 1) return;
281
+ throw new CliError("usage", "`aai secret put` takes only the secret NAME — the value is read from stdin.", "Pipe it in: `printf %s \"$VALUE\" | aai secret put NAME`. A value passed as an argument would be left in your shell history and visible in `ps`.");
282
+ }
242
283
  const secretPut = defineExec({
243
284
  meta: {
244
285
  name: "put",
245
- description: "Create or update a secret"
286
+ description: "Create or update a secret (value read from stdin, or prompted on a terminal)"
246
287
  },
247
288
  args: {
248
289
  name: {
249
290
  type: "positional",
250
- description: "Secret name",
291
+ description: "Secret name. The VALUE is not an argument — pipe it in (`printf %s \"$VALUE\" | aai secret put NAME`), or be prompted, masked, when stdin is a terminal",
251
292
  required: true
252
293
  },
253
- server: sharedArgs.server,
254
- json: sharedArgs.json
294
+ ...platformArgs
255
295
  },
256
296
  cwd: "any",
257
297
  async run({ args, mode, cwd }) {
258
- const { executeSecretPut, NO_INPUT, readStdin } = await import("./secret-B-3T5tvr.mjs");
259
- const value = mode === "json" ? await readStdin() : void 0;
260
- if (mode === "json" && !value) throw new CliError(...NO_INPUT);
298
+ refuseValueInArgv(args._);
299
+ const { executeSecretPut, resolveSecretValue } = await import("./secret-Cjp912yF.mjs");
300
+ const value = await resolveSecretValue(args.name, mode);
261
301
  return executeSecretPut(cwd, args.name, value, args.server);
262
302
  }
263
303
  });
@@ -272,12 +312,11 @@ const secretDelete = defineExec({
272
312
  description: "Secret name",
273
313
  required: true
274
314
  },
275
- server: sharedArgs.server,
276
- json: sharedArgs.json
315
+ ...platformArgs
277
316
  },
278
317
  cwd: "any",
279
318
  async run({ args, cwd }) {
280
- const { executeSecretDelete } = await import("./secret-B-3T5tvr.mjs");
319
+ const { executeSecretDelete } = await import("./secret-Cjp912yF.mjs");
281
320
  return executeSecretDelete(cwd, args.name, args.server);
282
321
  }
283
322
  });
@@ -286,13 +325,10 @@ const secretList = defineExec({
286
325
  name: "list",
287
326
  description: "List all secrets"
288
327
  },
289
- args: {
290
- server: sharedArgs.server,
291
- json: sharedArgs.json
292
- },
328
+ args: { ...platformArgs },
293
329
  cwd: "any",
294
330
  async run({ args, cwd }) {
295
- const { executeSecretList } = await import("./secret-B-3T5tvr.mjs");
331
+ const { executeSecretList } = await import("./secret-Cjp912yF.mjs");
296
332
  return executeSecretList(cwd, args.server);
297
333
  }
298
334
  });
@@ -327,12 +363,11 @@ const logs = defineExec({
327
363
  alias: "f",
328
364
  description: "Keep printing new output"
329
365
  },
330
- server: sharedArgs.server,
331
- json: sharedArgs.json
366
+ ...platformArgs
332
367
  },
333
368
  cwd: "any",
334
369
  async run({ args, cwd }) {
335
- const { executeLogs } = await import("./logs-hWnJ66Bl.mjs");
370
+ const { executeLogs } = await import("./logs-7BRwq0cG.mjs");
336
371
  return executeLogs(resolveDirArg(cwd, args.dir), {
337
372
  server: args.server,
338
373
  follow: args.follow
@@ -340,7 +375,7 @@ const logs = defineExec({
340
375
  }
341
376
  });
342
377
  //#endregion
343
- //#region _studio-commands.ts
378
+ //#region src/_studio-commands.ts
344
379
  /**
345
380
  * The fast-forward override `push` and `publish` share — `publish` pushes
346
381
  * first, so the two must always describe the same thing to the user.
@@ -357,13 +392,10 @@ const list = defineExec({
357
392
  name: "list",
358
393
  description: "List your studio projects"
359
394
  },
360
- args: {
361
- server: sharedArgs.server,
362
- json: sharedArgs.json
363
- },
395
+ args: { ...platformArgs },
364
396
  cwd: "any",
365
397
  async run({ args, cwd }) {
366
- const { executeList } = await import("./studio-BxAS_FQQ.mjs");
398
+ const { executeList } = await import("./studio-CpHlNHUZ.mjs");
367
399
  return executeList({
368
400
  cwd,
369
401
  server: args.server
@@ -391,12 +423,11 @@ const pull = defineExec({
391
423
  alias: "f",
392
424
  description: "Overwrite files in a non-empty directory"
393
425
  },
394
- server: sharedArgs.server,
395
- json: sharedArgs.json
426
+ ...platformArgs
396
427
  },
397
428
  cwd: "any",
398
429
  async run({ args, cwd }) {
399
- const { executePull } = await import("./studio-BxAS_FQQ.mjs");
430
+ const { executePull } = await import("./studio-CpHlNHUZ.mjs");
400
431
  return executePull({
401
432
  cwd,
402
433
  project: args.project,
@@ -413,12 +444,11 @@ const push = defineExec({
413
444
  },
414
445
  args: {
415
446
  force: forceArg,
416
- server: sharedArgs.server,
417
- json: sharedArgs.json
447
+ ...platformArgs
418
448
  },
419
449
  cwd: "agent",
420
450
  async run({ args, cwd }) {
421
- const { executePush } = await import("./studio-BxAS_FQQ.mjs");
451
+ const { executePush } = await import("./studio-CpHlNHUZ.mjs");
422
452
  return executePush({
423
453
  cwd,
424
454
  server: args.server,
@@ -433,8 +463,7 @@ const publish = defineExec({
433
463
  },
434
464
  args: {
435
465
  force: forceArg,
436
- server: sharedArgs.server,
437
- json: sharedArgs.json,
466
+ ...platformArgs,
438
467
  skipTypecheck: {
439
468
  type: "boolean",
440
469
  description: "Skip type checking before publishing"
@@ -442,7 +471,7 @@ const publish = defineExec({
442
471
  },
443
472
  cwd: "agent",
444
473
  async run({ args, cwd }) {
445
- const { executePublish } = await import("./studio-BxAS_FQQ.mjs");
474
+ const { executePublish } = await import("./studio-CpHlNHUZ.mjs");
446
475
  return executePublish({
447
476
  cwd,
448
477
  server: args.server,
@@ -452,7 +481,7 @@ const publish = defineExec({
452
481
  }
453
482
  });
454
483
  //#endregion
455
- //#region cli-workflow.ts
484
+ //#region src/cli-workflow.ts
456
485
  /**
457
486
  * The `aai workflow` subcommand group.
458
487
  *
@@ -480,7 +509,7 @@ const workflowToken = {
480
509
  * and until this flag existed there was no way to say so: every verb resolved a
481
510
  * platform origin plus a PUBLISHED slug, so an undeployed project was told to
482
511
  * `aai publish` while the runs it asked about were answering on localhost. A
483
- * dev server also has no slug segment at all (`createServer` mounts the API on
512
+ * dev server also has no slug segment at all (`createRuntimeServer` mounts the API on
484
513
  * the origin), so a different `--server` could not express it either.
485
514
  *
486
515
  * Separate from `--server` rather than a mode of it, because the two carry
@@ -504,8 +533,7 @@ const runIdArg = {
504
533
  * without `--token`.
505
534
  */
506
535
  const workflowArgs = {
507
- server: sharedArgs.server,
508
- json: sharedArgs.json,
536
+ ...platformArgs,
509
537
  token: workflowToken,
510
538
  agent: workflowAgent
511
539
  };
@@ -515,6 +543,19 @@ const workflowArgs = {
515
543
  * never edited still names a deployed agent whose runs are worth asking about.
516
544
  */
517
545
  const WORKFLOW_CWD = "any";
546
+ /**
547
+ * The group flags, forwarded.
548
+ *
549
+ * The declaration side is DRY (`workflowArgs`) and the forwarding side was not:
550
+ * four hand-copied `{ server, token, agent }` triples, in the module whose own
551
+ * doc argues that "four hand-copied triples is how one of them ends up without
552
+ * `--token`". A fifth group flag is one edit here rather than four below.
553
+ */
554
+ const workflowOpts = (args) => ({
555
+ server: args.server,
556
+ token: args.token,
557
+ agent: args.agent
558
+ });
518
559
  const workflowList = defineExec({
519
560
  meta: {
520
561
  name: "list",
@@ -523,12 +564,8 @@ const workflowList = defineExec({
523
564
  args: workflowArgs,
524
565
  cwd: WORKFLOW_CWD,
525
566
  async run({ args, cwd }) {
526
- const { executeWorkflowList } = await import("./workflow-BBu5oEDw.mjs");
527
- return executeWorkflowList(cwd, {
528
- server: args.server,
529
- token: args.token,
530
- agent: args.agent
531
- });
567
+ const { executeWorkflowList } = await import("./workflow-CVioyO3V.mjs");
568
+ return executeWorkflowList(cwd, workflowOpts(args));
532
569
  }
533
570
  });
534
571
  const workflowRuns = defineExec({
@@ -550,13 +587,11 @@ const workflowRuns = defineExec({
550
587
  },
551
588
  cwd: WORKFLOW_CWD,
552
589
  async run({ args, cwd }) {
553
- const { executeWorkflowRuns } = await import("./workflow-BBu5oEDw.mjs");
590
+ const { executeWorkflowRuns } = await import("./workflow-CVioyO3V.mjs");
554
591
  const limit = args.limit === void 0 ? void 0 : Number(args.limit);
555
592
  if (limit !== void 0 && !Number.isFinite(limit)) throw new CliError("bad_limit", "--limit must be a number");
556
593
  return executeWorkflowRuns(cwd, args.workflow, {
557
- server: args.server,
558
- token: args.token,
559
- agent: args.agent,
594
+ ...workflowOpts(args),
560
595
  limit
561
596
  });
562
597
  }
@@ -572,12 +607,8 @@ const workflowShow = defineExec({
572
607
  },
573
608
  cwd: WORKFLOW_CWD,
574
609
  async run({ args, cwd }) {
575
- const { executeWorkflowShow } = await import("./workflow-BBu5oEDw.mjs");
576
- return executeWorkflowShow(cwd, args.runId, {
577
- server: args.server,
578
- token: args.token,
579
- agent: args.agent
580
- });
610
+ const { executeWorkflowShow } = await import("./workflow-CVioyO3V.mjs");
611
+ return executeWorkflowShow(cwd, args.runId, workflowOpts(args));
581
612
  }
582
613
  });
583
614
  const workflowCancel = defineExec({
@@ -591,12 +622,8 @@ const workflowCancel = defineExec({
591
622
  },
592
623
  cwd: WORKFLOW_CWD,
593
624
  async run({ args, cwd }) {
594
- const { executeWorkflowCancel } = await import("./workflow-BBu5oEDw.mjs");
595
- return executeWorkflowCancel(cwd, args.runId, {
596
- server: args.server,
597
- token: args.token,
598
- agent: args.agent
599
- });
625
+ const { executeWorkflowCancel } = await import("./workflow-CVioyO3V.mjs");
626
+ return executeWorkflowCancel(cwd, args.runId, workflowOpts(args));
600
627
  }
601
628
  });
602
629
  const workflow = defineCommand({
@@ -612,11 +639,11 @@ const workflow = defineCommand({
612
639
  }
613
640
  });
614
641
  //#endregion
615
- //#region cli.ts
642
+ //#region src/cli.ts
616
643
  const cliDir = path.dirname(fileURLToPath(import.meta.url));
617
644
  /**
618
- * Read this CLI's own version from its package.json (source layout keeps it
619
- * next to cli.ts; dist layout one level up). A missing or corrupt file must
645
+ * Read this CLI's own version from its package.json (one level up in both the
646
+ * source `src/` layout and the dist layout). A missing or corrupt file must
620
647
  * not brick every command over a cosmetic string — warn and fall back.
621
648
  */
622
649
  function readCliVersion(dir) {
@@ -678,7 +705,7 @@ const init = defineExec({
678
705
  },
679
706
  cwd: "none",
680
707
  async run({ args, mode }) {
681
- const { executeInit } = await import("./init-BtJI306C.mjs");
708
+ const { executeInit } = await import("./init-DukDxECd.mjs");
682
709
  return executeInit({
683
710
  dir: args.dir,
684
711
  force: args.force,
@@ -709,7 +736,7 @@ const dev = defineExec({
709
736
  },
710
737
  cwd: "agent",
711
738
  async run({ args, cwd }) {
712
- const { executeDev } = await import("./dev-BDykFvcc.mjs");
739
+ const { executeDev } = await import("./dev-DApPSaE_.mjs");
713
740
  return executeDev({
714
741
  cwd,
715
742
  port: args.port,
@@ -722,11 +749,17 @@ const test = defineExec({
722
749
  name: "test",
723
750
  description: "Run agent tests"
724
751
  },
725
- args: { json: sharedArgs.json },
752
+ args: {
753
+ json: sharedArgs.json,
754
+ all: {
755
+ type: "boolean",
756
+ description: "Run every spec in the project, not just agent.test.ts"
757
+ }
758
+ },
726
759
  cwd: "agent",
727
- async run({ cwd }) {
728
- const { executeTest } = await import("./test-CiLab-AA.mjs");
729
- return executeTest(cwd);
760
+ async run({ args, cwd }) {
761
+ const { executeTest } = await import("./test-D032V2cA.mjs");
762
+ return executeTest(cwd, { all: args.all === true });
730
763
  }
731
764
  });
732
765
  const evalCommand = defineExec({
@@ -737,7 +770,7 @@ const evalCommand = defineExec({
737
770
  args: { json: sharedArgs.json },
738
771
  cwd: "agent",
739
772
  async run({ cwd }) {
740
- const { executeEval } = await import("./eval-0qEOdm0l.mjs");
773
+ const { executeEval } = await import("./eval-BK47A_K5.mjs");
741
774
  return executeEval(cwd);
742
775
  }
743
776
  });
@@ -759,7 +792,7 @@ const build = defineExec({
759
792
  },
760
793
  cwd: "agent",
761
794
  async run({ args, cwd }) {
762
- const { executeBuild } = await import("./build-BLlLOrng.mjs");
795
+ const { executeBuild } = await import("./build-Mxk8gWvX.mjs");
763
796
  return executeBuild({
764
797
  cwd,
765
798
  skipTests: args.skipTests,
@@ -774,8 +807,7 @@ const deploy = defineExec({
774
807
  hidden: true
775
808
  },
776
809
  args: {
777
- server: sharedArgs.server,
778
- json: sharedArgs.json,
810
+ ...platformArgs,
779
811
  allowPreviewSlug: {
780
812
  type: "boolean",
781
813
  description: "Permit a `-preview`-suffixed slug (reserved for studio auto-previews; studio-internal — a slug you claim this way is subject to the preview reaper)"
@@ -787,7 +819,7 @@ const deploy = defineExec({
787
819
  },
788
820
  cwd: "agent",
789
821
  async run({ args, cwd }) {
790
- const { executeDeploy } = await import("./deploy-BzZ-r4iM.mjs");
822
+ const { executeDeploy } = await import("./deploy-uAJ4NukN.mjs");
791
823
  return executeDeploy({
792
824
  cwd,
793
825
  server: args.server,
@@ -801,13 +833,10 @@ const del = defineExec({
801
833
  name: "delete",
802
834
  description: "Delete the studio project and its deployed agents"
803
835
  },
804
- args: {
805
- server: sharedArgs.server,
806
- json: sharedArgs.json
807
- },
836
+ args: { ...platformArgs },
808
837
  cwd: "any",
809
838
  async run({ args, cwd }) {
810
- const { executeDelete } = await import("./delete-X_CRgCf6.mjs");
839
+ const { executeDelete } = await import("./delete-BdFnbnVR.mjs");
811
840
  return executeDelete({
812
841
  cwd,
813
842
  server: args.server
@@ -819,13 +848,10 @@ const login = defineExec({
819
848
  name: "login",
820
849
  description: "Link your signed-in browser account and save your API key"
821
850
  },
822
- args: {
823
- server: sharedArgs.server,
824
- json: sharedArgs.json
825
- },
851
+ args: { ...platformArgs },
826
852
  cwd: "none",
827
853
  async run({ args }) {
828
- const { executeLogin } = await import("./login-DeUETobb.mjs");
854
+ const { executeLogin } = await import("./login-DaLrPOFg.mjs");
829
855
  return executeLogin({ server: args.server });
830
856
  }
831
857
  });
@@ -837,7 +863,7 @@ const templates = defineExec({
837
863
  args: { json: sharedArgs.json },
838
864
  cwd: "none",
839
865
  async run({ mode }) {
840
- const { listTemplates } = await import("./_templates-0Zr2z6yA.mjs");
866
+ const { listTemplates } = await import("./_templates-CK4oKoeX.mjs");
841
867
  const names = await listTemplates();
842
868
  if (mode === "human") {
843
869
  for (const name of names) log.message(name);
@@ -913,17 +939,17 @@ if (process.env.VITEST !== "true") {
913
939
  await writeLine(`${JSON.stringify(fail("usage", `Invalid arguments for \`${named}\`.`, `Run \`${named} --help\` to see the arguments it accepts.`))}\n`);
914
940
  };
915
941
  /**
916
- * Refuse an unrecognized flag instead of ignoring it.
942
+ * Report a pre-parse failure the way the active output mode allows, then
943
+ * exit 1.
917
944
  *
918
- * citty drops one silently, so `aai push --serverr=http://x` exited 0 having
919
- * pushed to the DEFAULT server. `--server` decides where the API key and
920
- * secret values go, so a typo that quietly retargets it is worth failing on.
945
+ * Mode-aware for the same reason `usageForMode` is: JSON mode promises
946
+ * exactly one result line on stdout, and it is auto-detected on a pipe —
947
+ * so a clack block here left `aai push --json --serverr=x` emitting a
948
+ * human error where a script's `jq` expected a result, and no JSON at all.
949
+ * The guards below run BEFORE citty parses, so neither can lean on
950
+ * `defineExec`'s mode plumbing.
921
951
  */
922
- const assertKnownFlags = async () => {
923
- const unknown = await unknownFlagsForArgv(mainCommand, process.argv.slice(2));
924
- if (unknown.length === 0) return;
925
- const label = `Unknown ${unknown.length === 1 ? "option" : "options"}: ${unknown.join(", ")}`;
926
- const hint = "Run `aai <command> --help` to see the options it accepts.";
952
+ const reportAndExit = async (label, hint) => {
927
953
  if (getOutputMode({}) === "json") await writeLine(`${JSON.stringify(fail("usage", label, hint))}\n`);
928
954
  else {
929
955
  log.error(label);
@@ -931,7 +957,37 @@ if (process.env.VITEST !== "true") {
931
957
  }
932
958
  process.exit(1);
933
959
  };
934
- runDefault().then(assertKnownFlags).then(() => runMain(mainCommand, { showUsage: usageForMode })).catch((err) => {
960
+ /**
961
+ * Refuse a mistyped command or an unrecognized flag instead of letting
962
+ * either through — both read off ONE walk of the command tree.
963
+ *
964
+ * An unknown SUBCOMMAND is answered here rather than by citty, which throws
965
+ * `Unknown command ${cyan(name)}` and writes it with `console.error` —
966
+ * colour escapes and all, whatever the output mode and whether or not stderr
967
+ * is a terminal — AFTER `showUsage` has already emitted the result line. So
968
+ * `aai deploy-now | jq` produced an envelope that named `aai` instead of the
969
+ * token the user typed, plus an ANSI-studded sentence on stderr that no JSON
970
+ * consumer asked for. Reported here instead: the envelope names the command,
971
+ * and nothing colours a pipe.
972
+ *
973
+ * An unknown FLAG is refused because citty drops one silently, so
974
+ * `aai push --serverr=http://x` exited 0 having pushed to the DEFAULT server.
975
+ * `--server` decides where the API key and secret values go, so a typo that
976
+ * quietly retargets it is worth failing on.
977
+ *
978
+ * The command check comes first because a flag can only be judged against
979
+ * the right command's `argsDef` — which is why `resolveArgv` reports the two
980
+ * together instead of leaving the order to this call site.
981
+ */
982
+ const assertKnownArgv = async () => {
983
+ const { named, unknownCommand, argsDef, rest } = await resolveArgv(mainCommand, process.argv.slice(2));
984
+ if (unknownCommand !== void 0) await reportAndExit(`Unknown command: ${unknownCommand}`, `Run \`${named.join(" ")} --help\` to see the commands it accepts.`);
985
+ const unknown = findUnknownFlags(rest, argsDef);
986
+ if (unknown.length === 0) return;
987
+ const label = `Unknown ${plural(unknown.length, "option")}: ${unknown.join(", ")}`;
988
+ await reportAndExit(label, "Run `aai <command> --help` to see the options it accepts.");
989
+ };
990
+ runDefault().then(assertKnownArgv).then(() => runMain(mainCommand, { showUsage: usageForMode })).catch((err) => {
935
991
  log.error(errorMessage$1(err));
936
992
  process.exitCode = 1;
937
993
  });
@@ -1,13 +1,13 @@
1
1
  #!/usr/bin/env node
2
- import { o as errorMessage$1, s as fileExists } from "./_utils-B8QmtFhK.mjs";
3
- import { n as withPreservedNodeEnv, t as DEDUPED_PEERS } from "./_vite-env-D9Qj6KPX.mjs";
2
+ import { c as fileExists, s as errorMessage$1 } from "./_utils-D5JGcjiW.mjs";
3
+ import { n as withPreservedNodeEnv, t as DEDUPED_PEERS } from "./_vite-env-kejF0p2L.mjs";
4
4
  import { existsSync, unlinkSync, writeFileSync } from "node:fs";
5
5
  import path from "node:path";
6
6
  import { omitUndefined } from "@alexkroman1/aai/utils";
7
7
  import fs from "node:fs/promises";
8
8
  import { isTextAssetPath } from "@alexkroman1/aai/internal";
9
9
  import { build } from "vite";
10
- //#region _default-html.ts
10
+ //#region src/_default-html.ts
11
11
  /**
12
12
  * Default index.html for agents with a custom client.tsx but no index.html.
13
13
  * Used by both the dev server (Vite HMR) and the production bundler.
@@ -71,7 +71,7 @@ function writeTempHtml(root) {
71
71
  return cleanup;
72
72
  }
73
73
  //#endregion
74
- //#region client-bundler.ts
74
+ //#region src/client-bundler.ts
75
75
  const DEFAULT_OUT_DIR = ".aai/client";
76
76
  /**
77
77
  * Build the client SPA with Vite if `client.tsx` exists.
@@ -1,3 +1,3 @@
1
1
  #!/usr/bin/env node
2
- import { t as buildClient } from "./client-bundler-j5c46x0G.mjs";
2
+ import { t as buildClient } from "./client-bundler-BJgREAh6.mjs";
3
3
  export { buildClient };
@@ -1,11 +1,11 @@
1
1
  #!/usr/bin/env node
2
- import { a as ok } from "./_output-CKkmWs7i.mjs";
3
- import { n as log } from "./_ui-u7T4YooX.mjs";
4
- import { l as writeProjectConfig } from "./_config-CmJOFsAP.mjs";
5
- import { a as resolveDeployTarget, i as requireDeployedSlug } from "./_agent-BTwZJu4P.mjs";
6
- import { d as apiTestSeam, l as HINT_NOT_DEPLOYED, s as studioProjectApiUrl, u as apiRequest } from "./_studio-B1waXMuR.mjs";
2
+ import { a as ok } from "./_output-DBP9Op_d.mjs";
3
+ import { n as log } from "./_ui-DCt4qZrk.mjs";
4
+ import { l as writeProjectConfig } from "./_config-DYzC6WMD.mjs";
5
+ import { i as requireDeployedSlug, o as resolveDeployTarget } from "./_agent-BzUeqOdj.mjs";
6
+ import { d as apiTestSeam, l as HINT_NOT_DEPLOYED, s as studioProjectApiUrl, u as apiRequest } from "./_studio-DnR_BqFp.mjs";
7
7
  import { omitUndefined } from "@alexkroman1/aai/utils";
8
- //#region delete.ts
8
+ //#region src/delete.ts
9
9
  async function runDelete(opts) {
10
10
  await apiRequest(`${opts.url}/${opts.slug}`, {
11
11
  method: "DELETE",
@@ -1,17 +1,17 @@
1
1
  #!/usr/bin/env node
2
- import { a as ok } from "./_output-CKkmWs7i.mjs";
3
- import { n as log, r as notify, t as fmtUrl } from "./_ui-u7T4YooX.mjs";
4
- import { o as errorMessage$1 } from "./_utils-B8QmtFhK.mjs";
5
- import { s as updateProjectConfig } from "./_config-CmJOFsAP.mjs";
6
- import { i as evalWorkerConfig, t as buildAgentBundle } from "./_bundler-C31rlcYz.mjs";
7
- import { t as resolveServerEnv } from "./_server-common-6e0QI4mq.mjs";
8
- import { a as resolveDeployTarget } from "./_agent-BTwZJu4P.mjs";
9
- import { assertTypechecks } from "./_typecheck-gate-BXvUNnfs.mjs";
10
- import { n as scanWorkflowDeterminism, t as determinismWarnings } from "./_workflow-determinism-f9J-5Zlj.mjs";
11
- import { d as apiTestSeam, f as checkedResponse, i as projectNameFromDir, u as apiRequest } from "./_studio-B1waXMuR.mjs";
2
+ import { a as ok } from "./_output-DBP9Op_d.mjs";
3
+ import { n as log, r as notify, t as fmtUrl } from "./_ui-DCt4qZrk.mjs";
4
+ import { s as errorMessage$1 } from "./_utils-D5JGcjiW.mjs";
5
+ import { s as updateProjectConfig } from "./_config-DYzC6WMD.mjs";
6
+ import { i as evalWorkerConfig, t as buildAgentBundle } from "./_bundler-DolUCMxu.mjs";
7
+ import { t as resolveServerEnv } from "./_server-common-vILJp3it.mjs";
8
+ import { o as resolveDeployTarget } from "./_agent-BzUeqOdj.mjs";
9
+ import { assertTypechecks } from "./_typecheck-gate-U3jcil8L.mjs";
10
+ import { n as scanWorkflowDeterminism, t as determinismWarnings } from "./_workflow-determinism-CvpqMpdh.mjs";
11
+ import { d as apiTestSeam, f as checkedResponse, i as projectNameFromDir, u as apiRequest } from "./_studio-DnR_BqFp.mjs";
12
12
  import { isRecord, omitUndefined } from "@alexkroman1/aai/utils";
13
13
  import { gzipSync } from "node:zlib";
14
- //#region _deploy.ts
14
+ //#region src/_deploy.ts
15
15
  async function runDeploy(opts) {
16
16
  const body = gzipSync(JSON.stringify({
17
17
  ...omitUndefined({ slug: opts.slug }),
@@ -36,12 +36,12 @@ async function runDeploy(opts) {
36
36
  return checkedResponse(data, (value) => isRecord(value) && typeof value.slug === "string", `the deploy route at ${opts.url}`);
37
37
  }
38
38
  //#endregion
39
- //#region deploy.ts
39
+ //#region src/deploy.ts
40
40
  async function executeDeploy(opts) {
41
41
  const { cwd } = opts;
42
42
  const { config: projectConfig, serverUrl, apiKey } = await resolveDeployTarget(cwd, opts.server);
43
- if (!opts.skipTypecheck) await assertTypechecks(cwd);
44
- const preflightModule = import("./_preflight-Co1G9Jww.mjs");
43
+ await assertTypechecks(cwd, { skip: opts.skipTypecheck });
44
+ const preflightModule = import("./_preflight-CcAR577V.mjs");
45
45
  const bundle = await buildAgentBundle(cwd, { minify: true });
46
46
  const slug = projectConfig?.slug ?? projectNameFromDir(cwd) ?? void 0;
47
47
  const uploadEnv = {