@meowlynxsea/koi 0.2.6 → 0.2.8

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@meowlynxsea/koi",
3
- "version": "0.2.6",
3
+ "version": "0.2.8",
4
4
  "description": "A coding agent built on Pi SDK with TUI + Bun runtime",
5
5
  "module": "src/main.tsx",
6
6
  "type": "module",
@@ -12,6 +12,7 @@
12
12
  "files": [
13
13
  "dist",
14
14
  "bin",
15
+ "scripts",
15
16
  "src/main.tsx",
16
17
  "src/cce",
17
18
  "!src/cce/web/frontend/node_modules",
@@ -23,7 +24,6 @@
23
24
  "!src/cce/web/frontend/bun.lock",
24
25
  "!src/cce/web/frontend/index.html",
25
26
  "src/skills",
26
- "src/scripts",
27
27
  "src/tools",
28
28
  "src/styles.css",
29
29
  "src/commands",
@@ -73,5 +73,11 @@
73
73
  "jimp": "^1.6.1",
74
74
  "react": "^19.2.6",
75
75
  "turndown": "^7.2.4"
76
- }
76
+ },
77
+ "trustedDependencies": [
78
+ "@google/genai",
79
+ "koffi",
80
+ "onnxruntime-node",
81
+ "protobufjs"
82
+ ]
77
83
  }
@@ -0,0 +1,33 @@
1
+ /**
2
+ * Post-build script to fix native module paths in the bundle.
3
+ *
4
+ * Some native modules (like onnxruntime-node) use relative paths that are
5
+ * valid in node_modules but not when bundled. This script patches those paths.
6
+ */
7
+
8
+ import { existsSync, readFileSync, writeFileSync } from "fs";
9
+ import { join, dirname } from "path";
10
+ import { fileURLToPath } from "url";
11
+
12
+ const __dirname = dirname(fileURLToPath(import.meta.url));
13
+ const distDir = join(__dirname, "..", "dist");
14
+ const mainJsPath = join(distDir, "main.js");
15
+
16
+ if (!existsSync(mainJsPath)) {
17
+ console.log("dist/main.js not found, skipping postbuild...");
18
+ process.exit(0);
19
+ }
20
+
21
+ let content = readFileSync(mainJsPath, "utf-8");
22
+
23
+ // Fix onnxruntime-node path: ../bin/... -> ./bin/...
24
+ // The original code uses "../bin/napi-v3/..." which is relative to
25
+ // node_modules/onnxruntime-node/dist/, but when bundled, the path needs
26
+ // to be relative to dist/main.js
27
+ if (content.includes("../bin/napi-v3/")) {
28
+ content = content.replace(/\.\.\/bin\/napi-v3\//g, "./onnx-bin/napi-v3/");
29
+ writeFileSync(mainJsPath, content);
30
+ console.log("Fixed onnxruntime-node native module path in bundle");
31
+ }
32
+
33
+ console.log("Postbuild complete.");
@@ -0,0 +1,103 @@
1
+ /**
2
+ * Post-install script to fix @opentui/core platform-specific modules.
3
+ *
4
+ * @opentui/core-darwin-arm64 and similar packages use .ts files as entry points,
5
+ * but bun bundler cannot resolve dynamic .ts imports in bundled output.
6
+ * This script creates .js files that can be resolved at runtime.
7
+ * It also ensures all platform-specific packages are installed (not just the current platform).
8
+ */
9
+
10
+ import { existsSync, writeFileSync, readFileSync } from "fs";
11
+ import { join, dirname } from "path";
12
+ import { fileURLToPath } from "url";
13
+ import { execSync } from "child_process";
14
+
15
+ const __dirname = dirname(fileURLToPath(import.meta.url));
16
+ const rootDir = join(__dirname, "..");
17
+
18
+ // Platform-specific modules that need .js shims and installation
19
+ const platformModules = [
20
+ "@opentui/core-darwin-arm64",
21
+ "@opentui/core-darwin-x64",
22
+ "@opentui/core-linux-arm64",
23
+ "@opentui/core-linux-x64",
24
+ "@opentui/core-win32-arm64",
25
+ "@opentui/core-win32-x64",
26
+ ];
27
+
28
+ // Ensure all platform-specific packages are installed first
29
+ // This is needed because @opentui/core uses dynamic imports based on platform,
30
+ // and npm/bun only installs the current platform's optional dependency
31
+ const coreVersion = (() => {
32
+ const pkgPath = join(rootDir, "node_modules", "@opentui", "core", "package.json");
33
+ if (!existsSync(pkgPath)) return null;
34
+ try {
35
+ return JSON.parse(readFileSync(pkgPath, "utf-8")).version;
36
+ } catch {
37
+ return null;
38
+ }
39
+ })();
40
+
41
+ if (coreVersion) {
42
+ for (const pkg of platformModules) {
43
+ const pkgPath = join(rootDir, "node_modules", pkg);
44
+ if (existsSync(pkgPath)) continue;
45
+ console.log(`Installing ${pkg}...`);
46
+ try {
47
+ execSync(`bun add ${pkg}@${coreVersion}`, { cwd: rootDir, stdio: "pipe" });
48
+ } catch (e) {
49
+ console.warn(`Warning: Failed to install ${pkg}`);
50
+ }
51
+ }
52
+ }
53
+
54
+ const indexJsContent = `const module = await import("./libopentui.dylib", { with: { type: "file" } });
55
+ export default module.default;
56
+ `;
57
+
58
+ const indexJsWinContent = `const module = await import("./libopentui.dll", { with: { type: "file" } });
59
+ export default module.default;
60
+ `;
61
+
62
+ for (const moduleName of platformModules) {
63
+ const modulePath = join(rootDir, "node_modules", moduleName);
64
+ if (!existsSync(modulePath)) continue;
65
+
66
+ const indexJsPath = join(modulePath, "index.js");
67
+ const packageJsonPath = join(modulePath, "package.json");
68
+
69
+ // Create index.js if it doesn't exist
70
+ if (!existsSync(indexJsPath)) {
71
+ const content = moduleName.includes("win32")
72
+ ? indexJsWinContent
73
+ : indexJsContent;
74
+ writeFileSync(indexJsPath, content);
75
+ console.log(`Created ${moduleName}/index.js`);
76
+ }
77
+
78
+ // Update package.json main field to point to .js
79
+ if (existsSync(packageJsonPath)) {
80
+ const pkg = JSON.parse(readFileSync(packageJsonPath, "utf-8"));
81
+ if (pkg.main === "index.ts") {
82
+ pkg.main = "index.js";
83
+ pkg.module = "index.js";
84
+ writeFileSync(packageJsonPath, JSON.stringify(pkg, null, 2) + "\n");
85
+ console.log(`Updated ${moduleName}/package.json`);
86
+ }
87
+ }
88
+ }
89
+
90
+ // Fix @opentui/core's dynamic import to use .js instead of .ts
91
+ const opentuiCorePath = join(rootDir, "node_modules", "@opentui", "core");
92
+ const indexHmk8xzt3Path = join(opentuiCorePath, "index-hmk8xzt3.js");
93
+
94
+ if (existsSync(indexHmk8xzt3Path)) {
95
+ let content = readFileSync(indexHmk8xzt3Path, "utf-8");
96
+ if (content.includes("/index.ts")) {
97
+ content = content.replace(/\/index\.ts/g, "/index.js");
98
+ writeFileSync(indexHmk8xzt3Path, content);
99
+ console.log("Fixed @opentui/core/index-hmk8xzt3.js dynamic import");
100
+ }
101
+ }
102
+
103
+ console.log("Postinstall complete.");