md2wechat
Convert Markdown to WeChat Official Account HTML. Use this whenever the user wants WeChat article formatting, article preview, WeChat draft upload, image generation for articles, cover or infographic generation, image-post creation, writer-style drafting, title suggestions, AI tr
Install
npx skills add https://github.com/geekjourneyx/md2wechat-skill/tree/main/skills/md2wechat
claude plugin marketplace add https://llmmart.ai/marketplace.json && claude plugin install geekjourneyx-md2wechat-skill@llmmart
git clone https://github.com/geekjourneyx/md2wechat-skill.git
The skills CLI installs just this skill, for any of its supported agents. Claude Code installs the whole geekjourneyx/md2wechat-skill collection as a plugin from our marketplace. Git is the plain clone.
Skill manifest
md2wechat
Use this skill to operate the md2wechat CLI. Keep the skill focused on execution decisions. For full command tutorials, installation details, and FAQ-level explanations, refer users to the project docs instead of expanding this runtime protocol.
Intent Routing
Choose the command family before taking any publish or generation action:
- Standard article HTML, article preview, metadata inspection, or WeChat article draft: use
inspect,preview, andconvert. - Unpublished Zhihu, CSDN, or Toutiao draft: run
md2wechat skills read md2wechat references/sync/workflow.md --jsonfor the current CLI's embedded workflow; the CLI prepares content and the Agent operates the browser. - Image-first post, image note, image-text note,
newspic, or multi-image post: usecreate_image_post, notconvert --draft. - Article cover or article infographic: prefer
generate_coverorgenerate_infographicover rawgenerate_imagewhen a bundled preset fits. - Host-agent image generation request with no provider configured: use image plan mode (
--plan --json) to get prompt intent, then hand it to the host image-generation tool if one is available outside md2wechat. - WeChat title candidates for an existing article: use
title suggest <article.md> --json; it emits a host-Agent AI request and does not choose or write the final title. - Existing article or draft, user asks what to improve next: run
md2wechat advise <article.md> --json; treat it as recommendation-only and keepinspect --json data.readiness.targets/blockersas the publish gate. - Writing in a creator style or removing AI traces: use
writeorhumanize. - Provider, theme, prompt, or layout uncertainty: run discovery first. Do not guess from memory or repository files.
Treat convert --draft and create_image_post as different publish targets, not interchangeable variants.
Discovery First
Use CLI discovery as the source of truth, but keep it scoped to the next decision. Do not run the full catalog for tasks that do not need provider, theme, prompt, or layout selection.
Use capabilities for aggregate routing facts, resource list for lightweight selection fields, show for one full resource definition, and render for materialized prompt/layout output. JSON stdout is compact; use jq only when a human needs formatted output.
Run the smallest useful discovery set:
Article formatting with no theme or modules chosen:
md2wechat themes list --json md2wechat layout list --jsonA named theme, provider, prompt, or layout module:
md2wechat themes show <name> --json md2wechat providers show <name> --json md2wechat prompts show <name> --kind <kind> --json md2wechat layout show <name> --jsonImage generation or image-preset selection:
md2wechat providers list --json md2wechat prompts list --kind image --jsonSubject-reference (image-to-image) capability before using
--subject-reference:md2wechat providers show minimax --jsonRead
supports_subject_referenceon the provider and on each entry ofsupported_models. Only theminimaxprovider and itsimage-01model accept--subject-reference, and the reference must be a publicly reachablehttp(s)portrait image URL; inline data URLs and local paths are rejected. Unsupported provider/model combinations fail immediately withCONFIG_INVALID, so do not retry them as generation failures.Title suggestion prompt selection:
md2wechat prompts list --kind title --json md2wechat prompts show wechat-title-expert --kind title --jsonDraft, upload, API local-readiness, or configuration troubleshooting:
md2wechat doctor --json md2wechat config show --format json md2wechat config wechat-accounts --jsondoctorreadiness is local configuration attemptability.config wechat-accountsis local-only and never prints WeChat secrets. Useinspect --jsonfor article-specific target readiness.Unknown CLI version, changed behavior, or capability uncertainty:
md2wechat version --json md2wechat capabilities --json md2wechat skills list --json md2wechat skills read md2wechat --json
md2wechat skills read md2wechat --json reads the SOP embedded in the current CLI binary. Prefer it when the installed external skill, README, or repository checkout may be stale relative to the executable on PATH.
For simple local actions such as preview, humanize, or a user-specified command with explicit flags, do not run unrelated provider, theme, prompt, or layout discovery.
Inspect specific resources only when the task needs them:
md2wechat providers show <name> --json
md2wechat themes show <name> --json
md2wechat prompts show <name> --kind <kind> --json
md2wechat layout show <name> --json
Use CLI output as the source of truth for currently available modes, providers, themes, prompts, and layout modules.
Configuration Boundaries
- Assume
md2wechatis already available onPATH. convertdefaults to API mode unless the user explicitly asks for--mode ai.- API-mode preview and conversion require a valid
MD2WECHAT_API_KEY. - WeChat upload, article draft creation, and
create_image_postrequire WeChat credentials whenever the user explicitly requests those side effects. - Read-only discovery,
inspect,preview, and plain conversion are free of any global WeChat publishing credential requirement; API-mode preview and conversion still require a validMD2WECHAT_API_KEY. - Named WeChat account execution requires a valid
MD2WECHAT_API_KEY; the CLI validates it before upload, draft, orcreate_image_posteffects. - Direct image generation requires image-provider credentials; image plan mode (
--plan --json) only emits prompt intent for a host Agent or external tool and does not require image-provider credentials. title suggest --jsononly emits a title-generation prompt request for the host Agent or external model. It does not call a model, upload, create drafts, or write back to Markdown.- For stronger factual title hooks, pass --hook-level 2 or 3; do not treat generated titles as confirmed publishing intent.
doctor --jsonis local-only: it checks local readiness and does not perform live authentication, upload images, or create drafts.- Use
config show --format jsonwhen the user asks what configuration is currently effective. - Use
config wechat-accounts --jsonwhen the user asks which local WeChat accounts are configured.
Article Workflow
Prefer a confirm-first workflow for article work:
md2wechat inspect <article.md> --jsonmd2wechat preview <article.md>md2wechat convert <article.md> ...- Add
--upload,--draft,--cover, or--cover-media-idonly when the user explicitly asks for upload or draft creation.
inspect is the source-of-truth command for structured metadata, checks, readiness targets, and blockers. In --json output, read data.readiness.targets and data.readiness.blockers before deciding whether convert, upload, or draft is blocked. If the requested target is blocked, stop and report the matching blockers; do not continue by guessing from legacy booleans or checks alone. Do not invent data.agent_readiness, data.target_readiness, ArticleState, state files, or a second readiness/state object. preview writes only byte-identical final API HTML from a successful converter result; with --json, inspect diagnostics are returned in data.inspect and are never wrapped into that file. It does not upload images, create drafts, or write back to Markdown. convert performs conversion and only the explicitly requested upload/draft effects. convert --preview is the convert-path preview flag and is not the same as the standalone preview command. On PREVIEW_ACTION_REQUIRED or PREVIEW_FAILED, this invocation does not create or overwrite preview HTML. With --json, PREVIEW_ACTION_REQUIRED returns an empty data.output_file. Any pre-existing explicit output path is stale and must not be treated as this invocation's result; use the returned prompt for host-Agent work or report the failure.
When the intended execution path is convert --mode ai --custom-prompt ..., run inspect with the same --mode ai --custom-prompt ... before trusting readiness.
Formatting Protocol
When the user asks to format an article and has not chosen a theme or modules:
- Read the article and optional Brand Profile.
- Use discovery output as facts.
- Choose a compatible theme and a small set of modules from the article's content goal.
- Keep the source Markdown read-only.
- Create a temporary formatted Markdown artifact, for example
/tmp/md2wechat-format/<run-id>/article.formatted.md. - Insert only layout modules whose required fields can be filled correctly.
- Run
md2wechat layout validate --file <formatted.md> --json. - Pass the formatted Markdown artifact to
convert.
Saving generated Markdown next to the source file requires explicit user confirmation and must not overwrite the source.
Theme Selection
- Read
typeandselectablefromthemes list --json. - API mode can use only
type: apiandselectable: truethemes. - AI mode can use only
type: aiandselectable: truethemes. - Do not use collection descriptors such as non-selectable theme groups as concrete themes.
- If Brand Profile names a theme, verify it through CLI discovery before using it.
- If a requested theme is invalid or mode-incompatible, stop that path and choose a valid theme or ask the user.
Layout Modules
Advanced layout modules render only in API mode. AI mode (--mode ai) does not parse :::module syntax, so advanced layout cards will not render there.
Use this decision frame:
attention: help readers decide whether the article is worth reading.readability: make mobile reading easier.memorability: make one judgment, quote, metric, or brand anchor stick.conversion: help readers save, follow, inquire, share, or buy.
Use CLI discovery as the source of truth for layout syntax instead of memorizing or guessing body_format values:
- Inspect the opener, body schema, canonical executable example, and structurally distinct variants with
layout show <name> --json. Reuse the canonical witness. - Use
layout renderfor structured fields and--body-file(or--body-file -for stdin) for complex bodies, then validate the generated Markdown. - Default discovery returns recommended modules. Use
layout list --lifecycle compatibility --jsononly for old-content migration. Local validation proves syntax acceptance only; production support is a release-conformance fact.
Default module discipline:
- Do not pile on modules.
- Use at most one hero, one verdict, and one cta unless the user explicitly asks for more.
- Skip modules when the article does not provide enough content to fill them honestly.
API And AI Mode
- API mode is the default and is required for advanced layout modules.
- AI mode is a lighter path and does not render advanced layout modules.
- Do not silently switch from API mode to AI mode after an API failure. That changes the output capability.
- Use AI mode only when the user asks for it or accepts losing advanced layout rendering.
- If an AI-mode conversion completes, it is acceptable to briefly mention that API mode supports advanced layout modules and stronger visual structure.
Brand Profile
Brand Profile lives at ~/.config/md2wechat/brand.md.
- It is free-form Markdown, not YAML and not a fixed schema.
- The CLI does not parse it.
- Read it as context for voice, theme preferences, module preferences, CTA preferences, and forbidden expressions.
- Treat quantity preferences as soft constraints.
- Verify any named theme or module through CLI discovery.
- If Brand Profile does not exist, do not block the task. You may mention once that system defaults will be used.
- Create or edit Brand Profile only when the user explicitly asks.
Publishing Side Effects
Do not create drafts, upload images, publish, or call remote image generation unless the user asks for that action.
Before every explicit WeChat side effect—image upload, article draft creation, or create_image_post—require configured WeChat credentials and use the target-matched readiness/preflight path. Discovery and inspection remain non-publishing paths; preview and plain conversion are free of any global WeChat publishing credential requirement, while API mode still requires a valid MD2WECHAT_API_KEY.
Before WeChat article draft creation through convert:
- Use
inspect --jsonand checkdata.readiness.targets.draft; when blocked, read matchingdata.readiness.blockers. - Draft creation requires a cover via
--coveror--cover-media-id. - Do not assume a WeChat URL or
mmbiz.qpic.cnURL can be reused asthumb_media_id. - If draft creation returns
45004, check digest, summary, and description before assuming the body is too long.
In the WeChat convert flow, Markdown images are uploaded or replaced only during --upload or --draft, not during plain conversion or preview.
Failure Handling
- Missing or invalid config: run
doctor --jsonandconfig show --format json; reportdata.overallplus the blockingdata.readiness.*item. - Invalid layout syntax: run
layout validate, inspect the failing module withlayout show, fix the generated artifact, then validate again. - Unknown layout modules warn for forward compatibility; verify typos against
layout list --json. - Theme rejection: check
typeandselectable, then choose a compatible theme or ask the user. - AI request or style-writing flows may return a prompt/request rather than final prose or HTML unless the external model step is completed.
Files (md2wechat-skill)
-
references
-
sync
-
csdn.md 963 B
# CSDN 草稿 与公共 `workflow.md` 配合使用。 - 入口:首页账号公开主页入口用于核对身份;从“创作”进入富文本编辑器。不要切换“使用 MD 编辑器”,以免另开页面并产生默认模板稿。 - 标题:“请输入文章标题(5~100个字)”。正文:唯一 `iframe.cke_wysiwyg_frame` 内的可编辑 `body`;聚焦框架内正文,外层容器和侧边助手不能代替它。 - 图片:“图像”打开面板,“选择图片”触发文件窗口。等待图片进入正文并加载后读取地址。 - 保存:点击“保存草稿”并等待成功提示。从内容管理的“草稿箱”按标题、时间和正文取得唯一编辑链接;创建页可能一直是通用地址。重开后若标题为空,核对正文属于本次稿后在同稿补填、保存、重验。 - “发布博客”和“仅我可见”不能代替保存草稿;不启用文章备份或多平台发布。 -
toutiao.md 1.4 KB
# 头条草稿 与公共 `workflow.md` 配合使用。 - 输入限制:粘贴的 H2/H3 会统一为 H1。`heading_levels` 含多个级别时停止该目标;只有用户同意调整源稿后再准备。单一级别可继续,但须说明标题级别归一化。 - 字符核验:保存可能移除特殊字符,须与原文逐字符核对,不能用页面字数判断完整。发现丢失且无法修复时停止该目标,不自行删除或替换原稿字符。 - 入口:创作主页的公开主页链接用于核对账号;“文章”进入编辑器。“继续编辑”须先确认属于本次稿。 - 标题:“请输入文章标题(2~30个字)”。正文:`div.ProseMirror[contenteditable=true]`;“输入创作主题、观点或大纲”属于助手。 - 图片:编辑器工具栏内 `.syl-toolbar-tool.image button`,点击后应出现“上传图片”“本地上传”面板。选择文件,等待“已上传 N 张图片”符合本次数量,再点面板“确定”。从正文读取插入后的图片地址。 - 保存:等待“草稿已保存”。从创作主页“草稿箱”识别本次稿,点击标题后从新标签取得唯一编辑地址,再重开核验。图片组件有展示/编辑重复节点,按正文图片块及位置核对。 - 不点击“定时发布”或“预览并发布”,不修改首发声明等发布设置。 -
workflow.md 4 KB
# 跨平台草稿流程 复用用户已登录的浏览器,以 DOM 或可访问性定位操作正常编辑器;此流程仅保存草稿,不截图、不调用内部业务接口。 ## 准备 1. 已取得本次未变更原稿的成功准备结果时直接复用;否则通过 `md2wechat capabilities --json` 确认 `sync prepare` 可用,再运行 `md2wechat sync prepare <article.md> --output <new-dir> --json`。失败先处理返回的问题,不开始远端写入。`action_required` 只表示本地准备完成。 2. 读取结果中的 `title`、`body_html`、`images`、`heading_levels`,以及目标平台说明:`md2wechat skills read md2wechat references/sync/<platform>.md`,其中 `<platform>` 为 `zhihu`、`csdn` 或 `toutiao`。只读本次目标。 3. 按平台说明检查输入限制。标题计数不确定时,在上传正文前填写标题并检查页面校验;不自动截断或改写原稿。 4. 按下方“浏览器选择”确认现有会话、页面读取、正常 HTML 粘贴;有图片时还需文件上传。 5. 核对指定账号。已有本次草稿地址时恢复同稿;新开标签从当前列表取得。账号或草稿归属不明时先澄清。 ## 浏览器选择 优先使用当前 Agent 的 Computer Use/浏览器工具,通过 DOM 或可访问性结构完成操作。文件上传工具不可用时,可用宿主支持的系统文件窗口。 仅在宿主缺少必要能力且允许使用替代工具时,运行 `agent-browser --version` 检查备选工具,并依据该版本的 `--help` 确认连接和操作方式。优先连接用户已登录的浏览器;`--auto-connect` 需要浏览器提供可用的远程调试连接,安装工具不等于能连接现有会话。 未安装时告知可用 `npm install -g agent-browser` 安装,按用户授权和环境权限执行。`agent-browser install` 用于下载自动化浏览器,仅在需要独立浏览器且用户接受首次登录时使用,不作为默认步骤。 使用备选前确认能读取页面、正常粘贴富文本、上传所需图片并重新打开核验;仅有文本输入或截图能力不足以执行本流程。缺项未解决时报告具体阻碍并交接该步骤。权限拒绝不能通过换工具绕过;账号登录或平台内容限制也不能靠换工具解决。 切换工具后先恢复并核对原草稿,再执行未完成步骤;保存结果不明时按下方恢复流程检查,不重新创建。两种工具共用同一平台说明和核验要求。 ## 写入 控件必须在正文区域或当前弹层内唯一匹配;结构不符时停止该步骤,不猜位置。不同工具句柄须指向同一草稿。 有图片时,先在本次草稿中逐张正常上传并插入,等正文图片加载后读取实际地址。每个不同源文件上传一次;不同平台分别上传。 用 HTML 解析器处理 `body_html` 的平台副本:将 `img src` 的 URL 路径解码一次,与 `images` 的绝对路径匹配,再把所有对应出现位置替换为该平台已上传的地址并正确序列化。不要全局替换字符串或跨平台复用图片地址。 聚焦正文并全选该区域,用正常 HTML 粘贴替换临时内容;iframe 编辑器须在框架内聚焦。快捷键按宿主文档和操作系统选择,不通过脚本修改 DOM。立即回读,确认正文完整替换、无旧内容或重复图片。随后填写并回读标题。 ## 保存与恢复 按平台说明保存,保留唯一草稿编辑地址;通用写作入口不能用于恢复。结果不明时先查同稿或草稿箱,结合标题、时间和正文识别,不盲目重建。 重新打开唯一地址,对照准备内容核对标题、完整正文及顺序、标题层级、列表、代码与空白、表格单元格、图片位置和加载状态。图片组件的重复展示节点不算多张图片。出现缺失在同稿修正并重验;无法保留内容时停止该目标,不自动删改源稿。 报告已核验的草稿地址和未解决差异;保存提示或地址本身不能证明内容完整。 -
zhihu.md 854 B
# 知乎草稿 与公共 `workflow.md` 配合使用。 - 入口:首页账号公开主页入口用于核对身份;“写文章”会新开编辑标签。 - 标题:“请输入标题(最多 100 个字)”。正文:`.public-DraftEditor-content[contenteditable=true]`。表格单元格也可编辑,不要用全页可编辑元素定位正文。 - 图片:“图片”打开弹层;“本地图片上传”是说明文字,实际上传入口是同一容器内唯一 `role=button` 的加号控件。选择文件,等待“已上传 N 张图片”符合本次数量,再点“插入图片”;从正文读取插入后的图片地址。 - 保存:等待“草稿保存中”结束并出现草稿保存时间;保留具体文章编辑地址,再按公共流程重开核验。代码组件可能有重复展示节点,按内容块检查。
-
-
-
SKILL.md 14 KB
--- name: md2wechat description: Convert Markdown to WeChat Official Account HTML. Use this whenever the user wants WeChat article formatting, article preview, WeChat draft upload, image generation for articles, cover or infographic generation, image-post creation, writer-style drafting, title suggestions, AI trace removal, or current discovery of supported providers, themes, prompts, and layout modules. Also use for unpublished Zhihu, CSDN, or Toutiao drafts through a browser. --- # md2wechat Use this skill to operate the `md2wechat` CLI. Keep the skill focused on execution decisions. For full command tutorials, installation details, and FAQ-level explanations, refer users to the project docs instead of expanding this runtime protocol. ## Intent Routing Choose the command family before taking any publish or generation action: - Standard article HTML, article preview, metadata inspection, or WeChat article draft: use `inspect`, `preview`, and `convert`. - Unpublished Zhihu, CSDN, or Toutiao draft: run `md2wechat skills read md2wechat references/sync/workflow.md --json` for the current CLI's embedded workflow; the CLI prepares content and the Agent operates the browser. - Image-first post, image note, image-text note, `newspic`, or multi-image post: use `create_image_post`, not `convert --draft`. - Article cover or article infographic: prefer `generate_cover` or `generate_infographic` over raw `generate_image` when a bundled preset fits. - Host-agent image generation request with no provider configured: use image plan mode (`--plan --json`) to get prompt intent, then hand it to the host image-generation tool if one is available outside md2wechat. - WeChat title candidates for an existing article: use `title suggest <article.md> --json`; it emits a host-Agent AI request and does not choose or write the final title. - Existing article or draft, user asks what to improve next: run `md2wechat advise <article.md> --json`; treat it as recommendation-only and keep `inspect --json data.readiness.targets/blockers` as the publish gate. - Writing in a creator style or removing AI traces: use `write` or `humanize`. - Provider, theme, prompt, or layout uncertainty: run discovery first. Do not guess from memory or repository files. Treat `convert --draft` and `create_image_post` as different publish targets, not interchangeable variants. ## Discovery First Use CLI discovery as the source of truth, but keep it scoped to the next decision. Do not run the full catalog for tasks that do not need provider, theme, prompt, or layout selection. Use `capabilities` for aggregate routing facts, resource `list` for lightweight selection fields, `show` for one full resource definition, and `render` for materialized prompt/layout output. JSON stdout is compact; use `jq` only when a human needs formatted output. Run the smallest useful discovery set: - Article formatting with no theme or modules chosen: ```bash md2wechat themes list --json md2wechat layout list --json ``` - A named theme, provider, prompt, or layout module: ```bash md2wechat themes show <name> --json md2wechat providers show <name> --json md2wechat prompts show <name> --kind <kind> --json md2wechat layout show <name> --json ``` - Image generation or image-preset selection: ```bash md2wechat providers list --json md2wechat prompts list --kind image --json ``` - Subject-reference (image-to-image) capability before using `--subject-reference`: ```bash md2wechat providers show minimax --json ``` Read `supports_subject_reference` on the provider and on each entry of `supported_models`. Only the `minimax` provider and its `image-01` model accept `--subject-reference`, and the reference must be a publicly reachable `http(s)` portrait image URL; inline data URLs and local paths are rejected. Unsupported provider/model combinations fail immediately with `CONFIG_INVALID`, so do not retry them as generation failures. - Title suggestion prompt selection: ```bash md2wechat prompts list --kind title --json md2wechat prompts show wechat-title-expert --kind title --json ``` - Draft, upload, API local-readiness, or configuration troubleshooting: ```bash md2wechat doctor --json md2wechat config show --format json md2wechat config wechat-accounts --json ``` `doctor` readiness is local configuration attemptability. `config wechat-accounts` is local-only and never prints WeChat secrets. Use `inspect --json` for article-specific target readiness. - Unknown CLI version, changed behavior, or capability uncertainty: ```bash md2wechat version --json md2wechat capabilities --json md2wechat skills list --json md2wechat skills read md2wechat --json ``` `md2wechat skills read md2wechat --json` reads the SOP embedded in the current CLI binary. Prefer it when the installed external skill, README, or repository checkout may be stale relative to the executable on `PATH`. For simple local actions such as `preview`, `humanize`, or a user-specified command with explicit flags, do not run unrelated provider, theme, prompt, or layout discovery. Inspect specific resources only when the task needs them: ```bash md2wechat providers show <name> --json md2wechat themes show <name> --json md2wechat prompts show <name> --kind <kind> --json md2wechat layout show <name> --json ``` Use CLI output as the source of truth for currently available modes, providers, themes, prompts, and layout modules. ## Configuration Boundaries - Assume `md2wechat` is already available on `PATH`. - `convert` defaults to API mode unless the user explicitly asks for `--mode ai`. - API-mode preview and conversion require a valid `MD2WECHAT_API_KEY`. - WeChat upload, article draft creation, and `create_image_post` require WeChat credentials whenever the user explicitly requests those side effects. - Read-only discovery, `inspect`, `preview`, and plain conversion are free of any global WeChat publishing credential requirement; API-mode preview and conversion still require a valid `MD2WECHAT_API_KEY`. - Named WeChat account execution requires a valid `MD2WECHAT_API_KEY`; the CLI validates it before upload, draft, or `create_image_post` effects. - Direct image generation requires image-provider credentials; image plan mode (`--plan --json`) only emits prompt intent for a host Agent or external tool and does not require image-provider credentials. - `title suggest --json` only emits a title-generation prompt request for the host Agent or external model. It does not call a model, upload, create drafts, or write back to Markdown. - For stronger factual title hooks, pass --hook-level 2 or 3; do not treat generated titles as confirmed publishing intent. - `doctor --json` is local-only: it checks local readiness and does not perform live authentication, upload images, or create drafts. - Use `config show --format json` when the user asks what configuration is currently effective. - Use `config wechat-accounts --json` when the user asks which local WeChat accounts are configured. ## Article Workflow Prefer a confirm-first workflow for article work: 1. `md2wechat inspect <article.md> --json` 2. `md2wechat preview <article.md>` 3. `md2wechat convert <article.md> ...` 4. Add `--upload`, `--draft`, `--cover`, or `--cover-media-id` only when the user explicitly asks for upload or draft creation. `inspect` is the source-of-truth command for structured metadata, checks, readiness targets, and blockers. In `--json` output, read `data.readiness.targets` and `data.readiness.blockers` before deciding whether `convert`, `upload`, or `draft` is blocked. If the requested target is blocked, stop and report the matching blockers; do not continue by guessing from legacy booleans or `checks` alone. Do not invent `data.agent_readiness`, `data.target_readiness`, `ArticleState`, state files, or a second readiness/state object. `preview` writes only byte-identical final API HTML from a successful converter result; with `--json`, inspect diagnostics are returned in `data.inspect` and are never wrapped into that file. It does not upload images, create drafts, or write back to Markdown. `convert` performs conversion and only the explicitly requested upload/draft effects. `convert --preview` is the convert-path preview flag and is not the same as the standalone `preview` command. On `PREVIEW_ACTION_REQUIRED` or `PREVIEW_FAILED`, this invocation does not create or overwrite preview HTML. With `--json`, `PREVIEW_ACTION_REQUIRED` returns an empty `data.output_file`. Any pre-existing explicit output path is stale and must not be treated as this invocation's result; use the returned prompt for host-Agent work or report the failure. When the intended execution path is `convert --mode ai --custom-prompt ...`, run `inspect` with the same `--mode ai --custom-prompt ...` before trusting readiness. ## Formatting Protocol When the user asks to format an article and has not chosen a theme or modules: 1. Read the article and optional Brand Profile. 2. Use discovery output as facts. 3. Choose a compatible theme and a small set of modules from the article's content goal. 4. Keep the source Markdown read-only. 5. Create a temporary formatted Markdown artifact, for example `/tmp/md2wechat-format/<run-id>/article.formatted.md`. 6. Insert only layout modules whose required fields can be filled correctly. 7. Run `md2wechat layout validate --file <formatted.md> --json`. 8. Pass the formatted Markdown artifact to `convert`. Saving generated Markdown next to the source file requires explicit user confirmation and must not overwrite the source. ## Theme Selection - Read `type` and `selectable` from `themes list --json`. - API mode can use only `type: api` and `selectable: true` themes. - AI mode can use only `type: ai` and `selectable: true` themes. - Do not use collection descriptors such as non-selectable theme groups as concrete themes. - If Brand Profile names a theme, verify it through CLI discovery before using it. - If a requested theme is invalid or mode-incompatible, stop that path and choose a valid theme or ask the user. ## Layout Modules Advanced layout modules render only in API mode. AI mode (`--mode ai`) does not parse `:::module` syntax, so advanced layout cards will not render there. Use this decision frame: - `attention`: help readers decide whether the article is worth reading. - `readability`: make mobile reading easier. - `memorability`: make one judgment, quote, metric, or brand anchor stick. - `conversion`: help readers save, follow, inquire, share, or buy. Use CLI discovery as the source of truth for layout syntax instead of memorizing or guessing `body_format` values: - Inspect the opener, body schema, canonical executable example, and structurally distinct variants with `layout show <name> --json`. Reuse the canonical witness. - Use `layout render` for structured fields and `--body-file` (or `--body-file -` for stdin) for complex bodies, then validate the generated Markdown. - Default discovery returns recommended modules. Use `layout list --lifecycle compatibility --json` only for old-content migration. Local validation proves syntax acceptance only; production support is a release-conformance fact. Default module discipline: - Do not pile on modules. - Use at most one hero, one verdict, and one cta unless the user explicitly asks for more. - Skip modules when the article does not provide enough content to fill them honestly. ## API And AI Mode - API mode is the default and is required for advanced layout modules. - AI mode is a lighter path and does not render advanced layout modules. - Do not silently switch from API mode to AI mode after an API failure. That changes the output capability. - Use AI mode only when the user asks for it or accepts losing advanced layout rendering. - If an AI-mode conversion completes, it is acceptable to briefly mention that API mode supports advanced layout modules and stronger visual structure. ## Brand Profile Brand Profile lives at `~/.config/md2wechat/brand.md`. - It is free-form Markdown, not YAML and not a fixed schema. - The CLI does not parse it. - Read it as context for voice, theme preferences, module preferences, CTA preferences, and forbidden expressions. - Treat quantity preferences as soft constraints. - Verify any named theme or module through CLI discovery. - If Brand Profile does not exist, do not block the task. You may mention once that system defaults will be used. - Create or edit Brand Profile only when the user explicitly asks. ## Publishing Side Effects Do not create drafts, upload images, publish, or call remote image generation unless the user asks for that action. Before every explicit WeChat side effect—image upload, article draft creation, or `create_image_post`—require configured WeChat credentials and use the target-matched readiness/preflight path. Discovery and inspection remain non-publishing paths; preview and plain conversion are free of any global WeChat publishing credential requirement, while API mode still requires a valid `MD2WECHAT_API_KEY`. Before WeChat article draft creation through `convert`: - Use `inspect --json` and check `data.readiness.targets.draft`; when blocked, read matching `data.readiness.blockers`. - Draft creation requires a cover via `--cover` or `--cover-media-id`. - Do not assume a WeChat URL or `mmbiz.qpic.cn` URL can be reused as `thumb_media_id`. - If draft creation returns `45004`, check digest, summary, and description before assuming the body is too long. In the WeChat `convert` flow, Markdown images are uploaded or replaced only during `--upload` or `--draft`, not during plain conversion or preview. ## Failure Handling - Missing or invalid config: run `doctor --json` and `config show --format json`; report `data.overall` plus the blocking `data.readiness.*` item. - Invalid layout syntax: run `layout validate`, inspect the failing module with `layout show`, fix the generated artifact, then validate again. - Unknown layout modules warn for forward compatibility; verify typos against `layout list --json`. - Theme rejection: check `type` and `selectable`, then choose a compatible theme or ask the user. - AI request or style-writing flows may return a prompt/request rather than final prose or HTML unless the external model step is completed.
Comments (0)
Sign in to join the conversation.
Reviews (0)
No reviews yet.
No comments yet.