|
| 1 | +# ObjectQL - Copilot Instructions |
| 2 | + |
| 3 | +This is a TypeScript-based monorepo for ObjectQL, a universal data query engine designed to bridge MongoDB (schema-less) and PostgreSQL (schema-strict) with a unified JSON-DSL protocol. The project is AI-native and designed for LLM integration. |
| 4 | + |
| 5 | +## Code Standards |
| 6 | + |
| 7 | +### Required Before Each Commit |
| 8 | +- Ensure all TypeScript code compiles without errors |
| 9 | +- Run tests for packages you modified |
| 10 | +- Follow existing code structure and patterns in the monorepo |
| 11 | + |
| 12 | +### Development Flow |
| 13 | +- **Install dependencies**: `npm install` |
| 14 | +- **Build all packages**: `npm run build` (runs TypeScript compiler with project references) |
| 15 | +- **Test all packages**: `npm run test` (runs Jest tests across workspaces) |
| 16 | +- **Test specific package**: `npm run test --workspace=@objectql/core` |
| 17 | +- **Dev server**: `npm run dev` (starts @objectql/server in development mode) |
| 18 | + |
| 19 | +## Repository Structure |
| 20 | + |
| 21 | +This is a monorepo managed by npm workspaces: |
| 22 | + |
| 23 | +- `packages/core`: The query engine, AST parser, and metadata definitions |
| 24 | +- `packages/metadata`: Metadata type definitions and validation |
| 25 | +- `packages/driver-mongo`: MongoDB driver implementation |
| 26 | +- `packages/driver-knex`: SQL driver (PostgreSQL, MySQL, SQLite) using Knex with JSONB strategy |
| 27 | +- `packages/api`: API layer and query handling |
| 28 | +- `packages/server`: Server implementation |
| 29 | +- `packages/ui`: UI components |
| 30 | +- `packages/better-auth`: Authentication utilities |
| 31 | +- `examples/`: Usage examples and demonstrations |
| 32 | +- `docs/`: VitePress documentation site |
| 33 | + |
| 34 | +## Key Guidelines |
| 35 | + |
| 36 | +1. **Follow TypeScript best practices** |
| 37 | + - Use strict type checking |
| 38 | + - Export types from package index files |
| 39 | + - Maintain existing type definitions |
| 40 | + |
| 41 | +2. **Maintain monorepo structure** |
| 42 | + - Each package has its own `package.json`, `tsconfig.json`, and `jest.config.js` |
| 43 | + - Use workspace protocol (`"@objectql/metadata": "*"`) for internal dependencies |
| 44 | + - Root `tsconfig.json` uses project references for incremental builds |
| 45 | + |
| 46 | +3. **Write comprehensive tests** |
| 47 | + - Place tests in `test/` directory within each package |
| 48 | + - Use naming pattern `*.test.ts` for test files |
| 49 | + - Use Jest as the testing framework with `ts-jest` preset |
| 50 | + - Standard Jest config in each package: preset `ts-jest`, testEnvironment `node`, testMatch pattern `**/test/**/*.test.ts` |
| 51 | + - Every new feature must include test cases |
| 52 | + |
| 53 | +4. **Follow metadata specifications** |
| 54 | + - Maintain strict specification for Object Definitions |
| 55 | + - See `docs/specifications/metadata.md` for details |
| 56 | + - Object definitions use `.object.yml` files with YAML format |
| 57 | + |
| 58 | +5. **Preserve AI-native design** |
| 59 | + - Queries are JSON ASTs, not string concatenation |
| 60 | + - Maintain the unified JSON-DSL protocol across drivers |
| 61 | + - Keep the abstraction layer between DSL and driver implementations |
| 62 | + |
| 63 | +6. **Documentation** |
| 64 | + - Update relevant documentation in `docs/` when making significant changes |
| 65 | + - Use VitePress for documentation: `npm run docs:dev` to preview |
| 66 | + |
| 67 | +## Architecture Principles |
| 68 | + |
| 69 | +- **Dual-Stack Engine**: Support both MongoDB (via native driver) and SQL databases (via Knex) |
| 70 | +- **Pluggable Architecture**: Core logic is decoupled from storage drivers |
| 71 | +- **Zero Heavy Dependencies**: Keep the project lightweight and modern |
| 72 | +- **Promise-based async API**: All async operations use Promises, not callbacks |
0 commit comments