Skip to content

Commit 220a790

Browse files
feat(web): improve ask agent & MCP tools (#1014)
1 parent ee74234 commit 220a790

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

72 files changed

+2628
-1741
lines changed

.env.development

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,3 +76,5 @@ SOURCEBOT_TELEMETRY_DISABLED=true # Disables telemetry collection
7676
# CONFIG_MAX_REPOS_NO_TOKEN=
7777
NODE_ENV=development
7878
# SOURCEBOT_TENANCY_MODE=single
79+
80+
DEBUG_WRITE_CHAT_MESSAGES_TO_FILE=true

CHANGELOG.md

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

1010
### Changed
1111
- Changed language detection to resolve file extensions with multiple language resolutions (e.g., .md) to the most common resolution. [#1026](https://github.com/sourcebot-dev/sourcebot/pull/1026)
12+
- Changed the `webUrl` property of the `/api/repos` api to return a URL rather than just a path. [#1014](https://github.com/sourcebot-dev/sourcebot/pull/1014)
13+
- Changed the ask search scope selector to allow submitting questions with no search scope selected. When no selection is made, the agent will be able to search over all repos the user has access to. [#1014](https://github.com/sourcebot-dev/sourcebot/pull/1014)
14+
- Renamed the `search_code` tool to `grep` for ask and mcp. [#1014](https://github.com/sourcebot-dev/sourcebot/pull/1014)
15+
16+
### Added
17+
- Added `glob`, `find_symbol_definitions`, and `find_symbol_references` tools to the ask agent and MCP server. [#1014](https://github.com/sourcebot-dev/sourcebot/pull/1014)
18+
- Added `list_tree` tool to the ask agent. [#1014](https://github.com/sourcebot-dev/sourcebot/pull/1014)
19+
- Added input & output token breakdown in ask details card. [#1014](https://github.com/sourcebot-dev/sourcebot/pull/1014)
20+
- Added `path` parameter to the `/api/commits` api to allow filtering commits by paths. [#1014](https://github.com/sourcebot-dev/sourcebot/pull/1014)
21+
22+
### Fixed
23+
- Fixed issue where ask responses would sometimes appear in the details panel while generating. [#1014](https://github.com/sourcebot-dev/sourcebot/pull/1014)
24+
- Fixed reference panel overflow issue in the ask UI. [#1014](https://github.com/sourcebot-dev/sourcebot/pull/1014)
25+
- Fixed homepage scrolling issue in the ask UI. [#1014](https://github.com/sourcebot-dev/sourcebot/pull/1014)
1226

1327
## [4.15.11] - 2026-03-20
1428

CLAUDE.md

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,25 @@ Exceptions:
3838
- Special files like `README.md`, `CHANGELOG.md`, `LICENSE`
3939
- Next.js conventions: `page.tsx`, `layout.tsx`, `loading.tsx`, etc.
4040

41+
## Code Style
42+
43+
Always use curly braces for `if` statements, with the body on a new line — even for single-line bodies:
44+
45+
```ts
46+
// Correct
47+
if (!value) {
48+
return;
49+
}
50+
if (condition) {
51+
doSomething();
52+
}
53+
54+
// Incorrect
55+
if (!value) return;
56+
if (!value) { return; }
57+
if (condition) doSomething();
58+
```
59+
4160
## Tailwind CSS
4261

4362
Use Tailwind color classes directly instead of CSS variable syntax:

docs/docs/features/mcp-server.mdx

Lines changed: 46 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -304,22 +304,19 @@ Pass the key as an `Authorization: Bearer <key>` header when connecting to the M
304304

305305
## Available Tools
306306

307-
### `search_code`
307+
### `grep`
308308

309-
Searches for code that matches the provided search query as a substring by default, or as a regular expression if `useRegex` is true.
309+
Searches for code matching a regular expression pattern across repositories, similar to `grep`/`ripgrep`. Always case-sensitive. Results are grouped by file and include line numbers.
310310

311311
Parameters:
312312
| Name | Required | Description |
313-
|:----------------------|:---------|:---------------------------------------------------------------------------------------------------------------------|
314-
| `query` | yes | The search pattern to match against code contents. Do not escape quotes in your query. |
315-
| `useRegex` | no | Whether to use regular expression matching. When false, substring matching is used (default: false). |
316-
| `filterByRepos` | no | Scope the search to specific repositories. |
317-
| `filterByLanguages` | no | Scope the search to specific languages. |
318-
| `filterByFilepaths` | no | Scope the search to specific filepaths. |
319-
| `caseSensitive` | no | Whether the search should be case sensitive (default: false). |
320-
| `includeCodeSnippets` | no | Whether to include code snippets in the response (default: false). |
313+
|:----------|:---------|:--------------------------------------------------------------------------------------------------------------|
314+
| `pattern` | yes | The regex pattern to search for in file contents. |
315+
| `path` | no | Directory path to scope the search to. Defaults to the repository root. |
316+
| `include` | no | File glob pattern to include in the search (e.g. `*.ts`, `*.{ts,tsx}`). |
317+
| `repo` | no | Repository name to search in. If not provided, searches all repositories. Use the full name including host (e.g. `github.com/org/repo`). |
321318
| `ref` | no | Commit SHA, branch or tag name to search on. If not provided, defaults to the default branch. |
322-
| `maxTokens` | no | The maximum number of tokens to return (default: 10000). |
319+
| `limit` | no | Maximum number of matching files to return (default: 100). |
323320

324321
### `list_repos`
325322

@@ -336,18 +333,20 @@ Parameters:
336333

337334
### `read_file`
338335

339-
Reads the source code for a given file.
336+
Reads the source code for a given file, with optional line range control for large files.
340337

341338
Parameters:
342339
| Name | Required | Description |
343-
|:-------|:---------|:-------------------------------------------------------------------------------------------------------|
340+
|:---------|:---------|:-------------------------------------------------------------------------------------------------------|
344341
| `repo` | yes | The repository name. |
345342
| `path` | yes | The path to the file. |
346343
| `ref` | no | Commit SHA, branch or tag name to fetch the source code for. If not provided, uses the default branch. |
344+
| `offset` | no | Line number to start reading from (1-indexed). Omit to start from the beginning. |
345+
| `limit` | no | Maximum number of lines to read (max: 500). Omit to read up to 500 lines. |
347346

348347
### `list_tree`
349348

350-
Lists files and directories from a repository path. Can be used as a directory listing tool (`depth: 1`) or a repo-tree tool (`depth > 1`).
349+
Lists files and directories from a repository path. Directories are shown before files at each level.
351350

352351
Parameters:
353352
| Name | Required | Description |
@@ -376,6 +375,39 @@ Parameters:
376375
| `page` | no | Page number for pagination (min 1, default: 1). |
377376
| `perPage` | no | Results per page for pagination (min 1, max 100, default: 50). |
378377

378+
### `glob`
379+
380+
Finds files whose paths match a glob pattern across repositories (e.g. `**/*.ts`, `src/**/*.test.{ts,tsx}`). Results are grouped by repository.
381+
382+
Parameters:
383+
| Name | Required | Description |
384+
|:----------|:---------|:------------|
385+
| `pattern` | yes | Glob pattern to match file paths against (e.g. `**/*.ts`, `src/**/*.test.{ts,tsx}`). |
386+
| `path` | no | Restrict results to files under this subdirectory. |
387+
| `repo` | no | Repository name to search in. If not provided, searches all repositories. Use the full name including host (e.g. `github.com/org/repo`). |
388+
| `ref` | no | Commit SHA, branch or tag name to search on. If not provided, defaults to the default branch. |
389+
| `limit` | no | Maximum number of files to return (default: 100). |
390+
391+
### `find_symbol_definitions`
392+
393+
Finds where a symbol (function, class, variable, etc.) is defined in a repository.
394+
395+
Parameters:
396+
| Name | Required | Description |
397+
|:---------|:---------|:------------|
398+
| `symbol` | yes | The symbol name to find definitions of. |
399+
| `repo` | yes | Repository name to scope the search to. Use the full name including host (e.g. `github.com/org/repo`). |
400+
401+
### `find_symbol_references`
402+
403+
Finds all usages of a symbol (function, class, variable, etc.) across a repository.
404+
405+
Parameters:
406+
| Name | Required | Description |
407+
|:---------|:---------|:------------|
408+
| `symbol` | yes | The symbol name to find references to. |
409+
| `repo` | yes | Repository name to scope the search to. Use the full name including host (e.g. `github.com/org/repo`). |
410+
379411
### `list_language_models`
380412

381413
Lists the available language models configured on the Sourcebot instance. Use this to discover which models can be specified when calling `ask_codebase`.

packages/shared/src/logger.ts

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -32,12 +32,11 @@ const datadogFormat = format((info) => {
3232
return info;
3333
});
3434

35-
const humanReadableFormat = printf(({ level, message, timestamp, stack, label: _label }) => {
35+
const humanReadableFormat = printf(({ level, message, timestamp, stack, label: _label, ...rest }) => {
3636
const label = `[${_label}] `;
37-
if (stack) {
38-
return `${timestamp} ${level}: ${label}${message}\n${stack}`;
39-
}
40-
return `${timestamp} ${level}: ${label}${message}`;
37+
const extras = Object.keys(rest).length > 0 ? ` ${JSON.stringify(rest)}` : '';
38+
const base = `${timestamp} ${level}: ${label}${message}${extras}`;
39+
return stack ? `${base}\n${stack}` : base;
4140
});
4241

4342
const createLogger = (label: string) => {

packages/web/next.config.mjs

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,14 @@ const nextConfig = {
6363
]
6464
},
6565

66-
turbopack: {},
66+
turbopack: {
67+
rules: {
68+
'*.txt': {
69+
loaders: ['raw-loader'],
70+
as: '*.js',
71+
},
72+
},
73+
},
6774

6875
// @see: https://github.com/vercel/next.js/issues/58019#issuecomment-1910531929
6976
...(process.env.NODE_ENV === 'development' ? {

packages/web/package.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -144,6 +144,7 @@
144144
"escape-string-regexp": "^5.0.0",
145145
"fast-deep-equal": "^3.1.3",
146146
"fuse.js": "^7.0.0",
147+
"glob-to-regexp": "^0.4.1",
147148
"google-auth-library": "^10.1.0",
148149
"graphql": "^16.9.0",
149150
"http-status-codes": "^2.3.0",
@@ -189,6 +190,7 @@
189190
"stripe": "^17.6.0",
190191
"tailwind-merge": "^2.5.2",
191192
"tailwindcss-animate": "^1.0.7",
193+
"use-stick-to-bottom": "^1.1.3",
192194
"usehooks-ts": "^3.1.0",
193195
"vscode-icons-js": "^11.6.1",
194196
"zod": "^3.25.74",
@@ -202,6 +204,7 @@
202204
"@tanstack/eslint-plugin-query": "^5.74.7",
203205
"@testing-library/dom": "^10.4.1",
204206
"@testing-library/react": "^16.3.0",
207+
"@types/glob-to-regexp": "^0.4.4",
205208
"@types/micromatch": "^4.0.9",
206209
"@types/node": "^20",
207210
"@types/nodemailer": "^6.4.17",
@@ -218,6 +221,7 @@
218221
"jsdom": "^25.0.1",
219222
"npm-run-all": "^4.1.5",
220223
"postcss": "^8",
224+
"raw-loader": "^4.0.2",
221225
"react-email": "^5.1.0",
222226
"react-grab": "^0.1.23",
223227
"tailwindcss": "^3.4.1",

packages/web/src/app/[domain]/askgh/[owner]/[repo]/components/landingPage.tsx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,6 @@ export const LandingPage = ({
7777
languageModels={languageModels}
7878
selectedSearchScopes={selectedSearchScopes}
7979
searchContexts={[]}
80-
onContextSelectorOpenChanged={setIsContextSelectorOpen}
8180
isDisabled={isChatBoxDisabled}
8281
/>
8382
<Separator />

packages/web/src/app/[domain]/chat/components/landingPageChatBox.tsx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,6 @@ export const LandingPageChatBox = ({
4242
languageModels={languageModels}
4343
selectedSearchScopes={selectedSearchScopes}
4444
searchContexts={searchContexts}
45-
onContextSelectorOpenChanged={setIsContextSelectorOpen}
4645
isDisabled={isChatBoxDisabled}
4746
/>
4847
<Separator />

packages/web/src/app/[domain]/chat/page.tsx

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ export default async function Page(props: PageProps) {
7373
})() : undefined;
7474

7575
return (
76-
<div className="flex flex-col items-center min-h-screen overflow-hidden">
76+
<div className="flex flex-col items-center h-screen overflow-hidden">
7777
<NavigationMenu
7878
domain={params.domain}
7979
/>
@@ -88,12 +88,13 @@ export default async function Page(props: PageProps) {
8888
isCollapsedInitially={true}
8989
/>
9090
<AnimatedResizableHandle />
91-
<ResizablePanel
91+
<ResizablePanel
9292
order={2}
9393
id="chat-home-panel"
9494
defaultSize={85}
95+
className="overflow-hidden"
9596
>
96-
<div className="flex flex-col justify-center items-center mt-8 mb-8 md:mt-16 w-full px-5">
97+
<div className="flex flex-col items-center h-full overflow-y-auto pt-8 pb-8 md:pt-16 w-full px-5">
9798
<div className="max-h-44 w-auto">
9899
<SourcebotLogo
99100
className="h-18 md:h-40 w-auto"

0 commit comments

Comments
 (0)