packet28 0.2.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.
@@ -0,0 +1,80 @@
1
+ #!/usr/bin/env node
2
+ // Shortcut for `packet28 mcp serve` — designed for MCP server config.
3
+ // Usage in claude_desktop_config.json:
4
+ // { "command": "packet28-mcp", "args": ["--root", "."] }
5
+
6
+ import { spawn } from "node:child_process";
7
+ import { existsSync } from "node:fs";
8
+ import { createRequire } from "node:module";
9
+ import path from "node:path";
10
+ import { fileURLToPath } from "node:url";
11
+
12
+ const __filename = fileURLToPath(import.meta.url);
13
+ const __dirname = path.dirname(__filename);
14
+ const require = createRequire(import.meta.url);
15
+
16
+ const PLATFORM_PACKAGES = {
17
+ "darwin-arm64": "@packet28/darwin-arm64",
18
+ "darwin-x64": "@packet28/darwin-x64",
19
+ "linux-x64": "@packet28/linux-x64",
20
+ "linux-arm64": "@packet28/linux-arm64",
21
+ };
22
+
23
+ function getPlatformKey() {
24
+ const { platform, arch } = process;
25
+ if (platform === "darwin" && arch === "arm64") return "darwin-arm64";
26
+ if (platform === "darwin" && arch === "x64") return "darwin-x64";
27
+ if (platform === "linux" && arch === "x64") return "linux-x64";
28
+ if (platform === "linux" && arch === "arm64") return "linux-arm64";
29
+ return null;
30
+ }
31
+
32
+ function findBinary(name) {
33
+ const platformKey = getPlatformKey();
34
+ if (!platformKey) {
35
+ throw new Error(`Unsupported platform: ${process.platform} (${process.arch})`);
36
+ }
37
+
38
+ const platformPackage = PLATFORM_PACKAGES[platformKey];
39
+ try {
40
+ const pkgJsonPath = require.resolve(`${platformPackage}/package.json`);
41
+ const bin = path.join(path.dirname(pkgJsonPath), "bin", name);
42
+ if (existsSync(bin)) return bin;
43
+ } catch { /* fall through */ }
44
+
45
+ const local = path.join(__dirname, "..", "vendor", platformKey, name);
46
+ if (existsSync(local)) return local;
47
+
48
+ throw new Error(`Could not find ${name}. Reinstall: npm install -g packet28@latest`);
49
+ }
50
+
51
+ const binaryPath = findBinary("Packet28");
52
+
53
+ // Prepend "mcp serve" to the user's args
54
+ const child = spawn(binaryPath, ["mcp", "serve", ...process.argv.slice(2)], {
55
+ stdio: "inherit",
56
+ env: { ...process.env, PACKET28_MANAGED_BY_NPM: "1" },
57
+ });
58
+
59
+ child.on("error", (err) => {
60
+ console.error(`Failed to start Packet28 MCP server: ${err.message}`);
61
+ process.exit(1);
62
+ });
63
+
64
+ ["SIGINT", "SIGTERM", "SIGHUP"].forEach((sig) => {
65
+ process.on(sig, () => {
66
+ if (!child.killed) try { child.kill(sig); } catch { /* ignore */ }
67
+ });
68
+ });
69
+
70
+ const result = await new Promise((resolve) => {
71
+ child.on("exit", (code, signal) => {
72
+ resolve(signal ? { type: "signal", signal } : { type: "code", code: code ?? 1 });
73
+ });
74
+ });
75
+
76
+ if (result.type === "signal") {
77
+ process.kill(process.pid, result.signal);
78
+ } else {
79
+ process.exit(result.code);
80
+ }
@@ -0,0 +1,115 @@
1
+ #!/usr/bin/env node
2
+ // Unified entry point for the Packet28 CLI.
3
+ // Resolves the correct platform-specific binary and spawns it.
4
+
5
+ import { execSync, spawn } from "node:child_process";
6
+ import { existsSync } from "node:fs";
7
+ import { createRequire } from "node:module";
8
+ import path from "node:path";
9
+ import { fileURLToPath } from "node:url";
10
+
11
+ const __filename = fileURLToPath(import.meta.url);
12
+ const __dirname = path.dirname(__filename);
13
+ const require = createRequire(import.meta.url);
14
+
15
+ const PLATFORM_PACKAGES = {
16
+ "darwin-arm64": "@packet28/darwin-arm64",
17
+ "darwin-x64": "@packet28/darwin-x64",
18
+ "linux-x64": "@packet28/linux-x64",
19
+ "linux-arm64": "@packet28/linux-arm64",
20
+ };
21
+
22
+ function getPlatformKey() {
23
+ const { platform, arch } = process;
24
+ switch (platform) {
25
+ case "darwin":
26
+ if (arch === "arm64") return "darwin-arm64";
27
+ if (arch === "x64") return "darwin-x64";
28
+ break;
29
+ case "linux":
30
+ if (arch === "x64") return "linux-x64";
31
+ if (arch === "arm64") return "linux-arm64";
32
+ break;
33
+ }
34
+ return null;
35
+ }
36
+
37
+ function findBinary(name) {
38
+ const platformKey = getPlatformKey();
39
+ if (!platformKey) {
40
+ throw new Error(
41
+ `Unsupported platform: ${process.platform} (${process.arch}). ` +
42
+ `Packet28 supports: darwin-arm64, darwin-x64, linux-x64, linux-arm64.`,
43
+ );
44
+ }
45
+
46
+ const platformPackage = PLATFORM_PACKAGES[platformKey];
47
+
48
+ // Try 1: resolve from the platform-specific optional dependency
49
+ try {
50
+ const pkgJsonPath = require.resolve(`${platformPackage}/package.json`);
51
+ const vendorDir = path.join(path.dirname(pkgJsonPath), "bin");
52
+ const binaryPath = path.join(vendorDir, name);
53
+ if (existsSync(binaryPath)) return binaryPath;
54
+ } catch {
55
+ // optional dep not installed — fall through
56
+ }
57
+
58
+ // Try 2: local vendor directory (for development / cargo-built binaries)
59
+ const localBinary = path.join(
60
+ __dirname,
61
+ "..",
62
+ "vendor",
63
+ platformKey,
64
+ name,
65
+ );
66
+ if (existsSync(localBinary)) return localBinary;
67
+
68
+ // Try 3: check if the binary is already on PATH
69
+ try {
70
+ const which = execSync(`which ${name}`, { encoding: "utf-8" }).trim();
71
+ if (which && existsSync(which)) return which;
72
+ } catch {
73
+ // not on PATH
74
+ }
75
+
76
+ throw new Error(
77
+ `Could not find ${name} binary. Reinstall: npm install -g packet28@latest`,
78
+ );
79
+ }
80
+
81
+ const binaryPath = findBinary("Packet28");
82
+
83
+ const child = spawn(binaryPath, process.argv.slice(2), {
84
+ stdio: "inherit",
85
+ env: { ...process.env, PACKET28_MANAGED_BY_NPM: "1" },
86
+ });
87
+
88
+ child.on("error", (err) => {
89
+ console.error(`Failed to start Packet28: ${err.message}`);
90
+ process.exit(1);
91
+ });
92
+
93
+ ["SIGINT", "SIGTERM", "SIGHUP"].forEach((sig) => {
94
+ process.on(sig, () => {
95
+ if (!child.killed) {
96
+ try {
97
+ child.kill(sig);
98
+ } catch {
99
+ /* ignore */
100
+ }
101
+ }
102
+ });
103
+ });
104
+
105
+ const result = await new Promise((resolve) => {
106
+ child.on("exit", (code, signal) => {
107
+ resolve(signal ? { type: "signal", signal } : { type: "code", code: code ?? 1 });
108
+ });
109
+ });
110
+
111
+ if (result.type === "signal") {
112
+ process.kill(process.pid, result.signal);
113
+ } else {
114
+ process.exit(result.code);
115
+ }
package/package.json ADDED
@@ -0,0 +1,39 @@
1
+ {
2
+ "name": "packet28",
3
+ "version": "0.2.0",
4
+ "description": "Context broker for AI coding agents — manages your agent's context window so it conserves tokens",
5
+ "license": "MIT",
6
+ "repository": {
7
+ "type": "git",
8
+ "url": "git+https://github.com/usharma123/Packet28.git"
9
+ },
10
+ "homepage": "https://github.com/usharma123/Packet28",
11
+ "bin": {
12
+ "packet28": "bin/packet28.js",
13
+ "packet28-mcp": "bin/packet28-mcp.js"
14
+ },
15
+ "type": "module",
16
+ "engines": {
17
+ "node": ">=18"
18
+ },
19
+ "files": [
20
+ "bin",
21
+ "vendor"
22
+ ],
23
+ "optionalDependencies": {
24
+ "@packet28/darwin-arm64": "0.2.0",
25
+ "@packet28/darwin-x64": "0.2.0",
26
+ "@packet28/linux-x64": "0.2.0",
27
+ "@packet28/linux-arm64": "0.2.0"
28
+ },
29
+ "keywords": [
30
+ "ai",
31
+ "agent",
32
+ "context",
33
+ "mcp",
34
+ "llm",
35
+ "coverage",
36
+ "coding-agent",
37
+ "token-management"
38
+ ]
39
+ }