@kensnzk/koyu 0.19.0 → 0.20.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 (65) hide show
  1. package/README.ja.md +3 -1
  2. package/README.md +4 -2
  3. package/dist/analysis/contracts.d.ts +11 -1
  4. package/dist/analysis/contracts.d.ts.map +1 -1
  5. package/dist/analysis/contracts.js +11 -1
  6. package/dist/analysis/contracts.js.map +1 -1
  7. package/dist/cli.js +15 -2
  8. package/dist/cli.js.map +1 -1
  9. package/dist/core/diagnose.d.ts +1 -0
  10. package/dist/core/diagnose.d.ts.map +1 -1
  11. package/dist/core/diagnose.js +1 -0
  12. package/dist/core/diagnose.js.map +1 -1
  13. package/dist/core/diff.d.ts.map +1 -1
  14. package/dist/core/diff.js +4 -1
  15. package/dist/core/diff.js.map +1 -1
  16. package/dist/core/model.d.ts +157 -6
  17. package/dist/core/model.d.ts.map +1 -1
  18. package/dist/core/model.js +196 -8
  19. package/dist/core/model.js.map +1 -1
  20. package/dist/core/parse.d.ts.map +1 -1
  21. package/dist/core/parse.js +42 -11
  22. package/dist/core/parse.js.map +1 -1
  23. package/dist/form.d.ts +1 -0
  24. package/dist/form.d.ts.map +1 -1
  25. package/dist/form.js +5 -0
  26. package/dist/form.js.map +1 -1
  27. package/dist/index.d.ts +1 -1
  28. package/dist/index.d.ts.map +1 -1
  29. package/dist/index.js +4 -1
  30. package/dist/index.js.map +1 -1
  31. package/dist/mcp.js +12 -2
  32. package/dist/mcp.js.map +1 -1
  33. package/dist/model.d.ts +1 -1
  34. package/dist/model.d.ts.map +1 -1
  35. package/dist/model.js +1 -1
  36. package/dist/model.js.map +1 -1
  37. package/dist/validate/contracts.d.ts +6 -1
  38. package/dist/validate/contracts.d.ts.map +1 -1
  39. package/dist/validate/contracts.js +6 -1
  40. package/dist/validate/contracts.js.map +1 -1
  41. package/editors/vscode/package.json +1 -1
  42. package/editors/vscode/syntaxes/koyu.tmLanguage.json +55 -55
  43. package/examples/basement/main.muro +1 -1
  44. package/examples/complex/main.muro +1 -1
  45. package/examples/house/main.muro +1 -1
  46. package/examples/house.muro +1 -1
  47. package/examples/mansion.muro +1 -1
  48. package/examples/office.muro +1 -1
  49. package/examples/steps/06-finished.muro +1 -1
  50. package/examples/tower/main.muro +1 -1
  51. package/examples/twin/main.muro +1 -1
  52. package/examples/two-rooms.canonical.json +2 -2
  53. package/examples/two-rooms.muro +1 -1
  54. package/package.json +16 -2
  55. package/src/analysis/contracts.ts +11 -1
  56. package/src/cli.ts +16 -2
  57. package/src/core/diagnose.ts +1 -0
  58. package/src/core/diff.ts +4 -1
  59. package/src/core/model.ts +207 -7
  60. package/src/core/parse.ts +57 -9
  61. package/src/form.ts +13 -0
  62. package/src/index.ts +5 -0
  63. package/src/mcp.ts +18 -2
  64. package/src/model.ts +6 -0
  65. package/src/validate/contracts.ts +6 -1
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "$schema": "https://raw.githubusercontent.com/martinring/tmlanguage/master/tmlanguage.json",
3
- "name": "koyu",
4
- "scopeName": "source.koyu",
3
+ "name": "muro",
4
+ "scopeName": "source.muro",
5
5
  "fileTypes": ["muro"],
