Grep searches a repository by pattern and returns paginated results. Optional context lines include nearby lines for each match so agents and tools can retrieve only the relevant slices without cloning the repo.
// Example: find a line from "Introducing Code Storage".
const resp = await fetch('/api/v1/repos/grep', {
method: 'POST',
headers: {
Authorization: `Bearer ${token}`,
'Content-Type': 'application/json',
},
body: JSON.stringify({
rev: 'main',
query: { pattern: 'ephemeral branches' },
paths: ['app/blog/markdown/'],
file_filters: {
include_globs: ['**/*.md'],
},
context: { before: 0, after: 1 },
pagination: { limit: 50 },
}),
});
const data = await resp.json();