hd-garden 0.14.11 → 0.14.13

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (121) hide show
  1. package/Makefile +1 -1
  2. package/app/api/admin/distribution/route.ts +4 -2
  3. package/app/blog/[...path]/page.tsx +4 -2
  4. package/app/columns/[column]/[...path]/page.tsx +4 -2
  5. package/app/components/GardenMediaGuide.tsx +11 -23
  6. package/app/components/GardenPlayer.tsx +25 -0
  7. package/app/components/HandbookView.tsx +5 -3
  8. package/app/components/MarkdownArticle.tsx +7 -2
  9. package/app/components/PostReadingView.tsx +3 -3
  10. package/app/garden-modules.d.ts +10 -2
  11. package/app/globals.css +58 -1
  12. package/app/lib/content-body.ts +20 -0
  13. package/app/lib/garden-docs-meta.ts +2 -0
  14. package/app/lib/markdown-plugins.ts +5 -0
  15. package/app/lib/remark-video-player.d.mts +10 -0
  16. package/app/lib/remark-video-player.mjs +70 -0
  17. package/app/rss.xml/route.ts +3 -2
  18. package/bin/garden.mjs +18 -78
  19. package/docs/handbook/components/compose.md +3 -1
  20. package/docs/handbook/components/diagrams/chart.md +38 -0
  21. package/docs/handbook/components/diagrams/code-walkthrough.md +38 -0
  22. package/docs/handbook/components/diagrams/columns-join.md +38 -0
  23. package/docs/handbook/components/diagrams/compare.md +38 -0
  24. package/docs/handbook/components/diagrams/converter.md +38 -0
  25. package/docs/handbook/components/diagrams/facets.md +38 -0
  26. package/docs/handbook/components/diagrams/fan-out.md +38 -0
  27. package/docs/handbook/components/diagrams/icon-rail.md +38 -0
  28. package/docs/handbook/components/diagrams/inspect-grid.md +38 -0
  29. package/docs/handbook/components/diagrams/lanes.md +38 -0
  30. package/docs/handbook/components/diagrams/layers.md +38 -0
  31. package/docs/handbook/components/diagrams/other.md +37 -0
  32. package/docs/handbook/components/diagrams/plan.md +38 -0
  33. package/docs/handbook/components/diagrams/previews/chart.svg +7 -0
  34. package/docs/handbook/components/diagrams/previews/code-walkthrough.svg +5 -0
  35. package/docs/handbook/components/diagrams/previews/columns-join.svg +6 -0
  36. package/docs/handbook/components/diagrams/previews/compare.svg +5 -0
  37. package/docs/handbook/components/diagrams/previews/converter.svg +6 -0
  38. package/docs/handbook/components/diagrams/previews/facets.svg +6 -0
  39. package/docs/handbook/components/diagrams/previews/fan-out.svg +8 -0
  40. package/docs/handbook/components/diagrams/previews/icon-rail.svg +5 -0
  41. package/docs/handbook/components/diagrams/previews/inspect-grid.svg +5 -0
  42. package/docs/handbook/components/diagrams/previews/lanes.svg +5 -0
  43. package/docs/handbook/components/diagrams/previews/layers.svg +6 -0
  44. package/docs/handbook/components/diagrams/previews/other.svg +6 -0
  45. package/docs/handbook/components/diagrams/previews/plan.svg +5 -0
  46. package/docs/handbook/components/diagrams/previews/sequence.svg +7 -0
  47. package/docs/handbook/components/diagrams/previews/stepper.svg +5 -0
  48. package/docs/handbook/components/diagrams/previews/steps.svg +7 -0
  49. package/docs/handbook/components/diagrams/previews/tabs.svg +6 -0
  50. package/docs/handbook/components/diagrams/previews/timeline.svg +5 -0
  51. package/docs/handbook/components/diagrams/previews/trace.svg +7 -0
  52. package/docs/handbook/components/diagrams/previews/tunable.svg +4 -0
  53. package/docs/handbook/components/diagrams/previews/two-row.svg +4 -0
  54. package/docs/handbook/components/diagrams/sequence.md +38 -0
  55. package/docs/handbook/components/diagrams/stepper.md +38 -0
  56. package/docs/handbook/components/diagrams/steps.md +38 -0
  57. package/docs/handbook/components/diagrams/tabs.md +38 -0
  58. package/docs/handbook/components/diagrams/timeline.md +38 -0
  59. package/docs/handbook/components/diagrams/trace.md +38 -0
  60. package/docs/handbook/components/diagrams/tunable.md +38 -0
  61. package/docs/handbook/components/diagrams/two-row.md +38 -0
  62. package/docs/handbook/components/diagrams.md +100 -0
  63. package/docs/handbook/components/link-card.md +1 -1
  64. package/docs/handbook/components.md +1 -0
  65. package/docs/handbook/en/components/compose.md +3 -1
  66. package/docs/handbook/en/components/diagrams/chart.md +40 -0
  67. package/docs/handbook/en/components/diagrams/code-walkthrough.md +40 -0
  68. package/docs/handbook/en/components/diagrams/columns-join.md +40 -0
  69. package/docs/handbook/en/components/diagrams/compare.md +40 -0
  70. package/docs/handbook/en/components/diagrams/converter.md +40 -0
  71. package/docs/handbook/en/components/diagrams/facets.md +40 -0
  72. package/docs/handbook/en/components/diagrams/fan-out.md +40 -0
  73. package/docs/handbook/en/components/diagrams/icon-rail.md +40 -0
  74. package/docs/handbook/en/components/diagrams/inspect-grid.md +40 -0
  75. package/docs/handbook/en/components/diagrams/lanes.md +40 -0
  76. package/docs/handbook/en/components/diagrams/layers.md +40 -0
  77. package/docs/handbook/en/components/diagrams/other.md +39 -0
  78. package/docs/handbook/en/components/diagrams/plan.md +40 -0
  79. package/docs/handbook/en/components/diagrams/sequence.md +40 -0
  80. package/docs/handbook/en/components/diagrams/stepper.md +40 -0
  81. package/docs/handbook/en/components/diagrams/steps.md +40 -0
  82. package/docs/handbook/en/components/diagrams/tabs.md +40 -0
  83. package/docs/handbook/en/components/diagrams/timeline.md +40 -0
  84. package/docs/handbook/en/components/diagrams/trace.md +40 -0
  85. package/docs/handbook/en/components/diagrams/tunable.md +40 -0
  86. package/docs/handbook/en/components/diagrams/two-row.md +40 -0
  87. package/docs/handbook/en/components/diagrams.md +100 -0
  88. package/docs/handbook/en/components/link-card.md +1 -1
  89. package/docs/handbook/en/components.md +1 -0
  90. package/docs/handbook/en/start.md +1 -1
  91. package/docs/handbook/en/workflow.md +2 -2
  92. package/docs/handbook/en/writing.md +82 -1
  93. package/docs/handbook/start.md +1 -1
  94. package/docs/handbook/workflow.md +2 -2
  95. package/docs/handbook/writing.md +82 -1
  96. package/editors/dist/{garden-typora-0.14.11.zip → garden-typora-0.14.13.zip} +0 -0
  97. package/editors/dist/typora/main.js +296 -194
  98. package/editors/dist/typora/manifest.json +1 -1
  99. package/editors/dist/typora/style.css +48 -6
  100. package/editors/dist/vscode/{garden-ui-0.14.11.vsix → garden-ui-0.14.13.vsix} +0 -0
  101. package/package.json +1 -1
  102. package/scripts/build-content.mjs +23 -8
  103. package/scripts/dev-server.mjs +30 -2
  104. package/scripts/fetch-embed.mjs +39 -27
  105. package/scripts/handbook-diagrams.mjs +434 -0
  106. package/scripts/link-assets.mjs +6 -0
  107. package/scripts/vinext-runtime.mjs +80 -0
  108. package/templates/site/Makefile +1 -1
  109. package/templates/site/Makefile.en +1 -1
  110. package/ui/compose/compose.css +43 -5
  111. package/ui/garden/diagram-recipes.mjs +490 -0
  112. package/ui/garden/markdown-links.mjs +8 -5
  113. package/ui/garden/picker-placement.mjs +433 -0
  114. package/ui/garden/player.mjs +286 -0
  115. package/ui/garden/rehype-keep-punctuation.mjs +87 -18
  116. package/ui/garden/snippets.mjs +6 -4
  117. package/ui/garden/typora-suggest-contract.mjs +108 -0
  118. package/ui/preview/dist/garden-ui.css +43 -5
  119. package/ui/preview/dist/garden-ui.esm.js +4 -4
  120. package/ui/preview/dist/garden-ui.iife.js +4 -4
  121. package/vite.config.ts +84 -23
