@lokascript/framework 2.0.0 → 2.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.
Files changed (126) hide show
  1. package/dist/aot/index.d.ts +1 -0
  2. package/dist/aot/index.d.ts.map +1 -1
  3. package/dist/aot/registry-bridge.d.ts +27 -0
  4. package/dist/aot/registry-bridge.d.ts.map +1 -0
  5. package/dist/api/create-dsl.d.ts.map +1 -1
  6. package/dist/api/dispatcher.d.ts +22 -0
  7. package/dist/api/dispatcher.d.ts.map +1 -1
  8. package/dist/api/domain-registry.d.ts +41 -0
  9. package/dist/api/domain-registry.d.ts.map +1 -1
  10. package/dist/api/index.js +1351 -21
  11. package/dist/api/index.js.map +1 -1
  12. package/dist/core/index.js +114 -10
  13. package/dist/core/index.js.map +1 -1
  14. package/dist/core/pattern-matching/index.js +74 -10
  15. package/dist/core/pattern-matching/index.js.map +1 -1
  16. package/dist/core/pattern-matching/pattern-matcher.d.ts.map +1 -1
  17. package/dist/core/types.d.ts +80 -2
  18. package/dist/core/types.d.ts.map +1 -1
  19. package/dist/core/types.js +40 -0
  20. package/dist/core/types.js.map +1 -1
  21. package/dist/feedback/confidence-gate.d.ts +28 -0
  22. package/dist/feedback/confidence-gate.d.ts.map +1 -0
  23. package/dist/feedback/feedback-formatter.d.ts +21 -0
  24. package/dist/feedback/feedback-formatter.d.ts.map +1 -0
  25. package/dist/feedback/index.d.ts +11 -0
  26. package/dist/feedback/index.d.ts.map +1 -0
  27. package/dist/feedback/pattern-tracker.d.ts +47 -0
  28. package/dist/feedback/pattern-tracker.d.ts.map +1 -0
  29. package/dist/feedback/types.d.ts +113 -0
  30. package/dist/feedback/types.d.ts.map +1 -0
  31. package/dist/generation/index.js +2 -1
  32. package/dist/generation/index.js.map +1 -1
  33. package/dist/index.cjs +2685 -71
  34. package/dist/index.cjs.map +1 -1
  35. package/dist/index.d.ts +6 -2
  36. package/dist/index.d.ts.map +1 -1
  37. package/dist/index.js +2652 -71
  38. package/dist/index.js.map +1 -1
  39. package/dist/ir/explicit-parser.d.ts +31 -0
  40. package/dist/ir/explicit-parser.d.ts.map +1 -0
  41. package/dist/ir/explicit-renderer.d.ts +17 -0
  42. package/dist/ir/explicit-renderer.d.ts.map +1 -0
  43. package/dist/ir/from-interchange.d.ts +51 -0
  44. package/dist/ir/from-interchange.d.ts.map +1 -0
  45. package/dist/ir/index.d.ts +29 -0
  46. package/dist/ir/index.d.ts.map +1 -0
  47. package/dist/ir/index.js +1557 -0
  48. package/dist/ir/index.js.map +1 -0
  49. package/dist/ir/json-schema.d.ts +40 -0
  50. package/dist/ir/json-schema.d.ts.map +1 -0
  51. package/dist/ir/protocol-json.d.ts +73 -0
  52. package/dist/ir/protocol-json.d.ts.map +1 -0
  53. package/dist/ir/references.d.ts +19 -0
  54. package/dist/ir/references.d.ts.map +1 -0
  55. package/dist/ir/types.d.ts +141 -0
  56. package/dist/ir/types.d.ts.map +1 -0
  57. package/dist/parsing/index.js +74 -10
  58. package/dist/parsing/index.js.map +1 -1
  59. package/dist/prompts/index.d.ts +9 -0
  60. package/dist/prompts/index.d.ts.map +1 -0
  61. package/dist/prompts/prompt-generator.d.ts +49 -0
  62. package/dist/prompts/prompt-generator.d.ts.map +1 -0
  63. package/dist/prompts/types.d.ts +64 -0
  64. package/dist/prompts/types.d.ts.map +1 -0
  65. package/dist/schema/command-schema.d.ts +17 -0
  66. package/dist/schema/command-schema.d.ts.map +1 -1
  67. package/dist/schema/index.js.map +1 -1
  68. package/dist/testing/index.js +3 -0
  69. package/dist/testing/index.js.map +1 -1
  70. package/dist/training/index.d.ts +11 -0
  71. package/dist/training/index.d.ts.map +1 -0
  72. package/dist/training/jsonl-writer.d.ts +42 -0
  73. package/dist/training/jsonl-writer.d.ts.map +1 -0
  74. package/dist/training/schema-synthesizer.d.ts +20 -0
  75. package/dist/training/schema-synthesizer.d.ts.map +1 -0
  76. package/dist/training/types.d.ts +73 -0
  77. package/dist/training/types.d.ts.map +1 -0
  78. package/package.json +5 -1
  79. package/src/aot/index.ts +1 -0
  80. package/src/aot/registry-bridge.test.ts +104 -0
  81. package/src/aot/registry-bridge.ts +66 -0
  82. package/src/api/create-dsl.test.ts +306 -0
  83. package/src/api/create-dsl.ts +21 -0
  84. package/src/api/dispatcher.test.ts +66 -0
  85. package/src/api/dispatcher.ts +77 -9
  86. package/src/api/domain-registry.ts +120 -4
  87. package/src/core/pattern-matching/pattern-matcher.test.ts +131 -0
  88. package/src/core/pattern-matching/pattern-matcher.ts +102 -19
  89. package/src/core/types.ts +145 -2
  90. package/src/feedback/confidence-gate.test.ts +111 -0
  91. package/src/feedback/confidence-gate.ts +70 -0
  92. package/src/feedback/feedback-formatter.test.ts +198 -0
  93. package/src/feedback/feedback-formatter.ts +298 -0
  94. package/src/feedback/index.ts +24 -0
  95. package/src/feedback/pattern-tracker.test.ts +198 -0
  96. package/src/feedback/pattern-tracker.ts +140 -0
  97. package/src/feedback/types.ts +149 -0
  98. package/src/generation/pattern-generator.ts +2 -2
  99. package/src/index.ts +22 -0
  100. package/src/integration/llm-lse-integration.test.ts +457 -0
  101. package/src/ir/explicit-parser.test.ts +306 -0
  102. package/src/ir/explicit-parser.ts +419 -0
  103. package/src/ir/explicit-renderer.test.ts +144 -0
  104. package/src/ir/explicit-renderer.ts +146 -0
  105. package/src/ir/from-interchange.test.ts +853 -0
  106. package/src/ir/from-interchange.ts +594 -0
  107. package/src/ir/index.ts +66 -0
  108. package/src/ir/json-schema.test.ts +281 -0
  109. package/src/ir/json-schema.ts +299 -0
  110. package/src/ir/protocol-json.test.ts +1185 -0
  111. package/src/ir/protocol-json.ts +745 -0
  112. package/src/ir/references.test.ts +38 -0
  113. package/src/ir/references.ts +33 -0
  114. package/src/ir/round-trip.test.ts +557 -0
  115. package/src/ir/types.ts +181 -0
  116. package/src/prompts/index.ts +15 -0
  117. package/src/prompts/prompt-generator.test.ts +386 -0
  118. package/src/prompts/prompt-generator.ts +531 -0
  119. package/src/prompts/types.ts +89 -0
  120. package/src/schema/command-schema.ts +19 -0
  121. package/src/training/index.ts +13 -0
  122. package/src/training/jsonl-writer.test.ts +138 -0
  123. package/src/training/jsonl-writer.ts +67 -0
  124. package/src/training/schema-synthesizer.test.ts +250 -0
  125. package/src/training/schema-synthesizer.ts +306 -0
  126. package/src/training/types.ts +103 -0
@@ -40,7 +40,7 @@ export type SemanticRole = string;
40
40
  * A semantic value represents a typed piece of data in a semantic node.
41
41
  * Values are language-neutral - they capture what something IS, not how it's written.
42
42
  */
43
- export type SemanticValue = LiteralValue | SelectorValue | ReferenceValue | PropertyPathValue | ExpressionValue;
43
+ export type SemanticValue = LiteralValue | SelectorValue | ReferenceValue | PropertyPathValue | ExpressionValue | FlagValue;
44
44
  /**
45
45
  * Expected value types for role tokens.
46
46
  * Shared between RoleSpec (command-schemas) and RolePatternToken.
@@ -70,6 +70,40 @@ export interface ExpressionValue {
70
70
  /** Raw expression string for complex expressions that need further parsing */
71
71
  readonly raw: string;
72
72
  }
