@mutagent/cli 0.1.42 → 0.1.44

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
@@ -7216,24 +7216,27 @@ description: |
7216
7216
  ---`;
7217
7217
  var SKILL_BODY = `# MutagenT CLI Skill
7218
7218
 
7219
- ## Quick Reference
7220
- Run \`mutagent --help\` for full command list and examples.
7221
- Run \`mutagent <command> --help\` for on-the-fly instructions before using any command.
7219
+ ## First Things First
7220
+ Run \`mutagent --help\` this is the CENTRAL navigation hub containing ALL commands, workflows, and rules.
7221
+ Run \`mutagent <command> --help\` BEFORE using ANY command for the first time.
7222
7222
 
7223
- Key commands:
7224
- - \`mutagent auth login\` Authenticate
7225
- - \`mutagent prompts list\` List prompts
7226
- - \`mutagent usage\` — Check plan limits and remaining optimization runs
7227
- - \`mutagent explore\`Discover prompts in codebase
7228
- - \`mutagent integrate <framework>\` — Framework integration instructions
7223
+ ## Agent Protocol (4 Rules)
7224
+ 1. EVERY command MUST include \`--json\`
7225
+ 2. Run \`<command> --help\` BEFORE first use
7226
+ 3. **MANDATORY**: Parse \`_directive.renderedCard\` and copy it into your CHAT RESPONSE verbatim. The card appears in bash output but that is NOT sufficient the user cannot read collapsed bash blocks. HARD STOP: do NOT run any further commands until the card text is rendered in your chat message.
7227
+ 4. ALL user interaction via AskUserQuestion CLI is non-interactive
7229
7228
 
7230
- ## Agent Usage Guidelines
7229
+ ## Directive System
7230
+ Every JSON response may include:
7231
+ - \`_directive.renderedCard\` — Pre-formatted card that MUST be shown to the user verbatim
7232
+ - \`_directive.instruction\` — Next step for the agent
7233
+ - \`_directive.next\` — Array of suggested commands
7234
+ - \`_links\` — Dashboard/API URLs (format as markdown)
7231
7235
 
7232
- - **ALWAYS** run \`mutagent prompts list --json\` and \`mutagent usage --json\` BEFORE creating or modifying resources
7233
- - **ALWAYS** use the \`--json\` flag for machine-readable output
7234
- - **ALWAYS** confirm with the user before write operations (create, update, delete, optimize)
7235
- - **CHECK** \`mutagent usage\` before running \`optimize start\` to verify remaining optimization runs
7236
- - Format dashboard links as markdown: \`[View on Dashboard](url)\`
7236
+ The agent MUST parse and act on directives. Cards in collapsed bash output are invisible to the user — always render them in chat.
7237
+
7238
+ ## Prompt Variables
7239
+ Use \`{single_braces}\`: \`"Analyze: {document}"\`
7237
7240
 
7238
7241
  ## Post-Onboarding Decision Tree
7239
7242
 
@@ -7259,58 +7262,56 @@ After \`mutagent auth login\`, the user lands in one of 3 paths:
7259
7262
  ### Path C: Manual
7260
7263
  User uses CLI commands directly. Run \`mutagent --help\`.
7261
7264
 
7262
- ## State Tracking
7263
- - \`.mutagent/mutation-context.md\` — Local context file tracking all uploads
7264
- - \`mutagent auth status\` — Shows onboarding completion + integration state
7265
- - Comment markers (\`// MutagenT:START ... // MutagenT:END\`) in source files
7265
+ ## Guided Evaluation Creation
7266
+ Use \`--guided --json\` when creating evaluations (NEVER \`--guided\` alone it launches interactive prompts that agents can't use):
7267
+ \\\`\\\`\\\`
7268
+ mutagent prompts evaluation create <id> --guided --json
7269
+ \\\`\\\`\\\`
7266
7270
 
7267
- ## Wireframe Templates
7271
+ **When to use guided mode:**
7272
+ The optimizer requires each criterion to have \`name\`, \`description\` (scoring rubric), and \`evaluationParameter\` (a field from the prompt's inputSchema or outputSchema). If the user's existing evaluation format doesn't match this shape — e.g. they have generic rubrics without per-field targeting, or criteria that don't map 1:1 to schema fields — use \`--guided\` to:
7273
+ 1. Fetch the prompt's inputSchema + outputSchema fields
7274
+ 2. Show which fields need coverage
7275
+ 3. Return a criteria template with the exact JSON shape
7268
7276
 
7269
- ### Active Operation Status Card
7270
- \`\`\`
7271
- ┌─────────────────────────────────────────┐
7272
- MutagenT: Optimizing │
7273
- ───────────────────────────────────────
7274
- │ Prompt: "email-summarizer" (ID: 42) │
7275
- │ Dataset: "customer-emails" (150 items) │
7276
- │ Status: Running — Iteration 3/10 │
7277
- │ Score: 0.72 → 0.85 (+18%) │
7278
- │ ████████████░░░░░░░░ 60% │
7279
- │ │
7280
- │ \uD83D\uDD17 View: https://app.mutagent.io/... │
7281
- └─────────────────────────────────────────┘
7282
- \`\`\`
7277
+ **Validation rules the CLI enforces:**
7278
+ - Every criterion MUST have \`name\`, \`description\`, and \`evaluationParameter\`
7279
+ - \`evaluationParameter\` MUST match an actual schema field name
7280
+ - No duplicate \`evaluationParameter\` values — each criterion targets a unique field
7281
+ - ALL schema fields must be covered (missing fields = error)
7283
7282
 
7284
- ### Optimization Scorecard
7285
- \`\`\`
7286
- ┌─────────────────────────────────────────┐
7287
- \uD83D\uDCCA Optimization Results │
7288
- ───────────────────────────────────────
7289
- │ BEFORE │
7290
- │ System: "You are a helpful..." │
7291
- │ Score: 0.62 │
7292
- │ │
7293
- │ AFTER │
7294
- │ System: "You are an expert..." │
7295
- │ Score: 0.91 (+47%) │
7296
- │ │
7297
- │ Iterations: 5 | Best: #4 │
7298
- │ ─────────────────────────────────────── │
7299
- │ Score Progression: │
7300
- │ #1: 0.62 #2: 0.71 #3: 0.78 │
7301
- │ #4: 0.91 #5: 0.89 │
7302
- │ │
7303
- │ [Apply] [Reject] [View Details] │
7304
- │ │
7305
- │ \uD83D\uDD17 Dashboard: https://app.mutagent... │
7306
- │ \uD83D\uDD17 Optimizer: https://app.mutagent... │
7307
- └─────────────────────────────────────────┘
7308
- \`\`\`
7283
+ ## State Tracking
7284
+ - \`.mutagent/mutation-context.md\` — Codebase index of discovered/uploaded prompts
7285
+ - Check and update this file after explore, create, and dataset operations
7286
+ - \`mutagent auth status\` — Auth + workspace state
7287
+ - Comment markers (\`// MutagenT:START ... // MutagenT:END\`) in source files
7288
+
7289
+ ## Post-Optimization
7290
+ After \`optimize results\`: ALWAYS show the before/after diff to the user first. Then offer choices via AskUserQuestion: Apply / Reject.
7309
7291
 
7310
7292
  ## Evaluation Criteria Reminder
7311
7293
  Every evaluation MUST specify criteria targeting either:
7312
7294
  - Input variable fields (from inputSchema)
7313
- - Output fields (from outputSchema / structured output)`;
7295
+ - Output fields (from outputSchema / structured output)
7296
+
7297
+ ## Optimization Cost Control
7298
+ - Default max-iterations is 1. NEVER increase without explicit user request.
7299
+ - Each iteration incurs LLM costs. Starting >1 iterations without consent = protocol violation.
7300
+ - If user wants more, confirm the number via AskUserQuestion first.
7301
+
7302
+ ## Claude Code Hooks (Session Telemetry)
7303
+ Optional — sends session activity to MutagenT traces API for observability.
7304
+
7305
+ Install via \`.claude/settings.local.json\`:
7306
+ \\\`\\\`\\\`json
7307
+ {"hooks": {
7308
+ "SessionStart": [{"matcher": "startup", "hooks": [{"type": "command", "command": "mutagent hooks claude-code session-start"}]}],
7309
+ "Stop": [{"hooks": [{"type": "command", "command": "mutagent hooks claude-code session-end"}]}],
7310
+ "PreToolUse": [{"hooks": [{"type": "command", "command": "mutagent hooks claude-code pre-tool-use"}]}],
7311
+ "PostToolUse": [{"hooks": [{"type": "command", "command": "mutagent hooks claude-code post-tool-use"}]}]
7312
+ }}
7313
+ \\\`\\\`\\\`
7314
+ Or run: \`mutagent init\` (option 1 installs skill + hooks together)`;
7314
7315
  var SKILL_DIR = ".claude/skills/mutagent-cli";
