@kensnzk/koyu 0.22.0 → 0.24.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 (74) hide show
  1. package/dist/cli.js +51 -2
  2. package/dist/cli.js.map +1 -1
  3. package/dist/core/bodies.d.ts +26 -0
  4. package/dist/core/bodies.d.ts.map +1 -0
  5. package/dist/core/bodies.js +67 -0
  6. package/dist/core/bodies.js.map +1 -0
  7. package/dist/core/model.d.ts +20 -1
  8. package/dist/core/model.d.ts.map +1 -1
  9. package/dist/core/model.js +27 -1
  10. package/dist/core/model.js.map +1 -1
  11. package/dist/core/parse.d.ts.map +1 -1
  12. package/dist/core/parse.js +11 -13
  13. package/dist/core/parse.js.map +1 -1
  14. package/dist/core/poly.d.ts +35 -0
  15. package/dist/core/poly.d.ts.map +1 -1
  16. package/dist/core/poly.js +67 -0
  17. package/dist/core/poly.js.map +1 -1
  18. package/dist/core/section.d.ts +88 -0
  19. package/dist/core/section.d.ts.map +1 -0
  20. package/dist/core/section.js +247 -0
  21. package/dist/core/section.js.map +1 -0
  22. package/dist/draw/axo.d.ts.map +1 -1
  23. package/dist/draw/axo.js +13 -31
  24. package/dist/draw/axo.js.map +1 -1
  25. package/dist/draw/index.d.ts +4 -0
  26. package/dist/draw/index.d.ts.map +1 -1
  27. package/dist/draw/index.js +4 -0
  28. package/dist/draw/index.js.map +1 -1
  29. package/dist/draw/marks.d.ts +126 -0
  30. package/dist/draw/marks.d.ts.map +1 -0
  31. package/dist/draw/marks.js +227 -0
  32. package/dist/draw/marks.js.map +1 -0
  33. package/dist/draw/plan.d.ts.map +1 -1
  34. package/dist/draw/plan.js +117 -133
  35. package/dist/draw/plan.js.map +1 -1
  36. package/dist/draw/scene.d.ts +133 -0
  37. package/dist/draw/scene.d.ts.map +1 -0
  38. package/dist/draw/scene.js +251 -0
  39. package/dist/draw/scene.js.map +1 -0
  40. package/dist/draw/section.d.ts +23 -0
  41. package/dist/draw/section.d.ts.map +1 -0
  42. package/dist/draw/section.js +168 -0
  43. package/dist/draw/section.js.map +1 -0
  44. package/dist/draw/sheet.d.ts +40 -0
  45. package/dist/draw/sheet.d.ts.map +1 -0
  46. package/dist/draw/sheet.js +93 -0
  47. package/dist/draw/sheet.js.map +1 -0
  48. package/dist/draw/written.d.ts +27 -0
  49. package/dist/draw/written.d.ts.map +1 -0
  50. package/dist/draw/written.js +50 -0
  51. package/dist/draw/written.js.map +1 -0
  52. package/dist/form.d.ts +1 -0
  53. package/dist/form.d.ts.map +1 -1
  54. package/dist/form.js +4 -0
  55. package/dist/form.js.map +1 -1
  56. package/dist/mcp.js +67 -3
  57. package/dist/mcp.js.map +1 -1
  58. package/package.json +2 -2
  59. package/src/cli.ts +57 -1
  60. package/src/core/bodies.ts +90 -0
  61. package/src/core/model.ts +32 -1
  62. package/src/core/parse.ts +13 -12
  63. package/src/core/poly.ts +76 -0
  64. package/src/core/section.ts +311 -0
  65. package/src/draw/axo.ts +13 -29
  66. package/src/draw/index.ts +24 -0
  67. package/src/draw/marks.ts +315 -0
  68. package/src/draw/plan.ts +111 -130
  69. package/src/draw/scene.ts +389 -0
  70. package/src/draw/section.ts +224 -0
  71. package/src/draw/sheet.ts +102 -0
  72. package/src/draw/written.ts +64 -0
  73. package/src/form.ts +18 -0
  74. package/src/mcp.ts +75 -2
