tavily-cli 0.2.0__tar.gz → 0.2.2__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {tavily_cli-0.2.0 → tavily_cli-0.2.2}/PKG-INFO +18 -14
- {tavily_cli-0.2.0 → tavily_cli-0.2.2}/README.md +15 -11
- {tavily_cli-0.2.0 → tavily_cli-0.2.2}/pyproject.toml +3 -3
- {tavily_cli-0.2.0 → tavily_cli-0.2.2}/tavily_cli/cli.py +8 -0
- {tavily_cli-0.2.0 → tavily_cli-0.2.2}/tavily_cli/commands/init.py +7 -34
- tavily_cli-0.2.2/tavily_cli/init_skills.py +111 -0
- {tavily_cli-0.2.0 → tavily_cli-0.2.2}/tests/test_cli.py +10 -0
- {tavily_cli-0.2.0 → tavily_cli-0.2.2}/tests/test_defaults.py +2 -2
- tavily_cli-0.2.2/tests/test_init.py +176 -0
- {tavily_cli-0.2.0 → tavily_cli-0.2.2}/tests/test_output.py +2 -2
- tavily_cli-0.2.0/tavily_cli/init_skills.py +0 -390
- tavily_cli-0.2.0/tests/test_init.py +0 -292
- {tavily_cli-0.2.0 → tavily_cli-0.2.2}/.gitignore +0 -0
- {tavily_cli-0.2.0 → tavily_cli-0.2.2}/LICENSE +0 -0
- {tavily_cli-0.2.0 → tavily_cli-0.2.2}/install.sh +0 -0
- {tavily_cli-0.2.0 → tavily_cli-0.2.2}/tavily_cli/__init__.py +0 -0
- {tavily_cli-0.2.0 → tavily_cli-0.2.2}/tavily_cli/commands/__init__.py +0 -0
- {tavily_cli-0.2.0 → tavily_cli-0.2.2}/tavily_cli/commands/auth.py +0 -0
- {tavily_cli-0.2.0 → tavily_cli-0.2.2}/tavily_cli/commands/crawl.py +0 -0
- {tavily_cli-0.2.0 → tavily_cli-0.2.2}/tavily_cli/commands/defaults.py +0 -0
- {tavily_cli-0.2.0 → tavily_cli-0.2.2}/tavily_cli/commands/extract.py +0 -0
- {tavily_cli-0.2.0 → tavily_cli-0.2.2}/tavily_cli/commands/map_cmd.py +0 -0
- {tavily_cli-0.2.0 → tavily_cli-0.2.2}/tavily_cli/commands/research.py +0 -0
- {tavily_cli-0.2.0 → tavily_cli-0.2.2}/tavily_cli/commands/search.py +0 -0
- {tavily_cli-0.2.0 → tavily_cli-0.2.2}/tavily_cli/commands/update.py +0 -0
- {tavily_cli-0.2.0 → tavily_cli-0.2.2}/tavily_cli/common.py +0 -0
- {tavily_cli-0.2.0 → tavily_cli-0.2.2}/tavily_cli/config.py +0 -0
- {tavily_cli-0.2.0 → tavily_cli-0.2.2}/tavily_cli/keyless.py +0 -0
- {tavily_cli-0.2.0 → tavily_cli-0.2.2}/tavily_cli/mcp_client.py +0 -0
- {tavily_cli-0.2.0 → tavily_cli-0.2.2}/tavily_cli/oauth.py +0 -0
- {tavily_cli-0.2.0 → tavily_cli-0.2.2}/tavily_cli/output.py +0 -0
- {tavily_cli-0.2.0 → tavily_cli-0.2.2}/tavily_cli/repl.py +0 -0
- {tavily_cli-0.2.0 → tavily_cli-0.2.2}/tavily_cli/theme.py +0 -0
- {tavily_cli-0.2.0 → tavily_cli-0.2.2}/tests/test_install_sh.py +0 -0
- {tavily_cli-0.2.0 → tavily_cli-0.2.2}/tests/test_oauth.py +0 -0
- {tavily_cli-0.2.0 → tavily_cli-0.2.2}/tests/test_update.py +0 -0
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
Metadata-Version: 2.5
|
|
2
2
|
Name: tavily-cli
|
|
3
|
-
Version: 0.2.
|
|
4
|
-
Summary:
|
|
3
|
+
Version: 0.2.2
|
|
4
|
+
Summary: Deprecated: the Tavily CLI moved to npm as @tavily/cli. This package is no longer updated.
|
|
5
5
|
Project-URL: Homepage, https://tavily.com
|
|
6
6
|
Project-URL: Documentation, https://docs.tavily.com
|
|
7
7
|
Project-URL: Repository, https://github.com/tavily-ai/tavily-cli
|
|
@@ -10,7 +10,7 @@ Author-email: Tavily <support@tavily.com>
|
|
|
10
10
|
License-Expression: MIT
|
|
11
11
|
License-File: LICENSE
|
|
12
12
|
Keywords: agents,ai,crawl,extract,llm,rag,research,tavily,web-search
|
|
13
|
-
Classifier: Development Status ::
|
|
13
|
+
Classifier: Development Status :: 7 - Inactive
|
|
14
14
|
Classifier: Intended Audience :: Developers
|
|
15
15
|
Classifier: License :: OSI Approved :: MIT License
|
|
16
16
|
Classifier: Operating System :: OS Independent
|
|
@@ -37,6 +37,12 @@ Description-Content-Type: text/markdown
|
|
|
37
37
|
|
|
38
38
|
# Tavily CLI
|
|
39
39
|
|
|
40
|
+
> **Deprecated.** The Tavily CLI now lives on npm as [`@tavily/cli`](https://www.npmjs.com/package/@tavily/cli),
|
|
41
|
+
> with source at [tavily-ai/cli](https://github.com/tavily-ai/cli). This Python package receives no further
|
|
42
|
+
> updates. Install the current CLI with `npx @tavily/cli init`, then remove this one with
|
|
43
|
+
> `uv tool uninstall tavily-cli` or `pip uninstall tavily-cli`. Every `tvly` command in this package
|
|
44
|
+
> prints a one-line reminder on stderr; nothing else changed in this release.
|
|
45
|
+
|
|
40
46
|
CLI and agent tools for the [Tavily API](https://docs.tavily.com) — search, extract, crawl, map, and research from the command line.
|
|
41
47
|
|
|
42
48
|
> **Note:** This package provides the `tvly` command-line tool. It depends on
|
|
@@ -121,13 +127,12 @@ tvly search "latest AI trends"
|
|
|
121
127
|
`tvly init` guides you through:
|
|
122
128
|
|
|
123
129
|
1. **Authentication:** reuse an existing credential or sign in through browser OAuth.
|
|
124
|
-
2. **Agent setup:** detect Claude Code, Codex, and Cursor and install Tavily
|
|
125
|
-
3. **Verification:** check the CLI
|
|
130
|
+
2. **Agent setup:** detect Claude Code, Codex, and Cursor and install the Tavily agent skills.
|
|
131
|
+
3. **Verification:** check the CLI, then run a live search.
|
|
126
132
|
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
Node.js,
|
|
130
|
-
Restart your agent after new skills are installed.
|
|
133
|
+
Skills are installed with the [skills.sh CLI](https://skills.sh)
|
|
134
|
+
(`npx skills add tavily-ai/skills`), so skill setup requires Node.js. Without
|
|
135
|
+
Node.js, use `--skip-skills`. Restart your agent after new skills are installed.
|
|
131
136
|
|
|
132
137
|
```bash
|
|
133
138
|
# Set up one or more supported agents
|
|
@@ -149,10 +154,9 @@ tvly init --skip-skills
|
|
|
149
154
|
|
|
150
155
|
Skills are installed in `~/.agents/skills`, which Codex and Cursor load
|
|
151
156
|
directly; Claude Code gets links in `~/.claude/skills`. If no supported agent
|
|
152
|
-
is detected, setup
|
|
153
|
-
Rerunning `tvly init` updates existing skills to the latest published version
|
|
154
|
-
|
|
155
|
-
run `npx skills update` at any time.
|
|
157
|
+
is detected, setup skips the skills.
|
|
158
|
+
Rerunning `tvly init` updates existing skills to the latest published version.
|
|
159
|
+
You can also run `npx skills update` at any time.
|
|
156
160
|
|
|
157
161
|
### Try search and extract without signing in
|
|
158
162
|
|
|
@@ -426,7 +430,7 @@ tvly --status --json # structured status
|
|
|
426
430
|
### `tvly init`
|
|
427
431
|
|
|
428
432
|
Run first-time setup, install or update the Tavily skills (through
|
|
429
|
-
`npx skills
|
|
433
|
+
`npx skills`, which requires Node.js), and verify the CLI with a live search.
|
|
430
434
|
|
|
431
435
|
| Option | Description |
|
|
432
436
|
|--------|-------------|
|
|
@@ -1,5 +1,11 @@
|
|
|
1
1
|
# Tavily CLI
|
|
2
2
|
|
|
3
|
+
> **Deprecated.** The Tavily CLI now lives on npm as [`@tavily/cli`](https://www.npmjs.com/package/@tavily/cli),
|
|
4
|
+
> with source at [tavily-ai/cli](https://github.com/tavily-ai/cli). This Python package receives no further
|
|
5
|
+
> updates. Install the current CLI with `npx @tavily/cli init`, then remove this one with
|
|
6
|
+
> `uv tool uninstall tavily-cli` or `pip uninstall tavily-cli`. Every `tvly` command in this package
|
|
7
|
+
> prints a one-line reminder on stderr; nothing else changed in this release.
|
|
8
|
+
|
|
3
9
|
CLI and agent tools for the [Tavily API](https://docs.tavily.com) — search, extract, crawl, map, and research from the command line.
|
|
4
10
|
|
|
5
11
|
> **Note:** This package provides the `tvly` command-line tool. It depends on
|
|
@@ -84,13 +90,12 @@ tvly search "latest AI trends"
|
|
|
84
90
|
`tvly init` guides you through:
|
|
85
91
|
|
|
86
92
|
1. **Authentication:** reuse an existing credential or sign in through browser OAuth.
|
|
87
|
-
2. **Agent setup:** detect Claude Code, Codex, and Cursor and install Tavily
|
|
88
|
-
3. **Verification:** check the CLI
|
|
93
|
+
2. **Agent setup:** detect Claude Code, Codex, and Cursor and install the Tavily agent skills.
|
|
94
|
+
3. **Verification:** check the CLI, then run a live search.
|
|
89
95
|
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
Node.js,
|
|
93
|
-
Restart your agent after new skills are installed.
|
|
96
|
+
Skills are installed with the [skills.sh CLI](https://skills.sh)
|
|
97
|
+
(`npx skills add tavily-ai/skills`), so skill setup requires Node.js. Without
|
|
98
|
+
Node.js, use `--skip-skills`. Restart your agent after new skills are installed.
|
|
94
99
|
|
|
95
100
|
```bash
|
|
96
101
|
# Set up one or more supported agents
|
|
@@ -112,10 +117,9 @@ tvly init --skip-skills
|
|
|
112
117
|
|
|
113
118
|
Skills are installed in `~/.agents/skills`, which Codex and Cursor load
|
|
114
119
|
directly; Claude Code gets links in `~/.claude/skills`. If no supported agent
|
|
115
|
-
is detected, setup
|
|
116
|
-
Rerunning `tvly init` updates existing skills to the latest published version
|
|
117
|
-
|
|
118
|
-
run `npx skills update` at any time.
|
|
120
|
+
is detected, setup skips the skills.
|
|
121
|
+
Rerunning `tvly init` updates existing skills to the latest published version.
|
|
122
|
+
You can also run `npx skills update` at any time.
|
|
119
123
|
|
|
120
124
|
### Try search and extract without signing in
|
|
121
125
|
|
|
@@ -389,7 +393,7 @@ tvly --status --json # structured status
|
|
|
389
393
|
### `tvly init`
|
|
390
394
|
|
|
391
395
|
Run first-time setup, install or update the Tavily skills (through
|
|
392
|
-
`npx skills
|
|
396
|
+
`npx skills`, which requires Node.js), and verify the CLI with a live search.
|
|
393
397
|
|
|
394
398
|
| Option | Description |
|
|
395
399
|
|--------|-------------|
|
|
@@ -4,8 +4,8 @@ build-backend = "hatchling.build"
|
|
|
4
4
|
|
|
5
5
|
[project]
|
|
6
6
|
name = "tavily-cli"
|
|
7
|
-
version = "0.2.
|
|
8
|
-
description = "
|
|
7
|
+
version = "0.2.2"
|
|
8
|
+
description = "Deprecated: the Tavily CLI moved to npm as @tavily/cli. This package is no longer updated."
|
|
9
9
|
readme = "README.md"
|
|
10
10
|
requires-python = ">=3.10"
|
|
11
11
|
license = "MIT"
|
|
@@ -14,7 +14,7 @@ authors = [
|
|
|
14
14
|
]
|
|
15
15
|
keywords = ["ai", "tavily", "web-search", "llm", "rag", "agents", "research", "crawl", "extract"]
|
|
16
16
|
classifiers = [
|
|
17
|
-
"Development Status ::
|
|
17
|
+
"Development Status :: 7 - Inactive",
|
|
18
18
|
"Intended Audience :: Developers",
|
|
19
19
|
"License :: OSI Approved :: MIT License",
|
|
20
20
|
"Operating System :: OS Independent",
|
|
@@ -15,6 +15,13 @@ from tavily_cli.commands.research import research
|
|
|
15
15
|
from tavily_cli.commands.search import search
|
|
16
16
|
from tavily_cli.commands.update import update_command
|
|
17
17
|
|
|
18
|
+
# The CLI moved to npm as @tavily/cli; this package is kept only so pinned installs keep working.
|
|
19
|
+
DEPRECATION_NOTICE = (
|
|
20
|
+
"tavily-cli on PyPI is deprecated and no longer updated. "
|
|
21
|
+
"Switch to the npm CLI: npx @tavily/cli init "
|
|
22
|
+
"(then: uv tool uninstall tavily-cli, or pip uninstall tavily-cli)"
|
|
23
|
+
)
|
|
24
|
+
|
|
18
25
|
|
|
19
26
|
@click.group(invoke_without_command=True)
|
|
20
27
|
@click.option("--version", is_flag=True, default=False, help="Show version and exit.")
|
|
@@ -34,6 +41,7 @@ def cli(ctx: click.Context, version: bool, show_status: bool, json_output: bool)
|
|
|
34
41
|
"""
|
|
35
42
|
ctx.ensure_object(dict)
|
|
36
43
|
ctx.obj["json_output"] = json_output
|
|
44
|
+
click.echo(DEPRECATION_NOTICE, err=True)
|
|
37
45
|
|
|
38
46
|
if version:
|
|
39
47
|
if json_output:
|
|
@@ -12,14 +12,7 @@ import click
|
|
|
12
12
|
|
|
13
13
|
from tavily_cli import __version__
|
|
14
14
|
from tavily_cli.common import json_option
|
|
15
|
-
from tavily_cli.init_skills import
|
|
16
|
-
SKILLS_REPO,
|
|
17
|
-
SKILLS_SOURCE,
|
|
18
|
-
agent_specs,
|
|
19
|
-
detect_agents,
|
|
20
|
-
install_agent_skills,
|
|
21
|
-
verify_skills,
|
|
22
|
-
)
|
|
15
|
+
from tavily_cli.init_skills import SKILLS_REPO, agent_specs, detect_agents, install_agent_skills
|
|
23
16
|
|
|
24
17
|
_AGENT_CHOICES = tuple(agent_specs())
|
|
25
18
|
|
|
@@ -61,7 +54,7 @@ def init_command(
|
|
|
61
54
|
|
|
62
55
|
selected_agents = _select_agents(agents, all_agents, assume_yes, skip_skills, json_output)
|
|
63
56
|
result = _empty_result(selected_agents)
|
|
64
|
-
result["skills"]["skipped"] = skip_skills
|
|
57
|
+
result["skills"]["skipped"] = skip_skills or not selected_agents
|
|
65
58
|
|
|
66
59
|
try:
|
|
67
60
|
auth = _ensure_auth(api_key=api_key, skip_auth=skip_auth, browser=browser, json_output=json_output)
|
|
@@ -72,22 +65,10 @@ def init_command(
|
|
|
72
65
|
result["mode"] = "authenticated" if auth["authenticated"] else "keyless"
|
|
73
66
|
result["verification"]["auth"] = auth["authenticated"]
|
|
74
67
|
|
|
75
|
-
if not
|
|
68
|
+
if not result["skills"]["skipped"]:
|
|
76
69
|
try:
|
|
77
70
|
skills_result = install_agent_skills(selected_agents)
|
|
78
|
-
result["skills"].
|
|
79
|
-
"installer": skills_result.installer,
|
|
80
|
-
"source": SKILLS_REPO if skills_result.installer == "npx" else SKILLS_SOURCE,
|
|
81
|
-
"installed": skills_result.installed,
|
|
82
|
-
"updated": skills_result.updated,
|
|
83
|
-
"unchanged": skills_result.unchanged,
|
|
84
|
-
"total": skills_result.total,
|
|
85
|
-
"linked": skills_result.linked,
|
|
86
|
-
"restart_required": skills_result.restart_required,
|
|
87
|
-
})
|
|
88
|
-
result["verification"]["skills"] = verify_skills(selected_agents)
|
|
89
|
-
if not result["verification"]["skills"]:
|
|
90
|
-
raise RuntimeError("Installed Tavily skills could not be verified.")
|
|
71
|
+
result["skills"]["restart_required"] = skills_result.restart_required
|
|
91
72
|
except Exception as exc:
|
|
92
73
|
_fail(result, "skills", str(exc), 1, json_output)
|
|
93
74
|
return
|
|
@@ -195,21 +176,14 @@ def _empty_result(agents: tuple[str, ...]) -> dict[str, Any]:
|
|
|
195
176
|
"mode": "unknown",
|
|
196
177
|
"auth": {"authenticated": False, "method": "none"},
|
|
197
178
|
"skills": {
|
|
198
|
-
"
|
|
199
|
-
"source": SKILLS_SOURCE,
|
|
179
|
+
"source": SKILLS_REPO,
|
|
200
180
|
"agents": list(agents),
|
|
201
|
-
"installed": 0,
|
|
202
|
-
"updated": 0,
|
|
203
|
-
"unchanged": 0,
|
|
204
|
-
"total": 0,
|
|
205
|
-
"linked": 0,
|
|
206
181
|
"restart_required": False,
|
|
207
182
|
"skipped": False,
|
|
208
183
|
},
|
|
209
184
|
"verification": {
|
|
210
185
|
"cli": False,
|
|
211
186
|
"auth": False,
|
|
212
|
-
"skills": None,
|
|
213
187
|
"live_search": False,
|
|
214
188
|
},
|
|
215
189
|
}
|
|
@@ -251,11 +225,10 @@ def _print_result(result: dict[str, Any], *, json_output: bool) -> None:
|
|
|
251
225
|
if skills["skipped"]:
|
|
252
226
|
console.print(" [dim]• Skills skipped[/dim]")
|
|
253
227
|
else:
|
|
254
|
-
|
|
255
|
-
console.print(f" [#9BC0AE]✓[/#9BC0AE] {skills['total']} Tavily skills ready for {agents}")
|
|
228
|
+
console.print(f" [#9BC0AE]✓[/#9BC0AE] Tavily skills ready for {', '.join(skills['agents'])}")
|
|
256
229
|
console.print(" [#9BC0AE]✓[/#9BC0AE] Live search verified")
|
|
257
230
|
|
|
258
|
-
if skills["restart_required"]
|
|
231
|
+
if skills["restart_required"]:
|
|
259
232
|
console.print()
|
|
260
233
|
console.print(f" [dim]Restart {', '.join(skills['agents'])} to load newly installed skills.[/dim]")
|
|
261
234
|
|
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
"""Install Tavily's maintained agent skills with the skills.sh CLI (``npx skills``).
|
|
2
|
+
|
|
3
|
+
Installs track the latest published skills and are counted on skills.sh.
|
|
4
|
+
"""
|
|
5
|
+
|
|
6
|
+
from __future__ import annotations
|
|
7
|
+
|
|
8
|
+
import hashlib
|
|
9
|
+
import os
|
|
10
|
+
import shutil
|
|
11
|
+
import subprocess
|
|
12
|
+
from dataclasses import dataclass
|
|
13
|
+
from pathlib import Path
|
|
14
|
+
|
|
15
|
+
SKILLS_REPO = "tavily-ai/skills"
|
|
16
|
+
# Exact version: npx runs whatever this resolves to with the user's permissions.
|
|
17
|
+
NPX_SKILLS_PACKAGE = "skills@1.7.4"
|
|
18
|
+
|
|
19
|
+
_NPX_TIMEOUT_SECONDS = 300
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
@dataclass(frozen=True)
|
|
23
|
+
class AgentSpec:
|
|
24
|
+
marker: Path
|
|
25
|
+
skills_dir: Path
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
@dataclass(frozen=True)
|
|
29
|
+
class SkillsInstallResult:
|
|
30
|
+
agents: tuple[str, ...]
|
|
31
|
+
restart_required: bool
|
|
32
|
+
|
|
33
|
+
|
|
34
|
+
def agent_specs(home: Path | None = None) -> dict[str, AgentSpec]:
|
|
35
|
+
"""Return supported agent locations rooted at the current user's home."""
|
|
36
|
+
root = home or Path.home()
|
|
37
|
+
if home is None:
|
|
38
|
+
claude_root = Path(os.environ.get("CLAUDE_CONFIG_DIR", root / ".claude")).expanduser()
|
|
39
|
+
codex_root = Path(os.environ.get("CODEX_HOME", root / ".codex")).expanduser()
|
|
40
|
+
else:
|
|
41
|
+
claude_root = root / ".claude"
|
|
42
|
+
codex_root = root / ".codex"
|
|
43
|
+
return {
|
|
44
|
+
"claude-code": AgentSpec(claude_root, claude_root / "skills"),
|
|
45
|
+
"codex": AgentSpec(codex_root, codex_root / "skills"),
|
|
46
|
+
"cursor": AgentSpec(root / ".cursor", root / ".cursor" / "skills"),
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
|
|
50
|
+
def detect_agents(home: Path | None = None) -> tuple[str, ...]:
|
|
51
|
+
"""Detect supported agents from their existing configuration directories."""
|
|
52
|
+
return tuple(name for name, spec in agent_specs(home).items() if spec.marker.is_dir())
|
|
53
|
+
|
|
54
|
+
|
|
55
|
+
def install_agent_skills(agents: tuple[str, ...]) -> SkillsInstallResult:
|
|
56
|
+
"""Install every skill in the Tavily skills repo for the selected agents."""
|
|
57
|
+
npx = shutil.which("npx")
|
|
58
|
+
if not npx:
|
|
59
|
+
raise RuntimeError("Installing Tavily skills requires Node.js (npx). Install Node.js, or rerun with --skip-skills.")
|
|
60
|
+
|
|
61
|
+
# npx writes to the shared directory, or straight into an agent's own
|
|
62
|
+
# directory when that agent is the only target.
|
|
63
|
+
specs = agent_specs()
|
|
64
|
+
skill_dirs = (Path.home() / ".agents" / "skills", *(specs[name].skills_dir for name in agents))
|
|
65
|
+
before = _snapshot_skills(skill_dirs)
|
|
66
|
+
|
|
67
|
+
# Keep every argument free of quotes and spaces: on Windows npx is a .cmd
|
|
68
|
+
# shim, so the command line is re-parsed by cmd.exe.
|
|
69
|
+
command = [
|
|
70
|
+
npx, "--yes", NPX_SKILLS_PACKAGE, "add", SKILLS_REPO,
|
|
71
|
+
"--skill", "*", "--global", "--agent", *agents, "--yes",
|
|
72
|
+
]
|
|
73
|
+
try:
|
|
74
|
+
completed = subprocess.run(
|
|
75
|
+
command,
|
|
76
|
+
stdin=subprocess.DEVNULL,
|
|
77
|
+
capture_output=True,
|
|
78
|
+
text=True,
|
|
79
|
+
timeout=_NPX_TIMEOUT_SECONDS,
|
|
80
|
+
check=False,
|
|
81
|
+
)
|
|
82
|
+
except subprocess.TimeoutExpired as exc:
|
|
83
|
+
raise RuntimeError("npx skills timed out while installing Tavily skills.") from exc
|
|
84
|
+
if completed.returncode != 0:
|
|
85
|
+
detail = (completed.stderr or completed.stdout).strip().splitlines()
|
|
86
|
+
raise RuntimeError(f"npx skills failed: {detail[-1] if detail else f'exit code {completed.returncode}'}")
|
|
87
|
+
|
|
88
|
+
return SkillsInstallResult(agents=agents, restart_required=_snapshot_skills(skill_dirs) != before)
|
|
89
|
+
|
|
90
|
+
|
|
91
|
+
def _snapshot_skills(skill_dirs: tuple[Path, ...]) -> dict[Path, str]:
|
|
92
|
+
# Key by path so a new agent link to an existing shared skill counts as a change.
|
|
93
|
+
return {
|
|
94
|
+
path: _directory_digest(path)
|
|
95
|
+
for skill_dir in skill_dirs
|
|
96
|
+
if skill_dir.is_dir()
|
|
97
|
+
for path in skill_dir.iterdir()
|
|
98
|
+
if path.is_dir()
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
|
|
102
|
+
def _directory_digest(path: Path) -> str:
|
|
103
|
+
digest = hashlib.sha256()
|
|
104
|
+
for file_path in sorted(item for item in path.rglob("*") if item.is_file()):
|
|
105
|
+
relative = file_path.relative_to(path).as_posix().encode("utf-8")
|
|
106
|
+
content = file_path.read_bytes()
|
|
107
|
+
digest.update(len(relative).to_bytes(4, "big"))
|
|
108
|
+
digest.update(relative)
|
|
109
|
+
digest.update(len(content).to_bytes(8, "big"))
|
|
110
|
+
digest.update(content)
|
|
111
|
+
return digest.hexdigest()
|
|
@@ -12,6 +12,16 @@ from tavily_cli import repl
|
|
|
12
12
|
from tavily_cli.cli import cli
|
|
13
13
|
|
|
14
14
|
|
|
15
|
+
def test_every_run_prints_the_deprecation_notice_on_stderr_only() -> None:
|
|
16
|
+
result = CliRunner().invoke(cli, ["--version", "--json"])
|
|
17
|
+
|
|
18
|
+
assert result.exit_code == 0
|
|
19
|
+
assert "deprecated" in result.stderr
|
|
20
|
+
assert "npx @tavily/cli init" in result.stderr
|
|
21
|
+
assert result.stdout.startswith("{")
|
|
22
|
+
assert "deprecated" not in result.stdout
|
|
23
|
+
|
|
24
|
+
|
|
15
25
|
def test_cli_help_promotes_guided_setup_and_browser_login() -> None:
|
|
16
26
|
result = CliRunner().invoke(cli, ["--help"])
|
|
17
27
|
|
|
@@ -28,7 +28,7 @@ def test_set_default_creates_both_files(homes: tuple[Path, Path]) -> None:
|
|
|
28
28
|
assert result.exit_code == 0, result.output
|
|
29
29
|
assert json.loads(claude.read_text()) == {"permissions": {"deny": ["WebSearch", "WebFetch"]}}
|
|
30
30
|
assert codex.read_text() == 'web_search = "disabled"\n'
|
|
31
|
-
assert all(r["changed"] for r in json.loads(result.
|
|
31
|
+
assert all(r["changed"] for r in json.loads(result.stdout)["results"])
|
|
32
32
|
|
|
33
33
|
|
|
34
34
|
def test_claude_round_trip_preserves_existing_settings(homes: tuple[Path, Path]) -> None:
|
|
@@ -132,7 +132,7 @@ def test_project_scope_writes_to_cwd(
|
|
|
132
132
|
assert codex.read_text() == 'web_search = "disabled"\n'
|
|
133
133
|
assert not global_claude.exists()
|
|
134
134
|
assert not global_codex.exists()
|
|
135
|
-
assert {r["scope"] for r in json.loads(result.
|
|
135
|
+
assert {r["scope"] for r in json.loads(result.stdout)["results"]} == {"project"}
|
|
136
136
|
|
|
137
137
|
result = CliRunner().invoke(cli, ["unset-default", "--claude", "--codex", "--project"])
|
|
138
138
|
|
|
@@ -0,0 +1,176 @@
|
|
|
1
|
+
"""Tests for one-shot CLI and agent skill setup."""
|
|
2
|
+
|
|
3
|
+
from __future__ import annotations
|
|
4
|
+
|
|
5
|
+
import json
|
|
6
|
+
import subprocess
|
|
7
|
+
from pathlib import Path
|
|
8
|
+
|
|
9
|
+
import pytest
|
|
10
|
+
from click.testing import CliRunner
|
|
11
|
+
|
|
12
|
+
from tavily_cli import init_skills as init_skills_module
|
|
13
|
+
from tavily_cli.cli import cli
|
|
14
|
+
from tavily_cli.commands import init as init_module
|
|
15
|
+
from tavily_cli.init_skills import SkillsInstallResult, detect_agents, install_agent_skills
|
|
16
|
+
|
|
17
|
+
SKILLS = ("tavily-search", "tavily-research")
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
def test_detect_agents_only_returns_existing_markers(tmp_path: Path) -> None:
|
|
21
|
+
(tmp_path / ".codex").mkdir()
|
|
22
|
+
(tmp_path / ".config" / "opencode").mkdir(parents=True)
|
|
23
|
+
|
|
24
|
+
assert detect_agents(tmp_path) == ("codex",)
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
def test_detect_agents_honors_custom_agent_directories(tmp_path: Path, monkeypatch: pytest.MonkeyPatch) -> None:
|
|
28
|
+
default_home = tmp_path / "home"
|
|
29
|
+
codex_home = tmp_path / "custom-codex"
|
|
30
|
+
claude_home = tmp_path / "custom-claude"
|
|
31
|
+
for path in (default_home, codex_home, claude_home):
|
|
32
|
+
path.mkdir()
|
|
33
|
+
monkeypatch.setattr(Path, "home", lambda: default_home)
|
|
34
|
+
monkeypatch.setenv("CODEX_HOME", str(codex_home))
|
|
35
|
+
monkeypatch.setenv("CLAUDE_CONFIG_DIR", str(claude_home))
|
|
36
|
+
|
|
37
|
+
assert detect_agents() == ("claude-code", "codex")
|
|
38
|
+
|
|
39
|
+
|
|
40
|
+
def _fake_npx_install(home: Path, calls: list[list[str]], *, returncode: int = 0, content: str = ""):
|
|
41
|
+
"""Mimic the skills.sh CLI writing skills to the shared directory."""
|
|
42
|
+
|
|
43
|
+
def run(command: list[str], **kwargs: object) -> subprocess.CompletedProcess[str]:
|
|
44
|
+
calls.append(command)
|
|
45
|
+
if returncode == 0:
|
|
46
|
+
for skill_name in SKILLS:
|
|
47
|
+
skill_dir = home / ".agents" / "skills" / skill_name
|
|
48
|
+
skill_dir.mkdir(parents=True, exist_ok=True)
|
|
49
|
+
(skill_dir / "SKILL.md").write_text(f"---\nname: {skill_name}\n---\n{content}")
|
|
50
|
+
return subprocess.CompletedProcess(command, returncode, "", "Error: repo not found\n")
|
|
51
|
+
|
|
52
|
+
return run
|
|
53
|
+
|
|
54
|
+
|
|
55
|
+
def test_agent_skills_install_runs_npx(tmp_path: Path, monkeypatch: pytest.MonkeyPatch) -> None:
|
|
56
|
+
monkeypatch.setattr(Path, "home", lambda: tmp_path)
|
|
57
|
+
monkeypatch.setattr(init_skills_module.shutil, "which", lambda name: "/usr/bin/npx")
|
|
58
|
+
calls: list[list[str]] = []
|
|
59
|
+
monkeypatch.setattr(init_skills_module.subprocess, "run", _fake_npx_install(tmp_path, calls))
|
|
60
|
+
|
|
61
|
+
agents = ("claude-code", "codex", "cursor")
|
|
62
|
+
first = install_agent_skills(agents)
|
|
63
|
+
|
|
64
|
+
command = calls[0]
|
|
65
|
+
assert command[:5] == ["/usr/bin/npx", "--yes", "skills@1.7.4", "add", "tavily-ai/skills"]
|
|
66
|
+
assert command[command.index("--agent") + 1 : command.index("--agent") + 4] == list(agents)
|
|
67
|
+
assert "--global" in command and command.count("--yes") == 2
|
|
68
|
+
assert all(" " not in arg and '"' not in arg for arg in command)
|
|
69
|
+
assert first.restart_required
|
|
70
|
+
|
|
71
|
+
second = install_agent_skills(agents)
|
|
72
|
+
|
|
73
|
+
assert not second.restart_required
|
|
74
|
+
|
|
75
|
+
monkeypatch.setattr(init_skills_module.subprocess, "run", _fake_npx_install(tmp_path, calls, content="new"))
|
|
76
|
+
third = install_agent_skills(agents)
|
|
77
|
+
|
|
78
|
+
assert third.restart_required
|
|
79
|
+
|
|
80
|
+
|
|
81
|
+
def test_agent_skills_install_counts_new_agent_links(tmp_path: Path, monkeypatch: pytest.MonkeyPatch) -> None:
|
|
82
|
+
monkeypatch.setattr(Path, "home", lambda: tmp_path)
|
|
83
|
+
monkeypatch.delenv("CLAUDE_CONFIG_DIR", raising=False)
|
|
84
|
+
monkeypatch.setattr(init_skills_module.shutil, "which", lambda name: "/usr/bin/npx")
|
|
85
|
+
calls: list[list[str]] = []
|
|
86
|
+
monkeypatch.setattr(init_skills_module.subprocess, "run", _fake_npx_install(tmp_path, calls))
|
|
87
|
+
install_agent_skills(("codex",))
|
|
88
|
+
|
|
89
|
+
def link_skills(command: list[str], **kwargs: object) -> subprocess.CompletedProcess[str]:
|
|
90
|
+
for skill_name in SKILLS:
|
|
91
|
+
link = tmp_path / ".claude" / "skills" / skill_name
|
|
92
|
+
link.parent.mkdir(parents=True, exist_ok=True)
|
|
93
|
+
link.symlink_to(tmp_path / ".agents" / "skills" / skill_name, target_is_directory=True)
|
|
94
|
+
return subprocess.CompletedProcess(command, 0, "", "")
|
|
95
|
+
|
|
96
|
+
monkeypatch.setattr(init_skills_module.subprocess, "run", link_skills)
|
|
97
|
+
|
|
98
|
+
assert install_agent_skills(("claude-code", "codex")).restart_required
|
|
99
|
+
|
|
100
|
+
|
|
101
|
+
def test_agent_skills_install_requires_npx(monkeypatch: pytest.MonkeyPatch) -> None:
|
|
102
|
+
monkeypatch.setattr(init_skills_module.shutil, "which", lambda name: None)
|
|
103
|
+
|
|
104
|
+
with pytest.raises(RuntimeError, match="requires Node.js"):
|
|
105
|
+
install_agent_skills(("codex",))
|
|
106
|
+
|
|
107
|
+
|
|
108
|
+
def test_agent_skills_install_reports_npx_failure(tmp_path: Path, monkeypatch: pytest.MonkeyPatch) -> None:
|
|
109
|
+
monkeypatch.setattr(Path, "home", lambda: tmp_path)
|
|
110
|
+
monkeypatch.setattr(init_skills_module.shutil, "which", lambda name: "/usr/bin/npx")
|
|
111
|
+
calls: list[list[str]] = []
|
|
112
|
+
monkeypatch.setattr(init_skills_module.subprocess, "run", _fake_npx_install(tmp_path, calls, returncode=1))
|
|
113
|
+
|
|
114
|
+
with pytest.raises(RuntimeError, match="npx skills failed: Error: repo not found"):
|
|
115
|
+
install_agent_skills(("codex",))
|
|
116
|
+
|
|
117
|
+
|
|
118
|
+
def test_init_skips_skills_without_detected_agents(monkeypatch: pytest.MonkeyPatch) -> None:
|
|
119
|
+
monkeypatch.setattr(init_module, "detect_agents", lambda: ())
|
|
120
|
+
monkeypatch.setattr(init_module, "install_agent_skills", lambda agents: pytest.fail("skills installed"))
|
|
121
|
+
monkeypatch.setattr(init_module, "_verify_cli", lambda: True)
|
|
122
|
+
monkeypatch.setattr(init_module, "_verify_live_search", lambda: True)
|
|
123
|
+
|
|
124
|
+
result = CliRunner().invoke(cli, ["init", "--json"], env={"TAVILY_API_KEY": "tvly-test"})
|
|
125
|
+
|
|
126
|
+
assert result.exit_code == 0
|
|
127
|
+
assert json.loads(result.stdout)["skills"]["skipped"] is True
|
|
128
|
+
|
|
129
|
+
|
|
130
|
+
def test_init_json_reuses_environment_auth(monkeypatch: pytest.MonkeyPatch) -> None:
|
|
131
|
+
monkeypatch.setattr(init_module, "detect_agents", lambda: ("codex",))
|
|
132
|
+
monkeypatch.setattr(
|
|
133
|
+
init_module,
|
|
134
|
+
"install_agent_skills",
|
|
135
|
+
lambda agents: SkillsInstallResult(agents, True),
|
|
136
|
+
)
|
|
137
|
+
monkeypatch.setattr(init_module, "_verify_cli", lambda: True)
|
|
138
|
+
monkeypatch.setattr(init_module, "_verify_live_search", lambda: True)
|
|
139
|
+
|
|
140
|
+
result = CliRunner().invoke(cli, ["init", "--json"], env={"TAVILY_API_KEY": "tvly-test"})
|
|
141
|
+
|
|
142
|
+
assert result.exit_code == 0
|
|
143
|
+
output = json.loads(result.stdout)
|
|
144
|
+
assert output["ok"] is True
|
|
145
|
+
assert output["auth"] == {"authenticated": True, "method": "env"}
|
|
146
|
+
assert output["skills"]["agents"] == ["codex"]
|
|
147
|
+
assert output["skills"]["restart_required"] is True
|
|
148
|
+
assert output["skills"]["source"] == "tavily-ai/skills"
|
|
149
|
+
assert output["verification"]["live_search"] is True
|
|
150
|
+
|
|
151
|
+
|
|
152
|
+
def test_init_noninteractive_auth_failure_is_json(monkeypatch: pytest.MonkeyPatch) -> None:
|
|
153
|
+
from tavily_cli import config
|
|
154
|
+
|
|
155
|
+
monkeypatch.setattr(config, "get_api_key", lambda: None)
|
|
156
|
+
result = CliRunner().invoke(cli, ["init", "--skip-skills", "--json"])
|
|
157
|
+
|
|
158
|
+
assert result.exit_code == 3
|
|
159
|
+
output = json.loads(result.stdout)
|
|
160
|
+
assert output["ok"] is False
|
|
161
|
+
assert output["error"]["stage"] == "auth"
|
|
162
|
+
assert output["skills"]["skipped"] is True
|
|
163
|
+
|
|
164
|
+
|
|
165
|
+
def test_init_live_search_failure_exits_four(monkeypatch: pytest.MonkeyPatch) -> None:
|
|
166
|
+
from tavily_cli import config
|
|
167
|
+
|
|
168
|
+
monkeypatch.setattr(config, "get_api_key", lambda: None)
|
|
169
|
+
monkeypatch.setattr(init_module, "_verify_cli", lambda: True)
|
|
170
|
+
monkeypatch.setattr(init_module, "_verify_live_search", lambda: False)
|
|
171
|
+
|
|
172
|
+
result = CliRunner().invoke(cli, ["init", "--skip-auth", "--skip-skills", "--json"])
|
|
173
|
+
|
|
174
|
+
assert result.exit_code == 4
|
|
175
|
+
output = json.loads(result.stdout)
|
|
176
|
+
assert output["error"]["stage"] == "live_search"
|
|
@@ -97,7 +97,7 @@ def test_multi_query_runs_each_with_shared_options(fake_client):
|
|
|
97
97
|
assert result.exit_code == 0, result.output
|
|
98
98
|
assert sorted(q for q, _ in fake_client.calls) == ["one", "two"]
|
|
99
99
|
assert all(kw["search_depth"] == "advanced" for _, kw in fake_client.calls)
|
|
100
|
-
lines = result.
|
|
100
|
+
lines = result.stdout.splitlines()
|
|
101
101
|
assert lines[0] == "=== [1/2] one" and lines[1] == "1. T one" and "=== [2/2] two" in lines
|
|
102
102
|
|
|
103
103
|
|
|
@@ -112,7 +112,7 @@ def test_multi_query_keeps_keyless_cap_details(fake_client, monkeypatch):
|
|
|
112
112
|
|
|
113
113
|
monkeypatch.setattr(fake_client, "search", search)
|
|
114
114
|
result = CliRunner().invoke(cli, ["search", "ok", "capped", "--json"])
|
|
115
|
-
error = json.loads(result.
|
|
115
|
+
error = json.loads(result.stdout)[1]["error"]
|
|
116
116
|
assert error["code"] == "keyless_cap" and error["retry_after_seconds"] == 60 and error["next_actions"]
|
|
117
117
|
result = CliRunner().invoke(cli, ["search", "capped", "capped"])
|
|
118
118
|
assert result.exit_code == 3 and "tvly login" in result.output
|