@resourcexjs/core 2.8.0 → 2.10.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/README.md CHANGED
@@ -14,15 +14,16 @@ bun add @resourcexjs/core
14
14
 
15
15
  ## Core Concepts
16
16
 
17
- ResourceX uses a layered architecture with five core primitives:
17
+ ResourceX uses a layered architecture with six core primitives:
18
18
 
19
19
  | Primitive | Description |
20
20
  | --------- | -------------------------------------------------------- |
21
21
  | **RXD** | Resource Definition - content of `resource.json` |
22
- | **RXL** | Resource Locator - unique identifier for a resource |
22
+ | **RXI** | Resource Identifier - structured identifier `{ registry?, path?, name, tag }` |
23
+ | **RXL** | Resource Locator - unified locator string (RXI string, directory path, or URL) |
23
24
  | **RXM** | Resource Manifest - metadata stored within the resource |
24
25
  | **RXA** | Resource Archive - tar.gz container for storage/transfer |
25
- | **RXR** | Resource - complete resource (RXL + RXM + RXA) |
26
+ | **RXR** | Resource - complete resource (RXI + RXM + RXA) |
26
27
 
27
28
  ### Locator Format
28
29
 
@@ -38,14 +39,14 @@ registry.example.com/org/hello -> registry=registry.example.com, path=org, name
38
39
 
39
40
  ## API
40
41
 
41
- ### `parse(locator: string): RXL`
42
+ ### `parse(locator: string): RXI`
42
43
 
43
- Parse a locator string into an RXL object.
44
+ Parse a locator string into an RXI object.
44
45
 
45
46
  ```typescript
46
47
  import { parse } from "@resourcexjs/core";
47
48
 
48
- const rxl = parse("registry.example.com/prompts/hello:1.0.0");
49
+ const rxi = parse("registry.example.com/prompts/hello:1.0.0");
49
50
  // {
50
51
  // registry: "registry.example.com",
51
52
  // path: "prompts",
@@ -57,9 +58,9 @@ const simple = parse("hello");
57
58
  // { registry: undefined, path: undefined, name: "hello", tag: "latest" }
58
59
  ```
59
60
 
60
- ### `format(rxl: RXL): string`
61
+ ### `format(rxi: RXI): string`
61
62
 
62
- Format an RXL object back to a locator string.
63
+ Format an RXI object back to a locator string.
63
64
 
64
65
  ```typescript
65
66
  import { format } from "@resourcexjs/core";
@@ -121,14 +122,14 @@ const rxm = manifest(rxd);
121
122
  // { name: "my-prompt", type: "text", tag: "1.0.0" }
122
123
  ```
123
124
 
124
- ### `locate(rxm: RXM): RXL`
125
+ ### `locate(rxm: RXM): RXI`
125
126
 
126
- Create a locator from a manifest.
127
+ Create an identifier from a manifest.
127
128
 
128
129
  ```typescript
129
130
  import { locate } from "@resourcexjs/core";
130
131
 
131
- const rxl = locate({
132
+ const rxi = locate({
132
133
  registry: "example.com",
133
134
  path: "prompts",
134
135
  name: "hello",
@@ -212,7 +213,7 @@ const rxm = manifest(rxd);
212
213
  const rxa = await archive({ content: Buffer.from("Hello!") });
213
214
  const rxr = resource(rxm, rxa);
214
215
  // {
215
- // locator: { name: "hello", tag: "1.0.0" },
216
+ // identifier: { name: "hello", tag: "1.0.0" },
216
217
  // manifest: { name: "hello", type: "text", tag: "1.0.0" },
217
218
  // archive: RXA
218
219
  // }
@@ -240,12 +241,12 @@ interface RXD {
240
241
  }
241
242
  ```
242
243
 
243
- ### RXL - Resource Locator
244
+ ### RXI - Resource Identifier
244
245
 
245
- Unique identifier for a resource.
246
+ Structured identifier for a resource.
246
247
 
247
248
  ```typescript
248
- interface RXL {
249
+ interface RXI {
249
250
  readonly registry?: string; // e.g., "localhost:3098", "registry.example.com"
250
251
  readonly path?: string; // e.g., "org", "prompts"
251
252
  readonly name: string; // Resource name
@@ -253,6 +254,14 @@ interface RXL {
253
254
  }
254
255
  ```
255
256
 
