From e344e634680e32a913396b463b84ffd674682b03 Mon Sep 17 00:00:00 2001 From: James Long Date: Tue, 21 Apr 2026 14:57:26 -0400 Subject: [PATCH] reduce variables --- packages/opencode/src/project/project.ts | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/packages/opencode/src/project/project.ts b/packages/opencode/src/project/project.ts index d628f87f97..73fa443858 100644 --- a/packages/opencode/src/project/project.ts +++ b/packages/opencode/src/project/project.ts @@ -207,13 +207,16 @@ export const layer: Layer.Layer< vcs: fakeVcs, } } - const common = resolveGitPath(sandbox, commonDir.text.trim()) - const bareCheck = yield* git(["config", "--bool", "core.bare"], { cwd: sandbox }) - const isBareRepo = bareCheck.code === 0 && bareCheck.text.trim() === "true" - const worktree = common === sandbox ? sandbox : isBareRepo ? common : pathSvc.dirname(common) + + const worktree = yield* Effect.gen(function* () { + const common = resolveGitPath(sandbox, commonDir.text.trim()) + const bareCheck = yield* git(["config", "--bool", "core.bare"], { cwd: sandbox }) + const isBareRepo = bareCheck.code === 0 && bareCheck.text.trim() === "true" + return common === sandbox ? sandbox : isBareRepo ? common : pathSvc.dirname(common) + }) if (id == null) { - id = yield* readCachedProjectId(common) + id = yield* readCachedProjectId(pathSvc.join(worktree, ".git")) } if (!id) { @@ -226,7 +229,7 @@ export const layer: Layer.Layer< id = roots[0] ? ProjectID.make(roots[0]) : undefined if (id) { - yield* fs.writeFileString(pathSvc.join(common, "opencode"), id).pipe(Effect.ignore) + yield* fs.writeFileString(pathSvc.join(pathSvc.join(worktree, ".git"), "opencode"), id).pipe(Effect.ignore) } }