Repository navigation
feat: support Git source URLs in collection YAML - #37
Conversation
Add Source field to SkillRef struct for Git URL references. Update Validate() to enforce mutual exclusivity between image and source fields. Name is optional for source entries (derived at install time from SKILL.md frontmatter). Refs: #35 Assisted-By: Claude (Anthropic AI) <[email protected]> Signed-off-by: Pavel Anni <[email protected]>
LsRemote queries a remote Git repo for the commit SHA of a ref without cloning. Used by collection install to skip unchanged source entries. Refs: #35 Assisted-By: Claude (Anthropic AI) <[email protected]> Signed-off-by: Pavel Anni <[email protected]>
Export WriteProvenance and NewSkillCardFromRef so the collection install command can reuse them. Refs: #35 Assisted-By: Claude (Anthropic AI) <[email protected]> Signed-off-by: Pavel Anni <[email protected]>
Implements skillctl collection install with support for both image: (OCI registry) and source: (Git URL) entries. Includes SHA/digest-based skip logic and --force flag to override. Refs: #35 Assisted-By: Claude (Anthropic AI) <[email protected]> Signed-off-by: Pavel Anni <[email protected]>
Tests input validation, target resolution, invalid YAML handling, and mutual exclusivity validation for the collection install command. Refs: #35 Assisted-By: Claude (Anthropic AI) <[email protected]> Signed-off-by: Pavel Anni <[email protected]>
Shows mixed source: (Git URL) and image: (OCI ref) entries in a collection YAML for the development workflow. Refs: #35 Assisted-By: Claude (Anthropic AI) <[email protected]> Signed-off-by: Pavel Anni <[email protected]>
Pull from remote first, then compare remote digest against installed digest. Fixes bug where stale local store would cause collection install to incorrectly skip image updates. Refs: #35 Assisted-By: Claude (Anthropic AI) <[email protected]> Signed-off-by: Pavel Anni <[email protected]>
|
Warning Rate limit exceeded
To keep reviews running without waiting, you can enable usage-based add-on for your organization. This allows additional reviews beyond the hourly cap. Account admins can enable it under billing. ⌛ How to resolve this issue?After the wait time has elapsed, a review can be triggered using the We recommend that you space out your commits to avoid hitting the rate limit. 🚦 How do rate limits work?CodeRabbit enforces hourly rate limits for each developer per organization. Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout. Please see our FAQ for further information. ℹ️ Review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Enterprise Run ID: 📒 Files selected for processing (1)
📝 WalkthroughWalkthroughAdds a new Changes
Sequence DiagramsequenceDiagram
participant User
participant CLI as collection install
participant Resolver as Collection Resolver
participant Validator as Validator
participant Git as Git Ops
participant OCI as OCI Client
participant FS as Filesystem
participant Prov as Provenance Writer
User->>CLI: run collection install (file or Git URL)
CLI->>Resolver: load & parse collection
Resolver-->>CLI: collection data
CLI->>Validator: validate collection schema
Validator-->>CLI: validation result
CLI->>FS: ensure destination directory
FS-->>CLI: ready
loop per skill
alt image (OCI)
CLI->>OCI: pull image (if remote)
OCI-->>CLI: image data/digest
CLI->>FS: unpack image to dest
CLI->>Prov: WriteProvenance(digest)
Prov-->>CLI: success / warn
else source (Git)
CLI->>Git: LsRemote(cloneURL, ref)
Git-->>CLI: commit SHA
CLI->>Git: clone/fetch at SHA (sparse unless disabled)
Git-->>CLI: repo checked out
CLI->>OCI: build artifact from repo
OCI-->>CLI: built artifact
CLI->>FS: unpack artifact to dest
CLI->>Prov: WriteProvenance(commit SHA)
Prov-->>CLI: success / warn
end
end
CLI-->>User: complete (or error if failures)
Estimated code review effort🎯 4 (Complex) | ⏱️ ~45 minutes 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Review rate limit: 0/1 reviews remaining, refill in 51 minutes and 13 seconds.Comment |
Refs: #35 Assisted-By: Claude (Anthropic AI) <[email protected]> Signed-off-by: Pavel Anni <[email protected]>
There was a problem hiding this comment.
Actionable comments posted: 4
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
internal/cli/install.go (1)
178-200:⚠️ Potential issue | 🟠 Major | ⚡ Quick winDerive
Metadata.Namespacefrom the repository path, not the registry host.Using the first
/truncates multi-segment refs, soghcr.io/org/team/skill:1.2.3is serialized withNamespace: ghcr.ioinstead ofghcr.io/org/team. That writes incorrect provenance/metadata for any nested repo path.Proposed fix
- namespace := "unknown" - if idx := strings.Index(ref, "/"); idx >= 0 { - namespace = ref[:idx] - } + namespace := "unknown" + if idx := strings.LastIndex(ref, "/"); idx >= 0 { + namespace = ref[:idx] + }🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@internal/cli/install.go` around lines 178 - 200, NewSkillCardFromRef currently derives Metadata.Namespace by taking everything before the first '/' which yields only the registry host; change it to derive the repository path by using the last '/' in the ref so nested repo paths are preserved (e.g. "ghcr.io/org/team" for "ghcr.io/org/team/skill:1.2.3"). In NewSkillCardFromRef, replace the first-slash logic with strings.LastIndex(ref, "/") and set namespace = ref[:lastSlash] when lastSlash >= 0 (leave "unknown" otherwise); keep tagFromRef/version handling and the call sites intact so only namespace serialization changes.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@internal/cli/collection.go`:
- Around line 321-341: The skip-on-up-to-date logic in installFromSource
currently only runs when skillLabel(s) is non-empty, so source-based skills
without a name never hit the git ls-remote fast path; change the gate to use a
resolved identity instead of the optional collection label: in
installFromSource, remove the label != "" condition and compute a stable key
(e.g., resolvedID := skillLabel(s); if resolvedID == "" { resolvedID =
resolveSkillIdentityFromSource(src) } ) then call readInstalledCommit(destDir,
resolvedID) and proceed with the existing ref/ls-remote comparison (using
source.ParseGitURL and source.LsRemote) so unnamed source entries can be skipped
correctly; alternatively enforce a name in validation if you prefer, but
implement the resolvedID approach in installFromSource to fix the current
behavior.
In `@pkg/collection/collection.go`:
- Around line 66-79: The validation currently allows entries with s.Source set
but no s.Name which later causes invalid Kube/Podman generation; update the
validation block around s.Image/s.Source/s.Name (the switch and subsequent
checks that append to errs and update seen) to explicitly reject source-only
entries by adding a case for s.Source != "" && s.Name == "" with an error like
"skills[%d].name is required for source entries", and ensure duplicate-name
checks (seen map) still run only when s.Name != ""; alternatively, if you prefer
generator-side enforcement, modify the generator functions that render
Kube/Podman output to return an error when encountering a skill with s.Source
set and s.Name empty so generation fails fast.
In `@pkg/source/lsremote_test.go`:
- Around line 8-35: The tests TestLsRemoteReturnsCommitSHA and
TestLsRemoteBadRef call LsRemote (and CheckGit) against GitHub and must be
converted to gated integration tests and use a timeout: mark or move these tests
so they're only run for integration (e.g., add an integration build tag or
rename to *_integration_test.go and/or check testing.Short() and call t.Skip),
and wrap their context.Background() usage with context.WithTimeout to a
reasonable duration (e.g., 10s) and defer cancel(); keep references to CheckGit
and LsRemote unchanged so the same helpers are used, and ensure the skip/gate
prevents CI flakiness while the timeout prevents indefinite hangs.
In `@pkg/source/lsremote.go`:
- Around line 24-37: The error messages currently interpolate the raw cloneURL
(variable cloneURL) which can leak credentials; before constructing the
fmt.Errorf messages (the ones that include cloneURL alongside ref and
sanitizeGitOutput), parse cloneURL with net/url (e.g., url.Parse), strip or zero
out the User info, and use the resulting sanitized string (e.g., safeCloneURL)
in the three error returns instead of cloneURL so userinfo is never included in
logs or errors.
---
Outside diff comments:
In `@internal/cli/install.go`:
- Around line 178-200: NewSkillCardFromRef currently derives Metadata.Namespace
by taking everything before the first '/' which yields only the registry host;
change it to derive the repository path by using the last '/' in the ref so
nested repo paths are preserved (e.g. "ghcr.io/org/team" for
"ghcr.io/org/team/skill:1.2.3"). In NewSkillCardFromRef, replace the first-slash
logic with strings.LastIndex(ref, "/") and set namespace = ref[:lastSlash] when
lastSlash >= 0 (leave "unknown" otherwise); keep tagFromRef/version handling and
the call sites intact so only namespace serialization changes.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Enterprise
Run ID: 9d8f6d24-83e2-437d-a6a2-95d0fcd1c827
📒 Files selected for processing (10)
examples/dev-collection.yamlinternal/cli/collection.gointernal/cli/collection_install_test.gointernal/cli/install.gointernal/cli/install_test.gointernal/cli/upgrade.gopkg/collection/collection.gopkg/collection/collection_test.gopkg/source/lsremote.gopkg/source/lsremote_test.go
| switch { | ||
| case s.Image != "" && s.Source != "": | ||
| errs = append(errs, fmt.Sprintf("skills[%d]: image and source are mutually exclusive", i)) | ||
| case s.Image == "" && s.Source == "": | ||
| errs = append(errs, fmt.Sprintf("skills[%d]: image or source is required", i)) | ||
| case s.Image != "" && s.Name == "": | ||
| errs = append(errs, fmt.Sprintf("skills[%d].name is required for image entries", i)) | ||
| } | ||
| if s.Name != "" && seen[s.Name] { | ||
| errs = append(errs, fmt.Sprintf("duplicate skill name %q", s.Name)) | ||
| } | ||
| seen[s.Name] = true | ||
| if s.Name != "" { | ||
| seen[s.Name] = true | ||
| } |
There was a problem hiding this comment.
Validation now permits data that generator paths cannot safely render.
By allowing source-only entries without name (Line 69 onward), you can pass validation but still generate invalid Kube/Podman output later in this file (empty names/image references). Please add explicit guardrails: either enforce image+name for generation workflows or make generator functions return errors on unsupported source entries.
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.
In `@pkg/collection/collection.go` around lines 66 - 79, The validation currently
allows entries with s.Source set but no s.Name which later causes invalid
Kube/Podman generation; update the validation block around
s.Image/s.Source/s.Name (the switch and subsequent checks that append to errs
and update seen) to explicitly reject source-only entries by adding a case for
s.Source != "" && s.Name == "" with an error like "skills[%d].name is required
for source entries", and ensure duplicate-name checks (seen map) still run only
when s.Name != ""; alternatively, if you prefer generator-side enforcement,
modify the generator functions that render Kube/Podman output to return an error
when encountering a skill with s.Source set and s.Name empty so generation fails
fast.
- Derive skip-check identity from source URL subpath when name is omitted, so unnamed source entries hit the ls-remote fast path - Sanitize credentials from URLs in LsRemote error messages - Gate LsRemote tests with testing.Short() and add context timeouts Refs: #35 Assisted-By: Claude (Anthropic AI) <[email protected]> Signed-off-by: Pavel Anni <[email protected]>
…en symlinks When a repository uses symlinks that point outside the sparse checkout scope, Discover() cannot find SKILL.md files. Detect this by retrying with DisableSparse when Discover fails after a sparse checkout. Refs: #35 Assisted-By: Claude (Anthropic AI) <[email protected]> Signed-off-by: Pavel Anni <[email protected]>
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@pkg/source/lsremote.go`:
- Around line 35-43: The code currently grabs the first line's SHA
(firstLine/fields) which returns the tag object ID for annotated tags; instead
iterate over the output lines and if any line's refname field ends with "^{ }"
(the peeled tag ref, typically "refs/tags/...^{}") return that line's SHA
(fields[0]); otherwise fall back to returning the first line's SHA. Update the
parsing in lsremote.go (the block using firstLine and fields) to prefer the
peeled-ref line when present before returning the SHA.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Enterprise
Run ID: 3c8690ee-0cd7-4313-9429-cd05637b9214
📒 Files selected for processing (5)
internal/cli/collection.gopkg/source/clone.gopkg/source/lsremote.gopkg/source/lsremote_test.gopkg/source/source.go
🚧 Files skipped from review as they are similar to previous changes (2)
- pkg/source/lsremote_test.go
- internal/cli/collection.go
| // Output format: "<sha>\t<refname>\n" — may have multiple lines. | ||
| // Take the first line's SHA. | ||
| firstLine := strings.SplitN(output, "\n", 2)[0] | ||
| fields := strings.Fields(firstLine) | ||
| if len(fields) < 1 { | ||
| return "", fmt.Errorf("unexpected ls-remote output for %s %s", safeURL, ref) | ||
| } | ||
|
|
||
| return fields[0], nil |
There was a problem hiding this comment.
🧩 Analysis chain
🏁 Script executed:
cat -n pkg/source/lsremote.goRepository: redhat-et/skillimage
Length of output: 1695
🏁 Script executed:
rg "LsRemote" --type goRepository: redhat-et/skillimage
Length of output: 788
🏁 Script executed:
rg -B 5 -A 10 "remoteSHA, lsErr := source.LsRemote" internal/cli/collection.goRepository: redhat-et/skillimage
Length of output: 458
🏁 Script executed:
cat -n pkg/source/lsremote_test.goRepository: redhat-et/skillimage
Length of output: 1483
🏁 Script executed:
rg -B 3 -A 3 "commitSHAPattern" pkg/source/Repository: redhat-et/skillimage
Length of output: 1032
🏁 Script executed:
rg -B 5 -A 15 "installedSHA" internal/cli/collection.go | head -50Repository: redhat-et/skillimage
Length of output: 789
🏁 Script executed:
rg -B 5 -A 10 "func readInstalledCommit" internal/cli/Repository: redhat-et/skillimage
Length of output: 809
🏁 Script executed:
rg -B 2 -A 8 "readInstalledCommit" internal/cli/collection.go | tail -30Repository: redhat-et/skillimage
Length of output: 829
🏁 Script executed:
rg -A 15 "func readInstalledCommit" internal/cli/collection.goRepository: redhat-et/skillimage
Length of output: 418
🏁 Script executed:
cd /tmp && git clone --depth 1 https://github.com/octocat/Hello-World.git test-repo 2>/dev/null && cd test-repo && echo "=== Branches ===" && git ls-remote origin master && echo "=== Tags ===" && git ls-remote origin v0.0.1 2>/dev/null || echo "Tag not found" && echo "=== All refs ===" && git ls-remote origin | head -20Repository: redhat-et/skillimage
Length of output: 1372
🏁 Script executed:
cd /tmp && rm -rf test-repo && git clone --depth 1 https://github.com/git/git.git test-repo 2>&1 | grep -i clone && cd test-repo && echo "=== Querying for a lightweight ref ===" && git ls-remote origin refs/tags/v2.40.0 2>/dev/null || git ls-remote origin refs/tags/v2.25.0 2>/dev/null || (echo "Trying v2.0.0:" && git ls-remote origin refs/tags/v2.0.0)Repository: redhat-et/skillimage
Length of output: 280
🌐 Web query:
git ls-remote annotated tag output peeled ^{} format
💡 Result:
The git ls-remote command outputs references from a remote repository in the format TAB LF. For annotated tags (created with git tag -a), it shows two lines per tag unless --refs is used: one for the tag ref pointing to the annotated tag object, and another for ^{} pointing to the peeled object (typically a commit) that the tag references. The ^{} suffix dereferences the tag recursively to a non-tag object. Example output: d4ca2e3147b409459955613c152220f4db848ee1 refs/tags/v2.40.0 73876f4861cd3d187a4682290ab75c9dccadbc56 refs/tags/v2.40.0^{} Lightweight tags (created with plain git tag) show only one line. Use --refs to show only the tag refs without peeled lines, or --tags to list only tags.
Citations:
- 1: https://code.googlesource.com/git/+/HEAD/Documentation/git-ls-remote.adoc
- 2: https://git-scm.com/docs/git-ls-remote
- 3: https://stackoverflow.com/questions/70436768/what-is-the-mean-of-in-git-ls-remote
- 4: https://stackoverflow.com/questions/15472107/when-listing-git-ls-remote-why-theres-after-the-tag-name
🏁 Script executed:
rg -i "annotated" --type go pkg/ internal/Repository: redhat-et/skillimage
Length of output: 200
🏁 Script executed:
rg "git tag" --type go pkg/ internal/ || echo "No git tag commands in code"Repository: redhat-et/skillimage
Length of output: 92
🏁 Script executed:
rg -i "tag" pkg/source/clone.go | head -20Repository: redhat-et/skillimage
Length of output: 46
🏁 Script executed:
find . -name "*test*" -type f -exec grep -l "tag" {} \; | head -10Repository: redhat-et/skillimage
Length of output: 228
Handle peeled tag output before returning the SHA.
git ls-remote returns two lines for annotated tags: the tag object ID on the first line, and the peeled commit ID on the second line with a ^{} suffix. The current code returns the tag object ID, which breaks the skip logic in collection.go that compares against stored commit SHAs—for annotated tags, tag object ID ≠ commit ID, so the comparison fails and unnecessary clones occur.
Suggested fix
- // Output format: "<sha>\t<refname>\n" — may have multiple lines.
- // Take the first line's SHA.
- firstLine := strings.SplitN(output, "\n", 2)[0]
- fields := strings.Fields(firstLine)
- if len(fields) < 1 {
- return "", fmt.Errorf("unexpected ls-remote output for %s %s", safeURL, ref)
- }
-
- return fields[0], nil
+ var fallbackSHA string
+ for _, line := range strings.Split(output, "\n") {
+ fields := strings.Fields(line)
+ if len(fields) < 2 {
+ continue
+ }
+ if strings.HasSuffix(fields[1], "^{}") {
+ return fields[0], nil
+ }
+ if fallbackSHA == "" {
+ fallbackSHA = fields[0]
+ }
+ }
+ if fallbackSHA == "" {
+ return "", fmt.Errorf("unexpected ls-remote output for %s %s", safeURL, ref)
+ }
+ return fallbackSHA, nil🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.
In `@pkg/source/lsremote.go` around lines 35 - 43, The code currently grabs the
first line's SHA (firstLine/fields) which returns the tag object ID for
annotated tags; instead iterate over the output lines and if any line's refname
field ends with "^{ }" (the peeled tag ref, typically "refs/tags/...^{}") return
that line's SHA (fields[0]); otherwise fall back to returning the first line's
SHA. Update the parsing in lsremote.go (the block using firstLine and fields) to
prefer the peeled-ref line when present before returning the SHA.
Build() tags images as <version>-draft by default, but installFromSource used bare <version> for the unpack ref. Use lifecycle.TagForState to construct the correct tag. Refs: #35 Assisted-By: Claude (Anthropic AI) <[email protected]> Signed-off-by: Pavel Anni <[email protected]>
Summary
source:field to collection YAMLSkillReffor Git repo URLs, mutually exclusive withimage:skillctl collection installsubcommand that installs skills from a collection YAML (-flocal file or positional Git URL) into agent skill directories (--targetor-o)git ls-remote--forceoverrides bothTest plan
pkg/collection/unit tests: source field parsing, mutual exclusivity, optional name validationpkg/source/unit tests:LsRemotereturns SHA, errors on bad refinternal/cli/tests: input validation, target resolution, invalid YAML, validation errorsmake test)make lint)skillctl collection install --helpshows correct flagsCloses #35
🤖 Generated with Claude Code
Summary by CodeRabbit
New Features
collection installcommand to install skills from collection manifests.Improvements
Tests