257
+ ### RXL - Resource Locator
258
+
259
+ Unified locator string. Can be an RXI string, directory path, or URL.
260
+
261
+ ```typescript
262
+ type RXL = string;
263
+ ```
264
+
256
265
  ### RXM - Resource Manifest
257
266
 
258
267
  Resource metadata stored within the resource.
@@ -281,11 +290,11 @@ interface RXA {
281
290
 
282
291
  ### RXR - Resource
283
292
 
284
- Complete resource object combining locator, manifest, and archive.
293
+ Complete resource object combining identifier, manifest, and archive.
285
294
 
286
295
  ```typescript
287
296
  interface RXR {
288
- readonly locator: RXL;
297
+ readonly identifier: RXI;
289
298
  readonly manifest: RXM;
290
299
  readonly archive: RXA;
291
300
  }
@@ -324,7 +333,7 @@ try {
324
333
 
325
334
  ```
326
335
  ResourceXError (base)
327
- ├── LocatorError - RXL parsing errors
336
+ ├── LocatorError - RXI parsing errors
328
337
  ├── ManifestError - RXM validation errors
329
338
  ├── ContentError - RXA operations errors
330
339
  └── DefinitionError - RXD validation errors
@@ -357,7 +366,7 @@ const rxa = await archive({
357
366
  const rxr: RXR = resource(rxm, rxa);
358
367
 
359
368
  // 5. Access locator string
360
- const locatorStr = format(rxr.locator);
369
+ const locatorStr = format(rxr.identifier);
361
370
  console.log(locatorStr); // "assistant-prompt:1.0.0"
362
371
 
363
372
  // 6. Extract files when needed
@@ -381,13 +390,13 @@ const cas = new CASRegistry(new MemoryRXAStore(), new MemoryRXMStore());
381
390
  await cas.put(rxr);
382
391
 
383
392
  // Get a resource
384
- const rxr = await cas.get(rxl);
393
+ const rxr = await cas.get(rxi);
385
394
 
386
395
  // Check existence
387
- const exists = await cas.has(rxl);
396
+ const exists = await cas.has(rxi);
388
397
 
389
398
  // Remove a resource
390
- await cas.remove(rxl);
399
+ await cas.remove(rxi);
391
400
 
392
401
  // List resources
393
402
  const results = await cas.list({ query: "prompt", limit: 10 });
package/dist/index.d.ts CHANGED
@@ -51,9 +51,9 @@ declare function define(input: unknown): RXD;
51
51
  */
52
52
  declare function extract(rxa: RXA): Promise<Record<string, Buffer>>;
53
53
  /**
54
- * RXL - ResourceX Locator
54
+ * RXI - ResourceX Identifier
55
55
  *
56
- * Unique identifier for a resource (pure data object).
56
+ * Structured identifier for a resource (pure data object).
57
57
  * Docker-style format with optional tag.
58
58
  *
59
59
  * Format: [registry/][path/]name[:tag]
@@ -65,7 +65,7 @@ declare function extract(rxa: RXA): Promise<Record<string, Buffer>>;
65
65
  * - localhost:3098/hello:1.0.0 → registry=localhost:3098, name=hello, tag=1.0.0
66
66
  * - registry.example.com/org/hello:latest → registry=registry.example.com, path=org, name=hello, tag=latest
67
67
  */
68
- interface RXL {
68
+ interface RXI {
69
69
  /** Registry host:port (e.g., "localhost:3098", "registry.example.com") */
70
70
  readonly registry?: string;
71
71
  /** Path within registry (e.g., "org", "prompts") */
@@ -76,7 +76,7 @@ interface RXL {
76
76
  readonly tag: string;
77
77
  }
78
78
  /**
79
- * Format RXL to locator string.
79
+ * Format RXI to locator string.
80
80
  *
81
81
  * Docker-style format: [registry/][path/]name[:tag]
82
82
  *
@@ -85,40 +85,81 @@ interface RXL {
85
85
  * - { name: "hello", tag: "1.0.0" } → "hello:1.0.0"
86
86
  * - { registry: "localhost:3098", name: "hello", tag: "1.0.0" } → "localhost:3098/hello:1.0.0"
87
87
  *
88
- * @param rxl - Resource locator
88
+ * @param rxi - Resource identifier
89
89
  * @returns Locator string
90
90
  */
91
- declare function format(rxl: RXL): string;
91
+ declare function format(rxi: RXI): string;
92
92
  /**
93
93
  * RXM - ResourceX Manifest
94
94
  *
95
- * Resource metadata stored within the resource (pure data object).
95
+ * Resource context representation organized by RX primitives.
96
+ * Structure: definition (RXD) + archive (RXA) + source (RXS)
96
97
  */
97
- interface RXM {
98
- readonly registry?: string;
99
- readonly path?: string;
98
+ /**
99
+ * RXM Definition — what the resource IS.
100
+ * Sourced from RXD (resource.json).
101
+ */
102
+ interface RXMDefinition {
100
103
  readonly name: string;
101
104
  readonly type: string;
102
105
  readonly tag: string;
103
- readonly files?: string[];
106
+ readonly registry?: string;
107
+ readonly path?: string;
108
+ readonly description?: string;
109
+ readonly author?: string;
110
+ readonly license?: string;
111
+ readonly keywords?: string[];
112
+ readonly repository?: string;
113
+ }
114
+ /**
115
+ * RXM Archive — packaging metadata.
116
+ * Placeholder for future fields (digest, size, md5, etc.)
117
+ */
118
+ type RXMArchive = {};
119
+ /**
120
+ * File entry with metadata.
121
+ */
122
+ interface FileEntry {
123
+ readonly size: number;
104
124
  }
105
125
  /**
106
- * Create RXL from RXM.
126
+ * Recursive file tree structure.
127
+ * Keys ending with '/' are directories containing nested FileTree.
128
+ * Other keys are files with FileEntry metadata.
129
+ */
130
+ type FileTree = {
131
+ readonly [key: string]: FileEntry | FileTree
132
+ };
133
+ /**
134
+ * RXM Source — what's IN the resource.
135
+ * File structure and content preview.
136
+ */
137
+ interface RXMSource {
138
+ readonly files?: FileTree;
139
+ readonly preview?: string;
140
+ }
141
+ interface RXM {
142
+ readonly definition: RXMDefinition;
143
+ readonly archive: RXMArchive;
144
+ readonly source: RXMSource;
145
+ }
146
+ /**
147
+ * Create RXI from RXM.
107
148
  *
108
149
  * @param rxm - Resource manifest
109
- * @returns RXL locator object (pure data)
150
+ * @returns RXI identifier object (pure data)
110
151
  */
111
- declare function locate(rxm: RXM): RXL;
152
+ declare function locate(rxm: RXM): RXI;
112
153
  /**
113
154
  * Create RXM from RXD.
114
- * Extracts only the core metadata fields (pure data object).
155
+ * Maps RXD fields into the structured RXM format.
115
156
  *
116
157
  * @param rxd - Resource definition
117
158
  * @returns RXM manifest object
118
159
  */
119
160
  declare function manifest(rxd: RXD): RXM;
120
161
  /**
121
- * Parse locator string to RXL.
162
+ * Parse locator string to RXI.
122
163
  *
123
164
  * Docker-style format: [registry/][path/]name[:tag]
124
165
  *
@@ -129,17 +170,17 @@ declare function manifest(rxd: RXD): RXM;
129
170
  * - localhost:3098/hello:1.0.0 → registry=localhost:3098, name=hello, tag=1.0.0
130
171
  *
131
172
  * @param locator - Locator string
132
- * @returns RXL object
173
+ * @returns RXI object
133
174
  * @throws LocatorError if parsing fails
134
175
  */
135
- declare function parse(locator: string): RXL;
176
+ declare function parse(locator: string): RXI;
136
177
  /**
137
178
  * RXR - ResourceX Resource
138
179
  *
139
- * Complete resource object combining locator, manifest, and archive.
180
+ * Complete resource object combining identifier, manifest, and archive.
140
181
  */
141
182
  interface RXR {
142
- readonly locator: RXL;
183
+ readonly identifier: RXI;
143
184
  readonly manifest: RXM;
144
185
  readonly archive: RXA;
145
186
  }
@@ -152,6 +193,19 @@ interface RXR {
152
193
  */
153
194
  declare function resource(rxm: RXM, rxa: RXA): RXR;
154
195
  /**
196
+ * RXL - ResourceX Locator
197
+ *
198
+ * Unified locator type for any resource reference.
199
+ * An RXL can be:
200
+ * - An RXI identifier string (e.g., "hello:1.0.0", "deepractice/skill-creator:0.1.0")
201
+ * - A local directory path (e.g., "/home/user/skills/my-skill")
202
+ * - A URL (e.g., "https://github.com/org/repo/tree/main/skills/my-skill")
203
+ *
204
+ * RXL is the input type for `ingest()` — the unified entry point that
205
+ * accepts any form of resource reference and resolves it.
206
+ */
207
+ type RXL = string;
208
+ /**
155
209
  * RXS - ResourceX Source
156
210
  *
157
211
  * Intermediate representation of raw files from any source.
@@ -590,6 +644,11 @@ interface StoredRXM {
590
644
  readonly name: string;
591
645
  readonly type: string;
592
646
  readonly tag: string;
647
+ readonly description?: string;
648
+ readonly author?: string;
649
+ readonly license?: string;
650
+ readonly keywords?: string[];
651
+ readonly repository?: string;
593
652
  readonly files: Record<string, string>;
594
653
  readonly createdAt?: Date;
595
654
  readonly updatedAt?: Date;
@@ -773,10 +832,10 @@ interface SearchOptions {
773
832
  */
774
833
  interface Registry {
775
834
  /**
776
- * Get resource by locator.
835
+ * Get resource by identifier.
777
836
  * @throws RegistryError if not found
778
837
  */
779
- get(rxl: RXL): Promise<RXR>;
838
+ get(rxi: RXI): Promise<RXR>;
780
839
  /**
781
840
  * Store resource.
782
841
  */
@@ -784,26 +843,26 @@ interface Registry {
784
843
  /**
785
844
  * Check if resource exists.
786
845
  */
787
- has(rxl: RXL): Promise<boolean>;
846
+ has(rxi: RXI): Promise<boolean>;
788
847
  /**
789
848
  * Delete resource.
790
849
  */
791
- remove(rxl: RXL): Promise<void>;
850
+ remove(rxi: RXI): Promise<void>;
792
851
  /**
793
852
  * List resources matching options.
794
853
  */
795
- list(options?: SearchOptions): Promise<RXL[]>;
854
+ list(options?: SearchOptions): Promise<RXI[]>;
796
855
  }
797
856
  declare class CASRegistry implements Registry {
798
857
  private readonly rxaStore;
799
858
  private readonly rxmStore;
800
859
  constructor(rxaStore: RXAStore, rxmStore: RXMStore);
801
860
  private resolveTag;
802
- get(rxl: RXL): Promise<RXR>;
861
+ get(rxi: RXI): Promise<RXR>;
803
862
  put(rxr: RXR): Promise<void>;
804
- has(rxl: RXL): Promise<boolean>;
805
- remove(rxl: RXL): Promise<void>;
806
- list(options?: SearchOptions): Promise<RXL[]>;
863
+ has(rxi: RXI): Promise<boolean>;
864
+ remove(rxi: RXI): Promise<void>;
865
+ list(options?: SearchOptions): Promise<RXI[]>;
807
866
  /**
808
867
  * Clear cached resources (resources with registry).
809
868
  * @param registry - If provided, only clear resources from this registry
@@ -848,37 +907,37 @@ declare class LinkedRegistry implements Registry {
848
907
  * Check if a path is a symlink.
849
908
  */
850
909
  private isSymlink;
851
- get(rxl: RXL): Promise<RXR>;
910
+ get(rxi: RXI): Promise<RXR>;
852
911
  /**
853
912
  * Put is not typically used for LinkedRegistry.
854
913
  * Use link() instead to create symlinks.
855
914
  */
856
915
  put(_rxr: RXR): Promise<void>;
857
- has(rxl: RXL): Promise<boolean>;
858
- remove(rxl: RXL): Promise<void>;
859
- list(options?: SearchOptions): Promise<RXL[]>;
916
+ has(rxi: RXI): Promise<boolean>;
917
+ remove(rxi: RXI): Promise<void>;
918
+ list(options?: SearchOptions): Promise<RXI[]>;
860
919
  /**
861
920
  * Link a development directory.
862
921
  * Creates a symlink so changes are reflected immediately.
863
922
  *
864
923
  * @param devPath - Path to development directory (must contain resource.json)
865
- * @returns The RXL of the linked resource
924
+ * @returns The RXI of the linked resource
866
925
  */
867
- link(devPath: string): Promise<RXL>;
926
+ link(devPath: string): Promise<RXI>;
868
927
  /**
869
928
  * Unlink a development directory.
870
929
  * Alias for remove().
871
930
  */
872
- unlink(rxl: RXL): Promise<void>;
931
+ unlink(rxi: RXI): Promise<void>;
873
932
  /**
874
933
  * Recursively scan for symlinks.
875
934
  */
876
935
  private scanSymlinks;
877
936
  /**
878
- * Parse relative path to RXL.
937
+ * Parse relative path to RXI.
879
938
  * Path format: {registry}/{path}/{name}/{tag}
880
939
  */
881
- private parsePathToRXL;
940
+ private parsePathToRXI;
882
941
  }
883
942
  /**
884
943
  * Base class for Registry middleware.
@@ -888,11 +947,11 @@ declare class LinkedRegistry implements Registry {
888
947
  declare abstract class RegistryMiddleware implements Registry {
889
948
  protected readonly inner: Registry;
890
949
  constructor(inner: Registry);
891
- get(rxl: RXL): Promise<RXR>;
950
+ get(rxi: RXI): Promise<RXR>;
892
951
  put(rxr: RXR): Promise<void>;
893
- has(rxl: RXL): Promise<boolean>;
894
- remove(rxl: RXL): Promise<void>;
895
- list(options?: SearchOptions): Promise<RXL[]>;
952
+ has(rxi: RXI): Promise<boolean>;
953
+ remove(rxi: RXI): Promise<void>;
954
+ list(options?: SearchOptions): Promise<RXI[]>;
896
955
  }
897
956
  /**
898
957
  * Registry validation middleware.
@@ -908,7 +967,7 @@ declare class RegistryValidation extends RegistryMiddleware {
908
967
  /**
909
968
  * Get resource and validate registry.
910
969
  */
911
- get(rxl: RXL): Promise<RXR>;
970
+ get(rxi: RXI): Promise<RXR>;
912
971
  }
913
972
  /**
914
973
  * Factory function to create registry validation middleware.
@@ -1196,4 +1255,4 @@ declare class TypeHandlerChain {
1196
1255
  */
1197
1256
  clear(): void;
1198
1257
  }
1199
- export { wrap, withDomainValidation, textType, resource, resolveSource, parse, manifest, locate, loadResource, jsonType, isValidDigest, generateDefinition, format, extract, discoverRegistry, define, computeDigest, bundleResourceType, builtinTypes, binaryType, archive, WellKnownResponse, TypeHandlerChain, TypeDetectorChain, TypeDetector, TypeDetectionResult, StoredRXM, SourceLoaderChain, SourceLoader, SkillDetector, SearchOptions, ResourceXProvider, ResourceXError, ResourceTypeError, ResourceType, ResourceResolver, ResourceLoader, ResourceJsonDetector, ResolvedResource, ResolveSourceConfig, ResolveContext, RegistryMiddleware, RegistryError, Registry, RXS, RXR, RXMStore, RXMSearchOptions, RXM, RXL, RXD, RXAStore, RXA, ProviderStores, ProviderConfig, MemoryRXMStore, MemoryRXAStore, ManifestError, LocatorError, LoadResourceConfig, LinkedRegistry, JSONSchemaProperty, JSONSchema, IsolatorType, GitHubSourceLoader, FolderSourceLoader, FolderLoader, DomainValidation, DiscoveryResult, DefinitionError, ContentError, CASRegistry, BundledType };
1258
+ export { wrap, withDomainValidation, textType, resource, resolveSource, parse, manifest, locate, loadResource, jsonType, isValidDigest, generateDefinition, format, extract, discoverRegistry, define, computeDigest, bundleResourceType, builtinTypes, binaryType, archive, WellKnownResponse, TypeHandlerChain, TypeDetectorChain, TypeDetector, TypeDetectionResult, StoredRXM, SourceLoaderChain, SourceLoader, SkillDetector, SearchOptions, ResourceXProvider, ResourceXError, ResourceTypeError, ResourceType, ResourceResolver, ResourceLoader, ResourceJsonDetector, ResolvedResource, ResolveSourceConfig, ResolveContext, RegistryMiddleware, RegistryError, Registry, RXS, RXR, RXMStore, RXMSource, RXMSearchOptions, RXMDefinition, RXMArchive, RXM, RXL, RXI, RXD, RXAStore, RXA, ProviderStores, ProviderConfig, MemoryRXMStore, MemoryRXAStore, ManifestError, LocatorError, LoadResourceConfig, LinkedRegistry, JSONSchemaProperty, JSONSchema, IsolatorType, GitHubSourceLoader, FolderSourceLoader, FolderLoader, FileTree, FileEntry, DomainValidation, DiscoveryResult, DefinitionError, ContentError, CASRegistry, BundledType };