Skip to content

Commit 3064275

Browse files
authored
docs: Update AGENTS.md (#851)
Cleans up self-evident conventions from `AGENTS.md` and adds non-obvious, project-specific information that AI agents can't infer from reading source files. Changes based on Claude's own suggestions and some things I've noticed.
1 parent 637be39 commit 3064275

1 file changed

Lines changed: 18 additions & 24 deletions

File tree

AGENTS.md

Lines changed: 18 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -4,33 +4,38 @@ Documentation:
44

55
Development workflows:
66

7+
- This is a Node.js monorepo managed with Yarn workspaces
8+
- Published packages are prefixed with `@metamask/`, private packages with `@ocap/`
79
- Use `yarn` and `yarn workspace` to run package scripts:
810
- `lint:fix` for linting
911
- `test:dev:quiet` for unit tests, add `--coverage=true` to include coverage
1012
- if available, integration and e2e tests invoked separately via
1113
`test:integration` and `test:e2e`, respectively
12-
- `build` and `test:dev` from root are cached using Turboerpo (`turbo`)
14+
- `build`, `build:dev`, `test:dev`, and `test:dev:quiet` from root are cached using Turborepo (`turbo`)
1315
- No other scripts use `turbo`
16+
- When adding another monorepo package as a dependency, also add it to
17+
`references` in both `tsconfig.json` and `tsconfig.build.json`
1418

1519
General conventions:
1620

1721
- Use `@metamask/superstruct` for runtime type checking and to define object types
1822
- Use TypeDoc for documentation
19-
- Naming conventions:
20-
- Nouns for variable names (e.g. `isKernelActive`, `hasVatAccess`, `unresolvedMessages`)
21-
- Verbs for function names (e.g. `startVat`, `stopKernel`)
22-
- kebab-case for package and file names (`@ocap/test-utils`, `kernel-worker.js`, `vat.js`)
23-
- Factory methods: `X.make()`
24-
- Factory functions: `makeX()`
23+
- kebab-case for package and file names (`@ocap/test-utils`, `kernel-worker.js`, `vat.js`)
2524
- If a function has more than two arguments or could be expected to grow thereto,
2625
give it an options bag (i.e. named parameters)
2726

2827
Object capability (ocap) patterns:
2928

30-
- Production code should run under "lockdown" from `@endo/lockdown`
29+
- Production code must run under "lockdown" from `@endo/lockdown` / `ses` via the local `@metamask/kernel-shims` package
30+
— Many `@endo/*` packages fail silently or throw in non-locked-down environments
3131
- Lockdown must be the first thing that runs in the given JavaScript realm for it to work
32-
- Use `harden()` from `@endo/ses` for immutability where feasible
33-
- Including object literals, class instances, class prototypes, etc.
32+
- Use "development" mode (per-package) only for local debugging; it disables lockdown and
33+
coverage and does not run in CI
34+
- Some tests use a mock shim from `@ocap/repo-tools/test-utils/mock-endoify` for test runner compatibility
35+
- Use `harden()` (globally available via lockdown) for immutability where feasible:
36+
- Harden class instances: `harden(this)` at the end of constructors
37+
- Harden classes: `harden(ClassName)` after the class definition
38+
- Harden returned object literals inline: `return harden({ ... })`
3439
- Use `E()` from `@endo/eventual-send` to:
3540
- Communicate with objects between vats or between processes with a CapTP connection
3641
- Queue messages on a promise (that resolves to some object with methods)
@@ -44,16 +49,11 @@ Testing:
4449
- Use `vitest` for testing
4550
- Avoid introducing global state in tests
4651
- If you need a mock object of type `Foo`, add a utility like `const makeFoo = () => { ... }`
47-
- Always use `toStrictEqual()` for deep object comparisons
48-
- If testing all properties of an object, use a single `toStrictEqual()` on the entire object
49-
instead of multiple `expect()` calls
50-
- Use `it.each()` for parameterized tests
51-
- Use logically nested `describe()` blocks
52+
- If testing all properties of an object, use a single `toStrictEqual()` on the entire object
53+
instead of multiple `expect()` calls
54+
- Prefer `it.each()` for parameterized tests
5255
- Test titles should use concise verb forms without "should" (e.g., `it('creates and starts libp2p node', ...)` not `it('should create and start libp2p node', ...)`)
5356
- Avoid negative cases, but if you must, use "does not" instead of "should not" (e.g., `it('does not duplicate relays', ...)`)
54-
- Mock functions with `vi.fn()` and explicit return types
55-
- Mock external dependencies using vitest's `vi.mock()`
56-
- Aim for complete unit test coverage when writing tests
5757
- Check the local package `@ocap/test-utils` (`packages/test-utils`) for test utilities before creating new ones
5858
- Use `vi.useFakeTimers()` for tests that rely on timers
5959

@@ -72,12 +72,6 @@ File and directory structure:
7272
- Test utilities used by a single package should be separated into that package's `<package-root>/test/` directory
7373
- Test utilities used by multiple packages should be relocated into the dedicated `test-utils` package
7474

75-
UI and styling:
76-
77-
- For React UI components, prefer CSS classes (e.g., `className="bg-section p-4 rounded mb-4"`) over inline styles
78-
- Use design system components (BadgeStatus, TextComponent, etc.) consistently
79-
- Maintain consistent spacing patterns (e.g., `gap-12`, `mb-4`, `mt-2`)
80-
8175
Cross-environment compatibility:
8276

8377
- Libraries should be platform-agnostic and run in any environment unless otherwise specified

0 commit comments

Comments
 (0)