maestro-bundle 1.7.0 → 1.8.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/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
package/package.json
CHANGED
package/src/cli.mjs
CHANGED
|
@@ -33,6 +33,10 @@ const BUNDLES = {
|
|
|
33
33
|
name: "Frontend SPA",
|
|
34
34
|
desc: "React + TypeScript + Tailwind + Vite",
|
|
35
35
|
},
|
|
36
|
+
"ai-agents-deep": {
|
|
37
|
+
name: "Deep Agent (tipo Claude Code)",
|
|
38
|
+
desc: "Python + Deep Agents SDK + LangGraph + Subagentes + Skills",
|
|
39
|
+
},
|
|
36
40
|
};
|
|
37
41
|
|
|
38
42
|
// ============================================================
|
|
@@ -321,8 +325,8 @@ async function main() {
|
|
|
321
325
|
}
|
|
322
326
|
spinner2.succeed(`${skills.length} skills canônicas em skills/`);
|
|
323
327
|
|
|
324
|
-
// 3. LangChain Skills (
|
|
325
|
-
if (bundleName === "ai-agents") {
|
|
328
|
+
// 3. LangChain Skills (para bundles de AI)
|
|
329
|
+
if (bundleName === "ai-agents" || bundleName === "ai-agents-deep") {
|
|
326
330
|
const spinnerLc = ora("Instalando LangChain Skills (langchain-ai/langchain-skills)").start();
|
|
327
331
|
try {
|
|
328
332
|
// Instalar todas as 11 skills do LangChain para o editor escolhido
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
# Constitution — Projeto Deep Agent
|
|
2
|
+
|
|
3
|
+
## Princípios
|
|
4
|
+
|
|
5
|
+
1. **Spec primeiro, código depois** — Toda demanda passa pelo fluxo SDD antes de implementação
|
|
6
|
+
2. **Agent harness completo** — Todo Deep Agent tem: tools, system prompt, middleware, backend, checkpointer
|
|
7
|
+
3. **Subagentes para isolamento** — Tarefas especializadas vão para subagentes, nunca bloat no main
|
|
8
|
+
4. **Human-in-the-loop obrigatório** — Operações destrutivas sempre pedem aprovação
|
|
9
|
+
5. **Skills on-demand** — Carregar conhecimento quando relevante, não no startup
|
|
10
|
+
|
|
11
|
+
## Padrões de desenvolvimento
|
|
12
|
+
|
|
13
|
+
- Python 3.11+, type hints, Black + Ruff
|
|
14
|
+
- Tools com schemas Pydantic e descrições claras
|
|
15
|
+
- System prompts versionados em código
|
|
16
|
+
- Checkpointer obrigatório (MemorySaver dev, PostgresSaver prod)
|
|
17
|
+
- Backend explícito (nunca confiar no StateBackend default em prod)
|
|
18
|
+
|
|
19
|
+
## Padrões de qualidade
|
|
20
|
+
|
|
21
|
+
- Evals com golden dataset antes de deploy
|
|
22
|
+
- Middleware de logging em todo agente
|
|
23
|
+
- Testes unitários para tools e middleware
|
|
24
|
+
- Cobertura mínima: 80%
|
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
# Projeto: Deep Agent (tipo Claude Code)
|
|
2
|
+
|
|
3
|
+
Você está construindo um Deep Agent — um agente AI autônomo que pode planejar, executar tarefas, gerenciar arquivos, delegar para subagentes e interagir com o usuário. Similar ao Claude Code, Cursor Agent ou Codex. Construído com o framework Deep Agents do LangChain.
|
|
4
|
+
|
|
5
|
+
## Specification-Driven Development (SDD)
|
|
6
|
+
|
|
7
|
+
A regra fundamental de SDD está definida no bundle-base (AGENTS.md base) e é inegociável:
|
|
8
|
+
**Sem spec, sem código. Sem exceção.** O agente deve recusar implementar qualquer demanda que
|
|
9
|
+
não tenha passado pelo fluxo `/speckit.specify` → `/speckit.plan` → `/speckit.tasks` → `/speckit.implement`.
|
|
10
|
+
|
|
11
|
+
Se o usuário pedir para codar algo sem spec, PARE e inicie o fluxo SDD primeiro.
|
|
12
|
+
Consulte `.specify/specs/` para verificar se já existe spec para a demanda.
|
|
13
|
+
|
|
14
|
+
## Product Requirements Document
|
|
15
|
+
|
|
16
|
+
O arquivo `PRD.md` na raiz do projeto contém os requisitos do produto definidos pelo analista/dev. Consulte-o para entender O QUE construir. Este AGENTS.md define COMO o agente deve trabalhar; o PRD define O QUE deve ser construído.
|
|
17
|
+
|
|
18
|
+
- `PRD.md` — Requisitos do produto, user stories, API spec, modelo de dados
|
|
19
|
+
|
|
20
|
+
## Stack do projeto
|
|
21
|
+
|
|
22
|
+
- **Linguagem:** Python 3.11+
|
|
23
|
+
- **Framework:** Deep Agents SDK (`deepagents`)
|
|
24
|
+
- **Execução:** LangGraph (por baixo)
|
|
25
|
+
- **Modelos:** Claude (Anthropic), GPT (OpenAI), Gemini (Google), Ollama (local)
|
|
26
|
+
- **Backends:** StateBackend, FilesystemBackend, StoreBackend, LocalShellBackend, Sandboxes
|
|
27
|
+
- **API:** FastAPI (para servir o agente como API)
|
|
28
|
+
- **Observabilidade:** LangSmith ou Langfuse
|
|
29
|
+
- **Testes:** Pytest + evals customizados
|
|
30
|
+
|
|
31
|
+
## Estrutura do projeto
|
|
32
|
+
|
|
33
|
+
```
|
|
34
|
+
src/
|
|
35
|
+
├── agent/ # Definição do Deep Agent principal
|
|
36
|
+
│ ├── main.py # create_deep_agent + configuração
|
|
37
|
+
│ ├── tools.py # Tools customizadas
|
|
38
|
+
│ ├── subagents.py # Definição de subagentes
|
|
39
|
+
│ ├── middleware.py # Middleware customizado
|
|
40
|
+
│ └── prompts.py # System prompts versionados
|
|
41
|
+
├── skills/ # Skills que o agente pode carregar
|
|
42
|
+
│ ├── code-review/SKILL.md
|
|
43
|
+
│ ├── deploy/SKILL.md
|
|
44
|
+
│ └── ...
|
|
45
|
+
├── backends/ # Configuração de backends
|
|
46
|
+
│ ├── filesystem.py
|
|
47
|
+
│ ├── store.py
|
|
48
|
+
│ └── composite.py
|
|
49
|
+
├── api/ # Servir agente como API (opcional)
|
|
50
|
+
│ ├── server.py # FastAPI
|
|
51
|
+
│ └── websocket.py # Streaming via WebSocket
|
|
52
|
+
├── evals/ # Avaliação do agente
|
|
53
|
+
│ ├── golden_dataset.json
|
|
54
|
+
│ ├── evaluators.py
|
|
55
|
+
│ └── run_evals.py
|
|
56
|
+
└── config/
|
|
57
|
+
├── settings.py
|
|
58
|
+
└── models.py
|
|
59
|
+
```
|
|
60
|
+
|
|
61
|
+
## Padrões de código
|
|
62
|
+
|
|
63
|
+
- Máximo 500 linhas por arquivo, 20 linhas por função
|
|
64
|
+
- Type hints em funções públicas
|
|
65
|
+
- f-strings, Black + Ruff
|
|
66
|
+
- Nomes descritivos, guard clauses
|
|
67
|
+
- Tratar exceções com tipos específicos
|
|
68
|
+
|
|
69
|
+
## Padrões de Deep Agent
|
|
70
|
+
|
|
71
|
+
- System prompts versionados em `prompts.py`, nunca hardcoded
|
|
72
|
+
- Tools com schemas Pydantic e descrições claras
|
|
73
|
+
- Cada subagente tem UMA responsabilidade
|
|
74
|
+
- Human-in-the-loop para operações destrutivas (delete, deploy, email)
|
|
75
|
+
- Timeout e max_iterations em todo agente
|
|
76
|
+
- Checkpointer obrigatório para persistência de estado
|
|
77
|
+
- Backend explícito (nunca confiar no default em produção)
|
|
78
|
+
- Skills carregadas on-demand, nunca todas no system prompt
|
|
79
|
+
|
|
80
|
+
## Middleware obrigatório
|
|
81
|
+
|
|
82
|
+
O Deep Agent já vem com middleware padrão que não deve ser desabilitado:
|
|
83
|
+
- **TodoListMiddleware** — Planejamento de tarefas
|
|
84
|
+
- **FilesystemMiddleware** — Gerenciamento de arquivos
|
|
85
|
+
- **SubAgentMiddleware** — Delegação para subagentes
|
|
86
|
+
- **SummarizationMiddleware** — Compressão de contexto
|
|
87
|
+
|
|
88
|
+
## Git
|
|
89
|
+
|
|
90
|
+
- Commits: `feat(agent): adicionar tool de busca semântica`
|
|
91
|
+
- Branches: `feature/<componente>-<descricao>`
|
|
92
|
+
- Nunca commitar API keys, .env
|
|
93
|
+
|
|
94
|
+
## Testes
|
|
95
|
+
|
|
96
|
+
- Testes unitários para tools e middleware
|
|
97
|
+
- Testes de integração para o agente completo
|
|
98
|
+
- Evals com golden dataset + LLM-as-judge
|
|
99
|
+
- Cobertura mínima: 80%
|
|
100
|
+
|
|
101
|
+
## References
|
|
102
|
+
|
|
103
|
+
- `references/deep-agents-api.md` — API reference do Deep Agents SDK
|
|
104
|
+
- `references/backends-guide.md` — Guia de backends e quando usar cada um
|
|
105
|
+
- `references/middleware-guide.md` — Middleware padrão e customizado
|
|
@@ -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
|