@amsterdamdatalabs/enact-factory 0.1.1

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 (644) hide show
  1. package/LICENSE +674 -0
  2. package/README.md +566 -0
  3. package/dist/adapters/agenticLoop.d.ts +90 -0
  4. package/dist/adapters/agenticLoop.d.ts.map +1 -0
  5. package/dist/adapters/agenticLoop.js +219 -0
  6. package/dist/adapters/agenticLoop.js.map +1 -0
  7. package/dist/adapters/base.d.ts +16 -0
  8. package/dist/adapters/base.d.ts.map +1 -0
  9. package/dist/adapters/base.js +135 -0
  10. package/dist/adapters/base.js.map +1 -0
  11. package/dist/adapters/claude.d.ts +13 -0
  12. package/dist/adapters/claude.d.ts.map +1 -0
  13. package/dist/adapters/claude.js +318 -0
  14. package/dist/adapters/claude.js.map +1 -0
  15. package/dist/adapters/codex.d.ts +14 -0
  16. package/dist/adapters/codex.d.ts.map +1 -0
  17. package/dist/adapters/codex.js +366 -0
  18. package/dist/adapters/codex.js.map +1 -0
  19. package/dist/adapters/cryptoQuantAdapter.d.ts +85 -0
  20. package/dist/adapters/cryptoQuantAdapter.d.ts.map +1 -0
  21. package/dist/adapters/cryptoQuantAdapter.js +238 -0
  22. package/dist/adapters/cryptoQuantAdapter.js.map +1 -0
  23. package/dist/adapters/cursor.d.ts +13 -0
  24. package/dist/adapters/cursor.d.ts.map +1 -0
  25. package/dist/adapters/cursor.js +300 -0
  26. package/dist/adapters/cursor.js.map +1 -0
  27. package/dist/adapters/envPath.d.ts +20 -0
  28. package/dist/adapters/envPath.d.ts.map +1 -0
  29. package/dist/adapters/envPath.js +49 -0
  30. package/dist/adapters/envPath.js.map +1 -0
  31. package/dist/adapters/hermes.d.ts +13 -0
  32. package/dist/adapters/hermes.d.ts.map +1 -0
  33. package/dist/adapters/hermes.js +283 -0
  34. package/dist/adapters/hermes.js.map +1 -0
  35. package/dist/adapters/index.d.ts +18 -0
  36. package/dist/adapters/index.d.ts.map +1 -0
  37. package/dist/adapters/index.js +56 -0
  38. package/dist/adapters/index.js.map +1 -0
  39. package/dist/adapters/opencode.d.ts +13 -0
  40. package/dist/adapters/opencode.d.ts.map +1 -0
  41. package/dist/adapters/opencode.js +282 -0
  42. package/dist/adapters/opencode.js.map +1 -0
  43. package/dist/adapters/processRegistry.d.ts +38 -0
  44. package/dist/adapters/processRegistry.d.ts.map +1 -0
  45. package/dist/adapters/processRegistry.js +147 -0
  46. package/dist/adapters/processRegistry.js.map +1 -0
  47. package/dist/adapters/responses.d.ts +16 -0
  48. package/dist/adapters/responses.d.ts.map +1 -0
  49. package/dist/adapters/responses.js +244 -0
  50. package/dist/adapters/responses.js.map +1 -0
  51. package/dist/adapters/streamBuffer.d.ts +59 -0
  52. package/dist/adapters/streamBuffer.d.ts.map +1 -0
  53. package/dist/adapters/streamBuffer.js +123 -0
  54. package/dist/adapters/streamBuffer.js.map +1 -0
  55. package/dist/adapters/tools.d.ts +30 -0
  56. package/dist/adapters/tools.d.ts.map +1 -0
  57. package/dist/adapters/tools.js +219 -0
  58. package/dist/adapters/tools.js.map +1 -0
  59. package/dist/adapters/types.d.ts +82 -0
  60. package/dist/adapters/types.d.ts.map +1 -0
  61. package/dist/adapters/types.js +6 -0
  62. package/dist/adapters/types.js.map +1 -0
  63. package/dist/agents/agentBus.d.ts +160 -0
  64. package/dist/agents/agentBus.d.ts.map +1 -0
  65. package/dist/agents/agentBus.js +350 -0
  66. package/dist/agents/agentBus.js.map +1 -0
  67. package/dist/agents/agentPair.d.ts +215 -0
  68. package/dist/agents/agentPair.d.ts.map +1 -0
  69. package/dist/agents/agentPair.js +456 -0
  70. package/dist/agents/agentPair.js.map +1 -0
  71. package/dist/agents/auditor.d.ts +27 -0
  72. package/dist/agents/auditor.d.ts.map +1 -0
  73. package/dist/agents/auditor.js +238 -0
  74. package/dist/agents/auditor.js.map +1 -0
  75. package/dist/agents/cliStreamParser.d.ts +18 -0
  76. package/dist/agents/cliStreamParser.d.ts.map +1 -0
  77. package/dist/agents/cliStreamParser.js +156 -0
  78. package/dist/agents/cliStreamParser.js.map +1 -0
  79. package/dist/agents/documenter.d.ts +31 -0
  80. package/dist/agents/documenter.d.ts.map +1 -0
  81. package/dist/agents/documenter.js +286 -0
  82. package/dist/agents/documenter.js.map +1 -0
  83. package/dist/agents/draftAnalyzer.d.ts +50 -0
  84. package/dist/agents/draftAnalyzer.d.ts.map +1 -0
  85. package/dist/agents/draftAnalyzer.js +289 -0
  86. package/dist/agents/draftAnalyzer.js.map +1 -0
  87. package/dist/agents/evaluator.d.ts +61 -0
  88. package/dist/agents/evaluator.d.ts.map +1 -0
  89. package/dist/agents/evaluator.js +338 -0
  90. package/dist/agents/evaluator.js.map +1 -0
  91. package/dist/agents/executor.d.ts +33 -0
  92. package/dist/agents/executor.d.ts.map +1 -0
  93. package/dist/agents/executor.js +130 -0
  94. package/dist/agents/executor.js.map +1 -0
  95. package/dist/agents/index.d.ts +10 -0
  96. package/dist/agents/index.d.ts.map +1 -0
  97. package/dist/agents/index.js +10 -0
  98. package/dist/agents/index.js.map +1 -0
  99. package/dist/agents/pairMetrics.d.ts +63 -0
  100. package/dist/agents/pairMetrics.d.ts.map +1 -0
  101. package/dist/agents/pairMetrics.js +232 -0
  102. package/dist/agents/pairMetrics.js.map +1 -0
  103. package/dist/agents/pairPipeline.d.ts +184 -0
  104. package/dist/agents/pairPipeline.d.ts.map +1 -0
  105. package/dist/agents/pairPipeline.js +934 -0
  106. package/dist/agents/pairPipeline.js.map +1 -0
  107. package/dist/agents/pairWebhook.d.ts +59 -0
  108. package/dist/agents/pairWebhook.d.ts.map +1 -0
  109. package/dist/agents/pairWebhook.js +242 -0
  110. package/dist/agents/pairWebhook.js.map +1 -0
  111. package/dist/agents/pipelineFormat.d.ts +8 -0
  112. package/dist/agents/pipelineFormat.d.ts.map +1 -0
  113. package/dist/agents/pipelineFormat.js +65 -0
  114. package/dist/agents/pipelineFormat.js.map +1 -0
  115. package/dist/agents/pipelineGuards.d.ts +23 -0
  116. package/dist/agents/pipelineGuards.d.ts.map +1 -0
  117. package/dist/agents/pipelineGuards.js +257 -0
  118. package/dist/agents/pipelineGuards.js.map +1 -0
  119. package/dist/agents/reviewer.d.ts +37 -0
  120. package/dist/agents/reviewer.d.ts.map +1 -0
  121. package/dist/agents/reviewer.js +214 -0
  122. package/dist/agents/reviewer.js.map +1 -0
  123. package/dist/agents/skillDocumenter.d.ts +23 -0
  124. package/dist/agents/skillDocumenter.d.ts.map +1 -0
  125. package/dist/agents/skillDocumenter.js +219 -0
  126. package/dist/agents/skillDocumenter.js.map +1 -0
  127. package/dist/agents/tester.d.ts +37 -0
  128. package/dist/agents/tester.d.ts.map +1 -0
  129. package/dist/agents/tester.js +309 -0
  130. package/dist/agents/tester.js.map +1 -0
  131. package/dist/automation/autonomousRunner.d.ts +145 -0
  132. package/dist/automation/autonomousRunner.d.ts.map +1 -0
  133. package/dist/automation/autonomousRunner.js +1272 -0
  134. package/dist/automation/autonomousRunner.js.map +1 -0
  135. package/dist/automation/dailyReporter.d.ts +26 -0
  136. package/dist/automation/dailyReporter.d.ts.map +1 -0
  137. package/dist/automation/dailyReporter.js +130 -0
  138. package/dist/automation/dailyReporter.js.map +1 -0
  139. package/dist/automation/index.d.ts +5 -0
  140. package/dist/automation/index.d.ts.map +1 -0
  141. package/dist/automation/index.js +5 -0
  142. package/dist/automation/index.js.map +1 -0
  143. package/dist/automation/longRunningMonitor.d.ts +26 -0
  144. package/dist/automation/longRunningMonitor.d.ts.map +1 -0
  145. package/dist/automation/longRunningMonitor.js +356 -0
  146. package/dist/automation/longRunningMonitor.js.map +1 -0
  147. package/dist/automation/prOwnership.d.ts +18 -0
  148. package/dist/automation/prOwnership.d.ts.map +1 -0
  149. package/dist/automation/prOwnership.js +61 -0
  150. package/dist/automation/prOwnership.js.map +1 -0
  151. package/dist/automation/runnerExecution.d.ts +57 -0
  152. package/dist/automation/runnerExecution.d.ts.map +1 -0
  153. package/dist/automation/runnerExecution.js +701 -0
  154. package/dist/automation/runnerExecution.js.map +1 -0
  155. package/dist/automation/runnerState.d.ts +170 -0
  156. package/dist/automation/runnerState.d.ts.map +1 -0
  157. package/dist/automation/runnerState.js +496 -0
  158. package/dist/automation/runnerState.js.map +1 -0
  159. package/dist/automation/runnerTypes.d.ts +57 -0
  160. package/dist/automation/runnerTypes.d.ts.map +1 -0
  161. package/dist/automation/runnerTypes.js +5 -0
  162. package/dist/automation/runnerTypes.js.map +1 -0
  163. package/dist/automation/scheduler.d.ts +75 -0
  164. package/dist/automation/scheduler.d.ts.map +1 -0
  165. package/dist/automation/scheduler.js +402 -0
  166. package/dist/automation/scheduler.js.map +1 -0
  167. package/dist/azdo/azdo.d.ts +70 -0
  168. package/dist/azdo/azdo.d.ts.map +1 -0
  169. package/dist/azdo/azdo.js +328 -0
  170. package/dist/azdo/azdo.js.map +1 -0
  171. package/dist/azdo/index.d.ts +3 -0
  172. package/dist/azdo/index.d.ts.map +1 -0
  173. package/dist/azdo/index.js +3 -0
  174. package/dist/azdo/index.js.map +1 -0
  175. package/dist/azdo/projectUpdater.d.ts +13 -0
  176. package/dist/azdo/projectUpdater.d.ts.map +1 -0
  177. package/dist/azdo/projectUpdater.js +155 -0
  178. package/dist/azdo/projectUpdater.js.map +1 -0
  179. package/dist/azureDevOps/client.d.ts +75 -0
  180. package/dist/azureDevOps/client.d.ts.map +1 -0
  181. package/dist/azureDevOps/client.js +150 -0
  182. package/dist/azureDevOps/client.js.map +1 -0
  183. package/dist/azureDevOps/hierarchy.d.ts +119 -0
  184. package/dist/azureDevOps/hierarchy.d.ts.map +1 -0
  185. package/dist/azureDevOps/hierarchy.js +470 -0
  186. package/dist/azureDevOps/hierarchy.js.map +1 -0
  187. package/dist/azureDevOps/mapper.d.ts +101 -0
  188. package/dist/azureDevOps/mapper.d.ts.map +1 -0
  189. package/dist/azureDevOps/mapper.js +438 -0
  190. package/dist/azureDevOps/mapper.js.map +1 -0
  191. package/dist/azureDevOps/stateMapping.d.ts +15 -0
  192. package/dist/azureDevOps/stateMapping.d.ts.map +1 -0
  193. package/dist/azureDevOps/stateMapping.js +141 -0
  194. package/dist/azureDevOps/stateMapping.js.map +1 -0
  195. package/dist/cli/authHandler.d.ts +13 -0
  196. package/dist/cli/authHandler.d.ts.map +1 -0
  197. package/dist/cli/authHandler.js +70 -0
  198. package/dist/cli/authHandler.js.map +1 -0
  199. package/dist/cli/checkHandler.d.ts +27 -0
  200. package/dist/cli/checkHandler.d.ts.map +1 -0
  201. package/dist/cli/checkHandler.js +560 -0
  202. package/dist/cli/checkHandler.js.map +1 -0
  203. package/dist/cli/daemon.d.ts +30 -0
  204. package/dist/cli/daemon.d.ts.map +1 -0
  205. package/dist/cli/daemon.js +141 -0
  206. package/dist/cli/daemon.js.map +1 -0
  207. package/dist/cli/factoryCommands.d.ts +3 -0
  208. package/dist/cli/factoryCommands.d.ts.map +1 -0
  209. package/dist/cli/factoryCommands.js +165 -0
  210. package/dist/cli/factoryCommands.js.map +1 -0
  211. package/dist/cli/promptHandler.d.ts +13 -0
  212. package/dist/cli/promptHandler.d.ts.map +1 -0
  213. package/dist/cli/promptHandler.js +193 -0
  214. package/dist/cli/promptHandler.js.map +1 -0
  215. package/dist/cli.d.ts +3 -0
  216. package/dist/cli.d.ts.map +1 -0
  217. package/dist/cli.js +320 -0
  218. package/dist/cli.js.map +1 -0
  219. package/dist/core/agentLifecycle.d.ts +322 -0
  220. package/dist/core/agentLifecycle.d.ts.map +1 -0
  221. package/dist/core/agentLifecycle.js +230 -0
  222. package/dist/core/agentLifecycle.js.map +1 -0
  223. package/dist/core/areaMapping.d.ts +9 -0
  224. package/dist/core/areaMapping.d.ts.map +1 -0
  225. package/dist/core/areaMapping.js +37 -0
  226. package/dist/core/areaMapping.js.map +1 -0
  227. package/dist/core/config.d.ts +469 -0
  228. package/dist/core/config.d.ts.map +1 -0
  229. package/dist/core/config.js +780 -0
  230. package/dist/core/config.js.map +1 -0
  231. package/dist/core/dashboardContract.d.ts +204 -0
  232. package/dist/core/dashboardContract.d.ts.map +1 -0
  233. package/dist/core/dashboardContract.js +205 -0
  234. package/dist/core/dashboardContract.js.map +1 -0
  235. package/dist/core/devopsModel.d.ts +138 -0
  236. package/dist/core/devopsModel.d.ts.map +1 -0
  237. package/dist/core/devopsModel.js +137 -0
  238. package/dist/core/devopsModel.js.map +1 -0
  239. package/dist/core/envFile.d.ts +11 -0
  240. package/dist/core/envFile.d.ts.map +1 -0
  241. package/dist/core/envFile.js +104 -0
  242. package/dist/core/envFile.js.map +1 -0
  243. package/dist/core/eventHub.d.ts +220 -0
  244. package/dist/core/eventHub.d.ts.map +1 -0
  245. package/dist/core/eventHub.js +136 -0
  246. package/dist/core/eventHub.js.map +1 -0
  247. package/dist/core/index.d.ts +8 -0
  248. package/dist/core/index.d.ts.map +1 -0
  249. package/dist/core/index.js +7 -0
  250. package/dist/core/index.js.map +1 -0
  251. package/dist/core/laneExecutionState.d.ts +29 -0
  252. package/dist/core/laneExecutionState.d.ts.map +1 -0
  253. package/dist/core/laneExecutionState.js +18 -0
  254. package/dist/core/laneExecutionState.js.map +1 -0
  255. package/dist/core/laneStatus.d.ts +49 -0
  256. package/dist/core/laneStatus.d.ts.map +1 -0
  257. package/dist/core/laneStatus.js +153 -0
  258. package/dist/core/laneStatus.js.map +1 -0
  259. package/dist/core/prSidecar.d.ts +96 -0
  260. package/dist/core/prSidecar.d.ts.map +1 -0
  261. package/dist/core/prSidecar.js +33 -0
  262. package/dist/core/prSidecar.js.map +1 -0
  263. package/dist/core/runtimeConfig.d.ts +6 -0
  264. package/dist/core/runtimeConfig.d.ts.map +1 -0
  265. package/dist/core/runtimeConfig.js +24 -0
  266. package/dist/core/runtimeConfig.js.map +1 -0
  267. package/dist/core/scmProvider.d.ts +19 -0
  268. package/dist/core/scmProvider.d.ts.map +1 -0
  269. package/dist/core/scmProvider.js +38 -0
  270. package/dist/core/scmProvider.js.map +1 -0
  271. package/dist/core/service.d.ts +10 -0
  272. package/dist/core/service.d.ts.map +1 -0
  273. package/dist/core/service.js +297 -0
  274. package/dist/core/service.js.map +1 -0
  275. package/dist/core/traceCollector.d.ts +105 -0
  276. package/dist/core/traceCollector.d.ts.map +1 -0
  277. package/dist/core/traceCollector.js +141 -0
  278. package/dist/core/traceCollector.js.map +1 -0
  279. package/dist/core/types.d.ts +432 -0
  280. package/dist/core/types.d.ts.map +1 -0
  281. package/dist/core/types.js +2 -0
  282. package/dist/core/types.js.map +1 -0
  283. package/dist/core/workItemMapper.d.ts +39 -0
  284. package/dist/core/workItemMapper.d.ts.map +1 -0
  285. package/dist/core/workItemMapper.js +427 -0
  286. package/dist/core/workItemMapper.js.map +1 -0
  287. package/dist/core/workItemModel.d.ts +120 -0
  288. package/dist/core/workItemModel.d.ts.map +1 -0
  289. package/dist/core/workItemModel.js +104 -0
  290. package/dist/core/workItemModel.js.map +1 -0
  291. package/dist/core/workItemPayload.d.ts +195 -0
  292. package/dist/core/workItemPayload.d.ts.map +1 -0
  293. package/dist/core/workItemPayload.js +24 -0
  294. package/dist/core/workItemPayload.js.map +1 -0
  295. package/dist/core/workspaceConfig.d.ts +57 -0
  296. package/dist/core/workspaceConfig.d.ts.map +1 -0
  297. package/dist/core/workspaceConfig.js +184 -0
  298. package/dist/core/workspaceConfig.js.map +1 -0
  299. package/dist/doctor.d.ts +18 -0
  300. package/dist/doctor.d.ts.map +1 -0
  301. package/dist/doctor.js +34 -0
  302. package/dist/doctor.js.map +1 -0
  303. package/dist/factory/activeSkill.d.ts +11 -0
  304. package/dist/factory/activeSkill.d.ts.map +1 -0
  305. package/dist/factory/activeSkill.js +44 -0
  306. package/dist/factory/activeSkill.js.map +1 -0
  307. package/dist/factory/assignment.d.ts +54 -0
  308. package/dist/factory/assignment.d.ts.map +1 -0
  309. package/dist/factory/assignment.js +94 -0
  310. package/dist/factory/assignment.js.map +1 -0
  311. package/dist/factory/auditLog.d.ts +10 -0
  312. package/dist/factory/auditLog.d.ts.map +1 -0
  313. package/dist/factory/auditLog.js +38 -0
  314. package/dist/factory/auditLog.js.map +1 -0
  315. package/dist/factory/closureRequirements.d.ts +12 -0
  316. package/dist/factory/closureRequirements.d.ts.map +1 -0
  317. package/dist/factory/closureRequirements.js +30 -0
  318. package/dist/factory/closureRequirements.js.map +1 -0
  319. package/dist/factory/delegationPrompt.d.ts +3 -0
  320. package/dist/factory/delegationPrompt.d.ts.map +1 -0
  321. package/dist/factory/delegationPrompt.js +16 -0
  322. package/dist/factory/delegationPrompt.js.map +1 -0
  323. package/dist/factory/http.d.ts +3 -0
  324. package/dist/factory/http.d.ts.map +1 -0
  325. package/dist/factory/http.js +555 -0
  326. package/dist/factory/http.js.map +1 -0
  327. package/dist/factory/lifecyclePushMap.d.ts +4 -0
  328. package/dist/factory/lifecyclePushMap.d.ts.map +1 -0
  329. package/dist/factory/lifecyclePushMap.js +7 -0
  330. package/dist/factory/lifecyclePushMap.js.map +1 -0
  331. package/dist/factory/missions.d.ts +125 -0
  332. package/dist/factory/missions.d.ts.map +1 -0
  333. package/dist/factory/missions.js +304 -0
  334. package/dist/factory/missions.js.map +1 -0
  335. package/dist/factory/mode.d.ts +9 -0
  336. package/dist/factory/mode.d.ts.map +1 -0
  337. package/dist/factory/mode.js +30 -0
  338. package/dist/factory/mode.js.map +1 -0
  339. package/dist/factory/operatorActiveSkill.d.ts +15 -0
  340. package/dist/factory/operatorActiveSkill.d.ts.map +1 -0
  341. package/dist/factory/operatorActiveSkill.js +95 -0
  342. package/dist/factory/operatorActiveSkill.js.map +1 -0
  343. package/dist/factory/paseoDispatcher.d.ts +52 -0
  344. package/dist/factory/paseoDispatcher.d.ts.map +1 -0
  345. package/dist/factory/paseoDispatcher.js +122 -0
  346. package/dist/factory/paseoDispatcher.js.map +1 -0
  347. package/dist/factory/paseoLifecycle.d.ts +32 -0
  348. package/dist/factory/paseoLifecycle.d.ts.map +1 -0
  349. package/dist/factory/paseoLifecycle.js +260 -0
  350. package/dist/factory/paseoLifecycle.js.map +1 -0
  351. package/dist/factory/paths.d.ts +31 -0
  352. package/dist/factory/paths.d.ts.map +1 -0
  353. package/dist/factory/paths.js +139 -0
  354. package/dist/factory/paths.js.map +1 -0
  355. package/dist/factory/progressWatchdog.d.ts +58 -0
  356. package/dist/factory/progressWatchdog.d.ts.map +1 -0
  357. package/dist/factory/progressWatchdog.js +160 -0
  358. package/dist/factory/progressWatchdog.js.map +1 -0
  359. package/dist/factory/roster.d.ts +59 -0
  360. package/dist/factory/roster.d.ts.map +1 -0
  361. package/dist/factory/roster.js +116 -0
  362. package/dist/factory/roster.js.map +1 -0
  363. package/dist/factory/runtime.d.ts +44 -0
  364. package/dist/factory/runtime.d.ts.map +1 -0
  365. package/dist/factory/runtime.js +238 -0
  366. package/dist/factory/runtime.js.map +1 -0
  367. package/dist/factory/sync.d.ts +29 -0
  368. package/dist/factory/sync.d.ts.map +1 -0
  369. package/dist/factory/sync.js +77 -0
  370. package/dist/factory/sync.js.map +1 -0
  371. package/dist/factory/workitemQueues.d.ts +37 -0
  372. package/dist/factory/workitemQueues.d.ts.map +1 -0
  373. package/dist/factory/workitemQueues.js +99 -0
  374. package/dist/factory/workitemQueues.js.map +1 -0
  375. package/dist/factory/workitemTriage.d.ts +9 -0
  376. package/dist/factory/workitemTriage.d.ts.map +1 -0
  377. package/dist/factory/workitemTriage.js +81 -0
  378. package/dist/factory/workitemTriage.js.map +1 -0
  379. package/dist/hooks.d.ts +18 -0
  380. package/dist/hooks.d.ts.map +1 -0
  381. package/dist/hooks.js +96 -0
  382. package/dist/hooks.js.map +1 -0
  383. package/dist/index.d.ts +3 -0
  384. package/dist/index.d.ts.map +1 -0
  385. package/dist/index.js +90 -0
  386. package/dist/index.js.map +1 -0
  387. package/dist/install/agentCatalog.d.ts +7 -0
  388. package/dist/install/agentCatalog.d.ts.map +1 -0
  389. package/dist/install/agentCatalog.js +28 -0
  390. package/dist/install/agentCatalog.js.map +1 -0
  391. package/dist/install/bundlePaths.d.ts +10 -0
  392. package/dist/install/bundlePaths.d.ts.map +1 -0
  393. package/dist/install/bundlePaths.js +30 -0
  394. package/dist/install/bundlePaths.js.map +1 -0
  395. package/dist/install/codex.d.ts +43 -0
  396. package/dist/install/codex.d.ts.map +1 -0
  397. package/dist/install/codex.js +207 -0
  398. package/dist/install/codex.js.map +1 -0
  399. package/dist/install/enactHome.d.ts +37 -0
  400. package/dist/install/enactHome.d.ts.map +1 -0
  401. package/dist/install/enactHome.js +152 -0
  402. package/dist/install/enactHome.js.map +1 -0
  403. package/dist/install/plugins.d.ts +115 -0
  404. package/dist/install/plugins.d.ts.map +1 -0
  405. package/dist/install/plugins.js +259 -0
  406. package/dist/install/plugins.js.map +1 -0
  407. package/dist/install/setup.d.ts +33 -0
  408. package/dist/install/setup.d.ts.map +1 -0
  409. package/dist/install/setup.js +167 -0
  410. package/dist/install/setup.js.map +1 -0
  411. package/dist/locale/en.d.ts +3 -0
  412. package/dist/locale/en.d.ts.map +1 -0
  413. package/dist/locale/en.js +435 -0
  414. package/dist/locale/en.js.map +1 -0
  415. package/dist/locale/index.d.ts +28 -0
  416. package/dist/locale/index.d.ts.map +1 -0
  417. package/dist/locale/index.js +84 -0
  418. package/dist/locale/index.js.map +1 -0
  419. package/dist/locale/prompts/en.d.ts +3 -0
  420. package/dist/locale/prompts/en.d.ts.map +1 -0
  421. package/dist/locale/prompts/en.js +254 -0
  422. package/dist/locale/prompts/en.js.map +1 -0
  423. package/dist/locale/types.d.ts +433 -0
  424. package/dist/locale/types.d.ts.map +1 -0
  425. package/dist/locale/types.js +5 -0
  426. package/dist/locale/types.js.map +1 -0
  427. package/dist/mcp/server.d.ts +489 -0
  428. package/dist/mcp/server.d.ts.map +1 -0
  429. package/dist/mcp/server.js +597 -0
  430. package/dist/mcp/server.js.map +1 -0
  431. package/dist/orchestration/decisionEngine.d.ts +175 -0
  432. package/dist/orchestration/decisionEngine.d.ts.map +1 -0
  433. package/dist/orchestration/decisionEngine.js +471 -0
  434. package/dist/orchestration/decisionEngine.js.map +1 -0
  435. package/dist/orchestration/index.d.ts +5 -0
  436. package/dist/orchestration/index.d.ts.map +1 -0
  437. package/dist/orchestration/index.js +5 -0
  438. package/dist/orchestration/index.js.map +1 -0
  439. package/dist/orchestration/workItemParser.d.ts +67 -0
  440. package/dist/orchestration/workItemParser.d.ts.map +1 -0
  441. package/dist/orchestration/workItemParser.js +560 -0
  442. package/dist/orchestration/workItemParser.js.map +1 -0
  443. package/dist/orchestration/workItemScheduler.d.ts +141 -0
  444. package/dist/orchestration/workItemScheduler.d.ts.map +1 -0
  445. package/dist/orchestration/workItemScheduler.js +317 -0
  446. package/dist/orchestration/workItemScheduler.js.map +1 -0
  447. package/dist/orchestration/workflow.d.ts +145 -0
  448. package/dist/orchestration/workflow.d.ts.map +1 -0
  449. package/dist/orchestration/workflow.js +301 -0
  450. package/dist/orchestration/workflow.js.map +1 -0
  451. package/dist/providers/codexSessions.d.ts +93 -0
  452. package/dist/providers/codexSessions.d.ts.map +1 -0
  453. package/dist/providers/codexSessions.js +366 -0
  454. package/dist/providers/codexSessions.js.map +1 -0
  455. package/dist/registry/bsDetector.d.ts +24 -0
  456. package/dist/registry/bsDetector.d.ts.map +1 -0
  457. package/dist/registry/bsDetector.js +276 -0
  458. package/dist/registry/bsDetector.js.map +1 -0
  459. package/dist/registry/entityScanner.d.ts +36 -0
  460. package/dist/registry/entityScanner.d.ts.map +1 -0
  461. package/dist/registry/entityScanner.js +693 -0
  462. package/dist/registry/entityScanner.js.map +1 -0
  463. package/dist/registry/index.d.ts +9 -0
  464. package/dist/registry/index.d.ts.map +1 -0
  465. package/dist/registry/index.js +13 -0
  466. package/dist/registry/index.js.map +1 -0
  467. package/dist/registry/schema.d.ts +307 -0
  468. package/dist/registry/schema.d.ts.map +1 -0
  469. package/dist/registry/schema.js +139 -0
  470. package/dist/registry/schema.js.map +1 -0
  471. package/dist/registry/sqliteStore.d.ts +101 -0
  472. package/dist/registry/sqliteStore.d.ts.map +1 -0
  473. package/dist/registry/sqliteStore.js +688 -0
  474. package/dist/registry/sqliteStore.js.map +1 -0
  475. package/dist/registry/workItemBridge.d.ts +8 -0
  476. package/dist/registry/workItemBridge.d.ts.map +1 -0
  477. package/dist/registry/workItemBridge.js +30 -0
  478. package/dist/registry/workItemBridge.js.map +1 -0
  479. package/dist/runners/cliRunner.d.ts +11 -0
  480. package/dist/runners/cliRunner.d.ts.map +1 -0
  481. package/dist/runners/cliRunner.js +193 -0
  482. package/dist/runners/cliRunner.js.map +1 -0
  483. package/dist/support/apiCache.d.ts +85 -0
  484. package/dist/support/apiCache.d.ts.map +1 -0
  485. package/dist/support/apiCache.js +163 -0
  486. package/dist/support/apiCache.js.map +1 -0
  487. package/dist/support/chat.d.ts +3 -0
  488. package/dist/support/chat.d.ts.map +1 -0
  489. package/dist/support/chat.js +305 -0
  490. package/dist/support/chat.js.map +1 -0
  491. package/dist/support/chatBackend.d.ts +25 -0
  492. package/dist/support/chatBackend.d.ts.map +1 -0
  493. package/dist/support/chatBackend.js +289 -0
  494. package/dist/support/chatBackend.js.map +1 -0
  495. package/dist/support/chatTui.d.ts +3 -0
  496. package/dist/support/chatTui.d.ts.map +1 -0
  497. package/dist/support/chatTui.js +1082 -0
  498. package/dist/support/chatTui.js.map +1 -0
  499. package/dist/support/costTracker.d.ts +29 -0
  500. package/dist/support/costTracker.d.ts.map +1 -0
  501. package/dist/support/costTracker.js +113 -0
  502. package/dist/support/costTracker.js.map +1 -0
  503. package/dist/support/dashboardHtml.d.ts +5 -0
  504. package/dist/support/dashboardHtml.d.ts.map +1 -0
  505. package/dist/support/dashboardHtml.js +2629 -0
  506. package/dist/support/dashboardHtml.js.map +1 -0
  507. package/dist/support/dev.d.ts +55 -0
  508. package/dist/support/dev.d.ts.map +1 -0
  509. package/dist/support/dev.js +298 -0
  510. package/dist/support/dev.js.map +1 -0
  511. package/dist/support/editParser.d.ts +37 -0
  512. package/dist/support/editParser.d.ts.map +1 -0
  513. package/dist/support/editParser.js +365 -0
  514. package/dist/support/editParser.js.map +1 -0
  515. package/dist/support/ghosttyThemeCatalog.generated.d.ts +2 -0
  516. package/dist/support/ghosttyThemeCatalog.generated.d.ts.map +1 -0
  517. package/dist/support/ghosttyThemeCatalog.generated.js +11116 -0
  518. package/dist/support/ghosttyThemeCatalog.generated.js.map +1 -0
  519. package/dist/support/gitStatus.d.ts +21 -0
  520. package/dist/support/gitStatus.d.ts.map +1 -0
  521. package/dist/support/gitStatus.js +108 -0
  522. package/dist/support/gitStatus.js.map +1 -0
  523. package/dist/support/gitTracker.d.ts +30 -0
  524. package/dist/support/gitTracker.d.ts.map +1 -0
  525. package/dist/support/gitTracker.js +143 -0
  526. package/dist/support/gitTracker.js.map +1 -0
  527. package/dist/support/index.d.ts +12 -0
  528. package/dist/support/index.d.ts.map +1 -0
  529. package/dist/support/index.js +12 -0
  530. package/dist/support/index.js.map +1 -0
  531. package/dist/support/planner.d.ts +64 -0
  532. package/dist/support/planner.d.ts.map +1 -0
  533. package/dist/support/planner.js +396 -0
  534. package/dist/support/planner.js.map +1 -0
  535. package/dist/support/projectMapper.d.ts +46 -0
  536. package/dist/support/projectMapper.d.ts.map +1 -0
  537. package/dist/support/projectMapper.js +273 -0
  538. package/dist/support/projectMapper.js.map +1 -0
  539. package/dist/support/pty-helper.py +117 -0
  540. package/dist/support/quotaTracker.d.ts +29 -0
  541. package/dist/support/quotaTracker.d.ts.map +1 -0
  542. package/dist/support/quotaTracker.js +89 -0
  543. package/dist/support/quotaTracker.js.map +1 -0
  544. package/dist/support/rateLimiter.d.ts +101 -0
  545. package/dist/support/rateLimiter.d.ts.map +1 -0
  546. package/dist/support/rateLimiter.js +219 -0
  547. package/dist/support/rateLimiter.js.map +1 -0
  548. package/dist/support/rollback.d.ts +61 -0
  549. package/dist/support/rollback.d.ts.map +1 -0
  550. package/dist/support/rollback.js +329 -0
  551. package/dist/support/rollback.js.map +1 -0
  552. package/dist/support/sharedShell.d.ts +17 -0
  553. package/dist/support/sharedShell.d.ts.map +1 -0
  554. package/dist/support/sharedShell.js +439 -0
  555. package/dist/support/sharedShell.js.map +1 -0
  556. package/dist/support/stuckDetector.d.ts +68 -0
  557. package/dist/support/stuckDetector.d.ts.map +1 -0
  558. package/dist/support/stuckDetector.js +174 -0
  559. package/dist/support/stuckDetector.js.map +1 -0
  560. package/dist/support/terminalBridge.d.ts +18 -0
  561. package/dist/support/terminalBridge.d.ts.map +1 -0
  562. package/dist/support/terminalBridge.js +553 -0
  563. package/dist/support/terminalBridge.js.map +1 -0
  564. package/dist/support/timeWindow.d.ts +60 -0
  565. package/dist/support/timeWindow.d.ts.map +1 -0
  566. package/dist/support/timeWindow.js +236 -0
  567. package/dist/support/timeWindow.js.map +1 -0
  568. package/dist/support/uiThemes.d.ts +44 -0
  569. package/dist/support/uiThemes.d.ts.map +1 -0
  570. package/dist/support/uiThemes.js +290 -0
  571. package/dist/support/uiThemes.js.map +1 -0
  572. package/dist/support/web.d.ts +29 -0
  573. package/dist/support/web.d.ts.map +1 -0
  574. package/dist/support/web.js +1097 -0
  575. package/dist/support/web.js.map +1 -0
  576. package/dist/support/worktreeManager.d.ts +20 -0
  577. package/dist/support/worktreeManager.d.ts.map +1 -0
  578. package/dist/support/worktreeManager.js +140 -0
  579. package/dist/support/worktreeManager.js.map +1 -0
  580. package/dist/task_state_model.py +55 -0
  581. package/dist/workItemState/store.d.ts +122 -0
  582. package/dist/workItemState/store.d.ts.map +1 -0
  583. package/dist/workItemState/store.js +438 -0
  584. package/dist/workItemState/store.js.map +1 -0
  585. package/dist/workItems/azdoBridge.d.ts +42 -0
  586. package/dist/workItems/azdoBridge.d.ts.map +1 -0
  587. package/dist/workItems/azdoBridge.js +143 -0
  588. package/dist/workItems/azdoBridge.js.map +1 -0
  589. package/dist/workItems/azdoSyncRuntime.d.ts +28 -0
  590. package/dist/workItems/azdoSyncRuntime.d.ts.map +1 -0
  591. package/dist/workItems/azdoSyncRuntime.js +158 -0
  592. package/dist/workItems/azdoSyncRuntime.js.map +1 -0
  593. package/dist/workItems/azureDevOpsSync.d.ts +128 -0
  594. package/dist/workItems/azureDevOpsSync.d.ts.map +1 -0
  595. package/dist/workItems/azureDevOpsSync.js +748 -0
  596. package/dist/workItems/azureDevOpsSync.js.map +1 -0
  597. package/dist/workItems/helpers.d.ts +11 -0
  598. package/dist/workItems/helpers.d.ts.map +1 -0
  599. package/dist/workItems/helpers.js +17 -0
  600. package/dist/workItems/helpers.js.map +1 -0
  601. package/dist/workItems/index.d.ts +21 -0
  602. package/dist/workItems/index.d.ts.map +1 -0
  603. package/dist/workItems/index.js +89 -0
  604. package/dist/workItems/index.js.map +1 -0
  605. package/dist/workItems/localWorkItemFetcher.d.ts +55 -0
  606. package/dist/workItems/localWorkItemFetcher.d.ts.map +1 -0
  607. package/dist/workItems/localWorkItemFetcher.js +209 -0
  608. package/dist/workItems/localWorkItemFetcher.js.map +1 -0
  609. package/dist/workItems/migrations/001_rename_workItem_to_work_item.sql +10 -0
  610. package/dist/workItems/postgresStore.d.ts +78 -0
  611. package/dist/workItems/postgresStore.d.ts.map +1 -0
  612. package/dist/workItems/postgresStore.js +937 -0
  613. package/dist/workItems/postgresStore.js.map +1 -0
  614. package/dist/workItems/schema.d.ts +257 -0
  615. package/dist/workItems/schema.d.ts.map +1 -0
  616. package/dist/workItems/schema.js +176 -0
  617. package/dist/workItems/schema.js.map +1 -0
  618. package/dist/workItems/sqliteStore.d.ts +124 -0
  619. package/dist/workItems/sqliteStore.d.ts.map +1 -0
  620. package/dist/workItems/sqliteStore.js +713 -0
  621. package/dist/workItems/sqliteStore.js.map +1 -0
  622. package/dist/workItems/workItemBoardHtml.d.ts +5 -0
  623. package/dist/workItems/workItemBoardHtml.d.ts.map +1 -0
  624. package/dist/workItems/workItemBoardHtml.js +2192 -0
  625. package/dist/workItems/workItemBoardHtml.js.map +1 -0
  626. package/package.json +99 -0
  627. package/templates/AGENTS.md +432 -0
  628. package/templates/BOOT.md +25 -0
  629. package/templates/BOOTSTRAP.md +50 -0
  630. package/templates/CHANGELOG_AUDIT.md +74 -0
  631. package/templates/HEARTBEAT.md +86 -0
  632. package/templates/IDENTITY.md +27 -0
  633. package/templates/PR_LAND.md +75 -0
  634. package/templates/PR_REVIEW.md +97 -0
  635. package/templates/SOUL.dev.md +52 -0
  636. package/templates/SOUL.md +81 -0
  637. package/templates/TOOLS.md +52 -0
  638. package/templates/USER.md +22 -0
  639. package/templates/WORKITEM_ANALYSIS.md +31 -0
  640. package/templates/agents/executor.md +26 -0
  641. package/templates/agents/plan.md +22 -0
  642. package/templates/agents/ralph.md +37 -0
  643. package/templates/agents/review.md +22 -0
  644. package/templates/agents/team.md +39 -0
