@lokascript/framework 4.6.0 → 4.7.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.
Files changed (115) hide show
  1. package/CHANGELOG.md +87 -1
  2. package/dist/api/create-dsl.d.ts +13 -0
  3. package/dist/api/create-dsl.d.ts.map +1 -1
  4. package/dist/api/index.d.ts +1 -0
  5. package/dist/api/index.d.ts.map +1 -1
  6. package/dist/api/index.js +1756 -710
  7. package/dist/api/index.js.map +1 -1
  8. package/dist/api/translation-loss.d.ts +84 -0
  9. package/dist/api/translation-loss.d.ts.map +1 -0
  10. package/dist/core/index.d.ts +1 -0
  11. package/dist/core/index.d.ts.map +1 -1
  12. package/dist/core/index.js +1047 -684
  13. package/dist/core/index.js.map +1 -1
  14. package/dist/core/matching/confidence-model.d.ts +54 -0
  15. package/dist/core/matching/confidence-model.d.ts.map +1 -0
  16. package/dist/core/matching/index.d.ts +12 -0
  17. package/dist/core/matching/index.d.ts.map +1 -0
  18. package/dist/core/matching/match-skeleton.d.ts +114 -0
  19. package/dist/core/matching/match-skeleton.d.ts.map +1 -0
  20. package/dist/core/matching/stock-confidence.d.ts +15 -0
  21. package/dist/core/matching/stock-confidence.d.ts.map +1 -0
  22. package/dist/core/matching/stock-reader.d.ts +56 -0
  23. package/dist/core/matching/stock-reader.d.ts.map +1 -0
  24. package/dist/core/matching/stock-reading.d.ts +44 -0
  25. package/dist/core/matching/stock-reading.d.ts.map +1 -0
  26. package/dist/core/matching/value-reader.d.ts +62 -0
  27. package/dist/core/matching/value-reader.d.ts.map +1 -0
  28. package/dist/core/pattern-matching/index.js +561 -660
  29. package/dist/core/pattern-matching/index.js.map +1 -1
  30. package/dist/core/pattern-matching/pattern-matcher.d.ts +0 -117
  31. package/dist/core/pattern-matching/pattern-matcher.d.ts.map +1 -1
  32. package/dist/core/types.d.ts +48 -0
  33. package/dist/core/types.d.ts.map +1 -1
  34. package/dist/core/types.js.map +1 -1
  35. package/dist/generation/index.d.ts +2 -0
  36. package/dist/generation/index.d.ts.map +1 -1
  37. package/dist/generation/index.js +583 -1
  38. package/dist/generation/index.js.map +1 -1
  39. package/dist/generation/pattern-render.d.ts +72 -0
  40. package/dist/generation/pattern-render.d.ts.map +1 -0
  41. package/dist/generation/schema-patterns.d.ts +152 -0
  42. package/dist/generation/schema-patterns.d.ts.map +1 -0
  43. package/dist/index.cjs +1979 -907
  44. package/dist/index.cjs.map +1 -1
  45. package/dist/index.js +1961 -906
  46. package/dist/index.js.map +1 -1
  47. package/dist/ir/index.js.map +1 -1
  48. package/dist/parsing/index.js +561 -660
  49. package/dist/parsing/index.js.map +1 -1
  50. package/dist/testing/gate/index.d.ts +8 -0
  51. package/dist/testing/gate/index.d.ts.map +1 -0
  52. package/dist/testing/gate/index.js +632 -0
  53. package/dist/testing/gate/index.js.map +1 -0
  54. package/dist/testing/gate/lint/format.d.ts +7 -0
  55. package/dist/testing/gate/lint/format.d.ts.map +1 -0
  56. package/dist/testing/gate/lint/index.d.ts +30 -0
  57. package/dist/testing/gate/lint/index.d.ts.map +1 -0
  58. package/dist/testing/gate/lint/rules/extractor-coverage.d.ts +18 -0
  59. package/dist/testing/gate/lint/rules/extractor-coverage.d.ts.map +1 -0
  60. package/dist/testing/gate/lint/rules/index.d.ts +14 -0
  61. package/dist/testing/gate/lint/rules/index.d.ts.map +1 -0
  62. package/dist/testing/gate/lint/rules/keyword-classification.d.ts +19 -0
  63. package/dist/testing/gate/lint/rules/keyword-classification.d.ts.map +1 -0
  64. package/dist/testing/gate/lint/rules/keyword-coverage.d.ts +13 -0
  65. package/dist/testing/gate/lint/rules/keyword-coverage.d.ts.map +1 -0
  66. package/dist/testing/gate/lint/rules/marker-tokenization.d.ts +20 -0
  67. package/dist/testing/gate/lint/rules/marker-tokenization.d.ts.map +1 -0
  68. package/dist/testing/gate/lint/rules/position-ordering.d.ts +25 -0
  69. package/dist/testing/gate/lint/rules/position-ordering.d.ts.map +1 -0
  70. package/dist/testing/gate/lint/rules/renderer-coherence.d.ts +24 -0
  71. package/dist/testing/gate/lint/rules/renderer-coherence.d.ts.map +1 -0
  72. package/dist/testing/gate/lint/rules/schema-rules.d.ts +10 -0
  73. package/dist/testing/gate/lint/rules/schema-rules.d.ts.map +1 -0
  74. package/dist/testing/gate/lint/types.d.ts +74 -0
  75. package/dist/testing/gate/lint/types.d.ts.map +1 -0
  76. package/dist/testing/gate/round-trip.d.ts +163 -0
  77. package/dist/testing/gate/round-trip.d.ts.map +1 -0
  78. package/package.json +6 -2
  79. package/src/__test__/fixtures/sql-dsl.ts +8 -2
  80. package/src/api/create-dsl-engine.test.ts +86 -0
  81. package/src/api/create-dsl.ts +141 -18
  82. package/src/api/index.ts +1 -0
  83. package/src/api/translation-loss.test.ts +89 -0
  84. package/src/api/translation-loss.ts +128 -0
  85. package/src/core/index.ts +1 -0
  86. package/src/core/matching/confidence-model.ts +58 -0
  87. package/src/core/matching/index.ts +12 -0
  88. package/src/core/matching/match-skeleton.test.ts +179 -0
  89. package/src/core/matching/match-skeleton.ts +621 -0
  90. package/src/core/matching/stock-confidence.ts +238 -0
  91. package/src/core/matching/stock-reader.test.ts +181 -0
  92. package/src/core/matching/stock-reader.ts +186 -0
  93. package/src/core/matching/stock-reading.ts +681 -0
  94. package/src/core/matching/value-reader.ts +85 -0
  95. package/src/core/pattern-matching/pattern-matcher.ts +11 -876
  96. package/src/core/types.ts +48 -0
  97. package/src/generation/index.ts +2 -0
  98. package/src/generation/pattern-render.ts +378 -0
  99. package/src/generation/schema-patterns.test.ts +99 -0
  100. package/src/generation/schema-patterns.ts +962 -0
  101. package/src/testing/gate/index.ts +8 -0
  102. package/src/testing/gate/lint/format.ts +23 -0
  103. package/src/testing/gate/lint/index.ts +73 -0
  104. package/src/testing/gate/lint/lint.test.ts +131 -0
  105. package/src/testing/gate/lint/rules/extractor-coverage.ts +63 -0
  106. package/src/testing/gate/lint/rules/index.ts +37 -0
  107. package/src/testing/gate/lint/rules/keyword-classification.ts +52 -0
  108. package/src/testing/gate/lint/rules/keyword-coverage.ts +38 -0
  109. package/src/testing/gate/lint/rules/marker-tokenization.ts +129 -0
  110. package/src/testing/gate/lint/rules/position-ordering.ts +87 -0
  111. package/src/testing/gate/lint/rules/renderer-coherence.ts +100 -0
  112. package/src/testing/gate/lint/rules/schema-rules.ts +35 -0
  113. package/src/testing/gate/lint/types.ts +83 -0
  114. package/src/testing/gate/round-trip.test.ts +118 -0
  115. package/src/testing/gate/round-trip.ts +438 -0
@@ -22,11 +22,6 @@ export declare class PatternMatcher {
22
22
  private logger;
23
23
  /** Current language profile for the pattern being matched */
24
24
  private currentProfile;
25
- /**
26
- * Safely convert a value to lowercase string.
27
- * Provides protection against non-string values at runtime.
28
- */
29
- private safeToLowerCase;
30
25
  /**
31
26
  * Try to match a single pattern against the token stream.
32
27
  * Returns the match result or null if no match.
@@ -60,52 +55,6 @@ export declare class PatternMatcher {
60
55
  * Match a literal pattern token (keyword or particle).
61
56
  */
62
57
  private matchLiteralToken;
63
- /**
64
- * Match a role pattern token (captures a semantic value).
65
- * Handles multi-token expressions like:
66
- * - 'my value' (possessive keyword + property)
67
- * - '#dialog.showModal()' (method call)
68
- * - "#element's *opacity" (possessive selector + property)
69
- */
70
- private matchRoleToken;
71
- /**
72
- * Try to match a possessive expression like 'my value' or 'its innerHTML'.
73
- * Returns the PropertyPathValue if matched, or null if not.
74
- */
75
- private tryMatchPossessiveExpression;
76
- /**
77
- * Check if a keyword is a structural keyword (preposition, control flow, etc.)
78
- * that shouldn't be consumed as a property name.
79
- */
80
- private isStructuralKeyword;
81
- /**
82
- * Try to match a method call expression like '#dialog.showModal()'.
83
- * Pattern: selector + '.' + identifier + '(' + [args] + ')'
84
- * Returns an expression value if matched, or null if not.
85
- */
86
- private tryMatchMethodCallExpression;
87
- /**
88
- * Try to match a property access expression like 'userData.name' or 'it.data'.
89
- * Pattern: (identifier | keyword) + '.' + identifier [+ '.' + identifier ...]
90
- * Returns an expression value if matched, or null if not.
91
- */
92
- private tryMatchPropertyAccessExpression;
93
- /**
94
- * Try to match a possessive selector expression like "#element's *opacity".
95
- * Pattern: selector + "'s" + (selector | identifier)
96
- * Returns a property-path value if matched, or null if not.
97
- */
98
- private tryMatchPossessiveSelectorExpression;
99
- /**
100
- * Try to match a selector + property expression like "#output.innerText".
101
- * This handles cases where the tokenizer produces two selector tokens:
102
- * - #output (id selector)
103
- * - .innerText (looks like class selector, but is actually property)
104
- *
105
- * Pattern: id-selector + class-selector-that-is-actually-property
106
- * Returns a property-path value if matched, or null if not.
107
- */
108
- private tryMatchSelectorPropertyExpression;
109
58
  /**
110
59
  * Match a group pattern token (optional sequence).
111
60
  * When the group's leading marker isn't at the current position, scans ahead
@@ -141,18 +90,6 @@ export declare class PatternMatcher {
141
90
  */
142
91
  private stemMatchCount;
143
92
  private totalKeywordMatches;
144
- /** Maximum depth for nested property access (e.g., a.b.c.d...) */
145
- private static readonly MAX_PROPERTY_DEPTH;
146
- /** Maximum number of arguments in method calls */
147
- private static readonly MAX_METHOD_ARGS;
148
- /**
149
- * Convert a language token to a semantic value.
150
- */
151
- private tokenToSemanticValue;
152
- /**
153
- * Parse a literal value (string, number, boolean).
154
- */
155
- private parseLiteralValue;
156
93
  /**
157
94
  * Apply extraction rules to fill in static values and defaults for missing roles.
158
95
  */
@@ -161,60 +98,6 @@ export declare class PatternMatcher {
161
98
  * Check if a pattern token is optional.
162
99
  */
163
100
  private isOptional;
164
- /**
165
- * Calculate confidence score for a match (0-1).
166
- *
167
- * Confidence is reduced for:
168
- * - Stem matches (morphological normalization has inherent uncertainty)
169
- * - Missing optional roles (but less penalty if role has a default value)
170
- *
171
- * Confidence is increased for:
172
- * - VSO languages (Arabic) when pattern starts with a verb
173
- */
174
- private calculateConfidence;
175
- /**
176
- * Calculate confidence boost for VSO (Verb-Subject-Object) language patterns.
177
- * Arabic naturally uses VSO word order, so patterns that start with a verb
178
- * should receive a confidence boost.
179
- *
180
- * Returns +0.15 confidence boost if:
181
- * - Language is Arabic ('ar')
182
- * - Pattern's first token is a verb keyword
183
- *
184
- * @param pattern The language pattern being matched
185
- * @returns Confidence boost (0 or 0.15)
186
- */
187
- private calculateVSOConfidenceBoost;
188
- /**
189
- * Arabic preposition disambiguation for confidence adjustment.
190
- *
191
- * Different Arabic prepositions are more or less natural for different semantic roles:
192
- * - على (on/upon) is preferred for patient/target roles (element selectors)
193
- * - إلى (to) is preferred for destination roles
194
- * - من (from) is preferred for source roles
195
- * - في (in) is preferred for location roles
196
- *
197
- * This method analyzes the prepositions used with captured semantic roles and
198
- * adjusts confidence based on idiomaticity:
199
- * - +0.10 for highly idiomatic preposition choices
200
- * - -0.10 for less natural preposition choices
201
- *
202
- * @param pattern The language pattern being matched
203
- * @param captured The captured semantic values
204
- * @returns Confidence adjustment (-0.10 to +0.10)
205
- */
206
- private arabicPrepositionDisambiguation;
207
- /**
208
- * Noise words that can be skipped in English for more natural syntax.
209
- * - "the" before selectors: "toggle the .active" → "toggle .active"
210
- * - "class" after class selectors: "add the .visible class" → "add .visible"
211
- */
212
- private static readonly ENGLISH_NOISE_WORDS;
213
- /**
214
- * Skip noise words like "the" before selectors.
215
- * This enables more natural English syntax like "toggle the .active".
216
- */
217
- private skipNoiseWords;
218
101
  /**
219
102
  * Extract event modifiers from the token stream.
220
103
  * Event modifiers are .once, .debounce(N), .throttle(N), .queue(strategy)
@@ -1 +1 @@
1
- {"version":3,"file":"pattern-matcher.d.ts","sourceRoot":"","sources":["../../../src/core/pattern-matching/pattern-matcher.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EACV,eAAe,EAEf,kBAAkB,EAIlB,WAAW,EAEZ,MAAM,UAAU,CAAC;AAoBlB;;;GAGG;AACH,MAAM,WAAW,qBAAqB;IACpC,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,UAAU,CAAC,EAAE;QACpB,QAAQ,CAAC,QAAQ,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,C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AAS;CAyD1F;AAMD;;GAEG;AACH,eAAO,MAAM,cAAc,gBAAuB,CAAC;AAEnD;;GAEG;AACH,wBAAgB,YAAY,CAC1B,MAAM,EAAE,WAAW,EACnB,OAAO,EAAE,eAAe,GACvB,kBAAkB,GAAG,IAAI,CAE3B;AAED;;GAEG;AACH,wBAAgB,SAAS,CACvB,MAAM,EAAE,WAAW,EACnB,QAAQ,EAAE,eAAe,EAAE,GAC1B,kBAAkB,GAAG,IAAI,CAE3B"}
@@ -58,6 +58,12 @@ export interface LanguagePattern {
58
58
  readonly template: PatternTemplate;
59
59
  readonly extraction: ExtractionRules;
60
60
  readonly constraints?: PatternConstraints;
61
+ /**
62
+ * The pattern reads a form the renderer does not write by choosing it
63
+ * (hyperscript's wait `esperar evento {event}`: the renderer writes the event
64
+ * word itself, before a name no table knows). The renderer skips it.
65
+ */
66
+ readonly parseOnly?: boolean;
61
67
  }
62
68
  export interface PatternTemplate {
63
69
  readonly format: string;
@@ -68,6 +74,13 @@ export interface LiteralPatternToken {
68
74
  readonly type: 'literal';
69
75
  readonly value: string;
70
76
  readonly alternatives?: string[];
77
+ /**
78
+ * Parse-only marker: the matcher still consumes this literal, but the
79
+ * renderer skips it. Set when a role declares `renderOverride: { <lang>: '' }`
80
+ * (hyperscript's fetch `from`: required to PARSE `fetch from /api`, absent from
81
+ * the render, since `fetch from "/api"` is not canonical _hyperscript).
82
+ */
83
+ readonly renderSuppress?: boolean;
71
84
  }
72
85
  export interface RolePatternToken {
73
86
  readonly type: 'role';
@@ -75,11 +88,27 @@ export interface RolePatternToken {
75
88
  readonly optional?: boolean;
76
89
  readonly expectedTypes?: Array<ExpectedType>;
77
90
  readonly greedy?: boolean;
91
+ /**
92
+ * Mirrors the schema's `RoleSpec.valueShape`: the slot's surface form is
93
+ * unambiguous on its own. Carried onto the pattern token because the value
94
+ * reader needs it too, not just the confidence model (hyperscript's
95
+ * `'keyword'` slots hold a fixed keyword phrase and are exempt from the
96
+ * trailing-slot verb guard).
97
+ */
98
+ readonly valueShape?: 'time' | 'reference' | 'keyword' | 'object' | 'clause' | 'list';
78
99
  }
79
100
  export interface GroupPatternToken {
80
101
  readonly type: 'group';
81
102
  readonly tokens: PatternToken[];
82
103
  readonly optional?: boolean;
104
+ /**
105
+ * The group is optional for PARSING but belongs in canonical output: the
106
+ * marker-only groups a profile's optional case markers produce (Turkish case
107
+ * suffixes may be dropped colloquially, so the parse accepts both forms).
108
+ * The matcher's skeleton also requires such a group's marker after a role it
109
+ * captures (`MatchSkeleton`).
110
+ */
111
+ readonly renderRequired?: boolean;
83
112
  }
84
113
  export interface ExtractionRules {
85
114
  readonly [role: string]: ExtractionRule;
@@ -91,6 +120,11 @@ export interface ExtractionRule {
91
120
  readonly transform?: (raw: string) => SemanticValue;
92
121
  readonly default?: SemanticValue;
93
122
  readonly value?: string;
123
+ /**
124
+ * The static `value` is an expression, as the English parse types the word
125
+ * (hyperscript's `go back` destination), not a literal.
126
+ */
127
+ readonly valueIsExpression?: true;
94
128
  readonly fromRole?: string;
95
129
  }
96
130
  export interface PatternConstraints {
@@ -104,6 +138,20 @@ export interface PatternMatchResult {
104
138
  readonly captured: ReadonlyMap<SemanticRole, SemanticValue>;
105
139
  readonly consumedTokens: number;
106
140
  readonly confidence: number;
141
+ /**
142
+ * Stream index at which each captured role's value STARTED, for callers that
143
+ * need to re-read a slot's own span rather than the tail after it. Populated
144
+ * on the same success path as `captured` (`MatchSkeleton`), so a role left
145
+ * behind by a rolled-back group survives in both maps or in neither.
146
+ */
147
+ readonly roleStarts?: ReadonlyMap<SemanticRole, number>;
148
+ /**
149
+ * A source phrase hyperscript's reader found in an event HEAD (`from #btn`
150
+ * right after the event) rather than in a pattern slot: kept out of
151
+ * `captured`, so a fused pattern's own source group can neither overwrite it
152
+ * nor be overwritten (`ValueReader.resultFields`).
153
+ */
154
+ readonly eventSource?: SemanticValue;
107
155
  }
108
156
  export interface PatternMatchError {
109
157
  readonly message: string;
@@ -1 +1 @@
1
- {"version":3,"file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IAAI,CAAC;IAClC,QAAQ,CAAC,QAAQ,CAAC,EAAE,MAAM,CAAC;CAC5B;AAED,MAAM,WAAW,kBAAkB;IACjC,QAAQ,CAAC,aAAa,CAAC,EAAE,YAAY,EAAE,CAAC;IACxC,QAAQ,CAAC,cAAc,CAAC,EAAE,YAAY,EAAE,CAAC;IACzC,QAAQ,CAAC,iBAAiB,CAAC,EAAE,KAAK,CAAC,aAAa,CAAC,cAAc,CAAC,CAAC,CAAC;IAClE,QAAQ,CAAC,aAAa,CAAC,EAAE,MAAM,EAAE,CAAC;CACnC;AAED,MAAM,WAAW,kBAAkB;IACjC,QAAQ,CAAC,OAAO,EAAE,eAAe,CAAC;IAClC,QAAQ,CAAC,QAAQ,EAAE,WAAW,CAAC,YAAY,EAAE,aAAa,CAAC,CAAC;IAC5D,QAAQ,CAAC,cAAc,EAAE,MAAM,CAAC;IAChC,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAC;IAC5B;;;;;OAKG;IACH,QAAQ,CAAC,UAAU,CAAC,EAAE,WAAW,CAAC,YAAY,EAAE,MAAM,CAAC,CAAC;IACxD;;;;;OAKG;IACH,QAAQ,CAAC,WAAW,CAAC,EAAE,aAAa,CAAC;CACtC;AAED,MAAM,WAAW,iBAAiB;IAChC,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IACzB,QAAQ,CAAC,QAAQ,EAAE,cAAc,CAAC;IAClC,QAAQ,CAAC,gBAAgB,CAAC,EAAE,MAAM,EAAE,CAAC;IACrC,QAAQ,CAAC,YAAY,CAAC,EAAE,OAAO,CAAC,kBAAkB,CAAC,CAAC;CACrD"}
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/core/types.ts"],"sourcesContent":["/**\n * Core Types — re-exported from @lokascript/intent + framework-specific extensions\n *\n * The universal semantic types (SemanticNode, SemanticValue, etc.) now live in\n * @lokascript/intent and are re-exported here for backward compatibility.\n *\n * Framework-specific types (tokenization, pattern matching) are defined below.\n */\n\n// =============================================================================\n// Re-export everything from @lokascript/intent\n// =============================================================================\n\nexport type {\n ActionType,\n SemanticRole,\n SemanticValue,\n ExpectedType,\n LiteralValue,\n SelectorValue,\n ReferenceValue,\n PropertyPathValue,\n ExpressionValue,\n FlagValue,\n Annotation,\n ProtocolDiagnostic,\n AsyncVariant,\n MatchArm,\n SemanticNode,\n SemanticMetadata,\n SourcePosition,\n CommandSemanticNode,\n EventHandlerSemanticNode,\n EventModifiers,\n ConditionalSemanticNode,\n CompoundSemanticNode,\n LoopVariant,\n LoopSemanticNode,\n LSEEnvelope,\n} from '@lokascript/intent';\n\nexport {\n createLiteral,\n createSelector,\n createReference,\n createPropertyPath,\n createExpression,\n createFlag,\n createCommandNode,\n createEventHandlerNode,\n createConditionalNode,\n createCompoundNode,\n createLoopNode,\n createTryNode,\n createAsyncNode,\n createMatchNode,\n extractValue,\n extractRoleValue,\n getRoleValue,\n} from '@lokascript/intent';\n\n// =============================================================================\n// Framework-specific types (multilingual DSL infrastructure)\n// =============================================================================\n\nimport type {\n ActionType,\n SemanticRole,\n SemanticValue,\n SelectorValue,\n ExpectedType,\n SourcePosition,\n} from '@lokascript/intent';\n\n/**\n * Token kind - categorizes what type of token this is.\n */\nexport type TokenKind =\n | 'keyword' // Command or modifier keyword\n | 'selector' // CSS selector or identifier (#id, .class, table-name)\n | 'literal' // String or number literal\n | 'particle' // Grammatical particle (を, に, من)\n | 'conjunction' // Grammatical conjunction\n | 'event-modifier' // Event modifier (.once, .debounce(300))\n | 'identifier' // Generic identifier\n | 'operator' // Operators (., +, -, etc.)\n | 'punctuation' // Punctuation (parentheses, etc.)\n | 'url'; // URL or path\n\n/**\n * A language token - the result of tokenization.\n */\nexport interface LanguageToken {\n readonly value: string;\n readonly kind: TokenKind;\n readonly position: SourcePosition;\n readonly normalized?: string;\n readonly stem?: string;\n readonly stemConfidence?: number;\n readonly metadata?: Record<string, unknown>;\n}\n\n/**\n * Token stream - provides sequential access to tokens with backtracking.\n */\nexport interface TokenStream {\n readonly tokens: readonly LanguageToken[];\n readonly language: string;\n peek(offset?: number): LanguageToken | null;\n advance(): LanguageToken;\n isAtEnd(): boolean;\n mark(): StreamMark;\n reset(mark: StreamMark): void;\n position(): number;\n}\n\nexport interface StreamMark {\n readonly position: number;\n}\n\n/**\n * Language tokenizer interface - converts text to tokens.\n */\nexport interface LanguageTokenizer {\n readonly language: string;\n readonly direction: 'ltr' | 'rtl';\n tokenize(input: string): TokenStream;\n classifyToken(token: string): TokenKind;\n}\n\n// =============================================================================\n// Pattern Matching Types\n// =============================================================================\n\nexport interface LanguagePattern {\n readonly id: string;\n readonly language: string;\n readonly command: ActionType;\n readonly priority: number;\n readonly template: PatternTemplate;\n readonly extraction: ExtractionRules;\n readonly constraints?: PatternConstraints;\n}\n\nexport interface PatternTemplate {\n readonly format: string;\n readonly tokens: PatternToken[];\n}\n\nexport type PatternToken = LiteralPatternToken | RolePatternToken | GroupPatternToken;\n\nexport interface LiteralPatternToken {\n readonly type: 'literal';\n readonly value: string;\n readonly alternatives?: string[];\n}\n\nexport interface RolePatternToken {\n readonly type: 'role';\n readonly role: SemanticRole;\n readonly optional?: boolean;\n readonly expectedTypes?: Array<ExpectedType>;\n readonly greedy?: boolean;\n}\n\nexport interface GroupPatternToken {\n readonly type: 'group';\n readonly tokens: PatternToken[];\n readonly optional?: boolean;\n}\n\nexport interface ExtractionRules {\n readonly [role: string]: ExtractionRule;\n}\n\nexport interface ExtractionRule {\n readonly position?: number;\n readonly marker?: string;\n readonly markerAlternatives?: string[];\n readonly transform?: (raw: string) => SemanticValue;\n readonly default?: SemanticValue;\n readonly value?: string;\n readonly fromRole?: string;\n}\n\nexport interface PatternConstraints {\n readonly requiredRoles?: SemanticRole[];\n readonly forbiddenRoles?: SemanticRole[];\n readonly validPatientTypes?: Array<SelectorValue['selectorKind']>;\n readonly conflictsWith?: string[];\n}\n\nexport interface PatternMatchResult {\n readonly pattern: LanguagePattern;\n readonly captured: ReadonlyMap<SemanticRole, SemanticValue>;\n readonly consumedTokens: number;\n readonly confidence: number;\n}\n\nexport interface PatternMatchError {\n readonly message: string;\n readonly position: SourcePosition;\n readonly expectedPatterns?: string[];\n readonly partialMatch?: Partial<PatternMatchResult>;\n}\n"],"mappings":";AAyCA;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;","names":[]}
1
+ {"version":3,"sources":["../../src/core/types.ts"],"sourcesContent":["/**\n * Core Types — re-exported from @lokascript/intent + framework-specific extensions\n *\n * The universal semantic types (SemanticNode, SemanticValue, etc.) now live in\n * @lokascript/intent and are re-exported here for backward compatibility.\n *\n * Framework-specific types (tokenization, pattern matching) are defined below.\n */\n\n// =============================================================================\n// Re-export everything from @lokascript/intent\n// =============================================================================\n\nexport type {\n ActionType,\n SemanticRole,\n SemanticValue,\n ExpectedType,\n LiteralValue,\n SelectorValue,\n ReferenceValue,\n PropertyPathValue,\n ExpressionValue,\n FlagValue,\n Annotation,\n ProtocolDiagnostic,\n AsyncVariant,\n MatchArm,\n SemanticNode,\n SemanticMetadata,\n SourcePosition,\n CommandSemanticNode,\n EventHandlerSemanticNode,\n EventModifiers,\n ConditionalSemanticNode,\n CompoundSemanticNode,\n LoopVariant,\n LoopSemanticNode,\n LSEEnvelope,\n} from '@lokascript/intent';\n\nexport {\n createLiteral,\n createSelector,\n createReference,\n createPropertyPath,\n createExpression,\n createFlag,\n createCommandNode,\n createEventHandlerNode,\n createConditionalNode,\n createCompoundNode,\n createLoopNode,\n createTryNode,\n createAsyncNode,\n createMatchNode,\n extractValue,\n extractRoleValue,\n getRoleValue,\n} from '@lokascript/intent';\n\n// =============================================================================\n// Framework-specific types (multilingual DSL infrastructure)\n// =============================================================================\n\nimport type {\n ActionType,\n SemanticRole,\n SemanticValue,\n SelectorValue,\n ExpectedType,\n SourcePosition,\n} from '@lokascript/intent';\n\n/**\n * Token kind - categorizes what type of token this is.\n */\nexport type TokenKind =\n | 'keyword' // Command or modifier keyword\n | 'selector' // CSS selector or identifier (#id, .class, table-name)\n | 'literal' // String or number literal\n | 'particle' // Grammatical particle (を, に, من)\n | 'conjunction' // Grammatical conjunction\n | 'event-modifier' // Event modifier (.once, .debounce(300))\n | 'identifier' // Generic identifier\n | 'operator' // Operators (., +, -, etc.)\n | 'punctuation' // Punctuation (parentheses, etc.)\n | 'url'; // URL or path\n\n/**\n * A language token - the result of tokenization.\n */\nexport interface LanguageToken {\n readonly value: string;\n readonly kind: TokenKind;\n readonly position: SourcePosition;\n readonly normalized?: string;\n readonly stem?: string;\n readonly stemConfidence?: number;\n readonly metadata?: Record<string, unknown>;\n}\n\n/**\n * Token stream - provides sequential access to tokens with backtracking.\n */\nexport interface TokenStream {\n readonly tokens: readonly LanguageToken[];\n readonly language: string;\n peek(offset?: number): LanguageToken | null;\n advance(): LanguageToken;\n isAtEnd(): boolean;\n mark(): StreamMark;\n reset(mark: StreamMark): void;\n position(): number;\n}\n\nexport interface StreamMark {\n readonly position: number;\n}\n\n/**\n * Language tokenizer interface - converts text to tokens.\n */\nexport interface LanguageTokenizer {\n readonly language: string;\n readonly direction: 'ltr' | 'rtl';\n tokenize(input: string): TokenStream;\n classifyToken(token: string): TokenKind;\n}\n\n// =============================================================================\n// Pattern Matching Types\n// =============================================================================\n\nexport interface LanguagePattern {\n readonly id: string;\n readonly language: string;\n readonly command: ActionType;\n readonly priority: number;\n readonly template: PatternTemplate;\n readonly extraction: ExtractionRules;\n readonly constraints?: PatternConstraints;\n /**\n * The pattern reads a form the renderer does not write by choosing it\n * (hyperscript's wait `esperar evento {event}`: the renderer writes the event\n * word itself, before a name no table knows). The renderer skips it.\n */\n readonly parseOnly?: boolean;\n}\n\nexport interface PatternTemplate {\n readonly format: string;\n readonly tokens: PatternToken[];\n}\n\nexport type PatternToken = LiteralPatternToken | RolePatternToken | GroupPatternToken;\n\nexport interface LiteralPatternToken {\n readonly type: 'literal';\n readonly value: string;\n readonly alternatives?: string[];\n /**\n * Parse-only marker: the matcher still consumes this literal, but the\n * renderer skips it. Set when a role declares `renderOverride: { <lang>: '' }`\n * (hyperscript's fetch `from`: required to PARSE `fetch from /api`, absent from\n * the render, since `fetch from \"/api\"` is not canonical _hyperscript).\n */\n readonly renderSuppress?: boolean;\n}\n\nexport interface RolePatternToken {\n readonly type: 'role';\n readonly role: SemanticRole;\n readonly optional?: boolean;\n readonly expectedTypes?: Array<ExpectedType>;\n readonly greedy?: boolean;\n /**\n * Mirrors the schema's `RoleSpec.valueShape`: the slot's surface form is\n * unambiguous on its own. Carried onto the pattern token because the value\n * reader needs it too, not just the confidence model (hyperscript's\n * `'keyword'` slots hold a fixed keyword phrase and are exempt from the\n * trailing-slot verb guard).\n */\n readonly valueShape?: 'time' | 'reference' | 'keyword' | 'object' | 'clause' | 'list';\n}\n\nexport interface GroupPatternToken {\n readonly type: 'group';\n readonly tokens: PatternToken[];\n readonly optional?: boolean;\n /**\n * The group is optional for PARSING but belongs in canonical output: the\n * marker-only groups a profile's optional case markers produce (Turkish case\n * suffixes may be dropped colloquially, so the parse accepts both forms).\n * The matcher's skeleton also requires such a group's marker after a role it\n * captures (`MatchSkeleton`).\n */\n readonly renderRequired?: boolean;\n}\n\nexport interface ExtractionRules {\n readonly [role: string]: ExtractionRule;\n}\n\nexport interface ExtractionRule {\n readonly position?: number;\n readonly marker?: string;\n readonly markerAlternatives?: string[];\n readonly transform?: (raw: string) => SemanticValue;\n readonly default?: SemanticValue;\n readonly value?: string;\n /**\n * The static `value` is an expression, as the English parse types the word\n * (hyperscript's `go back` destination), not a literal.\n */\n readonly valueIsExpression?: true;\n readonly fromRole?: string;\n}\n\nexport interface PatternConstraints {\n readonly requiredRoles?: SemanticRole[];\n readonly forbiddenRoles?: SemanticRole[];\n readonly validPatientTypes?: Array<SelectorValue['selectorKind']>;\n readonly conflictsWith?: string[];\n}\n\nexport interface PatternMatchResult {\n readonly pattern: LanguagePattern;\n readonly captured: ReadonlyMap<SemanticRole, SemanticValue>;\n readonly consumedTokens: number;\n readonly confidence: number;\n /**\n * Stream index at which each captured role's value STARTED, for callers that\n * need to re-read a slot's own span rather than the tail after it. Populated\n * on the same success path as `captured` (`MatchSkeleton`), so a role left\n * behind by a rolled-back group survives in both maps or in neither.\n */\n readonly roleStarts?: ReadonlyMap<SemanticRole, number>;\n /**\n * A source phrase hyperscript's reader found in an event HEAD (`from #btn`\n * right after the event) rather than in a pattern slot: kept out of\n * `captured`, so a fused pattern's own source group can neither overwrite it\n * nor be overwritten (`ValueReader.resultFields`).\n */\n readonly eventSource?: SemanticValue;\n}\n\nexport interface PatternMatchError {\n readonly message: string;\n readonly position: SourcePosition;\n readonly expectedPatterns?: string[];\n readonly partialMatch?: Partial<PatternMatchResult>;\n}\n"],"mappings":";AAyCA;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;","names":[]}
@@ -4,4 +4,6 @@
4
4
  export * from './pattern-generator';
5
5
  export * from './renderer';
6
6
  export * from './diagnostics';
7
+ export * from './schema-patterns';
8
+ export * from './pattern-render';
7
9
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/generation/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,cAAc,qBAAqB,CAAC;AACpC,cAAc,YAAY,CAAC;AAC3B,cAAc,eAAe,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/generation/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,cAAc,qBAAqB,CAAC;AACpC,cAAc,YAAY,CAAC;AAC3B,cAAc,eAAe,CAAC;AAC9B,cAAc,mBAAmB,CAAC;AAClC,cAAc,kBAAkB,CAAC"}