Skip to content

fix(wiki): rename +node-get --token to --node-token, keep alias#1074

Merged
fangshuyu-768 merged 1 commit into
mainfrom
fix/wiki-node-get-rename-token-flag
May 25, 2026
Merged

fix(wiki): rename +node-get --token to --node-token, keep alias#1074
fangshuyu-768 merged 1 commit into
mainfrom
fix/wiki-node-get-rename-token-flag

Conversation

@liujinkun2025
Copy link
Copy Markdown
Collaborator

@liujinkun2025 liujinkun2025 commented May 25, 2026

Summary

Addresses the third point of #1049: wiki +node-get used --token while every other wiki shortcut that operates on a node (+node-delete, +node-copy, +move, plus the *-node-token variants on +node-list / +node-create) uses --node-token. The lone outlier forced humans and AI agents to remember which adjacent command takes which flag, and was called out in the issue as a real source of validation failures during automation.

  • Make --node-token the canonical flag on wiki +node-get.
  • Keep --token as a hidden, deprecated alias via cobra MarkDeprecated, so existing scripts continue to work and just see a one-line stderr warning (Flag --token has been deprecated, use --node-token instead).
  • Reject the obvious bug case where both flags are set with different values; identical values are allowed.
  • Refresh skills docs (lark-wiki reference, lark-base SKILL.md) to prefer --node-token; note the legacy flag in a single line.

This is not a breaking change — every prior invocation of --token still succeeds with the same data shape; the only new surface is a stderr deprecation line.

Test plan

  • Unit tests: new coverage for resolveWikiNodeGetRawToken (prefer / legacy / both-same / conflict / both-empty), new mounted tests for --node-token happy path, legacy --token warns-but-works, and the conflict case.
  • Existing parser tests updated where error messages referenced --token.
  • Full unit-test suite (excluding cli_e2e) green.
  • gofmt -l clean; go vet ./... clean. (golangci-lint not installed locally — leaving to CI.)
  • End-to-end smoke against a real Feishu wiki node via ./lark-cli wiki +node-get --node-token <wiki_url> --as user --format pretty — URL token extraction + get_node call succeeded.

Summary by CodeRabbit

  • New Features

    • The wiki node-get command now uses --node-token as its canonical identifier flag
  • Deprecations

    • The --token flag is deprecated but continues to work; migration to --node-token is recommended
  • Documentation

    • Updated documentation for the wiki node-get command and related skills to reflect the new flag naming

Review Change Stack

Per issue #1049 (third point), wiki +node-get used --token while sibling
commands (+node-delete / +node-copy / +move) use --node-token. The
inconsistency forced humans and AI agents to remember which adjacent
command takes which flag.

Make --node-token the canonical flag and keep --token as a hidden,
deprecated alias so existing scripts continue to work. pflag's
MarkDeprecated prints "Flag --token has been deprecated, use --node-token
instead" to stderr on use, guiding callers to migrate. Conflict between
the two with different values is rejected upfront.

Skills docs (lark-wiki, lark-base) updated to prefer --node-token.

Change-Id: I3415a98f079613c0b1a0b989cf54a09cbb8986fb
@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented May 25, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 55af9c37-ca48-48a9-8d30-050a4345e3d3

📥 Commits

Reviewing files that changed from the base of the PR and between f2a4c95 and 87ae42d.

📒 Files selected for processing (4)
  • shortcuts/wiki/wiki_node_get.go
  • shortcuts/wiki/wiki_node_get_test.go
  • skills/lark-base/SKILL.md
  • skills/lark-wiki/references/lark-wiki-node-get.md

📝 Walkthrough

Walkthrough

This PR migrates the lark-cli wiki +node-get command's primary identifier flag from --token to --node-token, maintaining backward compatibility through deprecation warnings while updating all validation messages and documentation to reference the new canonical flag name.

Changes

CLI flag migration with deprecation and validation

