mori

module
v0.28.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 10, 2026 License: MIT

README

Mori forest-green banner with the forest kanji and the slogan Structural similarity, explained

Mori

Release CI

Mori finds source fragments with similar structure—even when they use different names or programming languages—and gives you an explainable shortlist to review.

Mori reports structural evidence. A match is never proof that two fragments behave the same way or should be merged.

🔒 Local Source stays on your machine. No upload or telemetry is required.
🌐 Cross-language Compare compatible functions across supported languages.
🔎 Explainable See scores, locations, shared shape, and directional differences.
⚙️ Predictable Deterministic output, visible coverage, and bounded resource use.

Install

Download a native archive from the latest release, or build from source with Go 1.23+ and a C compiler:

go install github.com/Cyberlane/mori/cmd/mori@latest
mori version

Official release binaries include complete build provenance and are recommended for CI and auditable reports.

Each release also includes checksum-pinned Homebrew, Scoop, and WinGet manifest assets, an SPDX SBOM, and GitHub/Sigstore attestations. Package-index submission is intentionally separate, so verify the release asset before local use.

Quick start

From a project root:

mori setup
mori scan .

mori setup inventories the project, asks a few focused questions, previews a conservative .mori.json, and writes it only after confirmation. Review its exclusions after the first scan; Mori cannot decide which tests, generated files, migrations, or framework repetition are intentional in your project.

For a no-write trial:

mori scan --profile review .

The review profile starts with same-language code, an 85% threshold, a 40-token floor, generated-source exclusion, and required aggregate coverage.

Example result:

1. 92.7% structural similarity · 1 location pair(s)
   weighted feature evidence: 114 intersection / 123 union
   A  Validator.java:6-9   [java]       looksLikeEmail
   B  validator.js:1-4     [javascript] looksLikeEmail
   shared shape: 3 calls, 1 return, 2 bindings

Always read both locations. Mori does not establish equivalent runtime values, effects, types, external calls, permissions, transactions, or error behavior.

Choose a workflow

Goal Start with
Review likely same-language duplication mori scan --profile review .
Explore across languages mori scan --profile explore --cross-language-only .
Review one language pair mori scan --language-pair go,typescript .
Review SQL queries mori scan --profile sql path/to/sql
Produce CI or agent evidence mori scan --profile review --format json .
Review exactly what is staged mori scan --staged --include-focused --require-focused-coverage
Produce a concise terminal shortlist mori scan --profile review --format compact .
Produce editor diagnostics mori scan --profile review --format sarif .
Save a local visual report mori scan --profile review --format html . > mori.html
Inspect language coverage mori inspect .
Check project setup mori doctor .
Check project-managed Mori assets mori project upgrade --check .

Lower the token floor toward 12 only for deliberate broad exploration; small callbacks and wrappers commonly dominate at that size.

Use mori explain <content-pair-id> [scan options] . to reproduce and isolate one reported identity. Text output uses restrained color on terminals; set --color never or NO_COLOR to disable it.

Supported source

Mori currently supports:

  • Bash/POSIX shell and Zsh;
  • C, C++, C#, Dart, GDScript, Go, Hack, Java, JavaScript/JSX, Kotlin, Lua, Luau, PHP, PowerShell, Python, Ruby, Rust, Swift, TypeScript/TSX;
  • generic SQL queries and explicitly selected PostgreSQL queries.

Run mori languages for the exact extensions, families, fragment kinds, and extensionless shebangs supported by your installed version. See Languages and parser limits for comparison boundaries and known gaps.

Editors and AI coding tools

The repository includes a dependency-free VS Code reference client. It analyzes unsaved buffers through a local Mori process and reports SARIF diagnostics without uploading source.

Install Mori's review skill into a project for compatible coding agents:

mori skill install --project .

The skill teaches agents to treat matches as review leads, verify coverage, inspect both source locations, and avoid score-only refactors.

After installing a newer Mori binary, coordinate the project pin, embedded skill, configuration and baseline validation, and automation inventory with:

mori project upgrade --dry-run .
mori project upgrade --apply .

