aui-agent-builder 0.4.40 → 0.4.42

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.
@@ -0,0 +1,388 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ import { render, Box } from "ink";
3
+ import { getConfig, loadProjectConfig, findProjectRoot, } from "../config/index.js";
4
+ import { getValidSession } from "../services/auth.service.js";
5
+ import { AUIClient } from "../api-client/index.js";
6
+ import { getTracer, SpanStatusCode, setUserContext, setProjectContext, setAgentContext, } from "../telemetry.js";
7
+ import { resolveAgentManagementInfo } from "./util/agent-resolve.js";
8
+ import { AuthenticationError, CLIError, ConfigError, ValidationError, } from "../errors/index.js";
9
+ import { Header, StatusLine, Spinner, Hint, } from "../ui/components/index.js";
10
+ import { isJsonMode, outputJson } from "../utils/json-output.js";
11
+ import { SCENARIOS_DIR, SCENARIOS_FILE, SCORES_FILE, INTENT_DIR, assembleBundleUploadFiles, pullScenariosToFolder, pullScoresToFolder, readLocalScenarios, readLocalScores, scaffoldScenarios, scoresToPushBody, } from "../services/scenarios.service.js";
12
+ // ─── Ink helpers ───
13
+ function log(node) {
14
+ const { unmount } = render(node);
15
+ unmount();
16
+ }
17
+ function startSpinner(label) {
18
+ const inst = render(_jsx(Spinner, { label: label }));
19
+ let done = false;
20
+ const stop = () => {
21
+ if (done)
22
+ return;
23
+ done = true;
24
+ inst.unmount();
25
+ };
26
+ return {
27
+ succeed(msg) {
28
+ stop();
29
+ log(_jsx(StatusLine, { kind: "success", label: msg }));
30
+ },
31
+ warn(msg) {
32
+ stop();
33
+ log(_jsx(StatusLine, { kind: "warning", label: msg }));
34
+ },
35
+ fail(msg) {
36
+ stop();
37
+ log(_jsx(StatusLine, { kind: "error", label: msg }));
38
+ },
39
+ stop,
40
+ };
41
+ }
42
+ // ─── Telemetry wrapper ───
43
+ //
44
+ // Every scenarios command runs inside its own OTel span so Logfire shows
45
+ // the command, its attributes, and — because the api-client attaches an
46
+ // `http.<name>` event (with `aui.curl_repro`) to the ACTIVE span on every
47
+ // request — the full replayable curl for each backend call it made.
48
+ async function runSpan(name, fn) {
49
+ const tracer = getTracer();
50
+ return tracer.startActiveSpan(name, async (span) => {
51
+ await setUserContext(span);
52
+ await setProjectContext(span);
53
+ try {
54
+ const result = await fn(span);
55
+ span.setStatus({ code: SpanStatusCode.OK });
56
+ return result;
57
+ }
58
+ catch (error) {
59
+ span.setStatus({
60
+ code: SpanStatusCode.ERROR,
61
+ message: error instanceof Error ? error.message : String(error),
62
+ });
63
+ span.recordException(error instanceof Error ? error : new Error(String(error)));
64
+ throw error;
65
+ }
66
+ finally {
67
+ span.end();
68
+ }
69
+ });
70
+ }
71
+ /**
72
+ * Resolve the current project's agent-management record. Requires running
73
+ * inside an agent directory (`.auirc`). NEVER prompts. When a `span` is
74
+ * passed, the resolved agent / version identifiers are attached to it.
75
+ */
76
+ async function resolveContext(span) {
77
+ const config = getConfig();
78
+ if (!config.isAuthenticated) {
79
+ throw new AuthenticationError("Not logged in.", {
80
+ suggestion: "Run `aui login` first.",
81
+ });
82
+ }
83
+ const projectRoot = findProjectRoot();
84
+ if (!projectRoot) {
85
+ throw new ConfigError("No agent project found in this directory.", {
86
+ suggestion: "Run `aui scenarios` commands from inside an agent project directory (one with a .auirc).",
87
+ });
88
+ }
89
+ const projectConfig = loadProjectConfig(projectRoot);
90
+ if (!projectConfig || (!projectConfig.agent_id && !projectConfig.agent_management_id)) {
91
+ throw new ConfigError("No agent linked to this project (.auirc).", {
92
+ suggestion: "Run `aui import-agent` to link an agent first.",
93
+ });
94
+ }
95
+ const session = await getValidSession();
96
+ const client = new AUIClient({
97
+ baseUrl: config.apiUrl,
98
+ authToken: config.authToken,
99
+ accountId: projectConfig.account_id || config.accountId,
100
+ organizationId: projectConfig.organization_id || config.organizationId,
101
+ environment: config.environment,
102
+ });
103
+ const { agentInfo, errors } = await resolveAgentManagementInfo(client, {
104
+ projectAgentManagementId: projectConfig.agent_management_id,
105
+ projectNetworkId: projectConfig.agent_id,
106
+ sessionAgentManagementId: session?.agent_management_id,
107
+ sessionNetworkId: session?.network_id,
108
+ });
109
+ if (!agentInfo) {
110
+ const detail = errors.length > 0 ? `\n - ${errors.join("\n - ")}` : "";
111
+ throw new ConfigError(`Could not resolve the agent for this project.${detail}`, {
112
+ suggestion: "Re-run `aui import-agent`, or check `aui status`.",
113
+ });
114
+ }
115
+ if (span) {
116
+ await setAgentContext(span, {
117
+ agentManagementId: agentInfo.id,
118
+ agentId: agentInfo.id,
119
+ agentCode: projectConfig.agent_code,
120
+ versionId: projectConfig.version_id,
121
+ versionLabel: projectConfig.version_label,
122
+ networkId: projectConfig.agent_id,
123
+ accountId: projectConfig.account_id,
124
+ organizationId: projectConfig.organization_id,
125
+ networkCategoryId: projectConfig.network_category_id,
126
+ });
127
+ span.setAttribute("scenarios.agent_management_id", agentInfo.id);
128
+ if (projectConfig.version_id)
129
+ span.setAttribute("scenarios.version_id", projectConfig.version_id);
130
+ if (projectConfig.version_tag)
131
+ span.setAttribute("scenarios.version_tag", projectConfig.version_tag);
132
+ }
133
+ return { client, projectRoot, projectConfig, session, agentInfo };
134
+ }
135
+ export async function scenariosGenerate(options = {}) {
136
+ return runSpan("aui.scenarios.generate", (span) => _scenariosGenerate(span, options));
137
+ }
138
+ async function _scenariosGenerate(span, _options) {
139
+ const json = isJsonMode();
140
+ const projectRoot = findProjectRoot();
141
+ if (!projectRoot) {
142
+ throw new ConfigError("No agent project found in this directory.", {
143
+ suggestion: "Run `aui scenarios generate` from inside an agent project directory (one with a .auirc).",
144
+ });
145
+ }
146
+ const result = scaffoldScenarios(projectRoot);
147
+ span.setAttribute("scenarios.created_scenarios_file", result.createdScenariosFile);
148
+ span.setAttribute("scenarios.created_intent_dir", result.createdIntentDir);
149
+ if (json) {
150
+ outputJson({
151
+ scaffolded: true,
152
+ created_scenarios_file: result.createdScenariosFile,
153
+ created_intent_dir: result.createdIntentDir,
154
+ paths: {
155
+ scenarios_file: `${SCENARIOS_DIR}/${SCENARIOS_FILE}`,
156
+ intent_dir: `${SCENARIOS_DIR}/${INTENT_DIR}/`,
157
+ },
158
+ });
159
+ return;
160
+ }
161
+ log(_jsx(Header, { title: "Scenarios \u2014 Generate" }));
162
+ log(_jsx(StatusLine, { kind: "success", label: `Scaffolded ${SCENARIOS_DIR}/ (${SCENARIOS_DIR}/${SCENARIOS_FILE}${result.createdIntentDir ? `, ${SCENARIOS_DIR}/${INTENT_DIR}/` : ""})` }));
163
+ log(_jsx(Box, { flexDirection: "column", paddingX: 1, marginTop: 1, children: _jsx(Hint, { message: `Next: drop the agent's requirements / docs / sample data into ${SCENARIOS_DIR}/${INTENT_DIR}/, then ask your coding agent to convert them into ${SCENARIOS_DIR}/${SCENARIOS_FILE} (the "scenarios" skill explains the format).` }) }));
164
+ }
165
+ export async function scenariosPull(options = {}) {
166
+ return runSpan("aui.scenarios.pull", (span) => _scenariosPull(span, options));
167
+ }
168
+ async function _scenariosPull(span, options) {
169
+ const json = isJsonMode();
170
+ if (!json)
171
+ log(_jsx(Header, { title: "Scenarios \u2014 Pull" }));
172
+ const { client, projectRoot, projectConfig, agentInfo } = await resolveContext(span);
173
+ if (options.version !== undefined)
174
+ span.setAttribute("scenarios.requested_version", options.version);
175
+ const spinner = json ? null : startSpinner("Pulling scenarios bundle...");
176
+ const bundleResult = await pullScenariosToFolder(client, agentInfo.id, projectRoot, { version: options.version });
177
+ span.setAttribute("scenarios.bundle_found", bundleResult.found);
178
+ if (bundleResult.found) {
179
+ span.setAttribute("scenarios.bundle_version", bundleResult.version ?? -1);
180
+ span.setAttribute("scenarios.scenarios_count", bundleResult.scenariosCount ?? 0);
181
+ span.setAttribute("scenarios.intents_count", bundleResult.intentsCount ?? 0);
182
+ }
183
+ if (!bundleResult.found) {
184
+ if (spinner)
185
+ spinner.warn("No scenarios bundle found for this agent yet.");
186
+ if (json) {
187
+ outputJson({ bundle_found: false, scores_found: false });
188
+ return;
189
+ }
190
+ log(_jsx(Hint, { message: "Run `aui scenarios generate` to start a new scenarios bundle, then `aui scenarios push`." }));
191
+ return;
192
+ }
193
+ if (spinner)
194
+ spinner.succeed(`Pulled bundle v${bundleResult.version} (${bundleResult.scenariosCount} scenario(s), ${bundleResult.intentsCount} intent file(s))`);
195
+ // Scores for the project's current version (best-effort).
196
+ const scoresSpinner = json ? null : startSpinner("Pulling latest scores...");
197
+ let scoresResult = {
198
+ found: false,
199
+ };
200
+ try {
201
+ scoresResult = await pullScoresToFolder(client, agentInfo.id, projectRoot, {
202
+ versionId: projectConfig.version_id,
203
+ versionTag: projectConfig.version_tag,
204
+ });
205
+ if (scoresSpinner) {
206
+ if (scoresResult.found) {
207
+ scoresSpinner.succeed(`Pulled latest scores (${scoresResult.pass}/${scoresResult.total} passed)`);
208
+ }
209
+ else {
210
+ scoresSpinner.warn("No evaluation scores recorded for this version yet.");
211
+ }
212
+ }
213
+ }
214
+ catch (err) {
215
+ // Scores are supplementary — never fail the whole pull on them.
216
+ if (scoresSpinner)
217
+ scoresSpinner.warn(`Could not pull scores: ${err instanceof Error ? err.message : String(err)}`);
218
+ }
219
+ span.setAttribute("scenarios.scores_found", scoresResult.found);
220
+ if (scoresResult.found) {
221
+ span.setAttribute("scenarios.scores_total", scoresResult.total ?? 0);
222
+ span.setAttribute("scenarios.scores_pass", scoresResult.pass ?? 0);
223
+ }
224
+ if (json) {
225
+ outputJson({
226
+ bundle_found: true,
227
+ version: bundleResult.version,
228
+ scenarios_count: bundleResult.scenariosCount,
229
+ intents_count: bundleResult.intentsCount,
230
+ scores_found: scoresResult.found,
231
+ ...(scoresResult.found
232
+ ? { total_scenarios: scoresResult.total, pass_scenarios: scoresResult.pass }
233
+ : {}),
234
+ });
235
+ }
236
+ }
237
+ export async function scenariosPush(options = {}) {
238
+ return runSpan("aui.scenarios.push", (span) => _scenariosPush(span, options));
239
+ }
240
+ async function _scenariosPush(span, options) {
241
+ const json = isJsonMode();
242
+ if (!json)
243
+ log(_jsx(Header, { title: "Scenarios \u2014 Push" }));
244
+ const { client, projectRoot, projectConfig, session, agentInfo } = await resolveContext(span);
245
+ const createdBy = session?.user_id;
246
+ if (!createdBy) {
247
+ throw new AuthenticationError("No user id in the current session.", {
248
+ suggestion: "Re-run `aui login`, then retry.",
249
+ });
250
+ }
251
+ // 1) Build bundle push (assemble + validate locally first).
252
+ const files = assembleBundleUploadFiles(projectRoot);
253
+ const intentCount = files.length - 1;
254
+ span.setAttribute("scenarios.intents_count", intentCount);
255
+ span.setAttribute("scenarios.skip_scores", options.skipScores === true);
256
+ const bundleSpinner = json
257
+ ? null
258
+ : startSpinner(`Pushing build bundle (${intentCount} intent file(s))...`);
259
+ const bundleResp = await client.agentManagement.pushBuildBundle(agentInfo.id, {
260
+ files,
261
+ createdBy,
262
+ notes: options.notes,
263
+ });
264
+ if (bundleSpinner)
265
+ bundleSpinner.succeed(`Pushed build bundle v${bundleResp.version} (${bundleResp.scenarios_count} scenario(s), ${bundleResp.intents_count} intent(s))`);
266
+ span.setAttribute("scenarios.bundle_version", bundleResp.version);
267
+ span.setAttribute("scenarios.bundle_id", bundleResp.bundle_id);
268
+ span.setAttribute("scenarios.scenarios_count", bundleResp.scenarios_count);
269
+ // 2) Scores push (sequenced AFTER the bundle so we can link the
270
+ // bundle version). Skipped when there's no local scores file or
271
+ // --skip-scores is set.
272
+ let scorePushed = false;
273
+ let scoreError;
274
+ const localScores = readLocalScores(projectRoot);
275
+ if (!options.skipScores && localScores) {
276
+ if (!projectConfig.version_id) {
277
+ scoreError =
278
+ "No version_id in .auirc — cannot push scores. Re-run `aui import-agent`/`aui pull` to record one.";
279
+ if (!json)
280
+ log(_jsx(StatusLine, { kind: "warning", label: scoreError }));
281
+ }
282
+ else {
283
+ const scoreSpinner = json ? null : startSpinner("Pushing evaluation scores...");
284
+ try {
285
+ const body = scoresToPushBody(localScores, {
286
+ versionId: projectConfig.version_id,
287
+ versionTag: projectConfig.version_tag,
288
+ bundleVersion: bundleResp.version,
289
+ createdBy,
290
+ });
291
+ const scoreResp = await client.agentManagement.pushEvaluationScore(agentInfo.id, body);
292
+ scorePushed = true;
293
+ if (scoreSpinner)
294
+ scoreSpinner.succeed(`Pushed scores for ${scoreResp.version_tag} (${scoreResp.pass_scenarios}/${scoreResp.total_scenarios} passed)`);
295
+ }
296
+ catch (err) {
297
+ scoreError = err instanceof Error ? err.message : String(err);
298
+ if (scoreSpinner)
299
+ scoreSpinner.fail(`Scores push failed: ${scoreError}`);
300
+ // Bundle already landed; surface the score failure but don't
301
+ // unwind. Re-throw below as a CLIError so the exit code is non-zero.
302
+ }
303
+ }
304
+ }
305
+ else if (!options.skipScores && !localScores) {
306
+ if (!json)
307
+ log(_jsx(Hint, { message: `No ${SCENARIOS_DIR}/${SCORES_FILE} found — pushed the bundle only. Run the scoring skill, then \`aui scenarios push\` again to record scores.` }));
308
+ }
309
+ span.setAttribute("scenarios.scores_pushed", scorePushed);
310
+ if (scoreError)
311
+ span.setAttribute("scenarios.scores_error", scoreError);
312
+ if (json) {
313
+ outputJson({
314
+ bundle: {
315
+ version: bundleResp.version,
316
+ bundle_id: bundleResp.bundle_id,
317
+ scenarios_count: bundleResp.scenarios_count,
318
+ intents_count: bundleResp.intents_count,
319
+ },
320
+ scores_pushed: scorePushed,
321
+ ...(scoreError ? { scores_error: scoreError } : {}),
322
+ });
323
+ }
324
+ if (scoreError) {
325
+ throw new CLIError(`Build bundle pushed, but scores push failed: ${scoreError}`, {
326
+ suggestion: "Fix the issue above and re-run `aui scenarios push` (the bundle is already versioned server-side).",
327
+ });
328
+ }
329
+ }
330
+ export async function scenariosScore(options = {}) {
331
+ return runSpan("aui.scenarios.score", (span) => _scenariosScore(span, options));
332
+ }
333
+ async function _scenariosScore(span, options) {
334
+ const json = isJsonMode();
335
+ if (!json)
336
+ log(_jsx(Header, { title: "Scenarios \u2014 Score" }));
337
+ const projectRoot = findProjectRoot();
338
+ if (!projectRoot) {
339
+ throw new ConfigError("No agent project found in this directory.", {
340
+ suggestion: "Run `aui scenarios score` from inside an agent project directory.",
341
+ });
342
+ }
343
+ const localScores = readLocalScores(projectRoot);
344
+ const localScenarios = readLocalScenarios(projectRoot);
345
+ span.setAttribute("scenarios.has_local_scores", !!localScores);
346
+ span.setAttribute("scenarios.scenario_count", localScenarios?.scenarios.length ?? 0);
347
+ let remote = null;
348
+ if (options.remote) {
349
+ const { client, projectConfig, agentInfo } = await resolveContext(span);
350
+ if (!projectConfig.version_id && !projectConfig.version_tag) {
351
+ throw new ValidationError("No version_id / version_tag in .auirc to query remote scores.", { suggestion: "Run `aui pull` to record the current version." });
352
+ }
353
+ remote = await client.agentManagement.pullEvaluationScores(agentInfo.id, {
354
+ versionId: projectConfig.version_id,
355
+ versionTag: projectConfig.version_tag,
356
+ });
357
+ span.setAttribute("scenarios.remote_history_count", remote.length);
358
+ }
359
+ if (json) {
360
+ outputJson({
361
+ local: localScores
362
+ ? {
363
+ total_scenarios: localScores.total_scenarios,
364
+ pass_scenarios: localScores.pass_scenarios,
365
+ pass_percentage: localScores.pass_percentage,
366
+ scenarios: localScores.scenarios ?? [],
367
+ }
368
+ : null,
369
+ scenario_count: localScenarios?.scenarios.length ?? 0,
370
+ ...(remote ? { remote_history_count: remote.length, remote } : {}),
371
+ });
372
+ return;
373
+ }
374
+ if (!localScores) {
375
+ log(_jsx(StatusLine, { kind: "muted", label: `No ${SCENARIOS_DIR}/${SCORES_FILE} yet — run the scoring skill to produce one.` }));
376
+ }
377
+ else {
378
+ const total = localScores.total_scenarios ?? localScores.scenarios?.length ?? 0;
379
+ const pass = localScores.pass_scenarios ?? 0;
380
+ const pct = localScores.pass_percentage ??
381
+ (total > 0 ? Math.round((pass / total) * 100) : 0);
382
+ log(_jsx(StatusLine, { kind: pass === total && total > 0 ? "success" : "info", label: `Local scores: ${pass}/${total} passed (${pct}%)` }));
383
+ }
384
+ if (remote) {
385
+ log(_jsx(StatusLine, { kind: "info", label: `Remote score history: ${remote.length} record(s) for this version.` }));
386
+ }
387
+ }
388
+ //# sourceMappingURL=scenarios.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"scenarios.js","sourceRoot":"","sources":["../../src/commands/scenarios.tsx"],"names":[],"mappings":";AAiBA,OAAO,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,KAAK,CAAC;AAClC,OAAO,EACL,SAAS,EACT,iBAAiB,EACjB,eAAe,GAGhB,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EAAE,eAAe,EAAE,MAAM,6BAA6B,CAAC;AAC9D,OAAO,EAAE,SAAS,EAAkB,MAAM,wBAAwB,CAAC;AACnE,OAAO,EACL,SAAS,EACT,cAAc,EACd,cAAc,EACd,iBAAiB,EACjB,eAAe,GAChB,MAAM,iBAAiB,CAAC;AACzB,OAAO,EAAE,0BAA0B,EAAE,MAAM,yBAAyB,CAAC;AACrE,OAAO,EACL,mBAAmB,EACnB,QAAQ,EACR,WAAW,EACX,eAAe,GAChB,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EACL,MAAM,EACN,UAAU,EACV,OAAO,EAEP,IAAI,GACL,MAAM,2BAA2B,CAAC;AACnC,OAAO,EAAE,UAAU,EAAE,UAAU,EAAE,MAAM,yBAAyB,CAAC;AACjE,OAAO,EACL,aAAa,EACb,cAAc,EACd,WAAW,EACX,UAAU,EACV,yBAAyB,EACzB,qBAAqB,EACrB,kBAAkB,EAClB,kBAAkB,EAClB,eAAe,EACf,iBAAiB,EACjB,gBAAgB,GACjB,MAAM,kCAAkC,CAAC;AAE1C,sBAAsB;AAEtB,SAAS,GAAG,CAAC,IAAkB;IAC7B,MAAM,EAAE,OAAO,EAAE,GAAG,MAAM,CAAC,IAAI,CAAC,CAAC;IACjC,OAAO,EAAE,CAAC;AACZ,CAAC;AAED,SAAS,YAAY,CAAC,KAAa;IACjC,MAAM,IAAI,GAAG,MAAM,CAAC,KAAC,OAAO,IAAC,KAAK,EAAE,KAAK,GAAI,CAAC,CAAC;IAC/C,IAAI,IAAI,GAAG,KAAK,CAAC;IACjB,MAAM,IAAI,GAAG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AAE,CAAC;QACjB,GAAG,CACD,KAAC,UAAU,IACT,IAAI,EAAC,OAAO,EACZ,KAAK,EAAE,MAAM,aAAa,IAAI,WAAW,8CAA8C,GACvF,CACH,CAAC;IACJ,CAAC;SAAM,CAAC;QACN,MAAM,KAAK,GAAG,WAAW,CAAC,eAAe,IAAI,WAAW,CAAC,SAAS,EAAE,MAAM,IAAI,CAAC,CAAC;QAChF,MAAM,IAAI,GAAG,WAAW,CAAC,cAAc,IAAI,CAAC,CAAC;QAC7C,MAAM,GAAG,GACP,WAAW,CAAC,eAAe;YAC3B,CAAC,KAAK,GAAG,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,IAAI,GAAG,KAAK,CAAC,GAAG,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;QACrD,GAAG,CACD,KAAC,UAAU,IACT,IAAI,EAAE,IAAI,KAAK,KAAK,IAAI,KAAK,GAAG,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,MAAM,EACtD,KAAK,EAAE,iBAAiB,IAAI,IAAI,KAAK,YAAY,GAAG,IAAI,GACxD,CACH,CAAC;IACJ,CAAC;IAED,IAAI,MAAM,EAAE,CAAC;QACX,GAAG,CACD,KAAC,UAAU,IACT,IAAI,EAAC,MAAM,EACX,KAAK,EAAE,yBAAyB,MAAM,CAAC,MAAM,8BAA8B,GAC3E,CACH,CAAC;IACJ,CAAC;AACH,CAAC"}
package/dist/index.js CHANGED
@@ -20,7 +20,7 @@ import { render } from "ink";
20
20
  import { initTelemetry, shutdownTelemetry, withSessionContext, startSessionRootSpan, endSessionRootSpan, withAgentContext, endAgentRootSpan, } from "./telemetry.js";
