@mutagent/cli 0.1.58 → 0.1.60

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
@@ -1105,11 +1105,11 @@ var init_sdk_client = __esm(() => {
1105
1105
  });
1106
1106
 
1107
1107
  // src/bin/cli.ts
1108
- import { Command as Command19 } from "commander";
1109
- import chalk30 from "chalk";
1110
- import { readFileSync as readFileSync11 } from "fs";
1111
- import { join as join9, dirname } from "path";
1112
- import { fileURLToPath } from "url";
1108
+ import { Command as Command20 } from "commander";
1109
+ import chalk31 from "chalk";
1110
+ import { readFileSync as readFileSync12 } from "fs";
1111
+ import { join as join10, dirname as dirname2 } from "path";
1112
+ import { fileURLToPath as fileURLToPath2 } from "url";
1113
1113
 
1114
1114
  // src/commands/auth.ts
1115
1115
  init_config();
@@ -8742,6 +8742,139 @@ Claude Code Session Telemetry:
8742
8742
  return hooks;
8743
8743
  }
8744
8744
 
8745
+ // src/commands/feedback.ts
8746
+ import { Command as Command19 } from "commander";
8747
+ import chalk30 from "chalk";
8748
+ init_errors();
8749
+ init_config();
8750
+ import { readFileSync as readFileSync11 } from "fs";
8751
+ import { join as join9, dirname } from "path";
8752
+ import { fileURLToPath } from "url";
8753
+ var VALID_CATEGORIES = ["bug", "feature", "improvement", "praise"];
8754
+ function getCliVersion() {
8755
+ if (process.env.CLI_VERSION) {
8756
+ return process.env.CLI_VERSION;
8757
+ }
8758
+ try {
8759
+ const __dirname2 = dirname(fileURLToPath(import.meta.url));
8760
+ const pkgPath = join9(__dirname2, "..", "..", "package.json");
8761
+ const pkg = JSON.parse(readFileSync11(pkgPath, "utf-8"));
8762
+ return pkg.version ?? "0.1.1";
8763
+ } catch {
8764
+ return "0.1.1";
8765
+ }
8766
+ }
8767
+ async function postToServer(payload, endpoint, apiKey, workspaceId, organizationId) {
8768
+ const headers = {
8769
+ "Content-Type": "application/json",
8770
+ "x-api-key": apiKey
8771
+ };
8772
+ if (workspaceId)
8773
+ headers["x-workspace-id"] = workspaceId;
8774
+ if (organizationId)
8775
+ headers["x-organization-id"] = organizationId;
8776
+ let response;
8777
+ try {
8778
+ response = await fetch(`${endpoint}/api/feedback`, {
8779
+ method: "POST",
8780
+ headers,
8781
+ body: JSON.stringify(payload)
8782
+ });
8783
+ } catch {
8784
+ throw new MutagentError("SERVER_UNAVAILABLE", "Server unavailable. Try again later.", "Check your network connection or verify the server endpoint with: mutagent config show");
8785
+ }
8786
+ if (response.ok) {
8787
+ return await response.json();
8788
+ }
8789
+ let errorMessage = `Server returned ${String(response.status)}`;
8790
+ try {
8791
+ const body = await response.json();
8792
+ errorMessage = body.message ?? body.error ?? errorMessage;
8793
+ } catch {}
8794
+ if (response.status === 401) {
8795
+ throw new MutagentError("AUTH_REQUIRED", errorMessage, "Authenticate first: mutagent auth login");
8796
+ }
8797
+ throw new MutagentError("API_ERROR", errorMessage, `Server responded with status ${String(response.status)}. Check your configuration with: mutagent config show`);
8798
+ }
8799
+ function createFeedbackCommand() {
8800
+ const feedback = new Command19("feedback").description("Send product feedback to MutagenT").addHelpText("after", `
8801
+ ${chalk30.bold("Examples:")}
8802
+ ${chalk30.cyan('mutagent feedback send -m "Great optimization results!"')}
8803
+ ${chalk30.cyan('mutagent feedback send -m "CLI crashed on export" --category bug')}
8804
+ ${chalk30.cyan('mutagent feedback send -m "Need batch operations" --category feature --json')}
8805
+
8806
+ ${chalk30.yellow("AI Agent (MANDATORY):")}
8807
+ ALWAYS use --json: mutagent feedback send -m "..." --category improvement --json
8808
+ Use this command to report bugs, request features, or share UX feedback.
8809
+ `).action(() => {
8810
+ feedback.help();
8811
+ });
8812
+ registerFeedbackSend(feedback);
8813
+ return feedback;
8814
+ }
8815
+ function registerFeedbackSend(feedback) {
8816
+ feedback.command("send").description("Send feedback about the MutagenT platform").requiredOption("-m, --message <text>", "Feedback message").option("--category <type>", `Feedback category: ${VALID_CATEGORIES.join(", ")}`, "improvement").option("--session <id>", "Link feedback to a specific session").addHelpText("after", `
8817
+ ${chalk30.bold("Examples:")}
8818
+ ${chalk30.dim("$")} mutagent feedback send -m "The optimization UX could show progress better"
8819
+ ${chalk30.dim("$")} mutagent feedback send -m "CLI errored on traces export" --category bug
8820
+ ${chalk30.dim("$")} mutagent feedback send -m "Love the guided eval!" --category praise --json
8821
+
8822
+ ${chalk30.bold("Categories:")}
8823
+ ${chalk30.bold("bug")} Something is broken or not working as expected
8824
+ ${chalk30.bold("feature")} Request a new capability
8825
+ ${chalk30.bold("improvement")} Suggest a UX or workflow enhancement (default)
8826
+ ${chalk30.bold("praise")} Share what you love about the platform
8827
+
8828
+ ${chalk30.yellow("AI Agent (MANDATORY):")}
8829
+ ALWAYS use --json: mutagent feedback send -m "..." --json
8830
+ Auto-captured context (CLI version, platform, node version) is included automatically.
8831
+ `).action(async (options) => {
8832
+ const isJson = getJsonFlag(feedback);
8833
+ const output = new OutputFormatter(isJson ? "json" : "table");
8834
+ try {
8835
+ if (!VALID_CATEGORIES.includes(options.category)) {
8836
+ throw new MutagentError("INVALID_ARGUMENTS", `Invalid category: "${options.category}". Must be one of: ${VALID_CATEGORIES.join(", ")}`, `Run: mutagent feedback send --help
8837
+ Valid categories: ${VALID_CATEGORIES.join(", ")}`);
8838
+ }
8839
+ const apiKey = getApiKey();
8840
+ if (!apiKey) {
8841
+ throw new MutagentError("AUTH_REQUIRED", "Authentication required to send feedback.", `Authenticate first: mutagent auth login
8842
+ Or set an API key: mutagent config set apiKey <key>`);
8843
+ }
8844
+ const config = loadConfig();
8845
+ const payload = {
8846
+ message: options.message,
8847
+ category: options.category,
8848
+ sessionId: options.session,
8849
+ context: {
8850
+ cliVersion: getCliVersion(),
8851
+ platform: process.platform,
8852
+ nodeVersion: process.version,
8853
+ workspaceId: config.defaultWorkspace,
8854
+ timestamp: new Date().toISOString()
8855
+ }
8856
+ };
8857
+ const endpoint = config.endpoint ?? "https://api.mutagent.io";
8858
+ const result = await postToServer(payload, endpoint, apiKey, config.defaultWorkspace, config.defaultOrganization);
8859
+ if (isJson) {
8860
+ output.output({
8861
+ success: true,
8862
+ id: result.id,
8863
+ category: options.category,
8864
+ message: options.message,
8865
+ _links: {
8866
+ send: 'mutagent feedback send -m "..." [--category bug|feature|improvement|praise]'
8867
+ }
8868
+ });
8869
+ } else {
8870
+ output.success(`Feedback sent! (${options.category})`);
8871
+ }
8872
+ } catch (error) {
8873
+ handleError(error, isJson);
8874
+ }
8875
+ });
8876
+ }
8877
+
8745
8878
  // src/bin/cli.ts
