@resourcexjs/registry 2.1.0 → 2.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/README.md CHANGED
@@ -66,7 +66,7 @@ const rxr = await loadResource("./my-prompt");
66
66
 
67
67
  // Link to registry
68
68
  const registry = createRegistry();
69
- await registry.link(rxr);
69
+ await registry.add(rxr);
70
70
 
71
71
  // Now available at: ~/.resourcex/localhost/my-prompt.text@1.0.0/
72
72
  ```
@@ -135,7 +135,7 @@ Link a resource to local registry.
135
135
  - `resource: RXR` - Complete resource object
136
136
 
137
137
  ```typescript
138
- await registry.link(rxr);
138
+ await registry.add(rxr);
139
139
  ```
140
140
 
141
141
  #### `resolve(locator: string): Promise<RXR>`
@@ -358,7 +358,7 @@ const rxr = await loadResource("./my-prompts/assistant");
358
358
  const registry = createRegistry();
359
359
 
360
360
  // 3. Link to local registry
361
- await registry.link(rxr);
361
+ await registry.add(rxr);
362
362
 
363
363
  // 4. Resolve later
364
364
  const resolved = await registry.resolve("localhost/assistant.prompt@1.0.0");
@@ -374,9 +374,9 @@ console.log(text);
374
374
  const registry = createRegistry();
375
375
 
376
376
  // Link multiple versions
377
- await registry.link(promptV1); // v1.0.0
378
- await registry.link(promptV2); // v2.0.0
379
- await registry.link(promptV3); // v3.0.0
377
+ await registry.add(promptV1); // v1.0.0
378
+ await registry.add(promptV2); // v2.0.0
379
+ await registry.add(promptV3); // v3.0.0
380
380
 
381
381
  // Resolve specific version
382
382
  const v1 = await registry.resolve("localhost/prompt.text@1.0.0");
@@ -392,7 +392,7 @@ const registry = createRegistry({
392
392
  path: "./project-registry",
393
393
  });
394
394
 
395
- await registry.link(rxr);
395
+ await registry.add(rxr);
396
396
  // Stored at: ./project-registry/localhost/...
397
397
  ```
398
398
 
@@ -406,9 +406,9 @@ const registry = createRegistry({
406
406
  });
407
407
 
408
408
  // Now can handle these custom types