21
21
  import { handleError, ExitCode } from "./errors/index.js";
22
22
  import { Banner } from "./ui/components/index.js";
23
- import { login, account, agents, importAgent, listAgents, push, validate, pullSchema, status, syncSessionCommand, diff, rag, env, serve, logout, pullAgent, upgrade, revert, report, } from "./commands/index.js";
23
+ import { login, account, agents, importAgent, listAgents, push, validate, pullSchema, status, syncSessionCommand, diff, rag, env, serve, logout, pullAgent, scenariosGenerate, scenariosPull, scenariosPush, scenariosScore, upgrade, revert, report, } from "./commands/index.js";
24
24
  import { apolloMenu, apolloCreateTask, apolloSendMessage, apolloRerun, apolloTrace, } from "./commands/apollo.js";
25
25
  import { mockdbMenu, mockdbProvision, mockdbDescribe, mockdbCollectionsCreate, mockdbCollectionsList, mockdbSeed, mockdbEndpointCreate, mockdbEndpointList, mockdbEndpointGet, mockdbEndpointUpdate, mockdbEndpointDelete, mockdbExecute, mockdbSessionGet, mockdbSessionReset, mockdbRotateMgmtKey, mockdbRotateRuntimeKey, mockdbExport, mockdbKeys, mockdbStatus, mockdbDelete, mockdbGuide, } from "./commands/mockdb.js";
