amness 0.0.0-stage → 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (233) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +212 -2
  3. package/dist/cli/acpcli.d.ts +7 -0
  4. package/dist/cli/acpcli.js +14 -0
  5. package/dist/cli/amness.d.ts +2 -0
  6. package/dist/cli/amness.js +693 -0
  7. package/dist/cli/benchcli.d.ts +5 -0
  8. package/dist/cli/benchcli.js +160 -0
  9. package/dist/cli/config.d.ts +79 -0
  10. package/dist/cli/config.js +54 -0
  11. package/dist/cli/demo.d.ts +13 -0
  12. package/dist/cli/demo.js +44 -0
  13. package/dist/cli/detect.d.ts +2 -0
  14. package/dist/cli/detect.js +20 -0
  15. package/dist/cli/evalcli.d.ts +15 -0
  16. package/dist/cli/evalcli.js +198 -0
  17. package/dist/cli/format.d.ts +5 -0
  18. package/dist/cli/format.js +55 -0
  19. package/dist/cli/headless.d.ts +2 -0
  20. package/dist/cli/headless.js +169 -0
  21. package/dist/cli/model.d.ts +11 -0
  22. package/dist/cli/model.js +19 -0
  23. package/dist/cli/plugincli.d.ts +2 -0
  24. package/dist/cli/plugincli.js +176 -0
  25. package/dist/cli/schedulecli.d.ts +2 -0
  26. package/dist/cli/schedulecli.js +66 -0
  27. package/dist/cli/state.d.ts +11 -0
  28. package/dist/cli/state.js +19 -0
  29. package/dist/cli/tui/ansi.d.ts +38 -0
  30. package/dist/cli/tui/ansi.js +142 -0
  31. package/dist/cli/tui/app.d.ts +328 -0
  32. package/dist/cli/tui/app.js +1358 -0
  33. package/dist/cli/tui/blocks.d.ts +151 -0
  34. package/dist/cli/tui/blocks.js +128 -0
  35. package/dist/cli/tui/brand.d.ts +9 -0
  36. package/dist/cli/tui/brand.js +16 -0
  37. package/dist/cli/tui/canvas.d.ts +92 -0
  38. package/dist/cli/tui/canvas.js +199 -0
  39. package/dist/cli/tui/cards.d.ts +44 -0
  40. package/dist/cli/tui/cards.js +215 -0
  41. package/dist/cli/tui/clipboard.d.ts +5 -0
  42. package/dist/cli/tui/clipboard.js +29 -0
  43. package/dist/cli/tui/commands.d.ts +10 -0
  44. package/dist/cli/tui/commands.js +649 -0
  45. package/dist/cli/tui/complete.d.ts +39 -0
  46. package/dist/cli/tui/complete.js +113 -0
  47. package/dist/cli/tui/custom.d.ts +9 -0
  48. package/dist/cli/tui/custom.js +34 -0
  49. package/dist/cli/tui/diffview.d.ts +25 -0
  50. package/dist/cli/tui/diffview.js +130 -0
  51. package/dist/cli/tui/editor.d.ts +60 -0
  52. package/dist/cli/tui/editor.js +230 -0
  53. package/dist/cli/tui/full.d.ts +86 -0
  54. package/dist/cli/tui/full.js +630 -0
  55. package/dist/cli/tui/keys.d.ts +31 -0
  56. package/dist/cli/tui/keys.js +134 -0
  57. package/dist/cli/tui/markdown.d.ts +37 -0
  58. package/dist/cli/tui/markdown.js +155 -0
  59. package/dist/cli/tui/mentions.d.ts +15 -0
  60. package/dist/cli/tui/mentions.js +48 -0
  61. package/dist/cli/tui/modal.d.ts +26 -0
  62. package/dist/cli/tui/modal.js +107 -0
  63. package/dist/cli/tui/overlays.d.ts +98 -0
  64. package/dist/cli/tui/overlays.js +237 -0
  65. package/dist/cli/tui/pager.d.ts +15 -0
  66. package/dist/cli/tui/pager.js +66 -0
  67. package/dist/cli/tui/pricing.d.ts +9 -0
  68. package/dist/cli/tui/pricing.js +23 -0
  69. package/dist/cli/tui/rich.d.ts +16 -0
  70. package/dist/cli/tui/rich.js +72 -0
  71. package/dist/cli/tui/screen.d.ts +30 -0
  72. package/dist/cli/tui/screen.js +62 -0
  73. package/dist/cli/tui/session.d.ts +77 -0
  74. package/dist/cli/tui/session.js +103 -0
  75. package/dist/cli/tui/sidebar.d.ts +84 -0
  76. package/dist/cli/tui/sidebar.js +114 -0
  77. package/dist/cli/tui/text.d.ts +15 -0
  78. package/dist/cli/tui/text.js +94 -0
  79. package/dist/cli/tui/theme.d.ts +59 -0
  80. package/dist/cli/tui/theme.js +148 -0
  81. package/dist/cli/tui/themes.d.ts +56 -0
  82. package/dist/cli/tui/themes.js +80 -0
  83. package/dist/cli/tui/tokens.d.ts +39 -0
  84. package/dist/cli/tui/tokens.js +71 -0
  85. package/dist/cli/tui/view.d.ts +60 -0
  86. package/dist/cli/tui/view.js +178 -0
  87. package/dist/cli/ui.d.ts +34 -0
  88. package/dist/cli/ui.js +224 -0
  89. package/dist/src/acp.d.ts +28 -0
  90. package/dist/src/acp.js +111 -0
  91. package/dist/src/agents.d.ts +23 -0
  92. package/dist/src/agents.js +71 -0
  93. package/dist/src/anthropic.d.ts +30 -0
  94. package/dist/src/anthropic.js +91 -0
  95. package/dist/src/approver.d.ts +15 -0
  96. package/dist/src/approver.js +40 -0
  97. package/dist/src/bench.d.ts +67 -0
  98. package/dist/src/bench.js +201 -0
  99. package/dist/src/bundle.d.ts +36 -0
  100. package/dist/src/bundle.js +55 -0
  101. package/dist/src/chaos.d.ts +15 -0
  102. package/dist/src/chaos.js +26 -0
  103. package/dist/src/code.d.ts +187 -0
  104. package/dist/src/code.js +590 -0
  105. package/dist/src/codeindex.d.ts +65 -0
  106. package/dist/src/codeindex.js +300 -0
  107. package/dist/src/deep.d.ts +62 -0
  108. package/dist/src/deep.js +177 -0
  109. package/dist/src/diff.d.ts +8 -0
  110. package/dist/src/diff.js +74 -0
  111. package/dist/src/dynamic.d.ts +42 -0
  112. package/dist/src/dynamic.js +133 -0
  113. package/dist/src/embed.d.ts +8 -0
  114. package/dist/src/embed.js +25 -0
  115. package/dist/src/evalcases.d.ts +11 -0
  116. package/dist/src/evalcases.js +196 -0
  117. package/dist/src/evals.d.ts +197 -0
  118. package/dist/src/evals.js +340 -0
  119. package/dist/src/gitflow.d.ts +27 -0
  120. package/dist/src/gitflow.js +56 -0
  121. package/dist/src/grade.d.ts +42 -0
  122. package/dist/src/grade.js +96 -0
  123. package/dist/src/guidance.d.ts +15 -0
  124. package/dist/src/guidance.js +68 -0
  125. package/dist/src/hardcases.d.ts +2 -0
  126. package/dist/src/hardcases.js +94 -0
  127. package/dist/src/harness.d.ts +411 -0
  128. package/dist/src/harness.js +725 -0
  129. package/dist/src/hooks.d.ts +44 -0
  130. package/dist/src/hooks.js +116 -0
  131. package/dist/src/images.d.ts +13 -0
  132. package/dist/src/images.js +27 -0
  133. package/dist/src/index.d.ts +57 -0
  134. package/dist/src/index.js +57 -0
  135. package/dist/src/ledger.d.ts +58 -0
  136. package/dist/src/ledger.js +78 -0
  137. package/dist/src/live.d.ts +16 -0
  138. package/dist/src/live.js +80 -0
  139. package/dist/src/lsp.d.ts +31 -0
  140. package/dist/src/lsp.js +147 -0
  141. package/dist/src/memory.d.ts +128 -0
  142. package/dist/src/memory.js +390 -0
  143. package/dist/src/metrics.d.ts +3 -0
  144. package/dist/src/metrics.js +42 -0
  145. package/dist/src/mining.d.ts +49 -0
  146. package/dist/src/mining.js +126 -0
  147. package/dist/src/openai.d.ts +50 -0
  148. package/dist/src/openai.js +307 -0
  149. package/dist/src/parallel.d.ts +66 -0
  150. package/dist/src/parallel.js +135 -0
  151. package/dist/src/patch.d.ts +45 -0
  152. package/dist/src/patch.js +219 -0
  153. package/dist/src/permissions.d.ts +46 -0
  154. package/dist/src/permissions.js +245 -0
  155. package/dist/src/plugins.d.ts +148 -0
  156. package/dist/src/plugins.js +225 -0
  157. package/dist/src/pluginscan.d.ts +8 -0
  158. package/dist/src/pluginscan.js +20 -0
  159. package/dist/src/procs.d.ts +41 -0
  160. package/dist/src/procs.js +94 -0
  161. package/dist/src/profiles.d.ts +36 -0
  162. package/dist/src/profiles.js +61 -0
  163. package/dist/src/progress.d.ts +29 -0
  164. package/dist/src/progress.js +75 -0
  165. package/dist/src/prompts.d.ts +10 -0
  166. package/dist/src/prompts.js +28 -0
  167. package/dist/src/ratelimit.d.ts +34 -0
  168. package/dist/src/ratelimit.js +116 -0
  169. package/dist/src/replay.d.ts +25 -0
  170. package/dist/src/replay.js +99 -0
  171. package/dist/src/review.d.ts +20 -0
  172. package/dist/src/review.js +49 -0
  173. package/dist/src/route.d.ts +9 -0
  174. package/dist/src/route.js +30 -0
  175. package/dist/src/router.d.ts +61 -0
  176. package/dist/src/router.js +126 -0
  177. package/dist/src/sandbox.d.ts +13 -0
  178. package/dist/src/sandbox.js +68 -0
  179. package/dist/src/schedule.d.ts +20 -0
  180. package/dist/src/schedule.js +59 -0
  181. package/dist/src/schema.d.ts +13 -0
  182. package/dist/src/schema.js +36 -0
  183. package/dist/src/secrets.d.ts +10 -0
  184. package/dist/src/secrets.js +41 -0
  185. package/dist/src/shell.d.ts +34 -0
  186. package/dist/src/shell.js +95 -0
  187. package/dist/src/skills.d.ts +20 -0
  188. package/dist/src/skills.js +112 -0
  189. package/dist/src/snapshot.d.ts +20 -0
  190. package/dist/src/snapshot.js +93 -0
  191. package/dist/src/stats.d.ts +24 -0
  192. package/dist/src/stats.js +62 -0
  193. package/dist/src/strategies.d.ts +16 -0
  194. package/dist/src/strategies.js +35 -0
  195. package/dist/src/suites.d.ts +30 -0
  196. package/dist/src/suites.js +112 -0
  197. package/dist/src/trace.d.ts +63 -0
  198. package/dist/src/trace.js +153 -0
  199. package/dist/src/tune.d.ts +38 -0
  200. package/dist/src/tune.js +49 -0
  201. package/dist/src/web.d.ts +19 -0
  202. package/dist/src/web.js +56 -0
  203. package/dist/src/worktree.d.ts +24 -0
  204. package/dist/src/worktree.js +85 -0
  205. package/docs/agent-loop.md +222 -0
  206. package/docs/architecture.md +228 -0
  207. package/docs/bench.md +293 -0
  208. package/docs/budgets.md +185 -0
  209. package/docs/build-your-own-harness.md +424 -0
  210. package/docs/cookbook.md +375 -0
  211. package/docs/development.md +150 -0
  212. package/docs/evaluation.md +450 -0
  213. package/docs/features.md +1320 -0
  214. package/docs/getting-started.md +196 -0
  215. package/docs/headless.md +183 -0
  216. package/docs/images/approval.png +0 -0
  217. package/docs/images/chat.png +0 -0
  218. package/docs/images/daylight.png +0 -0
  219. package/docs/images/loop.png +0 -0
  220. package/docs/images/palette.png +0 -0
  221. package/docs/images/running.png +0 -0
  222. package/docs/images/subagent-done.png +0 -0
  223. package/docs/images/subagent-running.png +0 -0
  224. package/docs/images/welcome.png +0 -0
  225. package/docs/index.md +25 -0
  226. package/docs/library.md +276 -0
  227. package/docs/plugins.md +691 -0
  228. package/docs/providers.md +175 -0
  229. package/docs/safety.md +237 -0
  230. package/docs/usage.md +348 -0
  231. package/docs/why.md +155 -0
  232. package/docs/writing-guide.md +39 -0
  233. package/package.json +72 -4
