跪拜 Guibai
← All articles
人工智能

WeMedia (wm) CLI: one command line for publishing articles across Juejin, WeChat, Xiaohongshu, and Zhihu

By 浪遏 ·
Read original on juejin.cn ↗ Google Translate ↗ Alt translation

For developers building multi-platform publishing automation, wm demonstrates a robust architecture for moving content and identity into checkable local artifacts so that writes fail loudly and resumably rather than silently duplicating. Its capability-based extension model and generated schema give AI agents a way to discover platform-specific requirements without hardcoded prompts.

Summary

WeMedia (wm) is a CLI tool (installed as `wm`) that helps AI assistants publish content across multiple Chinese platforms: Juejin, WeChat Official Account, Xiaohongshu, and Zhihu. Its architecture separates each platform's specific rules (like input fields, image limits, and request handling) from the common mechanisms that all platforms share: content preparation, account and session management, execution, and result tracking.

wm builds a publish plan before executing it. A `PlanningService` captures a content snapshot and fixes the target accounts and intended operations; a separate `PublishingService` carries out the steps and records each one. If the network drops mid-publish, operation records and look-back checks distinguish failed from unknown, allowing safe recovery without accidentally duplicating content.

The tool also supports extensibility by organizing platform features as declarative capabilities with Zod-defined inputs, which feed both TypeScript inference and JSON Schema that AI assistants can query. A new platform requires implementing login, capability declarations, content conversion, and step orchestration, but can reuse the common content snapshot, account binding, task records, and result query mechanisms.

Takeaways
— wm is an open-source CLI that publishes content to Juejin, WeChat Official Account, Xiaohongshu, and Zhihu, with each platform support differing: WeChat and Juejin support editing existing drafts, Xiaohongshu only handles image-and-text notes without drafts, and Zhihu supports creating/reading/publishing column drafts but not updating.
— The architecture separates platform-specific rules from shared mechanisms through five layers: entry, content preparation, execution, account/session, and platform adapters.
— Content preparation and execution are split into separate services (PlanningService and PublishingService), so users can inspect a preview plan before any remote side effects occur.
— Content snapshots use content digests and an ObjectStore to fix the exact bytes to publish, so editing a local file later does not alter an already-created plan.
— Task binding is to a stable identity of user account plus real account, not just the account alias, so rebinding the alias does not redirect old tasks.
— Each step of a publish writes an OperationRecord with status and remote references; on recovery, completed steps are skipped, unperformed steps can proceed, and uncertain states stay pending.
— Platform capabilities are declared per platform with Zod-defined inputs that generate both TypeScript types and JSON Schema for AI queries, and Command syntax comes from the Commander tree to keep CLI help in sync.
— Adding a new platform needs login/identity handling, capability declarations, content preparation, step orchestration, and registration in builtins.ts, but can reuse common services.
— The tool does not claim exactly-once semantics across all platforms; it reduces duplication and provides evidence for manual or scheduled checks when status is unknown.
— The article itself was produced using wm: screenshots via `wm content screenshot`, diagrams via `wm content diagram`, and a Juejin publish plan via `wm article plan` and `wm plan run`.
Conclusions

Capability declarations rather than a single unified interface are a pragmatically honest way to model platforms that differ drastically: callers get an explicit unavailable result instead of a fake success.

The separation of plan preparation from execution is an exercise in diff-friendly delegation: AI can see and approve the intended side effects before they become irreversible.

Treating a task as a snapshot of content plus a list of recorded facts makes recovery a matter of reconciling evidence rather than guessing intent.

The tool's explicit acknowledgment that network resends can be ambiguous is a useful departure from overclaiming at-least-once or exactly-once semantics in distributed systems.

Generating JSON Schema from the same Zod input definitions that drive TypeScript types closes a loop for AI agents: they can discover what the tool accepts without being hand-coded per platform.

Concepts & terms
Content snapshot (内容快照)
A frozen copy of the article text and assets, identified by content digest, representing exactly what is intended to be published. It lets a plan be recovered even if the source file is later edited.
Capability (能力)
A declared operation a platform exposes, with input and output contracts and a query or write classification. Examples include saving drafts, reading articles, and publishing.
Operation record (操作记录)
A persisted log entry per write step that includes status, remote references, and look-back information, used to decide how to resume after failures or interruptions.
Look-back (回查)
The process of querying a platform to determine whether a previously attempted operation actually completed, used to avoid duplicate writes when network failures leave ambiguity.
Content digest (内容摘要)
A fingerprint computed from the exact content bytes, used to verify integrity and detect when a file has changed without relying on path.
Source: juejin.cn ↗ Google Translate ↗ Backup ↗