atomwrite 0.1.37

Atomic file operations CLI for LLM agents — read, write, edit, search, replace with NDJSON output
[workspace]
members = ["xtask"]

[package]
name = "atomwrite"
version = "0.1.37"
edition = "2024"
rust-version = "1.90"
description = "Atomic file operations CLI for LLM agents — read, write, edit, search, replace with NDJSON output"
authors = ["Danilo Aguiar <daniloaguiarbr@proton.me>"]
license = "MIT OR Apache-2.0"
readme = "README.md"
repository = "https://github.com/danilo-aguiar-br/atomwrite"
homepage = "https://github.com/danilo-aguiar-br/atomwrite"
documentation = "https://docs.rs/atomwrite"
keywords = ["cli", "atomic-write", "llm", "ndjson", "file-operations"]
categories = ["command-line-utilities", "filesystem"]
exclude = [
    ".claude/",
    ".vscode/",
    "docs-prd/",
    "docs_prd/",
    "docs_rules/",
    "/CLAUDE.md",
    "/AGENTS.md",
    "/MEMORY.md",
    "**/graphrag.sqlite",
    "**/graphrag.sqlite-shm",
    "**/graphrag.sqlite-wal",
    "**/.enrich-queue.sqlite",
    "**/.enrich-queue.sqlite-shm",
    "**/.enrich-queue.sqlite-wal",
    "**/.ingest-queue.sqlite",
    "**/.ingest-queue.sqlite-shm",
    "**/.ingest-queue.sqlite-wal",
    ".setting.cyber/",
    "*.7z",
    "*.log",
    "*.env",
    "*.png",
    "*.jpg",
    "*.bak",
    "*.bak.*",
    "*.*.bak",
    "*.*.bak.*",
    "*.tmp",
    "*.tmp.*",
    "*.*.tmp",
    "*.*.tmp.*",
    "*.journal",
    "*.journal.*",
    "*.*.journal",
    "*.*.journal.*",
    "*.atomwrite_tmp",
    "*.atomwrite_tmp.*",
    "*atomwrite_tmp*",
    "*_tmp*",
    "*.atomwrite-*",
    "/*atomwrite-*",
    "*.atom_*",
    "/*atom_*",
    "*.atom-*",
    "/*atom-*",
    "*._agent_tmp*",
    "._agent_tmp*",
    "*agent_tmp*",
    "*.tmp_*",
    "*.*.tmp_*",
    "**/gaps.md",
    "graphrag.sqlite",
    "graphrag.sqlite.enrich-queue.sqlite",
    "**/graphrag.sqlite.enrich-queue.sqlite",
    "graphrag.sqlite-wal",
    ".enrich-queue.sqlite",
    ".enrich-queue.sqlite-shm",
    ".ingest-queue.sqlite-shm",
    ".ingest-queue.sqlite-wal",
    ".commit_hash",
    "**/.commit_hash",
    "base_*/**",
    "docs_rules*/**",
    ".atomwrite_*/**",
    ".atomwrite-*/**",
    ".atomwrite*/**",
    ".tmp*/**",
    ".atom_*/**",
    ".atom-*/**",
    ".agent_*/**",
    "_agent_*/**",
    ".staging*/**",
    ".tmp_*/**",
    ".setting.cyber/**",
    "docs_rules_ingest/**",
    ".claude/**",
    ".skill-build/**",
    ".enrich-overnight/**",
    ".archive/**",
    "uploads/**",
    "docs_bugs/**",
    "*atomwrite-*",
    "*atom_*",
    "*atom-*",
    "gaps.md",
    "CLAUDE.md",
    "docs-prd/**",
    "docs_prd/**",
]

