|
| 1 | +# AGENTS.md |
| 2 | + |
| 3 | +`motoko` is a TypeScript library that compiles and runs Motoko smart contracts in Node.js or the browser by wrapping a bundled `moc` compiler. |
| 4 | + |
| 5 | +## Commands |
| 6 | + |
| 7 | +- Build: `npm run build` (cleans `lib/` then runs `tsc -p .`). |
| 8 | +- Test: `npm test` (Jest via `ts-jest`). |
| 9 | +- Format: `prettier --write <files>` (no dedicated script; config in `.prettierrc`). |
| 10 | +- Bundle size: `npm run size-limit`. |
| 11 | +- Regenerate bundled compiler/core/error codes: `npm run generate` (prints latest versions), then `npm run generate <moc_version> <core_version>`. |
| 12 | + |
| 13 | +There is no lint script; formatting is the only style check. |
| 14 | + |
| 15 | +## Layout |
| 16 | + |
| 17 | +- `src/` — TypeScript source; the only directory compiled to `lib/`. |
| 18 | +- `lib/` — build output of `tsc`; generated, do not edit (gitignored). |
| 19 | +- `versions/latest/` — bundled `moc.min.js` / `moc_interpreter.min.js`, generated by `npm run generate`; do not hand-edit. |
| 20 | +- `packages/latest/core.json` — bundled Motoko core library, generated; do not hand-edit. |
| 21 | +- `contrib/generated/errorCodes.json` — generated by `npm run generate`; do not hand-edit. |
| 22 | +- `contrib/` — editor/highlighting integrations (hand-written: `hljs.js`, `monaco.js`, `snippets.json`). |
| 23 | +- `utils/generate.js` — the script behind `npm run generate`. |
| 24 | +- `examples/` — runnable usage samples. `tests/` — Jest specs. |
| 25 | + |
| 26 | +## Conventions & gotchas |
| 27 | + |
| 28 | +- Prettier config: 4-space tabs, single quotes, semicolons, trailing commas (`all`). Applied to `lib`, `contrib`, `utils`. |
| 29 | +- A Husky `pre-commit` hook runs `lint-staged`, which formats staged JS/TS in `lib`, `contrib`, `utils`. |
| 30 | +- `.npmrc` sets `min-release-age=7`; dependency installs respect a 7-day minimum release age. |
| 31 | +- Tests run on Node.js 22.x and 24.x in CI; publish and generate workflows use Node 24. |
| 32 | +- CI runs `npm ci`, `npm run build`, `npm test` on pushes/PRs to `main`. |
| 33 | +- Publishing is automatic: pushing a changed `version` in `package.json` to `main` builds, tests, and publishes to npm. |
| 34 | +- The `generate` script reads a Motoko checkout for error codes; override its location with the `MOTOKO_REPO` environment variable (defaults to `../../motoko/`). |
0 commit comments