Skip to content

AI media harness for planning, generating, and editing locally

TypeScript

Remove boxes and palettes from image prompts

Bitti15a192651f89
diff --git a/docs/architecture.md b/docs/architecture.md
index 72ba17e..b120e1c 100644
--- a/docs/architecture.md
+++ b/docs/architecture.md
@@ -43,7 +43,7 @@ non_diegetic_music: ...
Shots are sequential, later shots carry increasing cut timestamps, camera moves combine motion type with meaningful amplitude and speed, and dialogue uses stable speaker IDs. Keyframe jobs prepend the appropriate first/last-frame alignment instruction. Full-reference jobs additionally define stable subject/picture/video/audio labels and retention relationships. The editor stores both the human creative brief and the compiled H3 prompt so either can be revised.
-Image projects retain the [H3 base prompt structure](https://huggingface.co/MiniMaxAI/MiniMax-H3/blob/main/docs/VIDEO_PROMPT_WRITING_GUIDE_base_en.md): `integrated_multimodal_description` begins with `[Shot 1]`, visual style and one still composition. With selected references, `compileImagePrompt` uses the [six-section reference format](https://huggingface.co/MiniMaxAI/MiniMax-H3/blob/main/docs/VIDEO_PROMPT_WRITING_GUIDE_ref_en.md): `subject_definitions`, `summary`, `retention_analysis`, `detailed_description`, `overall_soundscape`, `non_diegetic_music`. Reference-mode style precedes `[Shot 1]`. Stable `<Subject N>` labels identify referenced content; `<Picture N>` sources follow the exact submitted image-path order. Refmods provide conditioning without consuming picture labels. Both audio fields are `N/A` for the silent still-image workflow. The compiler preserves nested visual elements, full-image placement percentages, palettes and verbatim quoted lettering; it adds no timestamps, subsequent shots or camera motion. Debug Prompt and generation use this same compiler. This applies the published video formats to native still-image requests, which set `stillImage: true` and `frames: 1`.
+Image projects retain the [H3 base prompt structure](https://huggingface.co/MiniMaxAI/MiniMax-H3/blob/main/docs/VIDEO_PROMPT_WRITING_GUIDE_base_en.md): `integrated_multimodal_description` begins with `[Shot 1]`, visual style and one still composition. With selected references, `compileImagePrompt` uses the [six-section reference format](https://huggingface.co/MiniMaxAI/MiniMax-H3/blob/main/docs/VIDEO_PROMPT_WRITING_GUIDE_ref_en.md): `subject_definitions`, `summary`, `retention_analysis`, `detailed_description`, `overall_soundscape`, `non_diegetic_music`. Reference-mode style precedes `[Shot 1]`. Stable `<Subject N>` labels identify referenced content; `<Picture N>` sources follow the exact submitted image-path order. Refmods provide conditioning without consuming picture labels. Both audio fields are `N/A` for the silent still-image workflow. The compiler preserves nested visual elements and verbatim quoted lettering, omitting bounding-box coordinates and color palettes from prompts; it adds no timestamps, subsequent shots or camera motion. Debug Prompt and generation use this same compiler. This applies the published video formats to native still-image requests, which set `stillImage: true` and `frames: 1`.
Image-root edits also use all six reference sections, even without selected references. The original source is submitted as the first reference image and defined as the standalone `<Picture 1>` composition anchor. The summary uses `[keyframe completion]` (plus `reference generation` for additional subjects), and retention marks the edited keyframe `partially_preserved`. Additional reference pictures start at 2; the source consumes one of H3's nine image-reference slots. Each inpainting step uses the previous result's pixels for its edit source while retaining the original picture as the visual anchor. Debug Prompt and saved generation snapshots contain these exact per-edit prompts.
diff --git a/src-tauri/assets/agent-image.md b/src-tauri/assets/agent-image.md
index 2ca3369..ee40e9d 100644
--- a/src-tauri/assets/agent-image.md
+++ b/src-tauri/assets/agent-image.md
@@ -27,6 +27,6 @@ For an explicitly requested complete composition replacement, the older full-aut
All fields are required; copy unchanged authored fields from imageScene in the current project. Do not send outputAssetId: generated results belong to the app. Each node has exactly these fields:
{"id":"stable-id","parentId":null,"kind":"root","name":"Image","description":"high-level image prompt","text":"","box":null,"colors":[]}
-Use exactly one root with parentId null. Other nodes have kind group, object, text or background, and parentId naming an existing node. IDs must be unique and the tree connected and acyclic. Objects, groups and text may carry box {"x":100,"y":100,"width":400,"height":600} in 0–1000 image coordinates; extents must be positive and stay within the image. Box null means automatic placement. A group's description provides context to its children. Text nodes use text for the exact lettering and description for appearance. Colors are hex #RRGGBB strings (up to 16). Names are short tree labels; put visual instructions in description. At most 500 nodes. Style mode is photo or art, steps 2–1000, seed -1 for random or a nonnegative safe integer. Placement is prose guidance to H3, not a guaranteed pixel mask.
+Use exactly one root with parentId null. Other nodes have kind group, object, text or background, and parentId naming an existing node. IDs must be unique and the tree connected and acyclic. Objects, groups and text may carry box {"x":100,"y":100,"width":400,"height":600} in 0–1000 image coordinates; extents must be positive and stay within the image. Box null means automatic placement. A group's description provides context to its children. Text nodes use text for the exact lettering and description for appearance. Colors are hex #RRGGBB strings (up to 16). Names are short tree labels; put visual instructions in description. At most 500 nodes. Style mode is photo or art, steps 2–1000, seed -1 for random or a nonnegative safe integer. Bounding-box coordinates and color palettes are omitted from H3 prompts. In image-root editing, boxes still define the inpainting area.
Use project.set for project name, resolution and aspectRatio. Use ref.add/ref.set for reusable descriptions, then cite each one in a description or the background as @[ref:<id>] with its reference ID, e.g. "@[ref:ref-mara] holds the lantern". Only the references cited this way are passed to generation; referenceIds is no longer used to choose them. Cite only existing image/text references. Remove its citations before ref.remove. Do not create scene.*, shot.* or clip.* commands for image projects. Preserve the current image composition unless asked to change it. Never invent files or claim to have generated an image: the user runs Generate in the Editor.
diff --git a/src/lib/imageEditing.test.ts b/src/lib/imageEditing.test.ts
index b4353f2..e403eac 100644
--- a/src/lib/imageEditing.test.ts
+++ b/src/lib/imageEditing.test.ts
@@ -13,12 +13,14 @@ it("uses hierarchy order, skips empty groups, and converts boxes to original pix
scene.nodes[2].description = "A blue boat";
scene = addImageNode(scene, group, "object", { x: 900, y: 900, width: 100, height: 100 });
scene.nodes[3].description = "A red balloon";
+ scene.nodes[3].colors = ["#FF0000"];
config.imageScene = scene;
config.settings.defaultLook = "watercolor";
const { edits } = compileImageEdits(config);
expect(edits).toHaveLength(2);
expect(edits[0]).toMatchObject({ x: 90, y: 69, width: 11, height: 8 });
expect(edits[0].prompt).toContain("A red balloon");
+ expect(edits[0].prompt).not.toMatch(/Use these colors|#FF0000/);
expect(edits[1]).toMatchObject({ x: 25, y: 19, width: 51, height: 39 });
expect(edits[1].prompt).toContain("A blue boat");
expect(edits[0].prompt).not.toContain("watercolor");
@@ -59,6 +61,7 @@ it("starts with a clean image root and requires described edits before submissio
expect(edited.imageScene!.nodes[0].description).toBe("");
expect(() => compileImageEdits(edited)).toThrow("Enter a whole-image edit prompt");
edited.imageScene = addImageNode(edited.imageScene!, "image-root", "object");
+ edited.imageScene.nodes[1].colors = ["#FF0000"];
expect(() => compileImageEdits(edited)).toThrow("Describe the edit");
expect(config.imageScene!.nodes.length).toBeGreaterThan(1);
expect(parseProjectConfig(JSON.parse(JSON.stringify(edited))).imageScene).toEqual(edited.imageScene);
diff --git a/src/lib/imageEditing.ts b/src/lib/imageEditing.ts
index 7540d9b..c726d9d 100644
--- a/src/lib/imageEditing.ts
+++ b/src/lib/imageEditing.ts
@@ -17,15 +17,15 @@ export function compileImageEdits(config: ProjectConfig): { source: ImageSource;
const ordered: ImageNode[] = root.description.trim() ? [{ ...root, box: { x: 0, y: 0, width: 1000, height: 1000 } }] : [];
const visit = (parent: string) => { for (const node of scene.nodes.filter((item) => item.parentId === parent)) { ordered.push(node); visit(node.id); } };
visit(root.id);
- const edits = ordered.filter((node) => node.kind !== "group" || node.description.trim() || node.text || node.colors.length).map((node) => {
+ const edits = ordered.filter((node) => node.kind !== "group" || node.description.trim() || node.text).map((node) => {
if (!node.box) throw new Error(`Set a placement box for '${node.name}'.`);
- if (!node.description.trim() && !node.text && !node.colors.length) throw new Error(`Describe the edit for '${node.name}'.`);
+ if (!node.description.trim() && !node.text) throw new Error(`Describe the edit for '${node.name}'.`);
const x = Math.min(source.width - 1, Math.floor(node.box.x * source.width / 1000));
const y = Math.min(source.height - 1, Math.floor(node.box.y * source.height / 1000));
const right = Math.min(source.width, Math.ceil((node.box.x + node.box.width) * source.width / 1000));
const bottom = Math.min(source.height, Math.ceil((node.box.y + node.box.height) * source.height / 1000));
const description = ["The edited keyframe corresponds to <Picture 1> with the following change. Preserve the composition and any previously completed edits.", node.description,
- node.text ? `Render the exact text "${node.text}".` : "", node.colors.length ? `Use these colors: ${node.colors.join(", ")}.` : ""].filter(Boolean).join(" ");
+ node.text ? `Render the exact text "${node.text}".` : ""].filter(Boolean).join(" ");
const editScene = { ...createImageScene(description), rootType: "image" as const, sourceImage: source, referenceIds: [] };
const compiled = compileImagePrompt({ ...config, settings: { ...config.settings, defaultLook: null }, imageScene: editScene });
return { prompt: compiled.prompt, references: compiled.references, x, y, width: Math.max(1, right - x), height: Math.max(1, bottom - y) };
diff --git a/src/lib/imagePrompt.test.ts b/src/lib/imagePrompt.test.ts
index d4493cb..6e496cc 100644
--- a/src/lib/imagePrompt.test.ts
+++ b/src/lib/imagePrompt.test.ts
@@ -21,16 +21,16 @@ describe("MiniMax H3 still-image prompts", () => {
expect(config).toEqual(snapshot);
});
- it("preserves nested composition, placement and palettes even for undescribed groups", () => {
+ it("preserves nested composition while omitting placement and palettes", () => {
const config = parseProjectConfig(fixture);
config.imageScene!.nodes[1].description = "";
const prompt = compileImagePrompt(config).prompt;
expect(prompt).toContain("integrated_multimodal_description: [Shot 1] A still image in Illustration");
expect(prompt).toContain("Screen print art style.");
- expect(prompt).toContain("Overall color palette: #204060.");
+ expect(prompt).not.toMatch(/palette|#204060|#FF0000|Position in|\[300, 100, 700, 900\]|\[350, 150, 650, 250\]/);
expect(prompt).toContain("Background: Ocean at dawn.");
- expect(prompt).toContain("A grouped arrangement. Position in the full image: left 30%, top 10%, width 40%, height 80%. Its composition includes:\n Visible lettering. Bold red lettering.");
- expect(prompt).toContain('Render the exact text "LIFT OFF". Position in the full image: left 35%, top 15%, width 30%, height 10%. Color palette: #FF0000.');
+ expect(prompt).toContain("A grouped arrangement. Its composition includes:\n Visible lettering. Bold red lettering.");
+ expect(prompt).toContain('Render the exact text "LIFT OFF".');
expect(prompt).not.toMatch(/group:|text:|group-rocket|Camera and lens/);
});
diff --git a/src/lib/imageScene.test.ts b/src/lib/imageScene.test.ts
index f790725..f7d3f4f 100644
--- a/src/lib/imageScene.test.ts
+++ b/src/lib/imageScene.test.ts
@@ -39,10 +39,15 @@ describe("image documents", () => {
const prompt = imageScenePrompt(resized);
expect(prompt).toContain('Render the exact text "LIFT OFF"');
expect(prompt).toContain("white rocket surrounded by glowing vapor");
- expect(prompt).toContain("left 12.5%");
+ expect(prompt).not.toContain("[125, 125, 275, 175]");
expect(prompt).toContain("Screen print");
- expect(prompt).toContain("#FF0000");
+ expect(prompt).not.toContain("#FF0000");
expect(imageScenePrompt(createImageScene())).toBe("");
- expect(addImageNode(createImageScene(), "image-root", "object").nodes).toHaveLength(2);
+ const objectScene = addImageNode(createImageScene(), "image-root", "object", { x: 172, y: 237, width: 681, height: 249 });
+ expect(objectScene.nodes).toHaveLength(2);
+ objectScene.nodes[1].colors = ["#FF0000"];
+ expect(imageScenePrompt(objectScene)).toBe("");
+ objectScene.nodes[1].description = "sunglasses";
+ expect(imageScenePrompt(objectScene)).toBe("A still photograph.\nsunglasses.");
});
});
diff --git a/src/lib/imageScene.ts b/src/lib/imageScene.ts
index c869a43..b3770fc 100644
--- a/src/lib/imageScene.ts
+++ b/src/lib/imageScene.ts
@@ -95,10 +95,10 @@ export function resizeImageNode(scene: ImageScene, id: string, box: ImageBox): I
const sentence = (text: string) => /[.!?。!?]$/.test(text.trim()) ? text.trim() : `${text.trim()}.`;
/** Visual content only. The compiler places style before or after [Shot 1]
- * according to H3's reference or base format. Boxes refer to the full image. */
+ * according to H3's reference or base format. Boxes and palettes are omitted. */
export function imageScenePromptParts(scene: ImageScene, look?: string): { style: string; composition: string } | null {
const root = scene.nodes.find((node) => node.kind === "root")!;
- const hasContent = scene.background.trim() || scene.nodes.some((node) => node.description.trim() || node.colors.length || (node.kind === "text" && node.text) || (node.kind !== "root" && node.box));
+ const hasContent = scene.background.trim() || scene.nodes.some((node) => node.description.trim() || (node.kind === "text" && node.text));
if (!hasContent) return null;
const treatment = [
...(look?.trim() ? [`${look.trim()} visual style`] : []),
@@ -108,11 +108,8 @@ export function imageScenePromptParts(scene: ImageScene, look?: string): { style
];
const medium = scene.style.mode === "photo" ? "A still photograph" : `A still image in ${scene.style.medium.trim() || "an artistic medium"}`;
const style = sentence(`${medium}${treatment.length ? ` with ${treatment.join(", ")}` : ""}`);
- const placement = (node: ImageNode) => node.box ? `Position in the full image: left ${node.box.x / 10}%, top ${node.box.y / 10}%, width ${node.box.width / 10}%, height ${node.box.height / 10}%.` : "";
const lines: string[] = [
...(root.description.trim() ? [sentence(root.description)] : []),
- ...(root.colors.length ? [`Overall color palette: ${root.colors.join(", ")}.`] : []),
- ...(root.box ? [placement(root)] : []),
...(scene.background.trim() ? [`Background: ${sentence(scene.background)}`] : []),
];
const visit = (node: ImageNode, depth: number) => {
@@ -120,10 +117,9 @@ export function imageScenePromptParts(scene: ImageScene, look?: string): { style
const description = node.description.trim() ? sentence(node.description) : "";
// Quote visible lettering verbatim, including its language and line breaks.
const text = node.kind === "text" && node.text ? `Render the exact text "${node.text}".` : "";
- const colors = node.colors.length ? `Color palette: ${node.colors.join(", ")}.` : "";
- const subject = node.kind === "group" ? "A grouped arrangement." : node.kind === "text" ? "Visible lettering." : node.kind === "background" ? "A background element." : "A depicted object.";
- const detail = [subject, description, text, placement(node), colors, ...(children.length ? ["Its composition includes:"] : [])].filter(Boolean).join(" ");
- lines.push(`${" ".repeat(depth)}${detail}`);
+ const subject = node.kind === "group" ? "A grouped arrangement." : node.kind === "text" ? "Visible lettering." : node.kind === "background" ? "A background element." : "";
+ const detail = [subject, description, text, ...(children.length ? ["Its composition includes:"] : [])].filter(Boolean).join(" ");
+ if (detail) lines.push(`${" ".repeat(depth)}${detail}`);
children.forEach((child) => visit(child, depth + 1));
};
scene.nodes.filter((node) => node.parentId === root.id).forEach((node) => visit(node, 0));