@hyperfixi/patterns-reference 2.0.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 +311 -0
- package/data/hyperfixi-extensions.json +106 -0
- package/dist/api/index.d.mts +59 -0
- package/dist/api/index.d.ts +59 -0
- package/dist/api/index.js +769 -0
- package/dist/api/index.mjs +731 -0
- package/dist/index-CBoczxz7.d.mts +296 -0
- package/dist/index-CBoczxz7.d.ts +296 -0
- package/dist/index.d.mts +403 -0
- package/dist/index.d.ts +403 -0
- package/dist/index.js +1312 -0
- package/dist/index.mjs +1240 -0
- package/dist/llm-DMR6tmkM.d.ts +123 -0
- package/dist/llm-UOOBXwj3.d.mts +123 -0
- package/dist/sync/index.d.mts +42 -0
- package/dist/sync/index.d.ts +42 -0
- package/dist/sync/index.js +28 -0
- package/dist/sync/index.mjs +23 -0
- package/package.json +92 -0
- package/src/adapters/index.ts +7 -0
- package/src/adapters/llm-adapter.ts +394 -0
- package/src/api/index.ts +52 -0
- package/src/api/language-docs.ts +529 -0
- package/src/api/llm.ts +357 -0
- package/src/api/patterns.ts +276 -0
- package/src/api/roles.ts +401 -0
- package/src/api/translations.ts +283 -0
- package/src/database/connection.ts +85 -0
- package/src/index.ts +266 -0
- package/src/registry/index.ts +7 -0
- package/src/registry/patterns-provider.ts +250 -0
- package/src/semantic-bridge.ts +204 -0
- package/src/sync/index.ts +70 -0
- package/src/types/better-sqlite3.d.ts +44 -0
- package/src/types/index.ts +434 -0
|
@@ -0,0 +1,296 @@
|
|
|
1
|
+
import { SemanticRole } from '@lokascript/semantic';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Patterns Reference Type Definitions
|
|
5
|
+
*/
|
|
6
|
+
/**
|
|
7
|
+
* Engine compatibility for a pattern.
|
|
8
|
+
* - 'hyperscript': only verified for official _hyperscript
|
|
9
|
+
* - 'lokascript': only verified for lokascript (not backward compatible)
|
|
10
|
+
* - 'both': verified for both engines
|
|
11
|
+
* - null: unverified
|
|
12
|
+
*/
|
|
13
|
+
type EngineCompat = 'hyperscript' | 'lokascript' | 'both';
|
|
14
|
+
/**
|
|
15
|
+
* A pattern from the database (code_examples table).
|
|
16
|
+
*/
|
|
17
|
+
interface Pattern {
|
|
18
|
+
id: string;
|
|
19
|
+
title: string;
|
|
20
|
+
description: string | null;
|
|
21
|
+
rawCode: string;
|
|
22
|
+
category: string | null;
|
|
23
|
+
primaryCommand: string | null;
|
|
24
|
+
tags: string[];
|
|
25
|
+
difficulty: 'beginner' | 'intermediate' | 'advanced';
|
|
26
|
+
engine: EngineCompat | null;
|
|
27
|
+
createdAt: Date;
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* Pattern with computed complexity classification.
|
|
31
|
+
*/
|
|
32
|
+
interface ClassifiedPattern extends Pattern {
|
|
33
|
+
complexity: ComplexityLevel;
|
|
34
|
+
lineCount: number;
|
|
35
|
+
commands: string[];
|
|
36
|
+
}
|
|
37
|
+
type ComplexityLevel = 'simple-command' | 'simple-event' | 'chained-command' | 'multi-line-event' | 'behavior-install' | 'behavior-def' | 'def-function' | 'complex';
|
|
38
|
+
type WordOrder = 'SVO' | 'SOV' | 'VSO' | 'V2';
|
|
39
|
+
type TranslationMethod = 'auto-generated' | 'hand-crafted' | 'verified';
|
|
40
|
+
/**
|
|
41
|
+
* A translation of a pattern to a specific language.
|
|
42
|
+
*/
|
|
43
|
+
interface Translation {
|
|
44
|
+
id: number;
|
|
45
|
+
codeExampleId: string;
|
|
46
|
+
language: string;
|
|
47
|
+
hyperscript: string;
|
|
48
|
+
wordOrder: WordOrder;
|
|
49
|
+
translationMethod: TranslationMethod;
|
|
50
|
+
confidence: number;
|
|
51
|
+
verifiedParses: boolean;
|
|
52
|
+
verifiedExecutes: boolean;
|
|
53
|
+
roleAlignmentScore: number | null;
|
|
54
|
+
createdAt: Date;
|
|
55
|
+
updatedAt: Date;
|
|
56
|
+
}
|
|
57
|
+
/**
|
|
58
|
+
* Result of translation verification.
|
|
59
|
+
*/
|
|
60
|
+
interface VerificationResult {
|
|
61
|
+
translation: Translation;
|
|
62
|
+
parseSuccess: boolean;
|
|
63
|
+
executeSuccess: boolean;
|
|
64
|
+
errorMessage: string | null;
|
|
65
|
+
confidence: number;
|
|
66
|
+
testedAt: Date;
|
|
67
|
+
}
|
|
68
|
+
/**
|
|
69
|
+
* An LLM example (prompt/completion pair).
|
|
70
|
+
*/
|
|
71
|
+
interface LLMExample {
|
|
72
|
+
id: number;
|
|
73
|
+
patternId: string;
|
|
74
|
+
language: string;
|
|
75
|
+
prompt: string;
|
|
76
|
+
completion: string;
|
|
77
|
+
qualityScore: number;
|
|
78
|
+
usageCount: number;
|
|
79
|
+
createdAt: Date;
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
/**
|
|
83
|
+
* Role type classification.
|
|
84
|
+
*/
|
|
85
|
+
type RoleType = 'selector' | 'literal' | 'reference' | 'expression' | 'keyword';
|
|
86
|
+
/**
|
|
87
|
+
* A semantic role extracted from a pattern.
|
|
88
|
+
*/
|
|
89
|
+
interface PatternRole {
|
|
90
|
+
id: number;
|
|
91
|
+
codeExampleId: string;
|
|
92
|
+
commandIndex: number;
|
|
93
|
+
role: SemanticRole;
|
|
94
|
+
roleValue: string | null;
|
|
95
|
+
roleType: RoleType | null;
|
|
96
|
+
required: boolean;
|
|
97
|
+
}
|
|
98
|
+
interface SearchOptions {
|
|
99
|
+
language?: string;
|
|
100
|
+
category?: string;
|
|
101
|
+
difficulty?: 'beginner' | 'intermediate' | 'advanced';
|
|
102
|
+
engine?: EngineCompat | null;
|
|
103
|
+
limit?: number;
|
|
104
|
+
offset?: number;
|
|
105
|
+
}
|
|
106
|
+
interface TestOptions {
|
|
107
|
+
language?: string;
|
|
108
|
+
browsers?: string[];
|
|
109
|
+
runtimeVersion?: string;
|
|
110
|
+
}
|
|
111
|
+
interface PatternStats {
|
|
112
|
+
totalPatterns: number;
|
|
113
|
+
totalTranslations: number;
|
|
114
|
+
byLanguage: Record<string, {
|
|
115
|
+
count: number;
|
|
116
|
+
verifiedCount: number;
|
|
117
|
+
}>;
|
|
118
|
+
byCategory: Record<string, number>;
|
|
119
|
+
avgConfidence: number;
|
|
120
|
+
}
|
|
121
|
+
interface SyncOptions {
|
|
122
|
+
dryRun?: boolean;
|
|
123
|
+
verbose?: boolean;
|
|
124
|
+
limit?: number;
|
|
125
|
+
languages?: string[];
|
|
126
|
+
}
|
|
127
|
+
interface SyncResult {
|
|
128
|
+
totalExamples: number;
|
|
129
|
+
successfulExamples: number;
|
|
130
|
+
skippedExamples: number;
|
|
131
|
+
totalTranslations: number;
|
|
132
|
+
byLanguage: Record<string, number>;
|
|
133
|
+
}
|
|
134
|
+
interface ValidationOptions {
|
|
135
|
+
verbose?: boolean;
|
|
136
|
+
languages?: string[];
|
|
137
|
+
}
|
|
138
|
+
interface ValidationResult {
|
|
139
|
+
total: number;
|
|
140
|
+
passed: number;
|
|
141
|
+
failed: number;
|
|
142
|
+
byLanguage: Record<string, {
|
|
143
|
+
passed: number;
|
|
144
|
+
failed: number;
|
|
145
|
+
}>;
|
|
146
|
+
failures: Array<{
|
|
147
|
+
language: string;
|
|
148
|
+
hyperscript: string;
|
|
149
|
+
error: string;
|
|
150
|
+
}>;
|
|
151
|
+
}
|
|
152
|
+
interface DiscoveryResult {
|
|
153
|
+
totalExamples: number;
|
|
154
|
+
byComplexity: Record<ComplexityLevel, number>;
|
|
155
|
+
parseable: number;
|
|
156
|
+
notParseable: number;
|
|
157
|
+
commandCoverage: Record<string, {
|
|
158
|
+
total: number;
|
|
159
|
+
parseable: number;
|
|
160
|
+
}>;
|
|
161
|
+
gaps: string[];
|
|
162
|
+
}
|
|
163
|
+
/**
|
|
164
|
+
* A hyperscript command definition.
|
|
165
|
+
*/
|
|
166
|
+
interface Command {
|
|
167
|
+
id: string;
|
|
168
|
+
name: string;
|
|
169
|
+
description: string | null;
|
|
170
|
+
syntax: string | null;
|
|
171
|
+
purpose: string | null;
|
|
172
|
+
implicitTarget: string | null;
|
|
173
|
+
implicitResultTarget: string | null;
|
|
174
|
+
isBlocking: boolean;
|
|
175
|
+
hasBody: boolean;
|
|
176
|
+
createdAt: Date;
|
|
177
|
+
updatedAt: Date;
|
|
178
|
+
}
|
|
179
|
+
/**
|
|
180
|
+
* A hyperscript expression definition.
|
|
181
|
+
*/
|
|
182
|
+
interface Expression {
|
|
183
|
+
id: string;
|
|
184
|
+
name: string;
|
|
185
|
+
description: string | null;
|
|
186
|
+
category: string;
|
|
187
|
+
evaluatesToType: string | null;
|
|
188
|
+
precedence: number | null;
|
|
189
|
+
associativity: string | null;
|
|
190
|
+
operators: string[];
|
|
191
|
+
createdAt: Date;
|
|
192
|
+
updatedAt: Date;
|
|
193
|
+
}
|
|
194
|
+
/**
|
|
195
|
+
* An operator for an expression.
|
|
196
|
+
*/
|
|
197
|
+
interface ExpressionOperator {
|
|
198
|
+
id: string;
|
|
199
|
+
expressionId: string;
|
|
200
|
+
operator: string;
|
|
201
|
+
}
|
|
202
|
+
/**
|
|
203
|
+
* A hyperscript keyword definition.
|
|
204
|
+
*/
|
|
205
|
+
interface Keyword {
|
|
206
|
+
id: string;
|
|
207
|
+
name: string;
|
|
208
|
+
description: string | null;
|
|
209
|
+
contextOfUse: string | null;
|
|
210
|
+
isOptional: boolean;
|
|
211
|
+
createdAt: Date;
|
|
212
|
+
updatedAt: Date;
|
|
213
|
+
}
|
|
214
|
+
/**
|
|
215
|
+
* A hyperscript feature (top-level construct like on, init, behavior).
|
|
216
|
+
*/
|
|
217
|
+
interface Feature {
|
|
218
|
+
id: string;
|
|
219
|
+
name: string;
|
|
220
|
+
description: string | null;
|
|
221
|
+
syntax: string | null;
|
|
222
|
+
trigger: string | null;
|
|
223
|
+
structureDescription: string | null;
|
|
224
|
+
scopeImpact: string | null;
|
|
225
|
+
createdAt: Date;
|
|
226
|
+
updatedAt: Date;
|
|
227
|
+
}
|
|
228
|
+
/**
|
|
229
|
+
* A special symbol (me, it, my, you, your).
|
|
230
|
+
*/
|
|
231
|
+
interface SpecialSymbol {
|
|
232
|
+
id: string;
|
|
233
|
+
name: string;
|
|
234
|
+
symbol: string;
|
|
235
|
+
symbolType: string;
|
|
236
|
+
description: string | null;
|
|
237
|
+
typicalValue: string | null;
|
|
238
|
+
scopeImplications: string | null;
|
|
239
|
+
createdAt: Date;
|
|
240
|
+
updatedAt: Date;
|
|
241
|
+
}
|
|
242
|
+
/**
|
|
243
|
+
* Element type for searching across language elements.
|
|
244
|
+
*/
|
|
245
|
+
type LanguageElementType = 'command' | 'expression' | 'keyword' | 'feature' | 'special_symbol';
|
|
246
|
+
/**
|
|
247
|
+
* A language element (union of all documentation types).
|
|
248
|
+
*/
|
|
249
|
+
type LanguageElement = {
|
|
250
|
+
type: 'command';
|
|
251
|
+
element: Command;
|
|
252
|
+
} | {
|
|
253
|
+
type: 'expression';
|
|
254
|
+
element: Expression;
|
|
255
|
+
} | {
|
|
256
|
+
type: 'keyword';
|
|
257
|
+
element: Keyword;
|
|
258
|
+
} | {
|
|
259
|
+
type: 'feature';
|
|
260
|
+
element: Feature;
|
|
261
|
+
} | {
|
|
262
|
+
type: 'special_symbol';
|
|
263
|
+
element: SpecialSymbol;
|
|
264
|
+
};
|
|
265
|
+
/**
|
|
266
|
+
* Statistics for language documentation.
|
|
267
|
+
*/
|
|
268
|
+
interface LanguageDocsStats {
|
|
269
|
+
commands: number;
|
|
270
|
+
expressions: number;
|
|
271
|
+
keywords: number;
|
|
272
|
+
features: number;
|
|
273
|
+
specialSymbols: number;
|
|
274
|
+
expressionOperators: number;
|
|
275
|
+
}
|
|
276
|
+
interface ConnectionOptions {
|
|
277
|
+
dbPath?: string;
|
|
278
|
+
readonly?: boolean;
|
|
279
|
+
}
|
|
280
|
+
/**
|
|
281
|
+
* Main API interface for the Patterns Reference system.
|
|
282
|
+
*/
|
|
283
|
+
interface PatternsReference {
|
|
284
|
+
getPatternById(id: string): Promise<Pattern | null>;
|
|
285
|
+
getPatternsByCategory(category: string): Promise<Pattern[]>;
|
|
286
|
+
getPatternsByCommand(command: string): Promise<Pattern[]>;
|
|
287
|
+
searchPatterns(query: string, options?: SearchOptions): Promise<Pattern[]>;
|
|
288
|
+
getTranslation(patternId: string, language: string): Promise<Translation | null>;
|
|
289
|
+
getAllTranslations(patternId: string): Promise<Translation[]>;
|
|
290
|
+
verifyTranslation(translation: Translation): Promise<VerificationResult>;
|
|
291
|
+
getLLMExamples(prompt: string, language?: string, limit?: number): Promise<LLMExample[]>;
|
|
292
|
+
getStats(): Promise<PatternStats>;
|
|
293
|
+
close(): void;
|
|
294
|
+
}
|
|
295
|
+
|
|
296
|
+
export type { ConnectionOptions as C, DiscoveryResult as D, Expression as E, Feature as F, Keyword as K, LanguageElementType as L, PatternsReference as P, RoleType as R, SpecialSymbol as S, Translation as T, VerificationResult as V, WordOrder as W, Command as a, LanguageElement as b, LanguageDocsStats as c, LLMExample as d, Pattern as e, ClassifiedPattern as f, ComplexityLevel as g, EngineCompat as h, TranslationMethod as i, ExpressionOperator as j, SearchOptions as k, TestOptions as l, PatternStats as m, SyncOptions as n, SyncResult as o, ValidationOptions as p, ValidationResult as q, PatternRole as r };
|
|
@@ -0,0 +1,296 @@
|
|
|
1
|
+
import { SemanticRole } from '@lokascript/semantic';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Patterns Reference Type Definitions
|
|
5
|
+
*/
|
|
6
|
+
/**
|
|
7
|
+
* Engine compatibility for a pattern.
|
|
8
|
+
* - 'hyperscript': only verified for official _hyperscript
|
|
9
|
+
* - 'lokascript': only verified for lokascript (not backward compatible)
|
|
10
|
+
* - 'both': verified for both engines
|
|
11
|
+
* - null: unverified
|
|
12
|
+
*/
|
|
13
|
+
type EngineCompat = 'hyperscript' | 'lokascript' | 'both';
|
|
14
|
+
/**
|
|
15
|
+
* A pattern from the database (code_examples table).
|
|
16
|
+
*/
|
|
17
|
+
interface Pattern {
|
|
18
|
+
id: string;
|
|
19
|
+
title: string;
|
|
20
|
+
description: string | null;
|
|
21
|
+
rawCode: string;
|
|
22
|
+
category: string | null;
|
|
23
|
+
primaryCommand: string | null;
|
|
24
|
+
tags: string[];
|
|
25
|
+
difficulty: 'beginner' | 'intermediate' | 'advanced';
|
|
26
|
+
engine: EngineCompat | null;
|
|
27
|
+
createdAt: Date;
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* Pattern with computed complexity classification.
|
|
31
|
+
*/
|
|
32
|
+
interface ClassifiedPattern extends Pattern {
|
|
33
|
+
complexity: ComplexityLevel;
|
|
34
|
+
lineCount: number;
|
|
35
|
+
commands: string[];
|
|
36
|
+
}
|
|
37
|
+
type ComplexityLevel = 'simple-command' | 'simple-event' | 'chained-command' | 'multi-line-event' | 'behavior-install' | 'behavior-def' | 'def-function' | 'complex';
|
|
38
|
+
type WordOrder = 'SVO' | 'SOV' | 'VSO' | 'V2';
|
|
39
|
+
type TranslationMethod = 'auto-generated' | 'hand-crafted' | 'verified';
|
|
40
|
+
/**
|
|
41
|
+
* A translation of a pattern to a specific language.
|
|
42
|
+
*/
|
|
43
|
+
interface Translation {
|
|
44
|
+
id: number;
|
|
45
|
+
codeExampleId: string;
|
|
46
|
+
language: string;
|
|
47
|
+
hyperscript: string;
|
|
48
|
+
wordOrder: WordOrder;
|
|
49
|
+
translationMethod: TranslationMethod;
|
|
50
|
+
confidence: number;
|
|
51
|
+
verifiedParses: boolean;
|
|
52
|
+
verifiedExecutes: boolean;
|
|
53
|
+
roleAlignmentScore: number | null;
|
|
54
|
+
createdAt: Date;
|
|
55
|
+
updatedAt: Date;
|
|
56
|
+
}
|
|
57
|
+
/**
|
|
58
|
+
* Result of translation verification.
|
|
59
|
+
*/
|
|
60
|
+
interface VerificationResult {
|
|
61
|
+
translation: Translation;
|
|
62
|
+
parseSuccess: boolean;
|
|
63
|
+
executeSuccess: boolean;
|
|
64
|
+
errorMessage: string | null;
|
|
65
|
+
confidence: number;
|
|
66
|
+
testedAt: Date;
|
|
67
|
+
}
|
|
68
|
+
/**
|
|
69
|
+
* An LLM example (prompt/completion pair).
|
|
70
|
+
*/
|
|
71
|
+
interface LLMExample {
|
|
72
|
+
id: number;
|
|
73
|
+
patternId: string;
|
|
74
|
+
language: string;
|
|
75
|
+
prompt: string;
|
|
76
|
+
completion: string;
|
|
77
|
+
qualityScore: number;
|
|
78
|
+
usageCount: number;
|
|
79
|
+
createdAt: Date;
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
/**
|
|
83
|
+
* Role type classification.
|
|
84
|
+
*/
|
|
85
|
+
type RoleType = 'selector' | 'literal' | 'reference' | 'expression' | 'keyword';
|
|
86
|
+
/**
|
|
87
|
+
* A semantic role extracted from a pattern.
|
|
88
|
+
*/
|
|
89
|
+
interface PatternRole {
|
|
90
|
+
id: number;
|
|
91
|
+
codeExampleId: string;
|
|
92
|
+
commandIndex: number;
|
|
93
|
+
role: SemanticRole;
|
|
94
|
+
roleValue: string | null;
|
|
95
|
+
roleType: RoleType | null;
|
|
96
|
+
required: boolean;
|
|
97
|
+
}
|
|
98
|
+
interface SearchOptions {
|
|
99
|
+
language?: string;
|
|
100
|
+
category?: string;
|
|
101
|
+
difficulty?: 'beginner' | 'intermediate' | 'advanced';
|
|
102
|
+
engine?: EngineCompat | null;
|
|
103
|
+
limit?: number;
|
|
104
|
+
offset?: number;
|
|
105
|
+
}
|
|
106
|
+
interface TestOptions {
|
|
107
|
+
language?: string;
|
|
108
|
+
browsers?: string[];
|
|
109
|
+
runtimeVersion?: string;
|
|
110
|
+
}
|
|
111
|
+
interface PatternStats {
|
|
112
|
+
totalPatterns: number;
|
|
113
|
+
totalTranslations: number;
|
|
114
|
+
byLanguage: Record<string, {
|
|
115
|
+
count: number;
|
|
116
|
+
verifiedCount: number;
|
|
117
|
+
}>;
|
|
118
|
+
byCategory: Record<string, number>;
|
|
119
|
+
avgConfidence: number;
|
|
120
|
+
}
|
|
121
|
+
interface SyncOptions {
|
|
122
|
+
dryRun?: boolean;
|
|
123
|
+
verbose?: boolean;
|
|
124
|
+
limit?: number;
|
|
125
|
+
languages?: string[];
|
|
126
|
+
}
|
|
127
|
+
interface SyncResult {
|
|
128
|
+
totalExamples: number;
|
|
129
|
+
successfulExamples: number;
|
|
130
|
+
skippedExamples: number;
|
|
131
|
+
totalTranslations: number;
|
|
132
|
+
byLanguage: Record<string, number>;
|
|
133
|
+
}
|
|
134
|
+
interface ValidationOptions {
|
|
135
|
+
verbose?: boolean;
|
|
136
|
+
languages?: string[];
|
|
137
|
+
}
|
|
138
|
+
interface ValidationResult {
|
|
139
|
+
total: number;
|
|
140
|
+
passed: number;
|
|
141
|
+
failed: number;
|
|
142
|
+
byLanguage: Record<string, {
|
|
143
|
+
passed: number;
|
|
144
|
+
failed: number;
|
|
145
|
+
}>;
|
|
146
|
+
failures: Array<{
|
|
147
|
+
language: string;
|
|
148
|
+
hyperscript: string;
|
|
149
|
+
error: string;
|
|
150
|
+
}>;
|
|
151
|
+
}
|
|
152
|
+
interface DiscoveryResult {
|
|
153
|
+
totalExamples: number;
|
|
154
|
+
byComplexity: Record<ComplexityLevel, number>;
|
|
155
|
+
parseable: number;
|
|
156
|
+
notParseable: number;
|
|
157
|
+
commandCoverage: Record<string, {
|
|
158
|
+
total: number;
|
|
159
|
+
parseable: number;
|
|
160
|
+
}>;
|
|
161
|
+
gaps: string[];
|
|
162
|
+
}
|
|
163
|
+
/**
|
|
164
|
+
* A hyperscript command definition.
|
|
165
|
+
*/
|
|
166
|
+
interface Command {
|
|
167
|
+
id: string;
|
|
168
|
+
name: string;
|
|
169
|
+
description: string | null;
|
|
170
|
+
syntax: string | null;
|
|
171
|
+
purpose: string | null;
|
|
172
|
+
implicitTarget: string | null;
|
|
173
|
+
implicitResultTarget: string | null;
|
|
174
|
+
isBlocking: boolean;
|
|
175
|
+
hasBody: boolean;
|
|
176
|
+
createdAt: Date;
|
|
177
|
+
updatedAt: Date;
|
|
178
|
+
}
|
|
179
|
+
/**
|
|
180
|
+
* A hyperscript expression definition.
|
|
181
|
+
*/
|
|
182
|
+
interface Expression {
|
|
183
|
+
id: string;
|
|
184
|
+
name: string;
|
|
185
|
+
description: string | null;
|
|
186
|
+
category: string;
|
|
187
|
+
evaluatesToType: string | null;
|
|
188
|
+
precedence: number | null;
|
|
189
|
+
associativity: string | null;
|
|
190
|
+
operators: string[];
|
|
191
|
+
createdAt: Date;
|
|
192
|
+
updatedAt: Date;
|
|
193
|
+
}
|
|
194
|
+
/**
|
|
195
|
+
* An operator for an expression.
|
|
196
|
+
*/
|
|
197
|
+
interface ExpressionOperator {
|
|
198
|
+
id: string;
|
|
199
|
+
expressionId: string;
|
|
200
|
+
operator: string;
|
|
201
|
+
}
|
|
202
|
+
/**
|
|
203
|
+
* A hyperscript keyword definition.
|
|
204
|
+
*/
|
|
205
|
+
interface Keyword {
|
|
206
|
+
id: string;
|
|
207
|
+
name: string;
|
|
208
|
+
description: string | null;
|
|
209
|
+
contextOfUse: string | null;
|
|
210
|
+
isOptional: boolean;
|
|
211
|
+
createdAt: Date;
|
|
212
|
+
updatedAt: Date;
|
|
213
|
+
}
|
|
214
|
+
/**
|
|
215
|
+
* A hyperscript feature (top-level construct like on, init, behavior).
|
|
216
|
+
*/
|
|
217
|
+
interface Feature {
|
|
218
|
+
id: string;
|
|
219
|
+
name: string;
|
|
220
|
+
description: string | null;
|
|
221
|
+
syntax: string | null;
|
|
222
|
+
trigger: string | null;
|
|
223
|
+
structureDescription: string | null;
|
|
224
|
+
scopeImpact: string | null;
|
|
225
|
+
createdAt: Date;
|
|
226
|
+
updatedAt: Date;
|
|
227
|
+
}
|
|
228
|
+
/**
|
|
229
|
+
* A special symbol (me, it, my, you, your).
|
|
230
|
+
*/
|
|
231
|
+
interface SpecialSymbol {
|
|
232
|
+
id: string;
|
|
233
|
+
name: string;
|
|
234
|
+
symbol: string;
|
|
235
|
+
symbolType: string;
|
|
236
|
+
description: string | null;
|
|
237
|
+
typicalValue: string | null;
|
|
238
|
+
scopeImplications: string | null;
|
|
239
|
+
createdAt: Date;
|
|
240
|
+
updatedAt: Date;
|
|
241
|
+
}
|
|
242
|
+
/**
|
|
243
|
+
* Element type for searching across language elements.
|
|
244
|
+
*/
|
|
245
|
+
type LanguageElementType = 'command' | 'expression' | 'keyword' | 'feature' | 'special_symbol';
|
|
246
|
+
/**
|
|
247
|
+
* A language element (union of all documentation types).
|
|
248
|
+
*/
|
|
249
|
+
type LanguageElement = {
|
|
250
|
+
type: 'command';
|
|
251
|
+
element: Command;
|
|
252
|
+
} | {
|
|
253
|
+
type: 'expression';
|
|
254
|
+
element: Expression;
|
|
255
|
+
} | {
|
|
256
|
+
type: 'keyword';
|
|
257
|
+
element: Keyword;
|
|
258
|
+
} | {
|
|
259
|
+
type: 'feature';
|
|
260
|
+
element: Feature;
|
|
261
|
+
} | {
|
|
262
|
+
type: 'special_symbol';
|
|
263
|
+
element: SpecialSymbol;
|
|
264
|
+
};
|
|
265
|
+
/**
|
|
266
|
+
* Statistics for language documentation.
|
|
267
|
+
*/
|
|
268
|
+
interface LanguageDocsStats {
|
|
269
|
+
commands: number;
|
|
270
|
+
expressions: number;
|
|
271
|
+
keywords: number;
|
|
272
|
+
features: number;
|
|
273
|
+
specialSymbols: number;
|
|
274
|
+
expressionOperators: number;
|
|
275
|
+
}
|
|
276
|
+
interface ConnectionOptions {
|
|
277
|
+
dbPath?: string;
|
|
278
|
+
readonly?: boolean;
|
|
279
|
+
}
|
|
280
|
+
/**
|
|
281
|
+
* Main API interface for the Patterns Reference system.
|
|
282
|
+
*/
|
|
283
|
+
interface PatternsReference {
|
|
284
|
+
getPatternById(id: string): Promise<Pattern | null>;
|
|
285
|
+
getPatternsByCategory(category: string): Promise<Pattern[]>;
|
|
286
|
+
getPatternsByCommand(command: string): Promise<Pattern[]>;
|
|
287
|
+
searchPatterns(query: string, options?: SearchOptions): Promise<Pattern[]>;
|
|
288
|
+
getTranslation(patternId: string, language: string): Promise<Translation | null>;
|
|
289
|
+
getAllTranslations(patternId: string): Promise<Translation[]>;
|
|
290
|
+
verifyTranslation(translation: Translation): Promise<VerificationResult>;
|
|
291
|
+
getLLMExamples(prompt: string, language?: string, limit?: number): Promise<LLMExample[]>;
|
|
292
|
+
getStats(): Promise<PatternStats>;
|
|
293
|
+
close(): void;
|
|
294
|
+
}
|
|
295
|
+
|
|
296
|
+
export type { ConnectionOptions as C, DiscoveryResult as D, Expression as E, Feature as F, Keyword as K, LanguageElementType as L, PatternsReference as P, RoleType as R, SpecialSymbol as S, Translation as T, VerificationResult as V, WordOrder as W, Command as a, LanguageElement as b, LanguageDocsStats as c, LLMExample as d, Pattern as e, ClassifiedPattern as f, ComplexityLevel as g, EngineCompat as h, TranslationMethod as i, ExpressionOperator as j, SearchOptions as k, TestOptions as l, PatternStats as m, SyncOptions as n, SyncResult as o, ValidationOptions as p, ValidationResult as q, PatternRole as r };
|