@mutagent/cli 0.1.41 → 0.1.42
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/bin/cli.js +91 -143
- package/dist/bin/cli.js.map +4 -4
- 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() {
|
|
@@ -7380,7 +7328,7 @@ that teaches coding agents how to use the MutagenT CLI effectively.
|
|
|
7380
7328
|
const repoRoot = findRepoRoot();
|
|
7381
7329
|
const skillDir = join7(repoRoot, SKILL_DIR);
|
|
7382
7330
|
const skillPath = join7(skillDir, SKILL_FILE);
|
|
7383
|
-
if (!
|
|
7331
|
+
if (!existsSync12(skillDir)) {
|
|
7384
7332
|
mkdirSync4(skillDir, { recursive: true });
|
|
7385
7333
|
}
|
|
7386
7334
|
const content = `${SKILL_FRONTMATTER}
|
|
@@ -7510,7 +7458,7 @@ import { Command as Command18 } from "commander";
|
|
|
7510
7458
|
import { randomUUID } from "crypto";
|
|
7511
7459
|
import { join as join8 } from "path";
|
|
7512
7460
|
import { tmpdir } from "os";
|
|
7513
|
-
import { readFileSync as
|
|
7461
|
+
import { readFileSync as readFileSync10, writeFileSync as writeFileSync6, unlinkSync, existsSync as existsSync13 } from "fs";
|
|
7514
7462
|
async function safeExecute(fn) {
|
|
7515
7463
|
try {
|
|
7516
7464
|
await fn();
|
|
@@ -7531,10 +7479,10 @@ function stateFilePath(sessionId) {
|
|
|
7531
7479
|
}
|
|
7532
7480
|
function readState(sessionId) {
|
|
7533
7481
|
const path = stateFilePath(sessionId);
|
|
7534
|
-
if (!
|
|
7482
|
+
if (!existsSync13(path))
|
|
7535
7483
|
return null;
|
|
7536
7484
|
try {
|
|
7537
|
-
return JSON.parse(
|
|
7485
|
+
return JSON.parse(readFileSync10(path, "utf-8"));
|
|
7538
7486
|
} catch {
|
|
7539
7487
|
return null;
|
|
7540
7488
|
}
|
|
@@ -7544,7 +7492,7 @@ function writeState(sessionId, state) {
|
|
|
7544
7492
|
}
|
|
7545
7493
|
function deleteState(sessionId) {
|
|
7546
7494
|
const path = stateFilePath(sessionId);
|
|
7547
|
-
if (
|
|
7495
|
+
if (existsSync13(path)) {
|
|
7548
7496
|
try {
|
|
7549
7497
|
unlinkSync(path);
|
|
7550
7498
|
} catch {}
|
|
@@ -7764,7 +7712,7 @@ if (process.env.CLI_VERSION) {
|
|
|
7764
7712
|
try {
|
|
7765
7713
|
const __dirname2 = dirname(fileURLToPath(import.meta.url));
|
|
7766
7714
|
const pkgPath = join9(__dirname2, "..", "..", "package.json");
|
|
7767
|
-
const pkg = JSON.parse(
|
|
7715
|
+
const pkg = JSON.parse(readFileSync11(pkgPath, "utf-8"));
|
|
7768
7716
|
cliVersion = pkg.version ?? cliVersion;
|
|
7769
7717
|
} catch {}
|
|
7770
7718
|
}
|
|
@@ -7859,5 +7807,5 @@ program.addCommand(createUsageCommand());
|
|
|
7859
7807
|
program.addCommand(createHooksCommand());
|
|
7860
7808
|
program.parse();
|
|
7861
7809
|
|
|
7862
|
-
//# debugId=
|
|
7810
|
+
//# debugId=167F4784D8F12D3E64756E2164756E21
|
|
7863
7811
|
//# sourceMappingURL=cli.js.map
|