/ego-skills:wechat-channels-videofrom ego-skills
Saves a WeChat Channels video draft via Ego Lite browser automation. Checks login state first, uploads video, fills metadata, and saves draft without publishing.
Ships in ego-skills. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
Read when SKILL.md points to them; scripts run unread.
用 Ego Lite 会话在 视频号助手 保存视频草稿。不点「发表」(扫码发表留给人)。
Save a WeChat Channels draft through Ego Lite. Never click Publish — QR publish is human-only.
先装 Ego Lite,保证 ego-browser 在 PATH。缺失则 soft-fail / 告知用户去装,不要硬调浏览器。
视频号登录态过期很快。Agent 在上传或填表之前必须跑:
node scripts/check-login.mjs
# 需要把窗口留给人扫码时:
node scripts/check-login.mjs --keep
| 退出码 | 含义 | Agent 做什么 |
|---|---|---|
0 | 已登录 | 把 login_tip 告诉用户,继续流程 |
2 | 未登录 / 无 ego-browser | 展示 how_to_login / how_to_login_zh,停。请人在 Ego 扫码后再跑 check-login |
1 | 其它错误 | 报告 JSON error,不要假装已发布 |
详见 references/login.md。不要另做 cookie-healthcheck 技能。
调用方提供视频与文案字段,见 references/inputs.md。本技能不写死任何 ~/… 业务目录。
最少需要:本机 video 路径、description、short_title。可选:tags、cover、位置/原创/活动。
ego-browser nodejs 不转发 shell argv;check-login 已用临时 entry + ego-browser nodejs -e 包好。
# 仓库根目录
node skills/wechat-channels-video/scripts/check-login.mjs
node skills/wechat-channels-video/scripts/check-login.mjs --keep
node skills/wechat-channels-video/scripts/serve-file.mjs --file /absolute/path/to/video.mp4 --port 18765
# 已安装的技能目录里也可以用相对路径
node scripts/check-login.mjs
node scripts/serve-file.mjs --file /absolute/path/to/video.mp4 --port 18765
finish({ keep: [] })(--keep 除外)。fetch 用的本机 CORS 文件服务;打印 { url, bytes, port },SIGINT 结束。大视频不要 base64。不把整段发表 UI 打成一个巨型脚本:wujie、坐标点击、封面 waitForFileChooser 需要 Agent 看 snapshot/截图。脚本负责可判定的登录与传文件;表单仍按下面 Agent 步骤。
每次 ego-browser nodejs 是新进程;TaskSpace / Page 跨调用持久,JS 变量不持久。
| API | 说明 |
|---|---|
taskSpace(name|id) | 一个用户目标一个 space;记下 spaceId 复用 |
task.page("p1") | 首屏用 goto 复用,别乱开页 |
page.snapshot() | 观察(能看穿 open shadow);点击在 wujie 内常被拦截 |
page.evaluate(fn, arg) | 只收一个 JSON 可序列化参数(长文案走这里) |
page.mouse.click(x, y) | wujie 内弹层常用 |
page.waitForFileChooser() | 封面唯一稳妥上传路径 |
task.handOff() | 交给人扫码发表 / 当面登录 |
task.finish({ keep: [] }) | 收尾关 space;需人接着看时用 handOff,不要长期占机器 |
关键:snapshot 看得见 wujie shadow;ref/text 点击会报 intercepts pointer events。wujie 内动作用 evaluate 里 .click() 或坐标 mouse.click。不要改用无障碍 snapshot 的 ref 兜底(channelsClickMethod().refClick === false)。那条兜底是别的站点的做法,视频号这里点不到。
不要直接 goto /platform/post/create(懒加载白屏)。走 UI:
首页 → 左栏「内容管理」→「视频」→ 右侧「发表视频」
就绪:wujie 内文案出现「视频描述」「短标题」,且有隐藏 input[type=file][accept*="video"] 与「保存草稿」。
const state = await page.evaluate(() => {
const app = document.querySelector('wujie-app');
if (!app?.shadowRoot) return { wujie: false };
const t = app.shadowRoot.textContent || '';
return {
wujie: true,
hasDesc: t.includes('视频描述'),
hasShort: t.includes('短标题'),
hasUpload: !!app.shadowRoot.querySelector('input[type=file][accept*="video"]'),
hasSave: t.includes('保存草稿'),
};
});
先起 serve-file(端口默认 18765),再在页面里 fetch + DataTransfer 注入隐藏 file input(视频组件未做 isTrusted 加固;封面做了):
const r = await page.evaluate(async (p) => {
const root = document.querySelector('wujie-app').shadowRoot;
const input = root.querySelector('input[type=file][accept*="video"]');
const resp = await fetch(p.url);
const dt = new DataTransfer();
dt.items.add(new File([await resp.blob()], p.name, { type: 'video/mp4' }));
input.files = dt.files;
input.dispatchEvent(new Event('input', { bubbles: true }));
input.dispatchEvent(new Event('change', { bubbles: true }));
return 'injected ' + dt.files[0].size;
}, { url: 'http://127.0.0.1:18765/video.mp4', name: 'video.mp4' });
验证只看 DOM,并且有次数上限。把每次探测交给 scripts/lib/pure.mjs 的 uploadProbeDecision / wujieProbeDecision(ego 脚本里 await import("<本技能目录>/scripts/lib/pure.mjs"))。不要另写一套更松的判断。
failed: true:action: "stop",立刻停。100 / 100%,或上传完成后百分比已经消失、但可见 <video> 和「转发」「赞」「评论」同时在(hasPreview: true),并且 stableCount >= 2:action: "proceed"。样式表里的 100% 和隐藏节点不算。action: "retry"。最多 8 次(CHANNELS_UPLOAD_WAIT_LIMIT)。用尽仍不满足就是 stop,原因是 timeout。wujie 为 null / wujie: false:wujieProbeDecision,最多 8 次。不要刷新。用尽就是 stop / unresolved。performance resource 抓不到上传 POST,不要拿它当成功。action 不是 proceed 时不要填表,也不要点「保存草稿」。上传中途不要填表。
uploadProbeDecision 返回 proceed 之后,用 maySaveCheckpoint 再确认一次,然后才点「保存草稿」。retry 就继续等;stop(超时、失败、看不清)停在这次点击之前。不要把没确认的上传存成草稿。检查点只为了避免稍后翻车重传大文件。描述还没写,所以这一下不查描述回读。
描述是 .input-editor(非 contenteditable)。execCommand;文案从 evaluate 第二参数传入:
await page.evaluate((p) => {
const ed = document.querySelector('wujie-app').shadowRoot.querySelector('.input-editor');
ed.focus();
document.execCommand('selectAll', false, null);
document.execCommand('delete', false, null);
document.execCommand('insertText', false, p.desc);
}, { desc });
await page.evaluate((p) => {
const ed = document.querySelector('wujie-app').shadowRoot.querySelector('.input-editor');
ed.focus();
document.execCommand('insertParagraph');
document.execCommand('insertText', false, p.tags);
ed.blur();
}, { tags });
写完立刻回读 .input-editor 的 innerText。不要改读别的字段来凑合。读不到编辑器就当作 { ok: false }。把回读和期望交给 descriptionReadbackOk(read, { desc, tags })。
insertParagraph 多出来的空行被当成不一致。ok !== true(mismatch、empty-readback、unresolved、missing-expected)时 停止,不要点「保存草稿」。不要靠肉眼当成已经写上。真 <input>,必须 native setter;验证读 input.value(innerText 不含 input 值)。
服务端硬限制(实测多期,触发即红字警告,保存被拒):
6.1 这类写法要改说法规避。|、#、@ 都不行:自带标题里的分隔符取主句(如「标题文字|栏目#066」→「标题文字」)。填完后检查输入框下方有没有红字警告;有就改写后再保存。
默认常带城市。稳妥:mouse.click 打开 → snapshot/截图 → 点「不显示位置」→ 回读字段确认。evaluate 坐标可能点到隐藏层。
不要自己点「保存草稿」。唯一支持的保存是:
node skills/wechat-channels-video/scripts/save-draft.mjs --desc "描述" --tags "#话题" --yes
node skills/wechat-channels-video/scripts/save-draft.mjs --desc "描述" --tags "#话题" --cover /absolute/path/to/cover.jpg --yes
脚本会重新读取描述、上传状态和封面预览,交给 maySaveDraft。没有 --yes 不点。描述不一致、上传没完成或失败、指定封面没换上、读不到编辑器,都在点击之前退出。脚本不点「发表」。
点保存之后的成功信号不变:「已保存」+ 底部按钮变灰。再 goto 草稿箱核对。草稿箱可见前不要离开编辑器。草稿箱核对发生在保存成功之后,不能用来补一张没通过回读的草稿。
可选:声明原创、活动搜索(native setter 写搜索词;搜不到就「不参与活动」)。
真 checkbox(授权钥匙串行)。勾选后弹协议层:勾「我已阅读并同意…」→ 点层内「声明原创」确认按钮。两步都要坐标点击并回读 input[type=checkbox].checked 确认。
input[placeholder*="搜索活动"] 失败就重试 2–3 次。keyboard.insertText 间歇性失效);二次搜索前先清空——native setter 是覆盖,但焦点点击后残留词会被追加成「AI科普AI科普」。唯一稳妥:waitForFileChooser() + 可信点击「上传封面」+ chooser.setFiles(<绝对路径>)。合成 input.files / OS 文件框方案已实测失败。不要改用无障碍树 ref 去点「上传封面」或「保存草稿」。
换封面之后,每次探测交给 coverPreviewDecision,最多 12 次(CHANNELS_COVER_WAIT_LIMIT):
stop,原因 spinning。previewChanged !== true:可见封面图(.cover-img)还没换掉页面记下的第一帧。隐藏的 .cover 提示图不算。用尽次数则 stop / unresolved。revertedToDefault: true:预览退回默认帧,立刻 stop,原因 reverted。previewChanged: true:proceed。requested: false,结果是 skip,不挡后面的保存判断。stop 或仍是 retry 时不要点「保存草稿」。
serve-file(释放端口)。handOff()。finish({ keep: [] }),不要长期占 space。wujie-app.shadowRoot 起。proceed 就不存检查点草稿。npm test
npm test 锁住 scripts/lib/pure.mjs 里的回读、有界等待、封面预览和「不点发表」。它不登录、不上传、不保存草稿。页面步骤仍由 Agent 按上面的闸门执行;单测没有代替实页验收。
agents/openai.yaml (opens in a new tab)references/inputs.md (opens in a new tab)references/login.md (opens in a new tab)scripts/check-login.mjs (opens in a new tab)scripts/lib/ego-deps.mjs (opens in a new tab)scripts/lib/launch-check.mjs (opens in a new tab)scripts/lib/launch-save.mjs (opens in a new tab)scripts/lib/pure.mjs (opens in a new tab)scripts/lib/run-check.mjs (opens in a new tab)scripts/lib/run-save.mjs (opens in a new tab)scripts/lib/save-flow.mjs (opens in a new tab)scripts/save-draft.mjs (opens in a new tab)scripts/serve-file.mjs (opens in a new tab)scripts/test/launch-check.test.mjs (opens in a new tab)scripts/test/pure.test.mjs (opens in a new tab)scripts/test/run-check.test.mjs (opens in a new tab)scripts/test/save-flow.test.mjs (opens in a new tab)What SKILL.md sets; muted values are Claude Code's defaults
npx claudepluginhub terryso/ego-skills --plugin ego-skills14 skills in this plugin
/bilibili-videoPublish a local video to the Bilibili creator platform (member.bilibili.com) with Ego Lite via ego-browser. Login-check first. Bilibili wants TWO covers uploaded separately: --cover-4x3 (首页推荐) and --cover-16x9 (个人空间). Nothing is submitted without --yes: that run only prints a local plan and exits 3. --type selects a partition from the human-type list and reads it back; a missing name stops before 立即投稿. Success is 投稿成功 / 审核中, with a BV URL or identity unconfirmed. Bilibili has no private visibility on web upload: approved submissions go public. Use when the user asks to post to B站, 哔哩哔哩, B站投稿, or publish a video to bilibili./chatgpt-image-genExpand a rough image idea with the six-axis domain engine from codex-imagegen, then create one image on the free ChatGPT website inside Ego Lite. Login-check first. Soft-fail with exit 2 when ego-browser is missing, chatgpt.com is logged out, or login cannot be proven. enrich and generate without --yes are offline. --yes sends one prompt and saves the image to --out. Flowcharts and timelines are SVG, not images. Does not call codex exec and does not use an API key. Use when the user asks to generate an image, enrich a prompt, or use ChatGPT Images without a Codex subscription./douyin-videoPublish a local video to the Douyin creator center (creator.douyin.com) with Ego Lite via ego-browser. Login-check first. Title is a separate field of at most 30 characters. Success is a redirect to content management or a publish-success message. The caller supplies a local video file. This skill does not download video. Use when the user asks to post to 抖音, 抖音发视频, 发布到抖音创作者中心, or creator.douyin.com.Other plugins' skills for the same job