{"id":47790659,"url":"https://github.com/deadronos/villagesim","last_synced_at":"2026-04-03T15:36:29.951Z","repository":{"id":346666123,"uuid":"1191025598","full_name":"deadronos/villagesim","owner":"deadronos","description":null,"archived":false,"fork":false,"pushed_at":"2026-03-25T20:32:52.000Z","size":344,"stargazers_count":0,"open_issues_count":7,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2026-03-26T03:31:22.572Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"https://villagesim.vercel.app","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/deadronos.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":"AGENTS.md","dco":null,"cla":null}},"created_at":"2026-03-24T21:09:02.000Z","updated_at":"2026-03-25T20:10:06.000Z","dependencies_parsed_at":null,"dependency_job_id":null,"html_url":"https://github.com/deadronos/villagesim","commit_stats":null,"previous_names":["deadronos/villagesim"],"tags_count":null,"template":false,"template_full_name":null,"purl":"pkg:github/deadronos/villagesim","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/deadronos%2Fvillagesim","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/deadronos%2Fvillagesim/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/deadronos%2Fvillagesim/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/deadronos%2Fvillagesim/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/deadronos","download_url":"https://codeload.github.com/deadronos/villagesim/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/deadronos%2Fvillagesim/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":31360807,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-03T15:19:21.178Z","status":"ssl_error","status_checked_at":"2026-04-03T15:19:20.670Z","response_time":107,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.6:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2026-04-03T15:36:29.441Z","updated_at":"2026-04-03T15:36:29.931Z","avatar_url":"https://github.com/deadronos.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# VillageSim\n\nVillageSim is a local-first starter for a 2D village simulation MVP. It includes a runnable Next.js UI, Convex-backed hosted authority for towns when enabled, mock local development state by default, NPC decision logic, a mock planner, a tick API, and a lightweight worker entrypoint so you can iterate before wiring full hosted planner infrastructure.\n\nCurrent setup and rollout instructions live in [SETUP_GUIDE.md](./SETUP_GUIDE.md). Use that guide for:\n\n- local mock mode\n- local planner-service mode\n- Vercel + Convex + Tailscale Funnel private-alpha setup\n- environment variable placement and rollout validation\n\n## What is in this starter?\n\n- Next.js App Router app scaffold with TypeScript enabled.\n- `/town/[id]` demo route that renders a seeded pixel village and NPC roster.\n- GitHub OAuth routes and signed cookie session helpers for hosted identity scaffolding.\n- Shared mock town state and simulation helpers in `lib/`.\n- A local-first `/api/tick` endpoint for advancing the simulation.\n- Worker entrypoints in `workers/` plus Convex-style query/mutation stubs in `convex/`.\n- Baseline scripts for development, production build, runtime start, linting, and mock ticking.\n\n## Local startup\n\nFor the full environment reference and hosted setup instructions, see [SETUP_GUIDE.md](./SETUP_GUIDE.md).\n\n1. Copy the example environment file:\n\n   ```bash\n   cp .env.example .env.local\n   ```\n\n2. Leave `VILLAGESIM_PLANNER_MOCK=true` for the first run and keep `VILLAGESIM_STATE_MODE=mock` unless you have a Convex deployment configured. That keeps the planner side mock-friendly while the rest of the app is still being wired.\n3. Install dependencies:\n\n   ```bash\n   npm install\n   ```\n\n   If you want to run the planner service locally, also install its separate dependency set:\n\n   ```bash\n   npm --prefix services/planner install\n   ```\n\n4. Start the app:\n\n   ```bash\n   npm run dev\n   ```\n\n5. Open [http://localhost:3000](http://localhost:3000).\n6. Visit [http://localhost:3000/town/demo-town](http://localhost:3000/town/demo-town).\n7. Optionally advance the local simulation manually:\n\n   ```bash\n   npm run tick:mock -- --town demo-town --count 2\n   ```\n\n## Scripts\n\n- `npm run dev` — start the local development server.\n- `npm run build` — create a production build.\n- `npm run start` — run the production build locally.\n- `npm run lint` — run the ESLint CLI checks for the Next.js app.\n- `npm run test` — run the full Vitest suite.\n- `npm run test:watch` — run Vitest in watch mode during local development.\n- `npm run test:coverage` — run the suite with coverage output in `coverage/`.\n- `npm run test:unit` — run unit tests under `tests/unit/`.\n- `npm run test:integration` — run integration tests under `tests/integration/`.\n- `npm run test:component` — run jsdom component tests under `tests/component/`.\n- `npm run tick:mock -- --town demo-town --count 1` — run the local worker tick against the seeded town.\n\n## Testing\n\nVillageSim now uses Vitest for fast local testing across three layers:\n\n- **Unit tests** in `tests/unit/` for focused pure-module behavior such as session encoding/parsing and planner helpers.\n- **Integration tests** in `tests/integration/` for multi-module flows such as simulation ticks and local state persistence.\n- **Component tests** in `tests/component/` using jsdom + React Testing Library for client components.\n\nThe current test strategy deliberately excludes end-to-end browser tests for now. The goal is to build reliable fast feedback around the shared simulation code, auth/session helpers, and React UI before adding a heavier E2E layer.\n\nComponent tests use the `@vitest-environment jsdom` docblock and share a common setup file that enables Testing Library cleanup and `jest-dom` matchers.\n\n## Environment notes\n\nThe provided `.env.example` covers the current app-side and planner-service env surface. The full reference, placement rules, failure modes, and rollout checklist now live in [SETUP_GUIDE.md](./SETUP_GUIDE.md).\n\nHosted GitHub sign-in stays private-alpha by default. Add approved GitHub logins to `APPROVED_GITHUB_LOGINS` before testing OAuth locally or on Vercel. Unapproved users are redirected back to `/` with an explicit denial message, and the local `demo-town` flow continues to work without OAuth.\n\nThe shared planner seam now uses `VILLAGESIM_PLANNER_SERVICE_*` names for the private service path while keeping `VILLAGESIM_PLANNER_MOCK=true` as the default local-first behavior. Legacy `MODEL_*` aliases are still accepted for compatibility during the transition.\n\n## Local-first architecture\n\n- `lib/mockData.ts` owns seeded town/NPC state and simple in-memory persistence for local mock mode.\n- `lib/authoritativeTownStore.ts` switches hosted reads/writes between local mock mode and Convex-backed authority.\n- `lib/npc_decision.ts` handles fast weighted decisions with injectable RNG.\n- `lib/plannerContract.ts` defines the shared zod-validated planner request/response contract used by the app-side planner seam.\n- `lib/model_proxy.ts` provides the deterministic mock planner plus the private planner-service transport that preserves mock fallback semantics.\n- `services/planner/` provides the Docker-friendly private planner service with signed `/plan` requests, replay protection, rate limiting, and a provider seam that can run either the mock planner or a local Copilot-backed runtime.\n- `lib/sim_engine.ts` applies actions, assigns plans, and advances ticks.\n- `app/api/tick/route.ts` advances either the local mock town or the hosted Convex town and returns structured JSON for the UI.\n- `workers/tick.ts` and `workers/worker_helpers.ts` exercise the same simulation logic outside the request path.\n\n## Next steps\n\n- Replace the mock in-memory town store with real Convex reads and mutations.\n- Move GitHub-auth town ownership from the in-memory mock bridge into Convex-backed persistence.\n- Harden planner-service observability and retries for the hosted background queue path.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdeadronos%2Fvillagesim","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdeadronos%2Fvillagesim","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdeadronos%2Fvillagesim/lists"}