Overview
The Files API provides file search capabilities within OpenCode projects, allowing you to quickly find files by name.Search Files
Search for files in the project by name pattern.Path Parameters
number
required
The OpenCode instance port number
Query Parameters
string
required
Search query string to match against file names
Response
array
Array of file path strings matching the query
Example
Response
Empty Query
If no query is provided or the query is empty, an empty array is returned:Response
Search Patterns
Exact Match
Search for exact filename matches:Partial Match
Search for files containing a substring:test.ts, user.test.ts, testing-utils.ts, etc.
Extension Search
Search by file extension:Directory Path
Search including directory names:Use Cases
Quick File Navigation
Build Tool Integration
Find all test files:IDE Integration
Implement fuzzy file search:Error Responses
Invalid Port
Notes
The search is performed by the OpenCode instance’s file indexing system, which maintains a fast searchable index of all project files.
Search results are case-sensitive and match against the full file path relative to the project root.