skills

package module
v0.0.0-...-e4ad0a8 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 2, 2026 License: MIT Imports: 10 Imported by: 0

README

Version

该 skills 由 cnb-sdk-generator 生成

CNB OpenAPI Skills

一个用于与 CNB (Cloud Native Build) Open API 交互的技能包,提供完整的代码管理和开发协作功能。

功能特性

  • 🚀 完整 API 覆盖 - 支持 CNB 平台所有 API 接口
  • 📝 详细文档 - 每个 API 都有完整的使用说明和示例
  • 🔐 安全认证 - 基于 Bearer Token 的身份验证
  • 🛠️ 开发友好 - 结构化的接口文档,便于集成和使用

快速开始

设置环境变量
Linux/Mac
export CNB_TOKEN="your_cnb_token_here"
# 可选:自定义 API 地址(默认为 https://api.cnb.cool)
export CNB_API_ENDPOINT="https://api.cnb.cool"
Windows
$env:CNB_TOKEN = "your_cnb_token_here"
# 可选:自定义 API 地址(默认为 https://api.cnb.cool)
$env:CNB_API_ENDPOINT = "https://api.cnb.cool"
使用

API 服务分类与文档结构

references/
├── activities/      # 活动统计 - 用户和仓库活动数据
├── ai/             # AI 功能 - AI 辅助开发功能
├── assets/         # 资产管理 - 项目资产和文件管理
├── badge/          # 徽章系统 - 项目徽章管理
├── build/          # 构建系统 - CI/CD 构建相关功能
├── charge/         # 计费系统 - 费用和计费查询
├── event/          # 事件系统 - 系统事件和通知
├── followers/      # 关注系统 - 用户关注和粉丝管理
├── git/            # Git 管理 - 分支、标签、提交等 Git 操作
├── gitsettings/    # Git 设置 - 合并请求设置、分支保护等
├── issues/         # 问题管理 - Issue 创建、查询、更新等
├── knowledgebase/  # 知识库 - 知识库查询和管理
├── members/        # 成员管理 - 项目成员和权限管理
├── missions/       # 任务系统 - 任务和项目管理
├── organizations/  # 组织管理 - 组织信息和设置
├── pulls/          # 合并请求 - Pull Request 相关操作
├── registries/     # 镜像仓库 - 容器镜像仓库管理
├── releases/       # 发布管理 - Release 和版本管理
├── repocontributor/ # 仓库贡献 - 贡献者统计分析
├── repolabels/     # 仓库标签 - 标签创建和管理
├── repositories/   # 仓库管理 - 仓库信息和设置管理
├── security/       # 安全管理 - 安全扫描和报告
├── starring/       # 收藏功能 - 仓库收藏和关注
├── users/          # 用户系统 - 用户信息和配置
└── workspace/      # 工作空间 - 开发环境和工作空间

技能文档

完整的技能说明请查看 SKILL.md 文件。

许可证

本项目遵循相应的开源许可证。

Documentation

Index

Constants

View Source
const DefaultAPIEndpoint = "https://api.cnb.cool"

DefaultAPIEndpoint 是默认的 API 基础地址

Variables

This section is empty.

Functions

func BuildSystemPrompt

func BuildSystemPrompt() string

BuildSystemPrompt 构建两阶段检索的 System Prompt 使用精简索引代替完整 SKILL.md,大幅减少 token 消耗 API 基础地址从环境变量 CNB_API_ENDPOINT 获取,默认为 https://api.cnb.cool

func GetAPIDoc

func GetAPIDoc(serviceOrRef string, api ...string) (string, error)

GetAPIDoc 获取指定 API 的详细文档 支持两种调用方式:

GetAPIDoc("issues", "listissues")   — 两个参数
GetAPIDoc("issues/listissues")      — 单个 "service/apiname" 引用

func GetAPIEndpoint

func GetAPIEndpoint() string

GetAPIEndpoint 从环境变量 CNB_API_ENDPOINT 获取 API 基础地址,默认为 https://api.cnb.cool

func GetCompactIndex

func GetCompactIndex() string

GetCompactIndex 从 SKILL.md 生成精简索引(每个 API 一行) 格式: "- APIName: METHOD /path — 描述 service/apiname" 相比完整 SKILL.md (~2700行) 大幅缩减 token 消耗

func GetSkill

func GetSkill() string

GetSkill 返回完整的 SKILL.md 内容

func ListAPIs

func ListAPIs(service string) ([]string, error)

ListAPIs 返回指定服务下的所有 API 名称(不含 .md 扩展名)

func ListServices

func ListServices() ([]string, error)

ListServices 返回所有 API 服务分类名称

Types

type Action

type Action struct {
	Type  string // "get_api_doc" 或 "curl"
	Value string
}

Action 表示从 AI 响应中解析出的动作指令

func ParseAction

func ParseAction(content string) *Action

ParseAction 解析 AI 响应中的动作指令 返回 nil 表示 AI 已给出最终回答(无需继续循环)

type CurlResult

type CurlResult struct {
	Success bool   `json:"success"`
	Data    any    `json:"data,omitempty"`
	Error   string `json:"error,omitempty"`
}

CurlResult 表示 curl 命令的执行结果

func ExecCurl

func ExecCurl(curlCmd string, vars map[string]string, opts ...ExecCurlOptions) CurlResult

ExecCurl 执行 curl 命令 vars 为占位符替换映射,如 map[string]string{"<CNB_TOKEN>": "xxx", "{repo}": "owner/repo"}

type ExecCurlOptions

type ExecCurlOptions struct {
	Timeout  time.Duration // 命令超时时间,默认 30s
	NoSilent bool          // 设为 true 则不自动追加 -s 静默模式(默认会追加)
}

ExecCurlOptions 可选配置

Source Files

  • skills.go

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL