@mcp-graph-workflow/mcp-graph 5.16.0 → 5.17.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 (173) hide show
  1. package/dist/api/router.d.ts.map +1 -1
  2. package/dist/api/router.js +2 -0
  3. package/dist/api/router.js.map +1 -1
  4. package/dist/api/routes/translation.d.ts +7 -0
  5. package/dist/api/routes/translation.d.ts.map +1 -0
  6. package/dist/api/routes/translation.js +170 -0
  7. package/dist/api/routes/translation.js.map +1 -0
  8. package/dist/core/config/ai-memory-generator.js +3 -3
  9. package/dist/core/context/compact-context.d.ts.map +1 -1
  10. package/dist/core/context/compact-context.js +7 -9
  11. package/dist/core/context/compact-context.js.map +1 -1
  12. package/dist/core/events/event-types.d.ts +32 -1
  13. package/dist/core/events/event-types.d.ts.map +1 -1
  14. package/dist/core/lsp/lsp-bridge.d.ts +12 -2
  15. package/dist/core/lsp/lsp-bridge.d.ts.map +1 -1
  16. package/dist/core/lsp/lsp-bridge.js +139 -3
  17. package/dist/core/lsp/lsp-bridge.js.map +1 -1
  18. package/dist/core/lsp/lsp-edit-applier.d.ts +23 -0
  19. package/dist/core/lsp/lsp-edit-applier.d.ts.map +1 -0
  20. package/dist/core/lsp/lsp-edit-applier.js +204 -0
  21. package/dist/core/lsp/lsp-edit-applier.js.map +1 -0
  22. package/dist/core/lsp/lsp-server-manager.d.ts.map +1 -1
  23. package/dist/core/lsp/lsp-server-manager.js +18 -0
  24. package/dist/core/lsp/lsp-server-manager.js.map +1 -1
  25. package/dist/core/lsp/lsp-types.d.ts +35 -0
  26. package/dist/core/lsp/lsp-types.d.ts.map +1 -1
  27. package/dist/core/lsp/lsp-types.js +20 -0
  28. package/dist/core/lsp/lsp-types.js.map +1 -1
  29. package/dist/core/planner/lifecycle-phase.d.ts +18 -0
  30. package/dist/core/planner/lifecycle-phase.d.ts.map +1 -1
  31. package/dist/core/planner/lifecycle-phase.js +112 -0
  32. package/dist/core/planner/lifecycle-phase.js.map +1 -1
  33. package/dist/core/rag/query-cache.js +2 -2
  34. package/dist/core/rag/query-cache.js.map +1 -1
  35. package/dist/core/rag/response-cache.d.ts +38 -0
  36. package/dist/core/rag/response-cache.d.ts.map +1 -0
  37. package/dist/core/rag/response-cache.js +84 -0
  38. package/dist/core/rag/response-cache.js.map +1 -0
  39. package/dist/core/siebel/wsdl-correlation.d.ts.map +1 -1
  40. package/dist/core/siebel/wsdl-correlation.js +2 -13
  41. package/dist/core/siebel/wsdl-correlation.js.map +1 -1
  42. package/dist/core/store/migrations.d.ts.map +1 -1
  43. package/dist/core/store/migrations.js +97 -0
  44. package/dist/core/store/migrations.js.map +1 -1
  45. package/dist/core/store/tool-call-log.d.ts +26 -0
  46. package/dist/core/store/tool-call-log.d.ts.map +1 -0
  47. package/dist/core/store/tool-call-log.js +66 -0
  48. package/dist/core/store/tool-call-log.js.map +1 -0
  49. package/dist/core/translation/confidence/ambiguity-detector.d.ts +18 -0
  50. package/dist/core/translation/confidence/ambiguity-detector.d.ts.map +1 -0
  51. package/dist/core/translation/confidence/ambiguity-detector.js +80 -0
  52. package/dist/core/translation/confidence/ambiguity-detector.js.map +1 -0
  53. package/dist/core/translation/confidence/equivalence-scorer.d.ts +22 -0
  54. package/dist/core/translation/confidence/equivalence-scorer.d.ts.map +1 -0
  55. package/dist/core/translation/confidence/equivalence-scorer.js +72 -0
  56. package/dist/core/translation/confidence/equivalence-scorer.js.map +1 -0
  57. package/dist/core/translation/generators/generator-adapter.d.ts +22 -0
  58. package/dist/core/translation/generators/generator-adapter.d.ts.map +1 -0
  59. package/dist/core/translation/generators/generator-adapter.js +6 -0
  60. package/dist/core/translation/generators/generator-adapter.js.map +1 -0
  61. package/dist/core/translation/generators/python-generator.d.ts +15 -0
  62. package/dist/core/translation/generators/python-generator.d.ts.map +1 -0
  63. package/dist/core/translation/generators/python-generator.js +74 -0
  64. package/dist/core/translation/generators/python-generator.js.map +1 -0
  65. package/dist/core/translation/generators/ts-generator.d.ts +14 -0
  66. package/dist/core/translation/generators/ts-generator.d.ts.map +1 -0
  67. package/dist/core/translation/generators/ts-generator.js +56 -0
  68. package/dist/core/translation/generators/ts-generator.js.map +1 -0
  69. package/dist/core/translation/language-detect.d.ts +12 -0
  70. package/dist/core/translation/language-detect.d.ts.map +1 -0
  71. package/dist/core/translation/language-detect.js +140 -0
  72. package/dist/core/translation/language-detect.js.map +1 -0
  73. package/dist/core/translation/parsers/parser-adapter.d.ts +23 -0
  74. package/dist/core/translation/parsers/parser-adapter.d.ts.map +1 -0
  75. package/dist/core/translation/parsers/parser-adapter.js +6 -0
  76. package/dist/core/translation/parsers/parser-adapter.js.map +1 -0
  77. package/dist/core/translation/parsers/python-parser-adapter.d.ts +10 -0
  78. package/dist/core/translation/parsers/python-parser-adapter.d.ts.map +1 -0
  79. package/dist/core/translation/parsers/python-parser-adapter.js +85 -0
  80. package/dist/core/translation/parsers/python-parser-adapter.js.map +1 -0
  81. package/dist/core/translation/parsers/ts-parser-adapter.d.ts +10 -0
  82. package/dist/core/translation/parsers/ts-parser-adapter.d.ts.map +1 -0
  83. package/dist/core/translation/parsers/ts-parser-adapter.js +145 -0
  84. package/dist/core/translation/parsers/ts-parser-adapter.js.map +1 -0
  85. package/dist/core/translation/prompt-builder.d.ts +34 -0
  86. package/dist/core/translation/prompt-builder.d.ts.map +1 -0
  87. package/dist/core/translation/prompt-builder.js +137 -0
  88. package/dist/core/translation/prompt-builder.js.map +1 -0
  89. package/dist/core/translation/translation-orchestrator.d.ts +67 -0
  90. package/dist/core/translation/translation-orchestrator.d.ts.map +1 -0
  91. package/dist/core/translation/translation-orchestrator.js +204 -0
  92. package/dist/core/translation/translation-orchestrator.js.map +1 -0
  93. package/dist/core/translation/translation-store.d.ts +35 -0
  94. package/dist/core/translation/translation-store.d.ts.map +1 -0
  95. package/dist/core/translation/translation-store.js +96 -0
  96. package/dist/core/translation/translation-store.js.map +1 -0
  97. package/dist/core/translation/translation-types.d.ts +156 -0
  98. package/dist/core/translation/translation-types.d.ts.map +1 -0
  99. package/dist/core/translation/translation-types.js +86 -0
  100. package/dist/core/translation/translation-types.js.map +1 -0
  101. package/dist/core/translation/ucr/construct-registry.d.ts +36 -0
  102. package/dist/core/translation/ucr/construct-registry.d.ts.map +1 -0
  103. package/dist/core/translation/ucr/construct-registry.js +159 -0
  104. package/dist/core/translation/ucr/construct-registry.js.map +1 -0
  105. package/dist/core/translation/ucr/construct-seed.d.ts +12 -0
  106. package/dist/core/translation/ucr/construct-seed.d.ts.map +1 -0
  107. package/dist/core/translation/ucr/construct-seed.js +35 -0
  108. package/dist/core/translation/ucr/construct-seed.js.map +1 -0
  109. package/dist/core/translation/ucr/construct-types.d.ts +174 -0
  110. package/dist/core/translation/ucr/construct-types.d.ts.map +1 -0
  111. package/dist/core/translation/ucr/construct-types.js +88 -0
  112. package/dist/core/translation/ucr/construct-types.js.map +1 -0
  113. package/dist/core/utils/ac-helpers.d.ts +6 -0
  114. package/dist/core/utils/ac-helpers.d.ts.map +1 -1
  115. package/dist/core/utils/ac-helpers.js +15 -0
  116. package/dist/core/utils/ac-helpers.js.map +1 -1
  117. package/dist/core/utils/constants.d.ts +19 -0
  118. package/dist/core/utils/constants.d.ts.map +1 -1
  119. package/dist/core/utils/constants.js +23 -0
  120. package/dist/core/utils/constants.js.map +1 -1
  121. package/dist/core/utils/errors.d.ts +12 -0
  122. package/dist/core/utils/errors.d.ts.map +1 -1
  123. package/dist/core/utils/errors.js +25 -0
  124. package/dist/core/utils/errors.js.map +1 -1
  125. package/dist/core/utils/similarity.d.ts +9 -0
  126. package/dist/core/utils/similarity.d.ts.map +1 -0
  127. package/dist/core/utils/similarity.js +20 -0
  128. package/dist/core/utils/similarity.js.map +1 -0
  129. package/dist/mcp/code-intelligence-wrapper.d.ts +79 -0
  130. package/dist/mcp/code-intelligence-wrapper.d.ts.map +1 -0
  131. package/dist/mcp/code-intelligence-wrapper.js +286 -0
  132. package/dist/mcp/code-intelligence-wrapper.js.map +1 -0
  133. package/dist/mcp/lifecycle-wrapper.d.ts.map +1 -1
  134. package/dist/mcp/lifecycle-wrapper.js +56 -1
  135. package/dist/mcp/lifecycle-wrapper.js.map +1 -1
  136. package/dist/mcp/tools/code-intelligence.d.ts +2 -0
  137. package/dist/mcp/tools/code-intelligence.d.ts.map +1 -1
  138. package/dist/mcp/tools/code-intelligence.js +157 -3
  139. package/dist/mcp/tools/code-intelligence.js.map +1 -1
  140. package/dist/mcp/tools/index.d.ts.map +1 -1
  141. package/dist/mcp/tools/index.js +3 -0
  142. package/dist/mcp/tools/index.js.map +1 -1
  143. package/dist/mcp/tools/rag-context.d.ts +1 -1
  144. package/dist/mcp/tools/rag-context.d.ts.map +1 -1
  145. package/dist/mcp/tools/rag-context.js +21 -2
  146. package/dist/mcp/tools/rag-context.js.map +1 -1
  147. package/dist/mcp/tools/set-phase.d.ts.map +1 -1
  148. package/dist/mcp/tools/set-phase.js +24 -4
  149. package/dist/mcp/tools/set-phase.js.map +1 -1
  150. package/dist/schemas/designer-schema.d.ts +4 -4
  151. package/dist/schemas/siebel.schema.d.ts +13 -13
  152. package/dist/web/dashboard/dist/assets/{benchmark-tab-LbjYcnjd.js → benchmark-tab-CjkvhBH9.js} +1 -1
  153. package/dist/web/dashboard/dist/assets/{context-tab-u_l0XUXT.js → context-tab-CDCm-rDm.js} +1 -1
  154. package/dist/web/dashboard/dist/assets/{gitnexus-tab-K304jKR3.js → gitnexus-tab-C8ya-m0E.js} +1 -1
  155. package/dist/web/dashboard/dist/assets/{graph-section-3_2LPo7V.js → graph-section-CUyy5O7e.js} +1 -1
  156. package/dist/web/dashboard/dist/assets/{graph-tab-KG6GQq1a.js → graph-tab-0C2cf7FY.js} +1 -1
  157. package/dist/web/dashboard/dist/assets/{graph-utils-cpyaBhnE.js → graph-utils-DThe_TpW.js} +1 -1
  158. package/dist/web/dashboard/dist/assets/{index-DY9euqve.js → index-CG74l_GF.js} +1 -1
  159. package/dist/web/dashboard/dist/assets/{index-C1UckjqB.css → index-DA2Y0E4s.css} +1 -1
  160. package/dist/web/dashboard/dist/assets/{index-Clwhz2ad.js → index-D_2dsvO7.js} +1 -1
  161. package/dist/web/dashboard/dist/assets/{index-Co7yktBf.js → index-gkGjyOqz.js} +47 -42
  162. package/dist/web/dashboard/dist/assets/{insights-tab-yrnRR8CL.js → insights-tab-C7zJ-naw.js} +1 -1
  163. package/dist/web/dashboard/dist/assets/{journey-tab-Cfh-qkYk.js → journey-tab-CL_lunyr.js} +1 -1
  164. package/dist/web/dashboard/dist/assets/languages-tab-BDD3QwUT.js +1 -0
  165. package/dist/web/dashboard/dist/assets/{logs-tab-B-8O6WzQ.js → logs-tab-B7w7XA3o.js} +1 -1
  166. package/dist/web/dashboard/dist/assets/{lsp-tab-CBM8pixC.js → lsp-tab-BTbRAwqG.js} +1 -1
  167. package/dist/web/dashboard/dist/assets/{memories-tab-5t0pfAsS.js → memories-tab-CbRr4xFM.js} +1 -1
  168. package/dist/web/dashboard/dist/assets/{prd-backlog-tab-Bgt2qin9.js → prd-backlog-tab-w32D0W8F.js} +1 -1
  169. package/dist/web/dashboard/dist/assets/{siebel-tab-CjYyszVw.js → siebel-tab-BKuaD7Pf.js} +3 -3
  170. package/dist/web/dashboard/dist/assets/{skills-tab-D-6Tem1J.js → skills-tab-VQC98jyT.js} +1 -1
  171. package/dist/web/dashboard/dist/assets/{style-Ci_RUKMJ.js → style-DkI8Vt9Y.js} +1 -1
  172. package/dist/web/dashboard/dist/index.html +2 -2
  173. package/package.json +2 -2
