Skip to content

Conversation

@marcusquinn
Copy link
Owner

@marcusquinn marcusquinn commented Feb 9, 2026

Summary

  • Add OpenCode as a model discovery source in model-registry-helper.sh, replacing direct API key probing when the OpenCode CLI is available
  • Update model-availability-helper.sh to use OpenCode models cache for instant model availability checks without requiring individual provider API keys
  • When OpenCode is available, tier resolution prefers opencode/* model IDs (routed through OpenCode gateway)

Changes

model-registry-helper.sh

  • New sync_opencode() function as Phase 3 (preferred source, from models.dev cache)
  • Filters to relevant providers only for performance (306 models in <1s)
  • Phase 4 (direct API probing) auto-skips when Phase 3 succeeds

model-availability-helper.sh

  • opencode added as known provider with cache-based health checks (no HTTP probe)
  • _is_opencode_available() and _opencode_model_exists() for instant lookups
  • get_tier_models() prefers opencode/* model IDs when OpenCode is available
  • OpenCode cache added as first model-level availability check

tests/test-model-availability.sh

  • New OpenCode Integration test section
  • All 33 tests pass, 0 shellcheck violations

Testing

  • model-registry-helper.sh sync --force: 306 models discovered from OpenCode
  • model-availability-helper.sh probe --all: opencode healthy
  • model-availability-helper.sh resolve : resolves to opencode/* models
  • ShellCheck: 0 violations on all 3 files

Closes t194

Summary by CodeRabbit

  • New Features

    • OpenCode is now supported as a provider option for accessing models
    • Model availability checks now leverage local caching for faster query responses
  • Documentation

    • Help and status outputs updated to document OpenCode provider support and caching behavior
  • Tests

    • Added comprehensive test coverage for OpenCode integration and health checks

… (t194)

Add OpenCode as a model discovery source, replacing direct API key probing
when the OpenCode CLI is available. This enables model availability checks
without requiring individual provider API keys in the environment.

model-registry-helper.sh:
- Add sync_opencode() as Phase 3 (preferred, from ~/.cache/opencode/models.json)
- Filter to relevant providers only (anthropic, openai, google, etc.) for performance
- Use batch SQL inserts instead of per-model queries (306 models in <1s)
- Phase 4 (direct API probing) auto-skips when Phase 3 succeeds

model-availability-helper.sh:
- Add 'opencode' as a known provider with cache-based health checks
- Add _is_opencode_available() and _opencode_model_exists() for instant lookups
- Update get_tier_models() to prefer opencode/* model IDs when available
  (routed through OpenCode's gateway, no direct API keys needed)
- Add OpenCode cache as first model-level availability check

tests/test-model-availability.sh:
- Add OpenCode integration test section (provider check, model check)
- Add opencode to provider check loop

Decision: chose OpenCode models cache over direct API probing as primary
source — matches existing project convention of using OpenCode as the
runtime environment (opencode.json provider config, opencode CLI dispatch).
@gemini-code-assist
Copy link

Warning

You have reached your daily quota limit. Please wait up to 24 hours and I will start processing your requests again!

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Feb 9, 2026

Caution

Review failed

The pull request is closed.

Walkthrough

Introduces OpenCode as a meta-provider alongside existing providers, adding CLI detection utilities, a local models.json cache mechanism, and conditional integration paths. Expands model availability checks, registry synchronization, and help documentation to recognize and leverage OpenCode when available, with fallback to existing behavior when absent.

Changes

Cohort / File(s) Summary
OpenCode Provider Integration
.agents/scripts/model-availability-helper.sh
Adds OpenCode as a known provider with new utilities (_is_opencode_available, _opencode_model_exists) for detecting the CLI and querying cached models.json. Extends KNOWN_PROVIDERS, endpoint resolution, and key variable handling to recognize OPENCODE_API_KEY. Updates tier-model resolution to prefer opencode/* mappings when available.
OpenCode Registry Synchronization
.agents/scripts/model-registry-helper.sh
Introduces sync_opencode() function to fetch model metadata from OpenCode registry cache or CLI, filter by providers, and batch-insert into the database. Integrates into cmd_sync workflow as Phase 3, with Phase 4 downgraded to fallback direct provider API discovery. Adds safeguards to skip provider probing if OpenCode sync recently discovered models.
OpenCode Integration Tests
tests/test-model-availability.sh
Adds new OpenCode Integration section with tests for help documentation, provider health checks, conditional model existence validation (when CLI and cache present), and JSON output handling. Updates existing provider check messaging and reorganizes section numbering to accommodate new coverage.

Sequence Diagram(s)

sequenceDiagram
    participant Client as Client/User
    participant Helper as Model Helper<br/>(availability-helper.sh)
    participant Cache as OpenCode<br/>models.json Cache
    participant CLI as OpenCode CLI
    participant API as Provider APIs<br/>(fallback)
    
    Client->>Helper: Request model availability/<br/>tier resolution
    Helper->>Helper: Check if OpenCode available
    alt OpenCode CLI + Cache Detected
        Helper->>Cache: Query local models.json
        Cache-->>Helper: Return cached models
        Helper->>Helper: Resolve tier using<br/>opencode/* mappings
    else OpenCode Not Available
        Helper->>API: Fallback to provider API<br/>direct discovery
        API-->>Helper: Return provider models
        Helper->>Helper: Resolve tier using<br/>standard mappings
    end
    Helper-->>Client: Return resolved models/<br/>availability status
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related issues

Possibly related PRs

Poem

🔌 OpenCode joins the provider dance,
With cache and CLI in perfect trance,
No API calls when models align,
Swift tier resolution, by design—
DevOps automation, now more refined! ✨

✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch feature/t194

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.

@github-actions
Copy link

github-actions bot commented Feb 9, 2026

🔍 Code Quality Report

�[0;35m[MONITOR]�[0m Code Review Monitoring Report

�[0;34m[INFO]�[0m Latest Quality Status:
SonarCloud: 0 bugs, 0 vulnerabilities, 60 code smells

�[0;34m[INFO]�[0m Recent monitoring activity:
Mon Feb 9 21:20:56 UTC 2026: Code review monitoring started
Mon Feb 9 21:20:56 UTC 2026: SonarCloud - Bugs: 0, Vulnerabilities: 0, Code Smells: 60

📈 Current Quality Metrics

  • BUGS: 0
  • CODE SMELLS: 60
  • VULNERABILITIES: 0

Generated on: Mon Feb 9 21:20:59 UTC 2026


Generated by AI DevOps Framework Code Review Monitoring

@sonarqubecloud
Copy link

sonarqubecloud bot commented Feb 9, 2026

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