@snaptrude/plugin-core 0.3.0 → 0.5.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/AGENTS.md +130 -48
- package/CHANGELOG.md +111 -0
- package/api-manifest.full.json +3999 -0
- package/api-manifest.json +3845 -0
- package/dist/api/core/buildings.d.ts +427 -0
- package/dist/api/core/buildings.d.ts.map +1 -0
- package/dist/api/core/comment/index.d.ts +230 -0
- package/dist/api/core/comment/index.d.ts.map +1 -0
- package/dist/api/core/geom/create/index.d.ts +247 -0
- package/dist/api/core/geom/create/index.d.ts.map +1 -0
- package/dist/api/core/geom/delete/index.d.ts +72 -0
- package/dist/api/core/geom/delete/index.d.ts.map +1 -0
- package/dist/api/core/geom/index.d.ts +24 -23
- package/dist/api/core/geom/index.d.ts.map +1 -1
- package/dist/api/core/geom/query/arc.d.ts +169 -0
- package/dist/api/core/geom/query/arc.d.ts.map +1 -0
- package/dist/api/core/geom/query/brep.d.ts +402 -0
- package/dist/api/core/geom/query/brep.d.ts.map +1 -0
- package/dist/api/core/geom/query/circle.d.ts +378 -0
- package/dist/api/core/geom/query/circle.d.ts.map +1 -0
- package/dist/api/core/geom/query/contour.d.ts +450 -0
- package/dist/api/core/geom/query/contour.d.ts.map +1 -0
- package/dist/api/core/geom/query/curve.d.ts +918 -0
- package/dist/api/core/geom/query/curve.d.ts.map +1 -0
- package/dist/api/core/geom/query/edge.d.ts +128 -0
- package/dist/api/core/geom/query/edge.d.ts.map +1 -0
- package/dist/api/core/geom/query/face.d.ts +363 -0
- package/dist/api/core/geom/query/face.d.ts.map +1 -0
- package/dist/api/core/geom/query/halfedge.d.ts +206 -0
- package/dist/api/core/geom/query/halfedge.d.ts.map +1 -0
- package/dist/api/core/geom/query/index.d.ts +61 -0
- package/dist/api/core/geom/query/index.d.ts.map +1 -0
- package/dist/api/core/geom/query/profile.d.ts +410 -0
- package/dist/api/core/geom/query/profile.d.ts.map +1 -0
- package/dist/api/core/geom/query/vertex.d.ts +187 -0
- package/dist/api/core/geom/query/vertex.d.ts.map +1 -0
- package/dist/api/core/geom/update/contour.d.ts +272 -0
- package/dist/api/core/geom/update/contour.d.ts.map +1 -0
- package/dist/api/core/geom/update/curve.d.ts +180 -0
- package/dist/api/core/geom/update/curve.d.ts.map +1 -0
- package/dist/api/core/geom/update/index.d.ts +27 -0
- package/dist/api/core/geom/update/index.d.ts.map +1 -0
- package/dist/api/core/geom/update/profile.d.ts +329 -0
- package/dist/api/core/geom/update/profile.d.ts.map +1 -0
- package/dist/api/core/groups.d.ts +485 -0
- package/dist/api/core/groups.d.ts.map +1 -0
- package/dist/api/core/history/index.d.ts +78 -0
- package/dist/api/core/history/index.d.ts.map +1 -0
- package/dist/api/core/index.d.ts +46 -1
- package/dist/api/core/index.d.ts.map +1 -1
- package/dist/api/core/layers.d.ts +402 -0
- package/dist/api/core/layers.d.ts.map +1 -0
- package/dist/api/core/math/quat.d.ts +111 -128
- package/dist/api/core/math/quat.d.ts.map +1 -1
- package/dist/api/core/math/vec3.d.ts +120 -102
- package/dist/api/core/math/vec3.d.ts.map +1 -1
- package/dist/api/core/project/index.d.ts +399 -0
- package/dist/api/core/project/index.d.ts.map +1 -0
- package/dist/api/core/tags.d.ts +755 -0
- package/dist/api/core/tags.d.ts.map +1 -0
- package/dist/api/core/units/index.d.ts +175 -0
- package/dist/api/core/units/index.d.ts.map +1 -0
- package/dist/api/core/zoom/index.d.ts +45 -0
- package/dist/api/core/zoom/index.d.ts.map +1 -0
- package/dist/api/design/boolean/index.d.ts +168 -0
- package/dist/api/design/boolean/index.d.ts.map +1 -0
- package/dist/api/design/create/index.d.ts +828 -0
- package/dist/api/design/create/index.d.ts.map +1 -0
- package/dist/api/design/delete/index.d.ts +63 -0
- package/dist/api/design/delete/index.d.ts.map +1 -0
- package/dist/api/design/doors/index.d.ts +268 -0
- package/dist/api/design/doors/index.d.ts.map +1 -0
- package/dist/api/design/edit/index.d.ts +49 -0
- package/dist/api/design/edit/index.d.ts.map +1 -0
- package/dist/api/design/erase/index.d.ts +160 -0
- package/dist/api/design/erase/index.d.ts.map +1 -0
- package/dist/api/design/furniture/index.d.ts +123 -0
- package/dist/api/design/furniture/index.d.ts.map +1 -0
- package/dist/api/design/index.d.ts +153 -0
- package/dist/api/design/index.d.ts.map +1 -0
- package/dist/api/design/lock.d.ts +41 -0
- package/dist/api/design/lock.d.ts.map +1 -0
- package/dist/api/design/materials/index.d.ts +297 -0
- package/dist/api/design/materials/index.d.ts.map +1 -0
- package/dist/api/design/query/geometry/index.d.ts +140 -0
- package/dist/api/design/query/geometry/index.d.ts.map +1 -0
- package/dist/api/design/query/index.d.ts +1011 -0
- package/dist/api/design/query/index.d.ts.map +1 -0
- package/dist/api/design/query/spaces.d.ts +221 -0
- package/dist/api/design/query/spaces.d.ts.map +1 -0
- package/dist/api/design/selection/index.d.ts +138 -0
- package/dist/api/design/selection/index.d.ts.map +1 -0
- package/dist/api/design/shared.d.ts +38 -0
- package/dist/api/design/shared.d.ts.map +1 -0
- package/dist/api/design/transform/index.d.ts +87 -0
- package/dist/api/design/transform/index.d.ts.map +1 -0
- package/dist/api/design/update/index.d.ts +178 -0
- package/dist/api/design/update/index.d.ts.map +1 -0
- package/dist/api/design/windows/index.d.ts +189 -0
- package/dist/api/design/windows/index.d.ts.map +1 -0
- package/dist/api/entity/buildableEnvelope.d.ts +261 -0
- package/dist/api/entity/buildableEnvelope.d.ts.map +1 -0
- package/dist/api/entity/department.d.ts +0 -98
- package/dist/api/entity/department.d.ts.map +1 -1
- package/dist/api/entity/index.d.ts +9 -9
- package/dist/api/entity/index.d.ts.map +1 -1
- package/dist/api/entity/referenceLine.d.ts +49 -106
- package/dist/api/entity/referenceLine.d.ts.map +1 -1
- package/dist/api/entity/space.d.ts +482 -249
- package/dist/api/entity/space.d.ts.map +1 -1
- package/dist/api/entity/story.d.ts +49 -39
- package/dist/api/entity/story.d.ts.map +1 -1
- package/dist/api/index.d.ts +17 -12
- package/dist/api/index.d.ts.map +1 -1
- package/dist/api/presentation/aiInspiration.d.ts +440 -0
- package/dist/api/presentation/aiInspiration.d.ts.map +1 -0
- package/dist/api/presentation/diagrams.d.ts +81 -0
- package/dist/api/presentation/diagrams.d.ts.map +1 -0
- package/dist/api/presentation/import.d.ts +113 -0
- package/dist/api/presentation/import.d.ts.map +1 -0
- package/dist/api/presentation/index.d.ts +46 -0
- package/dist/api/presentation/index.d.ts.map +1 -0
- package/dist/api/presentation/sheets.d.ts +176 -0
- package/dist/api/presentation/sheets.d.ts.map +1 -0
- package/dist/api/presentation/views.d.ts +296 -0
- package/dist/api/presentation/views.d.ts.map +1 -0
- package/dist/api/program/adjacency.d.ts +155 -0
- package/dist/api/program/adjacency.d.ts.map +1 -0
- package/dist/api/program/areas.d.ts +360 -0
- package/dist/api/program/areas.d.ts.map +1 -0
- package/dist/api/program/classification.d.ts +135 -0
- package/dist/api/program/classification.d.ts.map +1 -0
- package/dist/api/program/cores.d.ts +174 -0
- package/dist/api/program/cores.d.ts.map +1 -0
- package/dist/api/program/departments.d.ts +431 -0
- package/dist/api/program/departments.d.ts.map +1 -0
- package/dist/api/program/index.d.ts +69 -0
- package/dist/api/program/index.d.ts.map +1 -0
- package/dist/api/program/layout.d.ts +63 -0
- package/dist/api/program/layout.d.ts.map +1 -0
- package/dist/api/program/metrics.d.ts +108 -0
- package/dist/api/program/metrics.d.ts.map +1 -0
- package/dist/api/program/site.d.ts +367 -0
- package/dist/api/program/site.d.ts.map +1 -0
- package/dist/api/program/spreadsheet.d.ts +2041 -0
- package/dist/api/program/spreadsheet.d.ts.map +1 -0
- package/dist/handles.d.ts +138 -0
- package/dist/handles.d.ts.map +1 -0
- package/dist/host-utils.d.ts +7 -5
- package/dist/host-utils.d.ts.map +1 -1
- package/dist/index.cjs +4001 -904
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +3392 -870
- package/dist/index.js.map +1 -1
- package/package.json +6 -2
- package/scripts/generate-manifest.mjs +193 -0
- package/scripts/generate-manifest.test.mjs +193 -0
- package/src/api/core/buildings.ts +485 -0
- package/src/api/core/comment/index.ts +258 -0
- package/src/api/core/geom/create/index.ts +293 -0
- package/src/api/core/geom/delete/index.ts +78 -0
- package/src/api/core/geom/index.ts +24 -23
- package/src/api/core/geom/query/arc.ts +169 -0
- package/src/api/core/geom/query/brep.ts +444 -0
- package/src/api/core/geom/query/circle.ts +404 -0
- package/src/api/core/geom/query/contour.ts +540 -0
- package/src/api/core/geom/query/curve.ts +1078 -0
- package/src/api/core/geom/query/edge.ts +130 -0
- package/src/api/core/geom/query/face.ts +403 -0
- package/src/api/core/geom/query/halfedge.ts +210 -0
- package/src/api/core/geom/query/index.ts +63 -0
- package/src/api/core/geom/query/profile.ts +473 -0
- package/src/api/core/geom/query/vertex.ts +205 -0
- package/src/api/core/geom/update/contour.ts +315 -0
- package/src/api/core/geom/update/curve.ts +209 -0
- package/src/api/core/geom/update/index.ts +29 -0
- package/src/api/core/geom/update/profile.ts +377 -0
- package/src/api/core/groups.ts +521 -0
- package/src/api/core/history/index.ts +84 -0
- package/src/api/core/index.ts +46 -1
- package/src/api/core/layers.ts +333 -0
- package/src/api/core/math/quat.ts +112 -235
- package/src/api/core/math/vec3.ts +124 -159
- package/src/api/core/project/index.ts +418 -0
- package/src/api/core/tags.ts +808 -0
- package/src/api/core/units/index.ts +164 -0
- package/src/api/core/zoom/index.ts +47 -0
- package/src/api/design/boolean/index.ts +179 -0
- package/src/api/design/create/index.ts +886 -0
- package/src/api/design/delete/index.ts +67 -0
- package/src/api/design/doors/index.ts +285 -0
- package/src/api/design/edit/index.ts +54 -0
- package/src/api/design/erase/index.ts +151 -0
- package/src/api/design/furniture/index.ts +130 -0
- package/src/api/design/index.ts +162 -0
- package/src/api/design/lock.ts +42 -0
- package/src/api/design/materials/index.ts +301 -0
- package/src/api/design/query/geometry/index.ts +166 -0
- package/src/api/design/query/index.ts +937 -0
- package/src/api/design/query/spaces.ts +132 -0
- package/src/api/design/selection/index.ts +144 -0
- package/src/api/design/shared.ts +40 -0
- package/src/api/design/transform/index.ts +93 -0
- package/src/api/design/update/index.ts +117 -0
- package/src/api/design/windows/index.ts +207 -0
- package/src/api/entity/buildableEnvelope.ts +318 -0
- package/src/api/entity/department.ts +0 -113
- package/src/api/entity/index.ts +9 -9
- package/src/api/entity/referenceLine.ts +50 -38
- package/src/api/entity/space.ts +285 -226
- package/src/api/entity/story.ts +53 -42
- package/src/api/index.ts +17 -12
- package/src/api/presentation/aiInspiration.ts +362 -0
- package/src/api/presentation/diagrams.ts +84 -0
- package/src/api/presentation/import.ts +112 -0
- package/src/api/presentation/index.ts +48 -0
- package/src/api/presentation/sheets.ts +198 -0
- package/src/api/presentation/views.ts +303 -0
- package/src/api/program/adjacency.ts +164 -0
- package/src/api/program/areas.ts +335 -0
- package/src/api/program/classification.ts +138 -0
- package/src/api/program/cores.ts +171 -0
- package/src/api/program/departments.ts +465 -0
- package/src/api/program/index.ts +71 -0
- package/src/api/program/layout.ts +68 -0
- package/src/api/program/metrics.ts +120 -0
- package/src/api/program/site.ts +326 -0
- package/src/api/program/spreadsheet.ts +2075 -0
- package/src/handles.ts +148 -0
- package/src/host-utils.ts +10 -6
- package/src/index.ts +1 -0
- package/dist/api/core/geom/arc.d.ts +0 -81
- package/dist/api/core/geom/arc.d.ts.map +0 -1
- package/dist/api/core/geom/curve.d.ts +0 -70
- package/dist/api/core/geom/curve.d.ts.map +0 -1
- package/dist/api/core/geom/line.d.ts +0 -56
- package/dist/api/core/geom/line.d.ts.map +0 -1
- package/dist/api/core/geom/profile.d.ts +0 -121
- package/dist/api/core/geom/profile.d.ts.map +0 -1
- package/dist/api/tools/copy.d.ts +0 -59
- package/dist/api/tools/copy.d.ts.map +0 -1
- package/dist/api/tools/index.d.ts +0 -33
- package/dist/api/tools/index.d.ts.map +0 -1
- package/dist/api/tools/material.d.ts +0 -51
- package/dist/api/tools/material.d.ts.map +0 -1
- package/dist/api/tools/offset.d.ts +0 -43
- package/dist/api/tools/offset.d.ts.map +0 -1
- package/dist/api/tools/selection.d.ts +0 -48
- package/dist/api/tools/selection.d.ts.map +0 -1
- package/dist/api/tools/transform.d.ts +0 -114
- package/dist/api/tools/transform.d.ts.map +0 -1
- package/dist/api/units/index.d.ts +0 -163
- package/dist/api/units/index.d.ts.map +0 -1
- package/src/api/core/geom/arc.ts +0 -70
- package/src/api/core/geom/curve.ts +0 -41
- package/src/api/core/geom/line.ts +0 -53
- package/src/api/core/geom/profile.ts +0 -94
- package/src/api/tools/copy.ts +0 -55
- package/src/api/tools/index.ts +0 -39
- package/src/api/tools/material.ts +0 -49
- package/src/api/tools/offset.ts +0 -43
- package/src/api/tools/selection.ts +0 -51
- package/src/api/tools/transform.ts +0 -117
- package/src/api/units/index.ts +0 -163
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@snaptrude/plugin-core",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.5.0",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"main": "./dist/index.js",
|
|
6
6
|
"module": "./dist/index.js",
|
|
@@ -17,6 +17,7 @@
|
|
|
17
17
|
"access": "public"
|
|
18
18
|
},
|
|
19
19
|
"devDependencies": {
|
|
20
|
+
"ts-morph": "^28.0.0",
|
|
20
21
|
"tsup": "^8.5.1",
|
|
21
22
|
"typescript": "^5.5.4"
|
|
22
23
|
},
|
|
@@ -30,6 +31,9 @@
|
|
|
30
31
|
"check-types": "tsc --noEmit",
|
|
31
32
|
"build": "tsup --clean",
|
|
32
33
|
"dev": "tsup --watch",
|
|
33
|
-
"clean-dist": "rm -rf dist"
|
|
34
|
+
"clean-dist": "rm -rf dist",
|
|
35
|
+
"generate:manifest": "node scripts/generate-manifest.mjs",
|
|
36
|
+
"generate:manifest:check": "node scripts/generate-manifest.mjs --check",
|
|
37
|
+
"generate:manifest:all": "node scripts/generate-manifest.mjs --all"
|
|
34
38
|
}
|
|
35
39
|
}
|
|
@@ -0,0 +1,193 @@
|
|
|
1
|
+
// Discovery-manifest generator.
|
|
2
|
+
//
|
|
3
|
+
// The plugin API surface is a tree of abstract `Plugin*Api` classes; the wire
|
|
4
|
+
// method map (`PluginApiMethodMap`) is TYPE-LEVEL ONLY and cannot be enumerated
|
|
5
|
+
// at runtime. This script statically walks the abstract+Zod source with ts-morph
|
|
6
|
+
// and emits a flat, machine-readable manifest of every leaf method:
|
|
7
|
+
//
|
|
8
|
+
// { path, namespace, summary, examplePrompts[], argsType, resultType }
|
|
9
|
+
//
|
|
10
|
+
// The manifest is the substrate the discovery server (plugin-mcp-server) and the
|
|
11
|
+
// retrieval-accuracy eval harness key on. Authors only ever write the abstract
|
|
12
|
+
// class + Zod schemas + JSDoc + `@examplePrompt` lines — this regenerates the rest.
|
|
13
|
+
//
|
|
14
|
+
// Run: `pnpm --filter @snaptrude/plugin-core generate:manifest`
|
|
15
|
+
// add `--check` to assert the on-disk manifest is up-to-date (CI gate);
|
|
16
|
+
// exits non-zero without writing if regeneration would change it.
|
|
17
|
+
import { Project } from "ts-morph"
|
|
18
|
+
import { fileURLToPath } from "node:url"
|
|
19
|
+
import { dirname, resolve } from "node:path"
|
|
20
|
+
import { writeFileSync, readFileSync, existsSync } from "node:fs"
|
|
21
|
+
|
|
22
|
+
const here = dirname(fileURLToPath(import.meta.url))
|
|
23
|
+
const pkgRoot = resolve(here, "..")
|
|
24
|
+
const apiGlob = resolve(pkgRoot, "src/api/**/*.ts")
|
|
25
|
+
const outFile = resolve(pkgRoot, "api-manifest.json")
|
|
26
|
+
|
|
27
|
+
const ROOT_CLASS = "PluginApi"
|
|
28
|
+
const RETURN_WRAPPER = "PluginApiReturn"
|
|
29
|
+
|
|
30
|
+
/** First paragraph of a JSDoc description, whitespace-collapsed. */
|
|
31
|
+
function summaryOf(jsDoc) {
|
|
32
|
+
if (!jsDoc) return ""
|
|
33
|
+
const desc = (jsDoc.getDescription() ?? "").trim()
|
|
34
|
+
const firstPara = desc.split(/\n\s*\n/)[0] ?? ""
|
|
35
|
+
return firstPara.replace(/\s+/g, " ").trim()
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
/** All `@examplePrompt` comment strings on a method's JSDoc. */
|
|
39
|
+
function examplePromptsOf(jsDoc) {
|
|
40
|
+
if (!jsDoc) return []
|
|
41
|
+
return jsDoc
|
|
42
|
+
.getTags()
|
|
43
|
+
.filter((t) => t.getTagName() === "examplePrompt")
|
|
44
|
+
.map((t) => (t.getCommentText() ?? "").trim())
|
|
45
|
+
.filter(Boolean)
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
/** Strip the `PluginApiReturn<...>` wrapper to the inner result type text. */
|
|
49
|
+
function unwrapReturn(text) {
|
|
50
|
+
if (!text) return "void"
|
|
51
|
+
const m = text.match(new RegExp(`^${RETURN_WRAPPER}<([\\s\\S]*)>$`))
|
|
52
|
+
return (m ? m[1] : text).trim()
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
/**
|
|
56
|
+
* Statically walk the abstract `PluginApi` class tree and return one flat,
|
|
57
|
+
* sorted manifest entry per leaf method. Pure (no side effects) so it is unit
|
|
58
|
+
* testable; the CLI below adds the write + report.
|
|
59
|
+
*/
|
|
60
|
+
export function buildManifest({ includeOptional = false } = {}) {
|
|
61
|
+
const project = new Project({ skipAddingFilesFromTsConfig: true })
|
|
62
|
+
project.addSourceFilesAtPaths(apiGlob)
|
|
63
|
+
|
|
64
|
+
// className -> ClassDeclaration, for every abstract Plugin*Api class.
|
|
65
|
+
const classes = new Map()
|
|
66
|
+
for (const sf of project.getSourceFiles()) {
|
|
67
|
+
for (const cls of sf.getClasses()) {
|
|
68
|
+
const name = cls.getName()
|
|
69
|
+
if (name && name.startsWith("Plugin") && name.endsWith("Api")) {
|
|
70
|
+
classes.set(name, cls)
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
const leaves = []
|
|
76
|
+
|
|
77
|
+
function walk(className, pathPrefix) {
|
|
78
|
+
const cls = classes.get(className)
|
|
79
|
+
if (!cls) return
|
|
80
|
+
|
|
81
|
+
// Leaf methods on this namespace.
|
|
82
|
+
for (const method of cls.getMethods()) {
|
|
83
|
+
const name = method.getName()
|
|
84
|
+
const jsDoc = method.getJsDocs().at(-1) ?? null
|
|
85
|
+
const param = method.getParameters()[0]
|
|
86
|
+
leaves.push({
|
|
87
|
+
path: `${pathPrefix}${name}`,
|
|
88
|
+
namespace: pathPrefix.replace(/\.$/, ""),
|
|
89
|
+
summary: summaryOf(jsDoc),
|
|
90
|
+
examplePrompts: examplePromptsOf(jsDoc),
|
|
91
|
+
argsType: param?.getTypeNode()?.getText() ?? null,
|
|
92
|
+
resultType: unwrapReturn(method.getReturnTypeNode()?.getText()),
|
|
93
|
+
})
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
// Sub-namespaces are abstract properties typed as another Plugin*Api class.
|
|
97
|
+
//
|
|
98
|
+
// Author-ahead discipline: a member declared optional (`?`) is authored
|
|
99
|
+
// BEFORE the host implements it — present in the type tree (so plugins and
|
|
100
|
+
// codegen see the shape) but kept OUT of the discovery manifest until it is
|
|
101
|
+
// promoted to a required `abstract` member in the wave the host lands it.
|
|
102
|
+
// The default (discovery) build skips optional members; the authored-surface
|
|
103
|
+
// build (`includeOptional`, used by the retrieval eval) includes them — both
|
|
104
|
+
// the optional sub-namespaces and the optional function-property leaves.
|
|
105
|
+
for (const prop of cls.getProperties()) {
|
|
106
|
+
const optional = prop.hasQuestionToken()
|
|
107
|
+
if (optional && !includeOptional) continue
|
|
108
|
+
const typeNode = prop.getTypeNode()
|
|
109
|
+
const childType = typeNode?.getText()
|
|
110
|
+
if (childType && classes.has(childType)) {
|
|
111
|
+
walk(childType, `${pathPrefix}${prop.getName()}.`)
|
|
112
|
+
} else if (
|
|
113
|
+
includeOptional &&
|
|
114
|
+
typeNode &&
|
|
115
|
+
typeNode.getKindName() === "FunctionType"
|
|
116
|
+
) {
|
|
117
|
+
// An optional author-ahead leaf, written as a function-property.
|
|
118
|
+
const jsDoc = prop.getJsDocs().at(-1) ?? null
|
|
119
|
+
const param = typeNode.getParameters()[0]
|
|
120
|
+
leaves.push({
|
|
121
|
+
path: `${pathPrefix}${prop.getName()}`,
|
|
122
|
+
namespace: pathPrefix.replace(/\.$/, ""),
|
|
123
|
+
summary: summaryOf(jsDoc),
|
|
124
|
+
examplePrompts: examplePromptsOf(jsDoc),
|
|
125
|
+
argsType: param?.getTypeNode()?.getText() ?? null,
|
|
126
|
+
resultType: unwrapReturn(typeNode.getReturnTypeNode()?.getText()),
|
|
127
|
+
})
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
walk(ROOT_CLASS, "")
|
|
133
|
+
leaves.sort((a, b) => a.path.localeCompare(b.path))
|
|
134
|
+
return leaves
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
// --- CLI: write + report (skipped when imported, e.g. by tests) ------------
|
|
138
|
+
if (
|
|
139
|
+
process.argv[1] &&
|
|
140
|
+
resolve(process.argv[1]) === fileURLToPath(import.meta.url)
|
|
141
|
+
) {
|
|
142
|
+
// `--all` builds the AUTHORED-surface manifest (includes optional author-ahead
|
|
143
|
+
// members) to a separate file, for the retrieval eval. Default builds the
|
|
144
|
+
// discovery manifest (required/host-landed members only).
|
|
145
|
+
const all = process.argv.includes("--all")
|
|
146
|
+
const check = process.argv.includes("--check")
|
|
147
|
+
const target = all ? resolve(pkgRoot, "api-manifest.full.json") : outFile
|
|
148
|
+
const leaves = buildManifest({ includeOptional: all })
|
|
149
|
+
const json = JSON.stringify(leaves, null, 2) + "\n"
|
|
150
|
+
|
|
151
|
+
if (check) {
|
|
152
|
+
// Determinism / staleness gate: regenerate and compare, never write.
|
|
153
|
+
const current = existsSync(target) ? readFileSync(target, "utf8") : ""
|
|
154
|
+
if (current !== json) {
|
|
155
|
+
console.error(
|
|
156
|
+
`${target} is STALE or non-deterministic — run \`generate:manifest${all ? " --all" : ""}\` and commit the result.`,
|
|
157
|
+
)
|
|
158
|
+
process.exit(1)
|
|
159
|
+
}
|
|
160
|
+
console.log(
|
|
161
|
+
`manifest up-to-date & deterministic (${leaves.length} methods)`,
|
|
162
|
+
)
|
|
163
|
+
process.exit(0)
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
writeFileSync(target, json)
|
|
167
|
+
|
|
168
|
+
const missingPrompts = leaves.filter((l) => l.examplePrompts.length === 0)
|
|
169
|
+
console.log(
|
|
170
|
+
`manifest${all ? " (authored surface)" : ""}: ${leaves.length} methods -> ${target}`,
|
|
171
|
+
)
|
|
172
|
+
console.log(
|
|
173
|
+
`coverage: ${leaves.length - missingPrompts.length}/${leaves.length} methods have @examplePrompt lines`,
|
|
174
|
+
)
|
|
175
|
+
if (missingPrompts.length) {
|
|
176
|
+
console.log(
|
|
177
|
+
` (no @examplePrompt yet: ${missingPrompts.map((l) => l.path).join(", ")})`,
|
|
178
|
+
)
|
|
179
|
+
}
|
|
180
|
+
const slice = [
|
|
181
|
+
"program.departments.list",
|
|
182
|
+
"program.departments.get",
|
|
183
|
+
"program.metrics.get",
|
|
184
|
+
"presentation.views.list",
|
|
185
|
+
]
|
|
186
|
+
console.log("slice methods present:")
|
|
187
|
+
for (const p of slice) {
|
|
188
|
+
const hit = leaves.find((l) => l.path === p)
|
|
189
|
+
console.log(
|
|
190
|
+
` ${hit ? "OK " : "MISS"} ${p}${hit ? ` (${hit.examplePrompts.length} prompts)` : ""}`,
|
|
191
|
+
)
|
|
192
|
+
}
|
|
193
|
+
}
|
|
@@ -0,0 +1,193 @@
|
|
|
1
|
+
// Unit tests for the discovery-manifest generator (pure codegen logic).
|
|
2
|
+
// Run: `node --test scripts/generate-manifest.test.mjs` (from packages/plugin-core)
|
|
3
|
+
import { test } from "node:test"
|
|
4
|
+
import assert from "node:assert/strict"
|
|
5
|
+
import { buildManifest } from "./generate-manifest.mjs"
|
|
6
|
+
|
|
7
|
+
const manifest = buildManifest()
|
|
8
|
+
const byPath = new Map(manifest.map((m) => [m.path, m]))
|
|
9
|
+
|
|
10
|
+
test("every entry has a dotted path and a namespace", () => {
|
|
11
|
+
for (const m of manifest) {
|
|
12
|
+
assert.match(m.path, /^[a-z][a-zA-Z0-9.]*$/, `bad path: ${m.path}`)
|
|
13
|
+
assert.equal(typeof m.namespace, "string")
|
|
14
|
+
assert.ok(
|
|
15
|
+
Array.isArray(m.examplePrompts),
|
|
16
|
+
`${m.path} examplePrompts not array`,
|
|
17
|
+
)
|
|
18
|
+
}
|
|
19
|
+
})
|
|
20
|
+
|
|
21
|
+
test("output is sorted and unique by path", () => {
|
|
22
|
+
const paths = manifest.map((m) => m.path)
|
|
23
|
+
assert.deepEqual(
|
|
24
|
+
paths,
|
|
25
|
+
[...paths].sort((a, b) => a.localeCompare(b)),
|
|
26
|
+
"not sorted",
|
|
27
|
+
)
|
|
28
|
+
assert.equal(new Set(paths).size, paths.length, "duplicate paths")
|
|
29
|
+
})
|
|
30
|
+
|
|
31
|
+
test("all 4 Phase-1 slice methods are present with intent + prompts", () => {
|
|
32
|
+
const slice = [
|
|
33
|
+
"program.departments.list",
|
|
34
|
+
"program.departments.get",
|
|
35
|
+
"program.metrics.get",
|
|
36
|
+
"presentation.views.list",
|
|
37
|
+
]
|
|
38
|
+
for (const p of slice) {
|
|
39
|
+
const m = byPath.get(p)
|
|
40
|
+
assert.ok(m, `missing slice method: ${p}`)
|
|
41
|
+
assert.ok(m.summary.length > 0, `${p} has no intent summary`)
|
|
42
|
+
assert.ok(m.examplePrompts.length >= 3, `${p} has < 3 example prompts`)
|
|
43
|
+
assert.ok(
|
|
44
|
+
m.resultType && m.resultType !== "void",
|
|
45
|
+
`${p} has no result type`,
|
|
46
|
+
)
|
|
47
|
+
}
|
|
48
|
+
})
|
|
49
|
+
|
|
50
|
+
test("departments.get carries its args type; list takes no args", () => {
|
|
51
|
+
assert.equal(
|
|
52
|
+
byPath.get("program.departments.get").argsType,
|
|
53
|
+
"PluginProgramDepartmentsGetArgs",
|
|
54
|
+
)
|
|
55
|
+
assert.equal(byPath.get("program.departments.list").argsType, null)
|
|
56
|
+
})
|
|
57
|
+
|
|
58
|
+
test("return-type wrapper PluginApiReturn<...> is unwrapped", () => {
|
|
59
|
+
for (const m of manifest) {
|
|
60
|
+
assert.ok(
|
|
61
|
+
!/^PluginApiReturn</.test(m.resultType ?? ""),
|
|
62
|
+
`${m.path} not unwrapped`,
|
|
63
|
+
)
|
|
64
|
+
}
|
|
65
|
+
})
|
|
66
|
+
|
|
67
|
+
test("author-ahead (optional) members are kept OUT of the manifest", () => {
|
|
68
|
+
// Optional sub-namespaces (`aiInspiration?`) and optional leaf methods
|
|
69
|
+
// (`departments.delete?`, `cores.create?`) are authored ahead of the host and
|
|
70
|
+
// must not appear in the discovery manifest until promoted to required
|
|
71
|
+
// `abstract` members. (See the discipline note in generate-manifest.mjs.)
|
|
72
|
+
const authoredAhead = [
|
|
73
|
+
"presentation.aiInspiration.listModels",
|
|
74
|
+
"program.departments.delete",
|
|
75
|
+
"program.cores.create",
|
|
76
|
+
]
|
|
77
|
+
for (const p of authoredAhead) {
|
|
78
|
+
assert.ok(
|
|
79
|
+
!byPath.has(p),
|
|
80
|
+
`optional author-ahead member leaked into manifest: ${p}`,
|
|
81
|
+
)
|
|
82
|
+
}
|
|
83
|
+
})
|
|
84
|
+
|
|
85
|
+
test("promoted methods are present in the manifest", () => {
|
|
86
|
+
// Methods whose react host bodies have landed and been verified, flipped from
|
|
87
|
+
// optional author-ahead to required `abstract`.
|
|
88
|
+
const promoted = [
|
|
89
|
+
"program.departments.create",
|
|
90
|
+
"program.departments.setTargetArea",
|
|
91
|
+
"program.site.get",
|
|
92
|
+
"program.site.getContext",
|
|
93
|
+
"presentation.import.image",
|
|
94
|
+
"presentation.import.pdf",
|
|
95
|
+
"presentation.sheets.list",
|
|
96
|
+
"presentation.sheets.place",
|
|
97
|
+
"presentation.diagrams.place",
|
|
98
|
+
// 2026-07-02 promotions — react hosts landed and verified:
|
|
99
|
+
"program.spreadsheet.render",
|
|
100
|
+
"program.adjacency.getMatrix",
|
|
101
|
+
"program.adjacency.compute",
|
|
102
|
+
"program.spreadsheet.getTakeoff",
|
|
103
|
+
"program.spreadsheet.runScript",
|
|
104
|
+
"presentation.views.get",
|
|
105
|
+
"presentation.views.getActive",
|
|
106
|
+
"presentation.views.capture",
|
|
107
|
+
"presentation.views.setActive",
|
|
108
|
+
"presentation.views.create",
|
|
109
|
+
"core.layers.setActive",
|
|
110
|
+
"core.layers.update",
|
|
111
|
+
"program.areas.update",
|
|
112
|
+
]
|
|
113
|
+
for (const p of promoted) {
|
|
114
|
+
assert.ok(
|
|
115
|
+
byPath.has(p),
|
|
116
|
+
`expected promoted method missing from manifest: ${p}`,
|
|
117
|
+
)
|
|
118
|
+
}
|
|
119
|
+
})
|
|
120
|
+
|
|
121
|
+
test("v2 family reads (all 5 families) are present with intent + prompts", () => {
|
|
122
|
+
// All 22 reads of the five landed families. Every sub-api mount is now required
|
|
123
|
+
// `abstract` (the react hosts have landed), so each read is in the discovery
|
|
124
|
+
// manifest with a summary, >= 3 example prompts, and a result type.
|
|
125
|
+
const reads = [
|
|
126
|
+
"core.groups.list",
|
|
127
|
+
"core.groups.get",
|
|
128
|
+
"core.groups.getForComponent",
|
|
129
|
+
"core.groups.listMembers",
|
|
130
|
+
"core.groups.isLocked",
|
|
131
|
+
"core.groups.getBounds",
|
|
132
|
+
"core.buildings.list",
|
|
133
|
+
"core.buildings.get",
|
|
134
|
+
"core.buildings.listStoreys",
|
|
135
|
+
"core.buildings.getActive",
|
|
136
|
+
"core.layers.list",
|
|
137
|
+
"core.layers.get",
|
|
138
|
+
"core.layers.getActive",
|
|
139
|
+
"core.tags.listCategories",
|
|
140
|
+
"core.tags.getCategory",
|
|
141
|
+
"core.tags.list",
|
|
142
|
+
"core.tags.get",
|
|
143
|
+
"core.tags.getTagsForComponent",
|
|
144
|
+
"core.tags.listComponents",
|
|
145
|
+
"program.areas.get",
|
|
146
|
+
"program.areas.list",
|
|
147
|
+
"program.areas.listMembers",
|
|
148
|
+
]
|
|
149
|
+
for (const p of reads) {
|
|
150
|
+
const m = byPath.get(p)
|
|
151
|
+
assert.ok(m, `missing v2 family read: ${p}`)
|
|
152
|
+
assert.ok(m.summary.length > 0, `${p} has no intent summary`)
|
|
153
|
+
assert.ok(m.examplePrompts.length >= 3, `${p} has < 3 example prompts`)
|
|
154
|
+
assert.ok(
|
|
155
|
+
m.resultType && m.resultType !== "void",
|
|
156
|
+
`${p} has no result type`,
|
|
157
|
+
)
|
|
158
|
+
}
|
|
159
|
+
})
|
|
160
|
+
|
|
161
|
+
test("v2 family writes are IN the discovery manifest (hosts landed, promoted)", () => {
|
|
162
|
+
// 2026-07-02: every v2 family write's react host body has landed, so the
|
|
163
|
+
// contract members were promoted from optional `foo?: (args) => ...`
|
|
164
|
+
// fn-properties to required `abstract` methods — they now appear in the
|
|
165
|
+
// discovery build.
|
|
166
|
+
const promotedWrites = [
|
|
167
|
+
"core.groups.create",
|
|
168
|
+
"core.groups.update",
|
|
169
|
+
"core.groups.delete",
|
|
170
|
+
"core.buildings.setActive",
|
|
171
|
+
"core.buildings.create",
|
|
172
|
+
"core.buildings.update",
|
|
173
|
+
"core.buildings.copy",
|
|
174
|
+
"core.buildings.delete",
|
|
175
|
+
"core.layers.setActive",
|
|
176
|
+
"core.layers.update",
|
|
177
|
+
"core.tags.createCategory",
|
|
178
|
+
"core.tags.updateCategory",
|
|
179
|
+
"core.tags.deleteCategory",
|
|
180
|
+
"core.tags.create",
|
|
181
|
+
"core.tags.update",
|
|
182
|
+
"core.tags.delete",
|
|
183
|
+
"core.tags.assign",
|
|
184
|
+
"core.tags.unassign",
|
|
185
|
+
"program.areas.update",
|
|
186
|
+
]
|
|
187
|
+
for (const p of promotedWrites) {
|
|
188
|
+
assert.ok(
|
|
189
|
+
byPath.has(p),
|
|
190
|
+
`promoted v2 family write missing from manifest: ${p}`,
|
|
191
|
+
)
|
|
192
|
+
}
|
|
193
|
+
})
|