pi-pet-emote 0.1.0 → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +5 -2
- package/docs/package-cover.png +0 -0
- package/emotes/leo/ask/ask_1.png +0 -0
- package/emotes/leo/ask/ask_2.png +0 -0
- package/emotes/leo/build/build_1.png +0 -0
- package/emotes/leo/build/build_2.png +0 -0
- package/emotes/leo/build/build_3.png +0 -0
- package/emotes/leo/bye/bye_1.png +0 -0
- package/emotes/leo/bye/bye_2.png +0 -0
- package/emotes/leo/bye/in_1.png +0 -0
- package/emotes/leo/bye/in_2.png +0 -0
- package/emotes/leo/compact/compact_1.png +0 -0
- package/emotes/leo/compact/compact_2.png +0 -0
- package/emotes/leo/compact/compact_3.png +0 -0
- package/emotes/leo/delegate/delegate_1.png +0 -0
- package/emotes/leo/delegate/delegate_2.png +0 -0
- package/emotes/leo/delegate/delegate_3.png +0 -0
- package/emotes/leo/emotes.json +60 -0
- package/emotes/leo/explore/explore_1.png +0 -0
- package/emotes/leo/explore/explore_2.png +0 -0
- package/emotes/leo/explore/explore_3.png +0 -0
- package/emotes/leo/failure/failure_1.png +0 -0
- package/emotes/leo/failure/failure_2.png +0 -0
- package/emotes/leo/failure/failure_3.png +0 -0
- package/emotes/leo/grandma/in_1.png +0 -0
- package/emotes/leo/grandma/in_2.png +0 -0
- package/emotes/leo/grandma/in_3.png +0 -0
- package/emotes/leo/grandma/knit_1.png +0 -0
- package/emotes/leo/grandma/knit_2.png +0 -0
- package/emotes/leo/hi/in_1.png +0 -0
- package/emotes/leo/hi/in_2.png +0 -0
- package/emotes/leo/hi/in_3.png +0 -0
- package/emotes/leo/hi/in_4.png +0 -0
- package/emotes/leo/hi/in_5.png +0 -0
- package/emotes/leo/hi/in_6.png +0 -0
- package/emotes/leo/hi/landed_1.png +0 -0
- package/emotes/leo/hi/landed_2.png +0 -0
- package/emotes/leo/idle/idle.png +0 -0
- package/emotes/leo/idle/idle_blink.png +0 -0
- package/emotes/leo/jira/jira_1.png +0 -0
- package/emotes/leo/jira/jira_2.png +0 -0
- package/emotes/leo/jira/jira_3.png +0 -0
- package/emotes/leo/jobs/jobs_1.png +0 -0
- package/emotes/leo/jobs/jobs_2.png +0 -0
- package/emotes/leo/jobs/jobs_3.png +0 -0
- package/emotes/leo/judge/judge_1.png +0 -0
- package/emotes/leo/judge/judge_2.png +0 -0
- package/emotes/leo/read/read_1.png +0 -0
- package/emotes/leo/read/read_2.png +0 -0
- package/emotes/leo/read/read_3.png +0 -0
- package/emotes/leo/remember/remember_1.png +0 -0
- package/emotes/leo/remember/remember_2.png +0 -0
- package/emotes/leo/review/review_1.png +0 -0
- package/emotes/leo/review/review_2.png +0 -0
- package/emotes/leo/review/review_3.png +0 -0
- package/emotes/leo/review/review_4.png +0 -0
- package/emotes/leo/success/success_1.png +0 -0
- package/emotes/leo/success/success_2.png +0 -0
- package/emotes/leo/super-yolo/super-yolo.png +0 -0
- package/emotes/leo/super-yolo/super-yolo_blink.png +0 -0
- package/emotes/leo/talk/talk_close.png +0 -0
- package/emotes/leo/talk/talk_mid.png +0 -0
- package/emotes/leo/talk/talk_small.png +0 -0
- package/emotes/leo/talk/talk_wide.png +0 -0
- package/emotes/leo/think/think_1.png +0 -0
- package/emotes/leo/think/think_2.png +0 -0
- package/emotes/leo/tool/tool_1.png +0 -0
- package/emotes/leo/tool/tool_2.png +0 -0
- package/emotes/leo/tool/tool_3.png +0 -0
- package/emotes/leo/verify/fail.png +0 -0
- package/emotes/leo/verify/verify_1.png +0 -0
- package/emotes/leo/verify/verify_2.png +0 -0
- package/emotes/leo/verify/verify_3.png +0 -0
- package/emotes/leo/write/write_1.png +0 -0
- package/emotes/leo/write/write_2.png +0 -0
- package/emotes/leo/write/write_3.png +0 -0
- package/emotes/leo/write/write_4.png +0 -0
- package/emotes/leo/yolo/yolo.png +0 -0
- package/emotes/leo/yolo/yolo_blink.png +0 -0
- package/package.json +5 -4
- package/src/index.ts +33 -6
- package/src/pet-selection.ts +35 -0
package/README.md
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
# pi-pet-emote
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Meet **Mafe the dog** and **Leo the cat**, reactive pixel-art companions beside your [Pi](https://pi.dev) prompt. Choose either pet: 24 reactions follow local session events—thinking, tools, questions, and results—with no model calls.
|
|
4
4
|
|
|
5
|
-

|
|
6
6
|
|
|
7
7
|
Requires Node.js **22.19+** and an interactive Pi session. Image support depends on your terminal; ASCII is the fallback.
|
|
8
8
|
|
|
@@ -43,10 +43,13 @@ Run `/reload` in Pi to unload the extension.
|
|
|
43
43
|
| Command | Action |
|
|
44
44
|
| --- | --- |
|
|
45
45
|
| `/emote` | List available reactions. |
|
|
46
|
+
| `/emote pet` | Choose Mafe or Leo; the active pet is marked. |
|
|
46
47
|
| `/emote <state>` | Preview a reaction. |
|
|
47
48
|
| `/emote demo` | Play the reaction sequence. |
|
|
48
49
|
| `/emote idle` | Stop the preview and return to idle. |
|
|
49
50
|
|
|
51
|
+
Choosing a different pet switches immediately and stops any preview. Canceling or choosing the active pet changes nothing. Reactions, `demo`, and `idle` use the selected pet in this and future sessions.
|
|
52
|
+
|
|
50
53
|
## License
|
|
51
54
|
|
|
52
55
|
[MIT](LICENSE). Original code by Eiji Onchi and efolchmontiel; contributions by offluisangel.
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
{
|
|
2
|
+
"idle": {
|
|
3
|
+
"default": "idle.png",
|
|
4
|
+
"blink": "idle_blink.png"
|
|
5
|
+
},
|
|
6
|
+
"talk": {
|
|
7
|
+
"weights": {
|
|
8
|
+
"talk_close.png": 1,
|
|
9
|
+
"talk_small.png": 3,
|
|
10
|
+
"talk_mid.png": 3,
|
|
11
|
+
"talk_wide.png": 1
|
|
12
|
+
}
|
|
13
|
+
},
|
|
14
|
+
"cycle": {
|
|
15
|
+
"hi": "loop",
|
|
16
|
+
"think": "loop",
|
|
17
|
+
"tool": "loop",
|
|
18
|
+
"write": "loop",
|
|
19
|
+
"ask": "loop",
|
|
20
|
+
"success": "loop",
|
|
21
|
+
"failure": "loop",
|
|
22
|
+
"read": "pingpong",
|
|
23
|
+
"compact": "pingpong",
|
|
24
|
+
"delegate": "loop",
|
|
25
|
+
"jobs": "loop",
|
|
26
|
+
"remember": "loop",
|
|
27
|
+
"yolo": "loop",
|
|
28
|
+
"super-yolo": "loop",
|
|
29
|
+
"explore": "loop",
|
|
30
|
+
"build": "loop",
|
|
31
|
+
"verify": "loop",
|
|
32
|
+
"judge": "loop",
|
|
33
|
+
"review": "loop",
|
|
34
|
+
"jira": "loop"
|
|
35
|
+
},
|
|
36
|
+
"frameMs": {
|
|
37
|
+
"hi": 280,
|
|
38
|
+
"think": 420,
|
|
39
|
+
"tool": 260,
|
|
40
|
+
"write": 240,
|
|
41
|
+
"read": 450,
|
|
42
|
+
"ask": 800,
|
|
43
|
+
"success": 420,
|
|
44
|
+
"failure": 380,
|
|
45
|
+
"compact": 380,
|
|
46
|
+
"grandma": 520,
|
|
47
|
+
"bye": 650,
|
|
48
|
+
"delegate": 320,
|
|
49
|
+
"jobs": 900,
|
|
50
|
+
"remember": 800,
|
|
51
|
+
"yolo": 1100,
|
|
52
|
+
"super-yolo": 1100,
|
|
53
|
+
"explore": 420,
|
|
54
|
+
"build": 280,
|
|
55
|
+
"verify": 360,
|
|
56
|
+
"judge": 450,
|
|
57
|
+
"review": 1200,
|
|
58
|
+
"jira": 380
|
|
59
|
+
}
|
|
60
|
+
}
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "pi-pet-emote",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"description": "
|
|
3
|
+
"version": "0.2.0",
|
|
4
|
+
"description": "Mafe the dog and Leo the cat: reactive pixel-art pets for Pi, driven by local session events with no model calls.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": {
|
|
7
7
|
"type": "git",
|
|
@@ -18,7 +18,7 @@
|
|
|
18
18
|
},
|
|
19
19
|
"scripts": {
|
|
20
20
|
"test": "node --test \"tests/*.test.ts\"",
|
|
21
|
-
"sprites": "python3 -B scripts/sprites/build.py",
|
|
21
|
+
"sprites": "python3 -B scripts/sprites/build.py && node scripts/sprites/leo.ts",
|
|
22
22
|
"scenes": "node scripts/sprites/scenes.ts",
|
|
23
23
|
"pack:check": "node scripts/check-package.mjs",
|
|
24
24
|
"check:generated": "node scripts/check-generated.mjs"
|
|
@@ -38,12 +38,13 @@
|
|
|
38
38
|
"src",
|
|
39
39
|
"emotes",
|
|
40
40
|
"docs/avatar.png",
|
|
41
|
+
"docs/package-cover.png",
|
|
41
42
|
"config.json",
|
|
42
43
|
"README.md",
|
|
43
44
|
"LICENSE"
|
|
44
45
|
],
|
|
45
46
|
"pi": {
|
|
46
|
-
"image": "
|
|
47
|
+
"image": "https://cdn.jsdelivr.net/npm/pi-pet-emote@0.2.0/docs/package-cover.png",
|
|
47
48
|
"extensions": ["./src/index.ts"]
|
|
48
49
|
},
|
|
49
50
|
"devDependencies": {
|
package/src/index.ts
CHANGED
|
@@ -8,6 +8,7 @@ import type { Config, EmoteState, ResolvedRenderer } from "./types.ts";
|
|
|
8
8
|
import type { Renderer } from "./renderer.ts";
|
|
9
9
|
import { log, setDebug } from "./log.ts";
|
|
10
10
|
import { loadLayeredConfig } from "./config.ts";
|
|
11
|
+
import { PETS, loadPetSelection, savePetSelection } from "./pet-selection.ts";
|
|
11
12
|
import { resolveEmoteSet, findEmoteSetDir, findYoloSetDir, loadEmotesConfig, EXTENSION_NAME } from "./emotes.ts";
|
|
12
13
|
import { bannerConfigCandidates, createAccentTransform, resolveAccent } from "./accent.ts";
|
|
13
14
|
import type { Rgb } from "./accent.ts";
|
|
@@ -78,6 +79,7 @@ const EMOTE_DESCRIPTIONS: Record<string, string> = {
|
|
|
78
79
|
review: "marks a page in pink (review-* subagents)",
|
|
79
80
|
jira: "moves between task cards (jira subagents)",
|
|
80
81
|
demo: "plays every state in a row",
|
|
82
|
+
pet: "choose Mafe or Leo (saved for future sessions)",
|
|
81
83
|
};
|
|
82
84
|
|
|
83
85
|
/** Check if a set directory contains any image frames (PNG files in state subdirs). */
|
|
@@ -152,7 +154,8 @@ export default function (pi: ExtensionAPI) {
|
|
|
152
154
|
|
|
153
155
|
if (!config.enabled) return;
|
|
154
156
|
|
|
155
|
-
let
|
|
157
|
+
let selectedPet = loadPetSelection();
|
|
158
|
+
let currentEmoteSet: string = selectedPet ?? "pet";
|
|
156
159
|
let widgetActive = false;
|
|
157
160
|
let lastResolved = resolveRenderer(config.terminals, userConfiguredTerminals);
|
|
158
161
|
let renderer = createRendererFromResolved(lastResolved, config);
|
|
@@ -203,7 +206,7 @@ export default function (pi: ExtensionAPI) {
|
|
|
203
206
|
}
|
|
204
207
|
|
|
205
208
|
function switchEmoteSet(modelId: string, thinkingLevel: string) {
|
|
206
|
-
const setName = resolveEmoteSet(modelId, thinkingLevel, config.emotes);
|
|
209
|
+
const setName = selectedPet ?? resolveEmoteSet(modelId, thinkingLevel, config.emotes);
|
|
207
210
|
if (setName === currentEmoteSet) return;
|
|
208
211
|
loadEmoteSet(setName);
|
|
209
212
|
log(`switchEmoteSet: loaded "${setName}", state="${animator.currentState}"`);
|
|
@@ -352,9 +355,9 @@ export default function (pi: ExtensionAPI) {
|
|
|
352
355
|
}
|
|
353
356
|
|
|
354
357
|
pi.registerCommand?.("emote", {
|
|
355
|
-
description: "Preview a pi-pet-emote
|
|
358
|
+
description: "Preview or choose a pi-pet-emote pet: /emote <state> | demo | pet",
|
|
356
359
|
getArgumentCompletions: (prefix: string) =>
|
|
357
|
-
[...EMOTE_STATES, "demo"]
|
|
360
|
+
[...EMOTE_STATES, "demo", "pet"]
|
|
358
361
|
.filter((name) => name.startsWith(prefix.trim()))
|
|
359
362
|
.map((name) => ({ value: name, label: name, description: EMOTE_DESCRIPTIONS[name] })),
|
|
360
363
|
handler: async (args: string, ctx: any) => {
|
|
@@ -363,6 +366,29 @@ export default function (pi: ExtensionAPI) {
|
|
|
363
366
|
ctx.ui?.notify?.(`[${EXTENSION_NAME}] avatar inactive (no UI or disabled)`, "warning");
|
|
364
367
|
return;
|
|
365
368
|
}
|
|
369
|
+
if (name === "pet") {
|
|
370
|
+
if (!ctx.hasUI) return;
|
|
371
|
+
const options = PETS.map((pet) => `${pet.name}${pet.id === currentEmoteSet ? " (active)" : ""}`);
|
|
372
|
+
const choice = await ctx.ui.select("Choose pet", options);
|
|
373
|
+
const pet = PETS.find((_pet, index) => options[index] === choice);
|
|
374
|
+
if (!pet || pet.id === currentEmoteSet) return;
|
|
375
|
+
try {
|
|
376
|
+
savePetSelection(pet.id);
|
|
377
|
+
} catch (error) {
|
|
378
|
+
ctx.ui.notify(`[${EXTENSION_NAME}] Could not save pet selection: ${error instanceof Error ? error.message : String(error)}`, "error");
|
|
379
|
+
return;
|
|
380
|
+
}
|
|
381
|
+
selectedPet = pet.id;
|
|
382
|
+
clearPreview();
|
|
383
|
+
if (greetTimer) { clearTimeout(greetTimer); greetTimer = null; }
|
|
384
|
+
if (farewellTimer) { clearTimeout(farewellTimer); farewellTimer = null; }
|
|
385
|
+
farewell = false;
|
|
386
|
+
animator.clearAllTimers();
|
|
387
|
+
loadEmoteSet(pet.id);
|
|
388
|
+
animator.resetRenderCache();
|
|
389
|
+
animator.transitionTo("idle");
|
|
390
|
+
return;
|
|
391
|
+
}
|
|
366
392
|
if (name === "demo") {
|
|
367
393
|
playDemo();
|
|
368
394
|
return;
|
|
@@ -371,7 +397,7 @@ export default function (pi: ExtensionAPI) {
|
|
|
371
397
|
previewState(name as EmoteState);
|
|
372
398
|
return;
|
|
373
399
|
}
|
|
374
|
-
ctx.ui?.notify?.(`[${EXTENSION_NAME}] /emote <state>: ${[...EMOTE_STATES, "demo"].join(", ")}`, "info");
|
|
400
|
+
ctx.ui?.notify?.(`[${EXTENSION_NAME}] /emote <state>: ${[...EMOTE_STATES, "demo", "pet"].join(", ")}`, "info");
|
|
375
401
|
},
|
|
376
402
|
});
|
|
377
403
|
|
|
@@ -401,7 +427,8 @@ export default function (pi: ExtensionAPI) {
|
|
|
401
427
|
ctx.ui.notify(`[${EXTENSION_NAME}] No image protocol detected \u2014 using ASCII emotes.`, "warning");
|
|
402
428
|
}
|
|
403
429
|
|
|
404
|
-
|
|
430
|
+
selectedPet = loadPetSelection();
|
|
431
|
+
const setName = selectedPet ?? resolveEmoteSet(ctx.model?.id ?? "", pi.getThinkingLevel(), config.emotes);
|
|
405
432
|
log(`session_start: set="${setName}" dir="${findEmoteSetDir(setName, extDir, cwd)}"`);
|
|
406
433
|
unwatchYolo();
|
|
407
434
|
loadEmoteSet(setName);
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { mkdirSync, readFileSync, renameSync, unlinkSync, writeFileSync } from "node:fs";
|
|
2
|
+
import { randomUUID } from "node:crypto";
|
|
3
|
+
import { dirname, join } from "node:path";
|
|
4
|
+
import { agentDir, EXTENSION_NAME } from "./emotes.ts";
|
|
5
|
+
|
|
6
|
+
export const PETS = [
|
|
7
|
+
{ id: "pet", name: "Mafe" },
|
|
8
|
+
{ id: "leo", name: "Leo" },
|
|
9
|
+
] as const;
|
|
10
|
+
type PetId = typeof PETS[number]["id"];
|
|
11
|
+
|
|
12
|
+
const selectionPath = () => join(agentDir(), "extensions", EXTENSION_NAME, "pet-selection.json");
|
|
13
|
+
|
|
14
|
+
export function loadPetSelection(): PetId | undefined {
|
|
15
|
+
try {
|
|
16
|
+
const value = JSON.parse(readFileSync(selectionPath(), "utf8"))?.pet;
|
|
17
|
+
return PETS.find((pet) => pet.id === value)?.id;
|
|
18
|
+
} catch {
|
|
19
|
+
return undefined;
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
/** Keep this extension-owned preference separate from layered user configuration. */
|
|
24
|
+
export function savePetSelection(pet: PetId): void {
|
|
25
|
+
if (!PETS.some((entry) => entry.id === pet)) throw new Error("Invalid pet selection");
|
|
26
|
+
const path = selectionPath();
|
|
27
|
+
const temporary = `${path}.${randomUUID()}.tmp`;
|
|
28
|
+
mkdirSync(dirname(path), { recursive: true });
|
|
29
|
+
try {
|
|
30
|
+
writeFileSync(temporary, `${JSON.stringify({ pet })}\n`, { flag: "wx", mode: 0o600 });
|
|
31
|
+
renameSync(temporary, path);
|
|
32
|
+
} finally {
|
|
33
|
+
try { unlinkSync(temporary); } catch { /* renamed or never created */ }
|
|
34
|
+
}
|
|
35
|
+
}
|