Skip to content

Commit 7a18a89

Browse files
committed
chore: cleanup agents.md
Signed-off-by: Christian Stewart <christian@aperture.us>
1 parent cac99f2 commit 7a18a89

1 file changed

Lines changed: 6 additions & 62 deletions

File tree

AGENTS.md

Lines changed: 6 additions & 62 deletions
Original file line numberDiff line numberDiff line change
@@ -1,40 +1,20 @@
11
# Agent Rules for GoScript
22

3-
This document contains guidelines and rules for AI agents working on the GoScript project.
4-
53
## IMPORTANT
64

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
155
- NEVER run the vite dev server or anything that listens on any port yourself! Ask the user to do it!
166
- Read `docs/explainer.md` for an overview of the project if you need it
177

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
219

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
3110
- DO NOT maintain backwards compatibility - this is an experimental project
3211
- Remove any "for backwards compatibility" comments and fallback logic
3312
- 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
3514
- 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.
3716
- AVOID type arguments unless necessary (prefer type inference)
17+
- When making Git commits referencing issues use the short form: Fixes #128 (for example)
3818
- When making Git commits use the existing commit message pattern and Linux-kernel style commit message bodies.
3919
- 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.
4020

@@ -114,17 +94,11 @@ NOTE: `./tests/deps/` contains library dependencies compiled by the goscript com
11494
- Try to make a 1-1 match between AST type and function name
11595
- Avoid hiding logic in unexported functions
11696

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**:
12498
- Avoid leaving undecided implementation details in the code
12599
- Make a decision and add a comment explaining the choice if necessary
126100

127-
5. **Struct Field Policy**:
101+
4. **Struct Field Policy**:
128102
- You **may not** add new fields to `GoToTSCompiler`
129103
- You **may** add new fields to `Analysis` if you are adding ahead-of-time analysis only
130104

@@ -139,7 +113,6 @@ When working with golangci-lint:
139113
```go
140114
defer f.Close() //nolint:errcheck
141115
```
142-
This is appropriate for cases like deferring Close without checking the error return value, which can often be safely ignored.
143116

144117
Make sure that `bun test` and `bun lint` both pass before suggesting a task is complete.
145118

@@ -196,32 +169,3 @@ The playground at `website/` compiles Go to TypeScript using a WASM build of the
196169
- Playground examples are defined in `scripts/generate-examples.ts` (the `CURATED_EXAMPLES` array)
197170
- Do NOT add examples that import packages beyond `@goscript/builtin` (e.g., `encoding/json`) until dependency bundling is implemented
198171
- 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.
213-
func (c *GoToTSCompiler) WriteFuncDecl(decl *ast.FuncDecl) error {
214-
...
215-
}
216-
```
217-
218-
### Go Type Assertions
219-
220-
When using type assertion syntax in Go, add a comment line just before:
221-
222-
```go
223-
// _ is a type assertion
224-
var _ SomeInterface = (*SomeStruct)(nil)
225-
```
226-
227-
This verifies at compile-time that `SomeStruct` implements `SomeInterface`.

0 commit comments

Comments
 (0)