offgrid-ai 0.3.24 → 0.3.26
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 +2 -1
- package/src/cli.mjs +13 -19
- package/src/postinstall.mjs +53 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "offgrid-ai",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.26",
|
|
4
4
|
"description": "Privacy-first CLI for running local LLMs — discover, configure, run, benchmark",
|
|
5
5
|
"author": "Eeshan Srivastava (https://eeshans.com)",
|
|
6
6
|
"type": "module",
|
|
@@ -34,6 +34,7 @@
|
|
|
34
34
|
"release:check": "bash scripts/release-check.sh",
|
|
35
35
|
"release:check:fast": "bash scripts/release-check.sh --skip-install --skip-manual",
|
|
36
36
|
"prepack": "npm run check:privacy",
|
|
37
|
+
"postinstall": "node src/postinstall.mjs",
|
|
37
38
|
"pretest": "npm run lint"
|
|
38
39
|
},
|
|
39
40
|
"dependencies": {
|
package/src/cli.mjs
CHANGED
|
@@ -965,29 +965,23 @@ async function uninstallCommand(argv) {
|
|
|
965
965
|
console.log(pc.green("All servers stopped."));
|
|
966
966
|
}
|
|
967
967
|
|
|
968
|
-
// Ask about data
|
|
969
968
|
const dataDir = DATA_DIR;
|
|
970
|
-
const
|
|
969
|
+
const mode = await prompt.choice("Choose uninstall type", [
|
|
970
|
+
{ value: "keep-data", label: "Uninstall app only", hint: `keep profiles and settings in ${dataDir}` },
|
|
971
|
+
{ value: "delete-data", label: "Full uninstall", hint: "delete profiles/settings, then uninstall app" },
|
|
972
|
+
{ value: "cancel", label: "Cancel" },
|
|
973
|
+
], "keep-data");
|
|
971
974
|
|
|
972
|
-
if (
|
|
973
|
-
const confirmDelete = await prompt.yesNo(`Delete ${dataDir}? This removes all profiles and settings.`, false);
|
|
974
|
-
if (confirmDelete) {
|
|
975
|
-
await removeDataDir();
|
|
976
|
-
} else {
|
|
977
|
-
console.log(pc.dim("Keeping data directory."));
|
|
978
|
-
}
|
|
979
|
-
} else {
|
|
980
|
-
console.log(pc.dim(`Keeping ${dataDir} for when you reinstall.`));
|
|
981
|
-
}
|
|
982
|
-
|
|
983
|
-
// Remove the npm package
|
|
984
|
-
const confirmUninstall = await prompt.yesNo("Uninstall offgrid-ai npm package?", true);
|
|
985
|
-
if (confirmUninstall) {
|
|
986
|
-
await removeShellPath();
|
|
987
|
-
await removeSelf();
|
|
988
|
-
} else {
|
|
975
|
+
if (mode === "cancel") {
|
|
989
976
|
console.log(pc.dim("Cancelled."));
|
|
977
|
+
return;
|
|
990
978
|
}
|
|
979
|
+
|
|
980
|
+
if (mode === "delete-data") await removeDataDir();
|
|
981
|
+
else console.log(pc.dim(`Keeping ${dataDir} for when you reinstall.`));
|
|
982
|
+
|
|
983
|
+
await removeShellPath();
|
|
984
|
+
await removeSelf();
|
|
991
985
|
} finally {
|
|
992
986
|
prompt.close();
|
|
993
987
|
}
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import { existsSync, readFileSync, appendFileSync } from "node:fs";
|
|
3
|
+
import { join } from "node:path";
|
|
4
|
+
|
|
5
|
+
if (process.env.CI || process.env.OFFGRID_SKIP_POSTINSTALL) process.exit(0);
|
|
6
|
+
if (process.env.npm_config_global !== "true") process.exit(0);
|
|
7
|
+
|
|
8
|
+
const prefix = process.env.npm_config_prefix;
|
|
9
|
+
if (!prefix) process.exit(0);
|
|
10
|
+
|
|
11
|
+
if (isHermesPrefix(prefix, process.env.HOME)) {
|
|
12
|
+
console.log("offgrid-ai installed with a Hermes-managed npm prefix.");
|
|
13
|
+
console.log("Not adding Hermes Node to PATH automatically. Use your normal Node/npm, or run the offgrid-ai install script.");
|
|
14
|
+
process.exit(0);
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
const npmBin = join(prefix, "bin");
|
|
18
|
+
const marker = "# Added by offgrid-ai installer";
|
|
19
|
+
const pathLine = `export PATH="${npmBin}:$PATH"`;
|
|
20
|
+
const currentPath = process.env.PATH ?? "";
|
|
21
|
+
|
|
22
|
+
if (currentPath.split(":").includes(npmBin)) process.exit(0);
|
|
23
|
+
|
|
24
|
+
const home = process.env.HOME;
|
|
25
|
+
if (!home) process.exit(0);
|
|
26
|
+
|
|
27
|
+
const shell = process.env.SHELL ?? "";
|
|
28
|
+
const rcCandidates = shell.endsWith("zsh")
|
|
29
|
+
? [join(home, ".zshrc"), join(home, ".zprofile"), join(home, ".profile")]
|
|
30
|
+
: [join(home, ".bashrc"), join(home, ".bash_profile"), join(home, ".profile"), join(home, ".zshrc")];
|
|
31
|
+
|
|
32
|
+
const rcFile = rcCandidates.find((file) => existsSync(file)) ?? rcCandidates[0];
|
|
33
|
+
let content = "";
|
|
34
|
+
try {
|
|
35
|
+
content = existsSync(rcFile) ? readFileSync(rcFile, "utf8") : "";
|
|
36
|
+
} catch {
|
|
37
|
+
process.exit(0);
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
if (!content.includes(npmBin)) {
|
|
41
|
+
appendFileSync(rcFile, `${content.endsWith("\n") || content.length === 0 ? "" : "\n"}\n${marker}\n${pathLine}\n`, "utf8");
|
|
42
|
+
console.log(`offgrid-ai added ${npmBin} to ${rcFile}`);
|
|
43
|
+
console.log(`Open a new terminal, or run: source ${rcFile}`);
|
|
44
|
+
} else {
|
|
45
|
+
console.log(`offgrid-ai is installed in ${npmBin}`);
|
|
46
|
+
console.log(`Open a new terminal if the command is not found yet.`);
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
function isHermesPrefix(prefix, home) {
|
|
50
|
+
const normalized = prefix.replace(/\\/gu, "/");
|
|
51
|
+
if (normalized.includes("/.hermes/")) return true;
|
|
52
|
+
return Boolean(home && normalized === `${home.replace(/\\/gu, "/")}/.hermes/node`);
|
|
53
|
+
}
|