Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 22 additions & 0 deletions src/__tests__/commands/search.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 () => {
Expand All @@ -120,6 +123,25 @@ describe('executeSearch', () => {
);
});

it('forwards optional task context with the search request', async () => {
Comment thread
capy-ai[bot] marked this conversation as resolved.
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: [] }));

Expand Down
2 changes: 2 additions & 0 deletions src/commands/search.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
7 changes: 7 additions & 0 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -925,6 +925,11 @@ function createSearchCommand(): Command {
)
.argument('<query>', 'Search query, or alexandria for semantic tool search')
.argument('[tool-query]', 'Query for search alexandria')
.option('--objective <goal>', 'Broader task goal behind this search')
.option(
'--client-model <model>',
'Model issuing and consuming the results, if known'
)
.option(
'--limit <number>',
'Maximum number of results (default: 5, max: 100)',
Expand Down Expand Up @@ -1060,6 +1065,8 @@ function createSearchCommand(): Command {

const searchOptions = {
query,
objective: options.objective,
clientModel: options.clientModel,
toolDetail: options.toolDetail,
domainTools:
options.domainTools ??
Expand Down
4 changes: 4 additions & 0 deletions src/types/search.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 */
Expand Down
Loading