hd-garden 0.3.8 → 0.3.10

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 (95) hide show
  1. package/.agents/skills/garden-post-review/SKILL.md +2 -0
  2. package/.agents/skills/garden-ui/SKILL.md +111 -0
  3. package/.env.example +8 -0
  4. package/app/admin/page.tsx +14 -3
  5. package/app/admin/preview/[...path]/page.tsx +88 -0
  6. package/app/admin/ui/blocks/page.tsx +16 -0
  7. package/app/admin/ui/catalog/page.tsx +16 -0
  8. package/app/admin/ui/evals/page.tsx +19 -0
  9. package/app/admin/ui/page.tsx +22 -0
  10. package/app/admin-ui.css +227 -0
  11. package/app/api/admin/distribution/route.ts +4 -2
  12. package/app/api/admin/posts/source/route.ts +21 -0
  13. package/app/api/admin/preview/asset/route.ts +32 -0
  14. package/app/api/admin/thoughts/route.ts +1 -1
  15. package/app/api/admin/ui/blocks/route.ts +19 -0
  16. package/app/api/admin/ui/draft/route.ts +30 -0
  17. package/app/api/auth/github/route.ts +40 -1
  18. package/app/blog/page.tsx +6 -5
  19. package/app/columns/page.tsx +1 -1
  20. package/app/components/AdminDashboard.tsx +53 -1
  21. package/app/components/AdminUiPanels.tsx +258 -0
  22. package/app/components/AdminUiShell.tsx +56 -0
  23. package/app/components/ContentEmptyState.tsx +6 -6
  24. package/app/components/MarkdownArticle.tsx +15 -5
  25. package/app/components/UiBlock.tsx +22 -0
  26. package/app/components/UiStudio.tsx +422 -0
  27. package/app/components/ui-studio-keys.ts +3 -0
  28. package/app/globals.css +2 -0
  29. package/app/lib/admin-auth.ts +13 -1
  30. package/app/lib/content.ts +2 -1
  31. package/app/lib/fallback-site-config.ts +18 -18
  32. package/app/lib/github-content.ts +47 -4
  33. package/app/lib/repository-path.mjs +55 -0
  34. package/app/lib/ui-content.ts +79 -0
  35. package/app/lib/ui-model.ts +145 -0
  36. package/app/raw.d.ts +4 -0
  37. package/app/rss.xml/route.ts +2 -1
  38. package/app/ui-parity/page.tsx +120 -0
  39. package/bin/garden.mjs +71 -0
  40. package/eslint.config.mjs +3 -0
  41. package/package.json +15 -1
  42. package/scripts/build-content.mjs +35 -4
  43. package/scripts/build-ui-preview.mjs +29 -0
  44. package/scripts/check-post.mjs +26 -4
  45. package/scripts/ui-cli.mjs +303 -0
  46. package/site.config.yaml +19 -19
  47. package/templates/site/site.config.yaml +19 -19
  48. package/tsconfig.json +1 -1
  49. package/ui/core/apply.mjs +81 -0
  50. package/ui/core/catalog.mjs +536 -0
  51. package/ui/core/compile.mjs +63 -0
  52. package/ui/core/demos.mjs +223 -0
  53. package/ui/core/expr.mjs +310 -0
  54. package/ui/core/fence.mjs +201 -0
  55. package/ui/core/fix-prompt.mjs +35 -0
  56. package/ui/core/format.mjs +96 -0
  57. package/ui/core/index.mjs +37 -0
  58. package/ui/core/parse.mjs +229 -0
  59. package/ui/core/scan.mjs +53 -0
  60. package/ui/core/sha256.mjs +66 -0
  61. package/ui/core/starters.mjs +18 -0
  62. package/ui/core/state.mjs +259 -0
  63. package/ui/core/static.mjs +524 -0
  64. package/ui/core/transform.mjs +146 -0
  65. package/ui/core/validate.mjs +665 -0
  66. package/ui/evals/cases.yaml +155 -0
  67. package/ui/preview/dist/garden-ui.css +1182 -0
  68. package/ui/preview/dist/garden-ui.esm.js +367 -0
  69. package/ui/preview/dist/garden-ui.iife.js +367 -0
  70. package/ui/preview/index.tsx +191 -0
  71. package/ui/preview/mermaid-shim.ts +19 -0
  72. package/ui/prompt/build.mjs +24 -0
  73. package/ui/prompt/recipes/code-walkthrough.md +68 -0
  74. package/ui/prompt/recipes/compare.md +48 -0
  75. package/ui/prompt/recipes/converter.md +55 -0
  76. package/ui/prompt/recipes/data-chart.md +57 -0
  77. package/ui/prompt/recipes/inspect-grid.md +45 -0
  78. package/ui/prompt/recipes/param-bench.md +55 -0
  79. package/ui/prompt/recipes/plan.md +45 -0
  80. package/ui/prompt/recipes/stepper.md +52 -0
  81. package/ui/prompt/recipes/trace.md +62 -0
  82. package/ui/prompt/rules.md +104 -0
  83. package/ui/prompt/studio.md +20 -0
  84. package/ui/react/CatalogPage.tsx +166 -0
  85. package/ui/react/components/chart.tsx +470 -0
  86. package/ui/react/components/display.tsx +296 -0
  87. package/ui/react/components/inputs.tsx +268 -0
  88. package/ui/react/components/layout.tsx +236 -0
  89. package/ui/react/components/media.tsx +184 -0
  90. package/ui/react/index.tsx +59 -0
  91. package/ui/react/recipes.ts +25 -0
  92. package/ui/react/runtime.tsx +239 -0
  93. package/ui/react/types.ts +29 -0
  94. package/ui/react/ui.css +1182 -0
  95. package/vite.config.ts +4 -3
