@lokascript/framework 2.3.1 → 2.5.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 (54) hide show
  1. package/dist/api/index.js +29 -516
  2. package/dist/api/index.js.map +1 -1
  3. package/dist/core/index.js +20 -128
  4. package/dist/core/index.js.map +1 -1
  5. package/dist/core/pattern-matching/index.js +19 -12
  6. package/dist/core/pattern-matching/index.js.map +1 -1
  7. package/dist/core/tokenization/index.js.map +1 -1
  8. package/dist/core/types.d.ts +7 -354
  9. package/dist/core/types.d.ts.map +1 -1
  10. package/dist/core/types.js +21 -129
  11. package/dist/core/types.js.map +1 -1
  12. package/dist/generation/diagnostics.d.ts +5 -115
  13. package/dist/generation/diagnostics.d.ts.map +1 -1
  14. package/dist/generation/index.js +20 -77
  15. package/dist/generation/index.js.map +1 -1
  16. package/dist/index.cjs +189 -1458
  17. package/dist/index.cjs.map +1 -1
  18. package/dist/index.js +108 -1347
  19. package/dist/index.js.map +1 -1
  20. package/dist/interfaces/value-extractor.d.ts +20 -0
  21. package/dist/interfaces/value-extractor.d.ts.map +1 -1
  22. package/dist/ir/explicit-parser.d.ts +2 -83
  23. package/dist/ir/explicit-parser.d.ts.map +1 -1
  24. package/dist/ir/explicit-renderer.d.ts +2 -31
  25. package/dist/ir/explicit-renderer.d.ts.map +1 -1
  26. package/dist/ir/index.js +89 -1260
  27. package/dist/ir/index.js.map +1 -1
  28. package/dist/ir/protocol-json.d.ts +2 -70
  29. package/dist/ir/protocol-json.d.ts.map +1 -1
  30. package/dist/ir/references.d.ts +2 -16
  31. package/dist/ir/references.d.ts.map +1 -1
  32. package/dist/ir/types.d.ts +2 -148
  33. package/dist/ir/types.d.ts.map +1 -1
  34. package/dist/parsing/index.js +19 -12
  35. package/dist/parsing/index.js.map +1 -1
  36. package/dist/schema/command-schema.d.ts +3 -92
  37. package/dist/schema/command-schema.d.ts.map +1 -1
  38. package/dist/schema/index.js +3 -20
  39. package/dist/schema/index.js.map +1 -1
  40. package/dist/testing/index.js +1066 -712
  41. package/dist/testing/index.js.map +1 -1
  42. package/package.json +6 -2
  43. package/src/core/types.ts +71 -600
  44. package/src/generation/diagnostics.ts +12 -233
  45. package/src/interfaces/value-extractor.ts +32 -0
  46. package/src/ir/explicit-parser.ts +12 -792
  47. package/src/ir/explicit-renderer.ts +2 -195
  48. package/src/ir/from-interchange.test.ts +91 -4
  49. package/src/ir/from-interchange.ts +59 -0
  50. package/src/ir/protocol-json.test.ts +16 -7
  51. package/src/ir/protocol-json.ts +9 -748
  52. package/src/ir/references.ts +2 -30
  53. package/src/ir/types.ts +18 -190
  54. package/src/schema/command-schema.ts +3 -134
@@ -1,95 +1,6 @@
1
1
  /**
2
- * Command Schema Types
3
- *
4
- * Defines the structure of DSL commands for pattern generation.
5
- * These schemas are language-neutral and describe the semantic structure
6
- * of commands rather than their surface syntax.
2
+ * Command Schema Types — re-exported from @lokascript/intent
7
3
  */
