Skip to content

topmindspace/topmind-writing-skills / topmind-x-article

topmind-x-article

Verified

创作或整理 X Article 深度长文,支持论点推进、工具/插件介绍、产品实测评测与多源研究;按需导出可复制 HTML、纯文本、封面与发布清单。普通短帖用 topmind-briefs 或 topmind-viral-posts,纯格式化用 topmind-format。

FileKindSize
.gitignoreother31 B
README.en.mdmarkdown1.7 KB
README.mdmarkdown2.0 KB
SKILL.mdskill md4.6 KB
examples/01-长文-慢慢写.mdmarkdown1.8 KB
examples/02-长文-周末短途.mdmarkdown1.4 KB
examples/README.mdmarkdown716 B
knowledge/README.mdmarkdown9.4 KB
knowledge/cards/atlas-local-fix.mdmarkdown781 B
knowledge/cards/brief-news-to-post.mdmarkdown3.0 KB
knowledge/cards/brief-news.mdmarkdown916 B
knowledge/cards/brief-paper.mdmarkdown760 B
knowledge/cards/brief-tools.mdmarkdown617 B
knowledge/cards/brief-value-first.mdmarkdown3.1 KB
knowledge/cards/cover-abstract.mdmarkdown1.3 KB
knowledge/cards/cover-brief.mdmarkdown1.3 KB
knowledge/cards/cover-collage.mdmarkdown1.3 KB
knowledge/cards/cover-color.mdmarkdown1.2 KB
knowledge/cards/cover-culture.mdmarkdown1013 B
knowledge/cards/cover-editorial.mdmarkdown1.2 KB
knowledge/cards/cover-material.mdmarkdown1.3 KB
knowledge/cards/cover-photo.mdmarkdown1.1 KB
knowledge/cards/cover-playful.mdmarkdown1.0 KB
knowledge/cards/cover-scene.mdmarkdown962 B
knowledge/cards/cover-series.mdmarkdown1017 B
knowledge/cards/cover-typography.mdmarkdown1.3 KB
knowledge/cards/creative-choice.mdmarkdown807 B
knowledge/cards/crop-independent.mdmarkdown719 B
knowledge/cards/de-ai-mechanisms.mdmarkdown3.6 KB
knowledge/cards/experience-loop.mdmarkdown801 B
knowledge/cards/format-fidelity.mdmarkdown501 B
knowledge/cards/format-layouts.mdmarkdown502 B
knowledge/cards/poster-paging.mdmarkdown726 B
knowledge/cards/poster-structure.mdmarkdown646 B
knowledge/cards/poster-voices.mdmarkdown530 B
knowledge/cards/reference-reading.mdmarkdown857 B
knowledge/cards/revise-depth.mdmarkdown677 B
knowledge/cards/revise-feedback.mdmarkdown609 B
knowledge/cards/revise-learn-from-edits.mdmarkdown3.1 KB
knowledge/cards/revise-preserve.mdmarkdown788 B
knowledge/cards/viral-mechanisms.mdmarkdown535 B
knowledge/cards/viral-observation.mdmarkdown544 B
knowledge/cards/viral-play-dumb.mdmarkdown2.8 KB
knowledge/cards/viral-replies.mdmarkdown722 B
knowledge/cards/visual-density-and-evidence.mdmarkdown2.8 KB
knowledge/cards/voice-peer-stance.mdmarkdown2.7 KB
knowledge/cards/wechat-decide.mdmarkdown746 B
knowledge/cards/wechat-explain.mdmarkdown820 B
knowledge/cards/wechat-plugin-and-review.mdmarkdown2.5 KB
knowledge/cards/wechat-story.mdmarkdown798 B
knowledge/cards/x-adapt.mdmarkdown643 B
knowledge/cards/x-argument.mdmarkdown770 B
knowledge/cards/x-evidence.mdmarkdown608 B
knowledge/index.jsonconfig39.9 KB
package.jsonmanifest445 B
references/core-voice.mdmarkdown9.9 KB
references/creative-practice.mdmarkdown5.0 KB
references/de-ai-rules.mdmarkdown17.9 KB
references/image-sourcing.mdmarkdown2.7 KB
references/information-design.mdmarkdown5.0 KB
references/knowledge-library.mdmarkdown5.5 KB
references/platform-cover-specs.mdmarkdown7.4 KB
references/platform-operations.mdmarkdown2.5 KB
references/publish-checklist.mdmarkdown2.2 KB
references/research-mode.mdmarkdown1.6 KB
references/revision-workflow.mdmarkdown5.9 KB
references/social-writing-principles.mdmarkdown7.7 KB
references/workspace.mdmarkdown2.3 KB
references/x-delivery-contract.mdmarkdown3.6 KB
references/x-format.mdmarkdown3.5 KB
references/x-html-format.mdmarkdown6.8 KB
references/x-post-format.mdmarkdown2.5 KB
scripts/article_scaffold.pyscript5.6 KB
scripts/audit-provenance.pyscript14.9 KB
scripts/audit_css.pyscript1.1 KB
scripts/audit_docs.pyscript3.1 KB
scripts/audit_skill.pyscript3.1 KB
scripts/audit_styles.pyscript1.6 KB
scripts/check_article.pyscript13.9 KB
scripts/count_words.pyscript3.0 KB
scripts/de_ai_lint.pyscript41.5 KB
scripts/info_design_hints.pyscript14.2 KB
scripts/knowledge.pyscript11.8 KB
scripts/lint_x_post.pyscript20.0 KB
scripts/md2x-html.pyscript39.8 KB
scripts/md2x.pyscript15.4 KB
scripts/negative_tests.pyscript10.5 KB
scripts/package_skill.pyscript6.6 KB
scripts/revise_check.pyscript15.2 KB

