xonecas.io
53129
Pa

PAT / commit a9e5702

chore: repo updates

xonecas2025-12-16 a9e57029b75a3e1db2c2d4aaa157400af4c2f6ca parent 3a8d835

5 files changed

.prettierignore+9−0
@@ -0,0 +1,9 @@
1+node_modules
2+.next
3+.env
4+dist
5+build
6+*.min.js
7+*.min.css
8+drizzle
9+
.prettierrc+10−0
@@ -0,0 +1,10 @@
1+{
2+ "semi": true,
3+ "trailingComma": "es5",
4+ "singleQuote": false,
5+ "printWidth": 100,
6+ "tabWidth": 2,
7+ "useTabs": false,
8+ "plugins": ["prettier-plugin-tailwindcss"]
9+}
10+
AGENTS.md+43−4
@@ -10,6 +10,11 @@ All commands should be run from the project root directory:
1010 - **Build**: `npm run build` - Builds the production-ready Next.js application
1111 - **Start Production**: `npm run start` - Starts the production server (requires build first)
1212 - **Lint**: `npm run lint` - Runs ESLint to check code quality
13+- **Format**: `npm run format` - Formats all files with Prettier
14+- **Format Check**: `npm run format:check` - Checks code formatting without making changes
15+- **DB Generate**: `npm run db:generate` - Generates database migrations using Drizzle Kit
16+- **DB Migrate**: `npm run db:migrate` - Runs database migrations
17+- **DB Studio**: `npm run db:studio` - Opens Drizzle Studio for database management
1318
1419 ## Dependencies
1520
@@ -25,6 +30,8 @@ Agents MUST use only these existing dependencies. Do NOT add new dependencies wi
2530 - **ollama**: ^0.6.3 - Official Ollama npm package for model interaction
2631 - **autoprefixer**: ^10.4.17 - CSS post-processor
2732 - **postcss**: ^8.4.30 - CSS transformation tool
33+- **drizzle-orm**: ^0.45.1 - TypeScript ORM for SQL databases
34+- **better-sqlite3**: ^12.5.0 - Fast SQLite3 database driver
2835
2936 ### Dev Dependencies
3037
@@ -33,6 +40,10 @@ Agents MUST use only these existing dependencies. Do NOT add new dependencies wi
3340 - **@types/react-dom**: ^18.2.19 - TypeScript types for React DOM
3441 - **eslint**: ^8.56.0 - JavaScript/TypeScript linter
3542 - **eslint-config-next**: ^13.5.6 - Next.js ESLint configuration
43+- **prettier**: ^3.2.5 - Code formatter
44+- **prettier-plugin-tailwindcss**: ^0.5.11 - Prettier plugin for sorting Tailwind CSS classes
45+- **drizzle-kit**: ^0.31.8 - Drizzle ORM migration and introspection tool
46+- **@types/better-sqlite3**: ^7.6.13 - TypeScript types for better-sqlite3
3647
3748 ## Code Style Guidelines
3849
@@ -84,8 +95,10 @@ Agents MUST use only these existing dependencies. Do NOT add new dependencies wi
8495 - Set default text colors on topmost container to cascade: `text-slate-800 dark:text-slate-200`
8596
8697 7. **Code Formatting**:
98+ - Use Prettier for code formatting: `npm run format` to format all files
99+ - Prettier configuration is in `.prettierrc` (2 spaces, semicolons, double quotes, 100 char width)
100+ - Prettier automatically sorts Tailwind CSS classes via `prettier-plugin-tailwindcss`
87101 - Use consistent indentation (2 spaces)
88- - Use single quotes for strings in some contexts, double quotes in others (maintain existing file style)
89102 - Add trailing commas in multi-line objects/arrays
90103 - Use semicolons
91104
@@ -120,8 +133,17 @@ Agents MUST use only these existing dependencies. Do NOT add new dependencies wi
120133 │ │ └── icons/
121134 │ │ └── PaperPlaneIcon.tsx # Reusable icon components
122135 │ └── lib/
136+│ ├── db/
137+│ │ ├── index.ts # Database connection and setup
138+│ │ └── schema.ts # Drizzle ORM schema definitions
123139 │ ├── duckduckgo.ts # DuckDuckGo API wrapper
124-│ └── ollama.ts # Ollama API wrapper
140+│ └── ollama.ts # Ollama API wrapper
141+├── drizzle/ # Generated migration files
142+│ ├── meta/ # Migration metadata
143+│ └── *.sql # SQL migration files
144+├── data/ # Database files (created at runtime)
145+│ └── database.db # SQLite database file
146+├── drizzle.config.ts # Drizzle Kit configuration
125147 ├── package.json
126148 ├── tsconfig.json
127149 └── tailwind.config.js
@@ -155,6 +177,22 @@ Agents MUST use only these existing dependencies. Do NOT add new dependencies wi
155177 - Interface: `{ title: string; snippet: string; url: string }`
156178 - Located in: `src/lib/duckduckgo.ts`
157179
180+### Database Integration (Drizzle ORM)
181+
182+- **Database**: SQLite using better-sqlite3
183+- **Location**: `data/database.db` (created automatically)
184+- **Schema**: Defined in `src/lib/db/schema.ts`
185+- **Connection**: Exported from `src/lib/db/index.ts` as `db`
186+- **Tables**:
187+ - `threads`: Stores conversation threads with id, title, createdAt, updatedAt
188+ - `messages`: Stores messages with id, threadId, role, content, createdAt
189+- **Relations**: Messages belong to threads (one-to-many)
190+- **Types**: Exported types `Thread`, `NewThread`, `Message`, `NewMessage`
191+- **Configuration**: `drizzle.config.ts` defines schema path and database location
192+- **Migrations**: Generated in `drizzle/` directory using `npm run db:generate`
193+- **Foreign Keys**: Enabled automatically in database connection
194+- **Usage**: Import `db` from `src/lib/db/index.ts` to query the database
195+
158196 ### Chat API Flow
159197
160198 1. Client sends POST request to `/api/chat` with `{ message: string }`
@@ -168,8 +206,9 @@ Agents MUST use only these existing dependencies. Do NOT add new dependencies wi
168206 1. Start development server: `npm run dev`
169207 2. Make code changes
170208 3. Test in browser (typically `http://localhost:3000`)
171-4. Run linter: `npm run lint`
172-5. Build for production: `npm run build`
209+4. Format code: `npm run format`
210+5. Run linter: `npm run lint`
211+6. Build for production: `npm run build`
173212
174213 ## Important Constraints
175214
package-lock.json+94−1
@@ -30,7 +30,9 @@
3030 "@types/react": "^18.2.55",
3131 "@types/react-dom": "^18.2.19",
3232 "eslint": "^8.56.0",
33- "eslint-config-next": "^13.5.6"
33+ "eslint-config-next": "^13.5.6",
34+ "prettier": "^3.2.5",
35+ "prettier-plugin-tailwindcss": "^0.5.11"
3436 }
3537 },
3638 "node_modules/@alloc/quick-lru": {
@@ -7266,6 +7268,97 @@
72667268 "node": ">= 0.8.0"
72677269 }
72687270 },
7271+ "node_modules/prettier": {
7272+ "version": "3.7.4",
7273+ "resolved": "https://registry.npmjs.org/prettier/-/prettier-3.7.4.tgz",
7274+ "integrity": "sha512-v6UNi1+3hSlVvv8fSaoUbggEM5VErKmmpGA7Pl3HF8V6uKY7rvClBOJlH6yNwQtfTueNkGVpOv/mtWL9L4bgRA==",
7275+ "dev": true,
7276+ "license": "MIT",
7277+ "bin": {
7278+ "prettier": "bin/prettier.cjs"
7279+ },
7280+ "engines": {
7281+ "node": ">=14"
7282+ },
7283+ "funding": {
7284+ "url": "https://github.com/prettier/prettier?sponsor=1"
7285+ }
7286+ },
7287+ "node_modules/prettier-plugin-tailwindcss": {
7288+ "version": "0.5.14",
7289+ "resolved": "https://registry.npmjs.org/prettier-plugin-tailwindcss/-/prettier-plugin-tailwindcss-0.5.14.tgz",
7290+ "integrity": "sha512-Puaz+wPUAhFp8Lo9HuciYKM2Y2XExESjeT+9NQoVFXZsPPnc9VYss2SpxdQ6vbatmt8/4+SN0oe0I1cPDABg9Q==",
7291+ "dev": true,
7292+ "license": "MIT",
7293+ "engines": {
7294+ "node": ">=14.21.3"
7295+ },
7296+ "peerDependencies": {
7297+ "@ianvs/prettier-plugin-sort-imports": "*",
7298+ "@prettier/plugin-pug": "*",
7299+ "@shopify/prettier-plugin-liquid": "*",
7300+ "@trivago/prettier-plugin-sort-imports": "*",
7301+ "@zackad/prettier-plugin-twig-melody": "*",
7302+ "prettier": "^3.0",
7303+ "prettier-plugin-astro": "*",
7304+ "prettier-plugin-css-order": "*",
7305+ "prettier-plugin-import-sort": "*",
7306+ "prettier-plugin-jsdoc": "*",
7307+ "prettier-plugin-marko": "*",
7308+ "prettier-plugin-organize-attributes": "*",
7309+ "prettier-plugin-organize-imports": "*",
7310+ "prettier-plugin-sort-imports": "*",
7311+ "prettier-plugin-style-order": "*",
7312+ "prettier-plugin-svelte": "*"
7313+ },
7314+ "peerDependenciesMeta": {
7315+ "@ianvs/prettier-plugin-sort-imports": {
7316+ "optional": true
7317+ },
7318+ "@prettier/plugin-pug": {
7319+ "optional": true
7320+ },
7321+ "@shopify/prettier-plugin-liquid": {
7322+ "optional": true
7323+ },
7324+ "@trivago/prettier-plugin-sort-imports": {
7325+ "optional": true
7326+ },
7327+ "@zackad/prettier-plugin-twig-melody": {
7328+ "optional": true
7329+ },
7330+ "prettier-plugin-astro": {
7331+ "optional": true
7332+ },
7333+ "prettier-plugin-css-order": {
7334+ "optional": true
7335+ },
7336+ "prettier-plugin-import-sort": {
7337+ "optional": true
7338+ },
7339+ "prettier-plugin-jsdoc": {
7340+ "optional": true
7341+ },
7342+ "prettier-plugin-marko": {
7343+ "optional": true
7344+ },
7345+ "prettier-plugin-organize-attributes": {
7346+ "optional": true
7347+ },
7348+ "prettier-plugin-organize-imports": {
7349+ "optional": true
7350+ },
7351+ "prettier-plugin-sort-imports": {
7352+ "optional": true
7353+ },
7354+ "prettier-plugin-style-order": {
7355+ "optional": true
7356+ },
7357+ "prettier-plugin-svelte": {
7358+ "optional": true
7359+ }
7360+ }
7361+ },
72697362 "node_modules/prop-types": {
72707363 "version": "15.8.1",
72717364 "resolved": "https://registry.npmjs.org/prop-types/-/prop-types-15.8.1.tgz",
package.json+5−1
@@ -7,6 +7,8 @@
77 "build": "next build",
88 "start": "next start",
99 "lint": "next lint",
10+ "format": "prettier --write .",
11+ "format:check": "prettier --check .",
1012 "db:generate": "drizzle-kit generate",
1113 "db:migrate": "drizzle-kit migrate",
1214 "db:studio": "drizzle-kit studio"
@@ -34,6 +36,8 @@
3436 "@types/react": "^18.2.55",
3537 "@types/react-dom": "^18.2.19",
3638 "eslint": "^8.56.0",
37- "eslint-config-next": "^13.5.6"
39+ "eslint-config-next": "^13.5.6",
40+ "prettier": "^3.2.5",
41+ "prettier-plugin-tailwindcss": "^0.5.11"
3842 }
3943 }