You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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.
Copy file name to clipboardExpand all lines: AGENTS.md
+18-24Lines changed: 18 additions & 24 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -4,33 +4,38 @@ Documentation:
4
4
5
5
Development workflows:
6
6
7
+
- This is a Node.js monorepo managed with Yarn workspaces
8
+
- Published packages are prefixed with `@metamask/`, private packages with `@ocap/`
7
9
- Use `yarn` and `yarn workspace` to run package scripts:
8
10
-`lint:fix` for linting
9
11
-`test:dev:quiet` for unit tests, add `--coverage=true` to include coverage
10
12
- if available, integration and e2e tests invoked separately via
11
13
`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`)
13
15
- 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`
14
18
15
19
General conventions:
16
20
17
21
- Use `@metamask/superstruct` for runtime type checking and to define object types
18
22
- 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`)
25
24
- If a function has more than two arguments or could be expected to grow thereto,
26
25
give it an options bag (i.e. named parameters)
27
26
28
27
Object capability (ocap) patterns:
29
28
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
31
31
- 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({ ... })`
34
39
- Use `E()` from `@endo/eventual-send` to:
35
40
- Communicate with objects between vats or between processes with a CapTP connection
36
41
- Queue messages on a promise (that resolves to some object with methods)
@@ -44,16 +49,11 @@ Testing:
44
49
- Use `vitest` for testing
45
50
- Avoid introducing global state in tests
46
51
- 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
52
55
- 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', ...)`)
53
56
- 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
57
57
- Check the local package `@ocap/test-utils` (`packages/test-utils`) for test utilities before creating new ones
58
58
- Use `vi.useFakeTimers()` for tests that rely on timers
59
59
@@ -72,12 +72,6 @@ File and directory structure:
72
72
- Test utilities used by a single package should be separated into that package's `<package-root>/test/` directory
73
73
- Test utilities used by multiple packages should be relocated into the dedicated `test-utils` package
74
74
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
0 commit comments