@@ -0,0 +1,168 @@
1
+ // koyu — the section and the elevation (ADR-0064)
2
+ //
3
+ // **There is not one rule of shape here.** Which bodies the plane crossed, which stand behind it,
4
+ // where each one lands on the sheet and how far back it is — all of that arrives in the
5
+ // `FormSection` that `sectionForm` returns. This page decides the ink, the line weights, the
6
+ // stacking, the words of the annotation, the scale and the margins, and nothing else. That is the
7
+ // same division `plan.ts` keeps, and it makes this the thinnest of the drawings: it performs no
8
+ // geometry at all.
9
+ //
10
+ // **One renderer, two entry points.** An elevation is a section whose plane misses the mass, so
11
+ // `cut` comes back empty and everything is `beyond`. Writing it as a second renderer would be
12
+ // writing the same painter twice and inviting the two to drift.
13
+ import { derive } from "../core/derive.js";
14
+ import { displayName } from "../core/model.js";
15
+ import { defaultLook, elevationForm, sectionForm, } from "../core/section.js";
16
+ import { esc, Extent, FAINT, GRID, INK, openSheet, r2, ROOM } from "./sheet.js";
17
+ /** What stands behind the plane, in a tone that does not compete with the cut. */
18
+ const BEYOND = "#b8b0a0";
19
+ /** Glazing, cool so that it does not read as matter. */
20
+ const GLASS = "#b9c3c0";
21
+ /** Annotation. */
22
+ const LABEL = "#8a8171";
23
+ export function svgSection(model, opts) {
24
+ const look = opts.look ?? defaultLook(opts.axis);
25
+ const form = derive(model);
26
+ const section = sectionForm(form, {
27
+ axis: opts.axis,
28
+ at: opts.at,
29
+ ...(opts.atRef !== undefined ? { atRef: opts.atRef } : {}),
30
+ look,
31
+ });
32
+ const where = opts.atRef ?? `${opts.axis} ${opts.at}`;
33
+ return sheet(model, form, section, opts.scale, `${model.name ?? "Untitled"} — section at ${where} looking ${look}`);
34
+ }
35
+ export function svgElevation(model, opts) {
36
+ const form = derive(model);
37
+ const section = elevationForm(form, opts.face);
38
+ return sheet(model, form, section, opts.scale, `${model.name ?? "Untitled"} — ${opts.face} elevation`);
39
+ }
40
+ /**
41
+ * The stacking order, back to front.
42
+ *
43
+ * What is behind the plane is painted **far first**, so a nearer body covers a further one. That is
44
+ * the painter's algorithm ADR-0026 already accepted as enough for a drawing meant to check with,
45
+ * and here it is stronger than it is for an axonometric: there is one depth axis rather than the
46
+ * sum of three, so the order is exact whenever two bodies do not interpenetrate — and
47
+ * interpenetration in section is a contradiction `check` already reports (HGT01 / HGT02).
48
+ */
49
+ function sheet(model, form, section, scale, heading) {
50
+ const s = scale ?? 0.05;
51
+ // **Folded, never spread** — a wall is one body per interval, so a large building runs past the
52
+ // limit on how many arguments a call may take.
53
+ const ext = new Extent();
54
+ for (const e of section.entities)
55
+ for (const p of e.polygon)
56
+ ext.see(p.u, p.z);
57
+ if (ext.empty)
58
+ throw new Error("There is nothing to draw");
59
+ const minU = ext.min0;
60
+ const maxU = ext.max0;
61
+ // **A level with no matter on it still has a datum**, so the storey ladder widens the height of
62
+ // the sheet on its own — leave it out and a roof level declared without spaces falls off it.
63
+ let minZ = ext.min1;
64
+ let maxZ = ext.max1;
65
+ for (const l of form.levels) {
66
+ if (l.z < minZ)
67
+ minZ = l.z;
68
+ if (l.z > maxZ)
69
+ maxZ = l.z;
70
+ }
71
+ const ML = 132; // the left margin carries the level names and their heights
72
+ const MR = 84;
73
+ const MT = 84;
74
+ const MB = 84;
75
+ const W = (maxU - minU) * s + ML + MR;
76
+ const H = (maxZ - minZ) * s + MT + MB;
77
+ const sx = (u) => r2((u - minU) * s + ML);
78
+ const sy = (z) => r2((maxZ - z) * s + MT); // z is up on the page
79
+ const path2d = (poly) => poly.map((p, i) => `${i === 0 ? "M" : "L"} ${sx(p.u)} ${sy(p.z)}`).join(" ") + " Z";
80
+ const parts = openSheet(W, H);
81
+ // ---- the air the plane opened ----
82
+ // Behind everything, because it is not a surface. It is the storey's volume, and it shows only
83
+ // where nothing stands behind the plane to be seen instead.
84
+ for (const e of section.entities) {
85
+ if (e.class !== "cut" || e.of !== "space")
86
+ continue;
87
+ parts.push(`<path d="${path2d(e.polygon)}" fill="${ROOM}"/>`);
88
+ }
89
+ // ---- what stands behind the plane, far first ----
90
+ // An opening sits inside the wall it pierces, at the same distance, so it is painted after the
91
+ // walls of its own depth rather than being sorted against them by a tie nobody decided.
92
+ const beyond = section.entities
93
+ .filter((e) => e.class === "beyond")
94
+ .sort((a, b) => b.depth - a.depth || rank(a) - rank(b));
95
+ for (const e of beyond) {
96
+ const face = e.of === "opening" ? GLASS : BEYOND;
97
+ parts.push(`<path d="${path2d(e.polygon)}" fill="${face}" stroke="${INK}" stroke-width="0.35" stroke-opacity="0.5"/>`);
98
+ }
99
+ // ---- the storey ladder ----
100
+ // A level datum is to a section what a grid line is to a plan, so it is drawn as one.
101
+ for (const l of form.levels) {
102
+ if (l.z < minZ - 1 || l.z > maxZ + 1)
103
+ continue;
104
+ parts.push(`<line x1="${ML - 26}" y1="${sy(l.z)}" x2="${W - MR + 26}" y2="${sy(l.z)}" stroke="${GRID}" stroke-width="0.8" stroke-dasharray="7 3 1.5 3"/>`, `<text x="${ML - 34}" y="${sy(l.z) - 4}" text-anchor="end" font-size="10" fill="${GRID}">${esc(l.name)}</text>`, `<text x="${ML - 34}" y="${sy(l.z) + 9}" text-anchor="end" font-size="8.5" fill="${FAINT}">${l.z >= 0 ? "+" : ""}${l.z}</text>`);
105
+ }
106
+ // ---- the ground ----
107
+ // **koyu holds no ground level.** `origin elevation:` is the height of model z = 0 in a vertical
108
+ // reference system and says so on its own page — it is not GL, not 地盤面, not 平均地盤面. So this
109
+ // line is a convention of the sheet, exactly like the slab `axo` puts under a building, and the
110
+ // reference page says so. It is drawn at z = 0 because that is where the ground storey sits in
111
+ // every model that does not say otherwise, and because nothing in the source can say otherwise.
112
+ if (minZ - 1 <= 0 && 0 <= maxZ + 1) {
113
+ parts.push(`<line x1="0" y1="${sy(0)}" x2="${W}" y2="${sy(0)}" stroke="${INK}" stroke-width="1.2"/>`, `<text x="${W - MR + 26}" y="${sy(0) + 14}" text-anchor="end" font-size="8" fill="${LABEL}">z 0</text>`);
114
+ }
115
+ // ---- the grid, along the sheet ----
116
+ // The axis the plane is named on gets no bubbles — every one of its lines would land on the same
117
+ // point. The other axis is what runs across the sheet, so that is the one that marks it.
118
+ const across = section.axis === "X" ? model.grid.Y : model.grid.X;
119
+ const sign = section.look === "W" || section.look === "N" ? 1 : -1;
120
+ for (const [i, c] of across.coords.entries()) {
121
+ const u = c * sign;
122
+ if (u < minU - 1 || u > maxU + 1)
123
+ continue;
124
+ parts.push(`<line x1="${sx(u)}" y1="${MT - 26}" x2="${sx(u)}" y2="${H - MB + 26}" stroke="${GRID}" stroke-width="0.8" stroke-dasharray="7 3 1.5 3"/>`, `<circle cx="${sx(u)}" cy="${MT - 40}" r="11" fill="none" stroke="${GRID}" stroke-width="1"/>`, `<text x="${sx(u)}" y="${MT - 36}" text-anchor="middle" font-size="10" fill="${GRID}">${across.names[i]}</text>`);
125
+ }
126
+ // ---- what the plane cut ----
127
+ // Solid ink, painted last, exactly as a plan paints its black bands last. There is no operation
128
+ // that paints an opening back out in the paper colour: a wall arrives as the run of intervals its
129
+ // openings split it into, so the hole is in it from the start.
130
+ for (const e of section.entities) {
131
+ if (e.class !== "cut" || e.of === "space" || e.of === "opening")
132
+ continue;
133
+ parts.push(`<path d="${path2d(e.polygon)}" fill="${INK}"/>`);
134
+ }
135
+ // A leaf the plane cut is not matter in the way a wall is — it reads as the opening it fills.
136
+ for (const e of section.entities) {
137
+ if (e.class !== "cut" || e.of !== "opening")
138
+ continue;
139
+ parts.push(`<path d="${path2d(e.polygon)}" fill="${e.kind === "window" ? GLASS : ROOM}" stroke="${INK}" stroke-width="1"/>`);
140
+ }
141
+ // ---- the rooms, named ----
142
+ for (const e of section.entities) {
143
+ if (e.class !== "cut" || e.of !== "space")
144
+ continue;
145
+ const space = model.spaces.get(e.ref);
146
+ if (!space)
147
+ continue;
148
+ const b = box(e.polygon);
149
+ if ((b.u1 - b.u0) * s < 46 || (b.z1 - b.z0) * s < 22)
150
+ continue; // no room for the words
151
+ const cx = sx((b.u0 + b.u1) / 2);
152
+ const cy = sy((b.z0 + b.z1) / 2);
153
+ parts.push(`<text x="${cx}" y="${cy}" text-anchor="middle" font-size="12" fill="${INK}">${esc(displayName(space))}</text>`, `<text x="${cx}" y="${cy + 14}" text-anchor="middle" font-size="9" fill="${LABEL}">h ${Math.round(b.z1 - b.z0)}</text>`);
154
+ }
155
+ parts.push(`<text x="${ML - 62}" y="${H - 18}" font-size="12" fill="${INK}">${esc(heading)}</text>`, "</svg>");
156
+ return parts.join("\n") + "\n";
157
+ }
158
+ /** Within one distance, walls before the openings that pierce them. */
159
+ function rank(e) {
160
+ return e.of === "opening" ? 1 : 0;
161
+ }
162
+ function box(poly) {
163
+ const ext = new Extent();
164
+ for (const p of poly)
165
+ ext.see(p.u, p.z);
166
+ return { u0: ext.min0, u1: ext.max0, z0: ext.min1, z1: ext.max1 };
167
+ }
168
+ //# sourceMappingURL=section.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"section.js","sourceRoot":"","sources":["../../src/draw/section.ts"],"names":[],"mappings":"AAAA,kDAAkD;AAClD,EAAE;AACF,kGAAkG;AAClG,wFAAwF;AACxF,6FAA6F;AAC7F,kGAAkG;AAClG,gGAAgG;AAChG,mBAAmB;AACnB,EAAE;AACF,gGAAgG;AAChG,8FAA8F;AAC9F,gEAAgE;AAEhE,OAAO,EAAE,MAAM,EAAa,MAAM,mBAAmB,CAAC;AACtD,OAAO,EAAE,WAAW,EAAyB,MAAM,kBAAkB,CAAC;AACtE,OAAO,EACL,WAAW,EACX,aAAa,EACb,WAAW,GAKZ,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EAAE,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,IAAI,EAAE,GAAG,EAAE,SAAS,EAAE,EAAE,EAAE,IAAI,EAAE,MAAM,YAAY,CAAC;AAsBhF,kFAAkF;AAClF,MAAM,MAAM,GAAG,SAAS,CAAC;AACzB,wDAAwD;AACxD,MAAM,KAAK,GAAG,SAAS,CAAC;AACxB,kBAAkB;AAClB,MAAM,KAAK,GAAG,SAAS,CAAC;AAExB,MAAM,UAAU,UAAU,CAAC,KAAY,EAAE,IAAoB;IAC3D,MAAM,IAAI,GAAG,IAAI,CAAC,IAAI,IAAI,WAAW,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IACjD,MAAM,IAAI,GAAG,MAAM,CAAC,KAAK,CAAC,CAAC;IAC3B,MAAM,OAAO,GAAG,WAAW,CAAC,IAAI,EAAE;QAChC,IAAI,EAAE,IAAI,CAAC,IAAI;QACf,EAAE,EAAE,IAAI,CAAC,EAAE;QACX,GAAG,CAAC,IAAI,CAAC,KAAK,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,KAAK,EAAE,IAAI,CAAC,KAAK,EAAE,CAAC,C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,YAAY,EAAE,QAAQ,EAAE,+CAA+C,GAAG,KAAK,GAAG,CAAC,WAAW,CAAC,KAAK,CAAC,CAAC,SAAS,EAC/G,YAAY,EAAE,QAAQ,EAAE,GAAG,EAAE,8CAA8C,KAAK,OAAO,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,GAAG,CAAC,CAAC,EAAE,CAAC,SAAS,CACxH,CAAC;IACJ,CAAC;IAED,KAAK,CAAC,IAAI,CAAC,YAAY,EAAE,GAAG,EAAE,QAAQ,CAAC,GAAG,EAAE,0BAA0B,GAAG,KAAK,GAAG,CAAC,OAAO,CAAC,SAAS,EAAE,QAAQ,CAAC,CAAC;IAC/G,OAAO,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG,IAAI,CAAC;AACjC,CAAC;AAED,uEAAuE;AACvE,SAAS,IAAI,CAAC,CAAgB;IAC5B,OAAO,CAAC,CAAC,EAAE,KAAK,SAAS,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;AACpC,CAAC;AAED,SAAS,GAAG,CAAC,IAAiB;IAC5B,MAAM,GAAG,GAAG,IAAI,MAAM,EAAE,CAAC;IACzB,KAAK,MAAM,CAAC,IAAI,IAAI;QAAE,GAAG,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC;IACxC,OAAO,EAAE,EAAE,EAAE,GAAG,CAAC,IAAI,EAAE,EAAE,EAAE,GAAG,CAAC,IAAI,EAAE,EAAE,EAAE,GAAG,CAAC,IAAI,EAAE,EAAE,EAAE,GAAG,CAAC,IAAI,EAAE,CAAC;AACpE,CAAC"}
@@ -0,0 +1,40 @@
1
+ /** The drawing ink. */
2
+ export declare const INK = "#1f1f1f";
3
+ /** The paper. */
4
+ export declare const PAPER = "#faf8f4";
5
+ /** The air of a room, cut open. */
6
+ export declare const ROOM = "#f1ebdd";
7
+ /** Given lines — the grid, and the level datums that are the grid of a section. */
8
+ export declare const GRID = "#b5aa94";
9
+ /** A line that is present but not the subject. */
10
+ export declare const FAINT = "#b3ab9c";
11
+ /** Two decimal places — enough for a coordinate on paper, and it keeps the path text short. */
12
+ export declare const r2: (v: number) => number;
13
+ /**
14
+ * Text on its way into markup. Only the three characters that would end the surrounding element —
15
+ * no name from the source is ever put inside an attribute, so quotes need no treatment.
16
+ */
17
+ export declare const esc: (s: string) => string;
18
+ /** The opening element, the paper under the drawing, and the mark in the corner. */
19
+ export declare function openSheet(w: number, h: number): string[];
20
+ /** The koyu mark, its top-left corner at (x, y) and `size` tall. */
21
+ export declare function koyuMark(x: number, y: number, size: number): string;
22
+ /** How wide the mark drawn by `openSheet` is, so a caller can keep clear of it. */
23
+ export declare const MARK_WIDTH: number;
24
+ /**
25
+ * How far the drawing reaches.
26
+ *
27
+ * **It folds; it does not spread.** `Math.min(...points)` passes one argument per point and a large
28
+ * model runs past the limit on the number of arguments a call may take — a wall split by its
29
+ * openings is one body per interval, so the bundled examples reach past a hundred thousand points.
30
+ */
31
+ export declare class Extent {
32
+ min0: number;
33
+ max0: number;
34
+ min1: number;
35
+ max1: number;
36
+ see(a: number, b: number): void;
37
+ /** Whether anything was ever seen. */
38
+ get empty(): boolean;
39
+ }
40
+ //# sourceMappingURL=sheet.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"sheet.d.ts","sourceRoot":"","sources":["../../src/draw/sheet.ts"],"names":[],"mappings":"AAiBA,uBAAuB;AACvB,eAAO,MAAM,GAAG,YAAY,CAAC;AAC7B,iBAAiB;AACjB,eAAO,MAAM,KAAK,YAAY,CAAC;AAC/B,mCAAmC;AACnC,eAAO,MAAM,IAAI,YAAY,CAAC;AAC9B,mFAAmF;AACnF,eAAO,MAAM,IAAI,YAAY,CAAC;AAC9B,kDAAkD;AAClD,eAAO,MAAM,KAAK,YAAY,CAAC;AAE/B,+FAA+F;AAC/F,eAAO,MAAM,EAAE,GAAI,GAAG,MAAM,KAAG,MAAmC,CAAC;AAEnE;;;GAGG;AACH,eAAO,MAAM,GAAG,GAAI,GAAG,MAAM,KAAG,MACsC,CAAC;AAEvE,oFAAoF;AACpF,wBAAgB,SAAS,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,GAAG,MAAM,EAAE,CAMxD;AAgBD,oEAAoE;AACpE,wBAAgB,QAAQ,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,MAAM,CAUnE;AAED,mFAAmF;AACnF,eAAO,MAAM,UAAU,QAAyB,CAAC;AAEjD;;;;;;GAMG;AACH,qBAAa,MAAM;IACjB,IAAI,SAAY;IAChB,IAAI,SAAa;IACjB,IAAI,SAAY;IAChB,IAAI,SAAa;IAEjB,GAAG,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,GAAG,IAAI;IAO/B,sCAAsC;IACtC,IAAI,KAAK,IAAI,OAAO,CAEnB;CACF"}
@@ -0,0 +1,93 @@
1
+ // koyu — the page every drawing is put on.
2
+ //
3
+ // **Nothing here decides shape.** This module holds what a sheet of paper is: the two inks, the
4
+ // escaping a piece of text needs before it can sit in markup, the rounding that keeps a path
5
+ // readable, the opening element, and the accumulator that measures how far the drawing reaches.
6
+ //
7
+ // It exists because there are three renderers now. While `plan.ts` and `axo.ts` were the only two,
8
+ // each carrying its own copy of `esc` and its own spelling of `#1f1f1f`, the duplication was
9
+ // cheap; a third copy is the point at which "the paper is the same paper" stops being visible in
10
+ // the code. What is **not** here is anything the three do differently — the world-to-paper mapping
11
+ // (a plan flips y, an axonometric does not), the title block, the margin. Sharing those would mean
12
+ // parameterising them until the shared version says less than the three separate ones did.
13
+ // The palette. Shared so that a plan and a section of the same building read as one set of
14
+ // drawings — which is the whole use of being able to lay them side by side. Every one of these may
15
+ // change; none of them is on a frozen surface.
16
+ /** The drawing ink. */
17
+ export const INK = "#1f1f1f";
18
+ /** The paper. */
19
+ export const PAPER = "#faf8f4";
20
+ /** The air of a room, cut open. */
21
+ export const ROOM = "#f1ebdd";
22
+ /** Given lines — the grid, and the level datums that are the grid of a section. */
23
+ export const GRID = "#b5aa94";
24
+ /** A line that is present but not the subject. */
25
+ export const FAINT = "#b3ab9c";
26
+ /** Two decimal places — enough for a coordinate on paper, and it keeps the path text short. */
27
+ export const r2 = (v) => Math.round(v * 100) / 100;
28
+ /**
29
+ * Text on its way into markup. Only the three characters that would end the surrounding element —
30
+ * no name from the source is ever put inside an attribute, so quotes need no treatment.
31
+ */
32
+ export const esc = (s) => s.replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;");
33
+ /** The opening element, the paper under the drawing, and the mark in the corner. */
34
+ export function openSheet(w, h) {
35
+ return [
36
+ `<svg xmlns="http://www.w3.org/2000/svg" width="${w}" height="${h}" viewBox="0 0 ${w} ${h}" font-family="'Hiragino Sans','Noto Sans JP',sans-serif">`,
37
+ `<rect width="${w}" height="${h}" fill="${PAPER}"/>`,
38
+ koyuMark(14, 13, 19),
39
+ ];
40
+ }
41
+ // The mark, drawn rather than linked. A drawing koyu makes should say so on its face, and an SVG
42
+ // that reaches for a file is a drawing that arrives broken as often as not — so the two paths are
43
+ // here, in the light-mode colours, because the paper is light.
44
+ //
45
+ // The outline is a room in plan: a wall running round, stopping short at the foot to leave a
46
+ // doorway, one partition inside it, and an opening in red. Which is the whole notation in one
47
+ // figure, and the reason it is the mark.
48
+ const MARK_INK = "#171A18";
49
+ const MARK_OPENING = "#A84940";
50
+ const MARK_W = 803.138;
51
+ const MARK_H = 872.069;
52
+ const MARK_X = 224.392;
53
+ const MARK_Y = 171.361;
54
+ /** The koyu mark, its top-left corner at (x, y) and `size` tall. */
55
+ export function koyuMark(x, y, size) {
56
+ const k = size / MARK_H;
57
+ const tx = r2(x - MARK_X * k);
58
+ const ty = r2(y - MARK_Y * k);
59
+ return (`<g transform="translate(${tx} ${ty}) scale(${r2(k * 1000) / 1000})">` +
60
+ `<path d="M1027.53 171.361L224.461 171.363L224.392 1043.39L361.454 1043.42L361.567 308.689L889.587 308.679L889.581 904.864L566.4 904.876L566.387 524.585L419.01 452.015L419.047 1043.39L1027.51 1043.43L1027.53 171.361Z" fill="${MARK_INK}"/>` +
61
+ `<path d="M707 445.022L811.864 445L811.858 613.697C811.831 648.974 812.209 684.759 811.831 720L707.005 719.933L707 445.022Z" fill="${MARK_OPENING}"/>` +
62
+ `</g>`);
63
+ }
64
+ /** How wide the mark drawn by `openSheet` is, so a caller can keep clear of it. */
65
+ export const MARK_WIDTH = (19 / MARK_H) * MARK_W;
66
+ /**
67
+ * How far the drawing reaches.
68
+ *
69
+ * **It folds; it does not spread.** `Math.min(...points)` passes one argument per point and a large
70
+ * model runs past the limit on the number of arguments a call may take — a wall split by its
71
+ * openings is one body per interval, so the bundled examples reach past a hundred thousand points.
72
+ */
73
+ export class Extent {
74
+ min0 = Infinity;
75
+ max0 = -Infinity;
76
+ min1 = Infinity;
77
+ max1 = -Infinity;
78
+ see(a, b) {
79
+ if (a < this.min0)
80
+ this.min0 = a;
81
+ if (a > this.max0)
82
+ this.max0 = a;
83
+ if (b < this.min1)
84
+ this.min1 = b;
85
+ if (b > this.max1)
86
+ this.max1 = b;
87
+ }
88
+ /** Whether anything was ever seen. */
89
+ get empty() {
90
+ return this.min0 === Infinity;
91
+ }
92
+ }
93
+ //# sourceMappingURL=sheet.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"sheet.js","sourceRoot":"","sources":["../../src/draw/sheet.ts"],"names":[],"mappings":"AAAA,2CAA2C;AAC3C,EAAE;AACF,gGAAgG;AAChG,6FAA6F;AAC7F,gGAAgG;AAChG,EAAE;AACF,mGAAmG;AACnG,6FAA6F;AAC7F,iGAAiG;AACjG,mGAAmG;AACnG,mGAAmG;AACnG,2FAA2F;AAE3F,2FAA2F;AAC3F,mGAAmG;AACnG,+CAA+C;AAE/C,uBAAuB;AACvB,MAAM,CAAC,MAAM,GAAG,GAAG,SAAS,CAAC;AAC7B,iBAAiB;AACjB,MAAM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"../core/model.js";
2
+ /** What a model wrote at a place the `Form` points to. */
3
+ export interface Written {
4
+ /** the `spec` on a boundary, by its place in canonical order */
5
+ boundarySpec(boundary: number): string | undefined;
6
+ /** the `spec` on a segment that does not count */
7
+ segSpec(boundary: number, index: number): string | undefined;
8
+ /** the `spec` on an opening */
9
+ openingSpec(boundary: number, index: number): string | undefined;
10
+ /** any carried attribute on a boundary, including a namespaced one */
11
+ boundaryAttr(boundary: number, key: string): string | number | boolean | undefined;
12
+ /** any carried attribute on an opening */
13
+ openingAttr(boundary: number, index: number, key: string): string | number | boolean | undefined;
14
+ }
15
+ /**
16
+ * A window onto what a model wrote, addressed the way `Form` addresses it.
17
+ *
18
+ * ```ts
19
+ * const written = writtenOf(model);
20
+ * for (const n of sceneOf(form).nodes) {
21
+ * const spec = n.written && written.boundarySpec(n.written.boundary);
22
+ * // deciding that a spec containing "glass" means transparent is the viewer's judgement
23
+ * }
24
+ * ```
25
+ */
26
+ export declare function writtenOf(model: Model): Written;
27
+ //# sourceMappingURL=written.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"written.d.ts","sourceRoot":"","sources":["../../src/draw/written.ts"],"names":[],"mappings":"AAkBA,OAAO,EAA0B,KAAK,KAAK,EAAE,MAAM,kBAAkB,CAAC;AAEtE,0DAA0D;AAC1D,MAAM,WAAW,OAAO;IACtB,gEAAgE;IAChE,YAAY,CAAC,QAAQ,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,CAAC;IACnD,kDAAkD;IAClD,OAAO,CAAC,QAAQ,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,CAAC;IAC7D,+BAA+B;IAC/B,WAAW,CAAC,QAAQ,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,CAAC;IACjE,sEAAsE;IACtE,YAAY,CAAC,QAAQ,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,GAAG,MAAM,GAAG,MAAM,GAAG,OAAO,GAAG,SAAS,CAAC;IACnF,0CAA0C;IAC1C,WAAW,CAAC,QAAQ,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,GAAG,MAAM,GAAG,MAAM,GAAG,OAAO,GAAG,SAAS,CAAC;CAClG;AAMD;;;;;;;;;;GAUG;AACH,wBAAgB,SAAS,CAAC,KAAK,EAAE,KAAK,GAAG,OAAO,CAc/C"}
@@ -0,0 +1,50 @@
1
+ // koyu — reading back what was written, from a mark or a scene node (`@kensnzk/koyu/draw`)
2
+ //
3
+ // `Mark.written` and `SceneNode.written` give a place in **canonical boundary order**. Reaching the
4
+ // attributes from that place needs the model, and needs it read in exactly one way: `Form`'s index
5
+ // is an index into `canonicalBoundaryOrder(model)`, never into `model.boundaries`. Declaration
6
+ // order is information the canonical form discards, so indexing by it does not throw — **it reads
7
+ // another boundary's `spec`**, on some models and not others (ADR-0041).
8
+ //
9
+ // **Why this and not the ordering function itself.** Two things go wrong when a consumer holds the
10
+ // sorted array. It sorts per lookup — both viewers did, once per boundary, re-sorting the whole
11
+ // building each time, which is the cost ADR-0041 names. And the raw array invites
12
+ // `model.boundaries[i]` to be substituted for it by anyone who does not know the difference, which
13
+ // is the failure the ordering exists to prevent. A window that answers "what was written here"
14
+ // closes both: sorted once per model, and there is no array to mis-index.
15
+ //
16
+ // This lives in the presentation face because it is not part of the language. `spec` is a carried
17
+ // free word — core neither reads it nor promises what it means (docs/reference/muro/attributes.md);
18
+ // only a drawing ever asks.
19
+ import { canonicalBoundaryOrder } from "../core/model.js";
20
+ // A model is a value, so the answer for one never changes. Sorting is O(n log n) over every
21
+ // boundary; doing it once per model is the whole point of the cache.
22
+ const cache = new WeakMap();
23
+ /**
24
+ * A window onto what a model wrote, addressed the way `Form` addresses it.
25
+ *
26
+ * ```ts
27
+ * const written = writtenOf(model);
28
+ * for (const n of sceneOf(form).nodes) {
29
+ * const spec = n.written && written.boundarySpec(n.written.boundary);
30
+ * // deciding that a spec containing "glass" means transparent is the viewer's judgement
31
+ * }
32
+ * ```
33
+ */
34
+ export function writtenOf(model) {
35
+ const hit = cache.get(model);
36
+ if (hit)
37
+ return hit;
38
+ const ordered = canonicalBoundaryOrder(model);
39
+ const str = (v) => (typeof v === "string" ? v : undefined);
40
+ const made = {
41
+ boundarySpec: (b) => str(ordered[b]?.attrs["spec"]),
42
+ segSpec: (b, i) => str(ordered[b]?.segs[i]?.attrs["spec"]),
43
+ openingSpec: (b, i) => str(ordered[b]?.openings[i]?.attrs["spec"]),
44
+ boundaryAttr: (b, key) => ordered[b]?.attrs[key],
45
+ openingAttr: (b, i, key) => ordered[b]?.openings[i]?.attrs[key],
46
+ };
47
+ cache.set(model, made);
48
+ return made;
49
+ }
50
+ //# sourceMappingURL=written.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"written.js","sourceRoot":"","sources":["../../src/draw/written.ts"],"names":[],"mappings":"AAAA,2FAA2F;AAC3F,EAAE;AACF,oGAAoG;AACpG,mGAAmG;AACnG,+FAA+F;AAC/F,kGAAkG;AAClG,yEAAyE;AACzE,EAAE;AACF,mGAAmG;AACnG,gGAAgG;AAChG,kFAAkF;AAClF,mGAAmG;AACnG,+FAA+F;AAC/F,0EAA0E;AAC1E,EAAE;AACF,kGAAkG;AAClG,oGAAoG;AACpG,4BAA4B;AAC5B,OAAO,EAAE,sBAAsB,EAAc,MAAM,kBAAkB,CAAC;AAgBtE,4FAA4F;AAC5F,qEAAqE;AACrE,MAAM,KAAK,GAAG,IAAI,OAAO,EAAkB,CAAC;AAE5C;;;;;;;;;;GAUG;AACH,MAAM,UAAU,SAAS,CAAC,KAAY;IACpC,MAAM,GAAG,GAAG,KAAK,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC;IAC7B,IAAI,GAAG;QAAE,OAAO,GAAG,CAAC;IACpB,MAAM,OAAO,GAAG,sBAAsB,CAAC,KAAK,CAAC,CAAC;IAC9C,MAAM,GAAG,GAAG,CAAC,CAAU,EAAsB,EAAE,CAAC,CAAC,OAAO,CAAC,KAAK,QAAQ,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC;IACxF,MAAM,IAAI,GAAY;QACpB,YAAY,EAAE,CAAC,CAAC,EAAE,EAAE,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE,KAAK,CAAC,MAAM,CAAC,CAAC;QACnD,OAAO,EAAE,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE,IAAI,CAAC,CAAC,CAAC,EAAE,KAAK,CAAC,MAAM,CAAC,CAAC;QAC1D,WAAW,EAAE,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE,QAAQ,CAAC,CAAC,CAAC,EAAE,KAAK,CAAC,MAAM,CAAC,CAAC;QAClE,YAAY,EAAE,CAAC,CAAC,EAAE,GAAG,EAAE,EAAE,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE,KAAK,CAAC,GAAG,CAAC;QAChD,WAAW,EAAE,CAAC,CAAC,EAAE,CAAC,EAAE,GAAG,EAAE,EAAE,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE,QAAQ,CAAC,CAAC,CAAC,EAAE,KAAK,CAAC,GAAG,CAAC;KAChE,CAAC;IACF,KAAK,CAAC,GAAG,CAAC,KAAK,EAAE,IAAI,CAAC,CAAC;IACvB,OAAO,IAAI,CAAC;AACd,CAAC"}
package/dist/form.d.ts CHANGED
@@ -1,5 +1,6 @@
1
1
  export { band, bandLine, columnRect, runPrism, thicken, type FormPrism, } from "./core/derive.js";
