Skip to content

refactor(sdk): move public facade to sdk path - #11

Merged
FlanChanXwO merged 2 commits into
mainfrom
codex/sdk-public-facade
Aug 5, 2026
Merged

FlanChanXwO merged 2 commits into
mainfrom
codex/sdk-public-facade

Conversation

@FlanChanXwO

@FlanChanXwO FlanChanXwO commented Aug 5, 2026 •

Copy link
Copy Markdown
Owner

Summary

  • Move the public Go SDK facade from javdb/ to sdk/ while retaining package javdb.
  • Update CLI imports, bilingual SDK migration guidance, and maintainer documentation.
  • Add architecture and documentation checks for the new SDK path.

Scope and compatibility

  • Breaking SDK import change: github.com/FlanChanXwO/javdb-cli/javdb is replaced by github.com/FlanChanXwO/javdb-cli/sdk.
  • The public package name, types, and methods remain javdb; CLI commands, flags, JSON output, configuration, authentication, and release assets are unchanged.
  • Operator skill files are unchanged because CLI behavior is unchanged.

Verification

pre-commit run --all-files

All configured hooks passed: gofmt, go test ./..., release tooling, release notes, documentation structure, and architecture structure checks.

Release note declaration

Checklist

  • I added or updated focused tests for changed behavior.
  • I ran the relevant tests and recorded the results above.
  • I updated the required SDK, README, maintainer, and migration documentation.
  • I completed the required release-note declaration above.
  • I updated migration guidance for the breaking SDK import change.

Summary by Sourcery

将公共 Go SDK 门面从顶层的 javdb 目录移动到新的 sdk 目录,同时保持 javdb 包的 API 不变,并相应更新所有引用。

Enhancements:

  • 更新 CLI、文档和维护者指南,使其从新的 sdk 路径导入公共 SDK,同时继续使用 javdb 包。
  • 收紧架构和文档检查,以强制执行新的 sdk 位置,并防止使用已废弃的 javdb 导入路径。
Original summary in English

Summary by Sourcery

Move the public Go SDK facade from the top-level javdb directory to a new sdk directory while preserving the javdb package API and update references accordingly.

Enhancements:

  • Update CLI, documentation, and maintainer guides to import the public SDK from the new sdk path while keeping package javdb.
  • Tighten architecture and documentation checks to enforce the new sdk location and prevent use of the retired javdb import path.

Summary by CodeRabbit

  • 新功能

    • 提供统一的 Go SDK,支持搜索、浏览、影片详情、排行榜、用户列表、评论、磁力链接及媒体下载等操作。
    • 支持登录、令牌管理、代理、语言、超时和设备标识配置。
    • 提供影片媒体下载与磁力链接筛选辅助功能。
  • 文档

    • SDK 导入路径已迁移至新的公开路径,包名和现有 API 用法保持不变。
    • 新增迁移说明及中英文使用指南。

@sourcery-ai

sourcery-ai Bot commented Aug 5, 2026 •

Copy link
Copy Markdown

🧙 Sourcery 已完成对你的拉取请求的审查!


提示与命令

与 Sourcery 交互

  • 触发一次新的审查: 在拉取请求中评论 @sourcery-ai review。
  • 继续讨论: 直接回复 Sourcery 的审查评论。
  • 从审查评论生成 GitHub issue: 通过回复某条审查评论,请求 Sourcery 从该评论创建一个 issue。你也可以在审查评论中回复 @sourcery-ai issue 来从该评论创建一个 issue。
  • 生成拉取请求标题: 在拉取请求标题中的任意位置写上 @sourcery-ai,即可随时生成标题。你也可以在拉取请求中评论 @sourcery-ai title 来(重新)生成标题。
  • 生成拉取请求摘要: 在拉取请求正文中的任意位置写上 @sourcery-ai summary,即可在准确的位置随时生成 PR 摘要。你也可以在拉取请求中评论 @sourcery-ai summary 来(重新)生成摘要。
  • 生成审查者指南: 在拉取请求中评论 @sourcery-ai guide,即可随时(重新)生成审查者指南。
  • 解决所有 Sourcery 评论: 在拉取请求中评论 @sourcery-ai resolve,即可将所有 Sourcery 评论标记为已解决。如果你已经处理完所有评论且不想再看到它们,这会很有用。
  • 撤销所有 Sourcery 审查: 在拉取请求中评论 @sourcery-ai dismiss,即可撤销所有现有的 Sourcery 审查。特别适合在你想从一次全新的审查开始时使用——别忘了再评论 @sourcery-ai review 来触发新的审查!

