fix(docs): derive collection artifact counts from YAML at build time#1275
fix(docs): derive collection artifact counts from YAML at build time#1275
Conversation
- replace fs/path usage in collectionCards.ts with pure resolver fns - count YAML paths in docusaurus.config.js via customFields - pass counts to components via useDocusaurusContext - add useDocusaurusContext mock and jest.config.js mapping 🔧 - Generated by Copilot
- move fs/path counting to docusaurus.config.js via customFields - replace hardcoded artifacts in collectionCards.ts with resolver fns - add gitlab, jira, and rai-planning collections - add useDocusaurusContext mock and jest.config.js mapping - add npm run docs:test to PR template and contributing guides 🔧 - Generated by Copilot
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #1275 +/- ##
==========================================
- Coverage 87.72% 87.71% -0.02%
==========================================
Files 61 61
Lines 9320 9320
==========================================
- Hits 8176 8175 -1
- Misses 1144 1145 +1
Flags with carried forward coverage won't be shown. Click here to find out more. 🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
Advisory review, this PR is from a maintainer. Findings are informational only.
Review Overview
This PR cleanly eliminates the manual artifact-count maintenance burden in the Docusaurus collection cards by reading YAML manifests at build time. The architecture — separating static collectionCardDefinitions from dynamic resolveCollectionCards/resolveMetaCollections resolvers, injecting counts via customFields, and cross-validating with independent YAML reads in tests — is well-designed and idiomatic for Docusaurus. The documentation updates are consistent and the test infrastructure (mock + updated test) is correct.
Three minor advisory observations are left as inline comments.
Issue Alignment
✅ PR links Fixes #1248 and Fixes #1249. Based on the description, both issues relate to the manual-count maintenance problem. The changes directly address this by deriving counts automatically. Three previously missing collections (gitlab, jira, rai-planning) are added to the count list, which appears consistent with fixing a gap.
No scope creep detected.
PR Template Compliance
CollectionCardDefinition interface, two new exported resolver functions, a new mock, and build configuration additions. "Documentation update" alone does not accurately describe these changes. A "New feature" checkbox (or at minimum a note under "Other") would better reflect the nature of the code refactor.
All other template sections are filled in correctly. Required Automated Checks are all marked as passed.
Coding Standards
✅ Changed TypeScript and JavaScript files do not fall under any instruction file's applyTo patterns in this repository (instructions cover .ps1, .sh, .py, .cs, .rs, .tf, .bicep, and markdown). No convention violations detected against the applicable instruction files.
Markdown documentation changes (.md files) follow the markdown conventions — no heading skips, proper frontmatter, and concise additions.
Code Quality
Three advisory observations (inline):
index.tsxline 13 — Unsafeascast oncustomFields.collectionCountsbypasses theunknowntype from Docusaurus's typing. A nullish-coalescing fallback would prevent a hard crash if the field is absent.collectionCards.tsline 101 —?? 0silently swallows name mismatches betweencollectionCardDefinitionsandcollectionNamesindocusaurus.config.js. Test coverage mitigates this, but a dev-modeconsole.warnwould surface the issue earlier in the contribution loop.docusaurus.config.jsline 14 —fs.readFileSyncthrows a genericENOENTon a missing YAML. A descriptive error message naming the offending collection would improve DX during collection renames or additions.
No bugs, security issues, breaking changes, or resource leaks detected.
Action Items
These are informational suggestions only (advisory mode). No changes are required for merge:
- Consider adding "New feature" to the Type of Change checkboxes to accurately reflect the code refactoring.
- Optionally harden the type assertion in
index.tsxand the error message indocusaurus.config.jsper the inline suggestions.
Note
🔒 Integrity filter blocked 2 items
The following items were blocked because they don't meet the GitHub integrity level.
- #1248
issue_read: has lower integrity than agent requires. The agent cannot read data with integrity below "approved". - #1249
issue_read: has lower integrity than agent requires. The agent cannot read data with integrity below "approved".
To allow these resources, lower min-integrity in your GitHub frontmatter:
tools:
github:
min-integrity: approved # merged | approved | unapproved | none…L error - add optional chaining and nullish coalescing for collectionCounts cast - wrap readFileSync in try/catch with actionable error on missing manifest 🛡️ - Generated by Copilot
Replaced hardcoded artifact counts in the Docusaurus collection cards with build-time derivation from collection YAML manifests. Every time a skill, agent, or prompt was added to a collection,
collectionCards.tsrequired a manual count update that could silently break the site. The counts are now computed automatically fromcollections/*.collection.ymlduring the Docusaurus build.Contributing documentation and the PR template were updated to include
npm run docs:testas a required validation step so contributors know to verify counts after collection changes.Description
Build-Time Artifact Count Derivation
countYamlPaths()in docusaurus.config.js to read eachcollections/*.collection.ymland count- path:entries, exposing the result map throughcustomFields.collectionCountsartifactsintegers from the 12 card definitions in collectionCards.ts and introduced theCollectionCardDefinitioninterface that separates static metadata from dynamic countscollectionCardsandmetaCollectionsexports with pure resolver functionsresolveCollectionCards(counts)andresolveMetaCollections(counts)that accept a counts record at runtimecollectionCountsfromuseDocusaurusContext()and pass them throughresolveCollectionCards()wrapped inuseMemoTest Infrastructure
useDocusaurusContextmock returning emptycollectionCountsfor Jest component testsmoduleNameMappercollectionCardDefinitions,resolveCollectionCards, andresolveMetaCollectionsexportscountYamlPaths()to module scope for reuse across test suitesDocumentation and PR Template
npm run docs:testto the Required Automated Checks section in the PR templatenpm run docs:testafter collection manifest updatesnpm run docs:testto the automated validation command list in skills.mdRelated Issue(s)
Fixes #1248
Fixes #1249
Type of Change
Code & Documentation:
Infrastructure & Configuration:
AI Artifacts:
prompt-builderagent and addressed all feedback.github/instructions/*.instructions.md).github/prompts/*.prompt.md).github/agents/*.agent.md).github/skills/*/SKILL.md)Other:
.ps1,.sh,.py)Testing
fs.readFileSyncruns at build time only, not in the browser bundle.lint:md,spell-check,lint:frontmatter,validate:skills,lint:md-links,lint:ps,plugin:generate,docs:test.Checklist
Required Checks
AI Artifact Contributions
/prompt-analyzeto review contributionprompt-builderreviewRequired Automated Checks
The following validation commands must pass before merging:
npm run lint:mdnpm run spell-checknpm run lint:frontmatternpm run validate:skillsnpm run lint:md-linksnpm run lint:psnpm run plugin:generatenpm run docs:testSecurity Considerations
Additional Notes
countYamlPaths()regex (^\s*- path:) is consistent with the YAML structure used across all collection manifests.collectionCardDefinitionslists 12 collections;docusaurus.config.jscounts 13 (includeshve-core-allfor the meta-collection).