David Li
3afb88920c
merge: resolve and finalize branch jw
2026-05-15 00:16:42 +08:00
jakevin
70aa3a44e3
fix(daemon,scanner,crypto): harden lifecycle, widen Windows page scan, fix SQLCipher short read ( #54 )
...
- daemon: write pid file only after IPC bound; clean sock+pid on normal return
- transport: PidFile JSON metadata + identity verification (ps/QueryFullProcessImageNameW); SIGTERM with poll-timeout; backward-compat read for plain-text pid
- daemon_cmd: status/stop work with both new JSON and legacy plain-text pid file
- config: cwd → exe_dir → ~/.wx-cli config precedence matches `wx init` write order; Windows DB auto-detect picks newest by latest mtime
- crypto: full_decrypt uses read_exact for intermediate pages, zero-pads only the final partial page; tests cover short-chunk reads and early EOF
- scanner/windows: page protect check covers PAGE_READWRITE / PAGE_WRITECOPY / PAGE_EXECUTE_*WRITE* with modifier-bit stripping
Cross-reviewed by @wx-cli-coder. Windows verified via `cargo check --target x86_64-pc-windows-gnu` (no Windows runtime test).
2026-05-14 17:11:42 +08:00
David Li
521c6296b6
fix: unterminated char literal and missing cli_dir in start_daemon
...
- Fix '\'' -> '\\' in src/daemon/mod.rs (lines 85, 151)
- Replace undefined preflight_cli_dir_writable() with inline
config::cli_dir() creation check in src/cli/transport.rs
2026-05-13 17:27:08 +08:00
David Li
107af74a72
chore: auto-commit after quick-task
...
GSD-Unit: Q3
2026-05-13 17:19:09 +08:00
David Li
3d0dd9b8b9
feat: migrate from eprintln! to tracing for structured logging
...
- Add tracing + tracing-subscriber dependencies
- Initialize tracing in main() with env-filter (RUST_LOG support)
- Replace all eprintln! diagnostic messages with tracing macros:
- info! for lifecycle events (daemon startup, cache hits, scan progress)
- warn! for non-fatal errors (skipped DBs, scan limits, connection errors)
- error! for fatal errors (daemon startup failure)
- debug! for cache hits (hidden behind RUST_LOG=debug)
- Add #[tracing::instrument] to key paths:
- daemon::start_daemon — automatic startup timing
- query::{sessions, history, search, new_messages} — per-query timing
- crypto::full_decrypt — per-decrypt timing with page count
- Keep println! for user-facing CLI output (YAML/JSON, status messages)
- Keep eprintln! for test output and CLI progress indicators
2026-05-13 16:08:48 +08:00
David Li
1f7b843a1a
feat: Wired transport module into daemon server, added TCP listening al…
...
- src/daemon/server.rs
- src/daemon/mod.rs
- src/cli/daemon_cmd.rs
- src/cli/mod.rs
GSD context:
- Milestone: M001 - TCP Transport
- Slice: S01
- Task: T02 - Wired transport module into daemon server, added TCP listening alongside local transport, and implemented `wx daemon start [--tcp ADDR]` subcommand
GSD-Task: S01/T02
2026-05-13 13:57:12 +08:00
JL
e8939f315d
feat(sns): sns-notifications / sns-feed / sns-search ( #14 )
...
新增 3 个朋友圈相关命令:sns-notifications / sns-feed / sns-search。
PR review 修复(已 push 进同一分支):
- 修 --user 过滤与 XML <username> fallback 打架的 bug(@wx-cli-codex 发现)
- 加 SNS_MAX_LIMIT / SNS_MAX_SCAN 防御性上限
- 抽 escape_like_pattern() helper
- 补 8 个单测(parse_post_xml / escape_like_pattern)
Cargo check 三 target 全过:aarch64-darwin / x86_64-pc-windows-gnu / x86_64-unknown-linux-gnu。
Co-authored-by: fengliu222 <fengliu222@users.noreply.github.com>
2026-04-19 01:58:21 +08:00
jackwener
1e52014a6b
perf(daemon): Arc<Names> + tokio RwLock, O(1) clone per IPC request
...
Was: Arc<std::sync::RwLock<Names>>; each dispatch clone_names() copied
4 HashMaps (~100KB for a user with 2700 contacts) and used std RwLock
which blocks the tokio worker thread during the clone.
Now: Arc<tokio::sync::RwLock<Arc<Names>>>; dispatch takes the read
guard, does Arc::clone (pointer bump), drops the guard, then spawns
the query work. Names is immutable after daemon startup; Arc is ideal.
Smoke tested: `wx sessions --json` returns correct data including
chat_type; 8 concurrent clients finish in 12ms.
2026-04-18 02:10:45 +08:00
JL
e977007306
feat(unread): 按 chat_type 分类会话,新增 --filter ( #9 )
...
Before: wx unread / sessions / history 把公众号、订阅号折叠入口
(brandsessionholder)、折叠群聊(@placeholder_foldgroup)、认证服务号
全归为 is_group=false,与真私聊混在一起。甚至 username 形如 wxid_* 但
实为公众号的条目也完全分不出来。
改动:
- 新增 chat_type_of(username, names) helper,输出固定为
group / official_account / folded / private。
- 判据依次:@chatroom → group;brandsessionholder / @placeholder_foldgroup
→ folded;contact.verify_flag != 0 → official_account(覆盖 wxid_*
伪装为公众号的情况,以及银行/品牌服务号、qqsafe / mphelper 等认证账号);
gh_* / biz_* / @* 前缀兜底;其余为 private。
- load_names 顺带读 contact.verify_flag,Names::is_verified 封装查询。
- q_sessions / q_unread / q_history / q_new_messages / q_stats 输出
新增 chat_type 字段,is_group 保留向后兼容并统一由 chat_type 派生。
- wx unread 新增 --filter,clap value_parser 限制可选值为
all / private / group / official / folded,逗号分隔多选,默认 all。
例:wx unread --filter private,group 可过滤公众号与折叠入口。
- SKILL.md / README.md 补充新字段与用法说明。
- .gitignore 补 target/(Rust 项目标配)。
性能:默认 wx unread 的 SQL 与改动前相同(保留 LIMIT)。仅当传入
--filter 时改为全表扫再 Rust 侧过滤,否则 SQL LIMIT 会先把匹配
filter 的条目截断导致漏召。
2026-04-18 01:59:35 +08:00
jackwener
6cdc806642
chore: Apache-2.0 license, Windows support, install.ps1
2026-04-16 22:30:45 +08:00
jackwener
7f869e7c3b
fix: 深度 review 修复 10 个 bug/问题
...
Critical & High:
- daemon 日志:启动时将 stdout/stderr 重定向到 ~/.wx-cli/daemon.log
而非 /dev/null,使 wx daemon logs 真正可用
- q_history 找不到聊天时改为 bail! 而非 ok:true+error 字段,
避免 CLI 静默返回空输出
- init 写 config.json 默认路径改为 ~/.wx-cli/config.json,
避免写入系统 bin 目录(/usr/local/bin/config.json)
- LIKE 通配符:搜索关键词中的 %/_/\ 现在正确转义
- WAL 路径:改用 OsString.push 拼接 "-wal" 后缀,
避免 display() 在非 UTF-8 路径上失效
- cmd_stop:检查 kill() 返回值,ESRCH 时给出明确提示
Performance & Code quality:
- full_decrypt:改为流式逐页读写,峰值内存从 2×文件大小降为 O(1)
- Regex:msg_table_re() 用 OnceLock 静态编译,避免热路径重复编译
- mtime_nanos:消除 daemon/mod.rs 与 cache.rs 的重复定义
- use super::super::cli::transport → use super::transport
- 删除未使用的 save_config、Request::to_json_line 死代码
2026-04-16 17:07:15 +08:00
jackwener
2fd864b85d
fix: 修复消息内容为空的 bug(TEXT/BLOB 兼容),过滤 fts/resource DB,超时调为 120s
2026-04-16 16:16:41 +08:00
jackwener
8bfea8869e
fix: 修复全部 medium/low 优先级问题
...
- cache/daemon: mtime 比较从 f64(secs) 改为 u64(nanos),避免浮点误差丢失变更
- transport: Unix 启动 daemon 前调用 setsid(),使其脱离控制终端防止 SIGHUP
- daemon/mod: 删除对已废弃 watcher 模块的引用
- watcher.rs: 删除全量死代码文件(功能已内联至 daemon/mod.rs)
- query: find_msg_tables 实际按 max_ts 降序排序(原注释有排序但无实现)
- scanner: 移除三平台 scan_memory 中的 dedup_by(search_pattern 已全局去重)
- watch: Windows 平台返回明确错误而非静默失败
- CI: cargo build 增加 --locked 确保使用 Cargo.lock 版本
2026-04-16 15:12:33 +08:00
jackwener
d475f6219b
feat: Rust 完整重写 wx-cli(单一二进制,支持 macOS/Linux/Windows)
...
实现所有核心模块:
- src/crypto/: SQLCipher 4 页解密 + WAL 应用(AES-256-CBC)
- src/scanner/: 三平台内存扫描(macOS Mach VM / Linux /proc/mem / Windows ReadProcessMemory)
- src/daemon/: tokio 异步 daemon,Unix socket IPC,mtime-aware DB 缓存,WAL 监听推送
- src/cli/: clap CLI,自动启动 daemon,完整命令实现
- src/config.rs: 跨平台配置加载,兼容 Python 版 config.json 格式
- src/ipc.rs: 换行符分隔 JSON 协议,与 Python 版兼容
- .github/workflows/release.yml: 四平台自动构建发布
cargo build --release 验证通过,生成 4.8MB macOS arm64 单一二进制
2026-04-16 14:37:10 +08:00