diff --git a/AGENTS.md b/AGENTS.md index d12bfdd..23fedcc 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -96,7 +96,7 @@ Read `docs/roadmap.md` before starting feature work. Current intended sequence: -- `0.2.8`: dogfood diagnostic precision, especially noisy Next.js/framework and suggestion behavior found in `cleisson.com`. +- Next diagnostic milestone, deferred from `0.2.8`: dogfood diagnostic precision, especially noisy Next.js/framework and suggestion behavior found in `cleisson.com`. - `0.2.9`: provider hardening through fake transports and deterministic failure tests. No remote image commands. - `0.2.10`: artifact contract stabilization for manifests, doctor JSON, compare JSON, suggestions, AI review JSON, alt-text JSON, draft Markdown, and agent-task Markdown. No `devimg remote` command. - `0.2.11` optional: remote safety design gate only. No public remote behavior unless explicitly re-scoped. @@ -317,7 +317,7 @@ It must not: - rewrite manifest helper files; - require OpenAI or Anthropic keys by default. -Consumer workflows should pin release tags such as `cleisson-labs/devimg/action@v0.2.7`. Use `uses: ./action` with `binary-path: target/debug/devimg` only when testing this repository's local Action. +Consumer workflows should pin release tags such as `cleisson-labs/devimg/action@v0.2.8`. Use `uses: ./action` with `binary-path: target/debug/devimg` only when testing this repository's local Action. ## `cleisson.com` Dogfood @@ -338,7 +338,7 @@ Tracked DevImg setup in `cleisson.com`: - SEO helper export: `lib/devimg-seo.generated.ts`. - app helper: `lib/devimg.ts`. - docs: `docs/devimg.md`. -- CI: `.github/workflows/ci.yml`, using the public `cleisson-labs/devimg/action@v0.2.7`. +- CI: `.github/workflows/ci.yml` downloads its pinned DevImg release from `cleisson-labs/devimg` and verifies the archive checksum. Important implementation details: diff --git a/CHANGELOG.md b/CHANGELOG.md index cb3d009..4ba8664 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,10 @@ DevImg follows a lightweight changelog during pre-1.0 development. Add unrelease ## Unreleased +## 0.2.8 + +- Updated dependency resolutions to address the Rust security audit. +- Completed focused coverage for previously uncovered core and CLI behavior. - Updated repository links, crate metadata, and GitHub Action references for the move to `cleisson-labs/devimg`. - Added GitHub-native coverage visibility through README workflow badges, Coverage job summaries, and uploaded HTML/JSON coverage artifacts. - Added an exact Rust line/function coverage gate through `scripts/coverage.sh` and a CI `Coverage` job using pinned `cargo-llvm-cov 0.8.7`. diff --git a/Cargo.lock b/Cargo.lock index 8916f28..3cb2414 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -87,9 +87,9 @@ dependencies = [ [[package]] name = "anyhow" -version = "1.0.102" +version = "1.0.103" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7f202df86484c868dbad7eaa557ef785d5c66295e41b460ef922eca0723b842c" +checksum = "2a4385e2e34eb35d6b3efe798b9eb88096925d87726c0798709bf56d9ed84af3" [[package]] name = "arbitrary" @@ -283,6 +283,17 @@ version = "0.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "613afe47fcd5fac7ccf1db93babcb082c5994d996f20b8b159f2ad1658eb5724" +[[package]] +name = "chacha20" +version = "0.10.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "65c35e4b699c7e15ccbe7ee35c005e4fc0a278d22238a2857e6ce2dadeda1b06" +dependencies = [ + "cfg-if", + "cpufeatures", + "rand_core 0.10.1", +] + [[package]] name = "clap" version = "4.6.1" @@ -365,9 +376,9 @@ dependencies = [ [[package]] name = "crossbeam-epoch" -version = "0.9.18" +version = "0.9.20" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5b82ac4a3c2ca9c3460964f020e1402edd5753411d7737aa39c3714ad1b5420e" +checksum = "2d6914041f254d6e9176c01941b21115dcfb7089e55135a35411081bd106ef3f" dependencies = [ "crossbeam-utils", ] @@ -380,7 +391,7 @@ checksum = "d0a5c400df2834b80a4c3327b3aad3a4c4cd4de0629063962b03235697506a28" [[package]] name = "devimg" -version = "0.2.7" +version = "0.2.8" dependencies = [ "base64", "clap", @@ -391,7 +402,7 @@ dependencies = [ [[package]] name = "devimg-core" -version = "0.2.7" +version = "0.2.8" dependencies = [ "blake3", "globset", @@ -475,9 +486,9 @@ dependencies = [ [[package]] name = "form_urlencoded" -version = "1.2.2" +version = "1.2.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cb4cb245038516f5f85277875cdaa4f7d2c9a0fa0468de06ed190163b1581fcf" +checksum = "afa489199eaffb1211795df1c6236ce1ad0d41a6fa45250add73e3b02420f06e" dependencies = [ "percent-encoding", ] @@ -551,10 +562,22 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "899def5c37c4fd7b2664648c28120ecec138e4d395b459e5ca34f9cce2dd77fd" dependencies = [ "cfg-if", - "js-sys", "libc", - "r-efi", + "r-efi 5.3.0", "wasip2", +] + +[[package]] +name = "getrandom" +version = "0.4.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "300e883d756b2e4ec94e02791f39b04b522276138852cfc41d9fb7e904106099" +dependencies = [ + "cfg-if", + "js-sys", + "libc", + "r-efi 6.0.0", + "rand_core 0.10.1", "wasm-bindgen", ] @@ -1200,14 +1223,15 @@ dependencies = [ [[package]] name = "quinn-proto" -version = "0.11.14" +version = "0.11.19" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "434b42fec591c96ef50e21e886936e66d3cc3f737104fdb9b737c40ffb94c098" +checksum = "0e750cca55fe4f0439a15d0bb529da9651e79993e8e72c61a899a36d462befbe" dependencies = [ "bytes", - "getrandom 0.3.4", + "getrandom 0.4.3", "lru-slab", - "rand", + "rand 0.10.4", + "rand_pcg", "ring", "rustc-hash", "rustls", @@ -1221,16 +1245,16 @@ dependencies = [ [[package]] name = "quinn-udp" -version = "0.5.14" +version = "0.5.16" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "addec6a0dcad8a8d96a771f815f0eaf55f9d1805756410b39f5fa81332574cbd" +checksum = "af66907df18639dcf4db56ca65490cabc4b27a97dbadd96f2926cca73298f016" dependencies = [ "cfg_aliases", "libc", "once_cell", "socket2", "tracing", - "windows-sys 0.60.2", + "windows-sys 0.52.0", ] [[package]] @@ -1248,6 +1272,12 @@ version = "5.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "69cdb34c158ceb288df11e18b4bd39de994f6657d83847bdffdbd7f346754b0f" +[[package]] +name = "r-efi" +version = "6.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f8dcc9c7d52a811697d2151c701e0d08956f92b0e24136cf4cf27b57a6a0d9bf" + [[package]] name = "rand" version = "0.9.4" @@ -1255,7 +1285,18 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "44c5af06bb1b7d3216d91932aed5265164bf384dc89cd6ba05cf59a35f5f76ea" dependencies = [ "rand_chacha", - "rand_core", + "rand_core 0.9.5", +] + +[[package]] +name = "rand" +version = "0.10.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8f6fa277c67e6ea590466f04c3fe82cb509f0864fe470643e5570de9514a9b11" +dependencies = [ + "chacha20", + "getrandom 0.4.3", + "rand_core 0.10.1", ] [[package]] @@ -1265,7 +1306,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d3022b5f1df60f26e1ffddd6c66e8aa15de382ae63b3a0c1bfc0e4d3e3f325cb" dependencies = [ "ppv-lite86", - "rand_core", + "rand_core 0.9.5", ] [[package]] @@ -1277,6 +1318,21 @@ dependencies = [ "getrandom 0.3.4", ] +[[package]] +name = "rand_core" +version = "0.10.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "63b8176103e19a2643978565ca18b50549f6101881c443590420e4dc998a3c69" + +[[package]] +name = "rand_pcg" +version = "0.10.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "eb95882a1e14462c69aea9984bb261293ccfe6022ef8de0eda18bd5afb0052df" +dependencies = [ + "rand_core 0.10.1", +] + [[package]] name = "rav1e" version = "0.8.1" @@ -1304,7 +1360,7 @@ dependencies = [ "num-traits", "paste", "profiling", - "rand", + "rand 0.9.4", "rand_chacha", "simd_helpers", "thiserror", @@ -1431,9 +1487,9 @@ checksum = "94300abf3f1ae2e2b8ffb7b58043de3d399c73fa6f4b73826402a5c457614dbe" [[package]] name = "rustls" -version = "0.23.40" +version = "0.23.46" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ef86cd5876211988985292b91c96a8f2d298df24e75989a43a3c73f2d4d8168b" +checksum = "48e13bd8c0e9365c43cfa5c9e8f9ad49d3c8444926c9aac819e0e4dc503c8fdf" dependencies = [ "once_cell", "ring", @@ -1455,9 +1511,9 @@ dependencies = [ [[package]] name = "rustls-webpki" -version = "0.103.13" +version = "0.103.16" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "61c429a8649f110dddef65e2a5ad240f747e85f7758a6bccc7e5777bd33f756e" +checksum = "4443b1b6d39d7c663139942cc4558262562d2c84123bb6282ef177009ca8b281" dependencies = [ "ring", "rustls-pki-types", @@ -1688,9 +1744,9 @@ checksum = "1f3ccbac311fea05f86f61904b462b55fb3df8837a366dfc601a0161d0532f20" [[package]] name = "tokio" -version = "1.52.3" +version = "1.53.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8fc7f01b389ac15039e4dc9531aa973a135d7a4135281b12d7c1bc79fd57fffe" +checksum = "ce3335fa71841cda333a58d7615b03901380ecf09d59b3296d21f8bbac0dde4e" dependencies = [ "bytes", "libc", @@ -1833,9 +1889,9 @@ checksum = "8ecb6da28b8a351d773b68d5825ac39017e680750f980f3a1a85cd8dd28a47c1" [[package]] name = "url" -version = "2.5.8" +version = "2.5.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ff67a8a4397373c3ef660812acab3268222035010ab8680ec4215f38ba3d0eed" +checksum = "f00cd2407bb42c0ef17be88d4cf020f5cceffd121665bac9b8b9493a369b3b1a" dependencies = [ "form_urlencoded", "idna", @@ -1986,9 +2042,9 @@ dependencies = [ [[package]] name = "webpki-roots" -version = "1.0.7" +version = "1.0.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "52f5ee44c96cf55f1b349600768e3ece3a8f26010c05265ab73f945bb1a2eb9d" +checksum = "1c1c8e20c8a38fc7d65abfe74eb7280e4aa667e8eec8bc84996d2874810748d9" dependencies = [ "rustls-pki-types", ] @@ -1999,7 +2055,7 @@ version = "0.1.11" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c2a7b1c03c876122aa43f3020e6c3c3ee5c05081c9a00739faf7503aeba10d22" dependencies = [ - "windows-sys 0.61.2", + "windows-sys 0.52.0", ] [[package]] @@ -2014,16 +2070,7 @@ version = "0.52.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "282be5f36a8ce781fad8c8ae18fa3f9beff57ec1b52cb3de0789201425d9a33d" dependencies = [ - "windows-targets 0.52.6", -] - -[[package]] -name = "windows-sys" -version = "0.60.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f2f500e4d28234f72040990ec9d39e3a6b950f9f22d3dba18416c35882612bcb" -dependencies = [ - "windows-targets 0.53.5", + "windows-targets", ] [[package]] @@ -2041,31 +2088,14 @@ version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9b724f72796e036ab90c1021d4780d4d3d648aca59e491e6b98e725b84e99973" dependencies = [ - "windows_aarch64_gnullvm 0.52.6", - "windows_aarch64_msvc 0.52.6", - "windows_i686_gnu 0.52.6", - "windows_i686_gnullvm 0.52.6", - "windows_i686_msvc 0.52.6", - "windows_x86_64_gnu 0.52.6", - "windows_x86_64_gnullvm 0.52.6", - "windows_x86_64_msvc 0.52.6", -] - -[[package]] -name = "windows-targets" -version = "0.53.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4945f9f551b88e0d65f3db0bc25c33b8acea4d9e41163edf90dcd0b19f9069f3" -dependencies = [ - "windows-link", - "windows_aarch64_gnullvm 0.53.1", - "windows_aarch64_msvc 0.53.1", - "windows_i686_gnu 0.53.1", - "windows_i686_gnullvm 0.53.1", - "windows_i686_msvc 0.53.1", - "windows_x86_64_gnu 0.53.1", - "windows_x86_64_gnullvm 0.53.1", - "windows_x86_64_msvc 0.53.1", + "windows_aarch64_gnullvm", + "windows_aarch64_msvc", + "windows_i686_gnu", + "windows_i686_gnullvm", + "windows_i686_msvc", + "windows_x86_64_gnu", + "windows_x86_64_gnullvm", + "windows_x86_64_msvc", ] [[package]] @@ -2074,96 +2104,48 @@ version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "32a4622180e7a0ec044bb555404c800bc9fd9ec262ec147edd5989ccd0c02cd3" -[[package]] -name = "windows_aarch64_gnullvm" -version = "0.53.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a9d8416fa8b42f5c947f8482c43e7d89e73a173cead56d044f6a56104a6d1b53" - [[package]] name = "windows_aarch64_msvc" version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "09ec2a7bb152e2252b53fa7803150007879548bc709c039df7627cabbd05d469" -[[package]] -name = "windows_aarch64_msvc" -version = "0.53.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b9d782e804c2f632e395708e99a94275910eb9100b2114651e04744e9b125006" - [[package]] name = "windows_i686_gnu" version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8e9b5ad5ab802e97eb8e295ac6720e509ee4c243f69d781394014ebfe8bbfa0b" -[[package]] -name = "windows_i686_gnu" -version = "0.53.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "960e6da069d81e09becb0ca57a65220ddff016ff2d6af6a223cf372a506593a3" - [[package]] name = "windows_i686_gnullvm" version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0eee52d38c090b3caa76c563b86c3a4bd71ef1a819287c19d586d7334ae8ed66" -[[package]] -name = "windows_i686_gnullvm" -version = "0.53.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fa7359d10048f68ab8b09fa71c3daccfb0e9b559aed648a8f95469c27057180c" - [[package]] name = "windows_i686_msvc" version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "240948bc05c5e7c6dabba28bf89d89ffce3e303022809e73deaefe4f6ec56c66" -[[package]] -name = "windows_i686_msvc" -version = "0.53.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1e7ac75179f18232fe9c285163565a57ef8d3c89254a30685b57d83a38d326c2" - [[package]] name = "windows_x86_64_gnu" version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "147a5c80aabfbf0c7d901cb5895d1de30ef2907eb21fbbab29ca94c5b08b1a78" -[[package]] -name = "windows_x86_64_gnu" -version = "0.53.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9c3842cdd74a865a8066ab39c8a7a473c0778a3f29370b5fd6b4b9aa7df4a499" - [[package]] name = "windows_x86_64_gnullvm" version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "24d5b23dc417412679681396f2b49f3de8c1473deb516bd34410872eff51ed0d" -[[package]] -name = "windows_x86_64_gnullvm" -version = "0.53.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0ffa179e2d07eee8ad8f57493436566c7cc30ac536a3379fdf008f47f6bb7ae1" - [[package]] name = "windows_x86_64_msvc" version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "589f6da84c646204747d1270a2a5661ea66ed1cced2631d546fdfb155959f9ec" -[[package]] -name = "windows_x86_64_msvc" -version = "0.53.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d6bbff5f0aada427a1e5a6da5f1f98158182f26556f345ac9e04d36d0ebed650" - [[package]] name = "winnow" version = "1.0.3" diff --git a/Cargo.toml b/Cargo.toml index 9456f1c..6c71151 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -6,7 +6,7 @@ members = [ resolver = "2" [workspace.package] -version = "0.2.7" +version = "0.2.8" edition = "2021" rust-version = "1.88" license = "Apache-2.0" diff --git a/README.md b/README.md index dabed5f..6894e5a 100644 --- a/README.md +++ b/README.md @@ -498,7 +498,7 @@ jobs: contents: read steps: - uses: actions/checkout@v6 - - uses: cleisson-labs/devimg/action@v0.2.7 + - uses: cleisson-labs/devimg/action@v0.2.8 with: mode: check export-output: lib/devimg.generated.ts @@ -552,8 +552,8 @@ cargo install devimg Create a version tag that matches the workspace version and push it after publishing crates: ```bash -git tag v0.2.7 -git push origin v0.2.7 +git tag v0.2.8 +git push origin v0.2.8 ``` The release workflow builds Linux, macOS, and Windows archives, attaches SHA-256 checksums, and publishes a GitHub Release. See `docs/release.md` for install and release details. diff --git a/action/README.md b/action/README.md index 932090a..9c39342 100644 --- a/action/README.md +++ b/action/README.md @@ -10,7 +10,7 @@ jobs: contents: read steps: - uses: actions/checkout@v6 - - uses: cleisson-labs/devimg/action@v0.2.7 + - uses: cleisson-labs/devimg/action@v0.2.8 with: mode: check export-output: lib/devimg.generated.ts @@ -34,7 +34,7 @@ Pin the release tag from public repositories with `cleisson-labs/devimg/action@v - `working-directory`: command working directory. Default: `.`. - `fail-on-warning`: pass `--fail-on-warning` in check mode. Acknowledged warnings remain visible but do not fail strict checks. - `binary-path`: use a prebuilt local binary, useful for smoke tests. -- `version`: release version to download when no binary is found. Default: `v0.2.7`. +- `version`: release version to download when no binary is found. Default: `v0.2.8`. - `report-path`: configured report path appended to the step summary; this does not override `devimg.toml`. - `manifest-path`: expected manifest path exposed as an output; this does not override `devimg.toml`. - `export-output`: optional checked-in manifest export/helper file to verify in check mode. diff --git a/action/action.yml b/action/action.yml index 47da3d3..4359bdf 100644 --- a/action/action.yml +++ b/action/action.yml @@ -28,7 +28,7 @@ inputs: version: description: Release version to download when no binary is available required: false - default: v0.2.7 + default: v0.2.8 report-path: description: Markdown report path to append to the job summary required: false diff --git a/crates/devimg-cli/Cargo.toml b/crates/devimg-cli/Cargo.toml index 0eab1e7..4f0987f 100644 --- a/crates/devimg-cli/Cargo.toml +++ b/crates/devimg-cli/Cargo.toml @@ -18,6 +18,6 @@ path = "src/main.rs" [dependencies] base64 = "0.22.1" clap = { version = "=4.6.1", features = ["derive"] } -devimg-core = { version = "0.2.7", path = "../devimg-core" } +devimg-core = { version = "0.2.8", path = "../devimg-core" } reqwest = { version = "0.12.24", default-features = false, features = ["blocking", "json", "rustls-tls"] } serde_json = "1.0.150" diff --git a/crates/devimg-cli/src/main_tests.rs b/crates/devimg-cli/src/main_tests.rs index 151a779..a14034e 100644 --- a/crates/devimg-cli/src/main_tests.rs +++ b/crates/devimg-cli/src/main_tests.rs @@ -41,6 +41,59 @@ use std::time::{SystemTime, UNIX_EPOCH}; static ENV_LOCK: Mutex<()> = Mutex::new(()); +#[test] +fn ai_env_roots_searches_each_normalized_directory_once() { + let current = std::env::current_dir().expect("current directory is available"); + let roots = super::ai_env_roots(&[current.clone(), current.join(".")]) + .expect("search roots are available"); + assert_eq!(roots, vec![normalize_lexical(¤t)]); +} + +#[cfg(unix)] +#[test] +fn review_reports_a_removed_working_directory_without_writing_html() { + const CHILD_ROOT: &str = "DEVIMG_TEST_REMOVED_REVIEW_CWD"; + if let Some(root) = std::env::var_os(CHILD_ROOT) { + assert_review_with_removed_working_directory(Path::new(&root)); + return; + } + let root = temp_dir("review_removed_cwd"); + let output = std::process::Command::new(std::env::current_exe().expect("test executable")) + .args([ + "--exact", + "tests::review_reports_a_removed_working_directory_without_writing_html", + ]) + .env(CHILD_ROOT, &root) + .output() + .expect("isolated review test runs"); + cleanup(&root); + assert!( + output.status.success(), + "{}{}", + String::from_utf8_lossy(&output.stdout), + String::from_utf8_lossy(&output.stderr) + ); +} + +#[cfg(unix)] +fn assert_review_with_removed_working_directory(root: &Path) { + let manifest = root.join("manifest.json"); + write_manifest_fixture(&manifest, "devimg.toml"); + let removed = root.join("removed"); + fs::create_dir(&removed).expect("working directory creates"); + std::env::set_current_dir(&removed).expect("enter isolated working directory"); + fs::remove_dir(&removed).expect("remove working directory"); + let html = root.join("review.html"); + let result = command_review(review_args_with(|args| { + args.manifest = manifest; + args.output = Some(html.clone()); + })); + assert!( + matches!(result, Err(CliError::Core(devimg_core::DevimgError::Io { path, .. })) if path == Path::new(".")) + ); + assert!(!html.exists()); +} + #[test] fn env_line_parser_extracts_key_without_comments() { assert_eq!( diff --git a/crates/devimg-cli/tests/cli.rs b/crates/devimg-cli/tests/cli.rs index 40d72d1..e050a73 100644 --- a/crates/devimg-cli/tests/cli.rs +++ b/crates/devimg-cli/tests/cli.rs @@ -18,7 +18,7 @@ fn help_and_usage_exit_codes_are_stable() { assert_code(run(["draft", "--help"]), 0); let version = run(["--version"]); assert_status(&version, 0); - assert!(String::from_utf8_lossy(&version.stdout).contains("0.2.7")); + assert!(String::from_utf8_lossy(&version.stdout).contains(env!("CARGO_PKG_VERSION"))); assert_code(run([] as [&str; 0]), 2); assert_code(run(["unknown"]), 2); } diff --git a/crates/devimg-core/src/ai_tests.rs b/crates/devimg-core/src/ai_tests.rs index 0f6632f..3e30d2d 100644 --- a/crates/devimg-core/src/ai_tests.rs +++ b/crates/devimg-core/src/ai_tests.rs @@ -446,6 +446,35 @@ fn ai_alt_request_uses_supported_variant_when_source_format_is_not_supported() { assert_eq!(request.selected_images[0].mime_type, "image/webp"); } +#[test] +fn ai_alt_request_records_sources_without_a_supported_image_for_the_provider() { + let mut manifest = sample_manifest(); + manifest.outputs.retain(|output| output.format == "avif"); + manifest.outputs[0].source_path = "assets/vector.svg".to_string(); + let request = build_ai_alt_request( + &manifest, + &AiAltOptions { + provider: Some(AiProvider::Openai), + model: Some("alt-model".to_string()), + command: "devimg alt".to_string(), + config_path: PathBuf::from("devimg.toml"), + manifest_path: PathBuf::from("manifest.json"), + project_root: PathBuf::from("."), + dry_run: true, + include_images: true, + image_detail: "low".to_string(), + max_images: 1, + output_path: None, + markdown_path: None, + }, + ); + assert!(request.selected_images.is_empty()); + assert_eq!(request.skipped_image_count, 1); + assert_eq!(request.sources[0].representative_image_format, "avif"); + assert!(!request.sources[0].image_bytes_included); + assert_eq!(request.sources[0].image_detail, None); +} + #[test] fn ai_alt_representative_image_falls_back_to_first_variant_or_source() { let builder = super::AiAltSourceBuilder { @@ -639,6 +668,63 @@ fn ai_alt_normalizers_default_unknown_values_for_review() { ); } +#[test] +fn ai_review_normalization_preserves_supported_advisory_categories() { + for category in [ + "crop risk", + "readability risk", + "excessive padding", + "low-resolution source", + "format-quality concern", + "accessibility note", + ] { + assert_eq!(super::normalize_observation_category(category), category); + } +} + +#[test] +fn ai_alt_normalization_preserves_supported_image_categories() { + for category in [ + "content-photo", + "screenshot", + "logo", + "illustration", + "diagram", + "icon", + "decorative", + "text-heavy", + "unknown", + ] { + assert_eq!(super::normalize_alt_category(category), category); + } +} + +#[test] +fn ai_alt_normalization_preserves_and_deduplicates_supported_warnings() { + let warnings = [ + "decorative", + "text-heavy", + "logo", + "screenshot", + "uncertain-description", + "needs-human-review", + "logo", + ] + .map(str::to_string) + .to_vec(); + assert_eq!( + super::normalize_alt_warnings(warnings), + vec![ + "decorative", + "logo", + "needs-human-review", + "screenshot", + "text-heavy", + "uncertain-description", + ] + ); +} + #[test] fn ai_alt_markdown_renders_empty_and_providerless_draft_states() { let empty_report = AiAltReport { @@ -697,6 +783,37 @@ fn ai_alt_markdown_renders_empty_and_providerless_draft_states() { let markdown = render_ai_alt_markdown(&filled); assert!(markdown.contains("- Candidate alt text: Dashboard screenshot")); assert!(markdown.contains("- Warnings: `text-heavy`")); + let mut without_warnings = filled; + without_warnings.drafts[0].warnings.clear(); + let markdown = render_ai_alt_markdown(&without_warnings); + assert!(markdown.contains("- Candidate alt text: Dashboard screenshot")); + assert!(!markdown.contains("- Warnings:")); +} + +#[test] +fn ai_draft_markdown_handles_small_context_and_empty_provider_sections() { + let mut request = sample_draft_request(AiDraftType::ReadmeSnippet, None, None, true); + request.report_summary.excerpt.clear(); + request + .manifest_summary + .outputs + .push(super::AiDraftManifestOutputSummary { + source_path: "assets/card.png".to_string(), + output_path: "public/card.webp".to_string(), + preset: "card".to_string(), + fit: "cover".to_string(), + width: 64, + height: 32, + format: "webp".to_string(), + bytes: 42, + }); + let mut report = build_ai_draft_placeholder_report(&request); + report.sections[0].body.clear(); + let markdown = render_ai_draft_markdown(&report); + assert!(markdown.contains("`assets/card.png` `card` 64x32 `webp` (`42` bytes)")); + assert!(!markdown.contains("additional outputs omitted")); + assert!(!markdown.contains("- Excerpt:")); + assert!(markdown.contains("## Review Checklist")); } #[test] diff --git a/crates/devimg-core/src/config_tests.rs b/crates/devimg-core/src/config_tests.rs index 0d81d58..6de1a41 100644 --- a/crates/devimg-core/src/config_tests.rs +++ b/crates/devimg-core/src/config_tests.rs @@ -252,9 +252,21 @@ widths = [640] formats = ["webp"] crop = "top-right" "#; - let config = parse_config(Path::new("devimg.toml"), raw).expect("config parses"); - - assert_eq!(config.presets[0].crop, CropPosition { x: 1.0, y: 0.0 }); + for (anchor, x, y) in [ + ("center", 0.5, 0.5), + ("top", 0.5, 0.0), + ("bottom", 0.5, 1.0), + ("left", 0.0, 0.5), + ("right", 1.0, 0.5), + ("top-left", 0.0, 0.0), + ("top-right", 1.0, 0.0), + ("bottom-left", 0.0, 1.0), + ("bottom-right", 1.0, 1.0), + ] { + let raw = raw.replace("top-right", anchor); + let config = parse_config(Path::new("devimg.toml"), &raw).expect("config parses"); + assert_eq!(config.presets[0].crop, CropPosition { x, y }, "{anchor}"); + } } #[test] diff --git a/crates/devimg-core/src/framework_tests.rs b/crates/devimg-core/src/framework_tests.rs index 8024fe7..0abd66b 100644 --- a/crates/devimg-core/src/framework_tests.rs +++ b/crates/devimg-core/src/framework_tests.rs @@ -26,6 +26,22 @@ fn detects_frameworks_from_package_json_and_config_files() { cleanup(&root); } +#[test] +fn detects_astro_from_optional_dependencies() { + let root = temp_project("framework_optional_dependency"); + fs::write( + root.join("package.json"), + r#"{"optionalDependencies":{"astro":"5.0.0"}}"#, + ) + .expect("package writes"); + let config = config(&root, "content_hash_filenames = false"); + + let report = inspect_frameworks(&config, None); + + assert_eq!(report.frameworks, vec!["astro"]); + cleanup(&root); +} + #[test] fn invalid_package_json_is_ignored_for_framework_detection() { let root = temp_project("framework_invalid_package"); diff --git a/crates/devimg-core/src/plan_tests.rs b/crates/devimg-core/src/plan_tests.rs index ad8bdd5..d59bb62 100644 --- a/crates/devimg-core/src/plan_tests.rs +++ b/crates/devimg-core/src/plan_tests.rs @@ -85,6 +85,33 @@ fn preset_overrides_respect_preset_include_and_exclude_filters() { assert_eq!(excluded.fit, FitMode::Cover); } +#[test] +fn quality_only_override_preserves_preset_geometry() { + let config = config( + vec![preset("card", FitMode::Cover)], + vec![PresetOverrideConfig { + include: Vec::new(), + exclude: Vec::new(), + presets: Vec::new(), + quality: Some(65), + fit: None, + crop: None, + allow_upscale: None, + }], + ); + + let plan = build_plan(&config, &[source_image("card.png")]).expect("plan builds"); + + assert_eq!(plan.operations.len(), 1); + assert_eq!(plan.operations[0].quality, 65); + assert_eq!(plan.operations[0].fit, FitMode::Cover); + assert_eq!(plan.operations[0].crop, CropPosition::CENTER); + assert_eq!( + (plan.operations[0].width, plan.operations[0].height), + (100, 50) + ); +} + #[test] fn encoder_hash_component_is_only_set_for_external_lossy_encoders() { assert_eq!(encoder_hash_component(FormatKind::Png), None); diff --git a/crates/devimg-core/src/quality_tests.rs b/crates/devimg-core/src/quality_tests.rs index 816ca24..5598d57 100644 --- a/crates/devimg-core/src/quality_tests.rs +++ b/crates/devimg-core/src/quality_tests.rs @@ -5,10 +5,22 @@ use crate::manifest::{Manifest, ManifestOutput}; use crate::pipeline::SourceImage; use super::{ - allowed_upscale_warning, cover_crop_warning, lossy_quality_warnings, manifest_quality_warnings, - skipped_upscale_warning, + allowed_upscale_warning, append_unique, cover_crop_warning, lossy_quality_warnings, + manifest_quality_warnings, skipped_upscale_warning, }; +#[test] +fn combining_warnings_preserves_order_and_removes_duplicates() { + let mut warnings = vec!["existing warning".to_string()]; + + append_unique( + &mut warnings, + ["existing warning", "new warning", "new warning"].map(str::to_string), + ); + + assert_eq!(warnings, vec!["existing warning", "new warning"]); +} + #[test] fn warns_for_low_lossy_quality_on_detail_sensitive_assets() { let source = source("assets/images/hero-screenshot.png", 1600, 900, 120_000); diff --git a/crates/devimg-core/src/suggest_tests.rs b/crates/devimg-core/src/suggest_tests.rs index 72cc84b..5d0c309 100644 --- a/crates/devimg-core/src/suggest_tests.rs +++ b/crates/devimg-core/src/suggest_tests.rs @@ -210,6 +210,23 @@ fn renders_empty_and_detailed_suggestion_markdown() { .contains("manual review or regeneration required")); } +#[test] +fn unknown_output_keeps_suggestion_fields_unresolved() { + let context = SuggestionContext::default(); + let mut fields = SuggestionFields { + output_path: Some("public/missing.webp".to_string()), + ..SuggestionFields::default() + }; + + context.enrich(&mut fields); + + assert_eq!(fields.output_path.as_deref(), Some("public/missing.webp")); + assert_eq!(fields.source_path, None); + assert_eq!(fields.preset, None); + assert_eq!(fields.width, None); + assert_eq!(fields.format, None); +} + #[test] fn context_enriches_fields_from_outputs_and_operations() { let mut context = SuggestionContext::default(); @@ -763,6 +780,18 @@ fn suggested_config_patches_cover_supported_codes() { assert!(suggested_config_patch("unknown", &fields, "message").is_none()); } +#[test] +fn invalid_output_without_a_known_path_suggests_regeneration() { + assert_eq!( + commands_for_diagnostic( + &config("devimg.toml"), + &diagnostic("invalid_output", "", "invalid output"), + &SuggestionFields::default(), + ), + vec!["devimg optimize --allow-overwrite", "devimg doctor"] + ); +} + #[test] fn commands_for_diagnostics_are_specific_and_deduped() { let config = config("devimg.toml"); diff --git a/crates/devimg-core/src/warnings_tests.rs b/crates/devimg-core/src/warnings_tests.rs index ddc9995..f6d0d54 100644 --- a/crates/devimg-core/src/warnings_tests.rs +++ b/crates/devimg-core/src/warnings_tests.rs @@ -42,6 +42,27 @@ fn parses_manifest_output_warning_metadata() { assert_eq!(info.output.as_deref(), Some("public/images/card.webp")); } +#[test] +fn incomplete_warning_messages_keep_unavailable_metadata_empty() { + let output = warning_info("quality:output-larger-than-source: output unavailable"); + assert_eq!(output.code, QUALITY_OUTPUT_LARGER_THAN_SOURCE); + assert_eq!(output.output, None); + + for message in [ + "plan:no-variants: source unavailable", + "plan:no-variants: no variants planned for assets/card.png", + ] { + let info = warning_info(message); + assert_eq!(info.code, PLAN_NO_VARIANTS); + assert_eq!(info.source, None); + } + + let preset = warning_info("quality:cover-crop: assets/card.png preset width 800 uses cover"); + assert_eq!(preset.source.as_deref(), Some("assets/card.png")); + assert_eq!(preset.preset, None); + assert_eq!(preset.width, Some(800)); +} + #[test] fn parses_skipped_upscale_and_plan_warning_metadata() { let skipped = warning_info( diff --git a/docs/action.md b/docs/action.md index c3209d5..63c75e9 100644 --- a/docs/action.md +++ b/docs/action.md @@ -18,7 +18,7 @@ jobs: contents: read steps: - uses: actions/checkout@v6 - - uses: cleisson-labs/devimg/action@v0.2.7 + - uses: cleisson-labs/devimg/action@v0.2.8 with: mode: check export-output: lib/devimg.generated.ts @@ -54,7 +54,7 @@ Export inputs: Set `review-output` when the workflow should produce a static visual review artifact. The Action runs `devimg review --manifest --output ` after the main command and optional export check pass. `review-manifest` can override the manifest path used for the artifact; otherwise it defaults to `manifest-path`. `review-force: true` passes `--force` to replace an existing artifact. Pair this with `actions/upload-artifact` because the Action does not upload files automatically. -The default `version` input is `v0.2.7`, which maps to release assets such as `devimg-linux-x86_64.tar.gz`. The Action downloads the matching `.sha256` file and verifies the archive before extraction. +The default `version` input is `v0.2.8`, which maps to release assets such as `devimg-linux-x86_64.tar.gz`. The Action downloads the matching `.sha256` file and verifies the archive before extraction. The Action exposes these outputs: diff --git a/docs/public-distribution.md b/docs/public-distribution.md index 2da75eb..8e7ca21 100644 --- a/docs/public-distribution.md +++ b/docs/public-distribution.md @@ -7,9 +7,9 @@ DevImg is distributed as public crates.io packages, GitHub Release binaries, and - Repository: - CLI crate: - Core crate: -- Current release: `v0.2.7` +- Current release: `v0.2.8` - Minimum Rust version for source installs: `1.88` -- GitHub Action: `cleisson-labs/devimg/action@v0.2.7` +- GitHub Action: `cleisson-labs/devimg/action@v0.2.8` ## CLI Install @@ -33,7 +33,7 @@ Users who do not want to build from source can download a GitHub Release archive Consumer workflows should pin a release tag: ```yaml -- uses: cleisson-labs/devimg/action@v0.2.7 +- uses: cleisson-labs/devimg/action@v0.2.8 with: mode: check ``` diff --git a/docs/release.md b/docs/release.md index e60ce95..088b1d6 100644 --- a/docs/release.md +++ b/docs/release.md @@ -51,7 +51,7 @@ Crates are effectively permanent. If a bad version is published, yank it with `c Tag the same commit after crates.io publish succeeds: ```bash -VERSION=0.2.7 +VERSION=0.2.8 git tag "v${VERSION}" git push origin "v${VERSION}" ``` @@ -74,7 +74,7 @@ Download the matching archive from the release page, verify its checksum, extrac Example for Linux x86_64: ```bash -VERSION=v0.2.7 +VERSION=v0.2.8 curl -fsSLO "https://github.com/cleisson-labs/devimg/releases/download/${VERSION}/devimg-linux-x86_64.tar.gz" curl -fsSLO "https://github.com/cleisson-labs/devimg/releases/download/${VERSION}/devimg-linux-x86_64.tar.gz.sha256" sha256sum -c devimg-linux-x86_64.tar.gz.sha256 @@ -87,7 +87,7 @@ tar -xzf devimg-linux-x86_64.tar.gz Install directly from a Git tag: ```bash -cargo install --git https://github.com/cleisson-labs/devimg --tag v0.2.7 devimg +cargo install --git https://github.com/cleisson-labs/devimg --tag v0.2.8 devimg ``` For local development: @@ -101,7 +101,7 @@ cargo install --path crates/devimg-cli Consumer workflows should pin the Action to a release tag: ```yaml -- uses: cleisson-labs/devimg/action@v0.2.7 +- uses: cleisson-labs/devimg/action@v0.2.8 with: mode: check ``` diff --git a/docs/roadmap.md b/docs/roadmap.md index e798859..60c9518 100644 --- a/docs/roadmap.md +++ b/docs/roadmap.md @@ -1,6 +1,6 @@ # DevImg Roadmap -This roadmap starts after `0.2.7`. The completed v0.2 AI plan has shipped; the rest of `0.2.x` should harden DevImg's current local-first, CI-first, provider-explicit contracts. Remote/dynamic image work is a new capability line and should start in `0.3.x` unless a release is explicitly marked as design/test prep only. +This roadmap starts after `0.2.8`, a maintenance release for dependency security, coverage and organization metadata. The diagnostic precision milestone originally planned for `0.2.8` remains open below. The completed v0.2 AI plan has shipped, and the rest of `0.2.x` should harden DevImg's current local-first, CI-first, provider-explicit contracts. Remote/dynamic image work is a new capability line and should start in `0.3.x` unless a release is explicitly marked as design/test prep only. DevImg's durable product constraints remain: @@ -14,7 +14,7 @@ DevImg's durable product constraints remain: - publish, sync, upload, delete, purge, cache invalidation, rollback, and social-platform posting belong outside DevImg core unless a future roadmap explicitly documents why that boundary changed; - generated variants, manifests, reports, review artifacts, and helper exports are regenerated through DevImg commands rather than hand-edited. -## `0.2.8`: Dogfood Diagnostic Precision +## Deferred From `0.2.8`: Dogfood Diagnostic Precision Goal: reduce noisy advisory output found during `cleisson.com` dogfooding without weakening safety checks. diff --git a/examples/workflows/image-pipeline.yml b/examples/workflows/image-pipeline.yml index afaa697..fae7932 100644 --- a/examples/workflows/image-pipeline.yml +++ b/examples/workflows/image-pipeline.yml @@ -14,7 +14,7 @@ jobs: contents: read steps: - uses: actions/checkout@v6 - - uses: cleisson-labs/devimg/action@v0.2.7 + - uses: cleisson-labs/devimg/action@v0.2.8 with: mode: check export-output: lib/devimg.generated.ts