Git Komut Rehberi & Terminal Asistanı
Sıfırdan Yeni Bir Depo Başlatın:
Mevcut Bir Git Deposu veya Klasörü Gönderin:
Hataları Geri Alma, İptal & Temizlik:
Son commit'i geri al (yapılan değişiklikleri korur):
git reset --soft HEAD~1
Yapılan yerel değişiklikleri iptal et (çalışma ağacını temizler):
git restore .
Takip edilmeyen gereksiz dosyaları sil:
git clean -fd
Değişiklikleri geçici sakla ve geri getir (stash):
git stash git stash pop
Dal (Branch) ve Sürüm Etiketleri:
Yeni dal aç ve geçiş yap:
git checkout -b yeni-ozellik git push -u origin yeni-ozellik
Sürüm etiketi (tag) oluştur ve gönder:
git tag -a v1.0.0 -m "Sürüm 1.0.0" git push origin --tags
Revert "AI Scene Bridge (MCP)"
This commit is contained in:
@@ -1,71 +0,0 @@
|
||||
import { promises as fs } from "node:fs";
|
||||
import path from "node:path";
|
||||
import { afterAll, describe, expect, it } from "vitest";
|
||||
import { GET, POST } from "@/app/api/scene/route";
|
||||
|
||||
const PENDING_DIR = path.join(process.cwd(), ".codex", "pending-scenes");
|
||||
const projectId = `project-vitest-${Date.now()}`;
|
||||
const stagedFile = path.join(PENDING_DIR, `${projectId}.json`);
|
||||
|
||||
function sceneRequest(body: unknown, headers: Record<string, string> = {}) {
|
||||
return new Request("http://127.0.0.1:3000/api/scene", {
|
||||
method: "POST",
|
||||
headers: { "Content-Type": "application/json", ...headers },
|
||||
body: JSON.stringify(body),
|
||||
});
|
||||
}
|
||||
|
||||
function getRequest(query: string, headers: Record<string, string> = {}) {
|
||||
return new Request(`http://127.0.0.1:3000/api/scene?${query}`, { method: "GET", headers });
|
||||
}
|
||||
|
||||
const oneBox = {
|
||||
projectId,
|
||||
shapes: [{ id: "s1", name: "Box", kind: "box", color: "#d41721", x: 0, z: 0, size: 20, width: 20, depth: 20, height: 20, rotation: 0 }],
|
||||
};
|
||||
|
||||
afterAll(async () => {
|
||||
await fs.rm(stagedFile, { force: true });
|
||||
});
|
||||
|
||||
describe("/api/scene route", () => {
|
||||
it("POSTs a scene, stages it, and GET returns it then 204 when caught up", async () => {
|
||||
const postRes = await POST(sceneRequest(oneBox));
|
||||
expect(postRes.status).toBe(200);
|
||||
const { stagingRevision } = (await postRes.json()) as { stagingRevision: number };
|
||||
expect(typeof stagingRevision).toBe("number");
|
||||
|
||||
// GET with sinceStaging=0 -> returns the staged command
|
||||
const getNew = await GET(getRequest(`projectId=${projectId}&sinceStaging=0`));
|
||||
expect(getNew.status).toBe(200);
|
||||
const command = (await getNew.json()) as { stagingRevision: number; op: string; shapes: unknown[] };
|
||||
expect(command.op).toBe("upsertScene");
|
||||
expect(command.shapes).toHaveLength(1);
|
||||
expect(command.stagingRevision).toBe(stagingRevision);
|
||||
|
||||
// GET with sinceStaging=current -> nothing newer -> 204
|
||||
const getCaughtUp = await GET(getRequest(`projectId=${projectId}&sinceStaging=${stagingRevision}`));
|
||||
expect(getCaughtUp.status).toBe(204);
|
||||
});
|
||||
|
||||
it("assigns a strictly increasing stagingRevision on re-POST", async () => {
|
||||
const first = (await (await POST(sceneRequest(oneBox))).json()) as { stagingRevision: number };
|
||||
const second = (await (await POST(sceneRequest(oneBox))).json()) as { stagingRevision: number };
|
||||
expect(second.stagingRevision).toBeGreaterThan(first.stagingRevision);
|
||||
});
|
||||
|
||||
it("rejects a cross-origin request with 403", async () => {
|
||||
const res = await POST(sceneRequest(oneBox, { Origin: "http://evil.example" }));
|
||||
expect(res.status).toBe(403);
|
||||
});
|
||||
|
||||
it("rejects a structurally invalid body with 400", async () => {
|
||||
const res = await POST(sceneRequest({ projectId, shapes: "not-an-array" }));
|
||||
expect(res.status).toBe(400);
|
||||
});
|
||||
|
||||
it("returns 204 for an unknown project", async () => {
|
||||
const res = await GET(getRequest(`projectId=project-does-not-exist-${Date.now()}&sinceStaging=0`));
|
||||
expect(res.status).toBe(204);
|
||||
});
|
||||
});
|
||||
@@ -1,57 +0,0 @@
|
||||
import { describe, expect, it } from "vitest";
|
||||
import { SHAPE_KINDS, shapesArraySchema, toWorkplaneShapes, type ShapeInput } from "../../apps/mcp/src/shapes";
|
||||
|
||||
describe("MCP scene schema + normalisation", () => {
|
||||
it("exposes all 18 shape kinds", () => {
|
||||
expect(SHAPE_KINDS).toHaveLength(18);
|
||||
expect(SHAPE_KINDS).toContain("box");
|
||||
expect(SHAPE_KINDS).toContain("mesh");
|
||||
});
|
||||
|
||||
it("accepts a minimal valid shape and fills defaults via the app's defaulter", () => {
|
||||
const parsed = shapesArraySchema.parse([{ kind: "box", width: 40, depth: 40, height: 10 }]);
|
||||
const [shape] = toWorkplaneShapes(parsed as ShapeInput[]);
|
||||
expect(shape.kind).toBe("box");
|
||||
expect(typeof shape.color).toBe("string"); // auto-filled
|
||||
expect(shape.color.length).toBeGreaterThan(0);
|
||||
expect(typeof shape.size).toBe("number"); // derived by sceneShape
|
||||
expect(typeof shape.id).toBe("string");
|
||||
expect(shape.name).toBeTruthy();
|
||||
});
|
||||
|
||||
it("preserves a cutter (hole: true) and grouped parts", () => {
|
||||
const [shape] = toWorkplaneShapes(
|
||||
shapesArraySchema.parse([
|
||||
{
|
||||
kind: "box",
|
||||
width: 40,
|
||||
depth: 40,
|
||||
height: 10,
|
||||
groupedShapes: [{ kind: "cylinder", hole: true, width: 8, depth: 8, height: 12 }],
|
||||
},
|
||||
]) as ShapeInput[],
|
||||
);
|
||||
expect(shape.groupedShapes).toHaveLength(1);
|
||||
expect(shape.groupedShapes?.[0]?.hole).toBe(true);
|
||||
});
|
||||
|
||||
it("rejects an invalid ShapeKind", () => {
|
||||
const result = shapesArraySchema.safeParse([{ kind: "banana", width: 1, depth: 1, height: 1 }]);
|
||||
expect(result.success).toBe(false);
|
||||
if (!result.success) {
|
||||
expect(JSON.stringify(result.error.issues)).toContain("invalid_enum_value");
|
||||
}
|
||||
});
|
||||
|
||||
it("rejects a malformed numeric field", () => {
|
||||
const result = shapesArraySchema.safeParse([{ kind: "box", width: "wide", depth: 10, height: 10 }]);
|
||||
expect(result.success).toBe(false);
|
||||
});
|
||||
|
||||
it("accepts an extreme shape and canonicalises rotation instead of rejecting", () => {
|
||||
const parsed = shapesArraySchema.parse([{ kind: "box", width: 100000, depth: 100000, height: 100000, rotation: 725 }]);
|
||||
const [shape] = toWorkplaneShapes(parsed as ShapeInput[]);
|
||||
expect(shape.rotation).toBe(5); // 725 mod 360 via canonicalizeShape, not rejected
|
||||
expect(shape.width).toBe(100000); // magnitude not range-rejected
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user