@snaptrude/plugin-core 0.9.17 → 0.9.18-networks-20261016.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 (213) hide show
  1. package/AGENTS.md +231 -231
  2. package/CHANGELOG.md +408 -408
  3. package/CLAUDE.md +11 -11
  4. package/dist/api/analysis/daylight.d.ts +5 -5
  5. package/dist/api/analysis/solar.d.ts +2 -2
  6. package/dist/api/core/camera/index.d.ts +29 -0
  7. package/dist/api/core/camera/index.d.ts.map +1 -1
  8. package/dist/api/core/geom/create/index.d.ts +7 -1
  9. package/dist/api/core/geom/create/index.d.ts.map +1 -1
  10. package/dist/api/core/geom/update/contour.d.ts +8 -2
  11. package/dist/api/core/geom/update/contour.d.ts.map +1 -1
  12. package/dist/api/core/zoom/index.d.ts +13 -0
  13. package/dist/api/core/zoom/index.d.ts.map +1 -1
  14. package/dist/api/design/bim.d.ts +209 -0
  15. package/dist/api/design/bim.d.ts.map +1 -0
  16. package/dist/api/design/boolean/index.d.ts +2 -0
  17. package/dist/api/design/boolean/index.d.ts.map +1 -1
  18. package/dist/api/design/catalog.d.ts +320 -0
  19. package/dist/api/design/catalog.d.ts.map +1 -0
  20. package/dist/api/design/create/bulk-items.d.ts +65 -25
  21. package/dist/api/design/create/bulk-items.d.ts.map +1 -1
  22. package/dist/api/design/create/index.d.ts +272 -99
  23. package/dist/api/design/create/index.d.ts.map +1 -1
  24. package/dist/api/design/create/opening-fields.d.ts +13 -12
  25. package/dist/api/design/create/opening-fields.d.ts.map +1 -1
  26. package/dist/api/design/delete/index.d.ts +1 -0
  27. package/dist/api/design/delete/index.d.ts.map +1 -1
  28. package/dist/api/design/doors/index.d.ts +18 -24
  29. package/dist/api/design/doors/index.d.ts.map +1 -1
  30. package/dist/api/design/family.d.ts +797 -27
  31. package/dist/api/design/family.d.ts.map +1 -1
  32. package/dist/api/design/index.d.ts +16 -0
  33. package/dist/api/design/index.d.ts.map +1 -1
  34. package/dist/api/design/networks.d.ts +1763 -0
  35. package/dist/api/design/networks.d.ts.map +1 -0
  36. package/dist/api/design/query/index.d.ts +42 -32
  37. package/dist/api/design/query/index.d.ts.map +1 -1
  38. package/dist/api/design/selection/index.d.ts +10 -10
  39. package/dist/api/design/types/index.d.ts +40 -24
  40. package/dist/api/design/types/index.d.ts.map +1 -1
  41. package/dist/api/design/update/index.d.ts +43 -3
  42. package/dist/api/design/update/index.d.ts.map +1 -1
  43. package/dist/api/design/windows/index.d.ts +8 -8
  44. package/dist/api/design/windows/index.d.ts.map +1 -1
  45. package/dist/api/presentation/aiInspiration.d.ts +10 -10
  46. package/dist/api/presentation/annotate.d.ts +38 -22
  47. package/dist/api/presentation/annotate.d.ts.map +1 -1
  48. package/dist/api/presentation/drawingContract.d.ts +32 -0
  49. package/dist/api/presentation/drawingContract.d.ts.map +1 -0
  50. package/dist/api/presentation/drawings.d.ts +3523 -0
  51. package/dist/api/presentation/drawings.d.ts.map +1 -0
  52. package/dist/api/presentation/export.d.ts +23 -5
  53. package/dist/api/presentation/export.d.ts.map +1 -1
  54. package/dist/api/presentation/index.d.ts +32 -12
  55. package/dist/api/presentation/index.d.ts.map +1 -1
  56. package/dist/api/presentation/placedViews.d.ts +106 -6
  57. package/dist/api/presentation/placedViews.d.ts.map +1 -1
  58. package/dist/api/presentation/shapes.d.ts +2 -2
  59. package/dist/api/presentation/sheets.d.ts +175 -19
  60. package/dist/api/presentation/sheets.d.ts.map +1 -1
  61. package/dist/api/presentation/viewPresets.d.ts +222 -0
  62. package/dist/api/presentation/viewPresets.d.ts.map +1 -0
  63. package/dist/api/presentation/views.d.ts +103 -5
  64. package/dist/api/presentation/views.d.ts.map +1 -1
  65. package/dist/api/presentation/walkthroughs.d.ts +6 -6
  66. package/dist/errors/codes.d.ts +3 -1
  67. package/dist/errors/codes.d.ts.map +1 -1
  68. package/dist/index.cjs +3732 -2383
  69. package/dist/index.cjs.map +1 -1
  70. package/dist/index.js +3607 -2383
  71. package/dist/index.js.map +1 -1
  72. package/package.json +42 -42
  73. package/scripts/check-dist-fresh.mjs +22 -22
  74. package/scripts/generate-manifest.mjs +243 -238
  75. package/scripts/generate-manifest.test.mjs +303 -303
  76. package/src/api/analysis/daylight.ts +470 -470
  77. package/src/api/analysis/heatmaps.ts +683 -683
  78. package/src/api/analysis/illuminance.ts +155 -155
  79. package/src/api/analysis/index.ts +61 -61
  80. package/src/api/analysis/shadows.ts +183 -183
  81. package/src/api/analysis/solar.ts +237 -237
  82. package/src/api/analysis/sunlightHours.ts +211 -211
  83. package/src/api/analysis/sunpath.ts +83 -83
  84. package/src/api/analysis/weather.ts +179 -179
  85. package/src/api/core/buildings.ts +485 -485
  86. package/src/api/core/camera/index.ts +696 -667
  87. package/src/api/core/comment/index.ts +376 -376
  88. package/src/api/core/geom/create/index.ts +2139 -2133
  89. package/src/api/core/geom/delete/index.ts +84 -84
  90. package/src/api/core/geom/index.ts +35 -35
  91. package/src/api/core/geom/query/arc.ts +169 -169
  92. package/src/api/core/geom/query/brep.ts +621 -621
  93. package/src/api/core/geom/query/circle.ts +404 -404
  94. package/src/api/core/geom/query/contour.ts +540 -540
  95. package/src/api/core/geom/query/curve.ts +1102 -1102
  96. package/src/api/core/geom/query/edge.ts +130 -130
  97. package/src/api/core/geom/query/face.ts +508 -508
  98. package/src/api/core/geom/query/halfedge.ts +210 -210
  99. package/src/api/core/geom/query/index.ts +63 -63
  100. package/src/api/core/geom/query/profile.ts +473 -473
  101. package/src/api/core/geom/query/vertex.ts +205 -205
  102. package/src/api/core/geom/update/contour.ts +323 -317
  103. package/src/api/core/geom/update/curve.ts +209 -209
  104. package/src/api/core/geom/update/index.ts +29 -29
  105. package/src/api/core/geom/update/profile.ts +379 -379
  106. package/src/api/core/groups.ts +521 -521
  107. package/src/api/core/handles/index.ts +234 -234
  108. package/src/api/core/history/index.ts +84 -84
  109. package/src/api/core/index.ts +99 -99
  110. package/src/api/core/io/export/index.ts +126 -126
  111. package/src/api/core/io/import/index.ts +504 -504
  112. package/src/api/core/io/index.ts +42 -42
  113. package/src/api/core/io/job/index.ts +140 -140
  114. package/src/api/core/io/query/index.ts +71 -71
  115. package/src/api/core/io/terrain/index.ts +360 -360
  116. package/src/api/core/io/underlay/index.ts +705 -705
  117. package/src/api/core/layers.ts +540 -540
  118. package/src/api/core/math/index.ts +20 -20
  119. package/src/api/core/math/quat.ts +172 -172
  120. package/src/api/core/math/vec3.ts +179 -179
  121. package/src/api/core/mode/index.ts +108 -108
  122. package/src/api/core/project/index.ts +479 -479
  123. package/src/api/core/proposals/index.ts +570 -570
  124. package/src/api/core/storeys/index.ts +308 -308
  125. package/src/api/core/storeys/layers.ts +339 -339
  126. package/src/api/core/tags.ts +911 -911
  127. package/src/api/core/units/index.ts +164 -164
  128. package/src/api/core/user.ts +46 -46
  129. package/src/api/core/zoom/index.ts +64 -51
  130. package/src/api/design/bim.ts +121 -0
  131. package/src/api/design/boolean/index.ts +181 -179
  132. package/src/api/design/catalog.ts +203 -0
  133. package/src/api/design/create/bulk-items.ts +294 -254
  134. package/src/api/design/create/grids.ts +137 -137
  135. package/src/api/design/create/index.ts +2148 -1980
  136. package/src/api/design/create/opening-fields.ts +40 -37
  137. package/src/api/design/delete/index.ts +75 -74
  138. package/src/api/design/dimensions.ts +453 -453
  139. package/src/api/design/doors/index.ts +516 -500
  140. package/src/api/design/edit/index.ts +54 -54
  141. package/src/api/design/erase/index.ts +151 -151
  142. package/src/api/design/family.ts +1334 -704
  143. package/src/api/design/furniture/index.ts +319 -319
  144. package/src/api/design/grids.ts +237 -237
  145. package/src/api/design/index.ts +304 -274
  146. package/src/api/design/lock.ts +69 -69
  147. package/src/api/design/materials/index.ts +608 -608
  148. package/src/api/design/networks.ts +667 -0
  149. package/src/api/design/query/geometry/index.ts +319 -319
  150. package/src/api/design/query/grids.ts +197 -197
  151. package/src/api/design/query/index.ts +1236 -1226
  152. package/src/api/design/query/referenceLines.ts +52 -52
  153. package/src/api/design/query/spaces.ts +275 -275
  154. package/src/api/design/selection/index.ts +273 -273
  155. package/src/api/design/shared.ts +40 -40
  156. package/src/api/design/transform/index.ts +254 -254
  157. package/src/api/design/types/index.ts +163 -156
  158. package/src/api/design/update/index.ts +1024 -983
  159. package/src/api/design/visibility.ts +143 -143
  160. package/src/api/design/windows/index.ts +351 -333
  161. package/src/api/entity/buildableEnvelope.ts +322 -322
  162. package/src/api/entity/index.ts +30 -30
  163. package/src/api/entity/referenceLine.ts +235 -235
  164. package/src/api/entity/space.ts +612 -612
  165. package/src/api/entity/story.ts +517 -517
  166. package/src/api/index.ts +47 -47
  167. package/src/api/presentation/aiInspiration.ts +1116 -1116
  168. package/src/api/presentation/annotate.ts +417 -385
  169. package/src/api/presentation/camera.ts +289 -289
  170. package/src/api/presentation/diagrams.ts +194 -194
  171. package/src/api/presentation/drawingContract.ts +70 -0
  172. package/src/api/presentation/drawings.ts +1179 -0
  173. package/src/api/presentation/export.ts +134 -108
  174. package/src/api/presentation/import.ts +159 -159
  175. package/src/api/presentation/index.ts +160 -135
  176. package/src/api/presentation/placedViews.ts +1211 -1120
  177. package/src/api/presentation/sections.ts +420 -420
  178. package/src/api/presentation/shapes.ts +274 -274
  179. package/src/api/presentation/sheets.ts +746 -585
  180. package/src/api/presentation/slideshow.ts +134 -134
  181. package/src/api/presentation/tables.ts +84 -84
  182. package/src/api/presentation/viewPresets.ts +241 -0
  183. package/src/api/presentation/views.ts +713 -673
  184. package/src/api/presentation/walkthroughs.ts +1201 -1201
  185. package/src/api/program/adjacency.ts +164 -164
  186. package/src/api/program/areas.ts +408 -408
  187. package/src/api/program/classification.ts +138 -138
  188. package/src/api/program/cores.ts +83 -83
  189. package/src/api/program/departments.ts +517 -517
  190. package/src/api/program/index.ts +73 -73
  191. package/src/api/program/labels.ts +332 -332
  192. package/src/api/program/layout.ts +422 -422
  193. package/src/api/program/metadata.ts +364 -364
  194. package/src/api/program/metrics.ts +120 -120
  195. package/src/api/program/site.ts +748 -748
  196. package/src/api/program/spreadsheet.ts +2698 -2698
  197. package/src/api/workspace/index.ts +612 -612
  198. package/src/errors/codes.ts +143 -136
  199. package/src/errors/envelope.ts +75 -75
  200. package/src/errors/index.ts +21 -21
  201. package/src/errors/plugin-error.ts +134 -134
  202. package/src/handles.ts +297 -297
  203. package/src/host-utils.ts +67 -67
  204. package/src/index.ts +7 -7
  205. package/src/massParameters.ops.ts +246 -246
  206. package/src/massParameters.ts +427 -427
  207. package/src/types.ts +16 -16
  208. package/test/drawingContract.test.mjs +288 -0
  209. package/test/errors.test.mjs +185 -184
  210. package/test/massParameters.test.mjs +952 -952
  211. package/tsconfig.json +22 -22
  212. package/tsup.config.ts +12 -12
  213. package/api-manifest.json +0 -9711
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
+ })