diff --git a/README.md b/README.md index 9d31fe2a8..4c2c63757 100644 --- a/README.md +++ b/README.md @@ -313,6 +313,8 @@ firecrawl search "AI data tools" | `--location ` | Geo-targeting (e.g., "Germany", "San Francisco,California,United States") | | `--country ` | ISO country code (default: US) | | `--timeout ` | Timeout in milliseconds (default: 60000) | +| `--highlights` | Return query-relevant highlights for each result | +| `--no-highlights` | Keep the original search snippets | | `--ignore-invalid-urls` | Exclude URLs invalid for other Firecrawl endpoints | | `--scrape` | Enable scraping of search results | | `--scrape-formats ` | Scrape formats when `--scrape` enabled (default: markdown) | diff --git a/package.json b/package.json index 083d30cd7..66923b8f2 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "firecrawl-cli", - "version": "1.19.26", + "version": "1.19.27", "description": "Command-line interface for Firecrawl. Scrape, crawl, and extract data from any website directly from your terminal.", "main": "dist/index.js", "bin": { diff --git a/src/__tests__/commands/search.test.ts b/src/__tests__/commands/search.test.ts index f55968381..116e12841 100644 --- a/src/__tests__/commands/search.test.ts +++ b/src/__tests__/commands/search.test.ts @@ -84,6 +84,23 @@ describe('executeSearch', () => { }); }); + it('should allow highlights to be disabled', async () => { + mockHttpPost.mockResolvedValue(mockSearchResponse({ web: [] })); + + await executeSearch({ + query: 'test query', + highlights: false, + }); + + expect(mockHttpPost).toHaveBeenCalledWith( + '/v2/search', + expect.objectContaining({ + highlights: false, + query: 'test query', + }) + ); + }); + 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 585066073..9a768ae0e 100644 --- a/src/commands/search.ts +++ b/src/commands/search.ts @@ -27,6 +27,10 @@ export async function executeSearch( integration: 'cli', }; + if (options.highlights !== undefined) { + searchParams.highlights = options.highlights; + } + // Add sources if specified if (options.sources && options.sources.length > 0) { searchParams.sources = options.sources.map((source) => ({ diff --git a/src/index.ts b/src/index.ts index 8949f0732..5c1ae11f3 100644 --- a/src/index.ts +++ b/src/index.ts @@ -943,6 +943,14 @@ function createSearchCommand(): Command { 'Exclude URLs invalid for other Firecrawl endpoints', false ) + .option( + '--highlights', + 'Return query-relevant highlights for each search result' + ) + .option( + '--no-highlights', + 'Keep the original search snippets instead of returning highlights' + ) .option('--scrape', 'Enable scraping of search results', false) .option( '--scrape-formats ', @@ -1022,6 +1030,7 @@ function createSearchCommand(): Command { country: options.country, timeout: options.timeout, ignoreInvalidUrls: options.ignoreInvalidUrls, + highlights: options.highlights, scrape: options.scrape, scrapeFormats, onlyMainContent: options.onlyMainContent, diff --git a/src/types/search.ts b/src/types/search.ts index e469b2b8c..48ad8295e 100644 --- a/src/types/search.ts +++ b/src/types/search.ts @@ -30,6 +30,8 @@ export interface SearchOptions { timeout?: number; /** Exclude URLs invalid for other Firecrawl endpoints */ ignoreInvalidUrls?: boolean; + /** Return query-relevant highlights instead of the original search snippets */ + highlights?: boolean; /** Output file path */ output?: string; /** Output as JSON format */