Skip to content

Commit 38a54bc

Browse files
fatmcgavGavin Williams
andauthored
feat: Add support for topics to Search Contexts (#1028)
* feat: Add support for `topics` to Search Contexts This commit updates Sourcebot to include support for using `topics` as part of the Search Context definition. As part of this: * Updated `repoMetadataSchema` to store `topics` for `github` and `gitlab` host types * Populate the topic list when compiling GitHub and Gitlab repos * Updated schemas to support `includeTopics/excludeTopics` * Expanded test coverage * Updated Docs * Replace some references to `GitLab` with `repository` * One more replace * Add CHANGELOG.md entry --------- Co-authored-by: Gavin Williams <gavin.williams@getchip.uk>
1 parent 220a790 commit 38a54bc

File tree

14 files changed

+833
-5
lines changed

14 files changed

+833
-5
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
1818
- Added `list_tree` tool to the ask agent. [#1014](https://github.com/sourcebot-dev/sourcebot/pull/1014)
1919
- Added input & output token breakdown in ask details card. [#1014](https://github.com/sourcebot-dev/sourcebot/pull/1014)
2020
- Added `path` parameter to the `/api/commits` api to allow filtering commits by paths. [#1014](https://github.com/sourcebot-dev/sourcebot/pull/1014)
21+
- Search contexts now support topic-based filtering with new `includeTopics` and `excludeTopics` fields, enabling repository filtering by GitHub/GitLab topics with glob pattern support and case-insensitive matching.[#1028](https://github.com/sourcebot-dev/sourcebot/pull/1028)
2122

2223
### Fixed
2324
- Fixed issue where ask responses would sometimes appear in the details panel while generating. [#1014](https://github.com/sourcebot-dev/sourcebot/pull/1014)

docs/docs/features/search/search-contexts.mdx

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,38 @@ Like other prefixes, contexts can be negated using `-` or combined using `or`:
106106

107107
See [this doc](/docs/features/search/syntax-reference) for more details on the search query syntax.
108108

109+
## Filtering by topic
110+
111+
If your repositories are tagged with topics on [GitHub](https://docs.github.com/en/repositories/managing-your-repositorys-settings-and-features/customizing-your-repository/classifying-your-repository-with-topics) or [GitLab](https://docs.gitlab.com/ee/user/project/topics.html), you can use `includeTopics` and `excludeTopics` to filter repositories by topic instead of (or in addition to) specifying individual repo URLs. Glob patterns are supported.
112+
113+
```json
114+
{
115+
"$schema": "https://raw.githubusercontent.com/sourcebot-dev/sourcebot/main/schemas/v3/index.json",
116+
"contexts": {
117+
"backend": {
118+
"includeTopics": ["backend", "core-*"],
119+
"excludeTopics": ["deprecated", "archived-*"],
120+
"description": "Active backend services."
121+
}
122+
},
123+
"connections": {
124+
/* ...connection definitions... */
125+
}
126+
}
127+
```
128+
129+
`includeTopics` and `excludeTopics` follow the same additive semantics as `include` and `exclude`:
130+
131+
- `includeTopics` adds all repos tagged with a matching topic to the context.
132+
- `excludeTopics` removes repos tagged with a matching topic from the context.
133+
- Both can be freely combined with `include`, `includeConnections`, `exclude`, and `excludeConnections`.
134+
135+
Topic matching is case-insensitive, so `"Backend"` matches the pattern `"backend"`.
136+
137+
<Note>
138+
Topics are populated when a connection syncs. If you add topics to your repositories after the last sync, trigger a re-sync for the new topics to take effect.
139+
</Note>
140+
109141
## Schema reference
110142

111143
<Accordion title="Reference">

docs/snippets/schemas/v3/index.schema.mdx

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -151,6 +151,32 @@
151151
"type": "string"
152152
}
153153
},
154+
"includeTopics": {
155+
"type": "array",
156+
"description": "List of repository topics to include in the search context. Only repositories matching at least one topic are included. Glob patterns are supported.",
157+
"items": {
158+
"type": "string"
159+
},
160+
"examples": [
161+
[
162+
"backend",
163+
"core-*"
164+
]
165+
]
166+
},
167+
"excludeTopics": {
168+
"type": "array",
169+
"description": "List of repository topics to exclude from the search context. Repositories matching any of these topics are excluded. Glob patterns are supported.",
170+
"items": {
171+
"type": "string"
172+
},
173+
"examples": [
174+
[
175+
"deprecated",
176+
"archived-*"
177+
]
178+
]
179+
},
154180
"description": {
155181
"type": "string",
156182
"description": "Optional description of the search context that surfaces in the UI."
@@ -313,6 +339,32 @@
313339
"type": "string"
314340
}
315341
},
342+
"includeTopics": {
343+
"type": "array",
344+
"description": "List of repository topics to include in the search context. Only repositories matching at least one topic are included. Glob patterns are supported.",
345+
"items": {
346+
"type": "string"
347+
},
348+
"examples": [
349+
[
350+
"backend",
351+
"core-*"
352+
]
353+
]
354+
},
355+
"excludeTopics": {
356+
"type": "array",
357+
"description": "List of repository topics to exclude from the search context. Repositories matching any of these topics are excluded. Glob patterns are supported.",
358+
"items": {
359+
"type": "string"
360+
},
361+
"examples": [
362+
[
363+
"deprecated",
364+
"archived-*"
365+
]
366+
]
367+
},
316368
"description": {
317369
"type": "string",
318370
"description": "Optional description of the search context that surfaces in the UI."

docs/snippets/schemas/v3/searchContext.schema.mdx

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,32 @@
4646
"type": "string"
4747
}
4848
},
49+
"includeTopics": {
50+
"type": "array",
51+
"description": "List of repository topics to include in the search context. Only repositories matching at least one topic are included. Glob patterns are supported.",
52+
"items": {
53+
"type": "string"
54+
},
55+
"examples": [
56+
[
57+
"backend",
58+
"core-*"
59+
]
60+
]
61+
},
62+
"excludeTopics": {
63+
"type": "array",
64+
"description": "List of repository topics to exclude from the search context. Repositories matching any of these topics are excluded. Glob patterns are supported.",
65+
"items": {
66+
"type": "string"
67+
},
68+
"examples": [
69+
[
70+
"deprecated",
71+
"archived-*"
72+
]
73+
]
74+
},
4975
"description": {
5076
"type": "string",
5177
"description": "Optional description of the search context that surfaces in the UI."

0 commit comments

Comments
 (0)