create-bk-agent 0.17.2 → 0.19.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 +57 -1
- package/dist/src/add/index.js +9 -0
- package/dist/src/add/modules/plugin.js +91 -0
- package/dist/src/add/patcher.js +41 -0
- package/package.json +33 -33
- 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/minimal/package.json +1 -1
- package/templates/base/multi-agent/package.json +1 -1
- package/templates/base/multi-agent/src/engine.ts +1 -0
- package/templates/base/single/package.json +1 -1
- package/templates/base/single/src/engine.ts +1 -0
- package/templates/coding/package.json +1 -1
- 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
|
@@ -11,7 +11,7 @@ npx create-bk-agent my-project
|
|
|
11
11
|
The CLI asks three questions and generates a production-ready project:
|
|
12
12
|
|
|
13
13
|
```
|
|
14
|
-
✨ create-bk-agent v0.
|
|
14
|
+
✨ create-bk-agent v0.18.0
|
|
15
15
|
|
|
16
16
|
? Project name: my-project
|
|
17
17
|
? Architecture: Multi-agent (orchestrator + specialists)
|
|
@@ -109,6 +109,62 @@ All `add` commands are **idempotent** — running the same command twice won't d
|
|
|
109
109
|
|
|
110
110
|
---
|
|
111
111
|
|
|
112
|
+
## Multi-project workspaces
|
|
113
|
+
|
|
114
|
+
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.
|
|
115
|
+
|
|
116
|
+
### Setup
|
|
117
|
+
|
|
118
|
+
Use the built-in `/workspace` slash commands from inside the running agent:
|
|
119
|
+
|
|
120
|
+
```
|
|
121
|
+
/workspace create my-system
|
|
122
|
+
/workspace add my-system ~/dev/my-system/auth-service
|
|
123
|
+
/workspace add my-system ~/dev/my-system/api-gateway
|
|
124
|
+
/workspace add my-system ~/dev/my-system/user-service
|
|
125
|
+
```
|
|
126
|
+
|
|
127
|
+
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.
|
|
128
|
+
|
|
129
|
+
### Commands
|
|
130
|
+
|
|
131
|
+
| Command | Description |
|
|
132
|
+
|---|---|
|
|
133
|
+
| `/workspace create <name>` | Create a workspace |
|
|
134
|
+
| `/workspace add <ws> <cwd> [name]` | Add a project |
|
|
135
|
+
| `/workspace import <cwd> [ws] [name]` | Add project (auto-creates workspace) |
|
|
136
|
+
| `/workspace switch <ws> [project]` | Switch to workspace (uses shared root if configured) |
|
|
137
|
+
| `/workspace set-root <ws> [path]` | Set shared root manually (auto-detected if no path) |
|
|
138
|
+
| `/workspace remove <ws> <project>` | Remove a project |
|
|
139
|
+
| `/workspace delete <name>` | Delete workspace |
|
|
140
|
+
| `/workspace list` | List all workspaces |
|
|
141
|
+
|
|
142
|
+
### Shared root (microservices)
|
|
143
|
+
|
|
144
|
+
For a system with multiple services under a common parent:
|
|
145
|
+
|
|
146
|
+
```
|
|
147
|
+
~/dev/my-system/ ← shared root (agent workingDir)
|
|
148
|
+
├── auth-service/
|
|
149
|
+
├── api-gateway/
|
|
150
|
+
└── user-service/
|
|
151
|
+
```
|
|
152
|
+
|
|
153
|
+
The agent can read and edit files across all services using relative paths:
|
|
154
|
+
|
|
155
|
+
```
|
|
156
|
+
auth-service/src/middleware.ts
|
|
157
|
+
api-gateway/src/routes/auth.ts
|
|
158
|
+
```
|
|
159
|
+
|
|
160
|
+
To override the auto-detected root:
|
|
161
|
+
|
|
162
|
+
```
|
|
163
|
+
/workspace set-root my-system ~/dev/my-system
|
|
164
|
+
```
|
|
165
|
+
|
|
166
|
+
---
|
|
167
|
+
|
|
112
168
|
## Requirements
|
|
113
169
|
|
|
114
170
|
- Node.js >= 20
|
package/dist/src/add/index.js
CHANGED
|
@@ -6,6 +6,7 @@ const server_1 = require("./modules/server");
|
|
|
6
6
|
const specialist_1 = require("./modules/specialist");
|
|
7
7
|
const tools_1 = require("./modules/tools");
|
|
8
8
|
const mcp_client_1 = require("./modules/mcp-client");
|
|
9
|
+
const plugin_1 = require("./modules/plugin");
|
|
9
10
|
const HELP = `
|
|
10
11
|
Usage: npx create-bk-agent add <module> [options]
|
|
11
12
|
|
|
@@ -23,11 +24,16 @@ Modules:
|
|
|
23
24
|
mcp-client <url> Add a remote MCP server to the engine
|
|
24
25
|
--name <s> Name for the mcpServers entry (default: last URL segment)
|
|
25
26
|
|
|
27
|
+
plugin <name> Install a backendkit agent as a stdio MCP plugin
|
|
28
|
+
Available: docker, k8s
|
|
29
|
+
|
|
26
30
|
Examples:
|
|
27
31
|
npx create-bk-agent add server --port 4000
|
|
28
32
|
npx create-bk-agent add specialist data-analyst
|
|
29
33
|
npx create-bk-agent add tools github
|
|
30
34
|
npx create-bk-agent add mcp-client http://localhost:3001/mcp --name billing
|
|
35
|
+
npx create-bk-agent add plugin docker
|
|
36
|
+
npx create-bk-agent add plugin k8s
|
|
31
37
|
`;
|
|
32
38
|
function runAdd(args, cwd) {
|
|
33
39
|
const [module, ...rest] = args;
|
|
@@ -59,6 +65,9 @@ function runAdd(args, cwd) {
|
|
|
59
65
|
case 'mcp-client':
|
|
60
66
|
(0, mcp_client_1.addMcpClient)(info, rest);
|
|
61
67
|
break;
|
|
68
|
+
case 'plugin':
|
|
69
|
+
(0, plugin_1.addPlugin)(info, rest);
|
|
70
|
+
break;
|
|
62
71
|
default:
|
|
63
72
|
console.error(`\n✗ Unknown module: "${module}"\n`);
|
|
64
73
|
console.log(HELP);
|
|
@@ -0,0 +1,91 @@
|
|
|
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.addPlugin = addPlugin;
|
|
37
|
+
const fs = __importStar(require("fs"));
|
|
38
|
+
const child_process_1 = require("child_process");
|
|
39
|
+
const patcher_1 = require("../patcher");
|
|
40
|
+
const PLUGINS = {
|
|
41
|
+
docker: {
|
|
42
|
+
npm: '@backendkit-labs/docker-agent',
|
|
43
|
+
tools: ['docker_execute', 'docker_deploy', 'docker_status'],
|
|
44
|
+
envHint: 'Requires: OPENAI_API_KEY (or LLM_API_KEY) and Docker daemon running.',
|
|
45
|
+
},
|
|
46
|
+
k8s: {
|
|
47
|
+
npm: '@backendkit-labs/k8s-agent',
|
|
48
|
+
tools: ['k8s_execute', 'k8s_deploy', 'k8s_status'],
|
|
49
|
+
envHint: 'Requires: OPENAI_API_KEY (or LLM_API_KEY) and kubectl configured.',
|
|
50
|
+
},
|
|
51
|
+
};
|
|
52
|
+
function addPlugin(info, args) {
|
|
53
|
+
const pluginName = args[0];
|
|
54
|
+
if (!pluginName) {
|
|
55
|
+
console.log('\nUsage: npx create-bk-agent add plugin <name>\n');
|
|
56
|
+
console.log('Available plugins:');
|
|
57
|
+
for (const [name, def] of Object.entries(PLUGINS)) {
|
|
58
|
+
console.log(` ${name.padEnd(10)} ${def.npm}`);
|
|
59
|
+
}
|
|
60
|
+
console.log('');
|
|
61
|
+
process.exit(0);
|
|
62
|
+
}
|
|
63
|
+
const plugin = PLUGINS[pluginName];
|
|
64
|
+
if (!plugin) {
|
|
65
|
+
console.error(`\n✗ Unknown plugin: "${pluginName}"`);
|
|
66
|
+
console.error(` Available: ${Object.keys(PLUGINS).join(', ')}\n`);
|
|
67
|
+
process.exit(1);
|
|
68
|
+
}
|
|
69
|
+
if (!fs.existsSync(info.engineFile)) {
|
|
70
|
+
console.error('\n✗ src/engine.ts not found.\n');
|
|
71
|
+
process.exit(1);
|
|
72
|
+
}
|
|
73
|
+
console.log(`\n Installing ${plugin.npm}...`);
|
|
74
|
+
const added = (0, patcher_1.addPackageDependency)(info.pkgFile, plugin.npm, 'latest');
|
|
75
|
+
if (added) {
|
|
76
|
+
(0, child_process_1.execSync)('npm install', { cwd: info.cwd, stdio: 'inherit' });
|
|
77
|
+
}
|
|
78
|
+
console.log(` Patching src/engine.ts...`);
|
|
79
|
+
const ok = (0, patcher_1.addMcpStdioEntry)(info.engineFile, pluginName, plugin.npm);
|
|
80
|
+
if (!ok) {
|
|
81
|
+
console.error('\n✗ Could not locate AgentEngine constructor in src/engine.ts.\n');
|
|
82
|
+
process.exit(1);
|
|
83
|
+
}
|
|
84
|
+
console.log(`\n ✅ Plugin "${pluginName}" added.\n`);
|
|
85
|
+
console.log(` MCP tools exposed:`);
|
|
86
|
+
for (const tool of plugin.tools)
|
|
87
|
+
console.log(` ${tool}`);
|
|
88
|
+
if (plugin.envHint)
|
|
89
|
+
console.log(`\n ${plugin.envHint}`);
|
|
90
|
+
console.log('');
|
|
91
|
+
}
|
package/dist/src/add/patcher.js
CHANGED
|
@@ -39,6 +39,7 @@ exports.insertBeforePattern = insertBeforePattern;
|
|
|
39
39
|
exports.addPackageScript = addPackageScript;
|
|
40
40
|
exports.addPackageDependency = addPackageDependency;
|
|
41
41
|
exports.addMcpServerEntry = addMcpServerEntry;
|
|
42
|
+
exports.addMcpStdioEntry = addMcpStdioEntry;
|
|
42
43
|
const fs = __importStar(require("fs"));
|
|
43
44
|
// ── Import block ──────────────────────────────────────────────────────────────
|
|
44
45
|
/** Adds `importLine` after the last import statement. No-op if already present. */
|
|
@@ -166,3 +167,43 @@ function addMcpServerEntry(file, name, url) {
|
|
|
166
167
|
fs.writeFileSync(file, lines.join('\n'));
|
|
167
168
|
return true;
|
|
168
169
|
}
|
|
170
|
+
/**
|
|
171
|
+
* Adds a stdio MCP entry `{ name, transport: 'stdio', command, args }` to AgentEngine.
|
|
172
|
+
* If mcpServers already exists, appends. Returns true on success.
|
|
173
|
+
*/
|
|
174
|
+
function addMcpStdioEntry(file, name, npmPackage) {
|
|
175
|
+
const content = fs.readFileSync(file, 'utf-8');
|
|
176
|
+
const entry = ` { name: '${name}', transport: 'stdio' as const, command: 'npx', args: ['-y', '${npmPackage}'] },`;
|
|
177
|
+
if (content.includes(`'${npmPackage}'`))
|
|
178
|
+
return true; // already registered
|
|
179
|
+
if (content.includes('mcpServers:')) {
|
|
180
|
+
const updated = content.replace(/(mcpServers:\s*\[)/, `$1\n${entry}`);
|
|
181
|
+
if (updated === content)
|
|
182
|
+
return false;
|
|
183
|
+
fs.writeFileSync(file, updated);
|
|
184
|
+
return true;
|
|
185
|
+
}
|
|
186
|
+
const lines = content.split('\n');
|
|
187
|
+
let depth = 0;
|
|
188
|
+
let engineStart = -1;
|
|
189
|
+
let closeIdx = -1;
|
|
190
|
+
for (let i = 0; i < lines.length; i++) {
|
|
191
|
+
if (lines[i].includes('new AgentEngine({')) {
|
|
192
|
+
engineStart = i;
|
|
193
|
+
depth = 0;
|
|
194
|
+
}
|
|
195
|
+
if (engineStart !== -1) {
|
|
196
|
+
depth += (lines[i].match(/\{/g) ?? []).length;
|
|
197
|
+
depth -= (lines[i].match(/\}/g) ?? []).length;
|
|
198
|
+
if (depth === 0 && i > engineStart) {
|
|
199
|
+
closeIdx = i;
|
|
200
|
+
break;
|
|
201
|
+
}
|
|
202
|
+
}
|
|
203
|
+
}
|
|
204
|
+
if (closeIdx === -1)
|
|
205
|
+
return false;
|
|
206
|
+
lines.splice(closeIdx, 0, ` mcpServers: [\n${entry}\n ],`);
|
|
207
|
+
fs.writeFileSync(file, lines.join('\n'));
|
|
208
|
+
return true;
|
|
209
|
+
}
|
package/package.json
CHANGED
|
@@ -1,33 +1,33 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "create-bk-agent",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"description": "Create a new BackendKit agent project",
|
|
5
|
-
"main": "dist/src/index.js",
|
|
6
|
-
"bin": {
|
|
7
|
-
"create-bk-agent": "./dist/bin/create-bk-agent.js"
|
|
8
|
-
},
|
|
9
|
-
"files": [
|
|
10
|
-
"dist/",
|
|
11
|
-
"templates/"
|
|
12
|
-
],
|
|
13
|
-
"repository": {
|
|
14
|
-
"type": "git",
|
|
15
|
-
"url": "https://github.com/BackendKit-labs/backendkit-agent-framework.git",
|
|
16
|
-
"directory": "packages/create-bk-agent"
|
|
17
|
-
},
|
|
18
|
-
"publishConfig": { "access": "public" },
|
|
19
|
-
"engines": { "node": ">=20.0.0" },
|
|
20
|
-
"scripts": {
|
|
21
|
-
"build": "tsc",
|
|
22
|
-
"prepack": "node scripts/copy-templates.js && npm run build",
|
|
23
|
-
"typecheck": "tsc --noEmit"
|
|
24
|
-
},
|
|
25
|
-
"dependencies": {
|
|
26
|
-
"prompts": "^2.4.2"
|
|
27
|
-
},
|
|
28
|
-
"devDependencies": {
|
|
29
|
-
"@types/node": "^20.0.0",
|
|
30
|
-
"@types/prompts": "^2.4.9",
|
|
31
|
-
"typescript": "^5.4.0"
|
|
32
|
-
}
|
|
33
|
-
}
|
|
1
|
+
{
|
|
2
|
+
"name": "create-bk-agent",
|
|
3
|
+
"version": "0.19.0",
|
|
4
|
+
"description": "Create a new BackendKit agent project",
|
|
5
|
+
"main": "dist/src/index.js",
|
|
6
|
+
"bin": {
|
|
7
|
+
"create-bk-agent": "./dist/bin/create-bk-agent.js"
|
|
8
|
+
},
|
|
9
|
+
"files": [
|
|
10
|
+
"dist/",
|
|
11
|
+
"templates/"
|
|
12
|
+
],
|
|
13
|
+
"repository": {
|
|
14
|
+
"type": "git",
|
|
15
|
+
"url": "git+https://github.com/BackendKit-labs/backendkit-agent-framework.git",
|
|
16
|
+
"directory": "packages/create-bk-agent"
|
|
17
|
+
},
|
|
18
|
+
"publishConfig": { "access": "public" },
|
|
19
|
+
"engines": { "node": ">=20.0.0" },
|
|
20
|
+
"scripts": {
|
|
21
|
+
"build": "tsc",
|
|
22
|
+
"prepack": "node scripts/copy-templates.js && npm run build",
|
|
23
|
+
"typecheck": "tsc --noEmit"
|
|
24
|
+
},
|
|
25
|
+
"dependencies": {
|
|
26
|
+
"prompts": "^2.4.2"
|
|
27
|
+
},
|
|
28
|
+
"devDependencies": {
|
|
29
|
+
"@types/node": "^20.0.0",
|
|
30
|
+
"@types/prompts": "^2.4.9",
|
|
31
|
+
"typescript": "^5.4.0"
|
|
32
|
+
}
|
|
33
|
+
}
|
|
@@ -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.17.0",
|
|
15
|
+
"@backendkit-labs/agent-core": "^0.17.0",
|
|
16
16
|
"dotenv": "^16.0.0"
|
|
17
17
|
},
|
|
18
18
|
"devDependencies": {
|