@snaptrude/plugin-core 0.3.0 → 0.6.0

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 (302) hide show
  1. package/AGENTS.md +130 -48
  2. package/CHANGELOG.md +163 -0
  3. package/api-manifest.full.json +5600 -0
  4. package/api-manifest.json +5502 -0
  5. package/dist/api/analysis/heatmaps.d.ts +234 -0
  6. package/dist/api/analysis/heatmaps.d.ts.map +1 -0
  7. package/dist/api/analysis/illuminance.d.ts +145 -0
  8. package/dist/api/analysis/illuminance.d.ts.map +1 -0
  9. package/dist/api/analysis/index.d.ts +44 -0
  10. package/dist/api/analysis/index.d.ts.map +1 -0
  11. package/dist/api/analysis/shadows.d.ts +165 -0
  12. package/dist/api/analysis/shadows.d.ts.map +1 -0
  13. package/dist/api/analysis/sunlightHours.d.ts +208 -0
  14. package/dist/api/analysis/sunlightHours.d.ts.map +1 -0
  15. package/dist/api/analysis/sunpath.d.ts +80 -0
  16. package/dist/api/analysis/sunpath.d.ts.map +1 -0
  17. package/dist/api/core/buildings.d.ts +427 -0
  18. package/dist/api/core/buildings.d.ts.map +1 -0
  19. package/dist/api/core/comment/index.d.ts +230 -0
  20. package/dist/api/core/comment/index.d.ts.map +1 -0
  21. package/dist/api/core/geom/create/index.d.ts +247 -0
  22. package/dist/api/core/geom/create/index.d.ts.map +1 -0
  23. package/dist/api/core/geom/delete/index.d.ts +72 -0
  24. package/dist/api/core/geom/delete/index.d.ts.map +1 -0
  25. package/dist/api/core/geom/index.d.ts +24 -23
  26. package/dist/api/core/geom/index.d.ts.map +1 -1
  27. package/dist/api/core/geom/query/arc.d.ts +169 -0
  28. package/dist/api/core/geom/query/arc.d.ts.map +1 -0
  29. package/dist/api/core/geom/query/brep.d.ts +402 -0
  30. package/dist/api/core/geom/query/brep.d.ts.map +1 -0
  31. package/dist/api/core/geom/query/circle.d.ts +378 -0
  32. package/dist/api/core/geom/query/circle.d.ts.map +1 -0
  33. package/dist/api/core/geom/query/contour.d.ts +450 -0
  34. package/dist/api/core/geom/query/contour.d.ts.map +1 -0
  35. package/dist/api/core/geom/query/curve.d.ts +918 -0
  36. package/dist/api/core/geom/query/curve.d.ts.map +1 -0
  37. package/dist/api/core/geom/query/edge.d.ts +128 -0
  38. package/dist/api/core/geom/query/edge.d.ts.map +1 -0
  39. package/dist/api/core/geom/query/face.d.ts +363 -0
  40. package/dist/api/core/geom/query/face.d.ts.map +1 -0
  41. package/dist/api/core/geom/query/halfedge.d.ts +206 -0
  42. package/dist/api/core/geom/query/halfedge.d.ts.map +1 -0
  43. package/dist/api/core/geom/query/index.d.ts +61 -0
  44. package/dist/api/core/geom/query/index.d.ts.map +1 -0
  45. package/dist/api/core/geom/query/profile.d.ts +410 -0
  46. package/dist/api/core/geom/query/profile.d.ts.map +1 -0
  47. package/dist/api/core/geom/query/vertex.d.ts +187 -0
  48. package/dist/api/core/geom/query/vertex.d.ts.map +1 -0
  49. package/dist/api/core/geom/update/contour.d.ts +272 -0
  50. package/dist/api/core/geom/update/contour.d.ts.map +1 -0
  51. package/dist/api/core/geom/update/curve.d.ts +180 -0
  52. package/dist/api/core/geom/update/curve.d.ts.map +1 -0
  53. package/dist/api/core/geom/update/index.d.ts +27 -0
  54. package/dist/api/core/geom/update/index.d.ts.map +1 -0
  55. package/dist/api/core/geom/update/profile.d.ts +329 -0
  56. package/dist/api/core/geom/update/profile.d.ts.map +1 -0
  57. package/dist/api/core/groups.d.ts +485 -0
  58. package/dist/api/core/groups.d.ts.map +1 -0
  59. package/dist/api/core/history/index.d.ts +78 -0
  60. package/dist/api/core/history/index.d.ts.map +1 -0
  61. package/dist/api/core/index.d.ts +51 -1
  62. package/dist/api/core/index.d.ts.map +1 -1
  63. package/dist/api/core/io/import/index.d.ts +392 -0
  64. package/dist/api/core/io/import/index.d.ts.map +1 -0
  65. package/dist/api/core/io/index.d.ts +35 -0
  66. package/dist/api/core/io/index.d.ts.map +1 -0
  67. package/dist/api/core/io/job/index.d.ts +139 -0
  68. package/dist/api/core/io/job/index.d.ts.map +1 -0
  69. package/dist/api/core/io/query/index.d.ts +74 -0
  70. package/dist/api/core/io/query/index.d.ts.map +1 -0
  71. package/dist/api/core/io/terrain/index.d.ts +206 -0
  72. package/dist/api/core/io/terrain/index.d.ts.map +1 -0
  73. package/dist/api/core/io/underlay/index.d.ts +286 -0
  74. package/dist/api/core/io/underlay/index.d.ts.map +1 -0
  75. package/dist/api/core/layers.d.ts +402 -0
  76. package/dist/api/core/layers.d.ts.map +1 -0
  77. package/dist/api/core/math/quat.d.ts +111 -128
  78. package/dist/api/core/math/quat.d.ts.map +1 -1
  79. package/dist/api/core/math/vec3.d.ts +120 -102
  80. package/dist/api/core/math/vec3.d.ts.map +1 -1
  81. package/dist/api/core/project/index.d.ts +399 -0
  82. package/dist/api/core/project/index.d.ts.map +1 -0
  83. package/dist/api/core/tags.d.ts +755 -0
  84. package/dist/api/core/tags.d.ts.map +1 -0
  85. package/dist/api/core/units/index.d.ts +175 -0
  86. package/dist/api/core/units/index.d.ts.map +1 -0
  87. package/dist/api/core/zoom/index.d.ts +45 -0
  88. package/dist/api/core/zoom/index.d.ts.map +1 -0
  89. package/dist/api/design/boolean/index.d.ts +168 -0
  90. package/dist/api/design/boolean/index.d.ts.map +1 -0
  91. package/dist/api/design/create/index.d.ts +837 -0
  92. package/dist/api/design/create/index.d.ts.map +1 -0
  93. package/dist/api/design/delete/index.d.ts +63 -0
  94. package/dist/api/design/delete/index.d.ts.map +1 -0
  95. package/dist/api/design/doors/index.d.ts +268 -0
  96. package/dist/api/design/doors/index.d.ts.map +1 -0
  97. package/dist/api/design/edit/index.d.ts +49 -0
  98. package/dist/api/design/edit/index.d.ts.map +1 -0
  99. package/dist/api/design/erase/index.d.ts +160 -0
  100. package/dist/api/design/erase/index.d.ts.map +1 -0
  101. package/dist/api/design/furniture/index.d.ts +123 -0
  102. package/dist/api/design/furniture/index.d.ts.map +1 -0
  103. package/dist/api/design/index.d.ts +153 -0
  104. package/dist/api/design/index.d.ts.map +1 -0
  105. package/dist/api/design/lock.d.ts +41 -0
  106. package/dist/api/design/lock.d.ts.map +1 -0
  107. package/dist/api/design/materials/index.d.ts +297 -0
  108. package/dist/api/design/materials/index.d.ts.map +1 -0
  109. package/dist/api/design/query/geometry/index.d.ts +140 -0
  110. package/dist/api/design/query/geometry/index.d.ts.map +1 -0
  111. package/dist/api/design/query/index.d.ts +1011 -0
  112. package/dist/api/design/query/index.d.ts.map +1 -0
  113. package/dist/api/design/query/spaces.d.ts +221 -0
  114. package/dist/api/design/query/spaces.d.ts.map +1 -0
  115. package/dist/api/design/selection/index.d.ts +282 -0
  116. package/dist/api/design/selection/index.d.ts.map +1 -0
  117. package/dist/api/design/shared.d.ts +38 -0
  118. package/dist/api/design/shared.d.ts.map +1 -0
  119. package/dist/api/design/transform/index.d.ts +87 -0
  120. package/dist/api/design/transform/index.d.ts.map +1 -0
  121. package/dist/api/design/update/index.d.ts +178 -0
  122. package/dist/api/design/update/index.d.ts.map +1 -0
  123. package/dist/api/design/windows/index.d.ts +189 -0
  124. package/dist/api/design/windows/index.d.ts.map +1 -0
  125. package/dist/api/entity/buildableEnvelope.d.ts +261 -0
  126. package/dist/api/entity/buildableEnvelope.d.ts.map +1 -0
  127. package/dist/api/entity/department.d.ts +0 -98
  128. package/dist/api/entity/department.d.ts.map +1 -1
  129. package/dist/api/entity/index.d.ts +9 -9
  130. package/dist/api/entity/index.d.ts.map +1 -1
  131. package/dist/api/entity/referenceLine.d.ts +49 -106
  132. package/dist/api/entity/referenceLine.d.ts.map +1 -1
  133. package/dist/api/entity/space.d.ts +484 -251
  134. package/dist/api/entity/space.d.ts.map +1 -1
  135. package/dist/api/entity/story.d.ts +49 -39
  136. package/dist/api/entity/story.d.ts.map +1 -1
  137. package/dist/api/index.d.ts +22 -12
  138. package/dist/api/index.d.ts.map +1 -1
  139. package/dist/api/presentation/aiInspiration.d.ts +440 -0
  140. package/dist/api/presentation/aiInspiration.d.ts.map +1 -0
  141. package/dist/api/presentation/diagrams.d.ts +81 -0
  142. package/dist/api/presentation/diagrams.d.ts.map +1 -0
  143. package/dist/api/presentation/import.d.ts +113 -0
  144. package/dist/api/presentation/import.d.ts.map +1 -0
  145. package/dist/api/presentation/index.d.ts +46 -0
  146. package/dist/api/presentation/index.d.ts.map +1 -0
  147. package/dist/api/presentation/sheets.d.ts +176 -0
  148. package/dist/api/presentation/sheets.d.ts.map +1 -0
  149. package/dist/api/presentation/views.d.ts +296 -0
  150. package/dist/api/presentation/views.d.ts.map +1 -0
  151. package/dist/api/program/adjacency.d.ts +155 -0
  152. package/dist/api/program/adjacency.d.ts.map +1 -0
  153. package/dist/api/program/areas.d.ts +360 -0
  154. package/dist/api/program/areas.d.ts.map +1 -0
  155. package/dist/api/program/classification.d.ts +135 -0
  156. package/dist/api/program/classification.d.ts.map +1 -0
  157. package/dist/api/program/cores.d.ts +174 -0
  158. package/dist/api/program/cores.d.ts.map +1 -0
  159. package/dist/api/program/departments.d.ts +431 -0
  160. package/dist/api/program/departments.d.ts.map +1 -0
  161. package/dist/api/program/index.d.ts +69 -0
  162. package/dist/api/program/index.d.ts.map +1 -0
  163. package/dist/api/program/layout.d.ts +63 -0
  164. package/dist/api/program/layout.d.ts.map +1 -0
  165. package/dist/api/program/metrics.d.ts +108 -0
  166. package/dist/api/program/metrics.d.ts.map +1 -0
  167. package/dist/api/program/site.d.ts +451 -0
  168. package/dist/api/program/site.d.ts.map +1 -0
  169. package/dist/api/program/spreadsheet.d.ts +2041 -0
  170. package/dist/api/program/spreadsheet.d.ts.map +1 -0
  171. package/dist/handles.d.ts +171 -0
  172. package/dist/handles.d.ts.map +1 -0
  173. package/dist/host-utils.d.ts +7 -5
  174. package/dist/host-utils.d.ts.map +1 -1
  175. package/dist/index.cjs +4344 -899
  176. package/dist/index.cjs.map +1 -1
  177. package/dist/index.d.ts +1 -0
  178. package/dist/index.d.ts.map +1 -1
  179. package/dist/index.js +3682 -865
  180. package/dist/index.js.map +1 -1
  181. package/package.json +6 -2
  182. package/scripts/generate-manifest.mjs +193 -0
  183. package/scripts/generate-manifest.test.mjs +215 -0
  184. package/src/api/analysis/heatmaps.ts +256 -0
  185. package/src/api/analysis/illuminance.ts +155 -0
  186. package/src/api/analysis/index.ts +46 -0
  187. package/src/api/analysis/shadows.ts +183 -0
  188. package/src/api/analysis/sunlightHours.ts +211 -0
  189. package/src/api/analysis/sunpath.ts +83 -0
  190. package/src/api/core/buildings.ts +485 -0
  191. package/src/api/core/comment/index.ts +258 -0
  192. package/src/api/core/geom/create/index.ts +293 -0
  193. package/src/api/core/geom/delete/index.ts +78 -0
  194. package/src/api/core/geom/index.ts +24 -23
  195. package/src/api/core/geom/query/arc.ts +169 -0
  196. package/src/api/core/geom/query/brep.ts +444 -0
  197. package/src/api/core/geom/query/circle.ts +404 -0
  198. package/src/api/core/geom/query/contour.ts +540 -0
  199. package/src/api/core/geom/query/curve.ts +1078 -0
  200. package/src/api/core/geom/query/edge.ts +130 -0
  201. package/src/api/core/geom/query/face.ts +403 -0
  202. package/src/api/core/geom/query/halfedge.ts +210 -0
  203. package/src/api/core/geom/query/index.ts +63 -0
  204. package/src/api/core/geom/query/profile.ts +473 -0
  205. package/src/api/core/geom/query/vertex.ts +205 -0
  206. package/src/api/core/geom/update/contour.ts +315 -0
  207. package/src/api/core/geom/update/curve.ts +209 -0
  208. package/src/api/core/geom/update/index.ts +29 -0
  209. package/src/api/core/geom/update/profile.ts +377 -0
  210. package/src/api/core/groups.ts +521 -0
  211. package/src/api/core/history/index.ts +84 -0
  212. package/src/api/core/index.ts +51 -1
  213. package/src/api/core/io/import/index.ts +432 -0
  214. package/src/api/core/io/index.ts +37 -0
  215. package/src/api/core/io/job/index.ts +140 -0
  216. package/src/api/core/io/query/index.ts +71 -0
  217. package/src/api/core/io/terrain/index.ts +214 -0
  218. package/src/api/core/io/underlay/index.ts +295 -0
  219. package/src/api/core/layers.ts +333 -0
  220. package/src/api/core/math/quat.ts +112 -235
  221. package/src/api/core/math/vec3.ts +124 -159
  222. package/src/api/core/project/index.ts +418 -0
  223. package/src/api/core/tags.ts +808 -0
  224. package/src/api/core/units/index.ts +164 -0
  225. package/src/api/core/zoom/index.ts +47 -0
  226. package/src/api/design/boolean/index.ts +179 -0
  227. package/src/api/design/create/index.ts +895 -0
  228. package/src/api/design/delete/index.ts +67 -0
  229. package/src/api/design/doors/index.ts +285 -0
  230. package/src/api/design/edit/index.ts +54 -0
  231. package/src/api/design/erase/index.ts +151 -0
  232. package/src/api/design/furniture/index.ts +130 -0
  233. package/src/api/design/index.ts +162 -0
  234. package/src/api/design/lock.ts +42 -0
  235. package/src/api/design/materials/index.ts +301 -0
  236. package/src/api/design/query/geometry/index.ts +166 -0
  237. package/src/api/design/query/index.ts +937 -0
  238. package/src/api/design/query/spaces.ts +132 -0
  239. package/src/api/design/selection/index.ts +273 -0
  240. package/src/api/design/shared.ts +40 -0
  241. package/src/api/design/transform/index.ts +93 -0
  242. package/src/api/design/update/index.ts +117 -0
  243. package/src/api/design/windows/index.ts +207 -0
  244. package/src/api/entity/buildableEnvelope.ts +318 -0
  245. package/src/api/entity/department.ts +0 -113
  246. package/src/api/entity/index.ts +9 -9
  247. package/src/api/entity/referenceLine.ts +50 -38
  248. package/src/api/entity/space.ts +285 -226
  249. package/src/api/entity/story.ts +53 -42
  250. package/src/api/index.ts +22 -12
  251. package/src/api/presentation/aiInspiration.ts +362 -0
  252. package/src/api/presentation/diagrams.ts +84 -0
  253. package/src/api/presentation/import.ts +112 -0
  254. package/src/api/presentation/index.ts +48 -0
  255. package/src/api/presentation/sheets.ts +198 -0
  256. package/src/api/presentation/views.ts +303 -0
  257. package/src/api/program/adjacency.ts +164 -0
  258. package/src/api/program/areas.ts +335 -0
  259. package/src/api/program/classification.ts +138 -0
  260. package/src/api/program/cores.ts +171 -0
  261. package/src/api/program/departments.ts +465 -0
  262. package/src/api/program/index.ts +71 -0
  263. package/src/api/program/layout.ts +68 -0
  264. package/src/api/program/metrics.ts +120 -0
  265. package/src/api/program/site.ts +419 -0
  266. package/src/api/program/spreadsheet.ts +2075 -0
  267. package/src/handles.ts +194 -0
  268. package/src/host-utils.ts +10 -6
  269. package/src/index.ts +1 -0
  270. package/dist/api/core/geom/arc.d.ts +0 -81
  271. package/dist/api/core/geom/arc.d.ts.map +0 -1
  272. package/dist/api/core/geom/curve.d.ts +0 -70
  273. package/dist/api/core/geom/curve.d.ts.map +0 -1
  274. package/dist/api/core/geom/line.d.ts +0 -56
  275. package/dist/api/core/geom/line.d.ts.map +0 -1
  276. package/dist/api/core/geom/profile.d.ts +0 -121
  277. package/dist/api/core/geom/profile.d.ts.map +0 -1
  278. package/dist/api/tools/copy.d.ts +0 -59
  279. package/dist/api/tools/copy.d.ts.map +0 -1
  280. package/dist/api/tools/index.d.ts +0 -33
  281. package/dist/api/tools/index.d.ts.map +0 -1
  282. package/dist/api/tools/material.d.ts +0 -51
  283. package/dist/api/tools/material.d.ts.map +0 -1
  284. package/dist/api/tools/offset.d.ts +0 -43
  285. package/dist/api/tools/offset.d.ts.map +0 -1
  286. package/dist/api/tools/selection.d.ts +0 -48
  287. package/dist/api/tools/selection.d.ts.map +0 -1
  288. package/dist/api/tools/transform.d.ts +0 -114
  289. package/dist/api/tools/transform.d.ts.map +0 -1
  290. package/dist/api/units/index.d.ts +0 -163
  291. package/dist/api/units/index.d.ts.map +0 -1
  292. package/src/api/core/geom/arc.ts +0 -70
  293. package/src/api/core/geom/curve.ts +0 -41
  294. package/src/api/core/geom/line.ts +0 -53
  295. package/src/api/core/geom/profile.ts +0 -94
  296. package/src/api/tools/copy.ts +0 -55
  297. package/src/api/tools/index.ts +0 -39
  298. package/src/api/tools/material.ts +0 -49
  299. package/src/api/tools/offset.ts +0 -43
  300. package/src/api/tools/selection.ts +0 -51
  301. package/src/api/tools/transform.ts +0 -117
  302. package/src/api/units/index.ts +0 -163
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@snaptrude/plugin-core",
3
- "version": "0.3.0",
3
+ "version": "0.6.0",
4
4
  "type": "module",
