@mutagent/cli 0.1.90 → 0.1.92
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 +131 -1
- package/dist/bin/cli.js.map +4 -4
- package/dist/index.js +15 -1
- package/dist/index.js.map +3 -3
- package/package.json +1 -1
package/dist/bin/cli.js
CHANGED
|
@@ -616,6 +616,20 @@ class SDKClientWrapper {
|
|
|
616
616
|
this.handleError(error);
|
|
617
617
|
}
|
|
618
618
|
}
|
|
619
|
+
async getDataset(datasetId) {
|
|
620
|
+
try {
|
|
621
|
+
return await this.request(`/api/prompts/datasets/${String(datasetId)}`);
|
|
622
|
+
} catch (error) {
|
|
623
|
+
this.handleError(error);
|
|
624
|
+
}
|
|
625
|
+
}
|
|
626
|
+
async getDatasetItem(itemId) {
|
|
627
|
+
try {
|
|
628
|
+
return await this.request(`/api/prompts/dataset-items/${String(itemId)}`);
|
|
629
|
+
} catch (error) {
|
|
630
|
+
this.handleError(error);
|
|
631
|
+
}
|
|
632
|
+
}
|
|
619
633
|
async listDatasets(promptId) {
|
|
620
634
|
try {
|
|
621
635
|
const response = await this.request(`/api/prompt/${promptId}/datasets`);
|
|
@@ -3443,8 +3457,10 @@ function registerDatasetCommands(prompts) {
|
|
|
3443
3457
|
const dataset = new Command3("dataset").description("Manage datasets for prompts").addHelpText("after", `
|
|
3444
3458
|
Examples:
|
|
3445
3459
|
${chalk8.dim("$")} mutagent prompts dataset list <prompt-id>
|
|
3460
|
+
${chalk8.dim("$")} mutagent prompts dataset get <dataset-id>
|
|
3446
3461
|
${chalk8.dim("$")} mutagent prompts dataset add <prompt-id> -d '[{"input":{...},"expectedOutput":{...}}]'
|
|
3447
3462
|
${chalk8.dim("$")} mutagent prompts dataset delete <prompt-id> <dataset-id>
|
|
3463
|
+
${chalk8.dim("$")} mutagent prompts dataset items get <item-id>
|
|
3448
3464
|
`).action(() => {
|
|
3449
3465
|
dataset.help();
|
|
3450
3466
|
});
|
|
@@ -3482,6 +3498,60 @@ Examples:
|
|
|
3482
3498
|
handleError(error, isJson);
|
|
3483
3499
|
}
|
|
3484
3500
|
});
|
|
3501
|
+
dataset.command("get").description("Get full details of a single dataset").argument("<dataset-id>", "Dataset ID (from: mutagent prompts dataset list <prompt-id>)").addHelpText("after", `
|
|
3502
|
+
Examples:
|
|
3503
|
+
${chalk8.dim("$")} mutagent prompts dataset get <dataset-id>
|
|
3504
|
+
${chalk8.dim("$")} mutagent prompts dataset get <dataset-id> --json
|
|
3505
|
+
|
|
3506
|
+
${chalk8.dim("Tip: Use this after `dataset list` to drill into a single dataset.")}
|
|
3507
|
+
`).action(async (datasetId) => {
|
|
3508
|
+
const isJson = getJsonFlag(prompts);
|
|
3509
|
+
const output = new OutputFormatter(isJson ? "json" : "table");
|
|
3510
|
+
try {
|
|
3511
|
+
if (!/^\d+$/.test(datasetId)) {
|
|
3512
|
+
throw new MutagentError("INVALID_ARGUMENT", `Invalid dataset ID: "${datasetId}" (must be numeric)`, `Run: mutagent prompts dataset list <prompt-id>
|
|
3513
|
+
Dataset IDs are numeric. Example: mutagent prompts dataset get 42`);
|
|
3514
|
+
}
|
|
3515
|
+
const client = await getSDKClient();
|
|
3516
|
+
const ds = await client.getDataset(datasetId);
|
|
3517
|
+
const promptGroupId = ds.promptGroupId;
|
|
3518
|
+
if (isJson) {
|
|
3519
|
+
output.output({
|
|
3520
|
+
...ds,
|
|
3521
|
+
_links: datasetLinks(promptGroupId, ds.id)
|
|
3522
|
+
});
|
|
3523
|
+
} else {
|
|
3524
|
+
output.success(`Dataset: ${ds.name} (id: ${String(ds.id)})`);
|
|
3525
|
+
if (ds.description)
|
|
3526
|
+
output.info(`Description: ${ds.description}`);
|
|
3527
|
+
if (ds.itemCount !== undefined)
|
|
3528
|
+
output.info(`Items: ${String(ds.itemCount)}`);
|
|
3529
|
+
if (ds.updatedAt)
|
|
3530
|
+
output.info(`Updated: ${new Date(String(ds.updatedAt)).toLocaleString()}`);
|
|
3531
|
+
if (ds.createdAt)
|
|
3532
|
+
output.info(`Created: ${new Date(String(ds.createdAt)).toLocaleString()}`);
|
|
3533
|
+
if (ds.createdBy)
|
|
3534
|
+
output.info(`Created by: ${ds.createdBy}`);
|
|
3535
|
+
if (ds.labels && ds.labels.length > 0)
|
|
3536
|
+
output.info(`Labels: ${ds.labels.join(", ")}`);
|
|
3537
|
+
const hints = formatCreationHints({
|
|
3538
|
+
resourceType: "Dataset",
|
|
3539
|
+
id: ds.id,
|
|
3540
|
+
name: ds.name,
|
|
3541
|
+
dashboardUrl: datasetLink(promptGroupId, ds.id),
|
|
3542
|
+
apiPath: `/api/prompts/datasets/${String(ds.id)}`
|
|
3543
|
+
});
|
|
3544
|
+
console.log(hints);
|
|
3545
|
+
}
|
|
3546
|
+
} catch (error) {
|
|
3547
|
+
if (error instanceof ApiError && error.statusCode === 404) {
|
|
3548
|
+
handleError(new MutagentError("NOT_FOUND", `Dataset ${datasetId} not found`, `Run: mutagent prompts dataset list <prompt-id>
|
|
3549
|
+
Verify the dataset ID exists, or list datasets for a prompt to find valid IDs.`), isJson);
|
|
3550
|
+
} else {
|
|
3551
|
+
handleError(error, isJson);
|
|
3552
|
+
}
|
|
3553
|
+
}
|
|
3554
|
+
});
|
|
3485
3555
|
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", `
|
|
3486
3556
|
Examples:
|
|
3487
3557
|
${chalk8.dim("$")} mutagent prompts dataset add <prompt-id> -d '[{"input":{"text":"hello"},"expectedOutput":{"result":"world"}}]'
|
|
@@ -3612,6 +3682,66 @@ Examples:
|
|
|
3612
3682
|
handleError(error, isJson);
|
|
3613
3683
|
}
|
|
3614
3684
|
});
|
|
3685
|
+
const items = new Command3("items").description("Manage individual dataset items").addHelpText("after", `
|
|
3686
|
+
Examples:
|
|
3687
|
+
${chalk8.dim("$")} mutagent prompts dataset items get <item-id>
|
|
3688
|
+
${chalk8.dim("$")} mutagent prompts dataset items get <item-id> --json
|
|
3689
|
+
`).action(() => {
|
|
3690
|
+
items.help();
|
|
3691
|
+
});
|
|
3692
|
+
dataset.addCommand(items);
|
|
3693
|
+
items.command("get").description("Get full details of a single dataset item").argument("<item-id>", "Dataset item ID").addHelpText("after", `
|
|
3694
|
+
Examples:
|
|
3695
|
+
${chalk8.dim("$")} mutagent prompts dataset items get <item-id>
|
|
3696
|
+
${chalk8.dim("$")} mutagent prompts dataset items get <item-id> --json
|
|
3697
|
+
|
|
3698
|
+
${chalk8.dim("Tip: Dataset item IDs are shown in dataset exports and optimization results.")}
|
|
3699
|
+
`).action(async (itemId) => {
|
|
3700
|
+
const isJson = getJsonFlag(prompts);
|
|
3701
|
+
const output = new OutputFormatter(isJson ? "json" : "table");
|
|
3702
|
+
try {
|
|
3703
|
+
if (!/^\d+$/.test(itemId)) {
|
|
3704
|
+
throw new MutagentError("INVALID_ARGUMENT", `Invalid dataset item ID: "${itemId}" (must be numeric)`, `Run: mutagent prompts dataset items get --help
|
|
3705
|
+
Dataset item IDs are numeric. Example: mutagent prompts dataset items get 17`);
|
|
3706
|
+
}
|
|
3707
|
+
const client = await getSDKClient();
|
|
3708
|
+
const item = await client.getDatasetItem(itemId);
|
|
3709
|
+
const itemWithDs = item;
|
|
3710
|
+
const dsId = itemWithDs.datasetId;
|
|
3711
|
+
if (isJson) {
|
|
3712
|
+
output.output({
|
|
3713
|
+
...item,
|
|
3714
|
+
_links: {
|
|
3715
|
+
api: `/api/prompts/dataset-items/${String(item.id)}`,
|
|
3716
|
+
...dsId !== undefined ? { dataset: `/api/prompts/datasets/${String(dsId)}` } : {}
|
|
3717
|
+
}
|
|
3718
|
+
});
|
|
3719
|
+
} else {
|
|
3720
|
+
output.success(`Dataset Item: ${String(item.id)}`);
|
|
3721
|
+
if (dsId !== undefined)
|
|
3722
|
+
output.info(`Dataset ID: ${String(dsId)}`);
|
|
3723
|
+
output.info(`Input: ${JSON.stringify(item.input, null, 2)}`);
|
|
3724
|
+
if (item.expectedOutput !== undefined) {
|
|
3725
|
+
output.info(`Expected output: ${typeof item.expectedOutput === "string" ? item.expectedOutput : JSON.stringify(item.expectedOutput, null, 2)}`);
|
|
3726
|
+
}
|
|
3727
|
+
if (item.metadata && Object.keys(item.metadata).length > 0) {
|
|
3728
|
+
output.info(`Metadata: ${JSON.stringify(item.metadata)}`);
|
|
3729
|
+
}
|
|
3730
|
+
if (item.createdAt)
|
|
3731
|
+
output.info(`Created: ${new Date(String(item.createdAt)).toLocaleString()}`);
|
|
3732
|
+
const itemWithUpdated = item;
|
|
3733
|
+
if (itemWithUpdated.updatedAt)
|
|
3734
|
+
output.info(`Updated: ${new Date(String(itemWithUpdated.updatedAt)).toLocaleString()}`);
|
|
3735
|
+
}
|
|
3736
|
+
} catch (error) {
|
|
3737
|
+
if (error instanceof ApiError && error.statusCode === 404) {
|
|
3738
|
+
handleError(new MutagentError("NOT_FOUND", `Dataset item ${itemId} not found`, `Run: mutagent prompts dataset items get --help
|
|
3739
|
+
Verify the item ID exists. Use the dashboard or dataset exports to find valid item IDs.`), isJson);
|
|
3740
|
+
} else {
|
|
3741
|
+
handleError(error, isJson);
|
|
3742
|
+
}
|
|
3743
|
+
}
|
|
3744
|
+
});
|
|
3615
3745
|
}
|
|
3616
3746
|
|
|
3617
3747
|
// src/commands/prompts/evaluations.ts
|
|
@@ -9105,5 +9235,5 @@ program.addCommand(createHooksCommand());
|
|
|
9105
9235
|
program.addCommand(createFeedbackCommand());
|
|
9106
9236
|
program.parse();
|
|
9107
9237
|
|
|
9108
|
-
//# debugId=
|
|
9238
|
+
//# debugId=A84DFC92DB1ED69764756E2164756E21
|
|
9109
9239
|
//# sourceMappingURL=cli.js.map
|