Source formatter — 0.14.0

The 0.14.0 SDK includes this command. Consult the versioned validation report for exact artifact and platform evidence.

threadone fmt src/main.one
threadone fmt src/main.one --check
threadone fmt src/main.one --stdout
threadone fmt src/lib/math.one --entry src/main.one
threadone fmt src/lib/math.one --entry src/main.one --check

Without a file, the CLI selects src/main.one, then main.one. --check exits 0 when formatting is current and 1 when changes are required. --stdout writes only formatted source. These modes never modify files and cannot be combined. Invalid input, unsupported flags and validation failures exit 1 with a diagnostic on stderr.

The formatter normalizes horizontal spacing, trailing code whitespace and LF line endings, adding a final newline when needed. It preserves existing line positions, leading indentation, raw strings/escape spelling, comments, numeric separators and token spelling. It does not convert brace syntax to indentation syntax, wrap lines, repair invalid indentation or reorder imports.

Only the selected file is rewritten. By default it must be a valid program entry, including its local imports. Use --entry program.one to format a library without its own main function or routes: the selected file must be reachable in that entry’s import graph. Both paths are relative to the current working directory (or absolute). The default selected file remains src/main.one, then main.one, even with --entry. Invalid entry graphs and unreachable selections are rejected in every mode. Other files remain unchanged, including shared dependencies in diamond import graphs. Formatting requires neither a native build nor a running application.

Before writing, the CLI validates both original and formatted module graphs, verifies identical emitted Rust, unchanged import order and the 1 MiB aggregate source budget. Invalid programs and oversized results remain untouched. The selected source must be a regular file, not a symbolic link. A changed read-only source is rejected. Unchanged files are not replaced.

Replacement stages a complete file in the same directory filesystem, preserves basic file permissions, synchronizes the staged file and renames it over the selected path. Hard-link aliases keep their original bytes. Ordinary concurrent changes are checked before rename; this is not a writer lock, so coordinate concurrent editors. Extended attributes, ACLs and ownership are not covered by the metadata preservation contract. The original formatter was tested on macOS arm64; the entry-context extension and full formatter suite have been tested on Linux x86_64. Windows replacement behavior remains unverified.

Development validation

THREADONE_BIN=tools/tmp/threadone-fmt python3 tests/formatter.py

For development, build a separate executable and select it with THREADONE_BIN. Published ZIPs remain immutable; a changed SDK requires a new archive and validation pass.