Skip to content

test#1295

Open
SunPeiYang996 wants to merge 5 commits into
mainfrom
sun/pre
Open

test#1295
SunPeiYang996 wants to merge 5 commits into
mainfrom
sun/pre

Conversation

@SunPeiYang996
Copy link
Copy Markdown
Collaborator

@SunPeiYang996 SunPeiYang996 commented Jun 5, 2026

Summary

Changes

  • Change 1
  • Change 2

Test Plan

  • Unit tests pass
  • Manual local verification confirms the lark-cli <domain> <command> flow works as expected

Related Issues

  • None

Summary by CodeRabbit

  • New Features

    • Added a new skills command for listing and reading embedded skill documentation.
    • Skill content is now embedded directly in the CLI binary.
  • Chores

    • Migrated docs shortcuts (+create, +fetch, +update) exclusively to v2 API; v1 (MCP) support removed.
    • Simplified embedded skill documentation structure.

dc-bytedance and others added 5 commits June 5, 2026 14:41
Add a top-level `lark-cli skills` meta command group that reads skill
content compiled into the binary at build time via go:embed, so the
content an AI agent reads always matches the running CLI version. It is
an additional, version-consistent source and a fallback for when skills
are not installed or are stale; it does not replace or thin the on-disk
skills.

Commands:
- `skills list` lists every embedded skill with name, description, and
  the frontmatter metadata block.
- `skills list <name>` / `skills list <name>/<sub>` list one directory
  layer (ls-style, no recursion); entries are skill-prefixed paths that
  can be fed straight back to `read`.
- `skills read <name>` prints the skill's SKILL.md and appends a one-line
  tip steering the model to fetch reference files via this command.
- `skills read <name> <path>` / `skills read <name>/<path>` print any
  file under the skill directory (no tip).
- `--json` wraps output in an envelope; on the main SKILL.md it carries a
  separate `guidance` field instead of merging the tip into content.

Implementation:
- skills/ is embedded from the repo-root package main (go:embed cannot
  cross parent dirs) and injected into cmd/skill via a package variable,
  avoiding any change to cmd.Execute's signature.
- internal/skillcontent is pure logic over an injected fs.FS; reference
  reads and directory listings share one path-traversal guard that
  rejects absolute paths, "..", and "..\\" escapes.
- Errors are typed (validation -> exit 2, file_io -> exit 5); rejected
  paths never write anything to stdout.

Risk is set per leaf subcommand (read); the group carries none, matching
the config/service command groups. The commands need no auth (local
embed reads only).
Set LARKSUITE_CLI_CONFIG_DIR to a per-test temp dir in the shared run()
helper so the command tests never touch the real config dir, matching
the repo-wide test convention. Addresses a CodeRabbit review comment.
1
Change-Id: Ib47c17c0f12d5b6cde75b59d70c54c9b513c916d
Change-Id: I4ba566e0c3ab5d13c399d27559162a6587dde664
Change-Id: I628eb83e36e1fb662456a00d1ff67643e9334c87
@github-actions github-actions Bot added domain/ccm PR touches the ccm domain size/XL Architecture-level or global-impact change labels Jun 5, 2026
@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Jun 5, 2026

Review Change Stack

📝 Walkthrough

Walkthrough

The PR introduces an embedded skills CLI subsystem for accessing skill documentation and migrates all docs shortcuts from dual V1/V2 support to v2-only with improved help guidance. Legacy V1 (MCP) runtime paths, semantic warnings, and versioned help are removed. The skills system is wired into the CLI command tree and provides list and read operations over embedded skill content.

Changes

Skills System & Docs V2-Only Migration

Layer / File(s) Summary
Embedded Skills System & CLI Command
skills_embed.go, cmd/build.go, cmd/skill/skill.go, cmd/skill/skill_test.go
Build-time embedding of skills/ directory and runtime initialization of skill.ContentFS; new skills list and skills read subcommands with JSON envelope support and guidance injection for main SKILL.md files; comprehensive test coverage for listing, reading, error handling, and traversal rejection.
Skill Content Reader Implementation & Tests
internal/skillcontent/reader.go, internal/skillcontent/reader_test.go
Reader type with List, ListPath, ReadSkill, and ReadReference methods; YAML frontmatter extraction for skill metadata; path-traversal validation; best-effort error handling via typed errors; unit tests cover frontmatter parsing variants, file/directory distinction, and missing-file scenarios.
V2-Only Validation Framework & Tests
shortcuts/doc/v2_only.go, shortcuts/doc/v2_only_test.go, shortcuts/doc/code_fence.go
New validateDocsV2Only function validates --api-version allowing only blank/v2, detects legacy v1 flag changes, and returns formatted errors; legacy flag metadata and hidden flag definitions for create/fetch/update; test coverage for allowed defaults, v1 rejection, and legacy flag detection.
Docs +create Migration to V2-Only
shortcuts/doc/docs_create.go, shortcuts/doc/docs_create_v2.go, shortcuts/doc/docs_create_test.go
Routes docs +create exclusively to v2 handlers; exposes content, doc-format, parent-token flags; adds early v2-only validation; removes v1 (MCP) conditional routing and large v1 implementation helpers; new tests reject v1 API version and legacy flags (--title, --markdown).
Docs +fetch Migration to V2-Only
shortcuts/doc/docs_fetch.go, shortcuts/doc/docs_fetch_v2.go, shortcuts/doc/docs_fetch_v2_test.go
Shifts docs +fetch to v2-only execution; exposes --doc-format, --detail, --revision-id, --scope, --start-block-id, --end-block-id, --keyword, --context-before/after, --max-depth with improved descriptions; adds test coverage for v2 endpoint defaults and v1/legacy-flag rejection.
Docs +update Migration to V2-Only
shortcuts/doc/docs_update.go, shortcuts/doc/docs_update_v2.go, shortcuts/doc/docs_update_test.go
Routes docs +update exclusively to v2; exposes command, doc-format, content, pattern, block-id, src-block-ids, revision-id; adds early v2-only validation; removes v1 (MCP) paths and semantic-warning infrastructure (docs_update_check.go/test.go deleted); new tests validate v2 dry-run and v1/legacy-flag rejection.
Unified Docs Help & Embedded Skill Guidance
shortcuts/doc/shortcuts.go, shortcuts/register_test.go, skills/lark-doc/SKILL.md
Unifies docs shortcut help to reference embedded skill read commands; removes API-version-dependent help/tips; adds docsSkillReadCommandForShortcut mapping; updates lark-doc description to remove v1 requirement and add docs --help prerequisite; deletes versioned_help.go/test.go; updates help assertions to verify "Start here" guidance and skill commands.
E2E Test Updates for V2 Behavior
tests/cli_e2e/docs/coverage.md, tests/cli_e2e/docs/docs_create_fetch_test.go, tests/cli_e2e/docs/docs_update_dryrun_test.go, tests/cli_e2e/docs/docs_update_test.go, tests/cli_e2e/docs/helpers_test.go
Updates create/fetch/update test invocations to use v2 flag/content formats (--parent-token, --doc-format, --command); changes result-extraction paths from data.title to data.document.content; replaces semantic-warning suppression test with v2 endpoint verification; removes MCP stub helpers.

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~60 minutes

Possibly related PRs

  • larksuite/cli#569: Removes semantic-warning checks in docs_update_check.go/docs_update_check_test.go and shifts docs +update to v2-only execution.
  • larksuite/cli#890: Modifies docs help wiring in shortcuts/doc/shortcuts.go and updates lark-doc skill description for v2 guidance.
  • larksuite/cli#710: Changes docs shortcut help configuration in shortcuts/doc/shortcuts.go and help assertion expectations in shortcuts/register_test.go.

Suggested labels

size/XL, domain/ccm

Suggested reviewers

  • fangshuyu-768
  • MaxHuang22

🐰 A new skill system hops into view,
V2 docs shortcuts now all true—
MCP paths fade away with grace,
While embedded wisdom claims its place!

🚥 Pre-merge checks | ✅ 2 | ❌ 3

❌ Failed checks (3 warnings)

Check name Status Explanation Resolution
Title check ⚠️ Warning The PR title 'test' is generic and non-descriptive, failing to convey the primary change of adding a skills CLI command system. Replace with a descriptive title like 'Add skills CLI command group with embedded skill content' or 'Implement lark-cli skills command with embedded skills support'.
Description check ⚠️ Warning The PR description is almost entirely empty, containing only unused template placeholders without any actual content describing the changes, motivation, or testing approach. Fill in the Summary section with the actual motivation (version-consistent skill fallback), describe the specific changes (skills list/read commands, path-traversal guards), explain testing approach, and link related issues if applicable.
Docstring Coverage ⚠️ Warning Docstring coverage is 27.47% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 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.

✏️ 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 sun/pre

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
Copy link
Copy Markdown

github-actions Bot commented Jun 5, 2026

🚀 PR Preview Install Guide

🧰 CLI update

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

🧩 Skill update

npx skills add larksuite/cli#sun/pre -y -g

@codecov
Copy link
Copy Markdown

codecov Bot commented Jun 5, 2026

Codecov Report

❌ Patch coverage is 88.29787% with 44 lines in your changes missing coverage. Please review.
✅ Project coverage is 70.66%. Comparing base (f3949f0) to head (65b80ce).
⚠️ Report is 3 commits behind head on main.

Files with missing lines Patch % Lines
internal/skillcontent/reader.go 89.28% 7 Missing and 5 partials ⚠️
shortcuts/doc/code_fence.go 67.56% 8 Missing and 4 partials ⚠️
cmd/skill/skill.go 92.15% 4 Missing and 4 partials ⚠️
shortcuts/doc/shortcuts.go 88.00% 3 Missing ⚠️
shortcuts/doc/docs_fetch.go 50.00% 2 Missing ⚠️
shortcuts/doc/docs_update.go 50.00% 2 Missing ⚠️
shortcuts/doc/v2_only.go 96.36% 2 Missing ⚠️
skills_embed.go 60.00% 1 Missing and 1 partial ⚠️
shortcuts/doc/docs_create.go 75.00% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1295      +/-   ##
==========================================
+ Coverage   70.33%   70.66%   +0.33%     
==========================================
  Files         672      680       +8     
  Lines       65322    65477     +155     
==========================================
+ Hits        45941    46272     +331     
+ Misses      15728    15532     -196     
- Partials     3653     3673      +20     

☔ 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.

Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (3)
skills/lark-doc/SKILL.md (1)

7-12: ⚠️ Potential issue | 🟡 Minor | ⚡ Quick win

Update stale --api-version guidance to match current docs command surface.

Line 7 still recommends lark-cli docs --api-version v2 --help, but the docs parent command no longer exposes a service-level --api-version. Line 12 also states the shortcut commands must carry --api-version v2, which is now misleading for v2-default flows. Please align this section with the current help contract to avoid directing users/agents to invalid or unnecessary invocation patterns.

Suggested patch
-  cliHelp: "lark-cli docs --api-version v2 --help; lark-cli docs +create --api-version v2 --help; lark-cli docs +fetch --api-version v2 --help; lark-cli docs +update --api-version v2 --help"
+  cliHelp: "lark-cli docs --help; lark-cli docs +create --help; lark-cli docs +fetch --help; lark-cli docs +update --help"
@@
-> **⚠️ API 版本:本 skill 使用 v2 API。所有 `docs +create --api-version v2`、`docs +fetch --api-version v2`、`docs +update --api-version v2` 命令必须携带 `--api-version v2`。**
+> **⚠️ API 版本:本 skill 使用 v2 API。`docs +create` / `docs +fetch` / `docs +update` 默认走 v2;如需显式声明可附加 `--api-version v2`。**
🤖 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 `@skills/lark-doc/SKILL.md` around lines 7 - 12, Update the stale guidance that
tells users to run the parent command with --api-version v2: modify the cliHelp
string (the "cliHelp" entry) and the docs vignette under the "docs (v2)" heading
so it no longer instructs using `lark-cli docs --api-version v2` or claims
subcommands "must" carry the flag; instead state that v2 is the default for this
skill and that only when invoking a non-default API version should callers add
`--api-version`, or explicitly indicate that `docs +create|+fetch|+update
--api-version v2` is optional when v2 is default. Ensure the text and examples
consistently reflect the current help contract and remove any reference to a
service-level --api-version on the parent `docs` command.
tests/cli_e2e/docs/docs_update_dryrun_test.go (1)

16-24: ⚠️ Potential issue | 🟡 Minor | ⚡ Quick win

Add config-dir isolation to this E2E test setup.

Set t.Setenv("LARKSUITE_CLI_CONFIG_DIR", t.TempDir()) to avoid cross-test config coupling.

As per coding guidelines **/*_test.go: Use t.Setenv("LARKSUITE_CLI_CONFIG_DIR", t.TempDir()) to isolate config state in tests.

🤖 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 16 - 24, The test
TestDocs_DryRunDefaultsToV2OpenAPI needs to isolate CLI config state; add a call
to set the config dir to a temp directory by invoking
t.Setenv("LARKSUITE_CLI_CONFIG_DIR", t.TempDir()) in the test setup (near where
other t.Setenv calls are made) so the test uses its own config directory and
avoids cross-test coupling.
tests/cli_e2e/docs/docs_create_fetch_test.go (1)

19-22: 🛠️ Refactor suggestion | 🟠 Major | ⚡ Quick win

Add per-test config-dir isolation at test startup.

Both test entry points should set LARKSUITE_CLI_CONFIG_DIR to a temp directory to avoid shared config bleed across test runs.

As per coding guidelines, **/*_test.go: use t.Setenv("LARKSUITE_CLI_CONFIG_DIR", t.TempDir()) to isolate config state in tests.

Also applies to: 56-60

🤖 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_create_fetch_test.go` around lines 19 - 22, Add
per-test config-dir isolation by setting the LARKSUITE_CLI_CONFIG_DIR env to a
fresh temp dir at test startup: in TestDocs_CreateAndFetchWorkflowAsBot (and
other test entry points mentioned around lines 56-60) call
t.Setenv("LARKSUITE_CLI_CONFIG_DIR", t.TempDir()) immediately after creating the
test context so each test gets an isolated config directory and avoids shared
config bleed.
🧹 Nitpick comments (1)
shortcuts/doc/docs_update_v2.go (1)

13-39: ⚡ Quick win

Unify command definitions to one source of truth.

validCommandsV2 and validCommandsV2Keys() duplicate the same command list. If one side changes first, flag enum/help and runtime validation can diverge.

Proposed refactor
+var validCommandsV2List = []string{
+	"str_replace",
+	"block_delete",
+	"block_insert_after",
+	"block_copy_insert_after",
+	"block_replace",
+	"block_move_after",
+	"overwrite",
+	"append",
+}
+
 var validCommandsV2 = map[string]bool{
-	"str_replace":             true,
-	"block_delete":            true,
-	"block_insert_after":      true,
-	"block_copy_insert_after": true,
-	"block_replace":           true,
-	"block_move_after":        true,
-	"overwrite":               true,
-	"append":                  true,
+}
+
+func init() {
+	for _, c := range validCommandsV2List {
+		validCommandsV2[c] = true
+	}
 }
@@
 func validCommandsV2Keys() []string {
-	return []string{"str_replace", "block_delete", "block_insert_after", "block_copy_insert_after", "block_replace", "block_move_after", "overwrite", "append"}
+	return append([]string(nil), validCommandsV2List...)
 }
🤖 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/doc/docs_update_v2.go` around lines 13 - 39, validCommandsV2 and
validCommandsV2Keys duplicate the same list causing drift; consolidate to a
single source of truth (e.g., a single slice variable like validCommandsV2Keys)
and derive the map and the v2UpdateFlags Enum from that slice: keep one
canonical slice (referenced by validCommandsV2Keys), update v2UpdateFlags to use
that slice for the Flag Enum, and build validCommandsV2 map programmatically
from the slice for runtime validation (refer to symbols validCommandsV2,
validCommandsV2Keys, and v2UpdateFlags).
🤖 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 `@tests/cli_e2e/docs/docs_update_dryrun_test.go`:
- Around line 70-84: The test currently concatenates result.Stdout and
result.Stderr into combined and asserts request-shape strings against that;
update the assertions to check only result.Stdout (not combined) for the
positive expectations (tt.wantURL and "docs_ai/v1") and for the negative checks
("/mcp", "MCP tool", "--api-version") so that JSON envelope output is validated
strictly from result.Stdout while stderr remains separate.

---

Outside diff comments:
In `@skills/lark-doc/SKILL.md`:
- Around line 7-12: Update the stale guidance that tells users to run the parent
command with --api-version v2: modify the cliHelp string (the "cliHelp" entry)
and the docs vignette under the "docs (v2)" heading so it no longer instructs
using `lark-cli docs --api-version v2` or claims subcommands "must" carry the
flag; instead state that v2 is the default for this skill and that only when
invoking a non-default API version should callers add `--api-version`, or
explicitly indicate that `docs +create|+fetch|+update --api-version v2` is
optional when v2 is default. Ensure the text and examples consistently reflect
the current help contract and remove any reference to a service-level
--api-version on the parent `docs` command.

In `@tests/cli_e2e/docs/docs_create_fetch_test.go`:
- Around line 19-22: Add per-test config-dir isolation by setting the
LARKSUITE_CLI_CONFIG_DIR env to a fresh temp dir at test startup: in
TestDocs_CreateAndFetchWorkflowAsBot (and other test entry points mentioned
around lines 56-60) call t.Setenv("LARKSUITE_CLI_CONFIG_DIR", t.TempDir())
immediately after creating the test context so each test gets an isolated config
directory and avoids shared config bleed.

In `@tests/cli_e2e/docs/docs_update_dryrun_test.go`:
- Around line 16-24: The test TestDocs_DryRunDefaultsToV2OpenAPI needs to
isolate CLI config state; add a call to set the config dir to a temp directory
by invoking t.Setenv("LARKSUITE_CLI_CONFIG_DIR", t.TempDir()) in the test setup
(near where other t.Setenv calls are made) so the test uses its own config
directory and avoids cross-test coupling.

---

Nitpick comments:
In `@shortcuts/doc/docs_update_v2.go`:
- Around line 13-39: validCommandsV2 and validCommandsV2Keys duplicate the same
list causing drift; consolidate to a single source of truth (e.g., a single
slice variable like validCommandsV2Keys) and derive the map and the
v2UpdateFlags Enum from that slice: keep one canonical slice (referenced by
validCommandsV2Keys), update v2UpdateFlags to use that slice for the Flag Enum,
and build validCommandsV2 map programmatically from the slice for runtime
validation (refer to symbols validCommandsV2, validCommandsV2Keys, and
v2UpdateFlags).
🪄 Autofix (Beta)

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

Run ID: 026ba463-f61a-4b10-a00d-8b37abcc615f

📥 Commits

Reviewing files that changed from the base of the PR and between 37b17f3 and 65b80ce.

📒 Files selected for processing (38)
  • cmd/build.go
  • cmd/skill/skill.go
  • cmd/skill/skill_test.go
  • internal/skillcontent/reader.go
  • internal/skillcontent/reader_test.go
  • shortcuts/doc/code_fence.go
  • shortcuts/doc/docs_create.go
  • shortcuts/doc/docs_create_test.go
  • shortcuts/doc/docs_create_v2.go
  • shortcuts/doc/docs_fetch.go
  • shortcuts/doc/docs_fetch_v2.go
  • shortcuts/doc/docs_fetch_v2_test.go
  • shortcuts/doc/docs_update.go
  • shortcuts/doc/docs_update_check.go
  • shortcuts/doc/docs_update_check_test.go
  • shortcuts/doc/docs_update_test.go
  • shortcuts/doc/docs_update_v2.go
  • shortcuts/doc/shortcuts.go
  • shortcuts/doc/v2_only.go
  • shortcuts/doc/v2_only_test.go
  • shortcuts/doc/versioned_help.go
  • shortcuts/doc/versioned_help_test.go
  • shortcuts/register_test.go
  • skills/lark-doc/SKILL.md
  • skills/lark-doc/references/lark-doc-create.md
  • skills/lark-doc/references/lark-doc-fetch.md
  • skills/lark-doc/references/lark-doc-md.md
  • skills/lark-doc/references/lark-doc-update.md
  • skills/lark-doc/references/lark-doc-xml.md
  • skills/lark-doc/references/style/lark-doc-create-workflow.md
  • skills/lark-doc/references/style/lark-doc-style.md
  • skills/lark-doc/references/style/lark-doc-update-workflow.md
  • skills_embed.go
  • tests/cli_e2e/docs/coverage.md
  • tests/cli_e2e/docs/docs_create_fetch_test.go
  • tests/cli_e2e/docs/docs_update_dryrun_test.go
  • tests/cli_e2e/docs/docs_update_test.go
  • tests/cli_e2e/docs/helpers_test.go
💤 Files with no reviewable changes (12)
  • skills/lark-doc/references/lark-doc-create.md
  • skills/lark-doc/references/style/lark-doc-style.md
  • skills/lark-doc/references/style/lark-doc-create-workflow.md
  • skills/lark-doc/references/style/lark-doc-update-workflow.md
  • shortcuts/doc/docs_update_check_test.go
  • shortcuts/doc/versioned_help.go
  • skills/lark-doc/references/lark-doc-md.md
  • skills/lark-doc/references/lark-doc-xml.md
  • skills/lark-doc/references/lark-doc-fetch.md
  • shortcuts/doc/versioned_help_test.go
  • shortcuts/doc/docs_update_check.go
  • skills/lark-doc/references/lark-doc-update.md

Comment on lines +70 to +84
combined := result.Stdout + "\n" + result.Stderr
for _, want := range []string{
tt.wantURL,
"docs_ai/v1",
} {
if !strings.Contains(combined, want) {
t.Fatalf("dry-run output missing %q\nstdout:\n%s\nstderr:\n%s", want, result.Stdout, result.Stderr)
}
}
if strings.Contains(combined, "/mcp") || strings.Contains(combined, "MCP tool") {
t.Fatalf("dry-run output should not use MCP\nstdout:\n%s\nstderr:\n%s", result.Stdout, result.Stderr)
}
if strings.Contains(combined, "--api-version") {
t.Fatalf("dry-run output should not ask for --api-version\nstdout:\n%s\nstderr:\n%s", result.Stdout, result.Stderr)
}
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟠 Major | ⚡ Quick win

Don’t merge stdout and stderr in dry-run success assertions.

Line 70 currently combines streams; this can pass even if the dry-run JSON envelope stops being written to stdout. Assert request-shape expectations from result.Stdout only.

Suggested change
-			combined := result.Stdout + "\n" + result.Stderr
+			payload := result.Stdout
 			for _, want := range []string{
 				tt.wantURL,
 				"docs_ai/v1",
 			} {
-				if !strings.Contains(combined, want) {
+				if !strings.Contains(payload, want) {
 					t.Fatalf("dry-run output missing %q\nstdout:\n%s\nstderr:\n%s", want, result.Stdout, result.Stderr)
 				}
 			}
-			if strings.Contains(combined, "/mcp") || strings.Contains(combined, "MCP tool") {
+			if strings.Contains(payload, "/mcp") || strings.Contains(payload, "MCP tool") {
 				t.Fatalf("dry-run output should not use MCP\nstdout:\n%s\nstderr:\n%s", result.Stdout, result.Stderr)
 			}
-			if strings.Contains(combined, "--api-version") {
+			if strings.Contains(payload, "--api-version") {
 				t.Fatalf("dry-run output should not ask for --api-version\nstdout:\n%s\nstderr:\n%s", result.Stdout, result.Stderr)
 			}
As per coding guidelines `**/*.go`: `stdout is data (JSON envelopes), stderr is everything else ... Never mix them`.
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
combined := result.Stdout + "\n" + result.Stderr
for _, want := range []string{
tt.wantURL,
"docs_ai/v1",
} {
if !strings.Contains(combined, want) {
t.Fatalf("dry-run output missing %q\nstdout:\n%s\nstderr:\n%s", want, result.Stdout, result.Stderr)
}
}
if strings.Contains(combined, "/mcp") || strings.Contains(combined, "MCP tool") {
t.Fatalf("dry-run output should not use MCP\nstdout:\n%s\nstderr:\n%s", result.Stdout, result.Stderr)
}
if strings.Contains(combined, "--api-version") {
t.Fatalf("dry-run output should not ask for --api-version\nstdout:\n%s\nstderr:\n%s", result.Stdout, result.Stderr)
}
payload := result.Stdout
for _, want := range []string{
tt.wantURL,
"docs_ai/v1",
} {
if !strings.Contains(payload, want) {
t.Fatalf("dry-run output missing %q\nstdout:\n%s\nstderr:\n%s", want, result.Stdout, result.Stderr)
}
}
if strings.Contains(payload, "/mcp") || strings.Contains(payload, "MCP tool") {
t.Fatalf("dry-run output should not use MCP\nstdout:\n%s\nstderr:\n%s", result.Stdout, result.Stderr)
}
if strings.Contains(payload, "--api-version") {
t.Fatalf("dry-run output should not ask for --api-version\nstdout:\n%s\nstderr:\n%s", result.Stdout, 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 70 - 84, The test
currently concatenates result.Stdout and result.Stderr into combined and asserts
request-shape strings against that; update the assertions to check only
result.Stdout (not combined) for the positive expectations (tt.wantURL and
"docs_ai/v1") and for the negative checks ("/mcp", "MCP tool", "--api-version")
so that JSON envelope output is validated strictly from result.Stdout while
stderr remains separate.

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 size/XL Architecture-level or global-impact change

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants