# exa-search-cli

> A command-line integration with Exa for repeatable research: web search, readable page-text retrieval, and external research tasks with structured output.

## Contribution and scope

Built with AI coding agents as part of Nolan Vale's independent product and workflow-automation work. Nolan defines requirements, directs implementation, checks results, and iterates. Exa provides the underlying search and research services; this repository supplies a CLI integration, not a new search engine or AI model.

## Install

```bash
uv tool install exa-search-cli
```

Alternatively, use pip install exa-search-cli in a suitable Python environment.

Set EXA_API_KEY to an authorized Exa API key. Do not commit or expose the key.

## Commands

- `exa-search <query>`: search. Flags: --json, --compact, --num-results, --type, --category, --start-date, --end-date, --include-domain, --exclude-domain, --similar, --text, --max-chars, --objective, --max-age-hours.
- `exa-crawl <url>`: request readable page text or focused excerpts. Flags: --json, --compact, --max-chars, --query, --max-age-hours.
- `exa-agent QUERY`: create a usage-billed Agent run. Flags: --effort, --max-cost, --system-prompt, --output-schema, --dry-run, --json.
- `exa-agent-status RUN_ID`: get one Agent run; --json preserves output, grounding, costDollars and stopReason.
- `exa-agent-cancel RUN_ID`: cancel a queued/running Agent run; --json supported.
- `exa-research` / `exa-research-status`: retired API migration helpers; fail locally with exit 1, never create a replacement run.

Source access, categories, models, and result availability depend on the provider.

## Workflow examples

```bash
exa-search "document review workflow" --json
exa-crawl https://example.com -c 8000
exa-agent "document processing approaches" --max-cost 1 --dry-run
exa-agent-status agent_run_REPLACE_WITH_RETURNED_ID --json
```

## Output reference

- Search: results[]{title, url, published_date, author, highlights[], text}.
- Crawl: results[]{url, title, text}.
- Agent: {id, status, output:{text, structured, grounding}, stopReason, costDollars, error}.
- Result iterator for object or array responses: (if type=="array" then . else (.results // []) end)[].

Consult README.md and docs/USAGE.md for examples and installed-command help for supported options.

## Data and review

Requests are sent to Exa. `exa-agent` creates an external task unless `--dry-run` is set; status reads a run and cancel updates it. The integration is not entirely read-only or offline. Protect credentials and review generated research against source material before using it in decisions.

## Key files

- README.md: purpose, contribution, setup, and limitations.
- AGENTS.md: contributor instructions.
- docs/USAGE.md: usage reference.
- pyproject.toml: dependencies and entry points.

## Links

- Repository: https://github.com/nolan-vale/exa-search-cli
- Product-builder portfolio: https://github.com/nolan-vale
- PyPI: https://pypi.org/project/exa-search-cli/
- Provider documentation: https://docs.exa.ai

## Research workflow (0.1.6)

- `--category publication`: scholarly sources; paper/research paper map to publication.
- Current types include auto, lite, fast, instant, deep-lite, deep, deep-reasoning; legacy keyword/neural remain accepted.
- `exa-search QUERY --text --max-chars 8000 --json`: bounded text per result; text and highlights are not requested together.
- `exa-crawl URL1 URL2 -c 12000 --json`: batch up to 100 URLs in one request; terminal output honors -c.
- All commands: --timeout SECONDS (default 60), --version. No automatic retries.
- Invalid arguments exit 2 before network calls; API failures exit nonzero with stderr diagnostics and redacted keys.
- Crawl JSON preserves per-URL statuses; partial failures warn on stderr, all failures exit 1.
- Search is discovery, not bibliographic verification; confirm metadata at the primary source. Crawl extracts text, not original PDF files.

## Focused retrieval

- `exa-search QUERY --objective "Prefer original pricing pages, not directories" --compact`: supplies the broader research goal. Objective is 1–4096 characters, not blank, and incompatible with --similar. Preferences do not replace hard filters or source validation.
- `exa-crawl URL --query "specific question" -c 2500 --compact`: extracts relevant passages from across a long page, with full text explicitly disabled. Do not assume excerpts contain all qualifications.
- Search and crawl support `--max-age-hours`: omitted = API defaults; -1 = cache only; 0 = fresh fetch; 1–720 = maximum cache age. This controls content age, not publication date. Search type lite does not support the flag.
- Search and crawl support `--compact`: implies JSON; one line; removes empty/decorative fields and duplicate URL IDs, while retaining evidence, substantive extended fields, costs, warnings and statuses. Ordinary --json remains unchanged.
- Bounded full text reaching its cap warns on stderr that content may be incomplete. No automatic paid refetch or implicit state is added.

## Agent migration (0.1.7)

- `/research` is retired. Old model names and Research IDs are not automatically translated to Agent runs.
- `exa-agent` calls the current Agent API once and returns immediately. No implicit polling, retries, continuation, or data-source add-ons.
- `--dry-run` prints a POST /agent/runs request without authentication, secrets, or network access.
- Efforts: minimal, low, medium, high, xhigh, auto (default), ultra. --max-cost accepts finite $1–$100 for auto/ultra. Omitted = provider default ($5 auto, $20 ultra at verification).
- Schema files must contain a JSON object. The API validates JSON Schema semantics. Status and cancellation use Agent run IDs and never create a new run.
- A completed run may stop at budget_reached and contain partial results. Preserve stopReason, citations and costs. Failed run status exits 1 with valid JSON.
- Validation: live search/crawl; live read-only Agent API access; mocked SDK create/get/cancel contracts. Paid Agent execution and completion were not tested. --version checks only the local package.
