Skip to content

mechakotik/gitevolve

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

gitevolve

An evolutionary agent built on top of git, which generates repository changes using some mutation operator and tries to maximize a user-defined score function. It can be paired with an LLM coding agent (e.g. Codex) to automatically find optimizations in large codebases (automated algorithm design).

How it works

  • Choose a base commit among previously generated commits, taking its score into account (the higher the score is, the more likely it is to be chosen)
  • Run mutation command to generate changes to the repository (for example, ask coding agent to "improve performance")
  • Commit these changes, to be possibly used as base afterwards
  • Run evaluation command to get score for the changed repository, and save it together with the commit
  • Repeat from the first step

Install

Install go and run:

go install github.com/mechakotik/gitevolve@latest

Usage

Write scripts that mutate and evaluate the repository, save them somewhere outside the repository so they can't be affected by mutation, e.g. ~/evolve/mutate.sh, ~/evolve/evaluate.sh.

Mutation script should generate changes in working directory (for example, call coding agent). Evaluation script should run some tests to get score, and print it as a single float number in stdout.

Save all the uncommitted changes and ignored files, as they will be destroyed when evolution runs. Go to repository root directory and run evolution like this:

gitevolve --mutate ~/evolve/mutate.sh --evaluate ~/evolve/evaluate.sh --data ~/evolve/data.json

data.json will contain hashes of all the generated commits with their evaluation results. This file can be used to resume evolution from the same point. If your score function has changed, you may set solutions' evaluated field to false, and evaluation will be re-run for them at the start of the next evolution run.

Customizing selection

gitevolve has a reasonable default selection algorithm, however you may want to tune it to work even better for your specific problem. Following the idea of tinyevolve, gitevolve code is simple enough to be understood completely by the user and modified for their needs.

Selection algorithm is in getBaseCommit function. It should select a base solution for next evolution iteration from state.Solutions and return its commit hash. For example, here is an implementation of tournament selection of size 5:

func getBaseCommit() string {
	best := rand.Intn(len(state.Solutions))
	for range 4 {
		cur := rand.Intn(len(state.Solutions))
		if state.Solutions[cur].Score > state.Solutions[best].Score {
			best = cur
		}
	}
	return state.Solutions[best].Commit
}

Citation

If you have used gitevolve in your research, please cite

@software{gitevolve,
  title = {gitevolve: Evolutionary agent for large codebases},
  author = {Andrei Sabalenka},
  year = {2026},
  publisher = {GitHub},
  url = {https://github.com/mechakotik/gitevolve}
}

About

Evolutionary agent for large codebases, built on top of git

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages