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,126 @@
1
+ # Brass Agent Copilot-like DX
2
+
3
+ Brass Agent started as a CLI-first coding agent. That is still the canonical execution surface, but VS Code users should not need to remember flags or switch to a terminal for normal usage.
4
+
5
+ P29 adds a Copilot-like VS Code surface around the existing CLI protocol.
6
+
7
+ ## Mental model
8
+
9
+ Brass Agent is not an inline autocomplete engine yet.
10
+
11
+ It is a task agent:
12
+
13
+ ```txt
14
+ you ask for a goal
15
+ -> brass-agent inspects the workspace
16
+ -> runs allowed validation commands
17
+ -> discovers context
18
+ -> calls the configured LLM
19
+ -> proposes a patch
20
+ -> VS Code previews the exact diff
21
+ -> you approve before writing
22
+ ```
23
+
24
+ The VS Code chat view makes that flow feel like a normal editor assistant.
25
+
26
+ ## Chat view
27
+
28
+ Open the Brass Agent activity bar and use the **Chat** view.
29
+
30
+ You can ask things like:
31
+
32
+ ```txt
33
+ inspect this workspace
34
+ fix the failing tests
35
+ explain the current type errors
36
+ refactor this module to reduce duplication
37
+ add tests for the selected function
38
+ ```
39
+
40
+ The chat has three modes:
41
+
42
+ | Mode | What it does |
43
+ | --- | --- |
44
+ | Ask | `read-only`; no shell writes, no patch apply |
45
+ | Propose patch | generates a plan and patch preview, but does not write |
46
+ | Apply after preview | still generates a proposal first; writes only after you approve the exact diff |
47
+
48
+ ## Selection-aware commands
49
+
50
+ Select code in an editor and right-click. Brass Agent contributes:
51
+
52
+ ```txt
53
+ Ask About Selection
54
+ Explain Selection
55
+ Fix Selection
56
+ ```
57
+
58
+ These commands open the chat with a prefilled prompt containing:
59
+
60
+ ```txt
61
+ file path
62
+ language id
63
+ selected code
64
+ ```
65
+
66
+ They do not directly edit the selection. `Fix Selection` asks the agent to generate a workspace patch and then uses the normal patch preview / approval flow.
67
+
68
+ ## Why not inline autocomplete first?
69
+
70
+ Inline autocomplete is useful for short completions while typing. Brass Agent's strongest path is different:
71
+
72
+ ```txt
73
+ multi-file context
74
+ validation commands
75
+ typed permissions
76
+ patch preview
77
+ rollback safety
78
+ run history
79
+ ```
80
+
81
+ That maps better to chat + code actions than to token-by-token inline completion.
82
+
83
+ A future inline completion provider can still be added, but it should be a separate lightweight layer for small edits, not the main agent loop.
84
+
85
+ ## Architecture
86
+
87
+ The boundary remains unchanged:
88
+
89
+ ```txt
90
+ src/core
91
+
92
+ src/agent
93
+
94
+ brass-agent CLI protocol
95
+
96
+ VS Code Chat / TreeView / Webview clients
97
+ ```
98
+
99
+ The chat view does not reimplement agent planning, permissions, approvals, context discovery, patch apply, or rollback. It calls:
100
+
101
+ ```bash
102
+ brass-agent --protocol-json --protocol-full-patches --cwd <workspace> <goal>
103
+ ```
104
+
105
+ and renders protocol events.
106
+
107
+ ## Recommended daily flow
108
+
109
+ 1. Open the Brass Agent sidebar.
110
+ 2. Use **Chat** for normal questions.
111
+ 3. Select code and use **Ask About Selection** or **Fix Selection**.
112
+ 4. Review patch previews before applying.
113
+ 5. Check **Run History** for past runs, details, patches, and reruns.
114
+
115
+ ## Safety notes
116
+
117
+ - `Apply after preview` still applies only after exact diff approval.
118
+ - Secrets should live in `.env`, `.env.local`, or `.brass-agent.env`; doctor verifies provider setup.
119
+ - Redaction and context exclude globs still run before LLM prompts.
120
+ - VS Code does not apply patches directly; it delegates back to `brass-agent`.
121
+
122
+ ## P30: sessions and slash commands
123
+
124
+ The Chat view now stores a workspace-local conversation, supports slash commands such as `/inspect`, `/fix-tests`, `/explain-last`, and `/apply-last`, and composes follow-up goals using the previous run summary, latest validation output, and patch stats.
125
+
126
+ See [Chat sessions and slash commands](./agent-chat-sessions.md).
@@ -0,0 +1,138 @@
1
+ # Declarative optimized planning roadmap
2
+
3
+ This note tracks the design goal:
4
+
5
+ > Keep the user-facing layer declarative and flexible, but internally convert
6
+ > work into optimized plans that execute with batches, compact memory, and the
7
+ > least practical overhead.
8
+
9
+ ## Does Brass Agent do this today?
10
+
11
+ Partially.
12
+
13
+ Brass Agent already has several pieces of the model:
14
+
15
+ - declarative user requests through CLI goals, VS Code chat, presets, and batch
16
+ files,
17
+ - `AgentAction -> Observation` execution through explicit capabilities,
18
+ - bounded context discovery before planning,
19
+ - compact protocol/events for editor integrations,
20
+ - sequential batch runs for multi-goal workflows,
21
+ - patch quality loops and rollback safety,
22
+ - project intelligence for mixed stacks.
23
+
24
+ However, the current agent still uses a mostly sequential decision loop. It does
25
+ not yet compile user intent into a first-class optimized plan IR, batch tool
26
+ calls aggressively, maintain a compact long-lived memory model, or minimize
27
+ runtime overhead through cost-aware scheduling.
28
+
29
+ ## What is missing for the full design?
30
+
31
+ ### 1. A first-class plan IR
32
+
33
+ Introduce an internal representation such as:
34
+
35
+ ```ts
36
+ type AgentPlan = {
37
+ readonly id: string;
38
+ readonly goal: string;
39
+ readonly steps: readonly PlanStep[];
40
+ readonly budgets: PlanBudgets;
41
+ };
42
+
43
+ type PlanStep =
44
+ | { readonly type: "read"; readonly paths: readonly string[] }
45
+ | { readonly type: "search"; readonly queries: readonly string[] }
46
+ | { readonly type: "validate"; readonly commands: readonly string[][] }
47
+ | { readonly type: "llm"; readonly purpose: "plan" | "patch" | "explain" }
48
+ | { readonly type: "patch"; readonly mode: "propose" | "apply" | "rollback" };
49
+ ```
50
+
51
+ The user keeps writing natural requests, but the agent compiles them into a
52
+ small, inspectable, optimizable plan before execution.
53
+
54
+ ### 2. Plan optimization passes
55
+
56
+ Before execution, run optimization passes:
57
+
58
+ - deduplicate repeated reads/searches,
59
+ - merge compatible searches,
60
+ - avoid reading files already in compact memory,
61
+ - skip validation commands that are irrelevant to the goal,
62
+ - cap expensive operations by budget,
63
+ - split independent work into parallel or batched groups.
64
+
65
+ ### 3. Batched tool execution
66
+
67
+ Add tool-level batching:
68
+
69
+ - `fs.readFiles(paths)` instead of repeated single reads,
70
+ - `fs.existsMany(paths)` for marker discovery,
71
+ - `search.batch(queries)` with shared `rg` invocation when possible,
72
+ - validation command groups with explicit ordering and concurrency rules.
73
+
74
+ The public agent API can remain declarative while the executor runs fewer tool
75
+ calls internally.
76
+
77
+ ### 4. Compact memory
78
+
79
+ Separate memory into layers:
80
+
81
+ ```txt
82
+ working memory current run, exact observations
83
+ compact memory summaries, file digests, validation summaries
84
+ persistent memory optional workspace-local cache, never required
85
+ ```
86
+
87
+ The LLM should receive compact summaries first, exact contents only when needed.
88
+ This reduces token usage, repeated file reads, and noisy follow-up prompts.
89
+
90
+ ### 5. Cost and overhead budgets
91
+
92
+ Every plan should carry budgets:
93
+
94
+ ```txt
95
+ max tool calls
96
+ max files read
97
+ max bytes read
98
+ max search queries
99
+ max validation commands
100
+ max LLM calls
101
+ max wall-clock time
102
+ ```
103
+
104
+ The planner and executor can then prefer lower-overhead plans and explain when a
105
+ budget prevented more exploration.
106
+
107
+ ### 6. Runtime lanes and scheduling
108
+
109
+ Use the runtime more directly for optimized execution lanes:
110
+
111
+ ```txt
112
+ FS lane bounded concurrency
113
+ Search lane low concurrency, deduped
114
+ LLM lane strict concurrency, retry/backoff
115
+ Validation lane serial by default
116
+ Patch lane exclusive
117
+ ```
118
+
119
+ This matches the original brass-runtime idea: a coding agent is a concurrent,
120
+ cancelable, observable effect program.
121
+
122
+ ## Suggested implementation path
123
+
124
+ 1. `P49`: introduce `AgentPlan` and log/preview plans without changing behavior.
125
+ 2. `P50`: compile current `decideNextAction` flow into a simple sequential plan.
126
+ 3. `P51`: add plan optimization passes for dedupe and budget caps.
127
+ 4. `P52`: add batched FS/exists/search tools.
128
+ 5. `P53`: add compact memory summaries for files, validation output, and patches.
129
+ 6. `P54`: add lane-based executor with bounded concurrency.
130
+ 7. `P55`: expose a VS Code “Plan Preview” so users can see what the agent is
131
+ about to do before it runs.
132
+
133
+ ## Short answer
134
+
135
+ Brass Agent currently supports the declarative UX and some compact/batch pieces,
136
+ but it is not yet a fully optimized internal planner. To get there, the next big
137
+ step is to introduce a first-class `AgentPlan` IR and then optimize/execute that
138
+ plan with batching, compact memory, budgets, and runtime lanes.
@@ -0,0 +1,224 @@
1
+ # Brass Agent DX surfaces
2
+
3
+ This document defines how `brass-agent` should be exposed to developers without
4
+ letting UI concerns leak into the runtime or agent core.
5
+
6
+ ## Decision
7
+
8
+ Start with a strong CLI and make editor integrations thin clients over a stable
9
+ machine protocol.
10
+
11
+ ```txt
12
+ src/core
13
+
14
+ src/agent
15
+
16
+ brass-agent CLI
17
+
18
+ VS Code / other IDE clients
19
+ ```
20
+
21
+ The VS Code extension should not reimplement the agent loop. It should call the
22
+ CLI with `--protocol-json`, parse JSON Lines, and render the run in editor UI.
23
+
24
+ ## Why CLI-first
25
+
26
+ The CLI is the canonical developer surface because it is:
27
+
28
+ - easy to run in any repo
29
+ - easy to use in CI and smoke tests
30
+ - easy to debug with `--json` and `--protocol-json`
31
+ - independent of a particular editor
32
+ - the best place to stabilize permissions, approvals, config, and event output
33
+
34
+ The CLI remains thin. It wires Node capabilities, config, approvals, LLM adapters,
35
+ and output formatting around `runAgent(...)`.
36
+
37
+ ## Why the VS Code extension is a thin client
38
+
39
+ The extension should use VS Code for editor-native UX:
40
+
41
+ - Command Palette commands
42
+ - workspace folder discovery
43
+ - input boxes for goals
44
+ - modal confirmation before write/apply runs
45
+ - output channel rendering
46
+ - cancellation from VS Code progress UI
47
+ - status bar updates
48
+
49
+ But the extension should not own:
50
+
51
+ - planning logic
52
+ - tool policy
53
+ - approvals semantics
54
+ - patch extraction/application
55
+ - project command discovery
56
+ - LLM adapter behavior
57
+
58
+ Those stay in `src/agent` and the CLI.
59
+
60
+ ## Protocol
61
+
62
+ Use:
63
+
64
+ ```bash
65
+ brass-agent --protocol-json "fix the failing tests"
66
+ ```
67
+
68
+ The CLI prints newline-delimited protocol messages:
69
+
70
+ ```jsonl
71
+ {"protocol":"brass-agent","version":1,"type":"event","event":{"type":"agent.run.started"}}
72
+ {"protocol":"brass-agent","version":1,"type":"event","event":{"type":"agent.action.started"}}
73
+ {"protocol":"brass-agent","version":1,"type":"final-state","state":{"phase":"done"}}
74
+ ```
75
+
76
+ `--events-json` remains useful for quick event-only streams. Integrations should
77
+ prefer `--protocol-json` because it includes both events and the final compact
78
+ state.
79
+
80
+ ## Current VS Code scaffold
81
+
82
+ The first extension scaffold lives in:
83
+
84
+ ```txt
85
+ extensions/vscode-brass-agent/
86
+ ```
87
+
88
+ It contributes commands:
89
+
90
+ ```txt
91
+ Brass Agent: Propose Fix
92
+ Brass Agent: Apply Fix
93
+ Brass Agent: Inspect Workspace
94
+ Brass Agent: Show Output
95
+ Brass Agent: Cancel Current Run
96
+ ```
97
+
98
+ The extension invokes the configured CLI command, defaulting to:
99
+
100
+ ```txt
101
+ brass-agent
102
+ ```
103
+
104
+ Settings:
105
+
106
+ ```json
107
+ {
108
+ "brassAgent.command": "brass-agent",
109
+ "brassAgent.extraArgs": [],
110
+ "brassAgent.environment": {}
111
+ }
112
+ ```
113
+
114
+ Development:
115
+
116
+ ```bash
117
+ cd extensions/vscode-brass-agent
118
+ npm install
119
+ npm run compile
120
+ ```
121
+
122
+ Then open the extension folder in VS Code and run the Extension Development Host.
123
+
124
+ ## Apply behavior
125
+
126
+ The VS Code `Apply Fix` command intentionally asks for one editor-level
127
+ confirmation before launching the CLI with:
128
+
129
+ ```bash
130
+ brass-agent --protocol-json --apply --yes ...
131
+ ```
132
+
133
+ That means the agent can apply a valid patch only after the user confirms in VS
134
+ Code. Deeper per-action approvals can be added later by extending the protocol
135
+ with request/response messages, but the first scaffold keeps the extension simple
136
+ and safe.
137
+
138
+ ## Future DX slices
139
+
140
+ Recommended next DX slices:
141
+
142
+ 1. Rich sidebar TreeView for run history and current actions.
143
+ 2. Webview panel for patch preview and approval.
144
+ 3. Chat Participant integration so users can invoke `@brass` from VS Code chat.
145
+ 4. Language Model Tool integration so VS Code/Copilot agent mode can call Brass tools.
146
+ 5. Import-mode extension that calls `runAgent(...)` directly with VS Code-native
147
+ file system, terminal, and approval services.
148
+
149
+ The invariant stays the same: editor integrations are consumers of the agent,
150
+ not owners of the agent semantics.
151
+
152
+ ## P10: VS Code patch preview
153
+
154
+ The VS Code extension now previews proposed diffs in a webview before applying
155
+ anything. The apply path uses a second CLI invocation with `--apply-patch-file`,
156
+ so the extension never applies patches itself. P13 patch repair is disabled for this exact apply path, preserving preview approval semantics.
157
+
158
+ ```txt
159
+ propose run -> patch.proposed -> webview preview -> approve -> apply supplied patch
160
+ ```
161
+
162
+ For trusted local clients, `--protocol-full-patches` keeps only patch payloads
163
+ untruncated in protocol output.
164
+
165
+ ## P11: VS Code run history
166
+
167
+ The VS Code extension now contributes a `Brass Agent` activity-bar view with a
168
+ persistent `Runs` TreeView. The view stores compact run metadata in VS Code
169
+ `workspaceState`, can reopen stored patch previews, can rerun previous goals,
170
+ and can clear history for the current workspace.
171
+
172
+ This remains client-side UX over the CLI protocol. The runtime and agent core do
173
+ not know about VS Code, TreeViews, or editor persistence.
174
+
175
+ ## VS Code batch runner
176
+
177
+ The VS Code extension can run batch files through the same CLI protocol boundary:
178
+
179
+ ```txt
180
+ VS Code
181
+ -> brass-agent --protocol-json --protocol-full-patches --batch-file <file>
182
+ -> protocol events / final states / batch summary
183
+ -> sidebar history parent with child runs
184
+ ```
185
+
186
+ This keeps batching in the CLI and keeps the extension as a UI client. See
187
+ [VS Code batch runner](./agent-vscode-batch-runner.md).
188
+
189
+ ## P23: local install and doctor
190
+
191
+ CI/release automation is intentionally deferred. The current DX path is local:
192
+
193
+ ```bash
194
+ npm run agent:vscode:install
195
+ npm run agent:doctor
196
+ ```
197
+
198
+ The VS Code extension also exposes:
199
+
200
+ ```txt
201
+ Brass Agent: Doctor
202
+ ```
203
+
204
+ This keeps the workflow human-driven while the CLI, protocol, VS Code client,
205
+ configuration, and safety model continue to stabilize.
206
+
207
+ ## Initialize a workspace first
208
+
209
+ For a new project, bootstrap local config before deeper DX setup:
210
+
211
+ ```bash
212
+ brass-agent --init
213
+ brass-agent --doctor
214
+ ```
215
+
216
+ The VS Code extension also contributes `Brass Agent: Initialize Workspace`, which runs the same init flow from the command palette.
217
+
218
+ ## Copilot-like chat surface
219
+
220
+ See [Copilot-like VS Code DX](./agent-copilot-like-dx.md) for the chat view, selection-aware commands, and why Brass Agent uses chat/code actions before inline autocomplete.
221
+
222
+ ## P30: chat sessions
223
+
224
+ The VS Code chat view now persists a lightweight workspace-local session, supports slash commands, and composes follow-up prompts from the last run summary, validation output, and patch stats. See [Chat sessions and slash commands](./agent-chat-sessions.md).
@@ -0,0 +1,126 @@
1
+ # Brass Agent env files
2
+
3
+ `brass-agent` can read local environment files for agent-specific variables.
4
+ This is useful for VS Code and local dogfooding because editor-launched commands do
5
+ not always inherit the same shell environment as your terminal.
6
+
7
+ ## Load order
8
+
9
+ By default, the CLI checks these files in `--cwd`:
10
+
11
+ ```txt
12
+ .brass-agent.env
13
+ .env.local
14
+ .env
15
+ ```
16
+
17
+ All existing files are parsed in that order. Exported shell variables win: the
18
+ loader never overwrites keys that are already present in `process.env`.
19
+
20
+ To load a specific file:
21
+
22
+ ```bash
23
+ brass-agent --env-file .env --doctor
24
+ ```
25
+
26
+ To disable env-file loading completely:
27
+
28
+ ```bash
29
+ brass-agent --no-env-file --doctor
30
+ ```
31
+
32
+ ## What gets loaded
33
+
34
+ For safety, the loader only imports known Brass Agent keys, plus the custom
35
+ `config.llm.apiKeyEnv` key when configured. Other application secrets in `.env`
36
+ are ignored and are not copied into `process.env` by the loader.
37
+
38
+ Supported built-in keys include:
39
+
40
+ ```txt
41
+ BRASS_LLM_PROVIDER
42
+ BRASS_FAKE_LLM_RESPONSE
43
+
44
+ GEMINI_API_KEY
45
+ GOOGLE_API_KEY
46
+ BRASS_GOOGLE_API_KEY
47
+ BRASS_GOOGLE_MODEL
48
+ BRASS_GOOGLE_API_VERSION
49
+ BRASS_GOOGLE_BASE_URL
50
+ BRASS_GOOGLE_ENDPOINT
51
+ BRASS_GOOGLE_SYSTEM_INSTRUCTION
52
+ BRASS_GOOGLE_TEMPERATURE
53
+ BRASS_GOOGLE_TOP_P
54
+ BRASS_GOOGLE_TOP_K
55
+ BRASS_GOOGLE_MAX_OUTPUT_TOKENS
56
+
57
+ BRASS_LLM_ENDPOINT
58
+ BRASS_LLM_API_KEY
59
+ BRASS_LLM_MODEL
60
+
61
+ BRASS_AGENT_APPROVAL
62
+ BRASS_AGENT_AUTO_APPROVE
63
+ BRASS_CODE_CMD
64
+ ```
65
+
66
+ The doctor prints key names only, never values.
67
+
68
+ ## Google / Gemini example
69
+
70
+ `.brass-agent.json`:
71
+
72
+ ```json
73
+ {
74
+ "llm": {
75
+ "provider": "google",
76
+ "model": "gemini-2.5-flash",
77
+ "apiKeyEnv": "GEMINI_API_KEY"
78
+ }
79
+ }
80
+ ```
81
+
82
+ `.env` or `.brass-agent.env`:
83
+
84
+ ```bash
85
+ BRASS_LLM_PROVIDER=google
86
+ GEMINI_API_KEY=...
87
+ BRASS_GOOGLE_MODEL=gemini-2.5-flash
88
+ ```
89
+
90
+ Then:
91
+
92
+ ```bash
93
+ brass-agent --doctor
94
+ ```
95
+
96
+ Expected doctor output includes:
97
+
98
+ ```txt
99
+ ✓ Agent env file: Loaded ... keys: BRASS_LLM_PROVIDER, GEMINI_API_KEY, BRASS_GOOGLE_MODEL
100
+ ✓ LLM provider: Google/Gemini provider is configured (google).
101
+ ```
102
+
103
+ ## Why `.env` alone used to fail
104
+
105
+ A shell does not automatically export variables from a `.env` file. Before the
106
+ env-file loader, this worked only when you did something like:
107
+
108
+ ```bash
109
+ set -a
110
+ source .env
111
+ set +a
112
+ brass-agent --doctor
113
+ ```
114
+
115
+ With the loader, keeping agent keys in `.env` or `.brass-agent.env` is enough for
116
+ the CLI and VS Code extension.
117
+
118
+ ## Safety notes
119
+
120
+ - Do not commit real API keys.
121
+ - Prefer `.brass-agent.env` when you want to keep agent credentials separate from
122
+ app/runtime `.env` files.
123
+ - The loader ignores non-agent keys in `.env` so app secrets are not imported
124
+ just because the agent is running.
125
+ - If a key was exposed publicly or pasted into a chat/log, revoke it and create a
126
+ new one.
@@ -0,0 +1,43 @@
1
+ # Brass Agent follow-up context
2
+
3
+ Brass Agent chat keeps a lightweight memory of the last run so the user can ask follow-up questions such as:
4
+
5
+ ```text
6
+ why did that fail?
7
+ try again but keep the public API unchanged
8
+ explain the last patch
9
+ ```
10
+
11
+ Follow-up context is intentionally gated. Slash commands such as `/inspect`, `/fix-tests`, `/typecheck`, and `/lint` start from a clean request instead of automatically embedding the previous run summary. This prevents a repeated `/inspect` from re-sending an old inspection summary as if it were the current request.
12
+
13
+ The chat only includes previous run context when one of these is true:
14
+
15
+ - the command explicitly asks for previous context, such as `/explain-last` or patch actions;
16
+ - the prompt looks like a follow-up, for example “why did that fail?” or “try again”;
17
+ - the caller explicitly forces context for a specific integration flow.
18
+
19
+ When context is included, the extension compactly sends:
20
+
21
+ - previous goal;
22
+ - previous mode/status;
23
+ - a truncated previous summary;
24
+ - a truncated error or validation output;
25
+ - patch stats, and optionally the last patch diff when requested.
26
+
27
+ This keeps model prompts smaller and avoids polluting context discovery with generic words from previous summaries.
28
+
29
+ ## LLM errors
30
+
31
+ If the model call fails, Brass Agent now surfaces the underlying provider message when available. Instead of only showing:
32
+
33
+ ```text
34
+ Agent stopped with LLMError.
35
+ ```
36
+
37
+ it reports a more actionable summary such as:
38
+
39
+ ```text
40
+ Agent stopped because the model call failed: Google Gemini request failed with 429: ...
41
+ ```
42
+
43
+ Secrets are still passed through the agent redaction layer before appearing in summaries.