26
26
  import { integration, integrationCreate, integrationDiscover, } from "./commands/integration.js";
@@ -441,6 +441,7 @@ program
441
441
  .option("--no-skills", "Skip skill generation entirely")
442
442
  .option("--skip-kb-files", "Skip knowledge-base-files schema fetch")
443
443
  .option("--with-kb-files", "Also download original binaries (PDF, CSV, …) into each KB folder")
444
+ .option("--skip-scenarios", "Skip the best-effort scenarios bundle pull after import")
444
445
  .option("--reset-git", "On re-import into an existing dir, wipe local git history and start a fresh baseline commit (default: preserve existing .git and commit on top)")
445
446
  .option("--exclude-skills", "Write coding agent configs (.claude/, .cursor/, .opencode/) to current directory instead of --dir")
446
447
  .option("--include-evaluate", "Include the evaluate (test_questions) schema")
@@ -504,6 +505,7 @@ program
504
505
  .option("--no-skills", "Skip skill generation entirely")
505
506
  .option("--skip-kb-files", "Skip knowledge-base-files schema fetch")
506
507
  .option("--with-kb-files", "Also download original binaries (PDF, CSV, …) into each KB folder")
508
+ .option("--skip-scenarios", "Skip the best-effort scenarios bundle pull after pull")
507
509
  .option("--include-evaluate", "Include the evaluate (test_questions) schema")
