Skip to content

Commit 7b7f0d0

Browse files
committed
Consolidate Gravity Index tool actions
1 parent 47347ed commit 7b7f0d0

18 files changed

Lines changed: 859 additions & 404 deletions

File tree

agents/base2/base2.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ export function createBase2(
7070
'set_output',
7171
'list_directory',
7272
'glob',
73-
'gravity_index_search',
73+
'gravity_index',
7474
),
7575
spawnableAgents: buildArray(
7676
!isMax && 'file-picker',
@@ -116,7 +116,7 @@ export function createBase2(
116116
117117
- **Conventions:** Rigorously adhere to existing project conventions when reading or modifying code. Analyze surrounding code, tests, and configuration first.
118118
- **Libraries/Frameworks:** NEVER assume a library/framework is available or appropriate. Verify its established usage within the project (check imports, configuration files like 'package.json', 'Cargo.toml', 'requirements.txt', 'build.gradle', etc., or observe neighboring files) before employing it.
119-
- **Third-party services:** When the user needs an external developer service (database, auth, email, payments, AI provider, vector store, observability, hosting, etc.), use the gravity_index_search tool before recommending or integrating a provider. Present its conversion_url prominently as "Get your {service.name} API key" when credentials are needed.
119+
- **Third-party services:** When the user needs an external developer service (database, auth, email, payments, AI provider, vector store, observability, hosting, etc.), use the gravity_index tool before recommending or integrating a provider. Present its conversion_url prominently as "Get your {service.name} API key" when credentials are needed.
120120
- **Style & Structure:** Mimic the style (formatting, naming), structure, framework choices, typing, and architectural patterns of existing code in the project.
121121
- **Idiomatic Changes:** When editing, understand the local context (imports, functions/classes) to ensure your changes integrate naturally and idiomatically.
122122
- **Simplicity & Minimalism:** You should make as few changes as possible to the codebase to address the user's request. Only do what the user has asked for and no more. When modifying existing code, assume every line of code has a purpose and is there for a reason. Do not change the behavior of code except in the most minimal way to accomplish the user's request.

agents/context-pruner.ts

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -291,11 +291,13 @@ const definition: AgentDefinition = {
291291
const query = input.query as string | undefined
292292
return query ? `Web search: "${query}"` : 'Web search'
293293
}
294-
case 'gravity_index_search': {
294+
case 'gravity_index': {
295295
const query = input.query as string | undefined
296-
return query
297-
? `Gravity Index search: "${query}"`
298-
: 'Gravity Index search'
296+
const action = input.action as string | undefined
297+
if (query) {
298+
return `Gravity Index ${action ?? 'search'}: "${query}"`
299+
}
300+
return action ? `Gravity Index ${action}` : 'Gravity Index'
299301
}
300302
case 'read_docs': {
301303
const libraryTitle = input.libraryTitle as string | undefined

agents/e2e/gravity-index.e2e.test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ import type { PrintModeEvent } from '@codebuff/common/types/print-mode'
1212

1313
describe('Gravity Index SDK E2E', () => {
1414
it(
15-
'base2-free uses gravity_index_search for third-party service selection',
15+
'base2-free uses gravity_index for third-party service selection',
1616
async () => {
1717
const apiKey = process.env[API_KEY_ENV_VAR]
1818
if (!apiKey) {
@@ -58,7 +58,7 @@ describe('Gravity Index SDK E2E', () => {
5858
expect(
5959
toolCalls.some(
6060
(event) =>
61-
'toolName' in event && event.toolName === 'gravity_index_search',
61+
'toolName' in event && event.toolName === 'gravity_index',
6262
),
6363
).toBe(true)
6464

agents/types/tools.ts

Lines changed: 40 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ export type ToolName =
99
| 'end_turn'
1010
| 'find_files'
1111
| 'glob'
12-
| 'gravity_index_search'
12+
| 'gravity_index'
1313
| 'list_directory'
1414
| 'lookup_agent_info'
1515
| 'propose_str_replace'
@@ -42,7 +42,7 @@ export interface ToolParamsMap {
4242
end_turn: EndTurnParams
4343
find_files: FindFilesParams
4444
glob: GlobParams
45-
gravity_index_search: GravityIndexSearchParams
45+
gravity_index: GravityIndexParams
4646
list_directory: ListDirectoryParams
4747
lookup_agent_info: LookupAgentInfoParams
4848
propose_str_replace: ProposeStrReplaceParams
@@ -159,12 +159,45 @@ export interface GlobParams {
159159
}
160160

161161
/**
162-
* Search the Gravity Index for a recommended developer service.
162+
* Search, browse, inspect, or report integrations in the Gravity Index.
163163
*/
164-
export interface GravityIndexSearchParams {
165-
/** A natural-language description of the third-party developer service the user needs, including stack and constraints when known. */
166-
query: string
167-
}
164+
export type GravityIndexParams =
165+
| {
166+
/** Search for the best service recommendation. */
167+
action: 'search'
168+
/** What the user needs, including stack, constraints, and required capabilities when known. */
169+
query: string
170+
/** Continue a previous Gravity Index search as a follow-up. */
171+
search_id?: string
172+
/** Optional structured context about the project, stack, or constraints. */
173+
context?: Record<string, any>
174+
}
175+
| {
176+
/** Browse catalog services by category and/or keyword. */
177+
action: 'browse'
178+
/** Optional category filter, e.g. Database, Auth, Payments, Hosting, Email, AI. */
179+
category?: string
180+
/** Optional keyword filter, e.g. sendgrid or postgres. */
181+
q?: string
182+
}
183+
| {
184+
/** List every category with service counts. */
185+
action: 'list_categories'
186+
}
187+
| {
188+
/** Fetch full detail for a single service by slug. */
189+
action: 'get_service'
190+
/** Service slug, e.g. supabase, stripe, sendgrid. */
191+
slug: string
192+
}
193+
| {
194+
/** Report that an integration from a prior search was completed. */
195+
action: 'report_integration'
196+
/** search_id from the earlier search result. */
197+
search_id: string
198+
/** Slug of the service that was actually integrated. */
199+
integrated_slug: string
200+
}
168201

169202
/**
170203
* List files and directories in the specified path. Returns separate arrays of file names and directory names.

common/src/constants/analytics-events.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -124,10 +124,10 @@ export enum AnalyticsEvent {
124124
DOCS_SEARCH_INSUFFICIENT_CREDITS = 'api.docs_search_insufficient_credits',
125125
DOCS_SEARCH_ERROR = 'api.docs_search_error',
126126

127-
GRAVITY_INDEX_SEARCH_REQUEST = 'api.gravity_index_search_request',
128-
GRAVITY_INDEX_SEARCH_AUTH_ERROR = 'api.gravity_index_search_auth_error',
129-
GRAVITY_INDEX_SEARCH_VALIDATION_ERROR = 'api.gravity_index_search_validation_error',
130-
GRAVITY_INDEX_SEARCH_ERROR = 'api.gravity_index_search_error',
127+
GRAVITY_INDEX_REQUEST = 'api.gravity_index_request',
128+
GRAVITY_INDEX_AUTH_ERROR = 'api.gravity_index_auth_error',
129+
GRAVITY_INDEX_VALIDATION_ERROR = 'api.gravity_index_validation_error',
130+
GRAVITY_INDEX_ERROR = 'api.gravity_index_error',
131131

132132
// Web - Feedback API
133133
FEEDBACK_SUBMITTED = 'api.feedback_submitted',

common/src/templates/initial-agents-dir/types/tools.ts

Lines changed: 40 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ export type ToolName =
99
| 'end_turn'
1010
| 'find_files'
1111
| 'glob'
12-
| 'gravity_index_search'
12+
| 'gravity_index'
1313
| 'list_directory'
1414
| 'lookup_agent_info'
1515
| 'propose_str_replace'
@@ -42,7 +42,7 @@ export interface ToolParamsMap {
4242
end_turn: EndTurnParams
4343
find_files: FindFilesParams
4444
glob: GlobParams
45-
gravity_index_search: GravityIndexSearchParams
45+
gravity_index: GravityIndexParams
4646
list_directory: ListDirectoryParams
4747
lookup_agent_info: LookupAgentInfoParams
4848
propose_str_replace: ProposeStrReplaceParams
@@ -159,12 +159,45 @@ export interface GlobParams {
159159
}
160160

161161
/**
162-
* Search the Gravity Index for a recommended developer service.
162+
* Search, browse, inspect, or report integrations in the Gravity Index.
163163
*/
164-
export interface GravityIndexSearchParams {
165-
/** A natural-language description of the third-party developer service the user needs, including stack and constraints when known. */
166-
query: string
167-
}
164+
export type GravityIndexParams =
165+
| {
166+
/** Search for the best service recommendation. */
167+
action: 'search'
168+
/** What the user needs, including stack, constraints, and required capabilities when known. */
169+
query: string
170+
/** Continue a previous Gravity Index search as a follow-up. */
171+
search_id?: string
172+
/** Optional structured context about the project, stack, or constraints. */
173+
context?: Record<string, any>
174+
}
175+
| {
176+
/** Browse catalog services by category and/or keyword. */
177+
action: 'browse'
178+
/** Optional category filter, e.g. Database, Auth, Payments, Hosting, Email, AI. */
179+
category?: string
180+
/** Optional keyword filter, e.g. sendgrid or postgres. */
181+
q?: string
182+
}
183+
| {
184+
/** List every category with service counts. */
185+
action: 'list_categories'
186+
}
187+
| {
188+
/** Fetch full detail for a single service by slug. */
189+
action: 'get_service'
190+
/** Service slug, e.g. supabase, stripe, sendgrid. */
191+
slug: string
192+
}
193+
| {
194+
/** Report that an integration from a prior search was completed. */
195+
action: 'report_integration'
196+
/** search_id from the earlier search result. */
197+
search_id: string
198+
/** Slug of the service that was actually integrated. */
199+
integrated_slug: string
200+
}
168201

169202
/**
170203
* List files and directories in the specified path. Returns separate arrays of file names and directory names.

common/src/tools/constants.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ export const toolNames = [
3030
'end_turn',
3131
'find_files',
3232
'glob',
33-
'gravity_index_search',
33+
'gravity_index',
3434
'list_directory',
3535
'lookup_agent_info',
3636
'propose_str_replace',
@@ -63,7 +63,7 @@ export const publishedTools = [
6363
'end_turn',
6464
'find_files',
6565
'glob',
66-
'gravity_index_search',
66+
'gravity_index',
6767
'list_directory',
6868
'lookup_agent_info',
6969
'propose_str_replace',

common/src/tools/list.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ import { createPlanParams } from './params/tool/create-plan'
1111
import { endTurnParams } from './params/tool/end-turn'
1212
import { findFilesParams } from './params/tool/find-files'
1313
import { globParams } from './params/tool/glob'
14-
import { gravityIndexSearchParams } from './params/tool/gravity-index-search'
14+
import { gravityIndexParams } from './params/tool/gravity-index'
1515
import { listDirectoryParams } from './params/tool/list-directory'
1616
import { lookupAgentInfoParams } from './params/tool/lookup-agent-info'
1717
import { proposeStrReplaceParams } from './params/tool/propose-str-replace'
@@ -50,7 +50,7 @@ export const toolParams = {
5050
end_turn: endTurnParams,
5151
find_files: findFilesParams,
5252
glob: globParams,
53-
gravity_index_search: gravityIndexSearchParams,
53+
gravity_index: gravityIndexParams,
5454
list_directory: listDirectoryParams,
5555
lookup_agent_info: lookupAgentInfoParams,
5656
propose_str_replace: proposeStrReplaceParams,

common/src/tools/params/tool/gravity-index-search.ts

Lines changed: 0 additions & 62 deletions
This file was deleted.

0 commit comments

Comments
 (0)