@snaptrude/plugin-core 0.9.16 → 0.9.18-edgesetbacks-20261021.1

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 (221) hide show
  1. package/AGENTS.md +231 -231
  2. package/CHANGELOG.md +408 -402
  3. package/CLAUDE.md +11 -11
  4. package/api-manifest.json +1510 -701
  5. package/dist/api/analysis/daylight.d.ts +5 -5
  6. package/dist/api/analysis/solar.d.ts +2 -2
  7. package/dist/api/core/camera/index.d.ts +29 -0
  8. package/dist/api/core/camera/index.d.ts.map +1 -1
  9. package/dist/api/core/geom/create/index.d.ts +7 -1
  10. package/dist/api/core/geom/create/index.d.ts.map +1 -1
  11. package/dist/api/core/geom/update/contour.d.ts +8 -2
  12. package/dist/api/core/geom/update/contour.d.ts.map +1 -1
  13. package/dist/api/core/storeys/index.d.ts +5 -2
  14. package/dist/api/core/storeys/index.d.ts.map +1 -1
  15. package/dist/api/core/zoom/index.d.ts +13 -0
  16. package/dist/api/core/zoom/index.d.ts.map +1 -1
  17. package/dist/api/design/bim.d.ts +299 -0
  18. package/dist/api/design/bim.d.ts.map +1 -0
  19. package/dist/api/design/boolean/index.d.ts +2 -0
  20. package/dist/api/design/boolean/index.d.ts.map +1 -1
  21. package/dist/api/design/catalog.d.ts +320 -0
  22. package/dist/api/design/catalog.d.ts.map +1 -0
  23. package/dist/api/design/create/bulk-items.d.ts +65 -25
  24. package/dist/api/design/create/bulk-items.d.ts.map +1 -1
  25. package/dist/api/design/create/index.d.ts +299 -100
  26. package/dist/api/design/create/index.d.ts.map +1 -1
  27. package/dist/api/design/create/opening-fields.d.ts +13 -12
  28. package/dist/api/design/create/opening-fields.d.ts.map +1 -1
  29. package/dist/api/design/delete/index.d.ts +1 -0
  30. package/dist/api/design/delete/index.d.ts.map +1 -1
  31. package/dist/api/design/doors/index.d.ts +18 -24
  32. package/dist/api/design/doors/index.d.ts.map +1 -1
  33. package/dist/api/design/family.d.ts +813 -35
  34. package/dist/api/design/family.d.ts.map +1 -1
  35. package/dist/api/design/index.d.ts +16 -0
  36. package/dist/api/design/index.d.ts.map +1 -1
  37. package/dist/api/design/networks.d.ts +1703 -0
  38. package/dist/api/design/networks.d.ts.map +1 -0
  39. package/dist/api/design/query/grids.d.ts +2 -2
  40. package/dist/api/design/query/index.d.ts +42 -32
  41. package/dist/api/design/query/index.d.ts.map +1 -1
  42. package/dist/api/design/selection/index.d.ts +10 -10
  43. package/dist/api/design/types/index.d.ts +40 -24
  44. package/dist/api/design/types/index.d.ts.map +1 -1
  45. package/dist/api/design/update/index.d.ts +111 -6
  46. package/dist/api/design/update/index.d.ts.map +1 -1
  47. package/dist/api/design/windows/index.d.ts +8 -8
  48. package/dist/api/design/windows/index.d.ts.map +1 -1
  49. package/dist/api/entity/buildableEnvelope.d.ts +84 -2
  50. package/dist/api/entity/buildableEnvelope.d.ts.map +1 -1
  51. package/dist/api/presentation/aiInspiration.d.ts +10 -10
  52. package/dist/api/presentation/annotate.d.ts +38 -22
  53. package/dist/api/presentation/annotate.d.ts.map +1 -1
  54. package/dist/api/presentation/drawingContract.d.ts +32 -0
  55. package/dist/api/presentation/drawingContract.d.ts.map +1 -0
  56. package/dist/api/presentation/drawings.d.ts +3523 -0
  57. package/dist/api/presentation/drawings.d.ts.map +1 -0
  58. package/dist/api/presentation/export.d.ts +23 -5
  59. package/dist/api/presentation/export.d.ts.map +1 -1
  60. package/dist/api/presentation/index.d.ts +41 -12
  61. package/dist/api/presentation/index.d.ts.map +1 -1
  62. package/dist/api/presentation/placedViews.d.ts +106 -6
  63. package/dist/api/presentation/placedViews.d.ts.map +1 -1
  64. package/dist/api/presentation/sections.d.ts +461 -0
  65. package/dist/api/presentation/sections.d.ts.map +1 -0
  66. package/dist/api/presentation/shapes.d.ts +2 -2
  67. package/dist/api/presentation/sheets.d.ts +175 -19
  68. package/dist/api/presentation/sheets.d.ts.map +1 -1
  69. package/dist/api/presentation/viewPresets.d.ts +222 -0
  70. package/dist/api/presentation/viewPresets.d.ts.map +1 -0
  71. package/dist/api/presentation/views.d.ts +141 -8
  72. package/dist/api/presentation/views.d.ts.map +1 -1
  73. package/dist/api/presentation/walkthroughs.d.ts +6 -6
  74. package/dist/errors/codes.d.ts +3 -1
  75. package/dist/errors/codes.d.ts.map +1 -1
  76. package/dist/index.cjs +3883 -2385
  77. package/dist/index.cjs.map +1 -1
  78. package/dist/index.js +3744 -2385
  79. package/dist/index.js.map +1 -1
  80. package/package.json +1 -1
  81. package/scripts/check-dist-fresh.mjs +22 -22
  82. package/scripts/generate-manifest.mjs +243 -238
  83. package/scripts/generate-manifest.test.mjs +303 -303
  84. package/src/api/analysis/daylight.ts +470 -470
  85. package/src/api/analysis/heatmaps.ts +683 -683
  86. package/src/api/analysis/illuminance.ts +155 -155
  87. package/src/api/analysis/index.ts +61 -61
  88. package/src/api/analysis/shadows.ts +183 -183
  89. package/src/api/analysis/solar.ts +237 -237
  90. package/src/api/analysis/sunlightHours.ts +211 -211
  91. package/src/api/analysis/sunpath.ts +83 -83
  92. package/src/api/analysis/weather.ts +179 -179
  93. package/src/api/core/buildings.ts +485 -485
  94. package/src/api/core/camera/index.ts +696 -667
  95. package/src/api/core/comment/index.ts +376 -376
  96. package/src/api/core/geom/create/index.ts +2139 -2133
  97. package/src/api/core/geom/delete/index.ts +84 -84
  98. package/src/api/core/geom/index.ts +35 -35
  99. package/src/api/core/geom/query/arc.ts +169 -169
  100. package/src/api/core/geom/query/brep.ts +621 -621
  101. package/src/api/core/geom/query/circle.ts +404 -404
  102. package/src/api/core/geom/query/contour.ts +540 -540
  103. package/src/api/core/geom/query/curve.ts +1102 -1102
  104. package/src/api/core/geom/query/edge.ts +130 -130
  105. package/src/api/core/geom/query/face.ts +508 -508
  106. package/src/api/core/geom/query/halfedge.ts +210 -210
  107. package/src/api/core/geom/query/index.ts +63 -63
  108. package/src/api/core/geom/query/profile.ts +473 -473
  109. package/src/api/core/geom/query/vertex.ts +205 -205
  110. package/src/api/core/geom/update/contour.ts +323 -317
  111. package/src/api/core/geom/update/curve.ts +209 -209
  112. package/src/api/core/geom/update/index.ts +29 -29
  113. package/src/api/core/geom/update/profile.ts +379 -379
  114. package/src/api/core/groups.ts +521 -521
  115. package/src/api/core/handles/index.ts +234 -234
  116. package/src/api/core/history/index.ts +84 -84
  117. package/src/api/core/index.ts +99 -99
  118. package/src/api/core/io/export/index.ts +126 -126
  119. package/src/api/core/io/import/index.ts +504 -504
  120. package/src/api/core/io/index.ts +42 -42
  121. package/src/api/core/io/job/index.ts +140 -140
  122. package/src/api/core/io/query/index.ts +71 -71
  123. package/src/api/core/io/terrain/index.ts +360 -360
  124. package/src/api/core/io/underlay/index.ts +705 -705
  125. package/src/api/core/layers.ts +540 -540
  126. package/src/api/core/math/index.ts +20 -20
  127. package/src/api/core/math/quat.ts +172 -172
  128. package/src/api/core/math/vec3.ts +179 -179
  129. package/src/api/core/mode/index.ts +108 -108
  130. package/src/api/core/project/index.ts +479 -479
  131. package/src/api/core/proposals/index.ts +570 -570
  132. package/src/api/core/storeys/index.ts +311 -308
  133. package/src/api/core/storeys/layers.ts +339 -339
  134. package/src/api/core/tags.ts +911 -911
  135. package/src/api/core/units/index.ts +164 -164
  136. package/src/api/core/user.ts +46 -46
  137. package/src/api/core/zoom/index.ts +64 -51
  138. package/src/api/design/bim.ts +210 -0
  139. package/src/api/design/boolean/index.ts +181 -179
  140. package/src/api/design/catalog.ts +203 -0
  141. package/src/api/design/create/bulk-items.ts +294 -254
  142. package/src/api/design/create/grids.ts +137 -137
  143. package/src/api/design/create/index.ts +2178 -1980
  144. package/src/api/design/create/opening-fields.ts +40 -37
  145. package/src/api/design/delete/index.ts +75 -74
  146. package/src/api/design/dimensions.ts +453 -453
  147. package/src/api/design/doors/index.ts +516 -500
  148. package/src/api/design/edit/index.ts +54 -54
  149. package/src/api/design/erase/index.ts +151 -151
  150. package/src/api/design/family.ts +1342 -704
  151. package/src/api/design/furniture/index.ts +319 -319
  152. package/src/api/design/grids.ts +237 -237
  153. package/src/api/design/index.ts +304 -274
  154. package/src/api/design/lock.ts +69 -69
  155. package/src/api/design/materials/index.ts +608 -608
  156. package/src/api/design/networks.ts +607 -0
  157. package/src/api/design/query/geometry/index.ts +319 -319
  158. package/src/api/design/query/grids.ts +197 -197
  159. package/src/api/design/query/index.ts +1236 -1226
  160. package/src/api/design/query/referenceLines.ts +52 -52
  161. package/src/api/design/query/spaces.ts +275 -275
  162. package/src/api/design/selection/index.ts +273 -273
  163. package/src/api/design/shared.ts +40 -40
  164. package/src/api/design/transform/index.ts +254 -254
  165. package/src/api/design/types/index.ts +163 -156
  166. package/src/api/design/update/index.ts +1096 -983
  167. package/src/api/design/visibility.ts +143 -143
  168. package/src/api/design/windows/index.ts +351 -333
  169. package/src/api/entity/buildableEnvelope.ts +397 -322
  170. package/src/api/entity/index.ts +30 -30
  171. package/src/api/entity/referenceLine.ts +235 -235
  172. package/src/api/entity/space.ts +612 -612
  173. package/src/api/entity/story.ts +517 -517
  174. package/src/api/index.ts +47 -47
  175. package/src/api/presentation/aiInspiration.ts +1116 -1116
  176. package/src/api/presentation/annotate.ts +417 -385
  177. package/src/api/presentation/camera.ts +289 -289
  178. package/src/api/presentation/diagrams.ts +194 -194
  179. package/src/api/presentation/drawingContract.ts +70 -0
  180. package/src/api/presentation/drawings.ts +1179 -0
  181. package/src/api/presentation/export.ts +134 -108
  182. package/src/api/presentation/import.ts +159 -159
  183. package/src/api/presentation/index.ts +160 -126
  184. package/src/api/presentation/placedViews.ts +1211 -1120
  185. package/src/api/presentation/sections.ts +420 -0
  186. package/src/api/presentation/shapes.ts +274 -274
  187. package/src/api/presentation/sheets.ts +746 -585
  188. package/src/api/presentation/slideshow.ts +134 -134
  189. package/src/api/presentation/tables.ts +84 -84
  190. package/src/api/presentation/viewPresets.ts +241 -0
  191. package/src/api/presentation/views.ts +742 -673
  192. package/src/api/presentation/walkthroughs.ts +1201 -1201
  193. package/src/api/program/adjacency.ts +164 -164
  194. package/src/api/program/areas.ts +408 -408
  195. package/src/api/program/classification.ts +138 -138
  196. package/src/api/program/cores.ts +83 -83
  197. package/src/api/program/departments.ts +517 -517
  198. package/src/api/program/index.ts +73 -73
  199. package/src/api/program/labels.ts +332 -332
  200. package/src/api/program/layout.ts +422 -422
  201. package/src/api/program/metadata.ts +364 -364
  202. package/src/api/program/metrics.ts +120 -120
  203. package/src/api/program/site.ts +748 -748
  204. package/src/api/program/spreadsheet.ts +2698 -2698
  205. package/src/api/workspace/index.ts +612 -612
  206. package/src/errors/codes.ts +143 -136
  207. package/src/errors/envelope.ts +75 -75
  208. package/src/errors/index.ts +21 -21
  209. package/src/errors/plugin-error.ts +134 -134
  210. package/src/handles.ts +297 -297
  211. package/src/host-utils.ts +67 -67
  212. package/src/index.ts +7 -7
  213. package/src/massParameters.ops.ts +246 -246
  214. package/src/massParameters.ts +427 -427
  215. package/src/types.ts +16 -16
  216. package/test/drawingContract.test.mjs +288 -0
  217. package/test/errors.test.mjs +185 -184
  218. package/test/massParameters.test.mjs +952 -952
  219. package/test/presentationViewSettings.test.mjs +85 -0
  220. package/tsconfig.json +22 -22
  221. package/tsup.config.ts +12 -12
