@burtson-labs/stealth-core-runtime 1.4.7

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 (415) hide show
  1. package/LICENSE +201 -0
  2. package/README.md +46 -0
  3. package/dist/banditEngineProvider.d.ts +48 -0
  4. package/dist/banditEngineProvider.d.ts.map +1 -0
  5. package/dist/banditEngineProvider.js +1021 -0
  6. package/dist/banditEngineProvider.js.map +1 -0
  7. package/dist/embeddingCache.d.ts +23 -0
  8. package/dist/embeddingCache.d.ts.map +1 -0
  9. package/dist/embeddingCache.js +196 -0
  10. package/dist/embeddingCache.js.map +1 -0
  11. package/dist/embeddingClient.d.ts +35 -0
  12. package/dist/embeddingClient.d.ts.map +1 -0
  13. package/dist/embeddingClient.js +162 -0
  14. package/dist/embeddingClient.js.map +1 -0
  15. package/dist/executorAgent.d.ts +7 -0
  16. package/dist/executorAgent.d.ts.map +1 -0
  17. package/dist/executorAgent.js +95 -0
  18. package/dist/executorAgent.js.map +1 -0
  19. package/dist/extensionSystemPrompt.d.ts +80 -0
  20. package/dist/extensionSystemPrompt.d.ts.map +1 -0
  21. package/dist/extensionSystemPrompt.js +208 -0
  22. package/dist/extensionSystemPrompt.js.map +1 -0
  23. package/dist/gatewaySearchAdapter.d.ts +69 -0
  24. package/dist/gatewaySearchAdapter.d.ts.map +1 -0
  25. package/dist/gatewaySearchAdapter.js +131 -0
  26. package/dist/gatewaySearchAdapter.js.map +1 -0
  27. package/dist/goalInference.d.ts +26 -0
  28. package/dist/goalInference.d.ts.map +1 -0
  29. package/dist/goalInference.js +605 -0
  30. package/dist/goalInference.js.map +1 -0
  31. package/dist/hostTypes.d.ts +86 -0
  32. package/dist/hostTypes.d.ts.map +1 -0
  33. package/dist/hostTypes.js +3 -0
  34. package/dist/hostTypes.js.map +1 -0
  35. package/dist/index.d.ts +37 -0
  36. package/dist/index.d.ts.map +1 -0
  37. package/dist/index.js +83 -0
  38. package/dist/index.js.map +1 -0
  39. package/dist/internalTypes.d.ts +16 -0
  40. package/dist/internalTypes.d.ts.map +1 -0
  41. package/dist/internalTypes.js +20 -0
  42. package/dist/internalTypes.js.map +1 -0
  43. package/dist/ollamaEmbeddingClient.d.ts +45 -0
  44. package/dist/ollamaEmbeddingClient.d.ts.map +1 -0
  45. package/dist/ollamaEmbeddingClient.js +143 -0
  46. package/dist/ollamaEmbeddingClient.js.map +1 -0
  47. package/dist/pdfjsShim.d.ts +2 -0
  48. package/dist/pdfjsShim.d.ts.map +1 -0
  49. package/dist/pdfjsShim.js +80 -0
  50. package/dist/pdfjsShim.js.map +1 -0
  51. package/dist/runtime/actionRuntime.d.ts +13 -0
  52. package/dist/runtime/actionRuntime.d.ts.map +1 -0
  53. package/dist/runtime/actionRuntime.js +15 -0
  54. package/dist/runtime/actionRuntime.js.map +1 -0
  55. package/dist/runtime/actionServices.d.ts +72 -0
  56. package/dist/runtime/actionServices.d.ts.map +1 -0
  57. package/dist/runtime/actionServices.js +53 -0
  58. package/dist/runtime/actionServices.js.map +1 -0
  59. package/dist/runtime/adapters/connectorBus.d.ts +9 -0
  60. package/dist/runtime/adapters/connectorBus.d.ts.map +1 -0
  61. package/dist/runtime/adapters/connectorBus.js +20 -0
  62. package/dist/runtime/adapters/connectorBus.js.map +1 -0
  63. package/dist/runtime/adapters/fsAdapter.d.ts +6 -0
  64. package/dist/runtime/adapters/fsAdapter.d.ts.map +1 -0
  65. package/dist/runtime/adapters/fsAdapter.js +144 -0
  66. package/dist/runtime/adapters/fsAdapter.js.map +1 -0
  67. package/dist/runtime/adapters/llmAdapter.d.ts +4 -0
  68. package/dist/runtime/adapters/llmAdapter.d.ts.map +1 -0
  69. package/dist/runtime/adapters/llmAdapter.js +12 -0
  70. package/dist/runtime/adapters/llmAdapter.js.map +1 -0
  71. package/dist/runtime/adapters/shellAdapter.d.ts +6 -0
  72. package/dist/runtime/adapters/shellAdapter.d.ts.map +1 -0
  73. package/dist/runtime/adapters/shellAdapter.js +118 -0
  74. package/dist/runtime/adapters/shellAdapter.js.map +1 -0
  75. package/dist/runtime/additionalWrites.d.ts +22 -0
  76. package/dist/runtime/additionalWrites.d.ts.map +1 -0
  77. package/dist/runtime/additionalWrites.js +148 -0
  78. package/dist/runtime/additionalWrites.js.map +1 -0
  79. package/dist/runtime/artifactManager.d.ts +32 -0
  80. package/dist/runtime/artifactManager.d.ts.map +1 -0
  81. package/dist/runtime/artifactManager.js +154 -0
  82. package/dist/runtime/artifactManager.js.map +1 -0
  83. package/dist/runtime/autoHealer.d.ts +27 -0
  84. package/dist/runtime/autoHealer.d.ts.map +1 -0
  85. package/dist/runtime/autoHealer.js +583 -0
  86. package/dist/runtime/autoHealer.js.map +1 -0
  87. package/dist/runtime/changeTracker.d.ts +20 -0
  88. package/dist/runtime/changeTracker.d.ts.map +1 -0
  89. package/dist/runtime/changeTracker.js +147 -0
  90. package/dist/runtime/changeTracker.js.map +1 -0
  91. package/dist/runtime/contextBuilder.d.ts +85 -0
  92. package/dist/runtime/contextBuilder.d.ts.map +1 -0
  93. package/dist/runtime/contextBuilder.js +159 -0
  94. package/dist/runtime/contextBuilder.js.map +1 -0
  95. package/dist/runtime/coreRuntime.d.ts +7 -0
  96. package/dist/runtime/coreRuntime.d.ts.map +1 -0
  97. package/dist/runtime/coreRuntime.js +173 -0
  98. package/dist/runtime/coreRuntime.js.map +1 -0
  99. package/dist/runtime/createStealthRuntime.d.ts +4 -0
  100. package/dist/runtime/createStealthRuntime.d.ts.map +1 -0
  101. package/dist/runtime/createStealthRuntime.js +514 -0
  102. package/dist/runtime/createStealthRuntime.js.map +1 -0
  103. package/dist/runtime/diagnostics.d.ts +53 -0
  104. package/dist/runtime/diagnostics.d.ts.map +1 -0
  105. package/dist/runtime/diagnostics.js +396 -0
  106. package/dist/runtime/diagnostics.js.map +1 -0
  107. package/dist/runtime/diagnosticsServices.d.ts +51 -0
  108. package/dist/runtime/diagnosticsServices.d.ts.map +1 -0
  109. package/dist/runtime/diagnosticsServices.js +46 -0
  110. package/dist/runtime/diagnosticsServices.js.map +1 -0
  111. package/dist/runtime/diffManager.d.ts +20 -0
  112. package/dist/runtime/diffManager.d.ts.map +1 -0
  113. package/dist/runtime/diffManager.js +172 -0
  114. package/dist/runtime/diffManager.js.map +1 -0
  115. package/dist/runtime/diffPresenter.d.ts +8 -0
  116. package/dist/runtime/diffPresenter.d.ts.map +1 -0
  117. package/dist/runtime/diffPresenter.js +57 -0
  118. package/dist/runtime/diffPresenter.js.map +1 -0
  119. package/dist/runtime/embeddingClientResolver.d.ts +14 -0
  120. package/dist/runtime/embeddingClientResolver.d.ts.map +1 -0
  121. package/dist/runtime/embeddingClientResolver.js +54 -0
  122. package/dist/runtime/embeddingClientResolver.js.map +1 -0
  123. package/dist/runtime/embeddingManager.d.ts +22 -0
  124. package/dist/runtime/embeddingManager.d.ts.map +1 -0
  125. package/dist/runtime/embeddingManager.js +224 -0
  126. package/dist/runtime/embeddingManager.js.map +1 -0
  127. package/dist/runtime/eventBus.d.ts +7 -0
  128. package/dist/runtime/eventBus.d.ts.map +1 -0
  129. package/dist/runtime/eventBus.js +28 -0
  130. package/dist/runtime/eventBus.js.map +1 -0
  131. package/dist/runtime/executorServices.d.ts +46 -0
  132. package/dist/runtime/executorServices.d.ts.map +1 -0
  133. package/dist/runtime/executorServices.js +47 -0
  134. package/dist/runtime/executorServices.js.map +1 -0
  135. package/dist/runtime/extractionService.d.ts +11 -0
  136. package/dist/runtime/extractionService.d.ts.map +1 -0
  137. package/dist/runtime/extractionService.js +282 -0
  138. package/dist/runtime/extractionService.js.map +1 -0
  139. package/dist/runtime/feedbackService.d.ts +12 -0
  140. package/dist/runtime/feedbackService.d.ts.map +1 -0
  141. package/dist/runtime/feedbackService.js +111 -0
  142. package/dist/runtime/feedbackService.js.map +1 -0
  143. package/dist/runtime/goalEngine.d.ts +10 -0
  144. package/dist/runtime/goalEngine.d.ts.map +1 -0
  145. package/dist/runtime/goalEngine.js +429 -0
  146. package/dist/runtime/goalEngine.js.map +1 -0
  147. package/dist/runtime/goalFlowServices.d.ts +49 -0
  148. package/dist/runtime/goalFlowServices.d.ts.map +1 -0
  149. package/dist/runtime/goalFlowServices.js +45 -0
  150. package/dist/runtime/goalFlowServices.js.map +1 -0
  151. package/dist/runtime/goalReplay.d.ts +33 -0
  152. package/dist/runtime/goalReplay.d.ts.map +1 -0
  153. package/dist/runtime/goalReplay.js +58 -0
  154. package/dist/runtime/goalReplay.js.map +1 -0
  155. package/dist/runtime/goalRunner.d.ts +35 -0
  156. package/dist/runtime/goalRunner.d.ts.map +1 -0
  157. package/dist/runtime/goalRunner.js +42 -0
  158. package/dist/runtime/goalRunner.js.map +1 -0
  159. package/dist/runtime/healingEngine.d.ts +72 -0
  160. package/dist/runtime/healingEngine.d.ts.map +1 -0
  161. package/dist/runtime/healingEngine.js +969 -0
  162. package/dist/runtime/healingEngine.js.map +1 -0
  163. package/dist/runtime/healingServices.d.ts +62 -0
  164. package/dist/runtime/healingServices.d.ts.map +1 -0
  165. package/dist/runtime/healingServices.js +45 -0
  166. package/dist/runtime/healingServices.js.map +1 -0
  167. package/dist/runtime/helpers.d.ts +22 -0
  168. package/dist/runtime/helpers.d.ts.map +1 -0
  169. package/dist/runtime/helpers.js +694 -0
  170. package/dist/runtime/helpers.js.map +1 -0
  171. package/dist/runtime/hosts/actionHost.d.ts +82 -0
  172. package/dist/runtime/hosts/actionHost.d.ts.map +1 -0
  173. package/dist/runtime/hosts/actionHost.js +61 -0
  174. package/dist/runtime/hosts/actionHost.js.map +1 -0
  175. package/dist/runtime/hosts/baseServices.d.ts +51 -0
  176. package/dist/runtime/hosts/baseServices.d.ts.map +1 -0
  177. package/dist/runtime/hosts/baseServices.js +73 -0
  178. package/dist/runtime/hosts/baseServices.js.map +1 -0
  179. package/dist/runtime/hosts/embeddingServices.d.ts +25 -0
  180. package/dist/runtime/hosts/embeddingServices.d.ts.map +1 -0
  181. package/dist/runtime/hosts/embeddingServices.js +34 -0
  182. package/dist/runtime/hosts/embeddingServices.js.map +1 -0
  183. package/dist/runtime/hosts/goalFlowHost.d.ts +34 -0
  184. package/dist/runtime/hosts/goalFlowHost.d.ts.map +1 -0
  185. package/dist/runtime/hosts/goalFlowHost.js +35 -0
  186. package/dist/runtime/hosts/goalFlowHost.js.map +1 -0
  187. package/dist/runtime/hosts/goalFlowRuntime.d.ts +41 -0
  188. package/dist/runtime/hosts/goalFlowRuntime.d.ts.map +1 -0
  189. package/dist/runtime/hosts/goalFlowRuntime.js +31 -0
  190. package/dist/runtime/hosts/goalFlowRuntime.js.map +1 -0
  191. package/dist/runtime/hosts/providerHost.d.ts +19 -0
  192. package/dist/runtime/hosts/providerHost.d.ts.map +1 -0
  193. package/dist/runtime/hosts/providerHost.js +18 -0
  194. package/dist/runtime/hosts/providerHost.js.map +1 -0
  195. package/dist/runtime/hosts/rewriteHost.d.ts +84 -0
  196. package/dist/runtime/hosts/rewriteHost.d.ts.map +1 -0
  197. package/dist/runtime/hosts/rewriteHost.js +64 -0
  198. package/dist/runtime/hosts/rewriteHost.js.map +1 -0
  199. package/dist/runtime/hosts/workspaceHost.d.ts +113 -0
  200. package/dist/runtime/hosts/workspaceHost.d.ts.map +1 -0
  201. package/dist/runtime/hosts/workspaceHost.js +76 -0
  202. package/dist/runtime/hosts/workspaceHost.js.map +1 -0
  203. package/dist/runtime/index.d.ts +78 -0
  204. package/dist/runtime/index.d.ts.map +1 -0
  205. package/dist/runtime/index.js +95 -0
  206. package/dist/runtime/index.js.map +1 -0
  207. package/dist/runtime/insight.d.ts +16 -0
  208. package/dist/runtime/insight.d.ts.map +1 -0
  209. package/dist/runtime/insight.js +11 -0
  210. package/dist/runtime/insight.js.map +1 -0
  211. package/dist/runtime/internalActions.d.ts +16 -0
  212. package/dist/runtime/internalActions.d.ts.map +1 -0
  213. package/dist/runtime/internalActions.js +302 -0
  214. package/dist/runtime/internalActions.js.map +1 -0
  215. package/dist/runtime/modelBehavior.d.ts +69 -0
  216. package/dist/runtime/modelBehavior.d.ts.map +1 -0
  217. package/dist/runtime/modelBehavior.js +514 -0
  218. package/dist/runtime/modelBehavior.js.map +1 -0
  219. package/dist/runtime/modelCapabilities.d.ts +139 -0
  220. package/dist/runtime/modelCapabilities.d.ts.map +1 -0
  221. package/dist/runtime/modelCapabilities.js +458 -0
  222. package/dist/runtime/modelCapabilities.js.map +1 -0
  223. package/dist/runtime/modelsDevCatalog.d.ts +34 -0
  224. package/dist/runtime/modelsDevCatalog.d.ts.map +1 -0
  225. package/dist/runtime/modelsDevCatalog.js +263 -0
  226. package/dist/runtime/modelsDevCatalog.js.map +1 -0
  227. package/dist/runtime/pendingInference.d.ts +18 -0
  228. package/dist/runtime/pendingInference.d.ts.map +1 -0
  229. package/dist/runtime/pendingInference.js +121 -0
  230. package/dist/runtime/pendingInference.js.map +1 -0
  231. package/dist/runtime/persistence.d.ts +21 -0
  232. package/dist/runtime/persistence.d.ts.map +1 -0
  233. package/dist/runtime/persistence.js +73 -0
  234. package/dist/runtime/persistence.js.map +1 -0
  235. package/dist/runtime/planContext.d.ts +42 -0
  236. package/dist/runtime/planContext.d.ts.map +1 -0
  237. package/dist/runtime/planContext.js +246 -0
  238. package/dist/runtime/planContext.js.map +1 -0
  239. package/dist/runtime/planGenerator.d.ts +21 -0
  240. package/dist/runtime/planGenerator.d.ts.map +1 -0
  241. package/dist/runtime/planGenerator.js +89 -0
  242. package/dist/runtime/planGenerator.js.map +1 -0
  243. package/dist/runtime/planPreparation.d.ts +64 -0
  244. package/dist/runtime/planPreparation.d.ts.map +1 -0
  245. package/dist/runtime/planPreparation.js +173 -0
  246. package/dist/runtime/planPreparation.js.map +1 -0
  247. package/dist/runtime/projectSummary.d.ts +3 -0
  248. package/dist/runtime/projectSummary.d.ts.map +1 -0
  249. package/dist/runtime/projectSummary.js +42 -0
  250. package/dist/runtime/projectSummary.js.map +1 -0
  251. package/dist/runtime/providerSettings.d.ts +28 -0
  252. package/dist/runtime/providerSettings.d.ts.map +1 -0
  253. package/dist/runtime/providerSettings.js +93 -0
  254. package/dist/runtime/providerSettings.js.map +1 -0
  255. package/dist/runtime/pythonActions.d.ts +78 -0
  256. package/dist/runtime/pythonActions.d.ts.map +1 -0
  257. package/dist/runtime/pythonActions.js +392 -0
  258. package/dist/runtime/pythonActions.js.map +1 -0
  259. package/dist/runtime/pythonBridge.d.ts +13 -0
  260. package/dist/runtime/pythonBridge.d.ts.map +1 -0
  261. package/dist/runtime/pythonBridge.js +117 -0
  262. package/dist/runtime/pythonBridge.js.map +1 -0
  263. package/dist/runtime/rewriteEngine.d.ts +46 -0
  264. package/dist/runtime/rewriteEngine.d.ts.map +1 -0
  265. package/dist/runtime/rewriteEngine.js +259 -0
  266. package/dist/runtime/rewriteEngine.js.map +1 -0
  267. package/dist/runtime/rewriteGenerator.d.ts +29 -0
  268. package/dist/runtime/rewriteGenerator.d.ts.map +1 -0
  269. package/dist/runtime/rewriteGenerator.js +1527 -0
  270. package/dist/runtime/rewriteGenerator.js.map +1 -0
  271. package/dist/runtime/rewriteHydration.d.ts +22 -0
  272. package/dist/runtime/rewriteHydration.d.ts.map +1 -0
  273. package/dist/runtime/rewriteHydration.js +265 -0
  274. package/dist/runtime/rewriteHydration.js.map +1 -0
  275. package/dist/runtime/rewriteOrchestration.d.ts +105 -0
  276. package/dist/runtime/rewriteOrchestration.d.ts.map +1 -0
  277. package/dist/runtime/rewriteOrchestration.js +130 -0
  278. package/dist/runtime/rewriteOrchestration.js.map +1 -0
  279. package/dist/runtime/rewritePayload.d.ts +18 -0
  280. package/dist/runtime/rewritePayload.d.ts.map +1 -0
  281. package/dist/runtime/rewritePayload.js +166 -0
  282. package/dist/runtime/rewritePayload.js.map +1 -0
  283. package/dist/runtime/rewriteRuntime.d.ts +13 -0
  284. package/dist/runtime/rewriteRuntime.d.ts.map +1 -0
  285. package/dist/runtime/rewriteRuntime.js +21 -0
  286. package/dist/runtime/rewriteRuntime.js.map +1 -0
  287. package/dist/runtime/rewriteServices.d.ts +70 -0
  288. package/dist/runtime/rewriteServices.d.ts.map +1 -0
  289. package/dist/runtime/rewriteServices.js +50 -0
  290. package/dist/runtime/rewriteServices.js.map +1 -0
  291. package/dist/runtime/runtimeHelpers.d.ts +9 -0
  292. package/dist/runtime/runtimeHelpers.d.ts.map +1 -0
  293. package/dist/runtime/runtimeHelpers.js +86 -0
  294. package/dist/runtime/runtimeHelpers.js.map +1 -0
  295. package/dist/runtime/sessionData.d.ts +4 -0
  296. package/dist/runtime/sessionData.d.ts.map +1 -0
  297. package/dist/runtime/sessionData.js +45 -0
  298. package/dist/runtime/sessionData.js.map +1 -0
  299. package/dist/runtime/sessionRuntime.d.ts +47 -0
  300. package/dist/runtime/sessionRuntime.d.ts.map +1 -0
  301. package/dist/runtime/sessionRuntime.js +128 -0
  302. package/dist/runtime/sessionRuntime.js.map +1 -0
  303. package/dist/runtime/stealthRuntimeTypes.d.ts +12 -0
  304. package/dist/runtime/stealthRuntimeTypes.d.ts.map +1 -0
  305. package/dist/runtime/stealthRuntimeTypes.js +3 -0
  306. package/dist/runtime/stealthRuntimeTypes.js.map +1 -0
  307. package/dist/runtime/stepExecutor.d.ts +22 -0
  308. package/dist/runtime/stepExecutor.d.ts.map +1 -0
  309. package/dist/runtime/stepExecutor.js +83 -0
  310. package/dist/runtime/stepExecutor.js.map +1 -0
  311. package/dist/runtime/stepLifecycle.d.ts +29 -0
  312. package/dist/runtime/stepLifecycle.d.ts.map +1 -0
  313. package/dist/runtime/stepLifecycle.js +122 -0
  314. package/dist/runtime/stepLifecycle.js.map +1 -0
  315. package/dist/runtime/stepMetadata.d.ts +6 -0
  316. package/dist/runtime/stepMetadata.d.ts.map +1 -0
  317. package/dist/runtime/stepMetadata.js +87 -0
  318. package/dist/runtime/stepMetadata.js.map +1 -0
  319. package/dist/runtime/taskQueue.d.ts +16 -0
  320. package/dist/runtime/taskQueue.d.ts.map +1 -0
  321. package/dist/runtime/taskQueue.js +103 -0
  322. package/dist/runtime/taskQueue.js.map +1 -0
  323. package/dist/runtime/telemetry.d.ts +6 -0
  324. package/dist/runtime/telemetry.d.ts.map +1 -0
  325. package/dist/runtime/telemetry.js +42 -0
  326. package/dist/runtime/telemetry.js.map +1 -0
  327. package/dist/runtime/telemetryHub.d.ts +61 -0
  328. package/dist/runtime/telemetryHub.d.ts.map +1 -0
  329. package/dist/runtime/telemetryHub.js +190 -0
  330. package/dist/runtime/telemetryHub.js.map +1 -0
  331. package/dist/runtime/textSanitizer.d.ts +4 -0
  332. package/dist/runtime/textSanitizer.d.ts.map +1 -0
  333. package/dist/runtime/textSanitizer.js +86 -0
  334. package/dist/runtime/textSanitizer.js.map +1 -0
  335. package/dist/runtime/typeCheckRunner.d.ts +33 -0
  336. package/dist/runtime/typeCheckRunner.d.ts.map +1 -0
  337. package/dist/runtime/typeCheckRunner.js +357 -0
  338. package/dist/runtime/typeCheckRunner.js.map +1 -0
  339. package/dist/runtime/types.d.ts +334 -0
  340. package/dist/runtime/types.d.ts.map +1 -0
  341. package/dist/runtime/types.js +3 -0
  342. package/dist/runtime/types.js.map +1 -0
  343. package/dist/runtime/typescriptValidator.d.ts +18 -0
  344. package/dist/runtime/typescriptValidator.d.ts.map +1 -0
  345. package/dist/runtime/typescriptValidator.js +363 -0
  346. package/dist/runtime/typescriptValidator.js.map +1 -0
  347. package/dist/runtime/undoManager.d.ts +7 -0
  348. package/dist/runtime/undoManager.d.ts.map +1 -0
  349. package/dist/runtime/undoManager.js +56 -0
  350. package/dist/runtime/undoManager.js.map +1 -0
  351. package/dist/runtime/validationController.d.ts +11 -0
  352. package/dist/runtime/validationController.d.ts.map +1 -0
  353. package/dist/runtime/validationController.js +29 -0
  354. package/dist/runtime/validationController.js.map +1 -0
  355. package/dist/runtime/validationUtils.d.ts +17 -0
  356. package/dist/runtime/validationUtils.d.ts.map +1 -0
  357. package/dist/runtime/validationUtils.js +121 -0
  358. package/dist/runtime/validationUtils.js.map +1 -0
  359. package/dist/runtime/workspaceAssertions.d.ts +21 -0
  360. package/dist/runtime/workspaceAssertions.d.ts.map +1 -0
  361. package/dist/runtime/workspaceAssertions.js +183 -0
  362. package/dist/runtime/workspaceAssertions.js.map +1 -0
  363. package/dist/runtime/workspaceIndexService.d.ts +24 -0
  364. package/dist/runtime/workspaceIndexService.d.ts.map +1 -0
  365. package/dist/runtime/workspaceIndexService.js +133 -0
  366. package/dist/runtime/workspaceIndexService.js.map +1 -0
  367. package/dist/runtime/workspaceIndexer.d.ts +21 -0
  368. package/dist/runtime/workspaceIndexer.d.ts.map +1 -0
  369. package/dist/runtime/workspaceIndexer.js +95 -0
  370. package/dist/runtime/workspaceIndexer.js.map +1 -0
  371. package/dist/runtime/workspacePackages.d.ts +22 -0
  372. package/dist/runtime/workspacePackages.d.ts.map +1 -0
  373. package/dist/runtime/workspacePackages.js +198 -0
  374. package/dist/runtime/workspacePackages.js.map +1 -0
  375. package/dist/runtime/workspaceRuntime.d.ts +58 -0
  376. package/dist/runtime/workspaceRuntime.d.ts.map +1 -0
  377. package/dist/runtime/workspaceRuntime.js +86 -0
  378. package/dist/runtime/workspaceRuntime.js.map +1 -0
  379. package/dist/runtime/workspaceService.d.ts +14 -0
  380. package/dist/runtime/workspaceService.d.ts.map +1 -0
  381. package/dist/runtime/workspaceService.js +88 -0
  382. package/dist/runtime/workspaceService.js.map +1 -0
  383. package/dist/runtime/workspaceServices.d.ts +114 -0
  384. package/dist/runtime/workspaceServices.d.ts.map +1 -0
  385. package/dist/runtime/workspaceServices.js +114 -0
  386. package/dist/runtime/workspaceServices.js.map +1 -0
  387. package/dist/runtime/writeServices.d.ts +34 -0
  388. package/dist/runtime/writeServices.d.ts.map +1 -0
  389. package/dist/runtime/writeServices.js +32 -0
  390. package/dist/runtime/writeServices.js.map +1 -0
  391. package/dist/sharedPromptSections.d.ts +58 -0
  392. package/dist/sharedPromptSections.d.ts.map +1 -0
  393. package/dist/sharedPromptSections.js +94 -0
  394. package/dist/sharedPromptSections.js.map +1 -0
  395. package/dist/statusTypes.d.ts +13 -0
  396. package/dist/statusTypes.d.ts.map +1 -0
  397. package/dist/statusTypes.js +3 -0
  398. package/dist/statusTypes.js.map +1 -0
  399. package/dist/streamIdleTimeout.d.ts +38 -0
  400. package/dist/streamIdleTimeout.d.ts.map +1 -0
  401. package/dist/streamIdleTimeout.js +44 -0
  402. package/dist/streamIdleTimeout.js.map +1 -0
  403. package/dist/types/bandit.d.ts +113 -0
  404. package/dist/types/bandit.d.ts.map +1 -0
  405. package/dist/types/bandit.js +3 -0
  406. package/dist/types/bandit.js.map +1 -0
  407. package/dist/types.d.ts +152 -0
  408. package/dist/types.d.ts.map +1 -0
  409. package/dist/types.js +3 -0
  410. package/dist/types.js.map +1 -0
  411. package/dist/workspaceIndex.d.ts +44 -0
  412. package/dist/workspaceIndex.d.ts.map +1 -0
  413. package/dist/workspaceIndex.js +258 -0
  414. package/dist/workspaceIndex.js.map +1 -0
  415. package/package.json +36 -0
