gemini-cli icon indicating copy to clipboard operation
gemini-cli copied to clipboard

fix(acp): convert RESOURCE_NOT_FOUND to ENOENT for fs delegation

Open codefromthecrypt opened this issue 2 months ago • 0 comments

Summary

Fix ACP fs delegation error handling: convert RESOURCE_NOT_FOUND errors to Node.js ENOENT format when reading files via client delegation.

Details

When clients advertise fs.readTextFile capability, gemini-cli delegates file reads to the client. If the file doesn't exist, the client returns an error with code -32002 (RESOURCE_NOT_FOUND). This change converts that error to a Node.js-style ENOENT error so downstream code handles it correctly.

Changes:

  • connection.ts: Add RESOURCE_NOT_FOUND error code constant
  • fileSystemService.ts: Make capabilities public readonly, add try/catch in readTextFile() to convert RESOURCE_NOT_FOUND to ENOENT
  • fileSystemService.test.ts: Add test for ENOENT conversion

How to Validate

  1. Start gemini-cli with a client that advertises fs.readTextFile: true
  2. Prompt to read a non-existent file
  3. Verify the error has code: 'ENOENT' instead of raw JSON-RPC error

Pre-Merge Checklist

  • [ ] Updated relevant documentation and README (if needed)
  • [x] Added/updated tests
  • [ ] Noted breaking changes (if any)

codefromthecrypt avatar Dec 01 '25 03:12 codefromthecrypt