WardrikACP (wardrik_acp v0.1.0-rc.1)

Copy Markdown

Gives WardrikCore agents coding agents, such as Claude Code, as tools. Each one runs over the Agent Client Protocol (ACP).

children = [
  {WardrikACP,
   name: MyApp.ACP,
   worktrees: "/var/lib/my_app/worktrees",
   checkouts: [billing: "/srv/billing"],
   harnesses: [claude: [command: "claude-agent-acp"]]}
]

WardrikCore.start_agent(
  agent_id: "builder",
  model: "anthropic:claude-haiku-4-5",
  capabilities: [{WardrikACP, name: MyApp.ACP, harnesses: [:claude]}],
  middleware: [{WardrikPolicy.Middleware, WardrikPolicy.new!(ask: ["claude/execute"])}]
)
  • The model sees a tool named claude. Its arguments are task, checkout and work.
  • Each work name has its own worktree, branch and session. Calling it again continues them.
  • Each permission request from the coding agent runs through the agent's middleware as a tool call named claude__execute, claude__edit, and so on, by ACP tool kind. Its arguments are the request's rawInput.
  • A request that parks parks the call. Answer it by the call's ID, as for any tool call.
  • The answer lists the branch, its commits, and the coding agent's last message.
  • Harness options are in WardrikACP.Harness.

Telemetry

  • [:wardrik_acp, :sweep] after each sweep. Measurements: :removed. Metadata: :acp, :removed (the paths).

  • [:wardrik_acp, :update] for each session update. Metadata: :agent_id, :span, :harness, :update (the ACP SessionUpdate map).

Summary

Functions

Returns a specification to start this module under a supervisor.

Starts WardrikACP. Coding agents start when a call first needs them.

Removes each worktree whose work is in its checkout's base, with its branch. Returns the paths removed.

Returns a tool for each of the named coding agents.

Functions

child_spec(init_arg)

Returns a specification to start this module under a supervisor.

See Supervisor.

start_link(opts)

@spec start_link(keyword()) :: Supervisor.on_start()

Starts WardrikACP. Coding agents start when a call first needs them.

Options

  • :name (atom/0) - Required. The name agents and functions use to find it.

  • :harnesses (list of tuple of , keyword/0 values) - Coding agents, as a list of name and options. See WardrikACP.Harness. The default value is [].

  • :checkouts (list of tuple of , values) - Git repositories coding agents work in, as a list of name and path or options. See WardrikACP.Checkout. The default value is [].

  • :sweep - Milliseconds between sweeps, or :infinity. The first runs at start. See sweep/1. The default value is 86400000.

  • :worktrees (String.t/0) - Required. The directory for worktrees, one per piece of work.

sweep(acp)

@spec sweep(atom()) :: [Path.t()]

Removes each worktree whose work is in its checkout's base, with its branch. Returns the paths removed.

WardrikACP.sweep(MyApp.ACP)
#=> ["/var/lib/my_app/worktrees/claude/billing/builder/_/fix-login"]
  • Work is in the base when merging the branch would change nothing: merged, squashed or cherry-picked.
  • A worktree stays while a call uses its coding agent, while a request waits, and while it has changes or untracked files. An idle coding agent is stopped first.
  • With fetch: true, the checkout runs git fetch first.

tools(context, opts)

Returns a tool for each of the named coding agents.

Options

  • :name - required. The WardrikACP name.
  • :harnesses - required. A coding agent's name or a list of them, as :claude.
  • :checkouts - the checkouts the tools may work in. All of them by default.