Skip to content

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

fix: pin playing-card pip counts to the classic layout and ban extra suit shapes

[._.]/ Adam Eivydbb753dc80e7
diff --git a/server/lib/deckTemplates.js b/server/lib/deckTemplates.js
index a3ef3b5899..503e2ed43c 100644
--- a/server/lib/deckTemplates.js
+++ b/server/lib/deckTemplates.js
@@ -191,6 +191,21 @@ const PLAYING_SUIT_SHAPES = Object.freeze({
clubs: Object.freeze({ color: 'black', noun: 'club', shape: 'three rounded lobes and a short stem' }),
});
+// The traditional pip layout for each numbered rank. Naming the arrangement
+// gives an image model a concrete structure to fill, which it follows far more
+// reliably than a bare count — "exactly 6" alone kept rendering 8–10 pips.
+const PIP_LAYOUTS = Object.freeze({
+ 2: 'one pip at the top center and one at the bottom center',
+ 3: 'a single vertical column of three pips down the center',
+ 4: 'two vertical columns of two pips, one pip near each corner of the central field',
+ 5: 'two vertical columns of two pips plus one pip in the exact center',
+ 6: 'two vertical columns of three pips, left and right, with nothing between them',
+ 7: 'two vertical columns of three pips plus one pip centered between the top and middle rows',
+ 8: 'two vertical columns of three pips plus two center pips, one between the top and middle rows and one between the middle and bottom rows',
+ 9: 'two vertical columns of four pips plus one pip in the exact center',
+ 10: 'two vertical columns of four pips plus two center pips, one in the upper gap and one in the lower gap',
+});
+
/**
* The fixed visual identity a playing-card render must preserve. The stable
* roster key is authoritative, so this also repairs renders from older saved
@@ -208,12 +223,13 @@ export function deckCardIdentityPrompt(deck, card) {
const pip = PLAYING_SUIT_SHAPES[suitKey];
const cardName = `${rank.name} of ${suit.name}`;
- const cornerIndex = `Both corner indices show the exact rank ${rankKey} beside one matching ${suit.symbol} suit mark.`;
+ const cornerIndex = `Both corner indices show the exact rank ${rankKey} beside one small matching ${suit.symbol} suit mark.`;
if (rankKey === 'A') {
- return `Fixed identity: ${cardName}. Show one large ornate ${pip.color} ${pip.noun} emblem (${suit.symbol}), shaped as a ${pip.shape}, in the center; do not repeat it as a pip field. ${cornerIndex} Show no other suit.`;
+ return `Fixed identity: ${cardName}. Show one large ornate ${pip.color} ${pip.noun} emblem (${suit.symbol}), shaped as a ${pip.shape}, in the center; do not repeat it as a pip field. ${cornerIndex} Apart from that emblem and the two corner marks, no other ${pip.noun} shapes appear anywhere. Show no other suit.`;
}
if (/^\d+$/.test(rankKey)) {
- return `Fixed identity: ${cardName}. Show exactly ${rankKey} separate ${pip.color} ${pip.noun}-shaped pips in the central field, each a ${pip.shape}; count them literally, with none missing or added. ${cornerIndex} Show no other suit or pip count.`;
+ const total = Number(rankKey) + 2;
+ return `Fixed identity: ${cardName}. Exactly ${rankKey} large ${pip.color} ${pip.noun} pips (${suit.symbol}), each a ${pip.shape}, printed flat on the card face in the classic playing-card arrangement: ${PIP_LAYOUTS[rankKey]}. The pips are graphic suit symbols, not objects in the scene; any illustration sits behind or between them and contains no ${pip.noun} shapes. ${cornerIndex} The whole card shows exactly ${total} ${pip.noun} symbols in total (${rankKey} pips plus the 2 corner marks) and no ${pip.noun} motifs in the border, background or scene. Show no other suit.`;
}
return `Fixed identity: ${cardName}. Show one full ${rank.name.toLowerCase()} figure as the central subject, with ${pip.color} ${pip.noun} emblems shaped as a ${pip.shape}. ${cornerIndex} Do not replace the face rank with a numbered pip field or show another suit.`;
}
@@ -352,7 +368,7 @@ export function composeCardRenderPrompt(deck, card) {
? [identity, trimmed(card?.prompt)].filter(Boolean).join(' ')
: [trimmed(card?.name), trimmed(card?.prompt)].filter(Boolean).join(': ');
const body = [layout, orientation, subject].filter(Boolean).join('. ');
- const identityNegative = identity ? 'wrong card rank, wrong card suit, incorrect pip count, missing pips, extra pips' : '';
+ const identityNegative = identity ? 'wrong card rank, wrong card suit, incorrect pip count, missing pips, extra pips, extra suit symbols, suit symbols in the border or background, pips disguised as scene objects' : '';
const cardNegative = [trimmed(card?.negativePrompt), orientationNegative, identityNegative].filter(Boolean).join(', ');
const composed = composeStyledPrompt(body, cardNegative, { prompt: style, negativePrompt: avoid });
return { ...composed, parts: { style, layout, orientation, subject } };
diff --git a/server/lib/deckTemplates.test.js b/server/lib/deckTemplates.test.js
index 08a53ee309..f453b55671 100644
--- a/server/lib/deckTemplates.test.js
+++ b/server/lib/deckTemplates.test.js
@@ -70,6 +70,19 @@ describe('composeCardRenderPrompt', () => {
expect(out.parts.orientation).toBe(defaultDeckCardOrientationPrompt({ kind: DECK_KIND.PLAYING }));
});
+ it('pins a numbered card to its classic pip layout and total suit-symbol count, ahead of a scene that disguises pips', () => {
+ const out = composeCardRenderPrompt(
+ { kind: DECK_KIND.PLAYING },
+ { key: 'spades-6', name: 'Six of Spades', prompt: 'six spade pips as rooftop pennants along a parapet' },
+ );
+ expect(out.parts.subject).toMatch(/^Fixed identity: Six of Spades\. Exactly 6 large black spade pips/);
+ expect(out.parts.subject).toContain('two vertical columns of three pips');
+ expect(out.parts.subject).toContain('exactly 8 spade symbols in total (6 pips plus the 2 corner marks)');
+ expect(out.parts.subject).toContain('not objects in the scene');
+ expect(out.negativePrompt).toContain('pips disguised as scene objects');
+ expect(out.negativePrompt).toContain('suit symbols in the border or background');
+ });
+
it('supports one-way faces and a true authored prompt override', () => {
const oneWay = composeCardRenderPrompt(
{ kind: DECK_KIND.PLAYING, cardOrientation: DECK_CARD_ORIENTATION.ONE_WAY },
diff --git a/server/services/deckPrompts.js b/server/services/deckPrompts.js
index c8ae9af17e..2ac336a66c 100644
--- a/server/services/deckPrompts.js
+++ b/server/services/deckPrompts.js
@@ -126,8 +126,8 @@ export function buildCardPromptsPrompt({ deck, roster, targets, universe }) {
? `${buildUniverseStyleContext(universe, { includePremise: true, includeEmbrace: false, escape: true, headerSuffix: 'the deck illustrates this universe' })}\n# Canon this deck draws on\n${renderCanonRoster(universe) || '(none)'}\n`
: '';
const kindRules = deck.kind === DECK_KIND.TAROT
- ? '- Keep each card recognizable as its tarot archetype (use the traditional motif as the skeleton) while dressing it in the deck\'s world; numbered pips show that many of the suit\'s emblem arranged meaningfully.'
- : '- Playing-card identity is exact: for each numbered rank 2–10, describe exactly that many distinct pips of the named suit; name the suit shape and color, and never add, omit or substitute pips. Aces show one large suit pip, face cards show the named rank as a full figure, and Jokers are jesters of this world.';
+ ? '- Keep each card recognizable as its tarot archetype (use the traditional motif as the skeleton) while dressing it in the deck\'s world; numbered pips show that many of the suit\'s emblem arranged meaningfully.\n- Cards of one suit should share a visual through-line (a recurring emblem, setting or color accent) so the suit reads as a family.'
+ : '- Playing-card identity is exact: for each numbered rank 2–10, state exactly that many pips of the named suit in the classic arrangement given on its target line, with the suit shape and color; never add, omit or substitute pips. Pips are flat printed suit symbols on the card face — never disguise them as scene objects (lanterns, pennants, windows, leaves), and never put any other suit-shaped object in the scene, border or background, because every extra suit shape reads as an extra pip. The world or canon scene is a restrained vignette behind or between the pips. Aces show one large suit pip, face cards show the named rank as a full figure, and Jokers are jesters of this world.\n- Cards of one suit share a visual through-line (a recurring setting, color accent or non-suit-shaped emblem) so the suit reads as a family.';
const targetLines = targets.map((c) => {
const canon = c.canonRef?.name ? ` → depict ${safe(c.canonRef.name)} (${c.canonRef.kind})` : '';
const identity = deckCardIdentityPrompt(deck, c);
@@ -148,9 +148,8 @@ Return a SINGLE JSON object: { "prompts": [ { "key": "<card key>", "prompt": "<s
# Rules
- "prompt" describes the SUBJECT of the card only — figures, pose, setting, symbols, composition, the suit emblem count — as comma-separated renderable phrases. The deck's style tokens, shared layout and face-orientation instructions are prepended automatically at render time, so do NOT repeat style, medium, palette, border, index/title or orientation instructions.
${kindRules}
-- For playing cards, the REQUIRED VISUAL IDENTITY on each target line is authoritative; include its exact pip count and suit description in the subject prompt even when the canon scene or visual motif suggests another arrangement.
+- For playing cards, the REQUIRED VISUAL IDENTITY on each target line is authoritative; open the subject prompt with its exact pip count, arrangement and suit description even when the canon scene or visual motif suggests another arrangement.
- When a card is cast with a canon entry, depict that entry faithfully to its description; otherwise invent a subject that belongs in this deck's world.
-- Cards of one suit should share a visual through-line (a recurring emblem, setting or color accent) so the suit reads as a family.
- No text instructions, no camera jargon. Never use double-quote characters inside a prompt string.
- Output JUST the JSON object — no markdown, no commentary.`;
}