Skip to content

kbot v4.2 Windows compatibility — 46 test failures across bash/files/git/plugins/forecast tools #42

@isaacsight

Description

@isaacsight

Summary

First time the kbot test suite ran on real Windows (Windows 11 Home, build 26200, Node 24.15.0, Acer Swift worker over Tailscale SSH). Of 1370 tests, 46 failed — all Windows-specific. Root causes cluster into two buckets: hardcoded forward-slash path splits, and Unix-only shell-outs.

This issue tracks the full picture and proposes a kbot v4.2 Windows-compat sprint. Five fixes already landed in main (see Fixed in this pass below); three real product-level gaps remain.

Fixed in this pass

# File Bug Fix
1 packages/kbot/src/tools/forecast-summary.ts:63 path.substring(0, path.lastIndexOf('/')) — crashes with ENOENT: mkdir '' on Windows because NTFS paths use \ dirname(path) from node:path
2 packages/kbot/src/train-curate.ts:263 Same hardcoded '/' split Same
3 packages/kbot/src/tools/security-audit-local.test.ts:28 Same pattern in a test helper Same
4 packages/kbot/src/plugins.ts:222 POSIX mode check (fileStat.mode & 0o022) !== 0 rejects every plugin on Windows — NTFS has no POSIX mode bits, Node fills mode with synthetic always-writable values Wrap in if (process.platform !== 'win32')
5 packages/kbot/src/plugin-sdk.ts:394 Same POSIX check on directories Same

After these, the plugins, plugin-sdk, forecast-summary, security-audit-local, and train-curate failures should clear. 26 of 46 failures attributable to these five lines.

Still open — proposed v4.2 sprint

1. bash tool — 8 of 27 tests fail (packages/kbot/src/tools/bash.ts)

Tool shells out to sh / Unix utilities. No sh on stock Windows; entire tool is non-functional. Test errors:

Error: Command failed: rm newfile.txt
Error: Command failed: git checkout master 2>/dev/null || git checkout main 2>/dev/null

Proposed fix: platform detection + dual implementation:

  • Windows: route through cmd.exe for simple commands, surface a clear error for Unix-isms
  • Better: implement a Node-native subset (rm/ls/cat/mkdir) that works identically on all platforms, fall back to platform shell only for genuinely shell-only operations

2. File tools — 3 of 34 tests fail (packages/kbot/src/tools/files.ts)

glob, grep, list_directory shell out to Unix tools. list_directory returns Error: Cannot list directory on Windows.

Proposed fix: pure-Node implementations:

  • globfast-glob (already a transitive dep in most setups) or globby
  • grepreaddirSync + readFileSync + JS regex
  • list_directoryreaddirSync with withFileTypes: true

All three are 20-50 line implementations and remove the shell-out attack surface entirely.

3. git tool — 6 fails (packages/kbot/src/tools/git.ts)

Commands constructed with Unix idioms: rm newfile.txt, || fallbacks, 2>/dev/null redirects. None of these work in cmd.exe.

Proposed fix:

  • Use execFile (no shell) instead of exec/spawn with shell: true
  • Replace 2>/dev/null with stdio: ['pipe', 'pipe', 'ignore']
  • Replace cmd1 || cmd2 with JS try/catch
  • File ops (rm newfile.txt) → fs.unlinkSync

4. computer-use tool — platform-gated to non-Windows (packages/kbot/src/tools/computer.ts)

Error: Computer use is only supported on macOS and Linux.

Hard-coded refusal. Track as a feature gap, not a regression. Filling it later (Playwright or nut.js could be the backend on Windows; Peekaboo is macOS-only) is worth its own issue but doesn't belong in v4.2.

How to reproduce

# On the Windows worker
cd C:\Users\isaac\kernel
git pull
npx vitest run

For one bucket at a time:

npx vitest run packages/kbot/src/tools/bash.test.ts
npx vitest run packages/kbot/src/tools/files.test.ts
npx vitest run packages/kbot/src/tools/git.test.ts

Test environment

  • Windows 11 Home, build 26200, x64
  • Node.js v24.15.0, npm v11.12.1
  • Vitest v4.1.0
  • Git 2.54.0.windows.1
  • All deps clean-installed (npm install post-git clone)
  • 1324 passed / 46 failed / 1370 total — 96.6% pass rate
  • Wall time: 41s tests + ~7min setup/transform/import

Why this matters

kbot is npm-distributed and MIT — there's no Windows install-base warning. Every Windows user has been silently hitting the plugin-loader bug (no plugins ever load) and the path bug (forecast/train tools crash). Cross-platform validation went from "wishful" to "verified" in under an hour once a Windows worker existed.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions