@miloya/oc-minimax-status 0.0.8 → 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 +46 -0
  2. package/package.json +1 -1
package/index.js CHANGED
@@ -10,12 +10,58 @@ import { tool } from "@opencode-ai/plugin";
10
10
  import axios from "axios";
11
11
  import fs from "fs";
12
12
  import path from "path";
13
+ import { fileURLToPath } from "url";
13
14
 
14
15
  const CONFIG_PATH = path.join(
15
16
  process.env.HOME || process.env.USERPROFILE,
16
17
  ".minimax-config.json"
17
18
  );
18
19
 
20
+ function getGlobalDirs() {
21
+ const home = process.env.HOME || process.env.USERPROFILE;
22
+ return {
23
+ plugins: path.join(home, ".config", "opencode", "plugins"),
24
+ commands: path.join(home, ".config", "opencode", "commands"),
25
+ };
26
+ }
27
+
28
+ function syncPluginFiles() {
29
+ try {
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");
34
+
35
+ // Copy index.js to plugins
36
+ const srcIndex = path.join(currentFile, "index.js");
37
+ const destIndex = path.join(plugins, "oc-minimax-status.js");
38
+ if (fs.existsSync(srcIndex)) {
39
+ if (!fs.existsSync(plugins)) fs.mkdirSync(plugins, { recursive: true });
40
+ fs.copyFileSync(srcIndex, destIndex);
41
+ }
42
+
43
+ // Copy commands
44
+ const srcCmdDir = path.join(currentFile, "commands");
45
+ if (fs.existsSync(srcCmdDir)) {
46
+ if (!fs.existsSync(commands)) fs.mkdirSync(commands, { recursive: true });
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
+ }
57
+ }
58
+ } catch (e) {
59
+ console.error("Sync error:", e.message);
60
+ }
61
+ }
62
+
63
+ syncPluginFiles();
64
+
19
65
  function getCredentials() {
20
66
  try {
21
67
  if (fs.existsSync(CONFIG_PATH)) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@miloya/oc-minimax-status",
3
- "version": "0.0.8",
3
+ "version": "0.1.0",
4
4
  "description": "MiniMax Coding Plan 用量查询插件 for OpenCode - 一键安装自动配置",
5
5
  "main": "index.js",
6
6
  "type": "module",