@lokascript/framework 2.0.0 → 2.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/aot/index.d.ts +1 -0
- package/dist/aot/index.d.ts.map +1 -1
- package/dist/aot/registry-bridge.d.ts +27 -0
- package/dist/aot/registry-bridge.d.ts.map +1 -0
- package/dist/api/create-dsl.d.ts.map +1 -1
- package/dist/api/dispatcher.d.ts +22 -0
- package/dist/api/dispatcher.d.ts.map +1 -1
- package/dist/api/domain-registry.d.ts +41 -0
- package/dist/api/domain-registry.d.ts.map +1 -1
- package/dist/api/index.js +1438 -21
- package/dist/api/index.js.map +1 -1
- package/dist/core/index.js +247 -10
- package/dist/core/index.js.map +1 -1
- package/dist/core/pattern-matching/index.js +74 -10
- package/dist/core/pattern-matching/index.js.map +1 -1
- package/dist/core/pattern-matching/pattern-matcher.d.ts.map +1 -1
- package/dist/core/tokenization/index.js +133 -0
- package/dist/core/tokenization/index.js.map +1 -1
- package/dist/core/tokenization/morphology/base-normalizer.d.ts +94 -0
- package/dist/core/tokenization/morphology/base-normalizer.d.ts.map +1 -0
- package/dist/core/tokenization/morphology/index.d.ts +3 -1
- package/dist/core/tokenization/morphology/index.d.ts.map +1 -1
- package/dist/core/types.d.ts +81 -2
- package/dist/core/types.d.ts.map +1 -1
- package/dist/core/types.js +40 -0
- package/dist/core/types.js.map +1 -1
- package/dist/feedback/confidence-gate.d.ts +28 -0
- package/dist/feedback/confidence-gate.d.ts.map +1 -0
- package/dist/feedback/feedback-formatter.d.ts +21 -0
- package/dist/feedback/feedback-formatter.d.ts.map +1 -0
- package/dist/feedback/index.d.ts +11 -0
- package/dist/feedback/index.d.ts.map +1 -0
- package/dist/feedback/pattern-tracker.d.ts +47 -0
- package/dist/feedback/pattern-tracker.d.ts.map +1 -0
- package/dist/feedback/types.d.ts +113 -0
- package/dist/feedback/types.d.ts.map +1 -0
- package/dist/generation/index.js +2 -1
- package/dist/generation/index.js.map +1 -1
- package/dist/index.cjs +3264 -132
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +8 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +3223 -132
- package/dist/index.js.map +1 -1
- package/dist/ir/explicit-parser.d.ts +86 -0
- package/dist/ir/explicit-parser.d.ts.map +1 -0
- package/dist/ir/explicit-renderer.d.ts +34 -0
- package/dist/ir/explicit-renderer.d.ts.map +1 -0
- package/dist/ir/from-interchange.d.ts +51 -0
- package/dist/ir/from-interchange.d.ts.map +1 -0
- package/dist/ir/index.d.ts +31 -0
- package/dist/ir/index.d.ts.map +1 -0
- package/dist/ir/index.js +1934 -0
- package/dist/ir/index.js.map +1 -0
- package/dist/ir/json-schema.d.ts +40 -0
- package/dist/ir/json-schema.d.ts.map +1 -0
- package/dist/ir/protocol-json.d.ts +73 -0
- package/dist/ir/protocol-json.d.ts.map +1 -0
- package/dist/ir/references.d.ts +19 -0
- package/dist/ir/references.d.ts.map +1 -0
- package/dist/ir/to-runtime-ast.d.ts +53 -0
- package/dist/ir/to-runtime-ast.d.ts.map +1 -0
- package/dist/ir/types.d.ts +151 -0
- package/dist/ir/types.d.ts.map +1 -0
- package/dist/parsing/index.js +74 -10
- package/dist/parsing/index.js.map +1 -1
- package/dist/prompts/index.d.ts +9 -0
- package/dist/prompts/index.d.ts.map +1 -0
- package/dist/prompts/prompt-generator.d.ts +49 -0
- package/dist/prompts/prompt-generator.d.ts.map +1 -0
- package/dist/prompts/types.d.ts +64 -0
- package/dist/prompts/types.d.ts.map +1 -0
- package/dist/schema/command-schema.d.ts +17 -0
- package/dist/schema/command-schema.d.ts.map +1 -1
- package/dist/schema/index.js.map +1 -1
- package/dist/testing/index.js +8673 -8260
- package/dist/testing/index.js.map +1 -1
- package/dist/training/index.d.ts +11 -0
- package/dist/training/index.d.ts.map +1 -0
- package/dist/training/jsonl-writer.d.ts +42 -0
- package/dist/training/jsonl-writer.d.ts.map +1 -0
- package/dist/training/schema-synthesizer.d.ts +20 -0
- package/dist/training/schema-synthesizer.d.ts.map +1 -0
- package/dist/training/types.d.ts +73 -0
- package/dist/training/types.d.ts.map +1 -0
- package/package.json +5 -1
- package/src/aot/index.ts +1 -0
- package/src/aot/registry-bridge.test.ts +104 -0
- package/src/aot/registry-bridge.ts +66 -0
- package/src/api/create-dsl.test.ts +306 -0
- package/src/api/create-dsl.ts +21 -0
- package/src/api/dispatcher.test.ts +66 -0
- package/src/api/dispatcher.ts +77 -9
- package/src/api/domain-registry.ts +120 -4
- package/src/core/pattern-matching/pattern-matcher.test.ts +131 -0
- package/src/core/pattern-matching/pattern-matcher.ts +102 -19
- package/src/core/tokenization/morphology/base-normalizer.ts +249 -0
- package/src/core/tokenization/morphology/index.ts +3 -1
- package/src/core/types.ts +147 -2
- package/src/feedback/confidence-gate.test.ts +111 -0
- package/src/feedback/confidence-gate.ts +70 -0
- package/src/feedback/feedback-formatter.test.ts +198 -0
- package/src/feedback/feedback-formatter.ts +298 -0
- package/src/feedback/index.ts +24 -0
- package/src/feedback/pattern-tracker.test.ts +198 -0
- package/src/feedback/pattern-tracker.ts +140 -0
- package/src/feedback/types.ts +149 -0
- package/src/generation/pattern-generator.ts +2 -2
- package/src/index.ts +29 -0
- package/src/integration/llm-lse-integration.test.ts +457 -0
- package/src/ir/conformance.test.ts +120 -0
- package/src/ir/explicit-parser.test.ts +612 -0
- package/src/ir/explicit-parser.ts +793 -0
- package/src/ir/explicit-renderer.test.ts +229 -0
- package/src/ir/explicit-renderer.ts +198 -0
- package/src/ir/from-interchange.test.ts +853 -0
- package/src/ir/from-interchange.ts +594 -0
- package/src/ir/index.ts +77 -0
- package/src/ir/json-schema.test.ts +281 -0
- package/src/ir/json-schema.ts +299 -0
- package/src/ir/protocol-json.test.ts +1187 -0
- package/src/ir/protocol-json.ts +751 -0
- package/src/ir/references.test.ts +38 -0
- package/src/ir/references.ts +33 -0
- package/src/ir/round-trip.test.ts +557 -0
- package/src/ir/to-runtime-ast.ts +203 -0
- package/src/ir/types.ts +191 -0
- package/src/prompts/index.ts +15 -0
- package/src/prompts/prompt-generator.test.ts +386 -0
- package/src/prompts/prompt-generator.ts +531 -0
- package/src/prompts/types.ts +89 -0
- package/src/schema/command-schema.ts +19 -0
- package/src/training/index.ts +13 -0
- package/src/training/jsonl-writer.test.ts +138 -0
- package/src/training/jsonl-writer.ts +67 -0
- package/src/training/schema-synthesizer.test.ts +250 -0
- package/src/training/schema-synthesizer.ts +306 -0
- package/src/training/types.ts +103 -0
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* BaseMorphologicalNormalizer — Shared base class for language normalizers.
|
|
3
|
+
*
|
|
4
|
+
* Provides the common suffix/prefix stripping loop, reflexive verb handling,
|
|
5
|
+
* and normalize() pipeline. Language-specific normalizers extend this class
|
|
6
|
+
* and provide their conjugation rules.
|
|
7
|
+
*
|
|
8
|
+
* Phase 3.1 of parser-ecosystem-plan-v3.
|
|
9
|
+
*/
|
|
10
|
+
import type { MorphologicalNormalizer, NormalizationResult, ConjugationType, SuffixRule, PrefixRule } from './types';
|
|
11
|
+
/**
|
|
12
|
+
* Conjugation ending rule for verb classes (Romance languages etc.)
|
|
13
|
+
* Broader than SuffixRule — includes the replacement stem (e.g., strip -ando, add -ar).
|
|
14
|
+
*/
|
|
15
|
+
export interface ConjugationEnding {
|
|
16
|
+
readonly ending: string;
|
|
17
|
+
readonly stem: string;
|
|
18
|
+
readonly confidence: number;
|
|
19
|
+
readonly type: ConjugationType;
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* Configuration for BaseMorphologicalNormalizer.
|
|
23
|
+
* Subclasses provide this in their constructor.
|
|
24
|
+
*/
|
|
25
|
+
export interface NormalizerConfig {
|
|
26
|
+
/** Language code */
|
|
27
|
+
readonly language: string;
|
|
28
|
+
/** Minimum word length to attempt normalization */
|
|
29
|
+
readonly minWordLength?: number;
|
|
30
|
+
/** Minimum stem length after stripping (default: 2) */
|
|
31
|
+
readonly minStemLength?: number;
|
|
32
|
+
/** Conjugation endings sorted longest-first */
|
|
33
|
+
readonly endings?: readonly ConjugationEnding[];
|
|
34
|
+
/** Suffix rules (for SuffixRule-style normalizers) */
|
|
35
|
+
readonly suffixRules?: readonly SuffixRule[];
|
|
36
|
+
/** Prefix rules */
|
|
37
|
+
readonly prefixRules?: readonly PrefixRule[];
|
|
38
|
+
/** Reflexive suffixes (for Romance languages) */
|
|
39
|
+
readonly reflexiveSuffixes?: readonly string[];
|
|
40
|
+
/** Infinitive endings (for checking if already normalized) */
|
|
41
|
+
readonly infinitiveEndings?: readonly string[];
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* Abstract base class for morphological normalizers.
|
|
45
|
+
*
|
|
46
|
+
* Subclasses must implement `isNormalizable()` and can override any
|
|
47
|
+
* normalization step. The default `normalize()` pipeline is:
|
|
48
|
+
*
|
|
49
|
+
* 1. Check if already in dictionary form → noChange
|
|
50
|
+
* 2. Try reflexive normalization (if reflexiveSuffixes configured)
|
|
51
|
+
* 3. Try conjugation endings (if endings configured)
|
|
52
|
+
* 4. Try suffix rules (if suffixRules configured)
|
|
53
|
+
* 5. Try prefix rules (if prefixRules configured)
|
|
54
|
+
* 6. Return noChange
|
|
55
|
+
*/
|
|
56
|
+
export declare abstract class BaseMorphologicalNormalizer implements MorphologicalNormalizer {
|
|
57
|
+
readonly language: string;
|
|
58
|
+
protected readonly config: NormalizerConfig;
|
|
59
|
+
constructor(config: NormalizerConfig);
|
|
60
|
+
/**
|
|
61
|
+
* Check if a word can be normalized. Subclasses must implement this
|
|
62
|
+
* with language-specific script/character detection.
|
|
63
|
+
*/
|
|
64
|
+
abstract isNormalizable(word: string): boolean;
|
|
65
|
+
/**
|
|
66
|
+
* Standard normalization pipeline. Override for custom behavior.
|
|
67
|
+
*/
|
|
68
|
+
normalize(word: string): NormalizationResult;
|
|
69
|
+
/**
|
|
70
|
+
* Check if word is already in dictionary form (e.g., ends in -ar/-er/-ir).
|
|
71
|
+
* Override for language-specific checks.
|
|
72
|
+
*/
|
|
73
|
+
protected isAlreadyNormalized(word: string): boolean;
|
|
74
|
+
/**
|
|
75
|
+
* Try to strip reflexive suffixes and normalize the remainder.
|
|
76
|
+
* Common in Romance languages (Spanish, Portuguese, French).
|
|
77
|
+
*/
|
|
78
|
+
protected tryReflexiveNormalization(word: string): NormalizationResult | null;
|
|
79
|
+
/**
|
|
80
|
+
* Try conjugation endings (verb class endings like -ar/-er/-ir patterns).
|
|
81
|
+
* Endings must be pre-sorted longest-first.
|
|
82
|
+
*/
|
|
83
|
+
protected tryConjugationEndings(word: string): NormalizationResult | null;
|
|
84
|
+
/**
|
|
85
|
+
* Try SuffixRule-style normalization.
|
|
86
|
+
* Rules must be pre-sorted longest-first.
|
|
87
|
+
*/
|
|
88
|
+
protected trySuffixRules(word: string): NormalizationResult | null;
|
|
89
|
+
/**
|
|
90
|
+
* Try PrefixRule-style normalization.
|
|
91
|
+
*/
|
|
92
|
+
protected tryPrefixRules(word: string): NormalizationResult | null;
|
|
93
|
+
}
|
|
94
|
+
//# sourceMappingURL=base-normalizer.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"base-normalizer.d.ts","sourceRoot":"","sources":["../../../../src/core/tokenization/morphology/base-normalizer.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,KAAK,EACV,uBAAuB,EACvB,mBAAmB,EACnB,eAAe,EACf,UAAU,EACV,UAAU,EACX,MAAM,SAAS,CAAC;AAGjB;;;GAGG;AACH,MAAM,WAAW,iBAAiB;IAChC,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAC;IAC5B,QAAQ,CAAC,IAAI,EAAE,eAAe,CAAC;CAChC;AAED;;;GAGG;AACH,MAAM,WAAW,gBAAgB;IAC/B,oBAAoB;IACpB,QAAQ,CAAC,QAAQ,EAAE,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E;;OAEG;IACH,SAAS,CAAC,cAAc,CAAC,IAAI,EAAE,MAAM,GAAG,mBAAmB,GAAG,IAAI;CAkBnE"}
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Morphological normalization types and
|
|
2
|
+
* Morphological normalization types, interfaces, and base class
|
|
3
3
|
*/
|
|
4
4
|
export * from './types';
|
|
5
|
+
export { BaseMorphologicalNormalizer } from './base-normalizer';
|
|
6
|
+
export type { ConjugationEnding, NormalizerConfig } from './base-normalizer';
|
|
5
7
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/core/tokenization/morphology/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,cAAc,SAAS,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/core/tokenization/morphology/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,cAAc,SAAS,CAAC;AACxB,OAAO,EAAE,2BAA2B,EAAE,MAAM,mBAAmB,CAAC;AAChE,YAAY,EAAE,iBAAiB,EAAE,gBAAgB,EAAE,MAAM,mBAAmB,CAAC"}
|
package/dist/core/types.d.ts
CHANGED
|
@@ -7,6 +7,7 @@
|
|
|
7
7
|
*
|
|
8
8
|
* These types are domain-agnostic - they work for any DSL (SQL, animations, etc.)
|
|
9
9
|
*/
|
|
10
|
+
import type { Diagnostic } from '../generation/diagnostics';
|
|
10
11
|
/**
|
|
11
12
|
* Action type represents the command/operation in a DSL.
|
|
12
13
|
* This is generic - each DSL defines its own set of actions.
|
|
@@ -40,7 +41,7 @@ export type SemanticRole = string;
|
|
|
40
41
|
* A semantic value represents a typed piece of data in a semantic node.
|
|
41
42
|
* Values are language-neutral - they capture what something IS, not how it's written.
|
|
42
43
|
*/
|
|
43
|
-
export type SemanticValue = LiteralValue | SelectorValue | ReferenceValue | PropertyPathValue | ExpressionValue;
|
|
44
|
+
export type SemanticValue = LiteralValue | SelectorValue | ReferenceValue | PropertyPathValue | ExpressionValue | FlagValue;
|
|
44
45
|
/**
|
|
45
46
|
* Expected value types for role tokens.
|
|
46
47
|
* Shared between RoleSpec (command-schemas) and RolePatternToken.
|
|
@@ -70,6 +71,40 @@ export interface ExpressionValue {
|
|
|
70
71
|
/** Raw expression string for complex expressions that need further parsing */
|
|
71
72
|
readonly raw: string;
|
|
72
73
|
}
|
|
74
|
+
/**
|
|
75
|
+
* A boolean flag value — present (+flag) or negated (~flag).
|
|
76
|
+
* Used in declarative domains for no-value attributes like primary-key, not-null.
|
|
77
|
+
*/
|
|
78
|
+
export interface FlagValue {
|
|
79
|
+
readonly type: 'flag';
|
|
80
|
+
readonly name: string;
|
|
81
|
+
readonly enabled: boolean;
|
|
82
|
+
}
|
|
83
|
+
/** A metadata annotation on a node (v1.2). */
|
|
84
|
+
export interface Annotation {
|
|
85
|
+
readonly name: string;
|
|
86
|
+
readonly value?: string;
|
|
87
|
+
}
|
|
88
|
+
/**
|
|
89
|
+
* A type constraint diagnostic attached to a node (v1.2).
|
|
90
|
+
*
|
|
91
|
+
* Named `ProtocolDiagnostic` to avoid collision with the framework's own
|
|
92
|
+
* `Diagnostic` type (which has `severity: 'error' | 'warning' | 'info'`
|
|
93
|
+
* and `suggestion?: string`).
|
|
94
|
+
*/
|
|
95
|
+
export interface ProtocolDiagnostic {
|
|
96
|
+
readonly level: 'error' | 'warning';
|
|
97
|
+
readonly role: string;
|
|
98
|
+
readonly message: string;
|
|
99
|
+
readonly code: string;
|
|
100
|
+
}
|
|
101
|
+
/** Async coordination variant (v1.2). */
|
|
102
|
+
export type AsyncVariant = 'all' | 'race';
|
|
103
|
+
/** A single arm in a match command (v1.2). */
|
|
104
|
+
export interface MatchArm {
|
|
105
|
+
readonly pattern: SemanticValue;
|
|
106
|
+
readonly body: SemanticNode[];
|
|
107
|
+
}
|
|
73
108
|
/**
|
|
74
109
|
* Base interface for all semantic nodes.
|
|
75
110
|
* Semantic nodes capture the MEANING of DSL constructs.
|
|
@@ -79,6 +114,10 @@ export interface SemanticNode {
|
|
|
79
114
|
readonly action: ActionType;
|
|
80
115
|
readonly roles: ReadonlyMap<SemanticRole, SemanticValue>;
|
|
81
116
|
readonly metadata?: SemanticMetadata;
|
|
117
|
+
/** Metadata annotations (v1.2). */
|
|
118
|
+
readonly annotations?: readonly Annotation[];
|
|
119
|
+
/** Diagnostics from parsing, validation, and schema checks (v1.2, extended v1.2.1). */
|
|
120
|
+
readonly diagnostics?: readonly Diagnostic[];
|
|
82
121
|
}
|
|
83
122
|
/**
|
|
84
123
|
* Metadata about the source of a semantic node.
|
|
@@ -107,9 +146,27 @@ export interface SourcePosition {
|
|
|
107
146
|
}
|
|
108
147
|
/**
|
|
109
148
|
* A command semantic node - represents a single DSL command.
|
|
149
|
+
*
|
|
150
|
+
* v1.2 adds optional fields for try/catch/finally, async coordination (all/race),
|
|
151
|
+
* and pattern matching (match/arms). These are encoded as fields on command nodes
|
|
152
|
+
* (matching the protocol wire format) rather than new node kinds.
|
|
110
153
|
*/
|
|
111
154
|
export interface CommandSemanticNode extends SemanticNode {
|
|
112
155
|
readonly kind: 'command';
|
|
156
|
+
/** try body — commands to execute in the try block (v1.2). */
|
|
157
|
+
readonly body?: readonly SemanticNode[];
|
|
158
|
+
/** catch branch — commands to execute on error (v1.2). */
|
|
159
|
+
readonly catchBranch?: readonly SemanticNode[];
|
|
160
|
+
/** finally branch — cleanup commands that always execute (v1.2). */
|
|
161
|
+
readonly finallyBranch?: readonly SemanticNode[];
|
|
162
|
+
/** Async coordination variant: all (wait for all) or race (first wins) (v1.2). */
|
|
163
|
+
readonly asyncVariant?: AsyncVariant;
|
|
164
|
+
/** Async body — concurrent commands for all/race (v1.2). */
|
|
165
|
+
readonly asyncBody?: readonly SemanticNode[];
|
|
166
|
+
/** Match arms — pattern/body pairs for match command (v1.2). */
|
|
167
|
+
readonly arms?: readonly MatchArm[];
|
|
168
|
+
/** Default arm — executed when no match arm matches (v1.2). */
|
|
169
|
+
readonly defaultArm?: readonly SemanticNode[];
|
|
113
170
|
}
|
|
114
171
|
/**
|
|
115
172
|
* An event handler semantic node - represents trigger-based commands.
|
|
@@ -143,7 +200,7 @@ export interface ConditionalSemanticNode extends SemanticNode {
|
|
|
143
200
|
export interface CompoundSemanticNode extends SemanticNode {
|
|
144
201
|
readonly kind: 'compound';
|
|
145
202
|
readonly statements: SemanticNode[];
|
|
146
|
-
readonly chainType: 'then' | 'and' | 'async' | 'sequential';
|
|
203
|
+
readonly chainType: 'then' | 'and' | 'async' | 'sequential' | 'pipe';
|
|
147
204
|
}
|
|
148
205
|
/**
|
|
149
206
|
* Loop variant discriminant for different loop types.
|
|
@@ -340,6 +397,10 @@ export declare function createPropertyPath(object: SemanticValue, property: stri
|
|
|
340
397
|
* Create an expression value
|
|
341
398
|
*/
|
|
342
399
|
export declare function createExpression(raw: string): ExpressionValue;
|
|
400
|
+
/**
|
|
401
|
+
* Create a boolean flag value (+flag or ~flag)
|
|
402
|
+
*/
|
|
403
|
+
export declare function createFlag(name: string, enabled?: boolean): FlagValue;
|
|
343
404
|
/**
|
|
344
405
|
* Create a command semantic node
|
|
345
406
|
*/
|
|
@@ -379,4 +440,22 @@ export declare function extractRoleValue(node: SemanticNode, role: string): stri
|
|
|
379
440
|
* Create a loop semantic node
|
|
380
441
|
*/
|
|
381
442
|
export declare function createLoopNode(action: ActionType, roles: Record<SemanticRole, SemanticValue> | Map<SemanticRole, SemanticValue>, loopVariant: LoopVariant, body: SemanticNode[], loopVariable?: string, indexVariable?: string, metadata?: SemanticMetadata): LoopSemanticNode;
|
|
443
|
+
/**
|
|
444
|
+
* Create a try/catch/finally command node (v1.2).
|
|
445
|
+
*/
|
|
446
|
+
export declare function createTryNode(body: SemanticNode[], catchBranch?: SemanticNode[], finallyBranch?: SemanticNode[], metadata?: SemanticMetadata): CommandSemanticNode;
|
|
447
|
+
/**
|
|
448
|
+
* Create an async coordination (all/race) command node (v1.2).
|
|
449
|
+
*/
|
|
450
|
+
export declare function createAsyncNode(variant: AsyncVariant, asyncBody: SemanticNode[], metadata?: SemanticMetadata): CommandSemanticNode;
|
|
451
|
+
/**
|
|
452
|
+
* Create a match command node with pattern arms (v1.2).
|
|
453
|
+
*/
|
|
454
|
+
export declare function createMatchNode(roles: Record<SemanticRole, SemanticValue> | Map<SemanticRole, SemanticValue>, arms: MatchArm[], defaultArm?: SemanticNode[], metadata?: SemanticMetadata): CommandSemanticNode;
|
|
455
|
+
/** Wire format envelope with version metadata (v1.2). */
|
|
456
|
+
export interface LSEEnvelope {
|
|
457
|
+
readonly lseVersion: string;
|
|
458
|
+
readonly features?: readonly string[];
|
|
459
|
+
readonly nodes: readonly SemanticNode[];
|
|
460
|
+
}
|
|
382
461
|
//# sourceMappingURL=types.d.ts.map
|
package/dist/core/types.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/core/types.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAMH;;;;;;;;GAQG;AACH,MAAM,MAAM,UAAU,GAAG,MAAM,CAAC;AAEhC;;;;;;;;;;;;;;;;;GAiBG;AACH,MAAM,MAAM,YAAY,GAAG,MAAM,CAAC;AAMlC;;;GAGG;AACH,MAAM,MAAM,aAAa,GACrB,YAAY,GACZ,aAAa,GACb,cAAc,GACd,iBAAiB,GACjB,eAAe,CAAC;AAEpB;;;GAGG;AACH,MAAM,MAAM,YAAY,GAAG,aAAa,CAAC,MAAM,CAAC,CAAC;AAEjD,MAAM,WAAW,YAAY;IAC3B,QAAQ,CAAC,IAAI,EAAE,SAAS,CAAC;IACzB,QAAQ,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,GAAG,OAAO,CAAC;IAC1C,QAAQ,CAAC,QAAQ,CAAC,EAAE,QAAQ,GAAG,QAAQ,GAAG,SAAS,GAAG,UAAU,CAAC;CAClE;AAED,MAAM,WAAW,aAAa;IAC5B,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W,EACxB,IAAI,EAAE,YAAY,EAAE,EACpB,YAAY,CAAC,EAAE,MAAM,EACrB,aAAa,CAAC,EAAE,MAAM,EACtB,QAAQ,CAAC,EAAE,gBAAgB,GAC1B,gBAAgB,CAelB;AAMD;;GAEG;AACH,wBAAgB,aAAa,CAC3B,IAAI,EAAE,YAAY,EAAE,EACpB,WAAW,CAAC,EAAE,YAAY,EAAE,EAC5B,aAAa,CAAC,EAAE,YAAY,EAAE,EAC9B,QAAQ,CAAC,EAAE,gBAAgB,GAC1B,mBAAmB,CAUrB;AAED;;GAEG;AACH,wBAAgB,eAAe,CAC7B,OAAO,EAAE,YAAY,EACrB,SAAS,EAAE,YAAY,EAAE,EACzB,QAAQ,CAAC,EAAE,gBAAgB,GAC1B,mBAAmB,CASrB;AAED;;GAEG;AACH,wBAAgB,eAAe,CAC7B,KAAK,EAAE,MAAM,CAAC,YAAY,EAAE,aAAa,CAAC,GAAG,GAAG,CAAC,YAAY,EAAE,aAAa,CAAC,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"}
|
package/dist/core/types.js
CHANGED
|
@@ -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
|
};
|
package/dist/core/types.js.map
CHANGED
|
@@ -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;AAAA,EAC7B;AACA,SAAO;AACT;AAKO,SAAS,uBACd,QACA,OACA,MACA,UACA,gBAC0B;AAC1B,QA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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\nimport type { Diagnostic } from '../generation/diagnostics';\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 /** Diagnostics from parsing, validation, and schema checks (v1.2, extended v1.2.1). */\n readonly diagnostics?: readonly Diagnostic[];\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":";AA4dO,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,QAAM,OAAO;AAAA,IACX,MAAM;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ation
|
|
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"}
|