@@ -0,0 +1,276 @@
1
+ # Use it as a library
2
+
3
+ This page shows you how to use the Amness agent loop inside your own TypeScript program, without the terminal chat.
4
+
5
+ In this page you will learn:
6
+
7
+ - how to install the library and run a coding agent
8
+ - how to add your own tool and ask for approval
9
+ - how to set a budget, rules, hooks and a sandbox
10
+ - how to run the research agent and an evaluation
11
+
12
+ Everything is exported from `src/index.ts`. The code samples on this page were type-checked against the real types in `src/harness.ts` and `src/code.ts`. They were not run against a live model.
13
+
14
+ ## Install the library
15
+
16
+ **What it is.** Amness runs TypeScript directly with Node.js type stripping. You need Node.js 22.18 or newer.
17
+
18
+ **Why you would use it.** You get the same guards as the chat (argument checks, verify gate, loop guard, budgets) inside a script, a server or a test.
19
+
20
+ **How to use it.** The README says Amness is not on npm yet, and this page could not confirm a release. Use a clone.
21
+
22
+ 1. Clone and build:
23
+
24
+ ```bash
25
+ git clone https://github.com/amirsdream/Amness.git
26
+ cd Amness
27
+ npm install
28
+ npm run build
29
+ npm pack
30
+ ```
31
+
32
+ 2. Install the tarball in your own project:
33
+
34
+ ```bash
35
+ cd ../my-project
36
+ npm install ../Amness/amness-0.1.0.tgz
37
+ ```
38
+
39
+ 3. Or skip the build and import the source from the clone. Node.js can run `.ts` files:
40
+
41
+ ```ts
42
+ import { createCodeAgent, openai } from "../Amness/src/index.ts";
43
+ ```
44
+
45
+ The CI job `package` does steps 1 and 2 and checks that `import("amness")` works.
46
+
47
+ **Limits.** The Claude adapter needs the optional package `@anthropic-ai/sdk` (`npm install @anthropic-ai/sdk`). The OpenAI adapter uses plain `fetch` and has no dependency.
48
+
49
+ ## Run a coding agent
50
+
51
+ **What it is.** `createCodeAgent` gives you an agent with file tools, a shell tool, memory and all guards. It works in one folder (`cwd`).
52
+
53
+ **How to use it.**
54
+
55
+ 1. Create a file `fix.ts`:
56
+
57
+ ```ts
58
+ import { createCodeAgent, openai } from "amness";
59
+
60
+ const agent = createCodeAgent({
61
+ model: openai({ model: "gpt-6.1-sol", effort: "high" }),
62
+ cwd: "./my-repo",
63
+ verify: "npm test", // "done" must be proven by this command
64
+ approve: ({ name, args, reason }) => false, // deny risky calls
65
+ });
66
+
67
+ const result = await agent.run("fix the failing test");
68
+ console.log(result.finished, result.text);
69
+ ```
70
+
71
+ 2. Set your key and run it:
72
+
73
+ ```bash
74
+ export OPENAI_API_KEY=sk-...
75
+ node fix.ts
76
+ ```
77
+
78
+ **Example.** If the tests pass after the fix, you see `true` and the summary the agent wrote. If the agent runs out of steps, you see `false` and a text that starts with `stopped:`.
79
+
80
+ **What `run` returns.** An object with `text`, `finished`, `steps`, `tokens`, `messages` and, when it stopped early, `stopped` (`"budget"`, `"maxSteps"`, `"aborted"`, `"stuck"` or `"blocked"`).
81
+
82
+ **Limits and common problems.**
83
+
84
+ - `approve` is called before every risky tool call. It must return `true`, `false`, or a string. A string is a denial that the agent reads. If you give no `approve`, risky calls are denied.
85
+ - Without `permissions: { mode }`, edits do not ask. Only shell commands on the risk list ask. For the chat behavior, pass `permissions: { mode: () => "default" }`. Modes are `"default"`, `"acceptEdits"`, `"plan"` and `"yolo"`.
86
+ - The default step limit is 40 (60 when `chat: true`). Change it with `maxSteps`.
87
+ - Memory is on by default. It writes to `.amness/memory` in `cwd` and to `~/.amness/memory`. Pass `memory: false` for a clean run.
88
+
89
+ ## Add your own tool
90
+
91
+ **What it is.** A tool is an object made with `defineTool`. The model calls it by name. The `schema` is a JSON schema. Amness validates the arguments before `run` is called.
92
+
93
+ **How to use it.**
94
+
95
+ ```ts
96
+ import { createHarness, defineTool, openai } from "amness";
97
+
98
+ const orders: Record<string, string> = { "42": "shipped" };
99
+
100
+ const lookup = defineTool<{ id: string }>({
101
+ name: "lookup",
102
+ description: "Look up the status of an order",
103
+ schema: { type: "object", required: ["id"], properties: { id: { type: "string" } } },
104
+ run: ({ id }) => orders[id] ?? "unknown order",
105
+ readOnly: true, // changes nothing, so it may run in parallel
106
+ });
107
+
108
+ const h = createHarness({
109
+ model: openai(),
110
+ tools: [lookup],
111
+ verify: () => true,
112
+ onEvent: (e) => console.error(e.kind),
113
+ });
114
+ const r = await h.run("What is the status of order 42?");
115
+ console.log(r.text);
116
+ ```
117
+
118
+ The flags on a tool:
119
+
120
+ | Flag | Meaning |
121
+ |---|---|
122
+ | `readOnly` | Changes nothing. Safe in plan mode and in parallel |
123
+ | `risky` | `true`, or a function that returns `true` or a reason text. The call needs `approve` |
124
+ | `untrusted` | The output comes from outside. It is wrapped as data, and shell commands that copy from it need approval |
125
+ | `deferred` | Hidden until the model finds it with `tool_search`. Good when you have many tools |
126
+ | `when` | Shows the tool only while the function returns `true` |
127
+
128
+ **Limits.** Without `approve`, `createHarness` denies every risky tool call. `createHarness` has no file or shell tools. Use `createCodeAgent` for those, and pass your tools with `tools: [...]`.
129
+
130
+ ## Set a budget, rules, hooks and a sandbox
131
+
132
+ **How to use it.**
133
+
134
+ ```ts
135
+ import { Budget, Hooks, Permissions, createCodeAgent, openai } from "amness";
136
+
137
+ const cwd = "./my-repo";
138
+ const budget = new Budget({ maxTokens: 200_000, maxMs: 10 * 60_000 });
139
+
140
+ const agent = createCodeAgent({
141
+ model: openai(),
142
+ cwd,
143
+ budget,
144
+ sandbox: "workspace", // "off" | "workspace" | "strict"
145
+ rules: new Permissions({ deny: ["sh(git push*)", "edit(.env)"] }, cwd),
146
+ hooks: Hooks.load(cwd, { trustProject: false }), // only your ~/.amness/hooks.json
147
+ check: "npx tsc --noEmit", // runs after each edit
148
+ approve: () => false,
149
+ });
150
+
151
+ const r = await agent.run("add a --verbose flag");
152
+ console.log(r.finished, budget.tokens);
153
+ ```
154
+
155
+ **Limits and common problems.**
156
+
157
+ - `rules` replaces the default. The built-in floor still applies when you pass your own `Permissions`. Passing `rules: false` switches the floor off too.
158
+ - `Hooks.load(cwd, { trustProject: true })` runs the commands in the project's `.amness/hooks.json`. Do this only for code you trust.
159
+ - If you ask for a sandbox that is not available (for example on Windows), shell commands fail with an error. They do not run unprotected.
160
+ - `taint` (`"ask"`, `"deny"` or `"off"`) and `redact` (`true` or `false`) control the text checks. See [Safety and privacy](safety.md).
161
+ - Call `await agent.procs?.dispose()` when you are done, so background processes stop.
162
+
163
+ ## Choose a model
164
+
165
+ A model is a function `(messages, tools, opts) => Promise<Message>`.
166
+
167
+ ```ts
168
+ import { anthropic, openai } from "amness";
169
+
170
+ const gpt = openai({ model: "gpt-6.1-sol" });
171
+ const local = openai({ baseUrl: "http://localhost:11434/v1", model: "qwen2.5-coder:7b" });
172
+ const claude = anthropic({ model: "claude-opus-5-5" }); // needs @anthropic-ai/sdk
173
+ ```
174
+
175
+ To add another provider, write one function that returns a `Message` (`{ role: "assistant", content, tool_calls? }`) and, if you can, `usage`. If the provider gives no token counts, Amness estimates them (about 4 characters per token).
176
+
177
+ ## Continue, stop and resume a run
178
+
179
+ - `checkpointFile: "state.json"` saves the transcript every turn. Later, `agent.run(task, { resume: true })` continues from it.
180
+ - `signal: controller.signal` stops the run at the next safe point.
181
+ - `agent.followUp(result, "now also update the docs")` continues the same conversation.
182
+ - `agent.exportBundle(result, "session.json")` saves a portable session. `agent.run(task, { bundle: "session.json" })` continues it on another machine.
183
+
184
+ ## Get checked JSON from a model
185
+
186
+ `createHarness(...).extract(prompt, schema)` asks for JSON and checks it against a schema. It sends validation errors back and tries up to 3 times. It throws an error if the JSON is still wrong.
187
+
188
+ ```ts
189
+ import { createHarness, openai } from "amness";
190
+
191
+ const h = createHarness({ model: openai() });
192
+ const data = await h.extract<{ name: string; age: number }>(
193
+ "Ada Lovelace was 36 when she died.",
194
+ { type: "object", required: ["name", "age"], properties: { name: { type: "string" }, age: { type: "integer" } } },
195
+ );
196
+ console.log(data.name, data.age);
197
+ ```
198
+
199
+ ## Run the research agent
200
+
201
+ `createDeepAgent` plans, sends work to subagents, searches the web and writes `/report.md`. It rejects a report that cites URLs the agents never saw.
202
+
203
+ ```ts
204
+ import { createDeepAgent, openai } from "amness";
205
+
206
+ const agent = createDeepAgent({
207
+ model: openai(),
208
+ dir: ".amness", // files persist between runs
209
+ });
210
+ const r = await agent.run("Compare two ways to cache HTTP responses in Node.js");
211
+ console.log(r.report ?? r.text);
212
+ ```
213
+
214
+ It uses `TAVILY_API_KEY` for search when set. Otherwise it reads DuckDuckGo's HTML page, which can break. Search queries and page requests leave your machine. See [Safety and privacy](safety.md).
215
+
216
+ ## Attach an MCP server
217
+
218
+ ```ts
219
+ import { createCodeAgent, loadMcp, openai } from "amness";
220
+
221
+ const mcp = await loadMcp("npx", ["-y", "@modelcontextprotocol/server-filesystem", "."]);
222
+ const agent = createCodeAgent({ model: openai(), cwd: ".", tools: mcp.tools, approve: () => false });
223
+ await agent.run("list the files");
224
+ mcp.close();
225
+ ```
226
+
227
+ Tools from the server get the prefix of the command name, then `__`, then the tool name. Tools that the server marks as changing things need approval. The server gets your full environment, and the output is treated as untrusted.
228
+
229
+ ## Compare harness variants
230
+
231
+ `evaluate` runs tasks with different harness settings and gives a table. A `Case` has `files`, a `task`, and a held-out `check` that the agent never sees.
232
+
233
+ ```ts
234
+ import { codeVariants, evaluate, openai, type Case } from "amness";
235
+
236
+ const cases: Case[] = [{
237
+ name: "rename-word",
238
+ files: { "a.txt": "one\n" },
239
+ task: "Change the text in a.txt from 'one' to 'two'.",
240
+ check: (dir) => import("node:fs").then((fs) => fs.readFileSync(`${dir}/a.txt`, "utf8").trim() === "two"),
241
+ }];
242
+
243
+ const { table } = await evaluate(cases, codeVariants(openai()), { trials: 3 });
244
+ console.log(table);
245
+ ```
246
+
247
+ This calls the model many times and costs money. For statistics and ablations, use the command line. See [Evaluating the harness](evaluation.md).
248
+
249
+ ## Examples in the repository
250
+
251
+ | File | What it shows |
252
+ |---|---|
253
+ | `examples/code.ts` | A coding agent with a terminal approval prompt, `--verify`, `--resume`, `--self-extend` and `--mcp` |
254
+ | `examples/research.ts` | The research agent |
255
+ | `examples/eval.ts` | A pass-rate table with `codeVariants` |
256
+ | `examples/cases.ts` | The built-in evaluation cases |
257
+ | `examples/plugins/house-rules.ts` | A plugin with hooks, a tool, a case and variants |
258
+
259
+ Run one with Node.js, for example:
260
+
261
+ ```bash
262
+ OPENAI_API_KEY=sk-... node examples/code.ts ./my-repo "fix the failing test" --verify "npm test"
263
+ ```
264
+
265
+ ## Related pages
266
+
267
+ - [The agent loop](agent-loop.md) for what the loop does each turn
268
+ - [Plugins](plugins.md) for rules you can load without changing code
269
+ - [Safety and privacy](safety.md) for approval, rules and the sandbox
270
+ - [Budgets and subagents](budgets.md) for `Budget`
271
+
272
+ ## Next steps
273
+
274
+ - Try the examples: [Cookbook](cookbook.md)
275
+ - Measure a change: [Evaluating the harness](evaluation.md)
276
+ - Understand the layers: [Architecture](architecture.md)