@kililabs/kili 0.1.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.
Files changed (2) hide show
  1. package/install.js +62 -0
  2. package/package.json +16 -0
package/install.js ADDED
@@ -0,0 +1,62 @@
1
+ const https = require("https");
2
+ const fs = require("fs");
3
+ const path = require("path");
4
+
5
+ const REPO = "kililabs/kili";
6
+ const BIN_DIR = path.join(__dirname, "bin");
7
+ const BIN_PATH = path.join(BIN_DIR, "kili.exe");
8
+ const VERSION = require("./package.json").version;
9
+
10
+ const DOWNLOAD_URL = `https://github.com/${REPO}/releases/download/v${VERSION}/kili_windows_amd64.exe`;
11
+
12
+ function download(url, dest, redirects) {
13
+ redirects = redirects || 0;
14
+ if (redirects > 5) {
15
+ console.error("Too many redirects");
16
+ process.exit(1);
17
+ }
18
+
19
+ https
20
+ .get(url, (res) => {
21
+ if (res.statusCode === 301 || res.statusCode === 302) {
22
+ download(res.headers.location, dest, redirects + 1);
23
+ return;
24
+ }
25
+
26
+ if (res.statusCode !== 200) {
27
+ console.error(
28
+ `Failed to download kili binary: HTTP ${res.statusCode}\nURL: ${url}`
29
+ );
30
+ process.exit(1);
31
+ }
32
+
33
+ if (!fs.existsSync(BIN_DIR)) {
34
+ fs.mkdirSync(BIN_DIR, { recursive: true });
35
+ }
36
+
37
+ const file = fs.createWriteStream(dest);
38
+ res.pipe(file);
39
+
40
+ file.on("finish", () => {
41
+ file.close();
42
+ try {
43
+ fs.chmodSync(dest, 0o755);
44
+ } catch (e) {}
45
+ console.log("kili installed successfully to " + dest);
46
+ });
47
+
48
+ file.on("error", (err) => {
49
+ fs.unlink(dest, () => {});
50
+ console.error("Error writing kili binary:", err.message);
51
+ process.exit(1);
52
+ });
53
+ })
54
+ .on("error", (err) => {
55
+ console.error("Error downloading kili binary:", err.message);
56
+ process.exit(1);
57
+ });
58
+ }
59
+
60
+ console.log("Downloading kili binary for Windows (amd64)...");
61
+ console.log("URL:", DOWNLOAD_URL);
62
+ download(DOWNLOAD_URL, BIN_PATH);
package/package.json ADDED
@@ -0,0 +1,16 @@
1
+ {
2
+ "name": "@kililabs/kili",
3
+ "version": "0.1.0",
4
+ "description": "Kili CLI - A terminal-first AI coding assistant",
5
+ "scripts": {
6
+ "postinstall": "node install.js"
7
+ },
8
+ "bin": {
9
+ "kili": "./bin/kili.exe"
10
+ },
11
+ "keywords": ["kili", "ai", "cli", "coding", "assistant"],
12
+ "author": "Kili Labs",
13
+ "license": "MIT",
14
+ "os": ["win32"],
15
+ "cpu": ["x64"]
16
+ }