-
Notifications
You must be signed in to change notification settings - Fork 60
Create an AGENTS.md #1134
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Create an AGENTS.md #1134
Changes from 2 commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,109 @@ | ||
# AGENTS.md | ||
|
||
This file provides guidance to AI coding assistants when working with code in this repository. | ||
|
||
## Project Overview | ||
|
||
This is the official ReScript VSCode extension, providing language support for ReScript (.res/.resi files) in Visual Studio Code. The project uses a Language Server Protocol (LSP) architecture with a TypeScript client/server and native OCaml binaries for analysis. | ||
|
||
## Architecture | ||
|
||
### Key Components | ||
|
||
- **client/**: VSCode extension client (`client/src/extension.ts`) - handles UI, commands, and language client initialization | ||
- **server/**: Language Server (`server/src/server.ts`, `server/src/cli.ts`) - implements LSP features, communicates with ReScript compiler | ||
- **analysis/**: Native OCaml binary for code analysis, hover, autocomplete, and other language features. This is for older ReScript versions only (ReScript 11 and below). New features are usually only implemented in the rescript compiler monorepo. | ||
- **tools/**: ReScript tools binary for additional functionality like interface file generation. This is also for older ReScript versions only (ReScript 11 and below). New features are usually only implemented in the rescript compiler monorepo. | ||
- **grammars/**: TextMate grammar files for syntax highlighting | ||
- **snippets.json**: Code snippets for common ReScript patterns | ||
|
||
### Build System | ||
|
||
The project uses: | ||
|
||
- **dune**: For building OCaml components (analysis & tools) | ||
- **esbuild**: For bundling TypeScript client/server | ||
- **npm**: For JavaScript/TypeScript dependencies | ||
- **TypeScript**: For type checking the client/server code | ||
|
||
## Development Commands | ||
|
||
### Initial Setup | ||
|
||
```bash | ||
npm install # Install all dependencies including client/server | ||
opam switch 5.2.0 # Install OCaml switch (if not already done) | ||
opam install . --deps-only # Install OCaml dependencies | ||
``` | ||
|
||
### Building | ||
|
||
```bash | ||
make build # Build OCaml binaries and copy to root | ||
npm run compile # Compile TypeScript (client & server) | ||
npm run bundle # Bundle for production (esbuild) | ||
npm run vscode:prepublish # Clean and bundle (used for publishing) | ||
``` | ||
|
||
### Development | ||
|
||
```bash | ||
npm run watch # Watch TypeScript compilation | ||
make -C analysis test # Run analysis tests | ||
make -C tools/tests test # Run tools tests | ||
make test # Run all tests | ||
``` | ||
|
||
### Code Quality | ||
|
||
```bash | ||
make format # Format OCaml (dune) and JS/TS (prettier) | ||
make checkformat # Check formatting without modifying | ||
make clean # Clean build artifacts | ||
``` | ||
|
||
### Running the Extension in Development | ||
|
||
1. Open the project in VSCode | ||
2. Press F5 to launch a new VSCode window (Extension Development Host) | ||
3. Open a ReScript project to test the extension | ||
|
||
## Key Files | ||
|
||
### Configuration | ||
|
||
- `package.json`: Extension manifest, commands, settings, and scripts | ||
- `rescript.configuration.json`: Editor configuration for ReScript files | ||
- `client/src/extension.ts`: Extension entry point and client initialization | ||
- `server/src/server.ts`: Language server implementation | ||
- `server/src/cli.ts`: CLI entry point for the language server | ||
|
||
### OCaml Components | ||
|
||
- `analysis/`: Code analysis binary (hover, autocomplete, etc.) | ||
- `tools/`: ReScript tools binary (interface generation, etc.) | ||
|
||
### Language Features | ||
|
||
- **LSP Features**: hover, goto definition, find references, rename, autocomplete | ||
- **Code Analysis**: dead code detection, exception analysis (via reanalyze) | ||
- **Build Integration**: compile diagnostics, status indicators | ||
- **Commands**: interface creation, file switching, compiled JS opening | ||
|
||
## Testing | ||
|
||
The project has several test suites: | ||
|
||
- `analysis/tests/`: Tests for the analysis binary | ||
- `tools/tests/`: Tests for ReScript tools | ||
- `analysis/tests-incremental-typechecking/`: Incremental typechecking tests | ||
- `analysis/tests-generic-jsx-transform/`: JSX transformation tests | ||
|
||
## Project Structure Notes | ||
|
||
- The extension supports both `.res` (implementation) and `.resi` (interface) files | ||
- Uses VSCode Language Client protocol for communication between client and server | ||
- Native binaries are cross-platform (darwin, linux, win32) and included in the extension | ||
- Supports workspace configurations and monorepo structures | ||
- Incremental type checking can be enabled for better performance on large projects | ||
- As mentioned above the native OCaml binaries here are only here for backwards-compatibility with ReScript versions 11 or below. Since ReScript 12 both `analysis` and `tools` are part of the ReScript compiler monorepo, thus refrain from changing them too much (bugfixes that need to be ported are ok). | ||
fhammerschmidt marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
AGENTS.md |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.