From 70a25c22dcb86b75cc9586ce031e2629b75f3782 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Tue, 3 Mar 2026 17:48:08 +0000 Subject: [PATCH 1/2] Initial plan From d177c5ff39ea7c83dab9b4bad738f7214d311d66 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Tue, 3 Mar 2026 17:49:29 +0000 Subject: [PATCH 2/2] fix: preserve file mode in ConflictResolver atomic write Co-authored-by: jaseel0 <225665919+jaseel0@users.noreply.github.com> --- git-ai/src/services/ConflictResolver.ts | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/git-ai/src/services/ConflictResolver.ts b/git-ai/src/services/ConflictResolver.ts index 460ad5b..7fa2809 100644 --- a/git-ai/src/services/ConflictResolver.ts +++ b/git-ai/src/services/ConflictResolver.ts @@ -173,7 +173,14 @@ export class ConflictResolver { // Atomic write: write to a temp file, fsync, then rename into place. const tempPath = path.join(targetParent, `.tmp-${process.pid}-${randomBytes(8).toString('hex')}`); const buffer = Buffer.from(resolvedContent, 'utf-8'); - const tempHandle = await fs.open(tempPath, fs.constants.O_CREAT | fs.constants.O_EXCL | fs.constants.O_WRONLY | fs.constants.O_NOFOLLOW, 0o644); + let fileMode = 0o644; + try { + const stat = await fs.lstat(targetPath); + fileMode = stat.mode & 0o777; + } catch { + // Target does not exist; use default mode 0o644 + } + const tempHandle = await fs.open(tempPath, fs.constants.O_CREAT | fs.constants.O_EXCL | fs.constants.O_WRONLY | fs.constants.O_NOFOLLOW, fileMode); try { await tempHandle.writeFile(buffer); await tempHandle.sync();