refactor: consolidate default hub configuration into infra - #387
Open
gblanc-1a wants to merge 1 commit into
Open
refactor: consolidate default hub configuration into infra#387gblanc-1a wants to merge 1 commit into
gblanc-1a wants to merge 1 commit into
Conversation
Two divergent copies existed: packages/infra/src/hub/default-hubs.ts (Amadeus + community, config/default-hubs.json) and the extension's src/config/default-hubs.ts (awesome-copilot + a non-existent community hub, config/defaultHubs.json). The infra module is now the single source of truth for both delivery layers: - add isDefaultHub()/isRecommendedDefaultHub(), comparing type+location case-insensitively and ignoring the git ref - split icon (plain text, CLI) from codicon (VS Code selector) so one config can serve both hosts - move the JSON to packages/infra/config/default-hubs.json (the path the loader reads) and drop the camelCase extension copy - give only the recommended hub recommended: true; two made getRecommendedHub() order-dependent - replace the h.name === 'Amadeus' compare in cli init with the predicate No behavior change beyond the recommended-flag fix.
mvgadagi
reviewed
Aug 13, 2026
| try { | ||
| // Try to load from JSON file in packages/infra/config/. `__dirname` is | ||
| // available at runtime because this package compiles to CommonJS. | ||
| const configPath = path.join(__dirname, '..', '..', 'config', 'default-hubs.json'); |
Contributor
There was a problem hiding this comment.
Hello @gblanc-1a thanks a lot for the this refractor, very nice to manage it at one place ❤️
It seems this path still returns false in the next line, so in the end the json file is not used instead it always uses the hardcoded config.
But I will have quick discussion with you once you back to discuss and I drafted the pr to you fork and once we align we can go with the merge
https://github.com/gblanc-1a/prompt-registry/pull/13/changes/d7418759dfdc313d395cad140220022a89157085..75679ec5f2679ba86732fb2acaa23db84d2744c6
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.
Description
Two divergent copies of the default-hub configuration existed and had drifted apart:
packages/infra/src/hub/default-hubs.tsapps/vscode-extension/src/config/default-hubs.tsgithub/awesome-copilot+promptregistry/community-hubconfig/default-hubs.jsonconfig/defaultHubs.json(camelCase)initThe extension's hardcoded fallback pointed at a hub that does not exist (
promptregistry/community-hub), and the twoiconfields meant different things — a VS Code codicon in one, a CLI emoji in the other. This makesinfrathe single source of truth for both delivery layers.Type of Change
Mostly a refactor, but it does fix one real defect — see the
recommendedflag below.Related Issues
None. Prerequisite for the auth-diagnostics work that replaces #374, which needs
isDefaultHub.Changes Made
apps/vscode-extension/config/defaultHubs.jsoncarriedrecommended: true, andgetRecommendedHub()returns the first match. Only the Amadeus hub is recommended now. The community hub consequently loses its ⭐ and "(recommended)" suffix in the first-run picker — the intended behavior.isDefaultHub(reference)andisRecommendedDefaultHub(reference), comparingtype+locationcase-insensitively and ignoring the git ref (a default hub pinned to another branch is still the same hub).icon(plain text/emoji, for the CLI) from a new optionalcodicon(VS Code selector), so one config serves both hosts without either rendering the other's value.extension.tsnow uses$(${hub.codicon ?? 'cloud'}).apps/vscode-extension/src/config/default-hubs.tsand its stale README, which documented filenames (defaultHubs.ts) that no longer existed.packages/infra/config/default-hubs.json— the path the loader actually reads — and addedconfigto infra'spackage.jsonfilesso it ships when published.h.name === 'Amadeus'string compare inpackages/cli/src/commands/init.tswithisRecommendedDefaultHub.iconis now plain text,codiconadded), the root README path,docs/contributor-guide/architecture/validation.md, and dropped the now-dead!config/allowlist from.vscodeignore.Testing
Test Coverage
New
packages/infra/test/hub/default-hubs.test.ts— 11 tests covering both predicates (same reference, different ref, case-insensitive location, wrong type, unrelated hub) plus two invariants that guard this PR's fix: exactly one entry isrecommended, and every entry has both aniconand acodicon.Manual Testing Steps
pnpm --filter "@ai-primitives-hub/*" build— clean.pnpm -C apps/vscode-extension run compile— clean, confirming the extension resolvesgetEnabledDefaultHubs/isDefaultHubfrominfra.pnpm -C apps/vscode-extension run test:unit— 2196 passing (no extension test imported the deleted module).eslint src test --fixin infra, cli, and the extension — clean.Not covered by automated tests: the first-run picker's rendered labels. The
codiconsplit is asserted at the config level (every entry has one), not at the UI level.Tested On
macOS
Windows
Linux
VS Code Stable
VS Code Insiders
The loader resolves its JSON path via
__dirname, which differs between the webpack bundle and a plain Node run — worth a sanity check on another platform, though both paths fall back to the identical hardcoded list.Screenshots
None captured. The visible change is in the first-run hub picker: the community hub no longer shows ⭐/"(recommended)".
Checklist
Documentation
Root README's repository-structure table pointed
config/at a path that does not exist; it now points atpackages/infra/config/. Newpackages/infra/config/README.mdreplaces the stale extension-side one.Additional Notes
Two judgement calls worth challenging:
packages/infra/config/, outsidedist/. The loader reads__dirname/../../config/default-hubs.json, so in the webpack-bundled extension it will not resolve and the hardcoded list is used instead. That list is byte-equivalent to the JSON, so behavior is identical either way — but it does mean the JSON is only an override for non-bundled (CLI) use. If you want it authoritative in the VSIX too, it needs a copy step.codiconis a new optional schema field. The alternative was to render the emoji directly in the picker and drop codicons entirely, which changes the UI. I preserved current rendering instead.Reviewer Guidelines
Please pay special attention to:
recommendedflag change: the community hub visibly loses its star. Confirm that is wanted.isDefaultHubignoringref— the auth fix uses this predicate to decide "no access to this hub is expected, not an error", so a too-broad match would silence a genuine failure on a fork.By submitting this pull request, I confirm that my contribution is made under the terms of the Apache License 2.0.