create-bk-agent 0.20.1 → 0.21.1

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 CHANGED
@@ -1,208 +1,270 @@
1
1
  # create-bk-agent
2
2
 
3
- Scaffold a new [BackendKit agent](https://github.com/BackendKit-labs/backendkit-agent-framework) project in seconds — or add capabilities to an existing one.
3
+ 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.
4
4
 
5
- ## Create a project
5
+ ## Usage
6
6
 
7
7
  ```bash
8
- npx create-bk-agent my-project
9
- ```
10
-
11
- The CLI asks three questions and generates a production-ready project:
8
+ npm create bk-agent@latest my-agent
9
+ cd my-agent && npm install && npm run dev
12
10
 
11
+ # Or with npx:
12
+ npx create-bk-agent my-agent
13
13
  ```
14
- ✨ create-bk-agent v0.20.0
15
14
 
16
- ? Project name: my-project
17
- ? Architecture: Multi-agent (orchestrator + specialists)
18
- ? Skill packs: Node.js / TypeScript
19
- ? How will it be used? MCP Server (HTTP)
15
+ ---
20
16
 
21
- Creating Multi-agent — MCP Server (HTTP) agent in ./my-project...
22
- Installing dependencies...
17
+ ## Interactive setup
23
18
 
24
- ✅ Done! Your agent is ready.
19
+ The CLI asks three questions:
25
20
 
26
- cd my-project
27
- cp .env.example .env # add your API key
28
- npm run server # starts HTTP MCP on port 3001
29
- ```
21
+ 1. **Architecture** — what kind of agent?
22
+ 2. **Deploy mode** — how will it be used?
23
+ 3. **Provider** — which LLM API?
24
+
25
+ ---
30
26
 
31
27
  ## Architectures
32
28
 
33
- | Architecture | What it gives you | Best for |
34
- |---|---|---|
35
- | `multi-agent` | Orchestrator + specialists with delegation | Domain agents (DevOps, finance, data, etc.) |
36
- | `single` | One agent with a tool registry | Simple task automation |
37
- | `coding` | 10 pre-built agents + all coding tools | Coding assistants, ready out of the box |
38
- | `autonomous` | Trigger system (cron / webhook / event) | Scheduled or event-driven daemons |
39
- | `minimal` | Bare engine, no entry point | Library embedding |
29
+ ### `multi-agent` — Multi-agent orchestrator
40
30
 
41
- ## Deploy modes
31
+ A routing orchestrator that delegates tasks to specialized sub-agents. Best for complex domains with distinct request types.
42
32
 
43
- Available for `multi-agent` and `single` architectures:
33
+ ```
34
+ src/
35
+ ├── agents/ ← agent profiles (JSON)
36
+ ├── tools/ ← typed tool definitions
37
+ ├── orchestrator.ts ← routes requests to sub-agents
38
+ └── index.ts
39
+ ```
44
40
 
45
- | Mode | Entry point | Use case |
46
- |---|---|---|
47
- | `repl` | `src/index.ts` — readline loop | Local terminal tool |
48
- | `mcp-http` | `src/server.ts` — HTTP MCP server | Connect to Claude Desktop, Cursor, etc. |
49
- | `mcp-stdio` | `src/server.ts` — stdio MCP server | Subprocess / pipe-based MCP |
50
- | `hybrid` | Both `index.ts` + `server.ts` | REPL for dev, server for production |
51
- | `library` | Only `src/engine.ts` exported | Import the engine in your own app |
41
+ **Use case:** A customer platform with separate agents for billing, support, and account management.
52
42
 
53
- ## Providers
43
+ ### `single` — Single-agent assistant
54
44
 
55
- Anthropic (Claude), OpenAI, DeepSeek / any OpenAI-compatible endpoint, and Ollama (local).
45
+ One agent with a custom system prompt and your tools.
56
46
 
57
- ## Model configuration
47
+ ```
48
+ src/
49
+ ├── tools/
50
+ ├── agent.ts
51
+ └── index.ts
52
+ ```
58
53
 
59
- Generated projects read three env vars for model selection:
54
+ ### `coding` — Coding assistant
60
55
 
61
- | Variable | Default | Description |
62
- |---|---|---|
63
- | `LLM_MODEL` | `gpt-4o` | Base model — used by all agents unless overridden |
64
- | `LLM_MODEL_FAST` | `LLM_MODEL` | Execution agents (specialists, tool-calling loops) |
65
- | `LLM_MODEL_SMART` | `LLM_MODEL` | Routing agents (orchestrator, reasoning-heavy tasks) |
56
+ Pre-configured with 10 coding agents, filesystem tools, persistent memory, and stack detection. Ready to use immediately.
66
57
 
67
- If `LLM_MODEL_FAST` and `LLM_MODEL_SMART` are not set, all agents use `LLM_MODEL` — fully backwards compatible.
58
+ ```
59
+ src/
60
+ └── index.ts ← createCodingEngine() + readline REPL
61
+ AGENT.md ← project context injected into every LLM call
62
+ ```
68
63
 
69
- Example `.env` for DeepSeek with smart/fast split:
64
+ **Use case:** A project-specific coding assistant with your team's conventions in `AGENT.md`.
70
65
 
71
- ```env
72
- LLM_API_KEY=sk-...
73
- LLM_BASE_URL=https://api.deepseek.com/v1
74
- LLM_MODEL=deepseek-chat
75
- LLM_MODEL_FAST=deepseek-chat
76
- LLM_MODEL_SMART=deepseek-reasoner
77
- ```
66
+ ### `autonomous` — Autonomous daemon
78
67
 
79
- The split is wired in `src/engine.ts` — specialists get `llmModelFast`, orchestrator gets `llmModelSmart`. To assign a model directly on a profile instead of via env vars, uncomment the `model:` field in the agent file:
68
+ Runs on a schedule without user interaction. Pre-wired with `createAutonomousAgent` + cron trigger.
80
69
 
81
- ```ts
82
- // src/agents/orchestrator.ts
83
- export const ORCHESTRATOR_PROFILE: AgentProfile = {
84
- id: 'orchestrator',
85
- model: 'deepseek-reasoner', // uncomment and set explicitly
86
- ...
87
- };
70
+ ```
71
+ src/
72
+ ├── triggers/
73
+ ├── tools/
74
+ └── index.ts ← cron + event loop
88
75
  ```
89
76
 
90
- ---
77
+ **Use case:** Nightly reports, daily standups, automated monitoring.
91
78
 
92
- ## Add capabilities to an existing project
79
+ ### `minimal` — Minimal / embedded
93
80
 
94
- Once a project is created, use `add` to extend it without editing code manually:
81
+ Bare-bones template — just `AgentEngine`, one tool, one agent. Use when embedding an agent into an existing application or building a library.
95
82
 
96
- ```bash
97
- npx create-bk-agent add <module> [options]
83
+ ```
84
+ src/
85
+ └── index.ts ← AgentEngine, bare minimum
98
86
  ```
99
87
 
100
- ### `add server` — expose the agent as an HTTP MCP server
88
+ ### `enterprise` — Enterprise (local LLM + RAG)
101
89
 
102
- ```bash
103
- npx create-bk-agent add server
104
- npx create-bk-agent add server --port 4000 --name my-agent
90
+ 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.
91
+
92
+ ```
93
+ src/
94
+ ├── server.ts ← createEnterpriseSetup() + AgentServer
95
+ └── agents/ ← 6 department profiles
96
+ .env.example ← VAULT_PATH, JWT_SECRET, PORT, OLLAMA_HOST
105
97
  ```
106
98
 
107
- - Generates `src/server.ts` wired to the existing engine
108
- - Adds `@backendkit-labs/mcp-server` to `dependencies`
109
- - Adds `"server"` script to `package.json`
99
+ ---
110
100
 
111
- ### `add specialist <name>` — add a specialist agent (multi-agent projects)
101
+ ## Deploy modes
112
102
 
113
- ```bash
114
- npx create-bk-agent add specialist data-analyst
115
- npx create-bk-agent add specialist git-expert
116
- ```
103
+ | Mode | Description |
104
+ |------|-------------|
105
+ | `repl` | Terminal REPL — stdin/stdout |
106
+ | `mcp-stdio` | MCP server over stdio (for Claude Desktop, agent-core) |
107
+ | `mcp-http` | MCP server over HTTP (`npm run server`) |
108
+ | `hybrid` | REPL + MCP server side-by-side |
109
+ | `library` | Exports an engine factory, no I/O |
110
+ | `web` | Fastify web server — chat + kanban (enterprise only) |
117
111
 
118
- - Creates `src/agents/<name>.ts` with an `AgentProfile` stub
119
- - Patches `src/engine.ts`: adds the import and `agents.register()`
112
+ ---
120
113
 
121
- ### `add tools <domain>` — add a tool file for a new domain
114
+ ## Provider options
122
115
 
123
- ```bash
124
- npx create-bk-agent add tools github
125
- npx create-bk-agent add tools my-database
126
- ```
116
+ | Provider | Required env var |
117
+ |----------|-----------------|
118
+ | DeepSeek | `DEEPSEEK_API_KEY` |
119
+ | OpenAI | `OPENAI_API_KEY` |
120
+ | Anthropic | `ANTHROPIC_API_KEY` |
121
+ | Ollama (local) | *(none — requires `ollama serve`)* |
127
122
 
128
- - Creates `src/tools/<domain>-tools.ts` with two stub tools (action + query)
129
- - Patches `src/engine.ts`: adds the import and `tools.register()`
123
+ The scaffolded `.env.example` lists all required variables.
130
124
 
131
- ### `add mcp-client <url>` — connect to a remote MCP server
125
+ ---
132
126
 
133
- ```bash
134
- npx create-bk-agent add mcp-client http://localhost:3001/mcp
135
- npx create-bk-agent add mcp-client http://billing-agent/mcp --name billing
136
- ```
127
+ ## Scaffolded project structure
137
128
 
138
- - Patches `src/engine.ts`: adds the entry to `mcpServers: [...]` inside `AgentEngine`
139
- - Creates the `mcpServers` array if it doesn't exist yet
129
+ ### Coding assistant (simplest)
140
130
 
141
- All `add` commands are **idempotent** — running the same command twice won't duplicate entries.
131
+ ```
132
+ my-agent/
133
+ ├── src/
134
+ │ └── index.ts ← createCodingEngine() + readline REPL
135
+ ├── AGENT.md ← project context (edit this!)
136
+ ├── package.json
137
+ ├── tsconfig.json
138
+ └── .env.example
139
+ ```
142
140
 
143
- ---
141
+ **`AGENT.md`** is injected into every LLM call. Describe your project, stack, and conventions:
144
142
 
145
- ## Multi-project workspaces
143
+ ```markdown
144
+ # My Project
146
145
 
147
- Group related projects (e.g. microservices) into a workspace so the agent can navigate all of them from a single shared root — no more switching context manually.
146
+ ## Tech stack
147
+ Node.js 20, TypeScript 5, Express 4, PostgreSQL 15
148
148
 
149
- ### Setup
149
+ ## Conventions
150
+ - All functions must have JSDoc
151
+ - Tests use Jest + Supertest
152
+ - Never use `any` — use `unknown`
150
153
 
151
- Use the built-in `/workspace` slash commands from inside the running agent:
154
+ ## Architecture
155
+ REST API with repository pattern. DB access only via src/repositories/.
156
+ ```
157
+
158
+ ### Enterprise web server (most complete)
152
159
 
153
160
  ```
154
- /workspace create my-system
155
- /workspace add my-system ~/dev/my-system/auth-service
156
- /workspace add my-system ~/dev/my-system/api-gateway
157
- /workspace add my-system ~/dev/my-system/user-service
161
+ my-agent/
162
+ ├── src/
163
+ │ ├── server.ts ← createEnterpriseSetup() + AgentServer
164
+ │ └── agents/ ← 6 department profiles
165
+ ├── .env.example ← VAULT_PATH, OLLAMA_HOST, JWT_SECRET, PORT
166
+ ├── package.json ← agent-enterprise + agent-web
167
+ └── tsconfig.json
158
168
  ```
159
169
 
160
- When a second project is added, a **common root** is auto-detected (`~/dev/my-system/`). The next `/workspace switch` sets that directory as the agent's working directory, giving it access to all services at once.
170
+ ---
171
+
172
+ ## Examples
161
173
 
162
- ### Commands
174
+ ### Coding assistant
163
175
 
164
- | Command | Description |
165
- |---|---|
166
- | `/workspace create <name>` | Create a workspace |
167
- | `/workspace add <ws> <cwd> [name]` | Add a project |
168
- | `/workspace import <cwd> [ws] [name]` | Add project (auto-creates workspace) |
169
- | `/workspace switch <ws> [project]` | Switch to workspace (uses shared root if configured) |
170
- | `/workspace set-root <ws> [path]` | Set shared root manually (auto-detected if no path) |
171
- | `/workspace remove <ws> <project>` | Remove a project |
172
- | `/workspace delete <name>` | Delete workspace |
173
- | `/workspace list` | List all workspaces |
176
+ ```bash
177
+ npx create-bk-agent my-dev-assistant
178
+ # → coding → repl → deepseek
174
179
 
175
- ### Shared root (microservices)
180
+ cd my-dev-assistant
181
+ cp .env.example .env
182
+ # Edit .env: add DEEPSEEK_API_KEY
176
183
 
177
- For a system with multiple services under a common parent:
184
+ # Describe your project
185
+ nano AGENT.md
178
186
 
179
- ```
180
- ~/dev/my-system/ ← shared root (agent workingDir)
181
- ├── auth-service/
182
- ├── api-gateway/
183
- └── user-service/
187
+ npm install && npm run dev
188
+ # > What can I help with?
184
189
  ```
185
190
 
186
- The agent can read and edit files across all services using relative paths:
191
+ ### Enterprise on-premises assistant
187
192
 
193
+ ```bash
194
+ npx create-bk-agent company-assistant
195
+ # → enterprise → web → ollama
196
+
197
+ cd company-assistant
198
+ cp .env.example .env
199
+ # Edit .env: VAULT_PATH=/path/to/obsidian-vault
200
+
201
+ ollama serve
202
+ ollama pull llama3.2
203
+ ollama pull nomic-embed-text
204
+
205
+ npm install && npm run dev
206
+ # → Indexing vault...
207
+ # → Server running on :4001
208
+ # Chat: http://localhost:4001/
209
+ # Kanban: http://localhost:4001/#kanban
188
210
  ```
189
- auth-service/src/middleware.ts
190
- api-gateway/src/routes/auth.ts
211
+
212
+ ### Autonomous cron agent
213
+
214
+ ```bash
215
+ npx create-bk-agent standup-bot
216
+ # → autonomous → repl → deepseek
217
+
218
+ cd standup-bot
219
+ # Edit src/triggers/index.ts: schedule, prompt, output
220
+ npm install && npm run dev
191
221
  ```
192
222
 
193
- To override the auto-detected root:
223
+ ### MCP server exposing your tools
224
+
225
+ ```bash
226
+ npx create-bk-agent my-tools-server
227
+ # → single → mcp-http → openai
194
228
 
229
+ cd my-tools-server
230
+ # Add tools to src/tools/
231
+ # Add agent to src/agents/
232
+ npm install && npm run server # MCP server on :3000
195
233
  ```
196
- /workspace set-root my-system ~/dev/my-system
234
+
235
+ Claude Desktop config:
236
+
237
+ ```json
238
+ {
239
+ "mcpServers": {
240
+ "my-tools": {
241
+ "command": "npx",
242
+ "args": ["-y", "my-tools-server"]
243
+ }
244
+ }
245
+ }
197
246
  ```
198
247
 
199
248
  ---
200
249
 
201
- ## Requirements
250
+ ## `bk add` command
251
+
252
+ After scaffolding, add new components to your project:
253
+
254
+ ```bash
255
+ bk add tool lookup-order # creates src/tools/lookup-order.ts
256
+ bk add agent billing # creates src/agents/billing.json
257
+ bk add trigger daily-report # adds a cron trigger
258
+ ```
202
259
 
203
- - Node.js >= 20
204
- - An API key for your chosen provider (Anthropic, OpenAI, DeepSeek, or Ollama)
260
+ ---
205
261
 
206
- ## License
262
+ ## Scripts in scaffolded projects
207
263
 
208
- MIT © [BackendKit Labs](https://github.com/BackendKit-labs)
264
+ | Script | Description |
265
+ |--------|-------------|
266
+ | `npm run dev` | Development with tsx / ts-node |
267
+ | `npm run build` | Compile TypeScript |
268
+ | `npm run start` | Run compiled output |
269
+ | `npm run server` | Start MCP or web server |
270
+ | `npm run typecheck` | TypeScript type-check only |
package/dist/src/index.js CHANGED
@@ -65,6 +65,7 @@ function describeChoices(choices) {
65
65
  'mcp-stdio': 'MCP Server (stdio)',
66
66
  hybrid: 'REPL + MCP Server',
67
67
  library: 'Library',
68
+ web: 'Web Server (chat + kanban)',
68
69
  };
69
70
  const archLabel = arch[choices.architecture] ?? choices.architecture;
70
71
  if (!choices.deployMode)
@@ -83,6 +84,17 @@ function buildNextSteps(choices) {
83
84
  return ['Implement your LLM provider in src/index.ts', 'npm run dev'];
84
85
  // Enterprise — local LLM + RAG
85
86
  if (arch === 'enterprise') {
87
+ if (mode === 'web') {
88
+ return [
89
+ 'Make sure Ollama is running: ollama serve',
90
+ 'Pull model: ollama pull llama3.2',
91
+ 'Review vault path in .env (VAULT_PATH)',
92
+ 'npm run dev # indexes vault + starts server on :4001',
93
+ '# Chat: http://localhost:4001/',
94
+ '# Kanban: http://localhost:4001/#kanban',
95
+ '# Monitor: ws://localhost:4001/monitor',
96
+ ];
97
+ }
86
98
  return [
87
99
  'Make sure Ollama is running: ollama serve',
88
100
  'Pull required models: ollama pull llama3.2 && ollama pull nomic-embed-text',
@@ -45,7 +45,7 @@ const SKILL_PACK_CHOICES = [
45
45
  { title: p('Go', 24) + 'go test, golangci-lint', value: 'go' },
46
46
  { title: p('Docker / K8s', 24) + 'docker, kubectl, helm', value: 'docker' },
47
47
  ];
48
- const DEPLOY_MODE_CHOICES = [
48
+ const DEPLOY_MODE_CHOICES_BASE = [
49
49
  {
50
50
  title: p('Terminal REPL', 28) + 'Humans type requests, agent responds in the terminal',
51
51
  value: 'repl',
@@ -68,6 +68,15 @@ const DEPLOY_MODE_CHOICES = [
68
68
  value: 'library',
69
69
  },
70
70
  ];
71
+ const WEB_DEPLOY_CHOICE = {
72
+ title: p('Web server', 28) + 'WebSocket chat + kanban monitor UI on port 4001',
73
+ value: 'web',
74
+ description: 'Serves @backendkit-labs/agent-web with all 6 enterprise departments',
75
+ };
76
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
77
+ const deployChoices = (_prev, v) => v.architecture === 'enterprise'
78
+ ? [...DEPLOY_MODE_CHOICES_BASE, WEB_DEPLOY_CHOICE]
79
+ : DEPLOY_MODE_CHOICES_BASE;
71
80
  const PROVIDER_CHOICES = [
72
81
  { title: p('Anthropic (Claude)', 32) + 'claude-sonnet-4-6 recommended', value: 'anthropic' },
73
82
  { title: p('OpenAI', 32) + 'gpt-4o recommended', value: 'openai' },
@@ -115,7 +124,7 @@ async function askQuestions(defaultName) {
115
124
  type: whenDeploy,
116
125
  name: 'deployMode',
117
126
  message: 'How will this agent be used?',
118
- choices: DEPLOY_MODE_CHOICES,
127
+ choices: deployChoices,
119
128
  initial: 0,
120
129
  },
121
130
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
@@ -77,6 +77,11 @@ const DEPLOY_SCRIPTS = {
77
77
  delete s['server'];
78
78
  },
79
79
  // hybrid: keep both dev (REPL) and server (MCP) — no changes
80
+ web: (s) => {
81
+ s['dev'] = 'ts-node src/server.ts';
82
+ s['start'] = 'node dist/server.js';
83
+ delete s['server'];
84
+ },
80
85
  library: (s) => {
81
86
  delete s['dev'];
82
87
  delete s['server'];
@@ -84,6 +89,7 @@ const DEPLOY_SCRIPTS = {
84
89
  },
85
90
  };
86
91
  const MCP_DEPLOY_MODES = ['mcp-http', 'mcp-stdio', 'hybrid'];
92
+ const WEB_DEPLOY_MODES = ['web'];
87
93
  function patchPackageJson(dir, projectName, deployMode) {
88
94
  const pkgPath = path.join(dir, 'package.json');
89
95
  if (!fs.existsSync(pkgPath))
@@ -98,6 +104,10 @@ function patchPackageJson(dir, projectName, deployMode) {
98
104
  pkg.dependencies ??= {};
99
105
  pkg.dependencies['@backendkit-labs/mcp-server'] ??= '^0.15.0';
100
106
  }
107
+ if (deployMode && WEB_DEPLOY_MODES.includes(deployMode)) {
108
+ pkg.dependencies ??= {};
109
+ pkg.dependencies['@backendkit-labs/agent-web'] ??= '^0.1.0';
110
+ }
101
111
  fs.writeFileSync(pkgPath, JSON.stringify(pkg, null, 2) + '\n');
102
112
  }
103
113
  // ── Write .env stub ───────────────────────────────────────────────────────────
@@ -165,10 +175,10 @@ function scaffold(choices, targetDir) {
165
175
  // 2. Deploy layer — overlaid on top of base (layered architectures only)
166
176
  if (isLayered && choices.deployMode && choices.deployMode !== 'library') {
167
177
  const deployDir = path.join(DEPLOY_DIR, choices.deployMode);
168
- if (!fs.existsSync(deployDir)) {
169
- throw new Error(`Deploy template not found: ${choices.deployMode} (in ${deployDir})`);
178
+ if (fs.existsSync(deployDir)) {
179
+ copyDir(deployDir, targetDir);
170
180
  }
171
- copyDir(deployDir, targetDir);
181
+ // No directory = base template already covers this mode
172
182
  }
173
183
  // 3. Skill packs — appended to engine.ts
174
184
  for (const pack of choices.skillPacks) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "create-bk-agent",
3
- "version": "0.20.1",
3
+ "version": "0.21.1",
4
4
  "description": "Create a new BackendKit agent project",
5
5
  "main": "dist/src/index.js",
6
6
  "bin": {