@snaptrude/plugin-core 0.0.0-dev-20260708130115

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 (241) hide show
  1. package/AGENTS.md +227 -0
  2. package/CHANGELOG.md +119 -0
  3. package/CLAUDE.md +11 -0
  4. package/api-manifest.json +5004 -0
  5. package/dist/api/core/buildings.d.ts +427 -0
  6. package/dist/api/core/buildings.d.ts.map +1 -0
  7. package/dist/api/core/comment/index.d.ts +230 -0
  8. package/dist/api/core/comment/index.d.ts.map +1 -0
  9. package/dist/api/core/geom/create/index.d.ts +247 -0
  10. package/dist/api/core/geom/create/index.d.ts.map +1 -0
  11. package/dist/api/core/geom/delete/index.d.ts +72 -0
  12. package/dist/api/core/geom/delete/index.d.ts.map +1 -0
  13. package/dist/api/core/geom/index.d.ts +33 -0
  14. package/dist/api/core/geom/index.d.ts.map +1 -0
  15. package/dist/api/core/geom/query/arc.d.ts +169 -0
  16. package/dist/api/core/geom/query/arc.d.ts.map +1 -0
  17. package/dist/api/core/geom/query/brep.d.ts +402 -0
  18. package/dist/api/core/geom/query/brep.d.ts.map +1 -0
  19. package/dist/api/core/geom/query/circle.d.ts +378 -0
  20. package/dist/api/core/geom/query/circle.d.ts.map +1 -0
  21. package/dist/api/core/geom/query/contour.d.ts +450 -0
  22. package/dist/api/core/geom/query/contour.d.ts.map +1 -0
  23. package/dist/api/core/geom/query/curve.d.ts +918 -0
  24. package/dist/api/core/geom/query/curve.d.ts.map +1 -0
  25. package/dist/api/core/geom/query/edge.d.ts +128 -0
  26. package/dist/api/core/geom/query/edge.d.ts.map +1 -0
  27. package/dist/api/core/geom/query/face.d.ts +363 -0
  28. package/dist/api/core/geom/query/face.d.ts.map +1 -0
  29. package/dist/api/core/geom/query/halfedge.d.ts +206 -0
  30. package/dist/api/core/geom/query/halfedge.d.ts.map +1 -0
  31. package/dist/api/core/geom/query/index.d.ts +61 -0
  32. package/dist/api/core/geom/query/index.d.ts.map +1 -0
  33. package/dist/api/core/geom/query/profile.d.ts +410 -0
  34. package/dist/api/core/geom/query/profile.d.ts.map +1 -0
  35. package/dist/api/core/geom/query/vertex.d.ts +187 -0
  36. package/dist/api/core/geom/query/vertex.d.ts.map +1 -0
  37. package/dist/api/core/geom/update/contour.d.ts +272 -0
  38. package/dist/api/core/geom/update/contour.d.ts.map +1 -0
  39. package/dist/api/core/geom/update/curve.d.ts +180 -0
  40. package/dist/api/core/geom/update/curve.d.ts.map +1 -0
  41. package/dist/api/core/geom/update/index.d.ts +27 -0
  42. package/dist/api/core/geom/update/index.d.ts.map +1 -0
  43. package/dist/api/core/geom/update/profile.d.ts +329 -0
  44. package/dist/api/core/geom/update/profile.d.ts.map +1 -0
  45. package/dist/api/core/groups.d.ts +485 -0
  46. package/dist/api/core/groups.d.ts.map +1 -0
  47. package/dist/api/core/history/index.d.ts +78 -0
  48. package/dist/api/core/history/index.d.ts.map +1 -0
  49. package/dist/api/core/index.d.ts +63 -0
  50. package/dist/api/core/index.d.ts.map +1 -0
  51. package/dist/api/core/layers.d.ts +402 -0
  52. package/dist/api/core/layers.d.ts.map +1 -0
  53. package/dist/api/core/math/index.d.ts +18 -0
  54. package/dist/api/core/math/index.d.ts.map +1 -0
  55. package/dist/api/core/math/quat.d.ts +170 -0
  56. package/dist/api/core/math/quat.d.ts.map +1 -0
  57. package/dist/api/core/math/vec3.d.ts +174 -0
  58. package/dist/api/core/math/vec3.d.ts.map +1 -0
  59. package/dist/api/core/project/index.d.ts +399 -0
  60. package/dist/api/core/project/index.d.ts.map +1 -0
  61. package/dist/api/core/tags.d.ts +755 -0
  62. package/dist/api/core/tags.d.ts.map +1 -0
  63. package/dist/api/core/units/index.d.ts +175 -0
  64. package/dist/api/core/units/index.d.ts.map +1 -0
  65. package/dist/api/core/zoom/index.d.ts +45 -0
  66. package/dist/api/core/zoom/index.d.ts.map +1 -0
  67. package/dist/api/design/boolean/index.d.ts +168 -0
  68. package/dist/api/design/boolean/index.d.ts.map +1 -0
  69. package/dist/api/design/create/index.d.ts +828 -0
  70. package/dist/api/design/create/index.d.ts.map +1 -0
  71. package/dist/api/design/delete/index.d.ts +63 -0
  72. package/dist/api/design/delete/index.d.ts.map +1 -0
  73. package/dist/api/design/doors/index.d.ts +268 -0
  74. package/dist/api/design/doors/index.d.ts.map +1 -0
  75. package/dist/api/design/edit/index.d.ts +49 -0
  76. package/dist/api/design/edit/index.d.ts.map +1 -0
  77. package/dist/api/design/erase/index.d.ts +160 -0
  78. package/dist/api/design/erase/index.d.ts.map +1 -0
  79. package/dist/api/design/furniture/index.d.ts +123 -0
  80. package/dist/api/design/furniture/index.d.ts.map +1 -0
  81. package/dist/api/design/index.d.ts +153 -0
  82. package/dist/api/design/index.d.ts.map +1 -0
  83. package/dist/api/design/lock.d.ts +41 -0
  84. package/dist/api/design/lock.d.ts.map +1 -0
  85. package/dist/api/design/materials/index.d.ts +297 -0
  86. package/dist/api/design/materials/index.d.ts.map +1 -0
  87. package/dist/api/design/query/geometry/index.d.ts +140 -0
  88. package/dist/api/design/query/geometry/index.d.ts.map +1 -0
  89. package/dist/api/design/query/index.d.ts +1011 -0
  90. package/dist/api/design/query/index.d.ts.map +1 -0
  91. package/dist/api/design/query/spaces.d.ts +221 -0
  92. package/dist/api/design/query/spaces.d.ts.map +1 -0
  93. package/dist/api/design/selection/index.d.ts +138 -0
  94. package/dist/api/design/selection/index.d.ts.map +1 -0
  95. package/dist/api/design/shared.d.ts +38 -0
  96. package/dist/api/design/shared.d.ts.map +1 -0
  97. package/dist/api/design/transform/index.d.ts +87 -0
  98. package/dist/api/design/transform/index.d.ts.map +1 -0
  99. package/dist/api/design/update/index.d.ts +178 -0
  100. package/dist/api/design/update/index.d.ts.map +1 -0
  101. package/dist/api/design/windows/index.d.ts +189 -0
  102. package/dist/api/design/windows/index.d.ts.map +1 -0
  103. package/dist/api/entity/buildableEnvelope.d.ts +261 -0
  104. package/dist/api/entity/buildableEnvelope.d.ts.map +1 -0
  105. package/dist/api/entity/department.d.ts +1 -0
  106. package/dist/api/entity/department.d.ts.map +1 -0
  107. package/dist/api/entity/index.d.ts +28 -0
  108. package/dist/api/entity/index.d.ts.map +1 -0
  109. package/dist/api/entity/referenceLine.d.ts +202 -0
  110. package/dist/api/entity/referenceLine.d.ts.map +1 -0
  111. package/dist/api/entity/space.d.ts +846 -0
  112. package/dist/api/entity/space.d.ts.map +1 -0
  113. package/dist/api/entity/story.d.ts +249 -0
  114. package/dist/api/entity/story.d.ts.map +1 -0
  115. package/dist/api/index.d.ts +35 -0
  116. package/dist/api/index.d.ts.map +1 -0
  117. package/dist/api/presentation/aiInspiration.d.ts +2400 -0
  118. package/dist/api/presentation/aiInspiration.d.ts.map +1 -0
  119. package/dist/api/presentation/diagrams.d.ts +81 -0
  120. package/dist/api/presentation/diagrams.d.ts.map +1 -0
  121. package/dist/api/presentation/import.d.ts +113 -0
  122. package/dist/api/presentation/import.d.ts.map +1 -0
  123. package/dist/api/presentation/index.d.ts +45 -0
  124. package/dist/api/presentation/index.d.ts.map +1 -0
  125. package/dist/api/presentation/sheets.d.ts +176 -0
  126. package/dist/api/presentation/sheets.d.ts.map +1 -0
  127. package/dist/api/presentation/views.d.ts +296 -0
  128. package/dist/api/presentation/views.d.ts.map +1 -0
  129. package/dist/api/program/adjacency.d.ts +155 -0
  130. package/dist/api/program/adjacency.d.ts.map +1 -0
  131. package/dist/api/program/areas.d.ts +360 -0
  132. package/dist/api/program/areas.d.ts.map +1 -0
  133. package/dist/api/program/classification.d.ts +135 -0
  134. package/dist/api/program/classification.d.ts.map +1 -0
  135. package/dist/api/program/cores.d.ts +174 -0
  136. package/dist/api/program/cores.d.ts.map +1 -0
  137. package/dist/api/program/departments.d.ts +431 -0
  138. package/dist/api/program/departments.d.ts.map +1 -0
  139. package/dist/api/program/index.d.ts +69 -0
  140. package/dist/api/program/index.d.ts.map +1 -0
  141. package/dist/api/program/layout.d.ts +63 -0
  142. package/dist/api/program/layout.d.ts.map +1 -0
  143. package/dist/api/program/metrics.d.ts +108 -0
  144. package/dist/api/program/metrics.d.ts.map +1 -0
  145. package/dist/api/program/site.d.ts +367 -0
  146. package/dist/api/program/site.d.ts.map +1 -0
  147. package/dist/api/program/spreadsheet.d.ts +2041 -0
  148. package/dist/api/program/spreadsheet.d.ts.map +1 -0
  149. package/dist/handles.d.ts +138 -0
  150. package/dist/handles.d.ts.map +1 -0
  151. package/dist/host-utils.d.ts +43 -0
  152. package/dist/host-utils.d.ts.map +1 -0
  153. package/dist/index.cjs +4597 -0
  154. package/dist/index.cjs.map +1 -0
  155. package/dist/index.d.ts +5 -0
  156. package/dist/index.d.ts.map +1 -0
  157. package/dist/index.js +3870 -0
  158. package/dist/index.js.map +1 -0
  159. package/dist/types.d.ts +16 -0
  160. package/dist/types.d.ts.map +1 -0
  161. package/package.json +39 -0
  162. package/scripts/generate-manifest.mjs +193 -0
  163. package/scripts/generate-manifest.test.mjs +193 -0
  164. package/src/api/core/buildings.ts +485 -0
  165. package/src/api/core/comment/index.ts +258 -0
  166. package/src/api/core/geom/create/index.ts +293 -0
  167. package/src/api/core/geom/delete/index.ts +78 -0
  168. package/src/api/core/geom/index.ts +35 -0
  169. package/src/api/core/geom/query/arc.ts +169 -0
  170. package/src/api/core/geom/query/brep.ts +444 -0
  171. package/src/api/core/geom/query/circle.ts +404 -0
  172. package/src/api/core/geom/query/contour.ts +540 -0
  173. package/src/api/core/geom/query/curve.ts +1078 -0
  174. package/src/api/core/geom/query/edge.ts +130 -0
  175. package/src/api/core/geom/query/face.ts +403 -0
  176. package/src/api/core/geom/query/halfedge.ts +210 -0
  177. package/src/api/core/geom/query/index.ts +63 -0
  178. package/src/api/core/geom/query/profile.ts +473 -0
  179. package/src/api/core/geom/query/vertex.ts +205 -0
  180. package/src/api/core/geom/update/contour.ts +315 -0
  181. package/src/api/core/geom/update/curve.ts +209 -0
  182. package/src/api/core/geom/update/index.ts +29 -0
  183. package/src/api/core/geom/update/profile.ts +377 -0
  184. package/src/api/core/groups.ts +521 -0
  185. package/src/api/core/history/index.ts +84 -0
  186. package/src/api/core/index.ts +65 -0
  187. package/src/api/core/layers.ts +333 -0
  188. package/src/api/core/math/index.ts +20 -0
  189. package/src/api/core/math/quat.ts +172 -0
  190. package/src/api/core/math/vec3.ts +179 -0
  191. package/src/api/core/project/index.ts +418 -0
  192. package/src/api/core/tags.ts +808 -0
  193. package/src/api/core/units/index.ts +164 -0
  194. package/src/api/core/zoom/index.ts +47 -0
  195. package/src/api/design/boolean/index.ts +179 -0
  196. package/src/api/design/create/index.ts +886 -0
  197. package/src/api/design/delete/index.ts +67 -0
  198. package/src/api/design/doors/index.ts +285 -0
  199. package/src/api/design/edit/index.ts +54 -0
  200. package/src/api/design/erase/index.ts +151 -0
  201. package/src/api/design/furniture/index.ts +130 -0
  202. package/src/api/design/index.ts +162 -0
  203. package/src/api/design/lock.ts +42 -0
  204. package/src/api/design/materials/index.ts +301 -0
  205. package/src/api/design/query/geometry/index.ts +166 -0
  206. package/src/api/design/query/index.ts +937 -0
  207. package/src/api/design/query/spaces.ts +132 -0
  208. package/src/api/design/selection/index.ts +144 -0
  209. package/src/api/design/shared.ts +40 -0
  210. package/src/api/design/transform/index.ts +93 -0
  211. package/src/api/design/update/index.ts +117 -0
  212. package/src/api/design/windows/index.ts +207 -0
  213. package/src/api/entity/buildableEnvelope.ts +318 -0
  214. package/src/api/entity/department.ts +0 -0
  215. package/src/api/entity/index.ts +30 -0
  216. package/src/api/entity/referenceLine.ts +227 -0
  217. package/src/api/entity/space.ts +612 -0
  218. package/src/api/entity/story.ts +273 -0
  219. package/src/api/index.ts +37 -0
  220. package/src/api/presentation/aiInspiration.ts +1116 -0
  221. package/src/api/presentation/diagrams.ts +84 -0
  222. package/src/api/presentation/import.ts +112 -0
  223. package/src/api/presentation/index.ts +47 -0
  224. package/src/api/presentation/sheets.ts +198 -0
  225. package/src/api/presentation/views.ts +303 -0
  226. package/src/api/program/adjacency.ts +164 -0
  227. package/src/api/program/areas.ts +335 -0
  228. package/src/api/program/classification.ts +138 -0
  229. package/src/api/program/cores.ts +171 -0
  230. package/src/api/program/departments.ts +465 -0
  231. package/src/api/program/index.ts +71 -0
  232. package/src/api/program/layout.ts +68 -0
  233. package/src/api/program/metrics.ts +120 -0
  234. package/src/api/program/site.ts +326 -0
  235. package/src/api/program/spreadsheet.ts +2075 -0
  236. package/src/handles.ts +148 -0
  237. package/src/host-utils.ts +64 -0
  238. package/src/index.ts +4 -0
  239. package/src/types.ts +16 -0
  240. package/tsconfig.json +17 -0
  241. package/tsup.config.ts +12 -0