8746
8879
  init_config();
8747
8880
  var cliVersion = "0.1.1";
@@ -8749,13 +8882,13 @@ if (process.env.CLI_VERSION) {
8749
8882
  cliVersion = process.env.CLI_VERSION;
8750
8883
  } else {
8751
8884
  try {
8752
- const __dirname2 = dirname(fileURLToPath(import.meta.url));
8753
- const pkgPath = join9(__dirname2, "..", "..", "package.json");
8754
- const pkg = JSON.parse(readFileSync11(pkgPath, "utf-8"));
8885
+ const __dirname2 = dirname2(fileURLToPath2(import.meta.url));
8886
+ const pkgPath = join10(__dirname2, "..", "..", "package.json");
8887
+ const pkg = JSON.parse(readFileSync12(pkgPath, "utf-8"));
8755
8888
  cliVersion = pkg.version ?? cliVersion;
8756
8889
  } catch {}
8757
8890
  }
8758
- var program = new Command19;
8891
+ var program = new Command20;
8759
8892
  program.name("mutagent").description(`MutagenT CLI - AI-native prompt optimization platform
8760
8893
 
8761
8894
  Documentation: https://docs.mutagent.io/cli
@@ -8764,100 +8897,103 @@ program.name("mutagent").description(`MutagenT CLI - AI-native prompt optimizati
8764
8897
  showGlobalOptions: true
8765
8898
  });
