@zhin.js/adapter-github 3.0.1 → 3.0.2

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 (102) hide show
  1. package/README.md +23 -12
  2. package/{skills/github/SKILL.md → agent/skills/github.md} +22 -5
  3. package/agent/tools/bind.ts +12 -0
  4. package/agent/tools/create_pr.ts +19 -0
  5. package/agent/tools/install.ts +12 -0
  6. package/agent/tools/patch_file.ts +18 -0
  7. package/agent/tools/prepare_workspace.ts +14 -0
  8. package/agent/tools/push_branch.ts +17 -0
  9. package/agent/tools/star.ts +15 -0
  10. package/agent/tools/subscribe.ts +16 -0
  11. package/agent/tools/subscriptions.ts +13 -0
  12. package/agent/tools/unbind.ts +12 -0
  13. package/agent/tools/unsubscribe.ts +15 -0
  14. package/agent/tools/whoami.ts +12 -0
  15. package/lib/agent/tools/bind.js +12 -0
  16. package/lib/agent/tools/bind.js.map +1 -0
  17. package/lib/agent/tools/create_pr.js +19 -0
  18. package/lib/agent/tools/create_pr.js.map +1 -0
  19. package/lib/agent/tools/install.js +12 -0
  20. package/lib/agent/tools/install.js.map +1 -0
  21. package/lib/agent/tools/patch_file.js +18 -0
  22. package/lib/agent/tools/patch_file.js.map +1 -0
  23. package/lib/agent/tools/prepare_workspace.js +14 -0
  24. package/lib/agent/tools/prepare_workspace.js.map +1 -0
  25. package/lib/agent/tools/push_branch.js +17 -0
  26. package/lib/agent/tools/push_branch.js.map +1 -0
  27. package/lib/agent/tools/star.js +15 -0
  28. package/lib/agent/tools/star.js.map +1 -0
  29. package/lib/agent/tools/subscribe.js +16 -0
  30. package/lib/agent/tools/subscribe.js.map +1 -0
  31. package/lib/agent/tools/subscriptions.js +13 -0
  32. package/lib/agent/tools/subscriptions.js.map +1 -0
  33. package/lib/agent/tools/unbind.js +12 -0
  34. package/lib/agent/tools/unbind.js.map +1 -0
  35. package/lib/agent/tools/unsubscribe.js +15 -0
  36. package/lib/agent/tools/unsubscribe.js.map +1 -0
  37. package/lib/agent/tools/whoami.js +12 -0
  38. package/lib/agent/tools/whoami.js.map +1 -0
  39. package/lib/{adapter.js → src/adapter.js} +11 -6
  40. package/lib/src/adapter.js.map +1 -0
  41. package/lib/{agent-prompt.js → src/agent-prompt.js} +10 -8
  42. package/lib/src/agent-prompt.js.map +1 -0
  43. package/lib/{endpoint.js → src/endpoint.js} +27 -3
  44. package/lib/src/endpoint.js.map +1 -0
  45. package/lib/{gh-client.js → src/gh-client.js} +99 -0
  46. package/lib/src/gh-client.js.map +1 -0
  47. package/lib/src/github-agent-deps.js +13 -0
  48. package/lib/src/github-agent-deps.js.map +1 -0
  49. package/lib/src/github-bot-handlers.js +78 -0
  50. package/lib/src/github-bot-handlers.js.map +1 -0
  51. package/lib/src/github-channel-context.js +32 -0
  52. package/lib/src/github-channel-context.js.map +1 -0
  53. package/lib/src/github-tool-handlers.js +215 -0
  54. package/lib/src/github-tool-handlers.js.map +1 -0
  55. package/lib/src/index.js +104 -0
  56. package/lib/src/index.js.map +1 -0
  57. package/lib/{register-github-mcp.js → src/register-github-mcp.js} +5 -0
  58. package/lib/src/register-github-mcp.js.map +1 -0
  59. package/lib/src/segment-mapper.js.map +1 -0
  60. package/lib/src/types.js.map +1 -0
  61. package/lib/src/workspace-manager.js +109 -0
  62. package/lib/src/workspace-manager.js.map +1 -0
  63. package/package.json +16 -6
  64. package/src/adapter.ts +12 -8
  65. package/src/agent-prompt.ts +11 -10
  66. package/src/endpoint.ts +38 -10
  67. package/src/gh-client.ts +131 -0
  68. package/src/github-agent-deps.ts +27 -0
  69. package/src/github-bot-handlers.ts +109 -0
  70. package/src/github-channel-context.ts +46 -0
  71. package/src/github-tool-handlers.ts +244 -0
  72. package/src/index.ts +32 -326
  73. package/src/register-github-mcp.ts +5 -0
  74. package/src/types.ts +6 -0
  75. package/src/workspace-manager.ts +114 -0
  76. package/lib/adapter.d.ts +0 -66
  77. package/lib/adapter.d.ts.map +0 -1
  78. package/lib/adapter.js.map +0 -1
  79. package/lib/agent-prompt.d.ts +0 -3
  80. package/lib/agent-prompt.d.ts.map +0 -1
  81. package/lib/agent-prompt.js.map +0 -1
  82. package/lib/endpoint.d.ts +0 -26
  83. package/lib/endpoint.d.ts.map +0 -1
  84. package/lib/endpoint.js.map +0 -1
  85. package/lib/gh-client.d.ts +0 -228
  86. package/lib/gh-client.d.ts.map +0 -1
  87. package/lib/gh-client.js.map +0 -1
  88. package/lib/index.d.ts +0 -34
  89. package/lib/index.d.ts.map +0 -1
  90. package/lib/index.js +0 -388
  91. package/lib/index.js.map +0 -1
  92. package/lib/register-github-mcp.d.ts +0 -7
  93. package/lib/register-github-mcp.d.ts.map +0 -1
  94. package/lib/register-github-mcp.js.map +0 -1
  95. package/lib/segment-mapper.d.ts +0 -2
  96. package/lib/segment-mapper.d.ts.map +0 -1
  97. package/lib/segment-mapper.js.map +0 -1
  98. package/lib/types.d.ts +0 -144
  99. package/lib/types.d.ts.map +0 -1
  100. package/lib/types.js.map +0 -1
  101. /package/lib/{segment-mapper.js → src/segment-mapper.js} +0 -0
  102. /package/lib/{types.js → src/types.js} +0 -0
