Repository navigation
feat: add rm/delete command to remove local skill images - #29
Conversation
Add three test cases for the Remove method (TDD red phase): - TestRemove: remove an existing image - TestRemoveNotFound: error on missing ref - TestRemoveMultipleImages: remove one, keep another Tests fail to compile as expected - client.Remove does not exist yet. Assisted-By: Claude (Anthropic AI) <[email protected]> Signed-off-by: Pavel Anni <[email protected]>
Assisted-By: Claude (Anthropic AI) <[email protected]> Signed-off-by: Pavel Anni <[email protected]>
Closes #22 Assisted-By: Claude (Anthropic AI) <[email protected]> Signed-off-by: Pavel Anni <[email protected]>
Signed-off-by: Pavel Anni <[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 (3)
📝 WalkthroughWalkthroughThis pull request introduces a new Changes
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 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 48 minutes and 47 seconds.Comment |
Signed-off-by: Pavel Anni <[email protected]>
There was a problem hiding this comment.
Actionable comments posted: 4
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@dev/plans/2026-04-30-rm-delete-command.md`:
- Line 21: The heading "### Task 1: Client.Remove method — test" jumps levels;
change it to a second-level heading by replacing "###" with "##" so heading
levels increment properly (update the markdown line containing "Client.Remove
method — test").
In `@dev/specs/2026-04-30-rm-delete-command-design.md`:
- Around line 26-28: The fenced code block containing the command usage
`skillctl rm <ref> [<ref>...] [flags]` is missing a language identifier; update
that fence in the markdown to include a language tag (for example add ```text or
```bash) so markdownlint MD040 is satisfied and the block renders
consistently—locate the fenced block in the spec file and change the opening
fence from ``` to a tagged fence like ```text or ```bash.
In `@internal/cli/rm.go`:
- Around line 41-42: Replace the use of process globals by switching the local
ctx := context.Background() to use the Cobra command context (cmd.Context()) and
replace direct reads from os.Stdin with cmd.InOrStdin() so
cancellations/timeouts and test-injected stdin are respected; update any
functions in this file that reference ctx or os.Stdin (e.g., the ctx variable
and the stdin usage around the confirmation/read logic in the rm command) to
accept/use cmd.Context() and cmd.InOrStdin().
In `@pkg/oci/remove.go`:
- Around line 16-18: The branch that checks errors.Is(err, errdef.ErrNotFound)
currently returns a plain error string which loses the original sentinel; update
that return to wrap the not-found sentinel using %w so callers can still detect
errdef.ErrNotFound (i.e., change the fmt.Errorf call in pkg/oci/remove.go to
include %w and wrap errdef.ErrNotFound, mirroring the other %w wraps in this
function).
🪄 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: 38be9260-6716-44b8-9428-0371e6f9b420
📒 Files selected for processing (6)
dev/plans/2026-04-30-rm-delete-command.mddev/specs/2026-04-30-rm-delete-command-design.mdinternal/cli/rm.gointernal/cli/root.gopkg/oci/remove.gopkg/oci/remove_test.go
| if errors.Is(err, errdef.ErrNotFound) { | ||
| return fmt.Errorf("image not found: %s", ref) | ||
| } |
There was a problem hiding this comment.
🧩 Analysis chain
🌐 Web query:
In oras-go v2, is wrapping resolve errors with %wthe recommended way to preserveerrdef.ErrNotFoundclassification for callers usingerrors.Is?
💡 Result:
Yes—if ORAS Go v2 wraps underlying resolve errors while preserving the original error in the wrapping chain (by using fmt.Errorf("...: %w", err) or errors.Join), callers can use errors.Is(err, errdef.ErrNotFound) to classify not-found at higher layers. However, this depends on the exact wrapping implementation in the relevant ORAS v2 function(s): ORAS v2 does define a sentinel ErrNotFound in its errdef package, and it relies on Go error-wrapping semantics for classification. The library also uses structured error types with Unwrap (e.g., CopyError) so the underlying ErrNotFound can still be found via errors.Is/errors.As. Grounding in ORAS Go v2: - ORAS Go v2 defines ErrNotFound as a sentinel error value in its errdef package. - CopyError in the v3 codebase (pattern indicative of how ORAS preserves inner errors) implements Unwrap to return the underlying Err; this is what makes errors.Is work when the underlying error is errdef.ErrNotFound. Practical recommendation: - When ORAS Go v2 needs to add context while preserving classification, wrapping with %w (or otherwise preserving the original error as an unwrap target) is the correct approach. - Callers should use errors.Is(err, errdef.ErrNotFound) rather than direct equality, because the library may wrap errors to add context. Note: I did not find an ORAS v2-specific documentation statement explicitly saying “%w is recommended” for resolve errors. The conclusion is based on ORAS Go v2’s use of sentinel errdef.ErrNotFound and ORAS’s observable wrapping/unwrapping patterns that are compatible with Go’s errors.Is mechanism.
Citations:
- 1: https://pkg.go.dev/oras.land/oras-go/v2/errdef
- 2: https://github.com/oras-project/oras-go/blob/main/copyerror.go
- 3: https://github.com/oras-project/oras-go/blob/42c1a3adcfba8ae373e3fe53308867f0c7357dc2/example_copyerror_test.go
- 4: https://github.com/oras-project/oras-go/blob/main/copy.go
🏁 Script executed:
# First, let's find and examine the remove.go file
fd -t f "remove.go" --exec wc -l {} \;Repository: redhat-et/skillimage
Length of output: 87
🏁 Script executed:
# Read the file with context around lines 16-18
cat -n pkg/oci/remove.go | head -30Repository: redhat-et/skillimage
Length of output: 900
Preserve the not-found sentinel when returning the custom error.
Line 17 returns a plain error string without wrapping, preventing callers from using errors.Is(err, errdef.ErrNotFound) for typed error handling. The function already wraps errors with %w on lines 19 and 23; line 17 should follow the same pattern.
Proposed fix
if _, err := c.store.Resolve(ctx, ref); err != nil {
if errors.Is(err, errdef.ErrNotFound) {
- return fmt.Errorf("image not found: %s", ref)
+ return fmt.Errorf("image not found: %s: %w", ref, err)
}
return fmt.Errorf("resolving %s: %w", ref, err)
}🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.
In `@pkg/oci/remove.go` around lines 16 - 18, The branch that checks
errors.Is(err, errdef.ErrNotFound) currently returns a plain error string which
loses the original sentinel; update that return to wrap the not-found sentinel
using %w so callers can still detect errdef.ErrNotFound (i.e., change the
fmt.Errorf call in pkg/oci/remove.go to include %w and wrap errdef.ErrNotFound,
mirroring the other %w wraps in this function).
- Fix heading levels in plan doc (h3 → h2) - Add language tag to fenced code block in spec - Use cmd.Context() instead of context.Background() - Use cmd.InOrStdin() instead of os.Stdin Signed-off-by: Pavel Anni <[email protected]>
Summary
skillctl rm(aliasdelete) to remove skill images from the local OCI store by name:tag reference--force)Client.Remove()method topkg/ocibacked by oras-goUntag()Closes #22
Design decisions
skillctl pruneTest plan
TestRemove— build image, remove by ref, verify absent from ListLocalTestRemoveNotFound— error on non-existent ref contains "not found"TestRemoveMultipleImages— remove one of two images, verify other remainsgo test ./...— all tests passmake lint— 0 issuesSummary by CodeRabbit
rmcommand to remove locally stored skill images by name:tag reference--forceflag to skip confirmation prompts--force)