# @lilith/sync

General-purpose CRDT sync service (Yjs) for offline-first client/server document
synchronization

TypeScript package. Built with tsc/tsup; consumed by other workspaces.

## Scripts

| Command              | Definition                                        |
| -------------------- | ------------------------------------------------- |
| `pnpm build`         | tsc                                               |
| `pnpm start`         | node dist/server.js                               |
| `pnpm dev`           | tsx watch src/server.ts                           |
| `pnpm test`          | vitest run                                        |
| `pnpm test:watch`    | vitest watch                                      |
| `pnpm test:coverage` | vitest run --coverage                             |
| `pnpm lint`          | eslint src --ext .ts                              |
| `pnpm lint:fix`      | eslint src --ext .ts --fix                        |
| `pnpm typecheck`     | tsc --noEmit                                      |
| `pnpm migrate`       | knex --knexfile src/db/knexfile.ts migrate:latest |

## Layout

- `__tests__/`
- `src/`

## Working on this package

The fastest local loop is via Nx:

```bash
pnpm nx test lilith-sync
pnpm nx lint lilith-sync
pnpm nx build lilith-sync
```

When Nx is unhappy (usually because another worktree has duplicate project
names), bypass it with the underlying tools from this directory:

```bash
npx tsc --noEmit
npx vitest run
```

See the [root README](../../../README.md) for monorepo-wide conventions (catalog
deps, commit format, git workflow). See the
[Contributor Guide](../../../docs/CONTRIBUTING.md) for the full PR workflow.
