@kensnzk/koyu 0.27.0 → 0.29.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/README.ja.md +1 -1
  2. package/README.md +1 -1
  3. package/assets/plan/README.md +18 -0
  4. package/assets/plan/catalog.muro +87 -0
  5. package/assets/plan/library.muro +26 -0
  6. package/assets/plan/svg/bathtub.svg +9 -0
  7. package/assets/plan/svg/bed-double.svg +9 -0
  8. package/assets/plan/svg/bed-single.svg +8 -0
  9. package/assets/plan/svg/cabinet.svg +9 -0
  10. package/assets/plan/svg/chair.svg +8 -0
  11. package/assets/plan/svg/desk.svg +9 -0
  12. package/assets/plan/svg/hedge-2m.svg +7 -0
  13. package/assets/plan/svg/kitchen-sink.svg +10 -0
  14. package/assets/plan/svg/locker.svg +9 -0
  15. package/assets/plan/svg/office-chair.svg +25 -0
  16. package/assets/plan/svg/potted-plant.svg +14 -0
  17. package/assets/plan/svg/refrigerator.svg +10 -0
  18. package/assets/plan/svg/shelf.svg +9 -0
  19. package/assets/plan/svg/shrub-1m.svg +7 -0
  20. package/assets/plan/svg/sofa-2.svg +9 -0
  21. package/assets/plan/svg/sofa-3.svg +9 -0
  22. package/assets/plan/svg/table-rect.svg +7 -0
  23. package/assets/plan/svg/table-round.svg +7 -0
  24. package/assets/plan/svg/tree-3m.svg +8 -0
  25. package/assets/plan/svg/urinal.svg +9 -0
  26. package/assets/plan/svg/washing-machine-pan.svg +13 -0
  27. package/assets/plan/svg/washing-machine.svg +10 -0
  28. package/assets/plan/svg/washstand-500.svg +12 -0
  29. package/assets/plan/svg/washstand.svg +12 -0
  30. package/assets/plan/svg/wc-cabinet.svg +14 -0
  31. package/assets/plan/svg/wc.svg +9 -0
  32. package/dist/analysis/contracts.d.ts +1 -0
  33. package/dist/analysis/contracts.d.ts.map +1 -1
  34. package/dist/cli.js +16 -4
  35. package/dist/cli.js.map +1 -1
  36. package/dist/core/components.d.ts +31 -0
  37. package/dist/core/components.d.ts.map +1 -0
  38. package/dist/core/components.js +167 -0
  39. package/dist/core/components.js.map +1 -0
  40. package/dist/core/derive.d.ts +13 -2
  41. package/dist/core/derive.d.ts.map +1 -1
  42. package/dist/core/derive.js +36 -5
  43. package/dist/core/derive.js.map +1 -1
  44. package/dist/core/diagnose.d.ts +7 -0
  45. package/dist/core/diagnose.d.ts.map +1 -1
  46. package/dist/core/diagnose.js +141 -5
  47. package/dist/core/diagnose.js.map +1 -1
  48. package/dist/core/diff.d.ts +4 -0
  49. package/dist/core/diff.d.ts.map +1 -1
  50. package/dist/core/diff.js +4 -0
  51. package/dist/core/diff.js.map +1 -1
  52. package/dist/core/fabric.js +1 -1
  53. package/dist/core/fabric.js.map +1 -1
  54. package/dist/core/graph.d.ts +8 -0
  55. package/dist/core/graph.d.ts.map +1 -1
  56. package/dist/core/graph.js +31 -1
  57. package/dist/core/graph.js.map +1 -1
  58. package/dist/core/light.d.ts.map +1 -1
  59. package/dist/core/light.js +2 -0
  60. package/dist/core/light.js.map +1 -1
  61. package/dist/core/model.d.ts +20 -14
  62. package/dist/core/model.d.ts.map +1 -1
  63. package/dist/core/model.js +15 -8
  64. package/dist/core/model.js.map +1 -1
  65. package/dist/core/parse.d.ts.map +1 -1
  66. package/dist/core/parse.js +23 -4
  67. package/dist/core/parse.js.map +1 -1
  68. package/dist/core/vocabulary.d.ts +20 -4
  69. package/dist/core/vocabulary.d.ts.map +1 -1
  70. package/dist/core/vocabulary.js +107 -9
  71. package/dist/core/vocabulary.js.map +1 -1
  72. package/dist/draw/component-files.d.ts +8 -0
  73. package/dist/draw/component-files.d.ts.map +1 -0
  74. package/dist/draw/component-files.js +35 -0
  75. package/dist/draw/component-files.js.map +1 -0
  76. package/dist/draw/component-svg.d.ts +14 -0
  77. package/dist/draw/component-svg.d.ts.map +1 -0
  78. package/dist/draw/component-svg.js +67 -0
  79. package/dist/draw/component-svg.js.map +1 -0
  80. package/dist/draw/conventions/architectural.d.ts +32 -0
  81. package/dist/draw/conventions/architectural.d.ts.map +1 -0
  82. package/dist/draw/conventions/architectural.js +29 -0
  83. package/dist/draw/conventions/architectural.js.map +1 -0
  84. package/dist/draw/index.d.ts +1 -1
  85. package/dist/draw/index.d.ts.map +1 -1
  86. package/dist/draw/index.js +1 -1
  87. package/dist/draw/index.js.map +1 -1
  88. package/dist/draw/marks.d.ts +37 -12
  89. package/dist/draw/marks.d.ts.map +1 -1
  90. package/dist/draw/marks.js +508 -38
  91. package/dist/draw/marks.js.map +1 -1
  92. package/dist/draw/plan.d.ts +3 -1
  93. package/dist/draw/plan.d.ts.map +1 -1
  94. package/dist/draw/plan.js +257 -86
  95. package/dist/draw/plan.js.map +1 -1
  96. package/dist/form.d.ts +1 -1
  97. package/dist/form.d.ts.map +1 -1
  98. package/dist/form.js.map +1 -1
  99. package/dist/index.js +1 -1
  100. package/dist/mcp.js +22 -3
  101. package/dist/mcp.js.map +1 -1
  102. package/dist/parse-file.d.ts +1 -0
  103. package/dist/parse-file.d.ts.map +1 -1
  104. package/dist/parse-file.js +1 -0
  105. package/dist/parse-file.js.map +1 -1
  106. package/dist/validate/assessment.js +13 -2
  107. package/dist/validate/assessment.js.map +1 -1
  108. package/dist/validate/builtin/index.d.ts +4 -2
  109. package/dist/validate/builtin/index.d.ts.map +1 -1
  110. package/dist/validate/builtin/index.js +9 -2
  111. package/dist/validate/builtin/index.js.map +1 -1
  112. package/dist/validate/builtin/opening-operations.d.ts +63 -0
  113. package/dist/validate/builtin/opening-operations.d.ts.map +1 -0
  114. package/dist/validate/builtin/opening-operations.js +406 -0
  115. package/dist/validate/builtin/opening-operations.js.map +1 -0
  116. package/dist/validate/contracts.d.ts +1 -0
  117. package/dist/validate/contracts.d.ts.map +1 -1
  118. package/dist/validate/contracts.js.map +1 -1
  119. package/editors/vscode/syntaxes/koyu.tmLanguage.json +4 -4
  120. package/examples/basement/main.muro +3 -3
  121. package/examples/complex/L1.muro +1 -1
  122. package/examples/complex/assets.muro +2 -2
  123. package/examples/complex/main.muro +1 -1
  124. package/examples/house/L1.muro +3 -3
  125. package/examples/house/L2.muro +2 -2
  126. package/examples/house/assets.muro +8 -8
  127. package/examples/house/main.muro +1 -1
  128. package/examples/house/site.muro +2 -2
  129. package/examples/house.muro +6 -6
  130. package/examples/mansion.muro +1 -1
  131. package/examples/office.muro +1 -1
  132. package/examples/spatial/layout.muro +8 -0
  133. package/examples/spatial/main.muro +4 -0
  134. package/examples/steps/06-finished.muro +1 -1
  135. package/examples/tower/assets.muro +1 -1
  136. package/examples/tower/main.muro +1 -1
  137. package/examples/twin/assets.muro +2 -2
  138. package/examples/twin/main.muro +1 -1
  139. package/examples/two-rooms.canonical.json +1 -1
  140. package/examples/two-rooms.muro +1 -1
  141. package/package.json +9 -5
  142. package/src/analysis/contracts.ts +1 -0
  143. package/src/cli.ts +15 -4
  144. package/src/core/components.ts +224 -0
  145. package/src/core/derive.ts +53 -6
  146. package/src/core/diagnose.ts +185 -5
  147. package/src/core/diff.ts +3 -0
  148. package/src/core/fabric.ts +1 -1
  149. package/src/core/graph.ts +32 -0
  150. package/src/core/light.ts +1 -0
  151. package/src/core/model.ts +23 -13
  152. package/src/core/parse.ts +21 -4
  153. package/src/core/vocabulary.ts +115 -9
  154. package/src/draw/component-files.ts +36 -0
  155. package/src/draw/component-svg.ts +79 -0
  156. package/src/draw/conventions/architectural.ts +60 -0
  157. package/src/draw/index.ts +1 -1
  158. package/src/draw/marks.ts +564 -44
  159. package/src/draw/plan.ts +262 -89
  160. package/src/form.ts +1 -0
  161. package/src/index.ts +1 -1
  162. package/src/mcp.ts +22 -3
  163. package/src/parse-file.ts +1 -0
  164. package/src/validate/assessment.ts +17 -3
  165. package/src/validate/builtin/index.ts +14 -2
  166. package/src/validate/builtin/opening-operations.ts +519 -0
  167. package/src/validate/contracts.ts +1 -0
