1实现原理 · 为什么它能做到
该 skill 不是可执行程序,而是 html-anything 的「模板」:一个目录(SKILL.md + example.html[/example.md]),由 loader.ts 在运行时扫盘读取——新增模板=新增目录,不需要改 TypeScript。
Adding a template = adding a folder. No TS code change required; the API
frontmatter 是给选择器/API 的元数据(zh_name/en_name/emoji/description/category/scenario/aspect_hint/featured/recommended/tags),由 fmToMeta() 映射成 SkillMeta;frontmatter 之后的正文才是给模型的规格。
zhName: fm.zh_name ?? fm.name ?? id,
生成时该模板正文被当成 prompt body:/api/convert 用 assemblePrompt() 把「全局设计指令 + 本模板正文 + 用户内容」拼成一段 prompt,交给宿主的本地 agent CLI,HTML 由 stdout 流式捕获。
prompt = assemblePrompt({ body: skill.body, content, format });
模板正文之上还压着一段全局前置指令(SHARED_DESIGN_DIRECTIVES),把技术与内容纪律统一加在每个模板之前——示例 HTML 里普遍出现的 CDN/字体外链就源自这里(宿主壳注入,不是模板自身要求)。
通过 CDN 引入 Tailwind v3 Play (https://cdn.tailwindcss.com) 与所需的 Google Fonts。
产物以 stdout 文本返回:全局指令显式禁止 agent 动用文件系统,落盘由前端负责——所以模板目录既无脚本也无写盘能力。
**禁止使用 Write / Edit / MultiEdit / Bash / Create / 任何文件系统工具**。
example.html 是随包预渲染示例:/api/templates/<id>/preview 原样按 text/html 返回给 iframe(选择器内联预览),/api/templates/<id>/example 另把 example.md + example.html 一起返回。
return new Response(skill.exampleHtml, {
正文用四件事定义 editorial-minimalist:暖色单色 canvas、serif 标题 + grotesque 正文 + mono meta 三字族分工、1px hairline 边框与极柔和 chip、大量留白 + 微入场动效。
- Serif display + grotesque body + mono meta
示例把字族分工写成 CSS 变量:Instrument Serif 作 display、Inter Tight 作 sans、JetBrains Mono 作 mono。
--display: 'Instrument Serif', 'Newsreader', 'Lyon Text', Georgia, serif;
「ambient micro-motion」用 IntersectionObserver 驱动,代码注释明确拒绝滚动监听:// Intersection-observer reveal — never window scroll listeners.
// Intersection-observer reveal — never window scroll listeners.
「极柔和 chip」实现为四组浅色底/深色字的语义色对(pale red/blue/green/yellow),全部走 1px hairline 边框而非阴影。
--pale-red-bg: #FDEBEC; --pale-red-fg: #9F2F2D;
CLI 侧另有一条关键词直配通道:skills-matcher.ts 把用户内容里的关键词直接映射到该模板 id,命中即给 confidence=命中数×2+3,达到阈值 3 就走本地规则、不再让模型挑模板。
[["editorial", "编辑", "杂志风", "serif", "排版"], "web-proto-editorial"],
CLI 兜底匹配用到的阈值常量:内容长度需超过 60 字符才启用 AI 摘要匹配;强信号阈值是 3。
const MIN_CONTENT_LENGTH_FOR_AI = 60;
宿主壳用 sandbox="allow-scripts allow-same-origin" 的 iframe 渲染示例/产物(允许脚本、允许同源)——这是产品壳取舍,写进风险,不参与本 skill 判级。
sandbox="allow-scripts allow-same-origin"
2核心能力
3外部依赖
| 类型 | 依赖 |
|---|---|
| network | Google Fonts(Instrument Serif / Inter Tight / JetBrains Mono) |
| network | Google Fonts 静态资源域(preconnect) |
4风险提醒 风险提醒:绿色 · 放心使用
- Instrument Serif 属较风格化字体 — 若 Google Fonts 不可达,回退到 Georgia 会明显改变气质;正文未要求内嵌字体或提供本地回退说明。
- 微动效依赖脚本 — reveal 由内联 IntersectionObserver 实现,禁用 JS 时 .reveal 元素可能停留在初始不可见态(模板未要求 prefers-reduced-motion / no-JS 兜底)。
- 无响应式约束 — 正文只给「桌面 1440」aspect_hint,长文 + 大留白在窄屏的折行策略未定义。
- 外链字体与宿主 Tailwind — 示例引用 Google Fonts 两域(+ 产品壳注入的 Tailwind CDN);属产物/宿主行为,不计档。
5第二遍独立确认
- [ok] skill 目录文件清单 — find 得 SKILL.md + example.html,无 scripts/references。
- [ok] 外部端点仅字体 — example.html 仅 fonts.googleapis.com css2 与 fonts.gstatic.com preconnect;SKILL.md 正文无 URL。
- [ok] 微动效实现方式 — 示例内联脚本用 IntersectionObserver(threshold 0.08) 一次性 reveal + unobserve,注释自述不用滚动监听。
- [ok] hairline / chip 是否按正文实现 — --hairline #EAEAEA 贯穿边框;.chip--green/blue/red/yellow 四组浅底深字,与正文「1px hairline borders, 极柔和 chip」对应。
- [unlocatable] 无 JS 时 reveal 是否兜底 — 示例的 .reveal 初始态与 is-in 类由脚本切换,styles 中未见 no-JS 或 prefers-reduced-motion 的兜底规则;无法从源码确证降级行为,未在正文作断言。
- [ok] CLI 匹配器路由 — cli/src/skills-matcher.ts 存在 [["editorial", "编辑", "杂志风", "serif", "排版"], "web-proto-editorial"] 行。
- [ok] 判级 green 自证 — 目录零脚本文件(示例内联 reveal 属产物示例)、零凭证、零写盘;正文无运行时接口 → green。
- [ok] official_desc 逐字 — meta.official_desc 取自 frontmatter description 原文。
6结论
cd20ceb19bfbeb7f…553ed98c28