git-subtree-dir: foundations/core git-subtree-mainline:16b1109180git-subtree-split:4f31d1b326
3.0 KiB
GitHub Copilot Instructions - Huly Core
Type: Rush monorepo (TypeScript)
License: EPL-2.0
Build System: Rush v5.158.1 + pnpm v10.15.1
Critical Rules
- Always use Rush commands, never npm/pnpm directly:
rush install,rush build,rush test,rush update - Internal dependencies must use
workspace:^protocol in package.json - All packages extend
@hcengineering/platform-rigfor tsconfig/eslint - don't override configs - Co-locate tests in
src/__tests__/directories (Jest + ts-jest) - Named exports only - avoid default exports
Quick Start
rush install && rush build # Initial setup
rush build:watch # Development mode
rush rebuild # Force clean rebuild (clears cache)
rush test # Run all tests
Package Structure (All packages follow this)
packages/<name>/
├── src/index.ts # Main entry (exports)
├── lib/ # Compiled JS (gitignored)
├── types/ # TS declarations (gitignored)
├── package.json # Scope: @hcengineering/, main: lib/index.js
├── tsconfig.json # Extends platform-rig
└── jest.config.js # preset: 'ts-jest', roots: ['./src']
Key Architecture Patterns
Plugin System: @hcengineering/platform provides dependency injection. Packages register resources/services via plugin manifests. Example: packages/core/src/plugin.ts
Data Flow: core → abstract models (Doc, Ref, Class) → client → concrete implementations → WebSocket/REST via api-client
Text Processing: Modular text-* packages (core/html/markdown/ydoc) support extensible rich-text editing with Yjs collaboration
Storage Abstraction: storage package defines interfaces; storage-client provides implementations; backends are pluggable
Common Tasks
Add a package: Create under packages/, add standard files (see structure above), register in rush.json if needed, run rush update
Debug build failures: Check <package>/rush-logs/ and .build/build.tsbuildinfo; use rush rebuild to clear incremental state
Run single package tests: cd packages/<name> && rushx test
Update dependencies: Edit package.json, run rush update, verify with rush build
Where to Look
- Rush config:
common/config/rush/,rush.json - Shared scripts:
common/scripts/(coverage merging, install helpers) - Core abstractions:
packages/core/src/(Doc, Hierarchy, TxOperations) - Platform runtime:
packages/platform/src/(plugin loader, resources) - Client layer:
packages/client/src/(LiveQuery, TxOperations client wrapper)
Watch Out For
- Rush uses incremental builds - cached artifacts in
.build/andcommon/temp/ - TypeScript strict mode enabled - type safety enforced
- platform-rig centralizes tooling configs (ESLint, Prettier, tsconfig)
- Check
common/temp/rush-recycler/for moved files during dependency updates