Self-hosted, Self-Improving, Federated Everything App — dev management, agent orchestration, persistent mind, digital twin, second brain, and creative pipeline from a single dashboard over Tailscale to port the user into the OS
JavaScript ai-agentsdashboarddeveloper-toolsdigital-twinquantified-selfsecond-brainself-hostedtailscale
fix([issue-3004]): stop turnaround sheets mirroring the front view instead of rotating
[._.]/ Adam Eivy5132b9147d44
diff --git a/.changelog/NEXT.md b/.changelog/NEXT.mdindex aba13550bd..8d9b36145c 100644--- a/.changelog/NEXT.md+++ b/.changelog/NEXT.md@@ -25,6 +25,7 @@## Sprite Manager+- **[issue-3004] Turnaround sheets stop mirroring the front view, so a front-worn bag no longer ends up on the character's back** — the back panel of a generated turnaround sheet was often just the front figure flipped left-to-right, which meant anything mounted on the *front* of the body (a hip bag worn at the front, a chest pack, a belt buckle) reappeared on the character's back in the rear view, and the same mistake carried into any single rotated view derived from the sheet. The old instruction only pinned accessories to the same anatomical *side* — a rule a mirrored figure satisfies perfectly, because the bug is on the front/back axis, not left/right. Every sprite prompt now states that the panels are one character physically *rotated* about a vertical axis and that no panel may be a flip or copy of another, and each facing carries its own rule for what that angle hides: a rear view hides front-mounted gear (keeping only what genuinely wraps around, like a strap crossing the back) and shows no face or front closures; a front view hides backpacks and back-slung weapons; each profile hides whatever sits on the far side of the torso. The front/back panels also now say where a right-hip item lands on screen once the character turns, so "same side" can't be satisfied by leaving it in the same pixels. The walk-video step is told not to invent gear the anchor hides mid-loop.- **[issue-2993] Imported characters can finally be re-derived — smoother walks, and an atlas you can compile here** — a character brought over from a source art pipeline was frozen the moment it arrived: Unlock, Reopen and Compile all refused it outright, so an imported 8-frame walk could never be brought up to 12 and its atlas could only ever be re-published, never rebuilt. That refusal was written when the import genuinely left nothing behind to work from — but the importer now copies each direction's source clip, so it had become a lie. Those actions are now gated on whether the clip is actually there: a direction with its clip on disk reopens and reprocesses at any frame count and speed, with no new render and no new spend, and the buttons appear instead of being hidden. A direction with no clip is still refused, but now says so plainly and tells you to re-import the character. Compiling is likewise per-direction: the atlas names the directions still packaged by the source pipeline instead of refusing the whole set, so an imported character becomes compilable one direction at a time as you re-derive them — and approving a direction whose packaged frames were never imported is now caught up front, rather than surfacing much later as an unexplained compile error.- **[issue-2996] A character you'd started but not locked now begins at the turnaround sheet too** — when turnaround sheets landed, characters already in progress kept the old flow: they'd still ask for a main reference first, and only pick up sheets afterward. Now a character that hasn't frozen anything yet simply starts at step 1 like a new one — nothing of yours is lost, because nothing was locked. Characters that *have* frozen a main reference are untouched: their locked artwork stays exactly as it is, and they still backfill a sheet from it. Uploading a design image is now accepted only on the turnaround step, since that's the render it actually seeds — the main reference and every anchor are drawn from the sheet, so attaching a separate image to them has nowhere to go and is rejected with a clear message.- **[issue-2982] Publishing an atlas your game can't read now stops instead of silently breaking it** — the atlas PNG used to be the *entire* export: nothing described how many walk frames were in it, so a game with an 8-frame walk baked in as a constant would happily accept a 12-frame publish and then draw the wrong frames from the wrong columns forever, with no crash and no log. Two things fix that. A publish target can now declare the grid it was built against (`runtimeContract`: walk frame count, cell size, column count), and a publish whose compiled atlas disagrees is refused with a message naming both numbers — "Atlas has 14 columns (12 walk frames) but Example App expects 10 (8 walk frames)" — plus the two ways to resolve it. And every publish now writes a small `….layout.json` file beside the atlas describing the grid PortOS actually produced: cell size, ordered column names, per-track column spans (so a future multi-frame scanner or ambient action is additive, not a rewrite), row order, and the atlas checksum — so the game can resolve columns by name and verify what it loaded instead of trusting a constant. Targets with no declared contract publish exactly as before. Also documented: playback **fps in PortOS is preview-only**. It ships in the sidecar labeled as authoring metadata, because the consuming game drives its walk from movement distance and has no frame-rate concept at all — a 6 fps preview and a 24 fps preview export byte-identical atlases. See `docs/features/sprite-export-contract.md`.diff --git a/server/services/sprites/prompts.js b/server/services/sprites/prompts.jsindex 934d814128..8a2f1d1176 100644--- a/server/services/sprites/prompts.js+++ b/server/services/sprites/prompts.js@@ -62,6 +62,57 @@ export function keyColorPhrase(hex) {// read a given facing from.export const TURNAROUND_VIEWS = ['south', 'east', 'north', 'west'];+// --- View geometry (issue #3004) -------------------------------------------+// The turnaround's dominant failure mode is that the model MIRRORS the front+// figure instead of rotating the character: a hip bag worn on the FRONT of the+// hip reappears on the character's back in the north panel, a face survives+// into the back view, and profile panels show gear that the torso should be+// hiding. "Same anatomical side" alone doesn't fix it — that rule is about the+// left/right axis, and this bug is on the front/back (depth) axis. So each+// facing carries an explicit statement of what that angle actually exposes.++const FRONT_GEAR = 'gear mounted on the front of the body (a hip bag or pouch worn at the front, '+ + 'belt buckle, chest pack, front pockets, lanyard, a holster on the front of the thigh)';+const BACK_GEAR = 'gear mounted on the back of the body (backpack, quiver, a weapon sheathed '+ + 'across the back, a hood hanging down)';++// Which half of the depth axis the camera is behind, per direction.+const REAR_FACING = new Set(['north', 'north-east', 'north-west']);+const FRONT_FACING = new Set(['south', 'south-east', 'south-west']);+// Which side of the body turns toward the viewer. Facing due east the character+// looks screen-right, so the viewer stands off their RIGHT shoulder (face east,+// south is on your right); facing west it is the left side.+const RIGHT_SIDE_TO_VIEWER = new Set(['east', 'south-east', 'north-east']);+const LEFT_SIDE_TO_VIEWER = new Set(['west', 'south-west', 'north-west']);++/**+ * One sentence describing what a given facing occludes — the concrete rule that+ * stops the model from mirroring the front view. Exported so the sheet prompt,+ * the derive-anchor prompt, and the tests all read from one vocabulary.+ */+export function viewGeometryClause(direction) {+ const parts = [];+ if (REAR_FACING.has(direction)) {+ parts.push(+ `This angle is behind the character: ${FRONT_GEAR} is hidden by the body and must not be `+ + 'drawn — only the parts that genuinely wrap around, such as a strap crossing the back or '+ + 'the rear of a waist belt, stay visible. Draw the back of the head, hair and garment: no '+ + 'face, no eyes, no front closures, buttons, zippers or chest emblems.',+ );+ } else if (FRONT_FACING.has(direction)) {+ parts.push(`This angle is in front of the character: ${BACK_GEAR} is hidden by the body — at `+ + 'most its shoulder straps show over the front.');+ }+ if (RIGHT_SIDE_TO_VIEWER.has(direction)) {+ parts.push('The viewer sees the character\'s right side, so right-side gear reads fully and '+ + 'left-side gear is occluded by the torso.');+ } else if (LEFT_SIDE_TO_VIEWER.has(direction)) {+ parts.push('The viewer sees the character\'s left side, so left-side gear reads fully and '+ + 'right-side gear is occluded by the torso.');+ }+ return parts.join(' ');+}+// The sheet's candidate/asset id — the `anchorIdForDirection` analogue for the// one reference artifact that has no direction. Lives here with the other// target vocabulary so validation.js and the services share one spelling.@@ -84,6 +135,12 @@ export function buildTurnaroundPrompt({ name, designPrompt, chromaKey }) {const panels = TURNAROUND_VIEWS.map((view, i) => `${i + 1}) ${REFERENCE_FACING[view] || view}`).join(', ');+ // Per-panel geometry: what each angle exposes and what it must hide. Without+ // this the model mirrors panel 1 and every front-mounted item survives into+ // the back view (issue #3004).+ const panelRules = TURNAROUND_VIEWS+ .map((view, i) => `Panel ${i + 1} (${REFERENCE_FACING[view] || view}): ${viewGeometryClause(view)}`)+ .join(' ');return (`Create a character turnaround model sheet for a game character named ${name}. `+ `Character design: ${description} `@@ -91,10 +148,22 @@ export function buildTurnaroundPrompt({ name, designPrompt, chromaKey }) {+ `image, evenly spaced left to right in this exact order: ${panels}. `+ 'Every figure is the identical character in a neutral standing pose, arms relaxed, at '+ 'the same scale, with feet level on one shared baseline. Identity, proportions, palette, '- + 'clothing, hairstyle, and accessories must match across all panels, and every accessory '- + '(bag, strap, pouch, pocket, weapon) must stay on the SAME anatomical side of the body in '- + 'every panel — an item worn on the character\'s right hip appears on the right hip from '- + 'the front, from behind, and in both profiles. Flat non-isometric pixel-art game sprite '+ + 'clothing, hairstyle, and accessories must match across all panels. '+ // Rotation, not reflection — stated before the per-panel rules because it is+ // the single instruction that kills the mirrored-front-view failure.+ + `The panels are one character physically rotated in place about a vertical axis through `+ + `${TURNAROUND_VIEWS.length} even steps of a full 360-degree turn. No panel is a horizontal `+ + 'flip, mirror, or copy of another panel: draw each one from the geometry that angle '+ + 'actually exposes, including the parts of the body and gear it hides. '+ // Left/right axis (unchanged rule) — now paired with the screen-position+ // consequence, so "same side" can't be satisfied by never moving the item.+ + 'Every accessory (bag, strap, pouch, pocket, weapon) stays on the SAME anatomical side of '+ + 'the body in every panel — an item worn on the character\'s right hip is on the right hip '+ + 'from the front, from behind, and in both profiles. Because the character turns, that item '+ + 'is drawn toward the viewer\'s left in the front panel and toward the viewer\'s right in '+ + 'the back panel. '+ + `${panelRules} `+ + 'Flat non-isometric pixel-art game sprite '+ `reference on a plain exact ${keyColorPhrase(chromaKey)} background. No panel borders, `+ 'labels, captions, arrows, grid, shadows, scenery, wireframe, or extra characters. '+ 'Return exactly one PNG.'@@ -104,13 +173,24 @@ export function buildTurnaroundPrompt({ name, designPrompt, chromaKey }) {// Shared preamble for a render seeded from the locked turnaround sheet: the// init image is a multi-figure sheet, so the model must be told to read ONE// panel and emit ONE figure — otherwise it happily returns another sheet.-const fromTurnaroundClause = (facing) => (- `The attached image is a turnaround model sheet showing the same character from `- + `${TURNAROUND_VIEWS.length} angles. Read the panel that shows the character ${facing}, and `- + 'take accessory placement (which anatomical side each bag, strap, pouch, or pocket sits on) '- + 'from the panels that show that side. Do not reproduce the sheet layout: return one single '- + 'figure, not multiple figures and not panels. '-);+const fromTurnaroundClause = (direction) => {+ const facing = REFERENCE_FACING[direction] || direction;+ return (+ `The attached image is a turnaround model sheet showing the same character from `+ + `${TURNAROUND_VIEWS.length} angles. Read the panel that shows the character ${facing}, and `+ + 'take accessory placement (which anatomical side each bag, strap, pouch, or pocket sits on) '+ + 'from the panels that show that side. Do not reproduce the sheet layout: return one single '+ + 'figure, not multiple figures and not panels. '+ );+};++// Depth/side geometry appended to every derive prompt. The sheet can still be+// imperfect, and the derive step is a second chance to keep a front-mounted bag+// off the character's back (issue #3004).+const geometryRule = (direction) => {+ const clause = viewGeometryClause(direction);+ return clause ? `${clause} ` : '';+};/*** Stage-1 prompt: create the frozen walk-south identity reference from a@@ -123,13 +203,13 @@ export function buildMainReferencePrompt({ name, designPrompt, chromaKey, fromTu? designPrompt.trim(): 'Use the attached visual reference as the character design.';return (- (fromTurnaround ? fromTurnaroundClause(REFERENCE_FACING.south) : '')+ (fromTurnaround ? fromTurnaroundClause('south') : '')+ `Create the frozen walk-south identity reference for a game character named ${name}. `+ `Character direction: ${description} `+ 'Draw exactly one full-body figure facing the viewer in a neutral standing pose, feet '+ 'level on one baseline, arms relaxed, with a clear readable silhouette. Match the '+ 'attached visual reference when provided. Preserve physical-left and physical-right '- + 'accessories exactly. Flat non-isometric pixel-art game sprite reference, centered on '+ + `accessories exactly. ${geometryRule('south')}Flat non-isometric pixel-art game sprite reference, centered on `+ `a plain exact ${keyColorPhrase(chromaKey)} background. No motion, labels, grid, shadows, scenery, `+ 'wireframe, or extra figures. Return exactly one PNG.');@@ -149,7 +229,9 @@ export function buildWalkVideoPrompt({ name, direction, chromaKey }) {`The source image is the locked directional identity anchor for the game character ${name}, `+ `${facing}. Animate a walk-in-place loop, walking ${direction}. `+ 'Preserve identity, palette, proportions, facing, and physical-left and physical-right '- + 'accessories exactly. Use a locked camera and an exactly uniform, non-emissive '+ + 'accessories exactly. Do not turn the character and do not add gear that the source image '+ + 'does not show — anything hidden behind the body there stays hidden for the whole loop. '+ + 'Use a locked camera and an exactly uniform, non-emissive '+ `${keyColorPhrase(chromaKey)} background that acts only as a compositing matte: no rim light, `+ 'bounce light, reflections, color cast, glow, or shadow on the character. Keep a stable '+ 'pivot and ground line with loop-friendly walk-in-place motion. No scenery, no text, no '@@ -172,11 +254,12 @@ export function buildAnchorPrompt({ name, direction, chromaKey, correctionPrompt? ` Important correction — apply this over the attached reference: ${correctionPrompt.trim()}`: '';return (- (fromTurnaround ? fromTurnaroundClause(facing) : '')+ (fromTurnaround ? fromTurnaroundClause(direction) : '')+ `Redraw the attached ${name} character as one `+ `full-body figure in a neutral standing pose, ${facing}. Keep the exact same `+ 'identity, proportions, palette, clothing, hairstyle, and accessories/straps on the '- + 'same anatomical side as the attached reference. Flat, non-isometric view; a '+ + 'same anatomical side as the attached reference. This is a rotation of the character, '+ + `not a mirrored copy of the reference. ${geometryRule(direction)}Flat, non-isometric view; a `+ `single centered figure; plain flat ${keyColorPhrase(chromaKey)} background; no labels, no `+ 'grid lines, no wireframe or guide colors. Return exactly one PNG.'+ correctiondiff --git a/server/services/sprites/prompts.test.js b/server/services/sprites/prompts.test.jsindex c00760c6a2..c803e75b98 100644--- a/server/services/sprites/prompts.test.js+++ b/server/services/sprites/prompts.test.js@@ -2,7 +2,7 @@ import { describe, it, expect } from 'vitest';import {SPRITE_DIRECTIONS, ANCHOR_DIRECTIONS, REFERENCE_FACING, anchorIdForDirection,keyColorPhrase, buildMainReferencePrompt, buildAnchorPrompt, buildTurnaroundPrompt,- TURNAROUND_VIEWS,+ buildWalkVideoPrompt, viewGeometryClause, TURNAROUND_VIEWS,} from './prompts.js';describe('sprite direction contracts', () => {@@ -107,6 +107,23 @@ describe('buildTurnaroundPrompt (#2979)', () => {expect(p).toContain('Use the attached visual reference as the character design.');});+ it('forbids mirroring and gives every panel its own occlusion rule (#3004)', () => {+ const p = buildTurnaroundPrompt({ name: 'Scout', designPrompt: 'a wiry ranger', chromaKey: '#FF00FF' });+ // Rotation, not reflection — the instruction that kills the mirrored-front bug.+ expect(p).toContain('rotated in place about a vertical axis');+ expect(p).toContain('No panel is a horizontal flip, mirror, or copy of another panel');+ // "Same anatomical side" is now paired with where that lands on screen, so+ // the rule can't be satisfied by leaving the item in the same pixels.+ expect(p).toContain('viewer\'s left in the front panel');+ expect(p).toContain('viewer\'s right in the back panel');+ // The reported failure: a front-worn hip bag surviving into the back panel.+ expect(p).toContain('hip bag or pouch worn at the front');+ expect(p).toContain('hidden by the body and must not be drawn');+ TURNAROUND_VIEWS.forEach((view, i) => {+ expect(p).toContain(`Panel ${i + 1} (${REFERENCE_FACING[view]}): ${viewGeometryClause(view)}`);+ });+ });+it('panel order matches SPRITE_DIRECTIONS\' cardinal facings', () => {// The sheet's four panels are the cardinal directions; the three-quarter// facings interpolate between adjacent ones.@@ -115,6 +132,65 @@ describe('buildTurnaroundPrompt (#2979)', () => {});});+describe('viewGeometryClause (#3004)', () => {+ it('hides front-mounted gear from every rear-ish facing', () => {+ for (const d of ['north', 'north-east', 'north-west']) {+ const c = viewGeometryClause(d);+ expect(c).toContain('behind the character');+ expect(c).toContain('hip bag or pouch worn at the front');+ expect(c).toContain('must not be drawn');+ // A mirrored front view keeps the face — say so explicitly.+ expect(c).toContain('no face');+ }+ });++ it('hides back-mounted gear from every front-ish facing', () => {+ for (const d of ['south', 'south-east', 'south-west']) {+ const c = viewGeometryClause(d);+ expect(c).toContain('in front of the character');+ expect(c).toContain('backpack');+ expect(c).not.toContain('no face');+ }+ });++ it('names the near side correctly for each profile', () => {+ // Facing due east the character looks screen-right, so the viewer stands+ // off their right shoulder (face east and south is on your right).+ for (const d of ['east', 'south-east', 'north-east']) {+ expect(viewGeometryClause(d)).toContain('character\'s right side');+ }+ for (const d of ['west', 'south-west', 'north-west']) {+ expect(viewGeometryClause(d)).toContain('character\'s left side');+ }+ });++ it('covers every sprite direction and stays silent on unknown ones', () => {+ for (const d of SPRITE_DIRECTIONS) expect(viewGeometryClause(d)).not.toBe('');+ expect(viewGeometryClause('nowhere')).toBe('');+ });+});++describe('derive prompts carry the geometry rule (#3004)', () => {+ it('appends the facing\'s occlusion rule to every anchor prompt', () => {+ for (const d of ANCHOR_DIRECTIONS) {+ const p = buildAnchorPrompt({ name: 'Scout', direction: d, chromaKey: '#FF00FF' });+ expect(p).toContain('not a mirrored copy of the reference');+ expect(p).toContain(viewGeometryClause(d));+ }+ });++ it('keeps the main reference free of back-mounted gear', () => {+ const p = buildMainReferencePrompt({ name: 'Scout', designPrompt: 'x', chromaKey: '#FF00FF' });+ expect(p).toContain(viewGeometryClause('south'));+ });++ it('stops the walk video from inventing gear the anchor hides', () => {+ const p = buildWalkVideoPrompt({ name: 'Scout', direction: 'north', chromaKey: '#FF00FF' });+ expect(p).toContain('do not add gear that the source image does not show');+ expect(p).toContain('stays hidden for the whole loop');+ });+});+describe('fromTurnaround prompt variants (#2979)', () => {it('tells an anchor to read one panel and emit one figure', () => {const p = buildAnchorPrompt({