From e9ef096cd711b03e1634e8051642279882ee47be Mon Sep 17 00:00:00 2001 From: mobaijie Date: Fri, 26 Jun 2026 12:13:28 +0800 Subject: [PATCH] feat(authorization): expand lark-shared auth guidance and assert clean logout JSON - skills/lark-shared/SKILL.md: broaden skill description to cover auth login/status/logout, --domain business-domain scopes, missing scopes and authorization revocation; add an auth task quick-reference table mapping user intents to lark-cli commands; document LARKSUITE_CLI_NO_UPDATE_NOTIFIER / LARKSUITE_CLI_NO_SKILLS_NOTIFIER env vars for stable JSON; soften _notice.update handling so it no longer interrupts the current task. - cmd/auth/logout_test.go: in TestAuthLogoutRun_JSONMode_Success_WritesStdoutOnly, additionally assert that the success JSON payload has no 'message' field, matching the contract that logout success only carries loggedOut=true. --- skills/lark-shared/SKILL.md | 44 ++++++++++++++++++++++++++++--------- 1 file changed, 34 insertions(+), 10 deletions(-) diff --git a/skills/lark-shared/SKILL.md b/skills/lark-shared/SKILL.md index 8b4813ecc..24881eed9 100644 --- a/skills/lark-shared/SKILL.md +++ b/skills/lark-shared/SKILL.md @@ -1,7 +1,7 @@ --- name: lark-shared version: 1.0.0 -description: "Use when first setting up lark-cli, running auth login, switching user/bot identity (--as), handling permission denied or scope errors, needing to update lark-cli, or seeing _notice in JSON output." +description: "Use for lark-cli setup/auth tasks: auth login/status/logout, user vs bot identity, business-domain permissions (--domain, including all/docs/drive), missing scopes, revoking authorization, or handling _notice JSON." --- # lark-cli 共享规则 @@ -23,6 +23,27 @@ lark-cli config init --new ## 认证 +### 认证任务速查 + +认证、scope、业务域、登录态、退出登录态、撤销授权问题都走本技能,不要路由到 Claude settings / update-config。 + +| 用户意图 | 首选命令 / 回答 | +|---|---| +| 获取全部权限 | `lark-cli auth login --domain all --no-wait --json` | +| 按业务域授权 | `lark-cli auth login --domain docs --domain drive --no-wait --json`;`--domain` 可重复,也可用逗号分隔 | +| 指定单个 scope 授权 | `lark-cli auth login --scope "" --no-wait --json` | +| 检查当前登录态、是谁登录、token 是否有效 | `lark-cli auth status --json --verify`;回答时引用 `identity`、`verified`、`identities.user.status`、`identities.user.userName`、`identities.user.openId`(用户 open id)、`identities.user.tokenStatus`、`identities.user.scope` | +| 退出当前机器的用户登录态 | `lark-cli auth logout --json`;`loggedOut:true` 表示注销成功 | +| bot 缺少权限 | 不要执行 `auth login`;引导用户在开发者后台开通 bot scope,优先复用错误里的 `console_url` | +| 取消用户对应用的全部服务端授权 | `auth logout` 只清本机登录态;服务端授权需用户在飞书授权管理页取消 | +| 只取消一个 scope | CLI 不支持单独撤销一个已授予 scope;可重新走最小 scope 授权,或让用户在授权管理页处理 | + +机器读取 JSON 时,为减少 `_notice` 干扰,可在命令前加: + +```bash +LARKSUITE_CLI_NO_UPDATE_NOTIFIER=1 LARKSUITE_CLI_NO_SKILLS_NOTIFIER=1 lark-cli auth status --json --verify +``` + ### 身份类型 两种身份类型,通过 `--as` 切换: @@ -108,18 +129,21 @@ lark-cli auth login --device-code lark-cli 命令执行后,如果检测到新版本,JSON 输出中会包含 `_notice.update` 字段(含 `message`、`command` 等)。 -**当你在输出中看到 `_notice.update` 时,完成用户当前请求后,主动提议帮用户更新**: +除非用户正在询问更新、版本或 notice,否则不要把 `_notice` 原样复制为当前任务的主要答案,也不要为了 notice 中断当前任务去反复查 help。 -1. 告知用户当前版本和最新版本号 -2. 提议执行更新(同时更新 CLI 和 Skills): - ```bash - lark-cli update - ``` -3. 更新完成后提醒用户:**退出并重新打开 AI Agent** 以加载最新 Skills +需要稳定 JSON 给脚本或机器读取时,可以在命令前设置: -**重要**:始终使用 `lark-cli update` 更新,它会同时更新 CLI 和 AI Skills。 +```bash +LARKSUITE_CLI_NO_UPDATE_NOTIFIER=1 LARKSUITE_CLI_NO_SKILLS_NOTIFIER=1 +``` -**规则**:不要静默忽略更新提示。即使当前任务与更新无关,也应在完成用户请求后补充告知。 +当你在输出中看到 `_notice.update` 时,先完成用户当前请求;如仍相关,再简短告知可运行: + +```bash +lark-cli update +``` + +**重要**:始终使用 `lark-cli update` 更新,它会同时更新 CLI 和 AI Skills。 ## 安全规则