8
- import type { ActionType, SemanticRole, SemanticValue, ExpectedType } from '../core/types';
9
- /**
10
- * Command schema - defines a DSL command's structure.
11
- */
12
- export interface CommandSchema {
13
- /** The action type (command name) */
14
- readonly action: ActionType;
15
- /** Human-readable description */
16
- readonly description: string;
17
- /** Roles this command accepts */
18
- readonly roles: RoleSpec[];
19
- /** The primary role (what the command acts on) */
20
- readonly primaryRole: SemanticRole;
21
- /** Category for grouping (DSL-specific) */
22
- readonly category: string;
23
- /** Whether this command typically has a body (like event handlers, blocks) */
24
- readonly hasBody?: boolean;
25
- /** Notes about special handling or usage */
26
- readonly notes?: string;
27
- }
28
- /**
29
- * Role specification - defines a semantic role in a command.
30
- */
31
- export interface RoleSpec {
32
- /** The semantic role */
33
- readonly role: SemanticRole;
34
- /** Description of what this role represents */
35
- readonly description: string;
36
- /** Whether this role is required */
37
- readonly required: boolean;
38
- /** Expected value types */
39
- readonly expectedTypes: Array<ExpectedType>;
40
- /** Default value if not provided */
41
- readonly default?: SemanticValue;
42
- /** Position hint for SVO languages (higher = earlier) */
43
- readonly svoPosition?: number;
44
- /** Position hint for SOV languages (higher = earlier) */
45
- readonly sovPosition?: number;
46
- /**
47
- * Override the default role marker for this command.
48
- * Maps language code to the marker to use (e.g., { en: 'from', ja: 'から' }).
49
- * If not specified, uses the language profile's default roleMarker.
50
- */
51
- readonly markerOverride?: Record<string, string>;
52
- /**
53
- * Override the rendering marker separately from parsing.
54
- * Used when the parsing grammar differs from rendered output.
55
- * Maps language code to the rendering marker.
56
- */
57
- readonly renderOverride?: Record<string, string>;
58
- /**
59
- * Override the marker position for this role in the generated pattern.
60
- * 'before' = marker precedes the role value (preposition: "set X").
61
- * 'after' = marker follows the role value (postposition: "X から").
62
- * If not set, falls back to the language profile's roleMarkers position,
63
- * then to the word-order default (SOV='after', else='before').
64
- */
65
- readonly markerPosition?: 'before' | 'after';
66
- /**
67
- * When true, this role captures all remaining tokens until the next
68
- * recognized marker keyword or end of input, joining their values
69
- * with spaces into a single ExpressionValue.
70
- *
71
- * Only meaningful for the last role in a sequence or a role followed
72
- * by a marked role. Default: false.
73
- */
74
- readonly greedy?: boolean;
75
- /**
76
- * Restricts which selector subtypes are valid for this role (v1.2).
77
- * Only meaningful when expectedTypes includes 'selector'.
78
- * If omitted, all selector kinds are accepted.
79
- *
80
- * Example: `selectorKinds: ['class', 'attribute']` means only `.class`
81
- * and `[attr]` selectors are valid, not `#id` or `*wildcard`.
82
- */
83
- readonly selectorKinds?: ReadonlyArray<'id' | 'class' | 'attribute' | 'element' | 'complex'>;
84
- }
85
- /**
86
- * Helper to create a command schema with sensible defaults.
87
- * Provides defaults for description, category, and primaryRole.
88
- */
89
- export declare function defineCommand(schema: Partial<CommandSchema> & Pick<CommandSchema, 'action' | 'roles'>): CommandSchema;
90
- /**
91
- * Helper to create a role spec with sensible defaults.
92
- * Provides default for description.
93
- */
94
- export declare function defineRole(role: Partial<RoleSpec> & Pick<RoleSpec, 'role' | 'required' | 'expectedTypes'>): RoleSpec;
4
+ export type { CommandSchema, RoleSpec } from '@lokascript/intent';
5
+ export { defineCommand, defineRole, getRoleSpec } from '@lokascript/intent';
95
6
  //# sourceMappingURL=command-schema.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"command-schema.d.ts","sourceRoot":"","sources":["../../src/schema/command-schema.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,KAAK,EAAE,UAAU,EAAE,YAAY,EAAE,aAAa,EAAE,YAAY,EAAE,MAAM,eAAe,CAAC;AAE3F;;GAEG;AACH,MAAM,WAAW,aAAa;IAC5B,qCAAqC;IACrC,QAAQ,CAAC,MAAM,EAAE,UAAU,CAAC;IAE5B,iCAAiC;IACjC,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAC;IAE7B,iCAAiC;IACjC,QAAQ,CAAC,KAAK,EAAE,QAAQ,EAAE,CAAC;IAE3B,kDAAkD;IAClD,QAAQ,CAAC,WAAW,EAAE,YAAY,CAAC;IAEnC,2CAA2C;IAC3C,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;IAE1B,8EAA8E;IAC9E,QAAQ,CAAC,OAAO,CAAC,EAAE,OAAO,CAAC;IAE3B,4CAA4C;IAC5C,QAAQ,CAAC,KAAK,CAAC,EAAE,MAAM,CAAC;CACzB;AAED;;GAEG;AACH,MAAM,WAAW,QAAQ;IACvB,wBAAwB;IACxB,QAAQ,CAAC,IAAI,EAAE,YAAY,CAAC;IAE5B,+CAA+C;IAC/C,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAC;IAE7B,oCAAoC;IACpC,QAAQ,CAAC,QAAQ,EAAE,OAAO,CAAC;IAE3B,2BAA2B;IAC3B,QAAQ,CAAC,aAAa,EAAE,KAAK,CAAC,YAAY,CAAC,CAAC;IAE5C,oCAAoC;IACpC,QAAQ,CAAC,OAAO,CAAC,EAAE,aAAa,CAAC;IAEjC,yDAAyD;IACzD,QAAQ,CAAC,WAAW,CAAC,EAAE,MAAM,CAAC;IAE9B,yDAAyD;IACzD,QAAQ,CAAC,WAAW,CAAC,EAAE,MAAM,CAAC;IAE9B;;;;OAIG;IACH,QAAQ,CAAC,cAAc,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAEjD;;;;OAIG;IACH,QAAQ,CAAC,cAAc,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAEjD;;;;;;OAMG;IACH,QAAQ,CAAC,cAAc,CAAC,EAAE,QAAQ,GAAG,OAAO,CAAC;IAE7C;;;;;;;OAOG;IACH,QAAQ,CAAC,MAAM,CAAC,EAAE,OAAO,CAAC;IAE1B;;;;;;;OAOG;IACH,QAAQ,CAAC,aAAa,CAAC,EAAE,aAAa,CAAC,IAAI,GAAG,OAAO,GAAG,WAAW,GAAG,SAAS,GAAG,SAAS,CAAC,CAAC;CAC9F;AAED;;;GAGG;AACH,wBAAgB,aAAa,CAC3B,MAAM,EAAE,OAAO,CAAC,aAAa,CAAC,GAAG,IAAI,CAAC,aAAa,EAAE,QAAQ,GAAG,OAAO,CAAC,GACvE,aAAa,CASf;AAED;;;GAGG;AACH,wBAAgB,UAAU,CACxB,IAAI,EAAE,OAAO,CAAC,QAAQ,CAAC,GAAG,IAAI,CAAC,QAAQ,EAAE,MAAM,GAAG,UAAU,GAAG,eAAe,CAAC,GAC9E,QAAQ,CAQV"}
