2026-10-20T12:56:38Z by Showboat 0.6.1
Run each Bash block from the LOCmetry repository root. Setup and replay instructions describe the fresh temporary copy created by source scripts/cli-demo-env.sh, external tools and output projections. The fixture README introduces the shared source tree.
PATH is an existing root-relative file with exact spelling. --root supplies the scan root. The table keeps classification evidence; only its absolute root line is removed. --no-color disables styling.
source scripts/cli-demo-env.sh
locmetry explain service/scripts/check.py --root acme-orders --no-user-config --no-color \
--format table \
| sed '/^Root:/d'Path explanation
Path: service/scripts/check.py
Project config: acme-orders/.locmetryrc
Personal config: none
State: counted
Language: Python
Kind: source
Purpose: production
Category: tooling
Rule: tooling
Stage: rule
Counts: 2 code, 1 comment, 0 blanks, 3 lines
Matching patterns: service/scripts/**
Reason: Maintained check script that developers run before a commit
Full JSON has a tagged result. These files demonstrate test classification, project exclusion, hidden policy, ignore rules, unclaimed source and unrecognized content. Counted/unclaimed is different from unavailable counts. Neither excluded nor unrecognized means a measured zero.
source scripts/cli-demo-env.sh
for path in web/src/orders/Order.test.ts service/third_party/sdk.py service/.hidden.py \
service/ignored.py service/experiments/probe.py web/docs/wireframe.asset; do
locmetry explain "$path" --root acme-orders --no-user-config --format json \
| jq '{path, result}'
done{
"path": "web/src/orders/Order.test.ts",
"result": {
"state": "counted",
"file": {
"path": "web/src/orders/Order.test.ts",
"language": "TypeScript",
"kind": "source",
"purpose": "test",
"category": "test",
"rule": "builtin:js-test-file",
"counts": {
"code": 3,
"comments": 1,
"blanks": 0,
"lines": 4
}
},
"decision": {
"stage": "convention",
"matched_patterns": [
"**/*.{test,spec}.{js,jsx,mjs,cjs,ts,tsx,mts,cts}"
]
}
}
}
{
"path": "service/third_party/sdk.py",
"result": {
"state": "excluded",
"at": "service/third_party",
"patterns": [
"service/third_party/**"
]
}
}
{
"path": "service/.hidden.py",
"result": {
"state": "not_selected",
"reason": "hidden_policy"
}
}
{
"path": "service/ignored.py",
"result": {
"state": "not_selected",
"reason": "ignore_policy"
}
}
{
"path": "service/experiments/probe.py",
"result": {
"state": "counted",
"file": {
"path": "service/experiments/probe.py",
"language": "Python",
"kind": "source",
"purpose": "other",
"category": "unclaimed",
"rule": "fallback",
"counts": {
"code": 1,
"comments": 1,
"blanks": 0,
"lines": 2
}
},
"decision": {
"stage": "fallback",
"matched_patterns": []
}
}
}
{
"path": "web/docs/wireframe.asset",
"result": {
"state": "unrecognized"
}
}
--hidden true and --respect-ignore-files false override effective scope. --exclude adds a root-relative exclusion. The projections expose the resulting state and decision.
source scripts/cli-demo-env.sh
locmetry explain service/.hidden.py --root acme-orders --hidden true --no-user-config \
--format json \
| jq '{path, result}'
locmetry explain service/ignored.py --root acme-orders --respect-ignore-files false \
--no-user-config --format json \
| jq '{path, result}'
locmetry explain web/src/orders/Order.ts --root acme-orders --exclude 'web/src/**' \
--no-user-config --format json \
| jq '{path, result}'{
"path": "service/.hidden.py",
"result": {
"state": "counted",
"file": {
"path": "service/.hidden.py",
"language": "Python",
"kind": "source",
"purpose": "other",
"category": "unclaimed",
"rule": "fallback",
"counts": {
"code": 1,
"comments": 0,
"blanks": 0,
"lines": 1
}
},
"decision": {
"stage": "fallback",
"matched_patterns": []
}
}
}
{
"path": "service/ignored.py",
"result": {
"state": "counted",
"file": {
"path": "service/ignored.py",
"language": "Python",
"kind": "source",
"purpose": "other",
"category": "unclaimed",
"rule": "fallback",
"counts": {
"code": 1,
"comments": 0,
"blanks": 0,
"lines": 1
}
},
"decision": {
"stage": "fallback",
"matched_patterns": []
}
}
}
{
"path": "web/src/orders/Order.ts",
"result": {
"state": "excluded",
"at": "web/src",
"patterns": [
"web/src/**"
]
}
}
--config replaces discovered project policy. An explicit override claims the experiment as intentional Other/prototype. This changes classification, not source content. The experimental configuration exists only in this temporary copy.
source scripts/cli-demo-env.sh
cat > proposed.toml <<'TOML'
version = 1
[[overrides]]
id = "experiment"
match = ["service/experiments/**"]
purpose = "other"
category = "prototype"
TOML
locmetry explain service/experiments/probe.py --root acme-orders --config proposed.toml \
--no-user-config --format json \
| jq '{path, result}'{
"path": "service/experiments/probe.py",
"result": {
"state": "counted",
"file": {
"path": "service/experiments/probe.py",
"language": "Python",
"kind": "source",
"purpose": "other",
"category": "prototype",
"rule": "experiment",
"counts": {
"code": 1,
"comments": 1,
"blanks": 0,
"lines": 2
}
},
"decision": {
"stage": "override",
"matched_patterns": [
"service/experiments/**"
]
}
}
}
A refinement changes only the category of files whose decided purpose it names. Here it relabels the web tests as unit tests but leaves out the order tests with except, so they fall through to the next refinement. The table keeps the convention as Rule and names the refinement with its reason.
source scripts/cli-demo-env.sh
cat > proposed.toml <<'TOML'
version = 1
[[refinements]]
id = "web-unit-tests"
purpose = "test"
match = ["web/src/**"]
except = ["web/src/orders/**"]
category = "unit"
[[refinements]]
id = "order-tests"
purpose = "test"
match = ["web/src/orders/**"]
category = "integration"
reason = "Tests of the order view together with its API client"
TOML
locmetry explain web/src/orders/Order.test.ts --root acme-orders --config proposed.toml \
--no-user-config --no-color --format table \
| sed '/^Root:/d'
Path explanation
Path: web/src/orders/Order.test.ts
Project config: proposed.toml
Personal config: none
State: counted
Language: TypeScript
Kind: source
Purpose: test
Category: integration
Rule: builtin:js-test-file
Stage: convention
Counts: 3 code, 1 comment, 0 blanks, 4 lines
Matching patterns: **/*.{test,spec}.{js,jsx,mjs,cjs,ts,tsx,mts,cts}
Refinement: order-tests, matching web/src/orders/**
Refinement reason: Tests of the order view together with its API client
--workspace-file takes member-prefixed paths and applies that member's policy. Single-root policy flags cannot accompany it. Explain supports table, JSON and Markdown; redirect stdout to save it because there is no --output or headline option. The Markdown excerpt omits its absolute root row.
source scripts/cli-demo-env.sh
locmetry explain web/src/orders/Order.test.ts --workspace-file workspace.toml --no-user-config \
--format json \
| jq '{member, path, result}'
locmetry explain service/scripts/check.py --root acme-orders --no-user-config --format markdown \
> explanation.md
sed '/^| .*Root.* |/d' explanation.md{
"member": "web",
"path": "web/src/orders/Order.test.ts",
"result": {
"state": "counted",
"file": {
"path": "web/src/orders/Order.test.ts",
"language": "TypeScript",
"kind": "source",
"purpose": "test",
"category": "test",
"rule": "builtin:js-test-file",
"counts": {
"code": 3,
"comments": 1,
"blanks": 0,
"lines": 4
}
},
"decision": {
"stage": "convention",
"matched_patterns": [
"**/*.{test,spec}.{js,jsx,mjs,cjs,ts,tsx,mts,cts}"
]
}
}
}
# Path explanation
| Evidence | Value |
| --- | --- |
| **Path** | service/scripts/check.py |
| **Project config** | acme-orders/.locmetryrc |
| **Personal config** | none |
| **State** | counted |
| **Language** | Python |
| **Kind** | source |
| **Purpose** | production |
| **Category** | tooling |
| **Rule** | tooling |
| **Stage** | rule |
| **Counts** | 2 code, 1 comment, 0 blanks, 3 lines |
| **Matching patterns** | service/scripts/** |
| **Reason** | Maintained check script that developers run before a commit |
The help excerpt includes selection and output groups, stops before presentation options and trims trailing whitespace.
These successful states exit 0. Unread or parse-failed files exit 2, and invalid paths or configuration exit 1. The synthetic fixture avoids OS-dependent permission failures; dedicated integration tests cover failures.
source scripts/cli-demo-env.sh
locmetry explain --no-color --help | sed '/^Presentation:/,$d; s/[[:space:]]*$//'
locmetry --schema explanation | jq '{title, required}'Explain selection and classification of existing root-relative files.
JSON prints the complete explanation; there is no separate headline.
Usage: locmetry explain [OPTIONS] <PATH>...
Arguments:
<PATH>...
Root-relative files, or MEMBER/PATH with --workspace-file; several print JSON Lines
Options:
-h, --help
Print help (see a summary with '-h')
Selection and policy:
--root <DIR>
Scan root [default: the current directory]
--config <FILE>
TOML configuration [default: .locmetryrc in the scan root, else built-in settings]
--exclude <GLOB>
Add a root-relative exclusion glob; repeatable
--hidden <BOOL>
Override whether hidden files and directories are measured
[possible values: true, false]
--respect-ignore-files <BOOL>
Override whether ignore files limit the selection
[possible values: true, false]
--workspace-file <FILE>
Workspace file; use the selected member's own policy
--no-user-config
Ignore personal defaults
Output and content:
--format <FORMAT>
Stdout format [default: table on a terminal, json otherwise]
Possible values:
- table: Tables and evidence
- json: Complete JSON explanation
- markdown: Markdown tables and evidence for reviews
{
"title": "Explanation",
"required": [
"document_type",
"schema_version",
"root",
"path",
"scope",
"result"
]
}