@almadar/patterns 2.8.13 → 2.9.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/helpers/pattern-recommender.d.ts +89 -0
- package/dist/helpers/prompt-helpers.d.ts +78 -0
- package/dist/index.d.ts +16 -29665
- package/dist/pattern-types.d.ts +2840 -0
- package/package.json +2 -2
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Pattern Recommender
|
|
3
|
+
*
|
|
4
|
+
* Maps transition context (entity fields, domain category, UI state) to
|
|
5
|
+
* ranked pattern suggestions using the registry's `suggestedFor` metadata,
|
|
6
|
+
* category matching, and entity field type heuristics.
|
|
7
|
+
*
|
|
8
|
+
* Used by the design-transition tool to include top-N recommendations
|
|
9
|
+
* in the LLM prompt context.
|
|
10
|
+
*
|
|
11
|
+
* @packageDocumentation
|
|
12
|
+
*/
|
|
13
|
+
import type { PatternType } from '../pattern-types.js';
|
|
14
|
+
/**
|
|
15
|
+
* Context for pattern recommendation.
|
|
16
|
+
*/
|
|
17
|
+
export interface RecommendationContext {
|
|
18
|
+
/** Current state name (e.g., "Browsing", "Creating") */
|
|
19
|
+
state?: string;
|
|
20
|
+
/** Triggering event (e.g., "INIT", "CREATE", "VIEW") */
|
|
21
|
+
event?: string;
|
|
22
|
+
/** Target UI slot */
|
|
23
|
+
slot?: 'main' | 'modal' | 'drawer' | 'sidebar' | 'overlay';
|
|
24
|
+
/** Domain category */
|
|
25
|
+
domainCategory?: string;
|
|
26
|
+
/** Entity field types present */
|
|
27
|
+
entityFieldTypes?: string[];
|
|
28
|
+
/** Entity has enum fields */
|
|
29
|
+
hasEnumFields?: boolean;
|
|
30
|
+
/** Entity has date/timestamp fields */
|
|
31
|
+
hasDateFields?: boolean;
|
|
32
|
+
/** Entity has numeric fields */
|
|
33
|
+
hasNumericFields?: boolean;
|
|
34
|
+
/** Entity has relation fields */
|
|
35
|
+
hasRelationFields?: boolean;
|
|
36
|
+
/** Entity has image/url fields */
|
|
37
|
+
hasMediaFields?: boolean;
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* A pattern recommendation with score and reasoning.
|
|
41
|
+
*/
|
|
42
|
+
export interface PatternRecommendation {
|
|
43
|
+
/** Pattern type name */
|
|
44
|
+
pattern: PatternType;
|
|
45
|
+
/** Relevance score (0-100) */
|
|
46
|
+
score: number;
|
|
47
|
+
/** Why this pattern was recommended */
|
|
48
|
+
reason: string;
|
|
49
|
+
/** Pattern category */
|
|
50
|
+
category: string;
|
|
51
|
+
/** Pattern description */
|
|
52
|
+
description: string;
|
|
53
|
+
/** Key props to use */
|
|
54
|
+
keyProps: string[];
|
|
55
|
+
}
|
|
56
|
+
/**
|
|
57
|
+
* Recommend patterns for a given context.
|
|
58
|
+
*
|
|
59
|
+
* Scoring algorithm:
|
|
60
|
+
* 1. suggestedFor match with domain keywords (+30)
|
|
61
|
+
* 2. suggestedFor match with event keywords (+25)
|
|
62
|
+
* 3. Category affinity with slot (+20)
|
|
63
|
+
* 4. Category affinity with state (+15)
|
|
64
|
+
* 5. Entity field type bonus (+10 per matching heuristic)
|
|
65
|
+
* 6. Entity-aware bonus for display patterns (+5)
|
|
66
|
+
*
|
|
67
|
+
* @returns Ranked pattern recommendations, highest score first
|
|
68
|
+
*/
|
|
69
|
+
export declare function recommendPatterns(context: RecommendationContext, maxResults?: number): PatternRecommendation[];
|
|
70
|
+
/**
|
|
71
|
+
* Build recommendation context from entity field information.
|
|
72
|
+
* Analyzes field types to set the boolean flags used by the recommender.
|
|
73
|
+
*/
|
|
74
|
+
export declare function buildRecommendationContext(options: {
|
|
75
|
+
state?: string;
|
|
76
|
+
event?: string;
|
|
77
|
+
slot?: 'main' | 'modal' | 'drawer' | 'sidebar' | 'overlay';
|
|
78
|
+
domainCategory?: string;
|
|
79
|
+
entityFields?: Array<{
|
|
80
|
+
name: string;
|
|
81
|
+
type: string;
|
|
82
|
+
values?: string[];
|
|
83
|
+
}>;
|
|
84
|
+
}): RecommendationContext;
|
|
85
|
+
/**
|
|
86
|
+
* Format recommendations as a concise prompt section.
|
|
87
|
+
* Used to inject into the design-transition tool's user prompt.
|
|
88
|
+
*/
|
|
89
|
+
export declare function formatRecommendationsForPrompt(recommendations: PatternRecommendation[]): string;
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Prompt Helpers for @almadar/patterns
|
|
3
|
+
*
|
|
4
|
+
* Helper functions for generating prompts/documentation from pattern registry.
|
|
5
|
+
* Used by @almadar/skills package and other tools.
|
|
6
|
+
*
|
|
7
|
+
* @packageDocumentation
|
|
8
|
+
*/
|
|
9
|
+
import type { PatternType } from '../pattern-types.js';
|
|
10
|
+
type PatternEntry = {
|
|
11
|
+
category?: string;
|
|
12
|
+
description?: string;
|
|
13
|
+
propsSchema?: Record<string, {
|
|
14
|
+
types?: string[];
|
|
15
|
+
required?: boolean;
|
|
16
|
+
}>;
|
|
17
|
+
entityAware?: boolean;
|
|
18
|
+
};
|
|
19
|
+
/**
|
|
20
|
+
* Get patterns grouped by category.
|
|
21
|
+
* Categories are derived from pattern registry metadata.
|
|
22
|
+
*/
|
|
23
|
+
export declare function getPatternsGroupedByCategory(): Record<string, PatternType[]>;
|
|
24
|
+
/**
|
|
25
|
+
* Get compact pattern props reference table.
|
|
26
|
+
* Generates markdown table of pattern names and their key props.
|
|
27
|
+
*/
|
|
28
|
+
export declare function getPatternPropsCompact(): string;
|
|
29
|
+
/**
|
|
30
|
+
* Get pattern action props reference.
|
|
31
|
+
* Lists patterns that have action/event props (buttons, forms, etc.).
|
|
32
|
+
*/
|
|
33
|
+
export declare function getPatternActionsRef(): string;
|
|
34
|
+
/**
|
|
35
|
+
* Generate pattern description from metadata.
|
|
36
|
+
* Auto-generates human-readable description from pattern props schema.
|
|
37
|
+
*/
|
|
38
|
+
export declare function generatePatternDescription(patternType: string): string;
|
|
39
|
+
/**
|
|
40
|
+
* Get all pattern types as array.
|
|
41
|
+
*/
|
|
42
|
+
export declare function getAllPatternTypes(): PatternType[];
|
|
43
|
+
/**
|
|
44
|
+
* Get pattern metadata for a specific pattern.
|
|
45
|
+
*/
|
|
46
|
+
export declare function getPatternMetadata(patternType: string): PatternEntry | null;
|
|
47
|
+
/**
|
|
48
|
+
* Get patterns allowed in .orb render-ui trees.
|
|
49
|
+
*
|
|
50
|
+
* Returns all non-entity patterns (atoms/molecules) plus the allowed
|
|
51
|
+
* entity-aware exceptions (data-list, data-grid, search-input, form-section, meter).
|
|
52
|
+
* Excludes game-specific, debug, and template patterns.
|
|
53
|
+
*
|
|
54
|
+
* Grouped by registry category with description and key props.
|
|
55
|
+
*/
|
|
56
|
+
export declare function getOrbAllowedPatterns(): Record<string, Array<{
|
|
57
|
+
name: string;
|
|
58
|
+
description: string;
|
|
59
|
+
keyProps: string[];
|
|
60
|
+
}>>;
|
|
61
|
+
/**
|
|
62
|
+
* Get compact markdown reference of .orb-allowed patterns.
|
|
63
|
+
* Derives everything from the registry. No hardcoded pattern lists.
|
|
64
|
+
*/
|
|
65
|
+
export declare function getOrbAllowedPatternsCompact(): string;
|
|
66
|
+
/**
|
|
67
|
+
* Get a slim one-line-per-pattern catalog for Gate 3.5 pattern selection.
|
|
68
|
+
* Format: "- pattern-name: one-line description"
|
|
69
|
+
* Much smaller than the full compact reference (~800 tokens vs ~3,500).
|
|
70
|
+
*/
|
|
71
|
+
export declare function getOrbAllowedPatternsSlim(): string;
|
|
72
|
+
/**
|
|
73
|
+
* Get compact markdown reference for a filtered subset of patterns.
|
|
74
|
+
* Used by Gate 4 after Gate 3.5 selects the relevant patterns.
|
|
75
|
+
* Includes all props (not just top 5) since we're showing fewer patterns.
|
|
76
|
+
*/
|
|
77
|
+
export declare function getOrbAllowedPatternsFiltered(patternNames: string[]): string;
|
|
78
|
+
export {};
|