@miloya/oc-minimax-status 0.0.9 → 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.
Files changed (2) hide show
  1. package/index.js +20 -14
  2. package/package.json +1 -1
package/index.js CHANGED
@@ -27,30 +27,36 @@ function getGlobalDirs() {
27
27
 
28
28
  function syncPluginFiles() {
29
29
  try {
30
- const currentFile = path.dirname(path.dirname(fileURLToPath(import.meta.url)));
31
- const { plugins, commands } = getGlobalDirs();
30
+ const currentFile = path.dirname(fileURLToPath(import.meta.url));
31
+ const home = process.env.HOME || process.env.USERPROFILE;
32
+ const plugins = path.join(home, ".config", "opencode", "plugins");
33
+ const commands = path.join(home, ".config", "opencode", "commands");
32
34
 
35
+ // Copy index.js to plugins
33
36
  const srcIndex = path.join(currentFile, "index.js");
34
37
  const destIndex = path.join(plugins, "oc-minimax-status.js");
35
38
  if (fs.existsSync(srcIndex)) {
39
+ if (!fs.existsSync(plugins)) fs.mkdirSync(plugins, { recursive: true });
36
40
  fs.copyFileSync(srcIndex, destIndex);
37
41
  }
38
42
 
39
- const srcCmd = path.join(currentFile, "commands", "minimax.md");
40
- const destCmd = path.join(commands, "minimax.md");
41
- if (fs.existsSync(srcCmd)) {
43
+ // Copy commands
44
+ const srcCmdDir = path.join(currentFile, "commands");
45
+ if (fs.existsSync(srcCmdDir)) {
42
46
  if (!fs.existsSync(commands)) fs.mkdirSync(commands, { recursive: true });
43
- fs.copyFileSync(srcCmd, destCmd);
44
- }
45
-
46
- const srcSetCmd = path.join(currentFile, "commands", "minimax-set.md");
47
- const destSetCmd = path.join(commands, "minimax-set.md");
48
- if (fs.existsSync(srcSetCmd)) {
49
- if (!fs.existsSync(commands)) fs.mkdirSync(commands, { recursive: true });
50
- fs.copyFileSync(srcSetCmd, destSetCmd);
47
+
48
+ const files = fs.readdirSync(srcCmdDir);
49
+ for (const file of files) {
50
+ if (file.endsWith(".md")) {
51
+ fs.copyFileSync(
52
+ path.join(srcCmdDir, file),
53
+ path.join(commands, file)
54
+ );
55
+ }
56
+ }
51
57
  }
52
58
  } catch (e) {
53
- // Ignore sync errors
59
+ console.error("Sync error:", e.message);
54
60
  }
55
61
  }
56
62
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@miloya/oc-minimax-status",
3
- "version": "0.0.9",
3
+ "version": "0.1.0",
4
4
  "description": "MiniMax Coding Plan 用量查询插件 for OpenCode - 一键安装自动配置",
5
5
  "main": "index.js",
6
6
  "type": "module",