@trim21/personal-pi-extensions 0.1.690 → 0.1.692

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 (44) hide show
  1. package/README.md +11 -3
  2. package/package.json +1 -1
  3. package/src/bwrap/dcg-scan.ts +2 -8
  4. package/src/bwrap/html.ts +13 -0
  5. package/src/bwrap/runtime.ts +1 -8
  6. package/src/claude-code/shell.ts +12 -42
  7. package/src/codemode/declarations.ts +3 -8
  8. package/src/codemode/tool.ts +15 -6
  9. package/src/gh/base.ts +91 -23
  10. package/src/gh/index.ts +8 -5
  11. package/src/gh/tools/download-release-assets.ts +6 -3
  12. package/src/gh/tools/get-workflow-jobs.ts +4 -7
  13. package/src/gh/tools/list-issues.ts +6 -39
  14. package/src/gh/tools/list-prs.ts +6 -39
  15. package/src/gh/tools/list-releases.ts +6 -9
  16. package/src/gh/tools/list-workflow-runs.ts +6 -9
  17. package/src/gh/tools/read-ci-logs.ts +8 -19
  18. package/src/gh/tools/read-issue-comments.ts +4 -12
  19. package/src/gh/tools/read-issue.ts +4 -12
  20. package/src/gh/tools/read-pr-comments.ts +6 -14
  21. package/src/gh/tools/read-pr-diff.ts +8 -8
  22. package/src/gh/tools/read-pr-status.ts +6 -4
  23. package/src/gh/tools/read-pr.ts +4 -12
  24. package/src/gh/tools/read-release.ts +5 -8
  25. package/src/gh/tools/read-repo.ts +5 -9
  26. package/src/gh/tools/wait-commit-checks.ts +2 -4
  27. package/src/gh/tools/wait-pr-checks.ts +2 -4
  28. package/src/gh/tools/watch-run.ts +7 -4
  29. package/src/index.ts +3 -0
  30. package/src/lib/abort.ts +10 -0
  31. package/src/lib/bash-tool.ts +48 -0
  32. package/src/lib/github-reads.ts +3 -23
  33. package/src/lib/github.ts +81 -41
  34. package/src/lib/model-call.ts +3 -7
  35. package/src/lib/tool-bus.ts +30 -2
  36. package/src/lib/tool-registration.ts +6 -0
  37. package/src/lib/tools-config.ts +24 -7
  38. package/src/opencode/bash.ts +11 -42
  39. package/src/opencode/glob.ts +1 -6
  40. package/src/opencode/grep.ts +1 -6
  41. package/src/opencode/ripgrep.ts +5 -0
  42. package/src/web/fetch.ts +2 -6
  43. package/src/web/search.ts +2 -6
  44. package/src/orphan-worker-cleaner.ts +0 -38
package/src/web/fetch.ts CHANGED
@@ -21,6 +21,7 @@ import { parseHTML } from "linkedom";
21
21
  import TurndownService from "turndown";
22
22
  import { Type } from "typebox";
23
23
 
24
+ import { withTimeoutSignal } from "../lib/abort.js";
24
25
  import { egress } from "../lib/egress.js";
25
26
  import { resolvePathArg } from "../lib/path.js";
26
27
  import { createRequestPolicy } from "../lib/request-policy.js";
@@ -120,11 +121,6 @@ export async function assertPublicHostname(
120
121
  }
121
122
  }
122
123
 
