This file provides guidance for AI assistants working in this repository.
OpenGrimoire (Agent Context Atlas): a Next.js app with a local-first context graph (brain map) plus survey, alignment, and admin flows backed by a gitignored SQLite file (data/opengrimoire.sqlite by default). Product copy targets OpenGrimoire, not a specific client event. GitHub: ManintheCrowds/OpenGrimoire. Local clone folder: prefer OpenGrimoire; legacy folder name OpenGrimoire still appears in older docs and paths until everyone renames.
Canonical persistence story: See README.md. Route × persistence × tools inventory: docs/OPENGRIMOIRE_SYSTEMS_INVENTORY.md.
- Routes:
/context-atlasand/brain-map(same UI). - Data: Static JSON —
public/brain-map-graph.json, or gitignoredpublic/brain-map-graph.local.jsonwhen present. - API:
GET /api/brain-map/graphserves the graph (do not use bare/brain-map-graph.jsonURLs — blocked). No database file required for this path beyond static JSON. - Agents: docs/AGENT_INTEGRATION.md.
- Regeneration:
cdinto sibling MiscRepos (see README.md), then runpython .cursor/scripts/build_brain_map.pywithCURSOR_STATE_DIR/CURSOR_STATE_DIRSas documented in README.
Dual label: Sync Session is the UX name for the survey flows at /operator-intake and /survey (submissions → POST /api/survey). Alignment Context is the alignment-item API and persistence (/api/alignment-context, alignment CLI)—a separate path from the survey form submit.
- Routes:
/operator-intake,/survey,/login,/admin/*, visualization data — persistence inOPENGRIMOIRE_DB_PATH(defaultdata/opengrimoire.sqlite; directory gitignored). - Admin auth:
POST /api/auth/loginsets an HTTP-only signed cookie (opengrimoire_session). ConfigureOPENGRIMOIRE_ADMIN_PASSWORDorOPENGRIMOIRE_ADMIN_PASSWORD_HASHandOPENGRIMOIRE_SESSION_SECRET(see.env.example). - Historical schema: Postgres migrations under
supabase/migrations/are reference only; runtime schema is created by the app (Drizzle + bootstrap).
npm run dev— Dev server at http://localhost:3001 (seepackage.jsonnext dev -p 3001).npm run build/npm run start— Production build and server.npm run lint— ESLint.npm run type-check—tsc --noEmit.npm run test— Vitest.npm run verify—lint+type-check+test.
- Frontend: Next.js 14 (App Router), React 18, TypeScript, Tailwind, OpenGrimoire theme tokens.
- Visualization: D3.js (2D), Three.js (3D constellation).
- State: React Context, Zustand.
- Backend: SQLite via
better-sqlite3(server-only); repositories undersrc/lib/storage/repositories/.
- Brain-map only: Optional
BRAIN_MAP_SECRET/NEXT_PUBLIC_BRAIN_MAP_SECRET(see docs/security/NEXT_PUBLIC_AND_SECRETS.md). - Alignment API: Optional
ALIGNMENT_CONTEXT_API_SECRETwhen using/api/alignment-context. - App URL:
NEXT_PUBLIC_APP_URL=http://localhost:3001for local dev. - SQLite + admin:
OPENGRIMOIRE_DB_PATH,OPENGRIMOIRE_SESSION_SECRET,OPENGRIMOIRE_ADMIN_PASSWORDorOPENGRIMOIRE_ADMIN_PASSWORD_HASH— see.env.example.
src/app/— App Router pages and API routes.src/components/BrainMap/— Context graph UI.docs/GUI_ACTION_MAP_BRAIN_MAP.md— Operator GUI actions + OpenHarness graph pipeline (agent-native parity).src/db/— Drizzle schema and SQLite client/bootstrap.src/lib/storage/repositories/— Alignment and survey data access.public/brain-map-graph.json— Default graph data for the viewer.
- Three.js and heavy D3 views are client-side where applicable (
'use client'). - Custom fonts under
/public/branding/.
- Sample/mock data:
src/data/,sample-survey-data.json, etc. - E2E: Playwright (
npm run test:e2e); seeplaywright.config.ts. - Tagged releases: RELEASING.md — optional
npm run test:maestrowhen Maestro is installed.