8766
8899
  program.addHelpText("after", `
8767
- ${chalk30.yellow("Non-Interactive Mode (CI/CD & Coding Agents):")}
8768
- export MUTAGENT_API_KEY=mt_... ${chalk30.dim("or")} --api-key mt_...
8769
- --json ${chalk30.dim("for structured output")} --non-interactive ${chalk30.dim("to disable prompts")}
8770
-
8771
- ${chalk30.yellow("Command Navigation:")}
8772
- mutagent auth login --browser ${chalk30.dim("Authenticate (OAuth)")}
8773
- mutagent auth status ${chalk30.dim("Check auth + workspace")}
8774
- mutagent init ${chalk30.dim("Initialize project (.mutagentrc.json)")}
8775
- mutagent explore ${chalk30.dim("Discover prompts in codebase")}
8776
- mutagent workspaces list --json ${chalk30.dim("List workspaces (verify ID)")}
8777
- mutagent config set workspace <id> ${chalk30.dim("Set active workspace")}
8778
- mutagent usage --json ${chalk30.dim("Check plan limits")}
8779
-
8780
- mutagent prompts create --help ${chalk30.dim("Upload prompt (read help first!)")}
8781
- mutagent prompts list --json ${chalk30.dim("List prompts")}
8782
- mutagent prompts get <id> --json ${chalk30.dim("Full prompt details + schemas")}
8783
-
8784
- mutagent prompts dataset add --help ${chalk30.dim("Upload dataset (read help first!)")}
8785
- mutagent prompts dataset list <id> ${chalk30.dim("List datasets")}
8786
-
8787
- mutagent prompts evaluation create --help ${chalk30.dim("Create eval (read help first!)")}
8788
- mutagent prompts evaluation create <id> --guided --json ${chalk30.dim("Guided eval workflow")}
8789
- mutagent prompts evaluation list <id> --json ${chalk30.dim("List evaluations")}
8790
-
8791
- mutagent prompts optimize start --help ${chalk30.dim("Run optimization (read help first!)")}
8792
- mutagent prompts optimize status <job-id> ${chalk30.dim("Poll progress")}
8793
- mutagent prompts optimize results <job-id> ${chalk30.dim("View scorecard")}
8794
-
8795
- mutagent integrate <framework> ${chalk30.dim("Framework integration guide")}
8796
- mutagent hooks --help ${chalk30.dim("Hook setup for Claude Code telemetry")}
8797
- mutagent playground run <id> --input '{...}' ${chalk30.dim("Quick test")}
8798
-
8799
- ${chalk30.yellow(" Workflow: Framework Integration (Tracing):")}
8800
- 1. mutagent explore ${chalk30.dim(" discover prompts/agents in codebase")}
8801
- 2. mutagent integrate <framework> ${chalk30.dim("← get integration instructions")}
8802
- 3. Apply tracing code to your codebase ${chalk30.dim(" follow the guide output")}
8803
- 4. mutagent traces list --json ${chalk30.dim("← verify traces are arriving")}
8804
-
8805
- ${chalk30.yellow(" Workflow: Evaluate Optimize:")}
8806
- 1. mutagent prompts create --help ${chalk30.dim("← read help")}
8807
- 2. mutagent prompts create ... --json ${chalk30.dim("← upload prompt with {variables} + inputSchema")}
8808
- 3. mutagent prompts dataset add --help ${chalk30.dim(" read help")}
8809
- 4. mutagent prompts dataset add <id> ... --json ${chalk30.dim("← upload dataset")}
8810
- 5. mutagent prompts evaluation create <id> --guided --json ${chalk30.dim("← guided eval")}
8900
+ ${chalk31.yellow("Non-Interactive Mode (CI/CD & Coding Agents):")}
8901
+ export MUTAGENT_API_KEY=mt_... ${chalk31.dim("or")} --api-key mt_...
8902
+ --json ${chalk31.dim("for structured output")} --non-interactive ${chalk31.dim("to disable prompts")}
8903
+
8904
+ ${chalk31.yellow("Command Navigation:")}
8905
+ mutagent auth login --browser ${chalk31.dim("Authenticate (OAuth)")}
8906
+ mutagent auth status ${chalk31.dim("Check auth + workspace")}
8907
+ mutagent init ${chalk31.dim("Initialize project (.mutagentrc.json)")}
8908
+ mutagent explore ${chalk31.dim("Discover prompts in codebase")}
8909
+ mutagent workspaces list --json ${chalk31.dim("List workspaces (verify ID)")}
8910
+ mutagent config set workspace <id> ${chalk31.dim("Set active workspace")}
8911
+ mutagent usage --json ${chalk31.dim("Check plan limits")}
8912
+
8913
+ mutagent prompts create --help ${chalk31.dim("Upload prompt (read help first!)")}
8914
+ mutagent prompts list --json ${chalk31.dim("List prompts")}
8915
+ mutagent prompts get <id> --json ${chalk31.dim("Full prompt details + schemas")}
8916
+
8917
+ mutagent prompts dataset add --help ${chalk31.dim("Upload dataset (read help first!)")}
8918
+ mutagent prompts dataset list <id> ${chalk31.dim("List datasets")}
8919
+
8920
+ mutagent prompts evaluation create --help ${chalk31.dim("Create eval (read help first!)")}
8921
+ mutagent prompts evaluation create <id> --guided --json ${chalk31.dim("Guided eval workflow")}
8922
+ mutagent prompts evaluation list <id> --json ${chalk31.dim("List evaluations")}
8923
+
8924
+ mutagent prompts optimize start --help ${chalk31.dim("Run optimization (read help first!)")}
8925
+ mutagent prompts optimize status <job-id> ${chalk31.dim("Poll progress")}
8926
+ mutagent prompts optimize results <job-id> ${chalk31.dim("View scorecard")}
8927
+
8928
+ mutagent feedback send -m "..." ${chalk31.dim("Send product feedback")}
8929
+ mutagent feedback send -m "..." --category bug ${chalk31.dim("Report a bug")}
8930
+
8931
+ mutagent integrate <framework> ${chalk31.dim("Framework integration guide")}
8932
+ mutagent hooks --help ${chalk31.dim("Hook setup for Claude Code telemetry")}
8933
+ mutagent playground run <id> --input '{...}' ${chalk31.dim("Quick test")}
8934
+
8935
+ ${chalk31.yellow(" Workflow: Framework Integration (Tracing):")}
8936
+ 1. mutagent explore ${chalk31.dim("← discover prompts/agents in codebase")}
8937
+ 2. mutagent integrate <framework> ${chalk31.dim("← get integration instructions")}
8938
+ 3. Apply tracing code to your codebase ${chalk31.dim(" follow the guide output")}
8939
+ 4. mutagent traces list --json ${chalk31.dim("← verify traces are arriving")}
8940
+
8941
+ ${chalk31.yellow(" Workflow: Evaluate → Optimize:")}
8942
+ 1. mutagent prompts create --help ${chalk31.dim("← read help")}
8943
+ 2. mutagent prompts create ... --json ${chalk31.dim("← upload prompt with {variables} + inputSchema")}
8944
+ 3. mutagent prompts dataset add --help ${chalk31.dim("← read help")}
8945
+ 4. mutagent prompts dataset add <id> ... --json ${chalk31.dim("← upload dataset")}
8946
+ 5. mutagent prompts evaluation create <id> --guided --json ${chalk31.dim("← guided eval")}
8811
8947
  6. mutagent prompts optimize start <id> --dataset <d> --evaluation <e> --json
8812
8948
 
8813
- ${chalk30.yellow("Post-Onboarding Decision Tree:")}
8814
- After ${chalk30.bold("mutagent auth login")}, users land in one of 3 paths:
8815
- ${chalk30.bold("Path A")} (Tracing): explore → integrate <framework> → apply tracing → verify
8816
- ${chalk30.bold("Path B")} (Optimization): explore → prompts create → dataset add → eval create → optimize
8817
- ${chalk30.bold("Path C")} (Manual): Use CLI commands directly — run mutagent <command> --help
8949
+ ${chalk31.yellow("Post-Onboarding Decision Tree:")}
8950
+ After ${chalk31.bold("mutagent auth login")}, users land in one of 3 paths:
8951
+ ${chalk31.bold("Path A")} (Tracing): explore → integrate <framework> → apply tracing → verify
8952
+ ${chalk31.bold("Path B")} (Optimization): explore → prompts create → dataset add → eval create → optimize
8953
+ ${chalk31.bold("Path C")} (Manual): Use CLI commands directly — run mutagent <command> --help
8818
8954
 
8819
- ${chalk30.yellow("Directive System:")}
8955
+ ${chalk31.yellow("Directive System:")}
8820
8956
  Every --json response may include:
8821
- ${chalk30.bold("_directive.renderedCard")} Pre-formatted card for the user ${chalk30.red("(MUST be shown in chat)")}
8822
- ${chalk30.bold("_directive.instruction")} Next step for the agent
8823
- ${chalk30.bold("_directive.next")} Array of suggested follow-up commands
8824
- ${chalk30.bold("_links")} Dashboard/API URLs (format as markdown links)
8957
+ ${chalk31.bold("_directive.renderedCard")} Pre-formatted card for the user ${chalk31.red("(MUST be shown in chat)")}
8958
+ ${chalk31.bold("_directive.instruction")} Next step for the agent
8959
+ ${chalk31.bold("_directive.next")} Array of suggested follow-up commands
8960
+ ${chalk31.bold("_links")} Dashboard/API URLs (format as markdown links)
8825
8961
 
8826
- ${chalk30.yellow("Evaluation Criteria Format:")}
8827
- Each criterion MUST have: ${chalk30.bold("name")}, ${chalk30.bold("description")} (scoring rubric), ${chalk30.bold("evaluationParameter")}
8962
+ ${chalk31.yellow("Evaluation Criteria Format:")}
8963
+ Each criterion MUST have: ${chalk31.bold("name")}, ${chalk31.bold("description")} (scoring rubric), ${chalk31.bold("evaluationParameter")}
8828
8964
  evaluationParameter MUST match an inputSchema or outputSchema field name
8829
8965
  No duplicate evaluationParameter values — each criterion targets a unique field
8830
8966
  ALL schema fields must be covered (missing fields = error)
8831
- Use ${chalk30.bold("--guided --json")} to generate criteria templates from prompt schemas
8967
+ Use ${chalk31.bold("--guided --json")} to generate criteria templates from prompt schemas
8832
8968
 
8833
- ${chalk30.yellow("Optimization Cost Control:")}
8834
- Default max-iterations is 1. ${chalk30.red("NEVER increase without explicit user request.")}
8969
+ ${chalk31.yellow("Optimization Cost Control:")}
8970
+ Default max-iterations is 1. ${chalk31.red("NEVER increase without explicit user request.")}
8835
8971
  Each iteration incurs LLM costs — confirm with user before starting >1.
8836
8972
 
8837
- ${chalk30.yellow("Post-Optimization:")}
8838
- After ${chalk30.bold("optimize results")}: ALWAYS show the before/after diff to the user first.
8839
- Then offer choices: ${chalk30.bold("Apply")} / ${chalk30.bold("Reject")}.
8973
+ ${chalk31.yellow("Post-Optimization:")}
8974
+ After ${chalk31.bold("optimize results")}: ALWAYS show the before/after diff to the user first.
8975
+ Then offer choices: ${chalk31.bold("Apply")} / ${chalk31.bold("Reject")}.
8840
8976
 
8841
- ${chalk30.yellow("State Tracking:")}
8977
+ ${chalk31.yellow("State Tracking:")}
8842
8978
  .mutagent/mutation-context.md — Codebase index of discovered/uploaded prompts
8843
8979
  Update after explore, create, and dataset operations
8844
8980
  mutagent auth status — Auth + workspace state
8845
8981
  Comment markers (// MutagenT:START ... // MutagenT:END) in source files
8846
8982
 
8847
- ${chalk30.yellow("AI Agent Rules (MANDATORY for coding agents):")}
8983
+ ${chalk31.yellow("AI Agent Rules (MANDATORY for coding agents):")}
8848
8984
  1. EVERY command MUST include --json (no exceptions)
8849
8985
  2. Run <command> --help BEFORE first use of any command
8850
8986
  3. Use --guided --json for evaluation creation (NEVER --guided alone)
8851
8987
  4. Parse _directive.renderedCard and copy it into your CHAT RESPONSE verbatim
8852
- ${chalk30.red("HARD STOP")}: do NOT run further commands until the card is rendered in chat
8988
+ ${chalk31.red("HARD STOP")}: do NOT run further commands until the card is rendered in chat
8853
8989
  5. After mutagent init, verify workspace: mutagent workspaces list --json
8854
8990
  6. Use {single_braces} for template variables in prompts
8855
8991
  7. Collect evaluation criteria from the user — NEVER auto-generate
8856
8992
  8. ALL user interaction via AskUserQuestion — CLI is non-interactive
8857
8993
  ${!hasCredentials() ? `
8858
- ` + chalk30.yellow(" Warning: Not authenticated. Run: mutagent auth login --browser") + `
8994
+ ` + chalk31.yellow(" Warning: Not authenticated. Run: mutagent auth login --browser") + `
8859
8995
  ` : ""}${!hasRcConfig() ? `
8860
- ` + chalk30.green(" Get started: mutagent init") + `
8996
+ ` + chalk31.green(" Get started: mutagent init") + `
8861
8997
  ` : ""}`);
8862
8998
  program.hook("preAction", (thisCommand) => {
8863
8999
  const globalOpts = thisCommand.optsWithGlobals();
@@ -8886,7 +9022,8 @@ program.addCommand(createExploreCommand());
8886
9022
  program.addCommand(createSkillsCommand());
8887
9023
  program.addCommand(createUsageCommand());
8888
9024
  program.addCommand(createHooksCommand());
9025
+ program.addCommand(createFeedbackCommand());
8889
9026
  program.parse();
8890
9027
 
8891
- //# debugId=5AE0DCCBB0C5BF5A64756E2164756E21
9028
+ //# debugId=D4182D0F3A84030D64756E2164756E21
8892
9029
  //# sourceMappingURL=cli.js.map