fix(windows): resolve Windows binary, ONNX, and storage bugs#65
fix(windows): resolve Windows binary, ONNX, and storage bugs#65Zireael wants to merge 2 commits into
Conversation
There was a problem hiding this comment.
6 issues found across 9 files
Prompt for AI agents (unresolved issues)
Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.
<file name="packages/aft-cli/src/lib/onnx.ts">
<violation number="1" location="packages/aft-cli/src/lib/onnx.ts:65">
P3: Path deduplication doesn't normalize internal separators, so Windows PATH entries like `C:/Program Files/onnxruntime/lib` and `C:\Program Files\onnxruntime\lib` won't be recognized as duplicates. Consider applying `path.normalize()` before lowercasing for more robust deduplication.</violation>
</file>
Tip: instead of fixing issues one by one fix them all with cubic
Re-trigger cubic
| // Deduplicate paths | ||
| const seen = new Set<string>(); | ||
| for (const dir of searchPaths) { | ||
| const normalized = dir.toLowerCase().replace(/[/\\]+$/, ""); |
There was a problem hiding this comment.
P3: Path deduplication doesn't normalize internal separators, so Windows PATH entries like C:/Program Files/onnxruntime/lib and C:\Program Files\onnxruntime\lib won't be recognized as duplicates. Consider applying path.normalize() before lowercasing for more robust deduplication.
Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At packages/aft-cli/src/lib/onnx.ts, line 65:
<comment>Path deduplication doesn't normalize internal separators, so Windows PATH entries like `C:/Program Files/onnxruntime/lib` and `C:\Program Files\onnxruntime\lib` won't be recognized as duplicates. Consider applying `path.normalize()` before lowercasing for more robust deduplication.</comment>
<file context>
@@ -31,15 +31,41 @@ export function getManualInstallHint(): string {
+ // Deduplicate paths
+ const seen = new Set<string>();
+ for (const dir of searchPaths) {
+ const normalized = dir.toLowerCase().replace(/[/\\]+$/, "");
+ if (seen.has(normalized)) continue;
+ seen.add(normalized);
</file context>
Closes cortexkit#64. Windows-specific fixes across the TypeScript and Rust layers: - **Binary version cache** (resolver.ts): add `findHighestCachedVersion()` to fall back to a newer cached binary when the exact plugin version isn't cached. - **Windows rename safety** (resolver.ts, downloader.ts): `unlinkSync` before `renameSync` to avoid `EEXIST` on Windows. - **ONNX Runtime detection** (onnx-runtime.ts, onnx.ts): search `%ProgramFiles%`, NuGet cache, and `%PATH%` directories for `onnxruntime.dll`. - **Storage directory** (opencode.ts): return `%LOCALAPPDATA%\cortexkit\aft` on Windows instead of falling through to the Unix path. - **Doctor output** (doctor.ts): issues summary section for actionable bullets; green `log.success()` instead of red `outro()` for the "looks good" message. - **Rust pre-validation** (semantic_index.rs): `pre_validate_onnx_runtime` now actually validates on Windows via `LoadLibraryExW` instead of being a no-op; `ONNX_RUNTIME_INSTALL_HINT` includes Windows guidance. - **Storage dir creation** (configure.rs): `fs::create_dir_all` in `handle_configure` so the root exists immediately after configure. - **Diagnostic robustness** (diagnostics.ts): best-effort `mkdirSync` in `diagnoseHarness` before reading storage subtrees. All Rust changes verified via `cargo check --workspace --all-targets` and `cargo clippy --workspace --all-targets --all-features -- -D warnings`.
9843233 to
f0a471c
Compare
…mination The JSDoc for findHighestCachedVersion contained the literal text 'v*/' which the TypeScript 6.0.3 tokenizer interprets as closing the multi-line comment, causing 62 cascading TS errors across the file. Replaced the glob pattern description with an explicit versioned-cache example that avoids the */ sequence.
|
Hey Zireael, thanks for taking time to send PRs for both projects. Sorry for the timing collision: we shipped a partial fix for #64 in v0.31.1 while this PR was open, which is why CI is now red. Message from AFT's agent: Could you rebase on the latest main (post-v0.31.1)? Once you do, several hunks will naturally drop out as already-shipped, and one section needs a small change to clear CI. Here's the breakdown:
Please drop (already shipped or conflicting):
Net after the trim should be ~150 LOC of focused Windows hardening across Rust validation, ONNX discovery, and file-replacement robustness — all CI-clean once rebased. Happy to merge once the rebase lands and the resolver hunk is resolved one way or the other. Thanks again for the careful work — the Windows ONNX detection in particular is a real improvement. |
Windows-specific fixes across the TypeScript and Rust layers for issue #64.
Binary resolution:
findHighestCachedVersion()in resolver.ts falls back to the highest cached binary when the exact plugin version isn't in cache — handlesaft doctor --fixdownloading a newer version.unlinkSyncbeforerenameSyncon Windows in both resolver.ts and downloader.ts to avoidEEXISTwhen the target already exists.ONNX Runtime detection (Windows):
findSystemOnnxRuntimein both onnx-runtime.ts and onnx.ts searches%ProgramFiles%, NuGet cache (%USERPROFILE%\.nuget\packages), and every%PATH%directory foronnxruntime.dll.Storage directory:
getStorageDir()in opencode.ts returns%LOCALAPPDATA%\cortexkit\aft(Windows) /~/.local/share/cortexkit/aft(Unix), matching the runtime path used by the AFT binary.Doctor CLI:
log.success("Everything looks good.")renders in green instead of the previous redoutro().Rust layer (verified via cargo check + clippy):
pre_validate_onnx_runtimeon Windows now actually validates viaLoadLibraryExW/FreeLibrary(raw kernel32 FFI, no crate deps) instead of being a no-op.ONNX_RUNTIME_INSTALL_HINTincludes Windows guidance +npx @cortexkit/aft doctorhint.fs::create_dir_all(storage_dir)inhandle_configureso the storage root exists immediately after configure.Diagnostics:
diagnoseHarnesscreates the storage directory on best-effort basis before reporting storage subtrees.All Rust changes verified via
cargo check --workspace --all-targetsandcargo clippy --workspace --all-targets --all-features -- -D warnings.Summary by cubic
Fixes Windows reliability across binary resolution, ONNX Runtime detection, and storage paths so
aft doctorand semantic search work as expected on Windows. Also improves diagnostics and ensures storage directories are created early.findHighestCachedVersion()that broke TypeScript 6.0.3 builds.%ProgramFiles%, NuGet cache, and all%PATH%dirs foronnxruntime.dll; skip version checks for PATH entries; dedupe paths; Rust pre-validation now loads the DLL viaLoadLibraryExWand updates the install hint.%LOCALAPPDATA%\cortexkit\afton Windows; create the storage root duringconfigure; doctor/diagnostics best-effort create the storage dir for clearer reports.Written for commit 70d677c. Summary will update on new commits. Review in cubic