409
- await registry.link(promptResource);
410
- await registry.link(toolResource);
411
- await registry.link(agentResource);
409
+ await registry.add(promptResource);
410
+ await registry.add(toolResource);
411
+ await registry.add(agentResource);
412
412
  ```
413
413
 
414
414
  ## Resolution Strategy
package/dist/index.d.ts CHANGED
@@ -136,6 +136,18 @@ interface Registry {
136
136
  */
137
137
  supportType(type: ResourceType): void;
138
138
  /**
139
+ * Link a development directory to local registry.
140
+ * Creates a symlink so changes are reflected immediately.
141
+ * @param path - Path to resource directory (must contain resource.json)
142
+ */
143
+ link(path: string): Promise<void>;
144
+ /**
145
+ * Add resource to local registry.
146
+ * Copies resource content to local storage.
147
+ * @param source - Resource directory path or RXR object
148
+ */
149
+ add(source: string | RXR): Promise<void>;
150
+ /**
139
151
  * Pull resource from remote registry to local cache.
140
152
  * Discovers remote registry via well-known and caches locally.
141
153
  * @param locator - Resource locator (must include domain)
@@ -144,15 +156,10 @@ interface Registry {
144
156
  pull(locator: string, options?: PullOptions): Promise<void>;
145
157
  /**
146
158
  * Publish resource to remote registry.
147
- * Resource must exist in local first.
148
- * @param resource - Resource to publish
149
- * @param options - Publish target configuration
150
- */
151
- publish(resource: RXR, options: PublishOptions): Promise<void>;
152
- /**
153
- * Link resource to local registry (for development/caching).
159
+ * @param source - Resource directory path or RXR object
160
+ * @param options - Publish target configuration (required)
154
161
  */
155
- link(resource: RXR): Promise<void>;
162
+ publish(source: string | RXR, options: PublishOptions): Promise<void>;
156
163
  /**
157
164
  * Get raw resource by locator string.
158
165
  * Returns the RXR (locator + manifest + content) without resolving.
@@ -231,12 +238,18 @@ declare class LocalRegistry implements Registry {
231
238
  */
232
239
  private findArea;
233
240
  /**
241
+ * Check if a path is a symlink.
242
+ */
243
+ private isSymlink;
244
+ /**
234
245
  * Load resource from a specific path.
246
+ * If path is a symlink, loads from the linked directory using FolderLoader.
235
247
  */
236
248
  private loadFrom;
249
+ link(path: string): Promise<void>;
250
+ add(source: string | RXR2): Promise<void>;
237
251
  pull(_locator: string, _options?: PullOptions): Promise<void>;
238
- publish(_resource: RXR2, _options: PublishOptions): Promise<void>;
239
- link(resource: RXR2): Promise<void>;
252
+ publish(_source: string | RXR2, _options: PublishOptions): Promise<void>;
240
253
  get(locator: string): Promise<RXR2>;
241
254
  resolve<
242
255
  TArgs = void,
@@ -271,9 +284,10 @@ declare class RemoteRegistry implements Registry {
271
284
  private readonly typeHandler;
272
285
  constructor(config: RemoteRegistryConfig);
273
286
  supportType(type: ResourceType3): void;
287
+ link(_path: string): Promise<void>;
288
+ add(_source: string | RXR3): Promise<void>;
274
289
  pull(_locator: string, _options?: PullOptions): Promise<void>;
275
- publish(_resource: RXR3, _options: PublishOptions): Promise<void>;
276
- link(_resource: RXR3): Promise<void>;
290
+ publish(_source: string | RXR3, _options: PublishOptions): Promise<void>;
277
291
  get(locator: string): Promise<RXR3>;
278
292
  resolve<
279
293
  TArgs = void,
@@ -291,10 +305,6 @@ declare class RemoteRegistry implements Registry {
291
305
  declare function discoverRegistry(domain: string): Promise<DiscoveryResult>;
292
306
  import { RXR as RXR4, RXL as RXL4 } from "@resourcexjs/core";
293
307
  import { ResourceType as ResourceType4, ResolvedResource as ResolvedResource4 } from "@resourcexjs/type";
294
- /**
295
- * Git-based registry implementation.
296
- * Clones a git repository and reads resources from it.
297
- */
298
308
  declare class GitRegistry implements Registry {
299
309
  private readonly url;
300
310
  private readonly ref;
@@ -302,6 +312,7 @@ declare class GitRegistry implements Registry {
302
312
  private readonly cacheDir;
303
313
  private readonly typeHandler;
304
314
  private readonly arp;
315
+ private readonly isLocal;
305
316
  constructor(config: GitRegistryConfig);
306
317
  /**
307
318
  * Build cache directory name from git URL.
@@ -315,6 +326,8 @@ declare class GitRegistry implements Registry {
315
326
  private toArpUrl;
316
327
  /**
317
328
  * Ensure the repository is cloned and up to date.
329
+ * For local paths, just verify the .git directory exists.
330
+ * For remote URLs, includes retry logic for transient network errors.
318
331
  */
319
332
  private ensureCloned;
320
333
  /**
@@ -322,10 +335,6 @@ declare class GitRegistry implements Registry {
322
335
  */
323
336
  private getDefaultBranch;
324
337
  /**
325
- * Execute git command in the cache directory.
326
- */
327
- private gitExec;
328
- /**
329
338
  * Build filesystem path for a resource in the cloned repo.
330
339
  * Path structure: {cacheDir}/{basePath}/{domain}/{path}/{name}.{type}/{version}
331
340
  */
@@ -338,9 +347,10 @@ declare class GitRegistry implements Registry {
338
347
  exists(locator: string): Promise<boolean>;
339
348
  search(options?: SearchOptions): Promise<RXL4[]>;
340
349
  private parseEntryToRXL;
350
+ link(_path: string): Promise<void>;
351
+ add(_source: string | RXR4): Promise<void>;
341
352
  pull(_locator: string, _options?: PullOptions): Promise<void>;
342
- publish(_resource: RXR4, _options: PublishOptions): Promise<void>;
343
- link(_resource: RXR4): Promise<void>;
353
+ publish(_source: string | RXR4, _options: PublishOptions): Promise<void>;
344
354
  delete(_locator: string): Promise<void>;
345
355
  }
346
356
  /**
@@ -381,9 +391,10 @@ declare abstract class RegistryMiddleware implements Registry {
381
391
  protected readonly inner: Registry;
382
392
  constructor(inner: Registry);
383
393
  supportType(type: ResourceType5): void;
394
+ link(path: string): Promise<void>;
395
+ add(source: string | RXR5): Promise<void>;
384
396
  pull(locator: string, options?: PullOptions): Promise<void>;
385
- publish(resource: RXR5, options: PublishOptions): Promise<void>;
386
- link(resource: RXR5): Promise<void>;
397
+ publish(source: string | RXR5, options: PublishOptions): Promise<void>;
387
398
  get(locator: string): Promise<RXR5>;
388
399
  resolve<
389
400
  TArgs = void,