fix(cli): discover adapters authored with registerCommand - #423
Open
ankitranjan7 wants to merge 1 commit into
Open
fix(cli): discover adapters authored with registerCommand#423ankitranjan7 wants to merge 1 commit into
ankitranjan7 wants to merge 1 commit into
Conversation
Discovery gated every candidate file through a regex over its source text (`\b(?:cli|registerSiteAuthCommands|onStartup|...)\s*\(`), so a user adapter written with `registerCommand` — a public export of `@agentrhq/webcmd/registry` — was never imported, while `adapter status` still listed it. The regex also matched comments and strings, so `// cli(` was enough to flip a file to discoverable. Gate on the runtime import specifier instead of on call syntax: a file can only register anything by importing the runtime, so this covers every authoring style and stops matching call-like comments. Helper modules that never import the runtime are still skipped. `registerCommand` is dropped from the public export surface: it takes the raw/lazy manifest shape (`func`, `_lazy`, `_modulePath`), not the authoring shape, and adapters written against it failed at execution with "has no func or pipeline". `cli()` is now the only way to author an adapter. Load failures are recorded and surfaced: `missingPluginGuidance` leads with the real cause and file path instead of "Site X is not installed", and `adapter status` annotates each file that discovery refused to load. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Contributor
🟠 Maintainer review suggested — low confidenceThe automated review could not reach a fully supported conclusion. Limitations
This review is advisory and does not block merging. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
An adapter in
~/.webcmd/clis/authored withregisterCommand— a public export of@agentrhq/webcmd/registry— was never imported, sowebcmd quotes listsaid the site was not installed whilewebcmd adapter statuslisted the same command as present.The problem
Discovery gated every candidate file through a regex over its source text:
/\b(?:cli|registerSiteAuthCommands|onStartup|onBeforeExecute|onAfterExecute)\s*\(/. Three consequences:registerCommand(is not in that list, so a file using the public export was silently never imported.// cli(to the same file flipped it to discoverable.adapter statusreads the filesystem, so it reported commands discovery had refused to load.What changed
src/discovery.ts). A file can only register anything by importing the runtime, so discovery now tests for an import of@agentrhq/webcmd/{registry,plugin-runtime,hooks}. That covers every authoring style instead of an enumerated list of call names, and a call-shaped comment no longer decides anything. Helper modules that never import the runtime are still skipped, so their side effects still do not run at startup. Chosen over deleting the gate entirely, which would execute every helper module in an adapter directory at startup.cli()is the only authoring API (src/registry-api.ts).registerCommandis removed from the public export surface: it takes the raw/lazy manifest shape used by the manifest fast path, not the authoring shape, and adapters written against it died at execution withhas no func or pipeline. It is undocumented and unused outside the runtime. An adapter importing it now fails loudly at load with the missing-export error, instead of registering a command that cannot run.src/discovery.ts). Every failed import is kept with its site, absolute path, and cause;missingPluginGuidancereports those instead ofSite "X" is not installed.when the site has failing files.adapter statusagrees with availability (src/cli.ts). Each row carriesloadError; the table annotates(failed to load: …)and the JSON output gained aloadErrorfield.Before / After
Before (
node dist/src/main.js,HOMEin a temp dir, adapter usesregisterCommand):After, same adapter:
After, same file rewritten with
cli({ …, access: 'read', func }):Tests
src/discovery.test.tsgains five cases: acli()adapter in a tempHOMEregisters; a file whose onlycli(is a comment registers nothing and records no failure; a module missingaccessrecords the real cause andmissingPluginGuidanceleads with it rather than "is not installed"; an adapter importingregisterCommanddoes not register and its failure names the export; failed files are recorded by the absolute pathadapter statuskeys off.src/cli.test.tscovers the newloadErrorJSON field.npm run typecheckclean.npx vitest run --project unit: 2708 passed, 1 skipped, 0 failed (the suite needsnpm run buildfirst — 120 hosted/manifest tests fail withoutdist/onmaintoo).npm run buildclean.🤖 Generated with Claude Code