usemcpkit 0.9.0 → 0.10.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 CHANGED
@@ -4,5 +4,6 @@
4
4
  npx usemcpkit
5
5
  ```
6
6
 
7
- A thin wrapper so `npx usemcpkit` runs `@usemcpkit/cli`; with no command it runs `mcpkit install`. See the
8
- [CLI](../cli/README.md) for the options.
7
+ A thin wrapper so `npx usemcpkit` runs the `usemcpkit` binary of the `@usemcpkit/cli-<target>` package for this
8
+ machine; with no command it runs `usemcpkit install`. See the
9
+ [README](../../README.md) for the options.
@@ -0,0 +1,68 @@
1
+ #!/usr/bin/env node
2
+ import { createRequire } from "node:module";
3
+ import { dirname, join } from "node:path";
4
+ import { spawn } from "node:child_process";
5
+ import { constants } from "node:os";
6
+ //#region src/const.ts
7
+ /** Each target's binaries are published as `@usemcpkit/cli-<target>`, holding `bin/usemcpkit[.exe]`. */
8
+ var PLATFORM_PACKAGE_PREFIX = "@usemcpkit/cli-";
9
+ var RUNNER_BINARY_PATH = "bin/usemcpkit";
10
+ //#endregion
11
+ //#region src/list-platform-packages.ts
12
+ /**
13
+ * The platform packages that may hold this machine's binary, in the order to try them. On Linux both the glibc and the
14
+ * musl package are named: npm installs only the one whose `libc` matches, so the first that resolves is the right one.
15
+ */
16
+ var listPlatformPackages = (platform, arch) => {
17
+ const target = `${platform === "win32" ? "windows" : platform}-${arch}`;
18
+ return (platform === "linux" ? [target, `${target}-musl`] : [target]).map((name) => `${PLATFORM_PACKAGE_PREFIX}${name}`);
19
+ };
20
+ //#endregion
21
+ //#region src/try-resolve-module.ts
22
+ /** Resolves `specifier`, or undefined when no such module is installed; any other failure is thrown. */
23
+ var tryResolveModule = (require, specifier) => {
24
+ try {
25
+ return require.resolve(specifier);
26
+ } catch (error) {
27
+ if (error instanceof Error && "code" in error && error.code === "MODULE_NOT_FOUND") return;
28
+ throw error;
29
+ }
30
+ };
31
+ //#endregion
32
+ //#region src/resolve-runner-binary.ts
33
+ /** The `usemcpkit` binary of the platform package npm installed for this machine, or undefined when there is none. */
34
+ var resolveRunnerBinary = (platform = process.platform, arch = process.arch) => {
35
+ const require = createRequire(import.meta.url);
36
+ const extension = platform === "win32" ? ".exe" : "";
37
+ for (const name of listPlatformPackages(platform, arch)) {
38
+ const packageJson = tryResolveModule(require, `${name}/package.json`);
39
+ if (packageJson !== void 0) return join(dirname(packageJson), `${RUNNER_BINARY_PATH}${extension}`);
40
+ }
41
+ };
42
+ //#endregion
43
+ //#region src/run-binary.ts
44
+ /**
45
+ * Runs `binary` with `args` on this process's stdio and resolves the code to exit with: its own, or 128 plus the
46
+ * signal number when a signal ended it, as a shell reports it.
47
+ */
48
+ var runBinary = (binary, args) => new Promise((resolve, reject) => {
49
+ const child = spawn(binary, args, { stdio: "inherit" });
50
+ child.on("error", reject);
51
+ child.on("exit", (code, signal) => {
52
+ if (signal !== null) {
53
+ resolve(128 + constants.signals[signal]);
54
+ return;
55
+ }
56
+ resolve(code ?? 0);
57
+ });
58
+ });
59
+ //#endregion
60
+ //#region src/main.ts
61
+ var binary = resolveRunnerBinary();
62
+ if (binary === void 0) {
63
+ process.stderr.write(`usemcpkit: no binary is published for ${process.platform}-${process.arch}\n`);
64
+ process.exit(1);
65
+ }
66
+ process.exitCode = await runBinary(binary, process.argv.slice(2));
67
+ //#endregion
68
+ export {};
package/package.json CHANGED
@@ -1,28 +1,25 @@
1
1
  {
2
2
  "name": "usemcpkit",
3
- "version": "0.9.0",
4
- "description": "npx usemcpkit: adds mcpkit to every AI client on this computer. Runs @usemcpkit/cli.",
3
+ "version": "0.10.0",
4
+ "description": "npx usemcpkit: runs the usemcpkit binary of this machine, which adds usemcpkit to every AI client with no command.",
5
5
  "repository": {
6
6
  "type": "git",
7
7
  "url": "git+https://github.com/MDReal32/mcpkit.git",
8
8
  "directory": "apps/npx"
9
9
  },
10
10
  "type": "module",
11
- "bin": "build/mcpkit.npx.js",
11
+ "bin": "build/usemcpkit.npx.js",
12
12
  "publishConfig": {
13
13
  "access": "public"
14
14
  },
15
15
  "files": [
16
- "build/mcpkit.npx.js"
16
+ "build/usemcpkit.npx.js"
17
17
  ],
18
18
  "scripts": {
19
19
  "build": "vite build --configLoader native",
20
20
  "typecheck": "tsc --noEmit",
21
21
  "lint": "biome check ."
22
22
  },
23
- "dependencies": {
24
- "@usemcpkit/cli": "0.9.0"
25
- },
26
23
  "devDependencies": {
27
24
  "@biomejs/biome": "2.5.15",
28
25
  "typescript": "^5.9.0",
@@ -31,5 +28,12 @@
31
28
  "engines": {
32
29
  "node": ">=22.18"
33
30
  },
34
- "license": "MIT"
31
+ "license": "MIT",
32
+ "optionalDependencies": {
33
+ "@usemcpkit/cli-linux-x64": "0.10.0",
34
+ "@usemcpkit/cli-linux-arm64": "0.10.0",
35
+ "@usemcpkit/cli-darwin-x64": "0.10.0",
36
+ "@usemcpkit/cli-darwin-arm64": "0.10.0",
37
+ "@usemcpkit/cli-windows-x64": "0.10.0"
38
+ }
35
39
  }
@@ -1,3 +0,0 @@
1
- #!/usr/bin/env node
2
- import "@usemcpkit/cli";
3
- export {};