← All posts
#developer tools#static analysis#go#tree-sitter#open source

Mori

A local CLI for finding structurally similar functions, scripts, and SQL queries across large codebases.

A local CLI for finding structurally similar functions, scripts, and SQL queries across large codebases.

Overview

Mori is a local command-line tool I built for the moments when a piece of code feels familiar, but I cannot remember where I have seen the same idea before.

It finds functions, scripts, and SQL queries with similar structure, including code written in different languages, and turns them into a shortlist for manual review. It is meant to answer “where should I look?” rather than declare that two pieces of code have identical behaviour.

How it works

Mori parses supported source files with Tree-sitter and keeps the structural shape of each comparison fragment. It puts formatting, comments, most names, and literal values to one side, then compares the remaining features using weighted Jaccard similarity.

Reports show the matching locations, a similarity percentage, and a concise explanation of their shared shape. Project configuration, changed-file focus, reviewed baselines, coverage checks, deterministic JSON reports, and CI exit modes make the same approach useful as a repository grows.

Mori supports Go, JavaScript and JSX, TypeScript and TSX, Python, Rust, Swift, Bash and POSIX shell, Zsh, and top-level SQL queries, including an explicit PostgreSQL dialect.

Review and privacy boundaries

A Mori score is structural evidence, not proof that two fragments are equivalent. Every candidate still needs to be read in the context of its types, side effects, runtime behaviour, external contracts, and tests.

Analysis runs locally. The scan path does not execute source, make network requests, or send telemetry, and machine-readable reports do not contain source bodies.

Install

Download a prebuilt binary for macOS, Linux, or Windows from the latest release, or install from source with Go 1.23 or newer and a C compiler:

go install \
  github.com/Cyberlane/mori/cmd/mori@latest
mori scan --profile review .

The complete documentation and source are available in the Mori repository.

Mori

A local CLI for finding structurally similar functions, scripts, and SQL queries across large codebases.

A local CLI for finding structurally similar functions, scripts, and SQL queries across large codebases.

Overview

Mori is a local command-line tool I built for the moments when a piece of code feels familiar, but I cannot remember where I have seen the same idea before.

It finds functions, scripts, and SQL queries with similar structure, including code written in different languages, and turns them into a shortlist for manual review. It is meant to answer “where should I look?” rather than declare that two pieces of code have identical behaviour.

How it works

Mori parses supported source files with Tree-sitter and keeps the structural shape of each comparison fragment. It puts formatting, comments, most names, and literal values to one side, then compares the remaining features using weighted Jaccard similarity.

Reports show the matching locations, a similarity percentage, and a concise explanation of their shared shape. Project configuration, changed-file focus, reviewed baselines, coverage checks, deterministic JSON reports, and CI exit modes make the same approach useful as a repository grows.

Mori supports Go, JavaScript and JSX, TypeScript and TSX, Python, Rust, Swift, Bash and POSIX shell, Zsh, and top-level SQL queries, including an explicit PostgreSQL dialect.

Review and privacy boundaries

A Mori score is structural evidence, not proof that two fragments are equivalent. Every candidate still needs to be read in the context of its types, side effects, runtime behaviour, external contracts, and tests.

Analysis runs locally. The scan path does not execute source, make network requests, or send telemetry, and machine-readable reports do not contain source bodies.

Install

Download a prebuilt binary for macOS, Linux, or Windows from the latest release, or install from source with Go 1.23 or newer and a C compiler:

go install \
  github.com/Cyberlane/mori/cmd/mori@latest
mori scan --profile review .

The complete documentation and source are available in the Mori repository.