refactor(client-mapping): single agent-host registry#385
Conversation
Deploying allagents with
|
| Latest commit: |
cc0e3f7
|
| Status: | ✅ Deploy successful! |
| Preview URL: | https://b058bb6e.allagents.pages.dev |
| Branch Preview URL: | https://refactor-377-host-registry.allagents.pages.dev |
Code Review: ✅ APPROVEThis is a clean, well-scoped refactor. The new Verification gate (#377)
CLAUDE.md compliance
Design notes worth calling out (positive)
Minor (non-blocking)1. Dead runtime use of The new import type { ClientType } from './workspace-config.js';
// ... no `void ClientTypeSchema;` needed2. The helper is implemented and tested elsewhere but isn't referenced anywhere in this PR. The issue mentions it'll be wired into the singular-rename's help text. Fine to land prep-work, but worth a one-line PR comment noting the intended consumer or a TODO that points at the issue, so it doesn't sit as dead code if the follow-up gets dropped. 3. The runtime const _check: _HostsCoverEveryClient = true;
void _check;Same compile-time guarantee can be expressed at the } as const satisfies readonly AgentHost[];Plus a separate Optional follow-upPR body notes a follow-up to "migrate call sites from the legacy records to Approving. |
`CLIENT_MAPPINGS` and `USER_CLIENT_MAPPINGS` were two near-duplicate ~130-line records that had already drifted (windsurf's user-scope path differs from its project-scope path, but the divergence was hard to spot in review). Consolidates both into a single `AGENT_HOSTS` array — one entry per host, with paired `project` and `user` mappings. - `AgentHost` interface and `AGENT_HOSTS` const list every supported client exactly once. Pattern modelled after `cli/cli`'s `internal/skills/registry/registry.go::AgentHost`. - `CLIENT_MAPPINGS` / `USER_CLIENT_MAPPINGS` are now derived via `Object.fromEntries(AGENT_HOSTS.map(...))` so future drift between project and user maps is impossible by construction. - New helpers: `findHostById`, `getMapping(id, scope)`, `uniqueProjectSkillsPaths`, `agentHelpList`. - Compile-time `_HostsCoverEveryClient` assertion + a runtime test that walks every `ClientTypeSchema` value catches the "added to enum but forgot to register" bug class. - Intentional deltas (`windsurf` and `copilot` differing between scopes) preserved and tested explicitly so future reviewers see them as deliberate. All existing call sites (`CLIENT_MAPPINGS.claude`, etc.) keep working — the exports are the same shape, just frozen and derived. Optional follow-up: migrate consumers to `getMapping(id, scope)` and drop the derived records. Closes #377
a61bd5c to
cc0e3f7
Compare
Summary
Folds
CLIENT_MAPPINGSandUSER_CLIENT_MAPPINGSinto a singleAGENT_HOSTSregistry — one entry per host, with pairedproject/usermappings. The legacy records are kept as derived constants (viaObject.fromEntries(AGENT_HOSTS.map(...))) so existing consumers keep working unchanged, and future drift between project and user maps is impossible by construction.Pattern modelled after
cli/cli'sinternal/skills/registry/registry.go::AgentHost.findHostById,getMapping(id, scope),uniqueProjectSkillsPaths,agentHelpList._HostsCoverEveryClientassertion + a runtime test walking everyClientTypeSchemavalue catches the "added to enum but forgot to register" bug class.Test plan
bun run build,bun run typecheckbun test— 1197 pass / 0 failCLIENT_MAPPINGS+USER_CLIENT_MAPPINGSinto a single agent-host registry #377:ClientTypevalue has exactly oneAGENT_HOSTSentry (no duplicates).getMapping(id, scope)returns identical content toCLIENT_MAPPINGS[id]/USER_CLIENT_MAPPINGS[id]for every (client, scope) pair..windsurf/skills/vs.codeium/windsurf/skills/).Optional follow-up: migrate call sites from the legacy records to
getMapping(id, scope)and drop the derived constants entirely.Closes #377