@kensnzk/koyu 0.17.0 → 0.19.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 (167) hide show
  1. package/dist/analysis/contracts.d.ts +217 -0
  2. package/dist/analysis/contracts.d.ts.map +1 -0
  3. package/dist/analysis/contracts.js +27 -0
  4. package/dist/analysis/contracts.js.map +1 -0
  5. package/dist/analysis/index.d.ts +5 -0
  6. package/dist/analysis/index.d.ts.map +1 -0
  7. package/dist/analysis/index.js +17 -0
  8. package/dist/analysis/index.js.map +1 -0
  9. package/dist/analysis/json.d.ts +21 -0
  10. package/dist/analysis/json.d.ts.map +1 -0
  11. package/dist/analysis/json.js +111 -0
  12. package/dist/analysis/json.js.map +1 -0
  13. package/dist/cli.js +116 -26
  14. package/dist/cli.js.map +1 -1
  15. package/dist/core/diagnose.d.ts +1 -0
  16. package/dist/core/diagnose.d.ts.map +1 -1
  17. package/dist/core/diagnose.js +11 -1
  18. package/dist/core/diagnose.js.map +1 -1
  19. package/dist/core/model.d.ts +50 -3
  20. package/dist/core/model.d.ts.map +1 -1
  21. package/dist/core/model.js +19 -3
  22. package/dist/core/model.js.map +1 -1
  23. package/dist/core/parse.d.ts.map +1 -1
  24. package/dist/core/parse.js +79 -0
  25. package/dist/core/parse.js.map +1 -1
  26. package/dist/core/site.d.ts +9 -0
  27. package/dist/core/site.d.ts.map +1 -1
  28. package/dist/core/site.js +6 -0
  29. package/dist/core/site.js.map +1 -1
  30. package/dist/core/vocabulary.d.ts.map +1 -1
  31. package/dist/core/vocabulary.js +11 -0
  32. package/dist/core/vocabulary.js.map +1 -1
  33. package/dist/diagnostics.d.ts +2 -0
  34. package/dist/diagnostics.d.ts.map +1 -0
  35. package/dist/diagnostics.js +3 -0
  36. package/dist/diagnostics.js.map +1 -0
  37. package/dist/diff.d.ts +2 -0
  38. package/dist/diff.d.ts.map +1 -0
  39. package/dist/diff.js +3 -0
  40. package/dist/diff.js.map +1 -0
  41. package/dist/draw/plan.d.ts.map +1 -1
  42. package/dist/draw/plan.js +24 -0
  43. package/dist/draw/plan.js.map +1 -1
  44. package/dist/form.d.ts +5 -0
  45. package/dist/form.d.ts.map +1 -0
  46. package/dist/form.js +4 -0
  47. package/dist/form.js.map +1 -0
  48. package/dist/graph.d.ts +2 -0
  49. package/dist/graph.d.ts.map +1 -0
  50. package/dist/graph.js +3 -0
  51. package/dist/graph.js.map +1 -0
  52. package/dist/index.d.ts +2 -15
  53. package/dist/index.d.ts.map +1 -1
  54. package/dist/index.js +35 -50
  55. package/dist/index.js.map +1 -1
  56. package/dist/mcp.js +55 -20
  57. package/dist/mcp.js.map +1 -1
  58. package/dist/model.d.ts +3 -0
  59. package/dist/model.d.ts.map +1 -0
  60. package/dist/model.js +3 -0
  61. package/dist/model.js.map +1 -0
  62. package/dist/validate/assessment.d.ts +8 -0
  63. package/dist/validate/assessment.d.ts.map +1 -0
  64. package/dist/validate/assessment.js +1738 -0
  65. package/dist/validate/assessment.js.map +1 -0
  66. package/dist/validate/builtin/access.d.ts +55 -0
  67. package/dist/validate/builtin/access.d.ts.map +1 -0
  68. package/dist/validate/builtin/access.js +494 -0
  69. package/dist/validate/builtin/access.js.map +1 -0
  70. package/dist/validate/builtin/daylight.d.ts +44 -0
  71. package/dist/validate/builtin/daylight.d.ts.map +1 -0
  72. package/dist/validate/builtin/daylight.js +233 -0
  73. package/dist/validate/builtin/daylight.js.map +1 -0
  74. package/dist/validate/builtin/door-column-collisions.d.ts +47 -0
  75. package/dist/validate/builtin/door-column-collisions.d.ts.map +1 -0
  76. package/dist/validate/builtin/door-column-collisions.js +189 -0
  77. package/dist/validate/builtin/door-column-collisions.js.map +1 -0
  78. package/dist/validate/builtin/envelope.d.ts +30 -0
  79. package/dist/validate/builtin/envelope.d.ts.map +1 -0
  80. package/dist/validate/builtin/envelope.js +169 -0
  81. package/dist/validate/builtin/envelope.js.map +1 -0
  82. package/dist/validate/builtin/freeze.d.ts +3 -0
  83. package/dist/validate/builtin/freeze.d.ts.map +1 -0
  84. package/dist/validate/builtin/freeze.js +21 -0
  85. package/dist/validate/builtin/freeze.js.map +1 -0
  86. package/dist/validate/builtin/index.d.ts +38 -0
  87. package/dist/validate/builtin/index.d.ts.map +1 -0
  88. package/dist/validate/builtin/index.js +106 -0
  89. package/dist/validate/builtin/index.js.map +1 -0
  90. package/dist/validate/builtin/site.d.ts +62 -0
  91. package/dist/validate/builtin/site.d.ts.map +1 -0
  92. package/dist/validate/builtin/site.js +333 -0
  93. package/dist/validate/builtin/site.js.map +1 -0
  94. package/dist/validate/builtin/vertical-runs.d.ts +53 -0
  95. package/dist/validate/builtin/vertical-runs.d.ts.map +1 -0
  96. package/dist/validate/builtin/vertical-runs.js +290 -0
  97. package/dist/validate/builtin/vertical-runs.js.map +1 -0
  98. package/dist/validate/contracts.d.ts +188 -0
  99. package/dist/validate/contracts.d.ts.map +1 -0
  100. package/dist/validate/contracts.js +28 -0
  101. package/dist/validate/contracts.js.map +1 -0
  102. package/dist/validate/index.d.ts +2 -59
  103. package/dist/validate/index.d.ts.map +1 -1
  104. package/dist/validate/index.js +22 -70
  105. package/dist/validate/index.js.map +1 -1
  106. package/dist/vocabulary.d.ts +2 -0
  107. package/dist/vocabulary.d.ts.map +1 -0
  108. package/dist/vocabulary.js +3 -0
  109. package/dist/vocabulary.js.map +1 -0
  110. package/editors/vscode/syntaxes/koyu.tmLanguage.json +2 -2
  111. package/examples/tower/site-geometry.muro +9 -0
  112. package/examples/two-rooms.canonical.json +1 -1
  113. package/package.json +37 -5
  114. package/src/analysis/contracts.ts +234 -0
  115. package/src/analysis/index.ts +61 -0
  116. package/src/analysis/json.ts +117 -0
  117. package/src/cli.ts +127 -28
  118. package/src/core/diagnose.ts +11 -1
  119. package/src/core/model.ts +67 -3
  120. package/src/core/parse.ts +99 -0
  121. package/src/core/site.ts +17 -0
  122. package/src/core/vocabulary.ts +12 -0
  123. package/src/diagnostics.ts +8 -0
  124. package/src/diff.ts +14 -0
  125. package/src/draw/plan.ts +31 -0
  126. package/src/form.ts +37 -0
  127. package/src/graph.ts +12 -0
  128. package/src/index.ts +39 -195
  129. package/src/mcp.ts +57 -25
  130. package/src/model.ts +45 -0
  131. package/src/validate/assessment.ts +1934 -0
  132. package/src/validate/builtin/access.ts +642 -0
  133. package/src/validate/builtin/daylight.ts +321 -0
  134. package/src/validate/builtin/door-column-collisions.ts +266 -0
  135. package/src/validate/builtin/envelope.ts +227 -0
  136. package/src/validate/builtin/freeze.ts +19 -0
  137. package/src/validate/builtin/index.ts +156 -0
  138. package/src/validate/builtin/site.ts +445 -0
  139. package/src/validate/builtin/vertical-runs.ts +390 -0
  140. package/src/validate/contracts.ts +240 -0
  141. package/src/validate/index.ts +45 -99
  142. package/src/vocabulary.ts +9 -0
  143. package/dist/validate/access.d.ts +0 -6
  144. package/dist/validate/access.d.ts.map +0 -1
  145. package/dist/validate/access.js +0 -248
  146. package/dist/validate/access.js.map +0 -1
  147. package/dist/validate/envelope.d.ts +0 -4
  148. package/dist/validate/envelope.d.ts.map +0 -1
  149. package/dist/validate/envelope.js +0 -55
  150. package/dist/validate/envelope.js.map +0 -1
  151. package/dist/validate/light.d.ts +0 -6
  152. package/dist/validate/light.d.ts.map +0 -1
  153. package/dist/validate/light.js +0 -28
  154. package/dist/validate/light.js.map +0 -1
  155. package/dist/validate/runs.d.ts +0 -16
  156. package/dist/validate/runs.d.ts.map +0 -1
  157. package/dist/validate/runs.js +0 -60
  158. package/dist/validate/runs.js.map +0 -1
  159. package/dist/validate/site.d.ts +0 -6
  160. package/dist/validate/site.d.ts.map +0 -1
  161. package/dist/validate/site.js +0 -63
  162. package/dist/validate/site.js.map +0 -1
  163. package/src/validate/access.ts +0 -291
  164. package/src/validate/envelope.ts +0 -59
  165. package/src/validate/light.ts +0 -43
  166. package/src/validate/runs.ts +0 -87
  167. package/src/validate/site.ts +0 -84
