Skip to content

fix(platform-api-docs): prefer source over build output when deduplicating - #10085

Merged
cryptodev-2s merged 6 commits into
mainfrom
fix/platform-api-docs-prefer-source-over-dist
Sep 23, 2026
Merged

cryptodev-2s merged 6 commits into
mainfrom
fix/platform-api-docs-prefer-source-over-dist

Conversation

@cryptodev-2s

@cryptodev-2s cryptodev-2s commented Sep 3, 2026 •

Copy link
Copy Markdown
Contributor

Explanation

A capability declared in a package's source is also visible in the dist built from it, and a cross-package import resolves to that dist rather than to the sibling's source. Whichever was reached first won, so 83 of 1164 source links pointed at .d.cts build output instead of code you can read and edit.

Deduplication now scores source above build output, so the outcome no longer depends on traversal order. All 1164 links point at source, and namespace, action and event counts are unchanged.

Both clients generate byte-identical docs, since they only ever see published packages and score every candidate the same way.

References

Checklist

  • I've updated the test suite for new or updated code as appropriate
  • I've updated documentation (JSDoc, Markdown, etc.) for new or updated code as appropriate
  • I've communicated my changes to consumers by updating changelogs for packages I've changed
  • I've introduced breaking changes in this PR and have prepared draft pull requests for clients and consumer packages to resolve them

Note

Low Risk
Documentation generation and link selection only; no runtime API or security behavior changes.

Overview
Generated platform API docs were linking many capabilities to dist declaration files (.d.cts) instead of editable .ts source, because monorepo scans see the same action/event twice and cross-package imports often resolve through node_modules to build output first—whichever duplicate was processed first won.

Deduplication scoring now adds a sourceScore that favors paths outside /dist/, so when both source and build declarations exist, docs keep the source file for links and metadata. Published-package-only consumers are unchanged (every candidate still looks like dist).

Tests cover scanning with node_modules under a broad scan dir and a monorepo-style a-controller / b-controller layout asserting actions.md points at packages/b-controller/src/... and not /dist/. The changelog records the fix under Fixed.

Reviewed by Cursor Bugbot for commit 38afbc9. Bugbot is set up for automated code reviews on this repo. Configure here.

@cryptodev-2s
cryptodev-2s requested a review from a team as a code owner September 3, 2026 08:39
@cryptodev-2s cryptodev-2s self-assigned this Sep 3, 2026
@cryptodev-2s
cryptodev-2s requested a review from mcmire September 3, 2026 08:51
@cryptodev-2s
cryptodev-2s force-pushed the fix/platform-api-docs-prefer-source-over-dist branch from 8236f2a to 0b32e92 Compare September 9, 2026 18:38
@cryptodev-2s

Copy link
Copy Markdown
Contributor Author

@mcmire In case you have missed to look at this ?

@mcmire

mcmire commented Sep 9, 2026 •

Copy link
Copy Markdown
Collaborator

@cryptodev-2s Ah sorry I did miss this, I haven't reviewed this yet. I will review this shortly.

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, have a team admin enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit 0b32e92. Configure here.

Comment thread packages/platform-api-docs/src/generate.ts Outdated

@mcmire mcmire left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Two more suggestions. Everything else looks good.

Comment on lines +234 to +237
// Scanning `.` makes the project root a scan directory, so its
// `node_modules` exclusion covers the published declaration files too.
// Each location has to be collected in its own call for them to survive,
// since exclusions apply to every pattern in the call they belong to.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Is this comment in the right place? Maybe it needs to be moved to above the generate call? On the other hand, to me, not knowing this fact doesn't seem to impact readability of this test, so I would also be fine with removing this:

Suggested change
// Scanning `.` makes the project root a scan directory, so its
// `node_modules` exclusion covers the published declaration files too.
// Each location has to be collected in its own call for them to survive,
// since exclusions apply to every pattern in the call they belong to.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Yes finally did drop it here 38afbc9

Comment on lines +365 to +368
// One call per location, not one call carrying every pattern. Exclusions
// apply to a whole call, so combining them lets the source-tree
// `node_modules` and `dist` exclusions match the published declaration files
// and drop them.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

I think this could be written in a clearer way:

Suggested change
// One call per location, not one call carrying every pattern. Exclusions
// apply to a whole call, so combining them lets the source-tree
// `node_modules` and `dist` exclusions match the published declaration files
// and drop them.
// NOTE: We are calling `addSourceFiles` for each kind of source instead of
// calling it at the very end so that at each step we can make sure to exclude
// `node_modules` and `dist`.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Make sense applied here 38afbc9

@mcmire mcmire left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

LGTM!

@cryptodev-2s
cryptodev-2s added this pull request to the merge queue Sep 23, 2026
Merged via the queue into main with commit b5fbb54 Sep 23, 2026
41 of 42 checks passed
@cryptodev-2s
cryptodev-2s deleted the fix/platform-api-docs-prefer-source-over-dist branch September 23, 2026 19:14
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.

3 participants