@mutmutco/cli 2.27.0 → 2.28.0

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.
Files changed (3) hide show
  1. package/README.md +1 -0
  2. package/dist/main.cjs +158 -7
  3. package/package.json +1 -1
package/README.md CHANGED
@@ -44,6 +44,7 @@ mmi-cli doctor --json
44
44
  - `mmi-cli oauth plan|verify` prints a repo's canonical Google OAuth URI set when the registry declares an `oauth` block and verifies the client is port-agnostic.
45
45
  - `mmi-cli issue create` creates typed, prioritized GitHub issues (priority sets the board field, not a label) and queues related-issue discovery. `--parent <ref>` files the new issue as a native GitHub sub-issue of a parent (works cross-repo); `mmi-cli issue link-child <parent> <child>` links two existing issues the same way.
46
46
  - `mmi-cli report` files a friction report on the Hub board with your GitHub identity, deduping against the open `report`-labeled issues (a confident duplicate becomes a +1 comment, not a new issue). No repo-local `.env`, no API key, no copied report script.
47
+ - `mmi-cli skill-lesson --skill <name>` files a **skill-lesson** on the Hub board when a skill's own instructions misfire — the cross-skill generalization of grind's Retro. GitHub identity, its own `skill-lesson` label + dedup pool (a confident duplicate becomes a +1 comment), and a footer pinning the source checkout + plugin SHA. Advisory: the fix lands via a reviewed PR to the skill in MMI-Hub, never a live edit.
47
48
  - `mmi-cli pr create` and `pr merge` create PRs and land them with branch/worktree cleanup; `mmi-cli gc` dry-runs cleanup of merged/closed PR branches + stale tracking refs.
48
49
  - `mmi-cli board read|claim|show|move|done|backfill-priority` reads and moves GitHub Project work.
49
50
  - `mmi-cli tenant control <owner/repo> <stage> <status|start|stop|restart>` runs bounded dev/rc box control for project-admins through the Hub API; main remains master-only.
package/dist/main.cjs CHANGED
@@ -5038,6 +5038,38 @@ function buildDupComment(duplicateNumber, body, sourceRepo) {
5038
5038
  ${buildReportBody(body, sourceRepo)}`;
5039
5039
  }
5040
5040
 
5041
+ // src/skill-lesson.ts
5042
+ var SKILL_LESSON_LABEL = "skill-lesson";
5043
+ var SKILL_NAMES = ["bootstrap", "grind", "hotfix", "mmi", "rcand", "release", "secrets", "stage"];
5044
+ function assertSkillName(name) {
5045
+ const match = SKILL_NAMES.find((skill) => skill === name);
5046
+ if (!match) throw new Error(`unknown skill "${name}" \u2014 expected one of: ${SKILL_NAMES.join(", ")}`);
5047
+ return match;
5048
+ }
5049
+ function buildSkillLessonTitle(skill, what) {
5050
+ return `skill-lesson(${skill}): ${what.trim()}`;
5051
+ }
5052
+ function buildSkillLessonBody(body, sourceRepo, pluginSha) {
5053
+ const where = sourceRepo ?? "an unidentified checkout";
5054
+ const at = pluginSha ? ` @ ${pluginSha}` : "";
5055
+ return `${body.trimEnd()}
5056
+
5057
+ ---
5058
+ Filed via \`mmi-cli skill-lesson\` from ${where}${at}.`;
5059
+ }
5060
+ function skillLessonDupMarker(duplicateNumber) {
5061
+ return `<!-- mmi-skill-lesson-dup:${duplicateNumber} -->`;
5062
+ }
5063
+ function buildSkillLessonDupComment(duplicateNumber, body, sourceRepo, pluginSha) {
5064
+ return `${skillLessonDupMarker(duplicateNumber)}
5065
+ +1 \u2014 same lesson surfaced again:
5066
+
5067
+ ${buildSkillLessonBody(body, sourceRepo, pluginSha)}`;
5068
+ }
5069
+ function findDuplicateLesson(source, openLessons) {
5070
+ return findDuplicateReport(source, openLessons);
5071
+ }
5072
+
5041
5073
  // src/board.ts
5042
5074
  var import_node_child_process5 = require("node:child_process");
5043
5075
  var import_node_util5 = require("node:util");
@@ -6711,6 +6743,28 @@ function buildMmiPluginCacheCleanupCheck(input) {
6711
6743
  }))
6712
6744
  };
6713
6745
  }
