@planvokter/riotplan-catalyst 1.0.17-dev.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.
@@ -0,0 +1,534 @@
1
+ /**
2
+ * @packageDocumentation
3
+ * Catalyst system for RiotPlan - composable, layerable guidance packages for plan creation
4
+ */
5
+
6
+ import { z } from 'zod';
7
+
8
+ /**
9
+ * Add a catalyst to a plan's manifest
10
+ *
11
+ * Convenience function that adds a catalyst ID to the catalysts array
12
+ * without affecting other fields.
13
+ *
14
+ * @param planDirectory - Absolute path to plan directory
15
+ * @param catalystId - Catalyst ID to add
16
+ *
17
+ * @example
18
+ * ```typescript
19
+ * await addCatalystToManifest('./my-plan', '@kjerneverk/catalyst-nodejs');
20
+ * ```
21
+ */
22
+ export declare function addCatalystToManifest(planDirectory: string, catalystId: string): Promise<void>;
23
+
24
+ /**
25
+ * A single piece of content with source attribution
26
+ */
27
+ export declare interface AttributedContent {
28
+ content: string;
29
+ sourceId: string;
30
+ filename?: string;
31
+ }
32
+
33
+ /**
34
+ * A fully loaded catalyst with manifest and all facet content
35
+ */
36
+ export declare interface Catalyst {
37
+ /** Parsed manifest from catalyst.yml */
38
+ manifest: CatalystManifest;
39
+ /** Loaded content for each facet type */
40
+ facets: CatalystFacets;
41
+ /** Absolute path to the catalyst directory */
42
+ directoryPath: string;
43
+ }
44
+
45
+ /**
46
+ * Container for all loaded facet content from a catalyst
47
+ * Each facet type maps to an array of file contents
48
+ */
49
+ export declare interface CatalystFacets {
50
+ /** Guiding questions for idea exploration and shaping */
51
+ questions?: FacetContent[];
52
+ /** Constraints and rules the plan must satisfy */
53
+ constraints?: FacetContent[];
54
+ /** Templates for expected deliverables (press release, 6-pager, etc.) */
55
+ outputTemplates?: FacetContent[];
56
+ /** Context about the domain, organization, or technology */
57
+ domainKnowledge?: FacetContent[];
58
+ /** Guidance on how to run the planning process */
59
+ processGuidance?: FacetContent[];
60
+ /** Post-creation validation checks */
61
+ validationRules?: FacetContent[];
62
+ }
63
+
64
+ /**
65
+ * Options for loading a catalyst
66
+ */
67
+ export declare interface CatalystLoadOptions {
68
+ /** Whether to validate the manifest strictly */
69
+ strict?: boolean;
70
+ /** Whether to warn about declared but missing facets */
71
+ warnOnMissingFacets?: boolean;
72
+ /** Whether to warn about present but undeclared facets */
73
+ warnOnUndeclaredFacets?: boolean;
74
+ }
75
+
76
+ /**
77
+ * Result of loading a catalyst - either success or error
78
+ */
79
+ export declare interface CatalystLoadResult {
80
+ success: boolean;
81
+ catalyst?: Catalyst;
82
+ error?: string;
83
+ warnings?: string[];
84
+ }
85
+
86
+ /**
87
+ * Parsed catalyst.yml manifest
88
+ */
89
+ export declare interface CatalystManifest {
90
+ /** Catalyst identifier (NPM package name) */
91
+ id: string;
92
+ /** Human-readable name */
93
+ name: string;
94
+ /** Description of what this catalyst provides */
95
+ description: string;
96
+ /** Semver version */
97
+ version: string;
98
+ /** Declaration of which facets this catalyst provides */
99
+ facets?: {
100
+ questions?: boolean;
101
+ constraints?: boolean;
102
+ outputTemplates?: boolean;
103
+ domainKnowledge?: boolean;
104
+ processGuidance?: boolean;
105
+ validationRules?: boolean;
106
+ };
107
+ }
108
+
109
+ /**
110
+ * Inferred TypeScript types from Zod schemas
111
+ */
112
+ export declare type CatalystManifestInput = z.input<typeof CatalystManifestSchema>;
113
+
114
+ export declare type CatalystManifestOutput = z.output<typeof CatalystManifestSchema>;
115
+
116
+ /**
117
+ * Schema for catalyst.yml manifest file
118
+ *
119
+ * The manifest defines the catalyst's identity and declares which facets it provides.
120
+ * Facets are optional - a catalyst can provide any subset of the six facet types.
121
+ */
122
+ export declare const CatalystManifestSchema: z.ZodObject<{
123
+ /**
124
+ * Catalyst identifier - should match NPM package name
125
+ * @example "@kjerneverk/catalyst-nodejs"
126
+ */
127
+ id: z.ZodString;
128
+ /** Human-readable name for display */
129
+ name: z.ZodString;
130
+ /** Description of what this catalyst provides */
131
+ description: z.ZodString;
132
+ /**
133
+ * Semver version string
134
+ * @example "1.0.0" or "1.0.0-dev.0"
135
+ */
136
+ version: z.ZodString;
137
+ /**
138
+ * Declaration of which facets this catalyst provides
139
+ * If omitted, facets are auto-detected from directory structure
140
+ */
141
+ facets: z.ZodOptional<z.ZodObject<{
142
+ questions: z.ZodOptional<z.ZodBoolean>;
143
+ constraints: z.ZodOptional<z.ZodBoolean>;
144
+ outputTemplates: z.ZodOptional<z.ZodBoolean>;
145
+ domainKnowledge: z.ZodOptional<z.ZodBoolean>;
146
+ processGuidance: z.ZodOptional<z.ZodBoolean>;
147
+ validationRules: z.ZodOptional<z.ZodBoolean>;
148
+ }, "strip", z.ZodTypeAny, {
149
+ questions?: boolean | undefined;
150
+ constraints?: boolean | undefined;
151
+ outputTemplates?: boolean | undefined;
152
+ domainKnowledge?: boolean | undefined;
153
+ processGuidance?: boolean | undefined;
154
+ validationRules?: boolean | undefined;
155
+ }, {
156
+ questions?: boolean | undefined;
157
+ constraints?: boolean | undefined;
158
+ outputTemplates?: boolean | undefined;
159
+ domainKnowledge?: boolean | undefined;
160
+ processGuidance?: boolean | undefined;
161
+ validationRules?: boolean | undefined;
162
+ }>>;
163
+ }, "strip", z.ZodTypeAny, {
164
+ id: string;
165
+ name: string;
166
+ description: string;
167
+ version: string;
168
+ facets?: {
169
+ questions?: boolean | undefined;
170
+ constraints?: boolean | undefined;
171
+ outputTemplates?: boolean | undefined;
172
+ domainKnowledge?: boolean | undefined;
173
+ processGuidance?: boolean | undefined;
174
+ validationRules?: boolean | undefined;
175
+ } | undefined;
176
+ }, {
177
+ id: string;
178
+ name: string;
179
+ description: string;
180
+ version: string;
181
+ facets?: {
182
+ questions?: boolean | undefined;
183
+ constraints?: boolean | undefined;
184
+ outputTemplates?: boolean | undefined;
185
+ domainKnowledge?: boolean | undefined;
186
+ processGuidance?: boolean | undefined;
187
+ validationRules?: boolean | undefined;
188
+ } | undefined;
189
+ }>;
190
+
191
+ /**
192
+ * Facet directory names as they appear on disk
193
+ */
194
+ export declare const FACET_DIRECTORIES: {
195
+ readonly questions: "questions";
196
+ readonly constraints: "constraints";
197
+ readonly outputTemplates: "output-templates";
198
+ readonly domainKnowledge: "domain-knowledge";
199
+ readonly processGuidance: "process-guidance";
200
+ readonly validationRules: "validation-rules";
201
+ };
202
+
203
+ /**
204
+ * All valid facet types
205
+ */
206
+ export declare const FACET_TYPES: readonly ["questions", "constraints", "outputTemplates", "domainKnowledge", "processGuidance", "validationRules"];
207
+
208
+ /**
209
+ * Content loaded from a single facet file
210
+ */
211
+ export declare interface FacetContent {
212
+ /** Filename without path (e.g., "testing.md") */
213
+ filename: string;
214
+ /** Full content of the file */
215
+ content: string;
216
+ }
217
+
218
+ /**
219
+ * Mapping from facet type to directory name on disk
220
+ */
221
+ export declare type FacetDirectoryMap = Record<FacetType, string>;
222
+
223
+ export declare type FacetsDeclaration = z.infer<typeof FacetsDeclarationSchema>;
224
+
225
+ /**
226
+ * Schema for the facets declaration in catalyst.yml
227
+ * Each facet can be declared as present (true) or explicitly absent (false)
228
+ */
229
+ export declare const FacetsDeclarationSchema: z.ZodObject<{
230
+ questions: z.ZodOptional<z.ZodBoolean>;
231
+ constraints: z.ZodOptional<z.ZodBoolean>;
232
+ outputTemplates: z.ZodOptional<z.ZodBoolean>;
233
+ domainKnowledge: z.ZodOptional<z.ZodBoolean>;
234
+ processGuidance: z.ZodOptional<z.ZodBoolean>;
235
+ validationRules: z.ZodOptional<z.ZodBoolean>;
236
+ }, "strip", z.ZodTypeAny, {
237
+ questions?: boolean | undefined;
238
+ constraints?: boolean | undefined;
239
+ outputTemplates?: boolean | undefined;
240
+ domainKnowledge?: boolean | undefined;
241
+ processGuidance?: boolean | undefined;
242
+ validationRules?: boolean | undefined;
243
+ }, {
244
+ questions?: boolean | undefined;
245
+ constraints?: boolean | undefined;
246
+ outputTemplates?: boolean | undefined;
247
+ domainKnowledge?: boolean | undefined;
248
+ processGuidance?: boolean | undefined;
249
+ validationRules?: boolean | undefined;
250
+ }>;
251
+
252
+ export declare type FacetType = typeof FACET_TYPES[number];
253
+
254
+ /**
255
+ * Load a catalyst from a local directory
256
+ *
257
+ * Reads the catalyst.yml manifest, validates it, and loads all facet content
258
+ * from the directory structure.
259
+ *
260
+ * @param directoryPath - Path to catalyst directory (absolute or relative)
261
+ * @param options - Load options
262
+ * @returns Loaded catalyst
263
+ * @throws Error if manifest is missing or invalid
264
+ *
265
+ * @example
266
+ * ```typescript
267
+ * const catalyst = await loadCatalyst('./my-catalyst');
268
+ * console.log(catalyst.manifest.name);
269
+ * console.log(catalyst.facets.constraints?.length);
270
+ * ```
271
+ */
272
+ export declare function loadCatalyst(directoryPath: string, options?: CatalystLoadOptions): Promise<Catalyst>;
273
+
274
+ /**
275
+ * Load a catalyst with full error handling
276
+ *
277
+ * Like loadCatalyst but returns a result object instead of throwing
278
+ *
279
+ * @param directoryPath - Path to catalyst directory
280
+ * @param options - Load options
281
+ * @returns Result object with success/error
282
+ */
283
+ export declare function loadCatalystSafe(directoryPath: string, options?: CatalystLoadOptions): Promise<CatalystLoadResult>;
284
+
285
+ /**
286
+ * Merge multiple catalysts in order
287
+ *
288
+ * Catalysts are merged in the order provided, with later catalysts
289
+ * layering on top of earlier ones. Content is concatenated (no conflict
290
+ * resolution in v1), and each piece of content retains its source catalyst ID.
291
+ *
292
+ * @param catalysts - Ordered array of catalysts to merge (can be empty)
293
+ * @returns Merged catalyst with source attribution
294
+ *
295
+ * @example
296
+ * ```typescript
297
+ * const catalyst1 = await loadCatalyst('./base-catalyst');
298
+ * const catalyst2 = await loadCatalyst('./nodejs-catalyst');
299
+ * const merged = mergeCatalysts([catalyst1, catalyst2]);
300
+ * ```
301
+ */
302
+ export declare function mergeCatalysts(catalysts: Catalyst[]): MergedCatalyst;
303
+
304
+ /**
305
+ * Result of merging multiple catalysts
306
+ */
307
+ export declare interface MergedCatalyst {
308
+ /** Ordered list of catalyst IDs that were merged */
309
+ catalystIds: string[];
310
+ /** Merged facets with source attribution */
311
+ facets: MergedFacets;
312
+ /** Metadata about each catalyst's contribution */
313
+ contributions: Map<string, {
314
+ facetTypes: FacetType[];
315
+ contentCount: number;
316
+ }>;
317
+ }
318
+
319
+ /**
320
+ * Facets merged from multiple catalysts with source attribution
321
+ */
322
+ export declare interface MergedFacets {
323
+ questions?: AttributedContent[];
324
+ constraints?: AttributedContent[];
325
+ outputTemplates?: AttributedContent[];
326
+ domainKnowledge?: AttributedContent[];
327
+ processGuidance?: AttributedContent[];
328
+ validationRules?: AttributedContent[];
329
+ }
330
+
331
+ /**
332
+ * Plan manifest stored in plan.yaml
333
+ */
334
+ export declare interface PlanManifest {
335
+ /** Plan identifier */
336
+ id: string;
337
+ /** Human-readable title */
338
+ title: string;
339
+ /** Ordered list of catalyst IDs */
340
+ catalysts?: string[];
341
+ /** ISO timestamp of creation */
342
+ created?: string;
343
+ /** Extensible metadata */
344
+ metadata?: Record<string, string>;
345
+ }
346
+
347
+ /**
348
+ * Plan manifest stored in plan.yaml
349
+ *
350
+ * This is the metadata file for a plan that records:
351
+ * - The plan's identity (ID and title)
352
+ * - Which catalysts are associated with the plan
353
+ * - When the plan was created
354
+ * - Arbitrary metadata for extensibility
355
+ */
356
+ declare type PlanManifest_2 = PlanManifestOutput;
357
+
358
+ export declare type PlanManifestInput = z.input<typeof PlanManifestSchema>;
359
+
360
+ export declare type PlanManifestOutput = z.output<typeof PlanManifestSchema>;
361
+
362
+ /**
363
+ * Schema for plan.yaml manifest file
364
+ *
365
+ * The plan manifest gives each plan an identity and records which catalysts
366
+ * are associated with it.
367
+ */
368
+ export declare const PlanManifestSchema: z.ZodObject<{
369
+ /** Plan identifier (typically kebab-case) */
370
+ id: z.ZodString;
371
+ /** Human-readable title */
372
+ title: z.ZodString;
373
+ /**
374
+ * Ordered list of catalyst IDs associated with this plan
375
+ * Catalysts are applied in order (first = base, last = top layer)
376
+ */
377
+ catalysts: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
378
+ /** ISO timestamp of when the plan was created */
379
+ created: z.ZodOptional<z.ZodString>;
380
+ /** Extensible metadata for future use */
381
+ metadata: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
382
+ }, "strip", z.ZodTypeAny, {
383
+ id: string;
384
+ title: string;
385
+ catalysts?: string[] | undefined;
386
+ created?: string | undefined;
387
+ metadata?: Record<string, string> | undefined;
388
+ }, {
389
+ id: string;
390
+ title: string;
391
+ catalysts?: string[] | undefined;
392
+ created?: string | undefined;
393
+ metadata?: Record<string, string> | undefined;
394
+ }>;
395
+
396
+ /**
397
+ * Read a plan manifest from plan.yaml
398
+ *
399
+ * Returns null if the manifest file doesn't exist (graceful handling
400
+ * for backward compatibility with plans created before catalyst support).
401
+ * Throws if the file exists but contains invalid data.
402
+ *
403
+ * @param planDirectory - Absolute path to plan directory
404
+ * @returns Parsed and validated manifest, or null if not present
405
+ * @throws Error if manifest exists but is invalid
406
+ *
407
+ * @example
408
+ * ```typescript
409
+ * const manifest = await readPlanManifest('./my-plan');
410
+ * if (manifest) {
411
+ * console.log(`Plan: ${manifest.title}`);
412
+ * console.log(`Uses catalysts: ${manifest.catalysts?.join(', ')}`);
413
+ * }
414
+ * ```
415
+ */
416
+ export declare function readPlanManifest(planDirectory: string): Promise<PlanManifest_2 | null>;
417
+
418
+ /**
419
+ * Remove a catalyst from a plan's manifest
420
+ *
421
+ * Convenience function that removes a catalyst ID from the catalysts array.
422
+ *
423
+ * @param planDirectory - Absolute path to plan directory
424
+ * @param catalystId - Catalyst ID to remove
425
+ *
426
+ * @example
427
+ * ```typescript
428
+ * await removeCatalystFromManifest('./my-plan', '@kjerneverk/catalyst-old');
429
+ * ```
430
+ */
431
+ export declare function removeCatalystFromManifest(planDirectory: string, catalystId: string): Promise<void>;
432
+
433
+ /**
434
+ * Render all facets from a merged catalyst
435
+ *
436
+ * Returns an object with each facet type mapped to its rendered string.
437
+ * Empty strings for facets with no content.
438
+ *
439
+ * @param merged - Merged catalyst
440
+ * @returns Object with all facets rendered
441
+ */
442
+ export declare function renderAllFacets(merged: MergedCatalyst): Record<FacetType, string>;
443
+
444
+ /**
445
+ * Render merged facet content into a prompt-ready string
446
+ *
447
+ * Groups content by catalyst source and formats it for use in AI prompts.
448
+ * Each source is labeled and content is separated for readability.
449
+ *
450
+ * @param merged - Merged catalyst
451
+ * @param facetType - Facet type to render
452
+ * @returns Formatted string ready for prompt injection, or empty string if no content
453
+ *
454
+ * @example
455
+ * ```typescript
456
+ * const merged = mergeCatalysts([catalyst1, catalyst2]);
457
+ * const constraints = renderFacet(merged, 'constraints');
458
+ * // Returns:
459
+ * // From @kjerneverk/base-catalyst:
460
+ * // [content from first catalyst]
461
+ * // From @kjerneverk/nodejs-catalyst:
462
+ * // [content from second catalyst]
463
+ * ```
464
+ */
465
+ export declare function renderFacet(merged: MergedCatalyst, facetType: FacetType): string;
466
+
467
+ /**
468
+ * Resolve catalyst identifiers to directories and load them
469
+ *
470
+ * Phase 1: Only supports local directory paths (absolute or relative)
471
+ * Phase 2 (future): Will support NPM package resolution from node_modules
472
+ *
473
+ * @param identifiers - Array of catalyst paths
474
+ * @param basePath - Base path for resolving relative paths
475
+ * @param options - Load options
476
+ * @returns Array of loaded catalysts
477
+ */
478
+ export declare function resolveCatalysts(identifiers: string[], basePath?: string, options?: CatalystLoadOptions): Promise<Catalyst[]>;
479
+
480
+ /**
481
+ * Generate a summary of merged catalysts
482
+ *
483
+ * Returns human-readable text about what was merged and what each
484
+ * catalyst contributed.
485
+ *
486
+ * @param merged - Merged catalyst
487
+ * @returns Summary string
488
+ */
489
+ export declare function summarizeMerge(merged: MergedCatalyst): string;
490
+
491
+ /**
492
+ * Update specific fields in a plan manifest
493
+ *
494
+ * Reads the existing manifest (or creates a new one if it doesn't exist),
495
+ * merges the provided updates, and writes it back.
496
+ *
497
+ * @param planDirectory - Absolute path to plan directory
498
+ * @param updates - Partial manifest to merge (only specified fields are changed)
499
+ * @throws Error if updates are invalid or operation fails
500
+ *
501
+ * @example
502
+ * ```typescript
503
+ * // Add a catalyst to an existing plan
504
+ * await updatePlanManifest('./my-plan', {
505
+ * catalysts: ['@kjerneverk/catalyst-nodejs', '@kjerneverk/catalyst-react'],
506
+ * });
507
+ * ```
508
+ */
509
+ export declare function updatePlanManifest(planDirectory: string, updates: Partial<PlanManifest_2>): Promise<void>;
510
+
511
+ /**
512
+ * Write a plan manifest to plan.yaml
513
+ *
514
+ * Creates or overwrites the plan.yaml file with the provided manifest.
515
+ * Automatically timestamps the manifest if `created` is not provided.
516
+ *
517
+ * @param planDirectory - Absolute path to plan directory
518
+ * @param manifest - Manifest to write
519
+ * @throws Error if manifest is invalid or write fails
520
+ *
521
+ * @example
522
+ * ```typescript
523
+ * const manifest: PlanManifest = {
524
+ * id: 'add-user-auth',
525
+ * title: 'Add User Authentication',
526
+ * catalysts: ['@kjerneverk/catalyst-nodejs'],
527
+ * created: new Date().toISOString(),
528
+ * };
529
+ * await writePlanManifest('./my-plan', manifest);
530
+ * ```
531
+ */
532
+ export declare function writePlanManifest(planDirectory: string, manifest: PlanManifest_2): Promise<void>;
533
+
534
+ export { }