/ego-skills:zhihu-articlefrom ego-skills
Prepares a Zhihu article draft via Ego Lite's visible editor. Supports offline preview, draft saving, and draft verification 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 里已经登录的知乎会话,准备一篇专栏文章草稿。只走看得见的页面。不写回答、评论、想法,不定时,不批量发布。
Prepare one Zhihu article draft in the visible editor. --save-draft is the only mutation consent. It does not publish. Public publishing is not implemented in this version.
成功不是点到了某个按钮。回读必须同时满足:编辑地址里有唯一的数字草稿 id、正文不是空的、页面有「已保存」或带时间的「刚刚 · 草稿」这类保存戳、标题、正文、标题层级、列表、链接和完成的正文图片张数都对得上,而且导语、标题和列表不能重复。图片的 alt 不会变成可见说明,不拿它当正文。封面必须是正文图片之外的一张 http 预览;封面面板里的缩略图不算正文图片,也不单独当成封面已上传。没有这条回读,结果是 unverified 或 uploaded。--verify-draft 才会重新打开回执里的那一个草稿地址做只读核对。--save-draft 看到同一哈希的未验证回执就停,不再打开 /write,也不粘贴、上传或删除块。重复正文仍然是 unverified。空编辑器上的「刚刚 · 草稿」仍然不是成功。
Success is not a click. The editor must show one numeric draft id, a saved stamp, and matching title, body, headings, lists, links, and image count. An empty editor showing 刚刚 · 草稿 is not success. An unverified receipt reopens that draft URL instead of /write.
知乎官方说明草稿是自动保存的,保存后页面顶部显示「已保存」;「发布」是另一步(专栏与文章使用常见问题)。如果页面上另外有「保存草稿」「存草稿」或「保存为草稿」,会点一次,而且只点一次。没有这种按钮时,成功路径是自动保存加上回读,mutation 为 autosave-verified。这两种都不等于发布。
先装 Ego Lite,保证 ego-browser 在 PATH。非交互 shell 找不到时,再试 ~/.local/bin/ego-browser。仍然缺失则 soft-fail(退出码 2)。不要改用 Playwright、Puppeteer 或云端浏览器。
node scripts/check-login.mjs
node scripts/check-login.mjs --expect-account "示例作者"
check-login 只打开 https://www.zhihu.com/,不打开写文章页。账号名来自顶栏身份控件,包括 header、banner、AppHeader 和头像 AppHeader-profileAvatar。标志 AppHeader-zhihuLogo 不是账号。头像的 alt、aria-label 或 title 若是「点击打开名字的主页」,空格可有可无。推荐流作者不算。--expect-account 只和这个名字比较。
写文章页 https://zhuanlan.zhihu.com/write 没有「创作中心 / 私信 / 消息」时,只要标题框、正文编辑器和顶栏头像都在,就仍算已登录。打不开探针是 probe-failed,验证页是 challenge,只有真正落到登录墙才是 login-expired。正文优先用 public-DraftEditor-content,创作助手里的编辑框不算正文。正文图片只认唯一一个可见控件,它的名字正好是「图片」。空的 accept、只是带有「图片」两个字的「AI 配图」、封面、附件、导入、视频和创作助手都不算。对不上这一个输入就停,不猜,也不点「发布」。这种失败会带上页面地址、标题,并在提供了截图目录时把截图写进那个目录。打开写文章页后知乎可能自己出现「刚刚 · 草稿」;那不是本技能确认过的 draft-saved。不要代填密码,不要粘贴 Cookie,不要抄 token,不要自动登录。
| 退出码 | 含义 | Agent 做什么 |
|---|---|---|
0 | 已登录,且只看到一个匹配的账号 | 把 login_tip 告诉用户 |
2 | 未登录、登录过期、账号不符,或没有 ego-browser | 展示 how_to_login,停 |
4 | 顶栏身份控件有多个名字,或已登录但读不到唯一名字(identity-not-visible) | 停。不要猜,也不要用信息流作者凑名字 |
3 | 草稿计划已打印,没有写入 | 把计划给人看。没有 --save-draft 不打开编辑器 |
1 | 参数、素材或浏览器错误 | 报告 JSON error,不要假装已保存 |
默认是离线预览,不启动浏览器,不写知乎。
| 命令 | 写入? |
|---|---|
preview | 否。退出码 0 只表示本地计划有效,state 为 not-started |
save-draft 不加 --save-draft 或 --verify-draft | 否。退出码 3 |
save-draft --verify-draft | 否。只重新打开回执里的草稿地址并读取 |
save-draft --repair-draft | 只在正文重复、选区与正文一致、并且删除后正文已空时替换一次 |
save-draft --save-draft | 只同意保存一篇新的文章草稿。已有未验证回执时不打开浏览器 |
--publish、--yes | 直接拒绝。它们不是草稿同意,也不是发布许可 |
publishPermitted 和 publishSupported 始终是 false。
state | 含义 | 可否自动再跑 |
|---|---|---|
not-started | 还没有远程写入 | 预览可以重跑。编辑器里已有内容时不要覆盖 |
uploaded | 图片或封面已提交,但没有确认到草稿 id | 否 |
draft-saved | 回读通过,verified 为 true | 否。同一哈希直接返回已有回执 |
unverified | 可能已经有草稿,但身份或正文对不上;包括只看到「已保存」、只点了按钮、自动保存和显式保存分不清 | 否 |
failed | 本地失败,没有观察到远程写入 | 只有 retryable: true 时可以修输入后再跑 |
回执在 --receipt-dir,默认是用户状态目录下的 zhihu-article/receipts。同一哈希如果已经是 unverified 或 uploaded,--save-draft 退出 4 且错误是 verify-draft-required,不打开编辑器。要读现有草稿,单独加 --verify-draft。
node skills/zhihu-article/scripts/check-login.mjs --expect-account "示例作者"
node skills/zhihu-article/scripts/preview.mjs \
--markdown /absolute/path/to/article.md \
--cover /absolute/path/to/cover.png
node skills/zhihu-article/scripts/save-draft.mjs \
--markdown /absolute/path/to/article.md \
--cover /absolute/path/to/cover.png \
--expect-account "示例作者" \
--save-draft --json
node skills/zhihu-article/scripts/save-draft.mjs \
--markdown /absolute/path/to/article.md \
--cover /absolute/path/to/cover.png \
--expect-account "示例作者" \
--verify-draft --json \
--receipt-dir /absolute/path/to/receipts \
--screenshot-dir /absolute/path/to/screenshots
node skills/zhihu-article/scripts/save-draft.mjs \
--markdown /absolute/path/to/article.md \
--cover /absolute/path/to/cover.png \
--expect-account "示例作者" \
--repair-draft --json \
--receipt-dir /absolute/path/to/receipts \
--screenshot-dir /absolute/path/to/screenshots
node skills/zhihu-article/scripts/cleanup.mjs
纯文本用 --text 或 --text-file,并且必须带 --title。正文图片写在 Markdown 里,只接受文章目录内的相对路径或调用方给出的绝对路径。不要写远程图片。
支持的 Markdown:标题、段落、**粗体**、*斜体*、链接、有序和无序列表、独立一行的本地 PNG/JPG 图片。代码块、表格、引用、原始 HTML、公式、四级及以上标题、嵌套列表、远程图片会在打开浏览器之前被拒绝。GIF 和 WebP 也不接受。封面必须宽于 330px、高于 100px。这些限制来自知乎公开的文章说明,加上本地守卫;本变更没有在真实编辑器里重测选择器和图片是否留下。
细节见 references/inputs.md、references/editor.md、references/states.md、references/login.md。本地验收步骤见 references/acceptance.md。
npm test
单测不打开知乎,也不写入真实账号。单测通过不能当作线上验收。
agents/openai.yaml (opens in a new tab)references/acceptance.md (opens in a new tab)references/editor.md (opens in a new tab)references/inputs.md (opens in a new tab)references/login.md (opens in a new tab)references/states.md (opens in a new tab)references/tos-notes.md (opens in a new tab)scripts/check-login.mjs (opens in a new tab)scripts/cleanup.mjs (opens in a new tab)scripts/lib/dom.mjs (opens in a new tab)scripts/lib/ego-deps.mjs (opens in a new tab)scripts/lib/flow.mjs (opens in a new tab)scripts/lib/launch.mjs (opens in a new tab)scripts/lib/prepare.mjs (opens in a new tab)scripts/lib/pure.mjs (opens in a new tab)scripts/lib/session.mjs (opens in a new tab)scripts/preview.mjs (opens in a new tab)scripts/save-draft.mjs (opens in a new tab)scripts/test/browser-dom.test.mjs (opens in a new tab)scripts/test/dom-fixture.mjs (opens in a new tab)What SKILL.md sets; muted values are Claude Code's defaults
Three short reads, in order
14 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.npx claudepluginhub terryso/ego-skills --plugin ego-skillsOther plugins' skills for the same job