Skip to content

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

Python

update cli-hub

yuhao42fc5c096dde
diff --git a/.github/scripts/tests/test_update_registry_dates.py b/.github/scripts/tests/test_update_registry_dates.py
new file mode 100644
index 000000000..894ee5627
--- /dev/null
+++ b/.github/scripts/tests/test_update_registry_dates.py
@@ -0,0 +1,56 @@
+from __future__ import annotations
+
+import importlib.util
+from pathlib import Path
+
+
+SCRIPT_PATH = Path(__file__).resolve().parents[1] / "update_registry_dates.py"
+SPEC = importlib.util.spec_from_file_location("update_registry_dates", SCRIPT_PATH)
+MODULE = importlib.util.module_from_spec(SPEC)
+assert SPEC and SPEC.loader
+SPEC.loader.exec_module(MODULE)
+
+
+def test_resolve_harness_path_prefers_install_subdirectory_for_qgis():
+ cli = {
+ "name": "qgis",
+ "install_cmd": "pip install git+https://github.com/HKUDS/CLI-Anything.git#subdirectory=QGIS/agent-harness",
+ "skill_md": "QGIS/agent-harness/cli_anything/qgis/skills/SKILL.md",
+ }
+
+ path = MODULE.resolve_harness_path(cli, MODULE.REPO_ROOT)
+
+ assert path == MODULE.REPO_ROOT / "QGIS" / "agent-harness"
+
+
+def test_resolve_harness_path_handles_underscore_directory_names():
+ cli = {
+ "name": "unimol_tools",
+ "install_cmd": "pip install git+https://github.com/HKUDS/CLI-Anything.git#subdirectory=unimol_tools/agent-harness",
+ "skill_md": "skills/cli-anything-unimol-tools/SKILL.md",
+ }
+
+ path = MODULE.resolve_harness_path(cli, MODULE.REPO_ROOT)
+
+ assert path == MODULE.REPO_ROOT / "unimol_tools" / "agent-harness"
+
+
+def test_extract_external_source_url_from_cargo_git_install():
+ cli = {
+ "name": "clibrowser",
+ "install_cmd": "cargo install --git https://github.com/allthingssecurity/clibrowser.git --tag v0.1.0 --locked",
+ "source_url": None,
+ }
+
+ source_url = MODULE.extract_external_source_url(cli)
+
+ assert source_url == "https://github.com/allthingssecurity/clibrowser"
+
+
+def test_extract_npm_package_supports_scoped_package_names():
+ cli = {
+ "npm_package": "@sentry/cli",
+ "install_cmd": "npm install -g @sentry/cli",
+ }
+
+ assert MODULE._extract_npm_package(cli) == "@sentry/cli"
diff --git a/.github/scripts/update_registry_dates.py b/.github/scripts/update_registry_dates.py
index 228afce39..d20374547 100644
--- a/.github/scripts/update_registry_dates.py
+++ b/.github/scripts/update_registry_dates.py
@@ -1,105 +1,278 @@
#!/usr/bin/env python3
-"""Update registry-dates.json with last modified dates from harness directories."""
+"""Update registry-dates.json with meaningful per-CLI update dates."""
+
+from __future__ import annotations
+
import json
import re
+import shlex
import subprocess
+import urllib.parse
import urllib.request
+from datetime import UTC, datetime
+from email.utils import parsedate_to_datetime
from pathlib import Path
-from datetime import datetime
-def get_last_modified(harness_path):
- """Get the most recent git commit date for files in a harness directory."""
+REPO_ROOT = Path(__file__).resolve().parents[2]
+USER_AGENT = "CLI-Anything registry date updater"
+GITHUB_REPO_RE = re.compile(r"https://github\.com/([^/]+/[^/#?]+?)(?:\.git)?(?:[/?#].*)?$")
+GIT_URL_RE = re.compile(r"https://github\.com/[^\s#]+")
+SUBDIRECTORY_RE = re.compile(r"#subdirectory=([^\s]+)")
+
+
+def _fetch_json(url: str) -> dict | None:
+ try:
+ req = urllib.request.Request(
+ url,
+ headers={
+ "Accept": "application/json",
+ "User-Agent": USER_AGENT,
+ },
+ )
+ with urllib.request.urlopen(req, timeout=10) as resp:
+ return json.loads(resp.read())
+ except Exception:
+ return None
+
+
+def _fetch_last_modified(url: str) -> str | None:
+ try:
+ req = urllib.request.Request(url, headers={"User-Agent": USER_AGENT}, method="HEAD")
+ with urllib.request.urlopen(req, timeout=10) as resp:
+ last_modified = resp.headers.get("Last-Modified")
+ if not last_modified:
+ return None
+ return parsedate_to_datetime(last_modified).astimezone(UTC).strftime("%Y-%m-%d")
+ except Exception:
+ return None
+
+
+def _git_log_timestamp(target_path: Path, excluded_globs: tuple[str, ...] = ()) -> int | None:
try:
+ relative_target = target_path.relative_to(REPO_ROOT).as_posix()
+ cmd = ["git", "log", "-1", "--format=%ct", "--", relative_target]
+ cmd.extend(f":(exclude,glob){pattern}" for pattern in excluded_globs)
result = subprocess.run(
- ['git', 'log', '-1', '--format=%ct', '--', str(harness_path)],
+ cmd,
capture_output=True,
text=True,
- check=True
+ check=True,
+ cwd=REPO_ROOT,
)
- timestamp = int(result.stdout.strip())
- return datetime.fromtimestamp(timestamp).strftime('%Y-%m-%d')
+ return int(result.stdout.strip())
except (subprocess.CalledProcessError, ValueError):
return None
-def get_github_repo_date(source_url):
+def get_last_modified(target_path: Path) -> str | None:
+ """Get the most recent git commit date for CLI-specific files in a repo path."""
+ relative_target = target_path.relative_to(REPO_ROOT).as_posix()
+ shared_file_globs = (
+ f"{relative_target}/cli_anything/**/utils/repl_skin.py",
+ f"{relative_target}/cli_anything/**/skills/SKILL.md",
+ f"{relative_target}/cli_anything/**/SKILL.md",
+ )
+
+ timestamp = _git_log_timestamp(target_path, excluded_globs=shared_file_globs)
+ if timestamp is None:
+ timestamp = _git_log_timestamp(target_path)
+ if timestamp is None:
+ return None
+
+ try:
+ return datetime.fromtimestamp(timestamp, tz=UTC).strftime("%Y-%m-%d")
+ except (OverflowError, OSError, ValueError):
+ return None
+
+
+def get_github_repo_date(source_url: str) -> str | None:
"""Get the last push date from a GitHub repo via the API."""
- # Extract owner/repo from URL like https://github.com/owner/repo
- match = re.match(r'https://github\.com/([^/]+/[^/]+?)(?:\.git)?$', source_url)
+ match = GITHUB_REPO_RE.match(source_url)
if not match:
return None
repo_slug = match.group(1)
- api_url = f'https://api.github.com/repos/{repo_slug}'
+ data = _fetch_json(f"https://api.github.com/repos/{repo_slug}")
+ if not data:
+ return None
+ pushed_at = data.get("pushed_at")
+ return pushed_at[:10] if pushed_at else None
+
+
+def _extract_pypi_package(install_cmd: str) -> str | None:
+ if not install_cmd:
+ return None
try:
- req = urllib.request.Request(api_url, headers={'Accept': 'application/vnd.github.v3+json'})
- with urllib.request.urlopen(req, timeout=10) as resp:
- data = json.loads(resp.read())
- pushed_at = data.get('pushed_at') # e.g. "2026-04-13T08:00:00Z"
- if pushed_at:
- return pushed_at[:10]
- except Exception:
- pass
+ tokens = shlex.split(install_cmd)
+ except ValueError:
+ return None
+
+ if not tokens:
+ return None
+
+ install_index = None
+ if tokens[:3] == ["python3", "-m", "pip"]:
+ install_index = 3
+ elif tokens[0] in {"pip", "pip3"}:
+ install_index = 1
+
+ if install_index is None or install_index >= len(tokens) or tokens[install_index] != "install":
+ return None
+
+ for token in tokens[install_index + 1 :]:
+ if token.startswith("-"):
+ continue
+ if "://" in token or token.startswith("git+"):
+ return None
+ return token
return None
-def get_pypi_date(install_cmd):
- """Get the last release date from PyPI for a simple pip package."""
- # Only works for plain "pip install <package>" commands (not git+ URLs)
- match = re.match(r'^pip install ([a-zA-Z0-9_-]+)$', install_cmd)
- if not match:
+def get_pypi_date(install_cmd: str) -> str | None:
+ """Get the last release date from PyPI for a pip-installable package."""
+ package = _extract_pypi_package(install_cmd)
+ if not package:
return None
- package = match.group(1)
- api_url = f'https://pypi.org/pypi/{package}/json'
- try:
- with urllib.request.urlopen(api_url, timeout=10) as resp:
- data = json.loads(resp.read())
- # Get the upload time of the latest version
- latest = data.get('info', {}).get('version')
- releases = data.get('releases', {})
- if latest and releases.get(latest):
- upload_time = releases[latest][0].get('upload_time') # e.g. "2026-04-10T12:00:00"
- if upload_time:
- return upload_time[:10]
- except Exception:
- pass
+ data = _fetch_json(f"https://pypi.org/pypi/{package}/json")
+ if not data:
+ return None
+ latest = data.get("info", {}).get("version")
+ releases = data.get("releases", {})
+ release_files = releases.get(latest or "", [])
+ if not release_files:
+ return None
+ upload_time = release_files[0].get("upload_time") or release_files[0].get("upload_time_iso_8601")
+ return upload_time[:10] if upload_time else None
+
+
+def _extract_npm_package(cli: dict) -> str | None:
+ package = cli.get("npm_package")
+ if package:
+ return package
+
+ install_cmd = cli.get("install_cmd", "")
+ match = re.search(r"npm install -g (\S+)", install_cmd)
+ return match.group(1) if match else None
+
+
+def get_npm_date(cli: dict) -> str | None:
+ """Get the latest publish date from the npm registry."""
+ package = _extract_npm_package(cli)
+ if not package:
+ return None
+ encoded = urllib.parse.quote(package, safe="")
+ data = _fetch_json(f"https://registry.npmjs.org/{encoded}")
+ if not data:
+ return None
+ latest = data.get("dist-tags", {}).get("latest")
+ published = data.get("time", {}).get(latest or "")
+ return published[:10] if published else None
+
+
+def _extract_install_subdirectory(cli: dict) -> str | None:
+ install_cmd = cli.get("install_cmd") or ""
+ match = SUBDIRECTORY_RE.search(install_cmd)
+ return match.group(1) if match else None
+
+
+def _extract_skill_subdirectory(cli: dict) -> str | None:
+ skill_md = cli.get("skill_md")
+ if not skill_md or skill_md.startswith("http"):
+ return None
+ marker = "/agent-harness/"
+ if marker not in skill_md:
+ return None
+ return skill_md.split(marker, 1)[0] + marker.rstrip("/")
+
+
+def resolve_harness_path(cli: dict, repo_root: Path) -> Path | None:
+ """Resolve the on-disk harness path for an in-repo CLI entry."""
+ for relative in (_extract_install_subdirectory(cli), _extract_skill_subdirectory(cli)):
+ if relative:
+ candidate = repo_root / relative
+ if candidate.exists():
+ return candidate
+
+ candidate_dirs = []
+ for name in (cli.get("name"), cli.get("name", "").replace("-", "_"), cli.get("name", "").replace("_", "-")):
+ if name and name not in candidate_dirs:
+ candidate_dirs.append(name)
+
+ for directory in candidate_dirs:
+ candidate = repo_root / directory / "agent-harness"
+ if candidate.exists():
+ return candidate
+ return None
+
+
+def extract_external_source_url(cli: dict) -> str | None:
+ """Best-effort source URL discovery for third-party CLIs."""
+ source_url = cli.get("source_url")
+ if source_url:
+ return source_url
+
+ install_cmd = cli.get("install_cmd") or ""
+ git_match = GIT_URL_RE.search(install_cmd)
+ if git_match:
+ return git_match.group(0).removesuffix(".git")
+
+ for field in ("homepage", "docs_url"):
+ value = cli.get(field)
+ if value and "github.com/" in value:
+ return value
return None
-def get_external_date(cli):
- """Get the last update date for an external CLI, trying GitHub API then PyPI."""
- source_url = cli.get('source_url')
+def get_external_date(cli: dict) -> str | None:
+ """Get a useful update date for external/public CLIs."""
+ source_url = extract_external_source_url(cli)
if source_url:
date = get_github_repo_date(source_url)
if date:
return date
- # Fallback to PyPI
- return get_pypi_date(cli.get('install_cmd', ''))
-
-
-def main():
- repo_root = Path(__file__).parent.parent.parent
- registry_path = repo_root / 'registry.json'
- dates_path = repo_root / 'docs' / 'hub' / 'registry-dates.json'
-
- with open(registry_path) as f:
- data = json.load(f)
-
- dates = {}
- for cli in data['clis']:
- if cli.get('source_url'):
- # External repo: query GitHub API / PyPI for real update date
- dates[cli['name']] = get_external_date(cli)
- else:
- # In-repo: use the last commit in the harness directory
- harness_path = repo_root / cli['name'] / 'agent-harness'
- if harness_path.exists():
- dates[cli['name']] = get_last_modified(harness_path)
-
- with open(dates_path, 'w') as f:
+
+ package_manager = (cli.get("package_manager") or "").lower()
+ if package_manager == "npm":
+ date = get_npm_date(cli)
+ if date:
+ return date
+
+ date = get_pypi_date(cli.get("install_cmd", ""))
+ if date:
+ return date
+
+ for field in ("homepage", "docs_url"):
+ url = cli.get(field)
+ if url:
+ date = _fetch_last_modified(url)
+ if date:
+ return date
+ return None
+
+
+def get_cli_date(cli: dict, repo_root: Path) -> str | None:
+ harness_path = resolve_harness_path(cli, repo_root)
+ if harness_path:
+ return get_last_modified(harness_path)
+ return get_external_date(cli)
+
+
+def _load_registry(path: Path) -> list[dict]:
+ with path.open(encoding="utf-8") as f:
+ return json.load(f)["clis"]
+
+
+def main() -> None:
+ dates_path = REPO_ROOT / "docs" / "hub" / "registry-dates.json"
+ all_clis = _load_registry(REPO_ROOT / "registry.json") + _load_registry(REPO_ROOT / "public_registry.json")
+
+ dates = {cli["name"]: get_cli_date(cli, REPO_ROOT) for cli in all_clis}
+
+ with dates_path.open("w", encoding="utf-8") as f:
json.dump(dates, f, indent=2)
print(f"Updated dates for {len(dates)} CLI entries")
-if __name__ == '__main__':
+
+if __name__ == "__main__":
main()
diff --git a/docs/hub/index-modern.html b/docs/hub/index-modern.html
index a74591d42..74a38dc49 100644
--- a/docs/hub/index-modern.html
+++ b/docs/hub/index-modern.html
@@ -1985,13 +1985,17 @@
<span class="control-kicker">Sort mode</span>
</div>
<button class="sort-trigger" id="sort-trigger-public" type="button" aria-haspopup="listbox" aria-expanded="false">
- <span class="sort-current" id="sort-current-public">Name</span>
+ <span class="sort-current" id="sort-current-public">Last updated</span>
<span class="sort-chevron">
<svg viewBox="0 0 24 24" width="14" height="14" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><polyline points="6 9 12 15 18 9"/></svg>
</span>
</button>
<div class="sort-menu" id="sort-menu-public" role="listbox" hidden>
- <button class="sort-option" type="button" data-deck="public" data-value="name" role="option" aria-selected="true">
+ <button class="sort-option" type="button" data-deck="public" data-value="updated" role="option" aria-selected="true">
+ <span><strong>Last updated</strong><span>Put the freshest public CLIs first.</span></span>
+ <span class="sort-option-mark">✓</span>
+ </button>
+ <button class="sort-option" type="button" data-deck="public" data-value="name" role="option" aria-selected="false">
<span><strong>Name</strong><span>Alphabetical list for known public tools.</span></span>
<span class="sort-option-mark">✓</span>
</button>
@@ -2098,7 +2102,7 @@
const deckState = {
harness: { filter: 'all', sort: 'updated', query: '' },
- public: { filter: 'all', sort: 'name', query: '' },
+ public: { filter: 'all', sort: 'updated', query: '' },
};
async function fetchJson(urls) {
@@ -2156,6 +2160,7 @@
if (publicData && publicData.clis) {
publicClis = publicData.clis;
+ if (dates) publicClis.forEach((c) => { c.last_modified = dates[c.name]; });
}
const totalClis = harnessClis.length + publicClis.length;
@@ -2459,6 +2464,7 @@
function renderPublicCard(c) {
const isBundled = (c.install_strategy || c.package_manager) === 'bundled';
+ const dateHtml = c.last_modified ? '<div class="card-date">Updated ' + esc(c.last_modified) + '</div>' : '';
const requiresHtml = c.requires
? '<div class="card-requires"><strong>Requires</strong> ' + esc(c.requires) + '</div>'
: '';
@@ -2498,6 +2504,7 @@
<div class="card-title">${titleHtml}</div>
<div class="card-desc">${esc(c.description)}</div>
<div class="card-submeta">
+ ${dateHtml}
${requiresHtml}
${directCmdHtml}
${installNotesHtml}
diff --git a/docs/hub/index.html b/docs/hub/index.html
index 4bdd170ae..5e853b05c 100644
--- a/docs/hub/index.html
+++ b/docs/hub/index.html
@@ -1887,6 +1887,7 @@
<div class="controls">
<input class="search" type="text" placeholder="Search public CLIs..." id="search-public">
<select class="sort-select" id="sort-public">
+ <option value="updated">Last updated</option>
<option value="name">Name</option>
<option value="category">Category</option>
</select>
@@ -1986,7 +1987,7 @@
// Per-deck state
const deckState = {
harness: { filter: 'all', sort: 'updated', query: '' },
- public: { filter: 'all', sort: 'name', query: '' },
+ public: { filter: 'all', sort: 'updated', query: '' },
};
async function fetchJson(urls) {
@@ -2042,6 +2043,7 @@
if (publicData && publicData.clis) {
publicClis = publicData.clis;
+ if (dates) publicClis.forEach(c => c.last_modified = dates[c.name]);
}
// Update counts
@@ -2393,6 +2395,9 @@
function renderNpmCard(c) {
const isBundled = (c.install_strategy || c.package_manager) === 'bundled';
+ const dateHtml = c.last_modified
+ ? `<div class="card-date">Updated ${esc(c.last_modified)}</div>`
+ : '';
const requiresHtml = c.requires
? `<div class="card-requires"><strong>Requires</strong> ${esc(c.requires)}</div>`
: '';
@@ -2439,6 +2444,7 @@
</div>
</div>
<div class="card-desc">${esc(c.description)}</div>
+ ${dateHtml}
${requiresHtml}
${cliHubInstallHtml}
${publicNotesHtml}