@@ -30,8 +30,17 @@ import { heff, isSemiOutdoor, levelsSorted, SUPPORTED_LANGUAGE_VERSIONS, type At
30
30
  isVoid,
31
31
  EXTERIOR
32
32
  } from "./model.js";
33
- import { ASSET_ELEM, attrSpec, isNamespaced } from "./vocabulary.js";
33
+ import {
34
+ MURO_1_5_OPENING_ATTRS,
35
+ MURO_1_5_OPENING_STYLES,
36
+ MURO_1_5_COMPONENT_AREA_ATTRS,
37
+ attrSpec,
38
+ assetElem,
39
+ isNamespaced,
40
+ openingStyleOwner,
41
+ } from "./vocabulary.js";
34
42
  import { runDecls, runIssues } from "./vertical.js";
43
+ import { placedComponents } from "./components.js";
35
44
 
36
45
  export interface CheckResult {
37
46
  errors: string[];
@@ -88,6 +97,10 @@ export const DIAGNOSTIC_CODES = {
88
97
  OPN06: "error", // 開口の幅が線分長を超える
89
98
  OPN07: "error", // 開口の明示位置の軸違い
90
99
  OPN08: "error", // 開口の明示位置のはみ出し
100
+ OPN09: "error", // opening kind and operation disagree
101
+ OPN10: "error", // curtain-wall panel layout is not applicable or not a whole count
102
+ CMP01: "error", // component asset declaration or area reference cannot be resolved
103
+ CMP02: "error", // transformed component footprint extends outside its host area
91
104
  SEG01: "error", // 領域を持たない空間へのarea
92
105
  SEG02: "warning", // areaのはみ出し
93
106
  SEG03: "warning", // open境界のseg (解釈されない)
@@ -132,6 +145,9 @@ export const DIAGNOSTIC_CODES = {
132
145
  VER05: "error", // koyu 1.0以前のファイルの型の位置に exterior / void (ADR-0051)
133
146
  VER06: "error", // the file declares a language version newer than this build reads
134
147
  VER07: "error", // the file declares a version in which a key it writes is retired (ADR-0061)
148
+ VER08: "error", // the file uses opening presentation introduced in muro 1.5 (ADR-0068/0074)
149
+ VER09: "error", // the file uses component assets or area placement introduced in muro 1.5
150
+ VER10: "error", // spatial mode requires muro 1.6
135
151
  SYN01: "error", // 構文・合成エラー (SourceError の写し — check --json のみ)
136
152
  } as const satisfies Record<string, "error" | "warning">;
137
153
 
@@ -211,7 +227,7 @@ function attrSubjects(
211
227
  }
212
228
  }
213
229
  for (const a of model.assets.values()) {
214
- out.push([`asset ${a.name}`, { elem: ASSET_ELEM, of: a.attrs }, { line: a.line, file: a.file }]);
230
+ out.push([`asset ${a.name}`, { elem: assetElem(a.kind), of: a.attrs }, { line: a.line, file: a.file }]);
215
231
  }
216
232
  for (const c of model.columns) {
217
233
  out.push([`column ${c.size}mm`, { elem: "column", of: c.attrs }, { line: c.line, file: c.file }]);
@@ -310,6 +326,8 @@ export function checkDiagnostics(model: Model): Diagnostic[] {
310
326
  checkSpaceOverlap(ctx);
311
327
  checkDaylightScope(ctx);
312
328
  checkAttrValues(ctx);
329
+ checkAssetOpenings(ctx);
330
+ checkComponents(ctx);
313
331
  checkRuns(ctx);
314
332
  checkDrawnLines(ctx);
315
333
  checkColumns(ctx);
@@ -326,6 +344,73 @@ export function checkDiagnostics(model: Model): Diagnostic[] {
326
344
  return diags;
327
345
  }
328
346
 
347
+ function curtainWallPanelIssue(kind: "door" | "window", attrs: Attrs): string | undefined {
348
+ const panels = attrs["panels"];
349
+ if (panels === undefined) return undefined;
350
+ if (kind !== "window" || attrs["style"] !== "curtain-wall") {
351
+ return "panels: may only be written on a window with style:curtain-wall";
352
+ }
353
+ // ATT01 owns non-numeric and non-positive values. This check adds the curtain-wall-specific
354
+ // fact that a count cannot be fractional, without emitting two errors for the same spelling.
355
+ if (typeof panels === "number" && panels > 0 && !Number.isInteger(panels)) {
356
+ return `panels on a curtain wall is a positive whole number: panels:${panels}`;
357
+ }
358
+ return undefined;
359
+ }
360
+
361
+ /** Asset declarations are useful without an instance, so their own opening facts must be valid. */
362
+ function checkAssetOpenings(ctx: Ctx): void {
363
+ const { model, emit } = ctx;
364
+ if (olderThan(model.version, "1.5")) return;
365
+ for (const asset of model.assets.values()) {
366
+ if (asset.kind === "component") continue;
367
+ const style = asset.attrs["style"];
368
+ if (typeof style === "string") {
369
+ const owner = openingStyleOwner(asset.kind, style);
370
+ if (owner) {
371
+ emit(
372
+ "OPN09",
373
+ `style:${style} is a ${owner}-only operation and cannot be used on ${asset.kind} asset ${asset.name}`,
374
+ { line: asset.line, file: asset.file },
375
+ );
376
+ }
377
+ }
378
+ const issue = curtainWallPanelIssue(asset.kind, asset.attrs);
379
+ if (issue) emit("OPN10", `${issue} on asset ${asset.name}`, { line: asset.line, file: asset.file });
380
+ }
381
+ }
382
+
383
+ /** Component declarations and their area-hosted instances are checked in source order. */
384
+ function checkComponents(ctx: Ctx): void {
385
+ const { model, emit } = ctx;
386
+ for (const asset of model.assets.values()) {
387
+ if (asset.kind !== "component") continue;
388
+ const missing = ["w", "d", "plan-svg"].filter((key) => asset.attrs[key] === undefined);
389
+ if (missing.length > 0) {
390
+ emit(
391
+ "CMP01",
392
+ `Component asset ${asset.name} requires ${missing.map((key) => `${key}:`).join(" / ")}`,
393
+ { line: asset.line, file: asset.file },
394
+ );
395
+ }
396
+ const ref = asset.attrs["plan-svg"];
397
+ if (ref !== undefined && (typeof ref !== "string" || (!ref.startsWith("./") && !ref.startsWith("../")))) {
398
+ emit(
399
+ "CMP01",
400
+ `Component asset ${asset.name} plan-svg takes a relative path: ${String(ref)}`,
401
+ { line: asset.line, file: asset.file },
402
+ );
403
+ }
404
+ }
405
+ for (const issue of placedComponents(model).issues) {
406
+ emit(issue.code, issue.message, {
407
+ line: issue.line,
408
+ ...(issue.file ? { file: issue.file } : {}),
409
+ path: issue.path,
410
+ });
411
+ }
412
+ }
413
+
329
414
 
330
415
  /** 吹抜けが下階の空間の平面をどれだけ覆うか (0..1) */
331
416
  function voidCoverage(s: Space, partners: Space[]): number {
@@ -641,10 +726,10 @@ function checkColumns(ctx: Ctx): void {
641
726
  }
642
727
  }
643
728
 
644
- /** 言語版の受理条件 — VER01〜VER05 と VER07 (VER06 は parse が投げる) */
729
+ /** Language-version acceptance: VER01–VER05 and VER07–VER08. Parsing raises VER06. */
645
730
  function checkLanguageVersion(ctx: Ctx): void {
646
731
  const { model, emit, loc, withRect, levels, levelIndex } = ctx;
647
- // 言語版の受理条件 (ADR-0017): 旧版は意味保存の場合のみ受理する。
732
+ // Language-version acceptance (ADR-0017): an older file is accepted only where meaning holds.
648
733
  // 既定境界 (ADR-0014) が導出されるファイルは、0.1の意味 (境界なし+警告) と食い違う — エラーで二択を示す
649
734
  if (model.version === "0.1") {
650
735
  for (const b of model.boundaries) {
@@ -764,6 +849,75 @@ function checkLanguageVersion(ctx: Ctx): void {
764
849
  }
765
850
  }
766
851
 
852
+ // The expanded opening operation vocabulary arrives in muro 1.5. An older processor rejects
853
+ // these values, so an older declaration may not use them even though this build can interpret
854
+ // them. Scan written assets and opening declarations; do not report an instance a second time
855
+ // when its value is inherited unchanged from an asset that is already reported.
856
+ if (olderThan(model.version, "1.5")) {
857
+ const introduced = new Set<string>(MURO_1_5_OPENING_STYLES);
858
+ const introducedAttrs = new Set<string>(MURO_1_5_OPENING_ATTRS);
859
+ for (const a of model.assets.values()) {
860
+ const style = a.attrs["style"];
861
+ const attr = Object.keys(a.attrs).find((key) => introducedAttrs.has(key));
862
+ if (typeof style === "string" && introduced.has(style)) {
863
+ emit(
864
+ "VER08",
865
+ `A muro ${model.version} file uses a 1.5 opening style: ${style} on asset ${a.name} — raise the version to muro 1.5`,
866
+ { line: a.line, file: a.file },
867
+ );
868
+ } else if (attr) {
869
+ emit(
870
+ "VER08",
871
+ `A muro ${model.version} file uses a 1.5 opening attribute: ${attr} on asset ${a.name} — raise the version to muro 1.5`,
872
+ { line: a.line, file: a.file },
873
+ );
874
+ }
875
+ }
876
+ for (const b of model.boundaries) {
877
+ for (const o of b.openings) {
878
+ const style = o.attrs["style"];
879
+ const inherited = o.ref === undefined ? undefined : model.assets.get(o.ref)?.attrs["style"];
880
+ const assetAttrs = o.ref === undefined ? undefined : model.assets.get(o.ref)?.attrs;
881
+ const attr = Object.keys(o.attrs).find(
882
+ (key) => introducedAttrs.has(key) && assetAttrs?.[key] !== o.attrs[key],
883
+ );
884
+ if (typeof style === "string" && introduced.has(style) && inherited !== style) {
885
+ emit(
886
+ "VER08",
887
+ `A muro ${model.version} file uses a 1.5 opening style: ${style} on ${o.kind} (${b.a} | ${b.b}) — raise the version to muro 1.5`,
888
+ { line: o.line, file: b.file, path: [b.a, b.b] },
889
+ );
890
+ } else if (attr) {
891
+ emit(
892
+ "VER08",
893
+ `A muro ${model.version} file uses a 1.5 opening attribute: ${attr} on ${o.kind} (${b.a} | ${b.b}) — raise the version to muro 1.5`,
894
+ { line: o.line, file: b.file, path: [b.a, b.b] },
895
+ );
896
+ }
897
+ }
898
+ }
899
+ const componentAreaAttrs = new Set<string>(MURO_1_5_COMPONENT_AREA_ATTRS);
900
+ for (const asset of model.assets.values()) {
901
+ if (asset.kind !== "component") continue;
902
+ emit(
903
+ "VER09",
904
+ `A muro ${model.version} file declares a 1.5 component asset: ${asset.name} — raise the version to muro 1.5`,
905
+ { line: asset.line, file: asset.file },
906
+ );
907
+ }
908
+ for (const space of model.spaces.values()) {
909
+ for (const area of space.areas) {
910
+ const attr = Object.keys(area.attrs).find((key) => componentAreaAttrs.has(key));
911
+ if (!attr) continue;
912
+ emit(
913
+ "VER09",
914
+ `A muro ${model.version} file uses a 1.5 component placement attribute: ${attr} on area (${space.path}) — raise the version to muro 1.5`,
915
+ { line: area.line, file: space.file, path: [space.path] },
916
+ );
917
+ }
918
+ }
919
+ }
920
+
767
921
  // A retired key is VER03/VER04 read from the other end. Those fire when a file declares an old
768
922
  // version and writes a word that version does not yet have; this one fires when a file declares
769
923
  // a new version and writes a word that version no longer has. Both say the same thing — the
@@ -987,6 +1141,31 @@ function checkOpenings(ctx: Ctx, b: Boundary): void {
987
1141
  }
988
1142
  const placedOnSeg: Array<{ o: (typeof b.openings)[number]; key: string; c: number }> = [];
989
1143
  for (const o of b.openings) {
1144
+ if (!olderThan(model.version, "1.5")) {
1145
+ const style = o.attrs["style"];
1146
+ if (typeof style === "string") {
1147
+ const owner = openingStyleOwner(o.kind, style);
1148
+ const inherited = o.ref === undefined ? undefined : model.assets.get(o.ref)?.attrs["style"];
1149
+ if (owner && inherited !== style) {
1150
+ emit(
1151
+ "OPN09",
1152
+ `style:${style} is a ${owner}-only operation and cannot be used on a ${o.kind}`,
1153
+ { line: o.line, file: b.file, path: [b.a, b.b] },
1154
+ );
1155
+ }
1156
+ }
1157
+ const panelIssue = curtainWallPanelIssue(o.kind, o.attrs);
1158
+ if (panelIssue) {
1159
+ const asset = o.ref === undefined ? undefined : model.assets.get(o.ref);
1160
+ const inheritedIssue = asset && asset.kind !== "component"
1161
+ ? curtainWallPanelIssue(asset.kind, asset.attrs)
1162
+ : undefined;
1163
+ const unchanged = asset?.attrs["style"] === o.attrs["style"] && asset?.attrs["panels"] === o.attrs["panels"];
1164
+ if (!(inheritedIssue === panelIssue && unchanged)) {
1165
+ emit("OPN10", panelIssue, { line: o.line, file: b.file, path: [b.a, b.b] });
1166
+ }
1167
+ }
1168
+ }
990
1169
  const placed = placeOpening(model, b, o);
991
1170
  if ("error" in placed && placed.error) {
992
1171
  emit(placed.code, placed.message, { line: placed.line, file: placed.file, path: [b.a, b.b] });
@@ -1195,7 +1374,7 @@ function checkSpaceSufficiency(ctx: Ctx): void {
1195
1374
  emit("SUF02", `${s.path} has a region, but its level cannot be determined (give it at the head of the path or with level:)`, at);
1196
1375
  continue; // z が決まらない空間には、天井高を問う意味が無い
1197
1376
  }
1198
- if (isVoid(s) || isOutside(s) || isSemiOutdoor(model, s)) continue;
1377
+ if (model.mode === "spatial" || isVoid(s) || isOutside(s) || isSemiOutdoor(model, s)) continue;
1199
1378
  if (heff(model, s) === undefined) {
1200
1379
  emit(
1201
1380
  "SUF01",
@@ -1214,6 +1393,7 @@ function checkSpaceSufficiency(ctx: Ctx): void {
1214
1393
  * 決定的な規則であり、複数の形が出るわけではない。ただし床の無い建物になることは知らされるべきである
1215
1394
  */
1216
1395
  function checkLevelSufficiency(ctx: Ctx): void {
1396
+ if (ctx.model.mode === "spatial") return;
1217
1397
  const { emit, withRect, levels } = ctx;
1218
1398
  for (const l of levels) {
1219
1399
  if (l.slab !== undefined) continue;
package/src/core/diff.ts CHANGED
@@ -87,6 +87,7 @@ export interface BoundaryChange {
87
87
 
88
88
  export interface ModelDiff {
89
89
  version?: { from: string; to: string };
90
+ mode?: { from: "building" | "spatial"; to: "building" | "spatial" };
90
91
  name?: { from?: string; to?: string };
91
92
  grid: GridChange[];
92
93
  levels: { added: string[]; removed: string[]; changed: ChangedItem[] };
@@ -464,6 +465,7 @@ export function semanticDiff(a: Model, b: Model): ModelDiff {
464
465
  boundaries: { added: [], removed: [], changed: [] },
465
466
  columns: { added: [], removed: [], changed: [] },
466
467
  };
468
+ if (a.mode !== b.mode) d.mode = { from: a.mode ?? "building", to: b.mode ?? "building" };
467
469
  if (a.version !== b.version) d.version = { from: a.version, to: b.version };
468
470
  if (a.name !== b.name) {
469
471
  d.name = { ...(a.name !== undefined ? { from: a.name } : {}), ...(b.name !== undefined ? { to: b.name } : {}) };
@@ -689,6 +691,7 @@ export function renderDiff(d: ModelDiff): string[] {
689
691
  // **The label names the language, not the implementation.** It also may not be the written
690
692
  // declaration: from 1.2 the word is `muro`, so printing `koyu 1.2` would show a line the
691
693
  // parser refuses. This is a label for a change, not a copy of either file's first line.
694
+ if (d.mode) out.push(`± mode ${d.mode.from} → ${d.mode.to}`);
692
695
  if (d.version) out.push(`± muro ${d.version.from} → ${d.version.to}`);
693
696
  if (d.name) out.push(`± name ${d.name.from ?? "—"} → ${d.name.to ?? "—"}`);
694
697
  for (const n of d.levels.added) out.push(`+ level ${n}`);
@@ -109,7 +109,7 @@ export function slabs(model: Model): Slab[] {
109
109
  // 吹抜けは、天窓で塞がれた竪穴か、空に開いた中庭かのどちらかであり、
110
110
  // 後者は半屋外として導出される (ADR-0007)。だから除くのは外部と半屋外だけである。
111
111
  // 逆に**覆っている側には吹抜けも数える** — 竪穴の途中の階に屋根は架からない。
112
- if (isExterior || semi) continue;
112
+ if (model.mode === "spatial" || isExterior || semi) continue;
113
113
  // **覆っているものも導出された形で取る。**割付で取ると、上階を斜めに切った
114
114
  // 範囲まで「覆われている」と数えてしまい、その真下に屋根が架からなかった
115
115
  const covers: Pt[][] = [];
package/src/core/graph.ts CHANGED
@@ -6,6 +6,7 @@
6
6
  import type { Boundary, Edge, Model, Opening, Pt, Rect, Space } from "./model.js";
7
7
  import {
8
8
  canonicalBoundaryOrder,
9
+ canonicalSpaceOrder,
9
10
  canonicalizeDrawn,
10
11
  compareCanonical,
11
12
  EXTERIOR,
@@ -152,6 +153,35 @@ export function mergeCollinear(segs: Segment[]): Segment[] {
152
153
  return out;
153
154
  }
154
155
 
156
+ /** An allocated face with no boundary declaration; it asserts no wall or passage. */
157
+ export interface UnresolvedBoundary {
158
+ a: string;
159
+ b: string;
160
+ level: string;
161
+ segment: Segment;
162
+ }
163
+
164
+ export function unresolvedBoundaries(model: Model): UnresolvedBoundary[] {
165
+ if (model.mode !== "spatial") return [];
166
+ const spaces = canonicalSpaceOrder(model).filter(s => s.rects.length > 0 && s.level !== undefined);
167
+ const result: UnresolvedBoundary[] = [];
168
+ for (let i = 0; i < spaces.length; i++) {
169
+ const a = spaces[i]!;
170
+ for (let j = i + 1; j < spaces.length; j++) {
171
+ const b = spaces[j]!;
172
+ if (a.level !== b.level) continue;
173
+ let segments = sharedFromPieces(piecesOf(a), piecesOf(b));
174
+ for (const boundary of model.boundaries) {
175
+ if (!((boundary.a === a.path && boundary.b === b.path) || (boundary.a === b.path && boundary.b === a.path))) continue;
176
+ for (const covered of segmentsFor(model, boundary)) segments = segments.flatMap(s => subtractOverlap(s, covered));
177
+ }
178
+ for (const segment of segments) result.push({ a: a.path, b: b.path, level: a.level!, segment });
179
+ }
180
+ for (const segment of envelopeGaps(model, a)) result.push({ a: a.path, b: EXTERIOR, level: a.level!, segment });
181
+ }
182
+ return result;
183
+ }
184
+
155
185
  /**
156
186
  * 既定境界の導出 (ADR-0014) — 垂直の「既定は床」と対称の、水平の「既定は壁」。
157
187
  * 同一レベル (未特定同士を含む) で平面が接する領域つき空間の組に、宣言境界がその組に
@@ -160,6 +190,7 @@ export function mergeCollinear(segs: Segment[]): Segment[] {
160
190
  * 合成・スパン展開の完了後に呼ぶ (parse / parseWith の出口)。冪等。
161
191
  */
162
192
  export function deriveDefaultBoundaries(model: Model): void {
193
+ if (model.mode === "spatial") return;
163
194
  const declared = new Set<string>();
164
195
  for (const b of model.boundaries) declared.add([b.a, b.b].sort().join("|"));
165
196
  const withRect = [...model.spaces.values()].filter((s) => s.rects.length > 0);
@@ -770,6 +801,7 @@ export interface Route {
770
801
 
771
802
  /** aからbまで扉をいくつ通るか (最小)。到達不能なら undefined */
772
803
  export function doorsBetween(model: Model, from: string, to: string): Route | undefined {
804
+ if (model.mode === "spatial") throw new Error("Circulation is not evaluated in spatial mode");
773
805
  if (!model.spaces.has(from) || !model.spaces.has(to)) return undefined;
774
806
  const dist = new Map<string, number>();
775
807
  const prev = new Map<string, string>();
package/src/core/light.ts CHANGED
@@ -33,6 +33,7 @@ export interface DaylightInput {
33
33
  * 上が開いた半屋外越しなら1.0。この係数は形の導出であって判定ではない。
34
34
  */
35
35
  export function daylightInputs(model: Model): DaylightInput[] {
36
+ if (model.mode === "spatial") throw new Error("Daylight is not evaluated in spatial mode");
36
37
  const out: DaylightInput[] = [];
37
38
  for (const s of model.spaces.values()) {
38
39
  if (s.rects.length === 0) continue;
package/src/core/model.ts CHANGED
@@ -51,6 +51,12 @@ export const MURO_SUPPORT: readonly { muro: string; since: string; until: string
51
51
  // boundary to a region-less space was written, so a forgotten line was a silent hole; from 1.4
52
52
  // that face is a wall, and what is declared is which outside it looks at (ADR-0065).
53
53
  { muro: "1.4", since: "0.26.0", until: null },
54
+ // 1.5 gives opening operation styles explicit values and adds area-hosted component assets.
55
+ // A plan can distinguish opening operations without guessing from names or widths, and can
56
+ // place fixed furniture or equipment footprints while keeping SVG artwork out of Form
57
+ // (ADR-0068, ADR-0075).
58
+ { muro: "1.5", since: "0.28.0", until: null },
59
+ { muro: "1.6", since: "0.29.0", until: null },
54
60
  ];
55
61
 
56
62
  /** The word a version line is written with from 1.2 on. */
@@ -77,7 +83,7 @@ export const LAST_KOYU_SPELLED_VERSION = "1.1";
77
83
  * `since` column is written in this vocabulary, and every surface that answers "which muro
78
84
  * does this build speak" needs both halves at once.
79
85
  */
80
- export const KOYU_VERSION = "0.27.0";
86
+ export const KOYU_VERSION = "0.29.0";
81
87
 
82
88
  /**
83
89
  * Whether `a` names a later language version than `b`.
@@ -198,18 +204,18 @@ export const NEWEST_LANGUAGE_VERSION = SUPPORTED_LANGUAGE_VERSIONS[SUPPORTED_LAN
198
204
  export const DEFAULT_LANGUAGE_VERSION = "1.1";
199
205
 
200
206
  /**
201
- * 機械形式 (正準JSON) が自分を名乗る版 (ADR-0036)。**言語版でもツール版でもない** —
202
- * 数えるのは綴りだけである。minorはキーが増えたとき、majorは既存のキーの名前・並び・照合順・
203
- * 正規化・数の綴りが変わったとき。**minorでも全ての文書のバイトは動く** — この文字列自体が
204
- * 第一キーだからで、増えたキーを持たない文書も先頭行だけは変わる (ADR-0051 が実測している)。
205
- * 意味論の版は muro が持つので、`muro` キー (書かれた版宣言の素通し) とは別の面である。
207
+ * The canonical spelling version is independent of the language and package versions.
208
+ * A format bump changes every document's bytes, including unchanged older sources.
209
+ * The optional `mode` key is gated by an explicit Muro 1.6 declaration and spatial opt-in;
210
+ * it keeps format 2.0 so building documents retain their existing canonical bytes.
211
+ * Consumers must understand the declared language and mode before interpreting a document.
206
212
  *
207
213
  * The format keeps the name `koyu` because it is the implementation's output spelling — the
208
214
  * shape koyu writes. The key inside it names the language, and is spelled `muro` for the same
209
215
  * reason the version line is.
210
216
  *
211
- * **That rename is why this is 2.0 and not 1.3.** An existing key changed its name, which the
212
- * rule above puts squarely in major. Shipping it as a minor would have told every reader that
217
+ * **That rename introduced 2.0 rather than 1.3.** An existing key changed its name, which the
218
+ * format policy puts squarely in major. Shipping it as a minor would have told every reader that
213
219
  * `1.x` stays compatible — so a reader expecting `koyu` would have accepted the document and
214
220
  * found no language version in it, which is the silent misread the format version exists to
215
221
  * prevent.
@@ -346,13 +352,13 @@ export interface Zone {
346
352
  }
347
353
 
348
354
  /**
349
- * 建具アセット — RevitのFamily、USDのReferenceにあたる型の宣言 (ADR-0010)。
350
- * `asset SD1 door w:800 style:sliding` と宣言し、開口が `door SD1 ...` で参照する。
351
- * インスタンス側の属性が上書きする。別ファイル (アセット集) に置いて import できる
355
+ * A reusable asset definition. Door/window assets provide opening defaults; component assets
356
+ * provide a fixed footprint and a plan artwork reference to a named area. Definitions may live
357
+ * in an imported library layer.
352
358
  */
353
359
  export interface Asset {
354
360
  name: string;
355
- kind: "door" | "window";
361
+ kind: "door" | "window" | "component";
356
362
  attrs: Attrs;
357
363
  line: number;
358
364
  file?: string;
@@ -472,6 +478,9 @@ export function srcRef(line: number, file?: string): string {
472
478
 
473
479
  export interface Model {
474
480
  version: string;
481
+ /** Absent means the building reading. Spatial mode leaves unwritten boundaries unresolved. */
482
+ mode?: "spatial";
483
+ modeSource?: { line: number; file?: string };
475
484
  name?: string;
476
485
  unit: "mm";
477
486
  /**
@@ -696,7 +705,7 @@ export class SourceError extends Error {
696
705
  * module, so the union cannot be imported here — and widening it to `string` would let
697
706
  * a typo reach `check --json` as a code no page documents.
698
707
  */
699
- public code?: "VER06",
708
+ public code?: "VER06" | "VER10",
700
709
  ) {
701
710
  super(`${file ? `${file}:` : ""}line ${line}: ${raw}`);
702
711
  this.name = "SourceError";
@@ -1209,6 +1218,7 @@ export function toCanonical(model: Model): string {
1209
1218
  // A document written `koyu 1.1` still says `"muro": "1.1"` here: the key is the name of
1210
1219
  // the thing being versioned, not a copy of how the author spelled the declaration.
1211
1220
  ...(model.versionDeclared ? { muro: model.version } : {}),
1221
+ ...(model.mode ? { mode: model.mode } : {}),
1212
1222
  ...(model.name ? { name: model.name } : {}),
1213
1223
  unit: model.unit,
1214
1224
  // 測地の枠 (ADR-0057) — **単位を言った直後、グリッドを言う前。**この二つは grid が張る
package/src/core/parse.ts CHANGED
@@ -66,6 +66,12 @@ interface BandMember {
66
66
  line: number;
67
67
  }
68
68
 
69
+ function checkModeVersion(model: Model): void {
70
+ if (model.mode && !isNewerVersion(model.version, "1.5")) {
71
+ throw new SourceError(model.modeSource?.line ?? 0, "mode spatial requires muro 1.6", model.modeSource?.file, "VER10");
72
+ }
73
+ }
74
+
69
75
  function emptyModel(): Model {
70
76
  return {
71
77
  version: DEFAULT_LANGUAGE_VERSION,
@@ -100,6 +106,7 @@ export function parse(source: string): Model {
100
106
  // 描かれた線で領域を切り分けてから、既定の壁を導く (ADR-0022 / docs/reference/form/index.md)。
101
107
  // 逆順だと、線で接触が消えた組にも既定境界が生まれ、線分ゼロの境界に
102
108
  // 出所の無い BND04 が出る — 書いていない関係を責めることになる
109
+ checkModeVersion(model);
103
110
  derivePieces(model);
104
111
  deriveDefaultBoundaries(model);
105
112
  return model;
@@ -121,6 +128,7 @@ export function parseWith(loader: LayerLoader, entry: string): Model {
121
128
  // 描かれた線で領域を切り分けてから、既定の壁を導く (ADR-0022 / docs/reference/form/index.md)。
122
129
  // 逆順だと、線で接触が消えた組にも既定境界が生まれ、線分ゼロの境界に
123
130
  // 出所の無い BND04 が出る — 書いていない関係を責めることになる
131
+ checkModeVersion(model);
124
132
  derivePieces(model);
125
133
  deriveDefaultBoundaries(model);
126
134
  return model;
@@ -328,6 +336,14 @@ function ingest(
328
336
  model.versionDeclared = true;
329
337
  break;
330
338
  }
339
+ case "mode": {
340
+ if (rest.length !== 1 || rest[0] !== "spatial") throw new SourceError(ln, "mode takes exactly one value: spatial");
341
+ if (file !== undefined && model.layers[0] !== file) throw new SourceError(ln, "The mode is declared only in the base layer (the entry)");
342
+ if (model.mode) throw new SourceError(ln, "The mode is declared once");
343
+ model.mode = "spatial";
344
+ model.modeSource = { line: ln, ...(file ? { file } : {}) };
345
+ break;
346
+ }
331
347
  case "import": {
332
348
  const rel = rest[0];
333
349
  if (!rel) throw new SourceError(ln, "import takes a relative path: import ./assets.muro");
@@ -382,14 +398,15 @@ function ingest(
382
398
  break;
383
399
  }
384
400
  case "asset": {
385
- // 建具アセット (RevitのFamily / USDのReference — ADR-0010)
401
+ // Referenced type. Door/window assets attach to boundaries; component assets attach to
402
+ // named uncounted areas and may carry external plan artwork.
386
403
  const aname = rest[0];
387
404
  const akind = rest[1];
388
405
  if (!aname || aname.includes(":") || aname.startsWith("/")) {
389
- throw new SourceError(ln, "asset takes the form asset <name> door|window [attributes...]");
406
+ throw new SourceError(ln, "asset takes the form asset <name> door|window|component [attributes...]");
390
407
  }
391
- if (akind !== "door" && akind !== "window") {
392
- throw new SourceError(ln, `An asset kind is door / window: ${akind}`);
408
+ if (akind !== "door" && akind !== "window" && akind !== "component") {
409
+ throw new SourceError(ln, `An asset kind is door / window / component: ${akind}`);
393
410
  }
394
411
  const prevA = model.assets.get(aname);
395
412
  if (prevA) {