diff --git a/README.md b/README.md index 8699392..991172c 100644 --- a/README.md +++ b/README.md @@ -65,13 +65,14 @@ linkup search "query" --include-domains linkup.so --from-date 2025-01-01 Extract the content of a URL as markdown. +- Select `--mode standard` (default) or `--mode pro` for harder-to-retrieve pages. - Use `--render-js` for JS-heavy pages. - Add `--include-raw-content` to include the source page content. - The deprecated `--include-raw-html` flag remains available for compatibility. - Add `--extract-images` to include image metadata. ```bash -linkup fetch https://example.com --render-js +linkup fetch https://example.com --mode pro --render-js ``` ### Asynchronous commands diff --git a/package-lock.json b/package-lock.json index 39b2c58..18a0307 100644 --- a/package-lock.json +++ b/package-lock.json @@ -11,7 +11,7 @@ "dependencies": { "@inquirer/prompts": "^8.5.2", "commander": "^13.1.0", - "linkup-sdk": "^3.4.0", + "linkup-sdk": "^3.5.0", "open": "^11.0.0" }, "bin": { @@ -5289,9 +5289,9 @@ "license": "MIT" }, "node_modules/linkup-sdk": { - "version": "3.4.0", - "resolved": "https://registry.npmjs.org/linkup-sdk/-/linkup-sdk-3.4.0.tgz", - "integrity": "sha512-Q6QZc/bUwliF6CeZysanD9txsLKxVGASEifts9hlwDNyUY5EPOoz+5VmDuj06uHC1fRKEI2/M/VsFrpCmK1xmA==", + "version": "3.5.0", + "resolved": "https://registry.npmjs.org/linkup-sdk/-/linkup-sdk-3.5.0.tgz", + "integrity": "sha512-gus++YKoqb8VbEYnq5yrDJCYxTpCn5UDsWYuvLK+kfl1HKZv6dOhfl6La/pUD8KAZikqTQiXJQ4JO9EUIc1yyA==", "license": "MIT", "dependencies": { "@x402/core": "^2.6.0", diff --git a/package.json b/package.json index 55c3ccb..7601ca3 100644 --- a/package.json +++ b/package.json @@ -45,7 +45,7 @@ "dependencies": { "@inquirer/prompts": "^8.5.2", "commander": "^13.1.0", - "linkup-sdk": "^3.4.0", + "linkup-sdk": "^3.5.0", "open": "^11.0.0" }, "devDependencies": { diff --git a/src/__tests__/fetch.integration.test.ts b/src/__tests__/fetch.integration.test.ts index 68d3113..41a1389 100644 --- a/src/__tests__/fetch.integration.test.ts +++ b/src/__tests__/fetch.integration.test.ts @@ -18,6 +18,8 @@ describe('fetch command integration', () => { 'linkup', 'fetch', 'https://example.com', + '--mode', + 'pro', '--render-js', '--include-raw-content', '--extract-images', @@ -26,6 +28,7 @@ describe('fetch command integration', () => { expect(fakeClient.fetch).toHaveBeenCalledWith({ extractImages: true, includeRawContent: true, + mode: 'pro', renderJs: true, url: 'https://example.com', }); diff --git a/src/__tests__/fetch.test.ts b/src/__tests__/fetch.test.ts index d78e8f0..df6ece5 100644 --- a/src/__tests__/fetch.test.ts +++ b/src/__tests__/fetch.test.ts @@ -13,12 +13,14 @@ describe('buildFetchParams', () => { extractImages: true, includeRawContent: true, includeRawHtml: true, + mode: 'pro', renderJs: true, }), ).toEqual({ extractImages: true, includeRawContent: true, includeRawHtml: true, + mode: 'pro', renderJs: true, url: 'https://example.com', }); diff --git a/src/commands/fetch.ts b/src/commands/fetch.ts index d4521e2..cd3e260 100644 --- a/src/commands/fetch.ts +++ b/src/commands/fetch.ts @@ -1,5 +1,5 @@ -import { type Command, InvalidArgumentError } from 'commander'; -import type { FetchParams, TaskRequest } from 'linkup-sdk'; +import { type Command, InvalidArgumentError, Option } from 'commander'; +import type { FetchMode, FetchParams, TaskRequest } from 'linkup-sdk'; import { resolveGlobals } from '../client.js'; import { exitWithError, formatErrorLine } from '../output/errors.js'; import { formatFetch } from '../output/fetch.js'; @@ -7,6 +7,7 @@ import { formatTaskErrorLine } from '../output/task-errors.js'; import { createPollIntervalOption, createTimeoutOption, runTaskFlow } from './async-task.js'; type FetchCommandOptions = { + mode?: FetchMode; renderJs?: boolean; includeRawContent?: boolean; includeRawHtml?: boolean; @@ -29,6 +30,7 @@ function parseFetchUrl(value: string): string { export function buildFetchParams(url: string, options: FetchCommandOptions): FetchParams { return { url, + ...(options.mode && { mode: options.mode }), ...(options.renderJs && { renderJs: true }), ...(options.includeRawContent && { includeRawContent: true }), ...(options.includeRawHtml && { includeRawHtml: true }), @@ -67,11 +69,15 @@ async function runFetch( } export function registerFetchCommand(program: Command): void { + const modeChoices: FetchMode[] = ['standard', 'pro']; + const modeOption = new Option('--mode ', 'Fetch mode').choices(modeChoices); + program .command('fetch') .alias('f') .description('Fetch and extract content from a URL') .argument('', 'URL to fetch', parseFetchUrl) + .addOption(modeOption) .option('--render-js', 'Execute JavaScript before extracting content') .option('--include-raw-content', 'Include the raw page content in the response output') .option('--include-raw-html', 'Include legacy raw HTML in the response output') @@ -85,6 +91,7 @@ export function registerFetchCommand(program: Command): void { ` Examples: linkup fetch https://example.com + linkup fetch https://example.com --mode pro linkup fetch https://example.com --render-js linkup fetch https://example.com --include-raw-content --json linkup fetch https://example.com --async --wait