- Change module from forge.lthn.ai/core/go to forge.lthn.ai/core/cli - Remove pkg/ directory (now served from core/go) - Add require + replace for forge.lthn.ai/core/go => ../go - Update go.work to include ../go workspace module - Fix all internal/cmd/* imports: pkg/ refs → forge.lthn.ai/core/go/pkg/ - Rename internal/cmd/sdk package to sdkcmd (avoids conflict with pkg/sdk) - Remove SDK library files from internal/cmd/sdk/ (now in core/go/pkg/sdk/) - Remove duplicate RAG helper functions from internal/cmd/rag/ - Remove stale cmd/core-ide/ (now in core/ide repo) - Update IDE variant to remove core-ide import - Fix test assertion for new module name - Run go mod tidy to sync dependencies core/cli is now a pure CLI application importing core/go for packages. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> Co-authored-by: Claude <developers@lethean.io> Reviewed-on: #1
86 lines
1.8 KiB
Go
86 lines
1.8 KiB
Go
package plugin
|
|
|
|
import (
|
|
"fmt"
|
|
"path/filepath"
|
|
|
|
"forge.lthn.ai/core/go/pkg/cli"
|
|
"forge.lthn.ai/core/go/pkg/i18n"
|
|
"forge.lthn.ai/core/go/pkg/io"
|
|
"forge.lthn.ai/core/go/pkg/plugin"
|
|
)
|
|
|
|
func addInfoCommand(parent *cli.Command) {
|
|
infoCmd := cli.NewCommand(
|
|
"info <name>",
|
|
i18n.T("Show detailed plugin information"),
|
|
"",
|
|
func(cmd *cli.Command, args []string) error {
|
|
return runInfo(args[0])
|
|
},
|
|
)
|
|
infoCmd.Args = cli.ExactArgs(1)
|
|
|
|
parent.AddCommand(infoCmd)
|
|
}
|
|
|
|
func runInfo(name string) error {
|
|
basePath, err := pluginBasePath()
|
|
if err != nil {
|
|
return err
|
|
}
|
|
|
|
registry := plugin.NewRegistry(io.Local, basePath)
|
|
if err := registry.Load(); err != nil {
|
|
return err
|
|
}
|
|
|
|
cfg, ok := registry.Get(name)
|
|
if !ok {
|
|
return fmt.Errorf("plugin not found: %s", name)
|
|
}
|
|
|
|
// Try to load the manifest for extended information
|
|
loader := plugin.NewLoader(io.Local, basePath)
|
|
manifest, manifestErr := loader.LoadPlugin(name)
|
|
|
|
fmt.Println()
|
|
cli.Label("Name", cfg.Name)
|
|
cli.Label("Version", cfg.Version)
|
|
cli.Label("Source", cfg.Source)
|
|
|
|
status := "disabled"
|
|
if cfg.Enabled {
|
|
status = "enabled"
|
|
}
|
|
cli.Label("Status", status)
|
|
cli.Label("Installed", cfg.InstalledAt)
|
|
cli.Label("Path", filepath.Join(basePath, name))
|
|
|
|
if manifestErr == nil && manifest != nil {
|
|
if manifest.Description != "" {
|
|
cli.Label("Description", manifest.Description)
|
|
}
|
|
if manifest.Author != "" {
|
|
cli.Label("Author", manifest.Author)
|
|
}
|
|
if manifest.Entrypoint != "" {
|
|
cli.Label("Entrypoint", manifest.Entrypoint)
|
|
}
|
|
if manifest.MinVersion != "" {
|
|
cli.Label("Min Version", manifest.MinVersion)
|
|
}
|
|
if len(manifest.Dependencies) > 0 {
|
|
for i, dep := range manifest.Dependencies {
|
|
if i == 0 {
|
|
cli.Label("Dependencies", dep)
|
|
} else {
|
|
fmt.Printf(" %s\n", dep)
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
fmt.Println()
|
|
return nil
|
|
}
|