package/src/index.ts CHANGED
@@ -1,211 +1,55 @@
1
- // koyu — 公開面 (ADR-0037)
1
+ // koyu — the root surface (`@kensnzk/koyu`)
2
2
  //
3
- // **ここに書き下された名だけが約束である。**`export *` は使わない — モジュールに
4
- // export を足した瞬間に、誰も宣言していない約束が凍る面に増えてしまうからである。
5
- // 凍らせる面は、書き下されていなければならない (docs/reference/scope.md)。
3
+ // **Only the names written down here are promised.** `export *` is never used: the moment a
4
+ // module gains an export, a promise nobody declared would freeze into the surface. A surface
5
+ // that freezes has to be written out by hand (docs/reference/scope.md).
6
6
  //
7
- // 載せる基準は一つ — **面の外に利用者がいること。**
8
- // 1. パッケージの外 (ugatsu / eval / scripts / editors) が実際に呼ぶ
9
- // 2. CLI か MCP が答えるものを API からも答えるために要る
10
- // (「CLIが答えるものはすべてこのAPIが答える」— docs/reference/api/index.md)
11
- // 3. 公開文書が名指しで約束する導出 (docs/reference/scope.md)
12
- // 4. test が契約として固定している
13
- // core のモジュール同士が引き合うだけの配管は面ではない。型は、載せた値の署名を
14
- // 書き下すのに要るものだけを載せる。
7
+ // **root is not a shorthand for every subpath.** What lives here is the minimum needed to begin
8
+ // the standard loop — read a `.muro`, confirm it is not self-contradictory, and take the
9
+ // canonical form — plus the types those signatures cannot be written without. Domain names
10
+ // (`model`, `graph`, `form`, `analysis`, `validate`, `draw`, `node`) are **not** re-exported
11
+ // from here. A caller who needs a domain names that domain, and the import line then says which
12
+ // contract is being relied on: the face that freezes, the face that computes from external
13
+ // conditions, the face that concludes, the presentation that may change freely, and the
14
+ // Node-specific adapter never get mixed together.
15
15
  //
16
- // この一覧と docs/reference/api/index.md の表は集合として一致する — test/public-api.test.ts が縛る。
16
+ // root is browser-safe: nothing reachable from here pulls a Node builtin.
17
+ //
18
+ // The twelve entry points:
19
+ //
20
+ // @kensnzk/koyu this file — compose, check, canonicalise
21
+ // @kensnzk/koyu/model Model, and the questions the model answers alone
22
+ // @kensnzk/koyu/diagnostics structural-consistency diagnostics
23
+ // @kensnzk/koyu/graph adjacency, passability, routes, boundary segments
24
+ // @kensnzk/koyu/form the one derivation of shape
25
+ // @kensnzk/koyu/analysis facts made under an explicit context and profile
26
+ // @kensnzk/koyu/diff the semantic difference between two models
27
+ // @kensnzk/koyu/vocabulary the attribute ledger
28
+ // @kensnzk/koyu/validate the rule SPI, the runner, AssessmentReport
29
+ // @kensnzk/koyu/validate/builtin the rules, rule set and profile koyu ships
30
+ // @kensnzk/koyu/draw presentation of the Form
31
+ // @kensnzk/koyu/node filesystem and other Node-specific adapters
32
+ //
33
+ // This list and the table in docs/reference/api/index.md agree as sets — test/public-api.test.ts
34
+ // binds them.
17
35
 
