@mutagent/cli 0.1.86 → 0.1.88

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
@@ -3710,6 +3710,30 @@ import { Command as Command4 } from "commander";
3710
3710
  import chalk8 from "chalk";
3711
3711
  init_errors();
3712
3712
 
3713
+ // src/lib/resolve-prompt-id.ts
3714
+ async function resolveNumericPromptId(client, promptGroupId) {
3715
+ if (!promptGroupId)
3716
+ return null;
3717
+ let prompts;
3718
+ try {
3719
+ prompts = await client.listPrompts();
3720
+ } catch {
3721
+ return null;
3722
+ }
3723
+ const matches = prompts.filter((p) => p.promptGroupId === promptGroupId);
3724
+ if (matches.length === 0)
3725
+ return null;
3726
+ const latestFlagged = matches.find((p) => p.isLatest);
3727
+ if (latestFlagged)
3728
+ return latestFlagged.id;
3729
+ const sorted = [...matches].sort((a, b) => {
3730
+ const ta = a.updatedAt ? new Date(a.updatedAt).getTime() : 0;
3731
+ const tb = b.updatedAt ? new Date(b.updatedAt).getTime() : 0;
3732
+ return tb - ta;
3733
+ });
3734
+ return sorted[0]?.id ?? null;
3735
+ }
3736
+
3713
3737
  // src/commands/prompts/guided-workflow.ts
3714
3738
  init_sdk_client();
3715
3739
  async function buildGuidedWorkflow(promptId) {
@@ -3821,6 +3845,35 @@ async function buildGuidedWorkflow(promptId) {
3821
3845
  };
3822
3846
  }
3823
3847
 
3848
+ // src/lib/adapters/eval-criteria.ts
3849
+ function cliCriterionToCanonical(c) {
3850
+ return {
3851
+ criteria: c.description,
3852
+ evaluationParameter: c.evaluationParameter,
3853
+ name: c.name
3854
+ };
3855
+ }
3856
+ function canonicalCriterionToCli(c) {
3857
+ if (!c || typeof c !== "object") {
3858
+ return { name: undefined, description: "", evaluationParameter: "" };
3859
+ }
3860
+ return {
3861
+ name: c.name ?? c.id,
3862
+ description: c.criteria ?? c.description ?? "",
3863
+ evaluationParameter: c.evaluationParameter ?? c.parameter ?? ""
3864
+ };
3865
+ }
3866
+ function cliCriteriaArrayToCanonical(arr) {
3867
+ if (!Array.isArray(arr))
3868
+ return [];
3869
+ return arr.map(cliCriterionToCanonical);
3870
+ }
3871
+ function canonicalCriteriaArrayToCli(arr) {
3872
+ if (!Array.isArray(arr))
3873
+ return [];
3874
+ return arr.map(canonicalCriterionToCli);
3875
+ }
3876
+
3824
3877
  // src/commands/prompts/evaluations.ts
3825
3878
  function registerEvaluationCommands(prompts) {
3826
3879
  const evaluation = new Command4("evaluation").description("Manage evaluations for prompts").addHelpText("after", `
@@ -3876,10 +3929,16 @@ Examples:
3876
3929
  try {
3877
3930
  const client = await getSDKClient();
3878
3931
  const evalObj = await client.getEvaluation(evaluationId);
3932
+ const numericPromptId = await resolveNumericPromptId(client, evalObj.promptGroupId);
3933
+ if (numericPromptId === null) {
3934
+ if (process.env.DEBUG) {
3935
+ console.error(`[debug] Evaluation ${String(evalObj.id)} references promptGroupId ${evalObj.promptGroupId} but no prompts were found in that group. Falling back to prompts dashboard.`);
3936
+ }
3937
+ }
3879
3938
  if (isJson) {
3880
3939
  output.output({
3881
3940
  ...evalObj,
3882
- _links: evaluationLinks(evalObj.promptGroupId, evalObj.id)
3941
+ _links: numericPromptId !== null ? evaluationLinks(numericPromptId, evalObj.id) : { dashboard: promptsDashboardLink(), api: `/api/prompts/${evalObj.promptGroupId}/evaluations/${String(evalObj.id)}` }
3883
3942
  });
3884
3943
  } else {
3885
3944
  output.success(`Evaluation: ${evalObj.name} (ID: ${String(evalObj.id)})`);
@@ -3889,8 +3948,8 @@ Examples:
3889
3948
  console.log(` Created: ${evalObj.createdAt ? new Date(String(evalObj.createdAt)).toLocaleDateString() : "N/A"}`);
3890
3949
  console.log("");
3891
3950
  const config = evalObj.evalConfig;
3892
- const criteria = config?.criteria;
3893
- if (criteria && Array.isArray(criteria) && criteria.length > 0) {
3951
+ const criteria = canonicalCriteriaArrayToCli(config?.criteria);
3952
+ if (criteria.length > 0) {
3894
3953
  console.log(" Criteria:");
3895
3954
  for (const c of criteria) {
3896
3955
  console.log(` ${chalk8.cyan(c.name)}`);
@@ -3913,7 +3972,8 @@ Examples:
3913
3972
  }
3914
3973
  console.log("");
3915
3974
  }
3916
- output.info(`View in dashboard: ${evaluationLink(evalObj.promptGroupId, evalObj.id)}`);
3975
+ const dashboardUrl = numericPromptId !== null ? evaluationLink(numericPromptId, evalObj.id) : promptsDashboardLink();
3976
+ output.info(`View in dashboard: ${dashboardUrl}`);
3917
3977
  }
3918
3978
  } catch (error) {
3919
3979
  handleError(error, isJson);
@@ -4139,6 +4199,10 @@ Example:
4139
4199
  ` + "Run: mutagent prompts evaluation create " + promptId + " --guided --json");
4140
4200
  }
4141
4201
  }
4202
+ if (evalData.evalConfig && Array.isArray(evalData.evalConfig.criteria)) {
4203
+ const cliCriteria = evalData.evalConfig.criteria;
4204
+ evalData.evalConfig.criteria = cliCriteriaArrayToCanonical(cliCriteria);
4205
+ }
4142
4206
  const client = await getSDKClient();
4143
4207
  const evalResult = await client.createEvaluation(promptId, evalData);
4144
4208
  if (isJson) {
@@ -9125,5 +9189,5 @@ program.addCommand(createHooksCommand());
9125
9189
  program.addCommand(createFeedbackCommand());
9126
9190
  program.parse();
9127
9191
 
9128
- //# debugId=F2490C97DAE1166264756E2164756E21
9192
+ //# debugId=3313422F119EC74164756E2164756E21
9129
9193
  //# sourceMappingURL=cli.js.map