From 6bea6d9e31c2c0cf61d2a0c8b0827ab42d7152a9 Mon Sep 17 00:00:00 2001 From: Abimael Martell Date: Fri, 6 Feb 2026 23:04:30 -0800 Subject: [PATCH 1/4] feat(scrape): Add --max-age option to Scrape --- src/__tests__/commands/scrape.test.ts | 15 +++++++++++++++ src/commands/scrape.ts | 5 +++++ src/index.ts | 5 +++++ src/types/scrape.ts | 2 ++ src/utils/options.ts | 1 + 5 files changed, 28 insertions(+) diff --git a/src/__tests__/commands/scrape.test.ts b/src/__tests__/commands/scrape.test.ts index 865cad186b..bf3c13b4b2 100644 --- a/src/__tests__/commands/scrape.test.ts +++ b/src/__tests__/commands/scrape.test.ts @@ -219,6 +219,21 @@ describe('executeScrape', () => { excludeTags: ['nav'], }); }); + + it('should include maxAge parameter when provided', async () => { + const mockResponse = { markdown: '# Test' }; + mockClient.scrape.mockResolvedValue(mockResponse); + + await executeScrape({ + url: 'https://example.com', + maxAge: 3600, + }); + + expect(mockClient.scrape).toHaveBeenCalledWith('https://example.com', { + formats: ['markdown'], + maxAge: 3600, + }); + }); }); describe('Response handling', () => { diff --git a/src/commands/scrape.ts b/src/commands/scrape.ts index 66314cc2aa..e6192831a2 100644 --- a/src/commands/scrape.ts +++ b/src/commands/scrape.ts @@ -76,6 +76,7 @@ export async function executeScrape( waitFor?: number; includeTags?: string[]; excludeTags?: string[]; + maxAge?: number; } = { formats, }; @@ -96,6 +97,10 @@ export async function executeScrape( scrapeParams.excludeTags = options.excludeTags; } + if (options.maxAge !== undefined) { + scrapeParams.maxAge = options.maxAge; + } + // Execute scrape with timing - only wrap the scrape call in try-catch const requestStartTime = Date.now(); diff --git a/src/index.ts b/src/index.ts index b427ecda1f..35d6e1ac81 100644 --- a/src/index.ts +++ b/src/index.ts @@ -120,6 +120,11 @@ function createScrapeCommand(): Command { 'Show request timing and other useful information', false ) + .option( + '--max-age ', + 'Maximum age of cached content in seconds (API-level caching)', + parseInt + ) .action(async (positionalUrl, positionalFormats, options) => { // Use positional URL if provided, otherwise use --url option const url = positionalUrl || options.url; diff --git a/src/types/scrape.ts b/src/types/scrape.ts index aaff2e1f9d..b958ea82e5 100644 --- a/src/types/scrape.ts +++ b/src/types/scrape.ts @@ -42,6 +42,8 @@ export interface ScrapeOptions { json?: boolean; /** Show request timing and other useful information */ timing?: boolean; + /** Maximum age of cached content in seconds (API-level caching) */ + maxAge?: number; } export interface ScrapeResult { diff --git a/src/utils/options.ts b/src/utils/options.ts index e4bc869679..efed091e27 100644 --- a/src/utils/options.ts +++ b/src/utils/options.ts @@ -90,5 +90,6 @@ export function parseScrapeOptions(options: any): ScrapeOptions { pretty: options.pretty, json: options.json, timing: options.timing, + maxAge: options.maxAge, }; } From f0857630b7857889abda37bf0b100f78e6367bcf Mon Sep 17 00:00:00 2001 From: Abimael Martell Date: Fri, 6 Feb 2026 23:06:08 -0800 Subject: [PATCH 2/4] update comment --- src/types/scrape.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/types/scrape.ts b/src/types/scrape.ts index b958ea82e5..76411541fb 100644 --- a/src/types/scrape.ts +++ b/src/types/scrape.ts @@ -42,7 +42,7 @@ export interface ScrapeOptions { json?: boolean; /** Show request timing and other useful information */ timing?: boolean; - /** Maximum age of cached content in seconds (API-level caching) */ + /** Maximum age of cached content in milliseconds (API-level caching) */ maxAge?: number; } From 5f69d41217c5bb02e00df386e1d4cfd758f0b5a9 Mon Sep 17 00:00:00 2001 From: Abimael Martell Date: Fri, 6 Feb 2026 23:08:09 -0800 Subject: [PATCH 3/4] update doc --- src/index.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/index.ts b/src/index.ts index 35d6e1ac81..54e1c2abd9 100644 --- a/src/index.ts +++ b/src/index.ts @@ -121,8 +121,8 @@ function createScrapeCommand(): Command { false ) .option( - '--max-age ', - 'Maximum age of cached content in seconds (API-level caching)', + '--max-age ', + 'Maximum age of cached content in milliseconds (API-level caching)', parseInt ) .action(async (positionalUrl, positionalFormats, options) => { From 2662487fb5c1879cfb6d644e45ded528c43bb1b2 Mon Sep 17 00:00:00 2001 From: Abimael Martell Date: Fri, 6 Feb 2026 23:08:25 -0800 Subject: [PATCH 4/4] update doc --- src/index.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/index.ts b/src/index.ts index 54e1c2abd9..f3a571c45f 100644 --- a/src/index.ts +++ b/src/index.ts @@ -122,7 +122,7 @@ function createScrapeCommand(): Command { ) .option( '--max-age ', - 'Maximum age of cached content in milliseconds (API-level caching)', + 'Maximum age of cached content in milliseconds', parseInt ) .action(async (positionalUrl, positionalFormats, options) => {