Add support for SkillRepository from any Git source#6571
Draft
calvinmclean wants to merge 4 commits into
Draft
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
This PR expands SkillRepository support beyond GitHub-only archives by introducing a shared pkg/git cloning utility and wiring SkillRepository creation/sync to use it, including optional per-repository personal access tokens stored as GPTScript credentials.
Changes:
- Add a generic
pkg/gitpackage (URL parsing, repo size checks, HTTPS cloning with size limits) and reuse it from MCP catalog + SkillRepository flows. - Extend SkillRepository manifest/types to carry optional
sourceURLCredentialsand add UI support for entering a personal access token. - Update controller/API handlers to store/reveal tokens via GPTScript credentials and pass them into repository sync.
Reviewed changes
Copilot reviewed 18 out of 18 changed files in this pull request and generated 6 comments.
Show a summary per file
| File | Description |
|---|---|
| ui/user/src/routes/admin/skills/+page.svelte | Adds optional PAT input and sends sourceURLCredentials on SkillRepository create. |
| ui/user/src/lib/services/admin/types.ts | Extends admin client types with sourceURLCredentials. |
| pkg/git/git.go | New shared git clone + URL parsing + pre-clone size checks. |
| pkg/git/git_test.go | Unit tests for IsGitRepoURL and parseGitURL. |
| pkg/git/fs.go | Moves/renames size-limited filesystem wrapper into pkg/git. |
| pkg/git/fs_test.go | Updates tests for the moved size-limited filesystem wrapper. |
| pkg/controller/routes.go | Wires SkillRepository handler construction with GPT client. |
| pkg/controller/handlers/skillrepository/skillrepository.go | Switches SkillRepository syncing/materialization to generic git fetch + credential reveal. |
| pkg/controller/handlers/skillrepository/skillrepository_test.go | Updates fetcher mocks/signatures to match new fetch interface. |
| pkg/controller/handlers/skillrepository/scan.go | Pulls maxSkillMDBytes constant into scan package scope. |
| pkg/controller/handlers/skillrepository/github.go | Replaces GitHub-only URL validation with git-based validation helper. |
| pkg/controller/handlers/skillrepository/github_test.go | Updates URL validation tests for the new validation behavior. |
| pkg/controller/handlers/skillrepository/git.go | New git-backed repository fetcher using pkg/git.Clone. |
| pkg/controller/handlers/mcpcatalog/mcpcatalog.go | Reuses pkg/git.IsGitRepoURL and relocates isPathSafe. |
| pkg/controller/handlers/mcpcatalog/github.go | Replaces inline clone logic with shared pkg/git.Clone. |
| pkg/controller/handlers/mcpcatalog/github_test.go | Removes duplicated git URL parsing tests (now covered in pkg/git). |
| pkg/api/handlers/skillrepositories.go | Stores/reveals per-repo tokens via GPTScript credentials and masks them in responses. |
| apiclient/types/skillrepository.go | Adds sourceURLCredentials to the public API types. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
4631cf7 to
b13378d
Compare
|
|
||
| sizeMB := repoInfo.Size / 1024 | ||
| if sizeMB > maxSizeMB { | ||
| return fmt.Errorf("repository %s/%s is too large: %d MB (limit: %d MB)", org, repo, sizeMB, maxSizeMB) |
| } | ||
|
|
||
| if sizeMB := info.Statistics.RepositorySize / (1024 * 1024); sizeMB > int64(maxSizeMB) { | ||
| return fmt.Errorf("repository %s is too large: %d MB (limit: %d MB)", projectPath, sizeMB, maxSizeMB) |
Comment on lines
+178
to
+190
| clonedRepo, cloneErr := gogit.CloneContext(ctx, storer, limitedFS, cloneOptions) | ||
| if cloneErr != nil { | ||
| attemptErrs = append(attemptErrs, fmt.Errorf("%s %s: %w", attempt.name, refAttempt.name, cloneErr)) | ||
| if errors.Is(cloneErr, errRepoTooLarge) { | ||
| cleanupFn() | ||
| return "", "", nil, fmt.Errorf("repository is too large (limit: %d MB)", maxRepoSizeMB) | ||
| } | ||
| if isContextError(cloneErr) { | ||
| cleanupFn() | ||
| return "", "", nil, fmt.Errorf("failed to clone repository: %w", cloneErr) | ||
| } | ||
| continue | ||
| } |
Comment on lines
249
to
252
|
|
||
| fetched, err := fetcher.MaterializeCommit(ctx, skill.Spec.RepoURL, skill.Spec.CommitSHA) | ||
| fetched, err := fetcher.Fetch(ctx, skill.Spec.RepoURL, "", skill.Spec.CommitSHA) | ||
| if err != nil { | ||
| return nil, "", err |
Comment on lines
+23
to
26
| const maxSkillMDBytes = 1024 * 1024 | ||
|
|
||
| func buildSkillsFromRepository(repoRoot string, repo *v1.SkillRepository, commitSHA string, indexedAt metav1.Time) ([]*v1.Skill, error) { | ||
| directories, err := discoverSkillDirectories(repoRoot) |
Comment on lines
+529
to
+537
| const repoURL = editingSource.value.trim(); | ||
| const manifest: Parameters<typeof AdminService.createSkillRepository>[0] = { | ||
| displayName: editingSource.name, | ||
| repoURL: editingSource.value, | ||
| repoURL, | ||
| ref: editingSource.ref | ||
| }); | ||
| }; | ||
| if (editingSource.token) { | ||
| manifest.sourceURLCredentials = { [repoURL]: editingSource.token }; | ||
| } |
| syncError?: string; | ||
| resolvedCommitSHA?: string; | ||
| discoveredSkillCount: number; | ||
| sourceURLCredentials?: Record<string, string>; |
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.
Addresses #6548