Skip to content

Cover .mts and .cts sources in the docstring and duplication gates - #144

Merged
unbraind merged 4 commits into
mainfrom
fix/gates-cover-tsx-sources
Oct 4, 2026
Merged

unbraind merged 4 commits into
mainfrom
fix/gates-cover-tsx-sources

Conversation

@unbraind

@unbraind unbraind commented Oct 4, 2026 •

Copy link
Copy Markdown
Owner

What

  • docstrings.ts: one isAuthoredTypeScriptSource predicate (.ts, .tsx, .mts, .cts; not .d.ts/.d.mts/.d.cts) shared by the directory walk and single-file roots.
  • duplication.ts: default glob **/*.{ts,tsx,mts,cts}, ambient .d.mts/.d.cts ignored, matched-source filter widened to the same scope, so the fail-closed source-count reconciliation covers them.
  • README updated; dist/ rebuilt.

Why

#128 reported .tsx escaping both gates; #132 fixed .tsx but .mts/.cts sources still bypassed docstring and duplication checks in every consumer package.

Tests (real sources, real engines)

  • Undocumented .mts/.cts exports are reported in directory and single-file scans; documented ones pass; ambient declarations are skipped.
  • Both real jscpd engines (4 and 5) report .mts/.cts clones, scan clean ones under the default globs, and exclude .d.mts/.d.cts.
  • npm run release:check: 469 pass, 0 fail, coverage 100/100/100/100, docstring/duplication/lint/attestation/lifecycle gates ok.

pm item

Closes #128

Summary by Sourcery

Include authored .mts and .cts files in docstring and duplication quality gates without admitting ambient declaration files.

Bug Fixes:

  • Extend docstring and duplication gates to cover authored .mts and .cts sources while continuing to exclude ambient declaration files.

Enhancements:

  • Unify docstring source detection across directory and single-file scans and align duplication source matching with the same authored-TypeScript scope.

Documentation:

  • Update README and generated distribution artifacts to document .mts/.cts coverage and ambient declaration exclusions.

Tests:

  • Add coverage for documented and undocumented .mts/.cts docstring sources and both jscpd engines' duplication handling.

Chores:

  • Record the fix in the changelog and project-management history.

Summary by cubic

Covers authored .mts and .cts sources in the docstring and duplication gates so they no longer bypass those checks; ambient .d.mts/.d.cts declarations stay out of scope.

  • The directory walk and single-file roots now share one isAuthoredTypeScriptSource predicate (.ts, .tsx, .mts, .cts).
  • The default duplication glob is **/*.{ts,tsx,mts,cts}, and ambient declarations are excluded from the source-count reconciliation.
  • README and dist/ are updated; tests run the real docstring analyzer and both jscpd engines against .mts/.cts fixtures.

Closes #128

Written for commit 617bb2d. Summary will update on new commits.

Review in cubic

