Skip to content

Official Codebase of 3DCodeVerse

Python

prompts: correct what the agent is told about tools, signatures and files that moved or never existed

gaoypeng5c443a624237
diff --git a/harness/codeverse3d/prompts/glsl_shader/system.md b/harness/codeverse3d/prompts/glsl_shader/system.md
index 0b32d6de..055d8219 100644
--- a/harness/codeverse3d/prompts/glsl_shader/system.md
+++ b/harness/codeverse3d/prompts/glsl_shader/system.md
@@ -1,7 +1,7 @@
You are a GLSL fragment-shader artist writing a raw Shadertoy-style body for a headless
harness. You own every pixel of one image pass. There is no state between pixels and no
state between frames: every frame is a pure function of the pixel and of absolute `u_time`.
-The harness owns the `#version` header, the uniform block and `common.glsl` — never
+The harness owns the `#version` header, the uniform block and `recipes.glsl` — never
redeclare them.
{% if tools %}
diff --git a/harness/codeverse3d/prompts/scene_threejs/contract.md b/harness/codeverse3d/prompts/scene_threejs/contract.md
index dd9ba02a..c046325e 100644
--- a/harness/codeverse3d/prompts/scene_threejs/contract.md
+++ b/harness/codeverse3d/prompts/scene_threejs/contract.md
@@ -4,8 +4,8 @@
```
src/scene.js export async function createScene({ THREE, renderer, loaders })
→ { scene, cameras, update(t, dt) }
-src/env.js export const BOUNDS; export function heightAt(x, z); export function buildEnv(THREE, scene) → { update(t, dt) }
-src/zones/<snake>.js export function build<Zone>(THREE, ctx) → THREE.Group (ctx = { heightAt, loaders, ... })
+src/env.js export const BOUNDS; export function heightAt(x, z); export function buildEnv(ctx) → { update(t, dt) }
+src/zones/<snake>.js export function build(ctx) → THREE.Group (ctx = { THREE, scene, heightAt, loaders, env, ... })
src/assets/<snake>.js export function build<Asset>(THREE, opts = {}) → THREE.Group (procedural, Y-up, on y = 0)
src/shaders/<snake>.js export function make<Name>Material(THREE, opts = {}) → THREE.ShaderMaterial | patched material
src/lib/*.js HARNESS-OWNED effect library (44 modules) — import and call, never rewrite
@@ -72,7 +72,7 @@ export const BOUNDS = { min: [-40, 0, -40], max: [40, 25, 40] };
export function heightAt(x, z) { // gentle rolling ground, deterministic
return 0.6 * Math.sin(x * 0.12) * Math.cos(z * 0.09) + 0.2 * Math.sin((x + z) * 0.31);
}
-export function buildEnv(THREE, scene) {
+export function buildEnv({ THREE, scene }) {
scene.background = new THREE.Color(0x9fc4e8);
scene.fog = new THREE.Fog(0x9fc4e8, 40, 140);
// ONE rig: key + hemisphere fill + the environment map metals read from + disc + shadows
@@ -94,7 +94,7 @@ export function buildEnv(THREE, scene) {
```js
import * as THREE from 'three';
const rand = (i) => { const s = Math.sin(i * 12.9898 + 78.233) * 43758.5453; return s - Math.floor(s); };
-export function buildGrove(THREE, { heightAt }) {
+export function build({ THREE, heightAt }) {
const zone = new THREE.Group(); zone.name = 'Grove';
const N = 40;
const trunk = new THREE.InstancedMesh(new THREE.CylinderGeometry(0.12, 0.18, 2.4, 8),
@@ -119,11 +119,12 @@ export function buildGrove(THREE, { heightAt }) {
```js
import * as THREE from 'three';
import { buildEnv, heightAt, BOUNDS } from './env.js';
-import { buildGrove } from './zones/grove.js';
+import { build as buildGrove } from './zones/grove.js';
export async function createScene({ THREE, renderer, loaders }) {
const scene = new THREE.Scene();
- const env = buildEnv(THREE, scene);
- const grove = buildGrove(THREE, { heightAt, loaders });
+ const ctx = { THREE, scene, renderer, loaders, heightAt, assets: {} };
+ const env = buildEnv(ctx); ctx.env = env;
+ const grove = buildGrove(ctx);
scene.add(grove);
const cameras = [ // plain objects; the harness builds the cameras
{ name: 'Establishing', position: [38, 14, 42], lookAt: [0, 2, 0], fov: 40 },
diff --git a/harness/codeverse3d/prompts/scene_threejs/cookbook.md b/harness/codeverse3d/prompts/scene_threejs/cookbook.md
index 6ddf60f7..1805edcb 100644
--- a/harness/codeverse3d/prompts/scene_threejs/cookbook.md
+++ b/harness/codeverse3d/prompts/scene_threejs/cookbook.md
@@ -1,8 +1,8 @@
# Scene cookbook — multi-file three.js scenes (r182), headless-rendered by the harness
Every `js` snippet runs as-is in node (the harness test suite concatenates them with
-`THREE` and the named addons in scope). Y-up, +Z front, meters. GLSL lives in
-`glsl_cookbook.md` — use its `makeShaderMaterial` for every custom shader.
+`THREE` and the named addons in scope). Y-up, +Z front, meters. GLSL goes through
+`lib/shader.js` — use its `makeShaderMaterial(opts)` for every custom shader.
The harness inlines the relevant chapters into your prompts; the full file is at
`.3dcode/cookbook.md` in your workspace.
@@ -30,7 +30,7 @@ function heightAt(x, z) {
return 0.8 * Math.sin(x * 0.09) * Math.cos(z * 0.07) + 0.35 * Math.sin((x * 0.31 + z * 0.23));
}
-function buildEnv(THREE, scene) {
+function buildEnv({ THREE, scene }) {
// fog + matching background: the single biggest depth cue
scene.fog = new THREE.Fog(0xa8c4dd, 45, 160); // near ≈ bounds/2, far ≈ 1.6 × diagonal
scene.background = new THREE.Color(0xa8c4dd);
@@ -429,7 +429,7 @@ Camera safety: the harness raycasts from every authored camera and calls anythin
of every eye-level camera, or — since these cards are not solid surfaces — give them
`mesh.raycast = () => {};` so the probe ignores them. Never do that to real geometry.
-## Water plane (use makeWaterMaterial from the GLSL cookbook)
+## Water plane (use makeWaterMaterial from src/shaders/water.js)
```js
function buildLake(THREE, waterMat, x, z, r, level) {
@@ -840,13 +840,12 @@ Rules: eye height 1.6 m (+ terrain!), fov 35–60, look at a focal POINT (an obj
the horizon), never inside geometry and ≥ 0.5 m from any surface, 3–5 cameras:
establishing → mid → detail. Compute positions from measured bounds/heightAt, not vibes.
-## Post-processing (optional; the default pipeline renders WITHOUT it)
+## Post-processing (the harness's own chain, ON by default)
-Only if the plan asks for bloom, and the scene must still read without it
-(`emissiveIntensity` ≤ 3, no white-out). Build an `EffectComposer` from
-`three/addons/postprocessing/*`: `RenderPass` → `UnrealBloomPass(new THREE.Vector2(w, h),
-0.35, 0.6, 0.85)` (strength ≤ 0.5, threshold ≥ 0.8 — glow, not soup) → `OutputPass` **last**
-(tone mapping + sRGB live there), and export it from `scene.js` alongside the scene.
+The harness renders scene pictures through its own post chain (GTAO + a selective emissive
+bloom + a grade that is identity unless `scene.userData.grade` is set), and the scene must
+still read without it (`emissiveIntensity` ≤ 3, no white-out). Do not build an
+`EffectComposer`: nothing reads one exported from `scene.js`.
## Performance budget
@@ -880,7 +879,7 @@ Only if the plan asks for bloom, and the scene must still read without it
10. **GLB asset invisible** → the zone never cloned `ctx.assets['<snake>']` (nothing loads a GLB
itself), or its pivot is not at the base; re-export from Blender with the object on z = 0.
11. **Camera inside a tree / wall** → positions are guesses; compute from `heightAt` +
- known object positions, then check with `render_sheet` (the harness flags
+ known object positions, then check with `scene_views` (the harness flags
camera-inside-geometry).
12. **update() allocates** (`new Vector3` per frame, `getSize` per frame) → GC hitches;
hoist scratch objects to module scope.
@@ -931,7 +930,7 @@ function sceneSelfcheck(THREE, scene, cameras) {
if (!cameras || cameras.length < 2) throw new Error('need 3-5 cameras');
console.log(`[selfcheck] draws=${draws} tris=${Math.round(tris)} lights=${lights} cameras=${cameras.length}`);
}
-const demoScene = new THREE.Scene(); buildEnv(THREE, demoScene);
+const demoScene = new THREE.Scene(); buildEnv({ THREE, scene: demoScene });
demoScene.add(forestDemo, coverDemo, campfireDemo, ff);
sceneSelfcheck(THREE, demoScene, planCameras(THREE, demoScene));
```
diff --git a/harness/codeverse3d/prompts/scene_threejs/glsl_cookbook.md b/harness/codeverse3d/prompts/scene_threejs/glsl_cookbook.md
index 5f4d2d9d..afdf4f18 100644
--- a/harness/codeverse3d/prompts/scene_threejs/glsl_cookbook.md
+++ b/harness/codeverse3d/prompts/scene_threejs/glsl_cookbook.md
@@ -203,7 +203,7 @@ export function makeGlowMaterial(THREE, opts = {}) {
Why: `additive: true` sets AdditiveBlending + `depthWrite:false` + distance fade through
ALPHA (ordinary fog would make added light brighter with distance). Strength ≤ 1.5
-without bloom; the harness renders without a bloom pass.
+without bloom.
## God-ray billboard (light shafts through trees / windows)
diff --git a/harness/codeverse3d/prompts/system/harness_contract.md b/harness/codeverse3d/prompts/system/harness_contract.md
index 78741b25..37c21b0d 100644
--- a/harness/codeverse3d/prompts/system/harness_contract.md
+++ b/harness/codeverse3d/prompts/system/harness_contract.md
@@ -54,10 +54,11 @@ artifacts/ harness output (object.glb, renders/, gates/, measurement.json). RE
## 4. You have eyes — use them
-Before declaring done you MUST look at what you built: `build` → `render_sheet` (4 views)
+Before declaring done you MUST look at what you built: `build` → `render_sheet` (14 views)
→ `check_connectivity` → fix → `isolate` a doubtful part → `cross_section` for cavities
-→ `compare_silhouette` if a reference image exists. Read the numbers (bbox, islands,
-tri count) and the images. "It should be fine" is not evidence; a render is.
+→ `compare_silhouette` if a reference image exists (each step whose tool is in your tool
+list). Read the numbers (bbox, islands, tri count) and the images. "It should be fine"
+is not evidence; a render is.
## 5. Honesty rules
@@ -80,9 +81,10 @@ tri count) and the images. "It should be fine" is not evidence; a render is.
1. [ ] `build` succeeds with zero errors (exit 0, GLB written).
2. [ ] Every plan part exists by exact name; no extra junk objects (`Cube`, `Camera`).
3. [ ] Measured overall bbox within ± 1 cm (objects) / declared bounds (scenes).
-4. [ ] `check_connectivity`: 1 connected assembly, no floating islands, lowest point at 0.
-5. [ ] `render_sheet` looked at: silhouette reads as the requested object from every
- view; nothing missing, nothing exploded, nothing lying on its back.
+4. [ ] `check_connectivity` (when in your tool list): 1 connected assembly, no floating
+ islands, lowest point at 0.
+5. [ ] `render_sheet` (when in your tool list) looked at: silhouette reads as the requested
+ object from every view; nothing missing, nothing exploded, nothing lying on its back.
6. [ ] Hollow / articulated / animated behaviour verified (`cross_section`,
`joint_sweep`, `scene_probe` + `check_placement` as applicable).
7. [ ] Materials / colours assigned per plan (no grey default everywhere).
diff --git a/harness/codeverse3d/prompts/threejs/cookbook.md b/harness/codeverse3d/prompts/threejs/cookbook.md
index 45ddb3cb..4a14b6e7 100644
--- a/harness/codeverse3d/prompts/threejs/cookbook.md
+++ b/harness/codeverse3d/prompts/threejs/cookbook.md
@@ -124,7 +124,7 @@ function buildFan(THREE) {
b.name = `Blade${i + 1}`; b.rotation.z = i * Math.PI * 2 / 3; hub.add(b);
}
g.add(hub);
- g.userData.tick = (dt) => { hub.rotation.z += dt * 2.0; }; // rad/s; harness calls tick(dt) when animating
+ g.userData.tick = (dt) => { hub.rotation.z += dt * 2.0; }; // rad/s
return g;
}
const fan = buildFan(THREE); fan.userData.tick(0.016);
@@ -423,11 +423,11 @@ primitive cannot; a wheel is 3 draw calls at any spoke count thanks to the Insta
(`geo.deleteAttribute('uv')`) or `toNonIndexed()` all; then `computeVertexNormals()`.
4. **Faceted / black shading after edits** → call `geometry.computeVertexNormals()`; for
flipped faces use `geometry.scale(-1,1,1)` carefully or rebuild the profile order.
-5. **`userData.tick` never runs** → it must be a function `(dt) => void` on the ROOT
- returned by `build`, or on a part Group (the harness traverses); don't animate scale.
+5. **`userData.tick` never runs** → nothing in the harness calls it (the GLB export drops
+ it): the judged pose is the one `build` returns; don't animate scale.
6. **Renderer / Scene / Camera / Light / OrbitControls in object code** → forbidden; the
module is imported in node with no WebGL. `document`/`canvas`/`Image`/`TextureLoader`
- crash the build (Mode 13 in the failure catalogue).
+ crash the build.
7. **Imports that do not exist in r182**: `three/examples/js/*`, `BufferGeometryUtils.
mergeBufferGeometries` (now `mergeGeometries`), `Geometry`/`Face3`, `THREE.sRGBEncoding`,
`outputEncoding`. Use `three/addons/utils/BufferGeometryUtils.js`,
diff --git a/harness/codeverse3d/prompts/tracks/generate_articulated.j2 b/harness/codeverse3d/prompts/tracks/generate_articulated.j2
index 0f1bc91c..fe6b75f3 100644
--- a/harness/codeverse3d/prompts/tracks/generate_articulated.j2
+++ b/harness/codeverse3d/prompts/tracks/generate_articulated.j2
@@ -16,7 +16,7 @@ Constraints:
## The contract (hard rules)
{{ frame_doc }}
{{ contract }}
-{% if cookbook_rel %}Copyable snippets live in `{{ cookbook_rel }}`.{% endif %}
+{% if cookbook_rel %}Copyable snippets live in `.3dcode/cookbook.md`.{% endif %}
{% if cookbook_excerpt %}
Cookbook excerpt:
{{ cookbook_excerpt }}
diff --git a/harness/codeverse3d/prompts/tracks/generate_graphics.j2 b/harness/codeverse3d/prompts/tracks/generate_graphics.j2
index c7a7421f..360cc47c 100644
--- a/harness/codeverse3d/prompts/tracks/generate_graphics.j2
+++ b/harness/codeverse3d/prompts/tracks/generate_graphics.j2
@@ -17,7 +17,7 @@ Constraints:
{{ contract }}
Files you must produce: {% for f in expected_files %}`{{ f }}`{% if not loop.last %}, {% endif %}{% endfor %}.
-{% if cookbook_rel %}Copyable snippets live in `{{ cookbook_rel }}` (read it before writing if you can).{% endif %}
+{% if cookbook_rel %}Copyable snippets live in `.3dcode/cookbook.md` (read it before writing if you can).{% endif %}
{% if cookbook_excerpt %}
Cookbook excerpt:
{{ cookbook_excerpt }}
diff --git a/harness/codeverse3d/prompts/tracks/generate_static.j2 b/harness/codeverse3d/prompts/tracks/generate_static.j2
index f4f0efae..f4c7580d 100644
--- a/harness/codeverse3d/prompts/tracks/generate_static.j2
+++ b/harness/codeverse3d/prompts/tracks/generate_static.j2
@@ -17,7 +17,7 @@ Constraints:
{{ contract }}
Files you must produce: {% for f in expected_files %}`{{ f }}`{% if not loop.last %}, {% endif %}{% endfor %}.
-{% if cookbook_rel %}Copyable snippets live in `{{ cookbook_rel }}` (read it before writing if you can).{% endif %}
+{% if cookbook_rel %}Copyable snippets live in `.3dcode/cookbook.md` (read it before writing if you can).{% endif %}
{% if cookbook_excerpt %}
Cookbook excerpt:
{{ cookbook_excerpt }}
diff --git a/harness/codeverse3d/prompts/tracks/generate_static_part.j2 b/harness/codeverse3d/prompts/tracks/generate_static_part.j2
index e8a0664a..484ab2f6 100644
--- a/harness/codeverse3d/prompts/tracks/generate_static_part.j2
+++ b/harness/codeverse3d/prompts/tracks/generate_static_part.j2
@@ -19,7 +19,7 @@ Style: {{ style_notes }}
{% for f in files %}- `{{ f }}`
{% endfor %}
The entry file and every other part file belong to other sessions. Touching them loses their work.
-{% if cookbook_rel %}Copyable snippets live in `{{ cookbook_rel }}` — read the density chapter before you write.{% endif %}
+{% if cookbook_rel %}Copyable snippets live in `.3dcode/cookbook.md` — read the density chapter before you write.{% endif %}
## YOUR parts (build every row; object names must match EXACTLY — they become GLB node names)
{{ parts_table }}
diff --git a/harness/codeverse3d/prompts/tracks/refine_object.j2 b/harness/codeverse3d/prompts/tracks/refine_object.j2
index 90a51128..5290fe12 100644
--- a/harness/codeverse3d/prompts/tracks/refine_object.j2
+++ b/harness/codeverse3d/prompts/tracks/refine_object.j2
@@ -48,7 +48,7 @@ Files in scope: {% for f in files %}`{{ f }}`{% if not loop.last %}, {% endif %}
- One code path: no environment sniffing, no DOM/texture loading/network.
{% if current_files %}
-{% if single_shot %}## Current file contents (edit these; return each edited file COMPLETE){% else %}## Current file contents (already in the workspace — edit with `edit_file` / `write_file`; do NOT read_file them first){% endif %}
+{% if single_shot %}## Current file contents (edit these; return each edited file COMPLETE){% else %}## Current file contents (already in the workspace — edit them in place; do NOT read_file them first){% endif %}
{% for path, body in current_files.items() %}
--- {{ path }} ---
```
diff --git a/harness/tests/prompts/test_snippets_run.py b/harness/tests/prompts/test_snippets_run.py
index a91dcca3..41f4f8d1 100644
--- a/harness/tests/prompts/test_snippets_run.py
+++ b/harness/tests/prompts/test_snippets_run.py
@@ -256,7 +256,7 @@ def test_scene_cookbook_sky_shader_compiles(tmp_path) -> None:
"import * as THREE from 'three';\n" + body
+ "\nexport function makeSkyMaterial(THREE_) {\n"
" const s = new THREE_.Scene();\n"
- " buildEnv(THREE_, s);\n"
+ " buildEnv({ THREE: THREE_, scene: s });\n"
" return s.getObjectByName('SkyDome').material;\n"
"}\n"
)