Skip to content

armgit / raea

Public Imported from GitHub
0

Render Anything Engine: tell your AI what to make. Videos, motion graphics, 3D and games as React and TypeScript, rendered on your own GPU. Rust + Bevy, macOS, Linux and Windows.

PL7: an agent finishes what it planned. A task marked done with a checkbox unticked or a subtask open is refused by the plan tools (plan_close, plan_update's state), naming each by place or id, as Org's org-enforce-todo-dependencies refuses; plan_close's all: true ticks them and closes the subtasks with it, and ticked in the same call it closes. Shane 11-16: "i notice often that it makes tasks but never completes them itself": v0.1.5's agent closed five tasks with every box unticked, so the list read 0/4 on finished work. docs/plan.feature PL7 says the rest, which is the app's (raea-feed plan-finish: raea asks an agent to settle its own open tasks each time it stops).

shinyobjectz32dcec11b91c
diff --git a/docs/plan.feature b/docs/plan.feature
index 122c18d0..d8099ae8 100644
--- a/docs/plan.feature
+++ b/docs/plan.feature
@@ -25,12 +25,15 @@ Feature: Plans: a project's plan.org, kept by its agents
# (Rust, engine/cli), so reference/files.md, generated from it, doesn't list one; the page makes it on the first
# write. The brief page (BriefView, unmounted) still draws a brief's own ## Tasks. Compositions can't import
# @raea/task until sdk/tsconfig.base.json and raea's bundler map it.
+ # 11-16: PL7, agents finish what they plan (raea-feed plan-finish: plan/keeper.ts, PlanKeeper.tsx; sdk/task tools.ts).
+ # Checked in raea's window: e2e chat-plan 2 of 2 with a real ACP stand-in planning through the tool port, and
+ # chat-goal, respawn, todo, outside, heads, primary, consolidate, ai-login unchanged; vitest 1621; sdk/task 33.
Background:
Given the app's code is apps/app (raea-feed), the SDK sdk/task, the skill skills/raea/plan.md in raea-skills
And the plan's tests: sdk/task/test/*.test.ts (PL2, PL3, PL5, PL6), apps/app src/plan/plan.test.ts (PL1c, PL4, PL4c,
PL5), src/plan/agent.test.ts (PL5a, PL5b), host/plan.test.ts (PL4, PL5), src/feed/todo.test.ts and outside.test.ts
- (PL4b), e2e/todo.spec.ts (PL4b)
+ (PL4b), e2e/todo.spec.ts (PL4b), apps/app src/plan/keeper.test.ts and e2e/chat-plan.spec.ts (PL7)
Rule: PL1. A project's plan is plan.org at the top of its folder
# Why there: it's the project's own file, versioned with it in the workspace's repo, found by anyone who opens the
@@ -198,3 +201,60 @@ Feature: Plans: a project's plan.org, kept by its agents
Then usePlan(text or source) gives the plan, its text and edit; useView a registered view; TaskLine, PlanOutline,
Agenda and BoardLanes draw them, with toggled for a checkbox's edit
And none of it uses a dynamic import or dangerouslySetInnerHTML, so raea's window bundle (one IIFE) holds it
+
+ Rule: PL7. An agent finishes what it planned
+ # Shane, 2026-11-16: "i notice often that it makes tasks but never completes them itself". His plans that morning:
+ # TarotChess's agent posted a first pass and left its own follow-ups TODO (frame rate, a clipping score, a dark
+ # encode); Cadence's said "all six masters are finished and posted" over a plan still saying Track MAKING and Build,
+ # Render and Masters TODO (it had woken itself on a render's report, a turn raea sends no plan with); v0.1.5's
+ # closed five tasks with every checkbox unticked, so the list read 0/4 on finished work; and its last turn ended
+ # with Film v2's tasks MAKING, "waiting on three helpers", when the session stopped under them. Nothing asked any
+ # of them to go on: only a /goal does that, and only when the person sets one.
+
+ @done
+ Scenario: PL7a. Each time an agent stops with tasks of its own open, raea asks it to settle them
+ Given a chat in a project whose agent's turn ends (apps/app src/plan/PlanKeeper.tsx, beside GoalKeeper)
+ And tasks of its own are TODO or MAKING in the plan, read from the file first
+ Then raea's next turn to it lists them by id ("[raea plan] Ask N: ...") and says how each is settled: closed with
+ the item it made, done now and closed, REVIEW saying what it needs from the person, dropped with why, or a
+ line starting "WAITING:" naming the job of its own that will report back
+ And it asks again each time the agent stops while one is TODO or MAKING; REVIEW is the person's, and ends it
+ And the rule each turn carries says the same: finish what you planned; before you stop, every task of yours is
+ closed, REVIEW or waiting on a job; close what a job finished when it reports back in a turn you started
+
+ @done
+ Scenario: PL7b. The asks stop
+ Then they stop when none of its tasks is TODO or MAKING, or pause, saying why, when the person presses Stop, its
+ session closes or the turn fails, its reply has a WAITING: line, two asks in a row leave the plan as it was, or
+ 12 have gone since the person's last message
+ And the person's next message starts them again from nothing, and Continue over the composer asks at once
+ And a chat with an open /goal is the goal's: its checks keep it going, and the plan's asks wait until it's met
+
+ @done
+ Scenario: PL7c. Which tasks are the agent's
+ Then a task is the chat's when its agent (or the chat) holds it; or nobody holds it and it stands on an item the
+ chat posted (its :ITEM:, or a note's item in its :FROM:: an agent writing plan.org by hand leaves :AGENT: out);
+ or nobody holds it and it's MAKING while no other agent holds open work
+ And a task nobody holds otherwise is the person's (written in the to-do list or Emacs, moved from a brief): never
+ pushed on whoever is chatting; one SCHEDULED for a later day waits for that day
+
+ @done
+ Scenario: PL7d. Done means its checkboxes and subtasks are done
+ When an agent marks a task done (plan_close, or plan_update's state) while a checkbox under it is unticked or a
+ subtask open, as Org's org-enforce-todo-dependencies refuses
+ Then the tool refuses, naming each by its place or id, and nothing is written
+ And plan_close with all: true ticks them and closes the subtasks with it; ticked in the same call, it closes
+ And dropped closes whatever is under it as it is; the person's own check-off in the to-do list isn't refused
+
+ @done
+ Scenario: PL7e. A post names what's still open
+ Given an agent's feed_post in a project
+ Then its answer carries the agent's open tasks and asks it to close what the post finished, with the item, so a
+ turn the agent started itself (a job reporting back carries no plan) still closes them
+
+ @done
+ Scenario: PL7f. Seen in the chat
+ Then each ask is a small line of its own ("Finishing the plan (2): 3 open"), never the marker in the person's words
+ And over the composer, while it asks or after it pauses with tasks open, one line: "Plan 3 of its tasks open",
+ "Finishing · ask 2" with × to stop asking until the next message, or "Paused · Continue" with why on hover
+
diff --git a/sdk/task/src/tools.ts b/sdk/task/src/tools.ts
index 097bcd1b..380a7c54 100644
--- a/sdk/task/src/tools.ts
+++ b/sdk/task/src/tools.ts
@@ -3,8 +3,8 @@
// and how to make edits on it, and these turn a tool's input into plan edits (edit.ts) and its answer into the open
// tasks with their ids. The app's page answers them through its plans, a headless run on the folder's plan.org.
import { planDigest } from "./digest.ts"
-import type { PlanEdit, TaskFields } from "./edit.ts"
-import { isClosed, readPlan } from "./model.ts"
+import { applyEdits, type PlanEdit, type TaskFields } from "./edit.ts"
+import { find, isClosed, readPlan, type Plan, type State, type Task } from "./model.ts"
export const PLAN_TOOLS = ["plan_read", "plan_add", "plan_update", "plan_close"] as const
export type PlanTool = (typeof PLAN_TOOLS)[number]
@@ -82,6 +82,54 @@ export function planToolEdits(tool: Exclude<PlanTool, "plan_read">, input: Recor
})
}
+/** The state a keyword or state name means in this plan. */
+const meant = (plan: Plan, state: string): State | undefined => plan.words.get(state) ?? plan.words.get(state.toUpperCase()) ?? (state.toLowerCase() as State)
+
+/** A task and what is still open under it: its unticked checkboxes, by place, and every open task below it. */
+function openUnder(plan: Plan, t: Task): { boxes: number[]; tasks: Task[] } {
+ const tasks: Task[] = []
+ const walk = (ref: string) => {
+ for (const r of find(plan, ref)?.children ?? []) {
+ const k = find(plan, r)
+ if (k?.state && !isClosed(k.state)) tasks.push(k)
+ if (k) walk(k.ref)
+ }
+ }
+ walk(t.ref)
+ return { boxes: t.checks.flatMap((c, i) => (c.done ? [] : [i])), tasks }
+}
+
+const quoted = (s: string) => `"${s.length > 40 ? `${s.slice(0, 39)}…` : s}"`
+
+/** The tasks a call marks done while work under them is still open (Org's org-enforce-todo-dependencies and its
+ * checkbox twin: a DONE that still shows [0/4] says the work isn't done). Each is refused, naming what's open, unless
+ * `all` says every one of them is done: then they are ticked and closed with it, after the call's own edits. */
+function closesOpen(text: string, edits: PlanEdit[], all: boolean, tool: PlanTool): PlanEdit[] {
+ const before = readPlan(text)
+ const done = edits.flatMap((e, i) => (e.op === "state" && meant(before, e.state) === "done" && meant(before, find(before, e.ref)?.keyword ?? "") !== "done" ? [i] : []))
+ if (!done.length) return []
+ const dry = applyEdits(text, edits)
+ const fix: PlanEdit[] = []
+ for (const i of done) {
+ const t = find(dry.plan, dry.refs[i])
+ if (!t) continue
+ const left = openUnder(dry.plan, t)
+ if (!left.boxes.length && !left.tasks.length) continue
+ if (!all) {
+ const parts = [
+ ...(left.boxes.length ? [`${left.boxes.length} unticked checkbox${left.boxes.length > 1 ? "es" : ""} (${left.boxes.map((b) => `${b} ${quoted(t.checks[b].text)}`).join(", ")})`] : []),
+ ...(left.tasks.length ? [`${left.tasks.length} open subtask${left.tasks.length > 1 ? "s" : ""} (${left.tasks.map((k) => `${k.ref} ${quoted(k.text)}`).join(", ")})`] : []),
+ ]
+ const how = tool === "plan_close" ? "or close it with all: true when every one is done" : "or close it with plan_close and all: true when every one is done"
+ throw new Error(`${t.ref} still has ${parts.join(" and ")}: tick what's done (plan_update check), close or move what's left, ${how}`)
+ }
+ const state = (edits[i] as Extract<PlanEdit, { op: "state" }>).state
+ for (const k of [t, ...left.tasks]) for (const b of openUnder(dry.plan, k).boxes) fix.push({ op: "check", ref: k.ref, index: b, done: true })
+ for (const k of left.tasks) fix.push({ op: "state", ref: k.ref, state })
+ }
+ return fix
+}
+
/** A tool answered: plan_read gives the open tasks by id (and the whole text with full), giving any task without an id
* one first; an edit gives the ids it touched and the open tasks after it. */
export async function answerPlanTool(tool: PlanTool, input: Record<string, unknown>, h: PlanToolHost): Promise<unknown> {
@@ -97,6 +145,11 @@ export async function answerPlanTool(tool: PlanTool, input: Record<string, unkno
const close = edits[0]
if (tool === "plan_close" && close.op === "state" && !/^(done|dropped)$/i.test(close.state) && !isClosed(readPlan(h.text()).words.get(close.state)))
throw new Error(`state: done or dropped, or a closing keyword of the plan's; ${close.state} doesn't close (plan_update sets it)`)
- const r = await h.apply(edits)
+ // a task marked done with work still open under it: every task named by id first, so the ids a dry run reads are the
+ // ones the file keeps
+ let text = h.text()
+ if (edits.some((e) => e.op === "state") && readPlan(text).tasks.some((t) => !t.id)) text = (await h.apply([])).text
+ const fix = closesOpen(text, edits, tool === "plan_close" && input.all === true, tool)
+ const r = await h.apply([...edits, ...fix])
return { file, ids: [...new Set(r.refs.filter(Boolean))], open: planDigest(readPlan(r.text)) }
}
diff --git a/sdk/task/test/tools.test.ts b/sdk/task/test/tools.test.ts
index 9f501c09..8e829e62 100644
--- a/sdk/task/test/tools.test.ts
+++ b/sdk/task/test/tools.test.ts
@@ -61,7 +61,7 @@ describe("an agent's plan tools", () => {
test("plan_close closes with CLOSED, the item it made and a note; dropped keeps the task", async () => {
const h = host()
- await answerPlanTool("plan_close", { id: "t-door", item: "i-door-3", note: "Warm key at 3200K." }, h)
+ await answerPlanTool("plan_close", { id: "t-door", item: "i-door-3", note: "Warm key at 3200K.", all: true }, h)
expect(h.now()).toContain("** DONE Light the door\nCLOSED: [2026-11-14 Sat 16:40]")
expect(h.now()).toContain(":ITEM: i-door-3")
expect(h.now()).toContain("Warm key at 3200K.")
@@ -88,4 +88,28 @@ describe("an agent's plan tools", () => {
expect(r.open).not.toMatch(/#\d/)
expect(h.now()).toContain("** TODO Written in Emacs\n:PROPERTIES:\n:ID: t-new1\n:END:\n")
})
+
+ test("done with its checkboxes unticked or a subtask open is refused, naming them; all: true ticks and closes them with it", async () => {
+ const h = host()
+ await expect(answerPlanTool("plan_close", { id: "t-door" }, h)).rejects.toThrow(/t-door still has 2 unticked checkboxes \(0 "warm key", 1 "cool fill"\): tick what's done \(plan_update check\), close or move what's left, or close it with all: true/)
+ await expect(answerPlanTool("plan_update", { changes: [{ id: "t-door", state: "done" }] }, h)).rejects.toThrow(/or close it with plan_close and all: true/)
+ expect(h.now()).toBe(START)
+ // ticked in the same call, in either order, it closes
+ await answerPlanTool("plan_update", { changes: [{ id: "t-door", check: 0 }, { id: "t-door", check: 1, state: "done" }] }, h)
+ expect(find(readPlan(h.now()), "t-door")).toMatchObject({ state: "done", progress: { done: 2, total: 2 } })
+ // dropped leaves what's open as it was
+ const d = host()
+ await answerPlanTool("plan_close", { id: "t-door", state: "dropped" }, d)
+ expect(find(readPlan(d.now()), "t-door")!.progress).toEqual({ done: 0, total: 2 })
+ // an open subtask, and its own checkbox, the same
+ const sub = host(`${START}*** TODO Rim light\n:PROPERTIES:\n:ID: t-rim\n:END:\n- [ ] gel\n`)
+ await expect(answerPlanTool("plan_close", { id: "t-door", all: false }, sub)).rejects.toThrow(/2 unticked checkboxes .* and 1 open subtask \(t-rim "Rim light"\)/)
+ await answerPlanTool("plan_close", { id: "t-door", all: true }, sub)
+ const p = readPlan(sub.now())
+ expect([find(p, "t-door")!.state, find(p, "t-rim")!.state, find(p, "t-rim")!.checks[0].done, find(p, "t-door")!.checks.every((c) => c.done)]).toEqual(["done", "done", true, true])
+ // a task already done isn't asked again (a note added to it, say)
+ const was = host(START.replace("** TODO", "** DONE"))
+ await answerPlanTool("plan_close", { id: "t-door", note: "Kept." }, was)
+ expect(was.now()).toContain("Kept.")
+ })
})