princeton-nlp / SWE-agent

SWE-agent takes a GitHub issue and tries to automatically fix it, using GPT-4, or your LM of choice. It solves 12.47% of bugs in the SWE-bench evaluation set and takes just 1 minute to run.
https://princeton-nlp.github.io/SWE-agent/
MIT License
11.86k stars 1.18k forks source link

Add filemap command in the spirit of repomap #619

Closed samuela closed 1 day ago

samuela commented 5 days ago

Reference Issues/PRs

n/a

What does this implement/fix? Explain your changes.

Adds a "filemap" command to aid in exploring large files/codebase and avoid scroll_down-hell. For example,

$ filemap SWE-agent/sweagent/agent/agents.py
...
   239 class Agent:
   240     """Agent handles the behaviour of the model and how it interacts with the environment."""
   241 
   242     def __init__(self, name: str, args: AgentArguments):
   243 ... eliding lines 243-256 ...
   257 
   258     def add_hook(self, hook: AgentHook):
   259         """Add hook to agent"""
   260         hook.on_init()
   261         self.hooks.append(hook)
   262 
   263     def _append_history(self, item: dict):
   264         for hook in self.hooks:
   265             hook.on_query_message_added(**item)
   266         self.history.append(item)
   267 
   268     def setup(self, instance_args, init_model_stats=None) -> None:
   269 ... eliding lines 269-322 ...
...

It is currently designed to elide any function or method definition that is at least 5 lines long. Changing this setting is straightforward.

There is currently no special handling for docstrings. If a function has a docstring it will be elided by default (unless the entire function body is less than 5 lines long).

Remaining TODOs:

klieret commented 5 days ago

Awesome :D

The easiest way to test this is to just do py run.py ... --model human and then you can type commands instead of the AI. So you could try what filemap does with some of the issues