fix(windows): keep Windows ONNX, storage, and file-replacement fixes

Merged
ZI
6mo ago
+301-44

Rebased on latest cortexkit/main (post-v0.31.1) per maintainer review.

Dropped (shipped in v0.31.1 or conflicting)

  • findHighestCachedVersion + compareSemver in resolver.ts — superseded by v0.31.1 skew detection
  • opencode.ts getStorageDir rewrite — upstream already routes through getCortexKitStorageRoot
  • doctor.ts issue bullets + log.success outro — equivalent shipped in v0.31.1

Kept (7 files, +201/-44)

FileChangeRationale
crates/aft/src/semantic_index.rspre_validate_onnx_runtime validates via LoadLibraryExW on Windows + updated install hintCatches missing/broken DLL before ort crate panics
crates/aft/src/commands/configure.rsfs::create_dir_all(storage_dir) during configureEnsures root exists before subsystems create subtrees
packages/aft-bridge/src/onnx-runtime.tsNuGet cache scan + %PATH% discovery + case-insensitive dedup + PATH-entry version-skipDiscovers ONNX from common Windows install locations
packages/aft-cli/src/lib/onnx.tsSame Win32 discovery for doctorMirror of bridge resolver for diagnostic output
packages/aft-bridge/src/downloader.tsunlinkSync before renameSync on WindowsFixes EEXIST crash on Windows file replacement
packages/aft-bridge/src/resolver.tsunlinkSync before renameSync in copyToVersionedCacheSame EEXIST fix for npm-platform-binary cache path
packages/aft-cli/src/lib/diagnostics.tsBest-effort mkdirSync for storage dirClearer doctor output on fresh installs

Verification

  • npx tsc --noEmit in packages/aft-bridge and packages/aft-cli — clean
  • cargo check --workspace --all-targets — clean
  • cargo clippy --workspace --all-targets --all-features -- -D warnings — clean

Summary by cubic

Improves Windows reliability: pre-validates and version-checks onnxruntime.dll, hardens ONNX discovery, and fixes file replacement crashes. Also ensures the storage directory exists during configure and diagnostics.

  • Bug Fixes

    • Windows: pre-validate and version-check onnxruntime.dll via LoadLibraryExW + GetFileVersionInfoW; clearer errors and stale DLL rejection; updated install hint with npx @cortexkit/aft doctor.
    • Windows: unlink before renameSync to prevent EEXIST when replacing binaries in downloader.ts and resolver.ts.
    • Ensure storage dir exists: create_dir_all in Rust configure; best‑effort mkdirSync in CLI diagnostics.
    • Security/CI: reuse pathEntriesForPlatform() in the bridge and require absolute PATH entries in the CLI; fix Windows build for format_ort_version_mismatch and Linux case‑sensitive path checks.
  • New Features

    • Windows ONNX discovery: scan NuGet cache (%USERPROFILE%\.nuget\packages\microsoft.ml.onnxruntime\...), common Program Files paths, and absolute %PATH%; case‑insensitive dedup; skip version checks for PATH entries while still filtering stale installs elsewhere.