feat(controller): add read-only skill catalog endpoint for workbench - #1211
feat(controller): add read-only skill catalog endpoint for workbench#1211LUOSENGWA wants to merge 1 commit into
Conversation
4538145 to
dd87e6e
Compare
shiyiyue1102
left a comment
There was a problem hiding this comment.
Thanks for the contribution. I think we should pause the current implementation and clarify the overall Skill Center design before deciding how this API should be implemented.
The main concern is the source of truth. Worker.spec.skills and Worker.spec.remoteSkills represent skills already assigned to individual Workers; they should not be used to reconstruct the deployment-wide catalog of skills available for assignment. A catalog should come from a shared, authoritative location and remain independent of the current Worker instances.
Please first prepare or update a design document and discuss the following points with the maintainers:
- What is the authoritative public catalog, and which component owns it?
- How are builtin, uploaded, marketplace, and remote-registry Skills represented?
- What is the boundary between catalog metadata, per-Worker assignment state, and the Worker’s runtime copy?
- What are the team visibility, tenant isolation, and credential-redaction rules?
- How is the catalog updated when Skills are added, updated, or removed?
The current implementation enumerates all Workers and exposes data derived from their remoteSkills. Besides making catalog contents depend on existing assignments, this can expose cross-team registry details and credential-bearing source URIs. The authorization branch also needs to enforce ActionList explicitly rather than allowing every action for the skills resource.
Once the Skill Center design and data boundaries are agreed upon, we can review how this endpoint and its tests should be adjusted.
感谢贡献。建议先暂停当前实现,在决定这个 API 如何落地之前,先把 Skill Center 的整体设计梳理清楚并完成讨论。
目前最主要的问题是权威数据源。Worker.spec.skills 和 Worker.spec.remoteSkills 表示已经分配给具体 Worker 的技能,不应该用来反向构建部署级的可分配技能目录。可分配目录应来自统一、公共、权威的位置,并且不依赖当前存在哪些 Worker。
请先整理或更新设计文档,并与维护者讨论以下问题:
- 公共技能目录的权威数据源是什么,由哪个组件维护?
- 内置、上传、市场和远程注册表 Skill 分别如何表达?
- Catalog 元数据、Worker 分配状态和 Worker 运行时副本之间的边界是什么?
- 团队可见性、租户隔离和凭据脱敏规则是什么?
- Skill 新增、更新和删除后,Catalog 如何保持同步?
当前实现会遍历全部 Worker,并从其 remoteSkills 中聚合数据。这不仅会使目录内容依赖现有分配状态,还可能暴露跨团队的注册表信息以及包含凭据的 source URI。另外,skills 资源的鉴权也应明确只允许 ActionList,不能直接放行所有 Action。
等 Skill Center 的设计和数据边界讨论确认后,再继续评审这个接口及其测试应该如何调整。
dd87e6e to
a45d104
Compare
|
@shiyiyue1102 Concretely:
各点同意——按要求暂停本 PR,先做 Skill Center 整体设计。
|
Read-only skill catalog endpoint
Summary
There was no controller API for listing which skills a deployment makes available to workers. The Dashboard Skill Center reads its own private storage (unreachable by user-facing clients), and the Worker CRD only records skills already assigned, not what is available to assign. Workbench UIs that let a team manage its workers' capabilities had no catalog to browse.
This PR adds
GET /api/v1/skills, a single read-only endpoint that returns:skills/<skill>/SKILL.mdfrontmatter contributesnameanddescription; the directory name is the fallback. A skill shipped by several templates is reported once, with the providing templates inagents.spec.remoteSkillsis aggregated, so skills already referenced from a registry (e.g. Nacos) appear with theirsource. A skill available both builtin and from a registry gets a combined source (builtin+nacos).The endpoint is metadata-only: no skill content, no registry network calls, no credentials. Output is sorted by name.
What's included
internal/server/skills_handler.go(new) — catalog assembly (builtin scan + remote aggregation) and a small SKILL.md frontmatter parser.internal/server/http.go—GET /api/v1/skillsroute;ServerDeps.WorkerAgentDir.internal/app/app.go— wires the configured agent-template directory.internal/auth/authorizer.go— newskillsresource kind: list allowed for admins, managers, team leaders, and team-scoped humans; denied for worker service accounts.docs/design/skill-catalog-api.md— design contract.docs/usage/resource-management.md(+ zh-cn) — API reference section.Data boundary
name/descriptionlines; skill bodies are never returned.Tests
internal/server/skills_handler_test.go(new): builtin scan across template dirs with cross-template dedup andagentsordering; remote aggregation including the combinedbuiltin+nacossource; stray non-directory files ignored; missing template dir → empty200; emptyWorkerAgentDir→200; sorted output; frontmatter parser cases (valid / no frontmatter / name-only / empty / missing file).go test ./internal/server/ ./internal/auth/green; fullgo test ./...: 19 packages ok, the only failure is a pre-existing environment issue ininternal/executor(unzip binary absent in the test container) untouched by this diff.gofmt/go vetclean.Related
docs/design/skill-catalog-api.md.只读技能目录端点
摘要
此前没有任何 Controller API 可以列出部署中可用的技能。Dashboard Skill Center 读的是它自己的私有存储(用户侧客户端够不到),Worker CRD 只记录已分配的技能,不是可分配目录。需要管理团队技能配置的工作台 UI 没有候选池可浏览。
本 PR 新增
GET /api/v1/skills,单一只读端点,返回:skills/<skill>/SKILL.mdfrontmatter 提供name和description,目录名兜底。多个模板都带的技能只报告一次,agents列出提供它的模板。spec.remoteSkills,已引用自注册表(如 Nacos)的技能带其source出现。内置与注册表都有的技能合并 source(builtin+nacos)。端点只暴露元数据:不返回技能正文、不做注册表网络调用、不泄露凭据。输出按名称排序。
包含内容
internal/server/skills_handler.go(新)— 目录组装(内置扫描 + 远程聚合)与小型 SKILL.md frontmatter 解析器。internal/server/http.go—GET /api/v1/skills路由;ServerDeps.WorkerAgentDir。internal/app/app.go— 接线配置的 agent 模板目录。internal/auth/authorizer.go— 新skills资源类型:admin/manager/团队 Leader/团队范围人类用户可 list,worker 服务账号拒绝。docs/design/skill-catalog-api.md— 设计契约。docs/usage/resource-management.md(+ zh-cn)— API 参考节。数据边界
name/description两行,技能正文永不返回。测试
internal/server/skills_handler_test.go(新):跨模板目录的内置扫描与去重、agents排序;远程聚合含builtin+nacos合并 source;非目录杂项文件被忽略;模板目录缺失 → 空200;空WorkerAgentDir→200;输出排序;frontmatter 解析器用例(合法/无 frontmatter/仅 name/空文件/文件缺失)。go test ./internal/server/ ./internal/auth/全绿;全量go test ./...:19 包 ok,唯一失败为internal/executor预存环境问题(测试容器缺 unzip),与本 diff 无关。gofmt/go vet干净。相关
docs/design/skill-catalog-api.md。