brass-runtime 1.16.0 → 1.16.1

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 (210) hide show
  1. package/CHANGELOG.md +17 -0
  2. package/README.md +283 -18
  3. package/dist/agent/cli/main.cjs +38 -38
  4. package/dist/agent/cli/main.js +6 -6
  5. package/dist/agent/cli/main.mjs +6 -6
  6. package/dist/agent/index.cjs +7 -7
  7. package/dist/agent/index.d.ts +1 -1
  8. package/dist/agent/index.js +6 -6
  9. package/dist/agent/index.mjs +6 -6
  10. package/dist/chunk-2HQTDLHF.mjs +683 -0
  11. package/dist/chunk-36I3M4UC.mjs +370 -0
  12. package/dist/{chunk-QY5FKYEQ.js → chunk-3AYM6WPJ.js} +570 -51
  13. package/dist/chunk-3LOYJFRR.cjs +300 -0
  14. package/dist/chunk-3Y2RIUMM.js +300 -0
  15. package/dist/{chunk-N6VHMOWB.cjs → chunk-4ROBZFL6.cjs} +128 -128
  16. package/dist/{chunk-NC5SDRYE.js → chunk-52OB2ROS.js} +4 -4
  17. package/dist/{chunk-JX3LZQJH.cjs → chunk-52PPNNI4.cjs} +82 -20
  18. package/dist/{chunk-5YOQOXEQ.cjs → chunk-5EC274J5.cjs} +676 -293
  19. package/dist/chunk-5QC7LRZ3.js +229 -0
  20. package/dist/{chunk-7TL2LHQJ.js → chunk-5VRJNBLZ.mjs} +524 -141
  21. package/dist/chunk-62AZW6UT.cjs +313 -0
  22. package/dist/chunk-6IXXWIUM.js +683 -0
  23. package/dist/chunk-74ZTY6CP.js +2871 -0
  24. package/dist/chunk-76YMRMH2.cjs +777 -0
  25. package/dist/chunk-7CMJS3QE.mjs +2871 -0
  26. package/dist/{chunk-2WC63LJK.mjs → chunk-7JIJOVCT.js} +20 -10
  27. package/dist/{chunk-FM4W4QPL.js → chunk-A2OM6NEH.mjs} +5 -4
  28. package/dist/chunk-AGR5B2BC.cjs +683 -0
  29. package/dist/chunk-AVNQLJ5V.js +777 -0
  30. package/dist/chunk-B33ICAKP.js +313 -0
  31. package/dist/{chunk-J3H54ZRV.mjs → chunk-B5JD23U7.mjs} +1 -1
  32. package/dist/chunk-BABBZK4Y.js +2024 -0
  33. package/dist/{chunk-U5KWK3PX.mjs → chunk-C3MDXTRZ.js} +11 -0
  34. package/dist/{chunk-F5EUMJL7.mjs → chunk-CIZFIMK5.js} +55 -5
  35. package/dist/{chunk-SPUEME2B.cjs → chunk-CZIVE6NT.cjs} +12 -1
  36. package/dist/{chunk-TDVMADDN.js → chunk-DNFJLJMW.mjs} +11 -0
  37. package/dist/chunk-DNFO2EIZ.mjs +777 -0
  38. package/dist/{chunk-XDZOO4L5.js → chunk-EJ6BPYVR.mjs} +79 -17
  39. package/dist/{chunk-JNFRRJYH.cjs → chunk-ENKODRU3.cjs} +242 -192
  40. package/dist/chunk-EOC4UHBS.mjs +229 -0
  41. package/dist/{chunk-7LVI2GIN.js → chunk-FH2X7BVP.js} +507 -72
  42. package/dist/{chunk-OOGJ73B6.js → chunk-FHQGHPMO.mjs} +20 -10
  43. package/dist/{chunk-WQ5QNU5R.cjs → chunk-GLE2WY7Z.cjs} +652 -217
  44. package/dist/{chunk-G6IQOE4P.mjs → chunk-GYM3LLGS.mjs} +507 -72
  45. package/dist/chunk-HLWLMW2F.mjs +2024 -0
  46. package/dist/{chunk-TVN5I4U6.cjs → chunk-JF5WGYJJ.cjs} +25 -24
  47. package/dist/{chunk-CY33PGEX.mjs → chunk-KH4SYAOS.mjs} +570 -51
  48. package/dist/chunk-KN32XNTH.mjs +313 -0
  49. package/dist/chunk-KQLYONSE.cjs +2871 -0
  50. package/dist/{chunk-7HUOJA4W.cjs → chunk-KZJQ723N.cjs} +90 -80
  51. package/dist/{chunk-CCKHV5BT.mjs → chunk-L2SYFEBS.js} +5 -4
  52. package/dist/{chunk-IJT6RRQ5.cjs → chunk-L6VB5N7Q.cjs} +20 -9
  53. package/dist/{chunk-ZGLD4TVZ.mjs → chunk-MBEJI5HF.mjs} +4 -4
  54. package/dist/{chunk-PRWCB3QL.mjs → chunk-MIIYDLGM.js} +524 -141
  55. package/dist/{chunk-H55LI6WY.js → chunk-MOO4L7F4.mjs} +15 -4
  56. package/dist/{chunk-7XOPAB5Q.js → chunk-MT3OWDPC.mjs} +55 -5
  57. package/dist/chunk-MVGUEJ5Z.cjs +370 -0
  58. package/dist/chunk-PD4EJTQC.cjs +229 -0
  59. package/dist/chunk-PWC3RBQE.mjs +300 -0
  60. package/dist/{chunk-MWXMNYJS.cjs → chunk-Q2I37RP3.cjs} +643 -124
  61. package/dist/{chunk-VFIUZG7J.mjs → chunk-RKGKFN2A.js} +79 -17
  62. package/dist/{chunk-NYL4D7SK.cjs → chunk-SA6HUJVI.cjs} +5 -5
  63. package/dist/{chunk-K2T3DV26.mjs → chunk-TRM4JUZQ.js} +15 -4
  64. package/dist/chunk-UB4B6OFY.js +370 -0
  65. package/dist/{chunk-G3XGCZDQ.js → chunk-UCUBNWM2.js} +1 -1
  66. package/dist/chunk-VN44DYYT.cjs +2024 -0
  67. package/dist/{client-CtFmoDvM.d.ts → client-CZHU674n.d.ts} +211 -36
  68. package/dist/core/index.cjs +135 -9
  69. package/dist/core/index.d.ts +238 -33
  70. package/dist/core/index.js +155 -29
  71. package/dist/core/index.mjs +155 -29
  72. package/dist/{effect-CGNl5Rqp.d.ts → effect-DIUHZ9IN.d.ts} +89 -1
  73. package/dist/effectRunner-CFLC32IK.cjs +8 -0
  74. package/dist/{effectRunner-A4CHJXJI.js → effectRunner-L4S7IPT3.js} +2 -2
  75. package/dist/{effectRunner-OPUF6QRN.mjs → effectRunner-NNGG75QA.mjs} +2 -2
  76. package/dist/http/index.cjs +324 -2986
  77. package/dist/http/index.d.ts +54 -68
  78. package/dist/http/index.js +238 -2900
  79. package/dist/http/index.mjs +238 -2900
  80. package/dist/http/testing.cjs +14 -12
  81. package/dist/http/testing.d.ts +5 -4
  82. package/dist/http/testing.js +10 -8
  83. package/dist/http/testing.mjs +10 -8
  84. package/dist/index.cjs +423 -255
  85. package/dist/index.d.ts +87 -69
  86. package/dist/index.js +301 -133
  87. package/dist/index.mjs +301 -133
  88. package/dist/observability/index.cjs +16 -531
  89. package/dist/observability/index.d.ts +81 -8
  90. package/dist/observability/index.js +23 -538
  91. package/dist/observability/index.mjs +23 -538
  92. package/dist/perf/cli.cjs +401 -0
  93. package/dist/perf/cli.d.ts +1 -0
  94. package/dist/perf/cli.js +401 -0
  95. package/dist/perf/cli.mjs +401 -0
  96. package/dist/perf/index.cjs +141 -0
  97. package/dist/perf/index.d.ts +483 -0
  98. package/dist/perf/index.js +141 -0
  99. package/dist/perf/index.mjs +141 -0
  100. package/dist/schedule-CK3Ml_7p.d.ts +259 -0
  101. package/dist/schema/index.cjs +6 -2
  102. package/dist/schema/index.d.ts +3 -1
  103. package/dist/schema/index.js +5 -1
  104. package/dist/schema/index.mjs +5 -1
  105. package/dist/{server-C8hDXA74.d.ts → server-GJPg8ZSG.d.ts} +4 -3
  106. package/dist/{stream-dvSs0QS5.d.ts → stream-B4oK9JFP.d.ts} +1 -1
  107. package/dist/{tracer-B5tRH9H7.d.ts → tracer-Hwt1cl7h.d.ts} +13 -54
  108. package/dist/{tracing-Dt9S_6V8.d.ts → tracing-DqbTKGcf.d.ts} +1 -1
  109. package/docs/ARCHITECTURE.md +292 -0
  110. package/docs/README.md +63 -0
  111. package/docs/adr/0001-ai-context-pack.md +32 -0
  112. package/docs/agent-apply-mode.md +104 -0
  113. package/docs/agent-approvals.md +110 -0
  114. package/docs/agent-batch.md +185 -0
  115. package/docs/agent-boundaries.md +112 -0
  116. package/docs/agent-chat-sessions.md +160 -0
  117. package/docs/agent-ci.md +17 -0
  118. package/docs/agent-cli.md +405 -0
  119. package/docs/agent-config.md +480 -0
  120. package/docs/agent-context-discovery.md +159 -0
  121. package/docs/agent-copilot-like-dx.md +126 -0
  122. package/docs/agent-declarative-optimized-planning.md +138 -0
  123. package/docs/agent-dx.md +224 -0
  124. package/docs/agent-env-files.md +126 -0
  125. package/docs/agent-follow-up-context.md +43 -0
  126. package/docs/agent-global-usage.md +180 -0
  127. package/docs/agent-init.md +109 -0
  128. package/docs/agent-install-and-configure.md +516 -0
  129. package/docs/agent-language-workspace-ux.md +99 -0
  130. package/docs/agent-llm-adapters.md +123 -0
  131. package/docs/agent-local-install.md +190 -0
  132. package/docs/agent-local-tests.md +51 -0
  133. package/docs/agent-observability.md +155 -0
  134. package/docs/agent-patch-quality-loop.md +162 -0
  135. package/docs/agent-presets.md +22 -0
  136. package/docs/agent-project-commands.md +237 -0
  137. package/docs/agent-project-intelligence.md +156 -0
  138. package/docs/agent-redaction.md +18 -0
  139. package/docs/agent-release-readiness.md +76 -0
  140. package/docs/agent-rollback-safety.md +162 -0
  141. package/docs/agent-rollback.md +23 -0
  142. package/docs/agent-run-artifacts.md +16 -0
  143. package/docs/agent-vscode-auto-discovery.md +137 -0
  144. package/docs/agent-vscode-batch-runner.md +100 -0
  145. package/docs/agent-vscode-chat-layout.md +90 -0
  146. package/docs/agent-vscode-clean-install.md +147 -0
  147. package/docs/agent-vscode-code-actions.md +70 -0
  148. package/docs/agent-vscode-diff-preview.md +45 -0
  149. package/docs/agent-vscode-inline-assist.md +56 -0
  150. package/docs/agent-vscode-install.md +186 -0
  151. package/docs/agent-vscode-model-setup.md +97 -0
  152. package/docs/agent-vscode-patch-preview.md +92 -0
  153. package/docs/agent-vscode-problems.md +79 -0
  154. package/docs/agent-vscode-project-dashboard.md +106 -0
  155. package/docs/agent-vscode-run-history.md +92 -0
  156. package/docs/agent-vscode-ux.md +73 -0
  157. package/docs/ai/INVARIANTS.md +84 -0
  158. package/docs/ai/PROJECT_MAP.md +338 -0
  159. package/docs/ai/PUBLIC_API.md +336 -0
  160. package/docs/ai/VALIDATION_MATRIX.md +67 -0
  161. package/docs/api-polish.md +37 -0
  162. package/docs/cancellation.md +162 -0
  163. package/docs/coverage.md +46 -0
  164. package/docs/getting-started.md +159 -0
  165. package/docs/guides/README.md +40 -0
  166. package/docs/guides/circuit-breaker.md +89 -0
  167. package/docs/guides/error-handling.md +91 -0
  168. package/docs/guides/getting-started.md +107 -0
  169. package/docs/guides/layers.md +189 -0
  170. package/docs/guides/metrics.md +101 -0
  171. package/docs/guides/resource-management.md +141 -0
  172. package/docs/guides/retry.md +215 -0
  173. package/docs/guides/semaphore.md +66 -0
  174. package/docs/guides/streams.md +117 -0
  175. package/docs/guides/supervisors.md +98 -0
  176. package/docs/guides/testing.md +162 -0
  177. package/docs/guides/tracing.md +71 -0
  178. package/docs/http-recipes.md +399 -0
  179. package/docs/http.md +749 -0
  180. package/docs/modules.md +285 -0
  181. package/docs/observability-collector-smoke.md +31 -0
  182. package/docs/observability-framework-examples.md +98 -0
  183. package/docs/observability.md +542 -0
  184. package/docs/otel-collector-smoke.yaml +27 -0
  185. package/docs/performance-profiler.md +199 -0
  186. package/docs/production-readiness.md +73 -0
  187. package/docs/recipes/README.md +12 -0
  188. package/docs/recipes/http-server.md +45 -0
  189. package/docs/recipes/layers.md +44 -0
  190. package/docs/recipes/performance.md +47 -0
  191. package/docs/recipes/runtime.md +41 -0
  192. package/docs/recipes/testing.md +41 -0
  193. package/docs/release.md +53 -0
  194. package/docs/wasm-bounded-queues.md +44 -0
  195. package/docs/wasm-engine-observability-benchmarks.md +85 -0
  196. package/docs/wasm-fiber-engine.md +117 -0
  197. package/docs/wasm-scheduler-state-machine.md +122 -0
  198. package/docs/wasm-stream-chunks.md +54 -0
  199. package/package.json +22 -2
  200. package/dist/chunk-45F7OKGT.cjs +0 -104
  201. package/dist/chunk-7V4KY4RL.mjs +0 -104
  202. package/dist/chunk-DJQ7OMMB.cjs +0 -144
  203. package/dist/chunk-GOV47PPB.mjs +0 -552
  204. package/dist/chunk-JF4XXPZ5.cjs +0 -552
  205. package/dist/chunk-KCPT2D6G.js +0 -552
  206. package/dist/chunk-NOYZIMUJ.mjs +0 -144
  207. package/dist/chunk-PNVFW245.js +0 -144
  208. package/dist/chunk-ROJC3NBJ.js +0 -104
  209. package/dist/effectRunner-3ZHAD3LE.cjs +0 -8
  210. package/dist/schedule-Fque9Abz.d.ts +0 -70
