Skip to content

Commit 4eaa36c

Browse files
cleanup
1 parent b4ce314 commit 4eaa36c

9 files changed

Lines changed: 21 additions & 64 deletions

File tree

CHANGELOG.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
99

1010
### Added
1111
- Added ask sidebar to homepage. [#721](https://github.com/sourcebot-dev/sourcebot/pull/721)
12+
- Added endpoint for searching commit history for a git repository. [#625](https://github.com/sourcebot-dev/sourcebot/pull/625)
1213

1314
## [4.10.17] - 2026-01-23
1415

@@ -162,7 +163,6 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
162163
## [4.10.0] - 2025-11-24
163164

164165
### Added
165-
- Added temporal filtering to search and repository APIs with support for git branch/revision filtering and repository index date filtering (since/until parameters). Supports both ISO 8601 and relative date formats (e.g., "30 days ago", "last week").
166166
- Added support for streaming code search results. [#623](https://github.com/sourcebot-dev/sourcebot/pull/623)
167167
- Added buttons to toggle case sensitivity and regex patterns. [#623](https://github.com/sourcebot-dev/sourcebot/pull/623)
168168
- Added counts to members, requets, and invites tabs in the members settings. [#621](https://github.com/sourcebot-dev/sourcebot/pull/621)

packages/mcp/CHANGELOG.md

Lines changed: 2 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -8,20 +8,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
88
## [Unreleased]
99

1010
### Added
11-
- Added comprehensive relative date support for all temporal parameters (e.g., "30 days ago", "last week", "yesterday")
12-
- Added `search_commits` tool to search commits by actual commit time with full temporal filtering. Accepts both numeric database IDs (e.g., 123) and string repository names (e.g., "github.com/owner/repo") for the `repoId` parameter, allowing direct use of repository names from `list_repos` output
13-
- Added `since`/`until` parameters to `search_code` (filters by index time - when Sourcebot indexed the repo)
14-
- Added `gitRevision` parameter to `search_code`
15-
- Added `activeAfter`/`activeBefore` parameters to `list_repos` (filters by index time - when Sourcebot indexed the repo)
16-
- Added date range validation to prevent invalid date ranges (since > until)
17-
- Added 30-second timeout for git operations to handle large repositories
18-
- Added enhanced error messages for git operations (timeout, repository not found, invalid git repository, ambiguous arguments)
19-
- Added clarification that repositories must be cloned on Sourcebot server disk for `search_commits` to work
20-
- Added comprehensive temporal parameter documentation to README with clear distinction between index time and commit time filtering
21-
- Added comprehensive unit tests for date parsing utilities (90+ test cases)
22-
- Added unit tests for git commit search functionality with mocking
23-
- Added integration tests for temporal parameter validation
24-
- Added unit tests for repository identifier resolution (both string and number types)
11+
- Added `search_commits` tool to search a repos commit history. [#625](https://github.com/sourcebot-dev/sourcebot/pull/625)
12+
- Added `gitRevision` parameter to the `search_code` tool to allow for searching on different branches. [#625](https://github.com/sourcebot-dev/sourcebot/pull/625)
2513

2614
## [1.0.12] - 2026-01-13
2715

packages/mcp/README.md

Lines changed: 6 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -166,8 +166,6 @@ For a more detailed guide, checkout [the docs](https://docs.sourcebot.dev/docs/f
166166

167167
Fetches code that matches the provided regex pattern in `query`.
168168

169-
**Temporal Filtering**: Use `since` and `until` to filter by repository index time (when Sourcebot last indexed the repo). This is different from commit time. See `search_commits` for commit-time filtering.
170-
171169
<details>
172170
<summary>Parameters</summary>
173171

@@ -178,9 +176,6 @@ Fetches code that matches the provided regex pattern in `query`.
178176
| `filterByLanguages` | no | Restrict search to specific languages (GitHub linguist format, e.g., Python, JavaScript). |
179177
| `caseSensitive` | no | Case sensitive search (default: false). |
180178
| `includeCodeSnippets` | no | Include code snippets in results (default: false). |
181-
| `gitRevision` | no | Git revision to search (e.g., 'main', 'develop', 'v1.0.0'). Defaults to HEAD. |
182-
| `since` | no | Only search repos indexed after this date. Supports ISO 8601 or relative (e.g., "30 days ago"). |
183-
| `until` | no | Only search repos indexed before this date. Supports ISO 8601 or relative (e.g., "yesterday"). |
184179
| `maxTokens` | no | Max tokens to return (default: env.DEFAULT_MINIMUM_TOKENS). |
185180
</details>
186181

@@ -189,18 +184,14 @@ Fetches code that matches the provided regex pattern in `query`.
189184

190185
Lists repositories indexed by Sourcebot with optional filtering and pagination.
191186

192-
**Temporal Filtering**: Use `activeAfter` and `activeBefore` to filter by repository index time (when Sourcebot last indexed the repo). This is the same filtering behavior as `search_code`'s `since`/`until` parameters.
193-
194187
<details>
195188
<summary>Parameters</summary>
196189

197-
| Name | Required | Description |
198-
|:----------------|:---------|:-----------------------------------------------------------------------------------------------|
199-
| `query` | no | Filter repositories by name (case-insensitive). |
200-
| `pageNumber` | no | Page number (1-indexed, default: 1). |
201-
| `limit` | no | Number of repositories per page (default: 50). |
202-
| `activeAfter` | no | Only return repos indexed after this date. Supports ISO 8601 or relative (e.g., "30 days ago"). |
203-
| `activeBefore` | no | Only return repos indexed before this date. Supports ISO 8601 or relative (e.g., "yesterday"). |
190+
| Name | Required | Description |
191+
|:-------------|:---------|:--------------------------------------------------------------------|
192+
| `query` | no | Filter repositories by name (case-insensitive). |
193+
| `pageNumber` | no | Page number (1-indexed, default: 1). |
194+
| `limit` | no | Number of repositories per page (default: 50). |
204195

205196
</details>
206197

@@ -219,11 +210,7 @@ Fetches the source code for a given file.
219210

220211
### search_commits
221212

222-
Searches for commits in a specific repository based on actual commit time (NOT index time).
223-
224-
**Requirements**: Repository must be cloned on the Sourcebot server disk. Sourcebot automatically clones repositories during indexing, but the cloning process may not be finished when this query is executed. Use `list_repos` first to get the repository ID.
225-
226-
**Date Formats**: Supports ISO 8601 dates (e.g., "2024-01-01") and relative formats (e.g., "30 days ago", "last week", "yesterday").
213+
Searches for commits in a specific repository based on actual commit time.
227214

228215
<details>
229216
<summary>Parameters</summary>
@@ -239,17 +226,6 @@ Searches for commits in a specific repository based on actual commit time (NOT i
239226

240227
</details>
241228

242-
## Date Format Examples
243-
244-
All temporal parameters support:
245-
- **ISO 8601**: `"2024-01-01"`, `"2024-12-31T23:59:59Z"`
246-
- **Relative dates**: `"30 days ago"`, `"1 week ago"`, `"last month"`, `"yesterday"`
247-
248-
**Important**: Different tools filter by different time dimensions:
249-
- `search_code` `since`/`until`: Filters by **index time** (when Sourcebot indexed the repo)
250-
- `list_repos` `activeAfter`/`activeBefore`: Filters by **index time** (when Sourcebot indexed the repo)
251-
- `search_commits` `since`/`until`: Filters by **commit time** (actual git commit dates)
252-
253229

254230
## Supported Code Hosts
255231
Sourcebot supports the following code hosts:

packages/mcp/src/client.ts

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,7 @@ export const search = async (request: SearchRequest): Promise<SearchResponse | S
2121
}
2222

2323
export const listRepos = async (): Promise<ListRepositoriesResponse | ServiceError> => {
24-
const url = new URL(`${env.SOURCEBOT_HOST}/api/repos`);
25-
26-
const result = await fetch(url.toString(), {
24+
const result = await fetch(`${env.SOURCEBOT_HOST}/api/repos`, {
2725
method: 'GET',
2826
headers: {
2927
'Content-Type': 'application/json',

packages/mcp/src/schemas.ts

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -203,14 +203,12 @@ export const searchCommitsRequestSchema = z.object({
203203
maxCount: z.number().int().positive().max(500).optional(),
204204
});
205205

206-
export const commitSchema = z.object({
206+
export const searchCommitsResponseSchema = z.array(z.object({
207207
hash: z.string(),
208208
date: z.string(),
209209
message: z.string(),
210210
refs: z.string(),
211211
body: z.string(),
212212
author_name: z.string(),
213213
author_email: z.string(),
214-
});
215-
216-
export const searchCommitsResponseSchema = z.array(commitSchema);
214+
}));

packages/shared/src/utils.ts

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -87,10 +87,6 @@ export const getConfigSettings = async (configPath?: string): Promise<ConfigSett
8787
}
8888
}
8989

90-
91-
// @todo: this is duplicated from the `getRepoPath` function in the
92-
// backend's `utils.ts` file. Eventually we should move this to a shared
93-
// package.
9490
export const getRepoPath = (repo: Repo): { path: string, isReadOnly: boolean } => {
9591
// If we are dealing with a local repository, then use that as the path.
9692
// Mark as read-only since we aren't guaranteed to have write access to the local filesystem.

packages/web/src/actions.ts

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -312,12 +312,12 @@ export const createApiKey = async (name: string, domain: string): Promise<{ key:
312312
withAuth((userId) =>
313313
withOrgMembership(userId, domain, async ({ org, userRole }) => {
314314
if (env.EXPERIMENT_DISABLE_API_KEY_CREATION_FOR_NON_ADMIN_USERS === 'true' && userRole !== OrgRole.OWNER) {
315-
logger.error(`API key creation is disabled for non-admin users. User ${userId} is not an owner.`);
316-
return {
317-
statusCode: StatusCodes.FORBIDDEN,
318-
errorCode: ErrorCode.INSUFFICIENT_PERMISSIONS,
319-
message: "API key creation is disabled for non-admin users.",
320-
} satisfies ServiceError;
315+
logger.error(`API key creation is disabled for non-admin users. User ${userId} is not an owner.`);
316+
return {
317+
statusCode: StatusCodes.FORBIDDEN,
318+
errorCode: ErrorCode.INSUFFICIENT_PERMISSIONS,
319+
message: "API key creation is disabled for non-admin users.",
320+
} satisfies ServiceError;
321321
}
322322

323323
const existingApiKey = await prisma.apiKey.findFirst({
@@ -465,7 +465,7 @@ export const getRepos = async ({
465465
take,
466466
}: {
467467
where?: Prisma.RepoWhereInput,
468-
take?: number,
468+
take?: number
469469
} = {}) => sew(() =>
470470
withOptionalAuthV2(async ({ org, prisma }) => {
471471
const repos = await prisma.repo.findMany({

packages/web/src/app/api/(server)/repos/route.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import { serviceErrorResponse } from "@/lib/serviceError";
33
import { isServiceError } from "@/lib/utils";
44
import { GetReposResponse } from "@/lib/types";
55

6+
67
export const GET = async () => {
78
const response: GetReposResponse = await getRepos();
89
if (isServiceError(response)) {

packages/web/src/features/search/searchApi.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import { parseQuerySyntaxIntoIR } from './parser';
88
import { SearchOptions } from "./types";
99
import { createZoektSearchRequest, zoektSearch, zoektStreamSearch } from './zoektSearcher';
1010

11+
1112
type QueryStringSearchRequest = {
1213
queryType: 'string';
1314
query: string;
@@ -45,7 +46,6 @@ export const search = (request: SearchRequest) => sew(() =>
4546

4647
export const streamSearch = (request: SearchRequest) => sew(() =>
4748
withOptionalAuthV2(async ({ prisma, user }) => {
48-
// Get repos filtered by permissions (if enabled)
4949
const repoSearchScope = await getAccessibleRepoNamesForUser({ user, prisma });
5050

5151
// If needed, parse the query syntax into the query intermediate representation.

0 commit comments

Comments
 (0)