Add status polling and CLI status command for tool moderation
- Add QTimer polling every 30s when tools are pending/changes_requested - Display changes_requested (⚠) and rejected (✗) states in tool tree - Show moderator feedback in tool info panel - Add `cmdforge registry status <tool>` CLI command with --sync flag - Update _sync_tool to persist registry_feedback field Co-Authored-By: Claude Opus 4.5 <[email protected]>
This commit is contained in:
@@ -186,6 +186,12 @@ def main():
|
||||
p_reg_mytools = registry_sub.add_parser("my-tools", help="List your published tools")
|
||||
p_reg_mytools.set_defaults(func=cmd_registry)
|
||||
|
||||
# registry status
|
||||
p_reg_status = registry_sub.add_parser("status", help="Check moderation status of a tool")
|
||||
p_reg_status.add_argument("tool", help="Tool name to check status for")
|
||||
p_reg_status.add_argument("--sync", action="store_true", help="Sync status from server and update local config")
|
||||
p_reg_status.set_defaults(func=cmd_registry)
|
||||
|
||||
# registry browse
|
||||
p_reg_browse = registry_sub.add_parser("browse", help="Browse tools (TUI)")
|
||||
p_reg_browse.set_defaults(func=cmd_registry)
|
||||
|
||||
@@ -30,6 +30,8 @@ def cmd_registry(args):
|
||||
return _cmd_registry_publish(args)
|
||||
elif args.registry_cmd == "my-tools":
|
||||
return _cmd_registry_my_tools(args)
|
||||
elif args.registry_cmd == "status":
|
||||
return _cmd_registry_status(args)
|
||||
elif args.registry_cmd == "browse":
|
||||
return _cmd_registry_browse(args)
|
||||
elif args.registry_cmd == "config":
|
||||
@@ -45,7 +47,8 @@ def cmd_registry(args):
|
||||
print(" update Update local index cache")
|
||||
print(" publish [path] Publish a tool")
|
||||
print(" my-tools List your published tools")
|
||||
print(" browse Browse tools (TUI)")
|
||||
print(" status <tool> Check moderation status of a tool")
|
||||
print(" browse Browse tools (GUI)")
|
||||
print(" config [action] Manage registry settings (admin)")
|
||||
return 0
|
||||
|
||||
@@ -503,6 +506,118 @@ def _cmd_registry_my_tools(args):
|
||||
return 0
|
||||
|
||||
|
||||
def _cmd_registry_status(args):
|
||||
"""Check moderation status of a tool."""
|
||||
from ..registry_client import RegistryError, get_client
|
||||
from ..tool import get_tools_dir
|
||||
|
||||
tool_name = args.tool
|
||||
do_sync = getattr(args, 'sync', False)
|
||||
|
||||
# Check if tool exists locally
|
||||
config_path = get_tools_dir() / tool_name / "config.yaml"
|
||||
if not config_path.exists():
|
||||
print(f"Error: Tool '{tool_name}' not found locally", file=sys.stderr)
|
||||
return 1
|
||||
|
||||
try:
|
||||
config_data = yaml.safe_load(config_path.read_text()) or {}
|
||||
except yaml.YAMLError as e:
|
||||
print(f"Error reading tool config: {e}", file=sys.stderr)
|
||||
return 1
|
||||
|
||||
local_status = config_data.get("registry_status", "not_published")
|
||||
local_hash = config_data.get("registry_hash")
|
||||
local_feedback = config_data.get("registry_feedback")
|
||||
|
||||
if not local_hash:
|
||||
print(f"Tool '{tool_name}' has not been published to the registry.")
|
||||
print()
|
||||
print("Publish with: cmdforge registry publish")
|
||||
return 0
|
||||
|
||||
# If syncing, fetch from server
|
||||
if do_sync:
|
||||
try:
|
||||
client = get_client()
|
||||
status_data = client.get_my_tool_status(tool_name)
|
||||
|
||||
new_status = status_data.get("status", "pending")
|
||||
new_hash = status_data.get("config_hash")
|
||||
new_feedback = status_data.get("feedback")
|
||||
|
||||
changed = False
|
||||
if local_status != new_status:
|
||||
config_data["registry_status"] = new_status
|
||||
local_status = new_status
|
||||
changed = True
|
||||
if new_hash and local_hash != new_hash:
|
||||
config_data["registry_hash"] = new_hash
|
||||
local_hash = new_hash
|
||||
changed = True
|
||||
if new_feedback != local_feedback:
|
||||
if new_feedback:
|
||||
config_data["registry_feedback"] = new_feedback
|
||||
local_feedback = new_feedback
|
||||
elif "registry_feedback" in config_data:
|
||||
del config_data["registry_feedback"]
|
||||
local_feedback = None
|
||||
changed = True
|
||||
|
||||
if changed:
|
||||
config_path.write_text(yaml.dump(config_data, default_flow_style=False, sort_keys=False))
|
||||
print("Status synced from server.\n")
|
||||
|
||||
except RegistryError as e:
|
||||
if e.code == "UNAUTHORIZED":
|
||||
print("Not logged in. Set your registry token to sync.", file=sys.stderr)
|
||||
elif e.code == "TOOL_NOT_FOUND":
|
||||
print(f"Tool '{tool_name}' not found in registry.", file=sys.stderr)
|
||||
else:
|
||||
print(f"Error syncing: {e.message}", file=sys.stderr)
|
||||
return 1
|
||||
except Exception as e:
|
||||
print(f"Error syncing: {e}", file=sys.stderr)
|
||||
return 1
|
||||
|
||||
# Display status
|
||||
print(f"Tool: {tool_name}")
|
||||
print(f"Registry Hash: {local_hash[:16]}...")
|
||||
|
||||
status_colors = {
|
||||
"approved": "\033[32mApproved\033[0m", # Green
|
||||
"pending": "\033[33mPending Review\033[0m", # Yellow
|
||||
"changes_requested": "\033[93mChanges Requested\033[0m", # Light yellow/orange
|
||||
"rejected": "\033[31mRejected\033[0m", # Red
|
||||
}
|
||||
status_display = status_colors.get(local_status, local_status)
|
||||
print(f"Status: {status_display}")
|
||||
|
||||
if local_feedback:
|
||||
print()
|
||||
print("Feedback from moderator:")
|
||||
print("-" * 40)
|
||||
print(local_feedback)
|
||||
print("-" * 40)
|
||||
|
||||
if local_status == "changes_requested":
|
||||
print()
|
||||
print("Action required: Address the feedback above and republish.")
|
||||
print(" cmdforge registry publish")
|
||||
elif local_status == "rejected":
|
||||
print()
|
||||
print("Your tool was rejected. Review the feedback above.")
|
||||
elif local_status == "pending":
|
||||
print()
|
||||
print("Your tool is waiting for moderator review.")
|
||||
print("Use --sync to check for updates.")
|
||||
elif local_status == "approved":
|
||||
print()
|
||||
print("Your tool is live in the registry!")
|
||||
|
||||
return 0
|
||||
|
||||
|
||||
def _cmd_registry_browse(args):
|
||||
"""Browse tools (GUI)."""
|
||||
from ..gui import run_gui
|
||||
|
||||
Reference in New Issue
Block a user