[dependencies]
notify = { version = "8", optional = true }
# Features: derive (API), wrap_help, string (runtime parsers). No clap env knobs (G-007).
# color + suggestions are also clap defaults; listed explicitly per rules_rust_cli_com_clap.
clap = { version = "4", features = ["derive", "wrap_help", "string", "color", "suggestions", "cargo"] }
clap_complete = "4"
serde = { version = "1", features = ["derive"] }
serde_json = { version = "1", features = ["preserve_order"] }
serde_path_to_error = "0.1"
mimalloc = { version = "0.1", default-features = false }
memchr = "2"
schemars = "1"
thiserror = "2"
# Non-cryptographic RNG for retry jitter (src/retry.rs). Already in the tree through tempfile.
fastrand = "2"
anyhow = "1"
tempfile = "3"
blake3 = { version = "1", features = ["mmap", "rayon"] }
rayon = "1"
crossbeam-channel = "0.5"
regex = "1"
tracing = "0.1"
tracing-subscriber = { version = "0.3", default-features = false, features = ["env-filter", "json", "fmt", "ansi", "std", "registry", "tracing-log"] }
tracing-appender = "0.2"
tracing-error = "0.2"
memmap2 = "0.9"
grep-regex = "0.1"
grep-searcher = "0.1"
grep-matcher = "0.1"
ignore = "0.4"
globset = "0.4"
similar = "3"
filetime = "0.2"
human-panic = "2"
grex = "1.4"
fend-core = "1.5"
ast-grep-core = { version = "0.51", optional = true }
ast-grep-language = { version = "0.51", optional = true }
same-file = "1"
unicode-normalization = "0.1"
sys-locale = "0.3"
rust-i18n = "4.2"
# v0.1.12 — new dependencies for resolving the Top 12 gaps + v14 Tier 3
reflink-copy = "0.1"   # G64: O(1) copy-on-write backup on APFS/btrfs/XFS
content_inspector = "0.2"  # G41: accurate binary/text detection (UTF-16LE aware)
strsim = "0.11"        # G116: fuzzy match cascade strategy 9 (context-aware)
heck = "0.5"           # v14 Tier 3: identifier case conversion (case subcommand)
# G44: multi-rule YAML for transform subcommand. serde-saphyr 1.x is the same major that
# rust-i18n-support 4.2 already pulls, so the graph carries one copy and no unsafe-libyaml.
serde-saphyr = { version = "1.3", optional = true }
directories = "6"      # GAP-072: XDG config paths for .atomwrite.toml
toml = "0.8"           # GAP-072: serde deserialize for .atomwrite.toml config
toml_edit = "0.22"     # v14 Tier 3: TOML editor preserving comments/formatting
# v0.1.12 — tree-sitter-language-pack for G72 real syntax check + v14 query/outline.
# Downloads parsers on first use (cache local); keeps install footprint small while
# enabling AST validation across 305 languages. See src/syntax_check.rs and
# src/commands/query.rs/outline.rs.
tree-sitter-language-pack = { version = "1.22.1", default-features = false, features = ["download", "dynamic-loading"], optional = true }
# v0.1.19 G122: direct tree-sitter dep for S-expression Query/QueryCursor APIs (language-pack only re-exports Language).
tree-sitter = { version = "0.27", optional = true }
unic-langid = "0.9"
fluent-langneg = "0.14"
# v0.1.37 E5 — artifact signal extraction (`extract-artifact`). Every crate below
# is pure Rust: no C toolchain, no system package, no OpenSSL, no telemetry.
# `zip` reads the OOXML container only. 9.x fixes RUSTSEC-2026-0367, -0368 and
# -0369 (all in `extract`, which this crate never calls). In 9.x the narrow
# `deflate-flate2` feature activates `dep:flate2` itself, so it is the smallest
# feature set that decodes deflate and lets the tests write fixtures. The
# `flate2` back-end is selected by the `rust_backend` shim below (`miniz_oxide`,
# pure Rust). The umbrella `deflate` is NOT used: in 9.x it routes through
# `deflate-flate2-zlib-rs` and `deflate-zopfli`, which adds crates for a writer
# quality this crate never uses. Never switch to `deflate-flate2-zlib*` (C zlib).
zip = { version = "9.0.5", default-features = false, features = ["deflate-flate2"] }
# Feature-unification shim on a dependency that other crates already pull in:
# `flate2` is reachable through `lopdf`, `tree-sitter-language-pack` and `zip`
# regardless of this line. Declaring `rust_backend` here pins the shared node to
# `miniz_oxide` (Rust) so no consumer in the graph can select C zlib, and keeps
# the pin explicit if an upstream edge is ever pruned.
flate2 = { version = "1", default-features = false, features = ["rust_backend"] }
# OOXML part parsing. Default feature set is empty; no serde/encoding pulled in.
quick-xml = { version = "0.42", default-features = false }
# Image dimensions from the header only — the crate has no dependencies at all
# and never decodes pixels.
imagesize = { version = "0.14", default-features = false, features = [
    "png",
    "jpeg",
    "gif",
    "bmp",
    "webp",
    "tiff",
    "ico",
] }
# PDF object model for page count, MediaBox and Info metadata. Default features
# pull chrono/jiff/time/rayon for date construction this command never uses.
lopdf = { version = "0.44", default-features = false }

[target.'cfg(unix)'.dependencies]
nix = { version = "0.31", features = ["fs", "signal", "process"] }
libc = "0.2"
signal-hook = "0.4"
xattr = "1"            # G39: extended attribute preservation (macOS/Linux)
# G54 advisory locking uses std::fs::File::try_lock on every platform, which
# maps to flock(2) on Unix and LockFileEx on Windows with no `unsafe` here.
# nix::sys::signal::kill only answers "does this PID still exist" for the
# WAL heal, which is why the signal and process features are enabled.

[target.'cfg(windows)'.dependencies]
windows-sys = { version = "0.61", features = ["Win32_Foundation", "Win32_Storage_FileSystem", "Win32_System_Console"] }
ctrlc = { version = "3.5", features = ["termination"] }

