@agentrules/core 0.0.11 → 0.1.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 +2 -2
- package/dist/index.d.ts +629 -174
- package/dist/index.js +461 -248
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,43 @@
|
|
|
1
1
|
import { z } from "zod";
|
|
2
2
|
|
|
3
|
+
//#region src/schemas/common.d.ts
|
|
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;
|
|
39
|
+
|
|
40
|
+
//#endregion
|
|
3
41
|
//#region src/preset/schema.d.ts
|
|
4
42
|
declare const platformIdSchema: z.ZodEnum<{
|
|
5
43
|
opencode: "opencode";
|
|
@@ -7,14 +45,22 @@ declare const platformIdSchema: z.ZodEnum<{
|
|
|
7
45
|
claude: "claude";
|
|
8
46
|
cursor: "cursor";
|
|
9
47
|
}>;
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
declare const
|
|
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;
|
|
15
53
|
declare const COMMON_LICENSES: readonly ["MIT", "Apache-2.0", "GPL-3.0-only", "BSD-3-Clause", "ISC", "Unlicense"];
|
|
16
54
|
type CommonLicense = (typeof COMMON_LICENSES)[number];
|
|
17
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
|
+
*/
|
|
18
64
|
declare const presetConfigSchema: z.ZodObject<{
|
|
19
65
|
$schema: z.ZodOptional<z.ZodString>;
|
|
20
66
|
name: z.ZodString;
|
|
@@ -24,118 +70,114 @@ declare const presetConfigSchema: z.ZodObject<{
|
|
|
24
70
|
tags: z.ZodArray<z.ZodString>;
|
|
25
71
|
features: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
26
72
|
license: z.ZodString;
|
|
27
|
-
|
|
73
|
+
ignore: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
74
|
+
agentrulesDir: z.ZodOptional<z.ZodString>;
|
|
75
|
+
platforms: z.ZodArray<z.ZodUnion<readonly [z.ZodEnum<{
|
|
28
76
|
opencode: "opencode";
|
|
29
77
|
codex: "codex";
|
|
30
78
|
claude: "claude";
|
|
31
79
|
cursor: "cursor";
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
|
|
80
|
+
}>, z.ZodObject<{
|
|
81
|
+
platform: z.ZodEnum<{
|
|
82
|
+
opencode: "opencode";
|
|
83
|
+
codex: "codex";
|
|
84
|
+
claude: "claude";
|
|
85
|
+
cursor: "cursor";
|
|
86
|
+
}>;
|
|
87
|
+
path: z.ZodOptional<z.ZodString>;
|
|
88
|
+
}, z.core.$strict>]>>;
|
|
35
89
|
}, z.core.$strict>;
|
|
36
90
|
declare const bundledFileSchema: z.ZodObject<{
|
|
37
91
|
path: z.ZodString;
|
|
38
92
|
size: z.ZodNumber;
|
|
39
93
|
checksum: z.ZodString;
|
|
40
|
-
|
|
94
|
+
content: z.ZodString;
|
|
41
95
|
}, z.core.$strip>;
|
|
42
96
|
/**
|
|
43
|
-
* Schema for
|
|
44
|
-
* Version is optional major version. Registry assigns full MAJOR.MINOR.
|
|
45
|
-
*
|
|
46
|
-
* Note: Clients send `name` (e.g., "my-preset"), and the registry defines the format of the slug.
|
|
47
|
-
* For example, a namespaced slug could be returned as "username/my-preset"
|
|
97
|
+
* Schema for per-platform variant in publish input.
|
|
48
98
|
*/
|
|
49
|
-
declare const
|
|
50
|
-
name: z.ZodString;
|
|
99
|
+
declare const publishVariantInputSchema: z.ZodObject<{
|
|
51
100
|
platform: z.ZodEnum<{
|
|
52
101
|
opencode: "opencode";
|
|
53
102
|
codex: "codex";
|
|
54
103
|
claude: "claude";
|
|
55
104
|
cursor: "cursor";
|
|
56
105
|
}>;
|
|
57
|
-
title: z.ZodString;
|
|
58
|
-
description: z.ZodString;
|
|
59
|
-
tags: z.ZodArray<z.ZodString>;
|
|
60
|
-
license: z.ZodString;
|
|
61
|
-
licenseContent: z.ZodOptional<z.ZodString>;
|
|
62
|
-
readmeContent: z.ZodOptional<z.ZodString>;
|
|
63
|
-
features: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
64
|
-
installMessage: z.ZodOptional<z.ZodString>;
|
|
65
106
|
files: z.ZodArray<z.ZodObject<{
|
|
66
107
|
path: z.ZodString;
|
|
67
108
|
size: z.ZodNumber;
|
|
68
109
|
checksum: z.ZodString;
|
|
69
|
-
|
|
110
|
+
content: z.ZodString;
|
|
70
111
|
}, z.core.$strip>>;
|
|
71
|
-
|
|
112
|
+
readmeContent: z.ZodOptional<z.ZodString>;
|
|
113
|
+
licenseContent: z.ZodOptional<z.ZodString>;
|
|
114
|
+
installMessage: z.ZodOptional<z.ZodString>;
|
|
72
115
|
}, z.core.$strip>;
|
|
73
116
|
/**
|
|
74
|
-
* Schema for what
|
|
75
|
-
*
|
|
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"
|
|
76
124
|
*/
|
|
77
|
-
declare const
|
|
125
|
+
declare const presetPublishInputSchema: z.ZodObject<{
|
|
126
|
+
name: z.ZodString;
|
|
78
127
|
title: z.ZodString;
|
|
79
128
|
description: z.ZodString;
|
|
80
129
|
tags: z.ZodArray<z.ZodString>;
|
|
81
130
|
license: z.ZodString;
|
|
82
|
-
platform: z.ZodEnum<{
|
|
83
|
-
opencode: "opencode";
|
|
84
|
-
codex: "codex";
|
|
85
|
-
claude: "claude";
|
|
86
|
-
cursor: "cursor";
|
|
87
|
-
}>;
|
|
88
131
|
features: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
132
|
+
variants: z.ZodArray<z.ZodObject<{
|
|
133
|
+
platform: z.ZodEnum<{
|
|
134
|
+
opencode: "opencode";
|
|
135
|
+
codex: "codex";
|
|
136
|
+
claude: "claude";
|
|
137
|
+
cursor: "cursor";
|
|
138
|
+
}>;
|
|
139
|
+
files: z.ZodArray<z.ZodObject<{
|
|
140
|
+
path: z.ZodString;
|
|
141
|
+
size: z.ZodNumber;
|
|
142
|
+
checksum: z.ZodString;
|
|
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>;
|
|
97
148
|
}, z.core.$strip>>;
|
|
98
|
-
|
|
99
|
-
version: z.ZodString;
|
|
149
|
+
version: z.ZodOptional<z.ZodNumber>;
|
|
100
150
|
}, z.core.$strip>;
|
|
101
|
-
|
|
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<{
|
|
102
156
|
title: z.ZodString;
|
|
103
157
|
description: z.ZodString;
|
|
104
158
|
tags: z.ZodArray<z.ZodString>;
|
|
159
|
+
variants: z.ZodArray<z.ZodObject<{
|
|
160
|
+
platform: z.ZodEnum<{
|
|
161
|
+
opencode: "opencode";
|
|
162
|
+
codex: "codex";
|
|
163
|
+
claude: "claude";
|
|
164
|
+
cursor: "cursor";
|
|
165
|
+
}>;
|
|
166
|
+
files: z.ZodArray<z.ZodObject<{
|
|
167
|
+
path: z.ZodString;
|
|
168
|
+
size: z.ZodNumber;
|
|
169
|
+
checksum: z.ZodString;
|
|
170
|
+
content: z.ZodString;
|
|
171
|
+
}, z.core.$strip>>;
|
|
172
|
+
readmeContent: z.ZodOptional<z.ZodString>;
|
|
173
|
+
licenseContent: z.ZodOptional<z.ZodString>;
|
|
174
|
+
installMessage: z.ZodOptional<z.ZodString>;
|
|
175
|
+
}, z.core.$strip>>;
|
|
105
176
|
license: z.ZodString;
|
|
106
|
-
platform: z.ZodEnum<{
|
|
107
|
-
opencode: "opencode";
|
|
108
|
-
codex: "codex";
|
|
109
|
-
claude: "claude";
|
|
110
|
-
cursor: "cursor";
|
|
111
|
-
}>;
|
|
112
|
-
version: z.ZodString;
|
|
113
177
|
features: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
114
178
|
slug: z.ZodString;
|
|
115
|
-
name: z.ZodString;
|
|
116
|
-
bundleUrl: z.ZodString;
|
|
117
|
-
fileCount: z.ZodNumber;
|
|
118
|
-
totalSize: z.ZodNumber;
|
|
119
|
-
}, z.core.$strip>;
|
|
120
|
-
declare const presetIndexSchema: z.ZodRecord<z.ZodString, z.ZodObject<{
|
|
121
|
-
title: z.ZodString;
|
|
122
|
-
description: z.ZodString;
|
|
123
|
-
tags: z.ZodArray<z.ZodString>;
|
|
124
|
-
license: z.ZodString;
|
|
125
|
-
platform: z.ZodEnum<{
|
|
126
|
-
opencode: "opencode";
|
|
127
|
-
codex: "codex";
|
|
128
|
-
claude: "claude";
|
|
129
|
-
cursor: "cursor";
|
|
130
|
-
}>;
|
|
131
179
|
version: z.ZodString;
|
|
132
|
-
|
|
133
|
-
slug: z.ZodString;
|
|
134
|
-
name: z.ZodString;
|
|
135
|
-
bundleUrl: z.ZodString;
|
|
136
|
-
fileCount: z.ZodNumber;
|
|
137
|
-
totalSize: z.ZodNumber;
|
|
138
|
-
}, z.core.$strip>>;
|
|
180
|
+
}, z.core.$strip>;
|
|
139
181
|
|
|
140
182
|
//#endregion
|
|
141
183
|
//#region src/platform/types.d.ts
|
|
@@ -216,14 +258,14 @@ declare const PLATFORMS: {
|
|
|
216
258
|
readonly globalDir: "~/.config/opencode";
|
|
217
259
|
readonly types: {
|
|
218
260
|
readonly instruction: {
|
|
219
|
-
readonly description: "Project instructions
|
|
261
|
+
readonly description: "Project instructions";
|
|
220
262
|
readonly format: "markdown";
|
|
221
263
|
readonly extension: "md";
|
|
222
264
|
readonly projectPath: "AGENTS.md";
|
|
223
265
|
readonly globalPath: "~/.config/opencode/AGENTS.md";
|
|
224
266
|
};
|
|
225
267
|
readonly agent: {
|
|
226
|
-
readonly description: "Specialized AI agent
|
|
268
|
+
readonly description: "Specialized AI agent";
|
|
227
269
|
readonly format: "markdown";
|
|
228
270
|
readonly extension: "md";
|
|
229
271
|
readonly projectPath: ".opencode/agent/{name}.md";
|
|
@@ -237,7 +279,7 @@ declare const PLATFORMS: {
|
|
|
237
279
|
readonly globalPath: "~/.config/opencode/command/{name}.md";
|
|
238
280
|
};
|
|
239
281
|
readonly tool: {
|
|
240
|
-
readonly description: "Custom tool
|
|
282
|
+
readonly description: "Custom tool";
|
|
241
283
|
readonly format: "typescript";
|
|
242
284
|
readonly extension: "ts";
|
|
243
285
|
readonly projectPath: ".opencode/tool/{name}.ts";
|
|
@@ -251,7 +293,7 @@ declare const PLATFORMS: {
|
|
|
251
293
|
readonly globalDir: "~/.claude";
|
|
252
294
|
readonly types: {
|
|
253
295
|
readonly instruction: {
|
|
254
|
-
readonly description: "Project instructions
|
|
296
|
+
readonly description: "Project instructions";
|
|
255
297
|
readonly format: "markdown";
|
|
256
298
|
readonly extension: "md";
|
|
257
299
|
readonly projectPath: "CLAUDE.md";
|
|
@@ -265,7 +307,7 @@ declare const PLATFORMS: {
|
|
|
265
307
|
readonly globalPath: "~/.claude/commands/{name}.md";
|
|
266
308
|
};
|
|
267
309
|
readonly skill: {
|
|
268
|
-
readonly description: "Custom skill
|
|
310
|
+
readonly description: "Custom skill";
|
|
269
311
|
readonly format: "markdown";
|
|
270
312
|
readonly extension: "md";
|
|
271
313
|
readonly projectPath: ".claude/skills/{name}/SKILL.md";
|
|
@@ -276,31 +318,45 @@ declare const PLATFORMS: {
|
|
|
276
318
|
readonly cursor: {
|
|
277
319
|
readonly label: "Cursor";
|
|
278
320
|
readonly projectDir: ".cursor";
|
|
279
|
-
readonly globalDir:
|
|
321
|
+
readonly globalDir: "~/.cursor";
|
|
280
322
|
readonly types: {
|
|
323
|
+
readonly instruction: {
|
|
324
|
+
readonly description: "Project instructions";
|
|
325
|
+
readonly format: "markdown";
|
|
326
|
+
readonly extension: "md";
|
|
327
|
+
readonly projectPath: "AGENTS.md";
|
|
328
|
+
readonly globalPath: null;
|
|
329
|
+
};
|
|
281
330
|
readonly rule: {
|
|
282
|
-
readonly description: "
|
|
331
|
+
readonly description: "Custom rule";
|
|
283
332
|
readonly format: "mdc";
|
|
284
333
|
readonly extension: "mdc";
|
|
285
334
|
readonly projectPath: ".cursor/rules/{name}.mdc";
|
|
286
335
|
readonly globalPath: null;
|
|
287
336
|
};
|
|
337
|
+
readonly command: {
|
|
338
|
+
readonly description: "Custom slash command";
|
|
339
|
+
readonly format: "markdown";
|
|
340
|
+
readonly extension: "md";
|
|
341
|
+
readonly projectPath: ".cursor/commands/{name}.md";
|
|
342
|
+
readonly globalPath: "~/.cursor/commands/{name}.md";
|
|
343
|
+
};
|
|
288
344
|
};
|
|
289
345
|
};
|
|
290
346
|
readonly codex: {
|
|
291
347
|
readonly label: "Codex";
|
|
292
|
-
readonly projectDir: "";
|
|
348
|
+
readonly projectDir: ".codex";
|
|
293
349
|
readonly globalDir: "~/.codex";
|
|
294
350
|
readonly types: {
|
|
295
351
|
readonly instruction: {
|
|
296
|
-
readonly description: "Project instructions
|
|
352
|
+
readonly description: "Project instructions";
|
|
297
353
|
readonly format: "markdown";
|
|
298
354
|
readonly extension: "md";
|
|
299
355
|
readonly projectPath: "AGENTS.md";
|
|
300
356
|
readonly globalPath: "~/.codex/AGENTS.md";
|
|
301
357
|
};
|
|
302
358
|
readonly command: {
|
|
303
|
-
readonly description: "Custom prompt
|
|
359
|
+
readonly description: "Custom prompt";
|
|
304
360
|
readonly format: "markdown";
|
|
305
361
|
readonly extension: "md";
|
|
306
362
|
readonly projectPath: null;
|
|
@@ -311,10 +367,10 @@ declare const PLATFORMS: {
|
|
|
311
367
|
};
|
|
312
368
|
/** Valid rule types for each platform. Must be kept in sync with PLATFORMS. */
|
|
313
369
|
declare const PLATFORM_RULE_TYPES: {
|
|
314
|
-
readonly opencode: readonly ["instruction", "
|
|
370
|
+
readonly opencode: readonly ["instruction", "command", "agent", "tool"];
|
|
315
371
|
readonly claude: readonly ["instruction", "command", "skill"];
|
|
316
|
-
readonly cursor: readonly ["rule"];
|
|
317
372
|
readonly codex: readonly ["instruction", "command"];
|
|
373
|
+
readonly cursor: readonly ["instruction", "command", "rule"];
|
|
318
374
|
};
|
|
319
375
|
/** Get valid rule types for a specific platform */
|
|
320
376
|
declare function getValidRuleTypes(platform: PlatformId): readonly string[];
|
|
@@ -343,7 +399,40 @@ declare function getPlatformFromDir(dirName: string): PlatformId | undefined;
|
|
|
343
399
|
|
|
344
400
|
//#endregion
|
|
345
401
|
//#region src/preset/types.d.ts
|
|
346
|
-
|
|
402
|
+
/**
|
|
403
|
+
* Platform entry in raw config - either a platform ID string or an object with optional path.
|
|
404
|
+
*
|
|
405
|
+
* Examples:
|
|
406
|
+
* - "opencode" (shorthand, uses default directory)
|
|
407
|
+
* - { platform: "opencode", path: "rules" } (custom path)
|
|
408
|
+
*/
|
|
409
|
+
type RawPlatformEntry = PlatformId | {
|
|
410
|
+
platform: PlatformId;
|
|
411
|
+
path?: string;
|
|
412
|
+
};
|
|
413
|
+
/**
|
|
414
|
+
* Normalized platform entry - always the object form.
|
|
415
|
+
*/
|
|
416
|
+
type PlatformConfig = {
|
|
417
|
+
platform: PlatformId;
|
|
418
|
+
path?: string;
|
|
419
|
+
};
|
|
420
|
+
/**
|
|
421
|
+
* Normalize a raw platform entry to the object form.
|
|
422
|
+
*/
|
|
423
|
+
declare function normalizePlatformEntry(entry: RawPlatformEntry): PlatformConfig;
|
|
424
|
+
/**
|
|
425
|
+
* Raw preset configuration - what users write in agentrules.json.
|
|
426
|
+
*
|
|
427
|
+
* Uses a unified `platforms` array that accepts either:
|
|
428
|
+
* - Platform ID strings: `["opencode", "claude"]`
|
|
429
|
+
* - Objects with optional path: `[{ platform: "opencode", path: "rules" }]`
|
|
430
|
+
* - Mixed: `["opencode", { platform: "claude", path: "my-claude" }]`
|
|
431
|
+
*
|
|
432
|
+
* **Order matters**: The first platform in the array is used as the default
|
|
433
|
+
* when viewing the preset on the registry without specifying a platform.
|
|
434
|
+
*/
|
|
435
|
+
type RawPresetConfig = {
|
|
347
436
|
$schema?: string;
|
|
348
437
|
name: string;
|
|
349
438
|
title: string;
|
|
@@ -352,21 +441,52 @@ type PresetConfig = {
|
|
|
352
441
|
tags?: string[];
|
|
353
442
|
features?: string[];
|
|
354
443
|
license: string;
|
|
355
|
-
platform: PlatformId;
|
|
356
|
-
/** Path to config files. Defaults to platform's projectDir (e.g., ".claude") */
|
|
357
|
-
path?: string;
|
|
358
444
|
/** Additional patterns to exclude from bundle (glob patterns) */
|
|
359
445
|
ignore?: string[];
|
|
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[];
|
|
457
|
+
};
|
|
458
|
+
/**
|
|
459
|
+
* Normalized preset configuration - used internally after loading.
|
|
460
|
+
* Always has platforms as PlatformConfig[] (object form).
|
|
461
|
+
*/
|
|
462
|
+
type PresetConfig = Omit<RawPresetConfig, "platforms"> & {
|
|
463
|
+
platforms: PlatformConfig[];
|
|
360
464
|
};
|
|
361
465
|
type BundledFile = {
|
|
362
466
|
path: string;
|
|
363
467
|
/** File size in bytes */
|
|
364
468
|
size: number;
|
|
365
469
|
checksum: string;
|
|
366
|
-
|
|
470
|
+
content: string;
|
|
367
471
|
};
|
|
368
472
|
/**
|
|
369
|
-
*
|
|
473
|
+
* Per-platform variant input for publishing.
|
|
474
|
+
* Contains files and optional metadata for a single platform.
|
|
475
|
+
*/
|
|
476
|
+
type PublishVariantInput = {
|
|
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
|
+
};
|
|
486
|
+
/**
|
|
487
|
+
* What clients send to publish a preset (multi-platform).
|
|
488
|
+
*
|
|
489
|
+
* One publish call creates ONE version with ALL platform variants.
|
|
370
490
|
* Version is optional major version. Registry assigns full MAJOR.MINOR.
|
|
371
491
|
*
|
|
372
492
|
* Note: Clients send `name` (e.g., "my-preset"), and the registry defines the format of the slug.
|
|
@@ -374,58 +494,388 @@ type BundledFile = {
|
|
|
374
494
|
*/
|
|
375
495
|
type PresetPublishInput = {
|
|
376
496
|
name: string;
|
|
377
|
-
platform: PlatformId;
|
|
378
497
|
title: string;
|
|
379
498
|
description: string;
|
|
380
499
|
tags: string[];
|
|
381
500
|
license: string;
|
|
382
|
-
licenseContent?: string;
|
|
383
|
-
readmeContent?: string;
|
|
384
501
|
features?: string[];
|
|
385
|
-
|
|
386
|
-
|
|
502
|
+
/** Platform variants - each contains files for that platform */
|
|
503
|
+
variants: PublishVariantInput[];
|
|
387
504
|
/** Major version. Defaults to 1 if not specified. */
|
|
388
505
|
version?: number;
|
|
389
506
|
};
|
|
390
507
|
/**
|
|
391
|
-
* What registries store and return.
|
|
392
|
-
*
|
|
508
|
+
* What registries store and return for a single platform bundle.
|
|
509
|
+
* This is stored in R2 and fetched via bundleUrl.
|
|
510
|
+
*
|
|
511
|
+
* Note: This is per-platform, while PresetPublishInput is multi-platform.
|
|
393
512
|
*/
|
|
394
|
-
type PresetBundle =
|
|
395
|
-
/** Full namespaced slug (e.g., "username/my-preset") */
|
|
396
|
-
slug: string;
|
|
397
|
-
/** Full version in MAJOR.MINOR format (e.g., "1.3", "2.1") */
|
|
398
|
-
version: string;
|
|
399
|
-
};
|
|
400
|
-
type Preset = {
|
|
513
|
+
type PresetBundle = {
|
|
401
514
|
name: string;
|
|
402
|
-
slug: string;
|
|
403
515
|
platform: PlatformId;
|
|
404
516
|
title: string;
|
|
405
|
-
version: string;
|
|
406
517
|
description: string;
|
|
407
518
|
tags: string[];
|
|
408
519
|
license: string;
|
|
409
520
|
features?: string[];
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
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;
|
|
413
529
|
};
|
|
414
|
-
type PresetIndex = Record<string, Preset>;
|
|
415
530
|
type PresetFileInput = {
|
|
416
531
|
path: string;
|
|
417
|
-
|
|
532
|
+
content: ArrayBuffer | ArrayBufferView | string;
|
|
533
|
+
};
|
|
534
|
+
/**
|
|
535
|
+
* Files for a single platform variant
|
|
536
|
+
*/
|
|
537
|
+
type PlatformFiles = {
|
|
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;
|
|
418
546
|
};
|
|
547
|
+
/**
|
|
548
|
+
* Preset input - what the CLI builds after loading files.
|
|
549
|
+
* Always uses platformFiles array (works for single or multi-platform).
|
|
550
|
+
*/
|
|
419
551
|
type PresetInput = {
|
|
420
552
|
name: string;
|
|
421
553
|
config: PresetConfig;
|
|
422
|
-
|
|
423
|
-
|
|
554
|
+
/** Files for each platform */
|
|
555
|
+
platformFiles: PlatformFiles[];
|
|
556
|
+
/** Shared install message (fallback for platforms without their own) */
|
|
424
557
|
installMessage?: string;
|
|
558
|
+
/** Shared README (fallback for platforms without their own) */
|
|
425
559
|
readmeContent?: string;
|
|
560
|
+
/** Shared LICENSE (fallback for platforms without their own) */
|
|
426
561
|
licenseContent?: string;
|
|
427
562
|
};
|
|
428
563
|
|
|
564
|
+
//#endregion
|
|
565
|
+
//#region src/resolve/schema.d.ts
|
|
566
|
+
declare const presetVariantSchema: z.ZodUnion<readonly [z.ZodObject<{
|
|
567
|
+
platform: z.ZodEnum<{
|
|
568
|
+
opencode: "opencode";
|
|
569
|
+
codex: "codex";
|
|
570
|
+
claude: "claude";
|
|
571
|
+
cursor: "cursor";
|
|
572
|
+
}>;
|
|
573
|
+
bundleUrl: z.ZodString;
|
|
574
|
+
fileCount: z.ZodNumber;
|
|
575
|
+
totalSize: z.ZodNumber;
|
|
576
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
577
|
+
platform: z.ZodEnum<{
|
|
578
|
+
opencode: "opencode";
|
|
579
|
+
codex: "codex";
|
|
580
|
+
claude: "claude";
|
|
581
|
+
cursor: "cursor";
|
|
582
|
+
}>;
|
|
583
|
+
content: z.ZodString;
|
|
584
|
+
fileCount: z.ZodNumber;
|
|
585
|
+
totalSize: z.ZodNumber;
|
|
586
|
+
}, z.core.$strip>]>;
|
|
587
|
+
declare const ruleVariantSchema: z.ZodObject<{
|
|
588
|
+
platform: z.ZodEnum<{
|
|
589
|
+
opencode: "opencode";
|
|
590
|
+
codex: "codex";
|
|
591
|
+
claude: "claude";
|
|
592
|
+
cursor: "cursor";
|
|
593
|
+
}>;
|
|
594
|
+
type: z.ZodString;
|
|
595
|
+
content: z.ZodString;
|
|
596
|
+
}, z.core.$strip>;
|
|
597
|
+
declare const presetVersionSchema: z.ZodObject<{
|
|
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
|
+
}>;
|
|
618
|
+
content: z.ZodString;
|
|
619
|
+
fileCount: z.ZodNumber;
|
|
620
|
+
totalSize: z.ZodNumber;
|
|
621
|
+
}, z.core.$strip>]>>;
|
|
622
|
+
}, z.core.$strip>;
|
|
623
|
+
declare const ruleVersionSchema: z.ZodObject<{
|
|
624
|
+
version: z.ZodString;
|
|
625
|
+
isLatest: z.ZodBoolean;
|
|
626
|
+
publishedAt: z.ZodOptional<z.ZodString>;
|
|
627
|
+
variants: z.ZodArray<z.ZodObject<{
|
|
628
|
+
platform: z.ZodEnum<{
|
|
629
|
+
opencode: "opencode";
|
|
630
|
+
codex: "codex";
|
|
631
|
+
claude: "claude";
|
|
632
|
+
cursor: "cursor";
|
|
633
|
+
}>;
|
|
634
|
+
type: z.ZodString;
|
|
635
|
+
content: z.ZodString;
|
|
636
|
+
}, z.core.$strip>>;
|
|
637
|
+
}, z.core.$strip>;
|
|
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;
|
|
693
|
+
content: z.ZodString;
|
|
694
|
+
}, z.core.$strip>>;
|
|
695
|
+
}, z.core.$strip>>;
|
|
696
|
+
}, z.core.$strip>;
|
|
697
|
+
declare const resolveResponseSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
698
|
+
kind: z.ZodLiteral<"preset">;
|
|
699
|
+
slug: z.ZodString;
|
|
700
|
+
name: z.ZodString;
|
|
701
|
+
title: z.ZodString;
|
|
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;
|
|
735
|
+
name: z.ZodString;
|
|
736
|
+
title: z.ZodString;
|
|
737
|
+
description: z.ZodString;
|
|
738
|
+
tags: z.ZodArray<z.ZodString>;
|
|
739
|
+
versions: z.ZodArray<z.ZodObject<{
|
|
740
|
+
version: z.ZodString;
|
|
741
|
+
isLatest: z.ZodBoolean;
|
|
742
|
+
publishedAt: z.ZodOptional<z.ZodString>;
|
|
743
|
+
variants: z.ZodArray<z.ZodObject<{
|
|
744
|
+
platform: z.ZodEnum<{
|
|
745
|
+
opencode: "opencode";
|
|
746
|
+
codex: "codex";
|
|
747
|
+
claude: "claude";
|
|
748
|
+
cursor: "cursor";
|
|
749
|
+
}>;
|
|
750
|
+
type: z.ZodString;
|
|
751
|
+
content: z.ZodString;
|
|
752
|
+
}, z.core.$strip>>;
|
|
753
|
+
}, z.core.$strip>>;
|
|
754
|
+
}, z.core.$strip>], "kind">;
|
|
755
|
+
|
|
756
|
+
//#endregion
|
|
757
|
+
//#region src/resolve/types.d.ts
|
|
758
|
+
/** Base fields for all variants */
|
|
759
|
+
type BaseVariant = {
|
|
760
|
+
platform: PlatformId;
|
|
761
|
+
};
|
|
762
|
+
/** Preset variant with bundle URL (for larger presets) */
|
|
763
|
+
type PresetVariantBundle = BaseVariant & {
|
|
764
|
+
bundleUrl: string;
|
|
765
|
+
fileCount: number;
|
|
766
|
+
totalSize: number;
|
|
767
|
+
};
|
|
768
|
+
/** Preset variant with inline content (for smaller presets) */
|
|
769
|
+
type PresetVariantInline = BaseVariant & {
|
|
770
|
+
content: string;
|
|
771
|
+
fileCount: number;
|
|
772
|
+
totalSize: number;
|
|
773
|
+
};
|
|
774
|
+
/** Preset variant - registry decides bundleUrl vs inline content */
|
|
775
|
+
type PresetVariant = PresetVariantBundle | PresetVariantInline;
|
|
776
|
+
/** Rule variant - always inline (rules are small text files) */
|
|
777
|
+
type RuleVariant = BaseVariant & {
|
|
778
|
+
type: string;
|
|
779
|
+
content: string;
|
|
780
|
+
};
|
|
781
|
+
type PresetVersion = {
|
|
782
|
+
version: string;
|
|
783
|
+
isLatest: boolean;
|
|
784
|
+
publishedAt?: string;
|
|
785
|
+
variants: PresetVariant[];
|
|
786
|
+
};
|
|
787
|
+
type RuleVersion = {
|
|
788
|
+
version: string;
|
|
789
|
+
isLatest: boolean;
|
|
790
|
+
publishedAt?: string;
|
|
791
|
+
variants: RuleVariant[];
|
|
792
|
+
};
|
|
793
|
+
type ResolvedPreset = {
|
|
794
|
+
kind: "preset";
|
|
795
|
+
slug: string;
|
|
796
|
+
name: string;
|
|
797
|
+
title: string;
|
|
798
|
+
description: string;
|
|
799
|
+
tags: string[];
|
|
800
|
+
license: string;
|
|
801
|
+
features: string[];
|
|
802
|
+
versions: PresetVersion[];
|
|
803
|
+
};
|
|
804
|
+
type ResolvedRule = {
|
|
805
|
+
kind: "rule";
|
|
806
|
+
slug: string;
|
|
807
|
+
name: string;
|
|
808
|
+
title: string;
|
|
809
|
+
description: string;
|
|
810
|
+
tags: string[];
|
|
811
|
+
versions: RuleVersion[];
|
|
812
|
+
};
|
|
813
|
+
/** Discriminated union for items endpoint response */
|
|
814
|
+
type ResolveResponse = ResolvedPreset | ResolvedRule;
|
|
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;
|
|
831
|
+
};
|
|
832
|
+
/**
|
|
833
|
+
* Type guard for preset variant with inline content
|
|
834
|
+
*/
|
|
835
|
+
declare function hasInlineContent(variant: PresetVariant): variant is PresetVariant & {
|
|
836
|
+
content: string;
|
|
837
|
+
};
|
|
838
|
+
/**
|
|
839
|
+
* Get the latest version from a resolved preset
|
|
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
|
|
876
|
+
*/
|
|
877
|
+
declare function ruleHasPlatform(item: ResolvedRule, platform: PlatformId): boolean;
|
|
878
|
+
|
|
429
879
|
//#endregion
|
|
430
880
|
//#region src/builder/registry.d.ts
|
|
431
881
|
/**
|
|
@@ -434,47 +884,56 @@ type PresetInput = {
|
|
|
434
884
|
*/
|
|
435
885
|
declare const STATIC_BUNDLE_DIR = "registry";
|
|
436
886
|
/**
|
|
437
|
-
* Options for building a PresetPublishInput
|
|
887
|
+
* Options for building a PresetPublishInput.
|
|
438
888
|
*/
|
|
439
889
|
type BuildPresetPublishInputOptions = {
|
|
890
|
+
/** Preset input (single or multi-platform) */
|
|
440
891
|
preset: PresetInput;
|
|
441
892
|
/** Major version. Defaults to 1 if not specified. */
|
|
442
893
|
version?: number;
|
|
443
894
|
};
|
|
444
895
|
/**
|
|
445
896
|
* Builds a PresetPublishInput from preset input.
|
|
446
|
-
*
|
|
897
|
+
*
|
|
898
|
+
* PresetInput always has platformFiles array (unified format).
|
|
447
899
|
*/
|
|
448
900
|
declare function buildPresetPublishInput(options: BuildPresetPublishInputOptions): Promise<PresetPublishInput>;
|
|
449
901
|
/**
|
|
450
902
|
* Options for building a static registry.
|
|
451
903
|
*/
|
|
452
904
|
type BuildPresetRegistryOptions = {
|
|
905
|
+
/** Presets to include (single or multi-platform) */
|
|
453
906
|
presets: PresetInput[];
|
|
454
907
|
/**
|
|
455
908
|
* Optional base path or URL prefix for bundle locations.
|
|
456
|
-
* Format: {bundleBase}/{STATIC_BUNDLE_DIR}/{slug}/{platform}
|
|
909
|
+
* Format: {bundleBase}/{STATIC_BUNDLE_DIR}/{slug}/{platform}/{version}
|
|
457
910
|
* Default: no prefix (bundleUrl starts with STATIC_BUNDLE_DIR)
|
|
458
911
|
*/
|
|
459
912
|
bundleBase?: string;
|
|
460
913
|
};
|
|
461
914
|
type BuildPresetRegistryResult = {
|
|
462
|
-
|
|
463
|
-
|
|
915
|
+
/** Resolved presets in the unified format (one per slug with all versions/variants) */
|
|
916
|
+
items: ResolvedPreset[];
|
|
917
|
+
/** Bundles for each platform variant (used to write individual bundle files) */
|
|
464
918
|
bundles: PresetBundle[];
|
|
465
919
|
};
|
|
466
920
|
/**
|
|
467
|
-
* Builds a static registry with
|
|
468
|
-
*
|
|
469
|
-
*
|
|
921
|
+
* Builds a static registry with items and bundles.
|
|
922
|
+
*
|
|
923
|
+
* Uses the same model as dynamic publishing:
|
|
924
|
+
* - Each PresetInput (single or multi-platform) becomes one item
|
|
925
|
+
* - Each platform variant becomes one bundle
|
|
470
926
|
*/
|
|
471
927
|
declare function buildPresetRegistry(options: BuildPresetRegistryOptions): Promise<BuildPresetRegistryResult>;
|
|
472
928
|
|
|
473
929
|
//#endregion
|
|
474
930
|
//#region src/builder/utils.d.ts
|
|
475
931
|
declare function cleanInstallMessage(value: unknown): string | undefined;
|
|
476
|
-
|
|
477
|
-
|
|
932
|
+
/**
|
|
933
|
+
* Validate raw preset config from JSON.
|
|
934
|
+
* Returns the raw config shape (before normalization).
|
|
935
|
+
*/
|
|
936
|
+
declare function validatePresetConfig(config: unknown, slug: string): RawPresetConfig;
|
|
478
937
|
|
|
479
938
|
//#endregion
|
|
480
939
|
//#region src/client/bundle.d.ts
|
|
@@ -486,26 +945,19 @@ declare function toUtf8String(payload: ArrayBuffer | ArrayBufferView): string;
|
|
|
486
945
|
//#endregion
|
|
487
946
|
//#region src/client/registry.d.ts
|
|
488
947
|
/**
|
|
489
|
-
*
|
|
948
|
+
* Fetches a bundle from an absolute URL.
|
|
490
949
|
*/
|
|
491
|
-
|
|
492
|
-
preset: Preset;
|
|
493
|
-
bundleUrl: string;
|
|
494
|
-
};
|
|
950
|
+
declare function fetchBundle(bundleUrl: string): Promise<PresetBundle>;
|
|
495
951
|
/**
|
|
496
|
-
* Resolves a
|
|
497
|
-
* Returns the entry metadata and the absolute bundle URL.
|
|
952
|
+
* Resolves a slug to get all versions and platform variants.
|
|
498
953
|
*
|
|
499
954
|
* @param baseUrl - Registry base URL
|
|
500
|
-
* @param slug -
|
|
501
|
-
* @param
|
|
502
|
-
* @
|
|
955
|
+
* @param slug - Content slug (may contain slashes, e.g., "username/my-preset")
|
|
956
|
+
* @param version - Optional version filter (server may ignore for static registries)
|
|
957
|
+
* @returns Resolved data, or null if not found
|
|
958
|
+
* @throws Error on network/server errors
|
|
503
959
|
*/
|
|
504
|
-
declare function
|
|
505
|
-
/**
|
|
506
|
-
* Fetches a bundle from an absolute URL or resolves it relative to the registry.
|
|
507
|
-
*/
|
|
508
|
-
declare function fetchBundle(bundleUrl: string): Promise<PresetBundle>;
|
|
960
|
+
declare function resolveSlug(baseUrl: string, slug: string, version?: string): Promise<ResolveResponse | null>;
|
|
509
961
|
|
|
510
962
|
//#endregion
|
|
511
963
|
//#region src/constants.d.ts
|
|
@@ -523,23 +975,17 @@ declare const LATEST_VERSION = "latest";
|
|
|
523
975
|
/**
|
|
524
976
|
* API endpoint paths (relative to registry base URL).
|
|
525
977
|
*
|
|
526
|
-
* Note
|
|
527
|
-
* - Slugs may contain slashes (e.g., "username/my-preset") which
|
|
528
|
-
*
|
|
529
|
-
* - Platform and version are constrained values (enums, validated formats)
|
|
530
|
-
* that only contain URL-safe characters
|
|
531
|
-
*
|
|
532
|
-
* The client is responsible for validating these values before making requests.
|
|
978
|
+
* Note on slug handling:
|
|
979
|
+
* - Slugs may contain slashes (e.g., "username/my-preset") which flow through as path segments
|
|
980
|
+
* - The client is responsible for validating values before making requests
|
|
533
981
|
*/
|
|
534
982
|
declare const API_ENDPOINTS: {
|
|
535
|
-
/** Preset endpoints */
|
|
983
|
+
/** Preset endpoints (for publishing) */
|
|
536
984
|
readonly presets: {
|
|
537
985
|
/** Base path for preset operations */
|
|
538
|
-
readonly base: "api/
|
|
539
|
-
/**
|
|
540
|
-
readonly
|
|
541
|
-
/** Unpublish preset version */
|
|
542
|
-
readonly unpublish: (slug: string, platform: string, version: string) => string;
|
|
986
|
+
readonly base: "api/presets";
|
|
987
|
+
/** Unpublish preset version (unpublishes all platform variants for that version) */
|
|
988
|
+
readonly unpublish: (slug: string, version: string) => string;
|
|
543
989
|
};
|
|
544
990
|
/** Auth endpoints */
|
|
545
991
|
readonly auth: {
|
|
@@ -550,11 +996,20 @@ declare const API_ENDPOINTS: {
|
|
|
550
996
|
/** Device token exchange */
|
|
551
997
|
readonly deviceToken: "api/auth/device/token";
|
|
552
998
|
};
|
|
553
|
-
/** Rule endpoints */
|
|
554
|
-
readonly
|
|
555
|
-
/** Base path for rule operations */
|
|
556
|
-
readonly base: "api/
|
|
557
|
-
/**
|
|
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
|
+
*/
|
|
558
1013
|
readonly get: (slug: string) => string;
|
|
559
1014
|
};
|
|
560
1015
|
};
|
|
@@ -562,12 +1017,18 @@ declare const API_ENDPOINTS: {
|
|
|
562
1017
|
//#endregion
|
|
563
1018
|
//#region src/rule/schema.d.ts
|
|
564
1019
|
/**
|
|
565
|
-
*
|
|
566
|
-
*
|
|
1020
|
+
* Rule-specific schema aliases.
|
|
1021
|
+
* All use shared schemas for consistency with presets:
|
|
1022
|
+
* - name: max 64 chars, lowercase kebab-case
|
|
1023
|
+
* - title: max 80 chars
|
|
1024
|
+
* - description: max 500 chars (optional for rules)
|
|
1025
|
+
* - tags: max 35 chars each, 1-10 required, platform names blocked
|
|
567
1026
|
*/
|
|
568
1027
|
declare const ruleNameSchema: z.ZodString;
|
|
569
1028
|
declare const ruleTitleSchema: z.ZodString;
|
|
570
1029
|
declare const ruleDescriptionSchema: z.ZodString;
|
|
1030
|
+
declare const ruleTagSchema: z.ZodString;
|
|
1031
|
+
declare const ruleTagsSchema: z.ZodArray<z.ZodString>;
|
|
571
1032
|
declare const rulePlatformSchema: z.ZodEnum<{
|
|
572
1033
|
opencode: "opencode";
|
|
573
1034
|
codex: "codex";
|
|
@@ -576,8 +1037,6 @@ declare const rulePlatformSchema: z.ZodEnum<{
|
|
|
576
1037
|
}>;
|
|
577
1038
|
declare const ruleTypeSchema: z.ZodString;
|
|
578
1039
|
declare const ruleContentSchema: z.ZodString;
|
|
579
|
-
declare const ruleTagSchema: z.ZodString;
|
|
580
|
-
declare const ruleTagsSchema: z.ZodArray<z.ZodString>;
|
|
581
1040
|
/**
|
|
582
1041
|
* Discriminated union schema for platform + type combinations.
|
|
583
1042
|
* Each platform has its own set of valid types.
|
|
@@ -600,6 +1059,8 @@ declare const rulePlatformTypeSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
|
600
1059
|
}, z.core.$strip>, z.ZodObject<{
|
|
601
1060
|
platform: z.ZodLiteral<"cursor">;
|
|
602
1061
|
type: z.ZodEnum<{
|
|
1062
|
+
instruction: "instruction";
|
|
1063
|
+
command: "command";
|
|
603
1064
|
rule: "rule";
|
|
604
1065
|
}>;
|
|
605
1066
|
}, z.core.$strip>, z.ZodObject<{
|
|
@@ -634,6 +1095,8 @@ declare const ruleCreateInputSchema: z.ZodIntersection<z.ZodObject<{
|
|
|
634
1095
|
}, z.core.$strip>, z.ZodObject<{
|
|
635
1096
|
platform: z.ZodLiteral<"cursor">;
|
|
636
1097
|
type: z.ZodEnum<{
|
|
1098
|
+
instruction: "instruction";
|
|
1099
|
+
command: "command";
|
|
637
1100
|
rule: "rule";
|
|
638
1101
|
}>;
|
|
639
1102
|
}, z.core.$strip>, z.ZodObject<{
|
|
@@ -643,15 +1106,7 @@ declare const ruleCreateInputSchema: z.ZodIntersection<z.ZodObject<{
|
|
|
643
1106
|
command: "command";
|
|
644
1107
|
}>;
|
|
645
1108
|
}, z.core.$strip>], "platform">>;
|
|
646
|
-
declare const ruleUpdateInputSchema: z.ZodObject<{
|
|
647
|
-
name: z.ZodString;
|
|
648
|
-
title: z.ZodOptional<z.ZodString>;
|
|
649
|
-
description: z.ZodOptional<z.ZodString>;
|
|
650
|
-
content: z.ZodOptional<z.ZodString>;
|
|
651
|
-
tags: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
652
|
-
}, z.core.$strip>;
|
|
653
1109
|
type RuleCreateInput = z.infer<typeof ruleCreateInputSchema>;
|
|
654
|
-
type RuleUpdateInput = z.infer<typeof ruleUpdateInputSchema>;
|
|
655
1110
|
|
|
656
1111
|
//#endregion
|
|
657
1112
|
//#region src/utils/diff.d.ts
|
|
@@ -678,4 +1133,4 @@ declare function toUint8Array(payload: ArrayBuffer | ArrayBufferView): Uint8Arra
|
|
|
678
1133
|
declare function normalizeBundlePath(value: string): string;
|
|
679
1134
|
|
|
680
1135
|
//#endregion
|
|
681
|
-
export { AGENT_RULES_DIR, API_ENDPOINTS, BuildPresetPublishInputOptions, BuildPresetRegistryOptions, BuildPresetRegistryResult, BundledFile, COMMON_LICENSES, CommonLicense, DiffPreviewOptions, LATEST_VERSION, PLATFORMS, PLATFORM_IDS, PLATFORM_ID_TUPLE, PLATFORM_RULE_TYPES, PRESET_CONFIG_FILENAME, PRESET_SCHEMA_URL, PlatformId, PlatformRuleConfig, PlatformRuleType,
|
|
1136
|
+
export { AGENT_RULES_DIR, API_ENDPOINTS, BuildPresetPublishInputOptions, BuildPresetRegistryOptions, BuildPresetRegistryResult, BundledFile, COMMON_LICENSES, CommonLicense, DiffPreviewOptions, LATEST_VERSION, PLATFORMS, PLATFORM_IDS, PLATFORM_ID_TUPLE, PLATFORM_RULE_TYPES, PRESET_CONFIG_FILENAME, PRESET_SCHEMA_URL, PlatformConfig, PlatformFiles, PlatformId, PlatformRuleConfig, PlatformRuleType, PresetBundle, PresetConfig, PresetFileInput, PresetInput, PresetPublishInput, PresetVariant, PresetVersion, PublishVariantInput, RawPlatformEntry, RawPresetConfig, ResolveResponse, ResolvedPreset, ResolvedRule, RuleCreateInput, RuleFileFormat, RuleType, RuleTypeConfig, RuleTypeForPlatform, RuleVariant, RuleVersion, STATIC_BUNDLE_DIR, buildPresetPublishInput, buildPresetRegistry, bundledFileSchema, cleanInstallMessage, createDiffPreview, decodeBundledFile, decodeUtf8, descriptionSchema, encodeUtf8, fetchBundle, getInstallPath, getLatestPresetVersion, getLatestRuleVersion, getPlatformConfig, getPlatformFromDir, getPresetPlatforms, getPresetVariant, getPresetVersion, getRulePlatforms, getRuleTypeConfig, getRuleVariant, getRuleVersion, getValidRuleTypes, hasBundle, hasInlineContent, isLikelyText, isPlatformDir, isPreset, isRule, isSupportedPlatform, isValidRuleType, licenseSchema, nameSchema, normalizeBundlePath, normalizePlatformEntry, normalizePlatformInput, platformIdSchema, presetBundleSchema, presetConfigSchema, presetHasPlatform, presetPublishInputSchema, presetVariantSchema, presetVersionSchema, publishVariantInputSchema, requiredDescriptionSchema, resolveResponseSchema, resolveSlug, resolvedPresetSchema, resolvedRuleSchema, ruleContentSchema, ruleCreateInputSchema, ruleDescriptionSchema, ruleHasPlatform, ruleNameSchema, rulePlatformSchema, rulePlatformTypeSchema, ruleTagSchema, ruleTagsSchema, ruleTitleSchema, ruleTypeSchema, ruleVariantSchema, ruleVersionSchema, tagSchema, tagsSchema, titleSchema, toPosixPath, toUint8Array, toUtf8String, validatePresetConfig, verifyBundledFileChecksum };
|