# GitHub Copilot Instructions — @bytelyst Common Platform

> For full agent instructions, read [`AGENTS.md`](../AGENTS.md) at the repo root.

## Project Context

Shared `@bytelyst/*` packages and `@lysnrai/*` microservices for the ByteLyst ecosystem. Product-agnostic — consumed by LysnrAI and MindLyst.

## Code Generation Rules

### Always

- Import `PRODUCT_ID` from `@bytelyst/config` (`loadProductIdentity()`) — never hardcode `"lysnrai"`
- Include `productId` field in every Cosmos DB document
- Validate inputs with Zod schemas
- Use `req.log` / `app.log` for Fastify logging
- Use ESM imports (`import ... from "./file.js"` with `.js` extension)
- Follow the module pattern: `types.ts` → `repository.ts` → `routes.ts`
- Propagate `x-request-id` headers in service-to-service calls
- Use `peerDependencies` for heavy deps in packages
- Use `workspace:*` for inter-package dependencies

### Never

- `console.log` in production code
- `any` type in TypeScript
- `Math.random()` for IDs in loops without an index suffix
- Hardcoded secrets or API keys
- `npm` commands (use `pnpm`)
- Edit generated token files directly (edit `bytelyst.tokens.json` instead)

### Suggestions Context

When suggesting code in these directories, follow these patterns:

| Directory                 | Framework          | Key Pattern                                               |
| ------------------------- | ------------------ | --------------------------------------------------------- |
| `packages/*/src/`         | TypeScript library | Export from `index.ts`, `peerDependencies` for heavy deps |
| `services/*/src/modules/` | Fastify 5 + Zod    | `types.ts` → `repository.ts` → `routes.ts`                |
| `services/*/src/lib/`     | Re-exports         | Re-export from `@bytelyst/*` packages                     |
| `packages/design-tokens/` | Token generator    | Edit `bytelyst.tokens.json`, run `generate.ts`            |

### Commit Messages

Format: `type(scope): description`

Types: `feat`, `fix`, `docs`, `refactor`, `test`, `chore`
