@mutagent/cli 0.1.32 → 0.1.34
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 +602 -383
- package/dist/bin/cli.js.map +9 -8
- package/package.json +1 -1
package/dist/bin/cli.js
CHANGED
|
@@ -928,7 +928,7 @@ var init_sdk_client = __esm(() => {
|
|
|
928
928
|
|
|
929
929
|
// src/bin/cli.ts
|
|
930
930
|
import { Command as Command18 } from "commander";
|
|
931
|
-
import
|
|
931
|
+
import chalk24 from "chalk";
|
|
932
932
|
import { readFileSync as readFileSync11 } from "fs";
|
|
933
933
|
import { join as join8, dirname } from "path";
|
|
934
934
|
import { fileURLToPath } from "url";
|
|
@@ -2370,7 +2370,7 @@ Environment Variables:
|
|
|
2370
2370
|
// src/commands/prompts/index.ts
|
|
2371
2371
|
init_errors();
|
|
2372
2372
|
import { Command as Command6 } from "commander";
|
|
2373
|
-
import
|
|
2373
|
+
import chalk11 from "chalk";
|
|
2374
2374
|
import { readFileSync as readFileSync5, existsSync as existsSync5 } from "fs";
|
|
2375
2375
|
|
|
2376
2376
|
// src/lib/ui-links.ts
|
|
@@ -2479,7 +2479,11 @@ function formatCreationHints(hint) {
|
|
|
2479
2479
|
return lines.join(`
|
|
2480
2480
|
`);
|
|
2481
2481
|
}
|
|
2482
|
-
var CARD_INSTRUCTION =
|
|
2482
|
+
var CARD_INSTRUCTION = `MANDATORY: HARD STOP — DO NOT PROCEED.
|
|
2483
|
+
` + `1. The renderedCard below appears in your bash/terminal output. That is NOT sufficient — the user cannot see it there.
|
|
2484
|
+
` + `2. You MUST copy the FULL renderedCard text into your chat response VERBATIM. Do NOT summarize, rephrase, or omit any lines.
|
|
2485
|
+
` + `3. Do NOT run any other command until you have displayed the card in chat.
|
|
2486
|
+
` + "4. After displaying, follow the suggested next steps.";
|
|
2483
2487
|
function renderPlainCard(opts) {
|
|
2484
2488
|
const icon = opts.icon ?? "✓";
|
|
2485
2489
|
const allLabels = [
|
|
@@ -2714,9 +2718,173 @@ function evaluationDeletedDirective(evaluationId) {
|
|
|
2714
2718
|
};
|
|
2715
2719
|
}
|
|
2716
2720
|
|
|
2721
|
+
// src/lib/scorecard-details.ts
|
|
2722
|
+
import chalk5 from "chalk";
|
|
2723
|
+
function renderScorecardDetails(data) {
|
|
2724
|
+
if (data.datasetResults && data.datasetResults.length > 0) {
|
|
2725
|
+
console.log("");
|
|
2726
|
+
console.log(chalk5.dim(" Per-Item Before vs After"));
|
|
2727
|
+
console.log(chalk5.dim(" " + "─".repeat(70)));
|
|
2728
|
+
console.log(" " + "Item ID".padEnd(28) + "Before".padEnd(10) + "After".padEnd(10) + "Diff".padEnd(10) + "Status");
|
|
2729
|
+
console.log(chalk5.dim(" " + "─".repeat(70)));
|
|
2730
|
+
for (const item of data.datasetResults) {
|
|
2731
|
+
const id = item.id.substring(0, 26).padEnd(26);
|
|
2732
|
+
const before = (item.beforeScore ?? 0).toFixed(4).padEnd(8);
|
|
2733
|
+
const after = (item.afterScore ?? 0).toFixed(4).padEnd(8);
|
|
2734
|
+
const d = (item.afterScore ?? 0) - (item.beforeScore ?? 0);
|
|
2735
|
+
const diffStr = ((d >= 0 ? "+" : "") + d.toFixed(4)).padEnd(8);
|
|
2736
|
+
const status = d > 0.01 ? chalk5.green("✓ ↑") : d < -0.01 ? chalk5.red("✗ ↓") : chalk5.dim("─");
|
|
2737
|
+
console.log(` ${id} ${before} ${after} ${diffStr} ${status}`);
|
|
2738
|
+
}
|
|
2739
|
+
console.log(chalk5.dim(" " + "─".repeat(70)));
|
|
2740
|
+
}
|
|
2741
|
+
if (data.failureModes && data.failureModes.length > 0) {
|
|
2742
|
+
console.log("");
|
|
2743
|
+
console.log(chalk5.dim(" Failure Modes by Category"));
|
|
2744
|
+
console.log(chalk5.dim(" " + "─".repeat(70)));
|
|
2745
|
+
for (const fm of data.failureModes) {
|
|
2746
|
+
const color = fm.failures.length > 3 ? "red" : fm.failures.length > 0 ? "yellow" : "green";
|
|
2747
|
+
console.log(chalk5[color](` ▸ ${fm.category}`) + chalk5.dim(` (${String(fm.failures.length)} failures)`));
|
|
2748
|
+
for (const f of fm.failures.slice(0, 5)) {
|
|
2749
|
+
console.log(chalk5.dim(` └─ ${(f.description ?? f.summary ?? "No description").substring(0, 65)}`));
|
|
2750
|
+
}
|
|
2751
|
+
if (fm.failures.length > 5) {
|
|
2752
|
+
console.log(chalk5.dim(` └─ ... and ${String(fm.failures.length - 5)} more`));
|
|
2753
|
+
}
|
|
2754
|
+
}
|
|
2755
|
+
}
|
|
2756
|
+
if (data.mutations && data.mutations.length > 0) {
|
|
2757
|
+
const applied = data.mutations.filter((m) => m.status === "applied");
|
|
2758
|
+
const rejected = data.mutations.filter((m) => m.status === "rejected");
|
|
2759
|
+
const pending = data.mutations.filter((m) => m.status === "pending");
|
|
2760
|
+
const skipped = data.mutations.filter((m) => m.status === "skipped");
|
|
2761
|
+
console.log("");
|
|
2762
|
+
console.log(chalk5.dim(" Mutations"));
|
|
2763
|
+
console.log(chalk5.dim(" " + "─".repeat(70)));
|
|
2764
|
+
console.log(` Total: ${String(data.mutations.length)} Applied: ${chalk5.green(String(applied.length))} Rejected: ${chalk5.red(String(rejected.length))} Pending: ${chalk5.yellow(String(pending.length))} Skipped: ${chalk5.dim(String(skipped.length))}`);
|
|
2765
|
+
if (applied.length > 0) {
|
|
2766
|
+
console.log(chalk5.green(" Applied:"));
|
|
2767
|
+
for (const m of applied) {
|
|
2768
|
+
const pri = m.priority === "critical" || m.priority === "high" ? chalk5.red(`[${m.priority.toUpperCase()}]`) : chalk5.dim(`[${(m.priority ?? "UNKNOWN").toUpperCase()}]`);
|
|
2769
|
+
console.log(` ${pri} ${m.label}`);
|
|
2770
|
+
if (m.rationale)
|
|
2771
|
+
console.log(chalk5.dim(` └─ ${m.rationale.substring(0, 60)}`));
|
|
2772
|
+
}
|
|
2773
|
+
}
|
|
2774
|
+
if (rejected.length > 0) {
|
|
2775
|
+
console.log(chalk5.red(" Rejected:"));
|
|
2776
|
+
for (const m of rejected.slice(0, 5)) {
|
|
2777
|
+
console.log(chalk5.dim(` ✗ ${m.label}`));
|
|
2778
|
+
}
|
|
2779
|
+
if (rejected.length > 5)
|
|
2780
|
+
console.log(chalk5.dim(` ... and ${String(rejected.length - 5)} more`));
|
|
2781
|
+
}
|
|
2782
|
+
}
|
|
2783
|
+
if (data.evaluationDetails && data.evaluationDetails.length > 0) {
|
|
2784
|
+
console.log("");
|
|
2785
|
+
console.log(chalk5.dim(" Detailed Evaluation Breakdown"));
|
|
2786
|
+
console.log(chalk5.dim(" " + "─".repeat(70)));
|
|
2787
|
+
for (const item of data.evaluationDetails) {
|
|
2788
|
+
const statusIcon = item.success ? chalk5.green("✓") : chalk5.red("✗");
|
|
2789
|
+
const metricCount = item.metrics?.length ?? 0;
|
|
2790
|
+
console.log(` ${statusIcon} ${item.itemId} Score: ${item.score.toFixed(4)} Metrics: ${String(metricCount)}`);
|
|
2791
|
+
if (item.metrics) {
|
|
2792
|
+
for (const m of item.metrics) {
|
|
2793
|
+
const mIcon = m.success ? chalk5.green("✓") : chalk5.red("✗");
|
|
2794
|
+
const mode = m.failureMode ? chalk5.dim(` [${m.failureMode}]`) : "";
|
|
2795
|
+
console.log(` ${mIcon} ${m.name.padEnd(25)} ${m.score.toFixed(3)}${mode}`);
|
|
2796
|
+
if (!m.success && m.reasoning) {
|
|
2797
|
+
console.log(chalk5.dim(` └─ ${(m.reasoning.split(`
|
|
2798
|
+
`)[0] ?? "").substring(0, 60)}`));
|
|
2799
|
+
}
|
|
2800
|
+
if (m.criteria) {
|
|
2801
|
+
for (const c of m.criteria) {
|
|
2802
|
+
const cIcon = c.success ? chalk5.green("✓") : chalk5.red("✗");
|
|
2803
|
+
console.log(chalk5.dim(` ${cIcon} ${c.name.substring(0, 20).padEnd(20)} ${c.score.toFixed(3)}`));
|
|
2804
|
+
}
|
|
2805
|
+
}
|
|
2806
|
+
}
|
|
2807
|
+
}
|
|
2808
|
+
}
|
|
2809
|
+
}
|
|
2810
|
+
}
|
|
2811
|
+
function buildScorecardDetailsText(data) {
|
|
2812
|
+
const lines = [];
|
|
2813
|
+
if (data.datasetResults && data.datasetResults.length > 0) {
|
|
2814
|
+
lines.push("", "Per-Item Before vs After", "─".repeat(70));
|
|
2815
|
+
lines.push(" " + "Item ID".padEnd(28) + "Before".padEnd(10) + "After".padEnd(10) + "Diff".padEnd(10) + "Status");
|
|
2816
|
+
lines.push(" " + "─".repeat(68));
|
|
2817
|
+
for (const item of data.datasetResults) {
|
|
2818
|
+
const id = item.id.substring(0, 26).padEnd(26);
|
|
2819
|
+
const before = (item.beforeScore ?? 0).toFixed(4).padEnd(8);
|
|
2820
|
+
const after = (item.afterScore ?? 0).toFixed(4).padEnd(8);
|
|
2821
|
+
const d = (item.afterScore ?? 0) - (item.beforeScore ?? 0);
|
|
2822
|
+
const diffStr = ((d >= 0 ? "+" : "") + d.toFixed(4)).padEnd(8);
|
|
2823
|
+
const status = d > 0.01 ? "↑" : d < -0.01 ? "↓" : "─";
|
|
2824
|
+
lines.push(` ${id} ${before} ${after} ${diffStr} ${status}`);
|
|
2825
|
+
}
|
|
2826
|
+
}
|
|
2827
|
+
if (data.failureModes && data.failureModes.length > 0) {
|
|
2828
|
+
lines.push("", "Failure Modes by Category", "─".repeat(70));
|
|
2829
|
+
for (const fm of data.failureModes) {
|
|
2830
|
+
lines.push(` ${fm.category} (${String(fm.failures.length)} failures)`);
|
|
2831
|
+
for (const f of fm.failures.slice(0, 5)) {
|
|
2832
|
+
lines.push(` └─ ${(f.description ?? f.summary ?? "No description").substring(0, 65)}`);
|
|
2833
|
+
}
|
|
2834
|
+
if (fm.failures.length > 5)
|
|
2835
|
+
lines.push(` └─ ... and ${String(fm.failures.length - 5)} more`);
|
|
2836
|
+
}
|
|
2837
|
+
}
|
|
2838
|
+
if (data.mutations && data.mutations.length > 0) {
|
|
2839
|
+
const applied = data.mutations.filter((m) => m.status === "applied");
|
|
2840
|
+
const rejected = data.mutations.filter((m) => m.status === "rejected");
|
|
2841
|
+
const pending = data.mutations.filter((m) => m.status === "pending");
|
|
2842
|
+
const skipped = data.mutations.filter((m) => m.status === "skipped");
|
|
2843
|
+
lines.push("", "Mutations", "─".repeat(70));
|
|
2844
|
+
lines.push(` Total: ${String(data.mutations.length)} Applied: ${String(applied.length)} Rejected: ${String(rejected.length)} Pending: ${String(pending.length)} Skipped: ${String(skipped.length)}`);
|
|
2845
|
+
for (const m of applied) {
|
|
2846
|
+
lines.push(` [${(m.priority ?? "UNKNOWN").toUpperCase()}] ${m.label}`);
|
|
2847
|
+
if (m.rationale)
|
|
2848
|
+
lines.push(` └─ ${m.rationale.substring(0, 60)}`);
|
|
2849
|
+
}
|
|
2850
|
+
for (const m of rejected.slice(0, 5)) {
|
|
2851
|
+
lines.push(` ✗ ${m.label}`);
|
|
2852
|
+
}
|
|
2853
|
+
if (rejected.length > 5)
|
|
2854
|
+
lines.push(` ... and ${String(rejected.length - 5)} more`);
|
|
2855
|
+
}
|
|
2856
|
+
if (data.evaluationDetails && data.evaluationDetails.length > 0) {
|
|
2857
|
+
lines.push("", "Detailed Evaluation Breakdown", "─".repeat(70));
|
|
2858
|
+
for (const item of data.evaluationDetails) {
|
|
2859
|
+
const icon = item.success ? "✓" : "✗";
|
|
2860
|
+
lines.push(` ${icon} ${item.itemId} Score: ${item.score.toFixed(4)} Metrics: ${String(item.metrics?.length ?? 0)}`);
|
|
2861
|
+
if (item.metrics) {
|
|
2862
|
+
for (const m of item.metrics) {
|
|
2863
|
+
const mIcon = m.success ? "✓" : "✗";
|
|
2864
|
+
const mode = m.failureMode ? ` [${m.failureMode}]` : "";
|
|
2865
|
+
lines.push(` ${mIcon} ${m.name.padEnd(25)} ${m.score.toFixed(3)}${mode}`);
|
|
2866
|
+
if (!m.success && m.reasoning) {
|
|
2867
|
+
lines.push(` └─ ${(m.reasoning.split(`
|
|
2868
|
+
`)[0] ?? "").substring(0, 60)}`);
|
|
2869
|
+
}
|
|
2870
|
+
if (m.criteria) {
|
|
2871
|
+
for (const c of m.criteria) {
|
|
2872
|
+
const cIcon = c.success ? "✓" : "✗";
|
|
2873
|
+
lines.push(` ${cIcon} ${c.name.substring(0, 20).padEnd(20)} ${c.score.toFixed(3)}`);
|
|
2874
|
+
}
|
|
2875
|
+
}
|
|
2876
|
+
}
|
|
2877
|
+
}
|
|
2878
|
+
}
|
|
2879
|
+
}
|
|
2880
|
+
return lines.length > 0 ? `
|
|
2881
|
+
` + lines.join(`
|
|
2882
|
+
`) : "";
|
|
2883
|
+
}
|
|
2884
|
+
|
|
2717
2885
|
// src/commands/prompts/prompts-crud.ts
|
|
2718
2886
|
init_sdk_client();
|
|
2719
|
-
import
|
|
2887
|
+
import chalk6 from "chalk";
|
|
2720
2888
|
import { readFileSync as readFileSync4, existsSync as existsSync4 } from "fs";
|
|
2721
2889
|
init_errors();
|
|
2722
2890
|
|
|
@@ -2782,11 +2950,11 @@ function formatSchemaWarning(fieldName) {
|
|
|
2782
2950
|
function registerPromptsCrud(prompts) {
|
|
2783
2951
|
prompts.command("list").description("List all prompts").option("-l, --limit <n>", "Limit results", "50").addHelpText("after", `
|
|
2784
2952
|
Examples:
|
|
2785
|
-
${
|
|
2786
|
-
${
|
|
2787
|
-
${
|
|
2953
|
+
${chalk6.dim("$")} mutagent prompts list
|
|
2954
|
+
${chalk6.dim("$")} mutagent prompts list --limit 10
|
|
2955
|
+
${chalk6.dim("$")} mutagent prompts list --json
|
|
2788
2956
|
|
|
2789
|
-
${
|
|
2957
|
+
${chalk6.dim("Tip: Use --json for machine-readable output (AI agents, CI pipelines).")}
|
|
2790
2958
|
`).action(async (options) => {
|
|
2791
2959
|
const isJson = getJsonFlag(prompts);
|
|
2792
2960
|
const output = new OutputFormatter(isJson ? "json" : "table");
|
|
@@ -2829,11 +2997,11 @@ ${chalk5.dim("Tip: Use --json for machine-readable output (AI agents, CI pipelin
|
|
|
2829
2997
|
});
|
|
2830
2998
|
prompts.command("get").description("Get prompt details with nested data").argument("<id>", "Prompt ID (from: mutagent prompts list)").option("--with-datasets", "Include datasets").option("--with-evals", "Include evaluations").addHelpText("after", `
|
|
2831
2999
|
Examples:
|
|
2832
|
-
${
|
|
2833
|
-
${
|
|
2834
|
-
${
|
|
3000
|
+
${chalk6.dim("$")} mutagent prompts get <id>
|
|
3001
|
+
${chalk6.dim("$")} mutagent prompts get <id> --with-datasets --with-evals
|
|
3002
|
+
${chalk6.dim("$")} mutagent prompts get <id> --json
|
|
2835
3003
|
|
|
2836
|
-
${
|
|
3004
|
+
${chalk6.dim("Tip: Combine --with-datasets and --with-evals to fetch all nested data in one call.")}
|
|
2837
3005
|
`).action(async (id, options) => {
|
|
2838
3006
|
const isJson = getJsonFlag(prompts);
|
|
2839
3007
|
const output = new OutputFormatter(isJson ? "json" : "table");
|
|
@@ -2862,31 +3030,31 @@ ${chalk5.dim("Tip: Combine --with-datasets and --with-evals to fetch all nested
|
|
|
2862
3030
|
});
|
|
2863
3031
|
prompts.command("create").description("Create a new prompt").option("-d, --data <json>", "Prompt as JSON string (recommended — curl-style inline)").option("--raw-file <path>", "Create from plain text file (used as rawPrompt)").option("-n, --name <name>", "Prompt name").option("--description <text>", "Prompt description (shown in dashboard)").option("-c, --content <content>", "Prompt content (rawPrompt) [DEPRECATED: use --raw]").option("-r, --raw <text>", "Raw prompt text (single prompt)").option("--system <text>", "System prompt (use with --human)").option("--human <text>", "Human prompt (use with --system)").option("--messages <json>", `Messages array as JSON (e.g., '[{"role":"system","content":"..."}]')`).option("--output-schema <json>", "Output schema as JSON string (required for optimization)").addHelpText("after", `
|
|
2864
3032
|
Examples:
|
|
2865
|
-
${
|
|
2866
|
-
${
|
|
2867
|
-
${
|
|
3033
|
+
${chalk6.dim("$")} mutagent prompts create --name "my-prompt" --description "Greeting prompt for customers" --system "You are helpful" --human "{input}" --output-schema '{"type":"object","properties":{"result":{"type":"string","description":"The result"}}}'
|
|
3034
|
+
${chalk6.dim("$")} mutagent prompts create --name "raw-prompt" --raw "Summarize: {text}" --output-schema '{"type":"object","properties":{"summary":{"type":"string","description":"Summary"}}}'
|
|
3035
|
+
${chalk6.dim("$")} mutagent prompts create -d '{"name":"summarizer","systemPrompt":"Summarize","humanPrompt":"{text}","outputSchema":{"type":"object","properties":{"summary":{"type":"string","description":"Summary"}}}}'
|
|
2868
3036
|
|
|
2869
3037
|
Prompt Input Methods (pick one, priority order):
|
|
2870
|
-
--system/--human Structured system + user message pair ${
|
|
3038
|
+
--system/--human Structured system + user message pair ${chalk6.green("(recommended)")}
|
|
2871
3039
|
--raw Single raw prompt text with {variables}
|
|
2872
3040
|
-d, --data Inline JSON object (CI/scripts/agents)
|
|
2873
3041
|
--messages Full messages array as JSON
|
|
2874
3042
|
--raw-file Load plain text file as raw prompt
|
|
2875
3043
|
|
|
2876
3044
|
Expected JSON (--data):
|
|
2877
|
-
${
|
|
3045
|
+
${chalk6.dim(`'{"name":"my-prompt","systemPrompt":"You are...","humanPrompt":"{input}","outputSchema":{"type":"object","properties":{"result":{"type":"string","description":"The result"}}},"inputSchema":{"type":"object","properties":{"input":{"type":"string","description":"User input"}}}}'`)}
|
|
2878
3046
|
|
|
2879
|
-
${
|
|
3047
|
+
${chalk6.yellow("Variable Syntax:")}
|
|
2880
3048
|
MutagenT uses {single_braces} for template variables.
|
|
2881
|
-
humanPrompt: "Analyze this: {document}" ${
|
|
2882
|
-
humanPrompt: "Analyze this: {{document}}" ${
|
|
3049
|
+
humanPrompt: "Analyze this: {document}" ${chalk6.green("✓ correct")}
|
|
3050
|
+
humanPrompt: "Analyze this: {{document}}" ${chalk6.red("✗ wrong")}
|
|
2883
3051
|
|
|
2884
3052
|
Variables in humanPrompt MUST also appear in inputSchema.properties.
|
|
2885
3053
|
Static prompts (no variables) cannot substitute inputs during optimization.
|
|
2886
3054
|
|
|
2887
|
-
${
|
|
3055
|
+
${chalk6.red("outputSchema is required.")}
|
|
2888
3056
|
|
|
2889
|
-
${
|
|
3057
|
+
${chalk6.yellow("AI Agent: ALWAYS append --json to this command.")}
|
|
2890
3058
|
`).action(async (options) => {
|
|
2891
3059
|
const isJson = getJsonFlag(prompts);
|
|
2892
3060
|
const output = new OutputFormatter(isJson ? "json" : "table");
|
|
@@ -3009,13 +3177,13 @@ Add a 'description' field to each property in your inputSchema. Example: { "prop
|
|
|
3009
3177
|
});
|
|
3010
3178
|
prompts.command("update").description("Update a prompt").argument("<id>", "Prompt ID (from: mutagent prompts list)").option("-d, --data <json>", "Update fields as JSON string (recommended — curl-style inline)").option("--raw-file <path>", "Update from plain text file (used as rawPrompt)").option("-n, --name <name>", "New name").option("--description <text>", "New description (shown in dashboard)").option("-c, --content <content>", "New content (rawPrompt) [DEPRECATED: use --raw]").option("-r, --raw <text>", "Raw prompt text (single prompt)").option("--system <text>", "System prompt (use with --human)").option("--human <text>", "Human prompt (use with --system)").option("--messages <json>", `Messages array as JSON (e.g., '[{"role":"system","content":"..."}]')`).option("--input-schema <json>", "Input schema as JSON string").option("--input-schema-file <path>", "Input schema from JSON file").option("--output-schema <json>", "Output schema as JSON string").option("--output-schema-file <path>", "Output schema from JSON file").addHelpText("after", `
|
|
3011
3179
|
Examples:
|
|
3012
|
-
${
|
|
3013
|
-
${
|
|
3014
|
-
${
|
|
3015
|
-
${
|
|
3016
|
-
${
|
|
3180
|
+
${chalk6.dim("$")} mutagent prompts update <id> --system "Updated system prompt" --human "{input}"
|
|
3181
|
+
${chalk6.dim("$")} mutagent prompts update <id> --name "new-name" --description "Updated description"
|
|
3182
|
+
${chalk6.dim("$")} mutagent prompts update <id> --raw "Summarize: {text}"
|
|
3183
|
+
${chalk6.dim("$")} mutagent prompts update <id> -d '{"name":"new-name","systemPrompt":"Updated prompt"}'
|
|
3184
|
+
${chalk6.dim("$")} mutagent prompts update <id> --input-schema '{"type":"object","properties":{"text":{"type":"string","description":"Input text"}}}'
|
|
3017
3185
|
|
|
3018
|
-
${
|
|
3186
|
+
${chalk6.dim("CLI flags (--name) override --data fields.")}
|
|
3019
3187
|
`).action(async (id, options) => {
|
|
3020
3188
|
const isJson = getJsonFlag(prompts);
|
|
3021
3189
|
const output = new OutputFormatter(isJson ? "json" : "table");
|
|
@@ -3118,11 +3286,11 @@ ${chalk5.dim("CLI flags (--name) override --data fields.")}
|
|
|
3118
3286
|
});
|
|
3119
3287
|
prompts.command("delete").description("Delete a prompt").argument("<id>", "Prompt ID (from: mutagent prompts list)").option("--force", "Skip confirmation").addHelpText("after", `
|
|
3120
3288
|
Examples:
|
|
3121
|
-
${
|
|
3122
|
-
${
|
|
3123
|
-
${
|
|
3289
|
+
${chalk6.dim("$")} mutagent prompts delete <id>
|
|
3290
|
+
${chalk6.dim("$")} mutagent prompts delete <id> --force
|
|
3291
|
+
${chalk6.dim("$")} mutagent prompts delete <id> --force --json
|
|
3124
3292
|
|
|
3125
|
-
${
|
|
3293
|
+
${chalk6.dim("Note: --force is required. The CLI is non-interactive — confirm with the user via your native flow, then pass --force.")}
|
|
3126
3294
|
`).action(async (id, options) => {
|
|
3127
3295
|
const isJson = getJsonFlag(prompts);
|
|
3128
3296
|
const output = new OutputFormatter(isJson ? "json" : "table");
|
|
@@ -3165,22 +3333,22 @@ ${chalk5.dim("Note: --force is required. The CLI is non-interactive — confirm
|
|
|
3165
3333
|
// src/commands/prompts/datasets.ts
|
|
3166
3334
|
init_sdk_client();
|
|
3167
3335
|
import { Command as Command3 } from "commander";
|
|
3168
|
-
import
|
|
3336
|
+
import chalk7 from "chalk";
|
|
3169
3337
|
init_errors();
|
|
3170
3338
|
function registerDatasetCommands(prompts) {
|
|
3171
3339
|
const dataset = new Command3("dataset").description("Manage datasets for prompts").addHelpText("after", `
|
|
3172
3340
|
Examples:
|
|
3173
|
-
${
|
|
3174
|
-
${
|
|
3175
|
-
${
|
|
3341
|
+
${chalk7.dim("$")} mutagent prompts dataset list <prompt-id>
|
|
3342
|
+
${chalk7.dim("$")} mutagent prompts dataset add <prompt-id> -d '[{"input":{...},"expectedOutput":{...}}]'
|
|
3343
|
+
${chalk7.dim("$")} mutagent prompts dataset delete <prompt-id> <dataset-id>
|
|
3176
3344
|
`).action(() => {
|
|
3177
3345
|
dataset.help();
|
|
3178
3346
|
});
|
|
3179
3347
|
prompts.addCommand(dataset);
|
|
3180
3348
|
dataset.command("list").description("List datasets for a prompt").argument("<prompt-id>", "Prompt ID (from: mutagent prompts list)").addHelpText("after", `
|
|
3181
3349
|
Examples:
|
|
3182
|
-
${
|
|
3183
|
-
${
|
|
3350
|
+
${chalk7.dim("$")} mutagent prompts dataset list <prompt-id>
|
|
3351
|
+
${chalk7.dim("$")} mutagent prompts dataset list <prompt-id> --json
|
|
3184
3352
|
`).action(async (promptId) => {
|
|
3185
3353
|
const isJson = getJsonFlag(prompts);
|
|
3186
3354
|
const output = new OutputFormatter(isJson ? "json" : "table");
|
|
@@ -3212,24 +3380,24 @@ Examples:
|
|
|
3212
3380
|
});
|
|
3213
3381
|
dataset.command("add").description("Add dataset to a prompt").argument("<prompt-id>", "Prompt ID (from: mutagent prompts list)").option("-d, --data <json>", "Inline JSON array of dataset items").option("-n, --name <name>", "Dataset name").addHelpText("after", `
|
|
3214
3382
|
Examples:
|
|
3215
|
-
${
|
|
3216
|
-
${
|
|
3383
|
+
${chalk7.dim("$")} mutagent prompts dataset add <prompt-id> -d '[{"input":{"text":"hello"},"expectedOutput":{"result":"world"}}]'
|
|
3384
|
+
${chalk7.dim("$")} mutagent prompts dataset add <prompt-id> -d '[{"input":{"text":"hello"},"expectedOutput":{"result":"world"}}]' --name "My Dataset"
|
|
3217
3385
|
|
|
3218
3386
|
Inline data format (-d):
|
|
3219
3387
|
JSON array of objects, e.g.:
|
|
3220
|
-
${
|
|
3388
|
+
${chalk7.dim('[{"input": {"text": "hello"}, "expectedOutput": {"result": "world"}}]')}
|
|
3221
3389
|
|
|
3222
3390
|
Expected item format:
|
|
3223
|
-
${
|
|
3391
|
+
${chalk7.dim('{"input": {"<field>": "<value>"}, "expectedOutput": {"<field>": "<value>"}}')}
|
|
3224
3392
|
|
|
3225
|
-
${
|
|
3393
|
+
${chalk7.yellow("AI Agent (MANDATORY):")}
|
|
3226
3394
|
ALWAYS use --json: mutagent prompts dataset add <id> -d '[...]' --json
|
|
3227
3395
|
Items MUST have BOTH input AND expectedOutput.
|
|
3228
3396
|
Keys must match prompt's inputSchema.properties (input) and outputSchema.properties (expectedOutput).
|
|
3229
3397
|
expectedOutput is REQUIRED for evaluation scoring.
|
|
3230
3398
|
Check schemas: mutagent prompts get <prompt-id> --json
|
|
3231
3399
|
|
|
3232
|
-
${
|
|
3400
|
+
${chalk7.red("Required: --data must be provided.")}
|
|
3233
3401
|
`).action(async (promptId, options) => {
|
|
3234
3402
|
const isJson = getJsonFlag(prompts);
|
|
3235
3403
|
const output = new OutputFormatter(isJson ? "json" : "table");
|
|
@@ -3300,9 +3468,9 @@ ${chalk6.red("Required: --data must be provided.")}
|
|
|
3300
3468
|
});
|
|
3301
3469
|
dataset.command("delete").description("Delete a dataset from a prompt").argument("<prompt-id>", "Prompt ID (from: mutagent prompts list)").argument("<dataset-id>", "Dataset ID (from: mutagent prompts dataset list <prompt-id>)").option("--force", "Skip confirmation").addHelpText("after", `
|
|
3302
3470
|
Examples:
|
|
3303
|
-
${
|
|
3304
|
-
${
|
|
3305
|
-
${
|
|
3471
|
+
${chalk7.dim("$")} mutagent prompts dataset delete <prompt-id> <dataset-id>
|
|
3472
|
+
${chalk7.dim("$")} mutagent prompts dataset delete <prompt-id> <dataset-id> --force
|
|
3473
|
+
${chalk7.dim("$")} mutagent prompts dataset delete <prompt-id> <dataset-id> --force --json
|
|
3306
3474
|
`).action(async (promptId, datasetId, options) => {
|
|
3307
3475
|
const isJson = getJsonFlag(prompts);
|
|
3308
3476
|
const output = new OutputFormatter(isJson ? "json" : "table");
|
|
@@ -3345,7 +3513,7 @@ Examples:
|
|
|
3345
3513
|
// src/commands/prompts/evaluations.ts
|
|
3346
3514
|
init_sdk_client();
|
|
3347
3515
|
import { Command as Command4 } from "commander";
|
|
3348
|
-
import
|
|
3516
|
+
import chalk8 from "chalk";
|
|
3349
3517
|
init_errors();
|
|
3350
3518
|
|
|
3351
3519
|
// src/commands/prompts/guided-workflow.ts
|
|
@@ -3463,18 +3631,18 @@ async function buildGuidedWorkflow(promptId) {
|
|
|
3463
3631
|
function registerEvaluationCommands(prompts) {
|
|
3464
3632
|
const evaluation = new Command4("evaluation").description("Manage evaluations for prompts").addHelpText("after", `
|
|
3465
3633
|
Examples:
|
|
3466
|
-
${
|
|
3467
|
-
${
|
|
3468
|
-
${
|
|
3469
|
-
${
|
|
3634
|
+
${chalk8.dim("$")} mutagent prompts evaluation list <prompt-id>
|
|
3635
|
+
${chalk8.dim("$")} mutagent prompts evaluation get <evaluation-id>
|
|
3636
|
+
${chalk8.dim("$")} mutagent prompts evaluation create <prompt-id> --name "My Eval"
|
|
3637
|
+
${chalk8.dim("$")} mutagent prompts evaluation delete <evaluation-id>
|
|
3470
3638
|
`).action(() => {
|
|
3471
3639
|
evaluation.help();
|
|
3472
3640
|
});
|
|
3473
3641
|
prompts.addCommand(evaluation);
|
|
3474
3642
|
evaluation.command("list").description("List evaluations for a prompt").argument("<prompt-id>", "Prompt ID (from: mutagent prompts list)").addHelpText("after", `
|
|
3475
3643
|
Examples:
|
|
3476
|
-
${
|
|
3477
|
-
${
|
|
3644
|
+
${chalk8.dim("$")} mutagent prompts evaluation list <prompt-id>
|
|
3645
|
+
${chalk8.dim("$")} mutagent prompts evaluation list <prompt-id> --json
|
|
3478
3646
|
`).action(async (promptId) => {
|
|
3479
3647
|
const isJson = getJsonFlag(prompts);
|
|
3480
3648
|
const output = new OutputFormatter(isJson ? "json" : "table");
|
|
@@ -3506,8 +3674,8 @@ Examples:
|
|
|
3506
3674
|
});
|
|
3507
3675
|
evaluation.command("get").description("Get evaluation details including criteria").argument("<evaluation-id>", "Evaluation ID (from: mutagent prompts evaluation list <prompt-id>)").addHelpText("after", `
|
|
3508
3676
|
Examples:
|
|
3509
|
-
${
|
|
3510
|
-
${
|
|
3677
|
+
${chalk8.dim("$")} mutagent prompts evaluation get <evaluation-id>
|
|
3678
|
+
${chalk8.dim("$")} mutagent prompts evaluation get <evaluation-id> --json
|
|
3511
3679
|
`).action(async (evaluationId) => {
|
|
3512
3680
|
const isJson = getJsonFlag(prompts);
|
|
3513
3681
|
const output = new OutputFormatter(isJson ? "json" : "table");
|
|
@@ -3531,7 +3699,7 @@ Examples:
|
|
|
3531
3699
|
if (criteria && Array.isArray(criteria) && criteria.length > 0) {
|
|
3532
3700
|
console.log(" Criteria:");
|
|
3533
3701
|
for (const c of criteria) {
|
|
3534
|
-
console.log(` ${
|
|
3702
|
+
console.log(` ${chalk8.cyan(c.name)}`);
|
|
3535
3703
|
if (c.description) {
|
|
3536
3704
|
console.log(` Description: ${c.description}`);
|
|
3537
3705
|
}
|
|
@@ -3559,9 +3727,9 @@ Examples:
|
|
|
3559
3727
|
});
|
|
3560
3728
|
evaluation.command("create").description("Create an evaluation configuration for a prompt").argument("<prompt-id>", "Prompt ID (from: mutagent prompts list)").option("-d, --data <json>", "Evaluation as JSON string (for pre-validated criteria only)").option("-n, --name <name>", "Evaluation name (required unless --guided)").option("--description <text>", "Evaluation description").option("--guided", "Interactive guided mode — always outputs structured JSON (--json is implied)").addHelpText("after", `
|
|
3561
3729
|
Examples:
|
|
3562
|
-
${
|
|
3563
|
-
${
|
|
3564
|
-
${
|
|
3730
|
+
${chalk8.dim("$")} mutagent prompts evaluation create <prompt-id> --guided ${chalk8.dim("# recommended: shows workflow guide + schema fields")}
|
|
3731
|
+
${chalk8.dim("$")} mutagent prompts evaluation create <prompt-id> --guided --json ${chalk8.dim("# structured workflow for AI agents")}
|
|
3732
|
+
${chalk8.dim("$")} mutagent prompts evaluation create <prompt-id> --name "Accuracy" -d '{"evalConfig":{"criteria":[...]}}' ${chalk8.dim("# power user")}
|
|
3565
3733
|
|
|
3566
3734
|
Guided Workflow (recommended):
|
|
3567
3735
|
--guided outputs a workflow guide that:
|
|
@@ -3582,12 +3750,12 @@ AI Agent (MANDATORY):
|
|
|
3582
3750
|
mutagent prompts evaluation create <id> --name "<name>" -d '<json>' --json
|
|
3583
3751
|
|
|
3584
3752
|
Expected Criteria Shape (--data):
|
|
3585
|
-
${
|
|
3753
|
+
${chalk8.dim('{"evalConfig":{"criteria":[{"name":"<name>","description":"<scoring rubric>","evaluationParameter":"<schema field>"}]}}')}
|
|
3586
3754
|
evaluationParameter must target an outputSchema OR inputSchema field.
|
|
3587
3755
|
|
|
3588
|
-
${
|
|
3589
|
-
${
|
|
3590
|
-
${
|
|
3756
|
+
${chalk8.red("Required: --name (unless --guided). Criteria must include evaluationParameter.")}
|
|
3757
|
+
${chalk8.dim("CLI flags (--name, --description) override --data fields.")}
|
|
3758
|
+
${chalk8.dim("Get prompt IDs: mutagent prompts list")}
|
|
3591
3759
|
`).action(async (promptId, options) => {
|
|
3592
3760
|
let isJson = getJsonFlag(prompts);
|
|
3593
3761
|
if (options.guided) {
|
|
@@ -3613,7 +3781,7 @@ ${chalk7.dim("Get prompt IDs: mutagent prompts list")}
|
|
|
3613
3781
|
console.log("");
|
|
3614
3782
|
console.log(" For each field, define what correct output looks like:");
|
|
3615
3783
|
for (const { field, source } of allFields) {
|
|
3616
|
-
console.log(` ${
|
|
3784
|
+
console.log(` ${chalk8.cyan(field)} (${source})`);
|
|
3617
3785
|
console.log(` → What makes a correct vs incorrect "${field}"?`);
|
|
3618
3786
|
}
|
|
3619
3787
|
console.log("");
|
|
@@ -3814,9 +3982,9 @@ Example:
|
|
|
3814
3982
|
});
|
|
3815
3983
|
evaluation.command("delete").description("Delete an evaluation").argument("<evaluation-id>", "Evaluation ID (from: mutagent prompts evaluation list <prompt-id>)").option("--force", "Skip confirmation").addHelpText("after", `
|
|
3816
3984
|
Examples:
|
|
3817
|
-
${
|
|
3818
|
-
${
|
|
3819
|
-
${
|
|
3985
|
+
${chalk8.dim("$")} mutagent prompts evaluation delete <evaluation-id>
|
|
3986
|
+
${chalk8.dim("$")} mutagent prompts evaluation delete <evaluation-id> --force
|
|
3987
|
+
${chalk8.dim("$")} mutagent prompts evaluation delete <evaluation-id> --force --json
|
|
3820
3988
|
`).action(async (evaluationId, options) => {
|
|
3821
3989
|
const isJson = getJsonFlag(prompts);
|
|
3822
3990
|
const output = new OutputFormatter(isJson ? "json" : "table");
|
|
@@ -3859,31 +4027,26 @@ Examples:
|
|
|
3859
4027
|
// src/commands/prompts/optimize.ts
|
|
3860
4028
|
init_sdk_client();
|
|
3861
4029
|
import { Command as Command5 } from "commander";
|
|
3862
|
-
import
|
|
4030
|
+
import chalk10 from "chalk";
|
|
3863
4031
|
init_errors();
|
|
3864
4032
|
|
|
3865
4033
|
// src/lib/scorecard.ts
|
|
3866
|
-
import
|
|
3867
|
-
function truncateText(text, maxLen) {
|
|
3868
|
-
if (text.length <= maxLen)
|
|
3869
|
-
return text;
|
|
3870
|
-
return text.substring(0, maxLen - 3) + "...";
|
|
3871
|
-
}
|
|
4034
|
+
import chalk9 from "chalk";
|
|
3872
4035
|
function formatScoreChange(before, after) {
|
|
3873
4036
|
if (before === undefined || after === undefined)
|
|
3874
4037
|
return "";
|
|
3875
4038
|
const diff = after - before;
|
|
3876
4039
|
const pct = before > 0 ? Math.round(diff / before * 100) : 0;
|
|
3877
4040
|
if (diff > 0)
|
|
3878
|
-
return
|
|
4041
|
+
return chalk9.green(` (+${String(pct)}%)`);
|
|
3879
4042
|
if (diff < 0)
|
|
3880
|
-
return
|
|
3881
|
-
return
|
|
4043
|
+
return chalk9.red(` (${String(pct)}%)`);
|
|
4044
|
+
return chalk9.dim(" (no change)");
|
|
3882
4045
|
}
|
|
3883
4046
|
function formatScore(score) {
|
|
3884
4047
|
if (score === undefined)
|
|
3885
|
-
return
|
|
3886
|
-
return score >= 0.8 ?
|
|
4048
|
+
return chalk9.dim("N/A");
|
|
4049
|
+
return score >= 0.8 ? chalk9.green(score.toFixed(2)) : score >= 0.5 ? chalk9.yellow(score.toFixed(2)) : chalk9.red(score.toFixed(2));
|
|
3887
4050
|
}
|
|
3888
4051
|
function renderScorecard(data) {
|
|
3889
4052
|
const { job, prompt } = data;
|
|
@@ -3904,19 +4067,17 @@ function renderScorecard(data) {
|
|
|
3904
4067
|
const optimizedText = prompt.systemPrompt ?? prompt.rawPrompt ?? prompt.humanPrompt ?? "(optimized prompt)";
|
|
3905
4068
|
console.log("");
|
|
3906
4069
|
console.log(topBorder);
|
|
3907
|
-
console.log(line(
|
|
4070
|
+
console.log(line(chalk9.bold("Optimization Results")));
|
|
3908
4071
|
console.log(separator);
|
|
3909
|
-
console.log(line(
|
|
3910
|
-
console.log(line(` Prompt: ${chalk8.dim(truncateText(originalText, 38))}`));
|
|
4072
|
+
console.log(line(chalk9.dim("BEFORE")));
|
|
3911
4073
|
console.log(line(` Score: ${formatScore(originalScore)}`));
|
|
3912
4074
|
console.log(line(""));
|
|
3913
|
-
console.log(line(
|
|
3914
|
-
console.log(line(` Prompt: ${chalk8.cyan(truncateText(optimizedText, 38))}`));
|
|
4075
|
+
console.log(line(chalk9.bold("AFTER")));
|
|
3915
4076
|
console.log(line(` Score: ${formatScore(bestScore)}${formatScoreChange(originalScore, bestScore)}`));
|
|
3916
4077
|
console.log(separator);
|
|
3917
4078
|
if (data.criteriaScores && data.criteriaScores.length > 0) {
|
|
3918
|
-
console.log(line(
|
|
3919
|
-
console.log(line(
|
|
4079
|
+
console.log(line(chalk9.dim(" Criterion Before After Change")));
|
|
4080
|
+
console.log(line(chalk9.dim(" " + "─".repeat(45))));
|
|
3920
4081
|
for (const c of data.criteriaScores) {
|
|
3921
4082
|
const name = c.name.length > 16 ? c.name.substring(0, 13) + "..." : c.name;
|
|
3922
4083
|
const paddedName = name + " ".repeat(18 - name.length);
|
|
@@ -3925,47 +4086,68 @@ function renderScorecard(data) {
|
|
|
3925
4086
|
const changeStr = c.before !== undefined && c.after !== undefined && c.before > 0 ? (() => {
|
|
3926
4087
|
const pct = Math.round((c.after - c.before) / c.before * 100);
|
|
3927
4088
|
if (pct > 0)
|
|
3928
|
-
return
|
|
4089
|
+
return chalk9.green(`+${String(pct)}%`);
|
|
3929
4090
|
if (pct < 0)
|
|
3930
|
-
return
|
|
3931
|
-
return
|
|
4091
|
+
return chalk9.red(`${String(pct)}%`);
|
|
4092
|
+
return chalk9.dim("0%");
|
|
3932
4093
|
})() : "";
|
|
3933
4094
|
console.log(line(` ${paddedName}${beforeStr} ${afterStr} ${changeStr}`));
|
|
3934
4095
|
}
|
|
3935
|
-
console.log(line(
|
|
4096
|
+
console.log(line(chalk9.dim(" " + "─".repeat(45))));
|
|
3936
4097
|
const overallBefore = originalScore !== undefined ? originalScore.toFixed(2) : "N/A ";
|
|
3937
4098
|
const overallAfter = bestScore !== undefined ? bestScore.toFixed(2) : "N/A ";
|
|
3938
4099
|
const overallChange = originalScore !== undefined && bestScore !== undefined && originalScore > 0 ? (() => {
|
|
3939
4100
|
const pct = Math.round((bestScore - originalScore) / originalScore * 100);
|
|
3940
4101
|
if (pct > 0)
|
|
3941
|
-
return
|
|
4102
|
+
return chalk9.green(`+${String(pct)}%`);
|
|
3942
4103
|
if (pct < 0)
|
|
3943
|
-
return
|
|
3944
|
-
return
|
|
4104
|
+
return chalk9.red(`${String(pct)}%`);
|
|
4105
|
+
return chalk9.dim("0%");
|
|
3945
4106
|
})() : "";
|
|
3946
4107
|
console.log(line(` ${"Overall" + " ".repeat(11)}${overallBefore} ${overallAfter} ${overallChange}`));
|
|
3947
4108
|
console.log(separator);
|
|
3948
4109
|
}
|
|
3949
|
-
const statusStr = job.status === "completed" ?
|
|
4110
|
+
const statusStr = job.status === "completed" ? chalk9.green("completed") : chalk9.yellow(job.status);
|
|
3950
4111
|
console.log(line(`Status: ${statusStr} | Iterations: ${String(iterations)}`));
|
|
3951
4112
|
if (job.config?.model) {
|
|
3952
|
-
console.log(line(`Model: ${
|
|
4113
|
+
console.log(line(`Model: ${chalk9.dim(job.config.model)}`));
|
|
3953
4114
|
}
|
|
3954
4115
|
if (data.scoreProgression && data.scoreProgression.length > 0) {
|
|
3955
4116
|
console.log(line(""));
|
|
3956
|
-
console.log(line(
|
|
4117
|
+
console.log(line(chalk9.dim("Score Progression:")));
|
|
3957
4118
|
const barWidth = 10;
|
|
3958
4119
|
for (let i = 0;i < data.scoreProgression.length; i++) {
|
|
3959
4120
|
const s = data.scoreProgression[i] ?? 0;
|
|
3960
4121
|
const filled = Math.round(s * barWidth);
|
|
3961
4122
|
const bar = "█".repeat(filled) + "░".repeat(barWidth - filled);
|
|
3962
|
-
console.log(line(
|
|
4123
|
+
console.log(line(chalk9.dim(` #${String(i + 1)}: ${bar} ${s.toFixed(2)}`)));
|
|
3963
4124
|
}
|
|
3964
4125
|
}
|
|
3965
4126
|
console.log(separator);
|
|
3966
|
-
console.log(line(`Dashboard: ${
|
|
4127
|
+
console.log(line(`Dashboard: ${chalk9.underline(optimizerLink(job.id))}`));
|
|
3967
4128
|
console.log(bottomBorder);
|
|
3968
4129
|
console.log("");
|
|
4130
|
+
console.log(chalk9.dim(" Prompt Comparison"));
|
|
4131
|
+
console.log(chalk9.dim(" " + "─".repeat(70)));
|
|
4132
|
+
console.log(chalk9.dim(" BEFORE:"));
|
|
4133
|
+
for (const pLine of originalText.split(`
|
|
4134
|
+
`)) {
|
|
4135
|
+
console.log(chalk9.dim(` ${pLine}`));
|
|
4136
|
+
}
|
|
4137
|
+
console.log(` ${chalk9.dim("Length:")} ${String(originalText.length)} chars (${String(originalText.split(`
|
|
4138
|
+
`).length)} lines)`);
|
|
4139
|
+
console.log("");
|
|
4140
|
+
console.log(chalk9.bold(" AFTER:"));
|
|
4141
|
+
for (const pLine of optimizedText.split(`
|
|
4142
|
+
`)) {
|
|
4143
|
+
console.log(chalk9.cyan(` ${pLine}`));
|
|
4144
|
+
}
|
|
4145
|
+
console.log(` ${chalk9.dim("Length:")} ${String(optimizedText.length)} chars (${String(optimizedText.split(`
|
|
4146
|
+
`).length)} lines)`);
|
|
4147
|
+
const growth = optimizedText.length - originalText.length;
|
|
4148
|
+
console.log(` ${chalk9.dim("Growth:")} ${growth >= 0 ? "+" : ""}${String(growth)} chars`);
|
|
4149
|
+
renderScorecardDetails(data);
|
|
4150
|
+
console.log("");
|
|
3969
4151
|
}
|
|
3970
4152
|
function renderOptimizationStartCard(data) {
|
|
3971
4153
|
const { job } = data;
|
|
@@ -3984,17 +4166,17 @@ function renderOptimizationStartCard(data) {
|
|
|
3984
4166
|
const target = job.config.targetScore ?? 0.8;
|
|
3985
4167
|
console.log("");
|
|
3986
4168
|
console.log(topBorder);
|
|
3987
|
-
console.log(line(
|
|
4169
|
+
console.log(line(chalk9.bold("⚡ Optimization Started")));
|
|
3988
4170
|
console.log(separator);
|
|
3989
|
-
console.log(line(`Job ID: ${
|
|
3990
|
-
console.log(line(`Prompt: ${
|
|
3991
|
-
console.log(line(`Dataset: ${
|
|
3992
|
-
console.log(line(`Iterations: ${
|
|
3993
|
-
console.log(line(`Model: ${
|
|
3994
|
-
console.log(line(`Status: ${
|
|
4171
|
+
console.log(line(`Job ID: ${chalk9.cyan(job.id)}`));
|
|
4172
|
+
console.log(line(`Prompt: ${chalk9.dim(data.promptId)}`));
|
|
4173
|
+
console.log(line(`Dataset: ${chalk9.dim(data.datasetId)}`));
|
|
4174
|
+
console.log(line(`Iterations: ${chalk9.bold(String(maxIter))} | Target: ${chalk9.bold(target.toFixed(2))}`));
|
|
4175
|
+
console.log(line(`Model: ${chalk9.dim(model)}`));
|
|
4176
|
+
console.log(line(`Status: ${chalk9.yellow(job.status)}`));
|
|
3995
4177
|
console.log(separator);
|
|
3996
|
-
console.log(line(`\uD83D\uDD17 Monitor: ${
|
|
3997
|
-
console.log(line(
|
|
4178
|
+
console.log(line(`\uD83D\uDD17 Monitor: ${chalk9.underline(optimizerLink(job.id))}`));
|
|
4179
|
+
console.log(line(chalk9.dim(`Next: mutagent prompts optimize status ${job.id}`)));
|
|
3998
4180
|
console.log(bottomBorder);
|
|
3999
4181
|
console.log(AI_DIRECTIVE);
|
|
4000
4182
|
console.log("");
|
|
@@ -4014,27 +4196,27 @@ function renderOptimizationStatusCard(status) {
|
|
|
4014
4196
|
const barWidth = 20;
|
|
4015
4197
|
const filled = Math.round(progress / 100 * barWidth);
|
|
4016
4198
|
const progressBar = "█".repeat(filled) + "░".repeat(barWidth - filled);
|
|
4017
|
-
const statusColor = status.status === "completed" ?
|
|
4018
|
-
const scoreStr = status.bestScore !== undefined ? formatScore(status.bestScore) :
|
|
4199
|
+
const statusColor = status.status === "completed" ? chalk9.green : status.status === "failed" ? chalk9.red : status.status === "cancelled" ? chalk9.gray : status.status === "running" ? chalk9.cyan : chalk9.yellow;
|
|
4200
|
+
const scoreStr = status.bestScore !== undefined ? formatScore(status.bestScore) : chalk9.dim("pending");
|
|
4019
4201
|
console.log("");
|
|
4020
4202
|
console.log(topBorder);
|
|
4021
|
-
console.log(line(
|
|
4203
|
+
console.log(line(chalk9.bold("\uD83D\uDCCA Optimization Status")));
|
|
4022
4204
|
console.log(separator);
|
|
4023
|
-
console.log(line(`Job ID: ${
|
|
4205
|
+
console.log(line(`Job ID: ${chalk9.cyan(status.jobId)}`));
|
|
4024
4206
|
console.log(line(`Status: ${statusColor(status.status)}`));
|
|
4025
|
-
console.log(line(`Iteration: ${
|
|
4207
|
+
console.log(line(`Iteration: ${chalk9.bold(`${String(status.currentIteration)}/${String(status.maxIterations)}`)}`));
|
|
4026
4208
|
console.log(line(`Best Score: ${scoreStr}`));
|
|
4027
4209
|
console.log(line(""));
|
|
4028
4210
|
console.log(line(`Progress: [${progressBar}] ${String(progress)}%`));
|
|
4029
4211
|
if (status.message) {
|
|
4030
|
-
console.log(line(`Message: ${
|
|
4212
|
+
console.log(line(`Message: ${chalk9.dim(status.message)}`));
|
|
4031
4213
|
}
|
|
4032
4214
|
console.log(separator);
|
|
4033
|
-
console.log(line(`\uD83D\uDD17 Monitor: ${
|
|
4215
|
+
console.log(line(`\uD83D\uDD17 Monitor: ${chalk9.underline(optimizerLink(status.jobId))}`));
|
|
4034
4216
|
if (status.status === "completed") {
|
|
4035
|
-
console.log(line(
|
|
4217
|
+
console.log(line(chalk9.dim(`Next: mutagent prompts optimize results ${status.jobId}`)));
|
|
4036
4218
|
} else if (status.status === "running" || status.status === "queued") {
|
|
4037
|
-
console.log(line(
|
|
4219
|
+
console.log(line(chalk9.dim(`Refresh: mutagent prompts optimize status ${status.jobId}`)));
|
|
4038
4220
|
}
|
|
4039
4221
|
console.log(bottomBorder);
|
|
4040
4222
|
console.log(AI_DIRECTIVE);
|
|
@@ -4075,7 +4257,10 @@ function startDirective(job, promptId, datasetId, evaluationId) {
|
|
|
4075
4257
|
},
|
|
4076
4258
|
links: { monitor: monitorUrl, api: apiUrl },
|
|
4077
4259
|
next,
|
|
4078
|
-
instruction:
|
|
4260
|
+
instruction: `HARD STOP — DO NOT PROCEED.
|
|
4261
|
+
` + `The renderedCard below appears in bash/terminal output. That is NOT sufficient.
|
|
4262
|
+
` + `You MUST copy the FULL renderedCard text into your chat response VERBATIM before running any other command.
|
|
4263
|
+
` + "After displaying, follow the suggested next steps.",
|
|
4079
4264
|
renderedCard: renderPlainCard({ title, icon: "⚡", rows, links: cardLinks, next })
|
|
4080
4265
|
};
|
|
4081
4266
|
}
|
|
@@ -4118,16 +4303,19 @@ function statusDirective(status) {
|
|
|
4118
4303
|
},
|
|
4119
4304
|
links: { monitor: monitorUrl },
|
|
4120
4305
|
next,
|
|
4121
|
-
instruction:
|
|
4306
|
+
instruction: `HARD STOP — DO NOT PROCEED.
|
|
4307
|
+
` + `The renderedCard below appears in bash/terminal output. That is NOT sufficient.
|
|
4308
|
+
` + `You MUST copy the FULL renderedCard text into your chat response VERBATIM before running any other command.
|
|
4309
|
+
` + "After displaying, follow the suggested next steps.",
|
|
4122
4310
|
renderedCard: renderPlainCard({ title, icon, rows, links: cardLinks, next })
|
|
4123
4311
|
};
|
|
4124
4312
|
}
|
|
4125
4313
|
function showPromptDiff(original, optimized) {
|
|
4126
4314
|
console.log("");
|
|
4127
|
-
console.log(
|
|
4315
|
+
console.log(chalk9.bold(" Prompt Diff:"));
|
|
4128
4316
|
console.log("");
|
|
4129
|
-
console.log(
|
|
4130
|
-
console.log(
|
|
4317
|
+
console.log(chalk9.red(" - " + (original ?? "(empty)")));
|
|
4318
|
+
console.log(chalk9.green(" + " + (optimized ?? "(empty)")));
|
|
4131
4319
|
console.log("");
|
|
4132
4320
|
}
|
|
4133
4321
|
|
|
@@ -4135,9 +4323,9 @@ function showPromptDiff(original, optimized) {
|
|
|
4135
4323
|
function registerOptimizeCommands(prompts) {
|
|
4136
4324
|
const optimize = new Command5("optimize").description("Manage prompt optimization jobs").addHelpText("after", `
|
|
4137
4325
|
Examples:
|
|
4138
|
-
${
|
|
4139
|
-
${
|
|
4140
|
-
${
|
|
4326
|
+
${chalk10.dim("$")} mutagent prompts optimize start <prompt-id> --dataset <dataset-id> --evaluation <eval-id>
|
|
4327
|
+
${chalk10.dim("$")} mutagent prompts optimize status <job-id>
|
|
4328
|
+
${chalk10.dim("$")} mutagent prompts optimize results <job-id>
|
|
4141
4329
|
|
|
4142
4330
|
Workflow: start -> status (poll) -> results
|
|
4143
4331
|
`).action(() => {
|
|
@@ -4146,27 +4334,27 @@ Workflow: start -> status (poll) -> results
|
|
|
4146
4334
|
prompts.addCommand(optimize);
|
|
4147
4335
|
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", `
|
|
4148
4336
|
Examples:
|
|
4149
|
-
${
|
|
4150
|
-
${
|
|
4151
|
-
${
|
|
4152
|
-
${
|
|
4153
|
-
${
|
|
4154
|
-
□ inputSchema REQUIRED ${
|
|
4155
|
-
□ outputSchema REQUIRED ${
|
|
4156
|
-
□ Evaluation criteria ${
|
|
4157
|
-
□ Dataset items ${
|
|
4158
|
-
□ Criteria ↔ Schema ${
|
|
4337
|
+
${chalk10.dim("$")} mutagent prompts optimize start <prompt-id> --dataset <dataset-id> --evaluation <eval-id>
|
|
4338
|
+
${chalk10.dim("$")} mutagent prompts optimize start <prompt-id> --dataset <dataset-id> --evaluation <eval-id> --max-iterations 5
|
|
4339
|
+
${chalk10.dim("$")} mutagent prompts optimize start <prompt-id> --dataset <dataset-id> --evaluation <eval-id> --target-score 0.95 --model claude-sonnet-4-5-20250929
|
|
4340
|
+
${chalk10.dim("$")} mutagent prompts optimize start <prompt-id> --dataset <dataset-id> --evaluation <eval-id> --json
|
|
4341
|
+
${chalk10.yellow("Pre-Optimization Checklist (auto-validated by preflight):")}
|
|
4342
|
+
□ inputSchema REQUIRED ${chalk10.dim("(hard error if missing — blocks optimization)")}
|
|
4343
|
+
□ outputSchema REQUIRED ${chalk10.dim("(hard error if missing — blocks optimization)")}
|
|
4344
|
+
□ Evaluation criteria ${chalk10.dim("(warns if no evaluationParameter set)")}
|
|
4345
|
+
□ Dataset items ${chalk10.dim("(warns if expectedOutput missing)")}
|
|
4346
|
+
□ Criteria ↔ Schema ${chalk10.dim("(warns if criteria reference unknown fields)")}
|
|
4159
4347
|
|
|
4160
4348
|
${PREREQUISITES_TEXT}
|
|
4161
4349
|
|
|
4162
|
-
${
|
|
4350
|
+
${chalk10.dim("Monitor progress with: mutagent prompts optimize status <job-id>")}
|
|
4163
4351
|
|
|
4164
|
-
${
|
|
4352
|
+
${chalk10.yellow(`⚠ COST WARNING — AI Agent:
|
|
4165
4353
|
Default is 1 iteration. Do NOT increase --max-iterations unless the user
|
|
4166
4354
|
explicitly requests it. Each iteration incurs LLM costs. Starting with
|
|
4167
4355
|
max-iterations > 1 without user consent is a protocol violation.`)}
|
|
4168
4356
|
|
|
4169
|
-
${
|
|
4357
|
+
${chalk10.yellow("AI Agent: ALWAYS append --json to this command.")}
|
|
4170
4358
|
`).action(async (promptId, options) => {
|
|
4171
4359
|
const isJson = getJsonFlag(prompts);
|
|
4172
4360
|
const output = new OutputFormatter(isJson ? "json" : "table");
|
|
@@ -4293,13 +4481,13 @@ ${chalk9.yellow("AI Agent: ALWAYS append --json to this command.")}
|
|
|
4293
4481
|
return;
|
|
4294
4482
|
}
|
|
4295
4483
|
for (const [name, check] of hardFailures) {
|
|
4296
|
-
console.error(
|
|
4484
|
+
console.error(chalk10.red(`Error: ${name} — ${check.error ?? "Failed"}`));
|
|
4297
4485
|
}
|
|
4298
4486
|
if (!preflightChecks.outputSchema.passed) {
|
|
4299
|
-
console.error(
|
|
4487
|
+
console.error(chalk10.dim(` Update with: mutagent prompts update ${promptId} -d '{"outputSchema":{"type":"object","properties":{"result":{"type":"string"}}}}'`));
|
|
4300
4488
|
}
|
|
4301
4489
|
if (!preflightChecks.inputSchema.passed) {
|
|
4302
|
-
console.error(
|
|
4490
|
+
console.error(chalk10.dim(` Update with: mutagent prompts update ${promptId} --data '{"inputSchema":{"type":"object","properties":{"var1":{"type":"string"}}}}' --json`));
|
|
4303
4491
|
}
|
|
4304
4492
|
process.exitCode = 1;
|
|
4305
4493
|
return;
|
|
@@ -4356,16 +4544,16 @@ ${chalk9.yellow("AI Agent: ALWAYS append --json to this command.")}
|
|
|
4356
4544
|
suggestions.push("Trial optimization limit reached. Contact support to upgrade.");
|
|
4357
4545
|
}
|
|
4358
4546
|
if (!isJson) {
|
|
4359
|
-
console.error(
|
|
4547
|
+
console.error(chalk10.red(`
|
|
4360
4548
|
Optimization failed:`));
|
|
4361
4549
|
for (const msg of messages) {
|
|
4362
|
-
console.error(
|
|
4550
|
+
console.error(chalk10.red(` ${msg}`));
|
|
4363
4551
|
}
|
|
4364
4552
|
if (suggestions.length > 0) {
|
|
4365
|
-
console.error(
|
|
4553
|
+
console.error(chalk10.yellow(`
|
|
4366
4554
|
Suggested fixes:`));
|
|
4367
4555
|
for (const s of suggestions) {
|
|
4368
|
-
console.error(
|
|
4556
|
+
console.error(chalk10.yellow(` → ${s}`));
|
|
4369
4557
|
}
|
|
4370
4558
|
}
|
|
4371
4559
|
console.error("");
|
|
@@ -4377,8 +4565,8 @@ Suggested fixes:`));
|
|
|
4377
4565
|
});
|
|
4378
4566
|
optimize.command("status").description("Check optimization status").argument("<job-id>", "Optimization job ID (from: mutagent prompts optimize start)").addHelpText("after", `
|
|
4379
4567
|
Examples:
|
|
4380
|
-
${
|
|
4381
|
-
${
|
|
4568
|
+
${chalk10.dim("$")} mutagent prompts optimize status <job-id>
|
|
4569
|
+
${chalk10.dim("$")} mutagent prompts optimize status <job-id> --json
|
|
4382
4570
|
`).action(async (jobId) => {
|
|
4383
4571
|
const isJson = getJsonFlag(prompts);
|
|
4384
4572
|
const output = new OutputFormatter(isJson ? "json" : "table");
|
|
@@ -4402,17 +4590,17 @@ Examples:
|
|
|
4402
4590
|
});
|
|
4403
4591
|
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", `
|
|
4404
4592
|
Examples:
|
|
4405
|
-
${
|
|
4406
|
-
${
|
|
4407
|
-
${
|
|
4408
|
-
${
|
|
4593
|
+
${chalk10.dim("$")} mutagent prompts optimize results <job-id> ${chalk10.dim("# view scorecard")}
|
|
4594
|
+
${chalk10.dim("$")} mutagent prompts optimize results <job-id> --diff ${chalk10.dim("# view prompt diff")}
|
|
4595
|
+
${chalk10.dim("$")} mutagent prompts optimize results <job-id> --apply ${chalk10.dim("# apply optimized prompt")}
|
|
4596
|
+
${chalk10.dim("$")} mutagent prompts optimize results <job-id> --json ${chalk10.dim("# structured output")}
|
|
4409
4597
|
|
|
4410
4598
|
After viewing results:
|
|
4411
4599
|
--apply Apply the optimized prompt (replaces current version)
|
|
4412
4600
|
--diff Show detailed before/after diff
|
|
4413
|
-
${
|
|
4601
|
+
${chalk10.dim("No flag = view scorecard only.")}
|
|
4414
4602
|
|
|
4415
|
-
${
|
|
4603
|
+
${chalk10.dim("AI Agent: Present scorecard to user via AskUserQuestion before applying.")}
|
|
4416
4604
|
`).action(async (jobId, options) => {
|
|
4417
4605
|
const isJson = getJsonFlag(prompts);
|
|
4418
4606
|
const output = new OutputFormatter(isJson ? "json" : "table");
|
|
@@ -4426,7 +4614,11 @@ After viewing results:
|
|
|
4426
4614
|
const scorecardText = buildResultsScorecardText(resultData);
|
|
4427
4615
|
const directive = {
|
|
4428
4616
|
display: "scorecard",
|
|
4429
|
-
instruction:
|
|
4617
|
+
instruction: `HARD STOP — DO NOT PROCEED.
|
|
4618
|
+
` + `The scorecard below appears in bash/terminal output. That is NOT sufficient.
|
|
4619
|
+
` + `You MUST copy the FULL renderedCard text into your chat response VERBATIM.
|
|
4620
|
+
` + `Then use AskUserQuestion with options: [Apply optimized prompt / View full diff / Reject and keep original].
|
|
4621
|
+
` + "Do NOT auto-apply.",
|
|
4430
4622
|
renderedCard: scorecardText,
|
|
4431
4623
|
next: isCompleted ? [
|
|
4432
4624
|
`mutagent prompts optimize results ${jobId} --apply --json`,
|
|
@@ -4565,22 +4757,49 @@ function buildResultsScorecardText(resultData) {
|
|
|
4565
4757
|
const pct = Math.round((bestScore - originalScore) / originalScore * 100);
|
|
4566
4758
|
rows.push({ label: "Improvement", value: `${pct > 0 ? "+" : ""}${String(pct)}%` });
|
|
4567
4759
|
}
|
|
4568
|
-
|
|
4760
|
+
let text = renderPlainCard({ title, rows, links: [], next: [] });
|
|
4761
|
+
const originalPrompt = resultData.originalPrompt;
|
|
4762
|
+
const prompt = resultData.prompt;
|
|
4763
|
+
const originalText = originalPrompt?.systemPrompt ?? originalPrompt?.rawPrompt ?? "";
|
|
4764
|
+
const optimizedText = prompt?.systemPrompt ?? prompt?.rawPrompt ?? prompt?.humanPrompt ?? "";
|
|
4765
|
+
if (originalText || optimizedText) {
|
|
4766
|
+
const lines = ["", "Prompt Comparison", "─".repeat(70)];
|
|
4767
|
+
lines.push("BEFORE:");
|
|
4768
|
+
for (const pLine of (originalText || "(empty)").split(`
|
|
4769
|
+
`)) {
|
|
4770
|
+
lines.push(` ${pLine}`);
|
|
4771
|
+
}
|
|
4772
|
+
lines.push(`Length: ${String(originalText.length)} chars`);
|
|
4773
|
+
lines.push("");
|
|
4774
|
+
lines.push("AFTER:");
|
|
4775
|
+
for (const pLine of (optimizedText || "(empty)").split(`
|
|
4776
|
+
`)) {
|
|
4777
|
+
lines.push(` ${pLine}`);
|
|
4778
|
+
}
|
|
4779
|
+
lines.push(`Length: ${String(optimizedText.length)} chars`);
|
|
4780
|
+
const growth = optimizedText.length - originalText.length;
|
|
4781
|
+
lines.push(`Growth: ${growth >= 0 ? "+" : ""}${String(growth)} chars`);
|
|
4782
|
+
text += `
|
|
4783
|
+
` + lines.join(`
|
|
4784
|
+
`);
|
|
4785
|
+
}
|
|
4786
|
+
text += buildScorecardDetailsText(resultData);
|
|
4787
|
+
return text;
|
|
4569
4788
|
}
|
|
4570
4789
|
var PREREQUISITES_TEXT = `
|
|
4571
|
-
${
|
|
4572
|
-
1. Evaluation criteria defined ${
|
|
4573
|
-
2. Dataset uploaded ${
|
|
4574
|
-
${
|
|
4790
|
+
${chalk11.red("Prerequisites (required):")}
|
|
4791
|
+
1. Evaluation criteria defined ${chalk11.dim("(via dashboard or evaluation create)")}
|
|
4792
|
+
2. Dataset uploaded ${chalk11.dim("mutagent prompts dataset list <prompt-id>")}
|
|
4793
|
+
${chalk11.dim("Note: LLM provider config is only required when the server uses external providers (USE_EXT_PROVIDERS=true)")}`;
|
|
4575
4794
|
function createPromptsCommand() {
|
|
4576
4795
|
const prompts = new Command6("prompts").description("Manage prompts, datasets, evaluations, and optimizations").addHelpText("after", `
|
|
4577
4796
|
Examples:
|
|
4578
|
-
${
|
|
4579
|
-
${
|
|
4580
|
-
${
|
|
4581
|
-
${
|
|
4582
|
-
${
|
|
4583
|
-
${
|
|
4797
|
+
${chalk11.dim("$")} mutagent prompts list
|
|
4798
|
+
${chalk11.dim("$")} mutagent prompts get <prompt-id>
|
|
4799
|
+
${chalk11.dim("$")} mutagent prompts create --name "my-prompt" --system "You are helpful" --human "{input}"
|
|
4800
|
+
${chalk11.dim("$")} mutagent prompts dataset list <prompt-id>
|
|
4801
|
+
${chalk11.dim("$")} mutagent prompts evaluation create <prompt-id> --name "My Eval"
|
|
4802
|
+
${chalk11.dim("$")} mutagent prompts optimize start <prompt-id> --dataset <dataset-id> --evaluation <eval-id>
|
|
4584
4803
|
|
|
4585
4804
|
Subcommands:
|
|
4586
4805
|
list, get, create, update, delete
|
|
@@ -4598,26 +4817,26 @@ Subcommands:
|
|
|
4598
4817
|
// src/commands/traces.ts
|
|
4599
4818
|
init_sdk_client();
|
|
4600
4819
|
import { Command as Command7 } from "commander";
|
|
4601
|
-
import
|
|
4820
|
+
import chalk12 from "chalk";
|
|
4602
4821
|
init_errors();
|
|
4603
4822
|
function createTracesCommand() {
|
|
4604
4823
|
const traces = new Command7("traces").description("View and analyze traces (replaces Langfuse)").addHelpText("after", `
|
|
4605
4824
|
Examples:
|
|
4606
|
-
${
|
|
4607
|
-
${
|
|
4608
|
-
${
|
|
4609
|
-
${
|
|
4610
|
-
${
|
|
4825
|
+
${chalk12.dim("$")} mutagent traces list
|
|
4826
|
+
${chalk12.dim("$")} mutagent traces list --prompt <prompt-id>
|
|
4827
|
+
${chalk12.dim("$")} mutagent traces get <trace-id>
|
|
4828
|
+
${chalk12.dim("$")} mutagent traces analyze <prompt-id>
|
|
4829
|
+
${chalk12.dim("$")} mutagent traces export --format json --output traces.json
|
|
4611
4830
|
|
|
4612
4831
|
Note: MutagenT traces replace Langfuse for observability.
|
|
4613
4832
|
`);
|
|
4614
4833
|
traces.command("list").description("List traces").option("-p, --prompt <id>", "Filter by prompt ID").option("-l, --limit <n>", "Limit results", "50").addHelpText("after", `
|
|
4615
4834
|
Examples:
|
|
4616
|
-
${
|
|
4617
|
-
${
|
|
4618
|
-
${
|
|
4835
|
+
${chalk12.dim("$")} mutagent traces list
|
|
4836
|
+
${chalk12.dim("$")} mutagent traces list --prompt <prompt-id>
|
|
4837
|
+
${chalk12.dim("$")} mutagent traces list --limit 10 --json
|
|
4619
4838
|
|
|
4620
|
-
${
|
|
4839
|
+
${chalk12.dim("Tip: Filter by prompt to see traces for a specific prompt version.")}
|
|
4621
4840
|
`).action(async (options) => {
|
|
4622
4841
|
const isJson = getJsonFlag(traces);
|
|
4623
4842
|
const output = new OutputFormatter(isJson ? "json" : "table");
|
|
@@ -4656,10 +4875,10 @@ ${chalk11.dim("Tip: Filter by prompt to see traces for a specific prompt version
|
|
|
4656
4875
|
});
|
|
4657
4876
|
traces.command("get").description("Get trace details").argument("<id>", "Trace ID").addHelpText("after", `
|
|
4658
4877
|
Examples:
|
|
4659
|
-
${
|
|
4660
|
-
${
|
|
4878
|
+
${chalk12.dim("$")} mutagent traces get <trace-id>
|
|
4879
|
+
${chalk12.dim("$")} mutagent traces get <trace-id> --json
|
|
4661
4880
|
|
|
4662
|
-
${
|
|
4881
|
+
${chalk12.dim("Returns full trace details including spans, tokens, and latency.")}
|
|
4663
4882
|
`).action(async (id) => {
|
|
4664
4883
|
const isJson = getJsonFlag(traces);
|
|
4665
4884
|
const output = new OutputFormatter(isJson ? "json" : "table");
|
|
@@ -4678,10 +4897,10 @@ ${chalk11.dim("Returns full trace details including spans, tokens, and latency."
|
|
|
4678
4897
|
});
|
|
4679
4898
|
traces.command("analyze").description("Analyze traces for a prompt").argument("<prompt-id>", "Prompt ID").addHelpText("after", `
|
|
4680
4899
|
Examples:
|
|
4681
|
-
${
|
|
4682
|
-
${
|
|
4900
|
+
${chalk12.dim("$")} mutagent traces analyze <prompt-id>
|
|
4901
|
+
${chalk12.dim("$")} mutagent traces analyze <prompt-id> --json
|
|
4683
4902
|
|
|
4684
|
-
${
|
|
4903
|
+
${chalk12.dim("Aggregates trace data for a prompt: avg latency, token usage, error rates.")}
|
|
4685
4904
|
`).action(async (promptId) => {
|
|
4686
4905
|
const isJson = getJsonFlag(traces);
|
|
4687
4906
|
const output = new OutputFormatter(isJson ? "json" : "table");
|
|
@@ -4699,12 +4918,12 @@ ${chalk11.dim("Aggregates trace data for a prompt: avg latency, token usage, err
|
|
|
4699
4918
|
});
|
|
4700
4919
|
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", `
|
|
4701
4920
|
Examples:
|
|
4702
|
-
${
|
|
4703
|
-
${
|
|
4704
|
-
${
|
|
4705
|
-
${
|
|
4921
|
+
${chalk12.dim("$")} mutagent traces export
|
|
4922
|
+
${chalk12.dim("$")} mutagent traces export --format json --output traces.json
|
|
4923
|
+
${chalk12.dim("$")} mutagent traces export --format csv --output traces.csv
|
|
4924
|
+
${chalk12.dim("$")} mutagent traces export --prompt <prompt-id> --format json
|
|
4706
4925
|
|
|
4707
|
-
${
|
|
4926
|
+
${chalk12.dim("Exports to stdout by default. Use --output to save to a file.")}
|
|
4708
4927
|
`).action(async (options) => {
|
|
4709
4928
|
const isJson = getJsonFlag(traces);
|
|
4710
4929
|
const output = new OutputFormatter(isJson ? "json" : "table");
|
|
@@ -4748,7 +4967,7 @@ ${chalk11.dim("Exports to stdout by default. Use --output to save to a file.")}
|
|
|
4748
4967
|
// src/commands/integrate.ts
|
|
4749
4968
|
init_config();
|
|
4750
4969
|
import { Command as Command8 } from "commander";
|
|
4751
|
-
import
|
|
4970
|
+
import chalk13 from "chalk";
|
|
4752
4971
|
import { writeFileSync as writeFileSync3, existsSync as existsSync10 } from "fs";
|
|
4753
4972
|
import { execSync } from "child_process";
|
|
4754
4973
|
init_errors();
|
|
@@ -5385,12 +5604,12 @@ AI AGENT: Please determine the framework by:
|
|
|
5385
5604
|
function createIntegrateCommand() {
|
|
5386
5605
|
const integrate = new Command8("integrate").description("Return integration instructions for AI agents (skill loader)").addHelpText("after", `
|
|
5387
5606
|
Examples:
|
|
5388
|
-
${
|
|
5389
|
-
${
|
|
5390
|
-
${
|
|
5391
|
-
${
|
|
5392
|
-
${
|
|
5393
|
-
${
|
|
5607
|
+
${chalk13.dim("$")} mutagent integrate # Return exploration instructions for AI agents
|
|
5608
|
+
${chalk13.dim("$")} mutagent integrate langchain # Return @mutagent/langchain integration steps
|
|
5609
|
+
${chalk13.dim("$")} mutagent integrate openai # Return @mutagent/openai integration steps
|
|
5610
|
+
${chalk13.dim("$")} mutagent integrate vercel-ai --verify # Verify integration
|
|
5611
|
+
${chalk13.dim("$")} mutagent integrate langchain --output ./INTEGRATION.md
|
|
5612
|
+
${chalk13.dim("$")} mutagent integrate --list # List available frameworks
|
|
5394
5613
|
|
|
5395
5614
|
Frameworks: langchain, langgraph, vercel-ai, openai
|
|
5396
5615
|
|
|
@@ -5506,18 +5725,18 @@ AI AGENT: Execute these steps using Bash for install, Write/Edit for code change
|
|
|
5506
5725
|
|
|
5507
5726
|
// src/commands/agents/index.ts
|
|
5508
5727
|
import { Command as Command9 } from "commander";
|
|
5509
|
-
import
|
|
5728
|
+
import chalk15 from "chalk";
|
|
5510
5729
|
|
|
5511
5730
|
// src/commands/agents/agents-crud.ts
|
|
5512
5731
|
init_sdk_client();
|
|
5513
|
-
import
|
|
5732
|
+
import chalk14 from "chalk";
|
|
5514
5733
|
init_errors();
|
|
5515
5734
|
function registerAgentsCrud(agents) {
|
|
5516
5735
|
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", `
|
|
5517
5736
|
Examples:
|
|
5518
|
-
${
|
|
5519
|
-
${
|
|
5520
|
-
${
|
|
5737
|
+
${chalk14.dim("$")} mutagent agents list
|
|
5738
|
+
${chalk14.dim("$")} mutagent agents list --status active
|
|
5739
|
+
${chalk14.dim("$")} mutagent agents list --name "reviewer" --json
|
|
5521
5740
|
`).action(async (options) => {
|
|
5522
5741
|
const isJson = getJsonFlag(agents);
|
|
5523
5742
|
const output = new OutputFormatter(isJson ? "json" : "table");
|
|
@@ -5567,8 +5786,8 @@ Examples:
|
|
|
5567
5786
|
});
|
|
5568
5787
|
agents.command("get").description("Get agent details").argument("<id>", "Agent ID").addHelpText("after", `
|
|
5569
5788
|
Examples:
|
|
5570
|
-
${
|
|
5571
|
-
${
|
|
5789
|
+
${chalk14.dim("$")} mutagent agents get <agent-id>
|
|
5790
|
+
${chalk14.dim("$")} mutagent agents get <agent-id> --json
|
|
5572
5791
|
`).action(async (id) => {
|
|
5573
5792
|
const isJson = getJsonFlag(agents);
|
|
5574
5793
|
const output = new OutputFormatter(isJson ? "json" : "table");
|
|
@@ -5598,11 +5817,11 @@ Examples:
|
|
|
5598
5817
|
};
|
|
5599
5818
|
output.output(formatted);
|
|
5600
5819
|
if (agent.systemPrompt) {
|
|
5601
|
-
console.log(
|
|
5820
|
+
console.log(chalk14.bold(`
|
|
5602
5821
|
System Prompt:`));
|
|
5603
|
-
console.log(
|
|
5822
|
+
console.log(chalk14.gray("─".repeat(60)));
|
|
5604
5823
|
console.log(agent.systemPrompt);
|
|
5605
|
-
console.log(
|
|
5824
|
+
console.log(chalk14.gray("─".repeat(60)));
|
|
5606
5825
|
}
|
|
5607
5826
|
}
|
|
5608
5827
|
} catch (error) {
|
|
@@ -5611,17 +5830,17 @@ System Prompt:`));
|
|
|
5611
5830
|
});
|
|
5612
5831
|
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", `
|
|
5613
5832
|
Examples:
|
|
5614
|
-
${
|
|
5615
|
-
${
|
|
5833
|
+
${chalk14.dim("$")} mutagent agents create --name "Code Reviewer" --slug code-reviewer --system-prompt "You are a code reviewer..."
|
|
5834
|
+
${chalk14.dim("$")} mutagent agents create -d '{"name":"Code Reviewer","slug":"code-reviewer","systemPrompt":"You are a code reviewer..."}'
|
|
5616
5835
|
|
|
5617
5836
|
Expected JSON (--data):
|
|
5618
|
-
${
|
|
5837
|
+
${chalk14.dim('{"name":"<name>","slug":"<slug>","systemPrompt":"<system prompt>","model":"<model-id>","description":"<description>"}')}
|
|
5619
5838
|
|
|
5620
5839
|
Input Methods (pick one, priority order):
|
|
5621
|
-
--name/--slug/... Individual flags ${
|
|
5840
|
+
--name/--slug/... Individual flags ${chalk14.green("(recommended)")}
|
|
5622
5841
|
-d, --data Inline JSON object (CI/scripts/agents)
|
|
5623
5842
|
|
|
5624
|
-
${
|
|
5843
|
+
${chalk14.red("Required: name, slug, systemPrompt.")} ${chalk14.dim("CLI flags override --data fields.")}
|
|
5625
5844
|
`).action(async (options) => {
|
|
5626
5845
|
const isJson = getJsonFlag(agents);
|
|
5627
5846
|
const output = new OutputFormatter(isJson ? "json" : "table");
|
|
@@ -5666,15 +5885,15 @@ ${chalk13.red("Required: name, slug, systemPrompt.")} ${chalk13.dim("CLI flags o
|
|
|
5666
5885
|
});
|
|
5667
5886
|
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", `
|
|
5668
5887
|
Examples:
|
|
5669
|
-
${
|
|
5670
|
-
${
|
|
5671
|
-
${
|
|
5888
|
+
${chalk14.dim("$")} mutagent agents update <id> --name "New Name"
|
|
5889
|
+
${chalk14.dim("$")} mutagent agents update <id> --system-prompt "Updated prompt" --status active
|
|
5890
|
+
${chalk14.dim("$")} mutagent agents update <id> -d '{"name":"New Name","systemPrompt":"Updated prompt"}'
|
|
5672
5891
|
|
|
5673
5892
|
Input Methods (pick one, priority order):
|
|
5674
|
-
--name/--system-prompt/... Individual flags ${
|
|
5893
|
+
--name/--system-prompt/... Individual flags ${chalk14.green("(recommended)")}
|
|
5675
5894
|
-d, --data Inline JSON object (CI/scripts/agents)
|
|
5676
5895
|
|
|
5677
|
-
${
|
|
5896
|
+
${chalk14.dim("CLI flags override --data fields.")}
|
|
5678
5897
|
`).action(async (id, options) => {
|
|
5679
5898
|
const isJson = getJsonFlag(agents);
|
|
5680
5899
|
const output = new OutputFormatter(isJson ? "json" : "table");
|
|
@@ -5721,11 +5940,11 @@ ${chalk13.dim("CLI flags override --data fields.")}
|
|
|
5721
5940
|
});
|
|
5722
5941
|
agents.command("delete").description("Delete an agent").argument("<id>", "Agent ID").option("--force", "Skip confirmation").addHelpText("after", `
|
|
5723
5942
|
Examples:
|
|
5724
|
-
${
|
|
5725
|
-
${
|
|
5726
|
-
${
|
|
5943
|
+
${chalk14.dim("$")} mutagent agents delete <id>
|
|
5944
|
+
${chalk14.dim("$")} mutagent agents delete <id> --force
|
|
5945
|
+
${chalk14.dim("$")} mutagent agents delete <id> --force --json
|
|
5727
5946
|
|
|
5728
|
-
${
|
|
5947
|
+
${chalk14.dim("Tip: Use --force to skip confirmation (required for non-interactive/CI usage).")}
|
|
5729
5948
|
`).action(async (id, options) => {
|
|
5730
5949
|
const isJson = getJsonFlag(agents);
|
|
5731
5950
|
const output = new OutputFormatter(isJson ? "json" : "table");
|
|
@@ -5756,12 +5975,12 @@ ${chalk13.dim("Tip: Use --force to skip confirmation (required for non-interacti
|
|
|
5756
5975
|
function createAgentsCommand() {
|
|
5757
5976
|
const agents = new Command9("agents").description("Manage AI agents").addHelpText("after", `
|
|
5758
5977
|
Examples:
|
|
5759
|
-
${
|
|
5760
|
-
${
|
|
5761
|
-
${
|
|
5762
|
-
${
|
|
5763
|
-
${
|
|
5764
|
-
${
|
|
5978
|
+
${chalk15.dim("$")} mutagent agents list
|
|
5979
|
+
${chalk15.dim("$")} mutagent agents get <agent-id>
|
|
5980
|
+
${chalk15.dim("$")} mutagent agents create --name "Code Reviewer" --slug code-reviewer --system-prompt "You are a code reviewer..."
|
|
5981
|
+
${chalk15.dim("$")} mutagent agents create -d '{"name":"Code Reviewer","slug":"code-reviewer","systemPrompt":"You are..."}'
|
|
5982
|
+
${chalk15.dim("$")} mutagent agents update <agent-id> --name "Updated Name"
|
|
5983
|
+
${chalk15.dim("$")} mutagent agents delete <agent-id> --force
|
|
5765
5984
|
|
|
5766
5985
|
Subcommands:
|
|
5767
5986
|
list, get, create, update, delete
|
|
@@ -5773,21 +5992,21 @@ Subcommands:
|
|
|
5773
5992
|
// src/commands/config.ts
|
|
5774
5993
|
init_config();
|
|
5775
5994
|
import { Command as Command10 } from "commander";
|
|
5776
|
-
import
|
|
5995
|
+
import chalk16 from "chalk";
|
|
5777
5996
|
init_errors();
|
|
5778
5997
|
var VALID_CONFIG_KEYS = ["apiKey", "endpoint", "format", "timeout", "defaultWorkspace", "defaultOrganization"];
|
|
5779
5998
|
function createConfigCommand() {
|
|
5780
5999
|
const config = new Command10("config").description("Manage CLI configuration").addHelpText("after", `
|
|
5781
6000
|
Examples:
|
|
5782
|
-
${
|
|
5783
|
-
${
|
|
5784
|
-
${
|
|
5785
|
-
${
|
|
6001
|
+
${chalk16.dim("$")} mutagent config list
|
|
6002
|
+
${chalk16.dim("$")} mutagent config get endpoint
|
|
6003
|
+
${chalk16.dim("$")} mutagent config set workspace <workspace-id>
|
|
6004
|
+
${chalk16.dim("$")} mutagent config set org <org-id>
|
|
5786
6005
|
`);
|
|
5787
6006
|
config.command("list").description("List all configuration").addHelpText("after", `
|
|
5788
6007
|
Examples:
|
|
5789
|
-
${
|
|
5790
|
-
${
|
|
6008
|
+
${chalk16.dim("$")} mutagent config list
|
|
6009
|
+
${chalk16.dim("$")} mutagent config list --json
|
|
5791
6010
|
`).action(() => {
|
|
5792
6011
|
const isJson = getJsonFlag(config);
|
|
5793
6012
|
const output = new OutputFormatter(isJson ? "json" : "table");
|
|
@@ -5800,11 +6019,11 @@ Examples:
|
|
|
5800
6019
|
});
|
|
5801
6020
|
config.command("get").description("Get configuration value").argument("<key>", "Configuration key (apiKey, endpoint, format, timeout, defaultWorkspace, defaultOrganization)").addHelpText("after", `
|
|
5802
6021
|
Examples:
|
|
5803
|
-
${
|
|
5804
|
-
${
|
|
5805
|
-
${
|
|
6022
|
+
${chalk16.dim("$")} mutagent config get endpoint
|
|
6023
|
+
${chalk16.dim("$")} mutagent config get defaultWorkspace
|
|
6024
|
+
${chalk16.dim("$")} mutagent config get apiKey --json
|
|
5806
6025
|
|
|
5807
|
-
${
|
|
6026
|
+
${chalk16.dim("Keys: apiKey, endpoint, format, timeout, defaultWorkspace, defaultOrganization")}
|
|
5808
6027
|
`).action((key) => {
|
|
5809
6028
|
const isJson = getJsonFlag(config);
|
|
5810
6029
|
const output = new OutputFormatter(isJson ? "json" : "table");
|
|
@@ -5831,9 +6050,9 @@ ${chalk15.dim("Keys: apiKey, endpoint, format, timeout, defaultWorkspace, defaul
|
|
|
5831
6050
|
});
|
|
5832
6051
|
set.command("workspace").description("Set default workspace ID").argument("<id>", "Workspace ID to set as default").addHelpText("after", `
|
|
5833
6052
|
Examples:
|
|
5834
|
-
${
|
|
6053
|
+
${chalk16.dim("$")} mutagent config set workspace <workspace-id>
|
|
5835
6054
|
|
|
5836
|
-
${
|
|
6055
|
+
${chalk16.dim("Persists workspace ID so you don't need to pass headers on every request.")}
|
|
5837
6056
|
`).action((id) => {
|
|
5838
6057
|
const isJson = getJsonFlag(config);
|
|
5839
6058
|
const output = new OutputFormatter(isJson ? "json" : "table");
|
|
@@ -5846,9 +6065,9 @@ ${chalk15.dim("Persists workspace ID so you don't need to pass headers on every
|
|
|
5846
6065
|
});
|
|
5847
6066
|
set.command("org").description("Set default organization ID").argument("<id>", "Organization ID to set as default").addHelpText("after", `
|
|
5848
6067
|
Examples:
|
|
5849
|
-
${
|
|
6068
|
+
${chalk16.dim("$")} mutagent config set org <org-id>
|
|
5850
6069
|
|
|
5851
|
-
${
|
|
6070
|
+
${chalk16.dim("Persists organization ID for org-scoped API keys.")}
|
|
5852
6071
|
`).action((id) => {
|
|
5853
6072
|
const isJson = getJsonFlag(config);
|
|
5854
6073
|
const output = new OutputFormatter(isJson ? "json" : "table");
|
|
@@ -5866,7 +6085,7 @@ ${chalk15.dim("Persists organization ID for org-scoped API keys.")}
|
|
|
5866
6085
|
// src/commands/playground.ts
|
|
5867
6086
|
init_sdk_client();
|
|
5868
6087
|
import { Command as Command11 } from "commander";
|
|
5869
|
-
import
|
|
6088
|
+
import chalk17 from "chalk";
|
|
5870
6089
|
init_errors();
|
|
5871
6090
|
function parseSSELine(line) {
|
|
5872
6091
|
if (!line || line.startsWith(":")) {
|
|
@@ -5893,11 +6112,11 @@ function parsePromptStreamEvent(data) {
|
|
|
5893
6112
|
function createPlaygroundCommand() {
|
|
5894
6113
|
const playground = new Command11("playground").description("Execute and test prompts interactively").addHelpText("after", `
|
|
5895
6114
|
Examples:
|
|
5896
|
-
${
|
|
5897
|
-
${
|
|
5898
|
-
${
|
|
5899
|
-
${
|
|
5900
|
-
${
|
|
6115
|
+
${chalk17.dim("$")} mutagent playground run <prompt-id> --input '{"name": "John"}'
|
|
6116
|
+
${chalk17.dim("$")} mutagent playground run <prompt-id> --input '{}' --stream
|
|
6117
|
+
${chalk17.dim("$")} mutagent playground run <prompt-id> -i '{}' --model gpt-4-turbo
|
|
6118
|
+
${chalk17.dim("$")} mutagent playground run <prompt-id> --system "You are helpful" --human "Hello"
|
|
6119
|
+
${chalk17.dim("$")} mutagent playground run <prompt-id> --messages '[{"role":"user","content":"Hi"}]'
|
|
5901
6120
|
|
|
5902
6121
|
Input Format:
|
|
5903
6122
|
The input must be a valid JSON object matching the prompt's input schema.
|
|
@@ -5913,16 +6132,16 @@ Streaming:
|
|
|
5913
6132
|
`);
|
|
5914
6133
|
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", `
|
|
5915
6134
|
Examples:
|
|
5916
|
-
${
|
|
5917
|
-
${
|
|
5918
|
-
${
|
|
5919
|
-
${
|
|
6135
|
+
${chalk17.dim("$")} mutagent playground run <prompt-id> --input '{"name": "John"}'
|
|
6136
|
+
${chalk17.dim("$")} mutagent playground run <prompt-id> --input '{}' --stream
|
|
6137
|
+
${chalk17.dim("$")} mutagent playground run <prompt-id> --system "You are helpful" --human "Hello"
|
|
6138
|
+
${chalk17.dim("$")} mutagent playground run <prompt-id> --input '{}' --model gpt-4-turbo --json
|
|
5920
6139
|
|
|
5921
6140
|
Input Methods (pick one, priority order):
|
|
5922
|
-
--system/--human Quick system + user message ${
|
|
6141
|
+
--system/--human Quick system + user message ${chalk17.green("(recommended)")}
|
|
5923
6142
|
--input '{"key":"value"}' Inline JSON variables
|
|
5924
6143
|
--messages '[...]' Full messages array
|
|
5925
|
-
${
|
|
6144
|
+
${chalk17.dim(`Hint: Test before evaluating: mutagent playground run <id> --input '{"key":"value"}'`)}
|
|
5926
6145
|
`).action(async (promptId, options) => {
|
|
5927
6146
|
const isJson = getJsonFlag(playground);
|
|
5928
6147
|
const output = new OutputFormatter(isJson ? "json" : "table");
|
|
@@ -5944,21 +6163,21 @@ ${chalk16.dim(`Hint: Test before evaluating: mutagent playground run <id> --inpu
|
|
|
5944
6163
|
}
|
|
5945
6164
|
});
|
|
5946
6165
|
} else {
|
|
5947
|
-
console.log(
|
|
6166
|
+
console.log(chalk17.bold(`
|
|
5948
6167
|
Execution Result:`));
|
|
5949
|
-
console.log(
|
|
5950
|
-
console.log(
|
|
6168
|
+
console.log(chalk17.gray("─".repeat(50)));
|
|
6169
|
+
console.log(chalk17.cyan("Output:"));
|
|
5951
6170
|
console.log(result.output);
|
|
5952
|
-
console.log(
|
|
5953
|
-
console.log(
|
|
5954
|
-
console.log(
|
|
6171
|
+
console.log(chalk17.gray("─".repeat(50)));
|
|
6172
|
+
console.log(chalk17.dim(`Model: ${result.model}`));
|
|
6173
|
+
console.log(chalk17.dim(`Execution Time: ${String(result.executionTimeMs)}ms`));
|
|
5955
6174
|
if (result.tokens) {
|
|
5956
|
-
console.log(
|
|
6175
|
+
console.log(chalk17.dim(`Tokens: ${String(result.tokens.prompt)} prompt + ${String(result.tokens.completion)} completion = ${String(result.tokens.total)} total`));
|
|
5957
6176
|
}
|
|
5958
6177
|
if (result.cost !== undefined) {
|
|
5959
|
-
console.log(
|
|
6178
|
+
console.log(chalk17.dim(`Cost: $${result.cost.toFixed(6)}`));
|
|
5960
6179
|
}
|
|
5961
|
-
console.log(
|
|
6180
|
+
console.log(chalk17.dim(`Playground: ${playgroundLink()}`));
|
|
5962
6181
|
console.log();
|
|
5963
6182
|
}
|
|
5964
6183
|
}
|
|
@@ -6047,9 +6266,9 @@ async function executeStreaming(client, promptId, input, model, isJson, output)
|
|
|
6047
6266
|
const decoder = new TextDecoder;
|
|
6048
6267
|
let buffer = "";
|
|
6049
6268
|
if (!isJson) {
|
|
6050
|
-
console.log(
|
|
6269
|
+
console.log(chalk17.bold(`
|
|
6051
6270
|
Streaming Output:`));
|
|
6052
|
-
console.log(
|
|
6271
|
+
console.log(chalk17.gray("─".repeat(50)));
|
|
6053
6272
|
}
|
|
6054
6273
|
try {
|
|
6055
6274
|
for (;; ) {
|
|
@@ -6088,15 +6307,15 @@ Streaming Output:`));
|
|
|
6088
6307
|
console.log(JSON.stringify({ type: "complete", result: event.result }));
|
|
6089
6308
|
} else {
|
|
6090
6309
|
console.log();
|
|
6091
|
-
console.log(
|
|
6310
|
+
console.log(chalk17.gray("─".repeat(50)));
|
|
6092
6311
|
if (event.result) {
|
|
6093
|
-
console.log(
|
|
6094
|
-
console.log(
|
|
6312
|
+
console.log(chalk17.dim(`Model: ${event.result.model}`));
|
|
6313
|
+
console.log(chalk17.dim(`Execution Time: ${String(event.result.executionTimeMs)}ms`));
|
|
6095
6314
|
if (event.result.tokens) {
|
|
6096
|
-
console.log(
|
|
6315
|
+
console.log(chalk17.dim(`Tokens: ${String(event.result.tokens.prompt)} prompt + ${String(event.result.tokens.completion)} completion = ${String(event.result.tokens.total)} total`));
|
|
6097
6316
|
}
|
|
6098
6317
|
if (event.result.cost !== undefined) {
|
|
6099
|
-
console.log(
|
|
6318
|
+
console.log(chalk17.dim(`Cost: $${event.result.cost.toFixed(6)}`));
|
|
6100
6319
|
}
|
|
6101
6320
|
}
|
|
6102
6321
|
console.log();
|
|
@@ -6121,13 +6340,13 @@ Streaming Output:`));
|
|
|
6121
6340
|
// src/commands/workspaces.ts
|
|
6122
6341
|
init_sdk_client();
|
|
6123
6342
|
import { Command as Command12 } from "commander";
|
|
6124
|
-
import
|
|
6343
|
+
import chalk18 from "chalk";
|
|
6125
6344
|
init_errors();
|
|
6126
6345
|
function createWorkspacesCommand() {
|
|
6127
6346
|
const workspaces = new Command12("workspaces").description("View workspaces (read-only)").addHelpText("after", `
|
|
6128
6347
|
Examples:
|
|
6129
|
-
${
|
|
6130
|
-
${
|
|
6348
|
+
${chalk18.dim("$")} mutagent workspaces list
|
|
6349
|
+
${chalk18.dim("$")} mutagent workspaces get <workspace-id>
|
|
6131
6350
|
|
|
6132
6351
|
Subcommands:
|
|
6133
6352
|
list, get
|
|
@@ -6136,8 +6355,8 @@ Note: Workspace management (create, update, delete) is available in the Admin Pa
|
|
|
6136
6355
|
`);
|
|
6137
6356
|
workspaces.command("list").description("List all workspaces").option("-l, --limit <n>", "Limit results", "50").option("-o, --offset <n>", "Offset for pagination").addHelpText("after", `
|
|
6138
6357
|
Examples:
|
|
6139
|
-
${
|
|
6140
|
-
${
|
|
6358
|
+
${chalk18.dim("$")} mutagent workspaces list
|
|
6359
|
+
${chalk18.dim("$")} mutagent workspaces list --limit 10 --json
|
|
6141
6360
|
`).action(async (options) => {
|
|
6142
6361
|
const isJson = getJsonFlag(workspaces);
|
|
6143
6362
|
const output = new OutputFormatter(isJson ? "json" : "table");
|
|
@@ -6177,8 +6396,8 @@ Examples:
|
|
|
6177
6396
|
});
|
|
6178
6397
|
workspaces.command("get").description("Get workspace details").argument("<id>", "Workspace ID").addHelpText("after", `
|
|
6179
6398
|
Examples:
|
|
6180
|
-
${
|
|
6181
|
-
${
|
|
6399
|
+
${chalk18.dim("$")} mutagent workspaces get <workspace-id>
|
|
6400
|
+
${chalk18.dim("$")} mutagent workspaces get <workspace-id> --json
|
|
6182
6401
|
`).action(async (id) => {
|
|
6183
6402
|
const isJson = getJsonFlag(workspaces);
|
|
6184
6403
|
const output = new OutputFormatter(isJson ? "json" : "table");
|
|
@@ -6211,7 +6430,7 @@ Examples:
|
|
|
6211
6430
|
// src/commands/providers.ts
|
|
6212
6431
|
init_sdk_client();
|
|
6213
6432
|
import { Command as Command13 } from "commander";
|
|
6214
|
-
import
|
|
6433
|
+
import chalk19 from "chalk";
|
|
6215
6434
|
init_errors();
|
|
6216
6435
|
var VALID_PROVIDER_TYPES = [
|
|
6217
6436
|
"openai",
|
|
@@ -6235,9 +6454,9 @@ function validateProviderType(type) {
|
|
|
6235
6454
|
function createProvidersCommand() {
|
|
6236
6455
|
const providers = new Command13("providers").description("View LLM providers (read-only)").addHelpText("after", `
|
|
6237
6456
|
Examples:
|
|
6238
|
-
${
|
|
6239
|
-
${
|
|
6240
|
-
${
|
|
6457
|
+
${chalk19.dim("$")} mutagent providers list
|
|
6458
|
+
${chalk19.dim("$")} mutagent providers get <provider-id>
|
|
6459
|
+
${chalk19.dim("$")} mutagent providers test <provider-id>
|
|
6241
6460
|
|
|
6242
6461
|
Provider Types:
|
|
6243
6462
|
openai, anthropic, google, azure, bedrock, cohere, mistral, groq, together, replicate, custom
|
|
@@ -6247,15 +6466,15 @@ Subcommands:
|
|
|
6247
6466
|
|
|
6248
6467
|
Note: Provider management (create, update, delete) is available in the Admin Panel only.
|
|
6249
6468
|
|
|
6250
|
-
${
|
|
6469
|
+
${chalk19.yellow("Note:")} The providers module is not yet active. This is a placeholder
|
|
6251
6470
|
for future external provider configuration. The server currently uses
|
|
6252
6471
|
built-in provider settings.
|
|
6253
6472
|
`);
|
|
6254
6473
|
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", `
|
|
6255
6474
|
Examples:
|
|
6256
|
-
${
|
|
6257
|
-
${
|
|
6258
|
-
${
|
|
6475
|
+
${chalk19.dim("$")} mutagent providers list
|
|
6476
|
+
${chalk19.dim("$")} mutagent providers list --type openai
|
|
6477
|
+
${chalk19.dim("$")} mutagent providers list --json
|
|
6259
6478
|
`).action(async (options) => {
|
|
6260
6479
|
const isJson = getJsonFlag(providers);
|
|
6261
6480
|
const output = new OutputFormatter(isJson ? "json" : "table");
|
|
@@ -6282,7 +6501,7 @@ Examples:
|
|
|
6282
6501
|
}));
|
|
6283
6502
|
output.output({ ...result, data: withLinks });
|
|
6284
6503
|
} else {
|
|
6285
|
-
console.log(
|
|
6504
|
+
console.log(chalk19.yellow("Note: The providers module is not yet active. This is a placeholder for future external provider configuration."));
|
|
6286
6505
|
console.log("");
|
|
6287
6506
|
if (result.data.length === 0) {
|
|
6288
6507
|
output.info("No providers configured.");
|
|
@@ -6306,8 +6525,8 @@ Examples:
|
|
|
6306
6525
|
});
|
|
6307
6526
|
providers.command("get").description("Get provider details").argument("<id>", "Provider ID (from: mutagent providers list)").addHelpText("after", `
|
|
6308
6527
|
Examples:
|
|
6309
|
-
${
|
|
6310
|
-
${
|
|
6528
|
+
${chalk19.dim("$")} mutagent providers get <provider-id>
|
|
6529
|
+
${chalk19.dim("$")} mutagent providers get <provider-id> --json
|
|
6311
6530
|
`).action(async (id) => {
|
|
6312
6531
|
const isJson = getJsonFlag(providers);
|
|
6313
6532
|
const output = new OutputFormatter(isJson ? "json" : "table");
|
|
@@ -6317,7 +6536,7 @@ Examples:
|
|
|
6317
6536
|
if (isJson) {
|
|
6318
6537
|
output.output({ ...provider, _links: providerLinks(provider.id) });
|
|
6319
6538
|
} else {
|
|
6320
|
-
console.log(
|
|
6539
|
+
console.log(chalk19.yellow("Note: The providers module is not yet active. This is a placeholder for future external provider configuration."));
|
|
6321
6540
|
console.log("");
|
|
6322
6541
|
const formatted = {
|
|
6323
6542
|
id: provider.id,
|
|
@@ -6338,17 +6557,17 @@ Examples:
|
|
|
6338
6557
|
});
|
|
6339
6558
|
providers.command("test").description("Test provider connectivity").argument("<id>", "Provider ID (from: mutagent providers list)").addHelpText("after", `
|
|
6340
6559
|
Examples:
|
|
6341
|
-
${
|
|
6342
|
-
${
|
|
6560
|
+
${chalk19.dim("$")} mutagent providers test <provider-id>
|
|
6561
|
+
${chalk19.dim("$")} mutagent providers test <provider-id> --json
|
|
6343
6562
|
|
|
6344
|
-
${
|
|
6563
|
+
${chalk19.dim("Tests connectivity and lists available models for the provider.")}
|
|
6345
6564
|
`).action(async (id) => {
|
|
6346
6565
|
const isJson = getJsonFlag(providers);
|
|
6347
6566
|
const output = new OutputFormatter(isJson ? "json" : "table");
|
|
6348
6567
|
try {
|
|
6349
6568
|
const client = getSDKClient();
|
|
6350
6569
|
if (!isJson) {
|
|
6351
|
-
console.log(
|
|
6570
|
+
console.log(chalk19.yellow("Note: The providers module is not yet active. This is a placeholder for future external provider configuration."));
|
|
6352
6571
|
console.log("");
|
|
6353
6572
|
output.info(`Testing provider ${id}...`);
|
|
6354
6573
|
}
|
|
@@ -6358,9 +6577,9 @@ ${chalk18.dim("Tests connectivity and lists available models for the provider.")
|
|
|
6358
6577
|
} else {
|
|
6359
6578
|
if (result.success) {
|
|
6360
6579
|
output.success(`Provider test passed (${String(result.responseTimeMs)}ms)`);
|
|
6361
|
-
console.log(
|
|
6580
|
+
console.log(chalk19.green(`Message: ${result.message}`));
|
|
6362
6581
|
if (result.availableModels && result.availableModels.length > 0) {
|
|
6363
|
-
console.log(
|
|
6582
|
+
console.log(chalk19.bold(`
|
|
6364
6583
|
Available Models:`));
|
|
6365
6584
|
result.availableModels.forEach((model) => {
|
|
6366
6585
|
console.log(` - ${model}`);
|
|
@@ -6369,7 +6588,7 @@ Available Models:`));
|
|
|
6369
6588
|
} else {
|
|
6370
6589
|
output.error(`Provider test failed: ${result.message}`);
|
|
6371
6590
|
if (result.error) {
|
|
6372
|
-
console.log(
|
|
6591
|
+
console.log(chalk19.red(`Error: ${result.error}`));
|
|
6373
6592
|
}
|
|
6374
6593
|
}
|
|
6375
6594
|
}
|
|
@@ -6384,7 +6603,7 @@ Available Models:`));
|
|
|
6384
6603
|
init_config();
|
|
6385
6604
|
import { Command as Command14 } from "commander";
|
|
6386
6605
|
import inquirer3 from "inquirer";
|
|
6387
|
-
import
|
|
6606
|
+
import chalk20 from "chalk";
|
|
6388
6607
|
import { existsSync as existsSync12, mkdirSync as mkdirSync3, writeFileSync as writeFileSync4 } from "fs";
|
|
6389
6608
|
import { execSync as execSync3 } from "child_process";
|
|
6390
6609
|
import { join as join6 } from "path";
|
|
@@ -6507,13 +6726,13 @@ function writeRcConfig(config, cwd = process.cwd()) {
|
|
|
6507
6726
|
function createInitCommand() {
|
|
6508
6727
|
const init = new Command14("init").description("Initialize MutagenT in your project").option("--non-interactive", "Skip interactive prompts (defaults to CLI-only mode)").addHelpText("after", `
|
|
6509
6728
|
Examples:
|
|
6510
|
-
${
|
|
6511
|
-
${
|
|
6729
|
+
${chalk20.dim("$")} mutagent init # Interactive setup wizard
|
|
6730
|
+
${chalk20.dim("$")} mutagent init --non-interactive # CLI-only mode (no prompts)
|
|
6512
6731
|
|
|
6513
6732
|
Modes:
|
|
6514
|
-
${
|
|
6515
|
-
${
|
|
6516
|
-
${
|
|
6733
|
+
${chalk20.bold("Full scaffold")} Install SDK + integration package, create config, setup tracing
|
|
6734
|
+
${chalk20.bold("CLI-only")} Verify auth + create .mutagentrc.json with workspace/endpoint
|
|
6735
|
+
${chalk20.bold("Skip")} Exit without changes
|
|
6517
6736
|
`).action(async (options) => {
|
|
6518
6737
|
const isJson = getJsonFlag(init);
|
|
6519
6738
|
const output = new OutputFormatter(isJson ? "json" : "table");
|
|
@@ -6763,23 +6982,23 @@ Modes:
|
|
|
6763
6982
|
|
|
6764
6983
|
// src/commands/explore.ts
|
|
6765
6984
|
import { Command as Command15 } from "commander";
|
|
6766
|
-
import
|
|
6985
|
+
import chalk21 from "chalk";
|
|
6767
6986
|
import { resolve as resolve3 } from "path";
|
|
6768
6987
|
init_errors();
|
|
6769
6988
|
function createExploreCommand() {
|
|
6770
6989
|
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", `
|
|
6771
6990
|
Examples:
|
|
6772
|
-
${
|
|
6773
|
-
${
|
|
6774
|
-
${
|
|
6775
|
-
${
|
|
6776
|
-
${
|
|
6991
|
+
${chalk21.dim("$")} mutagent explore
|
|
6992
|
+
${chalk21.dim("$")} mutagent explore --path ./src
|
|
6993
|
+
${chalk21.dim("$")} mutagent explore --include "**/*.{ts,py}" --depth 5
|
|
6994
|
+
${chalk21.dim("$")} mutagent explore --markers-only
|
|
6995
|
+
${chalk21.dim("$")} mutagent explore --json
|
|
6777
6996
|
|
|
6778
6997
|
Detection modes:
|
|
6779
|
-
${
|
|
6780
|
-
${
|
|
6998
|
+
${chalk21.dim("Heuristic")} Template variables ({{var}}), prompt constants, schema definitions
|
|
6999
|
+
${chalk21.dim("Marker")} MutagenT:START/END comment markers from previous uploads
|
|
6781
7000
|
|
|
6782
|
-
${
|
|
7001
|
+
${chalk21.dim("Results are saved to .mutagent/mutation-context.md for use by other commands.")}
|
|
6783
7002
|
`).action((options) => {
|
|
6784
7003
|
const isJson = getJsonFlag(explore);
|
|
6785
7004
|
const output = new OutputFormatter(isJson ? "json" : "table");
|
|
@@ -6797,7 +7016,7 @@ ${chalk20.dim("Results are saved to .mutagent/mutation-context.md for use by oth
|
|
|
6797
7016
|
markersOnly
|
|
6798
7017
|
};
|
|
6799
7018
|
if (!isJson) {
|
|
6800
|
-
console.log(
|
|
7019
|
+
console.log(chalk21.cyan(`
|
|
6801
7020
|
Scanning ${scanPath}...
|
|
6802
7021
|
`));
|
|
6803
7022
|
}
|
|
@@ -6826,41 +7045,41 @@ Scanning ${scanPath}...
|
|
|
6826
7045
|
const totalFindings = result.prompts.length + result.datasets.length + result.markers.length;
|
|
6827
7046
|
if (totalFindings === 0) {
|
|
6828
7047
|
output.info("No prompts, datasets, or markers found.");
|
|
6829
|
-
console.log(
|
|
7048
|
+
console.log(chalk21.dim(`
|
|
6830
7049
|
Tip: Create a prompt with template variables like {{input}} to get started.`));
|
|
6831
7050
|
return;
|
|
6832
7051
|
}
|
|
6833
7052
|
if (result.prompts.length > 0) {
|
|
6834
|
-
console.log(
|
|
7053
|
+
console.log(chalk21.bold(` Prompts Found (${String(result.prompts.length)}):`));
|
|
6835
7054
|
console.log();
|
|
6836
7055
|
for (const p of result.prompts) {
|
|
6837
|
-
const confidenceTag = p.confidence === "high" ?
|
|
6838
|
-
const reasonTag =
|
|
6839
|
-
console.log(` ${confidenceTag} ${
|
|
6840
|
-
console.log(` ${
|
|
7056
|
+
const confidenceTag = p.confidence === "high" ? chalk21.green("[high]") : p.confidence === "medium" ? chalk21.yellow("[medium]") : chalk21.dim("[low]");
|
|
7057
|
+
const reasonTag = chalk21.dim(`[${p.reason}]`);
|
|
7058
|
+
console.log(` ${confidenceTag} ${chalk21.green(p.file)}:${chalk21.yellow(String(p.line))} ${reasonTag}`);
|
|
7059
|
+
console.log(` ${chalk21.dim(p.preview)}`);
|
|
6841
7060
|
}
|
|
6842
7061
|
console.log();
|
|
6843
7062
|
}
|
|
6844
7063
|
if (result.datasets.length > 0) {
|
|
6845
|
-
console.log(
|
|
7064
|
+
console.log(chalk21.bold(` Datasets Found (${String(result.datasets.length)}):`));
|
|
6846
7065
|
console.log();
|
|
6847
7066
|
for (const d of result.datasets) {
|
|
6848
|
-
console.log(` ${
|
|
7067
|
+
console.log(` ${chalk21.green(d.file)} ${chalk21.dim(`(${String(d.items)} items)`)}`);
|
|
6849
7068
|
}
|
|
6850
7069
|
console.log();
|
|
6851
7070
|
}
|
|
6852
7071
|
if (result.markers.length > 0) {
|
|
6853
|
-
console.log(
|
|
7072
|
+
console.log(chalk21.bold(` MutagenT Markers (${String(result.markers.length)}):`));
|
|
6854
7073
|
console.log();
|
|
6855
7074
|
for (const m of result.markers) {
|
|
6856
|
-
const idPart = m.platformId ?
|
|
6857
|
-
console.log(` ${
|
|
7075
|
+
const idPart = m.platformId ? chalk21.cyan(` id=${m.platformId}`) : "";
|
|
7076
|
+
console.log(` ${chalk21.green(m.file)}:${chalk21.yellow(String(m.line))} ${chalk21.magenta(m.type)}${idPart}`);
|
|
6858
7077
|
}
|
|
6859
7078
|
console.log();
|
|
6860
7079
|
}
|
|
6861
|
-
console.log(
|
|
6862
|
-
console.log(` ${
|
|
6863
|
-
console.log(
|
|
7080
|
+
console.log(chalk21.dim(" ─────────────────────────────────"));
|
|
7081
|
+
console.log(` ${chalk21.bold("Summary:")} ${String(result.prompts.length)} prompts, ${String(result.datasets.length)} datasets, ${String(result.markers.length)} markers`);
|
|
7082
|
+
console.log(chalk21.dim(` Saved to .mutagent/mutation-context.md`));
|
|
6864
7083
|
console.log();
|
|
6865
7084
|
}
|
|
6866
7085
|
} catch (error) {
|
|
@@ -6872,7 +7091,7 @@ Scanning ${scanPath}...
|
|
|
6872
7091
|
|
|
6873
7092
|
// src/commands/skills.ts
|
|
6874
7093
|
import { Command as Command16 } from "commander";
|
|
6875
|
-
import
|
|
7094
|
+
import chalk22 from "chalk";
|
|
6876
7095
|
import { existsSync as existsSync13, mkdirSync as mkdirSync4, writeFileSync as writeFileSync5 } from "fs";
|
|
6877
7096
|
import { join as join7 } from "path";
|
|
6878
7097
|
import { execSync as execSync4 } from "child_process";
|
|
@@ -6995,7 +7214,7 @@ function createSkillsCommand() {
|
|
|
6995
7214
|
const skills = new Command16("skills").description("Manage MutagenT CLI skills for coding agents");
|
|
6996
7215
|
skills.command("install").description("Install MutagenT CLI skill for Claude Code").addHelpText("after", `
|
|
6997
7216
|
Examples:
|
|
6998
|
-
${
|
|
7217
|
+
${chalk22.dim("$")} mutagent skills install
|
|
6999
7218
|
|
|
7000
7219
|
This creates a Claude Code skill at .claude/skills/mutagent-cli/SKILL.md
|
|
7001
7220
|
that teaches coding agents how to use the MutagenT CLI effectively.
|
|
@@ -7022,10 +7241,10 @@ ${SKILL_BODY}
|
|
|
7022
7241
|
});
|
|
7023
7242
|
} else {
|
|
7024
7243
|
output.success(`Installed MutagenT CLI skill`);
|
|
7025
|
-
console.log(` ${
|
|
7244
|
+
console.log(` ${chalk22.dim("Path:")} ${skillPath}`);
|
|
7026
7245
|
console.log("");
|
|
7027
|
-
console.log(` ${
|
|
7028
|
-
console.log(` ${
|
|
7246
|
+
console.log(` ${chalk22.dim("This skill teaches coding agents how to use the MutagenT CLI.")}`);
|
|
7247
|
+
console.log(` ${chalk22.dim("It will be automatically loaded by Claude Code when relevant triggers match.")}`);
|
|
7029
7248
|
}
|
|
7030
7249
|
});
|
|
7031
7250
|
return skills;
|
|
@@ -7034,7 +7253,7 @@ ${SKILL_BODY}
|
|
|
7034
7253
|
// src/commands/usage.ts
|
|
7035
7254
|
init_config();
|
|
7036
7255
|
import { Command as Command17 } from "commander";
|
|
7037
|
-
import
|
|
7256
|
+
import chalk23 from "chalk";
|
|
7038
7257
|
init_errors();
|
|
7039
7258
|
init_sdk_client();
|
|
7040
7259
|
var TRIAL_OPTIMIZATION_LIMIT = 5;
|
|
@@ -7050,8 +7269,8 @@ function renderProgressBar(used, limit, width = 30) {
|
|
|
7050
7269
|
function createUsageCommand() {
|
|
7051
7270
|
const usage = new Command17("usage").description("Show resource counts and optimization run limits").addHelpText("after", `
|
|
7052
7271
|
Examples:
|
|
7053
|
-
${
|
|
7054
|
-
${
|
|
7272
|
+
${chalk23.dim("$")} mutagent usage
|
|
7273
|
+
${chalk23.dim("$")} mutagent usage --json
|
|
7055
7274
|
`);
|
|
7056
7275
|
usage.action(async () => {
|
|
7057
7276
|
const isJson = getJsonFlag(usage);
|
|
@@ -7106,21 +7325,21 @@ Examples:
|
|
|
7106
7325
|
});
|
|
7107
7326
|
} else {
|
|
7108
7327
|
console.log("");
|
|
7109
|
-
console.log(
|
|
7110
|
-
console.log(
|
|
7328
|
+
console.log(chalk23.bold("\uD83D\uDCCA MutagenT Usage"));
|
|
7329
|
+
console.log(chalk23.dim("─".repeat(45)));
|
|
7111
7330
|
console.log("");
|
|
7112
|
-
console.log(
|
|
7113
|
-
console.log(` Prompts: ${
|
|
7114
|
-
console.log(` Datasets: ${
|
|
7115
|
-
console.log(` Evaluations: ${
|
|
7331
|
+
console.log(chalk23.bold("Resources:"));
|
|
7332
|
+
console.log(` Prompts: ${chalk23.cyan(String(promptCount))}`);
|
|
7333
|
+
console.log(` Datasets: ${chalk23.cyan(String(datasetCount))}`);
|
|
7334
|
+
console.log(` Evaluations: ${chalk23.cyan(String(evaluationCount))}`);
|
|
7116
7335
|
console.log("");
|
|
7117
|
-
console.log(
|
|
7118
|
-
console.log(` Remaining: ${
|
|
7336
|
+
console.log(chalk23.bold(`Optimization Runs (${chalk23.yellow("trial")} plan):`));
|
|
7337
|
+
console.log(` Remaining: ${chalk23.cyan(String(optimizationRemaining))} / ${String(optimizationLimit)}`);
|
|
7119
7338
|
console.log(` ${renderProgressBar(optimizationUsed, optimizationLimit)}`);
|
|
7120
7339
|
console.log("");
|
|
7121
|
-
console.log(
|
|
7122
|
-
console.log(
|
|
7123
|
-
console.log(` Upgrade: ${
|
|
7340
|
+
console.log(chalk23.yellow(` ⚠ ${String(optimizationRemaining)} optimization runs remaining`));
|
|
7341
|
+
console.log(chalk23.dim(` ℹ Optimization run counts are approximate`));
|
|
7342
|
+
console.log(` Upgrade: ${chalk23.underline(BILLING_URL)}`);
|
|
7124
7343
|
console.log("");
|
|
7125
7344
|
}
|
|
7126
7345
|
} catch (error) {
|
|
@@ -7152,57 +7371,57 @@ program.name("mutagent").description(`MutagenT CLI - AI-native prompt optimizati
|
|
|
7152
7371
|
showGlobalOptions: true
|
|
7153
7372
|
});
|
|
7154
7373
|
program.addHelpText("after", `
|
|
7155
|
-
${
|
|
7156
|
-
export MUTAGENT_API_KEY=mt_... ${
|
|
7157
|
-
--json ${
|
|
7158
|
-
|
|
7159
|
-
${
|
|
7160
|
-
mutagent auth login --browser ${
|
|
7161
|
-
mutagent auth status ${
|
|
7162
|
-
mutagent init ${
|
|
7163
|
-
mutagent explore ${
|
|
7164
|
-
mutagent workspaces list --json ${
|
|
7165
|
-
mutagent config set workspace <id> ${
|
|
7166
|
-
mutagent usage --json ${
|
|
7167
|
-
|
|
7168
|
-
mutagent prompts create --help ${
|
|
7169
|
-
mutagent prompts list --json ${
|
|
7170
|
-
mutagent prompts get <id> --json ${
|
|
7171
|
-
|
|
7172
|
-
mutagent prompts dataset add --help ${
|
|
7173
|
-
mutagent prompts dataset list <id> ${
|
|
7174
|
-
|
|
7175
|
-
mutagent prompts evaluation create --help ${
|
|
7176
|
-
mutagent prompts evaluation create <id> --guided --json ${
|
|
7177
|
-
mutagent prompts evaluation list <id> --json ${
|
|
7178
|
-
|
|
7179
|
-
mutagent prompts optimize start --help ${
|
|
7180
|
-
mutagent prompts optimize status <job-id> ${
|
|
7181
|
-
mutagent prompts optimize results <job-id> ${
|
|
7182
|
-
|
|
7183
|
-
mutagent integrate <framework> ${
|
|
7184
|
-
mutagent playground run <id> --input '{...}' ${
|
|
7185
|
-
|
|
7186
|
-
${
|
|
7187
|
-
1. mutagent prompts create --help ${
|
|
7188
|
-
2. mutagent prompts create ... --json ${
|
|
7189
|
-
3. mutagent prompts dataset add --help ${
|
|
7190
|
-
4. mutagent prompts dataset add <id> ... --json ${
|
|
7191
|
-
5. mutagent prompts evaluation create <id> --guided --json ${
|
|
7374
|
+
${chalk24.yellow("Non-Interactive Mode (CI/CD & Coding Agents):")}
|
|
7375
|
+
export MUTAGENT_API_KEY=mt_... ${chalk24.dim("or")} --api-key mt_...
|
|
7376
|
+
--json ${chalk24.dim("for structured output")} --non-interactive ${chalk24.dim("to disable prompts")}
|
|
7377
|
+
|
|
7378
|
+
${chalk24.yellow("Command Navigation:")}
|
|
7379
|
+
mutagent auth login --browser ${chalk24.dim("Authenticate (OAuth)")}
|
|
7380
|
+
mutagent auth status ${chalk24.dim("Check auth + workspace")}
|
|
7381
|
+
mutagent init ${chalk24.dim("Initialize project (.mutagentrc.json)")}
|
|
7382
|
+
mutagent explore ${chalk24.dim("Discover prompts in codebase")}
|
|
7383
|
+
mutagent workspaces list --json ${chalk24.dim("List workspaces (verify ID)")}
|
|
7384
|
+
mutagent config set workspace <id> ${chalk24.dim("Set active workspace")}
|
|
7385
|
+
mutagent usage --json ${chalk24.dim("Check plan limits")}
|
|
7386
|
+
|
|
7387
|
+
mutagent prompts create --help ${chalk24.dim("Upload prompt (read help first!)")}
|
|
7388
|
+
mutagent prompts list --json ${chalk24.dim("List prompts")}
|
|
7389
|
+
mutagent prompts get <id> --json ${chalk24.dim("Full prompt details + schemas")}
|
|
7390
|
+
|
|
7391
|
+
mutagent prompts dataset add --help ${chalk24.dim("Upload dataset (read help first!)")}
|
|
7392
|
+
mutagent prompts dataset list <id> ${chalk24.dim("List datasets")}
|
|
7393
|
+
|
|
7394
|
+
mutagent prompts evaluation create --help ${chalk24.dim("Create eval (read help first!)")}
|
|
7395
|
+
mutagent prompts evaluation create <id> --guided --json ${chalk24.dim("Guided eval workflow")}
|
|
7396
|
+
mutagent prompts evaluation list <id> --json ${chalk24.dim("List evaluations")}
|
|
7397
|
+
|
|
7398
|
+
mutagent prompts optimize start --help ${chalk24.dim("Run optimization (read help first!)")}
|
|
7399
|
+
mutagent prompts optimize status <job-id> ${chalk24.dim("Poll progress")}
|
|
7400
|
+
mutagent prompts optimize results <job-id> ${chalk24.dim("View scorecard")}
|
|
7401
|
+
|
|
7402
|
+
mutagent integrate <framework> ${chalk24.dim("Framework integration guide")}
|
|
7403
|
+
mutagent playground run <id> --input '{...}' ${chalk24.dim("Quick test")}
|
|
7404
|
+
|
|
7405
|
+
${chalk24.yellow("Workflow: Evaluate → Optimize:")}
|
|
7406
|
+
1. mutagent prompts create --help ${chalk24.dim("← read help")}
|
|
7407
|
+
2. mutagent prompts create ... --json ${chalk24.dim("← upload prompt with {variables} + inputSchema")}
|
|
7408
|
+
3. mutagent prompts dataset add --help ${chalk24.dim("← read help")}
|
|
7409
|
+
4. mutagent prompts dataset add <id> ... --json ${chalk24.dim("← upload dataset")}
|
|
7410
|
+
5. mutagent prompts evaluation create <id> --guided --json ${chalk24.dim("← guided eval")}
|
|
7192
7411
|
6. mutagent prompts optimize start <id> --dataset <d> --evaluation <e> --json
|
|
7193
7412
|
|
|
7194
|
-
${
|
|
7413
|
+
${chalk24.yellow("AI Agent Rules (MANDATORY for coding agents):")}
|
|
7195
7414
|
1. EVERY command MUST include --json (no exceptions)
|
|
7196
7415
|
2. Run <command> --help BEFORE first use of any command
|
|
7197
7416
|
3. Use --guided --json for evaluation creation (NEVER --guided alone)
|
|
7198
|
-
4. Parse
|
|
7417
|
+
4. Parse _directive.renderedCard and copy it into your CHAT RESPONSE verbatim — bash output is NOT sufficient
|
|
7199
7418
|
5. After mutagent init, verify workspace: mutagent workspaces list --json
|
|
7200
7419
|
6. Use {single_braces} for template variables in prompts
|
|
7201
7420
|
7. Collect evaluation rubrics from the user — NEVER auto-generate
|
|
7202
7421
|
${!hasCredentials() ? `
|
|
7203
|
-
` +
|
|
7422
|
+
` + chalk24.yellow(" Warning: Not authenticated. Run: mutagent auth login --browser") + `
|
|
7204
7423
|
` : ""}${!hasRcConfig() ? `
|
|
7205
|
-
` +
|
|
7424
|
+
` + chalk24.green(" Get started: mutagent init") + `
|
|
7206
7425
|
` : ""}`);
|
|
7207
7426
|
program.hook("preAction", (thisCommand) => {
|
|
7208
7427
|
const globalOpts = thisCommand.optsWithGlobals();
|
|
@@ -7232,5 +7451,5 @@ program.addCommand(createSkillsCommand());
|
|
|
7232
7451
|
program.addCommand(createUsageCommand());
|
|
7233
7452
|
program.parse();
|
|
7234
7453
|
|
|
7235
|
-
//# debugId=
|
|
7454
|
+
//# debugId=B35CD49159FCE51364756E2164756E21
|
|
7236
7455
|
//# sourceMappingURL=cli.js.map
|