MCPcopy Index your code
hub / github.com/despiteallobjections/amigo

github.com/despiteallobjections/amigo @main

Chat with this repo
repository ↗ · DeepWiki ↗ · + Follow
4,812 symbols 14,022 edges 440 files 1,821 documented · 38%
What it actually does AI analysis from the code graph — generated when you open this
loading…
README

Amigo

Go

Amigo is an experiment to radically reinvision the Go tools ecosystem, including cmd/compile, cmd/vet, x/tools/gopls, and users of the go/ and x/tools/go/ APIs.

Hypotheses

Every proper experiment starts with declaring its hypotheses in advance, and amigo is no exception.

  1. Replace trees with tapes. The simdjson project demonstrates the performance benefit of parsing files into minimally structured token sequences, and then implementing a cursor API on top. Similarly, flatbuffers demonstrate the value of simply mapping data files into memory and walking them as-is, rather than trying to parse into traditional (sparse) data structures. I anticipate we can see similar benefits with parsing and traversing Go syntax.

  2. Opaque internal data structures. The go/types type checker suffers from the Go 1 compatibility guarantee: APIs like go/ast and go/types must remain backwards compatible for existing users, which constrains how they can be extended to support new Go language features. This results in monotonically increasing implementation complexity, and in turn maintainer anxiety in deciding how to extend existing APIs.

  3. First-class serialization. Today, Go tools frequently re-parse source files and re-type-check source packages. The compiler's "Unified IR" experiment demonstrates the benefit of serializing to bytes right away, and then developing multiple readers that can inflate the results into tool-appropriate data structures.

  4. Build SSA during type checking. Today, the type checker walks the AST, disambiguates various syntactic forms, and records a bunch of typing information; and then the SSA builders need to re-walk the same AST, disambiguate the same syntactic forms, and lookup all the recorded typing information. I anticipate that by incorporating SSA construction directly into type checking, we can reduce code complexity and improve performance (e.g., through better memory locality).

  5. Separate phases to improve concurrency. A typical Go build involves compiling each package in the dependency graph, and a package cannot be compiled until all of its dependencies have been compiled first. However, within cmd/compile, each compilation is internally split into a sequence of phases, and not all phases actually affect dependent packages. For example, (fully) type checking a package only requires having type checked all imported package's package-scope declarations; it does not require type checking function bodies, much less compiling and optimizing to machine instructions. By better defining these separate phases and the data flow between them, I anticipate we could further improve build concurrency.

This hypothesis is further elaborated in doc/parallelism.md.

Questions

cmd/asm

Should amigo incorporate cmd/asm too? I think yes, but cmd/asm seems especially challenging to incorporate, without pulling in all of cmd/internal/obj.

I suspect something like LLVM bitstream's "abbreviations" will be applicable here. For each unique instruction shape, we can define a separate abbreviation, so that instructions themselves can be very efficiently encoded, and the cmd/asm decoder can use vtables to rapidly construct obj.Progs (or report errors) from the encoded instructions.

Extension points exported contracts — how you extend this code

Importer (Interface)
An Importer resolves import paths to Packages. [6 implementers]
types/api.go
Value (Interface)
A Value is an SSA value that can be referenced by an instruction. [6 implementers]
types/ssa.go
Type (Interface)
A Type represents a type of Go. All types implement the Type interface. [13 implementers]
types/type.go
T3 (Interface)
parameterized types with self-recursive constraints [25 implementers]
types/testdata/fixedbugs/issue47796.go
VI (Interface)
(no doc) [9 implementers]
ssa/interp/testdata/coverage.go
Object (Interface)
An Object describes a named language entity such as a package, constant, type, variable, function (incl. methods), or la [2 …
types/object.go
Node (Interface)
---------------------------------------------------------------------------- Nodes [1 implementers]
syntax/nodes.go
PragmaHandler (Interface)
A PragmaHandler is used to process //go: directives while scanning. [1 implementers]
syntax/syntax.go

Core symbols most depended-on inside this repo

append
called by 449
types/testdata/check/issues1.go
assert
called by 341
types/errors.go
Type
called by 232
types/ssa.go
Pos
called by 206
types/ssa.go
errorf
called by 184
types/errors.go
Name
called by 169
types/ssa.go
print
called by 154
syntax/printer.go
new
called by 153
types/testdata/check/typeparams.go

Shape

Method 1,740
Function 1,480
Struct 639
TypeAlias 543
Interface 375
FuncType 35

Languages

Go100%

Modules by API surface

types/ssa.go193 symbols
types/testdata/check/unions.go107 symbols
types/testdata/check/decls0.go97 symbols
syntax/parser.go88 symbols
types/object.go85 symbols
types/testdata/check/cycles0.go83 symbols
syntax/nodes.go78 symbols
types/builder.go68 symbols
cgotool/gcc.go64 symbols
types/testdata/check/issues0.go63 symbols
types/testdata/check/decls3.go63 symbols
types/testdata/check/init2.go62 symbols

For agents

$ claude mcp add amigo \
  -- python -m otcore.mcp_server <graph>

⬇ download graph artifact