Skip to content

fix: make agent recovery and concealment reliable - #2189

Merged
liangshuo-1 merged 9 commits into
mainfrom
fix/agent-recovery-and-concealment
Aug 5, 2026
Merged

fix: make agent recovery and concealment reliable#2189
liangshuo-1 merged 9 commits into
mainfrom
fix/agent-recovery-and-concealment

Conversation

@evandance

@evandance evandance commented Aug 5, 2026

Copy link
Copy Markdown
Collaborator

Summary

Restore the agent-facing OAuth handoff detail lost when #1837 centralized typed permission recovery, and close command-surface projection gaps exposed by that change. In the affected typed-error, auth check, MCP, and inline-result paths, user authorization now uses an explicit non-blocking two-turn device flow, while bot calls stay on bot/app/admin recovery.

The one-command blocking root/classifier wording already existed before #1837. This PR therefore does two things deliberately: it restores the shortcut operational guidance lost during centralization, and it upgrades the older central recovery to an executable --no-wait --json / --device-code flow. Error, schema, docs, and skill behavior is derived from the final build-local surface without mutating producer errors.

Changes

  • For typed user-authorization errors and auth check missing-scope suggestions, start with auth login --scope "..." --no-wait --json (or --recommend --no-wait --json only when scope context is unavailable), present verification_url to the user and end the turn, then resume with --device-code after confirmation.
  • When the server omits permission_violations, rebuild user recovery from the current command's declared scopes instead of falling back to --recommend. Server-reported scopes retain precedence, and missing_scopes remains server-owned rather than being synthesized.
  • Preserve an explicit --profile override in both generated OAuth commands, including the start and --device-code resume steps, with shell-safe argument quoting. The default profile-free output remains unchanged from this PR's existing two-turn flow.
  • Route missing_scope, token_scope_insufficient, user_unauthorized, and permission_denied by the actual calling identity. Bot messages and hints stay on app, bot, tenant, resource, or admin remediation and never recommend user OAuth.
  • Preserve MCP UAT/TAT identity through HTTP and JSON-RPC error classification, including known Lark codes, message-only authorization failures, and raw HTTP 401 responses. Unknown structured HTTP 401 errors fall back to identity-aware token_invalid recovery, while registered business codes retain their precise classification and non-401 unknown-code fallback remains unchanged.
  • Route root errors and the affected task/VC inline partial-result sinks through one build-local presenter. Presentation clones typed producers, preserves causes and machine fields, and adds only a surface-valid recovery hint; existing VC calendar_event_id and error fields remain intact.
  • Project exact schema lookup, broad listings, candidate hints, and dotted/space completion through the final command surface so concealed commands cannot be rediscovered through schema.
  • Restore docs V2 recovery with the current command's --help plus version-matched embedded skill references, honoring command concealment and skill remap/removal.
  • Validate explicit metadata.requires.skills dependencies after SkillsOverlay composition, including UTF-8-BOM frontmatter, and declare lark-doc -> lark-shared. Incomplete composed distributions fail closed without widening Allow or overriding Remove.
  • Document the validation/command_unavailable wire contract and expected consumer behavior.

Scope and compatibility

  • For existing user-identity permission paths, stable machine fields (type, subtype, code, missing_scopes, identity, and log_id) remain unchanged. Human-facing hint/suggestion intentionally changes to the two-turn flow. Bot-only informational messages are corrected where the old text named the wrong actor. Affected VC partial results gain an additive projected hint field.
  • Recovery standardization here covers framework-owned typed recovery, auth check, MCP errors, and the identified inline result sinks. It does not claim a repository-wide rewrite of every pre-existing status note, help Tips entry, or post-success business-authored login sentence; that family needs a separate semantics-aware sink audit and broader lint coverage.
  • Required-skill validation is scoped to hosts that perform SkillsOverlay composition; this PR does not introduce a separate scan for no-overlay host bases.
  • The unmerged feat(event): compile the catalog and harden the consume pipeline #2142 event dry-run issue remains intentionally out of scope.

Test Plan

  • make unit-test (race-enabled)
  • go vet ./...
  • gofmt -l . (no output)
  • go mod tidy (no go.mod / go.sum changes)
  • golangci-lint v2.1.6 with --new-from-rev=origin/main (0 issues)
  • Full tests/plugin_e2e, including external-wrapper schema concealment, remapped docs recovery, skill dependency guards, and concealed authorization fallback
  • Targeted auth, recovery, classifier, presenter, MCP, skill-policy, task, and VC tests, including executable generic/scoped login, explicit-profile start/resume commands, declared-scope fallback without machine-field mutation, bot recovery across permission subtypes, HTTP/JSON-RPC identity propagation, structured HTTP 401 fallback with registered-code precedence, UTF-8-BOM enforcement, and visible/concealed inline hints
  • Built-CLI docs dry-run E2E with the exact legacy-flag recovery envelope and empty stdout on failure
  • Final GitHub CI on the current pushed head is the required merge gate, including dry-run and live E2E

Related Issues

@evandance
evandance requested a review from liangshuo-1 as a code owner August 5, 2026 04:19
@github-actions github-actions Bot added domain/ccm PR touches the ccm domain domain/task PR touches the task domain domain/vc PR touches the vc domain size/L Large or sensitive change across domains or core paths labels Aug 5, 2026
@coderabbitai

coderabbitai Bot commented Aug 5, 2026

Copy link
Copy Markdown

Review Change Stack

Note

Reviews paused

It looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • ▶️ Resume reviews
  • 🔍 Trigger review
📝 Walkthrough

Walkthrough

The change centralizes typed error presentation, adds device-code recovery hints, projects schema catalogs by command visibility, validates skill dependencies during composition, and resolves surface-aware skill references for runtime guidance.

Changes

Surface-aware CLI behavior

Layer / File(s) Summary
Structured recovery and error presentation
internal/recovery/*, internal/cmdutil/error_presenter*, internal/errclass/*, cmd/error_presenter_test.go
Recovery hints support nested rendering and device-code authorization flows. Factory.PresentError enriches cloned typed errors without mutating source errors.
Runtime and command error integration
cmd/*, shortcuts/common/*, shortcuts/task/*, shortcuts/vc/*
Root commands and shortcut results use centralized error presentation. Tests cover structured failures and concealed authorization commands.
Visibility-aware schema projection
cmd/schema/*, cmd/build.go, tests/plugin_e2e/restrict_test.go, errs/*, extension/platform/README.md
Schema execution, resolution, validation, and completion filter concealed services, resources, and methods. The concealed-command contract documents the resulting validation error.
Skill dependency composition
internal/skillpolicy/*, skills/lark-doc/SKILL.md, tests/plugin_e2e/*, extension/platform/skillsoverlay.go
Skill manifests declare dependencies. Composition validates dependencies after overlays. Plugin tests cover missing and available dependencies.
Contextual skill references and validation guidance
shortcuts/doc/*, shortcuts/common/*, internal/cmdutil/factory.go, tests/cli_e2e/docs/*
Runtime skill references support remapping and concealment. Documentation validation errors include structured recovery guidance and typed metadata.

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

Possibly related PRs

  • larksuite/cli#1837: Both changes modify command concealment, policy-aware error presentation, skill customization, and schema visibility.
  • larksuite/cli#2109: Both changes modify task shortcut failure handling in tasklist_add_task.go and tasklist_create.go.
  • larksuite/cli#2190: Both changes modify cmd/auth/check.go and authentication recovery guidance.

Suggested labels: enhancement

Suggested reviewers: liangshuo-1

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 30.71% 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
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.
Title check ✅ Passed The title clearly summarizes the main changes: reliable agent recovery and command concealment.
Description check ✅ Passed The description includes all required sections and gives clear scope, changes, testing, compatibility, and issue context.
✨ Finishing Touches 💡 2
📝 Generate docstrings 💡
  • Create stacked PR
  • Commit on current branch
🛠️ Fix failing CI checks 💡
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/agent-recovery-and-concealment

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.

@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: 5

🧹 Nitpick comments (2)
tests/cli_e2e/docs/docs_update_dryrun_test.go (1)

250-259: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Assert that stdout stays empty on this validate-stage failure.

The test verifies exit code 2 and the typed envelope on stderr. It does not verify that stdout stays empty. A regression that writes the error to stdout would still pass.

Stream separation is a stated repository rule: send JSON program data to stdout and send hints to stderr, and never mix the two streams. Add the assertion so this new error path pins that rule.

💚 Proposed addition
 	require.NoError(t, err)
 	result.AssertExitCode(t, 2)
+	require.Empty(t, result.Stdout, "validate-stage failure must not write to stdout")
 
 	require.Equal(t, "validation", gjson.Get(result.Stderr, "error.type").String(), result.Stderr)
🤖 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 `@tests/cli_e2e/docs/docs_update_dryrun_test.go` around lines 250 - 259, Add an
assertion in the validate-stage failure test around the existing
result.AssertExitCode and stderr envelope checks to verify result.Stdout is
empty. Keep the current stderr assertions unchanged and pin the
stream-separation rule for this error path.

Source: Coding guidelines

internal/skillpolicy/resolver_test.go (1)

364-372: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Add coverage for the two new fail-closed manifest paths.

This PR introduces two abort conditions that no test exercises:

  1. parseRequiredSkills returns "SKILL.md frontmatter is not closed" when an opening --- has no closing --- (internal/skillpolicy/dependencies.go lines 58-60).
  2. parseRequiredSkills rejects a dependency that fails isSkillName (internal/skillpolicy/dependencies.go lines 77-79).

Both surface through scanSkillTree as "skill %q has invalid metadata" and abort the build. The unclosed-frontmatter path applies to the host base tree, so it can break an existing overlay distribution. Add tests so a later relaxation of either rule fails.

💚 Proposed tests
+func TestResolve_UnclosedFrontmatterFailsClosed(t *testing.T) {
+	base := skillFS(map[string]string{
+		"lark-a/SKILL.md": "---\nmetadata:\n  requires:\n    skills: [\"lark-shared\"]\nbase a",
+	})
+	_, err := resolveContent(base, []PluginSkill{{
+		PluginName:    "acme",
+		SkillsOverlay: &platform.SkillsOverlay{Allow: []string{"lark-a"}},
+	}})
+	if err == nil {
+		t.Fatal("unclosed frontmatter unexpectedly resolved")
+	}
+	for _, want := range []string{"lark-a", "invalid metadata"} {
+		if !strings.Contains(err.Error(), want) {
+			t.Errorf("error %q does not identify %q", err, want)
+		}
+	}
+}
+
+func TestResolve_InvalidRequiredSkillNameFailsClosed(t *testing.T) {
+	base := skillFS(map[string]string{
+		"lark-a/SKILL.md": "---\nmetadata:\n  requires:\n    skills: [\"../escape\"]\n---\nbase a",
+	})
+	_, err := resolveContent(base, []PluginSkill{{
+		PluginName:    "acme",
+		SkillsOverlay: &platform.SkillsOverlay{Allow: []string{"lark-a"}},
+	}})
+	if err == nil {
+		t.Fatal("invalid required skill name unexpectedly resolved")
+	}
+	if !strings.Contains(err.Error(), "../escape") {
+		t.Errorf("error %q does not identify the invalid dependency", err)
+	}
+}
🤖 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 `@internal/skillpolicy/resolver_test.go` around lines 364 - 372, Add resolver
tests covering both fail-closed manifest paths through scanSkillTree: an
unclosed frontmatter block in the host base tree and a dependency name rejected
by isSkillName. Assert each causes resolution to abort with the existing “skill
%q has invalid metadata” error, using the setup patterns from
TestResolve_DoesNotInferDependenciesFromMarkdownLinks.

Source: Coding guidelines

🤖 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 `@cmd/error_presenter_test.go`:
- Around line 26-34: Strengthen the listed error-path tests to validate typed
metadata and cause preservation, not only rendered hints: in
cmd/error_presenter_test.go lines 26-34 assert errs.ProblemOf succeeds, then
verify the expected category and subtype and add a wrapped cause checked with
errors.Is; in internal/errclass/hint_gate_test.go lines 23-68 assert the
rendered permission error’s category and subtype and preserve a wrapped cause;
in cmd/root_test.go lines 546-562 assert the authentication subtype and
NeedAuthorizationError cause, lines 584-591 and 613-620 assert the
authentication category and subtype, and lines 644-655 assert category, subtype,
and the existing error chain. Use errors.As for Param only where the concrete
error type exposes it.

In `@internal/cmdutil/error_presenter_test.go`:
- Around line 16-58: Update
TestFactoryPresentErrorClonesAndPreservesPermissionMachineFields to attach a
sentinel cause to source and assert the presented error preserves it. Use
errs.ProblemOf on the presented error to verify the expected category, subtype,
and param metadata, while retaining the existing clone and field-preservation
checks.

In `@shortcuts/doc/v2_only_test.go`:
- Around line 42-56: Strengthen the typed validation assertions in
shortcuts/doc/v2_only_test.go:42-56 by checking problem.Category is
CategoryValidation and problem.Subtype is SubtypeInvalidArgument through
errs.ProblemOf, while retaining the existing errors.As assertion for
*errs.ValidationError and its --mode Param. Apply the same category and subtype
assertions in shortcuts/doc/docs_create_test.go:285-297 and assert its
validation Param is --markdown; in shortcuts/doc/docs_update_test.go:238-244,
assert the category, subtype, and --mode Param.

In `@tests/plugin_e2e/harness.go`:
- Around line 131-139: Replace the direct os.MkdirAll call in the fixture setup
loop with the corresponding internal/vfs directory-creation API, preserving the
existing path, permissions, error handling, and t.Fatalf behavior. Update any
required import or helper usage in the surrounding harness code without changing
unrelated filesystem operations.

In `@tests/plugin_e2e/skills_test.go`:
- Around line 272-282: Update the assertions in the affected test to parse the
documented JSON fields from res.stderr with gjson instead of checking raw
substrings. Assert the exact reason code field equals invalid_skills_overlay and
verify the affected-skills field contains exactly lark-doc and lark-shared,
while preserving the existing error.type and error.subtype assertions.

---

Nitpick comments:
In `@internal/skillpolicy/resolver_test.go`:
- Around line 364-372: Add resolver tests covering both fail-closed manifest
paths through scanSkillTree: an unclosed frontmatter block in the host base tree
and a dependency name rejected by isSkillName. Assert each causes resolution to
abort with the existing “skill %q has invalid metadata” error, using the setup
patterns from TestResolve_DoesNotInferDependenciesFromMarkdownLinks.

In `@tests/cli_e2e/docs/docs_update_dryrun_test.go`:
- Around line 250-259: Add an assertion in the validate-stage failure test
around the existing result.AssertExitCode and stderr envelope checks to verify
result.Stdout is empty. Keep the current stderr assertions unchanged and pin the
stream-separation rule for this error path.
🪄 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: f6972560-3a88-4608-a411-57bdb6b3e63d

📥 Commits

Reviewing files that changed from the base of the PR and between ebdeda8 and c32811c.

📒 Files selected for processing (40)
  • cmd/build.go
  • cmd/error_auth_hint.go
  • cmd/error_presenter_test.go
  • cmd/root.go
  • cmd/root_test.go
  • cmd/schema/schema.go
  • cmd/schema/schema_test.go
  • errs/ERROR_CONTRACT.md
  • extension/platform/README.md
  • extension/platform/skillsoverlay.go
  • internal/cmdutil/error_presenter.go
  • internal/cmdutil/error_presenter_test.go
  • internal/cmdutil/factory.go
  • internal/cmdutil/factory_test.go
  • internal/errclass/classify.go
  • internal/errclass/hint_gate_test.go
  • internal/recovery/hint.go
  • internal/recovery/hint_test.go
  • internal/skillpolicy/dependencies.go
  • internal/skillpolicy/overlay.go
  • internal/skillpolicy/resolver.go
  • internal/skillpolicy/resolver_test.go
  • shortcuts/common/runner.go
  • shortcuts/common/skill_references.go
  • shortcuts/doc/docs_create_test.go
  • shortcuts/doc/docs_fetch_v2_test.go
  • shortcuts/doc/docs_update_test.go
  • shortcuts/doc/v2_only.go
  • shortcuts/doc/v2_only_test.go
  • shortcuts/task/tasklist_add_task.go
  • shortcuts/task/tasklist_add_task_test.go
  • shortcuts/task/tasklist_create.go
  • shortcuts/task/tasklist_create_test.go
  • shortcuts/vc/vc_notes.go
  • shortcuts/vc/vc_notes_test.go
  • skills/lark-doc/SKILL.md
  • tests/cli_e2e/docs/docs_update_dryrun_test.go
  • tests/plugin_e2e/harness.go
  • tests/plugin_e2e/restrict_test.go
  • tests/plugin_e2e/skills_test.go

Comment thread cmd/error_presenter_test.go
Comment thread internal/cmdutil/error_presenter_test.go
Comment thread shortcuts/doc/v2_only_test.go
Comment thread tests/plugin_e2e/harness.go
Comment thread tests/plugin_e2e/skills_test.go
@github-actions

github-actions Bot commented Aug 5, 2026

Copy link
Copy Markdown

🚀 PR Preview Install Guide

🧰 CLI update

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

🧩 Skill update

npx skills add larksuite/cli#fix/agent-recovery-and-concealment -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: 1

🤖 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 `@internal/skillpolicy/resolver_test.go`:
- Around line 382-389: Strengthen both invalid-host-base error-path tests around
ErrInvalidHostBase to verify typed metadata, not just message text. Use
errs.ProblemOf(err) to assert the expected Category and Subtype, extract
*errs.ValidationError with errors.As to verify Param, and assert the expected
wrapped parse or validation cause with errors.Is or errors.As. Retain the
existing ErrInvalidHostBase sentinel and message assertions as supplementary
checks.
🪄 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: 28fe8693-037e-45ad-a4ce-8620bdd34228

📥 Commits

Reviewing files that changed from the base of the PR and between 0c5ee0e and 4cbcba4.

📒 Files selected for processing (11)
  • cmd/error_presenter_test.go
  • cmd/root_test.go
  • internal/cmdutil/error_presenter_test.go
  • internal/errclass/hint_gate_test.go
  • internal/skillpolicy/resolver_test.go
  • shortcuts/doc/docs_create_test.go
  • shortcuts/doc/docs_update_test.go
  • shortcuts/doc/v2_only_test.go
  • tests/cli_e2e/docs/docs_update_dryrun_test.go
  • tests/plugin_e2e/harness.go
  • tests/plugin_e2e/skills_test.go
🚧 Files skipped from review as they are similar to previous changes (10)
  • shortcuts/doc/docs_update_test.go
  • internal/errclass/hint_gate_test.go
  • tests/plugin_e2e/skills_test.go
  • tests/plugin_e2e/harness.go
  • internal/cmdutil/error_presenter_test.go
  • cmd/root_test.go
  • shortcuts/doc/docs_create_test.go
  • cmd/error_presenter_test.go
  • tests/cli_e2e/docs/docs_update_dryrun_test.go
  • shortcuts/doc/v2_only_test.go

Comment thread internal/skillpolicy/resolver_test.go
@codecov

codecov Bot commented Aug 5, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 80.57260% with 95 lines in your changes missing coverage. Please review.
✅ Project coverage is 76.00%. Comparing base (0848a5b) to head (aa7f9e3).

Files with missing lines Patch % Lines
internal/cmdutil/error_presenter.go 58.57% 23 Missing and 6 partials ⚠️
shortcuts/common/skill_references.go 0.00% 17 Missing ⚠️
internal/recovery/hint.go 66.66% 10 Missing and 1 partial ⚠️
cmd/schema/schema.go 89.74% 6 Missing and 2 partials ⚠️
internal/skillpolicy/dependencies.go 84.90% 4 Missing and 4 partials ⚠️
shortcuts/common/mcp_client.go 87.23% 4 Missing and 2 partials ⚠️
internal/recovery/projector.go 37.50% 4 Missing and 1 partial ⚠️
cmd/build.go 50.00% 2 Missing and 1 partial ⚠️
internal/recovery/context.go 83.33% 2 Missing and 1 partial ⚠️
shortcuts/common/runner.go 87.50% 1 Missing and 1 partial ⚠️
... and 3 more
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #2189      +/-   ##
==========================================
+ Coverage   75.92%   76.00%   +0.07%     
==========================================
  Files         962      966       +4     
  Lines      102197   102541     +344     
==========================================
+ Hits        77591    77933     +342     
+ Misses      18716    18704      -12     
- Partials     5890     5904      +14     

☔ View full report in Codecov by Harness.
📢 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.

@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: 1

🤖 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 `@cmd/error_presenter_test.go`:
- Around line 106-123: Update the test around the presented permission error to
obtain problem metadata via errs.ProblemOf(rendered), and assert Category and
Subtype from that result instead of presented. Keep the concrete
*errs.PermissionError assertion for Hint, Message, Identity, and MissingScopes,
and preserve the existing errors.Is cause assertion.
🪄 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: 76c6708d-e217-4752-86ef-74e973f858cd

📥 Commits

Reviewing files that changed from the base of the PR and between 4cbcba4 and dd14eb5.

📒 Files selected for processing (3)
  • cmd/error_presenter_test.go
  • cmd/skill_customization_test.go
  • tests/plugin_e2e/skills_test.go
🚧 Files skipped from review as they are similar to previous changes (1)
  • tests/plugin_e2e/skills_test.go

Comment thread cmd/error_presenter_test.go
@evandance

Copy link
Copy Markdown
Collaborator Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented Aug 5, 2026

Copy link
Copy Markdown
✅ Action performed

Review finished.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@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: 3

🤖 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 `@cmd/auth/check_test.go`:
- Around line 205-207: Isolate the test’s configuration state by setting
LARKSUITE_CLI_CONFIG_DIR to t.TempDir() with t.Setenv at the start of the test
containing the default suggestion assertion, before calling
cmdutil.TestFactory(t, cfg).

In `@shortcuts/common/mcp_client.go`:
- Around line 125-126: Replace the generic payload decoding in the
response-handling flow around json.Unmarshal with a typed MCP error envelope,
defining one projection function for each supported HTTP error shape. Decode
directly into the appropriate typed structure so numeric fields and error
properties are handled explicitly rather than through map[string]interface{}.
- Around line 134-145: Update the MCP error handling around
classifyMCPPayloadError and the hasBusinessError fallback so HTTP 401 responses
with unknown structured codes reach the existing AuthenticationError and
withMCPAuthenticationRecovery path before any generic APIError return. Preserve
classification for known business codes, and add coverage for both top-level and
JSON-RPC error payloads containing unknown codes.
🪄 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: 8a1fb4ff-d5bc-408e-b37e-94c2c680e454

📥 Commits

Reviewing files that changed from the base of the PR and between dd14eb5 and 8704958.

📒 Files selected for processing (23)
  • cmd/auth/check.go
  • cmd/auth/check_test.go
  • cmd/auth/login.go
  • cmd/auth/login_messages.go
  • cmd/auth/login_messages_test.go
  • cmd/auth/login_test.go
  • cmd/error_presenter_test.go
  • cmd/root_test.go
  • cmd/skill_customization_test.go
  • internal/cmdutil/error_presenter.go
  • internal/errclass/classify.go
  • internal/errclass/classify_test.go
  • internal/recovery/hint.go
  • internal/recovery/hint_test.go
  • internal/skillpolicy/dependencies.go
  • internal/skillpolicy/resolver_test.go
  • shortcuts/common/mcp_client.go
  • shortcuts/common/mcp_client_test.go
  • shortcuts/task/tasklist_create_test.go
  • shortcuts/vc/vc_calendar_event_recovery_test.go
  • shortcuts/vc/vc_notes.go
  • shortcuts/vc/vc_recording.go
  • skills/lark-shared/SKILL.md
🚧 Files skipped from review as they are similar to previous changes (7)
  • shortcuts/task/tasklist_create_test.go
  • cmd/skill_customization_test.go
  • internal/recovery/hint_test.go
  • internal/cmdutil/error_presenter.go
  • internal/recovery/hint.go
  • cmd/error_presenter_test.go
  • internal/skillpolicy/dependencies.go

Comment thread cmd/auth/check_test.go
Comment thread shortcuts/common/mcp_client.go
Comment thread shortcuts/common/mcp_client.go Outdated
@evandance
evandance force-pushed the fix/agent-recovery-and-concealment branch from 8704958 to eb663cc Compare August 5, 2026 07:54
@coderabbitai coderabbitai Bot mentioned this pull request Aug 5, 2026
5 tasks
@evandance
evandance force-pushed the fix/agent-recovery-and-concealment branch from eb663cc to d524df1 Compare August 5, 2026 10:36
@evandance
evandance force-pushed the fix/agent-recovery-and-concealment branch from d524df1 to aa7f9e3 Compare August 5, 2026 10:46
@liangshuo-1
liangshuo-1 merged commit 09feefe into main Aug 5, 2026
27 checks passed
@liangshuo-1
liangshuo-1 deleted the fix/agent-recovery-and-concealment branch August 5, 2026 11:44
sang-neo03 added a commit that referenced this pull request Aug 5, 2026
Reverts the unattended-login change: auth login no longer decides whether
to block from whether stdout is a terminal, and the --wait flag it added
is gone. The owner asked for this to land as its own change rather than
riding along with the token fixes.

Reverted to the merge base, not to origin/main. login.go and
login_test.go moved on main after this branch forked (#2189), and taking
those files from origin/main would have pulled that work in under a
revert commit. Merging main will bring it in on its own.

This also undoes a mistake of mine: main already emits
`"event": "device_authorization"` in the --no-wait payload. The reverted
change had dropped that field while rewriting the block, and I "restored"
it under a different name (authorization_requested), which would have
broken any caller matching on the original value. Reverting the file
restores the original name.

Still in this PR: the corrupted / expired stored-token fixes, and bot
auth for docs +search, base +title-resolve and vc +detail.
@liangshuo-1 liangshuo-1 mentioned this pull request Aug 5, 2026
3 tasks
zkh-bytedance pushed a commit that referenced this pull request Aug 6, 2026
Co-authored-by: TRAE CLI <traecli@bytedance.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

domain/ccm PR touches the ccm domain domain/task PR touches the task domain domain/vc PR touches the vc 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