superoc 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.
- package/LICENSE +21 -0
- package/README.md +37 -0
- package/bin/nimsuper.js +21 -0
- package/bin/nimsuper.ts +10 -0
- package/bin/superoc.js +21 -0
- package/bin/superoc.ts +10 -0
- package/dist/antigravity.d.ts +59 -0
- package/dist/antigravity.d.ts.map +1 -0
- package/dist/antigravity.js +423 -0
- package/dist/antigravity.js.map +1 -0
- package/dist/errors.d.ts +22 -0
- package/dist/errors.d.ts.map +1 -0
- package/dist/errors.js +122 -0
- package/dist/errors.js.map +1 -0
- package/dist/errors.test.d.ts +2 -0
- package/dist/errors.test.d.ts.map +1 -0
- package/dist/errors.test.js +137 -0
- package/dist/errors.test.js.map +1 -0
- package/dist/index.d.ts +5 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +809 -0
- package/dist/index.js.map +1 -0
- package/dist/opencode-sync.d.ts +9 -0
- package/dist/opencode-sync.d.ts.map +1 -0
- package/dist/opencode-sync.js +157 -0
- package/dist/opencode-sync.js.map +1 -0
- package/dist/provider.d.ts +5 -0
- package/dist/provider.d.ts.map +1 -0
- package/dist/provider.js +100 -0
- package/dist/provider.js.map +1 -0
- package/dist/provider.test.d.ts +2 -0
- package/dist/provider.test.d.ts.map +1 -0
- package/dist/provider.test.js +94 -0
- package/dist/provider.test.js.map +1 -0
- package/dist/quota.d.ts +12 -0
- package/dist/quota.d.ts.map +1 -0
- package/dist/quota.js +105 -0
- package/dist/quota.js.map +1 -0
- package/dist/quota.test.d.ts +2 -0
- package/dist/quota.test.d.ts.map +1 -0
- package/dist/quota.test.js +20 -0
- package/dist/quota.test.js.map +1 -0
- package/dist/storage.d.ts +43 -0
- package/dist/storage.d.ts.map +1 -0
- package/dist/storage.js +447 -0
- package/dist/storage.js.map +1 -0
- package/dist/themes.d.ts +64 -0
- package/dist/themes.d.ts.map +1 -0
- package/dist/themes.js +424 -0
- package/dist/themes.js.map +1 -0
- package/dist/tui/actions.d.ts +14 -0
- package/dist/tui/actions.d.ts.map +1 -0
- package/dist/tui/actions.js +464 -0
- package/dist/tui/actions.js.map +1 -0
- package/dist/tui/app.d.ts +2 -0
- package/dist/tui/app.d.ts.map +1 -0
- package/dist/tui/app.js +323 -0
- package/dist/tui/app.js.map +1 -0
- package/dist/tui/benchmark.d.ts +42 -0
- package/dist/tui/benchmark.d.ts.map +1 -0
- package/dist/tui/benchmark.js +379 -0
- package/dist/tui/benchmark.js.map +1 -0
- package/dist/tui/screens.d.ts +23 -0
- package/dist/tui/screens.d.ts.map +1 -0
- package/dist/tui/screens.js +791 -0
- package/dist/tui/screens.js.map +1 -0
- package/dist/tui/state.d.ts +54 -0
- package/dist/tui/state.d.ts.map +1 -0
- package/dist/tui/state.js +85 -0
- package/dist/tui/state.js.map +1 -0
- package/dist/tui/types.d.ts +16 -0
- package/dist/tui/types.d.ts.map +1 -0
- package/dist/tui/types.js +2 -0
- package/dist/tui/types.js.map +1 -0
- package/dist/tui/ui.d.ts +17 -0
- package/dist/tui/ui.d.ts.map +1 -0
- package/dist/tui/ui.js +77 -0
- package/dist/tui/ui.js.map +1 -0
- package/dist/types.d.ts +52 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +2 -0
- package/dist/types.js.map +1 -0
- package/package.json +68 -0
- package/scripts/postinstall.js +77 -0
- package/scripts/uninstall.js +119 -0
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
import { join } from "path";
|
|
4
|
+
import { homedir } from "os";
|
|
5
|
+
import { existsSync } from "fs";
|
|
6
|
+
import { readFile, writeFile, unlink } from "fs/promises";
|
|
7
|
+
|
|
8
|
+
const xdgConfig = process.env.XDG_CONFIG_HOME || join(homedir(), ".config");
|
|
9
|
+
const CONFIG_DIR = join(xdgConfig, "opencode");
|
|
10
|
+
const jsoncPath = join(CONFIG_DIR, "opencode.jsonc");
|
|
11
|
+
const jsonPath = join(CONFIG_DIR, "opencode.json");
|
|
12
|
+
const CONFIG_PATH = existsSync(jsoncPath) ? jsoncPath : jsonPath;
|
|
13
|
+
const KEYSTORE_PATH = join(CONFIG_DIR, "superoc-keys.json");
|
|
14
|
+
const LEGACY_KEYSTORE_PATH = join(CONFIG_DIR, "nimsuper-keys.json");
|
|
15
|
+
const THEME_PATH = join(CONFIG_DIR, "superoc-theme.json");
|
|
16
|
+
const LEGACY_THEME_PATH = join(CONFIG_DIR, "nimsuper-theme.json");
|
|
17
|
+
|
|
18
|
+
async function uninstall() {
|
|
19
|
+
console.log(
|
|
20
|
+
"\n+=============================================================+",
|
|
21
|
+
);
|
|
22
|
+
console.log("| superoc - Uninstaller |");
|
|
23
|
+
console.log(
|
|
24
|
+
"+=============================================================+\n",
|
|
25
|
+
);
|
|
26
|
+
|
|
27
|
+
let configModified = false;
|
|
28
|
+
|
|
29
|
+
// Remove plugin from OpenCode config
|
|
30
|
+
if (existsSync(CONFIG_PATH)) {
|
|
31
|
+
try {
|
|
32
|
+
const raw = await readFile(CONFIG_PATH, "utf-8");
|
|
33
|
+
const config = JSON.parse(raw);
|
|
34
|
+
|
|
35
|
+
if (Array.isArray(config.plugin)) {
|
|
36
|
+
const beforeLength = config.plugin.length;
|
|
37
|
+
config.plugin = config.plugin.filter(function (p) {
|
|
38
|
+
if (typeof p === "string") return p !== "superoc" && p !== "nimsuper";
|
|
39
|
+
if (Array.isArray(p)) return p[0] !== "superoc" && p[0] !== "nimsuper";
|
|
40
|
+
return true;
|
|
41
|
+
});
|
|
42
|
+
|
|
43
|
+
if (config.plugin.length !== beforeLength) {
|
|
44
|
+
await writeFile(CONFIG_PATH, JSON.stringify(config, null, 2) + "\n", {
|
|
45
|
+
mode: 0o600,
|
|
46
|
+
});
|
|
47
|
+
console.log("Removed superoc from OpenCode plugin list");
|
|
48
|
+
configModified = true;
|
|
49
|
+
} else {
|
|
50
|
+
console.log("Plugin was not found in OpenCode config - skipping");
|
|
51
|
+
}
|
|
52
|
+
} else {
|
|
53
|
+
console.log("No plugins array in OpenCode config - skipping");
|
|
54
|
+
}
|
|
55
|
+
} catch (err) {
|
|
56
|
+
console.warn("Could not update OpenCode config:", err);
|
|
57
|
+
}
|
|
58
|
+
} else {
|
|
59
|
+
console.log("OpenCode config not found - skipping");
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
// Remove key store file
|
|
63
|
+
const activeKeystore = existsSync(KEYSTORE_PATH)
|
|
64
|
+
? KEYSTORE_PATH
|
|
65
|
+
: existsSync(LEGACY_KEYSTORE_PATH)
|
|
66
|
+
? LEGACY_KEYSTORE_PATH
|
|
67
|
+
: null;
|
|
68
|
+
|
|
69
|
+
if (activeKeystore) {
|
|
70
|
+
if (!process.stdin.isTTY) {
|
|
71
|
+
console.warn(
|
|
72
|
+
"Key store file exists but cannot confirm deletion in non-interactive mode.",
|
|
73
|
+
);
|
|
74
|
+
console.warn("Manually remove: " + activeKeystore);
|
|
75
|
+
} else {
|
|
76
|
+
const readline = await import("readline");
|
|
77
|
+
const rl = readline.createInterface({
|
|
78
|
+
input: process.stdin,
|
|
79
|
+
output: process.stdout,
|
|
80
|
+
});
|
|
81
|
+
const answer = await new Promise(function (resolve) {
|
|
82
|
+
rl.question(
|
|
83
|
+
"Delete all stored API keys? This cannot be undone. [y/N] ",
|
|
84
|
+
resolve,
|
|
85
|
+
);
|
|
86
|
+
});
|
|
87
|
+
rl.close();
|
|
88
|
+
if (answer !== "y" && answer !== "Y") {
|
|
89
|
+
console.log("Key store preserved at: " + activeKeystore);
|
|
90
|
+
} else {
|
|
91
|
+
try {
|
|
92
|
+
if (existsSync(KEYSTORE_PATH)) await unlink(KEYSTORE_PATH);
|
|
93
|
+
if (existsSync(LEGACY_KEYSTORE_PATH)) await unlink(LEGACY_KEYSTORE_PATH);
|
|
94
|
+
console.log("Removed key store file");
|
|
95
|
+
} catch (err) {
|
|
96
|
+
console.warn("Could not remove key store file:", err);
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
} else {
|
|
101
|
+
console.log("Key store file not found - skipping");
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
// Remove theme override file
|
|
105
|
+
try {
|
|
106
|
+
if (existsSync(THEME_PATH)) await unlink(THEME_PATH);
|
|
107
|
+
if (existsSync(LEGACY_THEME_PATH)) await unlink(LEGACY_THEME_PATH);
|
|
108
|
+
console.log("Removed theme preference file");
|
|
109
|
+
} catch (err) {
|
|
110
|
+
console.warn("Could not remove theme preference file:", err);
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
console.log("\nUninstallation complete.\n");
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
await uninstall().catch(function (err) {
|
|
117
|
+
console.error("Uninstallation failed:", err);
|
|
118
|
+
process.exit(1);
|
|
119
|
+
});
|