YuyaoGe commited on
Commit
2ef5cbd
·
verified ·
1 Parent(s): 4643617

Initial release: 94 public scenarios, development document, contract skeleton, leaderboard

Browse files
LICENSE ADDED
@@ -0,0 +1,160 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ Apache License
2
+ Version 2.0, January 2004
3
+ http://www.apache.org/licenses/
4
+
5
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6
+
7
+ 1. Definitions.
8
+
9
+ "License" shall mean the terms and conditions for use, reproduction,
10
+ and distribution as defined by Sections 1 through 9 of this document.
11
+
12
+ "Licensor" shall mean the copyright owner or entity authorized by
13
+ the copyright owner that is granting the License.
14
+
15
+ "Legal Entity" shall mean the union of the acting entity and all
16
+ other entities that control, are controlled by, or are under common
17
+ control with that entity. For the purposes of this definition,
18
+ "control" means (i) the power, direct or indirect, to cause the
19
+ direction or management of such entity, whether by contract or
20
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
21
+ outstanding shares, or (iii) beneficial ownership of such entity.
22
+
23
+ "You" (or "Your") shall mean an individual or Legal Entity
24
+ exercising permissions granted by this License.
25
+
26
+ "Source" form shall mean the preferred form for making modifications,
27
+ including but not limited to software source code, documentation
28
+ source, and configuration files.
29
+
30
+ "Object" form shall mean any form resulting from mechanical
31
+ transformation or translation of a Source form, including but
32
+ not limited to compiled object code, generated documentation,
33
+ and conversions to other media types.
34
+
35
+ "Work" shall mean the work of authorship made available under
36
+ the License, as indicated by a copyright notice that is included in
37
+ or attached to the work (an example is provided in the Appendix below).
38
+
39
+ "Derivative Works" shall mean any work, whether in Source or Object
40
+ form, that is based on (or derived from) the Work and for which the
41
+ editorial revisions, annotations, elaborations, or other modifications
42
+ represent, as a whole, an original work of authorship. For the purposes
43
+ of this License, Derivative Works shall not include works that remain
44
+ separable from, or merely link (or bind by name) to the interfaces of,
45
+ the Work and Derivative Works thereof.
46
+
47
+ "Contribution" shall mean, as defined by the Licensor, any work of
48
+ authorship, including the original version of the Work and any
49
+ modifications or additions to that Work or Derivative Works of the Work,
50
+ that is intentionally submitted to the Licensor for inclusion in the Work
51
+ by the copyright owner or by an individual or Legal Entity authorized to
52
+ submit on behalf of the copyright owner.
53
+
54
+ "Contributor" shall mean Licensor and any Legal Entity on behalf of
55
+ whom a Contribution has been received by the Licensor and included
56
+ within the Work.
57
+
58
+ 2. Grant of Copyright License. Subject to the terms and conditions of
59
+ this License, each Contributor hereby grants to You a perpetual,
60
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
61
+ copyright license to reproduce, prepare Derivative Works of,
62
+ publicly display, publicly perform, sublicense, and distribute the
63
+ Work and such Derivative Works in Source or Object form.
64
+
65
+ 3. Grant of Patent License. Subject to the terms and conditions of
66
+ this License, each Contributor hereby grants to You a perpetual,
67
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
68
+ (except as stated in this section) patent license to make, have made,
69
+ use, offer to sell, sell, import, and otherwise transfer the Work,
70
+ where such license applies only to those patent claims licensable
71
+ by such Contributor that are necessarily infringed by their
72
+ Contribution(s) alone or by the combination of their Contribution(s)
73
+ with the Work to which such Contribution(s) was submitted. If You
74
+ institute patent litigation against any entity (including a cross-claim
75
+ or counterclaim in a lawsuit) alleging that the Work or any
76
+ Contribution embodied within the Work constitutes direct or
77
+ contributory patent infringement, then any patent licenses granted to
78
+ You under this License for that Work shall terminate as of the date
79
+ such litigation is filed.
80
+
81
+ 4. Redistribution. You may reproduce and distribute copies of the
82
+ Work or Derivative Works thereof in any medium, with or without
83
+ modifications, and in Source or Object form, provided that You
84
+ meet the following conditions:
85
+
86
+ (a) You must give any other recipients of the Work or Derivative
87
+ Works a copy of this License; and
88
+
89
+ (b) You must cause any modified files to carry prominent notices
90
+ stating that You changed the files; and
91
+
92
+ (c) You must retain, in the Source form of any Derivative Works
93
+ that You distribute, all copyright, patent, trademark, and
94
+ attribution notices from the Source form of the Work,
95
+ excluding those notices that do not pertain to any part of
96
+ the Derivative Works; and
97
+
98
+ (d) If the Work includes a "NOTICE" text file as part of its
99
+ distribution, You must include a readable copy of the
100
+ attribution notices contained within such NOTICE file, in
101
+ at least one of the following places: within a NOTICE text
102
+ file distributed as part of the Derivative Works; within
103
+ the Source form or documentation, if provided along with the
104
+ Derivative Works; or, within a display generated by the
105
+ Derivative Works, if and wherever such third-party notices
106
+ normally appear. The contents of the NOTICE file are for
107
+ informational purposes only and do not modify the License.
108
+ You may add Your own attribution notices within Derivative
109
+ Works that You distribute, alongside or as an addendum to
110
+ the NOTICE text from the Work, provided that such additional
111
+ attribution notices cannot be construed as modifying the License.
112
+
113
+ You may add Your own license statement for Your modifications and
114
+ may provide additional grant of rights to use, copy, modify, merge,
115
+ publish, distribute, sublicense, and/or sell copies of the Work
116
+ and derivative works.
117
+
118
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
119
+ any Contribution intentionally submitted for inclusion in the Work
120
+ by You to the Licensor shall be under the terms and conditions of
121
+ this License, without any additional terms or conditions.
122
+ Notwithstanding the above, nothing herein shall supersede or modify
123
+ the terms of any separate license agreement you may have executed
124
+ with Licensor regarding such Contributions.
125
+
126
+ 6. Trademarks. This License does not grant permission to use the trade
127
+ names, trademarks, service marks, or product names of the Licensor,
128
+ except as required for reasonable and customary use in describing the
129
+ origin of the Work and reproducing the content of the NOTICE file.
130
+
131
+ 7. Disclaimer of Warranty. Unless required by applicable law or
132
+ agreed to in writing, Licensor provides the Work (and each
133
+ Contributor provides its Contributions) on an "AS IS" BASIS,
134
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
135
+ implied, including, without limitation, any warranties or conditions
136
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
137
+ PARTICULAR PURPOSE. You are solely responsible for determining the
138
+ appropriateness of using or reproducing the Work and assume any
139
+ risks associated with Your exercise of permissions under this License.
140
+
141
+ 8. Limitation of Liability. In no event and under no legal theory,
142
+ whether in tort (including negligence), contract, or otherwise,
143
+ unless required by applicable law (such as deliberate and grossly
144
+ negligent acts) or agreed to in writing, shall any Contributor be
145
+ liable to You for damages, including any direct, indirect, special,
146
+ incidental, or exemplary damages of any character arising as a
147
+ result of this License or out of the use or inability to use the
148
+ Work (including but not limited to damages for loss of goodwill,
149
+ work stoppage, computer failure or malfunction, or all other
150
+ commercial damages or losses), even if such Contributor has been
151
+ advised of the possibility of such damages.
152
+
153
+ 9. Accepting Warranty or Additional Liability. While redistributing
154
+ the Work or Derivative Works thereof, You may choose to offer,
155
+ and charge a fee for, acceptance of support, warranty, indemnity,
156
+ or other liability obligations and/or rights consistent with this
157
+ License. However, in accepting such obligations, You may offer only
158
+ conditions consistent with this License.
159
+
160
+ END OF TERMS AND CONDITIONS
NOTICE ADDED
@@ -0,0 +1,45 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Third-party notices
2
+
3
+ doc2harness evaluates coding-agent products. This file records the upstream work
4
+ it builds on and relates to. It is an attribution record, not a license grant —
5
+ see `LICENSE` for this project's own terms.
6
+
7
+ ## mini-swe-agent
8
+
9
+ MIT License, Copyright (c) 2025 Kilian A. Lieret and Carlos E. Jimenez
10
+ https://mini-swe-agent.com/ · https://github.com/SWE-agent/mini-swe-agent
11
+
12
+ stage1 asks a model to build a harness product by implementing a hollowed
13
+ skeleton. That skeleton derives from mini-swe-agent's project layout.
14
+
15
+ Scope of what is redistributed here: **no mini-swe-agent source code is vendored
16
+ in this repository.** The skeleton at `src/stage1/f0_clean/` is a few small
17
+ files of contract sockets that raise `NotImplementedError`; it carries no upstream
18
+ implementation, and neither image installs mini-swe-agent. A product a builder
19
+ derives from mini-swe-agent remains subject to the MIT license above — anyone
20
+ distributing such a product needs to carry that notice with it.
21
+
22
+ Note for product builders: the stage1 build prompt instructs the model to
23
+ present the product under its own name and to suppress the upstream startup
24
+ banner. That is an evaluation-fidelity measure (the benchmark observes the
25
+ product's own declared behaviour), not an attempt to obscure provenance. It does
26
+ not remove the MIT attribution obligation, which this notice discharges for the
27
+ benchmark and which a product's own distribution must discharge for itself.
28
+
29
+ ## OpenCode
30
+
31
+ https://opencode.ai/
32
+
33
+ The builder image installs the OpenCode CLI binary, which drives the model
34
+ during a stage1 build. It is installed from upstream at image build time under
35
+ its own license; this repository redistributes no OpenCode code. The published
36
+ builder image does contain the binary — consult OpenCode's terms before
37
+ redistributing that image.
38
+
39
+ ## LiteLLM
40
+
41
+ https://github.com/BerriAI/LiteLLM
42
+
43
+ Used at runtime as the model gateway. It is a runtime dependency supplied by the
44
+ operator, is not a dependency of the published wheel, and no LiteLLM code is
45
+ redistributed here.
README.md ADDED
@@ -0,0 +1,169 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ license: apache-2.0
3
+ pretty_name: Doc2Harness
4
+ language:
5
+ - en
6
+ task_categories:
7
+ - text-generation
8
+ tags:
9
+ - code
10
+ - agents
11
+ - coding-agents
12
+ - harness-engineering
13
+ - benchmark
14
+ - llm-evaluation
15
+ size_categories:
16
+ - n<1K
17
+ configs:
18
+ - config_name: scenarios
19
+ default: true
20
+ data_files:
21
+ - split: test
22
+ path: data/scenarios.jsonl
23
+ - config_name: leaderboard
24
+ data_files:
25
+ - split: test
26
+ path: data/leaderboard.jsonl
27
+ ---
28
+
29
+ <p align="center">
30
+ <a href="https://geyuyao.com/doc2harness/"><img src="assets/logo.png" alt="Doc2Harness" width="420"></a>
31
+ </p>
32
+
33
+ <h3 align="center">Benchmarking LLMs on Long-Horizon Harness Engineering of Coding Agents</h3>
34
+
35
+ <p align="center">
36
+ <a href="https://geyuyao.com/doc2harness/">🌐 Project page</a> •
37
+ <a href="https://arxiv.org/abs/2610.20344">📄 Paper</a> •
38
+ <a href="https://github.com/YuyaoGe/doc2harness">💻 Code</a>
39
+ </p>
40
+
41
+ Doc2Harness measures how well a model can **build a working coding agent harness**
42
+ from a development document, rather than how well it writes a patch inside an
43
+ existing one.
44
+
45
+ - **Stage 1, build.** A build model, working through a fixed builder harness
46
+ (OpenCode) in an isolated container, receives a development document and an
47
+ interface-only contract skeleton, and implements a complete candidate harness.
48
+ - **Stage 2, evaluate.** The frozen candidate harness runs in containers
49
+ separate from the construction environment, one per test case, and is driven
50
+ end to end by a scripted **mock model**. Each test case is judged on four
51
+ observable channels (requests sent to the model, files on disk, process exit
52
+ code, command output), and **positive controls** rule out vacuous passes.
53
+
54
+ <p align="center">
55
+ <img src="assets/pipeline.png" alt="Doc2Harness pipeline" width="92%">
56
+ </p>
57
+
58
+ > [!NOTE]
59
+ > **This is a partial release.** The full benchmark in the paper has **328 test
60
+ > cases**. This dataset releases the same public subset as the
61
+ > [GitHub repository](https://github.com/YuyaoGe/doc2harness): **94 scenarios**,
62
+ > i.e. 53 scored test cases plus the 41 positive controls that gate them. The
63
+ > remaining test cases are held out. The leaderboard numbers come from the full
64
+ > suite and cannot be reproduced from this subset alone.
65
+
66
+ > [!IMPORTANT]
67
+ > Doc2Harness is an **executable** benchmark. This dataset lets you browse and
68
+ > analyze the scenarios, the development document, and the contract skeleton.
69
+ > To actually score a harness (Docker, mock gateway, drivers), use the code on
70
+ > [GitHub](https://github.com/YuyaoGe/doc2harness).
71
+
72
+ ## Contents
73
+
74
+ | Path | What it is |
75
+ |---|---|
76
+ | `data/scenarios.jsonl` | The 94 public scenarios, one per row (config `scenarios`) |
77
+ | `data/leaderboard.jsonl` | Pass rates of 19 frontier models on the full 328-case suite (config `leaderboard`) |
78
+ | `development_document/functional_spec_v6.md` | The development document given to the build model in Stage 1 |
79
+ | `contract_skeleton/` | The interface-only contract skeleton (CLI, headless entry point, evaluation API), plus `AGENT_CONTRACT-v2.md` |
80
+
81
+ ## Usage
82
+
83
+ ```python
84
+ from datasets import load_dataset
85
+
86
+ scenarios = load_dataset("YuyaoGe/doc2harness", "scenarios", split="test")
87
+ leaderboard = load_dataset("YuyaoGe/doc2harness", "leaderboard", split="test")
88
+
89
+ scored = scenarios.filter(lambda r: r["scored"])
90
+ print(len(scenarios), len(scored)) # 94 53
91
+ ```
92
+
93
+ The development document and the skeleton are plain files:
94
+
95
+ ```python
96
+ from huggingface_hub import snapshot_download
97
+
98
+ path = snapshot_download("YuyaoGe/doc2harness", repo_type="dataset",
99
+ allow_patterns=["development_document/*", "contract_skeleton/**"])
100
+ ```
101
+
102
+ ## Scenario fields (`scenarios`)
103
+
104
+ | Field | Type | Description |
105
+ |---|---|---|
106
+ | `scenario_id` | string | Stable identifier, equal to the scenario file name |
107
+ | `family` | string | Framework family: `permission`, `file`, `state`, `direct`, `headless`, `tui`, `artifact`, `startup`, `extension` |
108
+ | `category` | string | Category name used in the paper (e.g. `permissions`, `session state`, `interactive terminal`) |
109
+ | `role` | string | `test_case` (scored) or `positive_control` (not scored) |
110
+ | `scored` | bool | Whether the scenario counts toward the pass rate |
111
+ | `difficulty` | string | `standard` or `hard` |
112
+ | `gated_by` | list[string] | Positive controls that must PASS for this test case's status to count |
113
+ | `requires` | list[string] | Other scenarios this one depends on |
114
+ | `summary` | string | One-line purpose of the scenario |
115
+ | `description` | string | Purpose and step-by-step flow, from the scenario file |
116
+ | `source_path` | string | Path of the scenario file in the GitHub repository |
117
+ | `source_code` | string | Full source of the scenario (setup, stimulus, observation, and judgement) |
118
+
119
+ A **scenario** is the session through which the mock model drives the candidate
120
+ harness; a **test case** is a scenario plus its assertion. A **positive control**
121
+ proves that the probed operation *can* succeed when nothing blocks it, so a
122
+ blocked run in the gated test case reads as "the rule held" rather than "the
123
+ command never worked". If you select a subset, keep it closed under `gated_by`.
124
+
125
+ | Family | Total | Scored | Controls |
126
+ |---|--:|--:|--:|
127
+ | `file` | 17 | 9 | 8 |
128
+ | `permission` | 16 | 8 | 8 |
129
+ | `state` | 14 | 7 | 7 |
130
+ | `headless` | 13 | 6 | 7 |
131
+ | `direct` | 11 | 6 | 5 |
132
+ | `tui` | 9 | 5 | 4 |
133
+ | `artifact` | 7 | 7 | 0 |
134
+ | `startup` | 5 | 4 | 1 |
135
+ | `extension` | 2 | 1 | 1 |
136
+ | **Total** | **94** | **53** | **41** |
137
+
138
+ ## Leaderboard (`leaderboard`)
139
+
140
+ <p align="center">
141
+ <img src="assets/leaderboard.png" alt="Pass rate of nineteen models" width="100%">
142
+ </p>
143
+
144
+ Pass rate (%) of 19 frontier models on the **full 328-case suite**. Each model
145
+ built three independent candidate harnesses; `pass_rate` is their mean and
146
+ `pass_rate_std` the standard deviation. Category columns are the per-category
147
+ pass rates; `other` merges artifact checks, startup, and extension discovery.
148
+ Positive controls are excluded from every denominator. GPT-6 Astra leads at
149
+ 53.05%, the weakest model reaches 27.44%, and the cross-model mean is 38.30%.
150
+
151
+ ## Citation
152
+
153
+ ```bibtex
154
+ @article{ge2026doc2harness,
155
+ title = {Doc2Harness: Benchmarking LLMs on Long-Horizon Harness Engineering of Coding Agents},
156
+ author = {Ge, Yuyao and Liu, Shenghua and Gao, Peizhong and Ge, Chendi and Liu, Chenxu and
157
+ Wang, Yiwei and Mei, Lingrui and Bi, Baolong and Yao, Jiayu and Guo, Jiafeng and
158
+ Cheng, Xueqi},
159
+ journal = {arXiv preprint arXiv:2610.20344},
160
+ year = {2026}
161
+ }
162
+ ```
163
+
164
+ ## License
165
+
166
+ Apache 2.0, same as the [code repository](https://github.com/YuyaoGe/doc2harness).
167
+ The contract skeleton derives from the project layout of
168
+ [mini-swe-agent](https://github.com/SWE-agent/mini-swe-agent) (MIT); see `NOTICE`
169
+ for upstream attribution.
assets/leaderboard.png ADDED

Git LFS Details

  • SHA256: 2f789477a5a24535462d47c4f31e540e3a3b1fa697e23997d0fb8c0d9d2a8005
  • Pointer size: 131 Bytes
  • Size of remote file: 182 kB
assets/logo.png ADDED

Git LFS Details

  • SHA256: 7c10a641f41596c38e5fad58b44808805bc44df469a351d0e597fd8a91a774bf
  • Pointer size: 130 Bytes
  • Size of remote file: 22.5 kB
assets/pipeline.png ADDED

Git LFS Details

  • SHA256: dbff56c7405f33c5e6ca20393955b2f85c503adbc5723bc70e3409a6a9bd5ea2
  • Pointer size: 131 Bytes
  • Size of remote file: 146 kB
contract_skeleton/.gitignore ADDED
@@ -0,0 +1,2 @@
 
 
 
1
+ __pycache__/
2
+ *.pyc
contract_skeleton/AGENT_CONTRACT-v2.md ADDED
@@ -0,0 +1,32 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Entry-point contract
2
+
3
+ The format of the two input files `run_agent.sh` receives. For the remaining
4
+ interface requirements, see `functional_spec.md` §0.1.1.
5
+
6
+ ## `task.json` (referenced by `--task-file`, read-only)
7
+
8
+ ```json
9
+ {
10
+ "task_id": "<id>",
11
+ "type": "<type name>",
12
+ "problem_statement": "<problem text>",
13
+ "repo_dir": "/app",
14
+ "allow_network": false
15
+ }
16
+ ```
17
+
18
+ - `problem_statement` — the problem to solve, as plain text.
19
+ - `repo_dir` — path to the repository to modify; identical to `--repo-dir`.
20
+ - `allow_network` — whether network access is permitted for this run.
21
+
22
+ ## `budget.json` (referenced by `--budget-file`, read-only)
23
+
24
+ ```json
25
+ { "max_steps": 50, "max_tokens": 0, "max_wall_seconds": 1800 }
26
+ ```
27
+
28
+ - `max_steps` — maximum number of steps, where one step is approximately one
29
+ model call. On reaching the limit the agent must stop cleanly and record
30
+ `LimitsExceeded`.
31
+ - `max_tokens` — `0` means no limit is enforced on the agent side.
32
+ - `max_wall_seconds` — wall-clock limit, in seconds.
contract_skeleton/entry.py ADDED
@@ -0,0 +1,21 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #!/usr/bin/env python3
2
+ """Unattended entrypoint. Invoked directly by `run_agent.sh` and by external callers.
3
+ Arguments are specified in `.d2a_spec/AGENT_CONTRACT.md`.
4
+
5
+ Callers copy this directory verbatim into a clean container and run it as-is: no package
6
+ installation beforehand, and an empty PYTHONPATH.
7
+ """
8
+ from __future__ import annotations
9
+
10
+ import os
11
+ import sys
12
+
13
+ sys.path.insert(0, os.path.join(os.path.dirname(os.path.abspath(__file__)), "src"))
14
+
15
+
16
+ def main(argv: list[str] | None = None) -> int:
17
+ raise NotImplementedError
18
+
19
+
20
+ if __name__ == "__main__":
21
+ sys.exit(main())
contract_skeleton/install.sh ADDED
@@ -0,0 +1,4 @@
 
 
 
 
 
1
+ #!/usr/bin/env bash
2
+ # One-step install.
3
+ set -euo pipefail
4
+ cd "$(dirname "$0")"
contract_skeleton/pyproject.toml ADDED
@@ -0,0 +1,38 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # The environment is offline, so no new packages can be installed. The entries below are
2
+ # the libraries already present in the environment and importable as-is.
3
+
4
+ [build-system]
5
+ requires = ["setuptools>=68"]
6
+ build-backend = "setuptools.build_meta"
7
+
8
+ [project]
9
+ name = "yuyao-agent"
10
+ version = "0.1.0"
11
+ requires-python = ">=3.12"
12
+ dependencies = [
13
+ "litellm==1.95.0",
14
+ "openai==2.53.0",
15
+ "httpx==0.28.1",
16
+ "requests==2.34.2",
17
+ "aiohttp==3.14.3",
18
+ "rich==15.0.0",
19
+ "textual==8.2.8",
20
+ "prompt_toolkit==3.0.53",
21
+ "Pygments==2.20.0",
22
+ "typer==0.27.1",
23
+ "click==8.4.2",
24
+ "pydantic==2.13.4",
25
+ "PyYAML==6.0.3",
26
+ "Jinja2==3.1.6",
27
+ "jsonschema==4.26.0",
28
+ "tenacity==9.1.4",
29
+ "tiktoken==0.13.0",
30
+ "python-dotenv==1.2.2",
31
+ "tqdm==4.70.0",
32
+ ]
33
+
34
+ [project.scripts]
35
+ yuyao = "yuyao.cli:main"
36
+
37
+ [tool.setuptools.packages.find]
38
+ where = ["src"]
contract_skeleton/run_agent.sh ADDED
@@ -0,0 +1,5 @@
 
 
 
 
 
 
1
+ #!/usr/bin/env bash
2
+ # Unattended entrypoint. Arguments and input file formats are specified in
3
+ # `.d2a_spec/AGENT_CONTRACT.md`.
4
+ set -uo pipefail
5
+ exec python3 "$(dirname "$0")/entry.py" "$@"
contract_skeleton/src/yuyao/__init__.py ADDED
@@ -0,0 +1 @@
 
 
1
+ """yuyao agent."""
contract_skeleton/src/yuyao/__main__.py ADDED
@@ -0,0 +1,5 @@
 
 
 
 
 
 
1
+ import sys
2
+
3
+ from yuyao.cli import main
4
+
5
+ sys.exit(main())
contract_skeleton/src/yuyao/agent_api.py ADDED
@@ -0,0 +1,37 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """The fixed entry point through which external programs drive this agent.
2
+
3
+ For the contract, see `.d2a_spec/functional_spec.md` §0.1.2.
4
+
5
+ These signatures must not change: external programs call exactly this shape.
6
+ """
7
+ from __future__ import annotations
8
+
9
+
10
+ def create_session(*, deny=None, mode=None, role=None, cwd=None) -> "AgentSession":
11
+ raise NotImplementedError
12
+
13
+
14
+ class AgentSession:
15
+ @property
16
+ def cwd(self) -> str:
17
+ raise NotImplementedError
18
+
19
+ @property
20
+ def messages(self) -> list:
21
+ raise NotImplementedError
22
+
23
+ def dispatch(self, command: str) -> str:
24
+ raise NotImplementedError
25
+
26
+ def chat(self, text: str) -> str:
27
+ raise NotImplementedError
28
+
29
+ def config_get(self, key: str):
30
+ raise NotImplementedError
31
+
32
+ @property
33
+ def mcp_servers(self) -> list:
34
+ raise NotImplementedError
35
+
36
+ def close(self) -> None:
37
+ raise NotImplementedError
contract_skeleton/src/yuyao/cli.py ADDED
@@ -0,0 +1,12 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """Command-line entry point. `[project.scripts]` in `pyproject.toml` points at `main` here."""
2
+ from __future__ import annotations
3
+
4
+ import sys
5
+
6
+
7
+ def main(argv: list[str] | None = None) -> int:
8
+ raise NotImplementedError
9
+
10
+
11
+ if __name__ == "__main__":
12
+ sys.exit(main())
data/leaderboard.jsonl ADDED
@@ -0,0 +1,19 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {"rank": 1, "model": "GPT-6 Astra", "vendor": "OpenAI", "pass_rate": 53.05, "pass_rate_std": 0.25, "permissions": 71.6, "file_operations": 46.7, "session_state": 44.0, "direct_drive": 39.4, "headless": 45.0, "interactive_terminal": 91.7, "other": 60.0, "n_builds": 3, "n_test_cases": 328}
2
+ {"rank": 2, "model": "Opus 5", "vendor": "Anthropic", "pass_rate": 46.65, "pass_rate_std": 1.8, "permissions": 63.4, "file_operations": 39.6, "session_state": 38.1, "direct_drive": 17.2, "headless": 43.3, "interactive_terminal": 91.7, "other": 75.6, "n_builds": 3, "n_test_cases": 328}
3
+ {"rank": 3, "model": "Qwen3.8 Max", "vendor": "Alibaba", "pass_rate": 45.83, "pass_rate_std": 0.14, "permissions": 61.2, "file_operations": 38.2, "session_state": 43.3, "direct_drive": 15.2, "headless": 32.5, "interactive_terminal": 93.3, "other": 75.6, "n_builds": 3, "n_test_cases": 328}
4
+ {"rank": 4, "model": "GPT-5.6-sol", "vendor": "OpenAI", "pass_rate": 43.8, "pass_rate_std": 2.44, "permissions": 47.5, "file_operations": 48.9, "session_state": 29.4, "direct_drive": 32.3, "headless": 39.2, "interactive_terminal": 83.3, "other": 68.9, "n_builds": 3, "n_test_cases": 328}
5
+ {"rank": 5, "model": "Grok 4.7", "vendor": "xAI", "pass_rate": 43.5, "pass_rate_std": 2.49, "permissions": 54.6, "file_operations": 50.7, "session_state": 28.2, "direct_drive": 22.2, "headless": 33.3, "interactive_terminal": 78.3, "other": 75.6, "n_builds": 3, "n_test_cases": 328}
6
+ {"rank": 6, "model": "GLM 5.3", "vendor": "Z.ai", "pass_rate": 42.07, "pass_rate_std": 1.39, "permissions": 51.4, "file_operations": 41.8, "session_state": 33.3, "direct_drive": 18.2, "headless": 31.7, "interactive_terminal": 85.0, "other": 77.8, "n_builds": 3, "n_test_cases": 328}
7
+ {"rank": 7, "model": "MiMo-V2.6-Flash", "vendor": "Xiaomi", "pass_rate": 41.87, "pass_rate_std": 3.29, "permissions": 50.3, "file_operations": 40.4, "session_state": 37.7, "direct_drive": 14.1, "headless": 33.3, "interactive_terminal": 76.7, "other": 75.6, "n_builds": 3, "n_test_cases": 328}
8
+ {"rank": 8, "model": "Step 5 Preview", "vendor": "StepFun", "pass_rate": 40.75, "pass_rate_std": 3.29, "permissions": 47.0, "file_operations": 45.8, "session_state": 34.1, "direct_drive": 14.1, "headless": 25.8, "interactive_terminal": 76.7, "other": 77.8, "n_builds": 3, "n_test_cases": 328}
9
+ {"rank": 9, "model": "DeepSeek V4.1 Flash", "vendor": "DeepSeek", "pass_rate": 40.24, "pass_rate_std": 0.86, "permissions": 49.2, "file_operations": 36.4, "session_state": 34.5, "direct_drive": 14.1, "headless": 31.7, "interactive_terminal": 81.7, "other": 80.0, "n_builds": 3, "n_test_cases": 328}
10
+ {"rank": 10, "model": "Hy4 preview", "vendor": "Tencent", "pass_rate": 38.92, "pass_rate_std": 1.46, "permissions": 44.8, "file_operations": 38.2, "session_state": 35.7, "direct_drive": 10.1, "headless": 27.5, "interactive_terminal": 78.3, "other": 77.8, "n_builds": 3, "n_test_cases": 328}
11
+ {"rank": 11, "model": "Kimi K3", "vendor": "Moonshot AI", "pass_rate": 38.31, "pass_rate_std": 1.28, "permissions": 43.2, "file_operations": 40.9, "session_state": 25.4, "direct_drive": 18.2, "headless": 32.5, "interactive_terminal": 86.7, "other": 73.3, "n_builds": 3, "n_test_cases": 328}
12
+ {"rank": 12, "model": "Opus 4.8", "vendor": "Anthropic", "pass_rate": 38.01, "pass_rate_std": 0.87, "permissions": 30.1, "file_operations": 48.4, "session_state": 33.7, "direct_drive": 12.1, "headless": 22.5, "interactive_terminal": 83.3, "other": 80.0, "n_builds": 3, "n_test_cases": 328}
13
+ {"rank": 13, "model": "GPT-5.5", "vendor": "OpenAI", "pass_rate": 34.65, "pass_rate_std": 1.42, "permissions": 36.1, "file_operations": 36.4, "session_state": 25.0, "direct_drive": 24.2, "headless": 20.8, "interactive_terminal": 76.7, "other": 77.8, "n_builds": 3, "n_test_cases": 328}
14
+ {"rank": 14, "model": "Doubao Seed 2.1 Pro", "vendor": "ByteDance", "pass_rate": 32.62, "pass_rate_std": 1.51, "permissions": 41.5, "file_operations": 36.0, "session_state": 15.5, "direct_drive": 20.2, "headless": 18.3, "interactive_terminal": 83.3, "other": 73.3, "n_builds": 3, "n_test_cases": 328}
15
+ {"rank": 15, "model": "Opus 4.7", "vendor": "Anthropic", "pass_rate": 32.22, "pass_rate_std": 1.66, "permissions": 36.1, "file_operations": 29.8, "session_state": 25.8, "direct_drive": 12.1, "headless": 16.7, "interactive_terminal": 85.0, "other": 80.0, "n_builds": 3, "n_test_cases": 328}
16
+ {"rank": 16, "model": "DeepSeek V4 Pro", "vendor": "DeepSeek", "pass_rate": 31.91, "pass_rate_std": 1.23, "permissions": 29.5, "file_operations": 33.3, "session_state": 21.0, "direct_drive": 23.2, "headless": 21.7, "interactive_terminal": 78.3, "other": 80.0, "n_builds": 3, "n_test_cases": 328}
17
+ {"rank": 17, "model": "Opus 4.6", "vendor": "Anthropic", "pass_rate": 28.25, "pass_rate_std": 0.14, "permissions": 20.8, "file_operations": 37.3, "session_state": 21.8, "direct_drive": 25.3, "headless": 3.3, "interactive_terminal": 60.0, "other": 80.0, "n_builds": 3, "n_test_cases": 328}
18
+ {"rank": 18, "model": "GLM 5.2", "vendor": "Z.ai", "pass_rate": 27.64, "pass_rate_std": 1.01, "permissions": 23.0, "file_operations": 32.9, "session_state": 21.8, "direct_drive": 12.1, "headless": 12.5, "interactive_terminal": 63.3, "other": 80.0, "n_builds": 3, "n_test_cases": 328}
19
+ {"rank": 19, "model": "Hy3", "vendor": "Tencent", "pass_rate": 27.44, "pass_rate_std": 0.43, "permissions": 28.4, "file_operations": 31.1, "session_state": 19.4, "direct_drive": 13.1, "headless": 9.2, "interactive_terminal": 65.0, "other": 80.0, "n_builds": 3, "n_test_cases": 328}
data/scenarios.jsonl ADDED
The diff for this file is too large to render. See raw diff
 
development_document/functional_spec_v6.md ADDED
@@ -0,0 +1,474 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Functional Specification — Super Coding Agent
2
+
3
+ > This document defines the complete external surface of a "super coding agent": built-in tools, top-level commands, global flags, permission and role modes, in-session slash commands, the persistent memory system, convention files, and exit codes.
4
+ > From this specification the builder must produce an agent that is installable, interactive, and capable of unattended execution.
5
+ > Every feature listed in this document is a required item.
6
+ > §8 adds cross-cutting consistency rules and specifies the externally observable surfaces on which the effect of each feature must land.
7
+ ---
8
+
9
+ ## 0. Deliverables and Runtime Interfaces
10
+
11
+ ### 0.1 Deliverables
12
+ | Deliverable | Description |
13
+ |---|---|
14
+ | Installation script | One-shot installation (e.g. `install.sh`); once it has run, the `yuyao` command must be usable (for the product name see §0.4). It ships and declares all dependencies. |
15
+ | Interactive terminal interface (TUI / REPL) | `yuyao` starts an interactive session supporting the slash commands of §5, the keyboard shortcuts, and the input prefixes. For interface requirements see §0.6. |
16
+ | Non-interactive entry point `run_agent.sh` | For unattended invocation by external programs. |
17
+
18
+ #### 0.1.1 Required Interfaces
19
+
20
+ 1. **The artifact root must contain**: `run_agent.sh`, `entry.py`, `wheels/` (≥1 offline wheel), `requirements.lock`, `VERSION`.
21
+ 2. **`run_agent.sh` must accept and correctly handle these 7 arguments**: `--task-file`, `--repo-dir`, `--model-base-url`, `--model-name`, `--model-api-key`, `--budget-file`, `--out-dir`. The formats of the two input files are defined in `.d2a_spec/AGENT_CONTRACT.md`.
22
+ 3. **The model must be reached only through `--model-base-url`** (through `D2A_MODEL_*` in the TUI); no other egress address or credential may be hardcoded.
23
+ 4. **Code must be modified in place under `--repo-dir`**; execution traces and status must be written to `--out-dir` (`status.json` carrying `exit_status` and `cost_usd`, plus `.trajectory/`), and must not be written into `--repo-dir`.
24
+ 5. **The step limit in `--budget-file` must be honoured** (on reaching the limit, stop cleanly and record `LimitsExceeded`); exit codes must follow §9 (`Submitted`/`LimitsExceeded` → 0, error → 1, usage error → 2).
25
+ 6. **New third-party dependencies must be declared** under `[project.dependencies]` in `pyproject.toml` (or in `requirements.txt`) and must remain installable offline (the runtime environment has no network access).
26
+ 7. **`install.sh` must complete the installation in one shot**, leaving the `yuyao` command usable immediately afterwards.
27
+ 8. **`yuyao` must connect to the model with zero configuration**: when `D2A_MODEL_BASE_URL/NAME/API_KEY` are already present in the environment, the TUI must read them automatically, connect directly, and be usable at once.
28
+ 9. **Model calls must be real**: both the TUI and headless mode must genuinely send requests to the model and return the model's actual output.
29
+ 10. **The interactive TUI must be a coding agent that really executes tools, not a pure chatbot**: the model must be granted the tools of §1 (at minimum bash/read/write/edit/grep/glob), and the agent must actually execute the tool calls the model issues, feed the results back to the model, and continue. Plain conversation (e.g. `hi`) is answered with ordinary text. For the calling and execution pattern, see `agentic_turn` in `.d2a_spec/model_call_reference.py`.
30
+ 11. **The standard programmatic interface `yuyao.agent_api` must be exposed**: see §0.1.2.
31
+
32
+ #### 0.1.2 Standard Programmatic Interface
33
+
34
+ > This interface allows external programs to drive the agent deterministically: construct a session → run slash commands → run one agentic turn → read observable state,
35
+ > all through this single fixed interface, without going through internal class names, constructor signatures, or turn method names.
36
+ > `deny` / `mode` / `role` take effect when passed, with the same semantics as the command-line flags and the in-session switches; when omitted, your own defaults apply.
37
+
38
+ Your package must provide an importable module `yuyao.agent_api` exposing:
39
+
40
+ ```python
41
+ def create_session(*, deny=None, mode=None, role=None, cwd=None) -> AgentSession
42
+ ```
43
+
44
+ The returned `AgentSession` must provide the following members:
45
+
46
+ | Member | Type / signature | Meaning |
47
+ |---|---|---|
48
+ | `.cwd` | `str` | Path of the current working directory |
49
+ | `.messages` | `list[dict]` | Message list of the active session (OpenAI style, including tool results); tool execution results must genuinely land in it |
50
+ | `.dispatch(command)` | `(str) -> str` | Execute one slash command (e.g. `"/config set k v"`, `"/ask"`, `"/mcp add x"`), with the same semantics as typing it interactively; returns text (possibly the empty string) |
51
+ | `.chat(text)` | `(str) -> str` | Run one agentic turn: tools are really executed, results are fed back to the model, which continues; returns the assistant's final text (the same "hands-on" loop as item 10 of §0.1.1) |
52
+ | `.config_get(key)` | `(str) -> Any` | Read the current value of a persistent configuration key, or `None` if unset |
53
+ | `.mcp_servers` | `list[str]` | Names of the currently configured MCP servers |
54
+ | `.close()` | `() -> None` | Clean up |
55
+
56
+ Constraints: (i) `create_session` must not issue any model call during construction (lazy connection: constructing a session with placeholder or unreachable `D2A_MODEL_*` values must itself succeed); (ii) the session must be non-streaming and non-interactive (it must not read stdin and must not enter a Live view or spinner), and `dispatch`/`chat` must return synchronously.
57
+
58
+ ### 0.2 Model Connection: Unified Environment Variables
59
+
60
+ The model connection is supplied through the following unified environment variables, whose interface shape mirrors the `--model-*` arguments of `run_agent.sh`:
61
+
62
+ | Environment variable | Meaning |
63
+ |---|---|
64
+ | `D2A_MODEL_BASE_URL` | Model base URL (OpenAI-compatible gateway) |
65
+ | `D2A_MODEL_NAME` | Model name (litellm form, e.g. `litellm_proxy/<alias>`) |
66
+ | `D2A_MODEL_API_KEY` | API key used for calls |
67
+
68
+ When these three variables are present in the environment, the TUI must read them at startup, connect to the model directly, and be usable at once.
69
+
70
+ The agent must keep the model fully parameterized with zero hardcoding: headless mode reads the `--model-*` arguments of `run_agent.sh`, and the TUI reads the `D2A_MODEL_*` variables above (optionally overridden in-session by `/model`). No concrete URL, name, or key may be hardcoded, and the default model must not be an unreachable placeholder (such as `gpt-4`). When none of these variables is set, the TUI must emit a clear message rather than crash. Egress is permitted to that endpoint only.
71
+
72
+ The endpoint is the OpenAI-compatible `POST {D2A_MODEL_BASE_URL}/chat/completions`; for the calling convention see `.d2a_spec/model_call_reference.py`. The architecture is yours to design.
73
+
74
+ ### 0.3 Cost Accounting
75
+
76
+ Model unit prices are injected through the environment variable `D2A_MODEL_COST`, in the format `{"input_cost_per_token": <float>, "output_cost_per_token": <float>}`. The agent must accumulate spend accordingly and write it to `cost_usd` in `status.json`; when the variable is absent, spend counts as 0 and the agent must not crash.
77
+
78
+ ### 0.4 Branding and Naming
79
+
80
+ The product's only name is `yuyao agent`, and its launch command is `yuyao`. No Chinese name or other variant may be used. mini-swe-agent exists solely as an internal kernel; its name must never be visible to users.
81
+
82
+ - **Launch command**: installation provides the `yuyao` command (entering the interactive TUI); the headless contract entry point is `run_agent.sh`.
83
+ - **Use `yuyao` everywhere user-visible**: the TUI startup banner, titles, help text, prompt, version string, configuration and history file paths (e.g. `~/.yuyao/`), and the external names of packages and scripts — the string "mini" must not appear, nor may any Chinese name.
84
+ - Internal Python modules that reuse the mini kernel may keep its internal package names, but the string "mini" must not appear in user-visible output.
85
+ - The kernel's startup banner and version string must be suppressed: no text of the form `This is mini-swe-agent version X`, no migration notice, and no kernel logo may be printed to the user when `yuyao` starts or runs. Version numbers in the README, help output, and banner must be `yuyao`'s own.
86
+
87
+ ### 0.5 Documentation
88
+
89
+ - **README** (at the project root, replacing the original README): centred on `yuyao agent` — project overview and positioning, installation, quick start, feature overview (corresponding to §1–§7), non-interactive use of `run_agent.sh`, and FAQ.
90
+ - **Architecture document** (a separate file, e.g. `docs/ARCHITECTURE.md`): overall design and layering, directory and module responsibilities, core data flow (an entire task from input to persisted output), how permission and role modes are realized, built-in tools and the execution environment, the persistent memory and convention-file mechanisms, model integration, the relationship between the headless and TUI entry points, trace and status output, and the relationship between `yuyao` and the internal kernel.
91
+ - Documentation must match the actual implementation, and likewise must show only `yuyao` in user-visible places.
92
+
93
+ ### 0.6 Interface
94
+
95
+ - **Progress bars**: display a progress bar for long tasks, multi-step execution, installation, and batch processing (use a determinate progress bar when the total is known).
96
+ - **Loading animations**: display an animation with status text wherever the wait is of indeterminate length, such as awaiting a model response or executing a tool.
97
+ - **Streaming animation**: during streaming output (§5.5), render character by character or with a fade-in, plus a cursor animation; the thinking process may be presented collapsed (§5.5).
98
+ - **Overall look and feel**: clear sectioning and alignment, sensible colours and highlighting, visual separation of commands, output, thinking, and status, Markdown and code syntax highlighting, and conspicuous visual feedback for success, failure, and warnings; information density should be moderate and must not flood the screen.
99
+ - A mature TUI library (such as `rich`, `textual`, or `prompt_toolkit`) is recommended; the corresponding dependencies must be declared in `pyproject.toml` or `requirements.txt`.
100
+
101
+ ### 0.7 Pre-delivery Self-verification
102
+
103
+ Before submission, a real install-and-run pass must be performed in a clean environment: install with `install.sh`, start the `yuyao` interactive interface using the environment variables of §0.2 and complete one task against the real model, and run headless mode through to completion with `run_agent.sh` on a toy repository.
104
+
105
+ All functionality must be genuinely implemented; no placeholders, stubs, or unimplemented branches may remain.
106
+
107
+ ---
108
+
109
+ ## 1. Built-in Tools (Actions the Agent May Invoke While Solving a Task)
110
+
111
+ | Tool | Meaning |
112
+ |---|---|
113
+ | shell / bash | Execute shell commands (long tasks may run in the foreground or background), producing filesystem and output effects |
114
+ | read / write / edit / multi-edit | Read / write / replace exactly / edit in bulk; the targeted content lands on disk as expected and nothing else changes |
115
+ | apply-patch | Apply a patch |
116
+ | grep / glob | ripgrep content search / glob-based file lookup |
117
+ | web-fetch / web-search | Fetch a URL / search the web (subject to `--network`) |
118
+ | browser | Browser automation (open, click, extract data, screenshot), used to verify web changes |
119
+ | read-media (image / multimodal reading) | Read and understand multimodal files such as images, screenshots, diagrams, design mockups, architecture diagrams, and screen recordings, optionally as task input; the agent must be able to describe image content and act on the information it contains |
120
+ | lsp | Go to definition / find references / diagnostics; type errors and warnings are reported automatically after each edit |
121
+ | notebook-edit | Edit a Jupyter notebook by cell (replace / insert / delete); the target cell changes as expected and other cells are untouched |
122
+ | monitor | Run a command in the background and stream each output line back in real time (tailing logs, polling CI or PR status, watching a directory for changes) without blocking the session; when an event occurs, the agent must be able to notice it mid-flight and react |
123
+ | todo / task-list | Maintain a task list with status and dependencies (pending / in_progress / completed; create, query, update, delete); it survives context compaction |
124
+ | task (sub-agent) | Spawn (mostly read-only) sub-agents to explore, with sub-task results returned (for background shell processes see bg-*) |
125
+ | bg-list / bg-output / bg-stop | Manage background shell processes (distinct from task sub-agents): list / inspect output / stop |
126
+ | memory-search | Semantic or hybrid search over memory, matching relevant historical notes even under different wording |
127
+ | memory-get | Read a given memory file or line range |
128
+ | ask-user | Ask a structured question (interactive mode), pausing for the user's answer |
129
+
130
+ > Reference syntax `@<path|symbol|agent>`: reference a file, symbol, or sub-agent in a prompt as context.
131
+
132
+ ### 1.1 Tool Behaviour Contracts
133
+ | Tool | Required semantics |
134
+ |---|---|
135
+ | **read** | Images are understood as visual content (large images are downscaled automatically); PDFs can be read by page range; `.ipynb` returns each cell with its outputs; oversized files are returned paginated with a hint on how to continue with offset/limit; malformed input must fail closed — report a clean error, without crashing, looping forever, returning an inverted range, or returning empty content that fakes truncation |
136
+ | **edit** | Read before write: the file must have been read in this session before being modified, and must not have been changed externally on disk; `old_string` must match exactly and uniquely, otherwise extend the context to pin down a unique occurrence or use `replace_all`; no regular-expression or fuzzy matching |
137
+ | **multi-edit** | Multiple edits within a single tool call form one atomic operation: every hunk is first validated against the current on-disk content, and if any one fails to match, the whole call is abandoned with nothing written, leaving no intermediate state in which only the leading hunks were applied |
138
+ | **write** | An existing file must have been read before it is overwritten (new files are exempt); the write replaces the whole file rather than appending or merging; malformed input must fail closed and must not silently corrupt the content of an existing file |
139
+ | **bash** | Each command runs in its own process; a default timeout must exist, and a single command may request a longer limit when needed; output beyond the limit is spilled to a file, with the path and a preview returned; long tasks may run in the background; `cd` persists for subsequent commands within the project directory and is reset to the project root automatically when it escapes |
140
+ | **grep** | ripgrep syntax; three output modes `files_with_matches`/`content`/`count`; results can be restricted by glob or type and can span lines with `multiline`; `.gitignore` is honoured by default |
141
+ | **glob** | Results are sorted by modification time; the number of matches must be capped, and when the cap is exceeded only the results within it are returned, together with a truncation indicator |
142
+
143
+ > **Byte fidelity of changes**: the phrase "nothing else changes" for the editing tools above extends to the byte level — outside the matched region,
144
+ > line-ending sequences and byte encoding must remain byte-for-byte identical to the pre-edit content. Newly created files are exempt.
145
+
146
+ > **Multiple tool calls within one turn**: when the model issues several tool calls in a single reply,
147
+ > they must be executed one by one in the order given; each must really run and each must have a corresponding result fed back.
148
+ > Concurrent execution is not forbidden, but the observable effect on any given target must match sequential execution (e.g. a write followed by a delete ⇒ the final state is deleted).
149
+ > If one of them fails, the remaining calls must still each execute and each return their own result.
150
+
151
+ ---
152
+
153
+ ## 2. Top-level Commands / Sub-commands
154
+
155
+ | Invocation | Meaning |
156
+ |---|---|
157
+ | `agent` | Interactive session (REPL), accepting the slash commands of §5 |
158
+ | `agent -p "<task>"` (`--print`) | Run headless to termination, print the result to stdout, and exit per §9; never wait for input |
159
+ | `agent memory <status\|search\|index\|rem-backfill>` | Memory indexing, search, rebuild, and historical replay (see §6) |
160
+ | `agent mcp <add\|list\|remove>` | Manage MCP external tool connections; tools appear or disappear accordingly after add, remove, and list |
161
+ | `agent sandbox <list\|recreate\|explain>` | Sandbox runtime management and troubleshooting (see §3.3); `explain` states why something was blocked |
162
+ | `agent agents <list\|dispatch\|attach\|stop>` | Agent View: dispatch and monitor background sessions (each in its own git worktree), listing background sessions and their status on one screen, including which are awaiting input, with the ability to attach to or stop them |
163
+ | `agent features <list\|enable\|disable>` | Feature switches (hooks / skills / plugins / MCP) |
164
+ | `agent config <get\|set\|unset> <path> [val]` | Read and write runtime configuration with hot reload; a key change takes effect as soon as it validates, without a restart |
165
+
166
+ ---
167
+
168
+ ## 3. Permission Modes (Five Mutually Exclusive Levels) + Role Modes (Unified `--role`) + Sandbox / Network / Lists
169
+
170
+ ### 3.1 Permission Modes (Five Mutually Exclusive Levels)
171
+ `--mode <name>`, where `name ∈ {ask, plan, auto-edit, auto-review, yolo}`; convenience aliases are also provided.
172
+
173
+ | Mode | Canonical form | Alias | Meaning |
174
+ |---|---|---|---|
175
+ | Ask (default) | `--mode ask` | (omitted) | Every mutating operation is confirmed individually; when no one is present to confirm in headless mode, mutating operations are refused |
176
+ | Plan | `--mode plan` | `--plan` | Read-only: no file changes, no mutating commands |
177
+ | Auto-edit | `--mode auto-edit` | `--auto-edit` | File edits are approved automatically; mutating shell commands still require approval |
178
+ | Auto with classifier review | `--mode auto-review` | `--auto-review` | Fully automatic plus a secondary classifier reviewing each action, blocking dangerous ones (fail-closed). Distinct from `auto-edit`, which only waives approval for edits |
179
+ | Full permissions | `--mode yolo` | `--yolo` | Full permissions, all approvals skipped; both files and commands are executed automatically |
180
+
181
+ - Compatibility aliases (semantics must be identical, §8): `--dangerously-skip-permissions` ≡ `--yes` ≡ `-y` ≡ `--yolo`.
182
+
183
+ ### 3.2 Role Modes (Unified `--role <name>`, Orthogonal to Permission Modes; One Role at a Time)
184
+ `--role <name>`, where `name ∈ {execute, ask, architect, debug, orchestrator}`; `ask` and `debug` additionally have the in-session convenience aliases `/ask` and `/debug`.
185
+
186
+ | Role | Canonical form | Alias | Meaning |
187
+ |---|---|---|---|
188
+ | Execute (default) | `--role execute` | (omitted) | Carry out coding tasks normally: change code and run commands to solve the problem |
189
+ | Ask | `--role ask` | `/ask` | Answer without changing anything: explanation and Q&A, with zero modifications to the workspace |
190
+ | Architect | `--role architect` | — | A strong model produces the plan and an editing model lands the diff: plan first, then write to disk |
191
+ | Debug | `--role debug` | `/debug` | Focus on locating defects, adding diagnostics and a minimal reproduction |
192
+ | Orchestrator | `--role orchestrator [--team-name <n>]` | — | Coordinate the division of labour across multiple sub-agents (lead + teammates: a shared task list plus messages between them, with the lead splitting, assigning, and synchronizing work) |
193
+
194
+ ### 3.3 Sandbox / Network / Lists (Security Switches, Orthogonal to Modes and Roles)
195
+ | Flag / setting | Meaning |
196
+ |---|---|
197
+ | `--sandbox <read-only\|workspace-write\|full-access>` | OS-level isolation level; out-of-bounds writes and privilege escalation are blocked at the restricted levels |
198
+ | `--network <on\|off>` (default off) | Whether network access is allowed; when off, network actions are refused |
199
+ | `--allow <tool/glob>` / `--deny <tool/glob>` | Allowlist and denylist for tools and paths |
200
+
201
+ > To troubleshoot "why was this tool blocked", use `agent sandbox explain` (§2); no separate flag is provided.
202
+
203
+ > **Matching criterion for deny and allow**: a rule such as `Bash(<glob>)` matches the command's **effective program name**
204
+ > — that is, the program that will actually be executed, determined after shell lexical analysis, after removing quotes and escapes, after stripping wrappers (`sh -c`/`command`/`env`/`xargs`/`exec`/
205
+ > `nice`/`timeout`/`nohup`/`stdbuf`, and the like) and path prefixes.
206
+ > Quote-split words (`to""uch`), backslashes, redundant whitespace, subshells, command substitution,
207
+ > and forms such as `find -exec` that place a command in an argument position do not change the effective program name and match all the same.
208
+ > The converse also holds: a command that merely mentions a denied string without executing it
209
+ > (such as `grep "rm " f.txt` or `echo rm`) is permitted.
210
+
211
+ > **Segment-by-segment adjudication**: a command line may consist of several segments — `;`, `&&`, `||`, pipes, subshells, and command substitution
212
+ > each introduce a segment of executable content, and each segment has its own effective program name. Adjudication applies to **every one of those segments**,
213
+ > and the two directions compose differently: deny and ask are decided by a single veto — if any segment matches, the whole command line is blocked or turned into a confirmation,
214
+ > and wrapping a refused program inside a compound command does not constitute a bypass; allow requires unanimity — only if every segment is permitted is the whole command line exempt from confirmation,
215
+ > and a single allow rule matching one segment does not permit the whole line.
216
+
217
+ > **Undetermined means not permitted**: when the effective program name cannot be determined — unbalanced quotes, failed word splitting, structures beyond the implementation's understanding,
218
+ > or any situation in which the implementation can only guess rather than compute — the command must be treated as not permitted: in interactive mode it becomes an individual confirmation,
219
+ > and in unattended mode mutating operations are refused per §3.1. Indeterminacy must not result in permission, nor may the implementation degrade to an approximation such as splitting on whitespace.
220
+
221
+ > **Data exfiltration (strong invariant)**: only content that the user has explicitly referenced through `@<path>` (§5.4) or that the agent has itself read with tools such as read or grep may enter the context and the request body; merely mentioning a file name in free text (casually saying `~/.ssh/id_rsa` or `.env`, say) must not trigger an automatic read that wires its content into any model request. The contents of sensitive files such as private keys, credentials, and `.env` must never be collected automatically or transmitted without having been named.
222
+
223
+ ---
224
+
225
+ ## 4. Global Flags
226
+
227
+ | Flag | Meaning |
228
+ |---|---|
229
+ | `--output-format <text\|json>` / `--json` | Output format; with json, stdout is a single parseable JSON document |
230
+ | `--json-schema <file>` | Produce a structured result per the schema; the output must conform to that schema |
231
+ | `--stream <on\|off>` (default on) | Whether output is streamed; for presentation requirements see §5.5 |
232
+ | `--show-thinking <off\|collapsed\|expanded>` (default collapsed) | Whether the model's thinking is displayed. collapsed folds it into a summary that can be expanded; expanded shows it directly; off hides it. Thinking and the final answer are visually separated |
233
+ | `-c`/`--continue` \| `--resume <id>` | Continue the most recent \| a specified session (mutually exclusive), restoring the context to carry on |
234
+ | `--no-memory` | Do not load memory or convention files for this run (§6/§7); constraints declared by the repository are not honoured |
235
+ | `--max-steps <n>` | Upper bound on run steps; on reaching it, stop cleanly and record `LimitsExceeded` without crashing |
236
+ | `--thinking <off\|low\|medium\|high\|max>` | Thinking intensity, switching the reasoning budget. The level set is defined here and shared by `/think` |
237
+ | `--auto-commit` | Commit to git automatically after each edit (with a descriptive message); each change produces one commit |
238
+ | `--auto-test` / `--test-cmd <cmd>` | Run tests automatically after editing and iterate on the results; if tests fail, keep fixing until they pass |
239
+ | `--map-tokens <n>` | Repo map injection budget; for a large repository, inject the most relevant symbols; `0` means no repo map is injected |
240
+ | `--experimental-lsp` | Enable LSP code intelligence (= the lsp tool of §1) |
241
+ | `--model <name>` | Select the model |
242
+ | `--tools <list>` \| `--allowed-tools <rules>` \| `--disallowed-tools <rules>` | Restrict the available tool set \| tools permitted without confirmation \| tools refused. Rules take forms such as `Bash(git log *)` and `Edit(/src/**)` |
243
+ | `--worktree[=<name>]` (`-w`) | Start in an isolated git worktree (created automatically or named); changes occur in the isolated checkout and never touch the main working tree |
244
+ | `--bg [task]` (+`--exec <cmd>`) | Start as a background session and return immediately, printing the session ID and releasing the terminal; with `--exec`, run a shell job in the background instead |
245
+ | `--fork-session` | On resume, create a new session ID; the original session is preserved and a new one is forked from it |
246
+ | `--max-budget-usd <n>` | Spend ceiling (headless); once cumulative spend reaches it, stop cleanly |
247
+ | `--system-prompt <txt>` \| `--system-prompt-file <f>` | Replace the system prompt |
248
+ | `--append-system-prompt <txt>` \| `--append-system-prompt-file <f>` | Append after the default system prompt, preserving the default behaviour |
249
+ | `--input-format <text\|stream-json>` | Headless input format |
250
+ | `--verbose` | Detailed per-turn output, printing the full turn-by-turn process |
251
+ | `--help` | Print the complete invocation surface |
252
+
253
+ ---
254
+
255
+ ## 5. In-session Interaction: Slash Commands and Keyboard Shortcuts
256
+
257
+ ### 5.1 Core Slash Commands
258
+ | Command | Meaning |
259
+ |---|---|
260
+ | `/undo` | Revert the agent's most recent change (the "one step back" special case of `/rewind`); the affected files return to their pre-edit state, and the user's own uncommitted changes are left untouched |
261
+ | `/redo` | Reapply a reverted change. Any new change invalidates what could be redone — if a file was edited or created after `/undo`, `/redo` is a no-op and changes no file |
262
+ | `/rewind` (`/checkpoint`) | Open the checkpoint menu (`Esc Esc` also works on empty input): restore only the code, only the conversation, or both to a historical point, or summarize and compact the conversation from or up to that point. Every user prompt is a checkpoint, retained across sessions. `/undo` is its "one step back" special case. Limitation: only changes made by file-editing tools are tracked — files changed by bash commands (`rm`, `mv`, and so on) are not tracked and cannot be rewound |
263
+ | `/compact` (`/compress`) | Compact or summarize the context; after compaction the original task can still be carried on |
264
+ | `/plan` | Switch to read-only plan mode (= plan in §3.1) |
265
+ | `/ask` | Switch to the answer-only role (= ask in §3.2) |
266
+ | `/debug` | Switch to the debugging role (= debug in §3.2) |
267
+ | `/mode <ask\|plan\|auto-edit\|auto-review\|yolo>` | Switch permission mode in-session (mirrors `--mode`, §3.1) |
268
+ | `/role <execute\|ask\|architect\|debug\|orchestrator>` | Switch role in-session (mirrors `--role`, §3.2) |
269
+ | `/diff` | Show the current changes, listing modified files and their diffs |
270
+ | `/review [--fix] [--security\|--simplify]` | Review the current diff: by default read-only, looking for correctness bugs and cleanup opportunities; `--fix` applies findings to the working tree; `--security` focuses on security (injection, authorization, leaks); `--simplify` performs cleanup and refactoring only |
271
+ | `/security-review` | Review specifically the security risks of the current branch's changes, producing a risk list |
272
+ | `/run` | Build, launch, and drive the project's app, observing at runtime whether a change took effect rather than relying on tests alone |
273
+ | `/copy [N]` | Copy the most recent (or Nth most recent) answer to the clipboard; when it contains code blocks, a block may be selected or written to a file |
274
+ | `/focus` | Toggle the focused view: show only the latest prompt, a summary of tool calls (including diffstat), and the final answer |
275
+ | `/tui <default\|fullscreen>` | Switch the terminal UI renderer (fullscreen being flicker-free full-screen rendering), preserving the session |
276
+ | `/config` (`/settings`) | Open the settings interface: theme, editor mode (including Vim), output style, and so on; settings are visible, editable, and take effect immediately |
277
+ | `/background [prompt]` (`/bg`) | Detach the current session into a background session and release the terminal (optionally with a final instruction), monitorable through Agent View |
278
+ | `/init` | Generate the convention memory file `AGENTS.md` |
279
+ | `/memory` | View and manage cross-session memory (see §6) |
280
+ | `/tools` | List the currently available tools (= introspection over the built-in tools of §1) |
281
+ | `/recap` | Produce a one-line "where we left off" continuation summary for the session |
282
+ | `/context list` | List the size of each part of the context (raw vs injected) |
283
+ | `/context detail` | Inspect context truncation state in detail, reporting truncation and over-budget specifics |
284
+ | `/model <name>` | Switch model, preserving the context |
285
+ | `/new` | Archive the current session and start a new one |
286
+ | `/clear` (`/reset`) | Clear the current session context (without archiving; use `/new` to archive and start fresh) |
287
+ | `/sessions` (`/resume`) | List and restore past sessions |
288
+ | `/title` (`/rename`) | Rename the current session |
289
+ | `/status` | Show version, model, working directory, and current mode |
290
+ | `/export` | Export the current session as Markdown |
291
+ | `/add-dir <path>` | Add another accessible working directory to this session; files beneath it become readable and writable |
292
+ | `/cd <path>` | Change the session's working directory; subsequent operations are based on the new directory |
293
+ | `/permissions` | Manage tool permission rules interactively (allow / ask / deny, = the lists of §3.3) |
294
+ | `/hooks` | View and manage lifecycle hook configuration (= `hooks.json`, §7) |
295
+ | `/mcp` | Manage MCP connections (= the in-session mirror of `agent mcp`, §2) |
296
+ | `/agents` | Manage sub-agent configuration (= task in §1 / orchestrator in §3.2) |
297
+ | `/help` | List all supported commands |
298
+ | `/exit` (`/quit`) | Leave the session; the process ends with exit code 0 |
299
+
300
+ ### 5.2 Advanced
301
+ | Command | Meaning |
302
+ |---|---|
303
+ | `/goal <condition>` | Goal autonomy: once a completion condition is set, keep working and judge attainment independently, until the condition is met or a limit is reached |
304
+ | `/loop <prompt> [--interval <s>] [--max <n>] [--until <cond>]` | Run a fixed prompt in a loop or as a poll within the session. Unlike `/goal` (which judges completion autonomously), `/loop` repeats the same prompt; it stops on the `--until` condition, the `--max` count, or `Esc` |
305
+ | `/fork` | Spawn a background sub-agent (inheriting the current context, returning its result, and not polluting the original). To fork the conversation, use `/branch` |
306
+ | `/branch [name]` | Fork the conversation at the current point and switch into the copy, preserving the original, which remains reachable through `/sessions` |
307
+ | `/btw <question>` (`/side`) | Quick aside: the exchange is not recorded in the main conversation history, so the main history does not grow |
308
+ | `/verify` | Build, run, drive the app, and observe, confirming that the change meets the bar (at runtime, not by tests or type checks alone) |
309
+ | `/batch <instruction>` | Split a large change into independent units, each implemented in parallel by a sub-agent in its own worktree (= the concrete workflow of `--role orchestrator`) |
310
+ | `/workflows` (`/workflow <name>`) | Dynamic workflows: scripted orchestration of many sub-agents that cross-check each other's results, for multi-round tasks such as very large changes, whole-repository audits, and large-scale migrations; lists running and completed workflows with their current stage and each sub-agent's progress, and can run a named workflow |
311
+ | `/skills` \| `/skill <name>` | List skill packages (SKILL.md) \| trigger execution of a named skill |
312
+ | `/flow:<name>` | Execute an embedded skill flow graph, node by node |
313
+ | `/queue <steer\|followup\|collect\|interrupt>` | Queue, steer, or abort with a message mid-stream |
314
+ | `/tasks` (`/bashes`) | View and manage everything running in the background (background shell processes and tasks: list, inspect, stop, in concert with bg-* in §1) |
315
+ | `/think <level>` | Set the thinking level (the same level set as `--thinking`, §4) |
316
+ | `/show-thinking <off\|collapsed\|expanded>` | Switch how thinking is displayed in-session (mirrors `--show-thinking`; distinct from `/think`, which sets the reasoning budget) |
317
+ | `/stream <on\|off>` | Toggle streaming output in-session (mirrors `--stream`) |
318
+ | `/usage <off\|tokens\|full>` | Toggle token and usage display |
319
+
320
+ > **Delineating sub-agents, orchestration, and background execution**:
321
+ > - `task` (the §1 tool) = spawn a read-only sub-agent temporarily during problem solving to explore; `/fork` = spawn a background sub-agent that inherits the context and returns its result.
322
+ > - `--role orchestrator` (the §3.2 role) = adopt the working posture of coordinating multiple sub-agents; `/batch <instruction>` = its concrete workflow (split a large change into units, each in its own worktree, run in parallel).
323
+ > - `/branch` = fork the conversation (not an agent); `/tasks` + `bg-*` = manage background shell processes and tasks (not agents); `/background` (`/bg`) = move the entire current session into the background.
324
+ > - `/agents` (§5.1) = manage sub-agent configuration (does not spawn); `agent agents` (§2, Agent View) = dispatch and monitor background sessions (each with its own worktree), as distinct from `/tasks`, which manages the current session's background items.
325
+ > - `/loop` = loop or poll on a prompt within one session (does not spawn agents); `/workflows` = scripted orchestration of many sub-agents with cross-checking (larger in scale and multi-round compared with `/batch`).
326
+ > - Parallel work is isolated with git worktrees (§7), preventing multiple agents from editing the same file.
327
+
328
+ ### 5.3 Keyboard Shortcuts (Interactive Mode)
329
+ | Shortcut | Action |
330
+ |---|---|
331
+ | `Enter` | Submit the input; the current input is submitted as one turn |
332
+ | `Shift+Enter` / `Ctrl+J` | Insert a newline in the input; multi-line input is not submitted |
333
+ | `Shift+Tab` | Toggle between plan (read-only) and non-plan (= plan in §3.1) |
334
+ | `Ctrl+G` | Invoke `$EDITOR` to edit the input in an external editor |
335
+ | `Ctrl+V` | Paste an image or media file into this turn's context (in concert with read-media, §1) |
336
+ | `Ctrl+S` | Steer the running turn, injecting a mid-flight message into it (= `/queue steer`, §5.2) |
337
+ | `Esc` | Stop or cancel the current run |
338
+ | `Ctrl+C` | Interrupt the run / clear the input |
339
+ | `Ctrl+D` | Exit when the input is empty, with exit code 0 |
340
+ | `Ctrl+O` | Expand or collapse tool output (transcript viewer) |
341
+ | `Ctrl+T` | Expand or collapse the task list view |
342
+ | `Alt+T` | Toggle thinking display (= `/show-thinking`, collapsed ↔ expanded) |
343
+ | `Ctrl+E` | Expand or collapse the plan or preview |
344
+ | `Ctrl+R` | Reverse-search the input history, searching interactively and reusing an entry |
345
+ | `Ctrl+B` | Move the running bash command to the background and carry on the conversation |
346
+ | `Ctrl+X Ctrl+K` | Terminate all background sub-agents of this session (press twice to confirm) |
347
+ | `Esc Esc` | Open the rewind checkpoint menu on empty input; with text present, clear the draft and save it to history |
348
+ | `Ctrl+Z` / `Ctrl+Shift+Z` | Undo / redo an input edit |
349
+ | `Ctrl+L` | Clear the screen: clear only the terminal display, leaving the context untouched (as distinct from `/clear`, which clears the context) |
350
+ | `\` + `Enter` | Multi-line input (works in any terminal); does not submit but moves to the next line |
351
+
352
+ ### 5.4 Input Prefixes (`/` `@` `!`)
353
+ | Prefix | Meaning |
354
+ |---|---|
355
+ | `/<command>` | Slash command (§5.1/§5.2), recognized only at the start of a message |
356
+ | `@<path\|symbol\|agent>` | Reference injection: a file, a directory (recursively), a symbol, or a sub-agent as context |
357
+ | `!<shell command>` | The user executes a shell command directly (as distinct from the agent's bash tool); the command runs in a subshell and its output is echoed; a bare `!` toggles shell mode |
358
+
359
+ ### 5.5 Thinking Display / Streaming Presentation / Image Reading
360
+ | Capability | Meaning |
361
+ |---|---|
362
+ | Thinking is visible and collapsible | The agent's thinking is presented according to the `--show-thinking`/`/show-thinking`/`Alt+T` setting: `collapsed` folds it by default into a one-line summary expandable with a single key; `expanded` shows it directly; `off` hides it. Thinking, the final answer, and tool calls are visually separated and never conflated |
363
+ | Streaming output plus animation | `--stream on` (the default): model output is rendered incrementally token by token in real time, accompanied by a streaming animation; a stream can be aborted with `Esc` and steered with `Ctrl+S` or `/queue steer` |
364
+ | Conversation is not an unbounded agentic loop | Ordinary conversation and questions (greetings, queries) should receive a fast streaming answer; only an explicit coding task enters the multi-step "think → tool → observe" loop, with every step's action and output visible in real time |
365
+ | Non-streaming output | `--stream off`: the whole passage is emitted at once after generation completes, with no character-by-character animation, suiting pipes, logs, and TTY-less environments |
366
+ | Images as input | Images may be supplied through `@<image path>`, a `Ctrl+V` paste, or headless input, letting the agent understand screenshots, error images, design mockups, and architecture diagrams and solve the task from them; the TUI must show a visible indicator for each image taken in |
367
+
368
+ ### 5.6 Vim Editing Mode (Input Box)
369
+ Enabled through `/config` → editor mode; the input box then supports vim-style editing:
370
+ - **Modes**: NORMAL / INSERT / VISUAL (`Esc` enters NORMAL, `i/I/a/A/o/O` enter INSERT, `v/V` enter VISUAL).
371
+ - **Motion**: `h/j/k/l`, `w/e/b`, `0/$/^`, `gg/G`, `f/F/t/T` plus `;`/`,`.
372
+ - **Editing**: `x`, `dd/D`, `dw/de/db`, `cc/C/cw`, `yy/yw`, `p/P`, `>>/<<`, `J`, `u`, `.` (repeat).
373
+ - **Text objects**: `iw/aw`, `i"/a"`, `i(/a(`, `i[/a[`, `i{/a{` in combination with `d/c/y`.
374
+ - Once enabled, the input box responds with the vim semantics above; when disabled, it performs ordinary line editing.
375
+
376
+ ### 5.7 Interaction Enhancements
377
+ | Capability | Meaning |
378
+ |---|---|
379
+ | Command history and reverse search | Input history is saved per working directory; `↑/↓` browses it and `Ctrl+R` reverse-searches and reuses an entry; consecutive identical submissions are recorded once |
380
+ | Suggestions | After a turn, show a greyed-out next-step suggestion in the input box (predicted from the session and history); `Tab`/`→` accepts it and typing dismisses it |
381
+ | Session continuation summary | On returning after a while, show a one-line "where we left off" summary; `/recap` generates one on demand |
382
+ | PR status bar | When the current branch has an open PR, the footer shows a clickable PR link with a colour-coded state (passing, awaiting review, changes requested, draft), refreshed periodically |
383
+ | Focused and full-screen rendering | `/focus` for a condensed view, `/tui fullscreen` for flicker-free full-screen rendering (see §5.1) |
384
+
385
+ ---
386
+
387
+ ## 6. Persistent Memory System
388
+
389
+ > Memory = plain-text files in the workspace + search tools + automatic maintenance. Once written to persistent memory, content must land on disk
390
+ > (location and format are yours to choose) and must remain readable back, or recallable through `memory-search`, after `/new`, `/clear`, and in new sessions
391
+ > (`--no-memory` excepted).
392
+
393
+ ### 6.1 Memory Files
394
+ | File | Purpose | Loading / indexing rule |
395
+ |---|---|---|
396
+ | `MEMORY.md` | Long-term memory (distilled facts, preferences, decisions) | Loaded automatically at the start of every session; when it exceeds the bootstrap budget, the on-disk copy stays complete and the injected copy is truncated |
397
+ | `memory/YYYY-MM-DD.md` | Daily working memory (run context, notes) | Today's and yesterday's are loaded automatically; all are indexed by the search tools rather than injected every turn |
398
+ | `DREAMS.md` | Consolidation and review journal (output of dreaming) | For human review; written by the consolidation process |
399
+
400
+ ### 6.2 External Invocation of Memory
401
+ | Invocation | Meaning |
402
+ |---|---|
403
+ | Natural language "Remember that …" | Triggers an automatic write, into `MEMORY.md` or the day's `memory/*.md` |
404
+ | `/remember <text>` | Explicitly write one persistent memory entry into `MEMORY.md` |
405
+ | `/forget <query>` | Delete matching automatic memory entries. Matching is per entry: only the entry corresponding to the query is removed and every other entry is preserved individually; other entries whose body contains the same substring are not deleted along with it (forgetting `alpha`, for instance, does not affect another entry reading `alphabet …`). Case sensitivity and support for fuzzy matching are left to the implementation |
406
+ | `/dream` | Trigger memory consolidation manually (the manual form of dreaming, §6.3), promoting qualifying short-term signals into `MEMORY.md` |
407
+ | Tool `memory-search "<q>"` / `agent memory search` | Semantic or hybrid search, matching relevant historical notes even under different wording |
408
+ | Tool `memory-get <file[:lines]>` | Read the specified memory content |
409
+ | `agent memory status` | Print index readiness and the provider |
410
+ | `agent memory index --force` | Rebuild the index |
411
+ | `agent memory rem-backfill [--rollback]` | Replay historical notes: stage promotion candidates, with the option to roll back and remove them |
412
+ | `/context list` · `/context detail` | Inspect raw and injected sizes and truncation state |
413
+ | Editing `MEMORY.md`/`memory/*.md`/`DREAMS.md` directly | Edit memory by hand; the corresponding memory changes immediately |
414
+
415
+ ### 6.3 Automatic Maintenance
416
+ - **Automatic memory-flush before compaction (on by default)**: when the context is about to fill up, run a silent turn before compaction to persist important information into memory files, so that old facts remain recallable afterwards.
417
+ - **Distillation**: promote useful content from daily notes into `MEMORY.md` and delete stale entries.
418
+ - **Dreaming (off by default, may be enabled by the user)**: periodic background consolidation that promotes only qualifying short-term signals into `MEMORY.md` per thresholds (score, recall frequency, query diversity), writing stage summaries to `DREAMS.md`.
419
+
420
+ ### 6.4 Memory-related Configuration Keys
421
+ `memorySearch.provider` (embedding provider, trading off search quality) / `compaction.memoryFlush.model` (pin the flush turn to a specified or local model) / the memory backend is selectable (built-in / local sidecar / cross-session memory service, and so on).
422
+
423
+ ---
424
+
425
+ ## 7. Convention Files
426
+
427
+ | File / directory | Purpose |
428
+ |---|---|
429
+ | `.trajectory/` | Execution trace (mandatory): every run records its complete trace to `.trajectory/` (one per run), logging each step's action (tool call, command, edit) with its input and result. The format is the agent's own choice (plain text, JSONL, or split across files). Location: interactive mode writes to `<cwd>/.trajectory/` under the current working directory; headless mode writes to `<out-dir>/.trajectory/`, outside the repository being modified, so as not to pollute the patch |
430
+ | `AGENTS.md` (falling back to `CLAUDE.md`) | Operating instructions and memory conventions, read and honoured automatically; verifiable constraints written there are honoured, except under `--no-memory` |
431
+ | `MEMORY.md` / `memory/*.md` / `DREAMS.md` | Memory files, see §6 |
432
+ | `.plans/` | Editable plans produced by plan mode; after planning, a plan file appears that may be edited and then executed |
433
+ | `hooks.json` | Lifecycle hooks (able to intercept before and after execution); quality gates such as "tests or lint must pass before completion" can be configured. If `beforeShellExecution` returns deny, the command does not run; if a quality gate fails, the run is not allowed to finish |
434
+ | `plugins/<name>/plugin.json` | Plugins: declare a group of extensions that can be enabled or disabled as a whole (which may include custom commands, skills, and hooks). After `agent features disable plugins`, none of the extensions they declare takes effect |
435
+ | `SKILL.md` (`skills/<name>/`) | Trigger-based skill packages (agentskills standard): a trigger keyword loads and executes the skill |
436
+ | Custom commands (`commands/<name>.md`) | User-defined slash commands: Markdown plus YAML frontmatter, supporting `{{args}}` parameters, `@{file}` injection, and `!{cmd}` dynamic injection; subdirectories map to `:` namespaces (`/git:commit`). Dropping in the file makes `/<name>` available |
437
+ | `agents/<name>.md` (custom sub-agents) | Define reusable specialized sub-agents: constrain their role and available tool set. Dropping in the definition makes it invocable by name through `/agents` or `task`, running under the declared tool restrictions |
438
+ | git worktree (parallel isolation) | Parallel sub-agents and background sessions each use their own git worktree, so they never touch the same file |
439
+ | Rule files (glob-conditioned rules) | Rule injection triggered by path or condition; when a path matches, the rule takes effect |
440
+ | Permission list configuration (allow/deny) | Tools and paths permitted or refused by default |
441
+ | MCP configuration | Declare external MCP servers; once configured, additional tools appear |
442
+
443
+ ---
444
+
445
+ ## 8. Consistency Rules
446
+
447
+ > The following rules constrain the relationships between the features already listed in the preceding sections; their effect must land on an externally observable surface.
448
+ > "External" means one of: the request sent to the model, files on disk, the process exit code, or the command's own output — any one of the four suffices.
449
+ > The implementation is not constrained: no particular function need be exposed, and no wording, layout, or field name is prescribed for any output.
450
+
451
+ 1. **Aliases and shortcuts are synonymous triggers**: every convenience alias (`--plan`/`--auto`/`--yolo`/`/ask`/`/debug`/`--dangerously-skip-permissions`/`--yes`/`-y`, and so on) and every keyboard shortcut (such as `Ctrl+S` = `/queue steer`, `Shift+Tab` = toggle plan, `Esc` = abort, `Alt+T` = toggle thinking display, `Ctrl+T` = toggle the task list, `Esc Esc` = rewind) must behave exactly as its canonical long form and must not introduce new semantics.
452
+
453
+ 2. **In-session switches mirror the startup flags**: the semantics of switching with `/mode`, `/role`, `/stream`, and `/show-thinking` (and the aliases `/plan`/`/ask`/`/debug`) in-session must be identical to those of the corresponding startup flags; the switch takes effect immediately and is subject to the same constraints as the startup flag.
454
+
455
+ 3. **The current mode must be discernible in the request**: after a permission mode or role mode switch, the request sent to the model must itself reveal which level is in force.
456
+
457
+ 4. **Relationship of the three axes**: permission modes, role modes, and the security switches form three orthogonal axes that may be combined freely; conflicting combinations (such as `--role ask` together with a demand to modify files) resolve in favour of read-only. `yolo` only stops prompting for approval; it remains bound by `AGENTS.md` and by `--sandbox`/`--network`/`--deny`.
458
+
459
+ 5. **Thinking budget ⟂ thinking display**: `--thinking`/`/think` adjust the reasoning budget and intensity; `--show-thinking`/`/show-thinking`/`Alt+T` adjust whether thinking is displayed — the two are independent and must not override each other.
460
+
461
+ 6. **Unknown invocations must fail explicitly**: an unknown flag or slash command → an explicit error (headless exit code 2; a message in interactive mode).
462
+
463
+ 7. **Accepted means effective and readable back**: if a configuration write is accepted (no error reported), the new value must be retrievable through the corresponding read command. Refusing an unrecognized configuration key is legitimate (an explicit error suffices); an accepted write, however, must not read back as the old value or the default.
464
+
465
+ 8. **External tool connections: both surfaces must support add and remove, and listing must reflect the change**. The command-line sub-commands of §2 and the in-session commands of §5 must both support the three actions register, remove, and list. After an add or remove on either surface, the listing on that same surface must reflect the change. The argument form is yours to choose.
466
+
467
+ 9. **Requests sent to the model must always be well-formed**: every request sent to the model must satisfy — exactly one system prompt, placed first; no two adjacent messages with the same role; no tool call separated from its response; no empty content block and no empty tool result; and no illegal bytes (nulls, lone surrogates, and the like). This constraint applies to all requests, without exception.
468
+
469
+ ---
470
+
471
+ ## 9. Exit Codes (Closed Set, Mandatory for Headless Mode)
472
+ `0` clean termination (`Submitted` completed / `LimitsExceeded` limit reached); `1` runtime error; `2` usage error (unknown or conflicting flag, unknown sub-command or sub-action, missing argument).
473
+ - Self-reported status: headless mode writes `status.json` under `--out-dir` (`exit_status`: `Submitted`/`LimitsExceeded` correspond to exit code 0, errors to 1; including cumulative spend `cost_usd`, with unit prices per §0.3) plus `.trajectory/` (the trace, format of your choosing, see §7).
474
+ - **`Submitted` must be earned**: only genuine completion of the task (with an actual result or tool effect) may be recorded as `Submitted`; when the model returns empty content, a degenerate response, or takes no real action, `Submitted` must not be recorded and `LimitsExceeded` or an error state must be recorded instead.