@@ -0,0 +1,490 @@
1
+ /** Author-facing /garden picker. Each row is a graphic type plus when an author would use it, not an internal layout or recipe id. */
2
+ export const COMPOSE_FENCE_NAME = "compose";
3
+
4
+ const STROKE = "#3a3428";
5
+ const MUTED = "#8a8274";
6
+ const CARD = "#fffdf8";
7
+
8
+ function svgPreview(inner) {
9
+ return "data:image/svg+xml," + encodeURIComponent(
10
+ `<svg xmlns="http://www.w3.org/2000/svg" width="72" height="48" viewBox="0 0 72 48">${inner}</svg>`,
11
+ );
12
+ }
13
+
14
+ function intentFence(intent) {
15
+ return "```garden compose\n" + intent + "\n```";
16
+ }
17
+
18
+ function authorPrompt({label, routeHint, open=false}) {
19
+ if (open) {
20
+ return [
21
+ "请根据我提供的材料和表达目标,在统一的 garden compose 里自由组合图文。现成图形无法表达、或需要把几种内容组合在一起时,用任意 Markdown / HTML 以及已有的基础块做成合适的说明。",
22
+ "",
23
+ "我的材料:",
24
+ "- (粘贴要呈现的内容、关系和原文)",
25
+ "",
26
+ "我的表达目标:",
27
+ "- (读者应该理解什么、重点是什么)",
28
+ "",
29
+ "请你:",
30
+ "- 只根据材料组织内容,不要发明事实或结论",
31
+ "- 自行处理图形语法、布局和手机阅读适配,不要让我学习新语法或写 CSS",
32
+ "- 列表里的常用图示只是起点,不是合法白名单;没有现成配方也可以,先抽取真实关系再组合基础块",
33
+ "- 不要把结果限制为某一个现成模板;需要时可以混合普通 Markdown、安全 HTML,以及卡片、行列、步骤等基础块",
34
+ ].join("\n");
35
+ }
36
+ return [
37
+ `请根据我提供的材料和表达目标,用 garden compose 做一个「${label}」说明图。`,
38
+ "",
39
+ "我的材料:",
40
+ "- (粘贴原文条目和需要保留的措辞)",
41
+ "",
42
+ "我的表达目标:",
43
+ "- (读者要一眼看出什么)",
44
+ "",
45
+ "请你:",
46
+ "- 只根据材料组织内容,不要发明事实或结论",
47
+ "- 自行处理图形语法、布局和手机阅读适配,不要让我学习标签或写 CSS",
48
+ `- 「${label}」是推荐起点:${routeHint}`,
49
+ "- 推荐图示不是唯一合法写法;需要时仍可在同一 compose 里搭配必要的 Markdown / HTML 基础块",
50
+ "- 不要另起一种作者围栏或新语法,只使用 garden compose",
51
+ ].join("\n");
52
+ }
53
+
54
+ /** Fence language for editor completions: always compose, never a picker id. */
55
+ export function composeFenceOpen() {
56
+ return "garden compose";
57
+ }
58
+
59
+ const PREVIEW = {
60
+ "columns-join": svgPreview(`<g fill="none" stroke="${STROKE}" stroke-width="1.25">
61
+ <rect x="4" y="10" width="16" height="28" rx="2" fill="${CARD}"/><path d="M8 16h8M8 21h6"/>
62
+ <rect x="28" y="8" width="16" height="32" rx="2" fill="${CARD}"/><path d="M32 16h8M32 21h6"/>
63
+ <rect x="52" y="10" width="16" height="28" rx="2" fill="${CARD}"/><path d="M56 16h8M56 21h6"/>
64
+ <path d="M20 24h8M44 24h8" stroke="${MUTED}"/>
65
+ </g>`),
66
+ "fan-out": svgPreview(`<g fill="none" stroke="${STROKE}" stroke-width="1.25">
67
+ <rect x="6" y="16" width="16" height="16" rx="2" fill="${CARD}"/>
68
+ <path d="M22 24h8"/>
69
+ <rect x="48" y="4" width="18" height="10" rx="2" fill="${CARD}"/>
70
+ <rect x="48" y="19" width="18" height="10" rx="2" fill="${CARD}"/>
71
+ <rect x="48" y="34" width="18" height="10" rx="2" fill="${CARD}"/>
72
+ <path d="M30 24h10M40 24L48 9M40 24h8M40 24L48 39" stroke="${MUTED}"/>
73
+ </g>`),
74
+ layers: svgPreview(`<g fill="none" stroke="${STROKE}" stroke-width="1.25">
75
+ <rect x="10" y="4" width="52" height="8" rx="2" fill="${CARD}"/>
76
+ <rect x="10" y="14" width="52" height="8" rx="2" fill="${CARD}"/>
77
+ <rect x="10" y="24" width="52" height="8" rx="2" fill="${CARD}"/>
78
+ <rect x="10" y="34" width="52" height="10" rx="2" fill="${CARD}"/>
79
+ </g>`),
80
+ facets: svgPreview(`<g fill="none" stroke="${STROKE}" stroke-width="1.25">
81
+ <rect x="4" y="14" width="15" height="20" rx="2" fill="${CARD}"/>
82
+ <rect x="21" y="14" width="15" height="20" rx="2" fill="${CARD}"/>
83
+ <rect x="38" y="14" width="15" height="20" rx="2" fill="${CARD}"/>
84
+ <rect x="55" y="14" width="13" height="20" rx="2" fill="${CARD}"/>
85
+ </g>`),
86
+ "two-row": svgPreview(`<g fill="none" stroke="${STROKE}" stroke-width="1.25">
87
+ <rect x="6" y="6" width="16" height="12" rx="2" fill="${CARD}"/><path d="M22 12h6"/><rect x="28" y="6" width="16" height="12" rx="2" fill="${CARD}"/><path d="M44 12h6"/><rect x="50" y="6" width="16" height="12" rx="2" fill="${CARD}"/>
88
+ <rect x="6" y="28" width="16" height="14" rx="2" fill="${CARD}"/><path d="M22 35h6"/><rect x="28" y="28" width="16" height="14" rx="2" fill="${CARD}"/><path d="M44 35h6"/><rect x="50" y="28" width="16" height="14" rx="2" fill="${CARD}"/>
89
+ </g>`),
90
+ "icon-rail": svgPreview(`<g fill="none" stroke="${STROKE}" stroke-width="1.25">
91
+ <rect x="8" y="8" width="8" height="8" rx="1.5"/><path d="M20 10h28M20 15h20"/>
92
+ <path d="M10 24h52" stroke="${MUTED}" stroke-width="1"/>
93
+ <rect x="8" y="32" width="8" height="8" rx="1.5"/><path d="M20 34h28M20 39h16"/>
94
+ </g>`),
95
+ sequence: svgPreview(`<g fill="none" stroke="${STROKE}" stroke-width="1.25">
96
+ <rect x="6" y="16" width="14" height="16" rx="2" fill="${CARD}"/>
97
+ <path d="M22 24h6"/><path d="M25 21.5 L28.5 24 L25 26.5" fill="${STROKE}" stroke="none"/>
98
+ <rect x="29" y="16" width="14" height="16" rx="2" fill="${CARD}"/>
99
+ <path d="M45 24h6"/><path d="M48 21.5 L51.5 24 L48 26.5" fill="${STROKE}" stroke="none"/>
100
+ <rect x="52" y="16" width="14" height="16" rx="2" fill="${CARD}"/>
101
+ </g>`),
102
+ steps: svgPreview(`<g fill="none" stroke="${STROKE}" stroke-width="1.25">
103
+ <circle cx="14" cy="12" r="5"/><path d="M22 12h40M22 16h24"/>
104
+ <path d="M14 17v6" stroke="${MUTED}"/>
105
+ <circle cx="14" cy="28" r="5"/><path d="M22 28h40M22 32h20"/>
106
+ <path d="M14 33v6" stroke="${MUTED}"/>
107
+ <circle cx="14" cy="42" r="4"/><path d="M22 42h28"/>
108
+ </g>`),
109
+ compare: svgPreview(`<g fill="none" stroke="${STROKE}" stroke-width="1.25">
110
+ <rect x="6" y="8" width="28" height="32" rx="2" fill="${CARD}"/>
111
+ <rect x="38" y="8" width="28" height="32" rx="2" fill="${CARD}"/>
112
+ <path d="M10 14h20M10 20h14M10 26h18M42 14h20M42 20h14M42 26h18"/>
113
+ </g>`),
114
+ timeline: svgPreview(`<g fill="none" stroke="${STROKE}" stroke-width="1.25">
115
+ <path d="M16 6v36" stroke="${MUTED}"/>
116
+ <circle cx="16" cy="12" r="2.5" fill="${STROKE}" stroke="none"/><path d="M24 10h32M24 15h20"/>
117
+ <circle cx="16" cy="28" r="2.5" fill="${STROKE}" stroke="none"/><path d="M24 26h32M24 31h16"/>
118
+ </g>`),
119
+ lanes: svgPreview(`<g fill="none" stroke="${STROKE}" stroke-width="1.25">
120
+ <path d="M8 16h56M8 30h56" stroke="${MUTED}"/>
121
+ <rect x="14" y="10" width="16" height="8" rx="2" fill="${CARD}"/>
122
+ <path d="M30 18v8"/><rect x="36" y="24" width="16" height="8" rx="2" fill="${CARD}"/>
123
+ </g>`),
124
+ tabs: svgPreview(`<g fill="none" stroke="${STROKE}" stroke-width="1.25">
125
+ <rect x="8" y="8" width="16" height="8" rx="2" fill="${CARD}"/>
126
+ <rect x="26" y="8" width="16" height="8" rx="2"/>
127
+ <rect x="44" y="8" width="16" height="8" rx="2"/>
128
+ <rect x="8" y="16" width="56" height="24" rx="2" fill="${CARD}"/>
129
+ </g>`),
130
+ chart: svgPreview(`<g fill="none" stroke="${STROKE}" stroke-width="1.25">
131
+ <path d="M12 8v32h48" stroke="${MUTED}"/>
132
+ <rect x="18" y="28" width="6" height="12" fill="${CARD}"/>
133
+ <rect x="28" y="20" width="6" height="20" fill="${CARD}"/>
134
+ <rect x="38" y="24" width="6" height="16" fill="${CARD}"/>
135
+ <rect x="48" y="12" width="6" height="28" fill="${CARD}"/>
136
+ </g>`),
137
+ tunable: svgPreview(`<g fill="none" stroke="${STROKE}" stroke-width="1.25">
138
+ <path d="M12 16h48" stroke="${MUTED}"/><circle cx="40" cy="16" r="4" fill="${CARD}"/>
139
+ <rect x="16" y="28" width="40" height="12" rx="2" fill="${CARD}"/><path d="M22 34h20"/>
140
+ </g>`),
141
+ converter: svgPreview(`<g fill="none" stroke="${STROKE}" stroke-width="1.25">
142
+ <rect x="8" y="16" width="16" height="16" rx="2" fill="${CARD}"/>
143
+ <path d="M24 24h10"/><rect x="36" y="6" width="28" height="12" rx="2" fill="${CARD}"/>
144
+ <rect x="36" y="20" width="28" height="12" rx="2" fill="${CARD}"/>
145
+ <rect x="36" y="34" width="28" height="10" rx="2" fill="${CARD}"/>
146
+ </g>`),
147
+ "code-walkthrough": svgPreview(`<g fill="none" stroke="${STROKE}" stroke-width="1.25">
148
+ <rect x="6" y="6" width="36" height="36" rx="2" fill="${CARD}"/>
149
+ <path d="M10 12h28M10 18h20M10 24h24M10 30h16"/>
150
+ <rect x="46" y="14" width="20" height="20" rx="2"/><path d="M50 20h12M50 26h8"/>
151
+ </g>`),
152
+ stepper: svgPreview(`<g fill="none" stroke="${STROKE}" stroke-width="1.25">
153
+ <rect x="8" y="8" width="56" height="22" rx="2" fill="${CARD}"/>
154
+ <path d="M16 32h8M28 32h8M40 32h8" stroke="${MUTED}"/>
155
+ <circle cx="20" cy="40" r="3"/><circle cx="32" cy="40" r="3" fill="${STROKE}"/><circle cx="44" cy="40" r="3"/>
156
+ </g>`),
157
+ trace: svgPreview(`<g fill="none" stroke="${STROKE}" stroke-width="1.25">
158
+ <rect x="8" y="16" width="14" height="14" rx="7" fill="${CARD}"/>
159
+ <rect x="29" y="16" width="14" height="14" rx="7"/>
160
+ <rect x="50" y="16" width="14" height="14" rx="7" fill="${CARD}"/>
161
+ <path d="M22 23h7M43 23h7"/>
162
+ <circle cx="36" cy="23" r="3" fill="${STROKE}" stroke="none"/>
163
+ </g>`),
164
+ plan: svgPreview(`<g fill="none" stroke="${STROKE}" stroke-width="1.25">
165
+ <rect x="10" y="8" width="8" height="8" rx="1"/><path d="M24 12h36"/>
166
+ <rect x="10" y="20" width="8" height="8" rx="1"/><path d="M24 24h28"/>
167
+ <rect x="10" y="32" width="8" height="8" rx="1"/><path d="M24 36h32"/>
168
+ </g>`),
169
+ "inspect-grid": svgPreview(`<g fill="none" stroke="${STROKE}" stroke-width="1.25">
170
+ <rect x="12" y="6" width="48" height="36" rx="2"/>
171
+ <path d="M12 18h48M12 30h48M28 6v36M44 6v36" stroke="${MUTED}"/>
172
+ <rect x="28" y="18" width="16" height="12" fill="${CARD}"/>
173
+ </g>`),
174
+ other: svgPreview(`<g fill="none" stroke="${STROKE}" stroke-width="1.25">
175
+ <path d="M8 10h28M8 15h20" stroke="${MUTED}"/>
176
+ <rect x="40" y="8" width="24" height="16" rx="2" fill="${CARD}"/><path d="M44 13h16M44 18h10"/>
177
+ <rect x="8" y="26" width="22" height="14" rx="2"/><path d="M12 31h14M12 35h9"/>
178
+ <path d="M36 30h28M36 36h20" stroke="${MUTED}"/>
179
+ </g>`),
180
+ };
181
+
182
+ const SPECS = [
183
+ {
184
+ name: "columns-join",
185
+ label: "关联图",
186
+ hint: "适合说明两边如何通过中间一项关联起来",
187
+ when: "两边通过中间一项关联起来",
188
+ whenNot: "没有中间连接关系时,不必强行加连接",
189
+ searchText: "关联图 三列并排 中间接起来 列 连接 关系图 用户 角色 权限 columns-join",
190
+ routeHint: "先写清两边各是什么、中间一项如何把两边接上,哪一块是重点",
191
+ sources: [
192
+ {file: "docs/handbook/components/compose.md", phrase: "三列并排,中间接起来"},
193
+ ],
194
+ },
195
+ {
196
+ name: "fan-out",
197
+ label: "发散图",
198
+ hint: "适合说明先到一处,再同时连到好几处",
199
+ when: "先到一处,再同时连到好几处",
200
+ whenNot: "没有真正的先到再分支时,不要画成发散",
201
+ searchText: "发散图 先到再散开 先到一处 再散开 扇出 fan 一分多 汇合 分发",
202
+ routeHint: "先写清谁先到谁,再同时连到哪几处,哪一处是重点",
203
+ sources: [
204
+ {file: "docs/handbook/components/compose.md", phrase: "先到一处,再散开"},
205
+ {file: ".agents/skills/garden-compose/references/visual-selection.md", phrase: "一分多"},
206
+ ],
207
+ },
208
+ {
209
+ name: "layers",
210
+ label: "分层图",
211
+ hint: "适合说明自上而下的层次,不必按顺序走完",
212
+ when: "自上而下的层次",
213
+ whenNot: "层次不是自动变成必须按顺序走完的流程",
214
+ searchText: "分层图 分层结构 自上而下分层 分层 层次 架构 layers",
215
+ routeHint: "写出各层名称和哪些是重点,并说明是不是每次都按这个顺序走完",
216
+ sources: [
217
+ {file: "docs/handbook/components/compose.md", phrase: "自上而下分层"},
218
+ {file: ".agents/skills/garden-compose/references/visual-selection.md", phrase: "包含或分层"},
219
+ ],
220
+ },
221
+ {
222
+ name: "facets",
223
+ label: "并列图",
224
+ hint: "适合说明一件事的几个方面,没有先后顺序",
225
+ when: "一件事的几个方面,没有先后",
226
+ whenNot: "没有先后就不要画成流程;没有同一条件的比较时,也不要画成对比图",
227
+ searchText: "并列图 多个切面 并列 方面 等宽 卡片 facets 并列类别",
228
+ routeHint: "列出各方面的短名和说明,并写明这几块有没有严格先后",
229
+ sources: [
230
+ {file: "docs/handbook/components/compose.md", phrase: "一件事的多个切面"},
231
+ {file: ".agents/skills/garden-compose/references/visual-selection.md", phrase: "并列类别"},
232
+ ],
233
+ },
234
+ {
235
+ name: "two-row",
236
+ label: "上下对照图",
237
+ hint: "适合把背景过程和重点过程分行对照",
238
+ when: "上面是背景过程,下面才是要讲的过程",
239
+ whenNot: "不是在比两套过程、或其实是同一条件下的方案对比时,不要用这种分行对照",
240
+ searchText: "上下对照图 上下两行对比 两行 上下 对比 背景 过程 two-row",
241
+ routeHint: "写清上面的背景过程和下面的重点过程各自有哪些阶段,哪一行是重点",
242
+ sources: [
243
+ {file: "docs/handbook/components/compose.md", phrase: "上下两行对比"},
244
+ ],
245
+ },
246
+ {
247
+ name: "icon-rail",
248
+ label: "图文列表",
249
+ hint: "适合逐条说明互不依赖的内容",
250
+ when: "一条条独立说明,用图标带出标题和正文",
251
+ whenNot: "这些条目没有先后依赖,不要画成流程,也不要写成要照着做的清单",
252
+ searchText: "图文列表 图标窄栏 独立条目 标题正文 图标 icon-rail",
253
+ routeHint: "用图标带出一条条独立说明,标题和正文写在一起;这不是流程,不要加顺序箭头",
254
+ sources: [
255
+ {file: ".agents/skills/garden-compose/references/visual-selection.md", phrase: "图标窄栏、标题正文共左缘"},
256
+ {file: ".agents/skills/garden-compose/references/layout-recipes.md", phrase: "图标窄栏 + 共用右栏的纵向条目"},
257
+ ],
258
+ },
259
+ {
260
+ name: "sequence",
261
+ label: "流程图",
262
+ hint: "适合说明一件事按什么顺序完成",
263
+ when: "有明确先后的阶段",
264
+ whenNot: "没有顺序的条目不要加箭头,也不要靠缩字硬撑手机横排",
265
+ searchText: "流程图 顺序流程 短阶段 长阶段 从左到右 纵向 顺序链 sequence",
266
+ routeHint: "只有原文明确顺序才用箭头。阶段短可以从左到右,阶段长或窄屏改为从上到下,不要靠缩字硬撑横排",
267
+ sources: [
268
+ {file: ".agents/skills/garden-compose/references/visual-selection.md", phrase: "短阶段从左到右"},
269
+ {file: ".agents/skills/garden-compose/references/visual-selection.md", phrase: "长阶段或纵向顺序"},
270
+ ],
271
+ },
272
+ {
273
+ name: "steps",
274
+ label: "分步图",
275
+ hint: "适合一步步解释,步骤里可以展开细节",
276
+ when: "一步步解释,并可展开细节",
277
+ whenNot: "不是按比例表示时间,也不是让读者照着做的清单,更不是让读者逐步查看状态变化",
278
+ searchText: "分步图 分步说明 分步解释 步骤 steps step",
279
+ routeHint: "用分步图把顺序讲清楚,需要时在步骤里展开细节;不要把它写成待办清单或逐步演示,除非材料确实如此",
280
+ sources: [
281
+ {file: ".agents/skills/garden-compose/references/visual-selection.md", phrase: "分步解释"},
282
+ {file: "docs/compose-catalog.md", phrase: "分步"},
283
+ ],
284
+ },
285
+ {
286
+ name: "compare",
287
+ label: "对比图",
288
+ hint: "适合比较两三种方案在同一条件下的差异",
289
+ when: "两三种方案在同一条件下比较",
290
+ whenNot: "只是罗列各自特点、没有共同条件时,用普通表格或并列图即可",
291
+ searchText: "对比图 对照 比较 compare 方案 左右 同一条件",
292
+ routeHint: "只在有真实共同条件时做对比,保留各方事实,不要发明输赢或排序",
293
+ sources: [
294
+ {file: "ui/prompt/recipes/compare.md", phrase: "配方:对照"},
295
+ {file: ".agents/skills/garden-compose/references/visual-selection.md", phrase: "对照"},
296
+ ],
297
+ },
298
+ {
299
+ name: "timeline",
300
+ label: "时间线图",
301
+ hint: "适合按日期或时间点排列事件",
302
+ when: "按日期或时间点排列事件",
303
+ whenNot: "没有按时间比例展开的进度,不要画成带时长的甘特图",
304
+ searchText: "时间线图 时间节点 日期 事件 时间线 timeline",
305
+ routeHint: "按原文日期或时间点排列事件,保留顺序和日期;不要做成按时长比例的进度",
306
+ sources: [
307
+ {file: ".agents/skills/garden-compose/references/visual-selection.md", phrase: "时间节点"},
308
+ ],
309
+ },
310
+ {
311
+ name: "lanes",
312
+ label: "时序图",
313
+ hint: "适合说明谁在什么时候向谁发了什么",
314
+ when: "谁在什么时候向谁发了什么",
315
+ whenNot: "不是通用建模语言,也不支持任意分支、循环或自动布线",
316
+ searchText: "时序图 交互时序 时序 泳道 lanes actor message 谁发给谁",
317
+ routeHint: "按原文写出参与者和他们之间的消息方向与顺序,不要补出原文没有的分支或循环",
318
+ sources: [
319
+ {file: ".agents/skills/garden-compose/references/visual-selection.md", phrase: "交互时序"},
320
+ ],
321
+ },
322
+ {
323
+ name: "tabs",
324
+ label: "选项卡",
325
+ hint: "适合几组说明互相独立、一次只看一组",
326
+ when: "几组说明互相独立,一次看一组",
327
+ whenNot: "必须同时比较的事实不要藏进其他组,这不是应用导航",
328
+ searchText: "选项卡 分组切换 tabs 面板 分组说明",
329
+ routeHint: "只有各组说明可以分开看时才用选项卡;必须同时比较的内容不要藏起来",
330
+ sources: [
331
+ {file: ".agents/skills/garden-compose/references/visual-selection.md", phrase: "分组切换"},
332
+ ],
333
+ },
334
+ {
335
+ name: "chart",
336
+ label: "数据图",
337
+ hint: "适合把已有数字画成柱状、折线或占比",
338
+ when: "已有一组测过或给定的数字,要让读者看清具体值",
339
+ whenNot: "不要编造数据;结果可由公式随输入变化时,优先用参数调节图",
340
+ searchText: "数据图 图表 chart 柱状 折线 饼图 实测 占比",
341
+ routeHint: "只用材料里的真实数据做图,标明轴和单位;不要编造数值",
342
+ sources: [
343
+ {file: "docs/handbook/components/compose.md", phrase: "图表示例(play)"},
344
+ {file: "ui/prompt/recipes/data-chart.md", phrase: "配方:数据图"},
345
+ {file: ".agents/skills/garden-compose/references/visual-selection.md", phrase: "数据图"},
346
+ ],
347
+ },
348
+ {
349
+ name: "tunable",
350
+ label: "参数调节图",
351
+ hint: "适合让读者改一两个输入,看结果怎么变",
352
+ when: "结果由一两个输入决定,读者会想换成别的值会怎样",
353
+ whenNot: "只有一个固定例子要讲,或输入过多时先拆开;一个输入带动多项输出时用换算图",
354
+ searchText: "参数调节图 可调参数 参数台 参数实验 拧参数 调节 slider param-bench tunable",
355
+ routeHint: "写出可调的输入和随之变化的结论,默认状态就要能看懂;不要让作者去写程序",
356
+ sources: [
357
+ {file: "docs/handbook/components/compose.md", phrase: "可调参数(play)"},
358
+ {file: "ui/prompt/recipes/param-bench.md", phrase: "配方:参数台"},
359
+ {file: ".agents/skills/garden-compose/references/visual-selection.md", phrase: "参数实验"},
360
+ ],
361
+ },
362
+ {
363
+ name: "converter",
364
+ label: "换算图",
365
+ hint: "适合一个输入同时算出好几项结果",
366
+ when: "一个输入同时算出好几项结果",
367
+ whenNot: "只有一个结果时用参数调节图;各项要分别调时先拆开",
368
+ searchText: "换算图 换算器 换算 converter 用料 成本 单位 人数",
369
+ routeHint: "一个输入同时换算出多项结果,保留公式和单位,不要发明材料里没有的换算关系",
370
+ sources: [
371
+ {file: "ui/prompt/recipes/converter.md", phrase: "配方:换算器"},
372
+ ],
373
+ },
374
+ {
375
+ name: "code-walkthrough",
376
+ label: "代码走查",
377
+ hint: "适合一行行看代码执行到哪、变量是多少",
378
+ when: "一段不长的代码值得一行行讲",
379
+ whenNot: "只需要展示代码时用普通代码块;代码太长时先截关键段",
380
+ searchText: "代码走查 代码 逐行 walkthrough 变量",
381
+ routeHint: "对着不长的关键代码,讲清每一步执行到哪一行、变量此刻是多少,不要改写原文代码的事实",
382
+ sources: [
383
+ {file: "ui/prompt/recipes/code-walkthrough.md", phrase: "配方:代码走查"},
384
+ ],
385
+ },
386
+ {
387
+ name: "stepper",
388
+ label: "逐步演示",
389
+ hint: "适合让读者停在某一步,看状态怎么变",
390
+ when: "过程中的状态会变,读者想停在某一步看哪里变了",
391
+ whenNot: "只有两三个静态阶段时,用分步图或流程图即可",
392
+ searchText: "逐步演示 步进器 步进 stepper 状态变化 再走一步 停在某一步",
393
+ routeHint: "让读者按步查看状态如何变化;若只是静态阶段,改用分步图,不要做成逐步演示",
394
+ sources: [
395
+ {file: "ui/prompt/recipes/stepper.md", phrase: "配方:步进器"},
396
+ ],
397
+ },
398
+ {
399
+ name: "trace",
400
+ label: "路径标注图",
401
+ hint: "适合在已有流程或状态图上标出走到哪",
402
+ when: "已有一张状态图或流程图,并且过程沿着它一步步走",
403
+ whenNot: "只需要展示结构,或节点、连线过多时先拆开",
404
+ searchText: "路径标注图 轨迹 状态图 走到哪 当前状态 trace",
405
+ routeHint: "在已有状态图或流程上标出当前走到哪一步,不要发明原文没有的节点或转移",
406
+ sources: [
407
+ {file: "ui/prompt/recipes/trace.md", phrase: "配方:轨迹"},
408
+ ],
409
+ },
410
+ {
411
+ name: "plan",
412
+ label: "步骤清单",
413
+ hint: "适合读者照着一项项做,并回来查看进度",
414
+ when: "步骤多、要跟着做,读者一边操作一边回来查看做到哪了",
415
+ whenNot: "只是概念上的几个阶段时写列表或分步图;步骤之间要观察状态变化时用逐步演示",
416
+ searchText: "步骤清单 计划与清单 清单 部署 排查 步骤 plan checklist",
417
+ routeHint: "按读者会照着做的顺序列出清单,保留原文步骤,不要把概念阶段硬写成待办",
418
+ sources: [
419
+ {file: "ui/prompt/recipes/plan.md", phrase: "配方:计划与清单"},
420
+ ],
421
+ },
422
+ {
423
+ name: "inspect-grid",
424
+ label: "格子图",
425
+ hint: "适合标出二维结构里哪几格特别、为什么",
426
+ when: "二维结构里要盯住某几格,并说明为什么特别",
427
+ whenNot: "只是普通数据表、没有哪一格要特别解释时,用普通表格即可",
428
+ searchText: "格子图 检视格 格子 矩阵 bitmap inspect-grid Attention 高亮",
429
+ routeHint: "用格子呈现二维结构,并指出需要特别解释的格子及其原因;不要把普通表格硬做成格子图",
430
+ sources: [
431
+ {file: "ui/prompt/recipes/inspect-grid.md", phrase: "配方:检视格"},
432
+ ],
433
+ },
434
+ ];
435
+
436
+ const OTHER = {
437
+ name: "other",
438
+ label: "其他",
439
+ hint: "适合现成图形无法表达、需要自由组合图文的内容",
440
+ when: "现成图形无法表达,或需要把图文自由组合在一起",
441
+ whenNot: "不要把列表里的常用图示当成合法白名单,也不要为此学习新语法",
442
+ searchText: "其他 other 任意 灵活 开放 组合 自由组合 图文 无现成 无法表达 markdown html 基础块",
443
+ open: true,
444
+ sources: [
445
+ {file: ".agents/skills/garden-compose/references/composition-patterns.md", phrase: "无现成表示方式时"},
446
+ {file: ".agents/skills/garden-compose/references/composition-patterns.md", phrase: "没有配方不是失败条件"},
447
+ ],
448
+ };
449
+
450
+ function decorate(spec) {
451
+ const open = Boolean(spec.open);
452
+ const prompt = authorPrompt({label: spec.label, routeHint: spec.routeHint, open});
453
+ return {
454
+ name: spec.name,
455
+ label: spec.label,
456
+ hint: spec.hint,
457
+ when: spec.when,
458
+ whenNot: spec.whenNot,
459
+ searchText: spec.searchText,
460
+ preview: PREVIEW[spec.name],
461
+ prompt,
462
+ body: intentFence(prompt),
463
+ open,
464
+ sources: spec.sources ?? [],
465
+ };
466
+ }
467
+
468
+ export const DIAGRAM_RECIPES = [...SPECS.map(decorate), decorate(OTHER)];
469
+ export const OTHER_RECIPE_NAME = "other";
470
+ export const INTERNAL_LAYOUT_TERMS_NOT_FOR_AUTHORS = ["centered-chip", "frameless-scene", "equal-cards", "flow-row", "flow-stack"];
471
+
472
+ export function filterPickerItems(query, items=DIAGRAM_RECIPES) {
473
+ const needle = String(query ?? "").trim().toLowerCase();
474
+ if (!needle) return [...items];
475
+ return items.filter((item) => {
476
+ const hay = [item.name, item.label, item.hint, item.when, item.searchText].join("\n").toLowerCase();
477
+ return hay.includes(needle);
478
+ });
479
+ }
480
+
481
+ export function pickerSelectionResult(item, _typedText="") {
482
+ return {
483
+ insertText: item.body,
484
+ prompt: item.prompt,
485
+ };
486
+ }
487
+
488
+ export function recommendAuthorPrompt(item) {
489
+ return item.prompt;
490
+ }
@@ -3,6 +3,7 @@
3
3
  * and inline spans) is skipped, so a URL in a snippet is never a link.
