@agentrules/core 0.2.0 → 0.2.1

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/dist/index.d.ts CHANGED
@@ -316,6 +316,19 @@ declare function getInstallPath({
316
316
  }: GetInstallPathInput): string | null;
317
317
  /** Get platform configuration */
318
318
  declare function getPlatformConfig(platform: PlatformId): PlatformConfig;
319
+ /**
320
+ * Get the relative install path for a type (without the root directory prefix).
321
+ * Returns the path relative to the platform's root directory.
322
+ *
323
+ * Example: For codex instruction with scope="global", returns "AGENTS.md"
324
+ * (not "~/.codex/AGENTS.md")
325
+ */
326
+ declare function getRelativeInstallPath({
327
+ platform,
328
+ type,
329
+ name,
330
+ scope
331
+ }: GetInstallPathInput): string | null;
319
332
  /**
320
333
  * Platform-specific type tuples for zod schema validation.
321
334
  * Must be kept in sync with PLATFORMS types above.
@@ -453,11 +466,11 @@ declare const licenseSchema: z.ZodString;
453
466
  */
454
467
  declare const ruleTypeSchema: z.ZodEnum<{
455
468
  instruction: "instruction";
456
- rule: "rule";
457
- command: "command";
458
- skill: "skill";
459
469
  agent: "agent";
470
+ command: "command";
460
471
  tool: "tool";
472
+ rule: "rule";
473
+ skill: "skill";
461
474
  }>;