73
+ /**
74
+ * A boolean flag value — present (+flag) or negated (~flag).
75
+ * Used in declarative domains for no-value attributes like primary-key, not-null.
76
+ */
77
+ export interface FlagValue {
78
+ readonly type: 'flag';
79
+ readonly name: string;
80
+ readonly enabled: boolean;
81
+ }
82
+ /** A metadata annotation on a node (v1.2). */
83
+ export interface Annotation {
84
+ readonly name: string;
85
+ readonly value?: string;
86
+ }
87
+ /**
88
+ * A type constraint diagnostic attached to a node (v1.2).
89
+ *
90
+ * Named `ProtocolDiagnostic` to avoid collision with the framework's own
91
+ * `Diagnostic` type (which has `severity: 'error' | 'warning' | 'info'`
92
+ * and `suggestion?: string`).
93
+ */
94
+ export interface ProtocolDiagnostic {
95
+ readonly level: 'error' | 'warning';
96
+ readonly role: string;
97
+ readonly message: string;
98
+ readonly code: string;
99
+ }
100
+ /** Async coordination variant (v1.2). */
101
+ export type AsyncVariant = 'all' | 'race';
102
+ /** A single arm in a match command (v1.2). */
103
+ export interface MatchArm {
104
+ readonly pattern: SemanticValue;
105
+ readonly body: SemanticNode[];
106
+ }
73
107
  /**
74
108
  * Base interface for all semantic nodes.
75
109
  * Semantic nodes capture the MEANING of DSL constructs.
@@ -79,6 +113,10 @@ export interface SemanticNode {
79
113
  readonly action: ActionType;
80
114
  readonly roles: ReadonlyMap<SemanticRole, SemanticValue>;
81
115
  readonly metadata?: SemanticMetadata;
116
+ /** Metadata annotations (v1.2). */
117
+ readonly annotations?: readonly Annotation[];
118
+ /** Type constraint diagnostics (v1.2). */
119
+ readonly diagnostics?: readonly ProtocolDiagnostic[];
82
120
  }
83
121
  /**
84
122
  * Metadata about the source of a semantic node.
@@ -107,9 +145,27 @@ export interface SourcePosition {
107
145
  }
108
146
  /**
109
147
  * A command semantic node - represents a single DSL command.
148
+ *
149
+ * v1.2 adds optional fields for try/catch/finally, async coordination (all/race),
150
+ * and pattern matching (match/arms). These are encoded as fields on command nodes
151
+ * (matching the protocol wire format) rather than new node kinds.
110
152
  */
111
153
  export interface CommandSemanticNode extends SemanticNode {
112
154
  readonly kind: 'command';
155
+ /** try body — commands to execute in the try block (v1.2). */
156
+ readonly body?: readonly SemanticNode[];
157
+ /** catch branch — commands to execute on error (v1.2). */
158
+ readonly catchBranch?: readonly SemanticNode[];
159
+ /** finally branch — cleanup commands that always execute (v1.2). */
160
+ readonly finallyBranch?: readonly SemanticNode[];
161
+ /** Async coordination variant: all (wait for all) or race (first wins) (v1.2). */
162
+ readonly asyncVariant?: AsyncVariant;
163
+ /** Async body — concurrent commands for all/race (v1.2). */
164
+ readonly asyncBody?: readonly SemanticNode[];
165
+ /** Match arms — pattern/body pairs for match command (v1.2). */
166
+ readonly arms?: readonly MatchArm[];
167
+ /** Default arm — executed when no match arm matches (v1.2). */
168
+ readonly defaultArm?: readonly SemanticNode[];
113
169
  }
114
170
  /**
115
171
  * An event handler semantic node - represents trigger-based commands.
@@ -143,7 +199,7 @@ export interface ConditionalSemanticNode extends SemanticNode {
143
199
  export interface CompoundSemanticNode extends SemanticNode {
144
200
  readonly kind: 'compound';
145
201
  readonly statements: SemanticNode[];
146
- readonly chainType: 'then' | 'and' | 'async' | 'sequential';
202
+ readonly chainType: 'then' | 'and' | 'async' | 'sequential' | 'pipe';
147
203
  }
148
204
  /**
149
205
  * Loop variant discriminant for different loop types.
@@ -340,6 +396,10 @@ export declare function createPropertyPath(object: SemanticValue, property: stri
340
396
  * Create an expression value
341
397
  */
342
398
  export declare function createExpression(raw: string): ExpressionValue;
399
+ /**
400
+ * Create a boolean flag value (+flag or ~flag)
401
+ */
402
+ export declare function createFlag(name: string, enabled?: boolean): FlagValue;
343
403
  /**
344
404
  * Create a command semantic node
345
405
  */
@@ -379,4 +439,22 @@ export declare function extractRoleValue(node: SemanticNode, role: string): stri
379
439
  * Create a loop semantic node
380
440
  */
381
441
  export declare function createLoopNode(action: ActionType, roles: Record<SemanticRole, SemanticValue> | Map<SemanticRole, SemanticValue>, loopVariant: LoopVariant, body: SemanticNode[], loopVariable?: string, indexVariable?: string, metadata?: SemanticMetadata): LoopSemanticNode;
