openpetswithchatandmcp/apps/desktop/tests/prompt-memory-extraction.test.ts
OpenPets Dev 08eff41255 feat(desktop): minimal prompt window, larger pet bubbles, improved command memory, screen-filling pet scale slider
- Prompt window opens at 140px compact height and expands to 456px when editor/history shown.
- Pet speech bubbles scale with larger pets and window sizes; removed text overflow clipping.
- Extracted prompt memory extraction into testable module; added /remember, /memorize, /note, don't forget patterns.
- Replaced pet scale dropdown with continuous slider from 0.16x to 10x.
- Added prompt-memory-extraction.test.ts and updated packaging/onboarding tests.
2026-06-12 03:02:21 +00:00

52 lines
2.7 KiB
TypeScript

import assert from "node:assert/strict";
import { extractPromptMemoryCandidates } from "../src/prompt-memory-extraction.js";
function assertCandidate(prompt: string, expectedText: string, index = 0): void {
const candidates = extractPromptMemoryCandidates(prompt);
const candidate = candidates[index];
assert.ok(candidate, `Expected at least ${index + 1} memory candidate(s) for: ${prompt}`);
assert.equal(candidate.text, expectedText, `Unexpected memory text for: ${prompt}`);
}
function assertNoCandidate(prompt: string): void {
const candidates = extractPromptMemoryCandidates(prompt);
assert.equal(candidates.length, 0, `Expected no memory candidates for: ${prompt}`);
}
// Classic explicit remember commands
assertCandidate("remember that my name is Alice", "User's name is Alice.", 0);
assertCandidate("Remember my name is Bob", "User's name is Bob.", 0);
assertCandidate("/remember that I prefer dark mode", "User prefers dark mode.", 0);
assertCandidate("#memorize pizza is my favorite food", "pizza is my favorite food", 0);
assertCandidate("!note the server runs on port 3000", "the server runs on port 3000", 0);
assertCandidate("note: always use TypeScript", "always use TypeScript", 0);
assertCandidate("remember - I like hiking", "User likes hiking.", 0);
assertCandidate("remember, I hate spinach", "User hates spinach.", 0);
assertCandidate("don't forget that my favorite color is blue", "User's favorite color is blue.", 0);
assertCandidate("Don't forget I love summer", "User loves summer.", 0);
// Identity
assertCandidate("call me Charlie", "User's name is Charlie.", 0);
assertCandidate("my name is Diana", "User's name is Diana.", 0);
// Preferences
assertCandidate("my favorite programming language is Python", "User's favorite programming language is Python.", 0);
assertCandidate("I prefer tea over coffee", "User prefers tea over coffee.", 0);
assertCandidate("I like sci-fi movies", "User likes sci-fi movies.", 0);
assertCandidate("I love hiking in the mountains", "User loves hiking in the mountains.", 0);
assertCandidate("I dislike waiting", "User dislikes waiting.", 0);
assertCandidate("I hate noisy environments", "User hates noisy environments.", 0);
// Multi-line prompts should extract per line
const multiLine = "remember that I work late\nmy favorite editor is VS Code";
assert.equal(extractPromptMemoryCandidates(multiLine).length, 2, "Multi-line prompt should extract two candidates");
assertCandidate(multiLine, "I work late", 0);
assertCandidate(multiLine, "User's favorite editor is VS Code.", 1);
// Non-command prompts should not produce candidates
assertNoCandidate("What is the weather today?");
assertNoCandidate("Hello, how are you?");
assertNoCandidate("Tell me a joke");
console.log("Prompt memory extraction validation passed.");