@feniix/bridgekit 0.4.0 → 0.5.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 +3 -2
- package/examples/README.md +40 -5
- package/llms.txt +4 -2
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -171,8 +171,9 @@ Use `PortableToolHost<CustomHost>` for values that may be either a built-in host
|
|
|
171
171
|
- Keep runtime imports in `dependencies`.
|
|
172
172
|
- Avoid `workspace:` or `file:` dependency ranges in publishable packages.
|
|
173
173
|
- Avoid dangling `sourceMappingURL` comments: publish maps and useful sources together, or disable source maps for package builds.
|
|
174
|
-
- For MCP stdio bins, ensure the
|
|
175
|
-
- If
|
|
174
|
+
- For MCP stdio bins, ensure the executable entrypoint starts with a Node shebang, has executable mode (`chmod +x` or equivalent), and is included by `npm pack --dry-run --json`.
|
|
175
|
+
- If an npm-launched bin depends on generated output, prefer a checked-in wrapper under `bin/` over pointing `bin` directly at `dist/`; the wrapper should resolve the package-local generated file and may run the package-local build for workspace/local execution.
|
|
176
|
+
- If a package keeps a source-loaded host entrypoint (for example a pi extension source file), use a package-local MCP build behind that wrapper and narrow the build to the MCP entrypoint plus shared host-neutral modules.
|
|
176
177
|
- Declare a compatible Node engine (`>=22.19.0`) in downstream packages that expose BridgeKit-powered MCP bins.
|
|
177
178
|
- Run `npm run check`, `npm run test`, `npm run pack:dry-run`, and `npm run package-smoke` before publishing.
|
|
178
179
|
- Treat `docs/releasing.md` as the future release handoff; this repository is not configured for automated publish yet.
|
package/examples/README.md
CHANGED
|
@@ -20,6 +20,8 @@ Some packages have a host that intentionally loads TypeScript source directly, w
|
|
|
20
20
|
```text
|
|
21
21
|
my-pi-extension-package/
|
|
22
22
|
package.json
|
|
23
|
+
bin/
|
|
24
|
+
my-tools-mcp.js # checked-in npm bin wrapper for local/workspace resilience
|
|
23
25
|
extensions/
|
|
24
26
|
tools.ts # host-neutral portable tools
|
|
25
27
|
index.ts # source-loaded pi adapter wiring
|
|
@@ -177,7 +179,7 @@ In `package.json`:
|
|
|
177
179
|
}
|
|
178
180
|
```
|
|
179
181
|
|
|
180
|
-
For mixed source-loaded pi + compiled MCP packages, keep the pi source entrypoint and point
|
|
182
|
+
For mixed source-loaded pi + compiled MCP packages, keep the pi source entrypoint and point npm `bin` at a checked-in wrapper rather than directly at generated `dist/` output:
|
|
181
183
|
|
|
182
184
|
```json
|
|
183
185
|
{
|
|
@@ -186,11 +188,11 @@ For mixed source-loaded pi + compiled MCP packages, keep the pi source entrypoin
|
|
|
186
188
|
"extensions": ["./extensions/index.ts"]
|
|
187
189
|
},
|
|
188
190
|
"bin": {
|
|
189
|
-
"my-tools-mcp": "./
|
|
191
|
+
"my-tools-mcp": "./bin/my-tools-mcp.js"
|
|
190
192
|
},
|
|
191
|
-
"files": ["extensions/", "dist/", "README.md", "LICENSE"],
|
|
193
|
+
"files": ["bin/", "extensions/", "dist/", "README.md", "LICENSE"],
|
|
192
194
|
"scripts": {
|
|
193
|
-
"build:mcp": "tsc --project tsconfig.mcp.json
|
|
195
|
+
"build:mcp": "tsc --project tsconfig.mcp.json",
|
|
194
196
|
"prepack": "npm run build:mcp"
|
|
195
197
|
},
|
|
196
198
|
"engines": {
|
|
@@ -203,6 +205,38 @@ For mixed source-loaded pi + compiled MCP packages, keep the pi source entrypoin
|
|
|
203
205
|
}
|
|
204
206
|
```
|
|
205
207
|
|
|
208
|
+
The wrapper should resolve the generated MCP server relative to the installed package, build it when missing in local/workspace execution, and preserve build failures:
|
|
209
|
+
|
|
210
|
+
```js
|
|
211
|
+
#!/usr/bin/env node
|
|
212
|
+
import { existsSync } from "node:fs";
|
|
213
|
+
import { spawnSync } from "node:child_process";
|
|
214
|
+
import { dirname, join, resolve } from "node:path";
|
|
215
|
+
import { fileURLToPath, pathToFileURL } from "node:url";
|
|
216
|
+
|
|
217
|
+
const packageRoot = resolve(dirname(fileURLToPath(import.meta.url)), "..");
|
|
218
|
+
const serverPath = join(packageRoot, "dist", "extensions", "mcp-server.js");
|
|
219
|
+
|
|
220
|
+
if (!existsSync(serverPath)) {
|
|
221
|
+
const build = spawnSync("npm", ["run", "build:mcp", "--silent"], {
|
|
222
|
+
cwd: packageRoot,
|
|
223
|
+
stdio: "inherit",
|
|
224
|
+
shell: process.platform === "win32",
|
|
225
|
+
timeout: 60_000,
|
|
226
|
+
});
|
|
227
|
+
|
|
228
|
+
if (build.status !== 0 || !existsSync(serverPath)) {
|
|
229
|
+
console.error("[my-tools] Failed to build the local MCP server. Run `npm run build:mcp` and try again.");
|
|
230
|
+
process.exit(build.status && build.status !== 0 ? build.status : 1);
|
|
231
|
+
}
|
|
232
|
+
}
|
|
233
|
+
|
|
234
|
+
const { runServer } = await import(pathToFileURL(serverPath).href);
|
|
235
|
+
await runServer();
|
|
236
|
+
```
|
|
237
|
+
|
|
238
|
+
Commit the wrapper with executable mode (`chmod +x bin/my-tools-mcp.js`) and verify `npm pack --dry-run --json` includes it with executable mode.
|
|
239
|
+
|
|
206
240
|
MCP behavior:
|
|
207
241
|
|
|
208
242
|
- `tools/list` exposes TypeBox schemas directly as JSON Schema.
|
|
@@ -269,7 +303,8 @@ For publishable tool packages:
|
|
|
269
303
|
- Declare Node `>=22.19.0` when publishing BridgeKit-powered MCP bins.
|
|
270
304
|
- Avoid `workspace:` or `file:` ranges in publishable package dependencies.
|
|
271
305
|
- Avoid dangling `sourceMappingURL` comments: either publish maps and useful sources, or disable source maps for package builds.
|
|
272
|
-
- Ensure
|
|
306
|
+
- Ensure the npm bin entrypoint starts with a shebang, is executable (`chmod +x` or equivalent), and appears in `npm pack --dry-run --json` with executable mode.
|
|
307
|
+
- When a bin depends on generated output, prefer a checked-in wrapper under `bin/` over pointing directly at `dist/`; test existing output, missing output, failed builds, and successful builds that omit the expected file.
|
|
273
308
|
- If only the MCP bin needs compiled output, narrow its tsconfig to the MCP entrypoint and shared host-neutral modules instead of compiling unrelated host adapters.
|
|
274
309
|
- Add a packed-install smoke test that installs tarballs into a temporary project.
|
|
275
310
|
- For BridgeKit itself, run `npm run check`, `npm run test`, `npm run pack:dry-run`, and `npm run package-smoke` before release.
|
package/llms.txt
CHANGED
|
@@ -91,11 +91,13 @@ Use `PortableToolHost<"custom-host">` when a value may be either a built-in host
|
|
|
91
91
|
Some hosts, such as pi in source-extension packages, may intentionally load TypeScript source while MCP clients launched from npm need compiled JavaScript. In that case:
|
|
92
92
|
|
|
93
93
|
- Keep the host source entrypoint if that is the package convention, e.g. `pi.extensions: ["./extensions/index.ts"]`.
|
|
94
|
-
- Add a package-local MCP build
|
|
94
|
+
- Add a package-local MCP build and point npm `bin` at a checked-in wrapper under `bin/`, not directly at generated `dist/` output.
|
|
95
|
+
- The wrapper should resolve the package-local generated MCP server, run the package-local build when output is missing in workspace/local execution, and preserve non-zero build failures.
|
|
95
96
|
- Narrow the MCP build to the MCP entrypoint and shared host-neutral modules; avoid compiling pi adapter entrypoints into the standalone MCP path.
|
|
96
97
|
- Put runtime imports used by the compiled MCP bin in `dependencies`, not only peers or dev dependencies.
|
|
97
98
|
- Declare BridgeKit's Node engine requirement in the downstream package (`>=22.19.0`).
|
|
98
|
-
- Ensure the
|
|
99
|
+
- Ensure the checked-in wrapper is executable (`chmod +x` or equivalent) and verify the mode with `npm pack --dry-run --json`.
|
|
100
|
+
- Test wrapper behavior for existing output, missing output, failed builds, and builds that exit successfully without creating the expected file.
|
|
99
101
|
|
|
100
102
|
## Anti-patterns
|
|
101
103
|
|