@agentrules/core 0.1.0 → 0.2.1
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/README.md +80 -54
- package/dist/index.d.ts +613 -786
- package/dist/index.js +318 -314
- package/package.json +15 -10
package/dist/index.d.ts
CHANGED
|
@@ -1,185 +1,124 @@
|
|
|
1
1
|
import { z } from "zod";
|
|
2
2
|
|
|
3
|
-
//#region src/
|
|
4
|
-
/**
|
|
5
|
-
* Schema for a single tag.
|
|
6
|
-
* - Max 35 characters
|
|
7
|
-
* - Lowercase alphanumeric with hyphens
|
|
8
|
-
* - Platform names blocked (redundant with platform field)
|
|
9
|
-
*/
|
|
10
|
-
|
|
11
|
-
/**
|
|
12
|
-
* Schema for a single tag.
|
|
13
|
-
* - Max 35 characters
|
|
14
|
-
* - Lowercase alphanumeric with hyphens
|
|
15
|
-
* - Platform names blocked (redundant with platform field)
|
|
16
|
-
*/
|
|
17
|
-
declare const tagSchema: z.ZodString;
|
|
18
|
-
/**
|
|
19
|
-
* Schema for tags array.
|
|
20
|
-
* - 1-10 tags required
|
|
21
|
-
*/
|
|
22
|
-
declare const tagsSchema: z.ZodArray<z.ZodString>;
|
|
23
|
-
/**
|
|
24
|
-
* Schema for preset/rule name.
|
|
25
|
-
* - Max 64 characters
|
|
26
|
-
* - Lowercase alphanumeric with hyphens
|
|
27
|
-
*/
|
|
28
|
-
declare const nameSchema: z.ZodString;
|
|
29
|
-
/**
|
|
30
|
-
* Schema for display title.
|
|
31
|
-
* - Max 80 characters
|
|
32
|
-
*/
|
|
33
|
-
declare const titleSchema: z.ZodString;
|
|
34
|
-
/**
|
|
35
|
-
* Schema for description.
|
|
36
|
-
* - Max 500 characters
|
|
37
|
-
*/
|
|
38
|
-
declare const descriptionSchema: z.ZodString;
|
|
3
|
+
//#region src/resolve/schema.d.ts
|
|
39
4
|
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
declare const platformIdSchema: z.ZodEnum<{
|
|
43
|
-
opencode: "opencode";
|
|
44
|
-
codex: "codex";
|
|
45
|
-
claude: "claude";
|
|
46
|
-
cursor: "cursor";
|
|
47
|
-
}>;
|
|
48
|
-
/**
|
|
49
|
-
* Schema for required description (presets require a description).
|
|
50
|
-
* Extends base descriptionSchema with min(1) constraint.
|
|
51
|
-
*/
|
|
52
|
-
declare const requiredDescriptionSchema: z.ZodString;
|
|
53
|
-
declare const COMMON_LICENSES: readonly ["MIT", "Apache-2.0", "GPL-3.0-only", "BSD-3-Clause", "ISC", "Unlicense"];
|
|
54
|
-
type CommonLicense = (typeof COMMON_LICENSES)[number];
|
|
55
|
-
declare const licenseSchema: z.ZodString;
|
|
56
|
-
/**
|
|
57
|
-
* Preset config schema.
|
|
58
|
-
*
|
|
59
|
-
* Uses a unified `platforms` array that accepts either:
|
|
60
|
-
* - Platform ID strings: `["opencode", "claude"]`
|
|
61
|
-
* - Objects with optional path: `[{ platform: "opencode", path: "rules" }]`
|
|
62
|
-
* - Mixed: `["opencode", { platform: "claude", path: "my-claude" }]`
|
|
63
|
-
*/
|
|
64
|
-
declare const presetConfigSchema: z.ZodObject<{
|
|
65
|
-
$schema: z.ZodOptional<z.ZodString>;
|
|
66
|
-
name: z.ZodString;
|
|
67
|
-
title: z.ZodString;
|
|
68
|
-
version: z.ZodOptional<z.ZodNumber>;
|
|
69
|
-
description: z.ZodString;
|
|
70
|
-
tags: z.ZodArray<z.ZodString>;
|
|
71
|
-
features: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
72
|
-
license: z.ZodString;
|
|
73
|
-
ignore: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
74
|
-
agentrulesDir: z.ZodOptional<z.ZodString>;
|
|
75
|
-
platforms: z.ZodArray<z.ZodUnion<readonly [z.ZodEnum<{
|
|
5
|
+
declare const ruleVariantSchema: z.ZodUnion<readonly [z.ZodObject<{
|
|
6
|
+
platform: z.ZodEnum<{
|
|
76
7
|
opencode: "opencode";
|
|
77
8
|
codex: "codex";
|
|
78
9
|
claude: "claude";
|
|
79
10
|
cursor: "cursor";
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
cursor: "cursor";
|
|
86
|
-
}>;
|
|
87
|
-
path: z.ZodOptional<z.ZodString>;
|
|
88
|
-
}, z.core.$strict>]>>;
|
|
89
|
-
}, z.core.$strict>;
|
|
90
|
-
declare const bundledFileSchema: z.ZodObject<{
|
|
91
|
-
path: z.ZodString;
|
|
92
|
-
size: z.ZodNumber;
|
|
93
|
-
checksum: z.ZodString;
|
|
94
|
-
content: z.ZodString;
|
|
95
|
-
}, z.core.$strip>;
|
|
96
|
-
/**
|
|
97
|
-
* Schema for per-platform variant in publish input.
|
|
98
|
-
*/
|
|
99
|
-
declare const publishVariantInputSchema: z.ZodObject<{
|
|
11
|
+
}>;
|
|
12
|
+
bundleUrl: z.ZodString;
|
|
13
|
+
fileCount: z.ZodNumber;
|
|
14
|
+
totalSize: z.ZodNumber;
|
|
15
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
100
16
|
platform: z.ZodEnum<{
|
|
101
17
|
opencode: "opencode";
|
|
102
18
|
codex: "codex";
|
|
103
19
|
claude: "claude";
|
|
104
20
|
cursor: "cursor";
|
|
105
21
|
}>;
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
}, z.core.$strip>;
|
|
116
|
-
/**
|
|
117
|
-
* Schema for what clients send to publish a preset (multi-platform).
|
|
118
|
-
*
|
|
119
|
-
* One publish call creates ONE version with ALL platform variants.
|
|
120
|
-
* Version is optional major version. Registry assigns full MAJOR.MINOR.
|
|
121
|
-
*
|
|
122
|
-
* Note: Clients send `name` (e.g., "my-preset"), and the registry defines the format of the slug.
|
|
123
|
-
* For example, a namespaced slug could be returned as "username/my-preset"
|
|
124
|
-
*/
|
|
125
|
-
declare const presetPublishInputSchema: z.ZodObject<{
|
|
126
|
-
name: z.ZodString;
|
|
127
|
-
title: z.ZodString;
|
|
128
|
-
description: z.ZodString;
|
|
129
|
-
tags: z.ZodArray<z.ZodString>;
|
|
130
|
-
license: z.ZodString;
|
|
131
|
-
features: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
132
|
-
variants: z.ZodArray<z.ZodObject<{
|
|
22
|
+
content: z.ZodString;
|
|
23
|
+
fileCount: z.ZodNumber;
|
|
24
|
+
totalSize: z.ZodNumber;
|
|
25
|
+
}, z.core.$strip>]>;
|
|
26
|
+
declare const ruleVersionSchema: z.ZodObject<{
|
|
27
|
+
version: z.ZodString;
|
|
28
|
+
isLatest: z.ZodBoolean;
|
|
29
|
+
publishedAt: z.ZodOptional<z.ZodString>;
|
|
30
|
+
variants: z.ZodArray<z.ZodUnion<readonly [z.ZodObject<{
|
|
133
31
|
platform: z.ZodEnum<{
|
|
134
32
|
opencode: "opencode";
|
|
135
33
|
codex: "codex";
|
|
136
34
|
claude: "claude";
|
|
137
35
|
cursor: "cursor";
|
|
138
36
|
}>;
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
content: z.ZodString;
|
|
144
|
-
}, z.core.$strip>>;
|
|
145
|
-
readmeContent: z.ZodOptional<z.ZodString>;
|
|
146
|
-
licenseContent: z.ZodOptional<z.ZodString>;
|
|
147
|
-
installMessage: z.ZodOptional<z.ZodString>;
|
|
148
|
-
}, z.core.$strip>>;
|
|
149
|
-
version: z.ZodOptional<z.ZodNumber>;
|
|
150
|
-
}, z.core.$strip>;
|
|
151
|
-
/**
|
|
152
|
-
* Schema for what registries store and return.
|
|
153
|
-
* Includes full namespaced slug and version assigned by registry.
|
|
154
|
-
*/
|
|
155
|
-
declare const presetBundleSchema: z.ZodObject<{
|
|
156
|
-
title: z.ZodString;
|
|
157
|
-
description: z.ZodString;
|
|
158
|
-
tags: z.ZodArray<z.ZodString>;
|
|
159
|
-
variants: z.ZodArray<z.ZodObject<{
|
|
37
|
+
bundleUrl: z.ZodString;
|
|
38
|
+
fileCount: z.ZodNumber;
|
|
39
|
+
totalSize: z.ZodNumber;
|
|
40
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
160
41
|
platform: z.ZodEnum<{
|
|
161
42
|
opencode: "opencode";
|
|
162
43
|
codex: "codex";
|
|
163
44
|
claude: "claude";
|
|
164
45
|
cursor: "cursor";
|
|
165
46
|
}>;
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
47
|
+
content: z.ZodString;
|
|
48
|
+
fileCount: z.ZodNumber;
|
|
49
|
+
totalSize: z.ZodNumber;
|
|
50
|
+
}, z.core.$strip>]>>;
|
|
51
|
+
}, z.core.$strip>;
|
|
52
|
+
declare const resolvedRuleSchema: z.ZodObject<{
|
|
53
|
+
slug: z.ZodString;
|
|
54
|
+
name: z.ZodString;
|
|
55
|
+
title: z.ZodString;
|
|
56
|
+
description: z.ZodString;
|
|
57
|
+
tags: z.ZodArray<z.ZodString>;
|
|
58
|
+
license: z.ZodString;
|
|
59
|
+
features: z.ZodArray<z.ZodString>;
|
|
60
|
+
versions: z.ZodArray<z.ZodObject<{
|
|
61
|
+
version: z.ZodString;
|
|
62
|
+
isLatest: z.ZodBoolean;
|
|
63
|
+
publishedAt: z.ZodOptional<z.ZodString>;
|
|
64
|
+
variants: z.ZodArray<z.ZodUnion<readonly [z.ZodObject<{
|
|
65
|
+
platform: z.ZodEnum<{
|
|
66
|
+
opencode: "opencode";
|
|
67
|
+
codex: "codex";
|
|
68
|
+
claude: "claude";
|
|
69
|
+
cursor: "cursor";
|
|
70
|
+
}>;
|
|
71
|
+
bundleUrl: z.ZodString;
|
|
72
|
+
fileCount: z.ZodNumber;
|
|
73
|
+
totalSize: z.ZodNumber;
|
|
74
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
75
|
+
platform: z.ZodEnum<{
|
|
76
|
+
opencode: "opencode";
|
|
77
|
+
codex: "codex";
|
|
78
|
+
claude: "claude";
|
|
79
|
+
cursor: "cursor";
|
|
80
|
+
}>;
|
|
170
81
|
content: z.ZodString;
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
installMessage: z.ZodOptional<z.ZodString>;
|
|
82
|
+
fileCount: z.ZodNumber;
|
|
83
|
+
totalSize: z.ZodNumber;
|
|
84
|
+
}, z.core.$strip>]>>;
|
|
175
85
|
}, z.core.$strip>>;
|
|
176
|
-
license: z.ZodString;
|
|
177
|
-
features: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
178
|
-
slug: z.ZodString;
|
|
179
|
-
version: z.ZodString;
|
|
180
86
|
}, z.core.$strip>;
|
|
181
|
-
|
|
182
|
-
|
|
87
|
+
declare const resolveResponseSchema: z.ZodObject<{
|
|
88
|
+
slug: z.ZodString;
|
|
89
|
+
name: z.ZodString;
|
|
90
|
+
title: z.ZodString;
|
|
91
|
+
description: z.ZodString;
|
|
92
|
+
tags: z.ZodArray<z.ZodString>;
|
|
93
|
+
license: z.ZodString;
|
|
94
|
+
features: z.ZodArray<z.ZodString>;
|
|
95
|
+
versions: z.ZodArray<z.ZodObject<{
|
|
96
|
+
version: z.ZodString;
|
|
97
|
+
isLatest: z.ZodBoolean;
|
|
98
|
+
publishedAt: z.ZodOptional<z.ZodString>;
|
|
99
|
+
variants: z.ZodArray<z.ZodUnion<readonly [z.ZodObject<{
|
|
100
|
+
platform: z.ZodEnum<{
|
|
101
|
+
opencode: "opencode";
|
|
102
|
+
codex: "codex";
|
|
103
|
+
claude: "claude";
|
|
104
|
+
cursor: "cursor";
|
|
105
|
+
}>;
|
|
106
|
+
bundleUrl: z.ZodString;
|
|
107
|
+
fileCount: z.ZodNumber;
|
|
108
|
+
totalSize: z.ZodNumber;
|
|
109
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
110
|
+
platform: z.ZodEnum<{
|
|
111
|
+
opencode: "opencode";
|
|
112
|
+
codex: "codex";
|
|
113
|
+
claude: "claude";
|
|
114
|
+
cursor: "cursor";
|
|
115
|
+
}>;
|
|
116
|
+
content: z.ZodString;
|
|
117
|
+
fileCount: z.ZodNumber;
|
|
118
|
+
totalSize: z.ZodNumber;
|
|
119
|
+
}, z.core.$strip>]>>;
|
|
120
|
+
}, z.core.$strip>>;
|
|
121
|
+
}, z.core.$strip>; //#endregion
|
|
183
122
|
//#region src/platform/types.d.ts
|
|
184
123
|
/**
|
|
185
124
|
* Platform and rule type definitions.
|
|
@@ -187,39 +126,33 @@ declare const presetBundleSchema: z.ZodObject<{
|
|
|
187
126
|
declare const PLATFORM_ID_TUPLE: readonly ["opencode", "codex", "claude", "cursor"];
|
|
188
127
|
/** Union type of supported platform IDs */
|
|
189
128
|
type PlatformId = (typeof PLATFORM_ID_TUPLE)[number];
|
|
190
|
-
/**
|
|
191
|
-
type
|
|
192
|
-
/** Configuration for a single rule type */
|
|
193
|
-
type RuleTypeConfig = {
|
|
129
|
+
/** Configuration for a single type */
|
|
130
|
+
type TypeConfig = {
|
|
194
131
|
/** Human-readable description */
|
|
195
132
|
description: string;
|
|
196
|
-
/** File format */
|
|
197
|
-
format: RuleFileFormat;
|
|
198
|
-
/** File extension (without dot) */
|
|
199
|
-
extension: string;
|
|
200
133
|
/**
|
|
201
|
-
* Install path
|
|
202
|
-
*
|
|
134
|
+
* Install path template for project install.
|
|
135
|
+
* Supports: {platformDir}, {name}
|
|
203
136
|
* null if project install not supported.
|
|
204
137
|
*/
|
|
205
|
-
|
|
138
|
+
project: string | null;
|
|
206
139
|
/**
|
|
207
|
-
* Install path
|
|
208
|
-
*
|
|
140
|
+
* Install path template for global install.
|
|
141
|
+
* Supports: {platformDir}, {name}
|
|
209
142
|
* null if global install not supported.
|
|
210
143
|
*/
|
|
211
|
-
|
|
144
|
+
global: string | null;
|
|
212
145
|
};
|
|
213
146
|
/** Platform configuration with all its rule types */
|
|
214
|
-
type
|
|
147
|
+
type PlatformConfig = {
|
|
215
148
|
/** Human-readable platform name */
|
|
216
149
|
label: string;
|
|
217
|
-
/** Platform's project directory (e.g., ".
|
|
218
|
-
|
|
219
|
-
/** Platform's global config directory (
|
|
220
|
-
globalDir: string
|
|
221
|
-
/**
|
|
222
|
-
types: Record<string,
|
|
150
|
+
/** Platform's project directory (e.g., ".claude") */
|
|
151
|
+
platformDir: string;
|
|
152
|
+
/** Platform's global config directory (e.g., "~/.claude") */
|
|
153
|
+
globalDir: string;
|
|
154
|
+
/** Types supported by this platform */
|
|
155
|
+
types: Record<string, TypeConfig>;
|
|
223
156
|
};
|
|
224
157
|
/**
|
|
225
158
|
* Discriminated union of valid platform + type combinations.
|
|
@@ -230,10 +163,10 @@ type PlatformRuleType = {
|
|
|
230
163
|
type: "instruction" | "agent" | "command" | "tool";
|
|
231
164
|
} | {
|
|
232
165
|
platform: "claude";
|
|
233
|
-
type: "instruction" | "command" | "skill";
|
|
166
|
+
type: "instruction" | "command" | "skill" | "rule";
|
|
234
167
|
} | {
|
|
235
168
|
platform: "cursor";
|
|
236
|
-
type: "rule";
|
|
169
|
+
type: "instruction" | "command" | "rule";
|
|
237
170
|
} | {
|
|
238
171
|
platform: "codex";
|
|
239
172
|
type: "instruction" | "command";
|
|
@@ -242,388 +175,394 @@ type PlatformRuleType = {
|
|
|
242
175
|
type RuleTypeForPlatform<P extends PlatformId> = Extract<PlatformRuleType, {
|
|
243
176
|
platform: P;
|
|
244
177
|
}>["type"];
|
|
245
|
-
/**
|
|
178
|
+
/**
|
|
179
|
+
* All valid rule types.
|
|
180
|
+
* When type is omitted, freeform file structure is used.
|
|
181
|
+
*/
|
|
246
182
|
type RuleType = PlatformRuleType["type"];
|
|
183
|
+
/** Tuple of all rule types for schema validation */
|
|
184
|
+
declare const RULE_TYPE_TUPLE: readonly ["instruction", "rule", "command", "skill", "agent", "tool"];
|
|
247
185
|
|
|
248
186
|
//#endregion
|
|
249
187
|
//#region src/platform/config.d.ts
|
|
250
188
|
declare const PLATFORM_IDS: [PlatformId, ...PlatformId[]];
|
|
251
189
|
/**
|
|
252
|
-
* Platform configuration including supported
|
|
190
|
+
* Platform configuration including supported types and install paths.
|
|
253
191
|
*/
|
|
254
192
|
declare const PLATFORMS: {
|
|
255
193
|
readonly opencode: {
|
|
256
194
|
readonly label: "OpenCode";
|
|
257
|
-
readonly
|
|
195
|
+
readonly platformDir: ".opencode";
|
|
258
196
|
readonly globalDir: "~/.config/opencode";
|
|
259
197
|
readonly types: {
|
|
260
198
|
readonly instruction: {
|
|
261
199
|
readonly description: "Project instructions";
|
|
262
|
-
readonly
|
|
263
|
-
readonly
|
|
264
|
-
readonly projectPath: "AGENTS.md";
|
|
265
|
-
readonly globalPath: "~/.config/opencode/AGENTS.md";
|
|
200
|
+
readonly project: "AGENTS.md";
|
|
201
|
+
readonly global: "{platformDir}/AGENTS.md";
|
|
266
202
|
};
|
|
267
203
|
readonly agent: {
|
|
268
204
|
readonly description: "Specialized AI agent";
|
|
269
|
-
readonly
|
|
270
|
-
readonly
|
|
271
|
-
readonly projectPath: ".opencode/agent/{name}.md";
|
|
272
|
-
readonly globalPath: "~/.config/opencode/agent/{name}.md";
|
|
205
|
+
readonly project: "{platformDir}/agent/{name}.md";
|
|
206
|
+
readonly global: "{platformDir}/agent/{name}.md";
|
|
273
207
|
};
|
|
274
208
|
readonly command: {
|
|
275
209
|
readonly description: "Custom slash command";
|
|
276
|
-
readonly
|
|
277
|
-
readonly
|
|
278
|
-
readonly projectPath: ".opencode/command/{name}.md";
|
|
279
|
-
readonly globalPath: "~/.config/opencode/command/{name}.md";
|
|
210
|
+
readonly project: "{platformDir}/command/{name}.md";
|
|
211
|
+
readonly global: "{platformDir}/command/{name}.md";
|
|
280
212
|
};
|
|
281
213
|
readonly tool: {
|
|
282
214
|
readonly description: "Custom tool";
|
|
283
|
-
readonly
|
|
284
|
-
readonly
|
|
285
|
-
readonly projectPath: ".opencode/tool/{name}.ts";
|
|
286
|
-
readonly globalPath: "~/.config/opencode/tool/{name}.ts";
|
|
215
|
+
readonly project: "{platformDir}/tool/{name}.ts";
|
|
216
|
+
readonly global: "{platformDir}/tool/{name}.ts";
|
|
287
217
|
};
|
|
288
218
|
};
|
|
289
219
|
};
|
|
290
220
|
readonly claude: {
|
|
291
221
|
readonly label: "Claude Code";
|
|
292
|
-
readonly
|
|
222
|
+
readonly platformDir: ".claude";
|
|
293
223
|
readonly globalDir: "~/.claude";
|
|
294
224
|
readonly types: {
|
|
295
225
|
readonly instruction: {
|
|
296
226
|
readonly description: "Project instructions";
|
|
297
|
-
readonly
|
|
298
|
-
readonly
|
|
299
|
-
|
|
300
|
-
|
|
227
|
+
readonly project: "CLAUDE.md";
|
|
228
|
+
readonly global: "{platformDir}/CLAUDE.md";
|
|
229
|
+
};
|
|
230
|
+
readonly rule: {
|
|
231
|
+
readonly description: "Project rule";
|
|
232
|
+
readonly project: "{platformDir}/rules/{name}.md";
|
|
233
|
+
readonly global: "{platformDir}/rules/{name}.md";
|
|
301
234
|
};
|
|
302
235
|
readonly command: {
|
|
303
236
|
readonly description: "Custom slash command";
|
|
304
|
-
readonly
|
|
305
|
-
readonly
|
|
306
|
-
readonly projectPath: ".claude/commands/{name}.md";
|
|
307
|
-
readonly globalPath: "~/.claude/commands/{name}.md";
|
|
237
|
+
readonly project: "{platformDir}/commands/{name}.md";
|
|
238
|
+
readonly global: "{platformDir}/commands/{name}.md";
|
|
308
239
|
};
|
|
309
240
|
readonly skill: {
|
|
310
241
|
readonly description: "Custom skill";
|
|
311
|
-
readonly
|
|
312
|
-
readonly
|
|
313
|
-
readonly projectPath: ".claude/skills/{name}/SKILL.md";
|
|
314
|
-
readonly globalPath: "~/.claude/skills/{name}/SKILL.md";
|
|
242
|
+
readonly project: "{platformDir}/skills/{name}/SKILL.md";
|
|
243
|
+
readonly global: "{platformDir}/skills/{name}/SKILL.md";
|
|
315
244
|
};
|
|
316
245
|
};
|
|
317
246
|
};
|
|
318
247
|
readonly cursor: {
|
|
319
248
|
readonly label: "Cursor";
|
|
320
|
-
readonly
|
|
249
|
+
readonly platformDir: ".cursor";
|
|
321
250
|
readonly globalDir: "~/.cursor";
|
|
322
251
|
readonly types: {
|
|
323
252
|
readonly instruction: {
|
|
324
253
|
readonly description: "Project instructions";
|
|
325
|
-
readonly
|
|
326
|
-
readonly
|
|
327
|
-
readonly projectPath: "AGENTS.md";
|
|
328
|
-
readonly globalPath: null;
|
|
254
|
+
readonly project: "AGENTS.md";
|
|
255
|
+
readonly global: null;
|
|
329
256
|
};
|
|
330
257
|
readonly rule: {
|
|
331
258
|
readonly description: "Custom rule";
|
|
332
|
-
readonly
|
|
333
|
-
readonly
|
|
334
|
-
readonly projectPath: ".cursor/rules/{name}.mdc";
|
|
335
|
-
readonly globalPath: null;
|
|
259
|
+
readonly project: "{platformDir}/rules/{name}.mdc";
|
|
260
|
+
readonly global: null;
|
|
336
261
|
};
|
|
337
262
|
readonly command: {
|
|
338
263
|
readonly description: "Custom slash command";
|
|
339
|
-
readonly
|
|
340
|
-
readonly
|
|
341
|
-
readonly projectPath: ".cursor/commands/{name}.md";
|
|
342
|
-
readonly globalPath: "~/.cursor/commands/{name}.md";
|
|
264
|
+
readonly project: "{platformDir}/commands/{name}.md";
|
|
265
|
+
readonly global: "{platformDir}/commands/{name}.md";
|
|
343
266
|
};
|
|
344
267
|
};
|
|
345
268
|
};
|
|
346
269
|
readonly codex: {
|
|
347
270
|
readonly label: "Codex";
|
|
348
|
-
readonly
|
|
271
|
+
readonly platformDir: ".codex";
|
|
349
272
|
readonly globalDir: "~/.codex";
|
|
350
273
|
readonly types: {
|
|
351
274
|
readonly instruction: {
|
|
352
275
|
readonly description: "Project instructions";
|
|
353
|
-
readonly
|
|
354
|
-
readonly
|
|
355
|
-
readonly projectPath: "AGENTS.md";
|
|
356
|
-
readonly globalPath: "~/.codex/AGENTS.md";
|
|
276
|
+
readonly project: "AGENTS.md";
|
|
277
|
+
readonly global: "{platformDir}/AGENTS.md";
|
|
357
278
|
};
|
|
358
279
|
readonly command: {
|
|
359
280
|
readonly description: "Custom prompt";
|
|
360
|
-
readonly
|
|
361
|
-
readonly
|
|
362
|
-
readonly projectPath: null;
|
|
363
|
-
readonly globalPath: "~/.codex/prompts/{name}.md";
|
|
281
|
+
readonly project: null;
|
|
282
|
+
readonly global: "{platformDir}/prompts/{name}.md";
|
|
364
283
|
};
|
|
365
284
|
};
|
|
366
285
|
};
|
|
367
286
|
};
|
|
368
|
-
/**
|
|
369
|
-
declare
|
|
370
|
-
readonly opencode: readonly ["instruction", "command", "agent", "tool"];
|
|
371
|
-
readonly claude: readonly ["instruction", "command", "skill"];
|
|
372
|
-
readonly codex: readonly ["instruction", "command"];
|
|
373
|
-
readonly cursor: readonly ["instruction", "command", "rule"];
|
|
374
|
-
};
|
|
375
|
-
/** Get valid rule types for a specific platform */
|
|
376
|
-
declare function getValidRuleTypes(platform: PlatformId): readonly string[];
|
|
287
|
+
/** Get valid types for a specific platform */
|
|
288
|
+
declare function getValidTypes(platform: PlatformId): string[];
|
|
377
289
|
/** Check if a type is valid for a given platform */
|
|
378
|
-
declare function
|
|
290
|
+
declare function isValidType(platform: PlatformId, type: string): boolean;
|
|
291
|
+
type InstallScope = "project" | "global";
|
|
379
292
|
/** Get the configuration for a specific platform + type combination */
|
|
380
|
-
declare function
|
|
381
|
-
|
|
382
|
-
|
|
293
|
+
declare function getTypeConfig(platform: PlatformId, type: string): TypeConfig | undefined;
|
|
294
|
+
type SupportsInstallPathInput = {
|
|
295
|
+
platform: PlatformId;
|
|
296
|
+
type: string;
|
|
297
|
+
scope?: InstallScope;
|
|
298
|
+
};
|
|
299
|
+
declare function supportsInstallPath({
|
|
300
|
+
platform,
|
|
301
|
+
type,
|
|
302
|
+
scope
|
|
303
|
+
}: SupportsInstallPathInput): boolean;
|
|
304
|
+
/** Get the install path for a type, resolving all placeholders */
|
|
305
|
+
type GetInstallPathInput = {
|
|
306
|
+
platform: PlatformId;
|
|
307
|
+
type: string;
|
|
308
|
+
name?: string;
|
|
309
|
+
scope?: InstallScope;
|
|
310
|
+
};
|
|
311
|
+
declare function getInstallPath({
|
|
312
|
+
platform,
|
|
313
|
+
type,
|
|
314
|
+
name,
|
|
315
|
+
scope
|
|
316
|
+
}: GetInstallPathInput): string | null;
|
|
383
317
|
/** Get platform configuration */
|
|
384
|
-
declare function getPlatformConfig(platform: PlatformId):
|
|
318
|
+
declare function getPlatformConfig(platform: PlatformId): PlatformConfig;
|
|
319
|
+
/**
|
|
320
|
+
* Get the relative install path for a type (without the root directory prefix).
|
|
321
|
+
* Returns the path relative to the platform's root directory.
|
|
322
|
+
*
|
|
323
|
+
* Example: For codex instruction with scope="global", returns "AGENTS.md"
|
|
324
|
+
* (not "~/.codex/AGENTS.md")
|
|
325
|
+
*/
|
|
326
|
+
declare function getRelativeInstallPath({
|
|
327
|
+
platform,
|
|
328
|
+
type,
|
|
329
|
+
name,
|
|
330
|
+
scope
|
|
331
|
+
}: GetInstallPathInput): string | null;
|
|
332
|
+
/**
|
|
333
|
+
* Platform-specific type tuples for zod schema validation.
|
|
334
|
+
* Must be kept in sync with PLATFORMS types above.
|
|
335
|
+
*/
|
|
336
|
+
declare const PLATFORM_RULE_TYPES: {
|
|
337
|
+
readonly opencode: readonly ["instruction", "agent", "command", "tool"];
|
|
338
|
+
readonly claude: readonly ["instruction", "rule", "command", "skill"];
|
|
339
|
+
readonly cursor: readonly ["instruction", "rule", "command"];
|
|
340
|
+
readonly codex: readonly ["instruction", "command"];
|
|
341
|
+
};
|
|
385
342
|
|
|
386
343
|
//#endregion
|
|
387
344
|
//#region src/platform/utils.d.ts
|
|
388
345
|
declare function isSupportedPlatform(value: string): value is PlatformId;
|
|
389
346
|
declare function normalizePlatformInput(value: string): PlatformId;
|
|
390
347
|
/**
|
|
391
|
-
* Check if a directory name matches a platform's
|
|
392
|
-
* Used to detect if a
|
|
348
|
+
* Check if a directory name matches a platform's platformDir.
|
|
349
|
+
* Used to detect if a rule config is inside a platform directory (in-project mode).
|
|
393
350
|
*/
|
|
394
351
|
declare function isPlatformDir(dirName: string): boolean;
|
|
395
352
|
/**
|
|
396
|
-
* Get the platform ID from a directory name, if it matches a platform's
|
|
353
|
+
* Get the platform ID from a directory name, if it matches a platform's platformDir.
|
|
397
354
|
*/
|
|
398
355
|
declare function getPlatformFromDir(dirName: string): PlatformId | undefined;
|
|
399
|
-
|
|
400
|
-
//#endregion
|
|
401
|
-
//#region src/preset/types.d.ts
|
|
402
356
|
/**
|
|
403
|
-
*
|
|
357
|
+
* Infer the platform from a file path by searching for platformDir segments.
|
|
404
358
|
*
|
|
405
|
-
*
|
|
406
|
-
* - "opencode" (shorthand, uses default directory)
|
|
407
|
-
* - { platform: "opencode", path: "rules" } (custom path)
|
|
359
|
+
* Example: "/repo/.claude/commands/foo.md" -> "claude"
|
|
408
360
|
*/
|
|
409
|
-
|
|
410
|
-
platform: PlatformId;
|
|
411
|
-
path?: string;
|
|
412
|
-
};
|
|
361
|
+
declare function inferPlatformFromPath(value: string): PlatformId | undefined;
|
|
413
362
|
/**
|
|
414
|
-
*
|
|
363
|
+
* Return all platforms whose instruction file matches this basename.
|
|
364
|
+
*
|
|
365
|
+
* Example: "CLAUDE.md" -> ["claude"], "AGENTS.md" -> ["opencode", "cursor", "codex"]
|
|
415
366
|
*/
|
|
416
|
-
|
|
417
|
-
platform: PlatformId;
|
|
418
|
-
path?: string;
|
|
419
|
-
};
|
|
367
|
+
declare function inferInstructionPlatformsFromFileName(fileName: string): PlatformId[];
|
|
420
368
|
/**
|
|
421
|
-
*
|
|
369
|
+
* Infer a rule type from a file path for a known platform.
|
|
370
|
+
* Uses PLATFORMS templates as source-of-truth.
|
|
422
371
|
*/
|
|
423
|
-
declare function
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
372
|
+
declare function inferTypeFromPath(platform: PlatformId, filePath: string): string | undefined;
|
|
373
|
+
|
|
374
|
+
//#endregion
|
|
375
|
+
//#region src/resolve/types.d.ts
|
|
376
|
+
/** Base fields for all variants */
|
|
377
|
+
type BaseVariant = {
|
|
378
|
+
platform: PlatformId;
|
|
379
|
+
};
|
|
380
|
+
/** Rule variant with bundle URL (for larger rules) */
|
|
381
|
+
type RuleVariantBundle = BaseVariant & {
|
|
382
|
+
bundleUrl: string;
|
|
383
|
+
fileCount: number;
|
|
384
|
+
totalSize: number;
|
|
385
|
+
};
|
|
386
|
+
/** Rule variant with inline content (for smaller rules) */
|
|
387
|
+
type RuleVariantInline = BaseVariant & {
|
|
388
|
+
content: string;
|
|
389
|
+
fileCount: number;
|
|
390
|
+
totalSize: number;
|
|
391
|
+
};
|
|
392
|
+
/** Rule variant - registry decides bundleUrl vs inline content */
|
|
393
|
+
type RuleVariant = RuleVariantBundle | RuleVariantInline;
|
|
394
|
+
type RuleVersion = {
|
|
395
|
+
version: string;
|
|
396
|
+
isLatest: boolean;
|
|
397
|
+
publishedAt?: string;
|
|
398
|
+
variants: RuleVariant[];
|
|
399
|
+
};
|
|
400
|
+
type ResolvedRule = {
|
|
401
|
+
slug: string;
|
|
437
402
|
name: string;
|
|
403
|
+
/** Rule type - optional, defaults to freeform file structure */
|
|
404
|
+
type?: RuleType;
|
|
438
405
|
title: string;
|
|
439
|
-
version?: number;
|
|
440
406
|
description: string;
|
|
441
|
-
tags
|
|
442
|
-
features?: string[];
|
|
407
|
+
tags: string[];
|
|
443
408
|
license: string;
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
/**
|
|
447
|
-
* Directory containing metadata files (README.md, LICENSE.md, INSTALL.txt).
|
|
448
|
-
* Defaults to ".agentrules". Use "." to read metadata from the project root.
|
|
449
|
-
*/
|
|
450
|
-
agentrulesDir?: string;
|
|
451
|
-
/**
|
|
452
|
-
* Target platforms with optional custom paths.
|
|
453
|
-
* Order matters: the first platform is used as the default when viewing
|
|
454
|
-
* the preset on the registry.
|
|
455
|
-
*/
|
|
456
|
-
platforms: RawPlatformEntry[];
|
|
409
|
+
features: string[];
|
|
410
|
+
versions: RuleVersion[];
|
|
457
411
|
};
|
|
412
|
+
/** Response from items endpoint */
|
|
413
|
+
type ResolveResponse = ResolvedRule;
|
|
414
|
+
|
|
415
|
+
//#endregion
|
|
416
|
+
//#region src/resolve/utils.d.ts
|
|
458
417
|
/**
|
|
459
|
-
*
|
|
460
|
-
* Always has platforms as PlatformConfig[] (object form).
|
|
418
|
+
* Type guard for rule variant with bundleUrl
|
|
461
419
|
*/
|
|
462
|
-
|
|
463
|
-
|
|
420
|
+
declare function hasBundle(variant: RuleVariant): variant is RuleVariant & {
|
|
421
|
+
bundleUrl: string;
|
|
464
422
|
};
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
checksum: string;
|
|
423
|
+
/**
|
|
424
|
+
* Type guard for rule variant with inline content
|
|
425
|
+
*/
|
|
426
|
+
declare function hasInlineContent(variant: RuleVariant): variant is RuleVariant & {
|
|
470
427
|
content: string;
|
|
471
428
|
};
|
|
472
429
|
/**
|
|
473
|
-
*
|
|
474
|
-
* Contains files and optional metadata for a single platform.
|
|
430
|
+
* Get the latest version from a resolved rule
|
|
475
431
|
*/
|
|
476
|
-
|
|
477
|
-
platform: PlatformId;
|
|
478
|
-
files: BundledFile[];
|
|
479
|
-
/** Optional per-platform README */
|
|
480
|
-
readmeContent?: string;
|
|
481
|
-
/** Optional per-platform LICENSE */
|
|
482
|
-
licenseContent?: string;
|
|
483
|
-
/** Optional per-platform install message */
|
|
484
|
-
installMessage?: string;
|
|
485
|
-
};
|
|
432
|
+
declare function getLatestVersion(item: ResolvedRule): RuleVersion | undefined;
|
|
486
433
|
/**
|
|
487
|
-
*
|
|
488
|
-
*
|
|
489
|
-
* One publish call creates ONE version with ALL platform variants.
|
|
490
|
-
* Version is optional major version. Registry assigns full MAJOR.MINOR.
|
|
491
|
-
*
|
|
492
|
-
* Note: Clients send `name` (e.g., "my-preset"), and the registry defines the format of the slug.
|
|
493
|
-
* For example, a namespaced slug could be returned as "username/my-preset"
|
|
434
|
+
* Get a specific version from a resolved rule
|
|
494
435
|
*/
|
|
495
|
-
|
|
496
|
-
name: string;
|
|
497
|
-
title: string;
|
|
498
|
-
description: string;
|
|
499
|
-
tags: string[];
|
|
500
|
-
license: string;
|
|
501
|
-
features?: string[];
|
|
502
|
-
/** Platform variants - each contains files for that platform */
|
|
503
|
-
variants: PublishVariantInput[];
|
|
504
|
-
/** Major version. Defaults to 1 if not specified. */
|
|
505
|
-
version?: number;
|
|
506
|
-
};
|
|
436
|
+
declare function getVersion(item: ResolvedRule, version: string): RuleVersion | undefined;
|
|
507
437
|
/**
|
|
508
|
-
*
|
|
509
|
-
* This is stored in R2 and fetched via bundleUrl.
|
|
510
|
-
*
|
|
511
|
-
* Note: This is per-platform, while PresetPublishInput is multi-platform.
|
|
438
|
+
* Get a specific platform variant from a rule version
|
|
512
439
|
*/
|
|
513
|
-
|
|
514
|
-
name: string;
|
|
515
|
-
platform: PlatformId;
|
|
516
|
-
title: string;
|
|
517
|
-
description: string;
|
|
518
|
-
tags: string[];
|
|
519
|
-
license: string;
|
|
520
|
-
features?: string[];
|
|
521
|
-
files: BundledFile[];
|
|
522
|
-
readmeContent?: string;
|
|
523
|
-
licenseContent?: string;
|
|
524
|
-
installMessage?: string;
|
|
525
|
-
/** Full namespaced slug (e.g., "username/my-preset") */
|
|
526
|
-
slug: string;
|
|
527
|
-
/** Full version in MAJOR.MINOR format (e.g., "1.3", "2.1") */
|
|
528
|
-
version: string;
|
|
529
|
-
};
|
|
530
|
-
type PresetFileInput = {
|
|
531
|
-
path: string;
|
|
532
|
-
content: ArrayBuffer | ArrayBufferView | string;
|
|
533
|
-
};
|
|
440
|
+
declare function getVariant(version: RuleVersion, platform: PlatformId): RuleVariant | undefined;
|
|
534
441
|
/**
|
|
535
|
-
*
|
|
442
|
+
* Get all available platforms for a rule version
|
|
536
443
|
*/
|
|
537
|
-
|
|
538
|
-
platform: PlatformId;
|
|
539
|
-
files: PresetFileInput[];
|
|
540
|
-
/** Optional per-platform install message */
|
|
541
|
-
installMessage?: string;
|
|
542
|
-
/** Optional per-platform README */
|
|
543
|
-
readmeContent?: string;
|
|
544
|
-
/** Optional per-platform LICENSE */
|
|
545
|
-
licenseContent?: string;
|
|
546
|
-
};
|
|
444
|
+
declare function getPlatforms(version: RuleVersion): PlatformId[];
|
|
547
445
|
/**
|
|
548
|
-
*
|
|
549
|
-
* Always uses platformFiles array (works for single or multi-platform).
|
|
446
|
+
* Check if a platform is available in any version of a rule
|
|
550
447
|
*/
|
|
551
|
-
|
|
552
|
-
name: string;
|
|
553
|
-
config: PresetConfig;
|
|
554
|
-
/** Files for each platform */
|
|
555
|
-
platformFiles: PlatformFiles[];
|
|
556
|
-
/** Shared install message (fallback for platforms without their own) */
|
|
557
|
-
installMessage?: string;
|
|
558
|
-
/** Shared README (fallback for platforms without their own) */
|
|
559
|
-
readmeContent?: string;
|
|
560
|
-
/** Shared LICENSE (fallback for platforms without their own) */
|
|
561
|
-
licenseContent?: string;
|
|
562
|
-
};
|
|
448
|
+
declare function hasPlatform(item: ResolvedRule, platform: PlatformId): boolean;
|
|
563
449
|
|
|
564
450
|
//#endregion
|
|
565
|
-
//#region src/
|
|
566
|
-
declare const
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
451
|
+
//#region src/rule/schema.d.ts
|
|
452
|
+
declare const platformIdSchema: z.ZodEnum<{
|
|
453
|
+
opencode: "opencode";
|
|
454
|
+
codex: "codex";
|
|
455
|
+
claude: "claude";
|
|
456
|
+
cursor: "cursor";
|
|
457
|
+
}>;
|
|
458
|
+
declare const COMMON_LICENSES: readonly ["MIT", "Apache-2.0", "GPL-3.0-only", "BSD-3-Clause", "ISC", "Unlicense"];
|
|
459
|
+
type CommonLicense = (typeof COMMON_LICENSES)[number];
|
|
460
|
+
declare const licenseSchema: z.ZodString;
|
|
461
|
+
/**
|
|
462
|
+
* Schema for rule type.
|
|
463
|
+
* Valid types: instruction, rule, command, skill, agent, tool, multi.
|
|
464
|
+
* Optional - defaults to "multi" (freeform file structure).
|
|
465
|
+
* Platform-specific validation happens at publish time.
|
|
466
|
+
*/
|
|
467
|
+
declare const ruleTypeSchema: z.ZodEnum<{
|
|
468
|
+
instruction: "instruction";
|
|
469
|
+
agent: "agent";
|
|
470
|
+
command: "command";
|
|
471
|
+
tool: "tool";
|
|
472
|
+
rule: "rule";
|
|
473
|
+
skill: "skill";
|
|
474
|
+
}>;
|
|
475
|
+
/**
|
|
476
|
+
* Rule config schema.
|
|
477
|
+
*
|
|
478
|
+
* Uses a unified `platforms` array that accepts either:
|
|
479
|
+
* - Platform ID strings: `["opencode", "claude"]`
|
|
480
|
+
* - Objects with optional path: `[{ platform: "opencode", path: "rules" }]`
|
|
481
|
+
* - Mixed: `["opencode", { platform: "claude", path: "my-claude" }]`
|
|
482
|
+
*/
|
|
483
|
+
declare const ruleConfigSchema: z.ZodObject<{
|
|
484
|
+
$schema: z.ZodOptional<z.ZodString>;
|
|
485
|
+
name: z.ZodString;
|
|
486
|
+
type: z.ZodOptional<z.ZodEnum<{
|
|
487
|
+
instruction: "instruction";
|
|
488
|
+
agent: "agent";
|
|
489
|
+
command: "command";
|
|
490
|
+
tool: "tool";
|
|
491
|
+
rule: "rule";
|
|
492
|
+
skill: "skill";
|
|
493
|
+
}>>;
|
|
494
|
+
title: z.ZodString;
|
|
495
|
+
version: z.ZodOptional<z.ZodNumber>;
|
|
496
|
+
description: z.ZodDefault<z.ZodOptional<z.ZodString>>;
|
|
497
|
+
tags: z.ZodDefault<z.ZodOptional<z.ZodArray<z.ZodString>>>;
|
|
498
|
+
features: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
499
|
+
license: z.ZodString;
|
|
500
|
+
ignore: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
501
|
+
platforms: z.ZodArray<z.ZodUnion<readonly [z.ZodEnum<{
|
|
578
502
|
opencode: "opencode";
|
|
579
503
|
codex: "codex";
|
|
580
504
|
claude: "claude";
|
|
581
505
|
cursor: "cursor";
|
|
582
|
-
}
|
|
506
|
+
}>, z.ZodObject<{
|
|
507
|
+
platform: z.ZodEnum<{
|
|
508
|
+
opencode: "opencode";
|
|
509
|
+
codex: "codex";
|
|
510
|
+
claude: "claude";
|
|
511
|
+
cursor: "cursor";
|
|
512
|
+
}>;
|
|
513
|
+
path: z.ZodOptional<z.ZodString>;
|
|
514
|
+
}, z.core.$strict>]>>;
|
|
515
|
+
}, z.core.$strict>;
|
|
516
|
+
declare const bundledFileSchema: z.ZodObject<{
|
|
517
|
+
path: z.ZodString;
|
|
518
|
+
size: z.ZodNumber;
|
|
519
|
+
checksum: z.ZodString;
|
|
583
520
|
content: z.ZodString;
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
521
|
+
}, z.core.$strip>;
|
|
522
|
+
/**
|
|
523
|
+
* Schema for per-platform variant in publish input.
|
|
524
|
+
*/
|
|
525
|
+
declare const publishVariantInputSchema: z.ZodObject<{
|
|
588
526
|
platform: z.ZodEnum<{
|
|
589
527
|
opencode: "opencode";
|
|
590
528
|
codex: "codex";
|
|
591
529
|
claude: "claude";
|
|
592
530
|
cursor: "cursor";
|
|
593
531
|
}>;
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
version: z.ZodString;
|
|
599
|
-
isLatest: z.ZodBoolean;
|
|
600
|
-
publishedAt: z.ZodOptional<z.ZodString>;
|
|
601
|
-
variants: z.ZodArray<z.ZodUnion<readonly [z.ZodObject<{
|
|
602
|
-
platform: z.ZodEnum<{
|
|
603
|
-
opencode: "opencode";
|
|
604
|
-
codex: "codex";
|
|
605
|
-
claude: "claude";
|
|
606
|
-
cursor: "cursor";
|
|
607
|
-
}>;
|
|
608
|
-
bundleUrl: z.ZodString;
|
|
609
|
-
fileCount: z.ZodNumber;
|
|
610
|
-
totalSize: z.ZodNumber;
|
|
611
|
-
}, z.core.$strip>, z.ZodObject<{
|
|
612
|
-
platform: z.ZodEnum<{
|
|
613
|
-
opencode: "opencode";
|
|
614
|
-
codex: "codex";
|
|
615
|
-
claude: "claude";
|
|
616
|
-
cursor: "cursor";
|
|
617
|
-
}>;
|
|
532
|
+
files: z.ZodArray<z.ZodObject<{
|
|
533
|
+
path: z.ZodString;
|
|
534
|
+
size: z.ZodNumber;
|
|
535
|
+
checksum: z.ZodString;
|
|
618
536
|
content: z.ZodString;
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
|
|
537
|
+
}, z.core.$strip>>;
|
|
538
|
+
readmeContent: z.ZodOptional<z.ZodString>;
|
|
539
|
+
licenseContent: z.ZodOptional<z.ZodString>;
|
|
540
|
+
installMessage: z.ZodOptional<z.ZodString>;
|
|
622
541
|
}, z.core.$strip>;
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
|
|
542
|
+
/**
|
|
543
|
+
* Schema for what clients send to publish a rule.
|
|
544
|
+
*
|
|
545
|
+
* One publish call creates ONE version with ALL platform variants.
|
|
546
|
+
* Version is optional major version. Registry assigns full MAJOR.MINOR.
|
|
547
|
+
*
|
|
548
|
+
* Note: Clients send `name` (e.g., "my-rule"), and the registry defines the format of the slug.
|
|
549
|
+
* For example, a namespaced slug could be returned as "username/my-rule"
|
|
550
|
+
*/
|
|
551
|
+
declare const rulePublishInputSchema: z.ZodObject<{
|
|
552
|
+
name: z.ZodString;
|
|
553
|
+
type: z.ZodOptional<z.ZodEnum<{
|
|
554
|
+
instruction: "instruction";
|
|
555
|
+
agent: "agent";
|
|
556
|
+
command: "command";
|
|
557
|
+
tool: "tool";
|
|
558
|
+
rule: "rule";
|
|
559
|
+
skill: "skill";
|
|
560
|
+
}>>;
|
|
561
|
+
title: z.ZodString;
|
|
562
|
+
description: z.ZodDefault<z.ZodOptional<z.ZodString>>;
|
|
563
|
+
tags: z.ZodDefault<z.ZodOptional<z.ZodArray<z.ZodString>>>;
|
|
564
|
+
license: z.ZodString;
|
|
565
|
+
features: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
627
566
|
variants: z.ZodArray<z.ZodObject<{
|
|
628
567
|
platform: z.ZodEnum<{
|
|
629
568
|
opencode: "opencode";
|
|
@@ -631,250 +570,218 @@ declare const ruleVersionSchema: z.ZodObject<{
|
|
|
631
570
|
claude: "claude";
|
|
632
571
|
cursor: "cursor";
|
|
633
572
|
}>;
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
declare const resolvedPresetSchema: z.ZodObject<{
|
|
639
|
-
kind: z.ZodLiteral<"preset">;
|
|
640
|
-
slug: z.ZodString;
|
|
641
|
-
name: z.ZodString;
|
|
642
|
-
title: z.ZodString;
|
|
643
|
-
description: z.ZodString;
|
|
644
|
-
tags: z.ZodArray<z.ZodString>;
|
|
645
|
-
license: z.ZodString;
|
|
646
|
-
features: z.ZodArray<z.ZodString>;
|
|
647
|
-
versions: z.ZodArray<z.ZodObject<{
|
|
648
|
-
version: z.ZodString;
|
|
649
|
-
isLatest: z.ZodBoolean;
|
|
650
|
-
publishedAt: z.ZodOptional<z.ZodString>;
|
|
651
|
-
variants: z.ZodArray<z.ZodUnion<readonly [z.ZodObject<{
|
|
652
|
-
platform: z.ZodEnum<{
|
|
653
|
-
opencode: "opencode";
|
|
654
|
-
codex: "codex";
|
|
655
|
-
claude: "claude";
|
|
656
|
-
cursor: "cursor";
|
|
657
|
-
}>;
|
|
658
|
-
bundleUrl: z.ZodString;
|
|
659
|
-
fileCount: z.ZodNumber;
|
|
660
|
-
totalSize: z.ZodNumber;
|
|
661
|
-
}, z.core.$strip>, z.ZodObject<{
|
|
662
|
-
platform: z.ZodEnum<{
|
|
663
|
-
opencode: "opencode";
|
|
664
|
-
codex: "codex";
|
|
665
|
-
claude: "claude";
|
|
666
|
-
cursor: "cursor";
|
|
667
|
-
}>;
|
|
668
|
-
content: z.ZodString;
|
|
669
|
-
fileCount: z.ZodNumber;
|
|
670
|
-
totalSize: z.ZodNumber;
|
|
671
|
-
}, z.core.$strip>]>>;
|
|
672
|
-
}, z.core.$strip>>;
|
|
673
|
-
}, z.core.$strip>;
|
|
674
|
-
declare const resolvedRuleSchema: z.ZodObject<{
|
|
675
|
-
kind: z.ZodLiteral<"rule">;
|
|
676
|
-
slug: z.ZodString;
|
|
677
|
-
name: z.ZodString;
|
|
678
|
-
title: z.ZodString;
|
|
679
|
-
description: z.ZodString;
|
|
680
|
-
tags: z.ZodArray<z.ZodString>;
|
|
681
|
-
versions: z.ZodArray<z.ZodObject<{
|
|
682
|
-
version: z.ZodString;
|
|
683
|
-
isLatest: z.ZodBoolean;
|
|
684
|
-
publishedAt: z.ZodOptional<z.ZodString>;
|
|
685
|
-
variants: z.ZodArray<z.ZodObject<{
|
|
686
|
-
platform: z.ZodEnum<{
|
|
687
|
-
opencode: "opencode";
|
|
688
|
-
codex: "codex";
|
|
689
|
-
claude: "claude";
|
|
690
|
-
cursor: "cursor";
|
|
691
|
-
}>;
|
|
692
|
-
type: z.ZodString;
|
|
573
|
+
files: z.ZodArray<z.ZodObject<{
|
|
574
|
+
path: z.ZodString;
|
|
575
|
+
size: z.ZodNumber;
|
|
576
|
+
checksum: z.ZodString;
|
|
693
577
|
content: z.ZodString;
|
|
694
578
|
}, z.core.$strip>>;
|
|
579
|
+
readmeContent: z.ZodOptional<z.ZodString>;
|
|
580
|
+
licenseContent: z.ZodOptional<z.ZodString>;
|
|
581
|
+
installMessage: z.ZodOptional<z.ZodString>;
|
|
695
582
|
}, z.core.$strip>>;
|
|
583
|
+
version: z.ZodOptional<z.ZodNumber>;
|
|
696
584
|
}, z.core.$strip>;
|
|
697
|
-
|
|
698
|
-
|
|
699
|
-
|
|
700
|
-
|
|
701
|
-
|
|
702
|
-
description: z.ZodString;
|
|
703
|
-
tags: z.ZodArray<z.ZodString>;
|
|
704
|
-
license: z.ZodString;
|
|
705
|
-
features: z.ZodArray<z.ZodString>;
|
|
706
|
-
versions: z.ZodArray<z.ZodObject<{
|
|
707
|
-
version: z.ZodString;
|
|
708
|
-
isLatest: z.ZodBoolean;
|
|
709
|
-
publishedAt: z.ZodOptional<z.ZodString>;
|
|
710
|
-
variants: z.ZodArray<z.ZodUnion<readonly [z.ZodObject<{
|
|
711
|
-
platform: z.ZodEnum<{
|
|
712
|
-
opencode: "opencode";
|
|
713
|
-
codex: "codex";
|
|
714
|
-
claude: "claude";
|
|
715
|
-
cursor: "cursor";
|
|
716
|
-
}>;
|
|
717
|
-
bundleUrl: z.ZodString;
|
|
718
|
-
fileCount: z.ZodNumber;
|
|
719
|
-
totalSize: z.ZodNumber;
|
|
720
|
-
}, z.core.$strip>, z.ZodObject<{
|
|
721
|
-
platform: z.ZodEnum<{
|
|
722
|
-
opencode: "opencode";
|
|
723
|
-
codex: "codex";
|
|
724
|
-
claude: "claude";
|
|
725
|
-
cursor: "cursor";
|
|
726
|
-
}>;
|
|
727
|
-
content: z.ZodString;
|
|
728
|
-
fileCount: z.ZodNumber;
|
|
729
|
-
totalSize: z.ZodNumber;
|
|
730
|
-
}, z.core.$strip>]>>;
|
|
731
|
-
}, z.core.$strip>>;
|
|
732
|
-
}, z.core.$strip>, z.ZodObject<{
|
|
733
|
-
kind: z.ZodLiteral<"rule">;
|
|
734
|
-
slug: z.ZodString;
|
|
585
|
+
/**
|
|
586
|
+
* Schema for what registries store and return for a single platform bundle.
|
|
587
|
+
* This is per-platform (flat structure), stored in R2 and fetched via bundleUrl.
|
|
588
|
+
*/
|
|
589
|
+
declare const ruleBundleSchema: z.ZodObject<{
|
|
735
590
|
name: z.ZodString;
|
|
736
|
-
|
|
737
|
-
|
|
738
|
-
|
|
739
|
-
|
|
740
|
-
|
|
741
|
-
|
|
742
|
-
|
|
743
|
-
|
|
744
|
-
|
|
745
|
-
|
|
746
|
-
|
|
747
|
-
|
|
748
|
-
|
|
749
|
-
|
|
750
|
-
|
|
751
|
-
|
|
752
|
-
|
|
591
|
+
type: z.ZodOptional<z.ZodEnum<{
|
|
592
|
+
instruction: "instruction";
|
|
593
|
+
agent: "agent";
|
|
594
|
+
command: "command";
|
|
595
|
+
tool: "tool";
|
|
596
|
+
rule: "rule";
|
|
597
|
+
skill: "skill";
|
|
598
|
+
}>>;
|
|
599
|
+
platform: z.ZodEnum<{
|
|
600
|
+
opencode: "opencode";
|
|
601
|
+
codex: "codex";
|
|
602
|
+
claude: "claude";
|
|
603
|
+
cursor: "cursor";
|
|
604
|
+
}>;
|
|
605
|
+
title: z.ZodString;
|
|
606
|
+
description: z.ZodDefault<z.ZodOptional<z.ZodString>>;
|
|
607
|
+
tags: z.ZodDefault<z.ZodOptional<z.ZodArray<z.ZodString>>>;
|
|
608
|
+
license: z.ZodString;
|
|
609
|
+
features: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
610
|
+
files: z.ZodArray<z.ZodObject<{
|
|
611
|
+
path: z.ZodString;
|
|
612
|
+
size: z.ZodNumber;
|
|
613
|
+
checksum: z.ZodString;
|
|
614
|
+
content: z.ZodString;
|
|
753
615
|
}, z.core.$strip>>;
|
|
754
|
-
|
|
616
|
+
readmeContent: z.ZodOptional<z.ZodString>;
|
|
617
|
+
licenseContent: z.ZodOptional<z.ZodString>;
|
|
618
|
+
installMessage: z.ZodOptional<z.ZodString>;
|
|
619
|
+
slug: z.ZodString;
|
|
620
|
+
version: z.ZodString;
|
|
621
|
+
}, z.core.$strip>;
|
|
755
622
|
|
|
756
623
|
//#endregion
|
|
757
|
-
//#region src/
|
|
758
|
-
/**
|
|
759
|
-
type
|
|
624
|
+
//#region src/rule/types.d.ts
|
|
625
|
+
/** Normalized platform entry - always object form */
|
|
626
|
+
type PlatformEntry = {
|
|
760
627
|
platform: PlatformId;
|
|
628
|
+
path?: string;
|
|
761
629
|
};
|
|
762
|
-
/**
|
|
763
|
-
type
|
|
764
|
-
|
|
765
|
-
|
|
766
|
-
|
|
630
|
+
/** Raw platform entry - string shorthand or object with optional path */
|
|
631
|
+
type RawPlatformEntry = PlatformId | PlatformEntry;
|
|
632
|
+
/** Normalize a raw platform entry to the object form */
|
|
633
|
+
declare function normalizePlatformEntry(entry: RawPlatformEntry): PlatformEntry;
|
|
634
|
+
/**
|
|
635
|
+
* Raw rule configuration - what users write in agentrules.json.
|
|
636
|
+
*
|
|
637
|
+
* Uses a unified `platforms` array that accepts either:
|
|
638
|
+
* - Platform ID strings: `["opencode", "claude"]`
|
|
639
|
+
* - Objects with optional path: `[{ platform: "opencode", path: "rules" }]`
|
|
640
|
+
* - Mixed: `["opencode", { platform: "claude", path: "my-claude" }]`
|
|
641
|
+
*
|
|
642
|
+
* **Order matters**: The first platform in the array is used as the default
|
|
643
|
+
* when viewing the rule on the registry without specifying a platform.
|
|
644
|
+
*/
|
|
645
|
+
type RawRuleConfig = {
|
|
646
|
+
$schema?: string;
|
|
647
|
+
name: string;
|
|
648
|
+
/**
|
|
649
|
+
* Rule type - determines install path and constrains valid platforms.
|
|
650
|
+
* Optional - defaults to "multi" (freeform file structure).
|
|
651
|
+
*/
|
|
652
|
+
type?: RuleType;
|
|
653
|
+
title: string;
|
|
654
|
+
version?: number;
|
|
655
|
+
description: string;
|
|
656
|
+
tags?: string[];
|
|
657
|
+
features?: string[];
|
|
658
|
+
license: string;
|
|
659
|
+
/** Additional patterns to exclude from bundle (glob patterns) */
|
|
660
|
+
ignore?: string[];
|
|
661
|
+
/**
|
|
662
|
+
* Target platforms with optional custom paths.
|
|
663
|
+
* Order matters: the first platform is used as the default when viewing
|
|
664
|
+
* the rule on the registry.
|
|
665
|
+
*/
|
|
666
|
+
platforms: RawPlatformEntry[];
|
|
767
667
|
};
|
|
768
|
-
/**
|
|
769
|
-
|
|
770
|
-
|
|
771
|
-
|
|
772
|
-
|
|
668
|
+
/**
|
|
669
|
+
* Normalized rule configuration - used internally after loading.
|
|
670
|
+
*/
|
|
671
|
+
type RuleConfig = Omit<RawRuleConfig, "platforms"> & {
|
|
672
|
+
platforms: PlatformEntry[];
|
|
773
673
|
};
|
|
774
|
-
|
|
775
|
-
|
|
776
|
-
/**
|
|
777
|
-
|
|
778
|
-
|
|
674
|
+
type BundledFile = {
|
|
675
|
+
path: string;
|
|
676
|
+
/** File size in bytes */
|
|
677
|
+
size: number;
|
|
678
|
+
checksum: string;
|
|
779
679
|
content: string;
|
|
780
680
|
};
|
|
781
|
-
|
|
782
|
-
|
|
783
|
-
|
|
784
|
-
|
|
785
|
-
|
|
786
|
-
|
|
787
|
-
|
|
788
|
-
|
|
789
|
-
|
|
790
|
-
|
|
791
|
-
|
|
681
|
+
/**
|
|
682
|
+
* Per-platform variant input for publishing.
|
|
683
|
+
* Contains files and optional metadata for a single platform.
|
|
684
|
+
*/
|
|
685
|
+
type PublishVariantInput = {
|
|
686
|
+
platform: PlatformId;
|
|
687
|
+
files: BundledFile[];
|
|
688
|
+
/** Optional per-platform README */
|
|
689
|
+
readmeContent?: string;
|
|
690
|
+
/** Optional per-platform LICENSE */
|
|
691
|
+
licenseContent?: string;
|
|
692
|
+
/** Optional per-platform install message */
|
|
693
|
+
installMessage?: string;
|
|
792
694
|
};
|
|
793
|
-
|
|
794
|
-
|
|
795
|
-
|
|
695
|
+
/**
|
|
696
|
+
* What clients send to publish a rule (multi-platform).
|
|
697
|
+
*
|
|
698
|
+
* One publish call creates ONE version with ALL platform variants.
|
|
699
|
+
* Version is optional major version. Registry assigns full MAJOR.MINOR.
|
|
700
|
+
*
|
|
701
|
+
* Note: Clients send `name` (e.g., "my-rule"), and the registry defines the format of the slug.
|
|
702
|
+
* For example, a namespaced slug could be returned as "username/my-rule"
|
|
703
|
+
*/
|
|
704
|
+
type RulePublishInput = {
|
|
796
705
|
name: string;
|
|
706
|
+
/** Rule type - optional, defaults to freeform file structure */
|
|
707
|
+
type?: RuleType;
|
|
797
708
|
title: string;
|
|
798
709
|
description: string;
|
|
799
710
|
tags: string[];
|
|
800
711
|
license: string;
|
|
801
|
-
features
|
|
802
|
-
|
|
712
|
+
features?: string[];
|
|
713
|
+
/** Platform variants - each contains files for that platform */
|
|
714
|
+
variants: PublishVariantInput[];
|
|
715
|
+
/** Major version. Defaults to 1 if not specified. */
|
|
716
|
+
version?: number;
|
|
803
717
|
};
|
|
804
|
-
|
|
805
|
-
|
|
806
|
-
|
|
718
|
+
/**
|
|
719
|
+
* What registries store and return for a single platform bundle.
|
|
720
|
+
* This is stored in R2 and fetched via bundleUrl.
|
|
721
|
+
*
|
|
722
|
+
* Note: This is per-platform, while RulePublishInput is multi-platform.
|
|
723
|
+
*/
|
|
724
|
+
type RuleBundle = {
|
|
807
725
|
name: string;
|
|
726
|
+
/** Rule type - optional, defaults to freeform file structure */
|
|
727
|
+
type?: RuleType;
|
|
728
|
+
platform: PlatformId;
|
|
808
729
|
title: string;
|
|
809
730
|
description: string;
|
|
810
731
|
tags: string[];
|
|
811
|
-
|
|
732
|
+
license: string;
|
|
733
|
+
features?: string[];
|
|
734
|
+
files: BundledFile[];
|
|
735
|
+
readmeContent?: string;
|
|
736
|
+
licenseContent?: string;
|
|
737
|
+
installMessage?: string;
|
|
738
|
+
/** Full namespaced slug (e.g., "username/my-rule") */
|
|
739
|
+
slug: string;
|
|
740
|
+
/** Full version in MAJOR.MINOR format (e.g., "1.3", "2.1") */
|
|
741
|
+
version: string;
|
|
812
742
|
};
|
|
813
|
-
|
|
814
|
-
|
|
815
|
-
|
|
816
|
-
//#endregion
|
|
817
|
-
//#region src/resolve/utils.d.ts
|
|
818
|
-
/**
|
|
819
|
-
* Type guard for preset
|
|
820
|
-
*/
|
|
821
|
-
declare function isPreset(item: ResolveResponse): item is ResolvedPreset;
|
|
822
|
-
/**
|
|
823
|
-
* Type guard for rule
|
|
824
|
-
*/
|
|
825
|
-
declare function isRule(item: ResolveResponse): item is ResolvedRule;
|
|
826
|
-
/**
|
|
827
|
-
* Type guard for preset variant with bundleUrl
|
|
828
|
-
*/
|
|
829
|
-
declare function hasBundle(variant: PresetVariant): variant is PresetVariant & {
|
|
830
|
-
bundleUrl: string;
|
|
743
|
+
type RuleFileInput = {
|
|
744
|
+
path: string;
|
|
745
|
+
content: ArrayBuffer | ArrayBufferView | string;
|
|
831
746
|
};
|
|
832
747
|
/**
|
|
833
|
-
*
|
|
748
|
+
* Files for a single platform variant
|
|
834
749
|
*/
|
|
835
|
-
|
|
836
|
-
|
|
750
|
+
type PlatformFiles = {
|
|
751
|
+
platform: PlatformId;
|
|
752
|
+
files: RuleFileInput[];
|
|
753
|
+
/** Optional per-platform install message */
|
|
754
|
+
installMessage?: string;
|
|
755
|
+
/** Optional per-platform README */
|
|
756
|
+
readmeContent?: string;
|
|
757
|
+
/** Optional per-platform LICENSE */
|
|
758
|
+
licenseContent?: string;
|
|
837
759
|
};
|
|
838
760
|
/**
|
|
839
|
-
*
|
|
840
|
-
|
|
841
|
-
declare function getLatestPresetVersion(item: ResolvedPreset): PresetVersion | undefined;
|
|
842
|
-
/**
|
|
843
|
-
* Get the latest version from a resolved rule
|
|
844
|
-
*/
|
|
845
|
-
declare function getLatestRuleVersion(item: ResolvedRule): RuleVersion | undefined;
|
|
846
|
-
/**
|
|
847
|
-
* Get a specific version from a resolved preset
|
|
848
|
-
*/
|
|
849
|
-
declare function getPresetVersion(item: ResolvedPreset, version: string): PresetVersion | undefined;
|
|
850
|
-
/**
|
|
851
|
-
* Get a specific version from a resolved rule
|
|
852
|
-
*/
|
|
853
|
-
declare function getRuleVersion(item: ResolvedRule, version: string): RuleVersion | undefined;
|
|
854
|
-
/**
|
|
855
|
-
* Get a specific platform variant from a preset version
|
|
856
|
-
*/
|
|
857
|
-
declare function getPresetVariant(version: PresetVersion, platform: PlatformId): PresetVariant | undefined;
|
|
858
|
-
/**
|
|
859
|
-
* Get a specific platform variant from a rule version
|
|
860
|
-
*/
|
|
861
|
-
declare function getRuleVariant(version: RuleVersion, platform: PlatformId): RuleVariant | undefined;
|
|
862
|
-
/**
|
|
863
|
-
* Get all available platforms for a preset version
|
|
864
|
-
*/
|
|
865
|
-
declare function getPresetPlatforms(version: PresetVersion): PlatformId[];
|
|
866
|
-
/**
|
|
867
|
-
* Get all available platforms for a rule version
|
|
868
|
-
*/
|
|
869
|
-
declare function getRulePlatforms(version: RuleVersion): PlatformId[];
|
|
870
|
-
/**
|
|
871
|
-
* Check if a platform is available in any version of a preset
|
|
872
|
-
*/
|
|
873
|
-
declare function presetHasPlatform(item: ResolvedPreset, platform: PlatformId): boolean;
|
|
874
|
-
/**
|
|
875
|
-
* Check if a platform is available in any version of a rule
|
|
761
|
+
* Rule input - what the CLI builds after loading files.
|
|
762
|
+
* Always uses platformFiles array (works for single or multi-platform).
|
|
876
763
|
*/
|
|
877
|
-
|
|
764
|
+
type RuleInput = {
|
|
765
|
+
name: string;
|
|
766
|
+
config: RuleConfig;
|
|
767
|
+
/** Files for each platform */
|
|
768
|
+
platformFiles: PlatformFiles[];
|
|
769
|
+
/** Shared install message (fallback for platforms without their own) */
|
|
770
|
+
installMessage?: string;
|
|
771
|
+
/** Shared README (fallback for platforms without their own) */
|
|
772
|
+
readmeContent?: string;
|
|
773
|
+
/** Shared LICENSE (fallback for platforms without their own) */
|
|
774
|
+
licenseContent?: string;
|
|
775
|
+
};
|
|
776
|
+
|
|
777
|
+
//#endregion
|
|
778
|
+
//#region src/rule/validate.d.ts
|
|
779
|
+
type RuleValidationResult = {
|
|
780
|
+
valid: boolean;
|
|
781
|
+
errors: string[];
|
|
782
|
+
warnings: string[];
|
|
783
|
+
};
|
|
784
|
+
declare function validateRule(config: RuleConfig): RuleValidationResult;
|
|
878
785
|
|
|
879
786
|
//#endregion
|
|
880
787
|
//#region src/builder/registry.d.ts
|
|
@@ -884,26 +791,26 @@ declare function ruleHasPlatform(item: ResolvedRule, platform: PlatformId): bool
|
|
|
884
791
|
*/
|
|
885
792
|
declare const STATIC_BUNDLE_DIR = "registry";
|
|
886
793
|
/**
|
|
887
|
-
* Options for building a
|
|
794
|
+
* Options for building a publish input.
|
|
888
795
|
*/
|
|
889
|
-
type
|
|
890
|
-
/**
|
|
891
|
-
|
|
796
|
+
type BuildPublishInputOptions = {
|
|
797
|
+
/** Rule input (single or multi-platform) */
|
|
798
|
+
rule: RuleInput;
|
|
892
799
|
/** Major version. Defaults to 1 if not specified. */
|
|
893
800
|
version?: number;
|
|
894
801
|
};
|
|
895
802
|
/**
|
|
896
|
-
* Builds a
|
|
803
|
+
* Builds a RulePublishInput from rule input.
|
|
897
804
|
*
|
|
898
|
-
*
|
|
805
|
+
* RuleInput always has platformFiles array (unified format).
|
|
899
806
|
*/
|
|
900
|
-
declare function
|
|
807
|
+
declare function buildPublishInput(options: BuildPublishInputOptions): Promise<RulePublishInput>;
|
|
901
808
|
/**
|
|
902
809
|
* Options for building a static registry.
|
|
903
810
|
*/
|
|
904
|
-
type
|
|
905
|
-
/**
|
|
906
|
-
|
|
811
|
+
type BuildRegistryOptions = {
|
|
812
|
+
/** Rules to include (single or multi-platform) */
|
|
813
|
+
rules: RuleInput[];
|
|
907
814
|
/**
|
|
908
815
|
* Optional base path or URL prefix for bundle locations.
|
|
909
816
|
* Format: {bundleBase}/{STATIC_BUNDLE_DIR}/{slug}/{platform}/{version}
|
|
@@ -911,29 +818,29 @@ type BuildPresetRegistryOptions = {
|
|
|
911
818
|
*/
|
|
912
819
|
bundleBase?: string;
|
|
913
820
|
};
|
|
914
|
-
type
|
|
915
|
-
/** Resolved
|
|
916
|
-
|
|
821
|
+
type BuildRegistryResult = {
|
|
822
|
+
/** Resolved rules in the unified format (one per slug with all versions/variants) */
|
|
823
|
+
rules: ResolvedRule[];
|
|
917
824
|
/** Bundles for each platform variant (used to write individual bundle files) */
|
|
918
|
-
bundles:
|
|
825
|
+
bundles: RuleBundle[];
|
|
919
826
|
};
|
|
920
827
|
/**
|
|
921
828
|
* Builds a static registry with items and bundles.
|
|
922
829
|
*
|
|
923
830
|
* Uses the same model as dynamic publishing:
|
|
924
|
-
* - Each
|
|
831
|
+
* - Each RuleInput (single or multi-platform) becomes one item
|
|
925
832
|
* - Each platform variant becomes one bundle
|
|
926
833
|
*/
|
|
927
|
-
declare function
|
|
834
|
+
declare function buildRegistry(options: BuildRegistryOptions): Promise<BuildRegistryResult>;
|
|
928
835
|
|
|
929
836
|
//#endregion
|
|
930
837
|
//#region src/builder/utils.d.ts
|
|
931
838
|
declare function cleanInstallMessage(value: unknown): string | undefined;
|
|
932
839
|
/**
|
|
933
|
-
* Validate raw
|
|
840
|
+
* Validate raw rule config from JSON.
|
|
934
841
|
* Returns the raw config shape (before normalization).
|
|
935
842
|
*/
|
|
936
|
-
declare function
|
|
843
|
+
declare function validateConfig(config: unknown, slug: string): RawRuleConfig;
|
|
937
844
|
|
|
938
845
|
//#endregion
|
|
939
846
|
//#region src/client/bundle.d.ts
|
|
@@ -947,12 +854,12 @@ declare function toUtf8String(payload: ArrayBuffer | ArrayBufferView): string;
|
|
|
947
854
|
/**
|
|
948
855
|
* Fetches a bundle from an absolute URL.
|
|
949
856
|
*/
|
|
950
|
-
declare function fetchBundle(bundleUrl: string): Promise<
|
|
857
|
+
declare function fetchBundle(bundleUrl: string): Promise<RuleBundle>;
|
|
951
858
|
/**
|
|
952
859
|
* Resolves a slug to get all versions and platform variants.
|
|
953
860
|
*
|
|
954
861
|
* @param baseUrl - Registry base URL
|
|
955
|
-
* @param slug - Content slug (may contain slashes, e.g., "username/my-
|
|
862
|
+
* @param slug - Content slug (may contain slashes, e.g., "username/my-rule")
|
|
956
863
|
* @param version - Optional version filter (server may ignore for static registries)
|
|
957
864
|
* @returns Resolved data, or null if not found
|
|
958
865
|
* @throws Error on network/server errors
|
|
@@ -962,29 +869,29 @@ declare function resolveSlug(baseUrl: string, slug: string, version?: string): P
|
|
|
962
869
|
//#endregion
|
|
963
870
|
//#region src/constants.d.ts
|
|
964
871
|
/**
|
|
965
|
-
* Shared constants for agentrules
|
|
872
|
+
* Shared constants for agentrules.
|
|
966
873
|
*/
|
|
967
|
-
/** Filename for
|
|
968
|
-
declare const
|
|
969
|
-
/**
|
|
970
|
-
declare const
|
|
971
|
-
/**
|
|
972
|
-
declare const PRESET_SCHEMA_URL = "https://agentrules.directory/schema/agentrules.json";
|
|
973
|
-
/** Default version identifier for latest preset version */
|
|
874
|
+
/** Filename for rule configuration */
|
|
875
|
+
declare const RULE_CONFIG_FILENAME = "agentrules.json";
|
|
876
|
+
/** JSON Schema URL for rule configuration */
|
|
877
|
+
declare const RULE_SCHEMA_URL = "https://agentrules.directory/schema/agentrules.json";
|
|
878
|
+
/** Default version identifier for latest rule version */
|
|
974
879
|
declare const LATEST_VERSION = "latest";
|
|
975
880
|
/**
|
|
976
881
|
* API endpoint paths (relative to registry base URL).
|
|
977
882
|
*
|
|
978
883
|
* Note on slug handling:
|
|
979
|
-
* - Slugs may contain slashes (e.g., "username/my-
|
|
884
|
+
* - Slugs may contain slashes (e.g., "username/my-rule") which flow through as path segments
|
|
980
885
|
* - The client is responsible for validating values before making requests
|
|
981
886
|
*/
|
|
982
887
|
declare const API_ENDPOINTS: {
|
|
983
|
-
/**
|
|
984
|
-
readonly
|
|
985
|
-
/** Base path for
|
|
986
|
-
readonly base: "api/
|
|
987
|
-
/**
|
|
888
|
+
/** Rule endpoints (for publishing) */
|
|
889
|
+
readonly rules: {
|
|
890
|
+
/** Base path for rule operations (POST to publish) */
|
|
891
|
+
readonly base: "api/rules";
|
|
892
|
+
/** Get rule by slug (GET) */
|
|
893
|
+
readonly get: (slug: string) => string;
|
|
894
|
+
/** Unpublish rule version (DELETE) */
|
|
988
895
|
readonly unpublish: (slug: string, version: string) => string;
|
|
989
896
|
};
|
|
990
897
|
/** Auth endpoints */
|
|
@@ -996,121 +903,41 @@ declare const API_ENDPOINTS: {
|
|
|
996
903
|
/** Device token exchange */
|
|
997
904
|
readonly deviceToken: "api/auth/device/token";
|
|
998
905
|
};
|
|
999
|
-
/** Rule endpoints (for publishing) */
|
|
1000
|
-
readonly rules: {
|
|
1001
|
-
/** Base path for rule operations (POST to create) */
|
|
1002
|
-
readonly base: "api/rules";
|
|
1003
|
-
/** Rule by slug (PUT to update, DELETE to remove) */
|
|
1004
|
-
readonly bySlug: (slug: string) => string;
|
|
1005
|
-
};
|
|
1006
|
-
/** Items endpoint - unified content retrieval */
|
|
1007
|
-
readonly items: {
|
|
1008
|
-
/**
|
|
1009
|
-
* Get all versions and variants for a slug.
|
|
1010
|
-
* Version filtering via query param is optional (server may ignore for static registries).
|
|
1011
|
-
* @param slug - Content slug (may contain slashes, e.g., "username/my-preset")
|
|
1012
|
-
*/
|
|
1013
|
-
readonly get: (slug: string) => string;
|
|
1014
|
-
};
|
|
1015
906
|
};
|
|
1016
907
|
|
|
1017
908
|
//#endregion
|
|
1018
|
-
//#region src/
|
|
909
|
+
//#region src/schemas/common.d.ts
|
|
1019
910
|
/**
|
|
1020
|
-
*
|
|
1021
|
-
*
|
|
1022
|
-
* -
|
|
1023
|
-
* -
|
|
1024
|
-
* - description: max 500 chars (optional for rules)
|
|
1025
|
-
* - tags: max 35 chars each, 1-10 required, platform names blocked
|
|
911
|
+
* Schema for a single tag.
|
|
912
|
+
* - Max 35 characters
|
|
913
|
+
* - Lowercase alphanumeric with hyphens
|
|
914
|
+
* - Platform names blocked (redundant with platform field)
|
|
1026
915
|
*/
|
|
1027
|
-
declare const
|
|
1028
|
-
declare const ruleTitleSchema: z.ZodString;
|
|
1029
|
-
declare const ruleDescriptionSchema: z.ZodString;
|
|
1030
|
-
declare const ruleTagSchema: z.ZodString;
|
|
1031
|
-
declare const ruleTagsSchema: z.ZodArray<z.ZodString>;
|
|
1032
|
-
declare const rulePlatformSchema: z.ZodEnum<{
|
|
1033
|
-
opencode: "opencode";
|
|
1034
|
-
codex: "codex";
|
|
1035
|
-
claude: "claude";
|
|
1036
|
-
cursor: "cursor";
|
|
1037
|
-
}>;
|
|
1038
|
-
declare const ruleTypeSchema: z.ZodString;
|
|
1039
|
-
declare const ruleContentSchema: z.ZodString;
|
|
916
|
+
declare const tagSchema: z.ZodString;
|
|
1040
917
|
/**
|
|
1041
|
-
*
|
|
1042
|
-
*
|
|
918
|
+
* Schema for tags array.
|
|
919
|
+
* - 0-10 tags allowed
|
|
1043
920
|
*/
|
|
1044
|
-
declare const
|
|
1045
|
-
|
|
1046
|
-
|
|
1047
|
-
|
|
1048
|
-
|
|
1049
|
-
|
|
1050
|
-
|
|
1051
|
-
|
|
1052
|
-
|
|
1053
|
-
|
|
1054
|
-
|
|
1055
|
-
|
|
1056
|
-
|
|
1057
|
-
|
|
1058
|
-
|
|
1059
|
-
|
|
1060
|
-
|
|
1061
|
-
type: z.ZodEnum<{
|
|
1062
|
-
instruction: "instruction";
|
|
1063
|
-
command: "command";
|
|
1064
|
-
rule: "rule";
|
|
1065
|
-
}>;
|
|
1066
|
-
}, z.core.$strip>, z.ZodObject<{
|
|
1067
|
-
platform: z.ZodLiteral<"codex">;
|
|
1068
|
-
type: z.ZodEnum<{
|
|
1069
|
-
instruction: "instruction";
|
|
1070
|
-
command: "command";
|
|
1071
|
-
}>;
|
|
1072
|
-
}, z.core.$strip>], "platform">;
|
|
1073
|
-
/** Schema for rule creation with discriminated union for platform+type */
|
|
1074
|
-
declare const ruleCreateInputSchema: z.ZodIntersection<z.ZodObject<{
|
|
1075
|
-
name: z.ZodString;
|
|
1076
|
-
title: z.ZodString;
|
|
1077
|
-
description: z.ZodOptional<z.ZodString>;
|
|
1078
|
-
content: z.ZodString;
|
|
1079
|
-
tags: z.ZodArray<z.ZodString>;
|
|
1080
|
-
}, z.core.$strip>, z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
1081
|
-
platform: z.ZodLiteral<"opencode">;
|
|
1082
|
-
type: z.ZodEnum<{
|
|
1083
|
-
instruction: "instruction";
|
|
1084
|
-
agent: "agent";
|
|
1085
|
-
command: "command";
|
|
1086
|
-
tool: "tool";
|
|
1087
|
-
}>;
|
|
1088
|
-
}, z.core.$strip>, z.ZodObject<{
|
|
1089
|
-
platform: z.ZodLiteral<"claude">;
|
|
1090
|
-
type: z.ZodEnum<{
|
|
1091
|
-
instruction: "instruction";
|
|
1092
|
-
command: "command";
|
|
1093
|
-
skill: "skill";
|
|
1094
|
-
}>;
|
|
1095
|
-
}, z.core.$strip>, z.ZodObject<{
|
|
1096
|
-
platform: z.ZodLiteral<"cursor">;
|
|
1097
|
-
type: z.ZodEnum<{
|
|
1098
|
-
instruction: "instruction";
|
|
1099
|
-
command: "command";
|
|
1100
|
-
rule: "rule";
|
|
1101
|
-
}>;
|
|
1102
|
-
}, z.core.$strip>, z.ZodObject<{
|
|
1103
|
-
platform: z.ZodLiteral<"codex">;
|
|
1104
|
-
type: z.ZodEnum<{
|
|
1105
|
-
instruction: "instruction";
|
|
1106
|
-
command: "command";
|
|
1107
|
-
}>;
|
|
1108
|
-
}, z.core.$strip>], "platform">>;
|
|
1109
|
-
type RuleCreateInput = z.infer<typeof ruleCreateInputSchema>;
|
|
921
|
+
declare const tagsSchema: z.ZodArray<z.ZodString>;
|
|
922
|
+
/**
|
|
923
|
+
* Schema for rule name.
|
|
924
|
+
* - Max 64 characters
|
|
925
|
+
* - Lowercase alphanumeric with hyphens
|
|
926
|
+
*/
|
|
927
|
+
declare const nameSchema: z.ZodString;
|
|
928
|
+
/**
|
|
929
|
+
* Schema for display title.
|
|
930
|
+
* - Max 80 characters
|
|
931
|
+
*/
|
|
932
|
+
declare const titleSchema: z.ZodString;
|
|
933
|
+
/**
|
|
934
|
+
* Schema for description.
|
|
935
|
+
* - Max 500 characters
|
|
936
|
+
*/
|
|
937
|
+
declare const descriptionSchema: z.ZodString;
|
|
1110
938
|
|
|
1111
939
|
//#endregion
|
|
1112
940
|
//#region src/utils/diff.d.ts
|
|
1113
|
-
/** Re-export platform-rule types for convenience */
|
|
1114
941
|
type DiffPreviewOptions = {
|
|
1115
942
|
context?: number;
|
|
1116
943
|
maxLines?: number;
|
|
@@ -1133,4 +960,4 @@ declare function toUint8Array(payload: ArrayBuffer | ArrayBufferView): Uint8Arra
|
|
|
1133
960
|
declare function normalizeBundlePath(value: string): string;
|
|
1134
961
|
|
|
1135
962
|
//#endregion
|
|
1136
|
-
export {
|
|
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 };
|