wx-cli/src/cli
陈源泉 dab3217d3f
feat(biz): add wx biz-articles command to query public account messages (#33)
* feat(biz): add biz-articles command to query public account messages

加载 biz_message_0.db 提取公众号推送(标题/url/作者/时间)。

- daemon 端通过 DbCache 按需解密 biz_message_0.db(密钥已在 all_keys.json 中)
- 新增 IPC 变体 BizArticles(limit/account/since/until 参数)
- 新增 query 处理器 q_biz_articles:
  - 通过 Name2Id 反查 gh_* username → md5 → Msg_<hash> 表映射
  - 过滤 local_type & 0xFFFFFFFF = 49(appmsg 公众号文章)
  - zstd 解压 + extract_cdata 解析 <mmreader>/<item> XML
  - 支持多文章推送(一条消息含多篇文章)
  - 输出字段:time/timestamp/recv_time/account/account_username/title/url/digest/cover_url
- 新增 CLI 子命令 wx biz-articles,参数:-n / --account / --since / --until / --json
- 新增工具函数 extract_cdata(CDATA 块解析)和 parse_biz_xml_items
- 新增 8 个单测(biz_tests 模块)覆盖 CDATA 解析和多文章场景

支持工作流:
  wx biz-articles --since today --json | jq ".[].url" | xargs opencli weixin download

Verified: 返朴 ADHD 文章、Datawhale Claude Code 文章、土猛员外知识引擎文章均已正确提取。

* feat(biz-articles): add --unread filter (one latest article per account)

只列「有未读的公众号」的最近 1 篇文章 — 与 'wx unread --filter official'
行为一致,便于扫描"哪些公众号还有未读,标题是啥"。

- ipc.rs: BizArticles 加 unread: bool 字段(serde default = false 向后兼容)
- cli/mod.rs: --unread flag
- cli/biz_articles.rs: 透传 unread
- daemon/server.rs: dispatch 加 unread 参数
- daemon/query.rs: q_biz_articles
  - 开启 --unread 时先查 session.db 拿 unread_count>0 且
    chat_type==official_account 的 username 集合
  - 与 --account 取交集(两者都给时进一步缩小范围)
  - 空交集提前 return,避免无意义全表扫
  - 解析后按 pub_time DESC 排,每个 account_username 只保留首条
  - 最后再 truncate(limit)

* docs: PR draft - update --unread + --until usage

* chore(biz-articles): drop PR draft, document command, fix typo

- 删除 PR_DRAFT.md(误入 repo 的 PR 描述草稿,不该进 main)
- README.md / SKILL.md 补 biz-articles 用法
- query.rs: 密鑰 → 密钥

Co-authored-by: wx-cli-coder <coder@example.com>

---------

Co-authored-by: jackwener <jakevingoo@gmail.com>
Co-authored-by: wx-cli-coder <coder@example.com>
2026-05-14 16:07:39 +08:00
..
biz_articles.rs feat(biz): add wx biz-articles command to query public account messages (#33) 2026-05-14 16:07:39 +08:00
contacts.rs chore: Apache-2.0 license, Windows support, install.ps1 2026-04-16 22:30:45 +08:00
daemon_cmd.rs fix: replace macOS-only libc::__error() with std::io::Error::last_os_error() 2026-04-16 23:35:30 +08:00
export.rs chore: Apache-2.0 license, Windows support, install.ps1 2026-04-16 22:30:45 +08:00
favorites.rs chore: Apache-2.0 license, Windows support, install.ps1 2026-04-16 22:30:45 +08:00
history.rs chore: Apache-2.0 license, Windows support, install.ps1 2026-04-16 22:30:45 +08:00
init.rs fix(cli,config): 修复 sudo 下初始化失败 + daemon 不重载问题 (#37) 2026-05-14 13:50:04 +08:00
members.rs chore: Apache-2.0 license, Windows support, install.ps1 2026-04-16 22:30:45 +08:00
mod.rs feat(biz): add wx biz-articles command to query public account messages (#33) 2026-05-14 16:07:39 +08:00
new_messages.rs chore: Apache-2.0 license, Windows support, install.ps1 2026-04-16 22:30:45 +08:00
output.rs chore: Apache-2.0 license, Windows support, install.ps1 2026-04-16 22:30:45 +08:00
search.rs chore: Apache-2.0 license, Windows support, install.ps1 2026-04-16 22:30:45 +08:00
sessions.rs chore: Apache-2.0 license, Windows support, install.ps1 2026-04-16 22:30:45 +08:00
sns_feed.rs feat(sns): sns-notifications / sns-feed / sns-search (#14) 2026-04-19 01:58:21 +08:00
sns_notifications.rs feat(sns): sns-notifications / sns-feed / sns-search (#14) 2026-04-19 01:58:21 +08:00
sns_search.rs feat(sns): sns-notifications / sns-feed / sns-search (#14) 2026-04-19 01:58:21 +08:00
stats.rs chore: Apache-2.0 license, Windows support, install.ps1 2026-04-16 22:30:45 +08:00
transport.rs fix(cli,config): 修复 sudo 下初始化失败 + daemon 不重载问题 (#37) 2026-05-14 13:50:04 +08:00
unread.rs feat(unread): 按 chat_type 分类会话,新增 --filter (#9) 2026-04-18 01:59:35 +08:00