Skip to content

feat: generalize skill sync via GitRepoAdapter, add GitLab support#14153

Open
renefichtmueller wants to merge 1 commit into
danny-avila:mainfrom
renefichtmueller:upstream-skillsync-gitlab-adapter
Open

feat: generalize skill sync via GitRepoAdapter, add GitLab support#14153
renefichtmueller wants to merge 1 commit into
danny-avila:mainfrom
renefichtmueller:upstream-skillsync-gitlab-adapter

Conversation

@renefichtmueller

Copy link
Copy Markdown

Summary

Addresses #13990 (generalize skill sync beyond GitHub) — scoped to GitLab only for this PR; Bitbucket and Azure DevOps are natural follow-ups once this pattern is proven, not included here.

The existing GitHub-only skill-sync runner (packages/api/src/skills/sync/github.ts) tightly interleaved GitHub-specific REST calls with generic orchestration logic (skill discovery, DB upsert/cleanup, sync counters, stale-delete ordering). This PR:

  • Extracts a GitRepoAdapter interface (packages/api/src/skills/sync/adapters/types.ts) covering exactly the REST-specific surface the orchestration needs: resolveCommit, fetchTreeEntries, fetchFileContent.
  • Moves the GitHub REST implementation into adapters/github.ts implementing that interface; github.ts itself now only contains the (unchanged) generic orchestration, calling through the adapter.
  • Implements adapters/gitlab.ts (list tree via GET /projects/{id}/repository/tree?recursive=true, fetch blob via GET /projects/{id}/repository/files/{path}/raw, Private-Token auth, configurable baseUrl for self-hosted GitLab) and a parallel packages/api/src/skills/sync/gitlab.ts orchestrator mirroring github.ts.
  • Adds a createRepoAdapter factory (adapters/factory.ts) that picks the right adapter by provider.
  • Extends skillSyncConfigSchema (packages/data-provider/src/config.ts) with a gitlab key mirroring the github key's shape/validation, and extends SkillSyncProvider to 'github' | 'gitlab'.
  • Adds 'gitlab' to the Skill.source enum and SkillSyncStatusInput/ISkillSyncStatus gain baseUrl/projectId fields alongside the existing GitHub owner/repo.

Regression safety was the top priority for the extraction. Every existing GitHub sync test passes unmodified in behavior — only import paths changed where the code moved into adapters/github.ts.

Test plan

  • packages/api: npx jest src/skills/sync — 69/69 passing (includes all pre-existing GitHub orchestrator/scheduler tests unmodified, plus new adapters/gitlab.spec.ts and adapters/factory.spec.ts)
  • packages/api: npx jest src/admin/skills.spec.ts — 10/10 passing (admin skill-sync API surface, unaffected)
  • packages/data-schemas: npx jest src/methods/skillSync.spec.ts src/methods/skill.spec.ts — 106/106 passing
  • packages/data-provider: npx jest src/config — 119/119 passing (schema extension didn't break existing config validation)
  • tsc --noEmit clean on packages/api, packages/data-schemas, packages/data-provider
  • eslint clean on all changed/new files

Extracts the GitHub-specific REST calls out of the skill-sync runner into
a GitRepoAdapter interface (resolveCommit/fetchTreeEntries/fetchFileContent),
implemented by packages/api/src/skills/sync/adapters/{github,gitlab}.ts.
The generic orchestration (discovery, DB upsert/cleanup, sync counters,
stale-delete ordering) is unchanged and now depends only on the adapter
interface, never on a provider's HTTP shape directly.

Adds a GitLab source alongside the existing GitHub one, including
self-hosted GitLab support via a configurable baseUrl. Bitbucket and
Azure DevOps are deliberately left out of this change — same adapter
interface, follow-up PRs.
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