6746
+ var NESTED_PLUGIN_TREE_LABEL = "self-nested MMI plugin cache tree (#1126)";
6747
+ var NESTED_PLUGIN_TREE_FIX = "run `mmi-cli doctor` to surface the MAX_PATH-safe robocopy cleanup for a self-nested MMI plugin cache tree (#1126)";
6748
+ function nestedPluginTreeCleanupCommand(paths, isWindows) {
6749
+ if (paths.length === 0) return "";
6750
+ if (isWindows) {
6751
+ const clears = paths.map((p) => `robocopy $e "${p}" /MIR /NJH /NJS /NFL /NDL | Out-Null; Remove-Item -LiteralPath "${p}" -Recurse -Force`).join("; ");
6752
+ return `$e=Join-Path $env:TEMP 'mmi-empty'; New-Item -ItemType Directory -Force $e | Out-Null; ${clears}; Remove-Item -LiteralPath $e -Recurse -Force; ${CLAUDE_PLUGIN_RECOVERY}`;
6753
+ }
6754
+ return `${paths.map((p) => `rm -rf "${p}"`).join(" && ")} && ${CLAUDE_PLUGIN_RECOVERY}`;
6755
+ }
6756
+ function buildNestedPluginTreeCheck(input) {
6757
+ const base = { ok: true, label: NESTED_PLUGIN_TREE_LABEL, fix: NESTED_PLUGIN_TREE_FIX };
6758
+ if (!input.isOrgRepo) return base;
6759
+ const nested = input.entries.filter((e) => e.nested).map((e) => ({ surface: e.surface, path: e.path }));
6760
+ if (nested.length === 0) return base;
6761
+ return {
6762
+ ...base,
6763
+ ok: false,
6764
+ nested,
6765
+ fix: `${nested.length} self-nested MMI plugin cache tree(s) (#1126) exceed MAX_PATH and can't self-clean \u2014 run: ${nestedPluginTreeCleanupCommand(nested.map((n) => n.path), input.isWindows)}`
6766
+ };
6767
+ }
6714
6768
  function detectSurface(env) {
6715
6769
  const has = (k) => Boolean(env[k]?.trim());
6716
6770
  if (env.MMI_AGENT_SURFACE === "codex" || has("CODEX_HOME") || (env.CLAUDE_PLUGIN_ROOT ?? "").includes(".codex")) {
@@ -6739,8 +6793,18 @@ function reloadAction(surface) {
6739
6793
  return "restart Claude Code (or run /reload-plugins)";
6740
6794
  }
6741
6795
  }
6796
+ var CLAUDE_PLUGIN_RECOVERY = "claude plugin marketplace remove mmi && claude plugin marketplace add mutmutco/MMI-Hub && claude plugin install mmi@mmi";
6797
+ var CLAUDE_PLUGIN_HEAL_STEPS = [
6798
+ { args: ["plugin", "marketplace", "remove", "mmi"], gated: false },
6799
+ { args: ["plugin", "marketplace", "add", "mutmutco/MMI-Hub"], gated: true },
6800
+ { args: ["plugin", "install", "mmi@mmi"], gated: true },
6801
+ { args: ["plugin", "enable", "mmi@mmi"], gated: false }
6802
+ ];
6803
+ function healStepAborts(step, ok) {
6804
+ return !ok && step.gated;
6805
+ }
6742
6806
  function pluginRecoveryFix(surface) {
6743
- const claude = "claude plugin marketplace update mmi && claude plugin update mmi@mmi && claude plugin enable mmi@mmi";
6807
+ const claude = CLAUDE_PLUGIN_RECOVERY;
6744
6808
  switch (surface) {
6745
6809
  case "claude-vscode":
6746
6810
  case "claude-cli":
@@ -6755,7 +6819,7 @@ function pluginRecoveryFix(surface) {
6755
6819
  }
6756
6820
  }
6757
6821
  var PLUGIN_UPDATE_RECIPES = {
6758
- claude: ["claude plugin update mmi@mmi"],
6822
+ claude: [CLAUDE_PLUGIN_RECOVERY],
6759
6823
  codex: ["codex plugin marketplace upgrade mmi", "codex plugin list # verify mmi@mmi shows the new version"],
6760
6824
  cli: ["npm install -g @mutmutco/cli@latest"]
6761
6825
  };
@@ -6810,7 +6874,7 @@ function isSemverVersion(v) {
6810
6874
  return typeof v === "string" && /^v?\d+\.\d+\.\d+/.test(v.trim());
6811
6875
  }
6812
6876
  function staleRecordCommand(surface) {
6813
- return surface === "codex" ? "codex plugin marketplace upgrade mmi && codex plugin add mmi@mmi" : "claude plugin marketplace update mmi && claude plugin update mmi@mmi";
6877
+ return surface === "codex" ? "codex plugin marketplace upgrade mmi && codex plugin add mmi@mmi" : CLAUDE_PLUGIN_RECOVERY;
6814
6878
  }
6815
6879
  function staleSurfacesFix(stale, releasedVersion) {
6816
6880
  const parts = stale.map((s) => {
@@ -11635,10 +11699,10 @@ async function runClaudePlugin(args) {
11635
11699
  }
11636
11700
  async function applyClaudePluginHeal(surface, log) {
11637
11701
  if (surface !== "claude-cli" && surface !== "claude-vscode") return false;
11638
- log(" \u21BB updating the MMI plugin via `claude plugin` (marketplace \u2192 update \u2192 enable)\u2026");
11639
- if (!await runClaudePlugin(["plugin", "marketplace", "update", "mmi"])) return false;
11640
- if (!await runClaudePlugin(["plugin", "update", "mmi@mmi"])) return false;
11641
- await runClaudePlugin(["plugin", "enable", "mmi@mmi"]);
11702
+ log(" \u21BB reinstalling the MMI plugin via `claude plugin` (marketplace remove \u2192 add \u2192 install)\u2026");
11703
+ for (const step of CLAUDE_PLUGIN_HEAL_STEPS) {
11704
+ if (healStepAborts(step, await runClaudePlugin([...step.args]))) return false;
11705
+ }
11642
11706
  return true;
11643
11707
  }
11644
11708
  var program2 = new Command();
@@ -12584,6 +12648,74 @@ program2.command("report").description("file a friction report on the Hub board
12584
12648
  const projectItemId = await attachToProject(created.number, targetRepo2, priority);
12585
12649
  console.log(JSON.stringify({ ...created, deduped: false, label: REPORT_LABEL, priority, projectItemId }));
12586
12650
  });
12651
+ async function resolvePluginSha() {
12652
+ const root = process.env.CLAUDE_PLUGIN_ROOT;
12653
+ if (!root) return void 0;
12654
+ try {
12655
+ const { stdout } = await execFileP2("git", ["-C", root, "rev-parse", "--short", "HEAD"], { timeout: 5e3 });
12656
+ return stdout.trim() || void 0;
12657
+ } catch {
12658
+ return void 0;
12659
+ }
12660
+ }
12661
+ program2.command("skill-lesson").description("file a skill-lesson on the Hub board (GitHub auth, dedups open lessons) and print {number,url} JSON").requiredOption("--skill <name>", `which skill misfired (${SKILL_NAMES.join(" | ")})`).requiredOption("--title <title>", "one-line summary of what misfired").option("--body <body>", "lesson body: what misfired, the evidence, and the proposed amendment (markdown)").option("--body-file <path|->", "read the lesson body from a UTF-8 file, or from stdin with -").option("--priority <priority>", "urgent | high | medium | low (board Priority field when configured)", "medium").option("--repo <owner/repo>", `target repo (defaults to the org Hub: ${HUB_REPO})`).option("--force", "file a new issue even when an open lesson looks like a duplicate").option("--json", "machine-readable output (already the default \u2014 skill-lesson always prints JSON)").action(async (o) => {
12662
+ const targetRepo2 = o.repo ?? HUB_REPO;
12663
+ const sourceRepo = await resolveRepo(void 0);
12664
+ const pluginSha = await resolvePluginSha();
12665
+ let skill;
12666
+ let rawBody;
12667
+ let title;
12668
+ let priority;
12669
+ let body;
12670
+ let args;
12671
+ try {
12672
+ skill = assertSkillName(o.skill);
12673
+ rawBody = await resolveIssueBody({ body: o.body, bodyFile: o.bodyFile }, { readFile: import_promises3.readFile, readStdin });
12674
+ title = buildSkillLessonTitle(skill, o.title);
12675
+ priority = normalizePriority(o.priority);
12676
+ body = buildSkillLessonBody(rawBody, sourceRepo, pluginSha);
12677
+ args = buildIssueArgs({ type: "task", title, body, priority, repo: targetRepo2, labels: [SKILL_LESSON_LABEL] });
12678
+ } catch (e) {
12679
+ return fail(`skill-lesson: ${e.message}`);
12680
+ }
12681
+ if (!o.force) {
12682
+ let openLessons = [];
12683
+ try {
12684
+ openLessons = await ghJson([
12685
+ "issue",
12686
+ "list",
12687
+ "--repo",
12688
+ targetRepo2,
12689
+ "--state",
12690
+ "open",
12691
+ "--label",
12692
+ SKILL_LESSON_LABEL,
12693
+ "--limit",
12694
+ "100",
12695
+ "--json",
12696
+ "number,title,body,url"
12697
+ ]);
12698
+ } catch {
12699
+ }
12700
+ const dup = findDuplicateLesson({ title, body: rawBody }, openLessons);
12701
+ if (dup) {
12702
+ try {
12703
+ await execFileP2("gh", ["issue", "comment", String(dup.number), "--repo", targetRepo2, "--body", buildSkillLessonDupComment(dup.number, rawBody, sourceRepo, pluginSha)], { timeout: GH_MUTATION_TIMEOUT_MS });
12704
+ } catch (e) {
12705
+ const err = e;
12706
+ return fail(`skill-lesson: duplicate of #${dup.number} (${dup.url}) but the +1 comment failed: ${(err.stderr || err.message || String(e)).trim()}`);
12707
+ }
12708
+ return console.log(JSON.stringify({ deduped: true, number: dup.number, url: dup.url, score: dup.score }));
12709
+ }
12710
+ }
12711
+ try {
12712
+ await execFileP2("gh", ["label", "create", SKILL_LESSON_LABEL, "--color", "c2e0c6", "--repo", targetRepo2], { timeout: GH_MUTATION_TIMEOUT_MS });
12713
+ } catch {
12714
+ }
12715
+ const created = await ghCreate(args);
12716
+ const projectItemId = await attachToProject(created.number, targetRepo2, priority);
12717
+ console.log(JSON.stringify({ ...created, deduped: false, label: SKILL_LESSON_LABEL, skill, priority, projectItemId }));
12718
+ });
12587
12719
  var pr = program2.command("pr").description("pull requests \u2014 reliable create with structured output");
12588
12720
  pr.command("create").description("create a PR and print {number,url} JSON").requiredOption("--title <title>", "PR title").option("--body <body>", "PR body (markdown)").option("--body-file <path|->", "read PR body from a UTF-8 file, or from stdin with -").option("--base <branch>", "base branch (defaults to the repo default)").option("--head <branch>", "head branch (defaults to the current branch)").option("--repo <owner/repo>", "target repo (defaults to the current repo)").action(async (o) => {
12589
12721
  let body;
@@ -13576,6 +13708,18 @@ function mmiPluginCacheRootSnapshots() {
13576
13708
  }
13577
13709
  });
13578
13710
  }
13711
+ function hasNestedMmiChild(versionDir) {
13712
+ try {
13713
+ return (0, import_node_fs11.statSync)((0, import_node_path10.join)(versionDir, "mmi")).isDirectory();
13714
+ } catch {
13715
+ return false;
13716
+ }
13717
+ }
13718
+ function nestedPluginTreeSnapshot() {
13719
+ return mmiPluginCacheRootSnapshots().filter((root) => root.surface === "claude").flatMap(
13720
+ (root) => root.entries.filter((e) => e.isDirectory && /^v?\d+\.\d+\.\d+/.test(e.name)).map((e) => ({ surface: "claude", path: e.path, nested: hasNestedMmiChild(e.path) }))
13721
+ );
13722
+ }
13579
13723
  function uniqueQuarantineTarget(path2) {
13580
13724
  if (!(0, import_node_fs11.existsSync)(path2)) return path2;
13581
13725
  for (let i = 1; i < 100; i += 1) {
@@ -13768,6 +13912,13 @@ async function runDoctor(opts, io = consoleIo) {
13768
13912
  };
13769
13913
  }
13770
13914
  checks.push(cacheCleanupCheck);
13915
+ checks.push(
13916
+ buildNestedPluginTreeCheck({
13917
+ isOrgRepo: Boolean(cfg.sagaApiUrl),
13918
+ isWindows: isWin,
13919
+ entries: nestedPluginTreeSnapshot()
13920
+ })
13921
+ );
13771
13922
  const cursorCacheRoot = cursorPluginCacheRoot();
13772
13923
  checks.push(
13773
13924
  buildCursorPluginInstallCheck({
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mutmutco/cli",
3
- "version": "2.27.0",
3
+ "version": "2.28.0",
4
4
  "description": "MMI Future CLI — delivers the org rules (whole-file), plus saga and KB access. The cross-IDE engine the plugin's SessionStart hook drives.",
5
5
  "type": "module",
6
6
  "license": "UNLICENSED",