@alexkroman1/aai-cli 5.1.1 → 5.2.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 (99) hide show
  1. package/dist/_agent.d.ts +39 -0
  2. package/dist/_api-client.d.ts +37 -0
  3. package/dist/_bundler.d.ts +46 -0
  4. package/dist/_config.d.ts +57 -0
  5. package/dist/_default-html.d.ts +12 -0
  6. package/dist/_deploy.d.ts +28 -0
  7. package/dist/_dev-server.d.ts +74 -0
  8. package/dist/{_init-B-LEVTHx.mjs → _init-DU-sXH6S.mjs} +44 -65
  9. package/dist/_init.d.ts +7 -0
  10. package/dist/_mock-api.d.ts +22 -0
  11. package/dist/_mock-registry.d.ts +17 -0
  12. package/dist/_output.d.ts +50 -0
  13. package/dist/_server-common.d.ts +17 -0
  14. package/dist/_slug-api.d.ts +15 -0
  15. package/dist/_templates.d.ts +21 -0
  16. package/dist/_typecheck-gate.d.ts +7 -0
  17. package/dist/_ui.d.ts +22 -0
  18. package/dist/_utils.d.ts +48 -0
  19. package/dist/_vite-env.d.ts +8 -0
  20. package/dist/build.d.ts +16 -0
  21. package/dist/cli.d.ts +1 -0
  22. package/dist/cli.mjs +1 -1
  23. package/dist/client-bundler.d.ts +21 -0
  24. package/dist/delete.d.ts +18 -0
  25. package/dist/deploy.d.ts +15 -0
  26. package/dist/dev.d.ts +13 -0
  27. package/dist/{init-tc3Rbgrf.mjs → init-BjeK8crW.mjs} +1 -1
  28. package/dist/init.d.ts +24 -0
  29. package/dist/scaffold/.env.example +11 -0
  30. package/dist/scaffold/CLAUDE.md +919 -0
  31. package/dist/scaffold/global.d.ts +1 -0
  32. package/dist/scaffold/package.json +32 -0
  33. package/dist/scaffold/pnpm-workspace.yaml +13 -0
  34. package/dist/scaffold/tsconfig.json +19 -0
  35. package/dist/scaffold/vite.config.ts +14 -0
  36. package/dist/scaffold/vitest.config.ts +24 -0
  37. package/dist/secret.d.ts +25 -0
  38. package/dist/storage.d.ts +22 -0
  39. package/dist/templates/code-interpreter/agent.ts +11 -0
  40. package/dist/templates/code-interpreter/system-prompt.md +18 -0
  41. package/dist/templates/dispatch-center/agent.test.ts +153 -0
  42. package/dist/templates/dispatch-center/agent.ts +50 -0
  43. package/dist/templates/dispatch-center/client.tsx +378 -0
  44. package/dist/templates/dispatch-center/shared.ts +631 -0
  45. package/dist/templates/dispatch-center/system-prompt.md +39 -0
  46. package/dist/templates/dispatch-center/tools/incident_add_note.ts +27 -0
  47. package/dist/templates/dispatch-center/tools/incident_create.ts +79 -0
  48. package/dist/templates/dispatch-center/tools/incident_escalate.ts +88 -0
  49. package/dist/templates/dispatch-center/tools/incident_get.ts +36 -0
  50. package/dist/templates/dispatch-center/tools/incident_triage.ts +78 -0
  51. package/dist/templates/dispatch-center/tools/incident_update_status.ts +68 -0
  52. package/dist/templates/dispatch-center/tools/ops_dashboard.ts +52 -0
  53. package/dist/templates/dispatch-center/tools/ops_protocols.ts +27 -0
  54. package/dist/templates/dispatch-center/tools/ops_run_scenario.ts +149 -0
  55. package/dist/templates/dispatch-center/tools/resources_dispatch.ts +97 -0
  56. package/dist/templates/dispatch-center/tools/resources_get_available.ts +36 -0
  57. package/dist/templates/dispatch-center/tools/resources_update_status.ts +62 -0
  58. package/dist/templates/embedded-assets/agent.ts +55 -0
  59. package/dist/templates/embedded-assets/knowledge.json +20 -0
  60. package/dist/templates/health-assistant/agent.ts +174 -0
  61. package/dist/templates/health-assistant/system-prompt.md +17 -0
  62. package/dist/templates/infocom-adventure/agent.ts +119 -0
  63. package/dist/templates/infocom-adventure/client.tsx +279 -0
  64. package/dist/templates/infocom-adventure/shared.ts +38 -0
  65. package/dist/templates/infocom-adventure/system-prompt.md +43 -0
  66. package/dist/templates/math-buddy/agent.ts +16 -0
  67. package/dist/templates/math-buddy/system-prompt.md +12 -0
  68. package/dist/templates/night-owl/agent.ts +76 -0
  69. package/dist/templates/night-owl/client.tsx +130 -0
  70. package/dist/templates/night-owl/shared.ts +5 -0
  71. package/dist/templates/personal-finance/agent.ts +11 -0
  72. package/dist/templates/personal-finance/system-prompt.md +17 -0
  73. package/dist/templates/pipeline-simple/agent.test.ts +32 -0
  74. package/dist/templates/pipeline-simple/agent.ts +13 -0
  75. package/dist/templates/pizza-ordering/agent.test.ts +235 -0
  76. package/dist/templates/pizza-ordering/agent.ts +174 -0
  77. package/dist/templates/pizza-ordering/client.tsx +120 -0
  78. package/dist/templates/pizza-ordering/shared.ts +142 -0
  79. package/dist/templates/pizza-ordering/system-prompt.md +17 -0
  80. package/dist/templates/simple/agent.ts +5 -0
  81. package/dist/templates/solo-rpg/agent.test.ts +477 -0
  82. package/dist/templates/solo-rpg/agent.ts +37 -0
  83. package/dist/templates/solo-rpg/client.tsx +809 -0
  84. package/dist/templates/solo-rpg/shared.ts +747 -0
  85. package/dist/templates/solo-rpg/system-prompt.md +115 -0
  86. package/dist/templates/solo-rpg/tools/action_roll.ts +98 -0
  87. package/dist/templates/solo-rpg/tools/burn_momentum.ts +69 -0
  88. package/dist/templates/solo-rpg/tools/check_state.ts +11 -0
  89. package/dist/templates/solo-rpg/tools/load_game.ts +25 -0
  90. package/dist/templates/solo-rpg/tools/oracle.ts +248 -0
  91. package/dist/templates/solo-rpg/tools/save_game.ts +20 -0
  92. package/dist/templates/solo-rpg/tools/setup_character.ts +208 -0
  93. package/dist/templates/solo-rpg/tools/update_state.ts +170 -0
  94. package/dist/templates/web-researcher/agent.ts +11 -0
  95. package/dist/test.d.ts +39 -0
  96. package/dist/tsdown.config.d.ts +2 -0
  97. package/dist/typecheck.d.ts +26 -0
  98. package/dist/worker-bundler.d.ts +29 -0
  99. package/package.json +9 -6
