mirror of
https://github.com/shinyobjectz/raea.git
synced 2026-12-01 21:03:47 -10:00
The rules are raea/goal's (sdk/goal), run by `raea goal check` at four moments: the hook after a save, every render's end, raea cloud's publish, and the Stop hook. Rust's cut and goal gates and the box's word, sound, frame and place checks are packs (MK30-MK39); runtime/cut-plan, runtime/goal-plan, raea make status and the box's check code are gone with no alias (MK41). brief.ts is the one registered root (MK43): raea runs it, and every file that imports raea must be reached from it (the registered check, an error at publish and done). Its tasks are its `plan` (MK44), read from its run and written back where each is written by `raea goal tasks`, the one path for the app, agents and the box. Its `goal` is one goal or a workflow of several (MK46), each with its step, after and rules, checked and reported alone. Taste lines and signed asks run inside the loop (MK47). `raea goal check|tasks|seen|judge|gates|next` is the loop; `raea make clothes|motion|solid|wear|splat|physics|bake| sao|tokensynth|sounds|component|blockout|...` the asset tools (MK45). Old names are refused with where they went. docs/make.feature is docs/goal.feature; tools/legacy-names.sh holds the old names out. raea's Node mode on JavaScriptCore now gives a CommonJS package's names as named exports (React's jsx), loads a file a tool imports by URL, keeps process.exit's code from a promise callback, and reads stdin as fd 0, so the goal runner runs on the shipped binary.
57 lines
4.3 KiB
TypeScript
57 lines
4.3 KiB
TypeScript
// PL6: a plugin's keywords, properties, kinds and views (src/extend.ts, src/views.ts).
|
|
import { describe, expect, test } from "vitest"
|
|
import { checkPlan, createRegistry, defineKeywords, definePlanKind, defineProperty, defineView, view, type Task } from "../src"
|
|
import { applyEdits, readPlan } from "./text"
|
|
|
|
/** a plan.ts of these tasks */
|
|
const P = (tasks: string) => `export default plan({ tasks: [${tasks}] })`
|
|
|
|
describe("PL6: extending plans", () => {
|
|
test("a keyword sequence a plugin defines is read in any plan, with the states it gives", () => {
|
|
const reg = createRegistry()
|
|
defineKeywords({ name: "film", words: "SHOOT CUT GRADE | DELIVERED", states: { GRADE: "review" } }, reg)
|
|
const p = readPlan(P(`{ keyword: "SHOOT", title: "the steps" }, { keyword: "GRADE", title: "the steps" }, { keyword: "DELIVERED", title: "the trailer" }`), reg)
|
|
expect(p.tasks.map((t) => [t.keyword, t.state])).toEqual([
|
|
["SHOOT", "todo"],
|
|
["GRADE", "review"],
|
|
["DELIVERED", "done"],
|
|
])
|
|
// the default registry doesn't know them: a heading
|
|
expect(readPlan(P(`{ keyword: "SHOOT", title: "the steps" }`)).tasks).toEqual([])
|
|
expect(() => defineKeywords({ name: "bad", words: "to do | done" }, reg)).toThrow(/capitals/)
|
|
})
|
|
|
|
test("a kind names its sequence, the properties it needs and a check of its own; checkPlan says what's wrong", () => {
|
|
const reg = createRegistry()
|
|
defineKeywords({ name: "film", words: "SHOOT CUT | DELIVERED" }, reg)
|
|
defineProperty({ key: "shot", about: "the shot's number", check: (v) => (/^\d+$/.test(v) ? undefined : "a shot is a number") }, reg)
|
|
definePlanKind({ name: "shot", keywords: "film", props: ["SHOT"], check: (t: Task) => (t.deadline ? undefined : "a shot needs a deadline"), defaults: { tags: ["shot"] } }, reg)
|
|
const r = applyEdits("", [{ op: "add", id: "s1", title: "The steps, wide", kind: "shot", state: "SHOOT", props: { SHOT: "x" } }, { op: "add", id: "s2", title: "No kind", kind: "nope" }], { registry: reg })
|
|
expect(r.plan.tasks[0]).toMatchObject({ kind: "shot", keyword: "SHOOT", tags: ["shot"] })
|
|
// with no state, a task of a kind starts at its sequence's first word
|
|
const first = reg.sequences.get("film")!.words[0].word
|
|
expect(applyEdits("", [{ op: "add", title: "Another", kind: "shot" }], { registry: reg }).plan.tasks[0].keyword).toBe(first)
|
|
expect(checkPlan(r.plan, reg).map((d) => `${d.ref}: ${d.message}`)).toEqual(["s1: SHOT: a shot is a number", "s1: a shot needs a deadline", "s2: no kind nope is defined (shot)"])
|
|
const dup = readPlan(P(`{ id: "x", keyword: "TODO", title: "a" }, { id: "x", keyword: "TODO", title: "b" }`), reg)
|
|
expect(checkPlan(dup, reg)).toMatchObject([{ ref: "x", severity: "error" }])
|
|
expect(() => definePlanKind({ name: "take", keywords: "nope" }, reg)).toThrow(/defineKeywords it first/)
|
|
})
|
|
|
|
test("views: raea's board and agenda, and one a plugin adds", () => {
|
|
const reg = createRegistry()
|
|
const p = readPlan(
|
|
P(`{ keyword: "TODO", title: "a", deadline: "2026-11-13" }, { keyword: "MAKING", title: "b", scheduled: "2026-11-15" }, { keyword: "REVIEW", title: "c" },
|
|
{ keyword: "DONE", title: "d", deadline: "2026-11-14" }, { keyword: "DROPPED", title: "e" }, { keyword: "TODO", title: "f", tags: ["x"], props: { AGENT: "a-grade" } }`),
|
|
reg,
|
|
)
|
|
const lanes = view<{ state: string; tasks: Task[] }[]>(p, "board", undefined, reg)
|
|
expect(lanes.map((l) => `${l.state}:${l.tasks.map((t) => t.text).join("")}`)).toEqual(["todo:af", "making:b", "review:c", "done:d"])
|
|
const a = view<{ overdue: { task: Task }[]; days: { date: string; entries: { task: Task; why: string }[] }[] }, { from: string; days: number }>(p, "agenda", { from: "2026-11-14", days: 3 }, reg)
|
|
expect(a.overdue.map((e) => e.task.text)).toEqual(["a"])
|
|
expect(a.days.map((d) => `${d.date}:${d.entries.map((e) => `${e.task.text}/${e.why}`).join(",")}`)).toEqual(["2026-11-14:", "2026-11-15:b/scheduled", "2026-11-16:"])
|
|
defineView({ name: "by-agent", build: (plan) => Object.groupBy(plan.tasks.filter((t) => t.agents.length), (t) => t.agents[0]) }, reg)
|
|
expect(Object.keys(view<Record<string, Task[]>>(p, "by-agent", undefined, reg))).toEqual(["a-grade"])
|
|
expect(() => view(p, "nope", undefined, reg)).toThrow(/no plan view nope: board, agenda, outline, by-agent/)
|
|
})
|
|
})
|