π€ AI-Generated Project Notice
This entire project is an AI test case to explore how well software can be written through "vibecoding" - providing high-level descriptions and letting AI handle the implementation. This codebase was created with zero developer oversight - every line of code, architecture decision, and documentation was generated exclusively by AI (Claude) based on conversational prompts.
The goal is to see how sophisticated and production-ready a project can become when developed entirely through AI-assisted "vibe-based" programming, where the human provides the vision and the AI handles all implementation details.
A demonstration of building a plugin-based CLI tool using HashiCorp's go-plugin library, similar to how Terraform manages its providers. Despite being entirely AI-generated, it implements a complete, production-grade plugin architecture.
- Plugin Discovery: Automatically discovers plugins with
plugin-prefix in predefined paths - Version Compatibility: Ensures CLI and plugin version compatibility
- GitHub Downloads: Install plugins directly from GitHub releases
- gRPC Communication: Uses gRPC for efficient plugin communication
- Auto-Registration: Plugins are automatically discovered and registered
- Cobra CLI: Nested command structure for extensibility
βββ cmd/cli/ # Main CLI application
βββ plugins/ # Plugin implementations
β βββ dummy/ # Example plugin
βββ shared/ # Shared interfaces and protocols
βββ pkg/
β βββ plugin/ # Plugin loading and management
β βββ discovery/ # Plugin discovery logic
β βββ manager/ # Package manager for GitHub downloads
βββ internal/
βββ version/ # Version compatibility checking
βββ config/ # Configuration management
- Go 1.22 or higher
- Protocol Buffers compiler (protoc)
- Clone the repository:
git clone https://github.com/williamokano/hashicorp-plugin-example
cd hashicorp-plugin-example- Install dependencies:
make deps- Build everything:
make build- Install CLI and plugins:
make installplugin-cli plugin listplugin-cli plugin info dummyplugin-cli run -p dummy -m "Hello, World!"plugin-cli install owner/repo --version v1.0.0plugin-cli plugin remove dummy- Implement the
VersionedPlugininterface:
package main
import (
"context"
"github.com/williamokano/hashicorp-plugin-example/shared"
"github.com/hashicorp/go-plugin"
)
type MyPlugin struct{}
func (p *MyPlugin) Process(ctx context.Context, input shared.DummyModel) (shared.DummyModel, error) {
// Your plugin logic here
return shared.DummyModel{
Message: "Processed: " + input.Message,
}, nil
}
func (p *MyPlugin) Name() string { return "my-plugin" }
func (p *MyPlugin) Version() string { return "1.0.0" }
func (p *MyPlugin) BuildTime() string { return "2024-01-01" }
func (p *MyPlugin) MinCLIVersion() string { return "1.0.0" }
func (p *MyPlugin) MaxCLIVersion() string { return "2.0.0" }
func (p *MyPlugin) Description() string { return "My custom plugin" }
func main() {
plugin.Serve(&plugin.ServeConfig{
HandshakeConfig: shared.Handshake,
Plugins: map[string]plugin.Plugin{
"plugin": &shared.GRPCPlugin{Impl: &MyPlugin{}},
},
GRPCServer: plugin.DefaultGRPCServer,
})
}- Build your plugin:
go build -o plugin-myplugin myplugin.go- Place it in one of the plugin directories:
~/.local/share/plugins/./plugins/- Any path in
PLUGIN_PATHenvironment variable
The CLI searches for plugins in the following locations (in order):
~/.local/share/plugins/./plugins/(current directory)./.plugins/(hidden directory)- Paths specified in
PLUGIN_PATHenvironment variable /usr/local/lib/plugins/
Plugins must:
- Have executable permissions
- Start with
plugin-prefix - Implement the required interfaces
PLUGIN_PATH: Colon-separated list of additional plugin directoriesPLUGIN_LOG_LEVEL: Control plugin system logging (default:error)- Options:
trace,debug,info,warn,error,off - Example:
PLUGIN_LOG_LEVEL=debug plugin-cli plugin list
- Options:
Create a configuration file at ~/.config/plugin-cli/config.json:
{
"plugins": [
{
"name": "dummy",
"repository": "williamokano/plugin-dummy",
"version": "v1.0.0",
"enabled": true
}
],
"plugin_paths": [
"~/.local/share/plugins",
"./plugins"
],
"auto_download": true
}make protomake build-climake build-dummy-pluginmake testmake clean- shared/: Contains the plugin interface and gRPC protocol definitions
- pkg/plugin/: Plugin manager for loading and executing plugins
- pkg/discovery/: Auto-discovery logic for finding plugins
- pkg/manager/: GitHub release downloader and installer
- internal/version/: Version compatibility checking
- internal/config/: Configuration file management
Use Cobra to add new commands to the CLI:
func newMyCommand() *cobra.Command {
return &cobra.Command{
Use: "mycommand",
Short: "Description of my command",
RunE: func(cmd *cobra.Command, args []string) error {
// Command logic here
return nil
},
}
}MIT
Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.