package/src/types.ts CHANGED
@@ -1,16 +1,16 @@
1
- /**
2
- * A unique identifier for a component in the Snaptrude scene.
3
- *
4
- * Component IDs are returned by entity creation methods (e.g.
5
- * {@linkcode PluginSpaceApi.createRectangular}) and can be used with
6
- * query and transform methods throughout the API.
7
- */
8
- export type ComponentId = string
9
-
10
- /**
11
- * Return type for a plugin API method.
12
- *
13
- * Methods that require a host round-trip return `Promise<T>`,
14
- * while pure local computations may return `T` directly.
15
- */
16
- export type PluginApiReturn<T> = Promise<T> | T
1
+ /**
2
+ * A unique identifier for a component in the Snaptrude scene.
3
+ *
4
+ * Component IDs are returned by entity creation methods (e.g.
5
+ * {@linkcode PluginSpaceApi.createRectangular}) and can be used with
6
+ * query and transform methods throughout the API.
7
+ */
8
+ export type ComponentId = string
9
+
10
+ /**
11
+ * Return type for a plugin API method.
12
+ *
13
+ * Methods that require a host round-trip return `Promise<T>`,
14
+ * while pure local computations may return `T` directly.
15
+ */
16
+ export type PluginApiReturn<T> = Promise<T> | T
@@ -0,0 +1,288 @@
1
+ // The drawing tool contract the agent reads: export file names are base names
2
+ // without an extension, and architectural scales are standard denominators only.
3
+ // Run: node --test test/
4
+ // Imports the BUILT package (dist) — run `pnpm build` first.
5
+ import test from "node:test"
6
+ import assert from "node:assert/strict"
7
+ import { readFileSync } from "node:fs"
8
+ import {
9
+ STANDARD_DRAWING_SCALES,
10
+ METRIC_DRAWING_SCALES,
11
+ IMPERIAL_DRAWING_SCALES,
12
+ IMPERIAL_DETAIL_DRAWING_SCALES,
13
+ IMPERIAL_SITE_DRAWING_SCALES,
14
+ PluginDrawingCreateOptions,
15
+ PluginDrawingCreateArgs,
16
+ PluginDrawingScaleArgs,
17
+ PluginDrawingExportOptions,
18
+ PluginDrawingExportArgs,
19
+ PluginPresentationExportArgs,
20
+ PluginPresentationSheetsPlaceArgs,
21
+ PluginPresentationSheetsPlaceDrawingArgs,
22
+ PluginPresentationSheetsPlaceDrawingResult,
23
+ PluginPresentationSheetsPlaceResult,
24
+ PluginPresentationPlacedViewsSetScaleArgs,
25
+ } from "../dist/index.js"
26
+ import { buildManifest } from "../scripts/generate-manifest.mjs"
27
+
28
+ // The Scale dropdown's values in the frontend (ALL_SCALES_DICTIONARY in
29
+ // src/app/common/utils/scaleMeasurements.ts): metric, imperial detail, imperial site.
30
+ const METRIC = [10, 20, 50, 100, 150, 200, 250, 500, 1000]
31
+ const IMPERIAL_DETAIL = [12, 16, 24, 32, 48, 64, 96, 128, 192, 384, 768, 1536]
32
+ const IMPERIAL_SITE = [120, 240, 360, 480, 600, 1200, 2400, 3600, 4800]
33
+
34
+ const messagesOf = (result) => result.error.issues.map((issue) => issue.message)
35
+
36
+ // --- standard scales ---------------------------------------------------------
37
+
38
+ test("STANDARD_DRAWING_SCALES is the frontend's metric and imperial list, ascending", () => {
39
+ const expected = [...METRIC, ...IMPERIAL_DETAIL, ...IMPERIAL_SITE].sort((a, b) => a - b)
40
+ assert.deepEqual([...STANDARD_DRAWING_SCALES], expected)
41
+ assert.deepEqual([...METRIC_DRAWING_SCALES], METRIC)
42
+ assert.deepEqual([...IMPERIAL_DRAWING_SCALES], [...IMPERIAL_DETAIL, ...IMPERIAL_SITE].sort((a, b) => a - b))
43
+ assert.deepEqual([...IMPERIAL_DETAIL_DRAWING_SCALES], IMPERIAL_DETAIL)
44
+ assert.deepEqual([...IMPERIAL_SITE_DRAWING_SCALES], IMPERIAL_SITE)
45
+ })
46
+
47
+ const scaleSchemas = [
48
+ ["drawings.create options", (scale) => PluginDrawingCreateOptions.safeParse({ scale })],
49
+ ["drawings.create args", (scale) => PluginDrawingCreateArgs.safeParse({ viewId: "v1", scale })],
50
+ ["drawings.setScale", (scale) => PluginDrawingScaleArgs.safeParse({ drawingId: "d1", scale })],
51
+ ["sheets.place", (scale) => PluginPresentationSheetsPlaceArgs.safeParse({ sheetId: "s1", viewId: "v1", scale })],
52
+ ["placedViews.setScale", (scale) => PluginPresentationPlacedViewsSetScaleArgs.safeParse({ shapeId: "p1", scale })],
53
+ ]
54
+
55
+ for (const [name, parse] of scaleSchemas) {
56
+ test(`${name} accepts every standard scale`, () => {
57
+ for (const scale of STANDARD_DRAWING_SCALES) {
58
+ assert.equal(parse(scale).success, true, `${name} rejected ${scale}`)
59
+ }
60
+ })
61
+
62
+ test(`${name} rejects a non-standard scale and lists the allowed ones`, () => {
63
+ for (const scale of [137, 75, 1, 99.5]) {
64
+ const result = parse(scale)
65
+ assert.equal(result.success, false, `${name} accepted ${scale}`)
66
+ const message = messagesOf(result).join("\n")
67
+ assert.match(message, /standard/i)
68
+ assert.ok(message.includes(`Metric: ${METRIC.join(", ")}`), message)
69
+ assert.ok(message.includes(`imperial detail: ${IMPERIAL_DETAIL.join(", ")}`), message)
70
+ assert.ok(message.includes(`imperial site: ${IMPERIAL_SITE.join(", ")}`), message)
71
+ assert.match(message, /largest/i)
72
+ }
73
+ })
74
+ }
75
+
76
+ test("create options still allow omitting the scale", () => {
77
+ assert.equal(PluginDrawingCreateOptions.safeParse({}).success, true)
78
+ assert.equal(PluginPresentationSheetsPlaceArgs.safeParse({ sheetId: "s", viewId: "v" }).success, true)
79
+ })
80
+
81
+ // --- placing a drawing on a sheet -------------------------------------------
82
+
83
+ test("sheets.placeDrawing takes an optional boolean fit", () => {
84
+ const base = { sheetId: "s", drawingId: "d" }
85
+ assert.equal(PluginPresentationSheetsPlaceDrawingArgs.safeParse(base).success, true)
86
+ assert.equal(PluginPresentationSheetsPlaceDrawingArgs.safeParse({ ...base, fit: true }).success, true)
87
+ assert.equal(PluginPresentationSheetsPlaceDrawingArgs.safeParse({ ...base, fit: false }).success, true)
88
+ assert.equal(PluginPresentationSheetsPlaceDrawingArgs.safeParse({ ...base, fit: "yes" }).success, false)
89
+ })
90
+
91
+ test("sheets.placeDrawing reports the scale it used and whether it rescaled", () => {
92
+ const ok = (value) => PluginPresentationSheetsPlaceDrawingResult.safeParse(value).success
93
+ assert.equal(ok({ shapeId: "shape:a", scale: 192, rescaled: true }), true)
94
+ assert.equal(ok({ shapeId: "shape:a", scale: null, rescaled: false }), true)
95
+ assert.equal(ok({ shapeId: "shape:a" }), false)
96
+ assert.equal(ok({ shapeId: "shape:a", scale: 100 }), false)
97
+ assert.equal(ok({ shapeId: "shape:a", scale: 100, rescaled: false, overlaps: true }), true)
98
+ assert.equal(ok({ shapeId: "shape:a", scale: 100, rescaled: false, overlaps: "yes" }), false)
99
+ })
100
+
101
+ test("sheets.place may report the scale, whether it rescaled and whether it overlaps", () => {
102
+ const ok = (value) => PluginPresentationSheetsPlaceResult.safeParse(value).success
103
+ assert.equal(ok({ shapeId: "shape:a" }), true)
104
+ assert.equal(ok({ shapeId: "shape:a", scale: 192, rescaled: true, overlaps: false }), true)
105
+ assert.equal(ok({ shapeId: "shape:a", scale: null, rescaled: false }), true)
106
+ assert.equal(ok({ shapeId: "shape:a", overlaps: "no" }), false)
107
+ assert.equal(ok({ shapeId: "shape:a", rescaled: 1 }), false)
108
+ })
109
+
110
+ test("sheets.place may report that a drawing at an explicit scale overflows the sheet; placeDrawing never does", () => {
111
+ const place = (value) => PluginPresentationSheetsPlaceResult.safeParse(value).success
112
+ assert.equal(place({ shapeId: "shape:a", scale: 100, rescaled: false, overflows: true }), true)
113
+ assert.equal(place({ shapeId: "shape:a", scale: 100, rescaled: false, overflows: "yes" }), false)
114
+ const placeDrawing = PluginPresentationSheetsPlaceDrawingResult.safeParse({
115
+ shapeId: "shape:a",
116
+ scale: 100,
117
+ rescaled: false,
118
+ overflows: true,
119
+ })
120
+ assert.equal(placeDrawing.success, true)
121
+ assert.equal("overflows" in placeDrawing.data, false)
122
+ })
123
+
124
+ // --- file names --------------------------------------------------------------
125
+
126
+ const fileNameSchemas = [
127
+ ["drawings.export options", (fileName) => PluginDrawingExportOptions.safeParse({ fileName })],
128
+ ["drawings.export args", (fileName) => PluginDrawingExportArgs.safeParse({ drawingId: "d1", format: "pdf", fileName })],
129
+ ["presentation.export", (fileName) => PluginPresentationExportArgs.safeParse({ format: "pdf", fileName })],
130
+ ]
131
+
132
+ for (const [name, parse] of fileNameSchemas) {
133
+ test(`${name} rejects a file name with an extension`, () => {
134
+ for (const fileName of ["Floor Pattern View.pdf", "plan.PDF", "a.svg", "a.png", "a.jpg", "a.JPEG"]) {
135
+ const result = parse(fileName)
136
+ assert.equal(result.success, false, `${name} accepted ${fileName}`)
137
+ assert.match(messagesOf(result).join("\n"), /without an extension/i)
138
+ }
139
+ })
140
+
141
+ test(`${name} rejects a file name ending in a dot or whitespace`, () => {
142
+ // The host appends the extension, so "a.pdf." would become "a.pdf..pdf".
143
+ for (const fileName of ["a.pdf.", "plan.", "plan..", "plan ", "plan\t", "a.pdf .", "a.pdf. "]) {
144
+ const result = parse(fileName)
145
+ assert.equal(result.success, false, `${name} accepted ${JSON.stringify(fileName)}`)
146
+ assert.match(messagesOf(result).join("\n"), /without an extension/i)
147
+ }
148
+ })
149
+
150
+ test(`${name} accepts a base name`, () => {
151
+ for (const fileName of ["Floor Pattern View", "Level 1.2 plan", "pdf plan", "notes.v2"]) {
152
+ assert.equal(parse(fileName).success, true, `${name} rejected ${fileName}`)
153
+ }
154
+ })
155
+ }
156
+
157
+ // --- the contract the agent reads (api-manifest summaries) -------------------
158
+
159
+ // Overloaded methods produce one leaf per signature; the documented one comes first.
160
+ const manifest = new Map()
161
+ for (const leaf of buildManifest()) if (!manifest.has(leaf.path)) manifest.set(leaf.path, leaf)
162
+ const summaryOf = (path) => {
163
+ const leaf = manifest.get(path)
164
+ assert.ok(leaf, `no manifest leaf ${path}`)
165
+ return leaf.summary
166
+ }
167
+
168
+ test("export summaries tell the agent to pass fileName without an extension", () => {
169
+ for (const path of ["presentation.drawings.export", "presentation.export"]) {
170
+ assert.match(summaryOf(path), /fileName[^.]*without (an|its) extension/i, path)
171
+ }
172
+ })
173
+
174
+ test("scale summaries list the standard scales and say how to choose one", () => {
175
+ for (const path of [
176
+ "presentation.drawings.create",
177
+ "presentation.drawings.setScale",
178
+ "presentation.sheets.place",
179
+ "presentation.placedViews.setScale",
180
+ ]) {
181
+ const summary = summaryOf(path)
182
+ assert.ok(summary.includes(`Metric: ${METRIC.join(", ")}.`), `${path}: ${summary}`)
183
+ assert.ok(summary.includes(`Imperial detail: ${IMPERIAL_DETAIL.join(", ")}`), `${path}: ${summary}`)
184
+ assert.ok(summary.includes(`Imperial site: ${IMPERIAL_SITE.join(", ")}`), `${path}: ${summary}`)
185
+ assert.match(summary, /Pick the LARGEST standard scale \(smallest denominator\)/, path)
186
+ assert.match(summary, /fits its frame or sheet/i, path)
187
+ assert.match(summary, /usually 1:50 to 1:200/, path)
188
+ assert.match(summary, /Never use a site-sized scale/, path)
189
+ assert.match(summary, /project's unit system/, path)
190
+ }
191
+ })
192
+
193
+ test("drawings.create tells the agent to omit position and follow the label layout's suggested scale", () => {
194
+ const summary = summaryOf("presentation.drawings.create")
195
+ assert.match(summary, /Omit `position` unless the user asked for a specific place/, summary)
196
+ assert.match(summary, /next to its source view/, summary)
197
+ assert.match(summary, /labels\.getLayout\(drawingId\)/, summary)
198
+ assert.match(summary, /suggestedScale/, summary)
199
+ })
200
+
201
+ test("drawing writes send the agent to presentation.camera instead of promising to frame the camera", () => {
202
+ for (const path of [
203
+ "presentation.drawings.create",
204
+ "presentation.drawings.setScale",
205
+ "presentation.drawings.setCrop",
206
+ ]) {
207
+ const summary = summaryOf(path)
208
+ assert.doesNotMatch(summary, /frames the camera/i, path)
209
+ assert.match(summary, /Changes the drawing, not the Present camera/, path)
210
+ assert.match(summary, /presentation\.camera\.zoomTo\(drawing\.id\)/, path)
211
+ assert.match(summary, /presentation\.camera\.capture\(\)/, path)
212
+ }
213
+ for (const path of ["presentation.drawings.setScale", "presentation.drawings.setCrop"]) {
214
+ assert.match(summaryOf(path), /moves\s+to the nearest free spot/, path)
215
+ }
216
+ })
217
+
218
+ test("drawings.create says it never puts a drawing on a sheet and names the sheet calls", () => {
219
+ const summary = summaryOf("presentation.drawings.create")
220
+ assert.match(summary, /beside its source view/, summary)
221
+ assert.match(summary, /never on a sheet/, summary)
222
+ assert.match(summary, /sheets\.place\(sheetId, viewId\)/, summary)
223
+ assert.match(summary, /sheets\.placeDrawing\(sheetId, drawingId\)/, summary)
224
+ })
225
+
226
+ test("sheets.placeDrawing documents fitting, fit: false and one sheet per drawing", () => {
227
+ const summary = summaryOf("presentation.sheets.placeDrawing")
228
+ assert.match(summary, /scaled down to fit/, summary)
229
+ assert.match(summary, /never scaled up/, summary)
230
+ assert.match(summary, /`fit: false`/, summary)
231
+ assert.match(summary, /naming the\s+drawing, the sheet and the scale/, summary)
232
+ assert.match(summary, /without\s+`fit: false`\s+to fit it, or\s+use a larger sheet/, summary)
233
+ assert.doesNotMatch(summary, /use\s+`?sheets\.place`?\s+to\s+fit/, summary)
234
+ assert.match(summary, /reports the architectural scale/, summary)
235
+ })
236
+
237
+ // Without a position the host puts the drawing at the sheet centre or the nearest free spot,
238
+ // and only centres it over other drawings (reporting overlaps: true) when there is none.
239
+ const NO_STACK = /lands\s+on\s+top/
240
+ const FREE_SPOT = /nearest\s+free\s+spot/
241
+ const CENTRED_WHEN_FULL = /no\s+free\s+spot[^.]*centred[^.]*`overlaps:\s*true`/
242
+ const EXPLICIT_POSITION = /`position`[^.]*placed\s+as\s+given[^.]*`overlaps:\s*true`[^.]*not\s+moved/
243
+ const DRAWINGS_ONLY = /only\s+other\s+drawings\s+count[^.]*text,\s+images\s+and\s+other\s+shapes/
244
+
245
+ const assertPlacementLayout = (summary) => {
246
+ assert.doesNotMatch(summary, NO_STACK, summary)
247
+ assert.match(summary, FREE_SPOT, summary)
248
+ assert.match(summary, CENTRED_WHEN_FULL, summary)
249
+ assert.match(summary, EXPLICIT_POSITION, summary)
250
+ assert.match(summary, DRAWINGS_ONLY, summary)
251
+ }
252
+
253
+ test("sheets.placeDrawing says where a drawing goes without a position and when it overlaps", () => {
254
+ assertPlacementLayout(summaryOf("presentation.sheets.placeDrawing"))
255
+ })
256
+
257
+ test("sheets.place says it is the call that puts a view on a sheet and fits it to that sheet", () => {
258
+ const summary = summaryOf("presentation.sheets.place")
259
+ assert.match(summary, /This is the call that puts a view on a\s+sheet/, summary)
260
+ assert.match(summary, /largest\s+standard scale at which it fits inside the target sheet's margin/, summary)
261
+ assert.match(summary, /never at a larger scale than the normal view drop/, summary)
262
+ assert.match(summary, /3D view[^.]*shrunk\s+evenly/, summary)
263
+ assertPlacementLayout(summary)
264
+ })
265
+
266
+ // The full JSDoc of sheets.place, for the @returns and @throws tags the summary leaves out.
267
+ const placeJsDoc = () => {
268
+ const source = readFileSync(new URL("../src/api/presentation/sheets.ts", import.meta.url), "utf8")
269
+ const end = source.indexOf("public abstract place(")
270
+ const start = source.lastIndexOf("/**", end)
271
+ return source
272
+ .slice(start, end)
273
+ .replace(/\{@linkcode (\w+)\}/g, "$1")
274
+ .replace(/\s*\*\s*/g, " ")
275
+ }
276
+
277
+ test("sheets.place documents the scale and rescaled it returns", () => {
278
+ const doc = placeJsDoc()
279
+ assert.match(doc, /@returns[^@]*`scale` used \(`null` for a 3D view\)/, doc)
280
+ assert.match(doc, /@returns[^@]*`rescaled`/, doc)
281
+ assert.doesNotMatch(doc, /a host that reports them/, doc)
282
+ })
283
+
284
+ test("sheets.place documents PRECONDITION_FAILED for a view that does not fit", () => {
285
+ const doc = placeJsDoc()
286
+ assert.match(doc, /@throws[^@]*`PRECONDITION_FAILED`[^@]*smallest standard scale/, doc)
287
+ assert.match(doc, /@throws[^@]*`PRECONDITION_FAILED`[^@]*title block alone/, doc)
288
+ })