-
Notifications
You must be signed in to change notification settings - Fork 533
feat(skill-registry): support loading pre-curated skill registry via load command and --load flag #976
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
feat(skill-registry): support loading pre-curated skill registry via load command and --load flag #976
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -161,6 +161,69 @@ func Regenerate(cwd, home string, force bool) (Result, error) { | |||||||||||||||||||||
| return Result{Regenerated: true, SkillCount: len(entries), Reason: reason, Registry: registryPath, Cache: cachePath}, nil | ||||||||||||||||||||||
| } | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
| func LoadRegistry(loadPath, cwd string, force bool) (Result, error) { | ||||||||||||||||||||||
| cwd = filepath.Clean(cwd) | ||||||||||||||||||||||
| targetRegistryPath := filepath.Join(cwd, RegistryRelPath) | ||||||||||||||||||||||
| cachePath := filepath.Join(cwd, CacheRelPath) | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
| if loadPath == "" { | ||||||||||||||||||||||
| loadPath = targetRegistryPath | ||||||||||||||||||||||
| } else if !filepath.IsAbs(loadPath) { | ||||||||||||||||||||||
| loadPath = filepath.Join(cwd, loadPath) | ||||||||||||||||||||||
| } | ||||||||||||||||||||||
| loadPath = filepath.Clean(loadPath) | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
| data, err := os.ReadFile(loadPath) | ||||||||||||||||||||||
| if err != nil { | ||||||||||||||||||||||
| return Result{}, fmt.Errorf("read target skill registry %q: %w", loadPath, err) | ||||||||||||||||||||||
| } | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
| content := string(data) | ||||||||||||||||||||||
| if !strings.Contains(content, "## Skills") || !strings.Contains(content, "| Skill |") { | ||||||||||||||||||||||
| return Result{}, fmt.Errorf("invalid skill registry format in %q: missing required headers or table", loadPath) | ||||||||||||||||||||||
| } | ||||||||||||||||||||||
|
Comment on lines
+181
to
+184
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🗄️ Data Integrity & Integration | 🟠 Major | ⚡ Quick win Require all registry markers before accepting the load. Line 182 only rejects files when all markers are missing. A file with Suggested fix- if !strings.Contains(content, "## Skills") && !strings.Contains(content, "| Skill |") && !strings.Contains(content, "# Skill Registry") {
+ if !strings.Contains(content, "# Skill Registry") ||
+ !strings.Contains(content, "## Skills") ||
+ !strings.Contains(content, "| Skill |") {
return Result{}, fmt.Errorf("invalid skill registry format in %q: missing required headers or table", loadPath)
}📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents |
||||||||||||||||||||||
|
|
||||||||||||||||||||||
| if !force && loadPath == targetRegistryPath && fileExists(targetRegistryPath) && fileExists(cachePath) { | ||||||||||||||||||||||
| cached := readCachedFingerprint(cachePath) | ||||||||||||||||||||||
| if strings.HasPrefix(cached, "loaded:") { | ||||||||||||||||||||||
| return Result{Regenerated: false, Reason: "cache-hit", Registry: targetRegistryPath, Cache: cachePath}, nil | ||||||||||||||||||||||
| } | ||||||||||||||||||||||
| } | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
| if err := os.MkdirAll(filepath.Join(cwd, ".atl"), 0o755); err != nil { | ||||||||||||||||||||||
| return Result{}, fmt.Errorf("create .atl directory: %w", err) | ||||||||||||||||||||||
| } | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
| if loadPath != targetRegistryPath { | ||||||||||||||||||||||
| if _, err := filemerge.WriteFileAtomic(targetRegistryPath, data, 0o644); err != nil { | ||||||||||||||||||||||
| return Result{}, fmt.Errorf("write registry: %w", err) | ||||||||||||||||||||||
| } | ||||||||||||||||||||||
| } | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
| skillCount := 0 | ||||||||||||||||||||||
| for _, line := range strings.Split(content, "\n") { | ||||||||||||||||||||||
| if strings.HasPrefix(line, "| `") { | ||||||||||||||||||||||
| skillCount++ | ||||||||||||||||||||||
| } | ||||||||||||||||||||||
| } | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
| fp := "loaded:" + loadPath | ||||||||||||||||||||||
| cacheBytes, err := json.MarshalIndent(cacheFile{Fingerprint: fp}, "", " ") | ||||||||||||||||||||||
| if err != nil { | ||||||||||||||||||||||
| return Result{}, fmt.Errorf("marshal cache fingerprint: %w", err) | ||||||||||||||||||||||
| } | ||||||||||||||||||||||
| cacheBytes = append(cacheBytes, '\n') | ||||||||||||||||||||||
| if _, err := filemerge.WriteFileAtomic(cachePath, cacheBytes, 0o644); err != nil { | ||||||||||||||||||||||
| return Result{}, fmt.Errorf("write cache fingerprint: %w", err) | ||||||||||||||||||||||
| } | ||||||||||||||||||||||
|
coderabbitai[bot] marked this conversation as resolved.
|
||||||||||||||||||||||
|
|
||||||||||||||||||||||
| reason := "loaded" | ||||||||||||||||||||||
| if force { | ||||||||||||||||||||||
| reason = "forced-load" | ||||||||||||||||||||||
| } | ||||||||||||||||||||||
| return Result{Regenerated: true, SkillCount: skillCount, Reason: reason, Registry: targetRegistryPath, Cache: cachePath}, nil | ||||||||||||||||||||||
| } | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
| func EnsureATLIgnored(cwd string) error { | ||||||||||||||||||||||
| gitignorePath := filepath.Join(cwd, ".gitignore") | ||||||||||||||||||||||
| existingBytes, err := os.ReadFile(gitignorePath) | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
Uh oh!
There was an error while loading. Please reload this page.