@kensnzk/koyu 0.17.0 → 0.18.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (142) hide show
  1. package/dist/analysis/contracts.d.ts +217 -0
  2. package/dist/analysis/contracts.d.ts.map +1 -0
  3. package/dist/analysis/contracts.js +27 -0
  4. package/dist/analysis/contracts.js.map +1 -0
  5. package/dist/analysis/index.d.ts +5 -0
  6. package/dist/analysis/index.d.ts.map +1 -0
  7. package/dist/analysis/index.js +17 -0
  8. package/dist/analysis/index.js.map +1 -0
  9. package/dist/analysis/json.d.ts +21 -0
  10. package/dist/analysis/json.d.ts.map +1 -0
  11. package/dist/analysis/json.js +111 -0
  12. package/dist/analysis/json.js.map +1 -0
  13. package/dist/cli.js +94 -26
  14. package/dist/cli.js.map +1 -1
  15. package/dist/core/site.d.ts +9 -0
  16. package/dist/core/site.d.ts.map +1 -1
  17. package/dist/core/site.js +6 -0
  18. package/dist/core/site.js.map +1 -1
  19. package/dist/diagnostics.d.ts +2 -0
  20. package/dist/diagnostics.d.ts.map +1 -0
  21. package/dist/diagnostics.js +3 -0
  22. package/dist/diagnostics.js.map +1 -0
  23. package/dist/diff.d.ts +2 -0
  24. package/dist/diff.d.ts.map +1 -0
  25. package/dist/diff.js +3 -0
  26. package/dist/diff.js.map +1 -0
  27. package/dist/form.d.ts +5 -0
  28. package/dist/form.d.ts.map +1 -0
  29. package/dist/form.js +4 -0
  30. package/dist/form.js.map +1 -0
  31. package/dist/graph.d.ts +2 -0
  32. package/dist/graph.d.ts.map +1 -0
  33. package/dist/graph.js +3 -0
  34. package/dist/graph.js.map +1 -0
  35. package/dist/index.d.ts +2 -15
  36. package/dist/index.d.ts.map +1 -1
  37. package/dist/index.js +35 -50
  38. package/dist/index.js.map +1 -1
  39. package/dist/mcp.js +40 -20
  40. package/dist/mcp.js.map +1 -1
  41. package/dist/model.d.ts +3 -0
  42. package/dist/model.d.ts.map +1 -0
  43. package/dist/model.js +3 -0
  44. package/dist/model.js.map +1 -0
  45. package/dist/validate/assessment.d.ts +8 -0
  46. package/dist/validate/assessment.d.ts.map +1 -0
  47. package/dist/validate/assessment.js +1738 -0
  48. package/dist/validate/assessment.js.map +1 -0
  49. package/dist/validate/builtin/access.d.ts +55 -0
  50. package/dist/validate/builtin/access.d.ts.map +1 -0
  51. package/dist/validate/builtin/access.js +494 -0
  52. package/dist/validate/builtin/access.js.map +1 -0
  53. package/dist/validate/builtin/daylight.d.ts +44 -0
  54. package/dist/validate/builtin/daylight.d.ts.map +1 -0
  55. package/dist/validate/builtin/daylight.js +233 -0
  56. package/dist/validate/builtin/daylight.js.map +1 -0
  57. package/dist/validate/builtin/door-column-collisions.d.ts +47 -0
  58. package/dist/validate/builtin/door-column-collisions.d.ts.map +1 -0
  59. package/dist/validate/builtin/door-column-collisions.js +189 -0
  60. package/dist/validate/builtin/door-column-collisions.js.map +1 -0
  61. package/dist/validate/builtin/envelope.d.ts +30 -0
  62. package/dist/validate/builtin/envelope.d.ts.map +1 -0
  63. package/dist/validate/builtin/envelope.js +169 -0
  64. package/dist/validate/builtin/envelope.js.map +1 -0
  65. package/dist/validate/builtin/freeze.d.ts +3 -0
  66. package/dist/validate/builtin/freeze.d.ts.map +1 -0
  67. package/dist/validate/builtin/freeze.js +21 -0
  68. package/dist/validate/builtin/freeze.js.map +1 -0
  69. package/dist/validate/builtin/index.d.ts +38 -0
  70. package/dist/validate/builtin/index.d.ts.map +1 -0
  71. package/dist/validate/builtin/index.js +106 -0
  72. package/dist/validate/builtin/index.js.map +1 -0
  73. package/dist/validate/builtin/site.d.ts +62 -0
  74. package/dist/validate/builtin/site.d.ts.map +1 -0
  75. package/dist/validate/builtin/site.js +333 -0
  76. package/dist/validate/builtin/site.js.map +1 -0
  77. package/dist/validate/builtin/vertical-runs.d.ts +53 -0
  78. package/dist/validate/builtin/vertical-runs.d.ts.map +1 -0
  79. package/dist/validate/builtin/vertical-runs.js +290 -0
  80. package/dist/validate/builtin/vertical-runs.js.map +1 -0
  81. package/dist/validate/contracts.d.ts +188 -0
  82. package/dist/validate/contracts.d.ts.map +1 -0
  83. package/dist/validate/contracts.js +28 -0
  84. package/dist/validate/contracts.js.map +1 -0
  85. package/dist/validate/index.d.ts +2 -59
  86. package/dist/validate/index.d.ts.map +1 -1
  87. package/dist/validate/index.js +22 -70
  88. package/dist/validate/index.js.map +1 -1
  89. package/dist/vocabulary.d.ts +2 -0
  90. package/dist/vocabulary.d.ts.map +1 -0
  91. package/dist/vocabulary.js +3 -0
  92. package/dist/vocabulary.js.map +1 -0
  93. package/package.json +37 -5
  94. package/src/analysis/contracts.ts +234 -0
  95. package/src/analysis/index.ts +61 -0
  96. package/src/analysis/json.ts +117 -0
  97. package/src/cli.ts +103 -28
  98. package/src/core/site.ts +17 -0
  99. package/src/diagnostics.ts +8 -0
  100. package/src/diff.ts +14 -0
  101. package/src/form.ts +37 -0
  102. package/src/graph.ts +12 -0
  103. package/src/index.ts +39 -195
  104. package/src/mcp.ts +42 -25
  105. package/src/model.ts +43 -0
  106. package/src/validate/assessment.ts +1934 -0
  107. package/src/validate/builtin/access.ts +642 -0
  108. package/src/validate/builtin/daylight.ts +321 -0
  109. package/src/validate/builtin/door-column-collisions.ts +266 -0
  110. package/src/validate/builtin/envelope.ts +227 -0
  111. package/src/validate/builtin/freeze.ts +19 -0
  112. package/src/validate/builtin/index.ts +156 -0
  113. package/src/validate/builtin/site.ts +445 -0
  114. package/src/validate/builtin/vertical-runs.ts +390 -0
  115. package/src/validate/contracts.ts +240 -0
  116. package/src/validate/index.ts +45 -99
  117. package/src/vocabulary.ts +9 -0
  118. package/dist/validate/access.d.ts +0 -6
  119. package/dist/validate/access.d.ts.map +0 -1
  120. package/dist/validate/access.js +0 -248
  121. package/dist/validate/access.js.map +0 -1
  122. package/dist/validate/envelope.d.ts +0 -4
  123. package/dist/validate/envelope.d.ts.map +0 -1
  124. package/dist/validate/envelope.js +0 -55
  125. package/dist/validate/envelope.js.map +0 -1
  126. package/dist/validate/light.d.ts +0 -6
  127. package/dist/validate/light.d.ts.map +0 -1
  128. package/dist/validate/light.js +0 -28
  129. package/dist/validate/light.js.map +0 -1
  130. package/dist/validate/runs.d.ts +0 -16
  131. package/dist/validate/runs.d.ts.map +0 -1
  132. package/dist/validate/runs.js +0 -60
  133. package/dist/validate/runs.js.map +0 -1
  134. package/dist/validate/site.d.ts +0 -6
  135. package/dist/validate/site.d.ts.map +0 -1
  136. package/dist/validate/site.js +0 -63
  137. package/dist/validate/site.js.map +0 -1
  138. package/src/validate/access.ts +0 -291
  139. package/src/validate/envelope.ts +0 -59
  140. package/src/validate/light.ts +0 -43
  141. package/src/validate/runs.ts +0 -87
  142. package/src/validate/site.ts +0 -84
