Skip to content

Comments

Add plugin support and centralize config resolution in VS Code extension#185

Closed
clavery wants to merge 3 commits intofeature/content-treeviewfrom
feature/generic-plugins-hooks
Closed

Add plugin support and centralize config resolution in VS Code extension#185
clavery wants to merge 3 commits intofeature/content-treeviewfrom
feature/generic-plugins-hooks

Conversation

@clavery
Copy link
Collaborator

@clavery clavery commented Feb 22, 2026

Summary

Stacked on #174.

Plugin support for the VS Code extension

The b2c-cli plugin system (keychain managers, vault integrations, etc.) was only available through oclif hooks. The VS Code extension called resolveConfig() directly, bypassing all installed plugins. This adds a new SDK module (@salesforce/b2c-tooling-sdk/plugins) that handles plugin discovery and loading without depending on @oclif/core, making it reusable by the extension, MCP server, or any non-oclif consumer.

New SDK module (packages/b2c-tooling-sdk/src/plugins/):

  • discovery.ts — Discover installed plugins by reading the oclif data directory
  • loader.ts — Hook context shim + dynamic import of hook files (with new Function workaround for esbuild CJS bundling)
  • manager.tsB2CPluginManager orchestrator: invokes b2c:config-sources, b2c:http-middleware, and b2c:auth-middleware hooks with same priority mapping as the CLI
  • index.ts — Barrel file + ./plugins subpath export

Extension integration (packages/b2c-vs-extension/src/plugins.ts):

  • Lazy singleton that initializes B2CPluginManager during activation (fire-and-forget, non-fatal)
  • getPluginConfigSources() returns { sourcesBefore, sourcesAfter } for config resolution

Centralize config resolution

Replace 7 independent resolveConfigWithPlugins() call sites with a single B2CExtensionConfig singleton that lazily resolves, caches, and exposes getConfig() / getInstance() / getConfigError() / reset().

  • Add dw.json file watcher (RelativePattern + onDidSaveTextDocument) that auto-resets config and fires onDidReset event
  • WebDAV tree subscribes to onDidReset for automatic refresh on config changes
  • Silently handle FileNotFound in tree re-expansion after server switch (no error toasts for missing paths)
  • Delete WebDavConfigProvider (fully replaced by B2CExtensionConfig)
  • Add resolveForDirectory() for the deploy-cartridge case that uses a different working directory

Test plan

  • pnpm --filter @salesforce/b2c-tooling-sdk run test:agent — plugin discovery, loader, manager tests
  • pnpm --filter b2c-vs-extension run typecheck:agent && pnpm --filter b2c-vs-extension run build
  • pnpm run lint:agent
  • Reload extension with plugins installed — verify Output > B2C DX shows plugin discovery
  • Open SCAPI explorer — verify prefill populates from config (including plugin-provided credentials)
  • Edit dw.json hostname — WebDAV tree should auto-refresh (check [Config] log lines)
  • Switch server in dw.json while tree is expanded — no error toasts for missing paths

Replace 7 independent resolveConfigWithPlugins() call sites with a
single B2CExtensionConfig singleton that caches resolved config and
exposes getInstance()/getConfig()/getConfigError()/reset().

- Add dw.json file watcher (RelativePattern + onDidSaveTextDocument)
  that auto-resets config and fires onDidReset event
- WebDAV tree subscribes to onDidReset for automatic refresh on
  config changes
- Silently handle FileNotFound in tree re-expansion after server switch
- Delete WebDavConfigProvider (fully replaced by B2CExtensionConfig)
@clavery clavery requested a review from wei-liu-sf as a code owner February 22, 2026 02:44
@clavery clavery changed the title Centralize config resolution in VS Code extension Add plugin support and centralize config resolution in VS Code extension Feb 22, 2026
@clavery
Copy link
Collaborator Author

clavery commented Feb 22, 2026

Superseded by #186

@clavery clavery closed this Feb 22, 2026
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