2
2
  export { derive, DERIVATION_CONSTANTS, type DeriveOptions, type Form, type FormBoundary, type FormColumn, type FormInput, type FormLevel, type FormOpening, type FormPanel, type FormPlan, type FormRun, type FormSeg, type FormSite, type FormSpace, type FormSwing, type PlanClass, type PlanEntity, type PlanRole, type PlanSubject, } from "./core/derive.js";
3
+ export { axisOf, defaultLook, elevationForm, sectionArea, sectionForm, type FormSection, type SectionAxis, type SectionClass, type SectionEntity, type SectionPt, type SectionSpec, type SectionSubject, } from "./core/section.js";
3
4
  export { TOLERANCES } from "./core/tolerance.js";
4
5
  export type { Slab, SlabKind } from "./core/fabric.js";
5
6
  export type { RunDevice, RunForm, RunPart, RunSolid, Seg2, VerticalRun, } from "./core/vertical.js";
@@ -1 +1 @@
1
- {"version":3,"file":"form.d.ts","sourceRoot":"","sources":["../src/form.ts"],"names":[],"mappings":"AAMA,OAAO,EACL,IAAI,EACJ,QAAQ,EACR,UAAU,EACV,QAAQ,EACR,OAAO,EACP,KAAK,SAAS,GACf,MAAM,kBAAkB,CAAC;AAE1B,OAAO,EACL,MAAM,EACN,oBAAoB,EACpB,KAAK,aAAa,EAClB,KAAK,IAAI,EACT,KAAK,YAAY,EACjB,KAAK,UAAU,EACf,KAAK,SAAS,EACd,KAAK,SAAS,EACd,KAAK,WAAW,EAChB,KAAK,SAAS,EACd,KAAK,QAAQ,EACb,KAAK,OAAO,EACZ,KAAK,OAAO,EACZ,KAAK,QAAQ,EACb,KAAK,SAAS,EACd,KAAK,SAAS,EACd,KAAK,SAAS,EACd,KAAK,UAAU,EACf,KAAK,QAAQ,EACb,KAAK,WAAW,GACjB,MAAM,kBAAkB,CAAC;AAE1B,OAAO,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAC;AAEjD,YAAY,EAAE,IAAI,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAEvD,YAAY,EACV,SAAS,EACT,OAAO,EACP,OAAO,EACP,QAAQ,EACR,IAAI,EACJ,WAAW,GACZ,MAAM,oBAAoB,CAAC"}
1
+ {"version":3,"file":"form.d.ts","sourceRoot":"","sources":["../src/form.ts"],"names":[],"mappings":"AAMA,OAAO,EACL,IAAI,EACJ,QAAQ,EACR,UAAU,EACV,QAAQ,EACR,OAAO,EACP,KAAK,SAAS,GACf,MAAM,kBAAkB,CAAC;AAE1B,OAAO,EACL,MAAM,EACN,oBAAoB,EACpB,KAAK,aAAa,EAClB,KAAK,IAAI,EACT,KAAK,YAAY,EACjB,KAAK,UAAU,EACf,KAAK,SAAS,EACd,KAAK,SAAS,EACd,KAAK,WAAW,EAChB,KAAK,SAAS,EACd,KAAK,QAAQ,EACb,KAAK,OAAO,EACZ,KAAK,OAAO,EACZ,KAAK,QAAQ,EACb,KAAK,SAAS,EACd,KAAK,SAAS,EACd,KAAK,SAAS,EACd,KAAK,UAAU,EACf,KAAK,QAAQ,EACb,KAAK,WAAW,GACjB,MAAM,kBAAkB,CAAC;AAK1B,OAAO,EACL,MAAM,EACN,WAAW,EACX,aAAa,EACb,WAAW,EACX,WAAW,EACX,KAAK,WAAW,EAChB,KAAK,WAAW,EAChB,KAAK,YAAY,EACjB,KAAK,aAAa,EAClB,KAAK,SAAS,EACd,KAAK,WAAW,EAChB,KAAK,cAAc,GACpB,MAAM,mBAAmB,CAAC;AAE3B,OAAO,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAC;AAEjD,YAAY,EAAE,IAAI,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAEvD,YAAY,EACV,SAAS,EACT,OAAO,EACP,OAAO,EACP,QAAQ,EACR,IAAI,EACJ,WAAW,GACZ,MAAM,oBAAoB,CAAC"}
package/dist/form.js CHANGED
@@ -5,5 +5,9 @@
5
5
  // rules of assembly are not — which is the door to "two shapes from one Form".
