mirror of
https://github.com/docker/docker-agent.git
synced 2026-11-04 10:02:15 +00:00
Wire the Command Code CLI (`cmd`) in as a new coding-harness type,
alongside claude-code, codex, pi and opencode, so an agent can be run by
it:
harness:
type: command-code
The provider lives in github.com/rumpl/harness, so this bumps that
dependency. Until the commandcode package lands upstream
(https://github.com/rumpl/harness/pull/13) the bump is a temporary
replace, allow-listed in .golangci.yml with a TODO to drop it.
Signed-off-by: PremModhaOfficial <PremModhaOfficial@users.noreply.github.com>
72 lines
1.8 KiB
Go
72 lines
1.8 KiB
Go
package codingharness
|
|
|
|
import (
|
|
"errors"
|
|
"fmt"
|
|
|
|
baseharness "github.com/rumpl/harness"
|
|
"github.com/rumpl/harness/claudecode"
|
|
"github.com/rumpl/harness/codex"
|
|
"github.com/rumpl/harness/commandcode"
|
|
"github.com/rumpl/harness/opencode"
|
|
"github.com/rumpl/harness/pi"
|
|
|
|
"github.com/docker/docker-agent/pkg/config/latest"
|
|
)
|
|
|
|
const (
|
|
TypeClaudeCode = "claude-code"
|
|
TypeCodex = "codex"
|
|
TypePi = "pi"
|
|
TypeOpenCode = "opencode"
|
|
TypeCommandCode = "command-code"
|
|
)
|
|
|
|
func NewProvider(cfg *latest.HarnessConfig) (baseharness.Provider, error) {
|
|
if cfg == nil {
|
|
return nil, errors.New("harness config is nil")
|
|
}
|
|
|
|
switch cfg.Type {
|
|
case TypeClaudeCode:
|
|
return newClaudeCodeProvider(cfg), nil
|
|
case TypeCodex:
|
|
return codex.New(cfg.Model), nil
|
|
case TypePi:
|
|
return pi.New(cfg.Model), nil
|
|
case TypeOpenCode:
|
|
return newOpenCodeProvider(cfg), nil
|
|
case TypeCommandCode:
|
|
return newCommandCodeProvider(cfg), nil
|
|
default:
|
|
return nil, fmt.Errorf("unsupported harness type %q", cfg.Type)
|
|
}
|
|
}
|
|
|
|
func newClaudeCodeProvider(cfg *latest.HarnessConfig) baseharness.Provider {
|
|
var opts []claudecode.Option
|
|
if cfg.Effort != "" {
|
|
opts = append(opts, claudecode.WithEffort(claudecode.Effort(cfg.Effort)))
|
|
}
|
|
return claudecode.New(cfg.Model, opts...)
|
|
}
|
|
|
|
func newCommandCodeProvider(cfg *latest.HarnessConfig) baseharness.Provider {
|
|
var opts []commandcode.Option
|
|
if cfg.Effort != "" {
|
|
opts = append(opts, commandcode.WithEffort(cfg.Effort))
|
|
}
|
|
return commandcode.New(cfg.Model, opts...)
|
|
}
|
|
|
|
func newOpenCodeProvider(cfg *latest.HarnessConfig) baseharness.Provider {
|
|
var opts []opencode.Option
|
|
if cfg.Agent != "" {
|
|
opts = append(opts, opencode.WithAgent(cfg.Agent))
|
|
}
|
|
if cfg.Thinking {
|
|
opts = append(opts, opencode.WithThinking())
|
|
}
|
|
return opencode.New(cfg.Model, opts...)
|
|
}
|