1
+ {"version":3,"file":"command-schema.d.ts","sourceRoot":"","sources":["../../src/schema/command-schema.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,YAAY,EAAE,aAAa,EAAE,QAAQ,EAAE,MAAM,oBAAoB,CAAC;AAClE,OAAO,EAAE,aAAa,EAAE,UAAU,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAC"}
@@ -1,25 +1,8 @@
1
1
  // src/schema/command-schema.ts
2
- function defineCommand(schema) {
3
- return {
4
- description: schema.description || `${schema.action} command`,
5
- category: schema.category || "general",
6
- primaryRole: schema.primaryRole || schema.roles[0]?.role || "patient",
7
- ...schema,
8
- action: schema.action,
9
- roles: schema.roles
10
- };
11
- }
12
- function defineRole(role) {
13
- return {
14
- description: role.description || `${role.role} role`,
15
- ...role,
16
- role: role.role,
17
- required: role.required,
18
- expectedTypes: role.expectedTypes
19
- };
20
- }
2
+ import { defineCommand, defineRole, getRoleSpec } from "@lokascript/intent";
21
3
  export {
22
4
  defineCommand,
23
- defineRole
5
+ defineRole,
6
+ getRoleSpec
24
7
  };
25
8
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/schema/command-schema.ts"],"sourcesContent":["/**\n * Command Schema Types\n *\n * Defines the structure of DSL commands for pattern generation.\n * These schemas are language-neutral and describe the semantic structure\n * of commands rather than their surface syntax.\n */\n\nimport type { ActionType, SemanticRole, SemanticValue, ExpectedType } from '../core/types';\n\n/**\n * Command schema - defines a DSL command's structure.\n */\nexport interface CommandSchema {\n /** The action type (command name) */\n readonly action: ActionType;\n\n /** Human-readable description */\n readonly description: string;\n\n /** Roles this command accepts */\n readonly roles: RoleSpec[];\n\n /** The primary role (what the command acts on) */\n readonly primaryRole: SemanticRole;\n\n /** Category for grouping (DSL-specific) */\n readonly category: string;\n\n /** Whether this command typically has a body (like event handlers, blocks) */\n readonly hasBody?: boolean;\n\n /** Notes about special handling or usage */\n readonly notes?: string;\n}\n\n/**\n * Role specification - defines a semantic role in a command.\n */\nexport interface RoleSpec {\n /** The semantic role */\n readonly role: SemanticRole;\n\n /** Description of what this role represents */\n readonly description: string;\n\n /** Whether this role is required */\n readonly required: boolean;\n\n /** Expected value types */\n readonly expectedTypes: Array<ExpectedType>;\n\n /** Default value if not provided */\n readonly default?: SemanticValue;\n\n /** Position hint for SVO languages (higher = earlier) */\n readonly svoPosition?: number;\n\n /** Position hint for SOV languages (higher = earlier) */\n readonly sovPosition?: number;\n\n /**\n * Override the default role marker for this command.\n * Maps language code to the marker to use (e.g., { en: 'from', ja: 'から' }).\n * If not specified, uses the language profile's default roleMarker.\n */\n readonly markerOverride?: Record<string, string>;\n\n /**\n * Override the rendering marker separately from parsing.\n * Used when the parsing grammar differs from rendered output.\n * Maps language code to the rendering marker.\n */\n readonly renderOverride?: Record<string, string>;\n\n /**\n * Override the marker position for this role in the generated pattern.\n * 'before' = marker precedes the role value (preposition: \"set X\").\n * 'after' = marker follows the role value (postposition: \"X から\").\n * If not set, falls back to the language profile's roleMarkers position,\n * then to the word-order default (SOV='after', else='before').\n */\n readonly markerPosition?: 'before' | 'after';\n\n /**\n * When true, this role captures all remaining tokens until the next\n * recognized marker keyword or end of input, joining their values\n * with spaces into a single ExpressionValue.\n *\n * Only meaningful for the last role in a sequence or a role followed\n * by a marked role. Default: false.\n */\n readonly greedy?: boolean;\n\n /**\n * Restricts which selector subtypes are valid for this role (v1.2).\n * Only meaningful when expectedTypes includes 'selector'.\n * If omitted, all selector kinds are accepted.\n *\n * Example: `selectorKinds: ['class', 'attribute']` means only `.class`\n * and `[attr]` selectors are valid, not `#id` or `*wildcard`.\n */\n readonly selectorKinds?: ReadonlyArray<'id' | 'class' | 'attribute' | 'element' | 'complex'>;\n}\n\n/**\n * Helper to create a command schema with sensible defaults.\n * Provides defaults for description, category, and primaryRole.\n */\nexport function defineCommand(\n schema: Partial<CommandSchema> & Pick<CommandSchema, 'action' | 'roles'>\n): CommandSchema {\n return {\n description: schema.description || `${schema.action} command`,\n category: schema.category || 'general',\n primaryRole: schema.primaryRole || schema.roles[0]?.role || 'patient',\n ...schema,\n action: schema.action,\n roles: schema.roles,\n } as CommandSchema;\n}\n\n/**\n * Helper to create a role spec with sensible defaults.\n * Provides default for description.\n */\nexport function defineRole(\n role: Partial<RoleSpec> & Pick<RoleSpec, 'role' | 'required' | 'expectedTypes'>\n): RoleSpec {\n return {\n description: role.description || `${role.role} role`,\n ...role,\n role: role.role,\n required: role.required,\n expectedTypes: role.expectedTypes,\n };\n}\n"],"mappings":";AA6GO,SAAS,cACd,QACe;AACf,SAAO;AAAA,IACL,aAAa,OAAO,eAAe,GAAG,OAAO,MAAM;AAAA,IACnD,UAAU,OAAO,YAAY;AAAA,IAC7B,aAAa,OAAO,eAAe,OAAO,MAAM,CAAC,GAAG,QAAQ;AAAA,IAC5D,GAAG;AAAA,IACH,QAAQ,OAAO;AAAA,IACf,OAAO,OAAO;AAAA,EAChB;AACF;AAMO,SAAS,WACd,MACU;AACV,SAAO;AAAA,IACL,aAAa,KAAK,eAAe,GAAG,KAAK,IAAI;AAAA,IAC7C,GAAG;AAAA,IACH,MAAM,KAAK;AAAA,IACX,UAAU,KAAK;AAAA,IACf,eAAe,KAAK;AAAA,EACtB;AACF;","names":[]}
1
+ {"version":3,"sources":["../../src/schema/command-schema.ts"],"sourcesContent":["/**\n * Command Schema Types — re-exported from @lokascript/intent\n */\n\nexport type { CommandSchema, RoleSpec } from '@lokascript/intent';\nexport { defineCommand, defineRole, getRoleSpec } from '@lokascript/intent';\n"],"mappings":";AAKA,SAAS,eAAe,YAAY,mBAAmB;","names":[]}