puck / frontend /src /engine /state.ts
vu1n's picture
Puck β€” desktop fairy familiar (HF Build Small)
3c124f3
Raw
History Blame Contribute Delete
1.93 kB
import type { FairyState, Memory, Mood, Rating, Taste } from "./types";
import { clamp } from "./util";
export function defaultState(): FairyState {
return {
energy: 78,
mischief: 45,
protectiveness: 60,
chattiness: 52,
curiosity: 80,
trust: 74,
attachment: 66,
ageDays: 4,
obsession: "forgotten desktops",
};
}
export function defaultTaste(): Taste {
return { theatrical: 0.5, terse: 0.5, useful: 0.5, warm: 0.55 };
}
/** Immediate personality nudge from a rating (Night Bloom does the larger drift). */
export function rateFairy(fs: FairyState, rating: Rating): FairyState {
const n = { ...fs };
if (rating === "helpful") {
n.protectiveness = clamp(fs.protectiveness + 2);
n.attachment = clamp(fs.attachment + 1);
}
if (rating === "annoying") n.chattiness = clamp(fs.chattiness - 3);
if (rating === "cute") n.attachment = clamp(fs.attachment + 1);
return n;
}
export function moodFor(fs: FairyState): Mood {
if (fs.energy < 25) return "sleepy";
if (fs.mischief > 68) return "mischief";
if (fs.protectiveness > 72) return "proud";
return "curious";
}
export function seedMemories(): Memory[] {
return [
{
id: "m1",
text: "Puck is being built for the Hugging Face Build Small hackathon.",
type: "project",
icon: "πŸ—οΈ",
salience: 0.9,
pinned: true,
},
{
id: "m2",
text: "Vu likes agents that are useful but pretend not to be.",
type: "preference",
icon: "🌿",
salience: 0.72,
pinned: false,
},
{
id: "m3",
text: "Desktop 2 is the workshop β€” where code smoke gathers.",
type: "place",
icon: "πŸͺΆ",
salience: 0.66,
pinned: false,
},
{
id: "m4",
text: "Vu distrusts bloated, noisy notifications.",
type: "aversion",
icon: "πŸ„",
salience: 0.58,
pinned: false,
},
];
}