Files
sucker.severian.dev/package.json
Severian 11c244fdd2 Read the request by role, not by position
Some users' JanitorAI sends a "." user turn between the card and the
greeting; others' does not. Sucker read fixed indices, so on the shorter
shape every slot was off by one: first_mes was set to the name line, and
the name slot did not exist at all. That TypeError was caught by the
handler and reported as the "you dingus, read the directions" message,
which blamed the user for a shape they never chose.

src/lib/messages.ts now resolves the slots by role instead — the card is
the system turn, the greeting is the first assistant turn, the user's
latest input is the last user turn, and sucker's own previous reply is the
last assistant turn. All four hold in both shapes and in a continued
conversation, so the conversation token is found in either as well.

Extraction now throws a description of what is missing rather than a
TypeError, and tests/messages.test.ts pins both shapes. The tests need no
framework: `npm test` runs node's built-in runner.

Existing cards are unaffected: the update path already discards the
extracted name and keeps the original.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01NX2SsmUqQftWTZAY4BDuFa
2026-09-11 04:14:04 +08:00

43 lines
1.1 KiB
JSON

{
"name": "sucker",
"version": "0.1.0",
"private": true,
"scripts": {
"dev": "next dev",
"build": "next build",
"start": "next start",
"lint": "next lint",
"test": "node --experimental-strip-types --test \"tests/**/*.test.ts\""
},
"dependencies": {
"@radix-ui/react-accordion": "^1.2.2",
"@radix-ui/react-collapsible": "^1.1.2",
"@radix-ui/react-dialog": "^1.1.4",
"@radix-ui/react-dropdown-menu": "^2.1.16",
"@radix-ui/react-separator": "^1.1.1",
"@radix-ui/react-slot": "^1.1.1",
"@types/react": "^19.2.7",
"@types/react-dom": "^19.2.3",
"axios": "^1.6.2",
"class-variance-authority": "^0.7.1",
"clsx": "^2.1.1",
"cors": "^2.8.5",
"crc-32": "^1.2.2",
"html2canvas": "^1.4.1",
"lucide-react": "^0.471.0",
"next": "^16.0.7",
"react": "^19.2.1",
"react-dom": "^19.2.1",
"tailwind-merge": "^2.6.0",
"tailwindcss-animate": "^1.0.7",
"typescript": "^5.3.2"
},
"devDependencies": {
"@types/cors": "^2.8.17",
"@types/node": "^22.10.5",
"autoprefixer": "^10.4.16",
"postcss": "^8.4.31",
"tailwindcss": "^3.3.5"
}
}