diff --git a/src/__tests__/commands/search.test.ts b/src/__tests__/commands/search.test.ts index 632e9d5384..246e102017 100644 --- a/src/__tests__/commands/search.test.ts +++ b/src/__tests__/commands/search.test.ts @@ -101,6 +101,9 @@ describe('executeSearch', () => { integration: 'cli', toolDetail: 'compact', }); + const body = mockHttpPost.mock.calls[0][1]; + expect(body).not.toHaveProperty('objective'); + expect(body).not.toHaveProperty('clientModel'); }); it('should allow highlights to be disabled', async () => { @@ -120,6 +123,25 @@ describe('executeSearch', () => { ); }); + it('forwards optional task context with the search request', async () => { + mockHttpPost.mockResolvedValue(mockSearchResponse({ web: [] })); + + await executeSearch({ + query: 'React memo docs', + objective: 'Find official guidance on preventing unnecessary rerenders', + clientModel: 'claude-sonnet-4-6', + }); + + expect(mockHttpPost).toHaveBeenCalledWith( + '/v2/search', + expect.objectContaining({ + objective: + 'Find official guidance on preventing unnecessary rerenders', + clientModel: 'claude-sonnet-4-6', + }) + ); + }); + it('should pass apiUrl to getClient when provided', async () => { mockHttpPost.mockResolvedValue(mockSearchResponse({ web: [] })); diff --git a/src/commands/search.ts b/src/commands/search.ts index d3346864ec..d13436ce49 100644 --- a/src/commands/search.ts +++ b/src/commands/search.ts @@ -32,6 +32,8 @@ export async function executeSearch( limit: options.limit ?? DEFAULT_SEARCH_LIMIT, integration: 'cli', }; + if (options.objective) searchParams.objective = options.objective; + if (options.clientModel) searchParams.clientModel = options.clientModel; searchParams.toolDetail = options.toolDetail ?? 'compact'; if (options.domainTools !== undefined) searchParams.domainTools = options.domainTools; diff --git a/src/index.ts b/src/index.ts index 99801e2f76..5b973d7805 100644 --- a/src/index.ts +++ b/src/index.ts @@ -925,6 +925,11 @@ function createSearchCommand(): Command { ) .argument('', 'Search query, or alexandria for semantic tool search') .argument('[tool-query]', 'Query for search alexandria') + .option('--objective ', 'Broader task goal behind this search') + .option( + '--client-model ', + 'Model issuing and consuming the results, if known' + ) .option( '--limit ', 'Maximum number of results (default: 5, max: 100)', @@ -1060,6 +1065,8 @@ function createSearchCommand(): Command { const searchOptions = { query, + objective: options.objective, + clientModel: options.clientModel, toolDetail: options.toolDetail, domainTools: options.domainTools ?? diff --git a/src/types/search.ts b/src/types/search.ts index c8a094d65c..ebf52aa5d8 100644 --- a/src/types/search.ts +++ b/src/types/search.ts @@ -12,6 +12,10 @@ export interface SearchOptions { toolDetail?: 'compact' | 'summary' | 'full'; /** Search query (required) */ query: string; + /** Optional broader task goal for this search */ + objective?: string; + /** Model issuing and consuming this search, if known */ + clientModel?: string; /** API key for Firecrawl */ apiKey?: string; /** API URL for Firecrawl */