Skip to content

Conversation

@pyramation
Copy link
Contributor

Summary

Refactored the ZenFsAdapter from 186 lines to 47 lines (75% reduction) by delegating to zenfs.fs.promises instead of manually wrapping sync methods. The adapter now only provides the minimal glue needed for just-bash compatibility:

  • Stat shape conversion (zen-fs returns bigint for mode/size, just-bash expects number)
  • resolvePath() and getAllPaths() which are just-bash-specific methods
  • Return type adjustments (mkdir/mv return void, not string)

Removed custom type definitions, manual recursive cp implementation, and the ensureParentDirs helper.

Review & Testing Checklist for Human

  • Verify ensureParentDirs removal is acceptable: The old adapter auto-created parent directories on write operations. The new adapter does not - tests work because they use explicit mkdir -p. Confirm this behavioral change is intentional for the demo.
  • Check error handling parity: The old adapter had custom try/catch for rm --force. The new one delegates directly to fs.promises.rm. Verify edge cases still work as expected.
  • Confirm interface compatibility: The adapter no longer explicitly implements IFileSystem - it relies on duck typing. Run through the demo scenarios to ensure all operations work.

Test plan:

cd packages/zen-bash
pnpm test

All 9 tests should pass, demonstrating write-via-bash/read-via-zenfs and vice versa.

Notes

The getAllPaths() method still uses sync methods (readdirSync, lstatSync) since it returns string[] synchronously - this is required by just-bash's interface for glob matching.

Link to Devin run: https://app.devin.ai/sessions/e5a59ab234c5481e817dad43a74cfc6e
Requested by: Dan Lynch (@pyramation)

- Reduced from 186 lines to 47 lines (75% reduction)
- Delegates to zenfs.fs.promises for most operations
- Only adds just-bash-specific glue: resolvePath, getAllPaths, stat shape conversion
- Removed custom type definitions, ensureParentDirs, and manual cp implementation
@devin-ai-integration
Copy link

🤖 Devin AI Engineer

I'll be helping with this pull request! Here's what you should know:

✅ I will automatically:

  • Address comments on this PR. Add '(aside)' to your comment to have me ignore it.
  • Look at CI failures and help fix them

Note: I can only respond to comments from users who have write access to this repository.

⚙️ Control Options:

  • Disable automatic comment and CI monitoring

@pyramation pyramation merged commit f1a2e71 into main Dec 28, 2025
1 check passed
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.

2 participants