You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Report declaration-only TypeScript in JSON language detection - #252
A TypeScript entry in brief --json now includes declarations_only when there is matching file evidence. It is true for declaration files only, false when at least one implementation file is present, and omitted when only configuration or dependency evidence detected TypeScript. The check uses the same bounded file index and language-evidence filters as detection.
TypeScript matching also recognizes .mts, .cts, and nested .tsx files. Both .d.mts and .d.cts count as declarations.
Reproduced the missing distinction and missing module-file detection on f037b36.
Seven new CLI JSON cases pass, including files in excluded fixture and build directories. The focused detection suite and go vet ./... pass.
The generated schema exposes the optional field as a boolean. The CLI package passes with seven symlink tests omitted. The same tests fail on unchanged main because this Windows account cannot create symlinks.
Implemented with Codex.
Summary by CodeRabbit
New Features
TypeScript detection now includes .mts and .cts files and searches for .ts and .tsx files recursively.
TypeScript results indicate whether matching files are declaration-only. This metadata is omitted when no matching TypeScript files are found.
No actionable comments were generated in the recent review.
Walkthrough
TypeScript detection now reports an optional declarations_only field. Its value reflects whether matching TypeScript files are declaration files, implementation files, or absent within the detection scan.
Changes: TypeScript declaration metadata
Layer / File(s)
Summary
TypeScript file scope and classification knowledge/node/typescript.toml, detect/roles.go
The TypeScript patterns include .mts and .cts files and recursive .tsx matches. The classifier checks eligible TypeScript-family files and returns true, false, or nil.
Declaration metadata output and validation brief.go, detect/detect.go, cmd/brief/main_test.go, README.md
The Detection type adds an optional declarations_only field, which TypeScript detection populates. Scanner tests cover declaration and implementation cases. The README documents the field’s values and scan scope.
This adds an optional declarations_only field to TypeScript entries in brief --json output, and recognizes .mts, .cts, and nested .tsx files. Existing consumers are unaffected because the field is omitted when unset. No merge-blocking risk was found.
Pre-merge checks: 4
Check name
Status
Explanation
Description Check
Check skipped - CodeRabbit’s high-level summary is enabled.
Title check
The title names the main change: TypeScript detections in the JSON language output now report a declaration-only flag. The raw summary and PR objectives confirm this: an optional declarations_only fie…
Linked Issues check
Issue #251 requires that brief --json distinguish TypeScript declaration-file evidence from implementation-file evidence, including .d.mts and .d.cts, without a rescan. At head f1abd8e, `brief.g…
Out of Scope Changes check
The changes map to #251 or support it. brief.go, detect/detect.go, detect/roles.go, and the test file implement the new field. The knowledge/node/typescript.toml change adds .mts and .cts …
Full details: Title check
Explanation
The title names the main change: TypeScript detections in the JSON language output now report a declaration-only flag. The raw summary and PR objectives confirm this: an optional declarations_only field is added to TypeScript entries in brief --json, set from matching file evidence, and true only when all matched TypeScript files are declarations. The title is specific and concise, and it matches the changeset.
Full details: Linked Issues check
Explanation
Issue #251 requires that brief --json distinguish TypeScript declaration-file evidence from implementation-file evidence, including .d.mts and .d.cts, without a rescan. At head f1abd8e, brief.go adds Detection.DeclarationsOnly *bool with json:"declarations_only,omitempty". detect/detect.go sets it for TypeScript using Engine.typeScriptDeclarationsOnly() in detect/roles.go. That function reads the already-loaded projectFiles and applies languageEvidence. It returns false when a non-declaration .ts, .tsx, .mts, or .cts file is found. It returns true when only declaration files are found (.d.ts, .d.mts, .d.cts). It returns nil (omitted) when no matching file exists, which covers config or dependency-only detection. This meets the field semantics in the issue. cmd/brief/main_test.go adds TestScanReportsTypeScriptDeclarationOnly covering these cases. I did not run the tests. The comparison in this review relies on the diff and the PR's reported validation.
Full details: Out of Scope Changes check
Explanation
The changes map to #251 or support it. brief.go, detect/detect.go, detect/roles.go, and the test file implement the new field. The knowledge/node/typescript.toml change adds .mts and .cts patterns and makes .ts and .tsx patterns recursive (**/). This is needed so the field classifies .d.mts and .d.cts files, which the issue requests. The recursive .tsx and **/*.ts patterns broaden TypeScript detection beyond #251. The PR description and objectives disclose this broadening, and it uses the same bounded file index. It is not an unrelated change. No unrelated file changes appear in the summary.
Finishing Touches
Generate unit tests (beta)
Create a new PR
Autofix · 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.
File: No configuration file from this repository applied
Commit: Unavailable
Layers: Organization UI
Review profile: CHILL
Plan: Advanced
Run ID: 302aa963-2f6c-4d6e-8e9d-f84c88349b84
Commits
Reviewing files that changed from the base of the PR and between f037b36 and f1abd8e.
Files selected for processing: 6
README.md
brief.go
cmd/brief/main_test.go
detect/detect.go
detect/roles.go
knowledge/node/typescript.toml
Included review availability: This review used your included allowance. Your plan provides up to 1 included review per hour; 0 remain after this review.
The reason will be displayed to describe this comment to others. Learn more.
Thanks, this does what #251 asks for, and reusing the loaded file index with languageEvidence keeps it cheap. Two small changes before merging:
detect/roles.go: typeScriptDeclarationsOnly hardcodes .ts, .tsx, .mts and .cts, which repeats the patterns in knowledge/node/typescript.toml. If a pattern is later added there, detection will pick it up and this classifier won't. Please pass in the TypeScript tool definition and filter files with its Detect.Files patterns via matchesProjectPattern, keeping the .d suffix check, so both use one list.
brief.go: please drop the comment on DeclarationsOnly. It restates the field name, and none of the other fields in Detection have comments.
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
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.
Summary
A TypeScript entry in
brief --jsonnow includesdeclarations_onlywhen there is matching file evidence. It is true for declaration files only, false when at least one implementation file is present, and omitted when only configuration or dependency evidence detected TypeScript. The check uses the same bounded file index and language-evidence filters as detection.TypeScript matching also recognizes
.mts,.cts, and nested.tsxfiles. Both.d.mtsand.d.ctscount as declarations.Fixes #251.
Validation
f037b36.go vet ./...pass.Implemented with Codex.
Summary by CodeRabbit
.mtsand.ctsfiles and searches for.tsand.tsxfiles recursively.