Layer / File(s) Summary
Flag definition and deprecation setup
shortcuts/wiki/wiki_node_get.go
WikiNodeGet adds --node-token as canonical, hides --token as deprecated, registers PostMount to mark legacy flag deprecated, and updates tips to reference --node-token.
Token resolution and validation updates
shortcuts/wiki/wiki_node_get.go
New resolveWikiNodeGetRawToken helper handles trim, conflict detection, and canonical selection; readWikiNodeGetSpec calls this helper; parseWikiNodeGetSpec updates all validation errors to reference --node-token for required/format/URL-path/partial-path messages.
Unit tests for token resolution
shortcuts/wiki/wiki_node_get_test.go
Adds unit tests for resolveWikiNodeGetRawToken covering precedence, legacy acceptance, same values, conflicts, and empty inputs; updates existing whitespace-rejection test to assert --node-token is required.
CLI integration and deprecation tests
shortcuts/wiki/wiki_node_get_test.go
New mounted tests verify --node-token works without warnings, --token emits deprecation, and conflicting flags error before HTTP; adds mountWikiNodeGetWithFlagOut helper for output capture; updates URL-based and execution tests to use --node-token.
Documentation updates
skills/lark-base/SKILL.md, skills/lark-wiki/references/lark-wiki-node-get.md
Updates skill prerequisites, fast-path commands, and troubleshooting to use --node-token; documents --token as deprecated with warning behavior in reference docs.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Possibly related PRs

  • larksuite/cli#904: Introduces WikiNodeGet with initial --token flag; this PR refactors it to use --node-token with deprecation and conflict handling.
  • larksuite/cli#982: Updates skill documentation for Wiki-to-Base token resolution; overlaps with this PR's updates to skills/lark-base/SKILL.md to reference the new --node-token flag.

Suggested labels

size/M, domain/ccm

Suggested reviewers

  • fangshuyu-768
  • kongenpei

Poem

🐰 A token by any other flag would work the same,
But --node-token now stakes its claim,
While --token fades with deprecation's call,
Through tests and docs, we've honored them all. ✨

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 15.79% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and concisely summarizes the main change: renaming the --token flag to --node-token while maintaining backward compatibility via an alias.
Description check ✅ Passed The description comprehensively covers the motivation (aligning with other node commands), implementation details (canonical flag, deprecated alias, conflict handling), documentation updates, and a detailed test plan with verification steps.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/wiki-node-get-rename-token-flag

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@github-actions github-actions Bot added domain/base PR touches the base domain domain/ccm PR touches the ccm domain size/L Large or sensitive change across domains or core paths labels May 25, 2026
@github-actions
Copy link
Copy Markdown

🚀 PR Preview Install Guide

🧰 CLI update

npm i -g https://pkg.pr.new/larksuite/cli/@larksuite/cli@87ae42dc157ffef591ae8aa45a8a0d65dad2f41f

🧩 Skill update

npx skills add larksuite/cli#fix/wiki-node-get-rename-token-flag -y -g

@codecov
Copy link
Copy Markdown

codecov Bot commented May 25, 2026

Codecov Report

❌ Patch coverage is 92.00000% with 2 lines in your changes missing coverage. Please review.
✅ Project coverage is 67.83%. Comparing base (f2a4c95) to head (87ae42d).

Files with missing lines Patch % Lines
shortcuts/wiki/wiki_node_get.go 92.00% 1 Missing and 1 partial ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1074      +/-   ##
==========================================
+ Coverage   67.82%   67.83%   +0.01%     
==========================================
  Files         592      592              
  Lines       55307    55327      +20     
==========================================
+ Hits        37512    37532      +20     
  Misses      14683    14683              
  Partials     3112     3112              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@fangshuyu-768 fangshuyu-768 merged commit ac06eaa into main May 25, 2026
22 checks passed
@fangshuyu-768 fangshuyu-768 deleted the fix/wiki-node-get-rename-token-flag branch May 25, 2026 09:28
@liangshuo-1 liangshuo-1 mentioned this pull request May 25, 2026
2 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

domain/base PR touches the base domain domain/ccm PR touches the ccm domain size/L Large or sensitive change across domains or core paths

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants