@meowlynxsea/koi 0.2.7 → 0.2.9
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 +11 -3
- package/scripts/postbuild.ts +33 -0
- package/scripts/postinstall.ts +81 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@meowlynxsea/koi",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.9",
|
|
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,13 @@
|
|
|
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
|
+
"bun",
|
|
80
|
+
"koffi",
|
|
81
|
+
"onnxruntime-node",
|
|
82
|
+
"protobufjs",
|
|
83
|
+
"sharp"
|
|
84
|
+
]
|
|
77
85
|
}
|
|
@@ -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,81 @@
|
|
|
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
|
+
// Platform modules installation is now handled by the installer scripts
|
|
29
|
+
// to avoid infinite recursion when using bun add in postinstall
|
|
30
|
+
// This script only creates the shim files for existing platform modules
|
|
31
|
+
|
|
32
|
+
const indexJsContent = `const module = await import("./libopentui.dylib", { with: { type: "file" } });
|
|
33
|
+
export default module.default;
|
|
34
|
+
`;
|
|
35
|
+
|
|
36
|
+
const indexJsWinContent = `const module = await import("./libopentui.dll", { with: { type: "file" } });
|
|
37
|
+
export default module.default;
|
|
38
|
+
`;
|
|
39
|
+
|
|
40
|
+
for (const moduleName of platformModules) {
|
|
41
|
+
const modulePath = join(rootDir, "node_modules", moduleName);
|
|
42
|
+
if (!existsSync(modulePath)) continue;
|
|
43
|
+
|
|
44
|
+
const indexJsPath = join(modulePath, "index.js");
|
|
45
|
+
const packageJsonPath = join(modulePath, "package.json");
|
|
46
|
+
|
|
47
|
+
// Create index.js if it doesn't exist
|
|
48
|
+
if (!existsSync(indexJsPath)) {
|
|
49
|
+
const content = moduleName.includes("win32")
|
|
50
|
+
? indexJsWinContent
|
|
51
|
+
: indexJsContent;
|
|
52
|
+
writeFileSync(indexJsPath, content);
|
|
53
|
+
console.log(`Created ${moduleName}/index.js`);
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
// Update package.json main field to point to .js
|
|
57
|
+
if (existsSync(packageJsonPath)) {
|
|
58
|
+
const pkg = JSON.parse(readFileSync(packageJsonPath, "utf-8"));
|
|
59
|
+
if (pkg.main === "index.ts") {
|
|
60
|
+
pkg.main = "index.js";
|
|
61
|
+
pkg.module = "index.js";
|
|
62
|
+
writeFileSync(packageJsonPath, JSON.stringify(pkg, null, 2) + "\n");
|
|
63
|
+
console.log(`Updated ${moduleName}/package.json`);
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
// Fix @opentui/core's dynamic import to use .js instead of .ts
|
|
69
|
+
const opentuiCorePath = join(rootDir, "node_modules", "@opentui", "core");
|
|
70
|
+
const indexHmk8xzt3Path = join(opentuiCorePath, "index-hmk8xzt3.js");
|
|
71
|
+
|
|
72
|
+
if (existsSync(indexHmk8xzt3Path)) {
|
|
73
|
+
let content = readFileSync(indexHmk8xzt3Path, "utf-8");
|
|
74
|
+
if (content.includes("/index.ts")) {
|
|
75
|
+
content = content.replace(/\/index\.ts/g, "/index.js");
|
|
76
|
+
writeFileSync(indexHmk8xzt3Path, content);
|
|
77
|
+
console.log("Fixed @opentui/core/index-hmk8xzt3.js dynamic import");
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
console.log("Postinstall complete.");
|