maestro-bundle 1.7.0 → 1.9.0
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.
- package/README.md +120 -150
- package/package.json +1 -1
- package/src/cli.mjs +6 -2
- package/templates/bundle-ai-agents-deep/.spec/constitution.md +24 -0
- package/templates/bundle-ai-agents-deep/AGENTS.md +105 -0
- package/templates/bundle-ai-agents-deep/PRD_TEMPLATE.md +161 -0
- package/templates/bundle-ai-agents-deep/skills/deep-agent-backends/SKILL.md +165 -0
- package/templates/bundle-ai-agents-deep/skills/deep-agent-cli/SKILL.md +158 -0
- package/templates/bundle-ai-agents-deep/skills/deep-agent-creation/SKILL.md +165 -0
- package/templates/bundle-ai-agents-deep/skills/deep-agent-deployment/SKILL.md +196 -0
- package/templates/bundle-ai-agents-deep/skills/deep-agent-hitl/SKILL.md +152 -0
- package/templates/bundle-ai-agents-deep/skills/deep-agent-memory/SKILL.md +158 -0
- package/templates/bundle-ai-agents-deep/skills/deep-agent-middleware/SKILL.md +131 -0
- package/templates/bundle-ai-agents-deep/skills/deep-agent-skills-system/SKILL.md +155 -0
- package/templates/bundle-ai-agents-deep/skills/deep-agent-subagents/SKILL.md +141 -0
|
@@ -0,0 +1,161 @@
|
|
|
1
|
+
# Product Requirements Document (PRD)
|
|
2
|
+
|
|
3
|
+
> Este documento define os requisitos do produto. Deve ser preenchido pelo analista de requisitos e/ou pelo dev antes de iniciar o desenvolvimento. O agente AI usa este documento como contexto para entender O QUE construir.
|
|
4
|
+
|
|
5
|
+
## 1. Resumo Executivo
|
|
6
|
+
|
|
7
|
+
<!-- Descreva em 2-3 frases o que é o produto e qual problema resolve -->
|
|
8
|
+
|
|
9
|
+
## 2. Usuários Alvo
|
|
10
|
+
|
|
11
|
+
<!-- Quem vai usar o sistema? Descreva as personas -->
|
|
12
|
+
|
|
13
|
+
### Persona 1: [Nome]
|
|
14
|
+
- **Perfil:**
|
|
15
|
+
- **Objetivos:**
|
|
16
|
+
- **Dores:**
|
|
17
|
+
|
|
18
|
+
## 3. Escopo do MVP
|
|
19
|
+
|
|
20
|
+
### Incluído no MVP
|
|
21
|
+
- [ ] Feature 1
|
|
22
|
+
- [ ] Feature 2
|
|
23
|
+
- [ ] Feature 3
|
|
24
|
+
|
|
25
|
+
### Fora do MVP (futuro)
|
|
26
|
+
- [ ] Feature futura 1
|
|
27
|
+
- [ ] Feature futura 2
|
|
28
|
+
|
|
29
|
+
## 4. User Stories
|
|
30
|
+
|
|
31
|
+
### US01: [Título]
|
|
32
|
+
**Como** [persona], **quero** [ação], **para** [benefício].
|
|
33
|
+
|
|
34
|
+
**Critérios de aceite:**
|
|
35
|
+
- [ ] CA1:
|
|
36
|
+
- [ ] CA2:
|
|
37
|
+
|
|
38
|
+
### US02: [Título]
|
|
39
|
+
**Como** [persona], **quero** [ação], **para** [benefício].
|
|
40
|
+
|
|
41
|
+
**Critérios de aceite:**
|
|
42
|
+
- [ ] CA1:
|
|
43
|
+
- [ ] CA2:
|
|
44
|
+
|
|
45
|
+
## 5. Arquitetura de Alto Nível
|
|
46
|
+
|
|
47
|
+
<!-- Diagrama em Mermaid ou ASCII mostrando os componentes principais -->
|
|
48
|
+
|
|
49
|
+
```mermaid
|
|
50
|
+
graph LR
|
|
51
|
+
A[Frontend] --> B[API]
|
|
52
|
+
B --> C[Database]
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
### Estrutura de Diretórios
|
|
56
|
+
|
|
57
|
+
```
|
|
58
|
+
project/
|
|
59
|
+
├── src/
|
|
60
|
+
├── tests/
|
|
61
|
+
└── ...
|
|
62
|
+
```
|
|
63
|
+
|
|
64
|
+
## 6. Features Detalhadas
|
|
65
|
+
|
|
66
|
+
### Feature 1: [Nome]
|
|
67
|
+
- **Descrição:**
|
|
68
|
+
- **Regras de negócio:**
|
|
69
|
+
-
|
|
70
|
+
- **Inputs:**
|
|
71
|
+
- **Outputs:**
|
|
72
|
+
- **Edge cases:**
|
|
73
|
+
-
|
|
74
|
+
|
|
75
|
+
### Feature 2: [Nome]
|
|
76
|
+
- **Descrição:**
|
|
77
|
+
- **Regras de negócio:**
|
|
78
|
+
-
|
|
79
|
+
|
|
80
|
+
## 7. Stack Tecnológica
|
|
81
|
+
|
|
82
|
+
| Componente | Tecnologia | Justificativa |
|
|
83
|
+
|---|---|---|
|
|
84
|
+
| Backend | | |
|
|
85
|
+
| Frontend | | |
|
|
86
|
+
| Banco de dados | | |
|
|
87
|
+
| Cache | | |
|
|
88
|
+
| Deploy | | |
|
|
89
|
+
|
|
90
|
+
## 8. API Specification
|
|
91
|
+
|
|
92
|
+
### Endpoints
|
|
93
|
+
|
|
94
|
+
#### `GET /api/v1/resource`
|
|
95
|
+
- **Descrição:**
|
|
96
|
+
- **Response:** `200 OK`
|
|
97
|
+
```json
|
|
98
|
+
{
|
|
99
|
+
"items": [],
|
|
100
|
+
"total": 0,
|
|
101
|
+
"page": 1,
|
|
102
|
+
"size": 20
|
|
103
|
+
}
|
|
104
|
+
```
|
|
105
|
+
|
|
106
|
+
#### `POST /api/v1/resource`
|
|
107
|
+
- **Descrição:**
|
|
108
|
+
- **Body:**
|
|
109
|
+
```json
|
|
110
|
+
{
|
|
111
|
+
"field": "value"
|
|
112
|
+
}
|
|
113
|
+
```
|
|
114
|
+
- **Response:** `201 Created`
|
|
115
|
+
|
|
116
|
+
## 9. Modelo de Dados
|
|
117
|
+
|
|
118
|
+
```sql
|
|
119
|
+
CREATE TABLE example (
|
|
120
|
+
id UUID PRIMARY KEY DEFAULT gen_random_uuid(),
|
|
121
|
+
name VARCHAR(100) NOT NULL,
|
|
122
|
+
created_at TIMESTAMP DEFAULT NOW()
|
|
123
|
+
);
|
|
124
|
+
```
|
|
125
|
+
|
|
126
|
+
## 10. Requisitos Não-Funcionais
|
|
127
|
+
|
|
128
|
+
| Requisito | Alvo | Prioridade |
|
|
129
|
+
|---|---|---|
|
|
130
|
+
| Performance | Response time < 500ms | Alta |
|
|
131
|
+
| Disponibilidade | 99.9% uptime | Média |
|
|
132
|
+
| Segurança | OWASP Top 10 | Alta |
|
|
133
|
+
| Escalabilidade | Até X usuários simultâneos | Média |
|
|
134
|
+
|
|
135
|
+
## 11. Fases de Implementação
|
|
136
|
+
|
|
137
|
+
### Fase 1: Foundation
|
|
138
|
+
- [ ] Setup do projeto
|
|
139
|
+
- [ ] Modelo de dados
|
|
140
|
+
- [ ] Endpoints básicos
|
|
141
|
+
|
|
142
|
+
### Fase 2: Core Features
|
|
143
|
+
- [ ] Feature 1 completa
|
|
144
|
+
- [ ] Feature 2 completa
|
|
145
|
+
|
|
146
|
+
### Fase 3: Polish
|
|
147
|
+
- [ ] Testes E2E
|
|
148
|
+
- [ ] Performance
|
|
149
|
+
- [ ] Documentação
|
|
150
|
+
|
|
151
|
+
## 12. Riscos e Mitigações
|
|
152
|
+
|
|
153
|
+
| Risco | Impacto | Probabilidade | Mitigação |
|
|
154
|
+
|---|---|---|---|
|
|
155
|
+
| | | | |
|
|
156
|
+
|
|
157
|
+
## 13. Critérios de Sucesso
|
|
158
|
+
|
|
159
|
+
- [ ] Critério 1
|
|
160
|
+
- [ ] Critério 2
|
|
161
|
+
- [ ] Critério 3
|
|
@@ -0,0 +1,165 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: deep-agent-backends
|
|
3
|
+
description: Configure Deep Agent backends (StateBackend, FilesystemBackend, StoreBackend, LocalShellBackend, CompositeBackend, Sandboxes). Use when choosing storage, configuring file access, or setting up persistent state.
|
|
4
|
+
version: 1.0.0
|
|
5
|
+
author: Maestro
|
|
6
|
+
---
|
|
7
|
+
|
|
8
|
+
# Deep Agent Backends
|
|
9
|
+
|
|
10
|
+
Configure how your Deep Agent stores files and manages context. Backends determine where files live — in memory, on disk, in a database, or in a sandbox.
|
|
11
|
+
|
|
12
|
+
## When to Use
|
|
13
|
+
- When choosing between ephemeral vs persistent storage
|
|
14
|
+
- When the agent needs local filesystem access
|
|
15
|
+
- When you need shell execution capability
|
|
16
|
+
- When routing different paths to different storage
|
|
17
|
+
- When running in sandboxed environments (Modal, Daytona)
|
|
18
|
+
|
|
19
|
+
## Available Operations
|
|
20
|
+
1. Use StateBackend (ephemeral, default)
|
|
21
|
+
2. Use FilesystemBackend (local disk)
|
|
22
|
+
3. Use StoreBackend (persistent, cross-thread)
|
|
23
|
+
4. Use LocalShellBackend (filesystem + shell)
|
|
24
|
+
5. Use CompositeBackend (route paths to backends)
|
|
25
|
+
6. Use Sandboxes (isolated execution)
|
|
26
|
+
|
|
27
|
+
## Multi-Step Workflow
|
|
28
|
+
|
|
29
|
+
### Step 1: Choose Your Backend
|
|
30
|
+
|
|
31
|
+
| Backend | Persistence | Shell | Use when |
|
|
32
|
+
|---|---|---|---|
|
|
33
|
+
| StateBackend | Ephemeral (1 thread) | No | Prototyping, stateless tasks |
|
|
34
|
+
| FilesystemBackend | Local disk | No | Read/write project files |
|
|
35
|
+
| StoreBackend | DB (cross-thread) | No | Persistent memory, multi-session |
|
|
36
|
+
| LocalShellBackend | Local disk | Yes | Full coding agent (like Claude Code) |
|
|
37
|
+
| CompositeBackend | Mixed | Mixed | Different storage per path |
|
|
38
|
+
| Sandboxes | Isolated | Yes | Untrusted code execution |
|
|
39
|
+
|
|
40
|
+
### Step 2: StateBackend (Default)
|
|
41
|
+
|
|
42
|
+
```python
|
|
43
|
+
from deepagents import create_deep_agent
|
|
44
|
+
|
|
45
|
+
# Uses StateBackend automatically — files live in memory, gone after session
|
|
46
|
+
agent = create_deep_agent(model="anthropic:claude-sonnet-4-6")
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
### Step 3: FilesystemBackend (Local Files)
|
|
50
|
+
|
|
51
|
+
```python
|
|
52
|
+
from deepagents import create_deep_agent
|
|
53
|
+
from deepagents.backends import FilesystemBackend
|
|
54
|
+
|
|
55
|
+
agent = create_deep_agent(
|
|
56
|
+
model="anthropic:claude-sonnet-4-6",
|
|
57
|
+
backend=FilesystemBackend(root_dir=".", virtual_mode=True)
|
|
58
|
+
)
|
|
59
|
+
# Agent can now read/write files in the project directory
|
|
60
|
+
```
|
|
61
|
+
|
|
62
|
+
### Step 4: LocalShellBackend (Full Coding Agent)
|
|
63
|
+
|
|
64
|
+
```python
|
|
65
|
+
from deepagents import create_deep_agent
|
|
66
|
+
from deepagents.backends import LocalShellBackend
|
|
67
|
+
|
|
68
|
+
# WARNING: Agent can execute shell commands on your machine
|
|
69
|
+
agent = create_deep_agent(
|
|
70
|
+
model="anthropic:claude-sonnet-4-6",
|
|
71
|
+
backend=LocalShellBackend(
|
|
72
|
+
root_dir=".",
|
|
73
|
+
env={"PATH": "/usr/bin:/bin", "HOME": "/home/user"}
|
|
74
|
+
)
|
|
75
|
+
)
|
|
76
|
+
# Agent can now: read/write files, run shell commands, install packages
|
|
77
|
+
```
|
|
78
|
+
|
|
79
|
+
### Step 5: StoreBackend (Persistent Memory)
|
|
80
|
+
|
|
81
|
+
```python
|
|
82
|
+
from deepagents import create_deep_agent
|
|
83
|
+
from deepagents.backends import StoreBackend
|
|
84
|
+
from langgraph.store.memory import InMemoryStore
|
|
85
|
+
# Or for real persistence:
|
|
86
|
+
# from langgraph.store.postgres import PostgresStore
|
|
87
|
+
|
|
88
|
+
store = InMemoryStore()
|
|
89
|
+
|
|
90
|
+
agent = create_deep_agent(
|
|
91
|
+
model="anthropic:claude-sonnet-4-6",
|
|
92
|
+
backend=lambda rt: StoreBackend(rt),
|
|
93
|
+
store=store # Required for StoreBackend
|
|
94
|
+
)
|
|
95
|
+
```
|
|
96
|
+
|
|
97
|
+
### Step 6: CompositeBackend (Route by Path)
|
|
98
|
+
|
|
99
|
+
```python
|
|
100
|
+
from deepagents import create_deep_agent
|
|
101
|
+
from deepagents.backends import CompositeBackend, StateBackend, StoreBackend
|
|
102
|
+
from langgraph.store.memory import InMemoryStore
|
|
103
|
+
|
|
104
|
+
composite = lambda rt: CompositeBackend(
|
|
105
|
+
default=StateBackend(rt), # Everything else: ephemeral
|
|
106
|
+
routes={
|
|
107
|
+
"/memories/": StoreBackend(rt), # Memories: persistent
|
|
108
|
+
}
|
|
109
|
+
)
|
|
110
|
+
|
|
111
|
+
agent = create_deep_agent(
|
|
112
|
+
backend=composite,
|
|
113
|
+
store=InMemoryStore()
|
|
114
|
+
)
|
|
115
|
+
```
|
|
116
|
+
|
|
117
|
+
### Step 7: Verify
|
|
118
|
+
|
|
119
|
+
```bash
|
|
120
|
+
python -c "
|
|
121
|
+
from deepagents import create_deep_agent
|
|
122
|
+
from deepagents.backends import FilesystemBackend
|
|
123
|
+
|
|
124
|
+
agent = create_deep_agent(
|
|
125
|
+
backend=FilesystemBackend(root_dir='.', virtual_mode=True)
|
|
126
|
+
)
|
|
127
|
+
result = agent.invoke({
|
|
128
|
+
'messages': [{'role': 'user', 'content': 'List files in the current directory'}]
|
|
129
|
+
})
|
|
130
|
+
print(result['messages'][-1].content)
|
|
131
|
+
"
|
|
132
|
+
```
|
|
133
|
+
|
|
134
|
+
## Resources
|
|
135
|
+
- `references/backends-guide.md` — Detailed backend comparison and configuration
|
|
136
|
+
|
|
137
|
+
## Examples
|
|
138
|
+
|
|
139
|
+
### Example 1: Coding Agent with File Access
|
|
140
|
+
User asks: "Create an agent that can edit my project files"
|
|
141
|
+
Response approach:
|
|
142
|
+
1. Use `FilesystemBackend(root_dir=".", virtual_mode=True)`
|
|
143
|
+
2. Agent gets `ls`, `read_file`, `write_file`, `edit_file` tools
|
|
144
|
+
3. Test with "list files" command
|
|
145
|
+
|
|
146
|
+
### Example 2: Agent with Persistent Memory
|
|
147
|
+
User asks: "Agent should remember things across sessions"
|
|
148
|
+
Response approach:
|
|
149
|
+
1. Use `CompositeBackend` with `StoreBackend` for `/memories/`
|
|
150
|
+
2. Set up PostgresStore for production
|
|
151
|
+
3. Agent writes to `/memories/` for long-term storage
|
|
152
|
+
|
|
153
|
+
### Example 3: Full Coding Agent (like Claude Code)
|
|
154
|
+
User asks: "Build an agent that can run tests and install packages"
|
|
155
|
+
Response approach:
|
|
156
|
+
1. Use `LocalShellBackend(root_dir=".")`
|
|
157
|
+
2. Agent gets shell execution + file access
|
|
158
|
+
3. Add safety: limit commands, use virtual env
|
|
159
|
+
|
|
160
|
+
## Notes
|
|
161
|
+
- StateBackend is ephemeral — files are gone after the session
|
|
162
|
+
- FilesystemBackend `virtual_mode=True` is safer (sandboxed paths)
|
|
163
|
+
- LocalShellBackend gives full shell access — use with caution
|
|
164
|
+
- StoreBackend REQUIRES a `store` parameter
|
|
165
|
+
- CompositeBackend is the production choice (ephemeral default + persistent memory)
|
|
@@ -0,0 +1,158 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: deep-agent-cli
|
|
3
|
+
description: Build and use the Deep Agents CLI for terminal-based coding agents. Use when creating a CLI coding agent, running Deep Agents from terminal, or building a Claude Code-like experience.
|
|
4
|
+
version: 1.0.0
|
|
5
|
+
author: Maestro
|
|
6
|
+
---
|
|
7
|
+
|
|
8
|
+
# Deep Agents CLI
|
|
9
|
+
|
|
10
|
+
Build a terminal-based coding agent similar to Claude Code using the Deep Agents CLI or by creating your own CLI interface.
|
|
11
|
+
|
|
12
|
+
## When to Use
|
|
13
|
+
- When you want a Claude Code-like experience in the terminal
|
|
14
|
+
- When building a CLI tool for AI-assisted coding
|
|
15
|
+
- When running Deep Agents interactively
|
|
16
|
+
|
|
17
|
+
## Available Operations
|
|
18
|
+
1. Install and use the official Deep Agents CLI
|
|
19
|
+
2. Build a custom CLI with rich terminal UI
|
|
20
|
+
3. Configure CLI with local file access + shell
|
|
21
|
+
4. Add skills and AGENTS.md to CLI agent
|
|
22
|
+
|
|
23
|
+
## Multi-Step Workflow
|
|
24
|
+
|
|
25
|
+
### Step 1: Install Deep Agents CLI
|
|
26
|
+
|
|
27
|
+
```bash
|
|
28
|
+
pip install deepagents
|
|
29
|
+
# or
|
|
30
|
+
uv tool install deepagents
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
### Step 2: Run the CLI
|
|
34
|
+
|
|
35
|
+
```bash
|
|
36
|
+
# Start interactive session
|
|
37
|
+
deepagents
|
|
38
|
+
|
|
39
|
+
# Start with a specific model
|
|
40
|
+
deepagents --model anthropic:claude-sonnet-4-6
|
|
41
|
+
|
|
42
|
+
# Start in a specific directory
|
|
43
|
+
deepagents --dir ./my-project
|
|
44
|
+
|
|
45
|
+
# Start with a prompt
|
|
46
|
+
deepagents "Fix the failing tests in src/auth/"
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
### Step 3: Build Custom CLI
|
|
50
|
+
|
|
51
|
+
```python
|
|
52
|
+
# cli.py
|
|
53
|
+
import asyncio
|
|
54
|
+
import sys
|
|
55
|
+
from deepagents import create_deep_agent
|
|
56
|
+
from deepagents.backends import LocalShellBackend
|
|
57
|
+
from langgraph.checkpoint.memory import MemorySaver
|
|
58
|
+
|
|
59
|
+
async def main():
|
|
60
|
+
# Full coding agent with file + shell access
|
|
61
|
+
agent = create_deep_agent(
|
|
62
|
+
model="anthropic:claude-sonnet-4-6",
|
|
63
|
+
backend=LocalShellBackend(root_dir="."),
|
|
64
|
+
skills=["./skills/"],
|
|
65
|
+
memory=["/AGENTS.md"],
|
|
66
|
+
checkpointer=MemorySaver(),
|
|
67
|
+
system_prompt="You are a coding assistant. Follow the project conventions."
|
|
68
|
+
)
|
|
69
|
+
|
|
70
|
+
config = {"configurable": {"thread_id": "cli-session"}}
|
|
71
|
+
|
|
72
|
+
# One-shot mode
|
|
73
|
+
if len(sys.argv) > 1:
|
|
74
|
+
prompt = " ".join(sys.argv[1:])
|
|
75
|
+
async for event in agent.astream_events(
|
|
76
|
+
{"messages": [{"role": "user", "content": prompt}]},
|
|
77
|
+
config=config, version="v2"
|
|
78
|
+
):
|
|
79
|
+
if event["event"] == "on_chat_model_stream":
|
|
80
|
+
print(event["data"]["chunk"].content, end="", flush=True)
|
|
81
|
+
print()
|
|
82
|
+
return
|
|
83
|
+
|
|
84
|
+
# Interactive mode
|
|
85
|
+
print("Coding Agent (type 'exit' to quit)\n")
|
|
86
|
+
while True:
|
|
87
|
+
try:
|
|
88
|
+
user_input = input("> ")
|
|
89
|
+
except (EOFError, KeyboardInterrupt):
|
|
90
|
+
break
|
|
91
|
+
|
|
92
|
+
if user_input.lower() in ("exit", "quit"):
|
|
93
|
+
break
|
|
94
|
+
|
|
95
|
+
async for event in agent.astream_events(
|
|
96
|
+
{"messages": [{"role": "user", "content": user_input}]},
|
|
97
|
+
config=config, version="v2"
|
|
98
|
+
):
|
|
99
|
+
if event["event"] == "on_chat_model_stream":
|
|
100
|
+
print(event["data"]["chunk"].content, end="", flush=True)
|
|
101
|
+
print("\n")
|
|
102
|
+
|
|
103
|
+
asyncio.run(main())
|
|
104
|
+
```
|
|
105
|
+
|
|
106
|
+
### Step 4: Make it Installable
|
|
107
|
+
|
|
108
|
+
```toml
|
|
109
|
+
# pyproject.toml
|
|
110
|
+
[project]
|
|
111
|
+
name = "my-coding-agent"
|
|
112
|
+
version = "0.1.0"
|
|
113
|
+
dependencies = ["deepagents"]
|
|
114
|
+
|
|
115
|
+
[project.scripts]
|
|
116
|
+
myagent = "cli:main"
|
|
117
|
+
```
|
|
118
|
+
|
|
119
|
+
```bash
|
|
120
|
+
pip install -e .
|
|
121
|
+
myagent "Fix the auth tests"
|
|
122
|
+
```
|
|
123
|
+
|
|
124
|
+
### Step 5: Verify
|
|
125
|
+
|
|
126
|
+
```bash
|
|
127
|
+
# Run the CLI
|
|
128
|
+
python cli.py "List the files in the current directory"
|
|
129
|
+
|
|
130
|
+
# Interactive mode
|
|
131
|
+
python cli.py
|
|
132
|
+
```
|
|
133
|
+
|
|
134
|
+
## Resources
|
|
135
|
+
- `references/cli-patterns.md` — CLI design patterns
|
|
136
|
+
|
|
137
|
+
## Examples
|
|
138
|
+
|
|
139
|
+
### Example 1: Simple Coding Agent
|
|
140
|
+
User asks: "Create a CLI that can edit files and run tests"
|
|
141
|
+
Response approach:
|
|
142
|
+
1. Use `LocalShellBackend(root_dir=".")`
|
|
143
|
+
2. Add `skills=["./skills/"]` for project skills
|
|
144
|
+
3. Stream output with `astream_events`
|
|
145
|
+
4. Test in project directory
|
|
146
|
+
|
|
147
|
+
### Example 2: Add Project Context
|
|
148
|
+
User asks: "Agent should know our project conventions"
|
|
149
|
+
Response approach:
|
|
150
|
+
1. Create AGENTS.md with conventions
|
|
151
|
+
2. Pass `memory=["/AGENTS.md"]`
|
|
152
|
+
3. Agent loads it at startup
|
|
153
|
+
|
|
154
|
+
## Notes
|
|
155
|
+
- LocalShellBackend gives full filesystem + shell — use responsibly
|
|
156
|
+
- Always use `astream_events` for real-time output in CLI
|
|
157
|
+
- `checkpointer` enables conversation memory within session
|
|
158
|
+
- Skills load on-demand as user asks for things
|
|
@@ -0,0 +1,165 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: deep-agent-creation
|
|
3
|
+
description: Create Deep Agents with create_deep_agent(), configure model, tools, system prompt, and run. Use when starting a new deep agent project, configuring an agent, or adding tools.
|
|
4
|
+
version: 1.0.0
|
|
5
|
+
author: Maestro
|
|
6
|
+
---
|
|
7
|
+
|
|
8
|
+
# Deep Agent Creation
|
|
9
|
+
|
|
10
|
+
Create and configure Deep Agents using `create_deep_agent()` with tools, system prompts, and model selection.
|
|
11
|
+
|
|
12
|
+
## When to Use
|
|
13
|
+
- When creating a new Deep Agent from scratch
|
|
14
|
+
- When adding custom tools to an agent
|
|
15
|
+
- When configuring model and system prompt
|
|
16
|
+
- When setting up the main agent entry point
|
|
17
|
+
|
|
18
|
+
## Available Operations
|
|
19
|
+
1. Install Deep Agents SDK
|
|
20
|
+
2. Define custom tools
|
|
21
|
+
3. Create agent with `create_deep_agent()`
|
|
22
|
+
4. Run agent with `invoke()` or `stream()`
|
|
23
|
+
5. Configure model provider
|
|
24
|
+
|
|
25
|
+
## Multi-Step Workflow
|
|
26
|
+
|
|
27
|
+
### Step 1: Install
|
|
28
|
+
|
|
29
|
+
```bash
|
|
30
|
+
pip install deepagents
|
|
31
|
+
# or
|
|
32
|
+
uv add deepagents
|
|
33
|
+
|
|
34
|
+
# For search capability
|
|
35
|
+
pip install tavily-python
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
### Step 2: Set API Keys
|
|
39
|
+
|
|
40
|
+
```bash
|
|
41
|
+
export ANTHROPIC_API_KEY=your-key
|
|
42
|
+
# or
|
|
43
|
+
export OPENAI_API_KEY=your-key
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
### Step 3: Define Custom Tools
|
|
47
|
+
|
|
48
|
+
```python
|
|
49
|
+
# agent/tools.py
|
|
50
|
+
from langchain.tools import tool
|
|
51
|
+
|
|
52
|
+
@tool
|
|
53
|
+
def search_codebase(query: str, file_pattern: str = "**/*.py") -> str:
|
|
54
|
+
"""Search the codebase for files matching a pattern and containing a query."""
|
|
55
|
+
import glob
|
|
56
|
+
results = []
|
|
57
|
+
for filepath in glob.glob(file_pattern, recursive=True):
|
|
58
|
+
with open(filepath) as f:
|
|
59
|
+
content = f.read()
|
|
60
|
+
if query.lower() in content.lower():
|
|
61
|
+
results.append(f"Found in {filepath}")
|
|
62
|
+
return "\n".join(results) if results else "No matches found"
|
|
63
|
+
|
|
64
|
+
@tool
|
|
65
|
+
def run_tests(test_path: str = "tests/") -> str:
|
|
66
|
+
"""Run pytest on the specified path and return results."""
|
|
67
|
+
import subprocess
|
|
68
|
+
result = subprocess.run(
|
|
69
|
+
["pytest", test_path, "-v", "--tb=short"],
|
|
70
|
+
capture_output=True, text=True, timeout=120
|
|
71
|
+
)
|
|
72
|
+
return result.stdout + result.stderr
|
|
73
|
+
|
|
74
|
+
@tool
|
|
75
|
+
def lint_code(path: str = "src/") -> str:
|
|
76
|
+
"""Run ruff linter on the specified path."""
|
|
77
|
+
import subprocess
|
|
78
|
+
result = subprocess.run(
|
|
79
|
+
["ruff", "check", path],
|
|
80
|
+
capture_output=True, text=True
|
|
81
|
+
)
|
|
82
|
+
return result.stdout or "No lint issues found"
|
|
83
|
+
```
|
|
84
|
+
|
|
85
|
+
### Step 4: Create the Agent
|
|
86
|
+
|
|
87
|
+
```python
|
|
88
|
+
# agent/main.py
|
|
89
|
+
from deepagents import create_deep_agent
|
|
90
|
+
from agent.tools import search_codebase, run_tests, lint_code
|
|
91
|
+
|
|
92
|
+
agent = create_deep_agent(
|
|
93
|
+
model="anthropic:claude-sonnet-4-6",
|
|
94
|
+
tools=[search_codebase, run_tests, lint_code],
|
|
95
|
+
system_prompt="""You are a coding assistant that helps developers write,
|
|
96
|
+
test, and review code. You follow clean architecture principles and
|
|
97
|
+
always run tests after making changes."""
|
|
98
|
+
)
|
|
99
|
+
|
|
100
|
+
# Run
|
|
101
|
+
config = {"configurable": {"thread_id": "session-1"}}
|
|
102
|
+
result = agent.invoke(
|
|
103
|
+
{"messages": [{"role": "user", "content": "Review the auth module"}]},
|
|
104
|
+
config=config
|
|
105
|
+
)
|
|
106
|
+
print(result["messages"][-1].content)
|
|
107
|
+
```
|
|
108
|
+
|
|
109
|
+
### Step 5: Stream Responses
|
|
110
|
+
|
|
111
|
+
```python
|
|
112
|
+
# For real-time output (like Claude Code)
|
|
113
|
+
async for event in agent.astream_events(
|
|
114
|
+
{"messages": [{"role": "user", "content": "Fix the failing tests"}]},
|
|
115
|
+
config=config,
|
|
116
|
+
version="v2"
|
|
117
|
+
):
|
|
118
|
+
if event["event"] == "on_chat_model_stream":
|
|
119
|
+
print(event["data"]["chunk"].content, end="", flush=True)
|
|
120
|
+
```
|
|
121
|
+
|
|
122
|
+
### Step 6: Verify
|
|
123
|
+
|
|
124
|
+
```bash
|
|
125
|
+
# Run the agent
|
|
126
|
+
python agent/main.py
|
|
127
|
+
|
|
128
|
+
# Run tests
|
|
129
|
+
pytest tests/ -v
|
|
130
|
+
```
|
|
131
|
+
|
|
132
|
+
## Resources
|
|
133
|
+
- `references/deep-agents-api.md` — Full API reference for create_deep_agent()
|
|
134
|
+
- `references/model-providers.md` — Supported model providers and format
|
|
135
|
+
|
|
136
|
+
## Examples
|
|
137
|
+
|
|
138
|
+
### Example 1: Minimal Agent
|
|
139
|
+
User asks: "Create a simple deep agent with web search"
|
|
140
|
+
Response approach:
|
|
141
|
+
1. `pip install deepagents tavily-python`
|
|
142
|
+
2. Create `@tool` for Tavily search
|
|
143
|
+
3. Call `create_deep_agent(tools=[search])`
|
|
144
|
+
4. Test with `agent.invoke()`
|
|
145
|
+
|
|
146
|
+
### Example 2: Coding Agent
|
|
147
|
+
User asks: "Create an agent that can edit files and run tests"
|
|
148
|
+
Response approach:
|
|
149
|
+
1. Define tools: `run_tests`, `lint_code`, `search_codebase`
|
|
150
|
+
2. Use `FilesystemBackend` for file access
|
|
151
|
+
3. Add system prompt with coding conventions
|
|
152
|
+
4. Test end-to-end
|
|
153
|
+
|
|
154
|
+
### Example 3: Multi-Model Agent
|
|
155
|
+
User asks: "Use Claude for reasoning and GPT for code generation"
|
|
156
|
+
Response approach:
|
|
157
|
+
1. Main agent: `model="anthropic:claude-sonnet-4-6"`
|
|
158
|
+
2. Subagent for code: `model="openai:gpt-4o"`
|
|
159
|
+
3. Route tasks based on type
|
|
160
|
+
|
|
161
|
+
## Notes
|
|
162
|
+
- Built-in tools: `write_todos`, `ls`, `read_file`, `write_file`, `edit_file`, `glob`, `grep`, `task`
|
|
163
|
+
- Model format: `"provider:model-name"` (e.g., `"anthropic:claude-sonnet-4-6"`)
|
|
164
|
+
- Always use `thread_id` for conversation persistence
|
|
165
|
+
- System prompt is appended to built-in prompts, not replaces them
|