442
+ /**
443
+ * Create a try/catch/finally command node (v1.2).
444
+ */
445
+ export declare function createTryNode(body: SemanticNode[], catchBranch?: SemanticNode[], finallyBranch?: SemanticNode[], metadata?: SemanticMetadata): CommandSemanticNode;
446
+ /**
447
+ * Create an async coordination (all/race) command node (v1.2).
448
+ */
449
+ export declare function createAsyncNode(variant: AsyncVariant, asyncBody: SemanticNode[], metadata?: SemanticMetadata): CommandSemanticNode;
450
+ /**
451
+ * Create a match command node with pattern arms (v1.2).
452
+ */
453
+ export declare function createMatchNode(roles: Record<SemanticRole, SemanticValue> | Map<SemanticRole, SemanticValue>, arms: MatchArm[], defaultArm?: SemanticNode[], metadata?: SemanticMetadata): CommandSemanticNode;
454
+ /** Wire format envelope with version metadata (v1.2). */
455
+ export interface LSEEnvelope {
456
+ readonly lseVersion: string;
457
+ readonly features?: readonly string[];
458
+ readonly nodes: readonly SemanticNode[];
459
+ }
382
460
  //# sourceMappingURL=types.d.ts.map
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EAC7E,IAAI,EAAE,QAAQ,EAAE,EAChB,UAAU,CAAC,EAAE,YAAY,EAAE,EAC3B,QAAQ,CAAC,EAAE,gBAAgB,GAC1B,mBAAmB,CAUrB;AAED,yDAAyD;AACzD,MAAM,WAAW,WAAW;IAC1B,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAC;IAC5B,QAAQ,CAAC,QAAQ,CAAC,EAAE,SAAS,MAAM,EAAE,CAAC;IACtC,QAAQ,CAAC,KAAK,EAAE,SAAS,YAAY,EAAE,CAAC;CACzC"}
@@ -14,6 +14,9 @@ function createPropertyPath(object, property) {
14
14
  function createExpression(raw) {
15
15
  return { type: "expression", raw };
16
16
  }
17
+ function createFlag(name, enabled = true) {
18
+ return { type: "flag", name, enabled };
19
+ }
17
20
  function createCommandNode(action, roles, metadata) {
18
21
  const rolesMap = roles instanceof Map ? roles : new Map(Object.entries(roles));
19
22
  const node = {
@@ -65,6 +68,7 @@ function createCompoundNode(statements, chainType = "sequential", metadata) {
65
68
  return metadata ? { ...base, metadata } : base;
66
69
  }
67
70
  function extractValue(value) {
71
+ if (value.type === "flag") return value.name;
68
72
  if ("raw" in value && value.raw !== void 0) return String(value.raw);
69
73
  if ("value" in value && value.value !== void 0) return String(value.value);
70
74
  if (value.type === "property-path") return `${extractValue(value.object)}.${value.property}`;
@@ -91,17 +95,53 @@ function createLoopNode(action, roles, loopVariant, body, loopVariable, indexVar
91
95
  ...metadata && { metadata }
92
96
  };
93
97
  }
98
+ function createTryNode(body, catchBranch, finallyBranch, metadata) {
99
+ return {
100
+ kind: "command",
101
+ action: "try",
102
+ roles: /* @__PURE__ */ new Map(),
103
+ body,
104
+ ...catchBranch && catchBranch.length > 0 ? { catchBranch } : {},
105
+ ...finallyBranch && finallyBranch.length > 0 ? { finallyBranch } : {},
106
+ ...metadata ? { metadata } : {}
107
+ };
108
+ }
109
+ function createAsyncNode(variant, asyncBody, metadata) {
110
+ return {
111
+ kind: "command",
112
+ action: variant,
113
+ roles: /* @__PURE__ */ new Map(),
114
+ asyncVariant: variant,
115
+ asyncBody,
116
+ ...metadata ? { metadata } : {}
117
+ };
118
+ }
119
+ function createMatchNode(roles, arms, defaultArm, metadata) {
120
+ const rolesMap = roles instanceof Map ? roles : new Map(Object.entries(roles));
121
+ return {
122
+ kind: "command",
123
+ action: "match",
124
+ roles: rolesMap,
125
+ arms,
126
+ ...defaultArm && defaultArm.length > 0 ? { defaultArm } : {},
127
+ ...metadata ? { metadata } : {}
128
+ };
129
+ }
94
130
  export {
131
+ createAsyncNode,
95
132
  createCommandNode,
96
133
  createCompoundNode,
97
134
  createConditionalNode,
98
135
  createEventHandlerNode,
99
136
  createExpression,
137
+ createFlag,
100
138
  createLiteral,
101
139
  createLoopNode,
140
+ createMatchNode,
102
141
  createPropertyPath,
103
142
  createReference,
104
143
  createSelector,
144
+ createTryNode,
105
145
  extractRoleValue,
106
146
  extractValue
107
147
  };
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/core/types.ts"],"sourcesContent":["/**\n * Generic Semantic Types for Multilingual DSLs\n *\n * This module defines the canonical semantic representation that all languages\n * parse to and render from. The semantic layer is language-neutral - it captures\n * the MEANING of DSL commands independent of surface syntax.\n *\n * These types are domain-agnostic - they work for any DSL (SQL, animations, etc.)\n */\n\n// =============================================================================\n// Action Types (Generic)\n// =============================================================================\n\n/**\n * Action type represents the command/operation in a DSL.\n * This is generic - each DSL defines its own set of actions.\n *\n * Examples:\n * - Hyperscript: 'toggle', 'add', 'remove', 'fetch'\n * - SQL: 'select', 'insert', 'update', 'delete'\n * - Animation: 'animate', 'fade', 'slide', 'rotate'\n */\nexport type ActionType = string;\n\n/**\n * Semantic role represents the grammatical function of a part of a command.\n * This is generic - each DSL can define its own roles, though common ones include:\n *\n * Common roles across DSLs:\n * - action: The verb/command\n * - patient: What is being acted upon\n * - destination: Where something goes\n * - source: Where something comes from\n * - condition: Boolean expressions\n * - quantity: Numeric amounts\n * - duration: Time spans\n *\n * Examples:\n * - Hyperscript: 'patient', 'destination', 'source', 'event', 'style'\n * - SQL: 'columns', 'table', 'condition', 'orderBy', 'limit'\n * - Animation: 'target', 'duration', 'easing', 'delay'\n */\nexport type SemanticRole = string;\n\n// =============================================================================\n// Semantic Values\n// =============================================================================\n\n/**\n * A semantic value represents a typed piece of data in a semantic node.\n * Values are language-neutral - they capture what something IS, not how it's written.\n */\nexport type SemanticValue =\n | LiteralValue\n | SelectorValue\n | ReferenceValue\n | PropertyPathValue\n | ExpressionValue;\n\n/**\n * Expected value types for role tokens.\n * Shared between RoleSpec (command-schemas) and RolePatternToken.\n */\nexport type ExpectedType = SemanticValue['type'];\n\nexport interface LiteralValue {\n readonly type: 'literal';\n readonly value: string | number | boolean;\n readonly dataType?: 'string' | 'number' | 'boolean' | 'duration';\n}\n\nexport interface SelectorValue {\n readonly type: 'selector';\n readonly value: string; // The selector: #id, .class, [attr], table-name, etc.\n readonly selectorKind?: 'id' | 'class' | 'attribute' | 'element' | 'complex' | 'identifier';\n}\n\nexport interface ReferenceValue {\n readonly type: 'reference';\n readonly value: string; // Generic reference name (DSL-specific)\n}\n\nexport interface PropertyPathValue {\n readonly type: 'property-path';\n readonly object: SemanticValue;\n readonly property: string;\n}\n\nexport interface ExpressionValue {\n readonly type: 'expression';\n /** Raw expression string for complex expressions that need further parsing */\n readonly raw: string;\n}\n\n// =============================================================================\n// Semantic Nodes\n// =============================================================================\n\n/**\n * Base interface for all semantic nodes.\n * Semantic nodes capture the MEANING of DSL constructs.\n */\nexport interface SemanticNode {\n readonly kind: 'command' | 'event-handler' | 'conditional' | 'compound' | 'loop';\n readonly action: ActionType;\n readonly roles: ReadonlyMap<SemanticRole, SemanticValue>;\n readonly metadata?: SemanticMetadata;\n}\n\n/**\n * Metadata about the source of a semantic node.\n * Useful for debugging, error messages, and round-trip conversion.\n */\nexport interface SemanticMetadata {\n readonly sourceLanguage?: string;\n readonly sourceText?: string;\n readonly sourcePosition?: SourcePosition;\n readonly patternId?: string;\n /**\n * Confidence score for the parse (0-1).\n * Higher values indicate more certain matches.\n * - 1.0: Exact match with all roles captured\n * - 0.8-0.99: High confidence with minor uncertainty\n * - 0.6-0.8: Medium confidence (normalization, defaults applied)\n * - <0.6: Low confidence (may need fallback)\n */\n readonly confidence?: number;\n}\n\nexport interface SourcePosition {\n readonly start: number;\n readonly end: number;\n readonly line?: number;\n readonly column?: number;\n}\n\n/**\n * A command semantic node - represents a single DSL command.\n */\nexport interface CommandSemanticNode extends SemanticNode {\n readonly kind: 'command';\n}\n\n/**\n * An event handler semantic node - represents trigger-based commands.\n * E.g., \"on click [commands]\" in hyperscript, or \"when condition [commands]\" in other DSLs.\n */\nexport interface EventHandlerSemanticNode extends SemanticNode {\n readonly kind: 'event-handler';\n readonly body: SemanticNode[];\n readonly eventModifiers?: EventModifiers;\n readonly additionalEvents?: readonly SemanticValue[];\n readonly parameterNames?: readonly string[];\n}\n\nexport interface EventModifiers {\n readonly once?: boolean;\n readonly debounce?: number;\n readonly throttle?: number;\n readonly queue?: 'first' | 'last' | 'all' | 'none';\n readonly from?: SemanticValue;\n}\n\n/**\n * A conditional semantic node - represents \"if [condition] then [body] else [body]\".\n */\nexport interface ConditionalSemanticNode extends SemanticNode {\n readonly kind: 'conditional';\n readonly thenBranch: SemanticNode[];\n readonly elseBranch?: SemanticNode[];\n}\n\n/**\n * A compound semantic node - represents multiple chained statements.\n */\nexport interface CompoundSemanticNode extends SemanticNode {\n readonly kind: 'compound';\n readonly statements: SemanticNode[];\n readonly chainType: 'then' | 'and' | 'async' | 'sequential';\n}\n\n/**\n * Loop variant discriminant for different loop types.\n */\nexport type LoopVariant = 'forever' | 'times' | 'for' | 'while' | 'until';\n\n/**\n * A loop semantic node - represents repeat/for/while loops.\n */\nexport interface LoopSemanticNode extends SemanticNode {\n readonly kind: 'loop';\n readonly loopVariant: LoopVariant;\n readonly body: SemanticNode[];\n readonly loopVariable?: string;\n readonly indexVariable?: string;\n}\n\n// =============================================================================\n// Tokenization Types\n// =============================================================================\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 /** Normalized form from explicit keyword map */\n readonly normalized?: string;\n /** Morphologically normalized stem */\n readonly stem?: string;\n /** Confidence in the morphological stem (0.0-1.0) */\n readonly stemConfidence?: number;\n /** Additional metadata for specific token types */\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\n /** Look at token at current position + offset without consuming */\n peek(offset?: number): LanguageToken | null;\n\n /** Consume and return current token, advance position */\n advance(): LanguageToken;\n\n /** Check if we've consumed all tokens */\n isAtEnd(): boolean;\n\n /** Save current position for backtracking */\n mark(): StreamMark;\n\n /** Restore to a saved position */\n reset(mark: StreamMark): void;\n\n /** Get current position */\n position(): number;\n}\n\n/**\n * Stream mark for backtracking during parsing.\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\n /** Convert input string to token stream */\n tokenize(input: string): TokenStream;\n\n /** Classify a single token */\n classifyToken(token: string): TokenKind;\n}\n\n// =============================================================================\n// Pattern Matching Types\n// =============================================================================\n\n/**\n * A language pattern defines how a semantic structure appears in a specific language.\n */\nexport interface LanguagePattern {\n /** Unique identifier for this pattern */\n readonly id: string;\n /** ISO 639-1 language code */\n readonly language: string;\n /** Which command this pattern matches */\n readonly command: ActionType;\n /** Priority for disambiguation (higher = checked first) */\n readonly priority: number;\n /** The pattern template with role placeholders */\n readonly template: PatternTemplate;\n /** Rules for extracting semantic roles from matched tokens */\n readonly extraction: ExtractionRules;\n /** Optional constraints on when this pattern applies */\n readonly constraints?: PatternConstraints;\n}\n\n/**\n * Pattern template - defines expected token sequence.\n */\nexport interface PatternTemplate {\n /** Human-readable template string */\n readonly format: string;\n /** Parsed token sequence for matching */\n readonly tokens: PatternToken[];\n}\n\n/**\n * Pattern token - literal, role placeholder, or group.\n */\nexport type PatternToken = LiteralPatternToken | RolePatternToken | GroupPatternToken;\n\nexport interface LiteralPatternToken {\n readonly type: 'literal';\n readonly value: string;\n /** Alternative spellings/forms that also match */\n readonly alternatives?: string[];\n}\n\nexport interface RolePatternToken {\n readonly type: 'role';\n readonly role: SemanticRole;\n readonly optional?: boolean;\n /** Expected value types (for validation) */\n readonly expectedTypes?: Array<ExpectedType>;\n /** When true, captures all remaining tokens until next marker or end */\n readonly greedy?: boolean;\n}\n\nexport interface GroupPatternToken {\n readonly type: 'group';\n readonly tokens: PatternToken[];\n readonly optional?: boolean;\n}\n\n/**\n * Rules for extracting semantic values from matched tokens.\n */\nexport interface ExtractionRules {\n readonly [role: string]: ExtractionRule;\n}\n\nexport interface ExtractionRule {\n /** Position-based extraction (0-indexed from pattern start) */\n readonly position?: number;\n /** Marker-based extraction (find value after this marker) */\n readonly marker?: string;\n /** Alternative markers that also work */\n readonly markerAlternatives?: string[];\n /** Transform the extracted value */\n readonly transform?: (raw: string) => SemanticValue;\n /** Default value if not found (for optional roles) */\n readonly default?: SemanticValue;\n /** Static value extraction */\n readonly value?: string;\n /** Extract value from a pattern role by name */\n readonly fromRole?: string;\n}\n\n/**\n * Additional constraints on pattern applicability.\n */\nexport interface PatternConstraints {\n /** Required roles that must be present */\n readonly requiredRoles?: SemanticRole[];\n /** Roles that must NOT be present */\n readonly forbiddenRoles?: SemanticRole[];\n /** Valid selector types for the patient role */\n readonly validPatientTypes?: Array<SelectorValue['selectorKind']>;\n /** Pattern IDs this conflicts with */\n readonly conflictsWith?: string[];\n}\n\n/**\n * Result of matching a pattern against tokens.\n */\nexport interface PatternMatchResult {\n readonly pattern: LanguagePattern;\n readonly captured: ReadonlyMap<SemanticRole, SemanticValue>;\n readonly consumedTokens: number;\n readonly confidence: number; // 0-1, how well the pattern matched\n}\n\n/**\n * Error when pattern matching fails.\n */\nexport interface PatternMatchError {\n readonly message: string;\n readonly position: SourcePosition;\n readonly expectedPatterns?: string[];\n readonly partialMatch?: Partial<PatternMatchResult>;\n}\n\n// =============================================================================\n// Helper Functions\n// =============================================================================\n\n/**\n * Create a literal value\n */\nexport function createLiteral(\n value: string | number | boolean,\n dataType?: 'string' | 'number' | 'boolean' | 'duration'\n): LiteralValue {\n return dataType ? { type: 'literal', value, dataType } : { type: 'literal', value };\n}\n\n/**\n * Create a selector value\n */\nexport function createSelector(\n value: string,\n selectorKind?: SelectorValue['selectorKind']\n): SelectorValue {\n return selectorKind ? { type: 'selector', value, selectorKind } : { type: 'selector', value };\n}\n\n/**\n * Create a reference value\n */\nexport function createReference(value: string): ReferenceValue {\n return { type: 'reference', value };\n}\n\n/**\n * Create a property path value\n */\nexport function createPropertyPath(object: SemanticValue, property: string): PropertyPathValue {\n return { type: 'property-path', object, property };\n}\n\n/**\n * Create an expression value\n */\nexport function createExpression(raw: string): ExpressionValue {\n return { type: 'expression', raw };\n}\n\n/**\n * Create a command semantic node\n */\nexport function createCommandNode(\n action: ActionType,\n roles: Record<SemanticRole, SemanticValue> | Map<SemanticRole, SemanticValue>,\n metadata?: SemanticMetadata\n): CommandSemanticNode {\n const rolesMap = roles instanceof Map ? roles : new Map(Object.entries(roles));\n const node: CommandSemanticNode = {\n kind: 'command',\n action,\n roles: rolesMap,\n };\n if (metadata) {\n return { ...node, metadata };\n }\n return node;\n}\n\n/**\n * Create an event handler semantic node\n */\nexport function createEventHandlerNode(\n action: ActionType,\n roles: Record<SemanticRole, SemanticValue> | Map<SemanticRole, SemanticValue>,\n body: SemanticNode[],\n metadata?: SemanticMetadata,\n eventModifiers?: EventModifiers\n): EventHandlerSemanticNode {\n const rolesMap = roles instanceof Map ? roles : new Map(Object.entries(roles));\n const base = {\n kind: 'event-handler' as const,\n action,\n roles: rolesMap,\n body,\n };\n return {\n ...base,\n ...(eventModifiers && { eventModifiers }),\n ...(metadata && { metadata }),\n };\n}\n\n/**\n * Create a conditional semantic node\n */\nexport function createConditionalNode(\n action: ActionType,\n roles: Record<SemanticRole, SemanticValue> | Map<SemanticRole, SemanticValue>,\n thenBranch: SemanticNode[],\n elseBranch?: SemanticNode[],\n metadata?: SemanticMetadata\n): ConditionalSemanticNode {\n const rolesMap = roles instanceof Map ? roles : new Map(Object.entries(roles));\n const base = {\n kind: 'conditional' as const,\n action,\n roles: rolesMap,\n thenBranch,\n };\n return {\n ...base,\n ...(elseBranch && { elseBranch }),\n ...(metadata && { metadata }),\n };\n}\n\n/**\n * Create a compound semantic node\n */\nexport function createCompoundNode(\n statements: SemanticNode[],\n chainType: CompoundSemanticNode['chainType'] = 'sequential',\n metadata?: SemanticMetadata\n): CompoundSemanticNode {\n const base = {\n kind: 'compound' as const,\n action: 'compound' as const,\n roles: new Map(),\n statements,\n chainType,\n };\n return metadata ? { ...base, metadata } : base;\n}\n\n/**\n * Extract a string value from a SemanticValue.\n *\n * Handles all value types in the SemanticValue union:\n * - ExpressionValue: returns `raw`\n * - LiteralValue/SelectorValue/ReferenceValue: returns `value` as string\n * - PropertyPathValue: returns `object.property` path\n *\n * This is the standard way to get a display string from any semantic value,\n * eliminating the need for `as any` casts in domain code generators.\n */\nexport function extractValue(value: SemanticValue): string {\n if ('raw' in value && value.raw !== undefined) return String(value.raw);\n if ('value' in value && value.value !== undefined) return String(value.value);\n if (value.type === 'property-path') return `${extractValue(value.object)}.${value.property}`;\n return '';\n}\n\n/**\n * Extract a string value from a named role on a SemanticNode.\n *\n * Convenience wrapper: looks up the role, returns empty string if missing.\n * Eliminates the common `const x = node.roles.get('role'); const val = x ? extractValue(x as any) : '';` pattern.\n */\nexport function extractRoleValue(node: SemanticNode, role: string): string {\n const value = node.roles.get(role);\n if (!value) return '';\n return extractValue(value);\n}\n\n/**\n * Create a loop semantic node\n */\nexport function createLoopNode(\n action: ActionType,\n roles: Record<SemanticRole, SemanticValue> | Map<SemanticRole, SemanticValue>,\n loopVariant: LoopVariant,\n body: SemanticNode[],\n loopVariable?: string,\n indexVariable?: string,\n metadata?: SemanticMetadata\n): LoopSemanticNode {\n const rolesMap = roles instanceof Map ? roles : new Map(Object.entries(roles));\n const base = {\n kind: 'loop' as const,\n action,\n roles: rolesMap,\n loopVariant,\n body,\n };\n return {\n ...base,\n ...(loopVariable && { loopVariable }),\n ...(indexVariable && { indexVariable }),\n ...(metadata && { metadata }),\n };\n}\n"],"mappings":";AAwZO,SAAS,cACd,OACA,UACc;AACd,SAAO,WAAW,EAAE,MAAM,WAAW,OAAO,SAAS,IAAI,EAAE,MAAM,WAAW,MAAM;AACpF;AAKO,SAAS,eACd,OACA,cACe;AACf,SAAO,eAAe,EAAE,MAAM,YAAY,OAAO,aAAa,IAAI,EAAE,MAAM,YAAY,MAAM;AAC9F;AAKO,SAAS,gBAAgB,OAA+B;AAC7D,SAAO,EAAE,MAAM,aAAa,MAAM;AACpC;AAKO,SAAS,mBAAmB,QAAuB,UAAqC;AAC7F,SAAO,EAAE,MAAM,iBAAiB,QAAQ,SAAS;AACnD;AAKO,SAAS,iBAAiB,KAA8B;AAC7D,SAAO,EAAE,MAAM,cAAc,IAAI;AACnC;AAKO,SAAS,kBACd,QACA,OACA,UACqB;AACrB,QAAM,WAAW,iBAAiB,MAAM,QAAQ,IAAI,IAAI,OAAO,QAAQ,KAAK,CAAC;AAC7E,QAAM,OAA4B;AAAA,IAChC,MAAM;AAAA,IACN;AAAA,IACA,OAAO;AAAA,EACT;AACA,MAAI,UAAU;AACZ,WAAO,EAAE,GAAG,MAAM,SAAS;A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AAI;AACjC,MAAI,CAAC,MAAO,QAAO;AACnB,SAAO,aAAa,KAAK;AAC3B;AAKO,SAAS,eACd,QACA,OACA,aACA,MACA,cACA,eACA,UACkB;AAClB,QAAM,WAAW,iBAAiB,MAAM,QAAQ,IAAI,IAAI,OAAO,QAAQ,KAAK,CAAC;AAC7E,QAAM,OAAO;AAAA,IACX,MAAM;AAAA,IACN;AAAA,IACA,OAAO;AAAA,IACP;AAAA,IACA;AAAA,EACF;AACA,SAAO;AAAA,IACL,GAAG;AAAA,IACH,GAAI,gBAAgB,EAAE,aAAa;AAAA,IACnC,GAAI,iBAAiB,EAAE,cAAc;AAAA,IACrC,GAAI,YAAY,EAAE,SAAS;AAAA,EAC7B;AACF;","names":[]}
1
+ {"version":3,"sources":["../../src/core/types.ts"],"sourcesContent":["/**\n * Generic Semantic Types for Multilingual DSLs\n *\n * This module defines the canonical semantic representation that all languages\n * parse to and render from. The semantic layer is language-neutral - it captures\n * the MEANING of DSL commands independent of surface syntax.\n *\n * These types are domain-agnostic - they work for any DSL (SQL, animations, etc.)\n */\n\n// =============================================================================\n// Action Types (Generic)\n// =============================================================================\n\n/**\n * Action type represents the command/operation in a DSL.\n * This is generic - each DSL defines its own set of actions.\n *\n * Examples:\n * - Hyperscript: 'toggle', 'add', 'remove', 'fetch'\n * - SQL: 'select', 'insert', 'update', 'delete'\n * - Animation: 'animate', 'fade', 'slide', 'rotate'\n */\nexport type ActionType = string;\n\n/**\n * Semantic role represents the grammatical function of a part of a command.\n * This is generic - each DSL can define its own roles, though common ones include:\n *\n * Common roles across DSLs:\n * - action: The verb/command\n * - patient: What is being acted upon\n * - destination: Where something goes\n * - source: Where something comes from\n * - condition: Boolean expressions\n * - quantity: Numeric amounts\n * - duration: Time spans\n *\n * Examples:\n * - Hyperscript: 'patient', 'destination', 'source', 'event', 'style'\n * - SQL: 'columns', 'table', 'condition', 'orderBy', 'limit'\n * - Animation: 'target', 'duration', 'easing', 'delay'\n */\nexport type SemanticRole = string;\n\n// =============================================================================\n// Semantic Values\n// =============================================================================\n\n/**\n * A semantic value represents a typed piece of data in a semantic node.\n * Values are language-neutral - they capture what something IS, not how it's written.\n */\nexport type SemanticValue =\n | LiteralValue\n | SelectorValue\n | ReferenceValue\n | PropertyPathValue\n | ExpressionValue\n | FlagValue;\n\n/**\n * Expected value types for role tokens.\n * Shared between RoleSpec (command-schemas) and RolePatternToken.\n */\nexport type ExpectedType = SemanticValue['type'];\n\nexport interface LiteralValue {\n readonly type: 'literal';\n readonly value: string | number | boolean;\n readonly dataType?: 'string' | 'number' | 'boolean' | 'duration';\n}\n\nexport interface SelectorValue {\n readonly type: 'selector';\n readonly value: string; // The selector: #id, .class, [attr], table-name, etc.\n readonly selectorKind?: 'id' | 'class' | 'attribute' | 'element' | 'complex' | 'identifier';\n}\n\nexport interface ReferenceValue {\n readonly type: 'reference';\n readonly value: string; // Generic reference name (DSL-specific)\n}\n\nexport interface PropertyPathValue {\n readonly type: 'property-path';\n readonly object: SemanticValue;\n readonly property: string;\n}\n\nexport interface ExpressionValue {\n readonly type: 'expression';\n /** Raw expression string for complex expressions that need further parsing */\n readonly raw: string;\n}\n\n/**\n * A boolean flag value — present (+flag) or negated (~flag).\n * Used in declarative domains for no-value attributes like primary-key, not-null.\n */\nexport interface FlagValue {\n readonly type: 'flag';\n readonly name: string;\n readonly enabled: boolean;\n}\n\n// =============================================================================\n// Annotations & Diagnostics (v1.2)\n// =============================================================================\n\n/** A metadata annotation on a node (v1.2). */\nexport interface Annotation {\n readonly name: string;\n readonly value?: string;\n}\n\n/**\n * A type constraint diagnostic attached to a node (v1.2).\n *\n * Named `ProtocolDiagnostic` to avoid collision with the framework's own\n * `Diagnostic` type (which has `severity: 'error' | 'warning' | 'info'`\n * and `suggestion?: string`).\n */\nexport interface ProtocolDiagnostic {\n readonly level: 'error' | 'warning';\n readonly role: string;\n readonly message: string;\n readonly code: string;\n}\n\n/** Async coordination variant (v1.2). */\nexport type AsyncVariant = 'all' | 'race';\n\n/** A single arm in a match command (v1.2). */\nexport interface MatchArm {\n readonly pattern: SemanticValue;\n readonly body: SemanticNode[];\n}\n\n// =============================================================================\n// Semantic Nodes\n// =============================================================================\n\n/**\n * Base interface for all semantic nodes.\n * Semantic nodes capture the MEANING of DSL constructs.\n */\nexport interface SemanticNode {\n readonly kind: 'command' | 'event-handler' | 'conditional' | 'compound' | 'loop';\n readonly action: ActionType;\n readonly roles: ReadonlyMap<SemanticRole, SemanticValue>;\n readonly metadata?: SemanticMetadata;\n /** Metadata annotations (v1.2). */\n readonly annotations?: readonly Annotation[];\n /** Type constraint diagnostics (v1.2). */\n readonly diagnostics?: readonly ProtocolDiagnostic[];\n}\n\n/**\n * Metadata about the source of a semantic node.\n * Useful for debugging, error messages, and round-trip conversion.\n */\nexport interface SemanticMetadata {\n readonly sourceLanguage?: string;\n readonly sourceText?: string;\n readonly sourcePosition?: SourcePosition;\n readonly patternId?: string;\n /**\n * Confidence score for the parse (0-1).\n * Higher values indicate more certain matches.\n * - 1.0: Exact match with all roles captured\n * - 0.8-0.99: High confidence with minor uncertainty\n * - 0.6-0.8: Medium confidence (normalization, defaults applied)\n * - <0.6: Low confidence (may need fallback)\n */\n readonly confidence?: number;\n}\n\nexport interface SourcePosition {\n readonly start: number;\n readonly end: number;\n readonly line?: number;\n readonly column?: number;\n}\n\n/**\n * A command semantic node - represents a single DSL command.\n *\n * v1.2 adds optional fields for try/catch/finally, async coordination (all/race),\n * and pattern matching (match/arms). These are encoded as fields on command nodes\n * (matching the protocol wire format) rather than new node kinds.\n */\nexport interface CommandSemanticNode extends SemanticNode {\n readonly kind: 'command';\n /** try body — commands to execute in the try block (v1.2). */\n readonly body?: readonly SemanticNode[];\n /** catch branch — commands to execute on error (v1.2). */\n readonly catchBranch?: readonly SemanticNode[];\n /** finally branch — cleanup commands that always execute (v1.2). */\n readonly finallyBranch?: readonly SemanticNode[];\n /** Async coordination variant: all (wait for all) or race (first wins) (v1.2). */\n readonly asyncVariant?: AsyncVariant;\n /** Async body — concurrent commands for all/race (v1.2). */\n readonly asyncBody?: readonly SemanticNode[];\n /** Match arms — pattern/body pairs for match command (v1.2). */\n readonly arms?: readonly MatchArm[];\n /** Default arm — executed when no match arm matches (v1.2). */\n readonly defaultArm?: readonly SemanticNode[];\n}\n\n/**\n * An event handler semantic node - represents trigger-based commands.\n * E.g., \"on click [commands]\" in hyperscript, or \"when condition [commands]\" in other DSLs.\n */\nexport interface EventHandlerSemanticNode extends SemanticNode {\n readonly kind: 'event-handler';\n readonly body: SemanticNode[];\n readonly eventModifiers?: EventModifiers;\n readonly additionalEvents?: readonly SemanticValue[];\n readonly parameterNames?: readonly string[];\n}\n\nexport interface EventModifiers {\n readonly once?: boolean;\n readonly debounce?: number;\n readonly throttle?: number;\n readonly queue?: 'first' | 'last' | 'all' | 'none';\n readonly from?: SemanticValue;\n}\n\n/**\n * A conditional semantic node - represents \"if [condition] then [body] else [body]\".\n */\nexport interface ConditionalSemanticNode extends SemanticNode {\n readonly kind: 'conditional';\n readonly thenBranch: SemanticNode[];\n readonly elseBranch?: SemanticNode[];\n}\n\n/**\n * A compound semantic node - represents multiple chained statements.\n */\nexport interface CompoundSemanticNode extends SemanticNode {\n readonly kind: 'compound';\n readonly statements: SemanticNode[];\n readonly chainType: 'then' | 'and' | 'async' | 'sequential' | 'pipe';\n}\n\n/**\n * Loop variant discriminant for different loop types.\n */\nexport type LoopVariant = 'forever' | 'times' | 'for' | 'while' | 'until';\n\n/**\n * A loop semantic node - represents repeat/for/while loops.\n */\nexport interface LoopSemanticNode extends SemanticNode {\n readonly kind: 'loop';\n readonly loopVariant: LoopVariant;\n readonly body: SemanticNode[];\n readonly loopVariable?: string;\n readonly indexVariable?: string;\n}\n\n// =============================================================================\n// Tokenization Types\n// =============================================================================\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 /** Normalized form from explicit keyword map */\n readonly normalized?: string;\n /** Morphologically normalized stem */\n readonly stem?: string;\n /** Confidence in the morphological stem (0.0-1.0) */\n readonly stemConfidence?: number;\n /** Additional metadata for specific token types */\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\n /** Look at token at current position + offset without consuming */\n peek(offset?: number): LanguageToken | null;\n\n /** Consume and return current token, advance position */\n advance(): LanguageToken;\n\n /** Check if we've consumed all tokens */\n isAtEnd(): boolean;\n\n /** Save current position for backtracking */\n mark(): StreamMark;\n\n /** Restore to a saved position */\n reset(mark: StreamMark): void;\n\n /** Get current position */\n position(): number;\n}\n\n/**\n * Stream mark for backtracking during parsing.\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\n /** Convert input string to token stream */\n tokenize(input: string): TokenStream;\n\n /** Classify a single token */\n classifyToken(token: string): TokenKind;\n}\n\n// =============================================================================\n// Pattern Matching Types\n// =============================================================================\n\n/**\n * A language pattern defines how a semantic structure appears in a specific language.\n */\nexport interface LanguagePattern {\n /** Unique identifier for this pattern */\n readonly id: string;\n /** ISO 639-1 language code */\n readonly language: string;\n /** Which command this pattern matches */\n readonly command: ActionType;\n /** Priority for disambiguation (higher = checked first) */\n readonly priority: number;\n /** The pattern template with role placeholders */\n readonly template: PatternTemplate;\n /** Rules for extracting semantic roles from matched tokens */\n readonly extraction: ExtractionRules;\n /** Optional constraints on when this pattern applies */\n readonly constraints?: PatternConstraints;\n}\n\n/**\n * Pattern template - defines expected token sequence.\n */\nexport interface PatternTemplate {\n /** Human-readable template string */\n readonly format: string;\n /** Parsed token sequence for matching */\n readonly tokens: PatternToken[];\n}\n\n/**\n * Pattern token - literal, role placeholder, or group.\n */\nexport type PatternToken = LiteralPatternToken | RolePatternToken | GroupPatternToken;\n\nexport interface LiteralPatternToken {\n readonly type: 'literal';\n readonly value: string;\n /** Alternative spellings/forms that also match */\n readonly alternatives?: string[];\n}\n\nexport interface RolePatternToken {\n readonly type: 'role';\n readonly role: SemanticRole;\n readonly optional?: boolean;\n /** Expected value types (for validation) */\n readonly expectedTypes?: Array<ExpectedType>;\n /** When true, captures all remaining tokens until next marker or end */\n readonly greedy?: boolean;\n}\n\nexport interface GroupPatternToken {\n readonly type: 'group';\n readonly tokens: PatternToken[];\n readonly optional?: boolean;\n}\n\n/**\n * Rules for extracting semantic values from matched tokens.\n */\nexport interface ExtractionRules {\n readonly [role: string]: ExtractionRule;\n}\n\nexport interface ExtractionRule {\n /** Position-based extraction (0-indexed from pattern start) */\n readonly position?: number;\n /** Marker-based extraction (find value after this marker) */\n readonly marker?: string;\n /** Alternative markers that also work */\n readonly markerAlternatives?: string[];\n /** Transform the extracted value */\n readonly transform?: (raw: string) => SemanticValue;\n /** Default value if not found (for optional roles) */\n readonly default?: SemanticValue;\n /** Static value extraction */\n readonly value?: string;\n /** Extract value from a pattern role by name */\n readonly fromRole?: string;\n}\n\n/**\n * Additional constraints on pattern applicability.\n */\nexport interface PatternConstraints {\n /** Required roles that must be present */\n readonly requiredRoles?: SemanticRole[];\n /** Roles that must NOT be present */\n readonly forbiddenRoles?: SemanticRole[];\n /** Valid selector types for the patient role */\n readonly validPatientTypes?: Array<SelectorValue['selectorKind']>;\n /** Pattern IDs this conflicts with */\n readonly conflictsWith?: string[];\n}\n\n/**\n * Result of matching a pattern against tokens.\n */\nexport interface PatternMatchResult {\n readonly pattern: LanguagePattern;\n readonly captured: ReadonlyMap<SemanticRole, SemanticValue>;\n readonly consumedTokens: number;\n readonly confidence: number; // 0-1, how well the pattern matched\n}\n\n/**\n * Error when pattern matching fails.\n */\nexport interface PatternMatchError {\n readonly message: string;\n readonly position: SourcePosition;\n readonly expectedPatterns?: string[];\n readonly partialMatch?: Partial<PatternMatchResult>;\n}\n\n// =============================================================================\n// Helper Functions\n// =============================================================================\n\n/**\n * Create a literal value\n */\nexport function createLiteral(\n value: string | number | boolean,\n dataType?: 'string' | 'number' | 'boolean' | 'duration'\n): LiteralValue {\n return dataType ? { type: 'literal', value, dataType } : { type: 'literal', value };\n}\n\n/**\n * Create a selector value\n */\nexport function createSelector(\n value: string,\n selectorKind?: SelectorValue['selectorKind']\n): SelectorValue {\n return selectorKind ? { type: 'selector', value, selectorKind } : { type: 'selector', value };\n}\n\n/**\n * Create a reference value\n */\nexport function createReference(value: string): ReferenceValue {\n return { type: 'reference', value };\n}\n\n/**\n * Create a property path value\n */\nexport function createPropertyPath(object: SemanticValue, property: string): PropertyPathValue {\n return { type: 'property-path', object, property };\n}\n\n/**\n * Create an expression value\n */\nexport function createExpression(raw: string): ExpressionValue {\n return { type: 'expression', raw };\n}\n\n/**\n * Create a boolean flag value (+flag or ~flag)\n */\nexport function createFlag(name: string, enabled: boolean = true): FlagValue {\n return { type: 'flag', name, enabled };\n}\n\n/**\n * Create a command semantic node\n */\nexport function createCommandNode(\n action: ActionType,\n roles: Record<SemanticRole, SemanticValue> | Map<SemanticRole, SemanticValue>,\n metadata?: SemanticMetadata\n): CommandSemanticNode {\n const rolesMap = roles instanceof Map ? roles : new Map(Object.entries(roles));\n const node: CommandSemanticNode = {\n kind: 'command',\n action,\n roles: rolesMap,\n };\n if (metadata) {\n return { ...node, metadata };\n }\n return node;\n}\n\n/**\n * Create an event handler semantic node\n */\nexport function createEventHandlerNode(\n action: ActionType,\n roles: Record<SemanticRole, SemanticValue> | Map<SemanticRole, SemanticValue>,\n body: SemanticNode[],\n metadata?: SemanticMetadata,\n eventModifiers?: EventModifiers\n): EventHandlerSemanticNode {\n const rolesMap = roles instanceof Map ? roles : new Map(Object.entries(roles));\n const base = {\n kind: 'event-handler' as const,\n action,\n roles: rolesMap,\n body,\n };\n return {\n ...base,\n ...(eventModifiers && { eventModifiers }),\n ...(metadata && { metadata }),\n };\n}\n\n/**\n * Create a conditional semantic node\n */\nexport function createConditionalNode(\n action: ActionType,\n roles: Record<SemanticRole, SemanticValue> | Map<SemanticRole, SemanticValue>,\n thenBranch: SemanticNode[],\n elseBranch?: SemanticNode[],\n metadata?: SemanticMetadata\n): ConditionalSemanticNode {\n const rolesMap = roles instanceof Map ? roles : new Map(Object.entries(roles));\n const base = {\n kind: 'conditional' as const,\n action,\n roles: rolesMap,\n thenBranch,\n };\n return {\n ...base,\n ...(elseBranch && { elseBranch }),\n ...(metadata && { metadata }),\n };\n}\n\n/**\n * Create a compound semantic node\n */\nexport function createCompoundNode(\n statements: SemanticNode[],\n chainType: CompoundSemanticNode['chainType'] = 'sequential',\n metadata?: SemanticMetadata\n): CompoundSemanticNode {\n const base = {\n kind: 'compound' as const,\n action: 'compound' as const,\n roles: new Map(),\n statements,\n chainType,\n };\n return metadata ? { ...base, metadata } : base;\n}\n\n/**\n * Extract a string value from a SemanticValue.\n *\n * Handles all value types in the SemanticValue union:\n * - ExpressionValue: returns `raw`\n * - LiteralValue/SelectorValue/ReferenceValue: returns `value` as string\n * - PropertyPathValue: returns `object.property` path\n *\n * This is the standard way to get a display string from any semantic value,\n * eliminating the need for `as any` casts in domain code generators.\n */\nexport function extractValue(value: SemanticValue): string {\n if (value.type === 'flag') return value.name;\n if ('raw' in value && value.raw !== undefined) return String(value.raw);\n if ('value' in value && value.value !== undefined) return String(value.value);\n if (value.type === 'property-path') return `${extractValue(value.object)}.${value.property}`;\n return '';\n}\n\n/**\n * Extract a string value from a named role on a SemanticNode.\n *\n * Convenience wrapper: looks up the role, returns empty string if missing.\n * Eliminates the common `const x = node.roles.get('role'); const val = x ? extractValue(x as any) : '';` pattern.\n */\nexport function extractRoleValue(node: SemanticNode, role: string): string {\n const value = node.roles.get(role);\n if (!value) return '';\n return extractValue(value);\n}\n\n/**\n * Create a loop semantic node\n */\nexport function createLoopNode(\n action: ActionType,\n roles: Record<SemanticRole, SemanticValue> | Map<SemanticRole, SemanticValue>,\n loopVariant: LoopVariant,\n body: SemanticNode[],\n loopVariable?: string,\n indexVariable?: string,\n metadata?: SemanticMetadata\n): LoopSemanticNode {\n const rolesMap = roles instanceof Map ? roles : new Map(Object.entries(roles));\n const base = {\n kind: 'loop' as const,\n action,\n roles: rolesMap,\n loopVariant,\n body,\n };\n return {\n ...base,\n ...(loopVariable && { loopVariable }),\n ...(indexVariable && { indexVariable }),\n ...(metadata && { metadata }),\n };\n}\n\n// =============================================================================\n// v1.2 Factory Helpers\n// =============================================================================\n\n/**\n * Create a try/catch/finally command node (v1.2).\n */\nexport function createTryNode(\n body: SemanticNode[],\n catchBranch?: SemanticNode[],\n finallyBranch?: SemanticNode[],\n metadata?: SemanticMetadata\n): CommandSemanticNode {\n return {\n kind: 'command',\n action: 'try',\n roles: new Map(),\n body,\n ...(catchBranch && catchBranch.length > 0 ? { catchBranch } : {}),\n ...(finallyBranch && finallyBranch.length > 0 ? { finallyBranch } : {}),\n ...(metadata ? { metadata } : {}),\n };\n}\n\n/**\n * Create an async coordination (all/race) command node (v1.2).\n */\nexport function createAsyncNode(\n variant: AsyncVariant,\n asyncBody: SemanticNode[],\n metadata?: SemanticMetadata\n): CommandSemanticNode {\n return {\n kind: 'command',\n action: variant,\n roles: new Map(),\n asyncVariant: variant,\n asyncBody,\n ...(metadata ? { metadata } : {}),\n };\n}\n\n/**\n * Create a match command node with pattern arms (v1.2).\n */\nexport function createMatchNode(\n roles: Record<SemanticRole, SemanticValue> | Map<SemanticRole, SemanticValue>,\n arms: MatchArm[],\n defaultArm?: SemanticNode[],\n metadata?: SemanticMetadata\n): CommandSemanticNode {\n const rolesMap = roles instanceof Map ? roles : new Map(Object.entries(roles));\n return {\n kind: 'command',\n action: 'match',\n roles: rolesMap,\n arms,\n ...(defaultArm && defaultArm.length > 0 ? { defaultArm } : {}),\n ...(metadata ? { metadata } : {}),\n };\n}\n\n/** Wire format envelope with version metadata (v1.2). */\nexport interface LSEEnvelope {\n readonly lseVersion: string;\n readonly features?: readonly string[];\n readonly nodes: readonly SemanticNode[];\n}\n"],"mappings":";AA0dO,SAAS,cACd,OACA,UACc;AACd,SAAO,WAAW,EAAE,MAAM,WAAW,OAAO,SAAS,IAAI,EAAE,MAAM,WAAW,MAAM;AACpF;AAKO,SAAS,eACd,OACA,cACe;AACf,SAAO,eAAe,EAAE,MAAM,YAAY,OAAO,aAAa,IAAI,EAAE,MAAM,YAAY,MAAM;AAC9F;AAKO,SAAS,gBAAgB,OAA+B;AAC7D,SAAO,EAAE,MAAM,aAAa,MAAM;AACpC;AAKO,SAAS,mBAAmB,QAAuB,UAAqC;AAC7F,SAAO,EAAE,MAAM,iBAAiB,QAAQ,SAAS;AACnD;AAKO,SAAS,iBAAiB,KAA8B;AAC7D,SAAO,EAAE,MAAM,cAAc,IAAI;AACnC;AAKO,SAAS,WAAW,MAAc,UAAmB,MAAiB;AAC3E,SAAO,EAAE,MAAM,QAAQ,MAAM,QAAQ;AACvC;AAKO,SAAS,kBACd,QACA,OACA,UACqB;AACrB,QAAM,WAAW,iBAAiB,MAAM,QAAQ,IAAI,IAAI,OAAO,QAAQ,KAAK,CAAC;AAC7E,QAAM,OAA4B;AAAA,IAChC,MAAM;AAAA,IACN;AAAA,IACA,OAAO;AAAA,EACT;AACA,MAAI,UAAU;AACZ,WAAO,EAAE,GAAG,MAAM,SAAS;AAAA,EAC7B;AACA,SAAO;AACT;AAKO,SAAS,uBACd,QACA,OACA,MACA,UACA,gBAC0B;AAC1B,QAAM,WAAW,iBAAiB,MAAM,QAAQ,IAAI,IAAI,OAAO,QAAQ,KAAK,CAAC;AAC7E,Q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Disambiguation
3
+ *
4
+ * When parse confidence is borderline (between low and high thresholds),
5
+ * generates a disambiguation request with alternative interpretations
6
+ * instead of blindly accepting or rejecting.
7
+ */
8
+ import type { SemanticNode } from '../core/types';
9
+ import type { DisambiguationRequest } from './types';
10
+ /**
11
+ * Check whether a confidence score falls in the disambiguation range.
12
+ *
13
+ * @returns true if the confidence is ambiguous (between low and high thresholds)
14
+ */
15
+ export declare function needsDisambiguation(confidence: number, low?: number, high?: number): boolean;
16
+ /**
17
+ * Build a disambiguation request from candidate interpretations.
18
+ *
19
+ * @param input - The original ambiguous input
20
+ * @param candidates - Alternative interpretations with confidence scores
21
+ */
22
+ export declare function buildDisambiguation(input: string, candidates: ReadonlyArray<{
23
+ action: string;
24
+ confidence: number;
25
+ node: SemanticNode;
26
+ description?: string;
27
+ }>): DisambiguationRequest;
28
+ //# sourceMappingURL=confidence-gate.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"confidence-gate.d.ts","sourceRoot":"","sources":["../../src/feedback/confidence-gate.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,eAAe,CAAC;AAElD,OAAO,KAAK,EAAE,qBAAqB,EAA2B,MAAM,SAAS,CAAC;AAM9E;;;;GAIG;AACH,wBAAgB,mBAAmB,CACjC,UAAU,EAAE,MAAM,EAClB,GAAG,GAAE,MAAY,EACjB,IAAI,GAAE,MAAY,GACjB,OAAO,CAET;AAED;;;;;GAKG;AACH,wBAAgB,mBAAmB,CACjC,KAAK,EAAE,MAAM,EACb,UAAU,EAAE,aAAa,CAAC;IACxB,MAAM,EAAE,MAAM,CAAC;IACf,UAAU,EAAE,MAAM,CAAC;IACnB,IAAI,EAAE,YAAY,CAAC;IACnB,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB,CAAC,GACD,qBAAqB,CA0BvB"}
@@ -0,0 +1,21 @@
1
+ /**
2
+ * Feedback Formatter
3
+ *
4
+ * Maps diagnostics to machine-actionable LSEFeedback with hints,
5
+ * corrected examples, and schema context. Enables LLMs to self-correct
6
+ * based on structured error information.
7
+ */
8
+ import type { Diagnostic } from '../generation/diagnostics';
9
+ import type { SchemaLookup } from '../ir/types';
10
+ import type { LSEFeedback } from './types';
11
+ /**
12
+ * Build structured feedback from diagnostics and optional schema context.
13
+ *
14
+ * @param input - The original input text
15
+ * @param inputFormat - Format of the input
16
+ * @param diagnostics - Error diagnostics from validation/parsing
17
+ * @param schemaLookup - Optional schema lookup for generating hints and corrections
18
+ * @param action - The attempted command action (if identifiable)
19
+ */
20
+ export declare function buildFeedback(input: string, inputFormat: 'explicit' | 'json' | 'natural', diagnostics: readonly Diagnostic[], schemaLookup?: SchemaLookup, action?: string): LSEFeedback;
21
+ //# sourceMappingURL=feedback-formatter.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"feedback-formatter.d.ts","sourceRoot":"","sources":["../../src/feedback/feedback-formatter.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,2BAA2B,CAAC;AAE5D,OAAO,KAAK,EAAE,YAAY,EAAmC,MAAM,aAAa,CAAC;AAGjF,OAAO,KAAK,EAAE,WAAW,EAA+B,MAAM,SAAS,CAAC;AAMxE;;;;;;;;GAQG;AACH,wBAAgB,aAAa,CAC3B,KAAK,EAAE,MAAM,EACb,WAAW,EAAE,UAAU,GAAG,MAAM,GAAG,SAAS,EAC5C,WAAW,EAAE,SAAS,UAAU,EAAE,EAClC,YAAY,CAAC,EAAE,YAAY,EAC3B,MAAM,CAAC,EAAE,MAAM,GACd,WAAW,CA0Bb"}
@@ -0,0 +1,11 @@
1
+ /**
2
+ * Feedback Loop
3
+ *
4
+ * Structured error feedback, confidence-aware disambiguation,
5
+ * and pattern hit-rate tracking for the LLM ↔ LSE integration.
6
+ */
7
+ export type { LSEFeedback, FeedbackDiagnostic, FixType, DisambiguationRequest, DisambiguationCandidate, PatternEvent, HitRate, PatternTrackerSummary, TopFailure, } from './types';
8
+ export { buildFeedback } from './feedback-formatter';
9
+ export { needsDisambiguation, buildDisambiguation } from './confidence-gate';
10
+ export { PatternTracker } from './pattern-tracker';
11
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/feedback/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,YAAY,EACV,WAAW,EACX,kBAAkB,EAClB,OAAO,EACP,qBAAqB,EACrB,uBAAuB,EACvB,YAAY,EACZ,OAAO,EACP,qBAAqB,EACrB,UAAU,GACX,MAAM,SAAS,CAAC;AAEjB,OAAO,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AAErD,OAAO,EAAE,mBAAmB,EAAE,mBAAmB,EAAE,MAAM,mBAAmB,CAAC;AAE7E,OAAO,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC"}
@@ -0,0 +1,47 @@
1
+ /**
2
+ * Pattern Hit-Rate Tracker
3
+ *
4
+ * Records pattern events in a ring buffer and computes hit-rate
5
+ * statistics by command, language, and diagnostic code. Patterns
6
+ * with high rejected/attempts ratios indicate miscalibrated confidence.
7
+ */
8
+ import type { PatternEvent, HitRate, PatternTrackerSummary, TopFailure } from './types';
9
+ export declare class PatternTracker {
10
+ private events;
11
+ private readonly maxEvents;
12
+ constructor(maxEvents?: number);
13
+ /**
14
+ * Record a pattern event.
15
+ */
16
+ record(event: PatternEvent): void;
17
+ /**
18
+ * Get hit rate by command action.
19
+ */
20
+ getHitRateByCommand(): Record<string, HitRate>;
21
+ /**
22
+ * Get hit rate by language.
23
+ */
24
+ getHitRateByLanguage(): Record<string, HitRate>;
25
+ /**
26
+ * Get the most frequent failure diagnostic codes.
27
+ */
28
+ getTopFailures(limit?: number): TopFailure[];
29
+ /**
30
+ * Get a complete summary of tracking data.
31
+ */
32
+ getSummary(): PatternTrackerSummary;
33
+ /**
34
+ * Export all events as JSONL.
35
+ */
36
+ exportJSONL(): string;
37
+ /**
38
+ * Get the number of recorded events.
39
+ */
40
+ get size(): number;
41
+ /**
42
+ * Clear all events.
43
+ */
44
+ clear(): void;
45
+ private computeHitRate;
46
+ }
47
+ //# sourceMappingURL=pattern-tracker.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"pattern-tracker.d.ts","sourceRoot":"","sources":["../../src/feedback/pattern-tracker.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,KAAK,EAAE,YAAY,EAAE,OAAO,EAAE,qBAAqB,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AAMxF,qBAAa,cAAc;IACzB,OAAO,CAAC,MAAM,CAAsB;IACpC,OAAO,CAAC,QAAQ,CAAC,SAAS,CAAS;gBAEvB,SAAS,GAAE,MAAa;IAIpC;;OAEG;IACH,MAAM,CAAC,KAAK,EAAE,YAAY,GAAG,IAAI;IAQjC;;OAEG;IACH,mBAAmB,IAAI,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC;IAI9C;;OAEG;IACH,oBAAoB,IAAI,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC;IAI/C;;OAEG;IACH,cAAc,CAAC,KAAK,GAAE,MAAW,GAAG,UAAU,EAAE;IAuBhD;;OAEG;IACH,UAAU,IAAI,qBAAqB;IAenC;;OAEG;IACH,WAAW,IAAI,MAAM;IAIrB;;OAEG;IACH,IAAI,IAAI,IAAI,MAAM,CAEjB;IAED;;OAEG;IACH,KAAK,IAAI,IAAI;IAQb,OAAO,CAAC,cAAc;CAuBvB"}
@@ -0,0 +1,113 @@
1
+ /**
2
+ * Feedback Loop Types
3
+ *
4
+ * Types for structured error feedback, confidence-aware disambiguation,
5
+ * and pattern hit-rate tracking in the LLM ↔ LSE integration.
6
+ */
7
+ import type { SemanticJSON } from '../ir/types';
8
+ /**
9
+ * Structured feedback for an LSE validation attempt.
10
+ */
11
+ export interface LSEFeedback {
12
+ /** Whether the input was accepted (no errors) */
13
+ readonly accepted: boolean;
14
+ /** The original input */
15
+ readonly input: {
16
+ readonly format: 'explicit' | 'json' | 'natural';
17
+ readonly text: string;
18
+ };
19
+ /** Machine-actionable diagnostics */
20
+ readonly diagnostics: readonly FeedbackDiagnostic[];
21
+ /** Human-readable hints for retrying */
22
+ readonly hints: readonly string[];
23
+ /** Valid schema structure for the attempted command (if identifiable) */
24
+ readonly schema?: {
25
+ readonly action: string;
26
+ readonly requiredRoles: readonly string[];
27
+ readonly optionalRoles: readonly string[];
28
+ readonly roleDescriptions: Readonly<Record<string, string>>;
29
+ };
30
+ /** Corrected example (if fixable) */
31
+ readonly correctedExample?: {
32
+ readonly explicit: string;
33
+ readonly json: SemanticJSON;
34
+ };
35
+ }
36
+ /**
37
+ * A single diagnostic with machine-actionable fix type.
38
+ */
39
+ export interface FeedbackDiagnostic {
40
+ readonly severity: 'error' | 'warning' | 'info';
41
+ readonly code: string;
42
+ readonly message: string;
43
+ readonly suggestion?: string;
44
+ readonly fixType?: FixType;
45
+ }
46
+ /**
47
+ * Machine-actionable fix type for LLM retry logic.
48
+ */
49
+ export type FixType = 'missing_role' | 'invalid_type' | 'unknown_command' | 'unknown_role' | 'syntax_error';
50
+ /**
51
+ * A disambiguation request presented when confidence is borderline.
52
+ */
53
+ export interface DisambiguationRequest {
54
+ /** The original input that was ambiguous */
55
+ readonly input: string;
56
+ /** Candidate interpretations ranked by confidence */
57
+ readonly candidates: readonly DisambiguationCandidate[];
58
+ /** Human/LLM-readable disambiguation prompt */
59
+ readonly question: string;
60
+ }
61
+ /**
62
+ * A single candidate interpretation.
63
+ */
64
+ export interface DisambiguationCandidate {
65
+ /** Command action */
66
+ readonly action: string;
67
+ /** Confidence score */
68
+ readonly confidence: number;
69
+ /** Canonical LSE for this interpretation */
70
+ readonly explicit: string;
71
+ /** Human-readable description */
72
+ readonly description: string;
73
+ }
74
+ /**
75
+ * A single pattern event for hit-rate tracking.
76
+ */
77
+ export interface PatternEvent {
78
+ readonly timestamp: number;
79
+ readonly domain: string;
80
+ readonly action: string;
81
+ readonly language: string;
82
+ readonly inputFormat: 'explicit' | 'json' | 'natural';
83
+ readonly confidence: number;
84
+ readonly outcome: 'accepted' | 'rejected' | 'disambiguated';
85
+ readonly diagnosticCodes?: readonly string[];
86
+ }
87
+ /**
88
+ * Hit-rate statistics for a category.
89
+ */
90
+ export interface HitRate {
91
+ readonly attempts: number;
92
+ readonly successes: number;
93
+ readonly rate: number;
94
+ }
95
+ /**
96
+ * Summary of pattern tracking data.
97
+ */
98
+ export interface PatternTrackerSummary {
99
+ readonly totalEvents: number;
100
+ readonly byOutcome: Readonly<Record<string, number>>;
101
+ readonly byCommand: Readonly<Record<string, HitRate>>;
102
+ readonly byLanguage: Readonly<Record<string, HitRate>>;
103
+ readonly topFailures: readonly TopFailure[];
104
+ }
105
+ /**
106
+ * A frequently failing diagnostic code.
107
+ */
108
+ export interface TopFailure {
109
+ readonly code: string;
110
+ readonly count: number;
111
+ readonly actions: readonly string[];
112
+ }
113
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/feedback/types.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAMhD;;GAEG;AACH,MAAM,WAAW,WAAW;IAC1B,iDAAiD;IACjD,QAAQ,CAAC,QAAQ,EAAE,OAAO,CAAC;IAE3B,yBAAyB;IACzB,QAAQ,CAAC,KAAK,EAAE;QACd,QAAQ,CAAC,MAAM,EAAE,UAAU,GAAG,MAAM,GAAG,SAAS,CAAC;QACjD,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;KACvB,CAAC;IAEF,qCAAqC;IACrC,QAAQ,CAAC,WAAW,EAAE,SAAS,kBAAkB,EAAE,CAAC;IAEpD,wCAAwC;IACxC,QAAQ,CAAC,KAAK,EAAE,SAAS,MAAM,EAAE,CAAC;IAElC,yEAAyE;IACzE,QAAQ,CAA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B,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,QAAQ,CAAC,OAAO,EAAE,SAAS,MAAM,EAAE,CAAC;CACrC"}
@@ -69,7 +69,7 @@ function addRoleWithMarker(tokens, roleSpec, profile) {
69
69
  if (marker) {
70
70
  const markerInfo = profile.roleMarkers?.[roleSpec.role];
71
71
  const defaultPosition = profile.wordOrder === "SOV" ? "after" : "before";
72
- const position = markerInfo?.position ?? defaultPosition;
72
+ const position = roleSpec.markerPosition ?? markerInfo?.position ?? defaultPosition;
73
73
  if (isOptional) {
74
74
  if (position === "before") {
75
75
  tokens.push({
@@ -156,6 +156,7 @@ function generatePatternVariants(schema, profile, config = defaultConfig) {
156
156
 
157
157
  // src/core/types.ts
158
158
  function extractValue(value) {
159
+ if (value.type === "flag") return value.name;
159
160
  if ("raw" in value && value.raw !== void 0) return String(value.raw);
160
161
  if ("value" in value && value.value !== void 0) return String(value.value);
161
162
  if (value.type === "property-path") return `${extractValue(value.object)}.${value.property}`;