Repository navigation
refactor(platform-api-docs): isolate discovery strategies - #11184
Open
gaohan1994 wants to merge 1 commit into
Open
gaohan1994 wants to merge 1 commit into
gaohan1994 wants to merge 1 commit into
Conversation
This branch has not been deployed
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.
Explanation
Discovery logic is split across
generate.ts,extraction.ts, androot-messenger-discovery.ts, making it difficult to see what each strategy owns. Move scan file collection and*Messengertraversal intostrategies/scan.ts, and root-messenger resolution and its diagnostics intostrategies/root-messenger.ts. Keep declaration classification and packet extraction in the sharedcapability-extraction.ts.generate.tsnow selects a collection function and handles deduplication, grouping, and writing. Each collector returns capability packets and owns its diagnostics. The existing discriminated options union remains; no strategy interface or factory is added. CLI options, file exclusions and ordering, declaration matching, warnings, and empty-result safeguards are unchanged. ESM declaration matching remains a separate change in #10968.Move the existing extraction/discovery tests alongside their strategy. Add an exact-file collection test including files with no messenger declarations, so output-equivalent but incorrectly widened scans are detected.
Validation
Based on main
5acb2f996e, using Node 24.13.1:.spec.tsexclusion makes it fail with the extra file; the exclusion was then restored.a98daee58f: all 205 generated files are byte-identical (1,166 actions / 179 events).e6e5de7f3e: all 183 generated files are byte-identical (1,369 actions / 169 events). Dependencies were installed from its lockfile with build scripts skipped; no native app build was needed for type discovery.--help, rootyarn lint, changelog validation, andgit diff --checkpassed. Root lint was run afteryarn build:only-clean: running it immediately after a full monorepo build first reported an unlisted dependency in the unrelated generatedbridge-controller/dist/selectors.d.ts.The comparisons cover generated documentation trees, not a Docusaurus site build or wallet/native E2E. There are no dependency or consumer-facing changes, so no changelog entry is added under the repository's changelog guidance.
References
AI assistance
This refactor, its test and validation work, and this description were prepared with OpenAI Codex assistance. A separate AI-assisted read-only review checked behavior preservation; maintainer review is still required.
Checklist
Note
Low Risk
Internal refactor with behavior-preserving moves; scan exclusions, ordering, and diagnostics are intended unchanged per validation.
Overview
Splits platform-api-docs discovery into strategy modules so scan vs root-messenger ownership is clear, without changing CLI behavior or generated output.
Shared capability classification and packet extraction stay in
capability-extraction.ts(renamed from the old extraction module).*Messengerfile scanning, glob exclusions, and per-file traversal move tostrategies/scan.ts. Root union resolution, skipped-capability warnings, andcollectFromRootMessengerCapabilitiesmove tostrategies/root-messenger.ts(replacingroot-messenger-discovery.ts).generate.tsnow only picks a collector, then deduplicates, groups, and writes markdown.Tests are colocated with each strategy. A new
generatetest asserts the scan strategy adds exactly the expected source paths (including files with no messenger types), so regressions that widen the file set are caught.Reviewed by Cursor Bugbot for commit 4baa109. Bugbot is set up for automated code reviews on this repo. Configure here.