Add skill import from URL/git (#43)#73
Merged
Merged
Conversation
Add `skern skill import <url>` command to import skills from GitHub repository directories and gists. Supports --name override, --scope, --force, overlap detection, companion files, and JSON output. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
- Add 30s default HTTP timeout for skill import (was using http.DefaultClient with no timeout — slow/malicious endpoints could hang the CLI indefinitely). - Cap downloaded payloads at 10 MiB via io.LimitReader on the contents API JSON, gist API JSON, and each companion file. - Reject companion filenames containing path separators, "..", or absolute paths in Registry.Import. The contents API normally returns base names, but the gist API echoes user-supplied filenames, so validate defensively at the registry boundary. - Convert ParseImportURL switch to a tagged switch (staticcheck QF1002) and document that refs containing slashes cannot be unambiguously parsed from the tree-URL form. - Drop the misleading "github repo with branch ref" test that asserted the parser's incorrect behavior on slashed refs. - Fix errcheck: wrap unchecked Encode/Write returns in test servers and resp.Body.Close() defers. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
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
skern skill import <url>command that imports skills from GitHub repository directories and GitHub gists into the local registry--name(override manifest name),--scope(user/project),--force(overwrite existing + bypass overlap block) flagsskill createChanges
New files:
internal/skill/importer.go— URL parsing (ParseImportURL), HTTP fetching (FetchSkill),ParseManifestFromBytesinternal/cli/skill_import.go— Cobra command wiringinternal/skill/importer_test.go— 12 tests (URL parsing + mock HTTP fetch)internal/cli/skill_import_test.go— 11 CLI-level testsModified files:
internal/output/types_skill.go— AddedSkillImportResultinternal/registry/registry.go— AddedImport()method; migratedmanifestFiletoskill.ManifestFileinternal/skill/skill.go— ExportedManifestFileconstantinternal/cli/context.go— AddedHTTPClientandGitHubBaseURLfor testabilityinternal/cli/skill.go— RegisterednewSkillImportCmd()Test plan
go test ./...— all 23 new tests passmake build— binary builds successfullyskern skill import --help— shows correct usageCloses #43
🤖 Generated with Claude Code