@kensnzk/koyu 0.16.0 → 0.18.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.
- package/README.ja.md +12 -8
- package/README.md +13 -10
- package/dist/analysis/contracts.d.ts +217 -0
- package/dist/analysis/contracts.d.ts.map +1 -0
- package/dist/analysis/contracts.js +27 -0
- package/dist/analysis/contracts.js.map +1 -0
- package/dist/analysis/index.d.ts +5 -0
- package/dist/analysis/index.d.ts.map +1 -0
- package/dist/analysis/index.js +17 -0
- package/dist/analysis/index.js.map +1 -0
- package/dist/analysis/json.d.ts +21 -0
- package/dist/analysis/json.d.ts.map +1 -0
- package/dist/analysis/json.js +111 -0
- package/dist/analysis/json.js.map +1 -0
- package/dist/cli.js +106 -35
- package/dist/cli.js.map +1 -1
- package/dist/core/derive.d.ts +13 -8
- package/dist/core/derive.d.ts.map +1 -1
- package/dist/core/derive.js +19 -13
- package/dist/core/derive.js.map +1 -1
- package/dist/core/diagnose.d.ts +4 -3
- package/dist/core/diagnose.d.ts.map +1 -1
- package/dist/core/diagnose.js +46 -11
- package/dist/core/diagnose.js.map +1 -1
- package/dist/core/diff.d.ts +3 -2
- package/dist/core/diff.d.ts.map +1 -1
- package/dist/core/diff.js +8 -5
- package/dist/core/diff.js.map +1 -1
- package/dist/core/fabric.d.ts +1 -3
- package/dist/core/fabric.d.ts.map +1 -1
- package/dist/core/fabric.js +8 -8
- package/dist/core/fabric.js.map +1 -1
- package/dist/core/graph.d.ts +2 -2
- package/dist/core/graph.d.ts.map +1 -1
- package/dist/core/graph.js +12 -5
- package/dist/core/graph.js.map +1 -1
- package/dist/core/light.d.ts.map +1 -1
- package/dist/core/light.js +2 -2
- package/dist/core/light.js.map +1 -1
- package/dist/core/model.d.ts +59 -10
- package/dist/core/model.d.ts.map +1 -1
- package/dist/core/model.js +128 -26
- package/dist/core/model.js.map +1 -1
- package/dist/core/parse.d.ts.map +1 -1
- package/dist/core/parse.js +83 -82
- package/dist/core/parse.js.map +1 -1
- package/dist/core/poly.d.ts +0 -4
- package/dist/core/poly.d.ts.map +1 -1
- package/dist/core/poly.js +1 -5
- package/dist/core/poly.js.map +1 -1
- package/dist/core/site.d.ts +9 -0
- package/dist/core/site.d.ts.map +1 -1
- package/dist/core/site.js +8 -2
- package/dist/core/site.js.map +1 -1
- package/dist/core/tolerance.d.ts +1 -1
- package/dist/core/tolerance.js +2 -2
- package/dist/core/tolerance.js.map +1 -1
- package/dist/core/vertical.d.ts +9 -2
- package/dist/core/vertical.d.ts.map +1 -1
- package/dist/core/vertical.js +8 -1
- package/dist/core/vertical.js.map +1 -1
- package/dist/core/vocabulary.d.ts.map +1 -1
- package/dist/core/vocabulary.js +17 -5
- package/dist/core/vocabulary.js.map +1 -1
- package/dist/diagnostics.d.ts +2 -0
- package/dist/diagnostics.d.ts.map +1 -0
- package/dist/diagnostics.js +3 -0
- package/dist/diagnostics.js.map +1 -0
- package/dist/diff.d.ts +2 -0
- package/dist/diff.d.ts.map +1 -0
- package/dist/diff.js +3 -0
- package/dist/diff.js.map +1 -0
- package/dist/draw/index.js +1 -1
- package/dist/draw/index.js.map +1 -1
- package/dist/draw/plan.js +5 -5
- package/dist/draw/plan.js.map +1 -1
- package/dist/form.d.ts +5 -0
- package/dist/form.d.ts.map +1 -0
- package/dist/form.js +4 -0
- package/dist/form.js.map +1 -0
- package/dist/graph.d.ts +2 -0
- package/dist/graph.d.ts.map +1 -0
- package/dist/graph.js +3 -0
- package/dist/graph.js.map +1 -0
- package/dist/index.d.ts +2 -14
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +36 -45
- package/dist/index.js.map +1 -1
- package/dist/mcp.js +81 -30
- package/dist/mcp.js.map +1 -1
- package/dist/model.d.ts +3 -0
- package/dist/model.d.ts.map +1 -0
- package/dist/model.js +3 -0
- package/dist/model.js.map +1 -0
- package/dist/parse-file.d.ts.map +1 -1
- package/dist/parse-file.js +18 -3
- package/dist/parse-file.js.map +1 -1
- package/dist/validate/assessment.d.ts +8 -0
- package/dist/validate/assessment.d.ts.map +1 -0
- package/dist/validate/assessment.js +1738 -0
- package/dist/validate/assessment.js.map +1 -0
- package/dist/validate/builtin/access.d.ts +55 -0
- package/dist/validate/builtin/access.d.ts.map +1 -0
- package/dist/validate/builtin/access.js +494 -0
- package/dist/validate/builtin/access.js.map +1 -0
- package/dist/validate/builtin/daylight.d.ts +44 -0
- package/dist/validate/builtin/daylight.d.ts.map +1 -0
- package/dist/validate/builtin/daylight.js +233 -0
- package/dist/validate/builtin/daylight.js.map +1 -0
- package/dist/validate/builtin/door-column-collisions.d.ts +47 -0
- package/dist/validate/builtin/door-column-collisions.d.ts.map +1 -0
- package/dist/validate/builtin/door-column-collisions.js +189 -0
- package/dist/validate/builtin/door-column-collisions.js.map +1 -0
- package/dist/validate/builtin/envelope.d.ts +30 -0
- package/dist/validate/builtin/envelope.d.ts.map +1 -0
- package/dist/validate/builtin/envelope.js +169 -0
- package/dist/validate/builtin/envelope.js.map +1 -0
- package/dist/validate/builtin/freeze.d.ts +3 -0
- package/dist/validate/builtin/freeze.d.ts.map +1 -0
- package/dist/validate/builtin/freeze.js +21 -0
- package/dist/validate/builtin/freeze.js.map +1 -0
- package/dist/validate/builtin/index.d.ts +38 -0
- package/dist/validate/builtin/index.d.ts.map +1 -0
- package/dist/validate/builtin/index.js +106 -0
- package/dist/validate/builtin/index.js.map +1 -0
- package/dist/validate/builtin/site.d.ts +62 -0
- package/dist/validate/builtin/site.d.ts.map +1 -0
- package/dist/validate/builtin/site.js +333 -0
- package/dist/validate/builtin/site.js.map +1 -0
- package/dist/validate/builtin/vertical-runs.d.ts +53 -0
- package/dist/validate/builtin/vertical-runs.d.ts.map +1 -0
- package/dist/validate/builtin/vertical-runs.js +290 -0
- package/dist/validate/builtin/vertical-runs.js.map +1 -0
- package/dist/validate/contracts.d.ts +188 -0
- package/dist/validate/contracts.d.ts.map +1 -0
- package/dist/validate/contracts.js +28 -0
- package/dist/validate/contracts.js.map +1 -0
- package/dist/validate/index.d.ts +2 -59
- package/dist/validate/index.d.ts.map +1 -1
- package/dist/validate/index.js +22 -70
- package/dist/validate/index.js.map +1 -1
- package/dist/vocabulary.d.ts +2 -0
- package/dist/vocabulary.d.ts.map +1 -0
- package/dist/vocabulary.js +3 -0
- package/dist/vocabulary.js.map +1 -0
- package/editors/vscode/syntaxes/koyu.tmLanguage.json +2 -2
- package/examples/basement/main.muro +3 -3
- package/examples/complex/main.muro +1 -1
- package/examples/complex/podium.muro +1 -1
- package/examples/complex/site.muro +6 -6
- package/examples/house/L2.muro +1 -1
- package/examples/house/main.muro +1 -1
- package/examples/house/site.muro +4 -4
- package/examples/house.muro +6 -6
- package/examples/mansion.muro +2 -2
- package/examples/office.muro +3 -3
- package/examples/steps/04-exterior.muro +1 -1
- package/examples/steps/05-two-storeys.muro +1 -1
- package/examples/steps/06-finished.muro +2 -2
- package/examples/tower/L2.muro +1 -1
- package/examples/tower/main.muro +1 -1
- package/examples/tower/site.muro +4 -4
- package/examples/twin/main.muro +1 -1
- package/examples/twin/podium.muro +4 -4
- package/examples/twin/site.muro +8 -8
- package/examples/two-rooms.canonical.json +4 -4
- package/examples/two-rooms.muro +2 -2
- package/package.json +41 -9
- package/src/analysis/contracts.ts +234 -0
- package/src/analysis/index.ts +61 -0
- package/src/analysis/json.ts +117 -0
- package/src/cli.ts +116 -36
- package/src/core/derive.ts +32 -15
- package/src/core/diagnose.ts +63 -16
- package/src/core/diff.ts +10 -6
- package/src/core/fabric.ts +18 -9
- package/src/core/graph.ts +19 -5
- package/src/core/light.ts +2 -2
- package/src/core/model.ts +141 -31
- package/src/core/parse.ts +100 -85
- package/src/core/poly.ts +1 -8
- package/src/core/site.ts +19 -2
- package/src/core/tolerance.ts +2 -2
- package/src/core/vertical.ts +10 -3
- package/src/core/vocabulary.ts +18 -5
- package/src/diagnostics.ts +8 -0
- package/src/diff.ts +14 -0
- package/src/draw/index.ts +1 -1
- package/src/draw/plan.ts +5 -5
- package/src/form.ts +37 -0
- package/src/graph.ts +12 -0
- package/src/index.ts +40 -175
- package/src/mcp.ts +85 -35
- package/src/model.ts +43 -0
- package/src/parse-file.ts +17 -3
- package/src/validate/assessment.ts +1934 -0
- package/src/validate/builtin/access.ts +642 -0
- package/src/validate/builtin/daylight.ts +321 -0
- package/src/validate/builtin/door-column-collisions.ts +266 -0
- package/src/validate/builtin/envelope.ts +227 -0
- package/src/validate/builtin/freeze.ts +19 -0
- package/src/validate/builtin/index.ts +156 -0
- package/src/validate/builtin/site.ts +445 -0
- package/src/validate/builtin/vertical-runs.ts +390 -0
- package/src/validate/contracts.ts +240 -0
- package/src/validate/index.ts +45 -99
- package/src/vocabulary.ts +9 -0
- package/dist/validate/access.d.ts +0 -6
- package/dist/validate/access.d.ts.map +0 -1
- package/dist/validate/access.js +0 -238
- package/dist/validate/access.js.map +0 -1
- package/dist/validate/envelope.d.ts +0 -4
- package/dist/validate/envelope.d.ts.map +0 -1
- package/dist/validate/envelope.js +0 -55
- package/dist/validate/envelope.js.map +0 -1
- package/dist/validate/light.d.ts +0 -6
- package/dist/validate/light.d.ts.map +0 -1
- package/dist/validate/light.js +0 -28
- package/dist/validate/light.js.map +0 -1
- package/dist/validate/runs.d.ts +0 -16
- package/dist/validate/runs.d.ts.map +0 -1
- package/dist/validate/runs.js +0 -60
- package/dist/validate/runs.js.map +0 -1
- package/dist/validate/site.d.ts +0 -6
- package/dist/validate/site.d.ts.map +0 -1
- package/dist/validate/site.js +0 -63
- package/dist/validate/site.js.map +0 -1
- package/spec/README.md +0 -28
- package/spec/canonical-json.md +0 -98
- package/spec/composition.md +0 -121
- package/spec/derivation.md +0 -393
- package/spec/en/README.md +0 -30
- package/spec/en/canonical-json.md +0 -101
- package/spec/en/composition.md +0 -121
- package/spec/en/derivation.md +0 -393
- package/spec/en/language.md +0 -164
- package/spec/en/notation-v0.md +0 -145
- package/spec/en/scope.md +0 -229
- package/spec/en/semantics.md +0 -132
- package/spec/en/tools.md +0 -108
- package/spec/en/validation.md +0 -79
- package/spec/en/vocabulary.md +0 -103
- package/spec/language.md +0 -163
- package/spec/notation-v0.md +0 -184
- package/spec/scope.md +0 -229
- package/spec/semantics.md +0 -130
- package/spec/tools.md +0 -106
- package/spec/validation.md +0 -79
- package/spec/vocabulary.md +0 -114
- package/src/validate/access.ts +0 -279
- package/src/validate/envelope.ts +0 -59
- package/src/validate/light.ts +0 -43
- package/src/validate/runs.ts +0 -87
- package/src/validate/site.ts +0 -84
package/src/mcp.ts
CHANGED
|
@@ -8,26 +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,
|
|
25
|
+
isOutside,
|
|
19
26
|
isSemiOutdoor,
|
|
27
|
+
isVoid,
|
|
20
28
|
levelsSorted,
|
|
21
29
|
newUids,
|
|
22
|
-
polygonAreaM2,
|
|
23
30
|
toCanonical,
|
|
24
31
|
zoneAreaM2,
|
|
25
32
|
type Model,
|
|
26
33
|
type Space,
|
|
27
|
-
} from "./
|
|
28
|
-
import { check, checkDiagnostics } from "./core/diagnose.js";
|
|
29
|
-
import { svgPlan } from "./draw/plan.js";
|
|
30
|
-
import { siteReport } from "./core/site.js";
|
|
34
|
+
} from "./model.js";
|
|
31
35
|
import { parseFile, parseFileWith } from "./parse-file.js";
|
|
32
36
|
|
|
33
37
|
// ---- モデルの読み込みと要約 ----
|
|
@@ -36,9 +40,30 @@ function load(file: string): Model {
|
|
|
36
40
|
return parseFile(resolve(file));
|
|
37
41
|
}
|
|
38
42
|
|
|
39
|
-
/**
|
|
40
|
-
|
|
41
|
-
|
|
43
|
+
/**
|
|
44
|
+
* Every layer that took part in the composition — the Model records them all, whether or not
|
|
45
|
+
* they carry elements (a layer holding only `grid`/`level` is not dropped).
|
|
46
|
+
*
|
|
47
|
+
* The entry is always index 0 (`ingestLayer` pushes every layer). **Do not add the spelled
|
|
48
|
+
* `resolve(entry)`** — layer identity is filesystem identity, so adding a different spelling
|
|
49
|
+
* (a symlink, another letter case) counts one layer twice.
|
|
50
|
+
*
|
|
51
|
+
* **The order is strength order, which is what `model.layers` already is** — never sorted. The
|
|
52
|
+
* tool says "in strength order" and `koyu layers` prints the same order; sorting by path here made
|
|
53
|
+
* the two disagree about the same question, and strength is the answer an agent needs (it decides
|
|
54
|
+
* which layer's opinion wins).
|
|
55
|
+
*/
|
|
56
|
+
function layerFiles(model: Model): string[] {
|
|
57
|
+
return [...model.layers];
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
/** A path as the filesystem sees it; the spelling if it cannot be resolved — the same rule as layer identity (`parse-file.ts`) */
|
|
61
|
+
function real(path: string): string {
|
|
62
|
+
try {
|
|
63
|
+
return realpathSync.native(path);
|
|
64
|
+
} catch {
|
|
65
|
+
return path;
|
|
66
|
+
}
|
|
42
67
|
}
|
|
43
68
|
|
|
44
69
|
/** entryディレクトリ境界の検査 — 文字列prefixではなく相対パスで判定する (ADR-0013) */
|
|
@@ -52,7 +77,7 @@ function assertInside(entryDir: string, targetDir: string): void {
|
|
|
52
77
|
function summarize(model: Model, file: string): unknown {
|
|
53
78
|
const rooms = [...model.spaces.values()].filter((s) => s.rects.length > 0 && s.level);
|
|
54
79
|
const indoor = rooms.filter((s) => isIndoor(model, s));
|
|
55
|
-
const semi = rooms.filter((s) => s
|
|
80
|
+
const semi = rooms.filter((s) => !isVoid(s) && isSemiOutdoor(model, s));
|
|
56
81
|
const byLevel: Record<string, { rooms: number; subtotalM2: number }> = {};
|
|
57
82
|
for (const lv of levelsSorted(model)) {
|
|
58
83
|
const rs = indoor.filter((s) => s.level === lv.name);
|
|
@@ -71,7 +96,7 @@ function summarize(model: Model, file: string): unknown {
|
|
|
71
96
|
return {
|
|
72
97
|
name: model.name,
|
|
73
98
|
unit: model.unit,
|
|
74
|
-
layers: layerFiles(model
|
|
99
|
+
layers: layerFiles(model),
|
|
75
100
|
levels: levelsSorted(model).map((l) => ({
|
|
76
101
|
name: l.name,
|
|
77
102
|
z: l.z,
|
|
@@ -108,10 +133,15 @@ function summarize(model: Model, file: string): unknown {
|
|
|
108
133
|
function spaceInfo(model: Model, s: Space): unknown {
|
|
109
134
|
return {
|
|
110
135
|
path: s.path,
|
|
111
|
-
|
|
136
|
+
// 型は任意の自由なラベルなので、書かれていなければ鍵ごと出ない。
|
|
137
|
+
// **構成の事実はこの語ではなく下の二つが答える** — 型が無い空間について
|
|
138
|
+
// 「外部か」「吹抜けか」を消費側が推測できてしまうと、廃止した推定が戻る
|
|
139
|
+
...(s.type !== undefined ? { type: s.type } : {}),
|
|
112
140
|
name: displayName(s),
|
|
113
141
|
level: s.level,
|
|
114
142
|
areaM2: areaM2(s),
|
|
143
|
+
...(isOutside(s) ? { outside: true } : {}),
|
|
144
|
+
...(isVoid(s) ? { void: true } : {}),
|
|
115
145
|
semiOutdoor: isSemiOutdoor(model, s),
|
|
116
146
|
...(s.file ? { layer: s.file } : {}),
|
|
117
147
|
};
|
|
@@ -155,7 +185,9 @@ const TOOLS: Record<string, Tool> = {
|
|
|
155
185
|
spaces: m.spaces.size,
|
|
156
186
|
boundaries: m.boundaries.length,
|
|
157
187
|
...r,
|
|
158
|
-
// 構造化診断 (ADR-0016) — errors
|
|
188
|
+
// 構造化診断 (ADR-0016) — errors と warnings を足したものと同件。並びは走査の順で、
|
|
189
|
+
// errors/warnings はそれを severity で二本に割ったものなので、連結して添字で対応させてはならない。
|
|
190
|
+
// code/severity/path/relatedつき
|
|
159
191
|
diagnostics: checkDiagnostics(m),
|
|
160
192
|
};
|
|
161
193
|
},
|
|
@@ -166,7 +198,7 @@ const TOOLS: Record<string, Tool> = {
|
|
|
166
198
|
run: (a) => {
|
|
167
199
|
const file = str(a.file, "file");
|
|
168
200
|
const m = load(file);
|
|
169
|
-
return layerFiles(m
|
|
201
|
+
return layerFiles(m).map((f) => ({ file: f, source: readFileSync(f, "utf8") }));
|
|
170
202
|
},
|
|
171
203
|
},
|
|
172
204
|
write_layer: {
|
|
@@ -184,10 +216,13 @@ const TOOLS: Record<string, Tool> = {
|
|
|
184
216
|
run: (a) => {
|
|
185
217
|
const file = str(a.file, "file");
|
|
186
218
|
const content = str(a.content, "content");
|
|
187
|
-
|
|
219
|
+
// Resolve to the real path: it stops a spelling that goes through a symlink from slipping
|
|
220
|
+
// past the boundary check, and it matches the identity the composition counts layers by
|
|
221
|
+
// (mismatch would make the gatekeeper validate stale content)
|
|
222
|
+
const entryDir = real(resolve(dirname(resolve(file))));
|
|
188
223
|
const target = resolve(entryDir, str(a.layer, "layer"));
|
|
189
224
|
if (!target.endsWith(".muro")) throw new Error("Only .muro files can be written");
|
|
190
|
-
assertInside(entryDir, dirname(target));
|
|
225
|
+
assertInside(entryDir, real(dirname(target)));
|
|
191
226
|
// 門番は書き込みの前 — 差し替え内容で仮想合成し、parse不能なら原本に触れない (ADR-0013)。
|
|
192
227
|
// 合成に参加しないファイルの内容は検証されない (importされた時のcheckが捕まえる)
|
|
193
228
|
let m: Model;
|
|
@@ -279,37 +314,52 @@ const TOOLS: Record<string, Tool> = {
|
|
|
279
314
|
},
|
|
280
315
|
validate: {
|
|
281
316
|
description:
|
|
282
|
-
"Architectural verdicts: daylight, envelope continuity, stair proportions, slopes, reachability, column/door collisions, and the site.
|
|
283
|
-
schema: {
|
|
317
|
+
"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",
|
|
318
|
+
schema: {
|
|
319
|
+
type: "object",
|
|
320
|
+
properties: {
|
|
321
|
+
...FILE_PROP,
|
|
322
|
+
profile: {
|
|
323
|
+
type: "string",
|
|
324
|
+
description: `Rule profile id. koyu ships one: ${SCHEMATIC_PROFILE_ID.id}`,
|
|
325
|
+
},
|
|
326
|
+
asOf: {
|
|
327
|
+
type: "string",
|
|
328
|
+
description: "Effective date as YYYY-MM-DD. Not read from the clock, so the same input judges the same way twice",
|
|
329
|
+
},
|
|
330
|
+
},
|
|
331
|
+
required: ["file", "profile", "asOf"],
|
|
332
|
+
},
|
|
284
333
|
run: (a) => {
|
|
285
334
|
const m = load(str(a.file, "file"));
|
|
286
|
-
const
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
335
|
+
const profile = str(a.profile, "profile");
|
|
336
|
+
if (profile !== SCHEMATIC_PROFILE_ID.id) {
|
|
337
|
+
throw new Error(`Unknown profile: ${profile} (koyu ships one: ${SCHEMATIC_PROFILE_ID.id})`);
|
|
338
|
+
}
|
|
339
|
+
return assess(m, {
|
|
340
|
+
registry: createSchematicRegistry(),
|
|
341
|
+
profile: SCHEMATIC_PROFILE_ID,
|
|
342
|
+
context: { schema: "koyu-context/1", asOf: str(a.asOf, "asOf"), values: {} },
|
|
343
|
+
});
|
|
293
344
|
},
|
|
294
345
|
},
|
|
295
346
|
site: {
|
|
296
|
-
description:
|
|
347
|
+
description:
|
|
348
|
+
"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",
|
|
297
349
|
schema: { type: "object", properties: FILE_PROP, required: ["file"] },
|
|
298
350
|
run: (a) => {
|
|
351
|
+
// The ratios and their rounding belong to core, which is also what the site rules read.
|
|
352
|
+
// Dividing here again is how an adapter and a rule drift apart.
|
|
299
353
|
const r = siteReport(load(str(a.file, "file")));
|
|
300
|
-
const site = r.declaredArea ?? r.derivedArea;
|
|
301
354
|
return {
|
|
302
355
|
...(r.siteZone ? { siteZone: r.siteZone.path } : {}),
|
|
303
356
|
...(r.polygon ? { polygonVertices: r.polygon.points.length } : {}),
|
|
304
357
|
declaredAreaM2: r.declaredArea,
|
|
305
358
|
derivedAreaM2: r.derivedArea,
|
|
306
|
-
...(r.declaredArea !== undefined && r.derivedArea !== undefined
|
|
307
|
-
? { areaMatch: Math.abs(r.declaredArea - r.derivedArea) < 0.05 }
|
|
308
|
-
: {}),
|
|
309
359
|
footprintM2: r.footprint,
|
|
310
360
|
totalFloorM2: r.totalFloor,
|
|
311
|
-
coverageRatio:
|
|
312
|
-
floorAreaRatio:
|
|
361
|
+
coverageRatio: r.coveragePercent,
|
|
362
|
+
floorAreaRatio: r.floorAreaRatioPercent,
|
|
313
363
|
roads: r.roads.map((rd) => ({
|
|
314
364
|
path: rd.road.path,
|
|
315
365
|
name: displayName(rd.road),
|
|
@@ -365,7 +415,7 @@ function handle(msg: Json): void {
|
|
|
365
415
|
result(id, {
|
|
366
416
|
protocolVersion: (params.protocolVersion as string) ?? "2025-06-18",
|
|
367
417
|
capabilities: { tools: {} },
|
|
368
|
-
serverInfo: { name: "koyu", version: "0.
|
|
418
|
+
serverInfo: { name: "koyu", version: "0.18.0" },
|
|
369
419
|
instructions:
|
|
370
420
|
"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.",
|
|
371
421
|
});
|
package/src/model.ts
ADDED
|
@@ -0,0 +1,43 @@
|
|
|
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
|
+
Boundary,
|
|
9
|
+
BoundaryKind,
|
|
10
|
+
Column,
|
|
11
|
+
ColumnDecl,
|
|
12
|
+
DrawnLine,
|
|
13
|
+
Edge,
|
|
14
|
+
GridAxis,
|
|
15
|
+
GridRef,
|
|
16
|
+
Level,
|
|
17
|
+
Model,
|
|
18
|
+
Opening,
|
|
19
|
+
Pt,
|
|
20
|
+
Rect,
|
|
21
|
+
Seg,
|
|
22
|
+
SitePolygon,
|
|
23
|
+
Space,
|
|
24
|
+
Zone,
|
|
25
|
+
} from "./core/model.js";
|
|
26
|
+
|
|
27
|
+
export {
|
|
28
|
+
areaM2,
|
|
29
|
+
DEFAULT_LANGUAGE_VERSION,
|
|
30
|
+
displayName,
|
|
31
|
+
effectiveUse,
|
|
32
|
+
heff,
|
|
33
|
+
isCoveredAbove,
|
|
34
|
+
isIndoor,
|
|
35
|
+
isOutside,
|
|
36
|
+
isSemiOutdoor,
|
|
37
|
+
isVoid,
|
|
38
|
+
levelsSorted,
|
|
39
|
+
newUids,
|
|
40
|
+
SUPPORTED_LANGUAGE_VERSIONS,
|
|
41
|
+
toCanonical,
|
|
42
|
+
zoneAreaM2,
|
|
43
|
+
} from "./core/model.js";
|
package/src/parse-file.ts
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
// パーサ本体 (parse.ts) は純粋で、fsはこの薄い層だけが知る。
|
|
3
3
|
// ブラウザ (ugatsu等) は parseFiles (仮想ファイル群) を使う。
|
|
4
4
|
|
|
5
|
-
import { readFileSync } from "node:fs";
|
|
5
|
+
import { readFileSync, realpathSync } from "node:fs";
|
|
6
6
|
import { dirname, resolve } from "node:path";
|
|
7
7
|
import type { Model } from "./core/model.js";
|
|
8
8
|
import { parseWith } from "./core/parse.js";
|
|
@@ -21,8 +21,22 @@ export function parseFileWith(
|
|
|
21
21
|
overlay?: (absPath: string) => string | undefined,
|
|
22
22
|
): Model {
|
|
23
23
|
return parseWith((from, ref) => {
|
|
24
|
-
const
|
|
25
|
-
|
|
24
|
+
const spelled = from === undefined ? resolve(ref) : resolve(dirname(from), ref);
|
|
25
|
+
// **Layer identity is filesystem identity, not spelling.** Deciding it by spelling composes
|
|
26
|
+
// one file twice when it arrives through a symlink or in different letter case, breaking the
|
|
27
|
+
// promise that a layer imported twice is still composed once (rule 1) — in practice it failed
|
|
28
|
+
// with `grid X is declared once`. A path that does not exist yet (the overlay holds its
|
|
29
|
+
// content) has no realpath, so the spelling stands as its identity.
|
|
30
|
+
// `.native` asks the OS: on a case-insensitive filesystem (the macOS default) the JS
|
|
31
|
+
// implementation returns the spelling as given, so `B.muro` and `b.muro` become two layers
|
|
32
|
+
let key = spelled;
|
|
33
|
+
try {
|
|
34
|
+
key = realpathSync.native(spelled);
|
|
35
|
+
} catch {
|
|
36
|
+
/* not on disk yet — the spelling is the identity */
|
|
37
|
+
}
|
|
38
|
+
// The overlay answers to either spelling — the MCP gatekeeper matches on the resolved one
|
|
39
|
+
const src = overlay?.(spelled) ?? overlay?.(key) ?? readFileSync(key, "utf8");
|
|
26
40
|
return { key, src };
|
|
27
41
|
}, filePath);
|
|
28
42
|
}
|