opencode-oncall 0.1.0 → 0.1.5

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 CHANGED
@@ -13,7 +13,7 @@
13
13
  首发发布完成后,使用固定版本命令安装或升级:
14
14
 
15
15
  ```bash
16
- opencode plugin opencode-oncall@0.1.0 --force -g
16
+ opencode plugin opencode-oncall@0.1.5 --force -g
17
17
  ```
18
18
 
19
19
  如果你只想把插件安装到当前项目的 `.opencode`,可以去掉 `-g`;否则建议保留全局安装参数,让平时实际使用的 OpenCode 实例拿到同一版本。
@@ -43,8 +43,8 @@ npm run wechat:smoke:real-account -- --dry-run
43
43
 
44
44
  - 发布流程:[`docs/publishing.md`](docs/publishing.md)
45
45
  - Release Notes 模板:[`docs/release-notes-template.md`](docs/release-notes-template.md)
46
- - v0.1.0 首发说明:[`docs/release-notes-v0.1.0.md`](docs/release-notes-v0.1.0.md)
46
+ - v0.1.5 发布说明:[`docs/release-notes-v0.1.5.md`](docs/release-notes-v0.1.5.md)
47
47
 
48
48
  ## 许可证
49
49
 
50
- MPL-2.0 License. See [LICENSE](LICENSE) for details.
50
+ MPL-2.0 License. See [LICENSE](LICENSE) for details.
@@ -2,6 +2,7 @@ import net from "node:net";
2
2
  type BrokerEndpointOptions = {
3
3
  platform?: NodeJS.Platform;
4
4
  stateRoot?: string;
5
+ tmpdir?: string;
5
6
  now?: () => number;
6
7
  random?: () => number;
7
8
  };
@@ -1,21 +1,30 @@
1
1
  import net from "node:net";
2
+ import os from "node:os";
2
3
  import path from "node:path";
3
4
  function isNonEmptyString(value) {
4
5
  return typeof value === "string" && value.trim().length > 0;
5
6
  }
7
+ function createBrokerSocketPath(root, suffix) {
8
+ return path.join(root, `broker-${suffix}.sock`);
9
+ }
6
10
  export function isTcpBrokerEndpoint(endpoint) {
7
11
  return endpoint.startsWith("tcp://");
8
12
  }
9
13
  export function createDefaultBrokerEndpoint(options = {}) {
10
14
  const platform = options.platform ?? process.platform;
11
15
  const stateRoot = options.stateRoot ?? ".";
16
+ const tmpdir = options.tmpdir ?? os.tmpdir();
12
17
  const now = options.now ?? Date.now;
13
18
  const random = options.random ?? Math.random;
14
19
  const suffix = `${now()}-${random().toString(16).slice(2)}`;
15
20
  if (platform === "win32") {
16
21
  return "tcp://127.0.0.1:0";
17
22
  }
18
- return path.join(stateRoot, `broker-${suffix}.sock`);
23
+ const stateRootEndpoint = createBrokerSocketPath(stateRoot, suffix);
24
+ if (Buffer.byteLength(stateRootEndpoint) <= 100) {
25
+ return stateRootEndpoint;
26
+ }
27
+ return createBrokerSocketPath(tmpdir, suffix);
19
28
  }
20
29
  export function parseBrokerEndpoint(endpoint) {
21
30
  if (!isTcpBrokerEndpoint(endpoint)) {
@@ -37,13 +37,31 @@ export function resolveCreateJiti(namespace) {
37
37
  const defaultKeys = defaultValue && typeof defaultValue === "object" ? Object.keys(defaultValue).join(",") : typeof defaultValue;
38
38
  throw new Error(`[wechat-compat] createJiti export unavailable (keys=${topLevelKeys}; default=${defaultKeys})`);
39
39
  }
40
+ function isWindowsAbsolutePath(filePath) {
41
+ return /^[A-Za-z]:[\\/]/.test(filePath);
42
+ }
43
+ function joinSiblingFromResolvedPackage(packageJsonPath, ...segments) {
44
+ const pathImpl = isWindowsAbsolutePath(packageJsonPath) ? path.win32 : path;
45
+ return pathImpl.join(pathImpl.dirname(packageJsonPath), ...segments);
46
+ }
47
+ function encodeFileURLPathSegment(segment) {
48
+ return encodeURIComponent(segment);
49
+ }
50
+ function pathToFileURLHref(filePath) {
51
+ if (!isWindowsAbsolutePath(filePath)) {
52
+ return pathToFileURL(filePath).href;
53
+ }
54
+ const normalized = path.win32.normalize(filePath).replace(/\\/g, "/");
55
+ const [drive, ...segments] = normalized.split("/");
56
+ return `file:///${drive}/${segments.map(encodeFileURLPathSegment).join("/")}`;
57
+ }
40
58
  export function resolveJitiEsmEntry(resolveImpl = createRequire(import.meta.url).resolve) {
41
59
  const packageJsonPath = resolveImpl("jiti/package.json");
42
- return pathToFileURL(path.join(path.dirname(packageJsonPath), "lib", "jiti.cjs")).href;
60
+ return pathToFileURLHref(joinSiblingFromResolvedPackage(packageJsonPath, "lib", "jiti.cjs"));
43
61
  }
44
62
  export function resolveJitiCjsEntry(resolveImpl = createRequire(import.meta.url).resolve) {
45
63
  const packageJsonPath = resolveImpl("jiti/package.json");
46
- return path.join(path.dirname(packageJsonPath), "lib", "jiti.cjs");
64
+ return joinSiblingFromResolvedPackage(packageJsonPath, "lib", "jiti.cjs");
47
65
  }
48
66
  function onJitiError(error) {
49
67
  throw error;
@@ -100,7 +118,7 @@ export async function loadJiti(importImpl = (specifier) => import(specifier), re
100
118
  }
101
119
  }
102
120
  export async function loadModuleWithTsFallback(modulePath, options = {}) {
103
- const moduleUrl = pathToFileURL(modulePath).href;
121
+ const moduleUrl = pathToFileURLHref(modulePath);
104
122
  const importImpl = options.importImpl ?? nativeImport;
105
123
  // Even under Bun, TS entrypoints inside node_modules can transitively hit ESM/CJS
106
124
  // interop edges (for example openclaw -> json5 default import). Jiti keeps that
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "opencode-oncall",
3
- "version": "0.1.0",
3
+ "version": "0.1.5",
4
4
  "description": "Remote on-call UX plugin for OpenCode over WeChat",
5
5
  "main": "./dist/index.js",
6
6
  "types": "./dist/index.d.ts",