@ramarivera/coding-buddy 0.4.0-alpha.4 → 0.4.0-alpha.6
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/adapters/claude/plugin/marketplace.json +2 -2
- package/adapters/claude/plugin/plugin.json +1 -1
- package/adapters/claude/server/index.ts +1 -1
- package/adapters/pi/commands.ts +1 -1
- package/adapters/pi/events.ts +180 -13
- package/adapters/pi/prompt.ts +42 -0
- package/core/command-service.ts +34 -0
- package/core/reactions.ts +55 -0
- package/package.json +1 -1
|
@@ -5,14 +5,14 @@
|
|
|
5
5
|
},
|
|
6
6
|
"metadata": {
|
|
7
7
|
"description": "Permanent coding companion for Claude Code",
|
|
8
|
-
"version": "0.
|
|
8
|
+
"version": "0.4.0-alpha.6"
|
|
9
9
|
},
|
|
10
10
|
"plugins": [
|
|
11
11
|
{
|
|
12
12
|
"name": "claude-buddy",
|
|
13
13
|
"source": "./",
|
|
14
14
|
"description": "Permanent coding companion for Claude Code \u2014 survives any update. MCP-based terminal pet with ASCII art, stats, reactions, and personality.",
|
|
15
|
-
"version": "0.
|
|
15
|
+
"version": "0.4.0-alpha.6",
|
|
16
16
|
"author": {
|
|
17
17
|
"name": "1270011"
|
|
18
18
|
},
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "claude-buddy",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.4.0-alpha.6"
|
|
4
4
|
"description": "Permanent coding companion for Claude Code \u2014 survives any update. MCP-based terminal pet with ASCII art, stats, reactions, and personality.",
|
|
5
5
|
"author": {
|
|
6
6
|
"name": "1270011"
|
package/adapters/pi/commands.ts
CHANGED
|
@@ -81,7 +81,7 @@ export function registerBuddyCommands(pi: ExtensionAPI, deps: RegisterBuddyComma
|
|
|
81
81
|
case "on": {
|
|
82
82
|
deps.service.incrementCommandsRun();
|
|
83
83
|
deps.storage.setMuted(false);
|
|
84
|
-
const result = deps.service.
|
|
84
|
+
const result = deps.service.recordComment("*stretches* I'm back!");
|
|
85
85
|
deps.ui.refresh(ctx, result.companion, result.state, result.achievements);
|
|
86
86
|
ctx.ui.notify(`${result.companion.name} is back.`, "info");
|
|
87
87
|
deps.ui.notifyAchievements(ctx, result.achievements);
|
package/adapters/pi/events.ts
CHANGED
|
@@ -8,8 +8,14 @@ import type {
|
|
|
8
8
|
TurnEndEvent,
|
|
9
9
|
} from "@mariozechner/pi-coding-agent";
|
|
10
10
|
import { isBashToolResult } from "@mariozechner/pi-coding-agent";
|
|
11
|
+
import type { AgentMessage } from "@mariozechner/pi-agent-core";
|
|
12
|
+
import { complete, type AssistantMessage, type TextContent, type UserMessage } from "@mariozechner/pi-ai";
|
|
11
13
|
import { BuddyCommandService } from "../../core/command-service.ts";
|
|
14
|
+
import type { Achievement } from "../../core/achievements.ts";
|
|
15
|
+
import type { Companion } from "../../core/model.ts";
|
|
16
|
+
import { getNameReaction, getSuccessReaction } from "../../core/reactions.ts";
|
|
12
17
|
import { PiBuddyStorage } from "./storage.ts";
|
|
18
|
+
import { buildBuddyReactionPrompt, normalizeBuddyComment, stripBuddyComments } from "./prompt.ts";
|
|
13
19
|
import { PiBuddyUI } from "./ui.ts";
|
|
14
20
|
|
|
15
21
|
interface RegisterBuddyEventsDeps {
|
|
@@ -39,11 +45,8 @@ export function registerBuddyEvents(pi: ExtensionAPI, deps: RegisterBuddyEventsD
|
|
|
39
45
|
return { action: "continue" };
|
|
40
46
|
}
|
|
41
47
|
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
const result = deps.service.recordNameMention();
|
|
48
|
+
const reaction = getNameReaction(companion.bones.species);
|
|
49
|
+
const result = deps.service.recordComment(reaction, "turn");
|
|
47
50
|
deps.ui.refresh(ctx, result.companion, result.state, result.achievements);
|
|
48
51
|
deps.ui.notifyAchievements(ctx, result.achievements);
|
|
49
52
|
return { action: "continue" };
|
|
@@ -57,8 +60,10 @@ export function registerBuddyEvents(pi: ExtensionAPI, deps: RegisterBuddyEventsD
|
|
|
57
60
|
| ReturnType<BuddyCommandService["recordToolError"]>
|
|
58
61
|
| ReturnType<BuddyCommandService["recordTestFailure"]>
|
|
59
62
|
| ReturnType<BuddyCommandService["recordLargeDiff"]>
|
|
63
|
+
| ReturnType<BuddyCommandService["recordComment"]>
|
|
60
64
|
| undefined;
|
|
61
65
|
|
|
66
|
+
const companion = deps.service.ensureCompanion().companion;
|
|
62
67
|
if (event.isError) {
|
|
63
68
|
result = deps.service.recordToolError(undefined, firstLineNumber(text));
|
|
64
69
|
} else if (looksLikeTestFailure(text)) {
|
|
@@ -67,6 +72,8 @@ export function registerBuddyEvents(pi: ExtensionAPI, deps: RegisterBuddyEventsD
|
|
|
67
72
|
const diffLines = extractLargeDiffLines(text);
|
|
68
73
|
if (diffLines >= 80) {
|
|
69
74
|
result = deps.service.recordLargeDiff(diffLines);
|
|
75
|
+
} else if (looksLikeSuccess(text)) {
|
|
76
|
+
result = deps.service.recordComment(getSuccessReaction(companion.bones.species), "turn");
|
|
70
77
|
}
|
|
71
78
|
}
|
|
72
79
|
|
|
@@ -75,25 +82,28 @@ export function registerBuddyEvents(pi: ExtensionAPI, deps: RegisterBuddyEventsD
|
|
|
75
82
|
deps.ui.notifyAchievements(ctx, result.achievements);
|
|
76
83
|
});
|
|
77
84
|
|
|
78
|
-
pi.on("turn_end", async (
|
|
79
|
-
const
|
|
85
|
+
pi.on("turn_end", async (event: TurnEndEvent, ctx: ExtensionContext) => {
|
|
86
|
+
const progress = deps.service.recordTurnOnly();
|
|
80
87
|
if (deps.storage.isMuted()) {
|
|
81
|
-
deps.ui.refresh(ctx,
|
|
88
|
+
deps.ui.refresh(ctx, progress.companion, null, progress.achievements);
|
|
82
89
|
return;
|
|
83
90
|
}
|
|
84
91
|
|
|
85
92
|
if (!shouldEmitPassiveReaction(deps.storage)) {
|
|
86
|
-
deps.ui.refresh(ctx,
|
|
93
|
+
deps.ui.refresh(ctx, progress.companion, deps.storage.loadLatest(), progress.achievements);
|
|
87
94
|
return;
|
|
88
95
|
}
|
|
89
96
|
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
deps.ui.
|
|
97
|
+
const comment = await generateTurnComment(ctx, progress.companion, event);
|
|
98
|
+
if (!comment) {
|
|
99
|
+
deps.ui.refresh(ctx, progress.companion, deps.storage.loadLatest(), progress.achievements);
|
|
93
100
|
return;
|
|
94
101
|
}
|
|
95
102
|
|
|
96
|
-
|
|
103
|
+
const reaction = deps.service.recordComment(comment, "turn");
|
|
104
|
+
const achievements = mergeAchievements(progress.achievements, reaction.achievements);
|
|
105
|
+
deps.ui.refresh(ctx, reaction.companion, reaction.state, achievements);
|
|
106
|
+
deps.ui.notifyAchievements(ctx, achievements);
|
|
97
107
|
});
|
|
98
108
|
}
|
|
99
109
|
|
|
@@ -122,6 +132,10 @@ function looksLikeTestFailure(text: string): boolean {
|
|
|
122
132
|
return /(FAIL|failed|failing|test(s)? failed|not ok)/i.test(text);
|
|
123
133
|
}
|
|
124
134
|
|
|
135
|
+
function looksLikeSuccess(text: string): boolean {
|
|
136
|
+
return /\b(all )?[0-9]+ tests? (passed|ok)\b|✓|✔|PASS(ED)?|\bDone\b|\bSuccess\b|exit code 0|Build succeeded/i.test(text);
|
|
137
|
+
}
|
|
138
|
+
|
|
125
139
|
function extractFailureCount(text: string): number | undefined {
|
|
126
140
|
const match = text.match(/(\d+)\s+(tests? )?(failed|failing)/i);
|
|
127
141
|
return match ? Number(match[1]) : undefined;
|
|
@@ -148,3 +162,156 @@ function firstLineNumber(text: string): number | undefined {
|
|
|
148
162
|
function escapeRegExp(value: string): string {
|
|
149
163
|
return value.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
150
164
|
}
|
|
165
|
+
|
|
166
|
+
function mergeAchievements(first: Achievement[], second: Achievement[]): Achievement[] {
|
|
167
|
+
const merged = new Map<string, Achievement>();
|
|
168
|
+
for (const achievement of [...first, ...second]) {
|
|
169
|
+
merged.set(achievement.id, achievement);
|
|
170
|
+
}
|
|
171
|
+
return [...merged.values()];
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
function isAssistantMessage(message: AgentMessage): message is AssistantMessage {
|
|
175
|
+
return message.role === "assistant" && Array.isArray(message.content);
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
function getAssistantText(message: AssistantMessage): string {
|
|
179
|
+
return message.content
|
|
180
|
+
.filter((block): block is TextContent => block.type === "text")
|
|
181
|
+
.map((block) => stripBuddyComments(block.text))
|
|
182
|
+
.join("\n");
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
async function generateTurnComment(
|
|
186
|
+
ctx: ExtensionContext,
|
|
187
|
+
companion: Companion,
|
|
188
|
+
event: TurnEndEvent,
|
|
189
|
+
): Promise<string | null> {
|
|
190
|
+
const assistantText = isAssistantMessage(event.message) ? getAssistantText(event.message) : "";
|
|
191
|
+
if (!assistantText.trim()) return null;
|
|
192
|
+
|
|
193
|
+
if (ctx.model) {
|
|
194
|
+
const auth = await ctx.modelRegistry.getApiKeyAndHeaders(ctx.model);
|
|
195
|
+
if (auth.ok && auth.apiKey) {
|
|
196
|
+
const userMessage: UserMessage = {
|
|
197
|
+
role: "user",
|
|
198
|
+
content: [{ type: "text", text: buildBuddyReactionPrompt(companion, assistantText, getToolResultsText(event)) }],
|
|
199
|
+
timestamp: Date.now(),
|
|
200
|
+
};
|
|
201
|
+
|
|
202
|
+
try {
|
|
203
|
+
const response = await complete(
|
|
204
|
+
ctx.model,
|
|
205
|
+
{ messages: [userMessage] },
|
|
206
|
+
{
|
|
207
|
+
apiKey: auth.apiKey,
|
|
208
|
+
headers: auth.headers,
|
|
209
|
+
signal: ctx.signal,
|
|
210
|
+
},
|
|
211
|
+
);
|
|
212
|
+
|
|
213
|
+
if (response.stopReason !== "aborted") {
|
|
214
|
+
const text = response.content
|
|
215
|
+
.filter((block): block is TextContent => block.type === "text")
|
|
216
|
+
.map((block) => block.text)
|
|
217
|
+
.join("\n");
|
|
218
|
+
const normalized = normalizeBuddyComment(text);
|
|
219
|
+
if (normalized) return normalized;
|
|
220
|
+
}
|
|
221
|
+
} catch {
|
|
222
|
+
// Fall through to heuristic fallback.
|
|
223
|
+
}
|
|
224
|
+
}
|
|
225
|
+
}
|
|
226
|
+
|
|
227
|
+
return deriveTurnComment(companion, event.message);
|
|
228
|
+
}
|
|
229
|
+
|
|
230
|
+
function getToolResultsText(event: TurnEndEvent): string {
|
|
231
|
+
return event.toolResults
|
|
232
|
+
.map((result) => result.content
|
|
233
|
+
.filter((block): block is TextContent => block.type === "text")
|
|
234
|
+
.map((block) => block.text)
|
|
235
|
+
.join("\n"))
|
|
236
|
+
.filter(Boolean)
|
|
237
|
+
.join("\n\n")
|
|
238
|
+
.slice(0, 4000);
|
|
239
|
+
}
|
|
240
|
+
|
|
241
|
+
export function deriveTurnComment(companion: Companion, message: AgentMessage): string | null {
|
|
242
|
+
if (!isAssistantMessage(message)) return null;
|
|
243
|
+
|
|
244
|
+
const text = sanitizeAssistantText(getAssistantText(message));
|
|
245
|
+
if (!text) return null;
|
|
246
|
+
|
|
247
|
+
const file = firstMatch(text, /`([^`]+\.[a-z0-9]+)`/i)
|
|
248
|
+
?? firstMatch(text, /\b([A-Za-z0-9_./-]+\.(?:ts|tsx|js|jsx|json|md|sh|py|rs|go|java|rb|css|html|ya?ml))\b/i);
|
|
249
|
+
|
|
250
|
+
if (file) {
|
|
251
|
+
return fitComment(`*takes note* ${file} got the attention this turn.`, 150);
|
|
252
|
+
}
|
|
253
|
+
|
|
254
|
+
if (/\b(regex|unicode)\b/i.test(text)) {
|
|
255
|
+
return fitComment("*head tilts* that regex still wants a second look.", 150);
|
|
256
|
+
}
|
|
257
|
+
|
|
258
|
+
if (/\b(test|tests|assert|spec)\b/i.test(text)) {
|
|
259
|
+
return fitComment("*nods slowly* good. keep the tests honest.", 150);
|
|
260
|
+
}
|
|
261
|
+
|
|
262
|
+
if (/\b(error|bug|fix|failure|failing|exception)\b/i.test(text)) {
|
|
263
|
+
return fitComment("*watches closely* one fix always tries to drag a second one behind it.", 150);
|
|
264
|
+
}
|
|
265
|
+
|
|
266
|
+
const topic = firstMeaningfulSentence(text);
|
|
267
|
+
if (!topic) return null;
|
|
268
|
+
|
|
269
|
+
const speciesLead = companion.bones.species === "owl"
|
|
270
|
+
? "*blinks slowly*"
|
|
271
|
+
: companion.bones.species === "snail"
|
|
272
|
+
? "*slow nod*"
|
|
273
|
+
: "*takes note*";
|
|
274
|
+
|
|
275
|
+
return fitComment(`${speciesLead} ${topic}`, 150);
|
|
276
|
+
}
|
|
277
|
+
|
|
278
|
+
function sanitizeAssistantText(text: string): string {
|
|
279
|
+
return text
|
|
280
|
+
.replace(/<!--([\s\S]*?)-->/g, " ")
|
|
281
|
+
.replace(/```[\s\S]*?```/g, " ")
|
|
282
|
+
.replace(/`([^`]+)`/g, "$1")
|
|
283
|
+
.replace(/^#{1,6}\s+/gm, "")
|
|
284
|
+
.replace(/^\s*[-*+]\s+/gm, "")
|
|
285
|
+
.replace(/\[(.*?)\]\((.*?)\)/g, "$1")
|
|
286
|
+
.replace(/\s+/g, " ")
|
|
287
|
+
.trim();
|
|
288
|
+
}
|
|
289
|
+
|
|
290
|
+
function firstMatch(text: string, pattern: RegExp): string | null {
|
|
291
|
+
const match = text.match(pattern);
|
|
292
|
+
return match?.[1]?.trim() || null;
|
|
293
|
+
}
|
|
294
|
+
|
|
295
|
+
function firstMeaningfulSentence(text: string): string | null {
|
|
296
|
+
const sentences = text
|
|
297
|
+
.split(/(?<=[.!?])\s+/)
|
|
298
|
+
.map((sentence) => sentence.trim())
|
|
299
|
+
.filter(Boolean);
|
|
300
|
+
|
|
301
|
+
for (const sentence of sentences) {
|
|
302
|
+
const cleaned = sentence
|
|
303
|
+
.replace(/^here'?s what I (?:did|changed)[:\-]?\s*/i, "")
|
|
304
|
+
.replace(/^I\s+/i, "")
|
|
305
|
+
.replace(/^we\s+/i, "")
|
|
306
|
+
.trim();
|
|
307
|
+
if (cleaned.length < 18) continue;
|
|
308
|
+
return cleaned;
|
|
309
|
+
}
|
|
310
|
+
|
|
311
|
+
return text.length >= 18 ? text : null;
|
|
312
|
+
}
|
|
313
|
+
|
|
314
|
+
function fitComment(text: string, maxLength: number): string {
|
|
315
|
+
if (text.length <= maxLength) return text;
|
|
316
|
+
return `${text.slice(0, maxLength - 1).trimEnd()}…`;
|
|
317
|
+
}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import type { Companion } from "../../core/model.ts";
|
|
2
|
+
|
|
3
|
+
export function buildBuddyReactionPrompt(
|
|
4
|
+
companion: Companion,
|
|
5
|
+
assistantText: string,
|
|
6
|
+
toolText: string,
|
|
7
|
+
): string {
|
|
8
|
+
return [
|
|
9
|
+
`You are generating a single end-of-turn buddy reaction for ${companion.name}, a ${companion.bones.rarity} ${companion.bones.species}.`,
|
|
10
|
+
`Buddy personality: ${companion.personality}`,
|
|
11
|
+
`Peak stat: ${companion.bones.peak} (${companion.bones.stats[companion.bones.peak]}). Dump stat: ${companion.bones.dump} (${companion.bones.stats[companion.bones.dump]}).`,
|
|
12
|
+
"",
|
|
13
|
+
"Write exactly one short in-character reaction sentence as the buddy.",
|
|
14
|
+
"Rules:",
|
|
15
|
+
`- Write as ${companion.name}, not as the assistant.`,
|
|
16
|
+
"- Reference something specific from the turn.",
|
|
17
|
+
"- Max 150 characters.",
|
|
18
|
+
"- Use *asterisks* for physical actions when useful.",
|
|
19
|
+
"- Output only the reaction line, with no quotes, labels, markdown fences, or explanation.",
|
|
20
|
+
"",
|
|
21
|
+
"Assistant response:",
|
|
22
|
+
assistantText || "(empty)",
|
|
23
|
+
"",
|
|
24
|
+
"Tool result summary:",
|
|
25
|
+
toolText || "(none)",
|
|
26
|
+
].join("\n");
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
export function stripBuddyComments(text: string): string {
|
|
30
|
+
return text.replace(/<!--\s*buddy:\s*[\s\S]*?-->/gi, "").trimEnd();
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
export function normalizeBuddyComment(text: string): string {
|
|
34
|
+
return text
|
|
35
|
+
.replace(/<!--\s*buddy:\s*([\s\S]*?)\s*-->/gi, "$1")
|
|
36
|
+
.replace(/^buddy\s*:\s*/i, "")
|
|
37
|
+
.replace(/^['"`]+|['"`]+$/g, "")
|
|
38
|
+
.replace(/\s+/g, " ")
|
|
39
|
+
.trim()
|
|
40
|
+
.slice(0, 150)
|
|
41
|
+
.trim();
|
|
42
|
+
}
|
package/core/command-service.ts
CHANGED
|
@@ -40,6 +40,12 @@ export interface ReactionResult {
|
|
|
40
40
|
achievements: Achievement[];
|
|
41
41
|
}
|
|
42
42
|
|
|
43
|
+
export interface ProgressResult {
|
|
44
|
+
companion: Companion;
|
|
45
|
+
slot: string;
|
|
46
|
+
achievements: Achievement[];
|
|
47
|
+
}
|
|
48
|
+
|
|
43
49
|
export interface SaveBuddyResult {
|
|
44
50
|
companion: Companion;
|
|
45
51
|
slot: string;
|
|
@@ -209,6 +215,24 @@ export class BuddyCommandService {
|
|
|
209
215
|
return this.saveReaction("turn", companion, slot, scope);
|
|
210
216
|
}
|
|
211
217
|
|
|
218
|
+
recordTurnOnly(): ProgressResult {
|
|
219
|
+
const { companion, slot } = this.ensureCompanion();
|
|
220
|
+
this.deps.events.increment("turns", 1);
|
|
221
|
+
const achievements = this.unlockAchievements(slot);
|
|
222
|
+
return { companion, slot, achievements };
|
|
223
|
+
}
|
|
224
|
+
|
|
225
|
+
recordComment(
|
|
226
|
+
comment: string,
|
|
227
|
+
reason: "turn" | "error" | "test-fail" | "large-diff" = "turn",
|
|
228
|
+
scope?: string,
|
|
229
|
+
): ReactionResult {
|
|
230
|
+
const trimmed = comment.trim();
|
|
231
|
+
if (!trimmed) throw new Error("Buddy comment cannot be empty.");
|
|
232
|
+
const { companion, slot } = this.ensureCompanion();
|
|
233
|
+
return this.saveCustomReaction(trimmed, reason, companion, slot, scope);
|
|
234
|
+
}
|
|
235
|
+
|
|
212
236
|
incrementCommandsRun(): Achievement[] {
|
|
213
237
|
this.deps.events.increment("commands_run", 1, this.getActiveSlotOrUndefined());
|
|
214
238
|
return this.unlockAchievements(this.getActiveSlotOrUndefined());
|
|
@@ -292,6 +316,16 @@ export class BuddyCommandService {
|
|
|
292
316
|
companion.bones.rarity,
|
|
293
317
|
context,
|
|
294
318
|
);
|
|
319
|
+
return this.saveCustomReaction(reaction, reason, companion, slot, scope);
|
|
320
|
+
}
|
|
321
|
+
|
|
322
|
+
private saveCustomReaction(
|
|
323
|
+
reaction: string,
|
|
324
|
+
reason: "pet" | "turn" | "error" | "test-fail" | "large-diff",
|
|
325
|
+
companion: Companion,
|
|
326
|
+
slot: string,
|
|
327
|
+
scope?: string,
|
|
328
|
+
): ReactionResult {
|
|
295
329
|
const state: ReactionState = {
|
|
296
330
|
reaction,
|
|
297
331
|
reason,
|
package/core/reactions.ts
CHANGED
|
@@ -6,6 +6,51 @@ import type { Species, Rarity, StatName } from "./engine.ts";
|
|
|
6
6
|
|
|
7
7
|
type ReactionReason = "hatch" | "pet" | "error" | "test-fail" | "large-diff" | "turn" | "idle";
|
|
8
8
|
|
|
9
|
+
const NAME_REACTIONS: Partial<Record<Species, string[]>> = {
|
|
10
|
+
dragon: ["*one eye opens slowly*", "...you called?", "*smoke curls from nostril* yes.", "*regards you from above*"],
|
|
11
|
+
owl: ["*swivels head 180°*", "*blinks once, deliberately*", "hm.", "*adjusts perch*"],
|
|
12
|
+
cat: ["*ear flicks*", "...what.", "*ignores you, but heard*", "*opens one eye*"],
|
|
13
|
+
duck: ["*quack*", "*looks up mid-waddle*", "*attentive duck noises*"],
|
|
14
|
+
ghost: ["*materialises*", "...boo?", "*phases closer*"],
|
|
15
|
+
robot: ["NAME DETECTED.", "*whirrs attentively*", "STANDING BY."],
|
|
16
|
+
capybara: ["*barely moves*", "*blinks slowly*", "...yes, friend."],
|
|
17
|
+
axolotl: ["*gill flutter*", "*smiles gently*", "oh! hello."],
|
|
18
|
+
blob: ["*jiggles*", "*oozes toward you*", "*wobbles excitedly*"],
|
|
19
|
+
turtle: ["*slowly extends neck*", "...you called?", "*ancient eyes open*", "*shell creaks thoughtfully*", "*blinks once, patiently*"],
|
|
20
|
+
goose: ["HONK.", "*necks aggressively*", "*wing flap*", "*honks in recognition*"],
|
|
21
|
+
octopus: ["*eight eyes open*", "*curls an arm toward you*", "*changes color curiously*", "...yes, friend?"],
|
|
22
|
+
penguin: ["*adjusts tie*", "*dignified waddle*", "*bows slightly*", "...yes, quite?"],
|
|
23
|
+
snail: ["*slow head extension*", "...mmm?", "*trails slowly toward you*", "*antenna twitches*"],
|
|
24
|
+
cactus: ["*stands silent*", "...hm.", "*spine twitches*", "*slowly rotates*"],
|
|
25
|
+
rabbit: ["*ears perk up*", "*nose twitches*", "yes?", "*hops closer*"],
|
|
26
|
+
mushroom: ["*releases a tiny spore*", "*cap tilts*", "*stands mysterious*", "...yes?"],
|
|
27
|
+
chonk: ["*barely opens one eye*", "...mrrp?", "*yawns heavily*", "*rolls over toward you*"],
|
|
28
|
+
};
|
|
29
|
+
|
|
30
|
+
const SUCCESS_REACTIONS: Partial<Record<Species, string[]>> = {
|
|
31
|
+
dragon: ["*nods, barely*", "...acceptable.", "*gold eyes gleam*", "as expected."],
|
|
32
|
+
owl: ["*satisfied hoot*", "knowledge confirmed.", "*nods sagely*", "as the tests have spoken."],
|
|
33
|
+
cat: ["*was never worried*", "*yawns*", "I knew you'd figure it out. eventually.", "*already asleep*"],
|
|
34
|
+
duck: ["*celebratory quacking*", "*waddles in circles*", "quack!", "*happy duck noises*"],
|
|
35
|
+
robot: ["OBJECTIVE: COMPLETE.", "*satisfying beep*", "NOMINAL.", "WITHIN ACCEPTABLE PARAMETERS."],
|
|
36
|
+
capybara: ["*maximum chill maintained*", "*nods once*", "good vibes.", "see? no panic needed."],
|
|
37
|
+
ghost: ["*drifts in quiet approval*", "not bad for the living.", "*soft spectral nod*", "the haunting may continue peacefully."],
|
|
38
|
+
axolotl: ["*happy gill flutter*", "*beams*", "you did it!", "*blushes pink*"],
|
|
39
|
+
blob: ["*jiggles happily*", "*gleams*", "yay!", "*bounces*"],
|
|
40
|
+
turtle: ["*satisfied shell settle*", "as the ancients foretold.", "*slow approving nod*", "good. very good."],
|
|
41
|
+
goose: ["*victorious honk*", "HONK OF APPROVAL.", "*struts triumphantly*", "*wing spread of victory*"],
|
|
42
|
+
octopus: ["*turns gentle blue*", "*arms applaud in sync*", "excellent, from all angles.", "*satisfied bubble*"],
|
|
43
|
+
penguin: ["*polite applause*", "quite good, quite good.", "*nods approvingly*", "splendid work, really."],
|
|
44
|
+
snail: ["*slow satisfied nod*", "good things take time.", "*leaves victory slime*", "see? no rush was needed."],
|
|
45
|
+
cactus: ["*blooms briefly*", "survival confirmed.", "*flowers in victory*", "*quiet bloom*"],
|
|
46
|
+
rabbit: ["*excited binky*", "*zoomies of joy*", "yay yay yay!", "*thumps in celebration*"],
|
|
47
|
+
mushroom: ["*spores of celebration*", "the mycelium approves.", "*cap brightens*", "spore of pride."],
|
|
48
|
+
chonk: ["*happy purr*", "*satisfied chonk noises*", "acceptable.", "*sleeps even harder*"] ,
|
|
49
|
+
};
|
|
50
|
+
|
|
51
|
+
const DEFAULT_NAME_REACTIONS = ["*perks up*", "...yes?", "*looks your way*"];
|
|
52
|
+
const DEFAULT_SUCCESS_REACTIONS = ["*nods*", "nice.", "*quiet approval*", "clean."];
|
|
53
|
+
|
|
9
54
|
interface ReactionPool {
|
|
10
55
|
[key: string]: string[];
|
|
11
56
|
}
|
|
@@ -139,6 +184,16 @@ export function getReaction(
|
|
|
139
184
|
return reaction;
|
|
140
185
|
}
|
|
141
186
|
|
|
187
|
+
export function getNameReaction(species: Species): string {
|
|
188
|
+
const pool = NAME_REACTIONS[species] ?? DEFAULT_NAME_REACTIONS;
|
|
189
|
+
return pool[Math.floor(Math.random() * pool.length)];
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
export function getSuccessReaction(species: Species): string {
|
|
193
|
+
const pool = SUCCESS_REACTIONS[species] ?? DEFAULT_SUCCESS_REACTIONS;
|
|
194
|
+
return pool[Math.floor(Math.random() * pool.length)];
|
|
195
|
+
}
|
|
196
|
+
|
|
142
197
|
// ─── Personality generation (fallback names when API unavailable) ────────────
|
|
143
198
|
|
|
144
199
|
const FALLBACK_NAMES = [
|