@agentrules/core 0.2.0 → 0.3.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/dist/index.d.ts CHANGED
@@ -215,6 +215,11 @@ declare const PLATFORMS: {
215
215
  readonly project: "{platformDir}/tool/{name}.ts";
216
216
  readonly global: "{platformDir}/tool/{name}.ts";
217
217
  };
218
+ readonly skill: {
219
+ readonly description: "Agent skill";
220
+ readonly project: "{platformDir}/skill/{name}/SKILL.md";
221
+ readonly global: "{platformDir}/skill/{name}/SKILL.md";
222
+ };
218
223
  };
219
224
  };
220
225
  readonly claude: {
@@ -264,6 +269,11 @@ declare const PLATFORMS: {
264
269
  readonly project: "{platformDir}/commands/{name}.md";
265
270
  readonly global: "{platformDir}/commands/{name}.md";
266
271
  };
272
+ readonly skill: {
273
+ readonly description: "Agent skill";
274
+ readonly project: "{platformDir}/skills/{name}/SKILL.md";
275
+ readonly global: "{platformDir}/skills/{name}/SKILL.md";
276
+ };
267
277
  };
268
278
  };
269
279
  readonly codex: {
@@ -281,6 +291,11 @@ declare const PLATFORMS: {
281
291
  readonly project: null;
282
292
  readonly global: "{platformDir}/prompts/{name}.md";
283
293
  };
294
+ readonly skill: {
295
+ readonly description: "Agent skill";
296
+ readonly project: "{platformDir}/skills/{name}/SKILL.md";
297
+ readonly global: "{platformDir}/skills/{name}/SKILL.md";
298
+ };
284
299
  };
285
300
  };
286
301
  };
@@ -316,15 +331,28 @@ declare function getInstallPath({
316
331
  }: GetInstallPathInput): string | null;
317
332
  /** Get platform configuration */
318
333
  declare function getPlatformConfig(platform: PlatformId): PlatformConfig;
334
+ /**
335
+ * Get the relative install path for a type (without the root directory prefix).
336
+ * Returns the path relative to the platform's root directory.
337
+ *
338
+ * Example: For codex instruction with scope="global", returns "AGENTS.md"
339
+ * (not "~/.codex/AGENTS.md")
340
+ */
341
+ declare function getRelativeInstallPath({
342
+ platform,
343
+ type,
344
+ name,
345
+ scope
346
+ }: GetInstallPathInput): string | null;
319
347
  /**
320
348
  * Platform-specific type tuples for zod schema validation.
321
349
  * Must be kept in sync with PLATFORMS types above.
322
350
  */
323
351
  declare const PLATFORM_RULE_TYPES: {
324
- readonly opencode: readonly ["instruction", "agent", "command", "tool"];
352
+ readonly opencode: readonly ["instruction", "agent", "command", "tool", "skill"];
325
353
  readonly claude: readonly ["instruction", "rule", "command", "skill"];
326
- readonly cursor: readonly ["instruction", "rule", "command"];
327
- readonly codex: readonly ["instruction", "command"];
354
+ readonly cursor: readonly ["instruction", "rule", "command", "skill"];
355
+ readonly codex: readonly ["instruction", "command", "skill"];
328
356
  };
329
357
 
330
358
  //#endregion
@@ -357,6 +385,36 @@ declare function inferInstructionPlatformsFromFileName(fileName: string): Platfo
357
385
  * Uses PLATFORMS templates as source-of-truth.
358
386
  */
359
387
  declare function inferTypeFromPath(platform: PlatformId, filePath: string): string | undefined;
388
+ type GetInstallDirInput = {
389
+ platform: PlatformId;
390
+ type: string;
391
+ name: string;
392
+ };
393
+ /**
394
+ * Get the install directory for a type (parent directory of the install path).
395
+ * For skills, this is the directory containing SKILL.md.
396
+ */
397
+ declare function getInstallDir({
398
+ platform,
399
+ type,
400
+ name
401
+ }: GetInstallDirInput): string | null;
402
+ type BundleFile = {
403
+ path: string;
404
+ content: string | Uint8Array;
405
+ };
406
+ type NormalizeSkillFilesInput = {
407
+ files: BundleFile[];
408
+ installDir: string;
409
+ };
410
+ /**
411
+ * Normalize skill files by finding SKILL.md anchor and adjusting all paths.
412
+ * Strips any existing path prefix to prevent duplication.
413
+ */
414
+ declare function normalizeSkillFiles({
415
+ files,
416
+ installDir
417
+ }: NormalizeSkillFilesInput): BundleFile[];
360
418
 
361
419
  //#endregion
362
420
  //#region src/resolve/types.d.ts
