|
23 | 23 | **A3S Code** is an embeddable Rust library (`a3s-code-core`) for building AI coding agents. All subsystems — hooks, security, memory, MCP/LSP, subagent delegation, planning — are wired into the core execution path and active by default. Configure via HCL or JSON, create an `Agent`, bind sessions to workspaces, and go. |
24 | 24 |
|
25 | 25 | ```rust |
26 | | -use a3s_code_core::{Agent, AgentSession, CodeConfig}; |
| 26 | +use a3s_code_core::{Agent, AgentEvent}; |
27 | 27 |
|
28 | | -// Load config (HCL or JSON) |
29 | | -let config = CodeConfig::from_file("agent.hcl")?; |
30 | | - |
31 | | -let agent = Agent::builder() |
32 | | - .with_config(config) |
33 | | - .build() |
34 | | - .await?; |
| 28 | +// Load config (HCL or JSON) — one line |
| 29 | +let agent = Agent::new("agent.hcl").await?; |
35 | 30 |
|
36 | 31 | // Create a workspace-bound session |
37 | 32 | let session = agent.session("/my-project"); |
@@ -182,41 +177,32 @@ let config = CodeConfig { |
182 | 177 | ..Default::default() |
183 | 178 | }; |
184 | 179 |
|
185 | | -let agent = Agent::builder() |
186 | | - .with_config(config) |
187 | | - .build() |
188 | | - .await?; |
189 | | - |
190 | | -// Or from file (auto-detects HCL/JSON) |
191 | | -let agent = Agent::builder() |
192 | | - .with_config_file("agent.hcl")? |
193 | | - .build() |
194 | | - .await?; |
195 | | - |
196 | | -// Or from strings |
197 | | -let agent = Agent::builder() |
198 | | - .with_config_hcl(hcl_string)? |
199 | | - .build() |
200 | | - .await?; |
201 | | - |
202 | | -let agent = Agent::builder() |
203 | | - .with_config_json(json_string)? |
204 | | - .build() |
205 | | - .await?; |
| 180 | +let agent = Agent::from_config(config).await?; |
| 181 | + |
| 182 | +// Or from file path (auto-detects HCL/JSON) |
| 183 | +let agent = Agent::new("agent.hcl").await?; |
| 184 | + |
| 185 | +// Or from inline strings (auto-detects JSON vs HCL) |
| 186 | +let agent = Agent::new(r#"{"defaultProvider": "anthropic", ...}"#).await?; |
206 | 187 | ``` |
207 | 188 |
|
208 | | -### Builder Options |
| 189 | +### Config Options |
209 | 190 |
|
210 | | -```rust |
211 | | -let agent = Agent::builder() |
212 | | - .with_config(config) |
213 | | - .system_prompt("You are a senior Rust engineer.") |
214 | | - .max_tool_rounds(20) |
215 | | - .thinking_budget(4096) |
216 | | - .with_hooks(hook_engine) |
217 | | - .extra_tools(custom_tools) |
218 | | - .build() |
219 | | - .await?; |
| 191 | +```hcl |
| 192 | +default_provider = "anthropic" |
| 193 | +default_model = "claude-sonnet-4-20250514" |
| 194 | +system_prompt = "You are a senior Rust engineer." |
| 195 | +max_tool_rounds = 20 |
| 196 | +
|
| 197 | +providers { |
| 198 | + name = "anthropic" |
| 199 | + api_key = "sk-ant-..." |
| 200 | +
|
| 201 | + models { |
| 202 | + id = "claude-sonnet-4-20250514" |
| 203 | + name = "Claude Sonnet 4" |
| 204 | + } |
| 205 | +} |
220 | 206 | ``` |
221 | 207 |
|
222 | 208 | ## Architecture |
@@ -312,7 +298,7 @@ code/ # Cargo workspace root |
312 | 298 | │ ├── skills/ # Built-in skills (tool definitions, skill discovery) |
313 | 299 | │ └── src/ |
314 | 300 | │ ├── lib.rs # Library entry point + re-exports |
315 | | -│ ├── agent_api.rs # Agent / AgentSession / AgentBuilder facade |
| 301 | +│ ├── agent_api.rs # Agent / AgentSession facade |
316 | 302 | │ ├── agent.rs # Agentic loop execution engine |
317 | 303 | │ ├── config.rs # Configuration (HCL + JSON) |
318 | 304 | │ ├── session.rs # Session management |
@@ -356,7 +342,7 @@ Core agent loop, 11 tools, multi-session management, permission system, HITL, sk |
356 | 342 | ### Phase 10: Library-First Architecture ✅ |
357 | 343 |
|
358 | 344 | - [x] Extract all business logic into `a3s-code-core` — pure Rust library, zero server dependencies |
359 | | -- [x] `Agent` / `AgentSession` facade with config-driven builder pattern |
| 345 | +- [x] `Agent::new()` / `Agent::from_config()` facade with config-driven constructors |
360 | 346 | - [x] HCL and JSON configuration support with auto-detection by file extension |
361 | 347 | - [x] Multi-provider LLM config (default model required, multiple providers optional) |
362 | 348 | - [x] All 11 tools callable via direct function calls without serialization |
|
0 commit comments