package/src/mcp.ts CHANGED
@@ -8,28 +8,30 @@
8
8
 
9
9
  import { mkdirSync, readFileSync, realpathSync, renameSync, writeFileSync } from "node:fs";
10
10
  import { dirname, isAbsolute, relative, resolve, sep } from "node:path";
11
+ import { daylightInputs } from "./core/light.js";
12
+ import { polygonAreaM2 } from "./core/model.js";
13
+ import { check } from "./core/diagnose.js";
14
+ import { siteReport } from "./core/site.js";
15
+ import { assess } from "./validate/assessment.js";
16
+ import { createSchematicRegistry, SCHEMATIC_PROFILE_ID } from "./validate/builtin/index.js";
17
+ import { checkDiagnostics } from "./diagnostics.js";
18
+ import { svgPlan } from "./draw/index.js";
19
+ import { doorsBetween } from "./graph.js";
11
20
  import {
12
21
  areaM2,
13
22
  isIndoor,
14
- daylightInputs,
15
- validate,
16
23
  displayName,
17
- doorsBetween,
18
24
  effectiveUse,
19
25
  isOutside,
20
26
  isSemiOutdoor,
21
27
  isVoid,
22
28
  levelsSorted,
23
29
  newUids,
24
- polygonAreaM2,
25
30
  toCanonical,
26
31
  zoneAreaM2,
27
32
  type Model,
28
33
  type Space,
29
- } from "./index.js";
30
- import { check, checkDiagnostics } from "./core/diagnose.js";
31
- import { svgPlan } from "./draw/plan.js";
32
- import { siteReport } from "./core/site.js";
34
+ } from "./model.js";
33
35
  import { parseFile, parseFileWith } from "./parse-file.js";
34
36
 
35
37
  // ---- モデルの読み込みと要約 ----
@@ -312,37 +314,52 @@ const TOOLS: Record<string, Tool> = {
312
314
  },
313
315
  validate: {
314
316
  description:
315
- "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",
316
- schema: { type: "object", properties: FILE_PROP, required: ["file"] },
317
+ "Architectural verdicts under an explicit rule profile: daylight, envelope continuity, stair proportions, slopes, reachability, column/door collisions, and the site. Returns a full AssessmentReport — the profile and rule identities, every rule's outcome, the evidence behind it, and a summary that keeps pass, not-applicable, indeterminate and error apart. **A different surface from the check guarantee**, and not frozen. `profile` is required: no jurisdiction or effective date is inferred",
318
+ schema: {
319
+ type: "object",
320
+ properties: {
321
+ ...FILE_PROP,
322
+ profile: {
323
+ type: "string",
324
+ description: `Rule profile id. koyu ships one: ${SCHEMATIC_PROFILE_ID.id}`,
325
+ },
326
+ asOf: {
327
+ type: "string",
328
+ description: "Effective date as YYYY-MM-DD. Not read from the clock, so the same input judges the same way twice",
329
+ },
330
+ },
331
+ required: ["file", "profile", "asOf"],
332
+ },
317
333
  run: (a) => {
318
334
  const m = load(str(a.file, "file"));
319
- const findings = validate(m);
320
- return {
321
- findings,
322
- violations: findings.filter((f) => f.level === "violation").length,
323
- cautions: findings.filter((f) => f.level === "caution").length,
324
- note: "These are verdicts, not the structural-consistency guarantee of koyu check",
325
- };
335
+ const profile = str(a.profile, "profile");
336
+ if (profile !== SCHEMATIC_PROFILE_ID.id) {
337
+ throw new Error(`Unknown profile: ${profile} (koyu ships one: ${SCHEMATIC_PROFILE_ID.id})`);
338
+ }
339
+ return assess(m, {
340
+ registry: createSchematicRegistry(),
341
+ profile: SCHEMATIC_PROFILE_ID,
342
+ context: { schema: "koyu-context/1", asOf: str(a.asOf, "asOf"), values: {} },
343
+ });
326
344
  },
327
345
  },
