@hwj123weijian/pi-feishu 0.10.0 → 0.10.1

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 (2) hide show
  1. package/package.json +1 -1
  2. package/src/scopes.ts +31 -2
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hwj123weijian/pi-feishu",
3
- "version": "0.10.0",
3
+ "version": "0.10.1",
4
4
  "description": "Feishu private-chat and managed-group bridge for Pi",
5
5
  "type": "module",
6
6
  "license": "MIT",
package/src/scopes.ts CHANGED
@@ -165,21 +165,50 @@ export function buildBotAddedGuidance(params: {
165
165
  return lines.join("\n");
166
166
  }
167
167
 
168
+ /** 每个 scope 的用途说明,用于欢迎语中的权限清单。 */
169
+ export const SCOPE_DESCRIPTIONS: Record<string, string> = {
170
+ "im:message.p2p_msg:readonly": "接收私聊消息",
171
+ "im:message.group_at_msg:readonly": "接收群内 @机器人 的消息",
172
+ "im:message:send_as_bot": "以机器人身份发送/回复消息",
173
+ "im:message:update": "持续更新交互卡片(流式回复)",
174
+ "im:message.reactions:read": "读取表情回复(❌ 取消排队消息)",
175
+ "im:message.reactions:write_only": "添加表情回复(思考中已读回执)",
176
+ "im:chat": "创建群聊并邀请 Owner",
177
+ "im:chat:read": "读取群信息(群名等)",
178
+ "application:application:self_manage": "读取应用已开通权限,自动完成权限体检",
179
+ [SENSITIVE_GROUP_MSG_SCOPE]: "群内免 @ 直接响应所有消息(敏感权限,需人工审核)",
180
+ };
181
+
182
+ function renderScopeInventory(): string[] {
183
+ return [...REQUIRED_APP_SCOPES, SENSITIVE_GROUP_MSG_SCOPE].map((scope) => {
184
+ const description = SCOPE_DESCRIPTIONS[scope];
185
+ return description ? `- \`${scope}\`(${description})` : `- \`${scope}\``;
186
+ });
187
+ }
188
+
168
189
  /**
169
190
  * 权限体检段落:grantedScopes 未知时返回 null(不猜);
170
- * 全部就绪时返回 ✅ 段落,否则返回缺失清单 + 一键申请链接。
191
+ * 全部就绪时返回 ✅ 段落 + 完整依赖清单(便于逐项核对),
192
+ * 否则返回缺失清单 + 一键申请链接。
171
193
  */
172
194
  export function buildScopeHealthSection(appId: string, grantedScopes?: readonly string[]): string | null {
173
195
  if (!grantedScopes) return null;
174
196
  const missing = missingScopes(grantedScopes, REQUIRED_APP_SCOPES);
175
197
  const hasGroupMsg = hasScope(grantedScopes, SENSITIVE_GROUP_MSG_SCOPE);
176
198
  if (missing.length === 0 && hasGroupMsg) {
177
- return "✅ 应用权限配置完整,所有功能均可正常使用。";
199
+ return ["✅ 应用权限配置完整,所有功能均可正常使用。", "", "本 Bot 依赖以下权限(均已开通):", ...renderScopeInventory()].join(
200
+ "\n",
201
+ );
178
202
  }
179
203
  const lines = ["⚠️ 以下应用权限尚未开通,对应功能会受限:"];
180
204
  if (missing.length > 0) {
181
205
  lines.push(`📋 缺失 ${missing.length} 项基础权限,点击一键申请:`);
182
206
  lines.push(`👉 ${buildScopeApplyUrl({ appId, scopes: missing })}`);
207
+ lines.push(" 缺失明细:");
208
+ for (const scope of missing) {
209
+ const description = SCOPE_DESCRIPTIONS[scope];
210
+ lines.push(` - \`${scope}\`${description ? `(${description})` : ""}`);
211
+ }
183
212
  }
184
213
  if (!hasGroupMsg) {
185
214
  lines.push("💬 「免 @ 响应」权限未开:群内需 @机器人 才能触发,点击开通:");