brass-runtime 1.13.7 β†’ 1.13.8

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 (2) hide show
  1. package/README.md +231 -55
  2. package/package.json +1 -1
package/README.md CHANGED
@@ -1,58 +1,234 @@
1
- # Documentation
1
+ # πŸ› οΈ brass-runtime β€” Mini ZIO-like runtime in TypeScript
2
+
3
+ A small experimental runtime inspired by **ZIO 2**, implemented in vanilla TypeScript and intentionally built without using `Promise` / `async`/`await` as the **primary semantic primitive**.
4
+
5
+ `brass-runtime` is the foundation: it provides an effect system, fibers, scheduler, scopes, and streams.
6
+ Higher-level modules (HTTP, streaming utilities, integrations) are built **on top of the runtime**, not baked into it.
7
+
8
+ > You can still interop with the outside world (timers, fetch, Node APIs) via explicit, cancellable bridges such as `fromPromiseAbortable`.
9
+
10
+ ---
11
+
12
+ ## Philosophy
13
+
14
+ - **Effects are values** β€” lazy, composable, referentially transparent
15
+ - **Async is explicit** β€” no hidden Promise semantics
16
+ - **Concurrency is structured** β€” fibers, scopes, finalizers
17
+ - **Side effects are interpreted** β€” not executed eagerly
18
+ - **Higher-level APIs are libraries, not magic**
19
+
20
+ If you like ZIO’s separation between `zio-core`, `zio-streams`, and `zio-http`, this project follows the same spirit.
21
+
22
+ ---
23
+
24
+ ## Core concepts
25
+
26
+ - Sync core effect: `Effect<R, E, A>` and `Exit<E, A>`
27
+ - Algebraic async representation: `Async<R, E, A>`
28
+ - Cooperative `Scheduler` (observable / testable)
29
+ - Lightweight `Fiber`s with interruption & finalizers
30
+ - Structured `Scope`s for resource safety
31
+ - ZStream-style streams with backpressure
32
+
33
+ ---
34
+
35
+ ## Install
36
+
37
+ ```bash
38
+ npm i brass-runtime
39
+ ```
40
+
41
+ ---
42
+
43
+ ## Quick start
44
+
45
+ ### Run an effect
46
+
47
+ ```ts
48
+ import { Runtime, succeed, toPromise } from "brass-runtime";
49
+
50
+ const runtime = new Runtime({ env: {} });
51
+
52
+ const value = await toPromise(succeed(123), runtime.env);
53
+ console.log(value); // 123
54
+ ```
55
+
56
+ ### Structured concurrency with Scope
57
+
58
+ ```ts
59
+ import { Runtime, withScope } from "brass-runtime";
60
+
61
+ const runtime = new Runtime({ env: {} });
62
+
63
+ withScope(runtime, (scope) => {
64
+ const f = scope.fork(/* Async effect */);
65
+ // later...
66
+ scope.close(); // interrupts child fibers + runs finalizers
67
+ });
68
+ ```
69
+
70
+ > `toPromise` is just a convenience bridge for examples/DX. The runtime semantics remain explicit.
71
+
72
+ ---
73
+
74
+ ## Modules built on top of brass-runtime
75
+
76
+ These are optional layers, implemented using the runtime primitives.
77
+
78
+ ### 🌐 HTTP client (brass-http layer)
79
+
80
+ A ZIO-style HTTP client built on top of fibers and `Async`.
81
+
82
+ - Lazy & cancelable HTTP requests
83
+ - Explicit wire/content separation
84
+ - Middleware-friendly (logging, retry, timeout, etc.)
85
+ - Integrated with fiber interruption via `AbortController`
86
+
87
+ πŸ‘‰ **Docs:** [HTTP module](./docs/http.md)
88
+
89
+ Example:
90
+
91
+ ```ts
92
+ import { Runtime, toPromise } from "brass-runtime";
93
+ import { httpClientStream } from "brass-runtime/http";
94
+
95
+ type Post = { id: number; title: string; body: string };
96
+
97
+ const runtime = new Runtime({ env: {} });
98
+
99
+ const client = httpClientStream({ baseUrl: "https://jsonplaceholder.typicode.com" });
100
+
101
+ const res = await toPromise(client.getJson<Post>("/posts/1"), runtime.env);
102
+ console.log(res.status, res.value.title);
103
+ ```
104
+
105
+ ---
106
+
107
+ ### πŸ€– Brass Agent (experimental)
108
+
109
+ A CLI-first coding agent built on top of the runtime. Brass Agent is currently experimental: it can inspect a workspace, discover validation commands, gather bounded context, ask an LLM for a patch, apply/rollback patches through explicit policies, and expose a thin VS Code extension over the CLI protocol.
2
110
 