package/README.md CHANGED
@@ -12,7 +12,7 @@
12
12
  - ✅ **事件通知**:Webhook 订阅,跨平台推送到任意聊天
13
13
  - ✅ **GitHub App 认证**:JWT → Installation Token,自动刷新
14
14
  - ✅ **OAuth 用户绑定**:用户可绑定自己的 GitHub 账号,star/fork 以个人身份执行
15
- - ✅ **AI Skill**:所有工具自动暴露给 AI 调用
15
+ - ✅ **Bot 开发工作流**:托管 git 工作区 + App 身份 push/开 PR(HITL 确认)
16
16
  - ✅ **无 router 也能运行**:核心功能不依赖 HTTP 服务,有 router 时自动注册 Webhook 和 OAuth 路由
17
17
 
18
18
  ## 安装
@@ -37,7 +37,7 @@ pnpm add @zhin.js/adapter-github
37
37
  4. 权限设置(Permissions):
38
38
  - **Repository → Issues**: Read & Write
39
39
  - **Repository → Pull requests**: Read & Write
40
- - **Repository → Contents**: Read
40
+ - **Repository → Contents**: Read & Write(Bot 提交代码)
41
41
  - **Repository → Metadata**: Read
42
42
  - **Repository → Actions**: Read(查看 CI)
43
43
  5. 订阅事件(Subscribe to events):
@@ -56,7 +56,10 @@ endpoints:
56
56
  app_id: 123456
57
57
  private_key: ./data/github-app.pem # PEM 文件路径或直接粘贴内容
58
58
  webhook_secret: your-secret # 可选;配置后启用 Webhook
59
- webhook_path: /pub/github/webhook # 可选;默认 /github/webhook,/pub/* 可绕过 Bearer
59
+ webhook_path: /pub/github/webhook # 可选
60
+ auto_reply_repos: # 可选:这些 repo 的评论自动触发 AI
61
+ - zhinjs/zhin
62
+ workspace_root: ./data/github-workspaces # 可选:Bot git 工作区
60
63
 
61
64
  plugins:
62
65
  - database
@@ -67,13 +70,11 @@ plugins:
67
70
  ```env
68
71
  GITHUB_APP_ID=123456
69
72
  GITHUB_WEBHOOK_SECRET=your-secret
70
- # MCP server-github(适配器自动 addMcp,与 App 认证独立)
71
- GITHUB_PERSONAL_ACCESS_TOKEN=ghp_xxxxxxxxxxxx
72
- # 或 ai.githubMcp.token / ai.mcpServers
73
+ # MCP server-github(可选;PAT = 人身份,默认关闭)
74
+ # ai.githubMcp.enabled: true
75
+ # GITHUB_PERSONAL_ACCESS_TOKEN=ghp_xxxxxxxxxxxx
73
76
  ```
74
77
 
75
- 或在 `zhin.config.yml` 中设置 `ai.githubMcp.token`(优先于环境变量)。
76
-
77
78
  `private_key` 支持两种写法:
78
79
  - 文件路径:`./data/github-app.pem`
79
80
  - 直接内容:`"-----BEGIN RSA PRIVATE KEY-----\n..."`
@@ -97,12 +98,21 @@ GitHub adapter 将 Issue/PR 映射为聊天频道:
97
98
  | `github_bind` / `github_unbind` / `github_whoami` | 用户 GitHub 账号绑定 |
98
99
  | `github_install` | GitHub App 安装链接 |
99
100
  | `github_subscribe` / `github_unsubscribe` / `github_subscriptions` | 频道级 Webhook 订阅 |
101
+ | `github_prepare_workspace` | Clone/fetch 托管工作区并 checkout 分支 |
102
+ | `github_patch_file` | Contents API 单文件更新(Bot 身份) |
103
+ | `github_push_branch` | git commit + push(**需 HITL**) |
104
+ | `github_create_pr` | 创建 PR(**需 HITL**) |
105
+
106
+ ### Bot 工作流(App 身份)
100
107
 
101
- ### MCP(`@modelcontextprotocol/server-github`)
108
+ - 评论回复:Webhook → `$reply`,Installation Token,UI 显示 `{slug}[bot]` + **Bot** 徽章
109
+ - 开发提交:`github_prepare_workspace` → bash 改代码 → `github_push_branch`(确认)→ Issue 场景 `github_create_pr`
110
+ - PR 线程:push 到现有 PR head 分支,不新开 PR
111
+ - 工作区默认:`data/github-workspaces/{owner}/{repo}`
102
112
 
103
- 配置 `GITHUB_PERSONAL_ACCESS_TOKEN`(或 `ai.githubMcp.token`)后,适配器通过 `orchestrator.addMcp` 注册 `github` server;AI 侧工具名为 `mcp_github_*`(如 `mcp_github_fork_repository`、`mcp_github_create_issue`)。
113
+ ### MCP(`@modelcontextprotocol/server-github`,可选)
104
114
 
105
- **BREAKING**:`github_fork` 已移除,请改用 `mcp_github_fork_repository`。
115
+ 仅当 `ai.githubMcp.enabled: true` 且配置 PAT 时注册。`mcp_github_*` 以**用户 PAT** 操作,**不能**作为 Bot 写仓库。Bot 写操作请用上方 `github_*` 工具。
106
116
 
107
117
  ### 使用示例
108
118
 
@@ -153,7 +163,8 @@ Headers:
153
163
  | 操作类型 | 使用的 Token | 原因 |
154
164
  |---------|------------|------|
155
165
  | 读取 issue/PR/repo 信息 | App JWT | 不涉及用户身份 |
156
- | 评论(bot 发言) | App JWT | 以机器人身份发言 |
166
+ | 评论(bot 发言) | App Installation Token | `{slug}[bot]` 机器人身份发言 |
167
+ | push / 开 PR | App Installation Token + git author | UI **Bot** 徽章(非 Member) |
157
168
  | star / unstar | User OAuth | 个人行为 |
158
169
  | fork | User OAuth | 个人行为 |
159
170
 
@@ -60,6 +60,10 @@ tools:
60
60
  - github_subscribe
61
61
  - github_unsubscribe
62
62
  - github_subscriptions
63
+ - github_prepare_workspace
64
+ - github_patch_file
65
+ - github_push_branch
66
+ - github_create_pr
63
67
  always: false
64
68
  requires:
65
69
  bins:
@@ -72,7 +76,8 @@ requires:
72
76
 
73
77
  本技能提供三种操作方式:
74
78
  - **适配器内置工具**(`github_*`):用户交互类操作,具备账号绑定、Device Flow 授权、频道级订阅等适配器专有逻辑
75
- - **MCP server-github**(`mcp_github_*`):Issue/PR/搜索/Fork GitHub API(需 `GITHUB_PERSONAL_ACCESS_TOKEN` `ai.githubMcp.token`)
79
+ - **Bot 写仓库工具**(`github_prepare_workspace` / `github_patch_file` / `github_push_branch` / `github_create_pr`):Installation Token,UI 显示 **Bot** 身份;push/开 PR 需 HITL
80
+ - **MCP server-github**(`mcp_github_*`,可选):需 `ai.githubMcp.enabled: true` + PAT,**人身份**,勿用于 Bot 写仓库
76
81
  - **bash + gh CLI**:仓库自动化操作,灵活覆盖 GitHub API 全场景
77
82
 
78
83
  ## 一、适配器内置工具
@@ -94,7 +99,18 @@ requires:
94
99
  |------|------|
95
100
  | `github_star` | Star 或取消 Star 一个仓库。优先使用用户绑定的 GitHub 账号,未绑定则降级为 Endpoint 默认账号 |
96
101
 
97
- ### MCP(server-github,单一 PAT)
102
+ ### Bot 开发工作流(App 身份)
103
+
104
+ | 工具 | 说明 |
105
+ |------|------|
106
+ | `github_prepare_workspace` | Clone/fetch 托管工作区并 checkout Issue/PR 对应分支 |
107
+ | `github_patch_file` | Contents API 单文件更新(小改) |
108
+ | `github_push_branch` | git commit + push(**需 HITL**) |
109
+ | `github_create_pr` | 创建 PR(**需 HITL**;Issue 线程常用) |
110
+
111
+ Issue 线程:新分支 → 开发 → push → 开 PR。PR 线程:push 到现有 head 分支。
112
+
113
+ ### MCP(server-github,可选 PAT)
98
114
 
99
115
  | 工具 | 说明 |
100
116
  |------|------|
@@ -112,9 +128,10 @@ requires:
112
128
  ### 内置工具执行规则
113
129
 
114
130
  1. `github_star` 优先使用用户绑定的 GitHub 账号,未绑定则降级为 Endpoint 默认账号
115
- 2. Fork 与通用 API 使用 `mcp_github_*`(Bot PAT,非 per-user OAuth)
116
- 3. 当用户想操作自己的 GitHub 账号进行 Star 时,先引导用户使用 `github_bind` 绑定
117
- 4. Webhook 订阅关联到当前聊天通道,仅在该通道接收事件通知
131
+ 2. Bot 写仓库用 `github_*` 工具,不用 `mcp_github_*` 写操作
132
+ 3. MCP opt-in(`ai.githubMcp.enabled: true`),PAT 为人身份
133
+ 4. 当用户想操作自己的 GitHub 账号进行 Star 时,先引导用户使用 `github_bind` 绑定
134
+ 5. Webhook 订阅关联到当前聊天通道,仅在该通道接收事件通知
118
135
 
119
136
  ---
120
137
 
