@agentrules/core 0.0.10 → 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/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
- declare const titleSchema: z.ZodString;
11
- declare const descriptionSchema: z.ZodString;
12
- declare const tagSchema: z.ZodString;
13
- declare const tagsSchema: z.ZodArray<z.ZodString>;
14
- declare const slugSchema: z.ZodString;
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,142 +70,318 @@ 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
- platform: z.ZodEnum<{
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
- path: z.ZodOptional<z.ZodString>;
34
- ignore: z.ZodOptional<z.ZodArray<z.ZodString>>;
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
- contents: z.ZodString;
94
+ content: z.ZodString;
41
95
  }, z.core.$strip>;
42
96
  /**
43
- * Schema for what clients send to publish a preset.
44
- * Version is optional major version. Registry assigns full MAJOR.MINOR.
97
+ * Schema for per-platform variant in publish input.
45
98
  */
46
- declare const presetPublishInputSchema: z.ZodObject<{
47
- slug: z.ZodString;
99
+ declare const publishVariantInputSchema: z.ZodObject<{
48
100
  platform: z.ZodEnum<{
49
101
  opencode: "opencode";
50
102
  codex: "codex";
51
103
  claude: "claude";
52
104
  cursor: "cursor";
53
105
  }>;
54
- title: z.ZodString;
55
- description: z.ZodString;
56
- tags: z.ZodArray<z.ZodString>;
57
- license: z.ZodString;
58
- licenseContent: z.ZodOptional<z.ZodString>;
59
- readmeContent: z.ZodOptional<z.ZodString>;
60
- features: z.ZodOptional<z.ZodArray<z.ZodString>>;
61
- installMessage: z.ZodOptional<z.ZodString>;
62
106
  files: z.ZodArray<z.ZodObject<{
63
107
  path: z.ZodString;
64
108
  size: z.ZodNumber;
65
109
  checksum: z.ZodString;
66
- contents: z.ZodString;
110
+ content: z.ZodString;
67
111
  }, z.core.$strip>>;
68
- version: z.ZodOptional<z.ZodNumber>;
112
+ readmeContent: z.ZodOptional<z.ZodString>;
113
+ licenseContent: z.ZodOptional<z.ZodString>;
114
+ installMessage: z.ZodOptional<z.ZodString>;
69
115
  }, z.core.$strip>;
70
116
  /**
71
- * Schema for what registries store and return.
72
- * Includes version (required) - full MAJOR.MINOR format assigned by registry.
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"
73
124
  */
74
- declare const presetBundleSchema: z.ZodObject<{
125
+ declare const presetPublishInputSchema: z.ZodObject<{
126
+ name: z.ZodString;
75
127
  title: z.ZodString;
76
128
  description: z.ZodString;
77
129
  tags: z.ZodArray<z.ZodString>;
78
130
  license: z.ZodString;
79
- platform: z.ZodEnum<{
80
- opencode: "opencode";
81
- codex: "codex";
82
- claude: "claude";
83
- cursor: "cursor";
84
- }>;
85
131
  features: z.ZodOptional<z.ZodArray<z.ZodString>>;
86
- slug: z.ZodString;
87
- licenseContent: z.ZodOptional<z.ZodString>;
88
- readmeContent: z.ZodOptional<z.ZodString>;
89
- installMessage: z.ZodOptional<z.ZodString>;
90
- files: z.ZodArray<z.ZodObject<{
91
- path: z.ZodString;
92
- size: z.ZodNumber;
93
- checksum: z.ZodString;
94
- contents: z.ZodString;
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>;
95
148
  }, z.core.$strip>>;
96
- version: z.ZodString;
149
+ version: z.ZodOptional<z.ZodNumber>;
97
150
  }, z.core.$strip>;
98
- declare const presetSchema: z.ZodObject<{
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<{
99
156
  title: z.ZodString;
100
157
  description: z.ZodString;
101
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>>;
102
176
  license: z.ZodString;
103
- platform: z.ZodEnum<{
104
- opencode: "opencode";
105
- codex: "codex";
106
- claude: "claude";
107
- cursor: "cursor";
108
- }>;
109
- version: z.ZodString;
110
177
  features: z.ZodOptional<z.ZodArray<z.ZodString>>;
111
178
  slug: z.ZodString;
112
- name: z.ZodString;
113
- bundleUrl: z.ZodString;
114
- fileCount: z.ZodNumber;
115
- totalSize: z.ZodNumber;
116
- }, z.core.$strip>;
117
- declare const presetIndexSchema: z.ZodRecord<z.ZodString, z.ZodObject<{
118
- title: z.ZodString;
119
- description: z.ZodString;
120
- tags: z.ZodArray<z.ZodString>;
121
- license: z.ZodString;
122
- platform: z.ZodEnum<{
123
- opencode: "opencode";
124
- codex: "codex";
125
- claude: "claude";
126
- cursor: "cursor";
127
- }>;
128
179
  version: z.ZodString;
129
- features: z.ZodOptional<z.ZodArray<z.ZodString>>;
130
- slug: z.ZodString;
131
- name: z.ZodString;
132
- bundleUrl: z.ZodString;
133
- fileCount: z.ZodNumber;
134
- totalSize: z.ZodNumber;
135
- }, z.core.$strip>>;
180
+ }, z.core.$strip>;
136
181
 
137
182
  //#endregion
138
183
  //#region src/platform/types.d.ts
139
184
  /**
140
- * Single source of truth for platform IDs.
141
- * Add new platforms here - types and config will follow.
185
+ * Platform and rule type definitions.
142
186
  */
143
187
  declare const PLATFORM_ID_TUPLE: readonly ["opencode", "codex", "claude", "cursor"];
144
- /** Union type of supported platform IDs, derived from PLATFORM_ID_TUPLE */
188
+ /** Union type of supported platform IDs */
145
189
  type PlatformId = (typeof PLATFORM_ID_TUPLE)[number];
146
- /** Configuration for a platform's directory paths */
147
- type PlatformConfig = {
148
- /** Directory name for project installs (e.g., ".opencode") */
190
+ /** File format for a rule type */
191
+ type RuleFileFormat = "markdown" | "typescript" | "mdc";
192
+ /** Configuration for a single rule type */
193
+ type RuleTypeConfig = {
194
+ /** Human-readable description */
195
+ description: string;
196
+ /** File format */
197
+ format: RuleFileFormat;
198
+ /** File extension (without dot) */
199
+ extension: string;
200
+ /**
201
+ * Install path pattern relative to project root.
202
+ * Use {name} as placeholder for the rule slug/filename.
203
+ * null if project install not supported.
204
+ */
205
+ projectPath: string | null;
206
+ /**
207
+ * Install path pattern for global/user install.
208
+ * Use ~ for home directory.
209
+ * null if global install not supported.
210
+ */
211
+ globalPath: string | null;
212
+ };
213
+ /** Platform configuration with all its rule types */
214
+ type PlatformRuleConfig = {
215
+ /** Human-readable platform name */
216
+ label: string;
217
+ /** Platform's project directory (e.g., ".opencode") */
149
218
  projectDir: string;
150
- /** Path for global installs (e.g., "~/.config/opencode") */
151
- globalDir: string;
219
+ /** Platform's global config directory (null if not supported) */
220
+ globalDir: string | null;
221
+ /** Rule types supported by this platform */
222
+ types: Record<string, RuleTypeConfig>;
152
223
  };
224
+ /**
225
+ * Discriminated union of valid platform + type combinations.
226
+ * Must be kept in sync with PLATFORMS in config.ts.
227
+ */
228
+ type PlatformRuleType = {
229
+ platform: "opencode";
230
+ type: "instruction" | "agent" | "command" | "tool";
231
+ } | {
232
+ platform: "claude";
233
+ type: "instruction" | "command" | "skill";
234
+ } | {
235
+ platform: "cursor";
236
+ type: "rule";
237
+ } | {
238
+ platform: "codex";
239
+ type: "instruction" | "command";
240
+ };
241
+ /** Extract rule type for a specific platform */
242
+ type RuleTypeForPlatform<P extends PlatformId> = Extract<PlatformRuleType, {
243
+ platform: P;
244
+ }>["type"];
245
+ /** Union of all valid rule types across all platforms */
246
+ type RuleType = PlatformRuleType["type"];
153
247
 
154
248
  //#endregion
155
249
  //#region src/platform/config.d.ts
156
- /** List of supported platform IDs as a readonly tuple */
157
- declare const PLATFORM_IDS: readonly ["opencode", "codex", "claude", "cursor"];
250
+ declare const PLATFORM_IDS: [PlatformId, ...PlatformId[]];
158
251
  /**
159
- * Platform-specific configuration.
160
- * Single source of truth for all platform paths.
252
+ * Platform configuration including supported rule types and install paths.
161
253
  */
162
- declare const PLATFORMS: Record<PlatformId, PlatformConfig>;
254
+ declare const PLATFORMS: {
255
+ readonly opencode: {
256
+ readonly label: "OpenCode";
257
+ readonly projectDir: ".opencode";
258
+ readonly globalDir: "~/.config/opencode";
259
+ readonly types: {
260
+ readonly instruction: {
261
+ readonly description: "Project instructions";
262
+ readonly format: "markdown";
263
+ readonly extension: "md";
264
+ readonly projectPath: "AGENTS.md";
265
+ readonly globalPath: "~/.config/opencode/AGENTS.md";
266
+ };
267
+ readonly agent: {
268
+ readonly description: "Specialized AI agent";
269
+ readonly format: "markdown";
270
+ readonly extension: "md";
271
+ readonly projectPath: ".opencode/agent/{name}.md";
272
+ readonly globalPath: "~/.config/opencode/agent/{name}.md";
273
+ };
274
+ readonly command: {
275
+ readonly description: "Custom slash command";
276
+ readonly format: "markdown";
277
+ readonly extension: "md";
278
+ readonly projectPath: ".opencode/command/{name}.md";
279
+ readonly globalPath: "~/.config/opencode/command/{name}.md";
280
+ };
281
+ readonly tool: {
282
+ readonly description: "Custom tool";
283
+ readonly format: "typescript";
284
+ readonly extension: "ts";
285
+ readonly projectPath: ".opencode/tool/{name}.ts";
286
+ readonly globalPath: "~/.config/opencode/tool/{name}.ts";
287
+ };
288
+ };
289
+ };
290
+ readonly claude: {
291
+ readonly label: "Claude Code";
292
+ readonly projectDir: ".claude";
293
+ readonly globalDir: "~/.claude";
294
+ readonly types: {
295
+ readonly instruction: {
296
+ readonly description: "Project instructions";
297
+ readonly format: "markdown";
298
+ readonly extension: "md";
299
+ readonly projectPath: "CLAUDE.md";
300
+ readonly globalPath: "~/.claude/CLAUDE.md";
301
+ };
302
+ readonly command: {
303
+ readonly description: "Custom slash command";
304
+ readonly format: "markdown";
305
+ readonly extension: "md";
306
+ readonly projectPath: ".claude/commands/{name}.md";
307
+ readonly globalPath: "~/.claude/commands/{name}.md";
308
+ };
309
+ readonly skill: {
310
+ readonly description: "Custom skill";
311
+ readonly format: "markdown";
312
+ readonly extension: "md";
313
+ readonly projectPath: ".claude/skills/{name}/SKILL.md";
314
+ readonly globalPath: "~/.claude/skills/{name}/SKILL.md";
315
+ };
316
+ };
317
+ };
318
+ readonly cursor: {
319
+ readonly label: "Cursor";
320
+ readonly projectDir: ".cursor";
321
+ readonly globalDir: "~/.cursor";
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
+ };
330
+ readonly rule: {
331
+ readonly description: "Custom rule";
332
+ readonly format: "mdc";
333
+ readonly extension: "mdc";
334
+ readonly projectPath: ".cursor/rules/{name}.mdc";
335
+ readonly globalPath: null;
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
+ };
344
+ };
345
+ };
346
+ readonly codex: {
347
+ readonly label: "Codex";
348
+ readonly projectDir: ".codex";
349
+ readonly globalDir: "~/.codex";
350
+ readonly types: {
351
+ readonly instruction: {
352
+ readonly description: "Project instructions";
353
+ readonly format: "markdown";
354
+ readonly extension: "md";
355
+ readonly projectPath: "AGENTS.md";
356
+ readonly globalPath: "~/.codex/AGENTS.md";
357
+ };
358
+ readonly command: {
359
+ readonly description: "Custom prompt";
360
+ readonly format: "markdown";
361
+ readonly extension: "md";
362
+ readonly projectPath: null;
363
+ readonly globalPath: "~/.codex/prompts/{name}.md";
364
+ };
365
+ };
366
+ };
367
+ };
368
+ /** Valid rule types for each platform. Must be kept in sync with PLATFORMS. */
369
+ declare const PLATFORM_RULE_TYPES: {
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[];
377
+ /** Check if a type is valid for a given platform */
378
+ declare function isValidRuleType(platform: PlatformId, type: string): boolean;
379
+ /** Get the configuration for a specific platform + type combination */
380
+ declare function getRuleTypeConfig(platform: PlatformId, type: string): RuleTypeConfig | undefined;
381
+ /** Get the install path for a rule, replacing {name} placeholder */
382
+ declare function getInstallPath(platform: PlatformId, type: string, name: string, location?: "project" | "global"): string | null;
383
+ /** Get platform configuration */
384
+ declare function getPlatformConfig(platform: PlatformId): PlatformRuleConfig;
163
385
 
164
386
  //#endregion
165
387
  //#region src/platform/utils.d.ts
@@ -177,7 +399,40 @@ declare function getPlatformFromDir(dirName: string): PlatformId | undefined;
177
399
 
178
400
  //#endregion
179
401
  //#region src/preset/types.d.ts
180
- type PresetConfig = {
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 = {
181
436
  $schema?: string;
182
437
  name: string;
183
438
  title: string;
@@ -186,124 +441,499 @@ type PresetConfig = {
186
441
  tags?: string[];
187
442
  features?: string[];
188
443
  license: string;
189
- platform: PlatformId;
190
- /** Path to config files. Defaults to platform's projectDir (e.g., ".claude") */
191
- path?: string;
192
444
  /** Additional patterns to exclude from bundle (glob patterns) */
193
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[];
194
464
  };
195
465
  type BundledFile = {
196
466
  path: string;
197
467
  /** File size in bytes */
198
468
  size: number;
199
469
  checksum: string;
200
- contents: string;
470
+ content: string;
471
+ };
472
+ /**
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;
201
485
  };
202
486
  /**
203
- * What clients send to publish a preset.
487
+ * What clients send to publish a preset (multi-platform).
488
+ *
489
+ * One publish call creates ONE version with ALL platform variants.
204
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"
205
494
  */
206
495
  type PresetPublishInput = {
207
- slug: string;
208
- platform: PlatformId;
496
+ name: string;
209
497
  title: string;
210
498
  description: string;
211
499
  tags: string[];
212
500
  license: string;
213
- licenseContent?: string;
214
- readmeContent?: string;
215
501
  features?: string[];
216
- installMessage?: string;
217
- files: BundledFile[];
502
+ /** Platform variants - each contains files for that platform */
503
+ variants: PublishVariantInput[];
218
504
  /** Major version. Defaults to 1 if not specified. */
219
505
  version?: number;
220
506
  };
221
507
  /**
222
- * What registries store and return.
223
- * Includes version (required) - full MAJOR.MINOR format assigned by registry.
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.
224
512
  */
225
- type PresetBundle = Omit<PresetPublishInput, "version"> & {
226
- /** Full version in MAJOR.MINOR format (e.g., "1.3", "2.1") */
227
- version: string;
228
- };
229
- type Preset = {
513
+ type PresetBundle = {
230
514
  name: string;
231
- slug: string;
232
515
  platform: PlatformId;
233
516
  title: string;
234
- version: string;
235
517
  description: string;
236
518
  tags: string[];
237
519
  license: string;
238
520
  features?: string[];
239
- bundleUrl: string;
240
- fileCount: number;
241
- totalSize: number;
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;
242
529
  };
243
- type PresetIndex = Record<string, Preset>;
244
530
  type PresetFileInput = {
245
531
  path: string;
246
- contents: ArrayBuffer | ArrayBufferView | string;
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;
247
546
  };
547
+ /**
548
+ * Preset input - what the CLI builds after loading files.
549
+ * Always uses platformFiles array (works for single or multi-platform).
550
+ */
248
551
  type PresetInput = {
249
- slug: string;
552
+ name: string;
250
553
  config: PresetConfig;
251
- files: PresetFileInput[];
252
- /** Install message from INSTALL.txt file */
554
+ /** Files for each platform */
555
+ platformFiles: PlatformFiles[];
556
+ /** Shared install message (fallback for platforms without their own) */
253
557
  installMessage?: string;
558
+ /** Shared README (fallback for platforms without their own) */
254
559
  readmeContent?: string;
560
+ /** Shared LICENSE (fallback for platforms without their own) */
255
561
  licenseContent?: string;
256
562
  };
257
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
+
258
879
  //#endregion
259
880
  //#region src/builder/registry.d.ts
260
881
  /**
261
882
  * Directory name for bundle files in static registry output.
262
883
  * Used by `agentrules registry build` to structure output.
263
884
  */
264
- declare const STATIC_BUNDLE_DIR = "r";
885
+ declare const STATIC_BUNDLE_DIR = "registry";
265
886
  /**
266
- * Options for building a PresetPublishInput (for CLI publish command).
887
+ * Options for building a PresetPublishInput.
267
888
  */
268
889
  type BuildPresetPublishInputOptions = {
890
+ /** Preset input (single or multi-platform) */
269
891
  preset: PresetInput;
270
892
  /** Major version. Defaults to 1 if not specified. */
271
893
  version?: number;
272
894
  };
273
895
  /**
274
896
  * Builds a PresetPublishInput from preset input.
275
- * Used by CLI to prepare data for publishing to a registry.
897
+ *
898
+ * PresetInput always has platformFiles array (unified format).
276
899
  */
277
900
  declare function buildPresetPublishInput(options: BuildPresetPublishInputOptions): Promise<PresetPublishInput>;
278
901
  /**
279
902
  * Options for building a static registry.
280
903
  */
281
904
  type BuildPresetRegistryOptions = {
905
+ /** Presets to include (single or multi-platform) */
282
906
  presets: PresetInput[];
283
907
  /**
284
908
  * Optional base path or URL prefix for bundle locations.
285
- * Format: {bundleBase}/{STATIC_BUNDLE_DIR}/{slug}/{platform}
909
+ * Format: {bundleBase}/{STATIC_BUNDLE_DIR}/{slug}/{platform}/{version}
286
910
  * Default: no prefix (bundleUrl starts with STATIC_BUNDLE_DIR)
287
911
  */
288
912
  bundleBase?: string;
289
913
  };
290
914
  type BuildPresetRegistryResult = {
291
- entries: Preset[];
292
- index: PresetIndex;
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) */
293
918
  bundles: PresetBundle[];
294
919
  };
295
920
  /**
296
- * Builds a static registry with entries, index, and bundles.
297
- * Used for building static registry files (e.g., community-presets).
298
- * Each preset uses its version from config (default: major 1, minor 0).
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
299
926
  */
300
927
  declare function buildPresetRegistry(options: BuildPresetRegistryOptions): Promise<BuildPresetRegistryResult>;
301
928
 
302
929
  //#endregion
303
930
  //#region src/builder/utils.d.ts
304
931
  declare function cleanInstallMessage(value: unknown): string | undefined;
305
- declare function encodeItemName(slug: string, platform: PlatformId): string;
306
- declare function validatePresetConfig(config: unknown, slug: string): PresetConfig;
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;
307
937
 
308
938
  //#endregion
309
939
  //#region src/client/bundle.d.ts
@@ -315,26 +945,19 @@ declare function toUtf8String(payload: ArrayBuffer | ArrayBufferView): string;
315
945
  //#endregion
316
946
  //#region src/client/registry.d.ts
317
947
  /**
318
- * Resolved preset with absolute bundle URL
948
+ * Fetches a bundle from an absolute URL.
319
949
  */
320
- type ResolvedPreset = {
321
- preset: Preset;
322
- bundleUrl: string;
323
- };
950
+ declare function fetchBundle(bundleUrl: string): Promise<PresetBundle>;
324
951
  /**
325
- * Resolves a preset from the registry via API endpoint.
326
- * Returns the entry metadata and the absolute bundle URL.
952
+ * Resolves a slug to get all versions and platform variants.
327
953
  *
328
954
  * @param baseUrl - Registry base URL
329
- * @param slug - Preset slug
330
- * @param platform - Target platform
331
- * @param version - Version to resolve (defaults to "latest")
332
- */
333
- declare function resolvePreset(baseUrl: string, slug: string, platform: PlatformId, version?: string): Promise<ResolvedPreset>;
334
- /**
335
- * Fetches a bundle from an absolute URL or resolves it relative to the registry.
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
336
959
  */
337
- declare function fetchBundle(bundleUrl: string): Promise<PresetBundle>;
960
+ declare function resolveSlug(baseUrl: string, slug: string, version?: string): Promise<ResolveResponse | null>;
338
961
 
339
962
  //#endregion
340
963
  //#region src/constants.d.ts
@@ -351,16 +974,18 @@ declare const PRESET_SCHEMA_URL = "https://agentrules.directory/schema/agentrule
351
974
  declare const LATEST_VERSION = "latest";
352
975
  /**
353
976
  * API endpoint paths (relative to registry base URL).
977
+ *
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
354
981
  */
355
982
  declare const API_ENDPOINTS: {
356
- /** Preset endpoints */
983
+ /** Preset endpoints (for publishing) */
357
984
  readonly presets: {
358
985
  /** Base path for preset operations */
359
986
  readonly base: "api/presets";
360
- /** Get preset by slug, platform, and version (defaults to "latest") */
361
- readonly get: (slug: string, platform: string, version?: string) => string;
362
- /** Unpublish preset version */
363
- readonly unpublish: (slug: string, platform: string, version: string) => string;
987
+ /** Unpublish preset version (unpublishes all platform variants for that version) */
988
+ readonly unpublish: (slug: string, version: string) => string;
364
989
  };
365
990
  /** Auth endpoints */
366
991
  readonly auth: {
@@ -371,10 +996,121 @@ declare const API_ENDPOINTS: {
371
996
  /** Device token exchange */
372
997
  readonly deviceToken: "api/auth/device/token";
373
998
  };
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
+ };
374
1015
  };
375
1016
 
1017
+ //#endregion
1018
+ //#region src/rule/schema.d.ts
1019
+ /**
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
1026
+ */
1027
+ declare const ruleNameSchema: z.ZodString;
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;
1040
+ /**
1041
+ * Discriminated union schema for platform + type combinations.
1042
+ * Each platform has its own set of valid types.
1043
+ */
1044
+ declare const rulePlatformTypeSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
1045
+ platform: z.ZodLiteral<"opencode">;
1046
+ type: z.ZodEnum<{
1047
+ instruction: "instruction";
1048
+ agent: "agent";
1049
+ command: "command";
1050
+ tool: "tool";
1051
+ }>;
1052
+ }, z.core.$strip>, z.ZodObject<{
1053
+ platform: z.ZodLiteral<"claude">;
1054
+ type: z.ZodEnum<{
1055
+ instruction: "instruction";
1056
+ command: "command";
1057
+ skill: "skill";
1058
+ }>;
1059
+ }, z.core.$strip>, z.ZodObject<{
1060
+ platform: z.ZodLiteral<"cursor">;
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>;
1110
+
376
1111
  //#endregion
377
1112
  //#region src/utils/diff.d.ts
1113
+ /** Re-export platform-rule types for convenience */
378
1114
  type DiffPreviewOptions = {
379
1115
  context?: number;
380
1116
  maxLines?: number;
@@ -397,4 +1133,4 @@ declare function toUint8Array(payload: ArrayBuffer | ArrayBufferView): Uint8Arra
397
1133
  declare function normalizeBundlePath(value: string): string;
398
1134
 
399
1135
  //#endregion
400
- export { AGENT_RULES_DIR, API_ENDPOINTS, BuildPresetPublishInputOptions, BuildPresetRegistryOptions, BuildPresetRegistryResult, BundledFile, COMMON_LICENSES, CommonLicense, DiffPreviewOptions, LATEST_VERSION, PLATFORMS, PLATFORM_IDS, PLATFORM_ID_TUPLE, PRESET_CONFIG_FILENAME, PRESET_SCHEMA_URL, PlatformConfig, PlatformId, Preset, PresetBundle, PresetConfig, PresetFileInput, PresetIndex, PresetInput, PresetPublishInput, ResolvedPreset, STATIC_BUNDLE_DIR, buildPresetPublishInput, buildPresetRegistry, bundledFileSchema, cleanInstallMessage, createDiffPreview, decodeBundledFile, decodeUtf8, descriptionSchema, encodeItemName, encodeUtf8, fetchBundle, getPlatformFromDir, isLikelyText, isPlatformDir, isSupportedPlatform, licenseSchema, normalizeBundlePath, normalizePlatformInput, platformIdSchema, presetBundleSchema, presetConfigSchema, presetIndexSchema, presetPublishInputSchema, presetSchema, resolvePreset, slugSchema, tagSchema, tagsSchema, titleSchema, toPosixPath, toUint8Array, toUtf8String, validatePresetConfig, verifyBundledFileChecksum };
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 };