Skip to content

PDX-463: feat(mcp): fetch NitroX component packages from factPackages repo at release time#156

Merged
mrdailey99 merged 3 commits into
developfrom
feature/PDX-463-nitrox-component-package-retrieval
May 9, 2026
Merged

PDX-463: feat(mcp): fetch NitroX component packages from factPackages repo at release time#156
mrdailey99 merged 3 commits into
developfrom
feature/PDX-463-nitrox-component-package-retrieval

Conversation

@mrdailey99
Copy link
Copy Markdown
Collaborator

Summary

  • Added scripts/fetch-nitrox-packages.cjs to the prepack hook: fetches all component package files from ProvarTesting/factPackages@main, regenerates NITROX_COMPONENT_CATALOG.md, and writes NITROX_CATALOG_SOURCE.json with the commit SHA
  • Falls back gracefully to the committed catalog if no GITHUB_TOKEN/GH_TOKEN is set or the fetch fails; logs a warning and always exits 0 (release never blocked)
  • Added provar://nitrox/catalog-source MCP resource (served from NITROX_CATALOG_SOURCE.json) so consumers can verify which factPackages commit is bundled
  • docs/NITROX_CATALOG_SOURCE.json committed as a default (null SHA) that gets overwritten on each successful release build
  • docs/mcp.md updated to document the auto-refresh mechanism and the new resource

Jira

https://provartesting.atlassian.net/browse/PDX-463

Test plan

  • yarn compile passes
  • yarn test:only passes (941 tests, +3 new readCatalogSource tests)
  • node scripts/mcp-smoke.cjs passes (54/54)
  • yarn lint passes (0 errors)

Changes

  • scripts/fetch-nitrox-packages.cjs: new release-time fetch script
  • docs/NITROX_CATALOG_SOURCE.json: new default version file (null SHA)
  • package.json: prepack now runs fetch before sf-prepack; compile copies source JSON to lib/mcp/docs/
  • src/mcp/server.ts: adds provar://nitrox/catalog-source resource + exports readCatalogSource helper
  • test/unit/mcp/server.test.ts: 3 new unit tests for readCatalogSource
  • docs/mcp.md: updated provar://nitrox/component-catalog section; added provar://nitrox/catalog-source entry

… repo at release time

RCA: NitroX component packages were statically bundled in the repo and not updated automatically; the source of truth is the ProvarTesting/factPackages GitHub repo (main branch), so packages would silently drift stale between releases.
Fix: Added scripts/fetch-nitrox-packages.cjs to the prepack hook; it downloads all component package files from factPackages@main, regenerates NITROX_COMPONENT_CATALOG.md, and writes NITROX_CATALOG_SOURCE.json with the commit SHA. On failure (no token, network error) it logs a warning and falls back to the committed catalog — the release is never blocked. A new provar://nitrox/catalog-source MCP resource exposes the bundled version so consumers can verify which factPackages commit is in use.
Copilot AI review requested due to automatic review settings May 8, 2026 20:49
@github-actions
Copy link
Copy Markdown

github-actions Bot commented May 8, 2026

Quality Orchestrator

🟢 LOW · 4 / 100 · All changed files have mapped tests.


🧪 Tests to Run · Running 2 of 42 tests

  • unit/mcp/server.test.ts
  • unit/mcp/updateChecker.test.ts
▶ Run command
npx vitest run \
  unit/mcp/server.test.ts \
  unit/mcp/updateChecker.test.ts

⚡ quality-orchestrator  ·  /qo stub <file>  ·  qo analyze-local

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR adds a release-time mechanism to refresh the bundled NitroX component catalog from ProvarTesting/factPackages, records the source commit metadata, and exposes that metadata via a new MCP resource so consumers can verify which catalog version is bundled.

Changes:

  • Add scripts/fetch-nitrox-packages.cjs and run it during prepack to fetch component package files and regenerate docs/NITROX_COMPONENT_CATALOG.md.
  • Add docs/NITROX_CATALOG_SOURCE.json + readCatalogSource() and expose it as a new MCP resource provar://nitrox/catalog-source.
  • Update build copying/tests/docs to include and validate the new catalog source metadata.

