@trim21/personal-pi-extensions 0.1.650 → 0.1.652
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 +67 -9
- package/package.json +5 -13
- package/src/aft/index.ts +40 -23
- package/src/aft/tools.ts +10 -9
- package/src/claude-code/files.ts +99 -54
- package/src/claude-code/glob.ts +8 -5
- package/src/claude-code/grep.ts +8 -5
- package/src/claude-code/index.ts +56 -10
- package/src/claude-code/search.ts +4 -3
- package/src/claude-code/session-tools.ts +4 -3
- package/src/claude-code/shell.ts +3 -8
- package/src/gh/index.ts +48 -25
- package/src/gh/tools/download-release-assets.ts +3 -3
- package/src/gh/tools/get-workflow-jobs.ts +3 -3
- package/src/gh/tools/list-issues.ts +3 -3
- package/src/gh/tools/list-prs.ts +3 -3
- package/src/gh/tools/list-releases.ts +3 -3
- package/src/gh/tools/list-workflow-runs.ts +3 -3
- package/src/gh/tools/read-ci-logs.ts +3 -4
- package/src/gh/tools/read-issue-comments.ts +3 -3
- package/src/gh/tools/read-issue.ts +3 -3
- package/src/gh/tools/read-pr-comments.ts +3 -3
- package/src/gh/tools/read-pr-diff.ts +3 -3
- package/src/gh/tools/read-pr-status.ts +3 -3
- package/src/gh/tools/read-pr.ts +3 -3
- package/src/gh/tools/read-release.ts +3 -3
- package/src/gh/tools/read-repo.ts +3 -3
- package/src/gh/tools/wait-commit-checks.ts +3 -3
- package/src/gh/tools/wait-pr-checks.ts +3 -3
- package/src/gh/tools/watch-run.ts +3 -3
- package/src/index.ts +120 -0
- package/src/lib/lsp/inspect-tool.ts +5 -5
- package/src/lib/lsp/rename-tool.ts +4 -7
- package/src/lib/tool-bus.ts +126 -0
- package/src/lib/tool-registration.ts +83 -0
- package/src/lib/tool-services.ts +65 -0
- package/src/lib/tool-units.ts +102 -0
- package/src/lib/tools-config.ts +277 -0
- package/src/opencode/bash.ts +7 -2
- package/src/opencode/files.ts +90 -43
- package/src/opencode/glob.ts +7 -1
- package/src/opencode/grep.ts +7 -1
- package/src/opencode/index.ts +66 -21
- package/src/opencode/question.ts +8 -2
- package/src/opencode/todo.ts +8 -2
- package/src/orphan-worker-cleaner.ts +38 -0
- package/src/spawn-agent.ts +160 -175
- package/src/talk/index.ts +92 -66
- package/src/vision-agent.ts +31 -7
- package/src/web/fetch.ts +89 -72
- package/src/web/search.ts +14 -2
- package/src/gh-readonly.ts +0 -10
package/src/claude-code/index.ts
CHANGED
|
@@ -1,8 +1,11 @@
|
|
|
1
|
-
import type { ExtensionAPI } from "@earendil-works/pi-coding-agent";
|
|
1
|
+
import type { ExtensionAPI, ExtensionContext } from "@earendil-works/pi-coding-agent";
|
|
2
2
|
|
|
3
|
-
import { createBwrapRuntime } from "../bwrap/runtime.js";
|
|
4
|
-
import {
|
|
5
|
-
import
|
|
3
|
+
import { type BwrapRuntime, createBwrapRuntime } from "../bwrap/runtime.js";
|
|
4
|
+
import type { LspManager } from "../lib/lsp/lsp.js";
|
|
5
|
+
import { createRequestPolicy, type RequestPolicy } from "../lib/request-policy.js";
|
|
6
|
+
import type { ToolBus } from "../lib/tool-bus.js";
|
|
7
|
+
import { registerToolsOnSessionStart } from "../lib/tool-registration.js";
|
|
8
|
+
import { createClaudeCodeFileTools } from "./files.js";
|
|
6
9
|
import { registerSearchTools } from "./search.js";
|
|
7
10
|
import { registerSessionTools } from "./session-tools.js";
|
|
8
11
|
import { registerShellTools } from "./shell.js";
|
|
@@ -16,10 +19,53 @@ import { registerShellTools } from "./shell.js";
|
|
|
16
19
|
* 子代理按工具名直接 `-e` 加载各模块文件(files.ts / grep.ts / glob.ts 均为
|
|
17
20
|
* 独立扩展入口),那些入口各自创建一份策略并经 pi.events 保持同步。
|
|
18
21
|
*/
|
|
19
|
-
export
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
22
|
+
export interface ClaudeCodeToolsetOptions {
|
|
23
|
+
bus?: ToolBus;
|
|
24
|
+
policy?: RequestPolicy;
|
|
25
|
+
runtime?: BwrapRuntime;
|
|
26
|
+
manager?: LspManager;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
/** claude-code 风格工具集的共享部件:入口与独立默认导出都从这里取。 */
|
|
30
|
+
export function createClaudeCodeTools(pi: ExtensionAPI, options?: ClaudeCodeToolsetOptions) {
|
|
31
|
+
const policy = options?.policy ?? createRequestPolicy(pi.events);
|
|
32
|
+
const runtime = options?.runtime ?? createBwrapRuntime(policy);
|
|
33
|
+
// 独立入口(不经 src/index.ts 的共享服务)要自己接上 bwrap 的会话钩子与 /bwrap* 命令。
|
|
34
|
+
if (options?.runtime === undefined) {
|
|
35
|
+
runtime.setup(pi);
|
|
36
|
+
}
|
|
37
|
+
const fileTools = createClaudeCodeFileTools(pi, {
|
|
38
|
+
policy,
|
|
39
|
+
bus: options?.bus,
|
|
40
|
+
manager: options?.manager,
|
|
41
|
+
});
|
|
42
|
+
|
|
43
|
+
return {
|
|
44
|
+
fileTools,
|
|
45
|
+
/** 会话启动 / 分支切换时恢复已读记账。 */
|
|
46
|
+
restoreReads(ctx: ExtensionContext): void {
|
|
47
|
+
fileTools.restoreReads(ctx);
|
|
48
|
+
},
|
|
49
|
+
/** 把本工具集的工具注册到总线。 */
|
|
50
|
+
register(bus: ToolBus): void {
|
|
51
|
+
fileTools.register(bus);
|
|
52
|
+
registerSearchTools(bus, pi);
|
|
53
|
+
registerShellTools(bus, pi, runtime);
|
|
54
|
+
registerSessionTools(bus, pi);
|
|
55
|
+
},
|
|
56
|
+
};
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
export default function claudeCodeTools(pi: ExtensionAPI, options?: { bus?: ToolBus }): void {
|
|
60
|
+
const tools = createClaudeCodeTools(pi, { bus: options?.bus });
|
|
61
|
+
|
|
62
|
+
pi.on("session_start", (_event, ctx) => tools.restoreReads(ctx));
|
|
63
|
+
// rewind / 树内跳转只发 session_tree 不发 session_start,同样要重放当前分支。
|
|
64
|
+
pi.on("session_tree", (_event, ctx) => tools.restoreReads(ctx));
|
|
65
|
+
|
|
66
|
+
// 全部工具在同一次 session_start 里注册:禁用规则可以带 models,只有那时
|
|
67
|
+
// 才知道本会话的模型。
|
|
68
|
+
registerToolsOnSessionStart(pi, (bus) => {
|
|
69
|
+
tools.register(bus);
|
|
70
|
+
});
|
|
25
71
|
}
|
|
@@ -8,12 +8,13 @@
|
|
|
8
8
|
|
|
9
9
|
import type { ExtensionAPI } from "@earendil-works/pi-coding-agent";
|
|
10
10
|
|
|
11
|
+
import type { ToolBus } from "../lib/tool-bus.js";
|
|
11
12
|
import { registerGlobTool } from "./glob.js";
|
|
12
13
|
import { registerGrepTool } from "./grep.js";
|
|
13
14
|
|
|
14
|
-
export function registerSearchTools(pi: ExtensionAPI): void {
|
|
15
|
-
registerGlobTool(
|
|
16
|
-
registerGrepTool(pi);
|
|
15
|
+
export function registerSearchTools(bus: ToolBus, pi: ExtensionAPI): void {
|
|
16
|
+
registerGlobTool(bus);
|
|
17
|
+
registerGrepTool(bus, pi);
|
|
17
18
|
}
|
|
18
19
|
|
|
19
20
|
// Re-exported for tests that import pure functions from "./search.js"; the
|
|
@@ -3,6 +3,7 @@ import type { ExtensionAPI, ExtensionContext } from "@earendil-works/pi-coding-a
|
|
|
3
3
|
import { type Static, Type } from "typebox";
|
|
4
4
|
import { Value } from "typebox/value";
|
|
5
5
|
|
|
6
|
+
import type { ToolBus } from "../lib/tool-bus.js";
|
|
6
7
|
import { selectMultiple, selectWithOptionalInput } from "../lib/ui.js";
|
|
7
8
|
|
|
8
9
|
const TODO_STATUSES = ["pending", "in_progress", "completed"] as const;
|
|
@@ -121,7 +122,7 @@ async function askMultiple(
|
|
|
121
122
|
return selected.length > 0 ? selected.join(", ") : "Unanswered";
|
|
122
123
|
}
|
|
123
124
|
|
|
124
|
-
export function registerSessionTools(pi: ExtensionAPI): void {
|
|
125
|
+
export function registerSessionTools(bus: ToolBus, pi: ExtensionAPI): void {
|
|
125
126
|
// TodoWrite 的列表随工具结果 details 持久化(跟随会话分支),但 widget 是
|
|
126
127
|
// 纯 TUI 状态,进程重启后丢失。session 恢复时从当前分支取最后一个 TodoWrite
|
|
127
128
|
// 的列表重新渲染(完整列表替换语义,后出现的覆盖前面的)。
|
|
@@ -139,7 +140,7 @@ export function registerSessionTools(pi: ExtensionAPI): void {
|
|
|
139
140
|
}
|
|
140
141
|
});
|
|
141
142
|
|
|
142
|
-
|
|
143
|
+
bus.register({
|
|
143
144
|
name: "TodoWrite",
|
|
144
145
|
label: "Todo Write",
|
|
145
146
|
description: [
|
|
@@ -177,7 +178,7 @@ export function registerSessionTools(pi: ExtensionAPI): void {
|
|
|
177
178
|
},
|
|
178
179
|
});
|
|
179
180
|
|
|
180
|
-
|
|
181
|
+
bus.register({
|
|
181
182
|
name: "AskUserQuestion",
|
|
182
183
|
label: "Ask User Question",
|
|
183
184
|
description: [
|
package/src/claude-code/shell.ts
CHANGED
|
@@ -13,12 +13,11 @@ import { Type } from "typebox";
|
|
|
13
13
|
import {
|
|
14
14
|
BashInterruptedError,
|
|
15
15
|
type BwrapRuntime,
|
|
16
|
-
createBwrapRuntime,
|
|
17
16
|
formatElapsedSeconds,
|
|
18
17
|
sandboxHintBlock,
|
|
19
18
|
} from "../bwrap/runtime.js";
|
|
20
19
|
import { resolveWorkdir } from "../lib/path.js";
|
|
21
|
-
import {
|
|
20
|
+
import type { ToolBus } from "../lib/tool-bus.js";
|
|
22
21
|
|
|
23
22
|
const DEFAULT_TIMEOUT_MS = 120_000;
|
|
24
23
|
const MAX_TIMEOUT_MS = 7_200_000;
|
|
@@ -88,12 +87,8 @@ function formatBashSuccess(result: Awaited<ReturnType<BwrapRuntime["execute"]>>)
|
|
|
88
87
|
* runtime 由调用方注入:扩展工厂持有一个实例(不依赖模块级全局状态),
|
|
89
88
|
* 测试可注入预置模式的实例。状态随扩展实例生命周期,session 切换重建即重置。
|
|
90
89
|
*/
|
|
91
|
-
export function registerShellTools(
|
|
92
|
-
|
|
93
|
-
runtime: BwrapRuntime = createBwrapRuntime(createRequestPolicy(pi.events)),
|
|
94
|
-
): void {
|
|
95
|
-
runtime.setup(pi);
|
|
96
|
-
pi.registerTool({
|
|
90
|
+
export function registerShellTools(bus: ToolBus, pi: ExtensionAPI, runtime: BwrapRuntime): void {
|
|
91
|
+
bus.register({
|
|
97
92
|
name: "Bash",
|
|
98
93
|
promptSnippet: "execute command",
|
|
99
94
|
promptGuidelines: [BASH_PROMPT],
|
package/src/gh/index.ts
CHANGED
|
@@ -36,6 +36,8 @@
|
|
|
36
36
|
|
|
37
37
|
import type { ExtensionAPI } from "@earendil-works/pi-coding-agent";
|
|
38
38
|
|
|
39
|
+
import type { ToolBus } from "../lib/tool-bus.js";
|
|
40
|
+
import { registerToolsOnSessionStart } from "../lib/tool-registration.js";
|
|
39
41
|
import { GhClient, isGhAvailable } from "./base.js";
|
|
40
42
|
import { addDownloadReleaseAssetsTool } from "./tools/download-release-assets.js";
|
|
41
43
|
import { addGetWorkflowJobsTool } from "./tools/get-workflow-jobs.js";
|
|
@@ -62,20 +64,58 @@ export * from "./tools/download-release-assets.js";
|
|
|
62
64
|
export * from "./tools/read-ci-logs.js";
|
|
63
65
|
export * from "./tools/read-pr-status.js";
|
|
64
66
|
|
|
65
|
-
|
|
67
|
+
/** 本工具集的工具:入口从它取注册函数(gh 不可用时返回 undefined)。 */
|
|
68
|
+
export function createGithubTools(): { register(bus: ToolBus): void } | undefined {
|
|
66
69
|
// Windows 上禁用:gh 可执行文件的探测(无扩展名 + POSIX 路径)与进程
|
|
67
70
|
// 管理(SIGTERM 信号语义)都是 POSIX 假设,不做 Windows 适配。
|
|
68
71
|
if (process.platform === "win32") {
|
|
69
|
-
|
|
70
|
-
ctx.ui.notify("gh-readonly tools are disabled on Windows.", "warning");
|
|
71
|
-
});
|
|
72
|
-
return;
|
|
72
|
+
return undefined;
|
|
73
73
|
}
|
|
74
74
|
|
|
75
75
|
// Fail fast: the `gh` CLI is the only backend for these tools. Without it the
|
|
76
76
|
// extension registers nothing and reports the problem at session start, so
|
|
77
77
|
// the user gets one clear error instead of a dozen failing tool calls.
|
|
78
78
|
if (!isGhAvailable()) {
|
|
79
|
+
return undefined;
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
const gh = new GhClient();
|
|
83
|
+
return {
|
|
84
|
+
register(bus) {
|
|
85
|
+
addReadIssueTool(gh, bus);
|
|
86
|
+
addListIssuesTool(gh, bus);
|
|
87
|
+
addReadIssueCommentsTool(gh, bus);
|
|
88
|
+
addReadPrTool(gh, bus);
|
|
89
|
+
addListPrsTool(gh, bus);
|
|
90
|
+
addReadPrDiffTool(gh, bus);
|
|
91
|
+
addReadPrStatusTool(gh, bus);
|
|
92
|
+
addReadPrCommentsTool(gh, bus);
|
|
93
|
+
addReadCiLogsTool(gh, bus);
|
|
94
|
+
addListWorkflowRunsTool(gh, bus);
|
|
95
|
+
addGetWorkflowJobsTool(gh, bus);
|
|
96
|
+
addReadRepoTool(gh, bus);
|
|
97
|
+
addListReleasesTool(gh, bus);
|
|
98
|
+
addReadReleaseTool(gh, bus);
|
|
99
|
+
addDownloadReleaseAssetsTool(gh, bus);
|
|
100
|
+
addWaitPrChecksTool(gh, bus);
|
|
101
|
+
addWaitCommitChecksTool(gh, bus);
|
|
102
|
+
addWatchRunTool(gh, bus);
|
|
103
|
+
},
|
|
104
|
+
};
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
export default function ghReadonlyTools(pi: ExtensionAPI): void {
|
|
108
|
+
// Windows 上禁用:gh 可执行文件的探测与进程管理都是 POSIX 假设。
|
|
109
|
+
if (process.platform === "win32") {
|
|
110
|
+
pi.on("session_start", (_event, ctx) => {
|
|
111
|
+
ctx.ui.notify("gh-readonly tools are disabled on Windows.", "warning");
|
|
112
|
+
});
|
|
113
|
+
return;
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
// gh 不可用时一个工具都不注册,只在会话启动时报告一次问题。
|
|
117
|
+
const tools = createGithubTools();
|
|
118
|
+
if (!tools) {
|
|
79
119
|
pi.on("session_start", (_event, ctx) => {
|
|
80
120
|
ctx.ui.notify(
|
|
81
121
|
"gh CLI not found in PATH: GitHub read-only tools are disabled. Install GitHub CLI (https://cli.github.com/) and reload the session.",
|
|
@@ -85,24 +125,7 @@ export default function ghReadonlyTools(pi: ExtensionAPI) {
|
|
|
85
125
|
return;
|
|
86
126
|
}
|
|
87
127
|
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
addListIssuesTool(gh, pi);
|
|
92
|
-
addReadIssueCommentsTool(gh, pi);
|
|
93
|
-
addReadPrTool(gh, pi);
|
|
94
|
-
addListPrsTool(gh, pi);
|
|
95
|
-
addReadPrDiffTool(gh, pi);
|
|
96
|
-
addReadPrStatusTool(gh, pi);
|
|
97
|
-
addReadPrCommentsTool(gh, pi);
|
|
98
|
-
addReadCiLogsTool(gh, pi);
|
|
99
|
-
addListWorkflowRunsTool(gh, pi);
|
|
100
|
-
addGetWorkflowJobsTool(gh, pi);
|
|
101
|
-
addReadRepoTool(gh, pi);
|
|
102
|
-
addListReleasesTool(gh, pi);
|
|
103
|
-
addReadReleaseTool(gh, pi);
|
|
104
|
-
addDownloadReleaseAssetsTool(gh, pi);
|
|
105
|
-
addWaitPrChecksTool(gh, pi);
|
|
106
|
-
addWaitCommitChecksTool(gh, pi);
|
|
107
|
-
addWatchRunTool(gh, pi);
|
|
128
|
+
registerToolsOnSessionStart(pi, (bus) => {
|
|
129
|
+
tools.register(bus);
|
|
130
|
+
});
|
|
108
131
|
}
|
|
@@ -2,11 +2,11 @@ import { mkdir, readdir, stat } from "node:fs/promises";
|
|
|
2
2
|
import { homedir } from "node:os";
|
|
3
3
|
import { join } from "node:path";
|
|
4
4
|
|
|
5
|
-
import type { ExtensionAPI } from "@earendil-works/pi-coding-agent";
|
|
6
5
|
import { Type } from "typebox";
|
|
7
6
|
import { Value } from "typebox/value";
|
|
8
7
|
|
|
9
8
|
import { type ToolPendant } from "../../lib/pendant.js";
|
|
9
|
+
import type { ToolBus } from "../../lib/tool-bus.js";
|
|
10
10
|
import {
|
|
11
11
|
type GhClient,
|
|
12
12
|
GhError,
|
|
@@ -203,8 +203,8 @@ export async function downloadReleaseAssets(
|
|
|
203
203
|
};
|
|
204
204
|
}
|
|
205
205
|
|
|
206
|
-
export function addDownloadReleaseAssetsTool(_gh: GhClient,
|
|
207
|
-
|
|
206
|
+
export function addDownloadReleaseAssetsTool(_gh: GhClient, bus: ToolBus) {
|
|
207
|
+
bus.register({
|
|
208
208
|
name: "download-github-release-assets",
|
|
209
209
|
label: "GitHub Release Download",
|
|
210
210
|
description:
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import type { ExtensionAPI } from "@earendil-works/pi-coding-agent";
|
|
2
1
|
import { Type } from "typebox";
|
|
3
2
|
|
|
3
|
+
import type { ToolBus } from "../../lib/tool-bus.js";
|
|
4
4
|
import {
|
|
5
5
|
type GhClient,
|
|
6
6
|
resolveRepo,
|
|
@@ -30,8 +30,8 @@ async function workflowJobs(gh: GhClient, call: ToolCall<RunIdParams>): Promise<
|
|
|
30
30
|
return result;
|
|
31
31
|
}
|
|
32
32
|
|
|
33
|
-
export function addGetWorkflowJobsTool(gh: GhClient,
|
|
34
|
-
|
|
33
|
+
export function addGetWorkflowJobsTool(gh: GhClient, bus: ToolBus) {
|
|
34
|
+
bus.register({
|
|
35
35
|
name: "get-github-workflow-jobs",
|
|
36
36
|
label: "GitHub Workflow Jobs",
|
|
37
37
|
description:
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import type { ExtensionAPI } from "@earendil-works/pi-coding-agent";
|
|
2
1
|
import { Type } from "typebox";
|
|
3
2
|
|
|
3
|
+
import type { ToolBus } from "../../lib/tool-bus.js";
|
|
4
4
|
import {
|
|
5
5
|
type GhClient,
|
|
6
6
|
type ListFilters,
|
|
@@ -24,8 +24,8 @@ async function listIssues(gh: GhClient, call: ToolCall<ListFilters>): Promise<To
|
|
|
24
24
|
return result;
|
|
25
25
|
}
|
|
26
26
|
|
|
27
|
-
export function addListIssuesTool(gh: GhClient,
|
|
28
|
-
|
|
27
|
+
export function addListIssuesTool(gh: GhClient, bus: ToolBus) {
|
|
28
|
+
bus.register({
|
|
29
29
|
name: "list-github-issues",
|
|
30
30
|
label: "GitHub Issues List",
|
|
31
31
|
description:
|
package/src/gh/tools/list-prs.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import type { ExtensionAPI } from "@earendil-works/pi-coding-agent";
|
|
2
1
|
import { Type } from "typebox";
|
|
3
2
|
|
|
3
|
+
import type { ToolBus } from "../../lib/tool-bus.js";
|
|
4
4
|
import {
|
|
5
5
|
type GhClient,
|
|
6
6
|
type ListFilters,
|
|
@@ -24,8 +24,8 @@ async function listPrs(gh: GhClient, call: ToolCall<ListFilters>): Promise<ToolR
|
|
|
24
24
|
return result;
|
|
25
25
|
}
|
|
26
26
|
|
|
27
|
-
export function addListPrsTool(gh: GhClient,
|
|
28
|
-
|
|
27
|
+
export function addListPrsTool(gh: GhClient, bus: ToolBus) {
|
|
28
|
+
bus.register({
|
|
29
29
|
name: "list-github-prs",
|
|
30
30
|
label: "GitHub PRs List",
|
|
31
31
|
description:
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import type { ExtensionAPI } from "@earendil-works/pi-coding-agent";
|
|
2
1
|
import { Type } from "typebox";
|
|
3
2
|
|
|
3
|
+
import type { ToolBus } from "../../lib/tool-bus.js";
|
|
4
4
|
import { type GhClient, ghExec, repoArgs, subtitlePendant, toToolResult } from "../base.js";
|
|
5
5
|
|
|
6
|
-
export function addListReleasesTool(_gh: GhClient,
|
|
7
|
-
|
|
6
|
+
export function addListReleasesTool(_gh: GhClient, bus: ToolBus) {
|
|
7
|
+
bus.register({
|
|
8
8
|
name: "list-github-releases",
|
|
9
9
|
label: "GitHub Releases List",
|
|
10
10
|
description: "List GitHub releases.",
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import type { ExtensionAPI } from "@earendil-works/pi-coding-agent";
|
|
2
1
|
import { Type } from "typebox";
|
|
3
2
|
|
|
3
|
+
import type { ToolBus } from "../../lib/tool-bus.js";
|
|
4
4
|
import { type GhClient, ghExec, repoArgs, subtitlePendant, toToolResult } from "../base.js";
|
|
5
5
|
|
|
6
|
-
export function addListWorkflowRunsTool(_gh: GhClient,
|
|
7
|
-
|
|
6
|
+
export function addListWorkflowRunsTool(_gh: GhClient, bus: ToolBus) {
|
|
7
|
+
bus.register({
|
|
8
8
|
name: "list-github-workflow-runs",
|
|
9
9
|
label: "GitHub Workflow Runs",
|
|
10
10
|
description: "List GitHub Actions workflow runs.",
|
|
@@ -3,16 +3,15 @@
|
|
|
3
3
|
* each executed step's block inside it, so the model can read the exact line
|
|
4
4
|
* range of the step it needs.
|
|
5
5
|
*/
|
|
6
|
-
|
|
7
6
|
import { mkdir, readFile, writeFile } from "node:fs/promises";
|
|
8
7
|
import { homedir } from "node:os";
|
|
9
8
|
import { dirname, join } from "node:path";
|
|
10
9
|
|
|
11
|
-
import type { ExtensionAPI } from "@earendil-works/pi-coding-agent";
|
|
12
10
|
import { Type } from "typebox";
|
|
13
11
|
|
|
14
12
|
import type { RunJob } from "../../lib/github.js";
|
|
15
13
|
import { createSeqState } from "../../lib/seq-state.js";
|
|
14
|
+
import type { ToolBus } from "../../lib/tool-bus.js";
|
|
16
15
|
import {
|
|
17
16
|
type GhClient,
|
|
18
17
|
ghExec,
|
|
@@ -422,8 +421,8 @@ async function ciLogs(gh: GhClient, call: ToolCall<JobIdParams>): Promise<ToolRe
|
|
|
422
421
|
};
|
|
423
422
|
}
|
|
424
423
|
|
|
425
|
-
export function addReadCiLogsTool(gh: GhClient,
|
|
426
|
-
|
|
424
|
+
export function addReadCiLogsTool(gh: GhClient, bus: ToolBus) {
|
|
425
|
+
bus.register({
|
|
427
426
|
name: "read-github-ci-logs",
|
|
428
427
|
label: "GitHub CI Logs",
|
|
429
428
|
description:
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import type { ExtensionAPI } from "@earendil-works/pi-coding-agent";
|
|
2
1
|
import { Type } from "typebox";
|
|
3
2
|
|
|
3
|
+
import type { ToolBus } from "../../lib/tool-bus.js";
|
|
4
4
|
import { type GhClient, ghExec, repoArgs, subtitlePendant, toToolResultJson } from "../base.js";
|
|
5
5
|
|
|
6
|
-
export function addReadIssueCommentsTool(_gh: GhClient,
|
|
7
|
-
|
|
6
|
+
export function addReadIssueCommentsTool(_gh: GhClient, bus: ToolBus) {
|
|
7
|
+
bus.register({
|
|
8
8
|
name: "read-github-issue-comments",
|
|
9
9
|
label: "GitHub Issue Comments",
|
|
10
10
|
description: "Get comments on a GitHub issue.",
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import type { ExtensionAPI } from "@earendil-works/pi-coding-agent";
|
|
2
1
|
import { Type } from "typebox";
|
|
3
2
|
|
|
3
|
+
import type { ToolBus } from "../../lib/tool-bus.js";
|
|
4
4
|
import { type GhClient, ghExec, repoArgs, subtitlePendant, toToolResultJson } from "../base.js";
|
|
5
5
|
|
|
6
|
-
export function addReadIssueTool(_gh: GhClient,
|
|
7
|
-
|
|
6
|
+
export function addReadIssueTool(_gh: GhClient, bus: ToolBus) {
|
|
7
|
+
bus.register({
|
|
8
8
|
name: "read-github-issue",
|
|
9
9
|
label: "GitHub Issue",
|
|
10
10
|
description: "Get details of a GitHub issue by number.",
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import type { ExtensionAPI } from "@earendil-works/pi-coding-agent";
|
|
2
1
|
import { Type } from "typebox";
|
|
3
2
|
|
|
3
|
+
import type { ToolBus } from "../../lib/tool-bus.js";
|
|
4
4
|
import {
|
|
5
5
|
ghApiList,
|
|
6
6
|
type GhClient,
|
|
@@ -11,8 +11,8 @@ import {
|
|
|
11
11
|
toToolResultJson,
|
|
12
12
|
} from "../base.js";
|
|
13
13
|
|
|
14
|
-
export function addReadPrCommentsTool(_gh: GhClient,
|
|
15
|
-
|
|
14
|
+
export function addReadPrCommentsTool(_gh: GhClient, bus: ToolBus) {
|
|
15
|
+
bus.register({
|
|
16
16
|
name: "read-github-pr-comments",
|
|
17
17
|
label: "GitHub PR Comments",
|
|
18
18
|
description:
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import type { ExtensionAPI } from "@earendil-works/pi-coding-agent";
|
|
2
1
|
import { Type } from "typebox";
|
|
3
2
|
|
|
3
|
+
import type { ToolBus } from "../../lib/tool-bus.js";
|
|
4
4
|
import { type GhClient, ghExec, repoArgs, subtitlePendant, toToolResult } from "../base.js";
|
|
5
5
|
|
|
6
|
-
export function addReadPrDiffTool(_gh: GhClient,
|
|
7
|
-
|
|
6
|
+
export function addReadPrDiffTool(_gh: GhClient, bus: ToolBus) {
|
|
7
|
+
bus.register({
|
|
8
8
|
name: "read-github-pr-diff",
|
|
9
9
|
label: "GitHub PR Diff",
|
|
10
10
|
description: "Get the diff of a GitHub pull request.",
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import type { ExtensionAPI } from "@earendil-works/pi-coding-agent";
|
|
2
1
|
import { Type } from "typebox";
|
|
3
2
|
|
|
3
|
+
import type { ToolBus } from "../../lib/tool-bus.js";
|
|
4
4
|
import {
|
|
5
5
|
type GhClient,
|
|
6
6
|
mergeChecks,
|
|
@@ -52,8 +52,8 @@ export async function prStatus(gh: GhClient, call: ToolCall<PrStatusParams>): Pr
|
|
|
52
52
|
};
|
|
53
53
|
}
|
|
54
54
|
|
|
55
|
-
export function addReadPrStatusTool(gh: GhClient,
|
|
56
|
-
|
|
55
|
+
export function addReadPrStatusTool(gh: GhClient, bus: ToolBus) {
|
|
56
|
+
bus.register({
|
|
57
57
|
name: "read-github-pr-status",
|
|
58
58
|
label: "GitHub PR Status",
|
|
59
59
|
description:
|
package/src/gh/tools/read-pr.ts
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import type { ExtensionAPI } from "@earendil-works/pi-coding-agent";
|
|
2
1
|
import { Type } from "typebox";
|
|
3
2
|
|
|
3
|
+
import type { ToolBus } from "../../lib/tool-bus.js";
|
|
4
4
|
import { type GhClient, ghExec, repoArgs, subtitlePendant, toToolResultJson } from "../base.js";
|
|
5
5
|
|
|
6
|
-
export function addReadPrTool(_gh: GhClient,
|
|
7
|
-
|
|
6
|
+
export function addReadPrTool(_gh: GhClient, bus: ToolBus) {
|
|
7
|
+
bus.register({
|
|
8
8
|
name: "read-github-pr",
|
|
9
9
|
label: "GitHub PR",
|
|
10
10
|
description: "Get details of a GitHub pull request by number.",
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import type { ExtensionAPI } from "@earendil-works/pi-coding-agent";
|
|
2
1
|
import { Type } from "typebox";
|
|
3
2
|
|
|
3
|
+
import type { ToolBus } from "../../lib/tool-bus.js";
|
|
4
4
|
import { type GhClient, ghExec, repoArgs, subtitlePendant, toToolResult } from "../base.js";
|
|
5
5
|
|
|
6
|
-
export function addReadReleaseTool(_gh: GhClient,
|
|
7
|
-
|
|
6
|
+
export function addReadReleaseTool(_gh: GhClient, bus: ToolBus) {
|
|
7
|
+
bus.register({
|
|
8
8
|
name: "read-github-release",
|
|
9
9
|
label: "GitHub Release",
|
|
10
10
|
description: "Get details of a specific GitHub release by tag.",
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import type { ExtensionAPI } from "@earendil-works/pi-coding-agent";
|
|
2
1
|
import { Type } from "typebox";
|
|
3
2
|
|
|
3
|
+
import type { ToolBus } from "../../lib/tool-bus.js";
|
|
4
4
|
import { type GhClient, ghExec, subtitlePendant, toToolResult } from "../base.js";
|
|
5
5
|
|
|
6
|
-
export function addReadRepoTool(_gh: GhClient,
|
|
7
|
-
|
|
6
|
+
export function addReadRepoTool(_gh: GhClient, bus: ToolBus) {
|
|
7
|
+
bus.register({
|
|
8
8
|
name: "read-github-repo",
|
|
9
9
|
label: "GitHub Repo",
|
|
10
10
|
description: "Get repository information.",
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import type { ExtensionAPI } from "@earendil-works/pi-coding-agent";
|
|
2
1
|
import { Type } from "typebox";
|
|
3
2
|
|
|
3
|
+
import type { ToolBus } from "../../lib/tool-bus.js";
|
|
4
4
|
import {
|
|
5
5
|
type GhClient,
|
|
6
6
|
resolveRepo,
|
|
@@ -53,8 +53,8 @@ async function waitCommitChecks(
|
|
|
53
53
|
});
|
|
54
54
|
}
|
|
55
55
|
|
|
56
|
-
export function addWaitCommitChecksTool(gh: GhClient,
|
|
57
|
-
|
|
56
|
+
export function addWaitCommitChecksTool(gh: GhClient, bus: ToolBus) {
|
|
57
|
+
bus.register({
|
|
58
58
|
name: "wait-github-commit-checks",
|
|
59
59
|
label: "Watch GitHub Commit Checks",
|
|
60
60
|
description:
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import type { ExtensionAPI } from "@earendil-works/pi-coding-agent";
|
|
2
1
|
import { Type } from "typebox";
|
|
3
2
|
import { Value } from "typebox/value";
|
|
4
3
|
|
|
4
|
+
import type { ToolBus } from "../../lib/tool-bus.js";
|
|
5
5
|
import {
|
|
6
6
|
type GhClient,
|
|
7
7
|
ghExec,
|
|
@@ -55,8 +55,8 @@ async function waitPrChecks(gh: GhClient, call: ToolCall<PrChecksWaitParams>): P
|
|
|
55
55
|
});
|
|
56
56
|
}
|
|
57
57
|
|
|
58
|
-
export function addWaitPrChecksTool(gh: GhClient,
|
|
59
|
-
|
|
58
|
+
export function addWaitPrChecksTool(gh: GhClient, bus: ToolBus) {
|
|
59
|
+
bus.register({
|
|
60
60
|
name: "wait-github-pr-checks",
|
|
61
61
|
label: "Watch GitHub PR Checks",
|
|
62
62
|
description:
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import type { ExtensionAPI } from "@earendil-works/pi-coding-agent";
|
|
2
1
|
import { Type } from "typebox";
|
|
3
2
|
|
|
4
3
|
import { runGh } from "../../lib/gh-process.js";
|
|
4
|
+
import type { ToolBus } from "../../lib/tool-bus.js";
|
|
5
5
|
import { type GhClient, repoArgs, subtitlePendant } from "../base.js";
|
|
6
6
|
|
|
7
|
-
export function addWatchRunTool(_gh: GhClient,
|
|
8
|
-
|
|
7
|
+
export function addWatchRunTool(_gh: GhClient, bus: ToolBus) {
|
|
8
|
+
bus.register({
|
|
9
9
|
name: "watch-github-run",
|
|
10
10
|
label: "Watch GitHub Workflow Run",
|
|
11
11
|
description:
|