@trim21/personal-pi-extensions 0.1.644 → 0.1.647
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 +1 -1
- package/src/gh/tools/list-issues.ts +5 -2
- package/src/gh/tools/list-prs.ts +5 -2
- package/src/lib/github.ts +9 -13
- package/src/spawn-agent.ts +21 -7
package/package.json
CHANGED
|
@@ -41,9 +41,12 @@ export function addListIssuesTool(gh: GhClient, pi: ExtensionAPI) {
|
|
|
41
41
|
}),
|
|
42
42
|
),
|
|
43
43
|
label: Type.Optional(Type.String({ description: "Filter by label" })),
|
|
44
|
-
|
|
44
|
+
// `@me` 由 GitHub 的搜索 / 过滤 API 解析:不带 keywords 时 gh 自行展开(GraphQL 过滤分支)
|
|
45
|
+
// 或按字面量转发(搜索分支),带 keywords 时我们直接把 `assignee:@me` 交给搜索 API。
|
|
46
|
+
// 两条传输都支持,因此本仓库不要再实现一次展开。
|
|
47
|
+
author: Type.Optional(Type.String({ description: "Filter by author ('@me' for yourself)" })),
|
|
45
48
|
assignee: Type.Optional(
|
|
46
|
-
Type.String({ description: "Filter by assignee (@me for yourself)" }),
|
|
49
|
+
Type.String({ description: "Filter by assignee ('@me' for yourself)" }),
|
|
47
50
|
),
|
|
48
51
|
milestone: Type.Optional(Type.String({ description: "Filter by milestone" })),
|
|
49
52
|
limit: Type.Optional(Type.Number({ description: "Max results (default 30, max 100)" })),
|
package/src/gh/tools/list-prs.ts
CHANGED
|
@@ -41,9 +41,12 @@ export function addListPrsTool(gh: GhClient, pi: ExtensionAPI) {
|
|
|
41
41
|
}),
|
|
42
42
|
),
|
|
43
43
|
label: Type.Optional(Type.String({ description: "Filter by label" })),
|
|
44
|
-
|
|
44
|
+
// `@me` 由 GitHub 的搜索 / 过滤 API 解析:不带 keywords 时 gh 自行展开(GraphQL 过滤分支)
|
|
45
|
+
// 或按字面量转发(搜索分支),带 keywords 时我们直接把 `assignee:@me` 交给搜索 API。
|
|
46
|
+
// 两条传输都支持,因此本仓库不要再实现一次展开。
|
|
47
|
+
author: Type.Optional(Type.String({ description: "Filter by author ('@me' for yourself)" })),
|
|
45
48
|
assignee: Type.Optional(
|
|
46
|
-
Type.String({ description: "Filter by assignee (@me for yourself)" }),
|
|
49
|
+
Type.String({ description: "Filter by assignee ('@me' for yourself)" }),
|
|
47
50
|
),
|
|
48
51
|
milestone: Type.Optional(Type.String({ description: "Filter by milestone" })),
|
|
49
52
|
limit: Type.Optional(Type.Number({ description: "Max results (default 30, max 100)" })),
|
package/src/lib/github.ts
CHANGED
|
@@ -310,22 +310,18 @@ export function createGithubSearch(options: GithubClientOptions = {}): GithubSea
|
|
|
310
310
|
return {
|
|
311
311
|
async search(kind, params) {
|
|
312
312
|
const limit = Math.min(Math.max(params.limit ?? 30, 1), 100);
|
|
313
|
-
const effective = { ...params, limit };
|
|
314
313
|
|
|
315
314
|
try {
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
}
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
q,
|
|
326
|
-
per_page: limit,
|
|
315
|
+
// `@me` 是 gh CLI 的简写,REST 搜索不认识:这里不展开,带关键词时它按字面量
|
|
316
|
+
// 进入查询串(无关键词的列表走 gh CLI,由 gh 自己展开)。
|
|
317
|
+
const q = buildSearchQuery(kind, { ...params, limit });
|
|
318
|
+
return await api.call(async (client) => {
|
|
319
|
+
const { data } = await client.rest.search.issuesAndPullRequests({
|
|
320
|
+
q,
|
|
321
|
+
per_page: limit,
|
|
322
|
+
});
|
|
323
|
+
return data.items.map((item) => normalize(parseWithSchema(searchItemSchema, item)));
|
|
327
324
|
});
|
|
328
|
-
return data.items.map((item) => normalize(parseWithSchema(searchItemSchema, item)));
|
|
329
325
|
} catch (error) {
|
|
330
326
|
const status = (error as { status?: number }).status;
|
|
331
327
|
const message = (error as { message?: string }).message ?? String(error);
|
package/src/spawn-agent.ts
CHANGED
|
@@ -10,7 +10,11 @@
|
|
|
10
10
|
* pass to the tool. Execution
|
|
11
11
|
* is blocking: the tool awaits the subagent session until the turn settles and
|
|
12
12
|
* returns its final output to the parent model. Progress is streamed through
|
|
13
|
-
* `onUpdate`, the same channel the built-in bash tool uses for live output
|
|
13
|
+
* `onUpdate`, the same channel the built-in bash tool uses for live output, and
|
|
14
|
+
* is throttled like the bash tool: pushes are capped at one per
|
|
15
|
+
* `PROGRESS_UPDATE_THROTTLE_MS` so a burst of thinking deltas does not
|
|
16
|
+
* re-render the panel per chunk, and the trailing push still delivers the
|
|
17
|
+
* latest state at the end of the window.
|
|
14
18
|
* Progress is a rolling log: `tool: <name>` lines for tool calls and
|
|
15
19
|
* `text: <content>` lines for completed text blocks, keeping only the last few
|
|
16
20
|
* lines (`MAX_PROGRESS_LINES` in spawn-agent-progress.ts). Consecutive tool calls are merged into a
|
|
@@ -64,6 +68,7 @@ import {
|
|
|
64
68
|
SettingsManager,
|
|
65
69
|
truncateTail,
|
|
66
70
|
} from "@earendil-works/pi-coding-agent";
|
|
71
|
+
import { throttle } from "lodash-es";
|
|
67
72
|
import { Type } from "typebox";
|
|
68
73
|
|
|
69
74
|
import { type BwrapConfig, completeBwrapConfig } from "./bwrap/core.js";
|
|
@@ -87,6 +92,11 @@ import { createSubagentProgress, formatTokens } from "./spawn-agent-progress.js"
|
|
|
87
92
|
const MAX_OUTPUT_BYTES = 50 * 1024;
|
|
88
93
|
/** Read-only toolset used when an agent does not declare `tools`. */
|
|
89
94
|
const DEFAULT_TOOLS = ["read", "grep", "find", "ls"];
|
|
95
|
+
/**
|
|
96
|
+
* 进度推送的最小间隔(对齐 bash 工具的进度限流):逐 chunk 的 thinking 增量
|
|
97
|
+
* 会让面板每个 chunk 都重渲染一次。配合 trailing,窗口结束时的最新状态仍会送达。
|
|
98
|
+
*/
|
|
99
|
+
export const PROGRESS_UPDATE_THROTTLE_MS = 100;
|
|
90
100
|
/**
|
|
91
101
|
* 子代理未在 frontmatter 声明 `sandbox` 时 bash 使用的固定沙箱:文件系统只读 + 断网。
|
|
92
102
|
* 与主会话(跟随用户 sandbox.json)相反,子代理不继承用户配置——为交互会话放宽的
|
|
@@ -412,12 +422,16 @@ export async function runAgent(
|
|
|
412
422
|
|
|
413
423
|
const progress = createSubagentProgress({ name: result.agent });
|
|
414
424
|
|
|
415
|
-
const emitUpdate = (
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
425
|
+
const emitUpdate = throttle(
|
|
426
|
+
() => {
|
|
427
|
+
onUpdate?.({
|
|
428
|
+
content: [{ type: "text", text: progress.render(result.usage, result.model) }],
|
|
429
|
+
details: {},
|
|
430
|
+
});
|
|
431
|
+
},
|
|
432
|
+
PROGRESS_UPDATE_THROTTLE_MS,
|
|
433
|
+
{ trailing: true },
|
|
434
|
+
);
|
|
421
435
|
|
|
422
436
|
const handleEvent = (event: AgentSessionEvent) => {
|
|
423
437
|
switch (event.type) {
|