@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.
- package/README.ja.md +3 -1
- package/README.md +4 -2
- package/dist/analysis/contracts.d.ts +11 -1
- package/dist/analysis/contracts.d.ts.map +1 -1
- package/dist/analysis/contracts.js +11 -1
- package/dist/analysis/contracts.js.map +1 -1
- package/dist/cli.js +15 -2
- package/dist/cli.js.map +1 -1
- package/dist/core/diagnose.d.ts +1 -0
- package/dist/core/diagnose.d.ts.map +1 -1
- package/dist/core/diagnose.js +1 -0
- package/dist/core/diagnose.js.map +1 -1
- package/dist/core/diff.d.ts.map +1 -1
- package/dist/core/diff.js +4 -1
- package/dist/core/diff.js.map +1 -1
- package/dist/core/model.d.ts +157 -6
- package/dist/core/model.d.ts.map +1 -1
- package/dist/core/model.js +196 -8
- package/dist/core/model.js.map +1 -1
- package/dist/core/parse.d.ts.map +1 -1
- package/dist/core/parse.js +42 -11
- package/dist/core/parse.js.map +1 -1
- package/dist/form.d.ts +1 -0
- package/dist/form.d.ts.map +1 -1
- package/dist/form.js +5 -0
- package/dist/form.js.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +4 -1
- package/dist/index.js.map +1 -1
- package/dist/mcp.js +12 -2
- package/dist/mcp.js.map +1 -1
- package/dist/model.d.ts +1 -1
- package/dist/model.d.ts.map +1 -1
- package/dist/model.js +1 -1
- package/dist/model.js.map +1 -1
- package/dist/validate/contracts.d.ts +6 -1
- package/dist/validate/contracts.d.ts.map +1 -1
- package/dist/validate/contracts.js +6 -1
- package/dist/validate/contracts.js.map +1 -1
- package/editors/vscode/package.json +1 -1
- package/editors/vscode/syntaxes/koyu.tmLanguage.json +55 -55
- package/examples/basement/main.muro +1 -1
- package/examples/complex/main.muro +1 -1
- package/examples/house/main.muro +1 -1
- package/examples/house.muro +1 -1
- package/examples/mansion.muro +1 -1
- package/examples/office.muro +1 -1
- package/examples/steps/06-finished.muro +1 -1
- package/examples/tower/main.muro +1 -1
- package/examples/twin/main.muro +1 -1
- package/examples/two-rooms.canonical.json +2 -2
- package/examples/two-rooms.muro +1 -1
- package/package.json +16 -2
- package/src/analysis/contracts.ts +11 -1
- package/src/cli.ts +16 -2
- package/src/core/diagnose.ts +1 -0
- package/src/core/diff.ts +4 -1
- package/src/core/model.ts +207 -7
- package/src/core/parse.ts +57 -9
- package/src/form.ts +13 -0
- package/src/index.ts +5 -0
- package/src/mcp.ts +18 -2
- package/src/model.ts +6 -0
- package/src/validate/contracts.ts +6 -1
package/src/core/model.ts
CHANGED
|
@@ -8,11 +8,185 @@ export type AttrValue = string | number;
|
|
|
8
8
|
export type Attrs = Record<string, AttrValue>;
|
|
9
9
|
|
|
10
10
|
/**
|
|
11
|
-
*
|
|
12
|
-
*
|
|
11
|
+
* The correspondence between the two version lines, and the only place it is recorded.
|
|
12
|
+
*
|
|
13
|
+
* muro is the language; koyu is the implementation that reads it. They are counted
|
|
14
|
+
* separately because they promise different things, and until this ledger existed nothing
|
|
15
|
+
* said which koyu implemented which muro — the published norm asserted the declaration in
|
|
16
|
+
* prose while no such declaration existed on any surface.
|
|
17
|
+
*
|
|
18
|
+
* - `muro` the language version, as written in a `.muro` file
|
|
19
|
+
* - `since` the koyu version that first read it. **A version that shipped** — `1.0.0-rc.1`
|
|
20
|
+
* carried muro 1.0 in the tree but never reached npm, so muro 1.0 arrived for
|
|
21
|
+
* anyone outside this repository at 0.16.0, and that is what this records
|
|
22
|
+
* - `until` the last koyu version that reads it, once a version is retired. Empty on every
|
|
23
|
+
* row: nothing has been retired. The field exists so that retiring is filling in
|
|
24
|
+
* a value rather than reshaping the ledger
|
|
25
|
+
*
|
|
26
|
+
* **The order of this array is the order of the versions, oldest first.** Comparison is by
|
|
27
|
+
* index, never by spelling — as strings, "0.5" sorts after "1.0".
|
|
28
|
+
*
|
|
29
|
+
* Cutting a language version is adding a row here. `test/release.test.ts` holds that: a
|
|
30
|
+
* release that moves the newest version must carry a row whose `since` is its own version.
|
|
31
|
+
*/
|
|
32
|
+
export const MURO_SUPPORT: readonly { muro: string; since: string; until: string | null }[] = [
|
|
33
|
+
// The `koyu` keyword was read from the first commit, accepting whatever followed it.
|
|
34
|
+
{ muro: "0.1", since: "0.0.1", until: null },
|
|
35
|
+
// 0.9.0 introduced the accepted-version list, and with it the first rejection.
|
|
36
|
+
{ muro: "0.2", since: "0.9.0", until: null },
|
|
37
|
+
{ muro: "0.3", since: "0.11.0", until: null },
|
|
38
|
+
{ muro: "0.4", since: "0.11.0", until: null },
|
|
39
|
+
{ muro: "0.5", since: "0.11.0", until: null },
|
|
40
|
+
// Not 1.0.0-rc.1. That version set muro 1.0 in the tree and was never published; the
|
|
41
|
+
// implementation version was returned to the 0.x line and shipped as 0.16.0 instead.
|
|
42
|
+
{ muro: "1.0", since: "0.16.0", until: null },
|
|
43
|
+
{ muro: "1.1", since: "0.17.0", until: null },
|
|
44
|
+
// The version line stops answering to the implementation's name: `muro 1.2`, not `koyu 1.2`.
|
|
45
|
+
{ muro: "1.2", since: "0.20.0", until: null },
|
|
46
|
+
];
|
|
47
|
+
|
|
48
|
+
/** The word a version line is written with from 1.2 on. */
|
|
49
|
+
export const MURO_KEYWORD = "muro";
|
|
50
|
+
|
|
51
|
+
/**
|
|
52
|
+
* The last version whose line is spelled `koyu`.
|
|
53
|
+
*
|
|
54
|
+
* **One spelling per version, never both.** Up to and including this version a file declares
|
|
55
|
+
* itself `koyu <v>`, and from the next one it declares itself `muro <v>`. Accepting both for
|
|
56
|
+
* the same version would give one declaration two spellings, and the canonical form's
|
|
57
|
+
* uniqueness — which the whole conformance suite rests on — would go with it.
|
|
58
|
+
*
|
|
59
|
+
* Files written before 1.2 keep the old spelling and keep meaning exactly what they meant.
|
|
60
|
+
* Nothing migrates, and nothing has to.
|
|
61
|
+
*/
|
|
62
|
+
export const LAST_KOYU_SPELLED_VERSION = "1.1";
|
|
63
|
+
|
|
64
|
+
/**
|
|
65
|
+
* This implementation's own version — the one npm installs, held in step with `package.json`
|
|
66
|
+
* by `test/release.test.ts`.
|
|
67
|
+
*
|
|
68
|
+
* It sits beside `MURO_SUPPORT` because the two are one fact read from two directions: the
|
|
69
|
+
* `since` column is written in this vocabulary, and every surface that answers "which muro
|
|
70
|
+
* does this build speak" needs both halves at once.
|
|
71
|
+
*/
|
|
72
|
+
export const KOYU_VERSION = "0.20.0";
|
|
73
|
+
|
|
74
|
+
/**
|
|
75
|
+
* Whether `a` names a later language version than `b`.
|
|
76
|
+
*
|
|
77
|
+
* **Not by index in the ledger** — the whole point is to answer for a version the ledger has
|
|
78
|
+
* never heard of, which is what a file from the future carries. Compared as numbers, because
|
|
79
|
+
* as strings `"0.5" > "1.0"`. A spelling that is not `major.minor` is not a version at all
|
|
80
|
+
* and is never "newer": it is unreadable, which is a different answer.
|
|
81
|
+
*/
|
|
82
|
+
export function isNewerVersion(a: string, b: string): boolean {
|
|
83
|
+
const shape = /^(\d+)\.(\d+)$/;
|
|
84
|
+
const pa = shape.exec(a);
|
|
85
|
+
const pb = shape.exec(b);
|
|
86
|
+
if (!pa || !pb) return false;
|
|
87
|
+
const major = Number(pa[1]) - Number(pb[1]);
|
|
88
|
+
return major !== 0 ? major > 0 : Number(pa[2]) > Number(pb[2]);
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
/**
|
|
92
|
+
* What this build reads, what the newest version is, and how an undeclared file is read.
|
|
93
|
+
*
|
|
94
|
+
* The last two are separate facts and only coincide today. Once a newer version exists they
|
|
95
|
+
* differ permanently, and the line has to say both or it is telling half the truth to the
|
|
96
|
+
* person most likely to be surprised by it.
|
|
97
|
+
*/
|
|
98
|
+
export function versionLine(): string {
|
|
99
|
+
const read = SUPPORTED_LANGUAGE_VERSIONS;
|
|
100
|
+
const range = `${read[0]}–${read[read.length - 1]}`;
|
|
101
|
+
return `koyu ${KOYU_VERSION} — reads muro ${range} (newest ${NEWEST_LANGUAGE_VERSION}; a file with no version line is read as ${DEFAULT_LANGUAGE_VERSION})`;
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
/**
|
|
105
|
+
* The koyu version that first read this muro version, or `undefined` if no such version is
|
|
106
|
+
* accepted. This is the direction a downstream needs: it depends on a language version and
|
|
107
|
+
* has to turn that into a package range.
|
|
108
|
+
*/
|
|
109
|
+
export function koyuSince(muro: string): string | undefined {
|
|
110
|
+
return MURO_SUPPORT.find((r) => r.muro === muro)?.since;
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
/**
|
|
114
|
+
* Whether this build reads the given muro version.
|
|
115
|
+
*
|
|
116
|
+
* **What a downstream actually depends on is a language version, not a package range.** An
|
|
117
|
+
* application that writes `muro 1.1` needs a koyu that reads 1.1; which koyu that is, is the
|
|
118
|
+
* ledger's business, not the application's. Asserting this at startup turns a version skew
|
|
119
|
+
* into one sentence instead of a parse error somewhere later.
|
|
120
|
+
*/
|
|
121
|
+
export function speaksMuro(muro: string): boolean {
|
|
122
|
+
return SUPPORTED_LANGUAGE_VERSIONS.includes(muro);
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
/**
|
|
126
|
+
* Throw unless this build reads the given muro version, naming what would fix it.
|
|
127
|
+
*
|
|
128
|
+
* Separate from `speaksMuro` because the useful thing at a startup check is the message: the
|
|
129
|
+
* caller knows the version it needs and nothing else, and the ledger is the only place that
|
|
130
|
+
* can say which koyu to install for it.
|
|
131
|
+
*/
|
|
132
|
+
export function requireMuro(muro: string): void {
|
|
133
|
+
if (speaksMuro(muro)) return;
|
|
134
|
+
const row = MURO_SUPPORT.find((r) => r.muro === muro);
|
|
135
|
+
const head = `This build of koyu (${KOYU_VERSION}) does not read muro ${muro}.`;
|
|
136
|
+
// A row with `until` set is retired, and the advice is the opposite of the usual one:
|
|
137
|
+
// a newer koyu will not help, because newer is what dropped it.
|
|
138
|
+
if (row?.until) {
|
|
139
|
+
throw new Error(
|
|
140
|
+
`${head} It was retired after koyu ${row.until} — migrate the file, or install koyu ${row.until} or earlier.`,
|
|
141
|
+
);
|
|
142
|
+
}
|
|
143
|
+
if (row) throw new Error(`${head} It arrived in koyu ${row.since} — install koyu ${row.since} or later.`);
|
|
144
|
+
// **No row is not evidence that no koyu reads it.** A build only carries the rows compiled
|
|
145
|
+
// into it, so a version released after this one looks exactly like a version that never
|
|
146
|
+
// existed. Saying which is which is not this build's to say; saying what it knows is.
|
|
147
|
+
const newer = isNewerVersion(muro, NEWEST_LANGUAGE_VERSION);
|
|
148
|
+
throw new Error(
|
|
149
|
+
newer
|
|
150
|
+
? `${head} It is newer than anything this build knows (it reads up to ${NEWEST_LANGUAGE_VERSION}) — upgrade koyu.`
|
|
151
|
+
: `${head} This build reads ${SUPPORTED_LANGUAGE_VERSIONS.join(", ")}.`,
|
|
152
|
+
);
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
/**
|
|
156
|
+
* The language versions this build accepts (ADR-0017). An older version is accepted only
|
|
157
|
+
* where the meaning is preserved; `check` is what decides that.
|
|
158
|
+
*
|
|
159
|
+
* **Derived from `MURO_SUPPORT`, not declared beside it.** Two lists of one fact is how the
|
|
160
|
+
* correspondence drifted in the first place.
|
|
161
|
+
*/
|
|
162
|
+
export const SUPPORTED_LANGUAGE_VERSIONS: readonly string[] = MURO_SUPPORT.filter(
|
|
163
|
+
(r) => r.until === null,
|
|
164
|
+
).map((r) => r.muro);
|
|
165
|
+
|
|
166
|
+
/**
|
|
167
|
+
* The newest language version this build accepts — what to declare to get everything.
|
|
168
|
+
* Derived, for the same reason as above.
|
|
169
|
+
*/
|
|
170
|
+
export const NEWEST_LANGUAGE_VERSION = SUPPORTED_LANGUAGE_VERSIONS[SUPPORTED_LANGUAGE_VERSIONS.length - 1]!;
|
|
171
|
+
|
|
172
|
+
/**
|
|
173
|
+
* How a file with no version line is read. **Frozen at 1.1, and it does not follow the newest
|
|
174
|
+
* version.**
|
|
175
|
+
*
|
|
176
|
+
* It used to be the newest, which meant an undeclared file was re-read under new semantics
|
|
177
|
+
* every time the tool moved — silently, because nothing reports the absence of a declaration.
|
|
178
|
+
* That is not hypothetical: the 1.0 → 1.1 move read `exterior` out of the type position, and
|
|
179
|
+
* undeclared files written in the old dialect lost their outside spaces without a word.
|
|
180
|
+
*
|
|
181
|
+
* Freezing removes the danger rather than reporting it. **Newer semantics are opt-in: you get
|
|
182
|
+
* them by naming them.** The cost is that an undeclared file never gets new notation, which is
|
|
183
|
+
* the same statement read from the other side.
|
|
184
|
+
*
|
|
185
|
+
* Freezing this was not itself a version bump: at the moment it froze, the frozen value and
|
|
186
|
+
* the newest version were both 1.1, so no file that existed read differently. They part
|
|
187
|
+
* company from 1.2 on, and that gap is the whole point — an old file that names no version
|
|
188
|
+
* does not quietly become a 1.2 file.
|
|
13
189
|
*/
|
|
14
|
-
export const SUPPORTED_LANGUAGE_VERSIONS: readonly string[] = ["0.1", "0.2", "0.3", "0.4", "0.5", "1.0", "1.1"];
|
|
15
|
-
/** 版宣言を省略したときの解釈 — 常に最新版の意味論 (省略はツール版を跨いで意味安定ではない) */
|
|
16
190
|
export const DEFAULT_LANGUAGE_VERSION = "1.1";
|
|
17
191
|
|
|
18
192
|
/**
|
|
@@ -20,9 +194,19 @@ export const DEFAULT_LANGUAGE_VERSION = "1.1";
|
|
|
20
194
|
* 数えるのは綴りだけである。minorはキーが増えたとき、majorは既存のキーの名前・並び・照合順・
|
|
21
195
|
* 正規化・数の綴りが変わったとき。**minorでも全ての文書のバイトは動く** — この文字列自体が
|
|
22
196
|
* 第一キーだからで、増えたキーを持たない文書も先頭行だけは変わる (ADR-0051 が実測している)。
|
|
23
|
-
* 意味論の版は muro が持つので、`
|
|
197
|
+
* 意味論の版は muro が持つので、`muro` キー (書かれた版宣言の素通し) とは別の面である。
|
|
198
|
+
*
|
|
199
|
+
* The format keeps the name `koyu` because it is the implementation's output spelling — the
|
|
200
|
+
* shape koyu writes. The key inside it names the language, and is spelled `muro` for the same
|
|
201
|
+
* reason the version line is.
|
|
202
|
+
*
|
|
203
|
+
* **That rename is why this is 2.0 and not 1.3.** An existing key changed its name, which the
|
|
204
|
+
* rule above puts squarely in major. Shipping it as a minor would have told every reader that
|
|
205
|
+
* `1.x` stays compatible — so a reader expecting `koyu` would have accepted the document and
|
|
206
|
+
* found no language version in it, which is the silent misread the format version exists to
|
|
207
|
+
* prevent.
|
|
24
208
|
*/
|
|
25
|
-
export const CANONICAL_FORMAT = "koyu-canonical/
|
|
209
|
+
export const CANONICAL_FORMAT = "koyu-canonical/2.0";
|
|
26
210
|
|
|
27
211
|
/** 方位。edge指定は「最初に書いた空間」の矩形から見た辺。N=+Y, S=-Y, E=+X, W=-X */
|
|
28
212
|
export type Edge = "N" | "E" | "S" | "W";
|
|
@@ -461,6 +645,19 @@ export class SourceError extends Error {
|
|
|
461
645
|
public raw: string,
|
|
462
646
|
/** 出所ファイル (合成時) */
|
|
463
647
|
public file?: string,
|
|
648
|
+
/**
|
|
649
|
+
* The diagnostic code this failure carries in `check --json`, when it has one of its own.
|
|
650
|
+
*
|
|
651
|
+
* Most parse failures are just syntax and are reported as `SYN01`. A few are a named
|
|
652
|
+
* condition a caller has to be able to act on without matching the message text — a file
|
|
653
|
+
* declaring a language version this build cannot read is the case that forced this: the
|
|
654
|
+
* answer is "upgrade koyu", and a viewer wanting to say so should not be reading English.
|
|
655
|
+
*
|
|
656
|
+
* Narrow on purpose. The diagnostic ledger lives in `diagnose.ts`, which reads this
|
|
657
|
+
* module, so the union cannot be imported here — and widening it to `string` would let
|
|
658
|
+
* a typo reach `check --json` as a code no page documents.
|
|
659
|
+
*/
|
|
660
|
+
public code?: "VER06",
|
|
464
661
|
) {
|
|
465
662
|
super(`${file ? `${file}:` : ""}line ${line}: ${raw}`);
|
|
466
663
|
this.name = "SourceError";
|
|
@@ -941,7 +1138,10 @@ export function toCanonical(model: Model): string {
|
|
|
941
1138
|
// 出せば、その版を著者は書いていないのに書いたことになり、しかもツールの既定が動いた日に
|
|
942
1139
|
// 同じ入力のバイトが変わる。決定性は形式の側の約束なので、ツールの既定に預けない
|
|
943
1140
|
format: CANONICAL_FORMAT,
|
|
944
|
-
|
|
1141
|
+
// **The key names the language, so it is spelled `muro`** — whatever word the file used.
|
|
1142
|
+
// A document written `koyu 1.1` still says `"muro": "1.1"` here: the key is the name of
|
|
1143
|
+
// the thing being versioned, not a copy of how the author spelled the declaration.
|
|
1144
|
+
...(model.versionDeclared ? { muro: model.version } : {}),
|
|
945
1145
|
...(model.name ? { name: model.name } : {}),
|
|
946
1146
|
unit: model.unit,
|
|
947
1147
|
// 測地の枠 (ADR-0057) — **単位を言った直後、グリッドを言う前。**この二つは grid が張る
|
package/src/core/parse.ts
CHANGED
|
@@ -11,6 +11,11 @@ import {
|
|
|
11
11
|
type Boundary,
|
|
12
12
|
DEFAULT_LANGUAGE_VERSION,
|
|
13
13
|
type Edge,
|
|
14
|
+
isNewerVersion,
|
|
15
|
+
KOYU_VERSION,
|
|
16
|
+
LAST_KOYU_SPELLED_VERSION,
|
|
17
|
+
MURO_KEYWORD,
|
|
18
|
+
NEWEST_LANGUAGE_VERSION,
|
|
14
19
|
type Level,
|
|
15
20
|
type Model,
|
|
16
21
|
normalizeRegionOrder,
|
|
@@ -254,25 +259,68 @@ function ingest(
|
|
|
254
259
|
currentSpaces = [];
|
|
255
260
|
over = undefined;
|
|
256
261
|
switch (head) {
|
|
257
|
-
|
|
262
|
+
// **The version line is the only declaration that names the language, which is why it
|
|
263
|
+
// was the one that carried the wrong name.** `koyu` is the implementation; the language
|
|
264
|
+
// is muro. One spelling per version, never both: two ways to write the same declaration
|
|
265
|
+
// would end the uniqueness the canonical form rests on.
|
|
266
|
+
case "koyu":
|
|
267
|
+
case "muro": {
|
|
258
268
|
const v = rest[0];
|
|
259
|
-
|
|
269
|
+
const spelling = head;
|
|
270
|
+
if (!v) {
|
|
271
|
+
throw new SourceError(ln, `${spelling} takes a version: ${MURO_KEYWORD} ${NEWEST_LANGUAGE_VERSION}`);
|
|
272
|
+
}
|
|
260
273
|
if (rest.length > 1) {
|
|
261
|
-
throw new SourceError(ln, `Extra tokens on the
|
|
274
|
+
throw new SourceError(ln, `Extra tokens on the ${spelling} version declaration: ${rest.slice(1).join(" ")}`);
|
|
275
|
+
}
|
|
276
|
+
// **A version nobody ever released has no keyword to enforce.** `muro 0.6` is not a
|
|
277
|
+
// file whose author picked the wrong word — 0.6 does not exist, and answering with
|
|
278
|
+
// "a 0.6 file declares itself koyu 0.6" would send them to write a second invalid
|
|
279
|
+
// thing. Unknown-and-not-plausibly-future is settled first, on its own terms.
|
|
280
|
+
const known = SUPPORTED_LANGUAGE_VERSIONS.includes(v);
|
|
281
|
+
const future = isNewerVersion(v, NEWEST_LANGUAGE_VERSION);
|
|
282
|
+
if (!known && !future) {
|
|
283
|
+
throw new SourceError(
|
|
284
|
+
ln,
|
|
285
|
+
`Unsupported ${spelling} version: ${v} (this tool supports ${SUPPORTED_LANGUAGE_VERSIONS.join(", ")})`,
|
|
286
|
+
);
|
|
287
|
+
}
|
|
288
|
+
|
|
289
|
+
// **The spelling belongs to the version, and that is true of every build.** Decided
|
|
290
|
+
// before anything about what this build supports: `koyu 9.9` is not a file from the
|
|
291
|
+
// future, it is a declaration no version ever accepts, and telling its author to
|
|
292
|
+
// upgrade would send them to fix the one thing that is not wrong.
|
|
293
|
+
const wants = isNewerVersion(v, LAST_KOYU_SPELLED_VERSION) ? "muro" : "koyu";
|
|
294
|
+
if (spelling !== wants) {
|
|
295
|
+
throw new SourceError(
|
|
296
|
+
ln,
|
|
297
|
+
wants === "muro"
|
|
298
|
+
? `muro ${v} names itself muro: write "muro ${v}". The koyu spelling names the implementation and stops at ${LAST_KOYU_SPELLED_VERSION}`
|
|
299
|
+
: `The muro keyword arrives in 1.2, and a ${v} processor cannot read it — a ${v} file declares itself "koyu ${v}"`,
|
|
300
|
+
);
|
|
262
301
|
}
|
|
263
|
-
|
|
302
|
+
|
|
303
|
+
if (future) {
|
|
304
|
+
// **A file from the future is not a broken file.** It says the reader is behind, and
|
|
305
|
+
// the only useful advice is to upgrade — the opposite of the advice for a version
|
|
306
|
+
// that never existed. Both used to print the same sentence, so a viewer could not
|
|
307
|
+
// tell a stale build from a corrupt file, and one downstream rebuilt the
|
|
308
|
+
// distinction for itself out of the version list.
|
|
264
309
|
throw new SourceError(
|
|
265
310
|
ln,
|
|
266
|
-
`
|
|
311
|
+
`This file is written in muro ${v}, and this build of koyu (${KOYU_VERSION}) reads up to ${NEWEST_LANGUAGE_VERSION}. The file is not the problem — upgrade koyu`,
|
|
312
|
+
undefined,
|
|
313
|
+
"VER06",
|
|
267
314
|
);
|
|
268
315
|
}
|
|
316
|
+
|
|
269
317
|
// 版はbase層 (entry) でのみ・一度だけ宣言する — 合成順による黙った上書きを禁じる (ADR-0017)。
|
|
270
318
|
// gridの規律に合わせ、再宣言は同値でもエラー
|
|
271
319
|
if (file !== undefined && model.layers[0] !== file) {
|
|
272
|
-
throw new SourceError(ln, "The
|
|
320
|
+
throw new SourceError(ln, "The version is declared only in the base layer (the entry)");
|
|
273
321
|
}
|
|
274
322
|
if (model.versionDeclared) {
|
|
275
|
-
throw new SourceError(ln, `The
|
|
323
|
+
throw new SourceError(ln, `The version is declared once (already ${model.version})`);
|
|
276
324
|
}
|
|
277
325
|
model.version = v;
|
|
278
326
|
model.versionDeclared = true;
|
|
@@ -721,7 +769,7 @@ function ingest(
|
|
|
721
769
|
} catch (e) {
|
|
722
770
|
// 合成時はどのファイルのエラーかを言葉にする
|
|
723
771
|
if (e instanceof SourceError && !e.file && file) {
|
|
724
|
-
throw new SourceError(e.line, e.raw, file);
|
|
772
|
+
throw new SourceError(e.line, e.raw, file, e.code);
|
|
725
773
|
}
|
|
726
774
|
throw e;
|
|
727
775
|
}
|
|
@@ -732,7 +780,7 @@ function ingest(
|
|
|
732
780
|
expandBand(model, band, file);
|
|
733
781
|
} catch (e) {
|
|
734
782
|
if (e instanceof SourceError && !e.file && file) {
|
|
735
|
-
throw new SourceError(e.line, e.raw, file);
|
|
783
|
+
throw new SourceError(e.line, e.raw, file, e.code);
|
|
736
784
|
}
|
|
737
785
|
throw e;
|
|
738
786
|
}
|
package/src/form.ts
CHANGED
|
@@ -1,5 +1,18 @@
|
|
|
1
1
|
// Public Form surface. derive() is the only public operation that assembles shape.
|
|
2
2
|
|
|
3
|
+
// The constructors of matter. `Form` holds centre lines, thicknesses and z; raising matter from
|
|
4
|
+
// those is part of the derivation, so **there is exactly one implementation and it is this one.**
|
|
5
|
+
// A consumer that cannot import them has to rewrite them, and then the parts are shared while the
|
|
6
|
+
// rules of assembly are not — which is the door to "two shapes from one Form".
|
|
7
|
+
export {
|
|
8
|
+
band,
|
|
9
|
+
bandLine,
|
|
10
|
+
columnRect,
|
|
11
|
+
runPrism,
|
|
12
|
+
thicken,
|
|
13
|
+
type FormPrism,
|
|
14
|
+
} from "./core/derive.js";
|
|
15
|
+
|
|
3
16
|
export {
|
|
4
17
|
derive,
|
|
5
18
|
DERIVATION_CONSTANTS,
|
package/src/index.ts
CHANGED
|
@@ -46,8 +46,13 @@ export {
|
|
|
46
46
|
} from "./core/diagnose.js";
|
|
47
47
|
|
|
48
48
|
// ---- 機械形式と、版 ----
|
|
49
|
+
// `requireMuro` is the one thing a consumer *does* about versions: assert, at startup, that
|
|
50
|
+
// this build reads the language it writes. The ledger behind it lives on `/model` with the
|
|
51
|
+
// rest of the model surface — the root stays the smallest set that gets you to a decision.
|
|
49
52
|
export {
|
|
50
53
|
DEFAULT_LANGUAGE_VERSION,
|
|
54
|
+
NEWEST_LANGUAGE_VERSION,
|
|
55
|
+
requireMuro,
|
|
51
56
|
SourceError,
|
|
52
57
|
SUPPORTED_LANGUAGE_VERSIONS,
|
|
53
58
|
toCanonical,
|
package/src/mcp.ts
CHANGED
|
@@ -9,7 +9,13 @@
|
|
|
9
9
|
import { mkdirSync, readFileSync, realpathSync, renameSync, writeFileSync } from "node:fs";
|
|
10
10
|
import { dirname, isAbsolute, relative, resolve, sep } from "node:path";
|
|
11
11
|
import { daylightInputs } from "./core/light.js";
|
|
12
|
-
import {
|
|
12
|
+
import {
|
|
13
|
+
DEFAULT_LANGUAGE_VERSION,
|
|
14
|
+
KOYU_VERSION,
|
|
15
|
+
NEWEST_LANGUAGE_VERSION,
|
|
16
|
+
polygonAreaM2,
|
|
17
|
+
SUPPORTED_LANGUAGE_VERSIONS,
|
|
18
|
+
} from "./core/model.js";
|
|
13
19
|
import { check } from "./core/diagnose.js";
|
|
14
20
|
import { siteReport } from "./core/site.js";
|
|
15
21
|
import { assess } from "./validate/assessment.js";
|
|
@@ -430,7 +436,17 @@ function handle(msg: Json): void {
|
|
|
430
436
|
result(id, {
|
|
431
437
|
protocolVersion: (params.protocolVersion as string) ?? "2025-06-18",
|
|
432
438
|
capabilities: { tools: {} },
|
|
433
|
-
serverInfo: {
|
|
439
|
+
serverInfo: {
|
|
440
|
+
name: "koyu",
|
|
441
|
+
version: KOYU_VERSION,
|
|
442
|
+
// Which muro this build speaks. An agent choosing how to spell a version line
|
|
443
|
+
// has nothing else to read it from.
|
|
444
|
+
muro: {
|
|
445
|
+
reads: SUPPORTED_LANGUAGE_VERSIONS,
|
|
446
|
+
newest: NEWEST_LANGUAGE_VERSION,
|
|
447
|
+
undeclared: DEFAULT_LANGUAGE_VERSION,
|
|
448
|
+
},
|
|
449
|
+
},
|
|
434
450
|
instructions:
|
|
435
451
|
"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.",
|
|
436
452
|
});
|
package/src/model.ts
CHANGED
|
@@ -37,9 +37,15 @@ export {
|
|
|
37
37
|
isOutside,
|
|
38
38
|
isSemiOutdoor,
|
|
39
39
|
isVoid,
|
|
40
|
+
KOYU_VERSION,
|
|
41
|
+
koyuSince,
|
|
40
42
|
levelsSorted,
|
|
43
|
+
MURO_SUPPORT,
|
|
44
|
+
NEWEST_LANGUAGE_VERSION,
|
|
41
45
|
newUids,
|
|
46
|
+
speaksMuro,
|
|
42
47
|
SUPPORTED_LANGUAGE_VERSIONS,
|
|
43
48
|
toCanonical,
|
|
49
|
+
versionLine,
|
|
44
50
|
zoneAreaM2,
|
|
45
51
|
} from "./core/model.js";
|
|
@@ -144,7 +144,12 @@ export interface AssessmentSummary {
|
|
|
144
144
|
};
|
|
145
145
|
}
|
|
146
146
|
|
|
147
|
-
|
|
147
|
+
/**
|
|
148
|
+
* The name of the shape an assessment returns. **It carries no version**, for the same reason
|
|
149
|
+
* as `ANALYSIS_FORMAT`: judgements are the face that grows by addition and freezes nothing,
|
|
150
|
+
* and nothing reads this string back.
|
|
151
|
+
*/
|
|
152
|
+
export const ASSESSMENT_FORMAT = "koyu-assessment" as const;
|
|
148
153
|
|
|
149
154
|
export interface AssessmentReport {
|
|
150
155
|
readonly schema: typeof ASSESSMENT_FORMAT;
|