Initialize project structure with core files, environment settings, and basic configurations
Co-authored-by: Copilot <copilot@github.com>
This commit is contained in:
8
charactergarden/.env
Normal file
8
charactergarden/.env
Normal file
@@ -0,0 +1,8 @@
|
||||
NODE_ENV=development
|
||||
APP_PORT=3000
|
||||
FRONTEND_PORT=5173
|
||||
DB_PATH=/data/sqlite/app.db
|
||||
|
||||
# Optional — only needed when running with the llm profile
|
||||
OLLAMA_URL=http://ollama:11434
|
||||
OLLAMA_MODEL=llama3
|
||||
11
charactergarden/.env.example
Normal file
11
charactergarden/.env.example
Normal file
@@ -0,0 +1,11 @@
|
||||
# Copy this file to .env and adjust values as needed.
|
||||
# Never commit .env — it is gitignored.
|
||||
|
||||
NODE_ENV=development
|
||||
APP_PORT=3000
|
||||
FRONTEND_PORT=5173
|
||||
DB_PATH=/data/sqlite/app.db
|
||||
|
||||
# Optional — only required when running with: docker compose --profile llm up
|
||||
OLLAMA_URL=http://ollama:11434
|
||||
OLLAMA_MODEL=llama3
|
||||
33
charactergarden/.gitignore
vendored
Normal file
33
charactergarden/.gitignore
vendored
Normal file
@@ -0,0 +1,33 @@
|
||||
# ── Dependencies ────────────────────────────────────────────
|
||||
node_modules/
|
||||
|
||||
# ── TypeScript build output ──────────────────────────────────
|
||||
app/dist/
|
||||
frontend/dist/
|
||||
|
||||
# ── Vite cache ───────────────────────────────────────────────
|
||||
frontend/.vite/
|
||||
|
||||
# ── SQLite database (keep the directory, not the data) ───────
|
||||
data/sqlite/*.db
|
||||
data/sqlite/*.db-shm
|
||||
data/sqlite/*.db-wal
|
||||
|
||||
# ── Environment — commit .env.example, never .env ────────────
|
||||
.env
|
||||
.env.local
|
||||
.env.*.local
|
||||
|
||||
# ── Docker volumes / build context artifacts ─────────────────
|
||||
.docker/
|
||||
|
||||
# ── OS noise ─────────────────────────────────────────────────
|
||||
.DS_Store
|
||||
Thumbs.db
|
||||
desktop.ini
|
||||
|
||||
# ── Editor noise ─────────────────────────────────────────────
|
||||
.vscode/settings.json
|
||||
.idea/
|
||||
*.suo
|
||||
*.user
|
||||
22
charactergarden/app/package.json
Normal file
22
charactergarden/app/package.json
Normal file
@@ -0,0 +1,22 @@
|
||||
{
|
||||
"name": "charactergarden-app",
|
||||
"version": "0.1.0",
|
||||
"private": true,
|
||||
"scripts": {
|
||||
"dev": "ts-node-dev --respawn src/index.ts",
|
||||
"build": "tsc",
|
||||
"start": "node dist/index.js"
|
||||
},
|
||||
"dependencies": {
|
||||
"fastify": "^4.28.1",
|
||||
"better-sqlite3": "^9.6.0",
|
||||
"uuid": "^9.0.1"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@types/better-sqlite3": "^7.6.11",
|
||||
"@types/node": "^20.14.0",
|
||||
"@types/uuid": "^9.0.8",
|
||||
"ts-node-dev": "^2.0.0",
|
||||
"typescript": "^5.4.5"
|
||||
}
|
||||
}
|
||||
76
charactergarden/app/src/types.ts
Normal file
76
charactergarden/app/src/types.ts
Normal file
@@ -0,0 +1,76 @@
|
||||
// Core contracts — DO NOT modify without updating project.md
|
||||
|
||||
// ── Section 2.1 ─────────────────────────────────────────────
|
||||
export interface Entity {
|
||||
id: string;
|
||||
type: string;
|
||||
name: string;
|
||||
attributes: Record<string, unknown>;
|
||||
}
|
||||
|
||||
// ── Section 2.2 ─────────────────────────────────────────────
|
||||
export const ALLOWED_VERBS = [
|
||||
"move",
|
||||
"open",
|
||||
"close",
|
||||
"take",
|
||||
"drop",
|
||||
"use",
|
||||
"inspect",
|
||||
"speak",
|
||||
] as const;
|
||||
|
||||
export type Verb = (typeof ALLOWED_VERBS)[number];
|
||||
|
||||
export interface Action {
|
||||
actor: string; // entity id
|
||||
verb: Verb;
|
||||
target?: string; // entity id
|
||||
params?: Record<string, unknown>;
|
||||
}
|
||||
|
||||
// ── Section 2.3 ─────────────────────────────────────────────
|
||||
export interface ValidationResult {
|
||||
accepted: Action[];
|
||||
rejected: { action: Action; reason: string }[];
|
||||
state_changes: StateChange[];
|
||||
}
|
||||
|
||||
// ── Section 2.4 ─────────────────────────────────────────────
|
||||
export interface StateChange {
|
||||
entity_id: string;
|
||||
field: string;
|
||||
old_value: unknown;
|
||||
new_value: unknown;
|
||||
}
|
||||
|
||||
// ── Section 2.5 ─────────────────────────────────────────────
|
||||
export interface GameEvent {
|
||||
id: string;
|
||||
turn: number;
|
||||
action: Action;
|
||||
result: "success" | "fail";
|
||||
timestamp: number;
|
||||
}
|
||||
|
||||
// ── Section 4 — Memory types ─────────────────────────────────
|
||||
export interface Turn {
|
||||
id: string;
|
||||
turn: number;
|
||||
input: string;
|
||||
output: string;
|
||||
timestamp: number;
|
||||
}
|
||||
|
||||
export interface Belief {
|
||||
entity_id: string;
|
||||
claim: string;
|
||||
confidence: number;
|
||||
}
|
||||
|
||||
export interface Summary {
|
||||
id: string;
|
||||
turn_range: [number, number];
|
||||
text: string;
|
||||
timestamp: number;
|
||||
}
|
||||
15
charactergarden/app/tsconfig.json
Normal file
15
charactergarden/app/tsconfig.json
Normal file
@@ -0,0 +1,15 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"target": "ES2022",
|
||||
"module": "commonjs",
|
||||
"lib": ["ES2022"],
|
||||
"outDir": "dist",
|
||||
"rootDir": "src",
|
||||
"strict": true,
|
||||
"esModuleInterop": true,
|
||||
"skipLibCheck": true,
|
||||
"forceConsistentCasingInFileNames": true
|
||||
},
|
||||
"include": ["src"],
|
||||
"exclude": ["node_modules", "dist"]
|
||||
}
|
||||
1
charactergarden/data/sqlite/.gitkeep
Normal file
1
charactergarden/data/sqlite/.gitkeep
Normal file
@@ -0,0 +1 @@
|
||||
# sqlite data directory — tracked by git, contents ignored
|
||||
34
charactergarden/docker-compose.yml
Normal file
34
charactergarden/docker-compose.yml
Normal file
@@ -0,0 +1,34 @@
|
||||
version: "3.9"
|
||||
|
||||
services:
|
||||
app:
|
||||
build: ./app
|
||||
ports:
|
||||
- "${APP_PORT:-3000}:3000"
|
||||
environment:
|
||||
- NODE_ENV=${NODE_ENV:-development}
|
||||
- DB_PATH=/data/sqlite/app.db
|
||||
- OLLAMA_URL=${OLLAMA_URL:-http://ollama:11434}
|
||||
volumes:
|
||||
- ./data:/data
|
||||
depends_on:
|
||||
- ollama
|
||||
|
||||
frontend:
|
||||
build: ./frontend
|
||||
ports:
|
||||
- "${FRONTEND_PORT:-5173}:5173"
|
||||
depends_on:
|
||||
- app
|
||||
|
||||
ollama:
|
||||
image: ollama/ollama:latest
|
||||
ports:
|
||||
- "11434:11434"
|
||||
volumes:
|
||||
- ollama_data:/root/.ollama
|
||||
profiles:
|
||||
- llm
|
||||
|
||||
volumes:
|
||||
ollama_data:
|
||||
21
charactergarden/frontend/package.json
Normal file
21
charactergarden/frontend/package.json
Normal file
@@ -0,0 +1,21 @@
|
||||
{
|
||||
"name": "charactergarden-frontend",
|
||||
"version": "0.1.0",
|
||||
"private": true,
|
||||
"scripts": {
|
||||
"dev": "vite",
|
||||
"build": "vite build",
|
||||
"preview": "vite preview"
|
||||
},
|
||||
"dependencies": {
|
||||
"react": "^18.3.1",
|
||||
"react-dom": "^18.3.1"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@types/react": "^18.3.3",
|
||||
"@types/react-dom": "^18.3.0",
|
||||
"@vitejs/plugin-react": "^4.3.1",
|
||||
"typescript": "^5.4.5",
|
||||
"vite": "^5.3.1"
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user