Skip to content

Commit 5407772

Browse files
committed
new: nerve agents now shows a list of available agents from the index
1 parent 6ce9145 commit 5407772

File tree

1 file changed

+39
-5
lines changed

1 file changed

+39
-5
lines changed

nerve/cli/agents.py

Lines changed: 39 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
import asyncio
21
import pathlib
32
import typing as t
43

4+
import requests
55
import typer
66
from termcolor import colored
77

@@ -20,25 +20,59 @@
2020

2121
@cli.command(
2222
context_settings={"help_option_names": ["-h", "--help"]},
23-
help="List the agents available locally in $HOME/.nerve/agents or a custom path.",
23+
help="List locally installed agents and available ones from the awesomeagents.ai index.",
2424
)
2525
def agents(
2626
path: t.Annotated[
2727
pathlib.Path,
2828
typer.Argument(help="Path to the agent or workflow to create"),
2929
] = DEFAULT_AGENTS_LOAD_PATH,
30+
offline: t.Annotated[
31+
bool,
32+
typer.Option("--offline", "-o", help="Only show installed agents."),
33+
] = False,
3034
) -> None:
3135
print(f"🧠 nerve v{nerve.__version__}")
3236

33-
asyncio.run(show_agents(path))
37+
_show_installed_agents(path)
3438

39+
if not offline:
40+
agents = _fetch_awesome_agents()
41+
if agents:
42+
_show_awesome_agents(agents)
3543

36-
async def show_agents(path: pathlib.Path) -> None:
44+
45+
def _fetch_awesome_agents() -> list[dict] | None:
46+
try:
47+
response = requests.get("https://api.awesomeagents.ai/index.json")
48+
response.raise_for_status()
49+
agents = response.json()
50+
return [agent for agent in agents if "nerve" in agent.get("stack", [])]
51+
except Exception:
52+
return None
53+
54+
55+
def _show_awesome_agents(agents: list[dict]) -> None:
56+
print("🔍 Available from the index:\n")
57+
for agent in agents:
58+
repo = agent["repo"]
59+
# Extract username/repo from the repository URL
60+
repo_parts = repo.split("/")
61+
if len(repo_parts) >= 2:
62+
username_repo = f"{repo_parts[-2]}/{repo_parts[-1]}"
63+
else:
64+
username_repo = repo
65+
print(f" {colored(username_repo, 'white', attrs=['bold'])} - {agent['description']}")
66+
67+
print()
68+
69+
70+
def _show_installed_agents(path: pathlib.Path) -> None:
3771
anything = False
3872

3973
if path.exists() and path.is_dir():
4074
print()
41-
print(f"📁 agents in {path.absolute()}:")
75+
print(f"📁 Installed in {path.absolute()}:\n")
4276

4377
for item in path.iterdir():
4478
if Workflow.is_workflow(item):

0 commit comments

Comments
 (0)