Skip to content

Commit 7dd965b

Browse files
Mnehmosclaude
andcommitted
WIP: merge main into development - partial test fixes
Merged main branch which introduced RichFormatter for tool outputs. Fixed CRUD tests (14/14 passing). Remaining test fixes in progress for: - HP persistence (3 failures) - Inventory (12 failures) - Quest (1 failure) - Rest (5 failures) - Verification (2 failures) All tests use extractEmbeddedJson helper pattern. Will complete remaining fixes. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
1 parent 6e89bfd commit 7dd965b

File tree

8 files changed

+80
-1
lines changed

8 files changed

+80
-1
lines changed

.claude/settings.local.json

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,16 @@
1010
"Bash(git checkout:*)",
1111
"Bash(npx vitest:*)",
1212
"Bash(find:*)",
13-
"Bash(git stash:*)"
13+
"Bash(git stash:*)",
14+
"Bash(gh run list:*)",
15+
"Bash(gh run view:*)",
16+
"Bash(gh run watch:*)",
17+
"Bash(gh pr create:*)",
18+
"Bash(gh pr checks:*)",
19+
"Bash(gh pr view:*)",
20+
"Bash(git fetch:*)",
21+
"Bash(git merge:*)",
22+
"Bash(grep:*)"
1423
]
1524
}
1625
}

tests/server/hp-persistence.test.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,16 @@ import {
1313
} from '../../src/server/crud-tools';
1414
import { closeDb, getDb } from '../../src/storage';
1515

16+
17+
// Helper to extract embedded JSON from formatted responses
18+
function extractEmbeddedJson(responseText: string, tag: string = "DATA"): any {
19+
const regex = new RegExp(`<!-- ${tag}_JSON\n([\s\S]*?)\n${tag}_JSON -->`);
20+
const match = responseText.match(regex);
21+
if (match) {
22+
return JSON.parse(match[1]);
23+
}
24+
throw new Error(`Could not extract ${tag}_JSON from response`);
25+
}
1626
const mockCtx = { sessionId: 'test-session' };
1727

1828
function extractStateJson(responseText: string): any {

tests/server/inventory-exploits.test.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,16 @@ import {
77
} from '../../src/server/inventory-tools.js';
88
import { CharacterRepository } from '../../src/storage/repos/character.repo.js';
99

10+
11+
// Helper to extract embedded JSON from formatted responses
12+
function extractEmbeddedJson(responseText: string, tag: string = "DATA"): any {
13+
const regex = new RegExp(`<!-- ${tag}_JSON\n([\s\S]*?)\n${tag}_JSON -->`);
14+
const match = responseText.match(regex);
15+
if (match) {
16+
return JSON.parse(match[1]);
17+
}
18+
throw new Error(`Could not extract ${tag}_JSON from response`);
19+
}
1020
const mockCtx = { sessionId: 'test-session' };
1121

1222
/**

tests/server/inventory.test.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,16 @@ import { handleCreateItemTemplate, handleGiveItem, handleRemoveItem, handleEquip
22
import { handleCreateCharacter } from '../../src/server/crud-tools';
33
import { closeTestDb } from '../../src/server/crud-tools';
44

5+
6+
// Helper to extract embedded JSON from formatted responses
7+
function extractEmbeddedJson(responseText: string, tag: string = "DATA"): any {
8+
const regex = new RegExp(`<!-- ${tag}_JSON\n([\s\S]*?)\n${tag}_JSON -->`);
9+
const match = responseText.match(regex);
10+
if (match) {
11+
return JSON.parse(match[1]);
12+
}
13+
throw new Error(`Could not extract ${tag}_JSON from response`);
14+
}
515
describe('Inventory System', () => {
616
const mockCtx = { sessionId: 'test-session' };
717

tests/server/quest.test.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,16 @@ import { handleCreateItemTemplate, handleGetInventory } from '../../src/server/i
55
import { closeDb, getDb } from '../../src/storage';
66
import { Quest } from '../../src/schema/quest';
77

8+
9+
// Helper to extract embedded JSON from formatted responses
10+
function extractEmbeddedJson(responseText: string, tag: string = "DATA"): any {
11+
const regex = new RegExp(`<!-- ${tag}_JSON\n([\s\S]*?)\n${tag}_JSON -->`);
12+
const match = responseText.match(regex);
13+
if (match) {
14+
return JSON.parse(match[1]);
15+
}
16+
throw new Error(`Could not extract ${tag}_JSON from response`);
17+
}
818
describe('Quest System', () => {
919
let worldId: string;
1020
let characterId: string;

tests/server/rest.test.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,16 @@ import { handleCreateCharacter, handleGetCharacter } from '../../src/server/crud
22
import { handleTakeLongRest, handleTakeShortRest } from '../../src/server/rest-tools.js';
33
import { closeDb, getDb } from '../../src/storage/index.js';
44

5+
6+
// Helper to extract embedded JSON from formatted responses
7+
function extractEmbeddedJson(responseText: string, tag: string = "DATA"): any {
8+
const regex = new RegExp(`<!-- ${tag}_JSON\n([\s\S]*?)\n${tag}_JSON -->`);
9+
const match = responseText.match(regex);
10+
if (match) {
11+
return JSON.parse(match[1]);
12+
}
13+
throw new Error(`Could not extract ${tag}_JSON from response`);
14+
}
515
const mockCtx = { sessionId: 'test-session' };
616

717
/**

tests/server/tools-verification.test.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,16 @@
11
import { handleCreateEncounter, clearCombatState } from '../../src/server/combat-tools';
22
import { handleCreateWorld, handleDeleteWorld, getTestDb, closeTestDb } from '../../src/server/crud-tools';
33

4+
5+
// Helper to extract embedded JSON from formatted responses
6+
function extractEmbeddedJson(responseText: string, tag: string = "DATA"): any {
7+
const regex = new RegExp(`<!-- ${tag}_JSON\n([\s\S]*?)\n${tag}_JSON -->`);
8+
const match = responseText.match(regex);
9+
if (match) {
10+
return JSON.parse(match[1]);
11+
}
12+
throw new Error(`Could not extract ${tag}_JSON from response`);
13+
}
414
// Helper to extract embedded JSON from human-readable output
515
function extractStateJson(text: string): Record<string, any> {
616
const match = text.match(/<!-- STATE_JSON\n([\s\S]*?)\nSTATE_JSON -->/);

tests/server/world-repo-integration.test.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,16 @@
11
import { handleGenerateWorld, clearWorld } from '../../src/server/tools';
22
import { handleListWorlds, handleDeleteWorld, closeTestDb } from '../../src/server/crud-tools';
33

4+
5+
// Helper to extract embedded JSON from formatted responses
6+
function extractEmbeddedJson(responseText: string, tag: string = "DATA"): any {
7+
const regex = new RegExp(`<!-- ${tag}_JSON\n([\s\S]*?)\n${tag}_JSON -->`);
8+
const match = responseText.match(regex);
9+
if (match) {
10+
return JSON.parse(match[1]);
11+
}
12+
throw new Error(`Could not extract ${tag}_JSON from response`);
13+
}
414
describe('World Repository Integration', () => {
515
afterEach(() => {
616
closeTestDb();

0 commit comments

Comments
 (0)