Skip to content

refactor!: use abstract provider classes - #36

Merged
oritwoen merged 3 commits into
mainfrom
refactor/abstract-provider-classes
Aug 8, 2026
Merged

refactor!: use abstract provider classes#36
oritwoen merged 3 commits into
mainfrom
refactor/abstract-provider-classes

Conversation

@oritwoen

@oritwoen oritwoen commented Aug 7, 2026

Copy link
Copy Markdown
Member

I want provider integrations to be normal classes here, not factory-shaped objects. Registry now takes constructors for abstract Provider, while search, read and reachability stay separate capabilities so read-only provider doesn't need fake search(). This is breaking for custom registrations, no compatibility shim.

Review in cubic

@oritwoen oritwoen self-assigned this Aug 7, 2026

@cubic-dev-ai cubic-dev-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

All reported issues were addressed across 32 files

Architecture diagram
sequenceDiagram
    participant Caller as Caller (CLI/Extension/AI)
    participant Registry as Registry
    participant Base as Provider (abstract)
    participant Concrete as Concrete Provider (e.g., Brave)
    participant Error as Error Handler

    Note over Caller,Registry: NEW: Registration via class constructors
    Concrete->>Registry: register(ProviderClass) (static providerName, defaultBaseURL)
    Registry-->>Concrete: stored

    Note over Caller,Base: NEW: Capability-aware creation
    Caller->>Registry: createSearchProvider(name, config)
    Registry->>Registry: lookup ProviderClass
    Registry->>Concrete: new ProviderClass(config)
    Concrete->>Base: super(config, ProviderClass)
    Base->>Base: validate baseURL (http/https) - throws InvalidProviderUrlError if not
    Base-->>Concrete: initialized
    Registry->>Registry: isSearchProvider(provider) check
    alt provider lacks search()
        Registry->>Error: SearchNotSupportedError
        Error-->>Caller: error handled in command (exit 1)
    else provider supports search
        Registry-->>Caller: SearchProvider instance
        Caller->>Concrete: search(query, options)
        Concrete-->>Caller: SearchResult[]
    end

    Note over Caller,Registry: NEW: Read capability via createReadProvider
    Caller->>Registry: createReadProvider(name, config)
    Registry->>Concrete: new ProviderClass(config)
    Registry->>Registry: isReadProvider(provider) check
    alt provider lacks read()
        Registry->>Error: ReadNotSupportedError
        Error-->>Caller: thrown from readUrl()
    else provider supports read
        Registry-->>Caller: ReadProvider instance
        Caller->>Concrete: read(url, options)
        Concrete-->>Caller: ReadResult
    end

    Note over Caller,Registry: Availability probe (resolve.ts)
    Caller->>Registry: create(name)
    Registry->>Concrete: new ProviderClass(config)
    Caller->>Concrete: isAvailable()? (only if isAvailabilityProvider)
    Concrete-->>Caller: boolean (reachable)
Loading

Reply with feedback, questions, or to request a fix.

Re-trigger cubic

Comment thread test/unit/registry.test.ts
Comment thread src/core/provider.ts Outdated

@cubic-dev-ai cubic-dev-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

0 issues found across 5 files (changes from recent commits).

Confidence score: 5/5

  • Automated review surfaced no issues in the provided summaries.
  • No files require special attention.

Requires human review: Breaks public API: register and create signatures changed, custom provider integrations require update without compatibility shim. Needs human review to confirm migration approach.

Re-trigger cubic

@oritwoen
oritwoen merged commit 301af4b into main Aug 8, 2026
2 checks passed
@oritwoen
oritwoen deleted the refactor/abstract-provider-classes branch August 8, 2026 09:14
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.

1 participant