6
6
  export { band, bandLine, columnRect, runPrism, thicken, } from "./core/derive.js";
7
7
  export { derive, DERIVATION_CONSTANTS, } from "./core/derive.js";
8
+ // The section and the elevation. **They read a `Form` and assemble no matter** — the classifying
9
+ // of what a vertical plane cut and what stands behind it is derivation's, for the same reason the
10
+ // horizontal one is (docs/why/plan-is-not-a-section.md).
11
+ export { axisOf, defaultLook, elevationForm, sectionArea, sectionForm, } from "./core/section.js";
8
12
  export { TOLERANCES } from "./core/tolerance.js";
9
13
  //# sourceMappingURL=form.js.map
package/dist/form.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"form.js","sourceRoot":"","sources":["../src/form.ts"],"names":[],"mappings":"AAAA,mFAAmF;AAEnF,gGAAgG;AAChG,kGAAkG;AAClG,kGAAkG;AAClG,+EAA+E;AAC/E,OAAO,EACL,IAAI,EACJ,QAAQ,EACR,UAAU,EACV,QAAQ,EACR,OAAO,GAER,MAAM,kBAAkB,CAAC;AAE1B,OAAO,EACL,MAAM,EACN,oBAAoB,GAmBrB,MAAM,kBAAkB,CAAC;AAE1B,OAAO,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAC"}
1
+ {"version":3,"file":"form.js","sourceRoot":"","sources":["../src/form.ts"],"names":[],"mappings":"AAAA,mFAAmF;AAEnF,gGAAgG;AAChG,kGAAkG;AAClG,kGAAkG;AAClG,+EAA+E;AAC/E,OAAO,EACL,IAAI,EACJ,QAAQ,EACR,UAAU,EACV,QAAQ,EACR,OAAO,GAER,MAAM,kBAAkB,CAAC;AAE1B,OAAO,EACL,MAAM,EACN,oBAAoB,GAmBrB,MAAM,kBAAkB,CAAC;AAE1B,iGAAiG;AACjG,kGAAkG;AAClG,yDAAyD;AACzD,OAAO,EACL,MAAM,EACN,WAAW,EACX,aAAa,EACb,WAAW,EACX,WAAW,GAQZ,MAAM,mBAAmB,CAAC;AAE3B,OAAO,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAC"}
package/dist/mcp.js CHANGED
@@ -8,13 +8,14 @@
8
8
  import { mkdirSync, readFileSync, realpathSync, renameSync, writeFileSync } from "node:fs";
