Build and revise procedural 3D assets with your coding agent. Local MCP server, CLI and TypeScript engine with rendered review, editable source and GLB export.
JavaScript 3d3d-assets3d-modelingagent-skillsagent-toolsai-agentsasset-pipelinecligame-assetsglbgltfmcpmcp-servermodel-context-protocolprocedural-generationprocedural-modelingtext-to-3dthreejstypescript
feat(cli): kiln --version, sandbox globals and the export weld rule (#202)
Matt Kissinger9c8428670845
diff --git a/CHANGELOG.md b/CHANGELOG.mdindex 005c7b40..9b9f2951 100644--- a/CHANGELOG.md+++ b/CHANGELOG.md@@ -32,6 +32,10 @@ does not publish a package.and `autoUnwrap` instead of a generic "unwrap". The block is unchanged: a texture-backedmaterial on geometry without UV0 still fails QA, and no projection is addedautomatically ([#177](https://github.com/instruktlabs/kiln/issues/177)).+- `kiln --version` prints the installed version and exits 0+ ([#202](https://github.com/instruktlabs/kiln/issues/202)). `docs/programs.md` lists the+ sandbox globals and refused host capabilities, and `docs/geometry.md` states the+ exact-equality export weld that was documented only in the migration notes.## 1.4.0 (2026-10-23)diff --git a/docs/geometry.md b/docs/geometry.mdindex 16807fc3..b0864571 100644--- a/docs/geometry.md+++ b/docs/geometry.md@@ -477,6 +477,22 @@ glTF multiplies base colour by `COLOR_0`, and loaders enable vertex colours whenis present, whether or not the authoring material set `vertexColors`. Remove a`color` attribute that is not meant to tint the surface.+## Know what export welds++Export welds only exactly equal vertices. With the default `indexPolicy: 'indexed'`,+each primitive built without an index buffer gets one, and two corners merge only when+every attribute (position, normal, UVs, colour, tangent, author attributes and morph+data) is bitwise identical. Material optimization welds by the same rule. There is no+distance tolerance, so corners a rounding error apart stay separate vertices: seams+survive, and the file keeps every distinct corner you built.++To weld on purpose, call `mergeVertices` before returning the geometry, or round+coordinates you know should coincide so their corners become equal; both can shrink a+baked or generated mesh noticeably. `indexPolicy: 'asBuilt'` on render calls (local+hosts: `KILN_INDEX_POLICY=asBuilt`) keeps helper buffers as built and requires+optimization off. The receipt's `indexBuffers` reports vertex, morph and index payload+bytes before and after this pass, not GLB file size.+## Declare a triangle budget`defineBudget({ triangles: { LOD0: 4000, LOD1: 900 }, draws: 3 })` records the asset'sdiff --git a/docs/migration.md b/docs/migration.mdindex 6ac61757..2dcab279 100644--- a/docs/migration.md+++ b/docs/migration.md@@ -310,7 +310,8 @@ Changes to results and messages:`KILN_INDEX_POLICY=asBuilt` in a local host, to preserve helper buffers; combine itwith optimization off. Saved rebuild settings and cache identities retain thepolicy. `indexBuffers` reports unique vertex/morph/index accessor payload bytes at- this pass, before later optimizations; it is not a GLB compression measurement.+ this pass, before later optimizations; it is not a GLB compression measurement. See+ [what export welds](geometry.md#know-what-export-welds).- **Sweep evidence.** `SWEEP_SELF_INTERSECTION` is an observation of a tight stationradius or intersecting consecutive filled rings. Limits are 4096 stations, 512points per ring and 65536 segment/triangle tests. Budget exhaustion retains andiff --git a/docs/programs.md b/docs/programs.mdindex 42ce1c30..0dfc0b5f 100644--- a/docs/programs.md+++ b/docs/programs.md@@ -44,6 +44,30 @@ exactly one of `code` or `programRef`.Search returns surrounding source. A missing match returns `found: false` and emptycode. Read enough context to understand dependencies before editing.+## Sandbox globals++A program is a script, not a module. It defines `const meta = { name }`, a+`function build()` (or `async function build()`) that returns the root from+`createRoot`, and optionally `animate(root)`, which returns an array of clips. It runs+in strict mode with these globals and nothing to import:++- Every Kiln helper in the [Discovery](tools.md) catalog, such as `createRoot`,+ `createPart`, `boxGeo`, `gameMaterial` and `defineBudget`. Use `kiln discover` or+ `kiln_discover` for the complete list and each helper's contract.+- `THREE`, the three.js namespace, for direct geometry and maths. `DataTexture`,+ `ShaderMaterial` and `RawShaderMaterial` are refused; use the material and texture+ helpers. The namespace cannot be aliased or read with computed keys.+- `Math`, and `console` for diagnostics, which the host captures.+- Standard JavaScript built-ins such as `Array`, `Object`, `JSON`, `Map`, `Set` and+ `Promise`.++Host capabilities are refused before the program runs: `import`, `export` and dynamic+`import()`, `eval`, `Function` and constructor chains, `globalThis`, `global`,+`process`, `require`, `module`, `Reflect`, `fetch`, `XMLHttpRequest`, `WebSocket`, the+browser globals (`window`, `self`, `document`, `navigator`, `location`), `Bun` and+`Deno`, and `this` outside a method. This is a safety net, not process isolation.+`kiln validate` reports the first refused use with its line.+## Files and persistenceFrom a generated workspace, import and export without model transcription:diff --git a/src/__tests__/cli-version.test.ts b/src/__tests__/cli-version.test.tsnew file mode 100644index 00000000..0523721f--- /dev/null+++ b/src/__tests__/cli-version.test.ts@@ -0,0 +1,30 @@+import { expect, test } from 'bun:test';+import { spawnSync } from 'node:child_process';+import { readFileSync } from 'node:fs';+import { resolve } from 'node:path';++const entry = resolve(import.meta.dir, '../cli.ts');+const pkg = JSON.parse(readFileSync(resolve(import.meta.dir, '../../package.json'), 'utf8')) as {+ version: string;+};+const run = (args: string[]) =>+ spawnSync(process.execPath, [entry, ...args], {+ encoding: 'utf8',+ windowsHide: true,+ env: { ...process.env, KILN_RENDER: 'cpu' },+ timeout: 20_000,+ });++// #202: `kiln --version` was an unknown option (exit 2).+test('kiln --version prints the package version alone and exits 0', () => {+ const result = run(['--version']);+ expect(result.stderr).toBe('');+ expect(result.status).toBe(0);+ expect(result.stdout).toBe(`${pkg.version}\n`);+});++test('--version is not accepted after a command', () => {+ const result = run(['render', '--version']);+ expect(result.status).toBe(2);+ expect(result.stderr).toContain('unknown option: --version');+});diff --git a/src/__tests__/list-primitives.test.ts b/src/__tests__/list-primitives.test.tsindex c7637a74..c21c35fb 100644--- a/src/__tests__/list-primitives.test.ts+++ b/src/__tests__/list-primitives.test.ts@@ -60,6 +60,18 @@ describe('kiln.listHelperSpecs', () => {expect(missing).toEqual([]);});+ // #202: docs/programs.md names every sandbox global the catalog does not.+ test('docs/programs.md lists every sandbox global outside the catalog', async () => {+ const catalog = new Set(listHelperSpecs().map((p) => p.name));+ const extra = Object.keys(buildSandboxGlobals())+ .filter((name) => !catalog.has(name))+ .sort();+ expect(extra).toEqual(['Math', 'THREE', 'console']);+ const doc = await Bun.file(new URL('../../docs/programs.md', import.meta.url)).text();+ const section = doc.split('## Sandbox globals')[1]?.split('\n## ')[0] ?? '';+ for (const name of extra) expect(section).toContain(`\`${name}\``);+ });+test('returned array is a defensive copy', () => {const a = listHelperSpecs();const b = listHelperSpecs();diff --git a/src/cli.ts b/src/cli.tsindex e304dc75..c397d8aa 100644--- a/src/cli.ts+++ b/src/cli.ts@@ -35,6 +35,7 @@ import type { RequirementsBinding } from './requirements-store';import type { RenderResult } from './render';import { createGenerationCallBudget } from './agent/call-budget';import { assertNodeRuntime } from './runtime-support.mjs';+import { ENGINE_VERSION } from './engine-identity';const USAGE = `kiln — vision-in-the-loop 3D asset generation@@ -51,6 +52,7 @@ USAGEkiln animation <program.js|ref> [options] review sampled motion of an exported clipkiln inspect <program.js|ref> [options] close-up views and surface/anchor measurementskiln service status|start|stop|reprobe the shared GPU render service (see below)+ kiln --version print the installed Kiln versionOPTIONS--out <path> GLB output path (default: out.glb)@@ -749,6 +751,11 @@ export function main(argv: readonly string[]): Promise<number> {}async function runMain(argv: readonly string[]): Promise<number> {+ // Before the runtime check, so an unsupported Node can still say which Kiln it found (#202).+ if (argv.length === 1 && argv[0] === '--version') {+ console.log(ENGINE_VERSION);+ return 0;+ }try {assertNodeRuntime();} catch (error) {