[target.'cfg(target_os = "linux")'.dependencies]
rustix = { version = "0.38", features = ["fs"] }  # G114: ftruncate for in-place inode-preserving writes
nix = { version = "0.31", features = ["fs", "signal", "process"] }
libc = "0.2"
signal-hook = "0.4"

[dev-dependencies]
assert_cmd = "2"
predicates = "3"
tempfile = "3"
insta = { version = "1", features = ["json"] }
proptest = "1"
regex = "1"
criterion = { version = "0.5", features = ["html_reports"] }
tracing-test = "0.2"
filetime = "0.2"

[[bench]]
name = "hash_benchmark"
harness = false

[[bench]]
name = "read_benchmark"
harness = false

# ---------------------------------------------------------------------------
# Performance profiles (Rules Rust eficiência / economia)
# Order of optimization: algorithm → hot-path work → allocations → build opts
# → SIMD/parallelism last. Measure with criterion/samply before micro-opts.
# ---------------------------------------------------------------------------

# Production binary: max speed, cross-crate LTO, single CGU, small strip.
# overflow-checks kept ON after audit (file sizes / counts must not wrap silently).
# Not using target-cpu=native here — crates.io / multi-host distribution must
# stay portable (x86-64 baseline). Local dedicated builds may pass RUSTFLAGS.
# PGO/BOLT/multivers intentionally omitted: one-shot CLI; boot+FS dominate over
# long-lived PGO datasets (document when re-evaluating with representative trees).
[profile.release]
opt-level = 3
lto = "fat"
codegen-units = 1
strip = "symbols"
panic = "abort"
overflow-checks = true
debug = false

# Criterion must match production codegen (default [profile.bench] is opt-level=3
# but does NOT enable fat LTO / CGU=1 — microbenches would lie vs the shipped binary).
[profile.bench]
inherits = "release"

# Optional size-focused binary: cargo build --profile min-size
# (agents / constrained installs). Same LTO/CGU/strip as release.
[profile.min-size]
inherits = "release"
opt-level = "z"

# Speed up proc-macro / build.rs compiles without weakening the final binary.
[profile.release.build-override]
opt-level = 0
codegen-units = 16

[profile.dev.build-override]
opt-level = 0

# Dev: optimize dependencies (serde, regex, ignore, …) while keeping crate debug.
[profile.dev.package."*"]
opt-level = 2

# Dev: optimize THIS crate too, at the cheapest useful level.
# The fuzzy cascade is the hot path of `replace --fuzzy auto`, and at opt-level 0
# a 13 MB corpus took 18.5 s against 3.4 s at opt-level 2, measured on this host.
# Level 1 keeps `cargo build` fast and makes a debug binary usable for a real read
# or replace; the release profile stays the shipping shape.
[profile.dev]
opt-level = 1

# docs.rs build (nightly sandbox). May 2026+: without `targets`, only default-target is built.
# Multiplatform CLI: document primary desktop triples explicitly (max 10 on docs.rs).
[package.metadata.docs.rs]
all-features = true
default-target = "x86_64-unknown-linux-gnu"
targets = [
    "x86_64-unknown-linux-gnu",
    "x86_64-apple-darwin",
    "aarch64-apple-darwin",
    "x86_64-pc-windows-msvc",
]
rustdoc-args = ["--cfg", "docsrs"]

# `flate2` is never named in the source: it is a feature-unification shim that
# pins the shared `flate2` node to the pure-Rust `rust_backend` (see the
# `flate2` dependency comment above). cargo-machete cannot see that use.
[package.metadata.cargo-machete]
ignored = ["flate2"]

[badges.maintenance]
status = "actively-developed"

[features]
# E7 (v0.1.37): `watch` is OPT-IN. The default binary is one-shot
# (born, run, die) and does not carry `notify`; the `watch` subcommand stays
# on the surface through `src/commands/watch.rs` `#[cfg(not(feature = "watch"))]`
# stub, which fails closed with exit 78 and a rebuild hint.
default = ["core", "ast", "lang-rust", "lang-ts", "lang-py"]
core = []
ast = ["dep:ast-grep-core", "dep:ast-grep-language", "dep:tree-sitter", "dep:tree-sitter-language-pack", "dep:serde-saphyr"]
lang-rust = []
lang-ts = []
lang-py = []
lang-go = []
lang-full = ["lang-rust", "lang-ts", "lang-py", "lang-go"]
watch = ["dep:notify"]
# A-017: empty `semantic` feature removed — semantic-search is always compiled
# (offline Jaccard). Keep `full` without a no-op semantic gate.
full = ["default", "lang-full", "watch"]
# Opt-in property tests that may take longer than the default budget.
# Run with: cargo test --features slow-tests
slow-tests = []
# Optional i18n language packs (top-20 economic). Default binary ships only en + pt-BR.
# Features are placeholders until complete human-reviewed translations land — do not
# enable incomplete locales in release builds.
i18n-cjk = []
i18n-rtl = []
i18n-europe = []
i18n-full = ["i18n-cjk", "i18n-rtl", "i18n-europe"]