Archilyzer · Source

archilyzer

Archilyzer
git clone https://archilyzer.pages.dev/source/archilyzer.git
Log | Files | Refs | README | LICENSE

commit d4ae246ea06497f240c7daec7ba109787c47a3a2
parent 57d1d6693d4cf64f48df7cfb5374c325fbfc24b7
Author: I Mean I'm Just Saying <imeanimjustsaying@kiwifarms.st>
Date:   Mon,  9 Nov 2026 19:32:52 -0500

umtool: palette.spec.ts -- the look form run from the palette, the clip from the bench, POST /api/cli's refusals and the queue; docs.mjs out of the build trace

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>

Diffstat:
Aumtool/e2e/palette.spec.ts | 165+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Mumtool/lib/cli/docs.mjs | 4++--
2 files changed, 167 insertions(+), 2 deletions(-)

diff --git a/umtool/e2e/palette.spec.ts b/umtool/e2e/palette.spec.ts @@ -0,0 +1,165 @@ +import { test, expect, type Page } from "@playwright/test"; +import { readFileSync, writeFileSync } from "node:fs"; +import path from "node:path"; +import { fileURLToPath } from "node:url"; +import * as urls from "./urls"; + +// --------------------------------------------------------------------------- +// ⌘K COMMANDS (umtool redesign, lane palette L8a): the verb registry's forms in +// the palette. ⌘K on a project's page, "look" -> the `umtool look` form, the +// project filled in from the page -> mode=basic -> Copy as CLI is the exact +// line -> Run: the job's log, done, and the manifest changed. On a clip bench +// the clip is filled in too. POST /api/cli refuses a ui:"none" verb (absent +// from the palette), a raw argv, a value its schema refuses and a request no +// page of this app made; a verb that renders goes through the durable queue. +// Fixture: e2e/fixtures/basic-mode-fixture.mjs (basic-fixture, a deck cut); +// the spec puts its manifest back. E2E_PALETTE_SHOTS=<dir>: screenshots there (1366x768). +// --------------------------------------------------------------------------- + +const HERE = path.dirname(fileURLToPath(import.meta.url)); +const PROJECT = "reports/basic-fixture"; +const MANIFEST = path.join(HERE, "..", ".e2e-song", "reports", "basic-fixture", "video.manifest.json"); +const SHOTS = process.env.E2E_PALETTE_SHOTS ?? ""; +const original = readFileSync(MANIFEST, "utf8"); +const manifest = () => JSON.parse(readFileSync(MANIFEST, "utf8")); +const shot = async (page: Page, name: string) => { + if (SHOTS) await page.screenshot({ path: path.join(SHOTS, `${name}.png`) }); +}; +const palette = (page: Page) => page.locator("dialog[data-jump]"); +const open = async (page: Page) => { + await expect(page.locator("dialog[data-jump][data-ready]")).toBeAttached({ timeout: 60_000 }); + await page.keyboard.press("Control+k"); + await expect(palette(page)).toBeVisible(); +}; + +test.beforeEach(() => writeFileSync(MANIFEST, original)); +test.afterAll(() => writeFileSync(MANIFEST, original)); + +test("⌘K → look → its form, the project from the page → Copy as CLI → Run: the manifest changed", async ({ page, context }) => { + test.setTimeout(180_000); + await context.grantPermissions(["clipboard-read", "clipboard-write"]); + await page.setViewportSize({ width: 1366, height: 768 }); + await page.goto(urls.section(PROJECT, "build")); + await open(page); + + // Typed words find the verb among the places; > is commands only. + await page.keyboard.type("look"); + const row = palette(page).locator("[data-jump-item='cmd:look']"); + await expect(row).toBeVisible({ timeout: 30_000 }); + await expect(row).toContainText("umtool look"); + // A verb with no form is not offered. + await page.locator("[data-jump-input]").fill(">help"); + await expect(palette(page).locator("[data-jump-item='cmd:help']")).toHaveCount(0); + await page.locator("[data-jump-input]").fill(">teaser"); + await expect(palette(page).locator("[data-jump-item='cmd:timeline teaser']")).toBeVisible(); + await page.locator("[data-jump-input]").fill(">look"); + await expect(palette(page).locator("[role=option][aria-selected=true]")).toHaveAttribute("data-jump-item", "cmd:look"); + await page.keyboard.press("Enter"); + + const form = palette(page).locator("[data-cli-form='look']"); + await expect(form).toBeVisible(); + await expect(form.locator("[data-cli-arg='project'] input")).toHaveValue(PROJECT); + // Required settings missing: no line, no Run. + await expect(form.locator("[data-cli-invalid]")).toContainText("settings is required"); + await expect(form.locator("[data-cli-run]")).toBeDisabled(); + await form.locator("[data-cli-arg='settings'] textarea").fill("mode=basic"); + const line = `node umtool/bin/umtool.mjs look ${PROJECT} mode=basic`; + await expect(form.locator("[data-cli-line]")).toHaveText(line); + await form.locator("[data-cli-copy]").click(); + await expect(form.locator("[data-cli-copy]")).toHaveText("Copied"); + expect(await page.evaluate(() => navigator.clipboard.readText())).toBe(line); + const box = await palette(page).boundingBox(); + expect(box!.y + box!.height, "the form fits 1366×768").toBeLessThanOrEqual(768); + await shot(page, "palette-form"); + + expect(manifest().render.mode ?? "deck").not.toBe("basic"); + await form.locator("[data-cli-run]").click(); + await expect(form.locator("[data-cli-state]")).toHaveAttribute("data-cli-state", "done", { timeout: 90_000 }); + await expect(form.locator("[data-cli-log]")).toContainText(`look ${PROJECT} mode=basic`); + expect(manifest().render.mode).toBe("basic"); + await shot(page, "palette-run-done"); + + // Back to the list. + await form.locator("[data-cli-back]").click(); + await expect(palette(page).locator("[data-jump-input]")).toBeFocused(); +}); + +test("on a clip bench the clip is filled in; a refused value says why", async ({ page }) => { + test.setTimeout(120_000); + await page.setViewportSize({ width: 1366, height: 768 }); + await page.goto(urls.clipBenchHref(PROJECT, "c01")); + await open(page); + await page.keyboard.type(">window"); + await expect(palette(page).locator("[role=option][aria-selected=true]")).toHaveAttribute("data-jump-item", "cmd:window", { timeout: 30_000 }); + await page.keyboard.press("Enter"); + const form = palette(page).locator("[data-cli-form='window']"); + await expect(form.locator("[data-cli-arg='project'] input")).toHaveValue(PROJECT); + await expect(form.locator("[data-cli-arg='clip'] input")).toHaveValue("c01"); + await form.locator("[data-cli-arg='--title'] input").fill("A palette title"); + await expect(form.locator("[data-cli-line]")).toHaveText(`node umtool/bin/umtool.mjs window ${PROJECT} c01 --title 'A palette title'`); + await form.locator("[data-cli-arg='--start'] input").fill("soon"); + await expect(form.locator("[data-cli-invalid]")).toContainText("--start: a number"); + await shot(page, "palette-clip-form"); +}); + +test("POST /api/cli runs only registry form verbs, from this app's pages, with values its schema allows", async ({ page }) => { + test.setTimeout(120_000); + await page.goto(urls.homeHref()); + const origin = new URL(page.url()).origin; + const post = (data: unknown, headers: Record<string, string> = { origin }) => page.request.post("/api/cli", { data, headers }); + const said = async (r: Awaited<ReturnType<typeof post>>) => ((await r.json()) as { error?: string }).error ?? ""; + + // The list the palette is built from: forms only. + const list = (await (await page.request.get("/api/cli")).json()) as { verbs: Array<{ verb: string }> }; + const verbs = list.verbs.map((v) => v.verb); + expect(verbs).toContain("look"); + expect(verbs).toContain("timeline insert"); + expect(verbs).not.toContain("help"); + expect(verbs).not.toContain("queue add"); + expect(verbs).not.toContain("takes delete"); + + // A ui:"none" verb. + let r = await post({ verb: "queue add", values: {} }); + expect(r.status()).toBe(400); + expect(await said(r)).toContain("has no form"); + // A raw argv, in any spelling. + for (const body of [{ argv: ["look", PROJECT, "mode=basic"] }, { verb: "look", argv: ["--json"] }, { verb: "look", values: {}, cmd: "rm -rf /" }]) { + r = await post(body); + expect(r.status(), JSON.stringify(body)).toBe(400); + } + // A value its schema refuses, an arg it does not have, a project there is not. + r = await post({ verb: "look", values: { project: PROJECT, settings: "--unset render.rail" } }); + expect(r.status()).toBe(400); + r = await post({ verb: "look", values: { project: PROJECT, settings: "mode=basic", "--json": true } }); + expect(r.status()).toBe(400); + expect(await said(r)).toContain('takes no "--json"'); + r = await post({ verb: "show", values: { project: "reports/no-such-project" } }); + expect(r.status()).toBe(400); + expect(await said(r)).toContain("no project matches"); + // Not a page of this app: another site, and no page at all. + r = await post({ verb: "show", values: { project: PROJECT } }, { origin: "https://evil.example" }); + expect(r.status()).toBe(403); + r = await post({ verb: "show", values: { project: PROJECT } }, {}); + expect(r.status()).toBe(403); + expect(manifest().render.mode ?? "deck", "nothing refused wrote").not.toBe("basic"); + + // A read, as one job: its log is the command's output. + r = await post({ verb: "show", values: { project: PROJECT } }); + expect(r.status()).toBe(202); + const { job, line } = (await r.json()) as { job: { id: string }; line: string }; + expect(line).toBe(`node umtool/bin/umtool.mjs show ${PROJECT}`); + await expect + .poll(async () => ((await (await page.request.get(`/api/cli?job=${job.id}`)).json()) as { job: { state: string } }).job.state, { timeout: 60_000 }) + .toBe("done"); + const shown = (await (await page.request.get(`/api/cli?job=${job.id}`)).json()) as { job: { log: string[] } }; + expect(shown.job.log.join("\n")).toContain("The Basic Fixture"); + + // A verb that renders (or holds the heavy slot) is a step of the durable queue. + r = await post({ verb: "prep", values: { project: PROJECT, "--status": true } }); + expect(r.status()).toBe(202); + const { queued } = (await r.json()) as { queued: { qid: string } }; + expect(queued.qid).toMatch(/^q\d+$/); + await expect + .poll(async () => ((await (await page.request.get(`/api/cli?qid=${queued.qid}`)).json()) as { step: { state: string } }).step.state, { timeout: 90_000 }) + .toBe("done"); +}); diff --git a/umtool/lib/cli/docs.mjs b/umtool/lib/cli/docs.mjs @@ -90,7 +90,7 @@ export function withVerbsSection(text) { export const registryCommands = () => [...new Set(VERBS.map((r) => commandOf(r.verb)))]; if (process.argv[1] && fileURLToPath(import.meta.url) === process.argv[1]) { - const text = readFileSync(CLI_MD, "utf8"); + const text = readFileSync(/* turbopackIgnore: true */ CLI_MD, "utf8"); const next = withVerbsSection(text); if (process.argv.includes("--check")) { if (next !== text) { @@ -99,7 +99,7 @@ if (process.argv[1] && fileURLToPath(import.meta.url) === process.argv[1]) { } console.log("umtool/docs/cli.md is current"); } else if (next !== text) { - writeFileSync(CLI_MD, next); + writeFileSync(/* turbopackIgnore: true */ CLI_MD, next); console.log("umtool/docs/cli.md rewritten"); } else { console.log("umtool/docs/cli.md is current");