Skip to content

Commit d7ec52e

Browse files
authored
Merge pull request #24 from akihikokuroda/deprecatedcommands
bug: add backward compatible commands
2 parents 97783bc + 813a225 commit d7ec52e

File tree

7 files changed

+224
-0
lines changed

7 files changed

+224
-0
lines changed

internal/commands/create.go

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -161,3 +161,13 @@ func (c *CreateCommand) createMCPToolsFromYAML(agentsYaml []common.YAMLDocument)
161161

162162
return nil
163163
}
164+
165+
// DeprecatedCreateCommand deprecated create command
166+
func DeprecatedCreateCommand(args0 string, options *CommandOptions) error {
167+
createCmd := &CreateCommand{
168+
BaseCommand: NewBaseCommand(options),
169+
agentsFile: args0,
170+
mcpServerURI: "",
171+
}
172+
return createCmd.Run()
173+
}

internal/commands/create_cr.go

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -193,3 +193,13 @@ func sanitizeName(name string) string {
193193

194194
return newName
195195
}
196+
197+
198+
// DeprecatedCreateCommand deprecated create command
199+
func DeprecatedCreateCrCommand(args0 string, options *CommandOptions) error {
200+
createcrCmd := &CreateCrCommand{
201+
BaseCommand: NewBaseCommand(options),
202+
yamlFile: args0,
203+
}
204+
return createcrCmd.Run()
205+
}

internal/commands/deploy.go

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -217,3 +217,51 @@ func (c *DeployCommand) deployToTarget(target string, env string) error {
217217

218218
return nil
219219
}
220+
221+
// DeprecatedDeployCommand deprecated create command
222+
func DeprecatedDeployCommand(args []string, options *CommandOptions, cmd *cobra.Command) error {
223+
deployCmd := &DeployCommand{}
224+
deployCmd.BaseCommand = NewBaseCommand(options)
225+
deployCmd.agentsFile = args[0]
226+
deployCmd.workflowFile = args[1]
227+
deployCmd.env = args[2:]
228+
229+
// Get flag values
230+
var err error
231+
deployCmd.url, err = cmd.Flags().GetString("url")
232+
if err != nil {
233+
return err
234+
}
235+
236+
deployCmd.k8s, err = cmd.Flags().GetBool("k8s")
237+
if err != nil {
238+
return err
239+
}
240+
241+
deployCmd.kubernetes, err = cmd.Flags().GetBool("kubernetes")
242+
if err != nil {
243+
return err
244+
}
245+
246+
deployCmd.docker, err = cmd.Flags().GetBool("docker")
247+
if err != nil {
248+
return err
249+
}
250+
251+
deployCmd.streamlit, err = cmd.Flags().GetBool("streamlit")
252+
if err != nil {
253+
return err
254+
}
255+
256+
deployCmd.autoPrompt, err = cmd.Flags().GetBool("auto-prompt")
257+
if err != nil {
258+
return err
259+
}
260+
261+
deployCmd.mcpServerURI, err = cmd.Flags().GetString("mcp-server-uri")
262+
if err != nil {
263+
return err
264+
}
265+
266+
return deployCmd.Run()
267+
}

