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

Function newAgentSoulWriteCommand

internal/cli/authored_context.go:158–201  ·  view source on GitHub ↗
(deps commandDeps)

Source from the content-addressed store, hash-verified

156}
157
158func newAgentSoulWriteCommand(deps commandDeps) *cobra.Command {
159 var (
160 input authoredBodyInput
161 expectedDigest string
162 idempotencyKey string
163 )
164 cmd := &cobra.Command{
165 Use: "write <agent>",
166 Short: "Create or replace SOUL.md through managed authoring",
167 Example: " agh agent soul write coder --file SOUL.md --expected-digest sha256:old --workspace checkout-api --json",
168 Args: exactOneNonBlankArg(),
169 RunE: func(cmd *cobra.Command, args []string) error {
170 client, err := clientFromDeps(deps)
171 if err != nil {
172 return err
173 }
174 workspace, err := commandWorkspaceFlag(cmd)
175 if err != nil {
176 return err
177 }
178 body, err := readAuthoredBody(cmd, input, true)
179 if err != nil {
180 return err
181 }
182 digest := optionalStringFlag(cmd, "expected-digest", expectedDigest)
183 record, err := client.PutAgentSoul(cmd.Context(), args[0], AgentSoulPutRequest{
184 WorkspaceID: workspace,
185 AgentName: args[0],
186 Body: body,
187 ExpectedDigest: digest,
188 IdempotencyKey: strings.TrimSpace(idempotencyKey),
189 })
190 if err != nil {
191 return err
192 }
193 return writeCommandOutput(cmd, agentSoulMutationBundle(&record))
194 },
195 }
196 addWorkspaceFlag(cmd)
197 addAuthoredBodyFlags(cmd, &input)
198 cmd.Flags().StringVar(&expectedDigest, "expected-digest", "", "Expected current Soul digest for CAS")
199 cmd.Flags().StringVar(&idempotencyKey, "idempotency-key", "", "Optional idempotency key")
200 return cmd
201}
202
203func newAgentSoulDeleteCommand(deps commandDeps) *cobra.Command {
204 var expectedDigest string

Callers 1

newAgentSoulCommandFunction · 0.85

Calls 10

exactOneNonBlankArgFunction · 0.85
clientFromDepsFunction · 0.85
commandWorkspaceFlagFunction · 0.85
readAuthoredBodyFunction · 0.85
optionalStringFlagFunction · 0.85
writeCommandOutputFunction · 0.85
agentSoulMutationBundleFunction · 0.85
addWorkspaceFlagFunction · 0.85
addAuthoredBodyFlagsFunction · 0.85
PutAgentSoulMethod · 0.65

Tested by

no test coverage detected