From af7f44c34d4b38d219df4cd112b2259afca88ea8 Mon Sep 17 00:00:00 2001 From: Alex Dunmow Date: Thu, 4 Jun 2026 20:58:09 +0800 Subject: [PATCH] fix(plugin): drop VisibilityLabel and its proto import MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit When core/plugin imported core/internal/api/orchestrator/v1 for the PluginVisibility enum, every consumer of core/plugin (including the orchestrator) transitively pulled in core's generated bindings — and those bindings register the same proto descriptors as the orchestrator's own bindings, panicking at startup. Move the label helper into the CLI's cmd package where it belongs; core/plugin no longer references the proto package at all. Co-Authored-By: Claude Opus 4.7 --- cmd/ninja/cmd/plugin.go | 27 +++++++++++++++++++++++++-- plugin/mod.go | 23 ----------------------- 2 files changed, 25 insertions(+), 25 deletions(-) diff --git a/cmd/ninja/cmd/plugin.go b/cmd/ninja/cmd/plugin.go index 947af06..1b8eaa8 100644 --- a/cmd/ninja/cmd/plugin.go +++ b/cmd/ninja/cmd/plugin.go @@ -85,7 +85,7 @@ func printPublicSection(ctx context.Context, cli *orchclient.Client) { continue } for _, p := range gs.Msg.Plugins { - fmt.Printf(" @%s/%s [%s]\n", s.Slug, p.Name, core.VisibilityLabel(p.Visibility)) + fmt.Printf(" @%s/%s [%s]\n", s.Slug, p.Name, visibilityLabel(p.Visibility)) } } } @@ -175,6 +175,29 @@ func newPluginDeleteVersionCmd() *cobra.Command { return cmd } +// visibilityLabel converts the proto PluginVisibility enum into the +// lowercase, user-facing form ("private", "public", ...). Kept here in the +// CLI rather than in core/plugin so that external consumers of core/plugin +// don't transitively pull in core/internal/api/... — every such pull-in +// races with the orchestrator's own generated bindings of the same proto +// file at proto-registration time. +func visibilityLabel(v v1.PluginVisibility) string { + switch v { + case v1.PluginVisibility_PLUGIN_VISIBILITY_PRIVATE: + return "private" + case v1.PluginVisibility_PLUGIN_VISIBILITY_UNDER_REVIEW: + return "under_review" + case v1.PluginVisibility_PLUGIN_VISIBILITY_PUBLIC, + v1.PluginVisibility_PLUGIN_VISIBILITY_UNSPECIFIED: + return "public" + case v1.PluginVisibility_PLUGIN_VISIBILITY_REJECTED: + return "rejected" + case v1.PluginVisibility_PLUGIN_VISIBILITY_TAKEN_DOWN: + return "taken_down" + } + return "unknown" +} + // parsePrivateCoord accepts either a bare plugin name ("myplugin") or the // canonical "@private/name" form and returns just the plugin name. Any other // scope is rejected to make accidental deletion of public plugins impossible. @@ -740,7 +763,7 @@ func newPluginStatusCmd() *cobra.Command { continue } for _, p := range gs.Msg.Plugins { - fmt.Printf(" @%s/%s [%s]\n", s.Slug, p.Name, core.VisibilityLabel(p.Visibility)) + fmt.Printf(" @%s/%s [%s]\n", s.Slug, p.Name, visibilityLabel(p.Visibility)) } } return nil diff --git a/plugin/mod.go b/plugin/mod.go index ceca26a..a66d2b9 100644 --- a/plugin/mod.go +++ b/plugin/mod.go @@ -4,31 +4,8 @@ import ( "strings" tomlpkg "github.com/BurntSushi/toml" - - v1 "git.dev.alexdunmow.com/block/core/internal/api/orchestrator/v1" ) -// VisibilityLabel returns the lowercase, user-facing form of a PluginVisibility -// value (e.g. "private", "public", "under_review"). The default for the -// UNSPECIFIED zero value is "public", matching pre-enum behaviour for plugins -// that don't carry an explicit visibility. -func VisibilityLabel(v v1.PluginVisibility) string { - switch v { - case v1.PluginVisibility_PLUGIN_VISIBILITY_PRIVATE: - return "private" - case v1.PluginVisibility_PLUGIN_VISIBILITY_UNDER_REVIEW: - return "under_review" - case v1.PluginVisibility_PLUGIN_VISIBILITY_PUBLIC, - v1.PluginVisibility_PLUGIN_VISIBILITY_UNSPECIFIED: - return "public" - case v1.PluginVisibility_PLUGIN_VISIBILITY_REJECTED: - return "rejected" - case v1.PluginVisibility_PLUGIN_VISIBILITY_TAKEN_DOWN: - return "taken_down" - } - return "unknown" -} - type ModFile struct { Plugin ModPlugin `toml:"plugin"` Compatibility *ModCompat `toml:"compatibility"`