# opencli-plugin-x-article-publisher Publish Markdown with local images as an X long-form Article through OpenCLI and xPoster. 通过 OpenCLI 和 xPoster,把带本地图片的 Markdown 发布为 X 长文。 ## Requirements / 依赖 - OpenCLI `>=1.8.6` - Chrome logged into X and connected through the OpenCLI extension / 已登录 X、并连接 OpenCLI 扩展的 Chrome - xPoster enabled in the same Chrome profile / Chrome 中启用 xPoster - An X account with Articles access / X 账号具备 Articles 长文权限 ## Install / 安装 ```bash opencli plugin install github:genoooool/opencli-plugin-x-article-publisher ``` The plugin is installed independently from the OpenCLI package, so upgrading OpenCLI does not overwrite the plugin source. 插件独立安装,不存放在 OpenCLI 的全局安装目录中,因此升级 OpenCLI 不会覆盖插件源码。 ## Command / 命令 | Command | Type | Description | |---------|------|-------------| | `x-article/publish` | UI | 校验、创建草稿或公开发布 X 长文 | ```bash # 只检查 Markdown、封面与正文图,不修改 X opencli x-article publish article.md --prepare-only -f json # 创建远程草稿并验证预览 opencli x-article publish article.md -f json # 预览验证通过后公开发布 opencli x-article publish article.md --execute -f json ``` 可用 `--cover cover.jpg` 覆盖 frontmatter 的 `cover_image`,也可以用 `--caption "..."` 设置公开发布时的配文。 ## Markdown contract / Markdown 约定 - 标题来自 frontmatter 的 `title` 或正文第一个 H1。 - 封面来自 `--cover`、frontmatter 的 `cover_image`,或正文第一张图片。 - 正文图片必须是单独一行的本地 Markdown 图片。 - 图片使用逻辑块索引定位,并从文章末尾向前插入,避免前面的锚点漂移。 - 当前版本不支持远程图片 URL 和正文水平分隔线。 ## Safety / 安全边界 - `--prepare-only` 不打开或修改 X。 - 默认只创建并验证远程草稿。 - 只有显式传入 `--execute` 才会点击最终的公开发布按钮。 - 最终点击后如果公开回读超时,命令返回 `publish_clicked_unverified`,不会用可重试失败伪装状态,避免重复发布。 ## Development / 开发与验证 ```bash npm run check npm run validate opencli list -f json | jq '.[] | select(.site == "x-article")' ``` 块索引与逆序插图思路参考 [wshuyi/x-article-publisher-skill](https://github.com/wshuyi/x-article-publisher-skill) (MIT,参考提交 `eb3197d1d8579556aea5018d5c0b141d55fc2df6`)。本插件的浏览器驱动 使用 OpenCLI,不使用 Playwright MCP 或 Computer Use。