SWE-agent takes a GitHub issue and tries to automatically fix it, using your LM of choice. It can also be employed for offensive cybersecurity or competitive coding challenges. [NeurIPS 2024]
Feat(tools): Diff as state
Kilian Lieret3296f8d95ec4
diff --git a/tools/diff_state/bin/_state_diff_state b/tools/diff_state/bin/_state_diff_statenew file mode 100644index 00000000..8a583fdb--- /dev/null+++ b/tools/diff_state/bin/_state_diff_state@@ -0,0 +1,38 @@+#!/usr/bin/env python3++import json+import os+from pathlib import Path+import subprocess+++from registry import registry+++def main() -> None:+ state_path = Path("/root/state.json")+ if state_path.exists():+ state = json.loads(state_path.read_text())+ else:+ state = {}++ repo_root = registry.get("ROOT", os.getenv("ROOT"))++ patch_path = Path("/root/model.patch")++ subprocess.run(+ f"git add -A && git diff --cached > {patch_path}",+ shell=True,+ stdout=subprocess.DEVNULL,+ stderr=subprocess.DEVNULL,+ cwd=repo_root,+ )++ patch = patch_path.read_text()+ state["diff"] = patch.strip()++ state_path.write_text(json.dumps(state))+++if __name__ == "__main__":+ main()diff --git a/tools/diff_state/config.yaml b/tools/diff_state/config.yamlnew file mode 100644index 00000000..590aefaa--- /dev/null+++ b/tools/diff_state/config.yaml@@ -0,0 +1,2 @@+tools: {}+state_command: "_state_diff_state"\ No newline at end of file