adhdev 0.9.82-rc.36 → 0.9.82-rc.37
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cli/index.js +194 -20
- package/dist/cli/index.js.map +1 -1
- package/dist/index.js +194 -20
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
package/dist/index.js
CHANGED
|
@@ -46140,6 +46140,82 @@ function truncateValidationOutput(value) {
|
|
|
46140
46140
|
return `${text.slice(0, REFINE_VALIDATION_SUMMARY_CHARS)}
|
|
46141
46141
|
[truncated ${text.length - REFINE_VALIDATION_SUMMARY_CHARS} chars]`;
|
|
46142
46142
|
}
|
|
46143
|
+
function recordMeshRefineStage(stages, stage, status, startedAt, details) {
|
|
46144
|
+
stages.push({
|
|
46145
|
+
stage,
|
|
46146
|
+
status,
|
|
46147
|
+
durationMs: Date.now() - startedAt,
|
|
46148
|
+
...details || {}
|
|
46149
|
+
});
|
|
46150
|
+
}
|
|
46151
|
+
async function computeGitPatchId(cwd, fromRef, toRef) {
|
|
46152
|
+
const { execFileSync: execFileSync6 } = await import("child_process");
|
|
46153
|
+
const diff = execFileSync6("git", ["diff", "--patch", "--full-index", fromRef, toRef], {
|
|
46154
|
+
cwd,
|
|
46155
|
+
encoding: "utf8",
|
|
46156
|
+
maxBuffer: REFINE_PATCH_EQUIVALENCE_OUTPUT_LIMIT_BYTES
|
|
46157
|
+
});
|
|
46158
|
+
if (!diff.trim()) return "";
|
|
46159
|
+
const patchId = execFileSync6("git", ["patch-id", "--stable"], {
|
|
46160
|
+
cwd,
|
|
46161
|
+
input: diff,
|
|
46162
|
+
encoding: "utf8",
|
|
46163
|
+
maxBuffer: REFINE_PATCH_EQUIVALENCE_OUTPUT_LIMIT_BYTES
|
|
46164
|
+
}).trim();
|
|
46165
|
+
return patchId.split(/\s+/)[0] || "";
|
|
46166
|
+
}
|
|
46167
|
+
async function runMeshRefinePatchEquivalenceGate(repoRoot, baseHead, branchHead) {
|
|
46168
|
+
const startedAt = Date.now();
|
|
46169
|
+
try {
|
|
46170
|
+
const { execFileSync: execFileSync6 } = await import("child_process");
|
|
46171
|
+
const git = (args) => execFileSync6("git", args, {
|
|
46172
|
+
cwd: repoRoot,
|
|
46173
|
+
encoding: "utf8",
|
|
46174
|
+
maxBuffer: REFINE_PATCH_EQUIVALENCE_OUTPUT_LIMIT_BYTES
|
|
46175
|
+
});
|
|
46176
|
+
const mergeBase = git(["merge-base", baseHead, branchHead]).trim();
|
|
46177
|
+
const mergeTreeStdout = git(["merge-tree", "--write-tree", baseHead, branchHead]);
|
|
46178
|
+
const mergedTree = mergeTreeStdout.trim().split(/\s+/)[0] || "";
|
|
46179
|
+
if (!mergeBase || !mergedTree) {
|
|
46180
|
+
return {
|
|
46181
|
+
status: "failed",
|
|
46182
|
+
equivalent: false,
|
|
46183
|
+
baseHead,
|
|
46184
|
+
branchHead,
|
|
46185
|
+
mergeBase: mergeBase || void 0,
|
|
46186
|
+
mergedTree: mergedTree || void 0,
|
|
46187
|
+
durationMs: Date.now() - startedAt,
|
|
46188
|
+
error: "patch equivalence preflight could not resolve merge-base or synthetic merge tree",
|
|
46189
|
+
stdout: truncateValidationOutput(mergeTreeStdout)
|
|
46190
|
+
};
|
|
46191
|
+
}
|
|
46192
|
+
const expectedPatchId = await computeGitPatchId(repoRoot, mergeBase, branchHead);
|
|
46193
|
+
const actualPatchId = await computeGitPatchId(repoRoot, baseHead, mergedTree);
|
|
46194
|
+
const equivalent = expectedPatchId === actualPatchId;
|
|
46195
|
+
return {
|
|
46196
|
+
status: equivalent ? "passed" : "failed",
|
|
46197
|
+
equivalent,
|
|
46198
|
+
baseHead,
|
|
46199
|
+
branchHead,
|
|
46200
|
+
mergeBase,
|
|
46201
|
+
mergedTree,
|
|
46202
|
+
expectedPatchId,
|
|
46203
|
+
actualPatchId,
|
|
46204
|
+
durationMs: Date.now() - startedAt
|
|
46205
|
+
};
|
|
46206
|
+
} catch (e) {
|
|
46207
|
+
return {
|
|
46208
|
+
status: "failed",
|
|
46209
|
+
equivalent: false,
|
|
46210
|
+
baseHead,
|
|
46211
|
+
branchHead,
|
|
46212
|
+
durationMs: Date.now() - startedAt,
|
|
46213
|
+
error: e?.message || String(e),
|
|
46214
|
+
stdout: truncateValidationOutput(e?.stdout),
|
|
46215
|
+
stderr: truncateValidationOutput(e?.stderr)
|
|
46216
|
+
};
|
|
46217
|
+
}
|
|
46218
|
+
}
|
|
46143
46219
|
function readPackageScripts(workspace) {
|
|
46144
46220
|
try {
|
|
46145
46221
|
const packageJsonPath = (0, import_path7.join)(workspace, "package.json");
|
|
@@ -46483,7 +46559,7 @@ function summarizeSessionHostPruneResult(result) {
|
|
|
46483
46559
|
keptCount: Array.isArray(value.keptSessionIds) ? value.keptSessionIds.length : void 0
|
|
46484
46560
|
};
|
|
46485
46561
|
}
|
|
46486
|
-
var import_os4, import_path7, fs10, CHANNEL_NPM_TAG, CHANNEL_SERVER_URL, REFINE_VALIDATION_CATEGORIES, REFINE_VALIDATION_TIMEOUT_MS, REFINE_VALIDATION_OUTPUT_LIMIT_BYTES, REFINE_VALIDATION_SUMMARY_CHARS, REFINE_VALIDATION_MAX_COMMANDS, CHAT_COMMANDS, READ_DEBUG_ENABLED2, DaemonCommandRouter;
|
|
46562
|
+
var import_os4, import_path7, fs10, CHANNEL_NPM_TAG, CHANNEL_SERVER_URL, REFINE_VALIDATION_CATEGORIES, REFINE_VALIDATION_TIMEOUT_MS, REFINE_VALIDATION_OUTPUT_LIMIT_BYTES, REFINE_VALIDATION_SUMMARY_CHARS, REFINE_VALIDATION_MAX_COMMANDS, REFINE_PATCH_EQUIVALENCE_OUTPUT_LIMIT_BYTES, CHAT_COMMANDS, READ_DEBUG_ENABLED2, DaemonCommandRouter;
|
|
46487
46563
|
var init_router = __esm({
|
|
46488
46564
|
"../../oss/packages/daemon-core/src/commands/router.ts"() {
|
|
46489
46565
|
"use strict";
|
|
@@ -46525,6 +46601,7 @@ var init_router = __esm({
|
|
|
46525
46601
|
REFINE_VALIDATION_OUTPUT_LIMIT_BYTES = 128 * 1024;
|
|
46526
46602
|
REFINE_VALIDATION_SUMMARY_CHARS = 2e3;
|
|
46527
46603
|
REFINE_VALIDATION_MAX_COMMANDS = 4;
|
|
46604
|
+
REFINE_PATCH_EQUIVALENCE_OUTPUT_LIMIT_BYTES = 4 * 1024 * 1024;
|
|
46528
46605
|
CHAT_COMMANDS = [
|
|
46529
46606
|
"send_chat",
|
|
46530
46607
|
"new_chat",
|
|
@@ -47826,26 +47903,41 @@ var init_router = __esm({
|
|
|
47826
47903
|
const meshId = typeof args?.meshId === "string" ? args.meshId.trim() : "";
|
|
47827
47904
|
const nodeId = typeof args?.nodeId === "string" ? args.nodeId.trim() : "";
|
|
47828
47905
|
if (!meshId || !nodeId) return { success: false, error: "meshId and nodeId required" };
|
|
47906
|
+
const refineStages = [];
|
|
47829
47907
|
try {
|
|
47830
47908
|
const meshRecord = await this.getMeshForCommand(meshId, args?.inlineMesh);
|
|
47831
47909
|
const mesh = meshRecord?.mesh;
|
|
47832
47910
|
const node = mesh?.nodes?.find((n) => n.id === nodeId || n.nodeId === nodeId);
|
|
47833
|
-
if (!node) return { success: false, error: `Node '${nodeId}' not found in mesh
|
|
47911
|
+
if (!node) return { success: false, error: `Node '${nodeId}' not found in mesh`, refineStages };
|
|
47834
47912
|
if (!node.isLocalWorktree || !node.workspace) {
|
|
47835
|
-
return { success: false, error: `Refinery requires a local worktree node
|
|
47913
|
+
return { success: false, error: `Refinery requires a local worktree node`, refineStages };
|
|
47836
47914
|
}
|
|
47837
47915
|
const sourceNode = node.clonedFromNodeId ? mesh?.nodes.find((n) => n.id === node.clonedFromNodeId || n.nodeId === node.clonedFromNodeId) : mesh?.nodes.find((n) => !n.isLocalWorktree);
|
|
47838
47916
|
const repoRoot = sourceNode?.repoRoot || sourceNode?.workspace;
|
|
47839
|
-
if (!repoRoot) return { success: false, error: "Source node repoRoot not found" };
|
|
47917
|
+
if (!repoRoot) return { success: false, error: "Source node repoRoot not found", refineStages };
|
|
47840
47918
|
const { execFile: execFile3 } = await import("child_process");
|
|
47841
47919
|
const { promisify: promisify3 } = await import("util");
|
|
47842
47920
|
const execFileAsync3 = promisify3(execFile3);
|
|
47921
|
+
const resolveStarted = Date.now();
|
|
47843
47922
|
const { stdout: branchStdout } = await execFileAsync3("git", ["branch", "--show-current"], { cwd: node.workspace, encoding: "utf8" });
|
|
47844
47923
|
const branch = branchStdout.trim();
|
|
47845
|
-
if (!branch) return { success: false, error: "Could not determine branch of the worktree node" };
|
|
47924
|
+
if (!branch) return { success: false, error: "Could not determine branch of the worktree node", refineStages };
|
|
47846
47925
|
const { stdout: baseBranchStdout } = await execFileAsync3("git", ["branch", "--show-current"], { cwd: repoRoot, encoding: "utf8" });
|
|
47847
47926
|
const baseBranch = baseBranchStdout.trim();
|
|
47927
|
+
const { stdout: baseHeadStdout } = await execFileAsync3("git", ["rev-parse", "HEAD"], { cwd: repoRoot, encoding: "utf8" });
|
|
47928
|
+
const { stdout: branchHeadStdout } = await execFileAsync3("git", ["rev-parse", branch], { cwd: node.workspace, encoding: "utf8" });
|
|
47929
|
+
const baseHead = baseHeadStdout.trim();
|
|
47930
|
+
const branchHead = branchHeadStdout.trim();
|
|
47931
|
+
recordMeshRefineStage(refineStages, "resolve_refs", "passed", resolveStarted, { branch, baseBranch, baseHead, branchHead });
|
|
47932
|
+
const validationStarted = Date.now();
|
|
47848
47933
|
const validationSummary = await runMeshRefineValidationGate(mesh, node.workspace);
|
|
47934
|
+
recordMeshRefineStage(
|
|
47935
|
+
refineStages,
|
|
47936
|
+
"validation",
|
|
47937
|
+
validationSummary.status === "passed" ? "passed" : validationSummary.status === "failed" ? "failed" : "skipped",
|
|
47938
|
+
validationStarted,
|
|
47939
|
+
{ validationStatus: validationSummary.status, commandsRun: validationSummary.commandsRun.length }
|
|
47940
|
+
);
|
|
47849
47941
|
if (validationSummary.status === "failed") {
|
|
47850
47942
|
return {
|
|
47851
47943
|
success: false,
|
|
@@ -47855,6 +47947,7 @@ var init_router = __esm({
|
|
|
47855
47947
|
branch,
|
|
47856
47948
|
into: baseBranch,
|
|
47857
47949
|
validationSummary,
|
|
47950
|
+
refineStages,
|
|
47858
47951
|
finalBranchConvergenceState: {
|
|
47859
47952
|
branch,
|
|
47860
47953
|
baseBranch,
|
|
@@ -47874,6 +47967,7 @@ var init_router = __esm({
|
|
|
47874
47967
|
branch,
|
|
47875
47968
|
into: baseBranch,
|
|
47876
47969
|
validationSummary,
|
|
47970
|
+
refineStages,
|
|
47877
47971
|
finalBranchConvergenceState: {
|
|
47878
47972
|
branch,
|
|
47879
47973
|
baseBranch,
|
|
@@ -47884,37 +47978,121 @@ var init_router = __esm({
|
|
|
47884
47978
|
}
|
|
47885
47979
|
};
|
|
47886
47980
|
}
|
|
47981
|
+
const patchEquivalenceStarted = Date.now();
|
|
47982
|
+
const patchEquivalence = await runMeshRefinePatchEquivalenceGate(repoRoot, baseHead, branchHead);
|
|
47983
|
+
recordMeshRefineStage(refineStages, "patch_equivalence", patchEquivalence.status, patchEquivalenceStarted, {
|
|
47984
|
+
equivalent: patchEquivalence.equivalent,
|
|
47985
|
+
expectedPatchId: patchEquivalence.expectedPatchId,
|
|
47986
|
+
actualPatchId: patchEquivalence.actualPatchId,
|
|
47987
|
+
error: patchEquivalence.error
|
|
47988
|
+
});
|
|
47989
|
+
if (!patchEquivalence.equivalent) {
|
|
47990
|
+
return {
|
|
47991
|
+
success: false,
|
|
47992
|
+
code: "patch_equivalence_failed",
|
|
47993
|
+
convergenceStatus: "blocked_review",
|
|
47994
|
+
error: "Refinery patch-equivalence preflight failed; merge/refine was not attempted.",
|
|
47995
|
+
branch,
|
|
47996
|
+
into: baseBranch,
|
|
47997
|
+
validationSummary,
|
|
47998
|
+
patchEquivalence,
|
|
47999
|
+
refineStages,
|
|
48000
|
+
finalBranchConvergenceState: {
|
|
48001
|
+
branch,
|
|
48002
|
+
baseBranch,
|
|
48003
|
+
merged: false,
|
|
48004
|
+
removed: false,
|
|
48005
|
+
validation: "passed",
|
|
48006
|
+
patchEquivalence: "failed",
|
|
48007
|
+
status: "blocked_review"
|
|
48008
|
+
}
|
|
48009
|
+
};
|
|
48010
|
+
}
|
|
48011
|
+
let mergeResult;
|
|
48012
|
+
const mergeStarted = Date.now();
|
|
47887
48013
|
try {
|
|
47888
|
-
await execFileAsync3("git", ["merge", "--no-ff", branch, "-m", `Auto-merge branch '${branch}' via Refinery`], { cwd: repoRoot, encoding: "utf8" });
|
|
48014
|
+
const result = await execFileAsync3("git", ["merge", "--no-ff", branch, "-m", `Auto-merge branch '${branch}' via Refinery`], { cwd: repoRoot, encoding: "utf8" });
|
|
48015
|
+
mergeResult = {
|
|
48016
|
+
stdout: truncateValidationOutput(result.stdout),
|
|
48017
|
+
stderr: truncateValidationOutput(result.stderr),
|
|
48018
|
+
durationMs: Date.now() - mergeStarted
|
|
48019
|
+
};
|
|
48020
|
+
recordMeshRefineStage(refineStages, "merge", "passed", mergeStarted, mergeResult);
|
|
47889
48021
|
} catch (e) {
|
|
48022
|
+
recordMeshRefineStage(refineStages, "merge", "failed", mergeStarted, {
|
|
48023
|
+
error: e?.message || String(e),
|
|
48024
|
+
stdout: truncateValidationOutput(e?.stdout),
|
|
48025
|
+
stderr: truncateValidationOutput(e?.stderr)
|
|
48026
|
+
});
|
|
47890
48027
|
return {
|
|
47891
48028
|
success: false,
|
|
47892
48029
|
error: `Merge failed (conflicts?): ${e.message}`,
|
|
47893
48030
|
validationSummary,
|
|
48031
|
+
patchEquivalence,
|
|
48032
|
+
refineStages,
|
|
47894
48033
|
finalBranchConvergenceState: {
|
|
47895
48034
|
branch,
|
|
47896
48035
|
baseBranch,
|
|
47897
48036
|
merged: false,
|
|
47898
48037
|
removed: false,
|
|
47899
48038
|
validation: "passed",
|
|
48039
|
+
patchEquivalence: "passed",
|
|
47900
48040
|
status: "not_mergeable"
|
|
47901
48041
|
}
|
|
47902
48042
|
};
|
|
47903
48043
|
}
|
|
48044
|
+
const cleanupStarted = Date.now();
|
|
47904
48045
|
const removeResult = await this.execute("remove_mesh_node", {
|
|
47905
48046
|
meshId,
|
|
47906
48047
|
nodeId,
|
|
47907
|
-
sessionCleanupMode: "
|
|
48048
|
+
sessionCleanupMode: "preserve",
|
|
47908
48049
|
inlineMesh: args?.inlineMesh
|
|
47909
48050
|
});
|
|
48051
|
+
recordMeshRefineStage(refineStages, "cleanup", removeResult?.success === false ? "failed" : "passed", cleanupStarted, {
|
|
48052
|
+
removed: removeResult?.removed,
|
|
48053
|
+
code: removeResult?.code,
|
|
48054
|
+
error: removeResult?.error
|
|
48055
|
+
});
|
|
48056
|
+
let ledgerError;
|
|
48057
|
+
const ledgerStarted = Date.now();
|
|
47910
48058
|
try {
|
|
47911
48059
|
const { appendLedgerEntry: appendLedgerEntry2 } = await Promise.resolve().then(() => (init_mesh_ledger(), mesh_ledger_exports));
|
|
47912
48060
|
appendLedgerEntry2(meshId, {
|
|
47913
48061
|
kind: "node_removed",
|
|
47914
48062
|
nodeId,
|
|
47915
|
-
payload: { refined: true, mergedBranch: branch, into: baseBranch, validationSummary }
|
|
48063
|
+
payload: { refined: true, mergedBranch: branch, into: baseBranch, validationSummary, patchEquivalence }
|
|
47916
48064
|
});
|
|
47917
|
-
|
|
48065
|
+
recordMeshRefineStage(refineStages, "ledger", "passed", ledgerStarted);
|
|
48066
|
+
} catch (e) {
|
|
48067
|
+
ledgerError = e?.message || String(e);
|
|
48068
|
+
recordMeshRefineStage(refineStages, "ledger", "failed", ledgerStarted, { error: ledgerError });
|
|
48069
|
+
}
|
|
48070
|
+
const finalBranchConvergenceState = {
|
|
48071
|
+
branch: baseBranch,
|
|
48072
|
+
mergedBranch: branch,
|
|
48073
|
+
baseBranch,
|
|
48074
|
+
merged: true,
|
|
48075
|
+
removed: removeResult?.success !== false,
|
|
48076
|
+
validation: "passed",
|
|
48077
|
+
patchEquivalence: "passed",
|
|
48078
|
+
status: removeResult?.success === false ? "merged_cleanup_failed" : "merged"
|
|
48079
|
+
};
|
|
48080
|
+
if (removeResult?.success === false) {
|
|
48081
|
+
return {
|
|
48082
|
+
success: false,
|
|
48083
|
+
code: "cleanup_failed",
|
|
48084
|
+
error: "Refinery merge completed but worktree cleanup failed; manual cleanup/retry is required.",
|
|
48085
|
+
merged: true,
|
|
48086
|
+
branch,
|
|
48087
|
+
into: baseBranch,
|
|
48088
|
+
removeResult,
|
|
48089
|
+
validationSummary,
|
|
48090
|
+
patchEquivalence,
|
|
48091
|
+
mergeResult,
|
|
48092
|
+
refineStages,
|
|
48093
|
+
...ledgerError ? { ledgerError } : {},
|
|
48094
|
+
finalBranchConvergenceState
|
|
48095
|
+
};
|
|
47918
48096
|
}
|
|
47919
48097
|
return {
|
|
47920
48098
|
success: true,
|
|
@@ -47923,18 +48101,14 @@ var init_router = __esm({
|
|
|
47923
48101
|
into: baseBranch,
|
|
47924
48102
|
removeResult,
|
|
47925
48103
|
validationSummary,
|
|
47926
|
-
|
|
47927
|
-
|
|
47928
|
-
|
|
47929
|
-
|
|
47930
|
-
|
|
47931
|
-
removed: removeResult?.success !== false,
|
|
47932
|
-
validation: "passed",
|
|
47933
|
-
status: removeResult?.success === false ? "merged_cleanup_failed" : "merged"
|
|
47934
|
-
}
|
|
48104
|
+
patchEquivalence,
|
|
48105
|
+
mergeResult,
|
|
48106
|
+
refineStages,
|
|
48107
|
+
...ledgerError ? { ledgerError } : {},
|
|
48108
|
+
finalBranchConvergenceState
|
|
47935
48109
|
};
|
|
47936
48110
|
} catch (e) {
|
|
47937
|
-
return { success: false, error: e.message };
|
|
48111
|
+
return { success: false, error: e.message, refineStages };
|
|
47938
48112
|
}
|
|
47939
48113
|
}
|
|
47940
48114
|
case "remove_mesh_node": {
|
|
@@ -67605,7 +67779,7 @@ var init_adhdev_daemon = __esm({
|
|
|
67605
67779
|
init_version();
|
|
67606
67780
|
init_src();
|
|
67607
67781
|
init_runtime_defaults();
|
|
67608
|
-
pkgVersion = resolvePackageVersion({ injectedVersion: "0.9.82-rc.
|
|
67782
|
+
pkgVersion = resolvePackageVersion({ injectedVersion: "0.9.82-rc.37" });
|
|
67609
67783
|
AdhdevDaemon = class _AdhdevDaemon {
|
|
67610
67784
|
localHttpServer = null;
|
|
67611
67785
|
localWss = null;
|