@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/index.ts
CHANGED
|
@@ -1,44 +1,190 @@
|
|
|
1
|
-
// koyu
|
|
2
|
-
|
|
3
|
-
export
|
|
4
|
-
export
|
|
5
|
-
|
|
1
|
+
// koyu — 公開面 (ADR-0037)
|
|
2
|
+
//
|
|
3
|
+
// **ここに書き下された名だけが約束である。**`export *` は使わない — モジュールに
|
|
4
|
+
// export を足した瞬間に、誰も宣言していない約束が凍る面に増えてしまうからである。
|
|
5
|
+
// 凍らせる面は、書き下されていなければならない (spec/scope.md §8)。
|
|
6
|
+
//
|
|
7
|
+
// 載せる基準は一つ — **面の外に利用者がいること。**
|
|
8
|
+
// 1. パッケージの外 (ugatsu / eval / scripts / editors) が実際に呼ぶ
|
|
9
|
+
// 2. CLI か MCP が答えるものを API からも答えるために要る
|
|
10
|
+
// (「CLIが答えるものはすべてこのAPIが答える」— guide/api.md)
|
|
11
|
+
// 3. spec が名指しで約束する導出 (scope.md §4・§6 / semantics.md)
|
|
12
|
+
// 4. test が契約として固定している
|
|
13
|
+
// core のモジュール同士が引き合うだけの配管は面ではない。型は、載せた値の署名を
|
|
14
|
+
// 書き下すのに要るものだけを載せる。
|
|
15
|
+
//
|
|
16
|
+
// この一覧と spec/tools.md の一覧は集合として一致する — test/public-api.test.ts が縛る。
|
|
17
|
+
|
|
18
|
+
// ---- 解析と合成 (spec/composition.md) ----
|
|
19
|
+
export { parse, parseFiles, parseWith, tokenize, type LayerLoader } from "./core/parse.js";
|
|
20
|
+
|
|
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
|
+
// **合否は言わない** (spec/scope.md §4)。数と形を返すところまでが core である
|
|
6
48
|
export {
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
49
|
+
areaM2,
|
|
50
|
+
canonicalBoundaryOrder,
|
|
51
|
+
columnsFor,
|
|
52
|
+
DEFAULT_LANGUAGE_VERSION,
|
|
53
|
+
displayName,
|
|
54
|
+
effectiveUse,
|
|
55
|
+
heff,
|
|
56
|
+
isCoveredAbove,
|
|
57
|
+
isIndoor,
|
|
58
|
+
isSemiOutdoor,
|
|
59
|
+
levelsSorted,
|
|
60
|
+
newUids,
|
|
61
|
+
pointInPolygon,
|
|
62
|
+
polyBounds,
|
|
63
|
+
polygonAreaM2,
|
|
64
|
+
rectToPoly,
|
|
65
|
+
SourceError,
|
|
66
|
+
srcRef,
|
|
67
|
+
SUPPORTED_LANGUAGE_VERSIONS,
|
|
68
|
+
toCanonical,
|
|
69
|
+
unionAreaM2,
|
|
70
|
+
zoneAreaM2,
|
|
71
|
+
} from "./core/model.js";
|
|
72
|
+
|
|
73
|
+
// ---- 構造整合の診断 (ADR-0016) ----
|
|
74
|
+
export {
|
|
75
|
+
check,
|
|
76
|
+
checkDiagnostics,
|
|
77
|
+
DIAGNOSTIC_CODES,
|
|
78
|
+
type CheckResult,
|
|
79
|
+
type Diagnostic,
|
|
80
|
+
type DiagnosticCode,
|
|
81
|
+
} from "./core/diagnose.js";
|
|
82
|
+
|
|
83
|
+
// ---- 空間グラフと導出の部品 ----
|
|
84
|
+
export {
|
|
85
|
+
deriveDefaultBoundaries,
|
|
86
|
+
doorsBetween,
|
|
87
|
+
envelopeGaps,
|
|
88
|
+
neighbors,
|
|
89
|
+
passable,
|
|
90
|
+
placeBand,
|
|
91
|
+
placeOpening,
|
|
92
|
+
segmentsFor,
|
|
93
|
+
type Band,
|
|
94
|
+
type BandCode,
|
|
95
|
+
type BandError,
|
|
96
|
+
type NeighborInfo,
|
|
97
|
+
type PlacedBand,
|
|
98
|
+
type Route,
|
|
99
|
+
type Segment,
|
|
100
|
+
} from "./core/graph.js";
|
|
101
|
+
|
|
102
|
+
// ---- 形の参照実装 (ADR-0040) — **これが形の唯一の入口である** ----
|
|
103
|
+
// Form は見た目を持たない (spec/scope.md §6)。規則は spec/derivation.md が持つ
|
|
104
|
+
// 実体の構成子 (thicken / bandLine / band / columnRect / runPrism) も core が唯一の実装を
|
|
105
|
+
// 持つ — 芯線と厚みから四辺形や角柱を起こす規則も導出の一部だからである
|
|
106
|
+
export {
|
|
107
|
+
band,
|
|
108
|
+
bandLine,
|
|
109
|
+
columnRect,
|
|
110
|
+
derive,
|
|
111
|
+
DERIVATION_CONSTANTS,
|
|
112
|
+
levelPitch,
|
|
113
|
+
runPrism,
|
|
114
|
+
thicken,
|
|
115
|
+
type DeriveOptions,
|
|
116
|
+
type Form,
|
|
117
|
+
type FormBoundary,
|
|
118
|
+
type FormColumn,
|
|
119
|
+
type FormInput,
|
|
120
|
+
type FormLevel,
|
|
121
|
+
type FormOpening,
|
|
122
|
+
type FormPanel,
|
|
123
|
+
type FormPlan,
|
|
124
|
+
type FormPrism,
|
|
125
|
+
type FormRun,
|
|
126
|
+
type FormSeg,
|
|
127
|
+
type FormSite,
|
|
128
|
+
type FormSpace,
|
|
129
|
+
type FormSwing,
|
|
130
|
+
type PlanClass,
|
|
131
|
+
type PlanEntity,
|
|
132
|
+
type PlanRole,
|
|
133
|
+
type PlanSubject,
|
|
134
|
+
} from "./core/derive.js";
|
|
135
|
+
export { TOLERANCES } from "./core/tolerance.js";
|
|
136
|
+
|
|
137
|
+
// ---- 床・天井・屋根 (ADR-0024) ----
|
|
138
|
+
export { slabs, type Slab, type SlabKind } from "./core/fabric.js";
|
|
139
|
+
|
|
140
|
+
// ---- 採光の入力 (ADR-0020) ----
|
|
141
|
+
export { daylightInputs, type DaylightInput } from "./core/light.js";
|
|
142
|
+
|
|
143
|
+
// ---- 縦動線 (ADR-0021) ----
|
|
20
144
|
export {
|
|
21
|
-
verticalRuns,
|
|
22
|
-
verticalRun,
|
|
23
|
-
runDecls,
|
|
24
|
-
runSolids,
|
|
25
145
|
runDrawsForLevel,
|
|
26
|
-
|
|
146
|
+
runSolids,
|
|
27
147
|
slopeText,
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
RUN_KEYS,
|
|
31
|
-
RUN_FORMS,
|
|
148
|
+
verticalRuns,
|
|
149
|
+
type RunArrow,
|
|
32
150
|
type RunDevice,
|
|
151
|
+
type RunDraw,
|
|
33
152
|
type RunForm,
|
|
34
153
|
type RunPart,
|
|
35
|
-
type VerticalRun,
|
|
36
154
|
type RunSolid,
|
|
37
|
-
type RunDraw,
|
|
38
|
-
type RunArrow,
|
|
39
|
-
type RunIssue,
|
|
40
155
|
type Seg2,
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
156
|
+
type VerticalRun,
|
|
157
|
+
} from "./core/vertical.js";
|
|
158
|
+
|
|
159
|
+
// ---- 敷地 (ADR-0009 / ADR-0011) ----
|
|
160
|
+
export { siteReport, type RoadFrontage, type SiteReport } from "./core/site.js";
|
|
161
|
+
|
|
162
|
+
// ---- 構成の言葉の差分 (ADR-0018) ----
|
|
163
|
+
export {
|
|
164
|
+
renderDiff,
|
|
165
|
+
semanticDiff,
|
|
166
|
+
type BoundaryChange,
|
|
167
|
+
type BoundaryItem,
|
|
168
|
+
type ChangedItem,
|
|
169
|
+
type ColumnItem,
|
|
170
|
+
type FieldChange,
|
|
171
|
+
type GridChange,
|
|
172
|
+
type ModelDiff,
|
|
173
|
+
type RenamedItem,
|
|
174
|
+
type SpaceItem,
|
|
175
|
+
} from "./core/diff.js";
|
|
176
|
+
|
|
177
|
+
// ---- 生成 — **凍らない** (spec/scope.md §8)。SVGの中身は約束の外にある ----
|
|
178
|
+
// 領域としては `@kensnzk/koyu/draw` にも分けてある
|
|
179
|
+
export { svgPlan, type PlanOptions } from "./draw/plan.js";
|
|
180
|
+
export { svgAxo, type AxoOptions } from "./draw/axo.js";
|
|
181
|
+
|
|
182
|
+
// ---- 検証 — **core ではない。**凍らない・増える・合否を言う (spec/scope.md §3) ----
|
|
183
|
+
// Finding は Diagnostic と別の型で、フィールド名から違う (rule/level と code/severity)。
|
|
184
|
+
// 領域としては `@kensnzk/koyu/validate` にも分けてある
|
|
185
|
+
export {
|
|
186
|
+
validate,
|
|
187
|
+
VALIDATION_RULES,
|
|
188
|
+
type Finding,
|
|
189
|
+
type ValidationRule,
|
|
190
|
+
} from "./validate/index.js";
|
package/src/mcp.ts
CHANGED
|
@@ -11,21 +11,23 @@ import { dirname, isAbsolute, relative, resolve, sep } from "node:path";
|
|
|
11
11
|
import {
|
|
12
12
|
areaM2,
|
|
13
13
|
isIndoor,
|
|
14
|
-
|
|
14
|
+
daylightInputs,
|
|
15
|
+
validate,
|
|
15
16
|
displayName,
|
|
16
17
|
doorsBetween,
|
|
17
18
|
effectiveUse,
|
|
18
19
|
isSemiOutdoor,
|
|
19
20
|
levelsSorted,
|
|
21
|
+
newUids,
|
|
20
22
|
polygonAreaM2,
|
|
21
23
|
toCanonical,
|
|
22
24
|
zoneAreaM2,
|
|
23
25
|
type Model,
|
|
24
26
|
type Space,
|
|
25
27
|
} from "./index.js";
|
|
26
|
-
import { check, checkDiagnostics } from "./
|
|
27
|
-
import { svgPlan } from "./plan.js";
|
|
28
|
-
import { siteReport } from "./site.js";
|
|
28
|
+
import { check, checkDiagnostics } from "./core/diagnose.js";
|
|
29
|
+
import { svgPlan } from "./draw/plan.js";
|
|
30
|
+
import { siteReport } from "./core/site.js";
|
|
29
31
|
import { parseFile, parseFileWith } from "./parse-file.js";
|
|
30
32
|
|
|
31
33
|
// ---- モデルの読み込みと要約 ----
|
|
@@ -43,7 +45,7 @@ function layerFiles(model: Model, entry: string): string[] {
|
|
|
43
45
|
function assertInside(entryDir: string, targetDir: string): void {
|
|
44
46
|
const rel = relative(entryDir, targetDir);
|
|
45
47
|
if (rel === ".." || rel.startsWith(`..${sep}`) || isAbsolute(rel)) {
|
|
46
|
-
throw new Error("entry
|
|
48
|
+
throw new Error("Cannot write outside the entry's directory");
|
|
47
49
|
}
|
|
48
50
|
}
|
|
49
51
|
|
|
@@ -62,7 +64,7 @@ function summarize(model: Model, file: string): unknown {
|
|
|
62
64
|
}
|
|
63
65
|
const byUse: Record<string, number> = {};
|
|
64
66
|
for (const s of indoor) {
|
|
65
|
-
const u = effectiveUse(model, s) ?? "(
|
|
67
|
+
const u = effectiveUse(model, s) ?? "(unspecified)";
|
|
66
68
|
byUse[u] = Math.round(((byUse[u] ?? 0) + (areaM2(s) ?? 0)) * 100) / 100;
|
|
67
69
|
}
|
|
68
70
|
const r = check(model);
|
|
@@ -99,7 +101,7 @@ function summarize(model: Model, file: string): unknown {
|
|
|
99
101
|
floorsM2: byLevel,
|
|
100
102
|
byUseM2: byUse,
|
|
101
103
|
check: { errors: r.errors.length, warnings: r.warnings.length },
|
|
102
|
-
hint: "
|
|
104
|
+
hint: "Read layer contents with layers, check with check, and edit with write_layer (check is the gatekeeper). Architectural verdicts come from validate.",
|
|
103
105
|
};
|
|
104
106
|
}
|
|
105
107
|
|
|
@@ -124,17 +126,17 @@ interface Tool {
|
|
|
124
126
|
}
|
|
125
127
|
|
|
126
128
|
const FILE_PROP = {
|
|
127
|
-
file: { type: "string", description: "entry
|
|
129
|
+
file: { type: "string", description: "Path to the entry .muro file (imports are composed automatically)" },
|
|
128
130
|
};
|
|
129
131
|
const str = (v: unknown, name: string): string => {
|
|
130
|
-
if (typeof v !== "string" || !v) throw new Error(`${name} (
|
|
132
|
+
if (typeof v !== "string" || !v) throw new Error(`${name} (a string) is required`);
|
|
131
133
|
return v;
|
|
132
134
|
};
|
|
133
135
|
|
|
134
136
|
const TOOLS: Record<string, Tool> = {
|
|
135
137
|
model_summary: {
|
|
136
138
|
description:
|
|
137
|
-
"
|
|
139
|
+
"Summary of the building: name, levels, layer composition, zones, door/window assets, areas, and check counts. Call this first",
|
|
138
140
|
schema: { type: "object", properties: FILE_PROP, required: ["file"] },
|
|
139
141
|
run: (a) => {
|
|
140
142
|
const file = str(a.file, "file");
|
|
@@ -143,7 +145,7 @@ const TOOLS: Record<string, Tool> = {
|
|
|
143
145
|
},
|
|
144
146
|
check: {
|
|
145
147
|
description:
|
|
146
|
-
"
|
|
148
|
+
"The gatekeeper of the build: composes the layers and checks structural consistency. Errors and warnings carry layer:line. Call it after every edit. **This says nothing about architectural soundness** — that is the validate tool",
|
|
147
149
|
schema: { type: "object", properties: FILE_PROP, required: ["file"] },
|
|
148
150
|
run: (a) => {
|
|
149
151
|
const m = load(str(a.file, "file"));
|
|
@@ -159,7 +161,7 @@ const TOOLS: Record<string, Tool> = {
|
|
|
159
161
|
},
|
|
160
162
|
},
|
|
161
163
|
layers: {
|
|
162
|
-
description: "
|
|
164
|
+
description: "Returns every layer (.muro file) taking part in the composition, in strength order (later layers are stronger), with its source — this is how you read the original",
|
|
163
165
|
schema: { type: "object", properties: FILE_PROP, required: ["file"] },
|
|
164
166
|
run: (a) => {
|
|
165
167
|
const file = str(a.file, "file");
|
|
@@ -169,14 +171,13 @@ const TOOLS: Record<string, Tool> = {
|
|
|
169
171
|
},
|
|
170
172
|
write_layer: {
|
|
171
173
|
description:
|
|
172
|
-
"
|
|
173
|
-
"checkのエラーは返すが書き込みは行う (複数レイヤーにまたがる編集の途中を許す) — 直して再度書くこと。履歴はgitに任せる",
|
|
174
|
+
"Checks a layer (.muro file) before replacing it. Content that would make the composition unparsable is never written (the original stays intact). Check errors are returned but the write still happens, so that an edit spanning several layers can be made in steps — fix it and write again. History is left to git",
|
|
174
175
|
schema: {
|
|
175
176
|
type: "object",
|
|
176
177
|
properties: {
|
|
177
178
|
...FILE_PROP,
|
|
178
|
-
layer: { type: "string", description: "
|
|
179
|
-
content: { type: "string", description: "
|
|
179
|
+
layer: { type: "string", description: "Path of the .muro file to write (relative to the entry, or absolute)" },
|
|
180
|
+
content: { type: "string", description: "The full text of the layer (a whole-file replacement)" },
|
|
180
181
|
},
|
|
181
182
|
required: ["file", "layer", "content"],
|
|
182
183
|
},
|
|
@@ -185,7 +186,7 @@ const TOOLS: Record<string, Tool> = {
|
|
|
185
186
|
const content = str(a.content, "content");
|
|
186
187
|
const entryDir = resolve(dirname(resolve(file)));
|
|
187
188
|
const target = resolve(entryDir, str(a.layer, "layer"));
|
|
188
|
-
if (!target.endsWith(".muro")) throw new Error("
|
|
189
|
+
if (!target.endsWith(".muro")) throw new Error("Only .muro files can be written");
|
|
189
190
|
assertInside(entryDir, dirname(target));
|
|
190
191
|
// 門番は書き込みの前 — 差し替え内容で仮想合成し、parse不能なら原本に触れない (ADR-0013)。
|
|
191
192
|
// 合成に参加しないファイルの内容は検証されない (importされた時のcheckが捕まえる)
|
|
@@ -209,14 +210,36 @@ const TOOLS: Record<string, Tool> = {
|
|
|
209
210
|
return { written: target, ok: r.errors.length === 0, spaces: m.spaces.size, ...r };
|
|
210
211
|
},
|
|
211
212
|
},
|
|
213
|
+
new_uids: {
|
|
214
|
+
description:
|
|
215
|
+
"Mints fresh identity tokens (uid) to write onto spaces or zones with write_layer. They collide with nothing already composed into this model, and 80 bits of randomness keeps them apart from layers that are not composed here. **Nothing assigns a uid on its own** — call this only when a space has to be pointed at across renames (sensors, registers, long-running operations), and run check afterwards, because UID03 is the only thing that proves uniqueness",
|
|
216
|
+
schema: {
|
|
217
|
+
type: "object",
|
|
218
|
+
properties: {
|
|
219
|
+
...FILE_PROP,
|
|
220
|
+
count: { type: "integer", description: "How many tokens to mint (default 1)" },
|
|
221
|
+
},
|
|
222
|
+
required: ["file"],
|
|
223
|
+
},
|
|
224
|
+
run: (a) => {
|
|
225
|
+
const count = a.count === undefined ? 1 : Number(a.count);
|
|
226
|
+
if (!Number.isInteger(count) || count < 1 || count > 1000) {
|
|
227
|
+
throw new Error("count is an integer between 1 and 1000");
|
|
228
|
+
}
|
|
229
|
+
return {
|
|
230
|
+
uids: newUids(load(str(a.file, "file")), count),
|
|
231
|
+
note: "Write these as uid: on a space or zone. No other element accepts uid (the ledger rejects it). A uid is carried across renames by hand — that act is the record of the design decision that it is still the same space",
|
|
232
|
+
};
|
|
233
|
+
},
|
|
234
|
+
},
|
|
212
235
|
doors: {
|
|
213
|
-
description: "
|
|
236
|
+
description: "Circulation query: how many doors lie between space A and space B (the path with the fewest doors)",
|
|
214
237
|
schema: {
|
|
215
238
|
type: "object",
|
|
216
239
|
properties: {
|
|
217
240
|
...FILE_PROP,
|
|
218
|
-
from: { type: "string", description: "
|
|
219
|
-
to: { type: "string", description: "
|
|
241
|
+
from: { type: "string", description: "Path of the space to start from (e.g. /L9/A/ldk)" },
|
|
242
|
+
to: { type: "string", description: "Path of the space to reach (e.g. /out/road-s)" },
|
|
220
243
|
},
|
|
221
244
|
required: ["file", "from", "to"],
|
|
222
245
|
},
|
|
@@ -226,10 +249,10 @@ const TOOLS: Record<string, Tool> = {
|
|
|
226
249
|
},
|
|
227
250
|
},
|
|
228
251
|
spaces: {
|
|
229
|
-
description: "
|
|
252
|
+
description: "List of spaces: path, type, level, area, semi-outdoor flag, and originating layer. Optionally filtered by level",
|
|
230
253
|
schema: {
|
|
231
254
|
type: "object",
|
|
232
|
-
properties: { ...FILE_PROP, level: { type: "string", description: "
|
|
255
|
+
properties: { ...FILE_PROP, level: { type: "string", description: "Filter by level name (optional)" } },
|
|
233
256
|
required: ["file"],
|
|
234
257
|
},
|
|
235
258
|
run: (a) => {
|
|
@@ -240,22 +263,37 @@ const TOOLS: Record<string, Tool> = {
|
|
|
240
263
|
},
|
|
241
264
|
},
|
|
242
265
|
light: {
|
|
243
|
-
description:
|
|
266
|
+
description:
|
|
267
|
+
"Daylight inputs: floor area and effective window area for every space written with daylight:1 (a 0.7 factor applies through a covered semi-outdoor space). **It delivers no verdict** — the 1/7 judgement comes from the validate tool",
|
|
244
268
|
schema: { type: "object", properties: FILE_PROP, required: ["file"] },
|
|
245
269
|
run: (a) => {
|
|
246
270
|
const m = load(str(a.file, "file"));
|
|
247
|
-
return
|
|
248
|
-
path:
|
|
249
|
-
name: displayName(
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
needM2: r.need,
|
|
271
|
+
return daylightInputs(m).map((d) => ({
|
|
272
|
+
path: d.space.path,
|
|
273
|
+
name: displayName(d.space),
|
|
274
|
+
windowM2: d.window,
|
|
275
|
+
floorM2: d.floor,
|
|
276
|
+
missingH: d.missingH,
|
|
254
277
|
}));
|
|
255
278
|
},
|
|
256
279
|
},
|
|
280
|
+
validate: {
|
|
281
|
+
description:
|
|
282
|
+
"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",
|
|
283
|
+
schema: { type: "object", properties: FILE_PROP, required: ["file"] },
|
|
284
|
+
run: (a) => {
|
|
285
|
+
const m = load(str(a.file, "file"));
|
|
286
|
+
const findings = validate(m);
|
|
287
|
+
return {
|
|
288
|
+
findings,
|
|
289
|
+
violations: findings.filter((f) => f.level === "violation").length,
|
|
290
|
+
cautions: findings.filter((f) => f.level === "caution").length,
|
|
291
|
+
note: "These are verdicts, not the structural-consistency guarantee of koyu check",
|
|
292
|
+
};
|
|
293
|
+
},
|
|
294
|
+
},
|
|
257
295
|
site: {
|
|
258
|
-
description: "
|
|
296
|
+
description: "Site query: site area (declared against derived), road frontage, footprint, and the coverage and floor-area ratios",
|
|
259
297
|
schema: { type: "object", properties: FILE_PROP, required: ["file"] },
|
|
260
298
|
run: (a) => {
|
|
261
299
|
const r = siteReport(load(str(a.file, "file")));
|
|
@@ -282,16 +320,16 @@ const TOOLS: Record<string, Tool> = {
|
|
|
282
320
|
},
|
|
283
321
|
},
|
|
284
322
|
plan_svg: {
|
|
285
|
-
description: "
|
|
323
|
+
description: "Generates and returns the plan SVG for a level (form is generated, not written — the lowest level doubles as the site plan)",
|
|
286
324
|
schema: {
|
|
287
325
|
type: "object",
|
|
288
|
-
properties: { ...FILE_PROP, level: { type: "string", description: "
|
|
326
|
+
properties: { ...FILE_PROP, level: { type: "string", description: "Level name (e.g. L5)" } },
|
|
289
327
|
required: ["file", "level"],
|
|
290
328
|
},
|
|
291
329
|
run: (a) => svgPlan(load(str(a.file, "file")), { level: str(a.level, "level") }),
|
|
292
330
|
},
|
|
293
331
|
canonical_json: {
|
|
294
|
-
description: "
|
|
332
|
+
description: "The canonical JSON (machine format — one composed model, byte-stable). The ground for diffing and for external connections",
|
|
295
333
|
schema: { type: "object", properties: FILE_PROP, required: ["file"] },
|
|
296
334
|
run: (a) => JSON.parse(toCanonical(load(str(a.file, "file")))),
|
|
297
335
|
},
|
|
@@ -327,11 +365,9 @@ function handle(msg: Json): void {
|
|
|
327
365
|
result(id, {
|
|
328
366
|
protocolVersion: (params.protocolVersion as string) ?? "2025-06-18",
|
|
329
367
|
capabilities: { tools: {} },
|
|
330
|
-
serverInfo: { name: "koyu", version: "0.
|
|
368
|
+
serverInfo: { name: "koyu", version: "0.16.0" },
|
|
331
369
|
instructions:
|
|
332
|
-
"
|
|
333
|
-
"write_layerで編集する。checkが一棟のビルドの門番 — エラーは出所レイヤー:行つきで返る。" +
|
|
334
|
-
"doors/light/site/spacesは同じ記述への異なる問い。形 (plan_svg) は生成物。",
|
|
370
|
+
"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.",
|
|
335
371
|
});
|
|
336
372
|
return;
|
|
337
373
|
}
|
|
@@ -352,7 +388,7 @@ function handle(msg: Json): void {
|
|
|
352
388
|
const name = params.name as string;
|
|
353
389
|
const tool = TOOLS[name];
|
|
354
390
|
if (!tool) {
|
|
355
|
-
rpcError(id, -32602,
|
|
391
|
+
rpcError(id, -32602, `Unknown tool: ${name}`);
|
|
356
392
|
return;
|
|
357
393
|
}
|
|
358
394
|
try {
|
|
@@ -374,7 +410,7 @@ function handle(msg: Json): void {
|
|
|
374
410
|
result(id, { prompts: [] });
|
|
375
411
|
return;
|
|
376
412
|
default:
|
|
377
|
-
rpcError(id, -32601,
|
|
413
|
+
rpcError(id, -32601, `Unsupported method: ${method}`);
|
|
378
414
|
}
|
|
379
415
|
}
|
|
380
416
|
|
package/src/parse-file.ts
CHANGED
|
@@ -4,8 +4,8 @@
|
|
|
4
4
|
|
|
5
5
|
import { readFileSync } from "node:fs";
|
|
6
6
|
import { dirname, resolve } from "node:path";
|
|
7
|
-
import type { Model } from "./model.js";
|
|
8
|
-
import { parseWith } from "./parse.js";
|
|
7
|
+
import type { Model } from "./core/model.js";
|
|
8
|
+
import { parseWith } from "./core/parse.js";
|
|
9
9
|
|
|
10
10
|
/** ファイルから読む。import は書かれたファイルからの相対で解決される */
|
|
11
11
|
export function parseFile(filePath: string): Model {
|