@miloya/oc-minimax-status 0.1.1 → 0.1.3

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/bin/init.js +20 -11
  2. package/package.json +1 -1
package/bin/init.js CHANGED
@@ -28,9 +28,14 @@ function getCommandDir() {
28
28
  return path.join(home, ".config", "opencode", "commands");
29
29
  }
30
30
 
31
- function getPackageDir() {
32
- return process.cwd();
33
- }
31
+ function getPackageDir() {
32
+ // When running postinstall for global install, use npm_package_json env var
33
+ const pkgJson = process.env.npm_package_json;
34
+ if (pkgJson) {
35
+ return path.dirname(pkgJson);
36
+ }
37
+ return process.cwd();
38
+ }
34
39
 
35
40
  function updateOpencodeConfig() {
36
41
  const configPath = getOpencodeConfigPath();
@@ -88,17 +93,21 @@ async function init() {
88
93
  fs.copyFileSync(srcIndex, destIndex);
89
94
  console.log(` [OK] Copied ${PLUGIN_NAME}.js`);
90
95
 
91
- // Copy command file
96
+ // Copy command files
92
97
  const commandDir = getCommandDir();
93
- const srcCommand = path.join(packageDir, "commands", "minimax.md");
94
- const destCommand = path.join(commandDir, "minimax.md");
98
+
99
+ if (!fs.existsSync(commandDir)) {
100
+ fs.mkdirSync(commandDir, { recursive: true });
101
+ }
95
102
 
96
- if (fs.existsSync(srcCommand)) {
97
- if (!fs.existsSync(commandDir)) {
98
- fs.mkdirSync(commandDir, { recursive: true });
103
+ const cmdFiles = ["minimax.md", "minimax-set.md"];
104
+ for (const cmdFile of cmdFiles) {
105
+ const srcCommand = path.join(packageDir, "commands", cmdFile);
106
+ const destCommand = path.join(commandDir, cmdFile);
107
+ if (fs.existsSync(srcCommand)) {
108
+ fs.copyFileSync(srcCommand, destCommand);
109
+ console.log(` [OK] Copied /${cmdFile.replace(".md", "")} command`);
99
110
  }
100
- fs.copyFileSync(srcCommand, destCommand);
101
- console.log(` [OK] Copied /minimax command`);
102
111
  }
103
112
 
104
113
  console.log("-- Installing dependencies...");
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@miloya/oc-minimax-status",
3
- "version": "0.1.1",
3
+ "version": "0.1.3",
4
4
  "description": "MiniMax Coding Plan 用量查询插件 for OpenCode - 一键安装自动配置",
5
5
  "main": "index.js",
6
6
  "type": "module",