4
4
  */
5
5
  import { INLINE_LINK_SOURCE } from "./markdown-destination.mjs";
6
+ import { isPlayablePlayerUrl } from "./player.mjs";
6
7
 
7
8
  const FENCE = /^ {0,3}(`{3,}|~{3,})/u;
8
9
 
@@ -65,8 +66,10 @@ export const SOURCE_MARKER = "{source}";
65
66
 
66
67
  /**
67
68
  * A single-line paragraph whose only content is a web URL: bare, <autolink>,
68
- * or `[url](url)` (optional `{card}`). Those render as link cards and share
69
- * the OG fetch path with `{card}` markers.
69
+ * or `[url](url)` (optional `{card}`). Ordinary sites render as link cards and
70
+ * share the OG fetch path with `{card}` markers. A playable YouTube or
71
+ * Bilibili URL on its own line becomes a player instead, unless the author
72
+ * wrote `{card}`.
70
73
  */
71
74
  function standaloneUrl(line) {
72
75
  const trimmed = String(line ?? "").trim();
@@ -97,15 +100,15 @@ export function markdownLinks(markdown) {
97
100
  for (const match of text.matchAll(LINK)) {
98
101
  if (match[1] !== "!" && isWebUrl(linkUrl(match))) {
99
102
  const url = linkUrl(match);
100
- links.push({ url, card: match[6] === CARD_MARKER || standalone.has(url) });
103
+ links.push({ url, card: match[6] === CARD_MARKER || (standalone.has(url) && !isPlayablePlayerUrl(url)) });
101
104
  }
102
105
  }
103
106
  const rest = text.replace(LINK, " ");
104
107
  for (const match of rest.matchAll(AUTOLINK)) {
105
- links.push({ url: match[1], card: standalone.has(match[1]) });
108
+ links.push({ url: match[1], card: standalone.has(match[1]) && !isPlayablePlayerUrl(match[1]) });
106
109
  }
107
110
  for (const match of rest.replace(AUTOLINK, " ").matchAll(BARE)) {
108
- links.push({ url: match[2], card: standalone.has(match[2]) });
111
+ links.push({ url: match[2], card: standalone.has(match[2]) && !isPlayablePlayerUrl(match[2]) });
109
112
  }
110
113
  return text;
111
114
  });