Skip to content

Conversation

@adelrodriguez
Copy link
Collaborator

@adelrodriguez adelrodriguez commented Jan 11, 2026

Greptile Overview

Greptile Summary

Overview

This PR performs a comprehensive refactor to expand the use of Effect throughout the codebase and remove unused utility functions. The changes are well-structured and maintain consistency across the monorepo.

Key Changes

1. CLI Migration to Effect (Major Enhancement)

  • Migrated init-now CLI from consola to @effect/cli for better composability and error handling
  • Added 5 new commands: setup, add, update, check, rename
  • Moved template management from scripts/template to the CLI package
  • All commands use Effect's typed error handling with custom error types (OperationCancelled, GitInitFailed, etc.)

2. Removed Unused Utilities

Successfully removed 5 unused utility modules from @init/utils:

  • cache.ts - Caching wrapper (no longer used)
  • duration.ts - Custom duration parser (replaced with Effect.Duration)
  • encryption.ts - AES-256-GCM encryption utils (no longer used)
  • proxy.ts - Recursive proxy creator (no longer used)
  • serialize.ts - Stable serialization (no longer used)

Also removed unused type utilities: StrictOmit, UnionToIntersection

3. Duration API Migration

Consistently migrated from custom @init/utils/duration to Effect's Duration module:

  • packages/email/src/client.ts - Email scheduling with Duration.decode() and Duration.toMillis()
  • packages/kv/src/client.ts - TTL configuration with Duration.toSeconds()
  • apps/api/src/shared/middleware.ts - Rate limiting intervals
  • Updated apps/api/src/routes/health.ts from "1m" to more readable "1 minute" format

Effect's Duration API supports multiple formats including strings ("1 minute", "5 seconds"), numbers (milliseconds), and Duration objects.

4. Error Handling Improvements

  • Consolidated error definitions into packages/error/src/fault.ts (removed separate auth.ts and index.ts)
  • Added new email-specific error types with rich context
  • Updated imports across API and app packages from @init/error to @init/error/fault
  • Enhanced error messages with structured context (emails, subject, from fields)

5. Database Scripts Simplification

  • Removed production database support from reset.ts and seed.ts
  • Replaced consola with standard console.log for simpler output
  • Added protection to only run on local databases
  • Cleaner error handling and messaging

6. Dependency Updates

  • Added Effect ecosystem packages: @effect/cli, @effect/platform, @effect/platform-bun
  • Removed: consola, yargs, @types/yargs
  • Added effect to catalog dependencies for consistency

Architecture Improvements

The migration to Effect brings several benefits:

  • Type Safety: All CLI commands have proper type-safe error handling
  • Composability: Effect's functional approach makes commands easier to compose and test
  • Consistency: Using Effect.Duration standardizes duration handling across packages
  • Better Errors: Structured error types with causes and context improve debugging

Testing Coverage

The PR includes:

  • Updated test configuration in cli/src/__tests__/workspaces.test.ts
  • Tests are currently skipped (marked with describe.skip)
  • Workspace dependency validation logic remains intact

Breaking Changes

Import path changes (affects consumers):

  • @init/error@init/error/fault
  • Custom duration utilities removed (use Effect.Duration instead)

Duration format changes:

  • More readable format: "1m""1 minute" (both work with Effect.Duration)

Documentation Updates

Added comprehensive CLI command documentation to README.md with command table showing all available operations.

Confidence Score: 5/5

  • This PR is safe to merge with high confidence - it's a well-executed refactor with consistent patterns
  • The refactor is comprehensive and systematic: (1) All deleted utilities are confirmed unused via grep, (2) Effect.Duration API usage is correct and tested, (3) Import paths are consistently updated across all files, (4) Error handling is improved with structured types and context, (5) CLI commands follow consistent patterns with proper Effect error handling, (6) No logic bugs detected in migration, (7) Dependencies properly added/removed. The code quality is high with clear separation of concerns.
  • No files require special attention - the migration is clean and consistent throughout

Important Files Changed

File Analysis

