opencode-hub 1.0.9 → 1.0.11

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/oc-tui.js +25 -32
  2. package/package.json +1 -1
package/oc-tui.js CHANGED
@@ -34,15 +34,15 @@ function loadNpmPlugins() {
34
34
  var name = p.replace(/@[^@\/]+$/, "") || p;
35
35
  var version = "";
36
36
  try {
37
- // First try config-local node_modules, then global npm node_modules
38
- var pkgPath = join(CONFIG_DIR, "node_modules", name, "package.json");
39
- if (!existsSync(pkgPath)) {
40
- // Global npm fallback (Windows: AppData/Roaming/npm/node_modules, Unix: prefix/lib/node_modules)
41
- var globalNpm = process.platform === "win32"
42
- ? join(homedir(), "AppData", "Roaming", "npm", "node_modules")
43
- : join("/usr", "lib", "node_modules");
44
- pkgPath = join(globalNpm, name, "package.json");
45
- }
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");
46
46
  if (existsSync(pkgPath)) {
47
47
  version = JSON.parse(readFileSync(pkgPath, "utf-8")).version || "";
48
48
  }
@@ -70,7 +70,7 @@ function migrateConfigs() {
70
70
  }
71
71
  var legacyPlugins = join(CONFIG_DIR, "plugins.json");
72
72
  if (existsSync(legacyPlugins) && !existsSync(PLUGINS_JSON)) {
73
- try { copyFileSync(legacyPlugins, PLUGINS_JSON); } catch {}
73
+ try { copyFileSync(legacyPlugins, PLUGINS_JSON); try { unlinkSync(legacyPlugins); } catch {} } catch {}
74
74
  }
75
75
  }
76
76
 
@@ -436,7 +436,6 @@ function getPluginActions(pitem) {
436
436
  a.push({ key: "enable-auto", label: "Enable auto-update" });
437
437
  }
438
438
  a.push({ key: "update", label: "Force rebuild & deploy" });
439
- a.push({ key: "update-all", label: "Update all plugins" });
440
439
  a.push({ key: "commits", label: "Select specific commit (Downgrade)" });
441
440
  a.push({ key: "disable-plugin", label: "Disable plugin" });
442
441
  a.push({ key: "cancel", label: "Cancel" });
@@ -789,8 +788,8 @@ function buildPlugins(pushBody, pushFoot, cols, barW) {
789
788
  pushFoot(" " + DIM + "^v" + RST + "/" + DIM + "WS" + RST + " Move " +
790
789
  DIM + "Enter" + RST + " Select " +
791
790
  DIM + "U" + RST + " Update " +
791
+ DIM + "A" + RST + " Update all " +
792
792
  DIM + "D" + RST + " Disable " +
793
- DIM + "A" + RST + " Toggle auto " +
794
793
  DIM + "Q" + RST + " Quit" + RST);
795
794
  }
796
795
  }
@@ -959,13 +958,20 @@ function handlePluginKey(key) {
959
958
  flash(updateCount > 0 ? updateCount + " update(s) available" : "All plugins up to date");
960
959
  }
961
960
  else if (key === "a") {
962
- if (pluginItems.length > 0) {
963
- var p = pluginItems[pcursor];
964
- p.autoUpdate = !p.autoUpdate;
965
- var plugins = loadPlugins();
966
- var match = plugins.find(function(r) { return r.name === p.name; });
967
- if (match) { match.autoUpdate = p.autoUpdate; savePlugins(plugins); }
968
- flash(p.name + ": auto-update " + (p.autoUpdate ? "ON" : "OFF"));
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.");
969
975
  }
970
976
  }
971
977
  else if (key === "u") {
@@ -1009,19 +1015,6 @@ function handlePluginKey(key) {
1009
1015
  flash(err ? pitem.name + ": " + err : pitem.name + " updated. Restart OpenCode to apply.");
1010
1016
  mode = "list";
1011
1017
  }
1012
- else if (action === "update-all") {
1013
- var errors = [];
1014
- for (var pi of pluginItems) {
1015
- flash("Updating " + pi.name + "...");
1016
- render();
1017
- var e = runPluginUpdate(pi);
1018
- if (e) errors.push(pi.name + ": " + e);
1019
- }
1020
- pluginItems = buildPluginList();
1021
- if (pcursor >= pluginItems.length) pcursor = Math.max(0, pluginItems.length - 1);
1022
- flash(errors.length > 0 ? errors.join("; ") : "All plugins updated. Restart OpenCode to apply.");
1023
- mode = "list";
1024
- }
1025
1018
  else if (action === "enable-auto" || action === "disable-auto") {
1026
1019
  var newVal = action === "enable-auto";
1027
1020
  pitem.autoUpdate = newVal;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "opencode-hub",
3
- "version": "1.0.9",
3
+ "version": "1.0.11",
4
4
  "description": "TUI launcher for OpenCode - project switcher and plugin manager with oc command",
5
5
  "main": "plugin.js",
6
6
  "type": "module",