18
36
  // ---- 解析と合成 (docs/reference/muro/import.md) ----
19
37
  export { parse, parseFiles, parseWith, tokenize, type LayerLoader } from "./core/parse.js";
20
38
 
21
- // ---- モデルの語彙 — 書かれた構成の型 ----
22
- export type {
23
- Area,
24
- Asset,
25
- Attrs,
26
- AttrValue,
27
- Boundary,
28
- BoundaryKind,
29
- Column,
30
- ColumnDecl,
31
- DrawnLine,
32
- Edge,
33
- GridAxis,
34
- GridRef,
35
- Level,
36
- Model,
37
- Opening,
38
- Pt,
39
- Rect,
40
- Seg,
41
- SitePolygon,
42
- Space,
43
- Zone,
44
- } from "./core/model.js";
45
-
46
- // ---- モデルへの問い・導出・機械形式 ----
47
- // **合否は言わない** (docs/reference/scope.md)。数と形を返すところまでが core である
48
- export {
49
- areaM2,
50
- canonicalBoundaryOrder,
51
- columnsFor,
52
- DEFAULT_LANGUAGE_VERSION,
53
- displayName,
54
- effectiveUse,
55
- heff,
56
- isCoveredAbove,
57
- isIndoor,
58
- isOutside,
59
- isSemiOutdoor,
60
- isVoid,
61
- levelsSorted,
62
- newUids,
63
- pointInPolygon,
64
- polyBounds,
65
- polygonAreaM2,
66
- rectToPoly,
67
- SourceError,
68
- srcRef,
69
- SUPPORTED_LANGUAGE_VERSIONS,
70
- toCanonical,
71
- unionAreaM2,
72
- zoneAreaM2,
73
- } from "./core/model.js";
74
-
75
- // ---- 構造整合の診断 (ADR-0016) ----
39
+ // ---- 構造整合の確認 — **合否は言わない。**書かれたものが矛盾していないかまで ----
76
40
  export {
77
41
  check,
78
42
  checkDiagnostics,
79
- DIAGNOSTIC_CODES,
80
43
  type CheckResult,
81
44
  type Diagnostic,
82
45
  type DiagnosticCode,
83
46
  } from "./core/diagnose.js";
84
47
 
