@mutagent/cli 0.1.17 → 0.1.18

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/bin/cli.js CHANGED
@@ -235,7 +235,7 @@ function handleError(error, isJson) {
235
235
  }
236
236
  const message = error instanceof Error ? error.message : "Unknown error";
237
237
  if (isJson) {
238
- console.log(JSON.stringify({ error: { code: "UNKNOWN_ERROR", message } }, null, 2));
238
+ console.log(JSON.stringify({ success: false, error: message, code: "UNKNOWN_ERROR" }, null, 2));
239
239
  } else {
240
240
  console.error(`Error: ${message}`);
241
241
  }
@@ -256,11 +256,10 @@ var init_errors = __esm(() => {
256
256
  }
257
257
  toJSON() {
258
258
  return {
259
- error: {
260
- code: this.code,
261
- message: this.message,
262
- suggestion: this.suggestion
263
- }
259
+ success: false,
260
+ error: this.message,
261
+ code: this.code,
262
+ suggestedAction: this.suggestion
264
263
  };
265
264
  }
266
265
  };
@@ -300,7 +299,7 @@ var init_errors = __esm(() => {
300
299
  `);
301
300
  WorkspaceContextError = class WorkspaceContextError extends MutagentError {
302
301
  constructor(message) {
303
- super("WORKSPACE_CONTEXT_MISSING", message ?? "Workspace context is required but not configured", "Run: mutagent config set workspace <workspace-id>", 3);
302
+ super("WORKSPACE_REQUIRED", message ?? "Workspace context is required but not configured", "Run: mutagent config set workspace <workspace-id>", 3);
304
303
  }
305
304
  };
306
305
  ValidationError = class ValidationError extends MutagentError {
@@ -1054,9 +1053,14 @@ ${String(data.length)} result(s)`));
1054
1053
  console.log(chalk.green(`✓ ${message}`));
1055
1054
  }
1056
1055
  }
