Harness spec 1.1.0: one plan, prototypes and the library shared; the CLI implements it

The spec: plan_write and plan_update (new, shared, offered in every mode) and
plan_submit (now shared) keep one structured plan — findings, objectives,
phases of tasks — in place of the todo list, which lives on as a former name
of plan_write. The shared system text is one text for both projects, with
variables for what differs; the mode texts, a prototypes block and a library
block are shared. acp.md: the client hands the device what only it knows
(context, library, prototypes), the plan travels as a structure (plan_state),
library calls carry the chat's scope, and a client may rewind a session.
loop.json says its numbers as numbers. Four conformance areas: plan,
prototype, library_scope, toolcall_index.

The CLI: the plan is kept per session in the store and drawn above the prompt
and on the approval card; the prompt is assembled from the spec's texts with
their variables filled; the link reads the instance's instructions,
personalization, knowledge scope and prototype offer, sends the plan as a
structure and answers rewind; library calls to the instance carry the session
as scope; a prototype written in the terminal is saved as a file and named in
the transcript; a tool-call fragment without an index continues the last call;
the default theme is Moria; dead exports and Hermes leftovers removed.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
This commit is contained in:
HomerandClaude Fable 5.1 committed 2026-10-18 04:02:12 +02:00
1 parent 6e70ff46d0
commit 837f38c744
96 files changed
+3259 -527

No files matched your search

+35 -2
View File
@@ -8,6 +8,8 @@ import type { Store } from "./store.ts"
interface Turn {
prompt: string
/** Its id: the one it was given (the web UI's message id), or the one made here. */
turnId: string
/** engine.messages.length before the prompt. */
at: number
before?: string
@@ -56,8 +58,8 @@ export class Turns {
const before = this.snaps?.track()
this.base ??= before
const turnId = meta.turnId || crypto.randomUUID()
const turn: Turn = { prompt: text, at: this.engine.messages.length, before, firstRow: this.engine.lastRowId + 1, lastRow: 0 }
this.current = { ...turn, turnId }
const turn: Turn = { prompt: text, turnId, at: this.engine.messages.length, before, firstRow: this.engine.lastRowId + 1, lastRow: 0 }
this.current = { ...turn }
this.engine.o.bus.emit({ type: "task", state: "start", turnId })
try {
return await this.engine.prompt(text, extra, shown, { ...meta, turnId })
@@ -113,6 +115,37 @@ export class Turns {
return { prompt: u.turn.prompt, files }
}
/** `_lembas/session/rewind`: the turn `turnId` and every later one leave the conversation the
* model sees and the history — their rows re-kinded as /undo re-kinds a turn's, the messages
* dropped — and the files are left as they are (the client says so beside its control). The
* number of turns reverted, or undefined for a turn this session does not have. Not while a
* prompt runs: the caller checks. */
rewind(turnId: string): number | undefined {
const sessionId = this.engine.sessionId
const i = this.done.findIndex((t) => t.turnId === turnId)
if (i >= 0) {
const dropped = this.done.splice(i)
const first = dropped[0]!
const last = dropped[dropped.length - 1]!
this.engine.messages.splice(first.at)
if (this.store && sessionId && last.lastRow >= first.firstRow) this.store.setKind(sessionId, first.firstRow, last.lastRow, "reverted")
this.undone = []
return dropped.length
}
// A turn run before this process had the session (opened from the store): by its row. Every
// turn run here came after it, so they all go too.
if (!this.store || !sessionId) return undefined
const row = this.store.turnRow(sessionId, turnId)
if (row === undefined) return undefined
const count = this.store.turnsFrom(sessionId, row)
this.store.setKind(sessionId, row, Number.MAX_SAFE_INTEGER, "reverted")
const at = this.engine.messages.findIndex((m) => m.role === "user" && m.turnId === turnId)
if (at >= 0) this.engine.messages.splice(at)
this.done = []
this.undone = []
return count
}
/** Everything changed since the session's first prompt, as a unified diff. */
diff(): string | undefined {
if (!this.snaps || !this.base) return undefined