@agentrules/core 0.2.1 → 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 +53 -8
- package/dist/index.js +60 -4
- package/package.json +1 -1
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
|
};
|
|
@@ -334,10 +349,10 @@ declare function getRelativeInstallPath({
|
|
|
334
349
|
* Must be kept in sync with PLATFORMS types above.
|
|
335
350
|
*/
|
|
336
351
|
declare const PLATFORM_RULE_TYPES: {
|
|
337
|
-
readonly opencode: readonly ["instruction", "agent", "command", "tool"];
|
|
352
|
+
readonly opencode: readonly ["instruction", "agent", "command", "tool", "skill"];
|
|
338
353
|
readonly claude: readonly ["instruction", "rule", "command", "skill"];
|
|
339
|
-
readonly cursor: readonly ["instruction", "rule", "command"];
|
|
340
|
-
readonly codex: readonly ["instruction", "command"];
|
|
354
|
+
readonly cursor: readonly ["instruction", "rule", "command", "skill"];
|
|
355
|
+
readonly codex: readonly ["instruction", "command", "skill"];
|
|
341
356
|
};
|
|
342
357
|
|
|
343
358
|
//#endregion
|
|
@@ -370,6 +385,36 @@ declare function inferInstructionPlatformsFromFileName(fileName: string): Platfo
|
|
|
370
385
|
* Uses PLATFORMS templates as source-of-truth.
|
|
371
386
|
*/
|
|
372
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[];
|
|
373
418
|
|
|
374
419
|
//#endregion
|
|
375
420
|
//#region src/resolve/types.d.ts
|
|
@@ -469,8 +514,8 @@ declare const ruleTypeSchema: z.ZodEnum<{
|
|
|
469
514
|
agent: "agent";
|
|
470
515
|
command: "command";
|
|
471
516
|
tool: "tool";
|
|
472
|
-
rule: "rule";
|
|
473
517
|
skill: "skill";
|
|
518
|
+
rule: "rule";
|
|
474
519
|
}>;
|
|
475
520
|
/**
|
|
476
521
|
* Rule config schema.
|
|
@@ -488,8 +533,8 @@ declare const ruleConfigSchema: z.ZodObject<{
|
|
|
488
533
|
agent: "agent";
|
|
489
534
|
command: "command";
|
|
490
535
|
tool: "tool";
|
|
491
|
-
rule: "rule";
|
|
492
536
|
skill: "skill";
|
|
537
|
+
rule: "rule";
|
|
493
538
|
}>>;
|
|
494
539
|
title: z.ZodString;
|
|
495
540
|
version: z.ZodOptional<z.ZodNumber>;
|
|
@@ -555,8 +600,8 @@ declare const rulePublishInputSchema: z.ZodObject<{
|
|
|
555
600
|
agent: "agent";
|
|
556
601
|
command: "command";
|
|
557
602
|
tool: "tool";
|
|
558
|
-
rule: "rule";
|
|
559
603
|
skill: "skill";
|
|
604
|
+
rule: "rule";
|
|
560
605
|
}>>;
|
|
561
606
|
title: z.ZodString;
|
|
562
607
|
description: z.ZodDefault<z.ZodOptional<z.ZodString>>;
|
|
@@ -593,8 +638,8 @@ declare const ruleBundleSchema: z.ZodObject<{
|
|
|
593
638
|
agent: "agent";
|
|
594
639
|
command: "command";
|
|
595
640
|
tool: "tool";
|
|
596
|
-
rule: "rule";
|
|
597
641
|
skill: "skill";
|
|
642
|
+
rule: "rule";
|
|
598
643
|
}>>;
|
|
599
644
|
platform: z.ZodEnum<{
|
|
600
645
|
opencode: "opencode";
|
|
@@ -960,4 +1005,4 @@ declare function toUint8Array(payload: ArrayBuffer | ArrayBufferView): Uint8Arra
|
|
|
960
1005
|
declare function normalizeBundlePath(value: string): string;
|
|
961
1006
|
|
|
962
1007
|
//#endregion
|
|
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 };
|
|
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
|
}
|
|
@@ -179,7 +194,8 @@ const PLATFORM_RULE_TYPES = {
|
|
|
179
194
|
"instruction",
|
|
180
195
|
"agent",
|
|
181
196
|
"command",
|
|
182
|
-
"tool"
|
|
197
|
+
"tool",
|
|
198
|
+
"skill"
|
|
183
199
|
],
|
|
184
200
|
claude: [
|
|
185
201
|
"instruction",
|
|
@@ -190,9 +206,14 @@ const PLATFORM_RULE_TYPES = {
|
|
|
190
206
|
cursor: [
|
|
191
207
|
"instruction",
|
|
192
208
|
"rule",
|
|
193
|
-
"command"
|
|
209
|
+
"command",
|
|
210
|
+
"skill"
|
|
194
211
|
],
|
|
195
|
-
codex: [
|
|
212
|
+
codex: [
|
|
213
|
+
"instruction",
|
|
214
|
+
"command",
|
|
215
|
+
"skill"
|
|
216
|
+
]
|
|
196
217
|
};
|
|
197
218
|
|
|
198
219
|
//#endregion
|
|
@@ -289,6 +310,41 @@ function inferTypeFromPath(platform, filePath) {
|
|
|
289
310
|
if (!nextDir) return;
|
|
290
311
|
return getProjectTypeDirMap(platform).get(nextDir);
|
|
291
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
|
+
}
|
|
292
348
|
|
|
293
349
|
//#endregion
|
|
294
350
|
//#region src/utils/encoding.ts
|
|
@@ -907,4 +963,4 @@ function normalizeBundlePath(value) {
|
|
|
907
963
|
}
|
|
908
964
|
|
|
909
965
|
//#endregion
|
|
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 };
|
|
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 };
|