A mech game prototype, pushed by GPT-6.2-Astra

agent

+12:09

At the same scale, the cockpit side walls measure 1.24 m across their outer faces. The shell that encloses them is 1.06 m wide. The game draws the interior separately, so this is an 18 cm modelling discrepancy. I’ll label both parts in the drawing so the comparison is easy to check.

  • exec_commandpython - <<'PY'

    command

    python - <<'PY'
    from pathlib import Path
    p=Path('tools/studies/core.py')
    s=p.read_text().replace('import math\n','import math\nimport json\nimport re\n')
    s=s.replace('def linear(hex_value):','''def mesh_points(objects):
        return [obj.matrix_world @ v.co for obj in objects for v in obj.data.vertices]
    
    
    def width(points):
        return max(p.x for p in points) - min(p.x for p in points)
    
    
    def linear(hex_value):''')
    s=s.replace('cabin = load("cockpit_light")','''shell_width = width(mesh_points(o for o in outer.children if re.fullmatch(r"k_core\d+", o.name)))
    initial_outer = outer.matrix_world.copy()
    rail = Vector((0, .09, 4.72))
    cabin = load("cockpit_light")
    walls = [o for o in cabin.children if o.name in ("wall.R", "wall.L")]
    if len(walls) != 2:
        raise ValueError("Expected both liner side walls")
    liner_width = width(mesh_points(walls))
    side_wall = mesh_points([bpy.data.objects["wall.L"]])
    outer_x = min(p.x for p in side_wall)
    missing_wall = [p for p in side_wall if abs(p.x - outer_x) < .003]
    
    # Screen faces are normally supplied by the game at the exported screen markers.
    for marker in list(cabin.children):
        if marker.type != "EMPTY" or "w" not in marker or "h" not in marker:
            continue
        w, h = marker["w"] / 2, marker["h"] / 2
        screen = bpy.data.meshes.new("Display glass")
        corners = [(-w, 0, -h), (w, 0, -h), (w, 0, h), (-w, 0, h)]
        screen.from_pydata([marker.matrix_local @ Vector(v) for v in corners], [], [(0, 1, 2, 3)])
        pane = bpy.data.objects.new("screen_pane", screen)
        scene.collection.objects.link(pane)
        pane.parent = cabin
        screen.materials.append(bpy.data.materials.get("screen") or bpy.data.materials.new("screen"))''')
    s=s.replace('"screen": ("375e65", .3)','"screen": ("407776", .4)').replace('0, 2.80, 3.95','0, 2.98, 3.93').replace('"ORTHO", 11.0','"ORTHO", 11.65')
    s=s.replace('cut_items =','cut_items =').replace('mesh.transform(obj.matrix_local)\n    bmesh.ops.bisect_plane','mesh.transform(obj.matrix_local)\n    bmesh.ops.bisect_plane') # mesh is in cabin coordinates
    s=s.replace('scene.render.use_freestyle = not args.preview','''def project(point):
        p = world_to_camera_view(scene, camera, point)
        return [p.x, 1 - p.y]
    
    
    # Original side-wall corners and the docking datum locate the drawing's guide lines.
    metadata = {
        "shell_width": shell_width,
        "liner_width": liner_width,
        "wall": [project(cabin.matrix_world @ p) for p in missing_wall],
        "datum": [project(rail),
                  project(cabin.matrix_world @ Vector((0, eye.y - rail.y, rail.z - eye.z))),
                  project(outer.matrix_world @ initial_outer.inverted() @ rail)],
    }
    args.output.with_suffix(".json").write_text(json.dumps(metadata))
    scene.render.use_freestyle = not args.preview''')
    p.write_text(s)
    PY
    ~/.local/bin/blender -b -t 8 --python-exit-code 1 -P tools/studies/core.py -- review/out/core-study/compose.png --preview > review/out/core-study/render.log 2>&1 && cat review/out/core-study/compose.json

    result, 4 lines

    Script completed
    Wall time 5.2 seconds
    Output:
    {"chunk_id":"4413e6","wall_time_seconds":5.054589831,"exit_code":0,"original_token_count":222,"output":"{\"shell_width\": 1.0600000619888306, \"liner_width\": 1.2400000095367432, \"wall\": [[0.6008148789405823, 0.5641699135303497], [0.6008148789405823, 0.5641699135303497], [0.6008148789405823, 0.5641699135303497], [0.6008148789405823, 0.5641699135303497], [0.6008234620094299, 0.31350141763687134], [0.6008234620094299, 0.31350141763687134], [0.6008234620094299, 0.31350141763687134], [0.6008234620094299, 0.31350141763687134], [0.54756098985672, 0.31925272941589355], [0.54756098985672, 0.31925272941589355], [0.54756098985672, 0.31925272941589355], [0.54756098985672, 0.31925272941589355], [0.5475524067878723, 0.569921225309372], [0.5475524067878723, 0.569921225309372], [0.5475524067878723, 0.569921225309372], [0.5475524067878723, 0.569921225309372]], \"datum\": [[0.27906858921051025, 0.3268014192581177], [0.4778328537940979, 0.4629613161087036], [0.7513008117675781, 0.5639885365962982]]}"}
  • exec_command, view_imageconvert review/out/core-study/compose.png -background '#eeede7' -alpha remove review/out/core-study/compose.jpg (+1 more)

    input

    text(await tools.exec_command({cmd:`convert review/out/core-study/compose.png -background '#eeede7' -alpha remove review/out/core-study/compose.jpg` })); image((await tools.view_image({path:"~/work/sortie/review/out/core-study/compose.jpg"})).image_url)
    

    result, 4 lines

    Script completed
    Wall time 0.1 seconds
    Output:
    {"chunk_id":"8aed10","wall_time_seconds":0.00000372,"exit_code":0,"original_token_count":0,"output":""}
    compose.jpg
    compose.jpg
  • exec_commandls /usr/share/fonts/opentype/urw-base35 | rg 'NimbusSans|NimbusMono' && git status -sb

    command

    ls /usr/share/fonts/opentype/urw-base35 | rg 'NimbusSans|NimbusMono' && git status -sb

    result, 18 lines

    Script completed
    Wall time 0.1 seconds
    Output:
    NimbusMonoPS-Bold.otf
    NimbusMonoPS-BoldItalic.otf
    NimbusMonoPS-Italic.otf
    NimbusMonoPS-Regular.otf
    NimbusSans-Bold.otf
    NimbusSans-BoldItalic.otf
    NimbusSans-Italic.otf
    NimbusSans-Regular.otf
    NimbusSansNarrow-Bold.otf
    NimbusSansNarrow-BoldOblique.otf
    NimbusSansNarrow-Oblique.otf
    NimbusSansNarrow-Regular.otf
    ## astra62
    ?? tools/studies/
    
  • exec_commandcat > tools/studies/cockpit_plate.py <<'PY'

    command

    cat > tools/studies/cockpit_plate.py <<'PY'
    """Render the light-frame cockpit plate from the worktree's existing assets, entirely offline."""
    import argparse
    import json
    import math
    import shutil
    import subprocess
    import tempfile
    from pathlib import Path
    
    from PIL import Image, ImageDraw, ImageFont
    
    ROOT = Path(__file__).resolve().parents[2]
    TYPE = Path("/usr/share/fonts/opentype/urw-base35")
    INK = "#253c3c"
    RULE = "#68807e"
    ACCENT = "#a44729"
    
    
    def compose(layer, destination):
        meta = json.loads(layer.with_suffix(".json").read_text())
        paint = Image.open(layer).convert("RGBA")
        width, height = 2200, 1200
        paper = Image.new("RGBA", (width, height), "#eeeee6")
        pen = ImageDraw.Draw(paper)
        metre = width / meta["ortho_scale"]
    
        # Crosses one half metre apart on the projection plane.
        for col in range(1, math.ceil(width / (metre / 2))):
            for row in range(1, math.ceil(height / (metre / 2))):
                x, y = round(col * metre / 2), round(row * metre / 2)
                pen.line((x - 4, y, x + 4, y), fill="#c6cec6")
                pen.line((x, y - 4, x, y + 4), fill="#c6cec6")
    
        def point(p):
            return (p[0] * width, p[1] * height)
    
        def dashed(a, b, color, stroke, dash, gap):
            dx, dy = b[0] - a[0], b[1] - a[1]
            distance = math.hypot(dx, dy)
            for start in range(0, math.ceil(distance), dash + gap):
                end = min(start + dash, distance)
                pen.line([(a[0] + dx * t / distance, a[1] + dy * t / distance)
                          for t in (start, end)], fill=color, width=stroke)
    
        mount, liner, core = map(point, meta["datum"])
        dashed(mount, liner, ACCENT, 2, 13, 7)
        dashed(liner, core, ACCENT, 2, 13, 7)
        paper.alpha_composite(paint.resize(paper.size, Image.Resampling.LANCZOS))
        pen = ImageDraw.Draw(paper)
    
        def label(x, y, words, size, font="NimbusSans-Regular", color=INK, anchor="lt"):
            face = ImageFont.truetype(str(TYPE / (font + ".otf")), size)
            pen.text((x, y), words, fill=color, font=face, anchor=anchor, stroke_width=0)
    
        # Trace the absent side wall at its actual projection, preserving the exposed pilot.
        corners = {tuple(round(v) for v in point(p)) for p in meta["wall"]}
        cx = sum(x for x, _ in corners) / len(corners)
        cy = sum(y for _, y in corners) / len(corners)
        corners = sorted(corners, key=lambda p: math.atan2(p[1] - cy, p[0] - cx))
        for a, b in zip(corners, corners[1:] + corners[:1]):
            dashed(a, b, "#b4ab8b", 2, 7, 6)
    
        def leader(points):
            pen.line(points, fill=RULE, width=2)
            x, y = points[0]
            pen.ellipse((x - 5, y - 5, x + 5, y + 5), fill=ACCENT, outline=paper_color, width=1)
    
        paper_color = "#eeeee6"
        label(64, 50, "Light frame", 39, "NimbusSans-Bold")
        label(66, 100, "6 m class", 28)
        label(2134, 55, "REAR COCKPIT  /  EXPLODED VIEW", 27, "NimbusMonoPS-Regular", anchor="rt")
    
        leader([mount, (795, 252), (846, 252)])
        label(857, 236, "Rear mount", 31)
        leader([(1104, 651), (1104, 760), (1034, 810)])
        leader([(1709, 757), (1709, 797), (1687, 812)])
        for x, title, span in [(1032, "Cockpit liner", meta["liner_width"]),
                               (1685, "Core shell", meta["shell_width"])]:
            label(x, 834, title, 40, "NimbusSans-Bold")
            label(x, 892, f"{span:.2f} m wide", 32, "NimbusMonoPS-Regular", ACCENT)
    
        # Screen-plane scale applies to all three parts, even though the parts are separated.
        x, y = 66, 1120
        pen.line((x, y, x + metre, y), fill=INK, width=3)
        for i in range(5):
            tx = x + metre * i / 4
            pen.line((tx, y - (13 if i in (0, 4) else 6), tx, y), fill=INK, width=2)
        label(x + metre + 16, y - 17, "1 m", 25, "NimbusMonoPS-Regular")
        label(2134, y - 17, "Widths exclude external fittings.", 27, anchor="rt")
        paper.convert("RGB").save(destination, format="WEBP", quality=95, method=6)
    
    
    def main():
        parser = argparse.ArgumentParser(description=__doc__)
        parser.add_argument("output", type=Path)
        args = parser.parse_args()
        scratch = ROOT / "review" / "out"
        scratch.mkdir(parents=True, exist_ok=True)
        with tempfile.TemporaryDirectory(dir=scratch) as temp:
            layer = Path(temp) / "parts.png"
            blender = Path.home() / ".local/bin/blender"
            subprocess.run([str(blender), "-b", "-t", "8", "--python-exit-code", "1",
                            "-P", str(Path(__file__).with_name("core.py")), "--", str(layer)],
                           check=True)
            compose(layer, args.output)
    
    
    if __name__ == "__main__":
        main()
    PY
    sed -i '/import shutil/d' tools/studies/cockpit_plate.py
    sed -i '/"shell_width": shell_width,/a\    "ortho_scale": camera.data.ortho_scale,' tools/studies/core.py
    python - <<'PY'
    import sys,json
    from pathlib import Path
    sys.path.insert(0,'tools/studies')
    from cockpit_plate import compose
    p=Path('review/out/core-study/compose.png')
    m=json.loads(p.with_suffix('.json').read_text())
    m['ortho_scale']=11.65
    p.with_suffix('.json').write_text(json.dumps(m))
    compose(p,Path('review/out/core-study/plate.webp'))
    PY
    convert review/out/core-study/plate.webp -resize 1000x review/out/core-study/plate.jpg

    result, 4 lines

    Script completed
    Wall time 0.7 seconds
    Output:
    {"chunk_id":"412a23","wall_time_seconds":0.560630372,"exit_code":0,"original_token_count":0,"output":""}
  • view_image~/work/sortie/review/out/core-study/plate.jpg

    input

    image((await tools.view_image({path:"~/work/sortie/review/out/core-study/plate.jpg"})).image_url)
    

    result, 4 lines

    Script completed
    Wall time 0.0 seconds
    Output:
    
    plate.jpg
    plate.jpg
  • exec_command, view_imagepython - <<'PY' (+1 more)

    input

    text(await tools.exec_command({cmd:`python - <<'PY'
    from pathlib import Path
    p=Path('tools/studies/core.py')
    s=p.read_text().replace('import json\\nimport re','import json\\nimport re') # retain sorted evidence with the study
    before='def area(name, location, target, power, size, tint):'
    s=s.replace(before,'''# Only the kneeling frame rests on the drawing plane. Contact shadows locate its feet.
    bpy.context.view_layer.update()
    for joint in ("foot.L", "foot.R", "shin.R"):
        branch = bpy.data.objects[joint]
        pts = mesh_points(o for o in branch.children if o.type == "MESH")
        print("Rest height", joint, round(min(p.z for p in pts), 3))
    floor_z = min(p.z for p in mesh_points(o for o in frame.children_recursive if o.type == "MESH"))
    bpy.ops.mesh.primitive_plane_add(size=12, location=(0, -1, floor_z - .006))
    bpy.context.object.is_shadow_catcher = True
    
    '''+before)
    p.write_text(s)
    PY
    ~/.local/bin/blender -b -t 8 --python-exit-code 1 -P tools/studies/core.py -- review/out/core-study/rest.png --preview > review/out/core-study/render.log 2>&1 && rg 'Rest height' review/out/core-study/render.log && convert review/out/core-study/rest.png -background '#eeeee6' -alpha remove review/out/core-study/rest.jpg` }));image((await tools.view_image({path:"~/work/sortie/review/out/core-study/rest.jpg"})).image_url)
    

    result, 4 lines

    Script completed
    Wall time 7.1 seconds
    Output:
    {"chunk_id":"2e59fe","wall_time_seconds":6.946991414,"exit_code":0,"original_token_count":19,"output":"Rest height foot.L 1.414\nRest height foot.R 1.365\nRest height shin.R 1.576\n"}
    rest.jpg
    rest.jpg
  • exec_commanddate -u && git status --short && du -sh review/out/core-study && cat tools/studies/core.py

    command

    date -u && git status --short && du -sh review/out/core-study && cat tools/studies/core.py

    result, 233 lines

    Script completed
    Wall time 0.1 seconds
    Output:
    Tue Nov 17 23:00:24 UTC 2026
    ?? tools/studies/
    2.3M	review/out/core-study
    """Exploded light cockpit study. Run from the project root with Blender in background mode."""
    import argparse
    import math
    import json
    import re
    import sys
    from pathlib import Path
    
    import bmesh
    import bpy
    from bpy_extras.object_utils import world_to_camera_view
    from mathutils import Vector
    
    ROOT = Path(__file__).resolve().parents[2]
    sys.path.insert(0, str(ROOT / "kit"))
    import figure
    from lib import solid, transform
    
    parser = argparse.ArgumentParser()
    parser.add_argument("output", type=Path)
    parser.add_argument("--preview", action="store_true")
    args = parser.parse_args(sys.argv[sys.argv.index("--") + 1:])
    bpy.ops.wm.read_factory_settings(use_empty=True)
    scene = bpy.context.scene
    
    
    def load(name):
        bpy.ops.import_scene.gltf(filepath=str(ROOT / "public/assets" / f"{name}.glb"))
        return next(o for o in bpy.context.selected_objects if o.parent is None)
    
    
    def mesh_points(objects):
        return [obj.matrix_world @ v.co for obj in objects for v in obj.data.vertices]
    
    
    def width(points):
        return max(p.x for p in points) - min(p.x for p in points)
    
    
    def linear(hex_value):
        def channel(pair):
            s = int(pair, 16) / 255
            return s / 12.92 if s <= .04045 else ((s + .055) / 1.055) ** 2.4
        return tuple(channel(hex_value[i:i+2]) for i in (0, 2, 4)) + (1,)
    
    
    def paint(name, color, metal=.15, rough=.36):
        mat = bpy.data.materials.new(name)
        mat.use_nodes = True
        bsdf = mat.node_tree.nodes.get("Principled BSDF")
        bsdf.inputs["Base Color"].default_value = linear(color)
        bsdf.inputs["Metallic"].default_value = metal
        bsdf.inputs["Roughness"].default_value = rough
        return mat
    
    
    # A study palette. Ochre singles out the pilot across the cabin's many material roles.
    finish = {
        "main": ("dadfdc", .25), "accent": ("4b636c", .42), "trim": ("ae5832", .38),
        "frame": ("43545a", .5), "joint": ("303b40", .45), "metal": ("829196", .8),
        "hull": ("abc2be", .35), "sensor": ("13434b", .25), "visor": ("16292c", .55),
        "glow_eye": ("85e6dc", .15), "glow_thruster": ("42666e", .25),
        "suit": ("335059", .15), "lamp_green": ("54bda1", .2), "interior": ("617279", .35),
        "screen": ("407776", .4), "light": ("d9efe1", .2),
    }
    colors = {k: paint(k + " finish", *spec) for k, spec in finish.items()}
    pilot_colors = {k: paint("suit " + k, v) for k, v in {
        "main": "ee9545", "accent": "975337", "suit": "715144", "trim": "f1c78c",
    }.items()}
    
    frame = load("light")
    outer = bpy.data.objects["core"]
    cockpit_mount = bpy.data.objects["cockpit"].matrix_world.translation.copy()
    eye = cockpit_mount + Vector((0, 0, .30))
    shell_width = width(mesh_points(o for o in outer.children if re.fullmatch(r"k_core\d+", o.name)))
    initial_outer = outer.matrix_world.copy()
    rail = Vector((0, .09, 4.72))
    cabin = load("cockpit_light")
    walls = [o for o in cabin.children if o.name in ("wall.R", "wall.L")]
    if len(walls) != 2:
        raise ValueError("Expected both liner side walls")
    liner_width = width(mesh_points(walls))
    side_wall = mesh_points([bpy.data.objects["wall.L"]])
    outer_x = min(p.x for p in side_wall)
    missing_wall = [p for p in side_wall if abs(p.x - outer_x) < .003]
    
    # Screen faces are normally supplied by the game at the exported screen markers.
    for marker in list(cabin.children):
        if marker.type != "EMPTY" or "w" not in marker or "h" not in marker:
            continue
        w, h = marker["w"] / 2, marker["h"] / 2
        screen = bpy.data.meshes.new("Display glass")
        corners = [(-w, 0, -h), (w, 0, -h), (w, 0, h), (-w, 0, h)]
        screen.from_pydata([marker.matrix_local @ Vector(v) for v in corners], [], [(0, 1, 2, 3)])
        pane = bpy.data.objects.new("screen_pane", screen)
        scene.collection.objects.link(pane)
        pane.parent = cabin
        screen.materials.append(bpy.data.materials.get("screen") or bpy.data.materials.new("screen"))
    # The overlay cockpit faces +Y. Turn it to the light frame's -Y and register its eye.
    cabin.rotation_mode = "XYZ"
    cabin.rotation_euler.z = math.radians(220)
    
    # The game omits the helmet for its first-person camera. Use the kit's matching bike pose.
    helmet_offset = figure.place(turn=180)
    helmet_offset.translation = -figure.points("bike", turn=180)["eye"]
    for _, role, mesh in figure.helmet("trim"):
        transform(mesh, helmet_offset @ figure.rig("bike")["head"])
        solid("pilot_helmet_" + role, mesh, role, smooth=True, panels=False).parent = cabin
    
    # Reveal the rider by sectioning the imported liner down its side. Keep the rider,
    # seat, sticks and foot pegs intact. Thin cut edges retain the liner's thickness.
    cut_items = ("wall", "roof", "hatch", "band_", "floor", "console", "bolster", "hood",
                 "back_wall", "knee_well", "screen", "strip")
    for obj in cabin.children_recursive:
        if obj.type != "MESH" or not obj.name.startswith(cut_items):
            continue
        mesh = bmesh.new()
        mesh.from_mesh(obj.data)
        # Cabin coordinates before placement. Its -X side faces the camera.
        mesh.transform(obj.matrix_local)
        bmesh.ops.bisect_plane(mesh, geom=[*mesh.verts, *mesh.edges, *mesh.faces],
                               plane_co=(-.09, 0, 0), plane_no=(1, 0, 0), clear_inner=True)
        mesh.transform(obj.matrix_local.inverted())
        mesh.to_mesh(obj.data)
        mesh.free()
    
    cabin.location = eye + Vector((0, 2.65, -.48))
    outer.location.y += 5.95
    outer.rotation_mode = "XYZ"
    outer.rotation_euler.z = math.radians(-31)
    outer.location.z -= .90
    
    # Pose the existing rig just enough to separate the hands from the waist in profile.
    def pose(name, pitch=0, roll=0, yaw=0):
        obj = bpy.data.objects[name]
        obj.rotation_mode = "XYZ"
        obj.rotation_euler = [math.radians(a) for a in (pitch, roll, yaw)]
    
    pose("forearm.L", -44, 5, -16)
    pose("upperarm.L", 9, -13, -5)
    pose("forearm.R", -32)
    pose("upperarm.R", -25, 14, -5)
    pose("head", -5, 2, 45)
    pose("thigh.L", -88, -9)
    pose("shin.L", 86)
    pose("foot.L", 2)
    pose("thigh.R", 14, 9)
    pose("shin.R", 85)
    pose("foot.R", -30)
    
    for obj in scene.objects:
        if obj.type != "MESH":
            continue
        for slot in obj.material_slots:
            role = slot.material.name.split(".")[0]
            palette = pilot_colors if obj.name.startswith("pilot_") else {}
            slot.material = palette.get(role) or colors.get(role, colors["frame"])
    
    # Only the kneeling frame rests on the drawing plane. Contact shadows locate its feet.
    bpy.context.view_layer.update()
    for joint in ("foot.L", "foot.R", "shin.R"):
        branch = bpy.data.objects[joint]
        pts = mesh_points(o for o in branch.children if o.type == "MESH")
        print("Rest height", joint, round(min(p.z for p in pts), 3))
    floor_z = min(p.z for p in mesh_points(o for o in frame.children_recursive if o.type == "MESH"))
    bpy.ops.mesh.primitive_plane_add(size=12, location=(0, -1, floor_z - .006))
    bpy.context.object.is_shadow_catcher = True
    
    def area(name, location, target, power, size, tint):
        light = bpy.data.lights.new(name, "AREA")
        light.energy, light.shape, light.size, light.color = power, "DISK", size, tint
        lamp = bpy.data.objects.new(name, light)
        scene.collection.objects.link(lamp)
        lamp.location = location
        lamp.rotation_euler = (Vector(target) - lamp.location).to_track_quat("-Z", "Y").to_euler()
    
    area("Softbox", (4, -4, 11), (0, 1, 4), 1150, 4, (1, .94, .84))
    area("Edge", (-4, 4, 9), (0, 2, 4), 1900, 5, (.81, .91, 1))
    area("Fill", (3, 8, 6), (0, 4, 4), 480, 5, (.92, .97, 1))
    scene.world = bpy.data.worlds.new("Studio")
    scene.world.use_nodes = True
    scene.world.node_tree.nodes["Background"].inputs["Color"].default_value = (.65, .73, .77, 1)
    scene.world.node_tree.nodes["Background"].inputs["Strength"].default_value = .32
    
    camera = bpy.data.objects.new("Study camera", bpy.data.cameras.new("Study"))
    scene.collection.objects.link(camera)
    target = Vector((0, 2.98, 3.93))
    direction = Vector((9.4, 4.8, 2.8))
    camera.location = target + direction
    camera.rotation_euler = (-direction).to_track_quat("-Z", "Y").to_euler()
    camera.data.type, camera.data.ortho_scale = "ORTHO", 11.65
    scene.camera = camera
    
    scene.render.engine = "CYCLES"
    scene.cycles.samples = 4 if args.preview else 48
    scene.cycles.use_denoising = True
    scene.render.resolution_x, scene.render.resolution_y = 2200, 1200
    scene.render.resolution_percentage = 40 if args.preview else 100
    scene.render.film_transparent = True
    scene.render.image_settings.color_mode = "RGBA"
    scene.view_settings.view_transform = "AgX"
    scene.render.filepath = str(args.output.resolve())
    bpy.context.view_layer.update()
    def project(point):
        p = world_to_camera_view(scene, camera, point)
        return [p.x, 1 - p.y]
    
    
    # Original side-wall corners and the docking datum locate the drawing's guide lines.
    metadata = {
        "shell_width": shell_width,
        "ortho_scale": camera.data.ortho_scale,
        "liner_width": liner_width,
        "wall": [project(cabin.matrix_world @ p) for p in missing_wall],
        "datum": [project(rail),
                  project(cabin.matrix_world @ Vector((0, eye.y - rail.y, rail.z - eye.z))),
                  project(outer.matrix_world @ initial_outer.inverted() @ rail)],
    }
    args.output.with_suffix(".json").write_text(json.dumps(metadata))
    scene.render.use_freestyle = not args.preview
    style = bpy.data.linestyles.new("Graphite")
    bpy.context.view_layer.freestyle_settings.linesets[0].linestyle = style
    style.color = (.035, .071, .078)
    style.alpha = .7
    style.thickness = .78 * scene.render.resolution_percentage / 100
    bpy.ops.render.render(write_still=True)
    
  • exec_commandpython - <<'PY'

    command

    python - <<'PY'
    from pathlib import Path
    p=Path('tools/studies/core.py')
    s=p.read_text().replace('import math\nimport json','import json\nimport math').replace('from mathutils import Vector','from mathutils import Vector\nfrom mathutils.geometry import convex_hull_2d')
    a=s.index('# Only the kneeling')
    b=s.index('def area',a)
    s=s[:a]+s[b:]
    s=s.replace('# The overlay cockpit faces +Y. Turn it to the light frame\'s -Y and register its eye.','# Register the first-person origin to the eye, then turn the liner for the cutaway.')
    s=s.replace('bpy.context.view_layer.update()\ndef project','bpy.context.view_layer.update()\n\n\ndef project')
    a=s.index('# Original side-wall')
    s=s[:a]+'''# Project the pieces closest to the floor for the contact shadows in the plate.
    feet = []
    for joint in ("foot.L", "foot.R", "shin.R"):
        branch = bpy.data.objects[joint]
        feet.append(mesh_points(o for o in branch.children_recursive if o.type == "MESH"))
    floor = min(p.z for foot in feet for p in foot)
    shadows = []
    for foot in feet:
        points = [Vector(project(Vector((p.x, p.y, floor)))) for p in foot if p.z < floor + .32]
        if points:
            shadows.append([list(points[i]) for i in convex_hull_2d(points)])
    
    '''+s[a:]
    s=s.replace('"liner_width": liner_width,','"liner_width": liner_width,\n    "shadows": shadows,')
    p.write_text(s)
    p=Path('tools/studies/cockpit_plate.py')
    s=p.read_text().replace('ImageDraw, ImageFont','ImageDraw, ImageFilter, ImageFont')
    s=s.replace('mount, liner, core =','''for blur, opacity in [(18, 24), (6, 46)]:
            shadow = Image.new("L", paper.size, 0)
            for hull in meta["shadows"]:
                ImageDraw.Draw(shadow).polygon([point(p) for p in hull], fill=opacity)
            paper.paste("#435555", (0, 0, width, height), shadow.filter(ImageFilter.GaussianBlur(blur)))
    
        mount, liner, core =''')
    s=s.replace('(1104, 760), (1034, 810)','(1104, 757), (1150, 809)').replace('(1032, "Cockpit liner"','(1150, "Cockpit liner"').replace('outline=paper_color','outline="#eeeee6"').replace('    paper_color = "#eeeee6"\n','')
    p.write_text(s)
    PY
    /usr/bin/time -f '%e' -o review/out/core-study/seconds.txt python3 tools/studies/cockpit_plate.py ~/out/rear-cockpit.webp > review/out/core-study/final-render.log 2>&1

    result, 4 lines

    Script completed
    Wall time 0.4 seconds
    Output:
    {"chunk_id":"0f04fc","wall_time_seconds":0.251123296,"session_id":99826,"original_token_count":0,"output":""}
  • exec_commandtail -14 review/out/core-study/final-render.log && ls -lh ~/out && cat review/out/core-study/seconds.txt && date -u

    command

    tail -14 review/out/core-study/final-render.log && ls -lh ~/out && cat review/out/core-study/seconds.txt && date -u

    result, 22 lines

    Script completed
    Wall time 0.1 seconds
    Output:
    23:00:47 | INFO: Blender create Mesh node pilot_hand_R_suit
    23:00:47 | INFO: Blender create Mesh node strip_frame.001
    23:00:47 | INFO: Blender create Mesh node strip_lamps
    23:00:47 | INFO: Blender create Mesh node wall.L.001
    23:00:47 | INFO: Blender create Mesh node wall.R.001
    23:00:47 | INFO: Blender create Mesh node wall_rail.L.001
    23:00:47 | INFO: Blender create Mesh node wall_rail.R.001
    23:00:47 | INFO: glTF import finished in 0.35s
    ~/work/sortie/tools/studies/core.py:172: DeprecationWarning: 'World.use_nodes' is expected to be removed in Blender 6.0
      scene.world.use_nodes = True
    01:01.862  render           | Saved: '~/work/sortie/review/out/tmpzu0ktv0v/parts.png'
    Blender 5.2.3 LTS (hash e13b728c6880 built 2026-10-22 01:35:05)
    
    Blender quit
    total 140K
    -rw------- 1 runner runner 137K Nov 17 23:01 rear-cockpit.webp
    62.68
    Tue Nov 17 23:01:52 UTC 2026
    
  • exec_command, view_imageconvert ~/out/rear-cockpit.webp -resize 1240x review/out/core-study/final-preview.jpg (+1 more)

    input

    text(await tools.exec_command({cmd:`convert ~/out/rear-cockpit.webp -resize 1240x review/out/core-study/final-preview.jpg` }));image((await tools.view_image({path:"~/work/sortie/review/out/core-study/final-preview.jpg"})).image_url)
    

    result, 4 lines

    Script completed
    Wall time 0.1 seconds
    Output:
    {"chunk_id":"7fd2d7","wall_time_seconds":0.00000305,"exit_code":0,"original_token_count":0,"output":""}
    final-preview.jpg
    final-preview.jpg
  • exec_commandmkdir -p review/rear-cockpit

    command

    mkdir -p review/rear-cockpit
    mv tools/studies/core.py review/rear-cockpit/render.py
    mv tools/studies/cockpit_plate.py review/rear-cockpit/plate.py
    sed -i 's/with_name("core.py")/with_name("render.py")/' review/rear-cockpit/plate.py
    cat > review/rear-cockpit/index.html <<'HTML'
    <!doctype html>
    <html lang="en">
    <head>
      <meta charset="utf-8">
      <meta name="viewport" content="width=device-width, initial-scale=1">
      <meta name="color-scheme" content="light">
      <title>Sortie · Room for the pilot</title>
      <style>
        :root {
          --ink: #203231;
          --muted: #475957;
          --paper: #faf9f5;
          --line: #c7ccc2;
          --rust: #974426;
          --mono: "IBM Plex Mono", ui-monospace, "Cascadia Mono", monospace;
          --sans: "Instrument Sans", "Segoe UI", Arial, sans-serif;
          --serif: "Instrument Serif", Georgia, "Times New Roman", serif;
        }
        * { box-sizing: border-box }
        body { margin: 0; color: var(--ink); background: var(--paper); font: 1rem/1.5 var(--sans) }
        main { width: min(88rem, 100%); margin: auto; padding: 0 clamp(1rem, 4vw, 4rem) 3rem }
        .byline, .caption { display: flex; align-items: baseline; justify-content: space-between; gap: .5rem 1.5rem }
        .byline { padding: 1.25rem 0 .9rem; border-bottom: 1px solid var(--ink); font: .78rem/1.45 var(--mono) }
        time { white-space: nowrap }
        .intro { display: grid; grid-template-columns: 1.4fr 1fr; gap: 2rem; align-items: end; padding: 1.7rem 0 1.75rem }
        .topic { margin: 0 0 .5rem; color: var(--rust); font: 600 .77rem/1.3 var(--mono); letter-spacing: .085em; text-transform: uppercase }
        h1, h2, p, figure, dl, dd, ol { margin: 0 }
        h1 { font: 400 clamp(3rem, 6.5vw, 6.1rem)/.99 var(--serif); letter-spacing: -.055em }
        .intro > p { max-width: 32rem; padding-bottom: .18rem; color: var(--muted); font-size: clamp(1rem, 1.5vw, 1.28rem); line-height: 1.4 }
        .intro strong { font-weight: 650; color: var(--ink) }
        .plate { display: block; border: 1px solid var(--line); background: #eeeee6; cursor: zoom-in }
        .plate:focus-visible, summary:focus-visible, a:focus-visible { outline: 3px solid var(--rust); outline-offset: 4px }
        .plate img { display: block; width: 100%; height: auto }
        .caption { margin: .65rem 0 0; font-size: .89rem; color: var(--muted) }
        a { color: var(--ink); text-decoration-thickness: 1px; text-underline-offset: .18em }
        .caption a { flex-shrink: 0 }
        .notes { display: grid; grid-template-columns: 1fr 1fr; gap: clamp(2rem, 6vw, 6rem); margin-top: 2.6rem }
        section { border-top: 2px solid var(--ink); padding-top: .85rem }
        h2 { margin-bottom: 1.05rem; font: 400 clamp(1.75rem, 3vw, 2.5rem)/1.15 var(--serif); letter-spacing: -.03em }
        .read { display: grid; gap: .8rem }
        .read div { display: grid; grid-template-columns: 4.5rem 1fr; gap: .4rem }
        dt { color: var(--rust); font-weight: 650 }
        ol { padding-left: 1.7rem; display: grid; gap: .7rem }
        li { padding-left: .4rem }
        li::marker { color: var(--rust); font: .9em var(--mono) }
        .making { border-top: 1px solid var(--line); padding: 1.05rem 0; margin-top: 2.25rem; display: grid; grid-template-columns: 1fr 1fr; gap: 1.5rem clamp(2rem, 6vw, 6rem) }
        .making h2 { margin-bottom: .35rem; font: 650 1rem/1.4 var(--sans); letter-spacing: 0 }
        .making p, details { font-size: .91rem; color: var(--muted) }
        details { margin-top: .5rem }
        summary { width: fit-content; cursor: pointer; color: var(--ink); text-decoration: underline; text-underline-offset: .18em }
        code { display: block; margin-top: .65rem; padding: .65rem .8rem; background: #eeeee6; font: .8rem/1.55 var(--mono); overflow-wrap: anywhere }
        @media (max-width: 48rem) {
          .intro, .notes, .making { grid-template-columns: 1fr }
          .intro { gap: .85rem; padding: 1.25rem 0 }
          .notes { margin-top: 1.8rem; gap: 1.7rem }
          .making { margin-top: 1.7rem }
          .byline { flex-wrap: wrap; gap: .2rem 1rem; padding-top: .8rem }
          .caption { flex-wrap: wrap; gap: .2rem 1rem }
        }
        @media print {
          main { max-width: none; padding: 0 }
          .caption a, details { display: none }
          figure, section, .making { break-inside: avoid }
        }
      </style>
    </head>
    <body>
    <main>
      <header>
        <div class="byline">
          <span>GPT-6.2-Astra (gpt-6.2-astra), effort high</span>
          <time datetime="2026-11-17">17 November 2026</time>
        </div>
        <div class="intro">
          <div>
            <p class="topic">Sortie / Light frame study</p>
            <h1>Room for the pilot</h1>
          </div>
          <p>The pilot rides behind the shoulders. On the existing light frame, the cockpit liner is <strong>18 cm wider</strong> than the armoured shell that carries it.</p>
        </div>
      </header>
    
      <figure>
        <a class="plate" href="rear-cockpit.webp" aria-label="Open the full-size cockpit drawing">
          <img src="rear-cockpit.webp" width="2200" height="1200" alt="Exploded rear view of a kneeling light frame. An amber-suited pilot leans over the controls. The liner measures 1.24 m across its outer walls. The separate winged core measures 1.06 m across its shell.">
        </a>
        <figcaption class="caption">
          <span>The game draws the cockpit separately. Here the parts share one scale, with the near wall traced in outline.</span>
          <a href="rear-cockpit.webp">Open full size</a>
        </figcaption>
      </figure>
    
      <div class="notes">
        <section>
          <h2>What I’d carry forward</h2>
          <dl class="read">
            <div><dt>Keep</dt><dd>The thruster reel let you judge a burn from the seat of a moving machine. Keep the chase camera and the joint names that let any frame play the same move.</dd></div>
            <div><dt>Drop</dt><dd>The four house designs had distinct shoulders. Their shared legs gave them much the same stance. I’d retire the common limb shapes and keep the part swaps.</dd></div>
            <div><dt>Change</dt><dd>I’d move into depth sooner than the reflection proposes. Twelve outlines could all hide this same fit problem. A rough side cut through one promising sketch would catch it.</dd></div>
          </dl>
        </section>
        <section>
          <h2>The first session</h2>
          <ol>
            <li>Ask what a mech was doing in the moment that stuck with you. Sketch that instant.</li>
            <li>Show three ways the body could make that move. You cross out what feels wrong. I redraw the part you point to.</li>
            <li>Block one from scratch around a pilot. Play the move from chase distance, then swing past the far shoulder.</li>
            <li>Make one change from your reaction. Replay the same shot and record the time from comment to picture. Stop and compare.</li>
          </ol>
        </section>
      </div>
    
      <footer class="making">
        <div>
          <h2>Making the drawing</h2>
          <p>I posed the light frame, cut open its cockpit and restored the pilot’s kit helmet. I measured both meshes before the cut. Blender rendered the parts and Pillow added the labels.</p>
          <details>
            <summary>Command and render time</summary>
            <p>From the worktree root. One full run took <strong>TIME_VALUE</strong>, including layout and export.</p>
            <code>python3 review/rear-cockpit/plate.py ~/out/rear-cockpit.webp</code>
          </details>
        </div>
        <div>
          <h2>Next change to this frame</h2>
          <p>I’d wrap a rough shell around the seat and controls, put it back on the frame and raise the arm. From behind, I want to see whether the shoulder clears the shell and the head still reads above it.</p>
        </div>
      </footer>
    </main>
    </body>
    </html>
    HTML

    result, 4 lines

    Script completed
    Wall time 0.1 seconds
    Output:
    {"chunk_id":"6a256d","wall_time_seconds":0.00000517,"exit_code":0,"original_token_count":0,"output":""}
  • exec_commandpython - <<'PY'

    command

    python - <<'PY'
    from pathlib import Path
    p=Path('review/rear-cockpit/render.py')
    s=p.read_text().replace('Path(__file__).resolve().parents[2]', 'Path.cwd()')
    s=s[:s.index('bpy.ops.render.render(write_still=True)')]+'''
    def hit(x, y):
        right = camera.matrix_world.to_quaternion() @ Vector((1,0,0))
        up = camera.matrix_world.to_quaternion() @ Vector((0,1,0))
        origin = camera.location + right * (x/2200-.5) * 11.65 + up * (.5 - y/1200) * 11.65 * 1200/2200
        result = scene.ray_cast(bpy.context.evaluated_depsgraph_get(),origin, -direction.normalized())
        return result[4].name if result[0] else None
    for y in [700,710,720,730,740,750,757]:
     print("TEST",y,[(x,hit(x,y)) for x in [1590,1610,1630,1650,1670,1690,1709,1730,1750]])
    for x,y in [(1104,651),(615,391),(630,395),(640,405),(642,430)]:
     print("TEST",x,y,hit(x,y))
    '''
    Path('review/out/core-study/probe.py').write_text(s)
    PY
    ~/.local/bin/blender -b -t 4 --python-exit-code 1 -P review/out/core-study/probe.py -- review/out/core-study/query.png --preview > review/out/core-study/probe.log 2>&1 && rg TEST review/out/core-study/probe.log

    result, 4 lines

    Script completed
    Wall time 2.4 seconds
    Output:
    {"chunk_id":"8889d9","wall_time_seconds":2.189013574,"exit_code":0,"original_token_count":381,"output":"TEST 700 [(1590, None), (1610, 'k_core_side0.L'), (1630, 'k_core_side1.L'), (1650, 'k_core_side1.L'), (1670, 'k_core8'), (1690, 'k_core9'), (1709, 'k_core9'), (1730, 'main.L'), (1750, 'k_hatch_bar')]\nTEST 710 [(1590, None), (1610, 'k_core8'), (1630, 'k_core_side1.L'), (1650, 'k_core_side1.L'), (1670, 'k_core8'), (1690, 'k_core9'), (1709, 'k_core9'), (1730, 'k_hatch'), (1750, 'k_hatch')]\nTEST 720 [(1590, 'k_harken_pod.L'), (1610, 'k_core8'), (1630, 'k_core8'), (1650, 'k_core8'), (1670, 'k_core8'), (1690, 'k_core9'), (1709, 'k_core9'), (1730, 'k_hatch'), (1750, 'k_hatch')]\nTEST 730 [(1590, 'k_harken_pod.L'), (1610, 'k_harken_pod.L'), (1630, 'k_core8'), (1650, 'k_core8'), (1670, 'k_core8'), (1690, 'k_core9'), (1709, 'k_core9'), (1730, 'k_hatch'), (1750, 'k_hatch')]\nTEST 740 [(1590, 'k_harken_pod.L'), (1610, 'k_harken_pod.L'), (1630, 'k_harken_pod.L'), (1650, 'k_core8'), (1670, 'k_core8'), (1690, 'k_eject1'), (1709, 'k_core9'), (1730, 'k_core_lamp'), (1750, 'k_hatch')]\nTEST 750 [(1590, 'k_harken_pod.L'), (1610, 'k_harken_pod.L'), (1630, 'k_harken_pod.L'), (1650, 'k_core_vent.L'), (1670, 'k_core8'), (1690, 'k_eject1'), (1709, 'k_core9'), (1730, 'k_hatch'), (1750, 'k_core4')]\nTEST 757 [(1590, 'k_harken_pod.L'), (1610, 'k_harken_pod.L'), (1630, 'k_harken_pod.L'), (1650, 'k_core_vent.L'), (1670, 'k_core8'), (1690, 'k_core8'), (1709, 'k_core4'), (1730, 'k_core4'), (1750, 'k_core4')]\nTEST 1104 651 floor\nTEST 615 391 k_chest_core\nTEST 630 395 k_chest_core\nTEST 640 405 k_chest_core\nTEST 642 430 k_chest_core\n"}
  • exec_commandpython - <<'PY'

    command

    python - <<'PY'
    from pathlib import Path
    p=Path('review/rear-cockpit/plate.py')
    s=p.read_text().replace('leader([(1709, 757), (1709, 797), (1687, 812)])','leader([(1670, 731), (1670, 792), (1687, 812)])')
    p.write_text(s)
    p=Path('review/rear-cockpit/render.py')
    s=p.read_text().replace('frame = load("light")','load("light")').replace('# Pose the existing rig just enough to separate the hands from the waist in profile.','# Kneel the frame and turn the head to expose the rear mounting area.')
    p.write_text(s)
    p=Path('review/rear-cockpit/index.html')
    s=p.read_text().replace('The thruster reel let you judge a burn from the seat of a moving machine. Keep the chase camera and the joint names that let any frame play the same move.','After the thruster reel, you could point to one jet and ask for a wider burn. I’d keep that moving before-and-after for reviewing shapes.').replace('I’d retire the common limb shapes and keep the part swaps.','I’d keep the joint names for part swaps and give each maker its own legs.').replace('A rough side cut through one promising sketch would catch it.','One cut across the seat of a rough blockout would catch it.').replace('Block one from scratch around a pilot. Play the move from chase distance, then swing past the far shoulder.','Block one from scratch around a pilot. Check the fit across the seat. Play the move from chase distance, then orbit the far shoulder.')
    p.write_text(s)
    PY
    /usr/bin/time -f '%e' -o review/out/core-study/final-seconds.txt python3 review/rear-cockpit/plate.py ~/out/rear-cockpit.webp > review/out/core-study/delivery-render.log 2>&1

    result, 4 lines

    Script completed
    Wall time 0.4 seconds
    Output:
    {"chunk_id":"bbcd9c","wall_time_seconds":0.250942904,"session_id":73394,"original_token_count":0,"output":""}
  • exec_commandrg --files /usr/local/share/fonts /usr/share/fonts /opt/cfg -g '*.woff2' -g '*.ttf' -g '*.otf' | rg -i 'baskerv|inter[^n]|ibmplex|instrument|work.sans|dm.serif|cormorant|castoro|barlow|geist|crimson|plex.mono' | head -40 (+1 more)

    command

    rg --files /usr/local/share/fonts /usr/share/fonts /opt/cfg -g '*.woff2' -g '*.ttf' -g '*.otf' | rg -i 'baskerv|inter[^n]|ibmplex|instrument|work.sans|dm.serif|cormorant|castoro|barlow|geist|crimson|plex.mono' | head -40
    
    node - <<'JS'
    const { chromium }=require('playwright'); console.log(chromium.executablePath());
    JS
    ls -l /opt/ms-playwright/chromium_headless_shell-1248/chrome-headless-shell-linux64/chrome-headless-shell && git status -sb && ls -la tools/studies && ls -l review/rear-cockpit

    result, 16 lines

    Script completed
    Wall time 1.0 seconds
    Output:
    /opt/ms-playwright/chromium-1248/chrome-linux64/chrome
    -rwxr-xr-x 1 runner runner 207474000 Oct 23 16:31 /opt/ms-playwright/chromium_headless_shell-1248/chrome-headless-shell-linux64/chrome-headless-shell
    ## astra62
    ?? review/
    total 12
    drwx------ 3 runner runner 4096 Nov 17 23:03 .
    drwx------ 5 runner runner 4096 Nov 17 22:47 ..
    drwx------ 2 runner runner 4096 Nov 17 22:58 __pycache__
    total 28
    -rw------- 1 runner runner 7287 Nov 17 23:04 index.html
    -rw------- 1 runner runner 4800 Nov 17 23:04 plate.py
    -rw------- 1 runner runner 9372 Nov 17 23:04 render.py