328
346
  site: {
329
- description: "Site query: site area (declared against derived), road frontage, footprint, and the coverage and floor-area ratios",
347
+ description:
348
+ "Site query: site area (declared against derived), road frontage, footprint, and the coverage and floor-area ratios. **Numbers only** — whether the declared and derived areas agree closely enough is a verdict, and comes from the validate tool",
330
349
  schema: { type: "object", properties: FILE_PROP, required: ["file"] },
331
350
  run: (a) => {
351
+ // The ratios and their rounding belong to core, which is also what the site rules read.
352
+ // Dividing here again is how an adapter and a rule drift apart.
332
353
  const r = siteReport(load(str(a.file, "file")));
333
- const site = r.declaredArea ?? r.derivedArea;
334
354
  return {
335
355
  ...(r.siteZone ? { siteZone: r.siteZone.path } : {}),
336
356
  ...(r.polygon ? { polygonVertices: r.polygon.points.length } : {}),
337
357
  declaredAreaM2: r.declaredArea,
338
358
  derivedAreaM2: r.derivedArea,
339
- ...(r.declaredArea !== undefined && r.derivedArea !== undefined
340
- ? { areaMatch: Math.abs(r.declaredArea - r.derivedArea) < 0.05 }
341
- : {}),
342
359
  footprintM2: r.footprint,
343
360
  totalFloorM2: r.totalFloor,
344
- coverageRatio: site ? Math.round((r.footprint / site) * 1000) / 10 : undefined,
345
- floorAreaRatio: site ? Math.round((r.totalFloor / site) * 1000) / 10 : undefined,
361
+ coverageRatio: r.coveragePercent,
362
+ floorAreaRatio: r.floorAreaRatioPercent,
346
363
  roads: r.roads.map((rd) => ({
347
364
  path: rd.road.path,
348
365
  name: displayName(rd.road),
@@ -398,7 +415,7 @@ function handle(msg: Json): void {
398
415
  result(id, {
399
416
  protocolVersion: (params.protocolVersion as string) ?? "2025-06-18",
400
417
  capabilities: { tools: {} },
401
- serverInfo: { name: "koyu", version: "0.17.0" },
418
+ serverInfo: { name: "koyu", version: "0.18.0" },
402
419
  instructions:
403
420
  "Server for koyu, a space-first architectural description. Grasp the building with model_summary, read the original layers with layers, and edit with write_layer. check is the gatekeeper of the build and returns errors tagged layer:line — it guarantees structural consistency only. validate delivers the architectural verdicts, which are a separate and unfrozen surface. doors/light/site/spaces are different questions put to the same description. Form (plan_svg) is generated, never written.",
404
421
  });
package/src/model.ts ADDED
@@ -0,0 +1,43 @@
1
+ // Public model surface. Keep this facade explicit: adding an export is adding a package promise.
2
+
3
+ export type {
4
+ Area,
5
+ Asset,
6
+ Attrs,
7
+ AttrValue,
8
+ Boundary,
9
+ BoundaryKind,
10
+ Column,
11
+ ColumnDecl,
12
+ DrawnLine,
13
+ Edge,
14
+ GridAxis,
15
+ GridRef,
16
+ Level,
17
+ Model,
18
+ Opening,
19
+ Pt,
20
+ Rect,
21
+ Seg,
22
+ SitePolygon,
23
+ Space,
24
+ Zone,
25
+ } from "./core/model.js";
26
+
27
+ export {
28
+ areaM2,
29
+ DEFAULT_LANGUAGE_VERSION,
30
+ displayName,
31
+ effectiveUse,
32
+ heff,
33
+ isCoveredAbove,
34
+ isIndoor,
35
+ isOutside,
36
+ isSemiOutdoor,
37
+ isVoid,
38
+ levelsSorted,
39
+ newUids,
40
+ SUPPORTED_LANGUAGE_VERSIONS,
41
+ toCanonical,
42
+ zoneAreaM2,
43
+ } from "./core/model.js";