scripts/negative_tests.py

View on GitHub
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""topmind-x-article 异常输入测试:md2x.py 在各种坏输入下不崩溃(任一失败 → 退出码 1)。"""
from __future__ import annotations

import subprocess
import sys
import tempfile
from pathlib import Path

try:
    sys.stdout.reconfigure(encoding="utf-8", errors="replace")
except Exception:
    pass

ROOT = Path(__file__).resolve().parent.parent
MD2X = ROOT / "scripts" / "md2x.py"
PY = sys.executable
fails: list[str] = []


def run(args: list[str]) -> subprocess.CompletedProcess:
    return subprocess.run([PY, str(MD2X), *args], capture_output=True, text=True, timeout=30)


def check(name: str, cond: bool, detail: str = "") -> None:
    print(("  ✓ " if cond else "  ✗ ") + name + (f" — {detail}" if detail and not cond else ""))
    if not cond:
        fails.append(name)


def main() -> None:
    print("[negative_tests] topmind-x-article")
    with tempfile.TemporaryDirectory() as td:
        td = Path(td)

        # 1. 空文件
        (td / "empty.md").write_text("", encoding="utf-8")
        r = run([str(td / "empty.md"), "--out", str(td / "o1.txt")])
        check("空文件不崩溃", r.returncode == 0 and "Traceback" not in r.stderr)

        # 2. 只有 frontmatter
        (td / "fm.md").write_text("---\ntitle: t\n---\n", encoding="utf-8")
        r = run([str(td / "fm.md"), "--out", str(td / "o2.txt")])
        check("纯 frontmatter 不崩溃", r.returncode == 0 and "Traceback" not in r.stderr)

        # 3. 未闭合代码围栏
        (td / "fence.md").write_text("# t\n\n```python\nprint(1)\n", encoding="utf-8")
        r = run([str(td / "fence.md"), "--out", str(td / "o3.txt")])
        check("未闭合围栏不崩溃", r.returncode == 0 and "Traceback" not in r.stderr)

        # 4. 无分隔行的表格
        (td / "tbl.md").write_text("# t\n\n| a | b |\n| 1 | 2 |\n", encoding="utf-8")
        r = run([str(td / "tbl.md"), "--out", str(td / "o4.txt")])
        check("异常表格不崩溃", r.returncode == 0 and "Traceback" not in r.stderr)

        # 5. 不存在的输入 → 非零退出且无 Traceback
        r = run([str(td / "nope.md"), "--out", str(td / "o5.txt")])
        check("缺失输入干净报错", r.returncode != 0 and "Traceback" not in r.stderr)

        # 6. 正常输入产出配图清单
        (td / "ok.md").write_text("# t\n\n![a](x.png)\n", encoding="utf-8")
        r = run([str(td / "ok.md"), "--out", str(td / "o6.txt")])
        out = (td / "o6.txt").read_text(encoding="utf-8") if (td / "o6.txt").exists() else ""
        check("正常输入含配图清单", r.returncode == 0 and "[图1]" in out)

        # 7. 嵌套围栏:```` 开栏不被内层 ``` 提前闭合(内层栏是代码内容)
        (td / "nest.md").write_text(
            "# t\n\n````markdown\n外层\n```python\nprint(1)\n```\n结束\n````\n",
            encoding="utf-8")
        r = run([str(td / "nest.md"), "--out", str(td / "o7.txt")])
        out = (td / "o7.txt").read_text(encoding="utf-8") if (td / "o7.txt").exists() else ""
        check("嵌套围栏不提前闭合",
              r.returncode == 0 and "    ```python" in out and "print(1)" in out)

        # 8. 括号 URL 链接不断裂(与 md2wechat 对齐的守卫)
        (td / "paren.md").write_text(
            "# t\n\n[维基](https://zh.wikipedia.org/wiki/猫_(动物))\n", encoding="utf-8")
        r = run([str(td / "paren.md"), "--out", str(td / "o8.txt")])
        out = (td / "o8.txt").read_text(encoding="utf-8") if (td / "o8.txt").exists() else ""
        check("括号 URL 不截断",
              r.returncode == 0 and "猫_(动物)" in out)

        # 9. 列表转 emoji 项目符号(X 纯文本不渲染 Markdown 列表),代码块内不动;--list-style keep 保留原符号
        (td / "lst.md").write_text(
            "# t\n\n- 一\n- 二\n  - 二点一\n    - 更深\n\n1. 步骤一\n2. 步骤二\n\n```\n- 代码里的\n```\n\n-5% 不是列表\n",
            encoding="utf-8")
        r = run([str(td / "lst.md"), "--out", str(td / "o9.txt")])
        out = (td / "o9.txt").read_text(encoding="utf-8") if (td / "o9.txt").exists() else ""
        check("列表默认 plain(「· 」「1)」,二级缩进两格)",
              r.returncode == 0 and "· 一" in out and "  · 二点一" in out and "  · 更深" in out
              and "1)步骤一" in out and "2)步骤二" in out and "🔹" not in out)
        r = run([str(td / "lst.md"), "--out", str(td / "o9e.txt"), "--list-style", "emoji"])
        oute = (td / "o9e.txt").read_text(encoding="utf-8") if (td / "o9e.txt").exists() else ""
        check("--list-style emoji 仍可用(两层缩进、序号 keycap)",
              r.returncode == 0 and "🔹 一" in oute and "  ▫️ 二点一" in oute and "  ▫️ 更深" in oute
              and "1️⃣ 步骤一" in oute and "2️⃣ 步骤二" in oute)
        check("代码块内的 - 不被改写、-5% 不被当列表",
              "    - 代码里的" in out and "-5% 不是列表" in out)
        r = run([str(td / "lst.md"), "--out", str(td / "o10.txt"), "--list-style", "keep"])
        out = (td / "o10.txt").read_text(encoding="utf-8") if (td / "o10.txt").exists() else ""
        check("--list-style keep 保留原符号", r.returncode == 0 and "- 一" in out and "1. 步骤一" in out)

        # 10. 文章文件夹结构:md2x / md2x-html 直接读 <文章名>.md,产物缺省进 out/
        import base64 as _b64
        png = _b64.b64decode("iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAADUlEQVR42mNk"
                             "+M9QDwADhgGAWjR9awAAAABJRU5ErkJggg==")
        art = td / "示例文章"
        for d in ("images", "cover", "out"):
            (art / d).mkdir(parents=True)
        (art / "images" / "01-first.png").write_bytes(png)
        (art / "images" / "02-second.png").write_bytes(png + b"\x00second")
        (art / "cover" / "cover-1500x600.png").write_bytes(png)
        (art / "示例文章.md").write_text(
            "---\ntitle: 示例文章\ndate: 2026-01-01\nstatus: 草稿\ntags: []\n"
            "cover: cover/cover-1500x600.png\n---\n\n# 示例文章\n\n开头。\n\n"
            "![第一张](images/01-first.png)\n\n来源:某官方文档\n\n中段。\n\n"
            "![第二张](images/02-second.png)\n\n```\n![代码里的](images/none.png)\n```\n",
            encoding="utf-8")
        html_script = ROOT / "scripts" / "md2x-html.py"
        r = subprocess.run([PY, str(html_script), str(art / "示例文章.md")],
                           capture_output=True, text=True, timeout=30)
        outp = art / "out" / "X长文.html"
        html = outp.read_text(encoding="utf-8") if outp.exists() else ""
        b1 = _b64.b64encode(png).decode()
        b2 = _b64.b64encode(png + b"\x00second").decode()
        check("md2x-html 直接读 ![](),按文档顺序嵌图到 out/X长文.html",
              r.returncode == 0 and html.count('<figure class="ximg"') == 2
              and 0 <= html.find(b1) < html.find(b2), (r.stdout + r.stderr)[-300:])
        check("md2x-html「来源:」行成小号图注、代码块里的 ![]() 不动",
              '<p class="src">来源:某官方文档</p>' in html and "代码里的" in html)
        check("md2x-html 缺省读 frontmatter cover", "cover-1500x600" in html or html.count("data:image/png") == 3,
              str(html.count("data:image/png")))
        src = (art / "示例文章.md").read_text(encoding="utf-8")
        (art / "示例文章.md").write_text(src.replace("title: 示例文章\n", "title: 示例文章\nsubtitle: 过去、现在和明年\n"), encoding="utf-8")
        r = subprocess.run([PY, str(html_script), str(art / "示例文章.md")], capture_output=True, text=True, timeout=30)
        html = outp.read_text(encoding="utf-8") if outp.exists() else ""
        check("md2x-html subtitle 只在 no-paste 预览里出现一次",
              r.returncode == 0 and html.count("过去、现在和明年") == 1 and 'class="cover-note no-paste" id="subtitlebox"' in html,
              (r.stdout + r.stderr)[-300:])
        (art / "示例文章.md").write_text(src, encoding="utf-8")
        (art / "旧.md").write_text("# t\n\n[图1]\n", encoding="utf-8")
        r = subprocess.run([PY, str(html_script), str(art / "旧.md"), "--out", str(td / "x.html")],
                           capture_output=True, text=True, timeout=30)
        check("md2x-html 有 [图N] 却没给图片来源 → 干净报错",
              r.returncode != 0 and "--images-from" in r.stderr and "Traceback" not in r.stderr, r.stderr[-200:])
        r = run([str(art / "示例文章.md")])
        txt = art / "out" / "X发布稿.txt"
        check("md2x 缺省输出到 out/X发布稿.txt",
              r.returncode == 0 and txt.is_file() and "[图1]" in txt.read_text(encoding="utf-8"),
              (r.stdout + r.stderr)[-200:])
        r = subprocess.run([PY, str(ROOT / "scripts" / "check_article.py"), str(art)],
                           capture_output=True, text=True, timeout=30)
        check("check_article 示例文章结构通过", r.returncode == 0, r.stdout[-300:])

        # HTML 注释(写作提示、骨架备注)不进派生产物;代码里的原样保留
        (td / "cm.md").write_text("# t\n\n<!-- 写作提示:先放结论 -->\n第一段 <!-- 行内备注 --> 正文。\n\n<!--\n骨架备注\n-->\n第二段 `<!-- 行内代码 -->`。\n\n```html\n<!-- 围栏保留 -->\n```\n", encoding="utf-8")
        r = run([str(td / "cm.md"), "--out", str(td / "cm.txt")])
        t = (td / "cm.txt").read_text(encoding="utf-8") if (td / "cm.txt").exists() else ""
        check("md2x 去掉 HTML 注释、保留代码里的 <!--",
              r.returncode == 0 and all(k not in t for k in ("写作提示", "行内备注", "骨架备注"))
              and "第一段 正文。" in t and "行内代码" in t and "围栏保留" in t, t[:300])
        r = subprocess.run([PY, str(ROOT / "scripts" / "md2x-html.py"), str(td / "cm.md"), "--out", str(td / "cm.html")],
                           capture_output=True, text=True, timeout=30)
        h = (td / "cm.html").read_text(encoding="utf-8") if (td / "cm.html").exists() else ""
        check("md2x-html 去掉 HTML 注释、保留代码里的 <!--",
              r.returncode == 0 and all(k not in h for k in ("写作提示", "行内备注", "骨架备注"))
              and "行内代码" in h and "围栏保留" in h, (r.stdout + r.stderr)[-300:])

    if fails:
        print(f"\n[negative_tests] {len(fails)} 项失败")
        sys.exit(1)
    print("\n[negative_tests] 全部通过")


if __name__ == "__main__":
    main()
slack-gif-creatoranthropics/skillsKnowledge and utilities for creating animated GIFs optimized for Slack. Provides constraints, validation tools, and animation concepts. Use when users request animated GIFs for Slack like "make me a GIF of X doing Y for Slack."Stars: 198kUpdated Claude CodeCodexVerifiedInstall
ponytailDietrichGebert/ponytailLazy senior dev mode for any coding task: the smallest change that fully solves it, and a reply a busy human understands in one read.Stars: 194kUpdated Claude CodeCodexVerifiedInstall
ponytail-debtDietrichGebert/ponytailHarvest every shortcut: comment into one debt ledger, so deferrals get tracked instead of forgotten. One-shot report.Stars: 194kUpdated Claude CodeCodexVerifiedInstall
ponytail-debtDietrichGebert/ponytailList every `shortcut:` comment (and older `ponytail:` ones) as a debt ledger. One-shot report, changes nothing. Use for "ponytail debt", "what did ponytail defer", "list the shortcuts", /ponytail-debt.Stars: 194kUpdated Claude CodeCodexVerifiedInstall