@@ -0,0 +1,26 @@
1
+ /**
2
+ * Tool Call Log — tracks MCP tool calls per node for prerequisite enforcement.
3
+ * Follows ToolTokenStore pattern: receives Database.Database in constructor.
4
+ */
5
+ import type Database from "better-sqlite3";
6
+ export interface ToolCallEntry {
7
+ id: number;
8
+ projectId: string;
9
+ nodeId: string | null;
10
+ toolName: string;
11
+ toolArgs: string | null;
12
+ calledAt: string;
13
+ }
14
+ export declare class ToolCallLog {
15
+ private db;
16
+ constructor(db: Database.Database);
17
+ /** Record a successful tool call. */
18
+ record(projectId: string, nodeId: string | null, toolName: string, toolArgs?: string): void;
19
+ /** Check if a tool was called for a node (or project-wide when nodeId is null). */
20
+ hasBeenCalled(projectId: string, nodeId: string | null, toolName: string, toolArgs?: string): boolean;
21
+ /** Get all tool calls for a specific node. */
22
+ getCallsForNode(projectId: string, nodeId: string): ToolCallEntry[];
23
+ /** Clear all logs for a project. */
24
+ clearProject(projectId: string): void;
25
+ }
26
+ //# sourceMappingURL=tool-call-log.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"tool-call-log.d.ts","sourceRoot":"","sources":["../../../src/core/store/tool-call-log.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,QAAQ,MAAM,gBAAgB,CAAC;AAI3C,MAAM,WAAW,aAAa;IAC5B,EAAE,EAAE,MAAM,CAAC;IACX,SAAS,EAAE,MAAM,CAAC;IAClB,MAAM,EAAE,MAAM,GAAG,IAAI,CAAC;IACtB,QAAQ,EAAE,MAAM,CAAC;IACjB,QAAQ,EAAE,MAAM,GAAG,IAAI,CAAC;IACxB,QAAQ,EAAE,MAAM,CAAC;CAClB;AAsBD,qBAAa,WAAW;IACtB,OAAO,CAAC,EAAE,CAAoB;gBAElB,EAAE,EAAE,QAAQ,CAAC,QAAQ;IAIjC,qCAAqC;IACrC,MAAM,CAAC,SAAS,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,IAAI,EAAE,QAAQ,EAAE,MAAM,EAAE,QAAQ,CAAC,EAAE,MAAM,GAAG,IAAI;IAQ3F,mFAAmF;IACnF,aAAa,CAAC,SAAS,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,IAAI,EAAE,QAAQ,EAAE,MAAM,EAAE,QAAQ,CAAC,EAAE,MAAM,GAAG,OAAO;IAmCrG,8CAA8C;IAC9C,eAAe,CAAC,SAAS,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,aAAa,EAAE;IASnE,oCAAoC;IACpC,YAAY,CAAC,SAAS,EAAE,MAAM,GAAG,IAAI;CAItC"}
@@ -0,0 +1,66 @@
1
+ /**
2
+ * Tool Call Log — tracks MCP tool calls per node for prerequisite enforcement.
3
+ * Follows ToolTokenStore pattern: receives Database.Database in constructor.
4
+ */
5
+ import { now } from "../utils/time.js";
6
+ import { logger } from "../utils/logger.js";
7
+ function rowToEntry(row) {
8
+ return {
9
+ id: row.id,
10
+ projectId: row.project_id,
11
+ nodeId: row.node_id,
12
+ toolName: row.tool_name,
13
+ toolArgs: row.tool_args,
14
+ calledAt: row.called_at,
15
+ };
16
+ }
17
+ export class ToolCallLog {
18
+ db;
19
+ constructor(db) {
20
+ this.db = db;
21
+ }
22
+ /** Record a successful tool call. */
23
+ record(projectId, nodeId, toolName, toolArgs) {
24
+ this.db.prepare(`INSERT INTO tool_call_log (project_id, node_id, tool_name, tool_args, called_at)
25
+ VALUES (?, ?, ?, ?, ?)`).run(projectId, nodeId, toolName, toolArgs ?? null, now());
26
+ logger.debug("tool-call-log: recorded", { toolName, nodeId });
27
+ }
28
+ /** Check if a tool was called for a node (or project-wide when nodeId is null). */
29
+ hasBeenCalled(projectId, nodeId, toolName, toolArgs) {
30
+ if (nodeId === null) {
31
+ if (toolArgs) {
32
+ const row = this.db.prepare(`SELECT 1 FROM tool_call_log
33
+ WHERE project_id = ? AND node_id IS NULL AND tool_name = ? AND tool_args LIKE ?
34
+ LIMIT 1`).get(projectId, toolName, `%${toolArgs}%`);
35
+ return row !== undefined;
36
+ }
37
+ const row = this.db.prepare(`SELECT 1 FROM tool_call_log
38
+ WHERE project_id = ? AND node_id IS NULL AND tool_name = ?
39
+ LIMIT 1`).get(projectId, toolName);
40
+ return row !== undefined;
41
+ }
42
+ if (toolArgs) {
43
+ const row = this.db.prepare(`SELECT 1 FROM tool_call_log
44
+ WHERE project_id = ? AND node_id = ? AND tool_name = ? AND tool_args LIKE ?
45
+ LIMIT 1`).get(projectId, nodeId, toolName, `%${toolArgs}%`);
46
+ return row !== undefined;
47
+ }
48
+ const row = this.db.prepare(`SELECT 1 FROM tool_call_log
49
+ WHERE project_id = ? AND node_id = ? AND tool_name = ?
50
+ LIMIT 1`).get(projectId, nodeId, toolName);
51
+ return row !== undefined;
52
+ }
53
+ /** Get all tool calls for a specific node. */
54
+ getCallsForNode(projectId, nodeId) {
55
+ const rows = this.db.prepare(`SELECT * FROM tool_call_log
56
+ WHERE project_id = ? AND node_id = ?
57
+ ORDER BY called_at ASC`).all(projectId, nodeId);
58
+ return rows.map(rowToEntry);
59
+ }
60
+ /** Clear all logs for a project. */
61
+ clearProject(projectId) {
62
+ this.db.prepare("DELETE FROM tool_call_log WHERE project_id = ?").run(projectId);
63
+ logger.debug("tool-call-log: cleared project", { projectId });
64
+ }
65
+ }
66
+ //# sourceMappingURL=tool-call-log.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"tool-call-log.js","sourceRoot":"","sources":["../../../src/core/store/tool-call-log.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,EAAE,GAAG,EAAE,MAAM,kBAAkB,CAAC;AACvC,OAAO,EAAE,MAAM,EAAE,MAAM,oBAAoB,CAAC;AAoB5C,SAAS,UAAU,CAAC,GAAgB;IAClC,OAAO;QACL,EAAE,EAAE,GAAG,CAAC,EAAE;QACV,SAAS,EAAE,GAAG,CAAC,UAAU;QACzB,MAAM,EAAE,GAAG,CAAC,OAAO;QACnB,QAAQ,EAAE,GAAG,CAAC,SAAS;QACvB,QAAQ,EAAE,GAAG,CAAC,SAAS;QACvB,QAAQ,EAAE,GAAG,CAAC,SAAS;KACxB,CAAC;AACJ,CAAC;AAED,MAAM,OAAO,WAAW;IACd,EAAE,CAAoB;IAE9B,YAAY,EAAqB;QAC/B,IAAI,CAAC,EAAE,GAAG,EAAE,CAAC;IACf,CAAC;IAED,qCAAqC;IACrC,MAAM,CAAC,SAAiB,EAAE,MAAqB,EAAE,QAAgB,EAAE,QAAiB;QAClF,IAAI,CAA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c;QAC/C,MAAM,IAAI,GAAG,IAAI,CAAC,EAAE,CAAC,OAAO,CAC1B;;8BAEwB,CACzB,CAAC,GAAG,CAAC,SAAS,EAAE,MAAM,CAAkB,CAAC;QAC1C,OAAO,IAAI,CAAC,GAAG,CAAC,UAAU,CAAC,CAAC;IAC9B,CAAC;IAED,oCAAoC;IACpC,YAAY,CAAC,SAAiB;QAC5B,IAAI,CAAC,EAAE,CAAC,OAAO,CAAC,gDAAgD,CAAC,CAAC,GAAG,CAAC,SAAS,CAAC,CAAC;QACjF,MAAM,CAAC,KAAK,CAAC,gCAAgC,EAAE,EAAE,SAAS,EAAE,CAAC,CAAC;IAChE,CAAC;CACF"}
@@ -0,0 +1,18 @@
1
+ /**
2
+ * Ambiguity Detector — identifies constructs that need AI assistance.
3
+ *
4
+ * Takes scored constructs and classifies ambiguity:
5
+ * - multiple_targets: construct has >1 viable target mapping
6
+ * - no_target: construct has no valid target mapping
7
+ * - lossy_translation: single target but low confidence (information loss likely)
8
+ *
9
+ * Feeds the prompt-builder with precise context for AI-assisted translation.
10
+ */
11
+ import { ConstructRegistry } from "../ucr/construct-registry.js";
12
+ import type { TranslationScore, AmbiguityReport } from "../ucr/construct-types.js";
13
+ /**
14
+ * Detect ambiguities in scored constructs.
15
+ * Returns reports only for constructs that have translation issues.
16
+ */
17
+ export declare function detectAmbiguities(scores: TranslationScore[], registry: ConstructRegistry, sourceLang: string, targetLang: string): AmbiguityReport[];
18
+ //# sourceMappingURL=ambiguity-detector.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ambiguity-detector.d.ts","sourceRoot":"","sources":["../../../../src/core/translation/confidence/ambiguity-detector.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,OAAO,EAAE,iBAAiB,EAAE,MAAM,8BAA8B,CAAC;AACjE,OAAO,KAAK,EAAE,gBAAgB,EAAE,eAAe,EAAE,MAAM,2BAA2B,CAAC;AAQnF;;;GAGG;AACH,wBAAgB,iBAAiB,CAC/B,MAAM,EAAE,gBAAgB,EAAE,EAC1B,QAAQ,EAAE,iBAAiB,EAC3B,UAAU,EAAE,MAAM,EAClB,UAAU,EAAE,MAAM,GACjB,eAAe,EAAE,CASnB"}
@@ -0,0 +1,80 @@
1
+ /**
2
+ * Ambiguity Detector — identifies constructs that need AI assistance.
3
+ *
4
+ * Takes scored constructs and classifies ambiguity:
5
+ * - multiple_targets: construct has >1 viable target mapping
6
+ * - no_target: construct has no valid target mapping
7
+ * - lossy_translation: single target but low confidence (information loss likely)
8
+ *
9
+ * Feeds the prompt-builder with precise context for AI-assisted translation.
10
+ */
11
+ const LOSSY_THRESHOLD = 0.65;
12
+ /**
13
+ * Detect ambiguities in scored constructs.
14
+ * Returns reports only for constructs that have translation issues.
15
+ */
16
+ export function detectAmbiguities(scores, registry, sourceLang, targetLang) {
17
+ const reports = [];
18
+ for (const score of scores) {
19
+ const report = analyzeScore(score, registry, sourceLang, targetLang);
20
+ if (report)
21
+ reports.push(report);
22
+ }
23
+ return reports;
24
+ }
25
+ function analyzeScore(score, registry, _sourceLang, targetLang) {
26
+ // no_target: no valid mapping selected
27
+ if (!score.selectedMappingId) {
28
+ return buildReport(score, registry, "no_target", []);
29
+ }
30
+ // Get all target mappings to check for multiple options
31
+ const allMappings = registry.getMappings(score.constructId, targetLang);
32
+ // multiple_targets: more than one viable target mapping
33
+ if (allMappings.length > 1) {
34
+ const candidates = allMappings.map((m) => ({
35
+ mappingId: m.id,
36
+ confidence: m.confidence,
37
+ tradeoff: m.syntaxPattern
38
+ ? `Pattern: ${m.syntaxPattern.split("\n")[0]}`
39
+ : `Confidence: ${m.confidence}`,
40
+ }));
41
+ return buildReport(score, registry, "multiple_targets", candidates);
42
+ }
43
+ // lossy_translation: single target but low confidence
44
+ if (score.finalConfidence < LOSSY_THRESHOLD) {
45
+ const candidates = allMappings.map((m) => ({
46
+ mappingId: m.id,
47
+ confidence: m.confidence,
48
+ tradeoff: `Low confidence (${m.confidence}) — potential information loss`,
49
+ }));
50
+ return buildReport(score, registry, "lossy_translation", candidates);
51
+ }
52
+ // No ambiguity — exact or high-confidence single mapping
53
+ return null;
54
+ }
55
+ function buildReport(score, registry, ambiguityType, candidates) {
56
+ const construct = registry.getConstructById(score.constructId);
57
+ const canonicalName = construct?.canonicalName ?? score.constructId;
58
+ return {
59
+ constructId: score.constructId,
60
+ canonicalName,
61
+ ambiguityType,
62
+ candidates,
63
+ recommendation: generateRecommendation(ambiguityType, candidates),
64
+ };
65
+ }
66
+ function generateRecommendation(ambiguityType, candidates) {
67
+ switch (ambiguityType) {
68
+ case "multiple_targets": {
69
+ const best = candidates.reduce((a, b) => (a.confidence >= b.confidence ? a : b), candidates[0]);
70
+ return best
71
+ ? `Prefer mapping ${best.mappingId} (confidence: ${best.confidence}). Review alternatives.`
72
+ : "Multiple options available — AI should evaluate context.";
73
+ }
74
+ case "no_target":
75
+ return "No equivalent construct in target language. AI must synthesize a workaround.";
76
+ case "lossy_translation":
77
+ return "Translation possible but lossy. AI should validate semantic preservation.";
78
+ }
79
+ }
80
+ //# sourceMappingURL=ambiguity-detector.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ambiguity-detector.js","sourceRoot":"","sources":["../../../../src/core/translation/confidence/ambiguity-detector.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AASH,MAAM,eAAe,GAAG,IAAI,CAAC;AAE7B;;;GAGG;AACH,MAAM,UAAU,iBAAiB,CAC/B,MAA0B,EAC1B,QAA2B,EAC3B,UAAkB,EAClB,UAAkB;IAElB,MAAM,OAAO,GAAsB,EAAE,CAAC;IAEtC,KAAK,MAAM,KAAK,IAAI,MAAM,EAAE,CAAC;QAC3B,MAAM,MAAM,GAAG,YAAY,CAAC,KAAK,EAAE,QAAQ,EAAE,UAAU,EAAE,UAAU,CAAC,CAAC;QACrE,IAAI,MAAM;YAAE,OAAO,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;IACnC,CAAC;IAED,OAAO,OAAO,CAAC;AACjB,CA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,EAAE,UAAU,CAAC,CAAC;IACvE,CAAC;IAED,yDAAyD;IACzD,OAAO,IAAI,CAAC;AACd,CAAC;AAED,SAAS,WAAW,CAClB,KAAuB,EACvB,QAA2B,EAC3B,aAAqE,EACrE,UAAgC;IAEhC,MAAM,SAAS,GAAG,QAAQ,CAAC,gBAAgB,CAAC,KAAK,CAAC,WAAW,CAAC,CAAC;IAC/D,MAAM,aAAa,GAAG,SAAS,EAAE,aAAa,IAAI,KAAK,CAAC,WAAW,CAAC;IAEpE,OAAO;QACL,WAAW,EAAE,KAAK,CAAC,WAAW;QAC9B,aAAa;QACb,aAAa;QACb,UAAU;QACV,cAAc,EAAE,sBAAsB,CAAC,aAAa,EAAE,UAAU,CAAC;KAClE,CAAC;AACJ,CAAC;AAED,SAAS,sBAAsB,CAC7B,aAAqE,EACrE,UAAgC;IAEhC,QAAQ,aAAa,EAAE,CAAC;QACtB,KAAK,kBAAkB,CAAC,CAAC,CAAC;YACxB,MAAM,IAAI,GAAG,UAAU,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,CAAC,UAAU,IAAI,CAAC,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,UAAU,CAAC,CAAC,CAAC,CAAC,CAAC;YAChG,OAAO,IAAI;gBACT,CAAC,CAAC,kBAAkB,IAAI,CAAC,SAAS,iBAAiB,IAAI,CAAC,UAAU,yBAAyB;gBAC3F,CAAC,CAAC,0DAA0D,CAAC;QACjE,CAAC;QACD,KAAK,WAAW;YACd,OAAO,8EAA8E,CAAC;QACxF,KAAK,mBAAmB;YACtB,OAAO,2EAA2E,CAAC;IACvF,CAAC;AACH,CAAC"}
@@ -0,0 +1,22 @@
1
+ /**
2
+ * Equivalence Scorer — computes composite translation confidence per construct.
3
+ *
4
+ * Score = weighted(static, contextual)
5
+ * - static: UCR mapping confidence (min of source + target)
6
+ * - contextual: constraint satisfaction ratio
7
+ *
8
+ * Constructs with finalConfidence >= UCR_CONFIDENCE_THRESHOLD → deterministic
9
+ * Constructs with finalConfidence < UCR_CONFIDENCE_THRESHOLD → needsAiAssist
10
+ */
11
+ import { ConstructRegistry } from "../ucr/construct-registry.js";
12
+ import type { TranslationScore } from "../ucr/construct-types.js";
13
+ /**
14
+ * Score a single construct for translation between source and target languages.
15
+ * Returns null if no translation path exists.
16
+ */
17
+ export declare function scoreConstruct(registry: ConstructRegistry, constructId: string, sourceLang: string, targetLang: string): TranslationScore | null;
18
+ /**
19
+ * Score multiple constructs in batch. Skips constructs with no translation path.
20
+ */
21
+ export declare function scoreConstructs(registry: ConstructRegistry, constructIds: string[], sourceLang: string, targetLang: string): TranslationScore[];
22
+ //# sourceMappingURL=equivalence-scorer.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"equivalence-scorer.d.ts","sourceRoot":"","sources":["../../../../src/core/translation/confidence/equivalence-scorer.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,OAAO,EAAE,iBAAiB,EAAE,MAAM,8BAA8B,CAAC;AACjE,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,2BAA2B,CAAC;AAMlE;;;GAGG;AACH,wBAAgB,cAAc,CAC5B,QAAQ,EAAE,iBAAiB,EAC3B,WAAW,EAAE,MAAM,EACnB,UAAU,EAAE,MAAM,EAClB,UAAU,EAAE,MAAM,GACjB,gBAAgB,GAAG,IAAI,CA6BzB;AAED;;GAEG;AACH,wBAAgB,eAAe,CAC7B,QAAQ,EAAE,iBAAiB,EAC3B,YAAY,EAAE,MAAM,EAAE,EACtB,UAAU,EAAE,MAAM,EAClB,UAAU,EAAE,MAAM,GACjB,gBAAgB,EAAE,CAOpB"}
@@ -0,0 +1,72 @@
1
+ /**
2
+ * Equivalence Scorer — computes composite translation confidence per construct.
3
+ *
4
+ * Score = weighted(static, contextual)
5
+ * - static: UCR mapping confidence (min of source + target)
6
+ * - contextual: constraint satisfaction ratio
7
+ *
8
+ * Constructs with finalConfidence >= UCR_CONFIDENCE_THRESHOLD → deterministic
9
+ * Constructs with finalConfidence < UCR_CONFIDENCE_THRESHOLD → needsAiAssist
10
+ */
11
+ import { UCR_CONFIDENCE_THRESHOLD } from "../../utils/constants.js";
12
+ const STATIC_WEIGHT = 0.7;
13
+ const CONTEXTUAL_WEIGHT = 0.3;
14
+ /**
15
+ * Score a single construct for translation between source and target languages.
16
+ * Returns null if no translation path exists.
17
+ */
18
+ export function scoreConstruct(registry, constructId, sourceLang, targetLang) {
19
+ const path = registry.findTranslationPath(constructId, sourceLang, targetLang);
20
+ if (!path)
21
+ return null;
22
+ const staticConfidence = path.confidence;
23
+ // Contextual: evaluate constraint satisfaction on target mapping
24
+ const contextualConfidence = computeContextualConfidence(path.targetMapping.constraints);
25
+ const finalConfidence = STATIC_WEIGHT * staticConfidence + CONTEXTUAL_WEIGHT * contextualConfidence;
26
+ const needsAiAssist = finalConfidence < UCR_CONFIDENCE_THRESHOLD;
27
+ const alternatives = path.alternatives.map((alt) => ({
28
+ mappingId: alt.id,
29
+ confidence: alt.confidence,
30
+ reason: alt.syntaxPattern
31
+ ? `Alternative pattern: ${alt.syntaxPattern}`
32
+ : `Alternative mapping (confidence: ${alt.confidence})`,
33
+ }));
34
+ return {
35
+ constructId,
36
+ staticConfidence,
37
+ contextualConfidence,
38
+ finalConfidence,
39
+ selectedMappingId: path.targetMapping.id,
40
+ alternatives,
41
+ needsAiAssist,
42
+ };
43
+ }
44
+ /**
45
+ * Score multiple constructs in batch. Skips constructs with no translation path.
46
+ */
47
+ export function scoreConstructs(registry, constructIds, sourceLang, targetLang) {
48
+ const results = [];
49
+ for (const id of constructIds) {
50
+ const score = scoreConstruct(registry, id, sourceLang, targetLang);
51
+ if (score)
52
+ results.push(score);
53
+ }
54
+ return results;
55
+ }
56
+ /**
57
+ * Compute contextual confidence from constraint evaluation.
58
+ * Empty/no constraints → full confidence (no restrictions).
59
+ * Each constraint key reduces confidence slightly
60
+ * since constraints indicate translation caveats.
61
+ */
62
+ function computeContextualConfidence(constraints) {
63
+ if (!constraints)
64
+ return 1.0;
65
+ const keys = Object.keys(constraints);
66
+ if (keys.length === 0)
67
+ return 1.0;
68
+ // Each constraint reduces confidence by a diminishing factor
69
+ const penalty = Math.min(keys.length * 0.1, 0.5);
70
+ return 1.0 - penalty;
71
+ }
72
+ //# sourceMappingURL=equivalence-scorer.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"equivalence-scorer.js","sourceRoot":"","sources":["../../../../src/core/translation/confidence/equivalence-scorer.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAIH,OAAO,EAAE,wBAAwB,EAAE,MAAM,0BAA0B,CAAC;AAEpE,MAAM,aAAa,GAAG,GAAG,CAAC;AAC1B,MAAM,iBAAiB,GAAG,GAAG,CAAC;AAE9B;;;GAGG;AACH,MAAM,UAAU,cAAc,CAC5B,QAA2B,EAC3B,WAAmB,EACnB,UAAkB,EAClB,UAAkB;IAElB,MAAM,IAAI,GAAG,QAAQ,CAAC,mBAAmB,CAAC,WAAW,EAAE,UAAU,EAAE,UAAU,CAAC,CAAC;IAC/E,IAAI,CAAC,IAAI;QAAE,OAAO,IAAI,CAAC;IAEvB,MAAM,gBAAgB,GAAG,IAAI,CAAC,UAAU,CAAC;IAEzC,iEAAiE;IACjE,MAAM,oBAAoB,GAAG,2BAA2B,CAAC,IAAI,CAAC,aAAa,CAAC,WAAW,CAAC,CAAC;IAEzF,MAAM,eAAe,GAAG,aAAa,GAAG,gBAAgB,GAAG,iBAAiB,GAAG,oBAAoB,CAAC;IACpG,MAAM,aAAa,GAAG,eAAe,GAAG,wBAAwB,CAAC;IAEjE,MAAM,YAAY,GAAG,IAAI,CAAC,YAAY,CAAC,GAAG,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,CAAC;QACnD,SAAS,EAAE,GAAG,CAAC,EAAE;QACjB,UAAU,EAAE,GAAG,CAAC,UAAU;QAC1B,MAAM,EAAE,GAAG,CAAC,aAAa;YACvB,CAAC,CAAC,wBAAwB,GAAG,CAAC,aAAa,EAAE;YAC7C,CAAC,CAAC,oCAAoC,GAAG,CAAC,UAAU,GAAG;KAC1D,CAAC,CAAC,CAAC;IAEJ,OAAO;QACL,WAAW;QACX,gBAAgB;QAChB,oBAAoB;QACpB,eAAe;QACf,iBAAiB,EAAE,IAAI,CAAC,aAAa,CAAC,EAAE;QACxC,YAAY;QACZ,aAAa;KACd,CAAC;AACJ,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,eAAe,CAC7B,QAA2B,EAC3B,YAAsB,EACtB,UAAkB,EAClB,UAAkB;IAElB,MAAM,OAAO,GAAuB,EAAE,CAAC;IACvC,KAAK,MAAM,EAAE,IAAI,YAAY,EAAE,CAAC;QAC9B,MAAM,KAAK,GAAG,cAAc,CAAC,QAAQ,EAAE,EAAE,EAAE,UAAU,EAAE,UAAU,CAAC,CAAC;QACnE,IAAI,KAAK;YAAE,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;IACjC,CAAC;IACD,OAAO,OAAO,CAAC;AACjB,CAAC;AAED;;;;;GAKG;AACH,SAAS,2BAA2B,CAAC,WAAgD;IACnF,IAAI,CAAC,WAAW;QAAE,OAAO,GAAG,CAAC;IAC7B,MAAM,IAAI,GAAG,MAAM,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC;IACtC,IAAI,IAAI,CAAC,MAAM,KAAK,CAAC;QAAE,OAAO,GAAG,CAAC;IAClC,6DAA6D;IAC7D,MAAM,OAAO,GAAG,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,MAAM,GAAG,GAAG,EAAE,GAAG,CAAC,CAAC;IACjD,OAAO,GAAG,GAAG,OAAO,CAAC;AACvB,CAAC"}
@@ -0,0 +1,22 @@
1
+ /**
2
+ * Generator Adapter interface — language-agnostic contract for generating code
3
+ * from canonical constructs using UCR syntax patterns.
4
+ */
5
+ import type { ParsedConstruct } from "../parsers/parser-adapter.js";
6
+ /** Result of code generation. */
7
+ export interface GeneratedCode {
8
+ /** Generated source code */
9
+ code: string;
10
+ /** Construct IDs that were successfully mapped to syntax patterns */
11
+ mappedConstructs: string[];
12
+ /** Construct IDs that had no syntax pattern in the target language */
13
+ unmappedConstructs: string[];
14
+ }
15
+ /** Adapter interface for language-specific code generators. */
16
+ export interface GeneratorAdapter {
17
+ /** Target language identifier (matches UCR language_id) */
18
+ readonly languageId: string;
19
+ /** Generate code from parsed canonical constructs. */
20
+ generate(constructs: ParsedConstruct[]): GeneratedCode;
21
+ }
22
+ //# sourceMappingURL=generator-adapter.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"generator-adapter.d.ts","sourceRoot":"","sources":["../../../../src/core/translation/generators/generator-adapter.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,8BAA8B,CAAC;AAEpE,iCAAiC;AACjC,MAAM,WAAW,aAAa;IAC5B,4BAA4B;IAC5B,IAAI,EAAE,MAAM,CAAC;IACb,qEAAqE;IACrE,gBAAgB,EAAE,MAAM,EAAE,CAAC;IAC3B,sEAAsE;IACtE,kBAAkB,EAAE,MAAM,EAAE,CAAC;CAC9B;AAED,+DAA+D;AAC/D,MAAM,WAAW,gBAAgB;IAC/B,2DAA2D;IAC3D,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAC;IAE5B,sDAAsD;IACtD,QAAQ,CAAC,UAAU,EAAE,eAAe,EAAE,GAAG,aAAa,CAAC;CACxD"}
@@ -0,0 +1,6 @@
1
+ /**
2
+ * Generator Adapter interface — language-agnostic contract for generating code
3
+ * from canonical constructs using UCR syntax patterns.
4
+ */
5
+ export {};
6
+ //# sourceMappingURL=generator-adapter.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"generator-adapter.js","sourceRoot":"","sources":["../../../../src/core/translation/generators/generator-adapter.ts"],"names":[],"mappings":"AAAA;;;GAGG"}
@@ -0,0 +1,15 @@
1
+ /**
2
+ * Python Generator — emits Python code from canonical constructs
3
+ * using UCR syntax patterns. Handles indentation, snake_case naming,
4
+ * and Python-specific imports.
5
+ */
6
+ import { ConstructRegistry } from "../ucr/construct-registry.js";
7
+ import type { GeneratorAdapter, GeneratedCode } from "./generator-adapter.js";
8
+ import type { ParsedConstruct } from "../parsers/parser-adapter.js";
9
+ export declare class PythonGenerator implements GeneratorAdapter {
10
+ private readonly registry;
11
+ readonly languageId = "python";
12
+ constructor(registry: ConstructRegistry);
13
+ generate(constructs: ParsedConstruct[]): GeneratedCode;
14
+ }
15
+ //# sourceMappingURL=python-generator.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"python-generator.d.ts","sourceRoot":"","sources":["../../../../src/core/translation/generators/python-generator.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAE,iBAAiB,EAAE,MAAM,8BAA8B,CAAC;AACjE,OAAO,KAAK,EAAE,gBAAgB,EAAE,aAAa,EAAE,MAAM,wBAAwB,CAAC;AAC9E,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,8BAA8B,CAAC;AAEpE,qBAAa,eAAgB,YAAW,gBAAgB;IAG1C,OAAO,CAAC,QAAQ,CAAC,QAAQ;IAFrC,QAAQ,CAAC,UAAU,YAAY;gBAEF,QAAQ,EAAE,iBAAiB;IAExD,QAAQ,CAAC,UAAU,EAAE,eAAe,EAAE,GAAG,aAAa;CA4BvD"}
@@ -0,0 +1,74 @@
1
+ /**
2
+ * Python Generator — emits Python code from canonical constructs
3
+ * using UCR syntax patterns. Handles indentation, snake_case naming,
4
+ * and Python-specific imports.
5
+ */
6
+ export class PythonGenerator {
7
+ registry;
8
+ languageId = "python";
9
+ constructor(registry) {
10
+ this.registry = registry;
11
+ }
12
+ generate(constructs) {
13
+ if (constructs.length === 0) {
14
+ return { code: "", mappedConstructs: [], unmappedConstructs: [] };
15
+ }
16
+ const lines = [];
17
+ const mapped = [];
18
+ const unmapped = [];
19
+ for (const construct of constructs) {
20
+ const mapping = this.registry.getPrimaryMapping(construct.constructId, this.languageId);
21
+ if (!mapping || !mapping.syntaxPattern) {
22
+ unmapped.push(construct.constructId);
23
+ continue;
24
+ }
25
+ const code = substitutePattern(mapping.syntaxPattern, construct);
26
+ lines.push(code);
27
+ mapped.push(construct.constructId);
28
+ }
29
+ return {
30
+ code: lines.join("\n\n"),
31
+ mappedConstructs: mapped,
32
+ unmappedConstructs: unmapped,
33
+ };
34
+ }
35
+ }
36
+ /** Convert camelCase to snake_case for Python naming conventions. */
37
+ function toSnakeCase(name) {
38
+ return name
39
+ .replace(/([a-z])([A-Z])/g, "$1_$2")
40
+ .replace(/([A-Z])([A-Z][a-z])/g, "$1_$2")
41
+ .toLowerCase();
42
+ }
43
+ /** Check if a name is PascalCase (class-like). */
44
+ function isPascalCase(name) {
45
+ return /^[A-Z][a-zA-Z0-9]*$/.test(name);
46
+ }
47
+ /** Substitute {{placeholders}} in a syntax pattern with construct data. */
48
+ function substitutePattern(pattern, construct) {
49
+ let result = pattern;
50
+ if (construct.name) {
51
+ // Keep PascalCase for classes, convert functions/variables to snake_case
52
+ const isClass = construct.constructId === "uc_class_def" || construct.constructId === "uc_abstract_class";
53
+ const name = isClass || isPascalCase(construct.name) && isClass
54
+ ? construct.name
55
+ : toSnakeCase(construct.name);
56
+ result = result.replace(/\{\{name\}\}/g, name);
57
+ }
58
+ // Default placeholders for unresolved template vars
59
+ result = result.replace(/\{\{members\}\}/g, "pass # TODO: members");
60
+ result = result.replace(/\{\{params\}\}/g, "");
61
+ result = result.replace(/\{\{body\}\}/g, "pass # TODO: implement");
62
+ result = result.replace(/\{\{value\}\}/g, "None");
63
+ result = result.replace(/\{\{condition\}\}/g, "True # condition");
64
+ result = result.replace(/\{\{type\}\}/g, "Any");
65
+ result = result.replace(/\{\{module\}\}/g, "module");
66
+ result = result.replace(/\{\{items\}\}/g, "items");
67
+ result = result.replace(/\{\{item\}\}/g, "item");
68
+ result = result.replace(/\{\{expression\}\}/g, "None # expression");
69
+ result = result.replace(/\{\{error\}\}/g, "e");
70
+ result = result.replace(/\{\{message\}\}/g, "'Error'");
71
+ result = result.replace(/\{\{parent\}\}/g, "object");
72
+ return result;
73
+ }
74
+ //# sourceMappingURL=python-generator.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"python-generator.js","sourceRoot":"","sources":["../../../../src/core/translation/generators/python-generator.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAMH,MAAM,OAAO,eAAe;IAGG;IAFpB,UAAU,GAAG,QAAQ,CAAC;IAE/B,YAA6B,QAA2B;QAA3B,aAAQ,GAAR,QAAQ,CAAmB;IAAG,CAAC;IAE5D,QAAQ,CAAC,UAA6B;QACpC,IAAI,UAAU,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;YAC5B,OAAO,EAAE,IAAI,EAAE,EAAE,EAAE,gBAAgB,EAAE,EAAE,EAAE,kBAAkB,EAAE,EAAE,EAAE,CAAC;QACpE,CAAC;QAED,MAAM,KAAK,GAAa,EAAE,CAAC;QAC3B,MAAM,MAAM,GAAa,EAAE,CAAC;QAC5B,MAAM,QAAQ,GAAa,EAAE,CAAC;QAE9B,KAAK,MAAM,SAAS,IAAI,UAAU,EAAE,CAAC;YACnC,MAAM,OAAO,GAAG,IAAI,CAAC,QAAQ,CAAC,iBAAiB,CAAC,SAAS,CAAC,WAAW,EAAE,IAAI,CAAC,UAAU,CAAC,CAAC;YAExF,IAAI,CAAC,OAAO,IAAI,CAAC,OAAO,CAAC,aAAa,EAAE,CAAC;gBACvC,QAAQ,CAAC,IAAI,CAAC,SAAS,CAAC,WAAW,CAAC,CAAC;gBACrC,SAAS;YACX,CAAC;YAED,MAAM,IAAI,GAAG,iBAAiB,CAAC,OAAO,CAAC,aAAa,EAAE,SAAS,CAAC,CAAC;YACjE,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;YACjB,MAAM,CAAC,IAAI,CAAC,SAAS,CAAC,WAAW,CAAC,CAAC;QACrC,CAAC;QAED,OAAO;YACL,IAAI,EA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,EAAE,MAAM,CAAC,CAAC;IAClD,MAAM,GAAG,MAAM,CAAC,OAAO,CAAC,oBAAoB,EAAE,mBAAmB,CAAC,CAAC;IACnE,MAAM,GAAG,MAAM,CAAC,OAAO,CAAC,eAAe,EAAE,KAAK,CAAC,CAAC;IAChD,MAAM,GAAG,MAAM,CAAC,OAAO,CAAC,iBAAiB,EAAE,QAAQ,CAAC,CAAC;IACrD,MAAM,GAAG,MAAM,CAAC,OAAO,CAAC,gBAAgB,EAAE,OAAO,CAAC,CAAC;IACnD,MAAM,GAAG,MAAM,CAAC,OAAO,CAAC,eAAe,EAAE,MAAM,CAAC,CAAC;IACjD,MAAM,GAAG,MAAM,CAAC,OAAO,CAAC,qBAAqB,EAAE,oBAAoB,CAAC,CAAC;IACrE,MAAM,GAAG,MAAM,CAAC,OAAO,CAAC,gBAAgB,EAAE,GAAG,CAAC,CAAC;IAC/C,MAAM,GAAG,MAAM,CAAC,OAAO,CAAC,kBAAkB,EAAE,SAAS,CAAC,CAAC;IACvD,MAAM,GAAG,MAAM,CAAC,OAAO,CAAC,iBAAiB,EAAE,QAAQ,CAAC,CAAC;IACrD,OAAO,MAAM,CAAC;AAChB,CAAC"}
@@ -0,0 +1,14 @@
1
+ /**
2
+ * TypeScript Generator — emits TypeScript code from canonical constructs
3
+ * using UCR syntax patterns with {{placeholder}} substitution.
4
+ */
5
+ import { ConstructRegistry } from "../ucr/construct-registry.js";
6
+ import type { GeneratorAdapter, GeneratedCode } from "./generator-adapter.js";
7
+ import type { ParsedConstruct } from "../parsers/parser-adapter.js";
8
+ export declare class TsGenerator implements GeneratorAdapter {
9
+ private readonly registry;
10
+ readonly languageId = "typescript";
11
+ constructor(registry: ConstructRegistry);
12
+ generate(constructs: ParsedConstruct[]): GeneratedCode;
13
+ }
14
+ //# sourceMappingURL=ts-generator.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ts-generator.d.ts","sourceRoot":"","sources":["../../../../src/core/translation/generators/ts-generator.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,iBAAiB,EAAE,MAAM,8BAA8B,CAAC;AACjE,OAAO,KAAK,EAAE,gBAAgB,EAAE,aAAa,EAAE,MAAM,wBAAwB,CAAC;AAC9E,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,8BAA8B,CAAC;AAEpE,qBAAa,WAAY,YAAW,gBAAgB;IAGtC,OAAO,CAAC,QAAQ,CAAC,QAAQ;IAFrC,QAAQ,CAAC,UAAU,gBAAgB;gBAEN,QAAQ,EAAE,iBAAiB;IAExD,QAAQ,CAAC,UAAU,EAAE,eAAe,EAAE,GAAG,aAAa;CA4BvD"}
@@ -0,0 +1,56 @@
1
+ /**
2
+ * TypeScript Generator — emits TypeScript code from canonical constructs
3
+ * using UCR syntax patterns with {{placeholder}} substitution.
4
+ */
5
+ export class TsGenerator {
6
+ registry;
7
+ languageId = "typescript";
8
+ constructor(registry) {
9
+ this.registry = registry;
10
+ }
11
+ generate(constructs) {
12
+ if (constructs.length === 0) {
13
+ return { code: "", mappedConstructs: [], unmappedConstructs: [] };
14
+ }
15
+ const lines = [];
16
+ const mapped = [];
17
+ const unmapped = [];
18
+ for (const construct of constructs) {
19
+ const mapping = this.registry.getPrimaryMapping(construct.constructId, this.languageId);
20
+ if (!mapping || !mapping.syntaxPattern) {
21
+ unmapped.push(construct.constructId);
22
+ continue;
23
+ }
24
+ const code = substitutePattern(mapping.syntaxPattern, construct);
25
+ lines.push(code);
26
+ mapped.push(construct.constructId);
27
+ }
28
+ return {
29
+ code: lines.join("\n\n"),
30
+ mappedConstructs: mapped,
31
+ unmappedConstructs: unmapped,
32
+ };
33
+ }
34
+ }
35
+ /** Substitute {{placeholders}} in a syntax pattern with construct data. */
36
+ function substitutePattern(pattern, construct) {
37
+ let result = pattern;
38
+ if (construct.name) {
39
+ result = result.replace(/\{\{name\}\}/g, construct.name);
40
+ }
41
+ // Default placeholders for unresolved template vars
42
+ result = result.replace(/\{\{members\}\}/g, "// TODO: members");
43
+ result = result.replace(/\{\{params\}\}/g, "");
44
+ result = result.replace(/\{\{body\}\}/g, "// TODO: implement");
45
+ result = result.replace(/\{\{value\}\}/g, "undefined");
46
+ result = result.replace(/\{\{condition\}\}/g, "/* condition */");
47
+ result = result.replace(/\{\{type\}\}/g, "unknown");
48
+ result = result.replace(/\{\{module\}\}/g, "'./module'");
49
+ result = result.replace(/\{\{items\}\}/g, "items");
50
+ result = result.replace(/\{\{item\}\}/g, "item");
51
+ result = result.replace(/\{\{expression\}\}/g, "/* expression */");
52
+ result = result.replace(/\{\{error\}\}/g, "e");
53
+ result = result.replace(/\{\{message\}\}/g, "'Error'");
54
+ return result;
55
+ }
56
+ //# sourceMappingURL=ts-generator.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ts-generator.js","sourceRoot":"","sources":["../../../../src/core/translation/generators/ts-generator.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAMH,MAAM,OAAO,WAAW;IAGO;IAFpB,UAAU,GAAG,YAAY,CAAC;IAEnC,YAA6B,QAA2B;QAA3B,aAAQ,GAAR,QAAQ,CAAmB;IAAG,CAAC;IAE5D,QAAQ,CAAC,UAA6B;QACpC,IAAI,UAAU,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;YAC5B,OAAO,EAAE,IAAI,EAAE,EAAE,EAAE,gBAAgB,EAAE,EAAE,EAAE,kBAAkB,EAAE,EAAE,EAAE,CAAC;QACpE,CAAC;QAED,MAAM,KAAK,GAAa,EAAE,CAAC;QAC3B,MAAM,MAAM,GAAa,EAAE,CAAC;QAC5B,MAAM,QAAQ,GAAa,EAAE,CAAC;QAE9B,KAAK,MAAM,SAAS,IAAI,UAAU,EAAE,CAAC;YACnC,MAAM,OAAO,GAAG,IAAI,CAAC,QAAQ,CAAC,iBAAiB,CAAC,SAAS,CAAC,WAAW,EAAE,IAAI,CAAC,UAAU,CAAC,CAAC;YAExF,IAAI,CAAC,OAAO,IAAI,CAAC,OAAO,CAAC,aAAa,EAAE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AG,MAAM,CAAC,OAAO,CAAC,gBAAgB,EAAE,OAAO,CAAC,CAAC;IACnD,MAAM,GAAG,MAAM,CAAC,OAAO,CAAC,eAAe,EAAE,MAAM,CAAC,CAAC;IACjD,MAAM,GAAG,MAAM,CAAC,OAAO,CAAC,qBAAqB,EAAE,kBAAkB,CAAC,CAAC;IACnE,MAAM,GAAG,MAAM,CAAC,OAAO,CAAC,gBAAgB,EAAE,GAAG,CAAC,CAAC;IAC/C,MAAM,GAAG,MAAM,CAAC,OAAO,CAAC,kBAAkB,EAAE,SAAS,CAAC,CAAC;IACvD,OAAO,MAAM,CAAC;AAChB,CAAC"}
@@ -0,0 +1,12 @@
1
+ /**
2
+ * Language Detection from Code Snippets — heuristic keyword/pattern detection.
3
+ * Returns languageId, confidence (0-1), and indicators explaining the detection.
4
+ */
5
+ export { detectProjectLanguages } from "../lsp/language-detector.js";
6
+ export interface LanguageDetectionResult {
7
+ languageId: string;
8
+ confidence: number;
9
+ indicators: string[];
10
+ }
11
+ export declare function detectLanguageFromCode(code: string): LanguageDetectionResult;
12
+ //# sourceMappingURL=language-detect.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"language-detect.d.ts","sourceRoot":"","sources":["../../../src/core/translation/language-detect.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,sBAAsB,EAAE,MAAM,6BAA6B,CAAC;AAErE,MAAM,WAAW,uBAAuB;IACtC,UAAU,EAAE,MAAM,CAAC;IACnB,UAAU,EAAE,MAAM,CAAC;IACnB,UAAU,EAAE,MAAM,EAAE,CAAC;CACtB;AA6GD,wBAAgB,sBAAsB,CAAC,IAAI,EAAE,MAAM,GAAG,uBAAuB,CA4C5E"}