@mutmutco/cli 3.137.0 → 3.139.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 (2) hide show
  1. package/dist/main.cjs +152 -46
  2. package/package.json +1 -1
package/dist/main.cjs CHANGED
@@ -14487,10 +14487,10 @@ var rollout_plan_default = {
14487
14487
  note: "The v4.0.0 stamp happens at cut time (D6e #4463); until then the candidate is the origin/development head artifacts (built cli/dist + npm pack), identity proven by dist content hash (D6a)."
14488
14488
  },
14489
14489
  baseline: {
14490
- version: "3.137.0",
14491
- tag: "v3.137.0",
14492
- commit: "48d8161cd121",
14493
- npm: "@mutmutco/cli@3.137.0"
14490
+ version: "3.139.0",
14491
+ tag: "v3.139.0",
14492
+ commit: "b25f6dfd0b72",
14493
+ npm: "@mutmutco/cli@3.139.0"
14494
14494
  },
14495
14495
  exitCriterion: "fleet-n-of-n",
14496
14496
  hubOnlyShortcut: "forbidden",
@@ -14507,14 +14507,14 @@ var rollout_plan_default = {
14507
14507
  repo: "mutmutco/mmi-hub",
14508
14508
  role: "canary",
14509
14509
  schedule: "train",
14510
- v3Target: "v3.137.0"
14510
+ v3Target: "v3.139.0"
14511
14511
  }
14512
14512
  ],
14513
14513
  rollbackTrigger: "Any red inside the post-cut soak window: `devops train gate` FAIL attributable to the v4 doors, Hub endpoint health probe failure, a v3 client refused while the compat window must still admit it (SUPPORTED_MINOR_WINDOW=2, MIN_CLIENT_VERSION 0.0.0 \u2014 D6a), or npm consumer install/doctor failure on the v4 dist.",
14514
14514
  rollback: {
14515
14515
  independent: true,
14516
- mechanism: "npm dist-tag latest -> 3.137.0 and redeploy the Hub Lambda from tag v3.137.0 (48d8161cd121); installed clients repair via `mmi-cli doctor`. No other cohort is touched.",
14517
- v3Target: "v3.137.0 (@mutmutco/cli@3.137.0, tag commit 48d8161cd121 \u2014 the preserved latest-v3 distribution, D6b)"
14516
+ mechanism: "npm dist-tag latest -> 3.139.0 and redeploy the Hub Lambda from tag v3.139.0 (b25f6dfd0b72); installed clients repair via `mmi-cli doctor`. No other cohort is touched.",
14517
+ v3Target: "v3.139.0 (@mutmutco/cli@3.139.0, tag commit b25f6dfd0b72 \u2014 the preserved latest-v3 distribution, D6b)"
14518
14518
  }
14519
14519
  },
