MCPcopy Create free account
hub / github.com/compozy/agh / newInstallCommand

Function newInstallCommand

internal/cli/install.go:78–138  ·  view source on GitHub ↗
(deps commandDeps)

Source from the content-addressed store, hash-verified

76}
77
78func newInstallCommand(deps commandDeps) *cobra.Command {
79 var provider string
80 var model string
81
82 cmd := &cobra.Command{
83 Use: "install",
84 Short: "Bootstrap AGH and create the default general agent",
85 Example: ` # Create ~/.agh/config.toml and ~/.agh/agents/general/AGENT.md
86 agh install
87
88 # Bootstrap non-interactively for automation
89 agh install --provider codex --model gpt-5.4 -o json`,
90 RunE: func(cmd *cobra.Command, _ []string) error {
91 homePaths, err := deps.resolveHome()
92 if err != nil {
93 return err
94 }
95 if err := deps.ensureHome(homePaths); err != nil {
96 return err
97 }
98
99 cfg, err := aghconfig.LoadGlobalConfig(homePaths)
100 if err != nil {
101 return err
102 }
103
104 selection, err := resolveInstallSelection(cmd, &cfg, provider, model, deps.runInstallWizard)
105 if err != nil {
106 return err
107 }
108
109 cfg, err = aghconfig.SaveBootstrapConfig(homePaths, selection.Provider, selection.Model)
110 if err != nil {
111 return err
112 }
113 agentPath, createdAgent, err := aghconfig.EnsureBootstrapAgent(homePaths)
114 if err != nil {
115 return err
116 }
117 if _, _, err := aghconfig.EnsureOnboardingAgent(homePaths); err != nil {
118 return err
119 }
120
121 record := installRecord{
122 AgentName: aghconfig.DefaultAgentName,
123 Provider: cfg.Defaults.Provider,
124 Model: cfg.Providers[cfg.Defaults.Provider].Models.Default,
125 Permissions: string(cfg.Permissions.Mode),
126 ConfigFile: homePaths.ConfigFile,
127 AgentFile: agentPath,
128 CreatedAgent: createdAgent,
129 Managed: detectManagedState(deps).Managed,
130 Manager: detectManagedState(deps).Manager,
131 }
132 return writeCommandOutput(cmd, installBundle(record))
133 },
134 }
135 cmd.Flags().StringVar(&provider, cliProviderKey, "", "Default provider to configure without opening the wizard")

Callers 1

newRootCommandFunction · 0.85

Calls 4

resolveInstallSelectionFunction · 0.85
detectManagedStateFunction · 0.85
writeCommandOutputFunction · 0.85
installBundleFunction · 0.85

Tested by

no test coverage detected