Freedom251 › Code Clone Detection Tools
@kongyo2/similarity-ts

What @kongyo2/similarity-ts is
@kongyo2/similarity-ts is a free TypeScript analyzer that compares functions, types and classes for structural similarity across a repository. It is offered as a command-line tool and a JavaScript library, and requires Node.js 20 or newer. A quick start scans the current directory with `npx @kongyo2/similarity-ts .`.
The default scan includes `.ts`, `.tsx`, `.mts` and `.cts` files, with functions, types, classes and overlap as analysis modes. You can choose modes, narrow scan scope, filter extensions, exclude patterns and adjust the threshold. The default similarity threshold is 0.8; function candidates must have at least three lines unless an AST-token size minimum is used instead. It normalizes forms such as arrow functions and declarations, `.then()` and `await`, and some loop rewrites. It renames local declarations and parameters while retaining free identifier names; behavior-changing differences such as `.map` versus `.filter` remain distinct. Output can be pretty or JSON, and `--fail-on-duplicates` exits nonzero when a pair is reported. A preceding `// similarity-ignore` comment excludes a declaration.
Who it suits
It suits developers working in TypeScript repositories who want to identify structurally similar code from a CLI or library. Its nonzero exit option also supports CI workflows that should react when duplicate pairs are reported.
What it does well
- Compares functions, types and classes structurally.
- Offers CLI and JavaScript library package forms.
- Supports pretty and JSON output.
- Can exit nonzero when duplicate pairs are reported.
- Declarations can be excluded with a comment.
What to know first
- Requires Node.js 20 or newer.
- Default scan covers only four TypeScript file extensions.
- No IDE integration is listed.
Getting started
- Install or run it through Node.js 20 or newer.
- Run `npx @kongyo2/similarity-ts .` from the repository directory.
- Choose analysis modes, scan scope, file extensions, exclusions, or threshold as needed.
- Select pretty or JSON output, and use `--fail-on-duplicates` for a nonzero result when pairs are reported.
Verdict
@kongyo2/similarity-ts provides configurable structural comparisons and output choices for TypeScript repositories. Its Node.js 20 requirement and lack of listed IDE integration are worth noting; the project is free under the MIT license.
Questions
What does @kongyo2/similarity-ts compare?
It compares functions, types, and classes structurally, with overlap also included as a default analysis mode.
Which files does it scan by default?
The default extensions are `.ts`, `.tsx`, `.mts`, and `.cts`; the CLI can filter extensions.
How much does it cost, and is there a free plan?
The project is free and has a free plan.
What runtime does it require?
The package metadata specifies Node.js 20 or newer.
Is it open source?
The repository identifies its license as MIT.
Can it be used in CI?
Yes. Its `--fail-on-duplicates` option exits nonzero when any pair is reported.
Facts from @kongyo2/similarity-ts's own pages
- Accuracy benchmark
- The README reports that version 0.7.0 correctly labeled all 300 pairs in its stated benchmark corpus. · github.com, 7 Oct 2026
- Analysis modes
- Its default modes are functions, types, classes, and overlap, and the README documents options to select modes and restrict scan scope. · github.com, 5 Oct 2026
- Analysis targets
- It compares functions, types, and classes structurally. · github.com, 7 Oct 2026
- Behavioral distinctions
- The README says behavior-changing differences such as `.map` versus `.filter` and `async` versus synchronous contracts retain distinct shapes. · github.com, 7 Oct 2026
- CI use
- The CLI offers a `--fail-on-duplicates` option that exits non-zero when any pair is reported. · github.com, 7 Oct 2026
- CLI controls
- The CLI supports selecting analysis modes, setting a similarity threshold, filtering file extensions, excluding patterns, and choosing pretty or JSON output. · github.com, 7 Oct 2026
- Code style matching
- It canonicalizes documented style variants, including arrow functions versus declarations, `.then()` versus `await`, and several loop forms. · github.com, 5 Oct 2026
- Exclusions
- A declaration can be excluded from the report with a `// similarity-ignore` comment on the preceding line. · github.com, 5 Oct 2026
- Install and run
- The README’s quick start runs the analyzer with `npx @kongyo2/similarity-ts .`. · github.com, 5 Oct 2026
- Intended workflow
- The README suggests using the command with an AI coding assistant to find duplicate code patterns and create a refactoring plan. · github.com, 7 Oct 2026
- License
- The repository identifies its license as MIT. · github.com, 7 Oct 2026
- Maker identity
- The repository is hosted under the GitHub account `kongyo2`; the opened project pages do not state a maker’s personal or company name, headquarters, or founding date. · github.com, 5 Oct 2026
- Output and CI
- It supports pretty or JSON output and a `--fail-on-duplicates` option that exits nonzero when any pair is reported. · github.com, 5 Oct 2026
- Package form and runtime
- The package metadata describes a CLI and library, exposes a command-line binary and JavaScript entry point, and specifies Node.js 20 or newer. · github.com, 5 Oct 2026
- Package formats
- The package metadata exposes both a `similarity-ts` command-line executable and a JavaScript library entry point with TypeScript declarations. · github.com, 7 Oct 2026
- Purpose
- The project describes itself as a TypeScript-only similarity analyzer for detecting semantic code similarities. · github.com, 7 Oct 2026
- Rename handling
- It alpha-renames function parameters, locals, inner functions, and declaration names before comparison, while retaining free identifier names. · github.com, 7 Oct 2026
- Runtime requirement
- The package metadata specifies Node.js version 20 or newer. · github.com, 7 Oct 2026
- Style normalization
- The analyzer canonicalizes several equivalent coding forms, including function declarations and arrow functions, some loop rewrites, and structurally identical interfaces and type aliases. · github.com, 7 Oct 2026
- Supported file extensions
- The default extensions it scans are `ts`, `tsx`, `mts`, and `cts`. · github.com, 5 Oct 2026
- Threshold and size controls
- The similarity threshold defaults to 0.8, the minimum function length defaults to three lines, and a minimum AST-token size can replace the line gate. · github.com, 5 Oct 2026
- Usage
- The README shows running it on the current directory with `npx @kongyo2/similarity-ts .`. · github.com, 7 Oct 2026
Where @kongyo2/similarity-ts stands on Freedom251
- Code Clone Detection Tools#19 of 23