From 8c145b1728118823444d0905740224c8a6a1ff87 Mon Sep 17 00:00:00 2001
From: zishuo
Date: Tue, 26 May 2026 14:04:36 +0800
Subject: [PATCH 1/6] docs: add Chinese README translation
---
README-zh.md | 286 +++++++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 286 insertions(+)
create mode 100644 README-zh.md
diff --git a/README-zh.md b/README-zh.md
new file mode 100644
index 00000000..3950ffd9
--- /dev/null
+++ b/README-zh.md
@@ -0,0 +1,286 @@
+
+
+
+
+skillshare
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ AI CLI 技能(Skills)、智能体(Agents)、规则(Rules)、命令(Commands)等资源的唯一事实来源。
+ 一键同步到所有平台——从个人到组织级全覆盖。
+ 支持 Codex、Claude Code、OpenClaw、OpenCode 及 60+ 更多工具。
+
+
+
+
+
+
+
+ 官网 •
+ 安装 •
+ 快速开始 •
+ 亮点功能 •
+ 截图预览 •
+ 文档
+
+
+> [!NOTE]
+> **最新版本**: [v0.19.12](https://github.com/runkids/skillshare/releases/tag/v0.19.12) — config.yaml 中的 `skills:` 字段现在会保留(修复了团队共享问题)。[查看全部版本 →](https://github.com/runkids/skillshare/releases)
+
+## 为什么选择 skillshare
+
+每个 AI CLI 都有自己的技能目录。
+你在一个工具里编辑了技能,却忘了复制到另一个,最后记不清哪个在哪里。
+
+skillshare 解决了这个问题:
+
+- **单一来源,覆盖所有智能体** — 一条 `skillshare sync` 命令同步到 Claude、Cursor、Codex 及 60+ 工具
+- **智能体管理** — 将自定义智能体与技能一起同步到支持智能体的目标端
+- **不止于技能** — 使用 [extras](https://skillshare.runkids.cc/docs/reference/targets/configuration#extras) 管理规则、命令、提示词及任何基于文件的资源
+- **从任何地方安装** — GitHub、GitLab、Bitbucket、Azure DevOps 或任何自托管的 Git 仓库
+- **内置安全** — 在使用前审计技能是否存在提示注入和数据泄露风险
+- **团队就绪** — 项目中通过 `.skillshare/` 管理技能,组织级技能通过代码仓库同步
+- **本地轻量** — 单一二进制文件,无需注册中心,无遥测,完全支持离线使用
+- **细粒度过滤** — 通过 [`.skillignore`](https://skillshare.runkids.cc/docs/how-to/daily-tasks/filtering-skills)、SKILL.md 中的 `targets` 字段以及按目标端的 include/exclude 配置,精确控制哪些技能同步到哪些目标端
+
+> 从其他工具迁移?[迁移指南](https://skillshare.runkids.cc/docs/how-to/advanced/migration) · [功能对比](https://skillshare.runkids.cc/docs/understand/philosophy/comparison)
+
+## 工作原理
+
+- macOS / Linux:`~/.config/skillshare/`
+- Windows:`%AppData%\skillshare\`
+
+```
+┌─────────────────────────────────────────────────────────────┐
+│ 源目录 │
+│ ~/.config/skillshare/skills/ ← 技能(SKILL.md) │
+│ ~/.config/skillshare/agents/ ← 智能体 │
+│ ~/.config/skillshare/extras/ ← 规则、命令等 │
+└─────────────────────────────────────────────────────────────┘
+ │ sync
+ ┌───────────────┼───────────────┐
+ ▼ ▼ ▼
+ ┌───────────┐ ┌───────────┐ ┌───────────┐
+ │ Claude │ │ OpenCode │ │ OpenClaw │ ...
+ └───────────┘ └───────────┘ └───────────┘
+```
+
+| 平台 | 技能源目录 | 智能体源目录 | 扩展资源源目录 | 链接方式 |
+|----------|---------------|---------------|---------------|-----------|
+| macOS/Linux | `~/.config/skillshare/skills/` | `~/.config/skillshare/agents/` | `~/.config/skillshare/extras/` | 符号链接 |
+| Windows | `%AppData%\skillshare\skills\` | `%AppData%\skillshare\agents\` | `%AppData%\skillshare\extras\` | NTFS 交接点(无需管理员权限) |
+
+| | 命令式(逐命令安装) | 声明式(skillshare) |
+|---|---|---|
+| **事实来源** | 技能各自独立复制 | 单一来源 → 符号链接(或复制) |
+| **新机器配置** | 重新手动执行每次安装 | `git clone` 配置 + `sync` |
+| **安全审计** | 无 | 内置 `audit` + 安装/更新时自动扫描 |
+| **Web 仪表盘** | 无 | `skillshare ui` |
+| **运行时依赖** | Node.js + npm | 无(单一 Go 二进制文件) |
+
+> [完整对比 →](https://skillshare.runkids.cc/docs/understand/philosophy/comparison)
+
+## CLI 和 UI 预览
+
+| 技能详细页 | 安全审计 |
+|---|---|
+|
|
|
+
+| UI 仪表盘 | UI 技能列表 |
+|---|---|
+|
|
|
+
+## 安装
+
+### macOS / Linux
+
+```bash
+curl -fsSL https://raw.githubusercontent.com/runkids/skillshare/main/install.sh | sh
+```
+
+### Windows PowerShell
+
+```powershell
+irm https://raw.githubusercontent.com/runkids/skillshare/main/install.ps1 | iex
+```
+
+### Homebrew
+
+```bash
+brew install skillshare
+```
+
+> **提示:** 运行 `skillshare upgrade` 即可更新到最新版本。它会自动检测你的安装方式并完成后续操作。
+
+### GitHub Actions
+
+```yaml
+- uses: runkids/setup-skillshare@v1
+ with:
+ source: ./skills
+- run: skillshare sync
+```
+
+查看 [`setup-skillshare`](https://github.com/marketplace/actions/setup-skillshare) 获取所有选项(审计、项目模式、版本锁定等)。
+
+### 缩写别名(可选)
+
+在 shell 配置(`~/.zshrc` 或 `~/.bashrc`)中添加别名:
+
+```bash
+alias ss='skillshare'
+```
+
+## 快速开始
+
+```bash
+skillshare init # 创建配置、源目录并检测目标端
+skillshare sync # 将技能同步到所有目标端
+```
+
+## 亮点功能
+
+**安装和更新技能** — 从 GitHub、GitLab 或任何 Git 仓库
+
+```bash
+skillshare install github.com/reponame/skills
+skillshare update --all
+skillshare target claude --mode copy # 如果符号链接不适用
+```
+
+**符号链接有问题?** — 为每个目标端切换到复制模式
+
+```bash
+skillshare target <名称> --mode copy
+skillshare sync
+```
+
+**安全审计** — 在技能到达智能体之前进行扫描
+
+```bash
+skillshare audit
+```
+
+**项目级技能** — 按仓库管理,随代码一起提交
+
+```bash
+skillshare init -p && skillshare sync
+```
+
+**智能体** — 将自定义智能体同步到支持智能体的目标端
+
+```bash
+skillshare sync agents # 仅同步智能体
+skillshare sync --all # 同步技能 + 智能体 + 扩展资源
+```
+
+**扩展资源** — 管理规则、命令、提示词等
+
+```bash
+skillshare extras init rules # 创建一个 "rules" 扩展
+skillshare sync --all # 同步技能 + 扩展资源
+skillshare extras collect rules # 将本地文件收集回源目录
+```
+
+**Shell 自动补全** — Tab 键补全命令、标志和子命令
+
+```bash
+skillshare completion bash --install # 也支持:zsh、fish、powershell、nushell
+```
+
+**Web 仪表盘** — 可视化控制面板
+
+```bash
+skillshare ui
+```
+
+[所有命令和指南 →](https://skillshare.runkids.cc/docs/reference/commands)
+
+## 参与贡献
+
+欢迎贡献!请先提交 issue,然后提交带测试的草稿 PR。
+查看 [CONTRIBUTING.md](CONTRIBUTING.md) 了解开发环境设置。
+
+```bash
+git clone https://github.com/runkids/skillshare.git && cd skillshare
+make check # 格式化 + 代码检查 + 测试
+```
+
+> [!TIP]
+> 不知道从哪里开始?浏览 [open issues](https://github.com/runkids/skillshare/issues) 或尝试 [Playground](https://skillshare.runkids.cc/docs/learn/with-playground) 获取零配置开发环境。
+
+## 贡献者
+
+感谢所有帮助 skillshare 变得更好的人。
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+---
+
+如果 skillshare 对你有帮助,不妨点个 ⭐ 支持一下
+
+## Star 历史
+
+[](https://www.star-history.com/#runkids/skillshare&type=date&legend=top-left)
+
+---
+
+## 许可证
+
+MIT
From 17a9a0879b60b62232f30a78c7aa04ea5f8ca079 Mon Sep 17 00:00:00 2001
From: zishuo
Date: Tue, 26 May 2026 18:37:54 +0800
Subject: [PATCH 2/6] feat(install): add CNB platform support
Support CNB (Cloud Native Base, cnb.cool) as a git hosting platform for
installing skills. This adds platform detection, token authentication
via CNB_TOKEN, host configuration (cnb_hosts / SKILLSHARE_CNB_HOSTS),
and URL parsing for both direct and web URLs (including /-/tree paths).
Changes:
- auth.go: add PlatformCNB, detect cnb.cool hosts, resolve CNB_TOKEN
- config.go / project.go: add cnb_hosts config field with normalization
and env var merge, plus EffectiveCNBHosts() accessor
- source.go: add isCNBHost() and CNBHosts to ParseOptions
- install.go: pass CNBHosts from config to source parsing
- install_git.go: include CNB_TOKEN in auth error hints
---
cmd/skillshare/install.go | 2 ++
internal/config/config.go | 21 +++++++++++++++++++++
internal/config/project.go | 13 +++++++++++++
internal/install/auth.go | 9 +++++++++
internal/install/install_git.go | 2 +-
internal/install/source.go | 6 ++++++
6 files changed, 52 insertions(+), 1 deletion(-)
diff --git a/cmd/skillshare/install.go b/cmd/skillshare/install.go
index 88f6a044..f1308b26 100644
--- a/cmd/skillshare/install.go
+++ b/cmd/skillshare/install.go
@@ -252,6 +252,7 @@ func parseOptsFromConfig(cfg *config.Config) install.ParseOptions {
return install.ParseOptions{
GitLabHosts: cfg.EffectiveGitLabHosts(),
AzureHosts: cfg.EffectiveAzureHosts(),
+ CNBHosts: cfg.EffectiveCNBHosts(),
}
}
@@ -260,6 +261,7 @@ func parseOptsFromProjectConfig(cfg *config.ProjectConfig) install.ParseOptions
return install.ParseOptions{
GitLabHosts: cfg.EffectiveGitLabHosts(),
AzureHosts: cfg.EffectiveAzureHosts(),
+ CNBHosts: cfg.EffectiveCNBHosts(),
}
}
diff --git a/internal/config/config.go b/internal/config/config.go
index c88a74d0..53f5ed91 100644
--- a/internal/config/config.go
+++ b/internal/config/config.go
@@ -278,6 +278,7 @@ type Config struct {
TUI *bool `yaml:"tui,omitempty"` // nil = default true
GitLabHosts []string `yaml:"gitlab_hosts,omitempty"`
AzureHosts []string `yaml:"azure_hosts,omitempty"`
+ CNBHosts []string `yaml:"cnb_hosts,omitempty"`
// PreserveTildeOnSave folds $HOME prefixes back to ~ when serializing the
// config to YAML. Useful when the config is shared via dotfiles across
@@ -358,6 +359,11 @@ func (c *Config) EffectiveAzureHosts() []string {
return mergeAzureHostsFromEnv(c.AzureHosts)
}
+// EffectiveCNBHosts returns CNBHosts merged with SKILLSHARE_CNB_HOSTS env var.
+func (c *Config) EffectiveCNBHosts() []string {
+ return mergeCNBHostsFromEnv(c.CNBHosts)
+}
+
// IsTUIEnabled reports whether interactive TUI is enabled.
// nil (absent from config) is treated as true for backward compatibility.
func (c *Config) IsTUIEnabled() bool {
@@ -499,6 +505,13 @@ func Load() (*Config, error) {
}
cfg.AzureHosts = azureHosts
+ // Validate and normalize cnb_hosts
+ cnbHosts, err := normalizeCNBHosts(cfg.CNBHosts)
+ if err != nil {
+ return nil, err
+ }
+ cfg.CNBHosts = cnbHosts
+
// Migrate legacy flat target fields to skills: sub-key (one-time, persisted immediately)
if migrateTargetConfigs(cfg.Targets) {
if data, err := marshalYAML(&cfg); err == nil {
@@ -758,6 +771,10 @@ func normalizeAzureHosts(hosts []string) ([]string, error) {
return normalizeHostList(hosts, "azure_hosts")
}
+func normalizeCNBHosts(hosts []string) ([]string, error) {
+ return normalizeHostList(hosts, "cnb_hosts")
+}
+
// mergeHostsFromEnv merges comma-separated env var entries with config file hosts.
// Invalid entries in the env var are silently skipped.
func mergeHostsFromEnv(configHosts []string, envKey string) []string {
@@ -791,6 +808,10 @@ func mergeAzureHostsFromEnv(configHosts []string) []string {
return mergeHostsFromEnv(configHosts, "SKILLSHARE_AZURE_HOSTS")
}
+func mergeCNBHostsFromEnv(configHosts []string) []string {
+ return mergeHostsFromEnv(configHosts, "SKILLSHARE_CNB_HOSTS")
+}
+
func normalizeAuditBlockThreshold(v string) (string, error) {
threshold := strings.ToUpper(strings.TrimSpace(v))
if threshold == "" {
diff --git a/internal/config/project.go b/internal/config/project.go
index 7af009b9..342a37a7 100644
--- a/internal/config/project.go
+++ b/internal/config/project.go
@@ -273,6 +273,7 @@ type ProjectConfig struct {
Hub HubConfig `yaml:"hub,omitempty"`
GitLabHosts []string `yaml:"gitlab_hosts,omitempty"`
AzureHosts []string `yaml:"azure_hosts,omitempty"`
+ CNBHosts []string `yaml:"cnb_hosts,omitempty"`
}
// EffectiveSkillsSource returns the resolved skills source directory.
@@ -339,6 +340,11 @@ func (c *ProjectConfig) EffectiveAzureHosts() []string {
return mergeAzureHostsFromEnv(c.AzureHosts)
}
+// EffectiveCNBHosts returns CNBHosts merged with SKILLSHARE_CNB_HOSTS env var.
+func (c *ProjectConfig) EffectiveCNBHosts() []string {
+ return mergeCNBHostsFromEnv(c.CNBHosts)
+}
+
// ProjectConfigPath returns the project config path for the given root.
func ProjectConfigPath(projectRoot string) string {
return filepath.Join(projectRoot, ".skillshare", "config.yaml")
@@ -381,6 +387,13 @@ func LoadProject(projectRoot string) (*ProjectConfig, error) {
}
cfg.AzureHosts = azureHosts
+ // Validate and normalize cnb_hosts
+ cnbHosts, err := normalizeCNBHosts(cfg.CNBHosts)
+ if err != nil {
+ return nil, fmt.Errorf("project config: %w", err)
+ }
+ cfg.CNBHosts = cnbHosts
+
for _, target := range cfg.Targets {
if strings.TrimSpace(target.Name) == "" {
return nil, fmt.Errorf("project config has target with empty name")
diff --git a/internal/install/auth.go b/internal/install/auth.go
index c21a511f..9bf2a4f7 100644
--- a/internal/install/auth.go
+++ b/internal/install/auth.go
@@ -17,6 +17,7 @@ const (
PlatformGitLab // gitlab.com and self-hosted GitLab
PlatformBitbucket // bitbucket.org
PlatformAzureDevOps // dev.azure.com and visualstudio.com
+ PlatformCNB // cnb.cool and self-hosted CNB instances
)
// extractHost returns the hostname from a clone URL.
@@ -62,6 +63,9 @@ func detectPlatform(cloneURL string) Platform {
if host == "dev.azure.com" || host == "ssh.dev.azure.com" || strings.HasSuffix(host, ".visualstudio.com") {
return PlatformAzureDevOps
}
+ if strings.Contains(host, "cnb.cool") {
+ return PlatformCNB
+ }
return PlatformUnknown
}
@@ -98,6 +102,10 @@ func resolveToken(cloneURL string) (token, username string) {
if t := os.Getenv("AZURE_DEVOPS_TOKEN"); t != "" {
return t, "x-access-token"
}
+ case PlatformCNB:
+ if t := os.Getenv("CNB_TOKEN"); t != "" {
+ return t, "cnb"
+ }
}
// Generic fallback — use platform-appropriate username, or preserve
@@ -195,6 +203,7 @@ func sanitizeTokens(text string) string {
vars := []string{
"GITHUB_TOKEN", "GH_TOKEN", "GITLAB_TOKEN", "BITBUCKET_TOKEN",
"AZURE_DEVOPS_TOKEN", "SKILLSHARE_GIT_TOKEN", "BITBUCKET_USERNAME",
+ "CNB_TOKEN",
}
for _, v := range vars {
if t := os.Getenv(v); t != "" {
diff --git a/internal/install/install_git.go b/internal/install/install_git.go
index f68e69ac..5224ee35 100644
--- a/internal/install/install_git.go
+++ b/internal/install/install_git.go
@@ -74,7 +74,7 @@ func WrapGitError(stderr string, err error, tokenAuthAttempted bool) error {
}
return fmt.Errorf("authentication required — options:\n"+
" 1. SSH URL: git@:/.git\n"+
- " 2. Token env var: GITHUB_TOKEN, GITLAB_TOKEN, BITBUCKET_TOKEN, AZURE_DEVOPS_TOKEN, or SKILLSHARE_GIT_TOKEN\n"+
+ " 2. Token env var: GITHUB_TOKEN, GITLAB_TOKEN, BITBUCKET_TOKEN, AZURE_DEVOPS_TOKEN, CNB_TOKEN, or SKILLSHARE_GIT_TOKEN\n"+
" 3. Git credential helper: gh auth login\n %s", s)
}
if s != "" {
diff --git a/internal/install/source.go b/internal/install/source.go
index db69d81f..faa19a8c 100644
--- a/internal/install/source.go
+++ b/internal/install/source.go
@@ -81,6 +81,7 @@ var azureOnPremPattern = regexp.MustCompile(
type ParseOptions struct {
GitLabHosts []string // extra hostnames to treat as GitLab (nested subgroup support)
AzureHosts []string // extra hostnames to treat as Azure DevOps on-premises
+ CNBHosts []string // extra hostnames to treat as CNB instances
}
// ParseSource analyzes the input string and returns a Source struct.
@@ -462,6 +463,11 @@ func isGitLabHost(host string, extraHosts []string) bool {
hostMatchesAny(host, extraHosts)
}
+// isCNBHost returns true if the host should be treated as a CNB instance.
+func isCNBHost(host string, extraHosts []string) bool {
+ return strings.Contains(host, "cnb.cool") || hostMatchesAny(host, extraHosts)
+}
+
// stripGitBranchPrefix removes platform-specific branch path segments from web URLs.
// Bitbucket: src/{branch}/path → path
// GitLab: -/tree/{branch}/path → path, -/blob/{branch}/path → path
From ce9593e98e8e4da28d4e452fb89d0f49e2d85b11 Mon Sep 17 00:00:00 2001
From: zishuo
Date: Tue, 26 May 2026 18:49:18 +0800
Subject: [PATCH 3/6] feat(install): add Gitea platform support with API fast
path
Support Gitea (gitea.com and self-hosted instances) as a git hosting
platform for installing skills. Includes both core platform integration
and a Gitea Contents API fast path for direct file downloads without
full git clone.
Platform support (P0):
- auth.go: add PlatformGitea, detect gitea hosts, resolve GITEA_TOKEN
- config.go / project.go: add gitea_hosts config field with normalization,
env var merge (SKILLSHARE_GITEA_HOSTS), and EffectiveGiteaHosts()
- source.go: add isGiteaHost() and GiteaHosts to ParseOptions
- install.go: pass GiteaHosts from config to source parsing
- install_git.go: include GITEA_TOKEN in auth error hints
API fast path (P1):
- gitea_download.go: Gitea Contents API recursive directory download
(GET /api/v1/repos/{owner}/{repo}/contents/{path}), matching the
GitHub Contents API pattern
- install_apply.go / install_discovery.go: hook Gitea API fallback
after sparse checkout, before full clone
---
cmd/skillshare/install.go | 2 +
internal/config/config.go | 21 ++
internal/config/project.go | 13 ++
internal/install/auth.go | 10 +-
internal/install/gitea_download.go | 286 ++++++++++++++++++++++++++
internal/install/install_apply.go | 15 ++
internal/install/install_discovery.go | 27 +++
internal/install/install_git.go | 2 +-
internal/install/source.go | 6 +
9 files changed, 380 insertions(+), 2 deletions(-)
create mode 100644 internal/install/gitea_download.go
diff --git a/cmd/skillshare/install.go b/cmd/skillshare/install.go
index f1308b26..33840aae 100644
--- a/cmd/skillshare/install.go
+++ b/cmd/skillshare/install.go
@@ -253,6 +253,7 @@ func parseOptsFromConfig(cfg *config.Config) install.ParseOptions {
GitLabHosts: cfg.EffectiveGitLabHosts(),
AzureHosts: cfg.EffectiveAzureHosts(),
CNBHosts: cfg.EffectiveCNBHosts(),
+ GiteaHosts: cfg.EffectiveGiteaHosts(),
}
}
@@ -262,6 +263,7 @@ func parseOptsFromProjectConfig(cfg *config.ProjectConfig) install.ParseOptions
GitLabHosts: cfg.EffectiveGitLabHosts(),
AzureHosts: cfg.EffectiveAzureHosts(),
CNBHosts: cfg.EffectiveCNBHosts(),
+ GiteaHosts: cfg.EffectiveGiteaHosts(),
}
}
diff --git a/internal/config/config.go b/internal/config/config.go
index 53f5ed91..682c097f 100644
--- a/internal/config/config.go
+++ b/internal/config/config.go
@@ -279,6 +279,7 @@ type Config struct {
GitLabHosts []string `yaml:"gitlab_hosts,omitempty"`
AzureHosts []string `yaml:"azure_hosts,omitempty"`
CNBHosts []string `yaml:"cnb_hosts,omitempty"`
+ GiteaHosts []string `yaml:"gitea_hosts,omitempty"`
// PreserveTildeOnSave folds $HOME prefixes back to ~ when serializing the
// config to YAML. Useful when the config is shared via dotfiles across
@@ -364,6 +365,11 @@ func (c *Config) EffectiveCNBHosts() []string {
return mergeCNBHostsFromEnv(c.CNBHosts)
}
+// EffectiveGiteaHosts returns GiteaHosts merged with SKILLSHARE_GITEA_HOSTS env var.
+func (c *Config) EffectiveGiteaHosts() []string {
+ return mergeGiteaHostsFromEnv(c.GiteaHosts)
+}
+
// IsTUIEnabled reports whether interactive TUI is enabled.
// nil (absent from config) is treated as true for backward compatibility.
func (c *Config) IsTUIEnabled() bool {
@@ -512,6 +518,13 @@ func Load() (*Config, error) {
}
cfg.CNBHosts = cnbHosts
+ // Validate and normalize gitea_hosts
+ giteaHosts, err := normalizeGiteaHosts(cfg.GiteaHosts)
+ if err != nil {
+ return nil, err
+ }
+ cfg.GiteaHosts = giteaHosts
+
// Migrate legacy flat target fields to skills: sub-key (one-time, persisted immediately)
if migrateTargetConfigs(cfg.Targets) {
if data, err := marshalYAML(&cfg); err == nil {
@@ -775,6 +788,10 @@ func normalizeCNBHosts(hosts []string) ([]string, error) {
return normalizeHostList(hosts, "cnb_hosts")
}
+func normalizeGiteaHosts(hosts []string) ([]string, error) {
+ return normalizeHostList(hosts, "gitea_hosts")
+}
+
// mergeHostsFromEnv merges comma-separated env var entries with config file hosts.
// Invalid entries in the env var are silently skipped.
func mergeHostsFromEnv(configHosts []string, envKey string) []string {
@@ -812,6 +829,10 @@ func mergeCNBHostsFromEnv(configHosts []string) []string {
return mergeHostsFromEnv(configHosts, "SKILLSHARE_CNB_HOSTS")
}
+func mergeGiteaHostsFromEnv(configHosts []string) []string {
+ return mergeHostsFromEnv(configHosts, "SKILLSHARE_GITEA_HOSTS")
+}
+
func normalizeAuditBlockThreshold(v string) (string, error) {
threshold := strings.ToUpper(strings.TrimSpace(v))
if threshold == "" {
diff --git a/internal/config/project.go b/internal/config/project.go
index 342a37a7..24f3bfc9 100644
--- a/internal/config/project.go
+++ b/internal/config/project.go
@@ -274,6 +274,7 @@ type ProjectConfig struct {
GitLabHosts []string `yaml:"gitlab_hosts,omitempty"`
AzureHosts []string `yaml:"azure_hosts,omitempty"`
CNBHosts []string `yaml:"cnb_hosts,omitempty"`
+ GiteaHosts []string `yaml:"gitea_hosts,omitempty"`
}
// EffectiveSkillsSource returns the resolved skills source directory.
@@ -345,6 +346,11 @@ func (c *ProjectConfig) EffectiveCNBHosts() []string {
return mergeCNBHostsFromEnv(c.CNBHosts)
}
+// EffectiveGiteaHosts returns GiteaHosts merged with SKILLSHARE_GITEA_HOSTS env var.
+func (c *ProjectConfig) EffectiveGiteaHosts() []string {
+ return mergeGiteaHostsFromEnv(c.GiteaHosts)
+}
+
// ProjectConfigPath returns the project config path for the given root.
func ProjectConfigPath(projectRoot string) string {
return filepath.Join(projectRoot, ".skillshare", "config.yaml")
@@ -394,6 +400,13 @@ func LoadProject(projectRoot string) (*ProjectConfig, error) {
}
cfg.CNBHosts = cnbHosts
+ // Validate and normalize gitea_hosts
+ giteaHosts, err := normalizeGiteaHosts(cfg.GiteaHosts)
+ if err != nil {
+ return nil, fmt.Errorf("project config: %w", err)
+ }
+ cfg.GiteaHosts = giteaHosts
+
for _, target := range cfg.Targets {
if strings.TrimSpace(target.Name) == "" {
return nil, fmt.Errorf("project config has target with empty name")
diff --git a/internal/install/auth.go b/internal/install/auth.go
index 9bf2a4f7..948e344a 100644
--- a/internal/install/auth.go
+++ b/internal/install/auth.go
@@ -18,6 +18,7 @@ const (
PlatformBitbucket // bitbucket.org
PlatformAzureDevOps // dev.azure.com and visualstudio.com
PlatformCNB // cnb.cool and self-hosted CNB instances
+ PlatformGitea // gitea.com and self-hosted Gitea instances
)
// extractHost returns the hostname from a clone URL.
@@ -66,6 +67,9 @@ func detectPlatform(cloneURL string) Platform {
if strings.Contains(host, "cnb.cool") {
return PlatformCNB
}
+ if strings.Contains(host, "gitea") {
+ return PlatformGitea
+ }
return PlatformUnknown
}
@@ -106,6 +110,10 @@ func resolveToken(cloneURL string) (token, username string) {
if t := os.Getenv("CNB_TOKEN"); t != "" {
return t, "cnb"
}
+ case PlatformGitea:
+ if t := os.Getenv("GITEA_TOKEN"); t != "" {
+ return t, "x-access-token"
+ }
}
// Generic fallback — use platform-appropriate username, or preserve
@@ -203,7 +211,7 @@ func sanitizeTokens(text string) string {
vars := []string{
"GITHUB_TOKEN", "GH_TOKEN", "GITLAB_TOKEN", "BITBUCKET_TOKEN",
"AZURE_DEVOPS_TOKEN", "SKILLSHARE_GIT_TOKEN", "BITBUCKET_USERNAME",
- "CNB_TOKEN",
+ "CNB_TOKEN", "GITEA_TOKEN",
}
for _, v := range vars {
if t := os.Getenv(v); t != "" {
diff --git a/internal/install/gitea_download.go b/internal/install/gitea_download.go
new file mode 100644
index 00000000..2e76a329
--- /dev/null
+++ b/internal/install/gitea_download.go
@@ -0,0 +1,286 @@
+package install
+
+import (
+ "bytes"
+ "encoding/json"
+ "fmt"
+ "io"
+ "net/http"
+ "net/url"
+ "os"
+ "path/filepath"
+ "strings"
+ "time"
+)
+
+type giteaContentItem struct {
+ Type string `json:"type"`
+ Name string `json:"name"`
+ Path string `json:"path"`
+ DownloadURL string `json:"download_url"`
+}
+
+type giteaCommit struct {
+ SHA string `json:"sha"`
+}
+
+// isGiteaAPISource reports whether the source is a Gitea instance that supports
+// the Contents API for direct file downloads.
+func isGiteaAPISource(source *Source) bool {
+ if source == nil {
+ return false
+ }
+ host := strings.ToLower(extractHost(source.CloneURL))
+ return strings.Contains(host, "gitea")
+}
+
+// downloadGiteaDir downloads a repository subdirectory via the Gitea Contents API.
+func downloadGiteaDir(owner, repo, path, destDir string, source *Source, onProgress ProgressCallback) (string, error) {
+ if owner == "" || repo == "" {
+ return "", fmt.Errorf("gitea download requires owner and repo")
+ }
+
+ apiBase := giteaAPIBase(source)
+ if err := os.MkdirAll(destDir, 0755); err != nil {
+ return "", err
+ }
+
+ if onProgress != nil {
+ onProgress("Downloading via Gitea API...")
+ }
+
+ client := &http.Client{Timeout: 30 * time.Second}
+ if err := giteaDownloadDirRecursive(client, apiBase, owner, repo, strings.Trim(path, "/"), destDir, onProgress); err != nil {
+ return "", err
+ }
+
+ commitHash, err := giteaFetchLatestCommitHash(apiBase, owner, repo, source)
+ if err != nil {
+ return "", nil
+ }
+ return shortCommitHash(commitHash), nil
+}
+
+// giteaAPIBase returns the base API URL for a Gitea instance.
+func giteaAPIBase(source *Source) string {
+ host := strings.ToLower(extractHost(source.CloneURL))
+ scheme := "https"
+ // For standard gitea.com, use api.gitea.com convention
+ // For self-hosted, use https://{host}/api/v1
+ if host == "gitea.com" {
+ return "https://gitea.com/api/v1"
+ }
+ return fmt.Sprintf("%s://%s/api/v1", scheme, host)
+}
+
+// giteaDownloadDirRecursive recursively downloads a directory via the Gitea Contents API.
+func giteaDownloadDirRecursive(client *http.Client, apiBase, owner, repo, path, destDir string, onProgress ProgressCallback) error {
+ contentsURL := fmt.Sprintf("%s/repos/%s/%s/contents/%s",
+ strings.TrimRight(apiBase, "/"), owner, repo, url.PathEscape(path))
+
+ req, err := giteaNewRequest(contentsURL)
+ if err != nil {
+ return err
+ }
+
+ resp, err := client.Do(req)
+ if err != nil {
+ return fmt.Errorf("Gitea API request failed: %w", err)
+ }
+ defer resp.Body.Close()
+
+ if resp.StatusCode != http.StatusOK {
+ return fmt.Errorf("Gitea contents API returned %d for %s", resp.StatusCode, path)
+ }
+
+ var raw json.RawMessage
+ if err := json.NewDecoder(resp.Body).Decode(&raw); err != nil {
+ return fmt.Errorf("failed to parse Gitea contents response: %w", err)
+ }
+
+ trimmed := bytes.TrimSpace(raw)
+ if len(trimmed) == 0 {
+ return fmt.Errorf("empty Gitea contents response for %q", path)
+ }
+
+ // Single file response: {type, name, path, download_url, ...}
+ if trimmed[0] == '{' {
+ var item giteaContentItem
+ if err := json.Unmarshal(trimmed, &item); err != nil {
+ return err
+ }
+ if item.Type != "file" {
+ return fmt.Errorf("unsupported Gitea content type %q", item.Type)
+ }
+ fileName, err := giteaSanitizeName(item.Name)
+ if err != nil {
+ return err
+ }
+ target := filepath.Join(destDir, fileName)
+ if onProgress != nil {
+ onProgress(fmt.Sprintf("Downloading %s", item.Path))
+ }
+ return giteaDownloadFile(client, item.DownloadURL, target)
+ }
+
+ // Directory listing response: [{type, name, path, download_url, ...}]
+ if trimmed[0] == '[' {
+ var items []giteaContentItem
+ if err := json.Unmarshal(trimmed, &items); err != nil {
+ return err
+ }
+ for _, item := range items {
+ name, err := giteaSanitizeName(item.Name)
+ if err != nil {
+ return err
+ }
+ switch item.Type {
+ case "dir":
+ childDir := filepath.Join(destDir, name)
+ if err := os.MkdirAll(childDir, 0755); err != nil {
+ return err
+ }
+ if err := giteaDownloadDirRecursive(client, apiBase, owner, repo, item.Path, childDir, onProgress); err != nil {
+ return err
+ }
+ case "file":
+ target := filepath.Join(destDir, name)
+ if onProgress != nil {
+ onProgress(fmt.Sprintf("Downloading %s", item.Path))
+ }
+ if err := giteaDownloadFile(client, item.DownloadURL, target); err != nil {
+ return err
+ }
+ }
+ }
+ return nil
+ }
+
+ return fmt.Errorf("unexpected Gitea contents payload for %q", path)
+}
+
+// giteaDownloadFile downloads a single file from a URL.
+func giteaDownloadFile(client *http.Client, fileURL, destPath string) error {
+ req, err := giteaNewRequest(fileURL)
+ if err != nil {
+ return err
+ }
+
+ resp, err := client.Do(req)
+ if err != nil {
+ return err
+ }
+ defer resp.Body.Close()
+
+ if resp.StatusCode != http.StatusOK {
+ return fmt.Errorf("download returned %d", resp.StatusCode)
+ }
+
+ if err := os.MkdirAll(filepath.Dir(destPath), 0755); err != nil {
+ return err
+ }
+
+ f, err := os.OpenFile(destPath, os.O_CREATE|os.O_TRUNC|os.O_WRONLY, 0644)
+ if err != nil {
+ return err
+ }
+ defer f.Close()
+
+ _, err = io.Copy(f, resp.Body)
+ return err
+}
+
+// giteaNewRequest creates a GET request with Gitea API headers and optional
+// token authentication (GITEA_TOKEN or platform-resolved token).
+func giteaNewRequest(reqURL string) (*http.Request, error) {
+ req, err := http.NewRequest(http.MethodGet, reqURL, nil)
+ if err != nil {
+ return nil, err
+ }
+
+ req.Header.Set("Accept", "application/json")
+
+ // Try GITEA_TOKEN first, then SKILLSHARE_GIT_TOKEN
+ token := os.Getenv("GITEA_TOKEN")
+ if token == "" {
+ token = os.Getenv("SKILLSHARE_GIT_TOKEN")
+ }
+ if token != "" {
+ req.Header.Set("Authorization", "token "+token)
+ }
+
+ return req, nil
+}
+
+// giteaFetchLatestCommitHash retrieves the latest commit SHA from a Gitea repo.
+func giteaFetchLatestCommitHash(apiBase, owner, repo string, source *Source) (string, error) {
+ commitsURL := fmt.Sprintf("%s/repos/%s/%s/commits?per_page=1",
+ strings.TrimRight(apiBase, "/"), owner, repo)
+
+ req, err := giteaNewRequest(commitsURL)
+ if err != nil {
+ return "", err
+ }
+
+ client := &http.Client{Timeout: 15 * time.Second}
+ resp, err := client.Do(req)
+ if err != nil {
+ return "", err
+ }
+ defer resp.Body.Close()
+
+ if resp.StatusCode == http.StatusOK {
+ var commits []giteaCommit
+ if decodeErr := json.NewDecoder(resp.Body).Decode(&commits); decodeErr == nil && len(commits) > 0 {
+ return commits[0].SHA, nil
+ }
+ }
+
+ // Fallback: use git ls-remote
+ if source != nil && source.CloneURL != "" {
+ return getRemoteHeadCommit(source.CloneURL)
+ }
+
+ return "", fmt.Errorf("failed to fetch latest commit hash")
+}
+
+// giteaSanitizeName validates a Gitea file/directory name.
+func giteaSanitizeName(name string) (string, error) {
+ name = strings.TrimSpace(name)
+ if name == "" || name == "." || name == ".." || strings.Contains(name, "/") || strings.Contains(name, "\\") {
+ return "", fmt.Errorf("invalid Gitea item name %q", name)
+ }
+ return name, nil
+}
+
+// giteaOwnerRepo extracts the owner and repo name from a Gitea clone URL.
+// Clone URLs are in the format: https://host/owner/repo.git or git@host:owner/repo.git
+func giteaOwnerRepo(cloneURL string) (owner, repo string) {
+ u := strings.TrimSpace(cloneURL)
+ u = strings.TrimSuffix(u, ".git")
+ u = strings.TrimSuffix(u, "/")
+
+ // SSH: git@host:owner/repo
+ if strings.HasPrefix(u, "git@") {
+ parts := strings.Split(u, ":")
+ if len(parts) == 2 {
+ segments := strings.Split(parts[1], "/")
+ if len(segments) >= 2 {
+ return segments[0], segments[1]
+ }
+ }
+ return "", ""
+ }
+
+ // HTTPS: https://host/owner/repo
+ parsed, err := url.Parse(u)
+ if err != nil {
+ return "", ""
+ }
+ path := strings.Trim(parsed.Path, "/")
+ segments := strings.Split(path, "/")
+ if len(segments) >= 2 {
+ return segments[0], segments[1]
+ }
+ return "", ""
+}
diff --git a/internal/install/install_apply.go b/internal/install/install_apply.go
index f825d21f..f793fd76 100644
--- a/internal/install/install_apply.go
+++ b/internal/install/install_apply.go
@@ -492,6 +492,21 @@ func installFromGitSubdir(source *Source, destPath string, result *InstallResult
}
}
+ // Fast path 2b: Gitea Contents API
+ if subdirPath == "" && isGiteaAPISource(source) {
+ owner, repo := giteaOwnerRepo(source.CloneURL)
+ resolved = source.Subdir
+ subdirPath = filepath.Join(tempRepoPath, resolved)
+ hash, dlErr := downloadGiteaDir(owner, repo, source.Subdir, subdirPath, source, opts.OnProgress)
+ if dlErr == nil {
+ commitHash = hash
+ } else {
+ result.Warnings = append(result.Warnings, fmt.Sprintf("Gitea API install fallback: %v", dlErr))
+ subdirPath = ""
+ _ = os.RemoveAll(tempRepoPath)
+ }
+ }
+
// Fallback: full clone + fuzzy subdir resolution
if subdirPath == "" {
_ = os.RemoveAll(tempRepoPath)
diff --git a/internal/install/install_discovery.go b/internal/install/install_discovery.go
index d7a30ea2..ccc11675 100644
--- a/internal/install/install_discovery.go
+++ b/internal/install/install_discovery.go
@@ -389,6 +389,33 @@ func discoverFromGitSubdirWithProgressImpl(source *Source, onProgress ProgressCa
subdirPath = ""
}
+ // Fast path 2b: Gitea Contents API
+ if subdirPath == "" && isGiteaAPISource(source) {
+ owner, repo := giteaOwnerRepo(source.CloneURL)
+ subdirPath = filepath.Join(repoPath, source.Subdir)
+ hash, dlErr := downloadGiteaDir(owner, repo, source.Subdir, subdirPath, source, onProgress)
+ if dlErr == nil {
+ commitHash = hash
+ skills := discoverSkills(subdirPath, true)
+ agents := discoverAgents(subdirPath, len(skills) > 0)
+ skills, agents, err = constrainDiscoveryToExplicitSkill(source, skills, agents)
+ if err != nil {
+ _ = os.RemoveAll(tempDir)
+ return nil, err
+ }
+ return &DiscoveryResult{
+ RepoPath: tempDir,
+ Skills: skills,
+ Agents: agents,
+ Source: source,
+ CommitHash: commitHash,
+ }, nil
+ }
+ warnings = append(warnings, fmt.Sprintf("Gitea API discovery fallback: %v", dlErr))
+ _ = os.RemoveAll(repoPath)
+ subdirPath = ""
+ }
+
// Fallback: full clone + fuzzy subdir resolution
_ = os.RemoveAll(repoPath)
if onProgress != nil {
diff --git a/internal/install/install_git.go b/internal/install/install_git.go
index 5224ee35..5b1554fa 100644
--- a/internal/install/install_git.go
+++ b/internal/install/install_git.go
@@ -74,7 +74,7 @@ func WrapGitError(stderr string, err error, tokenAuthAttempted bool) error {
}
return fmt.Errorf("authentication required — options:\n"+
" 1. SSH URL: git@:/.git\n"+
- " 2. Token env var: GITHUB_TOKEN, GITLAB_TOKEN, BITBUCKET_TOKEN, AZURE_DEVOPS_TOKEN, CNB_TOKEN, or SKILLSHARE_GIT_TOKEN\n"+
+ " 2. Token env var: GITHUB_TOKEN, GITLAB_TOKEN, BITBUCKET_TOKEN, AZURE_DEVOPS_TOKEN, CNB_TOKEN, GITEA_TOKEN, or SKILLSHARE_GIT_TOKEN\n"+
" 3. Git credential helper: gh auth login\n %s", s)
}
if s != "" {
diff --git a/internal/install/source.go b/internal/install/source.go
index faa19a8c..1b4300c7 100644
--- a/internal/install/source.go
+++ b/internal/install/source.go
@@ -82,6 +82,7 @@ type ParseOptions struct {
GitLabHosts []string // extra hostnames to treat as GitLab (nested subgroup support)
AzureHosts []string // extra hostnames to treat as Azure DevOps on-premises
CNBHosts []string // extra hostnames to treat as CNB instances
+ GiteaHosts []string // extra hostnames to treat as Gitea instances
}
// ParseSource analyzes the input string and returns a Source struct.
@@ -468,6 +469,11 @@ func isCNBHost(host string, extraHosts []string) bool {
return strings.Contains(host, "cnb.cool") || hostMatchesAny(host, extraHosts)
}
+// isGiteaHost returns true if the host should be treated as a Gitea instance.
+func isGiteaHost(host string, extraHosts []string) bool {
+ return strings.Contains(host, "gitea") || hostMatchesAny(host, extraHosts)
+}
+
// stripGitBranchPrefix removes platform-specific branch path segments from web URLs.
// Bitbucket: src/{branch}/path → path
// GitLab: -/tree/{branch}/path → path, -/blob/{branch}/path → path
From 4112b9d47e6c20ddf84b4d2d29dba6cee2e6e022 Mon Sep 17 00:00:00 2001
From: zishuo
Date: Tue, 26 May 2026 19:05:45 +0800
Subject: [PATCH 4/6] docs(zh): update version to v0.19.23 in Chinese README
---
README-zh.md | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/README-zh.md b/README-zh.md
index 3950ffd9..b579747c 100644
--- a/README-zh.md
+++ b/README-zh.md
@@ -41,7 +41,7 @@
> [!NOTE]
-> **最新版本**: [v0.19.12](https://github.com/runkids/skillshare/releases/tag/v0.19.12) — config.yaml 中的 `skills:` 字段现在会保留(修复了团队共享问题)。[查看全部版本 →](https://github.com/runkids/skillshare/releases)
+> **最新版本**: [v0.19.23](https://github.com/runkids/skillshare/releases/tag/v0.19.23) — 子目录安装的技能在更新后不再重复标记为可更新,仪表盘更新检测状态现在会跨会话保留。[查看全部版本 →](https://github.com/runkids/skillshare/releases)
## 为什么选择 skillshare
From c3c0764365452437f42deddcf0a295de3500c901 Mon Sep 17 00:00:00 2001
From: zishuo
Date: Tue, 26 May 2026 19:21:31 +0800
Subject: [PATCH 5/6] fix(gitea): use segment-by-segment path escaping in
Contents API URL
Replace url.PathEscape(path) with escapeGiteaPath() that escapes each
path segment individually, preserving directory separators. The previous
approach would encode slashes as %2F, breaking nested subdirectory
downloads via the Gitea Contents API.
---
internal/install/gitea_download.go | 12 +++++++++++-
1 file changed, 11 insertions(+), 1 deletion(-)
diff --git a/internal/install/gitea_download.go b/internal/install/gitea_download.go
index 2e76a329..2886454b 100644
--- a/internal/install/gitea_download.go
+++ b/internal/install/gitea_download.go
@@ -76,7 +76,7 @@ func giteaAPIBase(source *Source) string {
// giteaDownloadDirRecursive recursively downloads a directory via the Gitea Contents API.
func giteaDownloadDirRecursive(client *http.Client, apiBase, owner, repo, path, destDir string, onProgress ProgressCallback) error {
contentsURL := fmt.Sprintf("%s/repos/%s/%s/contents/%s",
- strings.TrimRight(apiBase, "/"), owner, repo, url.PathEscape(path))
+ strings.TrimRight(apiBase, "/"), owner, repo, escapeGiteaPath(path))
req, err := giteaNewRequest(contentsURL)
if err != nil {
@@ -284,3 +284,13 @@ func giteaOwnerRepo(cloneURL string) (owner, repo string) {
}
return "", ""
}
+
+// escapeGiteaPath escapes each path segment individually for the Gitea Contents API.
+// This preserves directory separators while encoding special characters in each segment.
+func escapeGiteaPath(path string) string {
+ parts := strings.Split(path, "/")
+ for i := range parts {
+ parts[i] = url.PathEscape(parts[i])
+ }
+ return strings.Join(parts, "/")
+}
From bbd9090348920fbf33c0a44bdb2f85470f50696f Mon Sep 17 00:00:00 2001
From: zishuo
Date: Tue, 26 May 2026 19:54:58 +0800
Subject: [PATCH 6/6] fix: address bot review comments on PR #168
- fix(gitea): use shortHash instead of undefined shortCommitHash
- fix(gitea): use strings.LastIndex for robust SSH URL parsing
- fix(discovery): preserve warnings in Gitea API discovery fast path
- feat(auth): add detectPlatformFromHost with configured host support
---
internal/install/gitea_download.go | 8 ++++----
internal/install/install_discovery.go | 1 +
internal/install/source.go | 28 +++++++++++++++++++++++++++
3 files changed, 33 insertions(+), 4 deletions(-)
diff --git a/internal/install/gitea_download.go b/internal/install/gitea_download.go
index 2886454b..86854e1c 100644
--- a/internal/install/gitea_download.go
+++ b/internal/install/gitea_download.go
@@ -58,7 +58,7 @@ func downloadGiteaDir(owner, repo, path, destDir string, source *Source, onProgr
if err != nil {
return "", nil
}
- return shortCommitHash(commitHash), nil
+ return shortHash(commitHash), nil
}
// giteaAPIBase returns the base API URL for a Gitea instance.
@@ -262,9 +262,9 @@ func giteaOwnerRepo(cloneURL string) (owner, repo string) {
// SSH: git@host:owner/repo
if strings.HasPrefix(u, "git@") {
- parts := strings.Split(u, ":")
- if len(parts) == 2 {
- segments := strings.Split(parts[1], "/")
+ colon := strings.LastIndex(u, ":")
+ if colon != -1 {
+ segments := strings.Split(strings.Trim(u[colon+1:], "/"), "/")
if len(segments) >= 2 {
return segments[0], segments[1]
}
diff --git a/internal/install/install_discovery.go b/internal/install/install_discovery.go
index ccc11675..3169f94d 100644
--- a/internal/install/install_discovery.go
+++ b/internal/install/install_discovery.go
@@ -409,6 +409,7 @@ func discoverFromGitSubdirWithProgressImpl(source *Source, onProgress ProgressCa
Agents: agents,
Source: source,
CommitHash: commitHash,
+ Warnings: warnings,
}, nil
}
warnings = append(warnings, fmt.Sprintf("Gitea API discovery fallback: %v", dlErr))
diff --git a/internal/install/source.go b/internal/install/source.go
index 1b4300c7..ae960333 100644
--- a/internal/install/source.go
+++ b/internal/install/source.go
@@ -474,6 +474,34 @@ func isGiteaHost(host string, extraHosts []string) bool {
return strings.Contains(host, "gitea") || hostMatchesAny(host, extraHosts)
}
+// detectPlatformFromHost returns the platform for a given hostname, using
+// configured extra hosts for CNB and Gitea self-hosted instances.
+func detectPlatformFromHost(host string, cnbHosts, giteaHosts []string) Platform {
+ host = strings.ToLower(host)
+ if host == "" {
+ return PlatformUnknown
+ }
+ if strings.Contains(host, "github") {
+ return PlatformGitHub
+ }
+ if strings.Contains(host, "gitlab") {
+ return PlatformGitLab
+ }
+ if strings.Contains(host, "bitbucket") {
+ return PlatformBitbucket
+ }
+ if host == "dev.azure.com" || host == "ssh.dev.azure.com" || strings.HasSuffix(host, ".visualstudio.com") {
+ return PlatformAzureDevOps
+ }
+ if isCNBHost(host, cnbHosts) {
+ return PlatformCNB
+ }
+ if isGiteaHost(host, giteaHosts) {
+ return PlatformGitea
+ }
+ return PlatformUnknown
+}
+
// stripGitBranchPrefix removes platform-specific branch path segments from web URLs.
// Bitbucket: src/{branch}/path → path
// GitLab: -/tree/{branch}/path → path, -/blob/{branch}/path → path