Skip to content

feat(opencode): expose search filters in OpenCode plugin - #26

Open
oritwoen wants to merge 4 commits into
mainfrom
feat/opencode-search-filters
Open

feat(opencode): expose search filters in OpenCode plugin#26
oritwoen wants to merge 4 commits into
mainfrom
feat/opencode-search-filters

Conversation

@oritwoen

Copy link
Copy Markdown
Member

The AI SDK searchTool got filter support in #23 but the OpenCode plugin was left behind. Both integrations wrap the same core, so there's no reason for the gap.

Adds includeDomains, excludeDomains, category, startPublishedDate, and endPublishedDate to the OpenCode websxa tool args, matching what ai.ts already exposes. The options flow through to providers the same way.

Adds includeDomains, excludeDomains, category, and date filters
to the OpenCode plugin search tool, matching the AI SDK integration.
@coderabbitai

coderabbitai Bot commented Mar 17, 2026

Copy link
Copy Markdown
📝 Walkthrough

Walkthrough

New optional search filters added to the websxa tool: includeDomains, excludeDomains, category, startPublishedDate, and endPublishedDate. These consolidate into a searchOptions object passed to both searchAll and provider-specific search methods.

Changes

Cohort / File(s) Summary
WebsXA search filters
src/opencode.ts
Added 5 optional query parameters to the websxa tool's args schema. Consolidated maxResults and new filters into a single searchOptions object passed to searchAll and create(name).search instead of partial option objects.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~8 minutes

Possibly related PRs

Poem

🔍 Filter by domain, by date, by class,
One searchOptions object to pass them all,
Where includeDomains meets excludeDomains' call—
websxa queries now refine with grace! ✨

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Title check ✅ Passed The title directly and clearly describes the main change: exposing search filters in the OpenCode plugin, which matches the primary objective of adding filter support.
Description check ✅ Passed The description explains the context (alignment with ai.ts from PR #23) and lists the specific filters being added, all relevant to the changeset.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feat/opencode-search-filters
✨ Simplify code
  • Create PR with simplified code
  • Commit simplified code in branch feat/opencode-search-filters
📝 Coding Plan
  • Generate coding plan for human review comments

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

@coderabbitai coderabbitai 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.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@src/opencode.ts`:
- Around line 24-25: Validate the startPublishedDate and endPublishedDate
strings before they are forwarded in searchOptions inside the execute function:
ensure each provided value is a valid ISO 8601 date (parseable to a Date) and,
if both are present, ensure startPublishedDate <= endPublishedDate; on
validation failure return a clear error (or reject) instead of calling provider
search methods. Locate the code paths that build searchOptions (references:
execute, searchOptions, startPublishedDate, endPublishedDate) and add input
validation/normalization there so only valid date strings are passed to provider
calls.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro

Run ID: e3dc78bd-0a97-41ec-827e-eb449d631fca

📥 Commits

Reviewing files that changed from the base of the PR and between ea04a35 and d22ee05.

📒 Files selected for processing (1)
  • src/opencode.ts
📜 Review details
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
  • GitHub Check: cubic · AI code reviewer
🧰 Additional context used
📓 Path-based instructions (2)
src/**/*.{ts,tsx}

📄 CodeRabbit inference engine (AGENTS.md)

Keep provider names and capability flags as literal unions in TypeScript

Files:

  • src/opencode.ts
**/*.{ts,tsx}

📄 CodeRabbit inference engine (AGENTS.md)

Do not add as any, @ts-ignore, or placeholder unsafe types

Files:

  • src/opencode.ts
🧠 Learnings (2)
📚 Learning: 2026-03-10T19:52:07.717Z
Learnt from: aeitwoen
Repo: oritwoen/websxa PR: 5
File: packages/opencode-websxa/package.json:42-44
Timestamp: 2026-03-10T19:52:07.717Z
Learning: In the `oritwoen/websxa` monorepo, `packages/opencode-websxa` is a thin re-export shim (`export { default, WebsxaPlugin } from 'websxa/opencode'`) with no direct `opencode-ai/plugin` API usage. Its wide `>=1.0.0` peerDependency range for `opencode-ai/plugin` is intentional and mirrors the root `websxa` package; API compatibility is the root package's responsibility.

Applied to files:

  • src/opencode.ts
📚 Learning: 2026-03-17T23:08:03.291Z
Learnt from: oritwoen
Repo: oritwoen/websxa PR: 20
File: test/unit/all.test.ts:345-349
Timestamp: 2026-03-17T23:08:03.291Z
Learning: In the `oritwoen/websxa` repo, `searxng` self-registers on import (via `src/providers/index.ts`), so `detectAvailableProviders()` never returns an empty array in practice during tests. Mocking the provider registry to force an empty result is not worth the ceremony since the `NoProviderConfiguredError` throw is the same codepath as passing an explicit `providers: []`.

Applied to files:

  • src/opencode.ts
🧬 Code graph analysis (1)
src/opencode.ts (3)
src/core/all.ts (1)
  • searchAll (29-32)
src/index.ts (3)
  • searchAll (15-15)
  • resolveDefaultProvider (18-18)
  • create (13-13)
src/core/resolve.ts (1)
  • resolveDefaultProvider (28-40)
🔇 Additional comments (2)
src/opencode.ts (2)

21-23: Domain/category filters are threaded correctly

Good change. These new args are exposed and then carried forward through execution, so plugin and SDK behavior stay aligned.


32-32: Shared searchOptions on both paths is the right shape

Good call using the same options object for searchAll and create(name).search. It avoids branch drift and keeps filter behavior consistent.

Also applies to: 36-36

Comment thread src/opencode.ts

@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.

No issues found across 1 file

Confidence score: 5/5

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

Auto-approved: Adds optional search filter parameters to the OpenCode plugin tool schema to align with core functionality, which is a low-risk feature enhancement.

@oritwoen oritwoen self-assigned this Mar 18, 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