@alexkroman1/aai-cli 16.1.0 → 18.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.
- package/README.md +2 -1
- package/dist/{_build-target-ClEEuUuW.mjs → _build-target-C08aM-Es.mjs} +504 -43
- package/dist/_build-target.d.ts +98 -19
- package/dist/_console-audio.d.ts +17 -0
- package/dist/_console-session.d.ts +70 -0
- package/dist/_deno-target.d.ts +15 -14
- package/dist/_dev-env.d.ts +19 -13
- package/dist/{_dev-server-D1wKiA0_.mjs → _dev-server-Dtp4aAlo.mjs} +26 -18
- package/dist/_dev-server.d.ts +5 -3
- package/dist/_init.d.ts +39 -0
- package/dist/_modal-target.d.ts +11 -6
- package/dist/_preflight-CnW9QiE7.mjs +116 -0
- package/dist/_preflight.d.ts +110 -5
- package/dist/_target-bundle.d.ts +112 -0
- package/dist/_target-entry.d.ts +81 -0
- package/dist/_templates-DXadVNsL.mjs +135 -0
- package/dist/_templates.d.ts +11 -34
- package/dist/{_vitest-runner-BiAMIir1.mjs → _vitest-runner-CZNGj0ZC.mjs} +21 -16
- package/dist/_vitest-runner.d.ts +35 -23
- package/dist/{build-O6BT51x_.mjs → build-DrQTSc2R.mjs} +128 -293
- package/dist/build.d.ts +34 -4
- package/dist/cli.mjs +40 -16
- package/dist/console-BsyE3DyB.mjs +422 -0
- package/dist/console.d.ts +37 -0
- package/dist/{deploy-lldQyJVj.mjs → deploy-B68-x7xM.mjs} +12 -4
- package/dist/deploy.d.ts +9 -0
- package/dist/{dev-Du8pCWFq.mjs → dev-BGWU2zPP.mjs} +1 -1
- package/dist/dev.d.ts +1 -1
- package/dist/{eval-Ducmkt1n.mjs → eval-DB07kTxO.mjs} +1 -1
- package/dist/init-CbOhyNYe.mjs +559 -0
- package/dist/init.d.ts +43 -3
- package/dist/scaffold/CLAUDE.md +161 -166
- package/dist/scaffold/package.json +6 -6
- package/dist/scaffold/vite.config.ts +29 -1
- package/dist/start.d.ts +3 -3
- package/dist/{studio-It7SRfUN.mjs → studio-BRJsw7lr.mjs} +19 -9
- package/dist/templates/applicant-screening-agent/agent.eval.test.ts +20 -6
- package/dist/templates/applicant-screening-agent/agent.test.ts +17 -13
- package/dist/templates/applicant-screening-agent/agent.ts +28 -0
- package/dist/templates/applicant-screening-agent/crews.ts +4 -4
- package/dist/templates/applicant-screening-agent/shared.ts +11 -11
- package/dist/templates/call-audit-workflow/agent.ts +2 -0
- package/dist/templates/code-interpreter-agent/agent.eval.test.ts +3 -2
- package/dist/templates/code-interpreter-agent/agent.test.ts +2 -2
- package/dist/templates/code-interpreter-agent/agent.ts +1 -0
- package/dist/templates/coding-agent/agent.eval.test.ts +136 -0
- package/dist/templates/coding-agent/agent.test.ts +109 -0
- package/dist/templates/coding-agent/agent.ts +45 -0
- package/dist/templates/coding-agent/chat.ts +63 -0
- package/dist/templates/coding-agent/shared.ts +46 -0
- package/dist/templates/coding-agent/system-prompt.md +32 -0
- package/dist/templates/coding-agent/tools/bash.ts +6 -0
- package/dist/templates/coding-agent/tools/delete_file.ts +6 -0
- package/dist/templates/coding-agent/tools/edit_file.ts +6 -0
- package/dist/templates/coding-agent/tools/glob.ts +6 -0
- package/dist/templates/coding-agent/tools/grep.ts +6 -0
- package/dist/templates/coding-agent/tools/list_files.ts +6 -0
- package/dist/templates/coding-agent/tools/read_file.ts +6 -0
- package/dist/templates/coding-agent/tools/todo_write.ts +6 -0
- package/dist/templates/coding-agent/tools/write_file.ts +6 -0
- package/dist/templates/custom-pipeline-agent/agent.ts +3 -2
- package/dist/templates/custom-pipeline-agent/modes.test.ts +4 -4
- package/dist/templates/custom-pipeline-agent/stages.test.ts +75 -83
- package/dist/templates/document-redline-workflow/agent.ts +2 -0
- package/dist/templates/emergency-dispatch-agent/agent.eval.test.ts +1 -1
- package/dist/templates/emergency-dispatch-agent/agent.test.ts +103 -0
- package/dist/templates/emergency-dispatch-agent/agent.ts +15 -0
- package/dist/templates/emergency-dispatch-agent/guardrails.ts +105 -0
- package/dist/templates/emergency-dispatch-agent/system-prompt.md +1 -0
- package/dist/templates/entertainment-picks-agent/agent.eval.test.ts +9 -2
- package/dist/templates/entertainment-picks-agent/agent.ts +1 -0
- package/dist/templates/entertainment-picks-agent/system-prompt.md +6 -0
- package/dist/templates/entertainment-picks-agent/tools/revisit.ts +7 -0
- package/dist/templates/executive-inbox-agent/agent.eval.test.ts +84 -23
- package/dist/templates/executive-inbox-agent/agent.test.ts +35 -25
- package/dist/templates/executive-inbox-agent/agent.ts +1 -0
- package/dist/templates/executive-inbox-agent/calendar.test.ts +13 -7
- package/dist/templates/executive-inbox-agent/meeting.ts +3 -3
- package/dist/templates/executive-inbox-agent/prompts.ts +3 -1
- package/dist/templates/executive-inbox-agent/system-prompt.md +3 -3
- package/dist/templates/executive-inbox-agent/tools/meeting_assistant.ts +3 -3
- package/dist/templates/executive-inbox-agent/tools/open_email.ts +8 -16
- package/dist/templates/front-desk-agent/agent.eval.test.ts +174 -0
- package/dist/templates/front-desk-agent/agent.test.ts +150 -0
- package/dist/templates/front-desk-agent/agent.ts +22 -0
- package/dist/templates/front-desk-agent/shared.ts +234 -0
- package/dist/templates/front-desk-agent/system-prompt.md +13 -0
- package/dist/templates/front-desk-agent/tools/verify_account.ts +41 -0
- package/dist/templates/hotel-reception-agent/agent.eval.test.ts +85 -21
- package/dist/templates/hotel-reception-agent/agent.test.ts +3 -3
- package/dist/templates/hotel-reception-agent/agent.ts +6 -3
- package/dist/templates/hotel-reception-agent/client.tsx +14 -2
- package/dist/templates/hotel-reception-agent/concierge.ts +2 -1
- package/dist/templates/hotel-reception-agent/desk-seams.test.ts +3 -3
- package/dist/templates/hotel-reception-agent/disputes.ts +9 -11
- package/dist/templates/hotel-reception-agent/events.ts +2 -1
- package/dist/templates/hotel-reception-agent/session.ts +56 -0
- package/dist/templates/hotel-reception-agent/shared.ts +20 -21
- package/dist/templates/hotel-reception-agent/system-prompt.md +1 -1
- package/dist/templates/hotel-reception-agent/tools/abandon_booking.ts +2 -1
- package/dist/templates/hotel-reception-agent/tools/add_to_waitlist.ts +2 -1
- package/dist/templates/hotel-reception-agent/tools/book_airport_car.ts +2 -1
- package/dist/templates/hotel-reception-agent/tools/cancel_restaurant_reservation.ts +2 -1
- package/dist/templates/hotel-reception-agent/tools/cancel_room_booking.ts +2 -1
- package/dist/templates/hotel-reception-agent/tools/check_restaurant_availability.ts +1 -1
- package/dist/templates/hotel-reception-agent/tools/check_room_availability.ts +1 -1
- package/dist/templates/hotel-reception-agent/tools/choose_room.ts +1 -1
- package/dist/templates/hotel-reception-agent/tools/confirm_booking.ts +2 -1
- package/dist/templates/hotel-reception-agent/tools/dispatch_emergency.ts +2 -1
- package/dist/templates/hotel-reception-agent/tools/dispute_charge.ts +2 -1
- package/dist/templates/hotel-reception-agent/tools/flag_late_arrival.ts +2 -1
- package/dist/templates/hotel-reception-agent/tools/lookup_booking.ts +2 -1
- package/dist/templates/hotel-reception-agent/tools/lookup_guest_history.ts +1 -1
- package/dist/templates/hotel-reception-agent/tools/lookup_invoice.ts +2 -1
- package/dist/templates/hotel-reception-agent/tools/lookup_restaurant_reservation.ts +1 -1
- package/dist/templates/hotel-reception-agent/tools/modify_restaurant_reservation.ts +1 -1
- package/dist/templates/hotel-reception-agent/tools/record_card.ts +1 -1
- package/dist/templates/hotel-reception-agent/tools/record_followup.ts +2 -1
- package/dist/templates/hotel-reception-agent/tools/record_group_inquiry.ts +2 -1
- package/dist/templates/hotel-reception-agent/tools/record_guest_details.ts +1 -1
- package/dist/templates/hotel-reception-agent/tools/reinstate_booking.ts +1 -1
- package/dist/templates/hotel-reception-agent/tools/request_flight_reconfirmation.ts +2 -1
- package/dist/templates/hotel-reception-agent/tools/resend_confirmation.ts +2 -1
- package/dist/templates/hotel-reception-agent/tools/reserve_table.ts +1 -1
- package/dist/templates/hotel-reception-agent/tools/resolve_room_conflict.ts +2 -1
- package/dist/templates/hotel-reception-agent/tools/schedule_wakeup_call.ts +2 -1
- package/dist/templates/hotel-reception-agent/tools/set_do_not_disturb.ts +2 -1
- package/dist/templates/hotel-reception-agent/tools/set_extras.ts +1 -1
- package/dist/templates/hotel-reception-agent/tools/set_stay.ts +2 -1
- package/dist/templates/hotel-reception-agent/tools/start_booking_modification.ts +2 -1
- package/dist/templates/hotel-reception-agent/tools/start_room_booking.ts +2 -1
- package/dist/templates/hotel-reception-agent/tools/take_guest_message.ts +2 -1
- package/dist/templates/hotel-reception-agent/tools/transfer_call.ts +2 -1
- package/dist/templates/hotel-reception-agent/tools/update_card.ts +2 -1
- package/dist/templates/hotel-reception-agent/tools/verify_booking.ts +2 -1
- package/dist/templates/link-digest-workflow/agent.eval.test.ts +16 -1
- package/dist/templates/link-digest-workflow/agent.ts +5 -0
- package/dist/templates/medication-safety-agent/agent.test.ts +57 -4
- package/dist/templates/medication-safety-agent/agent.ts +48 -1
- package/dist/templates/meeting-recap-agent/agent.test.ts +2 -2
- package/dist/templates/meeting-recap-agent/agent.ts +4 -0
- package/dist/templates/pizza-ordering-agent/agent.eval.test.ts +68 -2
- package/dist/templates/pizza-ordering-agent/agent.ts +3 -0
- package/dist/templates/podcast-digest-workflow/agent.ts +4 -0
- package/dist/templates/push-to-talk-agent/agent.eval.test.ts +74 -0
- package/dist/templates/push-to-talk-agent/agent.test.ts +61 -0
- package/dist/templates/push-to-talk-agent/agent.ts +22 -0
- package/dist/templates/push-to-talk-agent/client.tsx +124 -0
- package/dist/templates/push-to-talk-agent/shared.ts +34 -0
- package/dist/templates/push-to-talk-agent/system-prompt.md +11 -0
- package/dist/templates/push-to-talk-agent/tools/list_notes.ts +15 -0
- package/dist/templates/push-to-talk-agent/tools/save_note.ts +26 -0
- package/dist/templates/quickstart-agent/agent.eval.test.ts +91 -3
- package/dist/templates/quickstart-agent/agent.test.ts +22 -0
- package/dist/templates/quickstart-agent/agent.ts +18 -2
- package/dist/templates/quickstart-agent/system-prompt.md +8 -0
- package/dist/templates/quickstart-agent/tools/get_weather.ts +59 -0
- package/dist/templates/research-handoff-agent/agent.eval.test.ts +1 -1
- package/dist/templates/research-handoff-agent/agent.test.ts +34 -26
- package/dist/templates/research-handoff-agent/agent.ts +4 -0
- package/dist/templates/research-planner-agent/agent.eval.test.ts +24 -2
- package/dist/templates/research-planner-agent/agent.test.ts +26 -16
- package/dist/templates/research-planner-agent/agent.ts +3 -0
- package/dist/templates/research-planner-agent/system-prompt.md +1 -1
- package/dist/templates/retail-orders-agent/agent.eval.test.ts +1 -1
- package/dist/templates/retail-orders-agent/agent.ts +32 -3
- package/dist/templates/retail-orders-agent/keyterms.ts +154 -0
- package/dist/templates/retail-orders-agent/resolve.ts +18 -3
- package/dist/templates/roadside-assistance-agent/agent.eval.test.ts +124 -5
- package/dist/templates/roadside-assistance-agent/agent.test.ts +39 -7
- package/dist/templates/roadside-assistance-agent/agent.ts +4 -0
- package/dist/templates/roadside-assistance-agent/shared.ts +12 -0
- package/dist/templates/roadside-assistance-agent/tools/acknowledge_disclosure.ts +14 -0
- package/dist/templates/roadside-assistance-agent/tools/lookup_coverage.ts +11 -0
- package/dist/templates/roadside-assistance-agent/tools/service_disclosure.ts +17 -11
- package/dist/templates/roadside-assistance-agent/yard.test.ts +4 -0
- package/dist/templates/spoken-summary-workflow/agent.ts +4 -0
- package/dist/templates/tabletop-rpg-agent/agent.eval.test.ts +6 -0
- package/dist/templates/tabletop-rpg-agent/agent.test.ts +125 -1
- package/dist/templates/tabletop-rpg-agent/agent.ts +30 -1
- package/dist/templates/tabletop-rpg-agent/shared.ts +81 -0
- package/dist/templates/tabletop-rpg-agent/system-prompt.md +1 -1
- package/dist/templates/tabletop-rpg-agent/tools/check_state.ts +16 -7
- package/dist/templates/technical-support-agent/agent.test.ts +29 -23
- package/dist/templates/technical-support-agent/agent.ts +5 -1
- package/dist/templates/technical-support-agent/knowledge.ts +165 -0
- package/dist/templates/technical-support-agent/nodes.ts +3 -2
- package/dist/templates/technical-support-agent/procedure.ts +7 -6
- package/dist/templates/technical-support-agent/shared.ts +10 -146
- package/dist/templates/technical-support-agent/tools/list_topics.ts +2 -1
- package/dist/templates/text-adventure-agent/agent.eval.test.ts +39 -6
- package/dist/templates/text-adventure-agent/agent.test.ts +79 -1
- package/dist/templates/text-adventure-agent/agent.ts +30 -1
- package/dist/templates/text-adventure-agent/shared.ts +37 -0
- package/dist/templates/text-adventure-agent/system-prompt.md +9 -2
- package/dist/templates/topic-briefing-agent/agent.eval.test.ts +18 -4
- package/dist/templates/topic-briefing-agent/agent.test.ts +61 -36
- package/dist/templates/topic-briefing-agent/agent.ts +4 -1
- package/dist/templates/topic-briefing-agent/shared.ts +19 -18
- package/dist/templates/topic-briefing-agent/system-prompt.md +13 -8
- package/dist/templates/topic-briefing-agent/tools/send_briefing.ts +43 -5
- package/dist/templates/transcription-workflow/agent.ts +3 -0
- package/dist/templates/travel-concierge-agent/agent.eval.test.ts +9 -7
- package/dist/templates/travel-concierge-agent/agent.test.ts +1 -2
- package/dist/templates/travel-concierge-agent/agent.ts +4 -0
- package/dist/templates/web-research-agent/agent.eval.test.ts +31 -5
- package/dist/templates/web-research-agent/agent.test.ts +16 -0
- package/dist/templates/web-research-agent/agent.ts +30 -0
- package/dist/templates/web-research-agent/system-prompt.md +8 -2
- package/dist/templates/word-game-agent/agent.eval.test.ts +79 -18
- package/dist/templates/word-game-agent/agent.test.ts +3 -1
- package/dist/templates/word-game-agent/agent.ts +20 -0
- package/dist/test-CjKPQ9_B.mjs +102 -0
- package/dist/test.d.ts +37 -12
- package/package.json +5 -5
- package/dist/_init-Bp1CjRrU.mjs +0 -199
- package/dist/_preflight-CcAR577V.mjs +0 -46
- package/dist/_templates-CuP74F8D.mjs +0 -291
- package/dist/init-CY4NAXAA.mjs +0 -183
- package/dist/test-PHHv0Vj6.mjs +0 -83
|
@@ -1,291 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
import { g as writeJson, s as errorMessage$1, u as isEexist } from "./_utils-D5JGcjiW.mjs";
|
|
3
|
-
import { t as getMonorepoRoot } from "./_agent-BzUeqOdj.mjs";
|
|
4
|
-
import { existsSync } from "node:fs";
|
|
5
|
-
import path from "node:path";
|
|
6
|
-
import { isRecord } from "@alexkroman1/aai/utils";
|
|
7
|
-
import fs from "node:fs/promises";
|
|
8
|
-
import { IGNORED_WORKSPACE_DIRS, isLocalOnlyFile } from "@alexkroman1/aai/workspace-files";
|
|
9
|
-
const REPO_URL = `https://github.com/alexkroman/agent`;
|
|
10
|
-
/**
|
|
11
|
-
* Templates as shipped inside the published tarball, copied into `dist/` by
|
|
12
|
-
* `bundle-templates.mjs` at build time — so this resolves to `dist/` for a
|
|
13
|
-
* published CLI and to the (template-less) package root when running source
|
|
14
|
-
* in the monorepo, where the branch above wins.
|
|
15
|
-
*
|
|
16
|
-
* They used to be fetched at `init` time with giget from
|
|
17
|
-
* `github:alexkroman/agent/packages/aai-templates#main`. That required a
|
|
18
|
-
* network for every `init`, and pinned templates to `main` regardless of the
|
|
19
|
-
* CLI version the user had installed, so a template written against a newer
|
|
20
|
-
* SDK could land in a project resolving an older one. Bundling pins the two
|
|
21
|
-
* together by construction. It also puts the templates inside the studio's
|
|
22
|
-
* guest sandbox, which has the CLI in its baked toolchain but no way to fetch
|
|
23
|
-
* anything from GitHub.
|
|
24
|
-
*/
|
|
25
|
-
function bundledTemplatesDir() {
|
|
26
|
-
return import.meta.dirname;
|
|
27
|
-
}
|
|
28
|
-
/** Resolve the templates root — env override, then monorepo, then bundled. */
|
|
29
|
-
function resolveTemplatesDir() {
|
|
30
|
-
const override = process.env.AAI_TEMPLATES_DIR;
|
|
31
|
-
if (override) return override;
|
|
32
|
-
const monorepoRoot = getMonorepoRoot();
|
|
33
|
-
if (monorepoRoot) return path.join(monorepoRoot, "packages", "aai-templates");
|
|
34
|
-
return bundledTemplatesDir();
|
|
35
|
-
}
|
|
36
|
-
/**
|
|
37
|
-
* List the shipped template names (sorted). Backs `aai templates` and the
|
|
38
|
-
* unknown-template error, so the discoverable list and the validated list
|
|
39
|
-
* can never drift.
|
|
40
|
-
*/
|
|
41
|
-
async function listTemplates(root = resolveTemplatesDir()) {
|
|
42
|
-
const templatesDir = path.join(root, "templates");
|
|
43
|
-
let available;
|
|
44
|
-
try {
|
|
45
|
-
available = await fs.readdir(templatesDir, { withFileTypes: true });
|
|
46
|
-
} catch (err) {
|
|
47
|
-
throw new Error(`Templates directory is missing or unreadable at ${templatesDir} (incomplete @alexkroman1/aai-cli install?): ${errorMessage$1(err)}`, { cause: err });
|
|
48
|
-
}
|
|
49
|
-
return available.filter((e) => e.isDirectory()).map((e) => e.name).sort();
|
|
50
|
-
}
|
|
51
|
-
/** package.json fields merged key-by-key rather than whole. */
|
|
52
|
-
const MERGED_MANIFEST_FIELDS = [
|
|
53
|
-
"dependencies",
|
|
54
|
-
"devDependencies",
|
|
55
|
-
"scripts"
|
|
56
|
-
];
|
|
57
|
-
/**
|
|
58
|
-
* Fill a manifest's gaps from the scaffold's, `existing` always winning.
|
|
59
|
-
*
|
|
60
|
-
* The same rule the file layering uses, one level deeper: a top-level field
|
|
61
|
-
* the manifest already declares is left alone, and for the three map fields
|
|
62
|
-
* it is each ENTRY that is left alone. Per-entry matters both ways — a
|
|
63
|
-
* workspace manifest pins its `dependencies` to exact installed versions and
|
|
64
|
-
* must keep them, while a single agent-added `devDependencies` entry must not
|
|
65
|
-
* shadow the whole toolchain block.
|
|
66
|
-
*
|
|
67
|
-
* Returns null when nothing was missing, so the common case writes no file.
|
|
68
|
-
*/
|
|
69
|
-
function mergeScaffoldManifest(existing, scaffold) {
|
|
70
|
-
const merged = { ...existing };
|
|
71
|
-
let changed = false;
|
|
72
|
-
for (const [key, value] of Object.entries(scaffold)) {
|
|
73
|
-
const mine = merged[key];
|
|
74
|
-
if (mine === void 0) {
|
|
75
|
-
merged[key] = value;
|
|
76
|
-
changed = true;
|
|
77
|
-
continue;
|
|
78
|
-
}
|
|
79
|
-
if (!MERGED_MANIFEST_FIELDS.includes(key)) continue;
|
|
80
|
-
if (!(isRecord(mine) && isRecord(value))) continue;
|
|
81
|
-
const entries = { ...mine };
|
|
82
|
-
for (const [dep, spec] of Object.entries(value)) {
|
|
83
|
-
if (dep in entries) continue;
|
|
84
|
-
entries[dep] = spec;
|
|
85
|
-
changed = true;
|
|
86
|
-
}
|
|
87
|
-
merged[key] = entries;
|
|
88
|
-
}
|
|
89
|
-
return changed ? merged : null;
|
|
90
|
-
}
|
|
91
|
-
/**
|
|
92
|
-
* Merge the scaffold's package.json UNDER the one already in `targetDir`.
|
|
93
|
-
*
|
|
94
|
-
* The file-level layering below can only skip a manifest that already exists,
|
|
95
|
-
* and for `aai pull` that manifest is the studio workspace's — which declares
|
|
96
|
-
* its runtime dependencies and nothing else. Toolchain packages are baked into
|
|
97
|
-
* the guest sandbox, so the workspace deliberately never names them (see
|
|
98
|
-
* aai-guest/studio-project-shape.ts); on a laptop nothing bakes them, so
|
|
99
|
-
* `pnpm install` fetched no `vite`, no `@vitejs/plugin-react`, no
|
|
100
|
-
* `@tailwindcss/vite`, and `aai dev` died resolving the vite.config.ts the
|
|
101
|
-
* very same layering had just written. Completing the manifest is the same job
|
|
102
|
-
* as completing the file tree.
|
|
103
|
-
*/
|
|
104
|
-
async function layerScaffoldManifest(scaffoldDir, targetDir) {
|
|
105
|
-
const target = path.join(targetDir, "package.json");
|
|
106
|
-
const [mine, theirs] = await Promise.all([readJsonFile(target), readJsonFile(path.join(scaffoldDir, "package.json"))]);
|
|
107
|
-
if (!(mine && theirs)) return;
|
|
108
|
-
const merged = mergeScaffoldManifest(mine, theirs);
|
|
109
|
-
if (merged) await writeJson(target, merged);
|
|
110
|
-
}
|
|
111
|
-
/** Parse a JSON file, or null when it is missing or unparseable. */
|
|
112
|
-
async function readJsonFile(file) {
|
|
113
|
-
try {
|
|
114
|
-
const parsed = JSON.parse(await fs.readFile(file, "utf-8"));
|
|
115
|
-
return isRecord(parsed) ? parsed : null;
|
|
116
|
-
} catch {
|
|
117
|
-
return null;
|
|
118
|
-
}
|
|
119
|
-
}
|
|
120
|
-
/**
|
|
121
|
-
* Directory holding the base scaffold — the files every project gets
|
|
122
|
-
* underneath its template (package.json, tsconfig, `.gitignore`, …).
|
|
123
|
-
*
|
|
124
|
-
* The scaffold is the single definition of the self-hosted entrypoint, so a
|
|
125
|
-
* caller needing one of its files resolves it here rather than carrying a
|
|
126
|
-
* second copy of that file's contents.
|
|
127
|
-
*/
|
|
128
|
-
function scaffoldDir() {
|
|
129
|
-
return path.join(resolveTemplatesDir(), "scaffold");
|
|
130
|
-
}
|
|
131
|
-
/**
|
|
132
|
-
* The project-root `CLAUDE.md` a scaffolded project gets — a POINTER at the
|
|
133
|
-
* guide inside the resolved SDK, not a copy of it.
|
|
134
|
-
*
|
|
135
|
-
* `scaffold/CLAUDE.md` is the authoring guide itself: 2,533 lines and 119k
|
|
136
|
-
* characters, sitting against the working cap `claude-md-limit.test.ts`
|
|
137
|
-
* enforces. It has three consumers, and only one wanted the bytes in a project:
|
|
138
|
-
* `sync-agent-guide.mjs` copies it into the `@alexkroman1/aai` tarball as
|
|
139
|
-
* `AGENT_GUIDE.md`, `studio-prompt.ts` embeds it in the studio system prompt,
|
|
140
|
-
* and — until this file — `fs.cp` wrote all 120KB into every `aai init`
|
|
141
|
-
* directory. That third copy is the one that cannot be right:
|
|
142
|
-
*
|
|
143
|
-
* - **It is stale by design.** The SDK's own shipped skill
|
|
144
|
-
* (`packages/aai/skills/aai/SKILL.md`) already says so in as many words:
|
|
145
|
-
* the project copy is "correct on day one, but frozen at scaffold time —
|
|
146
|
-
* `pnpm update @alexkroman1/aai` moves the SDK and leaves it behind. Prefer
|
|
147
|
-
* the file above whenever the two disagree." A file whose own publisher
|
|
148
|
-
* tells agents not to trust it is not carrying its weight.
|
|
149
|
-
* - **An agent pays for it on every session, whether or not it is writing
|
|
150
|
-
* agent code.** Claude Code loads a project-root `CLAUDE.md` in FULL at
|
|
151
|
-
* launch and documents a 200-line target; this was 2,533. Splitting it
|
|
152
|
-
* behind an `@import` would not have helped — imports are expanded at
|
|
153
|
-
* launch too — which is why the pointer below names the path inside a FENCE,
|
|
154
|
-
* the documented spelling for "mention, do not import". It is read on
|
|
155
|
-
* demand, by the agent that needs it, out of the tarball the project
|
|
156
|
-
* actually resolved.
|
|
157
|
-
*
|
|
158
|
-
* Nothing is lost that was not already duplicated: the guide ships in the SDK
|
|
159
|
-
* beside the `.d.ts` files it describes, which is the copy the skill has
|
|
160
|
-
* pointed at all along. What a project gets instead is the one thing the
|
|
161
|
-
* 120KB could not be — version-matched.
|
|
162
|
-
*/
|
|
163
|
-
const PROJECT_GUIDE_POINTER = `# Agent instructions
|
|
164
|
-
|
|
165
|
-
This is an [aai](${REPO_URL}) voice-agent project. An agent is a directory
|
|
166
|
-
containing \`agent.ts\`; the \`aai\` CLI bundles it and deploys it.
|
|
167
|
-
|
|
168
|
-
## Read the SDK guide before writing agent code
|
|
169
|
-
|
|
170
|
-
The complete authoring guide ships inside the installed package:
|
|
171
|
-
|
|
172
|
-
\`\`\`text
|
|
173
|
-
node_modules/@alexkroman1/aai/AGENT_GUIDE.md
|
|
174
|
-
\`\`\`
|
|
175
|
-
|
|
176
|
-
Read it with your file tools. It is version-matched by construction — it lives
|
|
177
|
-
in the same tarball as the \`@alexkroman1/aai\` this project resolved, so it
|
|
178
|
-
cannot describe a different release than the one being imported. Prefer it over
|
|
179
|
-
anything remembered about the SDK, and over anything in this file.
|
|
180
|
-
|
|
181
|
-
The types are the second source of truth: the shipped declarations are in
|
|
182
|
-
\`node_modules/@alexkroman1/aai/dist/\`. When the guide and the types disagree,
|
|
183
|
-
the types are what the compiler enforces.
|
|
184
|
-
|
|
185
|
-
## Commands
|
|
186
|
-
|
|
187
|
-
\`\`\`sh
|
|
188
|
-
npm run dev # Run locally on http://localhost:3000
|
|
189
|
-
npm test # This project's suite, minus the evals (vitest)
|
|
190
|
-
npm run test:agent # Just agent.test.ts, via the CLI
|
|
191
|
-
npm run eval # Drive a real session against a live model (spends money)
|
|
192
|
-
npm run build # Bundle the agent
|
|
193
|
-
npm start # Build, then self-host on http://127.0.0.1:3000
|
|
194
|
-
npm run publish:agent # Publish to the managed platform
|
|
195
|
-
\`\`\`
|
|
196
|
-
|
|
197
|
-
The \`aai\` CLI is a devDependency, so it is in \`node_modules/.bin\` rather than
|
|
198
|
-
on \`PATH\`: reach it through these scripts or with \`npx aai <command>\`.
|
|
199
|
-
|
|
200
|
-
## Project-specific notes
|
|
201
|
-
|
|
202
|
-
<!-- Add conventions, gotchas and decisions for THIS agent below. -->
|
|
203
|
-
`;
|
|
204
|
-
/**
|
|
205
|
-
* Layer the base scaffold (package.json, tsconfig, …) into targetDir
|
|
206
|
-
* WITHOUT overwriting anything already there. Shared by `aai init`
|
|
207
|
-
* (underneath a template) and `aai pull` (underneath the studio workspace
|
|
208
|
-
* files — the workspace stores source, and the scaffold completes it into a
|
|
209
|
-
* runnable project the same way the guest's `ensureProjectShape` does
|
|
210
|
-
* before an in-sandbox build).
|
|
211
|
-
*
|
|
212
|
-
* package.json is the one file merged rather than skipped — see
|
|
213
|
-
* {@link layerScaffoldManifest}. `CLAUDE.md` is the one file SUBSTITUTED: the
|
|
214
|
-
* scaffold's copy is the authoring guide, and a project gets
|
|
215
|
-
* {@link PROJECT_GUIDE_POINTER} instead.
|
|
216
|
-
*/
|
|
217
|
-
async function layerScaffold(targetDir) {
|
|
218
|
-
const dir = scaffoldDir();
|
|
219
|
-
if (!existsSync(dir)) return;
|
|
220
|
-
await fs.cp(dir, targetDir, {
|
|
221
|
-
recursive: true,
|
|
222
|
-
force: false,
|
|
223
|
-
errorOnExist: false,
|
|
224
|
-
filter: (src) => scaffoldCopyFilter(src, dir)
|
|
225
|
-
});
|
|
226
|
-
await Promise.all([layerScaffoldManifest(dir, targetDir), fs.writeFile(path.join(targetDir, "CLAUDE.md"), PROJECT_GUIDE_POINTER, { flag: "wx" }).catch((err) => {
|
|
227
|
-
if (!isEexist(err)) throw err;
|
|
228
|
-
})]);
|
|
229
|
-
}
|
|
230
|
-
/**
|
|
231
|
-
* `templateCopyFilter` plus the scaffold's own `CLAUDE.md`, which is the
|
|
232
|
-
* authoring guide rather than a file a project wants — see
|
|
233
|
-
* {@link PROJECT_GUIDE_POINTER}.
|
|
234
|
-
*
|
|
235
|
-
* Only the scaffold copy filters it. A TEMPLATE's `CLAUDE.md` would be that
|
|
236
|
-
* template's own notes and belongs in the project it seeds, so
|
|
237
|
-
* {@link downloadAndMergeTemplate} keeps using the unfiltered version. Matched
|
|
238
|
-
* on the full path rather than the basename for the same reason.
|
|
239
|
-
*/
|
|
240
|
-
function scaffoldCopyFilter(src, scaffold = scaffoldDir()) {
|
|
241
|
-
return templateCopyFilter(src) && path.resolve(src) !== path.join(scaffold, "CLAUDE.md");
|
|
242
|
-
}
|
|
243
|
-
/**
|
|
244
|
-
* `fs.cp` filter for every copy OUT of a template or the scaffold — the runtime
|
|
245
|
-
* ones here and the build-time one in `bundle-templates.mjs`.
|
|
246
|
-
*
|
|
247
|
-
* A template directory is also a runnable project, so a developer who runs
|
|
248
|
-
* `aai dev`, `aai build` or `aai publish` inside one leaves build output and
|
|
249
|
-
* machine state in it: `.aai/` (which holds `project.json` — a SLUG and a
|
|
250
|
-
* `serverUrl` — plus a built client), `.workflow-data/`, `node_modules/`, a
|
|
251
|
-
* `.env`. None of it is git-tracked, and an unfiltered `fs.cp` copied all of it
|
|
252
|
-
* anyway, to both destinations:
|
|
253
|
-
*
|
|
254
|
-
* - into every scaffolded project, so `aai init foo --template bar` produced a
|
|
255
|
-
* directory already LINKED to `bar`'s last local deploy. `aai init` publishes
|
|
256
|
-
* by default, so the first publish either targeted a slug the user never
|
|
257
|
-
* chose or — for the `http://localhost:8080` a dev checkout leaves behind —
|
|
258
|
-
* failed outright with "Refusing to send your API key to …", the project
|
|
259
|
-
* staying mis-linked for every later `push`/`publish`/`secret`.
|
|
260
|
-
* - into `packages/aai-cli/dist/templates`, i.e. into the PUBLISHED tarball
|
|
261
|
-
* (`files: ["bin.mjs", "dist"]`). Measured on a real build: 26 stray
|
|
262
|
-
* `.aai/project.json` files and 9.4 MB of one developer's `.aai/client`
|
|
263
|
-
* bundles out of a 12 MB `templates/`.
|
|
264
|
-
*
|
|
265
|
-
* The vocabulary is the SDK's, not a fourth list: {@link IGNORED_WORKSPACE_DIRS}
|
|
266
|
-
* is already "never walk this", and {@link isLocalOnlyFile} already means "this
|
|
267
|
-
* exists only on a developer's machine" — including a `.env` that must not ship
|
|
268
|
-
* to npm, and deliberately EXCLUDING `.env.example`, which the scaffold ships as
|
|
269
|
-
* source and a scaffolded project cannot do without.
|
|
270
|
-
*/
|
|
271
|
-
function templateCopyFilter(src) {
|
|
272
|
-
const name = path.basename(src);
|
|
273
|
-
return !(IGNORED_WORKSPACE_DIRS.has(name) || isLocalOnlyFile(name));
|
|
274
|
-
}
|
|
275
|
-
/**
|
|
276
|
-
* Copy a template into targetDir, merging scaffold files underneath.
|
|
277
|
-
*/
|
|
278
|
-
async function downloadAndMergeTemplate(template, targetDir) {
|
|
279
|
-
const root = resolveTemplatesDir();
|
|
280
|
-
const templatesDir = path.join(root, "templates");
|
|
281
|
-
const names = await listTemplates(root);
|
|
282
|
-
if (!names.includes(template)) throw new Error(`Unknown template "${template}". Available templates: ${names.join(", ")}`);
|
|
283
|
-
await fs.cp(path.join(templatesDir, template), targetDir, {
|
|
284
|
-
recursive: true,
|
|
285
|
-
force: true,
|
|
286
|
-
filter: templateCopyFilter
|
|
287
|
-
});
|
|
288
|
-
await layerScaffold(targetDir);
|
|
289
|
-
}
|
|
290
|
-
//#endregion
|
|
291
|
-
export { REPO_URL, downloadAndMergeTemplate, layerScaffold, listTemplates };
|
package/dist/init-CY4NAXAA.mjs
DELETED
|
@@ -1,183 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
import { a as ok } from "./_output-DBP9Op_d.mjs";
|
|
3
|
-
import { n as log, s as unwrapCancel } from "./_ui-DCt4qZrk.mjs";
|
|
4
|
-
import { c as fileExists, d as readJson, p as resolveCwd, s as errorMessage, t as AGENT_ENTRY } from "./_utils-D5JGcjiW.mjs";
|
|
5
|
-
import { r as isDevMode, t as getMonorepoRoot } from "./_agent-BzUeqOdj.mjs";
|
|
6
|
-
import { listTemplates } from "./_templates-CuP74F8D.mjs";
|
|
7
|
-
import path from "node:path";
|
|
8
|
-
import { styleText } from "node:util";
|
|
9
|
-
import * as p from "@clack/prompts";
|
|
10
|
-
import { execa } from "execa";
|
|
11
|
-
//#region src/init.ts
|
|
12
|
-
/**
|
|
13
|
-
* Run `fn` behind a clack spinner, stopping it in EVERY outcome.
|
|
14
|
-
*
|
|
15
|
-
* The naked form (`s?.start(); await work(); s?.stop()`) leaks the spinner on a
|
|
16
|
-
* failure: clack keeps its interval and its raw-mode stdin hook, so a throw
|
|
17
|
-
* left a spinner ticking under the error message with the cursor hidden. The
|
|
18
|
-
* `catch` label is what the terminal is left showing, so it names the step.
|
|
19
|
-
*/
|
|
20
|
-
async function withSpinner(silent, labels, fn) {
|
|
21
|
-
const s = silent ? void 0 : p.spinner();
|
|
22
|
-
s?.start(labels.start);
|
|
23
|
-
let succeeded = false;
|
|
24
|
-
try {
|
|
25
|
-
const value = await fn();
|
|
26
|
-
succeeded = true;
|
|
27
|
-
return value;
|
|
28
|
-
} finally {
|
|
29
|
-
s?.stop(succeeded ? labels.done : labels.failed);
|
|
30
|
-
}
|
|
31
|
-
}
|
|
32
|
-
const DEFAULT_PROJECT_NAME = "my-voice-agent";
|
|
33
|
-
/** Prompt for project name or return default when --yes is set. */
|
|
34
|
-
async function promptProjectName(yes) {
|
|
35
|
-
if (yes) return DEFAULT_PROJECT_NAME;
|
|
36
|
-
return unwrapCancel(await p.text({
|
|
37
|
-
message: "What is your project named?",
|
|
38
|
-
placeholder: DEFAULT_PROJECT_NAME,
|
|
39
|
-
defaultValue: DEFAULT_PROJECT_NAME
|
|
40
|
-
}), "Setup cancelled") || DEFAULT_PROJECT_NAME;
|
|
41
|
-
}
|
|
42
|
-
/**
|
|
43
|
-
* The template a non-interactive `init` gets, and the entry the selector opens
|
|
44
|
-
* on — so an author who just presses Enter lands where they used to.
|
|
45
|
-
*/
|
|
46
|
-
const DEFAULT_TEMPLATE = "quickstart-agent";
|
|
47
|
-
/**
|
|
48
|
-
* Ask which template to scaffold, listing what this CLI actually ships.
|
|
49
|
-
*
|
|
50
|
-
* The options are derived from {@link listTemplates} rather than a roster kept
|
|
51
|
-
* here: that function already backs `aai templates` AND the unknown-template
|
|
52
|
-
* error, so a template added to the package shows up in the picker with no
|
|
53
|
-
* second list to update. {@link DEFAULT_TEMPLATE} is hoisted to the top and
|
|
54
|
-
* pre-selected, which is what keeps a bare `aai init` a single Enter away from
|
|
55
|
-
* the project it produced before there was a picker.
|
|
56
|
-
*
|
|
57
|
-
* Callers must not reach here when there is nobody to answer — `--yes` and
|
|
58
|
-
* JSON mode (auto-detected on a pipe) resolve the default without prompting.
|
|
59
|
-
*/
|
|
60
|
-
async function promptTemplate(list = listTemplates) {
|
|
61
|
-
const [first, ...rest] = await list();
|
|
62
|
-
if (first === void 0) return DEFAULT_TEMPLATE;
|
|
63
|
-
if (rest.length === 0) return first;
|
|
64
|
-
const names = [first, ...rest];
|
|
65
|
-
const hasDefault = names.includes(DEFAULT_TEMPLATE);
|
|
66
|
-
const ordered = hasDefault ? [DEFAULT_TEMPLATE, ...names.filter((name) => name !== DEFAULT_TEMPLATE)] : names;
|
|
67
|
-
return unwrapCancel(await p.select({
|
|
68
|
-
message: "Which template?",
|
|
69
|
-
maxItems: 12,
|
|
70
|
-
initialValue: hasDefault ? DEFAULT_TEMPLATE : first,
|
|
71
|
-
options: ordered.map((name) => name === DEFAULT_TEMPLATE ? {
|
|
72
|
-
value: name,
|
|
73
|
-
hint: "the default starting point"
|
|
74
|
-
} : { value: name })
|
|
75
|
-
}), "Setup cancelled");
|
|
76
|
-
}
|
|
77
|
-
/** Best-effort corepack enable so pnpm is available (scaffold declares packageManager: pnpm). */
|
|
78
|
-
async function ensurePnpm() {
|
|
79
|
-
await execa("corepack", ["enable"], { reject: false });
|
|
80
|
-
}
|
|
81
|
-
/** Check if the project has any dependencies to install. */
|
|
82
|
-
async function hasDeps(cwd) {
|
|
83
|
-
if (await fileExists(path.join(cwd, "node_modules"))) return false;
|
|
84
|
-
const pkgJson = await readJson(path.join(cwd, "package.json")) ?? {};
|
|
85
|
-
const deps = Object.keys(pkgJson.dependencies ?? {});
|
|
86
|
-
const devDeps = Object.keys(pkgJson.devDependencies ?? {});
|
|
87
|
-
return deps.length > 0 || devDeps.length > 0;
|
|
88
|
-
}
|
|
89
|
-
/** Check whether the safe-chain binary is on PATH. */
|
|
90
|
-
async function hasSafeChain() {
|
|
91
|
-
const { failed } = await execa("safe-chain", ["--version"], { reject: false });
|
|
92
|
-
return !failed;
|
|
93
|
-
}
|
|
94
|
-
/** Build the command + args for running pnpm, routing through safe-chain when available. */
|
|
95
|
-
async function resolvePnpmCommand(checkSafeChain = hasSafeChain) {
|
|
96
|
-
if (await checkSafeChain()) return {
|
|
97
|
-
cmd: "safe-chain",
|
|
98
|
-
args: ["pnpm", "--safe-chain-skip-minimum-package-age"]
|
|
99
|
-
};
|
|
100
|
-
return {
|
|
101
|
-
cmd: "pnpm",
|
|
102
|
-
args: []
|
|
103
|
-
};
|
|
104
|
-
}
|
|
105
|
-
/** Run pnpm install and warn on failure. */
|
|
106
|
-
async function runPnpmInstall(cwd) {
|
|
107
|
-
const { cmd, args } = await resolvePnpmCommand();
|
|
108
|
-
const pnpmArgs = isDevMode() ? ["install"] : ["install", "--ignore-workspace"];
|
|
109
|
-
await execa(cmd, [...args, ...pnpmArgs], { cwd });
|
|
110
|
-
}
|
|
111
|
-
/**
|
|
112
|
-
* Install deps with pnpm, reporting a failure through `warn` rather than
|
|
113
|
-
* throwing: the project is scaffolded either way, and the two warnings say how
|
|
114
|
-
* to finish the install by hand. Nothing downstream branches on the outcome —
|
|
115
|
-
* `init` stops here — so it returns nothing.
|
|
116
|
-
*/
|
|
117
|
-
async function installDeps(cwd, warn, silent) {
|
|
118
|
-
if (!await hasDeps(cwd)) return;
|
|
119
|
-
await ensurePnpm();
|
|
120
|
-
try {
|
|
121
|
-
await withSpinner(silent, {
|
|
122
|
-
start: "Installing dependencies with pnpm",
|
|
123
|
-
done: "Dependencies installed",
|
|
124
|
-
failed: "Dependency install failed"
|
|
125
|
-
}, () => runPnpmInstall(cwd));
|
|
126
|
-
} catch (err) {
|
|
127
|
-
warn(`pnpm install failed: ${errorMessage(err)}`);
|
|
128
|
-
warn("Install pnpm (`npm install -g pnpm`), then run `pnpm install` in the project.");
|
|
129
|
-
}
|
|
130
|
-
}
|
|
131
|
-
/** Resolve target directory relative to the user's current directory. */
|
|
132
|
-
function resolveTargetDir(dir) {
|
|
133
|
-
return path.resolve(resolveCwd(), dir);
|
|
134
|
-
}
|
|
135
|
-
function collectWarnings() {
|
|
136
|
-
const warnings = [];
|
|
137
|
-
return {
|
|
138
|
-
warnings,
|
|
139
|
-
warn: (message) => {
|
|
140
|
-
warnings.push(message);
|
|
141
|
-
log.warn(message);
|
|
142
|
-
}
|
|
143
|
-
};
|
|
144
|
-
}
|
|
145
|
-
/** Scaffold the project, optionally showing a spinner. */
|
|
146
|
-
async function scaffoldProject(dir, cwd, template, silent) {
|
|
147
|
-
const { runInit } = await import("./_init-Bp1CjRrU.mjs");
|
|
148
|
-
await withSpinner(silent, {
|
|
149
|
-
start: `Creating ${dir}`,
|
|
150
|
-
done: "Project created",
|
|
151
|
-
failed: `Could not create ${dir}`
|
|
152
|
-
}, () => runInit({
|
|
153
|
-
targetDir: cwd,
|
|
154
|
-
template
|
|
155
|
-
}));
|
|
156
|
-
}
|
|
157
|
-
/** Print post-init instructions. */
|
|
158
|
-
function printPostInitInfo(cwd, monorepoRoot) {
|
|
159
|
-
log.success(`Created ${cwd}`);
|
|
160
|
-
if (monorepoRoot) log.info("Dev mode: project linked to workspace packages");
|
|
161
|
-
log.info(`Next: cd ${cwd} && aai dev`);
|
|
162
|
-
}
|
|
163
|
-
async function executeInit(opts, extra) {
|
|
164
|
-
const suppressUi = extra?.silent;
|
|
165
|
-
if (!suppressUi) p.intro(styleText("cyanBright", "Create a new voice agent"));
|
|
166
|
-
const dir = opts.dir ?? await promptProjectName(opts.yes);
|
|
167
|
-
const monorepoRoot = getMonorepoRoot();
|
|
168
|
-
const cwd = resolveTargetDir(dir);
|
|
169
|
-
if (!opts.force && await fileExists(path.join(cwd, "agent.ts"))) throw new Error(`${AGENT_ENTRY} already exists in this directory. Use ${styleText("cyanBright", "--force")} to overwrite.`);
|
|
170
|
-
const template = opts.template ?? (opts.yes || suppressUi ? DEFAULT_TEMPLATE : await promptTemplate());
|
|
171
|
-
const { warn, warnings } = collectWarnings();
|
|
172
|
-
await scaffoldProject(dir, cwd, template, suppressUi);
|
|
173
|
-
await installDeps(cwd, warn, suppressUi);
|
|
174
|
-
if (!suppressUi) printPostInitInfo(cwd, monorepoRoot);
|
|
175
|
-
const data = {
|
|
176
|
-
dir: cwd,
|
|
177
|
-
template
|
|
178
|
-
};
|
|
179
|
-
if (warnings.length > 0) data.warnings = warnings;
|
|
180
|
-
return ok(data);
|
|
181
|
-
}
|
|
182
|
-
//#endregion
|
|
183
|
-
export { executeInit };
|
package/dist/test-PHHv0Vj6.mjs
DELETED
|
@@ -1,83 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
import { a as ok, n as fail } from "./_output-DBP9Op_d.mjs";
|
|
3
|
-
import { n as log } from "./_ui-DCt4qZrk.mjs";
|
|
4
|
-
import { l as formatCappedList } from "./_utils-D5JGcjiW.mjs";
|
|
5
|
-
import { i as unrunSpecFiles, n as classifyVitestError, r as runVitest, t as WIDEN_HINT } from "./_vitest-runner-BiAMIir1.mjs";
|
|
6
|
-
import { omitUndefined } from "@alexkroman1/aai/utils";
|
|
7
|
-
//#region src/test.ts
|
|
8
|
-
/**
|
|
9
|
-
* `aai test` — run agent tests via vitest.
|
|
10
|
-
*
|
|
11
|
-
* The launcher is `_vitest-runner.ts`, shared with `aai eval` and `aai build`'s
|
|
12
|
-
* pre-build gate. What is here is the COMMAND: which files the test tier runs,
|
|
13
|
-
* and the verdict over the ones a run did not cover.
|
|
14
|
-
*/
|
|
15
|
-
/**
|
|
16
|
-
* The files `aai test` runs, in preference order.
|
|
17
|
-
*
|
|
18
|
-
* The tier's filenames belong to the command, not to the runner — `aai eval`
|
|
19
|
-
* declares `EVAL_FILES` the same way one module over, and neither names the
|
|
20
|
-
* other's. `aai build` imports this one because its pre-build gate runs the
|
|
21
|
-
* TEST tier.
|
|
22
|
-
*/
|
|
23
|
-
const TEST_FILES = ["agent.test.ts", "agent.test.js"];
|
|
24
|
-
/**
|
|
25
|
-
* Execute agent tests and return structured result.
|
|
26
|
-
*
|
|
27
|
-
* **An incomplete run is not a pass.** For as long as this command answered
|
|
28
|
-
* `{"ok":true,"data":{"passed":true}}` with exit 0 over specs it had not run,
|
|
29
|
-
* the scaffold's `"test": "aai test"` was what users wired into CI — so a suite
|
|
30
|
-
* of 25 tests could go red in the editor and green in the pipeline, and adding
|
|
31
|
-
* one tool could break `registry.test.ts` in 17 assertions with `pnpm test` and
|
|
32
|
-
* `pnpm build` both staying green throughout. It is the same defect
|
|
33
|
-
* `defineExec`'s `cwd` policy exists for (a green result for a project that is
|
|
34
|
-
* not there), one directory over, and it gets the same answer: the command
|
|
35
|
-
* fails, names the files, and names the flag that runs them.
|
|
36
|
-
*/
|
|
37
|
-
async function executeTest(cwd, opts = {}) {
|
|
38
|
-
log.step(opts.all ? "Running project tests" : "Running agent tests");
|
|
39
|
-
try {
|
|
40
|
-
const ran = runVitest(cwd, {
|
|
41
|
-
candidates: TEST_FILES,
|
|
42
|
-
announceUnrun: false,
|
|
43
|
-
...omitUndefined({ all: opts.all })
|
|
44
|
-
});
|
|
45
|
-
const unrun = unrunSpecFiles(cwd, ran);
|
|
46
|
-
if (unrun.length > 0) return incomplete(ran, unrun);
|
|
47
|
-
if (ran === false) {
|
|
48
|
-
log.info("No test file found. Create agent.test.ts to add tests.");
|
|
49
|
-
return ok({
|
|
50
|
-
passed: true,
|
|
51
|
-
skipped: true,
|
|
52
|
-
ran: [],
|
|
53
|
-
unrun: [],
|
|
54
|
-
complete: true
|
|
55
|
-
});
|
|
56
|
-
}
|
|
57
|
-
log.success(`Tests passed (${ran.length} spec file(s))`);
|
|
58
|
-
return ok({
|
|
59
|
-
passed: true,
|
|
60
|
-
ran,
|
|
61
|
-
unrun: [],
|
|
62
|
-
complete: true
|
|
63
|
-
});
|
|
64
|
-
} catch (err) {
|
|
65
|
-
const { code, message } = classifyVitestError(err);
|
|
66
|
-
return fail(code, message);
|
|
67
|
-
}
|
|
68
|
-
}
|
|
69
|
-
/**
|
|
70
|
-
* The verdict for a run that left specs uncovered.
|
|
71
|
-
*
|
|
72
|
-
* Both arms fail, and the `ran === false` arm is the one that had misled
|
|
73
|
-
* longest: `aai test` printed "No test file found" while the project's specs sat
|
|
74
|
-
* right there unrun, which reads as "this project has no tests". Measured on a
|
|
75
|
-
* project whose only spec was `tools/echo_back.test.ts` — `{"passed":true,
|
|
76
|
-
* "skipped":true}`, exit 0, and not a word about it.
|
|
77
|
-
*/
|
|
78
|
-
function incomplete(ran, unrun) {
|
|
79
|
-
const preamble = ran === false ? `\`aai test\` found no agent.test.ts, so it ran nothing, but ${unrun.length} spec file(s) exist` : `\`aai test\` ran ${ran.join(", ")} only — ${unrun.length} other spec file(s) in this project were not run`;
|
|
80
|
-
return fail("incomplete_run", `${preamble}: ${formatCappedList(unrun)}. An unrun spec is not a passing one, so this is not a green result.`, WIDEN_HINT);
|
|
81
|
-
}
|
|
82
|
-
//#endregion
|
|
83
|
-
export { TEST_FILES, executeTest };
|