@@ -0,0 +1,12 @@
1
+ import { defineTool } from '@zhin.js/agent/tools';
2
+ import { z } from 'zod';
3
+ import { executeGithubBind } from '../../src/github-tool-handlers.js';
4
+
5
+ export default defineTool({
6
+ description: '绑定你的 GitHub 账号 — 使用 Device Flow 授权,无需输入密码',
7
+ inputSchema: z.object({}),
8
+ tags: ['github'],
9
+ async execute() {
10
+ return executeGithubBind({});
11
+ },
12
+ });
@@ -0,0 +1,19 @@
1
+ import { defineTool } from '@zhin.js/agent/tools';
2
+ import { z } from 'zod';
3
+ import { executeGithubCreatePr } from '../../src/github-bot-handlers.js';
4
+
5
+ export default defineTool<{ repo?: string; title: string; body?: string; head?: string; base?: string }>({
6
+ description: '以 GitHub App Bot 身份创建 Pull Request(需 HITL 确认;Issue 场景常用)',
7
+ inputSchema: z.object({
8
+ repo: z.string().optional().describe('owner/repo'),
9
+ title: z.string().describe('PR 标题'),
10
+ body: z.string().optional().describe('PR 正文'),
11
+ head: z.string().optional().describe('head 分支,缺省为工作区分支'),
12
+ base: z.string().optional().describe('base 分支,缺省为仓库默认分支'),
13
+ }),
14
+ tags: ['github'],
15
+ approval: 'always',
16
+ async execute(input) {
17
+ return executeGithubCreatePr(input);
18
+ },
19
+ });
@@ -0,0 +1,12 @@
1
+ import { defineTool } from '@zhin.js/agent/tools';
2
+ import { z } from 'zod';
3
+ import { executeGithubInstall } from '../../src/github-tool-handlers.js';
4
+
5
+ export default defineTool({
6
+ description: '获取安装 GitHub App 的链接 — 安装后 Endpoint 可以访问你的仓库,你也可以使用更多功能',
7
+ inputSchema: z.object({}),
8
+ tags: ['github'],
9
+ async execute() {
10
+ return executeGithubInstall();
11
+ },
12
+ });
@@ -0,0 +1,18 @@
1
+ import { defineTool } from '@zhin.js/agent/tools';
2
+ import { z } from 'zod';
3
+ import { executeGithubPatchFile } from '../../src/github-bot-handlers.js';
4
+
5
+ export default defineTool<{ repo?: string; path: string; content: string; message: string; branch?: string }>({
6
+ description: '通过 Contents API 单文件更新(小改;Bot Installation Token 身份)',
7
+ inputSchema: z.object({
8
+ repo: z.string().optional().describe('owner/repo'),
9
+ path: z.string().describe('仓库内文件路径'),
10
+ content: z.string().describe('新文件内容'),
11
+ message: z.string().describe('commit message'),
12
+ branch: z.string().optional().describe('目标分支,缺省从 Issue/PR 上下文推断'),
13
+ }),
14
+ tags: ['github'],
15
+ async execute(input) {
16
+ return executeGithubPatchFile(input);
17
+ },
18
+ });
@@ -0,0 +1,14 @@
1
+ import { defineTool } from '@zhin.js/agent/tools';
2
+ import { z } from 'zod';
3
+ import { executeGithubPrepareWorkspace } from '../../src/github-bot-handlers.js';
4
+
5
+ export default defineTool<{ repo?: string }>({
6
+ description: 'Clone/fetch 托管工作区并 checkout 到 Issue/PR 对应分支(GitHub App Bot 身份)',
7
+ inputSchema: z.object({
8
+ repo: z.string().optional().describe('owner/repo,缺省从当前 Issue/PR 频道推断'),
9
+ }),
10
+ tags: ['github'],
11
+ async execute(input) {
12
+ return executeGithubPrepareWorkspace(input);
13
+ },
14
+ });
@@ -0,0 +1,17 @@
1
+ import { defineTool } from '@zhin.js/agent/tools';
2
+ import { z } from 'zod';
3
+ import { executeGithubPushBranch } from '../../src/github-bot-handlers.js';
4
+
5
+ export default defineTool<{ repo?: string; branch?: string; message: string }>({
6
+ description: '在托管工作区 git commit 并 push 到远程分支(需 HITL 确认;Bot 身份)',
7
+ inputSchema: z.object({
8
+ repo: z.string().optional().describe('owner/repo'),
9
+ branch: z.string().optional().describe('分支名,缺省从上下文推断'),
10
+ message: z.string().describe('commit message'),
11
+ }),
12
+ tags: ['github'],
13
+ approval: 'always',
14
+ async execute(input) {
15
+ return executeGithubPushBranch(input);
16
+ },
17
+ });
@@ -0,0 +1,15 @@
1
+ import { defineTool } from '@zhin.js/agent/tools';
2
+ import { z } from 'zod';
3
+ import { executeGithubStar } from '../../src/github-tool-handlers.js';
4
+
5
+ export default defineTool<{ action: 'star' | 'unstar' | 'check'; repo: string }>({
6
+ description: 'Star 或取消 Star 一个 GitHub 仓库(使用你绑定的 GitHub 账号,未绑定则用 Endpoint 默认账号)',
7
+ inputSchema: z.object({
8
+ action: z.enum(['star', 'unstar', 'check']),
9
+ repo: z.string().min(1),
10
+ }),
11
+ tags: ['github'],
12
+ async execute(input) {
13
+ return executeGithubStar(input);
14
+ },
15
+ });
@@ -0,0 +1,16 @@
1
+ import { defineTool } from '@zhin.js/agent/tools';
2
+ import { z } from 'zod';
3
+ import { executeGithubSubscribe } from '../../src/github-tool-handlers.js';
4
+
5
+ export default defineTool<{ repo: string; events?: string }>({
6
+ description: '订阅 GitHub 仓库的 Webhook 事件,事件将推送到当前聊天通道',
7
+ inputSchema: z.object({
8
+ repo: z.string().min(1),
9
+ events: z.string().optional(),
10
+ }),
11
+ platforms: ['github'],
12
+ tags: ['github'],
13
+ async execute(input) {
14
+ return executeGithubSubscribe(input);
15
+ },
16
+ });
@@ -0,0 +1,13 @@
1
+ import { defineTool } from '@zhin.js/agent/tools';
2
+ import { z } from 'zod';
3
+ import { executeGithubSubscriptions } from '../../src/github-tool-handlers.js';
4
+
5
+ export default defineTool({
6
+ description: '查看当前聊天通道的 GitHub 仓库订阅列表',
7
+ inputSchema: z.object({}),
8
+ platforms: ['github'],
9
+ tags: ['github'],
10
+ async execute() {
11
+ return executeGithubSubscriptions({});
12
+ },
13
+ });
@@ -0,0 +1,12 @@
1
+ import { defineTool } from '@zhin.js/agent/tools';
2
+ import { z } from 'zod';
3
+ import { executeGithubUnbind } from '../../src/github-tool-handlers.js';
4
+
5
+ export default defineTool({
6
+ description: '解除你绑定的 GitHub 账号',
7
+ inputSchema: z.object({}),
8
+ tags: ['github'],
9
+ async execute() {
10
+ return executeGithubUnbind({});
11
+ },
12
+ });
@@ -0,0 +1,15 @@
1
+ import { defineTool } from '@zhin.js/agent/tools';
2
+ import { z } from 'zod';
3
+ import { executeGithubUnsubscribe } from '../../src/github-tool-handlers.js';
4
+
5
+ export default defineTool<{ repo: string }>({
6
+ description: '取消订阅 GitHub 仓库的 Webhook 事件',
7
+ inputSchema: z.object({
8
+ repo: z.string().min(1),
9
+ }),
10
+ platforms: ['github'],
11
+ tags: ['github'],
12
+ async execute(input) {
13
+ return executeGithubUnsubscribe(input);
14
+ },
15
+ });
@@ -0,0 +1,12 @@
1
+ import { defineTool } from '@zhin.js/agent/tools';
2
+ import { z } from 'zod';
3
+ import { executeGithubWhoami } from '../../src/github-tool-handlers.js';
4
+
5
+ export default defineTool({
6
+ description: '查看你绑定的 GitHub 账号信息',
7
+ inputSchema: z.object({}),
8
+ tags: ['github'],
9
+ async execute() {
10
+ return executeGithubWhoami({});
11
+ },
12
+ });
@@ -0,0 +1,12 @@
1
+ import { defineTool } from '@zhin.js/agent/tools';
2
+ import { z } from 'zod';
3
+ import { executeGithubBind } from '../../src/github-tool-handlers.js';
4
+ export default defineTool({
5
+ description: '绑定你的 GitHub 账号 — 使用 Device Flow 授权,无需输入密码',
6
+ inputSchema: z.object({}),
7
+ tags: ['github'],
8
+ async execute() {
9
+ return executeGithubBind({});
10
+ },
11
+ });
12
+ //# sourceMappingURL=bind.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"bind.js","sourceRoot":"","sources":["../../../agent/tools/bind.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAC;AAClD,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAAE,iBAAiB,EAAE,MAAM,mCAAmC,CAAC;AAEtE,eAAe,UAAU,CAAC;IACxB,WAAW,EAAE,2CAA2C;IACxD,WAAW,EAAE,CAAC,CAAC,MAAM,CAAC,EAAE,CAAC;IACzB,IAAI,EAAE,CAAC,QAAQ,CAAC;IAChB,KAAK,CAAC,OAAO;QACX,OAAO,iBAAiB,CAAC,EAAE,CAAC,CAAC;IAC/B,CAAC;CACF,CAAC,CAAC"}
@@ -0,0 +1,19 @@
1
+ import { defineTool } from '@zhin.js/agent/tools';
2
+ import { z } from 'zod';
3
+ import { executeGithubCreatePr } from '../../src/github-bot-handlers.js';
4
+ export default defineTool({
5
+ description: '以 GitHub App Bot 身份创建 Pull Request(需 HITL 确认;Issue 场景常用)',
6
+ inputSchema: z.object({
7
+ repo: z.string().optional().describe('owner/repo'),
8
+ title: z.string().describe('PR 标题'),
9
+ body: z.string().optional().describe('PR 正文'),
10
+ head: z.string().optional().describe('head 分支,缺省为工作区分支'),
11
+ base: z.string().optional().describe('base 分支,缺省为仓库默认分支'),
12
+ }),
13
+ tags: ['github'],
14
+ approval: 'always',
15
+ async execute(input) {
16
+ return executeGithubCreatePr(input);
17
+ },
18
+ });
19
+ //# sourceMappingURL=create_pr.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"create_pr.js","sourceRoot":"","sources":["../../../agent/tools/create_pr.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAC;AAClD,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAAE,qBAAqB,EAAE,MAAM,kCAAkC,CAAC;AAEzE,eAAe,UAAU,CAAgF;IACvG,WAAW,EAAE,0DAA0D;IACvE,WAAW,EAAE,CAAC,CAAC,MAAM,CAAC;QACpB,IAAI,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE,CAAC,QAAQ,CAAC,YAAY,CAAC;QAClD,KAAK,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,CAAC,OAAO,CAAC;QACnC,IAAI,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE,CAAC,QAAQ,CAAC,OAAO,CAAC;QAC7C,IAAI,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE,CAAC,QAAQ,CAAC,kBAAkB,CAAC;QACxD,IAAI,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE,CAAC,QAAQ,CAAC,mBAAmB,CAAC;KAC1D,CAAC;IACF,IAAI,EAAE,CAAC,QAAQ,CAAC;IAChB,QAAQ,EAAE,QAAQ;IAClB,KAAK,CAAC,OAAO,CAAC,KAAK;QACjB,OAAO,qBAAqB,CAAC,KAAK,CAAC,CAAC;IACtC,CAAC;CACF,CAAC,CAAC"}
@@ -0,0 +1,12 @@
1
+ import { defineTool } from '@zhin.js/agent/tools';
2
+ import { z } from 'zod';
3
+ import { executeGithubInstall } from '../../src/github-tool-handlers.js';
4
+ export default defineTool({
5
+ description: '获取安装 GitHub App 的链接 — 安装后 Endpoint 可以访问你的仓库,你也可以使用更多功能',
6
+ inputSchema: z.object({}),
7
+ tags: ['github'],
8
+ async execute() {
9
+ return executeGithubInstall();
10
+ },
11
+ });
12
+ //# sourceMappingURL=install.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"install.js","sourceRoot":"","sources":["../../../agent/tools/install.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAC;AAClD,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAAE,oBAAoB,EAAE,MAAM,mCAAmC,CAAC;AAEzE,eAAe,UAAU,CAAC;IACxB,WAAW,EAAE,wDAAwD;IACrE,WAAW,EAAE,CAAC,CAAC,MAAM,CAAC,EAAE,CAAC;IACzB,IAAI,EAAE,CAAC,QAAQ,CAAC;IAChB,KAAK,CAAC,OAAO;QACX,OAAO,oBAAoB,EAAE,CAAC;IAChC,CAAC;CACF,CAAC,CAAC"}
@@ -0,0 +1,18 @@
1
+ import { defineTool } from '@zhin.js/agent/tools';
2
+ import { z } from 'zod';
3
+ import { executeGithubPatchFile } from '../../src/github-bot-handlers.js';
4
+ export default defineTool({
5
+ description: '通过 Contents API 单文件更新(小改;Bot Installation Token 身份)',
6
+ inputSchema: z.object({
7
+ repo: z.string().optional().describe('owner/repo'),
8
+ path: z.string().describe('仓库内文件路径'),
9
+ content: z.string().describe('新文件内容'),
10
+ message: z.string().describe('commit message'),
11
+ branch: z.string().optional().describe('目标分支,缺省从 Issue/PR 上下文推断'),
12
+ }),
13
+ tags: ['github'],
14
+ async execute(input) {
15
+ return executeGithubPatchFile(input);
16
+ },
17
+ });
18
+ //# sourceMappingURL=patch_file.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"patch_file.js","sourceRoot":"","sources":["../../../agent/tools/patch_file.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAC;AAClD,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAAE,sBAAsB,EAAE,MAAM,kCAAkC,CAAC;AAE1E,eAAe,UAAU,CAAqF;IAC5G,WAAW,EAAE,qDAAqD;IAClE,WAAW,EAAE,CAAC,CAAC,MAAM,CAAC;QACpB,IAAI,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE,CAAC,QAAQ,CAAC,YAAY,CAAC;QAClD,IAAI,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,CAAC,SAAS,CAAC;QACpC,OAAO,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,CAAC,OAAO,CAAC;QACrC,OAAO,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,CAAC,gBAAgB,CAAC;QAC9C,MAAM,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE,CAAC,QAAQ,CAAC,yBAAyB,CAAC;KAClE,CAAC;IACF,IAAI,EAAE,CAAC,QAAQ,CAAC;IAChB,KAAK,CAAC,OAAO,CAAC,KAAK;QACjB,OAAO,sBAAsB,CAAC,KAAK,CAAC,CAAC;IACvC,CAAC;CACF,CAAC,CAAC"}
@@ -0,0 +1,14 @@
1
+ import { defineTool } from '@zhin.js/agent/tools';
2
+ import { z } from 'zod';
3
+ import { executeGithubPrepareWorkspace } from '../../src/github-bot-handlers.js';
4
+ export default defineTool({
5
+ description: 'Clone/fetch 托管工作区并 checkout 到 Issue/PR 对应分支(GitHub App Bot 身份)',
6
+ inputSchema: z.object({
7
+ repo: z.string().optional().describe('owner/repo,缺省从当前 Issue/PR 频道推断'),
8
+ }),
9
+ tags: ['github'],
10
+ async execute(input) {
11
+ return executeGithubPrepareWorkspace(input);
12
+ },
13
+ });
14
+ //# sourceMappingURL=prepare_workspace.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"prepare_workspace.js","sourceRoot":"","sources":["../../../agent/tools/prepare_workspace.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAC;AAClD,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAAE,6BAA6B,EAAE,MAAM,kCAAkC,CAAC;AAEjF,eAAe,UAAU,CAAoB;IAC3C,WAAW,EAAE,gEAAgE;IAC7E,WAAW,EAAE,CAAC,CAAC,MAAM,CAAC;QACpB,IAAI,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE,CAAC,QAAQ,CAAC,gCAAgC,CAAC;KACvE,CAAC;IACF,IAAI,EAAE,CAAC,QAAQ,CAAC;IAChB,KAAK,CAAC,OAAO,CAAC,KAAK;QACjB,OAAO,6BAA6B,CAAC,KAAK,CAAC,CAAC;IAC9C,CAAC;CACF,CAAC,CAAC"}
@@ -0,0 +1,17 @@
1
+ import { defineTool } from '@zhin.js/agent/tools';
2
+ import { z } from 'zod';
3
+ import { executeGithubPushBranch } from '../../src/github-bot-handlers.js';
4
+ export default defineTool({
5
+ description: '在托管工作区 git commit 并 push 到远程分支(需 HITL 确认;Bot 身份)',
6
+ inputSchema: z.object({
7
+ repo: z.string().optional().describe('owner/repo'),
8
+ branch: z.string().optional().describe('分支名,缺省从上下文推断'),
9
+ message: z.string().describe('commit message'),
10
+ }),
11
+ tags: ['github'],
12
+ approval: 'always',
13
+ async execute(input) {
14
+ return executeGithubPushBranch(input);
15
+ },
16
+ });
17
+ //# sourceMappingURL=push_branch.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"push_branch.js","sourceRoot":"","sources":["../../../agent/tools/push_branch.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAC;AAClD,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAAE,uBAAuB,EAAE,MAAM,kCAAkC,CAAC;AAE3E,eAAe,UAAU,CAAsD;IAC7E,WAAW,EAAE,kDAAkD;IAC/D,WAAW,EAAE,CAAC,CAAC,MAAM,CAAC;QACpB,IAAI,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE,CAAC,QAAQ,CAAC,YAAY,CAAC;QAClD,MAAM,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE,CAAC,QAAQ,CAAC,cAAc,CAAC;QACtD,OAAO,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,CAAC,gBAAgB,CAAC;KAC/C,CAAC;IACF,IAAI,EAAE,CAAC,QAAQ,CAAC;IAChB,QAAQ,EAAE,QAAQ;IAClB,KAAK,CAAC,OAAO,CAAC,KAAK;QACjB,OAAO,uBAAuB,CAAC,KAAK,CAAC,CAAC;IACxC,CAAC;CACF,CAAC,CAAC"}
@@ -0,0 +1,15 @@
1
+ import { defineTool } from '@zhin.js/agent/tools';
2
+ import { z } from 'zod';
3
+ import { executeGithubStar } from '../../src/github-tool-handlers.js';
4
+ export default defineTool({
5
+ description: 'Star 或取消 Star 一个 GitHub 仓库(使用你绑定的 GitHub 账号,未绑定则用 Endpoint 默认账号)',
6
+ inputSchema: z.object({
7
+ action: z.enum(['star', 'unstar', 'check']),
8
+ repo: z.string().min(1),
9
+ }),
10
+ tags: ['github'],
11
+ async execute(input) {
12
+ return executeGithubStar(input);
13
+ },
14
+ });
15
+ //# sourceMappingURL=star.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"star.js","sourceRoot":"","sources":["../../../agent/tools/star.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAC;AAClD,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAAE,iBAAiB,EAAE,MAAM,mCAAmC,CAAC;AAEtE,eAAe,UAAU,CAAwD;IAC/E,WAAW,EAAE,kEAAkE;IAC/E,WAAW,EAAE,CAAC,CAAC,MAAM,CAAC;QACpB,MAAM,EAAE,CAAC,CAAC,IAAI,CAAC,CAAC,MAAM,EAAE,QAAQ,EAAE,OAAO,CAAC,CAAC;QAC3C,IAAI,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC;KACxB,CAAC;IACF,IAAI,EAAE,CAAC,QAAQ,CAAC;IAChB,KAAK,CAAC,OAAO,CAAC,KAAK;QACjB,OAAO,iBAAiB,CAAC,KAAK,CAAC,CAAC;IAClC,CAAC;CACF,CAAC,CAAC"}
@@ -0,0 +1,16 @@
1
+ import { defineTool } from '@zhin.js/agent/tools';
2
+ import { z } from 'zod';
3
+ import { executeGithubSubscribe } from '../../src/github-tool-handlers.js';
4
+ export default defineTool({
5
+ description: '订阅 GitHub 仓库的 Webhook 事件,事件将推送到当前聊天通道',
6
+ inputSchema: z.object({
7
+ repo: z.string().min(1),
8
+ events: z.string().optional(),
9
+ }),
10
+ platforms: ['github'],
11
+ tags: ['github'],
12
+ async execute(input) {
13
+ return executeGithubSubscribe(input);
14
+ },
15
+ });
16
+ //# sourceMappingURL=subscribe.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"subscribe.js","sourceRoot":"","sources":["../../../agent/tools/subscribe.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAC;AAClD,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAAE,sBAAsB,EAAE,MAAM,mCAAmC,CAAC;AAE3E,eAAe,UAAU,CAAoC;IAC3D,WAAW,EAAE,uCAAuC;IACpD,WAAW,EAAE,CAAC,CAAC,MAAM,CAAC;QACpB,IAAI,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC;QACvB,MAAM,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE;KAC9B,CAAC;IACF,SAAS,EAAE,CAAC,QAAQ,CAAC;IACrB,IAAI,EAAE,CAAC,QAAQ,CAAC;IAChB,KAAK,CAAC,OAAO,CAAC,KAAK;QACjB,OAAO,sBAAsB,CAAC,KAAK,CAAC,CAAC;IACvC,CAAC;CACF,CAAC,CAAC"}
@@ -0,0 +1,13 @@
1
+ import { defineTool } from '@zhin.js/agent/tools';
2
+ import { z } from 'zod';
3
+ import { executeGithubSubscriptions } from '../../src/github-tool-handlers.js';
4
+ export default defineTool({
5
+ description: '查看当前聊天通道的 GitHub 仓库订阅列表',
6
+ inputSchema: z.object({}),
7
+ platforms: ['github'],
8
+ tags: ['github'],
9
+ async execute() {
10
+ return executeGithubSubscriptions({});
11
+ },
12
+ });
13
+ //# sourceMappingURL=subscriptions.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"subscriptions.js","sourceRoot":"","sources":["../../../agent/tools/subscriptions.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAC;AAClD,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAAE,0BAA0B,EAAE,MAAM,mCAAmC,CAAC;AAE/E,eAAe,UAAU,CAAC;IACxB,WAAW,EAAE,yBAAyB;IACtC,WAAW,EAAE,CAAC,CAAC,MAAM,CAAC,EAAE,CAAC;IACzB,SAAS,EAAE,CAAC,QAAQ,CAAC;IACrB,IAAI,EAAE,CAAC,QAAQ,CAAC;IAChB,KAAK,CAAC,OAAO;QACX,OAAO,0BAA0B,CAAC,EAAE,CAAC,CAAC;IACxC,CAAC;CACF,CAAC,CAAC"}
@@ -0,0 +1,12 @@
1
+ import { defineTool } from '@zhin.js/agent/tools';
2
+ import { z } from 'zod';
3
+ import { executeGithubUnbind } from '../../src/github-tool-handlers.js';
4
+ export default defineTool({
5
+ description: '解除你绑定的 GitHub 账号',
6
+ inputSchema: z.object({}),
7
+ tags: ['github'],
8
+ async execute() {
9
+ return executeGithubUnbind({});
10
+ },
11
+ });
12
+ //# sourceMappingURL=unbind.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"unbind.js","sourceRoot":"","sources":["../../../agent/tools/unbind.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAC;AAClD,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAAE,mBAAmB,EAAE,MAAM,mCAAmC,CAAC;AAExE,eAAe,UAAU,CAAC;IACxB,WAAW,EAAE,kBAAkB;IAC/B,WAAW,EAAE,CAAC,CAAC,MAAM,CAAC,EAAE,CAAC;IACzB,IAAI,EAAE,CAAC,QAAQ,CAAC;IAChB,KAAK,CAAC,OAAO;QACX,OAAO,mBAAmB,CAAC,EAAE,CAAC,CAAC;IACjC,CAAC;CACF,CAAC,CAAC"}
@@ -0,0 +1,15 @@
1
+ import { defineTool } from '@zhin.js/agent/tools';
2
+ import { z } from 'zod';
3
+ import { executeGithubUnsubscribe } from '../../src/github-tool-handlers.js';
4
+ export default defineTool({
5
+ description: '取消订阅 GitHub 仓库的 Webhook 事件',
6
+ inputSchema: z.object({
7
+ repo: z.string().min(1),
8
+ }),
9
+ platforms: ['github'],
10
+ tags: ['github'],
11
+ async execute(input) {
12
+ return executeGithubUnsubscribe(input);
13
+ },
14
+ });
15
+ //# sourceMappingURL=unsubscribe.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"unsubscribe.js","sourceRoot":"","sources":["../../../agent/tools/unsubscribe.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAC;AAClD,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAAE,wBAAwB,EAAE,MAAM,mCAAmC,CAAC;AAE7E,eAAe,UAAU,CAAmB;IAC1C,WAAW,EAAE,4BAA4B;IACzC,WAAW,EAAE,CAAC,CAAC,MAAM,CAAC;QACpB,IAAI,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC;KACxB,CAAC;IACF,SAAS,EAAE,CAAC,QAAQ,CAAC;IACrB,IAAI,EAAE,CAAC,QAAQ,CAAC;IAChB,KAAK,CAAC,OAAO,CAAC,KAAK;QACjB,OAAO,wBAAwB,CAAC,KAAK,CAAC,CAAC;IACzC,CAAC;CACF,CAAC,CAAC"}
@@ -0,0 +1,12 @@
1
+ import { defineTool } from '@zhin.js/agent/tools';
2
+ import { z } from 'zod';
3
+ import { executeGithubWhoami } from '../../src/github-tool-handlers.js';
4
+ export default defineTool({
5
+ description: '查看你绑定的 GitHub 账号信息',
6
+ inputSchema: z.object({}),
7
+ tags: ['github'],
8
+ async execute() {
9
+ return executeGithubWhoami({});
10
+ },
11
+ });
12
+ //# sourceMappingURL=whoami.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"whoami.js","sourceRoot":"","sources":["../../../agent/tools/whoami.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAC;AAClD,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAAE,mBAAmB,EAAE,MAAM,mCAAmC,CAAC;AAExE,eAAe,UAAU,CAAC;IACxB,WAAW,EAAE,oBAAoB;IACjC,WAAW,EAAE,CAAC,CAAC,MAAM,CAAC,EAAE,CAAC;IACzB,IAAI,EAAE,CAAC,QAAQ,CAAC;IAChB,KAAK,CAAC,OAAO;QACX,OAAO,mBAAmB,CAAC,EAAE,CAAC,CAAC;IACjC,CAAC;CACF,CAAC,CAAC"}
@@ -3,7 +3,7 @@
3
3
  */
