@mutagent/cli 0.1.41 → 0.1.43
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 +215 -208
- package/dist/bin/cli.js.map +7 -7
- package/package.json +1 -1
package/dist/bin/cli.js
CHANGED
|
@@ -1063,7 +1063,7 @@ var init_sdk_client = __esm(() => {
|
|
|
1063
1063
|
// src/bin/cli.ts
|
|
1064
1064
|
import { Command as Command19 } from "commander";
|
|
1065
1065
|
import chalk24 from "chalk";
|
|
1066
|
-
import { readFileSync as
|
|
1066
|
+
import { readFileSync as readFileSync11 } from "fs";
|
|
1067
1067
|
import { join as join9, dirname } from "path";
|
|
1068
1068
|
import { fileURLToPath } from "url";
|
|
1069
1069
|
|
|
@@ -2505,7 +2505,7 @@ Environment Variables:
|
|
|
2505
2505
|
init_errors();
|
|
2506
2506
|
import { Command as Command6 } from "commander";
|
|
2507
2507
|
import chalk11 from "chalk";
|
|
2508
|
-
import { readFileSync as
|
|
2508
|
+
import { readFileSync as readFileSync4, existsSync as existsSync4 } from "fs";
|
|
2509
2509
|
|
|
2510
2510
|
// src/lib/ui-links.ts
|
|
2511
2511
|
function getAppBaseUrl() {
|
|
@@ -3019,7 +3019,6 @@ function buildScorecardDetailsText(data) {
|
|
|
3019
3019
|
// src/commands/prompts/prompts-crud.ts
|
|
3020
3020
|
init_sdk_client();
|
|
3021
3021
|
import chalk6 from "chalk";
|
|
3022
|
-
import { readFileSync as readFileSync4, existsSync as existsSync4 } from "fs";
|
|
3023
3022
|
init_errors();
|
|
3024
3023
|
|
|
3025
3024
|
// src/lib/schema-helpers.ts
|
|
@@ -3162,21 +3161,16 @@ ${chalk6.dim("Tip: Combine --with-datasets and --with-evals to fetch all nested
|
|
|
3162
3161
|
handleError(error, isJson);
|
|
3163
3162
|
}
|
|
3164
3163
|
});
|
|
3165
|
-
prompts.command("create").description("Create a new prompt").option("-
|
|
3164
|
+
prompts.command("create").description("Create a new prompt").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", `
|
|
3166
3165
|
Examples:
|
|
3167
3166
|
${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"}}}'
|
|
3168
3167
|
${chalk6.dim("$")} mutagent prompts create --name "raw-prompt" --raw "Summarize: {text}" --output-schema '{"type":"object","properties":{"summary":{"type":"string","description":"Summary"}}}'
|
|
3169
|
-
${chalk6.dim("$")} mutagent prompts create -
|
|
3168
|
+
${chalk6.dim("$")} mutagent prompts create --name "multi-turn" --messages '[{"role":"system","content":"You are helpful"},{"role":"user","content":"{input}"}]' --output-schema '{"type":"object","properties":{"result":{"type":"string","description":"The result"}}}'
|
|
3170
3169
|
|
|
3171
3170
|
Prompt Input Methods (pick one, priority order):
|
|
3172
3171
|
--system/--human Structured system + user message pair ${chalk6.green("(recommended)")}
|
|
3173
3172
|
--raw Single raw prompt text with {variables}
|
|
3174
|
-
-d, --data Inline JSON object (CI/scripts/agents)
|
|
3175
3173
|
--messages Full messages array as JSON
|
|
3176
|
-
--raw-file Load plain text file as raw prompt
|
|
3177
|
-
|
|
3178
|
-
Expected JSON (--data):
|
|
3179
|
-
${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"}}}}'`)}
|
|
3180
3174
|
|
|
3181
3175
|
${chalk6.yellow("Variable Syntax:")}
|
|
3182
3176
|
MutagenT uses {single_braces} for template variables.
|
|
@@ -3186,6 +3180,23 @@ ${chalk6.yellow("Variable Syntax:")}
|
|
|
3186
3180
|
Variables in humanPrompt MUST also appear in inputSchema.properties.
|
|
3187
3181
|
Static prompts (no variables) cannot substitute inputs during optimization.
|
|
3188
3182
|
|
|
3183
|
+
${chalk6.yellow("AI Agent: Format Selection Rules")}
|
|
3184
|
+
Examine the SOURCE CODE structure of the prompt being uploaded:
|
|
3185
|
+
|
|
3186
|
+
1. If the code uses SystemMessagePromptTemplate + HumanMessagePromptTemplate
|
|
3187
|
+
(or equivalent system/human split in any framework):
|
|
3188
|
+
→ Use --system "..." --human "..."
|
|
3189
|
+
|
|
3190
|
+
2. If the code is a single string template with {variables}, no role split:
|
|
3191
|
+
→ Use --raw "..."
|
|
3192
|
+
|
|
3193
|
+
3. If the code uses a messages array (ChatPromptTemplate.fromMessages,
|
|
3194
|
+
multi-turn, or >2 roles):
|
|
3195
|
+
→ Use --messages '[{"role":"system","content":"..."},{"role":"user","content":"..."}]'
|
|
3196
|
+
|
|
3197
|
+
The decision is about SOURCE CODE STRUCTURE, not prompt content.
|
|
3198
|
+
A persona description in a system prompt still uses --system/--human.
|
|
3199
|
+
|
|
3189
3200
|
${chalk6.red("outputSchema is required.")}
|
|
3190
3201
|
|
|
3191
3202
|
${chalk6.yellow("AI Agent: ALWAYS append --json to this command.")}
|
|
@@ -3194,29 +3205,7 @@ ${chalk6.yellow("AI Agent: ALWAYS append --json to this command.")}
|
|
|
3194
3205
|
const output = new OutputFormatter(isJson ? "json" : "table");
|
|
3195
3206
|
try {
|
|
3196
3207
|
let data;
|
|
3197
|
-
if (options.
|
|
3198
|
-
try {
|
|
3199
|
-
data = JSON.parse(options.data);
|
|
3200
|
-
} catch {
|
|
3201
|
-
throw new MutagentError("INVALID_JSON", "Invalid JSON in --data flag", `Run: mutagent prompts create --help
|
|
3202
|
-
Provide a valid JSON object, e.g., '{"name":"my-prompt","systemPrompt":"You are helpful"}'`);
|
|
3203
|
-
}
|
|
3204
|
-
if (options.name)
|
|
3205
|
-
data.name = options.name;
|
|
3206
|
-
if (options.description)
|
|
3207
|
-
data.description = options.description;
|
|
3208
|
-
} else if (options.rawFile) {
|
|
3209
|
-
if (!existsSync4(options.rawFile)) {
|
|
3210
|
-
throw new MutagentError("FILE_NOT_FOUND", `File not found: ${options.rawFile}`, `Run: mutagent prompts create --help
|
|
3211
|
-
Check the file path and try again`);
|
|
3212
|
-
}
|
|
3213
|
-
const textContent = readFileSync4(options.rawFile, "utf-8");
|
|
3214
|
-
data = {
|
|
3215
|
-
name: options.name ?? options.rawFile.replace(/^.*[\\/]/, "").replace(/\.[^.]+$/, ""),
|
|
3216
|
-
description: options.description,
|
|
3217
|
-
rawPrompt: textContent
|
|
3218
|
-
};
|
|
3219
|
-
} else if (options.name) {
|
|
3208
|
+
if (options.name) {
|
|
3220
3209
|
data = { name: options.name, description: options.description };
|
|
3221
3210
|
if (options.messages) {
|
|
3222
3211
|
try {
|
|
@@ -3242,11 +3231,11 @@ Provide a valid JSON array, e.g., '[{"role":"system","content":"..."}]'`);
|
|
|
3242
3231
|
data.rawPrompt = options.content;
|
|
3243
3232
|
} else {
|
|
3244
3233
|
throw new MutagentError("MISSING_ARGUMENTS", "Prompt content required", `Run: mutagent prompts create --help
|
|
3245
|
-
Use --
|
|
3234
|
+
Use --raw, --system/--human, or --messages to specify prompt content`);
|
|
3246
3235
|
}
|
|
3247
3236
|
} else {
|
|
3248
|
-
throw new MutagentError("MISSING_ARGUMENTS", "
|
|
3249
|
-
|
|
3237
|
+
throw new MutagentError("MISSING_ARGUMENTS", "--name is required. Use --name with --system/--human, --raw, or --messages", `Run: mutagent prompts create --help
|
|
3238
|
+
Provide --name with --system/--human, --raw, or --messages to specify prompt content`);
|
|
3250
3239
|
}
|
|
3251
3240
|
if (options.outputSchema) {
|
|
3252
3241
|
try {
|
|
@@ -3258,12 +3247,11 @@ Provide a valid JSON Schema, e.g., '{"type":"object","properties":{"result":{"ty
|
|
|
3258
3247
|
}
|
|
3259
3248
|
if (isSchemaEmpty(data.outputSchema)) {
|
|
3260
3249
|
throw new MutagentError("MISSING_ARGUMENTS", "outputSchema is required for prompt creation", `Run: mutagent prompts create --help
|
|
3261
|
-
Use --output-schema '{"type":"object","properties":{...}}'
|
|
3250
|
+
Use --output-schema '{"type":"object","properties":{...}}'`);
|
|
3262
3251
|
}
|
|
3263
3252
|
if (isSchemaEmpty(data.inputSchema)) {
|
|
3264
3253
|
throw new MutagentError("VALIDATION_ERROR", "inputSchema is required. Optimization cannot run without defined input variables.", `Run: mutagent prompts create --help
|
|
3265
|
-
|
|
3266
|
-
` + ` --data '{"inputSchema":{"type":"object","properties":{"query":{"type":"string","description":"User query"}}}}'`);
|
|
3254
|
+
inputSchema must be provided. Pass it via the API or dashboard.`);
|
|
3267
3255
|
} else if (!isValidJsonSchema(data.inputSchema)) {
|
|
3268
3256
|
throw new MutagentError("VALIDATION_ERROR", "inputSchema is not a valid JSON Schema object.", `Run: mutagent prompts create --help
|
|
3269
3257
|
` + formatSchemaWarning("inputSchema"));
|
|
@@ -3297,82 +3285,48 @@ Add a 'description' field to each property in your inputSchema. Example: { "prop
|
|
|
3297
3285
|
});
|
|
3298
3286
|
console.log(hints);
|
|
3299
3287
|
}
|
|
3300
|
-
if (options.rawFile) {
|
|
3301
|
-
const rawFilePath = options.rawFile;
|
|
3302
|
-
updateMutationContext((ctx) => {
|
|
3303
|
-
const preview = (data.rawPrompt ?? data.systemPrompt ?? data.name ?? "").slice(0, 50);
|
|
3304
|
-
ctx.addDiscoveredPrompt(rawFilePath, 1, preview);
|
|
3305
|
-
ctx.markPromptUploaded(rawFilePath, String(prompt.id), prompt.version);
|
|
3306
|
-
});
|
|
3307
|
-
}
|
|
3308
3288
|
} catch (error) {
|
|
3309
3289
|
handleError(error, isJson);
|
|
3310
3290
|
}
|
|
3311
3291
|
});
|
|
3312
|
-
prompts.command("update").description("Update a prompt").argument("<id>", "Prompt ID (from: mutagent prompts list)").option("-
|
|
3292
|
+
prompts.command("update").description("Update a prompt").argument("<id>", "Prompt ID (from: mutagent prompts list)").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", `
|
|
3313
3293
|
Examples:
|
|
3314
3294
|
${chalk6.dim("$")} mutagent prompts update <id> --system "Updated system prompt" --human "{input}"
|
|
3315
3295
|
${chalk6.dim("$")} mutagent prompts update <id> --name "new-name" --description "Updated description"
|
|
3316
3296
|
${chalk6.dim("$")} mutagent prompts update <id> --raw "Summarize: {text}"
|
|
3317
|
-
${chalk6.dim("$")} mutagent prompts update <id>
|
|
3297
|
+
${chalk6.dim("$")} mutagent prompts update <id> --messages '[{"role":"system","content":"Updated"},{"role":"user","content":"{input}"}]'
|
|
3318
3298
|
${chalk6.dim("$")} mutagent prompts update <id> --input-schema '{"type":"object","properties":{"text":{"type":"string","description":"Input text"}}}'
|
|
3319
|
-
|
|
3320
|
-
${chalk6.dim("CLI flags (--name) override --data fields.")}
|
|
3321
3299
|
`).action(async (id, options) => {
|
|
3322
3300
|
const isJson = getJsonFlag(prompts);
|
|
3323
3301
|
const output = new OutputFormatter(isJson ? "json" : "table");
|
|
3324
3302
|
try {
|
|
3325
3303
|
let data = {};
|
|
3326
|
-
if (options.
|
|
3304
|
+
if (options.name)
|
|
3305
|
+
data.name = options.name;
|
|
3306
|
+
if (options.description)
|
|
3307
|
+
data.description = options.description;
|
|
3308
|
+
if (options.messages) {
|
|
3327
3309
|
try {
|
|
3328
|
-
|
|
3310
|
+
const messages = JSON.parse(options.messages);
|
|
3311
|
+
const systemMsg = messages.find((m) => m.role === "system");
|
|
3312
|
+
const humanMsg = messages.find((m) => m.role === "user" || m.role === "human");
|
|
3313
|
+
if (systemMsg)
|
|
3314
|
+
data.systemPrompt = systemMsg.content;
|
|
3315
|
+
if (humanMsg)
|
|
3316
|
+
data.humanPrompt = humanMsg.content;
|
|
3329
3317
|
} catch {
|
|
3330
|
-
throw new MutagentError("INVALID_JSON", "Invalid JSON in --
|
|
3331
|
-
` + `Provide a valid JSON object, e.g., '{"name":"new-name","systemPrompt":"Updated prompt"}'`);
|
|
3332
|
-
}
|
|
3333
|
-
if (options.name)
|
|
3334
|
-
data.name = options.name;
|
|
3335
|
-
if (options.description)
|
|
3336
|
-
data.description = options.description;
|
|
3337
|
-
} else if (options.rawFile) {
|
|
3338
|
-
if (!existsSync4(options.rawFile)) {
|
|
3339
|
-
throw new MutagentError("FILE_NOT_FOUND", `File not found: ${options.rawFile}`, `Run: mutagent prompts update --help
|
|
3340
|
-
` + "Check the file path and try again");
|
|
3341
|
-
}
|
|
3342
|
-
const textContent = readFileSync4(options.rawFile, "utf-8");
|
|
3343
|
-
data.rawPrompt = textContent;
|
|
3344
|
-
if (options.name)
|
|
3345
|
-
data.name = options.name;
|
|
3346
|
-
if (options.description)
|
|
3347
|
-
data.description = options.description;
|
|
3348
|
-
} else {
|
|
3349
|
-
if (options.name)
|
|
3350
|
-
data.name = options.name;
|
|
3351
|
-
if (options.description)
|
|
3352
|
-
data.description = options.description;
|
|
3353
|
-
if (options.messages) {
|
|
3354
|
-
try {
|
|
3355
|
-
const messages = JSON.parse(options.messages);
|
|
3356
|
-
const systemMsg = messages.find((m) => m.role === "system");
|
|
3357
|
-
const humanMsg = messages.find((m) => m.role === "user" || m.role === "human");
|
|
3358
|
-
if (systemMsg)
|
|
3359
|
-
data.systemPrompt = systemMsg.content;
|
|
3360
|
-
if (humanMsg)
|
|
3361
|
-
data.humanPrompt = humanMsg.content;
|
|
3362
|
-
} catch {
|
|
3363
|
-
throw new MutagentError("INVALID_JSON", "Invalid JSON in --messages flag", `Run: mutagent prompts update --help
|
|
3318
|
+
throw new MutagentError("INVALID_JSON", "Invalid JSON in --messages flag", `Run: mutagent prompts update --help
|
|
3364
3319
|
` + `Provide a valid JSON array, e.g., '[{"role":"system","content":"..."}]'`);
|
|
3365
|
-
}
|
|
3366
|
-
} else if (options.system ?? options.human) {
|
|
3367
|
-
if (options.system)
|
|
3368
|
-
data.systemPrompt = options.system;
|
|
3369
|
-
if (options.human)
|
|
3370
|
-
data.humanPrompt = options.human;
|
|
3371
|
-
} else if (options.raw) {
|
|
3372
|
-
data.rawPrompt = options.raw;
|
|
3373
|
-
} else if (options.content) {
|
|
3374
|
-
data.rawPrompt = options.content;
|
|
3375
3320
|
}
|
|
3321
|
+
} else if (options.system ?? options.human) {
|
|
3322
|
+
if (options.system)
|
|
3323
|
+
data.systemPrompt = options.system;
|
|
3324
|
+
if (options.human)
|
|
3325
|
+
data.humanPrompt = options.human;
|
|
3326
|
+
} else if (options.raw) {
|
|
3327
|
+
data.rawPrompt = options.raw;
|
|
3328
|
+
} else if (options.content) {
|
|
3329
|
+
data.rawPrompt = options.content;
|
|
3376
3330
|
}
|
|
3377
3331
|
const parsedInputSchema = parseSchemaOption(options.inputSchema, options.inputSchemaFile, "input-schema", "mutagent prompts update --help");
|
|
3378
3332
|
if (parsedInputSchema)
|
|
@@ -3389,7 +3343,7 @@ ${chalk6.dim("CLI flags (--name) override --data fields.")}
|
|
|
3389
3343
|
}
|
|
3390
3344
|
if (Object.keys(data).length === 0) {
|
|
3391
3345
|
throw new MutagentError("MISSING_ARGUMENTS", "No update data provided", `Run: mutagent prompts update --help
|
|
3392
|
-
` + "Use --
|
|
3346
|
+
` + "Use --name, --raw, --system/--human, --messages, --input-schema, or --output-schema");
|
|
3393
3347
|
}
|
|
3394
3348
|
const client = getSDKClient();
|
|
3395
3349
|
const prompt = await client.updatePrompt(id, data);
|
|
@@ -3408,12 +3362,6 @@ ${chalk6.dim("CLI flags (--name) override --data fields.")}
|
|
|
3408
3362
|
});
|
|
3409
3363
|
console.log(hints);
|
|
3410
3364
|
}
|
|
3411
|
-
if (options.rawFile) {
|
|
3412
|
-
const rawFilePath = options.rawFile;
|
|
3413
|
-
updateMutationContext((ctx) => {
|
|
3414
|
-
ctx.markPromptUploaded(rawFilePath, String(prompt.id), prompt.version);
|
|
3415
|
-
});
|
|
3416
|
-
}
|
|
3417
3365
|
} catch (error) {
|
|
3418
3366
|
handleError(error, isJson);
|
|
3419
3367
|
}
|
|
@@ -4859,12 +4807,12 @@ Provide a valid JSON Schema, e.g., '{"type":"object","properties":{"field":{"typ
|
|
|
4859
4807
|
}
|
|
4860
4808
|
}
|
|
4861
4809
|
if (filePath) {
|
|
4862
|
-
if (!
|
|
4810
|
+
if (!existsSync4(filePath)) {
|
|
4863
4811
|
throw new MutagentError("FILE_NOT_FOUND", `File not found: ${filePath}`, `Run: ${helpCommand}
|
|
4864
4812
|
Check the file path and try again`);
|
|
4865
4813
|
}
|
|
4866
4814
|
try {
|
|
4867
|
-
return JSON.parse(
|
|
4815
|
+
return JSON.parse(readFileSync4(filePath, "utf-8"));
|
|
4868
4816
|
} catch {
|
|
4869
4817
|
throw new MutagentError("INVALID_JSON", `Failed to parse JSON from ${filePath}`, `Run: ${helpCommand}
|
|
4870
4818
|
Ensure the file contains valid JSON Schema`);
|
|
@@ -5104,20 +5052,20 @@ ${chalk12.dim("Exports to stdout by default. Use --output to save to a file.")}
|
|
|
5104
5052
|
init_config();
|
|
5105
5053
|
import { Command as Command8 } from "commander";
|
|
5106
5054
|
import chalk13 from "chalk";
|
|
5107
|
-
import { writeFileSync as writeFileSync3, existsSync as
|
|
5055
|
+
import { writeFileSync as writeFileSync3, existsSync as existsSync9 } from "fs";
|
|
5108
5056
|
import { execSync } from "child_process";
|
|
5109
5057
|
init_errors();
|
|
5110
5058
|
|
|
5111
5059
|
// src/lib/integrations/langchain.ts
|
|
5112
|
-
import { readFileSync as
|
|
5060
|
+
import { readFileSync as readFileSync5, existsSync as existsSync5 } from "fs";
|
|
5113
5061
|
var langchainIntegration = {
|
|
5114
5062
|
name: "langchain",
|
|
5115
5063
|
description: "LangChain framework",
|
|
5116
5064
|
detect() {
|
|
5117
5065
|
let hasLangchain = false;
|
|
5118
|
-
if (
|
|
5066
|
+
if (existsSync5("package.json")) {
|
|
5119
5067
|
try {
|
|
5120
|
-
const pkg = JSON.parse(
|
|
5068
|
+
const pkg = JSON.parse(readFileSync5("package.json", "utf-8"));
|
|
5121
5069
|
const deps = { ...pkg.dependencies, ...pkg.devDependencies };
|
|
5122
5070
|
hasLangchain = "langchain" in deps || "@langchain/core" in deps;
|
|
5123
5071
|
} catch {}
|
|
@@ -5249,15 +5197,15 @@ mutagent traces analyze <prompt-id>
|
|
|
5249
5197
|
};
|
|
5250
5198
|
|
|
5251
5199
|
// src/lib/integrations/langgraph.ts
|
|
5252
|
-
import { readFileSync as
|
|
5200
|
+
import { readFileSync as readFileSync6, existsSync as existsSync6 } from "fs";
|
|
5253
5201
|
var langgraphIntegration = {
|
|
5254
5202
|
name: "langgraph",
|
|
5255
5203
|
description: "LangGraph agent workflow framework",
|
|
5256
5204
|
detect() {
|
|
5257
5205
|
let hasLanggraph = false;
|
|
5258
|
-
if (
|
|
5206
|
+
if (existsSync6("package.json")) {
|
|
5259
5207
|
try {
|
|
5260
|
-
const pkg = JSON.parse(
|
|
5208
|
+
const pkg = JSON.parse(readFileSync6("package.json", "utf-8"));
|
|
5261
5209
|
const deps = { ...pkg.dependencies, ...pkg.devDependencies };
|
|
5262
5210
|
hasLanggraph = "@langchain/langgraph" in deps;
|
|
5263
5211
|
} catch {}
|
|
@@ -5378,15 +5326,15 @@ mutagent integrate langgraph --verify
|
|
|
5378
5326
|
};
|
|
5379
5327
|
|
|
5380
5328
|
// src/lib/integrations/vercel-ai.ts
|
|
5381
|
-
import { readFileSync as
|
|
5329
|
+
import { readFileSync as readFileSync7, existsSync as existsSync7 } from "fs";
|
|
5382
5330
|
var vercelAiIntegration = {
|
|
5383
5331
|
name: "vercel-ai",
|
|
5384
5332
|
description: "Vercel AI SDK",
|
|
5385
5333
|
detect() {
|
|
5386
5334
|
let hasAiSdk = false;
|
|
5387
|
-
if (
|
|
5335
|
+
if (existsSync7("package.json")) {
|
|
5388
5336
|
try {
|
|
5389
|
-
const pkg = JSON.parse(
|
|
5337
|
+
const pkg = JSON.parse(readFileSync7("package.json", "utf-8"));
|
|
5390
5338
|
const deps = { ...pkg.dependencies, ...pkg.devDependencies };
|
|
5391
5339
|
hasAiSdk = "ai" in deps;
|
|
5392
5340
|
} catch {}
|
|
@@ -5524,15 +5472,15 @@ mutagent integrate vercel-ai --verify
|
|
|
5524
5472
|
};
|
|
5525
5473
|
|
|
5526
5474
|
// src/lib/integrations/openai.ts
|
|
5527
|
-
import { readFileSync as
|
|
5475
|
+
import { readFileSync as readFileSync8, existsSync as existsSync8 } from "fs";
|
|
5528
5476
|
var openaiIntegration = {
|
|
5529
5477
|
name: "openai",
|
|
5530
5478
|
description: "OpenAI SDK integration with automatic tracing",
|
|
5531
5479
|
detect() {
|
|
5532
5480
|
let hasOpenAI = false;
|
|
5533
|
-
if (
|
|
5481
|
+
if (existsSync8("package.json")) {
|
|
5534
5482
|
try {
|
|
5535
|
-
const pkg = JSON.parse(
|
|
5483
|
+
const pkg = JSON.parse(readFileSync8("package.json", "utf-8"));
|
|
5536
5484
|
const deps = { ...pkg.dependencies, ...pkg.devDependencies };
|
|
5537
5485
|
hasOpenAI = "openai" in deps;
|
|
5538
5486
|
} catch {}
|
|
@@ -5686,16 +5634,16 @@ function getFrameworkMetadata(name) {
|
|
|
5686
5634
|
|
|
5687
5635
|
// src/commands/integrate.ts
|
|
5688
5636
|
function detectPackageManager() {
|
|
5689
|
-
if (
|
|
5637
|
+
if (existsSync9("bun.lockb") || existsSync9("bun.lock")) {
|
|
5690
5638
|
return "bun";
|
|
5691
5639
|
}
|
|
5692
|
-
if (
|
|
5640
|
+
if (existsSync9("pnpm-lock.yaml")) {
|
|
5693
5641
|
return "pnpm";
|
|
5694
5642
|
}
|
|
5695
|
-
if (
|
|
5643
|
+
if (existsSync9("yarn.lock")) {
|
|
5696
5644
|
return "yarn";
|
|
5697
5645
|
}
|
|
5698
|
-
if (
|
|
5646
|
+
if (existsSync9("package-lock.json")) {
|
|
5699
5647
|
return "npm";
|
|
5700
5648
|
}
|
|
5701
5649
|
try {
|
|
@@ -6740,13 +6688,13 @@ init_config();
|
|
|
6740
6688
|
import { Command as Command14 } from "commander";
|
|
6741
6689
|
import inquirer3 from "inquirer";
|
|
6742
6690
|
import chalk20 from "chalk";
|
|
6743
|
-
import { existsSync as
|
|
6691
|
+
import { existsSync as existsSync11, mkdirSync as mkdirSync3, writeFileSync as writeFileSync4 } from "fs";
|
|
6744
6692
|
import { execSync as execSync3 } from "child_process";
|
|
6745
6693
|
import { join as join6 } from "path";
|
|
6746
6694
|
init_errors();
|
|
6747
6695
|
|
|
6748
6696
|
// src/lib/framework-detection.ts
|
|
6749
|
-
import { existsSync as
|
|
6697
|
+
import { existsSync as existsSync10, readFileSync as readFileSync9 } from "fs";
|
|
6750
6698
|
import { execSync as execSync2 } from "child_process";
|
|
6751
6699
|
import { join as join5 } from "path";
|
|
6752
6700
|
var FRAMEWORK_DETECTION_MAP = {
|
|
@@ -6798,16 +6746,16 @@ var FRAMEWORK_DETECTION_MAP = {
|
|
|
6798
6746
|
}
|
|
6799
6747
|
};
|
|
6800
6748
|
function detectPackageManager2(cwd = process.cwd()) {
|
|
6801
|
-
if (
|
|
6749
|
+
if (existsSync10(join5(cwd, "bun.lockb")) || existsSync10(join5(cwd, "bun.lock"))) {
|
|
6802
6750
|
return "bun";
|
|
6803
6751
|
}
|
|
6804
|
-
if (
|
|
6752
|
+
if (existsSync10(join5(cwd, "pnpm-lock.yaml"))) {
|
|
6805
6753
|
return "pnpm";
|
|
6806
6754
|
}
|
|
6807
|
-
if (
|
|
6755
|
+
if (existsSync10(join5(cwd, "yarn.lock"))) {
|
|
6808
6756
|
return "yarn";
|
|
6809
6757
|
}
|
|
6810
|
-
if (
|
|
6758
|
+
if (existsSync10(join5(cwd, "package-lock.json"))) {
|
|
6811
6759
|
return "npm";
|
|
6812
6760
|
}
|
|
6813
6761
|
try {
|
|
@@ -6829,12 +6777,12 @@ function getInstallCommand2(pm, packages) {
|
|
|
6829
6777
|
}
|
|
6830
6778
|
function detectFrameworkFromPackageJson(cwd = process.cwd()) {
|
|
6831
6779
|
const pkgPath = join5(cwd, "package.json");
|
|
6832
|
-
if (!
|
|
6780
|
+
if (!existsSync10(pkgPath)) {
|
|
6833
6781
|
return null;
|
|
6834
6782
|
}
|
|
6835
6783
|
let pkg;
|
|
6836
6784
|
try {
|
|
6837
|
-
pkg = JSON.parse(
|
|
6785
|
+
pkg = JSON.parse(readFileSync9(pkgPath, "utf-8"));
|
|
6838
6786
|
} catch {
|
|
6839
6787
|
return null;
|
|
6840
6788
|
}
|
|
@@ -6850,7 +6798,7 @@ function detectFrameworkFromPackageJson(cwd = process.cwd()) {
|
|
|
6850
6798
|
return null;
|
|
6851
6799
|
}
|
|
6852
6800
|
function hasRcConfig(cwd = process.cwd()) {
|
|
6853
|
-
return
|
|
6801
|
+
return existsSync10(join5(cwd, ".mutagentrc.json"));
|
|
6854
6802
|
}
|
|
6855
6803
|
|
|
6856
6804
|
// src/commands/init.ts
|
|
@@ -7069,7 +7017,7 @@ Modes:
|
|
|
7069
7017
|
}
|
|
7070
7018
|
}
|
|
7071
7019
|
const skillPath = join6(cwd, ".claude/skills/mutagent-cli/SKILL.md");
|
|
7072
|
-
const skillInstalled =
|
|
7020
|
+
const skillInstalled = existsSync11(skillPath);
|
|
7073
7021
|
if (!isNonInteractive && !skillInstalled) {
|
|
7074
7022
|
const { installSkill } = await inquirer3.prompt([{
|
|
7075
7023
|
type: "confirm",
|
|
@@ -7080,7 +7028,7 @@ Modes:
|
|
|
7080
7028
|
if (installSkill) {
|
|
7081
7029
|
try {
|
|
7082
7030
|
const skillDir = join6(cwd, ".claude/skills/mutagent-cli");
|
|
7083
|
-
if (!
|
|
7031
|
+
if (!existsSync11(skillDir)) {
|
|
7084
7032
|
mkdirSync3(skillDir, { recursive: true });
|
|
7085
7033
|
}
|
|
7086
7034
|
execSync3("node " + join6(cwd, "node_modules/.bin/mutagent") + " skills install", {
|
|
@@ -7101,7 +7049,7 @@ Modes:
|
|
|
7101
7049
|
framework: confirmedFramework?.name ?? null,
|
|
7102
7050
|
authenticated,
|
|
7103
7051
|
workspaceValidation: workspaceValidation ?? null,
|
|
7104
|
-
skillInstalled: skillInstalled ||
|
|
7052
|
+
skillInstalled: skillInstalled || existsSync11(skillPath),
|
|
7105
7053
|
_directive: {
|
|
7106
7054
|
instruction: "Verify workspace. Run: mutagent workspaces list --json",
|
|
7107
7055
|
next: ["mutagent workspaces list --json", "mutagent prompts list --json"],
|
|
@@ -7247,7 +7195,7 @@ Scanning ${scanPath}...
|
|
|
7247
7195
|
// src/commands/skills.ts
|
|
7248
7196
|
import { Command as Command16 } from "commander";
|
|
7249
7197
|
import chalk22 from "chalk";
|
|
7250
|
-
import { existsSync as
|
|
7198
|
+
import { existsSync as existsSync12, mkdirSync as mkdirSync4, writeFileSync as writeFileSync5 } from "fs";
|
|
7251
7199
|
import { join as join7 } from "path";
|
|
7252
7200
|
import { execSync as execSync4 } from "child_process";
|
|
7253
7201
|
function findRepoRoot() {
|
|
@@ -7268,24 +7216,27 @@ description: |
|
|
|
7268
7216
|
---`;
|
|
7269
7217
|
var SKILL_BODY = `# MutagenT CLI Skill
|
|
7270
7218
|
|
|
7271
|
-
##
|
|
7272
|
-
Run \`mutagent --help\`
|
|
7273
|
-
Run \`mutagent <command> --help\`
|
|
7219
|
+
## First Things First
|
|
7220
|
+
Run \`mutagent --help\` — this is the CENTRAL navigation hub containing ALL commands, workflows, and rules.
|
|
7221
|
+
Run \`mutagent <command> --help\` BEFORE using ANY command for the first time.
|
|
7274
7222
|
|
|
7275
|
-
|
|
7276
|
-
|
|
7277
|
-
|
|
7278
|
-
|
|
7279
|
-
|
|
7280
|
-
- \`mutagent integrate <framework>\` — Framework integration instructions
|
|
7223
|
+
## Agent Protocol (4 Rules)
|
|
7224
|
+
1. EVERY command MUST include \`--json\`
|
|
7225
|
+
2. Run \`<command> --help\` BEFORE first use
|
|
7226
|
+
3. **MANDATORY**: Parse \`_directive.renderedCard\` and copy it into your CHAT RESPONSE verbatim. The card appears in bash output but that is NOT sufficient — the user cannot read collapsed bash blocks. HARD STOP: do NOT run any further commands until the card text is rendered in your chat message.
|
|
7227
|
+
4. ALL user interaction via AskUserQuestion — CLI is non-interactive
|
|
7281
7228
|
|
|
7282
|
-
##
|
|
7229
|
+
## Directive System
|
|
7230
|
+
Every JSON response may include:
|
|
7231
|
+
- \`_directive.renderedCard\` — Pre-formatted card that MUST be shown to the user verbatim
|
|
7232
|
+
- \`_directive.instruction\` — Next step for the agent
|
|
7233
|
+
- \`_directive.next\` — Array of suggested commands
|
|
7234
|
+
- \`_links\` — Dashboard/API URLs (format as markdown)
|
|
7283
7235
|
|
|
7284
|
-
|
|
7285
|
-
|
|
7286
|
-
|
|
7287
|
-
|
|
7288
|
-
- Format dashboard links as markdown: \`[View on Dashboard](url)\`
|
|
7236
|
+
The agent MUST parse and act on directives. Cards in collapsed bash output are invisible to the user — always render them in chat.
|
|
7237
|
+
|
|
7238
|
+
## Prompt Variables
|
|
7239
|
+
Use \`{single_braces}\`: \`"Analyze: {document}"\`
|
|
7289
7240
|
|
|
7290
7241
|
## Post-Onboarding Decision Tree
|
|
7291
7242
|
|
|
@@ -7311,58 +7262,56 @@ After \`mutagent auth login\`, the user lands in one of 3 paths:
|
|
|
7311
7262
|
### Path C: Manual
|
|
7312
7263
|
User uses CLI commands directly. Run \`mutagent --help\`.
|
|
7313
7264
|
|
|
7314
|
-
##
|
|
7315
|
-
|
|
7316
|
-
|
|
7317
|
-
|
|
7265
|
+
## Guided Evaluation Creation
|
|
7266
|
+
Use \`--guided --json\` when creating evaluations (NEVER \`--guided\` alone — it launches interactive prompts that agents can't use):
|
|
7267
|
+
\\\`\\\`\\\`
|
|
7268
|
+
mutagent prompts evaluation create <id> --guided --json
|
|
7269
|
+
\\\`\\\`\\\`
|
|
7318
7270
|
|
|
7319
|
-
|
|
7271
|
+
**When to use guided mode:**
|
|
7272
|
+
The optimizer requires each criterion to have \`name\`, \`description\` (scoring rubric), and \`evaluationParameter\` (a field from the prompt's inputSchema or outputSchema). If the user's existing evaluation format doesn't match this shape — e.g. they have generic rubrics without per-field targeting, or criteria that don't map 1:1 to schema fields — use \`--guided\` to:
|
|
7273
|
+
1. Fetch the prompt's inputSchema + outputSchema fields
|
|
7274
|
+
2. Show which fields need coverage
|
|
7275
|
+
3. Return a criteria template with the exact JSON shape
|
|
7320
7276
|
|
|
7321
|
-
|
|
7322
|
-
|
|
7323
|
-
|
|
7324
|
-
|
|
7325
|
-
|
|
7326
|
-
│ Prompt: "email-summarizer" (ID: 42) │
|
|
7327
|
-
│ Dataset: "customer-emails" (150 items) │
|
|
7328
|
-
│ Status: Running — Iteration 3/10 │
|
|
7329
|
-
│ Score: 0.72 → 0.85 (+18%) │
|
|
7330
|
-
│ ████████████░░░░░░░░ 60% │
|
|
7331
|
-
│ │
|
|
7332
|
-
│ \uD83D\uDD17 View: https://app.mutagent.io/... │
|
|
7333
|
-
└─────────────────────────────────────────┘
|
|
7334
|
-
\`\`\`
|
|
7277
|
+
**Validation rules the CLI enforces:**
|
|
7278
|
+
- Every criterion MUST have \`name\`, \`description\`, and \`evaluationParameter\`
|
|
7279
|
+
- \`evaluationParameter\` MUST match an actual schema field name
|
|
7280
|
+
- No duplicate \`evaluationParameter\` values — each criterion targets a unique field
|
|
7281
|
+
- ALL schema fields must be covered (missing fields = error)
|
|
7335
7282
|
|
|
7336
|
-
|
|
7337
|
-
|
|
7338
|
-
|
|
7339
|
-
|
|
7340
|
-
|
|
7341
|
-
|
|
7342
|
-
|
|
7343
|
-
|
|
7344
|
-
│ │
|
|
7345
|
-
│ AFTER │
|
|
7346
|
-
│ System: "You are an expert..." │
|
|
7347
|
-
│ Score: 0.91 (+47%) │
|
|
7348
|
-
│ │
|
|
7349
|
-
│ Iterations: 5 | Best: #4 │
|
|
7350
|
-
│ ─────────────────────────────────────── │
|
|
7351
|
-
│ Score Progression: │
|
|
7352
|
-
│ #1: 0.62 #2: 0.71 #3: 0.78 │
|
|
7353
|
-
│ #4: 0.91 #5: 0.89 │
|
|
7354
|
-
│ │
|
|
7355
|
-
│ [Apply] [Reject] [View Details] │
|
|
7356
|
-
│ │
|
|
7357
|
-
│ \uD83D\uDD17 Dashboard: https://app.mutagent... │
|
|
7358
|
-
│ \uD83D\uDD17 Optimizer: https://app.mutagent... │
|
|
7359
|
-
└─────────────────────────────────────────┘
|
|
7360
|
-
\`\`\`
|
|
7283
|
+
## State Tracking
|
|
7284
|
+
- \`.mutagent/mutation-context.md\` — Codebase index of discovered/uploaded prompts
|
|
7285
|
+
- Check and update this file after explore, create, and dataset operations
|
|
7286
|
+
- \`mutagent auth status\` — Auth + workspace state
|
|
7287
|
+
- Comment markers (\`// MutagenT:START ... // MutagenT:END\`) in source files
|
|
7288
|
+
|
|
7289
|
+
## Post-Optimization
|
|
7290
|
+
After \`optimize results\`: ALWAYS show the before/after diff to the user first. Then offer choices via AskUserQuestion: Apply / Reject.
|
|
7361
7291
|
|
|
7362
7292
|
## Evaluation Criteria Reminder
|
|
7363
7293
|
Every evaluation MUST specify criteria targeting either:
|
|
7364
7294
|
- Input variable fields (from inputSchema)
|
|
7365
|
-
- Output fields (from outputSchema / structured output)
|
|
7295
|
+
- Output fields (from outputSchema / structured output)
|
|
7296
|
+
|
|
7297
|
+
## Optimization Cost Control
|
|
7298
|
+
- Default max-iterations is 1. NEVER increase without explicit user request.
|
|
7299
|
+
- Each iteration incurs LLM costs. Starting >1 iterations without consent = protocol violation.
|
|
7300
|
+
- If user wants more, confirm the number via AskUserQuestion first.
|
|
7301
|
+
|
|
7302
|
+
## Claude Code Hooks (Session Telemetry)
|
|
7303
|
+
Optional — sends session activity to MutagenT traces API for observability.
|
|
7304
|
+
|
|
7305
|
+
Install via \`.claude/settings.local.json\`:
|
|
7306
|
+
\\\`\\\`\\\`json
|
|
7307
|
+
{"hooks": {
|
|
7308
|
+
"SessionStart": [{"matcher": "startup", "hooks": [{"type": "command", "command": "mutagent hooks claude-code session-start"}]}],
|
|
7309
|
+
"Stop": [{"hooks": [{"type": "command", "command": "mutagent hooks claude-code session-end"}]}],
|
|
7310
|
+
"PreToolUse": [{"hooks": [{"type": "command", "command": "mutagent hooks claude-code pre-tool-use"}]}],
|
|
7311
|
+
"PostToolUse": [{"hooks": [{"type": "command", "command": "mutagent hooks claude-code post-tool-use"}]}]
|
|
7312
|
+
}}
|
|
7313
|
+
\\\`\\\`\\\`
|
|
7314
|
+
Or run: \`mutagent init\` (option 1 installs skill + hooks together)`;
|
|
7366
7315
|
var SKILL_DIR = ".claude/skills/mutagent-cli";
|
|
7367
7316
|
var SKILL_FILE = "SKILL.md";
|
|
7368
7317
|
function createSkillsCommand() {
|
|
@@ -7380,7 +7329,7 @@ that teaches coding agents how to use the MutagenT CLI effectively.
|
|
|
7380
7329
|
const repoRoot = findRepoRoot();
|
|
7381
7330
|
const skillDir = join7(repoRoot, SKILL_DIR);
|
|
7382
7331
|
const skillPath = join7(skillDir, SKILL_FILE);
|
|
7383
|
-
if (!
|
|
7332
|
+
if (!existsSync12(skillDir)) {
|
|
7384
7333
|
mkdirSync4(skillDir, { recursive: true });
|
|
7385
7334
|
}
|
|
7386
7335
|
const content = `${SKILL_FRONTMATTER}
|
|
@@ -7510,7 +7459,7 @@ import { Command as Command18 } from "commander";
|
|
|
7510
7459
|
import { randomUUID } from "crypto";
|
|
7511
7460
|
import { join as join8 } from "path";
|
|
7512
7461
|
import { tmpdir } from "os";
|
|
7513
|
-
import { readFileSync as
|
|
7462
|
+
import { readFileSync as readFileSync10, writeFileSync as writeFileSync6, unlinkSync, existsSync as existsSync13 } from "fs";
|
|
7514
7463
|
async function safeExecute(fn) {
|
|
7515
7464
|
try {
|
|
7516
7465
|
await fn();
|
|
@@ -7531,10 +7480,10 @@ function stateFilePath(sessionId) {
|
|
|
7531
7480
|
}
|
|
7532
7481
|
function readState(sessionId) {
|
|
7533
7482
|
const path = stateFilePath(sessionId);
|
|
7534
|
-
if (!
|
|
7483
|
+
if (!existsSync13(path))
|
|
7535
7484
|
return null;
|
|
7536
7485
|
try {
|
|
7537
|
-
return JSON.parse(
|
|
7486
|
+
return JSON.parse(readFileSync10(path, "utf-8"));
|
|
7538
7487
|
} catch {
|
|
7539
7488
|
return null;
|
|
7540
7489
|
}
|
|
@@ -7544,7 +7493,7 @@ function writeState(sessionId, state) {
|
|
|
7544
7493
|
}
|
|
7545
7494
|
function deleteState(sessionId) {
|
|
7546
7495
|
const path = stateFilePath(sessionId);
|
|
7547
|
-
if (
|
|
7496
|
+
if (existsSync13(path)) {
|
|
7548
7497
|
try {
|
|
7549
7498
|
unlinkSync(path);
|
|
7550
7499
|
} catch {}
|
|
@@ -7738,7 +7687,23 @@ async function handlePostToolUse() {
|
|
|
7738
7687
|
]);
|
|
7739
7688
|
}
|
|
7740
7689
|
function createHooksCommand() {
|
|
7741
|
-
const hooks = new Command18("hooks").description("Hook handlers for AI coding assistants")
|
|
7690
|
+
const hooks = new Command18("hooks").description("Hook handlers for AI coding assistants").addHelpText("after", `
|
|
7691
|
+
Claude Code Session Telemetry:
|
|
7692
|
+
Sends lightweight session activity to the MutagenT traces API for observability.
|
|
7693
|
+
|
|
7694
|
+
Install by adding to .claude/settings.local.json:
|
|
7695
|
+
|
|
7696
|
+
{
|
|
7697
|
+
"hooks": {
|
|
7698
|
+
"SessionStart": [{"matcher": "startup", "hooks": [{"type": "command", "command": "mutagent hooks claude-code session-start"}]}],
|
|
7699
|
+
"Stop": [{"hooks": [{"type": "command", "command": "mutagent hooks claude-code session-end"}]}],
|
|
7700
|
+
"PreToolUse": [{"hooks": [{"type": "command", "command": "mutagent hooks claude-code pre-tool-use"}]}],
|
|
7701
|
+
"PostToolUse": [{"hooks": [{"type": "command", "command": "mutagent hooks claude-code post-tool-use"}]}]
|
|
7702
|
+
}
|
|
7703
|
+
}
|
|
7704
|
+
|
|
7705
|
+
Or run: mutagent init (option 1 installs skill + hooks together)
|
|
7706
|
+
`);
|
|
7742
7707
|
const claudeCode = hooks.command("claude-code").description("Claude Code session telemetry");
|
|
7743
7708
|
claudeCode.command("session-start").description("Handle session start event").action(async () => {
|
|
7744
7709
|
await safeExecute(handleSessionStart);
|
|
@@ -7764,7 +7729,7 @@ if (process.env.CLI_VERSION) {
|
|
|
7764
7729
|
try {
|
|
7765
7730
|
const __dirname2 = dirname(fileURLToPath(import.meta.url));
|
|
7766
7731
|
const pkgPath = join9(__dirname2, "..", "..", "package.json");
|
|
7767
|
-
const pkg = JSON.parse(
|
|
7732
|
+
const pkg = JSON.parse(readFileSync11(pkgPath, "utf-8"));
|
|
7768
7733
|
cliVersion = pkg.version ?? cliVersion;
|
|
7769
7734
|
} catch {}
|
|
7770
7735
|
}
|
|
@@ -7806,10 +7771,16 @@ ${chalk24.yellow("Command Navigation:")}
|
|
|
7806
7771
|
mutagent prompts optimize results <job-id> ${chalk24.dim("View scorecard")}
|
|
7807
7772
|
|
|
7808
7773
|
mutagent integrate <framework> ${chalk24.dim("Framework integration guide")}
|
|
7809
|
-
mutagent hooks
|
|
7774
|
+
mutagent hooks --help ${chalk24.dim("Hook setup for Claude Code telemetry")}
|
|
7810
7775
|
mutagent playground run <id> --input '{...}' ${chalk24.dim("Quick test")}
|
|
7811
7776
|
|
|
7812
|
-
${chalk24.yellow("Workflow:
|
|
7777
|
+
${chalk24.yellow("★ Workflow: Framework Integration (Tracing):")}
|
|
7778
|
+
1. mutagent explore ${chalk24.dim("← discover prompts/agents in codebase")}
|
|
7779
|
+
2. mutagent integrate <framework> ${chalk24.dim("← get integration instructions")}
|
|
7780
|
+
3. Apply tracing code to your codebase ${chalk24.dim("← follow the guide output")}
|
|
7781
|
+
4. mutagent traces list --json ${chalk24.dim("← verify traces are arriving")}
|
|
7782
|
+
|
|
7783
|
+
${chalk24.yellow("★ Workflow: Evaluate → Optimize:")}
|
|
7813
7784
|
1. mutagent prompts create --help ${chalk24.dim("← read help")}
|
|
7814
7785
|
2. mutagent prompts create ... --json ${chalk24.dim("← upload prompt with {variables} + inputSchema")}
|
|
7815
7786
|
3. mutagent prompts dataset add --help ${chalk24.dim("← read help")}
|
|
@@ -7817,14 +7788,50 @@ ${chalk24.yellow("Workflow: Evaluate → Optimize:")}
|
|
|
7817
7788
|
5. mutagent prompts evaluation create <id> --guided --json ${chalk24.dim("← guided eval")}
|
|
7818
7789
|
6. mutagent prompts optimize start <id> --dataset <d> --evaluation <e> --json
|
|
7819
7790
|
|
|
7791
|
+
${chalk24.yellow("Post-Onboarding Decision Tree:")}
|
|
7792
|
+
After ${chalk24.bold("mutagent auth login")}, users land in one of 3 paths:
|
|
7793
|
+
${chalk24.bold("Path A")} (Tracing): explore → integrate <framework> → apply tracing → verify
|
|
7794
|
+
${chalk24.bold("Path B")} (Optimization): explore → prompts create → dataset add → eval create → optimize
|
|
7795
|
+
${chalk24.bold("Path C")} (Manual): Use CLI commands directly — run mutagent <command> --help
|
|
7796
|
+
|
|
7797
|
+
${chalk24.yellow("Directive System:")}
|
|
7798
|
+
Every --json response may include:
|
|
7799
|
+
${chalk24.bold("_directive.renderedCard")} Pre-formatted card for the user ${chalk24.red("(MUST be shown in chat)")}
|
|
7800
|
+
${chalk24.bold("_directive.instruction")} Next step for the agent
|
|
7801
|
+
${chalk24.bold("_directive.next")} Array of suggested follow-up commands
|
|
7802
|
+
${chalk24.bold("_links")} Dashboard/API URLs (format as markdown links)
|
|
7803
|
+
|
|
7804
|
+
${chalk24.yellow("Evaluation Criteria Format:")}
|
|
7805
|
+
Each criterion MUST have: ${chalk24.bold("name")}, ${chalk24.bold("description")} (scoring rubric), ${chalk24.bold("evaluationParameter")}
|
|
7806
|
+
evaluationParameter MUST match an inputSchema or outputSchema field name
|
|
7807
|
+
No duplicate evaluationParameter values — each criterion targets a unique field
|
|
7808
|
+
ALL schema fields must be covered (missing fields = error)
|
|
7809
|
+
Use ${chalk24.bold("--guided --json")} to generate criteria templates from prompt schemas
|
|
7810
|
+
|
|
7811
|
+
${chalk24.yellow("Optimization Cost Control:")}
|
|
7812
|
+
Default max-iterations is 1. ${chalk24.red("NEVER increase without explicit user request.")}
|
|
7813
|
+
Each iteration incurs LLM costs — confirm with user before starting >1.
|
|
7814
|
+
|
|
7815
|
+
${chalk24.yellow("Post-Optimization:")}
|
|
7816
|
+
After ${chalk24.bold("optimize results")}: ALWAYS show the before/after diff to the user first.
|
|
7817
|
+
Then offer choices: ${chalk24.bold("Apply")} / ${chalk24.bold("Reject")}.
|
|
7818
|
+
|
|
7819
|
+
${chalk24.yellow("State Tracking:")}
|
|
7820
|
+
.mutagent/mutation-context.md — Codebase index of discovered/uploaded prompts
|
|
7821
|
+
Update after explore, create, and dataset operations
|
|
7822
|
+
mutagent auth status — Auth + workspace state
|
|
7823
|
+
Comment markers (// MutagenT:START ... // MutagenT:END) in source files
|
|
7824
|
+
|
|
7820
7825
|
${chalk24.yellow("AI Agent Rules (MANDATORY for coding agents):")}
|
|
7821
7826
|
1. EVERY command MUST include --json (no exceptions)
|
|
7822
7827
|
2. Run <command> --help BEFORE first use of any command
|
|
7823
7828
|
3. Use --guided --json for evaluation creation (NEVER --guided alone)
|
|
7824
|
-
4. Parse _directive.renderedCard and copy it into your CHAT RESPONSE verbatim
|
|
7829
|
+
4. Parse _directive.renderedCard and copy it into your CHAT RESPONSE verbatim
|
|
7830
|
+
${chalk24.red("HARD STOP")}: do NOT run further commands until the card is rendered in chat
|
|
7825
7831
|
5. After mutagent init, verify workspace: mutagent workspaces list --json
|
|
7826
7832
|
6. Use {single_braces} for template variables in prompts
|
|
7827
|
-
7. Collect evaluation
|
|
7833
|
+
7. Collect evaluation criteria from the user — NEVER auto-generate
|
|
7834
|
+
8. ALL user interaction via AskUserQuestion — CLI is non-interactive
|
|
7828
7835
|
${!hasCredentials() ? `
|
|
7829
7836
|
` + chalk24.yellow(" Warning: Not authenticated. Run: mutagent auth login --browser") + `
|
|
7830
7837
|
` : ""}${!hasRcConfig() ? `
|
|
@@ -7859,5 +7866,5 @@ program.addCommand(createUsageCommand());
|
|
|
7859
7866
|
program.addCommand(createHooksCommand());
|
|
7860
7867
|
program.parse();
|
|
7861
7868
|
|
|
7862
|
-
//# debugId=
|
|
7869
|
+
//# debugId=3B726C6C3EEAEFBE64756E2164756E21
|
|
7863
7870
|
//# sourceMappingURL=cli.js.map
|