Recommended instructions for AI agents working in this repository.
- Stack: Node.js (most recent), Metarhia tech stack including Impress: Metacom, Metaschema, Metautil, etc.
- Entry:
server.js+ static app inapplication/static/(PWA with Service Worker) - Run:
node server, static on./application/static, ports fromapplication/config/server.js
application/config/- App configs for server, ports, cache, log, scale, sessions, etc.application/domain/- Business logic; object-literal modules, accessed asdomain.<name>.<method>application/schemas/- Metarhia schema definitions (entities, types in.types.js)application/static/- Frontend: ES modulesapplication/api/- Server-side API accessible with Metacom RPCapplication/lib/- Common backend librariesapplication/test/- Teststypes/global.d.ts- TypeScript declarations for tooling
- Follow common codebase style
- Do not add comments, better make code self-descriptive but short and clear as well
- Do not use jsdoc comments, we use .d.ts typings
- Server code:
application/**/*.jsexceptapplication/static/*.js- Module format: Object-literal export:
({ method1() {}, method2() {} })do not use'use strict'(ESLint hasstrict: 'off'),sourceType: 'module' - Domain code (e.g.
domain/chat.js). Usedomain.<domain>.<method>(e.g.domain.chat.getRoom(name)). State lives in the same object (e.g.rooms: new Map()) - Config: Pure data objects in
config/*.js(host, ports, timeouts, cors, etc.) - Schemas: Metarhia schema syntax:
'Type','?Type'(optional),{ many: 'Type' },{ type: 'boolean', default: false }, etc. Seeapplication/schemas/and.types.jsfor custom types (e.g.datetime,json,ip)
- Module format: Object-literal export:
- Frontend code:
application/static/*.js- Module format: ES modules (
import/export) - Worker:
worker.js
- Module format: ES modules (
- Tests (
application/**/*.test.js)- Format: Object with
name,options,async run(t). Uset.test('description', async () => { ... })andnode.assertfor assertions
- Format: Object with
- Style, alignment, tooling
- Editor: LF, UTF-8, final newline, max 80 chars per line, trim trailing whitespace, 2 spaces for JS/TS/JSON/YML
- Lint/format: ESLint (
eslint-config-metarhia) + Prettier. Runnpm run lint/npm run fixbefore committing - Types:
npm run types(TypeScript check). Usetypes/global.d.tsand project types for editor support.
- Preserve architecture. Prefer existing patterns (object-literal domains, Metarhia schemas, Metacom + EventTransport in static). Don’t introduce a new framework or module system in
application/without explicit request. - Match existing code style and alignment. Use the same naming/style as surrounding code.
- Respect boundaries. Domain logic in
domain/, schema definitions inschemas/, config inconfig/, static assets and client/worker code instatic/. - Keep changes minimal and testable. Prefer small, focused edits.
- Don’t break the public API or config.
- Security and env. Don’t hardcode secrets or assume env vars that aren’t documented.
- Dependencies: do not add additional packages unless we directly ask you.