feat(FN-4606): complete Step 3 — route engine call sites

Ref: Runfusion/Fusion#321
Fusion-Task-Id: FN-4606
Fusion-Task-Lineage: 94b23f37-944e-4bcd-bfa1-67d0a8c0a267
This commit is contained in:
Fusion
2026-05-15 08:15:31 -07:00
committed by gsxdsm
parent f00df58eb7
commit 2799c101ac
8 changed files with 71 additions and 41 deletions

View File

@@ -30,6 +30,7 @@ export {
import { existsSync, readFileSync, writeFileSync, unlinkSync, renameSync } from "node:fs";
import { createHash } from "node:crypto";
import { join } from "node:path";
import { resolveTaskWorktreePath } from "./worktree-paths.js";
import { hostname } from "node:os";
import {
buildTaskLineageTrailer,
@@ -5625,9 +5626,10 @@ export async function pushToRemoteAfterMerge(
async function createPostMergeWorktree(
rootDir: string,
taskId: string,
settings: Partial<Settings>,
): Promise<string | null> {
const randomSuffix = Math.random().toString(36).slice(2, 10);
const postMergeWorktree = join(rootDir, ".worktrees", `post-merge-${taskId}-${randomSuffix}`);
const postMergeWorktree = resolveTaskWorktreePath(rootDir, settings, `post-merge-${taskId}-${randomSuffix}`);
try {
await execAsync(`git worktree add ${quoteArg(postMergeWorktree)} HEAD`, { cwd: rootDir });
@@ -7285,7 +7287,7 @@ export async function aiMergeTask(
throwIfAborted(options.signal, taskId);
const hasPostMergeSteps = await hasEnabledPostMergeWorkflowSteps(store, taskId, task.enabledWorkflowSteps);
if (hasPostMergeSteps) {
const postMergeWorktree = await createPostMergeWorktree(rootDir, taskId);
const postMergeWorktree = await createPostMergeWorktree(rootDir, taskId, settings);
const postMergeCwd = postMergeWorktree || rootDir;
if (postMergeWorktree) {
mergerLog.log(`${taskId}: running post-merge workflow steps in isolated worktree: ${postMergeWorktree}`);