package/AGENTS.md ADDED
@@ -0,0 +1,227 @@
1
+ # Plugin Core — Agent Guide
2
+
3
+ This package is the **single source of truth** for all Snaptrude plugin API definitions.
4
+ Every change here has downstream ripple effects. Follow the checklist below **before
5
+ considering your work done**.
6
+
7
+ ## What this package contains
8
+
9
+ - Abstract API classes (`src/api/`) — define method signatures, JSDoc, and Zod schemas
10
+ - Shared types (`src/types.ts`) — `ComponentId`, `PluginApiReturn<T>`, etc.
11
+ - Host utilities (`src/host-utils.ts`) — `PluginApiMethodMap`, `PluginApiMethod`, RPC payload types
12
+
13
+ ## Transport model — Handle vs value
14
+
15
+ Every plugin API argument and return value crosses the worker↔host RPC boundary by one
16
+ of exactly **two transports**. Choose the transport per type **before** writing the
17
+ signature — it is a contract decision, not an implementation detail. Authoritative design
18
+ record: [`PLUGIN_HANDLE_MIGRATION_HLD.md`](../../PLUGIN_HANDLE_MIGRATION_HLD.md) §2–§6.
19
+ Handle types + Zod schemas live in `src/handles.ts`.
20
+
21
+ ### The decision rule (Handle or value)
22
+
23
+ > **Is the type a JS primitive (`number` / `string` / `boolean`) or a string enum?**
24
+ > **Yes → value. No (any structured type) → handle.** No third option: no value DTOs, no
25
+ > `{x,y,z}`-as-input objects, no converter layer.
26
+
27
+ - A `Vec3`, `Quat`, `Line`, `Arc`, `Curve`, `Circle`, `Profile`, `Contour`, a BREP
28
+ topology object, or any scene entity is **structured → always a handle** — even a vec3,
29
+ which is "just three numbers". We never send its components across as an input object.
30
+ - A distance in mm, a boolean flag, a count, a `"round" | "square"` enum → **value**.
31
+ - **Reads are the one exception:** a read returns a bare **primitive record** (e.g.
32
+ `{ x, y, z }`) by value. That is not a value transport for a structured *type*; it is the
33
+ irreducible read leaf. A read must never mint a handle per call (§3).
34
+
35
+ ### Value transport — rules
36
+
37
+ - Primitives and enums only. No object arg may stand in for a structured type.
38
+ - Validated for **shape** at the router (`validateRPCCall`); numbers use Zod `.finite()`
39
+ wherever a schema exists. Trusted for shape only — never for identity or existence.
40
+ - Stateless: no arena, no registry, no lifecycle, no `dispose`.
41
+
42
+ ### Handle transport — rules
43
+
44
+ A handle is an opaque, kind-tagged string `"<kind>_<token>"` (`Handle<K>`), engine-free
45
+ and structured-clone-safe. The three method shapes:
46
+
47
+ - **Construction** — primitives in → handle out, async: `vec3.new({x,y,z}): Promise<Vec3Handle>`.
48
+ - **Operations** — handles in → handle out, async (every op is a host round-trip):
49
+ `vec3.add({a,b}): Promise<Vec3Handle>`.
50
+ - **Reads** — handle in → **primitive record out** (never a handle, never a DTO):
51
+ `vec3.components({v}): Promise<{x,y,z}>`.
52
+
53
+ Crossing/security rules:
54
+
55
+ - **Validation**: `handleSchema(kind)` checks only the `"<kind>_"` prefix at the trust
56
+ boundary; existence + kind + ownership are enforced host-side on resolve, and any miss
57
+ throws one `HANDLE_INVALID` (anti-oracle). Never resolve a handle in plugin-core.
58
+ - **Host wiring**: add a `register*`/`resolve*` pair in `plugins/handles/valueResolvers.ts`
59
+ (the one handle↔object converter) for value/resource handles. Entity handles are **not**
60
+ registered — they resolve live via the scene index. Reads build the record inline
61
+ (`{ x: v.x, y: v.y, z: v.z }`), never via a converter.
62
+
63
+ #### Handle classes — pick by lifecycle
64
+
65
+ All three are handles; they differ only in storage + lifecycle. Choose per backing object:
66
+
67
+ | Class | Kinds | Token shape | Storage | Lifecycle |
68
+ | ------------ | ---------------------------------------------------------------------------------- | ---------------------------------------- | ---------------------------------------------------------- | --------------------------------------------------------------- |
69
+ | **Value** | `vec3`, `quat`, `line`, `arc`, `curve`, `circle` | `<kind>_<token>` | value arena (quota 100k) | immutable; freed on plugin teardown; **not** deduped |
70
+ | **Resource** | `profile`, `contour`, `brep`, `face`, `edge`, `halfedge`, `vertex` | `<kind>_<token>` | resource arena (quota 10k) | session-ephemeral; explicit `dispose` + teardown; dedup by identity |
71
+ | **Entity** | `component`/`mass`, `material`, `story`, `referenceLine`, `department`, `buildableEnvelope` | raw `Component.id` / `Material.name` (**no prefix**) | not stored — resolved live via `StructureCollection` / `getMaterialByName` | scene-owned; stable across undo/redo; persistable across sessions |
72
+
73
+ - **Value vs Resource**: a lightweight immutable math/geom value with high churn → value
74
+ arena (big quota, no dispose obligation). A heavier engine object a plugin holds then
75
+ releases → resource arena (small quota, must `dispose`; deduped by object identity).
76
+ - **Entity**: any live scene object with a stable `Component.id` → entity handle. No arena,
77
+ no quota, no `<kind>_` prefix — the token IS the id, so it round-trips with the ids the
78
+ host already hands out.
79
+
80
+ ## Quick commands
81
+
82
+ ```bash
83
+ pnpm check-types # typecheck (no emit)
84
+ pnpm build # tsup build (ESM + CJS)
85
+ pnpm dev # tsup watch mode
86
+ ```
87
+
88
+ ## Change propagation checklist
89
+
90
+ Any time you add, remove, rename, or change the signature of an API method or type in
91
+ this package, you **must** propagate changes to all downstream consumers. Use this
92
+ checklist:
93
+
94
+ ### 1. Client implementation — `packages/plugin-client/`
95
+
96
+ > See [`packages/plugin-client/AGENTS.md`](../../packages/plugin-client/AGENTS.md) for client-specific guidance.
97
+
98
+ Every abstract method in `plugin-core` is served to plugins by `plugin-client`, but the
99
+ client has **no per-method code**: every namespace is backed by a single generic RPC
100
+ proxy (`createRpcNamespace` in `src/rpc-proxy.ts`). All calls — including math and
101
+ geom — are forwarded to the host; structured values cross as opaque handles.
102
+
103
+ | plugin-core source | plugin-client counterpart |
104
+ | ------------------- | ------------------------------------------------------------------ |
105
+ | `src/api/core/**` | `createRpcNamespace<PluginCoreApi>("core")` in `src/api/index.ts` |
106
+ | `src/api/design/**` | `createRpcNamespace<PluginDesignApi>("design")` in the same file |
107
+ | `src/api/entity/**` | `createRpcNamespace<PluginEntityApi>("entity")` in the same file |
108
+ | `src/api/tools/**` | `createRpcNamespace<PluginToolsApi>("tools")` in the same file |
109
+
110
+ - **New / removed / renamed method or signature change**: No client code change — the
111
+ proxy is generic and the types flow from plugin-core. Rebuild plugin-core so the
112
+ client picks up the new signatures.
113
+ - **New nested API module** (e.g. a new file under `core/` or `design/`): No client change
114
+ - **New top-level namespace**: Add a `createRpcNamespace<PluginXApi>("x")` property to
115
+ `ClientPluginApi` in `src/api/index.ts`
116
+
117
+ ### 2. Host implementation — `apps/snaptrudereact/src/app/plugins/api/`
118
+
119
+ > See [`apps/snaptrudereact/src/app/plugins/AGENTS.md`](../../apps/snaptrudereact/src/app/plugins/AGENTS.md) for host-specific guidance.
120
+
121
+ The host mirrors this package's `src/api/` file structure 1:1. Host classes extend the
122
+ abstract classes from plugin-core and provide the actual Snaptrude-internal implementation.
123
+
124
+ - **New method**: Implement using Snaptrude internals. Use Zod `.parse()` for input validation.
125
+ - **Removed method**: Delete from host
126
+ - **Renamed/signature change**: Update the host method to match
127
+ - **New API module**: Create the host file, wire into barrel, and add to `SnaptrudePluginApi` in `api/index.ts`
128
+ - **New structured type**: Structured types cross as opaque handles (all-handle model) — there is no DTO converter layer. Add a `register*`/`resolve*` pair in the host's `plugins/handles/valueResolvers.ts` (the one handle ↔ live-object converter); reads return primitive records built inline via `handles/readRecords.ts`.
129
+
130
+ ### 3. JSDoc — keep it complete
131
+
132
+ All public methods and types **must** have JSDoc with:
133
+
134
+ - A brief description
135
+ - `@param` for each parameter (with type and description)
136
+ - `@returns` description
137
+ - `@example` where helpful (especially for entity/tools APIs)
138
+
139
+ JSDoc in this package is the source of truth for the API docs site.
140
+
141
+ ### 4. API documentation — `apps/snaptrudereact/api-docs/`
142
+
143
+ > See [`apps/snaptrudereact/api-docs/AGENTS.md`](../../apps/snaptrudereact/api-docs/AGENTS.md) for the full source-to-doc mapping and sync procedure.
144
+
145
+ In summary:
146
+
147
+ - **Changed method**: Update the corresponding `.md` doc page to match the new JSDoc
148
+ - **New API module**: Create a new doc page following the template in `AGENTS.md`, and add it to `.vitepress/sidebar.mts`
149
+ - **Removed API module**: Delete the doc page and remove from sidebar
150
+
151
+ ### 5. Console tests — `apps/snaptrudereact/src/app/plugins/apiConsoleTesting/`
152
+
153
+ > See [`apps/snaptrudereact/src/app/plugins/AGENTS.md`](../../apps/snaptrudereact/src/app/plugins/AGENTS.md) for test harness details.
154
+
155
+ These are in-browser integration tests that exercise the plugin API end-to-end.
156
+
157
+ | plugin-core API module | Test file |
158
+ | ------------------------------------------------- | ---------------------------- |
159
+ | `core/math/*` | `tests/math.ts` |
160
+ | `core/geom/*` (curve/arc/profile/contour) | `tests/geom.ts` |
161
+ | `core/geom/query/*` (brep/face/edge/vertex topology) | `tests/geomTopology.ts` |
162
+ | `core/units/*` | `tests/units.ts` |
163
+ | `core/history/*` | `tests/history.ts` |
164
+ | `core/zoom/*` | `tests/zoom.ts` |
165
+ | `core/project/*` | `tests/project.ts` |
166
+ | `core/comment/*` | `tests/comment.ts` |
167
+ | `design/boolean/*` | `tests/designBoolean.ts` |
168
+ | `design/create/*` | `tests/designCreate.ts` |
169
+ | `design/query/*` | `tests/designQuery.ts` |
170
+ | `design/selection/*` | `tests/designSelection.ts` |
171
+ | `design/lock.ts` | `tests/designLock.ts` |
172
+ | `design/delete/*` | `tests/delete.ts` |
173
+ | `design/erase/*` | `tests/erase.ts` |
174
+ | `design/doors/*` | `tests/doors.ts` |
175
+ | `design/windows/*` | `tests/windows.ts` |
176
+ | `design/furniture/*` | `tests/furniture.ts` |
177
+ | `design/materials/*` | `tests/materials.ts` |
178
+ | `entity/space.ts` | `tests/spaces.ts` |
179
+ | `entity/story.ts` | `tests/story.ts` |
180
+ | `entity/referenceLine.ts` | `tests/referenceLines.ts` |
181
+ | `entity/department.ts` | `tests/departments.ts` |
182
+ | `entity/buildableEnvelope.ts` | `tests/buildableEnvelope.ts` |
183
+ | `tools/selection.ts` | `tests/selection.ts` |
184
+ | `tools/transform.ts` | `tests/transform.ts` |
185
+ | `tools/copy.ts` | `tests/copy.ts` |
186
+ | `tools/offset.ts` | `tests/offset.ts` |
187
+
188
+ - **New method**: Add test cases covering the new method
189
+ - **Removed method**: Remove corresponding tests
190
+ - **Signature change**: Update test calls to match new signature
191
+ - **New API module**: Create a new test file under `tests/` and import it in `tests/index.ts`
192
+
193
+ ### 6. Host-side Jest unit tests
194
+
195
+ Some host implementations have co-located `.test.ts` files:
196
+
197
+ - `api/core/math/vec3.test.ts`, `quat.test.ts`
198
+
199
+ If your change affects pure math logic, update the corresponding Jest tests.
200
+
201
+ ### 7. Downstream consumers (breaking changes only)
202
+
203
+ If your change is **breaking** (removed method, renamed method, changed required args),
204
+ check **all** consumers of `@snaptrude/plugin-client` or `@snaptrude/plugin-core`:
205
+
206
+ - Internal plugins under `plugins/`
207
+ - Example plugins under `examples/` — these are consumer-facing templates used by
208
+ `create-snaptrude-plugin`, so they must compile and demonstrate correct API usage
209
+
210
+ Search these directories for usage of the changed API and update accordingly.
211
+
212
+ ## Adding a new API namespace (end-to-end)
213
+
214
+ When adding an entirely new namespace (e.g. `snaptrude.materials`):
215
+
216
+ 1. **plugin-core**: Create abstract class + Zod schemas + types in `src/api/<namespace>/`
217
+ 2. **plugin-core**: Export from `src/api/index.ts` and add as property on `PluginApi`
218
+ 3. **plugin-core**: Verify `host-utils.ts` types auto-infer the new methods (they should via `ExtractMethodPaths`)
219
+ 4. **plugin-client**: Only if it's a new **top-level** namespace, add a
220
+ `createRpcNamespace<PluginXApi>("x")` property to `ClientPluginApi` in
221
+ `src/api/index.ts` (nested namespaces need no client change)
222
+ 5. **host**: Create host implementation in `apps/snaptrudereact/src/app/plugins/api/<namespace>/`
223
+ 6. **host**: Add to `SnaptrudePluginApi` class in `api/index.ts`
224
+ 7. **docs**: Create doc pages, update sidebar, follow [`apps/snaptrudereact/api-docs/AGENTS.md`](../../apps/snaptrudereact/api-docs/AGENTS.md) template
225
+ 8. **tests**: Add console test file + Jest tests for pure logic
226
+ 9. **examples**: Update example plugins if they should showcase the new namespace
227
+ 10. **build**: Run `pnpm check-types` in plugin-core, plugin-client, and snaptrudereact
package/CHANGELOG.md ADDED
@@ -0,0 +1,119 @@
1
+ # @snaptrude/plugin-core
2
+
3
+ ## 0.0.0-dev-20260708130115
4
+
5
+ ### Patch Changes
6
+
7
+ - 8f22cb7: Expand `presentation.aiInspiration` to the full AI Inspiration surface (18 methods) and make it a required member of `PluginPresentationApi` now that the host implementation lands.
8
+ - New methods: `getModelCapabilities`, `getSelection`, `getPresetCatalog`, `getJob`, `cancelJob`, `listJobs`, `getWorkflowForShape`, `getSelectedBranchRerunPlan`, `rerunSelectedBranch`, `extractRecipeFromShape`, `listRecipes`, `saveRecipe`, `deleteRecipe`, `runRecipe` (plus job/workflow/recipe Zod schemas).
9
+ - `generate`/`refine` (and `rerunSelectedBranch`/`runRecipe`) accept `runMode: "blocking" | "job"`; `PluginAIInspirationRunResult` is accordingly loosened to `{ jobId?, output?, outputs?, metadata? }` — job-mode calls resolve with a `jobId` instead of outputs.
10
+
11
+ ## 0.5.0
12
+
13
+ ### Minor Changes
14
+
15
+ - 7750aa3: Exposed more snaptrude APIs
16
+
17
+ ## 0.4.0
18
+
19
+ The Plugin API expose initiative. Pre-1.0, breaking changes ship as minor
20
+ version bumps.
21
+
22
+ ### Minor Changes
23
+
24
+ - **Breaking — positional arguments.** Every API method now takes positional
25
+ parameters, options-last (required first, then one optional `options`
26
+ object), replacing the single-args-object transport. Migrate by unwrapping
27
+ the object into positional args — `foo({ a, b, t })` → `foo(a, b, t)`. E.g.
28
+ `vec3.lerp(a, b, 0.5)`, `departments.assign(departmentId, spaceIds)`,
29
+ `design.query.spaces.get(space, ["area", "position"])`.
30
+ - **Breaking — handle-based boundary.** Only JS primitives and enum strings
31
+ cross the plugin ↔ host boundary by value. Every structured type (vector,
32
+ curve, profile, BREP topology, scene entity) is now an opaque, kind-tagged
33
+ string handle; scene-entity references use `ComponentHandle`. Migrate by
34
+ minting a handle instead of passing a raw object (`vec3.new(x, y, z)`, then
35
+ pass the handle) and reading values back with a query call
36
+ (`vec3.components(h)` → `{ x, y, z }`) — reads return primitive records,
37
+ never handles.
38
+ - **New namespaces.** Reorganized the surface into `core`, `design`, `entity`,
39
+ `program`, and `presentation`:
40
+ - `core`: `math` (`vec3`/`quat`), the `geom` geometry kernel, `history`
41
+ (undo/redo), `units`, `zoom`, `project`, `comment`, and the
42
+ `groups`/`buildings`/`layers`/`tags` organization families.
43
+ - `design`: `create`, `query` (+ `geom` query), `selection`, `doors`,
44
+ `windows`, `furniture`, `materials`, `boolean`, `erase`, `delete`,
45
+ `transform`, `edit`, `update`, plus top-level `lock`/`unlock`/`isLocked`/
46
+ `listLocked` verbs.
47
+ - `entity`: `story`, `referenceLine`, `buildableEnvelope`.
48
+ - `program`: `areas`, `departments`, `metrics`, `site`, `cores`,
49
+ `classification`, `adjacency`, and the `spreadsheet` reporting family.
50
+ - `presentation`: `views`, `sheets`, `diagrams`, `import`.
51
+ - Removed the legacy `entity.space.*` methods from the contract and
52
+ consolidated departments under `program.departments`. The selective space
53
+ property read is now `design.query.spaces.get`, and space adjacency is read
54
+ as an entity property via `design.query.getProperties().adjacency`. (The
55
+ host keeps a deprecated `entity.space.get` shim, but it is no longer part of
56
+ the published contract surface.)
57
+ - Added the `overlaps` entity filter to `design.query` list methods — matches
58
+ entities whose plan footprint has non-zero intersection area with a given
59
+ space's bottom-face footprint (fully-inside, boundary-nested, and overhanging
60
+ all match; edge-touching does not; holes respected). Hidden entities are
61
+ excluded unless `isHidden` is passed explicitly.
62
+ - Removed the never-shipped `computeAdjacencyMatrix`; renamed
63
+ `buildings.duplicate` → `buildings.copy`; folded `tags.createAndAssign` into
64
+ `tags.assign` (resolve-or-create, one atomic undo).
65
+
66
+ ## 0.2.8
67
+
68
+ ### Patch Changes
69
+
70
+ - 445e0b8: Add Present-mode AI Inspiration plugin APIs under `snaptrude.documentation.aiInspiration`.
71
+
72
+ ## 0.2.7
73
+
74
+ ### Patch Changes
75
+
76
+ - c5afd9a: added adjacecny
77
+
78
+ ## 0.2.6
79
+
80
+ ### Patch Changes
81
+
82
+ - c17d287: Add bulk space APIs: `space.bulkCreate`, `space.bulkUpdate`, and `space.bulkDelete`. Each batches its work into a single undo/redo step. All items are validated up front and the call throws if any item is invalid (nothing is applied), consistent with the single-item space methods. `bulkCreate` supports `spaceType`/`massType`/`departmentId` per item and returns `{ spaceIds }`; `bulkUpdate` takes geometry (`profile`+`extrudeHeight`) and/or nested `properties` per item and returns `{ spaces }` (one echoed result per item, like `update`); `bulkDelete` returns `{ deletedSpaceIds }`.
83
+ - 0683194: bulk apis
84
+
85
+ ## 0.2.5
86
+
87
+ ### Patch Changes
88
+
89
+ - Restore declaration files in published plugin packages.
90
+
91
+ ## 0.2.4
92
+
93
+ ### Patch Changes
94
+
95
+ - Add inner profile hole support to space creation from profiles.
96
+
97
+ ## 0.2.3
98
+
99
+ ### Patch Changes
100
+
101
+ - 647466b: fixed merge issues
102
+
103
+ ## 0.2.2
104
+
105
+ ### Patch Changes
106
+
107
+ - 064777a: buildable envelope apis
108
+
109
+ ## 0.2.1
110
+
111
+ ### Patch Changes
112
+
113
+ - 3b37f4a: added buildable envelop api
114
+
115
+ ## 0.2.0
116
+
117
+ ### Minor Changes
118
+
119
+ - 4d959a4: Exposed new offset and copy APIs for tools
package/CLAUDE.md ADDED
@@ -0,0 +1,11 @@
1
+ # CLAUDE.md
2
+
3
+ > **All coding standards, checks, and guidance live in [`AGENTS.md`](AGENTS.md).**
4
+ > `CLAUDE.md` is a pointer only — add all new rules, patterns, and instructions to `AGENTS.md`.
5
+
6
+ See [AGENTS.md](AGENTS.md) for:
7
+
8
+ - What this package contains and quick commands
9
+ - **Change propagation checklist** — the mandatory downstream sync steps for any API change
10
+ - File mappings to plugin-client, host implementation, docs, and tests
11
+ - End-to-end guide for adding a new API namespace