opencode-hub 1.0.8 → 1.0.10
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/oc-tui.js +40 -12
- package/package.json +1 -1
- package/plugin.js +14 -2
package/oc-tui.js
CHANGED
|
@@ -34,7 +34,15 @@ function loadNpmPlugins() {
|
|
|
34
34
|
var name = p.replace(/@[^@\/]+$/, "") || p;
|
|
35
35
|
var version = "";
|
|
36
36
|
try {
|
|
37
|
-
|
|
37
|
+
// OpenCode installs npm plugins into ~/.cache/opencode/node_modules
|
|
38
|
+
var cachePkg = join(homedir(), ".cache", "opencode", "node_modules", name, "package.json");
|
|
39
|
+
// Fallback: config-local node_modules, then global npm
|
|
40
|
+
var globalNpm = process.platform === "win32"
|
|
41
|
+
? join(homedir(), "AppData", "Roaming", "npm", "node_modules")
|
|
42
|
+
: join("/usr", "lib", "node_modules");
|
|
43
|
+
var pkgPath = existsSync(cachePkg) ? cachePkg
|
|
44
|
+
: existsSync(join(CONFIG_DIR, "node_modules", name, "package.json")) ? join(CONFIG_DIR, "node_modules", name, "package.json")
|
|
45
|
+
: join(globalNpm, name, "package.json");
|
|
38
46
|
if (existsSync(pkgPath)) {
|
|
39
47
|
version = JSON.parse(readFileSync(pkgPath, "utf-8")).version || "";
|
|
40
48
|
}
|
|
@@ -427,7 +435,7 @@ function getPluginActions(pitem) {
|
|
|
427
435
|
} else {
|
|
428
436
|
a.push({ key: "enable-auto", label: "Enable auto-update" });
|
|
429
437
|
}
|
|
430
|
-
a.push({ key: "
|
|
438
|
+
a.push({ key: "update", label: "Force rebuild & deploy" });
|
|
431
439
|
a.push({ key: "commits", label: "Select specific commit (Downgrade)" });
|
|
432
440
|
a.push({ key: "disable-plugin", label: "Disable plugin" });
|
|
433
441
|
a.push({ key: "cancel", label: "Cancel" });
|
|
@@ -779,9 +787,9 @@ function buildPlugins(pushBody, pushFoot, cols, barW) {
|
|
|
779
787
|
} else {
|
|
780
788
|
pushFoot(" " + DIM + "^v" + RST + "/" + DIM + "WS" + RST + " Move " +
|
|
781
789
|
DIM + "Enter" + RST + " Select " +
|
|
782
|
-
DIM + "F" + RST + " Fetch " +
|
|
783
|
-
DIM + "A" + RST + " Toggle auto " +
|
|
784
790
|
DIM + "U" + RST + " Update " +
|
|
791
|
+
DIM + "A" + RST + " Update all " +
|
|
792
|
+
DIM + "D" + RST + " Disable " +
|
|
785
793
|
DIM + "Q" + RST + " Quit" + RST);
|
|
786
794
|
}
|
|
787
795
|
}
|
|
@@ -950,13 +958,20 @@ function handlePluginKey(key) {
|
|
|
950
958
|
flash(updateCount > 0 ? updateCount + " update(s) available" : "All plugins up to date");
|
|
951
959
|
}
|
|
952
960
|
else if (key === "a") {
|
|
953
|
-
|
|
954
|
-
|
|
955
|
-
|
|
956
|
-
|
|
957
|
-
var
|
|
958
|
-
|
|
959
|
-
|
|
961
|
+
var toUpdate = pluginItems.filter(function(p) { return p.updateAvail || !p.deployed; });
|
|
962
|
+
if (toUpdate.length === 0) {
|
|
963
|
+
flash("All plugins are already up to date.");
|
|
964
|
+
} else {
|
|
965
|
+
var errors = [];
|
|
966
|
+
for (var pi of toUpdate) {
|
|
967
|
+
flash("Updating " + pi.name + "...");
|
|
968
|
+
render();
|
|
969
|
+
var e = runPluginUpdate(pi);
|
|
970
|
+
if (e) errors.push(pi.name + ": " + e);
|
|
971
|
+
}
|
|
972
|
+
pluginItems = buildPluginList();
|
|
973
|
+
if (pcursor >= pluginItems.length) pcursor = Math.max(0, pluginItems.length - 1);
|
|
974
|
+
flash(errors.length > 0 ? errors.join("; ") : toUpdate.length + " plugin(s) updated. Restart OpenCode to apply.");
|
|
960
975
|
}
|
|
961
976
|
}
|
|
962
977
|
else if (key === "u") {
|
|
@@ -970,6 +985,19 @@ function handlePluginKey(key) {
|
|
|
970
985
|
flash(err ? p.name + ": " + err : p.name + " updated. Restart OpenCode to apply.");
|
|
971
986
|
}
|
|
972
987
|
}
|
|
988
|
+
else if (key === "d") {
|
|
989
|
+
if (pluginItems.length > 0) {
|
|
990
|
+
var p = pluginItems[pcursor];
|
|
991
|
+
var plugins = loadPlugins();
|
|
992
|
+
var match = plugins.find(function(r) { return r.name === p.name; });
|
|
993
|
+
if (match) { match.enabled = false; savePlugins(plugins); }
|
|
994
|
+
var deployedPath = join(PLUGINS_DIR, p.pluginFile);
|
|
995
|
+
if (existsSync(deployedPath)) { try { unlinkSync(deployedPath); } catch {} }
|
|
996
|
+
pluginItems = buildPluginList();
|
|
997
|
+
if (pcursor >= pluginItems.length) pcursor = Math.max(0, pluginItems.length - 1);
|
|
998
|
+
flash(p.name + " disabled. Restart OpenCode to unload.");
|
|
999
|
+
}
|
|
1000
|
+
}
|
|
973
1001
|
else if (key === "q" || key === "escape") { cleanup(); process.exit(1); }
|
|
974
1002
|
} else if (mode === "pactions") {
|
|
975
1003
|
var pitem = pluginItems[pcursor];
|
|
@@ -978,7 +1006,7 @@ function handlePluginKey(key) {
|
|
|
978
1006
|
else if (key === "down" || key === "s") { pacursor = Math.min(acts.length - 1, pacursor + 1); }
|
|
979
1007
|
else if (key === "enter" || key === "space") {
|
|
980
1008
|
var action = acts[pacursor].key;
|
|
981
|
-
if (action === "update"
|
|
1009
|
+
if (action === "update") {
|
|
982
1010
|
flash("Updating " + pitem.name + "...");
|
|
983
1011
|
render();
|
|
984
1012
|
var err = runPluginUpdate(pitem);
|
package/package.json
CHANGED
package/plugin.js
CHANGED
|
@@ -12,10 +12,10 @@ function findTuiScript() {
|
|
|
12
12
|
var sameDirPath = join(import.meta.dir, "oc-tui.js");
|
|
13
13
|
if (existsSync(sameDirPath)) return sameDirPath;
|
|
14
14
|
|
|
15
|
-
// 2. Find config dir, then check repos/intisy/opencode-
|
|
15
|
+
// 2. Find config dir, then check repos/intisy/opencode-hub/ (updater case)
|
|
16
16
|
var configDir = findConfigDir(import.meta.dir);
|
|
17
17
|
if (configDir) {
|
|
18
|
-
var repoPath = join(configDir, "repos", "intisy", "opencode-
|
|
18
|
+
var repoPath = join(configDir, "repos", "intisy", "opencode-hub", "oc-tui.js");
|
|
19
19
|
if (existsSync(repoPath)) return repoPath;
|
|
20
20
|
}
|
|
21
21
|
|
|
@@ -52,6 +52,18 @@ function installOcCommand() {
|
|
|
52
52
|
var binDir = getBinDir();
|
|
53
53
|
if (!existsSync(binDir)) try { mkdirSync(binDir, { recursive: true }); } catch {}
|
|
54
54
|
|
|
55
|
+
// Always keep binDir/oc-tui.js in sync with the source (so `oc` always runs latest)
|
|
56
|
+
var binTuiPath = join(binDir, "oc-tui.js");
|
|
57
|
+
try {
|
|
58
|
+
var srcContent = readFileSync(tuiPath, "utf-8");
|
|
59
|
+
var dstContent = existsSync(binTuiPath) ? readFileSync(binTuiPath, "utf-8") : null;
|
|
60
|
+
if (srcContent !== dstContent) {
|
|
61
|
+
writeFileSync(binTuiPath, srcContent, "utf-8");
|
|
62
|
+
}
|
|
63
|
+
} catch {}
|
|
64
|
+
// Point shell launchers at the stable binDir copy
|
|
65
|
+
tuiPath = binTuiPath;
|
|
66
|
+
|
|
55
67
|
var tuiPathEscaped = tuiPath.replace(/\\/g, "\\\\");
|
|
56
68
|
|
|
57
69
|
if (process.platform === "win32") {
|