Skip to content

refactor: add per-agent types and register setup adapters - #137

Merged
Stephen Belanger (Qard) merged 1 commit into
mainfrom
refactor/agent-registry
Oct 6, 2026
Merged

Stephen Belanger (Qard) merged 1 commit into
mainfrom
refactor/agent-registry

Conversation

@Qard

@Qard Stephen Belanger (Qard) commented Oct 6, 2026 •

Copy link
Copy Markdown
Collaborator

Summary

Based on main now that #136 has merged.

This adds the agent model for the rest of the reorganization:

  • One concrete type per agent.
  • One trait per capability, which the agent types implement.
  • Each agent registers itself with the capabilities it supports.

A command looks agents up in its own registry, so an agent that lacks a capability simply isn't there. There is no central descriptor listing every agent's features.

// src/agents/mod.rs
pub(crate) struct Identity { id, source, aliases, display_name }
pub(crate) trait Agent: Send + Sync + 'static { fn identity(&self) -> &'static Identity; }
pub(crate) struct Agents<T: ?Sized> { … }        // get(name) by id, source or alias
pub(crate) struct Registrar { pub setup: Agents<dyn Setup> }
pub(crate) trait Register { fn register(self: Arc<Self>, registrar: &mut Registrar); }
pub(crate) fn registrar() -> &'static Registrar  // the one place every agent is listed

// src/agents/grok.rs
impl Register for Grok {
    fn register(self: Arc<Self>, registrar: &mut Registrar) {
        registrar.setup.insert(self);
    }
}

Setup is the first capability:

  • Each setup/<agent>.rs now has impl Setup for <Agent> instead of free enable/disable/update/stale functions.
  • run_enable, run_disable, run_update and update_warning dispatch through the registry instead of matching on SetupAgent.
  • The doctor's per-agent activation warnings move out of trace_runtime.rs into the Grok and Cursor Setup impls (activation_warning).

Identities replace duplicated tables. The clap enums (SetupAgent, DoctorAgent, ImportSource) still define the CLI surface, so value names and aliases are unchanged. Each enum gains identity(), which maps a variant to its agent. That replaces the id and display-name tables duplicated in:

  • setup (agent_details)
  • DoctorAgent::source/display_name
  • transcript_import::source_name

A new test checks that every SetupAgent variant has a registered setup adapter.

The next PR registers the remaining capabilities (translators, managed runs, transcript import) the same way.

Behaviour

None. The same CLI commands and output strings, and the same doctor warnings. CommandRunner is now passed as &mut dyn so the trait can be used as an object.

Testing

  • cargo clippy --all-features --all-targets -D warnings is clean.
  • cargo test --all-features --no-fail-fast: everything passes, including the new registry test, except trace_runtime::tests::doctor_reports_a_daemon_that_{cannot_authenticate_the_route,resolves_other_credentials}. Those fail the same way on main in my local environment.

🤖 Generated with Claude Code

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 6, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-06T12:33:33.369568Z fd8b9b2 PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

Base automatically changed from refactor/split-server to main October 6, 2026 14:42
Introduce `agents`, with one type per supported coding agent and an
`Identity` holding its CLI id, hook source, aliases and display name.
Each capability is a trait the agent types implement. An agent adds
itself to the registries for the capabilities it supports in
`Register::register`, so a command looks agents up in its own registry
and an unsupported capability is simply absent.

Setup is the first capability. Each setup module now implements
`Setup` for its agent type instead of exposing free functions, and
run_enable, run_disable, run_update and update_warning dispatch through
the registry rather than matching on SetupAgent. The doctor's
per-agent activation warnings for Grok and Cursor move into their
`Setup` impls.

The clap enums keep defining the CLI surface and map each variant to an
agent identity. The display-name and id tables duplicated in setup,
doctor and transcript import now come from those identities.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
@Qard
Stephen Belanger (Qard) merged commit 219ed2e into main Oct 6, 2026
20 checks passed
@Qard
Stephen Belanger (Qard) deleted the refactor/agent-registry branch October 6, 2026 15:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants