Skip to content

feat: add miaoda app collaborator management - #2230

Merged
yxy-bd merged 6 commits into
mainfrom
feat/miaoda-member-permissions
Aug 7, 2026
Merged

feat: add miaoda app collaborator management#2230
yxy-bd merged 6 commits into
mainfrom
feat/miaoda-member-permissions

Conversation

@yxy-bd

@yxy-bd yxy-bd commented Aug 7, 2026

Copy link
Copy Markdown
Collaborator

Summary

Add AI-friendly collaborator management commands for Miaoda applications. The new shortcuts let agents list, add, update, and remove collaborators, as well as read and update collaborator permission settings, using structured external IDs and typed errors.

Changes

  • Add apps +member-list, +member-add, +member-update, and +member-remove with user, chat, and department collaborator support.
  • Add apps +member-settings-get and +member-settings-set for the supported sharing and collaborator policy fields.
  • Keep write operations behind the existing high-risk confirmation flow while allowing request inspection through --dry-run.
  • Return agent-oriented projections that omit internal gateway fields, preserve opaque pagination tokens, and fail closed on malformed responses.
  • Normalize collaborator API failures into typed CLI errors, including an actionable feature_not_available error for applications whose collaborators must be managed in the Miaoda console.
  • Update the lark-apps skill guidance and add unit, response-contract, and dry-run E2E coverage.

Test Plan

  • go test ./errs -count=1
  • go test ./shortcuts/apps -count=1
  • go test ./tests/cli_e2e/dryrun -run '^TestAppsMember' -count=1
  • go vet ./errs ./shortcuts/apps ./tests/cli_e2e/dryrun
  • Manual CLI verification covered list pagination, user/chat/department mutations, permission settings, and representative error responses against a test application.

Related Issues

  • None

Summary by CodeRabbit

  • New Features

    • Added commands to list, add, update, and remove application collaborators.
    • Added commands to view and update collaborator permissions and settings.
    • Added validation, formatted output, dry-run support, and confirmation safeguards for collaborator operations.
    • Added handling for resources whose requested features are unavailable.
  • Documentation

    • Updated application guidance with collaborator management and permission workflows.
  • Tests

    • Added comprehensive coverage for validation, request behavior, output safety, and command registration.

@yxy-bd yxy-bd added the size/L Large or sensitive change across domains or core paths label Aug 7, 2026
@yxy-bd
yxy-bd requested a review from liangshuo-1 August 7, 2026 06:58
@yxy-bd

yxy-bd commented Aug 7, 2026

Copy link
Copy Markdown
Collaborator Author

Supersedes #2191 to align the head branch with the repository naming convention. The commit and diff are unchanged.

@coderabbitai

coderabbitai Bot commented Aug 7, 2026

Copy link
Copy Markdown

Review Change Stack

📝 Walkthrough

Walkthrough

This change adds six Miaoda app collaborator and permission shortcuts. It adds typed validation, request construction, response projection, error normalization, shortcut registration, documentation, and unit and CLI dry-run coverage.

Changes

App collaborator management

Layer / File(s) Summary
Member contracts and response validation
errs/subtypes.go, shortcuts/apps/apps_member_common.go
Adds the feature_not_available error subtype, collaborator request and response models, typed member validation, settings validation, endpoint builders, error normalization, and strict response projection.
Collaborator command execution
shortcuts/apps/apps_member.go
Adds list, add, update, remove, settings-get, and settings-set shortcuts with dry-run handling, API execution, normalized errors, projected responses, and formatted output.
Shortcut registration and command guidance
shortcuts/apps/shortcuts.go, shortcuts/apps/shortcuts_test.go, skills/lark-apps/SKILL.md, tests/cli_e2e/apps/coverage.md
Registers six shortcuts, verifies their metadata, and documents collaborator routing, identifiers, permissions, confirmation, settings, and coverage.
Member command and projection tests
shortcuts/apps/apps_member_common_test.go, shortcuts/apps/apps_member_response_test.go, tests/cli_e2e/dryrun/apps_member_dryrun_test.go
Tests validation, request methods and bodies, typed identifiers, fail-closed projection, sanitized output, confirmation requirements, and unsupported flags.

Estimated code review effort: 4 (Complex) | ~45 minutes

Possibly related PRs

  • larksuite/cli#2191: Implements the same Miaoda app collaborator shortcuts, subtype, guidance, and tests.

Suggested reviewers: liangshuo-1

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 33.33% 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 identifies the main change: adding Miaoda app collaborator management.
Description check ✅ Passed The description includes all required sections and provides clear scope, changes, test results, manual verification, and related issue status.
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.
✨ Finishing Touches 💡 1
📝 Generate docstrings 💡
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feat/miaoda-member-permissions

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.

@github-actions

github-actions Bot commented Aug 7, 2026

Copy link
Copy Markdown

🚀 PR Preview Install Guide

🧰 CLI update

npm i -g https://pkg.pr.new/larksuite/cli/@larksuite/cli@5e973905963bc21e5abd1a369b287501f597c25b

🧩 Skill update

npx skills add larksuite/cli#feat/miaoda-member-permissions -y -g

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 6

🧹 Nitpick comments (1)
shortcuts/apps/apps_member_common.go (1)

402-423: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Derive the invalid-parameter list from memberSettingSpecs.

Lines 417-420 hardcode the four writable flag names. memberSettingSpecs already declares them. If a writable spec is added or writable changes, this list drifts and the error omits the new flag. Build the list from the table instead.

The early return err inside the loop is also correct but hard to read. buildMemberSettingsUpdateRequest validates every writable spec, so a single post-loop call is clearer.

♻️ Proposed refactor
 func validateMemberSettingsSet(rctx *common.RuntimeContext) error {
 	if err := validateMemberAppID(rctx); err != nil {
 		return err
 	}
+	missing := make([]errs.InvalidParam, 0, len(memberSettingSpecs))
 	for _, spec := range memberSettingSpecs {
 		if !spec.writable {
 			continue
 		}
 		if rctx.Changed(spec.flag) {
-			_, err := buildMemberSettingsUpdateRequest(rctx)
-			return err
+			_, err := buildMemberSettingsUpdateRequest(rctx)
+			return err
 		}
+		missing = append(missing, appsInvalidParam("--"+spec.flag, "not provided"))
 	}
 	return appsValidationError("at least one collaborator setting must be provided").
-		WithParams(
-			appsInvalidParam("--external-access", "not provided"),
-			appsInvalidParam("--link-share", "not provided"),
-			appsInvalidParam("--manage-collaborators-by", "not provided"),
-			appsInvalidParam("--comment-by", "not provided"),
-		).
+		WithParams(missing...).
 		WithHint("pass at least one setting flag; omitted settings remain unchanged")
 }

Adjust the appsInvalidParam return type in the slice declaration to match the repository signature.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@shortcuts/apps/apps_member_common.go` around lines 402 - 423, Update
validateMemberSettingsSet to call buildMemberSettingsUpdateRequest once after
checking all writable memberSettingSpecs, rather than returning from inside the
loop. Derive the appsInvalidParam list in the missing-settings error from
memberSettingSpecs, including each writable spec’s flag name, and use the
repository’s expected slice type for that list so newly added writable settings
remain represented automatically.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@shortcuts/apps/apps_member_common_test.go`:
- Around line 84-102: Update requireAppsMemberValidationError in
shortcuts/apps/apps_member_common_test.go lines 84-102 to obtain the problem via
errs.ProblemOf and assert errs.CategoryValidation before retaining the existing
ValidationError.Param checks. Also update the typed-error helper in
shortcuts/apps/apps_member_response_test.go lines 64-76 to use errs.ProblemOf
and require errs.CategoryInternal with errs.SubtypeInvalidResponse.
- Around line 183-185: Update the mocked response and public projection
assertions in the AppsMemberSettingsSet test to include page_token and has_more.
Verify both pagination fields are returned and preserve the page_token value
exactly without transformation.
- Around line 148-162: The test around normalizeMemberAPIError must also verify
the normalized problem retains the API category and preserves the original input
as its cause. Add an assertion that problem.Category equals errs.CategoryAPI and
an errors.Is(got, input) check, while keeping the existing field and hint
validations.

In `@tests/cli_e2e/apps/coverage.md`:
- Line 8: Add an executable, fixture-gated live E2E workflow for collaborator
commands that performs self-contained create, update, settings read/write,
remove, and cleanup operations using bot credentials where required. Update the
coverage documentation to describe this automated coverage while retaining BOE
verification as supplemental evidence; anchor the implementation to the existing
collaborator E2E tests and fixture-gating conventions.

In `@tests/cli_e2e/dryrun/apps_member_dryrun_test.go`:
- Around line 207-212: Update the test around runAppsMemberCLI to assert the
exact error.params values for the “no settings specified” validation failure,
rather than only checking that at least one parameter exists. Preserve the
existing exit-code, stdout, and error.type assertions while ensuring the
reported parameter names match the rejected settings flags exactly.
- Around line 81-153: Add a live collaborator lifecycle E2E test alongside
TestAppsMemberDryRun, using the existing live E2E helpers and bot credentials to
create or select a test app, add and list a collaborator, update its permission,
remove it, and clean up the app. Make the workflow self-contained, and capture
and restore any member settings it modifies before cleanup.

---

Nitpick comments:
In `@shortcuts/apps/apps_member_common.go`:
- Around line 402-423: Update validateMemberSettingsSet to call
buildMemberSettingsUpdateRequest once after checking all writable
memberSettingSpecs, rather than returning from inside the loop. Derive the
appsInvalidParam list in the missing-settings error from memberSettingSpecs,
including each writable spec’s flag name, and use the repository’s expected
slice type for that list so newly added writable settings remain represented
automatically.
🪄 Autofix

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 98827d42-fada-48ed-b494-6516dff5ff4a

📥 Commits

Reviewing files that changed from the base of the PR and between be2a96f and 5e97390.

📒 Files selected for processing (10)
  • errs/subtypes.go
  • shortcuts/apps/apps_member.go
  • shortcuts/apps/apps_member_common.go
  • shortcuts/apps/apps_member_common_test.go
  • shortcuts/apps/apps_member_response_test.go
  • shortcuts/apps/shortcuts.go
  • shortcuts/apps/shortcuts_test.go
  • skills/lark-apps/SKILL.md
  • tests/cli_e2e/apps/coverage.md
  • tests/cli_e2e/dryrun/apps_member_dryrun_test.go

Comment thread shortcuts/apps/apps_member_common_test.go
Comment thread shortcuts/apps/apps_member_common_test.go
Comment thread shortcuts/apps/apps_member_common_test.go
Comment thread tests/cli_e2e/apps/coverage.md
Comment thread tests/cli_e2e/dryrun/apps_member_dryrun_test.go
Comment thread tests/cli_e2e/dryrun/apps_member_dryrun_test.go
@yxy-bd
yxy-bd merged commit db102ab into main Aug 7, 2026
69 of 74 checks passed
@yxy-bd
yxy-bd deleted the feat/miaoda-member-permissions branch August 7, 2026 08:20
@liangshuo-1 liangshuo-1 mentioned this pull request Aug 7, 2026
3 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

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