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
Copy file name to clipboardExpand all lines: AGENTS.md
+6-62Lines changed: 6 additions & 62 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,40 +1,20 @@
1
1
# Agent Rules for GoScript
2
2
3
-
This document contains guidelines and rules for AI agents working on the GoScript project.
4
-
5
3
## IMPORTANT
6
4
7
-
Fix anything that you come across in the project while working that violates any of these guidelines as you encounter it.
8
-
9
-
**CRITICAL: When asked to update AGENTS.md:**
10
-
11
-
- ALWAYS read the ENTIRE file first before making edits
12
-
- Check for duplicate information across sections
13
-
- Condense and consolidate duplicates into a single authoritative section
14
-
- Ensure guidelines are clear and non-contradictory
15
5
- NEVER run the vite dev server or anything that listens on any port yourself! Ask the user to do it!
16
6
- Read `docs/explainer.md` for an overview of the project if you need it
17
7
18
-
Remember to always delete dead code when changing things - for example if you changed something and a function is no longer used anywhere, delete that function.
19
-
20
-
### General Rules
8
+
### Project-Specific Rules
21
9
22
-
- Try to keep things in one function unless composable or reusable
23
-
- PREFER one exported struct per `.go` file (file named after the struct, e.g., `type-info.go` for `TypeInfo`)
24
-
- Multiple unexported (internal) structs in the same file are acceptable
25
-
- Constants and type aliases can be co-located with the struct that uses them
26
-
- DO NOT use `else` statements unless necessary
27
-
- DO NOT make git commits unless asked
28
-
- When making Git commits referencing issues use the short form: Fixes #128 (for example)
29
-
- AVOID `else` statements or "fallback" cases
30
-
- PREFER single word variable names where possible
31
10
- DO NOT maintain backwards compatibility - this is an experimental project
32
11
- Remove any "for backwards compatibility" comments and fallback logic
33
12
- NEVER hardcode things: examples include function names, builtins, etc.
34
-
- Actively try to improve the codebase to conform to the above when the opportunity arises
13
+
- Actively try to improve the codebase to conform to these rules when the opportunity arises
35
14
- Go standard library sources are located at "go env GOROOT" (shell command)
36
-
- Leverage adding more tests, for example in `compiler/analysis_test.go`, instead of debug logging, for diagnosing issues or investigating hypotheses. If the new test case is temporary and you plan to remove it later, add a `tmp_test.go` file or similar to keep things separated.
15
+
- Leverage adding more tests (e.g., `compiler/analysis_test.go`) instead of debug logging for diagnosing issues. If the new test case is temporary, add a `tmp_test.go` file to keep things separated.
37
16
- AVOID type arguments unless necessary (prefer type inference)
17
+
- When making Git commits referencing issues use the short form: Fixes #128 (for example)
38
18
- When making Git commits use the existing commit message pattern and Linux-kernel style commit message bodies.
39
19
- When you would normally add a new compliance test check if a very-similar compliance test already exists and if so extend that one instead. For example testing another function in the same package.
40
20
@@ -114,17 +94,11 @@ NOTE: `./tests/deps/` contains library dependencies compiled by the goscript com
114
94
- Try to make a 1-1 match between AST type and function name
115
95
- Avoid hiding logic in unexported functions
116
96
117
-
3.**Function Organization**:
118
-
- Avoid splitting functions unless:
119
-
- The logic is reused elsewhere
120
-
- The function becomes excessively long and complex
121
-
- Doing so adheres to existing patterns in the codebase
122
-
123
-
4.**Implementation Completeness**:
97
+
3.**Implementation Completeness**:
124
98
- Avoid leaving undecided implementation details in the code
125
99
- Make a decision and add a comment explaining the choice if necessary
126
100
127
-
5.**Struct Field Policy**:
101
+
4.**Struct Field Policy**:
128
102
- You **may not** add new fields to `GoToTSCompiler`
129
103
- You **may** add new fields to `Analysis` if you are adding ahead-of-time analysis only
130
104
@@ -139,7 +113,6 @@ When working with golangci-lint:
139
113
```go
140
114
defer f.Close() //nolint:errcheck
141
115
```
142
-
This is appropriate for cases like deferring Close without checking the error return value, which can often be safely ignored.
143
116
144
117
Make sure that `bun test` and `bun lint` both pass before suggesting a task is complete.
145
118
@@ -196,32 +169,3 @@ The playground at `website/` compiles Go to TypeScript using a WASM build of the
196
169
- Playground examples are defined in `scripts/generate-examples.ts` (the `CURATED_EXAMPLES` array)
197
170
- Do NOT add examples that import packages beyond `@goscript/builtin` (e.g., `encoding/json`) until dependency bundling is implemented
198
171
- Run `bun run scripts/generate-examples.ts` then `cd website && bun run build` to update
199
-
200
-
## Comments
201
-
202
-
When adding comments to functions, structs, or files:
203
-
204
-
- Use the format: `// FunctionName does something specific.`
205
-
- Start with the function/struct/type name followed by a verb
206
-
- End with a period
207
-
- Keep it concise and descriptive
208
-
209
-
Example:
210
-
211
-
```go
212
-
// WriteFuncDecl converts a Go function declaration to TypeScript.
0 commit comments