@trim21/personal-pi-extensions 0.1.437 → 0.1.438

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@trim21/personal-pi-extensions",
3
- "version": "0.1.437",
3
+ "version": "0.1.438",
4
4
  "type": "module",
5
5
  "description": "Custom pi coding-agent extensions: bwrap sandbox, workspace guard, opencode edit, and more",
6
6
  "keywords": [
@@ -23,7 +23,6 @@
23
23
  "format": "prettier --write .",
24
24
  "test": "vitest run",
25
25
  "test:coverage": "vitest run --coverage",
26
- "build:holder": "esbuild src/bwrap/holder.ts --format=esm --target=node24 --outfile=src/bwrap/holder.js",
27
26
  "prepare": "husky"
28
27
  },
29
28
  "peerDependencies": {
@@ -42,7 +41,6 @@
42
41
  "@types/turndown": "^5.0.6",
43
42
  "@typescript/native": "npm:typescript@^7.0.2",
44
43
  "@vitest/coverage-v8": "^4.1.10",
45
- "esbuild": "^0.28.2",
46
44
  "eslint": "^10.8.1",
47
45
  "eslint-config-prettier": "10.1.8",
48
46
  "eslint-plugin-erasable-syntax-only": "0.7.1",
@@ -37,7 +37,7 @@ export interface NetworkStackExecOptions {
37
37
  }
38
38
 
39
39
  const NAMESERVER_PATTERN = /^\s*nameserver\s+(\S+)/;
40
- const HOLDER_PATH = fileURLToPath(new URL("holder.js", import.meta.url));
40
+ const HOLDER_PATH = fileURLToPath(new URL("holder.ts", import.meta.url));
41
41
  // ip 通常位于 /usr/sbin 或 /sbin,进程默认 PATH 不含它们;node 则依赖宿主完整 PATH
42
42
  const SBIN_PATH_SUFFIX = "/usr/local/sbin:/usr/sbin:/sbin";
43
43
 
@@ -226,7 +226,6 @@ class BashOutput {
226
226
  });
227
227
  }
228
228
 
229
- // eslint-disable-next-line unicorn/no-nonstandard-builtin-properties -- ES2024 标准(Node 24 原生支持)
230
229
  async [Symbol.asyncDispose](): Promise<void> {
231
230
  await this.close();
232
231
  }
@@ -394,7 +393,6 @@ export class BwrapRuntime {
394
393
  // 每次命令现建网络栈(启动约 140ms),作用域结束自动停栈;allowlist 变化即时生效
395
394
  const networkStack = local ? undefined : await createNetworkStack(runtime);
396
395
  await using _stack = {
397
- // eslint-disable-next-line unicorn/no-nonstandard-builtin-properties -- ES2024 标准(Node 24 原生支持)
398
396
  async [Symbol.asyncDispose]() {
399
397
  try {
400
398
  await networkStack?.stop();
@@ -1,47 +0,0 @@
1
- import { spawn } from "node:child_process";
2
- import { dirname } from "node:path";
3
- import { setTimeout as sleep } from "node:timers/promises";
4
- const args = process.argv.slice(2);
5
- const configPath = args[0];
6
- const mihomoPath = args[1];
7
- if (!configPath || !mihomoPath) {
8
- process.exit(2);
9
- }
10
- function tap0Exists() {
11
- return new Promise((resolve) => {
12
- const child = spawn("ip", ["link", "show", "tap0"], { stdio: "ignore" });
13
- child.once("exit", (code) => resolve(code === 0));
14
- child.once("error", () => resolve(false));
15
- });
16
- }
17
- async function waitFor(attempts, delayMs, predicate) {
18
- for (let i = 0; i < attempts; i++) {
19
- if (await predicate()) return true;
20
- await sleep(delayMs);
21
- }
22
- return false;
23
- }
24
- async function main() {
25
- await waitFor(100, 100, tap0Exists);
26
- const mihomo = spawn(mihomoPath, ["-d", dirname(configPath), "-f", configPath], {
27
- stdio: ["ignore", "inherit", "inherit"]
28
- });
29
- const stop = () => {
30
- mihomo.kill("SIGTERM");
31
- };
32
- process.on("SIGTERM", () => {
33
- stop();
34
- process.exit(0);
35
- });
36
- process.on("SIGINT", () => {
37
- stop();
38
- process.exit(0);
39
- });
40
- await new Promise((resolve) => mihomo.once("exit", () => resolve()));
41
- }
42
- try {
43
- await main();
44
- } catch (error) {
45
- console.error(error);
46
- process.exit(1);
47
- }