feat(FN-4904): complete Step 3 — align engine and CLI root resolution

Fusion-Task-Id: FN-4904
Fusion-Task-Lineage: 5da52c8c-0ed6-4e3a-920e-aa1b56d0b719
This commit is contained in:
Fusion (runfusion.ai)
2026-05-17 10:34:55 -07:00
committed by gsxdsm
parent b40a58d693
commit 47eaf089bf
4 changed files with 86 additions and 6 deletions

View File

@@ -74,12 +74,21 @@ describe("resolveProjectRoot", () => {
expect(resolveProjectRoot(dir)).toBe(dir);
});
it("walks up from worktree path to find project root", () => {
it("prefers parent repo root for worktree paths when both parent and worktree have .fusion", () => {
const projectDir = `/tmp/skill-resolver-mock-${++mockDirCounter}`;
const worktreeDir = `${projectDir}/.worktrees/swift-falcon`;
mockDirs.add(`${projectDir}/.fusion`);
mockDirs.add(`${worktreeDir}/.fusion`);
expect(resolveProjectRoot(worktreeDir)).toBe(projectDir);
expect(resolveProjectRoot(`${worktreeDir}/sub`)).toBe(projectDir);
});
it("falls back to legacy walk when parent repo .fusion is missing", () => {
const projectDir = `/tmp/skill-resolver-mock-${++mockDirCounter}`;
const worktreeDir = `${projectDir}/.worktrees/swift-falcon`;
mockDirs.add(`${worktreeDir}/.fusion`);
expect(resolveProjectRoot(`${worktreeDir}/sub`)).toBe(worktreeDir);
});
it("walks up from deeply nested path", () => {