@skillctl/registry 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/dist/fetch/concurrency.d.ts +2 -0
- package/dist/fetch/concurrency.d.ts.map +1 -0
- package/dist/fetch/concurrency.js +32 -0
- package/dist/fetch/concurrency.js.map +1 -0
- package/dist/fetch/https.d.ts +2 -0
- package/dist/fetch/https.d.ts.map +1 -0
- package/dist/fetch/https.js +24 -0
- package/dist/fetch/https.js.map +1 -0
- package/dist/fetch/tarball.d.ts +4 -0
- package/dist/fetch/tarball.d.ts.map +1 -0
- package/dist/fetch/tarball.js +28 -0
- package/dist/fetch/tarball.js.map +1 -0
- package/dist/frontmatter.d.ts +5 -0
- package/dist/frontmatter.d.ts.map +1 -0
- package/dist/frontmatter.js +31 -0
- package/dist/frontmatter.js.map +1 -0
- package/dist/index.d.ts +8 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +8 -0
- package/dist/index.js.map +1 -0
- package/dist/locate-skill.d.ts +7 -0
- package/dist/locate-skill.d.ts.map +1 -0
- package/dist/locate-skill.js +112 -0
- package/dist/locate-skill.js.map +1 -0
- package/dist/manager.d.ts +23 -0
- package/dist/manager.d.ts.map +1 -0
- package/dist/manager.js +139 -0
- package/dist/manager.js.map +1 -0
- package/dist/names.d.ts +2 -0
- package/dist/names.d.ts.map +1 -0
- package/dist/names.js +2 -0
- package/dist/names.js.map +1 -0
- package/dist/registry.d.ts +137 -0
- package/dist/registry.d.ts.map +1 -0
- package/dist/registry.js +758 -0
- package/dist/registry.js.map +1 -0
- package/dist/sources/github.d.ts +12 -0
- package/dist/sources/github.d.ts.map +1 -0
- package/dist/sources/github.js +102 -0
- package/dist/sources/github.js.map +1 -0
- package/dist/sources/local.d.ts +12 -0
- package/dist/sources/local.d.ts.map +1 -0
- package/dist/sources/local.js +39 -0
- package/dist/sources/local.js.map +1 -0
- package/dist/sources/npm.d.ts +12 -0
- package/dist/sources/npm.d.ts.map +1 -0
- package/dist/sources/npm.js +89 -0
- package/dist/sources/npm.js.map +1 -0
- package/dist/sources/skills-sh.d.ts +12 -0
- package/dist/sources/skills-sh.d.ts.map +1 -0
- package/dist/sources/skills-sh.js +27 -0
- package/dist/sources/skills-sh.js.map +1 -0
- package/dist/test/registry-resolution.test.d.ts +3 -0
- package/dist/test/registry-resolution.test.d.ts.map +1 -0
- package/dist/test/registry-resolution.test.js +101 -0
- package/dist/test/registry-resolution.test.js.map +1 -0
- package/package.json +50 -0
|
@@ -0,0 +1,137 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Registry Manager + Sources for PR4.
|
|
3
|
+
*
|
|
4
|
+
* Supports: github, local (file:), skills.sh (shorthand alias), basic npm.
|
|
5
|
+
* Full resolution, materialize to canonical store, integrity (sha256 tree).
|
|
6
|
+
* Integrates with manifest/lock from PR3 (load/save, makeLockEntry).
|
|
7
|
+
*
|
|
8
|
+
* npm resolution algorithm (per design Issue 4 / appendix):
|
|
9
|
+
* 1. Parse spec → pkg, versionRange (supports npm:pkg, npm:pkg@ver, npm:@scope/pkg@^range).
|
|
10
|
+
* 2. Resolve best version: query registry.npmjs.org for versions, use semver to pick maxSatisfying (or 'latest' if no range).
|
|
11
|
+
* 3. Fetch package metadata for the version; get dist.tarball and dist.shasum (or integrity).
|
|
12
|
+
* 4. Download tarball (https), verify npm tarball shasum (sha1 for shasum field; note modern npm uses sha512 in integrity, we support both for basic).
|
|
13
|
+
* 5. Extract tarball to temp dir (using 'tar' pkg).
|
|
14
|
+
* 6. Locate skill dir inside extracted:
|
|
15
|
+
* - package.json "agentSkills" field? (string | string[] paths) or "skills" field.
|
|
16
|
+
* - or conventional ./skills/ subdir (if contains SKILL.md)
|
|
17
|
+
* - or root if SKILL.md present at top
|
|
18
|
+
* - fallback: glob ** /SKILL.md limited depth (1-2), pick first containing one.
|
|
19
|
+
* 7. From located skill dir: parse SKILL.md frontmatter for 'name' (canonicalize to lower-hyphen), validate basic.
|
|
20
|
+
* 8. Materialize: atomic copy of the skill dir contents to canonical/<name>/ (or the dir itself), compute tree sha256 integrity via core.
|
|
21
|
+
* 9. Record provenance: {type: 'npm', tarballHash: 'sha1:xxx' or npm integrity, subpath? }
|
|
22
|
+
* Also store resolved tarball info in resolved string.
|
|
23
|
+
* 10. Update lock with makeLockEntry + save; optionally update manifest.
|
|
24
|
+
*
|
|
25
|
+
* GitHub/local/skills.sh similar: resolve to (url/ref/subpath), fetch/extract/copy to temp, locate skill (prefer subpath or find SKILL.md), materialize, sha256 tree.
|
|
26
|
+
* Shorthands in resolve (e.g. owner/repo mapped to github:).
|
|
27
|
+
*
|
|
28
|
+
* Checksum (integrity) always written to lock entry.
|
|
29
|
+
*
|
|
30
|
+
* Uses core: loadConfig (for store), computeDirIntegrity, ensureDir, writeFileAtomic (indirect).
|
|
31
|
+
* No adapters. Basic add only.
|
|
32
|
+
*
|
|
33
|
+
* Sources implement (extend core RegistrySource for MVP):
|
|
34
|
+
*/
|
|
35
|
+
import type { RegistrySource, ResolvedSource, LockfileEntry } from '@skillctl/core';
|
|
36
|
+
export interface ResolvedSourceInternal extends ResolvedSource {
|
|
37
|
+
tarballUrl?: string;
|
|
38
|
+
tarballHash?: string;
|
|
39
|
+
gitUrl?: string;
|
|
40
|
+
ref?: string;
|
|
41
|
+
subpath?: string;
|
|
42
|
+
localPath?: string;
|
|
43
|
+
originalSpec: string;
|
|
44
|
+
}
|
|
45
|
+
export declare function parseSkillFrontmatter(skillDir: string): {
|
|
46
|
+
name?: string;
|
|
47
|
+
description?: string;
|
|
48
|
+
};
|
|
49
|
+
export declare function parseSkillFrontmatterAsync(skillDir: string): Promise<{
|
|
50
|
+
name?: string;
|
|
51
|
+
description?: string;
|
|
52
|
+
}>;
|
|
53
|
+
export declare function canonicalizeName(raw: string): string;
|
|
54
|
+
export declare class LocalSource implements RegistrySource {
|
|
55
|
+
readonly id = "local";
|
|
56
|
+
match(spec: string): boolean;
|
|
57
|
+
resolve(spec: string, options?: {
|
|
58
|
+
ref?: string;
|
|
59
|
+
}): Promise<ResolvedSource>;
|
|
60
|
+
fetch(resolved: ResolvedSource, dest: string): Promise<{
|
|
61
|
+
integrity: string;
|
|
62
|
+
}>;
|
|
63
|
+
}
|
|
64
|
+
export declare class GitHubSource implements RegistrySource {
|
|
65
|
+
readonly id = "github";
|
|
66
|
+
match(spec: string): boolean;
|
|
67
|
+
resolve(spec: string, options?: {
|
|
68
|
+
ref?: string;
|
|
69
|
+
}): Promise<ResolvedSource>;
|
|
70
|
+
fetch(resolved: ResolvedSource, dest: string): Promise<{
|
|
71
|
+
integrity: string;
|
|
72
|
+
}>;
|
|
73
|
+
private locateSkillDir;
|
|
74
|
+
}
|
|
75
|
+
export declare class SkillsShSource implements RegistrySource {
|
|
76
|
+
readonly id = "skills.sh";
|
|
77
|
+
match(spec: string): boolean;
|
|
78
|
+
resolve(spec: string, options?: {
|
|
79
|
+
ref?: string;
|
|
80
|
+
}): Promise<ResolvedSource>;
|
|
81
|
+
fetch(resolved: ResolvedSource, dest: string): Promise<{
|
|
82
|
+
integrity: string;
|
|
83
|
+
}>;
|
|
84
|
+
}
|
|
85
|
+
/**
|
|
86
|
+
* NpmSource - basic npm support.
|
|
87
|
+
* See class comments for full documented algorithm.
|
|
88
|
+
*/
|
|
89
|
+
export declare class NpmSource implements RegistrySource {
|
|
90
|
+
readonly id = "npm";
|
|
91
|
+
match(spec: string): boolean;
|
|
92
|
+
resolve(spec: string, options?: {
|
|
93
|
+
ref?: string;
|
|
94
|
+
}): Promise<ResolvedSource>;
|
|
95
|
+
fetch(resolved: ResolvedSource, dest: string): Promise<{
|
|
96
|
+
integrity: string;
|
|
97
|
+
}>;
|
|
98
|
+
/**
|
|
99
|
+
* Locate skill dir logic per design:
|
|
100
|
+
* 1. package.json "agentSkills" or "skills" field (string or array of paths relative)
|
|
101
|
+
* 2. conventional ./skills/<name> or root ./skills/
|
|
102
|
+
* 3. root if SKILL.md
|
|
103
|
+
* 4. limited glob ** /SKILL.md (depth limited)
|
|
104
|
+
*/
|
|
105
|
+
private locateNpmSkillDir;
|
|
106
|
+
}
|
|
107
|
+
export declare class RegistryManager {
|
|
108
|
+
private sources;
|
|
109
|
+
constructor();
|
|
110
|
+
register(source: RegistrySource): void;
|
|
111
|
+
private registerDefaultSources;
|
|
112
|
+
resolve(spec: string, options?: {
|
|
113
|
+
ref?: string;
|
|
114
|
+
}): Promise<ResolvedSourceInternal>;
|
|
115
|
+
/**
|
|
116
|
+
* Materialize resolved source to canonical store.
|
|
117
|
+
* Returns final canonicalPath + tree integrity.
|
|
118
|
+
* Uses atomic-ish: copy to .tmp then rename.
|
|
119
|
+
*/
|
|
120
|
+
materialize(resolved: ResolvedSourceInternal, options?: {
|
|
121
|
+
name?: string;
|
|
122
|
+
}): Promise<{
|
|
123
|
+
canonicalPath: string;
|
|
124
|
+
integrity: string;
|
|
125
|
+
sourceType: string;
|
|
126
|
+
}>;
|
|
127
|
+
/**
|
|
128
|
+
* Basic `add` : parse spec, resolve, materialize to canonical, update lock (and manifest if present).
|
|
129
|
+
* Returns the created/updated LockfileEntry.
|
|
130
|
+
* Integrates manifest/lock per PR3/4 spec.
|
|
131
|
+
*/
|
|
132
|
+
add(spec: string, opts?: {
|
|
133
|
+
cwd?: string;
|
|
134
|
+
updateManifest?: boolean;
|
|
135
|
+
}): Promise<LockfileEntry>;
|
|
136
|
+
}
|
|
137
|
+
//# sourceMappingURL=registry.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"registry.d.ts","sourceRoot":"","sources":["../src/registry.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAiCG;AAUH,OAAO,KAAK,EAAE,cAAc,EAAE,cAAc,EAAc,aAAa,EAAE,MAAM,gBAAgB,CAAC;AAgBhG,MAAM,WAAW,sBAAuB,SAAQ,cAAc;IAE5D,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,WAAW,CAAC,EA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