cure-cli-0.4.4 is not a library.
cure-cli
cure — the command-line front end of the
cure simplification engine: a
fault-tolerant, semantic-preserving code simplifier/formatter that turns
decompiled code back into something a human would have written. The CLI is
language-agnostic (Java, TypeScript/JavaScript, Python and Dart are the
backends implemented today) — a new language registers in LANG_BACKENDS
(extensions + pipeline function) and inherits traversal, parallelism,
--check/--diff/--stats, and the cross-platform batched I/O for free.
|
# class A {
# int m() {
# return foo();
# }
# }
|
# const x = 3;
# console.log(3);
|
# x = 3
# print(3)
|
# void main() {
# var x = new A(1);
# print(3);
# }
Highlights:
- Fault-tolerant — parse errors never abort a run; broken regions are
preserved verbatim while everything around them is simplified
(
--strictturns them into an error exit for CI). - Python 2.7 + 3.x —
.py/.pyiback end: one indentation-aware fault-tolerant parser for both grammars (Python 2 print/exec/raise statements, backticks,<>, long/old-octal literals,urstrings, tuple parameters; PEP 701 f-strings, t-strings,match, walrus,except*, PEP 695,lazy import), Python-semantics constant folding that preserves Python 2 int/long types andTrue/Falserebinding, and generator/scope guards. A 28-rule pack includes literal string/builtin/subscript folding, if/else-to-conditional (including adjacentreturnbranches), nested-if merging, else-after-terminal and empty-branch removal, not/is/in rewriting, redundant-paren removal, function-scope dead-assignment elimination, string accumulation and assign-back folding, trailing return/continue and empty-finally cleanup. Verified over 35,548 stdlib/site-package files with 0 diagnostics, 0 idempotency drift and 0 compile regressions. - Dart 1/2/3 —
.darttoken-preserving back end: every token and comment is kept, unmodelled syntax (legacy Dart 2 modifiers, records, patterns, extension types, macros) stays verbatim, and safe rewrites cover constant folding (32-bit int/bool/string, Euclidean%, truncating~/, literal string/int members), boolean/ternary/logic simplification, negated comparisons, if→ternary for returns/assignments, nested-if merge, empty-then inversion, else-after-terminal, unreachable statements, loop-tailcontinue, trailingreturn, compound assignments, rethrow-only try unwrapping, emptyfinally, adjacent-string merging, atom parentheses, emptyelseand${ident}interpolation compaction. Verified over 19,229 pub-cache files: 0 diagnostics, token-identical round-trips, 0 idempotency drift, and no newdart formatfailures. - Directory mode — recursive, parallel (dynamic work queue, threads =
CPU cores × 1.5), mirrors the tree into
<dir>-cure-out/; the 371,674-file OpenJDK corpus (4.70 GB) in ~15 s / ~430 MiB peak RSS on an 18-core laptop (--check), 0 failures. - Cross-platform batch I/O — optional Linux
io_uringbackend (--features io-uring; read syscalls 6,977 → 10 on a 3,483-file trace); macOS/Windows thread pool. Default build: zero runtime dependencies. - Dry runs (
--check), diffs (--diff), stats (--stats/--report), rule toggles (--disable), in-place mode (-w), thread control (-j). - Simplification-quality metrics (
--stats): AST nodes, decision points, max nesting — before vs. after. Untouched by formatting, they separate real simplification from reformatting; per-file classification (structurally simplified / format-only / untouched) surfaces files no rule reached.
Full documentation — rule catalog, verification methodology, performance notes, and the 中文版 — in the repository README.
License: MIT.