508
510
  .option("--skills-env <env>", "Override environment for skill/doc pages (staging|production|preview|custom)")
509
511
  .option("--notion", "[deprecated] Fetch skills and AGENTS.md from Notion instead of GitHub")
@@ -557,6 +559,87 @@ program
557
559
  await handleError(e);
558
560
  }
559
561
  });
562
+ // ─── scenarios ─────────────────────────────────────────────────────────
563
+ //
564
+ // Evaluation scenarios & scores. All subcommands run from INSIDE an agent
565
+ // project directory (they read agent_management_id / version_id /
566
+ // version_tag from `.auirc`) and are fully NON-INTERACTIVE.
567
+ const scenariosCmd = program
568
+ .command("scenarios")
569
+ .description("Evaluation scenarios & scores — generate, pull, push, and view scores")
570
+ .action(() => {
571
+ scenariosCmd.help();
572
+ });
573
+ scenariosCmd.addHelpText("after", `
574
+ \x1b[1mCommands\x1b[0m
575
+ generate Scaffold scenarios/ (+ intent/) and a skeleton scenarios.aui.json
576
+ pull Pull the latest scenarios bundle (and scores) for this agent
577
+ [--version <n>]
578
+ push Push the scenarios bundle, then the local scores for this version
579
+ [--notes <text>] [--skip-scores]
580
+ score Show local scores (pass/total); --remote lists the version's history
581
+
582
+ \x1b[1mNotes\x1b[0m
583
+ • Run these from inside an agent project directory (one with a .auirc).
584
+ • The agent_management_id / version_id / version_tag are read from .auirc.
585
+ • All commands are non-interactive (safe to script / run from the BFF).
586
+ • Local layout: scenarios/scenarios.aui.json, scenarios/scenarios-scores.aui.json,
587
+ scenarios/intent/ (raw intent files / docs / sample data).
588
+
589
+ \x1b[90m Run aui scenarios <command> --help for the options of each command.\x1b[0m
590
+ `);
591
+ scenariosCmd
592
+ .command("generate")
593
+ .description("Scaffold the scenarios/ folder (intent/ + skeleton scenarios.aui.json). Skill-driven: the coding agent fills in scenarios from the intent files.")
594
+ .action(async (options) => {
595
+ try {
596
+ await scenariosGenerate(options);
597
+ }
598
+ catch (e) {
599
+ await handleError(e);
600
+ }
601
+ });
602
+ scenariosCmd
603
+ .command("pull")
604
+ .description("Pull the latest scenarios bundle (scenarios.aui.json + intent files) and the latest scores for this agent version into scenarios/.")
605
+ .option("--version <n>", "Pull a specific build-bundle version (defaults to latest)")
606
+ .action(async (options) => {
607
+ try {
608
+ if (typeof options.version === "string") {
609
+ const parsed = parseInt(options.version, 10);
610
+ options.version = Number.isNaN(parsed) ? undefined : parsed;
611
+ }
612
+ await scenariosPull(options);
613
+ }
614
+ catch (e) {
615
+ await handleError(e);
616
+ }
617
+ });
618
+ scenariosCmd
619
+ .command("push")
620
+ .description("Push scenarios.aui.json + intent files as a new build bundle, then push scenarios-scores.aui.json (linked to that bundle) for this agent version.")
621
+ .option("--notes <text>", "Free-form note stored on the build bundle")
622
+ .option("--skip-scores", "Push only the build bundle; do not push scenarios-scores.aui.json")
623
+ .action(async (options) => {
624
+ try {
625
+ await scenariosPush(options);
626
+ }
627
+ catch (e) {
628
+ await handleError(e);
629
+ }
630
+ });
631
+ scenariosCmd
632
+ .command("score")
633
+ .description("Show the local scenarios-scores.aui.json summary. Pass --remote to list this version's recorded score history.")
634
+ .option("--remote", "Also fetch and summarize remote score history")
635
+ .action(async (options) => {
636
+ try {
637
+ await scenariosScore(options);
638
+ }
639
+ catch (e) {
640
+ await handleError(e);
641
+ }
642
+ });
560
643
  // ─── status ───
561
644
  program
562
645
  .command("status")