Skip to content

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]

Docs: Add more READMEs to mkdocs

Kilian Lieret8d7a94a0af2e
diff --git a/config/commands/README.md b/config/commands/README.md
deleted file mode 100644
index 945ca35f..00000000
--- a/config/commands/README.md
+++ /dev/null
@@ -1,50 +0,0 @@
-# Command Configuration
-In this document, we describe how to implement your own commands for the SWE-agent ACI.
-To see examples of command implementations, open the `.sh` and `.py` files in this folder.
-
-## Scaffolding
-Every command subscribes to the following skeleton code.
-```shell
-# @yaml
-# signature: [command] [argument(s)]
-# docstring: [Brief description of what your command does.]
-# arguments:
-# [argument 1 name]:
-# type: [type (i.e. integer, string)]
-# description: [Brief description of this argument]
-# required: [true|false]
-# [argument 2 name]:
-# ...
-[command]() {
- # Implementation here
-}
-```
-* If a command takes in arguments, reference them via positional parameters notation (i.e. `$1`).
-* If there are no arguments, omit the `arguments` section.
-* The implementation for your command is unconstrained. There are no limitations on the form of the underlying command code.
-* The minimal documentation requirements are `signature` and `docstring`.
-* If you'd like multiple commands to make modifications to a similar body of functions, we recommend using global variables.
- * For instance, in `config/commands/default.sh`, you'll see we define the `CURRENT_LINE` variable for the file viewer. This variable is modified across multiple commands, including `open`, `goto`, `scroll_up`, `scroll_down`, and `edit`.
- * You can also leverage third party libraries (check out how we do linting enabled `edit` in `config/commands/edit_linting.sh`).
-* To show effects of the command, print to standard output (i.e. `echo`). SWE-agent is implemented such that it does not look for a return value from these commands.
-
-## Displaying the Command to SWE-agent
-After you define a command, there are a small set of additional steps to making it available for the agent to use.
-
-First, within your config file...
-* Add `config/commands/<file name>.sh` file to the `command_files` field.
-* Set the `parse_command` field to `ParseCommandBash` or `ParseCommandDetailed`. This key points to the functionality that generates how command documentation is shown to the agent.
-* Decide which template(s) you want to show the `{command_docs}` in.
- * We strongly recommend including `{command_docs}` in the `system_template`, which is the first message shown to the agent for every task instance episode.
- * You might also consider adding `{command_docs}` to the `format_error_template`, which is shown if the response provided by a model is malformed.
-* (Optional) Including a demonstration that uses a command is helpful to showcase proper use + increases the frequency with which the agent uses the command. If you'd like to add a demonstration...
- * Create a demonstration manually (i.e. `python run.py --model human_thought ...`) or automatically (i.e. `python run_replay --traj_path ...`)
- * Add/Update the demonstration to the `demonstrations` argument.
- * Update `demonstration_template` to control how the demonstration is displayed to the agent.
-
-> If you're not familiar with how SWE-agent configuration files work, we recommend checking out the [`config` README](https://github.com/princeton-nlp/SWE-agent/tree/main/config).
-
-Next, run your configuration and see how your agent uses the commands!
-```bash
-python run.py --config_file config/[your config].yaml ...
-```
diff --git a/config/commands/README.md b/config/commands/README.md
new file mode 120000
index 00000000..786d0743
--- /dev/null
+++ b/config/commands/README.md
@@ -0,0 +1 @@
+../../docs/dev/commands.md
\ No newline at end of file
diff --git a/assets/inspector.png b/docs/assets/inspector.png
similarity index 100%
rename from assets/inspector.png
rename to docs/assets/inspector.png
diff --git a/docs/dev/commands.md b/docs/dev/commands.md
new file mode 100644
index 00000000..6155f946
--- /dev/null
+++ b/docs/dev/commands.md
@@ -0,0 +1,56 @@
+# Command Configuration
+In this document, we describe how to implement your own commands for the SWE-agent ACI.
+To see examples of command implementations, open the `.sh` and `.py` files in the
+[`config/commands`](https://github.com/princeton-nlp/SWE-agent/tree/main/config/commands) folder.
+
+## Scaffolding
+
+Every command subscribes to the following skeleton code.
+
+```shell
+# @yaml
+# signature: [command] [argument(s)]
+# docstring: [Brief description of what your command does.]
+# arguments:
+# [argument 1 name]:
+# type: [type (i.e. integer, string)]
+# description: [Brief description of this argument]
+# required: [true|false]
+# [argument 2 name]:
+# ...
+[command]() {
+ # Implementation here
+}
+```
+
+* If a command takes in arguments, reference them via positional parameters notation (i.e. `$1`).
+* If there are no arguments, omit the `arguments` section.
+* The implementation for your command is unconstrained. There are no limitations on the form of the underlying command code.
+* The minimal documentation requirements are `signature` and `docstring`.
+* If you'd like multiple commands to make modifications to a similar body of functions, we recommend using global variables.
+ * For instance, in `config/commands/default.sh`, you'll see we define the `CURRENT_LINE` variable for the file viewer. This variable is modified across multiple commands, including `open`, `goto`, `scroll_up`, `scroll_down`, and `edit`.
+ * You can also leverage third party libraries (check out how we do linting enabled `edit` in `config/commands/edit_linting.sh`).
+* To show effects of the command, print to standard output (i.e. `echo`). SWE-agent is implemented such that it does not look for a return value from these commands.
+
+## Displaying the Command to SWE-agent
+After you define a command, there are a small set of additional steps to making it available for the agent to use.
+
+First, within your config file...
+
+* Add `config/commands/<file name>.sh` file to the `command_files` field.
+* Set the `parse_command` field to `ParseCommandBash` or `ParseCommandDetailed`. This key points to the functionality that generates how command documentation is shown to the agent.
+* Decide which template(s) you want to show the `{command_docs}` in.
+ * We strongly recommend including `{command_docs}` in the `system_template`, which is the first message shown to the agent for every task instance episode.
+ * You might also consider adding `{command_docs}` to the `format_error_template`, which is shown if the response provided by a model is malformed.
+* (Optional) Including a demonstration that uses a command is helpful to showcase proper use + increases the frequency with which the agent uses the command. If you'd like to add a demonstration...
+ * Create a demonstration manually (i.e. `python run.py --model human_thought ...`) or automatically (i.e. `python run_replay --traj_path ...`)
+ * Add/Update the demonstration to the `demonstrations` argument.
+ * Update `demonstration_template` to control how the demonstration is displayed to the agent.
+
+!!! tip "Config files"
+ If you're not familiar with how SWE-agent configuration files work, we recommend checking out the [`config` documentation](config.md).
+
+Next, run your configuration and see how your agent uses the commands!
+```bash
+python run.py --config_file config/[your config].yaml ...
+```
diff --git a/docs/dev/config.md b/docs/dev/config.md
index 35ccd9b7..74666fee 100644
--- a/docs/dev/config.md
+++ b/docs/dev/config.md
@@ -4,7 +4,7 @@ This page contains details describing how to write your own configurations to co
A configuration is represented as a single `.yaml` file, specified by the `--config` flag in the [command line interface](../usage/cl_tutorial.md), allowing you to...
-* Define the **commands** that agents may use to traverse + modify a codebase.
+* Define the **commands** that agents may use to traverse + modify a codebase (see [here](commands.md) for more details)
* Write **prompts** that are deterministically/conditionally shown to the agent over the course of a single trajectory.
* Control the **input/output interface** that sits between the agent and `SWEEnv`.
@@ -66,9 +66,10 @@ history_processor: Reference to functionality for controlling agent's message hi
parse_function: Parser run on agent output
```
-In this directory, we recommend looking at...
-* `configs/` for examples of properly formatted configuration files. Each configuration differs in its set of commands, input/output format, demonstrations, etc.
-* `commands/` for the bash implementations of the custom commands that SWE-agent uses to navigate + edit the codebase.
+In the [`config/`](https://github.com/princeton-nlp/SWE-agent/tree/main/config) directory, we recommend looking at...
+
+* [`configs/`](https://github.com/princeton-nlp/SWE-agent/tree/main/config/configs) for examples of properly formatted configuration files. Each configuration differs in its set of commands, input/output format, demonstrations, etc.
+* [`commands/`](https://github.com/princeton-nlp/SWE-agent/tree/main/config/commands) for the bash implementations of the custom commands that SWE-agent uses to navigate + edit the codebase. More information [here](commands.md).
## How a Configuration File is Processed
Some notes on processing that occurs on config fields when SWE-agent is run:
diff --git a/docs/dev/demonstrations.md b/docs/dev/demonstrations.md
new file mode 100644
index 00000000..c44f6dfb
--- /dev/null
+++ b/docs/dev/demonstrations.md
@@ -0,0 +1,10 @@
+# Changing the demonstrations
+
+If you'd like to modify the example demonstration that we feed the model at the start of each run, first generate a trajectory manually by running the agent with ```--model_name human```
+and then convert that trajectory into a demonstration by following the guide [here](https://github.com/princeton-nlp/SWE-agent/tree/main/make_demos).
+
+To edit text in ```human``` mode:
+
+1. Run the command ```edit edit_start_line:edit_end_line```
+2. Write the text you want to insert. Feel free to write the text across multiple lines.
+3. Press ```return``` then write ```end_of_edit``` and then press ```return``` again to submit the edit.
diff --git a/docs/dev/modify.md b/docs/dev/modify.md
index 422c4fc1..255aaae4 100644
--- a/docs/dev/modify.md
+++ b/docs/dev/modify.md
@@ -7,14 +7,7 @@ This can be done using the config files. See [here](config.md) for more informat
## Changing the demonstrations
-If you'd like to modify the example demonstration that we feed the model at the start of each run, first generate a trajectory manually by running the agent with ```--model_name human```
-and then convert that trajectory into a demonstration by following the guide [here](https://github.com/princeton-nlp/SWE-agent/tree/main/make_demos).
-
-To edit text in ```human``` mode:
-
-1. Run the command ```edit edit_start_line:edit_end_line```
-2. Write the text you want to insert. Feel free to write the text across multiple lines.
-3. Press ```return``` then write ```end_of_edit``` and then press ```return``` again to submit the edit.
+Any [trajectory](../usage/trajectories.md) can be turned into a new demonstrations. See [here](demonstrations.md) for how it's done.
## Code structure
diff --git a/docs/usage/benchmarking.md b/docs/usage/benchmarking.md
index d7e506f6..76674f74 100644
--- a/docs/usage/benchmarking.md
+++ b/docs/usage/benchmarking.md
@@ -6,7 +6,7 @@ There are two steps to the SWE-agent pipeline. First SWE-agent takes an input Gi
At this moment, there are known issues with a small number of repositories that don't install properly for `arm64` / `aarch64` architecture computers. We're working on a fix, but if you'd like to run and evaluate on the entirety of SWE-bench, the easiest way is by using an `x86` machine.
## πŸ‘©β€πŸ’» Inference <a name="inference"></a>
-**Inference on *any* GitHub Issue**: See [above](cl_tutorial.md).
+**Inference on *any* GitHub Issue**: See [the command line tutorial](cl_tutorial.md).
**Inference on SWE-bench**: Run SWE-agent on [SWE-bench Lite](https://www.swebench.com/lite.html) and generate patches.
diff --git a/docs/usage/cl_tutorial.md b/docs/usage/cl_tutorial.md
index 05539f1d..c0ac839a 100644
--- a/docs/usage/cl_tutorial.md
+++ b/docs/usage/cl_tutorial.md
@@ -26,9 +26,13 @@ Here,
* `--per_instance_cost_limit` limits the total inference cost to $2 (default is $3).
!!! tip "All options"
- * Run `python run.py --help` to see all available options for `run.py`. This tutorial will only cover a subset of options.
+ Run `python run.py --help` to see all available options for `run.py`. This tutorial will only cover a subset of options.
+
+!!! tip "Running more than once"
+ * The complete details of the run are saved as a "trajectory" file (more about them [here](trajectories.md)). They can also be turned into new [demonstrations](../dev/modify.md).
* If you run the same command more than once, you will find that SWE-agent aborts with ` Skipping existing trajectory`. You can either remove the trajectory from the warning message, or add the `--skip_existing=False` flag.
+
## Specifying the repository
In the above example, the repository/codebase is inferred from the `--data_path`.
diff --git a/docs/usage/inspector.md b/docs/usage/inspector.md
new file mode 100644
index 00000000..713a2b65
--- /dev/null
+++ b/docs/usage/inspector.md
@@ -0,0 +1,26 @@
+# Trajectory inspector
+
+We provide a web interface for visualizing [`.traj` files](trajectories.md) from the `trajectories` folder more easily.
+
+**Set Up**
+
+* Change to the `inspector` directory
+* Run `python server.py --directory insert_full_absolute_path_to_the_trajectories_folder_here/trajectories`
+* Open http://localhost:8000 in your browser to use the inspector.
+
+**Additional flags**
+
+- `--data_path`: Path to SWE-bench style dataset that trajectories were generated for (Optional)
+- `--directory`: Directory of trajectories to inspect (Defaults to `./trajectories` folder)
+- `--port`: Port to host web app (Defaults to `8000`).
+
+**Example Usage**
+
+From running the command:
+
+```bash
+python server.py --directory /Users/ofirp/swe-agent/trajectories
+```
+The inspector will then be launched in the browser:
+
+![trajectory inspector](../assets/inspector.png)
\ No newline at end of file
diff --git a/docs/usage/trajectories.md b/docs/usage/trajectories.md
new file mode 100644
index 00000000..8171b3a6
--- /dev/null
+++ b/docs/usage/trajectories.md
@@ -0,0 +1,50 @@
+# Trajectories
+
+The [`trajectories/`](https://github.com/princeton-nlp/SWE-agent/tree/main/trajectories) folder is the default location that experiment results (invocations of [`run.py`](cl_tutorial.md)) will be written to.
+
+At a high level, the experiments folder is organized in the following manner:
+```
+trajectories
+β”œβ”€β”€ <user 1> πŸ‘©β€πŸ’»
+β”‚ β”œβ”€β”€ <experiment 1> πŸ§ͺ
+β”‚ β”‚ β”œβ”€β”€ all_preds.jsonl
+β”‚ β”‚ β”œβ”€β”€ args.yaml
+β”‚ β”‚ β”œβ”€β”€ *.html (Webpage Files)
+β”‚ β”‚ └── *.traj (Trajectories)
+β”‚ └── <experiment 2> πŸ§ͺ
+β”‚ β”œβ”€β”€ all_preds.jsonl
+β”‚ β”œβ”€β”€ args.yaml
+β”‚ β”œβ”€β”€ *.html (Webpage Files)
+β”‚ └── *.traj (Trajectories)
+β”œβ”€β”€ <user 2> πŸ‘¨β€πŸ’»
+β”‚ β”œβ”€β”€ <experiment 1> πŸ§ͺ
+β”‚ β”‚ └── ...
+β”‚ └── <experiment 2> πŸ§ͺ
+β”‚ └── ...
+...
+```
+Where every experiment follows the pattern `trajectories/<user name>/<experiment name>`. The `<user name>` is automatically inferred from your system, and the `experiment name` is inferred from the arguments of the `run.py`.
+
+!!! tip "Viewing trajectories"
+ We provide a [trajectory viewer](inspector.md) for an easy viewing of trajectories.
+
+## How an Experiment Folder is Generated
+
+Each call to `run.py` produces a single `trajectories/<user name>/<experiment name>` folder containing the following assets:
+
+* `all_preds.jsonl`: A single file containing all of the predictions generated for the experiment (1 prediction per task instance), where each line is formatted as:
+```
+{
+ "instance_id": "<Unique task instance ID>",
+ "model_patch": "<.patch file content string>",
+ "model_name_or_path": "<Model name here (Inferred from experiment configs)>",
+}
+```
+* `args.yaml`: A summary of the configurations for the experiment run.
+* `<instance_id>.traj`: A `.json` formatted file containing the (thought, action, observation) turns generated by SWE-agent towards solving `<instance_id>`.
+* `<instance_id>.html`: An `.html` single webpage render of the trajectory, which can be directly opened in the browser for easier viewing of the trajectory.
+
+!!! tip
+ * Evaluation is not completed by `run.py`, it is a separate step (see [benchmarking](benchmarking.md))
+ * `all_preds.jsonl` can be referenced directly into `evaluation/run_eval.sh` to run evaluation (see [benchmarking](benchmarking.md))
+ * Trajectories can be turned into custom demonstrations for SWE-agent ([more information](../dev/demonstrations.md)).
\ No newline at end of file
diff --git a/docs/usage/web_ui.md b/docs/usage/web_ui.md
index 4232811e..2db2306b 100644
--- a/docs/usage/web_ui.md
+++ b/docs/usage/web_ui.md
@@ -8,8 +8,9 @@ To start our web UI, simply run
from the root of the repository.
-If the user interface doesn't automatically open in your browser, please open it at `http://localhost:3000`.
-Running from GitHub codespaces? More tips [here](../installation/codespaces.md#running-the-web-ui).
+!!! tip "Opening the webpage"
+ If the user interface doesn't automatically open in your browser, please open it at `http://localhost:3000`.
+ Running from GitHub codespaces? More tips [here](../installation/codespaces.md#running-the-web-ui).
!!! warning "Limitations"
Currently, the web interface only has a subset of the options of the command line interface (CLI).
\ No newline at end of file
diff --git a/inspector/README.md b/inspector/README.md
deleted file mode 100644
index a966a03a..00000000
--- a/inspector/README.md
+++ /dev/null
@@ -1,23 +0,0 @@
-# Inspector
-We provide a web interface for visualizing `.traj` files from the `trajectories` folder more easily.
-
-**Set Up**
-* Run `python server.py --directory insert_full_absolute_path_to_the_trajectories_folder_here/trajectories`
-* Open http://localhost:8000 in your browser to use the inspector.
-
-**Additional flags**
-- `--data_path`: Path to SWE-bench style dataset that trajectories were generated for (Optional)
-- `--directory`: Directory of trajectories to inspect (Defaults to `./trajectories` folder)
-- `--port`: Port to host web app (Defaults to `8000`).
-
-**Example Usage**
-
-From running the command:
-```
-python server.py --directory /Users/ofirp/swe-agent/trajectories
-```
-The inspector will then be launched in the browser:
-
-<p align="center">
- <img src="../assets/inspector.png" alt="swe-agent.com" />
-</p>
diff --git a/inspector/README.md b/inspector/README.md
new file mode 120000
index 00000000..950d9250
--- /dev/null
+++ b/inspector/README.md
@@ -0,0 +1 @@
+../docs/usage/inspector.md
\ No newline at end of file
diff --git a/mkdocs.yml b/mkdocs.yml
index eb96c0dc..12ef1c1e 100644
--- a/mkdocs.yml
+++ b/mkdocs.yml
@@ -50,11 +50,15 @@ nav:
- "usage/index.md"
- "Command line usage": "usage/cl_tutorial.md"
- "Using the web UI": "usage/web_ui.md"
+ - "Trajectories": "usage/trajectories.md"
+ - "Trajectory inspector": "usage/inspector.md"
- "FAQ": "usage/faq.md"
- "Benchmarking": "usage/benchmarking.md"
- Development:
- "Modifying swe-agent": "dev/modify.md"
- "Config files": "dev/config.md"
+ - "Command definitions": "dev/commands.md"
+ - "Demonstrations": "dev/demonstrations.md"
- "Contribution guide": "dev/contribute.md"
plugins:
diff --git a/trajectories/README.md b/trajectories/README.md
deleted file mode 100644
index 5b4d81c1..00000000
--- a/trajectories/README.md
+++ /dev/null
@@ -1,45 +0,0 @@
-# Trajectories
-
-The `trajectories/` folder is the default location that experiment results (invocations of `run.py`) will be written to.
-
-At a high level, the experiments folder is organized in the following manner:
-```
-trajectories
-β”œβ”€β”€ <user 1> πŸ‘©β€πŸ’»
-β”‚ β”œβ”€β”€ <experiment 1> πŸ§ͺ
-β”‚ β”‚ β”œβ”€β”€ all_preds.jsonl
-β”‚ β”‚ β”œβ”€β”€ args.yaml
-β”‚ β”‚ β”œβ”€β”€ *.html (Webpage Files)
-β”‚ β”‚ └── *.traj (Trajectories)
-β”‚ └── <experiment 2> πŸ§ͺ
-β”‚ β”œβ”€β”€ all_preds.jsonl
-β”‚ β”œβ”€β”€ args.yaml
-β”‚ β”œβ”€β”€ *.html (Webpage Files)
-β”‚ └── *.traj (Trajectories)
-β”œβ”€β”€ <user 2> πŸ‘¨β€πŸ’»
-β”‚ β”œβ”€β”€ <experiment 1> πŸ§ͺ
-β”‚ β”‚ └── ...
-β”‚ └── <experiment 2> πŸ§ͺ
-β”‚ └── ...
-...
-```
-Where every experiment follows the pattern `trajectories/<user name>/<experiment name>`. The `<user name>` is automatically inferred from your system, and the `experiment name` is inferred from the arguments of the `run.py`.
-
-## How an Experiment Folder is Generated
-
-Each call to `run.py` produces a single `trajectories/<user name>/<experiment name>` folder containing the following assets:
-* `all_preds.jsonl`: A single file containing all of the predictions generated for the experiment (1 prediction per task instance), where each line is formatted as:
-```
-{
- "instance_id": "<Unique task instance ID>",
- "model_patch": "<.patch file content string>",
- "model_name_or_path": "<Model name here (Inferred from experiment configs)>",
-}
-```
-* `args.yaml`: A summary of the configurations for the experiment run.
-* `<instance_id>.traj`: A `.json` formatted file containing the (thought, action, observation) turns generated by SWE-agent towards solving `<instance_id>`.
-* `<instance_id>.html`: An `.html` single webpage render of the trajectory, which can be directly opened in the browser for easier viewing of the trajectory.
-
-> ⚠️ Notes
-> * Evaluation is not completed by `run.py`, it is a separate step.
-> * `all_preds.jsonl` can be referenced directly into `evaluation/run_eval.sh` to run evaluation.
\ No newline at end of file
diff --git a/trajectories/README.md b/trajectories/README.md
new file mode 120000
index 00000000..f238cdb8
--- /dev/null
+++ b/trajectories/README.md
@@ -0,0 +1 @@
+../docs/usage/trajectories.md
\ No newline at end of file