Skip to content

Commit c2c73eb

Browse files
feat(run): add --build flag to rebuild image before running
1 parent 7ecca0f commit c2c73eb

File tree

2 files changed

+16
-1
lines changed

2 files changed

+16
-1
lines changed

go/cli/cmd/kagent/main.go

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -389,15 +389,29 @@ Examples:
389389
runCfg.ProjectDir = "."
390390
}
391391

392+
if runCfg.Build {
393+
fmt.Fprintf(os.Stderr, "Building image before running...\n")
394+
395+
buildCfg := &cli.BuildCfg{
396+
Config: runCfg.Config,
397+
ProjectDir: runCfg.ProjectDir,
398+
}
399+
400+
if err := cli.BuildCmd(buildCfg); err != nil {
401+
fmt.Fprintf(os.Stderr, "Build failed: %v\n", err)
402+
os.Exit(1)
403+
}
404+
}
392405
if err := cli.RunCmd(cmd.Context(), runCfg); err != nil {
393-
fmt.Fprintf(os.Stderr, "Error: %v\n", err)
406+
fmt.Fprintf(os.Stderr, "Error running agent: %v\n", err)
394407
os.Exit(1)
395408
}
396409
},
397410
Example: `kagent run ./my-agent`,
398411
}
399412

400413
runCmd.Flags().StringVar(&runCfg.ProjectDir, "project-dir", "", "Project directory (default: current directory)")
414+
runCmd.Flags().BoolVar(&runCfg.Build, "build", false, "Rebuild the Docker image before running")
401415

402416
rootCmd.AddCommand(installCmd, uninstallCmd, invokeCmd, bugReportCmd, versionCmd, dashboardCmd, getCmd, initCmd, buildCmd, deployCmd, addMcpCmd, runCmd, mcp.NewMCPCmd())
403417

go/cli/internal/cli/agent/run.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ import (
1919
type RunCfg struct {
2020
ProjectDir string
2121
Config *config.Config
22+
Build bool
2223
}
2324

2425
// RunCmd starts docker-compose in the background and launches a chat session with the local agent

0 commit comments

Comments
 (0)