Environment
- OS: Windows 11 + WSL2 (Ubuntu)
- WeChat Version: xwechat (new WeChat desktop, not legacy WeChat)
- wx-cli Version: 0.3.0
- Install Method: npm install -g @jackwener/wx-cli
Data Directory Structure
The new xwechat stores data at:
C:\Users\zexin\Documents\xwechat_files\
├── Backup/
├── WMPF/
├── all_users/
├── kenny_blog_ba4b/
├── wxid_3vmmyby98la022_906b/
│ ├── db_storage/
│ │ ├── message/
│ │ │ ├── biz_message_0.db
│ │ │ ├── media_0.db
│ │ │ ├── message_0.db
│ │ │ ├── message_1.db
│ │ │ └── ...
│ │ ├── contact/
│ │ ├── favorite/
│ │ └── ...
│ ├── msg/
│ └── resource/
└── wxid_lcdlrizly9bj02_7c92/
└── ...
Problem
1. wx init fails with auto-detection error
$ wx init
检测微信数据目录...
错误: 未能自动检测到微信数据目录
请手动编辑 config.json 中的 db_dir 字段
Even after manually creating config.json with the correct db_dir:
{"db_dir":"C:\\Users\\zexin\\Documents\\xwechat_files\\wxid_3vmmyby98la022_906b"}
wx init still fails with the same auto-detection error. It seems wx init ignores the db_dir config and always tries auto-detection first.
2. Other commands fail due to missing all_keys.json
$ wx sessions
启动 wx-daemon...
错误: wx-daemon 启动超时(>15s)
Daemon log shows:
[daemon] DB_DIR: C:\Users\zexin\Documents\xwechat_files\wxid_3vmmyby98la022_906b
[daemon] 启动失败: 读取密钥文件 "C:\\Users\\zexin\\.wx-cli\\all_keys.json" 失败: 系统找不到指定的文件。 (os error 2)
Expected Behavior
wx init should recognize xwechat data directory structure (xwechat_files/wxid_*_*/db_storage)
- OR
wx init should use db_dir from config.json when auto-detection fails
- OR provide a
--db-dir CLI flag to manually specify the data directory
Workarounds Tried
- ✅ Created
config.json with correct db_dir — ignored by wx init
- ❌ Tried
WX_CLI_DB_DIR environment variable — not supported
- ❌ Tried
wx init --force — same auto-detection error
Suggested Fix
Option A: Add xwechat path patterns to auto-detection:
%USERPROFILE%\Documents\xwechat_files\wxid_*
%USERPROFILE%\Documents\xwechat_files\*\db_storage
Option B: Make wx init fall back to db_dir from config.json when auto-detection fails
Option C: Add --db-dir CLI argument to wx init
Additional Context
The legacy WeChat path (WeChat Files/wxid_*/Msg) works fine, but the new xwechat uses a completely different structure:
- Root:
xwechat_files instead of WeChat Files
- Account dirs:
wxid_*_xxxx (with suffix) instead of wxid_*
- Database location:
db_storage/message/ instead of Msg/
Environment
Data Directory Structure
The new xwechat stores data at:
Problem
1.
wx initfails with auto-detection errorEven after manually creating
config.jsonwith the correctdb_dir:{"db_dir":"C:\\Users\\zexin\\Documents\\xwechat_files\\wxid_3vmmyby98la022_906b"}wx initstill fails with the same auto-detection error. It seemswx initignores thedb_dirconfig and always tries auto-detection first.2. Other commands fail due to missing
all_keys.json$ wx sessions 启动 wx-daemon... 错误: wx-daemon 启动超时(>15s)Daemon log shows:
Expected Behavior
wx initshould recognize xwechat data directory structure (xwechat_files/wxid_*_*/db_storage)wx initshould usedb_dirfromconfig.jsonwhen auto-detection fails--db-dirCLI flag to manually specify the data directoryWorkarounds Tried
config.jsonwith correctdb_dir— ignored bywx initWX_CLI_DB_DIRenvironment variable — not supportedwx init --force— same auto-detection errorSuggested Fix
Option A: Add xwechat path patterns to auto-detection:
%USERPROFILE%\Documents\xwechat_files\wxid_*%USERPROFILE%\Documents\xwechat_files\*\db_storageOption B: Make
wx initfall back todb_dirfromconfig.jsonwhen auto-detection failsOption C: Add
--db-dirCLI argument towx initAdditional Context
The legacy WeChat path (
WeChat Files/wxid_*/Msg) works fine, but the new xwechat uses a completely different structure:xwechat_filesinstead ofWeChat Fileswxid_*_xxxx(with suffix) instead ofwxid_*db_storage/message/instead ofMsg/