3
111
  Start here:
4
112
 
5
- - **[Getting started](./getting-started.md)** β€” installation, first effects, and running examples
6
- - **[Architecture](./ARCHITECTURE.md)** β€” how the runtime is structured
7
- - **[Cancellation & interruption](./cancellation.md)** β€” interruption semantics, scopes, and cancellable `Async`
8
- - **[Observability](./observability.md)** β€” hooks, events, sinks, and tracing
9
- - **[HTTP client](./http.md)** β€” ZIO-style HTTP built on brass-runtime
10
- - **[Modules overview](./modules.md)** β€” map of core modules and where things live
11
- - **[Agent module boundaries](./agent-boundaries.md)** β€” rules for keeping `brass-agent` isolated from the core runtime
12
- - **[Brass Agent install and configure](./agent-install-and-configure.md)** β€” end-to-end local setup for CLI, config, providers, and VS Code
13
-
14
- - [Agent LLM adapters](./agent-llm-adapters.md)
15
- - [Agent env files](./agent-env-files.md)
16
- - [Agent global usage and workspace discovery](./agent-global-usage.md)
17
- - [Agent apply mode](./agent-apply-mode.md)
18
- - [Brass Agent CLI](./agent-cli.md)
19
- - [Agent init](./agent-init.md)
20
- - [Agent observability](./agent-observability.md)
21
- - [Agent approvals](./agent-approvals.md)
22
- - [Agent config and policy files](./agent-config.md)
23
- - [Agent project command discovery](./agent-project-commands.md)
24
- - [Agent project intelligence](./agent-project-intelligence.md)
25
- - [Declarative optimized planning roadmap](./agent-declarative-optimized-planning.md)
26
- - [Agent context discovery](./agent-context-discovery.md)
27
- - [Agent patch quality loop](./agent-patch-quality-loop.md)
28
- - [Agent automatic rollback safety](./agent-rollback-safety.md)
29
- - [Agent DX surfaces](./agent-dx.md)
30
-
31
- - [VS Code patch preview](./agent-vscode-patch-preview.md)
32
- - [VS Code enhanced diff preview](./agent-vscode-diff-preview.md)
33
- - [VS Code run history](./agent-vscode-run-history.md)
34
- - [VS Code batch runner](./agent-vscode-batch-runner.md)
35
- - [VS Code UX](./agent-vscode-ux.md)
36
- - [VS Code Project dashboard](./agent-vscode-project-dashboard.md)
37
- - [VS Code Chat layout / focus mode](./agent-vscode-chat-layout.md)
38
- - [Copilot-like VS Code DX](./agent-copilot-like-dx.md)
39
- - [Chat sessions and slash commands](./agent-chat-sessions.md)
40
- - [Agent follow-up context](./agent-follow-up-context.md)
41
- - [VS Code code actions](./agent-vscode-code-actions.md)
42
- - [VS Code problems-aware chat](./agent-vscode-problems.md)
43
- - [VS Code inline assist](./agent-vscode-inline-assist.md)
44
- - [Agent release readiness](./agent-release-readiness.md)
45
- - [VS Code local install](./agent-vscode-install.md)
46
- - [VS Code auto-discovery](./agent-vscode-auto-discovery.md)
47
- - [VS Code model setup](./agent-vscode-model-setup.md)
48
- - [Agent local install and doctor](./agent-local-install.md)
49
- - [Agent local tests](./agent-local-tests.md)
50
-
51
- - [Agent rollback patches](./agent-rollback.md)
52
- - [Agent redaction](./agent-redaction.md)
53
- - [Agent run artifacts](./agent-run-artifacts.md)
54
- - [Agent CI mode](./agent-ci.md)
55
- - [Agent presets](./agent-presets.md)
56
- - [Agent batch runs](./agent-batch.md)
57
- - [VS Code full clean and reinstall](./agent-vscode-clean-install.md)
58
- - [Agent language and workspace setup UX](agent-language-workspace-ux.md)
113
+ - [Install and configure Brass Agent](./docs/agent-install-and-configure.md)
114
+ - [Declarative optimized planning roadmap](./docs/agent-declarative-optimized-planning.md)
115
+ - [Brass Agent CLI](./docs/agent-cli.md)
116
+ - [Project intelligence](./docs/agent-project-intelligence.md)
117
+ - [Global usage and workspace discovery](./docs/agent-global-usage.md)
118
+ - [VS Code local install](./docs/agent-vscode-install.md)
119
+ - [VS Code auto-discovery](./docs/agent-vscode-auto-discovery.md)
120
+ - [VS Code model setup](./docs/agent-vscode-model-setup.md)
121
+ - [VS Code chat layout / focus mode](./docs/agent-vscode-chat-layout.md)
122
+
123
+ ```bash
124
+ npm run agent:vscode:install
125
+ # then open any repo in VS Code and use Brass Agent -> Chat
126
+
127
+ npm run build
128
+ npm run agent:link
129
+ brass-agent --where
130
+ brass-agent --doctor
131
+ brass-agent --init
132
+ brass-agent --preset inspect
133
+ ```
134
+
135
+ ---
136
+
137
+ ### 🌊 Streams (ZStream-like)
138
+
139
+ Pull-based, resource-aware streams with backpressure.
140
+
141
+ - `ZStream<R, E, A>`
142
+ - `Pull` semantics
143
+ - Bounded buffers
144
+ - Deterministic resource cleanup
145
+
146
+ Examples:
147
+
148
+ - `src/examples/fromPromise.ts`
149
+ - `src/examples/mergeStreamSync.ts`
150
+
151
+ ---
152
+
153
+ ## Docs
154
+
155
+ - [Getting Started](./docs/getting-started.md)
156
+ - [Architecture](./docs/ARCHITECTURE.md)
157
+ - [Cancellation & Interruption](./docs/cancellation.md)
158
+ - [Observability: Hooks & Tracing](./docs/observability.md)
159
+ - [HTTP module](./docs/http.md)
160
+ - [Modules overview](./docs/modules.md)
161
+ - [Install and configure Brass Agent](./docs/agent-install-and-configure.md)
162
+ - [Declarative optimized planning roadmap](./docs/agent-declarative-optimized-planning.md)
163
+
164
+ ---
165
+
166
+ ## What’s new (recent changes)
167
+
168
+ - Stream buffering with backpressure (`buffer`)
169
+ - Abortable async integration (`fromPromiseAbortable`)
170
+ - Fiber-safe `toPromise` for examples & DX
171
+ - HTTP client module built on top of the runtime
172
+
173
+ ---
174
+
175
+ ## Features (status)
176
+
177
+ ### Runtime (core)
178
+
179
+ - [x] Sync core: `Effect`
180
+ - [x] Async algebra: `Async`
181
+ - [x] Cooperative `Scheduler`
182
+ - [x] Fibers with interruption & finalizers
183
+ - [x] Structured `Scope`
184
+ - [x] Resource safety (`acquireRelease`)
185
+
186
+ ### Concurrency & Streams
187
+
188
+ - [x] `race`, `zipPar`, `collectAllPar`
189
+ - [x] ZStream-like core
190
+ - [x] Bounded buffers & backpressure
191
+ - [x] Stream merge / zip
192
+ - [x] Hubs / Broadcast
193
+ - [x] Pipelines (`ZPipeline`-style)
194
+
195
+ ### Libraries
196
+
197
+ - [x] HTTP client
198
+ - [ ] Retry / timeout middleware
199
+ - [ ] Logging / metrics layers
200
+
201
+ ---
202
+
203
+ ## Design notes
204
+
205
+ - **No hidden Promises**: async is always modeled explicitly
206
+ - **Deterministic execution**: scheduler is observable & testable
207
+ - **Resource safety is structural**: scopes guarantee cleanup
208
+ - **Libraries compose via functions**: middleware, not inheritance
209
+
210
+ ---
211
+
212
+ ## Contributing
213
+
214
+ - Runtime invariants matter β€” avoid sneaking Promises into semantics
215
+ - Prefer libraries on top of the runtime over changes in the core
216
+ - Small, focused PRs are welcome (your repo may enforce PR-only changes)
217
+
218
+ ---
219
+
220
+ ## License
221
+
222
+ MIT License Β© 2025
223
+
224
+ ## Brass Agent local smoke tests
225
+
226
+ Run local smoke tests without CI or a real LLM provider:
227
+
228
+ ```bash
229
+ npm run agent:test:local
230
+ ```
231
+
232
+ This builds the project and runs a fake-LLM smoke test against the `brass-agent` CLI.
233
+
234
+ See also: [Agent language and workspace setup UX](docs/agent-language-workspace-ux.md).
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "brass-runtime",
3
- "version": "1.13.7",
3
+ "version": "1.13.8",
4
4
  "description": "Effect runtime utilities for TypeScript",
5
5
  "license": "MIT",
6
6
  "author": "Augusto Vivaldelli",