@mutagent/cli 0.1.72 → 0.1.73
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 +28 -4
- package/dist/bin/cli.js.map +5 -5
- package/dist/index.js +13 -3
- package/dist/index.js.map +3 -3
- package/package.json +1 -1
package/dist/bin/cli.js
CHANGED
|
@@ -1001,7 +1001,11 @@ class SDKClientWrapper {
|
|
|
1001
1001
|
if (this.organizationId && this.workspaceId)
|
|
1002
1002
|
return;
|
|
1003
1003
|
if (!this.organizationId) {
|
|
1004
|
-
|
|
1004
|
+
let orgs = await fetchOrganizations(this.apiKey, this.endpoint).catch(() => []);
|
|
1005
|
+
if (orgs.length === 0) {
|
|
1006
|
+
await new Promise((r) => setTimeout(r, 1000));
|
|
1007
|
+
orgs = await fetchOrganizations(this.apiKey, this.endpoint).catch(() => []);
|
|
1008
|
+
}
|
|
1005
1009
|
if (orgs.length > 0 && orgs[0]) {
|
|
1006
1010
|
this.organizationId = orgs[0].id;
|
|
1007
1011
|
}
|
|
@@ -1081,7 +1085,13 @@ async function getSDKClient() {
|
|
|
1081
1085
|
workspaceId: config.defaultWorkspace,
|
|
1082
1086
|
organizationId: config.defaultOrganization
|
|
1083
1087
|
});
|
|
1084
|
-
await sdkClient.ensureContext().catch(() => {
|
|
1088
|
+
await sdkClient.ensureContext().catch((err) => {
|
|
1089
|
+
if (process.env.MUTAGENT_DEBUG) {
|
|
1090
|
+
const message = err instanceof Error ? err.message : String(err);
|
|
1091
|
+
process.stderr.write(`[mutagent] Context resolution failed: ${message}
|
|
1092
|
+
`);
|
|
1093
|
+
}
|
|
1094
|
+
});
|
|
1085
1095
|
}
|
|
1086
1096
|
return sdkClient;
|
|
1087
1097
|
}
|
|
@@ -6876,6 +6886,7 @@ init_config();
|
|
|
6876
6886
|
import { Command as Command10 } from "commander";
|
|
6877
6887
|
import chalk19 from "chalk";
|
|
6878
6888
|
init_errors();
|
|
6889
|
+
init_sdk_client();
|
|
6879
6890
|
var VALID_CONFIG_KEYS = ["apiKey", "endpoint", "format", "timeout", "defaultWorkspace", "defaultOrganization"];
|
|
6880
6891
|
function createConfigCommand() {
|
|
6881
6892
|
const config = new Command10("config").description("Manage CLI configuration").addHelpText("after", `
|
|
@@ -6939,6 +6950,7 @@ ${chalk19.dim("Persists workspace ID so you don't need to pass headers on every
|
|
|
6939
6950
|
const isJson = getJsonFlag(config);
|
|
6940
6951
|
const output = new OutputFormatter(isJson ? "json" : "table");
|
|
6941
6952
|
setDefaultWorkspace(id);
|
|
6953
|
+
resetSDKClient();
|
|
6942
6954
|
if (isJson) {
|
|
6943
6955
|
output.output({ success: true, defaultWorkspace: id });
|
|
6944
6956
|
} else {
|
|
@@ -6954,6 +6966,7 @@ ${chalk19.dim("Persists organization ID for org-scoped API keys.")}
|
|
|
6954
6966
|
const isJson = getJsonFlag(config);
|
|
6955
6967
|
const output = new OutputFormatter(isJson ? "json" : "table");
|
|
6956
6968
|
setDefaultOrganization(id);
|
|
6969
|
+
resetSDKClient();
|
|
6957
6970
|
if (isJson) {
|
|
6958
6971
|
output.output({ success: true, defaultOrganization: id });
|
|
6959
6972
|
} else {
|
|
@@ -8957,7 +8970,7 @@ var program = new Command20;
|
|
|
8957
8970
|
program.name("mutagent").description(`MutagenT CLI - AI-native prompt optimization platform
|
|
8958
8971
|
|
|
8959
8972
|
Documentation: https://docs.mutagent.io/cli
|
|
8960
|
-
Dashboard: https://app.mutagent.io`).
|
|
8973
|
+
Dashboard: https://app.mutagent.io`).option("-v, --version", "Display the version number").option("--json", "Output results as JSON (for AI agents)").option("--api-key <key>", "MutagenT API key").option("--endpoint <url>", "MutagenT server endpoint").option("--non-interactive", "Disable interactive prompts (for CI/AI agents)").configureHelp({
|
|
8961
8974
|
sortSubcommands: true,
|
|
8962
8975
|
showGlobalOptions: true
|
|
8963
8976
|
});
|
|
@@ -9060,6 +9073,17 @@ ${!hasCredentials() ? `
|
|
|
9060
9073
|
` : ""}${!hasRcConfig() ? `
|
|
9061
9074
|
` + chalk31.green(" Get started: mutagent init") + `
|
|
9062
9075
|
` : ""}`);
|
|
9076
|
+
program.hook("preAction", (thisCommand) => {
|
|
9077
|
+
const opts = thisCommand.optsWithGlobals();
|
|
9078
|
+
if (opts.version) {
|
|
9079
|
+
if (opts.json) {
|
|
9080
|
+
console.log(JSON.stringify({ version: cliVersion }));
|
|
9081
|
+
} else {
|
|
9082
|
+
console.log(cliVersion);
|
|
9083
|
+
}
|
|
9084
|
+
process.exit(0);
|
|
9085
|
+
}
|
|
9086
|
+
});
|
|
9063
9087
|
program.hook("preAction", (thisCommand) => {
|
|
9064
9088
|
const globalOpts = thisCommand.optsWithGlobals();
|
|
9065
9089
|
if (globalOpts.apiKey && !process.env.MUTAGENT_API_KEY) {
|
|
@@ -9090,5 +9114,5 @@ program.addCommand(createHooksCommand());
|
|
|
9090
9114
|
program.addCommand(createFeedbackCommand());
|
|
9091
9115
|
program.parse();
|
|
9092
9116
|
|
|
9093
|
-
//# debugId=
|
|
9117
|
+
//# debugId=7EC4737925B3BC4B64756E2164756E21
|
|
9094
9118
|
//# sourceMappingURL=cli.js.map
|