462
475
  /**
463
476
  * Rule config schema.
@@ -472,11 +485,11 @@ declare const ruleConfigSchema: z.ZodObject<{
472
485
  name: z.ZodString;
473
486
  type: z.ZodOptional<z.ZodEnum<{
474
487
  instruction: "instruction";
475
- rule: "rule";
476
- command: "command";
477
- skill: "skill";
478
488
  agent: "agent";
489
+ command: "command";
479
490
  tool: "tool";
491
+ rule: "rule";
492
+ skill: "skill";
480
493
  }>>;
481
494
  title: z.ZodString;
482
495
  version: z.ZodOptional<z.ZodNumber>;
@@ -539,11 +552,11 @@ declare const rulePublishInputSchema: z.ZodObject<{
539
552
  name: z.ZodString;
540
553
  type: z.ZodOptional<z.ZodEnum<{
541
554
  instruction: "instruction";
542
- rule: "rule";
543
- command: "command";
544
- skill: "skill";
545
555
  agent: "agent";
556
+ command: "command";
546
557
  tool: "tool";
558
+ rule: "rule";
559
+ skill: "skill";
547
560
  }>>;
548
561
  title: z.ZodString;
549
562
  description: z.ZodDefault<z.ZodOptional<z.ZodString>>;
@@ -577,11 +590,11 @@ declare const ruleBundleSchema: z.ZodObject<{
577
590
  name: z.ZodString;
578
591
  type: z.ZodOptional<z.ZodEnum<{
579
592
  instruction: "instruction";
580
- rule: "rule";
581
- command: "command";
582
- skill: "skill";
583
593
  agent: "agent";
594
+ command: "command";
584
595
  tool: "tool";
596
+ rule: "rule";
597
+ skill: "skill";
585
598
  }>>;
586
599
  platform: z.ZodEnum<{
587
600
  opencode: "opencode";
@@ -947,4 +960,4 @@ declare function toUint8Array(payload: ArrayBuffer | ArrayBufferView): Uint8Arra
947
960
  declare function normalizeBundlePath(value: string): string;
948
961
 
949
962
  //#endregion
950
- export { API_ENDPOINTS, BuildPublishInputOptions, BuildRegistryOptions, BuildRegistryResult, BundledFile, COMMON_LICENSES, CommonLicense, DiffPreviewOptions, GetInstallPathInput, InstallScope, LATEST_VERSION, PLATFORMS, PLATFORM_IDS, PLATFORM_ID_TUPLE, PLATFORM_RULE_TYPES, PlatformConfig, PlatformEntry, PlatformFiles, PlatformId, PlatformRuleType, PublishVariantInput, RULE_CONFIG_FILENAME, RULE_SCHEMA_URL, RULE_TYPE_TUPLE, RawPlatformEntry, RawRuleConfig, ResolveResponse, ResolvedRule, RuleBundle, RuleConfig, RuleFileInput, RuleInput, RulePublishInput, RuleType, RuleTypeForPlatform, RuleValidationResult, RuleVariant, RuleVersion, STATIC_BUNDLE_DIR, SupportsInstallPathInput, TypeConfig, buildPublishInput, buildRegistry, bundledFileSchema, cleanInstallMessage, createDiffPreview, decodeBundledFile, decodeUtf8, descriptionSchema, encodeUtf8, fetchBundle, getInstallPath, getLatestVersion, getPlatformConfig, getPlatformFromDir, getPlatforms, getTypeConfig, getValidTypes, getVariant, getVersion, hasBundle, hasInlineContent, hasPlatform, inferInstructionPlatformsFromFileName, inferPlatformFromPath, inferTypeFromPath, isLikelyText, isPlatformDir, isSupportedPlatform, isValidType, licenseSchema, nameSchema, normalizeBundlePath, normalizePlatformEntry, normalizePlatformInput, platformIdSchema, publishVariantInputSchema, resolveResponseSchema, resolveSlug, resolvedRuleSchema, ruleBundleSchema, ruleConfigSchema, rulePublishInputSchema, ruleTypeSchema, ruleVariantSchema, ruleVersionSchema, supportsInstallPath, tagSchema, tagsSchema, titleSchema, toPosixPath, toUint8Array, toUtf8String, validateConfig, validateRule, verifyBundledFileChecksum };
963
+ export { API_ENDPOINTS, BuildPublishInputOptions, BuildRegistryOptions, BuildRegistryResult, BundledFile, COMMON_LICENSES, CommonLicense, DiffPreviewOptions, GetInstallPathInput, InstallScope, LATEST_VERSION, PLATFORMS, PLATFORM_IDS, PLATFORM_ID_TUPLE, PLATFORM_RULE_TYPES, PlatformConfig, PlatformEntry, PlatformFiles, PlatformId, PlatformRuleType, PublishVariantInput, RULE_CONFIG_FILENAME, RULE_SCHEMA_URL, RULE_TYPE_TUPLE, RawPlatformEntry, RawRuleConfig, ResolveResponse, ResolvedRule, RuleBundle, RuleConfig, RuleFileInput, RuleInput, RulePublishInput, RuleType, RuleTypeForPlatform, RuleValidationResult, RuleVariant, RuleVersion, STATIC_BUNDLE_DIR, SupportsInstallPathInput, TypeConfig, buildPublishInput, buildRegistry, bundledFileSchema, cleanInstallMessage, createDiffPreview, decodeBundledFile, decodeUtf8, descriptionSchema, encodeUtf8, fetchBundle, getInstallPath, getLatestVersion, getPlatformConfig, getPlatformFromDir, getPlatforms, getRelativeInstallPath, getTypeConfig, getValidTypes, getVariant, getVersion, hasBundle, hasInlineContent, hasPlatform, inferInstructionPlatformsFromFileName, inferPlatformFromPath, inferTypeFromPath, isLikelyText, isPlatformDir, isSupportedPlatform, isValidType, licenseSchema, nameSchema, normalizeBundlePath, normalizePlatformEntry, normalizePlatformInput, platformIdSchema, publishVariantInputSchema, resolveResponseSchema, resolveSlug, resolvedRuleSchema, ruleBundleSchema, ruleConfigSchema, rulePublishInputSchema, ruleTypeSchema, ruleVariantSchema, ruleVersionSchema, supportsInstallPath, tagSchema, tagsSchema, titleSchema, toPosixPath, toUint8Array, toUtf8String, validateConfig, validateRule, verifyBundledFileChecksum };
package/dist/index.js CHANGED
@@ -156,6 +156,21 @@ function getPlatformConfig(platform) {
156
156
  return PLATFORMS[platform];
157
157
  }
158
158
  /**
159
+ * Get the relative install path for a type (without the root directory prefix).
160
+ * Returns the path relative to the platform's root directory.
161
+ *
162
+ * Example: For codex instruction with scope="global", returns "AGENTS.md"
163
+ * (not "~/.codex/AGENTS.md")
164
+ */
165
+ function getRelativeInstallPath({ platform, type, name, scope = "project" }) {
166
+ const typeConfig = getTypeConfig(platform, type);
167
+ if (!typeConfig) return null;
168
+ const template = scope === "project" ? typeConfig.project : typeConfig.global;
169
+ if (!template) return null;
170
+ if (template.includes("{name}") && !name) throw new Error(`Missing name for install path: platform="${platform}" type="${type}" scope="${scope}"`);
171
+ return template.replace("{platformDir}/", "").replace("{platformDir}", "").replace("{name}", name ?? "");
172
+ }
173
+ /**
159
174
  * Platform-specific type tuples for zod schema validation.
160
175
  * Must be kept in sync with PLATFORMS types above.
161
176
  */