@@ -0,0 +1,480 @@
1
+ # Agent configuration and policy files
2
+
3
+ > For the end-to-end setup flow, see [Brass Agent install and configure](./agent-install-and-configure.md).
4
+
5
+ P7 adds a small JSON configuration file for the experimental `brass-agent` CLI.
6
+ The goal is to keep policy out of hardcoded TypeScript while preserving the
7
+ runtime boundary:
8
+
9
+ ```txt
10
+ src/core
11
+
12
+ src/agent policy/config
13
+
14
+ src/agent/cli loads .brass-agent.json
15
+ ```
16
+
17
+ `src/core` still does not know that the agent exists. The CLI loads config as a
18
+ Node setup step, then passes the resolved policy into `AgentEnv`.
19
+
20
+ ## Discovery
21
+
22
+ By default, the CLI searches upward from `--cwd` for either file:
23
+
24
+ ```txt
25
+ .brass-agent.json
26
+ brass-agent.config.json
27
+ ```
28
+
29
+ You can force a specific file:
30
+
31
+ ```bash
32
+ brass-agent --config ./agent.policy.json "fix the failing tests"
33
+ ```
34
+
35
+ Or disable config loading entirely:
36
+
37
+ ```bash
38
+ brass-agent --no-config "fix the failing tests"
39
+ ```
40
+
41
+ ## Precedence
42
+
43
+ Configuration is intentionally lower precedence than explicit execution knobs:
44
+
45
+ ```txt
46
+ CLI flags > environment variables > .brass-agent.json > built-in defaults
47
+ ```
48
+
49
+ Examples:
50
+
51
+ ```txt
52
+ --mode write beats config.mode
53
+ --approval deny beats config.approval
54
+ BRASS_LLM_PROVIDER beats config.llm.provider
55
+ BRASS_LLM_MODEL beats config.llm.model
56
+ ```
57
+
58
+ ## Minimal config
59
+
60
+ ```json
61
+ {
62
+ "mode": "propose",
63
+ "approval": "auto",
64
+ "llm": {
65
+ "provider": "google",
66
+ "model": "gemini-2.5-flash",
67
+ "apiKeyEnv": "GEMINI_API_KEY"
68
+ }
69
+ }
70
+ ```
71
+
72
+ Do not store API keys in the config file. Use `apiKeyEnv` and keep the secret in
73
+ the environment.
74
+
75
+ ## LLM config
76
+
77
+ ```json
78
+ {
79
+ "llm": {
80
+ "provider": "google",
81
+ "model": "gemini-2.5-flash",
82
+ "apiKeyEnv": "GEMINI_API_KEY",
83
+ "temperature": 0.2,
84
+ "maxOutputTokens": 4096
85
+ }
86
+ }
87
+ ```
88
+
89
+ OpenAI-compatible example:
90
+
91
+ ```json
92
+ {
93
+ "llm": {
94
+ "provider": "openai-compatible",
95
+ "endpoint": "https://api.openai.com/v1/chat/completions",
96
+ "model": "gpt-4.1",
97
+ "apiKeyEnv": "BRASS_LLM_API_KEY"
98
+ }
99
+ }
100
+ ```
101
+
102
+ Offline/fake example:
103
+
104
+ ```json
105
+ {
106
+ "llm": {
107
+ "provider": "fake",
108
+ "fakeResponse": "Fake plan from config"
109
+ }
110
+ }
111
+ ```
112
+
113
+ ## Project command discovery
114
+
115
+ P8 adds project-aware command discovery. The agent reads `package.json`, checks
116
+ common lockfiles, infers npm/pnpm/yarn/bun, and selects validation commands from
117
+ scripts instead of assuming `npm test`.
118
+
119
+ Basic example:
120
+
121
+ ```json
122
+ {
123
+ "project": {
124
+ "packageManager": "auto",
125
+ "testScriptNames": ["test", "test:ci", "test:unit"],
126
+ "includeTypecheck": true,
127
+ "maxValidationCommands": 2
128
+ }
129
+ }
130
+ ```
131
+
132
+ Exact validation commands override discovery:
133
+
134
+ ```json
135
+ {
136
+ "project": {
137
+ "validationCommands": [
138
+ "pnpm run test:unit",
139
+ "pnpm run typecheck"
140
+ ]
141
+ }
142
+ }
143
+ ```
144
+
145
+ Use an empty array to disable shell validation:
146
+
147
+ ```json
148
+ {
149
+ "project": {
150
+ "validationCommands": []
151
+ }
152
+ }
153
+ ```
154
+
155
+ Supported `project.packageManager` values are `auto`, `npm`, `pnpm`,
156
+ `yarn`, and `bun`.
157
+
158
+ See [Agent project command discovery](./agent-project-commands.md).
159
+
160
+ ## Context discovery
161
+
162
+ P12 adds a bounded context discovery pass before planning. It reads direct files
163
+ mentioned by validation output, searches likely identifiers, and reads a small
164
+ number of matched files before calling the LLM.
165
+
166
+ ```json
167
+ {
168
+ "context": {
169
+ "enabled": true,
170
+ "maxSearchQueries": 3,
171
+ "maxFiles": 4,
172
+ "maxSearchResults": 40,
173
+ "globs": ["*.ts", "*.tsx", "*.json"]
174
+ }
175
+ }
176
+ ```
177
+
178
+ Disable it when you want the old minimal context behavior:
179
+
180
+ ```json
181
+ {
182
+ "context": {
183
+ "enabled": false
184
+ }
185
+ }
186
+ ```
187
+
188
+ See [Agent context discovery](./agent-context-discovery.md).
189
+
190
+ ## Patch quality loop
191
+
192
+ P13 adds a bounded repair loop for patches generated by the agent. If a generated patch fails to apply, or if validation still fails after `patch.applied`, the agent can ask the LLM for an incremental repair patch.
193
+
194
+ ```json
195
+ {
196
+ "patchQuality": {
197
+ "enabled": true,
198
+ "maxRepairAttempts": 1
199
+ }
200
+ }
201
+ ```
202
+
203
+ Set `maxRepairAttempts` to `0` or `enabled` to `false` to keep one-shot apply behavior. Repairs are disabled for exact patch-file runs such as `--apply-patch-file` so the VS Code preview flow still applies exactly the patch the user approved.
204
+
205
+ See [Agent patch quality loop](./agent-patch-quality-loop.md).
206
+
207
+
208
+ ## Automatic rollback safety
209
+
210
+ P14 adds automatic rollback safety for generated patches. After validation fails
211
+ and the patch quality repair budget is exhausted, the agent can reverse-apply
212
+ generated patches through `PatchService.rollback`.
213
+
214
+ ```json
215
+ {
216
+ "rollback": {
217
+ "enabled": true,
218
+ "onFinalValidationFailure": true,
219
+ "strategy": "all",
220
+ "maxRollbackDepth": 8,
221
+ "runValidationAfterRollback": true,
222
+ "allowForSuppliedPatches": false
223
+ }
224
+ }
225
+ ```
226
+
227
+ `strategy` can be `last` or `all`. Exact patch-file flows such as
228
+ `--apply-patch-file` are protected by default, so VS Code preview still applies
229
+ exactly the patch the user approved.
230
+
231
+ See [Agent automatic rollback safety](./agent-rollback-safety.md).
232
+
233
+ ## Batch runs
234
+
235
+ P21 adds optional default batch goals. The CLI uses `config.batch.goals` only when no explicit goal, `--preset`, `--patch-file`, or `--batch-file` is provided.
236
+
237
+ ```json
238
+ {
239
+ "batch": {
240
+ "stopOnFailure": true,
241
+ "goals": [
242
+ { "preset": "inspect" },
243
+ { "preset": "typecheck" },
244
+ { "preset": "lint" }
245
+ ]
246
+ }
247
+ }
248
+ ```
249
+
250
+ See [Agent batch runs](./agent-batch.md).
251
+
252
+ ## Permission config
253
+
254
+ Shell commands are matched against the command array joined with spaces. Patterns
255
+ support `*` as a simple wildcard.
256
+
257
+ Built-in safe validation commands remain allowed by default for npm, pnpm, yarn,
258
+ and bun, along with read-only git commands. Examples include:
259
+
260
+ ```txt
261
+ npm test
262
+ npm run test*
263
+ npm run typecheck
264
+ pnpm test
265
+ pnpm run test*
266
+ yarn run lint*
267
+ bun run check
268
+ git status
269
+ git diff
270
+ git log
271
+ ```
272
+
273
+ You can extend them:
274
+
275
+ ```json
276
+ {
277
+ "permissions": {
278
+ "shell": {
279
+ "allow": [
280
+ "npm run typecheck",
281
+ "npm run lint",
282
+ "pnpm test *"
283
+ ],
284
+ "ask": [
285
+ {
286
+ "pattern": "npm run build",
287
+ "reason": "Build can be slow; confirm before running it.",
288
+ "risk": "medium",
289
+ "defaultAnswer": "approve"
290
+ }
291
+ ],
292
+ "deny": [
293
+ "rm *",
294
+ "git push *"
295
+ ]
296
+ }
297
+ }
298
+ }
299
+ ```
300
+
301
+ For a strict allowlist, disable inherited defaults:
302
+
303
+ ```json
304
+ {
305
+ "permissions": {
306
+ "shell": {
307
+ "inheritDefaults": false,
308
+ "allow": ["npm test"]
309
+ }
310
+ }
311
+ }
312
+ ```
313
+
314
+ Deny rules win over ask rules, and ask rules win over allow rules.
315
+
316
+ ## Patch apply policy
317
+
318
+ `patch.apply` is still denied in `read-only` and `propose` modes. In `write` and
319
+ `autonomous` modes, you can configure the decision:
320
+
321
+ ```json
322
+ {
323
+ "permissions": {
324
+ "patchApply": {
325
+ "decision": "ask",
326
+ "reason": "Apply the generated diff to the workspace.",
327
+ "risk": "high",
328
+ "defaultAnswer": "reject"
329
+ }
330
+ }
331
+ }
332
+ ```
333
+
334
+ Short form:
335
+
336
+ ```json
337
+ {
338
+ "permissions": {
339
+ "patchApply": "ask"
340
+ }
341
+ }
342
+ ```
343
+
344
+ Supported values are `allow`, `ask`, and `deny`.
345
+
346
+ ## Tool policy overrides
347
+
348
+ Tool policies let a project tune timeouts and retries without changing code.
349
+ Keys are `AgentAction.type` strings:
350
+
351
+ ```json
352
+ {
353
+ "tools": {
354
+ "fs.readFile": {
355
+ "timeoutMs": 10000,
356
+ "retries": 1
357
+ },
358
+ "fs.exists": {
359
+ "timeoutMs": 5000,
360
+ "retries": 1
361
+ },
362
+ "llm.complete": {
363
+ "timeoutMs": 90000,
364
+ "retries": 3
365
+ },
366
+ "shell.exec": {
367
+ "timeoutMs": 180000,
368
+ "retries": 0
369
+ },
370
+ "patch.apply": {
371
+ "timeoutMs": 30000,
372
+ "retries": 0
373
+ }
374
+ }
375
+ }
376
+ ```
377
+
378
+ Retryability is still controlled in code by error class. Config can tune counts
379
+ and timeouts, but it cannot make unsafe errors retryable.
380
+
381
+ ## Full example
382
+
383
+ ```json
384
+ {
385
+ "mode": "propose",
386
+ "approval": "auto",
387
+ "llm": {
388
+ "provider": "google",
389
+ "model": "gemini-2.5-flash",
390
+ "apiKeyEnv": "GEMINI_API_KEY",
391
+ "temperature": 0.2,
392
+ "maxOutputTokens": 4096
393
+ },
394
+ "project": {
395
+ "packageManager": "auto",
396
+ "testScriptNames": ["test", "test:ci", "test:unit"],
397
+ "includeTypecheck": true,
398
+ "maxValidationCommands": 2
399
+ },
400
+ "patchQuality": {
401
+ "enabled": true,
402
+ "maxRepairAttempts": 1
403
+ },
404
+ "rollback": {
405
+ "enabled": true,
406
+ "strategy": "all",
407
+ "maxRollbackDepth": 8
408
+ },
409
+ "permissions": {
410
+ "shell": {
411
+ "inheritDefaults": true,
412
+ "allow": [
413
+ "npm run typecheck",
414
+ "npm run lint"
415
+ ],
416
+ "ask": [
417
+ {
418
+ "pattern": "npm run build",
419
+ "reason": "Build may take a while.",
420
+ "risk": "medium",
421
+ "defaultAnswer": "approve"
422
+ }
423
+ ],
424
+ "deny": [
425
+ "git push *",
426
+ "rm *"
427
+ ]
428
+ },
429
+ "patchApply": {
430
+ "decision": "ask",
431
+ "risk": "high",
432
+ "defaultAnswer": "reject"
433
+ }
434
+ },
435
+ "tools": {
436
+ "llm.complete": {
437
+ "timeoutMs": 90000,
438
+ "retries": 2
439
+ },
440
+ "shell.exec": {
441
+ "timeoutMs": 180000,
442
+ "retries": 0
443
+ }
444
+ }
445
+ }
446
+ ```
447
+
448
+
449
+ ## Context exclude globs
450
+
451
+ ```json
452
+ {
453
+ "context": {
454
+ "excludeGlobs": [".env*", "secrets/**", "*.pem", "*.key"]
455
+ }
456
+ }
457
+ ```
458
+
459
+ These globs reduce what context discovery reads or searches before prompting the LLM.
460
+
461
+ ## Language config
462
+
463
+ Natural-language responses can match the user's prompt automatically, or be fixed per workspace:
464
+
465
+ ```json
466
+ {
467
+ "language": {
468
+ "response": "es"
469
+ }
470
+ }
471
+ ```
472
+
473
+ Supported values are `auto`, `match-user`, `en`, `es`, `pt`, `fr`, `de`, `it`, and `custom`.
474
+ Use `custom` with `language.custom` for a human-readable language name.
475
+
476
+ The language policy affects explanations and summaries only. Code, identifiers,
477
+ file paths, shell commands, logs, and unified diffs remain unchanged.
478
+
479
+ The VS Code extension can create or update this section through **Brass Agent:
480
+ Configure Workspace** or `/workspace` in the Chat view.
@@ -0,0 +1,159 @@
1
+ # Agent context discovery
2
+
3
+ P12 adds a small context discovery pass before the first LLM planning call.
4
+ The goal is to give the model the files that are most likely connected to the
5
+ failure, instead of sending only `package.json` and validation output.
6
+
7
+ The boundary remains unchanged:
8
+
9
+ ```txt
10
+ src/core
11
+
12
+ src/agent context discovery
13
+
14
+ src/agent/cli config loading
15
+ ```
16
+
17
+ Context discovery is pure agent logic. It inspects existing observations and
18
+ chooses normal `AgentAction` values:
19
+
20
+ ```txt
21
+ fs.searchText
22
+ fs.readFile
23
+ ```
24
+
25
+ It does not bypass `PermissionService`, does not run shell commands directly,
26
+ and does not require changes to the runtime core.
27
+
28
+ ## Flow
29
+
30
+ Before `llm.complete`, the agent now does this:
31
+
32
+ ```txt
33
+ read package.json
34
+ check package-manager lockfiles
35
+ discover validation commands
36
+ run allowed validation commands
37
+ extract path and identifier signals from goal + validation output
38
+ read direct files mentioned by failures
39
+ search likely identifiers with rg through fs.searchText
40
+ read top matched files
41
+ ask LLM with command + context discovery summary
42
+ ```
43
+
44
+ Examples of signals:
45
+
46
+ ```txt
47
+ src/user/UserService.ts:12:3
48
+ Cannot find name AuthClient
49
+ Expected getUserById to return ...
50
+ ```
51
+
52
+ From those, the agent may read `src/user/UserService.ts`, search for
53
+ `AuthClient`, and read the most relevant matches.
54
+
55
+ ## Defaults
56
+
57
+ ```txt
58
+ enabled: true
59
+ maxSearchQueries: 3
60
+ maxFiles: 4
61
+ maxSearchResults: 40
62
+ globs: TypeScript, JavaScript, JSON, Markdown, YAML files
63
+ ```
64
+
65
+ The step budget was raised to leave room for the extra discovery work.
66
+
67
+ ## Config
68
+
69
+ You can tune or disable context discovery from `.brass-agent.json`:
70
+
71
+ ```json
72
+ {
73
+ "context": {
74
+ "enabled": true,
75
+ "maxSearchQueries": 3,
76
+ "maxFiles": 4,
77
+ "maxSearchResults": 40,
78
+ "globs": ["*.ts", "*.tsx", "*.json"]
79
+ }
80
+ }
81
+ ```
82
+
83
+ Disable it entirely:
84
+
85
+ ```json
86
+ {
87
+ "context": {
88
+ "enabled": false
89
+ }
90
+ }
91
+ ```
92
+
93
+ Use smaller budgets for very large repositories:
94
+
95
+ ```json
96
+ {
97
+ "context": {
98
+ "maxSearchQueries": 1,
99
+ "maxFiles": 2
100
+ }
101
+ }
102
+ ```
103
+
104
+ ## Search semantics
105
+
106
+ The Node filesystem adapter uses ripgrep in fixed-string mode:
107
+
108
+ ```txt
109
+ rg --fixed-strings --line-number --no-heading --max-count 5 ...
110
+ ```
111
+
112
+ This keeps generated searches safe and predictable. Query strings are derived
113
+ from simple path and identifier signals; they are not treated as regexes.
114
+
115
+ ## Prompting
116
+
117
+ The planning prompt now includes a context summary alongside the project command
118
+ summary:
119
+
120
+ ```txt
121
+ Project commands: ...
122
+ Context discovery: searched queries: ...
123
+ Discovered paths: ...
124
+ Read context files: ...
125
+ ```
126
+
127
+ Large observations are compacted before prompting. Search results are capped in
128
+ prompt context so a broad query cannot flood the model.
129
+
130
+ ## Safety
131
+
132
+ Context discovery is intentionally bounded:
133
+
134
+ ```txt
135
+ - fixed number of searches
136
+ - fixed number of files read
137
+ - ignored generated/vendor directories
138
+ - workspace-relative paths only
139
+ - no direct shell execution from discovery logic
140
+ ```
141
+
142
+ `fs.searchText` is still interpreted by the configured `FileSystem` service, and
143
+ `fs.readFile` still goes through the same workspace path validation used by other
144
+ agent actions.
145
+
146
+
147
+ ## Excluding sensitive paths
148
+
149
+ P17 adds `context.excludeGlobs`. Excluded paths are filtered from direct error-path reads and are also passed to `rg` as negative globs.
150
+
151
+ ```json
152
+ {
153
+ "context": {
154
+ "excludeGlobs": [".env*", "secrets/**", "*.pem", "*.key"]
155
+ }
156
+ }
157
+ ```
158
+
159
+ This is a context-discovery guard. It does not replace redaction, shell permissions, or workspace path validation.