agent/pkg/agentic/commands_commit.go
Virgil 2e9529c018 feat(agentic): expose commit command
Co-Authored-By: Virgil <virgil@lethean.io>
2026-04-02 02:45:26 +00:00

48 lines
1.6 KiB
Go

// SPDX-License-Identifier: EUPL-1.2
package agentic
import core "dappco.re/go/core"
func (s *PrepSubsystem) registerCommitCommands() {
c := s.Core()
c.Command("commit", core.Command{Description: "Write the final dispatch record to the workspace journal", Action: s.cmdCommit})
c.Command("agentic:commit", core.Command{Description: "Write the final dispatch record to the workspace journal", Action: s.cmdCommit})
}
// core-agent commit core/go-io/task-42
func (s *PrepSubsystem) cmdCommit(options core.Options) core.Result {
workspace := optionStringValue(options, "workspace", "_arg")
if workspace == "" {
core.Print(nil, "usage: core-agent commit <workspace>")
return core.Result{Value: core.E("agentic.cmdCommit", "workspace is required", nil), OK: false}
}
result := s.handleCommit(s.commandContext(), core.NewOptions(
core.Option{Key: "workspace", Value: workspace},
))
if !result.OK {
err := commandResultError("agentic.cmdCommit", result)
core.Print(nil, "error: %v", err)
return core.Result{Value: err, OK: false}
}
output, ok := result.Value.(CommitOutput)
if !ok {
err := core.E("agentic.cmdCommit", "invalid commit output", nil)
core.Print(nil, "error: %v", err)
return core.Result{Value: err, OK: false}
}
core.Print(nil, "workspace: %s", output.Workspace)
core.Print(nil, "journal: %s", output.JournalPath)
if output.MarkerPath != "" {
core.Print(nil, "marker: %s", output.MarkerPath)
}
if output.Skipped {
core.Print(nil, "skipped: true")
} else {
core.Print(nil, "committed: %s", output.CommittedAt)
}
return core.Result{Value: output, OK: true}
}