khlilo

Cognitive Writer v2.0.2(AI Writing Engine)

2026-03-16
RustTokioClapLLM API

面向微信公众号的 AI 文章生成 CLI 工具

痛点:AI 生成的文章没人味

用 AI 写文章最大的问题不是写不出来,而是写出来的每篇都像同一个模板——没有你的语气、你的节奏、你的思维方式。

公众号和博客写作的 AI 工具越来越多,但几乎所有工具都面临同一个问题:生成的文章千篇一律、缺乏个人辨识度。你需要的不是"AI 帮你写",而是"AI 用你的风格写"。

核心架构:骨架-渲染双通道

采用 骨架-渲染(CoT)双通道架构,解决单次长文生成的逻辑坍缩/重复问题。

                         Pass 1 (骨架)              Pass 2 (渲染)
inputs/idea_01.md ──┬─→ OUTLINE_SYSTEM_PROMPT ─→ outline ──┐
                    │                                       ├─→ style prompt ─→ Markdown ─┬─→ outputs/{slug}_v{N}.md
styles/*.md ────────┘───────────────────────────────────────┘                              ├─→ outputs/{slug}_v{N}.html
                                                                                          └─→ 系统剪贴板(富文本)

Pass 1 — 骨架生成:让 LLM 先输出 300-500 字的结构化大纲,包含核心论点、支撑素材方向、段落衔接关系。

Pass 2 — 正文渲染:将大纲 + 原始素材 + 风格 prompt 拼接,让 LLM 按骨架逐段展开完整正文。

这种分离是为了控制单次生成的信息密度——AI 在处理短文本时质量更高。

三大子命令

generate — 文章生成

选择风格模板 → 读取素材 → 双通道 LLM 调用 → 三轨输出(Markdown 归档 + 微信 HTML + 剪贴板注入)。

learn — 风格逆向学习

输入一篇文章 URL,通过 Jina Reader 抓取正文,LLM 从 10 个维度分析写作风格(整体风格定位、标题策略、开头模式、段落节奏、句式特征、论证手法、情绪基调、结尾策略、用词偏好、读者互动方式),输出可复用的 system prompt。

refine — 局部重绘

在 Markdown 中插入 <AI_EDIT instruction="..."> 标记,工具自动识别并调用 LLM 重写标记内的文本,同时保持与上下文风格一致。适合精修段落而不是重写全文。

输出:微信兼容富文本

生成的 Markdown 自动转换为微信公众号兼容的 HTML 格式,并通过 CF_HTML 协议注入系统剪贴板。在 WSL2、Linux、Windows 三端都能一键粘贴到微信编辑器。

跨平台剪贴板注入优先级:

| 优先级 | 环境 | 方法 | |--------|------|------| | 1 | WSL2 | PowerShell CF_HTML(绕过 .NET UTF-16 编码,解决中文乱码) | | 2 | Linux X11 | xclip -selection clipboard -t text/html | | 3 | Linux Wayland | wl-copy --type text/html |

风格模板系统

每个 .md 文件是一个完整的 LLM system prompt,控制文章生成的风格。

wechat_base.md 核心规则:

  • 反 AI 清单:禁用"众所周知"、"不可否认"等套话,禁止"三段并列+升华"公式
  • 人称:第一人称"我"为主
  • 句长:以短为主(10-20 字),偶尔长句调节节奏
  • 结构:开头直给洞察 → 核心概念一句话定义 → 2-3 论点+具体案例 → 最小可行动作

AI 协作过程

用 Claude Code 协作开发,Rust 从零搭建 CLI 骨架。核心设计围绕对模型能力的理解展开:双通道分离是信息密度控制,风格学习是 few-shot prompt 的自动化提取,局部重绘利用了模型对上下文标记的遵循能力。

项目链接

GitHub

The Problem: AI Writes Like Everyone Else

The biggest issue with AI writing isn't that it can't write — it's that everything sounds like the same template. No your voice, no your rhythm, no your thinking.

More AI writing tools are emerging, but they all share the same flaw: generic output with zero personal identity. What you need isn't "AI to write for you" but "AI to write as you."

Core Architecture: Skeleton-Render Dual Channel

采用 Skeleton-Render (CoT) dual-channel architecture to solve the logic collapse and repetition problem in single-pass long-form generation.

                         Pass 1 (Skeleton)          Pass 2 (Render)
inputs/idea_01.md ──┬─→ OUTLINE_SYSTEM_PROMPT ─→ outline ──┐
                    │                                       ├─→ style prompt ─→ Markdown ─┬─→ outputs/{slug}_v{N}.md
styles/*.md ────────┘───────────────────────────────────────┘                              ├─→ outputs/{slug}_v{N}.html
                                                                                          └─→ System clipboard (rich text)

Pass 1 — Skeleton: LLM generates a 300-500 word structured outline with core arguments, supporting material directions, and paragraph transitions.

Pass 2 — Render: Outline + raw material + style prompt are concatenated, and LLM expands the full text paragraph by paragraph following the skeleton.

This separation controls information density per call — LLMs produce higher quality on shorter texts.

Three Subcommands

generate — Article Generation

Select style template → Load material → Dual-channel LLM calls → Triple output (Markdown archive + WeChat HTML + clipboard injection).

learn — Style Reverse Learning

Input an article URL, fetch content via Jina Reader, LLM analyzes writing style across 10 dimensions (overall style positioning, title strategy, opening pattern, paragraph rhythm, sentence characteristics, argumentation methods, emotional tone, closing strategy, word preferences, reader interaction style), outputs a reusable system prompt.

refine — Local Redraw

Insert <AI_EDIT instruction="..."> markers in Markdown. The tool automatically detects them and calls LLM to rewrite the marked text while maintaining style consistency with surrounding context. Ideal for polishing paragraphs, not rewriting entire articles.

Output: WeChat-Compatible Rich Text

Generated Markdown is automatically converted to WeChat-compatible HTML and injected into the system clipboard via CF_HTML protocol. One-click paste into the WeChat editor on WSL2, Linux, and Windows.

Cross-platform clipboard injection priority:

| Priority | Environment | Method | |----------|-------------|--------| | 1 | WSL2 | PowerShell CF_HTML (bypasses .NET UTF-16 encoding, fixes Chinese garbled text) | | 2 | Linux X11 | xclip -selection clipboard -t text/html | | 3 | Linux Wayland | wl-copy --type text/html |

Style Template System

Each .md file is a complete LLM system prompt that controls article generation style.

wechat_base.md core rules:

  • Anti-AI checklist: Banned phrases like "as we all know", "undeniably"; no "three-parallel + elevation" formula
  • Person: First person "I" primarily
  • Sentence length: Short为主 (10-20 chars), occasional long sentences for rhythm
  • Structure: Opening insight → One-sentence concept definition → 2-3 arguments with concrete examples → Minimal actionable takeaway

AI Collaboration

Built from scratch with Claude Code. The core design revolves around understanding model capabilities: dual-channel separation is information density control, style learning is automated few-shot prompt extraction, and local redraw leverages the model's ability to follow contextual markers.

Links

GitHub