fix(windows): keep Windows ONNX, storage, and file-replacement fixes
Merged
ZI
6mo ago+301+301+012345678901234567890123456789-44-44-01234567890123456789
Rebased on latest cortexkit/main (post-v0.31.1) per maintainer review.
Dropped (shipped in v0.31.1 or conflicting)
findHighestCachedVersion+compareSemverinresolver.ts— superseded by v0.31.1 skew detectionopencode.tsgetStorageDirrewrite — upstream already routes throughgetCortexKitStorageRootdoctor.tsissue bullets +log.successoutro — equivalent shipped in v0.31.1
Kept (7 files, +201/-44)
| File | Change | Rationale |
|---|---|---|
crates/aft/src/semantic_index.rs | pre_validate_onnx_runtime validates via LoadLibraryExW on Windows + updated install hint | Catches missing/broken DLL before ort crate panics |
crates/aft/src/commands/configure.rs | fs::create_dir_all(storage_dir) during configure | Ensures root exists before subsystems create subtrees |
packages/aft-bridge/src/onnx-runtime.ts | NuGet cache scan + %PATH% discovery + case-insensitive dedup + PATH-entry version-skip | Discovers ONNX from common Windows install locations |
packages/aft-cli/src/lib/onnx.ts | Same Win32 discovery for doctor | Mirror of bridge resolver for diagnostic output |
packages/aft-bridge/src/downloader.ts | unlinkSync before renameSync on Windows | Fixes EEXIST crash on Windows file replacement |
packages/aft-bridge/src/resolver.ts | unlinkSync before renameSync in copyToVersionedCache | Same EEXIST fix for npm-platform-binary cache path |
packages/aft-cli/src/lib/diagnostics.ts | Best-effort mkdirSync for storage dir | Clearer doctor output on fresh installs |
Verification
npx tsc --noEmitinpackages/aft-bridgeandpackages/aft-cli— cleancargo check --workspace --all-targets— cleancargo 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.dllviaLoadLibraryExW+GetFileVersionInfoW; clearer errors and stale DLL rejection; updated install hint withnpx @cortexkit/aft doctor. - Windows: unlink before
renameSyncto prevent EEXIST when replacing binaries indownloader.tsandresolver.ts. - Ensure storage dir exists:
create_dir_allin Rust configure; best‑effortmkdirSyncin CLI diagnostics. - Security/CI: reuse
pathEntriesForPlatform()in the bridge and require absolute PATH entries in the CLI; fix Windows build forformat_ort_version_mismatchand Linux case‑sensitive path checks.
- Windows: pre-validate and version-check
-
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.
- Windows ONNX discovery: scan NuGet cache (