Skip to content

"CLI-Anything: Making ALL Software Agent-Native" -- CLI-Hub: https://clianything.cc/

Python

refactor: remove deprecated answer, similar, and session endpoints

Devin AIb0e360262b0b
diff --git a/exa/agent-harness/EXA.md b/exa/agent-harness/EXA.md
index d6e44dd1c..d6b623e41 100644
--- a/exa/agent-harness/EXA.md
+++ b/exa/agent-harness/EXA.md
@@ -3,9 +3,9 @@
## Overview
`cli-anything-exa` is a CLI harness for the [Exa API](https://exa.ai), an AI-native search
-engine built on neural embeddings rather than keyword matching. This harness makes all
+engine built on neural embeddings rather than keyword matching. This harness makes
core Exa capabilities available to any AI coding agent (Claude Code, Codex, OpenCode, etc.)
-via a structured, stateful command-line interface.
+via a structured command-line interface.
## Backend
@@ -17,27 +17,16 @@ Authentication uses `EXA_API_KEY` from the environment — no server process is
```
cli-anything-exa [--json]
├── search <query> Neural/keyword/deep web search
-├── similar <url> Find pages related to a URL
├── contents <url> [url …] Fetch full-text or highlighted page content
-├── answer <query> LLM-synthesised answer with citations
-├── server status Verify API key and connectivity
-└── session
- ├── status Session summary
- └── history Per-query history (most recent first)
+└── server status Verify API key and connectivity
```
-## State Model
-
-Session state (search history) is held in memory in `core/session.py`. It is scoped to
-the process lifetime and is intended for REPL use — agents in non-interactive mode
-receive stateless JSON responses on each invocation.
-
## Output Strategy
All commands emit human-readable output by default and structured JSON when `--json` is
passed at the root level. JSON output is the recommended mode for agent pipelines.
-JSON result shape for search/similar/contents:
+JSON result shape for search/contents:
```json
{
"results": [
@@ -55,24 +44,12 @@ JSON result shape for search/similar/contents:
}
```
-JSON result shape for answer:
-```json
-{
- "answer": "...",
- "citations": [{"title": "...", "url": "..."}],
- "cost_dollars": {"total": 0.003}
-}
-```
-
## Design Decisions
**`highlights` as default content mode** — Exa highlights are 10× more token-efficient
than full text and are sufficient for most agent retrieval tasks. Full text is available
via `--content text` when needed.
-**No streaming in v1** — The `answer` endpoint supports SSE streaming but CLI streaming
-complicates JSON parsing for agents. Deferred to a future iteration.
-
**Research commands deferred** — Exa's async deep researcher (`/research/v1`) has a
start→poll→get lifecycle that warrants a separate v2 PR with proper state persistence.
@@ -92,9 +69,7 @@ exa/agent-harness/
├── exa_cli.py Entry point, Click command tree, REPL
├── README.md Setup and usage guide
├── core/
- │ ├── search.py web_search(), find_similar(), get_contents()
- │ ├── answer.py get_answer()
- │ └── session.py In-session history and status
+ │ └── search.py web_search(), get_contents()
├── utils/
│ ├── exa_backend.py SDK client init, contents/category helpers
│ └── repl_skin.py Shared REPL terminal UI
diff --git a/exa/agent-harness/cli_anything/exa/README.md b/exa/agent-harness/cli_anything/exa/README.md
index 41763cbbf..ccec10b6b 100644
--- a/exa/agent-harness/cli_anything/exa/README.md
+++ b/exa/agent-harness/cli_anything/exa/README.md
@@ -1,6 +1,6 @@
# cli-anything-exa
-Agent-native CLI harness for [Exa](https://exa.ai) — AI-powered web search, similar-page discovery, full-text content extraction, and LLM-synthesised answers.
+Agent-native CLI harness for [Exa](https://exa.ai) — AI-powered web search and full-text content extraction.
## HOW TO RUN
@@ -46,21 +46,11 @@ Expected output:
cli-anything-exa search "large language models 2024" --type deep --content highlights
```
-**Find similar pages:**
-```bash
-cli-anything-exa similar https://arxiv.org/abs/2303.08774 --num-results 5
-```
-
**Fetch page contents:**
```bash
cli-anything-exa contents https://exa.ai --content text
```
-**LLM answer with citations:**
-```bash
-cli-anything-exa answer "What makes Exa different from Google?"
-```
-
**JSON output (for agents):**
```bash
cli-anything-exa --json search "AI safety papers" --num-results 3
diff --git a/exa/agent-harness/cli_anything/exa/core/answer.py b/exa/agent-harness/cli_anything/exa/core/answer.py
deleted file mode 100644
index 0801c5867..000000000
--- a/exa/agent-harness/cli_anything/exa/core/answer.py
+++ /dev/null
@@ -1,48 +0,0 @@
-"""
-core/answer.py — LLM-synthesised answers with citations via Exa.
-"""
-
-from __future__ import annotations
-
-from typing import Any
-
-from cli_anything.exa.utils.exa_backend import get_client
-
-
-def get_answer(query: str) -> dict[str, Any]:
- """Ask Exa a question and receive an LLM-synthesised answer with citations.
-
- Args:
- query: Natural-language question.
-
- Returns:
- Dict with keys: answer (str), citations (list[dict]).
- """
- client = get_client()
- response = client.answer(query, text=False)
- return _answer_to_dict(response)
-
-
-def _answer_to_dict(response: Any) -> dict[str, Any]:
- """Convert an exa-py AnswerResponse to a plain dict."""
- out: dict[str, Any] = {}
-
- answer_text = getattr(response, "answer", None)
- if answer_text is not None:
- out["answer"] = answer_text
-
- citations = []
- for r in getattr(response, "results", []) or []:
- cite: dict[str, Any] = {}
- for attr in ("title", "url", "published_date", "author"):
- val = getattr(r, attr, None)
- if val is not None:
- cite[attr] = val
- citations.append(cite)
- out["citations"] = citations
-
- cost = getattr(response, "cost_dollars", None)
- if cost is not None:
- out["cost_dollars"] = cost
-
- return out
diff --git a/exa/agent-harness/cli_anything/exa/core/search.py b/exa/agent-harness/cli_anything/exa/core/search.py
index 7390bc072..87dd53507 100644
--- a/exa/agent-harness/cli_anything/exa/core/search.py
+++ b/exa/agent-harness/cli_anything/exa/core/search.py
@@ -1,5 +1,5 @@
"""
-core/search.py — Web search, find-similar, and get-contents operations.
+core/search.py — Web search and get-contents operations.
"""
from __future__ import annotations
@@ -59,24 +59,6 @@ def web_search(
return _response_to_dict(response)
-def find_similar(
- url: str,
- *,
- num_results: int = 10,
- content_mode: str = "highlights",
-) -> dict[str, Any]:
- """Find pages similar to the given URL."""
- client = get_client()
- contents = build_contents_param(content_mode, "smart")
-
- kwargs: dict[str, Any] = {"num_results": num_results}
- if contents:
- kwargs["contents"] = contents
-
- response = client.find_similar(url, **kwargs)
- return _response_to_dict(response)
-
-
def get_contents(
urls: list[str],
*,
diff --git a/exa/agent-harness/cli_anything/exa/core/session.py b/exa/agent-harness/cli_anything/exa/core/session.py
deleted file mode 100644
index a53f8d672..000000000
--- a/exa/agent-harness/cli_anything/exa/core/session.py
+++ /dev/null
@@ -1,55 +0,0 @@
-"""
-core/session.py — In-session state for the interactive REPL.
-
-Tracks search history and current context so the REPL banner and
-`session history` command have something to display.
-"""
-
-from __future__ import annotations
-
-from dataclasses import dataclass, field
-from datetime import datetime
-from typing import Any
-
-
-@dataclass
-class _SearchEntry:
- query: str
- command: str # "search" | "similar" | "contents" | "answer"
- result_count: int
- timestamp: str = field(default_factory=lambda: datetime.now().strftime("%H:%M:%S"))
-
-
-_history: list[_SearchEntry] = []
-
-
-def record(query: str, command: str, result_count: int) -> None:
- """Add an entry to the in-session history."""
- _history.append(_SearchEntry(query=query, command=command, result_count=result_count))
-
-
-def get_history() -> list[dict[str, Any]]:
- """Return history as a list of plain dicts (most recent first)."""
- return [
- {
- "time": e.timestamp,
- "command": e.command,
- "query": e.query,
- "results": e.result_count,
- }
- for e in reversed(_history)
- ]
-
-
-def get_status() -> dict[str, Any]:
- """Return a summary of the current session."""
- return {
- "total_queries": len(_history),
- "commands_used": sorted({e.command for e in _history}) or [],
- "last_query": _history[-1].query if _history else None,
- }
-
-
-def clear() -> None:
- """Clear all history (used in tests)."""
- _history.clear()
diff --git a/exa/agent-harness/cli_anything/exa/exa_cli.py b/exa/agent-harness/cli_anything/exa/exa_cli.py
index 4256997cf..394485616 100644
--- a/exa/agent-harness/cli_anything/exa/exa_cli.py
+++ b/exa/agent-harness/cli_anything/exa/exa_cli.py
@@ -1,17 +1,12 @@
-"""
-exa_cli.py — CLI harness for Exa.
+"""exa_cli.py — CLI harness for Exa.
-Provides a stateful, agent-native command-line interface for the Exa API:
+Provides an agent-native command-line interface for the Exa API:
- web search (neural, keyword, or deep)
- - find-similar pages
- fetch full page contents
- - LLM-synthesised answers with citations
Usage (non-interactive):
cli-anything-exa search "AI safety papers 2024" --type deep --content highlights
- cli-anything-exa similar https://example.com --num-results 5
cli-anything-exa contents https://example.com --content text
- cli-anything-exa answer "What is Exa's neural search?"
cli-anything-exa --json search "latest LLM benchmarks" --num-results 3
cli-anything-exa server status
@@ -27,9 +22,7 @@ from typing import Any
import click
-from cli_anything.exa.core import answer as answer_core
from cli_anything.exa.core import search as search_core
-from cli_anything.exa.core import session as session_core
from cli_anything.exa.utils.exa_backend import check_connectivity
# ---------------------------------------------------------------------------
@@ -56,16 +49,9 @@ def _pretty(data: Any) -> None:
if isinstance(data, dict):
if "results" in data:
_print_results(data)
- elif "answer" in data:
- _print_answer(data)
elif "ok" in data:
status = "OK" if data["ok"] else "ERROR"
click.echo(f"[{status}] {data.get('message', '')}")
- elif "total_queries" in data:
- click.echo(f"Queries this session : {data['total_queries']}")
- click.echo(f"Commands used : {', '.join(data['commands_used']) or 'none'}")
- if data["last_query"]:
- click.echo(f"Last query : {data['last_query']}")
else:
# Generic dict fallback
for k, v in data.items():
@@ -116,20 +102,6 @@ def _print_results(data: dict[str, Any]) -> None:
click.echo(f"{'─' * 72}")
-def _print_answer(data: dict[str, Any]) -> None:
- click.echo(f"\n{data.get('answer', '')}\n")
- citations = data.get("citations", [])
- if citations:
- click.echo("Sources:")
- for i, c in enumerate(citations, 1):
- click.echo(f" {i}. {c.get('title') or c.get('url', '')}")
- click.echo(f" {c.get('url', '')}")
- cost = data.get("cost_dollars")
- if cost:
- total = cost.get("total", "") if isinstance(cost, dict) else cost
- click.echo(f"\nCost: ${total}")
-
-
def _err(msg: str) -> None:
if _json_output:
click.echo(json.dumps({"error": msg}))
@@ -249,25 +221,6 @@ def search_cmd(
content_mode=content_mode,
freshness=freshness,
)
- session_core.record(query, "search", len(result.get("results", [])))
- _out(result)
-
-
-# ---------------------------------------------------------------------------
-# similar
-# ---------------------------------------------------------------------------
-
[email protected]("--num-results", "-n", default=10, show_default=True,
- type=click.IntRange(1, 100), help="Number of results.")
[email protected]("--content", "content_mode", default="highlights", show_default=True,
- type=_CONTENT_CHOICES, help="Content to include with each result.")
-@_handle_errors
-def similar_cmd(url: str, num_results: int, content_mode: str) -> None:
- """Find pages similar to a given URL."""
- result = search_core.find_similar(url, num_results=num_results, content_mode=content_mode)
- session_core.record(url, "similar", len(result.get("results", [])))
_out(result)
@@ -287,21 +240,6 @@ def similar_cmd(url: str, num_results: int, content_mode: str) -> None:
def contents_cmd(urls: tuple[str, ...], content_mode: str, freshness: str) -> None:
"""Fetch full page contents for one or more URLs."""
result = search_core.get_contents(list(urls), content_mode=content_mode, freshness=freshness)
- session_core.record(str(urls[0]), "contents", len(result.get("results", [])))
- _out(result)
-
-
-# ---------------------------------------------------------------------------
-# answer
-# ---------------------------------------------------------------------------
-
-@_handle_errors
-def answer_cmd(query: str) -> None:
- """Get an LLM-synthesised answer with cited sources."""
- result = answer_core.get_answer(query)
- session_core.record(query, "answer", len(result.get("citations", [])))
_out(result)
@@ -322,40 +260,6 @@ def server_status() -> None:
_out(result)
-# ---------------------------------------------------------------------------
-# session
-# ---------------------------------------------------------------------------
-
-def session_group() -> None:
- """Inspect the current REPL session state."""
-
-
-@session_group.command("status")
-def session_status() -> None:
- """Show a summary of activity in this session."""
- _out(session_core.get_status())
-
-
-@session_group.command("history")
-def session_history() -> None:
- """List queries made in this session (most recent first)."""
- history = session_core.get_history()
- if _json_output:
- click.echo(json.dumps(history, indent=2))
- else:
- if not history:
- click.echo("No queries yet.")
- return
- click.echo(f"{'Time':<10} {'Cmd':<10} {'Results':<9} Query")
- click.echo("─" * 72)
- for entry in history:
- click.echo(
- f"{entry['time']:<10} {entry['command']:<10} "
- f"{entry['results']:<9} {entry['query']}"
- )
-
-
# ---------------------------------------------------------------------------
# REPL
# ---------------------------------------------------------------------------
@@ -370,10 +274,8 @@ def repl() -> None:
sys.exit(1)
skin = ReplSkin(
- software_name="Exa",
+ software="exa",
version="1.0.0",
- accent_color="cyan",
- skill_package="cli_anything.exa",
)
skin.print_banner()
diff --git a/exa/agent-harness/cli_anything/exa/skills/SKILL.md b/exa/agent-harness/cli_anything/exa/skills/SKILL.md
index e57f81b89..68d19fb66 100644
--- a/exa/agent-harness/cli_anything/exa/skills/SKILL.md
+++ b/exa/agent-harness/cli_anything/exa/skills/SKILL.md
@@ -9,8 +9,7 @@
## What This CLI Does
Provides an agent-native command-line interface to the Exa API — a neural search engine
optimised for AI agent workflows. Supports web search across multiple modes (fast, deep,
-deep-reasoning), finding similar pages, fetching full-text or highlighted page contents,
-and getting LLM-synthesised answers with cited sources.
+deep-reasoning) and fetching full-text or highlighted page contents.
## Prerequisites
- Python >= 3.10
@@ -41,32 +40,16 @@ Options:
--location CC Two-letter country code for geo-bias
```
-### similar — Find similar pages
-```bash
-cli-anything-exa similar "<url>" [--num-results N] [--content highlights|text|summary|none]
-```
-
### contents — Fetch page contents
```bash
cli-anything-exa contents <url> [url ...] [--content text|highlights|summary] [--freshness smart|always|never]
```
-### answer — LLM-synthesised answer with citations
-```bash
-cli-anything-exa answer "<question>"
-```
-
### server status — Verify API key and connectivity
```bash
cli-anything-exa server status
```
-### session — Inspect current REPL session
-```bash
-cli-anything-exa session status
-cli-anything-exa session history
-```
-
## JSON Output
All commands support `--json` at the root level for machine-readable output:
```bash
@@ -100,21 +83,11 @@ cli-anything-exa --json search "Anthropic funding history" --category company
cli-anything-exa --json search "AI regulation news" --category news --from 2024-01-01
```
-### Find related resources
-```bash
-cli-anything-exa --json similar https://arxiv.org/abs/2303.08774 --num-results 10
-```
-
### Fetch full content for summarisation
```bash
cli-anything-exa --json contents https://example.com/article --content text
```
-### Quick factual answer
-```bash
-cli-anything-exa --json answer "What is the context window of Claude 3.5 Sonnet?"
-```
-
## Interactive REPL
```bash
cli-anything-exa # No subcommand → enters REPL
diff --git a/exa/agent-harness/cli_anything/exa/tests/TEST.md b/exa/agent-harness/cli_anything/exa/tests/TEST.md
index 84152da3f..224a602d2 100644
--- a/exa/agent-harness/cli_anything/exa/tests/TEST.md
+++ b/exa/agent-harness/cli_anything/exa/tests/TEST.md
@@ -22,16 +22,11 @@
- [x] Hyphenated slugs map correctly to API space-separated values
- [x] Simple slugs pass through unchanged
-### TestSession
-- [x] Empty session returns zero totals
-- [x] `record()` adds entries visible in `get_history()`
-- [x] History returned most-recent-first
-- [x] Status reflects all distinct commands used
-
### TestCLIHelp
- [x] Root `--help` exits 0 and mentions "Exa"
- [x] `search --help` shows all flags
-- [x] All subcommand `--help` exits exit code 0
+- [x] `contents --help` exits exit code 0
+- [x] `server status --help` exits exit code 0
### TestSearchCLI
- [x] Basic search calls `exa.search()` with correct query
@@ -41,28 +36,15 @@
- [x] `--include-domains` is forwarded to SDK
- [x] Invalid `--type` value is rejected (exit != 0)
-### TestSimilarCLI
-- [x] Basic call invokes `exa.find_similar()`
-- [x] `--json` produces parseable JSON
-
### TestContentsCLI
- [x] Single URL invokes `exa.get_contents()`
- [x] Multiple URLs forwarded as list
-### TestAnswerCLI
-- [x] Answer text appears in output
-- [x] `--json` produces `answer` and `citations` keys
-
### TestServerCLI
- [x] `[OK]` shown on success
- [x] `[ERROR]` shown on failure
- [x] `--json` produces `{"ok": true}`
-### TestSessionCLI
-- [x] `session status` shows query count after search
-- [x] `session history` shows "No queries" when empty
-- [x] `session history --json` returns a list
-
### TestErrorHandling
- [x] `RuntimeError` from backend produces `{"error": "..."}` in JSON mode
- [x] Missing required argument exits non-zero
@@ -84,22 +66,12 @@ Skipped automatically when `EXA_API_KEY` is not set.
- [ ] `--include-domains arxiv.org` — all result URLs contain `arxiv.org`
- [ ] `--num-results 5` returns ≤ 5 results
- [ ] Human-readable output contains `http`
-- [ ] Session is updated after search
-
-### TestSimilarE2E
-- [ ] `similar <url>` returns results
-- [ ] Results contain `url` and `title`
### TestContentsE2E
- [ ] `contents <url>` returns results
- [ ] `--content text` result has non-empty `text`
- [ ] Multiple URLs: at least 1 result returned
-### TestAnswerE2E
-- [ ] `answer <question>` returns `answer` string (> 10 chars)
-- [ ] `answer` result has `citations` list
-- [ ] Human-readable output is non-empty
-
### TestEntryPoint
- [ ] `cli-anything-exa --help` exits 0 via subprocess
- [ ] `cli-anything-exa --json search ...` returns valid JSON via subprocess
diff --git a/exa/agent-harness/cli_anything/exa/tests/test_core.py b/exa/agent-harness/cli_anything/exa/tests/test_core.py
index 32f4e2c9c..5e5ba524e 100644
--- a/exa/agent-harness/cli_anything/exa/tests/test_core.py
+++ b/exa/agent-harness/cli_anything/exa/tests/test_core.py
@@ -15,7 +15,6 @@ import pytest
from click.testing import CliRunner
from cli_anything.exa.exa_cli import cli
-from cli_anything.exa.core import session as session_core
from cli_anything.exa.utils.exa_backend import build_contents_param, CATEGORY_SLUG_MAP
@@ -23,14 +22,6 @@ from cli_anything.exa.utils.exa_backend import build_contents_param, CATEGORY_SL
# Fixtures
# ---------------------------------------------------------------------------
[email protected](autouse=True)
-def clear_session():
- """Reset session history before each test."""
- session_core.clear()
- yield
- session_core.clear()
-
-
@pytest.fixture()
def runner():
return CliRunner()
@@ -55,21 +46,6 @@ def _mock_result(n: int = 2):
return SimpleNamespace(results=results, cost_dollars={"total": 0.005})
-def _mock_answer():
- citation = SimpleNamespace(
- title="Some Paper",
- url="https://example.com/paper",
- published_date="2024-01-01",
- author="Jane Doe",
- )
- return SimpleNamespace(
- answer="Exa uses neural embeddings for search.",
- results=[citation],
- cost_dollars={"total": 0.003},
- )
- return response
-
-
# ---------------------------------------------------------------------------
# Backend unit tests
# ---------------------------------------------------------------------------
@@ -116,40 +92,6 @@ class TestCategorySlugMap:
assert CATEGORY_SLUG_MAP["company"] == "company"
-# ---------------------------------------------------------------------------
-# Session unit tests
-# ---------------------------------------------------------------------------
-
-class TestSession:
- def test_empty_session(self):
- status = session_core.get_status()
- assert status["total_queries"] == 0
- assert status["last_query"] is None
-
- def test_record_and_history(self):
- session_core.record("test query", "search", 5)
- history = session_core.get_history()
- assert len(history) == 1
- assert history[0]["query"] == "test query"
- assert history[0]["results"] == 5
-
- def test_history_most_recent_first(self):
- session_core.record("first", "search", 1)
- session_core.record("second", "answer", 2)
- history = session_core.get_history()
- assert history[0]["query"] == "second"
- assert history[1]["query"] == "first"
-
- def test_status_after_records(self):
- session_core.record("q1", "search", 3)
- session_core.record("q2", "answer", 1)
- status = session_core.get_status()
- assert status["total_queries"] == 2
- assert "search" in status["commands_used"]
- assert "answer" in status["commands_used"]
- assert status["last_query"] == "q2"
-
-
# ---------------------------------------------------------------------------
# CLI parsing tests
# ---------------------------------------------------------------------------
@@ -167,27 +109,14 @@ class TestCLIHelp:
assert "--num-results" in result.output
assert "--content" in result.output
- def test_similar_help(self, runner):
- result = runner.invoke(cli, ["similar", "--help"])
- assert result.exit_code == 0
- assert "--num-results" in result.output
-
def test_contents_help(self, runner):
result = runner.invoke(cli, ["contents", "--help"])
assert result.exit_code == 0
- def test_answer_help(self, runner):
- result = runner.invoke(cli, ["answer", "--help"])
- assert result.exit_code == 0
-
def test_server_status_help(self, runner):
result = runner.invoke(cli, ["server", "status", "--help"])
assert result.exit_code == 0
- def test_session_help(self, runner):
- result = runner.invoke(cli, ["session", "--help"])
- assert result.exit_code == 0
-
class TestSearchCLI:
@patch("cli_anything.exa.core.search.get_client")
@@ -255,29 +184,6 @@ class TestSearchCLI:
assert result.exit_code != 0
-class TestSimilarCLI:
- @patch("cli_anything.exa.core.search.get_client")
- def test_basic_similar(self, mock_get_client, runner):
- mock_client = MagicMock()
- mock_client.find_similar.return_value = _mock_result(3)
- mock_get_client.return_value = mock_client
-
- result = runner.invoke(cli, ["similar", "https://example.com"])
- assert result.exit_code == 0
- mock_client.find_similar.assert_called_once()
-
- @patch("cli_anything.exa.core.search.get_client")
- def test_similar_json_output(self, mock_get_client, runner):
- mock_client = MagicMock()
- mock_client.find_similar.return_value = _mock_result(2)
- mock_get_client.return_value = mock_client
-
- result = runner.invoke(cli, ["--json", "similar", "https://example.com"])
- assert result.exit_code == 0
- data = json.loads(result.output)
- assert "results" in data
-
-
class TestContentsCLI:
@patch("cli_anything.exa.core.search.get_client")
def test_basic_contents(self, mock_get_client, runner):
@@ -303,30 +209,6 @@ class TestContentsCLI:
assert len(args[0]) == 2
-class TestAnswerCLI:
- @patch("cli_anything.exa.core.answer.get_client")
- def test_basic_answer(self, mock_get_client, runner):
- mock_client = MagicMock()
- mock_client.answer.return_value = _mock_answer()
- mock_get_client.return_value = mock_client
-
- result = runner.invoke(cli, ["answer", "What is Exa?"])
- assert result.exit_code == 0
- assert "neural embeddings" in result.output
-
- @patch("cli_anything.exa.core.answer.get_client")
- def test_answer_json_output(self, mock_get_client, runner):
- mock_client = MagicMock()
- mock_client.answer.return_value = _mock_answer()
- mock_get_client.return_value = mock_client
-
- result = runner.invoke(cli, ["--json", "answer", "What is Exa?"])
- assert result.exit_code == 0
- data = json.loads(result.output)
- assert "answer" in data
- assert "citations" in data
-
-
class TestServerCLI:
@patch("cli_anything.exa.exa_cli.check_connectivity")
def test_server_status_ok(self, mock_check, runner):
@@ -351,37 +233,6 @@ class TestServerCLI:
assert data["ok"] is True
-class TestSessionCLI:
- @patch("cli_anything.exa.core.search.get_client")
- def test_session_status_after_search(self, mock_get_client, runner):
- mock_client = MagicMock()
- mock_client.search.return_value = _mock_result(3)
- mock_get_client.return_value = mock_client
-
- runner.invoke(cli, ["search", "test query"])
- result = runner.invoke(cli, ["session", "status"])
- assert result.exit_code == 0
- assert "1" in result.output # total_queries
-
- def test_session_history_empty(self, runner):
- result = runner.invoke(cli, ["session", "history"])
- assert result.exit_code == 0
- assert "No queries" in result.output
-
- @patch("cli_anything.exa.core.search.get_client")
- def test_session_history_json(self, mock_get_client, runner):
- mock_client = MagicMock()
- mock_client.search.return_value = _mock_result(2)
- mock_get_client.return_value = mock_client
-
- runner.invoke(cli, ["search", "test"])
- result = runner.invoke(cli, ["--json", "session", "history"])
- assert result.exit_code == 0
- data = json.loads(result.output)
- assert isinstance(data, list)
- assert data[0]["query"] == "test"
-
-
class TestErrorHandling:
@patch("cli_anything.exa.core.search.get_client")
def test_runtime_error_produces_json_error(self, mock_get_client, runner):
diff --git a/exa/agent-harness/cli_anything/exa/tests/test_full_e2e.py b/exa/agent-harness/cli_anything/exa/tests/test_full_e2e.py
index c2191974e..6f22f1950 100644
--- a/exa/agent-harness/cli_anything/exa/tests/test_full_e2e.py
+++ b/exa/agent-harness/cli_anything/exa/tests/test_full_e2e.py
@@ -21,7 +21,6 @@ import pytest
from click.testing import CliRunner
from cli_anything.exa.exa_cli import cli
-from cli_anything.exa.core import session as session_core
# ---------------------------------------------------------------------------
@@ -34,13 +33,6 @@ pytestmark = pytest.mark.skipif(
)
[email protected](autouse=True)
-def clear_session():
- session_core.clear()
- yield
- session_core.clear()
-
-
@pytest.fixture()
def runner():
return CliRunner()
@@ -158,37 +150,6 @@ class TestSearchE2E:
assert result.exit_code == 0
assert "http" in result.output # URL is shown
- def test_search_records_session(self, runner):
- runner.invoke(cli, ["--json", "search", "test query"])
- status = session_core.get_status()
- assert status["total_queries"] == 1
- assert status["last_query"] == "test query"
-
-
-# ---------------------------------------------------------------------------
-# similar
-# ---------------------------------------------------------------------------
-
-class TestSimilarE2E:
- def test_basic_similar(self, runner):
- result = runner.invoke(
- cli, ["--json", "similar", "https://arxiv.org/abs/2303.08774", "--num-results", "3"]
- )
- assert result.exit_code == 0
- data = json.loads(result.output)
- assert "results" in data
- assert len(data["results"]) > 0
-
- def test_similar_result_fields(self, runner):
- result = runner.invoke(
- cli, ["--json", "similar", "https://openai.com/research/gpt-4", "--num-results", "2"]
- )
- assert result.exit_code == 0
- data = json.loads(result.output)
- r = data["results"][0]
- assert "url" in r
- assert "title" in r
-
# ---------------------------------------------------------------------------
# contents
@@ -224,31 +185,6 @@ class TestContentsE2E:
assert len(data["results"]) >= 1
-# ---------------------------------------------------------------------------
-# answer
-# ---------------------------------------------------------------------------
-
-class TestAnswerE2E:
- def test_basic_answer(self, runner):
- result = runner.invoke(cli, ["--json", "answer", "What is Exa's neural search?"])
- assert result.exit_code == 0
- data = json.loads(result.output)
- assert "answer" in data
- assert len(data["answer"]) > 10
-
- def test_answer_has_citations(self, runner):
- result = runner.invoke(cli, ["--json", "answer", "How does Exa differ from Google?"])
- assert result.exit_code == 0
- data = json.loads(result.output)
- assert "citations" in data
- assert isinstance(data["citations"], list)
-
- def test_answer_human_readable(self, runner):
- result = runner.invoke(cli, ["answer", "What is RAG in AI?"])
- assert result.exit_code == 0
- assert len(result.output.strip()) > 0
-
-
# ---------------------------------------------------------------------------
# subprocess (entry-point) smoke test
# ---------------------------------------------------------------------------
diff --git a/exa/agent-harness/cli_anything/exa/utils/exa_backend.py b/exa/agent-harness/cli_anything/exa/utils/exa_backend.py
index c9589eb30..3528cbac9 100644
--- a/exa/agent-harness/cli_anything/exa/utils/exa_backend.py
+++ b/exa/agent-harness/cli_anything/exa/utils/exa_backend.py
@@ -30,7 +30,10 @@ def get_client() -> Exa:
"EXA_API_KEY environment variable is not set.\n"
"Get a free key at https://dashboard.exa.ai/api-keys"
)
- return Exa(api_key=api_key)
+ return Exa(
+ api_key=api_key,
+ additional_headers={"x-exa-integration": "cli-anything"},
+ )
def check_connectivity() -> dict[str, Any]:
@@ -59,10 +62,10 @@ def build_contents_param(
freshness: "smart" | "always" | "never"
Returns:
- A contents dict suitable for passing to exa.search() / exa.find_similar(),
+ A contents dict suitable for passing to exa.search() / exa.get_contents(),
or None if content_mode is "none".
"""
- if content_mode == "none":
+ if content_mode == "none": # noqa: SIM114
return None
contents: dict[str, Any] = {}
diff --git a/exa/agent-harness/setup.py b/exa/agent-harness/setup.py
index 1f4d98455..1cdc8b38e 100644
--- a/exa/agent-harness/setup.py
+++ b/exa/agent-harness/setup.py
@@ -16,7 +16,7 @@ setup(
version="1.0.0",
author="cli-anything contributors",
author_email="",
- description="CLI harness for Exa — AI-powered web search, similar-page discovery, and LLM-synthesized answers via the Exa API",
+ description="CLI harness for Exa — AI-powered web search and content extraction via the Exa API",
long_description=long_description,
long_description_content_type="text/markdown",
url="https://github.com/HKUDS/CLI-Anything",
diff --git a/registry.json b/registry.json
index b341b174a..fbacb8cdf 100644
--- a/registry.json
+++ b/registry.json
@@ -471,7 +471,7 @@
"name": "exa",
"display_name": "Exa",
"version": "1.0.0",
- "description": "AI-powered web search, similar-page discovery, and LLM-synthesised answers via the Exa API",
+ "description": "AI-powered web search and content extraction via the Exa API",
"requires": "EXA_API_KEY (free tier at exa.ai)",
"homepage": "https://exa.ai",
"install_cmd": "pip install git+https://github.com/HKUDS/CLI-Anything.git#subdirectory=exa/agent-harness",