85
- // ---- 空間グラフと導出の部品 ----
86
- export {
87
- deriveDefaultBoundaries,
88
- doorsBetween,
89
- envelopeGaps,
90
- neighbors,
91
- passable,
92
- placeBand,
93
- placeOpening,
94
- segmentsFor,
95
- type Band,
96
- type BandCode,
97
- type BandError,
98
- type NeighborInfo,
99
- type PlacedBand,
100
- type Route,
101
- type Segment,
102
- } from "./core/graph.js";
103
-
104
- // ---- 形の参照実装 (ADR-0040) — **これが形の唯一の入口である** ----
105
- // Form は見た目を持たない (docs/reference/scope.md)。規則は docs/reference/form/index.md が持つ
106
- // 実体の構成子 (thicken / bandLine / band / columnRect / runPrism) も core が唯一の実装を
107
- // 持つ — 芯線と厚みから四辺形や角柱を起こす規則も導出の一部だからである
108
- export {
109
- band,
110
- bandLine,
111
- columnRect,
112
- derive,
113
- DERIVATION_CONSTANTS,
114
- levelPitch,
115
- runPrism,
116
- thicken,
117
- type DeriveOptions,
118
- type Form,
119
- type FormBoundary,
120
- type FormColumn,
121
- type FormInput,
122
- type FormLevel,
123
- type FormOpening,
124
- type FormPanel,
125
- type FormPlan,
126
- type FormPrism,
127
- type FormRun,
128
- type FormSeg,
129
- type FormSite,
130
- type FormSpace,
131
- type FormSwing,
132
- type PlanClass,
133
- type PlanEntity,
134
- type PlanRole,
135
- type PlanSubject,
136
- } from "./core/derive.js";
137
- export { TOLERANCES } from "./core/tolerance.js";
138
-
139
- // ---- 床・天井・屋根 (ADR-0024) ----
140
- export { slabs, type Slab, type SlabKind } from "./core/fabric.js";
141
-
142
- // ---- 採光の入力 (ADR-0020) ----
143
- export { daylightInputs, type DaylightInput } from "./core/light.js";
144
-
145
- // ---- 縦動線 (ADR-0021) ----
146
- export {
147
- RUN_KEYS,
148
- runDecls,
149
- runDrawsForLevel,
150
- runSolids,
151
- slopeText,
152
- verticalRuns,
153
- type RunArrow,
154
- type RunDecl,
155
- type RunDevice,
156
- type RunDraw,
157
- type RunForm,
158
- type RunPart,
159
- type RunSolid,
160
- type Seg2,
161
- type VerticalRun,
162
- } from "./core/vertical.js";
163
-
164
- // ---- 敷地 (ADR-0009 / ADR-0011) ----
165
- export { siteReport, type RoadFrontage, type SiteReport } from "./core/site.js";
166
-
167
- // ---- 構成の言葉の差分 (ADR-0018) ----
168
- export {
169
- renderDiff,
170
- semanticDiff,
171
- type BoundaryChange,
172
- type BoundaryItem,
173
- type ChangedItem,
174
- type ColumnItem,
175
- type FieldChange,
176
- type GridChange,
177
- type ModelDiff,
178
- type RenamedItem,
179
- type SpaceItem,
180
- } from "./core/diff.js";
181
-
182
- // ---- 属性の台帳 — **書いてよいキーの一覧であって、読むキーの一覧ではない** ----
183
- //
184
- // 利用者の側にも境界が要る。台帳を出していなかった間、消費側のアプリは
185
- // 「この鍵はこの要素に書けるか」を答えるために台帳を手で写すしかなく、写しは必ずずれる。
186
- // `outside` と `void` を型の位置から台帳へ移した以上、その台帳は読めなければ意味がない。
48
+ // ---- 機械形式と、版 ----
187
49
  export {
188
- ASSET_ELEM,
189
- ATTR_LEDGER,
190
- attrSpec,
191
- CARRY_NAMESPACE,
192
- isNamespaced,
193
- known,
194
- type AttrSpec,
195
- type AttrTier,
196
- } from "./core/vocabulary.js";
197
-
198
- // ---- 生成 — **凍らない** (docs/reference/scope.md)。SVGの中身は約束の外にある ----
199
- // 領域としては `@kensnzk/koyu/draw` にも分けてある
200
- export { svgPlan, type PlanOptions } from "./draw/plan.js";
201
- export { svgAxo, type AxoOptions } from "./draw/axo.js";
202
-
203
- // ---- 検証 — **core ではない。**凍らない・増える・合否を言う (docs/reference/scope.md) ----
204
- // Finding は Diagnostic と別の型で、フィールド名から違う (rule/level と code/severity)。
205
- // 領域としては `@kensnzk/koyu/validate` にも分けてある
206
- export {
207
- validate,
208
- VALIDATION_RULES,
209
- type Finding,
210
- type ValidationRule,
211
- } from "./validate/index.js";
50
+ DEFAULT_LANGUAGE_VERSION,
51
+ SourceError,
52
+ SUPPORTED_LANGUAGE_VERSIONS,
53
+ toCanonical,
54
+ type Model,
55
+ } from "./core/model.js";
package/src/mcp.ts CHANGED
@@ -8,28 +8,30 @@
8
8
 
9
9
  import { mkdirSync, readFileSync, realpathSync, renameSync, writeFileSync } from "node:fs";
10
10
  import { dirname, isAbsolute, relative, resolve, sep } from "node:path";