@@ -674,7 +689,7 @@ function normalizeBundleBase(base) {
674
689
  }
675
690
  function getBundlePath(base, slug, platform, version) {
676
691
  const prefix = base ? `${base}/` : "";
677
- return `${prefix}${STATIC_BUNDLE_DIR}/${slug}/${platform}/${version}`;
692
+ return `${prefix}${STATIC_BUNDLE_DIR}/${slug}/${version}/${platform}.json`;
678
693
  }
679
694
  function ensureKnownPlatform(platform, slug) {
680
695
  if (!isSupportedPlatform(platform)) throw new Error(`Unknown platform "${platform}" in ${slug}. Supported: ${PLATFORM_IDS.join(", ")}`);
@@ -892,4 +907,4 @@ function normalizeBundlePath(value) {
892
907
  }
893
908
 
894
909
  //#endregion
895
- export { API_ENDPOINTS, COMMON_LICENSES, LATEST_VERSION, PLATFORMS, PLATFORM_IDS, PLATFORM_ID_TUPLE, PLATFORM_RULE_TYPES, RULE_CONFIG_FILENAME, RULE_SCHEMA_URL, RULE_TYPE_TUPLE, STATIC_BUNDLE_DIR, buildPublishInput, buildRegistry, bundledFileSchema, cleanInstallMessage, createDiffPreview, decodeBundledFile, decodeUtf8, descriptionSchema, encodeUtf8, fetchBundle, getInstallPath, getLatestVersion, getPlatformConfig, getPlatformFromDir, getPlatforms, getTypeConfig, getValidTypes, getVariant, getVersion, hasBundle, hasInlineContent, hasPlatform, inferInstructionPlatformsFromFileName, inferPlatformFromPath, inferTypeFromPath, isLikelyText, isPlatformDir, isSupportedPlatform, isValidType, licenseSchema, nameSchema, normalizeBundlePath, normalizePlatformEntry, normalizePlatformInput, platformIdSchema, publishVariantInputSchema, resolveResponseSchema, resolveSlug, resolvedRuleSchema, ruleBundleSchema, ruleConfigSchema, rulePublishInputSchema, ruleTypeSchema, ruleVariantSchema, ruleVersionSchema, supportsInstallPath, tagSchema, tagsSchema, titleSchema, toPosixPath, toUint8Array, toUtf8String, validateConfig, validateRule, verifyBundledFileChecksum };
910
+ export { API_ENDPOINTS, COMMON_LICENSES, LATEST_VERSION, PLATFORMS, PLATFORM_IDS, PLATFORM_ID_TUPLE, PLATFORM_RULE_TYPES, RULE_CONFIG_FILENAME, RULE_SCHEMA_URL, RULE_TYPE_TUPLE, STATIC_BUNDLE_DIR, buildPublishInput, buildRegistry, bundledFileSchema, cleanInstallMessage, createDiffPreview, decodeBundledFile, decodeUtf8, descriptionSchema, encodeUtf8, fetchBundle, getInstallPath, getLatestVersion, getPlatformConfig, getPlatformFromDir, getPlatforms, getRelativeInstallPath, getTypeConfig, getValidTypes, getVariant, getVersion, hasBundle, hasInlineContent, hasPlatform, inferInstructionPlatformsFromFileName, inferPlatformFromPath, inferTypeFromPath, isLikelyText, isPlatformDir, isSupportedPlatform, isValidType, licenseSchema, nameSchema, normalizeBundlePath, normalizePlatformEntry, normalizePlatformInput, platformIdSchema, publishVariantInputSchema, resolveResponseSchema, resolveSlug, resolvedRuleSchema, ruleBundleSchema, ruleConfigSchema, rulePublishInputSchema, ruleTypeSchema, ruleVariantSchema, ruleVersionSchema, supportsInstallPath, tagSchema, tagsSchema, titleSchema, toPosixPath, toUint8Array, toUtf8String, validateConfig, validateRule, verifyBundledFileChecksum };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@agentrules/core",
3
- "version": "0.2.0",
3
+ "version": "0.2.1",
4
4
  "author": "Brian Cheung <bcheung.dev@gmail.com> (https://github.com/bcheung)",
5
5
  "license": "MIT",
6
6
  "homepage": "https://agentrules.directory",