Skip to content

Commit 4807283

Browse files
committed
fix(slides): declare screenshot scope
1 parent d2bb365 commit 4807283

3 files changed

Lines changed: 10 additions & 15 deletions

File tree

shortcuts/slides/slides_screenshot.go

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,9 +37,7 @@ var SlidesScreenshot = common.Shortcut{
3737
Command: "+screenshot",
3838
Description: "Save up to 10 slide screenshots to local files without printing Base64 image data",
3939
Risk: "read",
40-
Scopes: []string{},
41-
// The screenshot API is allowlist-gated for only a few apps, so do not
42-
// advertise/preflight its scope. Let the API fail and let callers degrade.
40+
Scopes: []string{"slides:presentation:screenshot"},
4341
// wiki:node:read is required only when --presentation is a wiki URL.
4442
ConditionalScopes: []string{"wiki:node:read"},
4543
AuthTypes: []string{"user", "bot"},

shortcuts/slides/slides_screenshot_test.go

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import (
88
"encoding/json"
99
"os"
1010
"path/filepath"
11+
"reflect"
1112
"strings"
1213
"testing"
1314

@@ -17,23 +18,19 @@ import (
1718
)
1819

1920
func TestSlidesScreenshotDeclaredScopes(t *testing.T) {
20-
if got := SlidesScreenshot.ScopesForIdentity("user"); len(got) != 0 {
21-
t.Fatalf("user preflight scopes = %#v, want empty", got)
21+
base := []string{"slides:presentation:screenshot"}
22+
if got := SlidesScreenshot.ScopesForIdentity("user"); !reflect.DeepEqual(got, base) {
23+
t.Fatalf("user preflight scopes = %#v, want %#v", got, base)
2224
}
23-
if got := SlidesScreenshot.ScopesForIdentity("bot"); len(got) != 0 {
24-
t.Fatalf("bot preflight scopes = %#v, want empty", got)
25+
if got := SlidesScreenshot.ScopesForIdentity("bot"); !reflect.DeepEqual(got, base) {
26+
t.Fatalf("bot preflight scopes = %#v, want %#v", got, base)
2527
}
2628

2729
got := SlidesScreenshot.DeclaredScopesForIdentity("user")
28-
want := []string{"wiki:node:read"}
29-
if len(got) != len(want) || got[0] != want[0] {
30+
want := []string{"slides:presentation:screenshot", "wiki:node:read"}
31+
if !reflect.DeepEqual(got, want) {
3032
t.Fatalf("declared scopes = %#v, want %#v", got, want)
3133
}
32-
for _, scope := range got {
33-
if scope == "slides:presentation:screenshot" {
34-
t.Fatalf("declared scopes must not advertise screenshot scope: %#v", got)
35-
}
36-
}
3734
}
3835

3936
func TestSlidesScreenshotWritesFilesAndSuppressesBase64(t *testing.T) {

skills/lark-slides/references/lark-slides-screenshot.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
获取幻灯片页面截图并保存为本地图片文件。默认用于已存在 PPT 页面截图;传入 `--content` 时用于直接渲染单个 `<slide>` XML 片段预览。本 shortcut 会在 CLI 进程内解码并写入文件,stdout 只返回文件路径、大小、页面 ID 等元信息,避免把图片 Base64 输出给模型。
66

7-
注意:该截图能力受应用白名单限制,绝大多数应用不可用。截图失败时不要引导用户申请 `slides:presentation:screenshot` 权限;记录错误后降级到 XML 读回、结构 lint、文本重叠检查等非截图检查路径
7+
截图失败则降级到 XML 读回、结构 lint等非截图检查路径
88

99
## 命令
1010

0 commit comments

Comments
 (0)