diff --git a/skills/firecrawl-scrape/SKILL.md b/.agents/skills/firecrawl-scrape/SKILL.md similarity index 93% rename from skills/firecrawl-scrape/SKILL.md rename to .agents/skills/firecrawl-scrape/SKILL.md index a090f48..4a33683 100644 --- a/skills/firecrawl-scrape/SKILL.md +++ b/.agents/skills/firecrawl-scrape/SKILL.md @@ -34,6 +34,9 @@ firecrawl scrape https://example.com https://example.com/blog https://example.co # Get markdown and links together firecrawl scrape "" --format markdown,links -o .firecrawl/page.json + +# Ask a question about the page +firecrawl scrape "https://example.com/pricing" --query "What is the enterprise plan price?" ``` ## Options @@ -41,6 +44,7 @@ firecrawl scrape "" --format markdown,links -o .firecrawl/page.json | Option | Description | | ------------------------ | ---------------------------------------------------------------- | | `-f, --format ` | Output formats: markdown, html, rawHtml, links, screenshot, json | +| `-Q, --query ` | Ask a question about the page content (5 credits) | | `-H` | Include HTTP headers in output | | `--only-main-content` | Strip nav, footer, sidebar — main content only | | `--wait-for ` | Wait for JS rendering before scraping | diff --git a/package.json b/package.json index 0d803b9..ae708d7 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "firecrawl-cli", - "version": "1.9.8", + "version": "1.10.0", "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/skills/firecrawl-agent/SKILL.md b/skills/firecrawl-agent/SKILL.md deleted file mode 100644 index 0b3577f..0000000 --- a/skills/firecrawl-agent/SKILL.md +++ /dev/null @@ -1,57 +0,0 @@ ---- -name: firecrawl-agent -description: | - AI-powered autonomous data extraction that navigates complex sites and returns structured JSON. Use this skill when the user wants structured data from websites, needs to extract pricing tiers, product listings, directory entries, or any data as JSON with a schema. Triggers on "extract structured data", "get all the products", "pull pricing info", "extract as JSON", or when the user provides a JSON schema for website data. More powerful than simple scraping for multi-page structured extraction. -allowed-tools: - - Bash(firecrawl *) - - Bash(npx firecrawl *) ---- - -# firecrawl agent - -AI-powered autonomous extraction. The agent navigates sites and extracts structured data (takes 2-5 minutes). - -## When to use - -- You need structured data from complex multi-page sites -- Manual scraping would require navigating many pages -- You want the AI to figure out where the data lives - -## Quick start - -```bash -# Extract structured data -firecrawl agent "extract all pricing tiers" --wait -o .firecrawl/pricing.json - -# With a JSON schema for structured output -firecrawl agent "extract products" --schema '{"type":"object","properties":{"name":{"type":"string"},"price":{"type":"number"}}}' --wait -o .firecrawl/products.json - -# Focus on specific pages -firecrawl agent "get feature list" --urls "" --wait -o .firecrawl/features.json -``` - -## Options - -| Option | Description | -| ---------------------- | ----------------------------------------- | -| `--urls ` | Starting URLs for the agent | -| `--model ` | Model to use: spark-1-mini or spark-1-pro | -| `--schema ` | JSON schema for structured output | -| `--schema-file ` | Path to JSON schema file | -| `--max-credits ` | Credit limit for this agent run | -| `--wait` | Wait for agent to complete | -| `--pretty` | Pretty print JSON output | -| `-o, --output ` | Output file path | - -## Tips - -- Always use `--wait` to get results inline. Without it, returns a job ID. -- Use `--schema` for predictable, structured output — otherwise the agent returns freeform data. -- Agent runs consume more credits than simple scrapes. Use `--max-credits` to cap spending. -- For simple single-page extraction, prefer `scrape` — it's faster and cheaper. - -## See also - -- [firecrawl-scrape](../firecrawl-scrape/SKILL.md) — simpler single-page extraction -- [firecrawl-browser](../firecrawl-browser/SKILL.md) — manual browser automation (more control) -- [firecrawl-crawl](../firecrawl-crawl/SKILL.md) — bulk extraction without AI diff --git a/skills/firecrawl-browser/SKILL.md b/skills/firecrawl-browser/SKILL.md deleted file mode 100644 index ed0f0ae..0000000 --- a/skills/firecrawl-browser/SKILL.md +++ /dev/null @@ -1,107 +0,0 @@ ---- -name: firecrawl-browser -description: | - Cloud browser automation for pages requiring interaction — clicks, form fills, login, pagination, infinite scroll. Use this skill when the user needs to interact with a webpage, log into a site, click buttons, fill forms, navigate multi-step flows, handle pagination, or when regular scraping fails because content requires JavaScript interaction. Triggers on "click", "fill out the form", "log in to", "paginated", "infinite scroll", "interact with the page", or "scrape failed". Provides remote Chromium sessions with persistent profiles. -allowed-tools: - - Bash(firecrawl *) - - Bash(npx firecrawl *) ---- - -# firecrawl browser - -Cloud Chromium sessions in Firecrawl's remote sandboxed environment. Interact with pages that require clicks, form fills, pagination, or login. - -## When to use - -- Content requires interaction: clicks, form fills, pagination, login -- `scrape` failed because content is behind JavaScript interaction -- You need to navigate a multi-step flow -- Last resort in the [workflow escalation pattern](firecrawl-cli): search → scrape → map → crawl → **browser** -- **Never use browser for web searches** — use `search` instead - -## Quick start - -```bash -# Typical browser workflow -firecrawl browser "open " -firecrawl browser "snapshot -i" # see interactive elements with @ref IDs -firecrawl browser "click @e5" # interact with elements -firecrawl browser "fill @e3 'search query'" # fill form fields -firecrawl browser "scrape" -o .firecrawl/page.md # extract content -firecrawl browser close -``` - -Shorthand auto-launches a session if none exists — no setup required. - -## Commands - -| Command | Description | -| -------------------- | ---------------------------------------- | -| `open ` | Navigate to a URL | -| `snapshot -i` | Get interactive elements with `@ref` IDs | -| `screenshot` | Capture a PNG screenshot | -| `click <@ref>` | Click an element by ref | -| `type <@ref> ` | Type into an element | -| `fill <@ref> ` | Fill a form field (clears first) | -| `scrape` | Extract page content as markdown | -| `scroll ` | Scroll up/down/left/right | -| `wait ` | Wait for a duration | -| `eval ` | Evaluate JavaScript on the page | - -Session management: `launch-session --ttl 600`, `list`, `close` - -## Options - -| Option | Description | -| ---------------------------- | -------------------------------------------------- | -| `--ttl ` | Session time-to-live | -| `--ttl-inactivity ` | Inactivity timeout | -| `--session ` | Use a specific session ID | -| `--profile ` | Use a named profile (persists state) | -| `--no-save-changes` | Read-only reconnect (don't write to session state) | -| `-o, --output ` | Output file path | - -## Profiles - -Profiles survive close and can be reconnected by name. Use them for login-then-work flows: - -```bash -# Session 1: Login and save state -firecrawl browser launch-session --profile my-app -firecrawl browser "open https://app.example.com/login" -firecrawl browser "snapshot -i" -firecrawl browser "fill @e3 'user@example.com'" -firecrawl browser "click @e7" -firecrawl browser "wait 2" -firecrawl browser close - -# Session 2: Come back authenticated -firecrawl browser launch-session --profile my-app -firecrawl browser "open https://app.example.com/dashboard" -firecrawl browser "scrape" -o .firecrawl/dashboard.md -firecrawl browser close -``` - -Read-only reconnect (no writes to session state): - -```bash -firecrawl browser launch-session --profile my-app --no-save-changes -``` - -Shorthand with profile: - -```bash -firecrawl browser --profile my-app "open https://example.com" -``` - -## Tips - -- If you get forbidden errors, the session may have expired — create a new one. -- For parallel browser work, launch separate sessions and operate them via `--session `. -- Always `close` sessions when done to free resources. - -## See also - -- [firecrawl-scrape](../firecrawl-scrape/SKILL.md) — try scrape first, escalate to browser only when needed -- [firecrawl-search](../firecrawl-search/SKILL.md) — for web searches (never use browser for searching) -- [firecrawl-agent](../firecrawl-agent/SKILL.md) — AI-powered extraction (less manual control) diff --git a/skills/firecrawl-crawl/SKILL.md b/skills/firecrawl-crawl/SKILL.md deleted file mode 100644 index fb2f3bd..0000000 --- a/skills/firecrawl-crawl/SKILL.md +++ /dev/null @@ -1,58 +0,0 @@ ---- -name: firecrawl-crawl -description: | - Bulk extract content from an entire website or site section. Use this skill when the user wants to crawl a site, extract all pages from a docs section, bulk-scrape multiple pages following links, or says "crawl", "get all the pages", "extract everything under /docs", "bulk extract", or needs content from many pages on the same site. Handles depth limits, path filtering, and concurrent extraction. -allowed-tools: - - Bash(firecrawl *) - - Bash(npx firecrawl *) ---- - -# firecrawl crawl - -Bulk extract content from a website. Crawls pages following links up to a depth/limit. - -## When to use - -- You need content from many pages on a site (e.g., all `/docs/`) -- You want to extract an entire site section -- Step 4 in the [workflow escalation pattern](firecrawl-cli): search → scrape → map → **crawl** → browser - -## Quick start - -```bash -# Crawl a docs section -firecrawl crawl "" --include-paths /docs --limit 50 --wait -o .firecrawl/crawl.json - -# Full crawl with depth limit -firecrawl crawl "" --max-depth 3 --wait --progress -o .firecrawl/crawl.json - -# Check status of a running crawl -firecrawl crawl -``` - -## Options - -| Option | Description | -| ------------------------- | ------------------------------------------- | -| `--wait` | Wait for crawl to complete before returning | -| `--progress` | Show progress while waiting | -| `--limit ` | Max pages to crawl | -| `--max-depth ` | Max link depth to follow | -| `--include-paths ` | Only crawl URLs matching these paths | -| `--exclude-paths ` | Skip URLs matching these paths | -| `--delay ` | Delay between requests | -| `--max-concurrency ` | Max parallel crawl workers | -| `--pretty` | Pretty print JSON output | -| `-o, --output ` | Output file path | - -## Tips - -- Always use `--wait` when you need the results immediately. Without it, crawl returns a job ID for async polling. -- Use `--include-paths` to scope the crawl — don't crawl an entire site when you only need one section. -- Crawl consumes credits per page. Check `firecrawl credit-usage` before large crawls. - -## See also - -- [firecrawl-scrape](../firecrawl-scrape/SKILL.md) — scrape individual pages -- [firecrawl-map](../firecrawl-map/SKILL.md) — discover URLs before deciding to crawl -- [firecrawl-download](../firecrawl-download/SKILL.md) — download site to local files (uses map + scrape) diff --git a/skills/firecrawl-download/SKILL.md b/skills/firecrawl-download/SKILL.md deleted file mode 100644 index d2beeb7..0000000 --- a/skills/firecrawl-download/SKILL.md +++ /dev/null @@ -1,69 +0,0 @@ ---- -name: firecrawl-download -description: | - Download an entire website as local files — markdown, screenshots, or multiple formats per page. Use this skill when the user wants to save a site locally, download documentation for offline use, bulk-save pages as files, or says "download the site", "save as local files", "offline copy", "download all the docs", or "save for reference". Combines site mapping and scraping into organized local directories. -allowed-tools: - - Bash(firecrawl *) - - Bash(npx firecrawl *) ---- - -# firecrawl download - -> **Experimental.** Convenience command that combines `map` + `scrape` to save an entire site as local files. - -Maps the site first to discover pages, then scrapes each one into nested directories under `.firecrawl/`. All scrape options work with download. Always pass `-y` to skip the confirmation prompt. - -## When to use - -- You want to save an entire site (or section) to local files -- You need offline access to documentation or content -- Bulk content extraction with organized file structure - -## Quick start - -```bash -# Interactive wizard (picks format, screenshots, paths for you) -firecrawl download https://docs.example.com - -# With screenshots -firecrawl download https://docs.example.com --screenshot --limit 20 -y - -# Multiple formats (each saved as its own file per page) -firecrawl download https://docs.example.com --format markdown,links --screenshot --limit 20 -y -# Creates per page: index.md + links.txt + screenshot.png - -# Filter to specific sections -firecrawl download https://docs.example.com --include-paths "/features,/sdks" - -# Skip translations -firecrawl download https://docs.example.com --exclude-paths "/zh,/ja,/fr,/es,/pt-BR" - -# Full combo -firecrawl download https://docs.example.com \ - --include-paths "/features,/sdks" \ - --exclude-paths "/zh,/ja" \ - --only-main-content \ - --screenshot \ - -y -``` - -## Download options - -| Option | Description | -| ------------------------- | -------------------------------------------------------- | -| `--limit ` | Max pages to download | -| `--search ` | Filter URLs by search query | -| `--include-paths ` | Only download matching paths | -| `--exclude-paths ` | Skip matching paths | -| `--allow-subdomains` | Include subdomain pages | -| `-y` | Skip confirmation prompt (always use in automated flows) | - -## Scrape options (all work with download) - -`-f `, `-H`, `-S`, `--screenshot`, `--full-page-screenshot`, `--only-main-content`, `--include-tags`, `--exclude-tags`, `--wait-for`, `--max-age`, `--country`, `--languages` - -## See also - -- [firecrawl-map](../firecrawl-map/SKILL.md) — just discover URLs without downloading -- [firecrawl-scrape](../firecrawl-scrape/SKILL.md) — scrape individual pages -- [firecrawl-crawl](../firecrawl-crawl/SKILL.md) — bulk extract as JSON (not local files) diff --git a/skills/firecrawl-map/SKILL.md b/skills/firecrawl-map/SKILL.md deleted file mode 100644 index f8047fc..0000000 --- a/skills/firecrawl-map/SKILL.md +++ /dev/null @@ -1,50 +0,0 @@ ---- -name: firecrawl-map -description: | - Discover and list all URLs on a website, with optional search filtering. Use this skill when the user wants to find a specific page on a large site, list all URLs, see the site structure, find where something is on a domain, or says "map the site", "find the URL for", "what pages are on", or "list all pages". Essential when the user knows which site but not which exact page. -allowed-tools: - - Bash(firecrawl *) - - Bash(npx firecrawl *) ---- - -# firecrawl map - -Discover URLs on a site. Use `--search` to find a specific page within a large site. - -## When to use - -- You need to find a specific subpage on a large site -- You want a list of all URLs on a site before scraping or crawling -- Step 3 in the [workflow escalation pattern](firecrawl-cli): search → scrape → **map** → crawl → browser - -## Quick start - -```bash -# Find a specific page on a large site -firecrawl map "" --search "authentication" -o .firecrawl/filtered.txt - -# Get all URLs -firecrawl map "" --limit 500 --json -o .firecrawl/urls.json -``` - -## Options - -| Option | Description | -| --------------------------------- | ---------------------------- | -| `--limit ` | Max number of URLs to return | -| `--search ` | Filter URLs by search query | -| `--sitemap ` | Sitemap handling strategy | -| `--include-subdomains` | Include subdomain URLs | -| `--json` | Output as JSON | -| `-o, --output ` | Output file path | - -## Tips - -- **Map + scrape is a common pattern**: use `map --search` to find the right URL, then `scrape` it. -- Example: `map https://docs.example.com --search "auth"` → found `/docs/api/authentication` → `scrape` that URL. - -## See also - -- [firecrawl-scrape](../firecrawl-scrape/SKILL.md) — scrape the URLs you discover -- [firecrawl-crawl](../firecrawl-crawl/SKILL.md) — bulk extract instead of map + scrape -- [firecrawl-download](../firecrawl-download/SKILL.md) — download entire site (uses map internally) diff --git a/skills/firecrawl-search/SKILL.md b/skills/firecrawl-search/SKILL.md deleted file mode 100644 index aec4232..0000000 --- a/skills/firecrawl-search/SKILL.md +++ /dev/null @@ -1,59 +0,0 @@ ---- -name: firecrawl-search -description: | - Web search with full page content extraction. Use this skill whenever the user asks to search the web, find articles, research a topic, look something up, find recent news, discover sources, or says "search for", "find me", "look up", "what are people saying about", or "find articles about". Returns real search results with optional full-page markdown — not just snippets. Provides capabilities beyond Claude's built-in WebSearch. -allowed-tools: - - Bash(firecrawl *) - - Bash(npx firecrawl *) ---- - -# firecrawl search - -Web search with optional content scraping. Returns search results as JSON, optionally with full page content. - -## When to use - -- You don't have a specific URL yet -- You need to find pages, answer questions, or discover sources -- First step in the [workflow escalation pattern](firecrawl-cli): search → scrape → map → crawl → browser - -## Quick start - -```bash -# Basic search -firecrawl search "your query" -o .firecrawl/result.json --json - -# Search and scrape full page content from results -firecrawl search "your query" --scrape -o .firecrawl/scraped.json --json - -# News from the past day -firecrawl search "your query" --sources news --tbs qdr:d -o .firecrawl/news.json --json -``` - -## Options - -| Option | Description | -| ------------------------------------ | --------------------------------------------- | -| `--limit ` | Max number of results | -| `--sources ` | Source types to search | -| `--categories ` | Filter by category | -| `--tbs ` | Time-based search filter | -| `--location` | Location for search results | -| `--country ` | Country code for search | -| `--scrape` | Also scrape full page content for each result | -| `--scrape-formats` | Formats when scraping (default: markdown) | -| `-o, --output ` | Output file path | -| `--json` | Output as JSON | - -## Tips - -- **`--scrape` fetches full content** — don't re-scrape URLs from search results. This saves credits and avoids redundant fetches. -- Always write results to `.firecrawl/` with `-o` to avoid context window bloat. -- Use `jq` to extract URLs or titles: `jq -r '.data.web[].url' .firecrawl/search.json` -- Naming convention: `.firecrawl/search-{query}.json` or `.firecrawl/search-{query}-scraped.json` - -## See also - -- [firecrawl-scrape](../firecrawl-scrape/SKILL.md) — scrape a specific URL -- [firecrawl-map](../firecrawl-map/SKILL.md) — discover URLs within a site -- [firecrawl-crawl](../firecrawl-crawl/SKILL.md) — bulk extract from a site diff --git a/src/commands/scrape.ts b/src/commands/scrape.ts index 96b652b..7f68b5e 100644 --- a/src/commands/scrape.ts +++ b/src/commands/scrape.ts @@ -10,7 +10,7 @@ import type { ScrapeLocation, } from '../types/scrape'; import { getClient } from '../utils/client'; -import { handleScrapeOutput } from '../utils/output'; +import { handleScrapeOutput, writeOutput } from '../utils/output'; import { getOrigin } from '../utils/url'; import { executeMap } from './map'; import { getStatus } from './status'; @@ -71,6 +71,11 @@ export async function executeScrape( formats.push('screenshot'); } + // Inject query format if --query was provided + if (options.query) { + formats.push({ type: 'query', prompt: options.query } as any); + } + // If no formats specified, default to markdown if (formats.length === 0) { formats.push('markdown'); @@ -136,6 +141,12 @@ export async function handleScrapeCommand( ): Promise { const result = await executeScrape(options); + // Query mode: output answer directly + if (options.query && result.success && result.data?.answer) { + writeOutput(result.data.answer, options.output, !!options.output); + return; + } + // Determine effective formats for output handling const effectiveFormats: ScrapeFormat[] = options.formats && options.formats.length > 0 diff --git a/src/index.ts b/src/index.ts index 2ceb242..072aa29 100644 --- a/src/index.ts +++ b/src/index.ts @@ -158,6 +158,10 @@ function createScrapeCommand(): Command { '--languages ', 'Comma-separated language codes for scraping (e.g., en,es)' ) + .option( + '-Q, --query ', + 'Ask a question about the page content (query format)' + ) .action(async (positionalArgs, options) => { // Collect URLs from positional args and --url option diff --git a/src/types/scrape.ts b/src/types/scrape.ts index eaa553d..345b797 100644 --- a/src/types/scrape.ts +++ b/src/types/scrape.ts @@ -55,6 +55,8 @@ export interface ScrapeOptions { maxAge?: number; /** Location settings for geo-targeted scraping */ location?: ScrapeLocation; + /** Question to ask about the page content (query format) */ + query?: string; } export interface ScrapeResult { diff --git a/src/utils/options.ts b/src/utils/options.ts index 290c665..52a3a95 100644 --- a/src/utils/options.ts +++ b/src/utils/options.ts @@ -111,5 +111,6 @@ export function parseScrapeOptions(options: any): ScrapeOptions { timing: options.timing, maxAge: options.maxAge, location, + query: options.query, }; }