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: strengthen playing card identity prompts

[._.]/ Adam Eivy5d1bc444ebcf
diff --git a/client/src/lib/decks.js b/client/src/lib/decks.js
index 283da90e96..31dbb74c0a 100644
--- a/client/src/lib/decks.js
+++ b/client/src/lib/decks.js
@@ -20,6 +20,7 @@ export {
cardStatus,
composeCardRenderPrompt,
defaultDeckCardOrientationPrompt,
+ deckCardIdentityPrompt,
deckCardOrientation,
deckCardOrientationNegativePrompt,
deckCardOrientationPrompt,
diff --git a/server/lib/README.md b/server/lib/README.md
index 0acf065ad9..ce25cdced8 100644
--- a/server/lib/README.md
+++ b/server/lib/README.md
@@ -727,7 +727,7 @@ The barrel `server/lib/index.js` is a machine-checkable enumeration of every pub
| `auditQuality.js` | Category discovery strategies, assessment prompt and strict schema, sentinel parsing, and freshness-aware app quality aggregation with deterministic latest-per-category selection across peers. |
| `mindToolRecipes.js` | Closed recipe schemas, current semantic-contract validation, and safe JSON field binding resolution. |
-| `deckTemplates.js` | Decks (playing cards / tarot): kind alphabet, per-kind card roster (`deckCardRoster`), shared layout and face-orientation prompts (`deckCardOrientationPrompt`), render prompt composition (`composeCardRenderPrompt`), per-card status and `deckCompletion`, plus `deckCardSize` / `deckCardAspectStyle` (persisted trim → thumbnail box). Pure — re-exported by `client/src/lib/decks.js`. |
+| `deckTemplates.js` | Decks (playing cards / tarot): kind alphabet, per-kind card roster (`deckCardRoster`), exact playing-card rank/suit identity cues (`deckCardIdentityPrompt`), shared layout and face-orientation prompts (`deckCardOrientationPrompt`), render prompt composition (`composeCardRenderPrompt`), per-card status and `deckCompletion`, plus `deckCardSize` / `deckCardAspectStyle` (persisted trim → thumbnail box). Pure — re-exported by `client/src/lib/decks.js`. |
| `deckValidation.js` | Zod schemas + limits for the `/api/decks` routes (create/update deck, card patch, sample analysis, prompt generation, render). |
| `kilo.js` | Kilo Code command identity (`kilo`/`kilocode`), `run` headless argv, `--auto` approval posture, and TUI arguments. |
| `openchamber.js` | OpenChamber control-CLI identity, `session create` headless argv, `provider/model` gate, and `--dir`/`--prompt` spawn-time delivery. |
diff --git a/server/lib/deckTemplates.js b/server/lib/deckTemplates.js
index 0352adad21..a3ef3b5899 100644
--- a/server/lib/deckTemplates.js
+++ b/server/lib/deckTemplates.js
@@ -184,6 +184,40 @@ const PLAYING_RANKS = Object.freeze([
{ key: 'K', name: 'King' },
]);
+const PLAYING_SUIT_SHAPES = Object.freeze({
+ spades: Object.freeze({ color: 'black', noun: 'spade', shape: 'pointed leaf with a narrow stem' }),
+ hearts: Object.freeze({ color: 'red', noun: 'heart', shape: 'two rounded lobes and a pointed bottom' }),
+ diamonds: Object.freeze({ color: 'red', noun: 'diamond', shape: 'pointed lozenge' }),
+ clubs: Object.freeze({ color: 'black', noun: 'club', shape: 'three rounded lobes and a short stem' }),
+});
+
+/**
+ * The fixed visual identity a playing-card render must preserve. The stable
+ * roster key is authoritative, so this also repairs renders from older saved
+ * subject prompts that named the card without spelling out its suit or count.
+ */
+export function deckCardIdentityPrompt(deck, card) {
+ if (deck?.kind !== DECK_KIND.PLAYING) return '';
+ const match = /^(spades|hearts|diamonds|clubs)-(A|[2-9]|10|J|Q|K)$/.exec(String(card?.key || ''));
+ if (!match) return '';
+
+ const [, suitKey, rankKey] = match;
+ const suit = PLAYING_SUITS.find((entry) => entry.key === suitKey);
+ const rank = PLAYING_RANKS.find((entry) => entry.key === rankKey);
+ if (!suit || !rank) return '';
+
+ 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.`;
+ 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.`;
+ }
+ 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.`;
+ }
+ 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.`;
+}
+
// Major arcana with the traditional motif each card carries — the prompt
// generator gets these as grounding so a deck stays recognizable as tarot even
// when a universe's cast is placed on the cards.
@@ -313,9 +347,13 @@ export function composeCardRenderPrompt(deck, card) {
const layout = trimmed(deck?.layoutPrompt);
const orientation = deckCardOrientationPrompt(deck);
const orientationNegative = deckCardOrientationNegativePrompt(deck);
- const subject = [trimmed(card?.name), trimmed(card?.prompt)].filter(Boolean).join(': ');
+ const identity = deckCardIdentityPrompt(deck, card);
+ const subject = identity
+ ? [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 cardNegative = [trimmed(card?.negativePrompt), orientationNegative].filter(Boolean).join(', ');
+ const identityNegative = identity ? 'wrong card rank, wrong card suit, incorrect pip count, missing pips, extra pips' : '';
+ 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/services/deckPrompts.js b/server/services/deckPrompts.js
index a488193705..c8ae9af17e 100644
--- a/server/services/deckPrompts.js
+++ b/server/services/deckPrompts.js
@@ -21,7 +21,7 @@ import { ServerError } from '../lib/errorHandler.js';
import { stripPromptControlChars, buildUniverseStyleContext } from './universeBuilder/compile.js';
import { truncDesc } from '../lib/universePromptRenderers.js';
import {
- DECK_KIND, DECK_KIND_LABELS, deckCardOrientation, deckCardOrientationPrompt,
+ DECK_KIND, DECK_KIND_LABELS, deckCardIdentityPrompt, deckCardOrientation, deckCardOrientationPrompt,
} from '../lib/deckTemplates.js';
import { DECK_CARD_PROMPT_MAX } from '../lib/deckValidation.js';
@@ -127,14 +127,20 @@ export function buildCardPromptsPrompt({ deck, roster, targets, universe }) {
: '';
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.'
- : '- Face cards show a full figure; numbered cards arrange that many suit pips into a scene or emblem; Aces are a single large ornate pip; Jokers are jesters of this world.';
+ : '- 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.';
+ const targetLines = targets.map((c) => {
+ const canon = c.canonRef?.name ? ` → depict ${safe(c.canonRef.name)} (${c.canonRef.kind})` : '';
+ const identity = deckCardIdentityPrompt(deck, c);
+ const fixedIdentity = identity ? ` — REQUIRED VISUAL IDENTITY: ${safe(identity)}` : '';
+ return ` - ${c.key}: ${safe(c.name)}${canon}${fixedIdentity}`;
+ });
return `You are a prompt engineer writing image-generation prompts for the cards of a ${DECK_KIND_LABELS[deck.kind] || deck.kind} deck.
${deckContext(deck)}${universeBlock}
# Full roster (for consistency — "→" marks a canon entry already cast on that card)
${roster.map(rosterLine).join('\n')}
# Write prompts for THESE cards only
-${targets.map((c) => ` - ${c.key}: ${safe(c.name)}${c.canonRef?.name ? ` → depict ${safe(c.canonRef.name)} (${c.canonRef.kind})` : ''}`).join('\n')}
+${targetLines.join('\n')}
# Output contract
Return a SINGLE JSON object: { "prompts": [ { "key": "<card key>", "prompt": "<string, max 600 chars>" } ] } — exactly one entry per card in the list above.
@@ -142,6 +148,7 @@ 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.
- 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.