11
+ import { daylightInputs } from "./core/light.js";
12
+ import { polygonAreaM2 } from "./core/model.js";
13
+ import { check } from "./core/diagnose.js";
14
+ import { siteReport } from "./core/site.js";
15
+ import { assess } from "./validate/assessment.js";
16
+ import { createSchematicRegistry, SCHEMATIC_PROFILE_ID } from "./validate/builtin/index.js";
17
+ import { checkDiagnostics } from "./diagnostics.js";
18
+ import { svgPlan } from "./draw/index.js";
19
+ import { doorsBetween } from "./graph.js";
11
20
  import {
12
21
  areaM2,
13
22
  isIndoor,
14
- daylightInputs,
15
- validate,
16
23
  displayName,
17
- doorsBetween,
18
24
  effectiveUse,
19
25
  isOutside,
20
26
  isSemiOutdoor,
21
27
  isVoid,
22
28
  levelsSorted,
23
29
  newUids,
24
- polygonAreaM2,
25
30
  toCanonical,
26
31
  zoneAreaM2,
27
32
  type Model,
28
33
  type Space,
29
- } from "./index.js";
30
- import { check, checkDiagnostics } from "./core/diagnose.js";
31
- import { svgPlan } from "./draw/plan.js";
32
- import { siteReport } from "./core/site.js";
34
+ } from "./model.js";
33
35
  import { parseFile, parseFileWith } from "./parse-file.js";
34
36
 
35
37
  // ---- モデルの読み込みと要約 ----
