Skip to content

Commit da602ef

Browse files
feat: add custom instructions for copilot
1 parent fff3146 commit da602ef

File tree

4 files changed

+81
-0
lines changed

4 files changed

+81
-0
lines changed

.github/copilot-instructions.md

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
# AI Coding Agent Guidelines for MoonBit Core
2+
3+
Welcome to the MoonBit Core repository! This document provides essential guidelines for AI coding agents to be productive and effective contributors to this codebase.
4+
5+
## Project Overview
6+
MoonBit Core is the standard library for the MoonBit language. It is organized into modular packages, each with its own directory. Key files include:
7+
- `moon.pkg.json`: Defines package dependencies.
8+
- `.mbti` files: Generated interfaces for packages, providing a formal description of their public API.
9+
- `.mbt` files: Core implementation files, organized in block style with `///|` separators.
10+
- `_test.mbt` and `_wbtest.mbt`: Blackbox and whitebox test files, respectively.
11+
12+
The top-level `moon.mod.json` file contains metadata about the entire module.
13+
14+
## Key Workflows
15+
1. **Code Formatting and Interface Updates**:
16+
- Use `moon fmt` to format code.
17+
- Run `moon info` to update `.mbti` files. If no changes occur, your modifications are safe for external users.
18+
19+
2. **Testing**:
20+
- Run `moon test` to execute tests.
21+
- Use `moon test --update` to update snapshots when behavior changes.
22+
- Analyze test coverage with `moon coverage analyze > uncovered.log`.
23+
24+
3. **Linting**:
25+
- Use `moon check` to ensure code adheres to linting rules.
26+
27+
## Project-Specific Conventions
28+
- **Block Style Organization**: Code blocks are separated by `///|`. The order of blocks is irrelevant, allowing independent processing.
29+
- **Deprecated Code**: Place deprecated blocks in `deprecated.mbt` files within the respective directory.
30+
- **Testing Practices**: Prefer `inspect` for snapshot testing. Use `assert_eq` sparingly, such as in loops with variable snapshots.
31+
32+
## Integration Points
33+
- **External Dependencies**: Defined per package in `moon.pkg.json`.
34+
- **Cross-Component Communication**: Interfaces are formalized in `.mbti` files, ensuring clear boundaries between packages.
35+
36+
## Examples
37+
- **Adding a New Function**:
38+
1. Implement the function in a `.mbt` file, using `///|` to separate blocks.
39+
2. Update the corresponding `.mbti` file with `moon info`.
40+
3. Write tests in `_test.mbt` or `_wbtest.mbt`.
41+
4. Format and lint the code with `moon fmt` and `moon check`.
42+
43+
- **Refactoring**:
44+
1. Modify code block by block.
45+
2. Ensure no unexpected changes in `.mbti` files after running `moon info`.
46+
3. Verify tests pass and update snapshots if needed.
47+
48+
## Additional Notes
49+
- Refer to `AGENTS.md` for more detailed refactoring tips.
50+
- Use `agent-todo.md` for small, AI-friendly tasks.
51+
52+
By following these guidelines, AI agents can contribute effectively to the MoonBit Core project. If any section is unclear or incomplete, please provide feedback for improvement!
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
---
2+
applyTo: **/pkg.generated.mbti
3+
---
4+
5+
# MoonBit Interface File
6+
7+
`pkg.generated.mbti` contains the public API surface for the current package.
8+
9+
- Execute `moon info` to sync all the interface files with the actual code in the project.
10+
- Any change of the interface files, which reflects the change of the API, should be reviewed carefully.
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
---
2+
applyTo: **/moon.pkg.json
3+
---
4+
5+
# MoonBit Package File
6+
7+
`moon.pkg.json` is the package manifest file for the MoonBit project. It contains metadata about the package, including dependencies, and other configuration options.
8+
9+
[Reference]: https://docs.moonbitlang.com/en/latest/toolchain/moon/package.html
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
---
2+
applyTo: "**/README.mbt.md"
3+
---
4+
5+
# Documentation writing guidlines
6+
7+
`README.mbt.md` is the documentation whose MoonBit code snippets will be checked and tested.
8+
9+
- It should be written from the aspect of the user of the API.
10+
- Write actual code. Do not write pseudocode in MoonBit code blocks.

0 commit comments

Comments
 (0)