自定义你的体验

访问你的控制台以:

  • 启用或禁用审查功能,例如 Sourcery 生成的拉取请求摘要、审查者指南等。
  • 更改审查语言。
  • 添加、删除或编辑自定义审查说明。
  • 调整其他审查设置。

获取帮助

Original review guide in English

🧙 Sourcery has finished reviewing your pull request!


Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

@coderabbitai

coderabbitai Bot commented Aug 5, 2026 •

Copy link
Copy Markdown

Review Change Stack

📝 Walkthrough

Walkthrough

新增顶层 sdk/ 公共 Go SDK,包名仍为 javdb。CLI 改用新导入路径。文档、架构说明和检查脚本同步更新。SDK 新增客户端、搜索、影片、用户、列表、排行榜及媒体下载接口。

Changes

公共 SDK

Layer / File(s) Summary
SDK 客户端基础
sdk/client.go, sdk/errors.go, sdk/client_test.go
新增 Client、配置选项、认证方法、错误别名和设备 UUID 持久化逻辑。
领域 API facade
sdk/search.go, sdk/browse.go, sdk/entity.go, sdk/lists.go, sdk/rankings.go, sdk/user.go, sdk/magnets.go
新增搜索、浏览、实体、列表、排行榜、用户和磁力链接接口,并转发至底层 API。
影片媒体接口
sdk/movie.go, sdk/movie_test.go
新增影片查询、媒体解析和媒体下载流程,并验证预览图选择及输出路径冲突。
CLI 导入与架构检查
internal/cli/*, scripts/test-architecture.sh
CLI 及测试改用 sdk/ 导入。架构脚本检查新目录和废弃导入。
文档与维护规范
README*, docs/*, AGENTS.md, CONTRIBUTING*, .github/copilot-instructions.md
统一说明 sdk/ 路径、javdb 包名和导入迁移要求。

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

Sequence Diagram(s)

sequenceDiagram
  participant CLI
  participant SDKClient
  participant AppAPI
  participant FileSystem
  CLI->>SDKClient: DownloadMovieMedia(movieID, options)
  SDKClient->>SDKClient: 校验媒体选择和输出路径
  SDKClient->>AppAPI: MovieDetail(movieID)
  AppAPI-->>SDKClient: 影片媒体 URL
  SDKClient->>AppAPI: 下载选定媒体
  AppAPI-->>SDKClient: 媒体字节
  SDKClient->>FileSystem: 写入媒体文件
  FileSystem-->>SDKClient: 输出路径和字节数
  SDKClient-->>CLI: MovieMediaDownloadResult
Loading

Possibly related PRs

Poem

小兔背上新 SDK,
sdk/ 路径跳得齐。
javdb 名字仍不变,
CLI 跟随新入口。
媒体写入文件里,
文档也把路标立。

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 37.04% 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.
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed 标题准确概括了将公共 SDK facade 从 javdb/ 移动到 sdk/ 路径这一主要变更。
✨ Finishing Touches 💡 2
📝 Generate docstrings 💡
  • Create stacked PR
  • Commit on current branch
🛠️ Fix failing CI checks 💡
  • Create stacked PR
  • Commit on current branch

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.

@sourcery-ai sourcery-ai 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.

Hey - 我已经审查了你的更改,一切看起来都很棒!


Sourcery 对开源项目是免费的——如果你喜欢我们的代码审查,请考虑分享给更多人 ✨
帮我变得更有用!请在每条评论上点 👍 或 👎,我会根据你的反馈不断改进代码审查质量。
Original comment in English

Hey - I've reviewed your changes and they look great!


Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

@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

🧹 Nitpick comments (1)
sdk/movie_test.go (1)

8-29: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

覆盖 thumb_url 回退路径。

当第一张预览图没有 large_url 时,movieMediaURLs 应返回同一项的 thumb_url。当前测试只覆盖 large_url 成功的路径,无法防止该回退逻辑回归。

建议的测试
+func TestMovieMediaURLsFallsBackToFirstPreviewThumbnail(t *testing.T) {
+	sources := movieMediaURLs(map[string]any{
+		"preview_images": []any{
+			map[string]any{"thumb_url": "https://media.example.test/first-thumb.jpg"},
+			map[string]any{"large_url": "https://media.example.test/second-large.jpg"},
+		},
+	})
+	if sources.previewImage != "https://media.example.test/first-thumb.jpg" {
+		t.Fatalf("preview image = %q", sources.previewImage)
+	}
+}
🤖 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 `@sdk/movie_test.go` around lines 8 - 29, 在
TestMovieMediaURLsUsesOnlyFirstPreviewImage 中补充第一张预览图缺少 large_url、但包含 thumb_url
的场景,并断言 movieMediaURLs 返回该同一项的 thumb_url 作为 previewImage;保留现有缩略图、视频及不选取后续预览图的断言。
🤖 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 `@scripts/test-architecture.sh`:
- Around line 16-24: Update the ripgrep check in the architecture test to
capture its exit status explicitly. Treat status 1 as the expected “no matches”
result, but exit with an error for every other nonzero status, including scan
failures or an unavailable rg command; preserve the existing failure for
detected retired SDK imports.

In `@sdk/client.go`:
- Around line 106-117: Propagate each public SDK method’s context.Context
through the full request stack instead of discarding it. In sdk/client.go lines
106-117, update Login and ResolveUserID; in sdk/search.go lines 16-18, Search;
in sdk/browse.go lines 14-34, taxonomy and Browse methods; in sdk/entity.go
lines 13-33, entity queries and pagination aggregation; in sdk/lists.go lines
6-20, list requests; in sdk/rankings.go lines 13-33, ranking requests; and in
sdk/user.go lines 6-38, user reads and mutations. Add context-aware appapi and
HTTP methods, constructing requests with http.NewRequestWithContext or an
equivalent mechanism so cancellation and deadlines reach the underlying
requests.

In `@sdk/movie.go`:
- Around line 27-42: Propagate the caller’s context instead of discarding it
throughout the SDK movie flows: update the appapi request methods used by
MovieDetail, MovieMagnets, MovieComments, and the other affected methods, plus
DownloadImage, fetchMedia, and the HLS download path, to accept and pass context
into their HTTP requests and downloads. Ensure cancellation and deadlines stop
all corresponding network operations, and remove the `_ = ctx` placeholders.

---

Nitpick comments:
In `@sdk/movie_test.go`:
- Around line 8-29: 在 TestMovieMediaURLsUsesOnlyFirstPreviewImage 中补充第一张预览图缺少
large_url、但包含 thumb_url 的场景,并断言 movieMediaURLs 返回该同一项的 thumb_url 作为
previewImage;保留现有缩略图、视频及不选取后续预览图的断言。
🪄 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: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: a39211b5-12ce-41f2-8c1e-3eac2738c193

📥 Commits

Reviewing files that changed from the base of the PR and between a2e911e and 5cfb724.

📒 Files selected for processing (40)
  • .github/copilot-instructions.md
  • AGENTS.md
  • CONTRIBUTING.md
  • CONTRIBUTING.zh-CN.md
  • README.md
  • README.zh-CN.md
  • docs/en/sdk.md
  • docs/maintainers/agents/documentation-guidelines.md
  • docs/maintainers/agents/review-checklist.md
  • docs/maintainers/architecture.md
  • docs/maintainers/development.md
  • docs/zh-CN/sdk.md
  • internal/cli/authclient.go
  • internal/cli/authclient_test.go
  • internal/cli/comments_cmd.go
  • internal/cli/detail_cmd.go
  • internal/cli/download_cmd.go
  • internal/cli/entity_cmd.go
  • internal/cli/lists_cmd.go
  • internal/cli/magnets_cmd.go
  • internal/cli/rankings_cmd.go
  • internal/cli/root.go
  • internal/cli/search_cmd.go
  • internal/cli/tags_browse_cmd.go
  • internal/cli/user_cmd.go
  • internal/cli/user_cmd_test.go
  • scripts/test-architecture.sh
  • scripts/test-documentation.sh
  • sdk/browse.go
  • sdk/client.go
  • sdk/client_test.go
  • sdk/entity.go
  • sdk/errors.go
  • sdk/lists.go
  • sdk/magnets.go
  • sdk/movie.go
  • sdk/movie_test.go
  • sdk/rankings.go
  • sdk/search.go
  • sdk/user.go

Comment on lines +16 to +24
if rg -n -F 'github.com/FlanChanXwO/javdb-cli/javdb' \
"$repo_root/cmd" \
"$repo_root/internal" \
"$repo_root/sdk" \
-g '*.go'; then
printf '%s\n' 'source code imports the retired public SDK path' >&2
exit 1
fi

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win

区分“无匹配”和扫描错误。

rg 在没有匹配时返回 1,在路径错误或命令不可用时返回其他非零状态。当前命令位于 if 条件中,因此 set -e 不会处理这些错误。架构检查可能在未完成扫描时通过。

请显式保存退出码。只接受 1 作为“未找到”,并对其他非零状态退出。

建议的退出码处理
 if rg -n -F 'github.com/FlanChanXwO/javdb-cli/javdb' \
 	"$repo_root/cmd" \
 	"$repo_root/internal" \
 	"$repo_root/sdk" \
 	-g '*.go'; then
 	printf '%s\n' 'source code imports the retired public SDK path' >&2
 	exit 1
+else
+	status=$?
+	if [ "$status" -ne 1 ]; then
+		exit "$status"
+	fi
 fi
📝 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
if rg -n -F 'github.com/FlanChanXwO/javdb-cli/javdb' \
"$repo_root/cmd" \
"$repo_root/internal" \
"$repo_root/sdk" \
-g '*.go'; then
printf '%s\n' 'source code imports the retired public SDK path' >&2
exit 1
fi
if rg -n -F 'github.com/FlanChanXwO/javdb-cli/javdb' \
"$repo_root/cmd" \
"$repo_root/internal" \
"$repo_root/sdk" \
-g '*.go'; then
printf '%s\n' 'source code imports the retired public SDK path' >&2
exit 1
else
status=$?
if [ "$status" -ne 1 ]; then
exit "$status"
fi
fi
🤖 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 `@scripts/test-architecture.sh` around lines 16 - 24, Update the ripgrep check
in the architecture test to capture its exit status explicitly. Treat status 1
as the expected “no matches” result, but exit with an error for every other
nonzero status, including scan failures or an unavailable rg command; preserve
the existing failure for detected retired SDK imports.

Source: Coding guidelines

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

Caution

Inline review comments failed to post. This is likely due to GitHub's internal server error or limits when posting large numbers of comments. If you are seeing this consistently it is likely a permissions issue. Please check "Moderation" -> "Code review limits" under your organization settings.

Actionable comments posted: 3

🧹 Nitpick comments (1)
sdk/movie_test.go (1)

8-29: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

覆盖 thumb_url 回退路径。

当第一张预览图没有 large_url 时,movieMediaURLs 应返回同一项的 thumb_url。当前测试只覆盖 large_url 成功的路径,无法防止该回退逻辑回归。

建议的测试
+func TestMovieMediaURLsFallsBackToFirstPreviewThumbnail(t *testing.T) {
+	sources := movieMediaURLs(map[string]any{
+		"preview_images": []any{
+			map[string]any{"thumb_url": "https://media.example.test/first-thumb.jpg"},
+			map[string]any{"large_url": "https://media.example.test/second-large.jpg"},
+		},
+	})
+	if sources.previewImage != "https://media.example.test/first-thumb.jpg" {
+		t.Fatalf("preview image = %q", sources.previewImage)
+	}
+}
🤖 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 `@sdk/movie_test.go` around lines 8 - 29, 在
TestMovieMediaURLsUsesOnlyFirstPreviewImage 中补充第一张预览图缺少 large_url、但包含 thumb_url
的场景,并断言 movieMediaURLs 返回该同一项的 thumb_url 作为 previewImage;保留现有缩略图、视频及不选取后续预览图的断言。
🤖 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 `@scripts/test-architecture.sh`:
- Around line 16-24: Update the ripgrep check in the architecture test to
capture its exit status explicitly. Treat status 1 as the expected “no matches”
result, but exit with an error for every other nonzero status, including scan
failures or an unavailable rg command; preserve the existing failure for
detected retired SDK imports.

In `@sdk/client.go`:
- Around line 106-117: Propagate each public SDK method’s context.Context
through the full request stack instead of discarding it. In sdk/client.go lines
106-117, update Login and ResolveUserID; in sdk/search.go lines 16-18, Search;
in sdk/browse.go lines 14-34, taxonomy and Browse methods; in sdk/entity.go
lines 13-33, entity queries and pagination aggregation; in sdk/lists.go lines
6-20, list requests; in sdk/rankings.go lines 13-33, ranking requests; and in
sdk/user.go lines 6-38, user reads and mutations. Add context-aware appapi and
HTTP methods, constructing requests with http.NewRequestWithContext or an
equivalent mechanism so cancellation and deadlines reach the underlying
requests.

In `@sdk/movie.go`:
- Around line 27-42: Propagate the caller’s context instead of discarding it
throughout the SDK movie flows: update the appapi request methods used by
MovieDetail, MovieMagnets, MovieComments, and the other affected methods, plus
DownloadImage, fetchMedia, and the HLS download path, to accept and pass context
into their HTTP requests and downloads. Ensure cancellation and deadlines stop
all corresponding network operations, and remove the `_ = ctx` placeholders.

---

Nitpick comments:
In `@sdk/movie_test.go`:
- Around line 8-29: 在 TestMovieMediaURLsUsesOnlyFirstPreviewImage 中补充第一张预览图缺少
large_url、但包含 thumb_url 的场景,并断言 movieMediaURLs 返回该同一项的 thumb_url 作为
previewImage;保留现有缩略图、视频及不选取后续预览图的断言。
🪄 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: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: a39211b5-12ce-41f2-8c1e-3eac2738c193

📥 Commits

Reviewing files that changed from the base of the PR and between a2e911e and 5cfb724.

📒 Files selected for processing (40)
  • .github/copilot-instructions.md
  • AGENTS.md
  • CONTRIBUTING.md
  • CONTRIBUTING.zh-CN.md
  • README.md
  • README.zh-CN.md
  • docs/en/sdk.md
  • docs/maintainers/agents/documentation-guidelines.md
  • docs/maintainers/agents/review-checklist.md
  • docs/maintainers/architecture.md
  • docs/maintainers/development.md
  • docs/zh-CN/sdk.md
  • internal/cli/authclient.go
  • internal/cli/authclient_test.go
  • internal/cli/comments_cmd.go
  • internal/cli/detail_cmd.go
  • internal/cli/download_cmd.go
  • internal/cli/entity_cmd.go
  • internal/cli/lists_cmd.go
  • internal/cli/magnets_cmd.go
  • internal/cli/rankings_cmd.go
  • internal/cli/root.go
  • internal/cli/search_cmd.go
  • internal/cli/tags_browse_cmd.go
  • internal/cli/user_cmd.go
  • internal/cli/user_cmd_test.go
  • scripts/test-architecture.sh
  • scripts/test-documentation.sh
  • sdk/browse.go
  • sdk/client.go
  • sdk/client_test.go
  • sdk/entity.go
  • sdk/errors.go
  • sdk/lists.go
  • sdk/magnets.go
  • sdk/movie.go
  • sdk/movie_test.go
  • sdk/rankings.go
  • sdk/search.go
  • sdk/user.go
🛑 Comments failed to post (2)
sdk/client.go (1)

106-117: 🩺 Stability & Availability | 🟠 Major | 🏗️ Heavy lift

传播所有公开 SDK 方法的 context.Context。

这些方法接受 context.Context,但立即使用 _ = ctx 丢弃它。调用方的取消和 deadline 不会中断请求。WithTimeout 的固定客户端超时不能替代每个调用的 context 控制。

请在 appapi 和 HTTP 请求层添加 context-aware 方法,并使用 http.NewRequestWithContext 或等效机制传递 ctx。

  • sdk/client.go#L106-L117: 将 Login 和 ResolveUserID 的 ctx 传递到下层。
  • sdk/search.go#L16-L18: 将 Search 的 ctx 传递到下层。
  • sdk/browse.go#L14-L34: 将 taxonomy 和 Browse 方法的 ctx 传递到下层。
  • sdk/entity.go#L13-L33: 将实体查询和分页聚合的 ctx 传递到下层。
  • sdk/lists.go#L6-L20: 将列表请求的 ctx 传递到下层。
  • sdk/rankings.go#L13-L33: 将排行榜请求的 ctx 传递到下层。
  • sdk/user.go#L6-L38: 将用户读取和状态修改请求的 ctx 传递到下层。
📍 Affects 7 files
  • sdk/client.go#L106-L117 (this comment)
  • sdk/search.go#L16-L18
  • sdk/browse.go#L14-L34
  • sdk/entity.go#L13-L33
  • sdk/lists.go#L6-L20
  • sdk/rankings.go#L13-L33
  • sdk/user.go#L6-L38
🤖 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 `@sdk/client.go` around lines 106 - 117, Propagate each public SDK method’s
context.Context through the full request stack instead of discarding it. In
sdk/client.go lines 106-117, update Login and ResolveUserID; in sdk/search.go
lines 16-18, Search; in sdk/browse.go lines 14-34, taxonomy and Browse methods;
in sdk/entity.go lines 13-33, entity queries and pagination aggregation; in
sdk/lists.go lines 6-20, list requests; in sdk/rankings.go lines 13-33, ranking
requests; and in sdk/user.go lines 6-38, user reads and mutations. Add
context-aware appapi and HTTP methods, constructing requests with
http.NewRequestWithContext or an equivalent mechanism so cancellation and
deadlines reach the underlying requests.
sdk/movie.go (1)

27-42: 🩺 Stability & Availability | 🟠 Major | 🏗️ Heavy lift

🧩 Analysis chain

🏁 Script executed:

#!/bin/sh
set -eu

ast-grep outline sdk/movie.go --items all
ast-grep outline internal/javdb/appapi --items all --type function

rg -n -C 4 --type go \
  'func \(c \*Client\) (MovieDetail|MovieMagnets|MovieComments|ResolveMovieID|DownloadImage|DownloadHLS|fetchMedia)\b|NewRequestWithContext|\.Do\(' \
  sdk internal/javdb/appapi

Repository: FlanChanXwO/javdb-cli

Length of output: 9433


🏁 Script executed:

#!/bin/sh
set -eu

sed -n '1,220p' sdk/movie.go
printf '\n--- internal/javdb/appapi/client.go ---\n'
sed -n '1,240p' internal/javdb/appapi/client.go
printf '\n--- internal/javdb/appapi/movie.go ---\n'
sed -n '1,120p' internal/javdb/appapi/movie.go
printf '\n--- internal/javdb/appapi/resolve.go ---'
sed -n '1,120p' internal/javdb/appapi/resolve.go
printf '\n--- internal/javdb/appapi/media.go ---\n'
sed -n '1,160p' internal/javdb/appapi/media.go

printf '\n--- httpx Client methods ---\n'
rg -n -C 3 --type go 'func \(.*httpx\.Client.*\)|type Client|Do\(|Get\(' internal/sdk internal/javdb/protocol internal/javdb

Repository: FlanChanXwO/javdb-cli

Length of output: 24816


让 ctx 控制网络调用。

sdk/movie.go 在第 28、34、41、48 和 160 行丢弃了 context.Context,但 appapi 的请求、图片下载和 HLS 下载路径也没有接收并传递 context。调用方取消 context 或到达 deadline 后,影片详情、磁链、评论、解析、图片下载和 HLS 请求仍会继续执行。将 context.Context 引入 appapi 请求、DownloadImage、fetchMedia 与 HLS 下载路径并正确传递。

🤖 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 `@sdk/movie.go` around lines 27 - 42, Propagate the caller’s context instead of
discarding it throughout the SDK movie flows: update the appapi request methods
used by MovieDetail, MovieMagnets, MovieComments, and the other affected
methods, plus DownloadImage, fetchMedia, and the HLS download path, to accept
and pass context into their HTTP requests and downloads. Ensure cancellation and
deadlines stop all corresponding network operations, and remove the `_ = ctx`
placeholders.

@FlanChanXwO
FlanChanXwO merged commit c4deaaa into main Aug 5, 2026
13 checks passed
@FlanChanXwO
FlanChanXwO deleted the codex/sdk-public-facade branch August 10, 2026 03:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant