首页 / 全部技能 / 设计 / social-x-post-card
设计 · nexu-io/html-anything

social-x-post-card

拟真 X 推文卡片 + 互动数据 (likes/reposts/views), 适配视频叠加或图卡分享

L3 联网 · 声明域名与密钥范围V1 已固定联网Dual-pass Audit
Author nexu-ioGitHub nexu-io/html-anything ↗Stars 8827License Apache-2.0(仓库根 LICENSE = Apache License 2.0;GitHub API spdx_id=Apache-2.0)Commit 553ed98c28
管控等级描述 skill 的能力与建议配套的管控措施,不代表质量或安全认证,也不表示可用或不可用。是否使用由用户和管理者决定。不同 agent 宿主对权限的约束各不相同,请勿假定宿主一定会提供安全兜底。第三方 skill 版权归原作者,使用风险由使用者自行承担。

1实现原理 · 为什么它能做到

本模板是「文件夹即模板」结构里的一份纯数据:SKILL.md 用 YAML frontmatter 供选择器使用,正文是给 agent 的版式指令;仓库不为单个模板写任何代码,新增模板=新增一个文件夹。

next/src/lib/templates/loader.ts
SKILL.md — frontmatter (id, scenario, tags, …) + prompt body
loader.ts 在文件头注释里写明目录约定;frontmatter 由进程内正则解析(无 YAML 依赖),正文原样作为 prompt body 取出,前端不会拿到(「Body is excluded so we can return the entire registry in one cheap fetch without shipping prompt text to the browser.」)。

运行时由宿主把本模板正文夹在共享设计指令与用户内容之间拼成一次 prompt —— 模板的「智能」全在这段自然语言里,没有可执行代码。

next/src/lib/templates/shared.ts
return `${SHARED_DESIGN_DIRECTIVES} ${opts.body.trim()}
assemblePrompt 的返回是「共享设计指令 + 模板正文 + 【输入格式】+【用户内容】」。共享段(同一文件 SHARED_DESIGN_DIRECTIVES)负责单文件 HTML、Tailwind/字体 CDN、内容驱动数量、禁止使用文件系统工具等硬性要求,对所有模板一致,不是本模板自带。

宿主的 /api/convert 载入该模板后把这些文字交给本地已登录的 coding-agent CLI,只把 stdout 当 HTML 流式回收;模板本身不发网络、不读凭证、不写文件。

next/src/app/api/convert/route.ts
prompt = assemblePrompt({ body: skill.body, content, format });
同一 route 随后调用 invokeAgent({ … }) 拉起 CLI(claude / codex / cursor-agent 等,由宿主 PATH 探测);与其配套的共享指令还明写「**禁止使用 Write / Edit / MultiEdit / Bash / Create / 任何文件系统工具**」。

随模板附带的 example.html 是「预渲染示例」,由预览接口原样吐出、进入选择器与画廊的 iframe —— 它决定模板卡片有没有可视预览,不参与内容生成。

next/src/app/api/templates/[id]/preview/route.ts
Returns the skill's `example.html` verbatim so it can be loaded into an
预览按 skill id 缓存(Cache-Control: public, max-age=300);前端在预览面板里给 iframe 加了 sandbox="allow-scripts allow-same-origin"(宿主侧实现,本模板不可控)。

frontmatter 的字段被逐项映射成选择器元数据(featured 决定全量排序、recommended 进顶部「★ 推荐」组、example_* 生成示例卡文案),并决定它在分类/场景过滤里出现在哪里。

next/src/lib/templates/loader.ts
if (typeof fm.featured === "number") meta.featured = fm.featured;
fmToMeta 同时把 category/scenario/aspectHint/tags 直接搬到 SkillMeta;example 块在 example_id 或 example.{md,html} 存在时生成(id/name/format/tagline/desc + 可选 source)。这些字段只影响展示与排序,不影响生成行为。

该模板的生成能力全部由它自己的正文兑现:social-x-post-card/SKILL.md 只描述版面、配色、字体与内容纪律,没有一句让 agent 去跑工具、取接口或读外部数据。

next/src/lib/templates/skills/social-x-post-card/SKILL.md
【模板: X (Twitter) 帖子卡】
skill 目录共 2–3 个文件(SKILL.md + example.html[+ example.md]),无 scripts/references/数据文件;example.html 只是同一模板的人工示例产物(见 internal_assets)。

意图是把推文或用户金句渲染成拟真度极高的 X 帖子卡,注明灵感来自 hyperframes 的 x-post。

next/src/lib/templates/skills/social-x-post-card/SKILL.md
【意图】把一段推文内容 (或用户的金句) 渲染成一张拟真度极高的 X 帖子卡片, 用于视频叠加、推特发图、知识沉淀。Inspired by hyperframes x-post。

卡面结构由头像 + 用户名 + handle + verified 蓝勾 + 时间组成,头像明确要求用 CSS gradient 占位。

next/src/lib/templates/skills/social-x-post-card/SKILL.md
- 顶部 row: 头像 (48×48 圆形, 用 CSS gradient 占位) + 用户名 + handle `@username` + verified 蓝勾 + 时间 (mono, 12px, 灰)。

互动数据要求按平台习惯格式化,不允许出现原始整数。

next/src/lib/templates/skills/social-x-post-card/SKILL.md
- 数字格式化: 1.2K / 4.5M (不要原始 1234)。

内容纪律:必须来自用户输入,不能编造推文。

next/src/lib/templates/skills/social-x-post-card/SKILL.md
- 内容必须来自用户输入, 不能编造推文。

非推文输入会被自动转成金句,且受 X 的 280 字符约束。

next/src/lib/templates/skills/social-x-post-card/SKILL.md
- 若用户输入是数据 → 自动总结成一句"金句"推文 (≤ 280 字符)。

素材约束:单文件 HTML、icon 内联 SVG、不要任何外部图片 URL。

next/src/lib/templates/skills/social-x-post-card/SKILL.md
- 单文件 HTML; icon 内联 SVG; 不要任何外部图片 URL。

示例产物用内联 SVG 还原 X 蓝勾与互动图标,互动数字做了 K 格式化。

next/src/lib/templates/skills/social-x-post-card/example.html
<span style="color:#f91880">12.3K</span>

2核心能力

01拟真 X 帖子卡(头像 / handle / 蓝勾 / 时间 顶部行)
02互动数据行(回复 / 转推 / 引用 / 点赞,内联 SVG 官方风格图标)
03数字格式化(1.2K / 4.5M,不出原始整数)
04明暗双配色(dark 推荐用于视频叠加)
05可选引用卡与 16:9 图片占位(CSS 渐变,不引外链)
06数据输入 → ≤280 字符金句推文
07示例产物:金句推文 + 12.3K likes / 482 回复 / 2.1M 浏览

3外部依赖

KindDependency / Endpoint
networkTailwind CDN(仅出现在产物示例 example.html,运行时不要求)
networkGoogle Fonts(仅出现在产物示例 example.html)
network灵感出处标注(frontmatter example_source_url,非运行时调用)
cli本地 coding-agent CLI(宿主提供,模板自身不调用)

4管控建议与判定依据

建议配套管控措施
面向 Agent
声明可访问域名与密钥范围
面向管理者
密钥最小权限,保留请求日志
判定依据(文件路径与关键语句摘要)
  • 网络端点: 声明外部网络访问: cdn.tailwindcss.com(example.html 的 <script src>,选择器预览/本地打开示例时由浏览器请求)
审计说明: 。判级对象=本 skill 目录(SKILL.md + example.html[+ example.md]):无自带脚本、无凭证读取、无写盘指令、运行时不要求任何外部端点——正文只给版面/配色/字体族名与内容纪律,字族名不构成请求。目录内实际出现的外链全部是「产物示例」性质,逐条列出自证:cdn.tailwindcss.com(example.html 第 6 行 <script src>)、fonts.googleapis.com(example.html 第 7 行 <link>,Inter + Noto Sans SC)、hyperframes.heygen.com(frontmatter 出处标注)。 按批4 口径(端点仅见于产物示例/出处标注 → green)不影响档位。宿主侧行为(loader.ts 读盘、assemblePrompt 拼 prompt、agents/invoke.ts 拉起本地 CLI、预览 iframe 的 sandbox="allow-scripts allow-same-origin")写在 verdict.risks,不作为档位依据。

5第二遍独立确认

  • [ok] skill 目录的脚本 / 网络 / 凭证 / 写盘面 — 目录仅 SKILL.md / example.html / example.md 3 个文件,无 scripts/references/数据目录;token 扫描(curl / wget / fetch / exec / spawn / process.env / API_KEY / token / secret / write / save / delete)在该目录的 SKILL.md 中零命中;无自带可执行脚本。
  • [ok] 运行时链路复核 — 重读 loader.ts / shared.ts / app/api/convert/route.ts / app/api/templates/[id]/preview/route.ts:模板正文只作为 prompt body 被 assemblePrompt 拼装,宿主 spawn 本地 CLI 并捕获 stdout;模板不参与任何执行。
  • [ok] commit 与元数据 — 工作副本 git HEAD = 553ed98c283f9c0f489902d035416a972d6a9699(=任务表 pin 的 full 40 位);GitHub API nexu-io/html-anything:stars 8827、license spdx Apache-2.0、pushed_at 2026-09-15T03:36:24Z(与本地 HEAD 提交时间 2026-09-15 11:36:24 +0800 一致)。
  • [discrepancy] README 与源码的 frontmatter schema 漂移(仓库级) — README 第 213 / 217 / 468 行称模板 frontmatter 必须含 mode · scenario · surface · preview · design_system;但在 next/src/lib/templates/skills/ 下 '^mode:'、'^surface:'、'^design_system:' 全部零命中,实际字段是 category / scenario / aspect_hint / featured / recommended + example_*(loader.ts 的 SkillFrontmatter)。文档滞后于代码,不影响本模板运行,但照 README 新写模板会踩空。
  • [ok] frontmatter 元数据映射 — loader.ts fmToMeta 逐字段映射 zhName / enName / emoji / description / category / scenario / aspectHint / tags + featured / recommended + example 卡;本模板取自 SKILL.md 的实际取值与之相符。
  • [ok] example.html 与 SKILL.md 的一致性 — 蓝勾与四个互动图标均为内联 SVG(fill="#1d9bf0" 等),互动数字已格式化(12.3K / 482 / 2.1M),符合正文「数字格式化」与「icon 内联 SVG」两条。
  • [ok] 端点扫描(目录内) — 3 处:cdn.tailwindcss.com、fonts.googleapis.com(均在 example.html)+ frontmatter 的 hyperframes.heygen.com 出处标注;SKILL.md 正文与 example.md 无其它 URL。
  • [ok] 「不要任何外部图片 URL」自证 — example.html 内无 img/图片 URL:头像与图片位按正文用 CSS 渐变占位,图标为内联 SVG。

6结论

  • 把平台规则写进模板(280 字符、1.2K/4.5M 数字格式),产出更像真推文
  • 内容纪律明确:必须来自用户输入,不能编造推文
  • 输入兼容性好:数据也能被总结成 ≤280 字符的金句
  • 产物自足:蓝勾/互动图标内联 SVG,图片位 CSS 渐变,无外部图片
  • README 给出配套抓取工具链建议(TweetClaw 取数 → 本模板渲染),职责边界清晰
  • 适合: 适合把金句/观点做成 X 图卡用于转发与视频叠加,或把一条已发布的推文沉淀成图;也适合需要「数据 → 金句」自动浓缩的内容运营。
    不适合: 不适合需要真实推文数据接入(本模板不抓 X、不调 API;README 建议交给外部工具)、不适合正式品牌物料(蓝勾与互动数据是拟真元素),也不适合长文本——推文形态受 280 字符约束。
    Install Agent-Ready
    ① Verified Mirror 2026-09-15
    Option A · Direct DownloadDownload social-x-post-card.tar.gz
    sha256: d347f9e7707442ba…
    Option B · Copy Guide for Agent
    install.json
    agent 读 JSON 指南后会自动从本站下载安装,无需更多说明。
    ② Upstream GitHub
    GitHub Repo ↗
    Pinned to commit 553ed98c28.