wechat-to-ima
Save WeChat Official Account articles into IMA notes or into a named IMA knowledge base with preserved article structure. Use when the user sends an mp.weixin.qq.com link and wants to save, archive, import, collect, or store the article in IMA/笔记/知识库. Handles parsing article metadata, preserving inline body images in order, falling back to the cover image when the body has no images, then either saving to IMA notes or resolving a target knowledge base and adding the article there. When the user asks for a 知识库, route only to that knowledge base and do not create an extra user-visible IMA note.
WeChat to IMA
Save a WeChat article into IMA with two user-facing flows:
- 解析公众号文章 → 存到 IMA 笔记
- 解析公众号文章 → 查知识库 → 加入该知识库
不要把内部实现细节当成用户流程来描述。
Workflow
- Parse the WeChat article.
- Keep inline body images in original order.
- If the body contains no inline images, insert the cover image near the top.
- If the user wants 笔记: save into IMA notes and read back once to verify the note is not empty.
- If the user wants 知识库: resolve the target knowledge base by name or ID, then add the parsed article there as a Markdown knowledge item.
Flow mapping
scripts/save_wechat_to_ima.py <url>→ 解析公众号文章 → 存到 IMA 笔记scripts/save_wechat_to_ima.py <url> <knowledge_base_name_or_id>→ 解析公众号文章 → 查知识库 → 加入该知识库
Requirements
IMA_OPENAPI_CLIENTIDandIMA_OPENAPI_APIKEYmust be available in the environment, or stored in~/.config/ima/client_idand~/.config/ima/api_key.- Run
npm installonce inside this skill directory so the bundled extractor dependencies are available. skills/ima-skill/ima_api.cjsis used when present, so this skill stays aligned with the latest IMA OpenAPI wrapper and error handling.
Output
The script prints JSON with:
titleaccountauthorpublish_timebody_img_countcover_usedmarkdown_pathnote_idreadback_okknowledge_base_name(when requested)knowledge_base_id(when requested)knowledge_media_id(when requested)knowledge_file_name(when requested)
Notes
- Prefer this skill over ad-hoc manual parsing when the user wants the article stored in IMA.
- This skill is self-contained for article parsing and does not depend on a separate
wechat-article-extractorinstallation. - The IMA readback check uses plain text, so it confirms content landed successfully but does not visually render images in the terminal output.
- When the user names a target knowledge base, this skill resolves the knowledge base by name and routes the article into that knowledge base only.
- Knowledge-base mode should not create an extra user-visible IMA note. Instead, upload the rebuilt Markdown into the target knowledge base as the final artifact.
- Strict target rule: if the user specified a knowledge-base name, do not silently substitute another addable knowledge base. If exact resolution fails, stop and report that the requested target is not found/accessible, then use a logged-in IMA desktop/web session or ask for the exact knowledge-base ID.
- If parsing succeeds but the article body has no inline images, that is expected for some articles; use the cover-image fallback instead of treating it as a failure.
- If the original article contains code or code-block-style content, preserve it as fenced Markdown code blocks when importing into IMA; do not flatten code into ordinary prose.
Related skills
- Downloads
- 929All time
- Security audit
- Review
- Last updated
- 2mo ago
- Current version
- v1.2.2
- License
- MIT-0