Filename Score Overview
cli/src/index.ts 5/5 Migrated from consola to Effect CLI, clean refactor with proper error handling
cli/src/commands/setup.ts 5/5 New setup command with comprehensive workspace initialization, proper Effect usage
cli/src/commands/update.ts 5/5 Template synchronization with git operations, well-structured with Effect
cli/src/utils.ts 5/5 Utility functions for version management and file operations with Effect
packages/email/src/client.ts 4/5 Migrated to Effect.Duration and Fault error handling, improved error context
packages/kv/src/client.ts 4/5 Migrated to Effect.Duration API for TTL configuration
packages/error/src/fault.ts 5/5 Consolidated error types with new email errors, moved from auth.ts and index.ts
apps/api/src/shared/middleware.ts 4/5 Migrated to Effect.Duration for rate limiting intervals
packages/db/scripts/reset.ts 5/5 Simplified script, removed production database reset support with console.log
packages/db/scripts/seed.ts 5/5 Simplified script, removed production database seed support with console.log

Sequence Diagram

sequenceDiagram
    participant User
    participant CLI as init-now CLI
    participant Effect as Effect Runtime
    participant FS as FileSystem
    participant Git as Git Commands
    participant Packages as @init Packages
    
    Note over User,Packages: Main refactor: Effect adoption & CLI expansion
    
    User->>CLI: bunx init-now@latest
    CLI->>Effect: Command.run(main)
    Effect->>User: Prompt for project name
    User->>Effect: Provides name
    Effect->>FS: Check directory exists
    Effect->>User: Confirm overwrite (if needed)
    Effect->>Git: downloadTemplate
    Effect->>FS: Create project structure
    Effect->>User: Prompt install deps
    Effect->>Effect: bun install (if confirmed)
    Effect->>User: Success message
    
    Note over User,Packages: New CLI commands (moved from scripts/template)
    
    User->>CLI: init-now setup
    CLI->>Effect: setupCommand.handler
    Effect->>User: Prompt workspace selection
    Effect->>FS: Remove unselected workspaces
    Effect->>FS: Update package.json
    Effect->>FS: Setup .env files
    Effect->>Git: Initialize git repo
    
    User->>CLI: init-now update
    CLI->>Effect: updateCommand.handler
    Effect->>Git: Clone template repo
    Effect->>Git: Compare local vs template
    Effect->>FS: Copy updated files
    Effect->>Git: Stage changes
    
    Note over Packages: Duration & Error handling migration
    
    User->>Packages: Use @init/email
    Packages->>Effect: Duration.decode("1 minute")
    Effect->>Packages: Duration object
    Packages->>Packages: Duration.toMillis()
    Packages->>Packages: Fault.wrap(error) on failure
    
    User->>Packages: Use @init/kv with TTL
    Packages->>Effect: Duration.decode(config.ttl)
    Effect->>Packages: Duration object
    Packages->>Packages: Duration.toSeconds()
    
    User->>Packages: API rate limiting
    Packages->>Effect: Duration.decode("1 minute")
    Effect->>Packages: Duration object
    Packages->>Packages: Duration.toMillis()
Loading

@coderabbitai
Copy link

coderabbitai bot commented Jan 11, 2026

Important

Review skipped

Auto reviews are disabled on this repository.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

✨ Finishing touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch more-effect

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Collaborator Author

adelrodriguez commented Jan 11, 2026

@adelrodriguez adelrodriguez changed the base branch from effect-cli to graphite-base/66 January 11, 2026 00:53
@adelrodriguez adelrodriguez changed the base branch from graphite-base/66 to effect-cli January 11, 2026 01:05
Base automatically changed from effect-cli to main January 11, 2026 01:06
@adelrodriguez adelrodriguez marked this pull request as ready for review January 11, 2026 01:07
Copy link

@greptile-apps greptile-apps bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No files reviewed, no comments

Edit Code Review Agent Settings | Greptile

@adelrodriguez adelrodriguez merged commit 427c815 into main Jan 11, 2026
7 checks passed
@adelrodriguez adelrodriguez deleted the more-effect branch January 11, 2026 01:17
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