cwm-assistant 0.4.1 → 0.4.3

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.
@@ -2619,7 +2619,7 @@ var Type = type_exports2;
2619
2619
 
2620
2620
  // ../../packages/contracts/src/assistant.ts
2621
2621
  var ASSISTANT_PROTOCOL = 1;
2622
- var ASSISTANT_VERSION = "0.4.1";
2622
+ var ASSISTANT_VERSION = "0.4.3";
2623
2623
  var ASSISTANT_PORT = 46322;
2624
2624
 
2625
2625
  // ../../packages/contracts/src/index.ts
@@ -5959,7 +5959,7 @@ async function frozenRefs(git4, cwd) {
5959
5959
  }
5960
5960
  function scopeStatus(conflict, branches, nonVersionEntries) {
5961
5961
  if (conflict) return "CONFLICT";
5962
- return branches.some((branch) => (branch.missingCommits || []).length) || nonVersionEntries.length ? "WARN" : "PASS";
5962
+ return branches.some((branch) => branch.unresolved || (branch.missingCommits || []).length) || nonVersionEntries.length ? "WARN" : "PASS";
5963
5963
  }
5964
5964
  async function branchScope(git4, cwd, productionSha, stagingSha, refs, branches, production, staging) {
5965
5965
  const nodes = lines(
@@ -5974,6 +5974,10 @@ async function branchScope(git4, cwd, productionSha, stagingSha, refs, branches,
5974
5974
  };
5975
5975
  const accounted = /* @__PURE__ */ new Set();
5976
5976
  for (const branch of branches) {
5977
+ if (branch.unresolved) {
5978
+ branch.status = "UNRESOLVED";
5979
+ continue;
5980
+ }
5977
5981
  const expected = [...await history(branch.sha)];
5978
5982
  branch.expectedCommits = expected;
5979
5983
  branch.coveredCommits = expected.filter((sha) => incoming.has(sha));
@@ -6067,6 +6071,7 @@ function reviewLabel(status) {
6067
6071
  return status === "PASS" ? "\u5BA1\u67E5\u901A\u8FC7" : "\u5BA1\u67E5\u4E0D\u901A\u8FC7";
6068
6072
  }
6069
6073
  function inclusionLabel(branch, incomplete) {
6074
+ if (branch.unresolved) return "\u5206\u652F\u5F02\u5E38\uFF1A" + branch.unresolved;
6070
6075
  if (incomplete || !branch.expectedCommits) return "\u672A\u5B8C\u6210\u68C0\u67E5";
6071
6076
  const missing = branch.missingCommits || [];
6072
6077
  if (!missing.length) return "\u5DF2\u5305\u542B";
@@ -6087,25 +6092,31 @@ function readableReport(snapshot, result, createdAt, _runId) {
6087
6092
  "\u7ED3\u679C\uFF1A" + reviewLabel(result),
6088
6093
  "\u5BA1\u67E5\u65F6\u95F4\uFF1A" + createdAt,
6089
6094
  ...uncoveredRequirementLines(snapshot.uncoveredRequirements),
6090
- ...snapshot.results.flatMap((repo) => [
6091
- "",
6092
- "## " + repo.alias,
6093
- ...repo.error ? [repo.error] : [],
6094
- ...repo.status === "CONFLICT" ? ["staging \u5408\u5165 production \u5B58\u5728\u51B2\u7A81"] : [],
6095
- "| \u7248\u672C\u5185\u5206\u652F | staging \u662F\u5426\u5305\u542B |",
6096
- "| --- | --- |",
6097
- ...repo.branches.map(
6098
- (b) => `| ${safe(b.name)} | ${inclusionLabel(b, repo.status === "ERROR")} |`
6099
- ),
6100
- ...(repo.nonVersionEntries || []).length ? [
6095
+ ...snapshot.results.flatMap((repo) => {
6096
+ const unresolved = (repo.branches || []).filter((branch) => branch.unresolved);
6097
+ return [
6101
6098
  "",
6102
- "| staging \u591A\u51FA\u7684\u975E\u7248\u672C\u5185\u5206\u652F / commit ID | \u7ED3\u679C |",
6099
+ "## " + repo.alias,
6100
+ ...repo.error ? [repo.error] : [],
6101
+ ...unresolved.length ? [
6102
+ "\u5206\u652F\u5F02\u5E38\uFF08\u8FDC\u7AEF\u4E0D\u5B58\u5728\uFF0C\u53EF\u80FD\u5C1A\u672A\u63A8\u9001\uFF1B\u540C\u4ED3\u5E93\u5176\u4ED6\u5206\u652F\u5DF2\u7167\u5E38\u68C0\u67E5\uFF09\uFF1A" + unresolved.map((branch) => branch.name).join("\u3001")
6103
+ ] : [],
6104
+ ...repo.status === "CONFLICT" ? ["staging \u5408\u5165 production \u5B58\u5728\u51B2\u7A81"] : [],
6105
+ "| \u7248\u672C\u5185\u5206\u652F | staging \u662F\u5426\u5305\u542B |",
6103
6106
  "| --- | --- |",
6104
- ...repo.nonVersionEntries.map(
6105
- (entry) => `| ${safe(entry.name || entry.sha)} | ${safe(entry.reason)} |`
6106
- )
6107
- ] : []
6108
- ])
6107
+ ...repo.branches.map(
6108
+ (b) => `| ${safe(b.name)} | ${inclusionLabel(b, repo.status === "ERROR")} |`
6109
+ ),
6110
+ ...(repo.nonVersionEntries || []).length ? [
6111
+ "",
6112
+ "| staging \u591A\u51FA\u7684\u975E\u7248\u672C\u5185\u5206\u652F / commit ID | \u7ED3\u679C |",
6113
+ "| --- | --- |",
6114
+ ...repo.nonVersionEntries.map(
6115
+ (entry) => `| ${safe(entry.name || entry.sha)} | ${safe(entry.reason)} |`
6116
+ )
6117
+ ] : []
6118
+ ];
6119
+ })
6109
6120
  ].join("\n");
6110
6121
  }
6111
6122
 
@@ -6148,9 +6159,11 @@ async function auditLocalVersion(initial, root, runId, inputHash, body, log) {
6148
6159
  const results = [], folders = [];
6149
6160
  const groups = [...new Set(includedMounts.map((mount) => mount.repository_id))];
6150
6161
  const emptyRepositories = /* @__PURE__ */ new Set();
6151
- log("\u5BA1\u67E5\u4ED3\u5E93\u603B\u6570\uFF1A" + groups.length);
6152
6162
  excludedRepositories.forEach((repo) => log("\u5DF2\u6392\u9664\uFF1A" + repo.alias + "\uFF08" + repo.reason + "\uFF09"));
6153
- for (const repositoryId of groups) {
6163
+ let kept = 0;
6164
+ const reportTotal = (remaining) => log("\u5BA1\u67E5\u4ED3\u5E93\u603B\u6570\uFF1A" + (kept + remaining));
6165
+ reportTotal(groups.length);
6166
+ for (const [index, repositoryId] of groups.entries()) {
6154
6167
  const entries = includedMounts.filter((entry) => entry.repository_id === repositoryId), repo = entries[0];
6155
6168
  const directory = path26.join(root, repositoryId.replace(/[^a-zA-Z0-9_-]/g, "_"));
6156
6169
  const result2 = {
@@ -6176,17 +6189,21 @@ async function auditLocalVersion(initial, root, runId, inputHash, body, log) {
6176
6189
  if (!localOrigin && !/^(https:\/\/|ssh:\/\/|[\w.-]+@[\w.-]+:)/.test(remote) || remote.includes("::") || /[\s\x00-\x1f]/.test(remote) || /https?:\/\/[^/]*@/.test(remote))
6177
6190
  throw new Error("\u8FDC\u7AEF\u5730\u5740\u65E0\u6548");
6178
6191
  await git3(root, ["clone", "--no-checkout", "--no-local", "--", remote, directory]);
6179
- folders.push({ name: repo.alias, path: directory });
6180
6192
  result2.remoteRefs = await frozenRefs(git3, directory);
6181
- log("\u4ED3\u5E93\u5FEB\u7167\u5DF2\u83B7\u53D6\uFF1A" + repo.alias);
6182
- const resolveBranch = async (branch) => {
6183
- if (!valid(branch)) throw new Error("\u9700\u6C42\u5206\u652F\u540D\u65E0\u6548\u6216\u7F3A\u5931");
6184
- const clean = branch.replace(/^refs\/remotes\/origin\//, "").replace(/^origin\//, "").replace(/^refs\/heads\//, "");
6193
+ log("\u5DF2\u83B7\u53D6\u8FDC\u7AEF\u5FEB\u7167\uFF1A" + repo.alias);
6194
+ const cleanBranchName = (branch) => branch.replace(/^refs\/remotes\/origin\//, "").replace(/^origin\//, "").replace(/^refs\/heads\//, "");
6195
+ const resolveOptional = async (branch) => {
6196
+ if (!valid(branch)) return { sha: "", error: "\u9700\u6C42\u5206\u652F\u540D\u65E0\u6548\u6216\u7F3A\u5931" };
6197
+ const clean = cleanBranchName(branch);
6185
6198
  const ref = result2.remoteRefs.find(
6186
6199
  (item) => item.name === clean
6187
6200
  );
6188
- if (!ref) throw new Error(repo.alias + "\uFF1A\u8FDC\u7AEF\u5206\u652F\u4E0D\u5B58\u5728\uFF1A" + clean);
6189
- return ref.sha;
6201
+ return ref ? { sha: ref.sha, error: "" } : { sha: "", error: repo.alias + "\uFF1A\u8FDC\u7AEF\u5206\u652F\u4E0D\u5B58\u5728\uFF1A" + clean };
6202
+ };
6203
+ const resolveBranch = async (branch) => {
6204
+ const { sha, error } = await resolveOptional(branch);
6205
+ if (!sha) throw new Error(error);
6206
+ return sha;
6190
6207
  };
6191
6208
  const compareName = (repo.compare_branch || "").replace(/^origin\//, "") || production;
6192
6209
  const baseSha = await resolveBranch(compareName).catch(() => "");
@@ -6207,26 +6224,32 @@ async function auditLocalVersion(initial, root, runId, inputHash, body, log) {
6207
6224
  if (!activeEntries.length) {
6208
6225
  results.splice(results.indexOf(result2), 1);
6209
6226
  emptyRepositories.add(repositoryId);
6210
- const folderIndex = folders.findIndex((folder) => folder.name === repo.alias);
6211
- if (folderIndex >= 0) folders.splice(folderIndex, 1);
6212
6227
  excludedRepositories.push({
6213
6228
  repositoryId,
6214
6229
  alias: repo.alias,
6215
6230
  reason: "\u5206\u652F\u76F8\u5BF9 " + compareName + " \u65E0\u6539\u52A8"
6216
6231
  });
6217
6232
  log("\u5DF2\u6392\u9664\uFF1A" + repo.alias + "\uFF08\u5206\u652F\u76F8\u5BF9 " + compareName + " \u65E0\u6539\u52A8\uFF09");
6233
+ reportTotal(groups.length - index - 1);
6218
6234
  continue;
6219
6235
  }
6220
6236
  entries.length = 0;
6221
6237
  entries.push(...activeEntries);
6238
+ folders.push({ name: repo.alias, path: directory });
6239
+ kept += 1;
6240
+ log("\u4ED3\u5E93\u5FEB\u7167\u5DF2\u83B7\u53D6\uFF1A" + repo.alias);
6222
6241
  const p = await resolveBranch(production), s = await resolveBranch(staging);
6223
6242
  result2.refs = { production: p, staging: s };
6224
- for (const branch of [...new Set(activeEntries.map((entry) => entry.branch))])
6243
+ for (const branch of [...new Set(activeEntries.map((entry) => entry.branch))]) {
6244
+ const resolution = await resolveOptional(branch);
6225
6245
  result2.branches.push({
6226
6246
  name: branch,
6227
- sha: await resolveBranch(branch),
6247
+ sha: resolution.sha,
6248
+ ...resolution.error ? { unresolved: resolution.error } : {},
6228
6249
  requirementIds: activeEntries.filter((entry) => entry.branch === branch).map((entry) => entry.requirement_id)
6229
6250
  });
6251
+ if (resolution.error) log(resolution.error);
6252
+ }
6230
6253
  log("\u5F00\u59CB\u5B8C\u6574\u6027\u68C0\u67E5\uFF1A" + repo.alias);
6231
6254
  let mergeConflict = false;
6232
6255
  try {
@@ -6947,4 +6970,4 @@ async function cli(args, entry) {
6947
6970
  export {
6948
6971
  cli
6949
6972
  };
6950
- //# sourceMappingURL=cli-KVOOANBW.js.map
6973
+ //# sourceMappingURL=cli-7R2P2XQE.js.map