Reviewed changes

Copilot reviewed 6 out of 6 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
scripts/fetch-nitrox-packages.cjs New prepack-time fetch + catalog regeneration script and source metadata writer.
package.json Runs the fetch script in prepack and includes the source JSON in compile outputs.
src/mcp/server.ts Adds provar://nitrox/catalog-source resource and readCatalogSource() helper.
test/unit/mcp/server.test.ts Adds unit coverage for readCatalogSource() fallback/parse behavior.
docs/NITROX_CATALOG_SOURCE.json Adds default committed source metadata (null SHA/timestamp).
docs/mcp.md Documents auto-refresh behavior and the new MCP resource.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread scripts/fetch-nitrox-packages.cjs Outdated
Comment on lines +134 to +135
async function downloadRaw(filePath, token) {
const url = `https://raw.githubusercontent.com/${REPO_OWNER}/${REPO_NAME}/${BRANCH}/${filePath}`;
Comment on lines +44 to +53
function httpsGet(url, headers) {
return new Promise((resolve, reject) => {
const parsed = new URL(url);
const reqHeaders = {
'User-Agent': 'provardx-cli/fetch-nitrox-packages',
Accept: 'application/json',
...headers,
};
const req = https.get(
{ hostname: parsed.hostname, path: parsed.pathname + parsed.search, headers: reqHeaders },
Comment on lines +77 to +86
function httpsGetBuffer(url, headers) {
return new Promise((resolve, reject) => {
const parsed = new URL(url);
const req = https.get({ hostname: parsed.hostname, path: parsed.pathname + parsed.search, headers }, (res) => {
if (res.statusCode === 301 || res.statusCode === 302) {
resolve(httpsGetBuffer(res.headers.location, headers));
return;
}
const chunks = [];
res.on('data', (chunk) => chunks.push(chunk));
mrdailey99 added 2 commits May 8, 2026 22:03
…ings

RCA: The factPackages repo stores component files under fact-*/src/components/ not fact-*/components/, so the path-matching regexes and catalog builder needed updating; additionally nine pre-existing unicorn/numeric-separators-style lint warnings in updateChecker.ts and its test file were left unaddressed.
Fix: Updated PKG_JSON_RE and COMPONENT_FILE_RE in fetch-nitrox-packages.cjs to match the fact-*/src/ layout and adjusted buildCatalogFromDir to navigate the src/ subdirectory; ran eslint --fix on updateChecker.ts and updateChecker.test.ts to resolve all numeric-separator warnings, leaving the project at 0 lint errors and 0 warnings.
RCA: downloadRaw() used the branch name (main) in the raw URL rather than the resolved commit SHA, so files could be fetched from a different commit than the one the tree listing described; additionally both httpsGet and httpsGetBuffer had no timeout, meaning a stalled network connection would block prepack indefinitely.
Fix: Added REQUEST_TIMEOUT_MS (15s) to both http helpers via req.setTimeout/req.destroy so hangs fail fast and fall through to the graceful fallback; updated downloadRaw to accept and use the commitSha parameter so all downloads are pinned to the same commit as the tree.
@mrdailey99
Copy link
Copy Markdown
Collaborator Author

Addressed all three Copilot review comments in commit 019bb87:

  1. downloadRaw SHA consistencydownloadRaw now accepts commitSha as a parameter and pins the raw URL to that SHA (raw.githubusercontent.com/.../${commitSha}/...) instead of the branch name, so every download corresponds exactly to the same commit as the tree listing.

  2. httpsGet timeout — Added REQUEST_TIMEOUT_MS = 15_000 and wired req.setTimeout(REQUEST_TIMEOUT_MS, () => req.destroy(...)) so a stalled connection aborts after 15 s and propagates to the catch block, falling through to the graceful fallback.

  3. httpsGetBuffer timeout — Same req.setTimeout / req.destroy pattern applied.

@mrdailey99 mrdailey99 merged commit b2d0afc into develop May 9, 2026
4 checks passed
@mrdailey99 mrdailey99 deleted the feature/PDX-463-nitrox-component-package-retrieval branch May 12, 2026 21:33
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