@@ -119,6 +121,21 @@ function summarize(model: Model, file: string): unknown {
119
121
  ...(model.polygons.size
120
122
  ? { sitePolygons: [...model.polygons.keys()] }
121
123
  : {}),
124
+ // 測地の枠 (ADR-0057) — 書かれていれば返す。**何も導出されていない。**
125
+ // origin の値はメートル、azimuth は +Y の真方位角 (真北から時計回り、0以上360未満)。
126
+ // 不在は 0 ではなく「未知」なので、鍵ごと出ない
127
+ ...(model.origin
128
+ ? {
129
+ origin: {
130
+ epsg: model.origin.epsg,
131
+ easting: model.origin.easting,
132
+ northing: model.origin.northing,
133
+ ...(model.origin.elevation !== undefined ? { elevation: model.origin.elevation } : {}),
134
+ ...(model.origin.vertical !== undefined ? { vertical: model.origin.vertical } : {}),
135
+ },
136
+ }
137
+ : {}),
138
+ ...(model.azimuth ? { azimuth: model.azimuth.deg } : {}),
122
139
  totalFloorM2: Math.round(indoor.reduce((a, s) => a + (areaM2(s) ?? 0), 0) * 100) / 100,
123
140
  semiOutdoorM2: Math.round(semi.reduce((a, s) => a + (areaM2(s) ?? 0), 0) * 100) / 100,
124
141
  floorsM2: byLevel,
@@ -312,37 +329,52 @@ const TOOLS: Record<string, Tool> = {
312
329
  },
313
330
  validate: {
314
331
  description:
315
- "Architectural verdicts: daylight, envelope continuity, stair proportions, slopes, reachability, column/door collisions, and the site. **This is a different surface from the check guarantee** — findings carry rule/level, never code/severity. The surface grows and is not frozen",
316
- schema: { type: "object", properties: FILE_PROP, required: ["file"] },
332
+ "Architectural verdicts under an explicit rule profile: daylight, envelope continuity, stair proportions, slopes, reachability, column/door collisions, and the site. Returns a full AssessmentReport — the profile and rule identities, every rule's outcome, the evidence behind it, and a summary that keeps pass, not-applicable, indeterminate and error apart. **A different surface from the check guarantee**, and not frozen. `profile` is required: no jurisdiction or effective date is inferred",
333
+ schema: {
334
+ type: "object",
335
+ properties: {
336
+ ...FILE_PROP,
337
+ profile: {
338
+ type: "string",
339
+ description: `Rule profile id. koyu ships one: ${SCHEMATIC_PROFILE_ID.id}`,
340
+ },
341
+ asOf: {
342
+ type: "string",
343
+ description: "Effective date as YYYY-MM-DD. Not read from the clock, so the same input judges the same way twice",
344
+ },
345
+ },
346
+ required: ["file", "profile", "asOf"],
347
+ },
317
348
  run: (a) => {
318
349
  const m = load(str(a.file, "file"));
319
- const findings = validate(m);
320
- return {
321
- findings,
322
- violations: findings.filter((f) => f.level === "violation").length,
323
- cautions: findings.filter((f) => f.level === "caution").length,
324
- note: "These are verdicts, not the structural-consistency guarantee of koyu check",
325
- };
350
+ const profile = str(a.profile, "profile");
351
+ if (profile !== SCHEMATIC_PROFILE_ID.id) {
352
+ throw new Error(`Unknown profile: ${profile} (koyu ships one: ${SCHEMATIC_PROFILE_ID.id})`);
353
+ }
354
+ return assess(m, {
355
+ registry: createSchematicRegistry(),
356
+ profile: SCHEMATIC_PROFILE_ID,
357
+ context: { schema: "koyu-context/1", asOf: str(a.asOf, "asOf"), values: {} },
358
+ });
326
359
  },
327
360
  },
328
361
  site: {
329
- description: "Site query: site area (declared against derived), road frontage, footprint, and the coverage and floor-area ratios",
362
+ description:
363
+ "Site query: site area (declared against derived), road frontage, footprint, and the coverage and floor-area ratios. **Numbers only** — whether the declared and derived areas agree closely enough is a verdict, and comes from the validate tool",
330
364
  schema: { type: "object", properties: FILE_PROP, required: ["file"] },
331
365
  run: (a) => {
366
+ // The ratios and their rounding belong to core, which is also what the site rules read.
367
+ // Dividing here again is how an adapter and a rule drift apart.
332
368
  const r = siteReport(load(str(a.file, "file")));
333
- const site = r.declaredArea ?? r.derivedArea;
334
369
  return {
335
370
  ...(r.siteZone ? { siteZone: r.siteZone.path } : {}),
336
371
  ...(r.polygon ? { polygonVertices: r.polygon.points.length } : {}),
337
372
  declaredAreaM2: r.declaredArea,
338
373
  derivedAreaM2: r.derivedArea,
339
- ...(r.declaredArea !== undefined && r.derivedArea !== undefined
340
- ? { areaMatch: Math.abs(r.declaredArea - r.derivedArea) < 0.05 }
341
- : {}),
342
374
  footprintM2: r.footprint,
343
375
  totalFloorM2: r.totalFloor,
344
- coverageRatio: site ? Math.round((r.footprint / site) * 1000) / 10 : undefined,
345
- floorAreaRatio: site ? Math.round((r.totalFloor / site) * 1000) / 10 : undefined,
376
+ coverageRatio: r.coveragePercent,
377
+ floorAreaRatio: r.floorAreaRatioPercent,
346
378
  roads: r.roads.map((rd) => ({
347
379
  path: rd.road.path,
348
380
  name: displayName(rd.road),
@@ -398,7 +430,7 @@ function handle(msg: Json): void {
398
430
  result(id, {
399
431
  protocolVersion: (params.protocolVersion as string) ?? "2025-06-18",
400
432
  capabilities: { tools: {} },
401
- serverInfo: { name: "koyu", version: "0.17.0" },
433
+ serverInfo: { name: "koyu", version: "0.19.0" },
402
434
  instructions:
403
435
  "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.",
404
436
  });
package/src/model.ts ADDED
@@ -0,0 +1,45 @@
1
+ // Public model surface. Keep this facade explicit: adding an export is adding a package promise.
2
+
3
+ export type {
4
+ Area,
5
+ Asset,
6
+ Attrs,
7
+ AttrValue,
8
+ Azimuth,
9
+ Boundary,
10
+ BoundaryKind,
11
+ Column,
12
+ ColumnDecl,
13
+ DrawnLine,
14
+ Edge,
15
+ GridAxis,
16
+ GridRef,
17
+ Level,
18
+ Model,
19
+ Opening,
20
+ Pt,
21
+ Rect,
22
+ Seg,
23
+ SiteOrigin,
24
+ SitePolygon,
25
+ Space,
26
+ Zone,
27
+ } from "./core/model.js";
28
+
29
+ export {
30
+ areaM2,
31
+ DEFAULT_LANGUAGE_VERSION,
32
+ displayName,
33
+ effectiveUse,
34
+ heff,
35
+ isCoveredAbove,
36
+ isIndoor,
37
+ isOutside,
38
+ isSemiOutdoor,
39
+ isVoid,
40
+ levelsSorted,
41
+ newUids,
42
+ SUPPORTED_LANGUAGE_VERSIONS,
43
+ toCanonical,
44
+ zoneAreaM2,
45
+ } from "./core/model.js";