|
| 1 | +# Rambda — Agent instructions |
| 2 | + |
| 3 | +## Repository structure |
| 4 | + |
| 5 | +- **`source/`** — development directory. Contains both implementations (`.js`) and tests (`.spec.js`, `-spec.ts`). |
| 6 | +- **`src/`** — generated artifact. Rebuilt from `source/` via `yarn populatereadme` (delegates to sibling `rambda-scripts` repo). Only `.js` files for registered methods are copied; spec files are excluded. |
| 7 | +- **`rambda.js`** — barrel entrypoint, re-exports from `./src/`. Also regenerated during `populatereadme`. |
| 8 | +- **`files/index.d.ts`** (5090 lines) — the true TypeScript definition source. `source/index.d.ts` is a stub. |
| 9 | +- **`dist/`** — rollup output (CJS, ESM, UMD). |
| 10 | + |
| 11 | +## Commands |
| 12 | + |
| 13 | +| Command | Action | |
| 14 | +|---|---| |
| 15 | +| `yarn test` | Run all runtime tests (`vitest run --watch -u`) | |
| 16 | +| `yarn test:ci` | Run runtime tests in CI mode | |
| 17 | +| `yarn test:typings` / `yarn ts` | Run type-level tests only | |
| 18 | +| `yarn test:file <path>` | Run a single test file | |
| 19 | +| `yarn lint:typings` | `tsc` type check | |
| 20 | +| `yarn lint` | Run ESLint + oxlint + Biome + Prettier on `source/` | |
| 21 | +| `yarn build` | Bundle `dist/` via rollup (CJS + ESM + UMD) | |
| 22 | +| `yarn out` | Full pipeline: populate docs → sync `src/` → build → docsify | |
| 23 | + |
| 24 | +## CI order (must match) |
| 25 | + |
| 26 | +`yarn lint:typings` → `yarn test:ci` → `yarn test:typings` |
| 27 | + |
| 28 | +## Testing quirks |
| 29 | + |
| 30 | +- Two vitest configs: `vitest.config.js` (runtime `*.spec.js` + `*-spec.ts`) and `vitest.typings.config.js` (type-only `*-spec.ts`). |
| 31 | +- Runtime tests use `test(...)` (globals from vitest). Type tests use `describe/it` + `expectTypeOf`. |
| 32 | +- Coverage threshold: **100%** enforced. |
| 33 | +- `source/_internals/` and `source/*.ts` excluded from coverage. |
| 34 | + |
| 35 | +## Method conventions |
| 36 | + |
| 37 | +- **All methods are curried**: `filter(fn)(list)`, **never** `filter(fn, list)`. |
| 38 | +- Designed for `pipe(input, ...fns)` usage — type inference works best inside `R.pipe`. |
| 39 | +- `max-params: 2` enforced (ESLint). |
| 40 | +- `max-statements: 12` enforced (ESLint). |
| 41 | +- File naming: `.ts` files must be `kebab-case`, `.tsx` must be `CAMEL_CASE`. |
| 42 | +- Semicolons are disabled (Prettier). Single quotes preferred. |
| 43 | + |
| 44 | +## Type definition workflow |
| 45 | + |
| 46 | +1. Edit `files/index.d.ts`. |
| 47 | +2. Add type test in `source/*-spec.ts`. |
| 48 | +3. Verify with `yarn test:typings`. |
| 49 | +4. Use `// @ts-expect-error` for tests expected to fail. |
| 50 | + |
| 51 | +## Build note |
| 52 | + |
| 53 | +`yarn out` requires `rambda-scripts` cloned as a sibling directory (`../rambda-scripts`). Without it, `populatedocs`, `populatereadme`, and `create-docsify` will fail. |
0 commit comments