5
5
  "main": "./dist/index.js",
6
6
  "module": "./dist/index.js",
@@ -17,6 +17,7 @@
17
17
  "access": "public"
18
18
  },
19
19
  "devDependencies": {
20
+ "ts-morph": "^28.0.0",
20
21
  "tsup": "^8.5.1",
21
22
  "typescript": "^5.5.4"
22
23
  },
@@ -30,6 +31,9 @@
30
31
  "check-types": "tsc --noEmit",
31
32
  "build": "tsup --clean",
32
33
  "dev": "tsup --watch",
33
- "clean-dist": "rm -rf dist"
34
+ "clean-dist": "rm -rf dist",
35
+ "generate:manifest": "node scripts/generate-manifest.mjs",
36
+ "generate:manifest:check": "node scripts/generate-manifest.mjs --check",
37
+ "generate:manifest:all": "node scripts/generate-manifest.mjs --all"
34
38
  }
35
39
  }
@@ -0,0 +1,193 @@
1
+ // Discovery-manifest generator.
2
+ //
3
+ // The plugin API surface is a tree of abstract `Plugin*Api` classes; the wire
4
+ // method map (`PluginApiMethodMap`) is TYPE-LEVEL ONLY and cannot be enumerated
5
+ // at runtime. This script statically walks the abstract+Zod source with ts-morph
6
+ // and emits a flat, machine-readable manifest of every leaf method:
7
+ //
8
+ // { path, namespace, summary, examplePrompts[], argsType, resultType }
9
+ //
10
+ // The manifest is the substrate the discovery server (plugin-mcp-server) and the
11
+ // retrieval-accuracy eval harness key on. Authors only ever write the abstract
12
+ // class + Zod schemas + JSDoc + `@examplePrompt` lines — this regenerates the rest.
13
+ //
14
+ // Run: `pnpm --filter @snaptrude/plugin-core generate:manifest`
15
+ // add `--check` to assert the on-disk manifest is up-to-date (CI gate);
16
+ // exits non-zero without writing if regeneration would change it.
17
+ import { Project } from "ts-morph"
18
+ import { fileURLToPath } from "node:url"
19
+ import { dirname, resolve } from "node:path"
20
+ import { writeFileSync, readFileSync, existsSync } from "node:fs"
21
+
22
+ const here = dirname(fileURLToPath(import.meta.url))
23
+ const pkgRoot = resolve(here, "..")
24
+ const apiGlob = resolve(pkgRoot, "src/api/**/*.ts")
25
+ const outFile = resolve(pkgRoot, "api-manifest.json")
26
+
27
+ const ROOT_CLASS = "PluginApi"
28
+ const RETURN_WRAPPER = "PluginApiReturn"
29
+
30
+ /** First paragraph of a JSDoc description, whitespace-collapsed. */
31
+ function summaryOf(jsDoc) {
32
+ if (!jsDoc) return ""
33
+ const desc = (jsDoc.getDescription() ?? "").trim()
34
+ const firstPara = desc.split(/\n\s*\n/)[0] ?? ""
35
+ return firstPara.replace(/\s+/g, " ").trim()
36
+ }
37
+
38
+ /** All `@examplePrompt` comment strings on a method's JSDoc. */
39
+ function examplePromptsOf(jsDoc) {
40
+ if (!jsDoc) return []
41
+ return jsDoc
42
+ .getTags()
43
+ .filter((t) => t.getTagName() === "examplePrompt")
44
+ .map((t) => (t.getCommentText() ?? "").trim())
45
+ .filter(Boolean)
46
+ }
47
+
48
+ /** Strip the `PluginApiReturn<...>` wrapper to the inner result type text. */
49
+ function unwrapReturn(text) {
50
+ if (!text) return "void"
51
+ const m = text.match(new RegExp(`^${RETURN_WRAPPER}<([\\s\\S]*)>$`))
52
+ return (m ? m[1] : text).trim()
53
+ }
54
+
55
+ /**
56
+ * Statically walk the abstract `PluginApi` class tree and return one flat,
57
+ * sorted manifest entry per leaf method. Pure (no side effects) so it is unit
58
+ * testable; the CLI below adds the write + report.
59
+ */
60
+ export function buildManifest({ includeOptional = false } = {}) {
61
+ const project = new Project({ skipAddingFilesFromTsConfig: true })
62
+ project.addSourceFilesAtPaths(apiGlob)
63
+
64
+ // className -> ClassDeclaration, for every abstract Plugin*Api class.
65
+ const classes = new Map()
66
+ for (const sf of project.getSourceFiles()) {
67
+ for (const cls of sf.getClasses()) {
68
+ const name = cls.getName()
69
+ if (name && name.startsWith("Plugin") && name.endsWith("Api")) {
70
+ classes.set(name, cls)
71
+ }
72
+ }
73
+ }
74
+
75
+ const leaves = []
76
+
77
+ function walk(className, pathPrefix) {
78
+ const cls = classes.get(className)
79
+ if (!cls) return
80
+
81
+ // Leaf methods on this namespace.
82
+ for (const method of cls.getMethods()) {
83
+ const name = method.getName()
84
+ const jsDoc = method.getJsDocs().at(-1) ?? null
85
+ const param = method.getParameters()[0]
86
+ leaves.push({
87
+ path: `${pathPrefix}${name}`,
88
+ namespace: pathPrefix.replace(/\.$/, ""),
89
+ summary: summaryOf(jsDoc),
90
+ examplePrompts: examplePromptsOf(jsDoc),
91
+ argsType: param?.getTypeNode()?.getText() ?? null,
92
+ resultType: unwrapReturn(method.getReturnTypeNode()?.getText()),
93
+ })
94
+ }
95
+
96
+ // Sub-namespaces are abstract properties typed as another Plugin*Api class.
97
+ //
98
+ // Author-ahead discipline: a member declared optional (`?`) is authored
99
+ // BEFORE the host implements it — present in the type tree (so plugins and
100
+ // codegen see the shape) but kept OUT of the discovery manifest until it is
101
+ // promoted to a required `abstract` member in the wave the host lands it.
102
+ // The default (discovery) build skips optional members; the authored-surface
103
+ // build (`includeOptional`, used by the retrieval eval) includes them — both
104
+ // the optional sub-namespaces and the optional function-property leaves.
105
+ for (const prop of cls.getProperties()) {
106
+ const optional = prop.hasQuestionToken()
107
+ if (optional && !includeOptional) continue
108
+ const typeNode = prop.getTypeNode()
109
+ const childType = typeNode?.getText()
110
+ if (childType && classes.has(childType)) {
111
+ walk(childType, `${pathPrefix}${prop.getName()}.`)
112
+ } else if (
113
+ includeOptional &&
114
+ typeNode &&
115
+ typeNode.getKindName() === "FunctionType"
116
+ ) {
117
+ // An optional author-ahead leaf, written as a function-property.
118
+ const jsDoc = prop.getJsDocs().at(-1) ?? null
119
+ const param = typeNode.getParameters()[0]
120
+ leaves.push({
121
+ path: `${pathPrefix}${prop.getName()}`,
122
+ namespace: pathPrefix.replace(/\.$/, ""),
123
+ summary: summaryOf(jsDoc),
124
+ examplePrompts: examplePromptsOf(jsDoc),
125
+ argsType: param?.getTypeNode()?.getText() ?? null,
126
+ resultType: unwrapReturn(typeNode.getReturnTypeNode()?.getText()),
127
+ })
128
+ }
129
+ }
130
+ }
131
+
132
+ walk(ROOT_CLASS, "")
133
+ leaves.sort((a, b) => a.path.localeCompare(b.path))
134
+ return leaves
135
+ }
136
+
137
+ // --- CLI: write + report (skipped when imported, e.g. by tests) ------------
138
+ if (
139
+ process.argv[1] &&
140
+ resolve(process.argv[1]) === fileURLToPath(import.meta.url)
141
+ ) {
142
+ // `--all` builds the AUTHORED-surface manifest (includes optional author-ahead
143
+ // members) to a separate file, for the retrieval eval. Default builds the
144
+ // discovery manifest (required/host-landed members only).
145
+ const all = process.argv.includes("--all")
146
+ const check = process.argv.includes("--check")
147
+ const target = all ? resolve(pkgRoot, "api-manifest.full.json") : outFile
148
+ const leaves = buildManifest({ includeOptional: all })
149
+ const json = JSON.stringify(leaves, null, 2) + "\n"
150
+
151
+ if (check) {
152
+ // Determinism / staleness gate: regenerate and compare, never write.
153
+ const current = existsSync(target) ? readFileSync(target, "utf8") : ""
154
+ if (current !== json) {
155
+ console.error(
156
+ `${target} is STALE or non-deterministic — run \`generate:manifest${all ? " --all" : ""}\` and commit the result.`,
157
+ )
158
+ process.exit(1)
159
+ }
160
+ console.log(
161
+ `manifest up-to-date & deterministic (${leaves.length} methods)`,
162
+ )
163
+ process.exit(0)
164
+ }
165
+
166
+ writeFileSync(target, json)
167
+
168
+ const missingPrompts = leaves.filter((l) => l.examplePrompts.length === 0)
169
+ console.log(
170
+ `manifest${all ? " (authored surface)" : ""}: ${leaves.length} methods -> ${target}`,
171
+ )
172
+ console.log(
173
+ `coverage: ${leaves.length - missingPrompts.length}/${leaves.length} methods have @examplePrompt lines`,
174
+ )
175
+ if (missingPrompts.length) {
176
+ console.log(
177
+ ` (no @examplePrompt yet: ${missingPrompts.map((l) => l.path).join(", ")})`,
178
+ )
179
+ }
180
+ const slice = [
181
+ "program.departments.list",
182
+ "program.departments.get",
183
+ "program.metrics.get",
184
+ "presentation.views.list",
185
+ ]
186
+ console.log("slice methods present:")
187
+ for (const p of slice) {
188
+ const hit = leaves.find((l) => l.path === p)
189
+ console.log(
190
+ ` ${hit ? "OK " : "MISS"} ${p}${hit ? ` (${hit.examplePrompts.length} prompts)` : ""}`,
191
+ )
192
+ }
193
+ }
@@ -0,0 +1,215 @@
1
+ // Unit tests for the discovery-manifest generator (pure codegen logic).
2
+ // Run: `node --test scripts/generate-manifest.test.mjs` (from packages/plugin-core)
3
+ import { test } from "node:test"
4
+ import assert from "node:assert/strict"
5
+ import { buildManifest } from "./generate-manifest.mjs"
6
+
7
+ const manifest = buildManifest()
8
+ const byPath = new Map(manifest.map((m) => [m.path, m]))
9
+
10
+ test("every entry has a dotted path and a namespace", () => {
11
+ for (const m of manifest) {
12
+ assert.match(m.path, /^[a-z][a-zA-Z0-9.]*$/, `bad path: ${m.path}`)
13
+ assert.equal(typeof m.namespace, "string")
14
+ assert.ok(
15
+ Array.isArray(m.examplePrompts),
16
+ `${m.path} examplePrompts not array`,
17
+ )
18
+ }
19
+ })
20
+
21
+ test("output is sorted and unique by path", () => {
22
+ const paths = manifest.map((m) => m.path)
23
+ assert.deepEqual(
24
+ paths,
25
+ [...paths].sort((a, b) => a.localeCompare(b)),
26
+ "not sorted",
27
+ )
28
+ assert.equal(new Set(paths).size, paths.length, "duplicate paths")
29
+ })
30
+
31
+ test("all 4 Phase-1 slice methods are present with intent + prompts", () => {
32
+ const slice = [
33
+ "program.departments.list",
34
+ "program.departments.get",
35
+ "program.metrics.get",
36
+ "presentation.views.list",
37
+ ]
38
+ for (const p of slice) {
39
+ const m = byPath.get(p)
40
+ assert.ok(m, `missing slice method: ${p}`)
41
+ assert.ok(m.summary.length > 0, `${p} has no intent summary`)
42
+ assert.ok(m.examplePrompts.length >= 3, `${p} has < 3 example prompts`)
43
+ assert.ok(
44
+ m.resultType && m.resultType !== "void",
45
+ `${p} has no result type`,
46
+ )
47
+ }
48
+ })
49
+
50
+ test("departments.get carries its args type; list takes no args", () => {
51
+ assert.equal(byPath.get("program.departments.get").argsType, "string")
52
+ assert.equal(byPath.get("program.departments.list").argsType, null)
53
+ })
54
+
55
+ test("return-type wrapper PluginApiReturn<...> is unwrapped", () => {
56
+ for (const m of manifest) {
57
+ assert.ok(
58
+ !/^PluginApiReturn</.test(m.resultType ?? ""),
59
+ `${m.path} not unwrapped`,
60
+ )
61
+ }
62
+ })
63
+
64
+ test("author-ahead (optional) members are kept OUT of the manifest", () => {
65
+ // Optional sub-namespaces (`aiInspiration?`) and optional leaf methods
66
+ // (`departments.delete?`, `cores.create?`) are authored ahead of the host and
67
+ // must not appear in the discovery manifest until promoted to required
68
+ // `abstract` members. (See the discipline note in generate-manifest.mjs.)
69
+ const authoredAhead = [
70
+ "presentation.aiInspiration.listModels",
71
+ "program.departments.delete",
72
+ "program.cores.create",
73
+ ]
74
+ for (const p of authoredAhead) {
75
+ assert.ok(
76
+ !byPath.has(p),
77
+ `optional author-ahead member leaked into manifest: ${p}`,
78
+ )
79
+ }
80
+ })
81
+
82
+ test("promoted methods are present in the manifest", () => {
83
+ // Methods whose react host bodies have landed and been verified, flipped from
84
+ // optional author-ahead to required `abstract`.
85
+ const promoted = [
86
+ "program.departments.create",
87
+ "program.departments.setTargetArea",
88
+ "program.site.get",
89
+ "program.site.getContext",
90
+ "presentation.import.image",
91
+ "presentation.import.pdf",
92
+ "presentation.sheets.list",
93
+ "presentation.sheets.place",
94
+ "presentation.diagrams.place",
95
+ // 2026-07-02 promotions — react hosts landed and verified:
96
+ "program.spreadsheet.render",
97
+ "program.adjacency.getMatrix",
98
+ "program.adjacency.compute",
99
+ "program.spreadsheet.getTakeoff",
100
+ "program.spreadsheet.runScript",
101
+ "presentation.views.get",
102
+ "presentation.views.getActive",
103
+ "presentation.views.capture",
104
+ "presentation.views.setActive",
105
+ "presentation.views.create",
106
+ "core.layers.setActive",
107
+ "core.layers.update",
108
+ "program.areas.update",
109
+ // 2026-07-06 promotions — analysis namespace + program.site geo reads,
110
+ // react hosts landed:
111
+ "analysis.sunpath.enable",
112
+ "analysis.sunpath.disable",
113
+ "analysis.sunpath.isActive",
114
+ "analysis.shadows.enable",
115
+ "analysis.shadows.disable",
116
+ "analysis.shadows.isEnabled",
117
+ "analysis.shadows.setDateTime",
118
+ "analysis.shadows.getDateTime",
119
+ "analysis.sunlightHours.compute",
120
+ "analysis.sunlightHours.get",
121
+ "analysis.sunlightHours.cancel",
122
+ "analysis.sunlightHours.reset",
123
+ "analysis.illuminance.compute",
124
+ "analysis.illuminance.get",
125
+ "analysis.illuminance.cancel",
126
+ "analysis.illuminance.reset",
127
+ "program.site.getLocation",
128
+ "program.site.getNorthAngle",
129
+ // 2026-07-07 promotion — analysis.heatmaps, react host landed:
130
+ "analysis.heatmaps.renderSpaces",
131
+ "analysis.heatmaps.renderGrid",
132
+ "analysis.heatmaps.reset",
133
+ "analysis.heatmaps.isActive",
134
+ ]
135
+ for (const p of promoted) {
136
+ assert.ok(
137
+ byPath.has(p),
138
+ `expected promoted method missing from manifest: ${p}`,
139
+ )
140
+ }
141
+ })
142
+
143
+ test("v2 family reads (all 5 families) are present with intent + prompts", () => {
144
+ // All 22 reads of the five landed families. Every sub-api mount is now required
145
+ // `abstract` (the react hosts have landed), so each read is in the discovery
146
+ // manifest with a summary, >= 3 example prompts, and a result type.
147
+ const reads = [
148
+ "core.groups.list",
149
+ "core.groups.get",
150
+ "core.groups.getForComponent",
151
+ "core.groups.listMembers",
152
+ "core.groups.isLocked",
153
+ "core.groups.getBounds",
154
+ "core.buildings.list",
155
+ "core.buildings.get",
156
+ "core.buildings.listStoreys",
157
+ "core.buildings.getActive",
158
+ "core.layers.list",
159
+ "core.layers.get",
160
+ "core.layers.getActive",
161
+ "core.tags.listCategories",
162
+ "core.tags.getCategory",
163
+ "core.tags.list",
164
+ "core.tags.get",
165
+ "core.tags.getTagsForComponent",
166
+ "core.tags.listComponents",
167
+ "program.areas.get",
168
+ "program.areas.list",
169
+ "program.areas.listMembers",
170
+ ]
171
+ for (const p of reads) {
172
+ const m = byPath.get(p)
173
+ assert.ok(m, `missing v2 family read: ${p}`)
174
+ assert.ok(m.summary.length > 0, `${p} has no intent summary`)
175
+ assert.ok(m.examplePrompts.length >= 3, `${p} has < 3 example prompts`)
176
+ assert.ok(
177
+ m.resultType && m.resultType !== "void",
178
+ `${p} has no result type`,
179
+ )
180
+ }
181
+ })
182
+
183
+ test("v2 family writes are IN the discovery manifest (hosts landed, promoted)", () => {
184
+ // 2026-07-02: every v2 family write's react host body has landed, so the
185
+ // contract members were promoted from optional `foo?: (args) => ...`
186
+ // fn-properties to required `abstract` methods — they now appear in the
187
+ // discovery build.
188
+ const promotedWrites = [
189
+ "core.groups.create",
190
+ "core.groups.update",
191
+ "core.groups.delete",
192
+ "core.buildings.setActive",
193
+ "core.buildings.create",
194
+ "core.buildings.update",
195
+ "core.buildings.copy",
196
+ "core.buildings.delete",
197
+ "core.layers.setActive",
198
+ "core.layers.update",
199
+ "core.tags.createCategory",
200
+ "core.tags.updateCategory",
201
+ "core.tags.deleteCategory",
202
+ "core.tags.create",
203
+ "core.tags.update",
204
+ "core.tags.delete",
205
+ "core.tags.assign",
206
+ "core.tags.unassign",
207
+ "program.areas.update",
208
+ ]
209
+ for (const p of promotedWrites) {
210
+ assert.ok(
211
+ byPath.has(p),
212
+ `promoted v2 family write missing from manifest: ${p}`,
213
+ )
214
+ }
215
+ })
@@ -0,0 +1,256 @@
1
+ import * as z from "zod"
2
+ import { PluginApiReturn } from "../../types"
3
+ import { ComponentHandle, Vec3Components } from "../../handles"
4
+
5
+ /**
6
+ * Analysis heatmaps — render plugin-computed scalar data as a heatmap.
7
+ *
8
+ * Unlike the built-in studies ({@linkcode PluginAnalysisSunlightHoursApi},
9
+ * {@linkcode PluginAnalysisIlluminanceApi}) where the host computes the
10
+ * values, here the **plugin brings its own numbers** and the host renders
11
+ * them. Two render modes:
12
+ *
13
+ * - {@linkcode PluginAnalysisHeatmapsApi.renderSpaces} — one flat colour per
14
+ * space, painted on the space's top face (occupancy, energy use, any
15
+ * per-room metric).
16
+ * - {@linkcode PluginAnalysisHeatmapsApi.renderGrid} — a coloured grid mesh
17
+ * from point samples in world coordinates (wind, noise, microclimate — any
18
+ * field sampled over an area).
19
+ *
20
+ * Shared semantics:
21
+ *
22
+ * - **Single active heatmap** — a render call **replaces** whatever heatmap
23
+ * is currently showing (from either mode).
24
+ * - **Legend** — the host renders a legend card from
25
+ * {@linkcode PluginAnalysisHeatmapOptions} (title, unit, min/max, colour
26
+ * segments). Values outside `[min, max]` **clamp to the end colours** and
27
+ * the legend shows `<` / `>` markers at the clamped ends.
28
+ * - **Ephemeral** — the heatmap is a transient overlay: never persisted,
29
+ * never saved with views, and auto-cleared when a scene-mutating edit
30
+ * invalidates it. Re-render after changing the model.
31
+ *
32
+ * Accessed via `snaptrude.analysis.heatmaps`.
33
+ */
34
+ export abstract class PluginAnalysisHeatmapsApi {
35
+ constructor() {}
36
+
37
+ /**
38
+ * Render a per-space heatmap — one flat colour per space's top face.
39
+ *
40
+ * Each entry maps a space to a scalar value; the value is mapped through
41
+ * the colour ramp (see {@linkcode PluginAnalysisHeatmapOptions}) and the
42
+ * space's top face is painted that single flat colour. Replaces any
43
+ * heatmap currently showing (single active heatmap). Spaces whose top
44
+ * face is not flat (pitched/sloped tops) are **skipped with a console
45
+ * warning** — the rest of the heatmap still renders.
46
+ *
47
+ * The heatmap is ephemeral: it is auto-cleared by scene-mutating edits
48
+ * and is never persisted or saved with views.
49
+ *
50
+ * @param entries - One {@linkcode PluginAnalysisHeatmapSpaceEntry} per
51
+ * space: the space's handle and its scalar value.
52
+ * @param options - {@linkcode PluginAnalysisHeatmapOptions} — legend
53
+ * title/unit, explicit min/max range (auto-derived from the data when
54
+ * omitted), and the colour ramp.
55
+ * @returns A {@linkcode PluginAnalysisHeatmapsRenderResult} —
56
+ * `{ success: true }` once the heatmap is rendered.
57
+ * @throws When `entries` is empty or a handle does not resolve to a space.
58
+ * @throws When no space had a flat top face to paint (every entry was
59
+ * skipped).
60
+ * @throws When `options.min` is greater than `options.max`.
61
+ * @throws When a colour in `options.colors` is not a 6-digit hex colour.
62
+ * @throws When plugin writes are disabled.
63
+ *
64
+ * @examplePrompt Color each room by its occupancy count
65
+ * @examplePrompt Show my energy simulation results as a heatmap per space
66
+ * @examplePrompt Paint the rooms red to blue by temperature
67
+ *
68
+ * # Example
69
+ * ```ts
70
+ * const spaces = await snaptrude.design.query.listSpaces()
71
+ * await snaptrude.analysis.heatmaps.renderSpaces(
72
+ * spaces.map((space) => ({ space, value: occupancy[space] ?? 0 })),
73
+ * { title: "Occupancy", unit: "people", min: 0, max: 50 },
74
+ * )
75
+ * ```
76
+ */
77
+ public abstract renderSpaces(
78
+ entries: PluginAnalysisHeatmapSpaceEntry[],
79
+ options?: PluginAnalysisHeatmapOptions,
80
+ ): PluginApiReturn<PluginAnalysisHeatmapsRenderResult>
81
+
82
+ /**
83
+ * Render a grid heatmap — a coloured mesh from point samples.
84
+ *
85
+ * Each cell is a scalar sample at a **world-coordinate** position
86
+ * (**y is up** — a ground-level field sits at `y = 0`); the host builds
87
+ * one square cell of edge `cellSize` per sample — in the same Snaptrude
88
+ * internal units as `position` (convert real-world lengths via
89
+ * {@linkcode PluginUnitsApi.convert}) — coloured by mapping the value
90
+ * through the colour ramp
91
+ * (see {@linkcode PluginAnalysisHeatmapOptions}). This is the mode for
92
+ * field data — wind, noise, microclimate — sampled over an area. Replaces
93
+ * any heatmap currently showing (single active heatmap).
94
+ *
95
+ * The heatmap is ephemeral: it is auto-cleared by scene-mutating edits
96
+ * and is never persisted or saved with views.
97
+ *
98
+ * @param cells - One {@linkcode PluginAnalysisHeatmapGridCell} per
99
+ * sample: a world-coordinate `position` (y up) and its scalar `value`.
100
+ * @param cellSize - Edge length of each (square) cell, in the same
101
+ * Snaptrude internal units as `position` (see
102
+ * {@linkcode PluginUnitsApi.convert}). Must be a positive, finite number.
103
+ * @param options - {@linkcode PluginAnalysisHeatmapOptions} — legend
104
+ * title/unit, explicit min/max range (auto-derived from the data when
105
+ * omitted), and the colour ramp.
106
+ * @returns A {@linkcode PluginAnalysisHeatmapsRenderResult} —
107
+ * `{ success: true }` once the heatmap is rendered.
108
+ * @throws When `cells` is empty or `cellSize` is not a positive, finite number.
109
+ * @throws When `options.min` is greater than `options.max`.
110
+ * @throws When a colour in `options.colors` is not a 6-digit hex colour.
111
+ * @throws When plugin writes are disabled.
112
+ *
113
+ * @examplePrompt Overlay my CFD wind simulation results on the site
114
+ * @examplePrompt Render a noise-level grid around the building
115
+ * @examplePrompt Show these sampled microclimate values as a colored grid
116
+ *
117
+ * # Example
118
+ * ```ts
119
+ * // World coordinates are y-up: a ground-level field varies in x/z at y = 0.
120
+ * await snaptrude.analysis.heatmaps.renderGrid(
121
+ * samples.map((s) => ({ position: { x: s.x, y: 0, z: s.z }, value: s.windSpeed })),
122
+ * 2, // 2-unit square cells
123
+ * { title: "Wind speed", unit: "m/s", colors: ["#0000ff", "#00ff00", "#ff0000"] },
124
+ * )
125
+ * ```
126
+ */
127
+ public abstract renderGrid(
128
+ cells: PluginAnalysisHeatmapGridCell[],
129
+ cellSize: number,
130
+ options?: PluginAnalysisHeatmapOptions,
131
+ ): PluginApiReturn<PluginAnalysisHeatmapsRenderResult>
132
+
133
+ /**
134
+ * Clear the plugin heatmap from the scene.
135
+ *
136
+ * Un-applies the rendered heatmap (either mode) and removes its legend.
137
+ * A no-op (returns `false`) when no plugin heatmap is showing. Does not
138
+ * touch the built-in study heatmaps (`sunlightHours` / `illuminance`) —
139
+ * they have their own `reset`.
140
+ *
141
+ * @returns `true` when a heatmap was cleared, `false` when none was
142
+ * showing.
143
+ * @throws When plugin writes are disabled.
144
+ *
145
+ * @examplePrompt Clear my custom heatmap
146
+ * @examplePrompt Remove the wind overlay from the model
147
+ * @examplePrompt Reset the plugin heatmap view
148
+ *
149
+ * # Example
150
+ * ```ts
151
+ * await snaptrude.analysis.heatmaps.reset()
152
+ * ```
153
+ */
154
+ public abstract reset(): PluginApiReturn<boolean>
155
+
156
+ /**
157
+ * Is a plugin heatmap currently showing?
158
+ *
159
+ * `true` between a successful render and the next
160
+ * {@linkcode PluginAnalysisHeatmapsApi.reset} — or the scene-mutating
161
+ * edit that auto-clears it (heatmaps are ephemeral).
162
+ *
163
+ * @returns `true` when a plugin heatmap is rendered on the scene.
164
+ *
165
+ * @examplePrompt Is my heatmap still showing?
166
+ * @examplePrompt Check whether the custom heatmap is active
167
+ * @examplePrompt Do I need to re-render the wind overlay?
168
+ *
169
+ * # Example
170
+ * ```ts
171
+ * if (!(await snaptrude.analysis.heatmaps.isActive())) {
172
+ * await snaptrude.analysis.heatmaps.renderGrid(cells, 2)
173
+ * }
174
+ * ```
175
+ */
176
+ public abstract isActive(): PluginApiReturn<boolean>
177
+ }
178
+
179
+ /**
180
+ * One space's entry in {@linkcode PluginAnalysisHeatmapsApi.renderSpaces}.
181
+ *
182
+ * | Property | Type | Description |
183
+ * |---|---|---|
184
+ * | `space` | {@linkcode ComponentHandle} | Handle of the space to colour |
185
+ * | `value` | `number` | The scalar value mapped to a colour |
186
+ */
187
+ export const PluginAnalysisHeatmapSpaceEntry = z.object({
188
+ space: ComponentHandle,
189
+ value: z.number().finite(),
190
+ })
191
+ export type PluginAnalysisHeatmapSpaceEntry = z.infer<
192
+ typeof PluginAnalysisHeatmapSpaceEntry
193
+ >
194
+
195
+ /**
196
+ * One grid sample in {@linkcode PluginAnalysisHeatmapsApi.renderGrid}.
197
+ *
198
+ * | Property | Type | Description |
199
+ * |---|---|---|
200
+ * | `position` | `{ x, y, z }` | Cell centre in **world coordinates** (y is up) |
201
+ * | `value` | `number` | The scalar value mapped to a colour |
202
+ */
203
+ export const PluginAnalysisHeatmapGridCell = z.object({
204
+ position: Vec3Components,
205
+ value: z.number().finite(),
206
+ })
207
+ export type PluginAnalysisHeatmapGridCell = z.infer<
208
+ typeof PluginAnalysisHeatmapGridCell
209
+ >
210
+
211
+ /**
212
+ * Display options shared by both heatmap render modes.
213
+ *
214
+ * The colour ramp maps values to colours: `colors` is an **ordered list of
215
+ * hex colour stops, low → high** (e.g. `["#0000ff", "#ff0000"]`). When
216
+ * omitted, the host's default blue → cyan → green → yellow → red ramp is used. Values outside
217
+ * `[min, max]` clamp to the end colours; the legend marks the clamped ends
218
+ * with `<` / `>`. `min`/`max` are auto-derived from the data when omitted.
219
+ *
220
+ * | Property | Type | Description |
221
+ * |---|---|---|
222
+ * | `title` | `string \| undefined` | Legend title |
223
+ * | `unit` | `string \| undefined` | Unit label shown on the legend (e.g. `"m/s"`) |
224
+ * | `min` | `number \| undefined` | Value mapped to the first colour stop; data minimum when omitted |
225
+ * | `max` | `number \| undefined` | Value mapped to the last colour stop; data maximum when omitted |
226
+ * | `colors` | `string[] \| undefined` | Ordered 6-digit hex colour stops (e.g. `"#0000ff"`), low → high; host blue → cyan → green → yellow → red default |
227
+ */
228
+ export const PluginAnalysisHeatmapOptions = z.object({
229
+ title: z.string().optional(),
230
+ unit: z.string().optional(),
231
+ min: z.number().finite().optional(),
232
+ max: z.number().finite().optional(),
233
+ colors: z
234
+ .array(z.string().regex(/^#?[0-9a-fA-F]{6}$/, "expected a 6-digit hex colour like \"#0000ff\""))
235
+ .min(1)
236
+ .optional(),
237
+ })
238
+ export type PluginAnalysisHeatmapOptions = z.infer<
239
+ typeof PluginAnalysisHeatmapOptions
240
+ >
241
+
242
+ /**
243
+ * Result of {@linkcode PluginAnalysisHeatmapsApi.renderSpaces} /
244
+ * {@linkcode PluginAnalysisHeatmapsApi.renderGrid} — render failures throw,
245
+ * so a returned value always carries `success: true`.
246
+ *
247
+ * | Property | Type | Description |
248
+ * |---|---|---|
249
+ * | `success` | `true` | The heatmap is rendered on the scene |
250
+ */
251
+ export const PluginAnalysisHeatmapsRenderResult = z.object({
252
+ success: z.literal(true),
253
+ })
254
+ export type PluginAnalysisHeatmapsRenderResult = z.infer<
255
+ typeof PluginAnalysisHeatmapsRenderResult
256
+ >