@imi-ai/imi 0.3.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.
- package/package.json +19 -0
- package/run.js +87 -0
package/package.json
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@imi-ai/imi",
|
|
3
|
+
"version": "0.3.0",
|
|
4
|
+
"description": "IMI — the persistent brain for AI agents. One command to install and initialize.",
|
|
5
|
+
"bin": {
|
|
6
|
+
"imi": "./run.js"
|
|
7
|
+
},
|
|
8
|
+
"scripts": {},
|
|
9
|
+
"keywords": ["ai", "agents", "cli", "imi", "memory", "persistent"],
|
|
10
|
+
"author": "aibyimi",
|
|
11
|
+
"license": "MIT",
|
|
12
|
+
"repository": {
|
|
13
|
+
"type": "git",
|
|
14
|
+
"url": "https://github.com/ProjectAI00/ai-db-imi"
|
|
15
|
+
},
|
|
16
|
+
"engines": {
|
|
17
|
+
"node": ">=16"
|
|
18
|
+
}
|
|
19
|
+
}
|
package/run.js
ADDED
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
"use strict";
|
|
3
|
+
|
|
4
|
+
const https = require("https");
|
|
5
|
+
const { execSync, spawnSync } = require("child_process");
|
|
6
|
+
const { existsSync, mkdirSync, chmodSync, unlinkSync, createWriteStream } = require("fs");
|
|
7
|
+
const { join } = require("path");
|
|
8
|
+
const { homedir, tmpdir } = require("os");
|
|
9
|
+
|
|
10
|
+
const VERSION = require("./package.json").version;
|
|
11
|
+
const REPO = "ProjectAI00/ai-db-imi";
|
|
12
|
+
const BIN_DIR = join(homedir(), ".local", "bin");
|
|
13
|
+
const BIN = join(BIN_DIR, "imi");
|
|
14
|
+
|
|
15
|
+
function getTarget() {
|
|
16
|
+
const { platform, arch } = process;
|
|
17
|
+
if (platform === "darwin" && arch === "arm64") return "aarch64-apple-darwin";
|
|
18
|
+
if (platform === "darwin" && arch === "x64") return "x86_64-apple-darwin";
|
|
19
|
+
if (platform === "linux" && arch === "x64") return "x86_64-unknown-linux-musl";
|
|
20
|
+
if (platform === "linux" && arch === "arm64") return "aarch64-unknown-linux-musl";
|
|
21
|
+
console.error(`Unsupported platform: ${platform} ${arch}`);
|
|
22
|
+
process.exit(1);
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
function fetch(url, dest) {
|
|
26
|
+
return new Promise((resolve, reject) => {
|
|
27
|
+
const file = createWriteStream(dest);
|
|
28
|
+
const req = (u) =>
|
|
29
|
+
https.get(u, (res) => {
|
|
30
|
+
if (res.statusCode === 301 || res.statusCode === 302) {
|
|
31
|
+
return req(res.headers.location);
|
|
32
|
+
}
|
|
33
|
+
if (res.statusCode !== 200) {
|
|
34
|
+
reject(new Error(`HTTP ${res.statusCode} for ${u}`));
|
|
35
|
+
return;
|
|
36
|
+
}
|
|
37
|
+
res.pipe(file);
|
|
38
|
+
file.on("finish", () => file.close(resolve));
|
|
39
|
+
}).on("error", reject);
|
|
40
|
+
req(url);
|
|
41
|
+
});
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
async function main() {
|
|
45
|
+
const target = getTarget();
|
|
46
|
+
const url = `https://github.com/${REPO}/releases/download/v${VERSION}/imi-${target}.tar.gz`;
|
|
47
|
+
const tmp = join(tmpdir(), `imi-${Date.now()}.tar.gz`);
|
|
48
|
+
|
|
49
|
+
// Skip download if already the right version
|
|
50
|
+
if (existsSync(BIN)) {
|
|
51
|
+
try {
|
|
52
|
+
const installed = execSync(`${BIN} --version 2>/dev/null`, { encoding: "utf8" }).trim();
|
|
53
|
+
if (installed.includes(VERSION)) {
|
|
54
|
+
console.log(`imi ${VERSION} already installed`);
|
|
55
|
+
runInit();
|
|
56
|
+
return;
|
|
57
|
+
}
|
|
58
|
+
} catch {}
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
process.stdout.write(`Installing imi v${VERSION} for ${target}... `);
|
|
62
|
+
await fetch(url, tmp);
|
|
63
|
+
mkdirSync(BIN_DIR, { recursive: true });
|
|
64
|
+
execSync(`tar -xzf "${tmp}" -C "${BIN_DIR}"`, { stdio: "pipe" });
|
|
65
|
+
chmodSync(BIN, 0o755);
|
|
66
|
+
unlinkSync(tmp);
|
|
67
|
+
console.log("done");
|
|
68
|
+
|
|
69
|
+
// Ensure ~/.local/bin is on PATH hint
|
|
70
|
+
const inPath = (process.env.PATH || "").split(":").includes(BIN_DIR);
|
|
71
|
+
if (!inPath) {
|
|
72
|
+
console.log(`\nAdd to your shell config:\n export PATH="$HOME/.local/bin:$PATH"\n`);
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
runInit();
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
function runInit() {
|
|
79
|
+
const result = spawnSync(BIN, ["init"], { stdio: "inherit" });
|
|
80
|
+
process.exit(result.status ?? 0);
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
main().catch((err) => {
|
|
84
|
+
console.error("\nInstall failed:", err.message);
|
|
85
|
+
console.error(`Manual install: curl -fsSL https://aibyimi.com/install | bash`);
|
|
86
|
+
process.exit(1);
|
|
87
|
+
});
|