openai-ws-opencode 0.1.0 → 0.1.1
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 +1 -1
- package/bin/setup.js +15 -2
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -101,7 +101,7 @@ Then point OpenCode at the packed tarball through the plugin array:
|
|
|
101
101
|
|
|
102
102
|
```jsonc
|
|
103
103
|
{
|
|
104
|
-
"plugin": ["openai-ws-opencode@file:/absolute/path/openai-ws-opencode-0.1.
|
|
104
|
+
"plugin": ["openai-ws-opencode@file:/absolute/path/openai-ws-opencode-0.1.1.tgz"]
|
|
105
105
|
}
|
|
106
106
|
```
|
|
107
107
|
|
package/bin/setup.js
CHANGED
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
|
|
3
3
|
// bin/setup.ts
|
|
4
|
+
import { realpathSync } from "node:fs";
|
|
4
5
|
import fs from "node:fs/promises";
|
|
5
6
|
import os from "node:os";
|
|
6
7
|
import path from "node:path";
|
|
8
|
+
import { fileURLToPath } from "node:url";
|
|
7
9
|
import { applyEdits, format, modify, parse } from "jsonc-parser";
|
|
8
10
|
|
|
9
11
|
// src/constants.ts
|
|
@@ -225,7 +227,17 @@ function parseArgs(argv) {
|
|
|
225
227
|
}
|
|
226
228
|
return options;
|
|
227
229
|
}
|
|
228
|
-
|
|
230
|
+
function isDirectExecution(moduleUrl = import.meta.url, argvPath = process.argv[1]) {
|
|
231
|
+
if (!argvPath)
|
|
232
|
+
return false;
|
|
233
|
+
const modulePath = fileURLToPath(moduleUrl);
|
|
234
|
+
try {
|
|
235
|
+
return realpathSync(modulePath) === realpathSync(argvPath);
|
|
236
|
+
} catch {
|
|
237
|
+
return path.resolve(modulePath) === path.resolve(argvPath);
|
|
238
|
+
}
|
|
239
|
+
}
|
|
240
|
+
if (isDirectExecution()) {
|
|
229
241
|
setupOpenCodeConfig(parseArgs(process.argv.slice(2))).then((file) => {
|
|
230
242
|
console.log(`Updated OpenCode config: ${file}`);
|
|
231
243
|
}).catch((error) => {
|
|
@@ -235,5 +247,6 @@ if (import.meta.url === `file://${process.argv[1]}`) {
|
|
|
235
247
|
}
|
|
236
248
|
export {
|
|
237
249
|
setupOpenCodeConfig,
|
|
238
|
-
patchConfigText
|
|
250
|
+
patchConfigText,
|
|
251
|
+
isDirectExecution
|
|
239
252
|
};
|