Fix update-readme CLI and allow admin to update any tool's README

Make tool argument optional when --all is used, add validation for
single-tool mode without tool name, and allow admin role to update
READMEs for tools owned by any publisher (e.g. official namespace).

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
rob 2026-02-01 01:43:51 -04:00
parent e83c9c15f3
commit f24450c19c
3 changed files with 6 additions and 2 deletions

View File

@ -192,7 +192,7 @@ def main():
# registry update-readme
p_reg_update_readme = registry_sub.add_parser("update-readme", help="Update README for a published tool")
p_reg_update_readme.add_argument("tool", help="Tool name (local name, will resolve owner)")
p_reg_update_readme.add_argument("tool", nargs="?", default="", help="Tool name (local name, will resolve owner)")
p_reg_update_readme.add_argument("--all", action="store_true", dest="update_all", help="Update README for all published tools that have a local README.md")
p_reg_update_readme.set_defaults(func=cmd_registry)

View File

@ -688,6 +688,9 @@ def _cmd_registry_update_readme(args):
# Single tool mode
tool_name = args.tool
if not tool_name:
print("Error: tool name required (or use --all)", file=sys.stderr)
return 1
tool_dir = TOOLS_DIR / tool_name
config_path = tool_dir / "config.yaml"
readme_path = tool_dir / "README.md"

View File

@ -2819,7 +2819,8 @@ def create_app() -> Flask:
@require_token
def update_tool_readme(owner: str, name: str) -> Response:
"""Update the README for an existing tool without affecting config or hash."""
if g.current_publisher["slug"] != owner:
is_admin = g.current_publisher.get("role") == "admin"
if g.current_publisher["slug"] != owner and not is_admin:
return error_response("FORBIDDEN", "You can only update your own tools", 403)
data = request.get_json() or {}