Skip to content

Add globalConfigSourceRegistry to match middleware pattern#206

Merged
clavery merged 3 commits intomainfrom
clavery/global-config-source-registry
Feb 25, 2026
Merged

Add globalConfigSourceRegistry to match middleware pattern#206
clavery merged 3 commits intomainfrom
clavery/global-config-source-registry

Conversation

@clavery
Copy link
Collaborator

@clavery clavery commented Feb 25, 2026

Summary

  • Adds a globalConfigSourceRegistry singleton that resolveConfig() auto-includes, matching the existing globalMiddlewareRegistry and globalAuthMiddlewareRegistry patterns
  • Eliminates per-call plugin source plumbing — loadConfig() callers no longer need to pass getPluginSources()
  • B2CPluginManager.applyMiddleware() now registers config sources globally alongside HTTP and auth middleware
  • Fixes silent MCP server bug where plugin config sources were dropped (mcp.ts:277 calls loadConfig() without plugin sources)
  • Simplifies VS Code extension by removing the resolveConfigWithPlugins() wrapper

Test isolation

  • Adds B2C_SKIP_PLUGIN_HOOKS env var guard to all collectPlugin* methods in BaseCommand — prevents real plugins (keychain, password-store, etc.) from running during tests
  • Adds mocha root hooks to CLI, MCP, and SDK packages that clear all global registries before each test
  • Fixes a pre-existing test isolation issue where locally installed plugins could pollute test state (plugin sources accumulated across tests)

Test plan

  • SDK tests pass (1328 passing)
  • CLI tests pass (523 passing, 7s — with plugins installed locally)
  • MCP tests pass (346 passing)
  • Lint passes
  • Typecheck passes

Add a global ConfigSourceRegistry singleton that resolveConfig() auto-includes,
matching the existing globalMiddlewareRegistry and globalAuthMiddlewareRegistry
patterns. This eliminates the need to manually pass plugin config sources to
every resolveConfig()/loadConfig() call.

Changes:
- New ConfigSourceRegistry class with register/unregister/getSources/clear
- resolveConfig() auto-includes globalConfigSourceRegistry sources
- B2CPluginManager.applyMiddleware() registers config sources globally
- Simplified BaseCommand: removed getPluginSources() and pluginSources properties
- Simplified 6 loadConfig() callsites across CLI commands
- Deprecated PluginSources type in cli/config.ts
- VS Code extension: removed resolveConfigWithPlugins() wrapper
- Fixes MCP server bug where plugin config sources were silently dropped
@clavery clavery requested a review from wei-liu-sf as a code owner February 25, 2026 01:18
…istries)

Add B2C_SKIP_PLUGIN_HOOKS env var guard to all three collectPlugin* methods
in BaseCommand to prevent real plugins (keychain, password-store, etc.) from
running during tests. Add mocha root hooks to CLI, MCP, and SDK packages that
set this env var and clear global registries before each test.

This fixes a pre-existing test isolation issue where locally installed plugins
could pollute test state, made visible by the globalConfigSourceRegistry
addition (plugin config sources accumulated O(N^2) across N tests).
Copy link
Contributor

@patricksullivansf patricksullivansf left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. As it makes config registry global, but ability to call loadConfig/resolveConfig multiple times and get fresh results remains (needed for long running MCP).

@clavery clavery merged commit eff87af into main Feb 25, 2026
5 of 7 checks passed
@clavery clavery deleted the clavery/global-config-source-registry branch February 25, 2026 02:48
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