@startuml
title Tool Registry Workflow

== A. Publishing a Tool ==

actor Developer as dev1
participant CLI as cli1
participant "API Server" as api1
participant Gitea as gitea1

dev1 -> cli1 : publish ./tool/
cli1 -> cli1 : validate locally
cli1 -> api1 : POST /tools
api1 -> gitea1 : Create branch
api1 -> gitea1 : Create PR
gitea1 --> api1 : PR URL
api1 --> cli1 : {"pr_url": "..."}
cli1 --> dev1 : "PR created, pending review"

== B. Installing a Tool ==

actor Developer as dev2
participant CLI as cli2
participant "API Server" as api2
participant "Local FS" as fs2

dev2 -> cli2 : install summarize
cli2 -> api2 : GET /tools/summarize
api2 --> cli2 : {config: "yaml..."}
cli2 -> fs2 : write config.yaml
cli2 -> fs2 : generate wrapper script
cli2 --> dev2 : "Installed summarize v1.2.0"

== C. Sync on Merge ==

actor Maintainer as maint
participant Gitea as gitea3
participant "API Server" as api3
participant Database as db3

maint -> gitea3 : Merge PR
gitea3 -> api3 : POST /webhook/gitea
api3 -> gitea3 : git pull
gitea3 --> api3 : (repo contents)
api3 -> api3 : parse tools/
api3 -> db3 : UPDATE tools
api3 -> db3 : rebuild search idx

@enduml