Documentation
¶
Overview ¶
Package md manages isolated Docker development containers for AI coding agents.
It provides programmatic access to create, manage, and tear down containers that each get a full git clone of your repository with SSH access.
Index ¶
- Constants
- func GitCurrentBranch(ctx context.Context, wd string) (string, error)
- func GitRootDir(ctx context.Context, wd string) (string, error)
- type Client
- type Container
- func (c *Container) Diff(ctx context.Context, stdout, stderr io.Writer, extraArgs []string) error
- func (c *Container) Fetch(ctx context.Context, provider, model string) error
- func (c *Container) GetHostPort(ctx context.Context, containerPort string) (string, error)
- func (c *Container) Kill(ctx context.Context) error
- func (c *Container) Pull(ctx context.Context, provider, model string) error
- func (c *Container) Push(ctx context.Context) error
- func (c *Container) Run(ctx context.Context, baseImage string, command []string) (_ int, retErr error)
- func (c *Container) Start(ctx context.Context, opts *StartOpts) (retErr error)
- type StartOpts
Constants ¶
const DefaultBaseImage = "ghcr.io/maruel/md"
DefaultBaseImage is the base image used when none is specified.
Variables ¶
This section is empty.
Functions ¶
func GitCurrentBranch ¶
GitCurrentBranch returns the current branch name for the given working directory.
Types ¶
type Client ¶
type Client struct {
// W is the writer for progress and status messages.
W io.Writer
// Paths.
Home string
XDGConfigHome string
XDGDataHome string
XDGStateHome string
// SSH key paths.
HostKeyPath string // ~/.config/md/ssh_host_ed25519_key (generated)
UserKeyPath string // ~/.ssh/md
// Docker.
ImageName string
// Tokens.
GithubToken string // GitHub API token for Docker build secrets.
TailscaleAPIKey string // Tailscale API key for auth key generation and device deletion.
// contains filtered or unexported fields
}
Client holds global MD tool state (paths, image config, SSH keys).
func (*Client) Container ¶
Container returns a Container handle for the given git root and branch.
It doesn't start it, it is just a reference.
type Container ¶
type Container struct {
*Client
GitRoot string
RepoName string
Branch string
Name string
State string
CreatedAt time.Time
}
Container holds state for a single container instance.
func (*Container) Diff ¶
Diff writes the diff between base and current in the container. When stdout is a terminal, a TTY is allocated so git's pager and colors work.
func (*Container) Fetch ¶
Fetch commits any uncommitted changes in the container and fetches them locally, updating the remote-tracking ref without integrating.
provider and model control AI commit message generation. See https://github.com/maruel/genai for valid names. If provider is empty, a default message is used.
func (*Container) GetHostPort ¶
GetHostPort returns the host port mapped to a container port (e.g. "5901/tcp"). Returns empty string if the port is not mapped.
func (*Container) Pull ¶
Pull fetches changes from the container and integrates them into the local branch.
provider and model control AI commit message generation. See https://github.com/maruel/genai for valid names. If provider is empty, a default message is used.
type StartOpts ¶
type StartOpts struct {
// BaseImage is the full Docker image reference (e.g.
// "ghcr.io/maruel/md:v1.0" or "myregistry/custom:tag"). When empty,
// DefaultBaseImage is used.
BaseImage string
Display bool
Tailscale bool
TailscaleAuthKey string
TailscaleEphemeral bool
Labels []string
NoSSH bool
Quiet bool
}
StartOpts configures container startup.