mirror of
https://github.com/shinyobjectz/raea.git
synced 2026-12-01 12:44:11 -10:00
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.
131 lines
5.6 KiB
TypeScript
131 lines
5.6 KiB
TypeScript
// PL2 (docs/goal.feature MK40): a plan.ts read as data and written back (src/doc.ts, src/literal.ts, src/time.ts).
|
|
import { describe, expect, test } from "vitest"
|
|
import { checksOf, dayOf, formatStamp, linksIn, linkText, linkTo, parseStamp } from "../src"
|
|
import { planModule } from "../src/source.ts"
|
|
import { value } from "./text"
|
|
import { printValue, readValue } from "../src/literal.ts"
|
|
import { newPlan, readPlan } from "./text"
|
|
|
|
describe("the value in plan(...)", () => {
|
|
test("objects, arrays, strings of three quotes, numbers, booleans, null; bare and quoted keys; trailing commas; comments", () => {
|
|
const { value } = readValue(`{ a: 1, "b c": [true, false, null, -2.5e3,], 'd': 'it\\'s', e: \`two
|
|
lines\`, /* note */ f: { g: "\\u00e9" }, // end
|
|
}`)
|
|
expect(value).toEqual({ a: 1, "b c": [true, false, null, -2500], d: "it's", e: "two\nlines", f: { g: "é" } })
|
|
})
|
|
test("what isn't a value says where: code in a template, a missing comma, a string that never ends", () => {
|
|
expect(() => readValue("{ a: `${x}` }")).toThrow(/code, not a value/)
|
|
expect(() => readValue("{ a: 1 b: 2 }")).toThrow(/line 1, column 8: a comma or }/)
|
|
expect(() => readValue('{ a: "open }')).toThrow(/never ends|line break/)
|
|
})
|
|
test("written as TypeScript writes it, and read back the same", () => {
|
|
const v = { title: "Ides", tags: ["a", "b"], "odd key": { x: 1 }, tasks: [{ title: "x" }] }
|
|
const text = printValue(v)
|
|
expect(text).toBe('{\n title: "Ides",\n tags: ["a", "b"],\n "odd key": {\n x: 1,\n },\n tasks: [\n {\n title: "x",\n },\n ],\n}')
|
|
expect(readValue(text).value).toEqual(v)
|
|
})
|
|
})
|
|
|
|
describe("PL2a: a plan written back keeps everything", () => {
|
|
const PLAN = `import { plan } from "raea/task"
|
|
|
|
export default plan({
|
|
title: "The Ides of March",
|
|
keywords: ["TODO MAKING REVIEW | DONE DROPPED", "WAITING | GONE"],
|
|
tags: ["film"],
|
|
trackers: {
|
|
linear: {
|
|
"In Progress": "MAKING",
|
|
Done: "DONE",
|
|
},
|
|
},
|
|
notes: ["Some words before any task."],
|
|
tasks: [
|
|
{
|
|
title: "Act one",
|
|
tags: ["act_one"],
|
|
tasks: [
|
|
{
|
|
id: "t-cast",
|
|
keyword: "DONE",
|
|
priority: "A",
|
|
title: "Cast the narrator",
|
|
tags: ["score"],
|
|
deadline: "2026-11-01",
|
|
closed: "2026-11-02 10:14",
|
|
props: {
|
|
AGENT: "a-score",
|
|
CUSTOM_THING: "kept as written",
|
|
},
|
|
},
|
|
{
|
|
id: "t-rome",
|
|
keyword: "TODO",
|
|
title: "Rome storyboard with [the brief](item:i-brief)",
|
|
scheduled: "2026-11-20 10:00-11:00 +1w -2d",
|
|
notes: [
|
|
"- [X] the forum",
|
|
"- [ ] the steps",
|
|
" - [x] a nested one",
|
|
"- [-] the senate",
|
|
"",
|
|
"Prose under it.",
|
|
],
|
|
tasks: [
|
|
{
|
|
keyword: "WAITING",
|
|
title: "Deep",
|
|
},
|
|
],
|
|
},
|
|
],
|
|
},
|
|
],
|
|
})
|
|
`
|
|
test("a plan raea wrote prints back the same, byte for byte", () => {
|
|
expect(planModule(value(PLAN)!)).toBe(PLAN)
|
|
expect(planModule(value(newPlan("x"))!)).toBe(newPlan("x"))
|
|
})
|
|
test("every field reads as values", () => {
|
|
const p = readPlan(PLAN)
|
|
expect(p.problem).toBeUndefined()
|
|
expect(p.filetags).toEqual(["film"])
|
|
expect(p.words.get("WAITING")).toBe("todo")
|
|
const rome = p.entries.find((t) => t.id === "t-rome")!
|
|
expect(rome).toMatchObject({ text: "Rome storyboard with the brief", scheduled: { date: "2026-11-20", time: "10:00", end: "11:00", repeat: "+1w", warn: "-2d" }, inherited: ["film", "act_one"], progress: { done: 0, total: 1 } })
|
|
expect(rome.links).toEqual([{ target: "item:i-brief", desc: "the brief", type: "item", path: "i-brief" }])
|
|
expect(checksOf(rome.body.split("\n")).map((c) => [c.done, c.partial, c.indent, c.text])).toEqual([
|
|
[true, false, 0, "the forum"],
|
|
[false, false, 0, "the steps"],
|
|
[true, false, 2, "a nested one"],
|
|
[false, true, 0, "the senate"],
|
|
])
|
|
expect(p.entries.find((t) => t.id === "t-cast")).toMatchObject({ priority: "A", closed: { active: false, date: "2026-11-02", time: "10:14" }, props: { ID: "t-cast", AGENT: "a-score", CUSTOM_THING: "kept as written" } })
|
|
})
|
|
test("an empty file is an empty plan; a date that isn't one says so", () => {
|
|
expect(readPlan("").entries).toEqual([])
|
|
expect(readPlan(`export default plan({ tasks: [{ title: "x", deadline: "next week" }] })`).problem).toMatch(/deadline "next week" of "x"/)
|
|
})
|
|
})
|
|
|
|
describe("dates and links", () => {
|
|
test("read and written back; a day as a person writes it", () => {
|
|
for (const s of ["2026-11-14", "2026-11-14 16:40", "2026-11-14 10:00-11:30 .+1d --3d"]) expect(formatStamp(parseStamp(s)!)).toBe(s)
|
|
expect(parseStamp("<2026-11-14 Sat>")).toBeUndefined()
|
|
expect(dayOf("11-03", new Date(2026, 0, 1))).toEqual({ active: true, date: "2026-11-03" })
|
|
expect(dayOf("2026-11-03 09:30")).toMatchObject({ date: "2026-11-03", time: "09:30" })
|
|
expect(dayOf("2026-02-30")).toBeUndefined()
|
|
expect(dayOf("soon")).toBeUndefined()
|
|
})
|
|
test("links by type: a feed item, a task by id, a web page", () => {
|
|
expect(linksIn("Made [the trailer](item:i-hero), see [](id:t-cast) and [](https://raea.io)").map((l) => [l.type, l.path, l.desc])).toEqual([
|
|
["item", "i-hero", "the trailer"],
|
|
["id", "t-cast", undefined],
|
|
["https", "//raea.io", undefined],
|
|
])
|
|
expect(linkText("Grade [the trailer](item:i-hero) after [](id:t-1)")).toBe("Grade the trailer after t-1")
|
|
expect(linkTo("item:i-1", "the [cut]")).toBe("[the cut](item:i-1)")
|
|
})
|
|
})
|