123
- function withTimeout(signal: AbortSignal | undefined, ms: number): AbortSignal {
124
- const timeout = AbortSignal.timeout(ms);
125
- return signal ? AbortSignal.any([signal, timeout]) : timeout;
126
- }
127
-
128
124
  interface FetchedPage {
129
125
  url: string;
130
126
  title: string;
@@ -150,7 +146,7 @@ async function fetchWithRedirects(
150
146
  await assertPublicHostname(current.hostname);
151
147
  const response = await fetchFn(current, {
152
148
  redirect: "manual",
153
- signal: withTimeout(signal, TIMEOUT_MS),
149
+ signal: withTimeoutSignal(signal, TIMEOUT_MS),
154
150
  headers: { "user-agent": "Mozilla/5.0 (compatible; pi-web-fetch/1.0)" },
155
151
  });
156
152
  const location = response.headers.get("location");
package/src/web/search.ts CHANGED
@@ -11,6 +11,7 @@ import type { ExtensionAPI } from "@earendil-works/pi-coding-agent";
11
11
  import { Type } from "typebox";
12
12
  import { Value } from "typebox/value";
13
13
 
14
+ import { withTimeoutSignal } from "../lib/abort.js";
14
15
  import { egress } from "../lib/egress.js";
15
16
  import type { ToolBus } from "../lib/tool-bus.js";
16
17
  import { registerToolsOnSessionStart } from "../lib/tool-registration.js";
@@ -143,11 +144,6 @@ function mapHits(
143
144
  }
144
145
 
145
146
  /** 合并调用方 signal 与超时;调用方未传时仍有超时兜底 */
146
- function withTimeout(signal: AbortSignal | undefined, ms: number): AbortSignal {
147
- const timeout = AbortSignal.timeout(ms);
148
- return signal ? AbortSignal.any([signal, timeout]) : timeout;
149
- }
150
-
151
147
  export async function searchWeb(
152
148
  query: string,
153
149
  apiKey: string,
@@ -160,7 +156,7 @@ export async function searchWeb(
160
156
  "Content-Type": "application/json",
161
157
  },
162
158
  body: JSON.stringify(buildSearchBody(query, options)),
163
- signal: withTimeout(options.signal, TIMEOUT_MS),
159
+ signal: withTimeoutSignal(options.signal, TIMEOUT_MS),
164
160
  });
165
161
 
166
162
  const raw = await response.text();
@@ -1,38 +0,0 @@
1
- /**
2
- * orphan-worker-cleaner —— 宿主消失时让 pi SDK worker 自行退出
3
- *
4
- * VS Code 的 pi 扩展(Pendant)用 fork 启动 dist/pi-sdk-worker.cjs 承载 pi SDK。
5
- * 宿主进程消失时 worker 不会退出:worker 侧只把 IPC 断连当成可重试的传输错误
6
- * 上报,既不清理也不自杀,于是留下 ppid=1 的孤儿,连同它拉起的 language server
7
- * (实测单个 worker 身上挂 4 GiB 上下)一起常驻。
8
- *
9
- * 这里只做一件事:定时看一眼自己的父进程还在不在(父进程退出后会被 init 收养,
10
- * ppid 变成 1),不在就退出。worker 一退,它拉起的 language server 会因为 stdin
11
- * 关闭自行退出,language server 退出时(process.on("exit") → shutdown())又会
12
- * kill 掉自己 fork 的 tsserver,整棵树随之消失 —— 所以不需要遍历或清理别的进程。
13
- *
14
- * 只对 fork 出来的 SDK worker 生效(process.channel 存在):CLI 直跑、以及 pi
15
- * 内部 spawn 出来的进程都没有 IPC channel,不在此列,不会被误伤。
16
- */
17
-
18
- import type { ExtensionAPI } from "@earendil-works/pi-coding-agent";
19
-
20
- /** 检查父进程是否还在的间隔 */
21
- export const DEFAULT_CHECK_INTERVAL_MS = 5_000;
22
-
23
- export default function orphanWorkerCleaner(pi: ExtensionAPI): void {
24
- if (process.channel === undefined) {
25
- return;
26
- }
27
- const timer = setInterval(() => {
28
- if (process.ppid === 1) {
29
- // eslint-disable-next-line unicorn/no-process-exit -- 宿主已经没了,worker 必须整体退出
30
- process.exit(0);
31
- }
32
- }, DEFAULT_CHECK_INTERVAL_MS);
33
- timer.unref();
34
-
35
- pi.on("session_shutdown", () => {
36
- clearInterval(timer);
37
- });
38
- }