Skip to content

feat(skills): batch import endpoint for the directory picker - #10

Merged
wujunyi792 merged 1 commit into
mainfrom
feat/skill-batch-import
Jul 22, 2026
Merged

wujunyi792 merged 1 commit into
mainfrom
feat/skill-batch-import

Conversation

@wujunyi792

@wujunyi792 wujunyi792 commented Jul 22, 2026 •

Copy link
Copy Markdown
Member

Why

Selecting several sub-skills in the directory-of-skills picker (#9) fired N sequential client import requests. Against throttled GitHub, one skill's many file downloads could take ~20s — long enough that the browser dropped the connection mid-import (server saw context canceled → 500) and that skill was lost.

What

POST /api/skills/import/batch: one request carrying the selected URLs. The server imports them with bounded concurrency (4) + a single fetch retry, returning a per-URL result plus created/skipped/failed counts.

  • on_conflict defaults to skip so one already-existing skill never fails the rest; fail is rejected (meaningless for a set).
  • Refactors a single import's create/conflict tail into returning helpers (importOneImportedSkill / resolveImportConflictResult) the batch aggregates — the existing single-import write path is untouched.

Frontend: api.importSkillsBatch; the picker's Import selected makes one batch call and reports created/skipped/failed. i18n en/zh/ja/ko.

Verified end-to-end (real browser + real GitHub)

Picked 3 lark skills (base/calendar/doc) → one batch request → all landed with content: 13565 / 7001 / 6769 bytes, 25 / 10 / 18 files. lark-calendar, which previously context canceled-500'd on the sequential path, now imports cleanly. Also go build/vet, dedupeNonEmpty unit test, core+views typecheck, full views vitest (2914, incl. locale parity).

🤖 Generated with Claude Code

Summary by CodeRabbit

  • 新功能

    • 支持从多个 URL 批量导入技能,并显示每项导入结果及汇总统计。
    • 支持对已存在技能选择跳过、覆盖或重命名。
    • 批量导入过程中,单个 URL 失败不会中断其他导入。
  • 体验优化

    • 优化部分失败、全部跳过等场景的提示信息。
    • 新增英文、日文、韩文和简体中文提示文案。

Selecting several sub-skills in the directory-of-skills picker previously fired
N sequential client import requests. With unauthenticated/throttled GitHub, one
skill's many file downloads could run ~20s, long enough that the browser dropped
the connection mid-import (server saw "context canceled" → 500) and the skill
was lost.

Add POST /api/skills/import/batch: one request carrying the selected URLs; the
server imports them with bounded concurrency (4) + a single fetch retry, and
returns a per-URL result plus created/skipped/failed counts. on_conflict
defaults to "skip" so one pre-existing skill never fails the rest ("fail" is
rejected as meaningless for a set).

Refactors the create/conflict tail of a single import into returning helpers
(importOneImportedSkill / resolveImportConflictResult) that the batch aggregates,
leaving the existing single-import write path untouched.

Frontend: api.importSkillsBatch; the picker's "Import selected" now makes one
batch call and reports created/skipped/failed. i18n en/zh/ja/ko.

Verified end-to-end in a browser: picked 3 lark skills (base/calendar/doc) →
one batch request → all three landed with content (13565/7001/6769 bytes,
25/10/18 files). The previously-failing lark-calendar now imports cleanly.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01NYStwEXJFCJLokYqKVUBUg
@wujunyi792
wujunyi792 merged commit 1c65a2a into main Jul 22, 2026
6 of 7 checks passed
@wujunyi792
wujunyi792 deleted the feat/skill-batch-import branch July 22, 2026 06:29
@coderabbitai

coderabbitai Bot commented Jul 22, 2026 •

Copy link
Copy Markdown

Review Change Stack

Caution

Review failed

The pull request is closed.

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 6b829e55-41ff-4bfb-ac5c-9247f3ac99e5

📥 Commits

Reviewing files that changed from the base of the PR and between 9ce6af7 and a85ecc1.

📒 Files selected for processing (11)
  • packages/core/api/client.ts
  • packages/core/types/agent.ts
  • packages/core/types/index.ts
  • packages/views/locales/en/skills.json
  • packages/views/locales/ja/skills.json
  • packages/views/locales/ko/skills.json
  • packages/views/locales/zh-Hans/skills.json
  • packages/views/skills/components/create-skill-dialog.tsx
  • server/cmd/server/router.go
  • server/internal/handler/skill_directory_import_test.go
  • server/internal/handler/skill_import_batch.go

Walkthrough

新增技能批量导入能力:服务端提供并发批量接口及冲突策略,客户端增加类型与调用方法,导入对话框根据汇总结果展示成功、跳过和失败提示。

Changes

技能批量导入

Layer / File(s) Summary
批量导入 API 契约
packages/core/types/agent.ts, packages/core/types/index.ts, packages/core/api/client.ts
新增批量导入结果类型、类型导出及 importSkillsBatch 客户端方法。
批量接口与请求编排
server/internal/handler/skill_import_batch.go, server/cmd/server/router.go, server/internal/handler/skill_directory_import_test.go
新增批量导入路由与处理器,校验并去重 URL,限制批量规模和并发度,按输入顺序返回逐项结果及汇总计数,并测试 URL 归一化。
单 URL 导入与冲突处理
server/internal/handler/skill_import_batch.go
新增来源检测、可重试抓取、文件校验、技能创建及 skip、overwrite、rename 冲突处理流程。
客户端结果处理与本地化提示
packages/views/skills/components/create-skill-dialog.tsx, packages/views/locales/*/skills.json
批量导入对话框依据服务端结果处理成功、部分失败和全部跳过状态,并新增多语言提示。

Estimated code review effort: 3 (Moderate) | ~25 minutes

Sequence Diagram(s)

sequenceDiagram
  participant 用户
  participant CreateSkillDialog
  participant ApiClient
  participant ImportSkillsBatch
  participant SkillImportPipeline
  用户->>CreateSkillDialog: 选择候选技能并导入
  CreateSkillDialog->>ApiClient: 调用 importSkillsBatch
  ApiClient->>ImportSkillsBatch: POST 批量 URL 与冲突策略
  ImportSkillsBatch->>SkillImportPipeline: 并发导入各 URL
  SkillImportPipeline-->>ImportSkillsBatch: 返回逐项状态
  ImportSkillsBatch-->>ApiClient: 返回 results 与 created/skipped/failed
  ApiClient-->>CreateSkillDialog: 返回批量结果
  CreateSkillDialog-->>用户: 显示导入、失败或全部跳过提示
Loading

Suggested reviewers: nevilleqingny, bohan-j

Poem

我是小兔,抱来一筐 URL,
并发蹦跳,技能排队入库。
已存在的轻轻跳过,
新技能闪闪发光,
失败原因也写得清楚。

✨ 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 feat/skill-batch-import

Warning

There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure.

🔧 golangci-lint (2.12.2)

level=error msg="[linters_context] typechecking error: pattern ./...: directory prefix . does not contain main module or its selected dependencies"


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.

wujunyi792 added a commit that referenced this pull request Aug 24, 2026
Selecting several sub-skills in the directory-of-skills picker previously fired
N sequential client import requests. With unauthenticated/throttled GitHub, one
skill's many file downloads could run ~20s, long enough that the browser dropped
the connection mid-import (server saw "context canceled" → 500) and the skill
was lost.

Add POST /api/skills/import/batch: one request carrying the selected URLs; the
server imports them with bounded concurrency (4) + a single fetch retry, and
returns a per-URL result plus created/skipped/failed counts. on_conflict
defaults to "skip" so one pre-existing skill never fails the rest ("fail" is
rejected as meaningless for a set).

Refactors the create/conflict tail of a single import into returning helpers
(importOneImportedSkill / resolveImportConflictResult) that the batch aggregates,
leaving the existing single-import write path untouched.

Frontend: api.importSkillsBatch; the picker's "Import selected" now makes one
batch call and reports created/skipped/failed. i18n en/zh/ja/ko.

Verified end-to-end in a browser: picked 3 lark skills (base/calendar/doc) →
one batch request → all three landed with content (13565/7001/6769 bytes,
25/10/18 files). The previously-failing lark-calendar now imports cleanly.

Claude-Session: https://claude.ai/code/session_01NYStwEXJFCJLokYqKVUBUg

Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
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