plugin-updater 1.3.3 → 1.3.5

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/README.md CHANGED
@@ -91,6 +91,8 @@ Deployed automatically to both apps on each `earlyLaunch` (`~/.config/opencode/c
91
91
 
92
92
  ## Configuration
93
93
 
94
+ > Config files are **auto-created with defaults on first run** (via core `ensureConfig`). **Global console logging** for every plugin is toggled in `config/settings.json` (`logConsole: true`, the opencode.json-equivalent).
95
+
94
96
  Config file: `~/.config/opencode/config/plugin-updater.json` (preferred) or `~/.config/opencode/plugin-updater.json` (fallback); same under `~/.claude` for Claude Code.
95
97
 
96
98
  | Key | Type | Default | Description |
package/dist/index.js CHANGED
@@ -8,11 +8,13 @@ import { syncPluginsAcrossApps } from "./syncbridge.js";
8
8
  // @ts-ignore — generated bundle, no .d.ts
9
9
  import { maybeRunCli, deployUpdaterCommands } from "./commands.js";
10
10
  // @ts-ignore — generated bundle, no .d.ts
11
- import { ensureConfig } from "../lib/core.js";
11
+ import { defineConfig } from "../lib/core.js";
12
12
  import path from "path";
13
13
  import fs from "fs";
14
14
  // `node dist/index.js config …` (from the /plugin-updater-config command) runs the
15
15
  // config CLI and exits, before the self-activation/updater sequence below.
16
+ // Register config defaults BEFORE the CLI guard so `config schema` sees them (no write).
17
+ defineConfig("plugin-updater", { logging: true });
16
18
  if (await maybeRunCli()) {
17
19
  process.exit(0);
18
20
  }
@@ -72,10 +74,6 @@ export async function earlyLaunch(configDir, plugins) {
72
74
  deployUpdaterCommands();
73
75
  }
74
76
  catch { /* best-effort */ }
75
- try {
76
- ensureConfig("plugin-updater", { logging: true });
77
- }
78
- catch { /* best-effort */ }
79
77
  // pull in any `sync: true` plugins from the other app BEFORE building, then
80
78
  // re-read the list so a freshly-synced-in plugin is cloned/built this pass.
81
79
  await syncPluginsAcrossApps(configDir);
package/lib/core.js CHANGED
@@ -83,18 +83,13 @@ function loadConfig(name, configDir = getAppConfigDir()) {
83
83
  CACHE[key] = data && typeof data === "object" && !Array.isArray(data) ? data : {};
84
84
  return CACHE[key];
85
85
  }
86
- function ensureConfig(name, defaults, configDir = getAppConfigDir()) {
87
- const preferred = join2(configDir, "config", `${name}.json`);
88
- const fallback = join2(configDir, `${name}.json`);
89
- if (!existsSync3(preferred) && !existsSync3(fallback)) {
90
- try {
91
- writeJson(preferred, defaults);
92
- } catch {
93
- }
94
- CACHE[configDir + "::" + name] = { ...defaults };
95
- return CACHE[configDir + "::" + name];
96
- }
97
- return { ...defaults, ...loadConfig(name, configDir) };
86
+ var DEFAULTS = {};
87
+ function defineConfig(name, defaults, configDir = getAppConfigDir()) {
88
+ DEFAULTS[name] = { ...DEFAULTS[name] ?? {}, ...defaults };
89
+ return { ...DEFAULTS[name], ...loadConfig(name, configDir) };
90
+ }
91
+ function getConfigDefaults(name) {
92
+ return { ...DEFAULTS[name] ?? {} };
98
93
  }
99
94
  function getConfigValue(name, key, configDir = getAppConfigDir()) {
100
95
  let node = loadConfig(name, configDir);
@@ -242,14 +237,22 @@ function configCommand(pluginName, commandName = `${pluginName}-config`) {
242
237
  // core/src/configcli.ts
243
238
  function runConfigCli(pluginName, argv) {
244
239
  const [action, key, ...rest] = argv;
240
+ if (action === "schema") {
241
+ console.log(JSON.stringify({ name: pluginName, defaults: getConfigDefaults(pluginName), current: listConfig(pluginName) }));
242
+ return;
243
+ }
245
244
  if (!action || action === "list") {
246
- const cfg = listConfig(pluginName);
247
- const keys = Object.keys(cfg);
245
+ const defaults = getConfigDefaults(pluginName);
246
+ const current = listConfig(pluginName);
247
+ const keys = Object.keys({ ...defaults, ...current });
248
248
  if (!keys.length) {
249
- console.log(`${pluginName}: no config set (using defaults).`);
249
+ console.log(`${pluginName}: no configurable settings.`);
250
250
  return;
251
251
  }
252
- for (const k of keys) console.log(`${k} = ${JSON.stringify(cfg[k])}`);
252
+ for (const k of keys) {
253
+ const isSet = Object.prototype.hasOwnProperty.call(current, k);
254
+ console.log(`${k} = ${JSON.stringify(isSet ? current[k] : defaults[k])}${isSet ? "" : " (default)"}`);
255
+ }
253
256
  return;
254
257
  }
255
258
  if (action === "get") {
@@ -270,7 +273,7 @@ function runConfigCli(pluginName, argv) {
270
273
  console.log(`set ${key} = ${JSON.stringify(value)}`);
271
274
  return;
272
275
  }
273
- console.log(`${pluginName} config \u2014 usage: list | get <key> | set <key> <value>`);
276
+ console.log(`${pluginName} config \u2014 usage: list | get <key> | set <key> <value> | schema`);
274
277
  }
275
278
  function maybeRunConfigCli(pluginName) {
276
279
  const argv = process.argv.slice(2);
@@ -288,13 +291,14 @@ export {
288
291
  configCommand,
289
292
  configPath,
290
293
  createLogger,
294
+ defineConfig,
291
295
  deployCommands,
292
- ensureConfig,
293
296
  ensureDir,
294
297
  existingApps,
295
298
  existingConfigDirs,
296
299
  getApp,
297
300
  getAppConfigDir,
301
+ getConfigDefaults,
298
302
  getConfigValue,
299
303
  globalSetting,
300
304
  isClaude,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "plugin-updater",
3
- "version": "1.3.3",
3
+ "version": "1.3.5",
4
4
  "description": "Plugin lifecycle manager for OpenCode and Claude Code launchers",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",