Merge branch 'worktree-agent-a8216628d445cce8b' into claude/practical-noether-1hb2s1

This commit is contained in:
Claude committed 2026-11-17 16:45:37 +00:00
commit 61fb3e36ba
36 files changed
+411 -63

No files matched your search

+16 -2
View File
@@ -529,6 +529,8 @@ export interface BlenderHost {
launch(exe: string, args: string[]): Promise<void>;
/** Pfad zu `dir/rel`. */
join(dir: string, rel: string): string;
/** [273] Arbeitsordner samt Inhalt löschen (nach Erfolg und Fehler; bei `--keep` und für „In Blender öffnen" nicht aufgerufen). */
cleanup?(dir: string): Promise<void>;
}
export class BlenderMissingError extends Error {
@@ -564,10 +566,22 @@ export interface RenderResult {
}
/** Gemeinsamer Ablauf: Paket auspacken, Blender im Hintergrund laufen lassen, Fortschritt melden, Ergebnisdatei lesen. */
async function runJob(host: BlenderHost, pkg: RenderPackage, opts: RenderRunOptions, outputRel: string, missingText: string): Promise<{ exe: string; bytes: Uint8Array; dir: string; path: string }> {
async function runJob(host: BlenderHost, pkg: RenderPackage, opts: RenderRunOptions, outputRel: string, missingText: string, keepDir = false): Promise<{ exe: string; bytes: Uint8Array; dir: string; path: string }> {
const exe = await host.find(opts.blenderPath);
if (!exe) throw new BlenderMissingError();
const dir = await host.prepare([...pkg.files, { path: "render_dossier.py", bytes: new TextEncoder().encode(opts.script) }]);
let ok = false;
try {
const r = await runIn(host, dir, exe, pkg, opts, outputRel, missingText);
ok = true;
return r;
} finally {
// [273] Arbeitsordner immer löschen (Erfolg, Fehler, Abbruch); nur „In Blender öffnen" braucht ihn danach noch.
if (!(ok && keepDir)) await host.cleanup?.(dir).catch(() => undefined);
}
}
async function runIn(host: BlenderHost, dir: string, exe: string, pkg: RenderPackage, opts: RenderRunOptions, outputRel: string, missingText: string): Promise<{ exe: string; bytes: Uint8Array; dir: string; path: string }> {
const scenePath = host.join(dir, "scene.json");
let stage = "import";
let error = "";
@@ -648,7 +662,7 @@ export async function runBlenderSave(host: BlenderHost, pkg: RenderPackage, opts
* speichert sie dort über „Speichern unter".
*/
export async function runBlenderOpen(host: BlenderHost, pkg: RenderPackage, opts: RenderRunOptions): Promise<{ dir: string; path: string }> {
const r = await runJob(host, pkg, opts, requireSave(pkg), "Blender hat keine .blend-Datei geschrieben");
const r = await runJob(host, pkg, opts, requireSave(pkg), "Blender hat keine .blend-Datei geschrieben", true);
await host.launch(r.exe, blendOpenArgs(r.path));
return { dir: r.dir, path: r.path };
}
+11
View File
@@ -134,6 +134,8 @@ export interface CyclesHost {
spawn(exe: string, args: string[], onLine: (line: string) => void): { done: Promise<number>; cancel(): void };
readFile(path: string): Promise<Uint8Array>;
join(dir: string, rel: string): string;
/** [273] Arbeitsordner samt Inhalt löschen (nach Erfolg und Fehler; bei `--keep` nicht aufgerufen). */
cleanup?(dir: string): Promise<void>;
}
export class CyclesMissingError extends Error {
@@ -198,6 +200,15 @@ export async function runCyclesRender(host: CyclesHost, pkg: CyclesPackage, opts
const exe = await host.find(opts.cyclesPath);
if (!exe) throw new CyclesMissingError();
const dir = await host.prepare(pkg.files);
try {
return await runCyclesIn(host, dir, exe, pkg, opts);
} finally {
// [273] Arbeitsordner immer löschen (Erfolg, Fehler, Abbruch).
await host.cleanup?.(dir).catch(() => undefined);
}
}
async function runCyclesIn(host: CyclesHost, dir: string, exe: string, pkg: CyclesPackage, opts: CyclesRunOptions): Promise<CyclesResult> {
const out = host.join(dir, "render.exr");
const total = pkg.info.samples;
const messages: string[] = [];
+3 -3
View File
@@ -6,8 +6,7 @@
import "../engine/fileioWasm.setup";
import { describe, expect, it } from "vitest";
import { spawnSync } from "node:child_process";
import { mkdtempSync, writeFileSync } from "node:fs";
import { tmpdir } from "node:os";
import { writeFileSync } from "node:fs";
import { join } from "node:path";
import { buildPlanDwg, buildPlanDxf, buildPlanDxfBinary, collectPlanDrawing } from "./exportDxf";
import { countByType, libreDwgReader, readDxf } from "./cadReadBack.testutil";
@@ -16,6 +15,7 @@ import { sampleProject } from "../model/sampleProject";
import { generatePlan } from "../plan/generatePlan";
import { flattenCategories } from "../model/types";
import type { Drawing2D, Project } from "../model/types";
import { makeTmpDir } from "../test/tmpDir";
const hasEzdxf = spawnSync("python3", ["-c", "import ezdxf"]).status === 0;
const allCodes = (p: Project) => new Set(flattenCategories(p.layers).map((l) => l.code));
@@ -62,7 +62,7 @@ interface Ez {
}
function ezdxf(name: string, data: string | Uint8Array): { status: number | null; r: Ez; err: string } {
const dir = mkdtempSync(join(tmpdir(), "dossier-cad-"));
const dir = makeTmpDir("dossier-cad-");
const file = join(dir, `${name}.dxf`);
writeFileSync(file, data);
const p = spawnSync("python3", ["scripts/validate-dxf.py", file], { encoding: "utf8", timeout: 60_000 });
+3 -3
View File
@@ -6,8 +6,7 @@
import "../engine/fileioWasm.setup";
import { describe, expect, it } from "vitest";
import { spawnSync } from "node:child_process";
import { mkdtempSync, writeFileSync } from "node:fs";
import { tmpdir } from "node:os";
import { writeFileSync } from "node:fs";
import { join } from "node:path";
import { buildPlanDxf, buildPlanDxfBinary } from "./exportDxf";
import { sampleProject } from "../model/sampleProject";
@@ -16,6 +15,7 @@ import type { Plan } from "../plan/generatePlan";
import { flattenCategories } from "../model/types";
import type { Project } from "../model/types";
import { projectToWorldCoords } from "../model/geoRebase";
import { makeTmpDir } from "../test/tmpDir";
const hasEzdxf = spawnSync("python3", ["-c", "import ezdxf"]).status === 0;
@@ -51,7 +51,7 @@ interface EzResult {
}
function ezdxfRead(name: string, dxf: string | Uint8Array): { status: number | null; result: EzResult | null; err: string } {
const dir = mkdtempSync(join(tmpdir(), "dossier-dxf-"));
const dir = makeTmpDir("dossier-dxf-");
const file = join(dir, `${name}.dxf`);
writeFileSync(file, dxf);
const r = spawnSync("python3", ["scripts/validate-dxf.py", file], { encoding: "utf8", timeout: 60_000 });
+3 -3
View File
@@ -5,14 +5,14 @@
import "../engine/fileioWasm.setup";
import { describe, expect, it } from "vitest";
import { spawnSync } from "node:child_process";
import { mkdtempSync, writeFileSync } from "node:fs";
import { tmpdir } from "node:os";
import { writeFileSync } from "node:fs";
import { join } from "node:path";
import { buildPlanDxf, buildPlanDxfBinary } from "./exportDxf";
import { sampleProject } from "../model/sampleProject";
import { generatePlan } from "../plan/generatePlan";
import { flattenCategories } from "../model/types";
import type { Project } from "../model/types";
import { makeTmpDir } from "../test/tmpDir";
const hasEzdxf = spawnSync("python3", ["-c", "import ezdxf"]).status === 0;
@@ -32,7 +32,7 @@ interface Res {
}
function ezdxf(name: string, bytes: string | Uint8Array): Res {
const dir = mkdtempSync(join(tmpdir(), "dossier-dxf-"));
const dir = makeTmpDir("dossier-dxf-");
const file = join(dir, `${name}.dxf`);
writeFileSync(file, bytes);
const r = spawnSync("python3", ["scripts/validate-dxf.py", file], { encoding: "utf8", timeout: 60_000, maxBuffer: 256 * 1024 * 1024 });
+3 -3
View File
@@ -5,8 +5,7 @@
import "../engine/fileioWasm.setup";
import { describe, expect, it } from "vitest";
import { spawnSync } from "node:child_process";
import { mkdtempSync, writeFileSync } from "node:fs";
import { tmpdir } from "node:os";
import { writeFileSync } from "node:fs";
import { join } from "node:path";
import { buildPlanDwg, buildPlanDxf } from "./exportDxf";
import { countByType, readDxf } from "./cadReadBack.testutil";
@@ -14,6 +13,7 @@ import { parseDxf } from "../io/dxfParser";
import { buildComplexSampleProject } from "../model/sampleProjectComplex";
import { collectVisibleCodes } from "../model/types";
import { viewportLevelPlan } from "../plan/viewportPlan";
import { makeTmpDir } from "../test/tmpDir";
const hasEzdxf = spawnSync("python3", ["-c", "import ezdxf"]).status === 0;
const p = buildComplexSampleProject();
@@ -42,7 +42,7 @@ describe.each([
it.skipIf(!hasEzdxf)(`${label}: ezdxf liest ohne Auditor-Fehler`, async () => {
const plan = await viewportLevelPlan(p, levelId, codes, "mittel", 100, true, false);
const dir = mkdtempSync(join(tmpdir(), "dossier-dxf-"));
const dir = makeTmpDir("dossier-dxf-");
const file = join(dir, `${levelId}.dxf`);
writeFileSync(file, buildPlanDxf(plan, p, { scaleDenominator: 100, levelId }));
const r = spawnSync("python3", ["scripts/validate-dxf.py", file], { encoding: "utf8", timeout: 60_000, maxBuffer: 256 * 1024 * 1024 });
+3 -3
View File
@@ -3,14 +3,14 @@
import { describe, expect, it } from "vitest";
import { spawnSync } from "node:child_process";
import { mkdtempSync, writeFileSync } from "node:fs";
import { tmpdir } from "node:os";
import { writeFileSync } from "node:fs";
import { join } from "node:path";
import "../engine/fileioWasm.setup";
import { exportIfcSpf } from "./exportIfc";
import { importIfcInto, inspectIfc } from "../io/importView.testutil";
import { sampleProject } from "../model/sampleProject";
import type { Project, Room } from "../model/types";
import { makeTmpDir } from "../test/tmpDir";
const hasIfcOpenShell = spawnSync("python3", ["-c", "import ifcopenshell, ifcopenshell.util.classification, ifcopenshell.validate, _pytest"]).status === 0;
@@ -151,7 +151,7 @@ for s in m.by_type("IfcBuildingStorey"):
print(json.dumps(out))
`;
const run = (name: string, ifc: string) => {
const dir = mkdtempSync(join(tmpdir(), "dossier-ifc-cls-"));
const dir = makeTmpDir("dossier-ifc-cls-");
const file = join(dir, `${name}.ifc`);
writeFileSync(file, ifc);
const r = spawnSync("python3", ["-c", PY, file], { encoding: "utf8", timeout: 120_000 });
+3 -3
View File
@@ -7,8 +7,7 @@
import { describe, expect, it, vi } from "vitest";
import { spawnSync } from "node:child_process";
import { mkdtempSync, writeFileSync } from "node:fs";
import { tmpdir } from "node:os";
import { writeFileSync } from "node:fs";
import { join } from "node:path";
import "../engine/fileioWasm.setup";
import { exportIfcSpf, type IfcExportOptions } from "./exportIfc";
@@ -17,11 +16,12 @@ import { buildComplexSampleProject } from "../model/sampleProjectComplex";
import { buildWettbewerbSampleProject } from "../model/sampleProjectWettbewerb";
import type { Drawing2D, Project } from "../model/types";
import { roomBook } from "./roomBook";
import { makeTmpDir } from "../test/tmpDir";
const hasIfcOpenShell = spawnSync("python3", ["-c", "import ifcopenshell, ifcopenshell.validate, ifcopenshell.util.shape, _pytest"]).status === 0;
function writeIfc(name: string, ifc: string): string {
const file = join(mkdtempSync(join(tmpdir(), "dossier-ifc-fp-")), `${name}.ifc`);
const file = join(makeTmpDir("dossier-ifc-fp-"), `${name}.ifc`);
writeFileSync(file, ifc);
return file;
}
+3 -3
View File
@@ -2,13 +2,13 @@
import { describe, expect, it } from "vitest";
import { spawnSync } from "node:child_process";
import { mkdtempSync, writeFileSync } from "node:fs";
import { tmpdir } from "node:os";
import { writeFileSync } from "node:fs";
import { join } from "node:path";
import "../engine/fileioWasm.setup";
import { exportIfcSpf } from "./exportIfc";
import { sampleProject } from "../model/sampleProject";
import type { Drawing2D, Project } from "../model/types";
import { makeTmpDir } from "../test/tmpDir";
const hasIfcOpenShell = spawnSync("python3", ["-c", "import ifcopenshell, ifcopenshell.validate, _pytest"]).status === 0;
@@ -51,7 +51,7 @@ describe("IfcGrid im Export [112]", () => {
it.skipIf(!hasIfcOpenShell)("ifcopenshell: gültig, Achsen lesbar (rechtwinklig und radial)", () => {
for (const [name, p] of [["ortho", gridProject()], ["radial", gridProject(true)]] as const) {
const dir = mkdtempSync(join(tmpdir(), "dossier-ifc-grid-"));
const dir = makeTmpDir("dossier-ifc-grid-");
const file = join(dir, `${name}.ifc`);
writeFileSync(file, exportIfcSpf(p));
const r = spawnSync("python3", ["scripts/validate-ifc.py", file], { encoding: "utf8", timeout: 120_000 });
+3 -3
View File
@@ -8,14 +8,14 @@
import { describe, expect, it } from "vitest";
import { spawnSync } from "node:child_process";
import { mkdtempSync, writeFileSync } from "node:fs";
import { tmpdir } from "node:os";
import { writeFileSync } from "node:fs";
import { join } from "node:path";
import "../engine/fileioWasm.setup";
import { exportIfcSpf } from "./exportIfc";
import { importIfcInto, inspectIfc } from "../io/importView.testutil";
import { emptyProject, sampleProject } from "../model/sampleProject";
import type { Project } from "../model/types";
import { makeTmpDir } from "../test/tmpDir";
const hasIfcOpenShell = spawnSync("python3", ["-c", "import ifcopenshell, ifcopenshell.validate, _pytest"]).status === 0;
const bytesOf = (s: string) => new TextEncoder().encode(s);
@@ -181,7 +181,7 @@ describe("IFC2x3-Export: eigener Import liest dasselbe wie bei IFC4", () => {
// ── ifcopenshell ────────────────────────────────────────────────────────────
function writeIfc(name: string, ifc: string): string {
const dir = mkdtempSync(join(tmpdir(), "dossier-ifc2x3-"));
const dir = makeTmpDir("dossier-ifc2x3-");
const file = join(dir, `${name}.ifc`);
writeFileSync(file, ifc);
return file;
+3 -3
View File
@@ -4,13 +4,13 @@
import { describe, expect, it } from "vitest";
import { spawnSync } from "node:child_process";
import { mkdtempSync, writeFileSync } from "node:fs";
import { tmpdir } from "node:os";
import { writeFileSync } from "node:fs";
import { join } from "node:path";
import "../engine/fileioWasm.setup";
import { exportIfcSpf } from "./exportIfc";
import { sampleProject } from "../model/sampleProject";
import type { Column, Project, Stair } from "../model/types";
import { makeTmpDir } from "../test/tmpDir";
const hasIfcOpenShell = spawnSync("python3", ["-c", "import ifcopenshell, ifcopenshell.validate, numpy"]).status === 0;
@@ -31,7 +31,7 @@ function project(): Project {
}
function writeIfc(name: string, ifc: string): string {
const dir = mkdtempSync(join(tmpdir(), "dossier-qto-"));
const dir = makeTmpDir("dossier-qto-");
const file = join(dir, `${name}.ifc`);
writeFileSync(file, ifc);
return file;
+3 -3
View File
@@ -4,8 +4,7 @@
import { describe, expect, it } from "vitest";
import { spawnSync } from "node:child_process";
import { mkdtempSync, writeFileSync } from "node:fs";
import { tmpdir } from "node:os";
import { writeFileSync } from "node:fs";
import { join } from "node:path";
import "../engine/fileioWasm.setup";
import { exportIfcSpf, ifcGuid } from "./exportIfc";
@@ -13,11 +12,12 @@ import { wallMeshVolumes } from "./meshScene.testutil";
import { emptyProject, sampleProject } from "../model/sampleProject";
import { buildComplexSampleProject } from "../model/sampleProjectComplex";
import type { Project } from "../model/types";
import { makeTmpDir } from "../test/tmpDir";
const hasIfcOpenShell = spawnSync("python3", ["-c", "import ifcopenshell, ifcopenshell.validate, _pytest"]).status === 0;
function writeIfc(name: string, ifc: string): string {
const dir = mkdtempSync(join(tmpdir(), "dossier-ifc-"));
const dir = makeTmpDir("dossier-ifc-");
const file = join(dir, `${name}.ifc`);
writeFileSync(file, ifc);
return file;