@adhdev/daemon-standalone 1.0.56-rc.7 → 1.0.56-rc.9
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 +945 -653
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
- package/vendor/mcp-server/index.js +110 -0
- package/vendor/mcp-server/index.js.map +1 -1
package/dist/index.js
CHANGED
|
@@ -36620,10 +36620,10 @@ var require_dist3 = __commonJS({
|
|
|
36620
36620
|
}
|
|
36621
36621
|
function getDaemonBuildInfo() {
|
|
36622
36622
|
if (cached2) return cached2;
|
|
36623
|
-
const commit = readInjected(true ? "
|
|
36624
|
-
const commitShort = readInjected(true ? "
|
|
36625
|
-
const version2 = readInjected(true ? "1.0.56-rc.
|
|
36626
|
-
const builtAt = readInjected(true ? "2026-08-
|
|
36623
|
+
const commit = readInjected(true ? "346a82b2748c5a3d6ab32d126bbe7399d24d9a82" : void 0) ?? "unknown";
|
|
36624
|
+
const commitShort = readInjected(true ? "346a82b2" : void 0) ?? (commit !== "unknown" ? commit.slice(0, 7) : "unknown");
|
|
36625
|
+
const version2 = readInjected(true ? "1.0.56-rc.9" : void 0) ?? readInjected(typeof process !== "undefined" ? process.env?.ADHDEV_PKG_VERSION : void 0) ?? "unknown";
|
|
36626
|
+
const builtAt = readInjected(true ? "2026-08-19T22:46:34.487Z" : void 0);
|
|
36627
36627
|
cached2 = builtAt ? { commit, commitShort, version: version2, builtAt } : { commit, commitShort, version: version2 };
|
|
36628
36628
|
return cached2;
|
|
36629
36629
|
}
|
|
@@ -40952,11 +40952,11 @@ child.on('exit', () => process.exit(0));
|
|
|
40952
40952
|
}
|
|
40953
40953
|
function windowsExtraBinDirs() {
|
|
40954
40954
|
const dirs = [];
|
|
40955
|
-
const
|
|
40955
|
+
const fs61 = require("fs");
|
|
40956
40956
|
const push = (dir) => {
|
|
40957
40957
|
if (!dir) return;
|
|
40958
40958
|
try {
|
|
40959
|
-
if (
|
|
40959
|
+
if (fs61.existsSync(dir)) dirs.push(dir);
|
|
40960
40960
|
} catch {
|
|
40961
40961
|
}
|
|
40962
40962
|
};
|
|
@@ -40972,12 +40972,12 @@ child.on('exit', () => process.exit(0));
|
|
|
40972
40972
|
}
|
|
40973
40973
|
function unixExtraBinDirs() {
|
|
40974
40974
|
const dirs = [];
|
|
40975
|
-
const
|
|
40975
|
+
const fs61 = require("fs");
|
|
40976
40976
|
const home = os52.homedir();
|
|
40977
40977
|
const push = (dir) => {
|
|
40978
40978
|
if (!dir) return;
|
|
40979
40979
|
try {
|
|
40980
|
-
if (
|
|
40980
|
+
if (fs61.existsSync(dir)) dirs.push(dir);
|
|
40981
40981
|
} catch {
|
|
40982
40982
|
}
|
|
40983
40983
|
};
|
|
@@ -41016,9 +41016,9 @@ child.on('exit', () => process.exit(0));
|
|
|
41016
41016
|
for (const ext of exes) {
|
|
41017
41017
|
const fullPath = path9.join(p, trimmed + ext);
|
|
41018
41018
|
try {
|
|
41019
|
-
const
|
|
41020
|
-
if (
|
|
41021
|
-
const stat2 =
|
|
41019
|
+
const fs61 = require("fs");
|
|
41020
|
+
if (fs61.existsSync(fullPath)) {
|
|
41021
|
+
const stat2 = fs61.statSync(fullPath);
|
|
41022
41022
|
if (stat2.isFile() && (isWin || stat2.mode & 73)) {
|
|
41023
41023
|
return fullPath;
|
|
41024
41024
|
}
|
|
@@ -41032,12 +41032,12 @@ child.on('exit', () => process.exit(0));
|
|
|
41032
41032
|
function isScriptBinary(binaryPath) {
|
|
41033
41033
|
if (!path9.isAbsolute(binaryPath)) return false;
|
|
41034
41034
|
try {
|
|
41035
|
-
const
|
|
41036
|
-
const resolved =
|
|
41035
|
+
const fs61 = require("fs");
|
|
41036
|
+
const resolved = fs61.realpathSync(binaryPath);
|
|
41037
41037
|
const head = Buffer.alloc(8);
|
|
41038
|
-
const fd =
|
|
41039
|
-
|
|
41040
|
-
|
|
41038
|
+
const fd = fs61.openSync(resolved, "r");
|
|
41039
|
+
fs61.readSync(fd, head, 0, 8, 0);
|
|
41040
|
+
fs61.closeSync(fd);
|
|
41041
41041
|
let i = 0;
|
|
41042
41042
|
if (head[0] === 239 && head[1] === 187 && head[2] === 191) i = 3;
|
|
41043
41043
|
return head[i] === 35 && head[i + 1] === 33;
|
|
@@ -41048,12 +41048,12 @@ child.on('exit', () => process.exit(0));
|
|
|
41048
41048
|
function looksLikeMachOOrElf(filePath) {
|
|
41049
41049
|
if (!path9.isAbsolute(filePath)) return false;
|
|
41050
41050
|
try {
|
|
41051
|
-
const
|
|
41052
|
-
const resolved =
|
|
41051
|
+
const fs61 = require("fs");
|
|
41052
|
+
const resolved = fs61.realpathSync(filePath);
|
|
41053
41053
|
const buf = Buffer.alloc(8);
|
|
41054
|
-
const fd =
|
|
41055
|
-
|
|
41056
|
-
|
|
41054
|
+
const fd = fs61.openSync(resolved, "r");
|
|
41055
|
+
fs61.readSync(fd, buf, 0, 8, 0);
|
|
41056
|
+
fs61.closeSync(fd);
|
|
41057
41057
|
let i = 0;
|
|
41058
41058
|
if (buf[0] === 239 && buf[1] === 187 && buf[2] === 191) i = 3;
|
|
41059
41059
|
const b = buf.subarray(i);
|
|
@@ -42860,6 +42860,7 @@ ${error48.message || ""}`;
|
|
|
42860
42860
|
"mesh_graph_view",
|
|
42861
42861
|
"mesh_graph_gate_claim",
|
|
42862
42862
|
"mesh_graph_gate_release",
|
|
42863
|
+
"mesh_graph_gate_abandon",
|
|
42863
42864
|
"mesh_queue_cancel",
|
|
42864
42865
|
"mesh_queue_requeue",
|
|
42865
42866
|
"mesh_send_task",
|
|
@@ -47896,11 +47897,31 @@ ${blocks.join("\n\n")}`;
|
|
|
47896
47897
|
...alertReason ? [alertReason] : []
|
|
47897
47898
|
].join("::");
|
|
47898
47899
|
}
|
|
47900
|
+
function isDurablyDedupedEvent(event) {
|
|
47901
|
+
if (!TERMINAL_COMPLETION_EVENTS.has(event.event)) return false;
|
|
47902
|
+
const metadata = readRecord2(event.metadataEvent) || {};
|
|
47903
|
+
const taskId = readNonEmptyString(metadata.taskId) || readNonEmptyString(readRecord2(metadata.payload)?.taskId);
|
|
47904
|
+
return !!taskId;
|
|
47905
|
+
}
|
|
47906
|
+
function recordDurableTerminalDedup(event, fingerprint) {
|
|
47907
|
+
if (!isDurablyDedupedEvent(event)) return;
|
|
47908
|
+
try {
|
|
47909
|
+
const store = MeshRuntimeStore.getInstance();
|
|
47910
|
+
store.recordCompletionFingerprint(event.meshId, `pending::${fingerprint}`, TERMINAL_COMPLETION_DEDUP_TTL_MS);
|
|
47911
|
+
store.sweepExpiredFingerprints();
|
|
47912
|
+
} catch {
|
|
47913
|
+
}
|
|
47914
|
+
}
|
|
47899
47915
|
function hasPendingCoordinatorEventDuplicate(event) {
|
|
47900
47916
|
const fingerprint = buildPendingEventFingerprint(event);
|
|
47901
47917
|
if (!fingerprint.trim()) return false;
|
|
47902
47918
|
try {
|
|
47903
|
-
|
|
47919
|
+
const store = MeshRuntimeStore.getInstance();
|
|
47920
|
+
if (store.hasPendingEventFingerprint(event.meshId, fingerprint)) return true;
|
|
47921
|
+
if (isDurablyDedupedEvent(event) && store.hasCompletionFingerprint(event.meshId, `pending::${fingerprint}`)) {
|
|
47922
|
+
return true;
|
|
47923
|
+
}
|
|
47924
|
+
return false;
|
|
47904
47925
|
} catch {
|
|
47905
47926
|
return false;
|
|
47906
47927
|
}
|
|
@@ -48123,6 +48144,7 @@ ${blocks.join("\n\n")}`;
|
|
|
48123
48144
|
dispatchedBy: event.dispatchedBy ? JSON.stringify(event.dispatchedBy) : null,
|
|
48124
48145
|
intendedFor: event.intendedFor ? JSON.stringify(event.intendedFor) : null
|
|
48125
48146
|
});
|
|
48147
|
+
recordDurableTerminalDedup(event, fingerprint);
|
|
48126
48148
|
return true;
|
|
48127
48149
|
} catch (e) {
|
|
48128
48150
|
LOG2.error(
|
|
@@ -48343,6 +48365,7 @@ ${blocks.join("\n\n")}`;
|
|
|
48343
48365
|
var loggedSqlitePendingDrainFailure;
|
|
48344
48366
|
var TERMINAL_COMPLETION_EVENTS;
|
|
48345
48367
|
var COORDINATOR_ALERT_EVENTS_WITH_REASON_FINGERPRINT;
|
|
48368
|
+
var TERMINAL_COMPLETION_DEDUP_TTL_MS;
|
|
48346
48369
|
var PENDING_EVENTS_DRAINED_RETENTION_MS;
|
|
48347
48370
|
var PENDING_EVENTS_UNDRAINED_RETENTION_MS;
|
|
48348
48371
|
var PENDING_RETENTION_EXPIRED_HOLD_REASON;
|
|
@@ -48396,6 +48419,7 @@ ${blocks.join("\n\n")}`;
|
|
|
48396
48419
|
COORDINATOR_ALERT_EVENTS_WITH_REASON_FINGERPRINT = /* @__PURE__ */ new Set([
|
|
48397
48420
|
"mesh:dispatch_blocked"
|
|
48398
48421
|
]);
|
|
48422
|
+
TERMINAL_COMPLETION_DEDUP_TTL_MS = 60 * 60 * 1e3;
|
|
48399
48423
|
PENDING_EVENTS_DRAINED_RETENTION_MS = 7 * 24 * 60 * 60 * 1e3;
|
|
48400
48424
|
PENDING_EVENTS_UNDRAINED_RETENTION_MS = 30 * 24 * 60 * 60 * 1e3;
|
|
48401
48425
|
PENDING_RETENTION_EXPIRED_HOLD_REASON = "pending_retention_expired";
|
|
@@ -54861,7 +54885,11 @@ The instruction it carried was never delivered to anyone. If it still matters, r
|
|
|
54861
54885
|
}
|
|
54862
54886
|
/** Remove all pending-event rows (drained included) for a mesh — mesh deletion / test cleanup. */
|
|
54863
54887
|
clearPendingEventsForMesh(meshId) {
|
|
54864
|
-
|
|
54888
|
+
const changes = this.db.prepare("DELETE FROM mesh_pending_events WHERE mesh_id = ?").run(meshId).changes;
|
|
54889
|
+
this.db.prepare(
|
|
54890
|
+
`DELETE FROM mesh_completion_fingerprints WHERE mesh_id = ? AND fingerprint LIKE 'pending::%'`
|
|
54891
|
+
).run(meshId);
|
|
54892
|
+
return changes;
|
|
54865
54893
|
}
|
|
54866
54894
|
pendingEventCount(meshId) {
|
|
54867
54895
|
const row = this.db.prepare(
|
|
@@ -57169,6 +57197,7 @@ When you compose the task message you dispatch to a node, include this requireme
|
|
|
57169
57197
|
| \`mesh_graph_view\` | Inspect orchestration graphs \u2014 node states, gates awaiting you, workspace sagas, why something is blocked |
|
|
57170
57198
|
| \`mesh_graph_gate_claim\` | Take the lease on a gate awaiting a coordinator; returns the fencing token + generation a release needs |
|
|
57171
57199
|
| \`mesh_graph_gate_release\` | Pass a gate you hold \u2014 the ONLY way through one (no timeout ever passes a gate). **A gate and its dependents are one unit**: a gate earns its keep only when some task names it in \`gated_by\`, because releasing it is what dispatches that task. A gate nothing depends on opens nothing and is pure claim/release overhead \u2014 declare the follower in the same batch, or skip the gate |
|
|
57200
|
+
| \`mesh_graph_gate_abandon\` | Give up on a gate that can never be opened, so its graph can go terminal. **Not a pass**: it CANCELS everything the gate was holding and produces no gate outcome. Use it when you cancelled the work behind a gate \u2014 otherwise that gate stays awaiting forever and the graph reaches no terminal state, not even cancelled |
|
|
57172
57201
|
| \`mesh_queue_cancel\` | Cancel a queue task (audit history kept) |
|
|
57173
57202
|
| \`mesh_queue_requeue\` | Return a task to pending for retry |
|
|
57174
57203
|
| \`mesh_send_task\` | Push a task straight to a specific node/session |
|
|
@@ -57243,6 +57272,7 @@ Before doing any coordinator work, confirm that the actual callable tool list in
|
|
|
57243
57272
|
- **"The only thing I am sure of right now is this one task" is not evidence of a single.** That feeling is about your confidence, not about how many steps are settled; two steps are routinely settled at once while it still feels that way. Count the steps you would actually dispatch. If that count is two or more, it is a batch no matter how the plan feels.
|
|
57244
57273
|
- **"I cannot choose the next step until I see this result" states that the next step EXISTS.** What the result decides is *which branch you take*, not *whether* there is a follow-up \u2014 and a branch that turns on a predecessor's output is what \`run_if\` selects, what \`inputs_from\` feeds, and what a coordinator gate holds until you decide. Needing to look at evidence before choosing is the ordinary case for a graph edge, not an exception to it.
|
|
57245
57274
|
- **A gate or a batch is not overhead when something follows it.** The extra call buys the dispatch of everything behind it, so it costs one call and saves a whole round-trip through you. The only genuinely wasteful gate is one nothing depends on \u2014 a gate no task names in \`gated_by\` opens nothing when released, which the release response tells you about; that case is answered by declaring the follower, not by abandoning the batch.
|
|
57275
|
+
- **If you cancel the tasks behind a gate, close the gate too.** Cancelling a task never touches the gate that was holding it \u2014 gates are a separate control plane on purpose. A gate left over a cancelled branch stays \`awaiting_coordinator\` forever, and while ANY gate is unsettled its graph can reach no terminal state at all, not even \`cancelled\`. Close it with \`mesh_graph_gate_abandon\` and a reason. \`mesh_graph_view\` flags this case for you as a \`gate_abandon\` action. Abandon is not a shortcut through a gate: it cancels whatever the gate was holding and yields no gate outcome, so use \`mesh_graph_gate_release\` whenever you actually want the downstream work to run.
|
|
57246
57276
|
|
|
57247
57277
|
When you do use \`mesh_enqueue_task\`, pass \`orchestration_decision\` recording why a single was right (\`single_reason\`: \`only_one_step_known\` / \`future_step_not_specifiable\` / \`same_session_continuation\` / \`legacy_client\` / \`operator_override\`). Omitting it is recorded as \`decision_missing\`.
|
|
57248
57278
|
|
|
@@ -58803,8 +58833,8 @@ ${rendered}`, "utf-8");
|
|
|
58803
58833
|
if (!(0, import_node_fs3.existsSync)(filePath)) return;
|
|
58804
58834
|
if (owned) {
|
|
58805
58835
|
try {
|
|
58806
|
-
const
|
|
58807
|
-
|
|
58836
|
+
const fs61 = require("fs");
|
|
58837
|
+
fs61.unlinkSync(filePath);
|
|
58808
58838
|
} catch {
|
|
58809
58839
|
}
|
|
58810
58840
|
return;
|
|
@@ -58817,8 +58847,8 @@ ${rendered}`, "utf-8");
|
|
|
58817
58847
|
const remaining = (existing.slice(0, openIdx) + existing.slice(closeIdx + CLOSE.length)).replace(/^\s*\n+/, "").replace(/\n+\s*$/, "");
|
|
58818
58848
|
if (!remaining.trim()) {
|
|
58819
58849
|
try {
|
|
58820
|
-
const
|
|
58821
|
-
|
|
58850
|
+
const fs61 = require("fs");
|
|
58851
|
+
fs61.unlinkSync(filePath);
|
|
58822
58852
|
} catch {
|
|
58823
58853
|
}
|
|
58824
58854
|
} else {
|
|
@@ -60945,6 +60975,98 @@ ${rendered}`, "utf-8");
|
|
|
60945
60975
|
store.updateQueueEntry(entry);
|
|
60946
60976
|
}
|
|
60947
60977
|
}
|
|
60978
|
+
function coordinatorGateAbandonedReason(gateId) {
|
|
60979
|
+
return `coordinator_gate_abandoned:${gateId}`;
|
|
60980
|
+
}
|
|
60981
|
+
function abandonMeshGraphGate(input) {
|
|
60982
|
+
const store = MeshRuntimeStore.getInstance();
|
|
60983
|
+
const nowMs = input.nowMs ?? Date.now();
|
|
60984
|
+
const nowIso = new Date(nowMs).toISOString();
|
|
60985
|
+
const result = store.transaction(() => {
|
|
60986
|
+
const graphStore = store.graphStore();
|
|
60987
|
+
const gate = graphStore.getGate(input.gateId);
|
|
60988
|
+
if (!gate || gate.meshId !== input.meshId) {
|
|
60989
|
+
return { abandoned: false, reason: "gate_not_found", cancelledNodeIds: [], cancelledTaskIds: [] };
|
|
60990
|
+
}
|
|
60991
|
+
if (gate.state === "cancelled") {
|
|
60992
|
+
return { abandoned: true, reason: "gate_already_abandoned", gate, cancelledNodeIds: [], cancelledTaskIds: [] };
|
|
60993
|
+
}
|
|
60994
|
+
if (gate.state === "released") {
|
|
60995
|
+
return { abandoned: false, reason: `gate_terminal:${gate.state}`, gate, cancelledNodeIds: [], cancelledTaskIds: [] };
|
|
60996
|
+
}
|
|
60997
|
+
if (!input.force && gate.state === "claimed" && gate.leaseExpiresAt && gate.leaseExpiresAt > nowIso) {
|
|
60998
|
+
return { abandoned: false, reason: "gate_lease_held", gate, cancelledNodeIds: [], cancelledTaskIds: [] };
|
|
60999
|
+
}
|
|
61000
|
+
const abandonReason = `${coordinatorGateAbandonedReason(gate.gateId)}:${input.reason}`;
|
|
61001
|
+
const won = graphStore.patchGate(gate.gateId, {
|
|
61002
|
+
state: "cancelled",
|
|
61003
|
+
// Drop the lease: an abandoned gate has no owner and no live fence.
|
|
61004
|
+
leaseOwnerSessionId: null,
|
|
61005
|
+
fencingToken: null,
|
|
61006
|
+
leaseExpiresAt: null
|
|
61007
|
+
}, nowIso, { leaseGeneration: gate.leaseGeneration });
|
|
61008
|
+
if (!won) {
|
|
61009
|
+
return { abandoned: false, reason: "gate_abandon_race", gate, cancelledNodeIds: [], cancelledTaskIds: [] };
|
|
61010
|
+
}
|
|
61011
|
+
const node = graphStore.getNode(gate.graphId, gate.nodeId);
|
|
61012
|
+
if (node && node.state !== "cancelled") {
|
|
61013
|
+
graphStore.updateNodeState(gate.graphId, gate.nodeId, "cancelled", nowIso, { failureReason: abandonReason });
|
|
61014
|
+
}
|
|
61015
|
+
const cancelledNodeIds = node ? cancelGateDownstreamSubtree(store, node, nowIso, abandonReason) : [];
|
|
61016
|
+
const cancelledTaskIds = [];
|
|
61017
|
+
for (const nodeId of cancelledNodeIds) {
|
|
61018
|
+
const target = graphStore.getNode(gate.graphId, nodeId);
|
|
61019
|
+
if (target?.queueTaskId) cancelledTaskIds.push(target.queueTaskId);
|
|
61020
|
+
}
|
|
61021
|
+
const graph = graphStore.getGraph(gate.graphId);
|
|
61022
|
+
let graphStatus;
|
|
61023
|
+
const rolled = classifyGraphRollup(graphStore.listNodes(gate.graphId));
|
|
61024
|
+
if (graph && rolled && graph.status !== rolled) {
|
|
61025
|
+
graphStore.updateGraphStatus(gate.graphId, rolled, nowIso, true);
|
|
61026
|
+
graphStatus = rolled;
|
|
61027
|
+
insertGateOutbox(
|
|
61028
|
+
graphStore,
|
|
61029
|
+
gate.meshId,
|
|
61030
|
+
gate.graphId,
|
|
61031
|
+
rolled === "completed" ? "graph_completed" : rolled === "failed" ? "graph_failed" : "graph_cancelled",
|
|
61032
|
+
{ graphId: gate.graphId, status: rolled },
|
|
61033
|
+
nowIso
|
|
61034
|
+
);
|
|
61035
|
+
} else if (graph?.status === "waiting_gate") {
|
|
61036
|
+
const stillWaiting = graphStore.listGatesByGraph(gate.graphId).some((g) => g.gateId !== gate.gateId && (g.state === "awaiting_coordinator" || g.state === "claimed"));
|
|
61037
|
+
if (!stillWaiting) {
|
|
61038
|
+
graphStore.updateGraphStatus(gate.graphId, "active", nowIso);
|
|
61039
|
+
graphStatus = "active";
|
|
61040
|
+
}
|
|
61041
|
+
}
|
|
61042
|
+
insertGateOutbox(graphStore, gate.meshId, gate.graphId, "graph_gate_abandoned", {
|
|
61043
|
+
graphId: gate.graphId,
|
|
61044
|
+
gateId: gate.gateId,
|
|
61045
|
+
nodeId: gate.nodeId,
|
|
61046
|
+
ref: gate.ref,
|
|
61047
|
+
action: gate.action,
|
|
61048
|
+
priorState: gate.state,
|
|
61049
|
+
reason: input.reason,
|
|
61050
|
+
...input.coordinatorSessionId ? { coordinatorSessionId: input.coordinatorSessionId } : {},
|
|
61051
|
+
...input.force ? { force: true } : {},
|
|
61052
|
+
...cancelledNodeIds.length > 0 ? { cancelledNodeIds } : {}
|
|
61053
|
+
}, nowIso);
|
|
61054
|
+
return {
|
|
61055
|
+
abandoned: true,
|
|
61056
|
+
gate: graphStore.getGate(gate.gateId),
|
|
61057
|
+
cancelledNodeIds,
|
|
61058
|
+
cancelledTaskIds,
|
|
61059
|
+
...graphStatus ? { graphStatus } : {}
|
|
61060
|
+
};
|
|
61061
|
+
});
|
|
61062
|
+
if (result.abandoned) {
|
|
61063
|
+
try {
|
|
61064
|
+
drainMeshGraphOutbox(input.meshId);
|
|
61065
|
+
} catch {
|
|
61066
|
+
}
|
|
61067
|
+
}
|
|
61068
|
+
return result;
|
|
61069
|
+
}
|
|
60948
61070
|
function sweepMeshGraphGateTimeouts(meshId, nowMs) {
|
|
60949
61071
|
const store = MeshRuntimeStore.getInstance();
|
|
60950
61072
|
const now = nowMs ?? Date.now();
|
|
@@ -60997,7 +61119,7 @@ ${rendered}`, "utf-8");
|
|
|
60997
61119
|
function isCancelExempt(state) {
|
|
60998
61120
|
return state === "completed" || state === "released" || state === "skipped" || state === "cancelled" || state === "failed" || state === "expired";
|
|
60999
61121
|
}
|
|
61000
|
-
function cancelGateDownstreamSubtree(store, gateNode, nowIso) {
|
|
61122
|
+
function cancelGateDownstreamSubtree(store, gateNode, nowIso, reason = `coordinator_gate_timeout:${gateNode.nodeId}`) {
|
|
61001
61123
|
const graphStore = store.graphStore();
|
|
61002
61124
|
const nodes = graphStore.listNodes(gateNode.graphId);
|
|
61003
61125
|
const edges = graphStore.listEdges(gateNode.graphId);
|
|
@@ -61014,13 +61136,13 @@ ${rendered}`, "utf-8");
|
|
|
61014
61136
|
const target = byId.get(edge.toNodeId);
|
|
61015
61137
|
if (!target || isCancelExempt(target.state)) continue;
|
|
61016
61138
|
graphStore.updateNodeState(target.graphId, target.nodeId, "cancelled", nowIso, {
|
|
61017
|
-
failureReason:
|
|
61139
|
+
failureReason: reason
|
|
61018
61140
|
});
|
|
61019
61141
|
if (target.queueTaskId) {
|
|
61020
61142
|
const entry = store.findQueueEntryById(target.meshId, target.queueTaskId);
|
|
61021
61143
|
if (entry && entry.status === "pending") {
|
|
61022
61144
|
entry.status = "cancelled";
|
|
61023
|
-
entry.blockedReason =
|
|
61145
|
+
entry.blockedReason = reason;
|
|
61024
61146
|
store.updateQueueEntry(entry);
|
|
61025
61147
|
}
|
|
61026
61148
|
}
|
|
@@ -61057,6 +61179,7 @@ ${rendered}`, "utf-8");
|
|
|
61057
61179
|
init_logger();
|
|
61058
61180
|
init_mesh_graph_input_binding();
|
|
61059
61181
|
init_mesh_graph_types();
|
|
61182
|
+
init_mesh_graph_derived_failure();
|
|
61060
61183
|
init_mesh_graph_transition_runner();
|
|
61061
61184
|
init_mesh_graph_transition_runner();
|
|
61062
61185
|
MESH_GATE_DEFAULT_LEASE_SECONDS = 900;
|
|
@@ -61189,6 +61312,20 @@ ${rendered}`, "utf-8");
|
|
|
61189
61312
|
...p.cancelledNodeIds?.length ? { cancelledNodeIds: p.cancelledNodeIds } : {}
|
|
61190
61313
|
});
|
|
61191
61314
|
}
|
|
61315
|
+
function recordGraphGateAbandoned(meshId, p) {
|
|
61316
|
+
safeAppend(meshId, "graph_gate_abandoned", {
|
|
61317
|
+
graphId: p.graphId,
|
|
61318
|
+
gateId: p.gateId,
|
|
61319
|
+
...p.ref ? { ref: p.ref } : {},
|
|
61320
|
+
action: p.action,
|
|
61321
|
+
priorState: p.priorState,
|
|
61322
|
+
reason: p.reason.slice(0, 500),
|
|
61323
|
+
...p.coordinatorSessionId ? { coordinatorSessionId: p.coordinatorSessionId } : {},
|
|
61324
|
+
...p.force ? { force: true } : {},
|
|
61325
|
+
...p.cancelledNodeIds?.length ? { cancelledNodeIds: p.cancelledNodeIds } : {},
|
|
61326
|
+
...p.graphStatus ? { graphStatus: p.graphStatus } : {}
|
|
61327
|
+
});
|
|
61328
|
+
}
|
|
61192
61329
|
var MESH_VALID_SINGLE_REASONS;
|
|
61193
61330
|
var MESH_SUPERSEDED_SINGLE_REASONS;
|
|
61194
61331
|
var MESH_DECLARED_ELIGIBLE_SINGLE_HINT;
|
|
@@ -62648,6 +62785,13 @@ The mesh has no work in flight. For each mission, decide its outcome: continue i
|
|
|
62648
62785
|
}
|
|
62649
62786
|
return false;
|
|
62650
62787
|
}
|
|
62788
|
+
function isReplayOfRecordedSynthSummary(recorded, incoming) {
|
|
62789
|
+
if (recorded === incoming) return true;
|
|
62790
|
+
if (!recorded || !incoming) return false;
|
|
62791
|
+
const [shorter, longer] = recorded.length <= incoming.length ? [recorded, incoming] : [incoming, recorded];
|
|
62792
|
+
if (!longer.startsWith(shorter)) return false;
|
|
62793
|
+
return longer.length <= shorter.length + 32;
|
|
62794
|
+
}
|
|
62651
62795
|
function hasIdenticalSynthesizedTerminal(args) {
|
|
62652
62796
|
const entries = readLedgerEntriesByKind(args.meshId, ["task_dispatched", ...TERMINAL_LEDGER_KINDS2]);
|
|
62653
62797
|
let afterDispatch = !args.dispatchEntryId && !args.dispatchTimestamp;
|
|
@@ -62667,7 +62811,7 @@ The mesh has no work in flight. For each mission, decide its outcome: continue i
|
|
|
62667
62811
|
if (entry.kind !== "task_completed" && entry.kind !== "task_failed") continue;
|
|
62668
62812
|
const diagnostic = readRecord2(entry.payload?.completionDiagnostic);
|
|
62669
62813
|
if (readNonEmptyString(diagnostic?.reason) !== "direct_task_transcript_reconciliation") continue;
|
|
62670
|
-
if (readNonEmptyString(entry.payload?.finalSummary)
|
|
62814
|
+
if (!isReplayOfRecordedSynthSummary(readNonEmptyString(entry.payload?.finalSummary), args.finalSummary)) continue;
|
|
62671
62815
|
const terminalTaskId = readNonEmptyString(entry.payload?.taskId);
|
|
62672
62816
|
if (terminalTaskId && terminalTaskId !== args.taskId) continue;
|
|
62673
62817
|
if (terminalTaskId && terminalTaskId === args.taskId) return true;
|
|
@@ -70810,81 +70954,6 @@ ${cleanBody}`;
|
|
|
70810
70954
|
init_mesh_events_utils();
|
|
70811
70955
|
}
|
|
70812
70956
|
});
|
|
70813
|
-
function bootstrapQueueTaskCountsAsHandled(task, bootstrapNodeId, nowMs) {
|
|
70814
|
-
if (!meshNodeIdMatches({ id: task.targetNodeId }, bootstrapNodeId)) return false;
|
|
70815
|
-
if (task.status === "assigned") return true;
|
|
70816
|
-
const al = task.autoLaunch;
|
|
70817
|
-
if (!al) return true;
|
|
70818
|
-
if (al.status === "started" || al.status === "completed") {
|
|
70819
|
-
const launchedAtMs = Date.parse(al.updatedAt);
|
|
70820
|
-
return Number.isFinite(launchedAtMs) && nowMs - launchedAtMs < AUTO_LAUNCH_AWAIT_CLAIM_MS;
|
|
70821
|
-
}
|
|
70822
|
-
return true;
|
|
70823
|
-
}
|
|
70824
|
-
function resolveCoordinatorDrainDaemonIds(components) {
|
|
70825
|
-
const statusInstanceId = readNonEmptyString(components.statusInstanceId);
|
|
70826
|
-
const machineId = readNonEmptyString(loadConfig2().machineId);
|
|
70827
|
-
return expandDaemonIdForms([statusInstanceId, machineId]);
|
|
70828
|
-
}
|
|
70829
|
-
function getCachedMeshByWorkspace(workspace) {
|
|
70830
|
-
const now = Date.now();
|
|
70831
|
-
const cached5 = meshByWorkspaceCache.get(workspace);
|
|
70832
|
-
if (cached5 && now - cached5.cachedAt < MESH_WORKSPACE_CACHE_TTL_MS) return cached5.mesh;
|
|
70833
|
-
const mesh = getMeshByRepo(workspace);
|
|
70834
|
-
meshByWorkspaceCache.set(workspace, { mesh, cachedAt: now });
|
|
70835
|
-
return mesh;
|
|
70836
|
-
}
|
|
70837
|
-
function recoverMeshIdByNodeId(nodeId) {
|
|
70838
|
-
if (!nodeId) return "";
|
|
70839
|
-
for (const mesh of listMeshes()) {
|
|
70840
|
-
if (Array.isArray(mesh.nodes) && mesh.nodes.some((n) => meshNodeIdMatches(n, nodeId))) {
|
|
70841
|
-
return readNonEmptyString(mesh.id);
|
|
70842
|
-
}
|
|
70843
|
-
}
|
|
70844
|
-
return "";
|
|
70845
|
-
}
|
|
70846
|
-
function recoverMeshIdByCoordinatorAndNode(coordinatorDaemonId, nodeId) {
|
|
70847
|
-
if (!coordinatorDaemonId) return "";
|
|
70848
|
-
const hosted = listMeshes().filter((mesh) => {
|
|
70849
|
-
const host = resolveMeshHostStatus(mesh);
|
|
70850
|
-
return host.role === "host" && (!host.hostDaemonId || daemonIdsEquivalent(host.hostDaemonId, coordinatorDaemonId));
|
|
70851
|
-
});
|
|
70852
|
-
if (hosted.length === 0) return "";
|
|
70853
|
-
if (nodeId) {
|
|
70854
|
-
const byNode = hosted.find((mesh) => Array.isArray(mesh.nodes) && mesh.nodes.some((n) => meshNodeIdMatches(n, nodeId)));
|
|
70855
|
-
if (byNode) return readNonEmptyString(byNode.id);
|
|
70856
|
-
return "";
|
|
70857
|
-
}
|
|
70858
|
-
return hosted.length === 1 ? readNonEmptyString(hosted[0].id) : "";
|
|
70859
|
-
}
|
|
70860
|
-
function resolveForwardEventMeshId(components, payload) {
|
|
70861
|
-
const direct = readNonEmptyString(payload.meshId);
|
|
70862
|
-
if (direct) return direct;
|
|
70863
|
-
const workspace = readNonEmptyString(payload.workspace);
|
|
70864
|
-
const byWorkspace = workspace ? readNonEmptyString(getCachedMeshByWorkspace(workspace)?.id) : "";
|
|
70865
|
-
if (byWorkspace) return byWorkspace;
|
|
70866
|
-
const byNode = recoverMeshIdByNodeId(readNonEmptyString(payload.nodeId));
|
|
70867
|
-
if (byNode) return byNode;
|
|
70868
|
-
const sessionId = readNonEmptyString(payload.targetSessionId) || readNonEmptyString(payload.sessionId) || readNonEmptyString(payload.instanceId);
|
|
70869
|
-
if (sessionId) {
|
|
70870
|
-
try {
|
|
70871
|
-
const state = components.instanceManager?.getInstance?.(sessionId)?.getState?.();
|
|
70872
|
-
const settings = state?.settings || {};
|
|
70873
|
-
const meshNodeFor = readNonEmptyString(settings.meshNodeFor);
|
|
70874
|
-
if (meshNodeFor) return meshNodeFor;
|
|
70875
|
-
const byStamp = recoverMeshIdByNodeId(readNonEmptyString(settings.meshNodeId));
|
|
70876
|
-
if (byStamp) return byStamp;
|
|
70877
|
-
const sessionWorkspace = readNonEmptyString(state?.workspace);
|
|
70878
|
-
const bySessionWorkspace = sessionWorkspace ? readNonEmptyString(getCachedMeshByWorkspace(sessionWorkspace)?.id) : "";
|
|
70879
|
-
if (bySessionWorkspace) return bySessionWorkspace;
|
|
70880
|
-
} catch {
|
|
70881
|
-
}
|
|
70882
|
-
}
|
|
70883
|
-
return "";
|
|
70884
|
-
}
|
|
70885
|
-
function __resetMeshWorkspaceCacheForTests() {
|
|
70886
|
-
meshByWorkspaceCache.clear();
|
|
70887
|
-
}
|
|
70888
70957
|
function sweepExpiredRemoteIdleSessions() {
|
|
70889
70958
|
try {
|
|
70890
70959
|
MeshRuntimeStore.getInstance().pruneExpiredRemoteIdleSessions();
|
|
@@ -71012,6 +71081,10 @@ ${cleanBody}`;
|
|
|
71012
71081
|
if (explicit) return explicit;
|
|
71013
71082
|
return extractJsonObjectFromSummary(readNonEmptyString(metadataEvent.finalSummary) || void 0);
|
|
71014
71083
|
}
|
|
71084
|
+
function resolveUnifiedCompletionEvidenceLevel(args) {
|
|
71085
|
+
if (args.computedLevel === "insufficient" || args.priorLevel === "insufficient") return "insufficient";
|
|
71086
|
+
return args.computedLevel || args.priorLevel;
|
|
71087
|
+
}
|
|
71015
71088
|
function supersedesTruncatedTerminalSummary(args) {
|
|
71016
71089
|
if (!args.terminalTaskId || !args.eventTaskId || args.terminalTaskId !== args.eventTaskId) return false;
|
|
71017
71090
|
if (!isGenuineCompletionEvidence(args.metadataEvent)) return false;
|
|
@@ -71052,7 +71125,7 @@ ${cleanBody}`;
|
|
|
71052
71125
|
return false;
|
|
71053
71126
|
}
|
|
71054
71127
|
function evaluateMeshEventSuppression(args, ctx) {
|
|
71055
|
-
const { traceCtx, eventSessionId, eventNodeId, eventTimestamp, workerCoordinatorDaemonId, components } = ctx;
|
|
71128
|
+
const { traceCtx, eventSessionId, eventNodeId, eventTimestamp, workerCoordinatorDaemonId, components, injectMeshSystemMessage: injectMeshSystemMessage2 } = ctx;
|
|
71056
71129
|
const intentionalCleanupStop = shouldSuppressIntentionalCleanupStop({
|
|
71057
71130
|
event: args.event,
|
|
71058
71131
|
meshId: args.meshId,
|
|
@@ -71138,7 +71211,7 @@ ${cleanBody}`;
|
|
|
71138
71211
|
eventSessionId,
|
|
71139
71212
|
attempt
|
|
71140
71213
|
});
|
|
71141
|
-
const heldForRetry = retryEligible && holdCompletionForLiveStateRetry(components, args, eventSessionId, Date.now(),
|
|
71214
|
+
const heldForRetry = retryEligible && holdCompletionForLiveStateRetry(components, args, eventSessionId, Date.now(), injectMeshSystemMessage2);
|
|
71142
71215
|
const authorityDetail = !authority.authoritative && authority.detail ? ` [authorityClass=${authority.detail.authorityClass ?? "none"} evidenceSource=${authority.detail.evidenceSource ?? "none"} timing=${authority.detail.timing ?? "none"}]` : "";
|
|
71143
71216
|
LOG2.info("MeshEvents", `Suppressed agent:generating_completed for session ${eventSessionId} (mesh ${args.meshId}): current live evidence remains pending (${live.kind ?? "unknown"}); transcript authority=${authority.authoritative ? "fresh_but_not_newer" : authority.reason}${authorityDetail}${heldForRetry ? " \u2014 bounded content-free retry armed" : ""}`);
|
|
71144
71217
|
traceMeshEventDrop(
|
|
@@ -71184,7 +71257,7 @@ ${cleanBody}`;
|
|
|
71184
71257
|
args,
|
|
71185
71258
|
eventSessionId,
|
|
71186
71259
|
Date.now(),
|
|
71187
|
-
|
|
71260
|
+
injectMeshSystemMessage2
|
|
71188
71261
|
);
|
|
71189
71262
|
LOG2.info("MeshEvents", `Suppressed agent:generating_completed for session ${eventSessionId} (mesh ${args.meshId}): terminal admission declined (${admission.reason}) \u2014 ${admission.detail}${heldForRetry ? " \u2014 bounded content-free retry armed" : ""}`);
|
|
71190
71263
|
traceMeshEventDrop(
|
|
@@ -71451,6 +71524,119 @@ ${cleanBody}`;
|
|
|
71451
71524
|
}
|
|
71452
71525
|
return false;
|
|
71453
71526
|
}
|
|
71527
|
+
var lastPendingEventsPruneAt;
|
|
71528
|
+
var PENDING_EVENTS_PRUNE_INTERVAL_MS;
|
|
71529
|
+
var INTENTIONAL_CLEANUP_STOP_SUPPRESSION_MS;
|
|
71530
|
+
var RECENT_COMPLETION_FINGERPRINT_TTL_MS;
|
|
71531
|
+
var RECONCILED_COMPLETION_SOURCES;
|
|
71532
|
+
var turnOutboxDrainScheduled;
|
|
71533
|
+
var init_mesh_event_suppression = __esm2({
|
|
71534
|
+
"src/mesh/mesh-event-suppression.ts"() {
|
|
71535
|
+
"use strict";
|
|
71536
|
+
init_logger();
|
|
71537
|
+
init_mesh_ledger();
|
|
71538
|
+
init_mesh_work_queue();
|
|
71539
|
+
init_mesh_runtime_store();
|
|
71540
|
+
init_mesh_events_pending();
|
|
71541
|
+
init_mesh_event_trace();
|
|
71542
|
+
init_dist();
|
|
71543
|
+
init_mesh_events_stale();
|
|
71544
|
+
init_mesh_task_inflight();
|
|
71545
|
+
init_mesh_node_identity();
|
|
71546
|
+
init_mesh_events_utils();
|
|
71547
|
+
init_mesh_turn_ledger();
|
|
71548
|
+
init_mesh_turn_presentation();
|
|
71549
|
+
init_mesh_queue_assignment();
|
|
71550
|
+
init_mesh_completion_live_gate();
|
|
71551
|
+
init_mesh_provider_event_admission();
|
|
71552
|
+
lastPendingEventsPruneAt = 0;
|
|
71553
|
+
PENDING_EVENTS_PRUNE_INTERVAL_MS = 60 * 60 * 1e3;
|
|
71554
|
+
INTENTIONAL_CLEANUP_STOP_SUPPRESSION_MS = 30 * 60 * 1e3;
|
|
71555
|
+
RECENT_COMPLETION_FINGERPRINT_TTL_MS = 10 * 60 * 1e3;
|
|
71556
|
+
RECONCILED_COMPLETION_SOURCES = /* @__PURE__ */ new Set([
|
|
71557
|
+
"direct_task_transcript_reconciliation",
|
|
71558
|
+
"daemon_reconcile_transcript_completion",
|
|
71559
|
+
"mcp_mesh_status_transcript_reconciliation",
|
|
71560
|
+
"no_progress_reconciliation"
|
|
71561
|
+
]);
|
|
71562
|
+
turnOutboxDrainScheduled = false;
|
|
71563
|
+
}
|
|
71564
|
+
});
|
|
71565
|
+
function bootstrapQueueTaskCountsAsHandled(task, bootstrapNodeId, nowMs) {
|
|
71566
|
+
if (!meshNodeIdMatches({ id: task.targetNodeId }, bootstrapNodeId)) return false;
|
|
71567
|
+
if (task.status === "assigned") return true;
|
|
71568
|
+
const al = task.autoLaunch;
|
|
71569
|
+
if (!al) return true;
|
|
71570
|
+
if (al.status === "started" || al.status === "completed") {
|
|
71571
|
+
const launchedAtMs = Date.parse(al.updatedAt);
|
|
71572
|
+
return Number.isFinite(launchedAtMs) && nowMs - launchedAtMs < AUTO_LAUNCH_AWAIT_CLAIM_MS;
|
|
71573
|
+
}
|
|
71574
|
+
return true;
|
|
71575
|
+
}
|
|
71576
|
+
function resolveCoordinatorDrainDaemonIds(components) {
|
|
71577
|
+
const statusInstanceId = readNonEmptyString(components.statusInstanceId);
|
|
71578
|
+
const machineId = readNonEmptyString(loadConfig2().machineId);
|
|
71579
|
+
return expandDaemonIdForms([statusInstanceId, machineId]);
|
|
71580
|
+
}
|
|
71581
|
+
function getCachedMeshByWorkspace(workspace) {
|
|
71582
|
+
const now = Date.now();
|
|
71583
|
+
const cached5 = meshByWorkspaceCache.get(workspace);
|
|
71584
|
+
if (cached5 && now - cached5.cachedAt < MESH_WORKSPACE_CACHE_TTL_MS) return cached5.mesh;
|
|
71585
|
+
const mesh = getMeshByRepo(workspace);
|
|
71586
|
+
meshByWorkspaceCache.set(workspace, { mesh, cachedAt: now });
|
|
71587
|
+
return mesh;
|
|
71588
|
+
}
|
|
71589
|
+
function recoverMeshIdByNodeId(nodeId) {
|
|
71590
|
+
if (!nodeId) return "";
|
|
71591
|
+
for (const mesh of listMeshes()) {
|
|
71592
|
+
if (Array.isArray(mesh.nodes) && mesh.nodes.some((n) => meshNodeIdMatches(n, nodeId))) {
|
|
71593
|
+
return readNonEmptyString(mesh.id);
|
|
71594
|
+
}
|
|
71595
|
+
}
|
|
71596
|
+
return "";
|
|
71597
|
+
}
|
|
71598
|
+
function recoverMeshIdByCoordinatorAndNode(coordinatorDaemonId, nodeId) {
|
|
71599
|
+
if (!coordinatorDaemonId) return "";
|
|
71600
|
+
const hosted = listMeshes().filter((mesh) => {
|
|
71601
|
+
const host = resolveMeshHostStatus(mesh);
|
|
71602
|
+
return host.role === "host" && (!host.hostDaemonId || daemonIdsEquivalent(host.hostDaemonId, coordinatorDaemonId));
|
|
71603
|
+
});
|
|
71604
|
+
if (hosted.length === 0) return "";
|
|
71605
|
+
if (nodeId) {
|
|
71606
|
+
const byNode = hosted.find((mesh) => Array.isArray(mesh.nodes) && mesh.nodes.some((n) => meshNodeIdMatches(n, nodeId)));
|
|
71607
|
+
if (byNode) return readNonEmptyString(byNode.id);
|
|
71608
|
+
return "";
|
|
71609
|
+
}
|
|
71610
|
+
return hosted.length === 1 ? readNonEmptyString(hosted[0].id) : "";
|
|
71611
|
+
}
|
|
71612
|
+
function resolveForwardEventMeshId(components, payload) {
|
|
71613
|
+
const direct = readNonEmptyString(payload.meshId);
|
|
71614
|
+
if (direct) return direct;
|
|
71615
|
+
const workspace = readNonEmptyString(payload.workspace);
|
|
71616
|
+
const byWorkspace = workspace ? readNonEmptyString(getCachedMeshByWorkspace(workspace)?.id) : "";
|
|
71617
|
+
if (byWorkspace) return byWorkspace;
|
|
71618
|
+
const byNode = recoverMeshIdByNodeId(readNonEmptyString(payload.nodeId));
|
|
71619
|
+
if (byNode) return byNode;
|
|
71620
|
+
const sessionId = readNonEmptyString(payload.targetSessionId) || readNonEmptyString(payload.sessionId) || readNonEmptyString(payload.instanceId);
|
|
71621
|
+
if (sessionId) {
|
|
71622
|
+
try {
|
|
71623
|
+
const state = components.instanceManager?.getInstance?.(sessionId)?.getState?.();
|
|
71624
|
+
const settings = state?.settings || {};
|
|
71625
|
+
const meshNodeFor = readNonEmptyString(settings.meshNodeFor);
|
|
71626
|
+
if (meshNodeFor) return meshNodeFor;
|
|
71627
|
+
const byStamp = recoverMeshIdByNodeId(readNonEmptyString(settings.meshNodeId));
|
|
71628
|
+
if (byStamp) return byStamp;
|
|
71629
|
+
const sessionWorkspace = readNonEmptyString(state?.workspace);
|
|
71630
|
+
const bySessionWorkspace = sessionWorkspace ? readNonEmptyString(getCachedMeshByWorkspace(sessionWorkspace)?.id) : "";
|
|
71631
|
+
if (bySessionWorkspace) return bySessionWorkspace;
|
|
71632
|
+
} catch {
|
|
71633
|
+
}
|
|
71634
|
+
}
|
|
71635
|
+
return "";
|
|
71636
|
+
}
|
|
71637
|
+
function __resetMeshWorkspaceCacheForTests() {
|
|
71638
|
+
meshByWorkspaceCache.clear();
|
|
71639
|
+
}
|
|
71454
71640
|
function injectMeshSystemMessage(components, args) {
|
|
71455
71641
|
const eventSessionId = resolveEventSessionId(args.metadataEvent, args.sourceInstanceId);
|
|
71456
71642
|
const eventNodeId = readNonEmptyString(args.nodeId) || readNonEmptyString(args.metadataEvent.meshNodeId);
|
|
@@ -71528,7 +71714,8 @@ ${cleanBody}`;
|
|
|
71528
71714
|
eventNodeId,
|
|
71529
71715
|
eventTimestamp,
|
|
71530
71716
|
workerCoordinatorDaemonId,
|
|
71531
|
-
components
|
|
71717
|
+
components,
|
|
71718
|
+
injectMeshSystemMessage
|
|
71532
71719
|
});
|
|
71533
71720
|
if (suppression) {
|
|
71534
71721
|
if (suppression.kind === "reconcile") {
|
|
@@ -72005,7 +72192,36 @@ ${cleanBody}`;
|
|
|
72005
72192
|
// worker-result-shaped, e.g. a MAGI envelope) is concrete evidence and must
|
|
72006
72193
|
// resolve to 'sufficient' — resolveWorkerResult now upgrades that case so a
|
|
72007
72194
|
// complete, valid answer is no longer mislabelled insufficient/reviewRecommended.
|
|
72008
|
-
|
|
72195
|
+
//
|
|
72196
|
+
// EVIDENCE-LEVEL-UNIFY: the LEDGER value is merged with whatever
|
|
72197
|
+
// applyTaskModeCompletionEvidence already stamped onto
|
|
72198
|
+
// args.metadataEvent.evidenceLevel earlier in markSessionTerminal, so a
|
|
72199
|
+
// 'reported' stamp can never make the ledger forget a locally-computed
|
|
72200
|
+
// 'insufficient' (and vice versa). See resolveUnifiedCompletionEvidenceLevel.
|
|
72201
|
+
//
|
|
72202
|
+
// ONE-WAY ON PURPOSE — do NOT write the resolved level back onto
|
|
72203
|
+
// args.metadataEvent. That mutation looks like the natural way to make the
|
|
72204
|
+
// later buildMeshSystemMessage read agree with the ledger, but
|
|
72205
|
+
// metadataEvent.evidenceLevel is load-bearing for DEDUP, not just wording:
|
|
72206
|
+
// buildPendingEventFingerprint (mesh-events-pending.ts) keys terminal
|
|
72207
|
+
// completions `…::weak` / `…::genuine` off isWeakCompletionMetadata, which
|
|
72208
|
+
// reads this very field. Stamping 'insufficient' back onto an ordinary
|
|
72209
|
+
// completion (workerResult.source === 'default' is the COMMON plain-text
|
|
72210
|
+
// finalSummary case, not an anomaly) moves it into the `::weak` slot, where
|
|
72211
|
+
// it collides with an earlier weak synth for the same taskId and the
|
|
72212
|
+
// genuine completion is dropped as a duplicate — the exact swallow that
|
|
72213
|
+
// EARLYNOTIFY-GATEBYPASS guards against. The ledger records the stricter
|
|
72214
|
+
// verdict; the coordinator-facing weakness signal stays owned by the
|
|
72215
|
+
// producers that set it deliberately.
|
|
72216
|
+
...(() => {
|
|
72217
|
+
const computedLevel = completionEvidence ? completionEvidence.workerResult.source === "default" ? "insufficient" : "sufficient" : void 0;
|
|
72218
|
+
const resolvedLevel = resolveUnifiedCompletionEvidenceLevel({
|
|
72219
|
+
computedLevel,
|
|
72220
|
+
priorLevel: readNonEmptyString(args.metadataEvent.evidenceLevel)
|
|
72221
|
+
});
|
|
72222
|
+
if (!resolvedLevel) return {};
|
|
72223
|
+
return resolvedLevel === "insufficient" ? { evidenceLevel: resolvedLevel, reviewRecommended: true } : { evidenceLevel: resolvedLevel };
|
|
72224
|
+
})(),
|
|
72009
72225
|
// FALSE-COMPLETION-GIT-EVIDENCE: markSessionTerminal's synchronous git-clean
|
|
72010
72226
|
// gate stamps this onto metadataEvent BEFORE this ledger append runs — OR it
|
|
72011
72227
|
// into reviewRecommended (never downgrade the NOTIF Defect-2b verdict above)
|
|
@@ -72503,12 +72719,6 @@ ${cleanBody}`;
|
|
|
72503
72719
|
var REMOTE_IDLE_SESSION_TTL_MS;
|
|
72504
72720
|
var meshByWorkspaceCache;
|
|
72505
72721
|
var MESH_WORKSPACE_CACHE_TTL_MS;
|
|
72506
|
-
var lastPendingEventsPruneAt;
|
|
72507
|
-
var PENDING_EVENTS_PRUNE_INTERVAL_MS;
|
|
72508
|
-
var INTENTIONAL_CLEANUP_STOP_SUPPRESSION_MS;
|
|
72509
|
-
var RECENT_COMPLETION_FINGERPRINT_TTL_MS;
|
|
72510
|
-
var RECONCILED_COMPLETION_SOURCES;
|
|
72511
|
-
var turnOutboxDrainScheduled;
|
|
72512
72722
|
var init_mesh_event_forwarding = __esm2({
|
|
72513
72723
|
"src/mesh/mesh-event-forwarding.ts"() {
|
|
72514
72724
|
"use strict";
|
|
@@ -72535,28 +72745,15 @@ ${cleanBody}`;
|
|
|
72535
72745
|
init_mesh_events_stale();
|
|
72536
72746
|
init_mesh_task_inflight();
|
|
72537
72747
|
init_mesh_graph_transition_runner();
|
|
72538
|
-
init_mesh_node_identity();
|
|
72539
72748
|
init_mesh_events_utils();
|
|
72540
72749
|
init_mesh_event_classify();
|
|
72541
72750
|
init_mesh_turn_ledger();
|
|
72542
|
-
init_mesh_turn_presentation();
|
|
72543
72751
|
init_mesh_queue_assignment();
|
|
72544
|
-
|
|
72545
|
-
|
|
72752
|
+
init_mesh_event_suppression();
|
|
72753
|
+
init_mesh_event_suppression();
|
|
72546
72754
|
REMOTE_IDLE_SESSION_TTL_MS = 5 * 60 * 1e3;
|
|
72547
72755
|
meshByWorkspaceCache = /* @__PURE__ */ new Map();
|
|
72548
72756
|
MESH_WORKSPACE_CACHE_TTL_MS = 5e3;
|
|
72549
|
-
lastPendingEventsPruneAt = 0;
|
|
72550
|
-
PENDING_EVENTS_PRUNE_INTERVAL_MS = 60 * 60 * 1e3;
|
|
72551
|
-
INTENTIONAL_CLEANUP_STOP_SUPPRESSION_MS = 30 * 60 * 1e3;
|
|
72552
|
-
RECENT_COMPLETION_FINGERPRINT_TTL_MS = 10 * 60 * 1e3;
|
|
72553
|
-
RECONCILED_COMPLETION_SOURCES = /* @__PURE__ */ new Set([
|
|
72554
|
-
"direct_task_transcript_reconciliation",
|
|
72555
|
-
"daemon_reconcile_transcript_completion",
|
|
72556
|
-
"mcp_mesh_status_transcript_reconciliation",
|
|
72557
|
-
"no_progress_reconciliation"
|
|
72558
|
-
]);
|
|
72559
|
-
turnOutboxDrainScheduled = false;
|
|
72560
72757
|
}
|
|
72561
72758
|
});
|
|
72562
72759
|
var init_mesh_events_coordinator = __esm2({
|
|
@@ -77621,8 +77818,8 @@ ${cleanBody}`;
|
|
|
77621
77818
|
let cwd = options.cwd;
|
|
77622
77819
|
if (cwd) {
|
|
77623
77820
|
try {
|
|
77624
|
-
const
|
|
77625
|
-
const stat2 =
|
|
77821
|
+
const fs61 = require("fs");
|
|
77822
|
+
const stat2 = fs61.statSync(cwd);
|
|
77626
77823
|
if (!stat2.isDirectory()) cwd = os14.homedir();
|
|
77627
77824
|
} catch {
|
|
77628
77825
|
cwd = os14.homedir();
|
|
@@ -79019,6 +79216,360 @@ ${cleanBody}`;
|
|
|
79019
79216
|
DEFAULT_REFINE_VITEST_MAX_WORKERS = 2;
|
|
79020
79217
|
}
|
|
79021
79218
|
});
|
|
79219
|
+
function readChangedGitlinkPaths(repoRoot, fromRef, toRef) {
|
|
79220
|
+
try {
|
|
79221
|
+
const output = (0, import_node_child_process11.execFileSync)(GIT4, ["diff", "--raw", "--no-abbrev", fromRef, toRef], {
|
|
79222
|
+
cwd: repoRoot,
|
|
79223
|
+
encoding: "utf8",
|
|
79224
|
+
maxBuffer: REFINE_PATCH_EQUIVALENCE_OUTPUT_LIMIT_BYTES
|
|
79225
|
+
});
|
|
79226
|
+
const paths = /* @__PURE__ */ new Set();
|
|
79227
|
+
for (const line of output.split("\n")) {
|
|
79228
|
+
if (!line.trim()) continue;
|
|
79229
|
+
const metaAndPath = line.split(" ");
|
|
79230
|
+
const meta3 = metaAndPath[0] || "";
|
|
79231
|
+
const path58 = metaAndPath[metaAndPath.length - 1]?.trim();
|
|
79232
|
+
if (!path58) continue;
|
|
79233
|
+
const parts = meta3.split(/\s+/);
|
|
79234
|
+
if (parts[0]?.includes("160000") || parts[1]?.includes("160000")) {
|
|
79235
|
+
paths.add(path58);
|
|
79236
|
+
}
|
|
79237
|
+
}
|
|
79238
|
+
return [...paths].sort();
|
|
79239
|
+
} catch {
|
|
79240
|
+
return [];
|
|
79241
|
+
}
|
|
79242
|
+
}
|
|
79243
|
+
function readTreeObject(repoRoot, ref, path58) {
|
|
79244
|
+
try {
|
|
79245
|
+
const output = (0, import_node_child_process11.execFileSync)(GIT4, ["ls-tree", ref, "--", path58], {
|
|
79246
|
+
cwd: repoRoot,
|
|
79247
|
+
encoding: "utf8",
|
|
79248
|
+
maxBuffer: 1024 * 1024
|
|
79249
|
+
}).trim();
|
|
79250
|
+
const match = output.match(/\bcommit\s+([0-9a-f]{40})\b/i);
|
|
79251
|
+
return match?.[1];
|
|
79252
|
+
} catch {
|
|
79253
|
+
return void 0;
|
|
79254
|
+
}
|
|
79255
|
+
}
|
|
79256
|
+
function submoduleCommitPresent(submoduleRepoPath, commit) {
|
|
79257
|
+
if (!commit) return false;
|
|
79258
|
+
try {
|
|
79259
|
+
(0, import_node_child_process11.execFileSync)(GIT4, ["cat-file", "-e", `${commit}^{commit}`], { cwd: submoduleRepoPath, stdio: "ignore" });
|
|
79260
|
+
return true;
|
|
79261
|
+
} catch {
|
|
79262
|
+
return false;
|
|
79263
|
+
}
|
|
79264
|
+
}
|
|
79265
|
+
function ensureSubmoduleCommitLocal(submoduleRepoPath, baseSubmoduleRepoPath, commit) {
|
|
79266
|
+
if (!commit) return false;
|
|
79267
|
+
const present = () => {
|
|
79268
|
+
try {
|
|
79269
|
+
(0, import_node_child_process11.execFileSync)(GIT4, ["cat-file", "-e", `${commit}^{commit}`], { cwd: submoduleRepoPath, stdio: "ignore" });
|
|
79270
|
+
return true;
|
|
79271
|
+
} catch {
|
|
79272
|
+
return false;
|
|
79273
|
+
}
|
|
79274
|
+
};
|
|
79275
|
+
if (present()) return true;
|
|
79276
|
+
try {
|
|
79277
|
+
if (!fs48.existsSync(submoduleRepoPath) || !fs48.existsSync(baseSubmoduleRepoPath)) return false;
|
|
79278
|
+
} catch {
|
|
79279
|
+
return false;
|
|
79280
|
+
}
|
|
79281
|
+
const strategies = [
|
|
79282
|
+
// 1. All local branches (historical behaviour).
|
|
79283
|
+
["fetch", "-q", baseSubmoduleRepoPath, "+refs/heads/*:refs/adhdev-refine-base/*"],
|
|
79284
|
+
// 2. The base checkout's detached HEAD plus every ref it has.
|
|
79285
|
+
["fetch", "-q", baseSubmoduleRepoPath, "HEAD", "+refs/*:refs/adhdev-refine-base-all/*"],
|
|
79286
|
+
// 3. The exact object, allowing a bare-sha want on the source side.
|
|
79287
|
+
["fetch", "-q", "--upload-pack", "git -c uploadpack.allowAnySHA1InWant=true upload-pack", baseSubmoduleRepoPath, commit]
|
|
79288
|
+
];
|
|
79289
|
+
for (const args of strategies) {
|
|
79290
|
+
try {
|
|
79291
|
+
(0, import_node_child_process11.execFileSync)(GIT4, ["-c", "protocol.file.allow=always", ...args], {
|
|
79292
|
+
cwd: submoduleRepoPath,
|
|
79293
|
+
stdio: ["ignore", "ignore", "pipe"]
|
|
79294
|
+
});
|
|
79295
|
+
} catch {
|
|
79296
|
+
}
|
|
79297
|
+
if (present()) return true;
|
|
79298
|
+
}
|
|
79299
|
+
return false;
|
|
79300
|
+
}
|
|
79301
|
+
var fs48;
|
|
79302
|
+
var import_node_child_process11;
|
|
79303
|
+
var GIT4;
|
|
79304
|
+
var REFINE_PATCH_EQUIVALENCE_OUTPUT_LIMIT_BYTES;
|
|
79305
|
+
var init_mesh_refine_gitlink_utils = __esm2({
|
|
79306
|
+
"src/mesh/mesh-refine-gitlink-utils.ts"() {
|
|
79307
|
+
"use strict";
|
|
79308
|
+
fs48 = __toESM2(require("fs"));
|
|
79309
|
+
import_node_child_process11 = require("child_process");
|
|
79310
|
+
init_resolve_executable();
|
|
79311
|
+
GIT4 = process.platform === "win32" ? resolveWin32Executable("git") : "git";
|
|
79312
|
+
REFINE_PATCH_EQUIVALENCE_OUTPUT_LIMIT_BYTES = 4 * 1024 * 1024;
|
|
79313
|
+
}
|
|
79314
|
+
});
|
|
79315
|
+
function classifySubmoduleDivergence(submoduleRepoPath, baseCommit, branchCommit) {
|
|
79316
|
+
if (!baseCommit || !branchCommit) return "undeterminable";
|
|
79317
|
+
if (baseCommit === branchCommit) return "not_diverged";
|
|
79318
|
+
try {
|
|
79319
|
+
if (!fs49.existsSync(submoduleRepoPath)) return "undeterminable";
|
|
79320
|
+
(0, import_node_child_process12.execFileSync)(GIT4, ["cat-file", "-e", `${baseCommit}^{commit}`], { cwd: submoduleRepoPath, stdio: "ignore" });
|
|
79321
|
+
(0, import_node_child_process12.execFileSync)(GIT4, ["cat-file", "-e", `${branchCommit}^{commit}`], { cwd: submoduleRepoPath, stdio: "ignore" });
|
|
79322
|
+
} catch {
|
|
79323
|
+
return "undeterminable";
|
|
79324
|
+
}
|
|
79325
|
+
try {
|
|
79326
|
+
(0, import_node_child_process12.execFileSync)(GIT4, ["merge-base", "--is-ancestor", baseCommit, branchCommit], { cwd: submoduleRepoPath, stdio: "ignore" });
|
|
79327
|
+
return "not_diverged";
|
|
79328
|
+
} catch {
|
|
79329
|
+
}
|
|
79330
|
+
try {
|
|
79331
|
+
(0, import_node_child_process12.execFileSync)(GIT4, ["merge-base", "--is-ancestor", branchCommit, baseCommit], { cwd: submoduleRepoPath, stdio: "ignore" });
|
|
79332
|
+
return "not_diverged";
|
|
79333
|
+
} catch {
|
|
79334
|
+
}
|
|
79335
|
+
try {
|
|
79336
|
+
const mb = (0, import_node_child_process12.execFileSync)(GIT4, ["merge-base", baseCommit, branchCommit], { cwd: submoduleRepoPath, encoding: "utf8" }).trim();
|
|
79337
|
+
return mb ? "diverged" : "not_diverged";
|
|
79338
|
+
} catch {
|
|
79339
|
+
return "not_diverged";
|
|
79340
|
+
}
|
|
79341
|
+
}
|
|
79342
|
+
function resolveSubmoduleRemoteMainRef(submoduleRepoPath) {
|
|
79343
|
+
try {
|
|
79344
|
+
const sym = (0, import_node_child_process12.execFileSync)(GIT4, ["symbolic-ref", "-q", "refs/remotes/origin/HEAD"], { cwd: submoduleRepoPath, encoding: "utf8" }).trim();
|
|
79345
|
+
if (sym) return sym;
|
|
79346
|
+
} catch {
|
|
79347
|
+
}
|
|
79348
|
+
for (const branch of ["main", "master"]) {
|
|
79349
|
+
try {
|
|
79350
|
+
(0, import_node_child_process12.execFileSync)(GIT4, ["rev-parse", "--verify", "-q", `refs/remotes/origin/${branch}`], { cwd: submoduleRepoPath, stdio: ["ignore", "pipe", "pipe"] });
|
|
79351
|
+
return `refs/remotes/origin/${branch}`;
|
|
79352
|
+
} catch {
|
|
79353
|
+
}
|
|
79354
|
+
}
|
|
79355
|
+
return void 0;
|
|
79356
|
+
}
|
|
79357
|
+
function findEquivalentPublishedSubmoduleCommit(submoduleRepoPath, baseCommit, branchCommit, remoteRef) {
|
|
79358
|
+
try {
|
|
79359
|
+
const mergeTreeOut = (0, import_node_child_process12.execFileSync)(GIT4, ["merge-tree", "--write-tree", baseCommit, branchCommit], {
|
|
79360
|
+
cwd: submoduleRepoPath,
|
|
79361
|
+
encoding: "utf8",
|
|
79362
|
+
stdio: ["ignore", "pipe", "pipe"]
|
|
79363
|
+
});
|
|
79364
|
+
const mergedTree = mergeTreeOut.trim().split(/\s+/)[0] || "";
|
|
79365
|
+
if (!mergedTree) return void 0;
|
|
79366
|
+
const candidates = (0, import_node_child_process12.execFileSync)(GIT4, ["rev-list", "--max-count=100", remoteRef, "--not", baseCommit], {
|
|
79367
|
+
cwd: submoduleRepoPath,
|
|
79368
|
+
encoding: "utf8"
|
|
79369
|
+
}).split("\n").map((s2) => s2.trim()).filter(Boolean);
|
|
79370
|
+
for (const candidate of candidates) {
|
|
79371
|
+
try {
|
|
79372
|
+
(0, import_node_child_process12.execFileSync)(GIT4, ["merge-base", "--is-ancestor", baseCommit, candidate], { cwd: submoduleRepoPath, stdio: "ignore" });
|
|
79373
|
+
} catch {
|
|
79374
|
+
continue;
|
|
79375
|
+
}
|
|
79376
|
+
const tree = (0, import_node_child_process12.execFileSync)(GIT4, ["rev-parse", `${candidate}^{tree}`], { cwd: submoduleRepoPath, encoding: "utf8" }).trim();
|
|
79377
|
+
if (tree === mergedTree) return candidate;
|
|
79378
|
+
}
|
|
79379
|
+
} catch {
|
|
79380
|
+
}
|
|
79381
|
+
return void 0;
|
|
79382
|
+
}
|
|
79383
|
+
function convergeDivergedSubmoduleGitlinks(worktreeRoot, baseRepoRoot, baseHead, branchHead) {
|
|
79384
|
+
const changed = readChangedGitlinkPaths(worktreeRoot, baseHead, branchHead);
|
|
79385
|
+
if (changed.length === 0) {
|
|
79386
|
+
return { converged: false, reason: "no_changed_gitlinks", resolutions: [], gitlinks: [] };
|
|
79387
|
+
}
|
|
79388
|
+
const gitlinks = [];
|
|
79389
|
+
const resolutions = [];
|
|
79390
|
+
let sawDiverged = false;
|
|
79391
|
+
let sawUndeterminable = false;
|
|
79392
|
+
for (const path58 of changed) {
|
|
79393
|
+
const baseCommit = readTreeObject(baseRepoRoot, baseHead, path58);
|
|
79394
|
+
const branchCommit = readTreeObject(worktreeRoot, branchHead, path58);
|
|
79395
|
+
const submoduleRepoPath = (0, import_path17.resolve)(worktreeRoot, path58);
|
|
79396
|
+
if (baseCommit) {
|
|
79397
|
+
ensureSubmoduleCommitLocal(submoduleRepoPath, (0, import_path17.resolve)(baseRepoRoot, path58), baseCommit);
|
|
79398
|
+
}
|
|
79399
|
+
const markUndeterminable = () => {
|
|
79400
|
+
const unavailable = [];
|
|
79401
|
+
if (!baseCommit || !submoduleCommitPresent(submoduleRepoPath, baseCommit)) unavailable.push("base");
|
|
79402
|
+
if (!branchCommit || !submoduleCommitPresent(submoduleRepoPath, branchCommit)) unavailable.push("branch");
|
|
79403
|
+
sawUndeterminable = true;
|
|
79404
|
+
gitlinks.push({ path: path58, baseCommit, branchCommit, action: "skipped_commit_unavailable", unavailable });
|
|
79405
|
+
};
|
|
79406
|
+
if (!baseCommit || !branchCommit) {
|
|
79407
|
+
markUndeterminable();
|
|
79408
|
+
continue;
|
|
79409
|
+
}
|
|
79410
|
+
const divergence = classifySubmoduleDivergence(submoduleRepoPath, baseCommit, branchCommit);
|
|
79411
|
+
if (divergence === "undeterminable") {
|
|
79412
|
+
markUndeterminable();
|
|
79413
|
+
continue;
|
|
79414
|
+
}
|
|
79415
|
+
if (divergence !== "diverged") {
|
|
79416
|
+
gitlinks.push({ path: path58, baseCommit, branchCommit, action: "skipped_not_diverged" });
|
|
79417
|
+
continue;
|
|
79418
|
+
}
|
|
79419
|
+
sawDiverged = true;
|
|
79420
|
+
try {
|
|
79421
|
+
(0, import_node_child_process12.execFileSync)(GIT4, ["-c", "protocol.file.allow=always", "fetch", "-q", "origin"], { cwd: submoduleRepoPath, stdio: ["ignore", "ignore", "pipe"] });
|
|
79422
|
+
} catch {
|
|
79423
|
+
}
|
|
79424
|
+
const remoteMainRef = resolveSubmoduleRemoteMainRef(submoduleRepoPath);
|
|
79425
|
+
const publishedEquivalent = remoteMainRef ? findEquivalentPublishedSubmoduleCommit(submoduleRepoPath, baseCommit, branchCommit, remoteMainRef) : void 0;
|
|
79426
|
+
if (publishedEquivalent) {
|
|
79427
|
+
try {
|
|
79428
|
+
(0, import_node_child_process12.execFileSync)(GIT4, ["checkout", "-q", "--detach", publishedEquivalent], { cwd: submoduleRepoPath, stdio: ["ignore", "ignore", "pipe"] });
|
|
79429
|
+
} catch {
|
|
79430
|
+
}
|
|
79431
|
+
gitlinks.push({ path: path58, baseCommit, branchCommit, rebasedCommit: publishedEquivalent, action: "converged_to_published" });
|
|
79432
|
+
resolutions.push({ path: path58, baseCommit, branchCommit, rebasedCommit: publishedEquivalent });
|
|
79433
|
+
continue;
|
|
79434
|
+
}
|
|
79435
|
+
let rebasedCommit;
|
|
79436
|
+
try {
|
|
79437
|
+
(0, import_node_child_process12.execFileSync)(GIT4, ["checkout", "-q", "--detach", branchCommit], { cwd: submoduleRepoPath, stdio: ["ignore", "ignore", "pipe"] });
|
|
79438
|
+
(0, import_node_child_process12.execFileSync)(GIT4, ["rebase", baseCommit], { cwd: submoduleRepoPath, stdio: ["ignore", "pipe", "pipe"] });
|
|
79439
|
+
rebasedCommit = (0, import_node_child_process12.execFileSync)(GIT4, ["rev-parse", "HEAD"], { cwd: submoduleRepoPath, encoding: "utf8" }).trim();
|
|
79440
|
+
} catch {
|
|
79441
|
+
try {
|
|
79442
|
+
(0, import_node_child_process12.execFileSync)(GIT4, ["rebase", "--abort"], { cwd: submoduleRepoPath, stdio: "ignore" });
|
|
79443
|
+
} catch {
|
|
79444
|
+
}
|
|
79445
|
+
try {
|
|
79446
|
+
(0, import_node_child_process12.execFileSync)(GIT4, ["checkout", "-q", "--detach", branchCommit], { cwd: submoduleRepoPath, stdio: "ignore" });
|
|
79447
|
+
} catch {
|
|
79448
|
+
}
|
|
79449
|
+
gitlinks.push({ path: path58, baseCommit, branchCommit, action: "rebase_conflict" });
|
|
79450
|
+
return { converged: false, reason: "rebase_conflict", resolutions: [], gitlinks };
|
|
79451
|
+
}
|
|
79452
|
+
const branchWorkSurvived = (() => {
|
|
79453
|
+
if (!rebasedCommit) return false;
|
|
79454
|
+
if (rebasedCommit === branchCommit) return true;
|
|
79455
|
+
if (rebasedCommit === baseCommit) return false;
|
|
79456
|
+
try {
|
|
79457
|
+
const replayed = (0, import_node_child_process12.execFileSync)(GIT4, ["rev-list", "--count", `${baseCommit}..${rebasedCommit}`], {
|
|
79458
|
+
cwd: submoduleRepoPath,
|
|
79459
|
+
encoding: "utf8"
|
|
79460
|
+
}).trim();
|
|
79461
|
+
return Number.parseInt(replayed, 10) > 0;
|
|
79462
|
+
} catch {
|
|
79463
|
+
return false;
|
|
79464
|
+
}
|
|
79465
|
+
})();
|
|
79466
|
+
if (!branchWorkSurvived) {
|
|
79467
|
+
try {
|
|
79468
|
+
(0, import_node_child_process12.execFileSync)(GIT4, ["checkout", "-q", "--detach", branchCommit], { cwd: submoduleRepoPath, stdio: "ignore" });
|
|
79469
|
+
} catch {
|
|
79470
|
+
}
|
|
79471
|
+
gitlinks.push({ path: path58, baseCommit, branchCommit, rebasedCommit, action: "rebase_dropped_branch_commits" });
|
|
79472
|
+
return { converged: false, reason: "rebase_dropped_branch_commits", resolutions: [], gitlinks };
|
|
79473
|
+
}
|
|
79474
|
+
gitlinks.push({ path: path58, baseCommit, branchCommit, rebasedCommit, action: "rebased" });
|
|
79475
|
+
resolutions.push({ path: path58, baseCommit, branchCommit, rebasedCommit });
|
|
79476
|
+
}
|
|
79477
|
+
if (!sawDiverged) {
|
|
79478
|
+
const reason = sawUndeterminable ? "submodule_commit_unavailable" : "not_diverged";
|
|
79479
|
+
return { converged: false, reason, resolutions: [], gitlinks };
|
|
79480
|
+
}
|
|
79481
|
+
return { converged: resolutions.length > 0, resolutions, gitlinks };
|
|
79482
|
+
}
|
|
79483
|
+
function rootRebaseResolvingGitlinks(worktreeRoot, baseHead, resolutions) {
|
|
79484
|
+
const resolveByPath = new Map(resolutions.map((r) => [r.path, r.rebasedCommit]));
|
|
79485
|
+
const runRebase = (args) => {
|
|
79486
|
+
try {
|
|
79487
|
+
(0, import_node_child_process12.execFileSync)(GIT4, args, {
|
|
79488
|
+
cwd: worktreeRoot,
|
|
79489
|
+
stdio: ["ignore", "pipe", "pipe"],
|
|
79490
|
+
// A rebase editor prompt would hang; keep it non-interactive.
|
|
79491
|
+
env: { ...process.env, GIT_EDITOR: "true", GIT_SEQUENCE_EDITOR: "true" }
|
|
79492
|
+
});
|
|
79493
|
+
return { ok: true };
|
|
79494
|
+
} catch {
|
|
79495
|
+
return { ok: false };
|
|
79496
|
+
}
|
|
79497
|
+
};
|
|
79498
|
+
const unmergedPaths = () => {
|
|
79499
|
+
try {
|
|
79500
|
+
return (0, import_node_child_process12.execFileSync)(GIT4, ["diff", "--name-only", "--diff-filter=U"], { cwd: worktreeRoot, encoding: "utf8" }).split("\n").map((s2) => s2.trim()).filter(Boolean);
|
|
79501
|
+
} catch {
|
|
79502
|
+
return [];
|
|
79503
|
+
}
|
|
79504
|
+
};
|
|
79505
|
+
const abort = (reason, conflictPaths) => {
|
|
79506
|
+
try {
|
|
79507
|
+
(0, import_node_child_process12.execFileSync)(GIT4, ["rebase", "--abort"], { cwd: worktreeRoot, stdio: "ignore" });
|
|
79508
|
+
} catch {
|
|
79509
|
+
}
|
|
79510
|
+
return { ok: false, reason, conflictPaths };
|
|
79511
|
+
};
|
|
79512
|
+
let progress = runRebase(["rebase", baseHead]);
|
|
79513
|
+
let guard = 0;
|
|
79514
|
+
while (!progress.ok) {
|
|
79515
|
+
if (guard++ > 100) return abort("rebase_error");
|
|
79516
|
+
const conflicts = unmergedPaths();
|
|
79517
|
+
if (conflicts.length === 0) {
|
|
79518
|
+
return abort("rebase_error");
|
|
79519
|
+
}
|
|
79520
|
+
const unresolvable = conflicts.filter((p) => !resolveByPath.has(p));
|
|
79521
|
+
if (unresolvable.length > 0) {
|
|
79522
|
+
const unresolvableGitlink = unresolvable.some((p) => {
|
|
79523
|
+
try {
|
|
79524
|
+
const staged = (0, import_node_child_process12.execFileSync)(GIT4, ["ls-files", "--stage", "--", p], { cwd: worktreeRoot, encoding: "utf8" });
|
|
79525
|
+
return /^160000\s/m.test(staged);
|
|
79526
|
+
} catch {
|
|
79527
|
+
return false;
|
|
79528
|
+
}
|
|
79529
|
+
});
|
|
79530
|
+
const allGitlink = unresolvable.every((p) => {
|
|
79531
|
+
try {
|
|
79532
|
+
const staged = (0, import_node_child_process12.execFileSync)(GIT4, ["ls-files", "--stage", "--", p], { cwd: worktreeRoot, encoding: "utf8" });
|
|
79533
|
+
return /^160000\s/m.test(staged);
|
|
79534
|
+
} catch {
|
|
79535
|
+
return false;
|
|
79536
|
+
}
|
|
79537
|
+
});
|
|
79538
|
+
return abort(allGitlink && unresolvableGitlink ? "unexpected_gitlink" : "non_gitlink_conflict", conflicts);
|
|
79539
|
+
}
|
|
79540
|
+
for (const p of conflicts) {
|
|
79541
|
+
const commit = resolveByPath.get(p);
|
|
79542
|
+
try {
|
|
79543
|
+
(0, import_node_child_process12.execFileSync)(GIT4, ["checkout", "-q", "--detach", commit], { cwd: (0, import_path17.resolve)(worktreeRoot, p), stdio: "ignore" });
|
|
79544
|
+
} catch {
|
|
79545
|
+
}
|
|
79546
|
+
try {
|
|
79547
|
+
(0, import_node_child_process12.execFileSync)(GIT4, ["add", p], { cwd: worktreeRoot, stdio: "ignore" });
|
|
79548
|
+
} catch {
|
|
79549
|
+
return abort("rebase_error", conflicts);
|
|
79550
|
+
}
|
|
79551
|
+
}
|
|
79552
|
+
progress = runRebase(["rebase", "--continue"]);
|
|
79553
|
+
}
|
|
79554
|
+
let branchHead;
|
|
79555
|
+
try {
|
|
79556
|
+
branchHead = (0, import_node_child_process12.execFileSync)(GIT4, ["rev-parse", "HEAD"], { cwd: worktreeRoot, encoding: "utf8" }).trim();
|
|
79557
|
+
} catch {
|
|
79558
|
+
}
|
|
79559
|
+
return { ok: true, branchHead };
|
|
79560
|
+
}
|
|
79561
|
+
var fs49;
|
|
79562
|
+
var import_path17;
|
|
79563
|
+
var import_node_child_process12;
|
|
79564
|
+
var init_mesh_refine_submodule_converge = __esm2({
|
|
79565
|
+
"src/mesh/mesh-refine-submodule-converge.ts"() {
|
|
79566
|
+
"use strict";
|
|
79567
|
+
fs49 = __toESM2(require("fs"));
|
|
79568
|
+
import_path17 = require("path");
|
|
79569
|
+
import_node_child_process12 = require("child_process");
|
|
79570
|
+
init_mesh_refine_gitlink_utils();
|
|
79571
|
+
}
|
|
79572
|
+
});
|
|
79022
79573
|
function truncateValidationOutput(value) {
|
|
79023
79574
|
const text = typeof value === "string" ? value : value == null ? "" : String(value);
|
|
79024
79575
|
if (text.length <= REFINE_VALIDATION_SUMMARY_CHARS) return text;
|
|
@@ -79036,13 +79587,13 @@ ${tail}`;
|
|
|
79036
79587
|
}
|
|
79037
79588
|
function writeValidationFailureLog(workspace, index, candidate, streams, now = () => /* @__PURE__ */ new Date()) {
|
|
79038
79589
|
try {
|
|
79039
|
-
const dir = (0,
|
|
79040
|
-
|
|
79590
|
+
const dir = (0, import_path18.join)(workspace, REFINE_VALIDATION_LOG_DIR);
|
|
79591
|
+
fs50.mkdirSync(dir, { recursive: true });
|
|
79041
79592
|
const stamp = now().toISOString().replace(/[:.]/g, "-");
|
|
79042
|
-
const file2 = (0,
|
|
79593
|
+
const file2 = (0, import_path18.join)(dir, `refine-${stamp}-${index}.log`);
|
|
79043
79594
|
const asText = (v) => typeof v === "string" ? v : v == null ? "" : String(v);
|
|
79044
79595
|
const shown = candidate.displayCommand || [candidate.command, ...candidate.args || []].join(" ");
|
|
79045
|
-
|
|
79596
|
+
fs50.writeFileSync(
|
|
79046
79597
|
file2,
|
|
79047
79598
|
`# refine validation failure
|
|
79048
79599
|
# command: ${shown}
|
|
@@ -79116,18 +79667,18 @@ ${asText(streams.stderr)}
|
|
|
79116
79667
|
return { enabled: false };
|
|
79117
79668
|
}
|
|
79118
79669
|
async function computeGitPatchId(cwd, fromRef, toRef, excludePaths = []) {
|
|
79119
|
-
const { execFileSync:
|
|
79670
|
+
const { execFileSync: execFileSync15 } = await import("child_process");
|
|
79120
79671
|
const diffArgs = ["diff", "--patch", "--full-index", fromRef, toRef];
|
|
79121
79672
|
if (excludePaths.length > 0) {
|
|
79122
79673
|
diffArgs.push("--", ".", ...excludePaths.map((path58) => `:(exclude)${path58}`));
|
|
79123
79674
|
}
|
|
79124
|
-
const diff =
|
|
79675
|
+
const diff = execFileSync15(GIT4, diffArgs, {
|
|
79125
79676
|
cwd,
|
|
79126
79677
|
encoding: "utf8",
|
|
79127
79678
|
maxBuffer: REFINE_PATCH_EQUIVALENCE_OUTPUT_LIMIT_BYTES
|
|
79128
79679
|
});
|
|
79129
79680
|
if (!diff.trim()) return "";
|
|
79130
|
-
const patchId =
|
|
79681
|
+
const patchId = execFileSync15(GIT4, ["patch-id", "--stable"], {
|
|
79131
79682
|
cwd,
|
|
79132
79683
|
input: diff,
|
|
79133
79684
|
encoding: "utf8",
|
|
@@ -79138,8 +79689,8 @@ ${asText(streams.stderr)}
|
|
|
79138
79689
|
async function runMeshRefinePatchEquivalenceGate(repoRoot, baseHead, branchHead) {
|
|
79139
79690
|
const startedAt = Date.now();
|
|
79140
79691
|
try {
|
|
79141
|
-
const { execFileSync:
|
|
79142
|
-
const git3 = (args) =>
|
|
79692
|
+
const { execFileSync: execFileSync15 } = await import("child_process");
|
|
79693
|
+
const git3 = (args) => execFileSync15(GIT4, args, {
|
|
79143
79694
|
cwd: repoRoot,
|
|
79144
79695
|
encoding: "utf8",
|
|
79145
79696
|
maxBuffer: REFINE_PATCH_EQUIVALENCE_OUTPUT_LIMIT_BYTES
|
|
@@ -79240,7 +79791,7 @@ ${e?.stderr || ""}`
|
|
|
79240
79791
|
...autoPublish !== void 0 ? { autoPublishSubmoduleMainCommits: autoPublish } : {}
|
|
79241
79792
|
};
|
|
79242
79793
|
try {
|
|
79243
|
-
const git3 = (args) => (0,
|
|
79794
|
+
const git3 = (args) => (0, import_node_child_process13.execFileSync)(GIT4, args, {
|
|
79244
79795
|
cwd: repoRoot,
|
|
79245
79796
|
encoding: "utf8",
|
|
79246
79797
|
maxBuffer: REFINE_PATCH_EQUIVALENCE_OUTPUT_LIMIT_BYTES,
|
|
@@ -79294,7 +79845,7 @@ ${e?.stderr || ""}`
|
|
|
79294
79845
|
} catch {
|
|
79295
79846
|
continue;
|
|
79296
79847
|
}
|
|
79297
|
-
const submoduleRepo = (0,
|
|
79848
|
+
const submoduleRepo = (0, import_path18.join)(repoRoot, p);
|
|
79298
79849
|
let fastForward;
|
|
79299
79850
|
let reachableFromOriginMain;
|
|
79300
79851
|
if (branchCommit) {
|
|
@@ -79365,7 +79916,7 @@ ${e?.stderr || ""}`
|
|
|
79365
79916
|
}
|
|
79366
79917
|
function execGitOk(cwd, args) {
|
|
79367
79918
|
try {
|
|
79368
|
-
(0,
|
|
79919
|
+
(0, import_node_child_process13.execFileSync)(GIT4, args, { cwd, encoding: "utf8", maxBuffer: REFINE_PATCH_EQUIVALENCE_OUTPUT_LIMIT_BYTES, windowsHide: true });
|
|
79369
79920
|
return true;
|
|
79370
79921
|
} catch {
|
|
79371
79922
|
return false;
|
|
@@ -79374,8 +79925,8 @@ ${e?.stderr || ""}`
|
|
|
79374
79925
|
async function checkWorktreeChangesPatchEquivalentInRef(repoRoot, ref, worktreeHead) {
|
|
79375
79926
|
const startedAt = Date.now();
|
|
79376
79927
|
try {
|
|
79377
|
-
const { execFileSync:
|
|
79378
|
-
const git3 = (gitArgs) =>
|
|
79928
|
+
const { execFileSync: execFileSync15 } = await import("child_process");
|
|
79929
|
+
const git3 = (gitArgs) => execFileSync15(GIT4, gitArgs, {
|
|
79379
79930
|
cwd: repoRoot,
|
|
79380
79931
|
encoding: "utf8",
|
|
79381
79932
|
maxBuffer: REFINE_PATCH_EQUIVALENCE_OUTPUT_LIMIT_BYTES
|
|
@@ -79438,8 +79989,8 @@ ${mergeTreeErr?.stderr || ""}`;
|
|
|
79438
79989
|
async function runMeshRefineEffectiveDiffGate(repoRoot, baseHead, branchHead) {
|
|
79439
79990
|
const startedAt = Date.now();
|
|
79440
79991
|
try {
|
|
79441
|
-
const { execFileSync:
|
|
79442
|
-
const git3 = (args, opts) =>
|
|
79992
|
+
const { execFileSync: execFileSync15 } = await import("child_process");
|
|
79993
|
+
const git3 = (args, opts) => execFileSync15(GIT4, args, {
|
|
79443
79994
|
cwd: opts?.cwd || repoRoot,
|
|
79444
79995
|
encoding: "utf8",
|
|
79445
79996
|
maxBuffer: REFINE_PATCH_EQUIVALENCE_OUTPUT_LIMIT_BYTES
|
|
@@ -79513,45 +80064,8 @@ ${mergeTreeErr?.stderr || ""}`;
|
|
|
79513
80064
|
]
|
|
79514
80065
|
};
|
|
79515
80066
|
}
|
|
79516
|
-
function readChangedGitlinkPaths(repoRoot, fromRef, toRef) {
|
|
79517
|
-
try {
|
|
79518
|
-
const output = (0, import_node_child_process11.execFileSync)(GIT4, ["diff", "--raw", "--no-abbrev", fromRef, toRef], {
|
|
79519
|
-
cwd: repoRoot,
|
|
79520
|
-
encoding: "utf8",
|
|
79521
|
-
maxBuffer: REFINE_PATCH_EQUIVALENCE_OUTPUT_LIMIT_BYTES
|
|
79522
|
-
});
|
|
79523
|
-
const paths = /* @__PURE__ */ new Set();
|
|
79524
|
-
for (const line of output.split("\n")) {
|
|
79525
|
-
if (!line.trim()) continue;
|
|
79526
|
-
const metaAndPath = line.split(" ");
|
|
79527
|
-
const meta3 = metaAndPath[0] || "";
|
|
79528
|
-
const path58 = metaAndPath[metaAndPath.length - 1]?.trim();
|
|
79529
|
-
if (!path58) continue;
|
|
79530
|
-
const parts = meta3.split(/\s+/);
|
|
79531
|
-
if (parts[0]?.includes("160000") || parts[1]?.includes("160000")) {
|
|
79532
|
-
paths.add(path58);
|
|
79533
|
-
}
|
|
79534
|
-
}
|
|
79535
|
-
return [...paths].sort();
|
|
79536
|
-
} catch {
|
|
79537
|
-
return [];
|
|
79538
|
-
}
|
|
79539
|
-
}
|
|
79540
|
-
function readTreeObject(repoRoot, ref, path58) {
|
|
79541
|
-
try {
|
|
79542
|
-
const output = (0, import_node_child_process11.execFileSync)(GIT4, ["ls-tree", ref, "--", path58], {
|
|
79543
|
-
cwd: repoRoot,
|
|
79544
|
-
encoding: "utf8",
|
|
79545
|
-
maxBuffer: 1024 * 1024
|
|
79546
|
-
}).trim();
|
|
79547
|
-
const match = output.match(/\bcommit\s+([0-9a-f]{40})\b/i);
|
|
79548
|
-
return match?.[1];
|
|
79549
|
-
} catch {
|
|
79550
|
-
return void 0;
|
|
79551
|
-
}
|
|
79552
|
-
}
|
|
79553
80067
|
function resolveGitDir(repoRoot) {
|
|
79554
|
-
const out = (0,
|
|
80068
|
+
const out = (0, import_node_child_process13.execFileSync)(GIT4, ["rev-parse", "--absolute-git-dir"], {
|
|
79555
80069
|
cwd: repoRoot,
|
|
79556
80070
|
encoding: "utf8",
|
|
79557
80071
|
maxBuffer: 1024 * 1024
|
|
@@ -79562,10 +80076,10 @@ ${mergeTreeErr?.stderr || ""}`;
|
|
|
79562
80076
|
if (!baseCommit || !branchCommit) return false;
|
|
79563
80077
|
if (baseCommit === branchCommit) return true;
|
|
79564
80078
|
try {
|
|
79565
|
-
if (!
|
|
79566
|
-
(0,
|
|
79567
|
-
(0,
|
|
79568
|
-
(0,
|
|
80079
|
+
if (!fs50.existsSync(submoduleRepoPath)) return false;
|
|
80080
|
+
(0, import_node_child_process13.execFileSync)(GIT4, ["cat-file", "-e", `${baseCommit}^{commit}`], { cwd: submoduleRepoPath, stdio: "ignore" });
|
|
80081
|
+
(0, import_node_child_process13.execFileSync)(GIT4, ["cat-file", "-e", `${branchCommit}^{commit}`], { cwd: submoduleRepoPath, stdio: "ignore" });
|
|
80082
|
+
(0, import_node_child_process13.execFileSync)(GIT4, ["merge-base", "--is-ancestor", baseCommit, branchCommit], { cwd: submoduleRepoPath, stdio: "ignore" });
|
|
79569
80083
|
return true;
|
|
79570
80084
|
} catch {
|
|
79571
80085
|
return false;
|
|
@@ -79573,7 +80087,7 @@ ${mergeTreeErr?.stderr || ""}`;
|
|
|
79573
80087
|
}
|
|
79574
80088
|
function readChangedPathKinds(repoRoot, fromRef, toRef) {
|
|
79575
80089
|
try {
|
|
79576
|
-
const output = (0,
|
|
80090
|
+
const output = (0, import_node_child_process13.execFileSync)(GIT4, ["diff", "--raw", "--no-abbrev", fromRef, toRef], {
|
|
79577
80091
|
cwd: repoRoot,
|
|
79578
80092
|
encoding: "utf8",
|
|
79579
80093
|
maxBuffer: REFINE_PATCH_EQUIVALENCE_OUTPUT_LIMIT_BYTES
|
|
@@ -79601,7 +80115,7 @@ ${mergeTreeErr?.stderr || ""}`;
|
|
|
79601
80115
|
const baseCommit = readTreeObject(repoRoot, baseHead, path58);
|
|
79602
80116
|
const branchCommit = readTreeObject(repoRoot, branchHead, path58);
|
|
79603
80117
|
if (!baseCommit || !branchCommit) return false;
|
|
79604
|
-
return isSubmoduleFastForward((0,
|
|
80118
|
+
return isSubmoduleFastForward((0, import_path18.resolve)(repoRoot, path58), baseCommit, branchCommit);
|
|
79605
80119
|
});
|
|
79606
80120
|
}
|
|
79607
80121
|
function collectTrivialFastForwardGitlinkResolutions(worktreeRoot, baseRepoRoot, baseHead, branchHead) {
|
|
@@ -79610,8 +80124,8 @@ ${mergeTreeErr?.stderr || ""}`;
|
|
|
79610
80124
|
const baseCommit = readTreeObject(baseRepoRoot, baseHead, path58);
|
|
79611
80125
|
const branchCommit = readTreeObject(worktreeRoot, branchHead, path58);
|
|
79612
80126
|
if (!baseCommit || !branchCommit) continue;
|
|
79613
|
-
const submoduleRepoPath = (0,
|
|
79614
|
-
ensureSubmoduleCommitLocal(submoduleRepoPath, (0,
|
|
80127
|
+
const submoduleRepoPath = (0, import_path18.resolve)(worktreeRoot, path58);
|
|
80128
|
+
ensureSubmoduleCommitLocal(submoduleRepoPath, (0, import_path18.resolve)(baseRepoRoot, path58), baseCommit);
|
|
79615
80129
|
if (baseCommit === branchCommit) {
|
|
79616
80130
|
continue;
|
|
79617
80131
|
}
|
|
@@ -79623,254 +80137,11 @@ ${mergeTreeErr?.stderr || ""}`;
|
|
|
79623
80137
|
}
|
|
79624
80138
|
return resolutions;
|
|
79625
80139
|
}
|
|
79626
|
-
function isSubmoduleDivergedSibling(submoduleRepoPath, baseCommit, branchCommit) {
|
|
79627
|
-
if (!baseCommit || !branchCommit || baseCommit === branchCommit) return false;
|
|
79628
|
-
try {
|
|
79629
|
-
if (!fs48.existsSync(submoduleRepoPath)) return false;
|
|
79630
|
-
(0, import_node_child_process11.execFileSync)(GIT4, ["cat-file", "-e", `${baseCommit}^{commit}`], { cwd: submoduleRepoPath, stdio: "ignore" });
|
|
79631
|
-
(0, import_node_child_process11.execFileSync)(GIT4, ["cat-file", "-e", `${branchCommit}^{commit}`], { cwd: submoduleRepoPath, stdio: "ignore" });
|
|
79632
|
-
} catch {
|
|
79633
|
-
return false;
|
|
79634
|
-
}
|
|
79635
|
-
try {
|
|
79636
|
-
(0, import_node_child_process11.execFileSync)(GIT4, ["merge-base", "--is-ancestor", baseCommit, branchCommit], { cwd: submoduleRepoPath, stdio: "ignore" });
|
|
79637
|
-
return false;
|
|
79638
|
-
} catch {
|
|
79639
|
-
}
|
|
79640
|
-
try {
|
|
79641
|
-
(0, import_node_child_process11.execFileSync)(GIT4, ["merge-base", "--is-ancestor", branchCommit, baseCommit], { cwd: submoduleRepoPath, stdio: "ignore" });
|
|
79642
|
-
return false;
|
|
79643
|
-
} catch {
|
|
79644
|
-
}
|
|
79645
|
-
try {
|
|
79646
|
-
const mb = (0, import_node_child_process11.execFileSync)(GIT4, ["merge-base", baseCommit, branchCommit], { cwd: submoduleRepoPath, encoding: "utf8" }).trim();
|
|
79647
|
-
return !!mb;
|
|
79648
|
-
} catch {
|
|
79649
|
-
return false;
|
|
79650
|
-
}
|
|
79651
|
-
}
|
|
79652
|
-
function resolveSubmoduleRemoteMainRef(submoduleRepoPath) {
|
|
79653
|
-
try {
|
|
79654
|
-
const sym = (0, import_node_child_process11.execFileSync)(GIT4, ["symbolic-ref", "-q", "refs/remotes/origin/HEAD"], { cwd: submoduleRepoPath, encoding: "utf8" }).trim();
|
|
79655
|
-
if (sym) return sym;
|
|
79656
|
-
} catch {
|
|
79657
|
-
}
|
|
79658
|
-
for (const branch of ["main", "master"]) {
|
|
79659
|
-
try {
|
|
79660
|
-
(0, import_node_child_process11.execFileSync)(GIT4, ["rev-parse", "--verify", "-q", `refs/remotes/origin/${branch}`], { cwd: submoduleRepoPath, stdio: ["ignore", "pipe", "pipe"] });
|
|
79661
|
-
return `refs/remotes/origin/${branch}`;
|
|
79662
|
-
} catch {
|
|
79663
|
-
}
|
|
79664
|
-
}
|
|
79665
|
-
return void 0;
|
|
79666
|
-
}
|
|
79667
|
-
function findEquivalentPublishedSubmoduleCommit(submoduleRepoPath, baseCommit, branchCommit, remoteRef) {
|
|
79668
|
-
try {
|
|
79669
|
-
const mergeTreeOut = (0, import_node_child_process11.execFileSync)(GIT4, ["merge-tree", "--write-tree", baseCommit, branchCommit], {
|
|
79670
|
-
cwd: submoduleRepoPath,
|
|
79671
|
-
encoding: "utf8",
|
|
79672
|
-
stdio: ["ignore", "pipe", "pipe"]
|
|
79673
|
-
});
|
|
79674
|
-
const mergedTree = mergeTreeOut.trim().split(/\s+/)[0] || "";
|
|
79675
|
-
if (!mergedTree) return void 0;
|
|
79676
|
-
const candidates = (0, import_node_child_process11.execFileSync)(GIT4, ["rev-list", "--max-count=100", remoteRef, "--not", baseCommit], {
|
|
79677
|
-
cwd: submoduleRepoPath,
|
|
79678
|
-
encoding: "utf8"
|
|
79679
|
-
}).split("\n").map((s2) => s2.trim()).filter(Boolean);
|
|
79680
|
-
for (const candidate of candidates) {
|
|
79681
|
-
try {
|
|
79682
|
-
(0, import_node_child_process11.execFileSync)(GIT4, ["merge-base", "--is-ancestor", baseCommit, candidate], { cwd: submoduleRepoPath, stdio: "ignore" });
|
|
79683
|
-
} catch {
|
|
79684
|
-
continue;
|
|
79685
|
-
}
|
|
79686
|
-
const tree = (0, import_node_child_process11.execFileSync)(GIT4, ["rev-parse", `${candidate}^{tree}`], { cwd: submoduleRepoPath, encoding: "utf8" }).trim();
|
|
79687
|
-
if (tree === mergedTree) return candidate;
|
|
79688
|
-
}
|
|
79689
|
-
} catch {
|
|
79690
|
-
}
|
|
79691
|
-
return void 0;
|
|
79692
|
-
}
|
|
79693
|
-
function ensureSubmoduleCommitLocal(submoduleRepoPath, baseSubmoduleRepoPath, commit) {
|
|
79694
|
-
if (!commit) return;
|
|
79695
|
-
try {
|
|
79696
|
-
(0, import_node_child_process11.execFileSync)(GIT4, ["cat-file", "-e", `${commit}^{commit}`], { cwd: submoduleRepoPath, stdio: "ignore" });
|
|
79697
|
-
return;
|
|
79698
|
-
} catch {
|
|
79699
|
-
}
|
|
79700
|
-
try {
|
|
79701
|
-
if (!fs48.existsSync(submoduleRepoPath) || !fs48.existsSync(baseSubmoduleRepoPath)) return;
|
|
79702
|
-
(0, import_node_child_process11.execFileSync)(GIT4, ["-c", "protocol.file.allow=always", "fetch", "-q", baseSubmoduleRepoPath, "+refs/heads/*:refs/adhdev-refine-base/*"], {
|
|
79703
|
-
cwd: submoduleRepoPath,
|
|
79704
|
-
stdio: ["ignore", "ignore", "pipe"]
|
|
79705
|
-
});
|
|
79706
|
-
} catch {
|
|
79707
|
-
}
|
|
79708
|
-
}
|
|
79709
|
-
function convergeDivergedSubmoduleGitlinks(worktreeRoot, baseRepoRoot, baseHead, branchHead) {
|
|
79710
|
-
const changed = readChangedGitlinkPaths(worktreeRoot, baseHead, branchHead);
|
|
79711
|
-
if (changed.length === 0) {
|
|
79712
|
-
return { converged: false, reason: "no_changed_gitlinks", resolutions: [], gitlinks: [] };
|
|
79713
|
-
}
|
|
79714
|
-
const gitlinks = [];
|
|
79715
|
-
const resolutions = [];
|
|
79716
|
-
let sawDiverged = false;
|
|
79717
|
-
for (const path58 of changed) {
|
|
79718
|
-
const baseCommit = readTreeObject(baseRepoRoot, baseHead, path58);
|
|
79719
|
-
const branchCommit = readTreeObject(worktreeRoot, branchHead, path58);
|
|
79720
|
-
const submoduleRepoPath = (0, import_path17.resolve)(worktreeRoot, path58);
|
|
79721
|
-
if (baseCommit) {
|
|
79722
|
-
ensureSubmoduleCommitLocal(submoduleRepoPath, (0, import_path17.resolve)(baseRepoRoot, path58), baseCommit);
|
|
79723
|
-
}
|
|
79724
|
-
if (!baseCommit || !branchCommit || !isSubmoduleDivergedSibling(submoduleRepoPath, baseCommit, branchCommit)) {
|
|
79725
|
-
gitlinks.push({ path: path58, baseCommit, branchCommit, action: "skipped_not_diverged" });
|
|
79726
|
-
continue;
|
|
79727
|
-
}
|
|
79728
|
-
sawDiverged = true;
|
|
79729
|
-
try {
|
|
79730
|
-
(0, import_node_child_process11.execFileSync)(GIT4, ["-c", "protocol.file.allow=always", "fetch", "-q", "origin"], { cwd: submoduleRepoPath, stdio: ["ignore", "ignore", "pipe"] });
|
|
79731
|
-
} catch {
|
|
79732
|
-
}
|
|
79733
|
-
const remoteMainRef = resolveSubmoduleRemoteMainRef(submoduleRepoPath);
|
|
79734
|
-
const publishedEquivalent = remoteMainRef ? findEquivalentPublishedSubmoduleCommit(submoduleRepoPath, baseCommit, branchCommit, remoteMainRef) : void 0;
|
|
79735
|
-
if (publishedEquivalent) {
|
|
79736
|
-
try {
|
|
79737
|
-
(0, import_node_child_process11.execFileSync)(GIT4, ["checkout", "-q", "--detach", publishedEquivalent], { cwd: submoduleRepoPath, stdio: ["ignore", "ignore", "pipe"] });
|
|
79738
|
-
} catch {
|
|
79739
|
-
}
|
|
79740
|
-
gitlinks.push({ path: path58, baseCommit, branchCommit, rebasedCommit: publishedEquivalent, action: "converged_to_published" });
|
|
79741
|
-
resolutions.push({ path: path58, baseCommit, branchCommit, rebasedCommit: publishedEquivalent });
|
|
79742
|
-
continue;
|
|
79743
|
-
}
|
|
79744
|
-
let rebasedCommit;
|
|
79745
|
-
try {
|
|
79746
|
-
(0, import_node_child_process11.execFileSync)(GIT4, ["checkout", "-q", "--detach", branchCommit], { cwd: submoduleRepoPath, stdio: ["ignore", "ignore", "pipe"] });
|
|
79747
|
-
(0, import_node_child_process11.execFileSync)(GIT4, ["rebase", baseCommit], { cwd: submoduleRepoPath, stdio: ["ignore", "pipe", "pipe"] });
|
|
79748
|
-
rebasedCommit = (0, import_node_child_process11.execFileSync)(GIT4, ["rev-parse", "HEAD"], { cwd: submoduleRepoPath, encoding: "utf8" }).trim();
|
|
79749
|
-
} catch {
|
|
79750
|
-
try {
|
|
79751
|
-
(0, import_node_child_process11.execFileSync)(GIT4, ["rebase", "--abort"], { cwd: submoduleRepoPath, stdio: "ignore" });
|
|
79752
|
-
} catch {
|
|
79753
|
-
}
|
|
79754
|
-
try {
|
|
79755
|
-
(0, import_node_child_process11.execFileSync)(GIT4, ["checkout", "-q", "--detach", branchCommit], { cwd: submoduleRepoPath, stdio: "ignore" });
|
|
79756
|
-
} catch {
|
|
79757
|
-
}
|
|
79758
|
-
gitlinks.push({ path: path58, baseCommit, branchCommit, action: "rebase_conflict" });
|
|
79759
|
-
return { converged: false, reason: "rebase_conflict", resolutions: [], gitlinks };
|
|
79760
|
-
}
|
|
79761
|
-
const branchWorkSurvived = (() => {
|
|
79762
|
-
if (!rebasedCommit) return false;
|
|
79763
|
-
if (rebasedCommit === branchCommit) return true;
|
|
79764
|
-
if (rebasedCommit === baseCommit) return false;
|
|
79765
|
-
try {
|
|
79766
|
-
const replayed = (0, import_node_child_process11.execFileSync)(GIT4, ["rev-list", "--count", `${baseCommit}..${rebasedCommit}`], {
|
|
79767
|
-
cwd: submoduleRepoPath,
|
|
79768
|
-
encoding: "utf8"
|
|
79769
|
-
}).trim();
|
|
79770
|
-
return Number.parseInt(replayed, 10) > 0;
|
|
79771
|
-
} catch {
|
|
79772
|
-
return false;
|
|
79773
|
-
}
|
|
79774
|
-
})();
|
|
79775
|
-
if (!branchWorkSurvived) {
|
|
79776
|
-
try {
|
|
79777
|
-
(0, import_node_child_process11.execFileSync)(GIT4, ["checkout", "-q", "--detach", branchCommit], { cwd: submoduleRepoPath, stdio: "ignore" });
|
|
79778
|
-
} catch {
|
|
79779
|
-
}
|
|
79780
|
-
gitlinks.push({ path: path58, baseCommit, branchCommit, rebasedCommit, action: "rebase_dropped_branch_commits" });
|
|
79781
|
-
return { converged: false, reason: "rebase_dropped_branch_commits", resolutions: [], gitlinks };
|
|
79782
|
-
}
|
|
79783
|
-
gitlinks.push({ path: path58, baseCommit, branchCommit, rebasedCommit, action: "rebased" });
|
|
79784
|
-
resolutions.push({ path: path58, baseCommit, branchCommit, rebasedCommit });
|
|
79785
|
-
}
|
|
79786
|
-
if (!sawDiverged) {
|
|
79787
|
-
return { converged: false, reason: "not_diverged", resolutions: [], gitlinks };
|
|
79788
|
-
}
|
|
79789
|
-
return { converged: resolutions.length > 0, resolutions, gitlinks };
|
|
79790
|
-
}
|
|
79791
|
-
function rootRebaseResolvingGitlinks(worktreeRoot, baseHead, resolutions) {
|
|
79792
|
-
const resolveByPath = new Map(resolutions.map((r) => [r.path, r.rebasedCommit]));
|
|
79793
|
-
const runRebase = (args) => {
|
|
79794
|
-
try {
|
|
79795
|
-
(0, import_node_child_process11.execFileSync)(GIT4, args, {
|
|
79796
|
-
cwd: worktreeRoot,
|
|
79797
|
-
stdio: ["ignore", "pipe", "pipe"],
|
|
79798
|
-
// A rebase editor prompt would hang; keep it non-interactive.
|
|
79799
|
-
env: { ...process.env, GIT_EDITOR: "true", GIT_SEQUENCE_EDITOR: "true" }
|
|
79800
|
-
});
|
|
79801
|
-
return { ok: true };
|
|
79802
|
-
} catch {
|
|
79803
|
-
return { ok: false };
|
|
79804
|
-
}
|
|
79805
|
-
};
|
|
79806
|
-
const unmergedPaths = () => {
|
|
79807
|
-
try {
|
|
79808
|
-
return (0, import_node_child_process11.execFileSync)(GIT4, ["diff", "--name-only", "--diff-filter=U"], { cwd: worktreeRoot, encoding: "utf8" }).split("\n").map((s2) => s2.trim()).filter(Boolean);
|
|
79809
|
-
} catch {
|
|
79810
|
-
return [];
|
|
79811
|
-
}
|
|
79812
|
-
};
|
|
79813
|
-
const abort = (reason, conflictPaths) => {
|
|
79814
|
-
try {
|
|
79815
|
-
(0, import_node_child_process11.execFileSync)(GIT4, ["rebase", "--abort"], { cwd: worktreeRoot, stdio: "ignore" });
|
|
79816
|
-
} catch {
|
|
79817
|
-
}
|
|
79818
|
-
return { ok: false, reason, conflictPaths };
|
|
79819
|
-
};
|
|
79820
|
-
let progress = runRebase(["rebase", baseHead]);
|
|
79821
|
-
let guard = 0;
|
|
79822
|
-
while (!progress.ok) {
|
|
79823
|
-
if (guard++ > 100) return abort("rebase_error");
|
|
79824
|
-
const conflicts = unmergedPaths();
|
|
79825
|
-
if (conflicts.length === 0) {
|
|
79826
|
-
return abort("rebase_error");
|
|
79827
|
-
}
|
|
79828
|
-
const unresolvable = conflicts.filter((p) => !resolveByPath.has(p));
|
|
79829
|
-
if (unresolvable.length > 0) {
|
|
79830
|
-
const unresolvableGitlink = unresolvable.some((p) => {
|
|
79831
|
-
try {
|
|
79832
|
-
const staged = (0, import_node_child_process11.execFileSync)(GIT4, ["ls-files", "--stage", "--", p], { cwd: worktreeRoot, encoding: "utf8" });
|
|
79833
|
-
return /^160000\s/m.test(staged);
|
|
79834
|
-
} catch {
|
|
79835
|
-
return false;
|
|
79836
|
-
}
|
|
79837
|
-
});
|
|
79838
|
-
const allGitlink = unresolvable.every((p) => {
|
|
79839
|
-
try {
|
|
79840
|
-
const staged = (0, import_node_child_process11.execFileSync)(GIT4, ["ls-files", "--stage", "--", p], { cwd: worktreeRoot, encoding: "utf8" });
|
|
79841
|
-
return /^160000\s/m.test(staged);
|
|
79842
|
-
} catch {
|
|
79843
|
-
return false;
|
|
79844
|
-
}
|
|
79845
|
-
});
|
|
79846
|
-
return abort(allGitlink && unresolvableGitlink ? "unexpected_gitlink" : "non_gitlink_conflict", conflicts);
|
|
79847
|
-
}
|
|
79848
|
-
for (const p of conflicts) {
|
|
79849
|
-
const commit = resolveByPath.get(p);
|
|
79850
|
-
try {
|
|
79851
|
-
(0, import_node_child_process11.execFileSync)(GIT4, ["checkout", "-q", "--detach", commit], { cwd: (0, import_path17.resolve)(worktreeRoot, p), stdio: "ignore" });
|
|
79852
|
-
} catch {
|
|
79853
|
-
}
|
|
79854
|
-
try {
|
|
79855
|
-
(0, import_node_child_process11.execFileSync)(GIT4, ["add", p], { cwd: worktreeRoot, stdio: "ignore" });
|
|
79856
|
-
} catch {
|
|
79857
|
-
return abort("rebase_error", conflicts);
|
|
79858
|
-
}
|
|
79859
|
-
}
|
|
79860
|
-
progress = runRebase(["rebase", "--continue"]);
|
|
79861
|
-
}
|
|
79862
|
-
let branchHead;
|
|
79863
|
-
try {
|
|
79864
|
-
branchHead = (0, import_node_child_process11.execFileSync)(GIT4, ["rev-parse", "HEAD"], { cwd: worktreeRoot, encoding: "utf8" }).trim();
|
|
79865
|
-
} catch {
|
|
79866
|
-
}
|
|
79867
|
-
return { ok: true, branchHead };
|
|
79868
|
-
}
|
|
79869
80140
|
function evaluateGitlinkTrivialFastForward(repoRoot, baseHead, branchHead) {
|
|
79870
80141
|
const changedGitlinks = readChangedGitlinkPaths(repoRoot, baseHead, branchHead).map((path58) => {
|
|
79871
80142
|
const baseCommit = readTreeObject(repoRoot, baseHead, path58);
|
|
79872
80143
|
const branchCommit = readTreeObject(repoRoot, branchHead, path58);
|
|
79873
|
-
const submoduleRepoPath = (0,
|
|
80144
|
+
const submoduleRepoPath = (0, import_path18.resolve)(repoRoot, path58);
|
|
79874
80145
|
const fastForward = !!baseCommit && !!branchCommit && isSubmoduleFastForward(submoduleRepoPath, baseCommit, branchCommit);
|
|
79875
80146
|
return { path: path58, baseCommit, branchCommit, fastForward };
|
|
79876
80147
|
});
|
|
@@ -79887,7 +80158,7 @@ ${mergeTreeErr?.stderr || ""}`;
|
|
|
79887
80158
|
}
|
|
79888
80159
|
let mergeBase = "";
|
|
79889
80160
|
try {
|
|
79890
|
-
mergeBase = (0,
|
|
80161
|
+
mergeBase = (0, import_node_child_process13.execFileSync)(GIT4, ["merge-base", baseHead, branchHead], {
|
|
79891
80162
|
cwd: repoRoot,
|
|
79892
80163
|
encoding: "utf8",
|
|
79893
80164
|
maxBuffer: 1024 * 1024
|
|
@@ -79917,7 +80188,7 @@ ${mergeTreeErr?.stderr || ""}`;
|
|
|
79917
80188
|
}
|
|
79918
80189
|
function buildTreeWithGitlinksEqualized(repoRoot, commitish, paths, placeholderCommit) {
|
|
79919
80190
|
try {
|
|
79920
|
-
const tree = (0,
|
|
80191
|
+
const tree = (0, import_node_child_process13.execFileSync)(GIT4, ["rev-parse", `${commitish}^{tree}`], {
|
|
79921
80192
|
cwd: repoRoot,
|
|
79922
80193
|
encoding: "utf8",
|
|
79923
80194
|
maxBuffer: 1024 * 1024
|
|
@@ -79925,11 +80196,11 @@ ${mergeTreeErr?.stderr || ""}`;
|
|
|
79925
80196
|
if (!tree) return void 0;
|
|
79926
80197
|
const updates = paths.map((path58) => `160000 commit ${placeholderCommit} ${path58}`).join("\n");
|
|
79927
80198
|
if (!updates) return tree;
|
|
79928
|
-
const tmpIndex = (0,
|
|
80199
|
+
const tmpIndex = (0, import_path18.join)(resolveGitDir(repoRoot), `adhdev-refine-eq-${commitish.slice(0, 12)}.index`);
|
|
79929
80200
|
const env2 = { ...process.env, GIT_INDEX_FILE: tmpIndex };
|
|
79930
80201
|
try {
|
|
79931
|
-
(0,
|
|
79932
|
-
(0,
|
|
80202
|
+
(0, import_node_child_process13.execFileSync)(GIT4, ["read-tree", tree], { cwd: repoRoot, env: env2, stdio: "ignore" });
|
|
80203
|
+
(0, import_node_child_process13.execFileSync)(GIT4, ["update-index", "--index-info"], {
|
|
79933
80204
|
cwd: repoRoot,
|
|
79934
80205
|
env: env2,
|
|
79935
80206
|
input: `${updates}
|
|
@@ -79937,11 +80208,11 @@ ${mergeTreeErr?.stderr || ""}`;
|
|
|
79937
80208
|
encoding: "utf8",
|
|
79938
80209
|
stdio: ["pipe", "ignore", "ignore"]
|
|
79939
80210
|
});
|
|
79940
|
-
const newTree = (0,
|
|
80211
|
+
const newTree = (0, import_node_child_process13.execFileSync)(GIT4, ["write-tree"], { cwd: repoRoot, env: env2, encoding: "utf8" }).trim();
|
|
79941
80212
|
return newTree || void 0;
|
|
79942
80213
|
} finally {
|
|
79943
80214
|
try {
|
|
79944
|
-
|
|
80215
|
+
fs50.rmSync(tmpIndex, { force: true });
|
|
79945
80216
|
} catch {
|
|
79946
80217
|
}
|
|
79947
80218
|
}
|
|
@@ -79953,7 +80224,7 @@ ${mergeTreeErr?.stderr || ""}`;
|
|
|
79953
80224
|
try {
|
|
79954
80225
|
const branchGitlinks = gitlinks.filter((entry) => entry.branchCommit);
|
|
79955
80226
|
const gitlinkPaths = branchGitlinks.map((entry) => entry.path);
|
|
79956
|
-
const mergeBase = (0,
|
|
80227
|
+
const mergeBase = (0, import_node_child_process13.execFileSync)(GIT4, ["merge-base", baseHead, branchHead], {
|
|
79957
80228
|
cwd: repoRoot,
|
|
79958
80229
|
encoding: "utf8",
|
|
79959
80230
|
maxBuffer: 1024 * 1024
|
|
@@ -79966,22 +80237,22 @@ ${mergeTreeErr?.stderr || ""}`;
|
|
|
79966
80237
|
const theirsEqTree = buildTreeWithGitlinksEqualized(repoRoot, branchHead, gitlinkPaths, placeholder);
|
|
79967
80238
|
if (baseEqTree && oursEqTree && theirsEqTree) {
|
|
79968
80239
|
try {
|
|
79969
|
-
const baseEqCommit = (0,
|
|
80240
|
+
const baseEqCommit = (0, import_node_child_process13.execFileSync)(GIT4, ["commit-tree", baseEqTree, "-m", "refine-ff-base"], {
|
|
79970
80241
|
cwd: repoRoot,
|
|
79971
80242
|
encoding: "utf8",
|
|
79972
80243
|
maxBuffer: 1024 * 1024
|
|
79973
80244
|
}).trim();
|
|
79974
|
-
const oursEqCommit = (0,
|
|
80245
|
+
const oursEqCommit = (0, import_node_child_process13.execFileSync)(GIT4, ["commit-tree", oursEqTree, "-p", baseEqCommit, "-m", "refine-ff-ours"], {
|
|
79975
80246
|
cwd: repoRoot,
|
|
79976
80247
|
encoding: "utf8",
|
|
79977
80248
|
maxBuffer: 1024 * 1024
|
|
79978
80249
|
}).trim();
|
|
79979
|
-
const theirsEqCommit = (0,
|
|
80250
|
+
const theirsEqCommit = (0, import_node_child_process13.execFileSync)(GIT4, ["commit-tree", theirsEqTree, "-p", baseEqCommit, "-m", "refine-ff-theirs"], {
|
|
79980
80251
|
cwd: repoRoot,
|
|
79981
80252
|
encoding: "utf8",
|
|
79982
80253
|
maxBuffer: 1024 * 1024
|
|
79983
80254
|
}).trim();
|
|
79984
|
-
const mergeOut = (0,
|
|
80255
|
+
const mergeOut = (0, import_node_child_process13.execFileSync)(GIT4, ["merge-tree", "--write-tree", oursEqCommit, theirsEqCommit], {
|
|
79985
80256
|
cwd: repoRoot,
|
|
79986
80257
|
encoding: "utf8",
|
|
79987
80258
|
maxBuffer: REFINE_PATCH_EQUIVALENCE_OUTPUT_LIMIT_BYTES
|
|
@@ -79992,7 +80263,7 @@ ${mergeTreeErr?.stderr || ""}`;
|
|
|
79992
80263
|
}
|
|
79993
80264
|
}
|
|
79994
80265
|
}
|
|
79995
|
-
const contentTree = mergedContentTree || (0,
|
|
80266
|
+
const contentTree = mergedContentTree || (0, import_node_child_process13.execFileSync)(GIT4, ["rev-parse", `${baseHead}^{tree}`], {
|
|
79996
80267
|
cwd: repoRoot,
|
|
79997
80268
|
encoding: "utf8",
|
|
79998
80269
|
maxBuffer: 1024 * 1024
|
|
@@ -80000,11 +80271,11 @@ ${mergeTreeErr?.stderr || ""}`;
|
|
|
80000
80271
|
if (!contentTree) return void 0;
|
|
80001
80272
|
const updates = branchGitlinks.map((entry) => `160000 commit ${entry.branchCommit} ${entry.path}`).join("\n");
|
|
80002
80273
|
if (!updates) return contentTree;
|
|
80003
|
-
const tmpIndex = (0,
|
|
80274
|
+
const tmpIndex = (0, import_path18.join)(resolveGitDir(repoRoot), `adhdev-refine-ff-${baseHead.slice(0, 12)}-${branchHead.slice(0, 12)}.index`);
|
|
80004
80275
|
const env2 = { ...process.env, GIT_INDEX_FILE: tmpIndex };
|
|
80005
80276
|
try {
|
|
80006
|
-
(0,
|
|
80007
|
-
(0,
|
|
80277
|
+
(0, import_node_child_process13.execFileSync)(GIT4, ["read-tree", contentTree], { cwd: repoRoot, env: env2, stdio: "ignore" });
|
|
80278
|
+
(0, import_node_child_process13.execFileSync)(GIT4, ["update-index", "--index-info"], {
|
|
80008
80279
|
cwd: repoRoot,
|
|
80009
80280
|
env: env2,
|
|
80010
80281
|
input: `${updates}
|
|
@@ -80012,11 +80283,11 @@ ${mergeTreeErr?.stderr || ""}`;
|
|
|
80012
80283
|
encoding: "utf8",
|
|
80013
80284
|
stdio: ["pipe", "ignore", "ignore"]
|
|
80014
80285
|
});
|
|
80015
|
-
const newTree = (0,
|
|
80286
|
+
const newTree = (0, import_node_child_process13.execFileSync)(GIT4, ["write-tree"], { cwd: repoRoot, env: env2, encoding: "utf8" }).trim();
|
|
80016
80287
|
return newTree || void 0;
|
|
80017
80288
|
} finally {
|
|
80018
80289
|
try {
|
|
80019
|
-
|
|
80290
|
+
fs50.rmSync(tmpIndex, { force: true });
|
|
80020
80291
|
} catch {
|
|
80021
80292
|
}
|
|
80022
80293
|
}
|
|
@@ -80128,7 +80399,7 @@ ${mergeTreeErr?.stderr || ""}`;
|
|
|
80128
80399
|
return { stdout: String(stdout || ""), stderr: String(stderr || ""), refspec };
|
|
80129
80400
|
};
|
|
80130
80401
|
const importCommitFromWorktreeSubmodule = async (submodulePath, worktreeSubmodulePath, commit) => {
|
|
80131
|
-
if (!
|
|
80402
|
+
if (!fs50.existsSync(worktreeSubmodulePath)) return false;
|
|
80132
80403
|
try {
|
|
80133
80404
|
await runGit3(worktreeSubmodulePath, ["cat-file", "-e", `${commit}^{commit}`]);
|
|
80134
80405
|
} catch {
|
|
@@ -80157,7 +80428,7 @@ ${mergeTreeErr?.stderr || ""}`;
|
|
|
80157
80428
|
return match ? { commit: match[1], path: match[2] } : null;
|
|
80158
80429
|
}).filter((entry) => !!entry);
|
|
80159
80430
|
for (const gitlink of gitlinks) {
|
|
80160
|
-
const submodulePath = (0,
|
|
80431
|
+
const submodulePath = (0, import_path18.resolve)(repoRoot, gitlink.path);
|
|
80161
80432
|
const entry = {
|
|
80162
80433
|
path: gitlink.path,
|
|
80163
80434
|
commit: gitlink.commit,
|
|
@@ -80165,7 +80436,7 @@ ${mergeTreeErr?.stderr || ""}`;
|
|
|
80165
80436
|
};
|
|
80166
80437
|
let submoduleDefaultBranch = "main";
|
|
80167
80438
|
try {
|
|
80168
|
-
if (!
|
|
80439
|
+
if (!fs50.existsSync(submodulePath)) {
|
|
80169
80440
|
entry.error = `Submodule checkout missing at ${gitlink.path}`;
|
|
80170
80441
|
entry.publishRequired = true;
|
|
80171
80442
|
if (options.allowAutoPublishSubmoduleMainCommits === true) {
|
|
@@ -80184,7 +80455,7 @@ ${mergeTreeErr?.stderr || ""}`;
|
|
|
80184
80455
|
entry.localReachable = false;
|
|
80185
80456
|
if (options.allowAutoPublishSubmoduleMainCommits === true && options.worktreeRoot) {
|
|
80186
80457
|
try {
|
|
80187
|
-
const imported = await importCommitFromWorktreeSubmodule(submodulePath, (0,
|
|
80458
|
+
const imported = await importCommitFromWorktreeSubmodule(submodulePath, (0, import_path18.resolve)(options.worktreeRoot, gitlink.path), gitlink.commit);
|
|
80188
80459
|
if (imported) {
|
|
80189
80460
|
entry.localReachable = true;
|
|
80190
80461
|
entry.importedFromWorktree = true;
|
|
@@ -80414,13 +80685,13 @@ ${mergeTreeErr?.stderr || ""}`;
|
|
|
80414
80685
|
...extras
|
|
80415
80686
|
});
|
|
80416
80687
|
const isPackageManagerValidation = (candidate) => {
|
|
80417
|
-
const command = (0,
|
|
80688
|
+
const command = (0, import_path18.basename)(candidate.command).replace(/\.(?:cmd|exe)$/i, "");
|
|
80418
80689
|
return ["npm", "pnpm", "yarn", "bun"].includes(command) && candidate.args.some((arg) => arg === "run" || arg === "test" || arg === "exec");
|
|
80419
80690
|
};
|
|
80420
80691
|
const dependenciesLikelyMissing = (cwd) => {
|
|
80421
|
-
if (!
|
|
80422
|
-
if (
|
|
80423
|
-
return ["package-lock.json", "npm-shrinkwrap.json", "pnpm-lock.yaml", "yarn.lock", "bun.lockb", "bun.lock"].some((lock) =>
|
|
80692
|
+
if (!fs50.existsSync((0, import_path18.join)(cwd, "package.json"))) return false;
|
|
80693
|
+
if (fs50.existsSync((0, import_path18.join)(cwd, "node_modules"))) return false;
|
|
80694
|
+
return ["package-lock.json", "npm-shrinkwrap.json", "pnpm-lock.yaml", "yarn.lock", "bun.lockb", "bun.lock"].some((lock) => fs50.existsSync((0, import_path18.join)(cwd, lock)));
|
|
80424
80695
|
};
|
|
80425
80696
|
const needsNodeModules = (candidate, cwd) => isPackageManagerValidation(candidate) && dependenciesLikelyMissing(cwd);
|
|
80426
80697
|
const isDaemonScopedCommand = (candidate) => {
|
|
@@ -80487,7 +80758,7 @@ ${mergeTreeErr?.stderr || ""}`;
|
|
|
80487
80758
|
summary.bootstrap = { stage: "legacy" };
|
|
80488
80759
|
for (const candidate of selection.bootstrapCommands) {
|
|
80489
80760
|
const startedAt = Date.now();
|
|
80490
|
-
const cwd = candidate.cwd ? (0,
|
|
80761
|
+
const cwd = candidate.cwd ? (0, import_path18.resolve)(workspace, candidate.cwd) : workspace;
|
|
80491
80762
|
const timeout = candidate.timeoutMs || REFINE_VALIDATION_TIMEOUT_MS;
|
|
80492
80763
|
const resolvedCommand = resolveWin32Executable(candidate.command);
|
|
80493
80764
|
const spawn7 = buildWin32ExecFileSpawn(resolvedCommand, candidate.args);
|
|
@@ -80520,7 +80791,7 @@ ${mergeTreeErr?.stderr || ""}`;
|
|
|
80520
80791
|
let missingDepsBlocked = false;
|
|
80521
80792
|
for (const candidate of commandsToRun) {
|
|
80522
80793
|
const startedAt = Date.now();
|
|
80523
|
-
const cwd = candidate.cwd ? (0,
|
|
80794
|
+
const cwd = candidate.cwd ? (0, import_path18.resolve)(workspace, candidate.cwd) : workspace;
|
|
80524
80795
|
const timeout = candidate.timeoutMs || REFINE_VALIDATION_TIMEOUT_MS;
|
|
80525
80796
|
const bootstrapProvidedDependencies = summary.bootstrap?.stage === "cached" || summary.bootstrap?.stage === "ran" || summary.bootstrap?.stage === "legacy";
|
|
80526
80797
|
if (!bootstrapProvidedDependencies && needsNodeModules(candidate, cwd)) {
|
|
@@ -80587,16 +80858,14 @@ ${mergeTreeErr?.stderr || ""}`;
|
|
|
80587
80858
|
summary.status = "passed";
|
|
80588
80859
|
return summary;
|
|
80589
80860
|
}
|
|
80590
|
-
var
|
|
80591
|
-
var
|
|
80592
|
-
var
|
|
80593
|
-
var GIT4;
|
|
80861
|
+
var import_path18;
|
|
80862
|
+
var fs50;
|
|
80863
|
+
var import_node_child_process13;
|
|
80594
80864
|
var REFINE_VALIDATION_TIMEOUT_MS;
|
|
80595
80865
|
var REFINE_VALIDATION_OUTPUT_LIMIT_BYTES;
|
|
80596
80866
|
var REFINE_VALIDATION_SUMMARY_HEAD_CHARS;
|
|
80597
80867
|
var REFINE_VALIDATION_SUMMARY_TAIL_CHARS;
|
|
80598
80868
|
var REFINE_VALIDATION_SUMMARY_CHARS;
|
|
80599
|
-
var REFINE_PATCH_EQUIVALENCE_OUTPUT_LIMIT_BYTES;
|
|
80600
80869
|
var REFINE_VALIDATION_LOG_DIR;
|
|
80601
80870
|
var init_mesh_refine_gates = __esm2({
|
|
80602
80871
|
"src/mesh/mesh-refine-gates.ts"() {
|
|
@@ -80604,19 +80873,19 @@ ${mergeTreeErr?.stderr || ""}`;
|
|
|
80604
80873
|
init_git_status();
|
|
80605
80874
|
init_refine_config();
|
|
80606
80875
|
init_worktree_bootstrap_config();
|
|
80607
|
-
|
|
80608
|
-
|
|
80609
|
-
|
|
80876
|
+
import_path18 = require("path");
|
|
80877
|
+
fs50 = __toESM2(require("fs"));
|
|
80878
|
+
import_node_child_process13 = require("child_process");
|
|
80610
80879
|
init_resolve_executable();
|
|
80611
80880
|
init_mesh_refine_worker_cap();
|
|
80612
|
-
|
|
80881
|
+
init_mesh_refine_gitlink_utils();
|
|
80882
|
+
init_mesh_refine_submodule_converge();
|
|
80613
80883
|
REFINE_VALIDATION_TIMEOUT_MS = 12e4;
|
|
80614
80884
|
REFINE_VALIDATION_OUTPUT_LIMIT_BYTES = 128 * 1024;
|
|
80615
80885
|
REFINE_VALIDATION_SUMMARY_HEAD_CHARS = 2e3;
|
|
80616
80886
|
REFINE_VALIDATION_SUMMARY_TAIL_CHARS = 6e3;
|
|
80617
80887
|
REFINE_VALIDATION_SUMMARY_CHARS = REFINE_VALIDATION_SUMMARY_HEAD_CHARS + REFINE_VALIDATION_SUMMARY_TAIL_CHARS;
|
|
80618
|
-
|
|
80619
|
-
REFINE_VALIDATION_LOG_DIR = (0, import_path17.join)(".adhdev", "logs");
|
|
80888
|
+
REFINE_VALIDATION_LOG_DIR = (0, import_path18.join)(".adhdev", "logs");
|
|
80620
80889
|
}
|
|
80621
80890
|
});
|
|
80622
80891
|
function findOpenRefineDispatchForNode(args) {
|
|
@@ -81303,6 +81572,9 @@ ${mergeTreeErr?.stderr || ""}`;
|
|
|
81303
81572
|
convergeReason: converge.reason,
|
|
81304
81573
|
gitlinks: converge.gitlinks
|
|
81305
81574
|
});
|
|
81575
|
+
if (converge.reason === "submodule_commit_unavailable") {
|
|
81576
|
+
LOG2.warn("Mesh", `[Refinery] Could NOT determine submodule gitlink divergence for node ${node.id} \u2014 a gitlink commit is missing from the local submodule object store (auto-converge could not run): ` + converge.gitlinks.filter((g) => g.action === "skipped_commit_unavailable").map((g) => `${g.path} (missing: ${(g.unavailable || []).join("+") || "unknown"}; base=${(g.baseCommit || "?").slice(0, 12)} branch=${(g.branchCommit || "?").slice(0, 12)})`).join(", "));
|
|
81577
|
+
}
|
|
81306
81578
|
recordMeshRefineStage(refineStages, "sync_base", "passed", syncStarted, {
|
|
81307
81579
|
ahead: divergence.ahead,
|
|
81308
81580
|
behind: divergence.behind,
|
|
@@ -81345,12 +81617,12 @@ ${mergeTreeErr?.stderr || ""}`;
|
|
|
81345
81617
|
throw err;
|
|
81346
81618
|
}
|
|
81347
81619
|
} else {
|
|
81348
|
-
(0,
|
|
81620
|
+
(0, import_node_child_process14.execFileSync)("git", ["rebase", baseHead], { cwd: node.workspace, stdio: ["ignore", "pipe", "pipe"] });
|
|
81349
81621
|
}
|
|
81350
81622
|
} catch (rebaseErr) {
|
|
81351
81623
|
if (!rebaseErr?.alreadyAborted) {
|
|
81352
81624
|
try {
|
|
81353
|
-
(0,
|
|
81625
|
+
(0, import_node_child_process14.execFileSync)("git", ["rebase", "--abort"], { cwd: node.workspace, stdio: "ignore" });
|
|
81354
81626
|
} catch {
|
|
81355
81627
|
}
|
|
81356
81628
|
}
|
|
@@ -82804,7 +83076,7 @@ ${e?.stderr || ""}`;
|
|
|
82804
83076
|
if (!repoRoot || !workspace) return;
|
|
82805
83077
|
const branch = typeof node?.worktreeBranch === "string" && node.worktreeBranch.trim() ? node.worktreeBranch.trim() : (() => {
|
|
82806
83078
|
try {
|
|
82807
|
-
return (0,
|
|
83079
|
+
return (0, import_node_child_process14.execFileSync)("git", ["branch", "--show-current"], { cwd: workspace, encoding: "utf8" }).trim();
|
|
82808
83080
|
} catch {
|
|
82809
83081
|
return "";
|
|
82810
83082
|
}
|
|
@@ -82812,7 +83084,7 @@ ${e?.stderr || ""}`;
|
|
|
82812
83084
|
if (!branch) return;
|
|
82813
83085
|
const baseBranch = (() => {
|
|
82814
83086
|
try {
|
|
82815
|
-
return (0,
|
|
83087
|
+
return (0, import_node_child_process14.execFileSync)("git", ["branch", "--show-current"], { cwd: repoRoot, encoding: "utf8" }).trim() || "main";
|
|
82816
83088
|
} catch {
|
|
82817
83089
|
return "main";
|
|
82818
83090
|
}
|
|
@@ -82880,13 +83152,13 @@ ${e?.stderr || ""}`;
|
|
|
82880
83152
|
});
|
|
82881
83153
|
return handle;
|
|
82882
83154
|
}
|
|
82883
|
-
var
|
|
83155
|
+
var import_node_child_process14;
|
|
82884
83156
|
var import_node_fs9;
|
|
82885
83157
|
var RETRYABLE_BASE_MOVEMENT_CODES;
|
|
82886
83158
|
var init_router_refine = __esm2({
|
|
82887
83159
|
"src/commands/router-refine.ts"() {
|
|
82888
83160
|
"use strict";
|
|
82889
|
-
|
|
83161
|
+
import_node_child_process14 = require("child_process");
|
|
82890
83162
|
import_node_fs9 = require("fs");
|
|
82891
83163
|
init_logger();
|
|
82892
83164
|
init_debug_trace();
|
|
@@ -83053,6 +83325,7 @@ ${e?.stderr || ""}`;
|
|
|
83053
83325
|
WORKSPACE_OWNER_GIT_CONFIG_KEY: () => WORKSPACE_OWNER_GIT_CONFIG_KEY,
|
|
83054
83326
|
WORKSPACE_SAGA_LEASE_MS: () => WORKSPACE_SAGA_LEASE_MS,
|
|
83055
83327
|
WorkspaceSagaPermanentError: () => WorkspaceSagaPermanentError,
|
|
83328
|
+
abandonMeshGraphGate: () => abandonMeshGraphGate,
|
|
83056
83329
|
addNode: () => addNode,
|
|
83057
83330
|
appendLedgerEntry: () => appendLedgerEntry,
|
|
83058
83331
|
appendRecentActivity: () => appendRecentActivity,
|
|
@@ -83126,6 +83399,7 @@ ${e?.stderr || ""}`;
|
|
|
83126
83399
|
configureDebugTraceStore: () => configureDebugTraceStore,
|
|
83127
83400
|
connectCdpManager: () => connectCdpManager,
|
|
83128
83401
|
consoleSymbols: () => consoleSymbols,
|
|
83402
|
+
coordinatorGateAbandonedReason: () => coordinatorGateAbandonedReason,
|
|
83129
83403
|
coordinatorGateBlockReason: () => coordinatorGateBlockReason,
|
|
83130
83404
|
coordinatorIdentityFromEmitFields: () => coordinatorIdentityFromEmitFields,
|
|
83131
83405
|
createDebugTraceStore: () => createDebugTraceStore,
|
|
@@ -83390,6 +83664,7 @@ ${e?.stderr || ""}`;
|
|
|
83390
83664
|
recordGraphEnqueueCommitted: () => recordGraphEnqueueCommitted,
|
|
83391
83665
|
recordGraphEnqueueRolledBack: () => recordGraphEnqueueRolledBack,
|
|
83392
83666
|
recordGraphEnqueueValidationFailed: () => recordGraphEnqueueValidationFailed,
|
|
83667
|
+
recordGraphGateAbandoned: () => recordGraphGateAbandoned,
|
|
83393
83668
|
recordGraphGateClaimed: () => recordGraphGateClaimed,
|
|
83394
83669
|
recordGraphGateExpired: () => recordGraphGateExpired,
|
|
83395
83670
|
recordGraphGateReleased: () => recordGraphGateReleased,
|
|
@@ -86551,8 +86826,25 @@ ${e?.stderr || ""}`;
|
|
|
86551
86826
|
});
|
|
86552
86827
|
const nodeStates = {};
|
|
86553
86828
|
for (const node of nodes) nodeStates[node.state] = (nodeStates[node.state] ?? 0) + 1;
|
|
86829
|
+
const orphanedGateIds = /* @__PURE__ */ new Set();
|
|
86830
|
+
for (const gate of gates) {
|
|
86831
|
+
if (gate.state !== "awaiting_coordinator" && gate.state !== "claimed" && gate.state !== "expired") continue;
|
|
86832
|
+
const downstream = edges.filter((e) => e.fromNodeId === gate.nodeId).map((e) => byId.get(e.toNodeId)).filter((n) => !!n);
|
|
86833
|
+
if (downstream.length === 0) continue;
|
|
86834
|
+
if (downstream.every((n) => n.state === "cancelled" || n.state === "failed" || n.state === "skipped")) {
|
|
86835
|
+
orphanedGateIds.add(gate.gateId);
|
|
86836
|
+
}
|
|
86837
|
+
}
|
|
86554
86838
|
const actions = [];
|
|
86555
86839
|
for (const gate of gateViews) {
|
|
86840
|
+
if (orphanedGateIds.has(gate.gateId)) {
|
|
86841
|
+
actions.push({
|
|
86842
|
+
kind: "gate_abandon",
|
|
86843
|
+
gateId: gate.gateId,
|
|
86844
|
+
detail: `Gate '${gate.ref ?? gate.gateId}' (${gate.action}) is ORPHANED: every task it was gating is already cancelled, failed or skipped, so releasing it would open nothing. While it stays unsettled this graph cannot reach ANY terminal state \u2014 not even cancelled. Close it with mesh_graph_gate_abandon and a reason. Abandon cancels what the gate was holding; it never passes the gate.`
|
|
86845
|
+
});
|
|
86846
|
+
continue;
|
|
86847
|
+
}
|
|
86556
86848
|
if (gate.state === "awaiting_coordinator") {
|
|
86557
86849
|
actions.push({
|
|
86558
86850
|
kind: "gate_awaiting",
|
|
@@ -86575,7 +86867,7 @@ ${e?.stderr || ""}`;
|
|
|
86575
86867
|
actions.push({
|
|
86576
86868
|
kind: "gate_reclaim",
|
|
86577
86869
|
gateId: gate.gateId,
|
|
86578
|
-
detail: `Gate '${gate.ref ?? gate.gateId}' passed its deadline under on_timeout=hold \u2014 downstream is still held. Reclaim it (optionally with extend_deadline_seconds) to resume, or
|
|
86870
|
+
detail: `Gate '${gate.ref ?? gate.gateId}' passed its deadline under on_timeout=hold \u2014 downstream is still held. Reclaim it with mesh_graph_gate_claim (optionally with extend_deadline_seconds) to resume, or give it up with mesh_graph_gate_abandon, which cancels what it was holding instead of opening it. A timeout is never passage: the gate cannot release itself.`
|
|
86579
86871
|
});
|
|
86580
86872
|
}
|
|
86581
86873
|
}
|
|
@@ -95210,7 +95502,7 @@ ${effect.notification.body || ""}`.trim();
|
|
|
95210
95502
|
if (!["cli", "ide", "extension", "acp"].includes(category)) {
|
|
95211
95503
|
return { success: false, error: `unknown category: ${category}` };
|
|
95212
95504
|
}
|
|
95213
|
-
const
|
|
95505
|
+
const fs61 = require("fs");
|
|
95214
95506
|
const path58 = require("path");
|
|
95215
95507
|
try {
|
|
95216
95508
|
const installRoot = this.getUpstreamInstallRoot();
|
|
@@ -95219,10 +95511,10 @@ ${effect.notification.body || ""}`.trim();
|
|
|
95219
95511
|
if (!targetDir.startsWith(installRootResolved + path58.sep)) {
|
|
95220
95512
|
return { success: false, error: "refusing to delete outside upstream root" };
|
|
95221
95513
|
}
|
|
95222
|
-
if (!
|
|
95514
|
+
if (!fs61.existsSync(targetDir)) {
|
|
95223
95515
|
return { success: false, error: "not installed" };
|
|
95224
95516
|
}
|
|
95225
|
-
|
|
95517
|
+
fs61.rmSync(targetDir, { recursive: true, force: true });
|
|
95226
95518
|
try {
|
|
95227
95519
|
this._ctx.providerLoader?.deactivateVerifiedChannel?.(type2);
|
|
95228
95520
|
} catch {
|
|
@@ -95242,28 +95534,28 @@ ${effect.notification.body || ""}`.trim();
|
|
|
95242
95534
|
* the UI and by the update checker.
|
|
95243
95535
|
*/
|
|
95244
95536
|
handleListInstalledProviders(_args) {
|
|
95245
|
-
const
|
|
95537
|
+
const fs61 = require("fs");
|
|
95246
95538
|
const path58 = require("path");
|
|
95247
95539
|
const installRoot = this.getUpstreamInstallRoot();
|
|
95248
|
-
if (!
|
|
95540
|
+
if (!fs61.existsSync(installRoot)) return { success: true, providers: [] };
|
|
95249
95541
|
const CATEGORIES = ["cli", "ide", "extension", "acp"];
|
|
95250
95542
|
const items = [];
|
|
95251
95543
|
for (const category of CATEGORIES) {
|
|
95252
95544
|
const categoryDir = path58.join(installRoot, category);
|
|
95253
|
-
if (!
|
|
95545
|
+
if (!fs61.existsSync(categoryDir)) continue;
|
|
95254
95546
|
let entries;
|
|
95255
95547
|
try {
|
|
95256
|
-
entries =
|
|
95548
|
+
entries = fs61.readdirSync(categoryDir);
|
|
95257
95549
|
} catch {
|
|
95258
95550
|
continue;
|
|
95259
95551
|
}
|
|
95260
95552
|
for (const type2 of entries) {
|
|
95261
95553
|
const v1Path = path58.join(categoryDir, type2, "provider.v1.json");
|
|
95262
95554
|
const v0Path = path58.join(categoryDir, type2, "provider.json");
|
|
95263
|
-
const manifestPath =
|
|
95555
|
+
const manifestPath = fs61.existsSync(v1Path) ? v1Path : fs61.existsSync(v0Path) ? v0Path : null;
|
|
95264
95556
|
if (!manifestPath) continue;
|
|
95265
95557
|
try {
|
|
95266
|
-
const m = JSON.parse(
|
|
95558
|
+
const m = JSON.parse(fs61.readFileSync(manifestPath, "utf-8"));
|
|
95267
95559
|
const modelOptions = Array.isArray(m.modelOptions) ? m.modelOptions.filter((x) => typeof x === "string" && !!x.trim()) : [];
|
|
95268
95560
|
const thinkingLevelOptions = Array.isArray(m.thinkingLevelOptions) ? m.thinkingLevelOptions.filter((x) => typeof x === "string" && !!x.trim()) : [];
|
|
95269
95561
|
items.push({
|
|
@@ -95484,7 +95776,7 @@ ${effect.notification.body || ""}`.trim();
|
|
|
95484
95776
|
if (!/^@[a-z0-9_-]+$/i.test(requestedName)) {
|
|
95485
95777
|
return { success: false, error: "name must match @[a-z0-9_-]+" };
|
|
95486
95778
|
}
|
|
95487
|
-
const
|
|
95779
|
+
const fs61 = require("fs");
|
|
95488
95780
|
const path58 = require("path");
|
|
95489
95781
|
const { spawnSync: spawnSync3 } = require("child_process");
|
|
95490
95782
|
const file2 = ext.loadExternalSources();
|
|
@@ -95495,8 +95787,8 @@ ${effect.notification.body || ""}`.trim();
|
|
|
95495
95787
|
return { success: false, error: `source url+ref already registered (use a different name to track another ref)` };
|
|
95496
95788
|
}
|
|
95497
95789
|
const sourceDir = path58.join(ext.externalRoot(), requestedName);
|
|
95498
|
-
if (!
|
|
95499
|
-
if (
|
|
95790
|
+
if (!fs61.existsSync(ext.externalRoot())) fs61.mkdirSync(ext.externalRoot(), { recursive: true });
|
|
95791
|
+
if (fs61.existsSync(sourceDir)) {
|
|
95500
95792
|
return { success: false, error: `directory already exists: ${sourceDir} (rename or remove first)` };
|
|
95501
95793
|
}
|
|
95502
95794
|
const clone2 = spawnSync3("git", ["clone", "--depth=1", "--branch", ref, "--", url2, sourceDir], {
|
|
@@ -95506,7 +95798,7 @@ ${effect.notification.body || ""}`.trim();
|
|
|
95506
95798
|
});
|
|
95507
95799
|
if (clone2.status !== 0) {
|
|
95508
95800
|
try {
|
|
95509
|
-
|
|
95801
|
+
fs61.rmSync(sourceDir, { recursive: true, force: true });
|
|
95510
95802
|
} catch {
|
|
95511
95803
|
}
|
|
95512
95804
|
return { success: false, error: `git clone failed: ${(clone2.stderr || clone2.stdout || "").trim() || "unknown error"}` };
|
|
@@ -95550,15 +95842,15 @@ ${effect.notification.body || ""}`.trim();
|
|
|
95550
95842
|
const name = typeof args?.name === "string" ? args.name.trim() : "";
|
|
95551
95843
|
if (!name) return { success: false, error: "name is required" };
|
|
95552
95844
|
const ext = (init_external_sources(), __toCommonJS2(external_sources_exports));
|
|
95553
|
-
const
|
|
95845
|
+
const fs61 = require("fs");
|
|
95554
95846
|
const path58 = require("path");
|
|
95555
95847
|
const file2 = ext.loadExternalSources();
|
|
95556
95848
|
const match = file2.sources.find((s2) => s2.name === name);
|
|
95557
95849
|
if (!match) return { success: false, error: `source "${name}" not registered` };
|
|
95558
95850
|
const sourceDir = path58.join(ext.externalRoot(), name);
|
|
95559
|
-
if (
|
|
95851
|
+
if (fs61.existsSync(sourceDir)) {
|
|
95560
95852
|
try {
|
|
95561
|
-
|
|
95853
|
+
fs61.rmSync(sourceDir, { recursive: true, force: true });
|
|
95562
95854
|
} catch (e) {
|
|
95563
95855
|
return { success: false, error: `failed to delete ${sourceDir}: ${e?.message || e}` };
|
|
95564
95856
|
}
|
|
@@ -97885,14 +98177,14 @@ ${marker}`,
|
|
|
97885
98177
|
}
|
|
97886
98178
|
},
|
|
97887
98179
|
list_coordinator_prompts: async (_ctx, _args) => {
|
|
97888
|
-
const
|
|
98180
|
+
const fs61 = await import("fs");
|
|
97889
98181
|
const path58 = await import("path");
|
|
97890
98182
|
const { getConfigDir: getConfigDir22 } = await Promise.resolve().then(() => (init_config(), config_exports));
|
|
97891
98183
|
const dir = path58.join(getConfigDir22(), "coordinator-prompts");
|
|
97892
98184
|
const entries = {};
|
|
97893
98185
|
try {
|
|
97894
|
-
if (
|
|
97895
|
-
for (const name of
|
|
98186
|
+
if (fs61.existsSync(dir)) {
|
|
98187
|
+
for (const name of fs61.readdirSync(dir)) {
|
|
97896
98188
|
const matchOverride = name.match(/^([a-zA-Z0-9_.-]+)\.md$/);
|
|
97897
98189
|
const matchAppend = name.match(/^([a-zA-Z0-9_.-]+)\.append\.md$/);
|
|
97898
98190
|
const m = matchAppend || matchOverride;
|
|
@@ -97902,7 +98194,7 @@ ${marker}`,
|
|
|
97902
98194
|
const full = path58.join(dir, name);
|
|
97903
98195
|
let content = "";
|
|
97904
98196
|
try {
|
|
97905
|
-
content =
|
|
98197
|
+
content = fs61.readFileSync(full, "utf8");
|
|
97906
98198
|
} catch {
|
|
97907
98199
|
}
|
|
97908
98200
|
if (!entries[key2]) entries[key2] = { override: "", append: "" };
|
|
@@ -97916,7 +98208,7 @@ ${marker}`,
|
|
|
97916
98208
|
return { success: true, dir, entries };
|
|
97917
98209
|
},
|
|
97918
98210
|
write_coordinator_prompt: async (_ctx, args) => {
|
|
97919
|
-
const
|
|
98211
|
+
const fs61 = await import("fs");
|
|
97920
98212
|
const path58 = await import("path");
|
|
97921
98213
|
const { getConfigDir: getConfigDir22 } = await Promise.resolve().then(() => (init_config(), config_exports));
|
|
97922
98214
|
const key2 = typeof args?.key === "string" ? args.key.trim() : "";
|
|
@@ -97929,11 +98221,11 @@ ${marker}`,
|
|
|
97929
98221
|
const filename = kind === "append" ? `${key2}.append.md` : `${key2}.md`;
|
|
97930
98222
|
const full = path58.join(dir, filename);
|
|
97931
98223
|
try {
|
|
97932
|
-
|
|
98224
|
+
fs61.mkdirSync(dir, { recursive: true });
|
|
97933
98225
|
if (content.trim()) {
|
|
97934
|
-
|
|
97935
|
-
} else if (
|
|
97936
|
-
|
|
98226
|
+
fs61.writeFileSync(full, content, { encoding: "utf8", mode: 384 });
|
|
98227
|
+
} else if (fs61.existsSync(full)) {
|
|
98228
|
+
fs61.unlinkSync(full);
|
|
97937
98229
|
}
|
|
97938
98230
|
return { success: true, path: full, kind, key: key2 };
|
|
97939
98231
|
} catch (error48) {
|
|
@@ -116161,7 +116453,7 @@ Run 'adhdev doctor' for detailed diagnostics.`
|
|
|
116161
116453
|
}
|
|
116162
116454
|
if (providerDir) {
|
|
116163
116455
|
try {
|
|
116164
|
-
const
|
|
116456
|
+
const fs61 = require("fs");
|
|
116165
116457
|
const path58 = require("path");
|
|
116166
116458
|
const candidates = [];
|
|
116167
116459
|
if (Array.isArray(base.compatibility)) {
|
|
@@ -116173,13 +116465,13 @@ Run 'adhdev doctor' for detailed diagnostics.`
|
|
|
116173
116465
|
}
|
|
116174
116466
|
candidates.push(path58.join(providerDir, "specs", "default.json"));
|
|
116175
116467
|
candidates.push(path58.join(providerDir, "spec.json"));
|
|
116176
|
-
const specPath = candidates.find((p) =>
|
|
116468
|
+
const specPath = candidates.find((p) => fs61.existsSync(p));
|
|
116177
116469
|
let nh;
|
|
116178
116470
|
if (specPath) {
|
|
116179
116471
|
resolved._resolvedSpecPath = specPath;
|
|
116180
116472
|
let specControls;
|
|
116181
116473
|
try {
|
|
116182
|
-
const rawSpec = JSON.parse(
|
|
116474
|
+
const rawSpec = JSON.parse(fs61.readFileSync(specPath, "utf8"));
|
|
116183
116475
|
specControls = rawSpec.control_bar;
|
|
116184
116476
|
nh = rawSpec.native_history;
|
|
116185
116477
|
} catch {
|
|
@@ -116222,7 +116514,7 @@ Run 'adhdev doctor' for detailed diagnostics.`
|
|
|
116222
116514
|
}
|
|
116223
116515
|
} else if (nh.override_path) {
|
|
116224
116516
|
const overrideFile = path58.resolve(providerDir, nh.override_path);
|
|
116225
|
-
if (
|
|
116517
|
+
if (fs61.existsSync(overrideFile)) {
|
|
116226
116518
|
try {
|
|
116227
116519
|
registerProviderScriptRootSafely(path58.dirname(path58.dirname(providerDir)));
|
|
116228
116520
|
delete require.cache[require.resolve(overrideFile)];
|
|
@@ -117139,7 +117431,7 @@ ${formatManifestValidationIssues2(validation2.issues)}`);
|
|
|
117139
117431
|
}
|
|
117140
117432
|
} else if (plat === "win32") {
|
|
117141
117433
|
try {
|
|
117142
|
-
const
|
|
117434
|
+
const fs61 = require("fs");
|
|
117143
117435
|
const appNameMap = getMacAppIdentifiers();
|
|
117144
117436
|
const appName = appNameMap[ideId];
|
|
117145
117437
|
if (appName) {
|
|
@@ -117148,8 +117440,8 @@ ${formatManifestValidationIssues2(validation2.issues)}`);
|
|
|
117148
117440
|
appName,
|
|
117149
117441
|
"storage.json"
|
|
117150
117442
|
);
|
|
117151
|
-
if (
|
|
117152
|
-
const data = JSON.parse(
|
|
117443
|
+
if (fs61.existsSync(storagePath)) {
|
|
117444
|
+
const data = JSON.parse(fs61.readFileSync(storagePath, "utf-8"));
|
|
117153
117445
|
const workspaces = data?.openedPathsList?.workspaces3 || data?.openedPathsList?.entries || [];
|
|
117154
117446
|
if (workspaces.length > 0) {
|
|
117155
117447
|
const recent = workspaces[0];
|
|
@@ -117839,7 +118131,7 @@ ${formatManifestValidationIssues2(validation2.issues)}`);
|
|
|
117839
118131
|
normalizeRepoMeshDeclarativeConfig: normalizeRepoMeshDeclarativeConfig2,
|
|
117840
118132
|
MESH_JSON_CONFIG_LOCATIONS: MESH_JSON_CONFIG_LOCATIONS2
|
|
117841
118133
|
} = await Promise.resolve().then(() => (init_mesh_json_config(), mesh_json_config_exports));
|
|
117842
|
-
const { existsSync:
|
|
118134
|
+
const { existsSync: existsSync69, readFileSync: readFileSync55, mkdirSync: mkdirSync31, writeFileSync: writeFileSync31 } = await import("fs");
|
|
117843
118135
|
const { dirname: dirname24, join: join67 } = await import("path");
|
|
117844
118136
|
const yaml6 = await Promise.resolve().then(() => (init_js_yaml(), js_yaml_exports));
|
|
117845
118137
|
const relativePath = MESH_JSON_CONFIG_LOCATIONS2[0];
|
|
@@ -117848,7 +118140,7 @@ ${formatManifestValidationIssues2(validation2.issues)}`);
|
|
|
117848
118140
|
let existedAsYaml = false;
|
|
117849
118141
|
for (const relative8 of MESH_JSON_CONFIG_LOCATIONS2) {
|
|
117850
118142
|
const candidate = join67(workspace, relative8);
|
|
117851
|
-
if (!
|
|
118143
|
+
if (!existsSync69(candidate)) continue;
|
|
117852
118144
|
try {
|
|
117853
118145
|
const text = readFileSync55(candidate, "utf-8");
|
|
117854
118146
|
const parsed = /\.json$/i.test(candidate) ? JSON.parse(text) : yaml6.load(text);
|
|
@@ -120162,7 +120454,7 @@ ${ptyResult.output.slice(-2e3)}`);
|
|
|
120162
120454
|
workspace
|
|
120163
120455
|
};
|
|
120164
120456
|
}
|
|
120165
|
-
const { existsSync:
|
|
120457
|
+
const { existsSync: existsSync69, readFileSync: readFileSync55, writeFileSync: writeFileSync31, copyFileSync: copyFileSync3, mkdirSync: mkdirSync31 } = await import("fs");
|
|
120166
120458
|
const { dirname: dirname24 } = await import("path");
|
|
120167
120459
|
const mcpConfigPath = coordinatorSetup.configPath;
|
|
120168
120460
|
const hermesManualFallback = cliType === "hermes-cli" && configFormat === "hermes_config_yaml" ? createHermesManualMeshCoordinatorSetup(meshId, workspace) : null;
|
|
@@ -120207,7 +120499,7 @@ ${ptyResult.output.slice(-2e3)}`);
|
|
|
120207
120499
|
if (hermesManualFallback) return returnManualFallback(message);
|
|
120208
120500
|
return { success: false, code: "mesh_coordinator_config_write_failed", error: message, meshId, cliType, workspace };
|
|
120209
120501
|
}
|
|
120210
|
-
const hadExistingMcpConfig =
|
|
120502
|
+
const hadExistingMcpConfig = existsSync69(mcpConfigPath);
|
|
120211
120503
|
let existingMcpConfig = hermesBaseConfig?.config || {};
|
|
120212
120504
|
if (hermesBaseConfig) {
|
|
120213
120505
|
copyHermesCoordinatorCredentialFiles(hermesBaseConfig.sourceHome, dirname24(mcpConfigPath));
|
|
@@ -121008,7 +121300,7 @@ ${ptyResult.output.slice(-2e3)}`);
|
|
|
121008
121300
|
const { deriveMeshReviewInboxItems: deriveMeshReviewInboxItems2 } = await Promise.resolve().then(() => (init_mesh_review_inbox(), mesh_review_inbox_exports));
|
|
121009
121301
|
const { readLedgerEntries: readLedgerEntries2 } = await Promise.resolve().then(() => (init_mesh_ledger(), mesh_ledger_exports));
|
|
121010
121302
|
const { getGitDiffSummary: getGitDiffSummary2 } = await Promise.resolve().then(() => (init_git_diff(), git_diff_exports));
|
|
121011
|
-
const { existsSync:
|
|
121303
|
+
const { existsSync: existsSync69 } = await import("fs");
|
|
121012
121304
|
const meshRecord = await ctx.getMeshForCommand(meshId, args?.inlineMesh, { preferInline: true });
|
|
121013
121305
|
const mesh = meshRecord?.mesh;
|
|
121014
121306
|
if (!mesh) return { success: false, error: "Mesh not found" };
|
|
@@ -121027,7 +121319,7 @@ ${ptyResult.output.slice(-2e3)}`);
|
|
|
121027
121319
|
const derivation = deriveMeshReviewInboxItems2({ nodes: nodeStatuses, ledgerEntries });
|
|
121028
121320
|
for (const item of derivation.items) {
|
|
121029
121321
|
const workspace = item.workspace;
|
|
121030
|
-
if (!workspace || !
|
|
121322
|
+
if (!workspace || !existsSync69(workspace)) continue;
|
|
121031
121323
|
const baseRef = item.defaultBranch ? `origin/${item.defaultBranch}` : "origin/main";
|
|
121032
121324
|
try {
|
|
121033
121325
|
const diffResult = await getGitDiffSummary2(workspace, { baseRef, maxFiles: 100 });
|
|
@@ -121222,12 +121514,12 @@ ${ptyResult.output.slice(-2e3)}`);
|
|
|
121222
121514
|
}
|
|
121223
121515
|
init_debug_trace();
|
|
121224
121516
|
init_mesh_host_ownership();
|
|
121225
|
-
var
|
|
121517
|
+
var fs53 = __toESM2(require("fs"));
|
|
121226
121518
|
init_mesh_node_identity();
|
|
121227
121519
|
init_router_refine();
|
|
121228
|
-
var
|
|
121520
|
+
var fs51 = __toESM2(require("fs"));
|
|
121229
121521
|
var import_node_os2 = require("os");
|
|
121230
|
-
var
|
|
121522
|
+
var import_path19 = require("path");
|
|
121231
121523
|
init_logger();
|
|
121232
121524
|
init_git_locale();
|
|
121233
121525
|
init_dist();
|
|
@@ -121239,7 +121531,7 @@ ${ptyResult.output.slice(-2e3)}`);
|
|
|
121239
121531
|
function acceptableManagedWorktreePaths(resolveWorktreePath2, normalizePath2, repoRoot, meshName, branch, worktreeBaseDir) {
|
|
121240
121532
|
const safeBranch = branch.replace(/[/\\:*?"<>|]/g, "-").replace(/^\.+|\.+$/g, "");
|
|
121241
121533
|
const safeMeshName = meshName.replace(/[/\\:*?"<>|]/g, "-").replace(/^\.+|\.+$/g, "");
|
|
121242
|
-
const legacyPath = (0,
|
|
121534
|
+
const legacyPath = (0, import_path19.join)((0, import_path19.dirname)(repoRoot), LEGACY_WORKTREE_DIR_NAME, safeMeshName, safeBranch);
|
|
121243
121535
|
const candidates = [
|
|
121244
121536
|
resolveWorktreePath2(repoRoot, meshName, branch, worktreeBaseDir),
|
|
121245
121537
|
legacyPath
|
|
@@ -121263,8 +121555,8 @@ ${ptyResult.output.slice(-2e3)}`);
|
|
|
121263
121555
|
function looksLikeCrossTrackWorktreePath(actualPath, normalizePath2) {
|
|
121264
121556
|
const home = normalizePath2((0, import_node_os2.homedir)());
|
|
121265
121557
|
return TRACK_CONFIG_DIR_NAMES.some((trackDirName) => {
|
|
121266
|
-
const trackWorktreesDir = (0,
|
|
121267
|
-
return actualPath === normalizePath2(trackWorktreesDir) || actualPath.startsWith(normalizePath2(trackWorktreesDir) +
|
|
121558
|
+
const trackWorktreesDir = (0, import_path19.join)(home, trackDirName, "worktrees");
|
|
121559
|
+
return actualPath === normalizePath2(trackWorktreesDir) || actualPath.startsWith(normalizePath2(trackWorktreesDir) + import_path19.sep);
|
|
121268
121560
|
});
|
|
121269
121561
|
}
|
|
121270
121562
|
function unexpectedPathRecoveryHint(actualPath, normalizePath2, suffix) {
|
|
@@ -121322,14 +121614,14 @@ ${ptyResult.output.slice(-2e3)}`);
|
|
|
121322
121614
|
return false;
|
|
121323
121615
|
}
|
|
121324
121616
|
async function bestEffortRemoveWorktreeDir(self, dir) {
|
|
121325
|
-
if (!dir || !
|
|
121617
|
+
if (!dir || !fs51.existsSync(dir)) return { removed: true, residue: false };
|
|
121326
121618
|
const sleep3 = (ms) => new Promise((resolve30) => setTimeout(resolve30, ms));
|
|
121327
121619
|
const ABSORB = /* @__PURE__ */ new Set(["EINVAL", "EPERM", "EBUSY", "ENOTEMPTY", "EACCES", "EMFILE", "ENFILE"]);
|
|
121328
121620
|
let lastErr;
|
|
121329
121621
|
for (let attempt = 0; attempt < 4; attempt++) {
|
|
121330
121622
|
try {
|
|
121331
|
-
|
|
121332
|
-
if (!
|
|
121623
|
+
fs51.rmSync(dir, { recursive: true, force: true, maxRetries: 3, retryDelay: 100 });
|
|
121624
|
+
if (!fs51.existsSync(dir)) return { removed: true, residue: false };
|
|
121333
121625
|
lastErr = new Error("directory still present after rmSync");
|
|
121334
121626
|
} catch (e) {
|
|
121335
121627
|
lastErr = e;
|
|
@@ -121340,7 +121632,7 @@ ${ptyResult.output.slice(-2e3)}`);
|
|
|
121340
121632
|
}
|
|
121341
121633
|
await sleep3(150 * (attempt + 1));
|
|
121342
121634
|
}
|
|
121343
|
-
return
|
|
121635
|
+
return fs51.existsSync(dir) ? { removed: false, residue: true, error: String(lastErr?.message || lastErr || "unknown rm error") } : { removed: true, residue: false };
|
|
121344
121636
|
}
|
|
121345
121637
|
async function precheckLocalWorktreeRemovable(self, args) {
|
|
121346
121638
|
const sessionPreservedNote = " The delegated session was left running (not stopped) \u2014 resolve the issue and retry mesh_remove_node.";
|
|
@@ -121353,10 +121645,10 @@ ${ptyResult.output.slice(-2e3)}`);
|
|
|
121353
121645
|
recoveryHint: "Inspect the mesh node record before removing it, or remove stale metadata manually only after confirming no managed worktree remains." + sessionPreservedNote
|
|
121354
121646
|
};
|
|
121355
121647
|
}
|
|
121356
|
-
if (!
|
|
121648
|
+
if (!fs51.existsSync(workspace)) return { ok: true };
|
|
121357
121649
|
const sourceNode = args.node?.clonedFromNodeId ? args.mesh?.nodes?.find((n) => meshNodeIdMatches(n, args.node.clonedFromNodeId)) : args.mesh?.nodes?.find((n) => !n.isLocalWorktree);
|
|
121358
121650
|
const repoRoot = typeof sourceNode?.repoRoot === "string" && sourceNode.repoRoot.trim() ? sourceNode.repoRoot.trim() : typeof sourceNode?.workspace === "string" && sourceNode.workspace.trim() ? sourceNode.workspace.trim() : "";
|
|
121359
|
-
if (!repoRoot || !
|
|
121651
|
+
if (!repoRoot || !fs51.existsSync(repoRoot)) {
|
|
121360
121652
|
return {
|
|
121361
121653
|
ok: false,
|
|
121362
121654
|
code: "mesh_worktree_cleanup_missing_source_repo",
|
|
@@ -121374,9 +121666,9 @@ ${ptyResult.output.slice(-2e3)}`);
|
|
|
121374
121666
|
}
|
|
121375
121667
|
const { resolveWorktreePath: resolveWorktreePath2, listWorktrees: listWorktrees2 } = await Promise.resolve().then(() => (init_git_worktree(), git_worktree_exports));
|
|
121376
121668
|
const normalizePath2 = (value) => {
|
|
121377
|
-
const resolved = (0,
|
|
121669
|
+
const resolved = (0, import_path19.resolve)(value);
|
|
121378
121670
|
try {
|
|
121379
|
-
return
|
|
121671
|
+
return fs51.realpathSync(resolved);
|
|
121380
121672
|
} catch {
|
|
121381
121673
|
return resolved;
|
|
121382
121674
|
}
|
|
@@ -121477,13 +121769,13 @@ ${ptyResult.output.slice(-2e3)}`);
|
|
|
121477
121769
|
recoveryHint: "Inspect the mesh node record before removing it, or remove stale metadata manually only after confirming no managed worktree remains."
|
|
121478
121770
|
};
|
|
121479
121771
|
}
|
|
121480
|
-
const worktreeExists =
|
|
121772
|
+
const worktreeExists = fs51.existsSync(workspace);
|
|
121481
121773
|
const sourceNode = args.node?.clonedFromNodeId ? args.mesh?.nodes?.find((n) => meshNodeIdMatches(n, args.node.clonedFromNodeId)) : args.mesh?.nodes?.find((n) => !n.isLocalWorktree);
|
|
121482
121774
|
const repoRoot = typeof sourceNode?.repoRoot === "string" && sourceNode.repoRoot.trim() ? sourceNode.repoRoot.trim() : typeof sourceNode?.workspace === "string" && sourceNode.workspace.trim() ? sourceNode.workspace.trim() : "";
|
|
121483
121775
|
if (!worktreeExists) {
|
|
121484
121776
|
return { success: true, skipped: true, removedPath: workspace, repoRoot: repoRoot || void 0, reason: "worktree_path_missing" };
|
|
121485
121777
|
}
|
|
121486
|
-
if (!repoRoot || !
|
|
121778
|
+
if (!repoRoot || !fs51.existsSync(repoRoot)) {
|
|
121487
121779
|
return {
|
|
121488
121780
|
success: false,
|
|
121489
121781
|
code: "mesh_worktree_cleanup_missing_source_repo",
|
|
@@ -121501,9 +121793,9 @@ ${ptyResult.output.slice(-2e3)}`);
|
|
|
121501
121793
|
}
|
|
121502
121794
|
const { resolveWorktreePath: resolveWorktreePath2, listWorktrees: listWorktrees2, removeWorktree: removeWorktree2 } = await Promise.resolve().then(() => (init_git_worktree(), git_worktree_exports));
|
|
121503
121795
|
const normalizePath2 = (value) => {
|
|
121504
|
-
const resolved = (0,
|
|
121796
|
+
const resolved = (0, import_path19.resolve)(value);
|
|
121505
121797
|
try {
|
|
121506
|
-
return
|
|
121798
|
+
return fs51.realpathSync(resolved);
|
|
121507
121799
|
} catch {
|
|
121508
121800
|
return resolved;
|
|
121509
121801
|
}
|
|
@@ -122150,8 +122442,8 @@ ${ptyResult.output.slice(-2e3)}`);
|
|
|
122150
122442
|
init_logger();
|
|
122151
122443
|
var yaml5 = __toESM2(require_js_yaml());
|
|
122152
122444
|
var import_os5 = require("os");
|
|
122153
|
-
var
|
|
122154
|
-
var
|
|
122445
|
+
var import_path20 = require("path");
|
|
122446
|
+
var fs52 = __toESM2(require("fs"));
|
|
122155
122447
|
var MESH_COORDINATOR_AUTO_IMPORT_FORMATS = ["claude_mcp_json", "hermes_config_yaml", "opencode_json"];
|
|
122156
122448
|
function isSupportedMeshCoordinatorConfigFormat(format) {
|
|
122157
122449
|
return MESH_COORDINATOR_AUTO_IMPORT_FORMATS.includes(format);
|
|
@@ -122191,14 +122483,14 @@ ${ptyResult.output.slice(-2e3)}`);
|
|
|
122191
122483
|
}
|
|
122192
122484
|
function resolveHermesUserHome() {
|
|
122193
122485
|
const explicitHome = process.env.HERMES_HOME?.trim();
|
|
122194
|
-
return explicitHome || (0,
|
|
122486
|
+
return explicitHome || (0, import_path20.join)((0, import_os5.homedir)(), ".hermes");
|
|
122195
122487
|
}
|
|
122196
122488
|
function loadHermesCoordinatorBaseConfig(targetConfigPath) {
|
|
122197
122489
|
const sourceHome = resolveHermesUserHome();
|
|
122198
|
-
const sourceConfigPath = (0,
|
|
122199
|
-
if (!
|
|
122200
|
-
if ((0,
|
|
122201
|
-
const parsed = parseMeshCoordinatorMcpConfig(
|
|
122490
|
+
const sourceConfigPath = (0, import_path20.join)(sourceHome, "config.yaml");
|
|
122491
|
+
if (!fs52.existsSync(sourceConfigPath)) return { config: {}, sourceHome, sourceConfigPath };
|
|
122492
|
+
if ((0, import_path20.resolve)(sourceConfigPath) === (0, import_path20.resolve)(targetConfigPath)) return { config: {}, sourceHome, sourceConfigPath };
|
|
122493
|
+
const parsed = parseMeshCoordinatorMcpConfig(fs52.readFileSync(sourceConfigPath, "utf-8"), "hermes_config_yaml");
|
|
122202
122494
|
const { mcp_servers: _mcpServers, ...baseConfig } = parsed;
|
|
122203
122495
|
return { config: baseConfig, sourceHome, sourceConfigPath };
|
|
122204
122496
|
}
|
|
@@ -122231,13 +122523,13 @@ ${ptyResult.output.slice(-2e3)}`);
|
|
|
122231
122523
|
return sanitized;
|
|
122232
122524
|
}
|
|
122233
122525
|
function copyHermesCoordinatorCredentialFiles(sourceHome, targetHome) {
|
|
122234
|
-
if ((0,
|
|
122526
|
+
if ((0, import_path20.resolve)(sourceHome) === (0, import_path20.resolve)(targetHome)) return;
|
|
122235
122527
|
for (const fileName of [".env", "auth.json"]) {
|
|
122236
|
-
const sourcePath = (0,
|
|
122237
|
-
const targetPath = (0,
|
|
122238
|
-
if (!
|
|
122528
|
+
const sourcePath = (0, import_path20.join)(sourceHome, fileName);
|
|
122529
|
+
const targetPath = (0, import_path20.join)(targetHome, fileName);
|
|
122530
|
+
if (!fs52.existsSync(sourcePath)) continue;
|
|
122239
122531
|
try {
|
|
122240
|
-
|
|
122532
|
+
fs52.copyFileSync(sourcePath, targetPath);
|
|
122241
122533
|
} catch (error48) {
|
|
122242
122534
|
LOG2.warn("MeshCoordinator", `Could not copy Hermes ${fileName} into isolated coordinator home: ${error48?.message || error48}`);
|
|
122243
122535
|
}
|
|
@@ -122752,7 +123044,7 @@ ${ptyResult.output.slice(-2e3)}`);
|
|
|
122752
123044
|
const nodeId = readInlineMeshNodeId(node);
|
|
122753
123045
|
if (!nodeId || !tombstones.has(nodeId)) return true;
|
|
122754
123046
|
const workspace = readStringValue(node?.workspace);
|
|
122755
|
-
if (workspace &&
|
|
123047
|
+
if (workspace && fs53.existsSync(workspace)) {
|
|
122756
123048
|
tombstones.delete(nodeId);
|
|
122757
123049
|
return true;
|
|
122758
123050
|
}
|
|
@@ -124812,7 +125104,7 @@ ${ptyResult.output.slice(-2e3)}`);
|
|
|
124812
125104
|
};
|
|
124813
125105
|
init_io_contracts();
|
|
124814
125106
|
init_chat_message_normalization();
|
|
124815
|
-
var
|
|
125107
|
+
var fs54 = __toESM2(require("fs"));
|
|
124816
125108
|
var path522 = __toESM2(require("path"));
|
|
124817
125109
|
var os28 = __toESM2(require("os"));
|
|
124818
125110
|
var import_os6 = require("os");
|
|
@@ -124829,8 +125121,8 @@ ${ptyResult.output.slice(-2e3)}`);
|
|
|
124829
125121
|
}
|
|
124830
125122
|
load() {
|
|
124831
125123
|
try {
|
|
124832
|
-
if (
|
|
124833
|
-
this.history = JSON.parse(
|
|
125124
|
+
if (fs54.existsSync(getArchivePath2())) {
|
|
125125
|
+
this.history = JSON.parse(fs54.readFileSync(getArchivePath2(), "utf-8"));
|
|
124834
125126
|
}
|
|
124835
125127
|
} catch {
|
|
124836
125128
|
this.history = {};
|
|
@@ -124867,8 +125159,8 @@ ${ptyResult.output.slice(-2e3)}`);
|
|
|
124867
125159
|
}
|
|
124868
125160
|
save() {
|
|
124869
125161
|
try {
|
|
124870
|
-
|
|
124871
|
-
|
|
125162
|
+
fs54.mkdirSync(path522.dirname(getArchivePath2()), { recursive: true });
|
|
125163
|
+
fs54.writeFileSync(getArchivePath2(), JSON.stringify(this.history, null, 2));
|
|
124872
125164
|
} catch {
|
|
124873
125165
|
}
|
|
124874
125166
|
}
|
|
@@ -124893,8 +125185,8 @@ ${ptyResult.output.slice(-2e3)}`);
|
|
|
124893
125185
|
for (const ext of exes) {
|
|
124894
125186
|
const fullPath = path522.join(p, name + ext);
|
|
124895
125187
|
try {
|
|
124896
|
-
if (
|
|
124897
|
-
const stat2 =
|
|
125188
|
+
if (fs54.existsSync(fullPath)) {
|
|
125189
|
+
const stat2 = fs54.statSync(fullPath);
|
|
124898
125190
|
if (stat2.isFile() && (isWin || stat2.mode & 73)) {
|
|
124899
125191
|
return fullPath;
|
|
124900
125192
|
}
|
|
@@ -124941,9 +125233,9 @@ ${ptyResult.output.slice(-2e3)}`);
|
|
|
124941
125233
|
if (p.includes("*")) {
|
|
124942
125234
|
const home = os28.homedir();
|
|
124943
125235
|
const resolved = p.replace(/\*/g, home.split(path522.sep).pop() || "");
|
|
124944
|
-
if (
|
|
125236
|
+
if (fs54.existsSync(resolved)) return resolved;
|
|
124945
125237
|
} else {
|
|
124946
|
-
if (
|
|
125238
|
+
if (fs54.existsSync(p)) return p;
|
|
124947
125239
|
}
|
|
124948
125240
|
}
|
|
124949
125241
|
return null;
|
|
@@ -124951,7 +125243,7 @@ ${ptyResult.output.slice(-2e3)}`);
|
|
|
124951
125243
|
async function getMacAppVersion(appPath) {
|
|
124952
125244
|
if ((0, import_os6.platform)() !== "darwin" || !appPath.endsWith(".app")) return null;
|
|
124953
125245
|
const plistPath = path522.join(appPath, "Contents", "Info.plist");
|
|
124954
|
-
if (!
|
|
125246
|
+
if (!fs54.existsSync(plistPath)) return null;
|
|
124955
125247
|
const raw = await runCommand(`/usr/libexec/PlistBuddy -c "Print CFBundleShortVersionString" "${plistPath}"`);
|
|
124956
125248
|
return raw || null;
|
|
124957
125249
|
}
|
|
@@ -124978,7 +125270,7 @@ ${ptyResult.output.slice(-2e3)}`);
|
|
|
124978
125270
|
let resolvedBin = cliBin;
|
|
124979
125271
|
if (!resolvedBin && appPath && currentOs === "darwin") {
|
|
124980
125272
|
const bundled = path522.join(appPath, "Contents", "Resources", "app", "bin", provider.cli || "");
|
|
124981
|
-
if (provider.cli &&
|
|
125273
|
+
if (provider.cli && fs54.existsSync(bundled)) resolvedBin = bundled;
|
|
124982
125274
|
}
|
|
124983
125275
|
info.installed = !!(appPath || resolvedBin);
|
|
124984
125276
|
info.path = appPath || null;
|
|
@@ -125024,7 +125316,7 @@ ${ptyResult.output.slice(-2e3)}`);
|
|
|
125024
125316
|
return results;
|
|
125025
125317
|
}
|
|
125026
125318
|
var http3 = __toESM2(require("http"));
|
|
125027
|
-
var
|
|
125319
|
+
var fs58 = __toESM2(require("fs"));
|
|
125028
125320
|
var path56 = __toESM2(require("path"));
|
|
125029
125321
|
init_config();
|
|
125030
125322
|
function generateFiles(type2, name, category, opts = {}) {
|
|
@@ -125370,7 +125662,7 @@ async (params) => {
|
|
|
125370
125662
|
}
|
|
125371
125663
|
init_logger();
|
|
125372
125664
|
init_builders();
|
|
125373
|
-
var
|
|
125665
|
+
var fs55 = __toESM2(require("fs"));
|
|
125374
125666
|
var path53 = __toESM2(require("path"));
|
|
125375
125667
|
init_logger();
|
|
125376
125668
|
async function handleCdpEvaluate(ctx, req, res) {
|
|
@@ -125551,17 +125843,17 @@ async (params) => {
|
|
|
125551
125843
|
}
|
|
125552
125844
|
let scriptsPath = "";
|
|
125553
125845
|
const directScripts = path53.join(dir, "scripts.js");
|
|
125554
|
-
if (
|
|
125846
|
+
if (fs55.existsSync(directScripts)) {
|
|
125555
125847
|
scriptsPath = directScripts;
|
|
125556
125848
|
} else {
|
|
125557
125849
|
const scriptsDir = path53.join(dir, "scripts");
|
|
125558
|
-
if (
|
|
125559
|
-
const versions =
|
|
125560
|
-
return
|
|
125850
|
+
if (fs55.existsSync(scriptsDir)) {
|
|
125851
|
+
const versions = fs55.readdirSync(scriptsDir).filter((d) => {
|
|
125852
|
+
return fs55.statSync(path53.join(scriptsDir, d)).isDirectory();
|
|
125561
125853
|
}).sort().reverse();
|
|
125562
125854
|
for (const ver of versions) {
|
|
125563
125855
|
const p = path53.join(scriptsDir, ver, "scripts.js");
|
|
125564
|
-
if (
|
|
125856
|
+
if (fs55.existsSync(p)) {
|
|
125565
125857
|
scriptsPath = p;
|
|
125566
125858
|
break;
|
|
125567
125859
|
}
|
|
@@ -125573,7 +125865,7 @@ async (params) => {
|
|
|
125573
125865
|
return;
|
|
125574
125866
|
}
|
|
125575
125867
|
try {
|
|
125576
|
-
const source =
|
|
125868
|
+
const source = fs55.readFileSync(scriptsPath, "utf-8");
|
|
125577
125869
|
const hints = {};
|
|
125578
125870
|
const funcRegex = /module\.exports\.(\w+)\s*=\s*function\s+\w+\s*\(params\)/g;
|
|
125579
125871
|
let match;
|
|
@@ -126386,7 +126678,7 @@ async (params) => {
|
|
|
126386
126678
|
ctx.json(res, 500, { error: `DOM context collection failed: ${e.message}` });
|
|
126387
126679
|
}
|
|
126388
126680
|
}
|
|
126389
|
-
var
|
|
126681
|
+
var fs56 = __toESM2(require("fs"));
|
|
126390
126682
|
var path54 = __toESM2(require("path"));
|
|
126391
126683
|
function slugifyFixtureName(value) {
|
|
126392
126684
|
const normalized = String(value || "").trim().toLowerCase().replace(/[^a-z0-9._-]+/g, "-").replace(/^-+|-+$/g, "");
|
|
@@ -126402,10 +126694,10 @@ async (params) => {
|
|
|
126402
126694
|
function readCliFixture(ctx, type2, name) {
|
|
126403
126695
|
const fixtureDir = getCliFixtureDir(ctx, type2);
|
|
126404
126696
|
const filePath = path54.join(fixtureDir, `${name}.json`);
|
|
126405
|
-
if (!
|
|
126697
|
+
if (!fs56.existsSync(filePath)) {
|
|
126406
126698
|
throw new Error(`Fixture not found: ${filePath}`);
|
|
126407
126699
|
}
|
|
126408
|
-
return JSON.parse(
|
|
126700
|
+
return JSON.parse(fs56.readFileSync(filePath, "utf-8"));
|
|
126409
126701
|
}
|
|
126410
126702
|
function getExerciseTranscriptText(result) {
|
|
126411
126703
|
const parts = [];
|
|
@@ -127155,7 +127447,7 @@ async (params) => {
|
|
|
127155
127447
|
return;
|
|
127156
127448
|
}
|
|
127157
127449
|
const fixtureDir = getCliFixtureDir(ctx, type2);
|
|
127158
|
-
|
|
127450
|
+
fs56.mkdirSync(fixtureDir, { recursive: true });
|
|
127159
127451
|
const name = slugifyFixtureName(String(body?.name || `${type2}-${Date.now()}`));
|
|
127160
127452
|
const result = await runCliExerciseInternal(ctx, { ...request, type: type2 });
|
|
127161
127453
|
const fixture = {
|
|
@@ -127183,7 +127475,7 @@ async (params) => {
|
|
|
127183
127475
|
notes: typeof body?.notes === "string" ? body.notes : void 0
|
|
127184
127476
|
};
|
|
127185
127477
|
const filePath = path54.join(fixtureDir, `${name}.json`);
|
|
127186
|
-
|
|
127478
|
+
fs56.writeFileSync(filePath, JSON.stringify(fixture, null, 2));
|
|
127187
127479
|
ctx.json(res, 200, {
|
|
127188
127480
|
saved: true,
|
|
127189
127481
|
name,
|
|
@@ -127201,14 +127493,14 @@ async (params) => {
|
|
|
127201
127493
|
async function handleCliFixtureList(ctx, type2, _req, res) {
|
|
127202
127494
|
try {
|
|
127203
127495
|
const fixtureDir = getCliFixtureDir(ctx, type2);
|
|
127204
|
-
if (!
|
|
127496
|
+
if (!fs56.existsSync(fixtureDir)) {
|
|
127205
127497
|
ctx.json(res, 200, { fixtures: [], count: 0 });
|
|
127206
127498
|
return;
|
|
127207
127499
|
}
|
|
127208
|
-
const fixtures =
|
|
127500
|
+
const fixtures = fs56.readdirSync(fixtureDir).filter((file2) => file2.endsWith(".json")).sort((a, b) => b.localeCompare(a, void 0, { numeric: true, sensitivity: "base" })).map((file2) => {
|
|
127209
127501
|
const fullPath = path54.join(fixtureDir, file2);
|
|
127210
127502
|
try {
|
|
127211
|
-
const raw = JSON.parse(
|
|
127503
|
+
const raw = JSON.parse(fs56.readFileSync(fullPath, "utf-8"));
|
|
127212
127504
|
return {
|
|
127213
127505
|
name: raw.name || file2.replace(/\.json$/i, ""),
|
|
127214
127506
|
path: fullPath,
|
|
@@ -127339,7 +127631,7 @@ async (params) => {
|
|
|
127339
127631
|
ctx.json(res, 500, { error: `Raw send failed: ${e.message}` });
|
|
127340
127632
|
}
|
|
127341
127633
|
}
|
|
127342
|
-
var
|
|
127634
|
+
var fs57 = __toESM2(require("fs"));
|
|
127343
127635
|
var path55 = __toESM2(require("path"));
|
|
127344
127636
|
var os29 = __toESM2(require("os"));
|
|
127345
127637
|
var import_session_host_core10 = require_dist();
|
|
@@ -127388,10 +127680,10 @@ async (params) => {
|
|
|
127388
127680
|
return fallback?.type || null;
|
|
127389
127681
|
}
|
|
127390
127682
|
function getLatestScriptVersionDir(scriptsDir) {
|
|
127391
|
-
if (!
|
|
127392
|
-
const versions =
|
|
127683
|
+
if (!fs57.existsSync(scriptsDir)) return null;
|
|
127684
|
+
const versions = fs57.readdirSync(scriptsDir).filter((d) => {
|
|
127393
127685
|
try {
|
|
127394
|
-
return
|
|
127686
|
+
return fs57.statSync(path55.join(scriptsDir, d)).isDirectory();
|
|
127395
127687
|
} catch {
|
|
127396
127688
|
return false;
|
|
127397
127689
|
}
|
|
@@ -127413,13 +127705,13 @@ async (params) => {
|
|
|
127413
127705
|
if (!sourceDir) {
|
|
127414
127706
|
return { dir: null, reason: `Provider source directory not found for '${type2}'` };
|
|
127415
127707
|
}
|
|
127416
|
-
if (!
|
|
127417
|
-
|
|
127418
|
-
|
|
127708
|
+
if (!fs57.existsSync(desiredDir)) {
|
|
127709
|
+
fs57.mkdirSync(path55.dirname(desiredDir), { recursive: true });
|
|
127710
|
+
fs57.cpSync(sourceDir, desiredDir, { recursive: true });
|
|
127419
127711
|
ctx.log(`Auto-implement writable copy created: ${desiredDir}`);
|
|
127420
127712
|
}
|
|
127421
127713
|
const providerJson = path55.join(desiredDir, "provider.json");
|
|
127422
|
-
if (!
|
|
127714
|
+
if (!fs57.existsSync(providerJson)) {
|
|
127423
127715
|
return { dir: null, reason: `provider.json not found in writable provider directory: ${desiredDir}` };
|
|
127424
127716
|
}
|
|
127425
127717
|
return { dir: desiredDir };
|
|
@@ -127427,15 +127719,15 @@ async (params) => {
|
|
|
127427
127719
|
function loadAutoImplReferenceScripts(ctx, referenceType) {
|
|
127428
127720
|
if (!referenceType) return {};
|
|
127429
127721
|
const refDir = ctx.findProviderDir(referenceType);
|
|
127430
|
-
if (!refDir || !
|
|
127722
|
+
if (!refDir || !fs57.existsSync(refDir)) return {};
|
|
127431
127723
|
const referenceScripts = {};
|
|
127432
127724
|
const scriptsDir = path55.join(refDir, "scripts");
|
|
127433
127725
|
const latestDir = getLatestScriptVersionDir(scriptsDir);
|
|
127434
127726
|
if (!latestDir) return referenceScripts;
|
|
127435
|
-
for (const file2 of
|
|
127727
|
+
for (const file2 of fs57.readdirSync(latestDir)) {
|
|
127436
127728
|
if (!file2.endsWith(".js")) continue;
|
|
127437
127729
|
try {
|
|
127438
|
-
referenceScripts[file2] =
|
|
127730
|
+
referenceScripts[file2] = fs57.readFileSync(path55.join(latestDir, file2), "utf-8");
|
|
127439
127731
|
} catch {
|
|
127440
127732
|
}
|
|
127441
127733
|
}
|
|
@@ -127544,15 +127836,15 @@ async (params) => {
|
|
|
127544
127836
|
const referenceScripts = loadAutoImplReferenceScripts(ctx, resolvedReference);
|
|
127545
127837
|
const prompt = buildAutoImplPrompt(ctx, type2, provider, providerDir, functions, domContext, referenceScripts, comment, resolvedReference, verification);
|
|
127546
127838
|
const tmpDir = path55.join(os29.tmpdir(), "adhdev-autoimpl");
|
|
127547
|
-
if (!
|
|
127839
|
+
if (!fs57.existsSync(tmpDir)) fs57.mkdirSync(tmpDir, { recursive: true });
|
|
127548
127840
|
const promptFile = path55.join(tmpDir, `prompt-${type2}-${Date.now()}.md`);
|
|
127549
|
-
|
|
127841
|
+
fs57.writeFileSync(promptFile, prompt, "utf-8");
|
|
127550
127842
|
ctx.log(`Auto-implement prompt written to ${promptFile} (${prompt.length} chars)`);
|
|
127551
127843
|
const agentProvider = ctx.providerLoader.resolve(agent) || ctx.providerLoader.getMeta(agent);
|
|
127552
127844
|
const spawn7 = agentProvider?.spawn;
|
|
127553
127845
|
if (!spawn7?.command) {
|
|
127554
127846
|
try {
|
|
127555
|
-
|
|
127847
|
+
fs57.unlinkSync(promptFile);
|
|
127556
127848
|
} catch {
|
|
127557
127849
|
}
|
|
127558
127850
|
ctx.json(res, 400, { error: `Agent '${agent}' has no spawn config. Select a CLI provider with a spawn configuration.` });
|
|
@@ -127654,7 +127946,7 @@ async (params) => {
|
|
|
127654
127946
|
} catch {
|
|
127655
127947
|
}
|
|
127656
127948
|
try {
|
|
127657
|
-
|
|
127949
|
+
fs57.unlinkSync(promptFile);
|
|
127658
127950
|
} catch {
|
|
127659
127951
|
}
|
|
127660
127952
|
ctx.log(`Auto-implement (ACP) ${success2 ? "completed" : "failed"}: ${type2} (exit: ${code})`);
|
|
@@ -127877,7 +128169,7 @@ async (params) => {
|
|
|
127877
128169
|
}
|
|
127878
128170
|
});
|
|
127879
128171
|
try {
|
|
127880
|
-
|
|
128172
|
+
fs57.unlinkSync(promptFile);
|
|
127881
128173
|
} catch {
|
|
127882
128174
|
}
|
|
127883
128175
|
ctx.log(`Auto-implement ${success2 ? "completed" : "failed"}: ${type2} (exit: ${code})${verificationSummary ? ` verify=${verificationSummary.pass ? "pass" : "fail"}` : ""}`);
|
|
@@ -127982,10 +128274,10 @@ async (params) => {
|
|
|
127982
128274
|
lines.push("## \u270F\uFE0F Target Files (EDIT THESE)");
|
|
127983
128275
|
lines.push("These are the ONLY files you are allowed to modify. Replace the TODO stubs with working implementations.");
|
|
127984
128276
|
lines.push("");
|
|
127985
|
-
for (const file2 of
|
|
128277
|
+
for (const file2 of fs57.readdirSync(latestScriptsDir)) {
|
|
127986
128278
|
if (file2.endsWith(".js") && targetFileNames.has(file2)) {
|
|
127987
128279
|
try {
|
|
127988
|
-
const content =
|
|
128280
|
+
const content = fs57.readFileSync(path55.join(latestScriptsDir, file2), "utf-8");
|
|
127989
128281
|
lines.push(`### \`${file2}\` \u270F\uFE0F EDIT`);
|
|
127990
128282
|
lines.push("```javascript");
|
|
127991
128283
|
lines.push(content);
|
|
@@ -127995,14 +128287,14 @@ async (params) => {
|
|
|
127995
128287
|
}
|
|
127996
128288
|
}
|
|
127997
128289
|
}
|
|
127998
|
-
const refFiles =
|
|
128290
|
+
const refFiles = fs57.readdirSync(latestScriptsDir).filter((f) => f.endsWith(".js") && !targetFileNames.has(f));
|
|
127999
128291
|
if (refFiles.length > 0) {
|
|
128000
128292
|
lines.push("## \u{1F512} Other Scripts (REFERENCE ONLY \u2014 DO NOT EDIT)");
|
|
128001
128293
|
lines.push("These files are shown for context only. Do NOT modify them under any circumstances.");
|
|
128002
128294
|
lines.push("");
|
|
128003
128295
|
for (const file2 of refFiles) {
|
|
128004
128296
|
try {
|
|
128005
|
-
const content =
|
|
128297
|
+
const content = fs57.readFileSync(path55.join(latestScriptsDir, file2), "utf-8");
|
|
128006
128298
|
lines.push(`### \`${file2}\` \u{1F512}`);
|
|
128007
128299
|
lines.push("```javascript");
|
|
128008
128300
|
lines.push(content);
|
|
@@ -128047,7 +128339,7 @@ async (params) => {
|
|
|
128047
128339
|
const loadGuide = (name) => {
|
|
128048
128340
|
try {
|
|
128049
128341
|
const p = path55.join(docsDir, name);
|
|
128050
|
-
if (
|
|
128342
|
+
if (fs57.existsSync(p)) return fs57.readFileSync(p, "utf-8");
|
|
128051
128343
|
} catch {
|
|
128052
128344
|
}
|
|
128053
128345
|
return null;
|
|
@@ -128291,11 +128583,11 @@ async (params) => {
|
|
|
128291
128583
|
lines.push("## \u270F\uFE0F Target Files (EDIT THESE)");
|
|
128292
128584
|
lines.push("These are the ONLY files you are allowed to modify. Replace TODO or heuristic-only logic with working PTY-aware implementations.");
|
|
128293
128585
|
lines.push("");
|
|
128294
|
-
for (const file2 of
|
|
128586
|
+
for (const file2 of fs57.readdirSync(latestScriptsDir)) {
|
|
128295
128587
|
if (!file2.endsWith(".js")) continue;
|
|
128296
128588
|
if (!targetFileNames.has(file2)) continue;
|
|
128297
128589
|
try {
|
|
128298
|
-
const content =
|
|
128590
|
+
const content = fs57.readFileSync(path55.join(latestScriptsDir, file2), "utf-8");
|
|
128299
128591
|
lines.push(`### \`${file2}\` \u270F\uFE0F EDIT`);
|
|
128300
128592
|
lines.push("```javascript");
|
|
128301
128593
|
lines.push(content);
|
|
@@ -128304,14 +128596,14 @@ async (params) => {
|
|
|
128304
128596
|
} catch {
|
|
128305
128597
|
}
|
|
128306
128598
|
}
|
|
128307
|
-
const refFiles =
|
|
128599
|
+
const refFiles = fs57.readdirSync(latestScriptsDir).filter((f) => f.endsWith(".js") && !targetFileNames.has(f));
|
|
128308
128600
|
if (refFiles.length > 0) {
|
|
128309
128601
|
lines.push("## \u{1F512} Other Scripts (REFERENCE ONLY \u2014 DO NOT EDIT)");
|
|
128310
128602
|
lines.push("These files are shown for context only. Do NOT modify them under any circumstances.");
|
|
128311
128603
|
lines.push("");
|
|
128312
128604
|
for (const file2 of refFiles) {
|
|
128313
128605
|
try {
|
|
128314
|
-
const content =
|
|
128606
|
+
const content = fs57.readFileSync(path55.join(latestScriptsDir, file2), "utf-8");
|
|
128315
128607
|
lines.push(`### \`${file2}\` \u{1F512}`);
|
|
128316
128608
|
lines.push("```javascript");
|
|
128317
128609
|
lines.push(content);
|
|
@@ -128348,7 +128640,7 @@ async (params) => {
|
|
|
128348
128640
|
const loadGuide = (name) => {
|
|
128349
128641
|
try {
|
|
128350
128642
|
const p = path55.join(docsDir, name);
|
|
128351
|
-
if (
|
|
128643
|
+
if (fs57.existsSync(p)) return fs57.readFileSync(p, "utf-8");
|
|
128352
128644
|
} catch {
|
|
128353
128645
|
}
|
|
128354
128646
|
return null;
|
|
@@ -129086,7 +129378,7 @@ data: ${JSON.stringify(msg.data)}
|
|
|
129086
129378
|
path56.join(process.cwd(), "packages/web-devconsole/dist")
|
|
129087
129379
|
];
|
|
129088
129380
|
for (const dir of candidates) {
|
|
129089
|
-
if (
|
|
129381
|
+
if (fs58.existsSync(path56.join(dir, "index.html"))) return dir;
|
|
129090
129382
|
}
|
|
129091
129383
|
return null;
|
|
129092
129384
|
}
|
|
@@ -129098,7 +129390,7 @@ data: ${JSON.stringify(msg.data)}
|
|
|
129098
129390
|
}
|
|
129099
129391
|
const htmlPath = path56.join(distDir, "index.html");
|
|
129100
129392
|
try {
|
|
129101
|
-
const html =
|
|
129393
|
+
const html = fs58.readFileSync(htmlPath, "utf-8");
|
|
129102
129394
|
res.writeHead(200, { "Content-Type": "text/html; charset=utf-8" });
|
|
129103
129395
|
res.end(html);
|
|
129104
129396
|
} catch (e) {
|
|
@@ -129128,7 +129420,7 @@ data: ${JSON.stringify(msg.data)}
|
|
|
129128
129420
|
return;
|
|
129129
129421
|
}
|
|
129130
129422
|
try {
|
|
129131
|
-
const content =
|
|
129423
|
+
const content = fs58.readFileSync(filePath);
|
|
129132
129424
|
const ext = path56.extname(filePath);
|
|
129133
129425
|
const contentType = _DevServer.MIME_MAP[ext] || "application/octet-stream";
|
|
129134
129426
|
res.writeHead(200, { "Content-Type": contentType, "Cache-Control": "public, max-age=31536000, immutable" });
|
|
@@ -129237,14 +129529,14 @@ data: ${JSON.stringify(msg.data)}
|
|
|
129237
129529
|
const files = [];
|
|
129238
129530
|
const scan = (d, prefix) => {
|
|
129239
129531
|
try {
|
|
129240
|
-
for (const entry of
|
|
129532
|
+
for (const entry of fs58.readdirSync(d, { withFileTypes: true })) {
|
|
129241
129533
|
if (entry.name.startsWith(".") || entry.name.endsWith(".bak")) continue;
|
|
129242
129534
|
const rel = prefix ? `${prefix}/${entry.name}` : entry.name;
|
|
129243
129535
|
if (entry.isDirectory()) {
|
|
129244
129536
|
files.push({ path: rel, size: 0, type: "dir" });
|
|
129245
129537
|
scan(path56.join(d, entry.name), rel);
|
|
129246
129538
|
} else {
|
|
129247
|
-
const stat2 =
|
|
129539
|
+
const stat2 = fs58.statSync(path56.join(d, entry.name));
|
|
129248
129540
|
files.push({ path: rel, size: stat2.size, type: "file" });
|
|
129249
129541
|
}
|
|
129250
129542
|
}
|
|
@@ -129272,11 +129564,11 @@ data: ${JSON.stringify(msg.data)}
|
|
|
129272
129564
|
this.json(res, 403, { error: "Forbidden" });
|
|
129273
129565
|
return;
|
|
129274
129566
|
}
|
|
129275
|
-
if (!
|
|
129567
|
+
if (!fs58.existsSync(fullPath) || fs58.statSync(fullPath).isDirectory()) {
|
|
129276
129568
|
this.json(res, 404, { error: `File not found: ${filePath}` });
|
|
129277
129569
|
return;
|
|
129278
129570
|
}
|
|
129279
|
-
const content =
|
|
129571
|
+
const content = fs58.readFileSync(fullPath, "utf-8");
|
|
129280
129572
|
this.json(res, 200, { type: type2, path: filePath, content, lines: content.split("\n").length });
|
|
129281
129573
|
}
|
|
129282
129574
|
/** POST /api/providers/:type/file — write a file { path, content } */
|
|
@@ -129298,9 +129590,9 @@ data: ${JSON.stringify(msg.data)}
|
|
|
129298
129590
|
return;
|
|
129299
129591
|
}
|
|
129300
129592
|
try {
|
|
129301
|
-
if (
|
|
129302
|
-
|
|
129303
|
-
|
|
129593
|
+
if (fs58.existsSync(fullPath)) fs58.copyFileSync(fullPath, fullPath + ".bak");
|
|
129594
|
+
fs58.mkdirSync(path56.dirname(fullPath), { recursive: true });
|
|
129595
|
+
fs58.writeFileSync(fullPath, content, "utf-8");
|
|
129304
129596
|
this.log(`File saved: ${fullPath} (${content.length} chars)`);
|
|
129305
129597
|
this.providerLoader.reload();
|
|
129306
129598
|
this.json(res, 200, { saved: true, path: filePath, chars: content.length });
|
|
@@ -129317,8 +129609,8 @@ data: ${JSON.stringify(msg.data)}
|
|
|
129317
129609
|
}
|
|
129318
129610
|
for (const name of ["scripts.js", "provider.json"]) {
|
|
129319
129611
|
const p = path56.join(dir, name);
|
|
129320
|
-
if (
|
|
129321
|
-
const source =
|
|
129612
|
+
if (fs58.existsSync(p)) {
|
|
129613
|
+
const source = fs58.readFileSync(p, "utf-8");
|
|
129322
129614
|
this.json(res, 200, { type: type2, path: p, source, lines: source.split("\n").length });
|
|
129323
129615
|
return;
|
|
129324
129616
|
}
|
|
@@ -129337,11 +129629,11 @@ data: ${JSON.stringify(msg.data)}
|
|
|
129337
129629
|
this.json(res, 404, { error: `Provider not found: ${type2}` });
|
|
129338
129630
|
return;
|
|
129339
129631
|
}
|
|
129340
|
-
const target =
|
|
129632
|
+
const target = fs58.existsSync(path56.join(dir, "scripts.js")) ? "scripts.js" : "provider.json";
|
|
129341
129633
|
const targetPath = path56.join(dir, target);
|
|
129342
129634
|
try {
|
|
129343
|
-
if (
|
|
129344
|
-
|
|
129635
|
+
if (fs58.existsSync(targetPath)) fs58.copyFileSync(targetPath, targetPath + ".bak");
|
|
129636
|
+
fs58.writeFileSync(targetPath, source, "utf-8");
|
|
129345
129637
|
this.log(`Saved provider: ${targetPath} (${source.length} chars)`);
|
|
129346
129638
|
this.providerLoader.reload();
|
|
129347
129639
|
this.json(res, 200, { saved: true, path: targetPath, chars: source.length });
|
|
@@ -129486,20 +129778,20 @@ data: ${JSON.stringify(msg.data)}
|
|
|
129486
129778
|
let targetDir;
|
|
129487
129779
|
targetDir = this.providerLoader.getUserProviderDir(category, type2);
|
|
129488
129780
|
const jsonPath = path56.join(targetDir, "provider.json");
|
|
129489
|
-
if (
|
|
129781
|
+
if (fs58.existsSync(jsonPath)) {
|
|
129490
129782
|
this.json(res, 409, { error: `Provider already exists at ${targetDir}`, path: targetDir });
|
|
129491
129783
|
return;
|
|
129492
129784
|
}
|
|
129493
129785
|
try {
|
|
129494
129786
|
const result = generateFiles(type2, name, category, { cdpPorts, cli, processName, installPath, binary: binary2, extensionId, version: version2, osPaths, processNames });
|
|
129495
|
-
|
|
129496
|
-
|
|
129787
|
+
fs58.mkdirSync(targetDir, { recursive: true });
|
|
129788
|
+
fs58.writeFileSync(jsonPath, result["provider.json"], "utf-8");
|
|
129497
129789
|
const createdFiles = ["provider.json"];
|
|
129498
129790
|
if (result.files) {
|
|
129499
129791
|
for (const [relPath, content] of Object.entries(result.files)) {
|
|
129500
129792
|
const fullPath = path56.join(targetDir, relPath);
|
|
129501
|
-
|
|
129502
|
-
|
|
129793
|
+
fs58.mkdirSync(path56.dirname(fullPath), { recursive: true });
|
|
129794
|
+
fs58.writeFileSync(fullPath, content, "utf-8");
|
|
129503
129795
|
createdFiles.push(relPath);
|
|
129504
129796
|
}
|
|
129505
129797
|
}
|
|
@@ -129548,10 +129840,10 @@ data: ${JSON.stringify(msg.data)}
|
|
|
129548
129840
|
}
|
|
129549
129841
|
// ─── Phase 2: Auto-Implement Backend ───
|
|
129550
129842
|
getLatestScriptVersionDir(scriptsDir) {
|
|
129551
|
-
if (!
|
|
129552
|
-
const versions =
|
|
129843
|
+
if (!fs58.existsSync(scriptsDir)) return null;
|
|
129844
|
+
const versions = fs58.readdirSync(scriptsDir).filter((d) => {
|
|
129553
129845
|
try {
|
|
129554
|
-
return
|
|
129846
|
+
return fs58.statSync(path56.join(scriptsDir, d)).isDirectory();
|
|
129555
129847
|
} catch {
|
|
129556
129848
|
return false;
|
|
129557
129849
|
}
|
|
@@ -129573,13 +129865,13 @@ data: ${JSON.stringify(msg.data)}
|
|
|
129573
129865
|
if (!sourceDir) {
|
|
129574
129866
|
return { dir: null, reason: `Provider source directory not found for '${type2}'` };
|
|
129575
129867
|
}
|
|
129576
|
-
if (!
|
|
129577
|
-
|
|
129578
|
-
|
|
129868
|
+
if (!fs58.existsSync(desiredDir)) {
|
|
129869
|
+
fs58.mkdirSync(path56.dirname(desiredDir), { recursive: true });
|
|
129870
|
+
fs58.cpSync(sourceDir, desiredDir, { recursive: true });
|
|
129579
129871
|
this.log(`Auto-implement writable copy created: ${desiredDir}`);
|
|
129580
129872
|
}
|
|
129581
129873
|
const providerJson = path56.join(desiredDir, "provider.json");
|
|
129582
|
-
if (!
|
|
129874
|
+
if (!fs58.existsSync(providerJson)) {
|
|
129583
129875
|
return { dir: null, reason: `provider.json not found in writable provider directory: ${desiredDir}` };
|
|
129584
129876
|
}
|
|
129585
129877
|
return { dir: desiredDir };
|
|
@@ -130388,7 +130680,7 @@ data: ${JSON.stringify(msg.data)}
|
|
|
130388
130680
|
}
|
|
130389
130681
|
}
|
|
130390
130682
|
var import_child_process14 = require("child_process");
|
|
130391
|
-
var
|
|
130683
|
+
var fs59 = __toESM2(require("fs"));
|
|
130392
130684
|
var os30 = __toESM2(require("os"));
|
|
130393
130685
|
var path57 = __toESM2(require("path"));
|
|
130394
130686
|
var import_session_host_core14 = require_dist();
|
|
@@ -130414,7 +130706,7 @@ data: ${JSON.stringify(msg.data)}
|
|
|
130414
130706
|
path57.resolve(__dirname, "../../vendor/session-host-daemon/index.js")
|
|
130415
130707
|
];
|
|
130416
130708
|
for (const candidate of packagedCandidates) {
|
|
130417
|
-
if (
|
|
130709
|
+
if (fs59.existsSync(candidate)) {
|
|
130418
130710
|
return candidate;
|
|
130419
130711
|
}
|
|
130420
130712
|
}
|
|
@@ -130434,8 +130726,8 @@ data: ${JSON.stringify(msg.data)}
|
|
|
130434
130726
|
function getPid() {
|
|
130435
130727
|
try {
|
|
130436
130728
|
const pidFile = getPidFile();
|
|
130437
|
-
if (!
|
|
130438
|
-
const pid = Number.parseInt(
|
|
130729
|
+
if (!fs59.existsSync(pidFile)) return null;
|
|
130730
|
+
const pid = Number.parseInt(fs59.readFileSync(pidFile, "utf8").trim(), 10);
|
|
130439
130731
|
return Number.isFinite(pid) ? pid : null;
|
|
130440
130732
|
} catch {
|
|
130441
130733
|
return null;
|
|
@@ -130485,7 +130777,7 @@ data: ${JSON.stringify(msg.data)}
|
|
|
130485
130777
|
if (markerIndex === -1) return;
|
|
130486
130778
|
const activePrefix = entry.slice(0, markerIndex);
|
|
130487
130779
|
const candidates = resolveConptyPrebuildCandidates(activePrefix);
|
|
130488
|
-
const found = candidates.find((candidate) =>
|
|
130780
|
+
const found = candidates.find((candidate) => fs59.existsSync(candidate));
|
|
130489
130781
|
if (!found) {
|
|
130490
130782
|
throw new Error(
|
|
130491
130783
|
`conpty.node missing at boot despite passing the install-time gate \u2014 likely deleted post-install (checked: ${candidates.join(", ")}). Every session-host spawn would crash requiring node-pty; refusing to spawn.`
|
|
@@ -130501,8 +130793,8 @@ data: ${JSON.stringify(msg.data)}
|
|
|
130501
130793
|
let logFd = null;
|
|
130502
130794
|
if (options.spawnStdio === "logfile") {
|
|
130503
130795
|
const logDir = path57.join(instance().configDir, "logs");
|
|
130504
|
-
|
|
130505
|
-
logFd =
|
|
130796
|
+
fs59.mkdirSync(logDir, { recursive: true });
|
|
130797
|
+
logFd = fs59.openSync(path57.join(logDir, "session-host.log"), "a");
|
|
130506
130798
|
stdio = ["ignore", logFd, logFd];
|
|
130507
130799
|
}
|
|
130508
130800
|
const child = (0, import_child_process14.spawn)(nodeExecutable, [entry], {
|
|
@@ -130514,7 +130806,7 @@ data: ${JSON.stringify(msg.data)}
|
|
|
130514
130806
|
child.unref();
|
|
130515
130807
|
if (logFd !== null) {
|
|
130516
130808
|
try {
|
|
130517
|
-
|
|
130809
|
+
fs59.closeSync(logFd);
|
|
130518
130810
|
} catch {
|
|
130519
130811
|
}
|
|
130520
130812
|
}
|
|
@@ -130532,8 +130824,8 @@ data: ${JSON.stringify(msg.data)}
|
|
|
130532
130824
|
const pidFile = getPidFile();
|
|
130533
130825
|
let keepPidFile = false;
|
|
130534
130826
|
try {
|
|
130535
|
-
if (
|
|
130536
|
-
const pid = Number.parseInt(
|
|
130827
|
+
if (fs59.existsSync(pidFile)) {
|
|
130828
|
+
const pid = Number.parseInt(fs59.readFileSync(pidFile, "utf8").trim(), 10);
|
|
130537
130829
|
if (Number.isFinite(pid) && pid !== process.pid) {
|
|
130538
130830
|
const managed = isManagedPid(pid);
|
|
130539
130831
|
if (managed) {
|
|
@@ -130553,7 +130845,7 @@ data: ${JSON.stringify(msg.data)}
|
|
|
130553
130845
|
} finally {
|
|
130554
130846
|
if (!keepPidFile) {
|
|
130555
130847
|
try {
|
|
130556
|
-
|
|
130848
|
+
fs59.unlinkSync(pidFile);
|
|
130557
130849
|
} catch {
|
|
130558
130850
|
}
|
|
130559
130851
|
}
|
|
@@ -130589,7 +130881,7 @@ data: ${JSON.stringify(msg.data)}
|
|
|
130589
130881
|
}
|
|
130590
130882
|
if (!reported) return;
|
|
130591
130883
|
if (pathsEquivalent(reported, currentEntry)) return;
|
|
130592
|
-
const reportedExists =
|
|
130884
|
+
const reportedExists = fs59.existsSync(reported);
|
|
130593
130885
|
LOG2.warn(
|
|
130594
130886
|
"SessionHost",
|
|
130595
130887
|
`Reachable session-host reports it is running from ${reported}${reportedExists ? "" : " (which no longer exists)"}, but this install runs from ${currentEntry}. That host would fail every create_session loading node-pty from its own prefix; stopping it so a current one is spawned in its place.`
|
|
@@ -130816,8 +131108,8 @@ data: ${JSON.stringify(msg.data)}
|
|
|
130816
131108
|
const res = await fetch(extension.vsixUrl);
|
|
130817
131109
|
if (res.ok) {
|
|
130818
131110
|
const buffer = Buffer.from(await res.arrayBuffer());
|
|
130819
|
-
const
|
|
130820
|
-
|
|
131111
|
+
const fs61 = await import("fs");
|
|
131112
|
+
fs61.writeFileSync(vsixPath, buffer);
|
|
130821
131113
|
return new Promise((resolve30) => {
|
|
130822
131114
|
const cmd = `"${ide.cliCommand}" --install-extension "${vsixPath}" --force`;
|
|
130823
131115
|
(0, import_child_process15.exec)(cmd, { timeout: 6e4 }, (error48, _stdout, stderr) => {
|
|
@@ -130963,7 +131255,7 @@ data: ${JSON.stringify(msg.data)}
|
|
|
130963
131255
|
init_mesh_events();
|
|
130964
131256
|
init_mesh_reconcile_loop();
|
|
130965
131257
|
var import_fs19 = require("fs");
|
|
130966
|
-
var
|
|
131258
|
+
var import_path21 = require("path");
|
|
130967
131259
|
var import_crypto18 = require("crypto");
|
|
130968
131260
|
init_logger();
|
|
130969
131261
|
init_mesh_ledger();
|
|
@@ -131041,7 +131333,7 @@ data: ${JSON.stringify(msg.data)}
|
|
|
131041
131333
|
}
|
|
131042
131334
|
for (const name of names) {
|
|
131043
131335
|
if (!isPendingEventsFile(name)) continue;
|
|
131044
|
-
const path58 = (0,
|
|
131336
|
+
const path58 = (0, import_path21.join)(dir, name);
|
|
131045
131337
|
result.filesScanned++;
|
|
131046
131338
|
const claimed = `${path58}.migrating`;
|
|
131047
131339
|
try {
|
|
@@ -131820,7 +132112,7 @@ ${upgradeFailureNotice.notice}${supersededHint}`);
|
|
|
131820
132112
|
Object.values(V1_PRIMITIVE_CATALOG).flat()
|
|
131821
132113
|
);
|
|
131822
132114
|
var V1_CONTRACT_VERSION = "1.0.0";
|
|
131823
|
-
var
|
|
132115
|
+
var fs60 = __toESM2(require("fs"));
|
|
131824
132116
|
var import_chalk2 = __toESM2((init_source(), __toCommonJS(source_exports)));
|
|
131825
132117
|
init_dist();
|
|
131826
132118
|
var CLAUDE_NO_API_LINE = "Claude has no quota API \u2014 adhdev borrows your statusLine to read it.";
|
|
@@ -131931,7 +132223,7 @@ ${upgradeFailureNotice.notice}${supersededHint}`);
|
|
|
131931
132223
|
console.log(import_chalk2.default.gray(` Backup: ${status.paths.backupFile}`));
|
|
131932
132224
|
let snapshotMtimeMs = null;
|
|
131933
132225
|
try {
|
|
131934
|
-
snapshotMtimeMs =
|
|
132226
|
+
snapshotMtimeMs = fs60.statSync(status.paths.snapshotFile).mtimeMs;
|
|
131935
132227
|
} catch {
|
|
131936
132228
|
}
|
|
131937
132229
|
console.log(import_chalk2.default.gray(
|