Files
raea/sdk/task/test/text.ts
shane d873402ac5 raea goal is the loop, raea make the asset tools (#269)
One loop, raea goal: every rule in TypeScript, held at edit, render, publish and done (goal check, tasks, judge, seen, gates, next); the brief's contract is goal: (one goal or a list, a workflow inline), and its plan is plan:. raea make is making a finished asset: character, clothes, motion, solid, wear, splat, physics, bake, sounds, component, the kit pipeline and shots. Instruments (check, judge, ask, world, scene faults, light check) stay top-level. With it: the montage pack (MK48-MK51), JavaScriptCore fixes raea goal needs (CommonJS named exports, reserved words too, dynamic import of file URLs, process.exit from a promise, stdin for -), raea-cli-goal and raea-cli-refused split out of raea-cli, and skills at raea-skills 105aede.
2026-11-29 18:43:09 -08:00

32 lines
1.3 KiB
TypeScript

// Test fixtures are written as a plan.ts's text: value() reads the literal (as source.ts finds it), and these wrap the
// value API so a test can say what a plan is and what it becomes in the words a person would write.
import type { PlanFile } from "../src/doc.ts"
import * as edit from "../src/edit.ts"
import type { PlanRegistry } from "../src/extend.ts"
import { readValue } from "../src/literal.ts"
import * as model from "../src/model.ts"
import { planModule } from "../src/source.ts"
/** the value plan({...}) writes in a plan.ts's text; none for an empty text */
export function value(text: string): PlanFile | undefined {
if (!text.trim()) return undefined
const m = /\bplan\s*\(/.exec(text)
if (!m) throw new Error("no plan({...})")
return readValue(text, m.index + m[0].length).value as unknown as PlanFile
}
export function readPlan(text: string, reg?: PlanRegistry): model.Plan {
try {
return model.readPlan(value(text), reg)
} catch (e) {
return { ...model.readPlan(undefined, reg), problem: (e as Error).message }
}
}
export function applyEdits(text: string, edits: readonly edit.PlanEdit[], o?: edit.ApplyOptions) {
const r = edit.applyEdits(value(text), edits, o)
return { ...r, text: planModule(r.file) }
}
export const newPlan = (title: string, keywords?: string) => planModule(edit.newPlan(title, keywords))