Skip to content

fix: install @google/generative-ai and use writeFile for atomic writes in ConflictResolver#11

Merged
jaseel0 merged 2 commits intocodefrom
copilot/sub-pr-8
Mar 3, 2026
Merged

fix: install @google/generative-ai and use writeFile for atomic writes in ConflictResolver#11
jaseel0 merged 2 commits intocodefrom
copilot/sub-pr-8

Conversation

Copy link
Contributor

Copilot AI commented Mar 3, 2026

Description

Two correctness fixes: ensures the @google/generative-ai package is fully installed so AIService.ts can resolve its import, and replaces a potentially partial write() call in ConflictResolver with writeFile() to guarantee full-buffer writes before fsync+rename.

Dependency resolution

  • @google/generative-ai was already declared in package.json and package-lock.json but absent from node_modules; ran npm install to populate it, unblocking TypeScript compilation.

Atomic write correctness in ConflictResolver.applyResolution

  • FileHandle.write(buffer, 0, buffer.length) does not guarantee all bytes are written in a single call — a short write silently truncates the resolved file before rename() completes.
  • Replaced with FileHandle.writeFile(buffer), which loops internally until the entire buffer is flushed, preserving the atomic-replace guarantee.
// Before — susceptible to short writes
await tempHandle.write(buffer, 0, buffer.length);

// After — full buffer guaranteed before fsync + rename
await tempHandle.writeFile(buffer);

Related Issue

Closes #

Type of Change

  • 🐛 Bug fix (non-breaking change that fixes an issue)
  • ✨ New feature (non-breaking change that adds functionality)
  • 💥 Breaking change (fix or feature that would cause existing functionality to change)
  • 📝 Documentation update
  • 🔧 Refactor / internal improvement
  • 🤖 CI/CD or tooling change
  • ⬆️ Dependency update

Checklist

  • I have read the CONTRIBUTING guidelines (if present)
  • My code follows the existing code style
  • I have added or updated tests that cover my changes
  • All existing tests pass locally
  • I have updated the documentation where necessary
  • My changes do not introduce new security vulnerabilities

How Has This Been Tested?

npm run lint (tsc --noEmit) passes with zero errors after installing the dependency. CodeQL analysis returned 0 alerts.

Screenshots (if applicable)

N/A

Additional Notes

node_modules/ remains gitignored; only package-lock.json changes (if any) are committed.


💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

…esolver

Co-authored-by: jaseel0 <225665919+jaseel0@users.noreply.github.com>
Copilot AI changed the title [WIP] Add foundational features for AI-powered Git CLI tool fix: install @google/generative-ai and use writeFile for atomic writes in ConflictResolver Mar 3, 2026
@naheel0 naheel0 marked this pull request as ready for review March 3, 2026 17:23
@jaseel0 jaseel0 merged commit a22ffaa into code Mar 3, 2026
2 checks passed
@jaseel0 jaseel0 deleted the copilot/sub-pr-8 branch March 3, 2026 17:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants