@alexkroman1/aai-cli 13.1.0 → 13.3.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.
- package/bin.mjs +1 -1
- package/dist/{_agent-BTwZJu4P.mjs → _agent-Clbq3a4h.mjs} +2 -2
- package/dist/{_bundler-C31rlcYz.mjs → _bundler-DEkjO1d8.mjs} +3 -3
- package/dist/{_config-CmJOFsAP.mjs → _config-ZY2euhdh.mjs} +7 -4
- package/dist/_config.d.ts +25 -1
- package/dist/{_dev-server-DWvkNoIS.mjs → _dev-server-C13xuGB1.mjs} +13 -13
- package/dist/_e2e-test-utils.d.ts +15 -7
- package/dist/{_init-BURbdHNM.mjs → _init-Ci4QGjp8.mjs} +58 -10
- package/dist/{_output-CKkmWs7i.mjs → _output-DbJt9gsl.mjs} +34 -3
- package/dist/_output.d.ts +17 -1
- package/dist/{_preflight-Co1G9Jww.mjs → _preflight-B2laWPdU.mjs} +1 -1
- package/dist/{_server-common-6e0QI4mq.mjs → _server-common-BV4_CrP3.mjs} +3 -3
- package/dist/{_slug-api-CfGQq1Tt.mjs → _slug-api-DlKpj91X.mjs} +3 -3
- package/dist/{_studio-B1waXMuR.mjs → _studio-DTi3EdXQ.mjs} +3 -3
- package/dist/{_templates-0Zr2z6yA.mjs → _templates-V4l5sZJy.mjs} +2 -2
- package/dist/{_typecheck-gate-BXvUNnfs.mjs → _typecheck-gate-sV4N5F93.mjs} +3 -3
- package/dist/{_ui-u7T4YooX.mjs → _ui-DCt4qZrk.mjs} +1 -1
- package/dist/{_utils-B8QmtFhK.mjs → _utils-Dhd058D9.mjs} +1 -1
- package/dist/{_vite-env-D9Qj6KPX.mjs → _vite-env-kejF0p2L.mjs} +1 -1
- package/dist/{_workflow-determinism-f9J-5Zlj.mjs → _workflow-determinism-C9l8uC2R.mjs} +1 -1
- package/dist/{build-BLlLOrng.mjs → build-CWyFGe-W.mjs} +11 -8
- package/dist/cli.d.ts +2 -1
- package/dist/cli.mjs +120 -46
- package/dist/{client-bundler-j5c46x0G.mjs → client-bundler-CT-_26c5.mjs} +4 -4
- package/dist/client-bundler.mjs +1 -1
- package/dist/{delete-X_CRgCf6.mjs → delete-RqlQZ6Y_.mjs} +6 -6
- package/dist/{deploy-BzZ-r4iM.mjs → deploy-B7f3CK7v.mjs} +13 -13
- package/dist/{dev-BDykFvcc.mjs → dev-DamXieW_.mjs} +5 -5
- package/dist/{eval-0qEOdm0l.mjs → eval-h3DTVfRw.mjs} +27 -11
- package/dist/eval.d.ts +2 -0
- package/dist/{init-BtJI306C.mjs → init-D-vFrV8h.mjs} +7 -7
- package/dist/{login-DeUETobb.mjs → login-CDiemNmC.mjs} +5 -5
- package/dist/{logs-hWnJ66Bl.mjs → logs-DGwPNCzB.mjs} +4 -4
- package/dist/project-config.mjs +1 -1
- package/dist/scaffold/.env.example +17 -1
- package/dist/scaffold/package.json +6 -5
- package/dist/secret-V1w7y9-j.mjs +162 -0
- package/dist/secret.d.ts +41 -8
- package/dist/{studio-BxAS_FQQ.mjs → studio-BpMCfUNx.mjs} +9 -9
- package/dist/templates/briefing-desk/agent.test.ts +7 -3
- package/dist/templates/call-audit/agent.eval.test.ts +14 -11
- package/dist/templates/call-audit/agent.test.ts +34 -7
- package/dist/templates/call-audit/client.tsx +14 -17
- package/dist/templates/call-audit/workflows/ingest.ts +10 -1
- package/dist/templates/code-interpreter/agent.eval.test.ts +27 -17
- package/dist/templates/dispatch-center/agent.eval.test.ts +18 -24
- package/dist/templates/embedded-assets/agent.eval.test.ts +3 -3
- package/dist/templates/embedded-assets/agent.test.ts +7 -1
- package/dist/templates/health-assistant/agent.eval.test.ts +38 -15
- package/dist/templates/health-assistant/agent.test.ts +8 -4
- package/dist/templates/link-digest/agent.eval.test.ts +24 -15
- package/dist/templates/link-digest/agent.test.ts +7 -1
- package/dist/templates/link-digest/client.tsx +17 -21
- package/dist/templates/math-buddy/agent.eval.test.ts +28 -17
- package/dist/templates/night-owl/agent.eval.test.ts +30 -15
- package/dist/templates/night-owl/agent.test.ts +6 -1
- package/dist/templates/personal-finance/agent.eval.test.ts +27 -17
- package/dist/templates/pipeline-simple/agent.test.ts +31 -14
- package/dist/templates/pizza-ordering/agent.eval.test.ts +11 -6
- package/dist/templates/plan-and-execute/agent.eval.test.ts +14 -7
- package/dist/templates/podcast-digest/agent.test.ts +13 -3
- package/dist/templates/podcast-digest/client.tsx +12 -15
- package/dist/templates/recap-workflow/agent.eval.test.ts +49 -20
- package/dist/templates/recap-workflow/agent.test.ts +22 -9
- package/dist/templates/redline/agent.eval.test.ts +32 -24
- package/dist/templates/redline/agent.test.ts +7 -1
- package/dist/templates/redline/client.tsx +12 -15
- package/dist/templates/research-workflow/agent.eval.test.ts +32 -22
- package/dist/templates/research-workflow/agent.test.ts +7 -1
- package/dist/templates/retail/agent.eval.test.ts +18 -34
- package/dist/templates/retail/registry.test.ts +99 -58
- package/dist/templates/simple/agent.test.ts +39 -6
- package/dist/templates/spoken-summary/agent.eval.test.ts +25 -16
- package/dist/templates/spoken-summary/agent.test.ts +21 -7
- package/dist/templates/spoken-summary/client.tsx +14 -18
- package/dist/templates/support-line/agent.eval.test.ts +23 -26
- package/dist/templates/transcription-workflow/agent.test.ts +26 -8
- package/dist/templates/transcription-workflow/client.tsx +19 -26
- package/dist/templates/transcription-workflow/workflows/normalize.ts +10 -1
- package/dist/templates/transcription-workflow/workflows/sync-api.ts +5 -2
- package/dist/templates/transcription-workflow/workflows/transcribe.ts +11 -4
- package/dist/templates/travel-concierge/agent.eval.test.ts +37 -56
- package/dist/test-guenJUxi.mjs +255 -0
- package/dist/test.d.ts +97 -31
- package/dist/typecheck.mjs +2 -2
- package/dist/worker-bundler.mjs +3 -3
- package/dist/{workflow-BBu5oEDw.mjs → workflow-BZyKLkhV.mjs} +5 -5
- package/package.json +10 -10
- package/dist/bin.d.mts +0 -2
- package/dist/secret-B-3T5tvr.mjs +0 -61
- package/dist/test-CiLab-AA.mjs +0 -182
- package/dist/tsdown.config.d.ts +0 -2
package/dist/test-CiLab-AA.mjs
DELETED
|
@@ -1,182 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
import { a as ok, n as fail } from "./_output-CKkmWs7i.mjs";
|
|
3
|
-
import { n as log, r as notify } from "./_ui-u7T4YooX.mjs";
|
|
4
|
-
import { i as errorCode, o as errorMessage$1, r as binFromPackageJson } from "./_utils-B8QmtFhK.mjs";
|
|
5
|
-
import { createRequire } from "node:module";
|
|
6
|
-
import { existsSync, readdirSync } from "node:fs";
|
|
7
|
-
import path from "node:path";
|
|
8
|
-
import { omitUndefined } from "@alexkroman1/aai/utils";
|
|
9
|
-
import { execaSync } from "execa";
|
|
10
|
-
//#region test.ts
|
|
11
|
-
/**
|
|
12
|
-
* `aai test` — run agent tests via vitest.
|
|
13
|
-
*/
|
|
14
|
-
/**
|
|
15
|
-
* Resolve the agent project's own vitest binary so tests run without the
|
|
16
|
-
* npx resolution overhead (and its potential network fetch of vitest).
|
|
17
|
-
*
|
|
18
|
-
* Resolves `vitest/package.json` from the agent directory, derives the bin
|
|
19
|
-
* script, and runs it with the current Node executable. Falls back to
|
|
20
|
-
* `npx vitest` only when no local install is resolvable.
|
|
21
|
-
*/
|
|
22
|
-
function resolveVitestCommand(cwd, resolve = createRequire(path.join(cwd, "package.json")).resolve) {
|
|
23
|
-
try {
|
|
24
|
-
const bin = binFromPackageJson(resolve("vitest/package.json"), "vitest");
|
|
25
|
-
if (bin) return {
|
|
26
|
-
cmd: process.execPath,
|
|
27
|
-
args: [bin]
|
|
28
|
-
};
|
|
29
|
-
} catch {}
|
|
30
|
-
return {
|
|
31
|
-
cmd: "npx",
|
|
32
|
-
args: ["vitest"]
|
|
33
|
-
};
|
|
34
|
-
}
|
|
35
|
-
/** The files `aai test` runs, in preference order. */
|
|
36
|
-
const TEST_FILES = ["agent.test.ts", "agent.test.js"];
|
|
37
|
-
/**
|
|
38
|
-
* Run vitest over one of `candidates` in the given project directory.
|
|
39
|
-
*
|
|
40
|
-
* Returns the FILE it ran, or `false` if none of the candidate files exists.
|
|
41
|
-
* Throws on failure.
|
|
42
|
-
*
|
|
43
|
-
* A vitest FILTER, not an include glob: the argument is matched as a substring
|
|
44
|
-
* against the paths vitest's own include globs already found, which is why the
|
|
45
|
-
* candidates are named `*.test.ts` — `agent.test.ts` cannot match
|
|
46
|
-
* `agent.eval.test.ts` and vice versa, so the two commands stay disjoint
|
|
47
|
-
* without either one having to exclude the other's file.
|
|
48
|
-
*/
|
|
49
|
-
function runVitest(cwd, opts = { candidates: TEST_FILES }) {
|
|
50
|
-
const testFile = opts.candidates.find((name) => existsSync(path.join(cwd, name)));
|
|
51
|
-
if (!testFile) return false;
|
|
52
|
-
const { cmd, args } = resolveVitestCommand(cwd);
|
|
53
|
-
execaSync(cmd, [
|
|
54
|
-
...args,
|
|
55
|
-
"run",
|
|
56
|
-
"--root",
|
|
57
|
-
".",
|
|
58
|
-
...opts.extraArgs ?? [],
|
|
59
|
-
testFile
|
|
60
|
-
], {
|
|
61
|
-
cwd,
|
|
62
|
-
stdio: "inherit",
|
|
63
|
-
...omitUndefined({ env: opts.env ? {
|
|
64
|
-
...process.env,
|
|
65
|
-
...opts.env
|
|
66
|
-
} : void 0 })
|
|
67
|
-
});
|
|
68
|
-
return testFile;
|
|
69
|
-
}
|
|
70
|
-
/**
|
|
71
|
-
* Classify a {@link runVitest} failure. execaSync throws an ENOENT-coded
|
|
72
|
-
* error when the binary itself couldn't be spawned (infrastructure problem)
|
|
73
|
-
* and an exit-code error when vitest ran and the tests failed.
|
|
74
|
-
*/
|
|
75
|
-
function classifyVitestError(err, label = "Tests") {
|
|
76
|
-
if (errorCode(err) === "ENOENT") return {
|
|
77
|
-
code: "spawn_failed",
|
|
78
|
-
message: `Could not launch the test runner: ${errorMessage$1(err)} — is the binary on your PATH?`
|
|
79
|
-
};
|
|
80
|
-
return {
|
|
81
|
-
code: "test_failed",
|
|
82
|
-
message: `${label} failed: ${errorMessage$1(err)}`
|
|
83
|
-
};
|
|
84
|
-
}
|
|
85
|
-
/** Directories a project's own specs never live in. */
|
|
86
|
-
const UNSCANNED_DIRS = /* @__PURE__ */ new Set([
|
|
87
|
-
"node_modules",
|
|
88
|
-
".aai",
|
|
89
|
-
".git",
|
|
90
|
-
"dist",
|
|
91
|
-
".workflow-data"
|
|
92
|
-
]);
|
|
93
|
-
/** What counts as a spec file. */
|
|
94
|
-
const SPEC_FILE_RE = /\.test\.(ts|js|tsx|mts|cts)$/;
|
|
95
|
-
/**
|
|
96
|
-
* Spec files in the project that `aai test` did NOT run.
|
|
97
|
-
*
|
|
98
|
-
* `runVitest` passes ONE filename as a vitest FILTER, which is what keeps `test`
|
|
99
|
-
* and `eval` disjoint without either excluding the other's file — see its doc.
|
|
100
|
-
* The cost is that every other `*.test.ts` in the project is skipped, and the
|
|
101
|
-
* skip was SILENT: the shipped `retail` template carries seven of them, so
|
|
102
|
-
* `aai test` there ran 1 file / 67 tests, printed "Tests passed", and left
|
|
103
|
-
* 211 of the project's 278 tests unrun with nothing saying so.
|
|
104
|
-
*
|
|
105
|
-
* A silent skip is the worst outcome available, so the skip is announced rather
|
|
106
|
-
* than the filter widened: which files `aai test` runs is a documented contract
|
|
107
|
-
* (the scaffold guide says "Run agent.test.ts via vitest"), and running a
|
|
108
|
-
* project's other specs by default could reach ones that are slow or want
|
|
109
|
-
* credentials. Naming them costs nothing and is what a reader needs.
|
|
110
|
-
*
|
|
111
|
-
* Eval files are excluded because they have their OWN command, named in the
|
|
112
|
-
* message.
|
|
113
|
-
*/
|
|
114
|
-
function unrunSpecFiles(cwd, ran) {
|
|
115
|
-
const found = [];
|
|
116
|
-
collectSpecs(cwd, "", ran, found);
|
|
117
|
-
return found.sort(compareCodeUnits);
|
|
118
|
-
}
|
|
119
|
-
/** Code-unit comparison — see {@link unrunSpecFiles} for why not `localeCompare`. */
|
|
120
|
-
function compareCodeUnits(a, b) {
|
|
121
|
-
if (a < b) return -1;
|
|
122
|
-
return a > b ? 1 : 0;
|
|
123
|
-
}
|
|
124
|
-
/** One directory of {@link unrunSpecFiles}, recursing into the ones that count. */
|
|
125
|
-
function collectSpecs(dir, prefix, ran, out) {
|
|
126
|
-
let entries;
|
|
127
|
-
try {
|
|
128
|
-
entries = readdirSync(dir, { withFileTypes: true });
|
|
129
|
-
} catch {
|
|
130
|
-
return;
|
|
131
|
-
}
|
|
132
|
-
for (const e of entries) {
|
|
133
|
-
const rel = prefix ? `${prefix}/${e.name}` : e.name;
|
|
134
|
-
if (e.isDirectory()) {
|
|
135
|
-
if (!(UNSCANNED_DIRS.has(e.name) || e.name.startsWith("."))) collectSpecs(path.join(dir, e.name), rel, ran, out);
|
|
136
|
-
} else if (isUnrunSpec(e.name, rel, ran)) out.push(rel);
|
|
137
|
-
}
|
|
138
|
-
}
|
|
139
|
-
/** A spec file this run did not cover. The `.eval.` INFIX is the tier convention. */
|
|
140
|
-
function isUnrunSpec(name, rel, ran) {
|
|
141
|
-
if (!SPEC_FILE_RE.test(name)) return false;
|
|
142
|
-
return rel !== ran && !name.includes(".eval.test.");
|
|
143
|
-
}
|
|
144
|
-
/**
|
|
145
|
-
* Warn, once, naming the spec files this run did not cover.
|
|
146
|
-
*
|
|
147
|
-
* `ran` is `false` when there was no `agent.test.ts` to run, and that case
|
|
148
|
-
* needs the warning MORE rather than less: `aai test` then prints "No test file
|
|
149
|
-
* found" while the project's spec files sit right there unrun, which reads as
|
|
150
|
-
* "this project has no tests". Measured on a project whose only spec was
|
|
151
|
-
* `tools/echo_back.test.ts` — `{"passed":true,"skipped":true}` and not a word
|
|
152
|
-
* about it. It stays silent when there is nothing to name, in both arms.
|
|
153
|
-
*/
|
|
154
|
-
function warnUnrunSpecs(cwd, ran) {
|
|
155
|
-
const skipped = unrunSpecFiles(cwd, ran === false ? "" : ran);
|
|
156
|
-
if (skipped.length === 0) return;
|
|
157
|
-
const preamble = ran === false ? `\`aai test\` found no agent.test.ts, so it ran nothing. ${skipped.length} spec file(s) exist and were NOT run:` : `\`aai test\` ran ${ran} only. ${skipped.length} other spec file(s) were NOT run:`;
|
|
158
|
-
notify("warn", `${preamble} ${skipped.join(", ")}. Run them with your own vitest (\`npx vitest run\`); behaviour evals have their own command (\`aai eval\`).`);
|
|
159
|
-
}
|
|
160
|
-
/** Execute agent tests and return structured result. */
|
|
161
|
-
async function executeTest(cwd) {
|
|
162
|
-
log.step("Running agent tests");
|
|
163
|
-
try {
|
|
164
|
-
const ran = runVitest(cwd);
|
|
165
|
-
if (!ran) {
|
|
166
|
-
log.info("No test file found. Create agent.test.ts to add tests.");
|
|
167
|
-
warnUnrunSpecs(cwd, ran);
|
|
168
|
-
return ok({
|
|
169
|
-
passed: true,
|
|
170
|
-
skipped: true
|
|
171
|
-
});
|
|
172
|
-
}
|
|
173
|
-
log.success("Tests passed");
|
|
174
|
-
warnUnrunSpecs(cwd, ran);
|
|
175
|
-
return ok({ passed: true });
|
|
176
|
-
} catch (err) {
|
|
177
|
-
const { code, message } = classifyVitestError(err);
|
|
178
|
-
return fail(code, message);
|
|
179
|
-
}
|
|
180
|
-
}
|
|
181
|
-
//#endregion
|
|
182
|
-
export { classifyVitestError, executeTest, runVitest };
|
package/dist/tsdown.config.d.ts
DELETED