This document covers the Windows-specific implementation details for crush-acp, particularly where behavior differs from macOS/Linux.
When crush runs in Zed on Windows, it uses SQLite for session data. Under certain conditions (process crash, forceful termination, or stdout/stderr pipe issues), the SQLite WAL (Write-Ahead Log) file can become out of sync with the main database, causing:
database disk image is malformed (11)
crush-acp uses two strategies:
-
Isolated data directory — Zed and TUI crush use separate
--data-dirpaths to avoid database conflicts:- Zed:
%APPDATA%\.crush-acp\zed-crush\ - TUI: crush's default location
- Zed:
-
WAL-only cleanup — Before each prompt, only the WAL and SHM files are removed. The main
crush.dbis kept intact so session continuity works.
Deleting crush.db would break session continuity — each prompt would start a completely fresh conversation. By cleaning only WAL/SHM, we:
- Remove corruption-prone files
- Preserve existing sessions
- Allow crush to continue the same conversation
| Purpose | Path |
|---|---|
| crush-acp sessions | %APPDATA%\.crush-acp\sessions\sessions.json |
| Zed crush isolated DB | %APPDATA%\.crush-acp\zed-crush\ |
| crush config | %LOCALAPPDATA%\crush\crush.json |
| crush logs | %APPDATA%\.crush\logs\ |
- Uses
spawn()from Node.js withstdio: ["ignore", "pipe", "pipe"] ignoreon stdin prevents TTY detection issues- Working directory set to
session.workingDirfrom Zed
- The WAL file may be left in an inconsistent state
- Next run triggers "database disk image is malformed"
- Fix: delete
crush.db-walandcrush.db-shmin the data directory
Remove-Item "$env:APPDATA\.crush-acp\zed-crush\crush.db-wal"
Remove-Item "$env:APPDATA\.crush-acp\zed-crush\crush.db-shm"On Windows, crush reads its config from:
%LOCALAPPDATA%\crush\crush.json(primary)%APPDATA%\crush\crush.json(fallback)
The adapter reads from both paths to detect configured providers.
Session configs (model, mode, thinking, yolo settings) are persisted to:
%APPDATA%\.crush-acp\sessions\sessions.json
This is independent of crush's own session storage and survives across crush-acp restarts.
| Aspect | macOS/Linux | Windows |
|---|---|---|
| Config location | ~/.config/crush/crush.json |
%LOCALAPPDATA%\crush\crush.json |
| Data directory | ~/.crush/ |
%APPDATA%\.crush\ |
| Session path | ~/.crush/sessions/ |
Same structure |
| WAL corruption | Rare | More common due to process handling |
| Working dir | TUI cwd | session.workingDir from Zed |
To diagnose issues on Windows:
- ACP logs:
Ctrl+Shift+P→dev: open acp logs - crush-acp stderr: Check Zed's output pane for
[crush-acp]prefixed logs - crush logs:
%APPDATA%\.crush\logs\crush.log - Manual config test: Run
crush modelsin PowerShell/CMD to verify API keys work