Skip to content

Commit 48726ef

Browse files
committed
AGENTS.md: adding agent guidance
1 parent 0d12c93 commit 48726ef

File tree

1 file changed

+57
-0
lines changed

1 file changed

+57
-0
lines changed

AGENTS.md

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
# Project Philosophy
2+
3+
Geas is an EVM assembler. It enables users to write low-level programs for the Ethereum
4+
Virtual Machine (EVM). The Geas assembly language is similar in spirit to the Go
5+
programming language, but also takes inspiration from Perl. In addition to writing basic
6+
opcodes, the user can use instruction macros to capture common opcodde sequences. The
7+
language also allows 'expression macros' which are useful for inserting constants and
8+
pre-calculated numbers and binary data into the bytecode.
9+
10+
The assembler should try to be maximally helpful to its user and give good error messages
11+
when the program has a mistake. Being a compiler for a low-level language, Geas cannot
12+
verify the correctness of the user's program, but it should ensure the program does not
13+
contain surface-level bugs such as invalid instructions, jumps to invalid destinations,
14+
and stack management issues.
15+
16+
# Project Structure
17+
18+
- `cmd/geas` - command line frontend
19+
- `asm/` - assembler implementation
20+
- `disasm/` - disassembler implementation
21+
22+
# Development Tips
23+
24+
When modifying Go code, just run `goimports -w` on the file after editing it to update and
25+
organize imports. Do this before compiling to ensure there is no error. If `goimports` is
26+
not installed yet, just install it to ~/go/bin.
27+
28+
You can use `staticcheck` to check for common programming mistakes and style issues. If
29+
staticcheck is not installed, you can also install it to ~/go/bin.
30+
31+
Sometimes it is useful to run the `geas` tool itself to perform test runs. To run the
32+
assembler, use `go run ./cmd/geas -a` from the project root. The tool does not accept
33+
filenames outside of the current directory.
34+
35+
To disassemble bytecode, use `go run ./cmd/geas -d` from the project root.
36+
37+
# Go Code Style
38+
39+
Avoid repeated expressions, and do not deeply nest expressions. Provide comments, but be
40+
terse, do not repeat the same information across many comments.
41+
42+
When creating documentation comments, adhere to the Go style of using the function name as
43+
the first word of the godoc comment. Do not use this convention for struct fields,
44+
variables and constants. When documenting tests, do not put a godoc style comment. Rather,
45+
add a comment like "this test does XXX".
46+
47+
# Compiler Tests
48+
49+
For the assembler, test cases are defined in a YAML file `./asm/testdata/compiler-tests.yaml`.
50+
51+
If possible, create new tests there whenever features are added or bugs are fixed. Do not
52+
modify any existing tests, except to adapt error messages when necessary.
53+
54+
Tests related for the stack checker are in `./asm/testdata/stackcheck-tests.yaml`. When
55+
modifying the stack checker or adding features there, make sure to create tests that
56+
produce a related warning.
57+

0 commit comments

Comments
 (0)