4
4
  import { formatCompact, Adapter, OUTBOUND_RICH_SEGMENT_POLICY_TEXT_ONLY } from 'zhin.js';
5
5
  import crypto from 'node:crypto';
6
- import { GitHubEndpoint } from './endpoint.js';
6
+ import { GitHubEndpoint, enrichGithubInboundMessage } from './endpoint.js';
7
7
  const VALID_EVENTS = ['push', 'issue', 'star', 'fork', 'unstar', 'pull_request'];
8
8
  function safeParseEvents(raw) {
9
9
  if (Array.isArray(raw))
@@ -201,22 +201,26 @@ export class GitHubAdapter extends Adapter {
201
201
  }
202
202
  // 处理消息类事件(Issue/PR 评论)
203
203
  if (endpoint && event === 'issue_comment' && payload.action === 'created' && payload.comment) {
204
- const message = endpoint.$formatMessage(payload);
204
+ let message = endpoint.$formatMessage(payload);
205
+ message = enrichGithubInboundMessage(message, endpoint.$config, endpoint.gh, repo);
205
206
  const botUser = endpoint.gh.authenticatedUser;
206
207
  if (!(botUser && message.$sender.id === botUser)) {
207
208
  this.emit('message.receive', message);
208
209
  }
209
210
  }
210
211
  if (endpoint && event === 'pull_request_review_comment' && payload.action === 'created' && payload.comment) {
211
- const message = endpoint.formatPRReviewComment(payload);
212
+ let message = endpoint.formatPRReviewComment(payload);
213
+ message = enrichGithubInboundMessage(message, endpoint.$config, endpoint.gh, repo);
212
214
  const botUser = endpoint.gh.authenticatedUser;
213
215
  if (!(botUser && message.$sender.id === botUser)) {
214
216
  this.emit('message.receive', message);
215
217
  }
216
218
  }
217
219
  if (endpoint && event === 'pull_request_review' && payload.action === 'submitted') {
218
- const message = endpoint.formatPRReview(payload);
219
- if (message) {
220
+ const formatted = endpoint.formatPRReview(payload);
221
+ if (formatted) {
222
+ let message = formatted;
223
+ message = enrichGithubInboundMessage(message, endpoint.$config, endpoint.gh, repo);
220
224
  const botUser = endpoint.gh.authenticatedUser;
221
225
  if (!(botUser && message.$sender.id === botUser)) {
222
226
  this.emit('message.receive', message);
@@ -333,7 +337,8 @@ export class GitHubAdapter extends Adapter {
333
337
  }
334
338
  // 处理消息类事件(Issue/PR 评论)
335
339
  if (endpoint && eventName === 'issue_comment' && ev.payload?.action === 'created' && ev.payload?.comment) {
336
- const message = endpoint.$formatMessage(ev.payload);
340
+ let message = endpoint.$formatMessage(ev.payload);
341
+ message = enrichGithubInboundMessage(message, endpoint.$config, endpoint.gh, repo);
337
342
  const botUser = endpoint.gh.authenticatedUser;
338
343
  if (!(botUser && message.$sender.id === botUser)) {
339
344
  this.emit('message.receive', message);