@mutagent/cli 0.1.47 → 0.1.49

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/dist/bin/cli.js CHANGED
@@ -1062,7 +1062,7 @@ var init_sdk_client = __esm(() => {
1062
1062
 
1063
1063
  // src/bin/cli.ts
1064
1064
  import { Command as Command19 } from "commander";
1065
- import chalk24 from "chalk";
1065
+ import chalk27 from "chalk";
1066
1066
  import { readFileSync as readFileSync11 } from "fs";
1067
1067
  import { join as join9, dirname } from "path";
1068
1068
  import { fileURLToPath } from "url";
@@ -2504,7 +2504,7 @@ Environment Variables:
2504
2504
  // src/commands/prompts/index.ts
2505
2505
  init_errors();
2506
2506
  import { Command as Command6 } from "commander";
2507
- import chalk11 from "chalk";
2507
+ import chalk14 from "chalk";
2508
2508
  import { readFileSync as readFileSync4, existsSync as existsSync4 } from "fs";
2509
2509
 
2510
2510
  // src/lib/ui-links.ts
@@ -4109,7 +4109,7 @@ Examples:
4109
4109
  // src/commands/prompts/optimize.ts
4110
4110
  init_sdk_client();
4111
4111
  import { Command as Command5 } from "commander";
4112
- import chalk10 from "chalk";
4112
+ import chalk13 from "chalk";
4113
4113
  init_errors();
4114
4114
 
4115
4115
  // src/lib/scorecard.ts
@@ -4401,42 +4401,766 @@ function showPromptDiff(original, optimized) {
4401
4401
  console.log("");
4402
4402
  }
4403
4403
 
4404
+ // src/commands/prompts/optimize-watch.ts
4405
+ import chalk12 from "chalk";
4406
+
4407
+ // src/lib/watch-client.ts
4408
+ function toWsUrl(baseUrl) {
4409
+ const url = baseUrl.replace(/\/+$/, "");
4410
+ if (url.startsWith("https://"))
4411
+ return url.replace("https://", "wss://");
4412
+ if (url.startsWith("http://"))
4413
+ return url.replace("http://", "ws://");
4414
+ if (url.startsWith("wss://") || url.startsWith("ws://"))
4415
+ return url;
4416
+ return `ws://${url}`;
4417
+ }
4418
+ function createWatchClient(opts) {
4419
+ const wsUrl = `${toWsUrl(opts.baseUrl)}/ws/optimization`;
4420
+ let ws = null;
4421
+ let closed = false;
4422
+ let lastEventId = 0;
4423
+ let reconnectAttempt = 0;
4424
+ let reconnectTimer = null;
4425
+ let pingInterval = null;
4426
+ const sigintHandler = () => {
4427
+ close();
4428
+ };
4429
+ function schedulePing() {
4430
+ clearPing();
4431
+ pingInterval = setInterval(() => {
4432
+ if (ws?.readyState === WebSocket.OPEN) {
4433
+ ws.send(JSON.stringify({ type: "ping" }));
4434
+ }
4435
+ }, 30000);
4436
+ }
4437
+ function clearPing() {
4438
+ if (pingInterval !== null) {
4439
+ clearInterval(pingInterval);
4440
+ pingInterval = null;
4441
+ }
4442
+ }
4443
+ function scheduleReconnect() {
4444
+ if (closed)
4445
+ return;
4446
+ const delay = Math.min(1000 * Math.pow(2, reconnectAttempt), 1e4);
4447
+ reconnectAttempt++;
4448
+ reconnectTimer = setTimeout(() => {
4449
+ reconnectTimer = null;
4450
+ doConnect();
4451
+ }, delay);
4452
+ }
4453
+ function handleMessage(raw) {
4454
+ let msg;
4455
+ try {
4456
+ msg = JSON.parse(raw);
4457
+ } catch {
4458
+ return;
4459
+ }
4460
+ if (msg.type === "event" && msg.event?.id !== undefined) {
4461
+ lastEventId = msg.event.id;
4462
+ }
4463
+ if (msg.type === "error") {
4464
+ opts.onError(new Error(msg.error ?? "Unknown WebSocket error"));
4465
+ return;
4466
+ }
4467
+ if (msg.type !== "event" || !msg.event)
4468
+ return;
4469
+ const { eventType, iteration, stage, data } = msg.event;
4470
+ switch (eventType) {
4471
+ case "stage:completed":
4472
+ opts.onStageComplete(stage ?? "unknown", iteration ?? 0, data?.stageResult ?? data ?? { type: "unknown" });
4473
+ break;
4474
+ case "iteration:completed":
4475
+ opts.onIterationComplete(iteration ?? 0, data?.score ?? data?.highestScore ?? 0);
4476
+ break;
4477
+ case "job:completed": {
4478
+ const finalScore = data?.bestScore ?? 0;
4479
+ opts.onJobComplete(finalScore);
4480
+ close();
4481
+ break;
4482
+ }
4483
+ case "job:failed":
4484
+ opts.onError(new Error(data?.error ?? "Optimization job failed"));
4485
+ close();
4486
+ break;
4487
+ default:
4488
+ break;
4489
+ }
4490
+ }
4491
+ function doConnect() {
4492
+ return new Promise((resolve3, reject) => {
4493
+ if (closed) {
4494
+ reject(new Error("Client is closed"));
4495
+ return;
4496
+ }
4497
+ try {
4498
+ ws = new WebSocket(wsUrl, {
4499
+ headers: {
4500
+ "x-api-key": opts.token,
4501
+ "x-workspace-id": opts.workspaceId
4502
+ }
4503
+ });
4504
+ } catch (err) {
4505
+ reject(err instanceof Error ? err : new Error(String(err)));
4506
+ return;
4507
+ }
4508
+ let settled = false;
4509
+ ws.onopen = () => {
4510
+ reconnectAttempt = 0;
4511
+ ws?.send(JSON.stringify({
4512
+ type: "subscribe",
4513
+ jobId: opts.jobId,
4514
+ workspaceId: opts.workspaceId,
4515
+ afterEventId: lastEventId
4516
+ }));
4517
+ schedulePing();
4518
+ if (!settled) {
4519
+ settled = true;
4520
+ resolve3();
4521
+ }
4522
+ };
4523
+ ws.onmessage = (event) => {
4524
+ handleMessage(typeof event.data === "string" ? event.data : String(event.data));
4525
+ };
4526
+ ws.onerror = () => {
4527
+ if (!settled) {
4528
+ settled = true;
4529
+ reject(new Error("WebSocket error"));
4530
+ }
4531
+ };
4532
+ ws.onclose = () => {
4533
+ clearPing();
4534
+ if (!settled) {
4535
+ settled = true;
4536
+ reject(new Error("WebSocket closed before open"));
4537
+ }
4538
+ if (!closed) {
4539
+ scheduleReconnect();
4540
+ }
4541
+ };
4542
+ });
4543
+ }
4544
+ async function connect() {
4545
+ process.on("SIGINT", sigintHandler);
4546
+ await doConnect();
4547
+ }
4548
+ function close() {
4549
+ if (closed)
4550
+ return;
4551
+ closed = true;
4552
+ clearPing();
4553
+ if (reconnectTimer !== null) {
4554
+ clearTimeout(reconnectTimer);
4555
+ reconnectTimer = null;
4556
+ }
4557
+ process.removeListener("SIGINT", sigintHandler);
4558
+ if (ws && ws.readyState === WebSocket.OPEN) {
4559
+ ws.send(JSON.stringify({ type: "unsubscribe", jobId: opts.jobId }));
4560
+ ws.close();
4561
+ }
4562
+ ws = null;
4563
+ }
4564
+ return { connect, close };
4565
+ }
4566
+
4567
+ // src/lib/stage-cards.ts
4568
+ import chalk11 from "chalk";
4569
+
4570
+ // src/lib/prompt-diff.ts
4571
+ import chalk10 from "chalk";
4572
+ function computeLcsTable(a, b) {
4573
+ const m = a.length;
4574
+ const n = b.length;
4575
+ const table = Array.from({ length: m + 1 }, () => new Array(n + 1).fill(0));
4576
+ for (let i = 1;i <= m; i++) {
4577
+ const row = table[i];
4578
+ const prevRow = table[i - 1];
4579
+ for (let j = 1;j <= n; j++) {
4580
+ if (a[i - 1] === b[j - 1]) {
4581
+ const prev = prevRow?.[j - 1] ?? 0;
4582
+ if (row)
4583
+ row[j] = prev + 1;
4584
+ } else {
4585
+ const fromAbove = prevRow?.[j] ?? 0;
4586
+ const fromLeft = row?.[j - 1] ?? 0;
4587
+ if (row)
4588
+ row[j] = Math.max(fromAbove, fromLeft);
4589
+ }
4590
+ }
4591
+ }
4592
+ return table;
4593
+ }
4594
+ function backtrackDiff(table, a, b) {
4595
+ const result = [];
4596
+ let i = a.length;
4597
+ let j = b.length;
4598
+ while (i > 0 || j > 0) {
4599
+ if (i > 0 && j > 0 && a[i - 1] === b[j - 1]) {
4600
+ result.push({
4601
+ type: "equal",
4602
+ content: a[i - 1] ?? "",
4603
+ oldIdx: i - 1,
4604
+ newIdx: j - 1
4605
+ });
4606
+ i--;
4607
+ j--;
4608
+ } else if (j > 0 && (i === 0 || (table[i]?.[j - 1] ?? 0) >= (table[i - 1]?.[j] ?? 0))) {
4609
+ result.push({ type: "add", content: b[j - 1] ?? "", newIdx: j - 1 });
4610
+ j--;
4611
+ } else {
4612
+ result.push({ type: "remove", content: a[i - 1] ?? "", oldIdx: i - 1 });
4613
+ i--;
4614
+ }
4615
+ }
4616
+ return result.reverse();
4617
+ }
4618
+ function buildHunks(rawLines, contextLines) {
4619
+ const changeIndices = [];
4620
+ for (let i = 0;i < rawLines.length; i++) {
4621
+ const raw = rawLines[i];
4622
+ if (raw && raw.type !== "equal") {
4623
+ changeIndices.push(i);
4624
+ }
4625
+ }
4626
+ if (changeIndices.length === 0)
4627
+ return [];
4628
+ const firstIdx = changeIndices[0] ?? 0;
4629
+ const groups = [];
4630
+ let groupStart = firstIdx;
4631
+ let groupEnd = firstIdx;
4632
+ for (let i = 1;i < changeIndices.length; i++) {
4633
+ const idx = changeIndices[i] ?? 0;
4634
+ if (idx - groupEnd <= contextLines * 2) {
4635
+ groupEnd = idx;
4636
+ } else {
4637
+ groups.push({ start: groupStart, end: groupEnd });
4638
+ groupStart = idx;
4639
+ groupEnd = idx;
4640
+ }
4641
+ }
4642
+ groups.push({ start: groupStart, end: groupEnd });
4643
+ const hunks = [];
4644
+ for (const group of groups) {
4645
+ const rangeStart = Math.max(0, group.start - contextLines);
4646
+ const rangeEnd = Math.min(rawLines.length - 1, group.end + contextLines);
4647
+ const lines = [];
4648
+ let oldLine = 0;
4649
+ let newLine = 0;
4650
+ for (let i = 0;i < rangeStart; i++) {
4651
+ const raw = rawLines[i];
4652
+ if (raw && (raw.type === "equal" || raw.type === "remove"))
4653
+ oldLine++;
4654
+ if (raw && (raw.type === "equal" || raw.type === "add"))
4655
+ newLine++;
4656
+ }
4657
+ const oldStart = oldLine + 1;
4658
+ const newStart = newLine + 1;
4659
+ let oldCount = 0;
4660
+ let newCount = 0;
4661
+ for (let i = rangeStart;i <= rangeEnd; i++) {
4662
+ const raw = rawLines[i];
4663
+ if (!raw)
4664
+ continue;
4665
+ if (raw.type === "equal") {
4666
+ oldLine++;
4667
+ newLine++;
4668
+ oldCount++;
4669
+ newCount++;
4670
+ lines.push({
4671
+ type: "context",
4672
+ content: raw.content,
4673
+ oldLineNo: oldLine,
4674
+ newLineNo: newLine
4675
+ });
4676
+ } else if (raw.type === "remove") {
4677
+ oldLine++;
4678
+ oldCount++;
4679
+ lines.push({
4680
+ type: "remove",
4681
+ content: raw.content,
4682
+ oldLineNo: oldLine
4683
+ });
4684
+ } else {
4685
+ newLine++;
4686
+ newCount++;
4687
+ lines.push({
4688
+ type: "add",
4689
+ content: raw.content,
4690
+ newLineNo: newLine
4691
+ });
4692
+ }
4693
+ }
4694
+ const header = `@@ -${String(oldStart)},${String(oldCount)} +${String(newStart)},${String(newCount)} @@`;
4695
+ lines.unshift({ type: "hunk-header", content: header });
4696
+ hunks.push({ oldStart, oldCount, newStart, newCount, lines });
4697
+ }
4698
+ return hunks;
4699
+ }
4700
+ function generatePromptDiff(original, mutated, contextLines = 3) {
4701
+ if (original === mutated)
4702
+ return [];
4703
+ const oldLines = original.split(`
4704
+ `);
4705
+ const newLines = mutated.split(`
4706
+ `);
4707
+ const lcsTable = computeLcsTable(oldLines, newLines);
4708
+ const rawDiff = backtrackDiff(lcsTable, oldLines, newLines);
4709
+ const hunks = buildHunks(rawDiff, contextLines);
4710
+ const result = [];
4711
+ for (const hunk of hunks) {
4712
+ result.push(...hunk.lines);
4713
+ }
4714
+ return result;
4715
+ }
4716
+ function renderDiffLines(lines, options) {
4717
+ const maxLines = options?.maxLines ?? 40;
4718
+ const noColor = options?.noColor ?? false;
4719
+ if (lines.length === 0)
4720
+ return "";
4721
+ const outputLines = [];
4722
+ let linesRendered = 0;
4723
+ let truncated = false;
4724
+ for (const line of lines) {
4725
+ if (linesRendered >= maxLines) {
4726
+ truncated = true;
4727
+ break;
4728
+ }
4729
+ let text;
4730
+ switch (line.type) {
4731
+ case "hunk-header":
4732
+ text = noColor ? line.content : chalk10.cyan(line.content);
4733
+ break;
4734
+ case "add":
4735
+ text = noColor ? `+${line.content}` : chalk10.green(`+${line.content}`);
4736
+ break;
4737
+ case "remove":
4738
+ text = noColor ? `-${line.content}` : chalk10.red(`-${line.content}`);
4739
+ break;
4740
+ case "context":
4741
+ text = noColor ? ` ${line.content}` : chalk10.dim(` ${line.content}`);
4742
+ break;
4743
+ }
4744
+ outputLines.push(text);
4745
+ linesRendered++;
4746
+ }
4747
+ if (truncated) {
4748
+ const remaining = lines.length - maxLines;
4749
+ const summary = `... ${String(remaining)} more lines changed`;
4750
+ outputLines.push(noColor ? summary : chalk10.yellow(summary));
4751
+ }
4752
+ return outputLines.join(`
4753
+ `);
4754
+ }
4755
+
4756
+ // src/lib/stage-cards.ts
4757
+ var ANSI_REGEX = /\u001B\[[0-9;]*m/g;
4758
+ var BOX_WIDTH = 66;
4759
+ function stripAnsi(text) {
4760
+ return text.replace(ANSI_REGEX, "");
4761
+ }
4762
+ function pad(text, width) {
4763
+ const stripped = stripAnsi(text);
4764
+ const remaining = width - stripped.length;
4765
+ return remaining > 0 ? text + " ".repeat(remaining) : text;
4766
+ }
4767
+ function line(text) {
4768
+ return `│ ${pad(text, BOX_WIDTH - 2)} │`;
4769
+ }
4770
+ function topBorder(title) {
4771
+ const titleStr = ` ${title} `;
4772
+ const remaining = BOX_WIDTH - titleStr.length - 1;
4773
+ return `┌─${titleStr}${"─".repeat(Math.max(0, remaining))}┐`;
4774
+ }
4775
+ function bottomBorder() {
4776
+ return `└${"─".repeat(BOX_WIDTH)}┘`;
4777
+ }
4778
+ function emptyLine() {
4779
+ return line("");
4780
+ }
4781
+ function formatScore2(score) {
4782
+ if (score >= 0.8)
4783
+ return chalk11.green(score.toFixed(2));
4784
+ if (score >= 0.5)
4785
+ return chalk11.yellow(score.toFixed(2));
4786
+ return chalk11.red(score.toFixed(2));
4787
+ }
4788
+ function scoreBar(score, width = 20) {
4789
+ const filled = Math.round(score * width);
4790
+ return "█".repeat(filled) + "░".repeat(width - filled);
4791
+ }
4792
+ function renderBaselineEvalCard(data) {
4793
+ const lines = [];
4794
+ lines.push(topBorder("\uD83D\uDCCA Baseline Evaluation"));
4795
+ lines.push(line(`Overall Score: ${formatScore2(data.overallScore)}`));
4796
+ lines.push(emptyLine());
4797
+ lines.push(line(`${"Criterion".padEnd(20)}${"Score".padEnd(8)}`));
4798
+ lines.push(line("─".repeat(40)));
4799
+ for (const criterion of data.scores) {
4800
+ const name = criterion.name.length > 18 ? criterion.name.substring(0, 15) + "..." : criterion.name;
4801
+ const scoreStr = formatScore2(criterion.score);
4802
+ const bar = scoreBar(criterion.score);
4803
+ lines.push(line(`${name.padEnd(20)}${scoreStr} ${bar}`));
4804
+ }
4805
+ lines.push(emptyLine());
4806
+ const durationStr = data.duration < 1 ? `${(data.duration * 1000).toFixed(0)}ms` : `${data.duration.toFixed(1)}s`;
4807
+ const footer = `Dataset: ${String(data.totalItems)} items │ Pass: ${String(data.passCount)} │ Fail: ${String(data.failCount)} │ Duration: ${durationStr}`;
4808
+ lines.push(line(footer));
4809
+ lines.push(bottomBorder());
4810
+ return lines.join(`
4811
+ `);
4812
+ }
4813
+ var SEVERITY_ORDER = {
4814
+ critical: 0,
4815
+ high: 1,
4816
+ medium: 2,
4817
+ low: 3
4818
+ };
4819
+ function severityRank(severity) {
4820
+ return SEVERITY_ORDER[severity.toLowerCase()] ?? 4;
4821
+ }
4822
+ function renderInsightsCard(data) {
4823
+ const lines = [];
4824
+ const sorted = [...data.categories].sort((a, b) => severityRank(a.severity) - severityRank(b.severity));
4825
+ const categoryCount = sorted.length;
4826
+ lines.push(topBorder("\uD83D\uDD0D Failure Insights"));
4827
+ lines.push(line(`${String(data.totalFailures)} failures across ${String(categoryCount)} categories`));
4828
+ lines.push(emptyLine());
4829
+ for (const cat of sorted) {
4830
+ const itemWord = cat.count === 1 ? "item" : "items";
4831
+ const label = `■ ${cat.name} (${cat.severity})`;
4832
+ const countStr = `${String(cat.count)} ${itemWord}`;
4833
+ const labelLen = stripAnsi(label).length;
4834
+ const countLen = countStr.length;
4835
+ const dashCount = Math.max(2, BOX_WIDTH - 4 - labelLen - countLen - 2);
4836
+ lines.push(line(`${label} ${"─".repeat(dashCount)} ${countStr}`));
4837
+ if (cat.example) {
4838
+ const maxExampleLen = 78;
4839
+ const truncated = cat.example.length > maxExampleLen ? cat.example.substring(0, maxExampleLen - 3) + "..." : cat.example;
4840
+ lines.push(line(chalk11.dim(` "${truncated}"`)));
4841
+ }
4842
+ }
4843
+ lines.push(emptyLine());
4844
+ const parts = [];
4845
+ const orderedKeys = ["critical", "high", "medium", "low"];
4846
+ for (const key of orderedKeys) {
4847
+ const count = data.severityDistribution[key];
4848
+ if (count !== undefined && count > 0) {
4849
+ parts.push(`${String(count)} ${key}`);
4850
+ }
4851
+ }
4852
+ for (const [key, count] of Object.entries(data.severityDistribution)) {
4853
+ if (!orderedKeys.includes(key) && count > 0) {
4854
+ parts.push(`${String(count)} ${key}`);
4855
+ }
4856
+ }
4857
+ lines.push(line(`Severity: ${parts.join(" │ ")}`));
4858
+ lines.push(bottomBorder());
4859
+ return lines.join(`
4860
+ `);
4861
+ }
4862
+ function renderPromptDiffCard(data) {
4863
+ const lines = [];
4864
+ const applied = data.mutations.filter((m) => m.status === "applied");
4865
+ const rejected = data.mutations.filter((m) => m.status !== "applied");
4866
+ const appliedCount = applied.length;
4867
+ const rejectedCount = rejected.length;
4868
+ const summary = rejectedCount > 0 ? `${String(appliedCount)} mutations applied, ${String(rejectedCount)} rejected` : `${String(appliedCount)} mutations applied`;
4869
+ lines.push(topBorder("✏️ Prompt Mutations Applied"));
4870
+ lines.push(line(summary));
4871
+ lines.push(emptyLine());
4872
+ const diffLines = generatePromptDiff(data.originalPrompt, data.mutatedPrompt);
4873
+ const rendered = renderDiffLines(diffLines, { maxLines: 20 });
4874
+ if (rendered) {
4875
+ for (const diffLine of rendered.split(`
4876
+ `)) {
4877
+ lines.push(line(` ${diffLine}`));
4878
+ }
4879
+ lines.push(emptyLine());
4880
+ }
4881
+ for (const mutation of data.mutations) {
4882
+ const icon = mutation.status === "applied" ? chalk11.green("✓") : chalk11.red("✗");
4883
+ const target = mutation.target.length > 30 ? mutation.target.substring(0, 27) + "..." : mutation.target;
4884
+ if (mutation.status === "applied") {
4885
+ const confStr = `confidence: ${mutation.confidence.toFixed(2)}`;
4886
+ const targetPad = target.padEnd(30);
4887
+ lines.push(line(`${icon} ${targetPad} ${chalk11.dim("──")} ${confStr}`));
4888
+ } else {
4889
+ const reason = mutation.rationale ? `rejected: ${mutation.rationale}` : `rejected`;
4890
+ const truncReason = reason.length > 30 ? reason.substring(0, 27) + "..." : reason;
4891
+ const targetPad = target.padEnd(30);
4892
+ lines.push(line(`${icon} ${targetPad} ${chalk11.dim("──")} ${truncReason}`));
4893
+ }
4894
+ }
4895
+ lines.push(emptyLine());
4896
+ const origLines = data.originalPrompt.split(`
4897
+ `).length;
4898
+ const mutLines = data.mutatedPrompt.split(`
4899
+ `).length;
4900
+ const netChange = mutLines - origLines;
4901
+ const netStr = netChange >= 0 ? `+${String(netChange)}` : String(netChange);
4902
+ lines.push(line(`Net change: ${netStr} lines │ Original: ${String(origLines)} → Mutated: ${String(mutLines)} lines`));
4903
+ lines.push(bottomBorder());
4904
+ return lines.join(`
4905
+ `);
4906
+ }
4907
+ function renderRerunAccuracyCard(data) {
4908
+ const lines = [];
4909
+ const pctChange = data.baselineScore > 0 ? (data.delta / data.baselineScore * 100).toFixed(1) : "0.0";
4910
+ const sign = data.delta >= 0 ? "+" : "";
4911
+ const deltaStr = `${sign}${data.delta.toFixed(2)}, ${sign}${pctChange}%`;
4912
+ const bar = scoreBar(data.newScore, 10);
4913
+ const scoreTransition = `Score: ${formatScore2(data.baselineScore)} → ${formatScore2(data.newScore)} (${deltaStr})`;
4914
+ lines.push(topBorder("\uD83C\uDFAF Re-run Results"));
4915
+ lines.push(line(`${scoreTransition}${" ".repeat(Math.max(0, 4))}${bar}`));
4916
+ lines.push(emptyLine());
4917
+ lines.push(line(`${"Criterion".padEnd(20)}${"Before".padEnd(9)}${"After".padEnd(9)}${"Delta".padEnd(10)}`));
4918
+ lines.push(line("─".repeat(50)));
4919
+ for (const criterion of data.perCriterion) {
4920
+ const name = criterion.name.length > 18 ? criterion.name.substring(0, 15) + "..." : criterion.name;
4921
+ const diff = criterion.after - criterion.before;
4922
+ const diffSign = diff >= 0 ? "+" : "";
4923
+ const arrow = diff > 0 ? chalk11.green("↑") : diff < 0 ? chalk11.red("↓") : chalk11.dim("─");
4924
+ const diffStr = `${diffSign}${diff.toFixed(2)}`;
4925
+ lines.push(line(`${name.padEnd(20)}${formatScore2(criterion.before).padEnd(9)}${formatScore2(criterion.after).padEnd(9)}${diffStr} ${arrow}`));
4926
+ }
4927
+ lines.push(emptyLine());
4928
+ const itemsSummary = `Items: ${String(data.improvedItems)} improved │ ${String(data.regressedItems)} regressed │ ${String(data.unchangedItems)} unchanged`;
4929
+ lines.push(line(itemsSummary));
4930
+ lines.push(bottomBorder());
4931
+ return lines.join(`
4932
+ `);
4933
+ }
4934
+ function renderStageCard(stage, data) {
4935
+ switch (stage) {
4936
+ case "baseline-eval":
4937
+ return renderBaselineEvalCard(data);
4938
+ case "insights":
4939
+ return renderInsightsCard(data);
4940
+ case "prompt-diff":
4941
+ return renderPromptDiffCard(data);
4942
+ case "rerun-accuracy":
4943
+ return renderRerunAccuracyCard(data);
4944
+ default:
4945
+ return `Unknown stage: ${stage}`;
4946
+ }
4947
+ }
4948
+
4949
+ // src/commands/prompts/optimize-watch.ts
4950
+ init_sdk_client();
4951
+ init_config();
4952
+ init_errors();
4953
+ var BOX_WIDTH2 = 66;
4954
+ function pad2(text, width) {
4955
+ const stripped = text.replace(/\u001B\[[0-9;]*m/g, "");
4956
+ const remaining = width - stripped.length;
4957
+ return remaining > 0 ? text + " ".repeat(remaining) : text;
4958
+ }
4959
+ function line2(text) {
4960
+ return `│ ${pad2(text, BOX_WIDTH2 - 2)} │`;
4961
+ }
4962
+ function renderIterationBoundaryCard(opts) {
4963
+ const { iteration, maxIterations, bestScore, baselineScore } = opts;
4964
+ const delta = baselineScore !== undefined ? bestScore - baselineScore : 0;
4965
+ const deltaStr = delta >= 0 ? `+${delta.toFixed(2)}` : delta.toFixed(2);
4966
+ const improving = delta > 0.001;
4967
+ const statusStr = improving ? "Improving" : "Converging";
4968
+ const title = ` \uD83D\uDD04 Iteration ${String(iteration)} of ${String(maxIterations)} `;
4969
+ const remaining = BOX_WIDTH2 - title.length - 1;
4970
+ const topBorder2 = `┌─${title}${"─".repeat(Math.max(0, remaining))}┐`;
4971
+ const bottomBorder2 = `└${"─".repeat(BOX_WIDTH2)}┘`;
4972
+ const lines = [];
4973
+ lines.push(topBorder2);
4974
+ lines.push(line2(`Best Score: ${bestScore.toFixed(2)} (${deltaStr} from baseline)`));
4975
+ lines.push(line2(`Status: ${statusStr}`));
4976
+ lines.push(bottomBorder2);
4977
+ return lines.join(`
4978
+ `);
4979
+ }
4980
+ function getWatchClientConfig() {
4981
+ const config = loadConfig();
4982
+ const apiKey = getApiKey();
4983
+ if (!apiKey) {
4984
+ throw new MutagentError("AUTH_REQUIRED", "API key is required for watch mode", "Run: mutagent auth login");
4985
+ }
4986
+ const baseUrl = config.endpoint ?? "https://api.mutagent.io";
4987
+ const workspaceId = config.defaultWorkspace ?? "";
4988
+ if (!workspaceId) {
4989
+ throw new MutagentError("WORKSPACE_REQUIRED", "A workspace must be configured for watch mode", "Run: mutagent config set defaultWorkspace <workspace-id>");
4990
+ }
4991
+ return { baseUrl, workspaceId, token: apiKey };
4992
+ }
4993
+ async function startWatchStream(jobId, isJson, maxIterations, baselineScore) {
4994
+ const { baseUrl, workspaceId, token } = getWatchClientConfig();
4995
+ return new Promise((resolve3, reject) => {
4996
+ const client = createWatchClient({
4997
+ baseUrl,
4998
+ jobId,
4999
+ workspaceId,
5000
+ token,
5001
+ onStageComplete: (stage, _iteration, data) => {
5002
+ if (isJson) {
5003
+ console.log(JSON.stringify({ type: "stage", stage, data }));
5004
+ } else {
5005
+ const card = renderStageCard(stage, data);
5006
+ console.log(card);
5007
+ console.log("");
5008
+ }
5009
+ },
5010
+ onIterationComplete: (iteration, bestScore) => {
5011
+ if (isJson) {
5012
+ console.log(JSON.stringify({ type: "iteration", iteration, bestScore }));
5013
+ } else {
5014
+ const card = renderIterationBoundaryCard({
5015
+ iteration,
5016
+ maxIterations: maxIterations ?? iteration,
5017
+ bestScore,
5018
+ baselineScore
5019
+ });
5020
+ console.log(card);
5021
+ console.log("");
5022
+ }
5023
+ },
5024
+ onJobComplete: (finalScore) => {
5025
+ if (isJson) {
5026
+ console.log(JSON.stringify({ type: "job_complete", finalScore }));
5027
+ } else {
5028
+ console.log(chalk12.green(`✓ Optimization complete! Final score: ${finalScore.toFixed(2)}`));
5029
+ console.log(chalk12.dim(` View results: mutagent prompts optimize results ${jobId}`));
5030
+ }
5031
+ resolve3();
5032
+ },
5033
+ onError: (error) => {
5034
+ if (isJson) {
5035
+ console.log(JSON.stringify({ type: "error", error: error.message }));
5036
+ } else {
5037
+ console.error(chalk12.red(`✗ Watch error: ${error.message}`));
5038
+ }
5039
+ reject(error);
5040
+ }
5041
+ });
5042
+ client.connect().catch(reject);
5043
+ });
5044
+ }
5045
+ async function renderCompletedJob(jobId, isJson) {
5046
+ const client = getSDKClient();
5047
+ const results = await client.getOptimizationResults(jobId);
5048
+ const resultData = results;
5049
+ if (isJson) {
5050
+ const output = new OutputFormatter("json");
5051
+ output.output({
5052
+ ...resultData,
5053
+ _links: { optimizer: optimizerLink(jobId) }
5054
+ });
5055
+ } else {
5056
+ renderScorecard(resultData);
5057
+ }
5058
+ }
5059
+ async function watchAction(jobId, options, parentCommand) {
5060
+ const isJson = options.json ?? getJsonFlag(parentCommand);
5061
+ const output = new OutputFormatter(isJson ? "json" : "table");
5062
+ try {
5063
+ const client = getSDKClient();
5064
+ const status = await client.getOptimizationStatus(jobId);
5065
+ switch (status.status) {
5066
+ case "completed":
5067
+ if (!isJson) {
5068
+ output.info("Job already completed. Rendering results...");
5069
+ console.log("");
5070
+ }
5071
+ await renderCompletedJob(jobId, isJson);
5072
+ break;
5073
+ case "running":
5074
+ case "queued":
5075
+ if (!isJson) {
5076
+ renderOptimizationStatusCard(status);
5077
+ console.log(chalk12.dim(`Watching for live updates...
5078
+ `));
5079
+ }
5080
+ await startWatchStream(jobId, isJson, status.maxIterations, status.bestScore);
5081
+ break;
5082
+ case "failed":
5083
+ if (isJson) {
5084
+ output.output({
5085
+ success: false,
5086
+ error: "Optimization job failed",
5087
+ status: status.status,
5088
+ jobId,
5089
+ message: status.message
5090
+ });
5091
+ } else {
5092
+ console.error(chalk12.red(`✗ Optimization job ${jobId} failed.`));
5093
+ if (status.message) {
5094
+ console.error(chalk12.dim(` ${status.message}`));
5095
+ }
5096
+ }
5097
+ process.exitCode = 1;
5098
+ break;
5099
+ case "cancelled":
5100
+ if (isJson) {
5101
+ output.output({
5102
+ success: false,
5103
+ error: "Optimization job was cancelled",
5104
+ status: status.status,
5105
+ jobId
5106
+ });
5107
+ } else {
5108
+ console.error(chalk12.yellow(`Optimization job ${jobId} was cancelled.`));
5109
+ }
5110
+ break;
5111
+ default:
5112
+ if (isJson) {
5113
+ output.output({
5114
+ success: false,
5115
+ error: `Unexpected job status: ${status.status}`,
5116
+ status: status.status,
5117
+ jobId
5118
+ });
5119
+ } else {
5120
+ console.error(chalk12.yellow(`Unexpected job status: ${status.status}`));
5121
+ }
5122
+ break;
5123
+ }
5124
+ } catch (error) {
5125
+ handleError(error, isJson);
5126
+ }
5127
+ }
5128
+
4404
5129
  // src/commands/prompts/optimize.ts
4405
5130
  function registerOptimizeCommands(prompts) {
4406
5131
  const optimize = new Command5("optimize").description("Manage prompt optimization jobs").addHelpText("after", `
4407
5132
  Examples:
4408
- ${chalk10.dim("$")} mutagent prompts optimize start <prompt-id> --dataset <dataset-id> --evaluation <eval-id>
4409
- ${chalk10.dim("$")} mutagent prompts optimize status <job-id>
4410
- ${chalk10.dim("$")} mutagent prompts optimize results <job-id>
5133
+ ${chalk13.dim("$")} mutagent prompts optimize start <prompt-id> --dataset <dataset-id> --evaluation <eval-id>
5134
+ ${chalk13.dim("$")} mutagent prompts optimize status <job-id>
5135
+ ${chalk13.dim("$")} mutagent prompts optimize results <job-id>
4411
5136
 
4412
- Workflow: start -> status (poll) -> results
4413
- `).action(() => {
5137
+ Workflow: start -> status (poll) -> results | start --watch | watch <job-id>`).action(() => {
4414
5138
  optimize.help();
4415
5139
  });
4416
5140
  prompts.addCommand(optimize);
4417
- optimize.command("start").description("Start prompt optimization").argument("<prompt-id>", "Prompt ID (from: mutagent prompts list)").requiredOption("-d, --dataset <id>", "Dataset ID for optimization (from: mutagent prompts dataset list <prompt-id>)").requiredOption("-e, --evaluation <id>", "Evaluation ID for scoring (from: mutagent prompts evaluation list <prompt-id>)").option("--max-iterations <n>", "Max optimization iterations (default: 1)").option("--target-score <n>", "Target accuracy 0-1 (default: 0.8)").option("--patience <n>", "Iterations without improvement before stopping").option("--model <model-id>", 'Target LLM model (e.g., "claude-sonnet-4-5-20250929")').option("--eval-model <model-id>", "Evaluation model (defaults to target model)").addHelpText("after", `
5141
+ optimize.command("start").description("Start prompt optimization").argument("<prompt-id>", "Prompt ID (from: mutagent prompts list)").requiredOption("-d, --dataset <id>", "Dataset ID for optimization (from: mutagent prompts dataset list <prompt-id>)").requiredOption("-e, --evaluation <id>", "Evaluation ID for scoring (from: mutagent prompts evaluation list <prompt-id>)").option("--max-iterations <n>", "Max optimization iterations (default: 1)").option("--target-score <n>", "Target accuracy 0-1 (default: 0.8)").option("--patience <n>", "Iterations without improvement before stopping").option("--model <model-id>", 'Target LLM model (e.g., "claude-sonnet-4-5-20250929")').option("--eval-model <model-id>", "Evaluation model (defaults to target model)").option("--watch", "Watch live progress with stage cards", false).addHelpText("after", `
4418
5142
  Examples:
4419
- ${chalk10.dim("$")} mutagent prompts optimize start <prompt-id> --dataset <dataset-id> --evaluation <eval-id>
4420
- ${chalk10.dim("$")} mutagent prompts optimize start <prompt-id> --dataset <dataset-id> --evaluation <eval-id> --max-iterations 5
4421
- ${chalk10.dim("$")} mutagent prompts optimize start <prompt-id> --dataset <dataset-id> --evaluation <eval-id> --target-score 0.95 --model claude-sonnet-4-5-20250929
4422
- ${chalk10.dim("$")} mutagent prompts optimize start <prompt-id> --dataset <dataset-id> --evaluation <eval-id> --json
4423
- ${chalk10.yellow("Pre-Optimization Checklist (auto-validated by preflight):")}
4424
- □ inputSchema REQUIRED ${chalk10.dim("(hard error if missing — blocks optimization)")}
4425
- □ outputSchema REQUIRED ${chalk10.dim("(hard error if missing — blocks optimization)")}
4426
- □ Evaluation criteria ${chalk10.dim("(warns if no evaluationParameter set)")}
4427
- □ Dataset items ${chalk10.dim("(warns if expectedOutput missing)")}
4428
- □ Criteria ↔ Schema ${chalk10.dim("(warns if criteria reference unknown fields)")}
5143
+ ${chalk13.dim("$")} mutagent prompts optimize start <prompt-id> --dataset <dataset-id> --evaluation <eval-id>
5144
+ ${chalk13.dim("$")} mutagent prompts optimize start <prompt-id> --dataset <dataset-id> --evaluation <eval-id> --max-iterations 5
5145
+ ${chalk13.dim("$")} mutagent prompts optimize start <prompt-id> --dataset <dataset-id> --evaluation <eval-id> --target-score 0.95 --model claude-sonnet-4-5-20250929
5146
+ ${chalk13.dim("$")} mutagent prompts optimize start <prompt-id> --dataset <dataset-id> --evaluation <eval-id> --json
5147
+ ${chalk13.yellow("Pre-Optimization Checklist (auto-validated by preflight):")}
5148
+ □ inputSchema REQUIRED ${chalk13.dim("(hard error if missing — blocks optimization)")}
5149
+ □ outputSchema REQUIRED ${chalk13.dim("(hard error if missing — blocks optimization)")}
5150
+ □ Evaluation criteria ${chalk13.dim("(warns if no evaluationParameter set)")}
5151
+ □ Dataset items ${chalk13.dim("(warns if expectedOutput missing)")}
5152
+ □ Criteria ↔ Schema ${chalk13.dim("(warns if criteria reference unknown fields)")}
4429
5153
 
4430
5154
  ${PREREQUISITES_TEXT}
4431
5155
 
4432
- ${chalk10.dim("Monitor progress with: mutagent prompts optimize status <job-id>")}
5156
+ ${chalk13.dim("Monitor progress with: mutagent prompts optimize status <job-id>")}
4433
5157
 
4434
- ${chalk10.yellow(`⚠ COST WARNING — AI Agent:
5158
+ ${chalk13.yellow(`⚠ COST WARNING — AI Agent:
4435
5159
  Default is 1 iteration. Do NOT increase --max-iterations unless the user
4436
5160
  explicitly requests it. Each iteration incurs LLM costs. Starting with
4437
5161
  max-iterations > 1 without user consent is a protocol violation.`)}
4438
5162
 
4439
- ${chalk10.yellow("AI Agent: ALWAYS append --json to this command.")}
5163
+ ${chalk13.yellow("AI Agent: ALWAYS append --json to this command.")}
4440
5164
  `).action(async (promptId, options) => {
4441
5165
  const isJson = getJsonFlag(prompts);
4442
5166
  const output = new OutputFormatter(isJson ? "json" : "table");
@@ -4563,13 +5287,13 @@ ${chalk10.yellow("AI Agent: ALWAYS append --json to this command.")}
4563
5287
  return;
4564
5288
  }
4565
5289
  for (const [name, check] of hardFailures) {
4566
- console.error(chalk10.red(`Error: ${name} — ${check.error ?? "Failed"}`));
5290
+ console.error(chalk13.red(`Error: ${name} — ${check.error ?? "Failed"}`));
4567
5291
  }
4568
5292
  if (!preflightChecks.outputSchema.passed) {
4569
- console.error(chalk10.dim(` Update with: mutagent prompts update ${promptId} -d '{"outputSchema":{"type":"object","properties":{"result":{"type":"string"}}}}'`));
5293
+ console.error(chalk13.dim(` Update with: mutagent prompts update ${promptId} -d '{"outputSchema":{"type":"object","properties":{"result":{"type":"string"}}}}'`));
4570
5294
  }
4571
5295
  if (!preflightChecks.inputSchema.passed) {
4572
- console.error(chalk10.dim(` Update with: mutagent prompts update ${promptId} --data '{"inputSchema":{"type":"object","properties":{"var1":{"type":"string"}}}}' --json`));
5296
+ console.error(chalk13.dim(` Update with: mutagent prompts update ${promptId} --data '{"inputSchema":{"type":"object","properties":{"var1":{"type":"string"}}}}' --json`));
4573
5297
  }
4574
5298
  process.exitCode = 1;
4575
5299
  return;
@@ -4602,6 +5326,10 @@ ${chalk10.yellow("AI Agent: ALWAYS append --json to this command.")}
4602
5326
  } else {
4603
5327
  renderOptimizationStartCard({ job, promptId, datasetId: options.dataset });
4604
5328
  }
5329
+ if (options.watch) {
5330
+ const maxIter = options.maxIterations ? parseInt(options.maxIterations, 10) : 1;
5331
+ await startWatchStream(job.id, isJson, maxIter);
5332
+ }
4605
5333
  } catch (error) {
4606
5334
  if (error instanceof ApiError) {
4607
5335
  const messages = parseValidationErrors(error);
@@ -4626,16 +5354,16 @@ ${chalk10.yellow("AI Agent: ALWAYS append --json to this command.")}
4626
5354
  suggestions.push("Trial optimization limit reached. Contact support to upgrade.");
4627
5355
  }
4628
5356
  if (!isJson) {
4629
- console.error(chalk10.red(`
5357
+ console.error(chalk13.red(`
4630
5358
  Optimization failed:`));
4631
5359
  for (const msg of messages) {
4632
- console.error(chalk10.red(` ${msg}`));
5360
+ console.error(chalk13.red(` ${msg}`));
4633
5361
  }
4634
5362
  if (suggestions.length > 0) {
4635
- console.error(chalk10.yellow(`
5363
+ console.error(chalk13.yellow(`
4636
5364
  Suggested fixes:`));
4637
5365
  for (const s of suggestions) {
4638
- console.error(chalk10.yellow(` → ${s}`));
5366
+ console.error(chalk13.yellow(` → ${s}`));
4639
5367
  }
4640
5368
  }
4641
5369
  console.error("");
@@ -4647,8 +5375,8 @@ Suggested fixes:`));
4647
5375
  });
4648
5376
  optimize.command("status").description("Check optimization status").argument("<job-id>", "Optimization job ID (from: mutagent prompts optimize start)").addHelpText("after", `
4649
5377
  Examples:
4650
- ${chalk10.dim("$")} mutagent prompts optimize status <job-id>
4651
- ${chalk10.dim("$")} mutagent prompts optimize status <job-id> --json
5378
+ ${chalk13.dim("$")} mutagent prompts optimize status <job-id>
5379
+ ${chalk13.dim("$")} mutagent prompts optimize status <job-id> --json
4652
5380
  `).action(async (jobId) => {
4653
5381
  const isJson = getJsonFlag(prompts);
4654
5382
  const output = new OutputFormatter(isJson ? "json" : "table");
@@ -4672,17 +5400,17 @@ Examples:
4672
5400
  });
4673
5401
  optimize.command("results").description("Get optimization results").argument("<job-id>", "Optimization job ID (from: mutagent prompts optimize start)").option("--apply", "Apply the optimized prompt as new version").option("--diff", "Show the prompt diff (before/after)").addHelpText("after", `
4674
5402
  Examples:
4675
- ${chalk10.dim("$")} mutagent prompts optimize results <job-id> ${chalk10.dim("# view scorecard")}
4676
- ${chalk10.dim("$")} mutagent prompts optimize results <job-id> --diff ${chalk10.dim("# view prompt diff")}
4677
- ${chalk10.dim("$")} mutagent prompts optimize results <job-id> --apply ${chalk10.dim("# apply optimized prompt")}
4678
- ${chalk10.dim("$")} mutagent prompts optimize results <job-id> --json ${chalk10.dim("# structured output")}
5403
+ ${chalk13.dim("$")} mutagent prompts optimize results <job-id> ${chalk13.dim("# view scorecard")}
5404
+ ${chalk13.dim("$")} mutagent prompts optimize results <job-id> --diff ${chalk13.dim("# view prompt diff")}
5405
+ ${chalk13.dim("$")} mutagent prompts optimize results <job-id> --apply ${chalk13.dim("# apply optimized prompt")}
5406
+ ${chalk13.dim("$")} mutagent prompts optimize results <job-id> --json ${chalk13.dim("# structured output")}
4679
5407
 
4680
5408
  After viewing results:
4681
5409
  --apply Apply the optimized prompt (replaces current version)
4682
5410
  --diff Show detailed before/after diff
4683
- ${chalk10.dim("No flag = view scorecard only.")}
5411
+ ${chalk13.dim("No flag = view scorecard only.")}
4684
5412
 
4685
- ${chalk10.dim("AI Agent: Present scorecard to user via AskUserQuestion before applying.")}
5413
+ ${chalk13.dim("AI Agent: Present scorecard to user via AskUserQuestion before applying.")}
4686
5414
  `).action(async (jobId, options) => {
4687
5415
  const isJson = getJsonFlag(prompts);
4688
5416
  const output = new OutputFormatter(isJson ? "json" : "table");
@@ -4754,6 +5482,13 @@ After viewing results:
4754
5482
  handleError(error, isJson);
4755
5483
  }
4756
5484
  });
5485
+ optimize.command("watch").description("Watch optimization job progress with live stage results").argument("<job-id>", "Optimization job ID").option("--json", "Output as JSON with agent directives").addHelpText("after", `
5486
+ Examples:
5487
+ ${chalk13.dim("$")} mutagent prompts optimize watch <job-id>
5488
+ ${chalk13.dim("$")} mutagent prompts optimize watch <job-id> --json
5489
+ ${chalk13.dim("Completed jobs render stored results. Running jobs stream via WebSocket.")}`).action(async (jobId, options) => {
5490
+ await watchAction(jobId, options, prompts);
5491
+ });
4757
5492
  }
4758
5493
 
4759
5494
  // src/commands/prompts/index.ts
@@ -4869,19 +5604,19 @@ function buildResultsScorecardText(resultData) {
4869
5604
  return text;
4870
5605
  }
4871
5606
  var PREREQUISITES_TEXT = `
4872
- ${chalk11.red("Prerequisites (required):")}
4873
- 1. Evaluation criteria defined ${chalk11.dim("(via dashboard or evaluation create)")}
4874
- 2. Dataset uploaded ${chalk11.dim("mutagent prompts dataset list <prompt-id>")}
4875
- ${chalk11.dim("Note: LLM provider config is only required when the server uses external providers (USE_EXT_PROVIDERS=true)")}`;
5607
+ ${chalk14.red("Prerequisites (required):")}
5608
+ 1. Evaluation criteria defined ${chalk14.dim("(via dashboard or evaluation create)")}
5609
+ 2. Dataset uploaded ${chalk14.dim("mutagent prompts dataset list <prompt-id>")}
5610
+ ${chalk14.dim("Note: LLM provider config is only required when the server uses external providers (USE_EXT_PROVIDERS=true)")}`;
4876
5611
  function createPromptsCommand() {
4877
5612
  const prompts = new Command6("prompts").description("Manage prompts, datasets, evaluations, and optimizations").addHelpText("after", `
4878
5613
  Examples:
4879
- ${chalk11.dim("$")} mutagent prompts list
4880
- ${chalk11.dim("$")} mutagent prompts get <prompt-id>
4881
- ${chalk11.dim("$")} mutagent prompts create --name "my-prompt" --system "You are helpful" --human "{input}"
4882
- ${chalk11.dim("$")} mutagent prompts dataset list <prompt-id>
4883
- ${chalk11.dim("$")} mutagent prompts evaluation create <prompt-id> --name "My Eval"
4884
- ${chalk11.dim("$")} mutagent prompts optimize start <prompt-id> --dataset <dataset-id> --evaluation <eval-id>
5614
+ ${chalk14.dim("$")} mutagent prompts list
5615
+ ${chalk14.dim("$")} mutagent prompts get <prompt-id>
5616
+ ${chalk14.dim("$")} mutagent prompts create --name "my-prompt" --system "You are helpful" --human "{input}"
5617
+ ${chalk14.dim("$")} mutagent prompts dataset list <prompt-id>
5618
+ ${chalk14.dim("$")} mutagent prompts evaluation create <prompt-id> --name "My Eval"
5619
+ ${chalk14.dim("$")} mutagent prompts optimize start <prompt-id> --dataset <dataset-id> --evaluation <eval-id>
4885
5620
 
4886
5621
  Subcommands:
4887
5622
  list, get, create, update, delete
@@ -4899,27 +5634,27 @@ Subcommands:
4899
5634
  // src/commands/traces.ts
4900
5635
  init_sdk_client();
4901
5636
  import { Command as Command7 } from "commander";
4902
- import chalk12 from "chalk";
5637
+ import chalk15 from "chalk";
4903
5638
  init_errors();
4904
5639
  function createTracesCommand() {
4905
5640
  const traces = new Command7("traces").description("View and analyze traces (replaces Langfuse)").addHelpText("after", `
4906
5641
  Examples:
4907
- ${chalk12.dim("$")} mutagent traces list
4908
- ${chalk12.dim("$")} mutagent traces list --prompt <prompt-id>
4909
- ${chalk12.dim("$")} mutagent traces get <trace-id>
4910
- ${chalk12.dim("$")} mutagent traces analyze <prompt-id>
4911
- ${chalk12.dim("$")} mutagent traces export --format json --output traces.json
5642
+ ${chalk15.dim("$")} mutagent traces list
5643
+ ${chalk15.dim("$")} mutagent traces list --prompt <prompt-id>
5644
+ ${chalk15.dim("$")} mutagent traces get <trace-id>
5645
+ ${chalk15.dim("$")} mutagent traces analyze <prompt-id>
5646
+ ${chalk15.dim("$")} mutagent traces export --format json --output traces.json
4912
5647
 
4913
5648
  Note: MutagenT traces replace Langfuse for observability.
4914
5649
  `);
4915
5650
  traces.command("list").description("List traces").option("-p, --prompt <id>", "Filter by prompt ID").option("-s, --source <source>", "Filter by trace source (e.g., claude-code, sdk, langchain)").option("-l, --limit <n>", "Limit results", "50").addHelpText("after", `
4916
5651
  Examples:
4917
- ${chalk12.dim("$")} mutagent traces list
4918
- ${chalk12.dim("$")} mutagent traces list --prompt <prompt-id>
4919
- ${chalk12.dim("$")} mutagent traces list --source claude-code --json
4920
- ${chalk12.dim("$")} mutagent traces list --limit 10 --json
5652
+ ${chalk15.dim("$")} mutagent traces list
5653
+ ${chalk15.dim("$")} mutagent traces list --prompt <prompt-id>
5654
+ ${chalk15.dim("$")} mutagent traces list --source claude-code --json
5655
+ ${chalk15.dim("$")} mutagent traces list --limit 10 --json
4921
5656
 
4922
- ${chalk12.dim("Tip: Filter by prompt to see traces for a specific prompt version.")}
5657
+ ${chalk15.dim("Tip: Filter by prompt to see traces for a specific prompt version.")}
4923
5658
  `).action(async (options) => {
4924
5659
  const isJson = getJsonFlag(traces);
4925
5660
  const output = new OutputFormatter(isJson ? "json" : "table");
@@ -4959,10 +5694,10 @@ ${chalk12.dim("Tip: Filter by prompt to see traces for a specific prompt version
4959
5694
  });
4960
5695
  traces.command("get").description("Get trace details").argument("<id>", "Trace ID").addHelpText("after", `
4961
5696
  Examples:
4962
- ${chalk12.dim("$")} mutagent traces get <trace-id>
4963
- ${chalk12.dim("$")} mutagent traces get <trace-id> --json
5697
+ ${chalk15.dim("$")} mutagent traces get <trace-id>
5698
+ ${chalk15.dim("$")} mutagent traces get <trace-id> --json
4964
5699
 
4965
- ${chalk12.dim("Returns full trace details including spans, tokens, and latency.")}
5700
+ ${chalk15.dim("Returns full trace details including spans, tokens, and latency.")}
4966
5701
  `).action(async (id) => {
4967
5702
  const isJson = getJsonFlag(traces);
4968
5703
  const output = new OutputFormatter(isJson ? "json" : "table");
@@ -4981,10 +5716,10 @@ ${chalk12.dim("Returns full trace details including spans, tokens, and latency."
4981
5716
  });
4982
5717
  traces.command("analyze").description("Analyze traces for a prompt").argument("<prompt-id>", "Prompt ID").addHelpText("after", `
4983
5718
  Examples:
4984
- ${chalk12.dim("$")} mutagent traces analyze <prompt-id>
4985
- ${chalk12.dim("$")} mutagent traces analyze <prompt-id> --json
5719
+ ${chalk15.dim("$")} mutagent traces analyze <prompt-id>
5720
+ ${chalk15.dim("$")} mutagent traces analyze <prompt-id> --json
4986
5721
 
4987
- ${chalk12.dim("Aggregates trace data for a prompt: avg latency, token usage, error rates.")}
5722
+ ${chalk15.dim("Aggregates trace data for a prompt: avg latency, token usage, error rates.")}
4988
5723
  `).action(async (promptId) => {
4989
5724
  const isJson = getJsonFlag(traces);
4990
5725
  const output = new OutputFormatter(isJson ? "json" : "table");
@@ -5002,12 +5737,12 @@ ${chalk12.dim("Aggregates trace data for a prompt: avg latency, token usage, err
5002
5737
  });
5003
5738
  traces.command("export").description("Export traces").option("-p, --prompt <id>", "Filter by prompt ID").option("-f, --format <format>", "Export format (json, csv)", "json").option("-o, --output <path>", "Output file path").addHelpText("after", `
5004
5739
  Examples:
5005
- ${chalk12.dim("$")} mutagent traces export
5006
- ${chalk12.dim("$")} mutagent traces export --format json --output traces.json
5007
- ${chalk12.dim("$")} mutagent traces export --format csv --output traces.csv
5008
- ${chalk12.dim("$")} mutagent traces export --prompt <prompt-id> --format json
5740
+ ${chalk15.dim("$")} mutagent traces export
5741
+ ${chalk15.dim("$")} mutagent traces export --format json --output traces.json
5742
+ ${chalk15.dim("$")} mutagent traces export --format csv --output traces.csv
5743
+ ${chalk15.dim("$")} mutagent traces export --prompt <prompt-id> --format json
5009
5744
 
5010
- ${chalk12.dim("Exports to stdout by default. Use --output to save to a file.")}
5745
+ ${chalk15.dim("Exports to stdout by default. Use --output to save to a file.")}
5011
5746
  `).action(async (options) => {
5012
5747
  const isJson = getJsonFlag(traces);
5013
5748
  const output = new OutputFormatter(isJson ? "json" : "table");
@@ -5051,7 +5786,7 @@ ${chalk12.dim("Exports to stdout by default. Use --output to save to a file.")}
5051
5786
  // src/commands/integrate.ts
5052
5787
  init_config();
5053
5788
  import { Command as Command8 } from "commander";
5054
- import chalk13 from "chalk";
5789
+ import chalk16 from "chalk";
5055
5790
  import { writeFileSync as writeFileSync3, existsSync as existsSync9 } from "fs";
5056
5791
  import { execSync } from "child_process";
5057
5792
  init_errors();
@@ -5688,12 +6423,12 @@ AI AGENT: Please determine the framework by:
5688
6423
  function createIntegrateCommand() {
5689
6424
  const integrate = new Command8("integrate").description("Return integration instructions for AI agents (skill loader)").addHelpText("after", `
5690
6425
  Examples:
5691
- ${chalk13.dim("$")} mutagent integrate # Return exploration instructions for AI agents
5692
- ${chalk13.dim("$")} mutagent integrate langchain # Return @mutagent/langchain integration steps
5693
- ${chalk13.dim("$")} mutagent integrate openai # Return @mutagent/openai integration steps
5694
- ${chalk13.dim("$")} mutagent integrate vercel-ai --verify # Verify integration
5695
- ${chalk13.dim("$")} mutagent integrate langchain --output ./INTEGRATION.md
5696
- ${chalk13.dim("$")} mutagent integrate --list # List available frameworks
6426
+ ${chalk16.dim("$")} mutagent integrate # Return exploration instructions for AI agents
6427
+ ${chalk16.dim("$")} mutagent integrate langchain # Return @mutagent/langchain integration steps
6428
+ ${chalk16.dim("$")} mutagent integrate openai # Return @mutagent/openai integration steps
6429
+ ${chalk16.dim("$")} mutagent integrate vercel-ai --verify # Verify integration
6430
+ ${chalk16.dim("$")} mutagent integrate langchain --output ./INTEGRATION.md
6431
+ ${chalk16.dim("$")} mutagent integrate --list # List available frameworks
5697
6432
 
5698
6433
  Frameworks: langchain, langgraph, vercel-ai, openai
5699
6434
 
@@ -5809,18 +6544,18 @@ AI AGENT: Execute these steps using Bash for install, Write/Edit for code change
5809
6544
 
5810
6545
  // src/commands/agents/index.ts
5811
6546
  import { Command as Command9 } from "commander";
5812
- import chalk15 from "chalk";
6547
+ import chalk18 from "chalk";
5813
6548
 
5814
6549
  // src/commands/agents/agents-crud.ts
5815
6550
  init_sdk_client();
5816
- import chalk14 from "chalk";
6551
+ import chalk17 from "chalk";
5817
6552
  init_errors();
5818
6553
  function registerAgentsCrud(agents) {
5819
6554
  agents.command("list").description("List all agents").option("-l, --limit <n>", "Limit results", "50").option("-o, --offset <n>", "Offset for pagination").option("-n, --name <name>", "Filter by name").option("-s, --status <status>", "Filter by status (active, paused, archived)").addHelpText("after", `
5820
6555
  Examples:
5821
- ${chalk14.dim("$")} mutagent agents list
5822
- ${chalk14.dim("$")} mutagent agents list --status active
5823
- ${chalk14.dim("$")} mutagent agents list --name "reviewer" --json
6556
+ ${chalk17.dim("$")} mutagent agents list
6557
+ ${chalk17.dim("$")} mutagent agents list --status active
6558
+ ${chalk17.dim("$")} mutagent agents list --name "reviewer" --json
5824
6559
  `).action(async (options) => {
5825
6560
  const isJson = getJsonFlag(agents);
5826
6561
  const output = new OutputFormatter(isJson ? "json" : "table");
@@ -5870,8 +6605,8 @@ Examples:
5870
6605
  });
5871
6606
  agents.command("get").description("Get agent details").argument("<id>", "Agent ID").addHelpText("after", `
5872
6607
  Examples:
5873
- ${chalk14.dim("$")} mutagent agents get <agent-id>
5874
- ${chalk14.dim("$")} mutagent agents get <agent-id> --json
6608
+ ${chalk17.dim("$")} mutagent agents get <agent-id>
6609
+ ${chalk17.dim("$")} mutagent agents get <agent-id> --json
5875
6610
  `).action(async (id) => {
5876
6611
  const isJson = getJsonFlag(agents);
5877
6612
  const output = new OutputFormatter(isJson ? "json" : "table");
@@ -5901,11 +6636,11 @@ Examples:
5901
6636
  };
5902
6637
  output.output(formatted);
5903
6638
  if (agent.systemPrompt) {
5904
- console.log(chalk14.bold(`
6639
+ console.log(chalk17.bold(`
5905
6640
  System Prompt:`));
5906
- console.log(chalk14.gray("─".repeat(60)));
6641
+ console.log(chalk17.gray("─".repeat(60)));
5907
6642
  console.log(agent.systemPrompt);
5908
- console.log(chalk14.gray("─".repeat(60)));
6643
+ console.log(chalk17.gray("─".repeat(60)));
5909
6644
  }
5910
6645
  }
5911
6646
  } catch (error) {
@@ -5914,17 +6649,17 @@ System Prompt:`));
5914
6649
  });
5915
6650
  agents.command("create").description("Create a new agent").option("-d, --data <json>", "Agent as JSON string (recommended for CI/scripts/agents)").option("-n, --name <name>", "Agent name").option("-s, --slug <slug>", "Agent slug (URL-friendly identifier)").option("-p, --system-prompt <prompt>", "System prompt").option("-m, --model <model>", "Model (claude-sonnet-4-5, claude-opus-4-5, claude-haiku-4-5)").option("--description <desc>", "Agent description").addHelpText("after", `
5916
6651
  Examples:
5917
- ${chalk14.dim("$")} mutagent agents create --name "Code Reviewer" --slug code-reviewer --system-prompt "You are a code reviewer..."
5918
- ${chalk14.dim("$")} mutagent agents create -d '{"name":"Code Reviewer","slug":"code-reviewer","systemPrompt":"You are a code reviewer..."}'
6652
+ ${chalk17.dim("$")} mutagent agents create --name "Code Reviewer" --slug code-reviewer --system-prompt "You are a code reviewer..."
6653
+ ${chalk17.dim("$")} mutagent agents create -d '{"name":"Code Reviewer","slug":"code-reviewer","systemPrompt":"You are a code reviewer..."}'
5919
6654
 
5920
6655
  Expected JSON (--data):
5921
- ${chalk14.dim('{"name":"<name>","slug":"<slug>","systemPrompt":"<system prompt>","model":"<model-id>","description":"<description>"}')}
6656
+ ${chalk17.dim('{"name":"<name>","slug":"<slug>","systemPrompt":"<system prompt>","model":"<model-id>","description":"<description>"}')}
5922
6657
 
5923
6658
  Input Methods (pick one, priority order):
5924
- --name/--slug/... Individual flags ${chalk14.green("(recommended)")}
6659
+ --name/--slug/... Individual flags ${chalk17.green("(recommended)")}
5925
6660
  -d, --data Inline JSON object (CI/scripts/agents)
5926
6661
 
5927
- ${chalk14.red("Required: name, slug, systemPrompt.")} ${chalk14.dim("CLI flags override --data fields.")}
6662
+ ${chalk17.red("Required: name, slug, systemPrompt.")} ${chalk17.dim("CLI flags override --data fields.")}
5928
6663
  `).action(async (options) => {
5929
6664
  const isJson = getJsonFlag(agents);
5930
6665
  const output = new OutputFormatter(isJson ? "json" : "table");
@@ -5969,15 +6704,15 @@ ${chalk14.red("Required: name, slug, systemPrompt.")} ${chalk14.dim("CLI flags o
5969
6704
  });
5970
6705
  agents.command("update").description("Update an agent").argument("<id>", "Agent ID").option("-d, --data <json>", "Agent updates as JSON string (CI/scripts/agents)").option("-n, --name <name>", "New name").option("-p, --system-prompt <prompt>", "New system prompt").option("-m, --model <model>", "New model").option("--description <desc>", "New description").option("-s, --status <status>", "New status (active, paused, archived)").addHelpText("after", `
5971
6706
  Examples:
5972
- ${chalk14.dim("$")} mutagent agents update <id> --name "New Name"
5973
- ${chalk14.dim("$")} mutagent agents update <id> --system-prompt "Updated prompt" --status active
5974
- ${chalk14.dim("$")} mutagent agents update <id> -d '{"name":"New Name","systemPrompt":"Updated prompt"}'
6707
+ ${chalk17.dim("$")} mutagent agents update <id> --name "New Name"
6708
+ ${chalk17.dim("$")} mutagent agents update <id> --system-prompt "Updated prompt" --status active
6709
+ ${chalk17.dim("$")} mutagent agents update <id> -d '{"name":"New Name","systemPrompt":"Updated prompt"}'
5975
6710
 
5976
6711
  Input Methods (pick one, priority order):
5977
- --name/--system-prompt/... Individual flags ${chalk14.green("(recommended)")}
6712
+ --name/--system-prompt/... Individual flags ${chalk17.green("(recommended)")}
5978
6713
  -d, --data Inline JSON object (CI/scripts/agents)
5979
6714
 
5980
- ${chalk14.dim("CLI flags override --data fields.")}
6715
+ ${chalk17.dim("CLI flags override --data fields.")}
5981
6716
  `).action(async (id, options) => {
5982
6717
  const isJson = getJsonFlag(agents);
5983
6718
  const output = new OutputFormatter(isJson ? "json" : "table");
@@ -6024,11 +6759,11 @@ ${chalk14.dim("CLI flags override --data fields.")}
6024
6759
  });
6025
6760
  agents.command("delete").description("Delete an agent").argument("<id>", "Agent ID").option("--force", "Skip confirmation").addHelpText("after", `
6026
6761
  Examples:
6027
- ${chalk14.dim("$")} mutagent agents delete <id>
6028
- ${chalk14.dim("$")} mutagent agents delete <id> --force
6029
- ${chalk14.dim("$")} mutagent agents delete <id> --force --json
6762
+ ${chalk17.dim("$")} mutagent agents delete <id>
6763
+ ${chalk17.dim("$")} mutagent agents delete <id> --force
6764
+ ${chalk17.dim("$")} mutagent agents delete <id> --force --json
6030
6765
 
6031
- ${chalk14.dim("Tip: Use --force to skip confirmation (required for non-interactive/CI usage).")}
6766
+ ${chalk17.dim("Tip: Use --force to skip confirmation (required for non-interactive/CI usage).")}
6032
6767
  `).action(async (id, options) => {
6033
6768
  const isJson = getJsonFlag(agents);
6034
6769
  const output = new OutputFormatter(isJson ? "json" : "table");
@@ -6059,12 +6794,12 @@ ${chalk14.dim("Tip: Use --force to skip confirmation (required for non-interacti
6059
6794
  function createAgentsCommand() {
6060
6795
  const agents = new Command9("agents").description("Manage AI agents").addHelpText("after", `
6061
6796
  Examples:
6062
- ${chalk15.dim("$")} mutagent agents list
6063
- ${chalk15.dim("$")} mutagent agents get <agent-id>
6064
- ${chalk15.dim("$")} mutagent agents create --name "Code Reviewer" --slug code-reviewer --system-prompt "You are a code reviewer..."
6065
- ${chalk15.dim("$")} mutagent agents create -d '{"name":"Code Reviewer","slug":"code-reviewer","systemPrompt":"You are..."}'
6066
- ${chalk15.dim("$")} mutagent agents update <agent-id> --name "Updated Name"
6067
- ${chalk15.dim("$")} mutagent agents delete <agent-id> --force
6797
+ ${chalk18.dim("$")} mutagent agents list
6798
+ ${chalk18.dim("$")} mutagent agents get <agent-id>
6799
+ ${chalk18.dim("$")} mutagent agents create --name "Code Reviewer" --slug code-reviewer --system-prompt "You are a code reviewer..."
6800
+ ${chalk18.dim("$")} mutagent agents create -d '{"name":"Code Reviewer","slug":"code-reviewer","systemPrompt":"You are..."}'
6801
+ ${chalk18.dim("$")} mutagent agents update <agent-id> --name "Updated Name"
6802
+ ${chalk18.dim("$")} mutagent agents delete <agent-id> --force
6068
6803
 
6069
6804
  Subcommands:
6070
6805
  list, get, create, update, delete
@@ -6076,21 +6811,21 @@ Subcommands:
6076
6811
  // src/commands/config.ts
6077
6812
  init_config();
6078
6813
  import { Command as Command10 } from "commander";
6079
- import chalk16 from "chalk";
6814
+ import chalk19 from "chalk";
6080
6815
  init_errors();
6081
6816
  var VALID_CONFIG_KEYS = ["apiKey", "endpoint", "format", "timeout", "defaultWorkspace", "defaultOrganization"];
6082
6817
  function createConfigCommand() {
6083
6818
  const config = new Command10("config").description("Manage CLI configuration").addHelpText("after", `
6084
6819
  Examples:
6085
- ${chalk16.dim("$")} mutagent config list
6086
- ${chalk16.dim("$")} mutagent config get endpoint
6087
- ${chalk16.dim("$")} mutagent config set workspace <workspace-id>
6088
- ${chalk16.dim("$")} mutagent config set org <org-id>
6820
+ ${chalk19.dim("$")} mutagent config list
6821
+ ${chalk19.dim("$")} mutagent config get endpoint
6822
+ ${chalk19.dim("$")} mutagent config set workspace <workspace-id>
6823
+ ${chalk19.dim("$")} mutagent config set org <org-id>
6089
6824
  `);
6090
6825
  config.command("list").description("List all configuration").addHelpText("after", `
6091
6826
  Examples:
6092
- ${chalk16.dim("$")} mutagent config list
6093
- ${chalk16.dim("$")} mutagent config list --json
6827
+ ${chalk19.dim("$")} mutagent config list
6828
+ ${chalk19.dim("$")} mutagent config list --json
6094
6829
  `).action(() => {
6095
6830
  const isJson = getJsonFlag(config);
6096
6831
  const output = new OutputFormatter(isJson ? "json" : "table");
@@ -6103,11 +6838,11 @@ Examples:
6103
6838
  });
6104
6839
  config.command("get").description("Get configuration value").argument("<key>", "Configuration key (apiKey, endpoint, format, timeout, defaultWorkspace, defaultOrganization)").addHelpText("after", `
6105
6840
  Examples:
6106
- ${chalk16.dim("$")} mutagent config get endpoint
6107
- ${chalk16.dim("$")} mutagent config get defaultWorkspace
6108
- ${chalk16.dim("$")} mutagent config get apiKey --json
6841
+ ${chalk19.dim("$")} mutagent config get endpoint
6842
+ ${chalk19.dim("$")} mutagent config get defaultWorkspace
6843
+ ${chalk19.dim("$")} mutagent config get apiKey --json
6109
6844
 
6110
- ${chalk16.dim("Keys: apiKey, endpoint, format, timeout, defaultWorkspace, defaultOrganization")}
6845
+ ${chalk19.dim("Keys: apiKey, endpoint, format, timeout, defaultWorkspace, defaultOrganization")}
6111
6846
  `).action((key) => {
6112
6847
  const isJson = getJsonFlag(config);
6113
6848
  const output = new OutputFormatter(isJson ? "json" : "table");
@@ -6134,9 +6869,9 @@ ${chalk16.dim("Keys: apiKey, endpoint, format, timeout, defaultWorkspace, defaul
6134
6869
  });
6135
6870
  set.command("workspace").description("Set default workspace ID").argument("<id>", "Workspace ID to set as default").addHelpText("after", `
6136
6871
  Examples:
6137
- ${chalk16.dim("$")} mutagent config set workspace <workspace-id>
6872
+ ${chalk19.dim("$")} mutagent config set workspace <workspace-id>
6138
6873
 
6139
- ${chalk16.dim("Persists workspace ID so you don't need to pass headers on every request.")}
6874
+ ${chalk19.dim("Persists workspace ID so you don't need to pass headers on every request.")}
6140
6875
  `).action((id) => {
6141
6876
  const isJson = getJsonFlag(config);
6142
6877
  const output = new OutputFormatter(isJson ? "json" : "table");
@@ -6149,9 +6884,9 @@ ${chalk16.dim("Persists workspace ID so you don't need to pass headers on every
6149
6884
  });
6150
6885
  set.command("org").description("Set default organization ID").argument("<id>", "Organization ID to set as default").addHelpText("after", `
6151
6886
  Examples:
6152
- ${chalk16.dim("$")} mutagent config set org <org-id>
6887
+ ${chalk19.dim("$")} mutagent config set org <org-id>
6153
6888
 
6154
- ${chalk16.dim("Persists organization ID for org-scoped API keys.")}
6889
+ ${chalk19.dim("Persists organization ID for org-scoped API keys.")}
6155
6890
  `).action((id) => {
6156
6891
  const isJson = getJsonFlag(config);
6157
6892
  const output = new OutputFormatter(isJson ? "json" : "table");
@@ -6169,18 +6904,18 @@ ${chalk16.dim("Persists organization ID for org-scoped API keys.")}
6169
6904
  // src/commands/playground.ts
6170
6905
  init_sdk_client();
6171
6906
  import { Command as Command11 } from "commander";
6172
- import chalk17 from "chalk";
6907
+ import chalk20 from "chalk";
6173
6908
  init_errors();
6174
- function parseSSELine(line) {
6175
- if (!line || line.startsWith(":")) {
6909
+ function parseSSELine(line3) {
6910
+ if (!line3 || line3.startsWith(":")) {
6176
6911
  return null;
6177
6912
  }
6178
- const colonIndex = line.indexOf(":");
6913
+ const colonIndex = line3.indexOf(":");
6179
6914
  if (colonIndex === -1) {
6180
- return { field: line, value: "" };
6915
+ return { field: line3, value: "" };
6181
6916
  }
6182
- const field = line.slice(0, colonIndex);
6183
- let value = line.slice(colonIndex + 1);
6917
+ const field = line3.slice(0, colonIndex);
6918
+ let value = line3.slice(colonIndex + 1);
6184
6919
  if (value.startsWith(" ")) {
6185
6920
  value = value.slice(1);
6186
6921
  }
@@ -6196,11 +6931,11 @@ function parsePromptStreamEvent(data) {
6196
6931
  function createPlaygroundCommand() {
6197
6932
  const playground = new Command11("playground").description("Execute and test prompts interactively").addHelpText("after", `
6198
6933
  Examples:
6199
- ${chalk17.dim("$")} mutagent playground run <prompt-id> --input '{"name": "John"}'
6200
- ${chalk17.dim("$")} mutagent playground run <prompt-id> --input '{}' --stream
6201
- ${chalk17.dim("$")} mutagent playground run <prompt-id> -i '{}' --model gpt-4-turbo
6202
- ${chalk17.dim("$")} mutagent playground run <prompt-id> --system "You are helpful" --human "Hello"
6203
- ${chalk17.dim("$")} mutagent playground run <prompt-id> --messages '[{"role":"user","content":"Hi"}]'
6934
+ ${chalk20.dim("$")} mutagent playground run <prompt-id> --input '{"name": "John"}'
6935
+ ${chalk20.dim("$")} mutagent playground run <prompt-id> --input '{}' --stream
6936
+ ${chalk20.dim("$")} mutagent playground run <prompt-id> -i '{}' --model gpt-4-turbo
6937
+ ${chalk20.dim("$")} mutagent playground run <prompt-id> --system "You are helpful" --human "Hello"
6938
+ ${chalk20.dim("$")} mutagent playground run <prompt-id> --messages '[{"role":"user","content":"Hi"}]'
6204
6939
 
6205
6940
  Input Format:
6206
6941
  The input must be a valid JSON object matching the prompt's input schema.
@@ -6216,16 +6951,16 @@ Streaming:
6216
6951
  `);
6217
6952
  playground.command("run").description("Execute a prompt with input variables").argument("<prompt-id>", "Prompt ID to execute (from: mutagent prompts list)").option("-i, --input <json>", "Input variables as JSON").option("-s, --stream", "Stream the response").option("-m, --model <model>", "Override model").option("--system <text>", "Set system prompt text").option("--human <text>", "Set human/user message text").option("--messages <json>", "Pass full messages array as JSON string").addHelpText("after", `
6218
6953
  Examples:
6219
- ${chalk17.dim("$")} mutagent playground run <prompt-id> --input '{"name": "John"}'
6220
- ${chalk17.dim("$")} mutagent playground run <prompt-id> --input '{}' --stream
6221
- ${chalk17.dim("$")} mutagent playground run <prompt-id> --system "You are helpful" --human "Hello"
6222
- ${chalk17.dim("$")} mutagent playground run <prompt-id> --input '{}' --model gpt-4-turbo --json
6954
+ ${chalk20.dim("$")} mutagent playground run <prompt-id> --input '{"name": "John"}'
6955
+ ${chalk20.dim("$")} mutagent playground run <prompt-id> --input '{}' --stream
6956
+ ${chalk20.dim("$")} mutagent playground run <prompt-id> --system "You are helpful" --human "Hello"
6957
+ ${chalk20.dim("$")} mutagent playground run <prompt-id> --input '{}' --model gpt-4-turbo --json
6223
6958
 
6224
6959
  Input Methods (pick one, priority order):
6225
- --system/--human Quick system + user message ${chalk17.green("(recommended)")}
6960
+ --system/--human Quick system + user message ${chalk20.green("(recommended)")}
6226
6961
  --input '{"key":"value"}' Inline JSON variables
6227
6962
  --messages '[...]' Full messages array
6228
- ${chalk17.dim(`Hint: Test before evaluating: mutagent playground run <id> --input '{"key":"value"}'`)}
6963
+ ${chalk20.dim(`Hint: Test before evaluating: mutagent playground run <id> --input '{"key":"value"}'`)}
6229
6964
  `).action(async (promptId, options) => {
6230
6965
  const isJson = getJsonFlag(playground);
6231
6966
  const output = new OutputFormatter(isJson ? "json" : "table");
@@ -6247,21 +6982,21 @@ ${chalk17.dim(`Hint: Test before evaluating: mutagent playground run <id> --inpu
6247
6982
  }
6248
6983
  });
6249
6984
  } else {
6250
- console.log(chalk17.bold(`
6985
+ console.log(chalk20.bold(`
6251
6986
  Execution Result:`));
6252
- console.log(chalk17.gray("─".repeat(50)));
6253
- console.log(chalk17.cyan("Output:"));
6987
+ console.log(chalk20.gray("─".repeat(50)));
6988
+ console.log(chalk20.cyan("Output:"));
6254
6989
  console.log(result.output);
6255
- console.log(chalk17.gray("─".repeat(50)));
6256
- console.log(chalk17.dim(`Model: ${result.model}`));
6257
- console.log(chalk17.dim(`Execution Time: ${String(result.executionTimeMs)}ms`));
6990
+ console.log(chalk20.gray("─".repeat(50)));
6991
+ console.log(chalk20.dim(`Model: ${result.model}`));
6992
+ console.log(chalk20.dim(`Execution Time: ${String(result.executionTimeMs)}ms`));
6258
6993
  if (result.tokens) {
6259
- console.log(chalk17.dim(`Tokens: ${String(result.tokens.prompt)} prompt + ${String(result.tokens.completion)} completion = ${String(result.tokens.total)} total`));
6994
+ console.log(chalk20.dim(`Tokens: ${String(result.tokens.prompt)} prompt + ${String(result.tokens.completion)} completion = ${String(result.tokens.total)} total`));
6260
6995
  }
6261
6996
  if (result.cost !== undefined) {
6262
- console.log(chalk17.dim(`Cost: $${result.cost.toFixed(6)}`));
6997
+ console.log(chalk20.dim(`Cost: $${result.cost.toFixed(6)}`));
6263
6998
  }
6264
- console.log(chalk17.dim(`Playground: ${playgroundLink()}`));
6999
+ console.log(chalk20.dim(`Playground: ${playgroundLink()}`));
6265
7000
  console.log();
6266
7001
  }
6267
7002
  }
@@ -6350,9 +7085,9 @@ async function executeStreaming(client, promptId, input, model, isJson, output)
6350
7085
  const decoder = new TextDecoder;
6351
7086
  let buffer = "";
6352
7087
  if (!isJson) {
6353
- console.log(chalk17.bold(`
7088
+ console.log(chalk20.bold(`
6354
7089
  Streaming Output:`));
6355
- console.log(chalk17.gray("─".repeat(50)));
7090
+ console.log(chalk20.gray("─".repeat(50)));
6356
7091
  }
6357
7092
  try {
6358
7093
  for (;; ) {
@@ -6363,8 +7098,8 @@ Streaming Output:`));
6363
7098
  const lines = buffer.split(`
6364
7099
  `);
6365
7100
  buffer = lines.pop() ?? "";
6366
- for (const line of lines) {
6367
- const parsed = parseSSELine(line);
7101
+ for (const line3 of lines) {
7102
+ const parsed = parseSSELine(line3);
6368
7103
  if (!parsed)
6369
7104
  continue;
6370
7105
  if (parsed.field === "data") {
@@ -6391,15 +7126,15 @@ Streaming Output:`));
6391
7126
  console.log(JSON.stringify({ type: "complete", result: event.result }));
6392
7127
  } else {
6393
7128
  console.log();
6394
- console.log(chalk17.gray("─".repeat(50)));
7129
+ console.log(chalk20.gray("─".repeat(50)));
6395
7130
  if (event.result) {
6396
- console.log(chalk17.dim(`Model: ${event.result.model}`));
6397
- console.log(chalk17.dim(`Execution Time: ${String(event.result.executionTimeMs)}ms`));
7131
+ console.log(chalk20.dim(`Model: ${event.result.model}`));
7132
+ console.log(chalk20.dim(`Execution Time: ${String(event.result.executionTimeMs)}ms`));
6398
7133
  if (event.result.tokens) {
6399
- console.log(chalk17.dim(`Tokens: ${String(event.result.tokens.prompt)} prompt + ${String(event.result.tokens.completion)} completion = ${String(event.result.tokens.total)} total`));
7134
+ console.log(chalk20.dim(`Tokens: ${String(event.result.tokens.prompt)} prompt + ${String(event.result.tokens.completion)} completion = ${String(event.result.tokens.total)} total`));
6400
7135
  }
6401
7136
  if (event.result.cost !== undefined) {
6402
- console.log(chalk17.dim(`Cost: $${event.result.cost.toFixed(6)}`));
7137
+ console.log(chalk20.dim(`Cost: $${event.result.cost.toFixed(6)}`));
6403
7138
  }
6404
7139
  }
6405
7140
  console.log();
@@ -6424,13 +7159,13 @@ Streaming Output:`));
6424
7159
  // src/commands/workspaces.ts
6425
7160
  init_sdk_client();
6426
7161
  import { Command as Command12 } from "commander";
6427
- import chalk18 from "chalk";
7162
+ import chalk21 from "chalk";
6428
7163
  init_errors();
6429
7164
  function createWorkspacesCommand() {
6430
7165
  const workspaces = new Command12("workspaces").description("View workspaces (read-only)").addHelpText("after", `
6431
7166
  Examples:
6432
- ${chalk18.dim("$")} mutagent workspaces list
6433
- ${chalk18.dim("$")} mutagent workspaces get <workspace-id>
7167
+ ${chalk21.dim("$")} mutagent workspaces list
7168
+ ${chalk21.dim("$")} mutagent workspaces get <workspace-id>
6434
7169
 
6435
7170
  Subcommands:
6436
7171
  list, get
@@ -6439,8 +7174,8 @@ Note: Workspace management (create, update, delete) is available in the Admin Pa
6439
7174
  `);
6440
7175
  workspaces.command("list").description("List all workspaces").option("-l, --limit <n>", "Limit results", "50").option("-o, --offset <n>", "Offset for pagination").addHelpText("after", `
6441
7176
  Examples:
6442
- ${chalk18.dim("$")} mutagent workspaces list
6443
- ${chalk18.dim("$")} mutagent workspaces list --limit 10 --json
7177
+ ${chalk21.dim("$")} mutagent workspaces list
7178
+ ${chalk21.dim("$")} mutagent workspaces list --limit 10 --json
6444
7179
  `).action(async (options) => {
6445
7180
  const isJson = getJsonFlag(workspaces);
6446
7181
  const output = new OutputFormatter(isJson ? "json" : "table");
@@ -6480,8 +7215,8 @@ Examples:
6480
7215
  });
6481
7216
  workspaces.command("get").description("Get workspace details").argument("<id>", "Workspace ID").addHelpText("after", `
6482
7217
  Examples:
6483
- ${chalk18.dim("$")} mutagent workspaces get <workspace-id>
6484
- ${chalk18.dim("$")} mutagent workspaces get <workspace-id> --json
7218
+ ${chalk21.dim("$")} mutagent workspaces get <workspace-id>
7219
+ ${chalk21.dim("$")} mutagent workspaces get <workspace-id> --json
6485
7220
  `).action(async (id) => {
6486
7221
  const isJson = getJsonFlag(workspaces);
6487
7222
  const output = new OutputFormatter(isJson ? "json" : "table");
@@ -6514,7 +7249,7 @@ Examples:
6514
7249
  // src/commands/providers.ts
6515
7250
  init_sdk_client();
6516
7251
  import { Command as Command13 } from "commander";
6517
- import chalk19 from "chalk";
7252
+ import chalk22 from "chalk";
6518
7253
  init_errors();
6519
7254
  var VALID_PROVIDER_TYPES = [
6520
7255
  "openai",
@@ -6538,9 +7273,9 @@ function validateProviderType(type) {
6538
7273
  function createProvidersCommand() {
6539
7274
  const providers = new Command13("providers").description("View LLM providers (read-only)").addHelpText("after", `
6540
7275
  Examples:
6541
- ${chalk19.dim("$")} mutagent providers list
6542
- ${chalk19.dim("$")} mutagent providers get <provider-id>
6543
- ${chalk19.dim("$")} mutagent providers test <provider-id>
7276
+ ${chalk22.dim("$")} mutagent providers list
7277
+ ${chalk22.dim("$")} mutagent providers get <provider-id>
7278
+ ${chalk22.dim("$")} mutagent providers test <provider-id>
6544
7279
 
6545
7280
  Provider Types:
6546
7281
  openai, anthropic, google, azure, bedrock, cohere, mistral, groq, together, replicate, custom
@@ -6550,15 +7285,15 @@ Subcommands:
6550
7285
 
6551
7286
  Note: Provider management (create, update, delete) is available in the Admin Panel only.
6552
7287
 
6553
- ${chalk19.yellow("Note:")} The providers module is not yet active. This is a placeholder
7288
+ ${chalk22.yellow("Note:")} The providers module is not yet active. This is a placeholder
6554
7289
  for future external provider configuration. The server currently uses
6555
7290
  built-in provider settings.
6556
7291
  `);
6557
7292
  providers.command("list").description("List all providers").option("-l, --limit <n>", "Limit results", "50").option("-o, --offset <n>", "Offset for pagination").option("-t, --type <type>", "Filter by provider type").addHelpText("after", `
6558
7293
  Examples:
6559
- ${chalk19.dim("$")} mutagent providers list
6560
- ${chalk19.dim("$")} mutagent providers list --type openai
6561
- ${chalk19.dim("$")} mutagent providers list --json
7294
+ ${chalk22.dim("$")} mutagent providers list
7295
+ ${chalk22.dim("$")} mutagent providers list --type openai
7296
+ ${chalk22.dim("$")} mutagent providers list --json
6562
7297
  `).action(async (options) => {
6563
7298
  const isJson = getJsonFlag(providers);
6564
7299
  const output = new OutputFormatter(isJson ? "json" : "table");
@@ -6585,7 +7320,7 @@ Examples:
6585
7320
  }));
6586
7321
  output.output({ ...result, data: withLinks });
6587
7322
  } else {
6588
- console.log(chalk19.yellow("Note: The providers module is not yet active. This is a placeholder for future external provider configuration."));
7323
+ console.log(chalk22.yellow("Note: The providers module is not yet active. This is a placeholder for future external provider configuration."));
6589
7324
  console.log("");
6590
7325
  if (result.data.length === 0) {
6591
7326
  output.info("No providers configured.");
@@ -6609,8 +7344,8 @@ Examples:
6609
7344
  });
6610
7345
  providers.command("get").description("Get provider details").argument("<id>", "Provider ID (from: mutagent providers list)").addHelpText("after", `
6611
7346
  Examples:
6612
- ${chalk19.dim("$")} mutagent providers get <provider-id>
6613
- ${chalk19.dim("$")} mutagent providers get <provider-id> --json
7347
+ ${chalk22.dim("$")} mutagent providers get <provider-id>
7348
+ ${chalk22.dim("$")} mutagent providers get <provider-id> --json
6614
7349
  `).action(async (id) => {
6615
7350
  const isJson = getJsonFlag(providers);
6616
7351
  const output = new OutputFormatter(isJson ? "json" : "table");
@@ -6620,7 +7355,7 @@ Examples:
6620
7355
  if (isJson) {
6621
7356
  output.output({ ...provider, _links: providerLinks(provider.id) });
6622
7357
  } else {
6623
- console.log(chalk19.yellow("Note: The providers module is not yet active. This is a placeholder for future external provider configuration."));
7358
+ console.log(chalk22.yellow("Note: The providers module is not yet active. This is a placeholder for future external provider configuration."));
6624
7359
  console.log("");
6625
7360
  const formatted = {
6626
7361
  id: provider.id,
@@ -6641,17 +7376,17 @@ Examples:
6641
7376
  });
6642
7377
  providers.command("test").description("Test provider connectivity").argument("<id>", "Provider ID (from: mutagent providers list)").addHelpText("after", `
6643
7378
  Examples:
6644
- ${chalk19.dim("$")} mutagent providers test <provider-id>
6645
- ${chalk19.dim("$")} mutagent providers test <provider-id> --json
7379
+ ${chalk22.dim("$")} mutagent providers test <provider-id>
7380
+ ${chalk22.dim("$")} mutagent providers test <provider-id> --json
6646
7381
 
6647
- ${chalk19.dim("Tests connectivity and lists available models for the provider.")}
7382
+ ${chalk22.dim("Tests connectivity and lists available models for the provider.")}
6648
7383
  `).action(async (id) => {
6649
7384
  const isJson = getJsonFlag(providers);
6650
7385
  const output = new OutputFormatter(isJson ? "json" : "table");
6651
7386
  try {
6652
7387
  const client = getSDKClient();
6653
7388
  if (!isJson) {
6654
- console.log(chalk19.yellow("Note: The providers module is not yet active. This is a placeholder for future external provider configuration."));
7389
+ console.log(chalk22.yellow("Note: The providers module is not yet active. This is a placeholder for future external provider configuration."));
6655
7390
  console.log("");
6656
7391
  output.info(`Testing provider ${id}...`);
6657
7392
  }
@@ -6661,9 +7396,9 @@ ${chalk19.dim("Tests connectivity and lists available models for the provider.")
6661
7396
  } else {
6662
7397
  if (result.success) {
6663
7398
  output.success(`Provider test passed (${String(result.responseTimeMs)}ms)`);
6664
- console.log(chalk19.green(`Message: ${result.message}`));
7399
+ console.log(chalk22.green(`Message: ${result.message}`));
6665
7400
  if (result.availableModels && result.availableModels.length > 0) {
6666
- console.log(chalk19.bold(`
7401
+ console.log(chalk22.bold(`
6667
7402
  Available Models:`));
6668
7403
  result.availableModels.forEach((model) => {
6669
7404
  console.log(` - ${model}`);
@@ -6672,7 +7407,7 @@ Available Models:`));
6672
7407
  } else {
6673
7408
  output.error(`Provider test failed: ${result.message}`);
6674
7409
  if (result.error) {
6675
- console.log(chalk19.red(`Error: ${result.error}`));
7410
+ console.log(chalk22.red(`Error: ${result.error}`));
6676
7411
  }
6677
7412
  }
6678
7413
  }
@@ -6687,7 +7422,7 @@ Available Models:`));
6687
7422
  init_config();
6688
7423
  import { Command as Command14 } from "commander";
6689
7424
  import inquirer3 from "inquirer";
6690
- import chalk20 from "chalk";
7425
+ import chalk23 from "chalk";
6691
7426
  import { existsSync as existsSync11, mkdirSync as mkdirSync3, writeFileSync as writeFileSync4 } from "fs";
6692
7427
  import { execSync as execSync3 } from "child_process";
6693
7428
  import { join as join6 } from "path";
@@ -6810,13 +7545,13 @@ function writeRcConfig(config, cwd = process.cwd()) {
6810
7545
  function createInitCommand() {
6811
7546
  const init = new Command14("init").description("Initialize MutagenT in your project").option("--non-interactive", "Skip interactive prompts (defaults to CLI-only mode)").addHelpText("after", `
6812
7547
  Examples:
6813
- ${chalk20.dim("$")} mutagent init # Interactive setup wizard
6814
- ${chalk20.dim("$")} mutagent init --non-interactive # CLI-only mode (no prompts)
7548
+ ${chalk23.dim("$")} mutagent init # Interactive setup wizard
7549
+ ${chalk23.dim("$")} mutagent init --non-interactive # CLI-only mode (no prompts)
6815
7550
 
6816
7551
  Modes:
6817
- ${chalk20.bold("Full scaffold")} Install SDK + integration package, create config, setup tracing
6818
- ${chalk20.bold("CLI-only")} Verify auth + create .mutagentrc.json with workspace/endpoint
6819
- ${chalk20.bold("Skip")} Exit without changes
7552
+ ${chalk23.bold("Full scaffold")} Install SDK + integration package, create config, setup tracing
7553
+ ${chalk23.bold("CLI-only")} Verify auth + create .mutagentrc.json with workspace/endpoint
7554
+ ${chalk23.bold("Skip")} Exit without changes
6820
7555
  `).action(async (options) => {
6821
7556
  const isJson = getJsonFlag(init);
6822
7557
  const output = new OutputFormatter(isJson ? "json" : "table");
@@ -7085,23 +7820,23 @@ Modes:
7085
7820
 
7086
7821
  // src/commands/explore.ts
7087
7822
  import { Command as Command15 } from "commander";
7088
- import chalk21 from "chalk";
7823
+ import chalk24 from "chalk";
7089
7824
  import { resolve as resolve3 } from "path";
7090
7825
  init_errors();
7091
7826
  function createExploreCommand() {
7092
7827
  const explore = new Command15("explore").description("Scan codebase for prompts, datasets, and MutagenT markers").option("-p, --path <dir>", "Directory to scan", ".").option("--depth <n>", "Max directory depth", "10").option("--include <glob>", "Include file pattern", "**/*.{ts,js,py,tsx,jsx}").option("--exclude <dirs>", "Comma-separated directories to exclude", "node_modules,dist,.git,build,.next,__pycache__,venv,.venv").option("--markers-only", "Only find existing MutagenT markers").addHelpText("after", `
7093
7828
  Examples:
7094
- ${chalk21.dim("$")} mutagent explore
7095
- ${chalk21.dim("$")} mutagent explore --path ./src
7096
- ${chalk21.dim("$")} mutagent explore --include "**/*.{ts,py}" --depth 5
7097
- ${chalk21.dim("$")} mutagent explore --markers-only
7098
- ${chalk21.dim("$")} mutagent explore --json
7829
+ ${chalk24.dim("$")} mutagent explore
7830
+ ${chalk24.dim("$")} mutagent explore --path ./src
7831
+ ${chalk24.dim("$")} mutagent explore --include "**/*.{ts,py}" --depth 5
7832
+ ${chalk24.dim("$")} mutagent explore --markers-only
7833
+ ${chalk24.dim("$")} mutagent explore --json
7099
7834
 
7100
7835
  Detection modes:
7101
- ${chalk21.dim("Heuristic")} Template variables ({{var}}), prompt constants, schema definitions
7102
- ${chalk21.dim("Marker")} MutagenT:START/END comment markers from previous uploads
7836
+ ${chalk24.dim("Heuristic")} Template variables ({{var}}), prompt constants, schema definitions
7837
+ ${chalk24.dim("Marker")} MutagenT:START/END comment markers from previous uploads
7103
7838
 
7104
- ${chalk21.dim("Results are saved to .mutagent/mutation-context.md for use by other commands.")}
7839
+ ${chalk24.dim("Results are saved to .mutagent/mutation-context.md for use by other commands.")}
7105
7840
  `).action((options) => {
7106
7841
  const isJson = getJsonFlag(explore);
7107
7842
  const output = new OutputFormatter(isJson ? "json" : "table");
@@ -7119,7 +7854,7 @@ ${chalk21.dim("Results are saved to .mutagent/mutation-context.md for use by oth
7119
7854
  markersOnly
7120
7855
  };
7121
7856
  if (!isJson) {
7122
- console.log(chalk21.cyan(`
7857
+ console.log(chalk24.cyan(`
7123
7858
  Scanning ${scanPath}...
7124
7859
  `));
7125
7860
  }
@@ -7148,41 +7883,41 @@ Scanning ${scanPath}...
7148
7883
  const totalFindings = result.prompts.length + result.datasets.length + result.markers.length;
7149
7884
  if (totalFindings === 0) {
7150
7885
  output.info("No prompts, datasets, or markers found.");
7151
- console.log(chalk21.dim(`
7886
+ console.log(chalk24.dim(`
7152
7887
  Tip: Create a prompt with template variables like {{input}} to get started.`));
7153
7888
  return;
7154
7889
  }
7155
7890
  if (result.prompts.length > 0) {
7156
- console.log(chalk21.bold(` Prompts Found (${String(result.prompts.length)}):`));
7891
+ console.log(chalk24.bold(` Prompts Found (${String(result.prompts.length)}):`));
7157
7892
  console.log();
7158
7893
  for (const p of result.prompts) {
7159
- const confidenceTag = p.confidence === "high" ? chalk21.green("[high]") : p.confidence === "medium" ? chalk21.yellow("[medium]") : chalk21.dim("[low]");
7160
- const reasonTag = chalk21.dim(`[${p.reason}]`);
7161
- console.log(` ${confidenceTag} ${chalk21.green(p.file)}:${chalk21.yellow(String(p.line))} ${reasonTag}`);
7162
- console.log(` ${chalk21.dim(p.preview)}`);
7894
+ const confidenceTag = p.confidence === "high" ? chalk24.green("[high]") : p.confidence === "medium" ? chalk24.yellow("[medium]") : chalk24.dim("[low]");
7895
+ const reasonTag = chalk24.dim(`[${p.reason}]`);
7896
+ console.log(` ${confidenceTag} ${chalk24.green(p.file)}:${chalk24.yellow(String(p.line))} ${reasonTag}`);
7897
+ console.log(` ${chalk24.dim(p.preview)}`);
7163
7898
  }
7164
7899
  console.log();
7165
7900
  }
7166
7901
  if (result.datasets.length > 0) {
7167
- console.log(chalk21.bold(` Datasets Found (${String(result.datasets.length)}):`));
7902
+ console.log(chalk24.bold(` Datasets Found (${String(result.datasets.length)}):`));
7168
7903
  console.log();
7169
7904
  for (const d of result.datasets) {
7170
- console.log(` ${chalk21.green(d.file)} ${chalk21.dim(`(${String(d.items)} items)`)}`);
7905
+ console.log(` ${chalk24.green(d.file)} ${chalk24.dim(`(${String(d.items)} items)`)}`);
7171
7906
  }
7172
7907
  console.log();
7173
7908
  }
7174
7909
  if (result.markers.length > 0) {
7175
- console.log(chalk21.bold(` MutagenT Markers (${String(result.markers.length)}):`));
7910
+ console.log(chalk24.bold(` MutagenT Markers (${String(result.markers.length)}):`));
7176
7911
  console.log();
7177
7912
  for (const m of result.markers) {
7178
- const idPart = m.platformId ? chalk21.cyan(` id=${m.platformId}`) : "";
7179
- console.log(` ${chalk21.green(m.file)}:${chalk21.yellow(String(m.line))} ${chalk21.magenta(m.type)}${idPart}`);
7913
+ const idPart = m.platformId ? chalk24.cyan(` id=${m.platformId}`) : "";
7914
+ console.log(` ${chalk24.green(m.file)}:${chalk24.yellow(String(m.line))} ${chalk24.magenta(m.type)}${idPart}`);
7180
7915
  }
7181
7916
  console.log();
7182
7917
  }
7183
- console.log(chalk21.dim(" ─────────────────────────────────"));
7184
- console.log(` ${chalk21.bold("Summary:")} ${String(result.prompts.length)} prompts, ${String(result.datasets.length)} datasets, ${String(result.markers.length)} markers`);
7185
- console.log(chalk21.dim(` Saved to .mutagent/mutation-context.md`));
7918
+ console.log(chalk24.dim(" ─────────────────────────────────"));
7919
+ console.log(` ${chalk24.bold("Summary:")} ${String(result.prompts.length)} prompts, ${String(result.datasets.length)} datasets, ${String(result.markers.length)} markers`);
7920
+ console.log(chalk24.dim(` Saved to .mutagent/mutation-context.md`));
7186
7921
  console.log();
7187
7922
  }
7188
7923
  } catch (error) {
@@ -7194,7 +7929,7 @@ Scanning ${scanPath}...
7194
7929
 
7195
7930
  // src/commands/skills.ts
7196
7931
  import { Command as Command16 } from "commander";
7197
- import chalk22 from "chalk";
7932
+ import chalk25 from "chalk";
7198
7933
  import { existsSync as existsSync12, mkdirSync as mkdirSync4, writeFileSync as writeFileSync5 } from "fs";
7199
7934
  import { join as join7 } from "path";
7200
7935
  import { execSync as execSync4 } from "child_process";
@@ -7318,7 +8053,7 @@ function createSkillsCommand() {
7318
8053
  const skills = new Command16("skills").description("Manage MutagenT CLI skills for coding agents");
7319
8054
  skills.command("install").description("Install MutagenT CLI skill for Claude Code").addHelpText("after", `
7320
8055
  Examples:
7321
- ${chalk22.dim("$")} mutagent skills install
8056
+ ${chalk25.dim("$")} mutagent skills install
7322
8057
 
7323
8058
  This creates a Claude Code skill at .claude/skills/mutagent-cli/SKILL.md
7324
8059
  that teaches coding agents how to use the MutagenT CLI effectively.
@@ -7345,10 +8080,10 @@ ${SKILL_BODY}
7345
8080
  });
7346
8081
  } else {
7347
8082
  output.success(`Installed MutagenT CLI skill`);
7348
- console.log(` ${chalk22.dim("Path:")} ${skillPath}`);
8083
+ console.log(` ${chalk25.dim("Path:")} ${skillPath}`);
7349
8084
  console.log("");
7350
- console.log(` ${chalk22.dim("This skill teaches coding agents how to use the MutagenT CLI.")}`);
7351
- console.log(` ${chalk22.dim("It will be automatically loaded by Claude Code when relevant triggers match.")}`);
8085
+ console.log(` ${chalk25.dim("This skill teaches coding agents how to use the MutagenT CLI.")}`);
8086
+ console.log(` ${chalk25.dim("It will be automatically loaded by Claude Code when relevant triggers match.")}`);
7352
8087
  }
7353
8088
  });
7354
8089
  return skills;
@@ -7357,7 +8092,7 @@ ${SKILL_BODY}
7357
8092
  // src/commands/usage.ts
7358
8093
  init_config();
7359
8094
  import { Command as Command17 } from "commander";
7360
- import chalk23 from "chalk";
8095
+ import chalk26 from "chalk";
7361
8096
  init_errors();
7362
8097
  init_sdk_client();
7363
8098
  var TRIAL_OPTIMIZATION_LIMIT = 5;
@@ -7373,8 +8108,8 @@ function renderProgressBar(used, limit, width = 30) {
7373
8108
  function createUsageCommand() {
7374
8109
  const usage = new Command17("usage").description("Show resource counts and optimization run limits").addHelpText("after", `
7375
8110
  Examples:
7376
- ${chalk23.dim("$")} mutagent usage
7377
- ${chalk23.dim("$")} mutagent usage --json
8111
+ ${chalk26.dim("$")} mutagent usage
8112
+ ${chalk26.dim("$")} mutagent usage --json
7378
8113
  `);
7379
8114
  usage.action(async () => {
7380
8115
  const isJson = getJsonFlag(usage);
@@ -7429,21 +8164,21 @@ Examples:
7429
8164
  });
7430
8165
  } else {
7431
8166
  console.log("");
7432
- console.log(chalk23.bold("\uD83D\uDCCA MutagenT Usage"));
7433
- console.log(chalk23.dim("─".repeat(45)));
8167
+ console.log(chalk26.bold("\uD83D\uDCCA MutagenT Usage"));
8168
+ console.log(chalk26.dim("─".repeat(45)));
7434
8169
  console.log("");
7435
- console.log(chalk23.bold("Resources:"));
7436
- console.log(` Prompts: ${chalk23.cyan(String(promptCount))}`);
7437
- console.log(` Datasets: ${chalk23.cyan(String(datasetCount))}`);
7438
- console.log(` Evaluations: ${chalk23.cyan(String(evaluationCount))}`);
8170
+ console.log(chalk26.bold("Resources:"));
8171
+ console.log(` Prompts: ${chalk26.cyan(String(promptCount))}`);
8172
+ console.log(` Datasets: ${chalk26.cyan(String(datasetCount))}`);
8173
+ console.log(` Evaluations: ${chalk26.cyan(String(evaluationCount))}`);
7439
8174
  console.log("");
7440
- console.log(chalk23.bold(`Optimization Runs (${chalk23.yellow("trial")} plan):`));
7441
- console.log(` Remaining: ${chalk23.cyan(String(optimizationRemaining))} / ${String(optimizationLimit)}`);
8175
+ console.log(chalk26.bold(`Optimization Runs (${chalk26.yellow("trial")} plan):`));
8176
+ console.log(` Remaining: ${chalk26.cyan(String(optimizationRemaining))} / ${String(optimizationLimit)}`);
7442
8177
  console.log(` ${renderProgressBar(optimizationUsed, optimizationLimit)}`);
7443
8178
  console.log("");
7444
- console.log(chalk23.yellow(` ⚠ ${String(optimizationRemaining)} optimization runs remaining`));
7445
- console.log(chalk23.dim(` ℹ Optimization run counts are approximate`));
7446
- console.log(` Upgrade: ${chalk23.underline(BILLING_URL)}`);
8179
+ console.log(chalk26.yellow(` ⚠ ${String(optimizationRemaining)} optimization runs remaining`));
8180
+ console.log(chalk26.dim(` ℹ Optimization run counts are approximate`));
8181
+ console.log(` Upgrade: ${chalk26.underline(BILLING_URL)}`);
7447
8182
  console.log("");
7448
8183
  }
7449
8184
  } catch (error) {
@@ -7742,100 +8477,100 @@ program.name("mutagent").description(`MutagenT CLI - AI-native prompt optimizati
7742
8477
  showGlobalOptions: true
7743
8478
  });
7744
8479
  program.addHelpText("after", `
7745
- ${chalk24.yellow("Non-Interactive Mode (CI/CD & Coding Agents):")}
7746
- export MUTAGENT_API_KEY=mt_... ${chalk24.dim("or")} --api-key mt_...
7747
- --json ${chalk24.dim("for structured output")} --non-interactive ${chalk24.dim("to disable prompts")}
7748
-
7749
- ${chalk24.yellow("Command Navigation:")}
7750
- mutagent auth login --browser ${chalk24.dim("Authenticate (OAuth)")}
7751
- mutagent auth status ${chalk24.dim("Check auth + workspace")}
7752
- mutagent init ${chalk24.dim("Initialize project (.mutagentrc.json)")}
7753
- mutagent explore ${chalk24.dim("Discover prompts in codebase")}
7754
- mutagent workspaces list --json ${chalk24.dim("List workspaces (verify ID)")}
7755
- mutagent config set workspace <id> ${chalk24.dim("Set active workspace")}
7756
- mutagent usage --json ${chalk24.dim("Check plan limits")}
7757
-
7758
- mutagent prompts create --help ${chalk24.dim("Upload prompt (read help first!)")}
7759
- mutagent prompts list --json ${chalk24.dim("List prompts")}
7760
- mutagent prompts get <id> --json ${chalk24.dim("Full prompt details + schemas")}
7761
-
7762
- mutagent prompts dataset add --help ${chalk24.dim("Upload dataset (read help first!)")}
7763
- mutagent prompts dataset list <id> ${chalk24.dim("List datasets")}
7764
-
7765
- mutagent prompts evaluation create --help ${chalk24.dim("Create eval (read help first!)")}
7766
- mutagent prompts evaluation create <id> --guided --json ${chalk24.dim("Guided eval workflow")}
7767
- mutagent prompts evaluation list <id> --json ${chalk24.dim("List evaluations")}
7768
-
7769
- mutagent prompts optimize start --help ${chalk24.dim("Run optimization (read help first!)")}
7770
- mutagent prompts optimize status <job-id> ${chalk24.dim("Poll progress")}
7771
- mutagent prompts optimize results <job-id> ${chalk24.dim("View scorecard")}
7772
-
7773
- mutagent integrate <framework> ${chalk24.dim("Framework integration guide")}
7774
- mutagent hooks --help ${chalk24.dim("Hook setup for Claude Code telemetry")}
7775
- mutagent playground run <id> --input '{...}' ${chalk24.dim("Quick test")}
7776
-
7777
- ${chalk24.yellow("★ Workflow: Framework Integration (Tracing):")}
7778
- 1. mutagent explore ${chalk24.dim("← discover prompts/agents in codebase")}
7779
- 2. mutagent integrate <framework> ${chalk24.dim("← get integration instructions")}
7780
- 3. Apply tracing code to your codebase ${chalk24.dim("← follow the guide output")}
7781
- 4. mutagent traces list --json ${chalk24.dim("← verify traces are arriving")}
7782
-
7783
- ${chalk24.yellow("★ Workflow: Evaluate → Optimize:")}
7784
- 1. mutagent prompts create --help ${chalk24.dim("← read help")}
7785
- 2. mutagent prompts create ... --json ${chalk24.dim("← upload prompt with {variables} + inputSchema")}
7786
- 3. mutagent prompts dataset add --help ${chalk24.dim("← read help")}
7787
- 4. mutagent prompts dataset add <id> ... --json ${chalk24.dim("← upload dataset")}
7788
- 5. mutagent prompts evaluation create <id> --guided --json ${chalk24.dim("← guided eval")}
8480
+ ${chalk27.yellow("Non-Interactive Mode (CI/CD & Coding Agents):")}
8481
+ export MUTAGENT_API_KEY=mt_... ${chalk27.dim("or")} --api-key mt_...
8482
+ --json ${chalk27.dim("for structured output")} --non-interactive ${chalk27.dim("to disable prompts")}
8483
+
8484
+ ${chalk27.yellow("Command Navigation:")}
8485
+ mutagent auth login --browser ${chalk27.dim("Authenticate (OAuth)")}
8486
+ mutagent auth status ${chalk27.dim("Check auth + workspace")}
8487
+ mutagent init ${chalk27.dim("Initialize project (.mutagentrc.json)")}
8488
+ mutagent explore ${chalk27.dim("Discover prompts in codebase")}
8489
+ mutagent workspaces list --json ${chalk27.dim("List workspaces (verify ID)")}
8490
+ mutagent config set workspace <id> ${chalk27.dim("Set active workspace")}
8491
+ mutagent usage --json ${chalk27.dim("Check plan limits")}
8492
+
8493
+ mutagent prompts create --help ${chalk27.dim("Upload prompt (read help first!)")}
8494
+ mutagent prompts list --json ${chalk27.dim("List prompts")}
8495
+ mutagent prompts get <id> --json ${chalk27.dim("Full prompt details + schemas")}
8496
+
8497
+ mutagent prompts dataset add --help ${chalk27.dim("Upload dataset (read help first!)")}
8498
+ mutagent prompts dataset list <id> ${chalk27.dim("List datasets")}
8499
+
8500
+ mutagent prompts evaluation create --help ${chalk27.dim("Create eval (read help first!)")}
8501
+ mutagent prompts evaluation create <id> --guided --json ${chalk27.dim("Guided eval workflow")}
8502
+ mutagent prompts evaluation list <id> --json ${chalk27.dim("List evaluations")}
8503
+
8504
+ mutagent prompts optimize start --help ${chalk27.dim("Run optimization (read help first!)")}
8505
+ mutagent prompts optimize status <job-id> ${chalk27.dim("Poll progress")}
8506
+ mutagent prompts optimize results <job-id> ${chalk27.dim("View scorecard")}
8507
+
8508
+ mutagent integrate <framework> ${chalk27.dim("Framework integration guide")}
8509
+ mutagent hooks --help ${chalk27.dim("Hook setup for Claude Code telemetry")}
8510
+ mutagent playground run <id> --input '{...}' ${chalk27.dim("Quick test")}
8511
+
8512
+ ${chalk27.yellow("★ Workflow: Framework Integration (Tracing):")}
8513
+ 1. mutagent explore ${chalk27.dim("← discover prompts/agents in codebase")}
8514
+ 2. mutagent integrate <framework> ${chalk27.dim("← get integration instructions")}
8515
+ 3. Apply tracing code to your codebase ${chalk27.dim("← follow the guide output")}
8516
+ 4. mutagent traces list --json ${chalk27.dim("← verify traces are arriving")}
8517
+
8518
+ ${chalk27.yellow("★ Workflow: Evaluate → Optimize:")}
8519
+ 1. mutagent prompts create --help ${chalk27.dim("← read help")}
8520
+ 2. mutagent prompts create ... --json ${chalk27.dim("← upload prompt with {variables} + inputSchema")}
8521
+ 3. mutagent prompts dataset add --help ${chalk27.dim("← read help")}
8522
+ 4. mutagent prompts dataset add <id> ... --json ${chalk27.dim("← upload dataset")}
8523
+ 5. mutagent prompts evaluation create <id> --guided --json ${chalk27.dim("← guided eval")}
7789
8524
  6. mutagent prompts optimize start <id> --dataset <d> --evaluation <e> --json
7790
8525
 
7791
- ${chalk24.yellow("Post-Onboarding Decision Tree:")}
7792
- After ${chalk24.bold("mutagent auth login")}, users land in one of 3 paths:
7793
- ${chalk24.bold("Path A")} (Tracing): explore → integrate <framework> → apply tracing → verify
7794
- ${chalk24.bold("Path B")} (Optimization): explore → prompts create → dataset add → eval create → optimize
7795
- ${chalk24.bold("Path C")} (Manual): Use CLI commands directly — run mutagent <command> --help
8526
+ ${chalk27.yellow("Post-Onboarding Decision Tree:")}
8527
+ After ${chalk27.bold("mutagent auth login")}, users land in one of 3 paths:
8528
+ ${chalk27.bold("Path A")} (Tracing): explore → integrate <framework> → apply tracing → verify
8529
+ ${chalk27.bold("Path B")} (Optimization): explore → prompts create → dataset add → eval create → optimize
8530
+ ${chalk27.bold("Path C")} (Manual): Use CLI commands directly — run mutagent <command> --help
7796
8531
 
7797
- ${chalk24.yellow("Directive System:")}
8532
+ ${chalk27.yellow("Directive System:")}
7798
8533
  Every --json response may include:
7799
- ${chalk24.bold("_directive.renderedCard")} Pre-formatted card for the user ${chalk24.red("(MUST be shown in chat)")}
7800
- ${chalk24.bold("_directive.instruction")} Next step for the agent
7801
- ${chalk24.bold("_directive.next")} Array of suggested follow-up commands
7802
- ${chalk24.bold("_links")} Dashboard/API URLs (format as markdown links)
8534
+ ${chalk27.bold("_directive.renderedCard")} Pre-formatted card for the user ${chalk27.red("(MUST be shown in chat)")}
8535
+ ${chalk27.bold("_directive.instruction")} Next step for the agent
8536
+ ${chalk27.bold("_directive.next")} Array of suggested follow-up commands
8537
+ ${chalk27.bold("_links")} Dashboard/API URLs (format as markdown links)
7803
8538
 
7804
- ${chalk24.yellow("Evaluation Criteria Format:")}
7805
- Each criterion MUST have: ${chalk24.bold("name")}, ${chalk24.bold("description")} (scoring rubric), ${chalk24.bold("evaluationParameter")}
8539
+ ${chalk27.yellow("Evaluation Criteria Format:")}
8540
+ Each criterion MUST have: ${chalk27.bold("name")}, ${chalk27.bold("description")} (scoring rubric), ${chalk27.bold("evaluationParameter")}
7806
8541
  evaluationParameter MUST match an inputSchema or outputSchema field name
7807
8542
  No duplicate evaluationParameter values — each criterion targets a unique field
7808
8543
  ALL schema fields must be covered (missing fields = error)
7809
- Use ${chalk24.bold("--guided --json")} to generate criteria templates from prompt schemas
8544
+ Use ${chalk27.bold("--guided --json")} to generate criteria templates from prompt schemas
7810
8545
 
7811
- ${chalk24.yellow("Optimization Cost Control:")}
7812
- Default max-iterations is 1. ${chalk24.red("NEVER increase without explicit user request.")}
8546
+ ${chalk27.yellow("Optimization Cost Control:")}
8547
+ Default max-iterations is 1. ${chalk27.red("NEVER increase without explicit user request.")}
7813
8548
  Each iteration incurs LLM costs — confirm with user before starting >1.
7814
8549
 
7815
- ${chalk24.yellow("Post-Optimization:")}
7816
- After ${chalk24.bold("optimize results")}: ALWAYS show the before/after diff to the user first.
7817
- Then offer choices: ${chalk24.bold("Apply")} / ${chalk24.bold("Reject")}.
8550
+ ${chalk27.yellow("Post-Optimization:")}
8551
+ After ${chalk27.bold("optimize results")}: ALWAYS show the before/after diff to the user first.
8552
+ Then offer choices: ${chalk27.bold("Apply")} / ${chalk27.bold("Reject")}.
7818
8553
 
7819
- ${chalk24.yellow("State Tracking:")}
8554
+ ${chalk27.yellow("State Tracking:")}
7820
8555
  .mutagent/mutation-context.md — Codebase index of discovered/uploaded prompts
7821
8556
  Update after explore, create, and dataset operations
7822
8557
  mutagent auth status — Auth + workspace state
7823
8558
  Comment markers (// MutagenT:START ... // MutagenT:END) in source files
7824
8559
 
7825
- ${chalk24.yellow("AI Agent Rules (MANDATORY for coding agents):")}
8560
+ ${chalk27.yellow("AI Agent Rules (MANDATORY for coding agents):")}
7826
8561
  1. EVERY command MUST include --json (no exceptions)
7827
8562
  2. Run <command> --help BEFORE first use of any command
7828
8563
  3. Use --guided --json for evaluation creation (NEVER --guided alone)
7829
8564
  4. Parse _directive.renderedCard and copy it into your CHAT RESPONSE verbatim
7830
- ${chalk24.red("HARD STOP")}: do NOT run further commands until the card is rendered in chat
8565
+ ${chalk27.red("HARD STOP")}: do NOT run further commands until the card is rendered in chat
7831
8566
  5. After mutagent init, verify workspace: mutagent workspaces list --json
7832
8567
  6. Use {single_braces} for template variables in prompts
7833
8568
  7. Collect evaluation criteria from the user — NEVER auto-generate
7834
8569
  8. ALL user interaction via AskUserQuestion — CLI is non-interactive
7835
8570
  ${!hasCredentials() ? `
7836
- ` + chalk24.yellow(" Warning: Not authenticated. Run: mutagent auth login --browser") + `
8571
+ ` + chalk27.yellow(" Warning: Not authenticated. Run: mutagent auth login --browser") + `
7837
8572
  ` : ""}${!hasRcConfig() ? `
7838
- ` + chalk24.green(" Get started: mutagent init") + `
8573
+ ` + chalk27.green(" Get started: mutagent init") + `
7839
8574
  ` : ""}`);
7840
8575
  program.hook("preAction", (thisCommand) => {
7841
8576
  const globalOpts = thisCommand.optsWithGlobals();
@@ -7866,5 +8601,5 @@ program.addCommand(createUsageCommand());
7866
8601
  program.addCommand(createHooksCommand());
7867
8602
  program.parse();
7868
8603
 
7869
- //# debugId=3B726C6C3EEAEFBE64756E2164756E21
8604
+ //# debugId=9DE14F18C9B5C35264756E2164756E21
7870
8605
  //# sourceMappingURL=cli.js.map