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

Function newSessionCreateCommand

internal/cli/session.go:82–150  ·  view source on GitHub ↗
(deps commandDeps)

Source from the content-addressed store, hash-verified

80}
81
82func newSessionCreateCommand(deps commandDeps) *cobra.Command {
83 var (
84 agentName string
85 cwd string
86 name string
87 channel string
88 provider string
89 model string
90 reasoningEffort string
91 workspaceRef string
92 )
93
94 cmd := &cobra.Command{
95 Use: sessionNewKey,
96 Short: "Create a new session",
97 Example: ` # Start a session in the current workspace using the configured default agent
98 agh session new
99
100 # Start a named session for a specific registered workspace and agent
101 agh session new --workspace checkout-api --agent reviewer --name review-api
102
103 # Override provider, model, and reasoning effort for this session only
104 agh session new --provider codex --model gpt-5.4 --reasoning-effort high
105
106 # Auto-register an absolute workspace path before creating the session
107 agh session new --cwd "$PWD" --agent reviewer`,
108 RunE: func(cmd *cobra.Command, _ []string) error {
109 client, err := clientFromDeps(deps)
110 if err != nil {
111 return err
112 }
113
114 workspace, workspacePath, err := resolveSessionCreateWorkspace(deps, workspaceRef, cwd)
115 if err != nil {
116 return err
117 }
118
119 created, err := client.CreateSession(cmd.Context(), CreateSessionRequest{
120 AgentName: agentName,
121 Provider: strings.TrimSpace(provider),
122 Model: strings.TrimSpace(model),
123 ReasoningEffort: strings.TrimSpace(reasoningEffort),
124 Name: name,
125 Workspace: workspace,
126 WorkspacePath: workspacePath,
127 Channel: strings.TrimSpace(channel),
128 })
129 if err != nil {
130 return err
131 }
132
133 return writeCommandOutput(cmd, sessionBundle(created, deps.now))
134 },
135 }
136 cmd.Flags().StringVar(&agentName, "agent", "", "Agent definition name (defaults to config default)")
137 cmd.Flags().StringVar(&workspaceRef, workspaceSkillSource, "", "Registered workspace name or ID")
138 cmd.Flags().StringVar(&cwd, "cwd", "", "Absolute workspace directory to auto-register")
139 cmd.Flags().StringVar(&name, sessionNameKey, "", "Optional session label")

Callers 1

newSessionCommandFunction · 0.85

Calls 5

clientFromDepsFunction · 0.85
writeCommandOutputFunction · 0.85
sessionBundleFunction · 0.85
CreateSessionMethod · 0.65

Tested by

no test coverage detected