refactor(core): introduce FrilVault facade#82
Conversation
📝 WalkthroughWalkthroughThe PR introduces a ChangesFrilVault Facade Refactor
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes Possibly related PRs
Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
🧹 Nitpick comments (1)
crates/frilvault-core/src/app/frilvault.rs (1)
22-47: ⚡ Quick winExtract shared workspace bootstrap into a private helper.
create_note_serviceandcreate_workspace_servicerepeat the same resolver/workspace/index setup. Centralizing that setup will reduce drift risk when bootstrap behavior changes.♻️ Proposed refactor
impl FrilVault { + fn bootstrap_workspace(&self) -> FrilVaultResult<(PathResolver, WorkspaceIndexRepository)> { + let resolver = PathResolver::new(&self.workspace_root); + + let workspace_repository = WorkspaceRepository::new(resolver.clone()); + workspace_repository.create_if_missing()?; + + let index_repository = WorkspaceIndexRepository::new(resolver.clone()); + index_repository.create_if_missing()?; + + Ok((resolver, index_repository)) + } + pub fn create_note_service(&self) -> FrilVaultResult<NoteService> { - let resolver = PathResolver::new(&self.workspace_root); - - let workspace_repository = WorkspaceRepository::new(resolver.clone()); - workspace_repository.create_if_missing()?; - - let index_repository = WorkspaceIndexRepository::new(resolver.clone()); - index_repository.create_if_missing()?; + let (resolver, index_repository) = self.bootstrap_workspace()?; let note_repository = YamlNoteRepository::new(resolver.clone()); let vault_context = VaultContext::new(note_repository, index_repository); Ok(NoteService::new(vault_context)) } pub fn create_workspace_service(&self) -> FrilVaultResult<WorkspaceService> { - let resolver = PathResolver::new(&self.workspace_root); - - let workspace_repository = WorkspaceRepository::new(resolver.clone()); - workspace_repository.create_if_missing()?; - - let index_repository = WorkspaceIndexRepository::new(resolver.clone()); - index_repository.create_if_missing()?; + let (resolver, index_repository) = self.bootstrap_workspace()?; let note_repository = YamlNoteRepository::new(resolver); let vault_context = VaultContext::new(note_repository, index_repository.clone()); Ok(WorkspaceService::new(vault_context, index_repository)) } }🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@crates/frilvault-core/src/app/frilvault.rs` around lines 22 - 47, The methods create_note_service and create_workspace_service contain duplicated code for workspace bootstrap setup (creating PathResolver, WorkspaceRepository, and WorkspaceIndexRepository instances with their create_if_missing calls). Extract this common setup logic into a private helper method that returns the initialized repositories and resolver, then call this helper from both create_note_service and create_workspace_service to eliminate duplication and reduce maintenance burden.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Nitpick comments:
In `@crates/frilvault-core/src/app/frilvault.rs`:
- Around line 22-47: The methods create_note_service and
create_workspace_service contain duplicated code for workspace bootstrap setup
(creating PathResolver, WorkspaceRepository, and WorkspaceIndexRepository
instances with their create_if_missing calls). Extract this common setup logic
into a private helper method that returns the initialized repositories and
resolver, then call this helper from both create_note_service and
create_workspace_service to eliminate duplication and reduce maintenance burden.
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro Plus
Run ID: e8ad59c6-d474-4e5d-acdc-369359022501
📒 Files selected for processing (13)
apps/frilvault-cli/src/command/add.rsapps/frilvault-cli/src/command/delete.rsapps/frilvault-cli/src/command/doctor.rsapps/frilvault-cli/src/command/list.rsapps/frilvault-cli/src/command/repair.rsapps/frilvault-cli/src/command/search.rsapps/frilvault-cli/src/command/stats.rsapps/frilvault-cli/src/command/update.rscrates/frilvault-core/src/app/frilvault.rscrates/frilvault-core/src/app/mod.rscrates/frilvault-core/src/lib.rscrates/frilvault-core/src/tests/frilvault_app_test.rscrates/frilvault-core/src/tests/mod.rs
Summary
refactor(core): introduce FrilVault facade
Type of Change
Required
cargo checkpassescargo fmt --all --checkpassescargo clippy --workspace --all-targets -- -D warningspassescargo testpassesChecklist
Summary by CodeRabbit
Refactor
Tests