@icebreakers/monorepo 5.5.9 → 5.5.10

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/cli.mjs CHANGED
@@ -1,4 +1,4 @@
1
- import { d as message, l as version, m as logger, p as supportedLocales, r as cliName, t as initToolingTargets, u as localize, y as fs } from "./types-W9fwiyx8.mjs";
1
+ import { d as message, l as version, m as logger, p as supportedLocales, r as cliName, t as initToolingTargets, u as localize, y as fs } from "./types-m8JLwKzl.mjs";
2
2
  import { s as resolveCommandConfig } from "./config-p842Knhq.mjs";
3
3
  import path from "pathe";
4
4
  import process from "node:process";
@@ -10,7 +10,7 @@ import { Command, Option } from "commander";
10
10
  async function handleAiPromptCreate(cwd, opts) {
11
11
  const [{ input }, { createTimestampFolderName, defaultAgenticBaseDir, generateAgenticTemplate, generateAgenticTemplates, loadAgenticTasks }, { resolveCommandConfig }] = await Promise.all([
12
12
  import("@icebreakers/monorepo-templates"),
13
- import("./commands-BCix_gOD.mjs").then((n) => n.t),
13
+ import("./commands-CIzCAxyY.mjs").then((n) => n.t),
14
14
  import("./config-p842Knhq.mjs").then((n) => n.n)
15
15
  ]);
16
16
  const aiConfig = await resolveCommandConfig("ai", cwd);
@@ -125,7 +125,7 @@ async function emitConfigInspection(inspection, opts, cwd) {
125
125
  }
126
126
  function registerConfigCommands(program, cwd) {
127
127
  program.command("config").alias("cfg").description(localize("Configuration commands", "配置命令")).command("inspect").description(localize("Show the active repoctl config file and resolved configuration", "输出当前 repoctl 配置文件和已解析配置")).alias("i").option("--json", localize("Output JSON for scripts", "输出 JSON,方便脚本消费")).option("--markdown", localize("Output Markdown", "输出 Markdown,方便粘贴到 issue 或 PR")).option("--out <file>", localize("Write output to a file", "把当前输出写入文件")).option("--redact", localize("Redact cwd, configDir, and home paths", "脱敏 cwd/configDir/home 绝对路径后再输出")).action(async (opts) => {
128
- const { inspectMonorepoConfig } = await import("./commands-BCix_gOD.mjs").then((n) => n.t);
128
+ const { inspectMonorepoConfig } = await import("./commands-CIzCAxyY.mjs").then((n) => n.t);
129
129
  await emitConfigInspection(await inspectMonorepoConfig(cwd), opts, cwd);
130
130
  });
131
131
  }
@@ -445,23 +445,23 @@ async function emitEnvSupportBundle(bundle, opts, cwd) {
445
445
  function registerEnvCommands(program, cwd) {
446
446
  const envCommand = program.command("env").alias("e").description(localize("Environment and support commands", "环境命令"));
447
447
  envCommand.command("info").description(localize("Show environment information for the current repository", "输出当前仓库环境信息")).alias("i").option("--json", localize("Output JSON for scripts", "输出 JSON,方便脚本消费")).option("--markdown", localize("Output Markdown", "输出 Markdown,方便粘贴到 issue 或 PR")).option("--out <file>", localize("Write output to a file", "把当前输出写入文件")).option("--redact", localize("Redact workspace, cwd, and home paths", "脱敏 workspace/cwd/home 绝对路径后再输出")).action(async (opts) => {
448
- const { collectEnvInfo } = await import("./commands-BCix_gOD.mjs").then((n) => n.t);
448
+ const { collectEnvInfo } = await import("./commands-CIzCAxyY.mjs").then((n) => n.t);
449
449
  await emitEnvInfo(await collectEnvInfo(cwd), opts, cwd);
450
450
  });
451
451
  envCommand.command("snapshot").description(localize("Create a support snapshot with environment, doctor, and check data", "输出排障快照,包含环境、doctor 和 check 计划")).alias("s").option("--json", localize("Output JSON for scripts", "输出 JSON,方便脚本消费")).option("--markdown", localize("Output Markdown", "输出 Markdown,方便粘贴到 issue 或 PR")).option("--out <file>", localize("Write output to a file", "把当前输出写入文件")).option("--redact", localize("Redact workspace, cwd, and home paths", "脱敏 workspace/cwd/home 绝对路径后再输出")).option("--strict", localize("Fail when doctor reports a failure or warning", "输出快照后,如果 doctor 有 fail 或 warn 则返回失败码")).action(async (opts) => {
452
- const { collectEnvSnapshot } = await import("./commands-BCix_gOD.mjs").then((n) => n.t);
452
+ const { collectEnvSnapshot } = await import("./commands-CIzCAxyY.mjs").then((n) => n.t);
453
453
  await emitEnvSnapshot(await collectEnvSnapshot(cwd), opts, cwd);
454
454
  });
455
455
  envCommand.command("paths").description(localize("Show important repository and report paths", "输出当前仓库关键路径和报告建议位置")).alias("p").option("--json", localize("Output JSON for scripts", "输出 JSON,方便脚本消费")).option("--markdown", localize("Output Markdown", "输出 Markdown,方便粘贴到 issue 或 PR")).option("--out <file>", localize("Write output to a file", "把当前输出写入文件")).option("--redact", localize("Redact workspace, cwd, and home paths", "脱敏 workspace/cwd/home 绝对路径后再输出")).action(async (opts) => {
456
- const { collectEnvPaths } = await import("./commands-BCix_gOD.mjs").then((n) => n.t);
456
+ const { collectEnvPaths } = await import("./commands-CIzCAxyY.mjs").then((n) => n.t);
457
457
  await emitEnvPaths(await collectEnvPaths(cwd), opts, cwd);
458
458
  });
459
459
  envCommand.command("support").description(localize("Create a complete support bundle", "输出完整排障包,包含环境、路径、配置、doctor 和 check 计划")).alias("b").option("--json", localize("Output JSON for scripts", "输出 JSON,方便脚本消费")).option("--markdown", localize("Output Markdown", "输出 Markdown,方便粘贴到 issue 或 PR")).option("--out <file>", localize("Write output to a file", "把当前输出写入文件")).option("--redact", localize("Redact workspace, cwd, and home paths", "脱敏 workspace/cwd/home 绝对路径后再输出")).option("--strict", localize("Fail when doctor reports a failure or warning", "输出排障包后,如果 doctor 有 fail 或 warn 则返回失败码")).action(async (opts) => {
460
- const { collectEnvSupportBundle } = await import("./commands-BCix_gOD.mjs").then((n) => n.t);
460
+ const { collectEnvSupportBundle } = await import("./commands-CIzCAxyY.mjs").then((n) => n.t);
461
461
  await emitEnvSupportBundle(await collectEnvSupportBundle(cwd), opts, cwd);
462
462
  });
463
463
  envCommand.command("mirror").description(localize("Configure the VS Code binary mirror", "设置 VS Code binary mirror")).alias("m").action(async () => {
464
- const { setVscodeBinaryMirror } = await import("./commands-BCix_gOD.mjs").then((n) => n.t);
464
+ const { setVscodeBinaryMirror } = await import("./commands-CIzCAxyY.mjs").then((n) => n.t);
465
465
  await setVscodeBinaryMirror(cwd);
466
466
  logger.success(localize("Environment mirror finished.", "环境镜像完成。"));
467
467
  });
@@ -470,7 +470,7 @@ function registerEnvCommands(program, cwd) {
470
470
  //#region src/cli/commands/package.ts
471
471
  function registerPackageCommands(program, cwd) {
472
472
  program.command("package").alias("pkg").description(localize("Package commands", "子包命令")).command("create").description(localize("Create a new workspace package", "创建一个新的子包")).alias("new").argument("[name]").option("-t, --template <template>", localize("Use a template key without prompting", "直接使用指定模板,跳过模板选择")).option("--dry-run", localize("Preview without writing files", "预览将要创建的目录与 package 信息,不写入文件")).option("--json", localize("Output JSON; implies --dry-run", "以 JSON 输出创建预览,隐含 --dry-run")).option("--out <file>", localize("Write the preview to a file; implies --dry-run", "把创建预览写入文件,隐含 --dry-run")).action(async (inputName, opts) => {
473
- const { runCreateFlow } = await import("./create-flow-ghL18gPo.mjs");
473
+ const { runCreateFlow } = await import("./create-flow-C811m80z.mjs");
474
474
  const result = await runCreateFlow(cwd, inputName, {
475
475
  ...opts.template !== void 0 ? { template: opts.template } : {},
476
476
  ...opts.dryRun || opts.json || opts.out ? { dryRun: true } : {},
@@ -500,14 +500,15 @@ async function resolveReleaseOptions(cwd) {
500
500
  }
501
501
  function registerReleaseCommands(program, cwd) {
502
502
  const releaseCommand = program.command("release").description(localize("Release and pnpm versioning commands", "发布与 pnpm versioning 工具集"));
503
- releaseCommand.command("ci").description(localize("Prepare, publish, or recover versions in CI", "在 CI 中自动准备、发布和恢复版本")).option("--mode <mode>", localize("auto / prepare / publish / publish-unpublished / reconcile", "auto / prepare / publish / publish-unpublished / reconcile"), "auto").option("--package <name>", localize("Package used by publish-unpublished mode", "publish-unpublished 使用的 package")).option("--version <version>", localize("Version used by publish-unpublished mode", "publish-unpublished 使用的版本")).option("--dry-run", localize("Preview reconcile changes without updating GitHub", "只预览 reconcile 变更,不更新 GitHub")).action(async (opts) => {
503
+ releaseCommand.command("ci").description(localize("Prepare, publish, or recover versions in CI", "在 CI 中自动准备、发布和恢复版本")).option("--mode <mode>", localize("auto / prepare / publish / publish-unpublished / reconcile", "auto / prepare / publish / publish-unpublished / reconcile"), "auto").option("--package <name>", localize("Package used by publish-unpublished mode", "publish-unpublished 使用的 package")).option("--version <version>", localize("Version used by publish-unpublished mode", "publish-unpublished 使用的版本")).option("--source-sha <sha>", localize("Recover a prepared release from its original main commit", "从 main 原始提交恢复整批发布")).option("--dry-run", localize("Preview reconcile changes without updating GitHub", "只预览 reconcile 变更,不更新 GitHub")).action(async (opts) => {
504
504
  await runReleaseAction(async () => {
505
- const { releaseCi } = await import("./commands-BCix_gOD.mjs").then((n) => n.t);
505
+ const { releaseCi } = await import("./commands-CIzCAxyY.mjs").then((n) => n.t);
506
506
  await releaseCi({
507
507
  ...await resolveReleaseOptions(cwd),
508
508
  ...opts.mode ? { mode: opts.mode } : {},
509
509
  ...opts.package ? { packageName: opts.package } : {},
510
510
  ...opts.version ? { packageVersion: opts.version } : {},
511
+ ...opts.sourceSha ? { sourceSha: opts.sourceSha } : {},
511
512
  ...opts.dryRun ? { dryRun: true } : {}
512
513
  });
513
514
  logger.success(localize("Release CI finished.", "Release CI 完成。"));
@@ -515,7 +516,7 @@ function registerReleaseCommands(program, cwd) {
515
516
  });
516
517
  releaseCommand.command("notes").description(localize("Manage GitHub Release notes", "维护 GitHub Release 正文")).command("repair").description(localize("Rebuild GitHub Release notes from the changelog for each release tag", "按每个发布 tag 对应的 changelog 重建 GitHub Release 正文")).option("--all", localize("Repair every recognized GitHub Release", "修复所有可识别的 GitHub Release")).option("--tag <package@version>", localize("Repair only the specified package@version", "只修复指定 package@version")).option("--dry-run", localize("Generate and summarize without updating GitHub Releases", "只生成并统计,不更新 GitHub Release")).option("--create-missing", localize("Create a missing GitHub Release after validating the published package and tag", "核验已发布 package 和 tag 后补建缺失的 GitHub Release")).action(async (opts) => {
517
518
  await runReleaseAction(async () => {
518
- const { repairReleaseNotes } = await import("./commands-BCix_gOD.mjs").then((n) => n.t);
519
+ const { repairReleaseNotes } = await import("./commands-CIzCAxyY.mjs").then((n) => n.t);
519
520
  const result = await repairReleaseNotes({
520
521
  cwd,
521
522
  ...opts.all ? { all: true } : {},
@@ -528,7 +529,7 @@ function registerReleaseCommands(program, cwd) {
528
529
  });
529
530
  const stableCommand = releaseCommand.command("stable").description(localize("Run a stable release from main", "在 main 分支执行正式发布")).action(async () => {
530
531
  await runReleaseAction(async () => {
531
- const { releaseCi } = await import("./commands-BCix_gOD.mjs").then((n) => n.t);
532
+ const { releaseCi } = await import("./commands-CIzCAxyY.mjs").then((n) => n.t);
532
533
  await releaseCi({
533
534
  ...await resolveReleaseOptions(cwd),
534
535
  mode: "publish"
@@ -538,7 +539,7 @@ function registerReleaseCommands(program, cwd) {
538
539
  });
539
540
  stableCommand.command("prepare").description(localize("Consume pnpm change intents and prepare a Release PR", "消费 pnpm change intents 并准备 Release PR")).action(async () => {
540
541
  await runReleaseAction(async () => {
541
- const { releaseCi } = await import("./commands-BCix_gOD.mjs").then((n) => n.t);
542
+ const { releaseCi } = await import("./commands-CIzCAxyY.mjs").then((n) => n.t);
542
543
  await releaseCi({
543
544
  ...await resolveReleaseOptions(cwd),
544
545
  mode: "prepare"
@@ -548,7 +549,7 @@ function registerReleaseCommands(program, cwd) {
548
549
  });
549
550
  stableCommand.command("publish").description(localize("Publish versions on main that are not yet on npm", "发布 main 分支上尚未发布的包")).action(async () => {
550
551
  await runReleaseAction(async () => {
551
- const { releaseCi } = await import("./commands-BCix_gOD.mjs").then((n) => n.t);
552
+ const { releaseCi } = await import("./commands-CIzCAxyY.mjs").then((n) => n.t);
552
553
  await releaseCi({
553
554
  ...await resolveReleaseOptions(cwd),
554
555
  mode: "publish"
@@ -559,21 +560,21 @@ function registerReleaseCommands(program, cwd) {
559
560
  const preCommand = releaseCommand.command("pre").description(localize("Run or manage prereleases", "执行或管理 prerelease 发布"));
560
561
  preCommand.command("publish").alias("run").description(localize("Publish a prerelease from an alpha, beta, rc, or next lane", "在 alpha/beta/rc/next 分支发布 prerelease")).action(async () => {
561
562
  await runReleaseAction(async () => {
562
- const { releaseCi } = await import("./commands-BCix_gOD.mjs").then((n) => n.t);
563
+ const { releaseCi } = await import("./commands-CIzCAxyY.mjs").then((n) => n.t);
563
564
  await releaseCi(await resolveReleaseOptions(cwd));
564
565
  logger.success(localize("Prerelease finished.", "预发布完成。"));
565
566
  });
566
567
  });
567
568
  preCommand.command("enter").description(localize("Enter a pnpm prerelease lane", "进入 pnpm prerelease lane")).argument("<tag>", localize("alpha / beta / rc / next", "alpha / beta / rc / next")).action(async (tag) => {
568
569
  await runReleaseAction(async () => {
569
- const { enterPrerelease } = await import("./commands-BCix_gOD.mjs").then((n) => n.t);
570
+ const { enterPrerelease } = await import("./commands-CIzCAxyY.mjs").then((n) => n.t);
570
571
  await enterPrerelease(tag, { cwd });
571
572
  logger.success(localize(`Entered ${tag} prerelease mode.`, `已进入 ${tag} 预发布模式。`));
572
573
  });
573
574
  });
574
575
  preCommand.command("exit").description(localize("Exit the pnpm prerelease lane", "退出 pnpm prerelease lane")).action(async () => {
575
576
  await runReleaseAction(async () => {
576
- const { exitPrerelease } = await import("./commands-BCix_gOD.mjs").then((n) => n.t);
577
+ const { exitPrerelease } = await import("./commands-CIzCAxyY.mjs").then((n) => n.t);
577
578
  await exitPrerelease({ cwd });
578
579
  logger.success(localize("Exited prerelease mode.", "已退出预发布模式。"));
579
580
  });
@@ -590,7 +591,7 @@ const skillTargets = [
590
591
  ];
591
592
  function registerSkillsCommands(program, cwd) {
592
593
  program.command("skills").alias("sk").description(localize("AI skill commands", "技能工具集")).command("sync").description(localize("Synchronize the repoctl skill to global agent directories", "同步 resources/skills/repoctl 到全局目录")).alias("s").option("--codex", localize("Synchronize to ~/.codex/skills", "同步到 ~/.codex/skills")).option("--claude", localize("Synchronize to ~/.claude/skills", "同步到 ~/.claude/skills")).option("--cursor", localize("Synchronize to ~/.cursor/skills", "同步到 ~/.cursor/skills")).option("--agents", localize("Synchronize to ~/.agents/skills", "同步到 ~/.agents/skills")).option("--grok", localize("Synchronize to ~/.grok/skills", "同步到 ~/.grok/skills")).option("--all", localize("Synchronize every target", "同步全部目标")).action(async (opts) => {
593
- const { syncSkills } = await import("./commands-BCix_gOD.mjs").then((n) => n.t);
594
+ const { syncSkills } = await import("./commands-CIzCAxyY.mjs").then((n) => n.t);
594
595
  const selected = /* @__PURE__ */ new Set();
595
596
  if (opts.all) for (const target of skillTargets) selected.add(target);
596
597
  else {
@@ -713,7 +714,7 @@ function registerTemplatesCommands(program) {
713
714
  program.command("templates").alias("tpl").description(localize("List the built-in templates", "列出可用的内置模板")).argument("[key]", localize("Show details for a template key", "查看指定模板详情")).option("-c, --category <category>", localize("Filter by library, app, service, docs, or tool", "按模板分类过滤:library / app / service / docs / tool")).option("--check", localize("Check built-in template metadata and directories", "检查内置模板元数据、目录和临时文件")).option("--json", localize("Output JSON for scripts", "输出 JSON,方便脚本消费")).option("--markdown", localize("Output Markdown for documentation", "输出 Markdown,方便同步文档")).option("--out <file>", localize("Write output to a file", "把当前输出写入文件")).action(async (key, opts) => {
714
715
  const { getTemplateChoice, getTemplateChoices, isTemplateCategory, suggestTemplateKey, templateCategories } = await import("@icebreakers/monorepo-templates");
715
716
  if (opts.check) {
716
- const { checkTemplates } = await import("./commands-BCix_gOD.mjs").then((n) => n.t);
717
+ const { checkTemplates } = await import("./commands-CIzCAxyY.mjs").then((n) => n.t);
717
718
  const report = await checkTemplates();
718
719
  if (opts.json) await emitTemplateOutput(JSON.stringify(report, null, 2), opts);
719
720
  else await emitTemplateOutput(formatTemplateHealthReport(report, !opts.out), opts);
@@ -792,7 +793,7 @@ function normalizeToolingTargets(tooling) {
792
793
  function registerToolingCommands(program, cwd) {
793
794
  program.command("tooling").alias("tg").description(localize("Tooling configuration commands", "工程化配置命令")).command("init").description(localize(`Generate tooling configuration (${initToolingTargets.join(", ")})`, `生成 tooling 配置(可选值:${initToolingTargets.join(", ")})`)).alias("i").argument("[tooling...]").option("-a, --all", localize("Generate every tooling configuration", "生成全部 tooling 配置")).option("-f, --force", localize("Overwrite existing tooling configuration files", "覆盖已存在的 tooling 配置文件")).action(async (tooling = [], opts) => {
794
795
  const normalizedTooling = normalizeToolingTargets(tooling);
795
- const { initTooling } = await import("./commands-BCix_gOD.mjs").then((n) => n.t);
796
+ const { initTooling } = await import("./commands-CIzCAxyY.mjs").then((n) => n.t);
796
797
  await initTooling(cwd, {
797
798
  ...normalizedTooling ? { targets: normalizedTooling } : {},
798
799
  ...opts.all !== void 0 ? { all: opts.all } : {},
@@ -963,7 +964,7 @@ async function emitCheckPlan(plan, opts, cwd) {
963
964
  }
964
965
  function registerTopLevelCommands(program, cwd) {
965
966
  program.command("init").description(localize("Initialize the current workspace with recommended configuration", "初始化当前 workspace,并生成推荐配置")).option("--preset <preset>", localize("Initialization preset: minimal or standard", "初始化预设:minimal / standard"), "standard").option("-f, --force", localize("Overwrite existing tooling configuration files", "覆盖已存在的 tooling 配置文件")).option("--overwrite", localize("Overwrite existing managed files", "覆盖受管的已存在文件")).option("-y, --yes", localize("Use defaults without prompting; suitable for CI", "使用默认值跳过所有交互,适合 CI")).action(async (opts) => {
966
- const { init } = await import("./commands-BCix_gOD.mjs").then((n) => n.t);
967
+ const { init } = await import("./commands-CIzCAxyY.mjs").then((n) => n.t);
967
968
  await init(cwd, {
968
969
  ...opts.preset !== void 0 ? { preset: opts.preset } : {},
969
970
  ...opts.force !== void 0 ? { force: opts.force } : {},
@@ -974,7 +975,7 @@ function registerTopLevelCommands(program, cwd) {
974
975
  logger.info(localize("Next: run `pnpm install` and `pnpm build`.", "下一步:运行 `pnpm install` 和 `pnpm build`。"));
975
976
  });
976
977
  program.command("new").description(localize("Create a new package or application", "创建新的 package / app")).argument("[name]").option("-t, --template <template>", localize("Use a template key without prompting", "直接使用指定模板,跳过模板选择")).option("--dry-run", localize("Preview directories and package metadata without writing", "预览将要创建的目录与 package 信息,不写入文件")).option("--json", localize("Output the creation preview as JSON; implies --dry-run", "以 JSON 输出创建预览,隐含 --dry-run")).option("--out <file>", localize("Write the creation preview to a file; implies --dry-run", "把创建预览写入文件,隐含 --dry-run")).action(async (inputName, opts) => {
977
- const { runCreateFlow } = await import("./create-flow-ghL18gPo.mjs");
978
+ const { runCreateFlow } = await import("./create-flow-C811m80z.mjs");
978
979
  const result = await runCreateFlow(cwd, inputName, {
979
980
  ...opts.template !== void 0 ? { template: opts.template } : {},
980
981
  ...opts.dryRun || opts.json || opts.out ? { dryRun: true } : {},
@@ -992,10 +993,10 @@ function registerTopLevelCommands(program, cwd) {
992
993
  ...opts.staged !== void 0 ? { staged: opts.staged } : {},
993
994
  ...opts.editFile !== void 0 ? { editFile: opts.editFile } : {}
994
995
  };
995
- const { resolveRecommendedCheckPlan, runRecommendedCheck } = await import("./commands-BCix_gOD.mjs").then((n) => n.t);
996
+ const { resolveRecommendedCheckPlan, runRecommendedCheck } = await import("./commands-CIzCAxyY.mjs").then((n) => n.t);
996
997
  if (opts.dryRun || opts.json || opts.markdown || opts.out) {
997
998
  if (opts.full) {
998
- const { resolveFullWorkspaceCheckPlan } = await import("./commands-BCix_gOD.mjs").then((n) => n.t);
999
+ const { resolveFullWorkspaceCheckPlan } = await import("./commands-CIzCAxyY.mjs").then((n) => n.t);
999
1000
  await emitCheckPlan(await resolveFullWorkspaceCheckPlan(cwd), opts, cwd);
1000
1001
  return;
1001
1002
  }
@@ -1006,7 +1007,7 @@ function registerTopLevelCommands(program, cwd) {
1006
1007
  logger.success(localize("Checks finished.", "检查完成。"));
1007
1008
  });
1008
1009
  program.command("doctor").description(localize("Diagnose whether the current repository is ready to use", "诊断当前仓库是否适合直接开始使用")).option("--json", localize("Output JSON for CI or scripts", "输出 JSON 报告,方便 CI 或脚本消费")).option("--markdown", localize("Output Markdown for an issue or pull request", "输出 Markdown 报告,方便粘贴到 issue 或 PR")).option("--out <file>", localize("Write the diagnostic report to a file", "把诊断报告写入文件")).option("--redact", localize("Redact workspace, cwd, and home paths", "脱敏 workspace/cwd/home 绝对路径后再输出")).option("--strict", localize("Treat warnings as failures", "把 warning 也视为失败,适合 CI 门禁")).action(async (opts) => {
1009
- const { runDoctor } = await import("./commands-BCix_gOD.mjs").then((n) => n.t);
1010
+ const { runDoctor } = await import("./commands-CIzCAxyY.mjs").then((n) => n.t);
1010
1011
  const report = await runDoctor(cwd);
1011
1012
  await emitDoctorReport(report, opts, cwd);
1012
1013
  if (opts.out || opts.json || opts.markdown) {
@@ -1029,7 +1030,7 @@ function registerTopLevelCommands(program, cwd) {
1029
1030
  logger.success(localize("Doctor finished.", "Doctor 诊断完成。"));
1030
1031
  });
1031
1032
  program.command("upgrade").description(localize("Synchronize standard repository assets and scripts", "同步仓库标准资产与脚本")).option("-i,--interactive", localize("Select managed files interactively", "交互式选择受管文件")).option("-c,--core", localize("Synchronize core configuration without GitHub assets", "仅同步核心配置,跳过 GitHub 相关资产")).option("--outDir <dir>", localize("Output directory", "输出目录")).option("-s,--skip-overwrite", localize("Preserve existing files", "保留已存在文件")).option("-y, --yes", localize("Skip prompts and overwrite drifted managed assets", "跳过交互并覆盖 drifted 标准资产")).option("--overwrite", localize("Overwrite drifted managed assets", "覆盖 drifted 标准资产")).option("--no-overwrite", localize("Preserve drifted managed assets", "不覆盖 drifted 标准资产")).option("--overwrite-release", localize("Overwrite an unmarked custom release workflow", "覆盖未标记的自定义 release workflow")).action(async (opts) => {
1032
- const { upgradeMonorepo } = await import("./commands-BCix_gOD.mjs").then((n) => n.t);
1033
+ const { upgradeMonorepo } = await import("./commands-CIzCAxyY.mjs").then((n) => n.t);
1033
1034
  await upgradeMonorepo(normalizeCliOpts(cwd, opts));
1034
1035
  logger.success(localize("Upgrade finished.", "升级完成。"));
1035
1036
  });
@@ -1039,22 +1040,22 @@ function registerTopLevelCommands(program, cwd) {
1039
1040
  function registerVerifyCommands(program, cwd) {
1040
1041
  const verifyCommand = program.command("verify").alias("v").description(localize("Local verification commands", "本地校验工具集"));
1041
1042
  verifyCommand.command("pre-push").description(localize("Run build, test, and tsd checks for pushed changes", "按推送变更范围执行 build/test/tsd 校验")).alias("push").action(async () => {
1042
- const { verifyPrePush } = await import("./commands-BCix_gOD.mjs").then((n) => n.t);
1043
+ const { verifyPrePush } = await import("./commands-CIzCAxyY.mjs").then((n) => n.t);
1043
1044
  await verifyPrePush({ cwd });
1044
1045
  });
1045
1046
  verifyCommand.command("pre-commit").description(localize("Run lint-staged verification", "执行 lint-staged 校验")).alias("commit").action(async () => {
1046
- const { verifyPreCommit } = await import("./commands-BCix_gOD.mjs").then((n) => n.t);
1047
+ const { verifyPreCommit } = await import("./commands-CIzCAxyY.mjs").then((n) => n.t);
1047
1048
  await verifyPreCommit({ cwd });
1048
1049
  });
1049
1050
  verifyCommand.command("commit-msg").description(localize("Run commitlint verification", "执行 commitlint 校验")).alias("msg").argument("<edit-file>").action(async (editFile) => {
1050
- const { verifyCommitMsg } = await import("./commands-BCix_gOD.mjs").then((n) => n.t);
1051
+ const { verifyCommitMsg } = await import("./commands-CIzCAxyY.mjs").then((n) => n.t);
1051
1052
  await verifyCommitMsg({
1052
1053
  cwd,
1053
1054
  editFile
1054
1055
  });
1055
1056
  });
1056
1057
  verifyCommand.command("staged-typecheck").description(localize("Run typecheck in workspaces containing staged files", "按暂存文件所在 workspace 执行 typecheck")).alias("tc").argument("[files...]").action(async (files = []) => {
1057
- const { verifyStagedTypecheck } = await import("./commands-BCix_gOD.mjs").then((n) => n.t);
1058
+ const { verifyStagedTypecheck } = await import("./commands-CIzCAxyY.mjs").then((n) => n.t);
1058
1059
  verifyStagedTypecheck(files, { cwd });
1059
1060
  });
1060
1061
  }
@@ -1133,12 +1134,12 @@ async function emitWorkspaceList(result, opts) {
1133
1134
  function registerWorkspaceCommands(program, cwd) {
1134
1135
  const workspaceCommand = program.command("workspace").alias("ws").description(localize("Workspace commands", "工作区命令"));
1135
1136
  workspaceCommand.command("upgrade").description(localize("Upgrade or synchronize monorepo packages", "升级/同步 monorepo 相关包")).alias("up").option("-i,--interactive", localize("Select managed files interactively", "交互式选择受管文件")).option("-c,--core", localize("Synchronize core configuration without GitHub assets", "仅同步核心配置,跳过 GitHub 相关资产")).option("--outDir <dir>", localize("Output directory", "输出目录")).option("-s,--skip-overwrite", localize("Preserve existing files", "保留已存在文件")).option("-y, --yes", localize("Skip prompts and overwrite drifted managed assets", "跳过交互并覆盖 drifted 标准资产")).option("--overwrite", localize("Overwrite drifted managed assets", "覆盖 drifted 标准资产")).option("--no-overwrite", localize("Preserve drifted managed assets", "不覆盖 drifted 标准资产")).option("--overwrite-release", localize("Overwrite an unmarked custom release workflow", "覆盖未标记的自定义 release workflow")).action(async (opts) => {
1136
- const { upgradeMonorepo } = await import("./commands-BCix_gOD.mjs").then((n) => n.t);
1137
+ const { upgradeMonorepo } = await import("./commands-CIzCAxyY.mjs").then((n) => n.t);
1137
1138
  await upgradeMonorepo(normalizeCliOpts(cwd, opts));
1138
1139
  logger.success(localize("Workspace upgrade finished.", "Workspace 升级完成。"));
1139
1140
  });
1140
1141
  workspaceCommand.command("init").description(localize("Initialize workspace metadata and repository files", "初始化工作区元信息(README、package.json、pnpm intent、issue template)")).alias("i").action(async () => {
1141
- const { initMetadata } = await import("./commands-BCix_gOD.mjs").then((n) => n.t);
1142
+ const { initMetadata } = await import("./commands-CIzCAxyY.mjs").then((n) => n.t);
1142
1143
  await initMetadata(cwd);
1143
1144
  logger.success(localize("Workspace initialization finished.", "Workspace 初始化完成。"));
1144
1145
  });
@@ -1151,7 +1152,7 @@ function registerWorkspaceCommands(program, cwd) {
1151
1152
  }), opts);
1152
1153
  });
1153
1154
  workspaceCommand.command("clean").description(localize("Remove selected workspace packages", "清除选中的包")).alias("rm").option("-y, --yes", localize("Skip prompts and clean immediately", "跳过交互直接清理(等价 autoConfirm)")).option("--include-private", localize("Include private packages", "包含 private 包")).option("--pinned-version <version>", localize("Override the repoctl version written to the root package", "覆盖写入的 repoctl 版本")).action(async (opts) => {
1154
- const { cleanProjects } = await import("./commands-BCix_gOD.mjs").then((n) => n.t);
1155
+ const { cleanProjects } = await import("./commands-CIzCAxyY.mjs").then((n) => n.t);
1155
1156
  await cleanProjects(cwd, normalizeCleanOptions(opts));
1156
1157
  logger.success(localize("Workspace cleanup finished.", "Workspace 清理完成。"));
1157
1158
  });
@@ -1,6 +1,6 @@
1
1
  import { t as __exportAll } from "./rolldown-runtime-8H4AJuhK.mjs";
2
2
  import { i as getWorkspacePackages, n as getWorkspaceData, r as getWorkspacePackageSummaries, t as clearWorkspaceCache } from "./workspace-MCKewElu.mjs";
3
- import { b as isIgnorableFsError, c as package_default$1, f as resolveRepoctlLocale, i as packageDir, l as version$1, m as logger, n as assetsDir, o as templatesDir, t as initToolingTargets, u as localize, y as fs$1 } from "./types-W9fwiyx8.mjs";
3
+ import { b as isIgnorableFsError, c as package_default$1, f as resolveRepoctlLocale, i as packageDir, l as version$1, m as logger, n as assetsDir, o as templatesDir, t as initToolingTargets, u as localize, y as fs$1 } from "./types-m8JLwKzl.mjs";
4
4
  import { a as loadMonorepoConfig, c as resolveToolingConfig, i as getRepoctlConfigCandidates, o as loadMonorepoConfigDetails, s as resolveCommandConfig } from "./config-p842Knhq.mjs";
5
5
  import { f as defineTsconfigConfig } from "./tooling-BfXlmCi-.mjs";
6
6
  import gitUrlParse from "git-url-parse";
@@ -8,7 +8,7 @@ import { simpleGit } from "simple-git";
8
8
  import { findWorkspaceDir } from "@pnpm/find-workspace-dir";
9
9
  import path from "pathe";
10
10
  import process from "node:process";
11
- import { access, readFile, readdir, realpath, rename, rm, writeFile } from "node:fs/promises";
11
+ import { access, copyFile, mkdtemp, readFile, readdir, realpath, rename, rm, writeFile } from "node:fs/promises";
12
12
  import { execFileSync, spawnSync } from "node:child_process";
13
13
  import fs from "node:fs";
14
14
  import path$1 from "node:path";
@@ -16,9 +16,9 @@ import { checkbox, ensureTemplateAssetsPrepared, getAssetTargets, getTemplateCho
16
16
  import YAML, { isSeq, parseDocument } from "yaml";
17
17
  import { Buffer } from "node:buffer";
18
18
  import crypto, { createHash, randomUUID } from "node:crypto";
19
- import os from "node:os";
19
+ import os, { tmpdir } from "node:os";
20
20
  import pc from "picocolors";
21
- import { coerce, gte, minVersion, satisfies } from "semver";
21
+ import semver, { coerce, gte, minVersion, satisfies } from "semver";
22
22
  import { parse, stringify } from "comment-json";
23
23
  import { stripVTControlCharacters } from "node:util";
24
24
  import { performance } from "node:perf_hooks";
@@ -2663,6 +2663,79 @@ var ReleaseCommandError = class extends Error {
2663
2663
  }
2664
2664
  };
2665
2665
  //#endregion
2666
+ //#region src/commands/release/intents/index.ts
2667
+ function parseLedger(content) {
2668
+ const ledger = YAML.parse(content) ?? {};
2669
+ if (!ledger || typeof ledger !== "object" || Array.isArray(ledger)) throw new ReleaseCommandError("Invalid .changeset/ledger.yaml");
2670
+ return Object.fromEntries(Object.entries(ledger).map(([key, value]) => {
2671
+ const entry = value;
2672
+ const intents = Array.isArray(value) ? value : entry?.intents ?? [];
2673
+ if (value != null && !Array.isArray(value) && (typeof value !== "object" || typeof entry?.dir !== "string") || !Array.isArray(intents) || intents.some((id) => typeof id !== "string")) throw new ReleaseCommandError(`Invalid ledger entry: ${key}`);
2674
+ return [key, {
2675
+ ...typeof entry?.dir === "string" ? { dir: entry.dir } : {},
2676
+ intents
2677
+ }];
2678
+ }));
2679
+ }
2680
+ async function readLedger(cwd) {
2681
+ try {
2682
+ return parseLedger(await readFile(path.join(cwd, ".changeset/ledger.yaml"), "utf8"));
2683
+ } catch (error) {
2684
+ if (error.code === "ENOENT") return {};
2685
+ throw error;
2686
+ }
2687
+ }
2688
+ function parseIntent(content, filename) {
2689
+ const lines = content.replace(/^\uFEFF/, "").split(/\r?\n/);
2690
+ const end = lines.findIndex((line, index) => index > 0 && line.trim() === "---");
2691
+ if (lines[0]?.trim() !== "---" || end < 0) throw new ReleaseCommandError(`Invalid change intent frontmatter: ${filename}`);
2692
+ let data;
2693
+ try {
2694
+ data = YAML.parse(lines.slice(1, end).join("\n")) ?? {};
2695
+ } catch {
2696
+ throw new ReleaseCommandError(`Invalid change intent YAML: ${filename}`);
2697
+ }
2698
+ if (!data || typeof data !== "object" || Array.isArray(data) || Object.values(data).some((value) => ![
2699
+ "none",
2700
+ "patch",
2701
+ "minor",
2702
+ "major"
2703
+ ].includes(String(value)))) throw new ReleaseCommandError(`Invalid change intent bump type: ${filename}`);
2704
+ return Object.entries(data);
2705
+ }
2706
+ /** Only unconsumed release requests count; declines and resurrected prose do not. */
2707
+ async function readPendingIntents(cwd) {
2708
+ let files;
2709
+ try {
2710
+ files = await readdir(path.join(cwd, ".changeset"), { withFileTypes: true });
2711
+ } catch (error) {
2712
+ if (error.code === "ENOENT") return [];
2713
+ throw error;
2714
+ }
2715
+ const root = await realpath(cwd);
2716
+ const ledger = await readLedger(cwd);
2717
+ const config = YAML.parse(await readFile(path.join(cwd, "pnpm-workspace.yaml"), "utf8"));
2718
+ const workspace = await getWorkspacePackages(cwd, { ignorePrivatePackage: false });
2719
+ const pending = [];
2720
+ for (const file of files.sort((a, b) => a.name.localeCompare(b.name))) {
2721
+ if (!file.isFile() || !file.name.endsWith(".md") || file.name.toLowerCase() === "readme.md") continue;
2722
+ const filename = `.changeset/${file.name}`;
2723
+ const releases = parseIntent(await readFile(path.join(cwd, filename), "utf8"), filename);
2724
+ let active = false;
2725
+ for (const [reference, bump] of releases) {
2726
+ if (bump === "none") continue;
2727
+ const pkg = workspace.find((item) => item.manifest.name === reference || path.relative(root, item.rootDir) === reference.replace(/^\.\//, ""));
2728
+ if (!pkg) throw new ReleaseCommandError(`Unknown package ${reference} in ${filename}`);
2729
+ const dir = path.relative(root, pkg.rootDir);
2730
+ const lane = config.versioning?.lanes?.[pkg.manifest.name ?? ""] ?? config.versioning?.lanes?.[dir];
2731
+ const consumed = Object.entries(ledger).some(([key, entry]) => (entry.dir ? entry.dir.replace(/^\.\//, "") === dir : key.slice(0, key.lastIndexOf("@")) === pkg.manifest.name) && entry.intents.includes(file.name.slice(0, -3)) && (lane && lane !== "main" || !semver.prerelease(key.slice(key.lastIndexOf("@") + 1))));
2732
+ active ||= !consumed;
2733
+ }
2734
+ if (active) pending.push(filename);
2735
+ }
2736
+ return pending;
2737
+ }
2738
+ //#endregion
2666
2739
  //#region src/commands/release/shared.ts
2667
2740
  function getReleaseEnv(options) {
2668
2741
  return options.env ?? process.env;
@@ -2705,11 +2778,7 @@ function hasGitChanges(options) {
2705
2778
  }).status !== 0;
2706
2779
  }
2707
2780
  async function hasPendingIntents(cwd) {
2708
- try {
2709
- return (await readdir(path.join(cwd, ".changeset"), { withFileTypes: true })).some((entry) => entry.isFile() && entry.name.endsWith(".md") && entry.name !== "README.md");
2710
- } catch {
2711
- return false;
2712
- }
2781
+ return (await readPendingIntents(cwd)).length > 0;
2713
2782
  }
2714
2783
  function resolveBranch(options) {
2715
2784
  return options.branch?.trim() || getReleaseEnv(options)["GITHUB_REF_NAME"]?.trim() || capture("git", [
@@ -3817,6 +3886,15 @@ async function findVersionCommit(pkg, options) {
3817
3886
  return target;
3818
3887
  }
3819
3888
  //#endregion
3889
+ //#region src/commands/release/lifecycle/key.ts
3890
+ function releaseStateKey(repository, distTag, candidates) {
3891
+ return createHash("sha256").update(JSON.stringify({
3892
+ repository,
3893
+ distTag,
3894
+ packages: candidates.map(packageKey).sort()
3895
+ })).digest("hex");
3896
+ }
3897
+ //#endregion
3820
3898
  //#region src/commands/release/lifecycle/registry.ts
3821
3899
  /** 明确的 E404 才代表不存在;其余失败不能作为重新上传的依据。 */
3822
3900
  async function inspectRegistry(pkg, options) {
@@ -3862,12 +3940,7 @@ async function publishLifecycle(options, selected, distTag = "latest") {
3862
3940
  const repository = env["GITHUB_REPOSITORY"];
3863
3941
  if (!repository || !/^[^/]+\/[^/]+$/.test(repository)) throw new ReleaseCommandError("GITHUB_REPOSITORY is required for durable release recovery");
3864
3942
  const candidates = selected ?? await getPublishCandidates(options.cwd);
3865
- const identity = JSON.stringify({
3866
- repository,
3867
- distTag,
3868
- packages: candidates.map(packageKey).sort()
3869
- });
3870
- const key = createHash("sha256").update(identity).digest("hex");
3943
+ const key = releaseStateKey(repository, distTag, candidates);
3871
3944
  const snapshot = await github.readReleaseState(key);
3872
3945
  let revision = snapshot?.revision;
3873
3946
  const releases = new Map((await github.listReleases()).map((release) => [release.tag_name, release]));
@@ -4028,6 +4101,82 @@ async function publishLifecycle(options, selected, distTag = "latest") {
4028
4101
  return packages;
4029
4102
  }
4030
4103
  //#endregion
4104
+ //#region src/commands/release/preparation/guard.ts
4105
+ /** A prepared version belongs to its original source, even before npm accepts it. */
4106
+ async function assertPreviousReleaseComplete(options, distTag = "latest") {
4107
+ const ledger = await readLedger(options.cwd);
4108
+ const candidates = await getPublishCandidates(options.cwd);
4109
+ const workspace = await getWorkspacePackages(options.cwd);
4110
+ const prepared = [];
4111
+ for (const pkg of candidates) {
4112
+ if (ledger[packageKey(pkg)]) {
4113
+ prepared.push(pkg);
4114
+ continue;
4115
+ }
4116
+ const directory = workspace.find((item) => item.manifest.name === pkg.name).rootDir;
4117
+ try {
4118
+ if (readVersionSection(await readFile(path.join(directory, "CHANGELOG.md"), "utf8"), pkg.version)?.previousVersion) prepared.push(pkg);
4119
+ } catch (error) {
4120
+ if (error.code !== "ENOENT") throw error;
4121
+ }
4122
+ }
4123
+ if (!prepared.length) return;
4124
+ const github = options.github;
4125
+ const releases = github?.listReleases ? await github.listReleases() : void 0;
4126
+ const repository = getReleaseEnv(options)["GITHUB_REPOSITORY"];
4127
+ const sources = /* @__PURE__ */ new Map();
4128
+ const cohorts = /* @__PURE__ */ new Map();
4129
+ for (const pkg of prepared) {
4130
+ const source = await findVersionCommit(pkg, options);
4131
+ sources.set(packageKey(pkg), source);
4132
+ cohorts.set(source, [...cohorts.get(source) ?? [], pkg]);
4133
+ }
4134
+ const unfinished = /* @__PURE__ */ new Set();
4135
+ if (repository && github?.readReleaseState) for (const group of [candidates, ...cohorts.values()]) {
4136
+ const key = releaseStateKey(repository, distTag, group);
4137
+ const checkpoint = await github.readReleaseState(key);
4138
+ if (checkpoint && (!checkpoint.state.complete || checkpoint.state.schemaVersion !== 1)) group.forEach((pkg) => unfinished.add(packageKey(pkg)));
4139
+ }
4140
+ const blocked = [];
4141
+ for (const pkg of prepared) {
4142
+ const published = await inspectRegistry(pkg, options);
4143
+ const release = releases?.find((item) => item.tag_name === packageKey(pkg));
4144
+ const tag = github?.readTagTarget ? await github.readTagTarget(packageKey(pkg)) : void 0;
4145
+ if (!published || unfinished.has(packageKey(pkg)) || releases && (!release || release.draft || Boolean(release.prerelease) !== (distTag !== "latest")) || github?.readTagTarget && (!tag || published.gitHead && tag !== published.gitHead)) {
4146
+ const source = sources.get(packageKey(pkg));
4147
+ const recovery = distTag === "latest" ? `repo release ci --mode publish --source-sha ${source}` : `check out ${source} on ${distTag} and run repo release ci`;
4148
+ blocked.push(`${packageKey(pkg)} (source ${source}); recover with ${recovery}`);
4149
+ }
4150
+ }
4151
+ if (blocked.length) throw new ReleaseCommandError(`Prepared releases must finish before consuming new intents:\n${blocked.join("\n")}`);
4152
+ }
4153
+ //#endregion
4154
+ //#region src/commands/release/preparation/result.ts
4155
+ async function applyVersions(options) {
4156
+ const before = await readWorkspaceVersions(options.cwd);
4157
+ const output = capture("pnpm", [
4158
+ "version",
4159
+ "-r",
4160
+ "--no-git-checks",
4161
+ "--json"
4162
+ ], options);
4163
+ let data;
4164
+ try {
4165
+ data = JSON.parse(output);
4166
+ } catch {
4167
+ throw new ReleaseCommandError("pnpm version returned invalid JSON; no release PR will be pushed");
4168
+ }
4169
+ if (!Array.isArray(data)) throw new ReleaseCommandError("pnpm version must return an applied release array");
4170
+ const after = await readWorkspaceVersions(options.cwd);
4171
+ const names = /* @__PURE__ */ new Set();
4172
+ for (const item of data) {
4173
+ if (!item || typeof item.name !== "string" || names.has(item.name) || typeof item.currentVersion !== "string" || !semver.valid(item.currentVersion) || typeof item.newVersion !== "string" || !semver.valid(item.newVersion) || before.get(item.name) !== item.currentVersion || after.get(item.name) !== item.newVersion) throw new ReleaseCommandError("pnpm version result does not match workspace manifests");
4174
+ names.add(item.name);
4175
+ }
4176
+ for (const [name, version] of after) if (before.get(name) !== version && !names.has(name)) throw new ReleaseCommandError(`pnpm version omitted changed package ${name}`);
4177
+ return data;
4178
+ }
4179
+ //#endregion
4031
4180
  //#region src/commands/release/types.ts
4032
4181
  const prereleaseBranches$1 = /* @__PURE__ */ new Set([
4033
4182
  "alpha",
@@ -4045,15 +4194,13 @@ async function releasePrerelease(options, publish) {
4045
4194
  if (publish) await runQualityScripts(options);
4046
4195
  return publish?.();
4047
4196
  }
4197
+ await assertPreviousReleaseComplete(options, branch);
4048
4198
  runReleaseHooks("beforeVersion", options);
4049
4199
  await runQualityScripts(options);
4050
- run("pnpm", [
4051
- "version",
4052
- "-r",
4053
- "--no-git-checks"
4054
- ], options);
4200
+ const releases = await applyVersions(options);
4055
4201
  runReleaseHooks("afterVersion", options);
4056
- if (!hasGitChanges(options)) return;
4202
+ if (!releases.length) return;
4203
+ if (!hasGitChanges(options)) throw new ReleaseCommandError("pnpm reported releases without file changes");
4057
4204
  run("git", ["add", "-A"], options);
4058
4205
  run("git", [
4059
4206
  "commit",
@@ -4179,21 +4326,152 @@ async function reconcileRelease(options) {
4179
4326
  };
4180
4327
  }
4181
4328
  //#endregion
4329
+ //#region src/commands/release/recovery/candidates.ts
4330
+ /** Dependency propagation can change manifests without adding ledger entries. */
4331
+ async function readSourceCandidates(options, source) {
4332
+ const ledger = await readLedger(options.cwd);
4333
+ const previous = capture("git", [
4334
+ "ls-tree",
4335
+ `${source}^`,
4336
+ "--",
4337
+ ".changeset/ledger.yaml"
4338
+ ], options) ? parseLedger(capture("git", ["show", `${source}^:.changeset/ledger.yaml`], options)) : {};
4339
+ const root = await realpath(options.cwd);
4340
+ const candidates = [];
4341
+ for (const pkg of await getWorkspacePackages(options.cwd)) {
4342
+ const { name, version } = pkg.manifest;
4343
+ if (!name || !version) continue;
4344
+ const file = path.relative(root, pkg.pkgJsonPath);
4345
+ const before = capture("git", [
4346
+ "ls-tree",
4347
+ `${source}^`,
4348
+ "--",
4349
+ file
4350
+ ], options) ? JSON.parse(capture("git", ["show", `${source}^:${file}`], options)) : void 0;
4351
+ const key = `${name}@${version}`;
4352
+ if (before?.name !== name || before.version !== version || ledger[key] && !previous[key]) candidates.push({
4353
+ name,
4354
+ version
4355
+ });
4356
+ }
4357
+ return candidates;
4358
+ }
4359
+ //#endregion
4360
+ //#region src/commands/release/recovery/source.ts
4361
+ /** Run current tooling against the original source, never today's package contents. */
4362
+ async function recoverSource(options, source) {
4363
+ if (!/^[a-f0-9]{40}$/.test(source)) throw new ReleaseCommandError("source-sha must be a full lowercase commit SHA");
4364
+ const mode = options.mode ?? getReleaseEnv(options)["REPO_RELEASE_MODE"] ?? "auto";
4365
+ if (!["publish", "publish-unpublished"].includes(mode)) throw new ReleaseCommandError("source-sha requires publish or publish-unpublished mode");
4366
+ if (capture("git", ["rev-parse", "--is-shallow-repository"], options) !== "false") throw new ReleaseCommandError("Source recovery requires full Git history");
4367
+ run("git", [
4368
+ "merge-base",
4369
+ "--is-ancestor",
4370
+ source,
4371
+ "origin/main"
4372
+ ], options);
4373
+ const origin = capture("git", [
4374
+ "remote",
4375
+ "get-url",
4376
+ "origin"
4377
+ ], options);
4378
+ const root = await mkdtemp(path.join(tmpdir(), "repoctl-release-source-"));
4379
+ const cwd = path.join(root, "source");
4380
+ try {
4381
+ run("git", [
4382
+ "clone",
4383
+ "--shared",
4384
+ "--no-checkout",
4385
+ options.cwd,
4386
+ cwd
4387
+ ], options);
4388
+ const env = {
4389
+ ...getReleaseEnv(options),
4390
+ REPO_RELEASE_SOURCE_SHA: source
4391
+ };
4392
+ let recovery = {
4393
+ ...options,
4394
+ cwd,
4395
+ branch: "main",
4396
+ env
4397
+ };
4398
+ run("git", [
4399
+ "remote",
4400
+ "set-url",
4401
+ "origin",
4402
+ origin
4403
+ ], recovery);
4404
+ run("git", [
4405
+ "checkout",
4406
+ "--detach",
4407
+ source
4408
+ ], recovery);
4409
+ clearWorkspaceCache();
4410
+ const workspaceCandidates = await getPublishCandidates(cwd);
4411
+ const candidates = await readSourceCandidates(recovery, source);
4412
+ if (!candidates.length) throw new ReleaseCommandError("Source commit introduces no prepared release versions");
4413
+ const name = options.packageName ?? env["REPO_RELEASE_PACKAGE"];
4414
+ const version = options.packageVersion ?? env["REPO_RELEASE_VERSION"];
4415
+ if ((name || version) && !candidates.some((pkg) => pkg.name === name && pkg.version === version)) throw new ReleaseCommandError("Requested package/version is not part of the source release");
4416
+ if (await hasPendingIntents(cwd)) throw new ReleaseCommandError("Source contains unconsumed release requests; select the merged version commit");
4417
+ const github = resolveGitHub(options);
4418
+ let selected = candidates;
4419
+ const repository = env["GITHUB_REPOSITORY"];
4420
+ if (repository && github.readReleaseState) {
4421
+ const checkpoint = await github.readReleaseState(releaseStateKey(repository, "latest", workspaceCandidates));
4422
+ if (checkpoint) {
4423
+ if (checkpoint.state.packages.some((pkg) => pkg.target !== source || !candidates.some((item) => packageKey(item) === packageKey(pkg)))) throw new ReleaseCommandError("Existing checkpoint includes a different source release; recover its original candidate set");
4424
+ selected = workspaceCandidates;
4425
+ }
4426
+ }
4427
+ if (!(options.dryRun ?? env["REPO_RELEASE_DRY_RUN"] === "true")) {
4428
+ run("pnpm", ["install", "--frozen-lockfile"], recovery);
4429
+ const config = await resolveCommandConfig("release", cwd);
4430
+ recovery = {
4431
+ ...recovery,
4432
+ config: config ?? {}
4433
+ };
4434
+ await runQualityScripts(recovery);
4435
+ } else recovery = {
4436
+ ...recovery,
4437
+ dryRun: true
4438
+ };
4439
+ return await publishLifecycle({
4440
+ ...recovery,
4441
+ github
4442
+ }, selected);
4443
+ } finally {
4444
+ for (const file of [
4445
+ "repoctl-publish-progress.json",
4446
+ "repoctl-release-progress.json",
4447
+ "pnpm-publish-summary.json"
4448
+ ]) await copyFile(path.join(cwd, file), path.join(options.cwd, file)).catch((error) => {
4449
+ if (error.code !== "ENOENT") throw error;
4450
+ });
4451
+ clearWorkspaceCache();
4452
+ await rm(root, {
4453
+ recursive: true,
4454
+ force: true
4455
+ });
4456
+ }
4457
+ }
4458
+ //#endregion
4182
4459
  //#region src/commands/release/stable.ts
4183
- async function prepareStable(options) {
4460
+ async function prepareStableReleases(options) {
4184
4461
  const branch = resolveBranch(options);
4185
4462
  if (branch !== "main") throw new ReleaseCommandError(`repo release stable prepare is only allowed on main, got ${branch}`);
4186
4463
  await assertStableLaneAssignments(options);
4187
- if (!await hasPendingIntents(options.cwd)) return false;
4464
+ if (!await hasPendingIntents(options.cwd)) return [];
4465
+ await assertPreviousReleaseComplete(options);
4188
4466
  runReleaseHooks("beforeVersion", options);
4189
4467
  await runQualityScripts(options);
4190
- run("pnpm", [
4191
- "version",
4192
- "-r",
4193
- "--no-git-checks"
4194
- ], options);
4468
+ const releases = await applyVersions(options);
4195
4469
  runReleaseHooks("afterVersion", options);
4196
- return hasGitChanges(options);
4470
+ if (releases.length && !hasGitChanges(options)) throw new ReleaseCommandError("pnpm reported releases without file changes");
4471
+ return releases;
4472
+ }
4473
+ async function prepareStable(options) {
4474
+ return (await prepareStableReleases(options)).length > 0;
4197
4475
  }
4198
4476
  async function assertStablePublish(options, quality = true) {
4199
4477
  const branch = resolveBranch(options);
@@ -4269,13 +4547,6 @@ function shouldRunRelease(context) {
4269
4547
  if (prereleaseBranches.has(context.branch)) return false;
4270
4548
  return isReleaseCommitMessage(context.commitMessage) || hasReleaseArtifactPair(context.changedFiles);
4271
4549
  }
4272
- async function readPendingChangesetFiles(cwd) {
4273
- try {
4274
- return (await readdir(path.join(cwd, ".changeset"), { withFileTypes: true })).filter((entry) => entry.isFile() && entry.name.endsWith(".md") && entry.name !== "README.md").map((entry) => `.changeset/${entry.name}`);
4275
- } catch {
4276
- return [];
4277
- }
4278
- }
4279
4550
  function readGitOutput(options, args) {
4280
4551
  try {
4281
4552
  return capture("git", args, options);
@@ -4311,7 +4582,7 @@ async function readReleaseTriggerContext(options) {
4311
4582
  return {
4312
4583
  eventName,
4313
4584
  branch,
4314
- pendingChangesetFiles: await readPendingChangesetFiles(options.cwd),
4585
+ pendingChangesetFiles: await readPendingIntents(options.cwd),
4315
4586
  changedFiles: await readChangedFiles(options),
4316
4587
  commitMessage: readGitOutput(options, [
4317
4588
  "log",
@@ -4327,9 +4598,32 @@ const releaseBranch = "release/pnpm-version";
4327
4598
  async function createReleasePullRequest(options) {
4328
4599
  const branch = resolveBranch(options);
4329
4600
  if (branch !== "main") throw new ReleaseCommandError(`repo release stable prepare is only allowed on main, got ${branch}`);
4330
- const previousVersions = await readWorkspaceVersions(options.cwd);
4331
4601
  const sourceCommits = await readPendingIntentCommits(options);
4332
- if (!await prepareStable(options)) return false;
4602
+ const github = resolveGitHub(options);
4603
+ const releases = await prepareStableReleases({
4604
+ ...options,
4605
+ github
4606
+ });
4607
+ if (!releases.length) return false;
4608
+ const releaseEnv = getReleaseEnv(options);
4609
+ const metadata = {
4610
+ locale: resolveReleaseLocale(options),
4611
+ commits: sourceCommits,
4612
+ ...releaseEnv["GITHUB_REPOSITORY"] ? { repository: releaseEnv["GITHUB_REPOSITORY"] } : {},
4613
+ ...releaseEnv["GITHUB_SERVER_URL"] ? { serverUrl: releaseEnv["GITHUB_SERVER_URL"] } : {}
4614
+ };
4615
+ const names = new Set(releases.map((release) => release.name));
4616
+ const previousVersions = new Map(releases.filter((release) => release.currentVersion !== release.newVersion).map((release) => [release.name, release.currentVersion]));
4617
+ let noteDocument = await buildReleaseNoteDocument(options.cwd, previousVersions, metadata, names);
4618
+ for (const release of releases) {
4619
+ const pkg = noteDocument.packages.find((pkg) => pkg.name === release.name && pkg.version === release.newVersion);
4620
+ if (!pkg || !noteDocument.entries.some((entry) => entry.packageName === pkg.name)) throw new ReleaseCommandError(`Missing release notes for ${release.name}@${release.newVersion}; no PR pushed`);
4621
+ if (release.currentVersion === release.newVersion) {
4622
+ delete pkg.previousVersion;
4623
+ delete pkg.previousNpmUrl;
4624
+ }
4625
+ }
4626
+ if (github.enrichReleaseNote) noteDocument = await github.enrichReleaseNote(noteDocument);
4333
4627
  run("git", [
4334
4628
  "config",
4335
4629
  "user.name",
@@ -4357,16 +4651,6 @@ async function createReleasePullRequest(options) {
4357
4651
  "origin",
4358
4652
  `HEAD:${releaseBranch}`
4359
4653
  ], options);
4360
- const github = resolveGitHub(options);
4361
- const releaseEnv = getReleaseEnv(options);
4362
- const metadata = {
4363
- locale: resolveReleaseLocale(options),
4364
- commits: sourceCommits,
4365
- ...releaseEnv["GITHUB_REPOSITORY"] ? { repository: releaseEnv["GITHUB_REPOSITORY"] } : {},
4366
- ...releaseEnv["GITHUB_SERVER_URL"] ? { serverUrl: releaseEnv["GITHUB_SERVER_URL"] } : {}
4367
- };
4368
- let noteDocument = await buildReleaseNoteDocument(options.cwd, previousVersions, metadata);
4369
- if (github.enrichReleaseNote) noteDocument = await github.enrichReleaseNote(noteDocument);
4370
4654
  await github.ensurePullRequest({
4371
4655
  head: releaseBranch,
4372
4656
  base: "main",
@@ -4422,7 +4706,7 @@ async function recoverUnpublished(options) {
4422
4706
  return packages;
4423
4707
  }
4424
4708
  function resolveMode(options) {
4425
- const requested = options.mode || getReleaseEnv(options)["REPO_RELEASE_MODE"]?.trim();
4709
+ const requested = options.mode && options.mode !== "auto" ? options.mode : getReleaseEnv(options)["REPO_RELEASE_MODE"]?.trim();
4426
4710
  if (requested && requested !== "auto") return requested;
4427
4711
  return "auto";
4428
4712
  }
@@ -4442,6 +4726,11 @@ async function publishStableCi(options) {
4442
4726
  }
4443
4727
  async function releaseCi(options) {
4444
4728
  const mode = resolveMode(options);
4729
+ const source = options.sourceSha ?? getReleaseEnv(options)["REPO_RELEASE_RECOVERY_SOURCE_SHA"]?.trim();
4730
+ if (source) return recoverSource({
4731
+ ...options,
4732
+ mode
4733
+ }, source);
4445
4734
  if (mode === "prepare") {
4446
4735
  await createReleasePullRequest(options);
4447
4736
  return;
@@ -4471,7 +4760,10 @@ async function releaseCi(options) {
4471
4760
  github
4472
4761
  }, void 0, branch);
4473
4762
  }
4474
- return releasePrerelease(options, () => publishLifecycle({
4763
+ return releasePrerelease({
4764
+ ...options,
4765
+ github
4766
+ }, () => publishLifecycle({
4475
4767
  ...options,
4476
4768
  github,
4477
4769
  env: {
@@ -1,5 +1,5 @@
1
- import { A as defaultTemplate, N as resolveCreateNewProjectPlan, j as getCreateChoices, k as createNewProject } from "./commands-BCix_gOD.mjs";
2
- import { m as logger, u as localize, y as fs } from "./types-W9fwiyx8.mjs";
1
+ import { A as defaultTemplate, N as resolveCreateNewProjectPlan, j as getCreateChoices, k as createNewProject } from "./commands-CIzCAxyY.mjs";
2
+ import { m as logger, u as localize, y as fs } from "./types-m8JLwKzl.mjs";
3
3
  import { s as resolveCommandConfig } from "./config-p842Knhq.mjs";
4
4
  import path from "pathe";
5
5
  import process from "node:process";
package/dist/index.d.mts CHANGED
@@ -418,6 +418,8 @@ interface ReleaseOptions {
418
418
  sleep?: (milliseconds: number) => Promise<void>;
419
419
  }
420
420
  interface ReleaseCiOptions extends ReleaseOptions {
421
+ /** Recover the entire prepared release from this main-history commit. */
422
+ sourceSha?: string;
421
423
  mode?: ReleaseMode;
422
424
  packageName?: string;
423
425
  packageVersion?: string;
@@ -439,7 +441,7 @@ export declare function releaseCi(options: ReleaseCiOptions): Promise<PublishedP
439
441
  } | undefined>;
440
442
  //#endregion
441
443
  //#region src/commands/release/prerelease.d.ts
442
- export declare function releasePrerelease(options: ReleaseOptions, publish?: () => Promise<PublishedPackage[]>): Promise<PublishedPackage[] | undefined>;
444
+ export declare function releasePrerelease(options: ReleaseCiOptions, publish?: () => Promise<PublishedPackage[]>): Promise<PublishedPackage[] | undefined>;
443
445
  export declare function enterPrerelease(tag: string, options: ReleaseOptions): Promise<void>;
444
446
  export declare function exitPrerelease(options: ReleaseOptions): Promise<void>;
445
447
  //#endregion
package/dist/index.mjs CHANGED
@@ -1,6 +1,6 @@
1
- import { $ as runRecommendedCheck, B as escapeStringRegexp, C as createContext, D as collectEnvSupportBundle, E as collectEnvSnapshot, F as inspectMonorepoConfig, G as isGitignoreFile, H as setByPath, I as cleanProjects, J as toWorkspaceGitignorePath, K as toPublishGitignorePath, L as getSkillTargetPaths, M as getTemplateMap, N as resolveCreateNewProjectPlan, O as runDoctor, P as templateMap, Q as resolveRecommendedCheckPlan, R as skillTargets, S as normalizeInitToolingTargets, T as collectEnvPaths, U as getFileHash, V as isMatch, W as isFileChanged, X as getKnownRepoCheckCommands, Y as updateIssueTemplateConfig, Z as resolveFullWorkspaceCheckPlan, _ as parsePublishSummary, a as createReleasePullRequest, at as defaultAgenticBaseDir, b as initMetadata, c as prepareStable, ct as loadAgenticTasks, d as reconcileRelease, et as verifyCommitMsg, f as enterPrerelease, g as GitHubApiError, h as GitHubClient, i as repairReleaseNotes, it as createTimestampFolderName, j as getCreateChoices, k as createNewProject, l as publishStable, lt as GitClient, m as releasePrerelease, n as upgradeMonorepo, nt as verifyPrePush, o as recoverUnpublished, ot as generateAgenticTemplate, p as exitPrerelease, q as toWorkspaceAssetPath, r as checkTemplates, rt as verifyStagedTypecheck, s as releaseCi, st as generateAgenticTemplates, tt as verifyPreCommit, u as releaseStable, v as setVscodeBinaryMirror, w as collectEnvInfo, x as initTooling, y as init, z as syncSkills } from "./commands-BCix_gOD.mjs";
1
+ import { $ as runRecommendedCheck, B as escapeStringRegexp, C as createContext, D as collectEnvSupportBundle, E as collectEnvSnapshot, F as inspectMonorepoConfig, G as isGitignoreFile, H as setByPath, I as cleanProjects, J as toWorkspaceGitignorePath, K as toPublishGitignorePath, L as getSkillTargetPaths, M as getTemplateMap, N as resolveCreateNewProjectPlan, O as runDoctor, P as templateMap, Q as resolveRecommendedCheckPlan, R as skillTargets, S as normalizeInitToolingTargets, T as collectEnvPaths, U as getFileHash, V as isMatch, W as isFileChanged, X as getKnownRepoCheckCommands, Y as updateIssueTemplateConfig, Z as resolveFullWorkspaceCheckPlan, _ as parsePublishSummary, a as createReleasePullRequest, at as defaultAgenticBaseDir, b as initMetadata, c as prepareStable, ct as loadAgenticTasks, d as reconcileRelease, et as verifyCommitMsg, f as enterPrerelease, g as GitHubApiError, h as GitHubClient, i as repairReleaseNotes, it as createTimestampFolderName, j as getCreateChoices, k as createNewProject, l as publishStable, lt as GitClient, m as releasePrerelease, n as upgradeMonorepo, nt as verifyPrePush, o as recoverUnpublished, ot as generateAgenticTemplate, p as exitPrerelease, q as toWorkspaceAssetPath, r as checkTemplates, rt as verifyStagedTypecheck, s as releaseCi, st as generateAgenticTemplates, tt as verifyPreCommit, u as releaseStable, v as setVscodeBinaryMirror, w as collectEnvInfo, x as initTooling, y as init, z as syncSkills } from "./commands-CIzCAxyY.mjs";
2
2
  import { i as getWorkspacePackages, n as getWorkspaceData, r as getWorkspacePackageSummaries, t as clearWorkspaceCache } from "./workspace-MCKewElu.mjs";
3
- import { C as outputJson, D as remove, E as readJson, O as writeJSON, S as outputJSON, T as readJSON, _ as ensureFile, a as rootDir, b as isIgnorableFsError, g as ensureDir, h as copy, i as packageDir, k as writeJson, l as version, m as logger, n as assetsDir, o as templatesDir, r as cliName, s as name, t as initToolingTargets, v as exists, w as pathExists, x as outputFile } from "./types-W9fwiyx8.mjs";
3
+ import { C as outputJson, D as remove, E as readJson, O as writeJSON, S as outputJSON, T as readJSON, _ as ensureFile, a as rootDir, b as isIgnorableFsError, g as ensureDir, h as copy, i as packageDir, k as writeJson, l as version, m as logger, n as assetsDir, o as templatesDir, r as cliName, s as name, t as initToolingTargets, v as exists, w as pathExists, x as outputFile } from "./types-m8JLwKzl.mjs";
4
4
  import { a as loadMonorepoConfig, c as resolveToolingConfig, i as getRepoctlConfigCandidates, o as loadMonorepoConfigDetails, r as defineMonorepoConfig, s as resolveCommandConfig, t as configExtensions } from "./config-p842Knhq.mjs";
5
5
  import { a as createMonorepoTsconfig, c as defineCommitlintConfig, d as defineStylelintConfig, f as defineTsconfigConfig, h as loadMonorepoToolingConfig, i as createMonorepoStylelintConfig, l as defineEslintConfig, m as defineVitestProjectConfig, n as createMonorepoEslintConfig, o as createMonorepoVitestConfig, p as defineVitestConfig, r as createMonorepoLintStagedConfig, s as createMonorepoVitestProjectConfig, t as createMonorepoCommitlintConfig, u as defineLintStagedConfig } from "./tooling-BfXlmCi-.mjs";
6
6
  export { GitClient, GitHubApiError, GitHubClient, assetsDir, checkTemplates, cleanProjects, clearWorkspaceCache, cliName, collectEnvInfo, collectEnvPaths, collectEnvSnapshot, collectEnvSupportBundle, configExtensions, copy, createContext, createMonorepoCommitlintConfig, createMonorepoEslintConfig, createMonorepoLintStagedConfig, createMonorepoStylelintConfig, createMonorepoTsconfig, createMonorepoVitestConfig, createMonorepoVitestProjectConfig, createNewProject, createReleasePullRequest, createTimestampFolderName, defaultAgenticBaseDir, defineCommitlintConfig, defineEslintConfig, defineLintStagedConfig, defineMonorepoConfig, defineStylelintConfig, defineTsconfigConfig, defineVitestConfig, defineVitestProjectConfig, ensureDir, ensureFile, enterPrerelease, escapeStringRegexp, exists, exitPrerelease, generateAgenticTemplate, generateAgenticTemplates, getCreateChoices, getFileHash, getKnownRepoCheckCommands, getRepoctlConfigCandidates, getSkillTargetPaths, getTemplateMap, getWorkspaceData, getWorkspacePackageSummaries, getWorkspacePackages, init, initMetadata, initTooling, initToolingTargets, inspectMonorepoConfig, isFileChanged, isGitignoreFile, isIgnorableFsError, isMatch, loadAgenticTasks, loadMonorepoConfig, loadMonorepoConfigDetails, loadMonorepoToolingConfig, logger, normalizeInitToolingTargets, outputFile, outputJSON, outputJson, packageDir, name as packageName, parsePublishSummary, pathExists, prepareStable, publishStable, readJSON, readJson, reconcileRelease, recoverUnpublished, releaseCi, releasePrerelease, releaseStable, remove, repairReleaseNotes, resolveCommandConfig, resolveCreateNewProjectPlan, resolveFullWorkspaceCheckPlan, resolveRecommendedCheckPlan, resolveToolingConfig, rootDir, runDoctor, runRecommendedCheck, setByPath, setVscodeBinaryMirror, skillTargets, syncSkills, templateMap, templatesDir, toPublishGitignorePath, toWorkspaceAssetPath, toWorkspaceGitignorePath, updateIssueTemplateConfig, upgradeMonorepo, verifyCommitMsg, verifyPreCommit, verifyPrePush, verifyStagedTypecheck, version, writeJSON, writeJson };
@@ -343,7 +343,7 @@ function message(key, values = {}) {
343
343
  //#endregion
344
344
  //#region package.json
345
345
  var name = "@icebreakers/monorepo";
346
- var version = "5.5.9";
346
+ var version = "5.5.10";
347
347
  var package_default = {
348
348
  name,
349
349
  type: "module",
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@icebreakers/monorepo",
3
3
  "type": "module",
4
- "version": "5.5.9",
4
+ "version": "5.5.10",
5
5
  "description": "Core engine and programmatic APIs for repoctl",
6
6
  "author": "ice breaker <hi@sonofmagic.top>",
7
7
  "license": "MIT",
@@ -77,8 +77,8 @@
77
77
  },
78
78
  "dependencies": {
79
79
  "@icebreakers/commitlint-config": "4.1.1",
80
- "@icebreakers/eslint-config": "8.0.5",
81
- "@icebreakers/monorepo-templates": "2.0.6",
80
+ "@icebreakers/eslint-config": "8.0.6",
81
+ "@icebreakers/monorepo-templates": "2.0.7",
82
82
  "@icebreakers/stylelint-config": "5.1.3",
83
83
  "@pnpm/find-workspace-dir": "^1000.1.5",
84
84
  "@pnpm/logger": "^1100.0.0",