Skip to content

Commit f62fcd8

Browse files
committed
docs: sync README and improvement-plan with prompt slots, git_worktree, SDK API reference
- Fix test count: 1435 → 1402 - Add System Prompt Customization section with Rust/TS/Python examples - Add SystemPromptSlots to architecture diagram - Add prompt_slots to SessionOptions API reference - Add Python SDK and Node.js SDK API reference sections - Add git_worktree examples to Multi-Language SDKs table - Add test_git_worktree to Integration & Feature Tests - Update improvement-plan.md: Phase 8 (git_worktree + prompt slots)
1 parent 9d1384d commit f62fcd8

2 files changed

Lines changed: 174 additions & 4 deletions

File tree

README.md

Lines changed: 157 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ let result = session.send("Refactor auth to use JWT").await?;
1111
[![Crates.io](https://img.shields.io/crates/v/a3s-code-core.svg)](https://crates.io/crates/a3s-code-core)
1212
[![Documentation](https://docs.rs/a3s-code-core/badge.svg)](https://docs.rs/a3s-code-core)
1313
[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](./LICENSE)
14-
[![Tests](https://img.shields.io/badge/tests-1435%20passing-brightgreen.svg)](./core/tests)
14+
[![Tests](https://img.shields.io/badge/tests-1402%20passing-brightgreen.svg)](./core/tests)
1515

1616
---
1717

@@ -312,6 +312,59 @@ Supports Lead/Worker/Reviewer roles, `mpsc` peer messaging, broadcast, and a ful
312312

313313
---
314314

315+
### 🎨 System Prompt Customization (Slot-Based)
316+
317+
Customize the agent's behavior without overriding the core agentic capabilities. The default prompt (tool usage strategy, autonomous behavior, completion criteria) is always preserved:
318+
319+
```rust
320+
use a3s_code_core::{SessionOptions, SystemPromptSlots};
321+
322+
SessionOptions::new()
323+
.with_prompt_slots(SystemPromptSlots {
324+
role: Some("You are a senior Rust developer".into()),
325+
guidelines: Some("Use clippy. No unwrap(). Prefer Result.".into()),
326+
response_style: Some("Be concise. Use bullet points.".into()),
327+
extra: Some("This project uses tokio and axum.".into()),
328+
})
329+
```
330+
331+
| Slot | Position | Behavior |
332+
|------|----------|----------|
333+
| `role` | Before core | Replaces default "You are A3S Code..." identity |
334+
| `guidelines` | After core | Appended as `## Guidelines` section |
335+
| `response_style` | Replaces section | Replaces default `## Response Format` |
336+
| `extra` | End | Freeform instructions (backward-compatible) |
337+
338+
<details>
339+
<summary><b>TypeScript</b></summary>
340+
341+
```typescript
342+
const session = agent.session('.', {
343+
role: 'You are a senior Rust developer',
344+
guidelines: 'Use clippy. No unwrap(). Prefer Result.',
345+
responseStyle: 'Be concise. Use bullet points.',
346+
extra: 'This project uses tokio and axum.',
347+
});
348+
```
349+
350+
</details>
351+
352+
<details>
353+
<summary><b>Python</b></summary>
354+
355+
```python
356+
opts = SessionOptions()
357+
opts.role = "You are a senior Rust developer"
358+
opts.guidelines = "Use clippy. No unwrap(). Prefer Result."
359+
opts.response_style = "Be concise. Use bullet points."
360+
opts.extra = "This project uses tokio and axum."
361+
session = agent.session(".", opts)
362+
```
363+
364+
</details>
365+
366+
---
367+
315368
### 💻 CLI (Terminal Agent)
316369

317370
Interactive AI coding agent in the terminal:
@@ -465,6 +518,7 @@ Agent (config-driven)
465518
├── AgentLoop (core execution engine)
466519
│ ├── ToolExecutor (13 built-in tools, batch parallel execution)
467520
│ ├── ToolIndex (per-turn tool filtering for large MCP sets)
521+
│ ├── SystemPromptSlots (role, guidelines, response_style, extra)
468522
│ ├── Planning (task decomposition + wave execution)
469523
│ └── HITL Confirmation
470524
├── SessionLaneQueue (a3s-lane backed)
@@ -638,13 +692,110 @@ SessionOptions::new()
638692
.with_circuit_breaker(5)
639693
// Queue
640694
.with_queue_config(queue_config)
695+
// Prompt customization (slot-based, preserves core agentic behavior)
696+
.with_prompt_slots(SystemPromptSlots {
697+
role: Some("You are a Python expert".into()),
698+
guidelines: Some("Follow PEP 8".into()),
699+
..Default::default()
700+
})
641701
// Extensions
642702
.with_permission_checker(policy)
643703
.with_confirmation_manager(mgr)
644704
.with_skill_registry(registry)
645705
.with_hook_engine(hooks)
646706
```
647707

708+
### Python SDK
709+
710+
```python
711+
from a3s_code import Agent, SessionOptions, builtin_skills
712+
713+
# Create agent
714+
agent = Agent("agent.hcl")
715+
716+
# Create session
717+
opts = SessionOptions()
718+
opts.model = "anthropic/claude-sonnet-4-20250514"
719+
opts.builtin_skills = True
720+
opts.role = "You are a Python expert"
721+
opts.guidelines = "Follow PEP 8. Use type hints."
722+
session = agent.session(".", opts)
723+
724+
# Send / Stream
725+
result = session.send("Explain auth module")
726+
for event in session.stream("Refactor auth"):
727+
if event.event_type == "text_delta":
728+
print(event.text, end="")
729+
730+
# Direct tools
731+
content = session.read_file("src/main.py")
732+
output = session.bash("pytest")
733+
files = session.glob("**/*.py")
734+
matches = session.grep("TODO")
735+
result = session.tool("git_worktree", {"command": "list"})
736+
737+
# Memory
738+
session.remember_success("task", ["tool"], "result")
739+
items = session.recall_similar("auth", 5)
740+
741+
# Hooks
742+
session.register_hook("audit", "pre_tool_use", handler_fn)
743+
744+
# Queue
745+
stats = session.queue_stats()
746+
dead = session.dead_letters()
747+
748+
# Persistence
749+
session.save()
750+
resumed = agent.resume_session(session.session_id, opts)
751+
```
752+
753+
### Node.js SDK
754+
755+
```typescript
756+
import { Agent } from '@a3s-lab/code';
757+
758+
// Create agent
759+
const agent = await Agent.create('agent.hcl');
760+
761+
// Create session
762+
const session = agent.session('.', {
763+
model: 'anthropic/claude-sonnet-4-20250514',
764+
builtinSkills: true,
765+
role: 'You are a TypeScript expert',
766+
guidelines: 'Use strict mode. Prefer interfaces over types.',
767+
});
768+
769+
// Send / Stream
770+
const result = await session.send('Explain auth module');
771+
const stream = await session.stream('Refactor auth');
772+
for await (const event of stream) {
773+
if (event.type === 'text_delta') process.stdout.write(event.text);
774+
}
775+
776+
// Direct tools
777+
const content = await session.readFile('src/main.ts');
778+
const output = await session.bash('npm test');
779+
const files = await session.glob('**/*.ts');
780+
const matches = await session.grep('TODO');
781+
const result = await session.tool('git_worktree', { command: 'list' });
782+
783+
// Memory
784+
await session.rememberSuccess('task', ['tool'], 'result');
785+
const items = await session.recallSimilar('auth', 5);
786+
787+
// Hooks
788+
session.registerHook('audit', 'pre_tool_use', handlerFn);
789+
790+
// Queue
791+
const stats = await session.queueStats();
792+
const dead = await session.deadLetters();
793+
794+
// Persistence
795+
await session.save();
796+
const resumed = agent.resumeSession(session.sessionId, options);
797+
```
798+
648799
---
649800

650801
## Examples
@@ -676,10 +827,13 @@ cargo run --example 02_streaming
676827

677828
| Language | File | Coverage |
678829
|----------|------|----------|
830+
| Rust | `core/examples/test_git_worktree.rs` | Git worktree tool: direct calls + LLM-driven |
679831
| Python | `sdk/python/examples/agentic_loop_demo.py` | Basic send, streaming, multi-turn, planning, skills, security |
680832
| Python | `sdk/python/examples/advanced_features_demo.py` | Direct tools, hooks, queue/lanes, security, resilience, memory |
833+
| Python | `sdk/python/examples/test_git_worktree.py` | Git worktree tool: direct calls + LLM-driven |
681834
| Node.js | `sdk/node/examples/agentic_loop_demo.js` | Basic send, streaming, multi-turn, planning, skills, security |
682835
| Node.js | `sdk/node/examples/advanced_features_demo.js` | Direct tools, hooks, queue/lanes, security, resilience, memory |
836+
| Node.js | `sdk/node/examples/test_git_worktree.js` | Git worktree tool: direct calls + LLM-driven |
683837

684838
### Integration & Feature Tests
685839

@@ -696,6 +850,7 @@ cargo run --example 02_streaming
696850
- `test_vector_rag` — Semantic code search with filesystem context
697851
- `test_hooks` — Lifecycle hook handlers (audit, block, transform)
698852
- `test_parallel_processing` — Concurrent multi-session workloads
853+
- `test_git_worktree` — Git worktree tool: create, list, remove, status + LLM-driven
699854

700855
---
701856

@@ -706,7 +861,7 @@ cargo test # All tests
706861
cargo test --lib # Unit tests only
707862
```
708863

709-
**Test Coverage:** 1435 tests, 100% pass rate
864+
**Test Coverage:** 1402 tests, 100% pass rate
710865

711866
---
712867

docs/improvement-plan.md

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,12 @@
22

33
## Current State Summary
44

5-
- 5 core components, 14 extension points, 11 built-in tools
6-
- 1422 tests passing, 3 SDKs (Rust/Python/Node.js) + CLI
5+
- 5 core components, 19 extension points, 13 built-in tools
6+
- 1402 tests passing, 3 SDKs (Rust/Python/Node.js) + CLI
77
- Lane-based priority queue with external task distribution
88
- Security, skills, planning, hooks, memory, session persistence all implemented
99
- Slash commands, tool search, agent teams, multi-modal attachments
10+
- Slot-based system prompt customization (role, guidelines, response_style, extra)
1011

1112
---
1213

@@ -98,6 +99,19 @@ Implemented:
9899

99100
---
100101

102+
## Phase 8: Git Worktree + System Prompt Slots ✅
103+
104+
**Status: Complete**
105+
106+
Implemented:
107+
- **Git Worktree Tool**: `git_worktree` builtin with `create`, `list`, `remove`, `status` subcommands for parallel workspace isolation
108+
- **System Prompt Slots**: `SystemPromptSlots` struct replaces `system_prompt: Option<String>` — users customize `role`, `guidelines`, `response_style`, `extra` without overriding core agentic capabilities
109+
- **SDK Alignment**: Prompt slots exposed as `role`, `guidelines`, `response_style`, `extra` fields on `SessionOptions` in both Python and Node.js
110+
- **Backward Compatibility**: Legacy `system_prompt` strings map to `extra` slot via `SystemPromptSlots::from_legacy()`
111+
- **Example Tests**: `test_git_worktree` examples in Rust, Python, and Node.js with real LLM configuration
112+
113+
---
114+
101115
## Priority Matrix
102116

103117
| Phase | Status | Effort | Impact |
@@ -109,5 +123,6 @@ Implemented:
109123
| 5. Sandbox Integration | ✅ Done | High | High |
110124
| 6. Multi-Modal | ✅ Done | High | Medium |
111125
| 7. SDK + Tool Search | ✅ Done | Medium | High |
126+
| 8. Git Worktree + Prompt Slots | ✅ Done | Medium | Medium |
112127

113128
All planned phases are complete. Future work should focus on production hardening, performance optimization, and ecosystem expansion (more MCP servers, more builtin tools).

0 commit comments

Comments
 (0)