@agentrules/core 0.0.7 → 0.0.9
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 +20 -9
- package/dist/index.js +29 -19
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -29,6 +29,7 @@ declare const presetConfigSchema: z.ZodObject<{
|
|
|
29
29
|
cursor: "cursor";
|
|
30
30
|
}>;
|
|
31
31
|
path: z.ZodOptional<z.ZodString>;
|
|
32
|
+
ignore: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
32
33
|
}, z.core.$strict>;
|
|
33
34
|
declare const bundledFileSchema: z.ZodObject<{
|
|
34
35
|
path: z.ZodString;
|
|
@@ -157,16 +158,20 @@ declare const PLATFORM_IDS: readonly ["opencode", "codex", "claude", "cursor"];
|
|
|
157
158
|
* Single source of truth for all platform paths.
|
|
158
159
|
*/
|
|
159
160
|
declare const PLATFORMS: Record<PlatformId, PlatformConfig>;
|
|
160
|
-
/**
|
|
161
|
-
* Convention: preset files under this directory map to the platform config directory.
|
|
162
|
-
* e.g., `config/agent.md` → `.opencode/agent.md` (project) or `agent.md` (global)
|
|
163
|
-
*/
|
|
164
|
-
declare const CONFIG_DIR_NAME = "config";
|
|
165
161
|
|
|
166
162
|
//#endregion
|
|
167
163
|
//#region src/platform/utils.d.ts
|
|
168
164
|
declare function isSupportedPlatform(value: string): value is PlatformId;
|
|
169
165
|
declare function normalizePlatformInput(value: string): PlatformId;
|
|
166
|
+
/**
|
|
167
|
+
* Check if a directory name matches a platform's projectDir.
|
|
168
|
+
* Used to detect if a preset config is inside a platform directory (in-project mode).
|
|
169
|
+
*/
|
|
170
|
+
declare function isPlatformDir(dirName: string): boolean;
|
|
171
|
+
/**
|
|
172
|
+
* Get the platform ID from a directory name, if it matches a platform's projectDir.
|
|
173
|
+
*/
|
|
174
|
+
declare function getPlatformFromDir(dirName: string): PlatformId | undefined;
|
|
170
175
|
|
|
171
176
|
//#endregion
|
|
172
177
|
//#region src/preset/types.d.ts
|
|
@@ -182,6 +187,8 @@ type PresetConfig = {
|
|
|
182
187
|
platform: PlatformId;
|
|
183
188
|
/** Path to config files. Defaults to platform's projectDir (e.g., ".claude") */
|
|
184
189
|
path?: string;
|
|
190
|
+
/** Additional patterns to exclude from bundle (glob patterns) */
|
|
191
|
+
ignore?: string[];
|
|
185
192
|
};
|
|
186
193
|
type BundledFile = {
|
|
187
194
|
path: string;
|
|
@@ -334,6 +341,8 @@ declare function fetchBundle(bundleUrl: string): Promise<PresetBundle>;
|
|
|
334
341
|
*/
|
|
335
342
|
/** Filename for preset configuration */
|
|
336
343
|
declare const PRESET_CONFIG_FILENAME = "agentrules.json";
|
|
344
|
+
/** Directory name for preset metadata (README, LICENSE, etc.) */
|
|
345
|
+
declare const AGENT_RULES_DIR = ".agentrules";
|
|
337
346
|
/** JSON Schema URL for preset configuration */
|
|
338
347
|
declare const PRESET_SCHEMA_URL = "https://agentrules.directory/schema/agentrules.json";
|
|
339
348
|
/** Default version identifier for latest preset version */
|
|
@@ -373,15 +382,17 @@ declare function createDiffPreview(path: string, currentText: string, incomingTe
|
|
|
373
382
|
//#endregion
|
|
374
383
|
//#region src/utils/encoding.d.ts
|
|
375
384
|
declare function toPosixPath(pathValue: string): string;
|
|
376
|
-
declare function encodeUtf8(value: string): Uint8Array<
|
|
385
|
+
declare function encodeUtf8(value: string): Uint8Array<ArrayBufferLike>;
|
|
377
386
|
declare function decodeUtf8(payload: ArrayBuffer | ArrayBufferView): string;
|
|
378
387
|
declare function toUint8Array(payload: ArrayBuffer | ArrayBufferView): Uint8Array<ArrayBufferLike>;
|
|
379
388
|
|
|
380
389
|
//#endregion
|
|
381
390
|
//#region src/utils/paths.d.ts
|
|
391
|
+
/**
|
|
392
|
+
* Normalize a bundle file path by converting backslashes to forward slashes
|
|
393
|
+
* and removing leading ./ or / prefixes.
|
|
394
|
+
*/
|
|
382
395
|
declare function normalizeBundlePath(value: string): string;
|
|
383
|
-
declare function normalizePathFragment(value?: string): string | undefined;
|
|
384
|
-
declare function maybeStripPrefix(pathInput: string, prefix?: string): string;
|
|
385
396
|
|
|
386
397
|
//#endregion
|
|
387
|
-
export { API_ENDPOINTS, BuildPresetPublishInputOptions, BuildPresetRegistryOptions, BuildPresetRegistryResult, BundledFile, COMMON_LICENSES,
|
|
398
|
+
export { AGENT_RULES_DIR, API_ENDPOINTS, BuildPresetPublishInputOptions, BuildPresetRegistryOptions, BuildPresetRegistryResult, BundledFile, COMMON_LICENSES, CommonLicense, DiffPreviewOptions, LATEST_VERSION, PLATFORMS, PLATFORM_IDS, PLATFORM_ID_TUPLE, PRESET_CONFIG_FILENAME, PRESET_SCHEMA_URL, PlatformConfig, PlatformId, Preset, PresetBundle, PresetConfig, PresetFileInput, PresetIndex, PresetInput, PresetPublishInput, ResolvedPreset, STATIC_BUNDLE_DIR, buildPresetPublishInput, buildPresetRegistry, bundledFileSchema, cleanInstallMessage, createDiffPreview, decodeBundledFile, decodeUtf8, descriptionSchema, encodeItemName, encodeUtf8, fetchBundle, getPlatformFromDir, isLikelyText, isPlatformDir, isSupportedPlatform, licenseSchema, normalizeBundlePath, normalizePlatformInput, platformIdSchema, presetBundleSchema, presetConfigSchema, presetIndexSchema, presetPublishInputSchema, presetSchema, resolvePreset, slugSchema, titleSchema, toPosixPath, toUint8Array, toUtf8String, validatePresetConfig, verifyBundledFileChecksum };
|
package/dist/index.js
CHANGED
|
@@ -7,6 +7,8 @@ import { createTwoFilesPatch } from "diff";
|
|
|
7
7
|
*/
|
|
8
8
|
/** Filename for preset configuration */
|
|
9
9
|
const PRESET_CONFIG_FILENAME = "agentrules.json";
|
|
10
|
+
/** Directory name for preset metadata (README, LICENSE, etc.) */
|
|
11
|
+
const AGENT_RULES_DIR = ".agentrules";
|
|
10
12
|
/** JSON Schema URL for preset configuration */
|
|
11
13
|
const PRESET_SCHEMA_URL = "https://agentrules.directory/schema/agentrules.json";
|
|
12
14
|
/** API root path segment */
|
|
@@ -68,11 +70,6 @@ const PLATFORMS = {
|
|
|
68
70
|
globalDir: "~/.cursor"
|
|
69
71
|
}
|
|
70
72
|
};
|
|
71
|
-
/**
|
|
72
|
-
* Convention: preset files under this directory map to the platform config directory.
|
|
73
|
-
* e.g., `config/agent.md` → `.opencode/agent.md` (project) or `agent.md` (global)
|
|
74
|
-
*/
|
|
75
|
-
const CONFIG_DIR_NAME = "config";
|
|
76
73
|
|
|
77
74
|
//#endregion
|
|
78
75
|
//#region src/platform/utils.ts
|
|
@@ -84,6 +81,20 @@ function normalizePlatformInput(value) {
|
|
|
84
81
|
if (isSupportedPlatform(normalized)) return normalized;
|
|
85
82
|
throw new Error(`Unknown platform "${value}". Supported platforms: ${PLATFORM_IDS.join(", ")}.`);
|
|
86
83
|
}
|
|
84
|
+
/**
|
|
85
|
+
* Check if a directory name matches a platform's projectDir.
|
|
86
|
+
* Used to detect if a preset config is inside a platform directory (in-project mode).
|
|
87
|
+
*/
|
|
88
|
+
function isPlatformDir(dirName) {
|
|
89
|
+
return PLATFORM_IDS.some((id) => PLATFORMS[id].projectDir === dirName);
|
|
90
|
+
}
|
|
91
|
+
/**
|
|
92
|
+
* Get the platform ID from a directory name, if it matches a platform's projectDir.
|
|
93
|
+
*/
|
|
94
|
+
function getPlatformFromDir(dirName) {
|
|
95
|
+
for (const id of PLATFORM_IDS) if (PLATFORMS[id].projectDir === dirName) return id;
|
|
96
|
+
return;
|
|
97
|
+
}
|
|
87
98
|
|
|
88
99
|
//#endregion
|
|
89
100
|
//#region src/utils/encoding.ts
|
|
@@ -107,13 +118,16 @@ function toUint8Array(payload) {
|
|
|
107
118
|
|
|
108
119
|
//#endregion
|
|
109
120
|
//#region src/preset/schema.ts
|
|
121
|
+
const PLATFORM_ID_SET = new Set(PLATFORM_IDS);
|
|
110
122
|
const VERSION_REGEX = /^[1-9]\d*\.\d+$/;
|
|
111
123
|
const platformIdSchema = z.enum(PLATFORM_IDS);
|
|
112
124
|
const titleSchema = z.string().trim().min(1, "Title is required").max(80, "Title must be 80 characters or less");
|
|
113
125
|
const descriptionSchema = z.string().trim().min(1, "Description is required").max(500, "Description must be 500 characters or less");
|
|
114
126
|
const versionSchema = z.string().trim().regex(VERSION_REGEX, "Version must be in MAJOR.MINOR format (e.g., 1.3)");
|
|
115
127
|
const majorVersionSchema = z.number().int().positive("Major version must be a positive integer");
|
|
116
|
-
const
|
|
128
|
+
const TAG_REGEX = /^[a-z0-9]+(?:-[a-z0-9]+)*$/;
|
|
129
|
+
const TAG_ERROR = "Must be lowercase alphanumeric with hyphens (e.g., my-tag)";
|
|
130
|
+
const tagSchema = z.string().trim().min(1, "Tag cannot be empty").max(35, "Tag must be 35 characters or less").regex(TAG_REGEX, TAG_ERROR).refine((tag) => !PLATFORM_ID_SET.has(tag), { message: "Platform names cannot be used as tags (redundant with platform field)" });
|
|
117
131
|
const tagsSchema = z.array(tagSchema).min(1, "At least one tag is required").max(10, "Maximum 10 tags allowed");
|
|
118
132
|
const featureSchema = z.string().trim().min(1, "Feature cannot be empty").max(100, "Feature must be 100 characters or less");
|
|
119
133
|
const featuresSchema = z.array(featureSchema).max(5, "Maximum 5 features allowed");
|
|
@@ -132,6 +146,8 @@ const COMMON_LICENSES = [
|
|
|
132
146
|
];
|
|
133
147
|
const licenseSchema = z.string().trim().min(1, "License is required").max(128, "License must be 128 characters or less");
|
|
134
148
|
const pathSchema = z.string().trim().min(1);
|
|
149
|
+
const ignorePatternSchema = z.string().trim().min(1, "Ignore pattern cannot be empty");
|
|
150
|
+
const ignoreSchema = z.array(ignorePatternSchema).max(50, "Maximum 50 ignore patterns allowed");
|
|
135
151
|
const presetConfigSchema = z.object({
|
|
136
152
|
$schema: z.string().optional(),
|
|
137
153
|
name: slugSchema,
|
|
@@ -142,7 +158,8 @@ const presetConfigSchema = z.object({
|
|
|
142
158
|
features: featuresSchema.optional(),
|
|
143
159
|
license: licenseSchema,
|
|
144
160
|
platform: platformIdSchema,
|
|
145
|
-
path: pathSchema.optional()
|
|
161
|
+
path: pathSchema.optional(),
|
|
162
|
+
ignore: ignoreSchema.optional()
|
|
146
163
|
}).strict();
|
|
147
164
|
const bundledFileSchema = z.object({
|
|
148
165
|
path: z.string().min(1),
|
|
@@ -469,20 +486,13 @@ function createDiffPreview(path, currentText, incomingText, options = {}) {
|
|
|
469
486
|
|
|
470
487
|
//#endregion
|
|
471
488
|
//#region src/utils/paths.ts
|
|
489
|
+
/**
|
|
490
|
+
* Normalize a bundle file path by converting backslashes to forward slashes
|
|
491
|
+
* and removing leading ./ or / prefixes.
|
|
492
|
+
*/
|
|
472
493
|
function normalizeBundlePath(value) {
|
|
473
494
|
return value.replace(/\\/g, "/").replace(/^\.\/+/, "").replace(/^\/+/, "");
|
|
474
495
|
}
|
|
475
|
-
function normalizePathFragment(value) {
|
|
476
|
-
if (!value) return;
|
|
477
|
-
const normalized = value.replace(/\\/g, "/").replace(/^\/+/, "");
|
|
478
|
-
return normalized.replace(/\/+$/, "");
|
|
479
|
-
}
|
|
480
|
-
function maybeStripPrefix(pathInput, prefix) {
|
|
481
|
-
if (!prefix) return pathInput;
|
|
482
|
-
if (pathInput === prefix) return "";
|
|
483
|
-
if (pathInput.startsWith(`${prefix}/`)) return pathInput.slice(prefix.length + 1);
|
|
484
|
-
return pathInput;
|
|
485
|
-
}
|
|
486
496
|
|
|
487
497
|
//#endregion
|
|
488
|
-
export { API_ENDPOINTS, COMMON_LICENSES,
|
|
498
|
+
export { AGENT_RULES_DIR, API_ENDPOINTS, COMMON_LICENSES, LATEST_VERSION, PLATFORMS, PLATFORM_IDS, PLATFORM_ID_TUPLE, PRESET_CONFIG_FILENAME, PRESET_SCHEMA_URL, STATIC_BUNDLE_DIR, buildPresetPublishInput, buildPresetRegistry, bundledFileSchema, cleanInstallMessage, createDiffPreview, decodeBundledFile, decodeUtf8, descriptionSchema, encodeItemName, encodeUtf8, fetchBundle, getPlatformFromDir, isLikelyText, isPlatformDir, isSupportedPlatform, licenseSchema, normalizeBundlePath, normalizePlatformInput, platformIdSchema, presetBundleSchema, presetConfigSchema, presetIndexSchema, presetPublishInputSchema, presetSchema, resolvePreset, slugSchema, titleSchema, toPosixPath, toUint8Array, toUtf8String, validatePresetConfig, verifyBundledFileChecksum };
|