create-bk-agent 0.22.6 → 0.22.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.
- package/README.md +280 -272
- package/dist/src/add/index.js +41 -33
- package/dist/src/add/modules/testing.js +116 -0
- package/dist/src/add/patcher.js +11 -0
- package/dist/src/scaffold.js +1 -0
- package/package.json +2 -2
- package/templates/autonomous/package.json +1 -1
- package/templates/base/autonomous/package.json +1 -1
- package/templates/base/coding/package.json +2 -2
- package/templates/base/enterprise/package.json +3 -3
- package/templates/base/minimal/package.json +1 -1
- package/templates/base/multi-agent/package.json +1 -1
- package/templates/base/single/package.json +1 -1
- package/templates/coding/package.json +2 -2
- package/templates/domain-agent/package.json +1 -1
- package/templates/mcp-server/package.json +1 -1
- package/templates/minimal/package.json +1 -1
package/README.md
CHANGED
|
@@ -1,272 +1,280 @@
|
|
|
1
|
-
# create-bk-agent
|
|
2
|
-
|
|
3
|
-
> **Status: `stable`** — Maintained and production-ready. No new features during the pilot phase.
|
|
4
|
-
|
|
5
|
-
CLI scaffolding tool for the BackendKit Labs agent framework. Generates a fully configured TypeScript agent project in seconds — choose your architecture, deployment mode, and LLM provider, and get a working project with all dependencies wired.
|
|
6
|
-
|
|
7
|
-
## Usage
|
|
8
|
-
|
|
9
|
-
```bash
|
|
10
|
-
npm create bk-agent@latest my-agent
|
|
11
|
-
cd my-agent && npm install && npm run dev
|
|
12
|
-
|
|
13
|
-
# Or with npx:
|
|
14
|
-
npx create-bk-agent my-agent
|
|
15
|
-
```
|
|
16
|
-
|
|
17
|
-
---
|
|
18
|
-
|
|
19
|
-
## Interactive setup
|
|
20
|
-
|
|
21
|
-
The CLI asks three questions:
|
|
22
|
-
|
|
23
|
-
1. **Architecture** — what kind of agent?
|
|
24
|
-
2. **Deploy mode** — how will it be used?
|
|
25
|
-
3. **Provider** — which LLM API?
|
|
26
|
-
|
|
27
|
-
---
|
|
28
|
-
|
|
29
|
-
## Architectures
|
|
30
|
-
|
|
31
|
-
### `multi-agent` — Multi-agent orchestrator
|
|
32
|
-
|
|
33
|
-
A routing orchestrator that delegates tasks to specialized sub-agents. Best for complex domains with distinct request types.
|
|
34
|
-
|
|
35
|
-
```
|
|
36
|
-
src/
|
|
37
|
-
├── agents/ ← agent profiles (JSON)
|
|
38
|
-
├── tools/ ← typed tool definitions
|
|
39
|
-
├── orchestrator.ts ← routes requests to sub-agents
|
|
40
|
-
└── index.ts
|
|
41
|
-
```
|
|
42
|
-
|
|
43
|
-
**Use case:** A customer platform with separate agents for billing, support, and account management.
|
|
44
|
-
|
|
45
|
-
### `single` — Single-agent assistant
|
|
46
|
-
|
|
47
|
-
One agent with a custom system prompt and your tools.
|
|
48
|
-
|
|
49
|
-
```
|
|
50
|
-
src/
|
|
51
|
-
├── tools/
|
|
52
|
-
├── agent.ts
|
|
53
|
-
└── index.ts
|
|
54
|
-
```
|
|
55
|
-
|
|
56
|
-
### `coding` — Coding assistant
|
|
57
|
-
|
|
58
|
-
Pre-configured with 10 coding agents, filesystem tools, persistent memory, and stack detection. Ready to use immediately.
|
|
59
|
-
|
|
60
|
-
```
|
|
61
|
-
src/
|
|
62
|
-
└── index.ts ← createCodingEngine() + readline REPL
|
|
63
|
-
AGENT.md ← project context injected into every LLM call
|
|
64
|
-
```
|
|
65
|
-
|
|
66
|
-
**Use case:** A project-specific coding assistant with your team's conventions in `AGENT.md`.
|
|
67
|
-
|
|
68
|
-
### `autonomous` — Autonomous daemon
|
|
69
|
-
|
|
70
|
-
Runs on a schedule without user interaction. Pre-wired with `createAutonomousAgent` + cron trigger.
|
|
71
|
-
|
|
72
|
-
```
|
|
73
|
-
src/
|
|
74
|
-
├── triggers/
|
|
75
|
-
├── tools/
|
|
76
|
-
└── index.ts ← cron + event loop
|
|
77
|
-
```
|
|
78
|
-
|
|
79
|
-
**Use case:** Nightly reports, daily standups, automated monitoring.
|
|
80
|
-
|
|
81
|
-
### `minimal` — Minimal / embedded
|
|
82
|
-
|
|
83
|
-
Bare-bones template — just `AgentEngine`, one tool, one agent. Use when embedding an agent into an existing application or building a library.
|
|
84
|
-
|
|
85
|
-
```
|
|
86
|
-
src/
|
|
87
|
-
└── index.ts ← AgentEngine, bare minimum
|
|
88
|
-
```
|
|
89
|
-
|
|
90
|
-
### `enterprise` — Enterprise (local LLM + RAG)
|
|
91
|
-
|
|
92
|
-
Full enterprise setup: Ollama LLM, Obsidian vault as knowledge base, six department agents (General, Support, HR, Sales, Finance, Ops), VaultWriter, and optionally an `AgentServer` web server.
|
|
93
|
-
|
|
94
|
-
```
|
|
95
|
-
src/
|
|
96
|
-
├── server.ts ← createEnterpriseSetup() + AgentServer
|
|
97
|
-
└── agents/ ← 6 department profiles
|
|
98
|
-
.env.example ← VAULT_PATH, JWT_SECRET, PORT, OLLAMA_HOST
|
|
99
|
-
```
|
|
100
|
-
|
|
101
|
-
---
|
|
102
|
-
|
|
103
|
-
## Deploy modes
|
|
104
|
-
|
|
105
|
-
| Mode | Description |
|
|
106
|
-
|------|-------------|
|
|
107
|
-
| `repl` | Terminal REPL — stdin/stdout |
|
|
108
|
-
| `mcp-stdio` | MCP server over stdio (for Claude Desktop, agent-core) |
|
|
109
|
-
| `mcp-http` | MCP server over HTTP (`npm run server`) |
|
|
110
|
-
| `hybrid` | REPL + MCP server side-by-side |
|
|
111
|
-
| `library` | Exports an engine factory, no I/O |
|
|
112
|
-
| `web` | Fastify web server — chat + kanban (enterprise only) |
|
|
113
|
-
|
|
114
|
-
---
|
|
115
|
-
|
|
116
|
-
## Provider options
|
|
117
|
-
|
|
118
|
-
| Provider | Required env var |
|
|
119
|
-
|----------|-----------------|
|
|
120
|
-
| DeepSeek | `DEEPSEEK_API_KEY` |
|
|
121
|
-
| OpenAI | `OPENAI_API_KEY` |
|
|
122
|
-
| Anthropic | `ANTHROPIC_API_KEY` |
|
|
123
|
-
| Ollama (local) | *(none — requires `ollama serve`)* |
|
|
124
|
-
|
|
125
|
-
The scaffolded `.env.example` lists all required variables.
|
|
126
|
-
|
|
127
|
-
---
|
|
128
|
-
|
|
129
|
-
## Scaffolded project structure
|
|
130
|
-
|
|
131
|
-
### Coding assistant (simplest)
|
|
132
|
-
|
|
133
|
-
```
|
|
134
|
-
my-agent/
|
|
135
|
-
├── src/
|
|
136
|
-
│ └── index.ts ← createCodingEngine() + readline REPL
|
|
137
|
-
├── AGENT.md ← project context (edit this!)
|
|
138
|
-
├── package.json
|
|
139
|
-
├── tsconfig.json
|
|
140
|
-
└── .env.example
|
|
141
|
-
```
|
|
142
|
-
|
|
143
|
-
**`AGENT.md`** is injected into every LLM call. Describe your project, stack, and conventions:
|
|
144
|
-
|
|
145
|
-
```markdown
|
|
146
|
-
# My Project
|
|
147
|
-
|
|
148
|
-
## Tech stack
|
|
149
|
-
Node.js 20, TypeScript 5, Express 4, PostgreSQL 15
|
|
150
|
-
|
|
151
|
-
## Conventions
|
|
152
|
-
- All functions must have JSDoc
|
|
153
|
-
- Tests use Jest + Supertest
|
|
154
|
-
- Never use `any` — use `unknown`
|
|
155
|
-
|
|
156
|
-
## Architecture
|
|
157
|
-
REST API with repository pattern. DB access only via src/repositories/.
|
|
158
|
-
```
|
|
159
|
-
|
|
160
|
-
### Enterprise web server (most complete)
|
|
161
|
-
|
|
162
|
-
```
|
|
163
|
-
my-agent/
|
|
164
|
-
├── src/
|
|
165
|
-
│ ├── server.ts ← createEnterpriseSetup() + AgentServer
|
|
166
|
-
│ └── agents/ ← 6 department profiles
|
|
167
|
-
├── .env.example ← VAULT_PATH, OLLAMA_HOST, JWT_SECRET, PORT
|
|
168
|
-
├── package.json ← agent-enterprise + agent-web
|
|
169
|
-
└── tsconfig.json
|
|
170
|
-
```
|
|
171
|
-
|
|
172
|
-
---
|
|
173
|
-
|
|
174
|
-
## Examples
|
|
175
|
-
|
|
176
|
-
### Coding assistant
|
|
177
|
-
|
|
178
|
-
```bash
|
|
179
|
-
npx create-bk-agent my-dev-assistant
|
|
180
|
-
# → coding → repl → deepseek
|
|
181
|
-
|
|
182
|
-
cd my-dev-assistant
|
|
183
|
-
cp .env.example .env
|
|
184
|
-
# Edit .env: add DEEPSEEK_API_KEY
|
|
185
|
-
|
|
186
|
-
# Describe your project
|
|
187
|
-
nano AGENT.md
|
|
188
|
-
|
|
189
|
-
npm install && npm run dev
|
|
190
|
-
# > What can I help with?
|
|
191
|
-
```
|
|
192
|
-
|
|
193
|
-
### Enterprise on-premises assistant
|
|
194
|
-
|
|
195
|
-
```bash
|
|
196
|
-
npx create-bk-agent company-assistant
|
|
197
|
-
# → enterprise → web → ollama
|
|
198
|
-
|
|
199
|
-
cd company-assistant
|
|
200
|
-
cp .env.example .env
|
|
201
|
-
# Edit .env: VAULT_PATH=/path/to/obsidian-vault
|
|
202
|
-
|
|
203
|
-
ollama serve
|
|
204
|
-
ollama pull llama3.2
|
|
205
|
-
ollama pull nomic-embed-text
|
|
206
|
-
|
|
207
|
-
npm install && npm run dev
|
|
208
|
-
# → Indexing vault...
|
|
209
|
-
# → Server running on :4001
|
|
210
|
-
# Chat: http://localhost:4001/
|
|
211
|
-
# Kanban: http://localhost:4001/#kanban
|
|
212
|
-
```
|
|
213
|
-
|
|
214
|
-
### Autonomous cron agent
|
|
215
|
-
|
|
216
|
-
```bash
|
|
217
|
-
npx create-bk-agent standup-bot
|
|
218
|
-
# → autonomous → repl → deepseek
|
|
219
|
-
|
|
220
|
-
cd standup-bot
|
|
221
|
-
# Edit src/triggers/index.ts: schedule, prompt, output
|
|
222
|
-
npm install && npm run dev
|
|
223
|
-
```
|
|
224
|
-
|
|
225
|
-
### MCP server exposing your tools
|
|
226
|
-
|
|
227
|
-
```bash
|
|
228
|
-
npx create-bk-agent my-tools-server
|
|
229
|
-
# → single → mcp-http → openai
|
|
230
|
-
|
|
231
|
-
cd my-tools-server
|
|
232
|
-
# Add tools to src/tools/
|
|
233
|
-
# Add agent to src/agents/
|
|
234
|
-
npm install && npm run server # MCP server on :3000
|
|
235
|
-
```
|
|
236
|
-
|
|
237
|
-
Claude Desktop config:
|
|
238
|
-
|
|
239
|
-
```json
|
|
240
|
-
{
|
|
241
|
-
"mcpServers": {
|
|
242
|
-
"my-tools": {
|
|
243
|
-
"command": "npx",
|
|
244
|
-
"args": ["-y", "my-tools-server"]
|
|
245
|
-
}
|
|
246
|
-
}
|
|
247
|
-
}
|
|
248
|
-
```
|
|
249
|
-
|
|
250
|
-
---
|
|
251
|
-
|
|
252
|
-
## `bk add` command
|
|
253
|
-
|
|
254
|
-
After scaffolding, add new components to your project:
|
|
255
|
-
|
|
256
|
-
```bash
|
|
257
|
-
bk add tool lookup-order # creates src/tools/lookup-order.ts
|
|
258
|
-
bk add agent billing # creates src/agents/billing.json
|
|
259
|
-
bk add trigger daily-report # adds a cron trigger
|
|
260
|
-
```
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
1
|
+
# create-bk-agent
|
|
2
|
+
|
|
3
|
+
> **Status: `stable`** — Maintained and production-ready. No new features during the pilot phase.
|
|
4
|
+
|
|
5
|
+
CLI scaffolding tool for the BackendKit Labs agent framework. Generates a fully configured TypeScript agent project in seconds — choose your architecture, deployment mode, and LLM provider, and get a working project with all dependencies wired.
|
|
6
|
+
|
|
7
|
+
## Usage
|
|
8
|
+
|
|
9
|
+
```bash
|
|
10
|
+
npm create bk-agent@latest my-agent
|
|
11
|
+
cd my-agent && npm install && npm run dev
|
|
12
|
+
|
|
13
|
+
# Or with npx:
|
|
14
|
+
npx create-bk-agent my-agent
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
---
|
|
18
|
+
|
|
19
|
+
## Interactive setup
|
|
20
|
+
|
|
21
|
+
The CLI asks three questions:
|
|
22
|
+
|
|
23
|
+
1. **Architecture** — what kind of agent?
|
|
24
|
+
2. **Deploy mode** — how will it be used?
|
|
25
|
+
3. **Provider** — which LLM API?
|
|
26
|
+
|
|
27
|
+
---
|
|
28
|
+
|
|
29
|
+
## Architectures
|
|
30
|
+
|
|
31
|
+
### `multi-agent` — Multi-agent orchestrator
|
|
32
|
+
|
|
33
|
+
A routing orchestrator that delegates tasks to specialized sub-agents. Best for complex domains with distinct request types.
|
|
34
|
+
|
|
35
|
+
```
|
|
36
|
+
src/
|
|
37
|
+
├── agents/ ← agent profiles (JSON)
|
|
38
|
+
├── tools/ ← typed tool definitions
|
|
39
|
+
├── orchestrator.ts ← routes requests to sub-agents
|
|
40
|
+
└── index.ts
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
**Use case:** A customer platform with separate agents for billing, support, and account management.
|
|
44
|
+
|
|
45
|
+
### `single` — Single-agent assistant
|
|
46
|
+
|
|
47
|
+
One agent with a custom system prompt and your tools.
|
|
48
|
+
|
|
49
|
+
```
|
|
50
|
+
src/
|
|
51
|
+
├── tools/
|
|
52
|
+
├── agent.ts
|
|
53
|
+
└── index.ts
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
### `coding` — Coding assistant
|
|
57
|
+
|
|
58
|
+
Pre-configured with 10 coding agents, filesystem tools, persistent memory, and stack detection. Ready to use immediately.
|
|
59
|
+
|
|
60
|
+
```
|
|
61
|
+
src/
|
|
62
|
+
└── index.ts ← createCodingEngine() + readline REPL
|
|
63
|
+
AGENT.md ← project context injected into every LLM call
|
|
64
|
+
```
|
|
65
|
+
|
|
66
|
+
**Use case:** A project-specific coding assistant with your team's conventions in `AGENT.md`.
|
|
67
|
+
|
|
68
|
+
### `autonomous` — Autonomous daemon
|
|
69
|
+
|
|
70
|
+
Runs on a schedule without user interaction. Pre-wired with `createAutonomousAgent` + cron trigger.
|
|
71
|
+
|
|
72
|
+
```
|
|
73
|
+
src/
|
|
74
|
+
├── triggers/
|
|
75
|
+
├── tools/
|
|
76
|
+
└── index.ts ← cron + event loop
|
|
77
|
+
```
|
|
78
|
+
|
|
79
|
+
**Use case:** Nightly reports, daily standups, automated monitoring.
|
|
80
|
+
|
|
81
|
+
### `minimal` — Minimal / embedded
|
|
82
|
+
|
|
83
|
+
Bare-bones template — just `AgentEngine`, one tool, one agent. Use when embedding an agent into an existing application or building a library.
|
|
84
|
+
|
|
85
|
+
```
|
|
86
|
+
src/
|
|
87
|
+
└── index.ts ← AgentEngine, bare minimum
|
|
88
|
+
```
|
|
89
|
+
|
|
90
|
+
### `enterprise` — Enterprise (local LLM + RAG)
|
|
91
|
+
|
|
92
|
+
Full enterprise setup: Ollama LLM, Obsidian vault as knowledge base, six department agents (General, Support, HR, Sales, Finance, Ops), VaultWriter, and optionally an `AgentServer` web server.
|
|
93
|
+
|
|
94
|
+
```
|
|
95
|
+
src/
|
|
96
|
+
├── server.ts ← createEnterpriseSetup() + AgentServer
|
|
97
|
+
└── agents/ ← 6 department profiles
|
|
98
|
+
.env.example ← VAULT_PATH, JWT_SECRET, PORT, OLLAMA_HOST
|
|
99
|
+
```
|
|
100
|
+
|
|
101
|
+
---
|
|
102
|
+
|
|
103
|
+
## Deploy modes
|
|
104
|
+
|
|
105
|
+
| Mode | Description |
|
|
106
|
+
|------|-------------|
|
|
107
|
+
| `repl` | Terminal REPL — stdin/stdout |
|
|
108
|
+
| `mcp-stdio` | MCP server over stdio (for Claude Desktop, agent-core) |
|
|
109
|
+
| `mcp-http` | MCP server over HTTP (`npm run server`) |
|
|
110
|
+
| `hybrid` | REPL + MCP server side-by-side |
|
|
111
|
+
| `library` | Exports an engine factory, no I/O |
|
|
112
|
+
| `web` | Fastify web server — chat + kanban (enterprise only) |
|
|
113
|
+
|
|
114
|
+
---
|
|
115
|
+
|
|
116
|
+
## Provider options
|
|
117
|
+
|
|
118
|
+
| Provider | Required env var |
|
|
119
|
+
|----------|-----------------|
|
|
120
|
+
| DeepSeek | `DEEPSEEK_API_KEY` |
|
|
121
|
+
| OpenAI | `OPENAI_API_KEY` |
|
|
122
|
+
| Anthropic | `ANTHROPIC_API_KEY` |
|
|
123
|
+
| Ollama (local) | *(none — requires `ollama serve`)* |
|
|
124
|
+
|
|
125
|
+
The scaffolded `.env.example` lists all required variables.
|
|
126
|
+
|
|
127
|
+
---
|
|
128
|
+
|
|
129
|
+
## Scaffolded project structure
|
|
130
|
+
|
|
131
|
+
### Coding assistant (simplest)
|
|
132
|
+
|
|
133
|
+
```
|
|
134
|
+
my-agent/
|
|
135
|
+
├── src/
|
|
136
|
+
│ └── index.ts ← createCodingEngine() + readline REPL
|
|
137
|
+
├── AGENT.md ← project context (edit this!)
|
|
138
|
+
├── package.json
|
|
139
|
+
├── tsconfig.json
|
|
140
|
+
└── .env.example
|
|
141
|
+
```
|
|
142
|
+
|
|
143
|
+
**`AGENT.md`** is injected into every LLM call. Describe your project, stack, and conventions:
|
|
144
|
+
|
|
145
|
+
```markdown
|
|
146
|
+
# My Project
|
|
147
|
+
|
|
148
|
+
## Tech stack
|
|
149
|
+
Node.js 20, TypeScript 5, Express 4, PostgreSQL 15
|
|
150
|
+
|
|
151
|
+
## Conventions
|
|
152
|
+
- All functions must have JSDoc
|
|
153
|
+
- Tests use Jest + Supertest
|
|
154
|
+
- Never use `any` — use `unknown`
|
|
155
|
+
|
|
156
|
+
## Architecture
|
|
157
|
+
REST API with repository pattern. DB access only via src/repositories/.
|
|
158
|
+
```
|
|
159
|
+
|
|
160
|
+
### Enterprise web server (most complete)
|
|
161
|
+
|
|
162
|
+
```
|
|
163
|
+
my-agent/
|
|
164
|
+
├── src/
|
|
165
|
+
│ ├── server.ts ← createEnterpriseSetup() + AgentServer
|
|
166
|
+
│ └── agents/ ← 6 department profiles
|
|
167
|
+
├── .env.example ← VAULT_PATH, OLLAMA_HOST, JWT_SECRET, PORT
|
|
168
|
+
├── package.json ← agent-enterprise + agent-web
|
|
169
|
+
└── tsconfig.json
|
|
170
|
+
```
|
|
171
|
+
|
|
172
|
+
---
|
|
173
|
+
|
|
174
|
+
## Examples
|
|
175
|
+
|
|
176
|
+
### Coding assistant
|
|
177
|
+
|
|
178
|
+
```bash
|
|
179
|
+
npx create-bk-agent my-dev-assistant
|
|
180
|
+
# → coding → repl → deepseek
|
|
181
|
+
|
|
182
|
+
cd my-dev-assistant
|
|
183
|
+
cp .env.example .env
|
|
184
|
+
# Edit .env: add DEEPSEEK_API_KEY
|
|
185
|
+
|
|
186
|
+
# Describe your project
|
|
187
|
+
nano AGENT.md
|
|
188
|
+
|
|
189
|
+
npm install && npm run dev
|
|
190
|
+
# > What can I help with?
|
|
191
|
+
```
|
|
192
|
+
|
|
193
|
+
### Enterprise on-premises assistant
|
|
194
|
+
|
|
195
|
+
```bash
|
|
196
|
+
npx create-bk-agent company-assistant
|
|
197
|
+
# → enterprise → web → ollama
|
|
198
|
+
|
|
199
|
+
cd company-assistant
|
|
200
|
+
cp .env.example .env
|
|
201
|
+
# Edit .env: VAULT_PATH=/path/to/obsidian-vault
|
|
202
|
+
|
|
203
|
+
ollama serve
|
|
204
|
+
ollama pull llama3.2
|
|
205
|
+
ollama pull nomic-embed-text
|
|
206
|
+
|
|
207
|
+
npm install && npm run dev
|
|
208
|
+
# → Indexing vault...
|
|
209
|
+
# → Server running on :4001
|
|
210
|
+
# Chat: http://localhost:4001/
|
|
211
|
+
# Kanban: http://localhost:4001/#kanban
|
|
212
|
+
```
|
|
213
|
+
|
|
214
|
+
### Autonomous cron agent
|
|
215
|
+
|
|
216
|
+
```bash
|
|
217
|
+
npx create-bk-agent standup-bot
|
|
218
|
+
# → autonomous → repl → deepseek
|
|
219
|
+
|
|
220
|
+
cd standup-bot
|
|
221
|
+
# Edit src/triggers/index.ts: schedule, prompt, output
|
|
222
|
+
npm install && npm run dev
|
|
223
|
+
```
|
|
224
|
+
|
|
225
|
+
### MCP server exposing your tools
|
|
226
|
+
|
|
227
|
+
```bash
|
|
228
|
+
npx create-bk-agent my-tools-server
|
|
229
|
+
# → single → mcp-http → openai
|
|
230
|
+
|
|
231
|
+
cd my-tools-server
|
|
232
|
+
# Add tools to src/tools/
|
|
233
|
+
# Add agent to src/agents/
|
|
234
|
+
npm install && npm run server # MCP server on :3000
|
|
235
|
+
```
|
|
236
|
+
|
|
237
|
+
Claude Desktop config:
|
|
238
|
+
|
|
239
|
+
```json
|
|
240
|
+
{
|
|
241
|
+
"mcpServers": {
|
|
242
|
+
"my-tools": {
|
|
243
|
+
"command": "npx",
|
|
244
|
+
"args": ["-y", "my-tools-server"]
|
|
245
|
+
}
|
|
246
|
+
}
|
|
247
|
+
}
|
|
248
|
+
```
|
|
249
|
+
|
|
250
|
+
---
|
|
251
|
+
|
|
252
|
+
## `bk add` command
|
|
253
|
+
|
|
254
|
+
After scaffolding, add new components to your project:
|
|
255
|
+
|
|
256
|
+
```bash
|
|
257
|
+
bk add tool lookup-order # creates src/tools/lookup-order.ts
|
|
258
|
+
bk add agent billing # creates src/agents/billing.json
|
|
259
|
+
bk add trigger daily-report # adds a cron trigger
|
|
260
|
+
```
|
|
261
|
+
|
|
262
|
+
### Tests that need no API key
|
|
263
|
+
|
|
264
|
+
```bash
|
|
265
|
+
npx create-bk-agent add testing
|
|
266
|
+
```
|
|
267
|
+
|
|
268
|
+
Adds `@backendkit-labs/agent-testkit`, jest and ts-jest as dev dependencies, a `jest.config.js`, a `test` script and an example test (`src/__tests__/agent.example.test.ts`) that runs an agent against a scripted provider. Existing files are never overwritten. See the [agent-testkit README](../testkit/README.md) for the mock LLM server, record/replay and the real-world assertions.
|
|
269
|
+
|
|
270
|
+
---
|
|
271
|
+
|
|
272
|
+
## Scripts in scaffolded projects
|
|
273
|
+
|
|
274
|
+
| Script | Description |
|
|
275
|
+
|--------|-------------|
|
|
276
|
+
| `npm run dev` | Development with tsx / ts-node |
|
|
277
|
+
| `npm run build` | Compile TypeScript |
|
|
278
|
+
| `npm run start` | Run compiled output |
|
|
279
|
+
| `npm run server` | Start MCP or web server |
|
|
280
|
+
| `npm run typecheck` | TypeScript type-check only |
|
package/dist/src/add/index.js
CHANGED
|
@@ -8,39 +8,44 @@ const tools_1 = require("./modules/tools");
|
|
|
8
8
|
const mcp_client_1 = require("./modules/mcp-client");
|
|
9
9
|
const plugin_1 = require("./modules/plugin");
|
|
10
10
|
const knowledge_1 = require("./modules/knowledge");
|
|
11
|
-
const
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
--
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
npx create-bk-agent add
|
|
40
|
-
npx create-bk-agent add
|
|
41
|
-
npx create-bk-agent add
|
|
42
|
-
npx create-bk-agent add
|
|
43
|
-
npx create-bk-agent add
|
|
11
|
+
const testing_1 = require("./modules/testing");
|
|
12
|
+
const HELP = `
|
|
13
|
+
Usage: npx create-bk-agent add <module> [options]
|
|
14
|
+
|
|
15
|
+
Modules:
|
|
16
|
+
server Add an HTTP MCP server (src/server.ts)
|
|
17
|
+
--port <n> Port to listen on (default: 3001)
|
|
18
|
+
--name <s> MCP server name (default: project directory name)
|
|
19
|
+
|
|
20
|
+
specialist <name> Add a new specialist agent to a multi-agent project
|
|
21
|
+
(creates src/agents/<name>.ts and patches engine.ts)
|
|
22
|
+
|
|
23
|
+
tools <domain> Add a tool file for a new domain
|
|
24
|
+
(creates src/tools/<domain>-tools.ts and patches engine.ts)
|
|
25
|
+
|
|
26
|
+
knowledge <path> Add a folder or vault to the RAG knowledge base (enterprise agents)
|
|
27
|
+
--vault <path> Register an entirely new Obsidian vault (instead of a subfolder)
|
|
28
|
+
|
|
29
|
+
mcp-client <url> Add a remote MCP server to the engine
|
|
30
|
+
--name <s> Name for the mcpServers entry (default: last URL segment)
|
|
31
|
+
|
|
32
|
+
plugin <name> Install a backendkit agent as a stdio MCP plugin
|
|
33
|
+
Available: docker, k8s
|
|
34
|
+
|
|
35
|
+
testing Set up tests that need no API key: agent-testkit + jest,
|
|
36
|
+
a jest.config.js, a "test" script and an example test
|
|
37
|
+
|
|
38
|
+
Examples:
|
|
39
|
+
npx create-bk-agent add server --port 4000
|
|
40
|
+
npx create-bk-agent add specialist data-analyst
|
|
41
|
+
npx create-bk-agent add tools github
|
|
42
|
+
npx create-bk-agent add knowledge ./docs
|
|
43
|
+
npx create-bk-agent add knowledge "04-Recursos/Backend"
|
|
44
|
+
npx create-bk-agent add knowledge --vault "C:/Company/HR-Vault"
|
|
45
|
+
npx create-bk-agent add mcp-client http://localhost:3001/mcp --name billing
|
|
46
|
+
npx create-bk-agent add plugin docker
|
|
47
|
+
npx create-bk-agent add plugin k8s
|
|
48
|
+
npx create-bk-agent add testing
|
|
44
49
|
`;
|
|
45
50
|
function runAdd(args, cwd) {
|
|
46
51
|
const [module, ...rest] = args;
|
|
@@ -78,6 +83,9 @@ function runAdd(args, cwd) {
|
|
|
78
83
|
case 'knowledge':
|
|
79
84
|
(0, knowledge_1.addKnowledge)(info, rest);
|
|
80
85
|
break;
|
|
86
|
+
case 'testing':
|
|
87
|
+
(0, testing_1.addTesting)(info, rest);
|
|
88
|
+
break;
|
|
81
89
|
default:
|
|
82
90
|
console.error(`\n✗ Unknown module: "${module}"\n`);
|
|
83
91
|
console.log(HELP);
|
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
35
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
|
+
exports.EXAMPLE_TEST = void 0;
|
|
37
|
+
exports.addTesting = addTesting;
|
|
38
|
+
const fs = __importStar(require("fs"));
|
|
39
|
+
const path = __importStar(require("path"));
|
|
40
|
+
const child_process_1 = require("child_process");
|
|
41
|
+
const patcher_1 = require("../patcher");
|
|
42
|
+
const scaffold_1 = require("../../scaffold");
|
|
43
|
+
const DEV_DEPS = [
|
|
44
|
+
['@backendkit-labs/agent-testkit', scaffold_1.GENERATED_DEP_RANGES['@backendkit-labs/agent-testkit']],
|
|
45
|
+
['jest', '^29.0.0'],
|
|
46
|
+
['ts-jest', '^29.0.0'],
|
|
47
|
+
['@types/jest', '^29.0.0'],
|
|
48
|
+
];
|
|
49
|
+
const JEST_CONFIG = `/** @type {import('jest').Config} */
|
|
50
|
+
module.exports = {
|
|
51
|
+
preset: 'ts-jest',
|
|
52
|
+
testEnvironment: 'node',
|
|
53
|
+
testMatch: ['**/__tests__/**/*.test.ts'],
|
|
54
|
+
};
|
|
55
|
+
`;
|
|
56
|
+
exports.EXAMPLE_TEST = `import { createBaseEngine } from '@backendkit-labs/agent-core';
|
|
57
|
+
import { mockTransport, scriptedProvider } from '@backendkit-labs/agent-testkit';
|
|
58
|
+
|
|
59
|
+
// Test an agent without an API key. This example builds its own small engine; to test your project's agent,
|
|
60
|
+
// export a factory from src/engine.ts that accepts a provider and pass the doubles below instead.
|
|
61
|
+
//
|
|
62
|
+
// More doubles in @backendkit-labs/agent-testkit:
|
|
63
|
+
// - startMockLlmServer(...) a fake OpenAI-compatible server that returns 429s, resets, overflows...
|
|
64
|
+
// - RecordingProvider / ReplayProvider record a real run once, replay it in every test run
|
|
65
|
+
// - world.fileEquals / untouched / processGone check what the agent really did to the system
|
|
66
|
+
|
|
67
|
+
const agent = {
|
|
68
|
+
id: 'helper', name: 'Helper', icon: '🤖', description: 'example agent',
|
|
69
|
+
systemPrompt: 'Answer briefly.', allowedTools: [], delegatesTo: [],
|
|
70
|
+
};
|
|
71
|
+
|
|
72
|
+
describe('an agent tested without an API key', () => {
|
|
73
|
+
it('answers from a scripted provider', async () => {
|
|
74
|
+
const t = mockTransport();
|
|
75
|
+
const engine = createBaseEngine({
|
|
76
|
+
providers: { mock: scriptedProvider([{ content: 'Hello from the script' }]) },
|
|
77
|
+
defaultProvider: 'mock', agents: [agent], defaultAgent: 'helper',
|
|
78
|
+
transport: t.transport, workingDir: process.cwd(), noQA: true, iterationMode: 'auto',
|
|
79
|
+
});
|
|
80
|
+
|
|
81
|
+
await engine.run('hi');
|
|
82
|
+
|
|
83
|
+
expect(t.text()).toBe('Hello from the script');
|
|
84
|
+
expect(t.eventsOf('error')).toEqual([]);
|
|
85
|
+
});
|
|
86
|
+
});
|
|
87
|
+
`;
|
|
88
|
+
/** \`add testing\`: dev dependencies, a jest config, a \`test\` script and an example test. Never overwrites files. */
|
|
89
|
+
function addTesting(info, _args, opts = {}) {
|
|
90
|
+
const install = opts.install ?? true;
|
|
91
|
+
let added = false;
|
|
92
|
+
for (const [name, range] of DEV_DEPS)
|
|
93
|
+
added = (0, patcher_1.addPackageDevDependency)(info.pkgFile, name, range) || added;
|
|
94
|
+
(0, patcher_1.addPackageScript)(info.pkgFile, 'test', 'jest');
|
|
95
|
+
const written = [];
|
|
96
|
+
const write = (rel, content) => {
|
|
97
|
+
const target = path.join(info.cwd, rel);
|
|
98
|
+
if (fs.existsSync(target))
|
|
99
|
+
return;
|
|
100
|
+
fs.mkdirSync(path.dirname(target), { recursive: true });
|
|
101
|
+
fs.writeFileSync(target, content);
|
|
102
|
+
written.push(rel);
|
|
103
|
+
};
|
|
104
|
+
if (!fs.existsSync(path.join(info.cwd, 'jest.config.js')) && !fs.existsSync(path.join(info.cwd, 'jest.config.ts'))) {
|
|
105
|
+
write('jest.config.js', JEST_CONFIG);
|
|
106
|
+
}
|
|
107
|
+
write(path.join('src', '__tests__', 'agent.example.test.ts'), exports.EXAMPLE_TEST);
|
|
108
|
+
if (added && install) {
|
|
109
|
+
console.log('\n Installing test dependencies...');
|
|
110
|
+
(0, child_process_1.execSync)('npm install', { cwd: info.cwd, stdio: 'inherit' });
|
|
111
|
+
}
|
|
112
|
+
console.log('\n ✅ Testing set up.\n');
|
|
113
|
+
for (const f of written)
|
|
114
|
+
console.log(` created ${f}`);
|
|
115
|
+
console.log(' run: npm test\n');
|
|
116
|
+
}
|
package/dist/src/add/patcher.js
CHANGED
|
@@ -38,6 +38,7 @@ exports.insertAfterPattern = insertAfterPattern;
|
|
|
38
38
|
exports.insertBeforePattern = insertBeforePattern;
|
|
39
39
|
exports.addPackageScript = addPackageScript;
|
|
40
40
|
exports.addPackageDependency = addPackageDependency;
|
|
41
|
+
exports.addPackageDevDependency = addPackageDevDependency;
|
|
41
42
|
exports.addMcpServerEntry = addMcpServerEntry;
|
|
42
43
|
exports.addMcpStdioEntry = addMcpStdioEntry;
|
|
43
44
|
const fs = __importStar(require("fs"));
|
|
@@ -123,6 +124,16 @@ function addPackageDependency(pkgFile, depName, version) {
|
|
|
123
124
|
fs.writeFileSync(pkgFile, JSON.stringify(pkg, null, 2) + '\n');
|
|
124
125
|
return true;
|
|
125
126
|
}
|
|
127
|
+
/** Adds `depName@version` to devDependencies if it is in neither dependencies nor devDependencies. */
|
|
128
|
+
function addPackageDevDependency(pkgFile, depName, version) {
|
|
129
|
+
const pkg = JSON.parse(fs.readFileSync(pkgFile, 'utf-8'));
|
|
130
|
+
if (pkg.dependencies?.[depName] || pkg.devDependencies?.[depName])
|
|
131
|
+
return false;
|
|
132
|
+
pkg.devDependencies ??= {};
|
|
133
|
+
pkg.devDependencies[depName] = version;
|
|
134
|
+
fs.writeFileSync(pkgFile, JSON.stringify(pkg, null, 2) + '\n');
|
|
135
|
+
return true;
|
|
136
|
+
}
|
|
126
137
|
// ── AgentEngine options patcher ───────────────────────────────────────────────
|
|
127
138
|
/**
|
|
128
139
|
* Adds `mcpServers: [{ name, url }]` to the first AgentEngine constructor call.
|
package/dist/src/scaffold.js
CHANGED
|
@@ -69,6 +69,7 @@ function copyDir(src, dst) {
|
|
|
69
69
|
exports.GENERATED_DEP_RANGES = {
|
|
70
70
|
'@backendkit-labs/mcp-server': '^0.16.0',
|
|
71
71
|
'@backendkit-labs/agent-web': '^0.4.0',
|
|
72
|
+
'@backendkit-labs/agent-testkit': '^0.1.0',
|
|
72
73
|
};
|
|
73
74
|
// ── Patch package.json — name + scripts ──────────────────────────────────────
|
|
74
75
|
const DEPLOY_SCRIPTS = {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "create-bk-agent",
|
|
3
|
-
"version": "0.22.
|
|
3
|
+
"version": "0.22.8",
|
|
4
4
|
"description": "Create a new BackendKit agent project",
|
|
5
5
|
"main": "dist/src/index.js",
|
|
6
6
|
"bin": {
|
|
@@ -28,7 +28,7 @@
|
|
|
28
28
|
"test": "jest"
|
|
29
29
|
},
|
|
30
30
|
"peerDependencies": {
|
|
31
|
-
"@backendkit-labs/agent-core": ">=0.24.0 <0.
|
|
31
|
+
"@backendkit-labs/agent-core": ">=0.24.0 <0.30.0"
|
|
32
32
|
},
|
|
33
33
|
"peerDependenciesMeta": {
|
|
34
34
|
"@backendkit-labs/agent-core": {
|
|
@@ -11,8 +11,8 @@
|
|
|
11
11
|
"typecheck": "tsc --noEmit"
|
|
12
12
|
},
|
|
13
13
|
"dependencies": {
|
|
14
|
-
"@backendkit-labs/agent-coding": "^0.
|
|
15
|
-
"@backendkit-labs/agent-core": "^0.
|
|
14
|
+
"@backendkit-labs/agent-coding": "^0.25.0",
|
|
15
|
+
"@backendkit-labs/agent-core": "^0.29.0",
|
|
16
16
|
"dotenv": "^16.0.0"
|
|
17
17
|
},
|
|
18
18
|
"devDependencies": {
|
|
@@ -12,9 +12,9 @@
|
|
|
12
12
|
"typecheck": "tsc --noEmit"
|
|
13
13
|
},
|
|
14
14
|
"dependencies": {
|
|
15
|
-
"@backendkit-labs/agent-core": "^0.
|
|
16
|
-
"@backendkit-labs/agent-coding": "^0.
|
|
17
|
-
"@backendkit-labs/agent-enterprise": "^0.
|
|
15
|
+
"@backendkit-labs/agent-core": "^0.29.0",
|
|
16
|
+
"@backendkit-labs/agent-coding": "^0.25.0",
|
|
17
|
+
"@backendkit-labs/agent-enterprise": "^0.6.0",
|
|
18
18
|
"dotenv": "^16.0.0",
|
|
19
19
|
"zod": "^3.25.0"
|
|
20
20
|
},
|
|
@@ -11,8 +11,8 @@
|
|
|
11
11
|
"typecheck": "tsc --noEmit"
|
|
12
12
|
},
|
|
13
13
|
"dependencies": {
|
|
14
|
-
"@backendkit-labs/agent-coding": "^0.
|
|
15
|
-
"@backendkit-labs/agent-core": "^0.
|
|
14
|
+
"@backendkit-labs/agent-coding": "^0.25.0",
|
|
15
|
+
"@backendkit-labs/agent-core": "^0.29.0",
|
|
16
16
|
"dotenv": "^16.0.0"
|
|
17
17
|
},
|
|
18
18
|
"devDependencies": {
|