@adhdev/daemon-standalone 1.0.58-rc.14 → 1.0.58-rc.15
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/index.js +911 -717
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
- package/vendor/mcp-server/index.js +5 -3
- package/vendor/mcp-server/index.js.map +1 -1
package/dist/index.js
CHANGED
|
@@ -36882,10 +36882,10 @@ var require_dist3 = __commonJS({
|
|
|
36882
36882
|
}
|
|
36883
36883
|
function getDaemonBuildInfo() {
|
|
36884
36884
|
if (cached2) return cached2;
|
|
36885
|
-
const commit = readInjected(true ? "
|
|
36886
|
-
const commitShort = readInjected(true ? "
|
|
36887
|
-
const version2 = readInjected(true ? "1.0.58-rc.
|
|
36888
|
-
const builtAt = readInjected(true ? "2026-08-
|
|
36885
|
+
const commit = readInjected(true ? "0b39364ac334ce9649b42e58d5bda606abe274ec" : void 0) ?? "unknown";
|
|
36886
|
+
const commitShort = readInjected(true ? "0b39364a" : void 0) ?? (commit !== "unknown" ? commit.slice(0, 7) : "unknown");
|
|
36887
|
+
const version2 = readInjected(true ? "1.0.58-rc.15" : void 0) ?? readInjected(typeof process !== "undefined" ? process.env?.ADHDEV_PKG_VERSION : void 0) ?? "unknown";
|
|
36888
|
+
const builtAt = readInjected(true ? "2026-08-26T02:38:01.516Z" : void 0);
|
|
36889
36889
|
cached2 = builtAt ? { commit, commitShort, version: version2, builtAt } : { commit, commitShort, version: version2 };
|
|
36890
36890
|
return cached2;
|
|
36891
36891
|
}
|
|
@@ -46233,6 +46233,20 @@ Next step: ${nextStep}`;
|
|
|
46233
46233
|
`[System] Refinery async job for ${args.nodeLabel} failed${details ? ` (${details})` : ""}${error48 ? `: ${error48}` : "."}`,
|
|
46234
46234
|
nextStep ? `Next step: ${nextStep}` : "Review the terminal refine event/ledger before retrying."
|
|
46235
46235
|
];
|
|
46236
|
+
const batchResults = result?.batch === true && Array.isArray(result?.results) ? result.results : [];
|
|
46237
|
+
const failedNodes = batchResults.filter((entry) => entry && entry.convergence !== "merged_to_main" && entry.convergence !== "skipped_patch_equivalent");
|
|
46238
|
+
if (failedNodes.length > 0) {
|
|
46239
|
+
parts.push("Per-node failures:");
|
|
46240
|
+
for (const entry of failedNodes) {
|
|
46241
|
+
const nodeId = readNonEmptyString(entry.nodeId) || "(unknown node)";
|
|
46242
|
+
const nodeConvergence = readNonEmptyString(entry.convergence);
|
|
46243
|
+
const nodeCode = readNonEmptyString(entry.code);
|
|
46244
|
+
const nodeStage = readNonEmptyString(entry.stage);
|
|
46245
|
+
const nodeError = readNonEmptyString(entry.error);
|
|
46246
|
+
const codeStage = [nodeCode ? `code=${nodeCode}` : "", nodeStage ? `stage=${nodeStage}` : ""].filter(Boolean).join(", ");
|
|
46247
|
+
parts.push(`- ${nodeId}${nodeConvergence ? `: ${nodeConvergence}` : ""}${codeStage ? ` (${codeStage})` : ""}${nodeError ? ` \u2014 ${nodeError.length > 200 ? `${nodeError.slice(0, 200)}\u2026` : nodeError}` : ""}`);
|
|
46248
|
+
}
|
|
46249
|
+
}
|
|
46236
46250
|
return parts.join("\n");
|
|
46237
46251
|
}
|
|
46238
46252
|
return "";
|
|
@@ -60646,7 +60660,7 @@ When the user asks to **set up / configure / onboard** this repo for Repo Mesh (
|
|
|
60646
60660
|
const remote = opts.remote?.trim() || "origin";
|
|
60647
60661
|
const localTimeout = opts.timeoutMs ?? 1e4;
|
|
60648
60662
|
const git3 = resolveWin32Executable("git");
|
|
60649
|
-
const
|
|
60663
|
+
const execFileAsync8 = (0, import_node_util3.promisify)(import_node_child_process4.execFile);
|
|
60650
60664
|
if (opts.superprojectWorkspace && opts.submodulePath) {
|
|
60651
60665
|
try {
|
|
60652
60666
|
const normalized = opts.submodulePath.replace(/\\/g, "/").replace(/\/+$/, "");
|
|
@@ -60656,7 +60670,7 @@ When the user asks to **set up / configure / onboard** this repo for Repo Mesh (
|
|
|
60656
60670
|
}
|
|
60657
60671
|
}
|
|
60658
60672
|
try {
|
|
60659
|
-
const { stdout } = await
|
|
60673
|
+
const { stdout } = await execFileAsync8(
|
|
60660
60674
|
git3,
|
|
60661
60675
|
["symbolic-ref", "--short", `refs/remotes/${remote}/HEAD`],
|
|
60662
60676
|
{ cwd: opts.submoduleRepoPath, encoding: "utf8", timeout: localTimeout, windowsHide: true }
|
|
@@ -60668,7 +60682,7 @@ When the user asks to **set up / configure / onboard** this repo for Repo Mesh (
|
|
|
60668
60682
|
} catch {
|
|
60669
60683
|
}
|
|
60670
60684
|
try {
|
|
60671
|
-
const { stdout } = await
|
|
60685
|
+
const { stdout } = await execFileAsync8(
|
|
60672
60686
|
git3,
|
|
60673
60687
|
["ls-remote", "--symref", remote, "HEAD"],
|
|
60674
60688
|
{ cwd: opts.submoduleRepoPath, encoding: "utf8", timeout: Math.max(localTimeout, 3e4), windowsHide: true }
|
|
@@ -60839,7 +60853,7 @@ When the user asks to **set up / configure / onboard** this repo for Repo Mesh (
|
|
|
60839
60853
|
if (!validation.valid) {
|
|
60840
60854
|
return { status: "failed", required: required2, configSource: loaded.path || loaded.source, configSourceType: "invalid", error: String(validation.rejectedCommands[0]?.reason || validation.errors.join("; ")), commandsRun: [] };
|
|
60841
60855
|
}
|
|
60842
|
-
const
|
|
60856
|
+
const execFileAsync8 = (0, import_node_util3.promisify)(import_node_child_process4.execFile);
|
|
60843
60857
|
const state = {
|
|
60844
60858
|
status: "running",
|
|
60845
60859
|
required: required2,
|
|
@@ -60867,7 +60881,7 @@ When the user asks to **set up / configure / onboard** this repo for Repo Mesh (
|
|
|
60867
60881
|
const resolvedCommand = resolveWin32Executable(command.command);
|
|
60868
60882
|
const spawn7 = buildWin32ExecFileSpawn(resolvedCommand, command.args);
|
|
60869
60883
|
try {
|
|
60870
|
-
const result = await
|
|
60884
|
+
const result = await execFileAsync8(spawn7.file, spawn7.args, {
|
|
60871
60885
|
cwd,
|
|
60872
60886
|
encoding: "utf8",
|
|
60873
60887
|
timeout: command.timeoutMs || DEFAULT_TIMEOUT_MS2,
|
|
@@ -76631,9 +76645,9 @@ ${cleanBody}`;
|
|
|
76631
76645
|
}
|
|
76632
76646
|
}
|
|
76633
76647
|
async function defaultRunGit(args, cwd) {
|
|
76634
|
-
const { execFile:
|
|
76635
|
-
const { promisify:
|
|
76636
|
-
const { stdout } = await
|
|
76648
|
+
const { execFile: execFile9 } = await import("child_process");
|
|
76649
|
+
const { promisify: promisify12 } = await import("util");
|
|
76650
|
+
const { stdout } = await promisify12(execFile9)("git", args, {
|
|
76637
76651
|
cwd,
|
|
76638
76652
|
encoding: "utf8",
|
|
76639
76653
|
timeout: 3e4,
|
|
@@ -83316,435 +83330,9 @@ ${cleanBody}`;
|
|
|
83316
83330
|
_acpValidator = null;
|
|
83317
83331
|
}
|
|
83318
83332
|
});
|
|
83319
|
-
function topLevel(path63) {
|
|
83320
|
-
const slash = path63.indexOf("/");
|
|
83321
|
-
return slash === -1 ? path63 : path63.slice(0, slash);
|
|
83322
|
-
}
|
|
83323
|
-
async function analyzeMeshRefineNodeChangeArea(args) {
|
|
83324
|
-
const { nodeId, workspace, branch, baseRef, branchRef, diffCwd, submodulePaths } = args;
|
|
83325
|
-
const base = {
|
|
83326
|
-
nodeId,
|
|
83327
|
-
workspace,
|
|
83328
|
-
branch,
|
|
83329
|
-
changedTopLevelPaths: [],
|
|
83330
|
-
changedFiles: [],
|
|
83331
|
-
touchedSubmodulePaths: [],
|
|
83332
|
-
touchesSubmodule: false,
|
|
83333
|
-
aheadCount: 0
|
|
83334
|
-
};
|
|
83335
|
-
try {
|
|
83336
|
-
let mergeBase = baseRef;
|
|
83337
|
-
try {
|
|
83338
|
-
const { stdout } = await execFileAsync5(GIT2, ["merge-base", baseRef, branchRef], { cwd: diffCwd, encoding: "utf8" });
|
|
83339
|
-
const resolved = stdout.trim();
|
|
83340
|
-
if (resolved) mergeBase = resolved;
|
|
83341
|
-
} catch {
|
|
83342
|
-
}
|
|
83343
|
-
const { stdout: countStdout } = await execFileAsync5(
|
|
83344
|
-
GIT2,
|
|
83345
|
-
["rev-list", "--count", `${mergeBase}..${branchRef}`],
|
|
83346
|
-
{ cwd: diffCwd, encoding: "utf8" }
|
|
83347
|
-
);
|
|
83348
|
-
base.aheadCount = Number.parseInt(countStdout.trim(), 10) || 0;
|
|
83349
|
-
const { stdout: nameStdout } = await execFileAsync5(
|
|
83350
|
-
GIT2,
|
|
83351
|
-
["diff", "--name-only", `${mergeBase}..${branchRef}`],
|
|
83352
|
-
{ cwd: diffCwd, encoding: "utf8" }
|
|
83353
|
-
);
|
|
83354
|
-
const files = nameStdout.split("\n").map((line) => line.trim()).filter(Boolean).slice(0, MAX_CHANGED_FILES2);
|
|
83355
|
-
base.changedFiles = files;
|
|
83356
|
-
const topSet = /* @__PURE__ */ new Set();
|
|
83357
|
-
const submoduleSet = /* @__PURE__ */ new Set();
|
|
83358
|
-
for (const file2 of files) {
|
|
83359
|
-
const top = topLevel(file2);
|
|
83360
|
-
topSet.add(top);
|
|
83361
|
-
if (submodulePaths.has(file2) || submodulePaths.has(top)) {
|
|
83362
|
-
submoduleSet.add(submodulePaths.has(file2) ? file2 : top);
|
|
83363
|
-
}
|
|
83364
|
-
}
|
|
83365
|
-
base.changedTopLevelPaths = [...topSet].sort();
|
|
83366
|
-
base.touchedSubmodulePaths = [...submoduleSet].sort();
|
|
83367
|
-
base.touchesSubmodule = submoduleSet.size > 0;
|
|
83368
|
-
return base;
|
|
83369
|
-
} catch (e) {
|
|
83370
|
-
base.error = e?.message || String(e);
|
|
83371
|
-
return base;
|
|
83372
|
-
}
|
|
83373
|
-
}
|
|
83374
|
-
function orderMeshRefineBatchNodes(changeAreas) {
|
|
83375
|
-
const areaById = {};
|
|
83376
|
-
for (const area of changeAreas) areaById[area.nodeId] = area;
|
|
83377
|
-
const ranked = [...changeAreas].sort((a, b) => {
|
|
83378
|
-
const aSub = a.touchesSubmodule ? 1 : 0;
|
|
83379
|
-
const bSub = b.touchesSubmodule ? 1 : 0;
|
|
83380
|
-
if (aSub !== bSub) return aSub - bSub;
|
|
83381
|
-
const aBreadth = a.changedTopLevelPaths.length;
|
|
83382
|
-
const bBreadth = b.changedTopLevelPaths.length;
|
|
83383
|
-
if (aBreadth !== bBreadth) return aBreadth - bBreadth;
|
|
83384
|
-
return a.nodeId.localeCompare(b.nodeId);
|
|
83385
|
-
});
|
|
83386
|
-
const rationale = [];
|
|
83387
|
-
const nonSub = ranked.filter((a) => !a.touchesSubmodule).map((a) => a.nodeId);
|
|
83388
|
-
const sub = ranked.filter((a) => a.touchesSubmodule).map((a) => a.nodeId);
|
|
83389
|
-
if (nonSub.length) {
|
|
83390
|
-
rationale.push(`Non-submodule nodes first (no submodule-main advance, conflict-free ordering): ${nonSub.join(", ")}`);
|
|
83391
|
-
}
|
|
83392
|
-
if (sub.length) {
|
|
83393
|
-
rationale.push(`Submodule-touching nodes last, serialized (each merge advances submodule main, forcing rebase of the next): ${sub.join(", ")}`);
|
|
83394
|
-
}
|
|
83395
|
-
for (const area of ranked) {
|
|
83396
|
-
if (area.error) rationale.push(`Node ${area.nodeId}: change-area analysis degraded (${area.error}); placed with neutral priority.`);
|
|
83397
|
-
}
|
|
83398
|
-
return { order: ranked.map((a) => a.nodeId), changeAreas: areaById, rationale };
|
|
83399
|
-
}
|
|
83400
|
-
var import_node_child_process10;
|
|
83401
|
-
var import_node_util6;
|
|
83402
|
-
var execFileAsync5;
|
|
83403
|
-
var GIT2;
|
|
83404
|
-
var MAX_CHANGED_FILES2;
|
|
83405
|
-
var init_mesh_refine_batch = __esm2({
|
|
83406
|
-
"src/mesh/mesh-refine-batch.ts"() {
|
|
83407
|
-
"use strict";
|
|
83408
|
-
import_node_child_process10 = require("child_process");
|
|
83409
|
-
import_node_util6 = require("util");
|
|
83410
|
-
init_resolve_executable();
|
|
83411
|
-
execFileAsync5 = (0, import_node_util6.promisify)(import_node_child_process10.execFile);
|
|
83412
|
-
GIT2 = process.platform === "win32" ? resolveWin32Executable("git") : "git";
|
|
83413
|
-
MAX_CHANGED_FILES2 = 500;
|
|
83414
|
-
}
|
|
83415
|
-
});
|
|
83416
|
-
async function git2(cwd, args) {
|
|
83417
|
-
const { stdout } = await execFileAsync6(GIT3, args, {
|
|
83418
|
-
cwd,
|
|
83419
|
-
encoding: "utf8",
|
|
83420
|
-
timeout: 15e3,
|
|
83421
|
-
windowsHide: true
|
|
83422
|
-
});
|
|
83423
|
-
return String(stdout || "").trim();
|
|
83424
|
-
}
|
|
83425
|
-
async function isAncestor(cwd, ancestor, descendant) {
|
|
83426
|
-
try {
|
|
83427
|
-
await git2(cwd, ["merge-base", "--is-ancestor", ancestor, descendant]);
|
|
83428
|
-
return true;
|
|
83429
|
-
} catch {
|
|
83430
|
-
return false;
|
|
83431
|
-
}
|
|
83432
|
-
}
|
|
83433
|
-
async function assessScope(cwd, path63, baseRef, branchRef) {
|
|
83434
|
-
try {
|
|
83435
|
-
if (!(0, import_node_fs7.existsSync)(cwd)) return { path: path63, verdict: "unknown", error: `path does not exist: ${cwd}` };
|
|
83436
|
-
const liveBaseHead = await git2(cwd, ["rev-parse", baseRef]);
|
|
83437
|
-
const branchHead = await git2(cwd, ["rev-parse", branchRef]);
|
|
83438
|
-
if (!liveBaseHead || !branchHead) {
|
|
83439
|
-
return { path: path63, verdict: "unknown", error: "could not resolve base or branch head" };
|
|
83440
|
-
}
|
|
83441
|
-
if (await isAncestor(cwd, liveBaseHead, branchHead)) {
|
|
83442
|
-
return { path: path63, verdict: "clear", liveBaseHead };
|
|
83443
|
-
}
|
|
83444
|
-
let mergeBase;
|
|
83445
|
-
try {
|
|
83446
|
-
mergeBase = await git2(cwd, ["merge-base", liveBaseHead, branchHead]);
|
|
83447
|
-
} catch {
|
|
83448
|
-
return { path: path63, verdict: "unknown", liveBaseHead, error: "no common merge base" };
|
|
83449
|
-
}
|
|
83450
|
-
if (!mergeBase) return { path: path63, verdict: "unknown", liveBaseHead, error: "empty merge base" };
|
|
83451
|
-
return { path: path63, verdict: "diverged", liveBaseHead, mergeBase };
|
|
83452
|
-
} catch (e) {
|
|
83453
|
-
return { path: path63, verdict: "unknown", error: e?.message || String(e) };
|
|
83454
|
-
}
|
|
83455
|
-
}
|
|
83456
|
-
async function resolveSubmodulePaths(repoRoot) {
|
|
83457
|
-
try {
|
|
83458
|
-
const stdout = await git2(repoRoot, ["config", "--file", ".gitmodules", "--get-regexp", "path"]);
|
|
83459
|
-
const paths = /* @__PURE__ */ new Set();
|
|
83460
|
-
for (const line of stdout.split("\n")) {
|
|
83461
|
-
const trimmed = line.trim();
|
|
83462
|
-
const spaceIdx = trimmed.indexOf(" ");
|
|
83463
|
-
if (spaceIdx === -1) continue;
|
|
83464
|
-
const value = trimmed.slice(spaceIdx + 1).trim();
|
|
83465
|
-
if (value) paths.add(value);
|
|
83466
|
-
}
|
|
83467
|
-
return paths;
|
|
83468
|
-
} catch {
|
|
83469
|
-
return /* @__PURE__ */ new Set();
|
|
83470
|
-
}
|
|
83471
|
-
}
|
|
83472
|
-
async function assessRefineBaseDivergence(args) {
|
|
83473
|
-
const started = Date.now();
|
|
83474
|
-
const { repoRoot, workspace, baseBranch, branch } = args;
|
|
83475
|
-
const scopes = [];
|
|
83476
|
-
let touchedSubmodulePaths = [];
|
|
83477
|
-
const rootBaseRef = await (async () => {
|
|
83478
|
-
for (const ref of [`origin/${baseBranch}`, baseBranch, "HEAD"]) {
|
|
83479
|
-
try {
|
|
83480
|
-
await git2(repoRoot, ["rev-parse", "--verify", `${ref}^{commit}`]);
|
|
83481
|
-
return ref;
|
|
83482
|
-
} catch {
|
|
83483
|
-
}
|
|
83484
|
-
}
|
|
83485
|
-
return `origin/${baseBranch}`;
|
|
83486
|
-
})();
|
|
83487
|
-
scopes.push(await assessScope(workspace, ".", rootBaseRef, branch));
|
|
83488
|
-
try {
|
|
83489
|
-
const submodulePaths = await resolveSubmodulePaths(repoRoot);
|
|
83490
|
-
if (submodulePaths.size > 0) {
|
|
83491
|
-
const baseRefSha = await git2(repoRoot, ["rev-parse", rootBaseRef]).catch(() => "");
|
|
83492
|
-
const branchRefSha = await git2(workspace, ["rev-parse", branch]).catch(() => "");
|
|
83493
|
-
if (baseRefSha && branchRefSha) {
|
|
83494
|
-
const area = await analyzeMeshRefineNodeChangeArea({
|
|
83495
|
-
nodeId: "(accept-precheck)",
|
|
83496
|
-
workspace,
|
|
83497
|
-
branch,
|
|
83498
|
-
baseRef: baseRefSha,
|
|
83499
|
-
branchRef: branchRefSha,
|
|
83500
|
-
diffCwd: workspace,
|
|
83501
|
-
submodulePaths
|
|
83502
|
-
});
|
|
83503
|
-
touchedSubmodulePaths = area.touchedSubmodulePaths;
|
|
83504
|
-
for (const subPath of touchedSubmodulePaths) {
|
|
83505
|
-
const subCwd = (0, import_node_path5.resolve)(workspace, subPath);
|
|
83506
|
-
const subBaseRef = await (async () => {
|
|
83507
|
-
for (const ref of ["origin/main", "origin/master", "main", "master"]) {
|
|
83508
|
-
try {
|
|
83509
|
-
await git2(subCwd, ["rev-parse", "--verify", `${ref}^{commit}`]);
|
|
83510
|
-
return ref;
|
|
83511
|
-
} catch {
|
|
83512
|
-
}
|
|
83513
|
-
}
|
|
83514
|
-
return "origin/main";
|
|
83515
|
-
})();
|
|
83516
|
-
scopes.push(await assessScope(subCwd, subPath, subBaseRef, "HEAD"));
|
|
83517
|
-
}
|
|
83518
|
-
}
|
|
83519
|
-
}
|
|
83520
|
-
} catch {
|
|
83521
|
-
}
|
|
83522
|
-
const verdict = scopes.some((s2) => s2.verdict === "diverged") ? "diverged" : scopes.some((s2) => s2.verdict === "unknown") ? "unknown" : "clear";
|
|
83523
|
-
return { verdict, scopes, touchedSubmodulePaths, durationMs: Date.now() - started };
|
|
83524
|
-
}
|
|
83525
|
-
var import_node_child_process11;
|
|
83526
|
-
var import_node_util7;
|
|
83527
|
-
var import_node_path5;
|
|
83528
|
-
var import_node_fs7;
|
|
83529
|
-
var execFileAsync6;
|
|
83530
|
-
var GIT3;
|
|
83531
|
-
var init_mesh_refine_base_divergence = __esm2({
|
|
83532
|
-
"src/mesh/mesh-refine-base-divergence.ts"() {
|
|
83533
|
-
"use strict";
|
|
83534
|
-
import_node_child_process11 = require("child_process");
|
|
83535
|
-
import_node_util7 = require("util");
|
|
83536
|
-
import_node_path5 = require("path");
|
|
83537
|
-
import_node_fs7 = require("fs");
|
|
83538
|
-
init_resolve_executable();
|
|
83539
|
-
init_mesh_refine_batch();
|
|
83540
|
-
execFileAsync6 = (0, import_node_util7.promisify)(import_node_child_process11.execFile);
|
|
83541
|
-
GIT3 = process.platform === "win32" ? resolveWin32Executable("git") : "git";
|
|
83542
|
-
}
|
|
83543
|
-
});
|
|
83544
|
-
var mesh_refine_zombie_sweep_exports = {};
|
|
83545
|
-
__export2(mesh_refine_zombie_sweep_exports, {
|
|
83546
|
-
classifyRefineDispatch: () => classifyRefineDispatch,
|
|
83547
|
-
refineArchivePairKey: () => refineArchivePairKey,
|
|
83548
|
-
selectOpenRefineDispatches: () => selectOpenRefineDispatches,
|
|
83549
|
-
shouldNotifyRefineCloseOut: () => shouldNotifyRefineCloseOut
|
|
83550
|
-
});
|
|
83551
|
-
function classifyRefineDispatch(record2, opts) {
|
|
83552
|
-
if (opts.isRunning(record2.nodeId)) return void 0;
|
|
83553
|
-
const dispatchedAtMs = new Date(record2.timestamp).getTime();
|
|
83554
|
-
const ageMs2 = Number.isFinite(dispatchedAtMs) ? opts.nowMs - dispatchedAtMs : void 0;
|
|
83555
|
-
const base = { nodeId: record2.nodeId, jobId: record2.jobId, ...ageMs2 !== void 0 ? { ageMs: ageMs2 } : {} };
|
|
83556
|
-
if (!opts.nodeExists(record2.nodeId)) {
|
|
83557
|
-
return { ...base, disposition: "close_removed_node" };
|
|
83558
|
-
}
|
|
83559
|
-
if (opts.executorLiveness) {
|
|
83560
|
-
let liveness;
|
|
83561
|
-
try {
|
|
83562
|
-
liveness = opts.executorLiveness(record2);
|
|
83563
|
-
} catch {
|
|
83564
|
-
liveness = "unknown";
|
|
83565
|
-
}
|
|
83566
|
-
if (liveness === "alive") {
|
|
83567
|
-
return { ...base, disposition: "defer_executor_alive" };
|
|
83568
|
-
}
|
|
83569
|
-
}
|
|
83570
|
-
if (ageMs2 !== void 0 && ageMs2 >= 0 && ageMs2 < opts.graceMs) {
|
|
83571
|
-
return { ...base, disposition: "defer_grace" };
|
|
83572
|
-
}
|
|
83573
|
-
if (ageMs2 !== void 0 && ageMs2 >= opts.zombieCutoffMs) {
|
|
83574
|
-
return { ...base, disposition: "close_stale" };
|
|
83575
|
-
}
|
|
83576
|
-
return { ...base, disposition: "resume" };
|
|
83577
|
-
}
|
|
83578
|
-
function selectOpenRefineDispatches(entries, archivedTerminalKeys) {
|
|
83579
|
-
const terminalKeys = /* @__PURE__ */ new Set();
|
|
83580
|
-
for (const e of entries) {
|
|
83581
|
-
if (e.kind !== "task_completed" && e.kind !== "task_failed") continue;
|
|
83582
|
-
if (!e.nodeId) continue;
|
|
83583
|
-
const jobId = e.payload?.refineJob?.jobId;
|
|
83584
|
-
if (jobId) terminalKeys.add(`${e.nodeId}:${jobId}`);
|
|
83585
|
-
}
|
|
83586
|
-
const open = [];
|
|
83587
|
-
const seen = /* @__PURE__ */ new Set();
|
|
83588
|
-
for (const e of entries) {
|
|
83589
|
-
if (e.kind !== "task_dispatched" || !e.nodeId) continue;
|
|
83590
|
-
const payload = e.payload;
|
|
83591
|
-
if (payload?.source !== "refine_mesh_node_async_job") continue;
|
|
83592
|
-
const jobId = payload?.refineJob?.jobId;
|
|
83593
|
-
if (!jobId) continue;
|
|
83594
|
-
const key2 = `${e.nodeId}:${jobId}`;
|
|
83595
|
-
if (terminalKeys.has(key2) || seen.has(key2)) continue;
|
|
83596
|
-
if (archivedTerminalKeys?.has(refineArchivePairKey(e.nodeId, jobId))) continue;
|
|
83597
|
-
seen.add(key2);
|
|
83598
|
-
const executor = payload?.refineJob?.executor;
|
|
83599
|
-
open.push({ nodeId: e.nodeId, jobId, timestamp: e.timestamp, ...executor ? { executor } : {} });
|
|
83600
|
-
}
|
|
83601
|
-
return open;
|
|
83602
|
-
}
|
|
83603
|
-
function refineArchivePairKey(nodeId, jobId) {
|
|
83604
|
-
return `refine:${nodeId}:${jobId}`;
|
|
83605
|
-
}
|
|
83606
|
-
function shouldNotifyRefineCloseOut(decision, notifyHorizonMs) {
|
|
83607
|
-
if (decision.disposition === "close_removed_node") return false;
|
|
83608
|
-
if (decision.disposition !== "close_stale") return false;
|
|
83609
|
-
if (decision.ageMs === void 0) return true;
|
|
83610
|
-
return decision.ageMs < notifyHorizonMs;
|
|
83611
|
-
}
|
|
83612
|
-
var init_mesh_refine_zombie_sweep = __esm2({
|
|
83613
|
-
"src/mesh/mesh-refine-zombie-sweep.ts"() {
|
|
83614
|
-
"use strict";
|
|
83615
|
-
}
|
|
83616
|
-
});
|
|
83617
|
-
function classifyRefineTerminal(result) {
|
|
83618
|
-
const refineCode = typeof result.code === "string" ? result.code : "";
|
|
83619
|
-
const landing = extractRefineMergeLanding(result);
|
|
83620
|
-
const isPostMergeWarning = result.success !== true && landing.merged && landing.pushed;
|
|
83621
|
-
const kind = result.success === true ? "completed" : isPostMergeWarning ? "completed_with_warnings" : refineCode === "blocked_review" || refineCode === "worktree_missing" || refineCode === "worktree_dirty" || refineCode === "rebase_precondition_failed" || refineCode === "rebase_failed" ? "blocked_review" : refineCode === "validation_failed" || refineCode === "validation_dependencies_missing" || refineCode === "missing_dependencies" || refineCode === "dependency_bootstrap_failed" || refineCode === "spawn_resolution_failed" || refineCode === "validation_unavailable" || refineCode === "output_limit_exceeded" ? "validation_failed" : refineCode === "submodule_reachability_failed" ? "submodule_reachability_failed" : refineCode === "merge_failed" || refineCode === "patch_equivalence_failed" || refineCode === "needs_rebase" || refineCode === "needs_rebase_with_conflicts" ? "merge_failed" : refineCode === "cleanup_failed" ? "cleanup_failed" : "merge_failed";
|
|
83622
|
-
const clean = kind === "completed";
|
|
83623
|
-
return { kind, landing, isPostMergeWarning, converged: clean || isPostMergeWarning, clean };
|
|
83624
|
-
}
|
|
83625
|
-
function refineTerminalNextStep(kind) {
|
|
83626
|
-
switch (kind) {
|
|
83627
|
-
case "blocked_review":
|
|
83628
|
-
return "Request user review/approval before attempting to merge again.";
|
|
83629
|
-
case "validation_failed":
|
|
83630
|
-
return "Fix failing tests or configure validation.bootstrapCommands and retry mesh_refine_node.";
|
|
83631
|
-
case "submodule_reachability_failed":
|
|
83632
|
-
return "Push unreachable submodule commits to origin/main, then retry mesh_refine_node.";
|
|
83633
|
-
case "merge_failed":
|
|
83634
|
-
return "Resolve merge conflicts or patch equivalence issues, then retry mesh_refine_node.";
|
|
83635
|
-
case "cleanup_failed":
|
|
83636
|
-
return "Manually remove the worktree and retry or use mesh_remove_node.";
|
|
83637
|
-
case "completed_with_warnings":
|
|
83638
|
-
return "The merge IS on origin \u2014 do NOT re-run mesh_refine_node. Only the post-merge step below needs attention (worktree cleanup / submodule alignment); treat the branch as merged_to_main.";
|
|
83639
|
-
default:
|
|
83640
|
-
return "Inspect refineStages for the failing stage and retry.";
|
|
83641
|
-
}
|
|
83642
|
-
}
|
|
83643
|
-
function buildRefineWorktreeMissingResult(nodeId, workspace, refineStages) {
|
|
83644
|
-
return {
|
|
83645
|
-
success: false,
|
|
83646
|
-
code: "worktree_missing",
|
|
83647
|
-
convergenceStatus: "blocked_review",
|
|
83648
|
-
// Never auto-retried: re-running cannot recreate the worktree, and the node has
|
|
83649
|
-
// most likely already converged.
|
|
83650
|
-
retryable: false,
|
|
83651
|
-
workspaceMissing: true,
|
|
83652
|
-
error: `The worktree directory for node '${nodeId}' no longer exists (${workspace}); nothing was merged by this run. Worktree removal is the final step of a SUCCESSFUL refine, so this node was most likely already merged and cleaned up by an earlier job \u2014 verify with 'git -C <repoRoot> log --oneline' before acting. Do NOT re-run refine to "fix" this.`,
|
|
83653
|
-
nextStep: "Verify whether the branch already merged into the base (it most likely did). If so, treat the node as merged_to_main and remove it from the mesh; only re-clone if the work is genuinely missing.",
|
|
83654
|
-
refineStages,
|
|
83655
|
-
finalBranchConvergenceState: {
|
|
83656
|
-
baseBranch: void 0,
|
|
83657
|
-
merged: false,
|
|
83658
|
-
removed: true,
|
|
83659
|
-
status: "blocked_review"
|
|
83660
|
-
}
|
|
83661
|
-
};
|
|
83662
|
-
}
|
|
83663
|
-
function extractRefineMergeLanding(result) {
|
|
83664
|
-
const fbcs = result.finalBranchConvergenceState && typeof result.finalBranchConvergenceState === "object" ? result.finalBranchConvergenceState : void 0;
|
|
83665
|
-
const merged = result.merged === true || result.mergedLocal === true || fbcs?.merged === true;
|
|
83666
|
-
const pushed = result.pushed === true || fbcs?.pushed === true;
|
|
83667
|
-
return { merged: !!merged, pushed: !!pushed && !!merged };
|
|
83668
|
-
}
|
|
83669
|
-
function buildRefineBlockerContext(result, opts) {
|
|
83670
|
-
if (opts.isTerminalClean) return void 0;
|
|
83671
|
-
const refineTerminalKind = opts.terminalKind;
|
|
83672
|
-
const refineCode = typeof result.code === "string" ? result.code : "";
|
|
83673
|
-
const code = typeof result.code === "string" ? result.code : refineTerminalKind;
|
|
83674
|
-
const stage = refineTerminalKind === "validation_failed" ? "validation" : refineTerminalKind === "submodule_reachability_failed" ? "submodule_reachability" : refineCode === "patch_equivalence_failed" ? "patch_equivalence" : refineCode === "needs_rebase" || refineCode === "needs_rebase_with_conflicts" ? "patch_equivalence" : refineCode === "worktree_dirty" || refineCode === "rebase_precondition_failed" || refineCode === "rebase_failed" ? "patch_equivalence" : refineTerminalKind === "merge_failed" ? "merge" : refineTerminalKind === "cleanup_failed" ? "cleanup" : refineTerminalKind === "completed_with_warnings" ? refineCode === "post_merge_submodule_alignment_failed" ? "submodule_alignment" : "cleanup" : "unknown";
|
|
83675
|
-
const ctx = { stage, reason: code, terminalKind: refineTerminalKind };
|
|
83676
|
-
if (typeof result.error === "string") ctx.error = result.error;
|
|
83677
|
-
if (typeof result.blockedReason === "string") ctx.blockedReason = result.blockedReason;
|
|
83678
|
-
if (typeof result.detailedReason === "string") ctx.detailedReason = result.detailedReason;
|
|
83679
|
-
if (typeof result.detailedReasonDescription === "string") ctx.detailedReasonDescription = result.detailedReasonDescription;
|
|
83680
|
-
if (typeof result.recommendedAction === "string") ctx.recommendedAction = result.recommendedAction;
|
|
83681
|
-
if (result.evidence && typeof result.evidence === "object") ctx.evidence = result.evidence;
|
|
83682
|
-
if (typeof result.rebaseStderr === "string") ctx.rebaseStderr = result.rebaseStderr;
|
|
83683
|
-
if (typeof result.rebaseFailureDetail === "string") ctx.rebaseFailureDetail = result.rebaseFailureDetail;
|
|
83684
|
-
if (typeof result.rebaseConflict === "boolean") ctx.rebaseConflict = result.rebaseConflict;
|
|
83685
|
-
if (stage === "patch_equivalence" && result.patchEquivalence) {
|
|
83686
|
-
const pe = result.patchEquivalence;
|
|
83687
|
-
ctx.details = {
|
|
83688
|
-
expectedPatchId: pe.expectedPatchId,
|
|
83689
|
-
actualPatchId: pe.actualPatchId,
|
|
83690
|
-
status: pe.status,
|
|
83691
|
-
actionableHint: pe.actionableHint,
|
|
83692
|
-
error: pe.error,
|
|
83693
|
-
...typeof result.detailedReason === "string" ? { detailedReason: result.detailedReason } : {},
|
|
83694
|
-
...typeof result.recommendedAction === "string" ? { recommendedAction: result.recommendedAction } : {},
|
|
83695
|
-
...result.evidence && typeof result.evidence === "object" ? { evidence: result.evidence } : {}
|
|
83696
|
-
};
|
|
83697
|
-
}
|
|
83698
|
-
if (stage === "submodule_reachability" && Array.isArray(result.unreachableSubmoduleCommits)) {
|
|
83699
|
-
ctx.details = {
|
|
83700
|
-
unreachableCount: result.unreachableSubmoduleCommits.length,
|
|
83701
|
-
paths: result.unreachableSubmoduleCommits.map((e) => e.path),
|
|
83702
|
-
autoPublishAllowed: result.unreachableSubmoduleCommits[0]?.autoPublishAllowed
|
|
83703
|
-
};
|
|
83704
|
-
}
|
|
83705
|
-
if (stage === "validation" && result.validationSummary) {
|
|
83706
|
-
const vs = result.validationSummary;
|
|
83707
|
-
const diagnostics = opts.extractValidationDiagnostics?.(vs);
|
|
83708
|
-
ctx.details = {
|
|
83709
|
-
failureCode: vs.failureCode,
|
|
83710
|
-
failureKind: vs.failureKind,
|
|
83711
|
-
commandsRun: Array.isArray(vs.commandsRun) ? vs.commandsRun.length : void 0,
|
|
83712
|
-
...diagnostics ? { failure: diagnostics } : {}
|
|
83713
|
-
};
|
|
83714
|
-
}
|
|
83715
|
-
return ctx;
|
|
83716
|
-
}
|
|
83717
|
-
var init_mesh_refine_landing = __esm2({
|
|
83718
|
-
"src/mesh/mesh-refine-landing.ts"() {
|
|
83719
|
-
"use strict";
|
|
83720
|
-
}
|
|
83721
|
-
});
|
|
83722
|
-
function resolveRefineVitestMaxWorkers(env2 = process.env) {
|
|
83723
|
-
const raw = env2[REFINE_VITEST_MAX_WORKERS_ENV];
|
|
83724
|
-
if (raw === void 0 || raw.trim() === "") return DEFAULT_REFINE_VITEST_MAX_WORKERS;
|
|
83725
|
-
const parsed = Number.parseInt(raw, 10);
|
|
83726
|
-
if (!Number.isFinite(parsed)) return DEFAULT_REFINE_VITEST_MAX_WORKERS;
|
|
83727
|
-
if (parsed === 0) return null;
|
|
83728
|
-
return Math.max(1, parsed);
|
|
83729
|
-
}
|
|
83730
|
-
function refineGateChildEnv(env2 = process.env) {
|
|
83731
|
-
if (env2.VITEST_MAX_WORKERS) return {};
|
|
83732
|
-
const cap = resolveRefineVitestMaxWorkers(env2);
|
|
83733
|
-
if (cap === null) return {};
|
|
83734
|
-
return { VITEST_MAX_WORKERS: String(cap) };
|
|
83735
|
-
}
|
|
83736
|
-
var REFINE_VITEST_MAX_WORKERS_ENV;
|
|
83737
|
-
var DEFAULT_REFINE_VITEST_MAX_WORKERS;
|
|
83738
|
-
var init_mesh_refine_worker_cap = __esm2({
|
|
83739
|
-
"src/mesh/mesh-refine-worker-cap.ts"() {
|
|
83740
|
-
"use strict";
|
|
83741
|
-
REFINE_VITEST_MAX_WORKERS_ENV = "ADHDEV_REFINE_VITEST_MAX_WORKERS";
|
|
83742
|
-
DEFAULT_REFINE_VITEST_MAX_WORKERS = 2;
|
|
83743
|
-
}
|
|
83744
|
-
});
|
|
83745
83333
|
function readChangedGitlinkPaths(repoRoot, fromRef, toRef) {
|
|
83746
83334
|
try {
|
|
83747
|
-
const output = (0,
|
|
83335
|
+
const output = (0, import_node_child_process9.execFileSync)(GIT2, ["diff", "--raw", "--no-abbrev", fromRef, toRef], {
|
|
83748
83336
|
cwd: repoRoot,
|
|
83749
83337
|
encoding: "utf8",
|
|
83750
83338
|
maxBuffer: REFINE_PATCH_EQUIVALENCE_OUTPUT_LIMIT_BYTES
|
|
@@ -83768,7 +83356,7 @@ ${cleanBody}`;
|
|
|
83768
83356
|
}
|
|
83769
83357
|
function readTreeObject(repoRoot, ref, path63) {
|
|
83770
83358
|
try {
|
|
83771
|
-
const output = (0,
|
|
83359
|
+
const output = (0, import_node_child_process9.execFileSync)(GIT2, ["ls-tree", ref, "--", path63], {
|
|
83772
83360
|
cwd: repoRoot,
|
|
83773
83361
|
encoding: "utf8",
|
|
83774
83362
|
maxBuffer: 1024 * 1024
|
|
@@ -83783,7 +83371,7 @@ ${cleanBody}`;
|
|
|
83783
83371
|
for (const ref of refs) {
|
|
83784
83372
|
if (!ref) return false;
|
|
83785
83373
|
try {
|
|
83786
|
-
(0,
|
|
83374
|
+
(0, import_node_child_process9.execFileSync)(GIT2, ["rev-parse", "--verify", "--quiet", `${ref}^{commit}`], { cwd, stdio: "ignore", windowsHide: true });
|
|
83787
83375
|
} catch {
|
|
83788
83376
|
return false;
|
|
83789
83377
|
}
|
|
@@ -83792,13 +83380,13 @@ ${cleanBody}`;
|
|
|
83792
83380
|
}
|
|
83793
83381
|
function probeGitAncestry(cwd, ancestor, descendant) {
|
|
83794
83382
|
try {
|
|
83795
|
-
if (!
|
|
83383
|
+
if (!fs50.existsSync(cwd)) return "undeterminable";
|
|
83796
83384
|
} catch {
|
|
83797
83385
|
return "undeterminable";
|
|
83798
83386
|
}
|
|
83799
83387
|
if (!gitRefsResolvable(cwd, [ancestor, descendant])) return "undeterminable";
|
|
83800
83388
|
try {
|
|
83801
|
-
(0,
|
|
83389
|
+
(0, import_node_child_process9.execFileSync)(GIT2, ["merge-base", "--is-ancestor", ancestor, descendant], { cwd, stdio: "ignore", windowsHide: true });
|
|
83802
83390
|
return true;
|
|
83803
83391
|
} catch (e) {
|
|
83804
83392
|
return e?.status === 1 ? false : "undeterminable";
|
|
@@ -83806,8 +83394,8 @@ ${cleanBody}`;
|
|
|
83806
83394
|
}
|
|
83807
83395
|
function probeSubmoduleGitlinkReachability(input) {
|
|
83808
83396
|
const { path: path63, baseCommit, branchCommit, probeRoot, baseRepoRoot } = input;
|
|
83809
|
-
const submoduleRepo = (0,
|
|
83810
|
-
const baseSubmoduleRepo = (0,
|
|
83397
|
+
const submoduleRepo = (0, import_path16.resolve)(probeRoot, path63);
|
|
83398
|
+
const baseSubmoduleRepo = (0, import_path16.resolve)(baseRepoRoot, path63);
|
|
83811
83399
|
if (baseCommit) ensureSubmoduleCommitLocal(submoduleRepo, baseSubmoduleRepo, baseCommit);
|
|
83812
83400
|
if (branchCommit) ensureSubmoduleCommitLocal(submoduleRepo, baseSubmoduleRepo, branchCommit);
|
|
83813
83401
|
let fastForward;
|
|
@@ -83845,7 +83433,7 @@ ${cleanBody}`;
|
|
|
83845
83433
|
function submoduleCommitPresent(submoduleRepoPath, commit) {
|
|
83846
83434
|
if (!commit) return false;
|
|
83847
83435
|
try {
|
|
83848
|
-
(0,
|
|
83436
|
+
(0, import_node_child_process9.execFileSync)(GIT2, ["cat-file", "-e", `${commit}^{commit}`], { cwd: submoduleRepoPath, stdio: "ignore" });
|
|
83849
83437
|
return true;
|
|
83850
83438
|
} catch {
|
|
83851
83439
|
return false;
|
|
@@ -83855,7 +83443,7 @@ ${cleanBody}`;
|
|
|
83855
83443
|
if (!commit) return false;
|
|
83856
83444
|
const present = () => {
|
|
83857
83445
|
try {
|
|
83858
|
-
(0,
|
|
83446
|
+
(0, import_node_child_process9.execFileSync)(GIT2, ["cat-file", "-e", `${commit}^{commit}`], { cwd: submoduleRepoPath, stdio: "ignore" });
|
|
83859
83447
|
return true;
|
|
83860
83448
|
} catch {
|
|
83861
83449
|
return false;
|
|
@@ -83863,7 +83451,7 @@ ${cleanBody}`;
|
|
|
83863
83451
|
};
|
|
83864
83452
|
if (present()) return true;
|
|
83865
83453
|
try {
|
|
83866
|
-
if (!
|
|
83454
|
+
if (!fs50.existsSync(submoduleRepoPath) || !fs50.existsSync(baseSubmoduleRepoPath)) return false;
|
|
83867
83455
|
} catch {
|
|
83868
83456
|
return false;
|
|
83869
83457
|
}
|
|
@@ -83877,7 +83465,7 @@ ${cleanBody}`;
|
|
|
83877
83465
|
];
|
|
83878
83466
|
for (const args of strategies) {
|
|
83879
83467
|
try {
|
|
83880
|
-
(0,
|
|
83468
|
+
(0, import_node_child_process9.execFileSync)(GIT2, ["-c", "protocol.file.allow=always", ...args], {
|
|
83881
83469
|
cwd: submoduleRepoPath,
|
|
83882
83470
|
stdio: ["ignore", "ignore", "pipe"]
|
|
83883
83471
|
});
|
|
@@ -83907,7 +83495,7 @@ ${cleanBody}`;
|
|
|
83907
83495
|
}
|
|
83908
83496
|
function readChangedPathKinds(repoRoot, fromRef, toRef) {
|
|
83909
83497
|
try {
|
|
83910
|
-
const output = (0,
|
|
83498
|
+
const output = (0, import_node_child_process9.execFileSync)(GIT2, ["diff", "--raw", "--no-abbrev", fromRef, toRef], {
|
|
83911
83499
|
cwd: repoRoot,
|
|
83912
83500
|
encoding: "utf8",
|
|
83913
83501
|
maxBuffer: REFINE_PATCH_EQUIVALENCE_OUTPUT_LIMIT_BYTES
|
|
@@ -83930,25 +83518,25 @@ ${cleanBody}`;
|
|
|
83930
83518
|
return [];
|
|
83931
83519
|
}
|
|
83932
83520
|
}
|
|
83933
|
-
async function verifyRemoteBranchContainsCommit(
|
|
83521
|
+
async function verifyRemoteBranchContainsCommit(runGit4, submodulePath, commit, branch = "main") {
|
|
83934
83522
|
try {
|
|
83935
|
-
await
|
|
83523
|
+
await runGit4(submodulePath, ["-c", "protocol.file.allow=always", "fetch", "origin", `refs/heads/${branch}:refs/remotes/origin/${branch}`]);
|
|
83936
83524
|
} catch (fetchError) {
|
|
83937
83525
|
return { state: "undeterminable", error: fetchError };
|
|
83938
83526
|
}
|
|
83939
83527
|
const remoteRef = `refs/remotes/origin/${branch}`;
|
|
83940
83528
|
try {
|
|
83941
|
-
await
|
|
83529
|
+
await runGit4(submodulePath, ["rev-parse", "--verify", "--quiet", `${remoteRef}^{commit}`]);
|
|
83942
83530
|
} catch (resolveError) {
|
|
83943
83531
|
return { state: "undeterminable", error: resolveError };
|
|
83944
83532
|
}
|
|
83945
83533
|
try {
|
|
83946
|
-
await
|
|
83534
|
+
await runGit4(submodulePath, ["rev-parse", "--verify", "--quiet", `${commit}^{commit}`]);
|
|
83947
83535
|
} catch (missingCandidate) {
|
|
83948
83536
|
return { state: "absent", error: missingCandidate };
|
|
83949
83537
|
}
|
|
83950
83538
|
try {
|
|
83951
|
-
await
|
|
83539
|
+
await runGit4(submodulePath, ["merge-base", "--is-ancestor", commit, remoteRef]);
|
|
83952
83540
|
return { state: "contained" };
|
|
83953
83541
|
} catch (ancestryError) {
|
|
83954
83542
|
return ancestryError?.code === 1 ? { state: "absent", error: ancestryError } : { state: "undeterminable", error: ancestryError };
|
|
@@ -83975,45 +83563,68 @@ ${cleanBody}`;
|
|
|
83975
83563
|
parts.push("Do not merge the root branch until every submodule gitlink commit is reachable from submodule origin/main.");
|
|
83976
83564
|
return parts.join(" ");
|
|
83977
83565
|
}
|
|
83978
|
-
var
|
|
83979
|
-
var
|
|
83980
|
-
var
|
|
83981
|
-
var
|
|
83566
|
+
var fs50;
|
|
83567
|
+
var import_node_child_process9;
|
|
83568
|
+
var import_path16;
|
|
83569
|
+
var GIT2;
|
|
83982
83570
|
var REFINE_PATCH_EQUIVALENCE_OUTPUT_LIMIT_BYTES;
|
|
83983
83571
|
var init_mesh_refine_gitlink_utils = __esm2({
|
|
83984
83572
|
"src/mesh/mesh-refine-gitlink-utils.ts"() {
|
|
83985
83573
|
"use strict";
|
|
83986
|
-
|
|
83987
|
-
|
|
83988
|
-
|
|
83574
|
+
fs50 = __toESM2(require("fs"));
|
|
83575
|
+
import_node_child_process9 = require("child_process");
|
|
83576
|
+
import_path16 = require("path");
|
|
83989
83577
|
init_logger();
|
|
83990
83578
|
init_resolve_executable();
|
|
83991
|
-
|
|
83579
|
+
GIT2 = process.platform === "win32" ? resolveWin32Executable("git") : "git";
|
|
83992
83580
|
REFINE_PATCH_EQUIVALENCE_OUTPUT_LIMIT_BYTES = 4 * 1024 * 1024;
|
|
83993
83581
|
}
|
|
83994
83582
|
});
|
|
83583
|
+
function resolveRefineVitestMaxWorkers(env2 = process.env) {
|
|
83584
|
+
const raw = env2[REFINE_VITEST_MAX_WORKERS_ENV];
|
|
83585
|
+
if (raw === void 0 || raw.trim() === "") return DEFAULT_REFINE_VITEST_MAX_WORKERS;
|
|
83586
|
+
const parsed = Number.parseInt(raw, 10);
|
|
83587
|
+
if (!Number.isFinite(parsed)) return DEFAULT_REFINE_VITEST_MAX_WORKERS;
|
|
83588
|
+
if (parsed === 0) return null;
|
|
83589
|
+
return Math.max(1, parsed);
|
|
83590
|
+
}
|
|
83591
|
+
function refineGateChildEnv(env2 = process.env) {
|
|
83592
|
+
if (env2.VITEST_MAX_WORKERS) return {};
|
|
83593
|
+
const cap = resolveRefineVitestMaxWorkers(env2);
|
|
83594
|
+
if (cap === null) return {};
|
|
83595
|
+
return { VITEST_MAX_WORKERS: String(cap) };
|
|
83596
|
+
}
|
|
83597
|
+
var REFINE_VITEST_MAX_WORKERS_ENV;
|
|
83598
|
+
var DEFAULT_REFINE_VITEST_MAX_WORKERS;
|
|
83599
|
+
var init_mesh_refine_worker_cap = __esm2({
|
|
83600
|
+
"src/mesh/mesh-refine-worker-cap.ts"() {
|
|
83601
|
+
"use strict";
|
|
83602
|
+
REFINE_VITEST_MAX_WORKERS_ENV = "ADHDEV_REFINE_VITEST_MAX_WORKERS";
|
|
83603
|
+
DEFAULT_REFINE_VITEST_MAX_WORKERS = 2;
|
|
83604
|
+
}
|
|
83605
|
+
});
|
|
83995
83606
|
function classifySubmoduleDivergence(submoduleRepoPath, baseCommit, branchCommit) {
|
|
83996
83607
|
if (!baseCommit || !branchCommit) return "undeterminable";
|
|
83997
83608
|
if (baseCommit === branchCommit) return "not_diverged";
|
|
83998
83609
|
try {
|
|
83999
|
-
if (!
|
|
84000
|
-
(0,
|
|
84001
|
-
(0,
|
|
83610
|
+
if (!fs51.existsSync(submoduleRepoPath)) return "undeterminable";
|
|
83611
|
+
(0, import_node_child_process10.execFileSync)(GIT2, ["cat-file", "-e", `${baseCommit}^{commit}`], { cwd: submoduleRepoPath, stdio: "ignore" });
|
|
83612
|
+
(0, import_node_child_process10.execFileSync)(GIT2, ["cat-file", "-e", `${branchCommit}^{commit}`], { cwd: submoduleRepoPath, stdio: "ignore" });
|
|
84002
83613
|
} catch {
|
|
84003
83614
|
return "undeterminable";
|
|
84004
83615
|
}
|
|
84005
83616
|
try {
|
|
84006
|
-
(0,
|
|
83617
|
+
(0, import_node_child_process10.execFileSync)(GIT2, ["merge-base", "--is-ancestor", baseCommit, branchCommit], { cwd: submoduleRepoPath, stdio: "ignore" });
|
|
84007
83618
|
return "not_diverged";
|
|
84008
83619
|
} catch {
|
|
84009
83620
|
}
|
|
84010
83621
|
try {
|
|
84011
|
-
(0,
|
|
83622
|
+
(0, import_node_child_process10.execFileSync)(GIT2, ["merge-base", "--is-ancestor", branchCommit, baseCommit], { cwd: submoduleRepoPath, stdio: "ignore" });
|
|
84012
83623
|
return "not_diverged";
|
|
84013
83624
|
} catch {
|
|
84014
83625
|
}
|
|
84015
83626
|
try {
|
|
84016
|
-
const mb = (0,
|
|
83627
|
+
const mb = (0, import_node_child_process10.execFileSync)(GIT2, ["merge-base", baseCommit, branchCommit], { cwd: submoduleRepoPath, encoding: "utf8" }).trim();
|
|
84017
83628
|
return mb ? "diverged" : "not_diverged";
|
|
84018
83629
|
} catch {
|
|
84019
83630
|
return "not_diverged";
|
|
@@ -84021,13 +83632,13 @@ ${cleanBody}`;
|
|
|
84021
83632
|
}
|
|
84022
83633
|
function resolveSubmoduleRemoteMainRef(submoduleRepoPath) {
|
|
84023
83634
|
try {
|
|
84024
|
-
const sym = (0,
|
|
83635
|
+
const sym = (0, import_node_child_process10.execFileSync)(GIT2, ["symbolic-ref", "-q", "refs/remotes/origin/HEAD"], { cwd: submoduleRepoPath, encoding: "utf8" }).trim();
|
|
84025
83636
|
if (sym) return sym;
|
|
84026
83637
|
} catch {
|
|
84027
83638
|
}
|
|
84028
83639
|
for (const branch of ["main", "master"]) {
|
|
84029
83640
|
try {
|
|
84030
|
-
(0,
|
|
83641
|
+
(0, import_node_child_process10.execFileSync)(GIT2, ["rev-parse", "--verify", "-q", `refs/remotes/origin/${branch}`], { cwd: submoduleRepoPath, stdio: ["ignore", "pipe", "pipe"] });
|
|
84031
83642
|
return `refs/remotes/origin/${branch}`;
|
|
84032
83643
|
} catch {
|
|
84033
83644
|
}
|
|
@@ -84036,24 +83647,24 @@ ${cleanBody}`;
|
|
|
84036
83647
|
}
|
|
84037
83648
|
function findEquivalentPublishedSubmoduleCommit(submoduleRepoPath, baseCommit, branchCommit, remoteRef) {
|
|
84038
83649
|
try {
|
|
84039
|
-
const mergeTreeOut = (0,
|
|
83650
|
+
const mergeTreeOut = (0, import_node_child_process10.execFileSync)(GIT2, ["merge-tree", "--write-tree", baseCommit, branchCommit], {
|
|
84040
83651
|
cwd: submoduleRepoPath,
|
|
84041
83652
|
encoding: "utf8",
|
|
84042
83653
|
stdio: ["ignore", "pipe", "pipe"]
|
|
84043
83654
|
});
|
|
84044
83655
|
const mergedTree = mergeTreeOut.trim().split(/\s+/)[0] || "";
|
|
84045
83656
|
if (!mergedTree) return void 0;
|
|
84046
|
-
const candidates = (0,
|
|
83657
|
+
const candidates = (0, import_node_child_process10.execFileSync)(GIT2, ["rev-list", "--max-count=100", remoteRef, "--not", baseCommit], {
|
|
84047
83658
|
cwd: submoduleRepoPath,
|
|
84048
83659
|
encoding: "utf8"
|
|
84049
83660
|
}).split("\n").map((s2) => s2.trim()).filter(Boolean);
|
|
84050
83661
|
for (const candidate of candidates) {
|
|
84051
83662
|
try {
|
|
84052
|
-
(0,
|
|
83663
|
+
(0, import_node_child_process10.execFileSync)(GIT2, ["merge-base", "--is-ancestor", baseCommit, candidate], { cwd: submoduleRepoPath, stdio: "ignore" });
|
|
84053
83664
|
} catch {
|
|
84054
83665
|
continue;
|
|
84055
83666
|
}
|
|
84056
|
-
const tree = (0,
|
|
83667
|
+
const tree = (0, import_node_child_process10.execFileSync)(GIT2, ["rev-parse", `${candidate}^{tree}`], { cwd: submoduleRepoPath, encoding: "utf8" }).trim();
|
|
84057
83668
|
if (tree === mergedTree) return candidate;
|
|
84058
83669
|
}
|
|
84059
83670
|
} catch {
|
|
@@ -84062,7 +83673,7 @@ ${cleanBody}`;
|
|
|
84062
83673
|
}
|
|
84063
83674
|
function submoduleHasOriginRemote(submoduleRepoPath) {
|
|
84064
83675
|
try {
|
|
84065
|
-
const url2 = (0,
|
|
83676
|
+
const url2 = (0, import_node_child_process10.execFileSync)(GIT2, ["remote", "get-url", "origin"], {
|
|
84066
83677
|
cwd: submoduleRepoPath,
|
|
84067
83678
|
encoding: "utf8",
|
|
84068
83679
|
stdio: ["ignore", "pipe", "ignore"]
|
|
@@ -84088,9 +83699,9 @@ ${cleanBody}`;
|
|
|
84088
83699
|
for (const path63 of changed) {
|
|
84089
83700
|
const baseCommit = readTreeObject(baseRepoRoot, baseHead, path63);
|
|
84090
83701
|
const branchCommit = readTreeObject(worktreeRoot, branchHead, path63);
|
|
84091
|
-
const submoduleRepoPath = (0,
|
|
83702
|
+
const submoduleRepoPath = (0, import_path17.resolve)(worktreeRoot, path63);
|
|
84092
83703
|
if (baseCommit) {
|
|
84093
|
-
ensureSubmoduleCommitLocal(submoduleRepoPath, (0,
|
|
83704
|
+
ensureSubmoduleCommitLocal(submoduleRepoPath, (0, import_path17.resolve)(baseRepoRoot, path63), baseCommit);
|
|
84094
83705
|
}
|
|
84095
83706
|
const markUndeterminable = () => {
|
|
84096
83707
|
const unavailable = [];
|
|
@@ -84116,7 +83727,7 @@ ${cleanBody}`;
|
|
|
84116
83727
|
const originConfigured = submoduleHasOriginRemote(submoduleRepoPath);
|
|
84117
83728
|
let remoteFetched = true;
|
|
84118
83729
|
try {
|
|
84119
|
-
(0,
|
|
83730
|
+
(0, import_node_child_process10.execFileSync)(GIT2, ["-c", "protocol.file.allow=always", "fetch", "-q", "origin"], { cwd: submoduleRepoPath, stdio: ["ignore", "ignore", "pipe"] });
|
|
84120
83731
|
} catch {
|
|
84121
83732
|
remoteFetched = false;
|
|
84122
83733
|
}
|
|
@@ -84124,7 +83735,7 @@ ${cleanBody}`;
|
|
|
84124
83735
|
const publishedEquivalent = remoteMainRef ? findEquivalentPublishedSubmoduleCommit(submoduleRepoPath, baseCommit, branchCommit, remoteMainRef) : void 0;
|
|
84125
83736
|
if (publishedEquivalent) {
|
|
84126
83737
|
try {
|
|
84127
|
-
(0,
|
|
83738
|
+
(0, import_node_child_process10.execFileSync)(GIT2, ["checkout", "-q", "--detach", publishedEquivalent], { cwd: submoduleRepoPath, stdio: ["ignore", "ignore", "pipe"] });
|
|
84128
83739
|
} catch {
|
|
84129
83740
|
}
|
|
84130
83741
|
gitlinks.push({ path: path63, baseCommit, branchCommit, rebasedCommit: publishedEquivalent, action: "converged_to_published" });
|
|
@@ -84136,7 +83747,7 @@ ${cleanBody}`;
|
|
|
84136
83747
|
const willMintUnpublishedCommit = branchPublished !== true;
|
|
84137
83748
|
const wouldConflict = (() => {
|
|
84138
83749
|
try {
|
|
84139
|
-
(0,
|
|
83750
|
+
(0, import_node_child_process10.execFileSync)(GIT2, ["merge-tree", "--write-tree", baseCommit, branchCommit], {
|
|
84140
83751
|
cwd: submoduleRepoPath,
|
|
84141
83752
|
encoding: "utf8",
|
|
84142
83753
|
stdio: ["ignore", "pipe", "pipe"]
|
|
@@ -84169,16 +83780,16 @@ ${cleanBody}`;
|
|
|
84169
83780
|
}
|
|
84170
83781
|
let rebasedCommit;
|
|
84171
83782
|
try {
|
|
84172
|
-
(0,
|
|
84173
|
-
(0,
|
|
84174
|
-
rebasedCommit = (0,
|
|
83783
|
+
(0, import_node_child_process10.execFileSync)(GIT2, ["checkout", "-q", "--detach", branchCommit], { cwd: submoduleRepoPath, stdio: ["ignore", "ignore", "pipe"] });
|
|
83784
|
+
(0, import_node_child_process10.execFileSync)(GIT2, ["rebase", baseCommit], { cwd: submoduleRepoPath, stdio: ["ignore", "pipe", "pipe"] });
|
|
83785
|
+
rebasedCommit = (0, import_node_child_process10.execFileSync)(GIT2, ["rev-parse", "HEAD"], { cwd: submoduleRepoPath, encoding: "utf8" }).trim();
|
|
84175
83786
|
} catch {
|
|
84176
83787
|
try {
|
|
84177
|
-
(0,
|
|
83788
|
+
(0, import_node_child_process10.execFileSync)(GIT2, ["rebase", "--abort"], { cwd: submoduleRepoPath, stdio: "ignore" });
|
|
84178
83789
|
} catch {
|
|
84179
83790
|
}
|
|
84180
83791
|
try {
|
|
84181
|
-
(0,
|
|
83792
|
+
(0, import_node_child_process10.execFileSync)(GIT2, ["checkout", "-q", "--detach", branchCommit], { cwd: submoduleRepoPath, stdio: "ignore" });
|
|
84182
83793
|
} catch {
|
|
84183
83794
|
}
|
|
84184
83795
|
gitlinks.push({ path: path63, baseCommit, branchCommit, action: "rebase_conflict" });
|
|
@@ -84189,7 +83800,7 @@ ${cleanBody}`;
|
|
|
84189
83800
|
if (rebasedCommit === branchCommit) return true;
|
|
84190
83801
|
if (rebasedCommit === baseCommit) return false;
|
|
84191
83802
|
try {
|
|
84192
|
-
const replayed = (0,
|
|
83803
|
+
const replayed = (0, import_node_child_process10.execFileSync)(GIT2, ["rev-list", "--count", `${baseCommit}..${rebasedCommit}`], {
|
|
84193
83804
|
cwd: submoduleRepoPath,
|
|
84194
83805
|
encoding: "utf8"
|
|
84195
83806
|
}).trim();
|
|
@@ -84200,7 +83811,7 @@ ${cleanBody}`;
|
|
|
84200
83811
|
})();
|
|
84201
83812
|
if (!branchWorkSurvived) {
|
|
84202
83813
|
try {
|
|
84203
|
-
(0,
|
|
83814
|
+
(0, import_node_child_process10.execFileSync)(GIT2, ["checkout", "-q", "--detach", branchCommit], { cwd: submoduleRepoPath, stdio: "ignore" });
|
|
84204
83815
|
} catch {
|
|
84205
83816
|
}
|
|
84206
83817
|
gitlinks.push({ path: path63, baseCommit, branchCommit, rebasedCommit, action: "rebase_dropped_branch_commits" });
|
|
@@ -84257,7 +83868,7 @@ ${cleanBody}`;
|
|
|
84257
83868
|
const resolveByPath = new Map(resolutions.map((r) => [r.path, r.rebasedCommit]));
|
|
84258
83869
|
const runRebase = (args) => {
|
|
84259
83870
|
try {
|
|
84260
|
-
(0,
|
|
83871
|
+
(0, import_node_child_process10.execFileSync)(GIT2, args, {
|
|
84261
83872
|
cwd: worktreeRoot,
|
|
84262
83873
|
stdio: ["ignore", "pipe", "pipe"],
|
|
84263
83874
|
// A rebase editor prompt would hang; keep it non-interactive.
|
|
@@ -84270,14 +83881,14 @@ ${cleanBody}`;
|
|
|
84270
83881
|
};
|
|
84271
83882
|
const unmergedPaths = () => {
|
|
84272
83883
|
try {
|
|
84273
|
-
return (0,
|
|
83884
|
+
return (0, import_node_child_process10.execFileSync)(GIT2, ["diff", "--name-only", "--diff-filter=U"], { cwd: worktreeRoot, encoding: "utf8" }).split("\n").map((s2) => s2.trim()).filter(Boolean);
|
|
84274
83885
|
} catch {
|
|
84275
83886
|
return [];
|
|
84276
83887
|
}
|
|
84277
83888
|
};
|
|
84278
83889
|
const abort = (reason, conflictPaths) => {
|
|
84279
83890
|
try {
|
|
84280
|
-
(0,
|
|
83891
|
+
(0, import_node_child_process10.execFileSync)(GIT2, ["rebase", "--abort"], { cwd: worktreeRoot, stdio: "ignore" });
|
|
84281
83892
|
} catch {
|
|
84282
83893
|
}
|
|
84283
83894
|
return { ok: false, reason, conflictPaths };
|
|
@@ -84294,7 +83905,7 @@ ${cleanBody}`;
|
|
|
84294
83905
|
if (unresolvable.length > 0) {
|
|
84295
83906
|
const unresolvableGitlink = unresolvable.some((p) => {
|
|
84296
83907
|
try {
|
|
84297
|
-
const staged = (0,
|
|
83908
|
+
const staged = (0, import_node_child_process10.execFileSync)(GIT2, ["ls-files", "--stage", "--", p], { cwd: worktreeRoot, encoding: "utf8" });
|
|
84298
83909
|
return /^160000\s/m.test(staged);
|
|
84299
83910
|
} catch {
|
|
84300
83911
|
return false;
|
|
@@ -84302,7 +83913,7 @@ ${cleanBody}`;
|
|
|
84302
83913
|
});
|
|
84303
83914
|
const allGitlink = unresolvable.every((p) => {
|
|
84304
83915
|
try {
|
|
84305
|
-
const staged = (0,
|
|
83916
|
+
const staged = (0, import_node_child_process10.execFileSync)(GIT2, ["ls-files", "--stage", "--", p], { cwd: worktreeRoot, encoding: "utf8" });
|
|
84306
83917
|
return /^160000\s/m.test(staged);
|
|
84307
83918
|
} catch {
|
|
84308
83919
|
return false;
|
|
@@ -84313,11 +83924,11 @@ ${cleanBody}`;
|
|
|
84313
83924
|
for (const p of conflicts) {
|
|
84314
83925
|
const commit = resolveByPath.get(p);
|
|
84315
83926
|
try {
|
|
84316
|
-
(0,
|
|
83927
|
+
(0, import_node_child_process10.execFileSync)(GIT2, ["checkout", "-q", "--detach", commit], { cwd: (0, import_path17.resolve)(worktreeRoot, p), stdio: "ignore" });
|
|
84317
83928
|
} catch {
|
|
84318
83929
|
}
|
|
84319
83930
|
try {
|
|
84320
|
-
(0,
|
|
83931
|
+
(0, import_node_child_process10.execFileSync)(GIT2, ["add", p], { cwd: worktreeRoot, stdio: "ignore" });
|
|
84321
83932
|
} catch {
|
|
84322
83933
|
return abort("rebase_error", conflicts);
|
|
84323
83934
|
}
|
|
@@ -84326,22 +83937,22 @@ ${cleanBody}`;
|
|
|
84326
83937
|
}
|
|
84327
83938
|
let branchHead;
|
|
84328
83939
|
try {
|
|
84329
|
-
branchHead = (0,
|
|
83940
|
+
branchHead = (0, import_node_child_process10.execFileSync)(GIT2, ["rev-parse", "HEAD"], { cwd: worktreeRoot, encoding: "utf8" }).trim();
|
|
84330
83941
|
} catch {
|
|
84331
83942
|
}
|
|
84332
83943
|
return { ok: true, branchHead };
|
|
84333
83944
|
}
|
|
84334
|
-
var
|
|
84335
|
-
var
|
|
84336
|
-
var
|
|
83945
|
+
var fs51;
|
|
83946
|
+
var import_path17;
|
|
83947
|
+
var import_node_child_process10;
|
|
84337
83948
|
var SUBMODULE_PUBLISH_REQUIRED_RECOMMENDED_ACTION;
|
|
84338
83949
|
var SUBMODULE_PUBLICATION_UNDETERMINABLE_RECOMMENDED_ACTION;
|
|
84339
83950
|
var init_mesh_refine_submodule_converge = __esm2({
|
|
84340
83951
|
"src/mesh/mesh-refine-submodule-converge.ts"() {
|
|
84341
83952
|
"use strict";
|
|
84342
|
-
|
|
84343
|
-
|
|
84344
|
-
|
|
83953
|
+
fs51 = __toESM2(require("fs"));
|
|
83954
|
+
import_path17 = require("path");
|
|
83955
|
+
import_node_child_process10 = require("child_process");
|
|
84345
83956
|
init_mesh_refine_gitlink_utils();
|
|
84346
83957
|
SUBMODULE_PUBLISH_REQUIRED_RECOMMENDED_ACTION = "Publish the branch-side submodule commit(s) to submodule origin main, then rerun mesh_refine_node. Do NOT retry the rebase: the branch was intentionally left unrewritten because a rebase here would mint a submodule commit the reachability gate must reject.";
|
|
84347
83958
|
SUBMODULE_PUBLICATION_UNDETERMINABLE_RECOMMENDED_ACTION = "Restore access to the submodule remote (the publication check could not be run), then rerun mesh_refine_node. Do NOT publish and do NOT retry the rebase on this evidence: it is unknown whether the branch-side commit is already on origin, so minting or pushing here can synthesize a redundant twin of a published commit.";
|
|
@@ -84364,13 +83975,13 @@ ${tail}`;
|
|
|
84364
83975
|
}
|
|
84365
83976
|
function writeValidationFailureLog(workspace, index, candidate, streams, now = () => /* @__PURE__ */ new Date()) {
|
|
84366
83977
|
try {
|
|
84367
|
-
const dir = (0,
|
|
84368
|
-
|
|
83978
|
+
const dir = (0, import_path18.join)(workspace, REFINE_VALIDATION_LOG_DIR);
|
|
83979
|
+
fs52.mkdirSync(dir, { recursive: true });
|
|
84369
83980
|
const stamp = now().toISOString().replace(/[:.]/g, "-");
|
|
84370
|
-
const file2 = (0,
|
|
83981
|
+
const file2 = (0, import_path18.join)(dir, `refine-${stamp}-${index}.log`);
|
|
84371
83982
|
const asText = (v) => typeof v === "string" ? v : v == null ? "" : String(v);
|
|
84372
83983
|
const shown = candidate.displayCommand || [candidate.command, ...candidate.args || []].join(" ");
|
|
84373
|
-
|
|
83984
|
+
fs52.writeFileSync(
|
|
84374
83985
|
file2,
|
|
84375
83986
|
`# refine validation failure
|
|
84376
83987
|
# command: ${shown}
|
|
@@ -84434,13 +84045,13 @@ ${asText(streams.stderr)}
|
|
|
84434
84045
|
if (excludePaths.length > 0) {
|
|
84435
84046
|
diffArgs.push("--", ".", ...excludePaths.map((path63) => `:(exclude)${path63}`));
|
|
84436
84047
|
}
|
|
84437
|
-
const diff = execFileSync16(
|
|
84048
|
+
const diff = execFileSync16(GIT2, diffArgs, {
|
|
84438
84049
|
cwd,
|
|
84439
84050
|
encoding: "utf8",
|
|
84440
84051
|
maxBuffer: REFINE_PATCH_EQUIVALENCE_OUTPUT_LIMIT_BYTES
|
|
84441
84052
|
});
|
|
84442
84053
|
if (!diff.trim()) return "";
|
|
84443
|
-
const patchId = execFileSync16(
|
|
84054
|
+
const patchId = execFileSync16(GIT2, ["patch-id", "--stable"], {
|
|
84444
84055
|
cwd,
|
|
84445
84056
|
input: diff,
|
|
84446
84057
|
encoding: "utf8",
|
|
@@ -84452,7 +84063,7 @@ ${asText(streams.stderr)}
|
|
|
84452
84063
|
const startedAt = Date.now();
|
|
84453
84064
|
try {
|
|
84454
84065
|
const { execFileSync: execFileSync16 } = await import("child_process");
|
|
84455
|
-
const git3 = (args) => execFileSync16(
|
|
84066
|
+
const git3 = (args) => execFileSync16(GIT2, args, {
|
|
84456
84067
|
cwd: repoRoot,
|
|
84457
84068
|
encoding: "utf8",
|
|
84458
84069
|
maxBuffer: REFINE_PATCH_EQUIVALENCE_OUTPUT_LIMIT_BYTES
|
|
@@ -84560,7 +84171,7 @@ ${e?.stderr || ""}`
|
|
|
84560
84171
|
...autoPublish !== void 0 ? { autoPublishSubmoduleMainCommits: autoPublish } : {}
|
|
84561
84172
|
};
|
|
84562
84173
|
try {
|
|
84563
|
-
const git3 = (args) => (0,
|
|
84174
|
+
const git3 = (args) => (0, import_node_child_process11.execFileSync)(GIT2, args, {
|
|
84564
84175
|
cwd: repoRoot,
|
|
84565
84176
|
encoding: "utf8",
|
|
84566
84177
|
maxBuffer: REFINE_PATCH_EQUIVALENCE_OUTPUT_LIMIT_BYTES,
|
|
@@ -84700,7 +84311,7 @@ ${e?.stderr || ""}`
|
|
|
84700
84311
|
const startedAt = Date.now();
|
|
84701
84312
|
try {
|
|
84702
84313
|
const { execFileSync: execFileSync16 } = await import("child_process");
|
|
84703
|
-
const git3 = (gitArgs) => execFileSync16(
|
|
84314
|
+
const git3 = (gitArgs) => execFileSync16(GIT2, gitArgs, {
|
|
84704
84315
|
cwd: repoRoot,
|
|
84705
84316
|
encoding: "utf8",
|
|
84706
84317
|
maxBuffer: REFINE_PATCH_EQUIVALENCE_OUTPUT_LIMIT_BYTES
|
|
@@ -84765,7 +84376,7 @@ ${mergeTreeErr?.stderr || ""}`;
|
|
|
84765
84376
|
const startedAt = Date.now();
|
|
84766
84377
|
try {
|
|
84767
84378
|
const { execFileSync: execFileSync16 } = await import("child_process");
|
|
84768
|
-
const git3 = (args, opts) => execFileSync16(
|
|
84379
|
+
const git3 = (args, opts) => execFileSync16(GIT2, args, {
|
|
84769
84380
|
cwd: opts?.cwd || repoRoot,
|
|
84770
84381
|
encoding: "utf8",
|
|
84771
84382
|
maxBuffer: REFINE_PATCH_EQUIVALENCE_OUTPUT_LIMIT_BYTES
|
|
@@ -84840,7 +84451,7 @@ ${mergeTreeErr?.stderr || ""}`;
|
|
|
84840
84451
|
};
|
|
84841
84452
|
}
|
|
84842
84453
|
function resolveGitDir(repoRoot) {
|
|
84843
|
-
const out = (0,
|
|
84454
|
+
const out = (0, import_node_child_process11.execFileSync)(GIT2, ["rev-parse", "--absolute-git-dir"], {
|
|
84844
84455
|
cwd: repoRoot,
|
|
84845
84456
|
encoding: "utf8",
|
|
84846
84457
|
maxBuffer: 1024 * 1024
|
|
@@ -84852,7 +84463,7 @@ ${mergeTreeErr?.stderr || ""}`;
|
|
|
84852
84463
|
const baseCommit = readTreeObject(repoRoot, baseHead, path63);
|
|
84853
84464
|
const branchCommit = readTreeObject(repoRoot, branchHead, path63);
|
|
84854
84465
|
if (!baseCommit || !branchCommit) return false;
|
|
84855
|
-
return isSubmoduleFastForward((0,
|
|
84466
|
+
return isSubmoduleFastForward((0, import_path18.resolve)(repoRoot, path63), baseCommit, branchCommit);
|
|
84856
84467
|
});
|
|
84857
84468
|
}
|
|
84858
84469
|
function collectTrivialFastForwardGitlinkResolutions(worktreeRoot, baseRepoRoot, baseHead, branchHead) {
|
|
@@ -84861,8 +84472,8 @@ ${mergeTreeErr?.stderr || ""}`;
|
|
|
84861
84472
|
const baseCommit = readTreeObject(baseRepoRoot, baseHead, path63);
|
|
84862
84473
|
const branchCommit = readTreeObject(worktreeRoot, branchHead, path63);
|
|
84863
84474
|
if (!baseCommit || !branchCommit) continue;
|
|
84864
|
-
const submoduleRepoPath = (0,
|
|
84865
|
-
ensureSubmoduleCommitLocal(submoduleRepoPath, (0,
|
|
84475
|
+
const submoduleRepoPath = (0, import_path18.resolve)(worktreeRoot, path63);
|
|
84476
|
+
ensureSubmoduleCommitLocal(submoduleRepoPath, (0, import_path18.resolve)(baseRepoRoot, path63), baseCommit);
|
|
84866
84477
|
if (baseCommit === branchCommit) {
|
|
84867
84478
|
continue;
|
|
84868
84479
|
}
|
|
@@ -84878,7 +84489,7 @@ ${mergeTreeErr?.stderr || ""}`;
|
|
|
84878
84489
|
const changedGitlinks = readChangedGitlinkPaths(repoRoot, baseHead, branchHead).map((path63) => {
|
|
84879
84490
|
const baseCommit = readTreeObject(repoRoot, baseHead, path63);
|
|
84880
84491
|
const branchCommit = readTreeObject(repoRoot, branchHead, path63);
|
|
84881
|
-
const submoduleRepoPath = (0,
|
|
84492
|
+
const submoduleRepoPath = (0, import_path18.resolve)(repoRoot, path63);
|
|
84882
84493
|
const probe = !!baseCommit && !!branchCommit ? probeSubmoduleFastForward(submoduleRepoPath, baseCommit, branchCommit) : "undeterminable";
|
|
84883
84494
|
return {
|
|
84884
84495
|
path: path63,
|
|
@@ -84903,7 +84514,7 @@ ${mergeTreeErr?.stderr || ""}`;
|
|
|
84903
84514
|
}
|
|
84904
84515
|
let mergeBase = "";
|
|
84905
84516
|
try {
|
|
84906
|
-
mergeBase = (0,
|
|
84517
|
+
mergeBase = (0, import_node_child_process11.execFileSync)(GIT2, ["merge-base", baseHead, branchHead], {
|
|
84907
84518
|
cwd: repoRoot,
|
|
84908
84519
|
encoding: "utf8",
|
|
84909
84520
|
maxBuffer: 1024 * 1024
|
|
@@ -84933,7 +84544,7 @@ ${mergeTreeErr?.stderr || ""}`;
|
|
|
84933
84544
|
}
|
|
84934
84545
|
function buildTreeWithGitlinksEqualized(repoRoot, commitish, paths, placeholderCommit) {
|
|
84935
84546
|
try {
|
|
84936
|
-
const tree = (0,
|
|
84547
|
+
const tree = (0, import_node_child_process11.execFileSync)(GIT2, ["rev-parse", `${commitish}^{tree}`], {
|
|
84937
84548
|
cwd: repoRoot,
|
|
84938
84549
|
encoding: "utf8",
|
|
84939
84550
|
maxBuffer: 1024 * 1024
|
|
@@ -84941,11 +84552,11 @@ ${mergeTreeErr?.stderr || ""}`;
|
|
|
84941
84552
|
if (!tree) return void 0;
|
|
84942
84553
|
const updates = paths.map((path63) => `160000 commit ${placeholderCommit} ${path63}`).join("\n");
|
|
84943
84554
|
if (!updates) return tree;
|
|
84944
|
-
const tmpIndex = (0,
|
|
84555
|
+
const tmpIndex = (0, import_path18.join)(resolveGitDir(repoRoot), `adhdev-refine-eq-${commitish.slice(0, 12)}.index`);
|
|
84945
84556
|
const env2 = { ...process.env, GIT_INDEX_FILE: tmpIndex };
|
|
84946
84557
|
try {
|
|
84947
|
-
(0,
|
|
84948
|
-
(0,
|
|
84558
|
+
(0, import_node_child_process11.execFileSync)(GIT2, ["read-tree", tree], { cwd: repoRoot, env: env2, stdio: "ignore" });
|
|
84559
|
+
(0, import_node_child_process11.execFileSync)(GIT2, ["update-index", "--index-info"], {
|
|
84949
84560
|
cwd: repoRoot,
|
|
84950
84561
|
env: env2,
|
|
84951
84562
|
input: `${updates}
|
|
@@ -84953,11 +84564,11 @@ ${mergeTreeErr?.stderr || ""}`;
|
|
|
84953
84564
|
encoding: "utf8",
|
|
84954
84565
|
stdio: ["pipe", "ignore", "ignore"]
|
|
84955
84566
|
});
|
|
84956
|
-
const newTree = (0,
|
|
84567
|
+
const newTree = (0, import_node_child_process11.execFileSync)(GIT2, ["write-tree"], { cwd: repoRoot, env: env2, encoding: "utf8" }).trim();
|
|
84957
84568
|
return newTree || void 0;
|
|
84958
84569
|
} finally {
|
|
84959
84570
|
try {
|
|
84960
|
-
|
|
84571
|
+
fs52.rmSync(tmpIndex, { force: true });
|
|
84961
84572
|
} catch {
|
|
84962
84573
|
}
|
|
84963
84574
|
}
|
|
@@ -84969,7 +84580,7 @@ ${mergeTreeErr?.stderr || ""}`;
|
|
|
84969
84580
|
try {
|
|
84970
84581
|
const branchGitlinks = gitlinks.filter((entry) => entry.branchCommit);
|
|
84971
84582
|
const gitlinkPaths = branchGitlinks.map((entry) => entry.path);
|
|
84972
|
-
const mergeBase = (0,
|
|
84583
|
+
const mergeBase = (0, import_node_child_process11.execFileSync)(GIT2, ["merge-base", baseHead, branchHead], {
|
|
84973
84584
|
cwd: repoRoot,
|
|
84974
84585
|
encoding: "utf8",
|
|
84975
84586
|
maxBuffer: 1024 * 1024
|
|
@@ -84982,22 +84593,22 @@ ${mergeTreeErr?.stderr || ""}`;
|
|
|
84982
84593
|
const theirsEqTree = buildTreeWithGitlinksEqualized(repoRoot, branchHead, gitlinkPaths, placeholder);
|
|
84983
84594
|
if (baseEqTree && oursEqTree && theirsEqTree) {
|
|
84984
84595
|
try {
|
|
84985
|
-
const baseEqCommit = (0,
|
|
84596
|
+
const baseEqCommit = (0, import_node_child_process11.execFileSync)(GIT2, ["commit-tree", baseEqTree, "-m", "refine-ff-base"], {
|
|
84986
84597
|
cwd: repoRoot,
|
|
84987
84598
|
encoding: "utf8",
|
|
84988
84599
|
maxBuffer: 1024 * 1024
|
|
84989
84600
|
}).trim();
|
|
84990
|
-
const oursEqCommit = (0,
|
|
84601
|
+
const oursEqCommit = (0, import_node_child_process11.execFileSync)(GIT2, ["commit-tree", oursEqTree, "-p", baseEqCommit, "-m", "refine-ff-ours"], {
|
|
84991
84602
|
cwd: repoRoot,
|
|
84992
84603
|
encoding: "utf8",
|
|
84993
84604
|
maxBuffer: 1024 * 1024
|
|
84994
84605
|
}).trim();
|
|
84995
|
-
const theirsEqCommit = (0,
|
|
84606
|
+
const theirsEqCommit = (0, import_node_child_process11.execFileSync)(GIT2, ["commit-tree", theirsEqTree, "-p", baseEqCommit, "-m", "refine-ff-theirs"], {
|
|
84996
84607
|
cwd: repoRoot,
|
|
84997
84608
|
encoding: "utf8",
|
|
84998
84609
|
maxBuffer: 1024 * 1024
|
|
84999
84610
|
}).trim();
|
|
85000
|
-
const mergeOut = (0,
|
|
84611
|
+
const mergeOut = (0, import_node_child_process11.execFileSync)(GIT2, ["merge-tree", "--write-tree", oursEqCommit, theirsEqCommit], {
|
|
85001
84612
|
cwd: repoRoot,
|
|
85002
84613
|
encoding: "utf8",
|
|
85003
84614
|
maxBuffer: REFINE_PATCH_EQUIVALENCE_OUTPUT_LIMIT_BYTES
|
|
@@ -85008,7 +84619,7 @@ ${mergeTreeErr?.stderr || ""}`;
|
|
|
85008
84619
|
}
|
|
85009
84620
|
}
|
|
85010
84621
|
}
|
|
85011
|
-
const contentTree = mergedContentTree || (0,
|
|
84622
|
+
const contentTree = mergedContentTree || (0, import_node_child_process11.execFileSync)(GIT2, ["rev-parse", `${baseHead}^{tree}`], {
|
|
85012
84623
|
cwd: repoRoot,
|
|
85013
84624
|
encoding: "utf8",
|
|
85014
84625
|
maxBuffer: 1024 * 1024
|
|
@@ -85016,11 +84627,11 @@ ${mergeTreeErr?.stderr || ""}`;
|
|
|
85016
84627
|
if (!contentTree) return void 0;
|
|
85017
84628
|
const updates = branchGitlinks.map((entry) => `160000 commit ${entry.branchCommit} ${entry.path}`).join("\n");
|
|
85018
84629
|
if (!updates) return contentTree;
|
|
85019
|
-
const tmpIndex = (0,
|
|
84630
|
+
const tmpIndex = (0, import_path18.join)(resolveGitDir(repoRoot), `adhdev-refine-ff-${baseHead.slice(0, 12)}-${branchHead.slice(0, 12)}.index`);
|
|
85020
84631
|
const env2 = { ...process.env, GIT_INDEX_FILE: tmpIndex };
|
|
85021
84632
|
try {
|
|
85022
|
-
(0,
|
|
85023
|
-
(0,
|
|
84633
|
+
(0, import_node_child_process11.execFileSync)(GIT2, ["read-tree", contentTree], { cwd: repoRoot, env: env2, stdio: "ignore" });
|
|
84634
|
+
(0, import_node_child_process11.execFileSync)(GIT2, ["update-index", "--index-info"], {
|
|
85024
84635
|
cwd: repoRoot,
|
|
85025
84636
|
env: env2,
|
|
85026
84637
|
input: `${updates}
|
|
@@ -85028,11 +84639,11 @@ ${mergeTreeErr?.stderr || ""}`;
|
|
|
85028
84639
|
encoding: "utf8",
|
|
85029
84640
|
stdio: ["pipe", "ignore", "ignore"]
|
|
85030
84641
|
});
|
|
85031
|
-
const newTree = (0,
|
|
84642
|
+
const newTree = (0, import_node_child_process11.execFileSync)(GIT2, ["write-tree"], { cwd: repoRoot, env: env2, encoding: "utf8" }).trim();
|
|
85032
84643
|
return newTree || void 0;
|
|
85033
84644
|
} finally {
|
|
85034
84645
|
try {
|
|
85035
|
-
|
|
84646
|
+
fs52.rmSync(tmpIndex, { force: true });
|
|
85036
84647
|
} catch {
|
|
85037
84648
|
}
|
|
85038
84649
|
}
|
|
@@ -85066,10 +84677,10 @@ ${mergeTreeErr?.stderr || ""}`;
|
|
|
85066
84677
|
}
|
|
85067
84678
|
const commandArgs = ["submodule", "update", "--init", "--recursive", "--", ...updatePaths];
|
|
85068
84679
|
try {
|
|
85069
|
-
const { execFile:
|
|
85070
|
-
const { promisify:
|
|
85071
|
-
const
|
|
85072
|
-
const result = await
|
|
84680
|
+
const { execFile: execFile9 } = await import("child_process");
|
|
84681
|
+
const { promisify: promisify12 } = await import("util");
|
|
84682
|
+
const execFileAsync8 = promisify12(execFile9);
|
|
84683
|
+
const result = await execFileAsync8(GIT2, commandArgs, {
|
|
85073
84684
|
cwd: repoRoot,
|
|
85074
84685
|
encoding: "utf8",
|
|
85075
84686
|
maxBuffer: REFINE_PATCH_EQUIVALENCE_OUTPUT_LIMIT_BYTES,
|
|
@@ -85115,11 +84726,11 @@ ${mergeTreeErr?.stderr || ""}`;
|
|
|
85115
84726
|
const startedAt = Date.now();
|
|
85116
84727
|
const entries = [];
|
|
85117
84728
|
try {
|
|
85118
|
-
const { execFile:
|
|
85119
|
-
const { promisify:
|
|
85120
|
-
const
|
|
85121
|
-
const
|
|
85122
|
-
const { stdout } = await
|
|
84729
|
+
const { execFile: execFile9 } = await import("child_process");
|
|
84730
|
+
const { promisify: promisify12 } = await import("util");
|
|
84731
|
+
const execFileAsync8 = promisify12(execFile9);
|
|
84732
|
+
const runGit4 = async (cwd, args) => {
|
|
84733
|
+
const { stdout } = await execFileAsync8(GIT2, args, {
|
|
85123
84734
|
cwd,
|
|
85124
84735
|
encoding: "utf8",
|
|
85125
84736
|
timeout: 3e4,
|
|
@@ -85128,10 +84739,10 @@ ${mergeTreeErr?.stderr || ""}`;
|
|
|
85128
84739
|
});
|
|
85129
84740
|
return String(stdout || "");
|
|
85130
84741
|
};
|
|
85131
|
-
const verifyRemoteMainContainsCommit = (submodulePath, commit, branch = "main") => verifyRemoteBranchContainsCommit(
|
|
84742
|
+
const verifyRemoteMainContainsCommit = (submodulePath, commit, branch = "main") => verifyRemoteBranchContainsCommit(runGit4, submodulePath, commit, branch);
|
|
85132
84743
|
const publishCommitToRemoteMain = async (submodulePath, commit, branch = "main") => {
|
|
85133
84744
|
const refspec = `${commit}:refs/heads/${branch}`;
|
|
85134
|
-
const { stdout, stderr } = await
|
|
84745
|
+
const { stdout, stderr } = await execFileAsync8(GIT2, ["push", "origin", refspec], {
|
|
85135
84746
|
cwd: submodulePath,
|
|
85136
84747
|
encoding: "utf8",
|
|
85137
84748
|
timeout: 3e4,
|
|
@@ -85141,25 +84752,25 @@ ${mergeTreeErr?.stderr || ""}`;
|
|
|
85141
84752
|
return { stdout: String(stdout || ""), stderr: String(stderr || ""), refspec };
|
|
85142
84753
|
};
|
|
85143
84754
|
const importCommitFromWorktreeSubmodule = async (submodulePath, worktreeSubmodulePath, commit) => {
|
|
85144
|
-
if (!
|
|
84755
|
+
if (!fs52.existsSync(worktreeSubmodulePath)) return false;
|
|
85145
84756
|
try {
|
|
85146
|
-
await
|
|
84757
|
+
await runGit4(worktreeSubmodulePath, ["cat-file", "-e", `${commit}^{commit}`]);
|
|
85147
84758
|
} catch {
|
|
85148
84759
|
return false;
|
|
85149
84760
|
}
|
|
85150
|
-
await
|
|
85151
|
-
await
|
|
84761
|
+
await runGit4(submodulePath, ["-c", "protocol.file.allow=always", "fetch", worktreeSubmodulePath, commit]);
|
|
84762
|
+
await runGit4(submodulePath, ["cat-file", "-e", `${commit}^{commit}`]);
|
|
85152
84763
|
return true;
|
|
85153
84764
|
};
|
|
85154
84765
|
const findEquivalentPublishedCommit = async (submodulePath, commit, remoteRef) => {
|
|
85155
84766
|
try {
|
|
85156
|
-
const targetTree = (await
|
|
84767
|
+
const targetTree = (await runGit4(submodulePath, ["rev-parse", `${commit}^{tree}`])).trim();
|
|
85157
84768
|
if (!targetTree) return void 0;
|
|
85158
|
-
const candidates = (await
|
|
84769
|
+
const candidates = (await runGit4(submodulePath, ["rev-list", "--max-count=100", remoteRef])).split("\n").map((s2) => s2.trim()).filter(Boolean);
|
|
85159
84770
|
for (const candidate of candidates) {
|
|
85160
84771
|
let tree = "";
|
|
85161
84772
|
try {
|
|
85162
|
-
tree = (await
|
|
84773
|
+
tree = (await runGit4(submodulePath, ["rev-parse", `${candidate}^{tree}`])).trim();
|
|
85163
84774
|
} catch {
|
|
85164
84775
|
continue;
|
|
85165
84776
|
}
|
|
@@ -85169,13 +84780,13 @@ ${mergeTreeErr?.stderr || ""}`;
|
|
|
85169
84780
|
}
|
|
85170
84781
|
return void 0;
|
|
85171
84782
|
};
|
|
85172
|
-
const treeOutput = await
|
|
84783
|
+
const treeOutput = await runGit4(repoRoot, ["ls-tree", "-r", "-z", mergedTree]);
|
|
85173
84784
|
const gitlinks = treeOutput.split("\0").filter(Boolean).map((record2) => {
|
|
85174
84785
|
const match = /^160000\s+commit\s+([0-9a-f]{40})\t(.+)$/.exec(record2);
|
|
85175
84786
|
return match ? { commit: match[1], path: match[2] } : null;
|
|
85176
84787
|
}).filter((entry) => !!entry);
|
|
85177
84788
|
for (const gitlink of gitlinks) {
|
|
85178
|
-
const submodulePath = (0,
|
|
84789
|
+
const submodulePath = (0, import_path18.resolve)(repoRoot, gitlink.path);
|
|
85179
84790
|
const entry = {
|
|
85180
84791
|
path: gitlink.path,
|
|
85181
84792
|
commit: gitlink.commit,
|
|
@@ -85183,7 +84794,7 @@ ${mergeTreeErr?.stderr || ""}`;
|
|
|
85183
84794
|
};
|
|
85184
84795
|
let submoduleDefaultBranch = "main";
|
|
85185
84796
|
try {
|
|
85186
|
-
if (!
|
|
84797
|
+
if (!fs52.existsSync(submodulePath)) {
|
|
85187
84798
|
entry.error = `Submodule checkout missing at ${gitlink.path}`;
|
|
85188
84799
|
entry.publishRequired = true;
|
|
85189
84800
|
if (options.allowAutoPublishSubmoduleMainCommits === true) {
|
|
@@ -85196,13 +84807,13 @@ ${mergeTreeErr?.stderr || ""}`;
|
|
|
85196
84807
|
}
|
|
85197
84808
|
entry.checkedLocal = true;
|
|
85198
84809
|
try {
|
|
85199
|
-
await
|
|
84810
|
+
await runGit4(submodulePath, ["cat-file", "-e", `${gitlink.commit}^{commit}`]);
|
|
85200
84811
|
entry.localReachable = true;
|
|
85201
84812
|
} catch {
|
|
85202
84813
|
entry.localReachable = false;
|
|
85203
84814
|
if (options.allowAutoPublishSubmoduleMainCommits === true && options.worktreeRoot) {
|
|
85204
84815
|
try {
|
|
85205
|
-
const imported = await importCommitFromWorktreeSubmodule(submodulePath, (0,
|
|
84816
|
+
const imported = await importCommitFromWorktreeSubmodule(submodulePath, (0, import_path18.resolve)(options.worktreeRoot, gitlink.path), gitlink.commit);
|
|
85206
84817
|
if (imported) {
|
|
85207
84818
|
entry.localReachable = true;
|
|
85208
84819
|
entry.importedFromWorktree = true;
|
|
@@ -85216,7 +84827,7 @@ ${mergeTreeErr?.stderr || ""}`;
|
|
|
85216
84827
|
entry.remote = "origin";
|
|
85217
84828
|
let remoteUrl = "";
|
|
85218
84829
|
try {
|
|
85219
|
-
remoteUrl = (await
|
|
84830
|
+
remoteUrl = (await runGit4(submodulePath, ["remote", "get-url", "origin"])).trim();
|
|
85220
84831
|
if (!remoteUrl) throw new Error("origin remote has no URL");
|
|
85221
84832
|
entry.remoteUrl = remoteUrl;
|
|
85222
84833
|
} catch {
|
|
@@ -85373,9 +84984,9 @@ ${mergeTreeErr?.stderr || ""}`;
|
|
|
85373
84984
|
};
|
|
85374
84985
|
}
|
|
85375
84986
|
async function runMeshRefineValidationGate(mesh, workspace, opts) {
|
|
85376
|
-
const { execFile:
|
|
85377
|
-
const { promisify:
|
|
85378
|
-
const
|
|
84987
|
+
const { execFile: execFile9 } = await import("child_process");
|
|
84988
|
+
const { promisify: promisify12 } = await import("util");
|
|
84989
|
+
const execFileAsync8 = promisify12(execFile9);
|
|
85379
84990
|
const selection = resolveMeshRefineValidationPlan(mesh, workspace);
|
|
85380
84991
|
const summary = {
|
|
85381
84992
|
status: "skipped",
|
|
@@ -85454,13 +85065,13 @@ ${mergeTreeErr?.stderr || ""}`;
|
|
|
85454
85065
|
...extras
|
|
85455
85066
|
});
|
|
85456
85067
|
const isPackageManagerValidation = (candidate) => {
|
|
85457
|
-
const command = (0,
|
|
85068
|
+
const command = (0, import_path18.basename)(candidate.command).replace(/\.(?:cmd|exe)$/i, "");
|
|
85458
85069
|
return ["npm", "pnpm", "yarn", "bun"].includes(command) && candidate.args.some((arg) => arg === "run" || arg === "test" || arg === "exec");
|
|
85459
85070
|
};
|
|
85460
85071
|
const dependenciesLikelyMissing = (cwd) => {
|
|
85461
|
-
if (!
|
|
85462
|
-
if (
|
|
85463
|
-
return ["package-lock.json", "npm-shrinkwrap.json", "pnpm-lock.yaml", "yarn.lock", "bun.lockb", "bun.lock"].some((lock) =>
|
|
85072
|
+
if (!fs52.existsSync((0, import_path18.join)(cwd, "package.json"))) return false;
|
|
85073
|
+
if (fs52.existsSync((0, import_path18.join)(cwd, "node_modules"))) return false;
|
|
85074
|
+
return ["package-lock.json", "npm-shrinkwrap.json", "pnpm-lock.yaml", "yarn.lock", "bun.lockb", "bun.lock"].some((lock) => fs52.existsSync((0, import_path18.join)(cwd, lock)));
|
|
85464
85075
|
};
|
|
85465
85076
|
const needsNodeModules = (candidate, cwd) => isPackageManagerValidation(candidate) && dependenciesLikelyMissing(cwd);
|
|
85466
85077
|
const isDaemonScopedCommand = (candidate) => {
|
|
@@ -85527,12 +85138,12 @@ ${mergeTreeErr?.stderr || ""}`;
|
|
|
85527
85138
|
summary.bootstrap = { stage: "legacy" };
|
|
85528
85139
|
for (const candidate of selection.bootstrapCommands) {
|
|
85529
85140
|
const startedAt = Date.now();
|
|
85530
|
-
const cwd = candidate.cwd ? (0,
|
|
85141
|
+
const cwd = candidate.cwd ? (0, import_path18.resolve)(workspace, candidate.cwd) : workspace;
|
|
85531
85142
|
const timeout = candidate.timeoutMs || REFINE_VALIDATION_TIMEOUT_MS;
|
|
85532
85143
|
const resolvedCommand = resolveWin32Executable(candidate.command);
|
|
85533
85144
|
const spawn7 = buildWin32ExecFileSpawn(resolvedCommand, candidate.args);
|
|
85534
85145
|
try {
|
|
85535
|
-
const result = await
|
|
85146
|
+
const result = await execFileAsync8(spawn7.file, spawn7.args, {
|
|
85536
85147
|
cwd,
|
|
85537
85148
|
encoding: "utf8",
|
|
85538
85149
|
timeout,
|
|
@@ -85560,7 +85171,7 @@ ${mergeTreeErr?.stderr || ""}`;
|
|
|
85560
85171
|
let missingDepsBlocked = false;
|
|
85561
85172
|
for (const candidate of commandsToRun) {
|
|
85562
85173
|
const startedAt = Date.now();
|
|
85563
|
-
const cwd = candidate.cwd ? (0,
|
|
85174
|
+
const cwd = candidate.cwd ? (0, import_path18.resolve)(workspace, candidate.cwd) : workspace;
|
|
85564
85175
|
const timeout = candidate.timeoutMs || REFINE_VALIDATION_TIMEOUT_MS;
|
|
85565
85176
|
const bootstrapProvidedDependencies = summary.bootstrap?.stage === "cached" || summary.bootstrap?.stage === "ran" || summary.bootstrap?.stage === "legacy";
|
|
85566
85177
|
if (!bootstrapProvidedDependencies && needsNodeModules(candidate, cwd)) {
|
|
@@ -85577,7 +85188,7 @@ ${mergeTreeErr?.stderr || ""}`;
|
|
|
85577
85188
|
const resolvedCommand = resolveWin32Executable(candidate.command);
|
|
85578
85189
|
const spawn7 = buildWin32ExecFileSpawn(resolvedCommand, candidate.args);
|
|
85579
85190
|
try {
|
|
85580
|
-
const result = await
|
|
85191
|
+
const result = await execFileAsync8(spawn7.file, spawn7.args, {
|
|
85581
85192
|
cwd,
|
|
85582
85193
|
encoding: "utf8",
|
|
85583
85194
|
timeout,
|
|
@@ -85627,9 +85238,9 @@ ${mergeTreeErr?.stderr || ""}`;
|
|
|
85627
85238
|
summary.status = "passed";
|
|
85628
85239
|
return summary;
|
|
85629
85240
|
}
|
|
85630
|
-
var
|
|
85631
|
-
var
|
|
85632
|
-
var
|
|
85241
|
+
var import_path18;
|
|
85242
|
+
var fs52;
|
|
85243
|
+
var import_node_child_process11;
|
|
85633
85244
|
var REFINE_VALIDATION_TIMEOUT_MS;
|
|
85634
85245
|
var REFINE_VALIDATION_OUTPUT_LIMIT_BYTES;
|
|
85635
85246
|
var REFINE_VALIDATION_SUMMARY_HEAD_CHARS;
|
|
@@ -85642,9 +85253,9 @@ ${mergeTreeErr?.stderr || ""}`;
|
|
|
85642
85253
|
init_git_status();
|
|
85643
85254
|
init_refine_config();
|
|
85644
85255
|
init_worktree_bootstrap_config();
|
|
85645
|
-
|
|
85646
|
-
|
|
85647
|
-
|
|
85256
|
+
import_path18 = require("path");
|
|
85257
|
+
fs52 = __toESM2(require("fs"));
|
|
85258
|
+
import_node_child_process11 = require("child_process");
|
|
85648
85259
|
init_resolve_executable();
|
|
85649
85260
|
init_mesh_refine_worker_cap();
|
|
85650
85261
|
init_mesh_refine_gitlink_utils();
|
|
@@ -85655,7 +85266,597 @@ ${mergeTreeErr?.stderr || ""}`;
|
|
|
85655
85266
|
REFINE_VALIDATION_SUMMARY_HEAD_CHARS = 2e3;
|
|
85656
85267
|
REFINE_VALIDATION_SUMMARY_TAIL_CHARS = 6e3;
|
|
85657
85268
|
REFINE_VALIDATION_SUMMARY_CHARS = REFINE_VALIDATION_SUMMARY_HEAD_CHARS + REFINE_VALIDATION_SUMMARY_TAIL_CHARS;
|
|
85658
|
-
REFINE_VALIDATION_LOG_DIR = (0,
|
|
85269
|
+
REFINE_VALIDATION_LOG_DIR = (0, import_path18.join)(".adhdev", "logs");
|
|
85270
|
+
}
|
|
85271
|
+
});
|
|
85272
|
+
async function runMeshRefineSubmoduleReachabilityPreflight(args) {
|
|
85273
|
+
const startedAt = Date.now();
|
|
85274
|
+
const touched = args.touchedSubmodulePaths ?? readChangedGitlinkPaths(args.worktreeRoot, args.baseRef, args.branchRef);
|
|
85275
|
+
if (touched.length === 0) return void 0;
|
|
85276
|
+
const entries = [];
|
|
85277
|
+
for (const path63 of touched) {
|
|
85278
|
+
const probedRepo = (0, import_path19.resolve)(args.worktreeRoot, path63);
|
|
85279
|
+
const commit = readTreeObject(args.worktreeRoot, args.branchRef, path63);
|
|
85280
|
+
if (!commit) {
|
|
85281
|
+
entries.push({
|
|
85282
|
+
path: path63,
|
|
85283
|
+
verdict: "undeterminable",
|
|
85284
|
+
probedRepo,
|
|
85285
|
+
error: `No gitlink commit recorded at '${path63}' on ${args.branchRef}`
|
|
85286
|
+
});
|
|
85287
|
+
continue;
|
|
85288
|
+
}
|
|
85289
|
+
let remoteMainBranch = "main";
|
|
85290
|
+
try {
|
|
85291
|
+
remoteMainBranch = await resolveSubmoduleDefaultBranch({
|
|
85292
|
+
submoduleRepoPath: probedRepo,
|
|
85293
|
+
superprojectWorkspace: args.worktreeRoot,
|
|
85294
|
+
submodulePath: path63
|
|
85295
|
+
});
|
|
85296
|
+
} catch {
|
|
85297
|
+
}
|
|
85298
|
+
const verdict = await verifyRemoteBranchContainsCommit(runGit2, probedRepo, commit, remoteMainBranch);
|
|
85299
|
+
if (verdict.state === "contained") {
|
|
85300
|
+
entries.push({ path: path63, commit, verdict: "reachable", remoteMainBranch, probedRepo });
|
|
85301
|
+
} else if (verdict.state === "absent") {
|
|
85302
|
+
entries.push({
|
|
85303
|
+
path: path63,
|
|
85304
|
+
commit,
|
|
85305
|
+
verdict: "unreachable",
|
|
85306
|
+
remoteMainBranch,
|
|
85307
|
+
probedRepo,
|
|
85308
|
+
error: `Submodule gitlink commit is not reachable from origin/${remoteMainBranch} (publish required before the root branch can merge).`
|
|
85309
|
+
});
|
|
85310
|
+
} else {
|
|
85311
|
+
entries.push({
|
|
85312
|
+
path: path63,
|
|
85313
|
+
commit,
|
|
85314
|
+
verdict: "undeterminable",
|
|
85315
|
+
remoteMainBranch,
|
|
85316
|
+
probedRepo,
|
|
85317
|
+
error: `Reachability against origin/${remoteMainBranch} could not be determined (the submodule remote was not successfully consulted). This is NOT evidence the commit is unpublished.`
|
|
85318
|
+
});
|
|
85319
|
+
}
|
|
85320
|
+
}
|
|
85321
|
+
const blocked = entries.filter((entry) => entry.verdict !== "reachable");
|
|
85322
|
+
const summary = {
|
|
85323
|
+
status: blocked.length ? "warning" : "passed",
|
|
85324
|
+
checked: entries.length,
|
|
85325
|
+
entries,
|
|
85326
|
+
durationMs: Date.now() - startedAt
|
|
85327
|
+
};
|
|
85328
|
+
if (blocked.length) {
|
|
85329
|
+
const gateEntries = blocked.map((entry) => ({
|
|
85330
|
+
path: entry.path,
|
|
85331
|
+
commit: entry.commit || "",
|
|
85332
|
+
reachable: false,
|
|
85333
|
+
publishRequired: entry.verdict === "unreachable",
|
|
85334
|
+
...entry.verdict === "undeterminable" ? { remoteMainUndeterminable: true } : {}
|
|
85335
|
+
}));
|
|
85336
|
+
summary.nextStep = buildSubmodulePublishRequiredNextStep(gateEntries);
|
|
85337
|
+
}
|
|
85338
|
+
return summary;
|
|
85339
|
+
}
|
|
85340
|
+
async function resolveRefinePlanBaseRef(repoRoot) {
|
|
85341
|
+
let baseBranch = "main";
|
|
85342
|
+
try {
|
|
85343
|
+
const { stdout } = await execFileAsync5(GIT2, ["branch", "--show-current"], { cwd: repoRoot, encoding: "utf8" });
|
|
85344
|
+
if (stdout.trim()) baseBranch = stdout.trim();
|
|
85345
|
+
} catch {
|
|
85346
|
+
}
|
|
85347
|
+
try {
|
|
85348
|
+
await execFileAsync5(GIT2, ["fetch", "origin", baseBranch], { cwd: repoRoot, encoding: "utf8" });
|
|
85349
|
+
} catch {
|
|
85350
|
+
}
|
|
85351
|
+
try {
|
|
85352
|
+
const { stdout } = await execFileAsync5(GIT2, ["rev-parse", `origin/${baseBranch}`], { cwd: repoRoot, encoding: "utf8" });
|
|
85353
|
+
if (stdout.trim()) return stdout.trim();
|
|
85354
|
+
} catch {
|
|
85355
|
+
}
|
|
85356
|
+
try {
|
|
85357
|
+
const { stdout } = await execFileAsync5(GIT2, ["rev-parse", "HEAD"], { cwd: repoRoot, encoding: "utf8" });
|
|
85358
|
+
if (stdout.trim()) return stdout.trim();
|
|
85359
|
+
} catch {
|
|
85360
|
+
}
|
|
85361
|
+
return "HEAD";
|
|
85362
|
+
}
|
|
85363
|
+
async function planMeshRefineNodeSubmodulePreflight(args) {
|
|
85364
|
+
const { mesh, node } = args;
|
|
85365
|
+
const workspace = typeof node?.workspace === "string" ? node.workspace : "";
|
|
85366
|
+
if (!workspace) return void 0;
|
|
85367
|
+
const allNodes = Array.isArray(mesh?.nodes) ? mesh.nodes : [];
|
|
85368
|
+
const sourceNode = node.clonedFromNodeId ? allNodes.find((n) => meshNodeIdMatches(n, node.clonedFromNodeId)) : allNodes.find((n) => !n.isLocalWorktree);
|
|
85369
|
+
const repoRoot = sourceNode?.repoRoot || sourceNode?.workspace;
|
|
85370
|
+
if (!repoRoot) return void 0;
|
|
85371
|
+
let branch = typeof node.worktreeBranch === "string" ? node.worktreeBranch : "";
|
|
85372
|
+
try {
|
|
85373
|
+
const { stdout } = await execFileAsync5(GIT2, ["branch", "--show-current"], { cwd: workspace, encoding: "utf8" });
|
|
85374
|
+
if (stdout.trim()) branch = stdout.trim();
|
|
85375
|
+
} catch {
|
|
85376
|
+
}
|
|
85377
|
+
if (!branch) return void 0;
|
|
85378
|
+
let branchRef = branch;
|
|
85379
|
+
try {
|
|
85380
|
+
const { stdout } = await execFileAsync5(GIT2, ["rev-parse", branch], { cwd: workspace, encoding: "utf8" });
|
|
85381
|
+
branchRef = stdout.trim() || branch;
|
|
85382
|
+
} catch {
|
|
85383
|
+
}
|
|
85384
|
+
const baseRef = await resolveRefinePlanBaseRef(repoRoot);
|
|
85385
|
+
return runMeshRefineSubmoduleReachabilityPreflight({
|
|
85386
|
+
worktreeRoot: workspace,
|
|
85387
|
+
baseRef,
|
|
85388
|
+
branchRef,
|
|
85389
|
+
...args.touchedSubmodulePaths ? { touchedSubmodulePaths: args.touchedSubmodulePaths } : {}
|
|
85390
|
+
});
|
|
85391
|
+
}
|
|
85392
|
+
async function buildMeshRefineBatchDryRunResult(args) {
|
|
85393
|
+
const { mesh, orderedNodes, ordering } = args;
|
|
85394
|
+
const warnings = [];
|
|
85395
|
+
for (const node of orderedNodes) {
|
|
85396
|
+
const area = ordering.changeAreas[node.id];
|
|
85397
|
+
if (!area?.touchesSubmodule || area.error) continue;
|
|
85398
|
+
let preflight;
|
|
85399
|
+
try {
|
|
85400
|
+
preflight = await planMeshRefineNodeSubmodulePreflight({
|
|
85401
|
+
mesh,
|
|
85402
|
+
node,
|
|
85403
|
+
touchedSubmodulePaths: area.touchedSubmodulePaths
|
|
85404
|
+
});
|
|
85405
|
+
} catch {
|
|
85406
|
+
}
|
|
85407
|
+
if (!preflight) continue;
|
|
85408
|
+
area.submoduleReachabilityPreflight = preflight;
|
|
85409
|
+
if (preflight.status === "warning") {
|
|
85410
|
+
warnings.push(`Node ${area.nodeId}: submodule reachability preflight warns \u2014 ${preflight.nextStep || "see changeAreas for details."}`);
|
|
85411
|
+
}
|
|
85412
|
+
}
|
|
85413
|
+
return {
|
|
85414
|
+
success: true,
|
|
85415
|
+
batch: true,
|
|
85416
|
+
dryRun: true,
|
|
85417
|
+
nodeCount: orderedNodes.length,
|
|
85418
|
+
order: ordering.order,
|
|
85419
|
+
orderingRationale: ordering.rationale,
|
|
85420
|
+
changeAreas: ordering.changeAreas,
|
|
85421
|
+
plan: orderedNodes.map((node) => ({
|
|
85422
|
+
nodeId: node.id,
|
|
85423
|
+
workspace: node.workspace,
|
|
85424
|
+
validationPlan: buildMeshRefineValidationPlan(mesh, node.workspace),
|
|
85425
|
+
mergeWillRun: false
|
|
85426
|
+
})),
|
|
85427
|
+
...warnings.length ? { submodulePreflightWarnings: warnings } : {},
|
|
85428
|
+
note: "Dry-run: no validation, rebase, or merge was executed. Re-run with execute=true to converge nodes in this order."
|
|
85429
|
+
};
|
|
85430
|
+
}
|
|
85431
|
+
var import_node_child_process12;
|
|
85432
|
+
var import_node_util6;
|
|
85433
|
+
var import_path19;
|
|
85434
|
+
var execFileAsync5;
|
|
85435
|
+
var runGit2;
|
|
85436
|
+
var init_mesh_refine_submodule_preflight = __esm2({
|
|
85437
|
+
"src/mesh/mesh-refine-submodule-preflight.ts"() {
|
|
85438
|
+
"use strict";
|
|
85439
|
+
import_node_child_process12 = require("child_process");
|
|
85440
|
+
import_node_util6 = require("util");
|
|
85441
|
+
import_path19 = require("path");
|
|
85442
|
+
init_dist();
|
|
85443
|
+
init_mesh_refine_gitlink_utils();
|
|
85444
|
+
init_mesh_refine_gates();
|
|
85445
|
+
init_worktree_bootstrap_config();
|
|
85446
|
+
execFileAsync5 = (0, import_node_util6.promisify)(import_node_child_process12.execFile);
|
|
85447
|
+
runGit2 = async (cwd, args) => {
|
|
85448
|
+
const { stdout } = await execFileAsync5(GIT2, args, {
|
|
85449
|
+
cwd,
|
|
85450
|
+
encoding: "utf8",
|
|
85451
|
+
timeout: 3e4,
|
|
85452
|
+
maxBuffer: REFINE_PATCH_EQUIVALENCE_OUTPUT_LIMIT_BYTES,
|
|
85453
|
+
windowsHide: true
|
|
85454
|
+
});
|
|
85455
|
+
return String(stdout || "");
|
|
85456
|
+
};
|
|
85457
|
+
}
|
|
85458
|
+
});
|
|
85459
|
+
function topLevel(path63) {
|
|
85460
|
+
const slash = path63.indexOf("/");
|
|
85461
|
+
return slash === -1 ? path63 : path63.slice(0, slash);
|
|
85462
|
+
}
|
|
85463
|
+
async function analyzeMeshRefineNodeChangeArea(args) {
|
|
85464
|
+
const { nodeId, workspace, branch, baseRef, branchRef, diffCwd, submodulePaths } = args;
|
|
85465
|
+
const base = {
|
|
85466
|
+
nodeId,
|
|
85467
|
+
workspace,
|
|
85468
|
+
branch,
|
|
85469
|
+
changedTopLevelPaths: [],
|
|
85470
|
+
changedFiles: [],
|
|
85471
|
+
touchedSubmodulePaths: [],
|
|
85472
|
+
touchesSubmodule: false,
|
|
85473
|
+
aheadCount: 0
|
|
85474
|
+
};
|
|
85475
|
+
try {
|
|
85476
|
+
let mergeBase = baseRef;
|
|
85477
|
+
try {
|
|
85478
|
+
const { stdout } = await execFileAsync6(GIT3, ["merge-base", baseRef, branchRef], { cwd: diffCwd, encoding: "utf8" });
|
|
85479
|
+
const resolved = stdout.trim();
|
|
85480
|
+
if (resolved) mergeBase = resolved;
|
|
85481
|
+
} catch {
|
|
85482
|
+
}
|
|
85483
|
+
const { stdout: countStdout } = await execFileAsync6(
|
|
85484
|
+
GIT3,
|
|
85485
|
+
["rev-list", "--count", `${mergeBase}..${branchRef}`],
|
|
85486
|
+
{ cwd: diffCwd, encoding: "utf8" }
|
|
85487
|
+
);
|
|
85488
|
+
base.aheadCount = Number.parseInt(countStdout.trim(), 10) || 0;
|
|
85489
|
+
const { stdout: nameStdout } = await execFileAsync6(
|
|
85490
|
+
GIT3,
|
|
85491
|
+
["diff", "--name-only", `${mergeBase}..${branchRef}`],
|
|
85492
|
+
{ cwd: diffCwd, encoding: "utf8" }
|
|
85493
|
+
);
|
|
85494
|
+
const files = nameStdout.split("\n").map((line) => line.trim()).filter(Boolean).slice(0, MAX_CHANGED_FILES2);
|
|
85495
|
+
base.changedFiles = files;
|
|
85496
|
+
const topSet = /* @__PURE__ */ new Set();
|
|
85497
|
+
const submoduleSet = /* @__PURE__ */ new Set();
|
|
85498
|
+
for (const file2 of files) {
|
|
85499
|
+
const top = topLevel(file2);
|
|
85500
|
+
topSet.add(top);
|
|
85501
|
+
if (submodulePaths.has(file2) || submodulePaths.has(top)) {
|
|
85502
|
+
submoduleSet.add(submodulePaths.has(file2) ? file2 : top);
|
|
85503
|
+
}
|
|
85504
|
+
}
|
|
85505
|
+
base.changedTopLevelPaths = [...topSet].sort();
|
|
85506
|
+
base.touchedSubmodulePaths = [...submoduleSet].sort();
|
|
85507
|
+
base.touchesSubmodule = submoduleSet.size > 0;
|
|
85508
|
+
return base;
|
|
85509
|
+
} catch (e) {
|
|
85510
|
+
base.error = e?.message || String(e);
|
|
85511
|
+
return base;
|
|
85512
|
+
}
|
|
85513
|
+
}
|
|
85514
|
+
function orderMeshRefineBatchNodes(changeAreas) {
|
|
85515
|
+
const areaById = {};
|
|
85516
|
+
for (const area of changeAreas) areaById[area.nodeId] = area;
|
|
85517
|
+
const ranked = [...changeAreas].sort((a, b) => {
|
|
85518
|
+
const aSub = a.touchesSubmodule ? 1 : 0;
|
|
85519
|
+
const bSub = b.touchesSubmodule ? 1 : 0;
|
|
85520
|
+
if (aSub !== bSub) return aSub - bSub;
|
|
85521
|
+
const aBreadth = a.changedTopLevelPaths.length;
|
|
85522
|
+
const bBreadth = b.changedTopLevelPaths.length;
|
|
85523
|
+
if (aBreadth !== bBreadth) return aBreadth - bBreadth;
|
|
85524
|
+
return a.nodeId.localeCompare(b.nodeId);
|
|
85525
|
+
});
|
|
85526
|
+
const rationale = [];
|
|
85527
|
+
const nonSub = ranked.filter((a) => !a.touchesSubmodule).map((a) => a.nodeId);
|
|
85528
|
+
const sub = ranked.filter((a) => a.touchesSubmodule).map((a) => a.nodeId);
|
|
85529
|
+
if (nonSub.length) {
|
|
85530
|
+
rationale.push(`Non-submodule nodes first (no submodule-main advance, conflict-free ordering): ${nonSub.join(", ")}`);
|
|
85531
|
+
}
|
|
85532
|
+
if (sub.length) {
|
|
85533
|
+
rationale.push(`Submodule-touching nodes last, serialized (each merge advances submodule main, forcing rebase of the next): ${sub.join(", ")}`);
|
|
85534
|
+
}
|
|
85535
|
+
for (const area of ranked) {
|
|
85536
|
+
if (area.error) rationale.push(`Node ${area.nodeId}: change-area analysis degraded (${area.error}); placed with neutral priority.`);
|
|
85537
|
+
}
|
|
85538
|
+
return { order: ranked.map((a) => a.nodeId), changeAreas: areaById, rationale };
|
|
85539
|
+
}
|
|
85540
|
+
var import_node_child_process14;
|
|
85541
|
+
var import_node_util7;
|
|
85542
|
+
var execFileAsync6;
|
|
85543
|
+
var GIT3;
|
|
85544
|
+
var MAX_CHANGED_FILES2;
|
|
85545
|
+
var init_mesh_refine_batch = __esm2({
|
|
85546
|
+
"src/mesh/mesh-refine-batch.ts"() {
|
|
85547
|
+
"use strict";
|
|
85548
|
+
import_node_child_process14 = require("child_process");
|
|
85549
|
+
import_node_util7 = require("util");
|
|
85550
|
+
init_resolve_executable();
|
|
85551
|
+
execFileAsync6 = (0, import_node_util7.promisify)(import_node_child_process14.execFile);
|
|
85552
|
+
GIT3 = process.platform === "win32" ? resolveWin32Executable("git") : "git";
|
|
85553
|
+
MAX_CHANGED_FILES2 = 500;
|
|
85554
|
+
}
|
|
85555
|
+
});
|
|
85556
|
+
async function git2(cwd, args) {
|
|
85557
|
+
const { stdout } = await execFileAsync7(GIT4, args, {
|
|
85558
|
+
cwd,
|
|
85559
|
+
encoding: "utf8",
|
|
85560
|
+
timeout: 15e3,
|
|
85561
|
+
windowsHide: true
|
|
85562
|
+
});
|
|
85563
|
+
return String(stdout || "").trim();
|
|
85564
|
+
}
|
|
85565
|
+
async function isAncestor(cwd, ancestor, descendant) {
|
|
85566
|
+
try {
|
|
85567
|
+
await git2(cwd, ["merge-base", "--is-ancestor", ancestor, descendant]);
|
|
85568
|
+
return true;
|
|
85569
|
+
} catch {
|
|
85570
|
+
return false;
|
|
85571
|
+
}
|
|
85572
|
+
}
|
|
85573
|
+
async function assessScope(cwd, path63, baseRef, branchRef) {
|
|
85574
|
+
try {
|
|
85575
|
+
if (!(0, import_node_fs7.existsSync)(cwd)) return { path: path63, verdict: "unknown", error: `path does not exist: ${cwd}` };
|
|
85576
|
+
const liveBaseHead = await git2(cwd, ["rev-parse", baseRef]);
|
|
85577
|
+
const branchHead = await git2(cwd, ["rev-parse", branchRef]);
|
|
85578
|
+
if (!liveBaseHead || !branchHead) {
|
|
85579
|
+
return { path: path63, verdict: "unknown", error: "could not resolve base or branch head" };
|
|
85580
|
+
}
|
|
85581
|
+
if (await isAncestor(cwd, liveBaseHead, branchHead)) {
|
|
85582
|
+
return { path: path63, verdict: "clear", liveBaseHead };
|
|
85583
|
+
}
|
|
85584
|
+
let mergeBase;
|
|
85585
|
+
try {
|
|
85586
|
+
mergeBase = await git2(cwd, ["merge-base", liveBaseHead, branchHead]);
|
|
85587
|
+
} catch {
|
|
85588
|
+
return { path: path63, verdict: "unknown", liveBaseHead, error: "no common merge base" };
|
|
85589
|
+
}
|
|
85590
|
+
if (!mergeBase) return { path: path63, verdict: "unknown", liveBaseHead, error: "empty merge base" };
|
|
85591
|
+
return { path: path63, verdict: "diverged", liveBaseHead, mergeBase };
|
|
85592
|
+
} catch (e) {
|
|
85593
|
+
return { path: path63, verdict: "unknown", error: e?.message || String(e) };
|
|
85594
|
+
}
|
|
85595
|
+
}
|
|
85596
|
+
async function resolveSubmodulePaths(repoRoot) {
|
|
85597
|
+
try {
|
|
85598
|
+
const stdout = await git2(repoRoot, ["config", "--file", ".gitmodules", "--get-regexp", "path"]);
|
|
85599
|
+
const paths = /* @__PURE__ */ new Set();
|
|
85600
|
+
for (const line of stdout.split("\n")) {
|
|
85601
|
+
const trimmed = line.trim();
|
|
85602
|
+
const spaceIdx = trimmed.indexOf(" ");
|
|
85603
|
+
if (spaceIdx === -1) continue;
|
|
85604
|
+
const value = trimmed.slice(spaceIdx + 1).trim();
|
|
85605
|
+
if (value) paths.add(value);
|
|
85606
|
+
}
|
|
85607
|
+
return paths;
|
|
85608
|
+
} catch {
|
|
85609
|
+
return /* @__PURE__ */ new Set();
|
|
85610
|
+
}
|
|
85611
|
+
}
|
|
85612
|
+
async function assessRefineBaseDivergence(args) {
|
|
85613
|
+
const started = Date.now();
|
|
85614
|
+
const { repoRoot, workspace, baseBranch, branch } = args;
|
|
85615
|
+
const scopes = [];
|
|
85616
|
+
let touchedSubmodulePaths = [];
|
|
85617
|
+
const rootBaseRef = await (async () => {
|
|
85618
|
+
for (const ref of [`origin/${baseBranch}`, baseBranch, "HEAD"]) {
|
|
85619
|
+
try {
|
|
85620
|
+
await git2(repoRoot, ["rev-parse", "--verify", `${ref}^{commit}`]);
|
|
85621
|
+
return ref;
|
|
85622
|
+
} catch {
|
|
85623
|
+
}
|
|
85624
|
+
}
|
|
85625
|
+
return `origin/${baseBranch}`;
|
|
85626
|
+
})();
|
|
85627
|
+
scopes.push(await assessScope(workspace, ".", rootBaseRef, branch));
|
|
85628
|
+
try {
|
|
85629
|
+
const submodulePaths = await resolveSubmodulePaths(repoRoot);
|
|
85630
|
+
if (submodulePaths.size > 0) {
|
|
85631
|
+
const baseRefSha = await git2(repoRoot, ["rev-parse", rootBaseRef]).catch(() => "");
|
|
85632
|
+
const branchRefSha = await git2(workspace, ["rev-parse", branch]).catch(() => "");
|
|
85633
|
+
if (baseRefSha && branchRefSha) {
|
|
85634
|
+
const area = await analyzeMeshRefineNodeChangeArea({
|
|
85635
|
+
nodeId: "(accept-precheck)",
|
|
85636
|
+
workspace,
|
|
85637
|
+
branch,
|
|
85638
|
+
baseRef: baseRefSha,
|
|
85639
|
+
branchRef: branchRefSha,
|
|
85640
|
+
diffCwd: workspace,
|
|
85641
|
+
submodulePaths
|
|
85642
|
+
});
|
|
85643
|
+
touchedSubmodulePaths = area.touchedSubmodulePaths;
|
|
85644
|
+
for (const subPath of touchedSubmodulePaths) {
|
|
85645
|
+
const subCwd = (0, import_node_path5.resolve)(workspace, subPath);
|
|
85646
|
+
const subBaseRef = await (async () => {
|
|
85647
|
+
for (const ref of ["origin/main", "origin/master", "main", "master"]) {
|
|
85648
|
+
try {
|
|
85649
|
+
await git2(subCwd, ["rev-parse", "--verify", `${ref}^{commit}`]);
|
|
85650
|
+
return ref;
|
|
85651
|
+
} catch {
|
|
85652
|
+
}
|
|
85653
|
+
}
|
|
85654
|
+
return "origin/main";
|
|
85655
|
+
})();
|
|
85656
|
+
scopes.push(await assessScope(subCwd, subPath, subBaseRef, "HEAD"));
|
|
85657
|
+
}
|
|
85658
|
+
}
|
|
85659
|
+
}
|
|
85660
|
+
} catch {
|
|
85661
|
+
}
|
|
85662
|
+
const verdict = scopes.some((s2) => s2.verdict === "diverged") ? "diverged" : scopes.some((s2) => s2.verdict === "unknown") ? "unknown" : "clear";
|
|
85663
|
+
return { verdict, scopes, touchedSubmodulePaths, durationMs: Date.now() - started };
|
|
85664
|
+
}
|
|
85665
|
+
var import_node_child_process15;
|
|
85666
|
+
var import_node_util8;
|
|
85667
|
+
var import_node_path5;
|
|
85668
|
+
var import_node_fs7;
|
|
85669
|
+
var execFileAsync7;
|
|
85670
|
+
var GIT4;
|
|
85671
|
+
var init_mesh_refine_base_divergence = __esm2({
|
|
85672
|
+
"src/mesh/mesh-refine-base-divergence.ts"() {
|
|
85673
|
+
"use strict";
|
|
85674
|
+
import_node_child_process15 = require("child_process");
|
|
85675
|
+
import_node_util8 = require("util");
|
|
85676
|
+
import_node_path5 = require("path");
|
|
85677
|
+
import_node_fs7 = require("fs");
|
|
85678
|
+
init_resolve_executable();
|
|
85679
|
+
init_mesh_refine_batch();
|
|
85680
|
+
execFileAsync7 = (0, import_node_util8.promisify)(import_node_child_process15.execFile);
|
|
85681
|
+
GIT4 = process.platform === "win32" ? resolveWin32Executable("git") : "git";
|
|
85682
|
+
}
|
|
85683
|
+
});
|
|
85684
|
+
var mesh_refine_zombie_sweep_exports = {};
|
|
85685
|
+
__export2(mesh_refine_zombie_sweep_exports, {
|
|
85686
|
+
classifyRefineDispatch: () => classifyRefineDispatch,
|
|
85687
|
+
refineArchivePairKey: () => refineArchivePairKey,
|
|
85688
|
+
selectOpenRefineDispatches: () => selectOpenRefineDispatches,
|
|
85689
|
+
shouldNotifyRefineCloseOut: () => shouldNotifyRefineCloseOut
|
|
85690
|
+
});
|
|
85691
|
+
function classifyRefineDispatch(record2, opts) {
|
|
85692
|
+
if (opts.isRunning(record2.nodeId)) return void 0;
|
|
85693
|
+
const dispatchedAtMs = new Date(record2.timestamp).getTime();
|
|
85694
|
+
const ageMs2 = Number.isFinite(dispatchedAtMs) ? opts.nowMs - dispatchedAtMs : void 0;
|
|
85695
|
+
const base = { nodeId: record2.nodeId, jobId: record2.jobId, ...ageMs2 !== void 0 ? { ageMs: ageMs2 } : {} };
|
|
85696
|
+
if (!opts.nodeExists(record2.nodeId)) {
|
|
85697
|
+
return { ...base, disposition: "close_removed_node" };
|
|
85698
|
+
}
|
|
85699
|
+
if (opts.executorLiveness) {
|
|
85700
|
+
let liveness;
|
|
85701
|
+
try {
|
|
85702
|
+
liveness = opts.executorLiveness(record2);
|
|
85703
|
+
} catch {
|
|
85704
|
+
liveness = "unknown";
|
|
85705
|
+
}
|
|
85706
|
+
if (liveness === "alive") {
|
|
85707
|
+
return { ...base, disposition: "defer_executor_alive" };
|
|
85708
|
+
}
|
|
85709
|
+
}
|
|
85710
|
+
if (ageMs2 !== void 0 && ageMs2 >= 0 && ageMs2 < opts.graceMs) {
|
|
85711
|
+
return { ...base, disposition: "defer_grace" };
|
|
85712
|
+
}
|
|
85713
|
+
if (ageMs2 !== void 0 && ageMs2 >= opts.zombieCutoffMs) {
|
|
85714
|
+
return { ...base, disposition: "close_stale" };
|
|
85715
|
+
}
|
|
85716
|
+
return { ...base, disposition: "resume" };
|
|
85717
|
+
}
|
|
85718
|
+
function selectOpenRefineDispatches(entries, archivedTerminalKeys) {
|
|
85719
|
+
const terminalKeys = /* @__PURE__ */ new Set();
|
|
85720
|
+
for (const e of entries) {
|
|
85721
|
+
if (e.kind !== "task_completed" && e.kind !== "task_failed") continue;
|
|
85722
|
+
if (!e.nodeId) continue;
|
|
85723
|
+
const jobId = e.payload?.refineJob?.jobId;
|
|
85724
|
+
if (jobId) terminalKeys.add(`${e.nodeId}:${jobId}`);
|
|
85725
|
+
}
|
|
85726
|
+
const open = [];
|
|
85727
|
+
const seen = /* @__PURE__ */ new Set();
|
|
85728
|
+
for (const e of entries) {
|
|
85729
|
+
if (e.kind !== "task_dispatched" || !e.nodeId) continue;
|
|
85730
|
+
const payload = e.payload;
|
|
85731
|
+
if (payload?.source !== "refine_mesh_node_async_job") continue;
|
|
85732
|
+
const jobId = payload?.refineJob?.jobId;
|
|
85733
|
+
if (!jobId) continue;
|
|
85734
|
+
const key2 = `${e.nodeId}:${jobId}`;
|
|
85735
|
+
if (terminalKeys.has(key2) || seen.has(key2)) continue;
|
|
85736
|
+
if (archivedTerminalKeys?.has(refineArchivePairKey(e.nodeId, jobId))) continue;
|
|
85737
|
+
seen.add(key2);
|
|
85738
|
+
const executor = payload?.refineJob?.executor;
|
|
85739
|
+
open.push({ nodeId: e.nodeId, jobId, timestamp: e.timestamp, ...executor ? { executor } : {} });
|
|
85740
|
+
}
|
|
85741
|
+
return open;
|
|
85742
|
+
}
|
|
85743
|
+
function refineArchivePairKey(nodeId, jobId) {
|
|
85744
|
+
return `refine:${nodeId}:${jobId}`;
|
|
85745
|
+
}
|
|
85746
|
+
function shouldNotifyRefineCloseOut(decision, notifyHorizonMs) {
|
|
85747
|
+
if (decision.disposition === "close_removed_node") return false;
|
|
85748
|
+
if (decision.disposition !== "close_stale") return false;
|
|
85749
|
+
if (decision.ageMs === void 0) return true;
|
|
85750
|
+
return decision.ageMs < notifyHorizonMs;
|
|
85751
|
+
}
|
|
85752
|
+
var init_mesh_refine_zombie_sweep = __esm2({
|
|
85753
|
+
"src/mesh/mesh-refine-zombie-sweep.ts"() {
|
|
85754
|
+
"use strict";
|
|
85755
|
+
}
|
|
85756
|
+
});
|
|
85757
|
+
function classifyRefineTerminal(result) {
|
|
85758
|
+
const refineCode = typeof result.code === "string" ? result.code : "";
|
|
85759
|
+
const landing = extractRefineMergeLanding(result);
|
|
85760
|
+
const isPostMergeWarning = result.success !== true && landing.merged && landing.pushed;
|
|
85761
|
+
const kind = result.success === true ? "completed" : isPostMergeWarning ? "completed_with_warnings" : refineCode === "blocked_review" || refineCode === "worktree_missing" || refineCode === "worktree_dirty" || refineCode === "rebase_precondition_failed" || refineCode === "rebase_failed" ? "blocked_review" : refineCode === "validation_failed" || refineCode === "validation_dependencies_missing" || refineCode === "missing_dependencies" || refineCode === "dependency_bootstrap_failed" || refineCode === "spawn_resolution_failed" || refineCode === "validation_unavailable" || refineCode === "output_limit_exceeded" ? "validation_failed" : refineCode === "submodule_reachability_failed" ? "submodule_reachability_failed" : refineCode === "merge_failed" || refineCode === "patch_equivalence_failed" || refineCode === "needs_rebase" || refineCode === "needs_rebase_with_conflicts" ? "merge_failed" : refineCode === "cleanup_failed" ? "cleanup_failed" : "merge_failed";
|
|
85762
|
+
const clean = kind === "completed";
|
|
85763
|
+
return { kind, landing, isPostMergeWarning, converged: clean || isPostMergeWarning, clean };
|
|
85764
|
+
}
|
|
85765
|
+
function refineTerminalNextStep(kind) {
|
|
85766
|
+
switch (kind) {
|
|
85767
|
+
case "blocked_review":
|
|
85768
|
+
return "Request user review/approval before attempting to merge again.";
|
|
85769
|
+
case "validation_failed":
|
|
85770
|
+
return "Fix failing tests or configure validation.bootstrapCommands and retry mesh_refine_node.";
|
|
85771
|
+
case "submodule_reachability_failed":
|
|
85772
|
+
return "Push unreachable submodule commits to origin/main, then retry mesh_refine_node.";
|
|
85773
|
+
case "merge_failed":
|
|
85774
|
+
return "Resolve merge conflicts or patch equivalence issues, then retry mesh_refine_node.";
|
|
85775
|
+
case "cleanup_failed":
|
|
85776
|
+
return "Manually remove the worktree and retry or use mesh_remove_node.";
|
|
85777
|
+
case "completed_with_warnings":
|
|
85778
|
+
return "The merge IS on origin \u2014 do NOT re-run mesh_refine_node. Only the post-merge step below needs attention (worktree cleanup / submodule alignment); treat the branch as merged_to_main.";
|
|
85779
|
+
default:
|
|
85780
|
+
return "Inspect refineStages for the failing stage and retry.";
|
|
85781
|
+
}
|
|
85782
|
+
}
|
|
85783
|
+
function buildRefineWorktreeMissingResult(nodeId, workspace, refineStages) {
|
|
85784
|
+
return {
|
|
85785
|
+
success: false,
|
|
85786
|
+
code: "worktree_missing",
|
|
85787
|
+
convergenceStatus: "blocked_review",
|
|
85788
|
+
// Never auto-retried: re-running cannot recreate the worktree, and the node has
|
|
85789
|
+
// most likely already converged.
|
|
85790
|
+
retryable: false,
|
|
85791
|
+
workspaceMissing: true,
|
|
85792
|
+
error: `The worktree directory for node '${nodeId}' no longer exists (${workspace}); nothing was merged by this run. Worktree removal is the final step of a SUCCESSFUL refine, so this node was most likely already merged and cleaned up by an earlier job \u2014 verify with 'git -C <repoRoot> log --oneline' before acting. Do NOT re-run refine to "fix" this.`,
|
|
85793
|
+
nextStep: "Verify whether the branch already merged into the base (it most likely did). If so, treat the node as merged_to_main and remove it from the mesh; only re-clone if the work is genuinely missing.",
|
|
85794
|
+
refineStages,
|
|
85795
|
+
finalBranchConvergenceState: {
|
|
85796
|
+
baseBranch: void 0,
|
|
85797
|
+
merged: false,
|
|
85798
|
+
removed: true,
|
|
85799
|
+
status: "blocked_review"
|
|
85800
|
+
}
|
|
85801
|
+
};
|
|
85802
|
+
}
|
|
85803
|
+
function extractRefineMergeLanding(result) {
|
|
85804
|
+
const fbcs = result.finalBranchConvergenceState && typeof result.finalBranchConvergenceState === "object" ? result.finalBranchConvergenceState : void 0;
|
|
85805
|
+
const merged = result.merged === true || result.mergedLocal === true || fbcs?.merged === true;
|
|
85806
|
+
const pushed = result.pushed === true || fbcs?.pushed === true;
|
|
85807
|
+
return { merged: !!merged, pushed: !!pushed && !!merged };
|
|
85808
|
+
}
|
|
85809
|
+
function buildRefineBlockerContext(result, opts) {
|
|
85810
|
+
if (opts.isTerminalClean) return void 0;
|
|
85811
|
+
const refineTerminalKind = opts.terminalKind;
|
|
85812
|
+
const refineCode = typeof result.code === "string" ? result.code : "";
|
|
85813
|
+
const code = typeof result.code === "string" ? result.code : refineTerminalKind;
|
|
85814
|
+
const stage = refineTerminalKind === "validation_failed" ? "validation" : refineTerminalKind === "submodule_reachability_failed" ? "submodule_reachability" : refineCode === "patch_equivalence_failed" ? "patch_equivalence" : refineCode === "needs_rebase" || refineCode === "needs_rebase_with_conflicts" ? "patch_equivalence" : refineCode === "worktree_dirty" || refineCode === "rebase_precondition_failed" || refineCode === "rebase_failed" ? "patch_equivalence" : refineTerminalKind === "merge_failed" ? "merge" : refineTerminalKind === "cleanup_failed" ? "cleanup" : refineTerminalKind === "completed_with_warnings" ? refineCode === "post_merge_submodule_alignment_failed" ? "submodule_alignment" : "cleanup" : "unknown";
|
|
85815
|
+
const ctx = { stage, reason: code, terminalKind: refineTerminalKind };
|
|
85816
|
+
if (typeof result.error === "string") ctx.error = result.error;
|
|
85817
|
+
if (typeof result.blockedReason === "string") ctx.blockedReason = result.blockedReason;
|
|
85818
|
+
if (typeof result.detailedReason === "string") ctx.detailedReason = result.detailedReason;
|
|
85819
|
+
if (typeof result.detailedReasonDescription === "string") ctx.detailedReasonDescription = result.detailedReasonDescription;
|
|
85820
|
+
if (typeof result.recommendedAction === "string") ctx.recommendedAction = result.recommendedAction;
|
|
85821
|
+
if (result.evidence && typeof result.evidence === "object") ctx.evidence = result.evidence;
|
|
85822
|
+
if (typeof result.rebaseStderr === "string") ctx.rebaseStderr = result.rebaseStderr;
|
|
85823
|
+
if (typeof result.rebaseFailureDetail === "string") ctx.rebaseFailureDetail = result.rebaseFailureDetail;
|
|
85824
|
+
if (typeof result.rebaseConflict === "boolean") ctx.rebaseConflict = result.rebaseConflict;
|
|
85825
|
+
if (stage === "patch_equivalence" && result.patchEquivalence) {
|
|
85826
|
+
const pe = result.patchEquivalence;
|
|
85827
|
+
ctx.details = {
|
|
85828
|
+
expectedPatchId: pe.expectedPatchId,
|
|
85829
|
+
actualPatchId: pe.actualPatchId,
|
|
85830
|
+
status: pe.status,
|
|
85831
|
+
actionableHint: pe.actionableHint,
|
|
85832
|
+
error: pe.error,
|
|
85833
|
+
...typeof result.detailedReason === "string" ? { detailedReason: result.detailedReason } : {},
|
|
85834
|
+
...typeof result.recommendedAction === "string" ? { recommendedAction: result.recommendedAction } : {},
|
|
85835
|
+
...result.evidence && typeof result.evidence === "object" ? { evidence: result.evidence } : {}
|
|
85836
|
+
};
|
|
85837
|
+
}
|
|
85838
|
+
if (stage === "submodule_reachability" && Array.isArray(result.unreachableSubmoduleCommits)) {
|
|
85839
|
+
ctx.details = {
|
|
85840
|
+
unreachableCount: result.unreachableSubmoduleCommits.length,
|
|
85841
|
+
paths: result.unreachableSubmoduleCommits.map((e) => e.path),
|
|
85842
|
+
autoPublishAllowed: result.unreachableSubmoduleCommits[0]?.autoPublishAllowed
|
|
85843
|
+
};
|
|
85844
|
+
}
|
|
85845
|
+
if (stage === "validation" && result.validationSummary) {
|
|
85846
|
+
const vs = result.validationSummary;
|
|
85847
|
+
const diagnostics = opts.extractValidationDiagnostics?.(vs);
|
|
85848
|
+
ctx.details = {
|
|
85849
|
+
failureCode: vs.failureCode,
|
|
85850
|
+
failureKind: vs.failureKind,
|
|
85851
|
+
commandsRun: Array.isArray(vs.commandsRun) ? vs.commandsRun.length : void 0,
|
|
85852
|
+
...diagnostics ? { failure: diagnostics } : {}
|
|
85853
|
+
};
|
|
85854
|
+
}
|
|
85855
|
+
return ctx;
|
|
85856
|
+
}
|
|
85857
|
+
var init_mesh_refine_landing = __esm2({
|
|
85858
|
+
"src/mesh/mesh-refine-landing.ts"() {
|
|
85859
|
+
"use strict";
|
|
85659
85860
|
}
|
|
85660
85861
|
});
|
|
85661
85862
|
function findOpenRefineDispatchForNode(args) {
|
|
@@ -85946,28 +86147,28 @@ ${excerpt}` : "\n--- git output ---\n(none captured)");
|
|
|
85946
86147
|
"use strict";
|
|
85947
86148
|
}
|
|
85948
86149
|
});
|
|
85949
|
-
async function hasOriginRemote(
|
|
86150
|
+
async function hasOriginRemote(execFileAsync8, repoRoot, env2) {
|
|
85950
86151
|
try {
|
|
85951
|
-
const { stdout } = await
|
|
86152
|
+
const { stdout } = await execFileAsync8("git", ["remote", "get-url", "origin"], { cwd: repoRoot, encoding: "utf8", env: env2 });
|
|
85952
86153
|
return !!stdout.trim();
|
|
85953
86154
|
} catch {
|
|
85954
86155
|
return false;
|
|
85955
86156
|
}
|
|
85956
86157
|
}
|
|
85957
86158
|
async function probeRefineBaseCas(params) {
|
|
85958
|
-
const { execFileAsync:
|
|
85959
|
-
if (!await hasOriginRemote(
|
|
86159
|
+
const { execFileAsync: execFileAsync8, repoRoot, baseBranch, pinnedBaseHead, branchHead, env: env2 } = params;
|
|
86160
|
+
if (!await hasOriginRemote(execFileAsync8, repoRoot, env2)) {
|
|
85960
86161
|
return { state: "no_origin" };
|
|
85961
86162
|
}
|
|
85962
86163
|
try {
|
|
85963
|
-
await
|
|
86164
|
+
await execFileAsync8("git", ["fetch", "origin", baseBranch], { cwd: repoRoot, encoding: "utf8", env: env2 });
|
|
85964
86165
|
} catch (e) {
|
|
85965
86166
|
const fetchError = e?.message || String(e);
|
|
85966
86167
|
return { state: "undeterminable", reason: `git fetch origin ${baseBranch} failed: ${fetchError}`, fetchError };
|
|
85967
86168
|
}
|
|
85968
86169
|
let liveBaseHead;
|
|
85969
86170
|
try {
|
|
85970
|
-
const { stdout } = await
|
|
86171
|
+
const { stdout } = await execFileAsync8("git", ["rev-parse", `origin/${baseBranch}`], { cwd: repoRoot, encoding: "utf8", env: env2 });
|
|
85971
86172
|
liveBaseHead = stdout.trim();
|
|
85972
86173
|
} catch (e) {
|
|
85973
86174
|
return { state: "undeterminable", reason: `git rev-parse origin/${baseBranch} failed: ${e?.message || String(e)}` };
|
|
@@ -85978,23 +86179,23 @@ ${excerpt}` : "\n--- git output ---\n(none captured)");
|
|
|
85978
86179
|
if (liveBaseHead !== pinnedBaseHead) {
|
|
85979
86180
|
return { state: "moved", liveBaseHead };
|
|
85980
86181
|
}
|
|
85981
|
-
const localBaseHead = branchHead ? await resolveLocalBaseHead(
|
|
85982
|
-
if (localBaseHead && branchHead && localBaseHead !== pinnedBaseHead && await isAncestor2(
|
|
86182
|
+
const localBaseHead = branchHead ? await resolveLocalBaseHead(execFileAsync8, repoRoot, env2) : void 0;
|
|
86183
|
+
if (localBaseHead && branchHead && localBaseHead !== pinnedBaseHead && await isAncestor2(execFileAsync8, repoRoot, pinnedBaseHead, localBaseHead, env2) && !await isAncestor2(execFileAsync8, repoRoot, localBaseHead, branchHead, env2) && !await isAncestor2(execFileAsync8, repoRoot, branchHead, localBaseHead, env2)) {
|
|
85983
86184
|
return { state: "moved", liveBaseHead, localBaseHead };
|
|
85984
86185
|
}
|
|
85985
86186
|
return { state: "unmoved", liveBaseHead };
|
|
85986
86187
|
}
|
|
85987
|
-
async function resolveLocalBaseHead(
|
|
86188
|
+
async function resolveLocalBaseHead(execFileAsync8, repoRoot, env2) {
|
|
85988
86189
|
try {
|
|
85989
|
-
const { stdout } = await
|
|
86190
|
+
const { stdout } = await execFileAsync8("git", ["rev-parse", "HEAD"], { cwd: repoRoot, encoding: "utf8", env: env2 });
|
|
85990
86191
|
return stdout.trim() || void 0;
|
|
85991
86192
|
} catch {
|
|
85992
86193
|
return void 0;
|
|
85993
86194
|
}
|
|
85994
86195
|
}
|
|
85995
|
-
async function isAncestor2(
|
|
86196
|
+
async function isAncestor2(execFileAsync8, repoRoot, maybeAncestor, descendant, env2) {
|
|
85996
86197
|
try {
|
|
85997
|
-
await
|
|
86198
|
+
await execFileAsync8("git", ["merge-base", "--is-ancestor", maybeAncestor, descendant], { cwd: repoRoot, encoding: "utf8", env: env2 });
|
|
85998
86199
|
return true;
|
|
85999
86200
|
} catch {
|
|
86000
86201
|
return false;
|
|
@@ -86632,30 +86833,30 @@ ${excerpt}` : "\n--- git output ---\n(none captured)");
|
|
|
86632
86833
|
const sourceNode = node.clonedFromNodeId ? mesh?.nodes.find((n) => meshNodeIdMatches(n, node.clonedFromNodeId)) : mesh?.nodes.find((n) => !n.isLocalWorktree);
|
|
86633
86834
|
const repoRoot = sourceNode?.repoRoot || sourceNode?.workspace;
|
|
86634
86835
|
if (!repoRoot) return { kind: "terminal", result: { success: false, error: "Source node repoRoot not found", refineStages } };
|
|
86635
|
-
const { execFile:
|
|
86636
|
-
const { promisify:
|
|
86637
|
-
const
|
|
86836
|
+
const { execFile: execFile9 } = await import("child_process");
|
|
86837
|
+
const { promisify: promisify12 } = await import("util");
|
|
86838
|
+
const execFileAsync8 = promisify12(execFile9);
|
|
86638
86839
|
const resolveStarted = Date.now();
|
|
86639
|
-
const { stdout: branchStdout } = await
|
|
86840
|
+
const { stdout: branchStdout } = await execFileAsync8("git", ["branch", "--show-current"], { cwd: node.workspace, encoding: "utf8", env: gitChildEnv() });
|
|
86640
86841
|
const branch = branchStdout.trim();
|
|
86641
86842
|
if (!branch) return { kind: "terminal", result: { success: false, error: "Could not determine branch of the worktree node", refineStages } };
|
|
86642
|
-
const { stdout: baseBranchStdout } = await
|
|
86843
|
+
const { stdout: baseBranchStdout } = await execFileAsync8("git", ["branch", "--show-current"], { cwd: repoRoot, encoding: "utf8", env: gitChildEnv() });
|
|
86643
86844
|
const baseBranch = baseBranchStdout.trim();
|
|
86644
86845
|
let fetchWarning;
|
|
86645
86846
|
try {
|
|
86646
|
-
await
|
|
86847
|
+
await execFileAsync8("git", ["fetch", "origin", baseBranch], { cwd: repoRoot, encoding: "utf8", env: gitChildEnv() });
|
|
86647
86848
|
} catch (e) {
|
|
86648
86849
|
fetchWarning = `git fetch origin ${baseBranch} failed (proceeding with local HEAD): ${e?.message}`;
|
|
86649
86850
|
}
|
|
86650
86851
|
let baseHeadRaw;
|
|
86651
86852
|
try {
|
|
86652
|
-
const { stdout } = await
|
|
86853
|
+
const { stdout } = await execFileAsync8("git", ["rev-parse", `origin/${baseBranch}`], { cwd: repoRoot, encoding: "utf8", env: gitChildEnv() });
|
|
86653
86854
|
baseHeadRaw = stdout.trim();
|
|
86654
86855
|
} catch {
|
|
86655
|
-
const { stdout: localHead } = await
|
|
86856
|
+
const { stdout: localHead } = await execFileAsync8("git", ["rev-parse", "HEAD"], { cwd: repoRoot, encoding: "utf8", env: gitChildEnv() });
|
|
86656
86857
|
baseHeadRaw = localHead.trim();
|
|
86657
86858
|
}
|
|
86658
|
-
const { stdout: branchHeadStdout } = await
|
|
86859
|
+
const { stdout: branchHeadStdout } = await execFileAsync8("git", ["rev-parse", branch], { cwd: node.workspace, encoding: "utf8", env: gitChildEnv() });
|
|
86659
86860
|
const baseHead = baseHeadRaw;
|
|
86660
86861
|
const branchHead = branchHeadStdout.trim();
|
|
86661
86862
|
let changeImpact;
|
|
@@ -86679,7 +86880,7 @@ ${excerpt}` : "\n--- git output ---\n(none captured)");
|
|
|
86679
86880
|
nodeId,
|
|
86680
86881
|
args,
|
|
86681
86882
|
refineStages,
|
|
86682
|
-
execFileAsync:
|
|
86883
|
+
execFileAsync: execFileAsync8,
|
|
86683
86884
|
mesh,
|
|
86684
86885
|
node,
|
|
86685
86886
|
sourceNode,
|
|
@@ -86695,17 +86896,17 @@ ${excerpt}` : "\n--- git output ---\n(none captured)");
|
|
|
86695
86896
|
}
|
|
86696
86897
|
};
|
|
86697
86898
|
}
|
|
86698
|
-
async function computeBranchBaseDivergence(
|
|
86899
|
+
async function computeBranchBaseDivergence(execFileAsync8, cwd, baseHead, branchHead) {
|
|
86699
86900
|
let mergeBase;
|
|
86700
86901
|
try {
|
|
86701
|
-
const { stdout } = await
|
|
86902
|
+
const { stdout } = await execFileAsync8("git", ["merge-base", baseHead, branchHead], { cwd, encoding: "utf8", env: gitChildEnv() });
|
|
86702
86903
|
mergeBase = stdout.trim() || void 0;
|
|
86703
86904
|
} catch {
|
|
86704
86905
|
}
|
|
86705
86906
|
let ahead = 0;
|
|
86706
86907
|
let behind = 0;
|
|
86707
86908
|
try {
|
|
86708
|
-
const { stdout } = await
|
|
86909
|
+
const { stdout } = await execFileAsync8("git", ["rev-list", "--left-right", "--count", `${baseHead}...${branchHead}`], { cwd, encoding: "utf8", env: gitChildEnv() });
|
|
86709
86910
|
const [left, right] = stdout.trim().split(/\s+/).map((n) => Number.parseInt(n, 10));
|
|
86710
86911
|
behind = Number.isFinite(left) ? left : 0;
|
|
86711
86912
|
ahead = Number.isFinite(right) ? right : 0;
|
|
@@ -86722,11 +86923,11 @@ ${excerpt}` : "\n--- git output ---\n(none captured)");
|
|
|
86722
86923
|
};
|
|
86723
86924
|
}
|
|
86724
86925
|
async function refineSyncBaseStage(self, ctx) {
|
|
86725
|
-
const { repoRoot, baseHead, node, branch, baseBranch, refineStages, execFileAsync:
|
|
86926
|
+
const { repoRoot, baseHead, node, branch, baseBranch, refineStages, execFileAsync: execFileAsync8 } = ctx;
|
|
86726
86927
|
let branchHead = ctx.branchHead;
|
|
86727
86928
|
let gitlinkResolutions = [];
|
|
86728
86929
|
const syncStarted = Date.now();
|
|
86729
|
-
const divergence = await computeBranchBaseDivergence(
|
|
86930
|
+
const divergence = await computeBranchBaseDivergence(execFileAsync8, node.workspace, baseHead, branchHead);
|
|
86730
86931
|
if (divergence.behind === 0) {
|
|
86731
86932
|
recordMeshRefineStage(refineStages, "sync_base", "passed", syncStarted, {
|
|
86732
86933
|
ahead: divergence.ahead,
|
|
@@ -86820,12 +87021,12 @@ ${excerpt}` : "\n--- git output ---\n(none captured)");
|
|
|
86820
87021
|
throw err;
|
|
86821
87022
|
}
|
|
86822
87023
|
} else {
|
|
86823
|
-
(0,
|
|
87024
|
+
(0, import_node_child_process16.execFileSync)("git", ["rebase", baseHead], { cwd: node.workspace, stdio: ["ignore", "pipe", "pipe"] });
|
|
86824
87025
|
}
|
|
86825
87026
|
} catch (rebaseErr) {
|
|
86826
87027
|
if (!rebaseErr?.alreadyAborted) {
|
|
86827
87028
|
try {
|
|
86828
|
-
(0,
|
|
87029
|
+
(0, import_node_child_process16.execFileSync)("git", ["rebase", "--abort"], { cwd: node.workspace, stdio: "ignore" });
|
|
86829
87030
|
} catch {
|
|
86830
87031
|
}
|
|
86831
87032
|
}
|
|
@@ -86930,7 +87131,7 @@ ${excerpt}` : "\n--- git output ---\n(none captured)");
|
|
|
86930
87131
|
}
|
|
86931
87132
|
} };
|
|
86932
87133
|
}
|
|
86933
|
-
const { stdout: rebasedHeadStdout } = await
|
|
87134
|
+
const { stdout: rebasedHeadStdout } = await execFileAsync8("git", ["rev-parse", "HEAD"], { cwd: node.workspace, encoding: "utf8", env: gitChildEnv() });
|
|
86934
87135
|
branchHead = rebasedHeadStdout.trim();
|
|
86935
87136
|
ctx.branchHead = branchHead;
|
|
86936
87137
|
let changeImpact = ctx.changeImpact;
|
|
@@ -87360,7 +87561,7 @@ ${hintLines.join("\n")}` : "",
|
|
|
87360
87561
|
}
|
|
87361
87562
|
}
|
|
87362
87563
|
async function refineMergeAndFinalizeStage(self, ctx) {
|
|
87363
|
-
const { meshId, nodeId, args, repoRoot, baseHead, node, branch, baseBranch, sourceNode, validationSummary, patchEquivalence, submoduleReachability, mesh, refineStages, execFileAsync:
|
|
87564
|
+
const { meshId, nodeId, args, repoRoot, baseHead, node, branch, baseBranch, sourceNode, validationSummary, patchEquivalence, submoduleReachability, mesh, refineStages, execFileAsync: execFileAsync8 } = ctx;
|
|
87364
87565
|
const leaseKey = `${repoRoot}::${baseBranch}`;
|
|
87365
87566
|
const leaseHolder = buildRefineJobKey(self, meshId, nodeId);
|
|
87366
87567
|
const alreadyHeld = self.refineBaseLeases.get(leaseKey) === leaseHolder;
|
|
@@ -87399,10 +87600,10 @@ ${hintLines.join("\n")}` : "",
|
|
|
87399
87600
|
}
|
|
87400
87601
|
}
|
|
87401
87602
|
async function runRefineMergeAndFinalizeLocked(self, ctx) {
|
|
87402
|
-
const { meshId, nodeId, args, repoRoot, baseHead, node, branch, baseBranch, sourceNode, validationSummary, patchEquivalence, submoduleReachability, mesh, refineStages, execFileAsync:
|
|
87603
|
+
const { meshId, nodeId, args, repoRoot, baseHead, node, branch, baseBranch, sourceNode, validationSummary, patchEquivalence, submoduleReachability, mesh, refineStages, execFileAsync: execFileAsync8 } = ctx;
|
|
87403
87604
|
const casStarted = Date.now();
|
|
87404
87605
|
const cas = await probeRefineBaseCas({
|
|
87405
|
-
execFileAsync:
|
|
87606
|
+
execFileAsync: execFileAsync8,
|
|
87406
87607
|
repoRoot,
|
|
87407
87608
|
baseBranch,
|
|
87408
87609
|
pinnedBaseHead: baseHead,
|
|
@@ -87426,7 +87627,7 @@ ${hintLines.join("\n")}` : "",
|
|
|
87426
87627
|
let mergeResult;
|
|
87427
87628
|
const mergeStarted = Date.now();
|
|
87428
87629
|
try {
|
|
87429
|
-
const result = await
|
|
87630
|
+
const result = await execFileAsync8("git", ["merge", "--no-ff", branch, "-m", `Auto-merge branch '${branch}' via Refinery`], { cwd: repoRoot, encoding: "utf8", env: gitChildEnv() });
|
|
87430
87631
|
mergeResult = {
|
|
87431
87632
|
stdout: truncateValidationOutput(result.stdout),
|
|
87432
87633
|
stderr: truncateValidationOutput(result.stderr),
|
|
@@ -87438,7 +87639,7 @@ ${hintLines.join("\n")}` : "",
|
|
|
87438
87639
|
${e?.stderr || ""}`;
|
|
87439
87640
|
const conflictPaths = [...mergeOutput.matchAll(/Merge conflict in (.+)/g)].map((m) => m[1].trim()).filter(Boolean);
|
|
87440
87641
|
try {
|
|
87441
|
-
await
|
|
87642
|
+
await execFileAsync8("git", ["merge", "--abort"], { cwd: repoRoot, encoding: "utf8", env: gitChildEnv() });
|
|
87442
87643
|
} catch {
|
|
87443
87644
|
}
|
|
87444
87645
|
recordMeshRefineStage(refineStages, "merge", "failed", mergeStarted, {
|
|
@@ -87521,7 +87722,7 @@ ${e?.stderr || ""}`;
|
|
|
87521
87722
|
if (!requireApprovalForPush) {
|
|
87522
87723
|
const pushStarted = Date.now();
|
|
87523
87724
|
try {
|
|
87524
|
-
await
|
|
87725
|
+
await execFileAsync8("git", ["push", "origin", baseBranch], { cwd: repoRoot, encoding: "utf8", env: gitChildEnv() });
|
|
87525
87726
|
pushResult = { pushed: true, remote: "origin", branch: baseBranch, durationMs: Date.now() - pushStarted };
|
|
87526
87727
|
recordMeshRefineStage(refineStages, "push", "passed", pushStarted, pushResult);
|
|
87527
87728
|
} catch (e) {
|
|
@@ -87765,9 +87966,9 @@ ${e?.stderr || ""}`;
|
|
|
87765
87966
|
if (targetNodes.length === 0) {
|
|
87766
87967
|
return { success: true, batch: true, dryRun: args?.dryRun !== false, nodeCount: 0, order: [], results: [], note: "No convergeable local worktree nodes found." };
|
|
87767
87968
|
}
|
|
87768
|
-
const { execFile:
|
|
87769
|
-
const { promisify:
|
|
87770
|
-
const
|
|
87969
|
+
const { execFile: execFile9 } = await import("child_process");
|
|
87970
|
+
const { promisify: promisify12 } = await import("util");
|
|
87971
|
+
const execFileAsync8 = promisify12(execFile9);
|
|
87771
87972
|
const resolveRepoRootFor = (node) => {
|
|
87772
87973
|
const sourceNode = node.clonedFromNodeId ? allNodes.find((n) => meshNodeIdMatches(n, node.clonedFromNodeId)) : allNodes.find((n) => !n.isLocalWorktree);
|
|
87773
87974
|
return sourceNode?.repoRoot || sourceNode?.workspace;
|
|
@@ -87779,21 +87980,21 @@ ${e?.stderr || ""}`;
|
|
|
87779
87980
|
if (cached5) return cached5;
|
|
87780
87981
|
let baseBranch = "main";
|
|
87781
87982
|
try {
|
|
87782
|
-
const { stdout } = await
|
|
87983
|
+
const { stdout } = await execFileAsync8("git", ["branch", "--show-current"], { cwd: repoRoot, encoding: "utf8", env: gitChildEnv() });
|
|
87783
87984
|
if (stdout.trim()) baseBranch = stdout.trim();
|
|
87784
87985
|
} catch {
|
|
87785
87986
|
}
|
|
87786
87987
|
let baseRef = "HEAD";
|
|
87787
87988
|
try {
|
|
87788
|
-
await
|
|
87989
|
+
await execFileAsync8("git", ["fetch", "origin", baseBranch], { cwd: repoRoot, encoding: "utf8", env: gitChildEnv() });
|
|
87789
87990
|
} catch {
|
|
87790
87991
|
}
|
|
87791
87992
|
try {
|
|
87792
|
-
const { stdout } = await
|
|
87993
|
+
const { stdout } = await execFileAsync8("git", ["rev-parse", `origin/${baseBranch}`], { cwd: repoRoot, encoding: "utf8", env: gitChildEnv() });
|
|
87793
87994
|
baseRef = stdout.trim();
|
|
87794
87995
|
} catch {
|
|
87795
87996
|
try {
|
|
87796
|
-
const { stdout } = await
|
|
87997
|
+
const { stdout } = await execFileAsync8("git", ["rev-parse", "HEAD"], { cwd: repoRoot, encoding: "utf8", env: gitChildEnv() });
|
|
87797
87998
|
baseRef = stdout.trim();
|
|
87798
87999
|
} catch {
|
|
87799
88000
|
}
|
|
@@ -87806,7 +88007,7 @@ ${e?.stderr || ""}`;
|
|
|
87806
88007
|
const repoRoot = resolveRepoRootFor(node);
|
|
87807
88008
|
let branch = typeof node.worktreeBranch === "string" ? node.worktreeBranch : "";
|
|
87808
88009
|
try {
|
|
87809
|
-
const { stdout } = await
|
|
88010
|
+
const { stdout } = await execFileAsync8("git", ["branch", "--show-current"], { cwd: node.workspace, encoding: "utf8", env: gitChildEnv() });
|
|
87810
88011
|
if (stdout.trim()) branch = stdout.trim();
|
|
87811
88012
|
} catch {
|
|
87812
88013
|
}
|
|
@@ -87827,7 +88028,7 @@ ${e?.stderr || ""}`;
|
|
|
87827
88028
|
if (!submodulePathsByRepoRoot.has(repoRoot)) {
|
|
87828
88029
|
let subPaths = /* @__PURE__ */ new Set();
|
|
87829
88030
|
try {
|
|
87830
|
-
const { stdout } = await
|
|
88031
|
+
const { stdout } = await execFileAsync8("git", ["config", "--file", ".gitmodules", "--get-regexp", "path"], { cwd: repoRoot, encoding: "utf8", env: gitChildEnv() });
|
|
87831
88032
|
for (const line of stdout.split("\n")) {
|
|
87832
88033
|
const trimmed = line.trim();
|
|
87833
88034
|
const spaceIdx = trimmed.indexOf(" ");
|
|
@@ -87843,7 +88044,7 @@ ${e?.stderr || ""}`;
|
|
|
87843
88044
|
const baseRef = await resolveBaseRef(repoRoot);
|
|
87844
88045
|
let branchRef = branch;
|
|
87845
88046
|
try {
|
|
87846
|
-
const { stdout } = await
|
|
88047
|
+
const { stdout } = await execFileAsync8("git", ["rev-parse", branch], { cwd: node.workspace, encoding: "utf8", env: gitChildEnv() });
|
|
87847
88048
|
branchRef = stdout.trim() || branch;
|
|
87848
88049
|
} catch {
|
|
87849
88050
|
}
|
|
@@ -87861,22 +88062,7 @@ ${e?.stderr || ""}`;
|
|
|
87861
88062
|
const orderedNodes = ordering.order.map((nodeId) => targetNodes.find((n) => meshNodeIdMatches(n, nodeId))).filter((n) => !!n);
|
|
87862
88063
|
const dryRun = args?.dryRun !== false && args?.execute !== true;
|
|
87863
88064
|
if (dryRun) {
|
|
87864
|
-
return {
|
|
87865
|
-
success: true,
|
|
87866
|
-
batch: true,
|
|
87867
|
-
dryRun: true,
|
|
87868
|
-
nodeCount: orderedNodes.length,
|
|
87869
|
-
order: ordering.order,
|
|
87870
|
-
orderingRationale: ordering.rationale,
|
|
87871
|
-
changeAreas: ordering.changeAreas,
|
|
87872
|
-
plan: orderedNodes.map((node) => ({
|
|
87873
|
-
nodeId: node.id,
|
|
87874
|
-
workspace: node.workspace,
|
|
87875
|
-
validationPlan: buildMeshRefineValidationPlan(mesh, node.workspace),
|
|
87876
|
-
mergeWillRun: false
|
|
87877
|
-
})),
|
|
87878
|
-
note: "Dry-run: no validation, rebase, or merge was executed. Re-run with execute=true to converge nodes in this order."
|
|
87879
|
-
};
|
|
88065
|
+
return buildMeshRefineBatchDryRunResult({ mesh, orderedNodes, ordering });
|
|
87880
88066
|
}
|
|
87881
88067
|
return runMeshRefineBatchConvergence(self, meshId, orderedNodes, ordering, args);
|
|
87882
88068
|
}
|
|
@@ -87951,7 +88137,9 @@ ${e?.stderr || ""}`;
|
|
|
87951
88137
|
allConverged,
|
|
87952
88138
|
results,
|
|
87953
88139
|
...allConverged ? {} : {
|
|
87954
|
-
|
|
88140
|
+
// Name the failed nodes inline — the aggregate nextStep used to hide
|
|
88141
|
+
// WHICH nodes blocked, forcing a manual git-log cross-check.
|
|
88142
|
+
nextStep: `Resolve blocked_review / not_mergeable nodes manually \u2014 failed: ${results.filter((r) => r.convergence === "blocked_review" || r.convergence === "not_mergeable").map((r) => `${r.nodeId}${r.code ? ` [${r.code}]` : ""}`).join(", ")} (see per-node code/stage/error), then re-run mesh_refine_batch for the remaining nodes.`
|
|
87955
88143
|
}
|
|
87956
88144
|
};
|
|
87957
88145
|
}
|
|
@@ -88263,7 +88451,7 @@ ${e?.stderr || ""}`;
|
|
|
88263
88451
|
if (!repoRoot || !workspace) return;
|
|
88264
88452
|
const branch = typeof node?.worktreeBranch === "string" && node.worktreeBranch.trim() ? node.worktreeBranch.trim() : (() => {
|
|
88265
88453
|
try {
|
|
88266
|
-
return (0,
|
|
88454
|
+
return (0, import_node_child_process16.execFileSync)("git", ["branch", "--show-current"], { cwd: workspace, encoding: "utf8" }).trim();
|
|
88267
88455
|
} catch {
|
|
88268
88456
|
return "";
|
|
88269
88457
|
}
|
|
@@ -88271,7 +88459,7 @@ ${e?.stderr || ""}`;
|
|
|
88271
88459
|
if (!branch) return;
|
|
88272
88460
|
const baseBranch = (() => {
|
|
88273
88461
|
try {
|
|
88274
|
-
return (0,
|
|
88462
|
+
return (0, import_node_child_process16.execFileSync)("git", ["branch", "--show-current"], { cwd: repoRoot, encoding: "utf8" }).trim() || "main";
|
|
88275
88463
|
} catch {
|
|
88276
88464
|
return "main";
|
|
88277
88465
|
}
|
|
@@ -88339,13 +88527,13 @@ ${e?.stderr || ""}`;
|
|
|
88339
88527
|
});
|
|
88340
88528
|
return handle;
|
|
88341
88529
|
}
|
|
88342
|
-
var
|
|
88530
|
+
var import_node_child_process16;
|
|
88343
88531
|
var import_node_fs9;
|
|
88344
88532
|
var RETRYABLE_BASE_MOVEMENT_CODES;
|
|
88345
88533
|
var init_router_refine = __esm2({
|
|
88346
88534
|
"src/commands/router-refine.ts"() {
|
|
88347
88535
|
"use strict";
|
|
88348
|
-
|
|
88536
|
+
import_node_child_process16 = require("child_process");
|
|
88349
88537
|
import_node_fs9 = require("fs");
|
|
88350
88538
|
init_logger();
|
|
88351
88539
|
init_debug_trace();
|
|
@@ -88354,6 +88542,7 @@ ${e?.stderr || ""}`;
|
|
|
88354
88542
|
init_mesh_reconcile_identity();
|
|
88355
88543
|
init_mesh_fast_forward();
|
|
88356
88544
|
init_mesh_refine_batch();
|
|
88545
|
+
init_mesh_refine_submodule_preflight();
|
|
88357
88546
|
init_mesh_refine_base_divergence();
|
|
88358
88547
|
init_mesh_refine_inflight();
|
|
88359
88548
|
init_mesh_refine_inflight();
|
|
@@ -125027,8 +125216,8 @@ ${formatManifestValidationIssues2(validation2.issues)}`);
|
|
|
125027
125216
|
let submodulesInitialized2 = false;
|
|
125028
125217
|
if (initSubmodules) {
|
|
125029
125218
|
try {
|
|
125030
|
-
const { runGit:
|
|
125031
|
-
await
|
|
125219
|
+
const { runGit: runGit4 } = await Promise.resolve().then(() => (init_git_executor(), git_executor_exports));
|
|
125220
|
+
await runGit4(
|
|
125032
125221
|
{ workspace: result.worktreePath, repoRoot: result.worktreePath, isGitRepo: true },
|
|
125033
125222
|
["submodule", "update", "--init", "--recursive"],
|
|
125034
125223
|
{ timeoutMs: 12e4 }
|
|
@@ -125591,6 +125780,7 @@ ${formatManifestValidationIssues2(validation2.issues)}`);
|
|
|
125591
125780
|
init_dist();
|
|
125592
125781
|
init_mesh_fast_forward();
|
|
125593
125782
|
init_cli_detector();
|
|
125783
|
+
init_mesh_refine_submodule_preflight();
|
|
125594
125784
|
var fastForwardHandlers = {
|
|
125595
125785
|
mesh_init: async (ctx, args) => {
|
|
125596
125786
|
const workspace = typeof args?.workspace === "string" && args.workspace.trim() ? args.workspace.trim() : process.cwd();
|
|
@@ -125613,6 +125803,7 @@ ${formatManifestValidationIssues2(validation2.issues)}`);
|
|
|
125613
125803
|
const mesh = meshRecord?.mesh;
|
|
125614
125804
|
const node = mesh?.nodes?.find((n) => meshNodeIdMatches(n, nodeId));
|
|
125615
125805
|
if (!node?.workspace) return { success: false, error: `Node '${nodeId}' workspace not found` };
|
|
125806
|
+
const submoduleReachabilityPreflight = await planMeshRefineNodeSubmodulePreflight({ mesh, node }).catch(() => void 0);
|
|
125616
125807
|
return {
|
|
125617
125808
|
success: true,
|
|
125618
125809
|
dryRun: true,
|
|
@@ -125620,7 +125811,8 @@ ${formatManifestValidationIssues2(validation2.issues)}`);
|
|
|
125620
125811
|
workspace: node.workspace,
|
|
125621
125812
|
validationPlan: buildMeshRefineValidationPlan(mesh, node.workspace),
|
|
125622
125813
|
mergeWillRun: false,
|
|
125623
|
-
cleanupWillRun: false
|
|
125814
|
+
cleanupWillRun: false,
|
|
125815
|
+
...submoduleReachabilityPreflight ? { submoduleReachabilityPreflight } : {}
|
|
125624
125816
|
};
|
|
125625
125817
|
},
|
|
125626
125818
|
fast_forward_mesh_node: async (ctx, args) => {
|
|
@@ -125717,6 +125909,7 @@ ${formatManifestValidationIssues2(validation2.issues)}`);
|
|
|
125717
125909
|
const mesh = meshRecord?.mesh;
|
|
125718
125910
|
const node = mesh?.nodes?.find((n) => meshNodeIdMatches(n, nodeId));
|
|
125719
125911
|
if (!node?.workspace) return { success: false, error: `Node '${nodeId}' workspace not found` };
|
|
125912
|
+
const submoduleReachabilityPreflight = await planMeshRefineNodeSubmodulePreflight({ mesh, node }).catch(() => void 0);
|
|
125720
125913
|
return {
|
|
125721
125914
|
success: true,
|
|
125722
125915
|
dryRun: true,
|
|
@@ -125725,6 +125918,7 @@ ${formatManifestValidationIssues2(validation2.issues)}`);
|
|
|
125725
125918
|
validationPlan: buildMeshRefineValidationPlan(mesh, node.workspace),
|
|
125726
125919
|
mergeWillRun: false,
|
|
125727
125920
|
cleanupWillRun: false,
|
|
125921
|
+
...submoduleReachabilityPreflight ? { submoduleReachabilityPreflight } : {},
|
|
125728
125922
|
hint: "Dry-run only \u2014 no merge/push/cleanup performed. Re-invoke with execute:true to converge this node."
|
|
125729
125923
|
};
|
|
125730
125924
|
}
|
|
@@ -126324,8 +126518,8 @@ ${formatManifestValidationIssues2(validation2.issues)}`);
|
|
|
126324
126518
|
}
|
|
126325
126519
|
}
|
|
126326
126520
|
};
|
|
126327
|
-
var
|
|
126328
|
-
var
|
|
126521
|
+
var import_path20 = require("path");
|
|
126522
|
+
var fs53 = __toESM2(require("fs"));
|
|
126329
126523
|
init_logger();
|
|
126330
126524
|
init_mesh_host_ownership();
|
|
126331
126525
|
init_coordinator_registry();
|
|
@@ -126365,9 +126559,9 @@ ${formatManifestValidationIssues2(validation2.issues)}`);
|
|
|
126365
126559
|
}
|
|
126366
126560
|
}
|
|
126367
126561
|
function isWorkspaceLocalPath(configPath, workspace) {
|
|
126368
|
-
const resolvedConfig = (0,
|
|
126369
|
-
const resolvedWorkspace = (0,
|
|
126370
|
-
return resolvedConfig === resolvedWorkspace || resolvedConfig.startsWith(resolvedWorkspace +
|
|
126562
|
+
const resolvedConfig = (0, import_path20.resolve)(configPath);
|
|
126563
|
+
const resolvedWorkspace = (0, import_path20.resolve)(workspace);
|
|
126564
|
+
return resolvedConfig === resolvedWorkspace || resolvedConfig.startsWith(resolvedWorkspace + import_path20.sep);
|
|
126371
126565
|
}
|
|
126372
126566
|
var meshCoordinatorLaunchHandlers = {
|
|
126373
126567
|
launch_mesh_coordinator: async (ctx, args) => {
|
|
@@ -126629,16 +126823,16 @@ ${ptyResult.output.slice(-2e3)}`);
|
|
|
126629
126823
|
};
|
|
126630
126824
|
}
|
|
126631
126825
|
if (cliType === "codex-cli") {
|
|
126632
|
-
const repoMcpConfigPath = (0,
|
|
126633
|
-
if (
|
|
126826
|
+
const repoMcpConfigPath = (0, import_path20.join)(workspace, ".mcp.json");
|
|
126827
|
+
if (fs53.existsSync(repoMcpConfigPath)) {
|
|
126634
126828
|
try {
|
|
126635
126829
|
const repoMcpConfig = parseMeshCoordinatorMcpConfig(
|
|
126636
|
-
|
|
126830
|
+
fs53.readFileSync(repoMcpConfigPath, "utf-8"),
|
|
126637
126831
|
"claude_mcp_json"
|
|
126638
126832
|
);
|
|
126639
126833
|
const existingServers2 = repoMcpConfig.mcpServers;
|
|
126640
126834
|
if (existingServers2 && typeof existingServers2 === "object" && !Array.isArray(existingServers2) && existingServers2[coordinatorSetup.serverName]) {
|
|
126641
|
-
|
|
126835
|
+
fs53.writeFileSync(repoMcpConfigPath, serializeMeshCoordinatorMcpConfig({
|
|
126642
126836
|
...repoMcpConfig,
|
|
126643
126837
|
mcpServers: {
|
|
126644
126838
|
...existingServers2,
|
|
@@ -127009,7 +127203,7 @@ ${ptyResult.output.slice(-2e3)}`);
|
|
|
127009
127203
|
}
|
|
127010
127204
|
}
|
|
127011
127205
|
};
|
|
127012
|
-
var
|
|
127206
|
+
var fs54 = __toESM2(require("fs"));
|
|
127013
127207
|
var import_os4 = require("os");
|
|
127014
127208
|
init_config();
|
|
127015
127209
|
init_git_status();
|
|
@@ -127018,7 +127212,7 @@ ${ptyResult.output.slice(-2e3)}`);
|
|
|
127018
127212
|
init_mesh_turn_presentation();
|
|
127019
127213
|
init_mesh_routing();
|
|
127020
127214
|
init_mesh_host_ownership();
|
|
127021
|
-
var
|
|
127215
|
+
var import_node_child_process13 = require("child_process");
|
|
127022
127216
|
var import_node_fs6 = require("fs");
|
|
127023
127217
|
init_git_locale();
|
|
127024
127218
|
var import_node_path4 = require("path");
|
|
@@ -127043,9 +127237,9 @@ ${ptyResult.output.slice(-2e3)}`);
|
|
|
127043
127237
|
if (PREVIEW_PIPELINE_SCRIPTS.some((rel) => (0, import_node_fs6.existsSync)((0, import_node_path4.resolve)(repoRoot, rel)))) return true;
|
|
127044
127238
|
return hasDeployPreviewNpmScript(repoRoot);
|
|
127045
127239
|
}
|
|
127046
|
-
function
|
|
127240
|
+
function runGit3(repoRoot, args) {
|
|
127047
127241
|
try {
|
|
127048
|
-
return (0,
|
|
127242
|
+
return (0, import_node_child_process13.execFileSync)("git", args, {
|
|
127049
127243
|
cwd: repoRoot,
|
|
127050
127244
|
encoding: "utf8",
|
|
127051
127245
|
stdio: ["ignore", "pipe", "ignore"],
|
|
@@ -127084,11 +127278,11 @@ ${ptyResult.output.slice(-2e3)}`);
|
|
|
127084
127278
|
return result;
|
|
127085
127279
|
}
|
|
127086
127280
|
function readCurrentMainCommit(repoRoot) {
|
|
127087
|
-
const originMain =
|
|
127281
|
+
const originMain = runGit3(repoRoot, ["rev-parse", "--verify", "origin/main^{commit}"]);
|
|
127088
127282
|
if (originMain) {
|
|
127089
127283
|
return { currentMainCommit: originMain, currentMainCommitSource: "origin/main" };
|
|
127090
127284
|
}
|
|
127091
|
-
const head =
|
|
127285
|
+
const head = runGit3(repoRoot, ["rev-parse", "--verify", "HEAD"]);
|
|
127092
127286
|
if (head) {
|
|
127093
127287
|
return { currentMainCommit: head, currentMainCommitSource: "HEAD" };
|
|
127094
127288
|
}
|
|
@@ -127392,7 +127586,7 @@ ${ptyResult.output.slice(-2e3)}`);
|
|
|
127392
127586
|
}
|
|
127393
127587
|
}
|
|
127394
127588
|
if (workspace) {
|
|
127395
|
-
if (!
|
|
127589
|
+
if (!fs54.existsSync(workspace)) {
|
|
127396
127590
|
const inlineTransitGit = buildInlineMeshTransitGitStatus(node);
|
|
127397
127591
|
let remoteProbeApplied = false;
|
|
127398
127592
|
if (inlineTransitGit) {
|
|
@@ -127533,7 +127727,7 @@ ${ptyResult.output.slice(-2e3)}`);
|
|
|
127533
127727
|
const pendingRetentionCounters2 = { ...getPendingRetentionCounters() };
|
|
127534
127728
|
const turnPresentationCounters = getTurnPresentationMetrics();
|
|
127535
127729
|
const previewFreshness = (() => {
|
|
127536
|
-
const localRepoRoot = nodeStatuses.map((node) => readStringValue(node?.git?.repoRoot, node?.repoRoot, node?.workspace)).find((candidate) => !!candidate &&
|
|
127730
|
+
const localRepoRoot = nodeStatuses.map((node) => readStringValue(node?.git?.repoRoot, node?.repoRoot, node?.workspace)).find((candidate) => !!candidate && fs54.existsSync(candidate));
|
|
127537
127731
|
return localRepoRoot ? buildPreviewFreshness(localRepoRoot) : void 0;
|
|
127538
127732
|
})();
|
|
127539
127733
|
const asyncRefineJobs = buildMeshAsyncRefineJobs({
|
|
@@ -127731,7 +127925,7 @@ ${ptyResult.output.slice(-2e3)}`);
|
|
|
127731
127925
|
);
|
|
127732
127926
|
init_dist();
|
|
127733
127927
|
init_logger();
|
|
127734
|
-
var
|
|
127928
|
+
var fs55 = __toESM2(require("fs"));
|
|
127735
127929
|
var path56 = __toESM2(require("path"));
|
|
127736
127930
|
init_config_dir();
|
|
127737
127931
|
var MAX_FILE_SIZE = 5 * 1024 * 1024;
|
|
@@ -127780,7 +127974,7 @@ ${ptyResult.output.slice(-2e3)}`);
|
|
|
127780
127974
|
currentFile = path56.join(dir, `commands-${today}.jsonl`);
|
|
127781
127975
|
if (dirChanged) {
|
|
127782
127976
|
try {
|
|
127783
|
-
|
|
127977
|
+
fs55.mkdirSync(dir, { recursive: true });
|
|
127784
127978
|
} catch {
|
|
127785
127979
|
}
|
|
127786
127980
|
cleanOldFiles();
|
|
@@ -127788,7 +127982,7 @@ ${ptyResult.output.slice(-2e3)}`);
|
|
|
127788
127982
|
}
|
|
127789
127983
|
function cleanOldFiles() {
|
|
127790
127984
|
try {
|
|
127791
|
-
const files =
|
|
127985
|
+
const files = fs55.readdirSync(currentDir).filter((f) => f.startsWith("commands-") && f.endsWith(".jsonl"));
|
|
127792
127986
|
const cutoff = /* @__PURE__ */ new Date();
|
|
127793
127987
|
cutoff.setDate(cutoff.getDate() - MAX_DAYS);
|
|
127794
127988
|
const cutoffStr = cutoff.toISOString().slice(0, 10);
|
|
@@ -127796,7 +127990,7 @@ ${ptyResult.output.slice(-2e3)}`);
|
|
|
127796
127990
|
const dateMatch = file2.match(/commands-(\d{4}-\d{2}-\d{2})/);
|
|
127797
127991
|
if (dateMatch && dateMatch[1] < cutoffStr) {
|
|
127798
127992
|
try {
|
|
127799
|
-
|
|
127993
|
+
fs55.unlinkSync(path56.join(currentDir, file2));
|
|
127800
127994
|
} catch {
|
|
127801
127995
|
}
|
|
127802
127996
|
}
|
|
@@ -127806,14 +128000,14 @@ ${ptyResult.output.slice(-2e3)}`);
|
|
|
127806
128000
|
}
|
|
127807
128001
|
function checkSize() {
|
|
127808
128002
|
try {
|
|
127809
|
-
const stat2 =
|
|
128003
|
+
const stat2 = fs55.statSync(currentFile);
|
|
127810
128004
|
if (stat2.size > MAX_FILE_SIZE) {
|
|
127811
128005
|
const backup = currentFile.replace(".jsonl", ".1.jsonl");
|
|
127812
128006
|
try {
|
|
127813
|
-
|
|
128007
|
+
fs55.unlinkSync(backup);
|
|
127814
128008
|
} catch {
|
|
127815
128009
|
}
|
|
127816
|
-
|
|
128010
|
+
fs55.renameSync(currentFile, backup);
|
|
127817
128011
|
}
|
|
127818
128012
|
} catch {
|
|
127819
128013
|
}
|
|
@@ -127846,15 +128040,15 @@ ${ptyResult.output.slice(-2e3)}`);
|
|
|
127846
128040
|
...entry.error ? { err: entry.error } : {},
|
|
127847
128041
|
...entry.durationMs !== void 0 ? { ms: entry.durationMs } : {}
|
|
127848
128042
|
});
|
|
127849
|
-
|
|
128043
|
+
fs55.appendFileSync(currentFile, line + "\n");
|
|
127850
128044
|
} catch {
|
|
127851
128045
|
}
|
|
127852
128046
|
}
|
|
127853
128047
|
function getRecentCommands(count = 50) {
|
|
127854
128048
|
try {
|
|
127855
128049
|
refreshCurrentFile();
|
|
127856
|
-
if (!
|
|
127857
|
-
const content =
|
|
128050
|
+
if (!fs55.existsSync(currentFile)) return [];
|
|
128051
|
+
const content = fs55.readFileSync(currentFile, "utf-8");
|
|
127858
128052
|
const lines = content.trim().split("\n").filter(Boolean);
|
|
127859
128053
|
return lines.slice(-count).map((line) => {
|
|
127860
128054
|
try {
|
|
@@ -127886,7 +128080,7 @@ ${ptyResult.output.slice(-2e3)}`);
|
|
|
127886
128080
|
init_router_refine();
|
|
127887
128081
|
var fs56 = __toESM2(require("fs"));
|
|
127888
128082
|
var import_node_os22 = require("os");
|
|
127889
|
-
var
|
|
128083
|
+
var import_path21 = require("path");
|
|
127890
128084
|
init_logger();
|
|
127891
128085
|
init_git_locale();
|
|
127892
128086
|
init_dist();
|
|
@@ -127898,7 +128092,7 @@ ${ptyResult.output.slice(-2e3)}`);
|
|
|
127898
128092
|
function acceptableManagedWorktreePaths(resolveWorktreePath2, normalizePath2, repoRoot, meshName, branch, worktreeBaseDir) {
|
|
127899
128093
|
const safeBranch = branch.replace(/[/\\:*?"<>|]/g, "-").replace(/^\.+|\.+$/g, "");
|
|
127900
128094
|
const safeMeshName = meshName.replace(/[/\\:*?"<>|]/g, "-").replace(/^\.+|\.+$/g, "");
|
|
127901
|
-
const legacyPath = (0,
|
|
128095
|
+
const legacyPath = (0, import_path21.join)((0, import_path21.dirname)(repoRoot), LEGACY_WORKTREE_DIR_NAME, safeMeshName, safeBranch);
|
|
127902
128096
|
const candidates = [
|
|
127903
128097
|
resolveWorktreePath2(repoRoot, meshName, branch, worktreeBaseDir),
|
|
127904
128098
|
legacyPath
|
|
@@ -127925,8 +128119,8 @@ ${ptyResult.output.slice(-2e3)}`);
|
|
|
127925
128119
|
function looksLikeCrossTrackWorktreePath(actualPath, normalizePath2) {
|
|
127926
128120
|
const home = normalizePath2((0, import_node_os22.homedir)());
|
|
127927
128121
|
return TRACK_CONFIG_DIR_NAMES.some((trackDirName) => {
|
|
127928
|
-
const trackWorktreesDir = (0,
|
|
127929
|
-
return actualPath === normalizePath2(trackWorktreesDir) || actualPath.startsWith(normalizePath2(trackWorktreesDir) +
|
|
128122
|
+
const trackWorktreesDir = (0, import_path21.join)(home, trackDirName, "worktrees");
|
|
128123
|
+
return actualPath === normalizePath2(trackWorktreesDir) || actualPath.startsWith(normalizePath2(trackWorktreesDir) + import_path21.sep);
|
|
127930
128124
|
});
|
|
127931
128125
|
}
|
|
127932
128126
|
function unexpectedPathRecoveryHint(actualPath, normalizePath2, suffix) {
|
|
@@ -127953,11 +128147,11 @@ ${ptyResult.output.slice(-2e3)}`);
|
|
|
127953
128147
|
}
|
|
127954
128148
|
async function hasUnpushedWorktreeCommits(workspace) {
|
|
127955
128149
|
try {
|
|
127956
|
-
const { execFile:
|
|
127957
|
-
const { promisify:
|
|
127958
|
-
const
|
|
128150
|
+
const { execFile: execFile9 } = await import("child_process");
|
|
128151
|
+
const { promisify: promisify12 } = await import("util");
|
|
128152
|
+
const execFileAsync8 = promisify12(execFile9);
|
|
127959
128153
|
const git3 = async (gitArgs) => {
|
|
127960
|
-
const { stdout } = await
|
|
128154
|
+
const { stdout } = await execFileAsync8("git", gitArgs, {
|
|
127961
128155
|
cwd: workspace,
|
|
127962
128156
|
encoding: "utf8",
|
|
127963
128157
|
timeout: 3e4,
|
|
@@ -128036,7 +128230,7 @@ ${ptyResult.output.slice(-2e3)}`);
|
|
|
128036
128230
|
}
|
|
128037
128231
|
const { resolveWorktreePath: resolveWorktreePath2, listWorktrees: listWorktrees2 } = await Promise.resolve().then(() => (init_git_worktree(), git_worktree_exports));
|
|
128038
128232
|
const normalizePath2 = (value) => {
|
|
128039
|
-
const resolved = (0,
|
|
128233
|
+
const resolved = (0, import_path21.resolve)(value);
|
|
128040
128234
|
try {
|
|
128041
128235
|
return fs56.realpathSync(resolved);
|
|
128042
128236
|
} catch {
|
|
@@ -128092,11 +128286,11 @@ ${ptyResult.output.slice(-2e3)}`);
|
|
|
128092
128286
|
}
|
|
128093
128287
|
}
|
|
128094
128288
|
if (args.force !== true) {
|
|
128095
|
-
const { execFile:
|
|
128096
|
-
const { promisify:
|
|
128097
|
-
const
|
|
128289
|
+
const { execFile: execFile9 } = await import("child_process");
|
|
128290
|
+
const { promisify: promisify12 } = await import("util");
|
|
128291
|
+
const execFileAsync8 = promisify12(execFile9);
|
|
128098
128292
|
try {
|
|
128099
|
-
const { stdout } = await
|
|
128293
|
+
const { stdout } = await execFileAsync8("git", ["status", "--porcelain"], {
|
|
128100
128294
|
cwd: workspace,
|
|
128101
128295
|
encoding: "utf8",
|
|
128102
128296
|
timeout: 3e4,
|
|
@@ -128163,7 +128357,7 @@ ${ptyResult.output.slice(-2e3)}`);
|
|
|
128163
128357
|
}
|
|
128164
128358
|
const { resolveWorktreePath: resolveWorktreePath2, listWorktrees: listWorktrees2, removeWorktree: removeWorktree2 } = await Promise.resolve().then(() => (init_git_worktree(), git_worktree_exports));
|
|
128165
128359
|
const normalizePath2 = (value) => {
|
|
128166
|
-
const resolved = (0,
|
|
128360
|
+
const resolved = (0, import_path21.resolve)(value);
|
|
128167
128361
|
try {
|
|
128168
128362
|
return fs56.realpathSync(resolved);
|
|
128169
128363
|
} catch {
|
|
@@ -128192,10 +128386,10 @@ ${ptyResult.output.slice(-2e3)}`);
|
|
|
128192
128386
|
const managedEntry = entries.find((entry) => normalizePath2(entry.path) === actualPath);
|
|
128193
128387
|
if (!managedEntry) {
|
|
128194
128388
|
try {
|
|
128195
|
-
const { execFile:
|
|
128196
|
-
const { promisify:
|
|
128197
|
-
const
|
|
128198
|
-
await
|
|
128389
|
+
const { execFile: execFile9 } = await import("child_process");
|
|
128390
|
+
const { promisify: promisify12 } = await import("util");
|
|
128391
|
+
const execFileAsync8 = promisify12(execFile9);
|
|
128392
|
+
await execFileAsync8("git", ["worktree", "prune"], {
|
|
128199
128393
|
cwd: repoRoot,
|
|
128200
128394
|
encoding: "utf8",
|
|
128201
128395
|
timeout: 3e4,
|
|
@@ -128284,15 +128478,15 @@ ${ptyResult.output.slice(-2e3)}`);
|
|
|
128284
128478
|
const isSubmoduleGuard = /working trees containing submodules cannot be moved or removed/i.test(message);
|
|
128285
128479
|
const submoduleForceBlocked = isSubmoduleGuard && !forceFallbackConvergence.allow;
|
|
128286
128480
|
if (forceFallbackConvergence.allow && !dirty) {
|
|
128287
|
-
const { execFile:
|
|
128288
|
-
const { promisify:
|
|
128289
|
-
const
|
|
128481
|
+
const { execFile: execFile9 } = await import("child_process");
|
|
128482
|
+
const { promisify: promisify12 } = await import("util");
|
|
128483
|
+
const execFileAsync8 = promisify12(execFile9);
|
|
128290
128484
|
const GIT_TIMEOUT_CLEANUP = 3e4;
|
|
128291
128485
|
const GIT_MAX_BUFFER_CLEANUP = 4 * 1024 * 1024;
|
|
128292
128486
|
const fallbackReason = isSubmoduleGuard ? "working_trees_containing_submodules" : "worktree_remove_failed";
|
|
128293
128487
|
try {
|
|
128294
128488
|
if (isSubmoduleGuard) {
|
|
128295
|
-
await
|
|
128489
|
+
await execFileAsync8("git", ["-C", workspace, "submodule", "deinit", "--all", "-f"], {
|
|
128296
128490
|
encoding: "utf8",
|
|
128297
128491
|
timeout: GIT_TIMEOUT_CLEANUP,
|
|
128298
128492
|
maxBuffer: GIT_MAX_BUFFER_CLEANUP,
|
|
@@ -128300,7 +128494,7 @@ ${ptyResult.output.slice(-2e3)}`);
|
|
|
128300
128494
|
env: gitChildEnv()
|
|
128301
128495
|
});
|
|
128302
128496
|
}
|
|
128303
|
-
await
|
|
128497
|
+
await execFileAsync8("git", ["worktree", "remove", "--force", workspace], {
|
|
128304
128498
|
cwd: repoRoot,
|
|
128305
128499
|
encoding: "utf8",
|
|
128306
128500
|
timeout: GIT_TIMEOUT_CLEANUP,
|
|
@@ -128322,7 +128516,7 @@ ${ptyResult.output.slice(-2e3)}`);
|
|
|
128322
128516
|
} catch (deinitError) {
|
|
128323
128517
|
const rm = await self.bestEffortRemoveWorktreeDir(workspace);
|
|
128324
128518
|
try {
|
|
128325
|
-
await
|
|
128519
|
+
await execFileAsync8("git", ["worktree", "prune"], {
|
|
128326
128520
|
cwd: repoRoot,
|
|
128327
128521
|
encoding: "utf8",
|
|
128328
128522
|
timeout: GIT_TIMEOUT_CLEANUP,
|
|
@@ -128368,11 +128562,11 @@ ${ptyResult.output.slice(-2e3)}`);
|
|
|
128368
128562
|
if (refinedConvergence === "merged_pushed" || refinedConvergence === "merged_to_main") {
|
|
128369
128563
|
return { allow: true, status: refinedConvergence, source: "node_refine_state" };
|
|
128370
128564
|
}
|
|
128371
|
-
const { execFile:
|
|
128372
|
-
const { promisify:
|
|
128373
|
-
const
|
|
128374
|
-
const
|
|
128375
|
-
const { stdout } = await
|
|
128565
|
+
const { execFile: execFile9 } = await import("child_process");
|
|
128566
|
+
const { promisify: promisify12 } = await import("util");
|
|
128567
|
+
const execFileAsync8 = promisify12(execFile9);
|
|
128568
|
+
const runGit4 = async (gitArgs, cwd) => {
|
|
128569
|
+
const { stdout } = await execFileAsync8("git", gitArgs, {
|
|
128376
128570
|
cwd,
|
|
128377
128571
|
encoding: "utf8",
|
|
128378
128572
|
timeout: 3e4,
|
|
@@ -128393,7 +128587,7 @@ ${ptyResult.output.slice(-2e3)}`);
|
|
|
128393
128587
|
return { allow: false, error: "worktree path is missing and worktreeBranch metadata is absent, so the branch tip cannot be resolved" };
|
|
128394
128588
|
}
|
|
128395
128589
|
try {
|
|
128396
|
-
head = await
|
|
128590
|
+
head = await runGit4(["rev-parse", "--verify", `${branch}^{commit}`], args.repoRoot);
|
|
128397
128591
|
} catch {
|
|
128398
128592
|
return { allow: true, status: "worktree_and_branch_absent", source: "git_branch_absent" };
|
|
128399
128593
|
}
|
|
@@ -128402,7 +128596,7 @@ ${ptyResult.output.slice(-2e3)}`);
|
|
|
128402
128596
|
}
|
|
128403
128597
|
} else {
|
|
128404
128598
|
try {
|
|
128405
|
-
head = await
|
|
128599
|
+
head = await runGit4(["rev-parse", "HEAD"], args.workspace);
|
|
128406
128600
|
} catch (e) {
|
|
128407
128601
|
return { allow: false, error: `could not resolve worktree HEAD: ${e?.message || e}` };
|
|
128408
128602
|
}
|
|
@@ -128410,7 +128604,7 @@ ${ptyResult.output.slice(-2e3)}`);
|
|
|
128410
128604
|
}
|
|
128411
128605
|
const candidateRefs = [];
|
|
128412
128606
|
try {
|
|
128413
|
-
const defaultBranch = await
|
|
128607
|
+
const defaultBranch = await runGit4(["branch", "--show-current"], args.repoRoot);
|
|
128414
128608
|
if (defaultBranch) {
|
|
128415
128609
|
candidateRefs.push(defaultBranch, `origin/${defaultBranch}`);
|
|
128416
128610
|
}
|
|
@@ -128425,14 +128619,14 @@ ${ptyResult.output.slice(-2e3)}`);
|
|
|
128425
128619
|
seen.add(ref);
|
|
128426
128620
|
let commit = "";
|
|
128427
128621
|
try {
|
|
128428
|
-
commit = await
|
|
128622
|
+
commit = await runGit4(["rev-parse", "--verify", `${ref}^{commit}`], args.repoRoot);
|
|
128429
128623
|
} catch {
|
|
128430
128624
|
continue;
|
|
128431
128625
|
}
|
|
128432
128626
|
checkedRefs.push(ref);
|
|
128433
128627
|
resolvedRefCommits.push({ ref, commit });
|
|
128434
128628
|
try {
|
|
128435
|
-
await
|
|
128629
|
+
await runGit4(["merge-base", "--is-ancestor", head, commit], args.repoRoot);
|
|
128436
128630
|
return { allow: true, status: "merged_to_default_ref", source: "git_merge_base", ref };
|
|
128437
128631
|
} catch {
|
|
128438
128632
|
}
|
|
@@ -128831,7 +129025,7 @@ ${ptyResult.output.slice(-2e3)}`);
|
|
|
128831
129025
|
init_logger();
|
|
128832
129026
|
var yaml5 = __toESM2(require_js_yaml());
|
|
128833
129027
|
var import_os5 = require("os");
|
|
128834
|
-
var
|
|
129028
|
+
var import_path222 = require("path");
|
|
128835
129029
|
var fs57 = __toESM2(require("fs"));
|
|
128836
129030
|
var MESH_COORDINATOR_AUTO_IMPORT_FORMATS = ["claude_mcp_json", "hermes_config_yaml", "opencode_json"];
|
|
128837
129031
|
function isSupportedMeshCoordinatorConfigFormat(format) {
|
|
@@ -128872,13 +129066,13 @@ ${ptyResult.output.slice(-2e3)}`);
|
|
|
128872
129066
|
}
|
|
128873
129067
|
function resolveHermesUserHome() {
|
|
128874
129068
|
const explicitHome = process.env.HERMES_HOME?.trim();
|
|
128875
|
-
return explicitHome || (0,
|
|
129069
|
+
return explicitHome || (0, import_path222.join)((0, import_os5.homedir)(), ".hermes");
|
|
128876
129070
|
}
|
|
128877
129071
|
function loadHermesCoordinatorBaseConfig(targetConfigPath) {
|
|
128878
129072
|
const sourceHome = resolveHermesUserHome();
|
|
128879
|
-
const sourceConfigPath = (0,
|
|
129073
|
+
const sourceConfigPath = (0, import_path222.join)(sourceHome, "config.yaml");
|
|
128880
129074
|
if (!fs57.existsSync(sourceConfigPath)) return { config: {}, sourceHome, sourceConfigPath };
|
|
128881
|
-
if ((0,
|
|
129075
|
+
if ((0, import_path222.resolve)(sourceConfigPath) === (0, import_path222.resolve)(targetConfigPath)) return { config: {}, sourceHome, sourceConfigPath };
|
|
128882
129076
|
const parsed = parseMeshCoordinatorMcpConfig(fs57.readFileSync(sourceConfigPath, "utf-8"), "hermes_config_yaml");
|
|
128883
129077
|
const { mcp_servers: _mcpServers, ...baseConfig } = parsed;
|
|
128884
129078
|
return { config: baseConfig, sourceHome, sourceConfigPath };
|
|
@@ -128912,10 +129106,10 @@ ${ptyResult.output.slice(-2e3)}`);
|
|
|
128912
129106
|
return sanitized;
|
|
128913
129107
|
}
|
|
128914
129108
|
function copyHermesCoordinatorCredentialFiles(sourceHome, targetHome) {
|
|
128915
|
-
if ((0,
|
|
129109
|
+
if ((0, import_path222.resolve)(sourceHome) === (0, import_path222.resolve)(targetHome)) return;
|
|
128916
129110
|
for (const fileName of [".env", "auth.json"]) {
|
|
128917
|
-
const sourcePath = (0,
|
|
128918
|
-
const targetPath = (0,
|
|
129111
|
+
const sourcePath = (0, import_path222.join)(sourceHome, fileName);
|
|
129112
|
+
const targetPath = (0, import_path222.join)(targetHome, fileName);
|
|
128919
129113
|
if (!fs57.existsSync(sourcePath)) continue;
|
|
128920
129114
|
try {
|
|
128921
129115
|
fs57.copyFileSync(sourcePath, targetPath);
|
|
@@ -138296,7 +138490,7 @@ data: ${JSON.stringify(msg.data)}
|
|
|
138296
138490
|
init_mesh_events();
|
|
138297
138491
|
init_mesh_reconcile_loop();
|
|
138298
138492
|
var import_fs20 = require("fs");
|
|
138299
|
-
var
|
|
138493
|
+
var import_path23 = require("path");
|
|
138300
138494
|
var import_crypto18 = require("crypto");
|
|
138301
138495
|
init_logger();
|
|
138302
138496
|
init_mesh_ledger();
|
|
@@ -138374,7 +138568,7 @@ data: ${JSON.stringify(msg.data)}
|
|
|
138374
138568
|
}
|
|
138375
138569
|
for (const name of names) {
|
|
138376
138570
|
if (!isPendingEventsFile(name)) continue;
|
|
138377
|
-
const path63 = (0,
|
|
138571
|
+
const path63 = (0, import_path23.join)(dir, name);
|
|
138378
138572
|
result.filesScanned++;
|
|
138379
138573
|
const claimed = `${path63}.migrating`;
|
|
138380
138574
|
try {
|