@@ -0,0 +1,155 @@
1
+ # 提示词回归集。每条是一段作者原话和期望结果:
2
+ # components 生成的 ui 块里必须出现的组件(可以更多,不能缺)
3
+ # assert 原话里有已知点:块头必须写 expect,并且通过校验
4
+ # note 这段用一张表或一句话就够:工作台应在围栏前给出"提醒:"
5
+ # 后台模型自检逐条以 mode: create 调用生成接口,记录:校验是否通过、修复轮数、
6
+ # 以上三项是否满足、token 用量、耗时。改提示词或组件目录后跑一遍,和上一次对比。
7
+
8
+ - id: kv-memory
9
+ intent: |
10
+ 让读者拧 batch 和序列长度,看 KV cache 占多少显存。
11
+ batch 1 到 32,默认 1;序列 1K 到 32K,默认 4K,用对数轴。
12
+ 显存 = 2 × 32 层 × 8 个 KV 头 × 128 维 × 序列长度 × batch × 2 字节。
13
+ batch 1、序列 4096 时是 512 MiB。
14
+ expect:
15
+ components: [Slider, Chart]
16
+ assert: true
17
+
18
+ - id: prefill-decode
19
+ intent: |
20
+ 让读者一步步看 KV cache 怎么增长:prompt 3 个 token,然后 decode 两步。
21
+ 每步标出哪一行 K/V 是新算的,哪些是直接读缓存。
22
+ expect:
23
+ components: [Steps, Grid]
24
+
25
+ - id: ecb-vs-cbc
26
+ intent: |
27
+ 明文分四块:A B A A。让读者在 ECB 和 CBC 之间切换,
28
+ 看 ECB 下密文出现重复块,CBC 下重复消失。点一个密文块能看到它和谁相同。
29
+ expect:
30
+ components: [Grid]
31
+
32
+ - id: mutex-vs-rwlock
33
+ intent: |
34
+ 并排对比 Mutex 和 RwLock。一个写者,读者数量 1 到 8 可调,每次读写都是 10 ms。
35
+ Mutex 下所有人排队;RwLock 下读者一起读,写者再独占。3 个读者时 Mutex 要 40 ms。
36
+ expect:
37
+ components: [Slider, Columns]
38
+ assert: true
39
+
40
+ - id: tcp-handshake
41
+ intent: |
42
+ 一步步走 TCP 三次握手,每一步列出客户端和服务端各自处于什么状态,
43
+ 标出这一步状态变了的那一方。
44
+ expect:
45
+ components: [Steps, Table]
46
+
47
+ - id: lr-warmup-cosine
48
+ intent: |
49
+ 学习率先线性预热到 3e-4,再按余弦衰减到 0,总共 10000 步。
50
+ 让读者拖预热步数(100 到 3000,默认 1000),看整条学习率曲线怎么变。
51
+ 预热结束那一步学习率正好是 3e-4。
52
+ expect:
53
+ components: [Slider, Chart]
54
+ assert: true
55
+
56
+ - id: float-sum
57
+ intent: |
58
+ 让读者从 0.1、0.2、0.25、0.5 里挑两个数相加,看结果,
59
+ 再看每个数的 64 位二进制表示,体会为什么 0.1 + 0.2 不等于 0.3,而 0.25 + 0.5 没问题。
60
+ expect:
61
+ components: [Choice, Table]
62
+
63
+ - id: gqa-compression
64
+ intent: |
65
+ 模型有 32 个查询头。GQA 让多个查询头共用一组 K/V。
66
+ 让读者选 KV 头数(1、2、4、8、32),看 KV cache 比 MHA 小了几倍。8 个 KV 头时是 4 倍。
67
+ expect:
68
+ components: [Choice]
69
+ assert: true
70
+
71
+ - id: raft-election
72
+ intent: |
73
+ 5 个节点的 Raft 集群,leader 宕机后的一次选举:
74
+ 某个 follower 超时、任期加一、变成 candidate、拉票、拿到多数票成为新 leader。
75
+ 一步步看每个节点的角色和任期。
76
+ expect:
77
+ components: [Steps, Table]
78
+
79
+ - id: go-gpm
80
+ intent: |
81
+ 一步步看 Go 调度器:新建的 goroutine 先进 P 的本地队列;P 绑在 M 上执行;
82
+ 本地队列空了以后,P 从全局队列偷一批。每步标出当前在动的是 G、P 还是 M。
83
+ expect:
84
+ components: [Steps]
85
+
86
+ - id: compound-savings
87
+ intent: |
88
+ 每月月末存 2000 元,年化 3%,按月复利。让读者拖存款年限(1 到 30 年,默认 10 年),
89
+ 看到期总额和其中的利息,再画一条总额随年限变化的曲线。10 年后约 27.9 万。
90
+ expect:
91
+ components: [Slider, Chart]
92
+ assert: true
93
+
94
+ - id: bill-split
95
+ intent: |
96
+ 聚餐 AA 计算器:总金额、人数、小费比例(0%、10%、15%)都能调,显示每人该付多少。
97
+ 600 元、4 个人、10% 小费时每人 165 元。
98
+ expect:
99
+ components: [Slider, Choice]
100
+ assert: true
101
+
102
+ - id: roast-shopping
103
+ intent: |
104
+ 按人数(2 到 12 人,默认 6 人)算周日烤羊腿要买多少:
105
+ 带骨羊腿每人 0.4 kg,土豆每人 250 g,胡萝卜每人 1.5 根,甜点苹果每人半个。
106
+ expect:
107
+ components: [Slider, Table]
108
+ assert: true
109
+
110
+ - id: roast-timeline
111
+ intent: |
112
+ 给一张周日烤羊腿的时间线清单,5 点开饭:前一天腌肉、做甜点,
113
+ 当天 13:30 进烤箱,15:30 出炉静置并烤土豆,16:45 切肉,读者可以一项项勾掉。
114
+ expect:
115
+ components: [Checklist]
116
+
117
+ - id: redis-io-threads
118
+ intent: |
119
+ 把 Redis I/O 线程数的压测结果画成柱状图,再列一张表:
120
+ 1 线程 98000 QPS,2 线程 181000,4 线程 312000,8 线程 356000。
121
+ expect:
122
+ components: [Chart, Table]
123
+
124
+ - id: binary-search
125
+ intent: |
126
+ 在 [1 3 5 7 9 11 13 15] 里二分查找 9,一步步标出每轮 lo、mid、hi 落在哪一格,
127
+ 以及这一轮比较的结果。
128
+ expect:
129
+ components: [Steps, Grid]
130
+
131
+ - id: hash-load-factor
132
+ intent: |
133
+ 开放寻址哈希表,一次查找失败时的平均探测次数约为 1 / (1 − α)。
134
+ 让读者拖装载因子 α(0.1 到 0.95),看探测次数,并画出曲线。α = 0.5 时是 2 次。
135
+ expect:
136
+ components: [Slider, Chart]
137
+ assert: true
138
+
139
+ - id: lock-names
140
+ intent: |
141
+ 列出 Go 标准库里的三种锁:Mutex、RWMutex、sync.Once,各写一句适用场景。
142
+ expect:
143
+ note: true
144
+
145
+ - id: what-is-kv-cache
146
+ intent: |
147
+ 用一段话解释什么是 KV cache,以及它为什么能加速推理。
148
+ expect:
149
+ note: true
150
+
151
+ - id: author-photo
152
+ intent: |
153
+ 在这里放一张我在会场演讲的照片。
154
+ expect:
155
+ note: true