feat: generalize skill sync via GitRepoAdapter, add GitLab support#14153
Open
renefichtmueller wants to merge 1 commit into
Open
feat: generalize skill sync via GitRepoAdapter, add GitLab support#14153renefichtmueller wants to merge 1 commit into
renefichtmueller wants to merge 1 commit into
Conversation
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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:GitRepoAdapterinterface (packages/api/src/skills/sync/adapters/types.ts) covering exactly the REST-specific surface the orchestration needs:resolveCommit,fetchTreeEntries,fetchFileContent.adapters/github.tsimplementing that interface;github.tsitself now only contains the (unchanged) generic orchestration, calling through the adapter.adapters/gitlab.ts(list tree viaGET /projects/{id}/repository/tree?recursive=true, fetch blob viaGET /projects/{id}/repository/files/{path}/raw,Private-Tokenauth, configurablebaseUrlfor self-hosted GitLab) and a parallelpackages/api/src/skills/sync/gitlab.tsorchestrator mirroringgithub.ts.createRepoAdapterfactory (adapters/factory.ts) that picks the right adapter by provider.skillSyncConfigSchema(packages/data-provider/src/config.ts) with agitlabkey mirroring thegithubkey's shape/validation, and extendsSkillSyncProviderto'github' | 'gitlab'.'gitlab'to theSkill.sourceenum andSkillSyncStatusInput/ISkillSyncStatusgainbaseUrl/projectIdfields alongside the existing GitHubowner/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 newadapters/gitlab.spec.tsandadapters/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 passingpackages/data-provider:npx jest src/config— 119/119 passing (schema extension didn't break existing config validation)tsc --noEmitclean onpackages/api,packages/data-schemas,packages/data-providereslintclean on all changed/new files