@icebreakers/monorepo 3.2.9 → 3.2.11

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.cjs CHANGED
@@ -1,4 +1,4 @@
1
- const require_upgrade = require('./upgrade-BU9MxePN.cjs');
1
+ const require_upgrade = require('./upgrade-BDVNfq80.cjs');
2
2
  let node_process = require("node:process");
3
3
  node_process = require_upgrade.__toESM(node_process);
4
4
  let _icebreakers_monorepo_templates = require("@icebreakers/monorepo-templates");
package/dist/cli.mjs CHANGED
@@ -1,4 +1,4 @@
1
- import { C as syncSkills, F as generateAgenticTemplate, I as generateAgenticTemplates, L as loadAgenticTasks, M as resolveCommandConfig, N as createTimestampFolderName, O as name, P as defaultAgenticBaseDir, R as logger, S as skillTargets, _ as getCreateChoices, b as cleanProjects, g as defaultTemplate, h as createNewProject, i as init, k as version, n as syncNpmMirror, r as setVscodeBinaryMirror, t as upgradeMonorepo } from "./upgrade-D3hLXGAI.mjs";
1
+ import { C as syncSkills, F as generateAgenticTemplate, I as generateAgenticTemplates, L as loadAgenticTasks, M as resolveCommandConfig, N as createTimestampFolderName, O as name, P as defaultAgenticBaseDir, R as logger, S as skillTargets, _ as getCreateChoices, b as cleanProjects, g as defaultTemplate, h as createNewProject, i as init, k as version, n as syncNpmMirror, r as setVscodeBinaryMirror, t as upgradeMonorepo } from "./upgrade-zJC3jLQe.mjs";
2
2
  import process from "node:process";
3
3
  import { input, program, select } from "@icebreakers/monorepo-templates";
4
4
 
package/dist/index.cjs CHANGED
@@ -1,5 +1,5 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
2
- const require_upgrade = require('./upgrade-BU9MxePN.cjs');
2
+ const require_upgrade = require('./upgrade-BDVNfq80.cjs');
3
3
  let _icebreakers_monorepo_templates = require("@icebreakers/monorepo-templates");
4
4
 
5
5
  exports.GitClient = require_upgrade.GitClient;
package/dist/index.mjs CHANGED
@@ -1,3 +1,3 @@
1
- import { A as defineMonorepoConfig, B as getWorkspacePackages, C as syncSkills, D as templatesDir, E as rootDir, F as generateAgenticTemplate, I as generateAgenticTemplates, L as loadAgenticTasks, M as resolveCommandConfig, N as createTimestampFolderName, O as name, P as defaultAgenticBaseDir, R as logger, S as skillTargets, T as packageDir, V as GitClient, _ as getCreateChoices, a as escapeStringRegexp, b as cleanProjects, c as isFileChanged, d as toWorkspaceGitignorePath, f as updateIssueTemplateConfig, h as createNewProject, i as init, j as loadMonorepoConfig, k as version, l as isGitignoreFile, m as createContext, n as syncNpmMirror, o as isMatch, p as isIgnorableFsError, r as setVscodeBinaryMirror, s as getFileHash, t as upgradeMonorepo, u as toPublishGitignorePath, v as getTemplateMap, w as assetsDir, x as getSkillTargetPaths, y as templateMap, z as getWorkspaceData } from "./upgrade-D3hLXGAI.mjs";
1
+ import { A as defineMonorepoConfig, B as getWorkspacePackages, C as syncSkills, D as templatesDir, E as rootDir, F as generateAgenticTemplate, I as generateAgenticTemplates, L as loadAgenticTasks, M as resolveCommandConfig, N as createTimestampFolderName, O as name, P as defaultAgenticBaseDir, R as logger, S as skillTargets, T as packageDir, V as GitClient, _ as getCreateChoices, a as escapeStringRegexp, b as cleanProjects, c as isFileChanged, d as toWorkspaceGitignorePath, f as updateIssueTemplateConfig, h as createNewProject, i as init, j as loadMonorepoConfig, k as version, l as isGitignoreFile, m as createContext, n as syncNpmMirror, o as isMatch, p as isIgnorableFsError, r as setVscodeBinaryMirror, s as getFileHash, t as upgradeMonorepo, u as toPublishGitignorePath, v as getTemplateMap, w as assetsDir, x as getSkillTargetPaths, y as templateMap, z as getWorkspaceData } from "./upgrade-zJC3jLQe.mjs";
2
2
 
3
3
  export { GitClient, assetsDir, cleanProjects, createContext, createNewProject, createTimestampFolderName, defaultAgenticBaseDir, defineMonorepoConfig, escapeStringRegexp, generateAgenticTemplate, generateAgenticTemplates, getCreateChoices, getFileHash, getSkillTargetPaths, getTemplateMap, getWorkspaceData, getWorkspacePackages, init, isFileChanged, isGitignoreFile, isIgnorableFsError, isMatch, loadAgenticTasks, loadMonorepoConfig, logger, name, packageDir, resolveCommandConfig, rootDir, setVscodeBinaryMirror, skillTargets, syncNpmMirror, syncSkills, templateMap, templatesDir, toPublishGitignorePath, toWorkspaceGitignorePath, updateIssueTemplateConfig, upgradeMonorepo, version };
@@ -570,7 +570,7 @@ async function resolveCommandConfig(name, cwd) {
570
570
  //#endregion
571
571
  //#region package.json
572
572
  var name = "@icebreakers/monorepo";
573
- var version = "3.2.9";
573
+ var version = "3.2.11";
574
574
 
575
575
  //#endregion
576
576
  //#region src/constants.ts
@@ -1171,6 +1171,86 @@ async function syncNpmMirror(cwd, options) {
1171
1171
  await Promise.all(tasks);
1172
1172
  }
1173
1173
 
1174
+ //#endregion
1175
+ //#region src/commands/upgrade/agents.ts
1176
+ function normalizeEol(input) {
1177
+ return input.replace(/\r\n/g, "\n");
1178
+ }
1179
+ function normalizeHeadingKey(line) {
1180
+ return line.replace(/^##\s+/, "").trim().toLowerCase();
1181
+ }
1182
+ function trimEdgeEmptyLines(lines) {
1183
+ const next = [...lines];
1184
+ while (next.length) {
1185
+ const first = next[0];
1186
+ if (first === void 0 || first.trim().length > 0) break;
1187
+ next.shift();
1188
+ }
1189
+ while (next.length) {
1190
+ const last = next.at(-1);
1191
+ if (last === void 0 || last.trim().length > 0) break;
1192
+ next.pop();
1193
+ }
1194
+ return next;
1195
+ }
1196
+ function parseMarkdownByH2(content) {
1197
+ const lines = normalizeEol(content).split("\n");
1198
+ const preamble = [];
1199
+ const sections = [];
1200
+ let current;
1201
+ for (const line of lines) {
1202
+ if (/^##\s+/.test(line)) {
1203
+ if (current) sections.push(current);
1204
+ current = {
1205
+ key: normalizeHeadingKey(line),
1206
+ lines: [line]
1207
+ };
1208
+ continue;
1209
+ }
1210
+ if (current) {
1211
+ current.lines.push(line);
1212
+ continue;
1213
+ }
1214
+ preamble.push(line);
1215
+ }
1216
+ if (current) sections.push(current);
1217
+ return {
1218
+ preamble,
1219
+ sections
1220
+ };
1221
+ }
1222
+ function mergePlainText(source, target) {
1223
+ const sourceLines = trimEdgeEmptyLines(normalizeEol(source).split("\n"));
1224
+ const result = trimEdgeEmptyLines(normalizeEol(target).split("\n"));
1225
+ const seen = new Set(result);
1226
+ for (const line of sourceLines) {
1227
+ if (!line.trim()) continue;
1228
+ if (seen.has(line)) continue;
1229
+ seen.add(line);
1230
+ result.push(line);
1231
+ }
1232
+ return `${result.join("\n")}\n`;
1233
+ }
1234
+ /**
1235
+ * Merge AGENTS instructions by keeping existing sections and filling missing sections
1236
+ * from source defaults. This avoids destructive overwrite while still syncing updates.
1237
+ */
1238
+ function mergeAgentsMarkdown(source, target) {
1239
+ const sourceParsed = parseMarkdownByH2(source);
1240
+ const targetParsed = parseMarkdownByH2(target);
1241
+ if (!sourceParsed.sections.length || !targetParsed.sections.length) return mergePlainText(source, target);
1242
+ const sourceSectionKeys = new Set(sourceParsed.sections.map((section) => section.key));
1243
+ const targetSectionMap = new Map(targetParsed.sections.map((section) => [section.key, section]));
1244
+ const mergedSections = [];
1245
+ for (const section of sourceParsed.sections) mergedSections.push(targetSectionMap.get(section.key) ?? section);
1246
+ for (const section of targetParsed.sections) if (!sourceSectionKeys.has(section.key)) mergedSections.push(section);
1247
+ const preamble = trimEdgeEmptyLines(targetParsed.preamble.length ? targetParsed.preamble : sourceParsed.preamble);
1248
+ const blocks = [];
1249
+ if (preamble.length) blocks.push(preamble.join("\n"));
1250
+ for (const section of mergedSections) blocks.push(trimEdgeEmptyLines(section.lines).join("\n"));
1251
+ return `${blocks.filter(Boolean).join("\n\n")}\n`;
1252
+ }
1253
+
1174
1254
  //#endregion
1175
1255
  //#region src/commands/upgrade/overwrite.ts
1176
1256
  function asBuffer(data) {
@@ -1376,6 +1456,7 @@ function mergeWorkspaceManifest(source, target) {
1376
1456
  * 将 assets 目录的模版文件同步到工程中,实现一键升级脚手架能力。
1377
1457
  */
1378
1458
  async function upgradeMonorepo(opts) {
1459
+ await (0, _icebreakers_monorepo_templates.ensureTemplateAssetsPrepared)();
1379
1460
  const cwd = opts.cwd ?? node_process.default.cwd();
1380
1461
  const upgradeConfig = await resolveCommandConfig("upgrade", cwd);
1381
1462
  const merged = {
@@ -1461,6 +1542,24 @@ async function upgradeMonorepo(opts) {
1461
1542
  });
1462
1543
  continue;
1463
1544
  }
1545
+ if (relPath === "AGENTS.md") {
1546
+ const source = await fs_extra.default.readFile(file.path, "utf8");
1547
+ const exists = await fs_extra.default.pathExists(targetPath);
1548
+ const target = exists ? await fs_extra.default.readFile(targetPath, "utf8") : "";
1549
+ const data = exists ? mergeAgentsMarkdown(source, target) : source;
1550
+ const intent = await evaluateWriteIntent(targetPath, buildWriteIntentOptions(data));
1551
+ const action = async () => {
1552
+ await fs_extra.default.outputFile(targetPath, data, "utf8");
1553
+ logger.success(targetPath);
1554
+ };
1555
+ await scheduleOverwrite(intent, {
1556
+ relPath,
1557
+ targetPath,
1558
+ action,
1559
+ pending: pendingOverwrites
1560
+ });
1561
+ continue;
1562
+ }
1464
1563
  if (relPath === ".changeset/config.json" && repoName) {
1465
1564
  const changesetJson = await fs_extra.default.readJson(file.path);
1466
1565
  (0, import_set_value.default)(changesetJson, "changelog.1.repo", repoName);
@@ -7,7 +7,7 @@ import path from "pathe";
7
7
  import process from "node:process";
8
8
  import fs from "fs-extra";
9
9
  import { createConsola } from "consola";
10
- import { assetsDir, checkbox, execaCommand, getAssetTargets, isGitignoreFile, scaffoldTemplate, templatesDir, toPublishGitignorePath, toWorkspaceGitignorePath } from "@icebreakers/monorepo-templates";
10
+ import { assetsDir, checkbox, ensureTemplateAssetsPrepared, execaCommand, getAssetTargets, isGitignoreFile, scaffoldTemplate, templatesDir, toPublishGitignorePath, toWorkspaceGitignorePath } from "@icebreakers/monorepo-templates";
11
11
  import { loadConfig } from "c12";
12
12
  import os from "node:os";
13
13
  import * as path$1 from "node:path";
@@ -559,7 +559,7 @@ async function resolveCommandConfig(name, cwd) {
559
559
  //#endregion
560
560
  //#region package.json
561
561
  var name = "@icebreakers/monorepo";
562
- var version = "3.2.9";
562
+ var version = "3.2.11";
563
563
 
564
564
  //#endregion
565
565
  //#region src/constants.ts
@@ -1160,6 +1160,86 @@ async function syncNpmMirror(cwd, options) {
1160
1160
  await Promise.all(tasks);
1161
1161
  }
1162
1162
 
1163
+ //#endregion
1164
+ //#region src/commands/upgrade/agents.ts
1165
+ function normalizeEol(input) {
1166
+ return input.replace(/\r\n/g, "\n");
1167
+ }
1168
+ function normalizeHeadingKey(line) {
1169
+ return line.replace(/^##\s+/, "").trim().toLowerCase();
1170
+ }
1171
+ function trimEdgeEmptyLines(lines) {
1172
+ const next = [...lines];
1173
+ while (next.length) {
1174
+ const first = next[0];
1175
+ if (first === void 0 || first.trim().length > 0) break;
1176
+ next.shift();
1177
+ }
1178
+ while (next.length) {
1179
+ const last = next.at(-1);
1180
+ if (last === void 0 || last.trim().length > 0) break;
1181
+ next.pop();
1182
+ }
1183
+ return next;
1184
+ }
1185
+ function parseMarkdownByH2(content) {
1186
+ const lines = normalizeEol(content).split("\n");
1187
+ const preamble = [];
1188
+ const sections = [];
1189
+ let current;
1190
+ for (const line of lines) {
1191
+ if (/^##\s+/.test(line)) {
1192
+ if (current) sections.push(current);
1193
+ current = {
1194
+ key: normalizeHeadingKey(line),
1195
+ lines: [line]
1196
+ };
1197
+ continue;
1198
+ }
1199
+ if (current) {
1200
+ current.lines.push(line);
1201
+ continue;
1202
+ }
1203
+ preamble.push(line);
1204
+ }
1205
+ if (current) sections.push(current);
1206
+ return {
1207
+ preamble,
1208
+ sections
1209
+ };
1210
+ }
1211
+ function mergePlainText(source, target) {
1212
+ const sourceLines = trimEdgeEmptyLines(normalizeEol(source).split("\n"));
1213
+ const result = trimEdgeEmptyLines(normalizeEol(target).split("\n"));
1214
+ const seen = new Set(result);
1215
+ for (const line of sourceLines) {
1216
+ if (!line.trim()) continue;
1217
+ if (seen.has(line)) continue;
1218
+ seen.add(line);
1219
+ result.push(line);
1220
+ }
1221
+ return `${result.join("\n")}\n`;
1222
+ }
1223
+ /**
1224
+ * Merge AGENTS instructions by keeping existing sections and filling missing sections
1225
+ * from source defaults. This avoids destructive overwrite while still syncing updates.
1226
+ */
1227
+ function mergeAgentsMarkdown(source, target) {
1228
+ const sourceParsed = parseMarkdownByH2(source);
1229
+ const targetParsed = parseMarkdownByH2(target);
1230
+ if (!sourceParsed.sections.length || !targetParsed.sections.length) return mergePlainText(source, target);
1231
+ const sourceSectionKeys = new Set(sourceParsed.sections.map((section) => section.key));
1232
+ const targetSectionMap = new Map(targetParsed.sections.map((section) => [section.key, section]));
1233
+ const mergedSections = [];
1234
+ for (const section of sourceParsed.sections) mergedSections.push(targetSectionMap.get(section.key) ?? section);
1235
+ for (const section of targetParsed.sections) if (!sourceSectionKeys.has(section.key)) mergedSections.push(section);
1236
+ const preamble = trimEdgeEmptyLines(targetParsed.preamble.length ? targetParsed.preamble : sourceParsed.preamble);
1237
+ const blocks = [];
1238
+ if (preamble.length) blocks.push(preamble.join("\n"));
1239
+ for (const section of mergedSections) blocks.push(trimEdgeEmptyLines(section.lines).join("\n"));
1240
+ return `${blocks.filter(Boolean).join("\n\n")}\n`;
1241
+ }
1242
+
1163
1243
  //#endregion
1164
1244
  //#region src/commands/upgrade/overwrite.ts
1165
1245
  function asBuffer(data) {
@@ -1365,6 +1445,7 @@ function mergeWorkspaceManifest(source, target) {
1365
1445
  * 将 assets 目录的模版文件同步到工程中,实现一键升级脚手架能力。
1366
1446
  */
1367
1447
  async function upgradeMonorepo(opts) {
1448
+ await ensureTemplateAssetsPrepared();
1368
1449
  const cwd = opts.cwd ?? process.cwd();
1369
1450
  const upgradeConfig = await resolveCommandConfig("upgrade", cwd);
1370
1451
  const merged = {
@@ -1450,6 +1531,24 @@ async function upgradeMonorepo(opts) {
1450
1531
  });
1451
1532
  continue;
1452
1533
  }
1534
+ if (relPath === "AGENTS.md") {
1535
+ const source = await fs.readFile(file.path, "utf8");
1536
+ const exists = await fs.pathExists(targetPath);
1537
+ const target = exists ? await fs.readFile(targetPath, "utf8") : "";
1538
+ const data = exists ? mergeAgentsMarkdown(source, target) : source;
1539
+ const intent = await evaluateWriteIntent(targetPath, buildWriteIntentOptions(data));
1540
+ const action = async () => {
1541
+ await fs.outputFile(targetPath, data, "utf8");
1542
+ logger.success(targetPath);
1543
+ };
1544
+ await scheduleOverwrite(intent, {
1545
+ relPath,
1546
+ targetPath,
1547
+ action,
1548
+ pending: pendingOverwrites
1549
+ });
1550
+ continue;
1551
+ }
1453
1552
  if (relPath === ".changeset/config.json" && repoName) {
1454
1553
  const changesetJson = await fs.readJson(file.path);
1455
1554
  (0, import_set_value.default)(changesetJson, "changelog.1.repo", repoName);
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@icebreakers/monorepo",
3
3
  "type": "module",
4
- "version": "3.2.9",
4
+ "version": "3.2.11",
5
5
  "description": "The icebreaker's monorepo manager",
6
6
  "author": "ice breaker <hi@sonofmagic.top>",
7
7
  "license": "MIT",
@@ -60,8 +60,8 @@
60
60
  "@pnpm/find-workspace-dir": "^1000.1.4",
61
61
  "@pnpm/logger": "^1001.0.1",
62
62
  "@pnpm/types": "^1001.3.0",
63
- "@pnpm/worker": "^1000.6.4",
64
- "@pnpm/workspace.find-packages": "^1000.0.59",
63
+ "@pnpm/worker": "^1000.6.5",
64
+ "@pnpm/workspace.find-packages": "^1000.0.62",
65
65
  "@pnpm/workspace.read-manifest": "^1000.2.10",
66
66
  "c12": "^3.3.3",
67
67
  "comment-json": "^4.5.1",
@@ -73,9 +73,9 @@
73
73
  "pathe": "^2.0.3",
74
74
  "picocolors": "^1.1.1",
75
75
  "semver": "^7.7.4",
76
- "simple-git": "^3.30.0",
76
+ "simple-git": "^3.32.2",
77
77
  "yaml": "^2.8.2",
78
- "@icebreakers/monorepo-templates": "0.1.9"
78
+ "@icebreakers/monorepo-templates": "0.1.11"
79
79
  },
80
80
  "devDependencies": {
81
81
  "@types/klaw": "^3.0.7",