Apply mode updates .mori-version and the project Agent Skill with backups. It does not install the CLI, invent configuration policy, rewrite hooks or CI, commit, push, or release anything.

To let a project agent configure Mori without granting hidden write access:

mori setup --agent --format json .

The agent can answer the emitted questions and preview the exact configuration before an explicit --apply. See Editors and coding agents.

Documentation

Development

make check

See Contributing for development policy. The calibration corpus is regression evidence for its reviewed cases, not a universal accuracy claim.

License

MIT

Directories

Path Synopsis
cmd
mori command
corpus
examples
internal
agentskill
Package agentskill installs Mori's embedded Agent Skill safely and deterministically.
Package agentskill installs Mori's embedded Agent Skill safely and deterministically.
analyzer
Package analyzer orchestrates parsing, comparison, and deterministic results.
Package analyzer orchestrates parsing, comparison, and deterministic results.
baseline
Package baseline stores reviewed-and-accepted Mori match candidates.
Package baseline stores reviewed-and-accepted Mori match candidates.
buildinfo
Package buildinfo holds immutable build provenance from linker flags or Go module build information.
Package buildinfo holds immutable build provenance from linker flags or Go module build information.
cli
Package cli implements the mori command-line interface.
Package cli implements the mori command-line interface.
cmd/corpuseval command
cmd/packageindex command
Command packageindex creates package-manager manifests for release archives.
Command packageindex creates package-manager manifests for release archives.
cmd/releasepack command
Command releasepack creates one native release archive.
Command releasepack creates one native release archive.
cmd/skillpack command
Command skillpack creates Mori's portable Agent Skill release archive.
Command skillpack creates Mori's portable Agent Skill release archive.
config
Package config loads Mori's strict project scan configuration.
Package config loads Mori's strict project scan configuration.
corpus
Package corpus evaluates Mori's redistributable labeled calibration corpus.
Package corpus evaluates Mori's redistributable labeled calibration corpus.
diagnostic
Package diagnostic formats errors without exposing private filesystem paths.
Package diagnostic formats errors without exposing private filesystem paths.
fingerprint
Package fingerprint creates stable content identities for normalized fragments and pairs of fragments.
Package fingerprint creates stable content identities for normalized fragments and pairs of fragments.
grammar/gdscript
Package gdscript exposes Mori's pinned Tree-sitter GDScript grammar.
Package gdscript exposes Mori's pinned Tree-sitter GDScript grammar.
grammar/hack
Package hack exposes Mori's pinned Tree-sitter Hack grammar.
Package hack exposes Mori's pinned Tree-sitter Hack grammar.
grammar/postgresql
Package postgresql exposes Mori's pinned Tree-sitter PostgreSQL grammar.
Package postgresql exposes Mori's pinned Tree-sitter PostgreSQL grammar.
grammar/swift
Package swift exposes Mori's pinned Tree-sitter Swift grammar.
Package swift exposes Mori's pinned Tree-sitter Swift grammar.
language
Package language owns supported Tree-sitter grammars and fragment boundaries.
Package language owns supported Tree-sitter grammars and fragment boundaries.
model
Package model defines the analyzer's stable internal and output models.
Package model defines the analyzer's stable internal and output models.
normalize
Package normalize converts grammar-specific trees into shared feature bags.
Package normalize converts grammar-specific trees into shared feature bags.
parser
Package parser turns supported source files into normalized fragments.
Package parser turns supported source files into normalized fragments.
pathutil
Package pathutil provides shared lexical path checks.
Package pathutil provides shared lexical path checks.
release
Package release creates deterministic native release archives.
Package release creates deterministic native release archives.
report
Package report renders stable machine-readable and human-readable reports.
Package report renders stable machine-readable and human-readable reports.
similarity
Package similarity scores normalized AST feature bags.
Package similarity scores normalized AST feature bags.
source
Package source discovers supported source files without following symlinks.
Package source discovers supported source files without following symlinks.
vcs
Package vcs resolves bounded, local version-control state for review focus.
Package vcs resolves bounded, local version-control state for review focus.
Package skills embeds the official Agent Skills distributed with Mori.
Package skills embeds the official Agent Skills distributed with Mori.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL