@metamesh/cli 0.0.0-stage → 0.13.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 (99) hide show
  1. package/CHANGELOG.md +27 -0
  2. package/LICENSE +200 -0
  3. package/README.md +71 -2
  4. package/dist/authoring/artifacts.d.ts +11 -0
  5. package/dist/authoring/artifacts.d.ts.map +1 -0
  6. package/dist/authoring/artifacts.js +343 -0
  7. package/dist/authoring/artifacts.js.map +1 -0
  8. package/dist/authoring/capture/render-client.js +4222 -0
  9. package/dist/authoring/capture/render-client.js.LEGAL.txt +9 -0
  10. package/dist/authoring/capture/render-client.js.map +7 -0
  11. package/dist/authoring/check.d.ts +3 -0
  12. package/dist/authoring/check.d.ts.map +1 -0
  13. package/dist/authoring/check.js +117 -0
  14. package/dist/authoring/check.js.map +1 -0
  15. package/dist/authoring/environment.d.ts +19 -0
  16. package/dist/authoring/environment.d.ts.map +1 -0
  17. package/dist/authoring/environment.js +173 -0
  18. package/dist/authoring/environment.js.map +1 -0
  19. package/dist/authoring/errors.d.ts +11 -0
  20. package/dist/authoring/errors.d.ts.map +1 -0
  21. package/dist/authoring/errors.js +41 -0
  22. package/dist/authoring/errors.js.map +1 -0
  23. package/dist/authoring/render-client.d.ts +6 -0
  24. package/dist/authoring/render-client.d.ts.map +1 -0
  25. package/dist/authoring/render-client.js +55 -0
  26. package/dist/authoring/render-client.js.map +1 -0
  27. package/dist/authoring/render-scene.d.ts +22 -0
  28. package/dist/authoring/render-scene.d.ts.map +1 -0
  29. package/dist/authoring/render-scene.js +139 -0
  30. package/dist/authoring/render-scene.js.map +1 -0
  31. package/dist/authoring/render-types.d.ts +81 -0
  32. package/dist/authoring/render-types.d.ts.map +1 -0
  33. package/dist/authoring/render-types.js +2 -0
  34. package/dist/authoring/render-types.js.map +1 -0
  35. package/dist/authoring/render.d.ts +23 -0
  36. package/dist/authoring/render.d.ts.map +1 -0
  37. package/dist/authoring/render.js +243 -0
  38. package/dist/authoring/render.js.map +1 -0
  39. package/dist/authoring/run.d.ts +3 -0
  40. package/dist/authoring/run.d.ts.map +1 -0
  41. package/dist/authoring/run.js +304 -0
  42. package/dist/authoring/run.js.map +1 -0
  43. package/dist/authoring/types.d.ts +138 -0
  44. package/dist/authoring/types.d.ts.map +1 -0
  45. package/dist/authoring/types.js +2 -0
  46. package/dist/authoring/types.js.map +1 -0
  47. package/dist/authoring/worker.d.ts +15 -0
  48. package/dist/authoring/worker.d.ts.map +1 -0
  49. package/dist/authoring/worker.js +163 -0
  50. package/dist/authoring/worker.js.map +1 -0
  51. package/dist/authoring.d.ts +12 -0
  52. package/dist/authoring.d.ts.map +1 -0
  53. package/dist/authoring.js +9 -0
  54. package/dist/authoring.js.map +1 -0
  55. package/dist/docs/guides/agent-authoring.md +183 -0
  56. package/dist/docs/guides/package.md +72 -0
  57. package/dist/docs/manifest.json +554 -0
  58. package/dist/docs/reference/authoring/AUTHORING_PROTOCOL_VERSION.md +9 -0
  59. package/dist/docs/reference/authoring/AuthoringDiagnostic.md +19 -0
  60. package/dist/docs/reference/authoring/AuthoringEnvironment.md +14 -0
  61. package/dist/docs/reference/authoring/AuthoringError.md +15 -0
  62. package/dist/docs/reference/authoring/AuthoringFailure-type.md +15 -0
  63. package/dist/docs/reference/authoring/AuthoringKind.md +9 -0
  64. package/dist/docs/reference/authoring/AuthoringPhase.md +9 -0
  65. package/dist/docs/reference/authoring/CapturedBuffer.md +13 -0
  66. package/dist/docs/reference/authoring/CapturedGeometry.md +13 -0
  67. package/dist/docs/reference/authoring/CapturedPart.md +16 -0
  68. package/dist/docs/reference/authoring/CapturedResource.md +14 -0
  69. package/dist/docs/reference/authoring/CapturedRun.md +13 -0
  70. package/dist/docs/reference/authoring/CapturedRunManifest.md +38 -0
  71. package/dist/docs/reference/authoring/CheckOptions.md +14 -0
  72. package/dist/docs/reference/authoring/CheckSuccess.md +15 -0
  73. package/dist/docs/reference/authoring/DocumentationEntry.md +18 -0
  74. package/dist/docs/reference/authoring/DocumentationManifest.md +14 -0
  75. package/dist/docs/reference/authoring/DocumentationSearchResult.md +12 -0
  76. package/dist/docs/reference/authoring/InstalledAuthoringPackage.md +14 -0
  77. package/dist/docs/reference/authoring/RenderCamera.md +22 -0
  78. package/dist/docs/reference/authoring/RenderFormat.md +10 -0
  79. package/dist/docs/reference/authoring/RenderOptions.md +20 -0
  80. package/dist/docs/reference/authoring/RenderResult.md +15 -0
  81. package/dist/docs/reference/authoring/RenderView.md +10 -0
  82. package/dist/docs/reference/authoring/RenderedImage.md +23 -0
  83. package/dist/docs/reference/authoring/RunOptions.md +17 -0
  84. package/dist/docs/reference/authoring/RunSuccess.md +13 -0
  85. package/dist/docs/reference/authoring/authoringFailure-value.md +9 -0
  86. package/dist/docs/reference/authoring/checkAuthoringSource.md +9 -0
  87. package/dist/docs/reference/authoring/discoverAuthoringEnvironment.md +9 -0
  88. package/dist/docs/reference/authoring/inspectCapturedRun.md +11 -0
  89. package/dist/docs/reference/authoring/installAuthoringBrowser.md +13 -0
  90. package/dist/docs/reference/authoring/readCapturedRun.md +10 -0
  91. package/dist/docs/reference/authoring/renderCapturedRun.md +13 -0
  92. package/dist/docs/reference/authoring/runAuthoringSource.md +9 -0
  93. package/dist/docs/reference/authoring/searchAuthoringDocumentation.md +12 -0
  94. package/dist/docs/reference/authoring/showAuthoringDocumentation.md +11 -0
  95. package/dist/metamesh.d.ts +3 -0
  96. package/dist/metamesh.d.ts.map +1 -0
  97. package/dist/metamesh.js +183 -0
  98. package/dist/metamesh.js.map +1 -0
  99. package/package.json +63 -3
@@ -0,0 +1,13 @@
1
+ # CapturedGeometry
2
+
3
+ CapturedGeometry exported from @metamesh/cli/authoring.
4
+
5
+ Import from `@metamesh/cli/authoring` (@metamesh/cli@0.13.0).
6
+
7
+ ```ts
8
+ export interface CapturedGeometry {
9
+ readonly id: string;
10
+ readonly positions: Float32Array;
11
+ readonly indices: Uint32Array;
12
+ }
13
+ ```
@@ -0,0 +1,16 @@
1
+ # CapturedPart
2
+
3
+ CapturedPart exported from @metamesh/cli/authoring.
4
+
5
+ Import from `@metamesh/cli/authoring` (@metamesh/cli@0.13.0).
6
+
7
+ ```ts
8
+ export interface CapturedPart {
9
+ readonly id: string;
10
+ readonly resourceId: string;
11
+ readonly position: Vector3;
12
+ readonly rotation: Vector3;
13
+ readonly color?: string;
14
+ readonly measurements: SnapshotPart["measurements"];
15
+ }
16
+ ```
@@ -0,0 +1,14 @@
1
+ # CapturedResource
2
+
3
+ CapturedResource exported from @metamesh/cli/authoring.
4
+
5
+ Import from `@metamesh/cli/authoring` (@metamesh/cli@0.13.0).
6
+
7
+ ```ts
8
+ export interface CapturedResource {
9
+ readonly id: string;
10
+ readonly positions: CapturedBuffer;
11
+ readonly indices: CapturedBuffer;
12
+ readonly measurements: SnapshotPart["measurements"];
13
+ }
14
+ ```
@@ -0,0 +1,13 @@
1
+ # CapturedRun
2
+
3
+ CapturedRun exported from @metamesh/cli/authoring.
4
+
5
+ Import from `@metamesh/cli/authoring` (@metamesh/cli@0.13.0).
6
+
7
+ ```ts
8
+ export interface CapturedRun {
9
+ readonly directory: string;
10
+ readonly manifest: CapturedRunManifest;
11
+ readonly resources: readonly CapturedGeometry[];
12
+ }
13
+ ```
@@ -0,0 +1,38 @@
1
+ # CapturedRunManifest
2
+
3
+ CapturedRunManifest exported from @metamesh/cli/authoring.
4
+
5
+ Import from `@metamesh/cli/authoring` (@metamesh/cli@0.13.0).
6
+
7
+ ```ts
8
+ export interface CapturedRunManifest {
9
+ readonly formatVersion: 1;
10
+ readonly status: "complete";
11
+ readonly runId: string;
12
+ readonly createdAt: string;
13
+ readonly kind: AuthoringKind;
14
+ readonly source: {
15
+ readonly entry: string;
16
+ readonly fingerprint: string;
17
+ };
18
+ readonly packages: Readonly<Record<string, string>>;
19
+ readonly parameters: Readonly<Record<string, unknown>>;
20
+ /** Effective Generator font selections, or declared and byte-verified standalone fixture revisions. */
21
+ readonly assets: readonly {
22
+ readonly faceId: string;
23
+ readonly revision: string;
24
+ readonly weight: number;
25
+ }[];
26
+ readonly policy: {
27
+ readonly timeoutMs: number;
28
+ readonly limits: ModelingLimits;
29
+ };
30
+ readonly diagnostics: readonly GenerationDiagnostic[];
31
+ readonly bounds: Bounds3;
32
+ readonly stats: FinalizedModel["stats"];
33
+ readonly dependencies: ModelDependencies;
34
+ readonly resources: readonly CapturedResource[];
35
+ readonly parts: readonly CapturedPart[];
36
+ readonly export3mf?: CapturedBuffer;
37
+ }
38
+ ```
@@ -0,0 +1,14 @@
1
+ # CheckOptions
2
+
3
+ CheckOptions exported from @metamesh/cli/authoring.
4
+
5
+ Import from `@metamesh/cli/authoring` (@metamesh/cli@0.13.0).
6
+
7
+ ```ts
8
+ export interface CheckOptions {
9
+ readonly entry: string;
10
+ readonly kind: AuthoringKind;
11
+ readonly project?: string;
12
+ readonly tsconfig?: string;
13
+ }
14
+ ```
@@ -0,0 +1,15 @@
1
+ # CheckSuccess
2
+
3
+ CheckSuccess exported from @metamesh/cli/authoring.
4
+
5
+ Import from `@metamesh/cli/authoring` (@metamesh/cli@0.13.0).
6
+
7
+ ```ts
8
+ export interface CheckSuccess {
9
+ readonly success: true;
10
+ readonly entry: string;
11
+ readonly kind: AuthoringKind;
12
+ readonly tsconfig?: string;
13
+ readonly diagnostics: readonly AuthoringDiagnostic[];
14
+ }
15
+ ```
@@ -0,0 +1,18 @@
1
+ # DocumentationEntry
2
+
3
+ DocumentationEntry exported from @metamesh/cli/authoring.
4
+
5
+ Import from `@metamesh/cli/authoring` (@metamesh/cli@0.13.0).
6
+
7
+ ```ts
8
+ export interface DocumentationEntry {
9
+ readonly id: string;
10
+ readonly title: string;
11
+ readonly summary: string;
12
+ readonly path: string;
13
+ readonly importPath: string;
14
+ readonly availability: string;
15
+ readonly canonical: string;
16
+ readonly keywords: readonly string[];
17
+ }
18
+ ```
@@ -0,0 +1,14 @@
1
+ # DocumentationManifest
2
+
3
+ DocumentationManifest exported from @metamesh/cli/authoring.
4
+
5
+ Import from `@metamesh/cli/authoring` (@metamesh/cli@0.13.0).
6
+
7
+ ```ts
8
+ export interface DocumentationManifest {
9
+ readonly formatVersion: 1;
10
+ readonly packageName: string;
11
+ readonly packageVersion: string;
12
+ readonly documents: readonly DocumentationEntry[];
13
+ }
14
+ ```
@@ -0,0 +1,12 @@
1
+ # DocumentationSearchResult
2
+
3
+ DocumentationSearchResult exported from @metamesh/cli/authoring.
4
+
5
+ Import from `@metamesh/cli/authoring` (@metamesh/cli@0.13.0).
6
+
7
+ ```ts
8
+ export interface DocumentationSearchResult extends DocumentationEntry {
9
+ readonly packageName: string;
10
+ readonly packageVersion: string;
11
+ }
12
+ ```
@@ -0,0 +1,14 @@
1
+ # InstalledAuthoringPackage
2
+
3
+ InstalledAuthoringPackage exported from @metamesh/cli/authoring.
4
+
5
+ Import from `@metamesh/cli/authoring` (@metamesh/cli@0.13.0).
6
+
7
+ ```ts
8
+ export interface InstalledAuthoringPackage {
9
+ readonly name: string;
10
+ readonly version: string;
11
+ readonly manifestPath: string;
12
+ readonly documentCount: number;
13
+ }
14
+ ```
@@ -0,0 +1,22 @@
1
+ # RenderCamera
2
+
3
+ Recorded orthographic camera, expressed in millimetres and world coordinates.
4
+
5
+ Import from `@metamesh/cli/authoring` (@metamesh/cli@0.13.0).
6
+
7
+ ```ts
8
+ /** Recorded orthographic camera, expressed in millimetres and world coordinates. */
9
+ export interface RenderCamera {
10
+ readonly position: readonly [number, number, number];
11
+ readonly target: readonly [number, number, number];
12
+ readonly up: readonly [number, number, number];
13
+ readonly frustum: {
14
+ readonly left: number;
15
+ readonly right: number;
16
+ readonly top: number;
17
+ readonly bottom: number;
18
+ readonly near: number;
19
+ readonly far: number;
20
+ };
21
+ }
22
+ ```
@@ -0,0 +1,10 @@
1
+ # RenderFormat
2
+
3
+ Image encodings; WebP is always lossless.
4
+
5
+ Import from `@metamesh/cli/authoring` (@metamesh/cli@0.13.0).
6
+
7
+ ```ts
8
+ /** Image encodings; WebP is always lossless. */
9
+ export type RenderFormat = "png" | "webp";
10
+ ```
@@ -0,0 +1,20 @@
1
+ # RenderOptions
2
+
3
+ Options for rendering a previously captured model, without executing author code.
4
+
5
+ Import from `@metamesh/cli/authoring` (@metamesh/cli@0.13.0).
6
+
7
+ ```ts
8
+ /** Options for rendering a previously captured model, without executing author code. */
9
+ export interface RenderOptions {
10
+ readonly views?: readonly RenderView[];
11
+ readonly width?: number;
12
+ readonly height?: number;
13
+ readonly format?: RenderFormat;
14
+ readonly background?: "transparent" | `#${string}`;
15
+ /** Parent for a new unique capture directory; defaults to the run's renders directory. */
16
+ readonly outputDirectory?: string;
17
+ /** Browser startup, page readiness, and capture deadline; defaults to 30 seconds. */
18
+ readonly timeoutMs?: number;
19
+ }
20
+ ```
@@ -0,0 +1,15 @@
1
+ # RenderResult
2
+
3
+ Images always belong to one captured run and one unique output directory.
4
+
5
+ Import from `@metamesh/cli/authoring` (@metamesh/cli@0.13.0).
6
+
7
+ ```ts
8
+ /** Images always belong to one captured run and one unique output directory. */
9
+ export interface RenderResult {
10
+ readonly runId: string;
11
+ readonly sourceFingerprint: string;
12
+ readonly directory: string;
13
+ readonly images: readonly RenderedImage[];
14
+ }
15
+ ```
@@ -0,0 +1,10 @@
1
+ # RenderView
2
+
3
+ Standard orthographic views in MetaMesh's Z-up coordinate system.
4
+
5
+ Import from `@metamesh/cli/authoring` (@metamesh/cli@0.13.0).
6
+
7
+ ```ts
8
+ /** Standard orthographic views in MetaMesh's Z-up coordinate system. */
9
+ export type RenderView = "isometric" | "front" | "top" | "right";
10
+ ```
@@ -0,0 +1,23 @@
1
+ # RenderedImage
2
+
3
+ A view and its provenance, also written beside the image as JSON.
4
+
5
+ Import from `@metamesh/cli/authoring` (@metamesh/cli@0.13.0).
6
+
7
+ ```ts
8
+ /** A view and its provenance, also written beside the image as JSON. */
9
+ export interface RenderedImage {
10
+ readonly path: string;
11
+ readonly metadataPath: string;
12
+ readonly runId: string;
13
+ readonly sourceFingerprint: string;
14
+ readonly view: RenderView;
15
+ readonly width: number;
16
+ readonly height: number;
17
+ readonly format: RenderFormat;
18
+ readonly background: string;
19
+ readonly camera: RenderCamera;
20
+ readonly rendererRevision: string;
21
+ readonly browserVersion: string;
22
+ }
23
+ ```
@@ -0,0 +1,17 @@
1
+ # RunOptions
2
+
3
+ RunOptions exported from @metamesh/cli/authoring.
4
+
5
+ Import from `@metamesh/cli/authoring` (@metamesh/cli@0.13.0).
6
+
7
+ ```ts
8
+ export interface RunOptions extends CheckOptions {
9
+ readonly params?: Readonly<Record<string, unknown>>;
10
+ readonly fontFixtures?: string;
11
+ readonly output?: string;
12
+ readonly timeoutMs?: number;
13
+ readonly limits?: Partial<ModelingLimits>;
14
+ readonly export3mf?: boolean;
15
+ readonly onLog?: (text: string) => void;
16
+ }
17
+ ```
@@ -0,0 +1,13 @@
1
+ # RunSuccess
2
+
3
+ RunSuccess exported from @metamesh/cli/authoring.
4
+
5
+ Import from `@metamesh/cli/authoring` (@metamesh/cli@0.13.0).
6
+
7
+ ```ts
8
+ export interface RunSuccess {
9
+ readonly success: true;
10
+ readonly runDirectory: string;
11
+ readonly manifest: CapturedRunManifest;
12
+ }
13
+ ```
@@ -0,0 +1,9 @@
1
+ # authoringFailure
2
+
3
+ authoringFailure exported from @metamesh/cli/authoring.
4
+
5
+ Import from `@metamesh/cli/authoring` (@metamesh/cli@0.13.0).
6
+
7
+ ```ts
8
+ export declare function authoringFailure(error: unknown, fallbackPhase?: AuthoringPhase): AuthoringFailure;
9
+ ```
@@ -0,0 +1,9 @@
1
+ # checkAuthoringSource
2
+
3
+ checkAuthoringSource exported from @metamesh/cli/authoring.
4
+
5
+ Import from `@metamesh/cli/authoring` (@metamesh/cli@0.13.0).
6
+
7
+ ```ts
8
+ export declare function checkAuthoringSource(options: CheckOptions): Promise<CheckSuccess | AuthoringFailure>;
9
+ ```
@@ -0,0 +1,9 @@
1
+ # discoverAuthoringEnvironment
2
+
3
+ discoverAuthoringEnvironment exported from @metamesh/cli/authoring.
4
+
5
+ Import from `@metamesh/cli/authoring` (@metamesh/cli@0.13.0).
6
+
7
+ ```ts
8
+ export declare function discoverAuthoringEnvironment(project?: string): Promise<AuthoringEnvironment>;
9
+ ```
@@ -0,0 +1,11 @@
1
+ # inspectCapturedRun
2
+
3
+ inspectCapturedRun exported from @metamesh/cli/authoring.
4
+
5
+ Import from `@metamesh/cli/authoring` (@metamesh/cli@0.13.0).
6
+
7
+ ```ts
8
+ export declare function inspectCapturedRun(directory: string, partId?: string): Promise<Omit<CapturedRun, "resources"> & {
9
+ readonly selectedPart?: CapturedPart;
10
+ }>;
11
+ ```
@@ -0,0 +1,13 @@
1
+ # installAuthoringBrowser
2
+
3
+ Explicit installation of this package's pinned Chromium. Never called by render.
4
+
5
+ Import from `@metamesh/cli/authoring` (@metamesh/cli@0.13.0).
6
+
7
+ ```ts
8
+ /** Explicit installation of this package's pinned Chromium. Never called by render. */
9
+ export declare function installAuthoringBrowser(): Promise<{
10
+ browser: "chromium";
11
+ executablePath: string;
12
+ }>;
13
+ ```
@@ -0,0 +1,10 @@
1
+ # readCapturedRun
2
+
3
+ Reads only immutable captured files. It never imports or executes original author source.
4
+
5
+ Import from `@metamesh/cli/authoring` (@metamesh/cli@0.13.0).
6
+
7
+ ```ts
8
+ /** Reads only immutable captured files. It never imports or executes original author source. */
9
+ export declare function readCapturedRun(directory: string): Promise<CapturedRun>;
10
+ ```
@@ -0,0 +1,13 @@
1
+ # renderCapturedRun
2
+
3
+ Render validated persisted local geometry and placements. Source code is never imported, and a fresh capture directory prevents overlapping calls from overwriting evidence.
4
+
5
+ Import from `@metamesh/cli/authoring` (@metamesh/cli@0.13.0).
6
+
7
+ ```ts
8
+ /**
9
+ * Render validated persisted local geometry and placements. Source code is never imported,
10
+ * and a fresh capture directory prevents overlapping calls from overwriting evidence.
11
+ */
12
+ export declare function renderCapturedRun(directory: string, options?: RenderOptions): Promise<RenderResult>;
13
+ ```
@@ -0,0 +1,9 @@
1
+ # runAuthoringSource
2
+
3
+ runAuthoringSource exported from @metamesh/cli/authoring.
4
+
5
+ Import from `@metamesh/cli/authoring` (@metamesh/cli@0.13.0).
6
+
7
+ ```ts
8
+ export declare function runAuthoringSource(options: RunOptions): Promise<RunSuccess | AuthoringFailure>;
9
+ ```
@@ -0,0 +1,12 @@
1
+ # searchAuthoringDocumentation
2
+
3
+ searchAuthoringDocumentation exported from @metamesh/cli/authoring.
4
+
5
+ Import from `@metamesh/cli/authoring` (@metamesh/cli@0.13.0).
6
+
7
+ ```ts
8
+ export declare function searchAuthoringDocumentation(query: string, options?: {
9
+ readonly project?: string;
10
+ readonly limit?: number;
11
+ }): Promise<readonly DocumentationSearchResult[]>;
12
+ ```
@@ -0,0 +1,11 @@
1
+ # showAuthoringDocumentation
2
+
3
+ showAuthoringDocumentation exported from @metamesh/cli/authoring.
4
+
5
+ Import from `@metamesh/cli/authoring` (@metamesh/cli@0.13.0).
6
+
7
+ ```ts
8
+ export declare function showAuthoringDocumentation(id: string, project?: string): Promise<DocumentationSearchResult & {
9
+ readonly markdown: string;
10
+ }>;
11
+ ```
@@ -0,0 +1,3 @@
1
+ #!/usr/bin/env node
2
+ export {};
3
+ //# sourceMappingURL=metamesh.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"metamesh.d.ts","sourceRoot":"","sources":["../src/metamesh.ts"],"names":[],"mappings":""}
@@ -0,0 +1,183 @@
1
+ #!/usr/bin/env node
2
+ import { readFile } from "node:fs/promises";
3
+ import { resolve } from "node:path";
4
+ import { Command, CommanderError, InvalidArgumentError, Option } from "commander";
5
+ import { AuthoringError, authoringFailure, isRecord } from "./authoring/errors.js";
6
+ import { AUTHORING_PROTOCOL_VERSION, } from "./authoring/types.js";
7
+ /** Keep the repository's strict scalar-option policy without importing unpublished tools. */
8
+ function valueOption(flags, description, choices) {
9
+ const option = new Option(flags, description);
10
+ if (choices)
11
+ option.choices([...choices]);
12
+ const parse = option.parseArg;
13
+ return option.argParser((value, previous) => {
14
+ if (previous !== undefined)
15
+ throw new InvalidArgumentError("option may only be provided once");
16
+ return parse ? parse(value, previous) : value;
17
+ });
18
+ }
19
+ const projectFor = (options) => resolve(options.project ?? process.cwd());
20
+ const entryOptions = (options, entry) => ({
21
+ entry,
22
+ kind: options.kind, // Commander requires and validates this option before the action.
23
+ project: projectFor(options),
24
+ ...(options.tsconfig === undefined ? {} : { tsconfig: options.tsconfig }),
25
+ });
26
+ async function readObject(project, file) {
27
+ if (file === undefined)
28
+ return undefined;
29
+ const value = JSON.parse(await readFile(resolve(project, file), "utf8"));
30
+ if (!isRecord(value))
31
+ throw new AuthoringError("invocation", "INVALID_JSON_INPUT", "Parameter and limit files must contain JSON objects.");
32
+ return value;
33
+ }
34
+ function humanResult(command, result) {
35
+ if (isRecord(result) && result.success === false && Array.isArray(result.diagnostics))
36
+ return `${result.diagnostics.map((issue) => `${issue.code}: ${issue.message}`).join("\n")}${typeof result.runDirectory === "string" ? `\nAttempt: ${result.runDirectory}` : ""}\n`;
37
+ if (command === "environment") {
38
+ const environment = result;
39
+ return `MetaMesh authoring protocol ${environment.authoringProtocolVersion}\nProject: ${environment.project}\n${environment.packages.map((pkg) => `${pkg.name} ${pkg.version} (${pkg.documentCount} topics)\n ${pkg.manifestPath}`).join("\n")}\n`;
40
+ }
41
+ if (command === "docs" && Array.isArray(result))
42
+ return `${result.map(({ id, summary }) => `${id}\n ${summary}`).join("\n")}\n`;
43
+ if (isRecord(result) && typeof result.markdown === "string")
44
+ return `${result.markdown}\n`;
45
+ if (command === "check" && isRecord(result) && result.success === true)
46
+ return `TypeScript check passed: ${String(result.entry)}\n`;
47
+ if ((command === "run" || command === "inspect") &&
48
+ isRecord(result) &&
49
+ isRecord(result.manifest)) {
50
+ const manifest = result.manifest;
51
+ return `${manifest.parts.length} parts; ${manifest.stats.vertices} vertices; ${manifest.stats.triangles} triangles; ${manifest.stats.volumeMm3.toFixed(3)} mm³\nCaptured: ${String(result.runDirectory ?? result.directory)}\n${manifest.diagnostics.map(({ severity, message }) => `${severity}: ${message}\n`).join("")}${isRecord(result.selectedPart) ? `Part: ${JSON.stringify(result.selectedPart)}\n` : ""}`;
52
+ }
53
+ return `${JSON.stringify(result, null, 2)}\n`;
54
+ }
55
+ async function main() {
56
+ const args = process.argv.slice(2);
57
+ const json = args.includes("--json");
58
+ let help = "";
59
+ const program = new Command("metamesh")
60
+ .description("Check, generate, inspect, and render local MetaMesh models.")
61
+ .option("--json", "emit one structured result on stdout")
62
+ .addOption(valueOption("--project <directory>", "resolve packages and paths from this project"))
63
+ .allowExcessArguments(false)
64
+ .configureHelp({ showGlobalOptions: true })
65
+ .configureOutput({
66
+ writeOut: (text) => {
67
+ help += text;
68
+ },
69
+ writeErr: () => { },
70
+ })
71
+ .addHelpText("after", "\nLocal author source executes with your account's permissions; this is not a sandbox.")
72
+ .exitOverride();
73
+ program.action(() => {
74
+ program.help();
75
+ });
76
+ const command = (parent, name, description) => parent.command(name).description(description).allowExcessArguments(false);
77
+ const action = (target, handler, format = target.name()) => {
78
+ target.action(async () => {
79
+ const result = await handler(target.optsWithGlobals(), target.args);
80
+ if (isRecord(result) && result.success === false)
81
+ process.exitCode = typeof result.exitCode === "number" ? result.exitCode : 2;
82
+ process.stdout.write(json ? `${JSON.stringify(result)}\n` : humanResult(format, result));
83
+ });
84
+ };
85
+ const entryCommand = (name, description) => command(program, name, description)
86
+ .argument("<entry>", "local TypeScript module")
87
+ .addOption(valueOption("--kind <kind>", "entry module contract", [
88
+ "model",
89
+ "generator",
90
+ ]).makeOptionMandatory())
91
+ .addOption(valueOption("--tsconfig <file>", "override the nearest TypeScript configuration"));
92
+ action(command(program, "environment", "discover installed packages and documentation"), async (options) => (await import("./authoring/environment.js")).discoverAuthoringEnvironment(projectFor(options)));
93
+ const docs = command(program, "docs", "search and read installed version-matched documentation");
94
+ docs.action(() => {
95
+ docs.help();
96
+ });
97
+ action(command(docs, "search", "search bounded topic and symbol metadata")
98
+ .argument("<query...>")
99
+ .addOption(valueOption("--limit <count>", "maximum results, 1–50 (default: 10)")), async (options, query) => (await import("./authoring/environment.js")).searchAuthoringDocumentation(query.join(" "), {
100
+ project: projectFor(options),
101
+ ...(options.limit === undefined ? {} : { limit: Number(options.limit) }),
102
+ }), "docs");
103
+ action(command(docs, "show", "read one installed topic").argument("<id>"), async (options, [id]) => (await import("./authoring/environment.js")).showAuthoringDocumentation(id, projectFor(options)));
104
+ action(entryCommand("check", "check TypeScript without evaluating source"), async (options, [entry]) => (await import("./authoring/check.js")).checkAuthoringSource(entryOptions(options, entry)));
105
+ action(entryCommand("run", "check, execute, and capture a fresh result")
106
+ .addOption(valueOption("--params <file>", "JSON parameter overrides (default: {})"))
107
+ .addOption(valueOption("--font-fixtures <file>", "local immutable font descriptors"))
108
+ .addOption(valueOption("--output <parent>", "parent for a unique run directory"))
109
+ .addOption(valueOption("--timeout <milliseconds>", "execution deadline (default: 30000)"))
110
+ .addOption(valueOption("--limits <file>", "JSON overrides lowering engine resource limits"))
111
+ .option("--export-3mf", "export this captured snapshot as 3MF"), async (options, [entry]) => {
112
+ const project = projectFor(options);
113
+ const limits = await readObject(project, options.limits);
114
+ return (await import("./authoring/run.js")).runAuthoringSource({
115
+ ...entryOptions(options, entry),
116
+ params: (await readObject(project, options.params)) ?? {},
117
+ ...(limits === undefined ? {} : { limits }),
118
+ ...(options.fontFixtures === undefined ? {} : { fontFixtures: options.fontFixtures }),
119
+ ...(options.output === undefined ? {} : { output: options.output }),
120
+ ...(options.timeout === undefined ? {} : { timeoutMs: Number(options.timeout) }),
121
+ export3mf: options.export3mf ?? false,
122
+ onLog: (text) => process.stderr.write(text),
123
+ });
124
+ });
125
+ action(command(program, "inspect", "read captured measurements and provenance")
126
+ .argument("<run-directory>")
127
+ .addOption(valueOption("--part <id>", "select a semantic part ID")), async (options, [directory]) => (await import("./authoring/artifacts.js")).inspectCapturedRun(resolve(projectFor(options), directory), options.part));
128
+ action(command(program, "render", "render captured geometry without executing author code")
129
+ .argument("<run-directory>")
130
+ .addOption(valueOption("--views <views>", "comma-separated isometric,front,top,right (default: isometric)"))
131
+ .addOption(valueOption("--width <pixels>", "image width (default: 1024)"))
132
+ .addOption(valueOption("--height <pixels>", "image height (default: 1024)"))
133
+ .addOption(valueOption("--format <format>", "image encoding (default: png)", ["png", "webp"]))
134
+ .option("--transparent", "use a transparent background")
135
+ .addOption(valueOption("--background <hex-color>", "six-digit RGB background").conflicts("transparent"))
136
+ .addOption(valueOption("--output <parent>", "parent for a unique capture directory")), async (options, [directory]) => (await import("./authoring/render.js")).renderCapturedRun(resolve(projectFor(options), directory), {
137
+ ...(options.views === undefined
138
+ ? {}
139
+ : { views: options.views.split(",") }),
140
+ ...(options.width === undefined ? {} : { width: Number(options.width) }),
141
+ ...(options.height === undefined ? {} : { height: Number(options.height) }),
142
+ ...(options.format === undefined ? {} : { format: options.format }),
143
+ ...(options.transparent
144
+ ? { background: "transparent" }
145
+ : options.background === undefined
146
+ ? {}
147
+ : { background: options.background }),
148
+ ...(options.output === undefined
149
+ ? {}
150
+ : { outputDirectory: resolve(projectFor(options), options.output) }),
151
+ }));
152
+ const browser = command(program, "browser", "set up the optional pinned capture browser");
153
+ browser.action(() => {
154
+ browser.help();
155
+ });
156
+ action(command(browser, "install", "explicitly install pinned Chromium"), async () => (await import("./authoring/render.js")).installAuthoringBrowser());
157
+ action(command(program, "setup", "print skill installation and project-instruction guidance"), () => ({
158
+ success: true,
159
+ authoringProtocolVersion: AUTHORING_PROTOCOL_VERSION,
160
+ installation: "pnpm dlx skills@1.5.22 add https://github.com/metamesh-studio/metamesh-skills --skill metamesh-developer",
161
+ publication: "The operator must publish the canonical skills repository before this GitHub installation command is available.",
162
+ instructions: "Use the metamesh-developer skill. Run metamesh environment --json in this project, consult installed docs with metamesh docs search/show, then check, run, and inspect the captured result. Render relevant views before declaring geometry work complete.",
163
+ }));
164
+ try {
165
+ await program.parseAsync(args, { from: "user" });
166
+ }
167
+ catch (error) {
168
+ if (error instanceof CommanderError && error.exitCode === 0) {
169
+ process.stdout.write(json ? `${JSON.stringify({ success: true, help })}\n` : help);
170
+ return;
171
+ }
172
+ const failure = authoringFailure(error instanceof CommanderError
173
+ ? new AuthoringError("invocation", "INVALID_ARGUMENTS", error.message.replace(/^error:\s*/i, ""))
174
+ : error, "invocation");
175
+ process.exitCode = failure.exitCode;
176
+ if (json)
177
+ process.stdout.write(`${JSON.stringify(failure)}\n`);
178
+ else
179
+ process.stderr.write(`${failure.diagnostics.map(({ code, message }) => `${code}: ${message}`).join("\n")}\n`);
180
+ }
181
+ }
182
+ await main();
183
+ //# sourceMappingURL=metamesh.js.map