@@ -0,0 +1,694 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || (function () {
19
+ var ownKeys = function(o) {
20
+ ownKeys = Object.getOwnPropertyNames || function (o) {
21
+ var ar = [];
22
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
+ return ar;
24
+ };
25
+ return ownKeys(o);
26
+ };
27
+ return function (mod) {
28
+ if (mod && mod.__esModule) return mod;
29
+ var result = {};
30
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
+ __setModuleDefault(result, mod);
32
+ return result;
33
+ };
34
+ })();
35
+ Object.defineProperty(exports, "__esModule", { value: true });
36
+ exports.createHelperManager = createHelperManager;
37
+ const path = __importStar(require("path"));
38
+ const ts = __importStar(require("typescript"));
39
+ const HELPER_RUNTIME_STORE = 'focus.helpers';
40
+ const HELPER_IMPORT_HINT_STORE = `${HELPER_RUNTIME_STORE}.importHints`;
41
+ const MAX_HELPER_IMPORT_HINTS = 12;
42
+ function createHelperManager(deps) {
43
+ return {
44
+ async validate(meta) {
45
+ const helperPath = meta.helperPath?.trim();
46
+ if (!helperPath) {
47
+ return { ok: false, error: 'Helper path unavailable for validation.' };
48
+ }
49
+ const workspaceRoot = deps.getWorkspaceRoot();
50
+ if (!workspaceRoot) {
51
+ return { ok: false, error: 'Workspace root unavailable for helper validation.' };
52
+ }
53
+ const absolute = path.join(workspaceRoot, helperPath);
54
+ const draftContent = meta.outputRef ? deps.getContextValue(meta.outputRef) : undefined;
55
+ let content = typeof draftContent === 'string' ? draftContent : '';
56
+ let loadedFrom;
57
+ if (content.trim().length > 0) {
58
+ loadedFrom = 'context';
59
+ }
60
+ else {
61
+ try {
62
+ const exists = await deps.fs.exists(absolute);
63
+ if (exists) {
64
+ content = await deps.fs.readText(absolute);
65
+ loadedFrom = 'workspace';
66
+ }
67
+ }
68
+ catch (error) {
69
+ const message = error instanceof Error ? error.message : String(error);
70
+ return { ok: false, error: `Unable to read helper file ${helperPath}: ${message}` };
71
+ }
72
+ }
73
+ if (!content || content.trim().length === 0) {
74
+ return { ok: false, error: `Helper content unavailable for validation: ${helperPath}` };
75
+ }
76
+ if (containsDiffMarkers(content)) {
77
+ return {
78
+ ok: false,
79
+ error: `Helper file ${helperPath} contains diff markers or multiple file outputs. Return only the helper file contents.`,
80
+ data: { helperPath }
81
+ };
82
+ }
83
+ if (containsConversationMarkers(content, deps.conversationMarkerPatterns)) {
84
+ return {
85
+ ok: false,
86
+ error: `Helper file ${helperPath} contains conversation markers like <start_of_turn>. Return only the helper file contents.`,
87
+ data: { helperPath }
88
+ };
89
+ }
90
+ if (!fileContainsExport(content)) {
91
+ return { ok: false, error: `Helper file ${helperPath} must export a component or function.` };
92
+ }
93
+ const syntaxValidation = validateHelperSyntax(content);
94
+ if (!syntaxValidation.ok) {
95
+ return {
96
+ ok: false,
97
+ error: syntaxValidation.error ?? `Syntax validation failed for ${helperPath}`,
98
+ data: { helperPath }
99
+ };
100
+ }
101
+ const helperExports = extractHelperExports(content);
102
+ if (usesJsx(content)) {
103
+ if (!helperExports.defaultName) {
104
+ return {
105
+ ok: false,
106
+ error: `Helper file ${helperPath} should use a default export for React components.`,
107
+ data: { helperPath }
108
+ };
109
+ }
110
+ if (hasImplicitAnyProps(content)) {
111
+ return {
112
+ ok: false,
113
+ error: `Helper file ${helperPath} must strongly type component props to avoid implicit any.`,
114
+ data: { helperPath }
115
+ };
116
+ }
117
+ }
118
+ const selfImport = findSelfImport(content, helperPath, deps.normalizeRelativePath);
119
+ if (selfImport) {
120
+ return {
121
+ ok: false,
122
+ error: `Helper file ${helperPath} imports itself via "${selfImport}". Remove the self-referencing import.`,
123
+ data: { helperPath }
124
+ };
125
+ }
126
+ const snippet = deps.clampSnippet(content.trim(), 1800);
127
+ const helperKey = (meta.helperId ?? helperPath).replace(/[^a-z0-9]/gi, '_');
128
+ deps.setContextValue(`${HELPER_RUNTIME_STORE}.${helperKey}.verified`, {
129
+ path: helperPath,
130
+ checkedAt: Date.now(),
131
+ exports: helperExports,
132
+ snippet,
133
+ source: loadedFrom ?? 'unknown',
134
+ typecheck: { ok: true }
135
+ });
136
+ return { ok: true };
137
+ },
138
+ async buildHelperGuidance(helperPath) {
139
+ if (!helperPath) {
140
+ return undefined;
141
+ }
142
+ await deps.ensureWorkspaceIndex().catch(() => undefined);
143
+ const callerPath = deps.getContextValue('focus.extract.sourcePath');
144
+ const callerContent = deps.getContextValue('focus.primary.content');
145
+ const projectRoot = inferProjectSourceRoot(helperPath) ?? inferProjectSourceRoot(callerPath);
146
+ let mappings = [];
147
+ if (callerPath && typeof callerContent === 'string' && callerContent.trim().length > 0) {
148
+ mappings = computeHelperImportMappings(helperPath, callerPath, callerContent, deps);
149
+ }
150
+ const sections = [
151
+ 'Path context for helper rewrite:',
152
+ `projectRoot: ${projectRoot ?? 'workspace root'}`,
153
+ `callerFilePath: ${callerPath ?? 'unknown'}`,
154
+ `targetFilePath: ${helperPath}`
155
+ ];
156
+ if (mappings.length > 0) {
157
+ storeHelperImportHints(helperPath, mappings, deps);
158
+ sections.push('validRelativeImports:');
159
+ sections.push(JSON.stringify(mappings, null, 2));
160
+ }
161
+ else {
162
+ sections.push('validRelativeImports: []');
163
+ }
164
+ sections.push('Rewrite every import to resolve from targetFilePath. Never copy caller-relative import specifiers without translating them.');
165
+ return sections.join('\n');
166
+ },
167
+ async buildCallerGuidance(meta, callerPath) {
168
+ const hints = collectHelperUsageHints(meta, callerPath, deps);
169
+ if (hints.length === 0) {
170
+ const additional = buildCallerPreservationHints(callerPath, deps);
171
+ return additional?.length ? additional.join('\n\n') : undefined;
172
+ }
173
+ const sections = [
174
+ 'Helper file(s) were extracted earlier. Import and invoke them directly instead of recreating their JSX or handlers.'
175
+ ];
176
+ hints.forEach((hint, index) => {
177
+ const parts = [
178
+ `${index + 1}. Helper path: ${hint.path}`,
179
+ `Import example: ${hint.importStatement}`
180
+ ];
181
+ if (hint.description) {
182
+ parts.push(hint.description);
183
+ }
184
+ if (hint.snippet) {
185
+ parts.push(['```tsx', hint.snippet.trim(), '```'].join('\n'));
186
+ }
187
+ sections.push(parts.join('\n'));
188
+ });
189
+ sections.push('Do not edit the helper files in this step — only update the caller to consume them.');
190
+ const preservationHints = buildCallerPreservationHints(callerPath, deps);
191
+ if (preservationHints.length > 0) {
192
+ sections.push(preservationHints.join('\n\n'));
193
+ }
194
+ return sections.join('\n\n');
195
+ },
196
+ applyImportHints(meta, content) {
197
+ if (!meta?.helperPath || !content) {
198
+ return content;
199
+ }
200
+ const key = normalizeHelperImportKey(meta.helperPath, deps);
201
+ if (!key) {
202
+ return content;
203
+ }
204
+ const hints = deps.getContextValue(`${HELPER_IMPORT_HINT_STORE}.${key}`);
205
+ if (!hints || hints.length === 0) {
206
+ return content;
207
+ }
208
+ let updated = content;
209
+ hints.forEach((hint) => {
210
+ const escaped = hint.fromCaller.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
211
+ const pattern = new RegExp(`from\\s+['"]${escaped}['"]`, 'g');
212
+ updated = updated.replace(pattern, `from '${hint.fromHelper}'`);
213
+ });
214
+ return updated;
215
+ },
216
+ async ensureChainReady(meta) {
217
+ const helperIds = meta.helperIds ?? [];
218
+ const helperPaths = meta.helperPaths ?? [];
219
+ if (!helperIds.length && !helperPaths.length) {
220
+ return { ok: true };
221
+ }
222
+ const workspaceRoot = deps.getWorkspaceRoot();
223
+ if (!workspaceRoot) {
224
+ return { ok: false, error: 'Workspace root unavailable.' };
225
+ }
226
+ const resolvedPaths = [];
227
+ for (const id of helperIds) {
228
+ const state = deps.getContextValue(`${HELPER_RUNTIME_STORE}.${id}.verified`);
229
+ if (state?.path) {
230
+ resolvedPaths.push(state.path);
231
+ }
232
+ }
233
+ helperPaths.forEach((helperPath) => {
234
+ if (helperPath && !resolvedPaths.includes(helperPath)) {
235
+ resolvedPaths.push(helperPath);
236
+ }
237
+ });
238
+ if (!resolvedPaths.length) {
239
+ return { ok: false, error: 'No helper paths available for caller preparation.' };
240
+ }
241
+ const missing = [];
242
+ for (const helperPath of resolvedPaths) {
243
+ const absolute = path.join(workspaceRoot, helperPath);
244
+ const exists = await deps.fs.exists(absolute);
245
+ if (!exists) {
246
+ missing.push(helperPath);
247
+ }
248
+ }
249
+ if (missing.length > 0) {
250
+ return { ok: false, error: `Helper files missing before caller update: ${missing.join(', ')}` };
251
+ }
252
+ return { ok: true };
253
+ }
254
+ };
255
+ }
256
+ function fileContainsExport(content) {
257
+ if (!content) {
258
+ return false;
259
+ }
260
+ const exportPattern = /\bexport\s+(?:default\s+)?(?:const|function|class|interface|type|enum)\b/;
261
+ return exportPattern.test(content);
262
+ }
263
+ function containsDiffMarkers(content) {
264
+ if (!content) {
265
+ return false;
266
+ }
267
+ const indicators = ['diff --git', '\n--- ', '\n+++ ', '\n@@', '\n// src/', '// src/'];
268
+ return indicators.some((indicator) => content.includes(indicator));
269
+ }
270
+ function containsConversationMarkers(content, patterns) {
271
+ if (!content) {
272
+ return false;
273
+ }
274
+ for (const regex of patterns) {
275
+ regex.lastIndex = 0;
276
+ if (regex.test(content)) {
277
+ return true;
278
+ }
279
+ }
280
+ return false;
281
+ }
282
+ function validateHelperSyntax(content) {
283
+ try {
284
+ const result = ts.transpileModule(content, {
285
+ compilerOptions: {
286
+ jsx: ts.JsxEmit.ReactJSX,
287
+ target: ts.ScriptTarget.ES2020,
288
+ module: ts.ModuleKind.ESNext,
289
+ allowJs: true
290
+ },
291
+ reportDiagnostics: true
292
+ });
293
+ const diagnostics = (result.diagnostics ?? []).filter((diagnostic) => diagnostic.category === ts.DiagnosticCategory.Error);
294
+ if (diagnostics.length === 0) {
295
+ return { ok: true };
296
+ }
297
+ const summary = diagnostics
298
+ .map((diagnostic) => {
299
+ const message = ts.flattenDiagnosticMessageText(diagnostic.messageText, ' ');
300
+ const line = diagnostic.file && diagnostic.start !== undefined
301
+ ? diagnostic.file.getLineAndCharacterOfPosition(diagnostic.start).line + 1
302
+ : undefined;
303
+ return line ? `line ${line}: ${message}` : message;
304
+ })
305
+ .slice(0, 3)
306
+ .join('; ');
307
+ return { ok: false, error: summary || 'Syntax errors detected.' };
308
+ }
309
+ catch (error) {
310
+ const message = error instanceof Error ? error.message : String(error);
311
+ return { ok: false, error: message };
312
+ }
313
+ }
314
+ function usesJsx(content) {
315
+ if (!content) {
316
+ return false;
317
+ }
318
+ const jsxPattern = /<[A-Za-z][\w:-]*(\s[^>]*>|>)/m;
319
+ return jsxPattern.test(content);
320
+ }
321
+ function hasImplicitAnyProps(content) {
322
+ if (!usesJsx(content)) {
323
+ return false;
324
+ }
325
+ const typedPropsPattern = /:\s*(?:React\.)?(?:FC|FunctionComponent)<[^>]+>/;
326
+ const typedDestructurePattern = /\(\s*{\s*[^}]+}\s*:\s*[^)]+\)/;
327
+ const typedParamPattern = /\(\s*[A-Za-z_$][\w$]*\s*:\s*[^)]+\)/;
328
+ if (typedPropsPattern.test(content)
329
+ || typedDestructurePattern.test(content)
330
+ || typedParamPattern.test(content)) {
331
+ return false;
332
+ }
333
+ const exportedUntypedPattern = /export\s+(?:default\s+)?(?:const|function)\s+[A-Za-z0-9_]+\s*(?:=\s*)?\(\s*(?:{[^}]+}|[A-Za-z_$][\w$]*)\s*\)/;
334
+ if (exportedUntypedPattern.test(content)) {
335
+ return true;
336
+ }
337
+ const defaultExportUntypedPattern = /const\s+[A-Za-z0-9_]+\s*=\s*\(\s*(?:{[^}]+}|[A-Za-z_$][\w$]*)\s*\)\s*=>/;
338
+ if (defaultExportUntypedPattern.test(content) && /export\s+default\s+[A-Za-z0-9_]+/.test(content)) {
339
+ return true;
340
+ }
341
+ return false;
342
+ }
343
+ function extractHelperExports(content) {
344
+ const metadata = { named: [] };
345
+ if (!content) {
346
+ return metadata;
347
+ }
348
+ const defaultPatterns = [
349
+ /export\s+default\s+function\s+([A-Za-z0-9_]+)/,
350
+ /export\s+default\s+class\s+([A-Za-z0-9_]+)/,
351
+ /export\s+default\s+([A-Za-z0-9_]+)/,
352
+ /export\s+default\s+const\s+([A-Za-z0-9_]+)/,
353
+ /export\s+default\s+let\s+([A-Za-z0-9_]+)/,
354
+ /export\s+default\s+var\s+([A-Za-z0-9_]+)/
355
+ ];
356
+ for (const pattern of defaultPatterns) {
357
+ const match = pattern.exec(content);
358
+ if (match && match[1]) {
359
+ metadata.defaultName = match[1];
360
+ break;
361
+ }
362
+ }
363
+ const namedPatterns = [
364
+ /export\s+(?:const|function|class|enum|interface|type)\s+([A-Za-z0-9_]+)/g,
365
+ /export\s+{([^}]+)}/g
366
+ ];
367
+ for (const pattern of namedPatterns) {
368
+ let match;
369
+ while ((match = pattern.exec(content)) !== null) {
370
+ if (!match[1]) {
371
+ continue;
372
+ }
373
+ if (pattern === namedPatterns[0]) {
374
+ metadata.named.push(match[1]);
375
+ continue;
376
+ }
377
+ const exports = match[1]
378
+ .split(',')
379
+ .map((entry) => entry.trim())
380
+ .filter(Boolean)
381
+ .map((entry) => entry.replace(/\s+as\s+.*/i, '').trim());
382
+ metadata.named.push(...exports);
383
+ }
384
+ }
385
+ const unique = Array.from(new Set(metadata.named.filter(Boolean)));
386
+ metadata.named = unique;
387
+ return metadata;
388
+ }
389
+ function findSelfImport(content, helperPath, normalizeRelativePath) {
390
+ if (!content || !helperPath) {
391
+ return undefined;
392
+ }
393
+ const normalizedPath = normalizeRelativePath(helperPath) ?? helperPath;
394
+ const normalizedPosix = normalizedPath.replace(/\\/g, '/');
395
+ const normalizedNoExt = normalizedPosix.replace(/\.[^.]+$/, '');
396
+ const helperDir = path.posix.dirname(normalizedPosix);
397
+ const specifiers = extractRelativeImportSpecifiers(content);
398
+ for (const specifier of specifiers) {
399
+ if (!specifier.startsWith('.')) {
400
+ continue;
401
+ }
402
+ const resolved = path.posix.normalize(path.posix.join(helperDir, specifier));
403
+ const resolvedNoExt = resolved.replace(/\.[^.]+$/, '');
404
+ if (resolved === normalizedPosix || resolvedNoExt === normalizedNoExt) {
405
+ return specifier;
406
+ }
407
+ }
408
+ return undefined;
409
+ }
410
+ function collectHelperUsageHints(meta, callerPath, deps) {
411
+ const hints = [];
412
+ const helperIds = meta.helperIds ?? [];
413
+ helperIds.forEach((id) => {
414
+ const state = deps.getContextValue(`${HELPER_RUNTIME_STORE}.${id}.verified`);
415
+ if (!state?.path) {
416
+ return;
417
+ }
418
+ const hint = buildHelperUsageHint(state, callerPath);
419
+ if (hint) {
420
+ hints.push(hint);
421
+ }
422
+ });
423
+ if (hints.length === 0 && meta.helperPaths?.length) {
424
+ meta.helperPaths.forEach((helperPath) => {
425
+ const fallbackState = { path: helperPath, checkedAt: Date.now(), snippet: undefined };
426
+ const hint = buildHelperUsageHint(fallbackState, callerPath);
427
+ if (hint) {
428
+ hints.push(hint);
429
+ }
430
+ });
431
+ }
432
+ return hints;
433
+ }
434
+ function computeHelperImportMappings(helperPath, callerPath, callerContent, deps) {
435
+ const helperDir = path.posix.dirname(helperPath);
436
+ const callerDir = path.posix.dirname(callerPath);
437
+ const specifiers = extractRelativeImportSpecifiers(callerContent);
438
+ const seen = new Set();
439
+ const mappings = [];
440
+ for (const specifier of specifiers) {
441
+ const resolved = path.posix.normalize(path.posix.join(callerDir, specifier));
442
+ const normalized = deps.normalizeRelativePath(resolved) ?? resolved.replace(/\\/g, '/');
443
+ if (!normalized) {
444
+ continue;
445
+ }
446
+ const workspaceTarget = deps.resolveWorkspaceImportTarget(normalized);
447
+ if (!workspaceTarget) {
448
+ continue;
449
+ }
450
+ const helperSpecifier = buildRelativeImportSpecifier(helperDir, workspaceTarget);
451
+ if (!helperSpecifier || helperSpecifier === specifier) {
452
+ continue;
453
+ }
454
+ const key = `${specifier}|${workspaceTarget.toLowerCase()}`;
455
+ if (seen.has(key)) {
456
+ continue;
457
+ }
458
+ seen.add(key);
459
+ mappings.push({
460
+ fromCaller: specifier,
461
+ fromHelper: helperSpecifier,
462
+ resolved: workspaceTarget
463
+ });
464
+ if (mappings.length >= MAX_HELPER_IMPORT_HINTS) {
465
+ break;
466
+ }
467
+ }
468
+ return mappings;
469
+ }
470
+ function extractRelativeImportSpecifiers(content) {
471
+ if (!content) {
472
+ return [];
473
+ }
474
+ const specifiers = new Set();
475
+ const importRegex = /import\s+(?:[\s\S]*?)\s+from\s+['"]([^'"]+)['"]/gi;
476
+ const exportRegex = /export\s+(?:{[\s\S]*?}|\*)\s+from\s+['"]([^'"]+)['"]/gi;
477
+ let match;
478
+ while ((match = importRegex.exec(content)) !== null) {
479
+ const spec = match[1]?.trim();
480
+ if (spec && spec.startsWith('.')) {
481
+ specifiers.add(spec);
482
+ }
483
+ }
484
+ while ((match = exportRegex.exec(content)) !== null) {
485
+ const spec = match[1]?.trim();
486
+ if (spec && spec.startsWith('.')) {
487
+ specifiers.add(spec);
488
+ }
489
+ }
490
+ return Array.from(specifiers);
491
+ }
492
+ function inferProjectSourceRoot(pathValue) {
493
+ if (!pathValue) {
494
+ return undefined;
495
+ }
496
+ const normalized = pathValue.replace(/\\/g, '/');
497
+ const srcIndex = normalized.indexOf('/src/');
498
+ if (srcIndex !== -1) {
499
+ return `${normalized.slice(0, srcIndex + 5)}`;
500
+ }
501
+ if (normalized.startsWith('src/')) {
502
+ return 'src/';
503
+ }
504
+ const segments = normalized.split('/');
505
+ if (segments.length >= 2) {
506
+ return `${segments[0]}/${segments[1]}/`;
507
+ }
508
+ if (segments.length === 1) {
509
+ return `${segments[0]}/`;
510
+ }
511
+ return undefined;
512
+ }
513
+ function buildHelperUsageHint(state, callerPath) {
514
+ if (!state.path) {
515
+ return undefined;
516
+ }
517
+ const importPath = buildRelativeImportPath(callerPath, state.path);
518
+ const defaultName = state.exports?.defaultName ?? deriveHelperNameFromPath(state.path);
519
+ const namedExports = (state.exports?.named ?? []).filter((name) => !state.exports?.defaultName || name !== state.exports.defaultName);
520
+ let importStatement;
521
+ if (state.exports?.defaultName) {
522
+ importStatement = `import ${state.exports.defaultName} from '${importPath}';`;
523
+ }
524
+ else if (namedExports.length > 0) {
525
+ importStatement = `import { ${namedExports.join(', ')} } from '${importPath}';`;
526
+ }
527
+ else {
528
+ importStatement = `import ${defaultName} from '${importPath}';`;
529
+ }
530
+ const description = namedExports.length
531
+ ? `Provides named exports: ${namedExports.join(', ')}.`
532
+ : `Default export: ${state.exports?.defaultName ?? defaultName}.`;
533
+ return {
534
+ path: state.path,
535
+ importStatement,
536
+ description,
537
+ snippet: state.snippet
538
+ };
539
+ }
540
+ function buildRelativeImportPath(fromPath, toPath) {
541
+ const fromDir = path.dirname(fromPath);
542
+ const relative = path.relative(fromDir, toPath).replace(/\\/g, '/');
543
+ const trimmed = relative.replace(/\.[^.]+$/, '');
544
+ if (!trimmed.startsWith('.')) {
545
+ return `./${trimmed}`;
546
+ }
547
+ return trimmed || './';
548
+ }
549
+ function deriveHelperNameFromPath(helperPath) {
550
+ const fileName = helperPath.split(/[\\/]/).pop() ?? 'Helper';
551
+ const base = fileName.replace(/\.[^.]+$/, '');
552
+ return base
553
+ .split(/[-_\s]/)
554
+ .filter(Boolean)
555
+ .map((segment) => segment.charAt(0).toUpperCase() + segment.slice(1))
556
+ .join('') || 'HelperComponent';
557
+ }
558
+ function storeHelperImportHints(helperPath, mappings, deps) {
559
+ if (!helperPath || !mappings.length) {
560
+ return;
561
+ }
562
+ const key = normalizeHelperImportKey(helperPath, deps);
563
+ if (!key) {
564
+ return;
565
+ }
566
+ deps.setContextValue(`${HELPER_IMPORT_HINT_STORE}.${key}`, mappings);
567
+ }
568
+ function normalizeHelperImportKey(helperPath, deps) {
569
+ const normalized = deps.normalizeRelativePath(helperPath) ?? helperPath;
570
+ if (!normalized) {
571
+ return undefined;
572
+ }
573
+ return normalized.toLowerCase().replace(/[^a-z0-9]+/g, '_');
574
+ }
575
+ function buildRelativeImportSpecifier(fromDir, targetPath) {
576
+ if (!fromDir) {
577
+ return undefined;
578
+ }
579
+ const relative = path.posix.relative(fromDir, targetPath).replace(/\\/g, '/');
580
+ if (!relative || relative === '.') {
581
+ return './';
582
+ }
583
+ return relative.startsWith('.') ? relative : `./${relative}`;
584
+ }
585
+ function buildCallerPreservationHints(callerPath, deps) {
586
+ const callerContent = deps.getContextValue('focus.primary.content');
587
+ if (!callerContent || callerContent.trim().length === 0) {
588
+ return [];
589
+ }
590
+ const bindings = parseImportBindings(callerContent);
591
+ const relativeHelpers = bindings.filter((entry) => entry.source.startsWith('.'));
592
+ const hints = [];
593
+ if (relativeHelpers.length > 0) {
594
+ const lines = ['Preserve existing helper imports from the caller instead of replacing them with new service calls:'];
595
+ relativeHelpers.forEach((entry) => {
596
+ if (entry.defaultName) {
597
+ lines.push(`- default ${entry.defaultName} from '${entry.source}'`);
598
+ }
599
+ if (entry.named.length > 0) {
600
+ lines.push(`- { ${entry.named.join(', ')} } from '${entry.source}'`);
601
+ }
602
+ if (entry.namespace) {
603
+ lines.push(`- * as ${entry.namespace} from '${entry.source}'`);
604
+ }
605
+ });
606
+ hints.push(lines.join('\n'));
607
+ }
608
+ const serviceImports = bindings.filter((entry) => entry.defaultName && /\/services\//.test(entry.source));
609
+ serviceImports.forEach((entry) => {
610
+ if (!entry.defaultName) {
611
+ return;
612
+ }
613
+ const methods = extractMemberAccesses(callerContent, entry.defaultName);
614
+ if (methods.length === 0) {
615
+ return;
616
+ }
617
+ hints.push(`Only use existing ${entry.defaultName} methods already present in the caller: ${methods.join(', ')}. Do not invent new methods.`);
618
+ });
619
+ return hints;
620
+ }
621
+ function parseImportBindings(content) {
622
+ if (!content) {
623
+ return [];
624
+ }
625
+ const bindings = [];
626
+ const importRegex = /import\s+([\s\S]*?)\s+from\s+['"]([^'"]+)['"]/gi;
627
+ let match;
628
+ while ((match = importRegex.exec(content)) !== null) {
629
+ const clause = match[1]?.trim();
630
+ const source = match[2]?.trim();
631
+ if (!clause || !source) {
632
+ continue;
633
+ }
634
+ const parsed = parseImportClause(clause);
635
+ bindings.push({
636
+ source,
637
+ defaultName: parsed.defaultName,
638
+ named: parsed.named,
639
+ namespace: parsed.namespace
640
+ });
641
+ }
642
+ return bindings;
643
+ }
644
+ function parseImportClause(clause) {
645
+ const cleaned = clause.replace(/^type\s+/, '').trim();
646
+ const result = { defaultName: undefined, named: [], namespace: undefined };
647
+ if (cleaned.startsWith('{')) {
648
+ result.named = parseNamedBindings(cleaned);
649
+ return result;
650
+ }
651
+ if (cleaned.startsWith('*')) {
652
+ const nsMatch = cleaned.match(/\*\s+as\s+([A-Za-z0-9_$]+)/);
653
+ if (nsMatch?.[1]) {
654
+ result.namespace = nsMatch[1];
655
+ }
656
+ return result;
657
+ }
658
+ const braceIndex = cleaned.indexOf('{');
659
+ if (braceIndex !== -1) {
660
+ result.defaultName = cleaned.slice(0, braceIndex).replace(/,\s*$/, '').trim() || undefined;
661
+ const namedPart = cleaned.slice(braceIndex);
662
+ result.named = parseNamedBindings(namedPart);
663
+ return result;
664
+ }
665
+ result.defaultName = cleaned || undefined;
666
+ return result;
667
+ }
668
+ function parseNamedBindings(namedPart) {
669
+ const inner = namedPart.replace(/[{}]/g, '');
670
+ return inner
671
+ .split(',')
672
+ .map((entry) => entry.trim())
673
+ .filter(Boolean)
674
+ .map((entry) => entry.replace(/^type\s+/, '').split(/\s+as\s+/i)[0].trim())
675
+ .filter(Boolean);
676
+ }
677
+ function extractMemberAccesses(content, identifier) {
678
+ if (!content || !identifier) {
679
+ return [];
680
+ }
681
+ const pattern = new RegExp(`\\b${escapeRegex(identifier)}\\.([A-Za-z0-9_$]+)\\b`, 'g');
682
+ const methods = new Set();
683
+ let match;
684
+ while ((match = pattern.exec(content)) !== null) {
685
+ if (match[1]) {
686
+ methods.add(match[1]);
687
+ }
688
+ }
689
+ return Array.from(methods).slice(0, 12);
690
+ }
691
+ function escapeRegex(value) {
692
+ return value.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
693
+ }
694
+ //# sourceMappingURL=helpers.js.map