Skip to content

fix: doctor command never discovers user agent plugins - #403

Open
djbclark wants to merge 2 commits into
subsy:mainfrom
djbclark:fix-doctor-user-plugin-discovery
Open

fix: doctor command never discovers user agent plugins#403
djbclark wants to merge 2 commits into
subsy:mainfrom
djbclark:fix-doctor-user-plugin-discovery

Conversation

@djbclark

@djbclark djbclark commented Aug 2, 2026

Copy link
Copy Markdown

Summary

  • `ralph-tui doctor --agent ` always reports "Unknown agent plugin", even for a custom plugin under `~/.config/ralph-tui/plugins/agents/` that `ralph-tui run` loads and executes fine.
  • Root cause: `run.tsx`'s `initializePlugins()` correctly calls `registry.initialize()` (which internally calls `discoverUserPlugins()`) before running, but `doctor.ts`'s `runDiagnostics()` only ever called `registerBuiltinAgents()` — so doctor's view of the world never includes user plugins.
  • Also adds an opt-in `RALPH_TUI_DEBUG_PLUGINS=1` env var to doctor's output. Right now a user plugin load failure (bad import, thrown error in the factory, etc.) is silently swallowed into a `PluginLoadResult[]` that nothing in the CLI ever surfaces — this makes debugging a broken custom plugin very hard. Confirmed by direct testing while building a custom plugin locally.

Test plan

  • `bun run typecheck`
  • `bun run build`
  • Manually verified against a local custom user plugin: before the fix, `doctor --agent ` reported "Unknown agent plugin"; after, it correctly loads and runs detection/preflight against it.

Summary by CodeRabbit

  • Bug Fixes
    • The doctor command now recognizes user-installed agent plugins.
    • Added optional diagnostic output for plugin loading when debug mode is enabled.

registry.initialize() (which calls discoverUserPlugins()) is already
called correctly in run.tsx's initializePlugins() before actually
running an agent, but doctor.ts only called registerBuiltinAgents()
— so `ralph-tui doctor --agent <custom-plugin>` always reported
"Unknown agent plugin" even for a plugin `run` could load fine.

Also adds an opt-in RALPH_TUI_DEBUG_PLUGINS env var to doctor's output,
since a user plugin load failure is otherwise silently swallowed into
a PluginLoadResult the CLI never prints anywhere.
@vercel

vercel Bot commented Aug 2, 2026

Copy link
Copy Markdown

@djbclark is attempting to deploy a commit to the plgeek Team on Vercel.

A member of the Team first needs to authorize it.

@coderabbitai

coderabbitai Bot commented Aug 2, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro Plus

Run ID: c7df433a-b2fe-4a6d-9e96-c386fee49b34

📥 Commits

Reviewing files that changed from the base of the PR and between e2a4f97 and c876997.

📒 Files selected for processing (1)
  • src/commands/doctor.test.ts

📝 Walkthrough

Walkthrough

The doctor command now initializes user-installed agent plugins before agent selection. It can log plugin-load results as formatted JSON to stderr when RALPH_TUI_DEBUG_PLUGINS is set. The related test mock now returns an empty resolved plugin list.

Changes

Doctor plugin support

Layer / File(s) Summary
Plugin initialization before agent selection
src/commands/doctor.ts, src/commands/doctor.test.ts
runDiagnostics loads user agent plugins before resolving the requested agent. The debug branch logs plugin-load results as formatted JSON to stderr. The test mock returns Promise.resolve([]).

Estimated code review effort: 2 (Simple) | ~10 minutes

Suggested reviewers: subsy

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and concisely describes the main fix: enabling the doctor command to discover user agent plugins.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches 💡 1
🛠️ Fix failing CI checks 💡
  • Create stacked PR
  • Commit on current branch

Warning

There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure.

🔧 ESLint

If the error stems from missing dependencies, add them to the package.json file. For unrecoverable errors (e.g., due to private dependencies), disable the tool in the CodeRabbit configuration.

ESLint install failed. For unrecoverable errors, disable the tool in CodeRabbit configuration.


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

The doctor.ts fix (registry.initialize() to discover user plugins)
broke 9 doctor.test.ts tests whose mock registry didn't implement
initialize(). Added the missing mock method, matching the real
AgentRegistry interface. Confirmed zero regressions vs main across
the full suite (3843 -> 3933 tests, same 71 pre-existing unrelated
failures, all new grok/antigravity tests passing).
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.

1 participant