From d57ede8a0c8107c471589aeb2365db0915c25171 Mon Sep 17 00:00:00 2001
From: SitgesRun <169425442+SitgesRun@users.noreply.github.com>
Date: Sun, 15 Nov 2026 16:49:08 -0800
Subject: [PATCH] One editable text per card: every prompt is composed when
drawn, a keyframe's, storyboard's or take's prompt.md is an override the
agent writes and "Use the automatic prompt" removes, and Use brings a folder
back as it was
The person's rule (A4): every card has one editable text, the person and Pine
Computer write it as equals, and nothing rewrites it as a side effect.
- An asset card edits its description only. Its Full prompt shows, read only,
the prompt its last draw sent (the receipt's prompt_sent), or "Composed when
drawn". The Studio's prompt editing is deleted: the 'prompt' card action, the
composer's prompt editor and CanvasPrompt.
- A keyframe, storyboard or take may have prompt.md, an override that drama-cli
sends as written. The card says "Its own prompt is used" and offers "Use the
automatic prompt", a new 'automatic' action that removes it. Generate no
longer needs a text. prompt.md is read only on those cards (PROMPT_CARDS).
- Use restores the object's own folder as of the result: its files then, the
files it did not hold then removed, object.json current with that result's
shown_file and, on a keyframe, storyboard or take, its
objects_sent_by_draw_request, which its prompt's Image N names.
readChangeOfObject is replaced by filesOfObjectAt.
- The major-1 conversion, which every project of a released Studio goes
through, writes the rule's shape: stored prompts are dropped (prompts/
folders and choices.json prompts; the backup keeps them), and a character's
look and a prop's text join description.md after the person's pending text,
in drama-cli's bytes (entries.prose). Its extract_json_field_to_markdown
operation is deleted.
- Major 2 was never released, so no project needs a one-time cleanup; a major-2
test project made before this keeps its stray prompt.md files, which
drama-cli ignores on description cards.
- doc/protocol.md 2.2, 3 and 5, doc/quick-start.md.
Signed-off-by: SitgesRun <169425442+SitgesRun@users.noreply.github.com>
---
doc/protocol.md | 12 ++-
doc/quick-start.md | 5 +-
extensions/pine-drama/canvas/canvas.tsx | 47 ++++++-----
extensions/pine-drama/canvas/seg.tsx | 8 +-
.../v2/major1-to-major2-conversion.json | 22 ++---
.../pine-drama/src/core/canvasProtocol.ts | 10 +--
.../src/core/convertMajor1ProjectToMajor2.ts | 32 +++++--
.../pine-drama/src/core/entryActions.ts | 40 +++++----
.../pine-drama/src/core/galleryProtocol.ts | 10 +--
extensions/pine-drama/src/core/major1.ts | 1 -
extensions/pine-drama/src/core/project.ts | 7 +-
.../pine-drama/src/core/projectHistory.ts | 22 ++---
extensions/pine-drama/src/core/protocol.ts | 4 +
extensions/pine-drama/src/core/segEditor.ts | 2 +-
.../pine-drama/src/core/segEditorProtocol.ts | 2 +-
extensions/pine-drama/src/episodeCanvas.ts | 6 +-
.../test/convertMajor1ProjectToMajor2.test.ts | 28 +++++--
.../pine-drama/src/test/entryActions.test.ts | 41 ++++++++-
.../pine-drama/src/test/project.test.ts | 2 +-
extensions/pine-drama/src/test/renderSmoke.ts | 83 +++++++------------
20 files changed, 211 insertions(+), 173 deletions(-)
diff --git a/doc/protocol.md b/doc/protocol.md
index 8a9a91b..bb73e95 100644
--- a/doc/protocol.md
+++ b/doc/protocol.md
@@ -82,7 +82,10 @@ An object is a folder holding **`object.json`** (`$defs/object`):
- **Pine Computer changes an object only in a turn that works on that object.** It plans, draws or rewrites that object itself: never as a side effect of another object changing, and never when it reads one. So a field the person set (`objects_sent_by_draw_request`, `relations`, `variant_of`, the text files) stays as they set it until they, or a turn that works on that object, change it. History keeps both.
- **References that no longer resolve.** A listed object may be deleted later, and a reference may point back at its own object, directly or through others. Both are allowed in the data. A draw sends the shown files of the listed objects that exist, in order, and Pine Computer tells the person each one it could not send (4.4). It refuses nothing. A draw sends files, not a graph, so a cycle sends each file once, as listed.
- **Who creates objects.** Either side may create an object. The client creates one when the person adds it, with `object.json` and the person's `description.md`. drama-cli derives every name a model reads from `name`, never from the id.
-- **The person's text.** In an object's folder, `description.md` and `prompt.md`, when present, are the text the person and Pine Computer edit. Whoever writes last wins, and git keeps the earlier text.
+- **One editable text per object.** The person and Pine Computer are equal writers of it: whoever writes last wins, and git keeps the earlier text. No side rewrites it as a side effect of drawing.
+ - A `character`, `scene`, `prop` or `variant` has `description.md`. Its draw composes the prompt from it, so it has no `prompt.md`; the prompt a draw sent is in its receipt (`prompt_sent`, 2.3). A character's outfit and a prop's printed words are part of the description (`Outfit: …`; `It shows the words "…".`). `entry.json` beside it keeps the asset's other story facts, which drama-cli reads and no card edits.
+ - A `character_face`, `scene_floor_plan` or `scene_view` has neither: it is drawn from its owner's description, and the variant's change for a variant's view.
+ - A `keyframe`, `storyboard` or `take` has `prompt.md` only as an override, which its draw sends as written. Without one, the draw composes the prompt. Removing it ("Use the automatic prompt") returns to that.
- **Removal.** Removing an object deletes its folder; a variant is a folder below its asset's, so it goes with it.
### 2.3 Receipts
@@ -113,7 +116,7 @@ Pine Computer keeps its own records of the drama in **`pine-computer-records/`**
- an `object.json` field (`objects_sent_by_draw_request`, `relations`, `variant_of`, `name`);
- adding an object, which writes its folder with `object.json` and `description.md`;
- removing an object, which deletes its folder;
- - `description.md` or `prompt.md`;
+ - `description.md`, or the `prompt.md` of a keyframe, storyboard or take, or its removal (2.2);
- the person's own picture or video, below.
- **Canvas positions** and every other view state are the client's own, per person or per profile, and are never written into the drama.
- **Hand changes** (a folder client): a file changed outside the client is recorded as `client-found-changes-on-disk` at the next opening, before the next turn, or at a running turn's next collection (4.3).
@@ -188,7 +191,10 @@ A turn ends as Pine reports it ([agent turns](https://console.pinecomputer.io/do
## 5. What the client shows
- **The cards** show what the client holds: each object's `object.json`, its `shown_file` and its receipts. A file's history is every earlier content of it (2.1; in git, `git log` of the path).
-- **"Use" on a past result** restores the files that result's change wrote inside the object's own folder, receipts with them, as a `person` change. That is the change's commit in git; for a turn's, the commit of the collection that landed it, which carries the turn's `Pine-Turn-Id`. Files of a variant or any other object folded inside it are not included, since each is an object of its own. Files the same change wrote for other objects stay as they are. The rule is the same whoever made the change: a turn, the person, or `client-found-changes-on-disk`, which may hold the whole project. The restored result's file is the shown one again: `object.json` `shown_file` names it, and a current shown file of another name is deleted with its receipt in the same change, as for the person's own picture (3). Use restores only the files that result's change wrote: a file a later result added beside them, such as a take's last frame, stays.
+- **"Use" on a past result** brings the object's own folder back as it was at that result, as a `person` change: the result is the commit that first wrote that shown file (in git; for a turn's, the commit of the collection that landed it, which carries the turn's `Pine-Turn-Id`).
+ - Every file of the folder then comes back, receipts with them, `description.md` and `entry.json` too, and a file the folder holds now but did not then is deleted.
+ - `object.json` stays the current one, with that result's `shown_file`. On a keyframe, storyboard or take, that result's `objects_sent_by_draw_request` comes back too, since its `prompt.md` names its images by that list; its `prompt.md` follows the folder, present or absent.
+ - Files of a variant or any other object folded inside it are not included, since each is an object of its own, and nothing outside the folder changes. The rule is the same whoever made the result: a turn, the person, or `client-found-changes-on-disk`.
## 6. Majors and upgrades
diff --git a/doc/quick-start.md b/doc/quick-start.md
index 10cf0dc..92490b0 100644
--- a/doc/quick-start.md
+++ b/doc/quick-start.md
@@ -42,7 +42,7 @@ Your reply is the go: nothing at a stop asks you to approve item by item.
| Stop | You look at | Your choice |
|---|---|---|
-| 1 | The planned asset cards, each with its prompt | Add, remove or change an asset, in one sentence |
+| 1 | The planned asset cards, each with its description | Add, remove or change an asset, in one sentence |
| 2 | The drawn assets, with what the agent found | The leads' looks |
| 3 | The episode's shot list and its planned cards | Revise it, or go |
| 4 | Storyboards, keyframes, video prompts, and the estimated video cost | Shoot everything, or hold some back |
@@ -55,7 +55,7 @@ The agent also stops for a red line in the screenplay, and for a screenplay it r
| Place | What's there | What you do |
|---|---|---|
| **Right: Chat** | The agent | Ask, answer, say go, press Stop |
-| **Center: canvas** | One canvas for the assets, one per episode | Edit a card's prompt, drop your picture on it, click an old version and press **Use** |
+| **Center: canvas** | One canvas for the assets, one per episode | Edit a card's description (an episode card: its prompt), drop your picture on it, click an old version and press **Use** |
| **Center: galleries** | Characters, places, props | **Create New**; click a card to see it on the canvas |
| **Center: seg editor** | An episode's segments and takes | Play takes; **Generate** writes the request into the Chat for you to send |
| **Left: Production** | The project and each object's versions | Look and open only |
@@ -95,7 +95,6 @@ How and why: [architecture](architecture.md).
| You answer hours after a question | The Computer may have stopped | Send your answer; the agent starts again from your folder |
| The Chat is dead after Stop | Known bug | Run **Developer: Reload Window** |
| A card you made with Create New can't be drawn | Its name has a space, dash or accent (known bug) | Use a name in plain letters a–z, or ask the agent to add it |
-| The redraw ignored your new description | A card is drawn from its prompt | Edit the card's prompt, or tell the agent what to change |
| A turn failed | What it made still lands; Pine gives the reason | Ask the agent to go on |
## 6. FAQ
diff --git a/extensions/pine-drama/canvas/canvas.tsx b/extensions/pine-drama/canvas/canvas.tsx
index 460a07e..93bca31 100644
--- a/extensions/pine-drama/canvas/canvas.tsx
+++ b/extensions/pine-drama/canvas/canvas.tsx
@@ -283,15 +283,14 @@ const notYet = 'Not available yet';
/**
* The composer: one floating dialog under the picked card, the same on both canvases (the person's design). A top row
- * (Upload, + Variant, Reference, Style, Full prompt), the references, the text specific to this picture, and a bottom
- * bar (model, settings, Generate). An asset's text is its description, its full prompt one click away; an episode
- * card's is its prompt, the only text it has; a storyboard has none. The text is for the next draw, so a picture the
- * person uploaded keeps it; how the picture on the card was made (its receipt; none for an upload) is behind "How it
- * was made". The model and settings are greyed, as the Computer cannot take a choice yet.
+ * (Upload, + Variant, Reference, Style, Full prompt), the references, an asset's one editable text, its description,
+ * and a bottom bar (model, settings, Generate). Its full prompt, the one its last draw sent, is read only; a keyframe's,
+ * a storyboard's or a take's own prompt can only be removed here (doc/protocol.md 2.2). How the picture on the card was
+ * made (its receipt) is behind "How it was made". The model and settings are greyed, as the Computer cannot take a choice yet.
*/
function Composer({ card, reply, onGo, onClose }: { card: CanvasCard; reply: DetailMessage | undefined; onGo: (stageId: string) => void; onClose: () => void }) {
const record = reply?.record ?? null;
- const prompt = reply?.prompt ?? null;
+ const ownPrompt = reply?.ownPrompt ?? null;
const [draft, setDraft] = useState<{ name: string; text: string } | null>(null);
const [full, setFull] = useState(false);
const [outcome, setOutcome] = useState<{ key: string; busy: boolean; error: string | null; unchanged: string | null } | null>(null);
@@ -311,16 +310,12 @@ function Composer({ card, reply, onGo, onClose }: { card: CanvasCard; reply: Det
};
const description = useTextEdit(`describe:${card.id}`, record?.description ?? null, busy, act,
text => ({ action: 'describe', object: card.id, description: record?.description ?? '', text }));
- const promptEdit = useTextEdit(`prompt:${card.id}`, prompt?.text ?? null, busy, act, text => ({ action: 'prompt', object: prompt?.object ?? card.id, text }));
- // The picture shown is the person's own upload: it was made from no prompt.
- // An asset's own text is its description, its full prompt behind Full prompt; an episode card's is its prompt, the only
- // text it has (the person's decision). One text is edited at a time, so Save and Generate act on the one shown.
- const main = record ? (full ? promptEdit : description) : prompt?.text != null ? promptEdit : null;
+ const fullPrompt = reply?.detail?.prompt ?? 'Composed when drawn';
// What its next draw sends, Image 1..N: the one list the draw builds its request from (objects_sent_by_draw_request).
const references = reply?.nextDraw ?? [];
const generate = () => {
- if (!main || main.blank) { return; }
- if (main.save()) { generateOnceSaved.set(main.key, card.id); } else { post({ v: CANVAS_PROTOCOL, type: 'generate', stageId: card.id }); }
+ if (record && description.blank) { return; }
+ if (record && description.save()) { generateOnceSaved.set(description.key, card.id); } else { post({ v: CANVAS_PROTOCOL, type: 'generate', stageId: card.id }); }
};
const addVariant = () => record && draft && draft.name.trim() && draft.text.trim() && !busy
&& act({ key: `variant:${card.id}`, request: { action: 'add', type: 'variant', from: card.id, name: draft.name.trim(), text: draft.text.trim() } });
@@ -338,8 +333,8 @@ function Composer({ card, reply, onGo, onClose }: { card: CanvasCard; reply: Det
{card.segment && }
- {record && prompt?.text != null && }
+ {record && }
{references.length > 0 && (
@@ -350,13 +345,22 @@ function Composer({ card, reply, onGo, onClose }: { card: CanvasCard; reply: Det
{reply?.picture && }
{!reply &&
)}
{reply?.detail && (
@@ -388,9 +392,8 @@ function Composer({ card, reply, onGo, onClose }: { card: CanvasCard; reply: Det
- {/* Generate draws from the text shown, so a card with none (a storyboard, a cut) offers none. */}
- {main && (
-
diff --git a/extensions/pine-drama/canvas/seg.tsx b/extensions/pine-drama/canvas/seg.tsx
index ac058f0..87b6870 100644
--- a/extensions/pine-drama/canvas/seg.tsx
+++ b/extensions/pine-drama/canvas/seg.tsx
@@ -90,22 +90,22 @@ function Thumb({ poster, icon }: { poster: Poster | null; icon: string }) {
);
}
-/** A seg's prompt (section 12c; Pippit's clip view; 760.png). Read-only. */
+/** A seg's own prompt (section 12c; Pippit's clip view; 760.png). Read-only here; the canvas edits it. */
function PlannedView({ text }: { text: string }) {
return (
-
Prompt
+
Your own prompt
{text}
);
}
-/** The take's prompt as its next draw sends it (prompt.md), and what the shown take was made with behind its disclosure. */
+/** The take's own prompt, which its next shoot sends as written (prompt.md), else none, and what the shown take was made with behind its disclosure. */
function Prompt({ seg }: { seg: Seg }) {
return (
{seg.prompt !== null ?
- :
No prompt yet: it is written when the take is planned.
}
+ :
The automatic prompt: composed when the take is shot.
}
{seg.request && (
How it was made
diff --git a/extensions/pine-drama/protocol/v2/major1-to-major2-conversion.json b/extensions/pine-drama/protocol/v2/major1-to-major2-conversion.json
index 2e24e47..e8fd4ae 100644
--- a/extensions/pine-drama/protocol/v2/major1-to-major2-conversion.json
+++ b/extensions/pine-drama/protocol/v2/major1-to-major2-conversion.json
@@ -40,7 +40,7 @@
},
"writes": {
"{owner}/description.md": "the description field's text",
- "{owner}/entry.json": "entry.json without entry_json_drop_fields and without the description field (description_field_by_owner_kind); every other field (look, members, establishing, …) stays"
+ "{owner}/entry.json": "entry.json without entry_json_drop_fields and without the description field (description_field_by_owner_kind); every other field (look, members, establishing, …) stays, until a character's look and a prop's text move into its description.md, after the person's pending text (pending_text): the one-editable-text merge (doc/protocol.md 2.2)"
},
"also_gives": "the fields of {owner}'s object.json (see object_json)",
"entry_json_drop_fields": [
@@ -49,8 +49,7 @@
"setting",
"inside_of",
"appears_in",
- "from",
- "text"
+ "from"
],
"kind_folder_to_type": {
"characters": "character",
@@ -90,16 +89,6 @@
}
}
},
- {
- "v1_object_ends_with": "/prompts",
- "owner": "the prompts folder's parent ({owner})",
- "operation": "extract_json_field_to_markdown",
- "reads": "prompt.json",
- "field": "text",
- "writes": {
- "{owner}/prompt.md": "the field's text"
- }
- },
{
"v1_object_ends_with": "/describe",
"owner": "the describe folder's parent ({owner})",
@@ -183,14 +172,15 @@
],
"dropped_wherever_they_are": [
"understanding",
- "asset-library"
+ "asset-library",
+ "prompts"
],
- "dropped_wherever_they_are_note": "folders of these names, at any depth (the root, an episode, a variant): drama-cli's own records of major 1, its understand calls and its asset-library uploads; drama-cli of major 2 keeps such records in pine-computer-records/ and reads none of these (kept in the backup)"
+ "dropped_wherever_they_are_note": "folders of these names, at any depth (the root, an episode, a variant): drama-cli's own records of major 1, its understand calls, its asset-library uploads and its stored prompts, since every prompt is composed when drawn (doc/protocol.md 2.2); drama-cli of major 2 keeps such records in pine-computer-records/ and reads none of these (kept in the backup)"
},
"current": {
"rule": "each kept object's files are the files of its major-1 current version (major 1's 3.2: the chosen version, else the newest not discarded), and every object.json is written (see object_json); earlier versions are kept in the backup only, and the converted folder is recorded as one commit, authored client-found-changes-on-disk",
"removed_objects": "an object choices.json marks removed is deleted, with every variant under it",
- "pending_text": "choices.json prompt and description fields become {object}/prompt.md and {object}/description.md"
+ "pending_text": "choices.json description becomes {object}/description.md; its prompt is dropped (kept in the backup), since every prompt is composed when drawn"
},
"snapshots": {
"read_from": [
diff --git a/extensions/pine-drama/src/core/canvasProtocol.ts b/extensions/pine-drama/src/core/canvasProtocol.ts
index 8110c8f..64b2d25 100644
--- a/extensions/pine-drama/src/core/canvasProtocol.ts
+++ b/extensions/pine-drama/src/core/canvasProtocol.ts
@@ -117,8 +117,8 @@ export type ToCanvas =
| { readonly v: typeof CANVAS_PROTOCOL; readonly type: 'detail'; readonly stageId: string; readonly detail: CanvasDetail | null; readonly error: string | null;
/** An asset's card: what the record panel edits; null elsewhere. */
readonly record?: CanvasRecord | null;
- /** The box's prompt; null for an object with none to edit. */
- readonly prompt?: CanvasPrompt | null;
+ /** A keyframe's, a storyboard's or a take's: whether it has its own prompt (prompt.md, its override); null for any other card. */
+ readonly ownPrompt?: boolean | null;
/** Its shown file's earlier results and the one in use, for Use (versionDetail.ts pictureHistory); null with none. */
readonly picture?: CanvasPicture | null;
/** What its next draw request sends, Image 1..N (versionDetail.ts nextDrawRequest): the composer's references. */
@@ -141,12 +141,6 @@ export interface CanvasPicture {
}[];
}
-/** The box's one text: the object's prompt.md, which the person and the agent edit; null while there is none. */
-export interface CanvasPrompt {
- readonly object: string;
- readonly text: string | null;
-}
-
/** An asset or variant as the record panel shows and edits it. */
export interface CanvasRecord {
/** Its description.md, which the person and the agent edit (doc/protocol.md 2.2). */
diff --git a/extensions/pine-drama/src/core/convertMajor1ProjectToMajor2.ts b/extensions/pine-drama/src/core/convertMajor1ProjectToMajor2.ts
index 45b1a02..37299f5 100644
--- a/extensions/pine-drama/src/core/convertMajor1ProjectToMajor2.ts
+++ b/extensions/pine-drama/src/core/convertMajor1ProjectToMajor2.ts
@@ -11,16 +11,15 @@ import { CHOICES_FILE, dramaRecordsOf, publishKeptTurns, readChoices, readVersio
import { readProjectMajor, writeProjectMarker } from './project';
import { commitPathsToHistory, runInProjectWriteQueue } from './projectHistory';
import { sha256OfFile } from './sha256';
-import { DESCRIPTION_FILE, type Edge, OBJECT_FILE, PROMPT_FILE, RECEIPT_SUFFIX, refuseWithUpgradeInstructions, STUDIO_RELEASES_URL } from './protocol';
+import { DESCRIPTION_FILE, type Edge, ENTRY_FILE, OBJECT_FILE, RECEIPT_SUFFIX, refuseWithUpgradeInstructions, STUDIO_RELEASES_URL } from './protocol';
const TABLE = require('../../protocol/v2/major1-to-major2-conversion.json') as ConversionTable;
interface RelationTarget { readonly only_on?: string; readonly first_existing_of?: readonly string[]; readonly target?: string }
interface RecordStage {
readonly v1_object_ends_with: string;
- readonly operation: 'split_entry_record_into_object_files' | 'extract_json_field_to_markdown' | 'write_receipt_only';
+ readonly operation: 'split_entry_record_into_object_files' | 'write_receipt_only';
readonly reads?: string;
- readonly field?: string;
readonly writes: Readonly>;
readonly description_field_by_owner_kind?: Readonly>;
readonly entry_json_drop_fields?: readonly string[];
@@ -92,6 +91,20 @@ const segmentsMatch = (pattern: string, id: string) => {
};
const stageOf = (object: string) => TABLE.record_stages.find(s => object.endsWith(s.v1_object_ends_with));
const ownerOf = (object: string, stage: RecordStage) => object.slice(0, -stage.v1_object_ends_with.length);
+/**
+ * A character's `look` or a prop's `text` moved from entry.json into its description, in drama-cli's bytes for a new
+ * asset (entries.prose); null when the entry has neither.
+ */
+function mergedDescription(type: string, description: string, entry: Readonly>): { readonly description: string; readonly entry: Record } | null {
+ const field = type === 'character' ? 'look' : type === 'prop' ? 'text' : null;
+ if (!field || !(field in entry)) { return null; }
+ const value = typeof entry[field] === 'string' ? (entry[field] as string).trim() : '';
+ const { [field]: _moved, ...rest } = entry;
+ const part = !value ? null : field === 'look' ? (description.includes(value) ? null : `Outfit: ${value}`)
+ : description.includes(`"${value}"`) ? null : `It shows the words "${value}".`;
+ return { description: part ? `${[description.trim(), part].filter(Boolean).join('\n\n')}\n` : description, entry: rest };
+}
+
/** A dot path into a JSON value (receipt_when_owner_current_entry_metadata's keys). */
const at = (value: unknown, path: string) => path.split('.').reduce((v, key) => (v as Record | undefined)?.[key], value);
@@ -129,7 +142,7 @@ function findMajor1Versions(root: string): Major1Version[] {
}
};
walk('');
- return found.filter(v => !TABLE.objects_dropped.includes(v.object));
+ return found.filter(v => !TABLE.objects_dropped.includes(v.object) && !v.object.split('/').some(part => DROPPED_BY_NAME.has(part)));
}
function readVersion(root: string, object: string, id: string): Major1Version {
@@ -236,9 +249,6 @@ class Conversion {
const owner = ownerOf(version.object, stage);
const record = () => json(join(this.root, version.object, version.id, stage.reads!)) as Record;
const [written] = Object.keys(stage.writes).map(path => path.replace('{owner}', owner));
- if (stage.operation === 'extract_json_field_to_markdown') {
- return writeWhole(join(this.root, written), String(record()[stage.field!] ?? ''));
- }
if (stage.operation === 'split_entry_record_into_object_files') {
const entry = record();
const field = stage.description_field_by_owner_kind![this.descriptionKeyOf(owner)];
@@ -317,9 +327,15 @@ class Conversion {
for (const object of new Set([...this.kept.listed.keys(), ...owners, ...pictures])) { if (!this.current.has(object)) { await this.writeObjectJson(object); } }
// The person's pending text, for the objects major 2 has (written_for), none of them removed.
for (const [object, choice] of Object.entries(this.choices?.objects ?? {}).filter(([id]) => this.described.has(id) && !removed.includes(id))) {
- if (choice.prompt !== undefined) { await writeWhole(join(this.root, object, PROMPT_FILE), choice.prompt); }
if (choice.description !== undefined) { await writeWhole(join(this.root, object, DESCRIPTION_FILE), choice.description); }
}
+ // One editable text per card (doc/protocol.md 2.2): an outfit or printed words join the description, after the pending text.
+ for (const owner of owners.filter(id => !removed.includes(id) && existsSync(join(this.root, id, ENTRY_FILE)))) {
+ const description = join(this.root, owner, DESCRIPTION_FILE);
+ const merged = mergedDescription(String(this.fieldsOf(owner)?.type), existsSync(description) ? await readFile(description, 'utf8') : '',
+ JSON.parse(await readFile(join(this.root, owner, ENTRY_FILE), 'utf8')));
+ if (merged) { await writeWhole(join(this.root, owner, ENTRY_FILE), `${JSON.stringify(merged.entry, null, '\t')}\n`); await writeWhole(description, merged.description); }
+ }
const configs = existsSync(join(this.root, CONFIG.folder)) ? readdirSync(join(this.root, CONFIG.folder))
.filter(v => existsSync(join(this.root, CONFIG.folder, v, CONFIG.file))).sort((a, b) => a.localeCompare(b, 'en', { numeric: true })) : [];
if (configs.length) { await writeWhole(join(this.root, CONFIG.file), await readFile(join(this.root, CONFIG.folder, configs.at(-1)!, CONFIG.file))); }
diff --git a/extensions/pine-drama/src/core/entryActions.ts b/extensions/pine-drama/src/core/entryActions.ts
index e0af7a5..13567ad 100644
--- a/extensions/pine-drama/src/core/entryActions.ts
+++ b/extensions/pine-drama/src/core/entryActions.ts
@@ -1,7 +1,7 @@
// The card actions as the person's changes to the project's files (doc/protocol.md section 3): each lands exactly the
// files it changes as one person change, through the one landing (applyChange.ts applyPersonChange), so the card shows
-// it at once and its history keeps what it replaced. "Use" brings a past result back the same way (section 5). Nothing
-// runs drama-cli here. No vscode import.
+// it at once and its history keeps what it replaced. "Use" brings an object back as it was at a past result the same
+// way (section 5). Nothing runs drama-cli here. No vscode import.
import { readFile } from 'node:fs/promises';
import { extname, join } from 'node:path';
@@ -9,8 +9,8 @@ import { applyPersonChange, type ChangeApplied } from './applyChange';
import type { CardRequest } from './galleryProtocol';
import { unusedName } from './placement';
import { ASSET_GROUPS, readObjectFile } from './project';
-import { listHistoryOfShownFile, readChangeOfObject, readFileAtCommit } from './projectHistory';
-import { DESCRIPTION_FILE, MAJOR, OBJECT_FILE, PROMPT_FILE, RECEIPT_SUFFIX } from './protocol';
+import { filesOfObjectAt, listHistoryOfShownFile, readFileAtCommit } from './projectHistory';
+import { DESCRIPTION_FILE, MAJOR, OBJECT_FILE, PROMPT_CARDS, PROMPT_FILE, RECEIPT_SUFFIX } from './protocol';
/** A card action, by the protocol's object ids (core/galleryProtocol.ts, where the pages read it too). */
export type { CardRequest } from './galleryProtocol';
@@ -65,8 +65,10 @@ export async function runCardAction(root: string, request: CardRequest, ask: Ent
const text = request.text ?? await ask.description(request.object, request.description);
return text === undefined ? undefined : change(`Description of ${request.object}`, async () => [[`${request.object}/${DESCRIPTION_FILE}`, text]]);
}
- case 'prompt':
- return change(`Prompt of ${request.object}`, async () => [[`${request.object}/${PROMPT_FILE}`, request.text]]);
+ case 'automatic':
+ // A keyframe's, a storyboard's or a take's own prompt goes (doc/protocol.md 2.2); no other card has one.
+ if (!PROMPT_CARDS.has((await readObjectFile(root, request.object)).type)) { throw new Error(`${request.object} has no prompt of its own: edit its description`); }
+ return change(`The automatic prompt for ${request.object}`, async () => [[`${request.object}/${PROMPT_FILE}`, null]]);
case 'remove':
// Its folder goes, with every variant below it (doc/protocol.md 2.2).
return change(`Removed ${request.object}`, async () => [[request.object, null]]);
@@ -99,17 +101,25 @@ export async function runCardAction(root: string, request: CardRequest, ask: Ent
}
case 'use':
return change(`Used an earlier result of ${request.object}`, async () => {
- // Every file the result's commit wrote in the object's own folder comes back, and its file is the shown one
- // again with its receipt as it was then, none where it had none (doc/protocol.md section 5); what the commit
- // wrote wins over the lines that show it.
const result = (await listHistoryOfShownFile(root, request.object)).find(entry => entry.commit === request.commit);
if (!result) { throw new Error(`${request.commit} is no result of ${request.object}`); }
- const receipt = `${result.file}${RECEIPT_SUFFIX}`;
- return [
- ...showing(request.object, await readObjectFile(root, request.object), result.file),
- [receipt, await readFileAtCommit(root, result.commit, receipt)],
- ...await readChangeOfObject(root, result.commit, request.object),
- ];
+ return restoredAsOf(root, request.object, result.commit);
});
}
}
+
+/** The writes that make `object`'s own folder what it was at `commit` (doc/protocol.md section 5). */
+async function restoredAsOf(root: string, object: string, commit: string): Promise<[string, Buffer | string | null][]> {
+ const raw = await readObjectFile(root, object);
+ const then = await readFileAtCommit(root, commit, `${object}/${OBJECT_FILE}`);
+ if (!then) { throw new Error(`${object} had no ${OBJECT_FILE} at ${commit}`); }
+ const was = JSON.parse(then.toString('utf8')) as Record;
+ const prompts = PROMPT_CARDS.has(raw.type);
+ const own = (path: string) => path !== `${object}/${OBJECT_FILE}` && (prompts || path !== `${object}/${PROMPT_FILE}`);
+ const files = new Map();
+ for (const path of (await filesOfObjectAt(root, 'HEAD', object)).filter(own)) { files.set(path, null); }
+ for (const path of (await filesOfObjectAt(root, commit, object)).filter(own)) { files.set(path, await readFileAtCommit(root, commit, path)); }
+ files.set(`${object}/${OBJECT_FILE}`, json({ ...raw, shown_file: was.shown_file ?? null,
+ ...prompts ? { objects_sent_by_draw_request: was.objects_sent_by_draw_request } : {} }));
+ return [...files];
+}
diff --git a/extensions/pine-drama/src/core/galleryProtocol.ts b/extensions/pine-drama/src/core/galleryProtocol.ts
index 88d31f4..e84db94 100644
--- a/extensions/pine-drama/src/core/galleryProtocol.ts
+++ b/extensions/pine-drama/src/core/galleryProtocol.ts
@@ -52,11 +52,12 @@ export type ToGallery =
/** A card action, by the protocol's object ids (project-relative paths); core/entryActions.ts runs it. */
export type CardRequest =
- /** "Use" on a past result of the object: its whole change, from that commit, comes back (doc/protocol.md section 5). */
+ /** "Use" on a past result of the object: its own folder comes back as it was at that commit (doc/protocol.md section 5). */
| { readonly action: 'use'; readonly object: string; readonly commit: string }
/** `text`: the new description, written in place; absent to ask the person, starting from `description`. */
| { readonly action: 'describe'; readonly object: string; readonly description: string; readonly text?: string }
- | { readonly action: 'prompt'; readonly object: string; readonly text: string }
+ /** "Use the automatic prompt": a keyframe's, a storyboard's or a take's own prompt.md goes, so its draw composes the prompt. */
+ | { readonly action: 'automatic'; readonly object: string }
| { readonly action: 'remove'; readonly object: string }
| { readonly action: 'add'; readonly type: 'character' | 'scene' | 'prop' | 'variant'; readonly name: string; readonly text: string; readonly from?: string; readonly setting?: Setting }
/** `file`: the person's picture on disk; null to ask for one. */
@@ -139,10 +140,9 @@ function readRequest(m: Record): EntryAction['request'] | undef
case 'describe':
return isPath(m.object) && typeof m.description === 'string' && (m.text === undefined || typeof m.text === 'string')
? { action: 'describe', object: m.object, description: m.description, ...(typeof m.text === 'string' ? { text: m.text } : {}) } : undefined;
- case 'prompt':
- return isPath(m.object) && text(m.text, TEXT_MAX) ? { action: 'prompt', object: m.object, text: m.text } : undefined;
case 'remove':
- return isPath(m.object) ? { action: 'remove', object: m.object } : undefined;
+ case 'automatic':
+ return isPath(m.object) ? { action: m.action, object: m.object } : undefined;
case 'add':
return (m.type === 'character' || m.type === 'scene' || m.type === 'prop' || m.type === 'variant') && text(m.name, NAME_MAX) && text(m.text, TEXT_MAX)
&& (m.from === undefined || isPath(m.from)) && (m.setting === undefined || m.setting === 'interior' || m.setting === 'exterior')
diff --git a/extensions/pine-drama/src/core/major1.ts b/extensions/pine-drama/src/core/major1.ts
index 697efc3..5a7a69e 100644
--- a/extensions/pine-drama/src/core/major1.ts
+++ b/extensions/pine-drama/src/core/major1.ts
@@ -28,7 +28,6 @@ export interface Chosen {
export interface ObjectChoice {
readonly chosen?: Chosen;
readonly discarded?: readonly string[];
- readonly prompt?: string;
readonly description?: string;
readonly removed?: true;
}
diff --git a/extensions/pine-drama/src/core/project.ts b/extensions/pine-drama/src/core/project.ts
index 0bd4bdc..d3dcf64 100644
--- a/extensions/pine-drama/src/core/project.ts
+++ b/extensions/pine-drama/src/core/project.ts
@@ -9,7 +9,7 @@ import { join } from 'node:path';
import { CHOICES_FILE } from './major1';
import { noFileThere, throughNoLink, writeWhole } from './placement';
import { projectIdentity } from './projectPlace';
-import { BIBLE_STORY_FILE, DESCRIPTION_FILE, OBJECT_FILE, PAID_CALL_ATTEMPT, PAID_CALL_LEDGER, PAID_CALL_LEDGER_BEFORE, PAID_CALL_UNDER_WAY, PINE_COMPUTER_RECORDS, PROJECT_MARKER_FILE, PROMPT_FILE, RECEIPT_SUFFIX, MAJOR, majorTwo, type Edge, type ObjectType } from './protocol';
+import { BIBLE_STORY_FILE, DESCRIPTION_FILE, OBJECT_FILE, PAID_CALL_ATTEMPT, PAID_CALL_LEDGER, PAID_CALL_LEDGER_BEFORE, PAID_CALL_UNDER_WAY, PINE_COMPUTER_RECORDS, PROJECT_MARKER_FILE, PROMPT_CARDS, PROMPT_FILE, RECEIPT_SUFFIX, MAJOR, majorTwo, type Edge, type ObjectType } from './protocol';
@@ -50,7 +50,7 @@ export interface ProjectObject {
* doc/protocol.md 2.2): the one source of its lines, drawn or not.
*/
readonly objectsSentByDrawRequest: readonly string[];
- /** The text of its description.md and prompt.md, or null without one. */
+ /** The text of its description.md, and of a keyframe's, a storyboard's or a take's own prompt.md, or null without one. */
readonly description: string | null;
readonly prompt: string | null;
/** A paid call for it is under way, by Pine Computer's records in the folder (objectsBeingMade). */
@@ -164,7 +164,8 @@ export async function readProjectFromFolder(projectRoot: string): Promise o.id));
diff --git a/extensions/pine-drama/src/core/projectHistory.ts b/extensions/pine-drama/src/core/projectHistory.ts
index bac7067..8b33d53 100644
--- a/extensions/pine-drama/src/core/projectHistory.ts
+++ b/extensions/pine-drama/src/core/projectHistory.ts
@@ -240,23 +240,13 @@ export async function readFileAtCommit(projectRoot: string, commit: string, path
}
/**
- * The files commit `commit` changed in `object`'s own folder, each with its bytes there, or null where it deleted the
- * file: what a "Use" of that result restores (doc/protocol.md section 5). A folder below holding an object.json, in the
- * commit or among what it changed, is an object of its own (a variant) and is left out. git diff-tree names them, the
- * first commit's too (--root).
+ * The files of `object`'s own folder at `rev` (git ls-tree): what a "Use" of a result restores (doc/protocol.md section
+ * 5). A folder below holding an object.json there is an object of its own (a variant) and is left out.
*/
-export async function readChangeOfObject(projectRoot: string, commit: string, object: string): Promise