@agentrules/core 0.0.8 → 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 +19 -8
- package/dist/index.js +25 -18
- 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 */
|
|
@@ -379,9 +388,11 @@ declare function toUint8Array(payload: ArrayBuffer | ArrayBufferView): Uint8Arra
|
|
|
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
|
|
@@ -135,6 +146,8 @@ 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,
|
|
@@ -145,7 +158,8 @@ const presetConfigSchema = z.object({
|
|
|
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, titleSchema, toPosixPath, toUint8Array, toUtf8String, validatePresetConfig, verifyBundledFileChecksum };
|