9
9
  import { dirname, isAbsolute, relative, resolve, sep } from "node:path";
10
10
  import { daylightInputs } from "./core/light.js";
11
- import { DEFAULT_LANGUAGE_VERSION, KOYU_VERSION, NEWEST_LANGUAGE_VERSION, polygonAreaM2, SUPPORTED_LANGUAGE_VERSIONS, } from "./core/model.js";
11
+ import { DEFAULT_LANGUAGE_VERSION, gridRef, KOYU_VERSION, NEWEST_LANGUAGE_VERSION, polygonAreaM2, SUPPORTED_LANGUAGE_VERSIONS, } from "./core/model.js";
12
+ import { axisOf } from "./core/section.js";
12
13
  import { check } from "./core/diagnose.js";
13
14
  import { siteReport } from "./core/site.js";
14
15
  import { assess } from "./validate/assessment.js";
15
16
  import { createSchematicRegistry, SCHEMATIC_PROFILE_ID } from "./validate/builtin/index.js";
16
17
  import { checkDiagnostics } from "./diagnostics.js";
17
- import { svgPlan } from "./draw/index.js";
18
+ import { svgElevation, svgPlan, svgSection } from "./draw/index.js";
18
19
  import { doorsBetween } from "./graph.js";
19
20
  import { areaM2, isIndoor, displayName, effectiveAttr, isOutside, isSemiOutdoor, isVoid, levelsSorted, newUids, toCanonical, zoneAreaM2, } from "./model.js";
