@agentrules/core 0.1.0 → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +80 -54
- package/dist/index.d.ts +600 -786
- package/dist/index.js +302 -313
- 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,381 @@ 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
|
+
* Platform-specific type tuples for zod schema validation.
|
|
321
|
+
* Must be kept in sync with PLATFORMS types above.
|
|
322
|
+
*/
|
|
323
|
+
declare const PLATFORM_RULE_TYPES: {
|
|
324
|
+
readonly opencode: readonly ["instruction", "agent", "command", "tool"];
|
|
325
|
+
readonly claude: readonly ["instruction", "rule", "command", "skill"];
|
|
326
|
+
readonly cursor: readonly ["instruction", "rule", "command"];
|
|
327
|
+
readonly codex: readonly ["instruction", "command"];
|
|
328
|
+
};
|
|
385
329
|
|
|
386
330
|
//#endregion
|
|
387
331
|
//#region src/platform/utils.d.ts
|
|
388
332
|
declare function isSupportedPlatform(value: string): value is PlatformId;
|
|
389
333
|
declare function normalizePlatformInput(value: string): PlatformId;
|
|
390
334
|
/**
|
|
391
|
-
* Check if a directory name matches a platform's
|
|
392
|
-
* Used to detect if a
|
|
335
|
+
* Check if a directory name matches a platform's platformDir.
|
|
336
|
+
* Used to detect if a rule config is inside a platform directory (in-project mode).
|
|
393
337
|
*/
|
|
394
338
|
declare function isPlatformDir(dirName: string): boolean;
|
|
395
339
|
/**
|
|
396
|
-
* Get the platform ID from a directory name, if it matches a platform's
|
|
340
|
+
* Get the platform ID from a directory name, if it matches a platform's platformDir.
|
|
397
341
|
*/
|
|
398
342
|
declare function getPlatformFromDir(dirName: string): PlatformId | undefined;
|
|
399
|
-
|
|
400
|
-
//#endregion
|
|
401
|
-
//#region src/preset/types.d.ts
|
|
402
343
|
/**
|
|
403
|
-
*
|
|
344
|
+
* Infer the platform from a file path by searching for platformDir segments.
|
|
404
345
|
*
|
|
405
|
-
*
|
|
406
|
-
* - "opencode" (shorthand, uses default directory)
|
|
407
|
-
* - { platform: "opencode", path: "rules" } (custom path)
|
|
346
|
+
* Example: "/repo/.claude/commands/foo.md" -> "claude"
|
|
408
347
|
*/
|
|
409
|
-
|
|
410
|
-
platform: PlatformId;
|
|
411
|
-
path?: string;
|
|
412
|
-
};
|
|
348
|
+
declare function inferPlatformFromPath(value: string): PlatformId | undefined;
|
|
413
349
|
/**
|
|
414
|
-
*
|
|
350
|
+
* Return all platforms whose instruction file matches this basename.
|
|
351
|
+
*
|
|
352
|
+
* Example: "CLAUDE.md" -> ["claude"], "AGENTS.md" -> ["opencode", "cursor", "codex"]
|
|
415
353
|
*/
|
|
416
|
-
|
|
417
|
-
platform: PlatformId;
|
|
418
|
-
path?: string;
|
|
419
|
-
};
|
|
354
|
+
declare function inferInstructionPlatformsFromFileName(fileName: string): PlatformId[];
|
|
420
355
|
/**
|
|
421
|
-
*
|
|
356
|
+
* Infer a rule type from a file path for a known platform.
|
|
357
|
+
* Uses PLATFORMS templates as source-of-truth.
|
|
422
358
|
*/
|
|
423
|
-
declare function
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
359
|
+
declare function inferTypeFromPath(platform: PlatformId, filePath: string): string | undefined;
|
|
360
|
+
|
|
361
|
+
//#endregion
|
|
362
|
+
//#region src/resolve/types.d.ts
|
|
363
|
+
/** Base fields for all variants */
|
|
364
|
+
type BaseVariant = {
|
|
365
|
+
platform: PlatformId;
|
|
366
|
+
};
|
|
367
|
+
/** Rule variant with bundle URL (for larger rules) */
|
|
368
|
+
type RuleVariantBundle = BaseVariant & {
|
|
369
|
+
bundleUrl: string;
|
|
370
|
+
fileCount: number;
|
|
371
|
+
totalSize: number;
|
|
372
|
+
};
|
|
373
|
+
/** Rule variant with inline content (for smaller rules) */
|
|
374
|
+
type RuleVariantInline = BaseVariant & {
|
|
375
|
+
content: string;
|
|
376
|
+
fileCount: number;
|
|
377
|
+
totalSize: number;
|
|
378
|
+
};
|
|
379
|
+
/** Rule variant - registry decides bundleUrl vs inline content */
|
|
380
|
+
type RuleVariant = RuleVariantBundle | RuleVariantInline;
|
|
381
|
+
type RuleVersion = {
|
|
382
|
+
version: string;
|
|
383
|
+
isLatest: boolean;
|
|
384
|
+
publishedAt?: string;
|
|
385
|
+
variants: RuleVariant[];
|
|
386
|
+
};
|
|
387
|
+
type ResolvedRule = {
|
|
388
|
+
slug: string;
|
|
437
389
|
name: string;
|
|
390
|
+
/** Rule type - optional, defaults to freeform file structure */
|
|
391
|
+
type?: RuleType;
|
|
438
392
|
title: string;
|
|
439
|
-
version?: number;
|
|
440
393
|
description: string;
|
|
441
|
-
tags
|
|
442
|
-
features?: string[];
|
|
394
|
+
tags: string[];
|
|
443
395
|
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[];
|
|
396
|
+
features: string[];
|
|
397
|
+
versions: RuleVersion[];
|
|
457
398
|
};
|
|
399
|
+
/** Response from items endpoint */
|
|
400
|
+
type ResolveResponse = ResolvedRule;
|
|
401
|
+
|
|
402
|
+
//#endregion
|
|
403
|
+
//#region src/resolve/utils.d.ts
|
|
458
404
|
/**
|
|
459
|
-
*
|
|
460
|
-
* Always has platforms as PlatformConfig[] (object form).
|
|
405
|
+
* Type guard for rule variant with bundleUrl
|
|
461
406
|
*/
|
|
462
|
-
|
|
463
|
-
|
|
407
|
+
declare function hasBundle(variant: RuleVariant): variant is RuleVariant & {
|
|
408
|
+
bundleUrl: string;
|
|
464
409
|
};
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
checksum: string;
|
|
410
|
+
/**
|
|
411
|
+
* Type guard for rule variant with inline content
|
|
412
|
+
*/
|
|
413
|
+
declare function hasInlineContent(variant: RuleVariant): variant is RuleVariant & {
|
|
470
414
|
content: string;
|
|
471
415
|
};
|
|
472
416
|
/**
|
|
473
|
-
*
|
|
474
|
-
* Contains files and optional metadata for a single platform.
|
|
417
|
+
* Get the latest version from a resolved rule
|
|
475
418
|
*/
|
|
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
|
-
};
|
|
419
|
+
declare function getLatestVersion(item: ResolvedRule): RuleVersion | undefined;
|
|
486
420
|
/**
|
|
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"
|
|
421
|
+
* Get a specific version from a resolved rule
|
|
494
422
|
*/
|
|
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
|
-
};
|
|
423
|
+
declare function getVersion(item: ResolvedRule, version: string): RuleVersion | undefined;
|
|
507
424
|
/**
|
|
508
|
-
*
|
|
509
|
-
* This is stored in R2 and fetched via bundleUrl.
|
|
510
|
-
*
|
|
511
|
-
* Note: This is per-platform, while PresetPublishInput is multi-platform.
|
|
425
|
+
* Get a specific platform variant from a rule version
|
|
512
426
|
*/
|
|
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
|
-
};
|
|
427
|
+
declare function getVariant(version: RuleVersion, platform: PlatformId): RuleVariant | undefined;
|
|
534
428
|
/**
|
|
535
|
-
*
|
|
429
|
+
* Get all available platforms for a rule version
|
|
536
430
|
*/
|
|
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
|
-
};
|
|
431
|
+
declare function getPlatforms(version: RuleVersion): PlatformId[];
|
|
547
432
|
/**
|
|
548
|
-
*
|
|
549
|
-
* Always uses platformFiles array (works for single or multi-platform).
|
|
433
|
+
* Check if a platform is available in any version of a rule
|
|
550
434
|
*/
|
|
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
|
-
};
|
|
435
|
+
declare function hasPlatform(item: ResolvedRule, platform: PlatformId): boolean;
|
|
563
436
|
|
|
564
437
|
//#endregion
|
|
565
|
-
//#region src/
|
|
566
|
-
declare const
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
438
|
+
//#region src/rule/schema.d.ts
|
|
439
|
+
declare const platformIdSchema: z.ZodEnum<{
|
|
440
|
+
opencode: "opencode";
|
|
441
|
+
codex: "codex";
|
|
442
|
+
claude: "claude";
|
|
443
|
+
cursor: "cursor";
|
|
444
|
+
}>;
|
|
445
|
+
declare const COMMON_LICENSES: readonly ["MIT", "Apache-2.0", "GPL-3.0-only", "BSD-3-Clause", "ISC", "Unlicense"];
|
|
446
|
+
type CommonLicense = (typeof COMMON_LICENSES)[number];
|
|
447
|
+
declare const licenseSchema: z.ZodString;
|
|
448
|
+
/**
|
|
449
|
+
* Schema for rule type.
|
|
450
|
+
* Valid types: instruction, rule, command, skill, agent, tool, multi.
|
|
451
|
+
* Optional - defaults to "multi" (freeform file structure).
|
|
452
|
+
* Platform-specific validation happens at publish time.
|
|
453
|
+
*/
|
|
454
|
+
declare const ruleTypeSchema: z.ZodEnum<{
|
|
455
|
+
instruction: "instruction";
|
|
456
|
+
rule: "rule";
|
|
457
|
+
command: "command";
|
|
458
|
+
skill: "skill";
|
|
459
|
+
agent: "agent";
|
|
460
|
+
tool: "tool";
|
|
461
|
+
}>;
|
|
462
|
+
/**
|
|
463
|
+
* Rule config schema.
|
|
464
|
+
*
|
|
465
|
+
* Uses a unified `platforms` array that accepts either:
|
|
466
|
+
* - Platform ID strings: `["opencode", "claude"]`
|
|
467
|
+
* - Objects with optional path: `[{ platform: "opencode", path: "rules" }]`
|
|
468
|
+
* - Mixed: `["opencode", { platform: "claude", path: "my-claude" }]`
|
|
469
|
+
*/
|
|
470
|
+
declare const ruleConfigSchema: z.ZodObject<{
|
|
471
|
+
$schema: z.ZodOptional<z.ZodString>;
|
|
472
|
+
name: z.ZodString;
|
|
473
|
+
type: z.ZodOptional<z.ZodEnum<{
|
|
474
|
+
instruction: "instruction";
|
|
475
|
+
rule: "rule";
|
|
476
|
+
command: "command";
|
|
477
|
+
skill: "skill";
|
|
478
|
+
agent: "agent";
|
|
479
|
+
tool: "tool";
|
|
480
|
+
}>>;
|
|
481
|
+
title: z.ZodString;
|
|
482
|
+
version: z.ZodOptional<z.ZodNumber>;
|
|
483
|
+
description: z.ZodDefault<z.ZodOptional<z.ZodString>>;
|
|
484
|
+
tags: z.ZodDefault<z.ZodOptional<z.ZodArray<z.ZodString>>>;
|
|
485
|
+
features: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
486
|
+
license: z.ZodString;
|
|
487
|
+
ignore: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
488
|
+
platforms: z.ZodArray<z.ZodUnion<readonly [z.ZodEnum<{
|
|
578
489
|
opencode: "opencode";
|
|
579
490
|
codex: "codex";
|
|
580
491
|
claude: "claude";
|
|
581
492
|
cursor: "cursor";
|
|
582
|
-
}
|
|
493
|
+
}>, z.ZodObject<{
|
|
494
|
+
platform: z.ZodEnum<{
|
|
495
|
+
opencode: "opencode";
|
|
496
|
+
codex: "codex";
|
|
497
|
+
claude: "claude";
|
|
498
|
+
cursor: "cursor";
|
|
499
|
+
}>;
|
|
500
|
+
path: z.ZodOptional<z.ZodString>;
|
|
501
|
+
}, z.core.$strict>]>>;
|
|
502
|
+
}, z.core.$strict>;
|
|
503
|
+
declare const bundledFileSchema: z.ZodObject<{
|
|
504
|
+
path: z.ZodString;
|
|
505
|
+
size: z.ZodNumber;
|
|
506
|
+
checksum: z.ZodString;
|
|
583
507
|
content: z.ZodString;
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
508
|
+
}, z.core.$strip>;
|
|
509
|
+
/**
|
|
510
|
+
* Schema for per-platform variant in publish input.
|
|
511
|
+
*/
|
|
512
|
+
declare const publishVariantInputSchema: z.ZodObject<{
|
|
588
513
|
platform: z.ZodEnum<{
|
|
589
514
|
opencode: "opencode";
|
|
590
515
|
codex: "codex";
|
|
591
516
|
claude: "claude";
|
|
592
517
|
cursor: "cursor";
|
|
593
518
|
}>;
|
|
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
|
-
}>;
|
|
519
|
+
files: z.ZodArray<z.ZodObject<{
|
|
520
|
+
path: z.ZodString;
|
|
521
|
+
size: z.ZodNumber;
|
|
522
|
+
checksum: z.ZodString;
|
|
618
523
|
content: z.ZodString;
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
|
|
524
|
+
}, z.core.$strip>>;
|
|
525
|
+
readmeContent: z.ZodOptional<z.ZodString>;
|
|
526
|
+
licenseContent: z.ZodOptional<z.ZodString>;
|
|
527
|
+
installMessage: z.ZodOptional<z.ZodString>;
|
|
622
528
|
}, z.core.$strip>;
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
|
|
529
|
+
/**
|
|
530
|
+
* Schema for what clients send to publish a rule.
|
|
531
|
+
*
|
|
532
|
+
* One publish call creates ONE version with ALL platform variants.
|
|
533
|
+
* Version is optional major version. Registry assigns full MAJOR.MINOR.
|
|
534
|
+
*
|
|
535
|
+
* Note: Clients send `name` (e.g., "my-rule"), and the registry defines the format of the slug.
|
|
536
|
+
* For example, a namespaced slug could be returned as "username/my-rule"
|
|
537
|
+
*/
|
|
538
|
+
declare const rulePublishInputSchema: z.ZodObject<{
|
|
539
|
+
name: z.ZodString;
|
|
540
|
+
type: z.ZodOptional<z.ZodEnum<{
|
|
541
|
+
instruction: "instruction";
|
|
542
|
+
rule: "rule";
|
|
543
|
+
command: "command";
|
|
544
|
+
skill: "skill";
|
|
545
|
+
agent: "agent";
|
|
546
|
+
tool: "tool";
|
|
547
|
+
}>>;
|
|
548
|
+
title: z.ZodString;
|
|
549
|
+
description: z.ZodDefault<z.ZodOptional<z.ZodString>>;
|
|
550
|
+
tags: z.ZodDefault<z.ZodOptional<z.ZodArray<z.ZodString>>>;
|
|
551
|
+
license: z.ZodString;
|
|
552
|
+
features: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
627
553
|
variants: z.ZodArray<z.ZodObject<{
|
|
628
554
|
platform: z.ZodEnum<{
|
|
629
555
|
opencode: "opencode";
|
|
@@ -631,250 +557,218 @@ declare const ruleVersionSchema: z.ZodObject<{
|
|
|
631
557
|
claude: "claude";
|
|
632
558
|
cursor: "cursor";
|
|
633
559
|
}>;
|
|
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;
|
|
560
|
+
files: z.ZodArray<z.ZodObject<{
|
|
561
|
+
path: z.ZodString;
|
|
562
|
+
size: z.ZodNumber;
|
|
563
|
+
checksum: z.ZodString;
|
|
693
564
|
content: z.ZodString;
|
|
694
565
|
}, z.core.$strip>>;
|
|
566
|
+
readmeContent: z.ZodOptional<z.ZodString>;
|
|
567
|
+
licenseContent: z.ZodOptional<z.ZodString>;
|
|
568
|
+
installMessage: z.ZodOptional<z.ZodString>;
|
|
695
569
|
}, z.core.$strip>>;
|
|
570
|
+
version: z.ZodOptional<z.ZodNumber>;
|
|
696
571
|
}, 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;
|
|
572
|
+
/**
|
|
573
|
+
* Schema for what registries store and return for a single platform bundle.
|
|
574
|
+
* This is per-platform (flat structure), stored in R2 and fetched via bundleUrl.
|
|
575
|
+
*/
|
|
576
|
+
declare const ruleBundleSchema: z.ZodObject<{
|
|
735
577
|
name: z.ZodString;
|
|
736
|
-
|
|
737
|
-
|
|
738
|
-
|
|
739
|
-
|
|
740
|
-
|
|
741
|
-
|
|
742
|
-
|
|
743
|
-
|
|
744
|
-
|
|
745
|
-
|
|
746
|
-
|
|
747
|
-
|
|
748
|
-
|
|
749
|
-
|
|
750
|
-
|
|
751
|
-
|
|
752
|
-
|
|
578
|
+
type: z.ZodOptional<z.ZodEnum<{
|
|
579
|
+
instruction: "instruction";
|
|
580
|
+
rule: "rule";
|
|
581
|
+
command: "command";
|
|
582
|
+
skill: "skill";
|
|
583
|
+
agent: "agent";
|
|
584
|
+
tool: "tool";
|
|
585
|
+
}>>;
|
|
586
|
+
platform: z.ZodEnum<{
|
|
587
|
+
opencode: "opencode";
|
|
588
|
+
codex: "codex";
|
|
589
|
+
claude: "claude";
|
|
590
|
+
cursor: "cursor";
|
|
591
|
+
}>;
|
|
592
|
+
title: z.ZodString;
|
|
593
|
+
description: z.ZodDefault<z.ZodOptional<z.ZodString>>;
|
|
594
|
+
tags: z.ZodDefault<z.ZodOptional<z.ZodArray<z.ZodString>>>;
|
|
595
|
+
license: z.ZodString;
|
|
596
|
+
features: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
597
|
+
files: z.ZodArray<z.ZodObject<{
|
|
598
|
+
path: z.ZodString;
|
|
599
|
+
size: z.ZodNumber;
|
|
600
|
+
checksum: z.ZodString;
|
|
601
|
+
content: z.ZodString;
|
|
753
602
|
}, z.core.$strip>>;
|
|
754
|
-
|
|
603
|
+
readmeContent: z.ZodOptional<z.ZodString>;
|
|
604
|
+
licenseContent: z.ZodOptional<z.ZodString>;
|
|
605
|
+
installMessage: z.ZodOptional<z.ZodString>;
|
|
606
|
+
slug: z.ZodString;
|
|
607
|
+
version: z.ZodString;
|
|
608
|
+
}, z.core.$strip>;
|
|
755
609
|
|
|
756
610
|
//#endregion
|
|
757
|
-
//#region src/
|
|
758
|
-
/**
|
|
759
|
-
type
|
|
611
|
+
//#region src/rule/types.d.ts
|
|
612
|
+
/** Normalized platform entry - always object form */
|
|
613
|
+
type PlatformEntry = {
|
|
760
614
|
platform: PlatformId;
|
|
615
|
+
path?: string;
|
|
761
616
|
};
|
|
762
|
-
/**
|
|
763
|
-
type
|
|
764
|
-
|
|
765
|
-
|
|
766
|
-
|
|
617
|
+
/** Raw platform entry - string shorthand or object with optional path */
|
|
618
|
+
type RawPlatformEntry = PlatformId | PlatformEntry;
|
|
619
|
+
/** Normalize a raw platform entry to the object form */
|
|
620
|
+
declare function normalizePlatformEntry(entry: RawPlatformEntry): PlatformEntry;
|
|
621
|
+
/**
|
|
622
|
+
* Raw rule configuration - what users write in agentrules.json.
|
|
623
|
+
*
|
|
624
|
+
* Uses a unified `platforms` array that accepts either:
|
|
625
|
+
* - Platform ID strings: `["opencode", "claude"]`
|
|
626
|
+
* - Objects with optional path: `[{ platform: "opencode", path: "rules" }]`
|
|
627
|
+
* - Mixed: `["opencode", { platform: "claude", path: "my-claude" }]`
|
|
628
|
+
*
|
|
629
|
+
* **Order matters**: The first platform in the array is used as the default
|
|
630
|
+
* when viewing the rule on the registry without specifying a platform.
|
|
631
|
+
*/
|
|
632
|
+
type RawRuleConfig = {
|
|
633
|
+
$schema?: string;
|
|
634
|
+
name: string;
|
|
635
|
+
/**
|
|
636
|
+
* Rule type - determines install path and constrains valid platforms.
|
|
637
|
+
* Optional - defaults to "multi" (freeform file structure).
|
|
638
|
+
*/
|
|
639
|
+
type?: RuleType;
|
|
640
|
+
title: string;
|
|
641
|
+
version?: number;
|
|
642
|
+
description: string;
|
|
643
|
+
tags?: string[];
|
|
644
|
+
features?: string[];
|
|
645
|
+
license: string;
|
|
646
|
+
/** Additional patterns to exclude from bundle (glob patterns) */
|
|
647
|
+
ignore?: string[];
|
|
648
|
+
/**
|
|
649
|
+
* Target platforms with optional custom paths.
|
|
650
|
+
* Order matters: the first platform is used as the default when viewing
|
|
651
|
+
* the rule on the registry.
|
|
652
|
+
*/
|
|
653
|
+
platforms: RawPlatformEntry[];
|
|
767
654
|
};
|
|
768
|
-
/**
|
|
769
|
-
|
|
770
|
-
|
|
771
|
-
|
|
772
|
-
|
|
655
|
+
/**
|
|
656
|
+
* Normalized rule configuration - used internally after loading.
|
|
657
|
+
*/
|
|
658
|
+
type RuleConfig = Omit<RawRuleConfig, "platforms"> & {
|
|
659
|
+
platforms: PlatformEntry[];
|
|
773
660
|
};
|
|
774
|
-
|
|
775
|
-
|
|
776
|
-
/**
|
|
777
|
-
|
|
778
|
-
|
|
661
|
+
type BundledFile = {
|
|
662
|
+
path: string;
|
|
663
|
+
/** File size in bytes */
|
|
664
|
+
size: number;
|
|
665
|
+
checksum: string;
|
|
779
666
|
content: string;
|
|
780
667
|
};
|
|
781
|
-
|
|
782
|
-
|
|
783
|
-
|
|
784
|
-
|
|
785
|
-
|
|
786
|
-
|
|
787
|
-
|
|
788
|
-
|
|
789
|
-
|
|
790
|
-
|
|
791
|
-
|
|
668
|
+
/**
|
|
669
|
+
* Per-platform variant input for publishing.
|
|
670
|
+
* Contains files and optional metadata for a single platform.
|
|
671
|
+
*/
|
|
672
|
+
type PublishVariantInput = {
|
|
673
|
+
platform: PlatformId;
|
|
674
|
+
files: BundledFile[];
|
|
675
|
+
/** Optional per-platform README */
|
|
676
|
+
readmeContent?: string;
|
|
677
|
+
/** Optional per-platform LICENSE */
|
|
678
|
+
licenseContent?: string;
|
|
679
|
+
/** Optional per-platform install message */
|
|
680
|
+
installMessage?: string;
|
|
792
681
|
};
|
|
793
|
-
|
|
794
|
-
|
|
795
|
-
|
|
682
|
+
/**
|
|
683
|
+
* What clients send to publish a rule (multi-platform).
|
|
684
|
+
*
|
|
685
|
+
* One publish call creates ONE version with ALL platform variants.
|
|
686
|
+
* Version is optional major version. Registry assigns full MAJOR.MINOR.
|
|
687
|
+
*
|
|
688
|
+
* Note: Clients send `name` (e.g., "my-rule"), and the registry defines the format of the slug.
|
|
689
|
+
* For example, a namespaced slug could be returned as "username/my-rule"
|
|
690
|
+
*/
|
|
691
|
+
type RulePublishInput = {
|
|
796
692
|
name: string;
|
|
693
|
+
/** Rule type - optional, defaults to freeform file structure */
|
|
694
|
+
type?: RuleType;
|
|
797
695
|
title: string;
|
|
798
696
|
description: string;
|
|
799
697
|
tags: string[];
|
|
800
698
|
license: string;
|
|
801
|
-
features
|
|
802
|
-
|
|
699
|
+
features?: string[];
|
|
700
|
+
/** Platform variants - each contains files for that platform */
|
|
701
|
+
variants: PublishVariantInput[];
|
|
702
|
+
/** Major version. Defaults to 1 if not specified. */
|
|
703
|
+
version?: number;
|
|
803
704
|
};
|
|
804
|
-
|
|
805
|
-
|
|
806
|
-
|
|
705
|
+
/**
|
|
706
|
+
* What registries store and return for a single platform bundle.
|
|
707
|
+
* This is stored in R2 and fetched via bundleUrl.
|
|
708
|
+
*
|
|
709
|
+
* Note: This is per-platform, while RulePublishInput is multi-platform.
|
|
710
|
+
*/
|
|
711
|
+
type RuleBundle = {
|
|
807
712
|
name: string;
|
|
713
|
+
/** Rule type - optional, defaults to freeform file structure */
|
|
714
|
+
type?: RuleType;
|
|
715
|
+
platform: PlatformId;
|
|
808
716
|
title: string;
|
|
809
717
|
description: string;
|
|
810
718
|
tags: string[];
|
|
811
|
-
|
|
719
|
+
license: string;
|
|
720
|
+
features?: string[];
|
|
721
|
+
files: BundledFile[];
|
|
722
|
+
readmeContent?: string;
|
|
723
|
+
licenseContent?: string;
|
|
724
|
+
installMessage?: string;
|
|
725
|
+
/** Full namespaced slug (e.g., "username/my-rule") */
|
|
726
|
+
slug: string;
|
|
727
|
+
/** Full version in MAJOR.MINOR format (e.g., "1.3", "2.1") */
|
|
728
|
+
version: string;
|
|
812
729
|
};
|
|
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;
|
|
730
|
+
type RuleFileInput = {
|
|
731
|
+
path: string;
|
|
732
|
+
content: ArrayBuffer | ArrayBufferView | string;
|
|
831
733
|
};
|
|
832
734
|
/**
|
|
833
|
-
*
|
|
735
|
+
* Files for a single platform variant
|
|
834
736
|
*/
|
|
835
|
-
|
|
836
|
-
|
|
737
|
+
type PlatformFiles = {
|
|
738
|
+
platform: PlatformId;
|
|
739
|
+
files: RuleFileInput[];
|
|
740
|
+
/** Optional per-platform install message */
|
|
741
|
+
installMessage?: string;
|
|
742
|
+
/** Optional per-platform README */
|
|
743
|
+
readmeContent?: string;
|
|
744
|
+
/** Optional per-platform LICENSE */
|
|
745
|
+
licenseContent?: string;
|
|
837
746
|
};
|
|
838
747
|
/**
|
|
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
|
|
748
|
+
* Rule input - what the CLI builds after loading files.
|
|
749
|
+
* Always uses platformFiles array (works for single or multi-platform).
|
|
876
750
|
*/
|
|
877
|
-
|
|
751
|
+
type RuleInput = {
|
|
752
|
+
name: string;
|
|
753
|
+
config: RuleConfig;
|
|
754
|
+
/** Files for each platform */
|
|
755
|
+
platformFiles: PlatformFiles[];
|
|
756
|
+
/** Shared install message (fallback for platforms without their own) */
|
|
757
|
+
installMessage?: string;
|
|
758
|
+
/** Shared README (fallback for platforms without their own) */
|
|
759
|
+
readmeContent?: string;
|
|
760
|
+
/** Shared LICENSE (fallback for platforms without their own) */
|
|
761
|
+
licenseContent?: string;
|
|
762
|
+
};
|
|
763
|
+
|
|
764
|
+
//#endregion
|
|
765
|
+
//#region src/rule/validate.d.ts
|
|
766
|
+
type RuleValidationResult = {
|
|
767
|
+
valid: boolean;
|
|
768
|
+
errors: string[];
|
|
769
|
+
warnings: string[];
|
|
770
|
+
};
|
|
771
|
+
declare function validateRule(config: RuleConfig): RuleValidationResult;
|
|
878
772
|
|
|
879
773
|
//#endregion
|
|
880
774
|
//#region src/builder/registry.d.ts
|
|
@@ -884,26 +778,26 @@ declare function ruleHasPlatform(item: ResolvedRule, platform: PlatformId): bool
|
|
|
884
778
|
*/
|
|
885
779
|
declare const STATIC_BUNDLE_DIR = "registry";
|
|
886
780
|
/**
|
|
887
|
-
* Options for building a
|
|
781
|
+
* Options for building a publish input.
|
|
888
782
|
*/
|
|
889
|
-
type
|
|
890
|
-
/**
|
|
891
|
-
|
|
783
|
+
type BuildPublishInputOptions = {
|
|
784
|
+
/** Rule input (single or multi-platform) */
|
|
785
|
+
rule: RuleInput;
|
|
892
786
|
/** Major version. Defaults to 1 if not specified. */
|
|
893
787
|
version?: number;
|
|
894
788
|
};
|
|
895
789
|
/**
|
|
896
|
-
* Builds a
|
|
790
|
+
* Builds a RulePublishInput from rule input.
|
|
897
791
|
*
|
|
898
|
-
*
|
|
792
|
+
* RuleInput always has platformFiles array (unified format).
|
|
899
793
|
*/
|
|
900
|
-
declare function
|
|
794
|
+
declare function buildPublishInput(options: BuildPublishInputOptions): Promise<RulePublishInput>;
|
|
901
795
|
/**
|
|
902
796
|
* Options for building a static registry.
|
|
903
797
|
*/
|
|
904
|
-
type
|
|
905
|
-
/**
|
|
906
|
-
|
|
798
|
+
type BuildRegistryOptions = {
|
|
799
|
+
/** Rules to include (single or multi-platform) */
|
|
800
|
+
rules: RuleInput[];
|
|
907
801
|
/**
|
|
908
802
|
* Optional base path or URL prefix for bundle locations.
|
|
909
803
|
* Format: {bundleBase}/{STATIC_BUNDLE_DIR}/{slug}/{platform}/{version}
|
|
@@ -911,29 +805,29 @@ type BuildPresetRegistryOptions = {
|
|
|
911
805
|
*/
|
|
912
806
|
bundleBase?: string;
|
|
913
807
|
};
|
|
914
|
-
type
|
|
915
|
-
/** Resolved
|
|
916
|
-
|
|
808
|
+
type BuildRegistryResult = {
|
|
809
|
+
/** Resolved rules in the unified format (one per slug with all versions/variants) */
|
|
810
|
+
rules: ResolvedRule[];
|
|
917
811
|
/** Bundles for each platform variant (used to write individual bundle files) */
|
|
918
|
-
bundles:
|
|
812
|
+
bundles: RuleBundle[];
|
|
919
813
|
};
|
|
920
814
|
/**
|
|
921
815
|
* Builds a static registry with items and bundles.
|
|
922
816
|
*
|
|
923
817
|
* Uses the same model as dynamic publishing:
|
|
924
|
-
* - Each
|
|
818
|
+
* - Each RuleInput (single or multi-platform) becomes one item
|
|
925
819
|
* - Each platform variant becomes one bundle
|
|
926
820
|
*/
|
|
927
|
-
declare function
|
|
821
|
+
declare function buildRegistry(options: BuildRegistryOptions): Promise<BuildRegistryResult>;
|
|
928
822
|
|
|
929
823
|
//#endregion
|
|
930
824
|
//#region src/builder/utils.d.ts
|
|
931
825
|
declare function cleanInstallMessage(value: unknown): string | undefined;
|
|
932
826
|
/**
|
|
933
|
-
* Validate raw
|
|
827
|
+
* Validate raw rule config from JSON.
|
|
934
828
|
* Returns the raw config shape (before normalization).
|
|
935
829
|
*/
|
|
936
|
-
declare function
|
|
830
|
+
declare function validateConfig(config: unknown, slug: string): RawRuleConfig;
|
|
937
831
|
|
|
938
832
|
//#endregion
|
|
939
833
|
//#region src/client/bundle.d.ts
|
|
@@ -947,12 +841,12 @@ declare function toUtf8String(payload: ArrayBuffer | ArrayBufferView): string;
|
|
|
947
841
|
/**
|
|
948
842
|
* Fetches a bundle from an absolute URL.
|
|
949
843
|
*/
|
|
950
|
-
declare function fetchBundle(bundleUrl: string): Promise<
|
|
844
|
+
declare function fetchBundle(bundleUrl: string): Promise<RuleBundle>;
|
|
951
845
|
/**
|
|
952
846
|
* Resolves a slug to get all versions and platform variants.
|
|
953
847
|
*
|
|
954
848
|
* @param baseUrl - Registry base URL
|
|
955
|
-
* @param slug - Content slug (may contain slashes, e.g., "username/my-
|
|
849
|
+
* @param slug - Content slug (may contain slashes, e.g., "username/my-rule")
|
|
956
850
|
* @param version - Optional version filter (server may ignore for static registries)
|
|
957
851
|
* @returns Resolved data, or null if not found
|
|
958
852
|
* @throws Error on network/server errors
|
|
@@ -962,29 +856,29 @@ declare function resolveSlug(baseUrl: string, slug: string, version?: string): P
|
|
|
962
856
|
//#endregion
|
|
963
857
|
//#region src/constants.d.ts
|
|
964
858
|
/**
|
|
965
|
-
* Shared constants for agentrules
|
|
859
|
+
* Shared constants for agentrules.
|
|
966
860
|
*/
|
|
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 */
|
|
861
|
+
/** Filename for rule configuration */
|
|
862
|
+
declare const RULE_CONFIG_FILENAME = "agentrules.json";
|
|
863
|
+
/** JSON Schema URL for rule configuration */
|
|
864
|
+
declare const RULE_SCHEMA_URL = "https://agentrules.directory/schema/agentrules.json";
|
|
865
|
+
/** Default version identifier for latest rule version */
|
|
974
866
|
declare const LATEST_VERSION = "latest";
|
|
975
867
|
/**
|
|
976
868
|
* API endpoint paths (relative to registry base URL).
|
|
977
869
|
*
|
|
978
870
|
* Note on slug handling:
|
|
979
|
-
* - Slugs may contain slashes (e.g., "username/my-
|
|
871
|
+
* - Slugs may contain slashes (e.g., "username/my-rule") which flow through as path segments
|
|
980
872
|
* - The client is responsible for validating values before making requests
|
|
981
873
|
*/
|
|
982
874
|
declare const API_ENDPOINTS: {
|
|
983
|
-
/**
|
|
984
|
-
readonly
|
|
985
|
-
/** Base path for
|
|
986
|
-
readonly base: "api/
|
|
987
|
-
/**
|
|
875
|
+
/** Rule endpoints (for publishing) */
|
|
876
|
+
readonly rules: {
|
|
877
|
+
/** Base path for rule operations (POST to publish) */
|
|
878
|
+
readonly base: "api/rules";
|
|
879
|
+
/** Get rule by slug (GET) */
|
|
880
|
+
readonly get: (slug: string) => string;
|
|
881
|
+
/** Unpublish rule version (DELETE) */
|
|
988
882
|
readonly unpublish: (slug: string, version: string) => string;
|
|
989
883
|
};
|
|
990
884
|
/** Auth endpoints */
|
|
@@ -996,121 +890,41 @@ declare const API_ENDPOINTS: {
|
|
|
996
890
|
/** Device token exchange */
|
|
997
891
|
readonly deviceToken: "api/auth/device/token";
|
|
998
892
|
};
|
|
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
893
|
};
|
|
1016
894
|
|
|
1017
895
|
//#endregion
|
|
1018
|
-
//#region src/
|
|
896
|
+
//#region src/schemas/common.d.ts
|
|
1019
897
|
/**
|
|
1020
|
-
*
|
|
1021
|
-
*
|
|
1022
|
-
* -
|
|
1023
|
-
* -
|
|
1024
|
-
* - description: max 500 chars (optional for rules)
|
|
1025
|
-
* - tags: max 35 chars each, 1-10 required, platform names blocked
|
|
898
|
+
* Schema for a single tag.
|
|
899
|
+
* - Max 35 characters
|
|
900
|
+
* - Lowercase alphanumeric with hyphens
|
|
901
|
+
* - Platform names blocked (redundant with platform field)
|
|
1026
902
|
*/
|
|
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;
|
|
903
|
+
declare const tagSchema: z.ZodString;
|
|
1040
904
|
/**
|
|
1041
|
-
*
|
|
1042
|
-
*
|
|
905
|
+
* Schema for tags array.
|
|
906
|
+
* - 0-10 tags allowed
|
|
1043
907
|
*/
|
|
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>;
|
|
908
|
+
declare const tagsSchema: z.ZodArray<z.ZodString>;
|
|
909
|
+
/**
|
|
910
|
+
* Schema for rule name.
|
|
911
|
+
* - Max 64 characters
|
|
912
|
+
* - Lowercase alphanumeric with hyphens
|
|
913
|
+
*/
|
|
914
|
+
declare const nameSchema: z.ZodString;
|
|
915
|
+
/**
|
|
916
|
+
* Schema for display title.
|
|
917
|
+
* - Max 80 characters
|
|
918
|
+
*/
|
|
919
|
+
declare const titleSchema: z.ZodString;
|
|
920
|
+
/**
|
|
921
|
+
* Schema for description.
|
|
922
|
+
* - Max 500 characters
|
|
923
|
+
*/
|
|
924
|
+
declare const descriptionSchema: z.ZodString;
|
|
1110
925
|
|
|
1111
926
|
//#endregion
|
|
1112
927
|
//#region src/utils/diff.d.ts
|
|
1113
|
-
/** Re-export platform-rule types for convenience */
|
|
1114
928
|
type DiffPreviewOptions = {
|
|
1115
929
|
context?: number;
|
|
1116
930
|
maxLines?: number;
|
|
@@ -1133,4 +947,4 @@ declare function toUint8Array(payload: ArrayBuffer | ArrayBufferView): Uint8Arra
|
|
|
1133
947
|
declare function normalizeBundlePath(value: string): string;
|
|
1134
948
|
|
|
1135
949
|
//#endregion
|
|
1136
|
-
export {
|
|
950
|
+
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, 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 };
|