14520
14520
  {
@@ -16288,7 +16288,8 @@ async function disarmFleetLockstep(client, org = ORG_LOGIN) {
16288
16288
  const include = conditions?.repository_name?.include ?? [];
16289
16289
  return writeFleetLockstepRuleset(client, fleetLockstepRulesetDesired(include, "disabled"), id, "disarm", org);
16290
16290
  }
16291
- async function computeFleetLockstepVerdict(gate = runFleetLockstepGate) {
16291
+ var HUB_POSTING_REPO = "mutmutco/mmi-hub";
16292
+ async function computeFleetLockstepVerdict(gate = runFleetLockstepGate, postingRepo) {
16292
16293
  let result;
16293
16294
  try {
16294
16295
  result = await gate();
@@ -16298,6 +16299,31 @@ async function computeFleetLockstepVerdict(gate = runFleetLockstepGate) {
16298
16299
  description: `fleet gate unreadable (fail-closed): ${e.message}`.slice(0, STATUS_DESCRIPTION_MAX)
16299
16300
  };
16300
16301
  }
16302
+ if (postingRepo?.trim().toLowerCase() === HUB_POSTING_REPO) {
16303
+ const structural = [];
16304
+ if (result.repos.length === 0) structural.push("empty roster");
16305
+ if (result.hubOnly) structural.push("hub-only coverage");
16306
+ if (result.unclassifiedProjects.length) structural.push(`${result.unclassifiedProjects.length} registered project(s) with no valid repository`);
16307
+ const hubRow = result.repos.find((r) => r.repo.trim().toLowerCase() === HUB_POSTING_REPO);
16308
+ if (!hubRow) structural.push("Hub row missing from the roster");
16309
+ if (structural.length || hubRow && hubRow.verdict !== "conforming") {
16310
+ const hubLocal = hubRow && hubRow.verdict !== "conforming" ? `Hub row is ${hubRow.verdict}` : null;
16311
+ return {
16312
+ state: "failure",
16313
+ description: `fleet lockstep FAIL: ${[...structural, hubLocal].filter(Boolean).join("; ")} (Hub train scope #5040)`.slice(0, STATUS_DESCRIPTION_MAX)
16314
+ };
16315
+ }
16316
+ if (result.verdict === "pass") {
16317
+ return {
16318
+ state: "success",
16319
+ description: `fleet lockstep ${result.conforming}/${result.denominator} PASS (evaluated ${result.evaluatedAt})`.slice(0, STATUS_DESCRIPTION_MAX)
16320
+ };
16321
+ }
16322
+ return {
16323
+ state: "success",
16324
+ description: `fleet lockstep ${result.conforming}/${result.denominator} \u2014 ${result.drift.length} drift, ${result.unknowns.length} unknown (other repos; non-blocking for the Hub train #5040)`.slice(0, STATUS_DESCRIPTION_MAX)
16325
+ };
16326
+ }
16301
16327
  return result.verdict === "pass" ? {
16302
16328
  state: "success",
16303
16329
  description: `fleet lockstep ${result.conforming}/${result.denominator} PASS (evaluated ${result.evaluatedAt})`.slice(0, STATUS_DESCRIPTION_MAX)
@@ -16308,7 +16334,7 @@ async function computeFleetLockstepVerdict(gate = runFleetLockstepGate) {
16308
16334
  }
16309
16335
  async function satisfyFleetLockstepContext(run, repo, sha, required, gate) {
16310
16336
  if (!required.includes(FLEET_LOCKSTEP_CONTEXT)) return void 0;
16311
- const verdict = await computeFleetLockstepVerdict(gate);
16337
+ const verdict = await computeFleetLockstepVerdict(gate, repo);
16312
16338
  let out;
16313
16339
  try {
16314
16340
  out = await run("gh", [
@@ -29012,6 +29038,11 @@ var ENVIRONMENT_BRANCHES = {
29012
29038
  rc: "rc",
29013
29039
  main: "main"
29014
29040
  };
29041
+ function classifyEnvironmentDrift(drift) {
29042
+ if (drift.missing) return { environment: drift.environment, action: "CREATE", reason: "environment is missing" };
29043
+ const why = [...drift.problems, ...drift.notes].join("; ");
29044
+ return why ? { environment: drift.environment, action: "UPDATE", reason: why } : { environment: drift.environment, action: "SKIP", reason: "already current" };
29045
+ }
29015
29046
  var TRACK_ENVIRONMENT_EXCEPTIONS = {
29016
29047
  direct: { rc: "direct release track has no rc stage" },
29017
29048
  trunk: {
@@ -29050,9 +29081,9 @@ function reviewerKey(reviewer) {
29050
29081
  return `${reviewer.type ?? ""}:${reviewer.id ?? ""}`;
29051
29082
  }
29052
29083
  function environmentDrift(live, desired) {
29053
- if (!live) return ["environment is missing"];
29084
+ if (!live) return { environment: desired.name, missing: true, problems: ["environment is missing"], notes: [] };
29054
29085
  const problems = [];
29055
- if (live.wait_timer !== desired.waitTimer) problems.push(`wait_timer=${live.wait_timer ?? "unset"} (want ${desired.waitTimer})`);
29086
+ const notes = [];
29056
29087
  const policy = live.deployment_branch_policy;
29057
29088
  if (policy?.protected_branches !== desired.deploymentBranchPolicy.protectedBranches) {
29058
29089
  problems.push(`protected_branches=${String(policy?.protected_branches)} (want true)`);
@@ -29060,16 +29091,67 @@ function environmentDrift(live, desired) {
29060
29091
  if (policy?.custom_branch_policies !== desired.deploymentBranchPolicy.customBranchPolicies) {
29061
29092
  problems.push(`custom_branch_policies=${String(policy?.custom_branch_policies)} (want false)`);
29062
29093
  }
29094
+ if (live.wait_timer !== desired.waitTimer) notes.push(`wait_timer=${live.wait_timer ?? "unset"} (want ${desired.waitTimer})`);
29063
29095
  const reviewers = (live.reviewers ?? []).map(reviewerKey).sort();
29064
- if (reviewers.length !== 0) problems.push(`reviewers=${reviewers.join(", ")} (want none)`);
29065
- return problems;
29096
+ if (reviewers.length !== 0) notes.push(`reviewers=${reviewers.join(", ")} (want none)`);
29097
+ return { environment: desired.name, missing: false, problems, notes };
29098
+ }
29099
+ function environmentBody(spec) {
29100
+ return {
29101
+ wait_timer: spec.waitTimer,
29102
+ reviewers: spec.reviewers,
29103
+ deployment_branch_policy: {
29104
+ protected_branches: spec.deploymentBranchPolicy.protectedBranches,
29105
+ custom_branch_policies: spec.deploymentBranchPolicy.customBranchPolicies
29106
+ }
29107
+ };
29108
+ }
29109
+ var PLAN_GATED_PROTECTION_RE = /billing plan/i;
29110
+ function isPlanGatedProtectionError(error) {
29111
+ return PLAN_GATED_PROTECTION_RE.test(String(error?.message ?? error));
29112
+ }
29113
+ async function reconcileRepoEnvironments(repo, releaseTrack, client) {
29114
+ const raw = await client.rest("GET", `repos/${repo}/environments`);
29115
+ const live = new Map(asEnvironmentList(raw).flatMap((entry) => entry.name ? [[entry.name, entry]] : []));
29116
+ const planned = provisionedEnvironmentSpecs(repo, releaseTrack);
29117
+ const created = [];
29118
+ const updated = [];
29119
+ const skipped = [];
29120
+ const planGated = [];
29121
+ for (const spec of planned) {
29122
+ const current = live.get(spec.name);
29123
+ const drift = environmentDrift(current, spec);
29124
+ if (drift.problems.length === 0 && drift.notes.length === 0) {
29125
+ skipped.push(spec.name);
29126
+ continue;
29127
+ }
29128
+ const path2 = `repos/${repo}/environments/${encodeURIComponent(spec.name)}`;
29129
+ let gatedProtections = [];
29130
+ try {
29131
+ await client.rest("PUT", path2, { body: environmentBody(spec) });
29132
+ } catch (error) {
29133
+ if (!isPlanGatedProtectionError(error)) throw error;
29134
+ await client.rest("PUT", path2, {
29135
+ body: {
29136
+ deployment_branch_policy: {
29137
+ protected_branches: spec.deploymentBranchPolicy.protectedBranches,
29138
+ custom_branch_policies: spec.deploymentBranchPolicy.customBranchPolicies
29139
+ }
29140
+ }
29141
+ });
29142
+ gatedProtections = ["wait_timer", "reviewers"];
29143
+ }
29144
+ if (gatedProtections.length) planGated.push({ environment: spec.name, protections: gatedProtections });
29145
+ (current ? updated : created).push(spec.name);
29146
+ }
29147
+ return { repo, planned, created, updated, skipped, planGated };
29066
29148
  }
29067
29149
  async function verifyRepoEnvironments(repo, releaseTrack, client) {
29068
29150
  const raw = await client.rest("GET", `repos/${repo}/environments`);
29069
29151
  const live = new Map(asEnvironmentList(raw).flatMap((entry) => entry.name ? [[entry.name, entry]] : []));
29070
29152
  return provisionedEnvironmentSpecs(repo, releaseTrack).map((spec) => {
29071
- const problems = environmentDrift(live.get(spec.name), spec);
29072
- return { environment: spec.name, missing: !live.has(spec.name), problems };
29153
+ const drift = environmentDrift(live.get(spec.name), spec);
29154
+ return { environment: spec.name, missing: !live.has(spec.name), problems: drift.problems, notes: drift.notes };
29073
29155
  });
29074
29156
  }
29075
29157
 
@@ -29320,7 +29402,7 @@ async function verifyBootstrap(repo, repoClass, deps, releaseTrack) {
29320
29402
  checks.push({
29321
29403
  ok: drift.problems.length === 0,
29322
29404
  label: `repository environment protected: ${drift.environment}`,
29323
- detail: drift.problems.length ? drift.problems.join("; ") : void 0
29405
+ detail: drift.problems.length ? drift.problems.join("; ") : drift.notes.length ? `advisory: ${drift.notes.join("; ")}` : void 0
29324
29406
  });
29325
29407
  }
29326
29408
  for (const spec of repoEnvironmentSpecs(repo, releaseTrack ?? (repoClass === "content" ? "trunk" : "full")).filter((entry) => entry.exception)) {
@@ -29767,7 +29849,7 @@ function registerBootstrapCommands(program3) {
29767
29849
  }
29768
29850
  if (findings.some((f) => f.state !== "waived")) process.exitCode = 1;
29769
29851
  });
29770
- bootstrap.command("apply <repo>").description("run from the MMI-Hub repo root: idempotent seed apply from skills/bootstrap/seeds/manifest.json; dry-run unless --execute (live, master-gated)").addOption(new Option("--class <class>", "deployable | content").default("deployable").choices(["deployable", "content"])).addOption(new Option("--project-type <type>", `${PROJECT_TYPES.join(" | ")} (capability shape)`).choices([...PROJECT_TYPES])).addOption(new Option("--deploy-model <model>", `${DEPLOY_MODELS.join(" | ")} (release/deploy path)`).choices([...DEPLOY_MODELS])).addOption(new Option("--release-track <track>", `${RELEASE_TRACKS.join(" | ")} (branch topology; direct skips rc)`).choices([...RELEASE_TRACKS])).option("--execute", "LIVE apply via gh (master-gated) \u2014 stamps seed files + labels into the repo").option("--only <target>", "deliver ONLY this manifest target (#3818) \u2014 one file, no labels/ruleset/registry writes").option("--var <KEY=VALUE...>", "placeholder values for repo-owned templates (repeatable)").option("--json", "machine-readable output").action(async (repo, cmdOpts) => {
29852
+ bootstrap.command("apply <repo>").description("run from the MMI-Hub repo root: idempotent seed apply from skills/bootstrap/seeds/manifest.json; dry-run unless --execute (live, master-gated)").addOption(new Option("--class <class>", "deployable | content").default("deployable").choices(["deployable", "content"])).addOption(new Option("--project-type <type>", `${PROJECT_TYPES.join(" | ")} (capability shape)`).choices([...PROJECT_TYPES])).addOption(new Option("--deploy-model <model>", `${DEPLOY_MODELS.join(" | ")} (release/deploy path)`).choices([...DEPLOY_MODELS])).addOption(new Option("--release-track <track>", `${RELEASE_TRACKS.join(" | ")} (branch topology; direct skips rc)`).choices([...RELEASE_TRACKS])).option("--execute", "LIVE apply via gh (master-gated) \u2014 stamps seed files + labels into the repo").option("--only <target>", "deliver ONLY this manifest target (#3818) \u2014 one file, no labels/ruleset/registry writes; or the special target environments (#5035) to run the deployment-environment reconcile alone (dry-run classifies, --execute writes)").option("--var <KEY=VALUE...>", "placeholder values for repo-owned templates (repeatable)").option("--json", "machine-readable output").action(async (repo, cmdOpts) => {
29771
29853
  const o = {
29772
29854
  class: rawValue("--class", "deployable"),
29773
29855
  projectType: rawValue("--project-type", ""),
@@ -29788,6 +29870,45 @@ function registerBootstrapCommands(program3) {
29788
29870
  } catch (e) {
29789
29871
  return fail(`bootstrap apply: ${e.message}`);
29790
29872
  }
29873
+ let effectiveTrack = bootstrapReleaseTrack;
29874
+ if (!o.releaseTrack) {
29875
+ try {
29876
+ const meta = await fetchProjectBySlug(parsedRepo.slug, registryClientDeps(await loadConfig()));
29877
+ effectiveTrack = resolveReleaseTrack(metaWithDeclaredClass(meta, o.class), void 0, repo);
29878
+ } catch {
29879
+ }
29880
+ }
29881
+ if (o.only.trim() === "environments") {
29882
+ const client = defaultGitHubClient();
29883
+ const envJson = { repo, track: effectiveTrack };
29884
+ if (!o.execute) {
29885
+ const drift = await verifyRepoEnvironments(repo, effectiveTrack, client);
29886
+ const classified = drift.map(classifyEnvironmentDrift);
29887
+ envJson.plan = classified;
29888
+ if (o.json) console.log(JSON.stringify(envJson, null, 2));
29889
+ else {
29890
+ console.log(`bootstrap apply --only environments \u2014 dry-run (${repo}, track ${effectiveTrack}); no writes:`);
29891
+ for (const c of classified) console.log(` ${c.action} ${c.environment} \u2014 ${c.reason}`);
29892
+ console.log(" (plan-gated protections \u2014 wait_timer/reviewers the org plan rejects \u2014 are reported at --execute)");
29893
+ }
29894
+ } else {
29895
+ const envResult = await reconcileRepoEnvironments(repo, effectiveTrack, client);
29896
+ const lines = [];
29897
+ if (envResult.created.length) lines.push(`environments created: ${envResult.created.join(", ")}`);
29898
+ if (envResult.updated.length) lines.push(`environments updated: ${envResult.updated.join(", ")}`);
29899
+ if (envResult.skipped.length) lines.push(`environments current: ${envResult.skipped.join(", ")}`);
29900
+ for (const gated of envResult.planGated) {
29901
+ lines.push(`environment ${gated.environment}: plan-gated protections (${gated.protections.join(", ")} not settable on this org plan \u2014 policy-only provisioned)`);
29902
+ }
29903
+ envJson.result = { created: envResult.created, updated: envResult.updated, skipped: envResult.skipped, planGated: envResult.planGated };
29904
+ if (o.json) console.log(JSON.stringify(envJson, null, 2));
29905
+ else {
29906
+ console.log(`LIVE environments apply to ${repo}:`);
29907
+ lines.forEach((l) => console.log(` ${l}`));
29908
+ }
29909
+ }
29910
+ return;
29911
+ }
29791
29912
  const manifestPath = "skills/bootstrap/seeds/manifest.json";
29792
29913
  if (!(0, import_node_fs38.existsSync)(manifestPath)) return fail(`bootstrap apply: ${manifestPath} not found; bootstrap runs from the MMI-Hub repo root by design \u2014 it stamps org-level resources (Project, Ruleset, secrets, access) through the GitHub App, which is only authorized from the Hub checkout`);
29793
29914
  const seedSource = await resolveHubSeedSource(execGitForSeedSource);
@@ -30037,6 +30158,19 @@ ${onlyManagedBlock ? `Only the marker-bounded Hub-managed block inside repo-owne
30037
30158
  }
30038
30159
  }
30039
30160
  }
30161
+ if (o.execute && !onlyTarget) {
30162
+ try {
30163
+ const envResult = await reconcileRepoEnvironments(repo, effectiveTrack, defaultGitHubClient());
30164
+ if (envResult.created.length) applied.push(`environments created: ${envResult.created.join(", ")}`);
30165
+ if (envResult.updated.length) applied.push(`environments updated: ${envResult.updated.join(", ")}`);
30166
+ if (envResult.skipped.length) applied.push(`environments current: ${envResult.skipped.join(", ")}`);
30167
+ for (const gated of envResult.planGated) {
30168
+ applied.push(`environment ${gated.environment}: plan-gated protections (${gated.protections.join(", ")} not settable on this org plan \u2014 policy-only provisioned)`);
30169
+ }
30170
+ } catch (e) {
30171
+ applied.push(`environments (failed: ${e.message})`);
30172
+ }
30173
+ }
30040
30174
  if (o.execute && !onlyTarget) {
30041
30175
  for (const l of manifest.labels) {
30042
30176
  try {
@@ -36730,34 +36864,6 @@ var surfaces_default = {
36730
36864
  },
36731
36865
  publishVisibility: "public"
36732
36866
  },
36733
- {
36734
- id: "mmi-updater-compat",
36735
- classification: "packaging",
36736
- kind: "cli",
36737
- ownerPath: "packages/updater-compat/package.json",
36738
- deliveryPath: "packages/updater-compat/package.json",
36739
- delivery: "npm",
36740
- applicability: "one-window deprecated @mutmutco/updater / mmi-updater wrapper delegating to the exact coordinated @mutmutco/hub version",
36741
- versionCoordinated: true,
36742
- versionPaths: [
36743
- {
36744
- path: "packages/updater-compat/package.json",
36745
- pointer: "version"
36746
- },
36747
- {
36748
- path: "packages/updater-compat/package.json",
36749
- pointer: "dependencies.@mutmutco/hub"
36750
- }
36751
- ],
36752
- additionalPaths: [
36753
- "packages/updater-compat/dist"
36754
- ],
36755
- artifactIdentity: {
36756
- kind: "npm-pack",
36757
- packagePath: "packages/updater-compat"
36758
- },
36759
- publishVisibility: "public"
36760
- },
36761
36867
  {
36762
36868
  id: "mmi-cli-lock",
36763
36869
  classification: "packaging",
@@ -39519,7 +39625,7 @@ withExamples(mutating(
39519
39625
  return fail("worktree create: --claim/--for need an issue-ref argument (e.g. worktree create 2687 --claim)");
39520
39626
  }
39521
39627
  const repoRoot2 = await primaryCheckoutRoot(process.cwd()) ?? process.cwd();
39522
- const wtPath = o.path ?? defaultWorktreePath(repoRoot2, branch);
39628
+ const wtPath = o.path ? (0, import_node_path46.resolve)(o.path) : defaultWorktreePath(repoRoot2, branch);
39523
39629
  const { base: fallbackBase, fetchBranch, preferRemote } = resolveWorktreeBase(fromRef, o.remote);
39524
39630
  let base = fallbackBase;
39525
39631
  step = `fetch the base ref ${fromRef}`;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mutmutco/cli",
3
- "version": "3.137.0",
3
+ "version": "3.139.0",
4
4
  "description": "MMI Future CLI — the org dev toolbox and shared cross-IDE engine for every registry-declared MMI coding surface.",
5
5
  "type": "module",
6
6
  "license": "UNLICENSED",