@kensnzk/koyu 0.15.0 → 0.16.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 +2 -2
- package/README.md +3 -3
- package/dist/cli.js +156 -81
- package/dist/cli.js.map +1 -1
- package/dist/core/derive.d.ts +259 -0
- package/dist/core/derive.d.ts.map +1 -0
- package/dist/core/derive.js +570 -0
- package/dist/core/derive.js.map +1 -0
- package/dist/{check.d.ts → core/diagnose.d.ts} +11 -12
- package/dist/core/diagnose.d.ts.map +1 -0
- package/dist/{check.js → core/diagnose.js} +232 -221
- package/dist/core/diagnose.js.map +1 -0
- package/dist/core/diff.d.ts.map +1 -0
- package/dist/{diff.js → core/diff.js} +84 -41
- package/dist/core/diff.js.map +1 -0
- package/dist/{fabric.d.ts → core/fabric.d.ts} +4 -0
- package/dist/core/fabric.d.ts.map +1 -0
- package/dist/{fabric.js → core/fabric.js} +4 -3
- package/dist/core/fabric.js.map +1 -0
- package/dist/{graph.d.ts → core/graph.d.ts} +1 -3
- package/dist/core/graph.d.ts.map +1 -0
- package/dist/{graph.js → core/graph.js} +43 -51
- package/dist/core/graph.js.map +1 -0
- package/dist/core/light.d.ts +24 -0
- package/dist/core/light.d.ts.map +1 -0
- package/dist/{light.js → core/light.js} +15 -10
- package/dist/core/light.js.map +1 -0
- package/dist/{model.d.ts → core/model.d.ts} +124 -13
- package/dist/core/model.d.ts.map +1 -0
- package/dist/{model.js → core/model.js} +186 -49
- package/dist/core/model.js.map +1 -0
- package/dist/core/parse.d.ts.map +1 -0
- package/dist/{parse.js → core/parse.js} +528 -116
- package/dist/core/parse.js.map +1 -0
- package/dist/{poly.d.ts → core/poly.d.ts} +3 -2
- package/dist/core/poly.d.ts.map +1 -0
- package/dist/{poly.js → core/poly.js} +8 -9
- package/dist/core/poly.js.map +1 -0
- package/dist/core/site.d.ts.map +1 -0
- package/dist/core/site.js.map +1 -0
- package/dist/core/tolerance.d.ts +26 -0
- package/dist/core/tolerance.d.ts.map +1 -0
- package/dist/core/tolerance.js +48 -0
- package/dist/core/tolerance.js.map +1 -0
- package/dist/{vertical.d.ts → core/vertical.d.ts} +41 -12
- package/dist/core/vertical.d.ts.map +1 -0
- package/dist/{vertical.js → core/vertical.js} +45 -104
- package/dist/core/vertical.js.map +1 -0
- package/dist/core/vocabulary.d.ts +40 -0
- package/dist/core/vocabulary.d.ts.map +1 -0
- package/dist/core/vocabulary.js +164 -0
- package/dist/core/vocabulary.js.map +1 -0
- package/dist/{axo.d.ts → draw/axo.d.ts} +1 -1
- package/dist/draw/axo.d.ts.map +1 -0
- package/dist/{axo.js → draw/axo.js} +53 -81
- package/dist/draw/axo.js.map +1 -0
- package/dist/draw/index.d.ts +3 -0
- package/dist/draw/index.d.ts.map +1 -0
- package/dist/draw/index.js +11 -0
- package/dist/draw/index.js.map +1 -0
- package/dist/draw/plan.d.ts +10 -0
- package/dist/draw/plan.d.ts.map +1 -0
- package/dist/draw/plan.js +284 -0
- package/dist/draw/plan.js.map +1 -0
- package/dist/index.d.ts +15 -11
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +49 -12
- package/dist/index.js.map +1 -1
- package/dist/mcp.js +71 -40
- package/dist/mcp.js.map +1 -1
- package/dist/parse-file.d.ts +1 -1
- package/dist/parse-file.d.ts.map +1 -1
- package/dist/parse-file.js +1 -1
- package/dist/parse-file.js.map +1 -1
- package/dist/validate/access.d.ts +6 -0
- package/dist/validate/access.d.ts.map +1 -0
- package/dist/validate/access.js +238 -0
- package/dist/validate/access.js.map +1 -0
- package/dist/validate/envelope.d.ts +4 -0
- package/dist/validate/envelope.d.ts.map +1 -0
- package/dist/validate/envelope.js +55 -0
- package/dist/validate/envelope.js.map +1 -0
- package/dist/validate/index.d.ts +60 -0
- package/dist/validate/index.d.ts.map +1 -0
- package/dist/validate/index.js +77 -0
- package/dist/validate/index.js.map +1 -0
- package/dist/validate/light.d.ts +6 -0
- package/dist/validate/light.d.ts.map +1 -0
- package/dist/validate/light.js +28 -0
- package/dist/validate/light.js.map +1 -0
- package/dist/validate/runs.d.ts +16 -0
- package/dist/validate/runs.d.ts.map +1 -0
- package/dist/validate/runs.js +60 -0
- package/dist/validate/runs.js.map +1 -0
- package/dist/validate/site.d.ts +6 -0
- package/dist/validate/site.d.ts.map +1 -0
- package/dist/validate/site.js +63 -0
- package/dist/validate/site.js.map +1 -0
- package/editors/vscode/.vscodeignore +2 -0
- package/editors/vscode/README.md +28 -0
- package/editors/vscode/extension.js +150 -0
- package/editors/vscode/language-configuration.json +19 -0
- package/editors/vscode/package.json +57 -0
- package/editors/vscode/syntaxes/koyu.tmLanguage.json +226 -0
- package/examples/basement/main.muro +1 -1
- package/examples/complex/main.muro +1 -1
- package/examples/house/main.muro +2 -2
- package/examples/house.muro +2 -2
- package/examples/mansion.muro +2 -2
- package/examples/office.muro +2 -2
- package/examples/steps/01-one-room.muro +1 -1
- package/examples/steps/02-two-rooms.muro +1 -1
- package/examples/steps/03-door.muro +1 -1
- 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/main.muro +1 -1
- package/examples/twin/main.muro +2 -2
- package/examples/two-rooms.canonical.json +4 -2
- package/examples/two-rooms.muro +2 -2
- package/package.json +16 -1
- package/spec/README.md +28 -0
- package/spec/canonical-json.md +98 -0
- package/spec/composition.md +121 -0
- package/spec/derivation.md +393 -0
- package/spec/en/README.md +30 -0
- package/spec/en/canonical-json.md +101 -0
- package/spec/en/composition.md +121 -0
- package/spec/en/derivation.md +393 -0
- package/spec/en/language.md +164 -0
- package/spec/en/notation-v0.md +145 -0
- package/spec/en/scope.md +229 -0
- package/spec/en/semantics.md +132 -0
- package/spec/en/tools.md +108 -0
- package/spec/en/validation.md +79 -0
- package/spec/en/vocabulary.md +103 -0
- package/spec/language.md +163 -0
- package/spec/notation-v0.md +184 -0
- package/spec/scope.md +229 -0
- package/spec/semantics.md +130 -0
- package/spec/tools.md +106 -0
- package/spec/validation.md +79 -0
- package/spec/vocabulary.md +114 -0
- package/src/cli.ts +165 -80
- package/src/core/derive.ts +852 -0
- package/src/{check.ts → core/diagnose.ts} +260 -229
- package/src/{diff.ts → core/diff.ts} +84 -40
- package/src/{fabric.ts → core/fabric.ts} +4 -3
- package/src/{graph.ts → core/graph.ts} +47 -60
- package/src/core/light.ts +69 -0
- package/src/{model.ts → core/model.ts} +228 -51
- package/src/{parse.ts → core/parse.ts} +584 -116
- package/src/{poly.ts → core/poly.ts} +8 -9
- package/src/core/tolerance.ts +55 -0
- package/src/{vertical.ts → core/vertical.ts} +65 -115
- package/src/core/vocabulary.ts +197 -0
- package/src/{axo.ts → draw/axo.ts} +51 -94
- package/src/draw/index.ts +11 -0
- package/src/draw/plan.ts +344 -0
- package/src/index.ts +181 -35
- package/src/mcp.ts +76 -40
- package/src/parse-file.ts +2 -2
- package/src/validate/access.ts +279 -0
- package/src/validate/envelope.ts +59 -0
- package/src/validate/index.ts +107 -0
- package/src/validate/light.ts +43 -0
- package/src/validate/runs.ts +87 -0
- package/src/validate/site.ts +84 -0
- package/dist/axo.d.ts.map +0 -1
- package/dist/axo.js.map +0 -1
- package/dist/check.d.ts.map +0 -1
- package/dist/check.js.map +0 -1
- package/dist/diff.d.ts.map +0 -1
- package/dist/diff.js.map +0 -1
- package/dist/fabric.d.ts.map +0 -1
- package/dist/fabric.js.map +0 -1
- package/dist/graph.d.ts.map +0 -1
- package/dist/graph.js.map +0 -1
- package/dist/light.d.ts +0 -15
- package/dist/light.d.ts.map +0 -1
- package/dist/light.js.map +0 -1
- package/dist/model.d.ts.map +0 -1
- package/dist/model.js.map +0 -1
- package/dist/parse.d.ts.map +0 -1
- package/dist/parse.js.map +0 -1
- package/dist/plan.d.ts +0 -10
- package/dist/plan.d.ts.map +0 -1
- package/dist/plan.js +0 -354
- package/dist/plan.js.map +0 -1
- package/dist/poly.d.ts.map +0 -1
- package/dist/poly.js.map +0 -1
- package/dist/site.d.ts.map +0 -1
- package/dist/site.js.map +0 -1
- package/dist/vertical.d.ts.map +0 -1
- package/dist/vertical.js.map +0 -1
- package/src/light.ts +0 -63
- package/src/plan.ts +0 -472
- /package/dist/{diff.d.ts → core/diff.d.ts} +0 -0
- /package/dist/{parse.d.ts → core/parse.d.ts} +0 -0
- /package/dist/{site.d.ts → core/site.d.ts} +0 -0
- /package/dist/{site.js → core/site.js} +0 -0
- /package/src/{site.ts → core/site.ts} +0 -0
package/src/cli.ts
CHANGED
|
@@ -8,14 +8,18 @@
|
|
|
8
8
|
// npm run koyu -- stats examples/office.muro
|
|
9
9
|
// npm run koyu -- levels examples/office.muro # テキストの矩計 (高さの積み上がり)
|
|
10
10
|
// npm run koyu -- json examples/office.muro
|
|
11
|
+
//
|
|
12
|
+
// **人向けの出力は英語である。**機械が読む面 (診断・Finding・MCP) と同じ言葉に揃えてあり、
|
|
13
|
+
// locale 引数は持たない — 同じ文言の台帳を二つ持たないためである。
|
|
11
14
|
|
|
12
15
|
import { mkdirSync, writeFileSync } from "node:fs";
|
|
13
16
|
import { dirname } from "node:path";
|
|
14
|
-
import { check, checkDiagnostics, type Diagnostic } from "./
|
|
15
|
-
import { renderDiff, semanticDiff } from "./diff.js";
|
|
16
|
-
import { doorsBetween, neighbors } from "./graph.js";
|
|
17
|
-
import {
|
|
18
|
-
import {
|
|
17
|
+
import { check, checkDiagnostics, type Diagnostic } from "./core/diagnose.js";
|
|
18
|
+
import { renderDiff, semanticDiff } from "./core/diff.js";
|
|
19
|
+
import { doorsBetween, neighbors } from "./core/graph.js";
|
|
20
|
+
import { daylightInputs } from "./core/light.js";
|
|
21
|
+
import { validate, type Finding } from "./validate/index.js";
|
|
22
|
+
import { siteReport } from "./core/site.js";
|
|
19
23
|
import {
|
|
20
24
|
areaM2,
|
|
21
25
|
displayName,
|
|
@@ -27,16 +31,22 @@ import {
|
|
|
27
31
|
toCanonical,
|
|
28
32
|
zoneAreaM2,
|
|
29
33
|
type Model,
|
|
30
|
-
|
|
34
|
+
srcRef,
|
|
35
|
+
} from "./core/model.js";
|
|
31
36
|
import { parseFile } from "./parse-file.js";
|
|
32
|
-
import { svgPlan } from "./plan.js";
|
|
33
|
-
import { svgAxo } from "./axo.js";
|
|
34
|
-
import { slopeText, verticalRuns } from "./vertical.js";
|
|
37
|
+
import { svgPlan } from "./draw/plan.js";
|
|
38
|
+
import { svgAxo } from "./draw/axo.js";
|
|
39
|
+
import { slopeText, verticalRuns } from "./core/vertical.js";
|
|
35
40
|
|
|
36
41
|
function load(file: string): Model {
|
|
37
42
|
return parseFile(file); // import による合成もここで働く
|
|
38
43
|
}
|
|
39
44
|
|
|
45
|
+
/** 数と名詞 — 英語は数が先に立ち、1のときだけ単数形になる */
|
|
46
|
+
function qty(count: number, one: string, many: string): string {
|
|
47
|
+
return `${count} ${count === 1 ? one : many}`;
|
|
48
|
+
}
|
|
49
|
+
|
|
40
50
|
/** `-l L1..L5` / `-l L1,L3` をレベル名の列へ */
|
|
41
51
|
/**
|
|
42
52
|
* `-l` の解決。**解決できない指定は空配列に落とさない** — 空配列は「一枚も描かない」を
|
|
@@ -50,19 +60,19 @@ function expandLevelArg(model: Model, arg: string): string[] {
|
|
|
50
60
|
if (!m) {
|
|
51
61
|
const names = arg.split(",");
|
|
52
62
|
const unknown = names.filter((n) => !all.includes(n));
|
|
53
|
-
if (unknown.length > 0) die(
|
|
63
|
+
if (unknown.length > 0) die(`Undeclared level: ${unknown.join(",")} (declared: ${all.join(" ")})`);
|
|
54
64
|
return names;
|
|
55
65
|
}
|
|
56
66
|
const za = model.levels[m[1]!]?.z;
|
|
57
67
|
const zb = model.levels[m[2]!]?.z;
|
|
58
68
|
if (za === undefined || zb === undefined) {
|
|
59
69
|
const bad = [m[1]!, m[2]!].filter((n) => model.levels[n] === undefined);
|
|
60
|
-
die(
|
|
70
|
+
die(`Undeclared level: ${bad.join(",")} (declared: ${all.join(" ")})`);
|
|
61
71
|
}
|
|
62
72
|
const out = levelsSorted(model)
|
|
63
73
|
.filter((l) => l.z >= Math.min(za!, zb!) && l.z <= Math.max(za!, zb!))
|
|
64
74
|
.map((l) => l.name);
|
|
65
|
-
if (out.length === 0) die(
|
|
75
|
+
if (out.length === 0) die(`No level falls in the range ${arg}`);
|
|
66
76
|
return out;
|
|
67
77
|
}
|
|
68
78
|
|
|
@@ -80,13 +90,42 @@ function opt(rest: string[], ...names: string[]): string | undefined {
|
|
|
80
90
|
return undefined;
|
|
81
91
|
}
|
|
82
92
|
|
|
93
|
+
/**
|
|
94
|
+
* 数を取る引数。**読めない値を黙って NaN のまま通さない。**
|
|
95
|
+
* `-s abc` は `width="NaN"` のSVGを終了コード0で書き出していた — 生成に成功したと言いながら
|
|
96
|
+
* 開けない図を残すのは、呼び方の問題を作品の問題に化けさせる。呼び方の問題として返す (ADR-0028)
|
|
97
|
+
*/
|
|
98
|
+
function numOpt(rest: string[], ...names: string[]): number | undefined {
|
|
99
|
+
const raw = opt(rest, ...names);
|
|
100
|
+
if (raw === undefined) return undefined;
|
|
101
|
+
const v = Number(raw);
|
|
102
|
+
if (!Number.isFinite(v) || v <= 0) die(`${names[0]} takes a positive number: ${raw}`);
|
|
103
|
+
return v;
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
/** 語彙の決まった引数。台帳に無い値は呼び方の問題である */
|
|
107
|
+
function enumOpt<T extends string>(
|
|
108
|
+
rest: string[],
|
|
109
|
+
allowed: readonly T[],
|
|
110
|
+
...names: string[]
|
|
111
|
+
): T | undefined {
|
|
112
|
+
const raw = opt(rest, ...names);
|
|
113
|
+
if (raw === undefined) return undefined;
|
|
114
|
+
if (!(allowed as readonly string[]).includes(raw)) {
|
|
115
|
+
die(`${names[0]} is one of ${allowed.join(" / ")}: ${raw}`);
|
|
116
|
+
}
|
|
117
|
+
return raw as T;
|
|
118
|
+
}
|
|
119
|
+
|
|
83
120
|
function main(argv: string[]): number {
|
|
84
121
|
const [cmd, file, ...rest] = argv;
|
|
85
122
|
if (!cmd || !file) {
|
|
86
123
|
console.log(
|
|
87
|
-
"
|
|
88
|
-
" check:
|
|
89
|
-
"
|
|
124
|
+
"Usage: koyu <check|validate|layers|diff|plan|axo|doors|graph|stats|levels|runs|light|site|json> <file.muro> [args...]\n" +
|
|
125
|
+
" check: --json (emit Diagnostic[] as JSON) / --strict (exit 1 if there are warnings) — structural consistency only\n" +
|
|
126
|
+
" validate: --json (emit Finding[] as JSON) — architectural judgement (not what check guarantees)\n" +
|
|
127
|
+
" layers: the layers that took part in composition, weakest first. --attrs for the provenance of each attribute\n" +
|
|
128
|
+
" diff: koyu diff <a.muro> <b.muro> [--json] — the difference in the language of composition (0=no difference / 1=differences / 2=the input is broken)",
|
|
90
129
|
);
|
|
91
130
|
return 2;
|
|
92
131
|
}
|
|
@@ -96,7 +135,7 @@ function main(argv: string[]): number {
|
|
|
96
135
|
// 終了コードは 0=差分なし / 1=差分あり / 2=入力が壊れている — checkの0/1と紛れない
|
|
97
136
|
const fileB = rest[0];
|
|
98
137
|
if (!fileB) {
|
|
99
|
-
console.log("
|
|
138
|
+
console.log("Usage: koyu diff <a.muro> <b.muro> [--json]");
|
|
100
139
|
return 2;
|
|
101
140
|
}
|
|
102
141
|
let ma: Model;
|
|
@@ -116,7 +155,7 @@ function main(argv: string[]): number {
|
|
|
116
155
|
if (rest.includes("--json")) {
|
|
117
156
|
console.log(JSON.stringify(d, null, 1));
|
|
118
157
|
} else if (lines.length === 0) {
|
|
119
|
-
console.log("
|
|
158
|
+
console.log("No differences");
|
|
120
159
|
} else {
|
|
121
160
|
for (const l of lines) console.log(l);
|
|
122
161
|
}
|
|
@@ -158,13 +197,56 @@ function main(argv: string[]): number {
|
|
|
158
197
|
for (const e of errors) console.log(`✖ ${e}`);
|
|
159
198
|
if (errors.length === 0) {
|
|
160
199
|
console.log(
|
|
161
|
-
`✔
|
|
162
|
-
(warnings.length ? ` (
|
|
200
|
+
`✔ Consistent — ${qty(model.spaces.size, "space", "spaces")} / ${qty(model.boundaries.length, "boundary", "boundaries")}` +
|
|
201
|
+
(warnings.length ? ` (${qty(warnings.length, "warning", "warnings")})` : ""),
|
|
163
202
|
);
|
|
203
|
+
// **緑の意味を、緑を出す場所で言う。**構造整合が成り立っただけであって、
|
|
204
|
+
// 建築として妥当かはここでは何も言っていない (spec/scope.md §3)
|
|
205
|
+
console.log(" Structural consistency only — architectural validity is what koyu validate says, separately");
|
|
164
206
|
return strict && warnings.length > 0 ? 1 : 0;
|
|
165
207
|
}
|
|
166
208
|
return 1;
|
|
167
209
|
}
|
|
210
|
+
case "validate": {
|
|
211
|
+
// 建築的な判定 (spec/scope.md §3)。**check の保証ではない** — 型もコードの綴りも別で、
|
|
212
|
+
// 終了コードだけが同じ流儀 (0=違反なし / 1=違反あり)
|
|
213
|
+
const findings = validate(model);
|
|
214
|
+
if (rest.includes("--json")) {
|
|
215
|
+
console.log(JSON.stringify(findings, null, 1));
|
|
216
|
+
return findings.some((f) => f.level === "violation") ? 1 : 0;
|
|
217
|
+
}
|
|
218
|
+
const label = (f: Finding) => (f.level === "violation" ? "✖" : "⚠");
|
|
219
|
+
for (const f of findings) {
|
|
220
|
+
const where = f.line !== undefined ? `${srcRef(f.line, f.file)}: ` : "";
|
|
221
|
+
console.log(`${label(f)} [${f.rule}] ${where}${f.message}`);
|
|
222
|
+
}
|
|
223
|
+
const violations = findings.filter((f) => f.level === "violation").length;
|
|
224
|
+
const cautions = findings.length - violations;
|
|
225
|
+
console.log(
|
|
226
|
+
findings.length === 0
|
|
227
|
+
? "✔ Nothing caught by validation (this is a judgement, not a guarantee about the composition)"
|
|
228
|
+
: `Validation — ${qty(violations, "violation", "violations")} / ${qty(cautions, "caution", "cautions")}`,
|
|
229
|
+
);
|
|
230
|
+
return violations > 0 ? 1 : 0;
|
|
231
|
+
}
|
|
232
|
+
case "layers": {
|
|
233
|
+
// 合成の規則1と6 (spec/composition.md) — 強度順序を見せ、最終値の出所を言う。
|
|
234
|
+
// **暗黙の解決はどこにも無い**ことを、目で確かめられるようにするための面である
|
|
235
|
+
if (model.layers.length === 0) {
|
|
236
|
+
console.log("No layers (parsing a single file involves no composition)");
|
|
237
|
+
return 0;
|
|
238
|
+
}
|
|
239
|
+
console.log("Layers (weakest first — later layers are stronger):");
|
|
240
|
+
model.layers.forEach((l, i) => console.log(` ${i}\t${l}`));
|
|
241
|
+
if (rest.includes("--attrs")) {
|
|
242
|
+
console.log("\nAttribute provenance:");
|
|
243
|
+
const rows = [...model.attrSrc].sort(([a], [b]) => (a < b ? -1 : a > b ? 1 : 0));
|
|
244
|
+
for (const [key, layerIdx] of rows) {
|
|
245
|
+
console.log(` ${key}\t← ${layerIdx} ${model.layers[layerIdx] ?? "?"}`);
|
|
246
|
+
}
|
|
247
|
+
}
|
|
248
|
+
return 0;
|
|
249
|
+
}
|
|
168
250
|
case "json": {
|
|
169
251
|
process.stdout.write(toCanonical(model));
|
|
170
252
|
return 0;
|
|
@@ -174,7 +256,7 @@ function main(argv: string[]): number {
|
|
|
174
256
|
// 未宣言のレベルは呼び方の問題 — 生のスタックトレースで落ちない (ADR-0028)
|
|
175
257
|
if (level !== undefined && model.levels[level] === undefined) {
|
|
176
258
|
die(
|
|
177
|
-
|
|
259
|
+
`Undeclared level: ${level} (declared: ${levelsSorted(model).map((l) => l.name).join(" ")})`,
|
|
178
260
|
);
|
|
179
261
|
}
|
|
180
262
|
const explicit = opt(rest, "-o");
|
|
@@ -183,21 +265,21 @@ function main(argv: string[]): number {
|
|
|
183
265
|
const svg = svgPlan(model, { level });
|
|
184
266
|
mkdirSync(dirname(outFile), { recursive: true });
|
|
185
267
|
writeFileSync(outFile, svg);
|
|
186
|
-
console.log(
|
|
268
|
+
console.log(`Generated the plan: ${outFile}`);
|
|
187
269
|
return 0;
|
|
188
270
|
}
|
|
189
271
|
case "doors": {
|
|
190
272
|
const [from, to] = rest;
|
|
191
273
|
if (!from || !to) {
|
|
192
|
-
console.log("
|
|
274
|
+
console.log("Usage: koyu doors <file> /pathA /pathB");
|
|
193
275
|
return 2;
|
|
194
276
|
}
|
|
195
277
|
const route = doorsBetween(model, from, to);
|
|
196
278
|
if (!route) {
|
|
197
|
-
console.log(
|
|
279
|
+
console.log(`Cannot reach ${to} from ${from}`);
|
|
198
280
|
return 1;
|
|
199
281
|
}
|
|
200
|
-
console.log(`${route.doors}
|
|
282
|
+
console.log(`${qty(route.doors, "door", "doors")} — ${route.path.join(" → ")}`);
|
|
201
283
|
return 0;
|
|
202
284
|
}
|
|
203
285
|
case "graph": {
|
|
@@ -207,18 +289,18 @@ function main(argv: string[]): number {
|
|
|
207
289
|
for (const n of ns) {
|
|
208
290
|
const mark =
|
|
209
291
|
n.boundary.kind === "open"
|
|
210
|
-
? "〰
|
|
292
|
+
? "〰 open"
|
|
211
293
|
: n.boundary.kind === "wall" && n.boundary.air && !n.passable
|
|
212
|
-
? "|
|
|
294
|
+
? "| railing etc. (open to the air, not passable)"
|
|
213
295
|
: n.boundary.kind === "stair"
|
|
214
|
-
? "↕
|
|
296
|
+
? "↕ stair"
|
|
215
297
|
: n.boundary.kind === "shaft"
|
|
216
|
-
? "↕
|
|
298
|
+
? "↕ shaft (not passable)"
|
|
217
299
|
: n.boundary.kind === "void"
|
|
218
|
-
? "↕
|
|
300
|
+
? "↕ void"
|
|
219
301
|
: n.passable
|
|
220
|
-
? `—
|
|
221
|
-
: "|
|
|
302
|
+
? `— ${qty(n.doors, "door", "doors")}`
|
|
303
|
+
: "| wall";
|
|
222
304
|
const attrs = Object.entries(n.boundary.attrs)
|
|
223
305
|
.map(([k, v]) => `${k}:${v}`)
|
|
224
306
|
.join(" ");
|
|
@@ -242,19 +324,19 @@ function main(argv: string[]): number {
|
|
|
242
324
|
let sub = 0;
|
|
243
325
|
for (const s of onLevel) {
|
|
244
326
|
if (s.type === "void") {
|
|
245
|
-
console.log(` ${s.path}\t${displayName(s)}\
|
|
327
|
+
console.log(` ${s.path}\t${displayName(s)}\tvoid (not counted as floor area)`);
|
|
246
328
|
continue;
|
|
247
329
|
}
|
|
248
330
|
const a = areaM2(s)!;
|
|
249
331
|
if (s.type === "exterior") {
|
|
250
332
|
outdoorTotal += a;
|
|
251
|
-
console.log(` ${s.path}\t${displayName(s)}\t${s.type}\t${a.toFixed(2)}
|
|
333
|
+
console.log(` ${s.path}\t${displayName(s)}\t${s.type}\t${a.toFixed(2)} m2 (outdoor, not counted)`);
|
|
252
334
|
continue;
|
|
253
335
|
}
|
|
254
336
|
if (isSemiOutdoor(model, s)) {
|
|
255
337
|
semiTotal += a;
|
|
256
338
|
console.log(
|
|
257
|
-
` ${s.path}\t${displayName(s)}\t${s.type}\t${a.toFixed(2)}
|
|
339
|
+
` ${s.path}\t${displayName(s)}\t${s.type}\t${a.toFixed(2)} m2 (semi-outdoor, reported separately)`,
|
|
258
340
|
);
|
|
259
341
|
continue;
|
|
260
342
|
}
|
|
@@ -263,108 +345,111 @@ function main(argv: string[]): number {
|
|
|
263
345
|
byType.set(s.type, (byType.get(s.type) ?? 0) + a);
|
|
264
346
|
const use = effectiveUse(model, s);
|
|
265
347
|
if (use) byUse.set(use, (byUse.get(use) ?? 0) + a);
|
|
266
|
-
console.log(` ${s.path}\t${displayName(s)}\t${s.type}\t${a.toFixed(2)}
|
|
348
|
+
console.log(` ${s.path}\t${displayName(s)}\t${s.type}\t${a.toFixed(2)} m2`);
|
|
267
349
|
}
|
|
268
|
-
console.log(`
|
|
350
|
+
console.log(` Subtotal ${sub.toFixed(2)} m2`);
|
|
269
351
|
}
|
|
270
|
-
console.log(
|
|
352
|
+
console.log(`Total ${total.toFixed(2)} m2 (indoor floor area)`);
|
|
271
353
|
if (outdoorTotal > 0) {
|
|
272
|
-
console.log(
|
|
354
|
+
console.log(`Outdoor ${outdoorTotal.toFixed(2)} m2 (plazas, open ground and the like — not counted as floor area)`);
|
|
273
355
|
}
|
|
274
356
|
if (semiTotal > 0) {
|
|
275
|
-
console.log(
|
|
357
|
+
console.log(`Semi-outdoor ${semiTotal.toFixed(2)} m2 (balconies, external stairs and the like — whether they count is a matter of regulatory detail, so it is reported separately)`);
|
|
276
358
|
}
|
|
277
359
|
const zonesToShow = [...model.zones.values()].filter((z) => z.attrs["site"] !== 1);
|
|
278
360
|
if (zonesToShow.length > 0) {
|
|
279
|
-
console.log("
|
|
361
|
+
console.log("By zone (counted aggregation):");
|
|
280
362
|
for (const z of zonesToShow.sort((a, b) => (a.path < b.path ? -1 : 1))) {
|
|
281
363
|
const nm = z.attrs["name"];
|
|
282
364
|
console.log(
|
|
283
|
-
` ${z.path}\t${typeof nm === "string" ? nm : ""}\t${zoneAreaM2(model, z.path).toFixed(2)}
|
|
365
|
+
` ${z.path}\t${typeof nm === "string" ? nm : ""}\t${zoneAreaM2(model, z.path).toFixed(2)} m2`,
|
|
284
366
|
);
|
|
285
367
|
}
|
|
286
368
|
}
|
|
287
|
-
for (const [t, a] of byType) console.log(` ${t}: ${a.toFixed(2)}
|
|
369
|
+
for (const [t, a] of byType) console.log(` ${t}: ${a.toFixed(2)} m2`);
|
|
288
370
|
if (byUse.size > 0) {
|
|
289
371
|
const parts = [...byUse.entries()].map(
|
|
290
|
-
([u, a]) => `${u} ${a.toFixed(2)}
|
|
372
|
+
([u, a]) => `${u} ${a.toFixed(2)} m2 (${((a / total) * 100).toFixed(1)}%)`,
|
|
291
373
|
);
|
|
292
|
-
console.log(`use
|
|
374
|
+
console.log(`By use: ${parts.join(" / ")}`);
|
|
293
375
|
}
|
|
294
376
|
return 0;
|
|
295
377
|
}
|
|
296
378
|
case "light": {
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
379
|
+
// 採光は**判定**である — core が返すのは床面積と有効窓面積という数だけで、
|
|
380
|
+
// 1/7 の合否は検証の面 (validate) が言う (spec/scope.md §4)
|
|
381
|
+
const inputs = daylightInputs(model);
|
|
382
|
+
if (inputs.length === 0) {
|
|
383
|
+
console.log("Nothing is in daylight scope (write daylight:1 on the rooms to be judged)");
|
|
300
384
|
return 0;
|
|
301
385
|
}
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
386
|
+
const failing = new Set(
|
|
387
|
+
validate(model).filter((f) => f.rule === "daylight.ratio").flatMap((f) => f.path ?? []),
|
|
388
|
+
);
|
|
389
|
+
for (const d of inputs) {
|
|
390
|
+
const ok = !failing.has(d.space.path);
|
|
391
|
+
const ratio = d.window > 0 ? `1/${(d.floor / d.window).toFixed(1)}` : "no window";
|
|
306
392
|
console.log(
|
|
307
|
-
`${
|
|
308
|
-
(
|
|
393
|
+
`${ok ? "✔" : "✖"} ${d.space.path}\t${displayName(d.space)}\twindow ${d.window.toFixed(2)} m2 / floor ${d.floor.toFixed(2)} m2 = ${ratio} (needs 1/7 ≈ ${(d.floor / 7).toFixed(2)} m2)` +
|
|
394
|
+
(d.missingH ? " ⚠ windows without h: are not counted" : ""),
|
|
309
395
|
);
|
|
310
396
|
}
|
|
311
397
|
console.log(
|
|
312
|
-
|
|
313
|
-
? `✔
|
|
314
|
-
: `✖ ${
|
|
398
|
+
failing.size === 0
|
|
399
|
+
? `✔ Every room meets 1/7 — ${qty(inputs.length, "room", "rooms")} in scope (a rough judgement with no correction factor — this is validation, not what check guarantees)`
|
|
400
|
+
: `✖ Short of 1/7: ${failing.size} of ${qty(inputs.length, "room", "rooms")} (this is a validation judgement)`,
|
|
315
401
|
);
|
|
316
|
-
return
|
|
402
|
+
return failing.size === 0 ? 0 : 1;
|
|
317
403
|
}
|
|
318
404
|
case "site": {
|
|
319
405
|
// 敷地の問い: 敷地面積・接道・建蔽率・容積率 (基本計画のボリューム検討の数字)
|
|
320
406
|
const r = siteReport(model);
|
|
321
407
|
if (!r.siteZone && r.roads.length === 0) {
|
|
322
|
-
console.log("
|
|
408
|
+
console.log("There is no site (write site:1 on a zone and road:<width> on the road)");
|
|
323
409
|
return 1;
|
|
324
410
|
}
|
|
325
411
|
const site = r.declaredArea ?? r.derivedArea;
|
|
326
412
|
if (r.siteZone) {
|
|
327
413
|
const nm = r.siteZone.attrs["name"];
|
|
328
|
-
console.log(
|
|
414
|
+
console.log(`Site ${r.siteZone.path}${typeof nm === "string" ? ` (${nm})` : ""}`);
|
|
329
415
|
}
|
|
330
416
|
if (r.polygon) {
|
|
331
|
-
console.log(`
|
|
417
|
+
console.log(` Site shape: polygon with ${r.polygon.points.length} vertices (a polygon declaration — given geometry)`);
|
|
332
418
|
}
|
|
333
419
|
if (r.declaredArea !== undefined) {
|
|
334
|
-
const ok = Math.abs(r.declaredArea - r.derivedArea) < 0.05;
|
|
335
420
|
console.log(
|
|
336
|
-
`
|
|
421
|
+
` Site area: declared ${r.declaredArea.toFixed(2)} m2 / derived ${r.derivedArea.toFixed(2)} m2`,
|
|
337
422
|
);
|
|
338
423
|
} else {
|
|
339
|
-
console.log(`
|
|
424
|
+
console.log(` Site area (derived): ${r.derivedArea.toFixed(2)} m2`);
|
|
340
425
|
}
|
|
341
426
|
for (const road of r.roads) {
|
|
342
427
|
const nm = road.road.attrs["name"];
|
|
343
428
|
console.log(
|
|
344
|
-
`
|
|
429
|
+
` Road: ${road.road.path}${typeof nm === "string" ? ` (${nm})` : ""} width ${road.width}mm / frontage ${road.frontage}mm`,
|
|
345
430
|
);
|
|
346
431
|
}
|
|
347
|
-
console.log(`
|
|
348
|
-
console.log(`
|
|
432
|
+
console.log(` Building footprint (horizontal projection, rough): ${r.footprint.toFixed(2)} m2 → building coverage ratio ${((r.footprint / site) * 100).toFixed(1)}%`);
|
|
433
|
+
console.log(` Total floor area: ${r.totalFloor.toFixed(2)} m2 → floor area ratio ${((r.totalFloor / site) * 100).toFixed(1)}%`);
|
|
349
434
|
return 0;
|
|
350
435
|
}
|
|
351
436
|
case "axo": {
|
|
352
437
|
// 軸測図 — 立体をそのまま投影する。平面と同じく生成物のSVGなので、
|
|
353
438
|
// 実行環境もWebGLも要らず、生成して見るという同じ手で立体を確かめられる
|
|
354
439
|
const outPath = opt(rest, "-o", "--out") ?? "out/axo.svg";
|
|
355
|
-
const dirOpt =
|
|
440
|
+
const dirOpt = enumOpt(rest, ["NE", "NW", "SE", "SW"] as const, "-d", "--dir");
|
|
356
441
|
const lv = opt(rest, "-l", "--levels");
|
|
357
|
-
const sc =
|
|
442
|
+
const sc = numOpt(rest, "-s", "--scale");
|
|
358
443
|
const svg = svgAxo(model, {
|
|
359
444
|
...(dirOpt ? { dir: dirOpt } : {}),
|
|
360
445
|
...(lv ? { levels: expandLevelArg(model, lv) } : {}),
|
|
361
|
-
...(sc ? { scale:
|
|
446
|
+
...(sc !== undefined ? { scale: sc } : {}),
|
|
362
447
|
...(rest.includes("--ceilings") ? { ceilings: true } : {}),
|
|
363
448
|
...(rest.includes("--no-walls") ? { walls: false } : {}),
|
|
364
449
|
});
|
|
365
450
|
mkdirSync(dirname(outPath), { recursive: true });
|
|
366
451
|
writeFileSync(outPath, svg);
|
|
367
|
-
console.log(
|
|
452
|
+
console.log(`Generated the axonometric: ${outPath}`);
|
|
368
453
|
return 0;
|
|
369
454
|
}
|
|
370
455
|
|
|
@@ -372,7 +457,7 @@ function main(argv: string[]): number {
|
|
|
372
457
|
// 縦動線 (ADR-0021): 段数も踏面も勾配も原本には書かれていない。全て導出値である
|
|
373
458
|
const runs = verticalRuns(model);
|
|
374
459
|
if (runs.length === 0) {
|
|
375
|
-
console.log("
|
|
460
|
+
console.log("There is no vertical circulation (write stair:N / ramp:N / escalator:N / lift:1 on a space)");
|
|
376
461
|
return 0;
|
|
377
462
|
}
|
|
378
463
|
for (const r of runs) {
|
|
@@ -385,10 +470,10 @@ function main(argv: string[]): number {
|
|
|
385
470
|
}
|
|
386
471
|
const shape =
|
|
387
472
|
r.device === "stair"
|
|
388
|
-
? `${r.risers}
|
|
389
|
-
:
|
|
473
|
+
? `${qty(r.risers, "riser", "risers")} of ${Math.round(r.riser)}mm, tread ${Math.round(r.tread)}mm`
|
|
474
|
+
: `slope ${slopeText(r.slope)}`;
|
|
390
475
|
console.log(
|
|
391
|
-
`${head}\
|
|
476
|
+
`${head}\trise ${r.rise}mm\t${r.form === "return" ? "return" : "straight"}\t${shape}\tgoing ${Math.round(r.going)}mm\t${r.path}`,
|
|
392
477
|
);
|
|
393
478
|
}
|
|
394
479
|
return 0;
|
|
@@ -398,7 +483,7 @@ function main(argv: string[]): number {
|
|
|
398
483
|
// テキストの矩計: レベルの積み上がりと高さの検算
|
|
399
484
|
const levels = levelsSorted(model);
|
|
400
485
|
if (levels.length === 0) {
|
|
401
|
-
console.log("
|
|
486
|
+
console.log("No level is defined");
|
|
402
487
|
return 1;
|
|
403
488
|
}
|
|
404
489
|
for (let i = levels.length - 1; i >= 0; i--) {
|
|
@@ -413,21 +498,21 @@ function main(argv: string[]): number {
|
|
|
413
498
|
const pitch = upper.z - l.z;
|
|
414
499
|
const detail =
|
|
415
500
|
l.h !== undefined && upper.slab !== undefined
|
|
416
|
-
? ` =
|
|
417
|
-
(pitch - l.h - upper.slab > 0 ? ` +
|
|
501
|
+
? ` = ceiling ${l.h} + slab ${upper.slab}` +
|
|
502
|
+
(pitch - l.h - upper.slab > 0 ? ` + ${pitch - l.h - upper.slab} left over` : "")
|
|
418
503
|
: "";
|
|
419
|
-
console.log(` ↑
|
|
504
|
+
console.log(` ↑ storey height ${pitch}${detail}`);
|
|
420
505
|
}
|
|
421
506
|
}
|
|
422
507
|
const spaces = [...model.spaces.values()].filter((s) => s.rects.length > 0 && s.level);
|
|
423
508
|
const overrides = spaces.filter((s) => typeof s.attrs["h"] === "number");
|
|
424
509
|
for (const s of overrides) {
|
|
425
|
-
console.log(
|
|
510
|
+
console.log(`Per-space ceiling height: ${s.path} h:${heff(model, s)}`);
|
|
426
511
|
}
|
|
427
512
|
return 0;
|
|
428
513
|
}
|
|
429
514
|
default:
|
|
430
|
-
console.log(
|
|
515
|
+
console.log(`Unknown command: ${cmd}`);
|
|
431
516
|
return 2;
|
|
432
517
|
}
|
|
433
518
|
}
|