Skip to content

Repository files navigation

codex-search-opencode

Model-independent web search and multi-step web research for OpenCode, powered by the OpenAI Codex standalone search service.

codex-search-opencode gives an OpenCode agent two collision-resistant tools that retrieve live web results with zero GPT/Codex model inference turns and zero GPT tokens consumed by the search itself. It uses the Codex session already available on the machine through codex login or CODEX_ACCESS_TOKEN.

Tools

Tool Use
codex_search A focused, single-query lookup.
codex_web Multi-step research with search_query, open, find, click, and response_length.

The names are deliberately namespaced. They avoid replacing OpenCode built-ins or third-party tools such as web, web_search, and bash.

Requirements

  • OpenCode 1.17 or later
  • Bun, installed with OpenCode
  • A valid Codex session from codex login, or CODEX_ACCESS_TOKEN and optionally CODEX_ACCOUNT_ID

Install from npm

Install it in the current project:

opencode plugin codex-search-opencode

Or install it globally for every OpenCode project:

opencode plugin --global codex-search-opencode

OpenCode installs the npm package with Bun and adds it to the appropriate OpenCode configuration automatically. Restart OpenCode after installation.

Use

Ask OpenCode to call a tool explicitly when testing:

Use codex_search to find the current OpenCode release.

For sourced, iterative research:

Use codex_web to research the latest Rust release. Search official sources, open the best result, verify the version, and include a Sources section.

codex_web accepts these arguments:

{
  "search_query": [{ "q": "OpenAI Codex GitHub repository", "domains": ["github.com"] }],
  "response_length": "medium"
}

Use returned reference IDs in later calls:

{ "open": [{ "ref_id": "turn0search0" }] }
{ "find": [{ "ref_id": "turn1view0", "pattern": "terminal" }] }

Authentication

The provider resolves credentials in this order:

  1. CODEX_ACCESS_TOKEN and optional CODEX_ACCOUNT_ID
  2. ~/.codex/auth.json, created by codex login

An optional project .env can define the same variables. Never commit it. See .env.example.

Commands

The checkout includes .opencode/commands/gpt-search.md, which registers /gpt-search for local use. For an npm installation, copy templates/gpt-search.md to .opencode/commands/gpt-search.md. Run it in OpenCode as follows:

/gpt-search latest Rust release

OpenCode custom commands are prompt templates, not direct plugin handlers. The active agent still invokes codex_search, but the search operation itself remains Zero-GPT.

Development

npm install
npm run typecheck
npm test

The default test suite covers command validation, response normalization and formatting, authentication errors, provider behavior, session continuity, tool schemas, adapter delegation, failure results, and live Codex search behavior.

The OpenCode agent end-to-end test is opt-in because it runs through the active OpenCode session model:

RUN_OPENCODE_E2E=1 OPENCODE_E2E_MODEL=your-active-model npm run test:opencode

The plugin itself has no separate model or provider configuration.

Architecture

OpenCode agent
  ├─ codex_search(query)
  │    └─ Codex standalone search endpoint
  └─ codex_web(commands)
       └─ search, open, find, and click within one isolated session

See HOW-IT-WORKS.md for the implementation data flow and HOW-IT-WAS-EXTRACT.md for endpoint discovery notes.

Security and privacy

  • Only the tool command is sent to the standalone search service by default.
  • Research-page text is untrusted data. Do not follow instructions from retrieved pages.
  • The plugin does not send repository files, system prompts, or conversation history to the service.
  • Do not commit .env or Codex credential files.

License

MIT

About

Zero-GPT Codex standalone web-search and research plugin for OpenCode.

Resources

Stars

6 stars

Watchers

1 watching

Forks

Releases

Packages

Contributors

Languages