@miloya/oc-minimax-status 0.1.4 → 0.1.6

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/index.js +21 -14
  2. package/package.json +1 -1
package/index.js CHANGED
@@ -19,39 +19,46 @@ const CONFIG_PATH = path.join(
19
19
 
20
20
  function syncPluginFiles() {
21
21
  try {
22
- const pkgDir = path.dirname(fileURLToPath(import.meta.url));
22
+ let pkgDir;
23
23
  const home = process.env.HOME || process.env.USERPROFILE;
24
+
25
+ // Try multiple ways to find package directory
26
+ if (process.env.BUN_INSTALL_CACHE_DIR) {
27
+ pkgDir = path.join(process.env.BUN_INSTALL_CACHE_DIR, "node_modules", "@miloya", "oc-minimax-status");
28
+ } else if (process.env.npm_package_json) {
29
+ pkgDir = path.dirname(process.env.npm_package_json);
30
+ } else if (typeof import.meta !== "undefined" && import.meta.url) {
31
+ pkgDir = path.dirname(fileURLToPath(import.meta.url));
32
+ } else {
33
+ pkgDir = path.join(home, ".cache", "opencode", "node_modules", "@miloya", "oc-minimax-status");
34
+ }
35
+
36
+ console.log("[minimax-status] Syncing from:", pkgDir);
37
+
24
38
  const plugins = path.join(home, ".config", "opencode", "plugins");
25
39
  const commands = path.join(home, ".config", "opencode", "commands");
26
40
 
27
- // Copy index.js to plugins
28
41
  const srcIndex = path.join(pkgDir, "index.js");
29
42
  const destIndex = path.join(plugins, "oc-minimax-status.js");
30
43
  if (fs.existsSync(srcIndex)) {
31
- if (!fs.existsSync(plugins)) {
32
- fs.mkdirSync(plugins, { recursive: true });
33
- }
44
+ if (!fs.existsSync(plugins)) fs.mkdirSync(plugins, { recursive: true });
34
45
  fs.copyFileSync(srcIndex, destIndex);
46
+ console.log("[minimax-status] Copied index.js");
35
47
  }
36
48
 
37
- // Copy commands
38
49
  const srcCmdDir = path.join(pkgDir, "commands");
39
50
  if (fs.existsSync(srcCmdDir)) {
40
- if (!fs.existsSync(commands)) {
41
- fs.mkdirSync(commands, { recursive: true });
42
- }
51
+ if (!fs.existsSync(commands)) fs.mkdirSync(commands, { recursive: true });
43
52
  const files = fs.readdirSync(srcCmdDir);
44
53
  for (const file of files) {
45
54
  if (file.endsWith(".md")) {
46
- fs.copyFileSync(
47
- path.join(srcCmdDir, file),
48
- path.join(commands, file)
49
- );
55
+ fs.copyFileSync(path.join(srcCmdDir, file), path.join(commands, file));
56
+ console.log("[minimax-status] Copied", file);
50
57
  }
51
58
  }
52
59
  }
53
60
  } catch (e) {
54
- // Silent fail
61
+ console.log("[minimax-status] Sync error:", e.message);
55
62
  }
56
63
  }
57
64
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@miloya/oc-minimax-status",
3
- "version": "0.1.4",
3
+ "version": "0.1.6",
4
4
  "description": "MiniMax Coding Plan 用量查询插件 for OpenCode - 一键安装自动配置",
5
5
  "main": "index.js",
6
6
  "type": "module",