Skip to content

Commit b03fba3

Browse files
authored
Merge branch 'main' into sirtimid/remote-comms-resource-limits
2 parents c60b263 + be89d42 commit b03fba3

File tree

39 files changed

+304
-221
lines changed

39 files changed

+304
-221
lines changed

.claude/commands/check.md

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
---
2+
name: check
3+
description: Lints, builds, and tests the code.
4+
argument-hint: [package-name]
5+
allowed-tools:
6+
- Bash(yarn lint*)
7+
- Bash(yarn build*)
8+
- Bash(yarn test*)
9+
- Bash(yarn workspace *)
10+
model: claude-haiku-4-5
11+
---
12+
13+
Run the following commands to check the current state of the code:
14+
15+
If `$ARGUMENTS` is provided (e.g. `@metamask/ocap-kernel`), run the commands in
16+
that workspace using `yarn workspace $ARGUMENTS`:
17+
18+
1. `yarn workspace $ARGUMENTS lint:fix`
19+
2. `yarn workspace $ARGUMENTS build`
20+
3. `yarn workspace $ARGUMENTS test:dev`
21+
22+
If `$ARGUMENTS` is empty, run the commands at the monorepo root:
23+
24+
1. `yarn lint:fix`
25+
2. `yarn build`
26+
3. `yarn test:dev`
27+
28+
Return the results of the commands.

.claude/commands/commit-push-pr.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
---
2+
name: commit-push-pr
3+
description: Optionally checks, then commits and pushes code to the remote repository, and creates a pull request.
4+
argument-hint: check | force
5+
allowed-tools:
6+
- Skill
7+
model: claude-haiku-4-5
8+
---
9+
10+
Run `/commit-push $ARGUMENTS` then `/pr`.

.claude/commands/commit-push.md

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
---
2+
name: commit-push
3+
description: Optionally checks, then commits and pushes code to the remote repository.
4+
argument-hint: check | force
5+
allowed-tools:
6+
- Bash(git branch*)
7+
- Bash(git checkout*)
8+
- Bash(git add*)
9+
- Bash(git status*)
10+
- Bash(git commit*)
11+
- Bash(git push*)
12+
- Bash(git diff*)
13+
- Bash(git log*)
14+
- Skill
15+
model: claude-haiku-4-5
16+
---
17+
18+
Arguments: $ARGUMENTS
19+
20+
If the argument is "force", skip the check step. Otherwise (default), run the `/check` command first to lint, build, and test the code. If any of the checks fail, stop and report the errors.
21+
22+
Once ready, commit and push the code by following these steps:
23+
24+
1. Run these bash commands in parallel to understand the current state:
25+
26+
- `git status` to see all untracked files
27+
- `git diff HEAD` to see both staged and unstaged changes
28+
- `git log --oneline -10` to see recent commit messages for style consistency
29+
30+
2. If you are on the `main` branch, create a new feature branch using `git branch` and switch to it.
31+
32+
3. Analyze all changes and draft a commit message:
33+
34+
- Summarize the nature of the changes (new feature, enhancement, bug fix, refactoring, test, docs, etc.)
35+
- Use the conventional commit format: `type(scope): description`
36+
- Keep the first line under 72 characters
37+
- Do not commit files that likely contain secrets (.env, credentials.json, etc.)
38+
39+
4. Stage and commit the changes:
40+
41+
- Add relevant files using `git add`
42+
- Create the commit with a message ending with:
43+
```
44+
Co-Authored-By: Claude <[email protected]>
45+
```
46+
- Use a HEREDOC for the commit message to ensure proper formatting
47+
48+
5. Push to the remote repository:
49+
50+
- Run `git push` to push the commit
51+
- If the branch has no upstream, use `git push -u origin <branch-name>`
52+
53+
6. Report the results including:
54+
- The commit hash
55+
- The commit message
56+
- The push status

.claude/commands/pr.md

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
---
2+
name: pr
3+
description: Creates a pull request for the current branch.
4+
allowed-tools:
5+
- Bash(git status*)
6+
- Bash(git log*)
7+
- Bash(git show*)
8+
- Bash(git diff*)
9+
- Bash(gh pr create*)
10+
model: claude-haiku-4-5
11+
---
12+
13+
1. Run `git status`. If any of the following conditions apply, stop and report the errors:
14+
- There are unstaged changes
15+
- There are untracked files
16+
- The current branch is the default branch (`main`)
17+
2. Run `git log main..HEAD --oneline` to see the commit history.
18+
3. Run `git diff` and/or `git show` as necessary to understand the changes.
19+
4. Run `gh pr create` to create a pull request.
20+
5. Return the results of the commands.

.claude/settings.json

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
{
2+
"permissions": {
3+
"allow": ["Skill(code-review)", "Skill(glossary)"],
4+
"deny": ["Read(**/.env)", "Read(**/.env.*)"]
5+
}
6+
}
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
---
2+
name: code-review
3+
description: How to review code; a pull request, feature branch, local changes etc.
4+
---
5+
6+
When asked to review code, whether a PR on GitHub or some local changes, provide feedback on:
7+
8+
- Code quality and best practices
9+
- Potential bugs or issues
10+
- Performance considerations
11+
- Security concerns
12+
- Test coverage
13+
14+
Use the repository's CLAUDE.md for guidance on style and conventions.
15+
If you encounter terms that should be added to the glossary, invoke the glossary
16+
skill using: Skill tool with skill="glossary"
17+
Be constructive and helpful in your feedback.

.claude/skills/glossary/SKILL.md

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
---
2+
name: glossary
3+
description: How to add entries to the glossary
4+
---
5+
6+
The [glossary](../../docs/glossary.md) explains terms with specific meanings in this
7+
project. When a new term is introduced—or an old term without a glossary entry discovered—
8+
consider adding the term to the glossary.
9+
10+
When doing so:
11+
12+
- Include links to relevant implementation files using `[term](../path/to/file.ts)` syntax
13+
- Use cross-references with `[term](#term)` syntax to link related concepts
14+
- Consider how new terms relate to existing architectural concepts

AGENTS.md

Lines changed: 63 additions & 135 deletions
Original file line numberDiff line numberDiff line change
@@ -1,148 +1,76 @@
1-
Code style and structure:
2-
3-
- Write concise, accurate JavaScript/TypeScript with modern ES Module syntax.
4-
- Always use TypeScript unless otherwise specified.
5-
- Use a class-based structure where applicable.
6-
- Use `harden()` from `@endo/ses` for object security.
7-
- Use object capability (ocap) design patterns.
8-
- Use `@metamask/superstruct` for validation.
9-
- Use TypeDoc for documentation.
10-
- Use the following naming conventions:
11-
- camelCase for functions and variables.
12-
- PascalCase for classes, types, interfaces, and enums.
13-
- kebab-case for package and file names (`@ocap/test-utils`, `kernel-worker.js`, `vat.js`).
14-
- Nouns for variable names (e.g. `isKernelActive`, `hasVatAccess`, `unresolvedMessages`)
15-
- Verbs for function names (e.g. `startVat`, `stopKernel`)
16-
- Use explicit return types for all functions.
17-
18-
Testing and debugging:
19-
20-
- Use `vitest` for testing.
21-
- Prefer `toStrictEqual()` for deep object comparisons in tests.
22-
- Use `it.each()` for parameterized tests.
23-
- Use descriptive test blocks with proper nesting.
24-
- 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', ...)`).
25-
- For negative cases, use "does not" instead of "should not" (e.g., `it('does not duplicate relays', ...)`).
26-
- Mock functions with `vi.fn()` and explicit return types.
27-
- Aim for high test coverage, including unit and integration tests.
28-
- Mock external dependencies using vitest's `vi.mock()`.
29-
30-
TypeScript usage:
1+
Documentation:
312

32-
- Use types for defining message structures and data contracts. Do not use `interface` declarations.
33-
- Leverage union types and type guards for robust runtime checks.
34-
- Use `Readonly<T>` for immutable data structures.
35-
- Follow strict mode settings for TypeScript.
36-
- Never use the `any` type.
37-
- Prefer `#` private fields over `private` class fields.
3+
- Check the [glossary](./docs/glossary.md) for definitions of unclear terms.
384

39-
File and directory structure:
5+
Development workflows:
406

41-
- Maintain a monorepo structure using Yarn workspaces.
42-
- Place package source files under `<package-root>/src/`.
43-
- Co-locate a package's unit tests with their covered source files in the `<package-root>/src/` directory (e.g. `ocap-kernel/src/kernel-worker.ts` should be tested in `ocap-kernel/src/kernel-worker.test.ts`).
44-
- Test utilities used by a single package should be separated into that package's `<package-root>/test/` directory.
45-
- If the utility is small, it can be in-lined in the test file.
46-
- Test utilities used by multiple packages should be relocated into the dedicated `test-utils` package.
7+
- Use `yarn` and `yarn workspace` to run package scripts:
8+
- `lint:fix` for linting
9+
- `test:dev` for unit tests, `test` to include coverage
10+
- e2e tests invoked separately via `test:e2e`, if available
11+
- `build` from root is cached using Turborepo
4712

48-
Kernel architecture:
13+
General conventions:
4914

50-
- Ensure clear separation of concerns between Kernel, Vat, and Supervisor components.
51-
- Use streams from the `streams` package for message passing / IPC.
15+
- Use `@metamask/superstruct` for runtime type checking and to define object types
16+
- Use TypeDoc for documentation
17+
- Naming conventions:
18+
- Nouns for variable names (e.g. `isKernelActive`, `hasVatAccess`, `unresolvedMessages`)
19+
- Verbs for function names (e.g. `startVat`, `stopKernel`)
20+
- kebab-case for package and file names (`@ocap/test-utils`, `kernel-worker.js`, `vat.js`)
21+
- Factory methods: `X.make()`
22+
- Factory functions: `makeX()`
23+
- If a function has more than two arguments or could be expected to grow thereto,
24+
give it an options bag (i.e. named parameters)
25+
26+
Object capability (ocap) patterns:
27+
28+
- Production code should run under "lockdown" from `@endo/lockdown`
29+
- Lockdown must be the first thing that runs in the given JavaScript realm for it to work
30+
- Use `harden()` from `@endo/ses` for immutability where feasible
31+
- Including object literals, class instances, class prototypes, etc.
32+
- Use `E()` from `@endo/eventual-send` to:
33+
- Communicate with objects between vats or between processes with a CapTP connection
34+
- Queue messages on a promise (that resolves to some object with methods)
35+
- If an object is to be made remotable, turn it into an exo using the internal `makeDefaultExo`
36+
which builds on `@endo/exo`
37+
- Do not use `Far` from `@endo/far`
38+
- It's fine to use `E()` on local objects that aren't exos
39+
40+
Testing:
41+
42+
- Use `vitest` for testing
43+
- Always use `toStrictEqual()` for deep object comparisons
44+
- Use `it.each()` for parameterized tests
45+
- Use logically nested `describe()` blocks
46+
- 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', ...)`)
47+
- Avoid negative cases, but if you must, use "does not" instead of "should not" (e.g., `it('does not duplicate relays', ...)`)
48+
- Mock functions with `vi.fn()` and explicit return types
49+
- Mock external dependencies using vitest's `vi.mock()`
50+
- Aim for complete unit test coverage when writing tests
51+
52+
TypeScript:
53+
54+
- Prefer `type`; do not use `interface` declarations
55+
- Prefer `#` private fields over `private` class fields
56+
- Never use the `any` type
57+
- Never use `enum`:s; always use string literal unions instead
5258

53-
Web extensions:
59+
File and directory structure:
5460

55-
- Use the latest manifest version (v3) for Chrome.
56-
- Minimize permissions in `manifest.json`, using optional permissions where feasible.
57-
- Apply Content Security Policies (CSP) in `manifest.json`.
61+
- Maintain a monorepo structure using Yarn workspaces
62+
- Place package source files under `<package-root>/src/`
63+
- Co-locate a package's unit tests with their covered source files in the `<package-root>/src/` directory (e.g. `ocap-kernel/src/kernel-worker.ts` should be tested in `ocap-kernel/src/kernel-worker.test.ts`)
64+
- Test utilities used by a single package should be separated into that package's `<package-root>/test/` directory
65+
- Test utilities used by multiple packages should be relocated into the dedicated `test-utils` package
5866

5967
UI and styling:
6068

61-
- Create responsive designs for UI components like popups or settings.
62-
- Use Flexbox or CSS Grid for layout consistency.
63-
- Use plain CSS, HTML, and JavaScript for UI components. Do not use React or other frameworks.
64-
- For React UI components, prefer CSS classes (e.g., `className="bg-section p-4 rounded mb-4"`) over inline styles.
65-
- Use inline styles only for dynamic values or when CSS classes are not available.
66-
- Structure layouts with semantic containers and proper spacing.
67-
- Use design system components (BadgeStatus, TextComponent, etc.) consistently.
68-
- Group related UI elements in logical sections with descriptive comments.
69-
- Maintain consistent spacing patterns (e.g., `gap-12`, `mb-4`, `mt-2`).
70-
- Use responsive classes and proper flex layouts for different screen sizes.
69+
- For React UI components, prefer CSS classes (e.g., `className="bg-section p-4 rounded mb-4"`) over inline styles
70+
- Use design system components (BadgeStatus, TextComponent, etc.) consistently
71+
- Maintain consistent spacing patterns (e.g., `gap-12`, `mb-4`, `mt-2`)
7172

7273
Cross-environment compatibility:
7374

74-
- Libraries should be platform-agnostic and run in any environment unless otherwise specified.
75-
- Packages like `extension` (browser) and `cli` (Node.js) are platform-specific.
76-
- Implement graceful degradation for environment-specific features.
77-
78-
Type safety:
79-
80-
- Prefer `@metamask/superstruct` when defining object types.
81-
- Use runtime type guards, not type assertions, when type narrowing is required.
82-
- Define object types for all data structures.
83-
- Avoid redundant type declarations.
84-
85-
Error handling:
86-
87-
- Use structured error classes with inheritance, error codes, and messages.
88-
- Implement error marshaling and unmarshaling.
89-
- Use type guards for error checking.
90-
91-
Documentation:
92-
93-
- Check the [glossary](./docs/glossary.md) for definitions of unclear terms.
94-
- Use JSDoc and TypeDoc for public APIs.
95-
- Include examples and document error cases.
96-
- When adding glossary entries:
97-
- Include links to relevant implementation files using `[term](../path/to/file.ts)` syntax
98-
- Use cross-references with `[term](#term)` syntax to link related concepts
99-
- Consider how new terms relate to existing architectural concepts
100-
101-
PR review:
102-
103-
- Check if new terms, concepts, or architectural patterns are introduced that should be added to the glossary for AI agent accessibility.
104-
- Consider adding glossary entries for:
105-
- New technical terms or abbreviations
106-
- Core architectural components
107-
- Important data structures or types
108-
- Communication patterns or protocols
109-
- System operations or processes
110-
- Include links to relevant implementation files when adding glossary entries.
111-
112-
Changelog management:
113-
114-
- Follow Keep a Changelog v1.0.0 format (https://keepachangelog.com/en/1.0.0/) for all CHANGELOG.md files.
115-
- For release PRs, categorize "### Uncategorized" entries into:
116-
- "### Added" for new features and functionality (entries starting with "feat:")
117-
- "### Changed" for changes to existing functionality (entries starting with "chore:" or breaking changes)
118-
- "### Deprecated" for soon-to-be removed features
119-
- "### Removed" for now removed features
120-
- "### Fixed" for bug fixes and corrections (entries starting with "fix:" or "refactor:")
121-
- "### Security" in case of vulnerabilities
122-
- Each changelog should describe changes specific to that package
123-
- Skip dependency updates unless they cause downstream changes; if so, describe the actual changes instead
124-
- Remove prefixes like "feat:", "chore:", "fix:", "refactor:" from changelog entries
125-
- Use clean, descriptive language without technical prefixes
126-
- When running in agent mode, fetch GitHub PR descriptions to better understand:
127-
- The actual impact of each change on the specific package
128-
- Whether dependency updates introduce breaking changes or new functionality
129-
- More context for writing accurate, descriptive changelog entries
130-
- Use PR descriptions to determine if changes should be:
131-
- Skipped entirely (pure dependency bumps with no package impact)
132-
- Rewritten to focus on user-facing changes rather than implementation details
133-
- Moved to different categories based on actual impact
134-
- Example transformations:
135-
- "feat(ocap-kernel): Add kernel command 'revoke'" → "Add kernel command 'revoke'"
136-
- "chore: bump endo dependencies" → Remove (unless it causes package-specific changes)
137-
- "fix: make Revoke button refresh object registry" → "Make Revoke button refresh object registry"
138-
139-
Context-aware development:
140-
141-
- Align new code with existing project structure for consistency.
142-
- Prioritize modular, reusable components.
143-
144-
Code output:
145-
146-
- Provide complete, self-contained examples.
147-
- Include necessary imports and context for code snippets.
148-
- Document significant changes, especially for Endo-specific patterns or Chrome APIs.
75+
- Libraries should be platform-agnostic and run in any environment unless otherwise specified
76+
- Packages like `extension` (browser) and `cli` (Node.js) are platform-specific

package.json

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,18 +20,18 @@
2020
"clean": "rimraf --glob './*.tsbuildinfo' ./.eslintcache ./coverage ./.turbo && yarn workspaces foreach --all --parallel --interlaced --verbose run clean",
2121
"create-package": "tsx packages/create-package/src/index.ts",
2222
"lint": "yarn constraints && yarn lint:eslint && yarn lint:misc --check && yarn lint:dependencies",
23-
"lint:dependencies": "yarn dedupe --check && yarn depcheck && yarn workspaces foreach --all --parallel --verbose run lint:dependencies",
24-
"lint:dependencies:fix": "yarn dedupe && yarn depcheck && yarn workspaces foreach --all --parallel --verbose run lint:dependencies",
23+
"lint:dependencies": "yarn dedupe --check >/dev/null && yarn depcheck --quiet && yarn workspaces foreach --all --parallel --verbose run lint:dependencies",
24+
"lint:dependencies:fix": "yarn dedupe >/dev/null && yarn depcheck --quiet && yarn workspaces foreach --all --parallel --verbose run lint:dependencies",
2525
"lint:eslint": "yarn eslint . --cache",
2626
"lint:fix": "yarn constraints --fix && yarn lint:eslint --fix && yarn lint:misc --write && yarn lint:dependencies:fix",
27-
"lint:misc": "prettier --no-error-on-unmatched-pattern '**/*.json' '**/*.md' '**/*.html' '**/*.yml' '!**/CHANGELOG.old.md' '!.yarnrc.yml' '!CLAUDE.md' '!merged-packages/**' --ignore-path .gitignore",
27+
"lint:misc": "prettier --no-error-on-unmatched-pattern '**/*.json' '**/*.md' '**/*.html' '**/*.yml' '!**/CHANGELOG.old.md' '!.yarnrc.yml' '!CLAUDE.md' '!merged-packages/**' --ignore-path .gitignore --log-level error",
2828
"postinstall": "simple-git-hooks && yarn rebuild:native",
2929
"prepack": "./scripts/prepack.sh",
3030
"pretest": "bash scripts/reset-coverage-thresholds.sh",
3131
"rebuild:native": "./scripts/rebuild-native.sh",
3232
"test": "yarn pretest && vitest run",
3333
"test:ci": "vitest run --coverage false",
34-
"test:dev": "yarn test --mode development",
34+
"test:dev": "yarn test --mode development --reporter dot",
3535
"test:e2e": "yarn workspaces foreach --all run test:e2e",
3636
"test:e2e:ci": "yarn workspaces foreach --all run test:e2e:ci",
3737
"test:verbose": "yarn test --reporter verbose",

0 commit comments

Comments
 (0)