6
6
  "information_for_contributors": [
7
7
  "koyu (.muro) の TextMate 文法。VS Code と Shiki (Docusaurus) が同じこの一枚を読む — ADR-0031。",
@@ -39,7 +39,7 @@
39
39
  "repository": {
40
40
  "string": {
41
41
  "comment": "引用符の中は空白も # も保たれる (tokenize) — コメントより先に食う",
42
- "name": "string.quoted.double.koyu",
42
+ "name": "string.quoted.double.muro",
43
43
  "begin": "\"",
44
44
  "end": "\"",
45
45
  "patterns": [{ "match": "." }]
@@ -47,180 +47,180 @@
47
47
  "comment": {
48
48
  "comment": "引用符の外の # 以降は行末までコメント",
49
49
  "match": "#.*$",
50
- "name": "comment.line.number-sign.koyu"
50
+ "name": "comment.line.number-sign.muro"
51
51
  },
52
52
  "line-version": {
53
- "match": "^(koyu)[ \\t]+([0-9][0-9.]*)",
53
+ "match": "^(koyu|muro)[ \\t]+([0-9][0-9.]*)",
54
54
  "captures": {
55
- "1": { "name": "keyword.control.directive.koyu" },
56
- "2": { "name": "constant.numeric.version.koyu" }
55
+ "1": { "name": "keyword.control.directive.muro" },
56
+ "2": { "name": "constant.numeric.version.muro" }
57
57
  }
58
58
  },
59
59
  "line-unit": {
60
60
  "match": "^(unit)[ \\t]+([^\\s#]+)",
61
61
  "captures": {
62
- "1": { "name": "keyword.control.directive.koyu" },
63
- "2": { "name": "constant.language.koyu" }
62
+ "1": { "name": "keyword.control.directive.muro" },
63
+ "2": { "name": "constant.language.muro" }
64
64
  }
65
65
  },
66
66
  "line-name": {
67
67
  "comment": "建物の名 — 行の残りが自由語 (日本語可)",
68
68
  "match": "^(name)[ \\t]+([^#\\n]*)",
69
69
  "captures": {
70
- "1": { "name": "keyword.control.directive.koyu" },
71
- "2": { "name": "string.unquoted.koyu" }
70
+ "1": { "name": "keyword.control.directive.muro" },
71
+ "2": { "name": "string.unquoted.muro" }
72
72
  }
73
73
  },
74
74
  "line-import": {
75
75
  "match": "^(import)[ \\t]+([^\\s#]+)",
76
76
  "captures": {
77
- "1": { "name": "keyword.control.import.koyu" },
78
- "2": { "name": "string.unquoted.path.koyu" }
77
+ "1": { "name": "keyword.control.import.muro" },
78
+ "2": { "name": "string.unquoted.path.muro" }
79
79
  }
80
80
  },
81
81
  "line-asset": {
82
82
  "comment": "asset <名> door|window ...",
83
83
  "match": "^(asset)[ \\t]+(?![^\\s#\"]*:)([^\\s#]+)[ \\t]+(door|window)\\b",
84
84
  "captures": {
85
- "1": { "name": "keyword.control.directive.koyu" },
86
- "2": { "name": "entity.name.function.asset.koyu" },
87
- "3": { "name": "support.type.koyu" }
85
+ "1": { "name": "keyword.control.directive.muro" },
86
+ "2": { "name": "entity.name.function.asset.muro" },
87
+ "3": { "name": "support.type.muro" }
88
88
  }
89
89
  },
90
90
  "line-grid": {
91
91
  "match": "^(grid)[ \\t]+([XY])\\b",
92
92
  "captures": {
93
- "1": { "name": "keyword.control.directive.koyu" },
94
- "2": { "name": "constant.language.axis.koyu" }
93
+ "1": { "name": "keyword.control.directive.muro" },
94
+ "2": { "name": "constant.language.axis.muro" }
95
95
  }
96
96
  },
97
97
  "line-level": {
98
98
  "comment": "level <名|等差範囲> <z> ... — 名はモデル全体の参照子",
99
99
  "match": "^(level)[ \\t]+(?![^\\s#\"]*:)([^\\s#]+)",
100
100
  "captures": {
101
- "1": { "name": "keyword.control.directive.koyu" },
102
- "2": { "name": "entity.name.type.level.koyu" }
101
+ "1": { "name": "keyword.control.directive.muro" },
102
+ "2": { "name": "entity.name.type.level.muro" }
103
103
  }
104
104
  },
105
105
  "line-stack": {
106
106
  "match": "^(stack)[ \\t]+(?![^\\s#\"]*:)([^\\s#]+)",
107
107
  "captures": {
108
- "1": { "name": "keyword.control.directive.koyu" },
109
- "2": { "name": "entity.name.function.stack.koyu" }
108
+ "1": { "name": "keyword.control.directive.muro" },
109
+ "2": { "name": "entity.name.function.stack.muro" }
110
110
  }
111
111
  },
112
112
  "line-band": {
113
113
  "match": "^(band)[ \\t]+([XY])\\b",
114
114
  "captures": {
115
- "1": { "name": "keyword.control.directive.koyu" },
116
- "2": { "name": "constant.language.axis.koyu" }
115
+ "1": { "name": "keyword.control.directive.muro" },
116
+ "2": { "name": "constant.language.axis.muro" }
117
117
  }
118
118
  },
119
119
  "line-boundary": {
120
120
  "comment": "boundary <パス> <パス> — 壁は物ではなく二つの空間の関係である",
121
121
  "match": "^(boundary)[ \\t]+(/[^\\s#\"]+)[ \\t]+(/[^\\s#\"]+)",
122
122
  "captures": {
123
- "1": { "name": "keyword.control.directive.koyu" },
124
- "2": { "name": "entity.name.type.path.koyu" },
125
- "3": { "name": "entity.name.type.path.koyu" }
123
+ "1": { "name": "keyword.control.directive.muro" },
124
+ "2": { "name": "entity.name.type.path.muro" },
125
+ "3": { "name": "entity.name.type.path.muro" }
126
126
  }
127
127
  },
128
128
  "line-zone": {
129
129
  "match": "^(zone)[ \\t]+(/[^\\s#\"]+)",
130
130
  "captures": {
131
- "1": { "name": "keyword.control.directive.koyu" },
132
- "2": { "name": "entity.name.type.path.koyu" }
131
+ "1": { "name": "keyword.control.directive.muro" },
132
+ "2": { "name": "entity.name.type.path.muro" }
133
133
  }
134
134
  },
135
135
  "line-polygon": {
136
136
  "match": "^(polygon)[ \\t]+(/[^\\s#\"]+)",
137
137
  "captures": {
138
- "1": { "name": "keyword.control.directive.koyu" },
139
- "2": { "name": "entity.name.type.path.koyu" }
138
+ "1": { "name": "keyword.control.directive.muro" },
139
+ "2": { "name": "entity.name.type.path.muro" }
140
140
  }
141
141
  },
142
142
  "line-space": {
143
143
  "comment": "space <パス> <型> ... — 字下げした space は帯 (band) の要素。型は開かれた語彙",
144
144
  "match": "^([ \\t]*)(space)[ \\t]+(/[^\\s#\"]+)(?:[ \\t]+(?![^\\s#\"]*:)([^\\s#]+))?",
145
145
  "captures": {
146
- "2": { "name": "keyword.control.directive.koyu" },
147
- "3": { "name": "entity.name.type.path.koyu" },
148
- "4": { "name": "support.type.koyu" }
146
+ "2": { "name": "keyword.control.directive.muro" },
147
+ "3": { "name": "entity.name.type.path.muro" },
148
+ "4": { "name": "support.type.muro" }
149
149
  }
150
150
  },
151
151
  "line-opening": {
152
152
  "comment": "door/window の第1トークンが k:v でなければアセット参照 (ADR-0010)",
153
153
  "match": "^([ \\t]+)(door|window)[ \\t]+(?![^\\s#\"]*:)([^\\s#]+)",
154
154
  "captures": {
155
- "2": { "name": "keyword.other.child.koyu" },
156
- "3": { "name": "entity.name.function.asset.koyu" }
155
+ "2": { "name": "keyword.other.child.muro" },
156
+ "3": { "name": "entity.name.function.asset.muro" }
157
157
  }
158
158
  },
159
159
  "keyword-child": {
160
160
  "comment": "字下げして書く語 — src/core/parse.ts の indented 分岐。+ / - / = は over の下の集合編集 (ADR-0035)",
161
161
  "match": "^[ \\t]+(door|window|seg|line|area|space)\\b",
162
- "captures": { "1": { "name": "keyword.other.child.koyu" } }
162
+ "captures": { "1": { "name": "keyword.other.child.muro" } }
163
163
  },
164
164
  "keyword-edit": {
165
165
  "comment": "over の下の集合編集 — + 追加 / - 削除 / = 置換 (ADR-0035)",
166
166
  "match": "^[ \\t]+([+=-])(?=[ \\t])",
167
- "captures": { "1": { "name": "keyword.operator.edit.koyu" } }
167
+ "captures": { "1": { "name": "keyword.operator.edit.muro" } }
168
168
  },
169
169
  "keyword-directive": {
170
170
  "comment": "行頭に書く語 — src/core/parse.ts の switch (head)",
171
- "match": "^(koyu|import|over|drop|asset|polygon|origin|azimuth|name|unit|grid|level|column|band|space|boundary|zone|stack)\\b",
172
- "captures": { "1": { "name": "keyword.control.directive.koyu" } }
171
+ "match": "^(koyu|muro|import|over|drop|asset|polygon|origin|azimuth|name|unit|grid|level|column|band|space|boundary|zone|stack)\\b",
172
+ "captures": { "1": { "name": "keyword.control.directive.muro" } }
173
173
  },
174
174
  "path": {
175
175
  "comment": "空間・ゾーンのパス — /L1/a /out /L2..L9/A",
176
176
  "match": "(?:^|[ \\t])(/[^\\s#\"]*)",
177
- "captures": { "1": { "name": "entity.name.type.path.koyu" } }
177
+ "captures": { "1": { "name": "entity.name.type.path.muro" } }
178
178
  },
179
179
  "attr-ledger": {
180
180
  "comment": "The ledger keys that are not carrier-tier — the attributes the tools act on. ATTR_LEDGER in src/core/vocabulary.ts is the contract; free k:v gets a different colour",
181
181
  "match": "\\b(underground|escalator|elevation|daylight|northing|vertical|ceiling|landing|outside|easting|hinge|level|riser|slope|stair|style|swing|tread|pitch|entry|lane|lift|form|road|slab|site|area|turn|type|edge|name|ramp|void|epsg|uid|air|use|at|h|w|t|d|x|y)(:)",
182
182
  "captures": {
183
- "1": { "name": "entity.other.attribute-name.koyu" },
184
- "2": { "name": "punctuation.separator.key-value.koyu" }
183
+ "1": { "name": "entity.other.attribute-name.muro" },
184
+ "2": { "name": "punctuation.separator.key-value.muro" }
185
185
  }
186
186
  },
187
187
  "attr-free": {
188
188
  "comment": "台帳に無い k:v — 運ばれるが解釈されない (規則2・3)",
189
189
  "match": "\\b([A-Za-z_][A-Za-z0-9_-]*)(:)",
190
190
  "captures": {
191
- "1": { "name": "variable.other.property.koyu" },
192
- "2": { "name": "punctuation.separator.key-value.koyu" }
191
+ "1": { "name": "variable.other.property.muro" },
192
+ "2": { "name": "punctuation.separator.key-value.muro" }
193
193
  }
194
194
  },
195
195
  "gridref": {
196
196
  "comment": "通り芯参照とオフセット — X2 / X2+600 / X1..X2 / X1+3200..X2+3200",
197
197
  "match": "\\b([XY][0-9]+)((?:[+-][0-9]+)?)(?:(\\.\\.)([XY][0-9]+)((?:[+-][0-9]+)?))?",
198
198
  "captures": {
199
- "1": { "name": "constant.language.gridref.koyu" },
200
- "2": { "name": "constant.numeric.offset.koyu" },
201
- "3": { "name": "keyword.operator.range.koyu" },
202
- "4": { "name": "constant.language.gridref.koyu" },
203
- "5": { "name": "constant.numeric.offset.koyu" }
199
+ "1": { "name": "constant.language.gridref.muro" },
200
+ "2": { "name": "constant.numeric.offset.muro" },
201
+ "3": { "name": "keyword.operator.range.muro" },
202
+ "4": { "name": "constant.language.gridref.muro" },
203
+ "5": { "name": "constant.numeric.offset.muro" }
204
204
  }
205
205
  },
206
206
  "range": {
207
207
  "comment": "レベルの範囲 — B2..L5 L14..L19",
208
208
  "match": "\\b([A-Za-z][A-Za-z0-9_]*)(\\.\\.)([A-Za-z][A-Za-z0-9_]*)\\b",
209
209
  "captures": {
210
- "1": { "name": "entity.name.type.level.koyu" },
211
- "2": { "name": "keyword.operator.range.koyu" },
212
- "3": { "name": "entity.name.type.level.koyu" }
210
+ "1": { "name": "entity.name.type.level.muro" },
211
+ "2": { "name": "keyword.operator.range.muro" },
212
+ "3": { "name": "entity.name.type.level.muro" }
213
213
  }
214
214
  },
215
215
  "union": {
216
216
  "comment": "領域の合併 — L字は矩形を + でつなぐ",
217
217
  "match": "(?<=[ \\t])\\+(?=[ \\t])",
218
- "name": "keyword.operator.union.koyu"
218
+ "name": "keyword.operator.union.muro"
219
219
  },
220
220
  "number": {
221
221
  "comment": "長さはmm、面積は㎡、比率は0..1。名の中の数字 (南区画01) は数値ではないので、前後が区切りのときだけ採る",
222
222
  "match": "(?<![^\\s,:])-?[0-9]+(?:\\.[0-9]+)?(?![^\\s,#])",
223
- "name": "constant.numeric.koyu"
223
+ "name": "constant.numeric.muro"
224
224
  }
225
225
  }
226
226
  }
@@ -11,7 +11,7 @@
11
11
  # * 地下は level の underground:1 という宣言。zの負値からは推定しない (ADR-0022)。
12
12
  # * 土に接する壁は spec 語彙 (spec:RC土圧壁)。境界の型は増やさない — 物の名は spec である。
13
13
 
14
- koyu 1.1
14
+ muro 1.2
15
15
  name 地下駐車場 — 縦動線の最小例
16
16
  unit mm
17
17
 
@@ -16,7 +16,7 @@
16
16
  # koyu site examples/complex/main.muro 敷地・接道
17
17
  # koyu plan examples/complex/main.muro -l L1 -o out/c-L1.svg
18
18
 
19
- koyu 1.1
19
+ muro 1.2
20
20
  name 特大複合建築 — 商業・事務所・ホテル
21
21
  unit mm
22
22
 
@@ -4,7 +4,7 @@
4
4
  # 合成時にコンフリクト (パス・アセット・グリッドの重複) が検査され、一棟としてビルドされる。
5
5
  # koyu check examples/house/main.muro がそのビルドの門番になる。
6
6
 
7
- koyu 1.1
7
+ muro 1.2
8
8
  name 小さな戸建住宅
9
9
  unit mm
10
10
 
@@ -7,7 +7,7 @@
7
7
  # 敷地 = zone site:1 (宣言面積と導出面積を site コマンドが突き合わせる)。
8
8
  # L1の平面図はそのまま配置図兼用になる。
9
9
 
10
- koyu 1.1
10
+ muro 1.2
11
11
  name 小さな戸建住宅
12
12
  unit mm
13
13
 
@@ -4,7 +4,7 @@
4
4
  # 外部に対し open または air:1 (手すり等、遮蔽しない物) の境界を持つ空間として導出される)。
5
5
  # 基準階は一度だけ書く — /L2..L9/ のスパンが8フロアに展開される。
6
6
 
7
- koyu 1.1
7
+ muro 1.2
8
8
  name 内廊下型集合住宅
9
9
  unit mm
10
10
 
@@ -2,7 +2,7 @@
2
2
  # 基本計画の解像度で書く。垂れ壁や建具詳細は表現しない — 省略ではなく抽象度の選択。
3
3
  # 高さの一貫性は level の宣言 (z / h / slab) と check の不変量が担保する。
4
4
 
5
- koyu 1.1
5
+ muro 1.2
6
6
  name 小さなオフィス
7
7
  unit mm
8
8
 
@@ -1,4 +1,4 @@
1
- koyu 1.1
1
+ muro 1.2
2
2
  name 小さな家
3
3
 
4
4
  grid X 0 3600 5400
@@ -5,7 +5,7 @@
5
5
  # L1-L2 商業 / L3-L10 住宅基準階 (L3は低層部屋根のテラス付き例外階) / L11 ペントハウス
6
6
  # koyu check examples/tower/main.muro が一棟のビルドの門番。
7
7
 
8
- koyu 1.1
8
+ muro 1.2
9
9
  name 街角の複合ビル — 低層商業+高層住宅
10
10
  unit mm
11
11
 
@@ -29,7 +29,7 @@
29
29
  # koyu plan examples/twin/main.muro -l L8 A棟基準階とB棟ホテル階
30
30
  # koyu axo examples/twin/main.muro -l L1,L2,L3,L4,L5
31
31
 
32
- koyu 1.1
32
+ muro 1.2
33
33
  name 双塔複合建築 — 商業・事務所・ホテル・レジデンス
34
34
  unit mm
35
35
 
@@ -1,6 +1,6 @@
1
1
  {
2
- "format": "koyu-canonical/1.2",
3
- "koyu": "1.1",
2
+ "format": "koyu-canonical/2.0",
3
+ "muro": "1.2",
4
4
  "name": "二室",
5
5
  "unit": "mm",
6
6
  "grid": {
@@ -4,7 +4,7 @@
4
4
  # 書いてあるのは、扉を吊るために宣言した境界と、外皮の境界だけ。
5
5
  # 両室に daylight:1 を書いたので、窓が要る — `koyu light` が 1/7 を確かめる (ADR-0020)。
6
6
 
7
- koyu 1.1
7
+ muro 1.2
8
8
  name 二室
9
9
  unit mm
10
10
 
package/package.json CHANGED
@@ -1,6 +1,20 @@
1
1
  {
2
2
  "name": "@kensnzk/koyu",
3
- "version": "0.19.0",
3
+ "version": "0.20.0",
4
+ "muro": {
5
+ "reads": [
6
+ "0.1",
7
+ "0.2",
8
+ "0.3",
9
+ "0.4",
10
+ "0.5",
11
+ "1.0",
12
+ "1.1",
13
+ "1.2"
14
+ ],
15
+ "newest": "1.2",
16
+ "undeclared": "1.1"
17
+ },
4
18
  "description": "空間を一次要素とするテキストネイティブ建築記述の探求 — writing architecture, not buildings",
5
19
  "type": "module",
6
20
  "main": "./dist/index.js",
@@ -82,7 +96,7 @@
82
96
  "gate:examples": "node --import tsx scripts/gate.mjs",
83
97
  "plan:examples": "tsx src/cli.ts plan examples/two-rooms.muro -o out/two-rooms.svg",
84
98
  "conformance": "node --import tsx --test test/conformance.test.ts",
85
- "gate:docs": "npm --prefix website run gate:canonical && npm --prefix website run check:navigation"
99
+ "gate:docs": "npm --prefix website run prepare:content && npm --prefix website run gate:canonical && npm --prefix website run check:navigation"
86
100
  },
87
101
  "devDependencies": {
88
102
  "@types/node": "^22.0.0",
@@ -218,7 +218,17 @@ export interface AnalysisResult<T extends JsonValue = JsonValue> {
218
218
  readonly artifact: AnalysisArtifact<T>;
219
219
  }
220
220
 
221
- export const ANALYSIS_FORMAT = "koyu-analysis/1" as const;
221
+ /**
222
+ * The name of the shape an analysis returns. **It carries no version, deliberately.**
223
+ *
224
+ * A version promises that something is worth checking against — and nothing checks this. It
225
+ * is written by `assess` and read by no one; the face it sits on is the one the project
226
+ * declares unfrozen, so a `/1` on it would announce a stability nobody intends to keep.
227
+ *
228
+ * The counter-example is `koyu-context/1`, the input this protocol takes: that one is checked
229
+ * on arrival and refused on mismatch, which is what makes its version worth carrying.
230
+ */
231
+ export const ANALYSIS_FORMAT = "koyu-analysis" as const;
222
232
 
223
233
  export interface AnalysisReport<T extends JsonValue = JsonValue> {
224
234
  readonly schema: typeof ANALYSIS_FORMAT;
package/src/cli.ts CHANGED
@@ -35,7 +35,8 @@ import {
35
35
  type Model,
36
36
  srcRef,
37
37
  isOutside,
38
- isVoid
38
+ isVoid,
39
+ versionLine
39
40
  } from "./core/model.js";
40
41
  import { parseFile } from "./parse-file.js";
41
42
  import { svgPlan } from "./draw/plan.js";
@@ -190,6 +191,18 @@ function firstModelLine(evidence: AssessmentReport["findings"][number]["outcome"
190
191
 
191
192
  function main(argv: string[]): number {
192
193
  const [cmd, file, ...rest] = argv;
194
+ // Asked before the usage text, because it takes no file and a tool that cannot state its
195
+ // own version sends the reader to package.json to find out what they are running.
196
+ if (cmd === "--version" || cmd === "-v") {
197
+ // It takes no file, so being handed one is a calling mistake like any other. Printing the
198
+ // version and exiting 0 would let a wrapper that passes the wrong flag look like it worked.
199
+ if (file !== undefined) {
200
+ console.error(`--version takes no arguments: ${[file, ...rest].join(" ")}`);
201
+ return 2;
202
+ }
203
+ console.log(versionLine());
204
+ return 0;
205
+ }
193
206
  if (!cmd || !file) {
194
207
  console.log(
195
208
  "Usage: koyu <check|validate|layers|diff|plan|axo|doors|graph|stats|levels|runs|light|site|json> <file.muro> [args...]\n" +
@@ -240,7 +253,8 @@ function main(argv: string[]): number {
240
253
  // check --json は構文・合成エラー (SourceError) でも有効JSONを返す — SYN01 の1件に写す (ADR-0016)
241
254
  if (cmd === "check" && rest.includes("--json") && e instanceof SourceError) {
242
255
  const d: Diagnostic = {
243
- code: "SYN01",
256
+ // A parse failure that named its own condition keeps that code; the rest are syntax.
257
+ code: e.code ?? "SYN01",
244
258
  severity: "error",
245
259
  message: e.raw,
246
260
  ...(e.line ? { line: e.line } : {}),
@@ -126,6 +126,7 @@ export const DIAGNOSTIC_CODES = {
126
126
  VER03: "error", // koyu 0.4以前のファイルに0.5の語 (縦動線・線・柱・地下)
127
127
  VER04: "error", // koyu 0.5以前のファイルに1.0の語 (over・drop・集合編集 — ADR-0035/0038)
128
128
  VER05: "error", // koyu 1.0以前のファイルの型の位置に exterior / void (ADR-0051)
129
+ VER06: "error", // the file declares a language version newer than this build reads
129
130
  SYN01: "error", // 構文・合成エラー (SourceError の写し — check --json のみ)
130
131
  } as const satisfies Record<string, "error" | "warning">;
131
132
 
package/src/core/diff.ts CHANGED
@@ -686,7 +686,10 @@ export function renderDiff(d: ModelDiff): string[] {
686
686
  else if (g.kind === "added") out.push(`+ grid ${g.axis} ${g.name} ${g.to}`);
687
687
  else out.push(`− grid ${g.axis} ${g.name} ${g.from}`);
688
688
  }
689
- if (d.version) out.push(`± koyu ${d.version.from} → ${d.version.to}`);
689
+ // **The label names the language, not the implementation.** It also may not be the written
690
+ // declaration: from 1.2 the word is `muro`, so printing `koyu 1.2` would show a line the
691
+ // parser refuses. This is a label for a change, not a copy of either file's first line.
692
+ if (d.version) out.push(`± muro ${d.version.from} → ${d.version.to}`);
690
693
  if (d.name) out.push(`± name ${d.name.from ?? "—"} → ${d.name.to ?? "—"}`);
691
694
  for (const n of d.levels.added) out.push(`+ level ${n}`);
692
695
  for (const n of d.levels.removed) out.push(`− level ${n}`);