@@ -0,0 +1,48 @@
1
+ export { errorDetail, errorMessage } from "@alexkroman1/aai/utils";
2
+ /**
3
+ * The file that marks a directory as an agent project — the single source
4
+ * for the entry filename every command checks or scaffolds.
5
+ */
6
+ export declare const AGENT_ENTRY = "agent.ts";
7
+ /** Resolve the working directory from INIT_CWD or process.cwd(). */
8
+ export declare function resolveCwd(): string;
9
+ /** The `code` of a Node errno-style error (`"ENOENT"`, `"EPIPE"`, …), or undefined. */
10
+ export declare function errorCode(err: unknown): string | undefined;
11
+ /** True when `err` is a filesystem EEXIST error (target already exists). */
12
+ export declare function isEexist(err: unknown): boolean;
13
+ /** Validate that a module's default export is a valid agent definition. Throws if invalid. */
14
+ export declare function validateAgentExport(mod: any): void;
15
+ /**
16
+ * Absolute path of `binName`'s script declared by the package.json at
17
+ * `pkgJsonPath`, or undefined when the package declares no such bin.
18
+ * Handles both `"bin": "script.js"` and `"bin": { name: "script.js" }`.
19
+ */
20
+ export declare function binFromPackageJson(pkgJsonPath: string, binName: string): string | undefined;
21
+ export declare function fileExists(p: string): Promise<boolean>;
22
+ /**
23
+ * Read and parse a JSON file. Returns null only when the file does not exist
24
+ * (ENOENT — the "optional file" case). A file that exists but cannot be read
25
+ * (EACCES, …) or parsed throws instead: treating a corrupted file as absent
26
+ * hides real problems — e.g. a corrupted `.aai/project.json` would silently
27
+ * deploy under a NEW slug, orphaning the live deployment.
28
+ */
29
+ export declare function readJson(filePath: string): Promise<unknown>;
30
+ /**
31
+ * Write `data` as pretty-printed JSON (+ trailing newline), creating parent dirs.
32
+ *
33
+ * Writes to a temp file in the same directory, then renames it into place.
34
+ * A plain `writeFile` can be observed (or left, on crash) half-written; a
35
+ * torn config.json fails `JSON.parse`, reads back as `{}`, and the next
36
+ * read-modify-write silently wipes fields like `approvedServers`. Rename on
37
+ * the same filesystem is atomic, so readers only ever see a complete file.
38
+ * Two concurrent CLI processes can still lose each other's *updates*
39
+ * (last rename wins) — acceptable for these small user-config files.
40
+ *
41
+ * `mode` restricts the file's permissions (the rename carries the temp
42
+ * file's mode to the destination, so an existing world-readable file is
43
+ * tightened on the next write). The parent directory is created 0o700 in
44
+ * that case so a fresh config dir never goes through a readable window.
45
+ */
46
+ export declare function writeJson(filePath: string, data: unknown, opts?: {
47
+ mode?: number;
48
+ }): Promise<void>;
@@ -0,0 +1,8 @@
1
+ /**
2
+ * `env` is injectable for tests ONLY, so specs can exercise the
3
+ * snapshot/refcount logic on a plain object instead of mutating (and
4
+ * repeatedly deleting) the real `process.env.NODE_ENV` mid-suite.
5
+ */
6
+ export declare function withPreservedNodeEnv<T>(fn: () => Promise<T>, env?: {
7
+ NODE_ENV?: string;
8
+ }): Promise<T>;
@@ -0,0 +1,16 @@
1
+ /**
2
+ * `aai build` — bundle the agent without deploying, behind the same gates
3
+ * deploy runs (tests, then typecheck), so the command previews the deploy
4
+ * artifact and its failures alike.
5
+ */
6
+ import { type CommandResult } from "./_output.ts";
7
+ type BuildData = {
8
+ name: string;
9
+ workerBytes: number;
10
+ };
11
+ export declare function executeBuild(opts: {
12
+ cwd: string;
13
+ skipTests?: boolean | undefined;
14
+ skipTypecheck?: boolean | undefined;
15
+ }): Promise<CommandResult<BuildData>>;
16
+ export {};
package/dist/cli.d.ts ADDED
@@ -0,0 +1 @@
1
+ export declare const mainCommand: import("citty").CommandDef<import("citty").ArgsDef>;
package/dist/cli.mjs CHANGED
@@ -105,7 +105,7 @@ const init = defineCommand({
105
105
  },
106
106
  async run({ args }) {
107
107
  await runCommand(args, async (mode) => {
108
- const { executeInit } = await import("./init-tc3Rbgrf.mjs");
108
+ const { executeInit } = await import("./init-BjeK8crW.mjs");
109
109
  return executeInit({
110
110
  dir: args.dir,
111
111
  force: args.force,
@@ -0,0 +1,21 @@
1
+ import { type PluginOption } from "vite";
2
+ export type BuildClientOptions = {
3
+ /**
4
+ * Plugins to inject instead of relying on the project's `vite.config.ts`
5
+ * (React + Tailwind for the studio, whose workspace has neither).
6
+ */
7
+ plugins?: PluginOption[];
8
+ /**
9
+ * `false` ignores any `vite.config.ts` under `cwd`. The studio passes this:
10
+ * a Vite config is executable code, and workspace files are untrusted.
11
+ */
12
+ configFile?: false;
13
+ /** Build output directory, relative to `cwd`. */
14
+ outDir?: string;
15
+ };
16
+ /**
17
+ * Build the client SPA with Vite if `client.tsx` exists.
18
+ * Returns a map of relative file paths to string contents for deploy,
19
+ * or `{}` when the project has no `client.tsx`.
20
+ */
21
+ export declare function buildClient(cwd: string, opts?: BuildClientOptions): Promise<Record<string, string>>;
@@ -0,0 +1,18 @@
1
+ import { type CommandResult } from "./_output.ts";
2
+ export type DeleteOpts = {
3
+ url: string;
4
+ slug: string;
5
+ apiKey: string;
6
+ /** Optional fetch implementation for testing. Defaults to globalThis.fetch. */
7
+ fetch?: typeof globalThis.fetch;
8
+ };
9
+ export declare function runDelete(opts: DeleteOpts): Promise<void>;
10
+ type DeleteData = {
11
+ slug: string;
12
+ };
13
+ /** Execute delete and return structured result. */
14
+ export declare function executeDelete(opts: {
15
+ cwd: string;
16
+ server?: string | undefined;
17
+ }): Promise<CommandResult<DeleteData>>;
18
+ export {};
@@ -0,0 +1,15 @@
1
+ import { type CommandResult } from "./_output.ts";
2
+ type DeployData = {
3
+ slug: string;
4
+ url: string;
5
+ warnings?: string[];
6
+ };
7
+ export declare function executeDeploy(opts: {
8
+ cwd: string;
9
+ server?: string | undefined;
10
+ /** See DeployOpts.allowMissingSecrets (`--allow-missing-secrets`). */
11
+ allowMissingSecrets?: boolean | undefined;
12
+ /** `--skipTypecheck`: deploy without the tsc gate. */
13
+ skipTypecheck?: boolean | undefined;
14
+ }): Promise<CommandResult<DeployData>>;
15
+ export {};
package/dist/dev.d.ts ADDED
@@ -0,0 +1,13 @@
1
+ import { type CommandResult } from "./_output.ts";
2
+ type DevData = {
3
+ url: string;
4
+ };
5
+ /**
6
+ * Start the dev server and return the result.
7
+ * The process stays alive after this returns — caller handles signals.
8
+ */
9
+ export declare function executeDev(opts: {
10
+ cwd: string;
11
+ port: string;
12
+ }): Promise<CommandResult<DevData>>;
13
+ export {};
@@ -92,7 +92,7 @@ async function tryDeploy(cwd, server) {
92
92
  }
93
93
  /** Scaffold the project, optionally showing a spinner. */
94
94
  async function scaffoldProject(dir, cwd, template, silent) {
95
- const { runInit } = await import("./_init-B-LEVTHx.mjs");
95
+ const { runInit } = await import("./_init-DU-sXH6S.mjs");
96
96
  const s = silent ? void 0 : p.spinner();
97
97
  s?.start(`Creating ${dir}`);
98
98
  await runInit({
package/dist/init.d.ts ADDED
@@ -0,0 +1,24 @@
1
+ import { type CommandResult } from "./_output.ts";
2
+ type InitData = {
3
+ dir: string;
4
+ template: string;
5
+ deployed: boolean;
6
+ slug?: string;
7
+ url?: string;
8
+ };
9
+ /** Build the command + args for running pnpm, routing through safe-chain when available. */
10
+ export declare function resolvePnpmCommand(checkSafeChain?: () => Promise<boolean>): Promise<{
11
+ cmd: string;
12
+ args: string[];
13
+ }>;
14
+ export declare function executeInit(opts: {
15
+ dir?: string | undefined;
16
+ force?: boolean | undefined;
17
+ template?: string | undefined;
18
+ yes?: boolean | undefined;
19
+ skipDeploy?: boolean | undefined;
20
+ server?: string | undefined;
21
+ }, extra?: {
22
+ silent?: boolean | undefined;
23
+ }): Promise<CommandResult<InitData>>;
24
+ export {};
@@ -0,0 +1,11 @@
1
+ # Secrets for local development — loaded automatically by `aai dev`.
2
+ # Only variables listed here are available via ctx.env (not all of process.env).
3
+ #
4
+ # For production, use `aai secret put <NAME>` to set the same keys on the server.
5
+ # In both cases, access secrets in agent code via ctx.env.MY_KEY.
6
+ #
7
+ # Add any secrets your agent needs below:
8
+
9
+ # Required only if your agent enables the `web_search` builtin
10
+ # (free key: https://brave.com/search/api/):
11
+ # BRAVE_API_KEY=