Files
CharacterGardenStack/charactergarden/app/src/index.ts
spencer 1df2ae8164 feat: implement core application structure with Fastify server and SQLite persistence
- Add Fastify server in `app/src/index.ts` with health check and API routes for game state and turn processing.
- Create `latentEntities.ts` to handle personal item plausibility and promote beliefs to facts based on actor context.
- Introduce `llmAdapter.ts` for action extraction from prose input.
- Develop `truthEngine.ts` for pure validation logic, handling all verbs with explicit rejection reasons.
- Define new types in `types.ts` for facts, affordances, and latent entity requests/resolutions.
- Update `docker-compose.yml` for improved service structure and volume management.
- Create frontend structure with React, including Dockerfile, Vite configuration, and initial components for state inspection.
- Implement basic styles and HTML structure for the frontend application.
- Document current status and next steps in `thoughts.md`.
2026-04-23 21:08:38 -04:00

35 lines
876 B
TypeScript

import Fastify from "fastify";
import { createCharacterGardenApp } from "./app";
const port = Number(process.env.APP_PORT ?? 3000);
const host = process.env.APP_HOST ?? "0.0.0.0";
const dbPath = process.env.DB_PATH ?? "/data/sqlite/app.db";
const game = createCharacterGardenApp(dbPath);
const server = Fastify({ logger: true });
server.get("/health", async () => ({ ok: true }));
server.get("/api/state", async () => game.getSnapshot());
server.post<{ Body: { input?: string } }>("/api/turn", async (request, reply) => {
const input = request.body?.input?.trim();
if (!input) {
reply.code(400);
return { error: "input is required" };
}
return game.processTurn(input);
});
async function start(): Promise<void> {
try {
await server.listen({ host, port });
} catch (error) {
server.log.error(error);
process.exit(1);
}
}
void start();