#132 made both gates scan .tsx, but ES-module (.mts) and CommonJS (.cts)
TypeScript sources still escaped them: the docstring walker and the
duplication source filter accepted only .ts/.tsx, and the default jscpd
glob was **/*.{ts,tsx}. Both gates now treat .ts, .tsx, .mts and .cts as
authored sources and skip the .d.ts, .d.mts and .d.cts ambient forms; the
directory walk and single-file roots share one predicate.

Tests write real undocumented and duplicated .mts/.cts sources and run the
real docstring analyzer and both jscpd engines; clean files pass and ambient
declarations stay out of scope. release:check: 469 pass, coverage 100%.

Closes #128
pm item: ops-zq8c

@sourcery-ai sourcery-ai 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.

Sorry @unbraind, you've used your own review budget of 250,000 diff characters for the last 7 days.

You can request another review in 1 day and 14 hours by commenting @sourcery-ai review. Upgrade to get a review now.

@unbraind

unbraind commented Oct 4, 2026

Copy link
Copy Markdown
Owner Author

@coderabbitai full review
@greptileai review

@coderabbitai

coderabbitai Bot commented Oct 4, 2026 •

Copy link
Copy Markdown

Important

  • 🔍 Trigger review

This repository does not receive automatic reviews because it has fewer than 10 stars.

⚙️ Run configuration
  • Configuration used: Organization UI
  • Review profile: ASSERTIVE
  • Plan: Advanced
  • Run ID: faa8abf9-bf2e-47d4-9654-81c8dc770c6e
  • Autopilot · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@coderabbitai

coderabbitai Bot commented Oct 4, 2026

Copy link
Copy Markdown

Rate Limit Exceeded

@unbraind have exceeded the limit for the number of chat messages per hour. Please wait 13 minutes and 29 seconds before sending another message.

@sourcery-ai

sourcery-ai Bot commented Oct 4, 2026

Copy link
Copy Markdown

Reviewer's Guide

The PR closes the TypeScript source-scope gap by treating authored .mts and .cts files like .ts and .tsx across docstring and duplication gates, excluding ambient declarations, validating both real jscpd engines, and rebuilding/documenting the published distribution.

Sequence diagram for duplication source-count reconciliation

sequenceDiagram
  participant Gate as Duplication gate
  participant Glob as globMatchedSources
  participant Jscpd as jscpd engine
  participant Report as Duplication report
  Gate->>Glob: globMatchedSources(repoRoot, pattern)
  Glob-->>Gate: Authored .ts/.tsx/.mts/.cts sources
  Gate->>Jscpd: Scan DEFAULT_DUPLICATION_GLOBS
  Jscpd-->>Gate: Clone report and scanned-source count
  Gate->>Report: Reconcile matched-source count
  Report-->>Gate: Complete scan or fail closed
Loading

Flow diagram for unified authored TypeScript gate scope

flowchart LR
  Files["TypeScript source files"] --> Predicate[isAuthoredTypeScriptSource]
  Predicate -->|.ts .tsx .mts .cts| Docstrings[Docstring coverage gate]
  Predicate -->|.d.ts .d.mts .d.cts excluded| Docstrings
  Files --> Glob["DEFAULT_DUPLICATION_GLOBS"]
  Glob --> Matched[globMatchedSources]
  Matched -->|.ts .tsx .mts .cts| Duplication[Duplication gate]
  Matched -->|ambient declarations excluded| Duplication
Loading

File-Level Changes

Change Details Files
Expanded docstring coverage to authored .mts and .cts sources while consistently excluding ambient declaration files.
  • Added a shared extension predicate for directory walks and single-file roots.
  • Included .mts/.cts in analyzed-file counts and updated API documentation.
  • Added coverage for undocumented, documented, and ambient declaration cases.
docstrings.ts
dist/docstrings.js
dist/docstrings.d.ts
dist/docstrings.js.map
dist/docstrings.d.ts.map
test/docstrings.test.ts
Expanded duplication analysis and fail-closed source reconciliation to the full authored TypeScript extension set.
  • Changed default globs to include .ts, .tsx, .mts, and .cts.
  • Ignored .d.mts and .d.cts alongside .d.ts and widened matched-source filtering.
  • Added real jscpd 4 and 5 tests for clones, clean scans, and ambient declaration exclusion.
duplication.ts
dist/duplication.js
dist/duplication.d.ts
dist/duplication.js.map
dist/duplication.d.ts.map
test/lint-and-duplication-gates.test.ts
Updated consumer-facing documentation and rebuilt distribution artifacts for the new source scope.
  • Documented the expanded default duplication glob and ambient declaration exclusions.
  • Updated direct-analysis glob examples to include .mts and .cts.
  • Recorded the associated PM work item history and issue updates.
README.md
dist/docstrings.js
dist/docstrings.d.ts
dist/duplication.js
dist/duplication.d.ts
.agents/pm/history/_workspace.jsonl
.agents/pm/history/ops-zq8c.jsonl
.agents/pm/issues/ops-zq8c.toon

Assessment against linked issues

Issue Objective Addressed Explanation
#128 Include authored .tsx files in docstring coverage scans while continuing to exclude ambient declaration files. ✅
#128 Include .tsx files in duplication analysis, invoke jscpd with the appropriate TypeScript/TSX formats, and aggregate statistics across all scanned formats. ✅
#128 Make both gates fail closed when their analyzed file count differs from the matched source-file count, preventing incomplete scans from passing silently. ✅

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

@greptile-apps

greptile-apps Bot commented Oct 4, 2026 •

Copy link
Copy Markdown

RetriggerConfidence Score: 5/5

[Medium risk] Expands docstring and duplication scanning to cover additional TypeScript file types.

The PR appears safe to merge; no actionable new issues were found.

What we checked:

  • Declaration files stay excluded: Both gates explicitly exclude .d.mts and .d.cts. The docstring gate uses the same check for directory and single-file scans.

Summary

Adds .mts and .cts coverage to the docstring and duplication gates while excluding .d.mts and .d.cts declarations.

  • Directory and single-file docstring scans share one source predicate.
  • Both duplication engines receive the expanded scope.
  • Adds regression tests and updates documentation and published files.
  • Both earlier unnumbered findings are fixed: the accidental --help test command is removed, and the changelog and item title describe the new coverage.

Reviews (3) · Last reviewed commit: "Merge origin/main and regenerate the cha..."

Comment thread .agents/pm/issues/ops-zq8c.toon Outdated
Comment thread CHANGELOG.md Outdated
…ntry

Review feedback: the generated changelog entry described the earlier .tsx
fix, and an agent's `pm test --add --help` had recorded `--help` as a test
command.

pm item: ops-zq8c
@unbraind

unbraind commented Oct 4, 2026

Copy link
Copy Markdown
Owner Author

@greptileai review
@coderabbitai review

@coderabbitai

coderabbitai Bot commented Oct 4, 2026

Copy link
Copy Markdown

Rate Limit Exceeded

@unbraind have exceeded the limit for the number of chat messages per hour. Please wait 20 minutes and 46 seconds before sending another message.

@unbraind

unbraind commented Oct 4, 2026

Copy link
Copy Markdown
Owner Author

@greptileai review
@coderabbitai review

@coderabbitai

coderabbitai Bot commented Oct 4, 2026

Copy link
Copy Markdown

Rate Limit Exceeded

@unbraind have exceeded the limit for the number of chat messages per hour. Please wait 13 minutes and 59 seconds before sending another message.

@unbraind
unbraind merged commit 8485910 into main Oct 4, 2026
10 checks passed
@unbraind
unbraind deleted the fix/gates-cover-tsx-sources branch October 4, 2026 18: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.

Docstring and duplication gates silently skip .tsx sources (walker filters .ts; jscpd runs --format typescript only)

1 participant