scripts/read_marketplace_name.py
354 tokens · o200k_base · 1,644 bytes
Source excerpt starting at line 1.#!/usr/bin/env python3"""Print the top-level marketplace name from any marketplace.json file.""" from __future__ import annotations import argparseimport jsonimport sysfrom pathlib import Path sys.path.insert(0, str(Path(__file__).resolve().parent)) from identifier_validation import validate_marketplace_name def default_marketplace_path() -> Path: return Path.home() / ".agents" / "plugins" / "marketplace.json" def parse_args() -> argparse.Namespace: parser = argparse.ArgumentParser( description=( "Print the top-level marketplace name from marketplace.json. Defaults to the personal " "marketplace path under the current home directory." ) ) parser.add_argument( "--marketplace-path", default=str(default_marketplace_path()), help="Path to marketplace.json", ) return parser.parse_args() def main() -> None: args = parse_args() marketplace_path = Path(args.marketplace_path).expanduser().resolve() payload = json.loads(marketplace_path.read_text(encoding="utf-8")) if not isinstance(payload, dict): raise ValueError(f"{marketplace_path} must contain a JSON object.") name = payload.get("name") if not isinstance(name, str) or not name.strip(): raise ValueError(f"{marketplace_path} must contain a non-empty string 'name'.") validate_marketplace_name(name) print(name) if __name__ == "__main__": try: main() except Exception as err: # noqa: BLE001 - CLI should surface a single clear message. print(str(err), file=sys.stderr) raise SystemExit(1) from err
Referenced from SKILL.md
Source excerpt starting at line 74.```bashpython3 scripts/read_marketplace_name.pypython3 scripts/update_plugin_cachebuster.py <plugin-path>
Source excerpt starting at line 118.- Marketplace names must match `[A-Za-z0-9_-]+`.- For existing marketplaces, always validate names with `scripts/read_marketplace_name.py`; stop if validation fails. With no argument it reads the default personal marketplace; with an explicit