@@ -0,0 +1,693 @@
1
+ // ============================================
2
+ // EnactFactory - Entity Scanner
3
+ // Created: 2026-04-10
4
+ // Purpose: 레포 소스 파일에서 함수/클래스/타입/상수 선언을 추출하여 레지스트리에 등록
5
+ // Dependencies: registry/sqliteStore
6
+ // Supported: TypeScript, JavaScript, Python, Go, Rust, Java, C, C++, C#
7
+ // ============================================
8
+ import { readdir, readFile, stat } from 'node:fs/promises';
9
+ import { join, extname, dirname } from 'node:path';
10
+ import { getRegistryStore } from '../registry/sqliteStore.js';
11
+ // ============ 상수 ============
12
+ const SKIP_DIRS = new Set([
13
+ 'node_modules', '.git', 'dist', 'build', '__pycache__',
14
+ '.next', '.venv', 'venv', '.tox', '.mypy_cache', '.pytest_cache',
15
+ 'coverage', '.turbo', '.cache', '.parcel-cache',
16
+ '.venv-mcp', 'site-packages', '.enact',
17
+ 'trash', 'testing', 'vendor', 'third_party',
18
+ 'target', // Rust/Java
19
+ 'bin', 'obj', // C#
20
+ 'cmake-build-debug', 'cmake-build-release', // C/C++
21
+ ]);
22
+ const SKIP_DIR_PREFIXES = ['.venv'];
23
+ const MAX_FILE_SIZE = 512 * 1024;
24
+ const MAX_DEPTH = 15;
25
+ const SCAN_TIMEOUT_MS = 60_000;
26
+ // ---- TypeScript / JavaScript ----
27
+ const TS_CONFIG = {
28
+ extensions: ['.ts', '.tsx', '.js', '.jsx', '.mjs', '.cjs'],
29
+ testPatterns: [/\.test\.[tj]sx?$/, /\.spec\.[tj]sx?$/],
30
+ blockStyle: 'brace',
31
+ skipIndented: ['function'],
32
+ commentPrefixes: ['//', '*', '/*'],
33
+ patterns: [
34
+ { pattern: /^export\s+(?:async\s+)?function\s+(\w+)\s*(\([^)]*\)(?:\s*:\s*[^{]+)?)?\s*\{?/, kind: 'function', sigGroup: 2 },
35
+ { pattern: /^export\s+(?:const|let|var)\s+(\w+)\s*=\s*(?:async\s+)?(?:\([^)]*\)\s*(?::\s*\w[^=]*)?\s*=>|function)/, kind: 'function' },
36
+ { pattern: /^export\s+(?:abstract\s+)?class\s+(\w+)/, kind: 'class' },
37
+ { pattern: /^export\s+(?:interface|type)\s+(\w+)/, kind: 'type' },
38
+ { pattern: /^export\s+(?:const\s+)?enum\s+(\w+)/, kind: 'type' },
39
+ { pattern: /^export\s+const\s+([A-Z][A-Z0-9_]+)\s*=/, kind: 'constant' },
40
+ { pattern: /^(?:async\s+)?function\s+(\w+)\s*(\([^)]*\)(?:\s*:\s*[^{]+)?)?\s*\{?/, kind: 'function', sigGroup: 2 },
41
+ { pattern: /^(?:abstract\s+)?class\s+(\w+)/, kind: 'class' },
42
+ ],
43
+ };
44
+ // ---- Python ----
45
+ const PY_CONFIG = {
46
+ extensions: ['.py', '.pyw'],
47
+ testPatterns: [/_test\.py$/, /test_.*\.py$/, /\.test\.py$/],
48
+ blockStyle: 'indent',
49
+ commentPrefixes: ['#'],
50
+ patterns: [
51
+ { pattern: /^(?:async\s+)?def\s+(\w+)\s*(\([^)]*\)(?:\s*->\s*[^:]+)?)?\s*:/, kind: 'function', sigGroup: 2 },
52
+ { pattern: /^class\s+(\w+)/, kind: 'class' },
53
+ // 타입 별칭: Name = Literal[...] / Name = Union[...] / Name: TypeAlias = ...
54
+ { pattern: /^([A-Z]\w+)\s*(?::\s*TypeAlias\s*)?=\s*(?:Literal|Union|Optional|Type|Annotated|Final)\[/, kind: 'type' },
55
+ // 상수: UPPER_CASE = ...
56
+ { pattern: /^([A-Z][A-Z0-9_]+)\s*(?::\s*\w[^=]*)?\s*=/, kind: 'constant' },
57
+ ],
58
+ };
59
+ // ---- Go ----
60
+ const GO_CONFIG = {
61
+ extensions: ['.go'],
62
+ testPatterns: [/_test\.go$/],
63
+ blockStyle: 'brace',
64
+ commentPrefixes: ['//', '*', '/*'],
65
+ patterns: [
66
+ // func FuncName(params) returnType {
67
+ { pattern: /^func\s+(\w+)\s*(\([^)]*\)(?:\s*(?:\([^)]*\)|[^{]+))?)?\s*\{?/, kind: 'function', sigGroup: 2 },
68
+ // func (receiver) MethodName(params) — 메서드 (receiver 있음)
69
+ { pattern: /^func\s+\([^)]+\)\s+(\w+)\s*(\([^)]*\)(?:\s*(?:\([^)]*\)|[^{]+))?)?\s*\{?/, kind: 'function', sigGroup: 2 },
70
+ // type StructName struct {
71
+ { pattern: /^type\s+(\w+)\s+struct\s*\{?/, kind: 'class' },
72
+ // type InterfaceName interface {
73
+ { pattern: /^type\s+(\w+)\s+interface\s*\{?/, kind: 'type' },
74
+ // type TypeName = ... / type TypeName ...
75
+ { pattern: /^type\s+(\w+)\s+[^si]/, kind: 'type' },
76
+ // const ConstName = ... (단일 const)
77
+ { pattern: /^const\s+(\w+)\s*(?:\w+)?\s*=/, kind: 'constant' },
78
+ // var VarName = ... (패키지 수준)
79
+ { pattern: /^var\s+(\w+)\s+/, kind: 'constant' },
80
+ ],
81
+ };
82
+ // ---- Rust ----
83
+ const RUST_CONFIG = {
84
+ extensions: ['.rs'],
85
+ testPatterns: [], // Rust는 같은 파일 내 #[cfg(test)] mod tests {}
86
+ blockStyle: 'brace',
87
+ commentPrefixes: ['//', '///', '*', '/*'],
88
+ patterns: [
89
+ // pub fn func_name(params) -> ReturnType {
90
+ { pattern: /^(?:pub(?:\(crate\))?\s+)?(?:async\s+)?fn\s+(\w+)\s*(<[^>]*>)?\s*(\([^)]*\)(?:\s*->\s*[^{]+)?)?\s*(?:where\s+[^{]*)?\{?/, kind: 'function', sigGroup: 3 },
91
+ // pub struct StructName {
92
+ { pattern: /^(?:pub(?:\(crate\))?\s+)?struct\s+(\w+)/, kind: 'class' },
93
+ // pub enum EnumName {
94
+ { pattern: /^(?:pub(?:\(crate\))?\s+)?enum\s+(\w+)/, kind: 'type' },
95
+ // pub trait TraitName {
96
+ { pattern: /^(?:pub(?:\(crate\))?\s+)?trait\s+(\w+)/, kind: 'type' },
97
+ // type TypeAlias = ...
98
+ { pattern: /^(?:pub(?:\(crate\))?\s+)?type\s+(\w+)/, kind: 'type' },
99
+ // const CONST_NAME: Type = ...
100
+ { pattern: /^(?:pub(?:\(crate\))?\s+)?const\s+([A-Z][A-Z0-9_]+)\s*:/, kind: 'constant' },
101
+ // static STATIC_NAME: Type = ...
102
+ { pattern: /^(?:pub(?:\(crate\))?\s+)?static\s+(?:mut\s+)?([A-Z][A-Z0-9_]+)\s*:/, kind: 'constant' },
103
+ // impl StructName {
104
+ { pattern: /^impl(?:<[^>]*>)?\s+(\w+)(?:<[^>]*>)?\s*(?:for\s+\w+)?\s*\{/, kind: 'class' },
105
+ ],
106
+ };
107
+ // ---- Java ----
108
+ const JAVA_CONFIG = {
109
+ extensions: ['.java'],
110
+ testPatterns: [/Test\.java$/, /Tests\.java$/, /IT\.java$/],
111
+ blockStyle: 'brace',
112
+ commentPrefixes: ['//', '*', '/*', '@'],
113
+ patterns: [
114
+ // public/private/protected ReturnType methodName(params) {
115
+ { pattern: /^(?:(?:public|private|protected)\s+)?(?:static\s+)?(?:final\s+)?(?:synchronized\s+)?(?:abstract\s+)?(?:native\s+)?(?:<[^>]+>\s+)?(?:\w+(?:<[^>]*>)?(?:\[\])*)\s+(\w+)\s*(\([^)]*\))\s*(?:throws\s+[^{]+)?\s*\{?/, kind: 'function', sigGroup: 2 },
116
+ // public class ClassName {
117
+ { pattern: /^(?:(?:public|private|protected)\s+)?(?:static\s+)?(?:final\s+)?(?:abstract\s+)?class\s+(\w+)/, kind: 'class' },
118
+ // public interface InterfaceName {
119
+ { pattern: /^(?:(?:public|private|protected)\s+)?(?:static\s+)?interface\s+(\w+)/, kind: 'type' },
120
+ // public enum EnumName {
121
+ { pattern: /^(?:(?:public|private|protected)\s+)?enum\s+(\w+)/, kind: 'type' },
122
+ // @interface AnnotationName {
123
+ { pattern: /^(?:(?:public|private|protected)\s+)?@interface\s+(\w+)/, kind: 'type' },
124
+ // public record RecordName(...)
125
+ { pattern: /^(?:(?:public|private|protected)\s+)?record\s+(\w+)/, kind: 'class' },
126
+ // public static final Type CONST_NAME = ...
127
+ { pattern: /^(?:(?:public|private|protected)\s+)?static\s+final\s+\w+(?:<[^>]*>)?\s+([A-Z][A-Z0-9_]+)\s*=/, kind: 'constant' },
128
+ ],
129
+ };
130
+ // ---- C ----
131
+ const C_CONFIG = {
132
+ extensions: ['.c', '.h'],
133
+ testPatterns: [/_test\.c$/, /test_.*\.c$/],
134
+ blockStyle: 'brace',
135
+ commentPrefixes: ['//', '*', '/*'],
136
+ patterns: [
137
+ // returnType funcName(params) { — top-level 함수
138
+ // 캡처: 반환형 다음 함수명, 괄호
139
+ { pattern: /^(?:static\s+)?(?:inline\s+)?(?:extern\s+)?(?:const\s+)?(?:unsigned\s+)?(?:signed\s+)?(?:long\s+)?(?:short\s+)?\w+[\s*]+(\w+)\s*(\([^)]*\))\s*\{/, kind: 'function', sigGroup: 2 },
140
+ // typedef struct { ... } Name;
141
+ { pattern: /^typedef\s+struct\s+(?:\w+\s*)?\{/, kind: 'class' },
142
+ // struct Name {
143
+ { pattern: /^(?:typedef\s+)?struct\s+(\w+)\s*\{?/, kind: 'class' },
144
+ // enum Name {
145
+ { pattern: /^(?:typedef\s+)?enum\s+(\w+)/, kind: 'type' },
146
+ // typedef returnType (*Name)(params);
147
+ { pattern: /^typedef\s+\w+[\s*]*\(\s*\*\s*(\w+)\s*\)/, kind: 'type' },
148
+ // typedef ... Name;
149
+ { pattern: /^typedef\s+.+\s+(\w+)\s*;/, kind: 'type' },
150
+ // #define MACRO_NAME
151
+ { pattern: /^#define\s+([A-Z][A-Z0-9_]+)/, kind: 'constant' },
152
+ // const type CONST = ... / static const ...
153
+ { pattern: /^(?:static\s+)?const\s+\w+\s+([A-Z][A-Z0-9_]+)\s*=/, kind: 'constant' },
154
+ ],
155
+ };
156
+ // ---- C++ ----
157
+ const CPP_CONFIG = {
158
+ extensions: ['.cpp', '.cxx', '.cc', '.hpp', '.hxx', '.hh'],
159
+ testPatterns: [/_test\.cpp$/, /test_.*\.cpp$/, /_test\.cc$/, /Test\.cpp$/],
160
+ blockStyle: 'brace',
161
+ commentPrefixes: ['//', '*', '/*'],
162
+ patterns: [
163
+ // class ClassName { (C++ 우선 — 함수보다 먼저 매칭)
164
+ { pattern: /^(?:template\s*<[^>]*>\s*)?(?:class|struct)\s+(?:\[\[.*?\]\]\s+)?(\w+)(?:\s*final)?\s*(?::\s*(?:public|private|protected)\s+[^{]+)?\s*\{/, kind: 'class' },
165
+ // namespace Name {
166
+ { pattern: /^namespace\s+(\w+)/, kind: 'module' },
167
+ // ReturnType ClassName::methodName(params) { — 이건 메서드이므로 별도 처리
168
+ { pattern: /^(?:template\s*<[^>]*>\s*)?(?:\w+[\s*&]+)?(\w+)::(\w+)\s*(\([^)]*\))/, kind: 'function', sigGroup: 3 },
169
+ // returnType funcName(params) {
170
+ { pattern: /^(?:template\s*<[^>]*>\s*)?(?:static\s+)?(?:inline\s+)?(?:virtual\s+)?(?:explicit\s+)?(?:constexpr\s+)?(?:const\s+)?(?:unsigned\s+)?\w+[\s*&]+(\w+)\s*(\([^)]*\))\s*(?:const)?\s*(?:override|final|noexcept)?\s*\{?/, kind: 'function', sigGroup: 2 },
171
+ // enum class Name {
172
+ { pattern: /^enum\s+(?:class\s+)?(\w+)/, kind: 'type' },
173
+ // using Name = ...
174
+ { pattern: /^using\s+(\w+)\s*=/, kind: 'type' },
175
+ // typedef
176
+ { pattern: /^typedef\s+.+\s+(\w+)\s*;/, kind: 'type' },
177
+ // constexpr auto CONST = ...
178
+ { pattern: /^(?:static\s+)?(?:inline\s+)?constexpr\s+\w+\s+([A-Z][A-Z0-9_]+)\s*[={]/, kind: 'constant' },
179
+ { pattern: /^#define\s+([A-Z][A-Z0-9_]+)/, kind: 'constant' },
180
+ { pattern: /^(?:static\s+)?const\s+\w+\s+([A-Z][A-Z0-9_]+)\s*=/, kind: 'constant' },
181
+ ],
182
+ };
183
+ // ---- C# ----
184
+ const CSHARP_CONFIG = {
185
+ extensions: ['.cs'],
186
+ testPatterns: [/Tests?\.cs$/, /\.test\.cs$/],
187
+ blockStyle: 'brace',
188
+ commentPrefixes: ['//', '///', '*', '/*'],
189
+ patterns: [
190
+ // public class ClassName
191
+ { pattern: /^(?:\[.*?\]\s*)?(?:(?:public|private|protected|internal)\s+)?(?:static\s+)?(?:sealed\s+)?(?:abstract\s+)?(?:partial\s+)?class\s+(\w+)/, kind: 'class' },
192
+ // public struct StructName
193
+ { pattern: /^(?:\[.*?\]\s*)?(?:(?:public|private|protected|internal)\s+)?(?:readonly\s+)?(?:ref\s+)?(?:partial\s+)?struct\s+(\w+)/, kind: 'class' },
194
+ // public record RecordName
195
+ { pattern: /^(?:\[.*?\]\s*)?(?:(?:public|private|protected|internal)\s+)?(?:sealed\s+)?(?:abstract\s+)?record\s+(?:struct\s+|class\s+)?(\w+)/, kind: 'class' },
196
+ // public interface IInterfaceName
197
+ { pattern: /^(?:\[.*?\]\s*)?(?:(?:public|private|protected|internal)\s+)?(?:partial\s+)?interface\s+(\w+)/, kind: 'type' },
198
+ // public enum EnumName
199
+ { pattern: /^(?:\[.*?\]\s*)?(?:(?:public|private|protected|internal)\s+)?enum\s+(\w+)/, kind: 'type' },
200
+ // public delegate ReturnType DelegateName(params);
201
+ { pattern: /^(?:(?:public|private|protected|internal)\s+)?delegate\s+\w+[\s<>[\],*]*\s+(\w+)\s*[(<]/, kind: 'type' },
202
+ // public ReturnType MethodName(params) {
203
+ { pattern: /^(?:\[.*?\]\s*)?(?:(?:public|private|protected|internal)\s+)?(?:static\s+)?(?:virtual\s+)?(?:override\s+)?(?:abstract\s+)?(?:async\s+)?(?:new\s+)?(?:\w+(?:<[^>]*>)?(?:\[\]|\?)?)\s+(\w+)\s*(<[^>]*>)?\s*(\([^)]*\))\s*(?:where\s+[^{]*)?\s*[{=>]/, kind: 'function', sigGroup: 3 },
204
+ // public const Type CONST = ...
205
+ { pattern: /^(?:(?:public|private|protected|internal)\s+)?(?:static\s+)?(?:readonly\s+)?const\s+\w+\s+(\w+)\s*=/, kind: 'constant' },
206
+ ],
207
+ };
208
+ // ============ 언어 레지스트리 ============
209
+ const LANGUAGE_CONFIGS = {
210
+ typescript: TS_CONFIG,
211
+ python: PY_CONFIG,
212
+ go: GO_CONFIG,
213
+ rust: RUST_CONFIG,
214
+ java: JAVA_CONFIG,
215
+ c: C_CONFIG,
216
+ cpp: CPP_CONFIG,
217
+ csharp: CSHARP_CONFIG,
218
+ };
219
+ // 확장자 → 언어 매핑
220
+ const EXT_TO_LANGUAGE = {};
221
+ for (const [lang, config] of Object.entries(LANGUAGE_CONFIGS)) {
222
+ for (const ext of config.extensions) {
223
+ EXT_TO_LANGUAGE[ext] = lang;
224
+ }
225
+ }
226
+ // 지원되는 확장자 전체
227
+ const SOURCE_EXTENSIONS = new Set(Object.keys(EXT_TO_LANGUAGE));
228
+ function detectLanguage(ext) {
229
+ return EXT_TO_LANGUAGE[ext] ?? null;
230
+ }
231
+ function isTestFile(name, language) {
232
+ return LANGUAGE_CONFIGS[language].testPatterns.some(p => p.test(name));
233
+ }
234
+ // ============ 엔티티 추출 ============
235
+ /**
236
+ * 소스 파일 내용에서 엔티티 선언을 추출
237
+ */
238
+ export function extractEntities(content, filePath, language) {
239
+ const lines = content.split('\n');
240
+ const entities = [];
241
+ const config = LANGUAGE_CONFIGS[language];
242
+ const seen = new Set();
243
+ for (let i = 0; i < lines.length; i++) {
244
+ const trimmed = lines[i].trimStart();
245
+ if (!trimmed)
246
+ continue;
247
+ // 주석 스킵
248
+ if (config.commentPrefixes.some(p => trimmed.startsWith(p)))
249
+ continue;
250
+ for (const { pattern, kind, sigGroup } of config.patterns) {
251
+ const match = trimmed.match(pattern);
252
+ if (!match)
253
+ continue;
254
+ const name = match[1];
255
+ if (!name)
256
+ continue;
257
+ const key = `${name}:${i}`;
258
+ if (seen.has(key))
259
+ continue;
260
+ seen.add(key);
261
+ // Python: 인덴트 있는 함수 = 메서드 → 스킵
262
+ if (language === 'python' && kind === 'function' && lines[i].match(/^\s+/))
263
+ continue;
264
+ // TS: skipIndented 설정된 kind가 인덴트 있으면 스킵
265
+ if (config.skipIndented?.includes(kind) && lines[i].match(/^\s{2,}/))
266
+ continue;
267
+ const isExported = language === 'go'
268
+ ? /^[A-Z]/.test(name) // Go: 대문자 시작 = exported
269
+ : trimmed.startsWith('export') || trimmed.startsWith('pub');
270
+ const signature = sigGroup ? match[sigGroup]?.trim() : undefined;
271
+ // 블록 끝 추정
272
+ let lineEnd;
273
+ if (config.blockStyle === 'brace') {
274
+ lineEnd = findBraceBlockEnd(lines, i);
275
+ }
276
+ else if (config.blockStyle === 'indent') {
277
+ lineEnd = findIndentBlockEnd(lines, i);
278
+ }
279
+ // 복잡도 산정
280
+ const complexity = (kind === 'function' || kind === 'class')
281
+ ? computeBlockMetrics(lines, i, lineEnd)
282
+ : { loc: 0, nestingDepth: 0, paramCount: 0 };
283
+ entities.push({
284
+ kind,
285
+ name,
286
+ filePath,
287
+ lineStart: i + 1,
288
+ lineEnd: lineEnd ? lineEnd + 1 : undefined,
289
+ signature,
290
+ isExported,
291
+ loc: complexity.loc,
292
+ nestingDepth: complexity.nestingDepth,
293
+ paramCount: complexity.paramCount,
294
+ });
295
+ break;
296
+ }
297
+ }
298
+ return entities;
299
+ }
300
+ // ============ 블록 끝 추정 ============
301
+ /** 중괄호 카운팅 (C계열, Go, Rust, Java, C#) */
302
+ function findBraceBlockEnd(lines, startIdx) {
303
+ let depth = 0;
304
+ let started = false;
305
+ for (let i = startIdx; i < Math.min(startIdx + 500, lines.length); i++) {
306
+ for (const ch of lines[i]) {
307
+ if (ch === '{') {
308
+ depth++;
309
+ started = true;
310
+ }
311
+ if (ch === '}')
312
+ depth--;
313
+ }
314
+ if (started && depth <= 0)
315
+ return i;
316
+ }
317
+ return undefined;
318
+ }
319
+ /** 인덴트 기반 (Python) */
320
+ function findIndentBlockEnd(lines, startIdx) {
321
+ // 선언 줄의 인덴트 수준 파악
322
+ const startLine = lines[startIdx];
323
+ const baseIndent = startLine.length - startLine.trimStart().length;
324
+ for (let i = startIdx + 1; i < Math.min(startIdx + 500, lines.length); i++) {
325
+ const line = lines[i];
326
+ // 빈 줄은 건너뜀
327
+ if (line.trim().length === 0)
328
+ continue;
329
+ const currentIndent = line.length - line.trimStart().length;
330
+ // 인덴트가 기본 수준 이하로 돌아오면 블록 끝
331
+ if (currentIndent <= baseIndent)
332
+ return i - 1;
333
+ }
334
+ return undefined;
335
+ }
336
+ // ============ 복잡도 산정 ============
337
+ function computeBlockMetrics(lines, startIdx, endIdx) {
338
+ const end = endIdx ?? Math.min(startIdx + 50, lines.length);
339
+ const blockLines = lines.slice(startIdx, end + 1);
340
+ const loc = blockLines.filter(l => l.trim().length > 0).length;
341
+ let maxNesting = 0;
342
+ let currentNesting = 0;
343
+ for (const line of blockLines) {
344
+ for (const ch of line) {
345
+ if (ch === '{' || ch === '(')
346
+ currentNesting++;
347
+ if (ch === '}' || ch === ')')
348
+ currentNesting--;
349
+ }
350
+ if (currentNesting > maxNesting)
351
+ maxNesting = currentNesting;
352
+ }
353
+ const firstLine = blockLines[0] ?? '';
354
+ const paramMatch = firstLine.match(/\(([^)]*)\)/);
355
+ const paramCount = paramMatch
356
+ ? paramMatch[1].split(',').filter(p => p.trim().length > 0).length
357
+ : 0;
358
+ return { loc, nestingDepth: maxNesting, paramCount };
359
+ }
360
+ function computeComplexityFromMetrics(loc, nestingDepth, paramCount) {
361
+ let score = 0;
362
+ if (loc > 100)
363
+ score += 3;
364
+ else if (loc > 50)
365
+ score += 2;
366
+ else if (loc > 20)
367
+ score += 1;
368
+ if (nestingDepth > 6)
369
+ score += 3;
370
+ else if (nestingDepth > 4)
371
+ score += 2;
372
+ else if (nestingDepth > 2)
373
+ score += 1;
374
+ if (paramCount > 6)
375
+ score += 2;
376
+ else if (paramCount > 3)
377
+ score += 1;
378
+ return Math.min(score, 10);
379
+ }
380
+ function computeRisk(complexityScore, hasTests) {
381
+ if (complexityScore >= 8)
382
+ return 'high';
383
+ if (complexityScore >= 6 && !hasTests)
384
+ return 'high';
385
+ if (complexityScore >= 6)
386
+ return 'medium';
387
+ if (complexityScore >= 4 && !hasTests)
388
+ return 'medium';
389
+ return 'low';
390
+ }
391
+ const TS_IMPORT_FROM = /import\s+\{([^}]+)\}\s+from\s+['"]([^'"]+)['"]/g;
392
+ // import 예약어 — 테스트 프레임워크 함수 등
393
+ const RESERVED_NAMES = new Set([
394
+ 'describe', 'it', 'test', 'expect', 'beforeEach', 'afterEach',
395
+ 'beforeAll', 'afterAll', 'vi', 'jest', 'mock', 'fn', 'spyOn',
396
+ 'console', 'setTimeout', 'setInterval', 'Promise', 'Date',
397
+ 'Array', 'Object', 'String', 'Number', 'Boolean', 'Map', 'Set',
398
+ 'JSON', 'Math', 'Error', 'RegExp', 'require', 'import',
399
+ 'resolve', 'reject', 'then', 'catch', 'finally', 'push',
400
+ 'filter', 'map', 'reduce', 'forEach', 'find', 'includes',
401
+ 'join', 'split', 'trim', 'slice', 'splice', 'pop', 'shift',
402
+ 'assert', 'assertEqual', 'assertTrue', 'assertFalse', 'assertRaises', // Python
403
+ 'testing', 'Errorf', 'Fatalf', 'Run', 'Equal', 'NotNil', // Go
404
+ 'assert_eq', 'assert_ne', 'assert', 'panic', 'println', // Rust
405
+ 'assertEquals', 'assertNotNull', 'assertThrows', 'assertTrue', // Java
406
+ 'Assert', 'Fact', 'Theory', // C#
407
+ ]);
408
+ function parseTestFile(content, testFilePath, language) {
409
+ const importedSymbols = new Map();
410
+ const referencedNames = new Set();
411
+ // TS/JS: import { A, B } from '@/registry/path'
412
+ if (language === 'typescript') {
413
+ TS_IMPORT_FROM.lastIndex = 0;
414
+ let match;
415
+ while ((match = TS_IMPORT_FROM.exec(content)) !== null) {
416
+ const symbols = match[1].split(',')
417
+ .map(s => s.trim().split(/\s+as\s+/)[0].trim())
418
+ .filter(s => s && !s.startsWith('type '));
419
+ const importPath = match[2];
420
+ if (importPath.startsWith('.')) {
421
+ const resolved = resolveImportPath(testFilePath, importPath);
422
+ if (resolved) {
423
+ const existing = importedSymbols.get(resolved) ?? new Set();
424
+ for (const s of symbols)
425
+ existing.add(s);
426
+ importedSymbols.set(resolved, existing);
427
+ }
428
+ }
429
+ }
430
+ }
431
+ // Go: 함수 호출 패턴으로 매핑 (import는 패키지 단위라 심볼 매핑 어려움)
432
+ // Java/C#: import/using 은 클래스 단위
433
+ // Rust: use crate::module::Name
434
+ // 범용: 코드 내 함수 호출 참조 수집
435
+ for (const line of content.split('\n')) {
436
+ const trimmed = line.trim();
437
+ const calls = trimmed.matchAll(/\b([a-zA-Z_]\w+)\s*\(/g);
438
+ for (const c of calls) {
439
+ if (!RESERVED_NAMES.has(c[1]))
440
+ referencedNames.add(c[1]);
441
+ }
442
+ }
443
+ return { testFilePath, importedSymbols, referencedNames };
444
+ }
445
+ function resolveImportPath(fromFile, importPath) {
446
+ const dir = dirname(fromFile);
447
+ const cleaned = importPath.replace(/\.[jt]sx?$/, '');
448
+ const resolved = join(dir, cleaned).replace(/\\/g, '/');
449
+ if (resolved.startsWith('..'))
450
+ return null;
451
+ return resolved.replace(/^\.\//, '');
452
+ }
453
+ function buildTestMap(entities, testFiles) {
454
+ const result = new Map();
455
+ const entitiesByFile = new Map();
456
+ const entityByName = new Map();
457
+ for (const e of entities) {
458
+ const list = entitiesByFile.get(e.filePath) ?? [];
459
+ list.push(e);
460
+ entitiesByFile.set(e.filePath, list);
461
+ const nameList = entityByName.get(e.name) ?? [];
462
+ nameList.push(e);
463
+ entityByName.set(e.name, nameList);
464
+ }
465
+ for (const tf of testFiles) {
466
+ // import 기반 매핑 (TS)
467
+ for (const [sourcePath, symbols] of tf.importedSymbols) {
468
+ const candidates = [
469
+ sourcePath + '.ts', sourcePath + '.tsx', sourcePath + '.js',
470
+ sourcePath + '/index.ts', sourcePath,
471
+ ];
472
+ for (const candidate of candidates) {
473
+ const fileEntities = entitiesByFile.get(candidate);
474
+ if (!fileEntities)
475
+ continue;
476
+ for (const entity of fileEntities) {
477
+ if (symbols.has(entity.name)) {
478
+ result.set(`${entity.filePath}::${entity.name}`, { hasTests: true, testFile: tf.testFilePath });
479
+ }
480
+ }
481
+ break;
482
+ }
483
+ }
484
+ // 참조 이름 기반 (범용)
485
+ for (const refName of tf.referencedNames) {
486
+ const matchingEntities = entityByName.get(refName);
487
+ if (!matchingEntities)
488
+ continue;
489
+ for (const entity of matchingEntities) {
490
+ const qName = `${entity.filePath}::${entity.name}`;
491
+ if (result.has(qName))
492
+ continue;
493
+ if (isNearbyTest(entity.filePath, tf.testFilePath)) {
494
+ result.set(qName, { hasTests: true, testFile: tf.testFilePath });
495
+ }
496
+ }
497
+ }
498
+ }
499
+ return result;
500
+ }
501
+ function isNearbyTest(sourceFile, testFile) {
502
+ const sourceDir = dirname(sourceFile);
503
+ const testDir = dirname(testFile);
504
+ const sourceBase = sourceFile.replace(/\.[^.]+$/, '');
505
+ const testBase = testFile
506
+ .replace(/\.test\.[^.]+$|\.spec\.[^.]+$/, '')
507
+ .replace(/_test\.[^.]+$/, '')
508
+ .replace(/Test\.[^.]+$/, '')
509
+ .replace(/Tests\.[^.]+$/, '');
510
+ // 파일명 매칭 (확장자 제외)
511
+ const srcName = sourceBase.split('/').pop();
512
+ const tstName = testBase.split('/').pop();
513
+ if (srcName && tstName && srcName === tstName)
514
+ return true;
515
+ if (sourceDir === testDir)
516
+ return true;
517
+ if (testDir === `${sourceDir}/__tests__`)
518
+ return true;
519
+ if (testDir === `${sourceDir}/tests`)
520
+ return true;
521
+ if (testDir === `${sourceDir}/test`)
522
+ return true;
523
+ const sourceParent = dirname(sourceDir);
524
+ if (testDir === `${sourceParent}/__tests__` || testDir === 'src/__tests__')
525
+ return true;
526
+ return false;
527
+ }
528
+ // ============ 메인 스캔 함수 ============
529
+ export async function scanRepository(projectPath, projectId, options) {
530
+ const startTime = Date.now();
531
+ const maxDepth = options?.maxDepth ?? MAX_DEPTH;
532
+ const timeoutMs = options?.timeoutMs ?? SCAN_TIMEOUT_MS;
533
+ const verbose = options?.verbose ?? false;
534
+ const store = getRegistryStore();
535
+ const allExtracted = [];
536
+ const testFiles = [];
537
+ const errors = [];
538
+ const languageBreakdown = {};
539
+ let scannedFiles = 0;
540
+ async function walk(dirPath, relPath, depth) {
541
+ if (depth > maxDepth)
542
+ return;
543
+ if (Date.now() - startTime > timeoutMs)
544
+ return;
545
+ let entries;
546
+ try {
547
+ entries = await readdir(dirPath, { withFileTypes: true });
548
+ }
549
+ catch (err) {
550
+ if (verbose)
551
+ console.log(` [scan] skip dir ${relPath}: ${err instanceof Error ? err.message : 'access denied'}`);
552
+ return;
553
+ }
554
+ for (const entry of entries) {
555
+ if (Date.now() - startTime > timeoutMs)
556
+ return;
557
+ const fullPath = join(dirPath, entry.name);
558
+ const entryRelPath = relPath ? `${relPath}/${entry.name}` : entry.name;
559
+ if (entry.isDirectory()) {
560
+ if (SKIP_DIRS.has(entry.name) || SKIP_DIR_PREFIXES.some(p => entry.name.startsWith(p)))
561
+ continue;
562
+ await walk(fullPath, entryRelPath, depth + 1);
563
+ }
564
+ else if (entry.isFile()) {
565
+ const ext = extname(entry.name);
566
+ if (!SOURCE_EXTENSIONS.has(ext))
567
+ continue;
568
+ const language = detectLanguage(ext);
569
+ if (!language)
570
+ continue;
571
+ try {
572
+ const fileStat = await stat(fullPath);
573
+ if (fileStat.size > MAX_FILE_SIZE)
574
+ continue;
575
+ }
576
+ catch (err) {
577
+ if (verbose)
578
+ console.log(` [scan] skip stat ${entryRelPath}: ${err instanceof Error ? err.message : 'access denied'}`);
579
+ continue;
580
+ }
581
+ try {
582
+ const content = await readFile(fullPath, 'utf-8');
583
+ if (isTestFile(entry.name, language)) {
584
+ testFiles.push(parseTestFile(content, entryRelPath, language));
585
+ }
586
+ else {
587
+ const entities = extractEntities(content, entryRelPath, language);
588
+ allExtracted.push(...entities);
589
+ scannedFiles++;
590
+ languageBreakdown[language] = (languageBreakdown[language] ?? 0) + 1;
591
+ if (verbose && entities.length > 0) {
592
+ console.log(` [scan] ${entryRelPath}: ${entities.length} entities (${language})`);
593
+ }
594
+ }
595
+ }
596
+ catch (err) {
597
+ errors.push(`${entryRelPath}: ${err instanceof Error ? err.message : String(err)}`);
598
+ }
599
+ }
600
+ }
601
+ }
602
+ await walk(projectPath, '', 0);
603
+ // 테스트 매핑 빌드
604
+ const testMap = buildTestMap(allExtracted, testFiles);
605
+ if (verbose && testMap.size > 0) {
606
+ console.log(` [test-map] ${testMap.size} entities mapped to tests`);
607
+ }
608
+ // 레지스트리 동기화
609
+ const existing = store.listEntities({ projectId, limit: 100_000, offset: 0 });
610
+ const existingByQName = new Map(existing.entities.map(e => [e.qualifiedName, e]));
611
+ const extractedQNames = new Set();
612
+ let registered = 0;
613
+ let updated = 0;
614
+ let testsMapped = 0;
615
+ for (const ext of allExtracted) {
616
+ const qualifiedName = `${ext.filePath}::${ext.name}`;
617
+ extractedQNames.add(qualifiedName);
618
+ const testInfo = testMap.get(qualifiedName);
619
+ const hasTests = testInfo?.hasTests ?? false;
620
+ const testFile = testInfo?.testFile;
621
+ const score = computeComplexityFromMetrics(ext.loc, ext.nestingDepth, ext.paramCount);
622
+ const riskLevel = computeRisk(score, hasTests);
623
+ if (hasTests)
624
+ testsMapped++;
625
+ const existingEntity = existingByQName.get(qualifiedName);
626
+ if (!existingEntity) {
627
+ try {
628
+ store.registerEntity({
629
+ projectId,
630
+ kind: ext.kind,
631
+ name: ext.name,
632
+ filePath: ext.filePath,
633
+ lineStart: ext.lineStart,
634
+ lineEnd: ext.lineEnd,
635
+ signature: ext.signature,
636
+ status: 'active',
637
+ hasTests,
638
+ testFile,
639
+ complexityScore: score,
640
+ riskLevel,
641
+ author: 'scanner',
642
+ });
643
+ registered++;
644
+ }
645
+ catch (err) {
646
+ if (!(err instanceof Error && err.message.includes('UNIQUE'))) {
647
+ errors.push(`register ${qualifiedName}: ${err instanceof Error ? err.message : String(err)}`);
648
+ }
649
+ }
650
+ }
651
+ else {
652
+ const needsUpdate = existingEntity.lineStart !== ext.lineStart ||
653
+ existingEntity.lineEnd !== ext.lineEnd ||
654
+ existingEntity.signature !== ext.signature ||
655
+ existingEntity.hasTests !== hasTests ||
656
+ existingEntity.testFile !== testFile ||
657
+ existingEntity.complexityScore !== score ||
658
+ existingEntity.riskLevel !== riskLevel;
659
+ if (needsUpdate) {
660
+ store.updateEntity(existingEntity.id, {
661
+ lineStart: ext.lineStart,
662
+ lineEnd: ext.lineEnd,
663
+ signature: ext.signature,
664
+ hasTests,
665
+ testFile,
666
+ complexityScore: score,
667
+ riskLevel,
668
+ }, 'scanner');
669
+ updated++;
670
+ }
671
+ }
672
+ }
673
+ // 사라진 엔티티 → broken
674
+ let removed = 0;
675
+ for (const [qName, entity] of existingByQName) {
676
+ if (!extractedQNames.has(qName) && entity.author === 'scanner' && entity.status === 'active') {
677
+ store.changeEntityStatus(entity.id, 'broken', 'scanner');
678
+ removed++;
679
+ }
680
+ }
681
+ return {
682
+ scanned: scannedFiles,
683
+ extracted: allExtracted.length,
684
+ registered,
685
+ updated,
686
+ removed,
687
+ testsMapped,
688
+ errors,
689
+ durationMs: Date.now() - startTime,
690
+ languageBreakdown,
691
+ };
692
+ }
693
+ //# sourceMappingURL=entityScanner.js.map