@@ -453,11 +511,11 @@ declare const licenseSchema: z.ZodString;
453
511
  */
454
512
  declare const ruleTypeSchema: z.ZodEnum<{
455
513
  instruction: "instruction";
456
- rule: "rule";
457
- command: "command";
458
- skill: "skill";
459
514
  agent: "agent";
515
+ command: "command";
460
516
  tool: "tool";
517
+ skill: "skill";
518
+ rule: "rule";
461
519
  }>;
462
520
  /**
463
521
  * Rule config schema.
@@ -472,11 +530,11 @@ declare const ruleConfigSchema: z.ZodObject<{
472
530
  name: z.ZodString;
473
531
  type: z.ZodOptional<z.ZodEnum<{
474
532
  instruction: "instruction";
475
- rule: "rule";
476
- command: "command";
477
- skill: "skill";
478
533
  agent: "agent";
534
+ command: "command";
479
535
  tool: "tool";
536
+ skill: "skill";
537
+ rule: "rule";
480
538
  }>>;
481
539
  title: z.ZodString;
482
540
  version: z.ZodOptional<z.ZodNumber>;
@@ -539,11 +597,11 @@ declare const rulePublishInputSchema: z.ZodObject<{
539
597
  name: z.ZodString;
540
598
  type: z.ZodOptional<z.ZodEnum<{
541
599
  instruction: "instruction";
542
- rule: "rule";
543
- command: "command";
544
- skill: "skill";
545
600
  agent: "agent";
601
+ command: "command";
546
602
  tool: "tool";
603
+ skill: "skill";
604
+ rule: "rule";
547
605
  }>>;
548
606
  title: z.ZodString;
549
607
  description: z.ZodDefault<z.ZodOptional<z.ZodString>>;
@@ -577,11 +635,11 @@ declare const ruleBundleSchema: z.ZodObject<{
577
635
  name: z.ZodString;
578
636
  type: z.ZodOptional<z.ZodEnum<{
579
637
  instruction: "instruction";
580
- rule: "rule";
581
- command: "command";
582
- skill: "skill";
583
638
  agent: "agent";
639
+ command: "command";
584
640
  tool: "tool";
641
+ skill: "skill";
642
+ rule: "rule";
585
643
  }>>;
586
644
  platform: z.ZodEnum<{
587
645
  opencode: "opencode";
@@ -947,4 +1005,4 @@ declare function toUint8Array(payload: ArrayBuffer | ArrayBufferView): Uint8Arra
947
1005
  declare function normalizeBundlePath(value: string): string;
948
1006
 
949
1007
  //#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 };
1008
+ export { API_ENDPOINTS, BuildPublishInputOptions, BuildRegistryOptions, BuildRegistryResult, BundleFile, BundledFile, COMMON_LICENSES, CommonLicense, DiffPreviewOptions, GetInstallDirInput, GetInstallPathInput, InstallScope, LATEST_VERSION, NormalizeSkillFilesInput, 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, getInstallDir, 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, normalizeSkillFiles, 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
@@ -52,6 +52,11 @@ const PLATFORMS = {
52
52
  description: "Custom tool",
53
53
  project: "{platformDir}/tool/{name}.ts",
54
54
  global: "{platformDir}/tool/{name}.ts"
55
+ },
56
+ skill: {
57
+ description: "Agent skill",
58
+ project: "{platformDir}/skill/{name}/SKILL.md",
59
+ global: "{platformDir}/skill/{name}/SKILL.md"
55
60
  }
56
61
  }
57
62
  },
@@ -101,6 +106,11 @@ const PLATFORMS = {
101
106
  description: "Custom slash command",
102
107
  project: "{platformDir}/commands/{name}.md",
103
108
  global: "{platformDir}/commands/{name}.md"
109
+ },
110
+ skill: {
111
+ description: "Agent skill",
112
+ project: "{platformDir}/skills/{name}/SKILL.md",
113
+ global: "{platformDir}/skills/{name}/SKILL.md"
104
114
  }
105
115
  }
106
116
  },
@@ -118,6 +128,11 @@ const PLATFORMS = {
118
128
  description: "Custom prompt",
119
129
  project: null,
120
130
  global: "{platformDir}/prompts/{name}.md"
131
+ },
132
+ skill: {
133
+ description: "Agent skill",
134
+ project: "{platformDir}/skills/{name}/SKILL.md",
135
+ global: "{platformDir}/skills/{name}/SKILL.md"
121
136
  }
122
137
  }
123
138
  }
@@ -156,6 +171,21 @@ function getPlatformConfig(platform) {
156
171
  return PLATFORMS[platform];
157
172
  }
158
173
  /**
174
+ * Get the relative install path for a type (without the root directory prefix).
175
+ * Returns the path relative to the platform's root directory.
176
+ *
177
+ * Example: For codex instruction with scope="global", returns "AGENTS.md"
178
+ * (not "~/.codex/AGENTS.md")
179
+ */
180
+ function getRelativeInstallPath({ platform, type, name, scope = "project" }) {
181
+ const typeConfig = getTypeConfig(platform, type);
182
+ if (!typeConfig) return null;
183
+ const template = scope === "project" ? typeConfig.project : typeConfig.global;
184
+ if (!template) return null;
185
+ if (template.includes("{name}") && !name) throw new Error(`Missing name for install path: platform="${platform}" type="${type}" scope="${scope}"`);
186
+ return template.replace("{platformDir}/", "").replace("{platformDir}", "").replace("{name}", name ?? "");
187
+ }
188
+ /**
159
189
  * Platform-specific type tuples for zod schema validation.
160
190
  * Must be kept in sync with PLATFORMS types above.
161
191
  */
@@ -164,7 +194,8 @@ const PLATFORM_RULE_TYPES = {
164
194
  "instruction",
165
195
  "agent",
166
196
  "command",
167
- "tool"
197
+ "tool",
198
+ "skill"
168
199
  ],
169
200
  claude: [
170
201
  "instruction",
@@ -175,9 +206,14 @@ const PLATFORM_RULE_TYPES = {
175
206
  cursor: [
176
207
  "instruction",
177
208
  "rule",
178
- "command"
209
+ "command",
210
+ "skill"
179
211
  ],
180
- codex: ["instruction", "command"]
212
+ codex: [
213
+ "instruction",
214
+ "command",
215
+ "skill"
216
+ ]
181
217
  };
182
218
 
183
219
  //#endregion
@@ -274,6 +310,41 @@ function inferTypeFromPath(platform, filePath) {
274
310
  if (!nextDir) return;
275
311
  return getProjectTypeDirMap(platform).get(nextDir);
276
312
  }
313
+ /**
314
+ * Get the install directory for a type (parent directory of the install path).
315
+ * For skills, this is the directory containing SKILL.md.
316
+ */
317
+ function getInstallDir({ platform, type, name }) {
318
+ const installPath = getInstallPath({
319
+ platform,
320
+ type,
321
+ name,
322
+ scope: "project"
323
+ });
324
+ if (!installPath) return null;
325
+ const lastSlash = installPath.lastIndexOf("/");
326
+ if (lastSlash === -1) return null;
327
+ return installPath.slice(0, lastSlash);
328
+ }
329
+ /**
330
+ * Normalize skill files by finding SKILL.md anchor and adjusting all paths.
331
+ * Strips any existing path prefix to prevent duplication.
332
+ */
333
+ function normalizeSkillFiles({ files, installDir }) {
334
+ const marker = files.find((f) => f.path === "SKILL.md" || f.path.endsWith("/SKILL.md"));
335
+ if (!marker) throw new Error("SKILL.md not found in files");
336
+ const skillRoot = marker.path === "SKILL.md" ? "." : marker.path.slice(0, marker.path.lastIndexOf("/"));
337
+ return files.map((f) => {
338
+ let relative;
339
+ if (skillRoot === ".") relative = f.path;
340
+ else if (f.path.startsWith(`${skillRoot}/`)) relative = f.path.slice(skillRoot.length + 1);
341
+ else relative = f.path;
342
+ return {
343
+ ...f,
344
+ path: `${installDir}/${relative}`
345
+ };
346
+ });
347
+ }
277
348
 
278
349
  //#endregion
279
350
  //#region src/utils/encoding.ts
@@ -674,7 +745,7 @@ function normalizeBundleBase(base) {
674
745
  }
675
746
  function getBundlePath(base, slug, platform, version) {
676
747
  const prefix = base ? `${base}/` : "";
677
- return `${prefix}${STATIC_BUNDLE_DIR}/${slug}/${platform}/${version}`;
748
+ return `${prefix}${STATIC_BUNDLE_DIR}/${slug}/${version}/${platform}.json`;
678
749
  }
679
750
  function ensureKnownPlatform(platform, slug) {
680
751
  if (!isSupportedPlatform(platform)) throw new Error(`Unknown platform "${platform}" in ${slug}. Supported: ${PLATFORM_IDS.join(", ")}`);
@@ -892,4 +963,4 @@ function normalizeBundlePath(value) {
892
963
  }
893
964
 
894
965
  //#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 };
966
+ 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, getInstallDir, 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, normalizeSkillFiles, 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.3.0",
4
4
  "author": "Brian Cheung <bcheung.dev@gmail.com> (https://github.com/bcheung)",
5
5
  "license": "MIT",
6
6
  "homepage": "https://agentrules.directory",