7315
7316
  var SKILL_FILE = "SKILL.md";
7316
7317
  function createSkillsCommand() {
@@ -7686,7 +7687,23 @@ async function handlePostToolUse() {
7686
7687
  ]);
7687
7688
  }
7688
7689
  function createHooksCommand() {
7689
- const hooks = new Command18("hooks").description("Hook handlers for AI coding assistants");
7690
+ const hooks = new Command18("hooks").description("Hook handlers for AI coding assistants").addHelpText("after", `
7691
+ Claude Code Session Telemetry:
7692
+ Sends lightweight session activity to the MutagenT traces API for observability.
7693
+
7694
+ Install by adding to .claude/settings.local.json:
7695
+
7696
+ {
7697
+ "hooks": {
7698
+ "SessionStart": [{"matcher": "startup", "hooks": [{"type": "command", "command": "mutagent hooks claude-code session-start"}]}],
7699
+ "Stop": [{"hooks": [{"type": "command", "command": "mutagent hooks claude-code session-end"}]}],
7700
+ "PreToolUse": [{"hooks": [{"type": "command", "command": "mutagent hooks claude-code pre-tool-use"}]}],
7701
+ "PostToolUse": [{"hooks": [{"type": "command", "command": "mutagent hooks claude-code post-tool-use"}]}]
7702
+ }
7703
+ }
7704
+
7705
+ Or run: mutagent init (option 1 installs skill + hooks together)
7706
+ `);
7690
7707
  const claudeCode = hooks.command("claude-code").description("Claude Code session telemetry");
7691
7708
  claudeCode.command("session-start").description("Handle session start event").action(async () => {
7692
7709
  await safeExecute(handleSessionStart);
@@ -7754,10 +7771,16 @@ ${chalk24.yellow("Command Navigation:")}
7754
7771
  mutagent prompts optimize results <job-id> ${chalk24.dim("View scorecard")}
7755
7772
 
7756
7773
  mutagent integrate <framework> ${chalk24.dim("Framework integration guide")}
7757
- mutagent hooks claude-code <event> ${chalk24.dim("Hook handler for Claude Code telemetry")}
7774
+ mutagent hooks --help ${chalk24.dim("Hook setup for Claude Code telemetry")}
7758
7775
  mutagent playground run <id> --input '{...}' ${chalk24.dim("Quick test")}
7759
7776
 
7760
- ${chalk24.yellow("Workflow: Evaluate Optimize:")}
7777
+ ${chalk24.yellow("Workflow: Framework Integration (Tracing):")}
7778
+ 1. mutagent explore ${chalk24.dim("← discover prompts/agents in codebase")}
7779
+ 2. mutagent integrate <framework> ${chalk24.dim("← get integration instructions")}
7780
+ 3. Apply tracing code to your codebase ${chalk24.dim("← follow the guide output")}
7781
+ 4. mutagent traces list --json ${chalk24.dim("← verify traces are arriving")}
7782
+
7783
+ ${chalk24.yellow("★ Workflow: Evaluate → Optimize:")}
7761
7784
  1. mutagent prompts create --help ${chalk24.dim("← read help")}
7762
7785
  2. mutagent prompts create ... --json ${chalk24.dim("← upload prompt with {variables} + inputSchema")}
7763
7786
  3. mutagent prompts dataset add --help ${chalk24.dim("← read help")}
@@ -7765,14 +7788,50 @@ ${chalk24.yellow("Workflow: Evaluate → Optimize:")}
7765
7788
  5. mutagent prompts evaluation create <id> --guided --json ${chalk24.dim("← guided eval")}
7766
7789
  6. mutagent prompts optimize start <id> --dataset <d> --evaluation <e> --json
7767
7790
 
7791
+ ${chalk24.yellow("Post-Onboarding Decision Tree:")}
7792
+ After ${chalk24.bold("mutagent auth login")}, users land in one of 3 paths:
7793
+ ${chalk24.bold("Path A")} (Tracing): explore → integrate <framework> → apply tracing → verify
7794
+ ${chalk24.bold("Path B")} (Optimization): explore → prompts create → dataset add → eval create → optimize
7795
+ ${chalk24.bold("Path C")} (Manual): Use CLI commands directly — run mutagent <command> --help
7796
+
7797
+ ${chalk24.yellow("Directive System:")}
7798
+ Every --json response may include:
7799
+ ${chalk24.bold("_directive.renderedCard")} Pre-formatted card for the user ${chalk24.red("(MUST be shown in chat)")}
7800
+ ${chalk24.bold("_directive.instruction")} Next step for the agent
7801
+ ${chalk24.bold("_directive.next")} Array of suggested follow-up commands
7802
+ ${chalk24.bold("_links")} Dashboard/API URLs (format as markdown links)
7803
+
7804
+ ${chalk24.yellow("Evaluation Criteria Format:")}
7805
+ Each criterion MUST have: ${chalk24.bold("name")}, ${chalk24.bold("description")} (scoring rubric), ${chalk24.bold("evaluationParameter")}
7806
+ evaluationParameter MUST match an inputSchema or outputSchema field name
7807
+ No duplicate evaluationParameter values — each criterion targets a unique field
7808
+ ALL schema fields must be covered (missing fields = error)
7809
+ Use ${chalk24.bold("--guided --json")} to generate criteria templates from prompt schemas
7810
+
7811
+ ${chalk24.yellow("Optimization Cost Control:")}
7812
+ Default max-iterations is 1. ${chalk24.red("NEVER increase without explicit user request.")}
7813
+ Each iteration incurs LLM costs — confirm with user before starting >1.
7814
+
7815
+ ${chalk24.yellow("Post-Optimization:")}
7816
+ After ${chalk24.bold("optimize results")}: ALWAYS show the before/after diff to the user first.
7817
+ Then offer choices: ${chalk24.bold("Apply")} / ${chalk24.bold("Reject")}.
7818
+
7819
+ ${chalk24.yellow("State Tracking:")}
7820
+ .mutagent/mutation-context.md — Codebase index of discovered/uploaded prompts
7821
+ Update after explore, create, and dataset operations
7822
+ mutagent auth status — Auth + workspace state
7823
+ Comment markers (// MutagenT:START ... // MutagenT:END) in source files
7824
+
7768
7825
  ${chalk24.yellow("AI Agent Rules (MANDATORY for coding agents):")}
7769
7826
  1. EVERY command MUST include --json (no exceptions)
7770
7827
  2. Run <command> --help BEFORE first use of any command
7771
7828
  3. Use --guided --json for evaluation creation (NEVER --guided alone)
7772
- 4. Parse _directive.renderedCard and copy it into your CHAT RESPONSE verbatim — bash output is NOT sufficient
7829
+ 4. Parse _directive.renderedCard and copy it into your CHAT RESPONSE verbatim
7830
+ ${chalk24.red("HARD STOP")}: do NOT run further commands until the card is rendered in chat
7773
7831
  5. After mutagent init, verify workspace: mutagent workspaces list --json
7774
7832
  6. Use {single_braces} for template variables in prompts
7775
- 7. Collect evaluation rubrics from the user — NEVER auto-generate
7833
+ 7. Collect evaluation criteria from the user — NEVER auto-generate
7834
+ 8. ALL user interaction via AskUserQuestion — CLI is non-interactive
7776
7835
  ${!hasCredentials() ? `
7777
7836
  ` + chalk24.yellow(" Warning: Not authenticated. Run: mutagent auth login --browser") + `
7778
7837
  ` : ""}${!hasRcConfig() ? `
@@ -7807,5 +7866,5 @@ program.addCommand(createUsageCommand());
7807
7866
  program.addCommand(createHooksCommand());
7808
7867
  program.parse();
7809
7868
 
7810
- //# debugId=167F4784D8F12D3E64756E2164756E21
7869
+ //# debugId=3B726C6C3EEAEFBE64756E2164756E21
7811
7870
  //# sourceMappingURL=cli.js.map