20
21
  import { parseFile, parseFileWith } from "./parse-file.js";
@@ -156,6 +157,21 @@ const str = (v, name) => {
156
157
  throw new Error(`${name} (a string) is required`);
157
158
  return v;
158
159
  };
160
+ /**
161
+ * A compass word, checked rather than trusted.
162
+ *
163
+ * **A schema is what the tool advertises, not what the server enforces.** A raw `tools/call` can
164
+ * carry anything, and a word that is not one of the four falls through the direction tests to a
165
+ * default — so an unsupported `look` would come back as a plausible drawing of a plane nobody
166
+ * asked for, which is worse than an error.
167
+ */
168
+ const edge = (v, name) => {
169
+ const s = str(v, name);
170
+ if (s !== "N" && s !== "E" && s !== "S" && s !== "W") {
171
+ throw new Error(`${name} is one of N / E / S / W: ${s}`);
172
+ }
173
+ return s;
174
+ };
159
175
  /** An optional array of attribute keys. Absent is not the same as empty, but both group nothing. */
160
176
  const keys = (v, name) => {
161
177
  if (v === undefined)
@@ -386,6 +402,54 @@ const TOOLS = {
386
402
  },
387
403
  run: (a) => svgPlan(load(str(a.file, "file")), { level: str(a.level, "level") }),
388
404
  },
