Skip to content

Commit 427736b

Browse files
herbertliuclaude
andcommitted
feat(wiki): add +space-list, +node-list, +node-copy shortcuts
Implement three new wiki shortcuts for organizing and migrating wiki content: - `+space-list`: list all accessible wiki spaces with auto-pagination - `+node-list`: list nodes under a space or parent node with auto-pagination - `+node-copy`: copy a wiki node (and subtree) to a target space or parent node Also includes: - Reference docs under skills/lark-wiki/references/ (with _EXAMPLE_TOKEN placeholders) - Updated skills/lark-wiki/SKILL.md with new shortcuts table entries - 9 unit tests covering registration, pagination, validation, and copy scenarios - scripts/check-doc-tokens.sh: pre-push check that catches realistic-looking example tokens in reference docs and prompts use of _EXAMPLE_TOKEN placeholders - Makefile: add `make gitleaks` target (runs check-doc-tokens then gitleaks) Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
1 parent 76fac11 commit 427736b

13 files changed

Lines changed: 885 additions & 3 deletions

.gitleaks.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,3 +14,4 @@ id = "lark-session-token"
1414
description = "Detect Lark session tokens"
1515
regex = '''\bXN0YXJ0-[A-Za-z0-9_-]+-WVuZA\b'''
1616
keywords = ["XN0YXJ0-", "-WVuZA"]
17+

Makefile

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ DATE := $(shell date +%Y-%m-%d)
88
LDFLAGS := -s -w -X $(MODULE)/internal/build.Version=$(VERSION) -X $(MODULE)/internal/build.Date=$(DATE)
99
PREFIX ?= /usr/local
1010

11-
.PHONY: build vet test unit-test integration-test install uninstall clean fetch_meta
11+
.PHONY: build vet test unit-test integration-test install uninstall clean fetch_meta gitleaks
1212

1313
fetch_meta:
1414
python3 scripts/fetch_meta.py
@@ -37,3 +37,13 @@ uninstall:
3737

3838
clean:
3939
rm -f $(BINARY)
40+
41+
# Run secret-leak checks locally before pushing.
42+
# Step 1: check-doc-tokens catches realistic-looking example tokens in reference
43+
# docs and asks you to use _EXAMPLE_TOKEN placeholders instead.
44+
# Step 2: gitleaks scans the full repo for real leaked secrets.
45+
# Install gitleaks: https://github.com/gitleaks/gitleaks#installing
46+
gitleaks:
47+
@bash scripts/check-doc-tokens.sh
48+
@command -v gitleaks >/dev/null 2>&1 || { echo "gitleaks not found. Install: brew install gitleaks"; exit 1; }
49+
gitleaks detect --redact -v --exit-code=2

scripts/check-doc-tokens.sh

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
#!/usr/bin/env bash
2+
# Copyright (c) 2026 Lark Technologies Pte. Ltd.
3+
# SPDX-License-Identifier: MIT
4+
#
5+
# check-doc-tokens.sh
6+
#
7+
# Scans skill reference docs for token-like values that look realistic but
8+
# are not using the required placeholder format (*_EXAMPLE_TOKEN or similar).
9+
#
10+
# Real token patterns (Lark API) often look like:
11+
# wikcnXXXXXXXXX doccnXXXXXXX shtcnXXX fldcnXXX ou_XXXX cli_XXXX
12+
#
13+
# Docs MUST use clearly fake placeholders, e.g.:
14+
# wikcn_EXAMPLE_TOKEN doccn_EXAMPLE_TOKEN <space_id> your_token_here
15+
#
16+
# If this check fails, replace the realistic-looking value with a placeholder
17+
# like `wikcn_EXAMPLE_TOKEN` so gitleaks CI won't flag it as a real secret.
18+
19+
set -euo pipefail
20+
21+
SKILLS_DIR="${1:-skills}"
22+
ERRORS=0
23+
24+
# Patterns that indicate a realistic-looking Lark token value inside a string.
25+
# Matches JSON-style: "field": "token_value" or markdown backtick spans.
26+
# Token prefixes used by Lark Open Platform:
27+
# wikcn doccn docx shtcn bascn fldcn vewcn tbln ou_ cli_ obcn flec
28+
#
29+
# Excluded (clearly fake):
30+
# - Values ending with EXAMPLE_TOKEN (e.g. wikcn_EXAMPLE_TOKEN)
31+
# - Values that are all uppercase X (e.g. bascnXXXXXXXX)
32+
# - Values containing only X/_/<> (e.g. <your_token>)
33+
REALISTIC_TOKEN_RE='"(wikcn|doccn|shtcn|bascn|fldcn|vewcn|tbln|obcn|flec)[A-Za-z0-9]{6,}"'
34+
PLACEHOLDER_RE='(EXAMPLE|_TOKEN|XXXX|xxxx|<|>|your_|_here)'
35+
36+
while IFS= read -r -d '' file; do
37+
# grep returns exit 1 when no match — use || true to avoid set -e killing us
38+
# Then filter out values that are clearly placeholders (EXAMPLE, XXXX, etc.)
39+
matches=$(grep -nEo "$REALISTIC_TOKEN_RE" "$file" 2>/dev/null | grep -vE "$PLACEHOLDER_RE" || true)
40+
if [[ -n "$matches" ]]; then
41+
echo ""
42+
echo "$file"
43+
echo " Contains realistic-looking token values that may trigger gitleaks:"
44+
while IFS= read -r line; do
45+
echo " $line"
46+
done <<< "$matches"
47+
echo " → Replace with a placeholder, e.g.: wikcn_EXAMPLE_TOKEN, doccn_EXAMPLE_TOKEN"
48+
ERRORS=$((ERRORS + 1))
49+
fi
50+
done < <(find "$SKILLS_DIR" -path "*/references/*.md" -print0)
51+
52+
if [[ $ERRORS -gt 0 ]]; then
53+
echo ""
54+
echo "❌ check-doc-tokens: $ERRORS file(s) contain realistic token values in reference docs."
55+
echo " Use _EXAMPLE_TOKEN placeholders to avoid false positives in gitleaks CI."
56+
exit 1
57+
else
58+
echo "✅ check-doc-tokens: all reference docs use safe placeholder tokens."
59+
fi

shortcuts/wiki/shortcuts.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,5 +9,8 @@ import "github.com/larksuite/cli/shortcuts/common"
99
func Shortcuts() []common.Shortcut {
1010
return []common.Shortcut{
1111
WikiNodeCreate,
12+
WikiSpaceList,
13+
WikiNodeList,
14+
WikiNodeCopy,
1215
}
1316
}

0 commit comments

Comments
 (0)