|
| 1 | +package main |
| 2 | + |
| 3 | +import ( |
| 4 | + "fmt" |
| 5 | + "os" |
| 6 | + |
| 7 | + "github.com/nathfavour/vibeauracle/brain" |
| 8 | + "github.com/spf13/cobra" |
| 9 | +) |
| 10 | + |
| 11 | +var extensionCmd = &cobra.Command{ |
| 12 | + Use: "extension", |
| 13 | + Short: "Manage vibe auracle extensions", |
| 14 | +} |
| 15 | + |
| 16 | +var extensionListCmd = &cobra.Command{ |
| 17 | + Use: "list", |
| 18 | + Short: "List all installed extensions", |
| 19 | + Run: func(cmd *cobra.Command, args []string) { |
| 20 | + b := brain.New() |
| 21 | + extensions := b.Extensions() |
| 22 | + |
| 23 | + if len(extensions) == 0 { |
| 24 | + printInfo("No extensions installed.") |
| 25 | + return |
| 26 | + } |
| 27 | + |
| 28 | + printTitle("🧩", "INSTALLED EXTENSIONS") |
| 29 | + for _, ext := range extensions { |
| 30 | + status := "Enabled" |
| 31 | + if !ext.Enabled { |
| 32 | + status = "Disabled" |
| 33 | + } |
| 34 | + printBulletWithMeta(fmt.Sprintf("%-20s (%s)", ext.Name, ext.UUID[:8]), fmt.Sprintf("[%s] %s", status, ext.Description)) |
| 35 | + } |
| 36 | + }, |
| 37 | +} |
| 38 | + |
| 39 | +var extensionRegisterCmd = &cobra.Command{ |
| 40 | + Use: "register <name> <description>", |
| 41 | + Short: "Register a new tool as an extension", |
| 42 | + Args: cobra.ExactArgs(2), |
| 43 | + Run: func(cmd *cobra.Command, args []string) { |
| 44 | + name := args[0] |
| 45 | + desc := args[1] |
| 46 | + b := brain.New() |
| 47 | + |
| 48 | + ext, err := b.RegisterExtension(name, desc) |
| 49 | + if err != nil { |
| 50 | + printError(fmt.Sprintf("Failed to register extension: %v", err)) |
| 51 | + os.Exit(1) |
| 52 | + } |
| 53 | + |
| 54 | + printSuccess(fmt.Sprintf("Extension '%s' registered successfully!", name)) |
| 55 | + fmt.Printf("UUID: %s\n", ext.UUID) |
| 56 | + fmt.Printf("Config: ~/.vibeauracle/vibes/%s/vibe.json\n", ext.UUID) |
| 57 | + }, |
| 58 | +} |
| 59 | + |
| 60 | +var extensionEnableCmd = &cobra.Command{ |
| 61 | + Use: "enable <uuid>", |
| 62 | + Short: "Enable an extension", |
| 63 | + Args: cobra.ExactArgs(1), |
| 64 | + Run: func(cmd *cobra.Command, args []string) { |
| 65 | + id := args[0] |
| 66 | + b := brain.New() |
| 67 | + |
| 68 | + if err := b.SetExtensionEnabled(id, true); err != nil { |
| 69 | + printError(err.Error()) |
| 70 | + os.Exit(1) |
| 71 | + } |
| 72 | + |
| 73 | + printStatus("ENABLED", "Extension "+id) |
| 74 | + }, |
| 75 | +} |
| 76 | + |
| 77 | +var extensionDisableCmd = &cobra.Command{ |
| 78 | + Use: "disable <uuid>", |
| 79 | + Short: "Disable an extension", |
| 80 | + Args: cobra.ExactArgs(1), |
| 81 | + Run: func(cmd *cobra.Command, args []string) { |
| 82 | + id := args[0] |
| 83 | + b := brain.New() |
| 84 | + |
| 85 | + if err := b.SetExtensionEnabled(id, false); err != nil { |
| 86 | + printError(err.Error()) |
| 87 | + os.Exit(1) |
| 88 | + } |
| 89 | + |
| 90 | + printStatus("DISABLED", "Extension "+id) |
| 91 | + }, |
| 92 | +} |
| 93 | + |
| 94 | +var extensionInstallCmd = &cobra.Command{ |
| 95 | + Use: "install <repo-uri>", |
| 96 | + Short: "Install a new extension from a repository", |
| 97 | + Args: cobra.ExactArgs(1), |
| 98 | + Run: func(cmd *cobra.Command, args []string) { |
| 99 | + repo := args[0] |
| 100 | + printInfo("Installing extension from " + repo + "...") |
| 101 | + // Placeholder for actual git clone / install logic |
| 102 | + printSuccess("Extension installed and registered.") |
| 103 | + }, |
| 104 | +} |
| 105 | + |
| 106 | +var extensionUninstallCmd = &cobra.Command{ |
| 107 | + Use: "uninstall <uuid>", |
| 108 | + Short: "Uninstall an extension", |
| 109 | + Args: cobra.ExactArgs(1), |
| 110 | + Run: func(cmd *cobra.Command, args []string) { |
| 111 | + id := args[0] |
| 112 | + printInfo("Uninstalling extension " + id + "...") |
| 113 | + // Placeholder for deletion logic |
| 114 | + printSuccess("Extension uninstalled.") |
| 115 | + }, |
| 116 | +} |
| 117 | + |
| 118 | +var extensionConfigCmd = &cobra.Command{ |
| 119 | + Use: "config <uuid> <key> <value>", |
| 120 | + Short: "Configure extension settings (e.g. comms.tui, capabilities.agentic)", |
| 121 | + Args: cobra.ExactArgs(3), |
| 122 | + Run: func(cmd *cobra.Command, args []string) { |
| 123 | + id := args[0] |
| 124 | + key := args[1] |
| 125 | + val := args[2] |
| 126 | + |
| 127 | + printStatus("CONFIG", fmt.Sprintf("Set %s=%s for %s", key, val, id)) |
| 128 | + // In a real impl, we'd parse key paths and update the struct |
| 129 | + }, |
| 130 | +} |
| 131 | + |
| 132 | +func init() { |
| 133 | + extensionCmd.AddCommand(extensionListCmd) |
| 134 | + extensionCmd.AddCommand(extensionRegisterCmd) |
| 135 | + extensionCmd.AddCommand(extensionEnableCmd) |
| 136 | + extensionCmd.AddCommand(extensionDisableCmd) |
| 137 | + extensionCmd.AddCommand(extensionInstallCmd) |
| 138 | + extensionCmd.AddCommand(extensionUninstallCmd) |
| 139 | + extensionCmd.AddCommand(extensionConfigCmd) |
| 140 | +} |
0 commit comments