opencode
opencode copied to clipboard
feat: Add websearch tool with Perplexity AI integration
Summary
- Adds websearch tool powered by Perplexity AI for real-time web search
- Uses llama-3.1-sonar-small-128k-online model for precise, concise answers
- Requires PERPLEXITY_API_KEY in ~/.local/share/opencode/auth.json
- Follows OpenCode coding standards (Bun APIs, no try/catch, optional chaining)
Changes
packages/opencode/src/tool/websearch.ts: New tool implementation using Bun.file() APIpackages/opencode/src/tool/websearch.txt: Tool documentation
Testing
Tool has been manually tested with custom Perplexity API key.
I can vouch for this feature, been rolling my own mini mcp server and name it 'pplx'. "hey go consult pplx about this topic before doing that", "research latest api spec for this api and save it as an md file using pplx" opened a whole new way to tackle problems.
More references
@ai-sdk/perplexity- Official perplexity mcp
- Personally I don't like its bulky implementation, though.