1057
- error(message) {
1056
+ error(message, code, suggestedAction) {
1058
1057
  if (this.format === "json") {
1059
- console.log(JSON.stringify({ success: false, error: message }, null, 2));
1058
+ const result = { success: false, error: message };
1059
+ if (code)
1060
+ result.code = code;
1061
+ if (suggestedAction)
1062
+ result.suggestedAction = suggestedAction;
1063
+ console.log(JSON.stringify(result, null, 2));
1060
1064
  } else {
1061
1065
  console.log(chalk.red(`✗ ${message}`));
1062
1066
  }
@@ -3419,7 +3423,7 @@ ${chalk7.dim("Tip: Use --force to skip confirmation (required for non-interactiv
3419
3423
  const isJson = getJsonFlag(prompts);
3420
3424
  const output = new OutputFormatter(isJson ? "json" : "table");
3421
3425
  try {
3422
- if (!options.force && !isJson) {
3426
+ if (!options.force && !isJson && !process.env.MUTAGENT_NON_INTERACTIVE) {
3423
3427
  const inquirer3 = (await import("inquirer")).default;
3424
3428
  const answers = await inquirer3.prompt([{
3425
3429
  type: "confirm",
@@ -3433,8 +3437,24 @@ ${chalk7.dim("Tip: Use --force to skip confirmation (required for non-interactiv
3433
3437
  }
3434
3438
  }
3435
3439
  const client = getSDKClient();
3436
- await client.deletePrompt(id);
3437
- output.success(`Deleted prompt: ${id}`);
3440
+ try {
3441
+ await client.deletePrompt(id);
3442
+ } catch (deleteError) {
3443
+ if (deleteError instanceof ApiError && deleteError.statusCode === 404) {
3444
+ if (isJson) {
3445
+ output.output({ success: true, deletedId: id });
3446
+ } else {
3447
+ output.success(`Prompt ${id} already deleted (idempotent)`);
3448
+ }
3449
+ return;
3450
+ }
3451
+ throw deleteError;
3452
+ }
3453
+ if (isJson) {
3454
+ output.output({ success: true, deletedId: id });
3455
+ } else {
3456
+ output.success(`Deleted prompt: ${id}`);
3457
+ }
3438
3458
  } catch (error) {
3439
3459
  handleError(error, isJson);
3440
3460
  }
@@ -3576,17 +3596,47 @@ ${chalk7.dim("--file and -d are mutually exclusive.")}
3576
3596
  handleError(error, isJson);
3577
3597
  }
3578
3598
  });
3579
- dataset.command("remove").description("Remove 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>)").addHelpText("after", `
3599
+ dataset.command("remove").description("Remove 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", `
3580
3600
  Examples:
3581
3601
  ${chalk7.dim("$")} mutagent prompts dataset remove <prompt-id> <dataset-id>
3582
- ${chalk7.dim("$")} mutagent prompts dataset remove <prompt-id> <dataset-id> --json
3583
- `).action(async (promptId, datasetId) => {
3602
+ ${chalk7.dim("$")} mutagent prompts dataset remove <prompt-id> <dataset-id> --force
3603
+ ${chalk7.dim("$")} mutagent prompts dataset remove <prompt-id> <dataset-id> --force --json
3604
+ `).action(async (promptId, datasetId, options) => {
3584
3605
  const isJson = getJsonFlag(prompts);
3585
3606
  const output = new OutputFormatter(isJson ? "json" : "table");
3586
3607
  try {
3608
+ if (!options.force && !isJson && !process.env.MUTAGENT_NON_INTERACTIVE) {
3609
+ const inquirer3 = (await import("inquirer")).default;
3610
+ const answers = await inquirer3.prompt([{
3611
+ type: "confirm",
3612
+ name: "confirm",
3613
+ message: `Remove dataset ${datasetId} from prompt ${promptId}?`,
3614
+ default: false
3615
+ }]);
3616
+ if (!answers.confirm) {
3617
+ output.info("Cancelled");
3618
+ return;
3619
+ }
3620
+ }
3587
3621
  const client = getSDKClient();
3588
- await client.removeDataset(promptId, datasetId);
3589
- output.success(`Removed dataset ${datasetId} from prompt ${promptId}`);
3622
+ try {
3623
+ await client.removeDataset(promptId, datasetId);
3624
+ } catch (deleteError) {
3625
+ if (deleteError instanceof ApiError && deleteError.statusCode === 404) {
3626
+ if (isJson) {
3627
+ output.output({ success: true, deletedId: datasetId });
3628
+ } else {
3629
+ output.success(`Dataset ${datasetId} already removed (idempotent)`);
3630
+ }
3631
+ return;
3632
+ }
3633
+ throw deleteError;
3634
+ }
3635
+ if (isJson) {
3636
+ output.output({ success: true, deletedId: datasetId });
3637
+ } else {
3638
+ output.success(`Removed dataset ${datasetId} from prompt ${promptId}`);
3639
+ }
3590
3640
  } catch (error) {
3591
3641
  handleError(error, isJson);
3592
3642
  }
@@ -3847,18 +3897,44 @@ Examples:
3847
3897
  handleError(error, isJson);
3848
3898
  }
3849
3899
  });
3850
- evaluation.command("delete").description("Delete an evaluation").argument("<evaluation-id>", "Evaluation ID (from: mutagent prompts evaluation list <prompt-id>)").addHelpText("after", `
3900
+ 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", `
3851
3901
  Examples:
3852
3902
  ${chalk7.dim("$")} mutagent prompts evaluation delete <evaluation-id>
3853
- ${chalk7.dim("$")} mutagent prompts evaluation delete <evaluation-id> --json
3854
- `).action(async (evaluationId) => {
3903
+ ${chalk7.dim("$")} mutagent prompts evaluation delete <evaluation-id> --force
3904
+ ${chalk7.dim("$")} mutagent prompts evaluation delete <evaluation-id> --force --json
3905
+ `).action(async (evaluationId, options) => {
3855
3906
  const isJson = getJsonFlag(prompts);
3856
3907
  const output = new OutputFormatter(isJson ? "json" : "table");
3857
3908
  try {
3909
+ if (!options.force && !isJson && !process.env.MUTAGENT_NON_INTERACTIVE) {
3910
+ const inquirer3 = (await import("inquirer")).default;
3911
+ const answers = await inquirer3.prompt([{
3912
+ type: "confirm",
3913
+ name: "confirm",
3914
+ message: `Delete evaluation ${evaluationId}?`,
3915
+ default: false
3916
+ }]);
3917
+ if (!answers.confirm) {
3918
+ output.info("Cancelled");
3919
+ return;
3920
+ }
3921
+ }
3858
3922
  const client = getSDKClient();
3859
- await client.deleteEvaluation(evaluationId);
3923
+ try {
3924
+ await client.deleteEvaluation(evaluationId);
3925
+ } catch (deleteError) {
3926
+ if (deleteError instanceof ApiError && deleteError.statusCode === 404) {
3927
+ if (isJson) {
3928
+ output.output({ success: true, deletedId: evaluationId });
3929
+ } else {
3930
+ output.success(`Evaluation ${evaluationId} already deleted (idempotent)`);
3931
+ }
3932
+ return;
3933
+ }
3934
+ throw deleteError;
3935
+ }
3860
3936
  if (isJson) {
3861
- output.output({ success: true, message: "Evaluation deleted successfully", evaluationId });
3937
+ output.output({ success: true, deletedId: evaluationId });
3862
3938
  } else {
3863
3939
  output.success(`Evaluation ${evaluationId} deleted successfully`);
3864
3940
  }
@@ -4891,7 +4967,13 @@ It returns INSTRUCTIONS that AI agents execute - it does NOT auto-install packag
4891
4967
  if (options.output) {
4892
4968
  writeFileSync3(options.output, explorationInstructions);
4893
4969
  output.success(`Exploration instructions saved to ${options.output}`);
4894
- } else if (options.raw === true || isJson) {
4970
+ } else if (isJson) {
4971
+ output.output({
4972
+ type: "exploration",
4973
+ frameworks: Array.from(frameworkRegistry.keys()),
4974
+ instructions: explorationInstructions
4975
+ });
4976
+ } else if (options.raw === true) {
4895
4977
  process.stdout.write(explorationInstructions);
4896
4978
  } else {
4897
4979
  output.info("MutagenT Integration - Framework Detection");
@@ -4939,7 +5021,14 @@ AI AGENT: Execute these steps using Bash for install, Write/Edit for code change
4939
5021
  if (options.output) {
4940
5022
  writeFileSync3(options.output, instructions);
4941
5023
  output.success(`Integration instructions saved to ${options.output}`);
4942
- } else if (options.raw === true || isJson) {
5024
+ } else if (isJson) {
5025
+ output.output({
5026
+ framework: frameworkArg,
5027
+ displayName: meta?.displayName ?? frameworkArg,
5028
+ mutagentPackage: mutagentPackage ?? null,
5029
+ instructions
5030
+ });
5031
+ } else if (options.raw === true) {
4943
5032
  process.stdout.write(instructions);
4944
5033
  } else {
4945
5034
  const displayName = meta?.displayName ?? frameworkArg;
@@ -6789,5 +6878,5 @@ program.addCommand(createSkillsCommand());
6789
6878
  program.addCommand(createUsageCommand());
6790
6879
  program.parse();
6791
6880
 
6792
- //# debugId=88B4F3961CA6D43E64756E2164756E21
6881
+ //# debugId=F0BA27BEF939892164756E2164756E21
6793
6882
  //# sourceMappingURL=cli.js.map