405
+ section_svg: {
406
+ description: "Generates and returns the section SVG cut at a grid reference (form is generated, not written). The reference names the plane: X3 cuts across the X axis, Y2-600 across the Y axis",
407
+ schema: {
408
+ type: "object",
409
+ properties: {
410
+ ...FILE_PROP,
411
+ at: {
412
+ type: "string",
413
+ description: "Grid reference for the cut — X3, X3+450, Y2-600. A plane on a grid line usually runs along a wall; offset it to cut through the rooms",
414
+ },
415
+ look: {
416
+ type: "string",
417
+ enum: ["N", "E", "S", "W"],
418
+ description: "Direction of view. Must cross the plane: E or W for an X reference, N or S for a Y reference. Defaults to W and N",
419
+ },
420
+ },
421
+ required: ["file", "at"],
422
+ },
423
+ run: (a) => {
424
+ const model = load(str(a.file, "file"));
425
+ const at = str(a.at, "at");
426
+ const g = gridRef(model, at);
427
+ if (!g) {
428
+ throw new Error(`Undefined grid reference: ${at} (declared: ${model.grid.X.names.join(" ")} ${model.grid.Y.names.join(" ")})`);
429
+ }
430
+ const look = a.look === undefined ? undefined : edge(a.look, "look");
431
+ if (look && axisOf(look) !== g.axis) {
432
+ throw new Error(`look ${look} runs along ${at} rather than across it (an X reference is looked at from E or W, a Y reference from N or S)`);
433
+ }
434
+ return svgSection(model, { axis: g.axis, at: g.coord, atRef: at, ...(look ? { look } : {}) });
435
+ },
436
+ },
437
+ elevation_svg: {
438
+ description: "Generates and returns the elevation SVG of one face (form is generated, not written). An elevation is a section whose plane stands outside the mass, so it cuts nothing",
439
+ schema: {
440
+ type: "object",
441
+ properties: {
442
+ ...FILE_PROP,
443
+ face: {
444
+ type: "string",
445
+ enum: ["N", "E", "S", "W"],
446
+ description: "The side the viewer stands on. S is the south elevation, seen from the south",
447
+ },
448
+ },
449
+ required: ["file", "face"],
450
+ },
451
+ run: (a) => svgElevation(load(str(a.file, "file")), { face: edge(a.face, "face") }),
452
+ },
389
453
  canonical_json: {
390
454
  description: "The canonical JSON (machine format — one composed model, byte-stable). The ground for diffing and for external connections",
391
455
  schema: { type: "object", properties: FILE_PROP, required: ["file"] },
@@ -426,7 +490,7 @@ function handle(msg) {
426
490
  undeclared: DEFAULT_LANGUAGE_VERSION,
427
491
  },
428
492
  },
429
- instructions: "Server for koyu, a space-first architectural description. Grasp the building with model_summary, read the original layers with layers, and edit with write_layer. check is the gatekeeper of the build and returns errors tagged layer:line — it guarantees structural consistency only. validate delivers the architectural verdicts, which are a separate and unfrozen surface. doors/light/site/spaces are different questions put to the same description. Form (plan_svg) is generated, never written.",
493
+ instructions: "Server for koyu, a space-first architectural description. Grasp the building with model_summary, read the original layers with layers, and edit with write_layer. check is the gatekeeper of the build and returns errors tagged layer:line — it guarantees structural consistency only. validate delivers the architectural verdicts, which are a separate and unfrozen surface. doors/light/site/spaces are different questions put to the same description. Form (the drawings — plan_svg, section_svg, elevation_svg) is generated, never written.",
430
494
  });
431
495
  return;
432
496
  }