KB / Memory / tech-codexbar-new-provider-is-a-plugin
A new CodexBar provider is a declarative spec plus one TypeScript plugin
CodexBar moved simple API-key providers to bundled QuickJS plugins; a new provider is ~25 lines of Swift plus a .ts file, not bespoke Swift
A new CodexBar provider is a declarative PluginProviderSpec plus one bundled TypeScript plugin. It is not bespoke Swift. Simple API-key providers were migrated during the 0.68 cycle (refactor(plugins): add declarative API-key provider builders, migrate simple API-key providers).
The whole provider is: case <id> in UsageProvider; a <Name>ProviderDescriptor.swift declaring id: .<id>, with public static let spec = PluginProviderSpec( and apiKeyField: .init(; <id>.ts + its transpiled <id>.js; the icon SVG. That is roughly 25 lines of Swift.
Why: Scripts/regenerate-provider-manifests.sh reads the enum order plus the descriptor's shape and generates the descriptor manifest, the implementation manifest, ProviderInstanceIDAliases.generated.swift, and docs/provider-ids.md. Having both spec and apiKeyField makes the script emit PluginAPIKeyProviderImplementation(spec: X.spec), so no ProviderImplementation file is needed at all.
How to apply:
- Run
Scripts/regenerate-plugin-js.shandScripts/regenerate-provider-manifests.sh; both have acheckmode that CI enforces. - In a plugin
.ts,catch (error) { void error; ... }— sucrase rewrites the optional catch binding and oxlint'sno-unused-varsthen fails on the result. Annotate parameters; the.tsis type-checked. ctx.format.usd()is native en_US currency formatting, so money rows are exact — write literal expectations in tests.- Adding a provider also needs:
BurnProviderChoice(asserted exhaustive), thebalanceOnly/fingerprint constants inProviderArchitectureGatekeeperTests, the advertised provider count (87 -> 88) across 7 files including 23 site locales, adocs/index.htmlprovider card, and a re-rendereddocs/social.png. - The
plugin-provider-specs.jsongolden covers a curated 31-provider list, not every provider, so a new provider need not be added. - CI runs
ubuntu-24.04with Swift 6.3.3;CodexBarPluginTests(TestsPlugin) andCodexBarLinuxTestsrun there, butTests/CodexBarTestsis macOS-only.
Gatekeeper fingerprints can be recomputed off-macOS: ProviderDescriptorRegistry lives in CodexBarCore, so a throwaway test in TestsPlugin can run the test's own hash over the registry and print the new constants. Verified: the untouched debugLogUnavailableMessage fingerprint reproduced its committed value exactly.
Decline history: project-anyrouter-codexbar-declined.
Sources