@metamesh/cli 0.0.0-stage → 0.14.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/CHANGELOG.md +39 -0
- package/LICENSE +200 -0
- package/README.md +86 -2
- package/dist/authoring/artifacts.d.ts +15 -0
- package/dist/authoring/artifacts.d.ts.map +1 -0
- package/dist/authoring/artifacts.js +347 -0
- package/dist/authoring/artifacts.js.map +1 -0
- package/dist/authoring/capture/render-client.js +4222 -0
- package/dist/authoring/capture/render-client.js.LEGAL.txt +9 -0
- package/dist/authoring/capture/render-client.js.map +7 -0
- package/dist/authoring/check.d.ts +4 -0
- package/dist/authoring/check.d.ts.map +1 -0
- package/dist/authoring/check.js +118 -0
- package/dist/authoring/check.js.map +1 -0
- package/dist/authoring/environment.d.ts +29 -0
- package/dist/authoring/environment.d.ts.map +1 -0
- package/dist/authoring/environment.js +182 -0
- package/dist/authoring/environment.js.map +1 -0
- package/dist/authoring/errors.d.ts +13 -0
- package/dist/authoring/errors.d.ts.map +1 -0
- package/dist/authoring/errors.js +43 -0
- package/dist/authoring/errors.js.map +1 -0
- package/dist/authoring/render-client.d.ts +6 -0
- package/dist/authoring/render-client.d.ts.map +1 -0
- package/dist/authoring/render-client.js +55 -0
- package/dist/authoring/render-client.js.map +1 -0
- package/dist/authoring/render-scene.d.ts +22 -0
- package/dist/authoring/render-scene.d.ts.map +1 -0
- package/dist/authoring/render-scene.js +139 -0
- package/dist/authoring/render-scene.js.map +1 -0
- package/dist/authoring/render-types.d.ts +81 -0
- package/dist/authoring/render-types.d.ts.map +1 -0
- package/dist/authoring/render-types.js +2 -0
- package/dist/authoring/render-types.js.map +1 -0
- package/dist/authoring/render.d.ts +23 -0
- package/dist/authoring/render.d.ts.map +1 -0
- package/dist/authoring/render.js +243 -0
- package/dist/authoring/render.js.map +1 -0
- package/dist/authoring/run.d.ts +7 -0
- package/dist/authoring/run.d.ts.map +1 -0
- package/dist/authoring/run.js +308 -0
- package/dist/authoring/run.js.map +1 -0
- package/dist/authoring/types.d.ts +175 -0
- package/dist/authoring/types.d.ts.map +1 -0
- package/dist/authoring/types.js +3 -0
- package/dist/authoring/types.js.map +1 -0
- package/dist/authoring/worker.d.ts +15 -0
- package/dist/authoring/worker.d.ts.map +1 -0
- package/dist/authoring/worker.js +163 -0
- package/dist/authoring/worker.js.map +1 -0
- package/dist/authoring.d.ts +12 -0
- package/dist/authoring.d.ts.map +1 -0
- package/dist/authoring.js +9 -0
- package/dist/authoring.js.map +1 -0
- package/dist/docs/guides/agent-authoring.md +240 -0
- package/dist/docs/guides/package.md +87 -0
- package/dist/docs/manifest.json +554 -0
- package/dist/docs/reference/authoring/AUTHORING_PROTOCOL_VERSION.md +9 -0
- package/dist/docs/reference/authoring/AuthoringDiagnostic.md +22 -0
- package/dist/docs/reference/authoring/AuthoringEnvironment.md +15 -0
- package/dist/docs/reference/authoring/AuthoringError.md +16 -0
- package/dist/docs/reference/authoring/AuthoringFailure-type.md +18 -0
- package/dist/docs/reference/authoring/AuthoringKind.md +10 -0
- package/dist/docs/reference/authoring/AuthoringPhase.md +10 -0
- package/dist/docs/reference/authoring/CapturedBuffer.md +14 -0
- package/dist/docs/reference/authoring/CapturedGeometry.md +14 -0
- package/dist/docs/reference/authoring/CapturedPart.md +19 -0
- package/dist/docs/reference/authoring/CapturedResource.md +15 -0
- package/dist/docs/reference/authoring/CapturedRun.md +14 -0
- package/dist/docs/reference/authoring/CapturedRunManifest.md +40 -0
- package/dist/docs/reference/authoring/CheckOptions.md +18 -0
- package/dist/docs/reference/authoring/CheckSuccess.md +16 -0
- package/dist/docs/reference/authoring/DocumentationEntry.md +20 -0
- package/dist/docs/reference/authoring/DocumentationManifest.md +15 -0
- package/dist/docs/reference/authoring/DocumentationSearchResult.md +13 -0
- package/dist/docs/reference/authoring/InstalledAuthoringPackage.md +15 -0
- package/dist/docs/reference/authoring/RenderCamera.md +22 -0
- package/dist/docs/reference/authoring/RenderFormat.md +10 -0
- package/dist/docs/reference/authoring/RenderOptions.md +20 -0
- package/dist/docs/reference/authoring/RenderResult.md +15 -0
- package/dist/docs/reference/authoring/RenderView.md +10 -0
- package/dist/docs/reference/authoring/RenderedImage.md +23 -0
- package/dist/docs/reference/authoring/RunOptions.md +25 -0
- package/dist/docs/reference/authoring/RunSuccess.md +14 -0
- package/dist/docs/reference/authoring/authoringFailure-value.md +10 -0
- package/dist/docs/reference/authoring/checkAuthoringSource.md +10 -0
- package/dist/docs/reference/authoring/discoverAuthoringEnvironment.md +13 -0
- package/dist/docs/reference/authoring/inspectCapturedRun.md +15 -0
- package/dist/docs/reference/authoring/installAuthoringBrowser.md +13 -0
- package/dist/docs/reference/authoring/readCapturedRun.md +10 -0
- package/dist/docs/reference/authoring/renderCapturedRun.md +13 -0
- package/dist/docs/reference/authoring/runAuthoringSource.md +13 -0
- package/dist/docs/reference/authoring/searchAuthoringDocumentation.md +16 -0
- package/dist/docs/reference/authoring/showAuthoringDocumentation.md +12 -0
- package/dist/metamesh.d.ts +3 -0
- package/dist/metamesh.d.ts.map +1 -0
- package/dist/metamesh.js +183 -0
- package/dist/metamesh.js.map +1 -0
- package/package.json +63 -3
|
@@ -0,0 +1,163 @@
|
|
|
1
|
+
import { readFile, writeFile } from "node:fs/promises";
|
|
2
|
+
import { pathToFileURL } from "node:url";
|
|
3
|
+
import { captureSnapshot } from "./artifacts.js";
|
|
4
|
+
import { AuthoringError, authoringFailure, isRecord } from "./errors.js";
|
|
5
|
+
function program(value) {
|
|
6
|
+
return isRecord(value) && value.kind === "metamesh-model" && typeof value.generate === "function";
|
|
7
|
+
}
|
|
8
|
+
async function execute(request) {
|
|
9
|
+
let snapshot;
|
|
10
|
+
let dispose;
|
|
11
|
+
let phase = "execute";
|
|
12
|
+
try {
|
|
13
|
+
const entry = await import(pathToFileURL(request.modulePath).href);
|
|
14
|
+
if (!isRecord(entry))
|
|
15
|
+
throw new AuthoringError("execute", "INVALID_ENTRY", "Author entry is not a module.", 1);
|
|
16
|
+
let model;
|
|
17
|
+
let definition;
|
|
18
|
+
let parameters = request.params;
|
|
19
|
+
if (request.kind === "generator") {
|
|
20
|
+
phase = "parameters";
|
|
21
|
+
if (request.packagesPath === undefined || request.parametersPath === undefined)
|
|
22
|
+
throw new AuthoringError("environment", "SDK_NOT_INSTALLED", "Generator execution requires the installed SDK.");
|
|
23
|
+
const packages = (await import(pathToFileURL(request.packagesPath).href));
|
|
24
|
+
const params = (await import(pathToFileURL(request.parametersPath).href));
|
|
25
|
+
definition = packages.parseGeneratorDefinition(entry.definition);
|
|
26
|
+
const parsed = params
|
|
27
|
+
.createParamCodec(definition)
|
|
28
|
+
.safeParse({ ...params.getDefaultParameters(definition), ...request.params });
|
|
29
|
+
if (!parsed.success)
|
|
30
|
+
return {
|
|
31
|
+
success: false,
|
|
32
|
+
phase: "parameters",
|
|
33
|
+
exitCode: 1,
|
|
34
|
+
diagnostics: parsed.issues.map((issue) => ({ ...issue, severity: "error" })),
|
|
35
|
+
};
|
|
36
|
+
parameters = parsed.data;
|
|
37
|
+
const runtime = entry.default;
|
|
38
|
+
if (!isRecord(runtime) ||
|
|
39
|
+
runtime.formatVersion !== packages.GENERATOR_PACKAGE_FORMAT_VERSION ||
|
|
40
|
+
runtime.generatorId !== definition.id ||
|
|
41
|
+
runtime.version !== definition.version ||
|
|
42
|
+
!program(runtime.generate))
|
|
43
|
+
throw new AuthoringError("execute", "INVALID_GENERATOR_MODULE", "Default export must be the Generator module envelope matching definition.", 1);
|
|
44
|
+
model = runtime.generate;
|
|
45
|
+
}
|
|
46
|
+
else {
|
|
47
|
+
if (!program(entry.default))
|
|
48
|
+
throw new AuthoringError("execute", "INVALID_MODEL_PROGRAM", "Default export must be an ordinary ModelProgram.", 1);
|
|
49
|
+
model = entry.default;
|
|
50
|
+
}
|
|
51
|
+
phase = "assets";
|
|
52
|
+
const loaded = request.fontFixtures === undefined
|
|
53
|
+
? undefined
|
|
54
|
+
: await (await import("@metamesh/testkit/font-fixtures")).loadFontFixtures(request.fontFixtures);
|
|
55
|
+
let services;
|
|
56
|
+
if (definition !== undefined) {
|
|
57
|
+
if (loaded !== undefined)
|
|
58
|
+
services = await loaded.prepareServices(definition, parameters);
|
|
59
|
+
else if (definition.parameters.some(({ type }) => type === "font"))
|
|
60
|
+
throw new AuthoringError("assets", "FONT_FIXTURES_REQUIRED", "Generator Font parameters require --font-fixtures <local-descriptors.json>.", 1);
|
|
61
|
+
else {
|
|
62
|
+
if (request.sdkPath === undefined)
|
|
63
|
+
throw new AuthoringError("environment", "SDK_NOT_INSTALLED", "Generator execution requires the installed SDK.");
|
|
64
|
+
services = (await import(pathToFileURL(request.sdkPath).href))
|
|
65
|
+
.UNPREPARED_GENERATOR_SERVICES;
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
phase = "execute";
|
|
69
|
+
const { createModelEngine } = (await import(pathToFileURL(request.enginePath).href));
|
|
70
|
+
const engine = await createModelEngine();
|
|
71
|
+
const session = services === undefined
|
|
72
|
+
? engine.createSession(model, {
|
|
73
|
+
limits: request.metadata.policy.limits,
|
|
74
|
+
})
|
|
75
|
+
: engine.createSession(model, {
|
|
76
|
+
services,
|
|
77
|
+
limits: request.metadata.policy.limits,
|
|
78
|
+
});
|
|
79
|
+
dispose = () => session.dispose();
|
|
80
|
+
snapshot = session.run(parameters);
|
|
81
|
+
const exported = request.export3mf ? await engine.export3mf(snapshot.parts) : undefined;
|
|
82
|
+
phase = "artifact";
|
|
83
|
+
const selectedAssets = definition === undefined
|
|
84
|
+
? (loaded?.selections ?? [])
|
|
85
|
+
: definition.parameters
|
|
86
|
+
.filter(({ type }) => type === "font")
|
|
87
|
+
.map(({ id }) => parameters[id])
|
|
88
|
+
.filter((value) => isRecord(value) &&
|
|
89
|
+
typeof value.faceId === "string" &&
|
|
90
|
+
typeof value.revision === "string" &&
|
|
91
|
+
typeof value.weight === "number");
|
|
92
|
+
const manifest = await captureSnapshot(request.directory, snapshot, { ...request.metadata, assets: selectedAssets, parameters }, exported);
|
|
93
|
+
return { success: true, runDirectory: request.directory, manifest };
|
|
94
|
+
}
|
|
95
|
+
catch (error) {
|
|
96
|
+
if (error instanceof AuthoringError)
|
|
97
|
+
return authoringFailure(error);
|
|
98
|
+
if (isRecord(error) || error instanceof Error) {
|
|
99
|
+
const shaped = error;
|
|
100
|
+
if (Array.isArray(shaped.issues))
|
|
101
|
+
return {
|
|
102
|
+
success: false,
|
|
103
|
+
phase,
|
|
104
|
+
exitCode: 1,
|
|
105
|
+
diagnostics: shaped.issues.map((issue) => ({
|
|
106
|
+
...issue,
|
|
107
|
+
code: issue.code ?? "INVALID_DEFINITION",
|
|
108
|
+
severity: "error",
|
|
109
|
+
})),
|
|
110
|
+
};
|
|
111
|
+
if (Array.isArray(shaped.diagnostics))
|
|
112
|
+
return {
|
|
113
|
+
success: false,
|
|
114
|
+
phase,
|
|
115
|
+
exitCode: 1,
|
|
116
|
+
diagnostics: shaped.diagnostics.map((issue) => ({
|
|
117
|
+
...issue,
|
|
118
|
+
code: issue.code ?? "GENERATION_ASSERTION",
|
|
119
|
+
})),
|
|
120
|
+
};
|
|
121
|
+
if (typeof shaped.code === "string" && isRecord(shaped.context))
|
|
122
|
+
return {
|
|
123
|
+
success: false,
|
|
124
|
+
phase,
|
|
125
|
+
exitCode: 1,
|
|
126
|
+
diagnostics: [
|
|
127
|
+
{
|
|
128
|
+
code: shaped.code,
|
|
129
|
+
severity: "error",
|
|
130
|
+
message: error instanceof Error ? error.message : "Geometry failure",
|
|
131
|
+
context: shaped.context,
|
|
132
|
+
},
|
|
133
|
+
],
|
|
134
|
+
};
|
|
135
|
+
}
|
|
136
|
+
return {
|
|
137
|
+
success: false,
|
|
138
|
+
phase,
|
|
139
|
+
exitCode: phase === "artifact" ? 2 : 1,
|
|
140
|
+
diagnostics: [
|
|
141
|
+
{
|
|
142
|
+
code: phase === "assets" ? "ASSET_PREPARATION_FAILED" : "EXECUTION_FAILED",
|
|
143
|
+
severity: "error",
|
|
144
|
+
message: error instanceof Error ? error.message : String(error),
|
|
145
|
+
...(error instanceof Error && error.stack !== undefined
|
|
146
|
+
? { context: { stack: error.stack } }
|
|
147
|
+
: {}),
|
|
148
|
+
},
|
|
149
|
+
],
|
|
150
|
+
};
|
|
151
|
+
}
|
|
152
|
+
finally {
|
|
153
|
+
snapshot?.dispose();
|
|
154
|
+
dispose?.();
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
const requestFile = process.argv[2];
|
|
158
|
+
const resultFile = process.argv[3];
|
|
159
|
+
if (requestFile !== undefined && resultFile !== undefined) {
|
|
160
|
+
const result = await execute(JSON.parse(await readFile(requestFile, "utf8")));
|
|
161
|
+
await writeFile(resultFile, JSON.stringify(result));
|
|
162
|
+
}
|
|
163
|
+
//# sourceMappingURL=worker.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"worker.js","sourceRoot":"","sources":["../../src/authoring/worker.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AACvD,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AASzC,OAAO,EAAE,eAAe,EAAE,MAAM,gBAAgB,CAAC;AACjD,OAAO,EAAE,cAAc,EAAE,gBAAgB,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AAiCzE,SAAS,OAAO,CAAC,KAAc;IAC7B,OAAO,QAAQ,CAAC,KAAK,CAAC,IAAI,KAAK,CAAC,IAAI,KAAK,gBAAgB,IAAI,OAAO,KAAK,CAAC,QAAQ,KAAK,UAAU,CAAC;AACpG,CAAC;AAED,KAAK,UAAU,OAAO,CAAC,OAAsB;IAC3C,IAAI,QAAmC,CAAC;IACxC,IAAI,OAAiC,CAAC;IACtC,IAAI,KAAK,GAA8B,SAAS,CAAC;IACjD,IAAI,CAAC;QACH,MAAM,KAAK,GAAY,MAAM,MAAM,CAAC,aAAa,CAAC,OAAO,CAAC,UAAU,CAAC,CAAC,IAAI,CAAC,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AAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC;oBAC/D,GAAG,CAAC,KAAK,YAAY,KAAK,IAAI,KAAK,CAAC,KAAK,KAAK,SAAS;wBACrD,CAAC,CAAC,EAAE,OAAO,EAAE,EAAE,KAAK,EAAE,KAAK,CAAC,KAAK,EAAE,EAAE;wBACrC,CAAC,CAAC,EAAE,CAAC;iBACR;aACF;SACF,CAAC;IACJ,CAAC;YAAS,CAAC;QACT,QAAQ,EAAE,OAAO,EAAE,CAAC;QACpB,OAAO,EAAE,EAAE,CAAC;IACd,CAAC;AACH,CAAC;AAED,MAAM,WAAW,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;AACpC,MAAM,UAAU,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;AACnC,IAAI,WAAW,KAAK,SAAS,IAAI,UAAU,KAAK,SAAS,EAAE,CAAC;IAC1D,MAAM,MAAM,GAAG,MAAM,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,MAAM,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAC,CAAkB,CAAC,CAAC;IAC/F,MAAM,SAAS,CAAC,UAAU,EAAE,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,CAAC,CAAC;AACtD,CAAC"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/** Node-only authoring tools for trusted local MetaMesh source. */
|
|
2
|
+
export { AUTHORING_PROTOCOL_VERSION } from "./authoring/types.js";
|
|
3
|
+
export type { AuthoringDiagnostic, AuthoringEnvironment, AuthoringFailure, AuthoringKind, AuthoringPhase, CapturedBuffer, CapturedGeometry, CapturedPart, CapturedResource, CapturedRun, CapturedRunManifest, CheckOptions, CheckSuccess, DocumentationEntry, DocumentationManifest, InstalledAuthoringPackage, RunOptions, RunSuccess, } from "./authoring/types.js";
|
|
4
|
+
export { AuthoringError, authoringFailure } from "./authoring/errors.js";
|
|
5
|
+
export { discoverAuthoringEnvironment, searchAuthoringDocumentation, showAuthoringDocumentation, } from "./authoring/environment.js";
|
|
6
|
+
export type { DocumentationSearchResult } from "./authoring/environment.js";
|
|
7
|
+
export { checkAuthoringSource } from "./authoring/check.js";
|
|
8
|
+
export { runAuthoringSource } from "./authoring/run.js";
|
|
9
|
+
export { inspectCapturedRun, readCapturedRun } from "./authoring/artifacts.js";
|
|
10
|
+
export { renderCapturedRun, installAuthoringBrowser } from "./authoring/render.js";
|
|
11
|
+
export type { RenderOptions, RenderResult, RenderView, RenderFormat, RenderCamera, RenderedImage, } from "./authoring/render-types.js";
|
|
12
|
+
//# sourceMappingURL=authoring.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"authoring.d.ts","sourceRoot":"","sources":["../src/authoring.ts"],"names":[],"mappings":"AAAA,mEAAmE;AACnE,OAAO,EAAE,0BAA0B,EAAE,MAAM,sBAAsB,CAAC;AAClE,YAAY,EACV,mBAAmB,EACnB,oBAAoB,EACpB,gBAAgB,EAChB,aAAa,EACb,cAAc,EACd,cAAc,EACd,gBAAgB,EAChB,YAAY,EACZ,gBAAgB,EAChB,WAAW,EACX,mBAAmB,EACnB,YAAY,EACZ,YAAY,EACZ,kBAAkB,EAClB,qBAAqB,EACrB,yBAAyB,EACzB,UAAU,EACV,UAAU,GACX,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EAAE,cAAc,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAC;AACzE,OAAO,EACL,4BAA4B,EAC5B,4BAA4B,EAC5B,0BAA0B,GAC3B,MAAM,4BAA4B,CAAC;AACpC,YAAY,EAAE,yBAAyB,EAAE,MAAM,4BAA4B,CAAC;AAC5E,OAAO,EAAE,oBAAoB,EAAE,MAAM,sBAAsB,CAAC;AAC5D,OAAO,EAAE,kBAAkB,EAAE,MAAM,oBAAoB,CAAC;AACxD,OAAO,EAAE,kBAAkB,EAAE,eAAe,EAAE,MAAM,0BAA0B,CAAC;AAC/E,OAAO,EAAE,iBAAiB,EAAE,uBAAuB,EAAE,MAAM,uBAAuB,CAAC;AACnF,YAAY,EACV,aAAa,EACb,YAAY,EACZ,UAAU,EACV,YAAY,EACZ,YAAY,EACZ,aAAa,GACd,MAAM,6BAA6B,CAAC"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/** Node-only authoring tools for trusted local MetaMesh source. */
|
|
2
|
+
export { AUTHORING_PROTOCOL_VERSION } from "./authoring/types.js";
|
|
3
|
+
export { AuthoringError, authoringFailure } from "./authoring/errors.js";
|
|
4
|
+
export { discoverAuthoringEnvironment, searchAuthoringDocumentation, showAuthoringDocumentation, } from "./authoring/environment.js";
|
|
5
|
+
export { checkAuthoringSource } from "./authoring/check.js";
|
|
6
|
+
export { runAuthoringSource } from "./authoring/run.js";
|
|
7
|
+
export { inspectCapturedRun, readCapturedRun } from "./authoring/artifacts.js";
|
|
8
|
+
export { renderCapturedRun, installAuthoringBrowser } from "./authoring/render.js";
|
|
9
|
+
//# sourceMappingURL=authoring.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"authoring.js","sourceRoot":"","sources":["../src/authoring.ts"],"names":[],"mappings":"AAAA,mEAAmE;AACnE,OAAO,EAAE,0BAA0B,EAAE,MAAM,sBAAsB,CAAC;AAqBlE,OAAO,EAAE,cAAc,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAC;AACzE,OAAO,EACL,4BAA4B,EAC5B,4BAA4B,EAC5B,0BAA0B,GAC3B,MAAM,4BAA4B,CAAC;AAEpC,OAAO,EAAE,oBAAoB,EAAE,MAAM,sBAAsB,CAAC;AAC5D,OAAO,EAAE,kBAAkB,EAAE,MAAM,oBAAoB,CAAC;AACxD,OAAO,EAAE,kBAAkB,EAAE,eAAe,EAAE,MAAM,0BAA0B,CAAC;AAC/E,OAAO,EAAE,iBAAiB,EAAE,uBAAuB,EAAE,MAAM,uBAAuB,CAAC"}
|
|
@@ -0,0 +1,240 @@
|
|
|
1
|
+
# Author and inspect models with an agent
|
|
2
|
+
|
|
3
|
+
Find installed documentation, check TypeScript, generate a captured model, and inspect its measurements and rendered views locally.
|
|
4
|
+
|
|
5
|
+
The `metamesh` CLI gives coding agents and developers the same local workflow: look up the
|
|
6
|
+
installed API, check source, execute the real engine, and inspect a captured result. It runs trusted
|
|
7
|
+
local TypeScript with your ordinary Node permissions. The child process is disposable; it is not a
|
|
8
|
+
security sandbox.
|
|
9
|
+
|
|
10
|
+
## Install and discover the environment
|
|
11
|
+
|
|
12
|
+
Install Modeling for your model code and the CLI for the local authoring workflow:
|
|
13
|
+
|
|
14
|
+
```bash
|
|
15
|
+
pnpm add @metamesh/modeling
|
|
16
|
+
pnpm add -D @metamesh/cli
|
|
17
|
+
pnpm exec metamesh environment --json
|
|
18
|
+
pnpm exec metamesh setup
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
`environment` reports project-resolved versions, documentation locations, available capabilities,
|
|
22
|
+
and `authoringProtocolVersion: 1`. An agent integration should check that protocol value before
|
|
23
|
+
using the commands. Missing packages, mismatched releases, or an unsupported protocol need an
|
|
24
|
+
environment fix before authoring.
|
|
25
|
+
|
|
26
|
+
Add the Generator SDK as a direct dependency when defining Generators, and Testkit when writing
|
|
27
|
+
automated tests. A project that only runs ordinary models needs Modeling and the CLI as its direct
|
|
28
|
+
dependencies. Keep installed MetaMesh packages on matching releases.
|
|
29
|
+
|
|
30
|
+
| Component | Responsibility |
|
|
31
|
+
| ------------------------- | --------------------------------------------------------------------------------------------- |
|
|
32
|
+
| `@metamesh/modeling` | Geometry operations, synchronous generation, engine sessions, and completed snapshots |
|
|
33
|
+
| `@metamesh/generator-sdk` | Serializable controls, parameter types and validation, and Generator module envelopes |
|
|
34
|
+
| `@metamesh/cli` | Installed documentation lookup, TypeScript checking, captured runs, inspection, and rendering |
|
|
35
|
+
| `@metamesh/testkit` | Test runners, fixtures, and assertions used by your existing test framework |
|
|
36
|
+
|
|
37
|
+
Every public package exposes its offline documentation manifest through `./docs/manifest.json`.
|
|
38
|
+
The CLI searches the packages installed in the selected project. Find a topic in the bounded index,
|
|
39
|
+
then read the returned document ID:
|
|
40
|
+
|
|
41
|
+
```bash
|
|
42
|
+
pnpm exec metamesh docs search "cylinder"
|
|
43
|
+
pnpm exec metamesh docs show modeling/reference/model/cylinder
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
Documentation is resolved from the selected project through package exports. No global installation
|
|
47
|
+
or documentation fetched from a moving Git branch replaces the installed version.
|
|
48
|
+
|
|
49
|
+
### Give an agent the same workflow
|
|
50
|
+
|
|
51
|
+
`setup` prints skill installation guidance and a project-instruction snippet for review. It does
|
|
52
|
+
not modify files, install a skill, or initialize a model. The optional `metamesh-developer` skill
|
|
53
|
+
describes the authoring and verification workflow; `metamesh-docs` supports documentation work.
|
|
54
|
+
Both are maintained separately in `metamesh-studio/metamesh-skills`.
|
|
55
|
+
|
|
56
|
+
Use a reviewed skill snapshot provided by your project or installed through your agent's skill
|
|
57
|
+
tooling. The printed GitHub installation source must be published before that command can work;
|
|
58
|
+
a skill is optional for the CLI workflow below. Skills teach the process. The installed npm
|
|
59
|
+
documentation owns exact signatures, import paths, units, lifecycle, and availability.
|
|
60
|
+
|
|
61
|
+
Project instructions should ask the agent to discover the environment, look up relevant installed
|
|
62
|
+
topics, check and run the current source, then inspect measurements and render useful views from
|
|
63
|
+
that same run directory. Include the commands and required checks that belong to your project.
|
|
64
|
+
When targeting another project directory, pass `--project PATH` consistently so discovery, lookup,
|
|
65
|
+
checking, and execution resolve the same installation.
|
|
66
|
+
|
|
67
|
+
## Model entries
|
|
68
|
+
|
|
69
|
+
A model entry default-exports an ordinary `ModelProgram`. It imports the real package; Studio's
|
|
70
|
+
virtual `@metamesh/project` module is not available in local Node projects.
|
|
71
|
+
|
|
72
|
+
|
|
73
|
+
|
|
74
|
+
```ts
|
|
75
|
+
import { box, cylinder, generate } from "@metamesh/modeling";
|
|
76
|
+
|
|
77
|
+
export default generate<Record<never, never>>(({ part }) => {
|
|
78
|
+
const body = box({ size: [30, 20, 6] });
|
|
79
|
+
const bore = cylinder({ height: 8, radius: 3, sizing: "face" });
|
|
80
|
+
return part("plate", body.subtract([bore]));
|
|
81
|
+
});
|
|
82
|
+
```
|
|
83
|
+
|
|
84
|
+
|
|
85
|
+
|
|
86
|
+
Save this as `model.ts`, then check and run it:
|
|
87
|
+
|
|
88
|
+
```bash
|
|
89
|
+
pnpm exec metamesh check model.ts --kind model
|
|
90
|
+
pnpm exec metamesh run model.ts --kind model --export-3mf
|
|
91
|
+
```
|
|
92
|
+
|
|
93
|
+
Both commands perform semantic TypeScript checking. They use the nearest project TypeScript
|
|
94
|
+
configuration, or an explicit `--tsconfig`, with strict checking enforced. Ordinary local imports
|
|
95
|
+
and installed dependencies are supported. `check` does not evaluate your source.
|
|
96
|
+
|
|
97
|
+
Use `--params values.json` for a model's JSON parameter map; the default is `{}`. Models do not
|
|
98
|
+
receive injected Generator services. A standalone module can prepare licensed local fonts before
|
|
99
|
+
constructing its synchronous generation program.
|
|
100
|
+
|
|
101
|
+
For standalone font provenance, also pass `--font-fixtures fonts.json`. The CLI verifies those local
|
|
102
|
+
bytes and records their declared font selections and immutable revisions in the capture; the model
|
|
103
|
+
still prepares its own fonts and receives no injected services. Arbitrary filesystem or network
|
|
104
|
+
reads are not intercepted, so their asset identities cannot be inferred. The source fingerprint
|
|
105
|
+
covers bundled source, while fixture descriptors provide explicit asset provenance.
|
|
106
|
+
|
|
107
|
+
## Generator entries
|
|
108
|
+
|
|
109
|
+
Install the Generator contract layer in addition to Modeling and the CLI:
|
|
110
|
+
|
|
111
|
+
```bash
|
|
112
|
+
pnpm add @metamesh/generator-sdk
|
|
113
|
+
```
|
|
114
|
+
|
|
115
|
+
A Generator entry named-exports `definition` and default-exports its module envelope:
|
|
116
|
+
|
|
117
|
+
|
|
118
|
+
|
|
119
|
+
```ts
|
|
120
|
+
import {
|
|
121
|
+
defineGenerator,
|
|
122
|
+
defineGeneratorModule,
|
|
123
|
+
type GeneratorParams,
|
|
124
|
+
} from "@metamesh/generator-sdk";
|
|
125
|
+
import { box, generate } from "@metamesh/modeling";
|
|
126
|
+
|
|
127
|
+
export const definition = defineGenerator({
|
|
128
|
+
id: "plate",
|
|
129
|
+
version: "0.1.0",
|
|
130
|
+
title: "Plate",
|
|
131
|
+
groups: [],
|
|
132
|
+
parameters: [{ id: "width", label: "Width", type: "number", default: 30, min: 1 }],
|
|
133
|
+
});
|
|
134
|
+
|
|
135
|
+
const model = generate<GeneratorParams<typeof definition>>(({ params, part }) =>
|
|
136
|
+
part("plate", box({ size: [params.width, 20, 6] }))
|
|
137
|
+
);
|
|
138
|
+
|
|
139
|
+
export default defineGeneratorModule({ definition, generate: model });
|
|
140
|
+
```
|
|
141
|
+
|
|
142
|
+
|
|
143
|
+
|
|
144
|
+
```bash
|
|
145
|
+
pnpm exec metamesh check generator.ts --kind generator
|
|
146
|
+
pnpm exec metamesh run generator.ts --kind generator --params values.json
|
|
147
|
+
```
|
|
148
|
+
|
|
149
|
+
Generator runs merge declared defaults with explicit overrides, then validate strictly. Unknown
|
|
150
|
+
keys, invalid values, and unsupported combinations produce diagnostics. They are not silently
|
|
151
|
+
clamped or repaired. Use assertions for relationships between parameters.
|
|
152
|
+
|
|
153
|
+
Generators with Font controls supply a local font-fixture descriptor with `--font-fixtures fonts.json`.
|
|
154
|
+
Fixtures resolve beside that descriptor and must match their immutable revisions. Missing
|
|
155
|
+
bytes and revision mismatches fail before generation; the CLI does not fetch catalog fonts.
|
|
156
|
+
|
|
157
|
+
## Inspect the captured result
|
|
158
|
+
|
|
159
|
+
Each run creates a unique directory under `.metamesh/runs`, or the explicit output parent. Use the
|
|
160
|
+
run directory reported by that command as `RUN_DIRECTORY` below:
|
|
161
|
+
|
|
162
|
+
```bash
|
|
163
|
+
pnpm exec metamesh inspect RUN_DIRECTORY
|
|
164
|
+
pnpm exec metamesh inspect RUN_DIRECTORY --part plate
|
|
165
|
+
pnpm exec metamesh browser install
|
|
166
|
+
pnpm exec metamesh render RUN_DIRECTORY
|
|
167
|
+
pnpm exec metamesh render RUN_DIRECTORY --views top --format webp --transparent
|
|
168
|
+
```
|
|
169
|
+
|
|
170
|
+
Inspection reads finalized geometry facts, including semantic part IDs, placements, colors,
|
|
171
|
+
measurements, diagnostics, and execution provenance. Rendering reads the same captured buffers
|
|
172
|
+
without executing the model again. Artifacts remain usable after the engine session is disposed or
|
|
173
|
+
the run directory is moved. Corrupt or incomplete artifacts reject.
|
|
174
|
+
|
|
175
|
+
Rendering requires the separately installed pinned Chromium. It is never downloaded implicitly;
|
|
176
|
+
checking, generation, and inspection work without it. Standard orthographic views are isometric,
|
|
177
|
+
front, top, and right. The default is an isometric 1024 × 1024 PNG on a neutral background. WebP is
|
|
178
|
+
lossless; PNG and WebP both support explicit transparent output. Images record their run, camera,
|
|
179
|
+
renderer, and browser versions. Compare pixels only within the pinned capture environment.
|
|
180
|
+
|
|
181
|
+
`--export-3mf` exports that run's finalized snapshot. A failed attempt never exposes an older
|
|
182
|
+
successful result as its output. Match the captured parameters and source fingerprint to the
|
|
183
|
+
revision you intended to verify.
|
|
184
|
+
|
|
185
|
+
## Test models
|
|
186
|
+
|
|
187
|
+
Install Testkit separately when you want assertions and fixtures for your existing test runner:
|
|
188
|
+
|
|
189
|
+
```bash
|
|
190
|
+
pnpm add -D @metamesh/testkit
|
|
191
|
+
```
|
|
192
|
+
|
|
193
|
+
Use `createGeneratorTestRunner(definition, runtime)` for a Generator's persistent generation
|
|
194
|
+
session. Its `execute` method returns a discriminated result: handle `type: "invalid"` before
|
|
195
|
+
reading a generated `model`. Dispose each successful `model` when finished and dispose the runner
|
|
196
|
+
separately; snapshots remain usable after the runner is disposed.
|
|
197
|
+
Unexpected execution or malformed-output errors reject instead of returning an `invalid` result.
|
|
198
|
+
For an ordinary `ModelProgram`, use an [engine session](https://metamesh.studio/docs/engine/hosting) and the same assertions
|
|
199
|
+
against its completed snapshot.
|
|
200
|
+
|
|
201
|
+
The runner normalizes saved values. To probe deliberately invalid typed inputs without that
|
|
202
|
+
recovery, call `runner.validate(parameters, { normalize: false })`. Validation checks declarations
|
|
203
|
+
and reached assertions without finalizing output; execute representative valid combinations too.
|
|
204
|
+
The CLI's strict overrides serve a different purpose: they reject invalid or unknown values
|
|
205
|
+
before execution instead of recovering saved state.
|
|
206
|
+
|
|
207
|
+
| Helper | What to check |
|
|
208
|
+
| ------------------------------ | ------------------------------------------------------------------ |
|
|
209
|
+
| `expectSerializableDefinition` | Strict definition parsing and a canonical JSON round trip |
|
|
210
|
+
| `expectValidDefaults` | Strict parameter decoding and agreement with defaults |
|
|
211
|
+
| `expectValidPresets` | Serializable preset metadata; execute presets for domain rules |
|
|
212
|
+
| `expectValidParts` | Part metadata, closed oriented topology, and native reconstruction |
|
|
213
|
+
| `expectMeshMeasurements` | Bounds, area, signed volume, and connected-component count |
|
|
214
|
+
|
|
215
|
+
Compare physical measurements with explicit absolute tolerances; bounds use millimetres, area
|
|
216
|
+
square millimetres, and volume cubic millimetres. Component counts are exact. Rendered views
|
|
217
|
+
complement those assertions. A valid solid alone does not prove a suitable fit or manufacturable
|
|
218
|
+
wall thickness.
|
|
219
|
+
|
|
220
|
+
For Font controls, supply the runner's `prepareServices` option using checked-in licensed bytes.
|
|
221
|
+
`prepareFontTestServices` from `@metamesh/testkit/fonts` verifies immutable font revisions and
|
|
222
|
+
prepares services without catalog downloads. Modeling's optional font peers are still required.
|
|
223
|
+
Use installed documentation for the exact runner and fixture signatures:
|
|
224
|
+
|
|
225
|
+
```bash
|
|
226
|
+
pnpm exec metamesh docs show testkit/guide/testing
|
|
227
|
+
```
|
|
228
|
+
|
|
229
|
+
Testkit has no compiler, renderer, or browser dependencies. The CLI owns those tools and its
|
|
230
|
+
reusable Node functions under `@metamesh/cli/authoring`; integrations can call them without
|
|
231
|
+
spawning the command.
|
|
232
|
+
|
|
233
|
+
## Command results
|
|
234
|
+
|
|
235
|
+
The CLI defaults to concise human output. Add `--json` for one structured stdout result, with
|
|
236
|
+
bounded author logs on stderr. Exit status is `0` for success, `1` for source, parameter, or
|
|
237
|
+
generation failure, and `2` for invocation, environment, artifact, or tooling failure. Runs have a
|
|
238
|
+
30-second default execution deadline and can lower engine resource ceilings.
|
|
239
|
+
|
|
240
|
+
Modeling and the Generator SDK remain independent of the CLI and its local Node tooling.
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
# `@metamesh/cli`
|
|
2
|
+
|
|
3
|
+
Check, execute, inspect, and render trusted local MetaMesh source. The `metamesh` executable and
|
|
4
|
+
Node-only `/authoring` functions use the production engine and version-matched installed documentation.
|
|
5
|
+
|
|
6
|
+
> **Preview:** `0.x` minor releases may break compatibility. Patches remain compatible within the
|
|
7
|
+
> same minor line.
|
|
8
|
+
|
|
9
|
+
## Installation
|
|
10
|
+
|
|
11
|
+
Install the same exact release of each MetaMesh package in the project where you author models:
|
|
12
|
+
|
|
13
|
+
```bash
|
|
14
|
+
pnpm add @metamesh/modeling
|
|
15
|
+
pnpm add -D @metamesh/cli
|
|
16
|
+
```
|
|
17
|
+
|
|
18
|
+
Add `@metamesh/generator-sdk` when your source defines Generators. Add `@metamesh/testkit` as a
|
|
19
|
+
development dependency when importing testing helpers. CLI internally reuses Testkit font fixtures
|
|
20
|
+
and its SDK contracts; neither package needs to be directly declared for standalone model authoring.
|
|
21
|
+
The compiler, bundler, Three renderer, and Playwright belong to CLI; Testkit does not install them.
|
|
22
|
+
Chromium is installed separately and never downloaded by checking or generation.
|
|
23
|
+
|
|
24
|
+
## Local workflow
|
|
25
|
+
|
|
26
|
+
```bash
|
|
27
|
+
pnpm exec metamesh environment --json
|
|
28
|
+
pnpm exec metamesh docs search "extrude"
|
|
29
|
+
pnpm exec metamesh docs show TOPIC_ID
|
|
30
|
+
pnpm exec metamesh check model.ts --kind model
|
|
31
|
+
pnpm exec metamesh run model.ts --kind model
|
|
32
|
+
pnpm exec metamesh inspect RUN_DIRECTORY
|
|
33
|
+
pnpm exec metamesh browser install
|
|
34
|
+
pnpm exec metamesh render RUN_DIRECTORY --views isometric,front,top,right
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
`environment` reports `authoringProtocolVersion: 1`, installed package versions, capabilities,
|
|
38
|
+
and documentation manifest paths. Mixed package versions or stale documentation fail before
|
|
39
|
+
generation. Commands resolve packages and relative paths from the current project; pass
|
|
40
|
+
`--project PATH` to select another project explicitly. `TOPIC_ID` comes from documentation search;
|
|
41
|
+
`RUN_DIRECTORY` comes from a successful run.
|
|
42
|
+
|
|
43
|
+
`run` includes semantic TypeScript checking and executes in a disposable child process with a
|
|
44
|
+
30-second default deadline. It saves each attempt beneath `.metamesh/runs` with source identity,
|
|
45
|
+
parameters, diagnostics, measurements, and hashed geometry buffers. `inspect` and `render` validate
|
|
46
|
+
those captured buffers without importing the original source. Use `--json` for one structured stdout
|
|
47
|
+
result; bounded author logs go to stderr. Exit codes are 0 for success, 1 for source or generation
|
|
48
|
+
failure, and 2 for invocation, environment, artifact, or tooling failure. This executes trusted local
|
|
49
|
+
code and is not a security sandbox.
|
|
50
|
+
|
|
51
|
+
For Generators, use `--kind generator`. Entries named-export `definition` and default-export the
|
|
52
|
+
Generator module envelope. Defaults merge with `--params parameters.json`, then strict validation
|
|
53
|
+
rejects unknown or invalid overrides. Standalone model entries default-export a `ModelProgram` and
|
|
54
|
+
receive no injected services. Both support normal local imports and installed dependencies; Studio's
|
|
55
|
+
virtual `@metamesh/project` module is unavailable.
|
|
56
|
+
|
|
57
|
+
Use `--help` on each command for parameters, fonts, resource limits, export, and image options.
|
|
58
|
+
`metamesh setup` prints installation guidance for `metamesh-developer` from the canonical
|
|
59
|
+
`metamesh-studio/metamesh-skills` repository and a project-instruction suggestion without modifying
|
|
60
|
+
files. Its printed GitHub installation command becomes usable when that repository is published;
|
|
61
|
+
the skill supplies the workflow, while installed package documentation supplies exact API facts.
|
|
62
|
+
|
|
63
|
+
## Programmatic API and documentation
|
|
64
|
+
|
|
65
|
+
```ts
|
|
66
|
+
import { inspectCapturedRun, runAuthoringSource } from "@metamesh/cli/authoring";
|
|
67
|
+
|
|
68
|
+
const result = await runAuthoringSource({ entry: "model.ts", kind: "model" });
|
|
69
|
+
if (result.success) {
|
|
70
|
+
console.log(await inspectCapturedRun(result.runDirectory));
|
|
71
|
+
}
|
|
72
|
+
```
|
|
73
|
+
|
|
74
|
+
Resolve `@metamesh/cli/docs/manifest.json` for the installed Markdown reference, or run
|
|
75
|
+
`pnpm exec metamesh docs show cli/guide/agent-authoring` for the complete authoring workflow.
|
|
76
|
+
The [authoring guide source](https://github.com/JasonKoolman/metamesh/blob/main/apps/web/content/docs/develop/agent-authoring.mdx)
|
|
77
|
+
also covers local font fixtures, artifacts, rendering, and agent integration. Until the public
|
|
78
|
+
documentation site launches, use installed documentation, repository sources, or
|
|
79
|
+
[run the docs locally](https://github.com/JasonKoolman/metamesh/blob/main/apps/web/README.md#local-use).
|
|
80
|
+
|
|
81
|
+
The reusable authoring functions and command implementation stay in this package; geometry and
|
|
82
|
+
Generator contracts retain their existing owners. Testing assertions and font-fixture adapters
|
|
83
|
+
remain in Testkit.
|
|
84
|
+
|
|
85
|
+
## License
|
|
86
|
+
|
|
87
|
+
[Apache-2.0](https://github.com/JasonKoolman/metamesh/blob/main/packages/cli/LICENSE).
|