internal/commands/run.go

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -305,3 +305,25 @@ func (c *RunCommand) runWorkflow(workflow common.YAMLDocument, agents []common.Y
305305
func (c *RunCommand) logWorkflowRun(logger *common.Logger, workflowID, workflowName, prompt, output string, modelsUsed []string, status string, startTime, endTime time.Time, durationMs int) {
306306
c.Console().Ok(fmt.Sprintf("Workflow %s completed with status: %s", workflowID, status))
307307
}
308+
309+
// DeprecatedRunCommand deprecated create command
310+
func DeprecatedRunCommand(args []string, options *CommandOptions) error {
311+
var agentsFile, workflowFile string
312+
if len(args) == 1 {
313+
agentsFile = ""
314+
workflowFile = args[0]
315+
} else if len(args) == 2 {
316+
agentsFile = args[0]
317+
workflowFile = args[1]
318+
}
319+
320+
runCmd := &RunCommand{
321+
BaseCommand: NewBaseCommand(options),
322+
agentsFile: agentsFile,
323+
workflowFile: workflowFile,
324+
prompt: false,
325+
mcpServerURI: "",
326+
}
327+
328+
return runCmd.Run()
329+
}

internal/commands/serve.go

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -427,3 +427,38 @@ func (c AgentServeCommand) serveFastAPIAgent() error {
427427
return nil
428428

429429
}
430+
// DeprecatedServeCommand deprecated create command
431+
func DeprecatedServeCommand(args []string, options *CommandOptions, cmd *cobra.Command) error {
432+
agentServeCmd := &AgentServeCommand{}
433+
agentServeCmd.BaseCommand = NewBaseCommand(options)
434+
agentServeCmd.agentsFile = args[0]
435+
436+
// Get flag values
437+
var err error
438+
agentServeCmd.agentName, err = cmd.Flags().GetString("agent-name")
439+
if err != nil {
440+
return err
441+
}
442+
443+
agentServeCmd.host, err = cmd.Flags().GetString("host")
444+
if err != nil {
445+
return err
446+
}
447+
448+
portStr, err := cmd.Flags().GetString("port")
449+
if err != nil {
450+
return err
451+
}
452+
453+
if portStr == "" {
454+
agentServeCmd.port = 8001
455+
} else {
456+
agentServeCmd.port, err = strconv.Atoi(portStr)
457+
if err != nil {
458+
return fmt.Errorf("invalid port number: %s", portStr)
459+
}
460+
}
461+
agentServeCmd.mcpServerURI = ""
462+
463+
return agentServeCmd.Run()
464+
}

src/commands.go

Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@ import (
44
"fmt"
55

66
"github.com/spf13/cobra"
7+
"maestro/internal/common"
8+
"maestro/internal/commands"
79
)
810

911
// VDB Commands
@@ -385,6 +387,85 @@ var metaAgentCmd = &cobra.Command{
385387
Example: ` maestro metaagent run TEXT_FILE.`,
386388
}
387389

390+
// Deprecated Create commands - agent/MCPtool
391+
var deprecatedCreateCmd = &cobra.Command{
392+
Use: "create",
393+
Short: "*** Deprecated *** Create",
394+
Long: `*** Deprecated *** Create: Use agent or tool create.`,
395+
Aliases: []string{"create"},
396+
Args: cobra.ExactArgs(1),
397+
Example: ` maestro agent/tool create yaml_file.`,
398+
RunE: func(cmd *cobra.Command, args []string) error {
399+
fmt.Println("***Deprecated Create: Use agent or tool create.***")
400+
defs, _ := common.ParseYAML(args[0])
401+
fmt.Println(defs[0]["kind"])
402+
if defs[0]["kind"] == "Agent" || defs[0]["kind"] == "MCPTool"{
403+
options := commands.NewCommandOptions(cmd)
404+
return commands.DeprecatedCreateCommand(args[0], options)
405+
}
406+
return nil
407+
},
408+
}
409+
410+
// Deprecated CreateCr commands - agent/MCPtool
411+
var deprecatedCreateCrCmd = &cobra.Command{
412+
Use: "create-cr",
413+
Short: "*** Deprecated *** Create-cr",
414+
Long: `*** Deprecated *** Create-cr: Use curomresource create yaml_file.`,
415+
Aliases: []string{"create"},
416+
Args: cobra.ExactArgs(1),
417+
Example: ` maestro agent/tool create-cr yaml_file.`,
418+
RunE: func(cmd *cobra.Command, args []string) error {
419+
fmt.Println("***Deprecated Create: Use agent or tool create.***")
420+
options := commands.NewCommandOptions(cmd)
421+
return commands.DeprecatedCreateCrCommand(args[0], options)
422+
},
423+
}
424+
425+
// Deprecated Run commands - workflow
426+
var deprecatedRunCmd = &cobra.Command{
427+
Use: "run",
428+
Short: "*** Deprecated *** Run",
429+
Long: `Deprecated Run: Use workflow run.`,
430+
Aliases: []string{"run"},
431+
Example: ` maestro workflow run agentyaml_file workflowyaml_file.`,
432+
RunE: func(cmd *cobra.Command, args []string) error {
433+
fmt.Println("***Deprecated Run: Use workflow run.***")
434+
options := commands.NewCommandOptions(cmd)
435+
return commands.DeprecatedRunCommand(args, options)
436+
},
437+
}
438+
439+
// Deprecated Deploy commands - workflow
440+
var deprecatedDeployCmd = &cobra.Command{
441+
Use: "deploy",
442+
Short: "*** Deprecated *** Deploy",
443+
Long: `*** Deprecated *** Deploy: Use workflow deploy.`,
444+
Aliases: []string{"deploy"},
445+
Args: cobra.MinimumNArgs(2),
446+
Example: ` maestro deploy agentyaml_file workflowyaml_file.`,
447+
RunE: func(cmd *cobra.Command, args []string) error {
448+
fmt.Println("***Deprecated Deploy: Use workflow deploy.***")
449+
options := commands.NewCommandOptions(cmd)
450+
return commands.DeprecatedDeployCommand(args, options, cmd)
451+
},
452+
}
453+
454+
// Deprecated Deploy commands - workflow
455+
var deprecatedServeCmd = &cobra.Command{
456+
Use: "serve",
457+
Short: "*** Deprecated *** Serve",
458+
Long: `*** Deprecated *** : Use workflow/agent serve.`,
459+
Aliases: []string{"serve"},
460+
Args: cobra.ExactArgs(1),
461+
Example: ` maestro serve agentyaml_file.`,
462+
RunE: func(cmd *cobra.Command, args []string) error {
463+
fmt.Println("***Deprecated Serve: Use workflow serve.***")
464+
options := commands.NewCommandOptions(cmd)
465+
return commands.DeprecatedServeCommand(args, options, cmd)
466+
},
467+
}
468+
388469
func init() {
389470
// Add flags to collection commands
390471
collectionListCmd.Flags().String("vdb", "", "Vector database name")

src/main.go

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,11 @@ A command-line interface for working with Maestro configurations.`,
126126
rootCmd.AddCommand(workflowCmd)
127127
rootCmd.AddCommand(customResourceCmd)
128128
rootCmd.AddCommand(metaAgentCmd)
129+
rootCmd.AddCommand(deprecatedCreateCmd)
130+
rootCmd.AddCommand(deprecatedCreateCrCmd)
131+
rootCmd.AddCommand(deprecatedRunCmd)
132+
rootCmd.AddCommand(deprecatedDeployCmd)
133+
rootCmd.AddCommand(deprecatedServeCmd)
129134
rootCmd.AddCommand(vdbCmd)
130135
rootCmd.AddCommand(collectionCmd)
131136
rootCmd.AddCommand(documentCmd)
@@ -137,6 +142,19 @@ A command-line interface for working with Maestro configurations.`,
137142
rootCmd.AddCommand(validateCmd)
138143
rootCmd.AddCommand(statusCmd)
139144

145+
// Add flags
146+
deprecatedDeployCmd.Flags().String("url", "127.0.0.1:5000", "The deployment URL")
147+
deprecatedDeployCmd.Flags().Bool("k8s", false, "Deploy to Kubernetes")
148+
deprecatedDeployCmd.Flags().Bool("kubernetes", false, "Deploy to Kubernetes")
149+
deprecatedDeployCmd.Flags().Bool("docker", false, "Deploy to Docker")
150+
deprecatedDeployCmd.Flags().Bool("streamlit", false, "Deploy as Streamlit application (default)")
151+
deprecatedDeployCmd.Flags().Bool("auto-prompt", false, "Run prompt by default if specified")
152+
deprecatedDeployCmd.Flags().StringVar(&mcpServerURI, "mcp-server-uri", "", "Maestro MCP server URI (overrides MAESTRO_MAESTRO_MCP_SERVER_URI environment variable)")
153+
deprecatedServeCmd.Flags().String("agent-name", "", "Specific agent name to serve (if multiple in file)")
154+
deprecatedServeCmd.Flags().String("host", "127.0.0.1", "Host to bind to")
155+
deprecatedServeCmd.Flags().String("port", "8000", "Port to serve on")
156+
deprecatedServeCmd.Flags().StringVar(&mcpServerURI, "mcp-server-uri", "", "Maestro MCP server URI (overrides MAESTRO_MAESTRO_MCP_SERVER_URI environment variable)")
157+
140158
// Add completion command
141159
AddCompletionCommand(rootCmd)
142160

0 commit comments

Comments
 (0)