@agentrules/core 0.0.8 → 0.0.10
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 +25 -12
- package/dist/index.js +26 -19
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -9,6 +9,8 @@ declare const platformIdSchema: z.ZodEnum<{
|
|
|
9
9
|
}>;
|
|
10
10
|
declare const titleSchema: z.ZodString;
|
|
11
11
|
declare const descriptionSchema: z.ZodString;
|
|
12
|
+
declare const tagSchema: z.ZodString;
|
|
13
|
+
declare const tagsSchema: z.ZodArray<z.ZodString>;
|
|
12
14
|
declare const slugSchema: z.ZodString;
|
|
13
15
|
declare const COMMON_LICENSES: readonly ["MIT", "Apache-2.0", "GPL-3.0-only", "BSD-3-Clause", "ISC", "Unlicense"];
|
|
14
16
|
type CommonLicense = (typeof COMMON_LICENSES)[number];
|
|
@@ -19,7 +21,7 @@ declare const presetConfigSchema: z.ZodObject<{
|
|
|
19
21
|
title: z.ZodString;
|
|
20
22
|
version: z.ZodOptional<z.ZodNumber>;
|
|
21
23
|
description: z.ZodString;
|
|
22
|
-
tags: z.
|
|
24
|
+
tags: z.ZodArray<z.ZodString>;
|
|
23
25
|
features: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
24
26
|
license: z.ZodString;
|
|
25
27
|
platform: z.ZodEnum<{
|
|
@@ -29,6 +31,7 @@ declare const presetConfigSchema: z.ZodObject<{
|
|
|
29
31
|
cursor: "cursor";
|
|
30
32
|
}>;
|
|
31
33
|
path: z.ZodOptional<z.ZodString>;
|
|
34
|
+
ignore: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
32
35
|
}, z.core.$strict>;
|
|
33
36
|
declare const bundledFileSchema: z.ZodObject<{
|
|
34
37
|
path: z.ZodString;
|
|
@@ -71,6 +74,7 @@ declare const presetPublishInputSchema: z.ZodObject<{
|
|
|
71
74
|
declare const presetBundleSchema: z.ZodObject<{
|
|
72
75
|
title: z.ZodString;
|
|
73
76
|
description: z.ZodString;
|
|
77
|
+
tags: z.ZodArray<z.ZodString>;
|
|
74
78
|
license: z.ZodString;
|
|
75
79
|
platform: z.ZodEnum<{
|
|
76
80
|
opencode: "opencode";
|
|
@@ -78,7 +82,6 @@ declare const presetBundleSchema: z.ZodObject<{
|
|
|
78
82
|
claude: "claude";
|
|
79
83
|
cursor: "cursor";
|
|
80
84
|
}>;
|
|
81
|
-
tags: z.ZodArray<z.ZodString>;
|
|
82
85
|
features: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
83
86
|
slug: z.ZodString;
|
|
84
87
|
licenseContent: z.ZodOptional<z.ZodString>;
|
|
@@ -95,6 +98,7 @@ declare const presetBundleSchema: z.ZodObject<{
|
|
|
95
98
|
declare const presetSchema: z.ZodObject<{
|
|
96
99
|
title: z.ZodString;
|
|
97
100
|
description: z.ZodString;
|
|
101
|
+
tags: z.ZodArray<z.ZodString>;
|
|
98
102
|
license: z.ZodString;
|
|
99
103
|
platform: z.ZodEnum<{
|
|
100
104
|
opencode: "opencode";
|
|
@@ -103,7 +107,6 @@ declare const presetSchema: z.ZodObject<{
|
|
|
103
107
|
cursor: "cursor";
|
|
104
108
|
}>;
|
|
105
109
|
version: z.ZodString;
|
|
106
|
-
tags: z.ZodArray<z.ZodString>;
|
|
107
110
|
features: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
108
111
|
slug: z.ZodString;
|
|
109
112
|
name: z.ZodString;
|
|
@@ -114,6 +117,7 @@ declare const presetSchema: z.ZodObject<{
|
|
|
114
117
|
declare const presetIndexSchema: z.ZodRecord<z.ZodString, z.ZodObject<{
|
|
115
118
|
title: z.ZodString;
|
|
116
119
|
description: z.ZodString;
|
|
120
|
+
tags: z.ZodArray<z.ZodString>;
|
|
117
121
|
license: z.ZodString;
|
|
118
122
|
platform: z.ZodEnum<{
|
|
119
123
|
opencode: "opencode";
|
|
@@ -122,7 +126,6 @@ declare const presetIndexSchema: z.ZodRecord<z.ZodString, z.ZodObject<{
|
|
|
122
126
|
cursor: "cursor";
|
|
123
127
|
}>;
|
|
124
128
|
version: z.ZodString;
|
|
125
|
-
tags: z.ZodArray<z.ZodString>;
|
|
126
129
|
features: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
127
130
|
slug: z.ZodString;
|
|
128
131
|
name: z.ZodString;
|
|
@@ -157,16 +160,20 @@ declare const PLATFORM_IDS: readonly ["opencode", "codex", "claude", "cursor"];
|
|
|
157
160
|
* Single source of truth for all platform paths.
|
|
158
161
|
*/
|
|
159
162
|
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
163
|
|
|
166
164
|
//#endregion
|
|
167
165
|
//#region src/platform/utils.d.ts
|
|
168
166
|
declare function isSupportedPlatform(value: string): value is PlatformId;
|
|
169
167
|
declare function normalizePlatformInput(value: string): PlatformId;
|
|
168
|
+
/**
|
|
169
|
+
* Check if a directory name matches a platform's projectDir.
|
|
170
|
+
* Used to detect if a preset config is inside a platform directory (in-project mode).
|
|
171
|
+
*/
|
|
172
|
+
declare function isPlatformDir(dirName: string): boolean;
|
|
173
|
+
/**
|
|
174
|
+
* Get the platform ID from a directory name, if it matches a platform's projectDir.
|
|
175
|
+
*/
|
|
176
|
+
declare function getPlatformFromDir(dirName: string): PlatformId | undefined;
|
|
170
177
|
|
|
171
178
|
//#endregion
|
|
172
179
|
//#region src/preset/types.d.ts
|
|
@@ -182,6 +189,8 @@ type PresetConfig = {
|
|
|
182
189
|
platform: PlatformId;
|
|
183
190
|
/** Path to config files. Defaults to platform's projectDir (e.g., ".claude") */
|
|
184
191
|
path?: string;
|
|
192
|
+
/** Additional patterns to exclude from bundle (glob patterns) */
|
|
193
|
+
ignore?: string[];
|
|
185
194
|
};
|
|
186
195
|
type BundledFile = {
|
|
187
196
|
path: string;
|
|
@@ -334,6 +343,8 @@ declare function fetchBundle(bundleUrl: string): Promise<PresetBundle>;
|
|
|
334
343
|
*/
|
|
335
344
|
/** Filename for preset configuration */
|
|
336
345
|
declare const PRESET_CONFIG_FILENAME = "agentrules.json";
|
|
346
|
+
/** Directory name for preset metadata (README, LICENSE, etc.) */
|
|
347
|
+
declare const AGENT_RULES_DIR = ".agentrules";
|
|
337
348
|
/** JSON Schema URL for preset configuration */
|
|
338
349
|
declare const PRESET_SCHEMA_URL = "https://agentrules.directory/schema/agentrules.json";
|
|
339
350
|
/** Default version identifier for latest preset version */
|
|
@@ -379,9 +390,11 @@ declare function toUint8Array(payload: ArrayBuffer | ArrayBufferView): Uint8Arra
|
|
|
379
390
|
|
|
380
391
|
//#endregion
|
|
381
392
|
//#region src/utils/paths.d.ts
|
|
393
|
+
/**
|
|
394
|
+
* Normalize a bundle file path by converting backslashes to forward slashes
|
|
395
|
+
* and removing leading ./ or / prefixes.
|
|
396
|
+
*/
|
|
382
397
|
declare function normalizeBundlePath(value: string): string;
|
|
383
|
-
declare function normalizePathFragment(value?: string): string | undefined;
|
|
384
|
-
declare function maybeStripPrefix(pathInput: string, prefix?: string): string;
|
|
385
398
|
|
|
386
399
|
//#endregion
|
|
387
|
-
export { API_ENDPOINTS, BuildPresetPublishInputOptions, BuildPresetRegistryOptions, BuildPresetRegistryResult, BundledFile, COMMON_LICENSES,
|
|
400
|
+
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, tagSchema, tagsSchema, 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
|
|
@@ -135,17 +146,20 @@ const COMMON_LICENSES = [
|
|
|
135
146
|
];
|
|
136
147
|
const licenseSchema = z.string().trim().min(1, "License is required").max(128, "License must be 128 characters or less");
|
|
137
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");
|
|
138
151
|
const presetConfigSchema = z.object({
|
|
139
152
|
$schema: z.string().optional(),
|
|
140
153
|
name: slugSchema,
|
|
141
154
|
title: titleSchema,
|
|
142
155
|
version: majorVersionSchema.optional(),
|
|
143
156
|
description: descriptionSchema,
|
|
144
|
-
tags: tagsSchema
|
|
157
|
+
tags: tagsSchema,
|
|
145
158
|
features: featuresSchema.optional(),
|
|
146
159
|
license: licenseSchema,
|
|
147
160
|
platform: platformIdSchema,
|
|
148
|
-
path: pathSchema.optional()
|
|
161
|
+
path: pathSchema.optional(),
|
|
162
|
+
ignore: ignoreSchema.optional()
|
|
149
163
|
}).strict();
|
|
150
164
|
const bundledFileSchema = z.object({
|
|
151
165
|
path: z.string().min(1),
|
|
@@ -472,20 +486,13 @@ function createDiffPreview(path, currentText, incomingText, options = {}) {
|
|
|
472
486
|
|
|
473
487
|
//#endregion
|
|
474
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
|
+
*/
|
|
475
493
|
function normalizeBundlePath(value) {
|
|
476
494
|
return value.replace(/\\/g, "/").replace(/^\.\/+/, "").replace(/^\/+/, "");
|
|
477
495
|
}
|
|
478
|
-
function normalizePathFragment(value) {
|
|
479
|
-
if (!value) return;
|
|
480
|
-
const normalized = value.replace(/\\/g, "/").replace(/^\/+/, "");
|
|
481
|
-
return normalized.replace(/\/+$/, "");
|
|
482
|
-
}
|
|
483
|
-
function maybeStripPrefix(pathInput, prefix) {
|
|
484
|
-
if (!prefix) return pathInput;
|
|
485
|
-
if (pathInput === prefix) return "";
|
|
486
|
-
if (pathInput.startsWith(`${prefix}/`)) return pathInput.slice(prefix.length + 1);
|
|
487
|
-
return pathInput;
|
|
488
|
-
}
|
|
489
496
|
|
|
490
497
|
//#endregion
|
|
491
|
-
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, tagSchema, tagsSchema, titleSchema, toPosixPath, toUint8Array, toUtf8String, validatePresetConfig, verifyBundledFileChecksum };
|