packet28 0.2.49 → 0.2.50

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.
Files changed (2) hide show
  1. package/bin/p28.js +121 -0
  2. package/package.json +7 -6
package/bin/p28.js ADDED
@@ -0,0 +1,121 @@
1
+ #!/usr/bin/env node
2
+ // Unified entry point for the p28 indexed search CLI.
3
+ // Resolves the correct platform-specific binary and spawns it.
4
+
5
+ import { execSync, spawn } from "node:child_process";
6
+ import { chmodSync, existsSync, statSync } 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 {
49
+ const pkgJsonPath = require.resolve(`${platformPackage}/package.json`);
50
+ const vendorDir = path.join(path.dirname(pkgJsonPath), "bin");
51
+ const binaryPath = path.join(vendorDir, name);
52
+ if (existsSync(binaryPath)) return binaryPath;
53
+ } catch {
54
+ // optional dep not installed — fall through
55
+ }
56
+
57
+ const localBinary = path.join(
58
+ __dirname,
59
+ "..",
60
+ "vendor",
61
+ platformKey,
62
+ name,
63
+ );
64
+ if (existsSync(localBinary)) return localBinary;
65
+
66
+ try {
67
+ const which = execSync(`which ${name}`, { encoding: "utf-8" }).trim();
68
+ if (which && existsSync(which)) return which;
69
+ } catch {
70
+ // not on PATH
71
+ }
72
+
73
+ throw new Error(
74
+ `Could not find ${name} binary. Reinstall: npm install -g packet28@latest`,
75
+ );
76
+ }
77
+
78
+ const binaryPath = findBinary("p28");
79
+
80
+ try {
81
+ const mode = statSync(binaryPath).mode;
82
+ if (!(mode & 0o111)) {
83
+ chmodSync(binaryPath, mode | 0o755);
84
+ }
85
+ } catch {
86
+ // ignore — will fail at spawn if truly broken
87
+ }
88
+
89
+ const child = spawn(binaryPath, process.argv.slice(2), {
90
+ stdio: "inherit",
91
+ env: { ...process.env, PACKET28_MANAGED_BY_NPM: "1" },
92
+ });
93
+
94
+ child.on("error", (err) => {
95
+ console.error(`Failed to start p28: ${err.message}`);
96
+ process.exit(1);
97
+ });
98
+
99
+ ["SIGINT", "SIGTERM", "SIGHUP"].forEach((sig) => {
100
+ process.on(sig, () => {
101
+ if (!child.killed) {
102
+ try {
103
+ child.kill(sig);
104
+ } catch {
105
+ /* ignore */
106
+ }
107
+ }
108
+ });
109
+ });
110
+
111
+ const result = await new Promise((resolve) => {
112
+ child.on("exit", (code, signal) => {
113
+ resolve(signal ? { type: "signal", signal } : { type: "code", code: code ?? 1 });
114
+ });
115
+ });
116
+
117
+ if (result.type === "signal") {
118
+ process.kill(process.pid, result.signal);
119
+ } else {
120
+ process.exit(result.code);
121
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "packet28",
3
- "version": "0.2.49",
3
+ "version": "0.2.50",
4
4
  "description": "Context broker for AI coding agents — manages your agent's context window so it conserves tokens",
5
5
  "license": "MIT",
6
6
  "repository": {
@@ -10,7 +10,8 @@
10
10
  "homepage": "https://github.com/usharma123/Packet28",
11
11
  "bin": {
12
12
  "packet28": "bin/packet28.js",
13
- "packet28-mcp": "bin/packet28-mcp.js"
13
+ "packet28-mcp": "bin/packet28-mcp.js",
14
+ "p28": "bin/p28.js"
14
15
  },
15
16
  "type": "module",
16
17
  "engines": {
@@ -21,10 +22,10 @@
21
22
  "vendor"
22
23
  ],
23
24
  "optionalDependencies": {
24
- "@packet28/darwin-arm64": "0.2.49",
25
- "@packet28/darwin-x64": "0.2.49",
26
- "@packet28/linux-x64": "0.2.49",
27
- "@packet28/linux-arm64": "0.2.49"
25
+ "@packet28/darwin-arm64": "0.2.50",
26
+ "@packet28/darwin-x64": "0.2.50",
27
+ "@packet28/linux-x64": "0.2.50",
28
+ "@packet28/linux-arm64": "0.2.50"
28
29
  },
29
30
  "keywords": [
30
31
  "ai",