@haoxu/cli
v1.20.0
Published
号续 Agent Bridge CLI — 供各类 Agent(Cursor / Claude Code / Codex / WorkBuddy / Trae 等)查询与维护本机号续数据
Maintainers
Readme
@haoxu/cli(号续 CLI)
通过本机 Agent Bridge 查询号续数据:账号统计、稿件、存稿任务、发表任务、分组、标签、代理 IP、稿件分类、员工(主账号),以及公众号远端草稿箱与发表记录。0.4.0 起支持账号元数据写操作(号主/备注、移组、设标签、分组/标签 CRUD)。0.5.0 起支持代理写操作(代理库 CRUD/绑定/检测/Excel 导入、异步 Job)。0.6.0 起支持统计刷新、账号检测(非代理检测)与未读刷新。0.7.0 起支持本机路径(含 zip)与公众号链接导入稿件。0.8.0 起支持存稿 create/start/cancel/delete 与发表 from-batch-draft / start / start-batch / start-all-pending。0.9.0 起支持单篇稿件设封面(本机路径 / URL / 清除)。1.0.0 起支持公众号面板远端写(删草稿、草稿另存、已发表改私密、素材库 list/上传/删图)。1.4.0 起支持单独导出账号 Cookie(须 cookieExport 权限)。1.5.0 起支持 Cookie 导入添加账号(accounts import-cookie)。1.7.0 起支持单篇稿件设摘要(--text / --clear)及 list --summary 筛选。1.8.0 起支持稿件正文样式读写(typography / set-typography,单篇或 --ids 批量)。1.9.0 起 import-paths 支持 --strip-image-metadata(导入时剔除正文图片的 AI 元信息)。1.10.0 起支持从正文图片设封面(body-images 列出正文图片,set-cover --body-image <n>)。1.11.0 起 accounts cookie 支持 --format json(比特浏览器可导入的 JSON 数组)。1.12.0 起支持删除本地稿件(manuscripts delete,单篇或 --ids 批量,须 --confirm)。1.13.0 起支持存稿 create-split(按固定篇数 / 随机范围 / chunkSizes 拆成多条任务;旧 create 仍是单任务、不拆分)。1.14.0 起支持单账号全量数据刷新(accounts refresh <id>,统计 + 未读一次调用)。1.15.0 起支持稿件排版主题(manuscripts themes / set-theme,单篇或 --ids 批量,导入支持 --theme;与手动正文样式互斥)。1.16.0 起支持存稿一键排版配置(draft-tasks create / create-split 的 --layout-mode keep|standard|thin,存稿成功后后台执行官方一键排版,贴图强制 keep,排版失败不影响存稿结果)。
供各类 AI Agent 调用(Cursor、Claude Code、Codex、WorkBuddy、QoderWork、QClaw、OpenClaw、Trae 等;凡能执行终端命令即可)。
前置: 必须安装并运行 号续桌面端(含 Agent Bridge 能力),在设置中启用 Agent Bridge 并生成 API Key。CLI 不能单独访问云端数据。查远端草稿/发表还需目标账号在线且已登录公众平台。稿件路径导入须本机绝对路径,号续与 Agent 同机;不支持飞书。
当前版本:1.20.0
安装
需要 Node.js 18+。
npm install -g @haoxu/[email protected]
# 或
npx @haoxu/[email protected] --help安装后全局命令为 haoxu。
快速开始
完整小白教程(含让 Agent 代装):号续仓库 Desktop/docs/agent/haoxu-agent-guide.md §1–§2。
- (推荐)安装 Agent Skill:
npx skills add montisan/skills --skill haoxu-agent -y -g - 安装本 CLI:
npm install -g @haoxu/[email protected] - 打开号续 → 设置 → Agent Bridge → 启用 → 生成并复制 API Key(主账号与子账号均可;Key 本机共用)
- 配置 CLI:
haoxu auth set-key
haoxu auth status --json- 查询示例:
haoxu accounts list --json
haoxu manuscripts list --assigned unassigned --json
haoxu draft-tasks list --status completed --completed today --json
haoxu publish-tasks list --status scheduled --json
haoxu groups list --json
haoxu tags list --json
haoxu ip-proxies list --status healthy --json
haoxu categories list --json
haoxu employees list --json # 仅主账号导出账号 Cookie(1.4.0)
accounts list|get 不返回 cookie;需要时用独立命令 accounts cookie,且当前登录用户须有 cookieExport 权限(员工账号看主账号的权限)。无权限返回 403 FORBIDDEN;账号未在号续内登录、取不到 CK 时返回 503 ACCOUNT_NOT_READY。
haoxu accounts cookie <id> --json
# → { "accountId": "...", "wxid": "...", "name": "...", "cookie": "slave_sid=...; ..." }
haoxu accounts cookie <id> --format json > cookie.json
# → [{ "name": "slave_sid", "value": "...", "domain": "mp.weixin.qq.com", "path": "/" }, ...]1.11.0 起 --format json 输出比特浏览器等指纹浏览器可直接导入的 JSON 数组(与桌面端「导出 CK(JSON)」同格式;库里只存 Cookie 头,domain 统一为 mp.weixin.qq.com、path 为 /),重定向到文件即可导入;此时忽略 --json。
Cookie 属敏感凭证,取到后请勿写入日志、仓库或转发给第三方。
Cookie 导入添加账号(1.5.0)
与桌面端「添加账号 → Cookie 导入」同一条链路:注入 Cookie → 校验登录态 → 从公众平台拉回 wxid / 名称 / 类型 → 入库并接管登录态延续。wxid、名称、类型无须传入。
# 直连
haoxu accounts import-cookie --cookie-file ./ck.txt --json
# 指定分组 + 代理库节点
haoxu accounts import-cookie --cookie-file ./ck.txt \
--group <groupId> --mode managed --ip-proxy-id <ipProxyId> --json
# 自定义代理(不入代理库,直接嵌到账号上),--payload-file 内容形如
# { "host": "1.2.3.4", "port": 1080, "type": "SOCKS5", "username": "u", "password": "p" }
haoxu accounts import-cookie --cookie-file ./ck.txt --mode custom --payload-file ./proxy.json --json| 参数 | 说明 |
|------|------|
| --cookie-file / --cookie | 二选一。支持标准 Cookie 头、JSON、Netscape 等格式,自动识别。长 Cookie 建议用文件 |
| --group | 分组 ID;省略或 ungrouped 表示未分组。员工账号通常必须指定 |
| --owner | 号主,可选 |
| --mode | direct(默认,本地直连)/ managed(配 --ip-proxy-id)/ custom(配 --payload-file) |
失败返回:账号数超限或未开通会员 403 FORBIDDEN;号续内正在添加账号(添加账号窗口开着 / 扫码未结束)或已有导入在跑 409 CONFLICT;Cookie 失效 401 REMOTE_UNAUTHORIZED。
一次只能导入一个账号,无批量接口;多账号请串行调用,遇
409稍后重试。
账号元数据写操作(0.4.0)
# 修改号主/备注
haoxu accounts patch <id> --owner 张三 --json
# 移组
haoxu accounts move-group <id> --group <groupId|ungrouped> --json
# 设标签(全量替换)
haoxu accounts set-tags <id> --tags t1,t2 --json
# 分组/标签 CRUD(删除须 --confirm)
haoxu groups create --name 新分组 --json
haoxu groups delete <id> --confirm --json
haoxu tags create --name 新标签 --json
haoxu tags delete <id> --confirm --json移组、分组 CRUD 仅主账号;员工可改可见账号的号主/备注与标签(须会员额度)。详见包内 Skill 权限表。
代理写操作(0.5.0)
# 代理 CRUD(删除须 --confirm)
haoxu ip-proxies create --host 1.2.3.4 --port 1080 --type socks5 --json
haoxu ip-proxies test <id> --json
haoxu ip-proxies delete <id> --confirm --json
# Excel 导入(异步,返回 jobId)
haoxu ip-proxies import --file ./proxies.xlsx --json
haoxu jobs get <jobId> --json
# 账号绑定 / 代理检测
haoxu accounts bind-proxy --accounts a1 --mode managed --ip-proxy-id <id> --json
haoxu accounts proxy-detect <accountId> --json
haoxu accounts proxy-detect-batch --accounts a1,a2 --poll --json
# 无库连通性 test
haoxu proxy test --host 1.2.3.4 --port 1080 --type socks5 --jsonExcel 导入与批量代理检测为异步 Job(内存存储,号续重启后丢失;完成后约 1h TTL)。--poll 自动轮询 Job 至 completed/failed。
统计刷新 / 账号检测 / 未读(0.6.0)
查统计仍用 accounts list|get。账号检测(detect)≠ 代理检测(proxy-detect)。
# 单账号全量刷新(统计 + 未读,一次调用;1.14.0)
haoxu accounts refresh <id> [--no-force] --json
# 单账号 / 批量统计刷新
haoxu accounts refresh-metrics <id> [--no-force] --json
haoxu accounts refresh-metrics-batch [--accounts a1,a2] [--poll] --json
# 单账号 / 批量账号检测
haoxu accounts detect <id> [--no-force] --json
haoxu accounts detect-batch [--accounts a1,a2] [--poll] --json
# 单账号 / 批量未读刷新
haoxu accounts refresh-unread <id> [--no-force] --json
haoxu accounts refresh-unread-batch [--accounts a1,a2] [--poll] --json批量省略 --accounts 时处理全部可见可刷新账号。默认 force: true;--no-force 仅刷新符合自动策略的账号。accounts refresh 是单账号全量刷新(内部等价于 refresh-metrics 后接 refresh-unread,统计被 skip_auto 跳过仍会刷未读)。
稿件导入(0.7.0)
路径须为本机绝对路径;号续与 Agent 同机。同步返回 { imported, errors }。不支持飞书。--strip-duplicate-title 剔除与标题重复的正文首行;--strip-image-metadata(1.9.0)剔除正文图片的 EXIF / XMP / IPTC / C2PA 等 AI 元信息。两者均仅 import-paths 可用。--theme <themeId>(1.15.0)导入时直接套用排版主题,两个导入命令都支持。
haoxu manuscripts import-paths --paths /abs/a.docx,/abs/b.zip [--category <id>] [--theme <themeId>] [--strip-duplicate-title] [--strip-image-metadata] --json
haoxu manuscripts import-links --urls https://mp.weixin.qq.com/s/xxx [--category <id>] [--theme <themeId>] --json单篇稿件设封面(0.9.0;正文图片 1.10.0)
--file / --url / --body-image / --clear 互斥;本机路径须绝对路径,号续与 Agent 同机可读(与 import-paths 相同约束)。成功返回 { coverUrl: string | null }。
1.10.0 起可从正文图片中选一张作封面:先 body-images 列出正文图片(按出现顺序去重,index 从 1 起;kind 为 local 本地素材或 url 网络图片),再 --body-image <n>。本地素材会复制一份作封面,网络图片直接作封面 URL;--strip-image-metadata 对 --file 与本地素材生效。
haoxu manuscripts set-cover <id> --file /abs/cover.jpg --json
haoxu manuscripts set-cover <id> --url https://example.com/cover.png --json
haoxu manuscripts body-images <id> --json
haoxu manuscripts set-cover <id> --body-image 2 --json
haoxu manuscripts set-cover <id> --clear --json单篇稿件设原文链接(1.2.0)
--url / --clear 互斥。成功返回 { sourceUrl: string | null }。无批量 API,循环调用即可。
haoxu manuscripts set-source-url <id> --url https://example.com/article --json
haoxu manuscripts set-source-url <id> --clear --json
haoxu manuscripts list --source-url unset --json单篇稿件设摘要(1.7.0)
--text / --clear 互斥。成功返回 { summary: string | null }。摘要最长约 120 字。链接导入自动带入摘要;md front-matter 可带 title / summary。无批量 API。list 可用 --summary all|set|unset 筛选。
haoxu manuscripts set-summary <id> --text 短摘要 --json
haoxu manuscripts set-summary <id> --clear --json
haoxu manuscripts list --summary unset --json删除本地稿件(1.12.0)
删除号续本地稿件库中的稿件(含导入稿),并删除对应素材目录。须 --confirm。单篇用位置参数,多篇用 --ids(二者互斥)。与桌面端一致:若稿件还挂在未完成的存稿任务上,对应任务明细会标为「稿件已删除」。单篇不存在返回 404;批量返回 { deleted, missing }。
haoxu manuscripts delete <稿件ID> --confirm --json
haoxu manuscripts delete --ids m1,m2 --confirm --json稿件正文样式 / 排版(1.8.0)
对齐桌面端「内容预览」工具条与「设置样式」批量弹窗:字号、行间距、字间距、对齐、缩进、段前距、段后距。
typography 读当前排版;set-typography 支持单篇(位置参数)或批量(--ids,最多 200 篇)。未指定的字段保留各稿件正文现值——只想改字号就只传 --font-size;要复刻 UI 批量弹窗的「全部重设」,把七项都显式传上。取值须为下拉档位之一,否则报错。成功返回 { updated, errors },个别稿件失败不影响其余稿件。
| 字段 | flag | 可选值 |
|------|------|--------|
| 字号 | --font-size | 12 / 14 / 15 / 16 / 17 / 18 / 20 / 24(默认 17) |
| 行间距 | --line-height | 1 / 1.5 / 1.6 / 1.75 / 2 / 3 / 4 / 5(默认 1.6) |
| 字间距 | --letter-spacing | 0 / 0.5 / 1 / 2(默认 0) |
| 对齐 | --align | left / center / right / justify(默认 left) |
| 首行缩进 | --indent | 0 / 8 / 16 / 24 / 32 / 40 / 48(默认 0) |
| 段前距 | --margin-top | 同上 |
| 段后距 | --margin-bottom | 同上 |
haoxu manuscripts typography <id> --json
haoxu manuscripts set-typography <id> --font-size 18 --json
haoxu manuscripts set-typography --ids m1,m2,m3 --font-size 18 --line-height 1.75 --align justify --json
haoxu manuscripts set-typography --ids m1,m2 --payload-file ./typography.json --json--payload-file 即 typography 对象本身:
{ "fontSizePx": 18, "lineHeight": 1.75, "letterSpacingPx": 1, "textAlign": "justify" }已启用排版主题的稿件不能再设手动样式(400,两者互斥;先 set-theme --clear)。
稿件排版主题(1.15.0)
themes 列出白名单(classic-* / elegant-* / concise-* 共 30 个);set-theme 单篇(位置参数)或批量(--ids,最多 200 篇)设置,--theme / --clear 互斥且须指定其一。未知 themeId 返回 400,不会静默清空;设主题后存稿/发表自动按主题渲染,无需额外操作。manuscripts list 新增「主题」列,list / get 响应含 themeId(null = 未启用)。
haoxu manuscripts themes --json
haoxu manuscripts set-theme <稿件ID> --theme elegant-classic-blue --json
haoxu manuscripts set-theme --ids m1,m2 --theme classic-classic-blue --json
haoxu manuscripts set-theme --ids m1,m2 --clear --json
haoxu manuscripts import-paths --paths /abs/a.html --theme concise-emerald-green --json| 命令 | flag | 说明 |
|------|------|------|
| manuscripts themes | (无) | 列出 30 个排版主题:{ items: [{ id, title, themeColor }], total } |
| manuscripts set-theme | <id> | --ids | 二选一;单篇用位置参数,批量用逗号分隔 ID(1–200) |
| | --theme | --clear | 二选一;--theme 传白名单 id,--clear 清除主题 |
| import-paths / import-links | --theme | 可选;导入时直接套用主题 |
批量返回 { updated, errors },逐篇累计,务必检查 errors。
单篇稿件插入配图(1.3.0)
--position:article_start / article_end / before_paragraph / after_paragraph。--files / --urls / --payload-file 三选一;本机路径须绝对路径且同机可读。成功返回 { contentWordCount: number }。
haoxu manuscripts insert-images <id> --position article_start --files /abs/a.jpg,/abs/b.png --json
haoxu manuscripts insert-images <id> --position before_paragraph --urls https://example.com/a.jpg --json
haoxu manuscripts insert-images <id> --payload-file ./insert-images.json --json存稿 / 发表写操作(0.8.0;1.13.0 create-split;1.16.0 --layout-mode;1.20.0 --default-cover-image-index)
启动后 fire-and-forget,须轮询 draft-tasks get / publish-tasks get 查看进度。1.1.0 起支持从远端草稿箱创建发表(from-drafts 默认只建、须 --start 开跑;from-first-drafts 创建后自动开跑)。仍不支持飞书 / 删发表任务。
作者/原创等与 UI 同级配置:用 --payload-file,字段在 originalityConfig(禁止顶层 author/isOriginal)。省略则默认未声明原创。完整字段见包内 Skill。
一键排版(1.16.0): create / create-split 支持 --layout-mode keep|standard|thin(body layoutMode):存稿成功后后台自动打开草稿执行官方一键排版,选「标准」或「简约」样式;keep(默认)保持原排版。贴图(note)强制 keep。排版失败不影响存稿结果。
缺省封面(1.20.0): create / create-split 支持 --default-cover-image-index <n>(body defaultCoverImageIndex,仅文章模式生效):稿件未单独设封面时取正文第 N 张图(从 1 数,默认 1=首图)作封面;文中没有第 N 张图则不设封面;已单独设封面的稿件不受影响。须为 >= 1 的整数,CLI / Bridge 双拦报错,不会静默收敛。与 UI 存稿弹窗「缺省封面」同链路。
create-split: POST /v1/batch-draft-tasks/create-split。切分三选一(manuscriptsPerTweet | randomMin+randomMax | chunkSizes);随机与桌面合并弹窗同算法(末条可少于 min);响应 { created, chunkSizes };各任务 mergeMode 由 planner 按 chunk 推导。
# 默认 --content-mode article(图文);贴图用 note(亦接受 sticker)
# 一键排版(1.16.0):--layout-mode standard|thin 存稿成功后后台执行官方一键排版;缺省 keep 保持原排版;贴图强制 keep
# 缺省封面(1.20.0):--default-cover-image-index 3 未设封面的稿件取正文第 3 张图作封面;缺省 1=首图;文中取不到则不设封面
haoxu draft-tasks create --account <id> --manuscripts m1,m2 [--content-mode article|note] [--layout-mode keep|standard|thin] [--default-cover-image-index <n>] [--payload-file ./draft.json] [--start] --json
haoxu draft-tasks create --account <id> --manuscripts m1 --content-mode note --start --json
# 按篇数拆成多条(1.13.0);三选一互斥;都不传 → 默认固定 min(8, 稿件数);旧 create 不拆分
haoxu draft-tasks create-split --account <id> --manuscripts m1,m2,... \
[--manuscripts-per-tweet <1-8>] \
[--manuscripts-per-tweet-random <min-max>] \
[--chunk-sizes 1,4,5] \
[--content-mode article|note] [--layout-mode keep|standard|thin] [--default-cover-image-index <n>] [--payload-file ./draft.json] [--start] --json
haoxu draft-tasks start|cancel <id> --json
haoxu draft-tasks delete <id> --confirm --json
# 定时三件套:--schedule-date 只认 今天|明天|X月X日(未来 7 天内),时分写两位(08/00,单位数自动补零),且须至少 5 分钟之后
haoxu publish-tasks from-batch-draft --tasks d1,d2 [--schedule-date <label> --schedule-hour <hh> --schedule-minute <mm>] [--start] --json
haoxu publish-tasks from-drafts --drafts '[{"accountId":"a1","platformDraftId":"d1","draftTitle":"标题"}]' [--schedule-date <label> --schedule-hour <hh> --schedule-minute <mm>] [--start] --json
haoxu publish-tasks from-drafts --drafts-file ./drafts.json [--start] --json
haoxu publish-tasks from-first-drafts --accounts a1,a2 --draft-type article --json
haoxu publish-tasks start <id> --json
haoxu publish-tasks start-batch --ids p1,p2 --json
haoxu publish-tasks start-all-pending --json公众号远端(0.3.0 读;1.0.0 写)
# 先查在线账号 ID
haoxu accounts list --quick-filter online --json
# 草稿箱关键词搜索
haoxu accounts mp-drafts <账号ID> --q 关键词 --json
# 今天发表记录
haoxu accounts mp-published <账号ID> --date-preset today --json
# 删草稿(须 --confirm)
haoxu accounts mp-drafts-delete <账号ID> <draftId> --confirm --json
# 草稿另存到其他账号(全同步,可能较久)
haoxu accounts mp-drafts-sync <账号ID> <draftId> --targets id1,id2 [--upload-material] --json
# 已发表设/取消仅自己可见
haoxu accounts mp-published-private <账号ID> --items '[{"appmsgid":123,"itemidx":1,"privateType":1}]' --json
# 素材库列表 / 上传 / 删图(上传与删图须本机绝对路径、同机;删图须 --confirm 与 --group-ids)
haoxu accounts mp-images <账号ID> [--group <id>] --json
haoxu accounts mp-images-upload <账号ID> --file /abs/image.jpg --json
haoxu accounts mp-images-delete <账号ID> --ids 1,2 --group-ids 0,0 --confirm --json带日期筛选时响应可能含 scanExhausted: true(扫描达 10 页上限,结果可能不完整)。
配置写入 ~/.haoxu/config.json(baseUrl 默认 http://127.0.0.1:19321,apiKey)。
列表过滤
- 过滤参数使用英文稳定码,与号续 UI 对齐
- 多选 ID 用逗号分隔(如
--group id1,id2;哨兵ungrouped/untagged/uncategorized) - 详见
haoxu --help或包内 Skill
常用示例:
haoxu accounts list --quick-filter online --group g1,g2 --json
haoxu manuscripts list --cover unset --json
haoxu ip-proxies list --group ungrouped --json员工列表:仅主账号可访问;员工子账号返回 403。
Agent Skill
推荐从 GitHub skills 仓库全局安装:
npx skills add montisan/skills --skill haoxu-agent -y -g仓库:https://github.com/montisan/skills
包内亦附带:skills/haoxu-agent/SKILL.md(备选:安装 CLI 后 cp 到 .cursor/skills 或 ~/.claude/skills)。
发布(维护者)
npm 账号 montisan,组织 haoxu(scope @haoxu):
npm whoami # montisan
npm org ls haoxu # 确认自己在组织内且有 publish 权限
cd packages/haoxu-cli
npm publish --access public更多
完整教程:号续仓库 Desktop/docs/agent/haoxu-agent-guide.md。
